ethdev: allow negative values in flow rule types
authorGregory Etelson <getelson@nvidia.com>
Fri, 16 Oct 2020 12:51:05 +0000 (15:51 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 16 Oct 2020 17:48:19 +0000 (19:48 +0200)
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.

RTE flow item or action conversion library accepts positive known
element types with predefined sizes only. Private PMD items and
actions do not fit into this scheme because PMD type values are
negative, each PMD has it's own types numeration and element types and
their sizes are not visible at RTE level.  To resolve these
limitations the patch proposes this solution:
1. PMD can expose elements of pointer size only.  RTE flow
   conversion functions will use pointer size for each configuration
   object in private PMD element it processes;
2. RTE flow verification will not reject elements with negative type.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
doc/guides/prog_guide/rte_flow.rst
doc/guides/rel_notes/release_20_11.rst
lib/librte_ethdev/rte_flow.c

index 6ee0d3a..7fb5ec9 100644 (file)
@@ -2775,6 +2775,9 @@ identifiers they are not aware of.
 
 A method to generate them remains to be defined.
 
+Application may use PMD dynamic items or actions in flow rules. In that case
+size of configuration object in dynamic element must be a pointer size.
+
 Planned types
 ~~~~~~~~~~~~~
 
index f0e9194..a8b547d 100644 (file)
@@ -110,6 +110,11 @@ New Features
     as flow action.
   * Added new flow APIs to create/update/destroy/query shared action.
 
+* **Flow rules allowed to use private PMD items / actions.**
+
+  * Flow rule verification was updated to accept private PMD
+    items and actions.
+
 * **Updated the ethdev library to support hairpin between two ports.**
 
   New APIs are introduced to support binding / unbinding 2 ports hairpin.
index 686fe40..b74ea55 100644 (file)
@@ -518,7 +518,11 @@ 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 = (int)item->type >= 0 ?
+                     rte_flow_desc_item[item->type].size : sizeof(void *);
                rte_memcpy(buf, data, (size > off ? off : size));
                break;
        }
@@ -621,7 +625,11 @@ 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 = (int)action->type >= 0 ?
+                     rte_flow_desc_action[action->type].size : sizeof(void *);
                rte_memcpy(buf, action->conf, (size > off ? off : size));
                break;
        }
@@ -663,8 +671,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 (((int)src->type >= 0) &&
+                       ((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");
@@ -752,8 +764,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 (((int)src->type >= 0) &&
+                   ((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");