From patchwork Wed Jun 7 13:02:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 128322 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 76FBB42C4D; Wed, 7 Jun 2023 15:07:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF3034301A; Wed, 7 Jun 2023 15:03:30 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 9014442D8B for ; Wed, 7 Jun 2023 15:03:05 +0200 (CEST) Received: from localhost.localdomain (unknown [78.109.69.83]) (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 1BDC0E1253; Wed, 7 Jun 2023 17:03:05 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Andy Moreton Subject: [PATCH v4 33/34] common/sfc_efx/base: support conntrack assistance counters Date: Wed, 7 Jun 2023 17:02:44 +0400 Message-Id: <20230607130245.8048-34-ivan.malov@arknetworks.am> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230607130245.8048-1-ivan.malov@arknetworks.am> References: <20230601195538.8265-1-ivan.malov@arknetworks.am> <20230607130245.8048-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 Counters that can be referenced by HW conntrack assistance table work similar to those of the action rules. However, their IDs belong to a separate (CT-specific) namespace. These are 1-bit saturating counters with no byte count. Signed-off-by: Ivan Malov Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 2 ++ drivers/common/sfc_efx/base/efx_impl.h | 1 + drivers/common/sfc_efx/base/efx_mae.c | 35 +++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 5a2e05134a..df4ed82780 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4195,6 +4195,7 @@ typedef struct efx_mae_limits_s { uint32_t eml_max_n_counters; uint32_t eml_max_n_action_counters; }; + uint32_t eml_max_n_conntrack_counters; } efx_mae_limits_t; LIBEFX_API @@ -4789,6 +4790,7 @@ efx_mae_action_set_fill_in_eh_id( */ typedef enum efx_counter_type_e { EFX_COUNTER_TYPE_ACTION = 0, + EFX_COUNTER_TYPE_CONNTRACK, } efx_counter_type_t; typedef struct efx_counter_s { diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index f6b472c160..a0dde1b1b4 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -842,6 +842,7 @@ typedef struct efx_mae_s { efx_mae_field_cap_t *em_outer_rule_field_caps; size_t em_outer_rule_field_caps_size; uint32_t em_max_n_action_counters; + uint32_t em_max_n_conntrack_counters; } efx_mae_t; #endif /* EFSYS_OPT_MAE */ diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index 4078146741..6457f39ccf 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -16,7 +16,7 @@ efx_mae_get_capabilities( efx_mcdi_req_t req; EFX_MCDI_DECLARE_BUF(payload, MC_CMD_MAE_GET_CAPS_IN_LEN, - MC_CMD_MAE_GET_CAPS_OUT_LEN); + MC_CMD_MAE_GET_CAPS_V2_OUT_LEN); struct efx_mae_s *maep = enp->en_maep; efx_rc_t rc; @@ -24,7 +24,7 @@ efx_mae_get_capabilities( req.emr_in_buf = payload; req.emr_in_length = MC_CMD_MAE_GET_CAPS_IN_LEN; req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_MAE_GET_CAPS_OUT_LEN; + req.emr_out_length = MC_CMD_MAE_GET_CAPS_V2_OUT_LEN; efx_mcdi_execute(enp, &req); @@ -70,6 +70,13 @@ efx_mae_get_capabilities( maep->em_max_n_action_counters = MCDI_OUT_DWORD(req, MAE_GET_CAPS_OUT_AR_COUNTERS); + if (req.emr_out_length_used >= MC_CMD_MAE_GET_CAPS_V2_OUT_LEN) { + maep->em_max_n_conntrack_counters = + MCDI_OUT_DWORD(req, MAE_GET_CAPS_V2_OUT_CT_COUNTERS); + } else { + maep->em_max_n_conntrack_counters = 0; + } + return (0); fail2: @@ -375,6 +382,7 @@ efx_mae_get_limits( emlp->eml_encap_header_size_limit = MC_CMD_MAE_ENCAP_HEADER_ALLOC_IN_HDR_DATA_MAXNUM_MCDI2; emlp->eml_max_n_action_counters = maep->em_max_n_action_counters; + emlp->eml_max_n_conntrack_counters = maep->em_max_n_conntrack_counters; return (0); @@ -3275,11 +3283,15 @@ efx_mae_counters_alloc_type( efx_rc_t rc; EFX_STATIC_ASSERT(EFX_COUNTER_TYPE_ACTION == MAE_COUNTER_TYPE_AR); + EFX_STATIC_ASSERT(EFX_COUNTER_TYPE_CONNTRACK == MAE_COUNTER_TYPE_CT); switch (type) { case EFX_COUNTER_TYPE_ACTION: max_n_counters = maep->em_max_n_action_counters; break; + case EFX_COUNTER_TYPE_CONNTRACK: + max_n_counters = maep->em_max_n_conntrack_counters; + break; default: rc = EINVAL; goto fail1; @@ -3396,6 +3408,9 @@ efx_mae_counters_free_type( case EFX_COUNTER_TYPE_ACTION: max_n_counters = maep->em_max_n_action_counters; break; + case EFX_COUNTER_TYPE_CONNTRACK: + max_n_counters = maep->em_max_n_conntrack_counters; + break; default: rc = EINVAL; goto fail1; @@ -3498,8 +3513,11 @@ efx_mae_counters_stream_start( __out uint32_t *flags_out) { efx_mcdi_req_t req; - EFX_MCDI_DECLARE_BUF(payload, MC_CMD_MAE_COUNTERS_STREAM_START_IN_LEN, + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_MAE_COUNTERS_STREAM_START_V2_IN_LEN, MC_CMD_MAE_COUNTERS_STREAM_START_OUT_LEN); + struct efx_mae_s *maep = enp->en_maep; + uint32_t counter_types; efx_rc_t rc; EFX_STATIC_ASSERT(EFX_MAE_COUNTERS_STREAM_IN_ZERO_SQUASH_DISABLE == @@ -3510,7 +3528,7 @@ efx_mae_counters_stream_start( req.emr_cmd = MC_CMD_MAE_COUNTERS_STREAM_START; req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_MAE_COUNTERS_STREAM_START_IN_LEN; + req.emr_in_length = MC_CMD_MAE_COUNTERS_STREAM_START_V2_IN_LEN; req.emr_out_buf = payload; req.emr_out_length = MC_CMD_MAE_COUNTERS_STREAM_START_OUT_LEN; @@ -3519,6 +3537,15 @@ efx_mae_counters_stream_start( packet_size); MCDI_IN_SET_DWORD(req, MAE_COUNTERS_STREAM_START_IN_FLAGS, flags_in); + counter_types = (1U << MAE_COUNTER_TYPE_AR); + + if (maep->em_max_n_conntrack_counters != 0) + counter_types |= (1U << MAE_COUNTER_TYPE_CT); + + MCDI_IN_SET_DWORD(req, + MAE_COUNTERS_STREAM_START_V2_IN_COUNTER_TYPES_MASK, + counter_types); + efx_mcdi_execute(enp, &req); if (req.emr_rc != 0) {