UDM-net.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. The U-Boot Driver Model Project
  2. ===============================
  3. Net system analysis
  4. ===================
  5. Marek Vasut <marek.vasut@gmail.com>
  6. 2012-03-03
  7. I) Overview
  8. -----------
  9. The networking subsystem already supports multiple devices. Therefore the
  10. conversion shall not be very hard.
  11. The network subsystem is operated from net/eth.c, which tracks all registered
  12. ethernet interfaces and calls their particular functions registered via
  13. eth_register().
  14. The eth_register() is called from the network driver initialization function,
  15. which in turn is called most often either from "board_net_init()" or
  16. "cpu_net_init()". This function has one important argument, which is the
  17. "struct eth_device", defined at include/net.h:
  18. struct eth_device {
  19. /* DRIVER: Name of the device */
  20. char name[NAMESIZE];
  21. /* DRIVER: MAC address */
  22. unsigned char enetaddr[6];
  23. /* DRIVER: Register base address */
  24. int iobase;
  25. /* CORE: state of the device */
  26. int state;
  27. /* DRIVER: Device initialization function */
  28. int (*init) (struct eth_device*, bd_t*);
  29. /* DRIVER: Function for sending packets */
  30. int (*send) (struct eth_device*, volatile void* packet, int length);
  31. /* DRIVER: Function for receiving packets */
  32. int (*recv) (struct eth_device*);
  33. /* DRIVER: Function to cease operation of the device */
  34. void (*halt) (struct eth_device*);
  35. /* DRIVER: Function to send multicast packet (OPTIONAL) */
  36. int (*mcast) (struct eth_device*, u32 ip, u8 set);
  37. /* DRIVER: Function to change ethernet MAC address */
  38. int (*write_hwaddr) (struct eth_device*);
  39. /* CORE: Next device in the linked list of devices managed by net core */
  40. struct eth_device *next;
  41. /* CORE: Device index */
  42. int index;
  43. /* DRIVER: Driver's private data */
  44. void *priv;
  45. };
  46. This structure defines the particular driver, though also contains elements that
  47. should not be exposed to the driver, like core state.
  48. Small, but important part of the networking subsystem is the PHY management
  49. layer, whose drivers are contained in drivers/net/phy. These drivers register in
  50. a very similar manner to network drivers, by calling "phy_register()" with the
  51. argument of "struct phy_driver":
  52. struct phy_driver {
  53. /* DRIVER: Name of the PHY driver */
  54. char *name;
  55. /* DRIVER: UID of the PHY driver */
  56. unsigned int uid;
  57. /* DRIVER: Mask for UID of the PHY driver */
  58. unsigned int mask;
  59. /* DRIVER: MMDS of the PHY driver */
  60. unsigned int mmds;
  61. /* DRIVER: Features the PHY driver supports */
  62. u32 features;
  63. /* DRIVER: Initialize the PHY hardware */
  64. int (*probe)(struct phy_device *phydev);
  65. /* DRIVER: Reconfigure the PHY hardware */
  66. int (*config)(struct phy_device *phydev);
  67. /* DRIVER: Turn on the PHY hardware, allow it to send/receive */
  68. int (*startup)(struct phy_device *phydev);
  69. /* DRIVER: Turn off the PHY hardware */
  70. int (*shutdown)(struct phy_device *phydev);
  71. /* CORE: Allows this driver to be part of list of drivers */
  72. struct list_head list;
  73. };
  74. II) Approach
  75. ------------
  76. To convert the elements of network subsystem to proper driver model method, the
  77. "struct eth_device" will have to be split into multiple components. The first
  78. will be a structure defining the driver operations:
  79. struct eth_driver_ops {
  80. int (*init)(struct instance*, bd_t*);
  81. int (*send)(struct instance*, void *packet, int length);
  82. int (*recv)(struct instance*);
  83. void (*halt)(struct instance*);
  84. int (*mcast)(struct instance*, u32 ip, u8 set);
  85. int (*write_hwaddr)(struct instance*);
  86. };
  87. Next, there'll be platform data which will be per-driver and will replace the
  88. "priv" part of "struct eth_device". Last part will be the per-device core state.
  89. With regards to the PHY part of the API, the "struct phy_driver" is almost ready
  90. to be used with the new driver model approach. The only change will be the
  91. replacement of per-driver initialization functions and removal of
  92. "phy_register()" function in favor or driver model approach.
  93. III) Analysis of in-tree drivers
  94. --------------------------------
  95. 1) drivers/net/4xx_enet.c
  96. -------------------------
  97. This driver uses the standard new networking API, therefore there should be no
  98. obstacles throughout the conversion process.
  99. 2) drivers/net/altera_tse.c
  100. ---------------------------
  101. This driver uses the standard new networking API, therefore there should be no
  102. obstacles throughout the conversion process.
  103. 3) drivers/net/armada100_fec.c
  104. ------------------------------
  105. This driver uses the standard new networking API, therefore there should be no
  106. obstacles throughout the conversion process.
  107. 4) drivers/net/at91_emac.c
  108. --------------------------
  109. This driver uses the standard new networking API, therefore there should be no
  110. obstacles throughout the conversion process.
  111. 5) drivers/net/ax88180.c
  112. ------------------------
  113. This driver uses the standard new networking API, therefore there should be no
  114. obstacles throughout the conversion process.
  115. 6) drivers/net/ax88796.c
  116. ------------------------
  117. This file contains a components of the NE2000 driver, implementing only
  118. different parts on the NE2000 clone AX88796. This being no standalone driver,
  119. no conversion will be done here.
  120. 7) drivers/net/bfin_mac.c
  121. -------------------------
  122. This driver uses the standard new networking API, therefore there should be no
  123. obstacles throughout the conversion process.
  124. 8) drivers/net/calxedaxgmac.c
  125. -----------------------------
  126. This driver uses the standard new networking API, therefore there should be no
  127. obstacles throughout the conversion process.
  128. 9) drivers/net/cs8900.c
  129. -----------------------
  130. This driver uses the standard new networking API, therefore there should be no
  131. obstacles throughout the conversion process.
  132. 10) drivers/net/davinci_emac.c
  133. ------------------------------
  134. This driver uses the standard new networking API, therefore there should be no
  135. obstacles throughout the conversion process.
  136. 11) drivers/net/dc2114x.c
  137. -------------------------
  138. This driver uses the standard new networking API, therefore there should be no
  139. obstacles throughout the conversion process.
  140. 12) drivers/net/designware.c
  141. ----------------------------
  142. This driver uses the standard new networking API, therefore there should be no
  143. obstacles throughout the conversion process.
  144. 13) drivers/net/dm9000x.c
  145. -------------------------
  146. This driver uses the standard new networking API, therefore there should be no
  147. obstacles throughout the conversion process.
  148. 14) drivers/net/dnet.c
  149. ----------------------
  150. This driver uses the standard new networking API, therefore there should be no
  151. obstacles throughout the conversion process.
  152. 15) drivers/net/e1000.c
  153. -----------------------
  154. This driver uses the standard new networking API, therefore there should be no
  155. obstacles throughout the conversion process.
  156. 16) drivers/net/e1000_spi.c
  157. ---------------------------
  158. Driver for the SPI bus integrated on the Intel E1000. This is not part of the
  159. network stack.
  160. 17) drivers/net/eepro100.c
  161. --------------------------
  162. This driver uses the standard new networking API, therefore there should be no
  163. obstacles throughout the conversion process.
  164. 18) drivers/net/enc28j60.c
  165. --------------------------
  166. This driver uses the standard new networking API, therefore there should be no
  167. obstacles throughout the conversion process.
  168. 19) drivers/net/ep93xx_eth.c
  169. ----------------------------
  170. This driver uses the standard new networking API, therefore there should be no
  171. obstacles throughout the conversion process.
  172. 20) drivers/net/ethoc.c
  173. -----------------------
  174. This driver uses the standard new networking API, therefore there should be no
  175. obstacles throughout the conversion process.
  176. 21) drivers/net/fec_mxc.c
  177. -------------------------
  178. This driver uses the standard new networking API, therefore there should be no
  179. obstacles throughout the conversion process.
  180. 22) drivers/net/fsl_mcdmafec.c
  181. ------------------------------
  182. This driver uses the standard new networking API, therefore there should be no
  183. obstacles throughout the conversion process.
  184. 23) drivers/net/fsl_mdio.c
  185. --------------------------
  186. This file contains driver for FSL MDIO interface, which is not part of the
  187. networking stack.
  188. 24) drivers/net/ftgmac100.c
  189. ---------------------------
  190. This driver uses the standard new networking API, therefore there should be no
  191. obstacles throughout the conversion process.
  192. 25) drivers/net/ftmac100.c
  193. --------------------------
  194. This driver uses the standard new networking API, therefore there should be no
  195. obstacles throughout the conversion process.
  196. 26) drivers/net/greth.c
  197. -----------------------
  198. This driver uses the standard new networking API, therefore there should be no
  199. obstacles throughout the conversion process.
  200. 27) drivers/net/inca-ip_sw.c
  201. ----------------------------
  202. This driver uses the standard new networking API, therefore there should be no
  203. obstacles throughout the conversion process.
  204. 28) drivers/net/ks8695eth.c
  205. ---------------------------
  206. This driver uses the standard new networking API, therefore there should be no
  207. obstacles throughout the conversion process.
  208. 29) drivers/net/lan91c96.c
  209. --------------------------
  210. This driver uses the standard new networking API, therefore there should be no
  211. obstacles throughout the conversion process.
  212. 30) drivers/net/macb.c
  213. ----------------------
  214. This driver uses the standard new networking API, therefore there should be no
  215. obstacles throughout the conversion process.
  216. 31) drivers/net/mcffec.c
  217. ------------------------
  218. This driver uses the standard new networking API, therefore there should be no
  219. obstacles throughout the conversion process.
  220. 32) drivers/net/mcfmii.c
  221. ------------------------
  222. This file contains MII interface driver for MCF FEC.
  223. 33) drivers/net/mpc512x_fec.c
  224. -----------------------------
  225. This driver uses the standard new networking API, therefore there should be no
  226. obstacles throughout the conversion process.
  227. 34) drivers/net/mpc5xxx_fec.c
  228. -----------------------------
  229. This driver uses the standard new networking API, therefore there should be no
  230. obstacles throughout the conversion process.
  231. 35) drivers/net/mvgbe.c
  232. -----------------------
  233. This driver uses the standard new networking API, therefore there should be no
  234. obstacles throughout the conversion process.
  235. 36) drivers/net/natsemi.c
  236. -------------------------
  237. This driver uses the standard new networking API, therefore there should be no
  238. obstacles throughout the conversion process.
  239. 37) drivers/net/ne2000_base.c
  240. -----------------------------
  241. This driver uses the standard new networking API, therefore there should be no
  242. obstacles throughout the conversion process. This driver contains the core
  243. implementation of NE2000, which needs a few external functions, implemented by
  244. AX88796, NE2000 etc.
  245. 38) drivers/net/ne2000.c
  246. ------------------------
  247. This file implements external functions necessary for native NE2000 compatible
  248. networking card to work.
  249. 39) drivers/net/netarm_eth.c
  250. ----------------------------
  251. This driver uses the old, legacy, network API and will either have to be
  252. converted or removed.
  253. 40) drivers/net/netconsole.c
  254. ----------------------------
  255. This is actually an STDIO driver.
  256. 41) drivers/net/ns8382x.c
  257. -------------------------
  258. This driver uses the standard new networking API, therefore there should be no
  259. obstacles throughout the conversion process.
  260. 42) drivers/net/pcnet.c
  261. -----------------------
  262. This driver uses the standard new networking API, therefore there should be no
  263. obstacles throughout the conversion process.
  264. 43) drivers/net/plb2800_eth.c
  265. -----------------------------
  266. This driver uses the standard new networking API, therefore there should be no
  267. obstacles throughout the conversion process.
  268. 44) drivers/net/rtl8139.c
  269. -------------------------
  270. This driver uses the standard new networking API, therefore there should be no
  271. obstacles throughout the conversion process.
  272. 45) drivers/net/rtl8169.c
  273. -------------------------
  274. This driver uses the standard new networking API, therefore there should be no
  275. obstacles throughout the conversion process.
  276. 46) drivers/net/sh_eth.c
  277. ------------------------
  278. This driver uses the standard new networking API, therefore there should be no
  279. obstacles throughout the conversion process.
  280. 47) drivers/net/smc91111.c
  281. --------------------------
  282. This driver uses the standard new networking API, therefore there should be no
  283. obstacles throughout the conversion process.
  284. 48) drivers/net/smc911x.c
  285. -------------------------
  286. This driver uses the standard new networking API, therefore there should be no
  287. obstacles throughout the conversion process.
  288. 49) drivers/net/tsec.c
  289. ----------------------
  290. This driver uses the standard new networking API, therefore there should be no
  291. obstacles throughout the conversion process.
  292. 50) drivers/net/tsi108_eth.c
  293. ----------------------------
  294. This driver uses the standard new networking API, therefore there should be no
  295. obstacles throughout the conversion process.
  296. 51) drivers/net/uli526x.c
  297. -------------------------
  298. This driver uses the standard new networking API, therefore there should be no
  299. obstacles throughout the conversion process.
  300. 52) drivers/net/vsc7385.c
  301. -------------------------
  302. This is a driver that only uploads firmware to a switch. This is not subject
  303. of conversion.
  304. 53) drivers/net/xilinx_axi_emac.c
  305. ---------------------------------
  306. This driver uses the standard new networking API, therefore there should be no
  307. obstacles throughout the conversion process.
  308. 54) drivers/net/xilinx_emaclite.c
  309. ---------------------------------
  310. This driver uses the standard new networking API, therefore there should be no
  311. obstacles throughout the conversion process.