From patchwork Sun May 30 08:58:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkat Duvvuru X-Patchwork-Id: 93551 X-Patchwork-Delegate: ajit.khaparde@broadcom.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 255C7A0524; Sun, 30 May 2021 11:00:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0AD640E64; Sun, 30 May 2021 11:00:32 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (saphodev.broadcom.com [192.19.11.229]) by mails.dpdk.org (Postfix) with ESMTP id 8311040E0F for ; Sun, 30 May 2021 11:00:29 +0200 (CEST) Received: from S60.dhcp.broadcom.net (unknown [10.123.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 990407DAF; Sun, 30 May 2021 02:00:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 990407DAF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1622365229; bh=Pw4UWVJklp28XXqHfOp1ofjZDwuWjoy2zP4l1XAO+pU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6aeyaYz9glQwRsoLNtFuPUk8IsYRr57cGx8ktyNE2SXwuNlVUXgudPHQTeysZeP/ y7CwJ8THSZb/dYpi0v4fwogK4BCbccHpy4Mbn0IzWRQ6zdzbiLxWRTVkHf6iGEVeg1 /6GPVkzrungANlqkqkAEotXGSPr+1TkXEAh8qKo0= From: Venkat Duvvuru To: dev@dpdk.org Cc: Farah Smith , Peter Spreadborough , Randy Schacher , Venkat Duvvuru Date: Sun, 30 May 2021 14:28:33 +0530 Message-Id: <20210530085929.29695-3-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com> References: <20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 02/58] net/bnxt: add base TRUFLOW support for Thor 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 Sender: "dev" From: Farah Smith Add infrastructure code to support TRUFLOW on Thor NICs. Also update meson.build Signed-off-by: Farah Smith Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/cfa_resource_types.h | 1 - drivers/net/bnxt/tf_core/meson.build | 1 + drivers/net/bnxt/tf_core/tf_core.c | 1 + drivers/net/bnxt/tf_core/tf_device.c | 207 +++++++++++++ drivers/net/bnxt/tf_core/tf_device.h | 24 ++ drivers/net/bnxt/tf_core/tf_device_p4.c | 111 ++++++- drivers/net/bnxt/tf_core/tf_device_p4.h | 3 +- drivers/net/bnxt/tf_core/tf_device_p58.c | 284 ++++++++++++++++++ drivers/net/bnxt/tf_core/tf_device_p58.h | 79 +++++ drivers/net/bnxt/tf_core/tf_em_common.c | 4 +- drivers/net/bnxt/tf_core/tf_msg.c | 33 -- drivers/net/bnxt/tf_core/tf_rm.c | 8 +- drivers/net/bnxt/tf_core/tf_shadow_tcam.c | 4 +- 13 files changed, 711 insertions(+), 49 deletions(-) create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.c create mode 100644 drivers/net/bnxt/tf_core/tf_device_p58.h diff --git a/drivers/net/bnxt/tf_core/cfa_resource_types.h b/drivers/net/bnxt/tf_core/cfa_resource_types.h index f55a98a388..b63b87bcf3 100644 --- a/drivers/net/bnxt/tf_core/cfa_resource_types.h +++ b/drivers/net/bnxt/tf_core/cfa_resource_types.h @@ -254,5 +254,4 @@ #define CFA_RESOURCE_TYPE_P4_TBL_SCOPE 0x22UL #define CFA_RESOURCE_TYPE_P4_LAST CFA_RESOURCE_TYPE_P4_TBL_SCOPE - #endif /* _CFA_RESOURCE_TYPES_H_ */ diff --git a/drivers/net/bnxt/tf_core/meson.build b/drivers/net/bnxt/tf_core/meson.build index b23e0fbe70..d7e8f664fd 100644 --- a/drivers/net/bnxt/tf_core/meson.build +++ b/drivers/net/bnxt/tf_core/meson.build @@ -20,6 +20,7 @@ sources += files( 'tf_session.c', 'tf_device.c', 'tf_device_p4.c', + 'tf_device_p58.c', 'tf_identifier.c', 'tf_shadow_tbl.c', 'tf_shadow_tcam.c', diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index feec3cf459..b1ce4e721c 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -35,6 +35,7 @@ tf_open_session(struct tf *tfp, * firmware open session succeeds. */ if (parms->device_type != TF_DEVICE_TYPE_WH && + parms->device_type != TF_DEVICE_TYPE_THOR && parms->device_type != TF_DEVICE_TYPE_SR) { TFP_DRV_LOG(ERR, "Unsupported device type %d\n", diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index f68eb723fe..9c63f6d5d4 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -5,6 +5,7 @@ #include "tf_device.h" #include "tf_device_p4.h" +#include "tf_device_p58.h" #include "tfp.h" #include "tf_em.h" @@ -12,6 +13,7 @@ struct tf; /* Forward declarations */ static int tf_dev_unbind_p4(struct tf *tfp); +static int tf_dev_unbind_p58(struct tf *tfp); /** * Device specific bind function, WH+ @@ -234,6 +236,203 @@ tf_dev_unbind_p4(struct tf *tfp) return rc; } +/** + * Device specific bind function, THOR + * + * [in] tfp + * Pointer to TF handle + * + * [in] shadow_copy + * Flag controlling shadow copy DB creation + * + * [in] resources + * Pointer to resource allocation information + * + * [out] dev_handle + * Device handle + * + * Returns + * - (0) if successful. + * - (-EINVAL) on parameter or internal failure. + */ +static int +tf_dev_bind_p58(struct tf *tfp, + bool shadow_copy, + struct tf_session_resources *resources, + struct tf_dev_info *dev_handle) +{ + int rc; + int frc; + struct tf_ident_cfg_parms ident_cfg; + struct tf_tbl_cfg_parms tbl_cfg; + struct tf_tcam_cfg_parms tcam_cfg; + struct tf_em_cfg_parms em_cfg; + struct tf_if_tbl_cfg_parms if_tbl_cfg; + struct tf_global_cfg_cfg_parms global_cfg; + + /* Initial function initialization */ + dev_handle->ops = &tf_dev_ops_p58_init; + + /* Initialize the modules */ + + ident_cfg.num_elements = TF_IDENT_TYPE_MAX; + ident_cfg.cfg = tf_ident_p58; + ident_cfg.shadow_copy = shadow_copy; + ident_cfg.resources = resources; + rc = tf_ident_bind(tfp, &ident_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Identifier initialization failure\n"); + goto fail; + } + + tbl_cfg.num_elements = TF_TBL_TYPE_MAX; + tbl_cfg.cfg = tf_tbl_p58; + tbl_cfg.shadow_copy = shadow_copy; + tbl_cfg.resources = resources; + rc = tf_tbl_bind(tfp, &tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Table initialization failure\n"); + goto fail; + } + + tcam_cfg.num_elements = TF_TCAM_TBL_TYPE_MAX; + tcam_cfg.cfg = tf_tcam_p58; + tcam_cfg.shadow_copy = shadow_copy; + tcam_cfg.resources = resources; + rc = tf_tcam_bind(tfp, &tcam_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "TCAM initialization failure\n"); + goto fail; + } + + /* + * EM + */ + em_cfg.num_elements = TF_EM_TBL_TYPE_MAX; + em_cfg.cfg = tf_em_int_p58; + em_cfg.resources = resources; + em_cfg.mem_type = 0; /* Not used by EM */ + + rc = tf_em_int_bind(tfp, &em_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "EM initialization failure\n"); + goto fail; + } + + /* + * IF_TBL + */ + if_tbl_cfg.num_elements = TF_IF_TBL_TYPE_MAX; + if_tbl_cfg.cfg = tf_if_tbl_p58; + if_tbl_cfg.shadow_copy = shadow_copy; + rc = tf_if_tbl_bind(tfp, &if_tbl_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "IF Table initialization failure\n"); + goto fail; + } + + /* + * GLOBAL_CFG + */ + global_cfg.num_elements = TF_GLOBAL_CFG_TYPE_MAX; + global_cfg.cfg = tf_global_cfg_p58; + rc = tf_global_cfg_bind(tfp, &global_cfg); + if (rc) { + TFP_DRV_LOG(ERR, + "Global Cfg initialization failure\n"); + goto fail; + } + + /* Final function initialization */ + dev_handle->ops = &tf_dev_ops_p58; + + return 0; + + fail: + /* Cleanup of already created modules */ + frc = tf_dev_unbind_p58(tfp); + if (frc) + return frc; + + return rc; +} + +/** + * Device specific unbind function, THOR + * + * [in] tfp + * Pointer to TF handle + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int + tf_dev_unbind_p58(struct tf *tfp) +{ + int rc = 0; + bool fail = false; + + /* Unbind all the support modules. As this is only done on + * close we only report errors as everything has to be cleaned + * up regardless. + * + * In case of residuals TCAMs are cleaned up first as to + * invalidate the pipeline in a clean manner. + */ + rc = tf_tcam_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, TCAM\n"); + fail = true; + } + + rc = tf_ident_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, Identifier\n"); + fail = true; + } + + rc = tf_tbl_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, Table Type\n"); + fail = true; + } + + rc = tf_em_int_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, EM\n"); + fail = true; + } + + rc = tf_if_tbl_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, IF Table Type\n"); + fail = true; + } + + rc = tf_global_cfg_unbind(tfp); + if (rc) { + TFP_DRV_LOG(ERR, + "Device unbind failed, Global Cfg Type\n"); + fail = true; + } + + if (fail) + return -1; + + return rc; +} + int tf_dev_bind(struct tf *tfp __rte_unused, enum tf_device_type type, @@ -249,6 +448,12 @@ tf_dev_bind(struct tf *tfp __rte_unused, shadow_copy, resources, dev_handle); + case TF_DEVICE_TYPE_THOR: + dev_handle->type = type; + return tf_dev_bind_p58(tfp, + shadow_copy, + resources, + dev_handle); default: TFP_DRV_LOG(ERR, "No such device\n"); @@ -264,6 +469,8 @@ tf_dev_unbind(struct tf *tfp, case TF_DEVICE_TYPE_WH: case TF_DEVICE_TYPE_SR: return tf_dev_unbind_p4(tfp); + case TF_DEVICE_TYPE_THOR: + return tf_dev_unbind_p58(tfp); default: TFP_DRV_LOG(ERR, "No such device\n"); diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index d0c4ec80d0..d5ef72309f 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -134,6 +134,28 @@ struct tf_dev_ops { int (*tf_dev_get_max_types)(struct tf *tfp, uint16_t *max_types); + /** + * Retrieves the string description for the CFA resource + * type + * + * [in] tfp + * Pointer to TF handle + * + * [in] resource_id + * HCAPI cfa resource type id + * + * [out] resource_str + * Pointer to a string + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_get_resource_str)(struct tf *tfp, + uint16_t resource_id, + const char **resource_str); + + /** * Retrieves the WC TCAM slice information that the device * supports. @@ -709,5 +731,7 @@ struct tf_dev_ops { */ extern const struct tf_dev_ops tf_dev_ops_p4_init; extern const struct tf_dev_ops tf_dev_ops_p4; +extern const struct tf_dev_ops tf_dev_ops_p58_init; +extern const struct tf_dev_ops tf_dev_ops_p58; #endif /* _TF_DEVICE_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 17d2f05bcc..257a0fb2d0 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -4,8 +4,8 @@ */ #include -#include +#include "cfa_resource_types.h" #include "tf_device.h" #include "tf_identifier.h" #include "tf_tbl.h" @@ -17,6 +17,79 @@ #define TF_DEV_P4_PARIF_MAX 16 #define TF_DEV_P4_PF_MASK 0xfUL +const char *tf_resource_str_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = { + /* CFA_RESOURCE_TYPE_P4_MCG */ + "mc_group", + /* CFA_RESOURCE_TYPE_P4_ENCAP_8B */ + "encap_8 ", + /* CFA_RESOURCE_TYPE_P4_ENCAP_16B */ + "encap_16", + /* CFA_RESOURCE_TYPE_P4_ENCAP_64B */ + "encap_64", + /* CFA_RESOURCE_TYPE_P4_SP_MAC */ + "sp_mac ", + /* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4 */ + "sp_macv4", + /* CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6 */ + "sp_macv6", + /* CFA_RESOURCE_TYPE_P4_COUNTER_64B */ + "ctr_64b ", + /* CFA_RESOURCE_TYPE_P4_NAT_PORT */ + "nat_port", + /* CFA_RESOURCE_TYPE_P4_NAT_IPV4 */ + "nat_ipv4", + /* CFA_RESOURCE_TYPE_P4_METER */ + "meter ", + /* CFA_RESOURCE_TYPE_P4_FLOW_STATE */ + "flow_st ", + /* CFA_RESOURCE_TYPE_P4_FULL_ACTION */ + "full_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION */ + "fmt0_act", + /* CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION */ + "ext0_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION */ + "fmt1_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION */ + "fmt2_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION */ + "fmt3_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION */ + "fmt4_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION */ + "fmt5_act", + /* CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION */ + "fmt6_act", + /* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH */ + "l2ctx_hi", + /* CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW */ + "l2ctx_lo", + /* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH */ + "l2ctr_hi", + /* CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW */ + "l2ctr_lo", + /* CFA_RESOURCE_TYPE_P4_PROF_FUNC */ + "prf_func", + /* CFA_RESOURCE_TYPE_P4_PROF_TCAM */ + "prf_tcam", + /* CFA_RESOURCE_TYPE_P4_EM_PROF_ID */ + "em_prof ", + /* CFA_RESOURCE_TYPE_P4_EM_REC */ + "em_rec ", + /* CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID */ + "wc_prof ", + /* CFA_RESOURCE_TYPE_P4_WC_TCAM */ + "wc_tcam ", + /* CFA_RESOURCE_TYPE_P4_METER_PROF */ + "mtr_prof", + /* CFA_RESOURCE_TYPE_P4_MIRROR */ + "mirror ", + /* CFA_RESOURCE_TYPE_P4_SP_TCAM */ + "sp_tcam ", + /* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */ + "tb_scope", +}; + /** * Device specific function that retrieves the MAX number of HCAPI * types the device supports. @@ -25,7 +98,7 @@ * Pointer to TF handle * * [out] max_types - * Pointer to the MAX number of HCAPI types supported + * Pointer to the MAX number of CFA resource types supported * * Returns * - (0) if successful. @@ -61,6 +134,38 @@ tf_dev_p4_get_max_types(struct tf *tfp, return 0; } +/** + * Device specific function that retrieves a human readable + * string to identify a CFA resource type. + * + * [in] tfp + * Pointer to TF handle + * + * [in] resource_id + * HCAPI CFA resource id + * + * [out] resource_str + * Resource string + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int +tf_dev_p4_get_resource_str(struct tf *tfp __rte_unused, + uint16_t resource_id, + const char **resource_str) +{ + if (resource_str == NULL) + return -EINVAL; + + if (resource_id > CFA_RESOURCE_TYPE_P4_LAST) + return -EINVAL; + + *resource_str = tf_resource_str_p4[resource_id]; + + return 0; +} /** * Device specific function that retrieves the WC TCAM slices the @@ -142,6 +247,7 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused, */ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_get_max_types = tf_dev_p4_get_max_types, + .tf_dev_get_resource_str = tf_dev_p4_get_resource_str, .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info, .tf_dev_alloc_ident = NULL, .tf_dev_free_ident = NULL, @@ -179,6 +285,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { */ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_get_max_types = tf_dev_p4_get_max_types, + .tf_dev_get_resource_str = tf_dev_p4_get_resource_str, .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info, .tf_dev_alloc_ident = tf_ident_alloc, .tf_dev_free_ident = tf_ident_free, diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h index 81ed2322d1..bfad02a0b8 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.h +++ b/drivers/net/bnxt/tf_core/tf_device_p4.h @@ -6,8 +6,7 @@ #ifndef _TF_DEVICE_P4_H_ #define _TF_DEVICE_P4_H_ -#include - +#include "cfa_resource_types.h" #include "tf_core.h" #include "tf_rm.h" #include "tf_if_tbl.h" diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c new file mode 100644 index 0000000000..fb5ad29a5c --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -0,0 +1,284 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2021 Broadcom + * All rights reserved. + */ + +#include + +#include "cfa_resource_types.h" +#include "tf_device.h" +#include "tf_identifier.h" +#include "tf_tbl.h" +#include "tf_tcam.h" +#include "tf_em.h" +#include "tf_if_tbl.h" +#include "tfp.h" + +#define TF_DEV_P58_PARIF_MAX 16 +#define TF_DEV_P58_PF_MASK 0xfUL + +const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = { + /* CFA_RESOURCE_TYPE_P58_METER */ + "meter ", + /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_0 */ + "sram_bk0", + /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_1 */ + "sram_bk1", + /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_2 */ + "sram_bk2", + /* CFA_RESOURCE_TYPE_P58_SRAM_BANK_3 */ + "sram_bk3", + /* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH */ + "l2ctx_hi", + /* CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW */ + "l2ctx_lo", + /* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH */ + "l2ctr_hi", + /* CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW */ + "l2ctr_lo", + /* CFA_RESOURCE_TYPE_P58_PROF_FUNC */ + "prf_func", + /* CFA_RESOURCE_TYPE_P58_PROF_TCAM */ + "prf_tcam", + /* CFA_RESOURCE_TYPE_P58_EM_PROF_ID */ + "em_prof ", + /* CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID */ + "wc_prof ", + /* CFA_RESOURCE_TYPE_P58_EM_REC */ + "em_rec ", + /* CFA_RESOURCE_TYPE_P58_WC_TCAM */ + "wc_tcam ", + /* CFA_RESOURCE_TYPE_P58_METER_PROF */ + "mtr_prof", + /* CFA_RESOURCE_TYPE_P58_MIRROR */ + "mirror ", + /* CFA_RESOURCE_TYPE_P58_EM_FKB */ + "em_fkb ", + /* CFA_RESOURCE_TYPE_P58_WC_FKB */ + "wc_fkb ", + /* CFA_RESOURCE_TYPE_P58_VEB_TCAM */ + "veb ", +}; + +/** + * Device specific function that retrieves the MAX number of HCAPI + * types the device supports. + * + * [in] tfp + * Pointer to TF handle + * + * [out] max_types + * Pointer to the MAX number of HCAPI types supported + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int +tf_dev_p58_get_max_types(struct tf *tfp, + uint16_t *max_types) +{ + struct tf_session *tfs; + struct tf_dev_info *dev; + int rc; + + if (max_types == NULL || tfp == NULL) + return -EINVAL; + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) + return rc; + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) + return rc; + + *max_types = CFA_RESOURCE_TYPE_P58_LAST + 1; + + return 0; +} +/** + * Device specific function that retrieves a human readable + * string to identify a CFA resource type. + * + * [in] tfp + * Pointer to TF handle + * + * [in] resource_id + * HCAPI CFA resource id + * + * [out] resource_str + * Resource string + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int +tf_dev_p58_get_resource_str(struct tf *tfp __rte_unused, + uint16_t resource_id, + const char **resource_str) +{ + if (resource_str == NULL) + return -EINVAL; + + if (resource_id > CFA_RESOURCE_TYPE_P58_LAST) + return -EINVAL; + + *resource_str = tf_resource_str_p58[resource_id]; + + return 0; +} + +/** + * Device specific function that retrieves the WC TCAM slices the + * device supports. + * + * [in] tfp + * Pointer to TF handle + * + * [out] slice_size + * Pointer to the WC TCAM slice size + * + * [out] num_slices_per_row + * Pointer to the WC TCAM row slice configuration + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int +tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused, + enum tf_tcam_tbl_type type, + uint16_t key_sz, + uint16_t *num_slices_per_row) +{ +#define CFA_P58_WC_TCAM_SLICES_PER_ROW 2 +#define CFA_P58_WC_TCAM_SLICE_SIZE 12 + + if (type == TF_TCAM_TBL_TYPE_WC_TCAM) { + *num_slices_per_row = CFA_P58_WC_TCAM_SLICES_PER_ROW; + if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE) + return -ENOTSUP; + + *num_slices_per_row = 1; + } else { /* for other type of tcam */ + *num_slices_per_row = 1; + } + + return 0; +} + +static int +tf_dev_p58_map_parif(struct tf *tfp __rte_unused, + uint16_t parif_bitmask, + uint16_t pf, + uint8_t *data, + uint8_t *mask, + uint16_t sz_in_bytes) +{ + uint32_t parif_pf[2] = { 0 }; + uint32_t parif_pf_mask[2] = { 0 }; + uint32_t parif; + uint32_t shift; + + if (sz_in_bytes != sizeof(uint64_t)) + return -ENOTSUP; + + for (parif = 0; parif < TF_DEV_P58_PARIF_MAX; parif++) { + if (parif_bitmask & (1UL << parif)) { + if (parif < 8) { + shift = 4 * parif; + parif_pf_mask[0] |= TF_DEV_P58_PF_MASK << shift; + parif_pf[0] |= pf << shift; + } else { + shift = 4 * (parif - 8); + parif_pf_mask[1] |= TF_DEV_P58_PF_MASK << shift; + parif_pf[1] |= pf << shift; + } + } + } + tfp_memcpy(data, parif_pf, sz_in_bytes); + tfp_memcpy(mask, parif_pf_mask, sz_in_bytes); + + return 0; +} + + +/** + * Truflow P58 device specific functions + */ +const struct tf_dev_ops tf_dev_ops_p58_init = { + .tf_dev_get_max_types = tf_dev_p58_get_max_types, + .tf_dev_get_resource_str = tf_dev_p58_get_resource_str, + .tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info, + .tf_dev_alloc_ident = NULL, + .tf_dev_free_ident = NULL, + .tf_dev_search_ident = NULL, + .tf_dev_alloc_ext_tbl = NULL, + .tf_dev_alloc_tbl = NULL, + .tf_dev_free_ext_tbl = NULL, + .tf_dev_free_tbl = NULL, + .tf_dev_alloc_search_tbl = NULL, + .tf_dev_set_tbl = NULL, + .tf_dev_set_ext_tbl = NULL, + .tf_dev_get_tbl = NULL, + .tf_dev_get_bulk_tbl = NULL, + .tf_dev_alloc_tcam = NULL, + .tf_dev_free_tcam = NULL, + .tf_dev_alloc_search_tcam = NULL, + .tf_dev_set_tcam = NULL, + .tf_dev_get_tcam = NULL, + .tf_dev_insert_int_em_entry = NULL, + .tf_dev_delete_int_em_entry = NULL, + .tf_dev_insert_ext_em_entry = NULL, + .tf_dev_delete_ext_em_entry = NULL, + .tf_dev_alloc_tbl_scope = NULL, + .tf_dev_map_tbl_scope = NULL, + .tf_dev_map_parif = NULL, + .tf_dev_free_tbl_scope = NULL, + .tf_dev_set_if_tbl = NULL, + .tf_dev_get_if_tbl = NULL, + .tf_dev_set_global_cfg = NULL, + .tf_dev_get_global_cfg = NULL, +}; + +/** + * Truflow P58 device specific functions + */ +const struct tf_dev_ops tf_dev_ops_p58 = { + .tf_dev_get_max_types = tf_dev_p58_get_max_types, + .tf_dev_get_resource_str = tf_dev_p58_get_resource_str, + .tf_dev_get_tcam_slice_info = tf_dev_p58_get_tcam_slice_info, + .tf_dev_alloc_ident = tf_ident_alloc, + .tf_dev_free_ident = tf_ident_free, + .tf_dev_search_ident = tf_ident_search, + .tf_dev_alloc_tbl = tf_tbl_alloc, + .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc, + .tf_dev_free_tbl = tf_tbl_free, + .tf_dev_free_ext_tbl = tf_tbl_ext_free, + .tf_dev_alloc_search_tbl = tf_tbl_alloc_search, + .tf_dev_set_tbl = tf_tbl_set, + .tf_dev_set_ext_tbl = tf_tbl_ext_common_set, + .tf_dev_get_tbl = tf_tbl_get, + .tf_dev_get_bulk_tbl = tf_tbl_bulk_get, + .tf_dev_alloc_tcam = tf_tcam_alloc, + .tf_dev_free_tcam = tf_tcam_free, + .tf_dev_alloc_search_tcam = tf_tcam_alloc_search, + .tf_dev_set_tcam = tf_tcam_set, + .tf_dev_get_tcam = NULL, + .tf_dev_insert_int_em_entry = tf_em_insert_int_entry, + .tf_dev_delete_int_em_entry = tf_em_delete_int_entry, + .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry, + .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry, + .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc, + .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope, + .tf_dev_map_parif = tf_dev_p58_map_parif, + .tf_dev_free_tbl_scope = tf_em_ext_common_free, + .tf_dev_set_if_tbl = tf_if_tbl_set, + .tf_dev_get_if_tbl = tf_if_tbl_get, + .tf_dev_set_global_cfg = tf_global_cfg_set, + .tf_dev_get_global_cfg = tf_global_cfg_get, +}; diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.h b/drivers/net/bnxt/tf_core/tf_device_p58.h new file mode 100644 index 0000000000..3d6e3240bf --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_device_p58.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2021 Broadcom + * All rights reserved. + */ + +#ifndef _TF_DEVICE_P58_H_ +#define _TF_DEVICE_P58_H_ + +#include "cfa_resource_types.h" +#include "tf_core.h" +#include "tf_rm.h" +#include "tf_if_tbl.h" +#include "tf_global_cfg.h" + +struct tf_rm_element_cfg tf_ident_p58[TF_IDENT_TYPE_MAX] = { + [TF_IDENT_TYPE_L2_CTXT_HIGH] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH + }, + [TF_IDENT_TYPE_L2_CTXT_LOW] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW + }, + [TF_IDENT_TYPE_PROF_FUNC] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_FUNC + }, + [TF_IDENT_TYPE_WC_PROF] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID + }, + [TF_IDENT_TYPE_EM_PROF] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_EM_PROF_ID + }, +}; + +struct tf_rm_element_cfg tf_tcam_p58[TF_TCAM_TBL_TYPE_MAX] = { + [TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH + }, + [TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW + }, + [TF_TCAM_TBL_TYPE_PROF_TCAM] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_PROF_TCAM + }, + [TF_TCAM_TBL_TYPE_WC_TCAM] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_WC_TCAM + }, + [TF_TCAM_TBL_TYPE_VEB_TCAM] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_VEB_TCAM + }, +}; + +struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = { + [TF_TBL_TYPE_METER_PROF] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_PROF + }, + [TF_TBL_TYPE_METER_INST] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER + }, + [TF_TBL_TYPE_MIRROR_CONFIG] = { + TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR + }, +}; + +struct tf_rm_element_cfg tf_em_int_p58[TF_EM_TBL_TYPE_MAX] = { + [TF_EM_TBL_TYPE_EM_RECORD] = { + TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P58_EM_REC + }, +}; + +struct tf_if_tbl_cfg tf_if_tbl_p58[TF_IF_TBL_TYPE_MAX]; + +struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = { + [TF_TUNNEL_ENCAP] = { + TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP + }, + [TF_ACTION_BLOCK] = { + TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK + }, +}; +#endif /* _TF_DEVICE_P58_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index c4137af2bd..ddc6b3c4dd 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -1115,8 +1115,8 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp, goto cleaner; } - gcfg_parms.type = - (enum tf_global_config_type)TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF; + /* Note that TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF is same as below enum */ + gcfg_parms.type = TF_GLOBAL_CFG_TYPE_MAX; gcfg_parms.offset = 0; gcfg_parms.config = (uint8_t *)data; gcfg_parms.config_mask = (uint8_t *)mask; diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 46fc6288b2..f20a5113bf 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -19,9 +19,6 @@ #include "hwrm_tf.h" #include "tf_em.h" -/* Logging defines */ -#define TF_RM_MSG_DEBUG 0 - /* Specific msg size defines as we cannot use defines in tf.yaml. This * means we have to manually sync hwrm with these defines if the * tf.yaml changes. @@ -361,29 +358,13 @@ tf_msg_session_resc_qcaps(struct tf *tfp, goto cleanup; } -#if (TF_RM_MSG_DEBUG == 1) - printf("size: %d\n", tfp_le_to_cpu_32(resp.size)); -#endif /* (TF_RM_MSG_DEBUG == 1) */ - /* Post process the response */ data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr; -#if (TF_RM_MSG_DEBUG == 1) - printf("\nQCAPS\n"); -#endif /* (TF_RM_MSG_DEBUG == 1) */ for (i = 0; i < size; i++) { query[i].type = tfp_le_to_cpu_32(data[i].type); query[i].min = tfp_le_to_cpu_16(data[i].min); query[i].max = tfp_le_to_cpu_16(data[i].max); - -#if (TF_RM_MSG_DEBUG == 1) - printf("type: %d(0x%x) %d %d\n", - query[i].type, - query[i].type, - query[i].min, - query[i].max); -#endif /* (TF_RM_MSG_DEBUG == 1) */ - } *resv_strategy = resp.flags & @@ -476,26 +457,12 @@ tf_msg_session_resc_alloc(struct tf *tfp, goto cleanup; } -#if (TF_RM_MSG_DEBUG == 1) - printf("\nRESV\n"); - printf("size: %d\n", tfp_le_to_cpu_32(resp.size)); -#endif /* (TF_RM_MSG_DEBUG == 1) */ - /* Post process the response */ resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr; for (i = 0; i < size; i++) { resv[i].type = tfp_le_to_cpu_32(resv_data[i].type); resv[i].start = tfp_le_to_cpu_16(resv_data[i].start); resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride); - -#if (TF_RM_MSG_DEBUG == 1) - printf("%d type: %d(0x%x) %d %d\n", - i, - resv[i].type, - resv[i].type, - resv[i].start, - resv[i].stride); -#endif /* (TF_RM_MSG_DEBUG == 1) */ } cleanup: diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c index 887a3dccf8..f93a6d9018 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.c +++ b/drivers/net/bnxt/tf_core/tf_rm.c @@ -6,6 +6,7 @@ #include #include +#include #include @@ -596,13 +597,6 @@ tf_rm_create_db(struct tf *tfp, rm_db->type = parms->type; *parms->rm_db = (void *)rm_db; -#if (TF_RM_DEBUG == 1) - printf("%s: type:%d num_entries:%d\n", - tf_dir_2_str(parms->dir), - parms->type, - i); -#endif /* (TF_RM_DEBUG == 1) */ - tfp_free((void *)req); tfp_free((void *)resv); diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tcam.c b/drivers/net/bnxt/tf_core/tf_shadow_tcam.c index 38b1e7687b..523261f189 100644 --- a/drivers/net/bnxt/tf_core/tf_shadow_tcam.c +++ b/drivers/net/bnxt/tf_core/tf_shadow_tcam.c @@ -6,6 +6,7 @@ #include "tf_common.h" #include "tf_util.h" #include "tfp.h" +#include "tf_tcam.h" #include "tf_shadow_tcam.h" #include "tf_hash.h" @@ -634,8 +635,7 @@ tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms) * requested allocation and return the info */ if (sparms->alloc) - ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt = - ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt + 1; + ctxt->shadow_ctxt.sh_res_tbl[shtbl_key].refcnt++; sparms->hit = 1; sparms->search_status = HIT;