From patchwork Sun Jun 4 23:24:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 128031 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 F0BC542C2C; Mon, 5 Jun 2023 01:25:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CCDC242D31; Mon, 5 Jun 2023 01:25:29 +0200 (CEST) Received: from agw.arknetworks.am (agw.arknetworks.am [79.141.165.80]) by mails.dpdk.org (Postfix) with ESMTP id C7F41410ED for ; Mon, 5 Jun 2023 01:25:25 +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 38613E11FF; Mon, 5 Jun 2023 03:25:25 +0400 (+04) From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Ferruh Yigit , Denis Pryazhennikov , Andy Moreton Subject: [PATCH v3 03/34] common/sfc_efx/base: add API to list HW tables Date: Mon, 5 Jun 2023 03:24:52 +0400 Message-Id: <20230604232523.6746-4-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 From: Denis Pryazhennikov New MCDI Table Access API allows management of the HW tables' content. This part of API helps to list all supported tables. In the near future, only the CT table is planned to be used, so only one identifier for this table was added to the efx. New table IDs will be added as needed. Signed-off-by: Denis Pryazhennikov Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 15 ++++ drivers/common/sfc_efx/base/efx_table.c | 94 +++++++++++++++++++++++++ drivers/common/sfc_efx/base/meson.build | 1 + drivers/common/sfc_efx/version.map | 2 + 4 files changed, 112 insertions(+) create mode 100644 drivers/common/sfc_efx/base/efx_table.c diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 520674a602..2de08d1230 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -5070,6 +5070,21 @@ efx_nic_dma_map( __in size_t len, __out efsys_dma_addr_t *nic_addrp); +/* Unique IDs for HW tables */ +typedef enum efx_table_id_e { + EFX_TABLE_ID_CONNTRACK = 0x10300, +} efx_table_id_t; + +LIBEFX_API +extern __checkReturn efx_rc_t +efx_table_list( + __in efx_nic_t *enp, + __in uint32_t entry_ofst, + __out_opt unsigned int *total_n_tablesp, + __out_ecount_opt(n_table_ids) efx_table_id_t *table_ids, + __in unsigned int n_table_ids, + __out_opt unsigned int *n_table_ids_writtenp); + #ifdef __cplusplus } #endif diff --git a/drivers/common/sfc_efx/base/efx_table.c b/drivers/common/sfc_efx/base/efx_table.c new file mode 100644 index 0000000000..7cfdfea36e --- /dev/null +++ b/drivers/common/sfc_efx/base/efx_table.c @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + */ + +#include "efx.h" +#include "efx_impl.h" + + __checkReturn efx_rc_t +efx_table_list( + __in efx_nic_t *enp, + __in uint32_t entry_ofst, + __out_opt unsigned int *total_n_tablesp, + __out_ecount_opt(n_table_ids) efx_table_id_t *table_ids, + __in unsigned int n_table_ids, + __out_opt unsigned int *n_table_ids_writtenp) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + unsigned int n_entries; + efx_mcdi_req_t req; + unsigned int i; + efx_rc_t rc; + EFX_MCDI_DECLARE_BUF(payload, + MC_CMD_TABLE_LIST_IN_LEN, + MC_CMD_TABLE_LIST_OUT_LENMAX_MCDI2); + + /* Ensure EFX and MCDI use same values for table IDs */ + EFX_STATIC_ASSERT(EFX_TABLE_ID_CONNTRACK == TABLE_ID_CONNTRACK_TABLE); + + if (encp->enc_table_api_supported == B_FALSE) { + rc = ENOTSUP; + goto fail1; + } + + if ((n_table_ids != 0) && + ((table_ids == NULL) || (n_table_ids_writtenp == NULL))) { + rc = EINVAL; + goto fail2; + } + + req.emr_cmd = MC_CMD_TABLE_LIST; + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_TABLE_LIST_IN_LEN; + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_TABLE_LIST_OUT_LENMAX_MCDI2; + + MCDI_IN_SET_DWORD(req, TABLE_LIST_IN_FIRST_TABLE_ID_INDEX, entry_ofst); + + efx_mcdi_execute(enp, &req); + + if (req.emr_rc != 0) { + rc = req.emr_rc; + goto fail3; + } + + if (req.emr_out_length_used < MC_CMD_TABLE_LIST_OUT_LENMIN) { + rc = EMSGSIZE; + goto fail4; + } + + if (total_n_tablesp != NULL) + *total_n_tablesp = MCDI_OUT_DWORD(req, TABLE_LIST_OUT_N_TABLES); + + n_entries = MC_CMD_TABLE_LIST_OUT_TABLE_ID_NUM(req.emr_out_length_used); + + if (table_ids != NULL) { + if (n_entries > n_table_ids) { + rc = ENOMEM; + goto fail5; + } + + for (i = 0; i < n_entries; i++) { + table_ids[i] = MCDI_OUT_INDEXED_DWORD(req, + TABLE_LIST_OUT_TABLE_ID, i); + } + } + + if (n_table_ids_writtenp != NULL) + *n_table_ids_writtenp = n_entries; + + return (0); + +fail5: + EFSYS_PROBE(fail5); +fail4: + EFSYS_PROBE(fail4); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} diff --git a/drivers/common/sfc_efx/base/meson.build b/drivers/common/sfc_efx/base/meson.build index ff7f33fb44..7fc04aa57b 100644 --- a/drivers/common/sfc_efx/base/meson.build +++ b/drivers/common/sfc_efx/base/meson.build @@ -16,6 +16,7 @@ sources = [ 'efx_lic.c', 'efx_mac.c', 'efx_mae.c', + 'efx_table.c', 'efx_mcdi.c', 'efx_mon.c', 'efx_nic.c', diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index aabc354118..5717cc0ed2 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -232,6 +232,8 @@ INTERNAL { efx_sram_buf_tbl_clear; efx_sram_buf_tbl_set; + efx_table_list; + efx_tunnel_config_clear; efx_tunnel_config_udp_add; efx_tunnel_config_udp_remove;