网络设备驱动程序-netdevice结构体关键部分注释

仅仅做个记录,内核4.19

struct net_device {
char name[IFNAMSIZ]; //网络设备的名称
struct hlist_node name_hlist;
char *ifalias;
/*
* I/O specific fields
* FIXME: Merge these and struct ifmap into one
*/
unsigned long mem_end; //设备所使用的共享内存的起始地址和结束地址
unsigned long mem_start;
unsigned long base_addr; //网络设备的I/O基地址
int irq; //设备使用的中端号

atomic_t carrier_changes;

/*
* Some hardware also needs these fields (state,dev_list,
* napi_list,unreg_list,close_list) but they are not
* part of the usual set specified in Space.c.
*/

unsigned long state;

struct list_head dev_list;
struct list_head napi_list;
struct list_head unreg_list;
struct list_head close_list;
struct list_head ptype_all;
struct list_head ptype_specific;

struct {
struct list_head upper;
struct list_head lower;
} adj_list;

netdev_features_t features;
netdev_features_t hw_features;
netdev_features_t wanted_features;
netdev_features_t vlan_features;
netdev_features_t hw_enc_features;
netdev_features_t mpls_features;
netdev_features_t gso_partial_features;

int ifindex;
int group;

struct net_device_stats stats;

atomic_long_t rx_dropped;
atomic_long_t tx_dropped;
atomic_long_t rx_nohandler;

#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;  //类似于file_ops
const struct ethtool_ops *ethtool_ops;       //用户控件ethtool工具的驱动层函数
#ifdef CONFIG_NET_SWITCHDEV
const struct switchdev_ops *switchdev_ops;
#endif
#ifdef CONFIG_HSR_PRP
const struct lredev_ops *lredev_ops;
#endif
#ifdef CONFIG_NET_L3_MASTER_DEV
const struct l3mdev_ops *l3mdev_ops;
#endif
#if IS_ENABLED(CONFIG_IPV6)
const struct ndisc_ops *ndisc_ops;
#endif

#ifdef CONFIG_XFRM
const struct xfrmdev_ops *xfrmdev_ops;
#endif

const struct header_ops *header_ops;

unsigned int flags; //网络接口标志
unsigned int priv_flags;

unsigned short gflags;
unsigned short padded;

unsigned char operstate;
unsigned char link_mode;

unsigned char if_port;
unsigned char dma;

unsigned int mtu; //最大的传输单元
unsigned int min_mtu;
unsigned int max_mtu;
unsigned short type; //接口的硬件类型
unsigned short hard_header_len;//网络设备的硬件头长度
unsigned char min_header_len;

unsigned short needed_headroom;
unsigned short needed_tailroom;

/* Interface address info. */
unsigned char perm_addr[MAX_ADDR_LEN];
unsigned char addr_assign_type;
unsigned char addr_len;
unsigned short neigh_priv_len;
unsigned short dev_id;
unsigned short dev_port;
spinlock_t addr_list_lock;
unsigned char name_assign_type;
bool uc_promisc;
struct netdev_hw_addr_list uc;
struct netdev_hw_addr_list mc;
struct netdev_hw_addr_list dev_addrs;

#ifdef CONFIG_SYSFS
struct kset *queues_kset;
#endif
unsigned int promiscuity;
unsigned int allmulti;

/* Protocol-specific pointers */

#if IS_ENABLED(CONFIG_VLAN_8021Q)
struct vlan_info __rcu *vlan_info;
#endif
#if IS_ENABLED(CONFIG_NET_DSA)
struct dsa_switch_tree *dsa_ptr;
#endif
#if IS_ENABLED(CONFIG_TIPC)
struct tipc_bearer __rcu *tipc_ptr;
#endif
void *atalk_ptr;
struct in_device __rcu *ip_ptr;
struct dn_dev __rcu *dn_ptr;
struct inet6_dev __rcu *ip6_ptr;
void *ax25_ptr;
struct wireless_dev *ieee80211_ptr;
struct wpan_dev *ieee802154_ptr;
#if IS_ENABLED(CONFIG_MPLS_ROUTING)
struct mpls_dev __rcu *mpls_ptr;
#endif

/*
* Cache lines mostly used on receive path (including eth_type_trans())
*/
/* Interface address info used in eth_type_trans() */
unsigned char *dev_addr; //设备的硬件地址

#ifdef CONFIG_SYSFS
struct netdev_rx_queue *_rx;

unsigned int num_rx_queues;
unsigned int real_num_rx_queues;
#endif

struct bpf_prog __rcu *xdp_prog;
unsigned long gro_flush_timeout;
rx_handler_func_t __rcu *rx_handler;
void __rcu *rx_handler_data;

#ifdef CONFIG_NET_CLS_ACT
struct tcf_proto __rcu *ingress_cl_list;
#endif
struct netdev_queue __rcu *ingress_queue;
#ifdef CONFIG_NETFILTER_INGRESS
struct nf_hook_entries __rcu *nf_hooks_ingress;
#endif

unsigned char broadcast[MAX_ADDR_LEN]; //广播地址
#ifdef CONFIG_RFS_ACCEL
struct cpu_rmap *rx_cpu_rmap;
#endif
struct hlist_node index_hlist;

/*
* Cache lines mostly used on transmit path
*/
struct netdev_queue *_tx ____cacheline_aligned_in_smp;
unsigned int num_tx_queues;
unsigned int real_num_tx_queues;
struct Qdisc *qdisc;
#ifdef CONFIG_NET_SCHED
DECLARE_HASHTABLE (qdisc_hash, 4);
#endif
unsigned int tx_queue_len;
spinlock_t tx_global_lock;
int watchdog_timeo;

#ifdef CONFIG_XPS
struct xps_dev_maps __rcu *xps_maps;
#endif
#ifdef CONFIG_NET_CLS_ACT
struct tcf_proto __rcu *egress_cl_list;
#endif

/* These may be needed for future network-power-down code. */
struct timer_list watchdog_timer;

int __percpu *pcpu_refcnt;
struct list_head todo_list;

struct list_head link_watch_list;

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:8;

bool dismantle;

enum {
RTNL_LINK_INITIALIZED,
RTNL_LINK_INITIALIZING,
} rtnl_link_state:16;

bool needs_free_netdev;
void (*priv_destructor)(struct net_device *dev);

#ifdef CONFIG_NETPOLL
struct netpoll_info __rcu *npinfo;
#endif

possible_net_t nd_net;

/* mid-layer private */
union {
void *ml_priv;
struct pcpu_lstats __percpu *lstats;
struct pcpu_sw_netstats __percpu *tstats;
struct pcpu_dstats __percpu *dstats;
struct pcpu_vstats __percpu *vstats;
};

#if IS_ENABLED(CONFIG_GARP)
struct garp_port __rcu *garp_port;
#endif
#if IS_ENABLED(CONFIG_MRP)
struct mrp_port __rcu *mrp_port;
#endif

struct device dev;
const struct attribute_group *sysfs_groups[4];
const struct attribute_group *sysfs_rx_queue_group;

const struct rtnl_link_ops *rtnl_link_ops;

/* for setting kernel sock attribute on TCP connection setup */
#define GSO_MAX_SIZE 65536
unsigned int gso_max_size;
#define GSO_MAX_SEGS 65535
u16 gso_max_segs;

#ifdef CONFIG_DCB
const struct dcbnl_rtnl_ops *dcbnl_ops;
#endif
u8 num_tc;
struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
u8 prio_tc_map[TC_BITMASK + 1];

#if IS_ENABLED(CONFIG_FCOE)
unsigned int fcoe_ddp_xid;
#endif
#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
struct netprio_map __rcu *priomap;
#endif
struct phy_device *phydev;
struct lock_class_key *qdisc_tx_busylock;
struct lock_class_key *qdisc_running_key;
bool proto_down;
};

