1. net_device在内核中代表一个网络设备。
网络设备驱动程序只需要填充net_device的具体成员,并注册net_device 即可实现硬件操作函数与内核的挂接。
net_device 是一个巨型结构体,包含了网络设备的属性描述和接口操作:
-
-
- struct
net_device { -
-
-
char name[IFNAMSIZ]; //网络设备的具体名字 -
-
struct pm_qos_request_list pm_qos_req; -
-
-
struct hlist_node name_hlist; -
-
char *ifalias; -
-
-
unsigned long mem_end; //设备说是用的共享内存的起始和结束地址 -
unsigned long mem_start; -
unsigned long base_addr; //网络设备I/O基地址 -
unsigned int irq; //设备使用的中断号 -
-
-
-
unsigned char if_port; //指定多端口设备使用哪个端口,仅针对多端口设备 -
unsigned char dma; //分配给该设备的 DMA 通道 -
-
unsigned long state; -
-
struct list_head dev_list; -
struct list_head napi_list; -
struct list_head unreg_list; -
-
-
unsigned long features; - #define
NETIF_F_SG 1 - #define
NETIF_F_IP_CSUM 2 - #define
NETIF_F_NO_CSUM 4 - #define
NETIF_F_HW_CSUM 8 - #define
NETIF_F_IPV6_CSUM 16 - #define
NETIF_F_HIGHDMA 32 - #define
NETIF_F_FRAGLIST 64 - #define
NETIF_F_HW_VLAN_TX 128 - #define
NETIF_F_HW_VLAN_RX 256 - #define
NETIF_F_HW_VLAN_FILTER 512 - #define
NETIF_F_VLAN_CHALLENGED 1024 - #define
NETIF_F_GSO 2048 - #define
NETIF_F_LLTX 4096 -
- #define
NETIF_F_NETNS_LOCAL 8192 - #define
NETIF_F_GRO 16384 - #define
NETIF_F_LRO 32768 -
-
- #define
NETIF_F_FCOE_CRC (1 << 24) - #define
NETIF_F_SCTP_CSUM (1 << 25) - #define
NETIF_F_FCOE_MTU (1 << 26) - #define
NETIF_F_NTUPLE (1 << 27) - #define
NETIF_F_RXHASH (1 << 28) -
-
- #define
NETIF_F_GSO_SHIFT 16 - #define
NETIF_F_GSO_MASK 0x00ff0000 - #define
NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT) - #define
NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT) - #define
NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT) - #define
NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT) - #define
NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) - #define
NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) -
-
- #define
NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ -
NETIF_F_TSO6 | NETIF_F_UFO) -
-
- #define
NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) - #define
NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM) - #define
NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) - #define
NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) -
-
- #define
NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ -
NETIF_F_SG | NETIF_F_HIGHDMA | \ -
NETIF_F_FRAGLIST) -
-
-
int ifindex; -
int iflink; -
-
struct net_device_stats stats; -
atomic_long_t rx_dropped; -
- #ifdef
CONFIG_WIRELESS_EXT -
-
const struct iw_handler_def * wireless_handlers; -
-
struct iw_public_data * wireless_data; - #endif
-
-
const struct net_device_ops *netdev_ops; -
const struct ethtool_ops *ethtool_ops; -
-
-
const struct header_ops *header_ops; -
-
unsigned int flags; //网络接口标志 -
unsigned short gflags; -
unsigned int priv_flags; -
unsigned short padded; -
-
unsigned char operstate; -
unsigned char link_mode; -
-
unsigned int mtu; //最大传输单元 -
unsigned short type; //硬件接口的类型 -
unsigned short hard_header_len; //网络设备的硬件头长度 -
-
-
unsigned short needed_headroom; -
unsigned short needed_tailroom; -
-
-
unsigned char perm_addr[MAX_ADDR_LEN]; -
unsigned char addr_assign_type; -
unsigned char addr_len; -
unsigned short dev_id; -
-
spinlock_t addr_list_lock; -
struct netdev_hw_addr_list uc; -
struct netdev_hw_addr_list mc; -
int uc_promisc; -
unsigned int promiscuity; -
unsigned int allmulti; -
-
-
-
- #if
defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) -
struct vlan_group __rcu *vlgrp; - #endif
- #ifdef
CONFIG_NET_DSA -
void *dsa_ptr; - #endif
-
void *atalk_ptr; -
struct in_device __rcu *ip_ptr; -
void *dn_ptr; -
struct inet6_dev __rcu *ip6_ptr; -
void *ec_ptr; -
void *ax25_ptr; -
struct wireless_dev *ieee80211_ptr; -
-
-
unsigned long last_rx; -
-
struct net_device *master; -
-
-
unsigned char *dev_addr; -
-
struct netdev_hw_addr_list dev_addrs; -
-
unsigned char broadcast[MAX_ADDR_LEN]; -
- #ifdef
CONFIG_RPS -
struct kset *queues_kset; -
-
struct netdev_rx_queue *_rx; -
-
-
unsigned int num_rx_queues; -
-
-
unsigned int real_num_rx_queues; - #endif
-
-
rx_handler_func_t *rx_handler; -
void *rx_handler_data; -
-
struct netdev_queue __rcu *ingress_queue; -
-
-
struct netdev_queue *_tx ____cacheline_aligned_in_smp; -
-
-
unsigned int num_tx_queues; -
-
-
unsigned int real_num_tx_queues; -
-
-
struct Qdisc *qdisc; -
-
unsigned long tx_queue_len; -
spinlock_t tx_global_lock; -
-
-
-
-
unsigned long trans_start; -
-
int watchdog_timeo; -
struct timer_list watchdog_timer; -
-
-
int __percpu *pcpu_refcnt; -
-
-
struct list_head todo_list; -
-
struct hlist_node index_hlist; -
-
struct list_head link_watch_list; -
-
-
enum { NETREG_UNINITIALIZED=0, -
NETREG_REGISTERED, -
NETREG_UNREGISTERING, -
NETREG_UNREGISTERED, -
NETREG_RELEASED, -
NETREG_DUMMY, -
} reg_state:16; -
-
enum { -
RTNL_LINK_INITIALIZED, -
RTNL_LINK_INITIALIZING, -
} rtnl_link_state:16; -
-
-
void (*destructor)(struct net_device *dev); -
- #ifdef
CONFIG_NETPOLL -
struct netpoll_info *npinfo; - #endif
-
- #ifdef
CONFIG_NET_NS -
-
struct net *nd_net; - #endif
-
-
-
union { -
void *ml_priv; -
struct pcpu_lstats __percpu *lstats; -
struct pcpu_tstats __percpu *tstats; -
struct pcpu_dstats __percpu *dstats; -
}; -
-
struct garp_port __rcu *garp_port; -
-
-
struct device dev; -
-
const struct attribute_group *sysfs_groups[4]; -
-
-
const struct rtnl_link_ops *rtnl_link_ops; -
-
-
unsigned long vlan_features; -
-
- #define
GSO_MAX_SIZE 65536 -
unsigned int gso_max_size; -
- #ifdef
CONFIG_DCB -
-
const struct dcbnl_rtnl_ops *dcbnl_ops; - #endif
-
- #if
defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) -
-
unsigned int fcoe_ddp_xid; - #endif
-
-
struct ethtool_rx_ntuple_list ethtool_ntuple_list; -
-
-
struct phy_device *phydev; - };
struct net_device { char name[IFNAMSIZ]; //网络设备的具体名字 struct pm_qos_request_list pm_qos_req; struct hlist_node name_hlist; char *ifalias; unsigned long mem_end; //设备说是用的共享内存的起始和结束地址 unsigned long mem_start; unsigned long base_addr; //网络设备I/O基地址 unsigned int irq; //设备使用的中断号 unsigned char if_port; //指定多端口设备使用哪个端口,仅针对多端口设备 unsigned char dma; //分配给该设备的 DMA 通道 unsigned long state; struct list_head dev_list; struct list_head napi_list; struct list_head unreg_list; unsigned long features; #define NETIF_F_SG 1 #define NETIF_F_IP_CSUM 2 #define NETIF_F_NO_CSUM 4 #define NETIF_F_HW_CSUM 8 #define NETIF_F_IPV6_CSUM 16 #define NETIF_F_HIGHDMA 32 #define NETIF_F_FRAGLIST 64 #define NETIF_F_HW_VLAN_TX 128 #define NETIF_F_HW_VLAN_RX 256 #define NETIF_F_HW_VLAN_FILTER 512 #define NETIF_F_VLAN_CHALLENGED 1024 #define NETIF_F_GSO 2048 #define NETIF_F_LLTX 4096 #define NETIF_F_NETNS_LOCAL 8192 #define NETIF_F_GRO 16384 #define NETIF_F_LRO 32768 #define NETIF_F_FCOE_CRC (1 << 24) #define NETIF_F_SCTP_CSUM (1 << 25) #define NETIF_F_FCOE_MTU (1 << 26) #define NETIF_F_NTUPLE (1 << 27) #define NETIF_F_RXHASH (1 << 28) #define NETIF_F_GSO_SHIFT 16 #define NETIF_F_GSO_MASK 0x00ff0000 #define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT) #define NETIF_F_UFO (SKB_GSO_UDP << NETIF_F_GSO_SHIFT) #define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT) #define NETIF_F_TSO_ECN (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT) #define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ NETIF_F_TSO6 | NETIF_F_UFO) #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) #define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM) #define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) #define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ NETIF_F_SG | NETIF_F_HIGHDMA | \ NETIF_F_FRAGLIST) int ifindex; int iflink; struct net_device_stats stats; atomic_long_t rx_dropped; #ifdef CONFIG_WIRELESS_EXT const struct iw_handler_def * wireless_handlers; struct iw_public_data * wireless_data; #endif const struct net_device_ops *netdev_ops; const struct ethtool_ops *ethtool_ops; const struct header_ops *header_ops; unsigned int flags; //网络接口标志 unsigned short gflags; unsigned int priv_flags; unsigned short padded; unsigned char operstate; unsigned char link_mode; unsigned int mtu; //最大传输单元 unsigned short type; //硬件接口的类型 unsigned short hard_header_len; //网络设备的硬件头长度 unsigned short needed_headroom; unsigned short needed_tailroom; unsigned char perm_addr[MAX_ADDR_LEN]; unsigned char addr_assign_type; unsigned char addr_len; unsigned short dev_id; spinlock_t addr_list_lock; struct netdev_hw_addr_list uc; struct netdev_hw_addr_list mc; int uc_promisc; unsigned int promiscuity; unsigned int allmulti; #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) struct vlan_group __rcu *vlgrp; #endif #ifdef CONFIG_NET_DSA void *dsa_ptr; #endif void *atalk_ptr; struct in_device __rcu *ip_ptr; void *dn_ptr; struct inet6_dev __rcu *ip6_ptr; void *ec_ptr; void *ax25_ptr; struct wireless_dev *ieee80211_ptr; unsigned long last_rx; struct net_device *master; unsigned char *dev_addr; struct netdev_hw_addr_list dev_addrs; unsigned char broadcast[MAX_ADDR_LEN]; #ifdef CONFIG_RPS struct kset *queues_kset; struct netdev_rx_queue *_rx; unsigned int num_rx_queues; unsigned int real_num_rx_queues; #endif rx_handler_func_t *rx_handler; void *rx_handler_data; struct netdev_queue __rcu *ingress_queue; struct netdev_queue *_tx ____cacheline_aligned_in_smp; unsigned int num_tx_queues; unsigned int real_num_tx_queues; struct Qdisc *qdisc; unsigned long tx_queue_len; spinlock_t tx_global_lock; unsigned long trans_start; int watchdog_timeo; struct timer_list watchdog_timer; int __percpu *pcpu_refcnt; struct list_head todo_list; struct hlist_node index_hlist; struct list_head link_watch_list; enum { NETREG_UNINITIALIZED=0, NETREG_REGISTERED, NETREG_UNREGISTERING, NETREG_UNREGISTERED, NETREG_RELEASED, NETREG_DUMMY, } reg_state:16; enum { RTNL_LINK_INITIALIZED, RTNL_LINK_INITIALIZING, } rtnl_link_state:16; void (*destructor)(struct net_device *dev); #ifdef CONFIG_NETPOLL struct netpoll_info *npinfo; #endif #ifdef CONFIG_NET_NS struct net *nd_net; #endif union { void *ml_priv; struct pcpu_lstats __percpu *lstats; struct pcpu_tstats __percpu *tstats; struct pcpu_dstats __percpu *dstats; }; struct garp_port __rcu *garp_port; struct device dev; const struct attribute_group *sysfs_groups[4]; const struct rtnl_link_ops *rtnl_link_ops; unsigned long vlan_features; #define GSO_MAX_SIZE 65536 unsigned int gso_max_size; #ifdef CONFIG_DCB const struct dcbnl_rtnl_ops *dcbnl_ops; #endif #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) unsigned int fcoe_ddp_xid; #endif struct ethtool_rx_ntuple_list ethtool_ntuple_list; struct phy_device *phydev; };
--- flags : 指网络接口标志,以IFF_ 开头 (interface flags), 部分标志由内核管理,其他的标志在接口初始化时被设置,以说明接口的能力和特性。
各类接口标志定义如下:
-
- #define
IFF_UP 0x1 - #define
IFF_BROADCAST 0x2 //允许广播 - #define
IFF_DEBUG 0x4 - #define
IFF_LOOPBACK 0x8 //回环 - #define
IFF_POINTOPOINT 0x10 //接口连接点到点链路 - #define
IFF_NOTRAILERS 0x20 - #define
IFF_RUNNING 0x40 - #define
IFF_NOARP 0x80 //不能执行ARP - #define
IFF_PROMISC 0x100 - #define
IFF_ALLMULTI 0x200 -
- #define
IFF_MASTER 0x400 - #define
IFF_SLAVE 0x800 -
- #define
IFF_MULTICAST 0x1000 //允许组播 -
- #define
IFF_PORTSEL 0x2000 - #define
IFF_AUTOMEDIA 0x4000 - #define
IFF_DYNAMIC 0x8000 -
- #define
IFF_LOWER_UP 0x10000 - #define
IFF_DORMANT 0x20000 -
- #define
IFF_ECHO 0x40000 -
- #define
IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\ -
IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) -
-
- #define
IFF_802_1Q_VLAN 0x1 - #define
IFF_EBRIDGE 0x2 - #define
IFF_SLAVE_INACTIVE 0x4 - #define
IFF_MASTER_8023AD 0x8 - #define
IFF_MASTER_ALB 0x10 - #define
IFF_BONDING 0x20 - #define
IFF_SLAVE_NEEDARP 0x40 - #define
IFF_ISATAP 0x80 - #define
IFF_MASTER_ARPMON 0x100 - #define
IFF_WAN_HDLC 0x200 - #define
IFF_XMIT_DST_RELEASE 0x400 - #define
IFF_DONT_BRIDGE 0x800 - #define
IFF_IN_NETPOLL 0x1000 - #define
IFF_DISABLE_NETPOLL 0x2000 - #define
IFF_MACVLAN_PORT 0x4000 - #define
IFF_BRIDGE_PORT 0x8000 - #define
IFF_OVS_DATAPATH 0x10000
#define IFF_UP 0x1 #define IFF_BROADCAST 0x2 //允许广播 #define IFF_DEBUG 0x4 #define IFF_LOOPBACK 0x8 //回环 #define IFF_POINTOPOINT 0x10 //接口连接点到点链路 #define IFF_NOTRAILERS 0x20 #define IFF_RUNNING 0x40 #define IFF_NOARP 0x80 //不能执行ARP #define IFF_PROMISC 0x100 #define IFF_ALLMULTI 0x200 #define IFF_MASTER 0x400 #define IFF_SLAVE 0x800 #define IFF_MULTICAST 0x1000 //允许组播 #define IFF_PORTSEL 0x2000 #define IFF_AUTOMEDIA 0x4000 #define IFF_DYNAMIC 0x8000 #define IFF_LOWER_UP 0x10000 #define IFF_DORMANT 0x20000 #define IFF_ECHO 0x40000 #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\ IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) #define IFF_802_1Q_VLAN 0x1 #define IFF_EBRIDGE 0x2 #define IFF_SLAVE_INACTIVE 0x4 #define IFF_MASTER_8023AD 0x8 #define IFF_MASTER_ALB 0x10 #define IFF_BONDING 0x20 #define IFF_SLAVE_NEEDARP 0x40 #define IFF_ISATAP 0x80 #define IFF_MASTER_ARPMON 0x100 #define IFF_WAN_HDLC 0x200 #define IFF_XMIT_DST_RELEASE 0x400 #define IFF_DONT_BRIDGE 0x800 #define IFF_IN_NETPOLL 0x1000 #define IFF_DISABLE_NETPOLL 0x2000 #define IFF_MACVLAN_PORT 0x4000 #define IFF_BRIDGE_PORT 0x8000 #define IFF_OVS_DATAPATH 0x10000
2. net_device_ops 是操作 net_device的各种操作:
之前linux版本的net_device操作函数,直接就在net_device结构里定义,但是新的linux版本,把这些函数归纳到了 net_device_ops 中了。
-
- #define
HAVE_NET_DEVICE_OPS - struct
net_device_ops { -
int (*ndo_init)(struct net_device *dev); -
void (*ndo_uninit)(struct net_device *dev); -
int (*ndo_open)(struct net_device *dev); //打开网络接口设备,获得设备需要的I/O地址,IRQ,DMA通道等。 -
int (*ndo_stop)(struct net_device *dev); //关闭网络设备 -
netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb, //驱动数据包发送,参数是sk_buff,使得驱动程序获取从上层传递下来的数据包 -
struct net_device *dev); -
u16 (*ndo_select_queue)(struct net_device *dev, -
struct sk_buff *skb); -
void (*ndo_change_rx_flags)(struct net_device *dev, -
int flags); -
void (*ndo_set_rx_mode)(struct net_device *dev); -
void (*ndo_set_multicast_list)(struct net_device *dev); -
int (*ndo_set_mac_address)(struct net_device *dev, -
void *addr); -
int (*ndo_validate_addr)(struct net_device *dev); -
int (*ndo_do_ioctl)(struct net_device *dev, -
struct ifreq *ifr, int cmd); -
int (*ndo_set_config)(struct net_device *dev, -
struct ifmap *map); -
int (*ndo_change_mtu)(struct net_device *dev, -
int new_mtu); -
int (*ndo_neigh_setup)(struct net_device *dev, -
struct neigh_parms *); -
void (*ndo_tx_timeout) (struct net_device *dev); //当数据包发送超时时,该函数会被调用,该函数需重新启动数据包发送过程,或重新启动硬件等回复网络到正常状态。 -
-
struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, -
struct rtnl_link_stats64 *storage); -
struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); -
-
void (*ndo_vlan_rx_register)(struct net_device *dev, -
struct vlan_group *grp); -
void (*ndo_vlan_rx_add_vid)(struct net_device *dev, -
unsigned short vid); -
void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, -
unsigned short vid); - #ifdef
CONFIG_NET_POLL_CONTROLLER -
void (*ndo_poll_controller)(struct net_device *dev); -
int (*ndo_netpoll_setup)(struct net_device *dev, -
struct netpoll_info *info); -
void (*ndo_netpoll_cleanup)(struct net_device *dev); - #endif
-
int (*ndo_set_vf_mac)(struct net_device *dev, -
int queue, u8 *mac); -
int (*ndo_set_vf_vlan)(struct net_device *dev, -
int queue, u16 vlan, u8 qos); -
int (*ndo_set_vf_tx_rate)(struct net_device *dev, -
int vf, int rate); -
int (*ndo_get_vf_config)(struct net_device *dev, -
int vf, -
struct ifla_vf_info *ivf); -
int (*ndo_set_vf_port)(struct net_device *dev, -
int vf, -
struct nlattr *port[]); -
int (*ndo_get_vf_port)(struct net_device *dev, -
int vf, struct sk_buff *skb); - #if
defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) -
int (*ndo_fcoe_enable)(struct net_device *dev); -
int (*ndo_fcoe_disable)(struct net_device *dev); -
int (*ndo_fcoe_ddp_setup)(struct net_device *dev, -
u16 xid, -
struct scatterlist *sgl, -
unsigned int sgc); -
int (*ndo_fcoe_ddp_done)(struct net_device *dev, -
u16 xid); - #define
NETDEV_FCOE_WWNN 0 - #define
NETDEV_FCOE_WWPN 1 -
int (*ndo_fcoe_get_wwn)(struct net_device *dev, -
u64 *wwn, int type); - #endif
- };
#define HAVE_NET_DEVICE_OPS struct net_device_ops { int (*ndo_init)(struct net_device *dev); void (*ndo_uninit)(struct net_device *dev); int (*ndo_open)(struct net_device *dev); //打开网络接口设备,获得设备需要的I/O地址,IRQ,DMA通道等。 int (*ndo_stop)(struct net_device *dev); //关闭网络设备 netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb, //驱动数据包发送,参数是sk_buff,使得驱动程序获取从上层传递下来的数据包 struct net_device *dev); u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb); void (*ndo_change_rx_flags)(struct net_device *dev, int flags); void (*ndo_set_rx_mode)(struct net_device *dev); void (*ndo_set_multicast_list)(struct net_device *dev); int (*ndo_set_mac_address)(struct net_device *dev, void *addr); int (*ndo_validate_addr)(struct net_device *dev); int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd); int (*ndo_set_config)(struct net_device *dev, struct ifmap *map); int (*ndo_change_mtu)(struct net_device *dev, int new_mtu); int (*ndo_neigh_setup)(struct net_device *dev, struct neigh_parms *); void (*ndo_tx_timeout) (struct net_device *dev); //当数据包发送超时时,该函数会被调用,该函数需重新启动数据包发送过程,或重新启动硬件等回复网络到正常状态。 struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, struct rtnl_link_stats64 *storage); struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); #ifdef CONFIG_NET_POLL_CONTROLLER void (*ndo_poll_controller)(struct net_device *dev); int (*ndo_netpoll_setup)(struct net_device *dev, struct netpoll_info *info); void (*ndo_netpoll_cleanup)(struct net_device *dev); #endif int (*ndo_set_vf_mac)(struct net_device *dev, int queue, u8 *mac); int (*ndo_set_vf_vlan)(struct net_device *dev, int queue, u16 vlan, u8 qos); int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); int (*ndo_get_vf_config)(struct net_device *dev, int vf, struct ifla_vf_info *ivf); int (*ndo_set_vf_port)(struct net_device *dev, int vf, struct nlattr *port[]); int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) int (*ndo_fcoe_enable)(struct net_device *dev); int (*ndo_fcoe_disable)(struct net_device *dev); int (*ndo_fcoe_ddp_setup)(struct net_device *dev, u16 xid, struct scatterlist *sgl, unsigned int sgc); int (*ndo_fcoe_ddp_done)(struct net_device *dev, u16 xid); #define NETDEV_FCOE_WWNN 0 #define NETDEV_FCOE_WWPN 1 int (*ndo_fcoe_get_wwn)(struct net_device *dev, u64 *wwn, int type); #endif };