[1/2] ethdev: allow negative values in flow rule types
Checks
Commit Message
RTE flow items & actions use positive values in item & action type.
Negative values are reserved for PMD private types. PMD
items & actions usually are not exposed to application and are not
used to create RTE flows.
The patch allows applications with access to PMD flow
items & actions ability to integrate RTE and PMD items & actions
and use them to create flow rule.
Signed-off-by: Gregory Etelson <getelson@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
---
lib/librte_ethdev/rte_flow.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
Comments
On 6/25/20 7:03 PM, Gregory Etelson wrote:
> RTE flow items & actions use positive values in item & action type.
> Negative values are reserved for PMD private types. PMD
> items & actions usually are not exposed to application and are not
> used to create RTE flows.
>
> The patch allows applications with access to PMD flow
> items & actions ability to integrate RTE and PMD items & actions
> and use them to create flow rule.
>
> Signed-off-by: Gregory Etelson <getelson@mellanox.com>
> Acked-by: Ori Kam <orika@mellanox.com>
> ---
> lib/librte_ethdev/rte_flow.c | 30 ++++++++++++++++++++++++------
> 1 file changed, 24 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
> index 1685be5f73..c19d25649f 100644
> --- a/lib/librte_ethdev/rte_flow.c
> +++ b/lib/librte_ethdev/rte_flow.c
> @@ -563,7 +563,12 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
> }
> break;
> default:
> - off = rte_flow_desc_item[item->type].size;
> + /**
> + * allow PMD private flow item
> + */
> + off = (uint32_t)item->type <= INT_MAX ?
> + rte_flow_desc_item[item->type].size :
> + sizeof(void *);
May be it is out-of-scope of the patch (strictly speaking), but
usage of 'off' variable is very misleading here. It is not used
as an offset. It is used as a size to copy.
Also it is absolutely unclear why sizeof(void *) is a right
size for PMD private flow items.
> -----Original Message-----
> From: Andrew Rybchenko <arybchenko@solarflare.com>
> Sent: Sunday, July 5, 2020 16:34
> To: Gregory Etelson <getelson@mellanox.com>; dev@dpdk.org
> Cc: Matan Azrad <matan@mellanox.com>; Raslan Darawsheh
> <rasland@mellanox.com>; Ori Kam <orika@mellanox.com>
> Subject: Re: [dpdk-dev] [PATCH 1/2] ethdev: allow negative values in
> flow rule types
>
> On 6/25/20 7:03 PM, Gregory Etelson wrote:
> > RTE flow items & actions use positive values in item & action type.
> > Negative values are reserved for PMD private types. PMD items &
> > actions usually are not exposed to application and are not used to
> > create RTE flows.
> >
> > The patch allows applications with access to PMD flow items &
> > actions ability to integrate RTE and PMD items & actions and use
> > them to create flow rule.
> >
> > Signed-off-by: Gregory Etelson <getelson@mellanox.com>
> > Acked-by: Ori Kam <orika@mellanox.com>
> > ---
> > lib/librte_ethdev/rte_flow.c | 30 ++++++++++++++++++++++++------
> > 1 file changed, 24 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/librte_ethdev/rte_flow.c
> > b/lib/librte_ethdev/rte_flow.c index 1685be5f73..c19d25649f 100644
> > --- a/lib/librte_ethdev/rte_flow.c
> > +++ b/lib/librte_ethdev/rte_flow.c
> > @@ -563,7 +563,12 @@ rte_flow_conv_item_spec(void *buf, const size_t
> size,
> > }
> > break;
> > default:
> > - off = rte_flow_desc_item[item->type].size;
> > + /**
> > + * allow PMD private flow item
> > + */
> > + off = (uint32_t)item->type <= INT_MAX ?
> > + rte_flow_desc_item[item->type].size :
> > + sizeof(void *);
>
> May be it is out-of-scope of the patch (strictly speaking), but usage of 'off'
> variable is very misleading here. It is not used as an offset. It is
> used as a size to copy.
>
The 'off' variable in that scope refers to object size to copy.
I did not change it because it's not related to proposed change.
> Also it is absolutely unclear why sizeof(void *) is a right size for
> PMD private flow items.
RTE flow library functions cannot work with PMD private items & actions (elements)
because RTE flow has no API to query PMD flow object size . In the patch,
PMD flow elements use object pointer. RTE flow library functions handle PMD element object size
as size of a pointer. PMD handles its objects internally.
@@ -563,7 +563,12 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
}
break;
default:
- off = rte_flow_desc_item[item->type].size;
+ /**
+ * allow PMD private flow item
+ */
+ off = (uint32_t)item->type <= INT_MAX ?
+ rte_flow_desc_item[item->type].size :
+ sizeof(void *);
rte_memcpy(buf, data, (size > off ? off : size));
break;
}
@@ -666,7 +671,12 @@ rte_flow_conv_action_conf(void *buf, const size_t size,
}
break;
default:
- off = rte_flow_desc_action[action->type].size;
+ /**
+ * allow PMD private flow action
+ */
+ off = (uint32_t)action->type <= INT_MAX ?
+ rte_flow_desc_action[action->type].size :
+ sizeof(void *);
rte_memcpy(buf, action->conf, (size > off ? off : size));
break;
}
@@ -708,8 +718,12 @@ rte_flow_conv_pattern(struct rte_flow_item *dst,
unsigned int i;
for (i = 0, off = 0; !num || i != num; ++i, ++src, ++dst) {
- if ((size_t)src->type >= RTE_DIM(rte_flow_desc_item) ||
- !rte_flow_desc_item[src->type].name)
+ /**
+ * allow PMD private flow item
+ */
+ if (((uint32_t)src->type <= INT_MAX) &&
+ ((size_t)src->type >= RTE_DIM(rte_flow_desc_item) ||
+ !rte_flow_desc_item[src->type].name))
return rte_flow_error_set
(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, src,
"cannot convert unknown item type");
@@ -797,8 +811,12 @@ rte_flow_conv_actions(struct rte_flow_action *dst,
unsigned int i;
for (i = 0, off = 0; !num || i != num; ++i, ++src, ++dst) {
- if ((size_t)src->type >= RTE_DIM(rte_flow_desc_action) ||
- !rte_flow_desc_action[src->type].name)
+ /**
+ * allow PMD private flow action
+ */
+ if (((uint32_t)src->type <= INT_MAX) &&
+ ((size_t)src->type >= RTE_DIM(rte_flow_desc_action) ||
+ !rte_flow_desc_action[src->type].name))
return rte_flow_error_set
(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
src, "cannot convert unknown action type");