diff options
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 101 |
1 files changed, 97 insertions, 4 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5440b7b705eb..be693b34662f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include <linux/neighbour.h> | 51 | #include <linux/neighbour.h> |
| 52 | #include <uapi/linux/netdevice.h> | 52 | #include <uapi/linux/netdevice.h> |
| 53 | #include <uapi/linux/if_bonding.h> | 53 | #include <uapi/linux/if_bonding.h> |
| 54 | #include <uapi/linux/pkt_cls.h> | ||
| 54 | 55 | ||
| 55 | struct netpoll_info; | 56 | struct netpoll_info; |
| 56 | struct device; | 57 | struct device; |
| @@ -267,6 +268,7 @@ struct header_ops { | |||
| 267 | void (*cache_update)(struct hh_cache *hh, | 268 | void (*cache_update)(struct hh_cache *hh, |
| 268 | const struct net_device *dev, | 269 | const struct net_device *dev, |
| 269 | const unsigned char *haddr); | 270 | const unsigned char *haddr); |
| 271 | bool (*validate)(const char *ll_header, unsigned int len); | ||
| 270 | }; | 272 | }; |
| 271 | 273 | ||
| 272 | /* These flag bits are private to the generic network queueing | 274 | /* These flag bits are private to the generic network queueing |
| @@ -778,6 +780,27 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a, | |||
| 778 | typedef u16 (*select_queue_fallback_t)(struct net_device *dev, | 780 | typedef u16 (*select_queue_fallback_t)(struct net_device *dev, |
| 779 | struct sk_buff *skb); | 781 | struct sk_buff *skb); |
| 780 | 782 | ||
| 783 | /* These structures hold the attributes of qdisc and classifiers | ||
| 784 | * that are being passed to the netdevice through the setup_tc op. | ||
| 785 | */ | ||
| 786 | enum { | ||
| 787 | TC_SETUP_MQPRIO, | ||
| 788 | TC_SETUP_CLSU32, | ||
| 789 | TC_SETUP_CLSFLOWER, | ||
| 790 | }; | ||
| 791 | |||
| 792 | struct tc_cls_u32_offload; | ||
| 793 | |||
| 794 | struct tc_to_netdev { | ||
| 795 | unsigned int type; | ||
| 796 | union { | ||
| 797 | u8 tc; | ||
| 798 | struct tc_cls_u32_offload *cls_u32; | ||
| 799 | struct tc_cls_flower_offload *cls_flower; | ||
| 800 | }; | ||
| 801 | }; | ||
| 802 | |||
| 803 | |||
| 781 | /* | 804 | /* |
| 782 | * This structure defines the management hooks for network devices. | 805 | * This structure defines the management hooks for network devices. |
| 783 | * The following hooks can be defined; unless noted otherwise, they are | 806 | * The following hooks can be defined; unless noted otherwise, they are |
| @@ -1073,6 +1096,12 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, | |||
| 1073 | * This function is used to get egress tunnel information for given skb. | 1096 | * This function is used to get egress tunnel information for given skb. |
| 1074 | * This is useful for retrieving outer tunnel header parameters while | 1097 | * This is useful for retrieving outer tunnel header parameters while |
| 1075 | * sampling packet. | 1098 | * sampling packet. |
| 1099 | * void (*ndo_set_rx_headroom)(struct net_device *dev, int needed_headroom); | ||
| 1100 | * This function is used to specify the headroom that the skb must | ||
| 1101 | * consider when allocation skb during packet reception. Setting | ||
| 1102 | * appropriate rx headroom value allows avoiding skb head copy on | ||
| 1103 | * forward. Setting a negative value reset the rx headroom to the | ||
| 1104 | * default value. | ||
| 1076 | * | 1105 | * |
| 1077 | */ | 1106 | */ |
| 1078 | struct net_device_ops { | 1107 | struct net_device_ops { |
| @@ -1150,7 +1179,10 @@ struct net_device_ops { | |||
| 1150 | int (*ndo_set_vf_rss_query_en)( | 1179 | int (*ndo_set_vf_rss_query_en)( |
| 1151 | struct net_device *dev, | 1180 | struct net_device *dev, |
| 1152 | int vf, bool setting); | 1181 | int vf, bool setting); |
| 1153 | int (*ndo_setup_tc)(struct net_device *dev, u8 tc); | 1182 | int (*ndo_setup_tc)(struct net_device *dev, |
| 1183 | u32 handle, | ||
| 1184 | __be16 protocol, | ||
| 1185 | struct tc_to_netdev *tc); | ||
| 1154 | #if IS_ENABLED(CONFIG_FCOE) | 1186 | #if IS_ENABLED(CONFIG_FCOE) |
| 1155 | int (*ndo_fcoe_enable)(struct net_device *dev); | 1187 | int (*ndo_fcoe_enable)(struct net_device *dev); |
| 1156 | int (*ndo_fcoe_disable)(struct net_device *dev); | 1188 | int (*ndo_fcoe_disable)(struct net_device *dev); |
| @@ -1255,6 +1287,8 @@ struct net_device_ops { | |||
| 1255 | bool proto_down); | 1287 | bool proto_down); |
| 1256 | int (*ndo_fill_metadata_dst)(struct net_device *dev, | 1288 | int (*ndo_fill_metadata_dst)(struct net_device *dev, |
| 1257 | struct sk_buff *skb); | 1289 | struct sk_buff *skb); |
| 1290 | void (*ndo_set_rx_headroom)(struct net_device *dev, | ||
| 1291 | int needed_headroom); | ||
| 1258 | }; | 1292 | }; |
| 1259 | 1293 | ||
| 1260 | /** | 1294 | /** |
| @@ -1291,6 +1325,10 @@ struct net_device_ops { | |||
| 1291 | * @IFF_OPENVSWITCH: device is a Open vSwitch master | 1325 | * @IFF_OPENVSWITCH: device is a Open vSwitch master |
| 1292 | * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device | 1326 | * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device |
| 1293 | * @IFF_TEAM: device is a team device | 1327 | * @IFF_TEAM: device is a team device |
| 1328 | * @IFF_RXFH_CONFIGURED: device has had Rx Flow indirection table configured | ||
| 1329 | * @IFF_PHONY_HEADROOM: the headroom value is controlled by an external | ||
| 1330 | * entity (i.e. the master device for bridged veth) | ||
| 1331 | * @IFF_MACSEC: device is a MACsec device | ||
| 1294 | */ | 1332 | */ |
| 1295 | enum netdev_priv_flags { | 1333 | enum netdev_priv_flags { |
| 1296 | IFF_802_1Q_VLAN = 1<<0, | 1334 | IFF_802_1Q_VLAN = 1<<0, |
| @@ -1318,6 +1356,9 @@ enum netdev_priv_flags { | |||
| 1318 | IFF_OPENVSWITCH = 1<<22, | 1356 | IFF_OPENVSWITCH = 1<<22, |
| 1319 | IFF_L3MDEV_SLAVE = 1<<23, | 1357 | IFF_L3MDEV_SLAVE = 1<<23, |
| 1320 | IFF_TEAM = 1<<24, | 1358 | IFF_TEAM = 1<<24, |
| 1359 | IFF_RXFH_CONFIGURED = 1<<25, | ||
| 1360 | IFF_PHONY_HEADROOM = 1<<26, | ||
| 1361 | IFF_MACSEC = 1<<27, | ||
| 1321 | }; | 1362 | }; |
| 1322 | 1363 | ||
| 1323 | #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN | 1364 | #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN |
| @@ -1345,6 +1386,8 @@ enum netdev_priv_flags { | |||
| 1345 | #define IFF_OPENVSWITCH IFF_OPENVSWITCH | 1386 | #define IFF_OPENVSWITCH IFF_OPENVSWITCH |
| 1346 | #define IFF_L3MDEV_SLAVE IFF_L3MDEV_SLAVE | 1387 | #define IFF_L3MDEV_SLAVE IFF_L3MDEV_SLAVE |
| 1347 | #define IFF_TEAM IFF_TEAM | 1388 | #define IFF_TEAM IFF_TEAM |
| 1389 | #define IFF_RXFH_CONFIGURED IFF_RXFH_CONFIGURED | ||
| 1390 | #define IFF_MACSEC IFF_MACSEC | ||
| 1348 | 1391 | ||
| 1349 | /** | 1392 | /** |
| 1350 | * struct net_device - The DEVICE structure. | 1393 | * struct net_device - The DEVICE structure. |
| @@ -1397,6 +1440,8 @@ enum netdev_priv_flags { | |||
| 1397 | * do not use this in drivers | 1440 | * do not use this in drivers |
| 1398 | * @tx_dropped: Dropped packets by core network, | 1441 | * @tx_dropped: Dropped packets by core network, |
| 1399 | * do not use this in drivers | 1442 | * do not use this in drivers |
| 1443 | * @rx_nohandler: nohandler dropped packets by core network on | ||
| 1444 | * inactive devices, do not use this in drivers | ||
| 1400 | * | 1445 | * |
| 1401 | * @wireless_handlers: List of functions to handle Wireless Extensions, | 1446 | * @wireless_handlers: List of functions to handle Wireless Extensions, |
| 1402 | * instead of ioctl, | 1447 | * instead of ioctl, |
| @@ -1420,8 +1465,7 @@ enum netdev_priv_flags { | |||
| 1420 | * @dma: DMA channel | 1465 | * @dma: DMA channel |
| 1421 | * @mtu: Interface MTU value | 1466 | * @mtu: Interface MTU value |
| 1422 | * @type: Interface hardware type | 1467 | * @type: Interface hardware type |
| 1423 | * @hard_header_len: Hardware header length, which means that this is the | 1468 | * @hard_header_len: Maximum hardware header length. |
| 1424 | * minimum size of a packet. | ||
| 1425 | * | 1469 | * |
| 1426 | * @needed_headroom: Extra headroom the hardware may need, but not in all | 1470 | * @needed_headroom: Extra headroom the hardware may need, but not in all |
| 1427 | * cases can this be guaranteed | 1471 | * cases can this be guaranteed |
| @@ -1611,6 +1655,7 @@ struct net_device { | |||
| 1611 | 1655 | ||
| 1612 | atomic_long_t rx_dropped; | 1656 | atomic_long_t rx_dropped; |
| 1613 | atomic_long_t tx_dropped; | 1657 | atomic_long_t tx_dropped; |
| 1658 | atomic_long_t rx_nohandler; | ||
| 1614 | 1659 | ||
| 1615 | #ifdef CONFIG_WIRELESS_EXT | 1660 | #ifdef CONFIG_WIRELESS_EXT |
| 1616 | const struct iw_handler_def * wireless_handlers; | 1661 | const struct iw_handler_def * wireless_handlers; |
| @@ -1908,6 +1953,26 @@ struct netdev_queue *netdev_pick_tx(struct net_device *dev, | |||
| 1908 | struct sk_buff *skb, | 1953 | struct sk_buff *skb, |
| 1909 | void *accel_priv); | 1954 | void *accel_priv); |
| 1910 | 1955 | ||
| 1956 | /* returns the headroom that the master device needs to take in account | ||
| 1957 | * when forwarding to this dev | ||
| 1958 | */ | ||
| 1959 | static inline unsigned netdev_get_fwd_headroom(struct net_device *dev) | ||
| 1960 | { | ||
| 1961 | return dev->priv_flags & IFF_PHONY_HEADROOM ? 0 : dev->needed_headroom; | ||
| 1962 | } | ||
| 1963 | |||
| 1964 | static inline void netdev_set_rx_headroom(struct net_device *dev, int new_hr) | ||
| 1965 | { | ||
| 1966 | if (dev->netdev_ops->ndo_set_rx_headroom) | ||
| 1967 | dev->netdev_ops->ndo_set_rx_headroom(dev, new_hr); | ||
| 1968 | } | ||
| 1969 | |||
| 1970 | /* set the device rx headroom to the dev's default */ | ||
| 1971 | static inline void netdev_reset_rx_headroom(struct net_device *dev) | ||
| 1972 | { | ||
| 1973 | netdev_set_rx_headroom(dev, -1); | ||
| 1974 | } | ||
| 1975 | |||
| 1911 | /* | 1976 | /* |
| 1912 | * Net namespace inlines | 1977 | * Net namespace inlines |
| 1913 | */ | 1978 | */ |
| @@ -2627,6 +2692,24 @@ static inline int dev_parse_header(const struct sk_buff *skb, | |||
| 2627 | return dev->header_ops->parse(skb, haddr); | 2692 | return dev->header_ops->parse(skb, haddr); |
| 2628 | } | 2693 | } |
| 2629 | 2694 | ||
| 2695 | /* ll_header must have at least hard_header_len allocated */ | ||
| 2696 | static inline bool dev_validate_header(const struct net_device *dev, | ||
| 2697 | char *ll_header, int len) | ||
| 2698 | { | ||
| 2699 | if (likely(len >= dev->hard_header_len)) | ||
| 2700 | return true; | ||
| 2701 | |||
| 2702 | if (capable(CAP_SYS_RAWIO)) { | ||
| 2703 | memset(ll_header + len, 0, dev->hard_header_len - len); | ||
| 2704 | return true; | ||
| 2705 | } | ||
| 2706 | |||
| 2707 | if (dev->header_ops && dev->header_ops->validate) | ||
| 2708 | return dev->header_ops->validate(ll_header, len); | ||
| 2709 | |||
| 2710 | return false; | ||
| 2711 | } | ||
| 2712 | |||
| 2630 | typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); | 2713 | typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); |
| 2631 | int register_gifconf(unsigned int family, gifconf_func_t *gifconf); | 2714 | int register_gifconf(unsigned int family, gifconf_func_t *gifconf); |
| 2632 | static inline int unregister_gifconf(unsigned int family) | 2715 | static inline int unregister_gifconf(unsigned int family) |
| @@ -3741,7 +3824,7 @@ void netdev_lower_state_changed(struct net_device *lower_dev, | |||
| 3741 | 3824 | ||
| 3742 | /* RSS keys are 40 or 52 bytes long */ | 3825 | /* RSS keys are 40 or 52 bytes long */ |
| 3743 | #define NETDEV_RSS_KEY_LEN 52 | 3826 | #define NETDEV_RSS_KEY_LEN 52 |
| 3744 | extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN]; | 3827 | extern u8 netdev_rss_key[NETDEV_RSS_KEY_LEN] __read_mostly; |
| 3745 | void netdev_rss_key_fill(void *buffer, size_t len); | 3828 | void netdev_rss_key_fill(void *buffer, size_t len); |
| 3746 | 3829 | ||
| 3747 | int dev_get_nest_level(struct net_device *dev, | 3830 | int dev_get_nest_level(struct net_device *dev, |
| @@ -3965,6 +4048,11 @@ static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol, | |||
| 3965 | skb->mac_len = mac_len; | 4048 | skb->mac_len = mac_len; |
| 3966 | } | 4049 | } |
| 3967 | 4050 | ||
| 4051 | static inline bool netif_is_macsec(const struct net_device *dev) | ||
| 4052 | { | ||
| 4053 | return dev->priv_flags & IFF_MACSEC; | ||
| 4054 | } | ||
| 4055 | |||
| 3968 | static inline bool netif_is_macvlan(const struct net_device *dev) | 4056 | static inline bool netif_is_macvlan(const struct net_device *dev) |
| 3969 | { | 4057 | { |
| 3970 | return dev->priv_flags & IFF_MACVLAN; | 4058 | return dev->priv_flags & IFF_MACVLAN; |
| @@ -4045,6 +4133,11 @@ static inline bool netif_is_lag_port(const struct net_device *dev) | |||
| 4045 | return netif_is_bond_slave(dev) || netif_is_team_port(dev); | 4133 | return netif_is_bond_slave(dev) || netif_is_team_port(dev); |
| 4046 | } | 4134 | } |
| 4047 | 4135 | ||
| 4136 | static inline bool netif_is_rxfh_configured(const struct net_device *dev) | ||
| 4137 | { | ||
| 4138 | return dev->priv_flags & IFF_RXFH_CONFIGURED; | ||
| 4139 | } | ||
| 4140 | |||
| 4048 | /* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ | 4141 | /* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ |
| 4049 | static inline void netif_keep_dst(struct net_device *dev) | 4142 | static inline void netif_keep_dst(struct net_device *dev) |
| 4050 | { | 4143 | { |
