From patchwork Sun Jun 4 23:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 128049 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15C5242C2C; Mon, 5 Jun 2023 01:27:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 488B742DCF; Mon, 5 Jun 2023 01:25:51 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 3969A42D4E for ; Mon, 5 Jun 2023 01:25:36 +0200 (CEST) Received: from localhost.localdomain (unknown [78.109.68.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by agw.arknetworks.am (Postfix) with ESMTPSA id BC7FDE126C; Mon, 5 Jun 2023 03:25:35 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Andy Moreton Subject: [PATCH v3 21/34] common/sfc_efx/base: provide an API to clone MAE match specs Date: Mon, 5 Jun 2023 03:25:10 +0400 Message-Id: <20230604232523.6746-22-ivan.malov@arknetworks.am> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230604232523.6746-1-ivan.malov@arknetworks.am> References: <20230601195538.8265-1-ivan.malov@arknetworks.am> <20230604232523.6746-1-ivan.malov@arknetworks.am> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Reviewed-by: Andy Moreton --- 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;