Skip to content

Commit 871b642

Browse files
Paolo Abenidavem330
authored andcommitted
netdev: introduce ndo_set_rx_headroom
This method allows the controlling device (i.e. the bridge) to specify additional headroom to be allocated for skb head on frame reception. Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 46d5efa commit 871b642

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

include/linux/netdevice.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,12 @@ struct tc_to_netdev {
10931093
* This function is used to get egress tunnel information for given skb.
10941094
* This is useful for retrieving outer tunnel header parameters while
10951095
* 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.
10961102
*
10971103
*/
10981104
struct net_device_ops {
@@ -1278,6 +1284,8 @@ struct net_device_ops {
12781284
bool proto_down);
12791285
int (*ndo_fill_metadata_dst)(struct net_device *dev,
12801286
struct sk_buff *skb);
1287+
void (*ndo_set_rx_headroom)(struct net_device *dev,
1288+
int needed_headroom);
12811289
};
12821290

12831291
/**
@@ -1315,6 +1323,8 @@ struct net_device_ops {
13151323
* @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device
13161324
* @IFF_TEAM: device is a team device
13171325
* @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)
13181328
*/
13191329
enum netdev_priv_flags {
13201330
IFF_802_1Q_VLAN = 1<<0,
@@ -1343,6 +1353,7 @@ enum netdev_priv_flags {
13431353
IFF_L3MDEV_SLAVE = 1<<23,
13441354
IFF_TEAM = 1<<24,
13451355
IFF_RXFH_CONFIGURED = 1<<25,
1356+
IFF_PHONY_HEADROOM = 1<<26,
13461357
};
13471358

13481359
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1937,6 +1948,26 @@ struct netdev_queue *netdev_pick_tx(struct net_device *dev,
19371948
struct sk_buff *skb,
19381949
void *accel_priv);
19391950

1951+
/* returns the headroom that the master device needs to take in account
1952+
* when forwarding to this dev
1953+
*/
1954+
static 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+
1959+
static 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 */
1966+
static inline void netdev_reset_rx_headroom(struct net_device *dev)
1967+
{
1968+
netdev_set_rx_headroom(dev, -1);
1969+
}
1970+
19401971
/*
19411972
* Net namespace inlines
19421973
*/

0 commit comments

Comments
 (0)