From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2454DA00BE; Fri, 12 Jun 2020 15:39:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ACA291BFA3; Fri, 12 Jun 2020 15:34:22 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id D1D7B1BF88 for ; Fri, 12 Jun 2020 15:34:19 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 9D9761BD7AC; Fri, 12 Jun 2020 06:34:18 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 9D9761BD7AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591968859; bh=TNWJRKej9CGxdA0yISPTVvisugIzIIf6sjQUv9z/UOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m+aCD2p9cZg9Dkn70HVi2iQsB0h1uV1ZQF2mm7HqnOPjbWV265+KuMuUW8O6jXq5R 6xIkVFY3RDWjvnrH9b1REX3r/1tZaX18ehpEKOLcrYTz2qz5kazge17Z4N6s0QEIDN tOHvokEzA97M4OHAGkbDtKdF+KzlMMLQYrc4aDD0= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:58:55 +0530 Message-Id: <20200612132934.16488-12-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200612132934.16488-1-somnath.kotur@broadcom.com> References: <20200612132934.16488-1-somnath.kotur@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 11/50] net/bnxt: add multi device support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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: Michael Wildt Introduce new modules for Device, Resource Manager, Identifier, Table Types, and TCAM. Signed-off-by: Michael Wildt Reviewed-by: Randy Schacher Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/meson.build | 8 + drivers/net/bnxt/tf_core/Makefile | 9 + drivers/net/bnxt/tf_core/cfa_resource_types.h | 266 +++++++++++++++++++ drivers/net/bnxt/tf_core/tf_core.c | 2 + drivers/net/bnxt/tf_core/tf_core.h | 56 ++-- drivers/net/bnxt/tf_core/tf_device.c | 50 ++++ drivers/net/bnxt/tf_core/tf_device.h | 331 +++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_device_p4.c | 24 ++ drivers/net/bnxt/tf_core/tf_device_p4.h | 64 +++++ drivers/net/bnxt/tf_core/tf_identifier.c | 47 ++++ drivers/net/bnxt/tf_core/tf_identifier.h | 140 ++++++++++ drivers/net/bnxt/tf_core/tf_rm.c | 54 +--- drivers/net/bnxt/tf_core/tf_rm.h | 18 -- drivers/net/bnxt/tf_core/tf_rm_new.c | 102 +++++++ drivers/net/bnxt/tf_core/tf_rm_new.h | 368 ++++++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_session.c | 31 +++ drivers/net/bnxt/tf_core/tf_session.h | 54 ++++ drivers/net/bnxt/tf_core/tf_shadow_tbl.c | 63 +++++ drivers/net/bnxt/tf_core/tf_shadow_tbl.h | 240 +++++++++++++++++ drivers/net/bnxt/tf_core/tf_shadow_tcam.c | 63 +++++ drivers/net/bnxt/tf_core/tf_shadow_tcam.h | 239 +++++++++++++++++ drivers/net/bnxt/tf_core/tf_tbl.c | 1 + drivers/net/bnxt/tf_core/tf_tbl_type.c | 78 ++++++ drivers/net/bnxt/tf_core/tf_tbl_type.h | 309 +++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_tcam.c | 78 ++++++ drivers/net/bnxt/tf_core/tf_tcam.h | 314 ++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_util.c | 145 ++++++++++ drivers/net/bnxt/tf_core/tf_util.h | 41 +++ 28 files changed, 3101 insertions(+), 94 deletions(-) create mode 100644 drivers/net/bnxt/tf_core/cfa_resource_types.h create mode 100644 drivers/net/bnxt/tf_core/tf_device.c create mode 100644 drivers/net/bnxt/tf_core/tf_device.h create mode 100644 drivers/net/bnxt/tf_core/tf_device_p4.c create mode 100644 drivers/net/bnxt/tf_core/tf_device_p4.h create mode 100644 drivers/net/bnxt/tf_core/tf_identifier.c create mode 100644 drivers/net/bnxt/tf_core/tf_identifier.h create mode 100644 drivers/net/bnxt/tf_core/tf_rm_new.c create mode 100644 drivers/net/bnxt/tf_core/tf_rm_new.h create mode 100644 drivers/net/bnxt/tf_core/tf_session.c create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.c create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tbl.h create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tcam.c create mode 100644 drivers/net/bnxt/tf_core/tf_shadow_tcam.h create mode 100644 drivers/net/bnxt/tf_core/tf_tbl_type.c create mode 100644 drivers/net/bnxt/tf_core/tf_tbl_type.h create mode 100644 drivers/net/bnxt/tf_core/tf_tcam.c create mode 100644 drivers/net/bnxt/tf_core/tf_tcam.h create mode 100644 drivers/net/bnxt/tf_core/tf_util.c create mode 100644 drivers/net/bnxt/tf_core/tf_util.h diff --git a/drivers/net/bnxt/meson.build b/drivers/net/bnxt/meson.build index 5c7859c..a50cb26 100644 --- a/drivers/net/bnxt/meson.build +++ b/drivers/net/bnxt/meson.build @@ -32,6 +32,14 @@ sources = files('bnxt_cpr.c', 'tf_core/tf_rm.c', 'tf_core/tf_tbl.c', 'tf_core/tfp.c', + 'tf_core/tf_device_p4.c', + 'tf_core/tf_identifier.c', + 'tf_core/tf_shadow_tbl.c', + 'tf_core/tf_shadow_tcam.c', + 'tf_core/tf_tbl_type.c', + 'tf_core/tf_tcam.c', + 'tf_core/tf_util.c', + 'tf_core/tf_rm_new.c', 'tf_ulp/bnxt_ulp.c', 'tf_ulp/ulp_mark_mgr.c', diff --git a/drivers/net/bnxt/tf_core/Makefile b/drivers/net/bnxt/tf_core/Makefile index 379da30..71df75b 100644 --- a/drivers/net/bnxt/tf_core/Makefile +++ b/drivers/net/bnxt/tf_core/Makefile @@ -14,4 +14,13 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tfp.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_msg.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_em.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_device_p4.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_identifier.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tbl.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_shadow_tcam.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl_type.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tcam.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_util.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_rm_new.c diff --git a/drivers/net/bnxt/tf_core/cfa_resource_types.h b/drivers/net/bnxt/tf_core/cfa_resource_types.h new file mode 100644 index 0000000..c0c1e75 --- /dev/null +++ b/drivers/net/bnxt/tf_core/cfa_resource_types.h @@ -0,0 +1,266 @@ +/* + * Copyright(c) 2001-2020, Broadcom. All rights reserved. The + * term Broadcom refers to Broadcom Inc. and/or its subsidiaries. + * Proprietary and Confidential Information. + * + * This source file is the property of Broadcom Corporation, and + * may not be copied or distributed in any isomorphic form without + * the prior written consent of Broadcom Corporation. + * + * DO NOT MODIFY!!! This file is automatically generated. + */ + +#ifndef _CFA_RESOURCE_TYPES_H_ +#define _CFA_RESOURCE_TYPES_H_ + +/* L2 Context TCAM */ +#define CFA_RESOURCE_TYPE_P59_L2_CTXT_TCAM 0x0UL +/* Profile Func */ +#define CFA_RESOURCE_TYPE_P59_PROF_FUNC 0x1UL +/* Profile TCAM */ +#define CFA_RESOURCE_TYPE_P59_PROF_TCAM 0x2UL +/* Exact Match Profile Id */ +#define CFA_RESOURCE_TYPE_P59_EM_PROF_ID 0x3UL +/* Wildcard TCAM Profile Id */ +#define CFA_RESOURCE_TYPE_P59_WC_TCAM_PROF_ID 0x4UL +/* Wildcard TCAM */ +#define CFA_RESOURCE_TYPE_P59_WC_TCAM 0x5UL +/* Meter Profile */ +#define CFA_RESOURCE_TYPE_P59_METER_PROF 0x6UL +/* Meter */ +#define CFA_RESOURCE_TYPE_P59_METER 0x7UL +/* Meter */ +#define CFA_RESOURCE_TYPE_P59_MIRROR 0x8UL +/* Source Properties TCAM */ +#define CFA_RESOURCE_TYPE_P59_SP_TCAM 0x9UL +/* Exact Match Flexible Key Builder */ +#define CFA_RESOURCE_TYPE_P59_EM_FKB 0xaUL +/* Wildcard Flexible Key Builder */ +#define CFA_RESOURCE_TYPE_P59_WC_FKB 0xbUL +/* Table Scope */ +#define CFA_RESOURCE_TYPE_P59_TBL_SCOPE 0xcUL +/* L2 Func */ +#define CFA_RESOURCE_TYPE_P59_L2_FUNC 0xdUL +/* EPOCH */ +#define CFA_RESOURCE_TYPE_P59_EPOCH 0xeUL +/* Metadata */ +#define CFA_RESOURCE_TYPE_P59_METADATA 0xfUL +/* Connection Tracking Rule TCAM */ +#define CFA_RESOURCE_TYPE_P59_CT_RULE_TCAM 0x10UL +/* Range Profile */ +#define CFA_RESOURCE_TYPE_P59_RANGE_PROF 0x11UL +/* Range */ +#define CFA_RESOURCE_TYPE_P59_RANGE 0x12UL +/* Link Aggrigation */ +#define CFA_RESOURCE_TYPE_P59_LAG 0x13UL +/* VEB TCAM */ +#define CFA_RESOURCE_TYPE_P59_VEB_TCAM 0x14UL +#define CFA_RESOURCE_TYPE_P59_LAST CFA_RESOURCE_TYPE_P59_VEB_TCAM + + +/* SRAM Multicast Group */ +#define CFA_RESOURCE_TYPE_P58_SRAM_MCG 0x0UL +/* SRAM Encap 8 byte record */ +#define CFA_RESOURCE_TYPE_P58_SRAM_ENCAP_8B 0x1UL +/* SRAM Encap 16 byte record */ +#define CFA_RESOURCE_TYPE_P58_SRAM_ENCAP_16B 0x2UL +/* SRAM Encap 64 byte record */ +#define CFA_RESOURCE_TYPE_P58_SRAM_ENCAP_64B 0x3UL +/* SRAM Source Property MAC */ +#define CFA_RESOURCE_TYPE_P58_SRAM_SP_MAC 0x4UL +/* SRAM Source Property MAC and IPv4 */ +#define CFA_RESOURCE_TYPE_P58_SRAM_SP_MAC_IPV4 0x5UL +/* SRAM Source Property MAC and IPv6 */ +#define CFA_RESOURCE_TYPE_P58_SRAM_SP_MAC_IPV6 0x6UL +/* SRAM Network Address Translation Source Port */ +#define CFA_RESOURCE_TYPE_P58_SRAM_NAT_SPORT 0x7UL +/* SRAM Network Address Translation Destination Port */ +#define CFA_RESOURCE_TYPE_P58_SRAM_NAT_DPORT 0x8UL +/* SRAM Network Address Translation Source IPv4 address */ +#define CFA_RESOURCE_TYPE_P58_SRAM_NAT_S_IPV4 0x9UL +/* SRAM Network Address Translation Destination IPv4 address */ +#define CFA_RESOURCE_TYPE_P58_SRAM_NAT_D_IPV4 0xaUL +/* SRAM Network Address Translation Source IPv4 address */ +#define CFA_RESOURCE_TYPE_P58_SRAM_NAT_S_IPV6 0xbUL +/* SRAM Network Address Translation Destination IPv4 address */ +#define CFA_RESOURCE_TYPE_P58_SRAM_NAT_D_IPV6 0xcUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P58_SRAM_METER 0xdUL +/* Flow State */ +#define CFA_RESOURCE_TYPE_P58_SRAM_FLOW_STATE 0xeUL +/* Full Action Records */ +#define CFA_RESOURCE_TYPE_P58_SRAM_FULL_ACTION 0xfUL +/* Action Record Format 0 */ +#define CFA_RESOURCE_TYPE_P58_SRAM_FORMAT_0_ACTION 0x10UL +/* Action Record Format 2 */ +#define CFA_RESOURCE_TYPE_P58_SRAM_FORMAT_2_ACTION 0x11UL +/* Action Record Format 3 */ +#define CFA_RESOURCE_TYPE_P58_SRAM_FORMAT_3_ACTION 0x12UL +/* Action Record Format 4 */ +#define CFA_RESOURCE_TYPE_P58_SRAM_FORMAT_4_ACTION 0x13UL +/* L2 Context TCAM */ +#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM 0x14UL +/* Profile Func */ +#define CFA_RESOURCE_TYPE_P58_PROF_FUNC 0x15UL +/* Profile TCAM */ +#define CFA_RESOURCE_TYPE_P58_PROF_TCAM 0x16UL +/* Exact Match Profile Id */ +#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID 0x17UL +/* Wildcard Profile Id */ +#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID 0x18UL +/* Wildcard TCAM */ +#define CFA_RESOURCE_TYPE_P58_WC_TCAM 0x19UL +/* Meter profile */ +#define CFA_RESOURCE_TYPE_P58_METER_PROF 0x1aUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P58_METER 0x1bUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P58_MIRROR 0x1cUL +/* Source Property TCAM */ +#define CFA_RESOURCE_TYPE_P58_SP_TCAM 0x1dUL +/* Exact Match Flexible Key Builder */ +#define CFA_RESOURCE_TYPE_P58_EM_FKB 0x1eUL +/* Wildcard Flexible Key Builder */ +#define CFA_RESOURCE_TYPE_P58_WC_FKB 0x1fUL +/* VEB TCAM */ +#define CFA_RESOURCE_TYPE_P58_VEB_TCAM 0x20UL +#define CFA_RESOURCE_TYPE_P58_LAST CFA_RESOURCE_TYPE_P58_VEB_TCAM + + +/* SRAM Multicast Group */ +#define CFA_RESOURCE_TYPE_P45_SRAM_MCG 0x0UL +/* SRAM Encap 8 byte record */ +#define CFA_RESOURCE_TYPE_P45_SRAM_ENCAP_8B 0x1UL +/* SRAM Encap 16 byte record */ +#define CFA_RESOURCE_TYPE_P45_SRAM_ENCAP_16B 0x2UL +/* SRAM Encap 64 byte record */ +#define CFA_RESOURCE_TYPE_P45_SRAM_ENCAP_64B 0x3UL +/* SRAM Source Property MAC */ +#define CFA_RESOURCE_TYPE_P45_SRAM_SP_MAC 0x4UL +/* SRAM Source Property MAC and IPv4 */ +#define CFA_RESOURCE_TYPE_P45_SRAM_SP_MAC_IPV4 0x5UL +/* SRAM Source Property MAC and IPv6 */ +#define CFA_RESOURCE_TYPE_P45_SRAM_SP_MAC_IPV6 0x6UL +/* SRAM 64B Counters */ +#define CFA_RESOURCE_TYPE_P45_SRAM_COUNTER_64B 0x7UL +/* SRAM Network Address Translation Source Port */ +#define CFA_RESOURCE_TYPE_P45_SRAM_NAT_SPORT 0x8UL +/* SRAM Network Address Translation Destination Port */ +#define CFA_RESOURCE_TYPE_P45_SRAM_NAT_DPORT 0x9UL +/* SRAM Network Address Translation Source IPv4 address */ +#define CFA_RESOURCE_TYPE_P45_SRAM_NAT_S_IPV4 0xaUL +/* SRAM Network Address Translation Destination IPv4 address */ +#define CFA_RESOURCE_TYPE_P45_SRAM_NAT_D_IPV4 0xbUL +/* SRAM Network Address Translation Source IPv6 address */ +#define CFA_RESOURCE_TYPE_P45_SRAM_NAT_S_IPV6 0xcUL +/* SRAM Network Address Translation Destination IPv6 address */ +#define CFA_RESOURCE_TYPE_P45_SRAM_NAT_D_IPV6 0xdUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P45_SRAM_METER 0xeUL +/* Flow State */ +#define CFA_RESOURCE_TYPE_P45_SRAM_FLOW_STATE 0xfUL +/* Full Action Records */ +#define CFA_RESOURCE_TYPE_P45_SRAM_FULL_ACTION 0x10UL +/* Action Record Format 0 */ +#define CFA_RESOURCE_TYPE_P45_SRAM_FORMAT_0_ACTION 0x11UL +/* Action Record Format 2 */ +#define CFA_RESOURCE_TYPE_P45_SRAM_FORMAT_2_ACTION 0x12UL +/* Action Record Format 3 */ +#define CFA_RESOURCE_TYPE_P45_SRAM_FORMAT_3_ACTION 0x13UL +/* Action Record Format 4 */ +#define CFA_RESOURCE_TYPE_P45_SRAM_FORMAT_4_ACTION 0x14UL +/* L2 Context TCAM */ +#define CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM 0x15UL +/* Profile Func */ +#define CFA_RESOURCE_TYPE_P45_PROF_FUNC 0x16UL +/* Profile TCAM */ +#define CFA_RESOURCE_TYPE_P45_PROF_TCAM 0x17UL +/* Exact Match Profile Id */ +#define CFA_RESOURCE_TYPE_P45_EM_PROF_ID 0x18UL +/* Exact Match Record */ +#define CFA_RESOURCE_TYPE_P45_EM_REC 0x19UL +/* Wildcard Profile Id */ +#define CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID 0x1aUL +/* Wildcard TCAM */ +#define CFA_RESOURCE_TYPE_P45_WC_TCAM 0x1bUL +/* Meter profile */ +#define CFA_RESOURCE_TYPE_P45_METER_PROF 0x1cUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P45_METER 0x1dUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P45_MIRROR 0x1eUL +/* Source Property TCAM */ +#define CFA_RESOURCE_TYPE_P45_SP_TCAM 0x1fUL +/* VEB TCAM */ +#define CFA_RESOURCE_TYPE_P45_VEB_TCAM 0x20UL +#define CFA_RESOURCE_TYPE_P45_LAST CFA_RESOURCE_TYPE_P45_VEB_TCAM + + +/* SRAM Multicast Group */ +#define CFA_RESOURCE_TYPE_P4_SRAM_MCG 0x0UL +/* SRAM Encap 8 byte record */ +#define CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_8B 0x1UL +/* SRAM Encap 16 byte record */ +#define CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_16B 0x2UL +/* SRAM Encap 64 byte record */ +#define CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_64B 0x3UL +/* SRAM Source Property MAC */ +#define CFA_RESOURCE_TYPE_P4_SRAM_SP_MAC 0x4UL +/* SRAM Source Property MAC and IPv4 */ +#define CFA_RESOURCE_TYPE_P4_SRAM_SP_MAC_IPV4 0x5UL +/* SRAM Source Property MAC and IPv6 */ +#define CFA_RESOURCE_TYPE_P4_SRAM_SP_MAC_IPV6 0x6UL +/* SRAM 64B Counters */ +#define CFA_RESOURCE_TYPE_P4_SRAM_COUNTER_64B 0x7UL +/* SRAM Network Address Translation Source Port */ +#define CFA_RESOURCE_TYPE_P4_SRAM_NAT_SPORT 0x8UL +/* SRAM Network Address Translation Destination Port */ +#define CFA_RESOURCE_TYPE_P4_SRAM_NAT_DPORT 0x9UL +/* SRAM Network Address Translation Source IPv4 address */ +#define CFA_RESOURCE_TYPE_P4_SRAM_NAT_S_IPV4 0xaUL +/* SRAM Network Address Translation Destination IPv4 address */ +#define CFA_RESOURCE_TYPE_P4_SRAM_NAT_D_IPV4 0xbUL +/* SRAM Network Address Translation Source IPv6 address */ +#define CFA_RESOURCE_TYPE_P4_SRAM_NAT_S_IPV6 0xcUL +/* SRAM Network Address Translation Destination IPv6 address */ +#define CFA_RESOURCE_TYPE_P4_SRAM_NAT_D_IPV6 0xdUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P4_SRAM_METER 0xeUL +/* Flow State */ +#define CFA_RESOURCE_TYPE_P4_SRAM_FLOW_STATE 0xfUL +/* Full Action Records */ +#define CFA_RESOURCE_TYPE_P4_SRAM_FULL_ACTION 0x10UL +/* Action Record Format 0 */ +#define CFA_RESOURCE_TYPE_P4_SRAM_FORMAT_0_ACTION 0x11UL +/* Action Record Format 2 */ +#define CFA_RESOURCE_TYPE_P4_SRAM_FORMAT_2_ACTION 0x12UL +/* Action Record Format 3 */ +#define CFA_RESOURCE_TYPE_P4_SRAM_FORMAT_3_ACTION 0x13UL +/* Action Record Format 4 */ +#define CFA_RESOURCE_TYPE_P4_SRAM_FORMAT_4_ACTION 0x14UL +/* L2 Context TCAM */ +#define CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM 0x15UL +/* Profile Func */ +#define CFA_RESOURCE_TYPE_P4_PROF_FUNC 0x16UL +/* Profile TCAM */ +#define CFA_RESOURCE_TYPE_P4_PROF_TCAM 0x17UL +/* Exact Match Profile Id */ +#define CFA_RESOURCE_TYPE_P4_EM_PROF_ID 0x18UL +/* Exact Match Record */ +#define CFA_RESOURCE_TYPE_P4_EM_REC 0x19UL +/* Wildcard Profile Id */ +#define CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID 0x1aUL +/* Wildcard TCAM */ +#define CFA_RESOURCE_TYPE_P4_WC_TCAM 0x1bUL +/* Meter profile */ +#define CFA_RESOURCE_TYPE_P4_METER_PROF 0x1cUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P4_METER 0x1dUL +/* Meter */ +#define CFA_RESOURCE_TYPE_P4_MIRROR 0x1eUL +/* Source Property TCAM */ +#define CFA_RESOURCE_TYPE_P4_SP_TCAM 0x1fUL +#define CFA_RESOURCE_TYPE_P4_LAST CFA_RESOURCE_TYPE_P4_SP_TCAM + + +#endif /* _CFA_RESOURCE_TYPES_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index ba54df6..58924b1 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -6,6 +6,7 @@ #include #include "tf_core.h" +#include "tf_util.h" #include "tf_session.h" #include "tf_tbl.h" #include "tf_em.h" @@ -229,6 +230,7 @@ tf_open_session(struct tf *tfp, /* Initialize Session */ session->device_type = parms->device_type; + session->dev = NULL; tf_rm_init(tfp); /* Construct the Session ID */ diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 81ff760..becc50c 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -371,6 +371,35 @@ struct tf { struct tf_session_info *session; }; +/** + * tf_session_resources parameter definition. + */ +struct tf_session_resources { + /** [in] Requested Identifier Resources + * + * The number of identifier resources requested for the session. + * The index used is tf_identifier_type. + */ + uint16_t identifer_cnt[TF_DIR_MAX][TF_IDENT_TYPE_MAX]; + /** [in] Requested Index Table resource counts + * + * The number of index table resources requested for the session. + * The index used is tf_tbl_type. + */ + uint16_t tbl_cnt[TF_TBL_TYPE_MAX][TF_DIR_MAX]; + /** [in] Requested TCAM Table resource counts + * + * The number of TCAM table resources requested for the session. + * The index used is tf_tcam_tbl_type. + */ + uint16_t tcam_tbl_cnt[TF_TCAM_TBL_TYPE_MAX][TF_DIR_MAX]; + /** [in] Requested EM resource counts + * + * The number of internal EM table resources requested for the session + * The index used is tf_em_tbl_type. + */ + uint16_t em_tbl_cnt[TF_EM_TBL_TYPE_MAX][TF_DIR_MAX]; +}; /** * tf_open_session parameters definition. @@ -414,33 +443,14 @@ struct tf_open_session_parms { union tf_session_id session_id; /** [in] device type * - * Device type is passed, one of Wh+, Brd2, Brd3, Brd4 + * Device type is passed, one of Wh+, SR, Thor, SR2 */ enum tf_device_type device_type; - /** [in] Requested Identifier Resources - * - * The number of identifier resources requested for the session. - * The index used is tf_identifier_type. - */ - uint16_t identifer_cnt[TF_IDENT_TYPE_MAX]; - /** [in] Requested Index Table resource counts - * - * The number of index table resources requested for the session. - * The index used is tf_tbl_type. - */ - uint16_t tbl_cnt[TF_TBL_TYPE_MAX]; - /** [in] Requested TCAM Table resource counts - * - * The number of TCAM table resources requested for the session. - * The index used is tf_tcam_tbl_type. - */ - uint16_t tcam_tbl_cnt[TF_TCAM_TBL_TYPE_MAX]; - /** [in] Requested EM resource counts + /** [in] resources * - * The number of internal EM table resources requested for the session - * The index used is tf_em_tbl_type. + * Resource allocation */ - uint16_t em_tbl_cnt[TF_EM_TBL_TYPE_MAX]; + struct tf_session_resources resources; }; /** diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c new file mode 100644 index 0000000..3b36831 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include "tf_device.h" +#include "tf_device_p4.h" +#include "tfp.h" +#include "bnxt.h" + +struct tf; + +/** + * Device specific bind function + */ +static int +dev_bind_p4(struct tf *tfp __rte_unused, + struct tf_session_resources *resources __rte_unused, + struct tf_dev_info *dev_info) +{ + /* Initialize the modules */ + + dev_info->ops = &tf_dev_ops_p4; + return 0; +} + +int +dev_bind(struct tf *tfp __rte_unused, + enum tf_device_type type, + struct tf_session_resources *resources, + struct tf_dev_info *dev_info) +{ + switch (type) { + case TF_DEVICE_TYPE_WH: + return dev_bind_p4(tfp, + resources, + dev_info); + default: + TFP_DRV_LOG(ERR, + "Device type not supported\n"); + return -ENOTSUP; + } +} + +int +dev_unbind(struct tf *tfp __rte_unused, + struct tf_dev_info *dev_handle __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h new file mode 100644 index 0000000..8b63ff1 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -0,0 +1,331 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef _TF_DEVICE_H_ +#define _TF_DEVICE_H_ + +#include "tf_core.h" +#include "tf_identifier.h" +#include "tf_tbl_type.h" +#include "tf_tcam.h" + +struct tf; +struct tf_session; + +/** + * The Device module provides a general device template. A supported + * device type should implement one or more of the listed function + * pointers according to its capabilities. + * + * If a device function pointer is NULL the device capability is not + * supported. + */ + +/** + * TF device information + */ +struct tf_dev_info { + const struct tf_dev_ops *ops; +}; + +/** + * @page device Device + * + * @ref tf_dev_bind + * + * @ref tf_dev_unbind + */ + +/** + * Device bind handles the initialization of the specified device + * type. + * + * [in] tfp + * Pointer to TF handle + * + * [in] type + * Device type + * + * [in] resources + * Pointer to resource allocation information + * + * [out] dev_handle + * Device handle + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int dev_bind(struct tf *tfp, + enum tf_device_type type, + struct tf_session_resources *resources, + struct tf_dev_info *dev_handle); + +/** + * Device release handles cleanup of the device specific information. + * + * [in] tfp + * Pointer to TF handle + * + * [in] dev_handle + * Device handle + */ +int dev_unbind(struct tf *tfp, + struct tf_dev_info *dev_handle); + +/** + * Truflow device specific function hooks structure + * + * The following device hooks can be defined; unless noted otherwise, + * they are optional and can be filled with a null pointer. The + * purpose of these hooks is to support Truflow device operations for + * different device variants. + */ +struct tf_dev_ops { + /** + * Allocation of an identifier element. + * + * This API allocates the specified identifier element from a + * device specific identifier DB. The allocated element is + * returned. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to identifier allocation parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_alloc_ident)(struct tf *tfp, + struct tf_ident_alloc_parms *parms); + + /** + * Free of an identifier element. + * + * This API free's a previous allocated identifier element from a + * device specific identifier DB. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to identifier free parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_free_ident)(struct tf *tfp, + struct tf_ident_free_parms *parms); + + /** + * Allocation of a table type element. + * + * This API allocates the specified table type element from a + * device specific table type DB. The allocated element is + * returned. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table type allocation parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_alloc_tbl_type)(struct tf *tfp, + struct tf_tbl_type_alloc_parms *parms); + + /** + * Free of a table type element. + * + * This API free's a previous allocated table type element from a + * device specific table type DB. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table type free parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_free_tbl_type)(struct tf *tfp, + struct tf_tbl_type_free_parms *parms); + + /** + * Searches for the specified table type element in a shadow DB. + * + * This API searches for the specified table type element in a + * device specific shadow DB. If the element is found the + * reference count for the element is updated. If the element + * is not found a new element is allocated from the table type + * DB and then inserted into the shadow DB. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table type allocation and search parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_alloc_search_tbl_type) + (struct tf *tfp, + struct tf_tbl_type_alloc_search_parms *parms); + + /** + * Sets the specified table type element. + * + * This API sets the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table type set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_set_tbl_type)(struct tf *tfp, + struct tf_tbl_type_set_parms *parms); + + /** + * Retrieves the specified table type element. + * + * This API retrieves the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table type get parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_get_tbl_type)(struct tf *tfp, + struct tf_tbl_type_get_parms *parms); + + /** + * Allocation of a tcam element. + * + * This API allocates the specified tcam element from a device + * specific tcam DB. The allocated element is returned. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to tcam allocation parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_alloc_tcam)(struct tf *tfp, + struct tf_tcam_alloc_parms *parms); + + /** + * Free of a tcam element. + * + * This API free's a previous allocated tcam element from a + * device specific tcam DB. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to tcam free parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_free_tcam)(struct tf *tfp, + struct tf_tcam_free_parms *parms); + + /** + * Searches for the specified tcam element in a shadow DB. + * + * This API searches for the specified tcam element in a + * device specific shadow DB. If the element is found the + * reference count for the element is updated. If the element + * is not found a new element is allocated from the tcam DB + * and then inserted into the shadow DB. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to tcam allocation and search parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_alloc_search_tcam) + (struct tf *tfp, + struct tf_tcam_alloc_search_parms *parms); + + /** + * Sets the specified tcam element. + * + * This API sets the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to tcam set parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_set_tcam)(struct tf *tfp, + struct tf_tcam_set_parms *parms); + + /** + * Retrieves the specified tcam element. + * + * This API retrieves the specified element data by invoking the + * firmware. + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to tcam get parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_get_tcam)(struct tf *tfp, + struct tf_tcam_get_parms *parms); +}; + +/** + * Supported device operation structures + */ +extern const struct tf_dev_ops tf_dev_ops_p4; + +#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 new file mode 100644 index 0000000..c3c4d1e --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include "tf_device.h" +#include "tf_identifier.h" +#include "tf_tbl_type.h" +#include "tf_tcam.h" + +const struct tf_dev_ops tf_dev_ops_p4 = { + .tf_dev_alloc_ident = tf_ident_alloc, + .tf_dev_free_ident = tf_ident_free, + .tf_dev_alloc_tbl_type = tf_tbl_type_alloc, + .tf_dev_free_tbl_type = tf_tbl_type_free, + .tf_dev_alloc_search_tbl_type = tf_tbl_type_alloc_search, + .tf_dev_set_tbl_type = tf_tbl_type_set, + .tf_dev_get_tbl_type = tf_tbl_type_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 = tf_tcam_get, +}; diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.h b/drivers/net/bnxt/tf_core/tf_device_p4.h new file mode 100644 index 0000000..84d90e3 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_device_p4.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef _TF_DEVICE_P4_H_ +#define _TF_DEVICE_P4_H_ + +#include + +#include "tf_core.h" +#include "tf_rm_new.h" + +struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = { + { TF_RM_ELEM_CFG_PRIVATE, 0 /* CFA_RESOURCE_TYPE_P4_INVALID */ }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_PROF_FUNC }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_PROF_ID }, + { TF_RM_ELEM_CFG_NULL, 0 /* CFA_RESOURCE_TYPE_P4_L2_FUNC */ } +}; + +struct tf_rm_element_cfg tf_tcam_p4[TF_TCAM_TBL_TYPE_MAX] = { + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_PROF_TCAM }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_WC_TCAM }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SP_TCAM }, + { TF_RM_ELEM_CFG_NULL, 0 /* CFA_RESOURCE_TYPE_P4_CT_RULE_TCAM */ }, + { TF_RM_ELEM_CFG_NULL, 0 /* CFA_RESOURCE_TYPE_P4_VEB_TCAM */ } +}; + +struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = { + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_FULL_ACTION }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_MCG }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_8B }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_16B }, + { TF_RM_ELEM_CFG_NULL, 0, /* CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_32B */ }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_ENCAP_64B }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_SP_MAC }, + { TF_RM_ELEM_CFG_NULL, 0 /* CFA_RESOURCE_TYPE_P4_SRAM_SP_SMAC_IPV4 */ }, + { TF_RM_ELEM_CFG_NULL, 0 /* CFA_RESOURCE_TYPE_P4_SRAM_SP_SMAC_IPV6 */ }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_COUNTER_64B }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_NAT_SPORT }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_NAT_DPORT }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_NAT_S_IPV4 }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_NAT_D_IPV4 }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_NAT_S_IPV6 }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_SRAM_NAT_D_IPV6 }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_METER_PROF }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_METER }, + { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_MIRROR }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_UPAR */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_EPOC */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_METADATA */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_CT_STATE */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_RANGE_PROF */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_RANGE_ENTRY */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_LAG */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_VNIC_SVIF */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_EM_FBK */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_WC_FKB */ }, + { TF_RM_ELEM_CFG_NULL, /* CFA_RESOURCE_TYPE_P4_EXT */ } +}; + +#endif /* _TF_DEVICE_P4_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c new file mode 100644 index 0000000..726d0b4 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_identifier.c @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_identifier.h" + +struct tf; + +/** + * Identifier DBs. + */ +/* static void *ident_db[TF_DIR_MAX]; */ + +/** + * Init flag, set on bind and cleared on unbind + */ +/* static uint8_t init; */ + +int +tf_ident_bind(struct tf *tfp __rte_unused, + struct tf_ident_cfg *parms __rte_unused) +{ + return 0; +} + +int +tf_ident_unbind(struct tf *tfp __rte_unused) +{ + return 0; +} + +int +tf_ident_alloc(struct tf *tfp __rte_unused, + struct tf_ident_alloc_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_ident_free(struct tf *tfp __rte_unused, + struct tf_ident_free_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_identifier.h b/drivers/net/bnxt/tf_core/tf_identifier.h new file mode 100644 index 0000000..b77c91b --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_identifier.h @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef _TF_IDENTIFIER_H_ +#define _TF_IDENTIFIER_H_ + +#include "tf_core.h" + +/** + * The Identifier module provides processing of Identifiers. + */ + +struct tf_ident_cfg { + /** + * Number of identifier types in each of the configuration + * arrays + */ + uint16_t num_elements; + + /** + * TCAM configuration array + */ + struct tf_rm_element_cfg *ident_cfg[TF_DIR_MAX]; +}; + +/** + * Identifier allcoation parameter definition + */ +struct tf_ident_alloc_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Identifier type + */ + enum tf_identifier_type ident_type; + /** + * [out] Identifier allocated + */ + uint16_t id; +}; + +/** + * Identifier free parameter definition + */ +struct tf_ident_free_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Identifier type + */ + enum tf_identifier_type ident_type; + /** + * [in] ID to free + */ + uint16_t id; +}; + +/** + * @page ident Identity Management + * + * @ref tf_ident_bind + * + * @ref tf_ident_unbind + * + * @ref tf_ident_alloc + * + * @ref tf_ident_free + */ + +/** + * Initializes the Identifier module with the requested DBs. Must be + * invoked as the first thing before any of the access functions. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_ident_bind(struct tf *tfp, + struct tf_ident_cfg *parms); + +/** + * Cleans up the private DBs and releases all the data. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_ident_unbind(struct tf *tfp); + +/** + * Allocates a single identifier type. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_ident_alloc(struct tf *tfp, + struct tf_ident_alloc_parms *parms); + +/** + * Free's a single identifier type. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_ident_free(struct tf *tfp, + struct tf_ident_free_parms *parms); + +#endif /* _TF_IDENTIFIER_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c index 38b1e71..2264704 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.c +++ b/drivers/net/bnxt/tf_core/tf_rm.c @@ -9,6 +9,7 @@ #include "tf_rm.h" #include "tf_core.h" +#include "tf_util.h" #include "tf_session.h" #include "tf_resources.h" #include "tf_msg.h" @@ -77,59 +78,6 @@ } while (0) const char -*tf_dir_2_str(enum tf_dir dir) -{ - switch (dir) { - case TF_DIR_RX: - return "RX"; - case TF_DIR_TX: - return "TX"; - default: - return "Invalid direction"; - } -} - -const char -*tf_ident_2_str(enum tf_identifier_type id_type) -{ - switch (id_type) { - case TF_IDENT_TYPE_L2_CTXT: - return "l2_ctxt_remap"; - case TF_IDENT_TYPE_PROF_FUNC: - return "prof_func"; - case TF_IDENT_TYPE_WC_PROF: - return "wc_prof"; - case TF_IDENT_TYPE_EM_PROF: - return "em_prof"; - case TF_IDENT_TYPE_L2_FUNC: - return "l2_func"; - default: - return "Invalid identifier"; - } -} - -const char -*tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type) -{ - switch (tcam_type) { - case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM: - return "l2_ctxt_tcam"; - case TF_TCAM_TBL_TYPE_PROF_TCAM: - return "prof_tcam"; - case TF_TCAM_TBL_TYPE_WC_TCAM: - return "wc_tcam"; - case TF_TCAM_TBL_TYPE_VEB_TCAM: - return "veb_tcam"; - case TF_TCAM_TBL_TYPE_SP_TCAM: - return "sp_tcam"; - case TF_TCAM_TBL_TYPE_CT_RULE_TCAM: - return "ct_rule_tcam"; - default: - return "Invalid tcam table type"; - } -} - -const char *tf_hcapi_hw_2_str(enum tf_resource_type_hw hw_type) { switch (hw_type) { diff --git a/drivers/net/bnxt/tf_core/tf_rm.h b/drivers/net/bnxt/tf_core/tf_rm.h index e69d443..1a09f13 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.h +++ b/drivers/net/bnxt/tf_core/tf_rm.h @@ -125,24 +125,6 @@ struct tf_rm_db { }; /** - * Helper function converting direction to text string - */ -const char -*tf_dir_2_str(enum tf_dir dir); - -/** - * Helper function converting identifier to text string - */ -const char -*tf_ident_2_str(enum tf_identifier_type id_type); - -/** - * Helper function converting tcam type to text string - */ -const char -*tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type); - -/** * Helper function used to convert HW HCAPI resource type to a string. */ const char diff --git a/drivers/net/bnxt/tf_core/tf_rm_new.c b/drivers/net/bnxt/tf_core/tf_rm_new.c new file mode 100644 index 0000000..51bb9ba --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_rm_new.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_rm_new.h" + +/** + * Resource query single entry. Used when accessing HCAPI RM on the + * firmware. + */ +struct tf_rm_query_entry { + /** Minimum guaranteed number of elements */ + uint16_t min; + /** Maximum non-guaranteed number of elements */ + uint16_t max; +}; + +/** + * Generic RM Element data type that an RM DB is build upon. + */ +struct tf_rm_element { + /** + * RM Element configuration type. If Private then the + * hcapi_type can be ignored. If Null then the element is not + * valid for the device. + */ + enum tf_rm_elem_cfg_type type; + + /** + * HCAPI RM Type for the element. + */ + uint16_t hcapi_type; + + /** + * HCAPI RM allocated range information for the element. + */ + struct tf_rm_alloc_info alloc; + + /** + * Bit allocator pool for the element. Pool size is controlled + * by the struct tf_session_resources at time of session creation. + * Null indicates that the element is not used for the device. + */ + struct bitalloc *pool; +}; + +/** + * TF RM DB definition + */ +struct tf_rm_db { + /** + * The DB consists of an array of elements + */ + struct tf_rm_element *db; +}; + +int +tf_rm_create_db(struct tf *tfp __rte_unused, + struct tf_rm_create_db_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_rm_free_db(struct tf *tfp __rte_unused, + struct tf_rm_free_db_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_rm_allocate(struct tf_rm_allocate_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_rm_free(struct tf_rm_free_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_rm_new.h b/drivers/net/bnxt/tf_core/tf_rm_new.h new file mode 100644 index 0000000..72dba09 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_rm_new.h @@ -0,0 +1,368 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef TF_RM_H_ +#define TF_RM_H_ + +#include "tf_core.h" +#include "bitalloc.h" + +struct tf; + +/** + * The Resource Manager (RM) module provides basic DB handling for + * internal resources. These resources exists within the actual device + * and are controlled by the HCAPI Resource Manager running on the + * firmware. + * + * The RM DBs are all intended to be indexed using TF types there for + * a lookup requires no additional conversion. The DB configuration + * specifies the TF Type to HCAPI Type mapping and it becomes the + * responsibility of the DB initialization to handle this static + * mapping. + * + * Accessor functions are providing access to the DB, thus hiding the + * implementation. + * + * The RM DB will work on its initial allocated sizes so the + * capability of dynamically growing a particular resource is not + * possible. If this capability later becomes a requirement then the + * MAX pool size of the Chip Å“needs to be added to the tf_rm_elem_info + * structure and several new APIs would need to be added to allow for + * growth of a single TF resource type. + */ + +/** + * Resource reservation single entry result. Used when accessing HCAPI + * RM on the firmware. + */ +struct tf_rm_entry { + /** Starting index of the allocated resource */ + uint16_t start; + /** Number of allocated elements */ + uint16_t stride; +}; + +/** + * RM Element configuration enumeration. Used by the Device to + * indicate how the RM elements the DB consists off, are to be + * configured at time of DB creation. The TF may present types to the + * ULP layer that is not controlled by HCAPI within the Firmware. + */ +enum tf_rm_elem_cfg_type { + TF_RM_ELEM_CFG_NULL, /**< No configuration */ + TF_RM_ELEM_CFG_HCAPI, /**< HCAPI 'controlled' */ + TF_RM_ELEM_CFG_PRIVATE, /**< Private thus not HCAPI 'controlled' */ + TF_RM_TYPE_MAX +}; + +/** + * RM Element configuration structure, used by the Device to configure + * how an individual TF type is configured in regard to the HCAPI RM + * of same type. + */ +struct tf_rm_element_cfg { + /** + * RM Element config controls how the DB for that element is + * processed. + */ + enum tf_rm_elem_cfg_type cfg; + + /* If a HCAPI to TF type conversion is required then TF type + * can be added here. + */ + + /** + * HCAPI RM Type for the element. Used for TF to HCAPI type + * conversion. + */ + uint16_t hcapi_type; +}; + +/** + * Allocation information for a single element. + */ +struct tf_rm_alloc_info { + /** + * HCAPI RM allocated range information. + * + * NOTE: + * In case of dynamic allocation support this would have + * to be changed to linked list of tf_rm_entry instead. + */ + struct tf_rm_entry entry; +}; + +/** + * Create RM DB parameters + */ +struct tf_rm_create_db_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Number of elements in the parameter structure + */ + uint16_t num_elements; + /** + * [in] Parameter structure + */ + struct tf_rm_element_cfg *parms; + /** + * [out] RM DB Handle + */ + void *tf_rm_db; +}; + +/** + * Free RM DB parameters + */ +struct tf_rm_free_db_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] RM DB Handle + */ + void *tf_rm_db; +}; + +/** + * Allocate RM parameters for a single element + */ +struct tf_rm_allocate_parms { + /** + * [in] RM DB Handle + */ + void *tf_rm_db; + /** + * [in] DB Index, indicates which DB entry to perform the + * action on. + */ + uint16_t db_index; + /** + * [in] Pointer to the allocated index in normalized + * form. Normalized means the index has been adjusted, + * i.e. Full Action Record offsets. + */ + uint32_t *index; +}; + +/** + * Free RM parameters for a single element + */ +struct tf_rm_free_parms { + /** + * [in] RM DB Handle + */ + void *tf_rm_db; + /** + * [in] DB Index, indicates which DB entry to perform the + * action on. + */ + uint16_t db_index; + /** + * [in] Index to free + */ + uint32_t index; +}; + +/** + * Is Allocated parameters for a single element + */ +struct tf_rm_is_allocated_parms { + /** + * [in] RM DB Handle + */ + void *tf_rm_db; + /** + * [in] DB Index, indicates which DB entry to perform the + * action on. + */ + uint16_t db_index; + /** + * [in] Index to free + */ + uint32_t index; + /** + * [in] Pointer to flag that indicates the state of the query + */ + uint8_t *allocated; +}; + +/** + * Get Allocation information for a single element + */ +struct tf_rm_get_alloc_info_parms { + /** + * [in] RM DB Handle + */ + void *tf_rm_db; + /** + * [in] DB Index, indicates which DB entry to perform the + * action on. + */ + uint16_t db_index; + /** + * [out] Pointer to the requested allocation information for + * the specified db_index + */ + struct tf_rm_alloc_info *info; +}; + +/** + * Get HCAPI type parameters for a single element + */ +struct tf_rm_get_hcapi_parms { + /** + * [in] RM DB Handle + */ + void *tf_rm_db; + /** + * [in] DB Index, indicates which DB entry to perform the + * action on. + */ + uint16_t db_index; + /** + * [out] Pointer to the hcapi type for the specified db_index + */ + uint16_t *hcapi_type; +}; + +/** + * @page rm Resource Manager + * + * @ref tf_rm_create_db + * + * @ref tf_rm_free_db + * + * @ref tf_rm_allocate + * + * @ref tf_rm_free + * + * @ref tf_rm_is_allocated + * + * @ref tf_rm_get_info + * + * @ref tf_rm_get_hcapi_type + */ + +/** + * Creates and fills a Resource Manager (RM) DB with requested + * elements. The DB is indexed per the parms structure. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to create parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +/* + * NOTE: + * - Fail on parameter check + * - Fail on DB creation, i.e. alloc amount is not possible or validation fails + * - Fail on DB creation if DB already exist + * + * - Allocs local DB + * - Does hcapi qcaps + * - Does hcapi reservation + * - Populates the pool with allocated elements + * - Returns handle to the created DB + */ +int tf_rm_create_db(struct tf *tfp, + struct tf_rm_create_db_parms *parms); + +/** + * Closes the Resource Manager (RM) DB and frees all allocated + * resources per the associated database. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to free parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_rm_free_db(struct tf *tfp, + struct tf_rm_free_db_parms *parms); + +/** + * Allocates a single element for the type specified, within the DB. + * + * [in] parms + * Pointer to allocate parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_rm_allocate(struct tf_rm_allocate_parms *parms); + +/** + * Free's a single element for the type specified, within the DB. + * + * [in] parms + * Pointer to free parameters + * + * Returns + * - (0) if successful. + * - (-EpINVAL) on failure. + */ +int tf_rm_free(struct tf_rm_free_parms *parms); + +/** + * Performs an allocation verification check on a specified element. + * + * [in] parms + * Pointer to is allocated parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +/* + * NOTE: + * - If pool is set to Chip MAX, then the query index must be checked + * against the allocated range and query index must be allocated as well. + * - If pool is allocated size only, then check if query index is allocated. + */ +int tf_rm_is_allocated(struct tf_rm_is_allocated_parms *parms); + +/** + * Retrieves an elements allocation information from the Resource + * Manager (RM) DB. + * + * [in] parms + * Pointer to get info parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms); + +/** + * Performs a lookup in the Resource Manager DB and retrives the + * requested HCAPI type. + * + * [in] parms + * Pointer to get hcapi parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_rm_get_hcapi_type(struct tf_rm_get_hcapi_parms *parms); + +#endif /* TF_RM_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c new file mode 100644 index 0000000..c749945 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_session.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +int +tf_session_get_session(struct tf *tfp, + struct tf_session *tfs) +{ + if (tfp->session == NULL || tfp->session->core_data == NULL) { + TFP_DRV_LOG(ERR, "Session not created\n"); + return -EINVAL; + } + + tfs = (struct tf_session *)(tfp->session->core_data); + + return 0; +} + +int +tf_session_get_device(struct tf_session *tfs, + struct tf_device *tfd) +{ + if (tfs->dev == NULL) { + TFP_DRV_LOG(ERR, "Device not created\n"); + return -EINVAL; + } + tfd = tfs->dev; + + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h index c9f4f8f..b1cc7a4 100644 --- a/drivers/net/bnxt/tf_core/tf_session.h +++ b/drivers/net/bnxt/tf_core/tf_session.h @@ -11,10 +11,21 @@ #include "bitalloc.h" #include "tf_core.h" +#include "tf_device.h" #include "tf_rm.h" #include "tf_tbl.h" #include "stack.h" +/** + * The Session module provides session control support. A session is + * to the ULP layer known as a session_info instance. The session + * private data is the actual session. + * + * Session manages: + * - The device and all the resources related to the device. + * - Any session sharing between ULP applications + */ + /** Session defines */ #define TF_SESSIONS_MAX 1 /** max # sessions */ @@ -90,6 +101,9 @@ struct tf_session { */ uint8_t ref_count; + /** Device */ + struct tf_dev_info *dev; + /** Session HW and SRAM resources */ struct tf_rm_db resc; @@ -309,4 +323,44 @@ struct tf_session { struct stack em_pool[TF_DIR_MAX]; }; +/** + * @page session Session Management + * + * @ref tf_session_get_session + * + * @ref tf_session_get_device + */ + +/** + * Looks up the private session information from the TF session info. + * + * [in] tfp + * Pointer to TF handle + * + * [out] tfs + * Pointer to the session + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_session_get_session(struct tf *tfp, + struct tf_session *tfs); + +/** + * Looks up the device information from the TF Session. + * + * [in] tfp + * Pointer to TF handle + * + * [out] tfd + * Pointer to the device + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_session_get_device(struct tf_session *tfs, + struct tf_dev_info *tfd); + #endif /* _TF_SESSION_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tbl.c b/drivers/net/bnxt/tf_core/tf_shadow_tbl.c new file mode 100644 index 0000000..8f2b6de --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_shadow_tbl.c @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_shadow_tbl.h" + +/** + * Shadow table DB element + */ +struct tf_shadow_tbl_element { + /** + * Hash table + */ + void *hash; + + /** + * Reference count, array of number of table type entries + */ + uint16_t *ref_count; +}; + +/** + * Shadow table DB definition + */ +struct tf_shadow_tbl_db { + /** + * The DB consists of an array of elements + */ + struct tf_shadow_tbl_element *db; +}; + +int +tf_shadow_tbl_create_db(struct tf_shadow_tbl_create_db_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tbl_insert(struct tf_shadow_tbl_insert_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tbl_remove(struct tf_shadow_tbl_remove_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tbl.h b/drivers/net/bnxt/tf_core/tf_shadow_tbl.h new file mode 100644 index 0000000..dfd336e --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_shadow_tbl.h @@ -0,0 +1,240 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef _TF_SHADOW_TBL_H_ +#define _TF_SHADOW_TBL_H_ + +#include "tf_core.h" + +struct tf; + +/** + * The Shadow Table module provides shadow DB handling for table based + * TF types. A shadow DB provides the capability that allows for reuse + * of TF resources. + * + * A Shadow table DB is intended to be used by the Table Type module + * only. + */ + +/** + * Shadow DB configuration information for a single table type. + * + * During Device initialization the HCAPI device specifics are learned + * and as well as the RM DB creation. From that those initial steps + * this structure can be populated. + * + * NOTE: + * If used in an array of table types then such array must be ordered + * by the TF type is represents. + */ +struct tf_shadow_tbl_cfg_parms { + /** + * TF Table type + */ + enum tf_tbl_type type; + + /** + * Number of entries the Shadow DB needs to hold + */ + int num_entries; + + /** + * Element width for this table type + */ + int element_width; +}; + +/** + * Shadow table DB creation parameters + */ +struct tf_shadow_tbl_create_db_parms { + /** + * [in] Configuration information for the shadow db + */ + struct tf_shadow_tbl_cfg_parms *cfg; + /** + * [in] Number of elements in the parms structure + */ + uint16_t num_elements; + /** + * [out] Shadow table DB handle + */ + void *tf_shadow_tbl_db; +}; + +/** + * Shadow table DB free parameters + */ +struct tf_shadow_tbl_free_db_parms { + /** + * Shadow table DB handle + */ + void *tf_shadow_tbl_db; +}; + +/** + * Shadow table search parameters + */ +struct tf_shadow_tbl_search_parms { + /** + * [in] Shadow table DB handle + */ + void *tf_shadow_tbl_db; + /** + * [in] Table type + */ + enum tf_tbl_type type; + /** + * [in] Pointer to entry blob value in remap table to match + */ + uint8_t *entry; + /** + * [in] Size of the entry blob passed in bytes + */ + uint16_t entry_sz; + /** + * [out] Index of the found element returned if hit + */ + uint16_t *index; + /** + * [out] Reference count incremented if hit + */ + uint16_t *ref_cnt; +}; + +/** + * Shadow table insert parameters + */ +struct tf_shadow_tbl_insert_parms { + /** + * [in] Shadow table DB handle + */ + void *tf_shadow_tbl_db; + /** + * [in] Tbl type + */ + enum tf_tbl_type type; + /** + * [in] Pointer to entry blob value in remap table to match + */ + uint8_t *entry; + /** + * [in] Size of the entry blob passed in bytes + */ + uint16_t entry_sz; + /** + * [in] Entry to update + */ + uint16_t index; + /** + * [out] Reference count after insert + */ + uint16_t *ref_cnt; +}; + +/** + * Shadow table remove parameters + */ +struct tf_shadow_tbl_remove_parms { + /** + * [in] Shadow table DB handle + */ + void *tf_shadow_tbl_db; + /** + * [in] Tbl type + */ + enum tf_tbl_type type; + /** + * [in] Entry to update + */ + uint16_t index; + /** + * [out] Reference count after removal + */ + uint16_t *ref_cnt; +}; + +/** + * @page shadow_tbl Shadow table DB + * + * @ref tf_shadow_tbl_create_db + * + * @ref tf_shadow_tbl_free_db + * + * @reg tf_shadow_tbl_search + * + * @reg tf_shadow_tbl_insert + * + * @reg tf_shadow_tbl_remove + */ + +/** + * Creates and fills a Shadow table DB. The DB is indexed per the + * parms structure. + * + * [in] parms + * Pointer to create db parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tbl_create_db(struct tf_shadow_tbl_create_db_parms *parms); + +/** + * Closes the Shadow table DB and frees all allocated + * resources per the associated database. + * + * [in] parms + * Pointer to the free DB parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms); + +/** + * Search Shadow table db for matching result + * + * [in] parms + * Pointer to the search parameters + * + * Returns + * - (0) if successful, element was found. + * - (-EINVAL) on failure. + */ +int tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms); + +/** + * Inserts an element into the Shadow table DB. Will fail if the + * elements ref_count is different from 0. Ref_count after insert will + * be incremented. + * + * [in] parms + * Pointer to insert parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tbl_insert(struct tf_shadow_tbl_insert_parms *parms); + +/** + * Removes an element from the Shadow table DB. Will fail if the + * elements ref_count is 0. Ref_count after removal will be + * decremented. + * + * [in] parms + * Pointer to remove parameter + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tbl_remove(struct tf_shadow_tbl_remove_parms *parms); + +#endif /* _TF_SHADOW_TBL_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tcam.c b/drivers/net/bnxt/tf_core/tf_shadow_tcam.c new file mode 100644 index 0000000..c61b833 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_shadow_tcam.c @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_shadow_tcam.h" + +/** + * Shadow tcam DB element + */ +struct tf_shadow_tcam_element { + /** + * Hash table + */ + void *hash; + + /** + * Reference count, array of number of tcam entries + */ + uint16_t *ref_count; +}; + +/** + * Shadow tcam DB definition + */ +struct tf_shadow_tcam_db { + /** + * The DB consists of an array of elements + */ + struct tf_shadow_tcam_element *db; +}; + +int +tf_shadow_tcam_create_db(struct tf_shadow_tcam_create_db_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tcam_free_db(struct tf_shadow_tcam_free_db_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tcam_insert(struct tf_shadow_tcam_insert_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_shadow_tcam_remove(struct tf_shadow_tcam_remove_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_shadow_tcam.h b/drivers/net/bnxt/tf_core/tf_shadow_tcam.h new file mode 100644 index 0000000..e2c4e06 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_shadow_tcam.h @@ -0,0 +1,239 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef _TF_SHADOW_TCAM_H_ +#define _TF_SHADOW_TCAM_H_ + +#include "tf_core.h" + +struct tf; + +/** + * The Shadow tcam module provides shadow DB handling for tcam based + * TF types. A shadow DB provides the capability that allows for reuse + * of TF resources. + * + * A Shadow tcam DB is intended to be used by the Tcam module only. + */ + +/** + * Shadow DB configuration information for a single tcam type. + * + * During Device initialization the HCAPI device specifics are learned + * and as well as the RM DB creation. From that those initial steps + * this structure can be populated. + * + * NOTE: + * If used in an array of tcam types then such array must be ordered + * by the TF type is represents. + */ +struct tf_shadow_tcam_cfg_parms { + /** + * TF tcam type + */ + enum tf_tcam_tbl_type type; + + /** + * Number of entries the Shadow DB needs to hold + */ + int num_entries; + + /** + * Element width for this table type + */ + int element_width; +}; + +/** + * Shadow tcam DB creation parameters + */ +struct tf_shadow_tcam_create_db_parms { + /** + * [in] Configuration information for the shadow db + */ + struct tf_shadow_tcam_cfg_parms *cfg; + /** + * [in] Number of elements in the parms structure + */ + uint16_t num_elements; + /** + * [out] Shadow tcam DB handle + */ + void *tf_shadow_tcam_db; +}; + +/** + * Shadow tcam DB free parameters + */ +struct tf_shadow_tcam_free_db_parms { + /** + * Shadow tcam DB handle + */ + void *tf_shadow_tcam_db; +}; + +/** + * Shadow tcam search parameters + */ +struct tf_shadow_tcam_search_parms { + /** + * [in] Shadow tcam DB handle + */ + void *tf_shadow_tcam_db; + /** + * [in] TCAM tbl type + */ + enum tf_tcam_tbl_type type; + /** + * [in] Pointer to entry blob value in remap table to match + */ + uint8_t *entry; + /** + * [in] Size of the entry blob passed in bytes + */ + uint16_t entry_sz; + /** + * [out] Index of the found element returned if hit + */ + uint16_t *index; + /** + * [out] Reference count incremented if hit + */ + uint16_t *ref_cnt; +}; + +/** + * Shadow tcam insert parameters + */ +struct tf_shadow_tcam_insert_parms { + /** + * [in] Shadow tcam DB handle + */ + void *tf_shadow_tcam_db; + /** + * [in] TCAM tbl type + */ + enum tf_tcam_tbl_type type; + /** + * [in] Pointer to entry blob value in remap table to match + */ + uint8_t *entry; + /** + * [in] Size of the entry blob passed in bytes + */ + uint16_t entry_sz; + /** + * [in] Entry to update + */ + uint16_t index; + /** + * [out] Reference count after insert + */ + uint16_t *ref_cnt; +}; + +/** + * Shadow tcam remove parameters + */ +struct tf_shadow_tcam_remove_parms { + /** + * [in] Shadow tcam DB handle + */ + void *tf_shadow_tcam_db; + /** + * [in] TCAM tbl type + */ + enum tf_tcam_tbl_type type; + /** + * [in] Entry to update + */ + uint16_t index; + /** + * [out] Reference count after removal + */ + uint16_t *ref_cnt; +}; + +/** + * @page shadow_tcam Shadow tcam DB + * + * @ref tf_shadow_tcam_create_db + * + * @ref tf_shadow_tcam_free_db + * + * @reg tf_shadow_tcam_search + * + * @reg tf_shadow_tcam_insert + * + * @reg tf_shadow_tcam_remove + */ + +/** + * Creates and fills a Shadow tcam DB. The DB is indexed per the + * parms structure. + * + * [in] parms + * Pointer to create db parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tcam_create_db(struct tf_shadow_tcam_create_db_parms *parms); + +/** + * Closes the Shadow tcam DB and frees all allocated + * resources per the associated database. + * + * [in] parms + * Pointer to the free DB parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tcam_free_db(struct tf_shadow_tcam_free_db_parms *parms); + +/** + * Search Shadow tcam db for matching result + * + * [in] parms + * Pointer to the search parameters + * + * Returns + * - (0) if successful, element was found. + * - (-EINVAL) on failure. + */ +int tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms); + +/** + * Inserts an element into the Shadow tcam DB. Will fail if the + * elements ref_count is different from 0. Ref_count after insert will + * be incremented. + * + * [in] parms + * Pointer to insert parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tcam_insert(struct tf_shadow_tcam_insert_parms *parms); + +/** + * Removes an element from the Shadow tcam DB. Will fail if the + * elements ref_count is 0. Ref_count after removal will be + * decremented. + * + * [in] parms + * Pointer to remove parameter + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_shadow_tcam_remove(struct tf_shadow_tcam_remove_parms *parms); + +#endif /* _TF_SHADOW_TCAM_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c index b9c71d4..c403d81 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_tbl.c @@ -15,6 +15,7 @@ #include "hsi_struct_def_dpdk.h" #include "tf_core.h" +#include "tf_util.h" #include "tf_em.h" #include "tf_msg.h" #include "tfp.h" diff --git a/drivers/net/bnxt/tf_core/tf_tbl_type.c b/drivers/net/bnxt/tf_core/tf_tbl_type.c new file mode 100644 index 0000000..a57a5dd --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_tbl_type.c @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_tbl_type.h" + +struct tf; + +/** + * Table Type DBs. + */ +/* static void *tbl_db[TF_DIR_MAX]; */ + +/** + * Table Type Shadow DBs + */ +/* static void *shadow_tbl_db[TF_DIR_MAX]; */ + +/** + * Init flag, set on bind and cleared on unbind + */ +/* static uint8_t init; */ + +/** + * Shadow init flag, set on bind and cleared on unbind + */ +/* static uint8_t shadow_init; */ + +int +tf_tbl_type_bind(struct tf *tfp __rte_unused, + struct tf_tbl_type_cfg_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tbl_type_unbind(struct tf *tfp __rte_unused) +{ + return 0; +} + +int +tf_tbl_type_alloc(struct tf *tfp __rte_unused, + struct tf_tbl_type_alloc_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tbl_type_free(struct tf *tfp __rte_unused, + struct tf_tbl_type_free_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tbl_type_alloc_search(struct tf *tfp __rte_unused, + struct tf_tbl_type_alloc_search_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tbl_type_set(struct tf *tfp __rte_unused, + struct tf_tbl_type_set_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tbl_type_get(struct tf *tfp __rte_unused, + struct tf_tbl_type_get_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_tbl_type.h b/drivers/net/bnxt/tf_core/tf_tbl_type.h new file mode 100644 index 0000000..c880b36 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_tbl_type.h @@ -0,0 +1,309 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef TF_TBL_TYPE_H_ +#define TF_TBL_TYPE_H_ + +#include "tf_core.h" + +struct tf; + +/** + * The Table Type module provides processing of Internal TF table types. + */ + +/** + * Table Type configuration parameters + */ +struct tf_tbl_type_cfg_parms { + /** + * Number of table types in each of the configuration arrays + */ + uint16_t num_elements; + + /** + * Table Type element configuration array + */ + struct tf_rm_element_cfg *tbl_cfg[TF_DIR_MAX]; + + /** + * Shadow table type configuration array + */ + struct tf_shadow_tbl_type_cfg *tbl_shadow_cfg[TF_DIR_MAX]; +}; + +/** + * Table Type allocation parameters + */ +struct tf_tbl_type_alloc_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of the allocation + */ + enum tf_tbl_type type; + /** + * [out] Idx of allocated entry or found entry (if search_enable) + */ + uint32_t idx; +}; + +/** + * Table Type free parameters + */ +struct tf_tbl_type_free_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of the allocation type + */ + enum tf_tbl_type type; + /** + * [in] Index to free + */ + uint32_t idx; + /** + * [out] Reference count after free, only valid if session has been + * created with shadow_copy. + */ + uint16_t ref_cnt; +}; + +struct tf_tbl_type_alloc_search_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of the allocation + */ + enum tf_tbl_type type; + /** + * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) + */ + uint32_t tbl_scope_id; + /** + * [in] Enable search for matching entry. If the table type is + * internal the shadow copy will be searched before + * alloc. Session must be configured with shadow copy enabled. + */ + uint8_t search_enable; + /** + * [in] Result data to search for (if search_enable) + */ + uint8_t *result; + /** + * [in] Result data size in bytes (if search_enable) + */ + uint16_t result_sz_in_bytes; + /** + * [out] If search_enable, set if matching entry found + */ + uint8_t hit; + /** + * [out] Current ref count after allocation (if search_enable) + */ + uint16_t ref_cnt; + /** + * [out] Idx of allocated entry or found entry (if search_enable) + */ + uint32_t idx; +}; + +/** + * Table Type set parameters + */ +struct tf_tbl_type_set_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of object to set + */ + enum tf_tbl_type type; + /** + * [in] Entry data + */ + uint8_t *data; + /** + * [in] Entry size + */ + uint16_t data_sz_in_bytes; + /** + * [in] Entry index to write to + */ + uint32_t idx; +}; + +/** + * Table Type get parameters + */ +struct tf_tbl_type_get_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of object to get + */ + enum tf_tbl_type type; + /** + * [out] Entry data + */ + uint8_t *data; + /** + * [out] Entry size + */ + uint16_t data_sz_in_bytes; + /** + * [in] Entry index to read + */ + uint32_t idx; +}; + +/** + * @page tbl_type Table Type + * + * @ref tf_tbl_type_bind + * + * @ref tf_tbl_type_unbind + * + * @ref tf_tbl_type_alloc + * + * @ref tf_tbl_type_free + * + * @ref tf_tbl_type_alloc_search + * + * @ref tf_tbl_type_set + * + * @ref tf_tbl_type_get + */ + +/** + * Initializes the Table Type module with the requested DBs. Must be + * invoked as the first thing before any of the access functions. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_bind(struct tf *tfp, + struct tf_tbl_type_cfg_parms *parms); + +/** + * Cleans up the private DBs and releases all the data. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_unbind(struct tf *tfp); + +/** + * Allocates the requested table type from the internal RM DB. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_alloc(struct tf *tfp, + struct tf_tbl_type_alloc_parms *parms); + +/** + * Free's the requested table type and returns it to the DB. If shadow + * DB is enabled its searched first and if found the element refcount + * is decremented. If refcount goes to 0 then its returned to the + * table type DB. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_free(struct tf *tfp, + struct tf_tbl_type_free_parms *parms); + +/** + * Supported if Shadow DB is configured. Searches the Shadow DB for + * any matching element. If found the refcount in the shadow DB is + * updated accordingly. If not found a new element is allocated and + * installed into the shadow DB. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_alloc_search(struct tf *tfp, + struct tf_tbl_type_alloc_search_parms *parms); + +/** + * Configures the requested element by sending a firmware request which + * then installs it into the device internal structures. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_set(struct tf *tfp, + struct tf_tbl_type_set_parms *parms); + +/** + * Retrieves the requested element by sending a firmware request to get + * the element. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tbl_type_get(struct tf *tfp, + struct tf_tbl_type_get_parms *parms); + +#endif /* TF_TBL_TYPE_H */ diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c new file mode 100644 index 0000000..3ad99dd --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_tcam.c @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_tcam.h" + +struct tf; + +/** + * TCAM DBs. + */ +/* static void *tcam_db[TF_DIR_MAX]; */ + +/** + * TCAM Shadow DBs + */ +/* static void *shadow_tcam_db[TF_DIR_MAX]; */ + +/** + * Init flag, set on bind and cleared on unbind + */ +/* static uint8_t init; */ + +/** + * Shadow init flag, set on bind and cleared on unbind + */ +/* static uint8_t shadow_init; */ + +int +tf_tcam_bind(struct tf *tfp __rte_unused, + struct tf_tcam_cfg_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tcam_unbind(struct tf *tfp __rte_unused) +{ + return 0; +} + +int +tf_tcam_alloc(struct tf *tfp __rte_unused, + struct tf_tcam_alloc_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tcam_free(struct tf *tfp __rte_unused, + struct tf_tcam_free_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tcam_alloc_search(struct tf *tfp __rte_unused, + struct tf_tcam_alloc_search_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tcam_set(struct tf *tfp __rte_unused, + struct tf_tcam_set_parms *parms __rte_unused) +{ + return 0; +} + +int +tf_tcam_get(struct tf *tfp __rte_unused, + struct tf_tcam_get_parms *parms __rte_unused) +{ + return 0; +} diff --git a/drivers/net/bnxt/tf_core/tf_tcam.h b/drivers/net/bnxt/tf_core/tf_tcam.h new file mode 100644 index 0000000..1420c9e --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_tcam.h @@ -0,0 +1,314 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +#ifndef _TF_TCAM_H_ +#define _TF_TCAM_H_ + +#include "tf_core.h" + +/** + * The TCAM module provides processing of Internal TCAM types. + */ + +/** + * TCAM configuration parameters + */ +struct tf_tcam_cfg_parms { + /** + * Number of tcam types in each of the configuration arrays + */ + uint16_t num_elements; + + /** + * TCAM configuration array + */ + struct tf_rm_element_cfg *tcam_cfg[TF_DIR_MAX]; + + /** + * Shadow table type configuration array + */ + struct tf_shadow_tcam_cfg *tcam_shadow_cfg[TF_DIR_MAX]; +}; + +/** + * TCAM allocation parameters + */ +struct tf_tcam_alloc_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of the allocation + */ + enum tf_tcam_tbl_type type; + /** + * [out] Idx of allocated entry or found entry (if search_enable) + */ + uint32_t idx; +}; + +/** + * TCAM free parameters + */ +struct tf_tcam_free_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of the allocation type + */ + enum tf_tcam_tbl_type type; + /** + * [in] Index to free + */ + uint32_t idx; + /** + * [out] Reference count after free, only valid if session has been + * created with shadow_copy. + */ + uint16_t ref_cnt; +}; + +/** + * TCAM allocate search parameters + */ +struct tf_tcam_alloc_search_parms { + /** + * [in] receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] TCAM table type + */ + enum tf_tcam_tbl_type tcam_tbl_type; + /** + * [in] Enable search for matching entry + */ + uint8_t search_enable; + /** + * [in] Key data to match on (if search) + */ + uint8_t *key; + /** + * [in] key size in bits (if search) + */ + uint16_t key_sz_in_bits; + /** + * [in] Mask data to match on (if search) + */ + uint8_t *mask; + /** + * [in] Priority of entry requested (definition TBD) + */ + uint32_t priority; + /** + * [out] If search, set if matching entry found + */ + uint8_t hit; + /** + * [out] Current refcnt after allocation + */ + uint16_t ref_cnt; + /** + * [out] Idx allocated + * + */ + uint16_t idx; +}; + +/** + * TCAM set parameters + */ +struct tf_tcam_set_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of object to set + */ + enum tf_tcam_tbl_type type; + /** + * [in] Entry data + */ + uint8_t *data; + /** + * [in] Entry size + */ + uint16_t data_sz_in_bytes; + /** + * [in] Entry index to write to + */ + uint32_t idx; +}; + +/** + * TCAM get parameters + */ +struct tf_tcam_get_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of object to get + */ + enum tf_tcam_tbl_type type; + /** + * [out] Entry data + */ + uint8_t *data; + /** + * [out] Entry size + */ + uint16_t data_sz_in_bytes; + /** + * [in] Entry index to read + */ + uint32_t idx; +}; + +/** + * @page tcam TCAM + * + * @ref tf_tcam_bind + * + * @ref tf_tcam_unbind + * + * @ref tf_tcam_alloc + * + * @ref tf_tcam_free + * + * @ref tf_tcam_alloc_search + * + * @ref tf_tcam_set + * + * @ref tf_tcam_get + * + */ + +/** + * Initializes the TCAM module with the requested DBs. Must be + * invoked as the first thing before any of the access functions. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_bind(struct tf *tfp, + struct tf_tcam_cfg_parms *parms); + +/** + * Cleans up the private DBs and releases all the data. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_unbind(struct tf *tfp); + +/** + * Allocates the requested tcam type from the internal RM DB. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_alloc(struct tf *tfp, + struct tf_tcam_alloc_parms *parms); + +/** + * Free's the requested table type and returns it to the DB. If shadow + * DB is enabled its searched first and if found the element refcount + * is decremented. If refcount goes to 0 then its returned to the + * table type DB. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_free(struct tf *tfp, + struct tf_tcam_free_parms *parms); + +/** + * Supported if Shadow DB is configured. Searches the Shadow DB for + * any matching element. If found the refcount in the shadow DB is + * updated accordingly. If not found a new element is allocated and + * installed into the shadow DB. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_alloc_search(struct tf *tfp, + struct tf_tcam_alloc_search_parms *parms); + +/** + * Configures the requested element by sending a firmware request which + * then installs it into the device internal structures. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_set(struct tf *tfp, + struct tf_tcam_set_parms *parms); + +/** + * Retrieves the requested element by sending a firmware request to get + * the element. + * + * [in] tfp + * Pointer to TF handle, used for HCAPI communication + * + * [in] parms + * Pointer to parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int tf_tcam_get(struct tf *tfp, + struct tf_tcam_get_parms *parms); + +#endif /* _TF_TCAM_H */ diff --git a/drivers/net/bnxt/tf_core/tf_util.c b/drivers/net/bnxt/tf_core/tf_util.c new file mode 100644 index 0000000..a901054 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_util.c @@ -0,0 +1,145 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2019 Broadcom + * All rights reserved. + */ + +#include + +#include "tf_util.h" + +const char +*tf_dir_2_str(enum tf_dir dir) +{ + switch (dir) { + case TF_DIR_RX: + return "RX"; + case TF_DIR_TX: + return "TX"; + default: + return "Invalid direction"; + } +} + +const char +*tf_ident_2_str(enum tf_identifier_type id_type) +{ + switch (id_type) { + case TF_IDENT_TYPE_L2_CTXT: + return "l2_ctxt_remap"; + case TF_IDENT_TYPE_PROF_FUNC: + return "prof_func"; + case TF_IDENT_TYPE_WC_PROF: + return "wc_prof"; + case TF_IDENT_TYPE_EM_PROF: + return "em_prof"; + case TF_IDENT_TYPE_L2_FUNC: + return "l2_func"; + default: + return "Invalid identifier"; + } +} + +const char +*tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type) +{ + switch (tcam_type) { + case TF_TCAM_TBL_TYPE_L2_CTXT_TCAM: + return "l2_ctxt_tcam"; + case TF_TCAM_TBL_TYPE_PROF_TCAM: + return "prof_tcam"; + case TF_TCAM_TBL_TYPE_WC_TCAM: + return "wc_tcam"; + case TF_TCAM_TBL_TYPE_VEB_TCAM: + return "veb_tcam"; + case TF_TCAM_TBL_TYPE_SP_TCAM: + return "sp_tcam"; + case TF_TCAM_TBL_TYPE_CT_RULE_TCAM: + return "ct_rule_tcam"; + default: + return "Invalid tcam table type"; + } +} + +const char +*tf_tbl_type_2_str(enum tf_tbl_type tbl_type) +{ + switch (tbl_type) { + case TF_TBL_TYPE_FULL_ACT_RECORD: + return "Full Action record"; + case TF_TBL_TYPE_MCAST_GROUPS: + return "Multicast Groups"; + case TF_TBL_TYPE_ACT_ENCAP_8B: + return "Encap 8B"; + case TF_TBL_TYPE_ACT_ENCAP_16B: + return "Encap 16B"; + case TF_TBL_TYPE_ACT_ENCAP_32B: + return "Encap 32B"; + case TF_TBL_TYPE_ACT_ENCAP_64B: + return "Encap 64B"; + case TF_TBL_TYPE_ACT_SP_SMAC: + return "Source Properties SMAC"; + case TF_TBL_TYPE_ACT_SP_SMAC_IPV4: + return "Source Properties SMAC IPv4"; + case TF_TBL_TYPE_ACT_SP_SMAC_IPV6: + return "Source Properties SMAC IPv6"; + case TF_TBL_TYPE_ACT_STATS_64: + return "Stats 64B"; + case TF_TBL_TYPE_ACT_MODIFY_SPORT: + return "NAT Source Port"; + case TF_TBL_TYPE_ACT_MODIFY_DPORT: + return "NAT Destination Port"; + case TF_TBL_TYPE_ACT_MODIFY_IPV4_SRC: + return "NAT IPv4 Source"; + case TF_TBL_TYPE_ACT_MODIFY_IPV4_DEST: + return "NAT IPv4 Destination"; + case TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC: + return "NAT IPv6 Source"; + case TF_TBL_TYPE_ACT_MODIFY_IPV6_DEST: + return "NAT IPv6 Destination"; + case TF_TBL_TYPE_METER_PROF: + return "Meter Profile"; + case TF_TBL_TYPE_METER_INST: + return "Meter"; + case TF_TBL_TYPE_MIRROR_CONFIG: + return "Mirror"; + case TF_TBL_TYPE_UPAR: + return "UPAR"; + case TF_TBL_TYPE_EPOCH0: + return "EPOCH0"; + case TF_TBL_TYPE_EPOCH1: + return "EPOCH1"; + case TF_TBL_TYPE_METADATA: + return "Metadata"; + case TF_TBL_TYPE_CT_STATE: + return "Connection State"; + case TF_TBL_TYPE_RANGE_PROF: + return "Range Profile"; + case TF_TBL_TYPE_RANGE_ENTRY: + return "Range"; + case TF_TBL_TYPE_LAG: + return "Link Aggregation"; + case TF_TBL_TYPE_VNIC_SVIF: + return "VNIC SVIF"; + case TF_TBL_TYPE_EM_FKB: + return "EM Flexible Key Builder"; + case TF_TBL_TYPE_WC_FKB: + return "WC Flexible Key Builder"; + case TF_TBL_TYPE_EXT: + return "External"; + default: + return "Invalid tbl type"; + } +} + +const char +*tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type) +{ + switch (em_type) { + case TF_EM_TBL_TYPE_EM_RECORD: + return "EM Record"; + case TF_EM_TBL_TYPE_TBL_SCOPE: + return "Table Scope"; + default: + return "Invalid EM type"; + } +} diff --git a/drivers/net/bnxt/tf_core/tf_util.h b/drivers/net/bnxt/tf_core/tf_util.h new file mode 100644 index 0000000..4099629 --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_util.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2019 Broadcom + * All rights reserved. + */ + +#ifndef _TF_UTIL_H_ +#define _TF_UTIL_H_ + +#include "tf_core.h" + +/** + * Helper function converting direction to text string + */ +const char +*tf_dir_2_str(enum tf_dir dir); + +/** + * Helper function converting identifier to text string + */ +const char +*tf_ident_2_str(enum tf_identifier_type id_type); + +/** + * Helper function converting tcam type to text string + */ +const char +*tf_tcam_tbl_2_str(enum tf_tcam_tbl_type tcam_type); + +/** + * Helper function converting tbl type to text string + */ +const char +*tf_tbl_type_2_str(enum tf_tbl_type tbl_type); + +/** + * Helper function converting em tbl type to text string + */ +const char +*tf_em_tbl_type_2_str(enum tf_em_tbl_type em_type); + +#endif /* _TF_UTIL_H_ */ -- 2.7.4