diff mbox

[net-next,v2,1/5] netdev: introduce ndo_set_rx_headroom

Message ID 94f5bf927e514df4fecd50a1332a56501fff2945.1456397229.git.pabeni@redhat.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Paolo Abeni Feb. 25, 2016, 11:09 a.m. UTC
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 <pabeni@redhat.com>

---
v1 -> v2:
 - fixed netdev_get_fwd_headroom()
 - added netdev_set_rx_headroom() and netdev_reset_rx_headroom() helpers
---
 include/linux/netdevice.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Sergei Shtylyov Feb. 25, 2016, 2:21 p.m. UTC | #1
Hello.

On 2/25/2016 2:09 PM, Paolo Abeni wrote:

> 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 <pabeni@redhat.com>
>
> ---
> v1 -> v2:
>   - fixed netdev_get_fwd_headroom()
>   - added netdev_set_rx_headroom() and netdev_reset_rx_headroom() helpers
> ---
>   include/linux/netdevice.h | 31 +++++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index e52077f..8f53674 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1093,6 +1093,12 @@ struct tc_to_netdev {
>    *	This function is used to get egress tunnel information for given skb.
>    *	This is useful for retrieving outer tunnel header parameters while
>    *	sampling packet.
> + * * int (*ndo_set_rx_headroom)(struct net_device *dev, int needed_headroom);

    It's *void* in the declaration.

> + *	This function is used to specify the headroom that the skb must
> + *	consider when allocation skb during packet reception. Setting
> + *	appropriate rx headroom value allows avoiding skb head copy on
> + *	forward. Setting a negative value reset the rx headroom to the
> + *	default value.
>    *
>    */
>   struct net_device_ops {
> @@ -1278,6 +1284,8 @@ struct net_device_ops {
>   							 bool proto_down);
>   	int			(*ndo_fill_metadata_dst)(struct net_device *dev,
>   						       struct sk_buff *skb);
> +	void			(*ndo_set_rx_headroom)(struct net_device *dev,
> +						       int needed_headroom);
>   };
>
>   /**
[...]

MBR, Sergei
Paolo Abeni Feb. 25, 2016, 3:37 p.m. UTC | #2
On Thu, 2016-02-25 at 17:21 +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 2/25/2016 2:09 PM, Paolo Abeni wrote:
> 
> > 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 <pabeni@redhat.com>
> >
> > ---
> > v1 -> v2:
> >   - fixed netdev_get_fwd_headroom()
> >   - added netdev_set_rx_headroom() and netdev_reset_rx_headroom() helpers
> > ---
> >   include/linux/netdevice.h | 31 +++++++++++++++++++++++++++++++
> >   1 file changed, 31 insertions(+)
> >
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index e52077f..8f53674 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -1093,6 +1093,12 @@ struct tc_to_netdev {
> >    *	This function is used to get egress tunnel information for given skb.
> >    *	This is useful for retrieving outer tunnel header parameters while
> >    *	sampling packet.
> > + * * int (*ndo_set_rx_headroom)(struct net_device *dev, int needed_headroom);
> 
>     It's *void* in the declaration.

You are right, thank you! must be 'void' here, too.

I'll fix it in v3.

Paolo
diff mbox

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index e52077f..8f53674 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1093,6 +1093,12 @@  struct tc_to_netdev {
  *	This function is used to get egress tunnel information for given skb.
  *	This is useful for retrieving outer tunnel header parameters while
  *	sampling packet.
+ * * int (*ndo_set_rx_headroom)(struct net_device *dev, int needed_headroom);
+ *	This function is used to specify the headroom that the skb must
+ *	consider when allocation skb during packet reception. Setting
+ *	appropriate rx headroom value allows avoiding skb head copy on
+ *	forward. Setting a negative value reset the rx headroom to the
+ *	default value.
  *
  */
 struct net_device_ops {
@@ -1278,6 +1284,8 @@  struct net_device_ops {
 							 bool proto_down);
 	int			(*ndo_fill_metadata_dst)(struct net_device *dev,
 						       struct sk_buff *skb);
+	void			(*ndo_set_rx_headroom)(struct net_device *dev,
+						       int needed_headroom);
 };
 
 /**
@@ -1315,6 +1323,8 @@  struct net_device_ops {
  * @IFF_L3MDEV_SLAVE: device is enslaved to an L3 master device
  * @IFF_TEAM: device is a team device
  * @IFF_RXFH_CONFIGURED: device has had Rx Flow indirection table configured
+ * @IFF_PHONY_HEADROOM: the headroom value is controlled by an external
+ *	entity (i.e. the master device for bridged veth)
  */
 enum netdev_priv_flags {
 	IFF_802_1Q_VLAN			= 1<<0,
@@ -1343,6 +1353,7 @@  enum netdev_priv_flags {
 	IFF_L3MDEV_SLAVE		= 1<<23,
 	IFF_TEAM			= 1<<24,
 	IFF_RXFH_CONFIGURED		= 1<<25,
+	IFF_PHONY_HEADROOM		= 1<<26,
 };
 
 #define IFF_802_1Q_VLAN			IFF_802_1Q_VLAN
@@ -1937,6 +1948,26 @@  struct netdev_queue *netdev_pick_tx(struct net_device *dev,
 				    struct sk_buff *skb,
 				    void *accel_priv);
 
+/* returns the headroom that the master device needs to take in account
+ * when forwarding to this dev
+ */
+static inline unsigned netdev_get_fwd_headroom(struct net_device *dev)
+{
+	return dev->priv_flags & IFF_PHONY_HEADROOM ? 0 : dev->needed_headroom;
+}
+
+static inline void netdev_set_rx_headroom(struct net_device *dev, int new_hr)
+{
+	if (dev->netdev_ops->ndo_set_rx_headroom)
+		dev->netdev_ops->ndo_set_rx_headroom(dev, new_hr);
+}
+
+/* set the device rx headroom to the dev's default */
+static inline void netdev_reset_rx_headroom(struct net_device *dev)
+{
+	netdev_set_rx_headroom(dev, -1);
+}
+
 /*
  * Net namespace inlines
  */