You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

netdevice.h 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. #ifndef _IPXE_NETDEVICE_H
  2. #define _IPXE_NETDEVICE_H
  3. /** @file
  4. *
  5. * Network device management
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/list.h>
  11. #include <ipxe/tables.h>
  12. #include <ipxe/refcnt.h>
  13. #include <ipxe/settings.h>
  14. #include <ipxe/interface.h>
  15. struct io_buffer;
  16. struct net_device;
  17. struct net_protocol;
  18. struct ll_protocol;
  19. struct device;
  20. /** Maximum length of a hardware address
  21. *
  22. * The longest currently-supported link-layer address is for IPoIB.
  23. */
  24. #define MAX_HW_ADDR_LEN 8
  25. /** Maximum length of a link-layer address
  26. *
  27. * The longest currently-supported link-layer address is for IPoIB.
  28. */
  29. #define MAX_LL_ADDR_LEN 20
  30. /** Maximum length of a link-layer header
  31. *
  32. * The longest currently-supported link-layer header is for RNDIS: an
  33. * 8-byte RNDIS header, a 32-byte RNDIS packet message header, a
  34. * 14-byte Ethernet header and a possible 4-byte VLAN header. Round
  35. * up to 64 bytes.
  36. */
  37. #define MAX_LL_HEADER_LEN 64
  38. /** Maximum length of a network-layer address */
  39. #define MAX_NET_ADDR_LEN 16
  40. /** Maximum length of a network-layer header
  41. *
  42. * The longest currently-supported network-layer header is for IPv6 at
  43. * 40 bytes.
  44. */
  45. #define MAX_NET_HEADER_LEN 40
  46. /** Maximum combined length of a link-layer and network-layer header */
  47. #define MAX_LL_NET_HEADER_LEN ( MAX_LL_HEADER_LEN + MAX_NET_HEADER_LEN )
  48. /**
  49. * A network-layer protocol
  50. *
  51. */
  52. struct net_protocol {
  53. /** Protocol name */
  54. const char *name;
  55. /**
  56. * Process received packet
  57. *
  58. * @v iobuf I/O buffer
  59. * @v netdev Network device
  60. * @v ll_dest Link-layer destination address
  61. * @v ll_source Link-layer source address
  62. * @v flags Packet flags
  63. * @ret rc Return status code
  64. *
  65. * This method takes ownership of the I/O buffer.
  66. */
  67. int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
  68. const void *ll_dest, const void *ll_source,
  69. unsigned int flags );
  70. /**
  71. * Transcribe network-layer address
  72. *
  73. * @v net_addr Network-layer address
  74. * @ret string Human-readable transcription of address
  75. *
  76. * This method should convert the network-layer address into a
  77. * human-readable format (e.g. dotted quad notation for IPv4).
  78. *
  79. * The buffer used to hold the transcription is statically
  80. * allocated.
  81. */
  82. const char * ( *ntoa ) ( const void * net_addr );
  83. /** Network-layer protocol
  84. *
  85. * This is an ETH_P_XXX constant, in network-byte order
  86. */
  87. uint16_t net_proto;
  88. /** Network-layer address length */
  89. uint8_t net_addr_len;
  90. };
  91. /** Packet is a multicast (including broadcast) packet */
  92. #define LL_MULTICAST 0x0001
  93. /** Packet is a broadcast packet */
  94. #define LL_BROADCAST 0x0002
  95. /**
  96. * A link-layer protocol
  97. *
  98. */
  99. struct ll_protocol {
  100. /** Protocol name */
  101. const char *name;
  102. /**
  103. * Add link-layer header
  104. *
  105. * @v netdev Network device
  106. * @v iobuf I/O buffer
  107. * @v ll_dest Link-layer destination address
  108. * @v ll_source Source link-layer address
  109. * @v net_proto Network-layer protocol, in network-byte order
  110. * @ret rc Return status code
  111. */
  112. int ( * push ) ( struct net_device *netdev, struct io_buffer *iobuf,
  113. const void *ll_dest, const void *ll_source,
  114. uint16_t net_proto );
  115. /**
  116. * Remove link-layer header
  117. *
  118. * @v netdev Network device
  119. * @v iobuf I/O buffer
  120. * @ret ll_dest Link-layer destination address
  121. * @ret ll_source Source link-layer address
  122. * @ret net_proto Network-layer protocol, in network-byte order
  123. * @ret flags Packet flags
  124. * @ret rc Return status code
  125. */
  126. int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
  127. const void **ll_dest, const void **ll_source,
  128. uint16_t *net_proto, unsigned int *flags );
  129. /**
  130. * Initialise link-layer address
  131. *
  132. * @v hw_addr Hardware address
  133. * @v ll_addr Link-layer address to fill in
  134. */
  135. void ( * init_addr ) ( const void *hw_addr, void *ll_addr );
  136. /**
  137. * Transcribe link-layer address
  138. *
  139. * @v ll_addr Link-layer address
  140. * @ret string Human-readable transcription of address
  141. *
  142. * This method should convert the link-layer address into a
  143. * human-readable format.
  144. *
  145. * The buffer used to hold the transcription is statically
  146. * allocated.
  147. */
  148. const char * ( * ntoa ) ( const void *ll_addr );
  149. /**
  150. * Hash multicast address
  151. *
  152. * @v af Address family
  153. * @v net_addr Network-layer address
  154. * @v ll_addr Link-layer address to fill in
  155. * @ret rc Return status code
  156. */
  157. int ( * mc_hash ) ( unsigned int af, const void *net_addr,
  158. void *ll_addr );
  159. /**
  160. * Generate Ethernet-compatible compressed link-layer address
  161. *
  162. * @v ll_addr Link-layer address
  163. * @v eth_addr Ethernet-compatible address to fill in
  164. * @ret rc Return status code
  165. */
  166. int ( * eth_addr ) ( const void *ll_addr, void *eth_addr );
  167. /**
  168. * Generate EUI-64 address
  169. *
  170. * @v ll_addr Link-layer address
  171. * @v eui64 EUI-64 address to fill in
  172. * @ret rc Return status code
  173. */
  174. int ( * eui64 ) ( const void *ll_addr, void *eui64 );
  175. /** Link-layer protocol
  176. *
  177. * This is an ARPHRD_XXX constant, in network byte order.
  178. */
  179. uint16_t ll_proto;
  180. /** Hardware address length */
  181. uint8_t hw_addr_len;
  182. /** Link-layer address length */
  183. uint8_t ll_addr_len;
  184. /** Link-layer header length */
  185. uint8_t ll_header_len;
  186. /** Flags */
  187. unsigned int flags;
  188. };
  189. /** Local link-layer address functions only as a name
  190. *
  191. * This flag indicates that the local link-layer address cannot
  192. * directly be used as a destination address by a remote node.
  193. */
  194. #define LL_NAME_ONLY 0x0001
  195. /** Network device operations */
  196. struct net_device_operations {
  197. /** Open network device
  198. *
  199. * @v netdev Network device
  200. * @ret rc Return status code
  201. *
  202. * This method should allocate RX I/O buffers and enable
  203. * the hardware to start transmitting and receiving packets.
  204. */
  205. int ( * open ) ( struct net_device *netdev );
  206. /** Close network device
  207. *
  208. * @v netdev Network device
  209. *
  210. * This method should stop the flow of packets, and free up
  211. * any packets that are currently in the device's TX queue.
  212. */
  213. void ( * close ) ( struct net_device *netdev );
  214. /** Transmit packet
  215. *
  216. * @v netdev Network device
  217. * @v iobuf I/O buffer
  218. * @ret rc Return status code
  219. *
  220. * This method should cause the hardware to initiate
  221. * transmission of the I/O buffer.
  222. *
  223. * If this method returns success, the I/O buffer remains
  224. * owned by the net device's TX queue, and the net device must
  225. * eventually call netdev_tx_complete() to free the buffer.
  226. * If this method returns failure, the I/O buffer is
  227. * immediately released; the failure is interpreted as
  228. * "failure to enqueue buffer".
  229. *
  230. * This method is guaranteed to be called only when the device
  231. * is open.
  232. */
  233. int ( * transmit ) ( struct net_device *netdev,
  234. struct io_buffer *iobuf );
  235. /** Poll for completed and received packets
  236. *
  237. * @v netdev Network device
  238. *
  239. * This method should cause the hardware to check for
  240. * completed transmissions and received packets. Any received
  241. * packets should be delivered via netdev_rx().
  242. *
  243. * This method is guaranteed to be called only when the device
  244. * is open.
  245. */
  246. void ( * poll ) ( struct net_device *netdev );
  247. /** Enable or disable interrupts
  248. *
  249. * @v netdev Network device
  250. * @v enable Interrupts should be enabled
  251. *
  252. * This method may be NULL to indicate that interrupts are not
  253. * supported.
  254. */
  255. void ( * irq ) ( struct net_device *netdev, int enable );
  256. };
  257. /** Network device error */
  258. struct net_device_error {
  259. /** Error status code */
  260. int rc;
  261. /** Error count */
  262. unsigned int count;
  263. };
  264. /** Maximum number of unique errors that we will keep track of */
  265. #define NETDEV_MAX_UNIQUE_ERRORS 4
  266. /** Network device statistics */
  267. struct net_device_stats {
  268. /** Count of successful completions */
  269. unsigned int good;
  270. /** Count of error completions */
  271. unsigned int bad;
  272. /** Error breakdowns */
  273. struct net_device_error errors[NETDEV_MAX_UNIQUE_ERRORS];
  274. };
  275. /** A network device configuration */
  276. struct net_device_configuration {
  277. /** Network device */
  278. struct net_device *netdev;
  279. /** Network device configurator */
  280. struct net_device_configurator *configurator;
  281. /** Configuration status */
  282. int rc;
  283. /** Job control interface */
  284. struct interface job;
  285. };
  286. /** A network device configurator */
  287. struct net_device_configurator {
  288. /** Name */
  289. const char *name;
  290. /** Check applicability of configurator
  291. *
  292. * @v netdev Network device
  293. * @ret applies Configurator applies to this network device
  294. */
  295. int ( * applies ) ( struct net_device *netdev );
  296. /** Start configuring network device
  297. *
  298. * @v job Job control interface
  299. * @v netdev Network device
  300. * @ret rc Return status code
  301. */
  302. int ( * start ) ( struct interface *job, struct net_device *netdev );
  303. };
  304. /** Network device configurator table */
  305. #define NET_DEVICE_CONFIGURATORS \
  306. __table ( struct net_device_configurator, "net_device_configurators" )
  307. /** Declare a network device configurator */
  308. #define __net_device_configurator \
  309. __table_entry ( NET_DEVICE_CONFIGURATORS, 01 )
  310. /** Maximum length of a network device name */
  311. #define NETDEV_NAME_LEN 12
  312. /**
  313. * A network device
  314. *
  315. * This structure represents a piece of networking hardware. It has
  316. * properties such as a link-layer address and methods for
  317. * transmitting and receiving raw packets.
  318. *
  319. * Note that this structure must represent a generic network device,
  320. * not just an Ethernet device.
  321. */
  322. struct net_device {
  323. /** Reference counter */
  324. struct refcnt refcnt;
  325. /** List of network devices */
  326. struct list_head list;
  327. /** List of open network devices */
  328. struct list_head open_list;
  329. /** Index of this network device */
  330. unsigned int index;
  331. /** Name of this network device */
  332. char name[NETDEV_NAME_LEN];
  333. /** Underlying hardware device */
  334. struct device *dev;
  335. /** Network device operations */
  336. struct net_device_operations *op;
  337. /** Link-layer protocol */
  338. struct ll_protocol *ll_protocol;
  339. /** Hardware address
  340. *
  341. * This is an address which is an intrinsic property of the
  342. * hardware, e.g. an address held in EEPROM.
  343. *
  344. * Note that the hardware address may not be the same length
  345. * as the link-layer address.
  346. */
  347. uint8_t hw_addr[MAX_HW_ADDR_LEN];
  348. /** Link-layer address
  349. *
  350. * This is the current link-layer address assigned to the
  351. * device. It can be changed at runtime.
  352. */
  353. uint8_t ll_addr[MAX_LL_ADDR_LEN];
  354. /** Link-layer broadcast address */
  355. const uint8_t *ll_broadcast;
  356. /** Current device state
  357. *
  358. * This is the bitwise-OR of zero or more NETDEV_XXX constants.
  359. */
  360. unsigned int state;
  361. /** Link status code
  362. *
  363. * Zero indicates that the link is up; any other value
  364. * indicates the error preventing link-up.
  365. */
  366. int link_rc;
  367. /** Maximum packet length
  368. *
  369. * This length includes any link-layer headers.
  370. */
  371. size_t max_pkt_len;
  372. /** TX packet queue */
  373. struct list_head tx_queue;
  374. /** Deferred TX packet queue */
  375. struct list_head tx_deferred;
  376. /** RX packet queue */
  377. struct list_head rx_queue;
  378. /** TX statistics */
  379. struct net_device_stats tx_stats;
  380. /** RX statistics */
  381. struct net_device_stats rx_stats;
  382. /** Configuration settings applicable to this device */
  383. struct generic_settings settings;
  384. /** Driver private data */
  385. void *priv;
  386. /** Network device configurations (variable length) */
  387. struct net_device_configuration configs[0];
  388. };
  389. /** Network device is open */
  390. #define NETDEV_OPEN 0x0001
  391. /** Network device interrupts are enabled */
  392. #define NETDEV_IRQ_ENABLED 0x0002
  393. /** Network device receive queue processing is frozen */
  394. #define NETDEV_RX_FROZEN 0x0004
  395. /** Link-layer protocol table */
  396. #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
  397. /** Declare a link-layer protocol */
  398. #define __ll_protocol __table_entry ( LL_PROTOCOLS, 01 )
  399. /** Network-layer protocol table */
  400. #define NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" )
  401. /** Declare a network-layer protocol */
  402. #define __net_protocol __table_entry ( NET_PROTOCOLS, 01 )
  403. /** A network upper-layer driver */
  404. struct net_driver {
  405. /** Name */
  406. const char *name;
  407. /** Probe device
  408. *
  409. * @v netdev Network device
  410. * @ret rc Return status code
  411. */
  412. int ( * probe ) ( struct net_device *netdev );
  413. /** Notify of device or link state change
  414. *
  415. * @v netdev Network device
  416. */
  417. void ( * notify ) ( struct net_device *netdev );
  418. /** Remove device
  419. *
  420. * @v netdev Network device
  421. */
  422. void ( * remove ) ( struct net_device *netdev );
  423. };
  424. /** Network driver table */
  425. #define NET_DRIVERS __table ( struct net_driver, "net_drivers" )
  426. /** Declare a network driver */
  427. #define __net_driver __table_entry ( NET_DRIVERS, 01 )
  428. extern struct list_head net_devices;
  429. extern struct net_device_operations null_netdev_operations;
  430. extern struct settings_operations netdev_settings_operations;
  431. /**
  432. * Initialise a network device
  433. *
  434. * @v netdev Network device
  435. * @v op Network device operations
  436. */
  437. static inline void netdev_init ( struct net_device *netdev,
  438. struct net_device_operations *op ) {
  439. netdev->op = op;
  440. }
  441. /**
  442. * Stop using a network device
  443. *
  444. * @v netdev Network device
  445. *
  446. * Drivers should call this method immediately before the final call
  447. * to netdev_put().
  448. */
  449. static inline void netdev_nullify ( struct net_device *netdev ) {
  450. netdev->op = &null_netdev_operations;
  451. }
  452. /**
  453. * Get printable network device link-layer address
  454. *
  455. * @v netdev Network device
  456. * @ret name Link-layer address
  457. */
  458. static inline const char * netdev_addr ( struct net_device *netdev ) {
  459. return netdev->ll_protocol->ntoa ( netdev->ll_addr );
  460. }
  461. /** Iterate over all network devices */
  462. #define for_each_netdev( netdev ) \
  463. list_for_each_entry ( (netdev), &net_devices, list )
  464. /** There exist some network devices
  465. *
  466. * @ret existence Existence of network devices
  467. */
  468. static inline int have_netdevs ( void ) {
  469. return ( ! list_empty ( &net_devices ) );
  470. }
  471. /**
  472. * Get reference to network device
  473. *
  474. * @v netdev Network device
  475. * @ret netdev Network device
  476. */
  477. static inline __attribute__ (( always_inline )) struct net_device *
  478. netdev_get ( struct net_device *netdev ) {
  479. ref_get ( &netdev->refcnt );
  480. return netdev;
  481. }
  482. /**
  483. * Drop reference to network device
  484. *
  485. * @v netdev Network device
  486. */
  487. static inline __attribute__ (( always_inline )) void
  488. netdev_put ( struct net_device *netdev ) {
  489. ref_put ( &netdev->refcnt );
  490. }
  491. /**
  492. * Get driver private area for this network device
  493. *
  494. * @v netdev Network device
  495. * @ret priv Driver private area for this network device
  496. */
  497. static inline __attribute__ (( always_inline )) void *
  498. netdev_priv ( struct net_device *netdev ) {
  499. return netdev->priv;
  500. }
  501. /**
  502. * Get per-netdevice configuration settings block
  503. *
  504. * @v netdev Network device
  505. * @ret settings Settings block
  506. */
  507. static inline __attribute__ (( always_inline )) struct settings *
  508. netdev_settings ( struct net_device *netdev ) {
  509. return &netdev->settings.settings;
  510. }
  511. /**
  512. * Initialise a per-netdevice configuration settings block
  513. *
  514. * @v generics Generic settings block
  515. * @v refcnt Containing object reference counter, or NULL
  516. * @v name Settings block name
  517. */
  518. static inline __attribute__ (( always_inline )) void
  519. netdev_settings_init ( struct net_device *netdev ) {
  520. generic_settings_init ( &netdev->settings, &netdev->refcnt );
  521. netdev->settings.settings.op = &netdev_settings_operations;
  522. }
  523. /**
  524. * Get network device configuration
  525. *
  526. * @v netdev Network device
  527. * @v configurator Network device configurator
  528. * @ret config Network device configuration
  529. */
  530. static inline struct net_device_configuration *
  531. netdev_configuration ( struct net_device *netdev,
  532. struct net_device_configurator *configurator ) {
  533. return &netdev->configs[ table_index ( NET_DEVICE_CONFIGURATORS,
  534. configurator ) ];
  535. }
  536. /**
  537. * Check if configurator applies to network device
  538. *
  539. * @v netdev Network device
  540. * @v configurator Network device configurator
  541. * @ret applies Configurator applies to network device
  542. */
  543. static inline int
  544. netdev_configurator_applies ( struct net_device *netdev,
  545. struct net_device_configurator *configurator ) {
  546. return ( ( configurator->applies == NULL ) ||
  547. configurator->applies ( netdev ) );
  548. }
  549. /**
  550. * Check link state of network device
  551. *
  552. * @v netdev Network device
  553. * @ret link_up Link is up
  554. */
  555. static inline __attribute__ (( always_inline )) int
  556. netdev_link_ok ( struct net_device *netdev ) {
  557. return ( netdev->link_rc == 0 );
  558. }
  559. /**
  560. * Check whether or not network device is open
  561. *
  562. * @v netdev Network device
  563. * @ret is_open Network device is open
  564. */
  565. static inline __attribute__ (( always_inline )) int
  566. netdev_is_open ( struct net_device *netdev ) {
  567. return ( netdev->state & NETDEV_OPEN );
  568. }
  569. /**
  570. * Check whether or not network device supports interrupts
  571. *
  572. * @v netdev Network device
  573. * @ret irq_supported Network device supports interrupts
  574. */
  575. static inline __attribute__ (( always_inline )) int
  576. netdev_irq_supported ( struct net_device *netdev ) {
  577. return ( netdev->op->irq != NULL );
  578. }
  579. /**
  580. * Check whether or not network device interrupts are currently enabled
  581. *
  582. * @v netdev Network device
  583. * @ret irq_enabled Network device interrupts are enabled
  584. */
  585. static inline __attribute__ (( always_inline )) int
  586. netdev_irq_enabled ( struct net_device *netdev ) {
  587. return ( netdev->state & NETDEV_IRQ_ENABLED );
  588. }
  589. /**
  590. * Check whether or not network device receive queue processing is frozen
  591. *
  592. * @v netdev Network device
  593. * @ret rx_frozen Network device receive queue processing is frozen
  594. */
  595. static inline __attribute__ (( always_inline )) int
  596. netdev_rx_frozen ( struct net_device *netdev ) {
  597. return ( netdev->state & NETDEV_RX_FROZEN );
  598. }
  599. extern void netdev_rx_freeze ( struct net_device *netdev );
  600. extern void netdev_rx_unfreeze ( struct net_device *netdev );
  601. extern void netdev_link_err ( struct net_device *netdev, int rc );
  602. extern void netdev_link_down ( struct net_device *netdev );
  603. extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
  604. extern void netdev_tx_defer ( struct net_device *netdev,
  605. struct io_buffer *iobuf );
  606. extern void netdev_tx_err ( struct net_device *netdev,
  607. struct io_buffer *iobuf, int rc );
  608. extern void netdev_tx_complete_err ( struct net_device *netdev,
  609. struct io_buffer *iobuf, int rc );
  610. extern void netdev_tx_complete_next_err ( struct net_device *netdev, int rc );
  611. extern void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf );
  612. extern void netdev_rx_err ( struct net_device *netdev,
  613. struct io_buffer *iobuf, int rc );
  614. extern void netdev_poll ( struct net_device *netdev );
  615. extern struct io_buffer * netdev_rx_dequeue ( struct net_device *netdev );
  616. extern struct net_device * alloc_netdev ( size_t priv_size );
  617. extern int register_netdev ( struct net_device *netdev );
  618. extern int netdev_open ( struct net_device *netdev );
  619. extern void netdev_close ( struct net_device *netdev );
  620. extern void unregister_netdev ( struct net_device *netdev );
  621. extern void netdev_irq ( struct net_device *netdev, int enable );
  622. extern struct net_device * find_netdev ( const char *name );
  623. extern struct net_device * find_netdev_by_index ( unsigned int index );
  624. extern struct net_device * find_netdev_by_location ( unsigned int bus_type,
  625. unsigned int location );
  626. extern struct net_device *
  627. find_netdev_by_ll_addr ( struct ll_protocol *ll_protocol, const void *ll_addr );
  628. extern struct net_device * last_opened_netdev ( void );
  629. extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
  630. struct net_protocol *net_protocol, const void *ll_dest,
  631. const void *ll_source );
  632. extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
  633. uint16_t net_proto, const void *ll_dest,
  634. const void *ll_source, unsigned int flags );
  635. extern void net_poll ( void );
  636. extern struct net_device_configurator *
  637. find_netdev_configurator ( const char *name );
  638. extern int netdev_configure ( struct net_device *netdev,
  639. struct net_device_configurator *configurator );
  640. extern int netdev_configure_all ( struct net_device *netdev );
  641. extern int netdev_configuration_in_progress ( struct net_device *netdev );
  642. extern int netdev_configuration_ok ( struct net_device *netdev );
  643. /**
  644. * Complete network transmission
  645. *
  646. * @v netdev Network device
  647. * @v iobuf I/O buffer
  648. *
  649. * The packet must currently be in the network device's TX queue.
  650. */
  651. static inline void netdev_tx_complete ( struct net_device *netdev,
  652. struct io_buffer *iobuf ) {
  653. netdev_tx_complete_err ( netdev, iobuf, 0 );
  654. }
  655. /**
  656. * Complete network transmission
  657. *
  658. * @v netdev Network device
  659. *
  660. * Completes the oldest outstanding packet in the TX queue.
  661. */
  662. static inline void netdev_tx_complete_next ( struct net_device *netdev ) {
  663. netdev_tx_complete_next_err ( netdev, 0 );
  664. }
  665. /**
  666. * Mark network device as having link up
  667. *
  668. * @v netdev Network device
  669. */
  670. static inline __attribute__ (( always_inline )) void
  671. netdev_link_up ( struct net_device *netdev ) {
  672. netdev_link_err ( netdev, 0 );
  673. }
  674. #endif /* _IPXE_NETDEVICE_H */