[dpdk-dev] [PATCH] acl: Fix RTE_ACL_RULE_SZ macro definition
Levend Sayar
levendsayar at gmail.com
Tue Jul 7 17:25:13 CEST 2020
Sure.
I am really sorry for not being verbose enough.
>From lib/librte_acl/rte_acl.h
#define RTE_ACL_RULE_DEF(name, fld_num) struct name {\
struct rte_acl_rule_data data; \
struct rte_acl_field field[fld_num]; \
}
RTE_ACL_RULE_DEF(rte_acl_rule,);
When you put the definition in-place, above line means :
struct rte_acl_rule {
struct rte_acl_rule_data data;
struct rte_acl_field field[];
}
There is another define to get the size of an acl rule such as
#define RTE_ACL_RULE_SZ(fld_num) \
(sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) * (fld_num))
So the above definition gets the size of a "struct rte_acl_rule" which has
fld_num fields.
which must be
*sizeof (struct rte_acl_rule_data) *+ (sizeof(struct rte_acl_field) *
fld_num)
Because it adds up the sizes of struct components;
But according to the current RTE_ACL_RULE_SZ, it is
*sizeof (struct rte_acl_rule)* + (sizeof(struct rte_acl_field) * fld_num)
So my patch only changes the part that I underlined.
sizeof (struct rte_acl_rule) = 16;
sizeof (struct rte_acl_rule_data) = 12;
Best,
Levend
On Tue, Jul 7, 2020 at 3:42 PM Ananyev, Konstantin <
konstantin.ananyev at intel.com> wrote:
>
> > From: Levend Sayar <levendsayar at gmail.com>
>
> Could you provide some explanation:
> What do you think is wrong with current version and why,
> and what your fix does.
>
> >
> > Signed-off-by: Levend Sayar <levendsayar at gmail.com>
> > ---
> > lib/librte_acl/rte_acl.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
> > index aa22e70c6..d34fdbc0e 100644
> > --- a/lib/librte_acl/rte_acl.h
> > +++ b/lib/librte_acl/rte_acl.h
> > @@ -116,7 +116,7 @@ struct rte_acl_rule_data {
> > RTE_ACL_RULE_DEF(rte_acl_rule,);
> >
> > #define RTE_ACL_RULE_SZ(fld_num) \
> > - (sizeof(struct rte_acl_rule) + sizeof(struct rte_acl_field) *
> (fld_num))
> > + (sizeof(struct rte_acl_rule_data) + sizeof(struct rte_acl_field) *
> (fld_num))
> >
> >
> > /** Max number of characters in name.*/
> > --
> > 2.27.0
>
>
More information about the dev
mailing list