The DPDK driver would like to have a means to make a copy of
the action rule match specification before trying to dissect
it to possibly move out the per-connection 5-tuple data from
it to build up an entry in the HW conntrack assistance table.

Making such a copy at the end of parsing should be preferred
over maintaining DPDK-level structures because the resulting
code is easier on eyes and less prone to errors in this case.

Signed-off-by: Ivan Malov <ivan.ma...@arknetworks.am>
Reviewed-by: Andy Moreton <amore...@xilinx.com>
---
 drivers/common/sfc_efx/base/efx.h     |  7 +++++++
 drivers/common/sfc_efx/base/efx_mae.c | 26 ++++++++++++++++++++++++++
 drivers/common/sfc_efx/version.map    |  1 +
 3 files changed, 34 insertions(+)

diff --git a/drivers/common/sfc_efx/base/efx.h 
b/drivers/common/sfc_efx/base/efx.h
index f96e398460..ee1ea81a35 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -4452,6 +4452,13 @@ efx_mae_match_spec_recirc_id_set(
        __in                            efx_mae_match_spec_t *spec,
        __in                            uint8_t recirc_id);
 
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_match_spec_clone(
+       __in                            efx_nic_t *enp,
+       __in                            efx_mae_match_spec_t *orig,
+       __out                           efx_mae_match_spec_t **clonep);
+
 LIBEFX_API
 extern __checkReturn                   boolean_t
 efx_mae_match_specs_equal(
diff --git a/drivers/common/sfc_efx/base/efx_mae.c 
b/drivers/common/sfc_efx/base/efx_mae.c
index 7732d99992..43dfba518a 100644
--- a/drivers/common/sfc_efx/base/efx_mae.c
+++ b/drivers/common/sfc_efx/base/efx_mae.c
@@ -1163,6 +1163,32 @@ efx_mae_match_spec_mport_set(
 
 fail2:
        EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
+       __checkReturn                   efx_rc_t
+efx_mae_match_spec_clone(
+       __in                            efx_nic_t *enp,
+       __in                            efx_mae_match_spec_t *orig,
+       __out                           efx_mae_match_spec_t **clonep)
+{
+       efx_mae_match_spec_t *clone;
+       efx_rc_t rc;
+
+       EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*clone), clone);
+       if (clone == NULL) {
+               rc = ENOMEM;
+               goto fail1;
+       }
+
+       memcpy(clone, orig, sizeof (efx_mae_match_spec_t));
+
+       *clonep = clone;
+
+       return (0);
+
 fail1:
        EFSYS_PROBE1(fail1, efx_rc_t, rc);
        return (rc);
diff --git a/drivers/common/sfc_efx/version.map 
b/drivers/common/sfc_efx/version.map
index d083a54a03..931d556e80 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -124,6 +124,7 @@ INTERNAL {
        efx_mae_mac_addr_alloc;
        efx_mae_mac_addr_free;
        efx_mae_match_spec_bit_set;
+       efx_mae_match_spec_clone;
        efx_mae_match_spec_field_set;
        efx_mae_match_spec_fini;
        efx_mae_match_spec_init;
-- 
2.30.2

Reply via email to