#include <stdint.h>
#include <gpxe/list.h>
#include <gpxe/tables.h>
#include <gpxe/refcnt.h>
#include <gpxe/settings.h>
Go to the source code of this file.
Data Structures | |
| struct | net_protocol |
| A network-layer protocol. More... | |
| struct | ll_protocol |
| A link-layer protocol. More... | |
| struct | net_device_operations |
| Network device operations. More... | |
| struct | net_device_error |
| Network device error. More... | |
| struct | net_device_stats |
| Network device statistics. More... | |
| struct | net_device |
| A network device. More... | |
Defines | |
| #define | MAX_HW_ADDR_LEN 8 |
| Maximum length of a hardware address. | |
| #define | MAX_LL_ADDR_LEN 20 |
| Maximum length of a link-layer address. | |
| #define | MAX_LL_HEADER_LEN 32 |
| Maximum length of a link-layer header. | |
| #define | MAX_NET_ADDR_LEN 4 |
| Maximum length of a network-layer address. | |
| #define | NETDEV_MAX_UNIQUE_ERRORS 4 |
| Maximum number of unique errors that we will keep track of. | |
| #define | NETDEV_OPEN 0x0001 |
| Network device is open. | |
| #define | NETDEV_IRQ_ENABLED 0x0002 |
| Network device interrupts are enabled. | |
| #define | LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" ) |
| Link-layer protocol table. | |
| #define | __ll_protocol __table_entry ( LL_PROTOCOLS, 01 ) |
| Declare a link-layer protocol. | |
| #define | NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" ) |
| Network-layer protocol table. | |
| #define | __net_protocol __table_entry ( NET_PROTOCOLS, 01 ) |
| Declare a network-layer protocol. | |
| #define | for_each_netdev(netdev) list_for_each_entry ( (netdev), &net_devices, list ) |
| Iterate over all network devices. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void | netdev_init (struct net_device *netdev, struct net_device_operations *op) |
| Initialise a network device. | |
| static void | netdev_nullify (struct net_device *netdev) |
| Stop using a network device. | |
| static const char * | netdev_addr (struct net_device *netdev) |
| Get printable network device link-layer address. | |
| static int | have_netdevs (void) |
| There exist some network devices. | |
| static struct net_device * | netdev_get (struct net_device *netdev) |
| Get reference to network device. | |
| static void | netdev_put (struct net_device *netdev) |
| Drop reference to network device. | |
| static void * | netdev_priv (struct net_device *netdev) |
| Get driver private area for this network device. | |
| static struct settings * | netdev_settings (struct net_device *netdev) |
| Get per-netdevice configuration settings block. | |
| static void | netdev_settings_init (struct net_device *netdev) |
| Initialise a per-netdevice configuration settings block. | |
| static void | netdev_link_up (struct net_device *netdev) |
| Mark network device as having link up. | |
| static void | netdev_link_err (struct net_device *netdev, int rc) |
| Mark network device as having link down due to a specific error. | |
| static int | netdev_link_ok (struct net_device *netdev) |
| Check link state of network device. | |
| static int | netdev_is_open (struct net_device *netdev) |
| Check whether or not network device is open. | |
| static int | netdev_irq_enabled (struct net_device *netdev) |
| Check whether or not network device interrupts are currently enabled. | |
| void | netdev_link_down (struct net_device *netdev) |
| Mark network device as having link down. | |
| int | netdev_tx (struct net_device *netdev, struct io_buffer *iobuf) |
| Transmit raw packet via network device. | |
| void | netdev_tx_complete_err (struct net_device *netdev, struct io_buffer *iobuf, int rc) |
| Complete network transmission. | |
| void | netdev_tx_complete_next_err (struct net_device *netdev, int rc) |
| Complete network transmission. | |
| void | netdev_rx (struct net_device *netdev, struct io_buffer *iobuf) |
| Add packet to receive queue. | |
| void | netdev_rx_err (struct net_device *netdev, struct io_buffer *iobuf, int rc) |
| Discard received packet. | |
| void | netdev_poll (struct net_device *netdev) |
| Poll for completed and received packets on network device. | |
| struct io_buffer * | netdev_rx_dequeue (struct net_device *netdev) |
| Remove packet from device's receive queue. | |
| struct net_device * | alloc_netdev (size_t priv_size) |
| Allocate network device. | |
| int | register_netdev (struct net_device *netdev) |
| Register network device. | |
| int | netdev_open (struct net_device *netdev) |
| Open network device. | |
| void | netdev_close (struct net_device *netdev) |
| Close network device. | |
| void | unregister_netdev (struct net_device *netdev) |
| Unregister network device. | |
| void | netdev_irq (struct net_device *netdev, int enable) |
| Enable or disable interrupts. | |
| struct net_device * | find_netdev (const char *name) |
| Get network device by name. | |
| struct net_device * | find_netdev_by_location (unsigned int bus_type, unsigned int location) |
| Get network device by PCI bus:dev.fn address. | |
| struct net_device * | last_opened_netdev (void) |
| Get most recently opened network device. | |
| int | net_tx (struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest) |
| Transmit network-layer packet. | |
| int | net_rx (struct io_buffer *iobuf, struct net_device *netdev, uint16_t net_proto, const void *ll_source) |
| Process received network-layer packet. | |
| static void | netdev_tx_complete (struct net_device *netdev, struct io_buffer *iobuf) |
| Complete network transmission. | |
| static void | netdev_tx_complete_next (struct net_device *netdev) |
| Complete network transmission. | |
Variables | |
| struct list_head | net_devices |
| List of network devices. | |
| struct net_device_operations | null_netdev_operations |
| struct settings_operations | netdev_settings_operations |
| Network device configuration settings operations. | |
Definition in file netdevice.h.
| #define MAX_HW_ADDR_LEN 8 |
Maximum length of a hardware address.
The longest currently-supported link-layer address is for IPoIB.
Definition at line 28 of file netdevice.h.
| #define MAX_LL_ADDR_LEN 20 |
Maximum length of a link-layer address.
The longest currently-supported link-layer address is for IPoIB.
Definition at line 34 of file netdevice.h.
Referenced by arp_resolve(), ipv4_tx(), ipv6_tx(), natsemi_probe(), and pxenv_undi_transmit().
| #define MAX_LL_HEADER_LEN 32 |
Maximum length of a link-layer header.
The longest currently-supported link-layer header is for 802.11: a 24-byte frame header plus an 8-byte 802.3 LLC/SNAP header. (The IPoIB link-layer pseudo-header doesn't actually include link-layer addresses; see ipoib.c for details).
Definition at line 43 of file netdevice.h.
Referenced by arp_resolve(), and wpa_alloc_frame().
| #define MAX_NET_ADDR_LEN 4 |
Maximum length of a network-layer address.
Definition at line 46 of file netdevice.h.
Referenced by arp_resolve().
| #define NETDEV_MAX_UNIQUE_ERRORS 4 |
Maximum number of unique errors that we will keep track of.
Definition at line 240 of file netdevice.h.
| #define NETDEV_OPEN 0x0001 |
Network device is open.
Definition at line 330 of file netdevice.h.
Referenced by netdev_close(), netdev_is_open(), and netdev_open().
| #define NETDEV_IRQ_ENABLED 0x0002 |
Network device interrupts are enabled.
Definition at line 333 of file netdevice.h.
Referenced by netdev_irq(), and netdev_irq_enabled().
| #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" ) |
| #define __ll_protocol __table_entry ( LL_PROTOCOLS, 01 ) |
| #define NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" ) |
| #define __net_protocol __table_entry ( NET_PROTOCOLS, 01 ) |
| #define for_each_netdev | ( | netdev | ) | list_for_each_entry ( (netdev), &net_devices, list ) |
Iterate over all network devices.
Definition at line 385 of file netdevice.h.
Referenced by autoboot(), close_all_netdevs(), ifcommon_do_all(), and ipv4_create_routes().
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static void netdev_init | ( | struct net_device * | netdev, | |
| struct net_device_operations * | op | |||
| ) | [inline, static] |
Initialise a network device.
Definition at line 357 of file netdevice.h.
References net_device::op.
Referenced by a3c90x_probe(), atl1e_init_netdev(), b44_probe(), e1000_probe(), e1000e_probe(), efab_probe(), ifec_pci_probe(), igb_probe(), ipoib_probe(), legacy_probe(), mtnic_probe(), myri10ge_pci_probe(), natsemi_probe(), net80211_alloc(), phantom_probe(), pnic_probe(), rtl8169_probe(), rtl_probe(), sis190_probe(), skge_probe(), sky2_probe(), undinet_probe(), and vxge_device_register().
00358 { 00359 netdev->op = op; 00360 }
| static void netdev_nullify | ( | struct net_device * | netdev | ) | [inline, static] |
Stop using a network device.
| netdev | Network device |
Definition at line 370 of file netdevice.h.
References null_netdev_operations, and net_device::op.
Referenced by a3c90x_remove(), atl1e_probe(), atl1e_remove(), b44_remove(), e1000_remove(), e1000e_remove(), efab_remove(), ifec_pci_probe(), ifec_pci_remove(), igb_remove(), ipoib_probe(), ipoib_remove(), legacy_probe(), legacy_remove(), mtnic_disable(), myri10ge_pci_probe(), myri10ge_pci_remove(), natsemi_remove(), net80211_free(), phantom_probe(), phantom_remove(), pnic_probe(), pnic_remove(), rtl8169_remove(), rtl_probe(), rtl_remove(), sis190_remove(), skge_probe(), skge_remove(), sky2_probe(), sky2_remove(), undinet_probe(), undinet_remove(), and vxge_device_unregister().
00370 { 00371 netdev->op = &null_netdev_operations; 00372 }
| static const char* netdev_addr | ( | struct net_device * | netdev | ) | [inline, static] |
Get printable network device link-layer address.
| netdev | Network device |
| name | Link-layer address |
Definition at line 380 of file netdevice.h.
References net_device::ll_addr, net_device::ll_protocol, and ll_protocol::ntoa.
Referenced by ifstat(), register_netdev(), rtl818x_probe(), skge_show_addr(), and sky2_show_addr().
00380 { 00381 return netdev->ll_protocol->ntoa ( netdev->ll_addr ); 00382 }
| static int have_netdevs | ( | void | ) | [inline, static] |
There exist some network devices.
| existence | Existence of network devices |
Definition at line 392 of file netdevice.h.
References list_empty(), and net_devices.
00392 { 00393 return ( ! list_empty ( &net_devices ) ); 00394 }
| static struct net_device* netdev_get | ( | struct net_device * | netdev | ) | [static, read] |
Get reference to network device.
| netdev | Network device |
| netdev | Network device |
Definition at line 403 of file netdevice.h.
References ref_get().
Referenced by add_ipv4_miniroute(), add_ipv6_miniroute(), aoe_attach(), efi_snp_driver_start(), gdbudp_configure(), pxe_set_netdev(), register_netdev(), start_dhcp(), and start_pxebs().
| static void netdev_put | ( | struct net_device * | netdev | ) | [inline, static] |
Drop reference to network device.
| netdev | Network device |
Definition at line 414 of file netdevice.h.
References ref_put().
Referenced by a3c90x_probe(), a3c90x_remove(), aoe_free(), atl1e_probe(), atl1e_remove(), b44_probe(), b44_remove(), del_ipv4_miniroute(), del_ipv6_miniroute(), dhcp_free(), e1000_probe(), e1000_remove(), e1000e_probe(), e1000e_remove(), efab_probe(), efab_remove(), efi_snp_driver_start(), efi_snp_driver_stop(), gdbudp_configure(), ifec_pci_probe(), ifec_pci_remove(), igb_probe(), igb_remove(), ipoib_probe(), ipoib_remove(), legacy_probe(), legacy_remove(), mtnic_disable(), myri10ge_pci_probe(), myri10ge_pci_remove(), natsemi_probe(), natsemi_remove(), net80211_free(), phantom_probe(), phantom_remove(), pnic_probe(), pnic_remove(), pxe_set_netdev(), rtl8169_probe(), rtl8169_remove(), rtl_probe(), rtl_remove(), sis190_remove(), skge_probe(), skge_remove(), sky2_probe(), sky2_remove(), undinet_probe(), undinet_remove(), unregister_netdev(), vxge_device_register(), and vxge_device_unregister().
| static void* netdev_priv | ( | struct net_device * | netdev | ) | [inline, static] |
Get driver private area for this network device.
| netdev | Network device |
| priv | Driver private area for this network device |
Definition at line 425 of file netdevice.h.
Referenced by __mdio_read(), __mdio_write(), a3c90x_close(), a3c90x_hw_start(), a3c90x_irq(), a3c90x_open(), a3c90x_poll(), a3c90x_probe(), a3c90x_process_rx_packets(), a3c90x_process_tx_packets(), a3c90x_remove(), a3c90x_transmit(), atl1e_close(), atl1e_irq(), atl1e_mdio_read(), atl1e_mdio_write(), atl1e_open(), atl1e_poll(), atl1e_probe(), atl1e_remove(), atl1e_xmit_frame(), b44_close(), b44_irq(), b44_open(), b44_poll(), b44_probe(), b44_remove(), b44_set_rx_mode(), b44_transmit(), bcom_check_link(), e1000_close(), e1000_irq(), e1000_open(), e1000_poll(), e1000_probe(), e1000_process_rx_packets(), e1000_process_tx_packets(), e1000_remove(), e1000_transmit(), e1000e_close(), e1000e_irq(), e1000e_open(), e1000e_poll(), e1000e_probe(), e1000e_process_rx_packets(), e1000e_process_tx_packets(), e1000e_remove(), e1000e_transmit(), efab_close(), efab_irq(), efab_open(), efab_poll(), efab_probe(), efab_remove(), efab_transmit(), genesis_mac_init(), ifec_free(), igb_close(), igb_irq(), igb_open(), igb_poll(), igb_probe(), igb_process_rx_packets(), igb_process_tx_packets(), igb_remove(), igb_transmit(), mtnic_alloc_resources(), mtnic_close(), mtnic_disable(), mtnic_open(), mtnic_poll(), mtnic_probe(), mtnic_transmit(), phantom_close(), phantom_irq(), phantom_open(), phantom_poll(), phantom_poll_link_state(), phantom_probe(), phantom_refill_rx_ring(), phantom_remove(), phantom_transmit(), rtl8169_close(), rtl8169_irq(), rtl8169_open(), rtl8169_poll(), rtl8169_probe(), rtl8169_process_rx_packets(), rtl8169_process_tx_packets(), rtl8169_remove(), rtl8169_set_speed(), rtl8169_set_speed_tbi(), rtl8169_set_speed_xmii(), rtl8169_transmit(), rtl_disable_clock_request(), rtl_hw_phy_config(), rtl_hw_start(), rtl_hw_start_8101(), rtl_hw_start_8168(), rtl_hw_start_8169(), rtl_set_rx_mode(), rtl_soft_reset(), rtl_tx_performance_tweak(), sis190_down(), sis190_free(), sis190_get_mac_addr_from_apc(), sis190_get_mac_addr_from_eeprom(), sis190_hw_start(), sis190_init_board(), sis190_init_ring(), sis190_init_rxfilter(), sis190_irq(), sis190_mii_probe(), sis190_mii_remove(), sis190_open(), sis190_poll(), sis190_probe(), sis190_set_rx_mode(), sis190_set_speed_auto(), sis190_transmit(), skge_devinit(), skge_down(), skge_free(), skge_net_irq(), skge_phyirq(), skge_poll(), skge_rx_done(), skge_rx_refill(), skge_tx_clean(), skge_tx_done(), skge_up(), skge_xmit_frame(), sky2_down(), sky2_init_netdev(), sky2_le_error(), sky2_net_irq(), sky2_phy_init(), sky2_phy_intr(), sky2_poll(), sky2_receive(), sky2_set_multicast(), sky2_status_intr(), sky2_tx_clean(), sky2_tx_done(), sky2_up(), sky2_xmit_frame(), vxge_close(), vxge_device_register(), vxge_device_unregister(), vxge_irq(), vxge_open(), vxge_poll(), vxge_remove(), vxge_xmit(), xm_check_link(), xm_link_down(), yukon_init(), and yukon_mac_init().
00425 { 00426 return netdev->priv; 00427 }
| static struct settings* netdev_settings | ( | struct net_device * | netdev | ) | [static, read] |
Get per-netdevice configuration settings block.
| netdev | Network device |
| settings | Settings block |
Definition at line 436 of file netdevice.h.
Referenced by create_fakedhcpack(), dhcp_request_rx(), efab_probe(), free_netdev(), gdbudp_configure(), ipv4_create_routes(), net80211_autoassociate(), net80211_check_settings_update(), phantom_probe(), register_netdev(), rtl_probe(), start_pxebs(), store_cached_dhcpack(), trivial_change_key(), trivial_init(), unregister_netdev(), and wpa_psk_start().
| static void netdev_settings_init | ( | struct net_device * | netdev | ) | [inline, static] |
Initialise a per-netdevice configuration settings block.
| generics | Generic settings block | |
| refcnt | Containing object reference counter, or NULL | |
| name | Settings block name |
Definition at line 448 of file netdevice.h.
References generic_settings_init(), and netdev_settings_operations.
Referenced by alloc_netdev().
00448 { 00449 generic_settings_init ( &netdev->settings, 00450 &netdev->refcnt, netdev->name ); 00451 netdev->settings.settings.op = &netdev_settings_operations; 00452 }
| static void netdev_link_up | ( | struct net_device * | netdev | ) | [inline, static] |
Mark network device as having link up.
| netdev | Network device |
Definition at line 460 of file netdevice.h.
Referenced by __vxge_hw_vpath_alarm_process(), a3c90x_probe(), atl1e_check_link(), b44_probe(), e1000_probe(), e1000e_probe(), efab_init_mac(), efab_probe(), ifec_link_update(), igb_probe(), legacy_probe(), mii_check_link(), mii_check_media(), mtnic_open(), myri10ge_interrupt_handler(), natsemi_probe(), net80211_step_associate(), phantom_poll_link_state(), pnic_probe(), rtl8169_probe(), rtl_probe(), sis190_phy_task(), skge_link_up(), sky2_link_up(), undinet_probe(), and vxge_open().
00460 { 00461 netdev->link_rc = 0; 00462 }
| static void netdev_link_err | ( | struct net_device * | netdev, | |
| int | rc | |||
| ) | [inline, static] |
Mark network device as having link down due to a specific error.
| netdev | Network device | |
| rc | Link status code |
Definition at line 471 of file netdevice.h.
Referenced by ipoib_join_complete(), ipoib_link_state_changed(), net80211_deauthenticate(), net80211_set_state(), and net80211_step_associate().
00471 { 00472 netdev->link_rc = rc; 00473 }
| static int netdev_link_ok | ( | struct net_device * | netdev | ) | [inline, static] |
Check link state of network device.
| netdev | Network device |
| link_up | Link is up |
Definition at line 482 of file netdevice.h.
Referenced by atl1e_check_link(), atl1e_clean_rx_irq(), atl1e_poll(), atl1e_xmit_frame(), bcom_check_link(), efi_snp_set_mode(), iflinkwait(), ifstat(), mii_check_link(), mii_check_media(), sis190_poll(), vxge_xmit(), xm_check_link(), and xm_link_down().
00482 { 00483 return ( netdev->link_rc == 0 ); 00484 }
| static int netdev_is_open | ( | struct net_device * | netdev | ) | [inline, static] |
Check whether or not network device is open.
Definition at line 493 of file netdevice.h.
References NETDEV_OPEN.
Referenced by efi_snp_station_address(), efi_snp_wait_for_packet(), ifstat(), ipv4_route(), iwlist(), last_opened_netdev(), net80211_change_channel(), net80211_check_settings_update(), net80211_prepare_assoc(), net80211_prepare_probe(), net80211_probe_start(), net80211_set_rate_idx(), netdev_poll(), netdev_tx(), pxenv_undi_set_station_address(), route(), and startpxe_payload().
00493 { 00494 return ( netdev->state & NETDEV_OPEN ); 00495 }
| static int netdev_irq_enabled | ( | struct net_device * | netdev | ) | [inline, static] |
Check whether or not network device interrupts are currently enabled.
Definition at line 504 of file netdevice.h.
References NETDEV_IRQ_ENABLED.
Referenced by pxenv_undi_isr().
00504 { 00505 return ( netdev->state & NETDEV_IRQ_ENABLED ); 00506 }
| void netdev_link_down | ( | struct net_device * | netdev | ) |
Mark network device as having link down.
| netdev | Network device |
Definition at line 61 of file netdevice.c.
References ENOTCONN, EUNKNOWN_LINK_STATUS, and net_device::link_rc.
Referenced by __vxge_hw_vpath_alarm_process(), atl1e_check_link(), atl1e_down(), atl1e_probe(), atl1e_sw_init(), ifec_link_update(), mii_check_link(), mii_check_media(), mtnic_open(), myri10ge_interrupt_handler(), net80211_netdev_close(), net80211_set_state(), phantom_poll_link_state(), sis190_phy_task(), sis190_probe(), skge_devinit(), skge_down(), skge_link_down(), sky2_link_down(), sky2_up(), vxge_close(), vxge_device_register(), and vxge_open().
00061 { 00062 00063 switch ( netdev->link_rc ) { 00064 case 0: 00065 case -EUNKNOWN_LINK_STATUS: 00066 netdev->link_rc = -ENOTCONN; 00067 break; 00068 default: 00069 /* Avoid clobbering a more detailed link status code, 00070 * if one is already set. 00071 */ 00072 break; 00073 } 00074 }
| int netdev_tx | ( | struct net_device * | netdev, | |
| struct io_buffer * | iobuf | |||
| ) |
Transmit raw packet via network device.
| netdev | Network device | |
| iobuf | I/O buffer |
| rc | Return status code |
Definition at line 125 of file netdevice.c.
References io_buffer::data, DBGC, ENETUNREACH, iob_len(), io_buffer::list, list_add_tail, netdev_is_open(), netdev_tx_complete_err(), net_device::op, net_device_error::rc, net_device_operations::transmit, and net_device::tx_queue.
Referenced by efi_snp_transmit(), gdbudp_recv(), gdbudp_send(), net80211_handle_auth(), net80211_netdev_transmit(), net80211_tx_mgmt(), net_tx(), and pxenv_undi_transmit().
00125 { 00126 int rc; 00127 00128 DBGC ( netdev, "NETDEV %p transmitting %p (%p+%zx)\n", 00129 netdev, iobuf, iobuf->data, iob_len ( iobuf ) ); 00130 00131 list_add_tail ( &iobuf->list, &netdev->tx_queue ); 00132 00133 if ( ! netdev_is_open ( netdev ) ) { 00134 rc = -ENETUNREACH; 00135 goto err; 00136 } 00137 00138 if ( ( rc = netdev->op->transmit ( netdev, iobuf ) ) != 0 ) 00139 goto err; 00140 00141 return 0; 00142 00143 err: 00144 netdev_tx_complete_err ( netdev, iobuf, rc ); 00145 return rc; 00146 }
| void netdev_tx_complete_err | ( | struct net_device * | netdev, | |
| struct io_buffer * | iobuf, | |||
| int | rc | |||
| ) |
Complete network transmission.
| netdev | Network device | |
| iobuf | I/O buffer | |
| rc | Packet status code |
Definition at line 157 of file netdevice.c.
References assert, DBGC, free_iob(), io_buffer::list, list_del, netdev_record_stat(), list_head::next, NULL, list_head::prev, strerror(), and net_device::tx_stats.
Referenced by e1000_process_tx_packets(), e1000e_process_tx_packets(), ifec_tx_process(), igb_process_tx_packets(), ipoib_complete_send(), natsemi_poll(), net80211_tx_complete(), netdev_tx(), netdev_tx_complete(), netdev_tx_complete_next_err(), phantom_close(), sis190_process_tx(), and vxge_xmit_compl().
00158 { 00159 00160 /* Update statistics counter */ 00161 netdev_record_stat ( &netdev->tx_stats, rc ); 00162 if ( rc == 0 ) { 00163 DBGC ( netdev, "NETDEV %p transmission %p complete\n", 00164 netdev, iobuf ); 00165 } else { 00166 DBGC ( netdev, "NETDEV %p transmission %p failed: %s\n", 00167 netdev, iobuf, strerror ( rc ) ); 00168 } 00169 00170 /* Catch data corruption as early as possible */ 00171 assert ( iobuf->list.next != NULL ); 00172 assert ( iobuf->list.prev != NULL ); 00173 00174 /* Dequeue and free I/O buffer */ 00175 list_del ( &iobuf->list ); 00176 free_iob ( iobuf ); 00177 }
| void netdev_tx_complete_next_err | ( | struct net_device * | netdev, | |
| int | rc | |||
| ) |
Complete network transmission.
| netdev | Network device | |
| rc | Packet status code |
Definition at line 187 of file netdevice.c.
References io_buffer::list, list_for_each_entry, netdev_tx_complete_err(), and net_device::tx_queue.
Referenced by netdev_tx_complete_next(), and netdev_tx_flush().
00187 { 00188 struct io_buffer *iobuf; 00189 00190 list_for_each_entry ( iobuf, &netdev->tx_queue, list ) { 00191 netdev_tx_complete_err ( netdev, iobuf, rc ); 00192 return; 00193 } 00194 }
| void netdev_rx | ( | struct net_device * | netdev, | |
| struct io_buffer * | iobuf | |||
| ) |
Add packet to receive queue.
| netdev | Network device | |
| iobuf | I/O buffer, or NULL |
Definition at line 218 of file netdevice.c.
References io_buffer::data, DBGC, iob_len(), io_buffer::list, list_add_tail, netdev_record_stat(), net_device::rx_queue, and net_device::rx_stats.
Referenced by a3c90x_process_rx_packets(), atl1e_clean_rx_irq(), b44_process_rx_packets(), e1000_process_rx_packets(), e1000e_process_rx_packets(), efab_receive(), ifec_rx_process(), igb_process_rx_packets(), ipoib_complete_recv(), legacy_poll(), mtnic_process_rx_cq(), myri10ge_net_poll(), natsemi_poll(), net80211_rx(), phantom_poll(), pnic_poll(), rtl8169_process_rx_packets(), rtl_poll(), sis190_process_rx(), skge_rx_done(), sky2_status_intr(), undinet_poll(), and vxge_hw_vpath_poll_rx().
00218 { 00219 00220 DBGC ( netdev, "NETDEV %p received %p (%p+%zx)\n", 00221 netdev, iobuf, iobuf->data, iob_len ( iobuf ) ); 00222 00223 /* Enqueue packet */ 00224 list_add_tail ( &iobuf->list, &netdev->rx_queue ); 00225 00226 /* Update statistics counter */ 00227 netdev_record_stat ( &netdev->rx_stats, 0 ); 00228 }
| void netdev_rx_err | ( | struct net_device * | netdev, | |
| struct io_buffer * | iobuf, | |||
| int | rc | |||
| ) |
Discard received packet.
| netdev | Network device | |
| iobuf | I/O buffer, or NULL | |
| rc | Packet status code |
iobuf may be NULL if, for example, the net device wishes to report an error due to being unable to allocate an I/O buffer.
Definition at line 242 of file netdevice.c.
References DBGC, free_iob(), netdev_record_stat(), net_device::rx_stats, and strerror().
Referenced by a3c90x_process_rx_packets(), atl1e_clean_rx_irq(), b44_process_rx_packets(), e1000_process_rx_packets(), e1000e_process_rx_packets(), ifec_rx_process(), igb_process_rx_packets(), ipoib_complete_recv(), natsemi_poll(), net80211_rx(), net80211_rx_err(), netdev_rx_flush(), phantom_refill_rx_ring(), pnic_poll(), rtl8169_process_rx_packets(), rtl_poll(), skge_rx_done(), sky2_receive(), sky2_status_intr(), undinet_poll(), and vxge_hw_vpath_poll_rx().
00243 { 00244 00245 DBGC ( netdev, "NETDEV %p failed to receive %p: %s\n", 00246 netdev, iobuf, strerror ( rc ) ); 00247 00248 /* Discard packet */ 00249 free_iob ( iobuf ); 00250 00251 /* Update statistics counter */ 00252 netdev_record_stat ( &netdev->rx_stats, rc ); 00253 }
| void netdev_poll | ( | struct net_device * | netdev | ) |
Poll for completed and received packets on network device.
| netdev | Network device |
Definition at line 264 of file netdevice.c.
References netdev_is_open(), net_device::op, and net_device_operations::poll.
Referenced by efi_snp_poll(), gdbudp_recv(), net_step(), net_tx(), and pxenv_undi_isr().
00264 { 00265 00266 if ( netdev_is_open ( netdev ) ) 00267 netdev->op->poll ( netdev ); 00268 }
| struct io_buffer* netdev_rx_dequeue | ( | struct net_device * | netdev | ) | [read] |
Remove packet from device's receive queue.
| netdev | Network device |
| iobuf | I/O buffer, or NULL |
Definition at line 279 of file netdevice.c.
References io_buffer::list, list_del, list_for_each_entry, NULL, and net_device::rx_queue.
Referenced by efi_snp_receive(), gdbudp_recv(), net_step(), netdev_rx_flush(), and pxenv_undi_isr().
00279 { 00280 struct io_buffer *iobuf; 00281 00282 list_for_each_entry ( iobuf, &netdev->rx_queue, list ) { 00283 list_del ( &iobuf->list ); 00284 return iobuf; 00285 } 00286 return NULL; 00287 }
| struct net_device* alloc_netdev | ( | size_t | priv_size | ) | [read] |
Allocate network device.
| priv_size | Size of private data area (net_device::priv) |
| netdev | Network device, or NULL |
Definition at line 326 of file netdevice.c.
References EUNKNOWN_LINK_STATUS, refcnt::free, free_netdev(), INIT_LIST_HEAD, net_device::link_rc, netdev, netdev_settings_init(), net_device::priv, net_device::refcnt, net_device::rx_queue, net_device::tx_queue, and zalloc().
Referenced by alloc_etherdev(), alloc_ipoibdev(), and net80211_alloc().
00326 { 00327 struct net_device *netdev; 00328 size_t total_len; 00329 00330 total_len = ( sizeof ( *netdev ) + priv_size ); 00331 netdev = zalloc ( total_len ); 00332 if ( netdev ) { 00333 netdev->refcnt.free = free_netdev; 00334 netdev->link_rc = -EUNKNOWN_LINK_STATUS; 00335 INIT_LIST_HEAD ( &netdev->tx_queue ); 00336 INIT_LIST_HEAD ( &netdev->rx_queue ); 00337 netdev_settings_init ( netdev ); 00338 netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) ); 00339 } 00340 return netdev; 00341 }
| int register_netdev | ( | struct net_device * | netdev | ) |
Register network device.
| netdev | Network device |
| rc | Return status code |
Definition at line 352 of file netdevice.c.
References DBGC, net_device::dev, net_device::hw_addr, ll_protocol::init_addr, net_device::list, list_add_tail, net_device::ll_addr, net_device::ll_protocol, device::name, net_device::name, netdev_addr(), netdev_get(), netdev_settings(), NULL, register_settings(), snprintf(), and strerror().
Referenced by a3c90x_probe(), atl1e_probe(), b44_probe(), e1000_probe(), e1000e_probe(), efab_probe(), ifec_pci_probe(), igb_probe(), ipoib_probe(), legacy_probe(), mtnic_probe(), myri10ge_pci_probe(), natsemi_probe(), net80211_register(), phantom_probe(), pnic_probe(), rtl8169_probe(), rtl_probe(), sis190_probe(), skge_probe(), sky2_probe(), undinet_probe(), and vxge_device_register().
00352 { 00353 static unsigned int ifindex = 0; 00354 int rc; 00355 00356 /* Create device name */ 00357 snprintf ( netdev->name, sizeof ( netdev->name ), "net%d", 00358 ifindex++ ); 00359 00360 /* Set initial link-layer address */ 00361 netdev->ll_protocol->init_addr ( netdev->hw_addr, netdev->ll_addr ); 00362 00363 /* Register per-netdev configuration settings */ 00364 if ( ( rc = register_settings ( netdev_settings ( netdev ), 00365 NULL ) ) != 0 ) { 00366 DBGC ( netdev, "NETDEV %p could not register settings: %s\n", 00367 netdev, strerror ( rc ) ); 00368 return rc; 00369 } 00370 00371 /* Add to device list */ 00372 netdev_get ( netdev ); 00373 list_add_tail ( &netdev->list, &net_devices ); 00374 DBGC ( netdev, "NETDEV %p registered as %s (phys %s hwaddr %s)\n", 00375 netdev, netdev->name, netdev->dev->name, 00376 netdev_addr ( netdev ) ); 00377 00378 return 0; 00379 }
| int netdev_open | ( | struct net_device * | netdev | ) |
Open network device.
| netdev | Network device |
| rc | Return status code |
Definition at line 387 of file netdevice.c.
References DBGC, list_add, NETDEV_OPEN, net_device::op, net_device_operations::open, net_device::open_list, and net_device::state.
Referenced by efi_snp_initialize(), efi_snp_reset(), gdbudp_ensure_netdev_open(), ifopen(), iwlist(), and pxe_netdev_open().
00387 { 00388 int rc; 00389 00390 /* Do nothing if device is already open */ 00391 if ( netdev->state & NETDEV_OPEN ) 00392 return 0; 00393 00394 DBGC ( netdev, "NETDEV %p opening\n", netdev ); 00395 00396 /* Open the device */ 00397 if ( ( rc = netdev->op->open ( netdev ) ) != 0 ) 00398 return rc; 00399 00400 /* Mark as opened */ 00401 netdev->state |= NETDEV_OPEN; 00402 00403 /* Add to head of open devices list */ 00404 list_add ( &netdev->open_list, &open_net_devices ); 00405 00406 return 0; 00407 }
| void netdev_close | ( | struct net_device * | netdev | ) |
Close network device.
| netdev | Network device |
Definition at line 414 of file netdevice.c.
References net_device_operations::close, DBGC, list_del, NETDEV_OPEN, netdev_rx_flush(), netdev_tx_flush(), net_device::op, net_device::open_list, and net_device::state.
Referenced by efi_snp_reset(), efi_snp_shutdown(), ifclose(), iwlist(), pxe_netdev_close(), and unregister_netdev().
00414 { 00415 00416 /* Do nothing if device is already closed */ 00417 if ( ! ( netdev->state & NETDEV_OPEN ) ) 00418 return; 00419 00420 DBGC ( netdev, "NETDEV %p closing\n", netdev ); 00421 00422 /* Close the device */ 00423 netdev->op->close ( netdev ); 00424 00425 /* Flush TX and RX queues */ 00426 netdev_tx_flush ( netdev ); 00427 netdev_rx_flush ( netdev ); 00428 00429 /* Mark as closed */ 00430 netdev->state &= ~NETDEV_OPEN; 00431 00432 /* Remove from open devices list */ 00433 list_del ( &netdev->open_list ); 00434 }
| void unregister_netdev | ( | struct net_device * | netdev | ) |
Unregister network device.
| netdev | Network device |
Definition at line 443 of file netdevice.c.
References DBGC, net_device::list, list_del, netdev_close(), netdev_put(), netdev_settings(), and unregister_settings().
Referenced by a3c90x_remove(), atl1e_remove(), b44_remove(), e1000_remove(), e1000e_remove(), efab_probe(), efab_remove(), ifec_pci_remove(), igb_remove(), ipoib_remove(), legacy_remove(), mtnic_disable(), myri10ge_pci_remove(), natsemi_remove(), net80211_unregister(), phantom_probe(), phantom_remove(), pnic_remove(), rtl8169_remove(), rtl_probe(), rtl_remove(), sis190_remove(), skge_remove(), sky2_remove(), undinet_remove(), and vxge_device_unregister().
00443 { 00444 00445 /* Ensure device is closed */ 00446 netdev_close ( netdev ); 00447 00448 /* Unregister per-netdev configuration settings */ 00449 unregister_settings ( netdev_settings ( netdev ) ); 00450 00451 /* Remove from device list */ 00452 list_del ( &netdev->list ); 00453 netdev_put ( netdev ); 00454 DBGC ( netdev, "NETDEV %p unregistered\n", netdev ); 00455 }
| void netdev_irq | ( | struct net_device * | netdev, | |
| int | enable | |||
| ) |
Enable or disable interrupts.
| netdev | Network device | |
| enable | Interrupts should be enabled |
Definition at line 462 of file netdevice.c.
References net_device_operations::irq, NETDEV_IRQ_ENABLED, net_device::op, and net_device::state.
Referenced by pxe_netdev_close(), pxe_netdev_open(), pxenv_undi_isr(), and pxenv_undi_transmit().
00462 { 00463 00464 /* Enable or disable device interrupts */ 00465 netdev->op->irq ( netdev, enable ); 00466 00467 /* Record interrupt enabled state */ 00468 netdev->state &= ~NETDEV_IRQ_ENABLED; 00469 if ( enable ) 00470 netdev->state |= NETDEV_IRQ_ENABLED; 00471 }
| struct net_device* find_netdev | ( | const char * | name | ) | [read] |
Get network device by name.
| name | Network device name |
| netdev | Network device, or NULL |
Definition at line 479 of file netdevice.c.
References net_device::list, list_for_each_entry, net_device::name, netdev, NULL, and strcmp().
Referenced by dhcp_exec(), gdbudp_configure(), ifcommon_do_list(), and pxebs_exec().
00479 { 00480 struct net_device *netdev; 00481 00482 list_for_each_entry ( netdev, &net_devices, list ) { 00483 if ( strcmp ( netdev->name, name ) == 0 ) 00484 return netdev; 00485 } 00486 00487 return NULL; 00488 }
| struct net_device* find_netdev_by_location | ( | unsigned int | bus_type, | |
| unsigned int | location | |||
| ) | [read] |
Get network device by PCI bus:dev.fn address.
| bus_type | Bus type | |
| location | Bus location |
| netdev | Network device, or NULL |
Definition at line 497 of file netdevice.c.
References device_description::bus_type, device::desc, net_device::dev, net_device::list, list_for_each_entry, device_description::location, netdev, and NULL.
Referenced by efi_snp_netdev(), and pxenv_start_undi().
00498 { 00499 struct net_device *netdev; 00500 00501 list_for_each_entry ( netdev, &net_devices, list ) { 00502 if ( ( netdev->dev->desc.bus_type == bus_type ) && 00503 ( netdev->dev->desc.location == location ) ) 00504 return netdev; 00505 } 00506 00507 return NULL; 00508 }
| struct net_device* last_opened_netdev | ( | void | ) | [read] |
Get most recently opened network device.
| netdev | Most recently opened network device, or NULL |
Definition at line 515 of file netdevice.c.
References assert, list_for_each_entry, netdev, netdev_is_open(), NULL, and net_device::open_list.
Referenced by aoeboot(), iscsiboot(), nbi_prepare_dhcp(), parse_settings_name(), pxe_exec(), and store_cached_dhcpack().
00515 { 00516 struct net_device *netdev; 00517 00518 list_for_each_entry ( netdev, &open_net_devices, open_list ) { 00519 assert ( netdev_is_open ( netdev ) ); 00520 return netdev; 00521 } 00522 00523 return NULL; 00524 }
| int net_tx | ( | struct io_buffer * | iobuf, | |
| struct net_device * | netdev, | |||
| struct net_protocol * | net_protocol, | |||
| const void * | ll_dest | |||
| ) |
Transmit network-layer packet.
| iobuf | I/O buffer | |
| netdev | Network device | |
| net_protocol | Network-layer protocol | |
| ll_dest | Destination link-layer address |
| rc | Return status code |
Definition at line 539 of file netdevice.c.
References free_iob(), net_device::ll_addr, net_device::ll_protocol, net_protocol::net_proto, netdev_poll(), netdev_tx(), and ll_protocol::push.
Referenced by aoe_send_command(), arp_resolve(), arp_rx(), ipv4_tx(), ipv6_tx(), and wpa_send_eapol().
00540 { 00541 struct ll_protocol *ll_protocol = netdev->ll_protocol; 00542 int rc; 00543 00544 /* Force a poll on the netdevice to (potentially) clear any 00545 * backed-up TX completions. This is needed on some network 00546 * devices to avoid excessive losses due to small TX ring 00547 * sizes. 00548 */ 00549 netdev_poll ( netdev ); 00550 00551 /* Add link-layer header */ 00552 if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, netdev->ll_addr, 00553 net_protocol->net_proto ) ) != 0 ) { 00554 free_iob ( iobuf ); 00555 return rc; 00556 } 00557 00558 /* Transmit packet */ 00559 return netdev_tx ( netdev, iobuf ); 00560 }
| int net_rx | ( | struct io_buffer * | iobuf, | |
| struct net_device * | netdev, | |||
| uint16_t | net_proto, | |||
| const void * | ll_source | |||
| ) |
Process received network-layer packet.
| iobuf | I/O buffer | |
| netdev | Network device | |
| net_proto | Network-layer protocol, in network-byte order | |
| ll_source | Source link-layer address |
| rc | Return status code |
Definition at line 571 of file netdevice.c.
References DBGC, for_each_table_entry, free_iob(), net_protocol::net_proto, NET_PROTOCOLS, ntohs, and net_protocol::rx.
Referenced by net_step().
00572 { 00573 struct net_protocol *net_protocol; 00574 00575 /* Hand off to network-layer protocol, if any */ 00576 for_each_table_entry ( net_protocol, NET_PROTOCOLS ) { 00577 if ( net_protocol->net_proto == net_proto ) 00578 return net_protocol->rx ( iobuf, netdev, ll_source ); 00579 } 00580 00581 DBGC ( netdev, "NETDEV %p unknown network protocol %04x\n", 00582 netdev, ntohs ( net_proto ) ); 00583 free_iob ( iobuf ); 00584 return 0; 00585 }
| static void netdev_tx_complete | ( | struct net_device * | netdev, | |
| struct io_buffer * | iobuf | |||
| ) | [inline, static] |
Complete network transmission.
| netdev | Network device | |
| iobuf | I/O buffer |
Definition at line 541 of file netdevice.h.
References netdev_tx_complete_err().
Referenced by a3c90x_process_tx_packets(), atl1e_clean_tx_irq(), atl1e_clean_tx_ring(), b44_tx_complete(), e1000_process_tx_packets(), e1000e_process_tx_packets(), efab_free_resources(), efab_transmit_done(), ifec_tx_process(), igb_process_tx_packets(), legacy_transmit(), mtnic_process_tx_cq(), myri10ge_interrupt_handler(), natsemi_poll(), net80211_netdev_transmit(), phantom_poll(), pnic_transmit(), rtl8169_process_tx_packets(), rtl_poll(), sis190_process_tx(), skge_tx_done(), sky2_tx_complete(), undinet_transmit(), and vxge_xmit_compl().
00542 { 00543 netdev_tx_complete_err ( netdev, iobuf, 0 ); 00544 }
| static void netdev_tx_complete_next | ( | struct net_device * | netdev | ) | [inline, static] |
Complete network transmission.
| netdev | Network device |
Definition at line 553 of file netdevice.h.
References netdev_tx_complete_next_err().
00553 { 00554 netdev_tx_complete_next_err ( netdev, 0 ); 00555 }
| struct list_head net_devices |
Network device configuration settings operations.
Definition at line 116 of file netdev_settings.c.
Referenced by netdev_settings_init().
1.5.7.1