From: Simon Horman <simon.horman@corigine.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: netdev@vger.kernel.org, deb.chatterjee@intel.com,
anjali.singhai@intel.com, namrata.limaye@intel.com,
tom@sipanda.io, p4tc-discussions@netdevconf.info,
mleitner@redhat.com, Mahesh.Shirshyad@amd.com,
Vipin.Jain@amd.com, tomasz.osinski@intel.com, jiri@resnulli.us,
xiyou.wangcong@gmail.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
vladbu@nvidia.com, khalidm@nvidia.com, toke@redhat.com
Subject: Re: [PATCH RFC v2 net-next 09/28] p4tc: add P4 data types
Date: Mon, 5 Jun 2023 12:08:32 +0200 [thread overview]
Message-ID: <ZH20IH+yHMk5kAcb@corigine.com> (raw)
In-Reply-To: <20230517110232.29349-9-jhs@mojatatu.com>
On Wed, May 17, 2023 at 07:02:13AM -0400, Jamal Hadi Salim wrote:
> Introduce abstraction that represents P4 data types.
> This also introduces the Kconfig and Makefile which later patches use.
> Types could be little, host or big endian definitions. The abstraction also
> supports defining:
>
> a) bitstrings using annotations in control that look like "bitX" where X
> is the number of bits defined in a type
>
> b) bitslices such that one can define in control bit8[0-3] and
> bit16[0-9]. A 4-bit slice from bits 0-3 and a 10-bit slice from bits
> 0-9 respectively.
>
> Each type has a bitsize, a name (for debugging purposes), an ID and
> methods/ops. The P4 types will be used by metadata, headers, dynamic
> actions and other part of P4TC.
>
> Each type has four ops:
>
> - validate_p4t: Which validates if a given value of a specific type
> meets valid boundary conditions.
>
> - create_bitops: Which, given a bitsize, bitstart and bitend allocates and
> returns a mask and a shift value. For example, if we have type bit8[3-3]
> meaning bitstart = 3 and bitend = 3, we'll create a mask which would only
> give us the fourth bit of a bit8 value, that is, 0x08. Since we are
> interested in the fourth bit, the bit shift value will be 3.
>
> - host_read : Which reads the value of a given type and transforms it to
> host order
>
> - host_write : Which writes a provided host order value and transforms it
> to the type's native order
>
> Co-developed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Victor Nogueira <victor@mojatatu.com>
> Co-developed-by: Pedro Tammela <pctammela@mojatatu.com>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Hi Victor, Pedro and Jamal,
some minor feedback from my side.
> diff --git a/net/sched/p4tc/p4tc_types.c b/net/sched/p4tc/p4tc_types.c
...
> +static struct p4tc_type *p4type_find_byname(const char *name)
> +{
> + struct p4tc_type *type;
> + unsigned long tmp, typeid;
As per my comment on another patch in this series,
please use reverse xmas tree - longest line to shortest -
for local variable declarations in networking code.
The following tool can help:
https://github.com/ecree-solarflare/xmastree
> +
> + idr_for_each_entry_ul(&p4tc_types_idr, type, tmp, typeid) {
> + if (!strncmp(type->name, name, P4T_MAX_STR_SZ))
> + return type;
> + }
> +
> + return NULL;
> +}
...
> +static int p4t_be32_validate(struct p4tc_type *container, void *value,
> + u16 bitstart, u16 bitend,
> + struct netlink_ext_ack *extack)
> +{
> + size_t container_maxsz = U32_MAX;
> + __u32 *val_u32 = value;
> + __be32 val = 0;
> + size_t maxval;
> + int ret;
> +
> + ret = p4t_validate_bitpos(bitstart, bitend, 31, 31, extack);
> + if (ret < 0)
> + return ret;
> +
> + if (value)
> + val = (__be32)(be32_to_cpu(*val_u32));
From a type annotation point of view, a value can be either CPU byte order
or big endian. It can't be both. What was the byte order of val_u32? What is
the desired byte order of val?
Sparse, invoked using make C=1, flags this and
sever other issues with endineness handling.
> +
> + maxval = GENMASK(bitend, 0);
> + if (val && (val > container_maxsz || val > maxval)) {
> + NL_SET_ERR_MSG_MOD(extack, "BE32 value out of range");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
...
next prev parent reply other threads:[~2023-06-05 10:08 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 11:02 [PATCH RFC v2 net-next 01/28] net: sched: act_api: Add dynamic actions IDR Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 02/28] net/sched: act_api: increase action kind string length Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 03/28] net/sched: act_api: increase TCA_ID_MAX Jamal Hadi Salim
2023-06-02 14:19 ` Marcelo Ricardo Leitner
2023-06-03 13:03 ` Jamal Hadi Salim
2023-06-05 17:39 ` Jakub Kicinski
2023-06-06 17:04 ` [p4tc-discussions] " Jamal Hadi Salim
2023-06-06 17:15 ` Jakub Kicinski
2023-06-06 18:52 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 04/28] net/sched: act_api: add init_ops to struct tc_action_op Jamal Hadi Salim
2023-06-05 9:51 ` Simon Horman
2023-06-05 11:09 ` Dan Carpenter
2023-06-05 14:01 ` [p4tc-discussions] " Jamal Hadi Salim
2023-06-05 14:57 ` Dan Carpenter
2023-06-05 15:27 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 05/28] net/sched: act_api: introduce tc_lookup_action_byid() Jamal Hadi Salim
2023-06-02 19:36 ` Marcelo Ricardo Leitner
2023-06-03 13:10 ` Jamal Hadi Salim
2023-06-03 13:14 ` Jamal Hadi Salim
2023-06-05 12:08 ` Marcelo Ricardo Leitner
2023-06-05 14:55 ` [p4tc-discussions] " Jamal Hadi Salim
2023-06-05 9:55 ` Simon Horman
2023-06-05 14:17 ` [p4tc-discussions] " Jamal Hadi Salim
2023-06-05 14:31 ` Simon Horman
2023-06-05 15:04 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 06/28] net/sched: act_api: export generic tc action searcher Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 07/28] net/sched: act_api: add struct p4tc_action_ops as a parameter to lookup callback Jamal Hadi Salim
2023-06-02 19:43 ` Marcelo Ricardo Leitner
2023-06-03 13:17 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 08/28] net: introduce rcu_replace_pointer_rtnl Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 09/28] p4tc: add P4 data types Jamal Hadi Salim
2023-06-02 20:30 ` Marcelo Ricardo Leitner
2023-06-03 13:54 ` Jamal Hadi Salim
2023-06-05 10:08 ` Simon Horman [this message]
2023-06-05 14:26 ` [p4tc-discussions] " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 10/28] p4tc: add pipeline create, get, update, delete Jamal Hadi Salim
2023-06-05 10:12 ` Simon Horman
2023-06-05 14:32 ` [p4tc-discussions] " Jamal Hadi Salim
2023-06-05 14:35 ` Simon Horman
2023-06-05 15:13 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 11/28] p4tc: add metadata create, update, delete, get, flush and dump Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 12/28] p4tc: add header field create, get, delete, " Jamal Hadi Salim
2023-06-05 10:24 ` Simon Horman
2023-06-05 14:48 ` [p4tc-discussions] " Jamal Hadi Salim
2023-06-05 15:14 ` Simon Horman
2023-06-05 15:34 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 13/28] p4tc: add action template create, update, delete, get, " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 14/28] p4tc: add table " Jamal Hadi Salim
2023-06-02 21:54 ` Marcelo Ricardo Leitner
2023-06-03 14:15 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 15/28] p4tc: add table entry create, update, get, delete, " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 16/28] p4tc: add register create, update, delete, get, " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 17/28] p4tc: add dynamic action commands Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 18/28] p4tc: add P4 classifier Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 19/28] selftests: tc-testing: add JSON introspection file directory for P4TC Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 20/28] selftests: tc-testing: Don't assume ENVIR is declared in local config Jamal Hadi Salim
2023-06-02 22:08 ` Marcelo Ricardo Leitner
2023-06-03 14:17 ` Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 21/28] selftests: tc-testing: add P4TC pipeline control path tdc tests Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 22/28] selftests: tc-testing: add P4TC metadata " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 23/28] selftests: tc-testing: add P4TC action templates " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 24/28] selftests: tc-testing: add P4TC table control path " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 25/28] selftests: tc-testing: add P4TC table entries " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 26/28] selftests: tc-testing: add P4TC register " Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 27/28] p4tc: add set of P4TC table lookup kfuncs Jamal Hadi Salim
2023-05-17 11:02 ` [PATCH RFC v2 net-next 28/28] MAINTAINERS: add p4tc entry Jamal Hadi Salim
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=ZH20IH+yHMk5kAcb@corigine.com \
--to=simon.horman@corigine.com \
--cc=Mahesh.Shirshyad@amd.com \
--cc=Vipin.Jain@amd.com \
--cc=anjali.singhai@intel.com \
--cc=davem@davemloft.net \
--cc=deb.chatterjee@intel.com \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=khalidm@nvidia.com \
--cc=kuba@kernel.org \
--cc=mleitner@redhat.com \
--cc=namrata.limaye@intel.com \
--cc=netdev@vger.kernel.org \
--cc=p4tc-discussions@netdevconf.info \
--cc=pabeni@redhat.com \
--cc=toke@redhat.com \
--cc=tom@sipanda.io \
--cc=tomasz.osinski@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).