public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu•com>
To: John Fastabend <john.fastabend@gmail•com>,
	jiri@resnulli•us, amir@vadai•me, davem@davemloft•net
Cc: netdev@vger•kernel.org, jeffrey.t.kirsher@intel•com
Subject: Re: [net-next PATCH v3 3/8] net: sched: add cls_u32 offload hooks for netdevs
Date: Wed, 17 Feb 2016 05:59:26 -0500	[thread overview]
Message-ID: <56C4528E.5090505@mojatatu.com> (raw)
In-Reply-To: <20160217051709.17139.88337.stgit@john-Precision-Tower-5810>

On 16-02-17 12:17 AM, John Fastabend wrote:
> This patch allows netdev drivers to consume cls_u32 offloads via
> the ndo_setup_tc ndo op.
>
> This works aligns with how network drivers have been doing qdisc
> offloads for mqprio.
>

This one i have comments on.

> Signed-off-by: John Fastabend <john.r.fastabend@intel•com>
> ---
>   include/linux/netdevice.h |    6 ++-
>   include/net/pkt_cls.h     |   34 +++++++++++++++
>   net/sched/cls_u32.c       |   99 ++++++++++++++++++++++++++++++++++++++++++++-
>   3 files changed, 136 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index e396060..47671ce0 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -779,17 +779,21 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a,
>   typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
>   				       struct sk_buff *skb);
>
> -/* This structure holds attributes of qdisc and classifiers
> +/* These structures hold the attributes of qdisc and classifiers
>    * that are being passed to the netdevice through the setup_tc op.
>    */
>   enum {
>   	TC_SETUP_MQPRIO,
> +	TC_SETUP_CLSU32,
>   };
>
> +struct tc_cls_u32_offload;
> +
>   struct tc_to_netdev {
>   	unsigned int type;
>   	union {
>   		u8 tc;
> +		struct tc_cls_u32_offload *cls_u32;
>   	};
>   };
>
 >
> diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
> index bc49967..59789ca 100644
> --- a/include/net/pkt_cls.h
> +++ b/include/net/pkt_cls.h
> @@ -358,4 +358,38 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)
>   }
>   #endif /* CONFIG_NET_CLS_IND */
>
> +struct tc_cls_u32_knode {
> +	struct tcf_exts *exts;
> +	u8 fshift;
> +	u32 handle;
> +	u32 val;
> +	u32 mask;
> +	u32 link_handle;
> +	struct tc_u32_sel *sel;
> +};
>

Swapping sel and fshift would give better struct alignment.

> +struct tc_cls_u32_hnode {
> +	u32 handle;
> +	u32 prio;
> +	unsigned int divisor;
> +};


Assuming in the future "prio" would be moved to something that is more
generic classifier specific?

> +enum tc_clsu32_command {
> +	TC_CLSU32_NEW_KNODE,
> +	TC_CLSU32_REPLACE_KNODE,
> +	TC_CLSU32_DELETE_KNODE,
> +	TC_CLSU32_NEW_HNODE,
> +	TC_CLSU32_REPLACE_HNODE,
> +	TC_CLSU32_DELETE_HNODE,
> +};
> +

It seems to me commands should be generic which speak
Netlinkism. A REPLACE is just a flag to NEW. You dont need
a NEW_XXX for every object. switchdev got this right.
If you use cmd + flags  then you can have all kinds of
netlink semantics that relay user intent from user space. Example:
Exclusivity where user says "create if it doesnt exist but dont replace
if it does".
At minimal add "flags" there.
Maybe not this release - but it makes sense to move "command" into 
tc_to_netdev; a u16 cmd + u16 flags.

> +struct tc_cls_u32_offload {
> +	/* knode values */
> +	enum tc_clsu32_command command;
> +	union {
> +		struct tc_cls_u32_knode knode;
> +		struct tc_cls_u32_hnode hnode;
> +	};
> +};
> +
>   #endif
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index 4fbb674..d54bc94 100644

> +static void u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h)
> +{
> +	struct net_device *dev = tp->q->dev_queue->dev;
> +	struct tc_cls_u32_offload u32_offload = {0};
> +	struct tc_to_netdev offload;
> +
> +	offload.type = TC_SETUP_CLSU32;
> +	offload.cls_u32 = &u32_offload;
> +
> +	if (dev->netdev_ops->ndo_setup_tc) {
> +		offload.cls_u32->command = TC_CLSU32_NEW_HNODE;

TC_CLSU32_REPLACE_HNODE?

> +		offload.cls_u32->hnode.divisor = h->divisor;
> +		offload.cls_u32->hnode.handle = h->handle;
> +		offload.cls_u32->hnode.prio = h->prio;
> +
> +		dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
> +					      tp->protocol, &offload);
> +	}
> +}


