分享

Struct net_device_ops数据结构解释

 笔录收藏 2012-05-10

Struct net_device_ops数据结构

Linux内核2.6.32.27  \linux-2.6.32.27\include\linux\Netdevice.h中定义的,内核自己有相关注释,下面的解释就是内核自己注释的,

 此数据结果声明了

网络设备注册,启用,停止,

发送数据帧,

选择网卡队列(对于支持网卡多队列的),

设置网络设备mac地址(如果此接口没有被定义将不会修改mac地址,那说明驱动要实现,网卡都需要支持才行,不过现在基本都支持),

验证网络设备的mac地址,

改变网络设备的MTU(如果该接口没有被定义则返回error,那说明驱动要实现,网卡要支持才行,不过现在基本都支持)

获取网络设备的使用统计状态net_device_stats(比如统计发了多少个数据包,接受了多少个数据包,发了多少字节,接受了多少字节,多少坏包等等,详解下面net_device_stats数据结构,如果驱动没有定义此接口,dev->stats will be used.)

#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);

         int                       (*ndo_stop)(struct net_device *dev);

         netdev_tx_t              (*ndo_start_xmit) (struct sk_buff *skb,

                                                           struct net_device *dev);

         u16                     (*ndo_select_queue)(struct net_device *dev,

                                                            struct sk_buff *skb);

#define HAVE_CHANGE_RX_FLAGS

         void                    (*ndo_change_rx_flags)(struct net_device *dev,

                                                               int flags);

#define HAVE_SET_RX_MODE

         void                    (*ndo_set_rx_mode)(struct net_device *dev);

#define HAVE_MULTICAST

         void                    (*ndo_set_multicast_list)(struct net_device *dev);

#define HAVE_SET_MAC_ADDR

         int                       (*ndo_set_mac_address)(struct net_device *dev,

                                                               void *addr);

#define HAVE_VALIDATE_ADDR

         int                       (*ndo_validate_addr)(struct net_device *dev);

#define HAVE_PRIVATE_IOCTL

         int                       (*ndo_do_ioctl)(struct net_device *dev,

                                                       struct ifreq *ifr, int cmd);

#define HAVE_SET_CONFIG

         int                       (*ndo_set_config)(struct net_device *dev,

                                                         struct ifmap *map);

#define HAVE_CHANGE_MTU

         int                       (*ndo_change_mtu)(struct net_device *dev,

                                                          int new_mtu);

         int                       (*ndo_neigh_setup)(struct net_device *dev,

                                                           struct neigh_parms *);

#define HAVE_TX_TIMEOUT

         void                    (*ndo_tx_timeout) (struct net_device *dev);

 

         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

#define HAVE_NETDEV_POLL

         void                    (*ndo_poll_controller)(struct net_device *dev);

#endif

#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);

#endif

};

 

struct net_device_stats
{
 unsigned long rx_packets;  
 unsigned long tx_packets;  
 unsigned long rx_bytes;  
 unsigned long tx_bytes;  
 unsigned long rx_errors;  
 unsigned long tx_errors;  
 unsigned long rx_dropped;  
 unsigned long tx_dropped;  
 unsigned long multicast;  
 unsigned long collisions;

 
 unsigned long rx_length_errors;
 unsigned long rx_over_errors;  
 unsigned long rx_crc_errors;  
 unsigned long rx_frame_errors; 
 unsigned long rx_fifo_errors;  
 unsigned long rx_missed_errors; 

 
 unsigned long tx_aborted_errors;
 unsigned long tx_carrier_errors;
 unsigned long tx_fifo_errors;
 unsigned long tx_heartbeat_errors;
 unsigned long tx_window_errors;
 
 
 unsigned long rx_compressed;
 unsigned long tx_compressed;
};

Struct net_device_ops数据结构解释

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多