aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-03-01 15:54:31 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-01 15:54:31 -0500
commitd2e42a1756501ce3466e538da742f9a67c233d47 (patch)
tree2530b68faffa4a6cb301fb71c64cab0ee69f3747 /include/linux
parent46d5efa9a6abe2345472bff93a02480b308d3141 (diff)
parent163e529200af7b7521fbde5dbcc653cf3ce597df (diff)
Merge branch 'ndo_set_rx_headroom'
Paolo Abeni says: ==================== bridge/ovs: avoid skb head copy on frame forwarding Currently, while when an OVS or Linux bridge is used to forward frames towards some tunnel device, a skb_head_copy() may occur if the ingress device do not provide enough headroom for the tx encapsulation. This patch series tries to address the issue implementing a new ndo operation to allow the master device to control the headroom used when allocating the skb on frame reception. Said operation is used by the Linux bridge to notify the bridged ports of needed_headroom changes, and similar bookkeeping and behaviour is also added to openvswitch, on a per datapath basis. Finally, the operation is implemented for veth and tun device, which give performance improvement in the 6-12% range when forwarding frames from said devices towards a vxlan tunnel. v2: - fix netdev_get_fwd_headroom() behaviour - remove some code duplication with the netdev_set_rx_headroom() and netdev_reset_rx_headroom() helpers - handle headroom reset on [v]port removal/deletion - initialize tun align to the old default value v3: - fix a comment typo ==================== Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/netdevice.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index e52077ffe5ed..efe7cec111fa 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1093,6 +1093,12 @@ struct tc_to_netdev {
1093 * This function is used to get egress tunnel information for given skb. 1093 * This function is used to get egress tunnel information for given skb.
1094 * This is useful for retrieving outer tunnel header parameters while 1094 * This is useful for retrieving outer tunnel header parameters while
1095 * sampling packet. 1095 * sampling packet.
1096 * void (*ndo_set_rx_headroom)(struct net_device *dev, int needed_headroom);
1097 * This function is used to specify the headroom that the skb must
1098 * consider when allocation skb during packet reception. Setting
1099 * appropriate rx headroom value allows avoiding skb head copy on
1100 * forward. Setting a negative value reset the rx headroom to the
1101 * default value.
1096 * 1102 *
1097 */ 1103 */
1098struct net_device_ops { 1104struct net_device_ops {
@@ -1278,6 +1284,8 @@ struct net_device_ops {
1278 bool proto_down); 1284 bool proto_down);
1279 int (*ndo_fill_metadata_dst)(struct net_device *dev, 1285 int (*ndo_fill_metadata_dst)(struct net_device *dev,
1280 struct sk_buff *skb); 1286 struct sk_buff *skb);
1287 void (*ndo_set_rx_headroom)(struct net_device *dev,
1288 int needed_headroom);
1281}; 1289};
1282 1290
1283/** 1291/**
@@ -1315,6 +1323,8 @@ struct net_device_ops {
1315 * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device 1323 * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device
1316 * @IFF_TEAM: device is a team device 1324 * @IFF_TEAM: device is a team device
1317 * @IFF_RXFH_CONFIGURED: device has had Rx Flow indirection table configured 1325 * @IFF_RXFH_CONFIGURED: device has had Rx Flow indirection table configured
1326 * @IFF_PHONY_HEADROOM: the headroom value is controlled by an external
1327 * entity (i.e. the master device for bridged veth)
1318 */ 1328 */
1319enum netdev_priv_flags { 1329enum netdev_priv_flags {
1320 IFF_802_1Q_VLAN = 1<<0, 1330 IFF_802_1Q_VLAN = 1<<0,
@@ -1343,6 +1353,7 @@ enum netdev_priv_flags {
1343 IFF_L3MDEV_SLAVE = 1<<23, 1353 IFF_L3MDEV_SLAVE = 1<<23,
1344 IFF_TEAM = 1<<24, 1354 IFF_TEAM = 1<<24,
1345 IFF_RXFH_CONFIGURED = 1<<25, 1355 IFF_RXFH_CONFIGURED = 1<<25,
1356 IFF_PHONY_HEADROOM = 1<<26,
1346}; 1357};
1347 1358
1348#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN 1359#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1937,6 +1948,26 @@ struct netdev_queue *netdev_pick_tx(struct net_device *dev,
1937 struct sk_buff *skb, 1948 struct sk_buff *skb,
1938 void *accel_priv); 1949 void *accel_priv);
1939 1950
1951/* returns the headroom that the master device needs to take in account
1952 * when forwarding to this dev
1953 */
1954static inline unsigned netdev_get_fwd_headroom(struct net_device *dev)
1955{
1956 return dev->priv_flags & IFF_PHONY_HEADROOM ? 0 : dev->needed_headroom;
1957}
1958
1959static inline void netdev_set_rx_headroom(struct net_device *dev, int new_hr)
1960{
1961 if (dev->netdev_ops->ndo_set_rx_headroom)
1962 dev->netdev_ops->ndo_set_rx_headroom(dev, new_hr);
1963}
1964
1965/* set the device rx headroom to the dev's default */
1966static inline void netdev_reset_rx_headroom(struct net_device *dev)
1967{
1968 netdev_set_rx_headroom(dev, -1);
1969}
1970
1940/* 1971/*
1941 * Net namespace inlines 1972 * Net namespace inlines
1942 */ 1973 */