>   static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
>   {
>   	struct tc_u_knode *n;
> @@ -434,6 +522,7 @@ static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
>   			RCU_INIT_POINTER(ht->ht[h],
>   					 rtnl_dereference(n->next));
>   			tcf_unbind_filter(tp, &n->res);
> +			u32_remove_hw_knode(tp, n->handle);
>   			call_rcu(&n->rcu, u32_delete_key_freepf_rcu);
>   		}
>   	}
> @@ -454,6 +543,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
>   	     phn;
>   	     hn = &phn->next, phn = rtnl_dereference(*hn)) {
>   		if (phn == ht) {
> +			u32_clear_hw_hnode(tp, ht);
>   			RCU_INIT_POINTER(*hn, ht->next);
>   			kfree_rcu(ht, rcu);
>   			return 0;
> @@ -540,8 +630,10 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
>   	if (ht == NULL)
>   		return 0;
>
> -	if (TC_U32_KEY(ht->handle))
> +	if (TC_U32_KEY(ht->handle)) {
> +		u32_remove_hw_knode(tp, ht->handle);
>   		return u32_delete_key(tp, (struct tc_u_knode *)ht);
> +	}
>


You are unconditionally calling the _hw_ api. For someone not using _hw_ 
offloads, there are a few more instructions. Maybe just do the
dev->netdev_ops->ndo_setup_tc first?


And to Or's point: How do i distinguish s/w from h/w?

cheers,
jamal

  parent reply	other threads:[~2016-02-17 10:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17  5:15 [net-next PATCH v3 0/8] tc offload for cls_u32 on ixgbe John Fastabend
2016-02-17  5:16 ` [net-next PATCH v3 1/8] net: rework ndo tc op to consume additional qdisc handle parameter John Fastabend
2016-02-17 10:42   ` Jamal Hadi Salim
2016-02-17  5:16 ` [net-next PATCH v3 2/8] net: rework setup_tc ndo op to consume general tc operand John Fastabend
2016-02-17 10:42   ` Jamal Hadi Salim
2016-02-17  5:17 ` [net-next PATCH v3 3/8] net: sched: add cls_u32 offload hooks for netdevs John Fastabend
2016-02-17  7:02   ` Jiri Pirko
2016-02-17 10:59   ` Jamal Hadi Salim [this message]
2016-02-17 14:24     ` John Fastabend
2016-02-17 23:07       ` John Fastabend
2016-02-18  9:23         ` Amir Vadai"
2016-02-19  3:37           ` Simon Horman
2016-02-19  8:16           ` Or Gerlitz
2016-02-18 12:14         ` Jamal Hadi Salim
2016-02-18 15:24           ` John Fastabend
2016-02-19 12:52             ` Jamal Hadi Salim
2016-02-17  5:17 ` [net-next PATCH v3 4/8] net: add tc offload feature flag John Fastabend
2016-02-17 11:01   ` Jamal Hadi Salim
2016-02-17  5:18 ` [net-next PATCH v3 5/8] net: tc: helper functions to query action types John Fastabend
2016-02-17  7:03   ` Jiri Pirko
2016-02-17 11:02   ` Jamal Hadi Salim
2016-02-17  5:18 ` [net-next PATCH v3 6/8] net: ixgbe: add minimal parser details for ixgbe John Fastabend
2016-02-17 11:06   ` Jamal Hadi Salim
2016-02-17 15:09     ` David Miller
2016-02-17 15:14       ` John Fastabend
2016-02-17 18:01   ` Rustad, Mark D
2016-02-17 22:34     ` John Fastabend
2016-02-17  5:18 ` [net-next PATCH v3 7/8] net: ixgbe: add support for tc_u32 offload John Fastabend
2016-02-17 11:17   ` Jamal Hadi Salim
2016-02-17 11:42     ` Jiri Pirko
2016-02-17 11:47       ` Jamal Hadi Salim
2016-02-17 14:25         ` John Fastabend
2016-02-17  5:19 ` [net-next PATCH v3 8/8] net: ixgbe: abort with cls u32 divisor groups greater than 1 John Fastabend
2016-02-17 14:48 ` [net-next PATCH v3 0/8] tc offload for cls_u32 on ixgbe David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C4528E.5090505@mojatatu.com \
    --to=jhs@mojatatu$(echo .)com \
    --cc=amir@vadai$(echo .)me \
    --cc=davem@davemloft$(echo .)net \
    --cc=jeffrey.t.kirsher@intel$(echo .)com \
    --cc=jiri@resnulli$(echo .)us \
    --cc=john.fastabend@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox