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.h156
1 files changed, 120 insertions, 36 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ce2a1f5f9a1e..440a02ee6f92 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -668,15 +668,28 @@ extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
668bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id, 668bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, u32 flow_id,
669 u16 filter_id); 669 u16 filter_id);
670#endif 670#endif
671#endif /* CONFIG_RPS */
671 672
672/* This structure contains an instance of an RX queue. */ 673/* This structure contains an instance of an RX queue. */
673struct netdev_rx_queue { 674struct netdev_rx_queue {
675#ifdef CONFIG_RPS
674 struct rps_map __rcu *rps_map; 676 struct rps_map __rcu *rps_map;
675 struct rps_dev_flow_table __rcu *rps_flow_table; 677 struct rps_dev_flow_table __rcu *rps_flow_table;
678#endif
676 struct kobject kobj; 679 struct kobject kobj;
677 struct net_device *dev; 680 struct net_device *dev;
678} ____cacheline_aligned_in_smp; 681} ____cacheline_aligned_in_smp;
679#endif /* CONFIG_RPS */ 682
683/*
684 * RX queue sysfs structures and functions.
685 */
686struct rx_queue_attribute {
687 struct attribute attr;
688 ssize_t (*show)(struct netdev_rx_queue *queue,
689 struct rx_queue_attribute *attr, char *buf);
690 ssize_t (*store)(struct netdev_rx_queue *queue,
691 struct rx_queue_attribute *attr, const char *buf, size_t len);
692};
680 693
681#ifdef CONFIG_XPS 694#ifdef CONFIG_XPS
682/* 695/*
@@ -1285,6 +1298,9 @@ struct net_device {
1285#if IS_ENABLED(CONFIG_NET_DSA) 1298#if IS_ENABLED(CONFIG_NET_DSA)
1286 struct dsa_switch_tree *dsa_ptr; /* dsa specific data */ 1299 struct dsa_switch_tree *dsa_ptr; /* dsa specific data */
1287#endif 1300#endif
1301#if IS_ENABLED(CONFIG_TIPC)
1302 struct tipc_bearer __rcu *tipc_ptr; /* TIPC specific data */
1303#endif
1288 void *atalk_ptr; /* AppleTalk link */ 1304 void *atalk_ptr; /* AppleTalk link */
1289 struct in_device __rcu *ip_ptr; /* IPv4 specific data */ 1305 struct in_device __rcu *ip_ptr; /* IPv4 specific data */
1290 struct dn_dev __rcu *dn_ptr; /* DECnet specific data */ 1306 struct dn_dev __rcu *dn_ptr; /* DECnet specific data */
@@ -1310,7 +1326,7 @@ struct net_device {
1310 unicast) */ 1326 unicast) */
1311 1327
1312 1328
1313#ifdef CONFIG_RPS 1329#ifdef CONFIG_SYSFS
1314 struct netdev_rx_queue *_rx; 1330 struct netdev_rx_queue *_rx;
1315 1331
1316 /* Number of RX queues allocated at register_netdev() time */ 1332 /* Number of RX queues allocated at register_netdev() time */
@@ -1408,7 +1424,7 @@ struct net_device {
1408 union { 1424 union {
1409 void *ml_priv; 1425 void *ml_priv;
1410 struct pcpu_lstats __percpu *lstats; /* loopback stats */ 1426 struct pcpu_lstats __percpu *lstats; /* loopback stats */
1411 struct pcpu_tstats __percpu *tstats; /* tunnel stats */ 1427 struct pcpu_sw_netstats __percpu *tstats;
1412 struct pcpu_dstats __percpu *dstats; /* dummy stats */ 1428 struct pcpu_dstats __percpu *dstats; /* dummy stats */
1413 struct pcpu_vstats __percpu *vstats; /* veth stats */ 1429 struct pcpu_vstats __percpu *vstats; /* veth stats */
1414 }; 1430 };
@@ -1421,6 +1437,8 @@ struct net_device {
1421 struct device dev; 1437 struct device dev;
1422 /* space for optional device, statistics, and wireless sysfs groups */ 1438 /* space for optional device, statistics, and wireless sysfs groups */
1423 const struct attribute_group *sysfs_groups[4]; 1439 const struct attribute_group *sysfs_groups[4];
1440 /* space for optional per-rx queue attributes */
1441 const struct attribute_group *sysfs_rx_queue_group;
1424 1442
1425 /* rtnetlink link ops */ 1443 /* rtnetlink link ops */
1426 const struct rtnl_link_ops *rtnl_link_ops; 1444 const struct rtnl_link_ops *rtnl_link_ops;
@@ -1443,7 +1461,7 @@ struct net_device {
1443 /* max exchange id for FCoE LRO by ddp */ 1461 /* max exchange id for FCoE LRO by ddp */
1444 unsigned int fcoe_ddp_xid; 1462 unsigned int fcoe_ddp_xid;
1445#endif 1463#endif
1446#if IS_ENABLED(CONFIG_NETPRIO_CGROUP) 1464#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
1447 struct netprio_map __rcu *priomap; 1465 struct netprio_map __rcu *priomap;
1448#endif 1466#endif
1449 /* phy device may attach itself for hardware timestamping */ 1467 /* phy device may attach itself for hardware timestamping */
@@ -1632,7 +1650,10 @@ struct napi_gro_cb {
1632 int data_offset; 1650 int data_offset;
1633 1651
1634 /* This is non-zero if the packet cannot be merged with the new skb. */ 1652 /* This is non-zero if the packet cannot be merged with the new skb. */
1635 int flush; 1653 u16 flush;
1654
1655 /* Save the IP ID here and check when we get to the transport layer */
1656 u16 flush_id;
1636 1657
1637 /* Number of segments aggregated. */ 1658 /* Number of segments aggregated. */
1638 u16 count; 1659 u16 count;
@@ -1649,7 +1670,13 @@ struct napi_gro_cb {
1649 unsigned long age; 1670 unsigned long age;
1650 1671
1651 /* Used in ipv6_gro_receive() */ 1672 /* Used in ipv6_gro_receive() */
1652 int proto; 1673 u16 proto;
1674
1675 /* Used in udp_gro_receive */
1676 u16 udp_mark;
1677
1678 /* used to support CHECKSUM_COMPLETE for tunneling protocols */
1679 __wsum csum;
1653 1680
1654 /* used in skb_gro_receive() slow path */ 1681 /* used in skb_gro_receive() slow path */
1655 struct sk_buff *last; 1682 struct sk_buff *last;
@@ -1676,7 +1703,7 @@ struct offload_callbacks {
1676 int (*gso_send_check)(struct sk_buff *skb); 1703 int (*gso_send_check)(struct sk_buff *skb);
1677 struct sk_buff **(*gro_receive)(struct sk_buff **head, 1704 struct sk_buff **(*gro_receive)(struct sk_buff **head,
1678 struct sk_buff *skb); 1705 struct sk_buff *skb);
1679 int (*gro_complete)(struct sk_buff *skb); 1706 int (*gro_complete)(struct sk_buff *skb, int nhoff);
1680}; 1707};
1681 1708
1682struct packet_offload { 1709struct packet_offload {
@@ -1685,6 +1712,20 @@ struct packet_offload {
1685 struct list_head list; 1712 struct list_head list;
1686}; 1713};
1687 1714
1715struct udp_offload {
1716 __be16 port;
1717 struct offload_callbacks callbacks;
1718};
1719
1720/* often modified stats are per cpu, other are shared (netdev->stats) */
1721struct pcpu_sw_netstats {
1722 u64 rx_packets;
1723 u64 rx_bytes;
1724 u64 tx_packets;
1725 u64 tx_bytes;
1726 struct u64_stats_sync syncp;
1727};
1728
1688#include <linux/notifier.h> 1729#include <linux/notifier.h>
1689 1730
1690/* netdevice notifier chain. Please remember to update the rtnetlink 1731/* netdevice notifier chain. Please remember to update the rtnetlink
@@ -1700,7 +1741,7 @@ struct packet_offload {
1700#define NETDEV_CHANGE 0x0004 /* Notify device state change */ 1741#define NETDEV_CHANGE 0x0004 /* Notify device state change */
1701#define NETDEV_REGISTER 0x0005 1742#define NETDEV_REGISTER 0x0005
1702#define NETDEV_UNREGISTER 0x0006 1743#define NETDEV_UNREGISTER 0x0006
1703#define NETDEV_CHANGEMTU 0x0007 1744#define NETDEV_CHANGEMTU 0x0007 /* notify after mtu change happened */
1704#define NETDEV_CHANGEADDR 0x0008 1745#define NETDEV_CHANGEADDR 0x0008
1705#define NETDEV_GOING_DOWN 0x0009 1746#define NETDEV_GOING_DOWN 0x0009
1706#define NETDEV_CHANGENAME 0x000A 1747#define NETDEV_CHANGENAME 0x000A
@@ -1716,6 +1757,7 @@ struct packet_offload {
1716#define NETDEV_JOIN 0x0014 1757#define NETDEV_JOIN 0x0014
1717#define NETDEV_CHANGEUPPER 0x0015 1758#define NETDEV_CHANGEUPPER 0x0015
1718#define NETDEV_RESEND_IGMP 0x0016 1759#define NETDEV_RESEND_IGMP 0x0016
1760#define NETDEV_PRECHANGEMTU 0x0017 /* notify before mtu change happened */
1719 1761
1720int register_netdevice_notifier(struct notifier_block *nb); 1762int register_netdevice_notifier(struct notifier_block *nb);
1721int unregister_netdevice_notifier(struct notifier_block *nb); 1763int unregister_netdevice_notifier(struct notifier_block *nb);
@@ -1741,8 +1783,6 @@ netdev_notifier_info_to_dev(const struct netdev_notifier_info *info)
1741 return info->dev; 1783 return info->dev;
1742} 1784}
1743 1785
1744int call_netdevice_notifiers_info(unsigned long val, struct net_device *dev,
1745 struct netdev_notifier_info *info);
1746int call_netdevice_notifiers(unsigned long val, struct net_device *dev); 1786int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
1747 1787
1748 1788
@@ -1809,7 +1849,6 @@ void dev_remove_pack(struct packet_type *pt);
1809void __dev_remove_pack(struct packet_type *pt); 1849void __dev_remove_pack(struct packet_type *pt);
1810void dev_add_offload(struct packet_offload *po); 1850void dev_add_offload(struct packet_offload *po);
1811void dev_remove_offload(struct packet_offload *po); 1851void dev_remove_offload(struct packet_offload *po);
1812void __dev_remove_offload(struct packet_offload *po);
1813 1852
1814struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags, 1853struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags,
1815 unsigned short mask); 1854 unsigned short mask);
@@ -1895,6 +1934,14 @@ static inline void *skb_gro_network_header(struct sk_buff *skb)
1895 skb_network_offset(skb); 1934 skb_network_offset(skb);
1896} 1935}
1897 1936
1937static inline void skb_gro_postpull_rcsum(struct sk_buff *skb,
1938 const void *start, unsigned int len)
1939{
1940 if (skb->ip_summed == CHECKSUM_COMPLETE)
1941 NAPI_GRO_CB(skb)->csum = csum_sub(NAPI_GRO_CB(skb)->csum,
1942 csum_partial(start, len, 0));
1943}
1944
1898static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, 1945static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
1899 unsigned short type, 1946 unsigned short type,
1900 const void *daddr, const void *saddr, 1947 const void *daddr, const void *saddr,
@@ -2351,7 +2398,7 @@ static inline bool netif_is_multiqueue(const struct net_device *dev)
2351 2398
2352int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq); 2399int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq);
2353 2400
2354#ifdef CONFIG_RPS 2401#ifdef CONFIG_SYSFS
2355int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq); 2402int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq);
2356#else 2403#else
2357static inline int netif_set_real_num_rx_queues(struct net_device *dev, 2404static inline int netif_set_real_num_rx_queues(struct net_device *dev,
@@ -2370,7 +2417,7 @@ static inline int netif_copy_real_num_queues(struct net_device *to_dev,
2370 from_dev->real_num_tx_queues); 2417 from_dev->real_num_tx_queues);
2371 if (err) 2418 if (err)
2372 return err; 2419 return err;
2373#ifdef CONFIG_RPS 2420#ifdef CONFIG_SYSFS
2374 return netif_set_real_num_rx_queues(to_dev, 2421 return netif_set_real_num_rx_queues(to_dev,
2375 from_dev->real_num_rx_queues); 2422 from_dev->real_num_rx_queues);
2376#else 2423#else
@@ -2378,20 +2425,67 @@ static inline int netif_copy_real_num_queues(struct net_device *to_dev,
2378#endif 2425#endif
2379} 2426}
2380 2427
2428#ifdef CONFIG_SYSFS
2429static inline unsigned int get_netdev_rx_queue_index(
2430 struct netdev_rx_queue *queue)
2431{
2432 struct net_device *dev = queue->dev;
2433 int index = queue - dev->_rx;
2434
2435 BUG_ON(index >= dev->num_rx_queues);
2436 return index;
2437}
2438#endif
2439
2381#define DEFAULT_MAX_NUM_RSS_QUEUES (8) 2440#define DEFAULT_MAX_NUM_RSS_QUEUES (8)
2382int netif_get_num_default_rss_queues(void); 2441int netif_get_num_default_rss_queues(void);
2383 2442
2384/* Use this variant when it is known for sure that it 2443enum skb_free_reason {
2385 * is executing from hardware interrupt context or with hardware interrupts 2444 SKB_REASON_CONSUMED,
2386 * disabled. 2445 SKB_REASON_DROPPED,
2387 */ 2446};
2388void dev_kfree_skb_irq(struct sk_buff *skb);
2389 2447
2390/* Use this variant in places where it could be invoked 2448void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason);
2391 * from either hardware interrupt or other context, with hardware interrupts 2449void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason);
2392 * either disabled or enabled. 2450
2451/*
2452 * It is not allowed to call kfree_skb() or consume_skb() from hardware
2453 * interrupt context or with hardware interrupts being disabled.
2454 * (in_irq() || irqs_disabled())
2455 *
2456 * We provide four helpers that can be used in following contexts :
2457 *
2458 * dev_kfree_skb_irq(skb) when caller drops a packet from irq context,
2459 * replacing kfree_skb(skb)
2460 *
2461 * dev_consume_skb_irq(skb) when caller consumes a packet from irq context.
2462 * Typically used in place of consume_skb(skb) in TX completion path
2463 *
2464 * dev_kfree_skb_any(skb) when caller doesn't know its current irq context,
2465 * replacing kfree_skb(skb)
2466 *
2467 * dev_consume_skb_any(skb) when caller doesn't know its current irq context,
2468 * and consumed a packet. Used in place of consume_skb(skb)
2393 */ 2469 */
2394void dev_kfree_skb_any(struct sk_buff *skb); 2470static inline void dev_kfree_skb_irq(struct sk_buff *skb)
2471{
2472 __dev_kfree_skb_irq(skb, SKB_REASON_DROPPED);
2473}
2474
2475static inline void dev_consume_skb_irq(struct sk_buff *skb)
2476{
2477 __dev_kfree_skb_irq(skb, SKB_REASON_CONSUMED);
2478}
2479
2480static inline void dev_kfree_skb_any(struct sk_buff *skb)
2481{
2482 __dev_kfree_skb_any(skb, SKB_REASON_DROPPED);
2483}
2484
2485static inline void dev_consume_skb_any(struct sk_buff *skb)
2486{
2487 __dev_kfree_skb_any(skb, SKB_REASON_CONSUMED);
2488}
2395 2489
2396int netif_rx(struct sk_buff *skb); 2490int netif_rx(struct sk_buff *skb);
2397int netif_rx_ni(struct sk_buff *skb); 2491int netif_rx_ni(struct sk_buff *skb);
@@ -2400,6 +2494,8 @@ gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb);
2400void napi_gro_flush(struct napi_struct *napi, bool flush_old); 2494void napi_gro_flush(struct napi_struct *napi, bool flush_old);
2401struct sk_buff *napi_get_frags(struct napi_struct *napi); 2495struct sk_buff *napi_get_frags(struct napi_struct *napi);
2402gro_result_t napi_gro_frags(struct napi_struct *napi); 2496gro_result_t napi_gro_frags(struct napi_struct *napi);
2497struct packet_offload *gro_find_receive_by_type(__be16 type);
2498struct packet_offload *gro_find_complete_by_type(__be16 type);
2403 2499
2404static inline void napi_free_frags(struct napi_struct *napi) 2500static inline void napi_free_frags(struct napi_struct *napi)
2405{ 2501{
@@ -2785,17 +2881,10 @@ int register_netdev(struct net_device *dev);
2785void unregister_netdev(struct net_device *dev); 2881void unregister_netdev(struct net_device *dev);
2786 2882
2787/* General hardware address lists handling functions */ 2883/* General hardware address lists handling functions */
2788int __hw_addr_add_multiple(struct netdev_hw_addr_list *to_list,
2789 struct netdev_hw_addr_list *from_list,
2790 int addr_len, unsigned char addr_type);
2791void __hw_addr_del_multiple(struct netdev_hw_addr_list *to_list,
2792 struct netdev_hw_addr_list *from_list,
2793 int addr_len, unsigned char addr_type);
2794int __hw_addr_sync(struct netdev_hw_addr_list *to_list, 2884int __hw_addr_sync(struct netdev_hw_addr_list *to_list,
2795 struct netdev_hw_addr_list *from_list, int addr_len); 2885 struct netdev_hw_addr_list *from_list, int addr_len);
2796void __hw_addr_unsync(struct netdev_hw_addr_list *to_list, 2886void __hw_addr_unsync(struct netdev_hw_addr_list *to_list,
2797 struct netdev_hw_addr_list *from_list, int addr_len); 2887 struct netdev_hw_addr_list *from_list, int addr_len);
2798void __hw_addr_flush(struct netdev_hw_addr_list *list);
2799void __hw_addr_init(struct netdev_hw_addr_list *list); 2888void __hw_addr_init(struct netdev_hw_addr_list *list);
2800 2889
2801/* Functions used for device addresses handling */ 2890/* Functions used for device addresses handling */
@@ -2803,10 +2892,6 @@ int dev_addr_add(struct net_device *dev, const unsigned char *addr,
2803 unsigned char addr_type); 2892 unsigned char addr_type);
2804int dev_addr_del(struct net_device *dev, const unsigned char *addr, 2893int dev_addr_del(struct net_device *dev, const unsigned char *addr,
2805 unsigned char addr_type); 2894 unsigned char addr_type);
2806int dev_addr_add_multiple(struct net_device *to_dev,
2807 struct net_device *from_dev, unsigned char addr_type);
2808int dev_addr_del_multiple(struct net_device *to_dev,
2809 struct net_device *from_dev, unsigned char addr_type);
2810void dev_addr_flush(struct net_device *dev); 2895void dev_addr_flush(struct net_device *dev);
2811int dev_addr_init(struct net_device *dev); 2896int dev_addr_init(struct net_device *dev);
2812 2897
@@ -2853,7 +2938,6 @@ extern int weight_p;
2853extern int bpf_jit_enable; 2938extern int bpf_jit_enable;
2854 2939
2855bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev); 2940bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev);
2856bool netdev_has_any_upper_dev(struct net_device *dev);
2857struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev, 2941struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev,
2858 struct list_head **iter); 2942 struct list_head **iter);
2859 2943
@@ -2882,6 +2966,7 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev,
2882 priv = netdev_lower_get_next_private_rcu(dev, &(iter))) 2966 priv = netdev_lower_get_next_private_rcu(dev, &(iter)))
2883 2967
2884void *netdev_adjacent_get_private(struct list_head *adj_list); 2968void *netdev_adjacent_get_private(struct list_head *adj_list);
2969void *netdev_lower_get_first_private_rcu(struct net_device *dev);
2885struct net_device *netdev_master_upper_dev_get(struct net_device *dev); 2970struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
2886struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev); 2971struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
2887int netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev); 2972int netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev);
@@ -2892,8 +2977,7 @@ int netdev_master_upper_dev_link_private(struct net_device *dev,
2892 void *private); 2977 void *private);
2893void netdev_upper_dev_unlink(struct net_device *dev, 2978void netdev_upper_dev_unlink(struct net_device *dev,
2894 struct net_device *upper_dev); 2979 struct net_device *upper_dev);
2895void *netdev_lower_dev_get_private_rcu(struct net_device *dev, 2980void netdev_adjacent_rename_links(struct net_device *dev, char *oldname);
2896 struct net_device *lower_dev);
2897void *netdev_lower_dev_get_private(struct net_device *dev, 2981void *netdev_lower_dev_get_private(struct net_device *dev,
2898 struct net_device *lower_dev); 2982 struct net_device *lower_dev);
2899int skb_checksum_help(struct sk_buff *skb); 2983int skb_checksum_help(struct sk_buff *skb);