From patchwork Thu Jun 1 19:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 127906 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 1780242C07; Thu, 1 Jun 2023 21:59:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C36643020; Thu, 1 Jun 2023 21:56:23 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id 3DD1B42D17 for ; Thu, 1 Jun 2023 21:55:59 +0200 (CEST) Received: from localhost.localdomain (unknown [78.109.69.146]) (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 C436DE1B92; Thu, 1 Jun 2023 23:55:58 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Andy Moreton Subject: [PATCH 33/34] common/sfc_efx/base: support conntrack assistance counters Date: Thu, 1 Jun 2023 23:55:37 +0400 Message-Id: <20230601195538.8265-34-ivan.malov@arknetworks.am> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230601195538.8265-1-ivan.malov@arknetworks.am> References: <20230601195538.8265-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 10908d97ef..0534179381 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 7e5701e801..09b1e95c59 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 eddba0e71c..9ff887e04b 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); @@ -3282,11 +3290,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; @@ -3403,6 +3415,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; @@ -3505,8 +3520,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 == @@ -3517,7 +3535,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; @@ -3526,6 +3544,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) {