原文地址:https://www.cnblogs.com/yddeboke/p/11703692.html

时间: 2024-11-09 03:29:44

网络设备驱动程序-netdevice结构体关键部分注释的相关文章

struct net_device网络设备结构体详解

在linux中使用struct net_device结构体来描述每一个网络设备.同时这个用来刻画网络设备的struct net_device结构体包含的字段非常的多,以至于内核的开发者都觉得在现在的linux内核中,这个struct net_device是一个大的错误.    在本篇文章中,只介绍struct net_device中的一些字段,其他的字段在以后使用的时候再说.    #define IFNAMSIZ 32    struct net_device    {        //用于

FFMPEG关键结构体

// FFMPEG关键结构体:// 转载 http://blog.csdn.net/leixiaohua1020/article/details/14214577// 2016.2.26 AVFrame(位于avcodec.h)结构体一般用于存储原始数据.===============================================================================下面看几个主要变量的作用(在这里考虑解码的情况):uint8_t *data[AV_N

结构体中函数指针与typedef关键用途(函数指针)

// 结构体函数指针.  #include<stdio.h> //为了代码的移植考虑,一般使用typedef定义函数指针类 ,另一个好处是,减少代码的书写量.  typedef void (*shout)(char *name,int age); typedef struct {  //用指针来存储字符串     char *name;    int age ;    shout personinfo; }person; //类似于c++中类方法的实现,在这里,是为结构体中指针函数提供实现.在

