aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h95
1 files changed, 66 insertions, 29 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b3d00fa4b314..60584b185a0c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -144,8 +144,6 @@ static inline bool dev_xmit_complete(int rc)
144# else 144# else
145# define LL_MAX_HEADER 96 145# define LL_MAX_HEADER 96
146# endif 146# endif
147#elif IS_ENABLED(CONFIG_TR)
148# define LL_MAX_HEADER 48
149#else 147#else
150# define LL_MAX_HEADER 32 148# define LL_MAX_HEADER 32
151#endif 149#endif
@@ -210,9 +208,10 @@ struct netdev_hw_addr {
210#define NETDEV_HW_ADDR_T_SLAVE 3 208#define NETDEV_HW_ADDR_T_SLAVE 3
211#define NETDEV_HW_ADDR_T_UNICAST 4 209#define NETDEV_HW_ADDR_T_UNICAST 4
212#define NETDEV_HW_ADDR_T_MULTICAST 5 210#define NETDEV_HW_ADDR_T_MULTICAST 5
213 bool synced;
214 bool global_use; 211 bool global_use;
212 int sync_cnt;
215 int refcount; 213 int refcount;
214 int synced;
216 struct rcu_head rcu_head; 215 struct rcu_head rcu_head;
217}; 216};
218 217
@@ -594,7 +593,6 @@ struct rps_dev_flow {
594struct rps_dev_flow_table { 593struct rps_dev_flow_table {
595 unsigned int mask; 594 unsigned int mask;
596 struct rcu_head rcu; 595 struct rcu_head rcu;
597 struct work_struct free_work;
598 struct rps_dev_flow flows[0]; 596 struct rps_dev_flow flows[0];
599}; 597};
600#define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \ 598#define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \
@@ -785,13 +783,13 @@ struct netdev_fcoe_hbainfo {
785 * 3. Update dev->stats asynchronously and atomically, and define 783 * 3. Update dev->stats asynchronously and atomically, and define
786 * neither operation. 784 * neither operation.
787 * 785 *
788 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); 786 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16t vid);
789 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) 787 * If device support VLAN filtering this function is called when a
790 * this function is called when a VLAN id is registered. 788 * VLAN id is registered.
791 * 789 *
792 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); 790 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
793 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) 791 * If device support VLAN filtering this function is called when a
794 * this function is called when a VLAN id is unregistered. 792 * VLAN id is unregistered.
795 * 793 *
796 * void (*ndo_poll_controller)(struct net_device *dev); 794 * void (*ndo_poll_controller)(struct net_device *dev);
797 * 795 *
@@ -895,7 +893,7 @@ struct netdev_fcoe_hbainfo {
895 * 893 *
896 * int (*ndo_bridge_setlink)(struct net_device *dev, struct nlmsghdr *nlh) 894 * int (*ndo_bridge_setlink)(struct net_device *dev, struct nlmsghdr *nlh)
897 * int (*ndo_bridge_getlink)(struct sk_buff *skb, u32 pid, u32 seq, 895 * int (*ndo_bridge_getlink)(struct sk_buff *skb, u32 pid, u32 seq,
898 * struct net_device *dev) 896 * struct net_device *dev, u32 filter_mask)
899 * 897 *
900 * int (*ndo_change_carrier)(struct net_device *dev, bool new_carrier); 898 * int (*ndo_change_carrier)(struct net_device *dev, bool new_carrier);
901 * Called to change device carrier. Soft-devices (like dummy, team, etc) 899 * Called to change device carrier. Soft-devices (like dummy, team, etc)
@@ -935,9 +933,9 @@ struct net_device_ops {
935 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 933 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
936 934
937 int (*ndo_vlan_rx_add_vid)(struct net_device *dev, 935 int (*ndo_vlan_rx_add_vid)(struct net_device *dev,
938 unsigned short vid); 936 __be16 proto, u16 vid);
939 int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, 937 int (*ndo_vlan_rx_kill_vid)(struct net_device *dev,
940 unsigned short vid); 938 __be16 proto, u16 vid);
941#ifdef CONFIG_NET_POLL_CONTROLLER 939#ifdef CONFIG_NET_POLL_CONTROLLER
942 void (*ndo_poll_controller)(struct net_device *dev); 940 void (*ndo_poll_controller)(struct net_device *dev);
943 int (*ndo_netpoll_setup)(struct net_device *dev, 941 int (*ndo_netpoll_setup)(struct net_device *dev,
@@ -1073,6 +1071,8 @@ struct net_device {
1073 struct list_head dev_list; 1071 struct list_head dev_list;
1074 struct list_head napi_list; 1072 struct list_head napi_list;
1075 struct list_head unreg_list; 1073 struct list_head unreg_list;
1074 struct list_head upper_dev_list; /* List of upper devices */
1075
1076 1076
1077 /* currently active device features */ 1077 /* currently active device features */
1078 netdev_features_t features; 1078 netdev_features_t features;
@@ -1145,6 +1145,13 @@ struct net_device {
1145 spinlock_t addr_list_lock; 1145 spinlock_t addr_list_lock;
1146 struct netdev_hw_addr_list uc; /* Unicast mac addresses */ 1146 struct netdev_hw_addr_list uc; /* Unicast mac addresses */
1147 struct netdev_hw_addr_list mc; /* Multicast mac addresses */ 1147 struct netdev_hw_addr_list mc; /* Multicast mac addresses */
1148 struct netdev_hw_addr_list dev_addrs; /* list of device
1149 * hw addresses
1150 */
1151#ifdef CONFIG_SYSFS
1152 struct kset *queues_kset;
1153#endif
1154
1148 bool uc_promisc; 1155 bool uc_promisc;
1149 unsigned int promiscuity; 1156 unsigned int promiscuity;
1150 unsigned int allmulti; 1157 unsigned int allmulti;
@@ -1177,21 +1184,11 @@ struct net_device {
1177 * avoid dirtying this cache line. 1184 * avoid dirtying this cache line.
1178 */ 1185 */
1179 1186
1180 struct list_head upper_dev_list; /* List of upper devices */
1181
1182 /* Interface address info used in eth_type_trans() */ 1187 /* Interface address info used in eth_type_trans() */
1183 unsigned char *dev_addr; /* hw address, (before bcast 1188 unsigned char *dev_addr; /* hw address, (before bcast
1184 because most packets are 1189 because most packets are
1185 unicast) */ 1190 unicast) */
1186 1191
1187 struct netdev_hw_addr_list dev_addrs; /* list of device
1188 hw addresses */
1189
1190 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
1191
1192#ifdef CONFIG_SYSFS
1193 struct kset *queues_kset;
1194#endif
1195 1192
1196#ifdef CONFIG_RPS 1193#ifdef CONFIG_RPS
1197 struct netdev_rx_queue *_rx; 1194 struct netdev_rx_queue *_rx;
@@ -1202,18 +1199,14 @@ struct net_device {
1202 /* Number of RX queues currently active in device */ 1199 /* Number of RX queues currently active in device */
1203 unsigned int real_num_rx_queues; 1200 unsigned int real_num_rx_queues;
1204 1201
1205#ifdef CONFIG_RFS_ACCEL
1206 /* CPU reverse-mapping for RX completion interrupts, indexed
1207 * by RX queue number. Assigned by driver. This must only be
1208 * set if the ndo_rx_flow_steer operation is defined. */
1209 struct cpu_rmap *rx_cpu_rmap;
1210#endif
1211#endif 1202#endif
1212 1203
1213 rx_handler_func_t __rcu *rx_handler; 1204 rx_handler_func_t __rcu *rx_handler;
1214 void __rcu *rx_handler_data; 1205 void __rcu *rx_handler_data;
1215 1206
1216 struct netdev_queue __rcu *ingress_queue; 1207 struct netdev_queue __rcu *ingress_queue;
1208 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
1209
1217 1210
1218/* 1211/*
1219 * Cache lines mostly used on transmit path 1212 * Cache lines mostly used on transmit path
@@ -1235,6 +1228,12 @@ struct net_device {
1235#ifdef CONFIG_XPS 1228#ifdef CONFIG_XPS
1236 struct xps_dev_maps __rcu *xps_maps; 1229 struct xps_dev_maps __rcu *xps_maps;
1237#endif 1230#endif
1231#ifdef CONFIG_RFS_ACCEL
1232 /* CPU reverse-mapping for RX completion interrupts, indexed
1233 * by RX queue number. Assigned by driver. This must only be
1234 * set if the ndo_rx_flow_steer operation is defined. */
1235 struct cpu_rmap *rx_cpu_rmap;
1236#endif
1238 1237
1239 /* These may be needed for future network-power-down code. */ 1238 /* These may be needed for future network-power-down code. */
1240 1239
@@ -1475,6 +1474,11 @@ static inline void *netdev_priv(const struct net_device *dev)
1475 */ 1474 */
1476#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype)) 1475#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
1477 1476
1477/* Default NAPI poll() weight
1478 * Device drivers are strongly advised to not use bigger value
1479 */
1480#define NAPI_POLL_WEIGHT 64
1481
1478/** 1482/**
1479 * netif_napi_add - initialize a napi context 1483 * netif_napi_add - initialize a napi context
1480 * @dev: network device 1484 * @dev: network device
@@ -1612,6 +1616,9 @@ extern seqcount_t devnet_rename_seq; /* Device rename seq */
1612 list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list) 1616 list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list)
1613#define for_each_netdev_continue_rcu(net, d) \ 1617#define for_each_netdev_continue_rcu(net, d) \
1614 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list) 1618 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
1619#define for_each_netdev_in_bond_rcu(bond, slave) \
1620 for_each_netdev_rcu(&init_net, slave) \
1621 if (netdev_master_upper_dev_get_rcu(slave) == bond)
1615#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) 1622#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
1616 1623
1617static inline struct net_device *next_net_device(struct net_device *dev) 1624static inline struct net_device *next_net_device(struct net_device *dev)
@@ -1684,7 +1691,6 @@ extern int netdev_refcnt_read(const struct net_device *dev);
1684extern void free_netdev(struct net_device *dev); 1691extern void free_netdev(struct net_device *dev);
1685extern void synchronize_net(void); 1692extern void synchronize_net(void);
1686extern int init_dummy_netdev(struct net_device *dev); 1693extern int init_dummy_netdev(struct net_device *dev);
1687extern void netdev_resync_ops(struct net_device *dev);
1688 1694
1689extern struct net_device *dev_get_by_index(struct net *net, int ifindex); 1695extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
1690extern struct net_device *__dev_get_by_index(struct net *net, int ifindex); 1696extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
@@ -2621,6 +2627,7 @@ extern int dev_uc_add(struct net_device *dev, const unsigned char *addr);
2621extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr); 2627extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
2622extern int dev_uc_del(struct net_device *dev, const unsigned char *addr); 2628extern int dev_uc_del(struct net_device *dev, const unsigned char *addr);
2623extern int dev_uc_sync(struct net_device *to, struct net_device *from); 2629extern int dev_uc_sync(struct net_device *to, struct net_device *from);
2630extern int dev_uc_sync_multiple(struct net_device *to, struct net_device *from);
2624extern void dev_uc_unsync(struct net_device *to, struct net_device *from); 2631extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
2625extern void dev_uc_flush(struct net_device *dev); 2632extern void dev_uc_flush(struct net_device *dev);
2626extern void dev_uc_init(struct net_device *dev); 2633extern void dev_uc_init(struct net_device *dev);
@@ -2632,6 +2639,7 @@ extern int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr);
2632extern int dev_mc_del(struct net_device *dev, const unsigned char *addr); 2639extern int dev_mc_del(struct net_device *dev, const unsigned char *addr);
2633extern int dev_mc_del_global(struct net_device *dev, const unsigned char *addr); 2640extern int dev_mc_del_global(struct net_device *dev, const unsigned char *addr);
2634extern int dev_mc_sync(struct net_device *to, struct net_device *from); 2641extern int dev_mc_sync(struct net_device *to, struct net_device *from);
2642extern int dev_mc_sync_multiple(struct net_device *to, struct net_device *from);
2635extern void dev_mc_unsync(struct net_device *to, struct net_device *from); 2643extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
2636extern void dev_mc_flush(struct net_device *dev); 2644extern void dev_mc_flush(struct net_device *dev);
2637extern void dev_mc_init(struct net_device *dev); 2645extern void dev_mc_init(struct net_device *dev);
@@ -2678,6 +2686,19 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, netdev_features_t features)
2678{ 2686{
2679 return __skb_gso_segment(skb, features, true); 2687 return __skb_gso_segment(skb, features, true);
2680} 2688}
2689__be16 skb_network_protocol(struct sk_buff *skb);
2690
2691static inline bool can_checksum_protocol(netdev_features_t features,
2692 __be16 protocol)
2693{
2694 return ((features & NETIF_F_GEN_CSUM) ||
2695 ((features & NETIF_F_V4_CSUM) &&
2696 protocol == htons(ETH_P_IP)) ||
2697 ((features & NETIF_F_V6_CSUM) &&
2698 protocol == htons(ETH_P_IPV6)) ||
2699 ((features & NETIF_F_FCOE_CRC) &&
2700 protocol == htons(ETH_P_FCOE)));
2701}
2681 2702
2682#ifdef CONFIG_BUG 2703#ifdef CONFIG_BUG
2683extern void netdev_rx_csum_fault(struct net_device *dev); 2704extern void netdev_rx_csum_fault(struct net_device *dev);
@@ -2712,6 +2733,17 @@ static inline netdev_features_t netdev_get_wanted_features(
2712} 2733}
2713netdev_features_t netdev_increment_features(netdev_features_t all, 2734netdev_features_t netdev_increment_features(netdev_features_t all,
2714 netdev_features_t one, netdev_features_t mask); 2735 netdev_features_t one, netdev_features_t mask);
2736
2737/* Allow TSO being used on stacked device :
2738 * Performing the GSO segmentation before last device
2739 * is a performance improvement.
2740 */
2741static inline netdev_features_t netdev_add_tso_features(netdev_features_t features,
2742 netdev_features_t mask)
2743{
2744 return netdev_increment_features(features, NETIF_F_ALL_TSO, mask);
2745}
2746
2715int __netdev_update_features(struct net_device *dev); 2747int __netdev_update_features(struct net_device *dev);
2716void netdev_update_features(struct net_device *dev); 2748void netdev_update_features(struct net_device *dev);
2717void netdev_change_features(struct net_device *dev); 2749void netdev_change_features(struct net_device *dev);
@@ -2756,6 +2788,11 @@ static inline void netif_set_gso_max_size(struct net_device *dev,
2756 dev->gso_max_size = size; 2788 dev->gso_max_size = size;
2757} 2789}
2758 2790
2791static inline bool netif_is_bond_master(struct net_device *dev)
2792{
2793 return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
2794}
2795
2759static inline bool netif_is_bond_slave(struct net_device *dev) 2796static inline bool netif_is_bond_slave(struct net_device *dev)
2760{ 2797{
2761 return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING; 2798 return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;