`
peizhiinfo
  • 浏览: 1427575 次
文章分类
社区版块
存档分类
最新评论

结构体net_device在2.6.31中函数接口的改动

 
阅读更多

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
};

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics