iPXE
netdevice.h
Go to the documentation of this file.
00001 #ifndef _IPXE_NETDEVICE_H
00002 #define _IPXE_NETDEVICE_H
00003 
00004 /** @file
00005  *
00006  * Network device management
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/list.h>
00014 #include <ipxe/tables.h>
00015 #include <ipxe/refcnt.h>
00016 #include <ipxe/settings.h>
00017 #include <ipxe/interface.h>
00018 #include <ipxe/retry.h>
00019 
00020 struct io_buffer;
00021 struct net_device;
00022 struct net_protocol;
00023 struct ll_protocol;
00024 struct device;
00025 
00026 /** Maximum length of a hardware address
00027  *
00028  * The longest currently-supported link-layer address is for IPoIB.
00029  */
00030 #define MAX_HW_ADDR_LEN 8
00031 
00032 /** Maximum length of a link-layer address
00033  *
00034  * The longest currently-supported link-layer address is for IPoIB.
00035  */
00036 #define MAX_LL_ADDR_LEN 20
00037 
00038 /** Maximum length of a link-layer header
00039  *
00040  * The longest currently-supported link-layer header is for RNDIS: an
00041  * 8-byte RNDIS header, a 32-byte RNDIS packet message header, a
00042  * 14-byte Ethernet header and a possible 4-byte VLAN header.  Round
00043  * up to 64 bytes.
00044  */
00045 #define MAX_LL_HEADER_LEN 64
00046 
00047 /** Maximum length of a network-layer address */
00048 #define MAX_NET_ADDR_LEN 16
00049 
00050 /** Maximum length of a network-layer header
00051  *
00052  * The longest currently-supported network-layer header is for IPv6 at
00053  * 40 bytes.
00054  */
00055 #define MAX_NET_HEADER_LEN 40
00056 
00057 /** Maximum combined length of a link-layer and network-layer header */
00058 #define MAX_LL_NET_HEADER_LEN ( MAX_LL_HEADER_LEN + MAX_NET_HEADER_LEN )
00059 
00060 /**
00061  * A network-layer protocol
00062  *
00063  */
00064 struct net_protocol {
00065         /** Protocol name */
00066         const char *name;
00067         /**
00068          * Process received packet
00069          *
00070          * @v iobuf             I/O buffer
00071          * @v netdev            Network device
00072          * @v ll_dest           Link-layer destination address
00073          * @v ll_source         Link-layer source address
00074          * @v flags             Packet flags
00075          * @ret rc              Return status code
00076          *
00077          * This method takes ownership of the I/O buffer.
00078          */
00079         int ( * rx ) ( struct io_buffer *iobuf, struct net_device *netdev,
00080                        const void *ll_dest, const void *ll_source,
00081                        unsigned int flags );
00082         /**
00083          * Transcribe network-layer address
00084          *
00085          * @v net_addr          Network-layer address
00086          * @ret string          Human-readable transcription of address
00087          *
00088          * This method should convert the network-layer address into a
00089          * human-readable format (e.g. dotted quad notation for IPv4).
00090          *
00091          * The buffer used to hold the transcription is statically
00092          * allocated.
00093          */
00094         const char * ( *ntoa ) ( const void * net_addr );
00095         /** Network-layer protocol
00096          *
00097          * This is an ETH_P_XXX constant, in network-byte order
00098          */
00099         uint16_t net_proto;
00100         /** Network-layer address length */
00101         uint8_t net_addr_len;
00102 };
00103 
00104 /** Packet is a multicast (including broadcast) packet */
00105 #define LL_MULTICAST 0x0001
00106 
00107 /** Packet is a broadcast packet */
00108 #define LL_BROADCAST 0x0002
00109 
00110 /**
00111  * A link-layer protocol
00112  *
00113  */
00114 struct ll_protocol {
00115         /** Protocol name */
00116         const char *name;
00117         /**
00118          * Add link-layer header
00119          *
00120          * @v netdev            Network device
00121          * @v iobuf             I/O buffer
00122          * @v ll_dest           Link-layer destination address
00123          * @v ll_source         Source link-layer address
00124          * @v net_proto         Network-layer protocol, in network-byte order
00125          * @ret rc              Return status code
00126          */
00127         int ( * push ) ( struct net_device *netdev, struct io_buffer *iobuf,
00128                          const void *ll_dest, const void *ll_source,
00129                          uint16_t net_proto );
00130         /**
00131          * Remove link-layer header
00132          *
00133          * @v netdev            Network device
00134          * @v iobuf             I/O buffer
00135          * @ret ll_dest         Link-layer destination address
00136          * @ret ll_source       Source link-layer address
00137          * @ret net_proto       Network-layer protocol, in network-byte order
00138          * @ret flags           Packet flags
00139          * @ret rc              Return status code
00140          */
00141         int ( * pull ) ( struct net_device *netdev, struct io_buffer *iobuf,
00142                          const void **ll_dest, const void **ll_source,
00143                          uint16_t *net_proto, unsigned int *flags );
00144         /**
00145          * Initialise link-layer address
00146          *
00147          * @v hw_addr           Hardware address
00148          * @v ll_addr           Link-layer address to fill in
00149          */
00150         void ( * init_addr ) ( const void *hw_addr, void *ll_addr );
00151         /**
00152          * Transcribe link-layer address
00153          *
00154          * @v ll_addr           Link-layer address
00155          * @ret string          Human-readable transcription of address
00156          *
00157          * This method should convert the link-layer address into a
00158          * human-readable format.
00159          *
00160          * The buffer used to hold the transcription is statically
00161          * allocated.
00162          */
00163         const char * ( * ntoa ) ( const void *ll_addr );
00164         /**
00165          * Hash multicast address
00166          *
00167          * @v af                Address family
00168          * @v net_addr          Network-layer address
00169          * @v ll_addr           Link-layer address to fill in
00170          * @ret rc              Return status code
00171          */
00172         int ( * mc_hash ) ( unsigned int af, const void *net_addr,
00173                             void *ll_addr );
00174         /**
00175          * Generate Ethernet-compatible compressed link-layer address
00176          *
00177          * @v ll_addr           Link-layer address
00178          * @v eth_addr          Ethernet-compatible address to fill in
00179          * @ret rc              Return status code
00180          */
00181         int ( * eth_addr ) ( const void *ll_addr, void *eth_addr );
00182         /**
00183          * Generate EUI-64 address
00184          *
00185          * @v ll_addr           Link-layer address
00186          * @v eui64             EUI-64 address to fill in
00187          * @ret rc              Return status code
00188          */
00189         int ( * eui64 ) ( const void *ll_addr, void *eui64 );
00190         /** Link-layer protocol
00191          *
00192          * This is an ARPHRD_XXX constant, in network byte order.
00193          */
00194         uint16_t ll_proto;
00195         /** Hardware address length */
00196         uint8_t hw_addr_len;
00197         /** Link-layer address length */
00198         uint8_t ll_addr_len;
00199         /** Link-layer header length */
00200         uint8_t ll_header_len;
00201         /** Flags */
00202         unsigned int flags;
00203 };
00204 
00205 /** Local link-layer address functions only as a name
00206  *
00207  * This flag indicates that the local link-layer address cannot
00208  * directly be used as a destination address by a remote node.
00209  */
00210 #define LL_NAME_ONLY 0x0001
00211 
00212 /** Network device operations */
00213 struct net_device_operations {
00214         /** Open network device
00215          *
00216          * @v netdev    Network device
00217          * @ret rc      Return status code
00218          *
00219          * This method should allocate RX I/O buffers and enable
00220          * the hardware to start transmitting and receiving packets.
00221          */
00222         int ( * open ) ( struct net_device *netdev );
00223         /** Close network device
00224          *
00225          * @v netdev    Network device
00226          *
00227          * This method should stop the flow of packets, and free up
00228          * any packets that are currently in the device's TX queue.
00229          */
00230         void ( * close ) ( struct net_device *netdev );
00231         /** Transmit packet
00232          *
00233          * @v netdev    Network device
00234          * @v iobuf     I/O buffer
00235          * @ret rc      Return status code
00236          *
00237          * This method should cause the hardware to initiate
00238          * transmission of the I/O buffer.
00239          *
00240          * If this method returns success, the I/O buffer remains
00241          * owned by the net device's TX queue, and the net device must
00242          * eventually call netdev_tx_complete() to free the buffer.
00243          * If this method returns failure, the I/O buffer is
00244          * immediately released; the failure is interpreted as
00245          * "failure to enqueue buffer".
00246          *
00247          * This method is guaranteed to be called only when the device
00248          * is open.
00249          */
00250         int ( * transmit ) ( struct net_device *netdev,
00251                              struct io_buffer *iobuf );
00252         /** Poll for completed and received packets
00253          *
00254          * @v netdev    Network device
00255          *
00256          * This method should cause the hardware to check for
00257          * completed transmissions and received packets.  Any received
00258          * packets should be delivered via netdev_rx().
00259          *
00260          * This method is guaranteed to be called only when the device
00261          * is open.
00262          */
00263         void ( * poll ) ( struct net_device *netdev );
00264         /** Enable or disable interrupts
00265          *
00266          * @v netdev    Network device
00267          * @v enable    Interrupts should be enabled
00268          *
00269          * This method may be NULL to indicate that interrupts are not
00270          * supported.
00271          */
00272         void ( * irq ) ( struct net_device *netdev, int enable );
00273 };
00274 
00275 /** Network device error */
00276 struct net_device_error {
00277         /** Error status code */
00278         int rc;
00279         /** Error count */
00280         unsigned int count;
00281 };
00282 
00283 /** Maximum number of unique errors that we will keep track of */
00284 #define NETDEV_MAX_UNIQUE_ERRORS 4
00285 
00286 /** Network device statistics */
00287 struct net_device_stats {
00288         /** Count of successful completions */
00289         unsigned int good;
00290         /** Count of error completions */
00291         unsigned int bad;
00292         /** Error breakdowns */
00293         struct net_device_error errors[NETDEV_MAX_UNIQUE_ERRORS];
00294 };
00295 
00296 /** A network device configuration */
00297 struct net_device_configuration {
00298         /** Network device */
00299         struct net_device *netdev;
00300         /** Network device configurator */
00301         struct net_device_configurator *configurator;
00302         /** Configuration status */
00303         int rc;
00304         /** Job control interface */
00305         struct interface job;
00306 };
00307 
00308 /** A network device configurator */
00309 struct net_device_configurator {
00310         /** Name */
00311         const char *name;
00312         /** Check applicability of configurator
00313          *
00314          * @v netdev            Network device
00315          * @ret applies         Configurator applies to this network device
00316          */
00317         int ( * applies ) ( struct net_device *netdev );
00318         /** Start configuring network device
00319          *
00320          * @v job               Job control interface
00321          * @v netdev            Network device
00322          * @ret rc              Return status code
00323          */
00324         int ( * start ) ( struct interface *job, struct net_device *netdev );
00325 };
00326 
00327 /** Network device configurator table */
00328 #define NET_DEVICE_CONFIGURATORS \
00329         __table ( struct net_device_configurator, "net_device_configurators" )
00330 
00331 /** Declare a network device configurator */
00332 #define __net_device_configurator \
00333         __table_entry ( NET_DEVICE_CONFIGURATORS, 01 )
00334 
00335 /** Maximum length of a network device name */
00336 #define NETDEV_NAME_LEN 12
00337 
00338 /**
00339  * A network device
00340  *
00341  * This structure represents a piece of networking hardware.  It has
00342  * properties such as a link-layer address and methods for
00343  * transmitting and receiving raw packets.
00344  *
00345  * Note that this structure must represent a generic network device,
00346  * not just an Ethernet device.
00347  */
00348 struct net_device {
00349         /** Reference counter */
00350         struct refcnt refcnt;
00351         /** List of network devices */
00352         struct list_head list;
00353         /** List of open network devices */
00354         struct list_head open_list;
00355         /** Index of this network device */
00356         unsigned int index;
00357         /** Name of this network device */
00358         char name[NETDEV_NAME_LEN];
00359         /** Underlying hardware device */
00360         struct device *dev;
00361 
00362         /** Network device operations */
00363         struct net_device_operations *op;
00364 
00365         /** Link-layer protocol */
00366         struct ll_protocol *ll_protocol;
00367         /** Hardware address
00368          *
00369          * This is an address which is an intrinsic property of the
00370          * hardware, e.g. an address held in EEPROM.
00371          *
00372          * Note that the hardware address may not be the same length
00373          * as the link-layer address.
00374          */
00375         uint8_t hw_addr[MAX_HW_ADDR_LEN];
00376         /** Link-layer address
00377          *
00378          * This is the current link-layer address assigned to the
00379          * device.  It can be changed at runtime.
00380          */
00381         uint8_t ll_addr[MAX_LL_ADDR_LEN];
00382         /** Link-layer broadcast address */
00383         const uint8_t *ll_broadcast;
00384 
00385         /** Current device state
00386          *
00387          * This is the bitwise-OR of zero or more NETDEV_XXX constants.
00388          */
00389         unsigned int state;
00390         /** Link status code
00391          *
00392          * Zero indicates that the link is up; any other value
00393          * indicates the error preventing link-up.
00394          */
00395         int link_rc;
00396         /** Link block timer */
00397         struct retry_timer link_block;
00398         /** Maximum packet length
00399          *
00400          * This is the maximum packet length (including any link-layer
00401          * headers) supported by the hardware.
00402          */
00403         size_t max_pkt_len;
00404         /** Maximum transmission unit length
00405          *
00406          * This is the maximum transmission unit length (excluding any
00407          * link-layer headers) configured for the link.
00408          */
00409         size_t mtu;
00410         /** TX packet queue */
00411         struct list_head tx_queue;
00412         /** Deferred TX packet queue */
00413         struct list_head tx_deferred;
00414         /** RX packet queue */
00415         struct list_head rx_queue;
00416         /** TX statistics */
00417         struct net_device_stats tx_stats;
00418         /** RX statistics */
00419         struct net_device_stats rx_stats;
00420 
00421         /** Configuration settings applicable to this device */
00422         struct generic_settings settings;
00423 
00424         /** Driver private data */
00425         void *priv;
00426 
00427         /** Network device configurations (variable length) */
00428         struct net_device_configuration configs[0];
00429 };
00430 
00431 /** Network device is open */
00432 #define NETDEV_OPEN 0x0001
00433 
00434 /** Network device interrupts are enabled */
00435 #define NETDEV_IRQ_ENABLED 0x0002
00436 
00437 /** Network device receive queue processing is frozen */
00438 #define NETDEV_RX_FROZEN 0x0004
00439 
00440 /** Network device interrupts are unsupported
00441  *
00442  * This flag can be used by a network device to indicate that
00443  * interrupts are not supported despite the presence of an irq()
00444  * method.
00445  */
00446 #define NETDEV_IRQ_UNSUPPORTED 0x0008
00447 
00448 /** Link-layer protocol table */
00449 #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
00450 
00451 /** Declare a link-layer protocol */
00452 #define __ll_protocol  __table_entry ( LL_PROTOCOLS, 01 )
00453 
00454 /** Network-layer protocol table */
00455 #define NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" )
00456 
00457 /** Declare a network-layer protocol */
00458 #define __net_protocol __table_entry ( NET_PROTOCOLS, 01 )
00459 
00460 /** A network upper-layer driver */
00461 struct net_driver {
00462         /** Name */
00463         const char *name;
00464         /** Probe device
00465          *
00466          * @v netdev            Network device
00467          * @ret rc              Return status code
00468          */
00469         int ( * probe ) ( struct net_device *netdev );
00470         /** Notify of device or link state change
00471          *
00472          * @v netdev            Network device
00473          */
00474         void ( * notify ) ( struct net_device *netdev );
00475         /** Remove device
00476          *
00477          * @v netdev            Network device
00478          */
00479         void ( * remove ) ( struct net_device *netdev );
00480 };
00481 
00482 /** Network driver table */
00483 #define NET_DRIVERS __table ( struct net_driver, "net_drivers" )
00484 
00485 /** Declare a network driver */
00486 #define __net_driver __table_entry ( NET_DRIVERS, 01 )
00487 
00488 extern struct list_head net_devices;
00489 extern struct net_device_operations null_netdev_operations;
00490 extern struct settings_operations netdev_settings_operations;
00491 
00492 /**
00493  * Initialise a network device
00494  *
00495  * @v netdev            Network device
00496  * @v op                Network device operations
00497  */
00498 static inline void netdev_init ( struct net_device *netdev,
00499                                  struct net_device_operations *op ) {
00500         netdev->op = op;
00501 }
00502 
00503 /**
00504  * Stop using a network device
00505  *
00506  * @v netdev            Network device
00507  *
00508  * Drivers should call this method immediately before the final call
00509  * to netdev_put().
00510  */
00511 static inline void netdev_nullify ( struct net_device *netdev ) {
00512         netdev->op = &null_netdev_operations;
00513 }
00514 
00515 /**
00516  * Get printable network device link-layer address
00517  *
00518  * @v netdev            Network device
00519  * @ret name            Link-layer address
00520  */
00521 static inline const char * netdev_addr ( struct net_device *netdev ) {
00522         return netdev->ll_protocol->ntoa ( netdev->ll_addr );
00523 }
00524 
00525 /** Iterate over all network devices */
00526 #define for_each_netdev( netdev ) \
00527         list_for_each_entry ( (netdev), &net_devices, list )
00528 
00529 /** There exist some network devices
00530  *
00531  * @ret existence       Existence of network devices
00532  */
00533 static inline int have_netdevs ( void ) {
00534         return ( ! list_empty ( &net_devices ) );
00535 }
00536 
00537 /**
00538  * Get reference to network device
00539  *
00540  * @v netdev            Network device
00541  * @ret netdev          Network device
00542  */
00543 static inline __attribute__ (( always_inline )) struct net_device *
00544 netdev_get ( struct net_device *netdev ) {
00545         ref_get ( &netdev->refcnt );
00546         return netdev;
00547 }
00548 
00549 /**
00550  * Drop reference to network device
00551  *
00552  * @v netdev            Network device
00553  */
00554 static inline __attribute__ (( always_inline )) void
00555 netdev_put ( struct net_device *netdev ) {
00556         ref_put ( &netdev->refcnt );
00557 }
00558 
00559 /**
00560  * Get driver private area for this network device
00561  *
00562  * @v netdev            Network device
00563  * @ret priv            Driver private area for this network device
00564  */
00565 static inline __attribute__ (( always_inline )) void *
00566 netdev_priv ( struct net_device *netdev ) {
00567         return netdev->priv;
00568 }
00569 
00570 /**
00571  * Get per-netdevice configuration settings block
00572  *
00573  * @v netdev            Network device
00574  * @ret settings        Settings block
00575  */
00576 static inline __attribute__ (( always_inline )) struct settings *
00577 netdev_settings ( struct net_device *netdev ) {
00578         return &netdev->settings.settings;
00579 }
00580 
00581 /**
00582  * Initialise a per-netdevice configuration settings block
00583  *
00584  * @v generics          Generic settings block
00585  * @v refcnt            Containing object reference counter, or NULL
00586  * @v name              Settings block name
00587  */
00588 static inline __attribute__ (( always_inline )) void
00589 netdev_settings_init ( struct net_device *netdev ) {
00590         generic_settings_init ( &netdev->settings, &netdev->refcnt );
00591         netdev->settings.settings.op = &netdev_settings_operations;
00592 }
00593 
00594 /**
00595  * Get network device configuration
00596  *
00597  * @v netdev            Network device
00598  * @v configurator      Network device configurator
00599  * @ret config          Network device configuration
00600  */
00601 static inline struct net_device_configuration *
00602 netdev_configuration ( struct net_device *netdev,
00603                        struct net_device_configurator *configurator ) {
00604 
00605         return &netdev->configs[ table_index ( NET_DEVICE_CONFIGURATORS,
00606                                                configurator ) ];
00607 }
00608 
00609 /**
00610  * Check if configurator applies to network device
00611  *
00612  * @v netdev            Network device
00613  * @v configurator      Network device configurator
00614  * @ret applies         Configurator applies to network device
00615  */
00616 static inline int
00617 netdev_configurator_applies ( struct net_device *netdev,
00618                               struct net_device_configurator *configurator ) {
00619         return ( ( configurator->applies == NULL ) ||
00620                  configurator->applies ( netdev ) );
00621 }
00622 
00623 /**
00624  * Check link state of network device
00625  *
00626  * @v netdev            Network device
00627  * @ret link_up         Link is up
00628  */
00629 static inline __attribute__ (( always_inline )) int
00630 netdev_link_ok ( struct net_device *netdev ) {
00631         return ( netdev->link_rc == 0 );
00632 }
00633 
00634 /**
00635  * Check link block state of network device
00636  *
00637  * @v netdev            Network device
00638  * @ret link_blocked    Link is blocked
00639  */
00640 static inline __attribute__ (( always_inline )) int
00641 netdev_link_blocked ( struct net_device *netdev ) {
00642         return ( timer_running ( &netdev->link_block ) );
00643 }
00644 
00645 /**
00646  * Check whether or not network device is open
00647  *
00648  * @v netdev            Network device
00649  * @ret is_open         Network device is open
00650  */
00651 static inline __attribute__ (( always_inline )) int
00652 netdev_is_open ( struct net_device *netdev ) {
00653         return ( netdev->state & NETDEV_OPEN );
00654 }
00655 
00656 /**
00657  * Check whether or not network device supports interrupts
00658  *
00659  * @v netdev            Network device
00660  * @ret irq_supported   Network device supports interrupts
00661  */
00662 static inline __attribute__ (( always_inline )) int
00663 netdev_irq_supported ( struct net_device *netdev ) {
00664         return ( ( netdev->op->irq != NULL ) &&
00665                  ! ( netdev->state & NETDEV_IRQ_UNSUPPORTED ) );
00666 }
00667 
00668 /**
00669  * Check whether or not network device interrupts are currently enabled
00670  *
00671  * @v netdev            Network device
00672  * @ret irq_enabled     Network device interrupts are enabled
00673  */
00674 static inline __attribute__ (( always_inline )) int
00675 netdev_irq_enabled ( struct net_device *netdev ) {
00676         return ( netdev->state & NETDEV_IRQ_ENABLED );
00677 }
00678 
00679 /**
00680  * Check whether or not network device receive queue processing is frozen
00681  *
00682  * @v netdev            Network device
00683  * @ret rx_frozen       Network device receive queue processing is frozen
00684  */
00685 static inline __attribute__ (( always_inline )) int
00686 netdev_rx_frozen ( struct net_device *netdev ) {
00687         return ( netdev->state & NETDEV_RX_FROZEN );
00688 }
00689 
00690 extern void netdev_rx_freeze ( struct net_device *netdev );
00691 extern void netdev_rx_unfreeze ( struct net_device *netdev );
00692 extern void netdev_link_err ( struct net_device *netdev, int rc );
00693 extern void netdev_link_down ( struct net_device *netdev );
00694 extern void netdev_link_block ( struct net_device *netdev,
00695                                 unsigned long timeout );
00696 extern void netdev_link_unblock ( struct net_device *netdev );
00697 extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
00698 extern void netdev_tx_defer ( struct net_device *netdev,
00699                               struct io_buffer *iobuf );
00700 extern void netdev_tx_err ( struct net_device *netdev,
00701                             struct io_buffer *iobuf, int rc );
00702 extern void netdev_tx_complete_err ( struct net_device *netdev,
00703                                  struct io_buffer *iobuf, int rc );
00704 extern void netdev_tx_complete_next_err ( struct net_device *netdev, int rc );
00705 extern void netdev_rx ( struct net_device *netdev, struct io_buffer *iobuf );
00706 extern void netdev_rx_err ( struct net_device *netdev,
00707                             struct io_buffer *iobuf, int rc );
00708 extern void netdev_poll ( struct net_device *netdev );
00709 extern struct io_buffer * netdev_rx_dequeue ( struct net_device *netdev );
00710 extern struct net_device * alloc_netdev ( size_t priv_size );
00711 extern int register_netdev ( struct net_device *netdev );
00712 extern int netdev_open ( struct net_device *netdev );
00713 extern void netdev_close ( struct net_device *netdev );
00714 extern void unregister_netdev ( struct net_device *netdev );
00715 extern void netdev_irq ( struct net_device *netdev, int enable );
00716 extern struct net_device * find_netdev ( const char *name );
00717 extern struct net_device * find_netdev_by_index ( unsigned int index );
00718 extern struct net_device * find_netdev_by_location ( unsigned int bus_type,
00719                                                      unsigned int location );
00720 extern struct net_device *
00721 find_netdev_by_ll_addr ( struct ll_protocol *ll_protocol, const void *ll_addr );
00722 extern struct net_device * last_opened_netdev ( void );
00723 extern int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
00724                     struct net_protocol *net_protocol, const void *ll_dest,
00725                     const void *ll_source );
00726 extern int net_rx ( struct io_buffer *iobuf, struct net_device *netdev,
00727                     uint16_t net_proto, const void *ll_dest,
00728                     const void *ll_source, unsigned int flags );
00729 extern void net_poll ( void );
00730 extern struct net_device_configurator *
00731 find_netdev_configurator ( const char *name );
00732 extern int netdev_configure ( struct net_device *netdev,
00733                               struct net_device_configurator *configurator );
00734 extern int netdev_configure_all ( struct net_device *netdev );
00735 extern int netdev_configuration_in_progress ( struct net_device *netdev );
00736 extern int netdev_configuration_ok ( struct net_device *netdev );
00737 
00738 /**
00739  * Complete network transmission
00740  *
00741  * @v netdev            Network device
00742  * @v iobuf             I/O buffer
00743  *
00744  * The packet must currently be in the network device's TX queue.
00745  */
00746 static inline void netdev_tx_complete ( struct net_device *netdev,
00747                                         struct io_buffer *iobuf ) {
00748         netdev_tx_complete_err ( netdev, iobuf, 0 );
00749 }
00750 
00751 /**
00752  * Complete network transmission
00753  *
00754  * @v netdev            Network device
00755  *
00756  * Completes the oldest outstanding packet in the TX queue.
00757  */
00758 static inline void netdev_tx_complete_next ( struct net_device *netdev ) {
00759         netdev_tx_complete_next_err ( netdev, 0 );
00760 }
00761 
00762 /**
00763  * Mark network device as having link up
00764  *
00765  * @v netdev            Network device
00766  */
00767 static inline __attribute__ (( always_inline )) void
00768 netdev_link_up ( struct net_device *netdev ) {
00769         netdev_link_err ( netdev, 0 );
00770 }
00771 
00772 #endif /* _IPXE_NETDEVICE_H */