📄 netdevice.h
字号:
/* Instance data managed by the core of Wireless Extensions. */ struct iw_public_data * wireless_data; const struct ethtool_ops *ethtool_ops; /* * This marks the end of the "visible" part of the structure. All * fields hereafter are internal to the system, and may change at * will (read: may be cleaned up at will). */ unsigned int flags; /* interface flags (a la BSD) */ unsigned short gflags; unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ unsigned short padded; /* How much padding added by alloc_netdev() */ unsigned char operstate; /* RFC2863 operstate */ unsigned char link_mode; /* mapping policy to operstate */ unsigned mtu; /* interface MTU value */ unsigned short type; /* interface hardware type */ unsigned short hard_header_len; /* hardware hdr length */ struct net_device *master; /* Pointer to master device of a group, * which this device is member of. */ /* Interface address info. */ unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ unsigned char addr_len; /* hardware address length */ unsigned short dev_id; /* for shared network cards */ struct dev_mc_list *mc_list; /* Multicast mac addresses */ int mc_count; /* Number of installed mcasts */ int promiscuity; int allmulti; /* Protocol specific pointers */ 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 *//* * Cache line mostly used on receive path (including eth_type_trans()) */ struct list_head poll_list ____cacheline_aligned_in_smp; /* Link to poll list */ int (*poll) (struct net_device *dev, int *quota); int quota; int weight; unsigned long last_rx; /* Time of last Rx */ /* Interface address info used in eth_type_trans() */ unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast because most packets are unicast) */ unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add *//* * Cache line mostly used on queue transmit path (qdisc) */ /* device queue lock */ spinlock_t queue_lock ____cacheline_aligned_in_smp; struct Qdisc *qdisc; struct Qdisc *qdisc_sleeping; struct list_head qdisc_list; unsigned long tx_queue_len; /* Max frames per queue allowed */ /* Partially transmitted GSO packet. */ struct sk_buff *gso_skb; /* ingress path synchronizer */ spinlock_t ingress_lock; struct Qdisc *qdisc_ingress;/* * One part is mostly used on xmit path (device) */ /* hard_start_xmit synchronizer */ spinlock_t _xmit_lock ____cacheline_aligned_in_smp; /* cpu id of processor entered to hard_start_xmit or -1, if nobody entered there. */ int xmit_lock_owner; void *priv; /* pointer to private data */ int (*hard_start_xmit) (struct sk_buff *skb, struct net_device *dev); /* These may be needed for future network-power-down code. */ unsigned long trans_start; /* Time (in jiffies) of last Tx */ int watchdog_timeo; /* used by dev_watchdog() */ struct timer_list watchdog_timer;/* * refcnt is a very hot point, so align it on SMP */ /* Number of references to this device */ atomic_t refcnt ____cacheline_aligned_in_smp; /* delayed register/unregister */ struct list_head todo_list; /* device index hash chain */ struct hlist_node index_hlist; /* 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 */ } reg_state; /* Called after device is detached from network. */ void (*uninit)(struct net_device *dev); /* Called after last user reference disappears. */ void (*destructor)(struct net_device *dev); /* Pointers to interface service routines. */ int (*open)(struct net_device *dev); int (*stop)(struct net_device *dev);#define HAVE_NETDEV_POLL int (*hard_header) (struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len); int (*rebuild_header)(struct sk_buff *skb);#define HAVE_MULTICAST void (*set_multicast_list)(struct net_device *dev);#define HAVE_SET_MAC_ADDR int (*set_mac_address)(struct net_device *dev, void *addr);#define HAVE_PRIVATE_IOCTL int (*do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);#define HAVE_SET_CONFIG int (*set_config)(struct net_device *dev, struct ifmap *map);#define HAVE_HEADER_CACHE int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh); void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr);#define HAVE_CHANGE_MTU int (*change_mtu)(struct net_device *dev, int new_mtu);#define HAVE_TX_TIMEOUT void (*tx_timeout) (struct net_device *dev); void (*vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); void (*vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); void (*vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); int (*hard_header_parse)(struct sk_buff *skb, unsigned char *haddr); int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);#ifdef CONFIG_NETPOLL struct netpoll_info *npinfo;#endif#ifdef CONFIG_NET_POLL_CONTROLLER void (*poll_controller)(struct net_device *dev);#endif /* bridge stuff */ struct net_bridge_port *br_port; /* class/net/name entry */ struct class_device class_dev; /* space for optional statistics and wireless sysfs groups */ struct attribute_group *sysfs_groups[3];};#define NETDEV_ALIGN 32#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)static inline void *netdev_priv(struct net_device *dev){ return (char *)dev + ((sizeof(struct net_device) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);}#define SET_MODULE_OWNER(dev) do { } while (0)/* Set the sysfs physical device reference for the network logical device * if set prior to registration will cause a symlink during initialization. */#define SET_NETDEV_DEV(net, pdev) ((net)->class_dev.dev = (pdev))struct packet_type { __be16 type; /* This is really htons(ether_type). */ struct net_device *dev; /* NULL is wildcarded here */ int (*func) (struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); struct sk_buff *(*gso_segment)(struct sk_buff *skb, int features); int (*gso_send_check)(struct sk_buff *skb); void *af_packet_priv; struct list_head list;};#include <linux/interrupt.h>#include <linux/notifier.h>extern struct net_device loopback_dev; /* The loopback */extern struct net_device *dev_base; /* All devices */extern rwlock_t dev_base_lock; /* Device list lock */extern int netdev_boot_setup_check(struct net_device *dev);extern unsigned long netdev_boot_base(const char *prefix, int unit);extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);extern struct net_device *dev_getfirstbyhwtype(unsigned short type);extern void dev_add_pack(struct packet_type *pt);extern void dev_remove_pack(struct packet_type *pt);extern void __dev_remove_pack(struct packet_type *pt);extern struct net_device *dev_get_by_flags(unsigned short flags, unsigned short mask);extern struct net_device *dev_get_by_name(const char *name);extern struct net_device *__dev_get_by_name(const char *name);extern int dev_alloc_name(struct net_device *dev, const char *name);extern int dev_open(struct net_device *dev);extern int dev_close(struct net_device *dev);extern int dev_queue_xmit(struct sk_buff *skb);extern int register_netdevice(struct net_device *dev);extern int unregister_netdevice(struct net_device *dev);extern void free_netdev(struct net_device *dev);extern void synchronize_net(void);extern int register_netdevice_notifier(struct notifier_block *nb);extern int unregister_netdevice_notifier(struct notifier_block *nb);extern int call_netdevice_notifiers(unsigned long val, void *v);extern struct net_device *dev_get_by_index(int ifindex);extern struct net_device *__dev_get_by_index(int ifindex);extern int dev_restart(struct net_device *dev);#ifdef CONFIG_NETPOLL_TRAPextern int netpoll_trap(void);#endiftypedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);extern int register_gifconf(unsigned int family, gifconf_func_t * gifconf);static inline int unregister_gifconf(unsigned int family){ return register_gifconf(family, NULL);}/* * Incoming packets are placed on per-cpu queues so that * no locking is needed. */struct softnet_data{ struct net_device *output_queue; struct sk_buff_head input_pkt_queue; struct list_head poll_list; struct sk_buff *completion_queue; struct net_device backlog_dev; /* Sorry. 8) */#ifdef CONFIG_NET_DMA struct dma_chan *net_dma;#endif};DECLARE_PER_CPU(struct softnet_data,softnet_data);#define HAVE_NETIF_QUEUEextern void __netif_schedule(struct net_device *dev);static inline void netif_schedule(struct net_device *dev){ if (!test_bit(__LINK_STATE_XOFF, &dev->state)) __netif_schedule(dev);}static inline void netif_start_queue(struct net_device *dev){ clear_bit(__LINK_STATE_XOFF, &dev->state);}static inline void netif_wake_queue(struct net_device *dev){#ifdef CONFIG_NETPOLL_TRAP if (netpoll_trap()) return;#endif if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state)) __netif_schedule(dev);}static inline void netif_stop_queue(struct net_device *dev){#ifdef CONFIG_NETPOLL_TRAP if (netpoll_trap()) return;#endif set_bit(__LINK_STATE_XOFF, &dev->state);}static inline int netif_queue_stopped(const struct net_device *dev){ return test_bit(__LINK_STATE_XOFF, &dev->state);}static inline int netif_running(const struct net_device *dev){ return test_bit(__LINK_STATE_START, &dev->state);}/* Use this variant when it is known for sure that it * is executing from interrupt context. */static inline void dev_kfree_skb_irq(struct sk_buff *skb){ if (atomic_dec_and_test(&skb->users)) { struct softnet_data *sd; unsigned long flags; local_irq_save(flags); sd = &__get_cpu_var(softnet_data); skb->next = sd->completion_queue; sd->completion_queue = skb; raise_softirq_irqoff(NET_TX_SOFTIRQ); local_irq_restore(flags); }}/* Use this variant in places where it could be invoked * either from interrupt or non-interrupt context. */extern void dev_kfree_skb_any(struct sk_buff *skb);#define HAVE_NETIF_RX 1extern int netif_rx(struct sk_buff *skb);extern int netif_rx_ni(struct sk_buff *skb);#define HAVE_NETIF_RECEIVE_SKB 1extern int netif_receive_skb(struct sk_buff *skb);extern int dev_valid_name(const char *name);extern int dev_ioctl(unsigned int cmd, void __user *);extern int dev_ethtool(struct ifreq *);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -