struct net_device在2.6.31中删减了很多,其函数接口用一个struct net_device_ops封装成一个独立的结构体,其结构如下:
structnet_device_ops{ int(*ndo_init)(structnet_device*dev); void(*ndo_uninit)(structnet_device*dev); int(*ndo_open)(structnet_device*dev); int(*ndo_stop)(structnet_device*dev); int(*ndo_start_xmit)(structsk_buff*skb, structnet_device*dev); u16(*ndo_select_queue)(structnet_device*dev, structsk_buff*skb); #defineHAVE_CHANGE_RX_FLAGS void(*ndo_change_rx_flags)(structnet_device*dev, intflags); #defineHAVE_SET_RX_MODE void(*ndo_set_rx_mode)(structnet_device*dev); #defineHAVE_MULTICAST void(*ndo_set_multicast_list)(structnet_device*dev); #defineHAVE_SET_MAC_ADDR int(*ndo_set_mac_address)(structnet_device*dev, void*addr); #defineHAVE_VALIDATE_ADDR int(*ndo_validate_addr)(structnet_device*dev); #defineHAVE_PRIVATE_IOCTL int(*ndo_do_ioctl)(structnet_device*dev, structifreq*ifr,intcmd); #defineHAVE_SET_CONFIG int(*ndo_set_config)(structnet_device*dev, structifmap*map); #defineHAVE_CHANGE_MTU int(*ndo_change_mtu)(structnet_device*dev, intnew_mtu); int(*ndo_neigh_setup)(structnet_device*dev, structneigh_parms*); #defineHAVE_TX_TIMEOUT void(*ndo_tx_timeout)(structnet_device*dev);
structnet_device_stats*(*ndo_get_stats)(structnet_device*dev);
void(*ndo_vlan_rx_register)(structnet_device*dev, structvlan_group*grp); void(*ndo_vlan_rx_add_vid)(structnet_device*dev, unsignedshortvid); void(*ndo_vlan_rx_kill_vid)(structnet_device*dev, unsignedshortvid); #ifdefCONFIG_NET_POLL_CONTROLLER #defineHAVE_NETDEV_POLL void(*ndo_poll_controller)(structnet_device*dev); #endif #ifdefined(CONFIG_FCOE)||defined(CONFIG_FCOE_MODULE) int(*ndo_fcoe_ddp_setup)(structnet_device*dev, u16 xid, structscatterlist*sgl, unsignedintsgc); int(*ndo_fcoe_ddp_done)(structnet_device*dev, u16 xid); #endif };
|
不难发现,很多原来的结构前面都在原来的基础上增加一个前缀ndo_,其原来的struct net_device结构体变为:
structnet_device {
/* * This is the first field of the "visible" part of this structure * (i.e. as seen by users in the "Space.c" file). It is the name * the interface. */ charname[IFNAMSIZ]; /* device name hash chain */ structhlist_nodename_hlist; /* snmp alias */ char*ifalias;
/* *I/O specific fields *FIXME: Merge these and struct ifmap into one */ unsignedlongmem_end;/* shared mem end*/ unsignedlongmem_start;/* shared mem start*/ unsignedlongbase_addr;/* device I/O address*/ unsignedintirq;/* device IRQ number*/
/* *Some hardware also needs these fields, but they are not *part of the usual set specified in Space.c. */
unsignedcharif_port;/* Selectable AUI, TP,..*/ unsignedchardma;/* DMA channel*/
unsignedlongstate;
structlist_headdev_list; structlist_headnapi_list;
/* Net device features */ unsignedlongfeatures; #defineNETIF_F_SG1/* Scatter/gather IO. */ #defineNETIF_F_IP_CSUM2/* Can checksum TCP/UDP over IPv4. */ #defineNETIF_F_NO_CSUM4/* Does not require checksum. F.e. loopack. */ #defineNETIF_F_HW_CSUM8/* Can checksum all the packets. */ #defineNETIF_F_IPV6_CSUM16/* Can checksum TCP/UDP over IPV6 */ #defineNETIF_F_HIGHDMA32/* Can DMA to high memory. */ #defineNETIF_F_FRAGLIST64/* Scatter/gather IO. */ #defineNETIF_F_HW_VLAN_TX128/* Transmit VLAN hw acceleration */ #defineNETIF_F_HW_VLAN_RX256/* Receive VLAN hw acceleration */ #defineNETIF_F_HW_VLAN_FILTER512/* Receive filtering on VLAN */ #defineNETIF_F_VLAN_CHALLENGED1024/* Device cannot handle VLAN packets */ #defineNETIF_F_GSO2048/* Enable software GSO. */ #defineNETIF_F_LLTX4096/* LockLess TX - deprecated. Please */ /* do not use LLTX in new drivers */ #defineNETIF_F_NETNS_LOCAL8192/* Does not change network namespaces */ #defineNETIF_F_GRO16384/* Generic receive offload */ #defineNETIF_F_LRO32768/* large receive offload */
/* the GSO_MASK reserves bits 16 through 23 */ #defineNETIF_F_FCOE_CRC(1<<24)/* FCoE CRC32 */ #defineNETIF_F_SCTP_CSUM(1<<25)/* SCTP checksum offload */
/* Segmentation offload features */ #defineNETIF_F_GSO_SHIFT16 #defineNETIF_F_GSO_MASK0x00ff0000 #defineNETIF_F_TSO(SKB_GSO_TCPV4<<NETIF_F_GSO_SHIFT) #defineNETIF_F_UFO(SKB_GSO_UDP<<NETIF_F_GSO_SHIFT) #defineNETIF_F_GSO_ROBUST(SKB_GSO_DODGY<<NETIF_F_GSO_SHIFT) #defineNETIF_F_TSO_ECN(SKB_GSO_TCP_ECN<<NETIF_F_GSO_SHIFT) #defineNETIF_F_TSO6(SKB_GSO_TCPV6<<NETIF_F_GSO_SHIFT) #defineNETIF_F_FSO(SKB_GSO_FCOE<<NETIF_F_GSO_SHIFT)
/* List of features with software fallbacks. */ #defineNETIF_F_GSO_SOFTWARE(NETIF_F_TSO|NETIF_F_TSO_ECN|NETIF_F_TSO6)
#defineNETIF_F_GEN_CSUM(NETIF_F_NO_CSUM|NETIF_F_HW_CSUM) #defineNETIF_F_V4_CSUM(NETIF_F_GEN_CSUM|NETIF_F_IP_CSUM) #defineNETIF_F_V6_CSUM(NETIF_F_GEN_CSUM|NETIF_F_IPV6_CSUM) #defineNETIF_F_ALL_CSUM(NETIF_F_V4_CSUM|NETIF_F_V6_CSUM)
/* * If one device supports one of these features, then enable them * for all in netdev_increment_features. */ #defineNETIF_F_ONE_FOR_ALL(NETIF_F_GSO_SOFTWARE|NETIF_F_GSO_ROBUST|/ NETIF_F_SG|NETIF_F_HIGHDMA|/ NETIF_F_FRAGLIST)
/* Interface index. Unique device identifier*/ intifindex; intiflink;
structnet_device_statsstats;
#ifdefCONFIG_WIRELESS_EXT /* List of functions to handle Wireless Extensions (instead of ioctl). * See <net/iw_handler.h> for details. Jean II */ conststructiw_handler_def*wireless_handlers; /* Instance data managed by the core of Wireless Extensions. */ structiw_public_data*wireless_data; #endif /* Management operations */ conststructnet_device_ops*netdev_ops; conststructethtool_ops*ethtool_ops;
/* Hardware header description */ conststructheader_ops*header_ops;
unsignedintflags;/* interface flags (a la BSD)*/ unsignedshortgflags; unsignedshortpriv_flags;/* Like 'flags' but invisible to userspace. */ unsignedshortpadded;/* How much padding added by alloc_netdev() */
unsignedcharoperstate;/* RFC2863 operstate */ unsignedcharlink_mode;/* mapping policy to operstate */
unsignedmtu;/* interface MTU value*/ unsignedshorttype;/* interface hardware type*/ unsignedshorthard_header_len;/* hardware hdr length*/
/* extra head- and tailroom the hardware may need, but not in all cases * can this be guaranteed, especially tailroom. Some cases also use * LL_MAX_HEADER instead to allocate the skb. */ unsignedshortneeded_headroom; unsignedshortneeded_tailroom;
structnet_device*master;/* Pointer to master device of a group, * which this device is member of. */
/* Interface address info. */ unsignedcharperm_addr[MAX_ADDR_LEN];/* permanent hw address */ unsignedcharaddr_len;/* hardware address length*/ unsignedshortdev_id;/* for shared network cards */
structnetdev_hw_addr_listuc;/* Secondary unicast mac addresses */ intuc_promisc; spinlock_taddr_list_lock; structdev_addr_list*mc_list;/* Multicast mac addresses*/ intmc_count;/* Number of installed mcasts*/ unsignedintpromiscuity; unsignedintallmulti;
/* Protocol specific pointers */
#ifdefCONFIG_NET_DSA void*dsa_ptr;/* dsa specific data */ #endif void*atalk_ptr;/* AppleTalk link */ void*ip_ptr;/* IPv4 specific data*/ void*dn_ptr;/* DECnet specific data */ void*ip6_ptr;/* IPv6 specific data */ void*ec_ptr;/* Econet specific data*/ void*ax25_ptr;/* AX.25 specific data */ structwireless_dev*ieee80211_ptr;/* IEEE 802.11 specific data, assign before registering */
/* * Cache line mostly used on receive path (including eth_type_trans()) */ unsignedlonglast_rx;/* Time of last Rx*/ /* Interface address info used in eth_type_trans() */ unsignedchar*dev_addr;/* hw address, (before bcast because most packets are unicast) */
structnetdev_hw_addr_listdev_addrs;/* list of device hw addresses */
unsignedcharbroadcast[MAX_ADDR_LEN];/* hw bcast add*/
structnetdev_queuerx_queue;
structnetdev_queue*_tx ____cacheline_aligned_in_smp;
/* Number of TX queues allocated at alloc_netdev_mq() time */ unsignedintnum_tx_queues;
/* Number of TX queues currently active in device */ unsignedintreal_num_tx_queues;
unsignedlongtx_queue_len;/* Max frames per queue allowed */ spinlock_ttx_global_lock; /* * One part is mostly used on xmit path (device) */ /* These may be needed for future network-power-down code. */
/* * trans_start here is expensive for high speed devices on SMP, * please use netdev_queue->trans_start instead. */ unsignedlongtrans_start;/* Time (in jiffies) of last Tx*/
intwatchdog_timeo;/* used by dev_watchdog() */ structtimer_listwatchdog_timer;
/* Number of references to this device */ atomic_trefcnt ____cacheline_aligned_in_smp;
/* delayed register/unregister */ structlist_headtodo_list; /* device index hash chain */ structhlist_nodeindex_hlist;
structnet_device*link_watch_next;
/* register/unregister state machine */ enum{NETREG_UNINITIALIZED=0, NETREG_REGISTERED,/* completed register_netdevice */ NETREG_UNREGISTERING,/* called unregister_netdevice */ NETREG_UNREGISTERED,/* completed unregister todo */ NETREG_RELEASED,/* called free_netdev */ NETREG_DUMMY,/* dummy device for NAPI poll */ }reg_state;
/* Called from unregister, can be used to call free_netdev */ void(*destructor)(structnet_device*dev);
#ifdefCONFIG_NETPOLL structnetpoll_info*npinfo; #endif
#ifdefCONFIG_NET_NS /* Network namespace this network device is inside */ structnet*nd_net; #endif
/* mid-layer private */ void*ml_priv;
/* bridge stuff */ structnet_bridge_port*br_port; /* macvlan */ structmacvlan_port*macvlan_port; /* GARP */ structgarp_port*garp_port;
/* class/net/name entry */ structdevicedev; /* space for optional statistics and wireless sysfs groups */ structattribute_group*sysfs_groups[3];
/* rtnetlink link ops */ conststructrtnl_link_ops*rtnl_link_ops;
/* VLAN feature mask */ unsignedlongvlan_features;
/* for setting kernel sock attribute on TCP connection setup */ #defineGSO_MAX_SIZE65536 unsignedintgso_max_size;
#ifdefCONFIG_DCB /* Data Center Bridging netlink ops */ structdcbnl_rtnl_ops*dcbnl_ops; #endif
#ifdefined(CONFIG_FCOE)||defined(CONFIG_FCOE_MODULE) /* max exchange id for FCoE LRO by ddp */ unsignedintfcoe_ddp_xid; #endif };
|
分享到:
相关推荐
一种通用的xml到结构体转换接口,用于程序的配置文件解析,使用者不需要再关注xml繁琐的规范。
08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_结构体指针08_07_C_04_...
windows CSHARP 结构体 UDP socket 传输
C#调用C++ dll, 包括结构体, 数组, 函数指针, 字符串等等
结构体可以看做是C语言中的类 但是结构体中不能封装函数,只能有数据成员 这个程序演示了如何像c++的类一样在结构体中增加函数 如果有错误,欢迎交流
用发送UDP消息的方式传输结构体数据,接收端定义同样的机构体 直接解析
详细地介绍了CAN的二次开发的各类Device Type 类型定义、VCI_BOARD_INFO结构体、VCI_CAN_OBJ结构体、VCI_INIT_CONFIG结构体、VCI_FILTER_RECORD、相关函数VCI_OpenDevice、VCI_CloseDevice、VCI_InitCan、VCI_...
网络协议解析,是一个报文解析为结构体的过程
成绩管理系统学生信息的整体注册,学生信息的修改等
把c++的结构体、数据类型、函数定义转换成对应的c#表达,很强大。
函数、指针与结构体练习题_参考答案.doc
利用MFC读入BMP格式图片存放在结构体中。
用结构体作为map的key实现及测试代码
完成端口功能说明:实现服务器发送结构体到客户端,接收后进行解析,获取发送的结构数据,并显示在IDC_LOGG控件里
接口封装_通过填写结构体中的参数来补充命令
第10章 结构体和共用体——向函数传递结构体C语言程序设计第10章 结构体和共用体向函数传递结构体向函数传递结构体的单个成员复制单个成员的内容向函数传递结构体的
将多个变量放到一个结构体中,减少函数传递时的多个参数传进传出的复杂性 结构体传进函数时,是以引用的形式传入的,不是以指针的形式。
实现一个链表类,能够实现对上述结构体组成的链表的插入、删除、排序等功能
串口编程函数和结构体串口编程函数和结构体
UDP的程序,自己设计的超时应答机制,帧数据结构采用共用体,丰富了UDP的功能,可以方便移植。