Z-stack关键结构体解析

OSAL的消息队列 每一个消息都包含一个消息头osal_msg_hdr_t和用户自定义的消息,osal_msg_hdr_t结构体定义如下: typedef struct { void *next; uint16 len; uint8 dest_id; } osal_msg_hdr_t; 在事件处理函数SampleApp_ProcessEvent()中,从消息队列中接收到一个消息,后才调用SampleApp_MessageMSGCB,接收到的消息中如何就包含了用户接收的数据消息呢? 是这样子的:每

C语言--&gt;(十四)结构体、宏、编译

知识点: 1.结构体 struct 2.typedef关键字 3.宏的定义 4.宏与函数的区别 5.文件包含和多文件编译 6.条件编译 ===========================结构体 思考:如果现在希望保存一个学生的信息,姓名,身高,年龄,地址,该如何保存 char name[64]; float height; int age; char addr[64]; 1.什么是结构体 struct 结构体指的是一种数据结构,是c语言中复合数据类型的一 种多种不同数据类型的集合 2.结构体

网络设备驱动程序框架

1网络设备驱动程序框架可以分为四层 网络协议接口层----------------------------------------------------------------------------------------------------------数据的发送                                                                数据的接收                      hard_start_xmit(struct

linux网络设备驱动程序

4.linux网络设备驱动程序体系结构 -------------------------------------- | 数据包发送 | 数据包接收 | ----->网络协议接口层 | dev_queue_xmit() | netif_rx() | |-------------------------------------- | 结构体 net_device | ----->网络设备接 口层 -------------------------------------- | 数据包发送 | 中

线程临界区相关结构体和函数

单进程的线程可以使用临界资源对象来解决同步互斥问题,该对象不能保证哪个线程能够获得到临界资源对象,因而该系统能公平的对待每一个线程. 每个进程中访问临界资源的那段代码称为临界区(Critical Section)(临界资源是一次仅允许一个进程使用的共享资源).每次只准许一个进程进入临界区,进入后不允许其他进程进入.不论是硬件临界资源,还是软件临界资源,多个进程必须互斥地对它进行访问. 多个进程中涉及到同一个临界资源的临界区称为相关临界区. 进程进入临界区的调度原则是: 1.如果有若干进程要求进入

Windows驱动开发-_DRIVER_OBJECT结构体

每个驱动程序会有唯一的驱动对象与之对应,并且这个驱动对象是在驱动加载的时候,被内核中的对象管理程序所创建的,内核对一个驱动只加载一个实例,是由内核中的I/O管理器负责加载的,驱动程序需要在DriverEntry中初始化该驱动对象. _DRIVER_OBJECT结构体源码 typedef struct _DRIVER_OBJECT { CSHORT Type; CSHORT Size; //每个驱动程序有一个或多个设备对象,每个设备对象都有一个指针指向下一个设备对象,最后一个设备对象指向空.此处是