Netdev List
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Felipe Magno de Almeida <felipe@sipanda.io>
Cc: jhs@mojatatu.com, jiri@resnulli.us, xiyou.wangcong@gmail.com,
	netdev@vger.kernel.org, boris.sukholitko@broadcom.com,
	vadym.kochan@plvision.eu, ilya.lifshits@broadcom.com,
	vladbu@nvidia.com, idosch@idosch.org, paulb@nvidia.com,
	dcaratti@redhat.com, amritha.nambiar@intel.com,
	sridhar.samudrala@intel.com, tom@sipanda.io,
	pctammela@mojatatu.com, eric.dumazet@gmail.com
Subject: Re: [PATCH RFC net-next 2/2] net/sched: Add flower2 packet classifier based on flower and PANDA parser
Date: Wed, 22 Sep 2021 17:33:45 -0300	[thread overview]
Message-ID: <YUuTKVdtAV73OjVu@t14s.localdomain> (raw)
In-Reply-To: <20210916200041.810-3-felipe@expertise.dev>

On Thu, Sep 16, 2021 at 05:00:41PM -0300, Felipe Magno de Almeida wrote:
> +int fl2_panda_parse(struct sk_buff *skb, struct fl2_flow_key* frame)
> +{
> +	int err;
> +	struct panda_parser_big_metadata_one mdata;
> +	void *data;
> +	size_t pktlen;
> +
> +	memset(&mdata, 0, sizeof(mdata.panda_data));
> +	memcpy(&mdata.frame, frame, sizeof(struct fl2_flow_key));
> +
> +	err = skb_linearize(skb);

Oh ow. Hopefully this is just for the RFC?

> +	if (err < 0)
> +		return err;
> +
> +	BUG_ON(skb->data_len);
> +
> +	data = skb_mac_header(skb);
> +	pktlen = skb_mac_header_len(skb) + skb->len;
> +
> +	err = panda_parse(PANDA_PARSER_KMOD_NAME(panda_parser_big_ether), data,
> +			  pktlen, &mdata.panda_data, 0, 1);
> +
> +	if (err != PANDA_STOP_OKAY) {
> +                pr_err("Failed to parse packet! (%d)", err);
> +		return -1;
> +        }
> +
> +	memcpy(frame, &mdata.frame, sizeof(struct fl2_flow_key));
> +
> +	return 0;
> +}
> +
> +static int fl2_classify(struct sk_buff *skb, const struct tcf_proto *tp,
> +		       struct tcf_result *res)
> +{
> +	struct cls_fl2_head *head = rcu_dereference_bh(tp->root);
> +	struct fl2_flow_key skb_key;
> +	struct fl2_flow_mask *mask;
> +	struct cls_fl2_filter *f;
> +
> +	list_for_each_entry_rcu(mask, &head->masks, list) {
> +		flow_dissector_init_keys(&skb_key.control, &skb_key.basic);
> +		fl2_clear_masked_range(&skb_key, mask);
> +
> +		skb_flow_dissect_meta(skb, &mask->dissector, &skb_key);
> +		/* skb_flow_dissect() does not set n_proto in case an unknown
> +		 * protocol, so do it rather here.
> +		 */
> +		skb_key.basic.n_proto = skb_protocol(skb, false);
> +
> +		if(skb->vlan_present) {
> +			skb_key.basic.n_proto = skb_protocol(skb, true);
> +			skb_key.vlan.vlan_id = skb_vlan_tag_get_id(skb);
> +			skb_key.vlan.vlan_priority = skb_vlan_tag_get_prio(skb);
> +			skb_key.vlan.vlan_tpid = skb->vlan_proto;
> +		}
> +		
> +		fl2_panda_parse(skb, &skb_key);
> +
> +		f = fl2_mask_lookup(mask, &skb_key);
> +		if (f && !tc_skip_sw(f->flags)) {
> +			*res = f->res;
> +			return tcf_exts_exec(skb, &f->exts, res);
> +		}
> +	}
> +	return -1;
> +}

  reply	other threads:[~2021-09-22 22:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 20:00 [PATCH RFC net-next 0/2] net:sched: Introduce tc flower2 classifier based on PANDA parser in kernel Felipe Magno de Almeida
2021-09-16 20:00 ` [PATCH RFC net-next 1/2] net: Add PANDA network packet parser Felipe Magno de Almeida
2021-09-16 20:00 ` [PATCH RFC net-next 2/2] net/sched: Add flower2 packet classifier based on flower and PANDA parser Felipe Magno de Almeida
2021-09-22 20:33   ` Marcelo Ricardo Leitner [this message]
2021-09-23 13:33     ` Felipe Magno de Almeida
2021-09-22  4:38 ` [PATCH RFC net-next 0/2] net:sched: Introduce tc flower2 classifier based on PANDA parser in kernel Cong Wang
2021-09-22  4:46   ` Jiri Pirko
2021-09-22 14:42     ` Tom Herbert
2021-09-22 15:49       ` Simon Horman
2021-09-22 17:28         ` Tom Herbert
2021-09-22 18:00           ` Simon Horman
2021-09-22 21:06             ` Tom Herbert
2021-09-22 21:40               ` John Fastabend
2021-09-22 23:51                 ` Tom Herbert
2021-09-23  1:28                   ` John Fastabend
     [not found]                     ` <CAOuuhY-ujF_EPm6qeHAfgs6O0_-yyfZLMryYx4pS=Yd1XLor+A@mail.gmail.com>
2021-09-23  3:25                       ` John Fastabend
2021-09-23  4:34                         ` Tom Herbert
2021-09-23 13:26                         ` Jamal Hadi Salim
2021-09-24  3:55                           ` John Fastabend
2021-09-24 16:21                             ` Tom Herbert
2021-09-24 19:14                               ` John Fastabend
2021-09-26 15:54                             ` Jamal Hadi Salim
2021-09-22 20:25           ` Marcelo Ricardo Leitner
2021-09-22 23:04             ` Tom Herbert

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=YUuTKVdtAV73OjVu@t14s.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=amritha.nambiar@intel.com \
    --cc=boris.sukholitko@broadcom.com \
    --cc=dcaratti@redhat.com \
    --cc=eric.dumazet@gmail.com \
    --cc=felipe@sipanda.io \
    --cc=idosch@idosch.org \
    --cc=ilya.lifshits@broadcom.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=paulb@nvidia.com \
    --cc=pctammela@mojatatu.com \
    --cc=sridhar.samudrala@intel.com \
    --cc=tom@sipanda.io \
    --cc=vadym.kochan@plvision.eu \
    --cc=vladbu@nvidia.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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