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 DCCE3A0563; Wed, 15 Apr 2020 10:22:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B11331D56F; Wed, 15 Apr 2020 10:19:55 +0200 (CEST) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id 521D31D589 for ; Wed, 15 Apr 2020 10:19:53 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id e16so6163170pjp.1 for ; Wed, 15 Apr 2020 01:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9FcZ6Zz7rTR9MdGtPIu5qAdiCKYEd3/5mxzH5mDfZBY=; b=G6OYUJG9Hy7Ue6YCcdSrRZCpBkgAYs3MxJuEfm2/WFMJ2CJUW4YYTQO88EzKpozOF2 Xzmv+Mz7dQhKa4Aoov9xrRoQnuAkZbjy/lq6CptToUcDJcTuONKpSSMWUf3eielr0zDv jSskKC6XmjlFeHRf7OTmfKT/X3Bf4JUDdwMy0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9FcZ6Zz7rTR9MdGtPIu5qAdiCKYEd3/5mxzH5mDfZBY=; b=ahDxSjiVZtgmN7p01CTJEiCn619WwBrvZTt2Kre3wW/DUyinK+AwktxPJN5GEmrSnN bk1b1iRd8/RXSd868gg1iSmVY/Pi16YrlOERSDJhSEzJ9p87OjxelFn8YPcM5VoMA1A8 GQ1iyR1NhCHnC6Ya55lbUqQ3S81v4liYX9n13XueZV2egR796yRLsdbZ/wjuHtug9m0n iJNe5e+hvZNakWCU4I+OptzOJFTQz3cXUADCM9PRS91d2SDxMf89rdew25/BjMUiWO8F A1NxX/mbcgjOVCdOav16qSykPTc5ASOacR9xNKnRQOSbtS9WIuI20ygvCJl6NbXzm8fM KH4Q== X-Gm-Message-State: AGi0PubNm1Vq3DnJ5rbZ2oQxTyr5h+Gti3HpU6BPrlktCYGJsmQ71+qL 3IVct5OdFl32EGiqnZR59+4AJ2q/HD2JjqSOZJDu3oLP6r4M5qDfXri3EhH6WN+E3oOsYn6srIn wF6S4lSbOGnp37X5yaCBMdw/9yZcWyPbJ0G0sS+Q5szRVBe/06Q8PzrDLaWkBuvMTkoIp X-Google-Smtp-Source: APiQypK5IgrGyaINVvaWyPfYZ8vN4FQzUFNrE0sLzRzTplVyoDw2Wi5pBBqG9UavmkKkOuh9rs4ILA== X-Received: by 2002:a17:902:b48c:: with SMTP id y12mr680825plr.184.1586938791831; Wed, 15 Apr 2020 01:19:51 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id fy21sm3819019pjb.25.2020.04.15.01.19.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2020 01:19:51 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Farah Smith , Michael Wildt Date: Wed, 15 Apr 2020 13:48:48 +0530 Message-Id: <1586938751-32808-12-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v4 11/34] net/bnxt: add tf core table scope 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: Farah Smith - Added TruFlow Table public API - Added Table Scope capability including Table Type support code for setting and getting Table Types. Signed-off-by: Farah Smith Signed-off-by: Michael Wildt Reviewed-by: Randy Schacher Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/tf_core/hwrm_tf.h | 21 ++++++ drivers/net/bnxt/tf_core/tf_core.c | 4 ++ drivers/net/bnxt/tf_core/tf_core.h | 128 +++++++++++++++++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_msg.c | 81 +++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_msg.h | 63 ++++++++++++++++++ drivers/net/bnxt/tf_core/tf_tbl.c | 43 +++++++++++++ 7 files changed, 341 insertions(+) create mode 100644 drivers/net/bnxt/tf_core/tf_tbl.c diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 02f8c3f..6714a6a 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -52,6 +52,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/bitalloc.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_msg.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/rand.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_rm.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tf_tbl.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_core/tfp.c # diff --git a/drivers/net/bnxt/tf_core/hwrm_tf.h b/drivers/net/bnxt/tf_core/hwrm_tf.h index a8a5547..acb9a8b 100644 --- a/drivers/net/bnxt/tf_core/hwrm_tf.h +++ b/drivers/net/bnxt/tf_core/hwrm_tf.h @@ -891,6 +891,27 @@ typedef struct tf_session_sram_resc_flush_input { } tf_session_sram_resc_flush_input_t, *ptf_session_sram_resc_flush_input_t; BUILD_BUG_ON(sizeof(tf_session_sram_resc_flush_input_t) <= TF_MAX_REQ_SIZE); +/* Input params for table type set */ +typedef struct tf_tbl_type_set_input { + /* Session Id */ + uint32_t fw_session_id; + /* flags */ + uint16_t flags; + /* When set to 0, indicates the get apply to RX */ +#define TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_RX (0x0) + /* When set to 1, indicates the get apply to TX */ +#define TF_TBL_TYPE_SET_INPUT_FLAGS_DIR_TX (0x1) + /* Type of the object to set */ + uint32_t type; + /* Size of the data to set in bytes */ + uint16_t size; + /* Data to set */ + uint8_t data[TF_BULK_SEND]; + /* Index to set */ + uint32_t index; +} tf_tbl_type_set_input_t, *ptf_tbl_type_set_input_t; +BUILD_BUG_ON(sizeof(tf_tbl_type_set_input_t) <= TF_MAX_REQ_SIZE); + /* Input params for table type get */ typedef struct tf_tbl_type_get_input { /* Session Id */ diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 39f4a11..f04a9b1 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -7,6 +7,7 @@ #include "tf_core.h" #include "tf_session.h" +#include "tf_tbl.h" #include "tf_rm.h" #include "tf_msg.h" #include "tfp.h" @@ -173,6 +174,9 @@ tf_open_session(struct tf *tfp, /* Setup hash seeds */ tf_seeds_init(session); + /* Initialize external pool data structures */ + tf_init_tbl_pool(session); + session->ref_count++; /* Return session ID */ diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 1431d06..4c90677 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -458,6 +458,134 @@ int tf_free_identifier(struct tf *tfp, struct tf_free_identifier_parms *parms); /** + * @page dram_table DRAM Table Scope Interface + * + * @ref tf_alloc_tbl_scope + * + * @ref tf_free_tbl_scope + * + * If we allocate the EEM memory from the core, we need to store it in + * the shared session data structure to make sure it can be freed later. + * (for example if the PF goes away) + * + * Current thought is that memory is allocated within core. + */ + + +/** tf_alloc_tbl_scope_parms definition + */ +struct tf_alloc_tbl_scope_parms { + /** + * [in] All Maximum key size required. + */ + uint16_t rx_max_key_sz_in_bits; + /** + * [in] Maximum Action size required (includes inlined items) + */ + uint16_t rx_max_action_entry_sz_in_bits; + /** + * [in] Memory size in Megabytes + * Total memory size allocated by user to be divided + * up for actions, hash, counters. Only inline external actions. + * Use this variable or the number of flows, do not set both. + */ + uint32_t rx_mem_size_in_mb; + /** + * [in] Number of flows * 1000. If set, rx_mem_size_in_mb must equal 0. + */ + uint32_t rx_num_flows_in_k; + /** + * [in] SR2 only receive table access interface id + */ + uint32_t rx_tbl_if_id; + /** + * [in] All Maximum key size required. + */ + uint16_t tx_max_key_sz_in_bits; + /** + * [in] Maximum Action size required (includes inlined items) + */ + uint16_t tx_max_action_entry_sz_in_bits; + /** + * [in] Memory size in Megabytes + * Total memory size allocated by user to be divided + * up for actions, hash, counters. Only inline external actions. + */ + uint32_t tx_mem_size_in_mb; + /** + * [in] Number of flows * 1000 + */ + uint32_t tx_num_flows_in_k; + /** + * [in] SR2 only receive table access interface id + */ + uint32_t tx_tbl_if_id; + /** + * [out] table scope identifier + */ + uint32_t tbl_scope_id; +}; + +struct tf_free_tbl_scope_parms { + /** + * [in] table scope identifier + */ + uint32_t tbl_scope_id; +}; + +/** + * allocate a table scope + * + * On SR2 Firmware will allocate a scope ID. On other devices, the scope + * is a software construct to identify an EEM table. This function will + * divide the hash memory/buckets and records according to the device + * device constraints based upon calculations using either the number of flows + * requested or the size of memory indicated. Other parameters passed in + * determine the configuration (maximum key size, maximum external action record + * size. + * + * This API will allocate the table region in + * DRAM, program the PTU page table entries, and program the number of static + * buckets (if SR2) in the RX and TX CFAs. Buckets are assumed to start at + * 0 in the EM memory for the scope. Upon successful completion of this API, + * hash tables are fully initialized and ready for entries to be inserted. + * + * A single API is used to allocate a common table scope identifier in both + * receive and transmit CFA. The scope identifier is common due to nature of + * connection tracking sending notifications between RX and TX direction. + * + * The receive and transmit table access identifiers specify which rings will + * be used to initialize table DRAM. The application must ensure mutual + * exclusivity of ring usage for table scope allocation and any table update + * operations. + * + * The hash table buckets, EM keys, and EM lookup results are stored in the + * memory allocated based on the rx_em_hash_mb/tx_em_hash_mb parameters. The + * hash table buckets are stored at the beginning of that memory. + * + * NOTES: No EM internal setup is done here. On chip EM records are managed + * internally by TruFlow core. + * + * Returns success or failure code. + */ +int tf_alloc_tbl_scope(struct tf *tfp, + struct tf_alloc_tbl_scope_parms *parms); + + +/** + * free a table scope + * + * Firmware checks that the table scope ID is owned by the TruFlow + * session, verifies that no references to this table scope remains + * (SR2 ILT) or Profile TCAM entries for either CFA (RX/TX) direction, + * then frees the table scope ID. + * + * Returns success or failure code. + */ +int tf_free_tbl_scope(struct tf *tfp, + struct tf_free_tbl_scope_parms *parms); + +/** * TCAM table type */ enum tf_tcam_tbl_type { diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 9d17440..3f3001c 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -869,6 +869,87 @@ tf_msg_session_sram_resc_flush(struct tf *tfp, return tfp_le_to_cpu_32(parms.tf_resp_code); } +int +tf_msg_set_tbl_entry(struct tf *tfp, + enum tf_dir dir, + enum tf_tbl_type type, + uint16_t size, + uint8_t *data, + uint32_t index) +{ + int rc; + struct tfp_send_msg_parms parms = { 0 }; + struct tf_tbl_type_set_input req = { 0 }; + struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data); + + /* Populate the request */ + req.fw_session_id = + tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id); + req.flags = tfp_cpu_to_le_16(dir); + req.type = tfp_cpu_to_le_32(type); + req.size = tfp_cpu_to_le_16(size); + req.index = tfp_cpu_to_le_32(index); + + tfp_memcpy(&req.data, + data, + size); + + MSG_PREP_NO_RESP(parms, + TF_KONG_MB, + HWRM_TF, + HWRM_TFT_TBL_TYPE_SET, + req); + + rc = tfp_send_msg_tunneled(tfp, &parms); + if (rc) + return rc; + + return tfp_le_to_cpu_32(parms.tf_resp_code); +} + +int +tf_msg_get_tbl_entry(struct tf *tfp, + enum tf_dir dir, + enum tf_tbl_type type, + uint16_t size, + uint8_t *data, + uint32_t index) +{ + int rc; + struct tfp_send_msg_parms parms = { 0 }; + struct tf_tbl_type_get_input req = { 0 }; + struct tf_tbl_type_get_output resp = { 0 }; + struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data); + + /* Populate the request */ + req.fw_session_id = + tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id); + req.flags = tfp_cpu_to_le_16(dir); + req.type = tfp_cpu_to_le_32(type); + req.index = tfp_cpu_to_le_32(index); + + MSG_PREP(parms, + TF_KONG_MB, + HWRM_TF, + HWRM_TFT_TBL_TYPE_GET, + req, + resp); + + rc = tfp_send_msg_tunneled(tfp, &parms); + if (rc) + return rc; + + /* Verify that we got enough buffer to return the requested data */ + if (resp.size < size) + return -EINVAL; + + tfp_memcpy(data, + &resp.data, + resp.size); + + return tfp_le_to_cpu_32(parms.tf_resp_code); +} + #define TF_BYTES_PER_SLICE(tfp) 12 #define NUM_SLICES(tfp, bytes) \ (((bytes) + TF_BYTES_PER_SLICE(tfp) - 1) / TF_BYTES_PER_SLICE(tfp)) diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h index fa74d78..9055b16 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.h +++ b/drivers/net/bnxt/tf_core/tf_msg.h @@ -6,6 +6,7 @@ #ifndef _TF_MSG_H_ #define _TF_MSG_H_ +#include "tf_tbl.h" #include "tf_rm.h" struct tf; @@ -150,4 +151,66 @@ int tf_msg_tcam_entry_set(struct tf *tfp, int tf_msg_tcam_entry_free(struct tf *tfp, struct tf_free_tcam_entry_parms *parms); +/** + * Sends Set message of a Table Type element to the firmware. + * + * [in] tfp + * Pointer to session handle + * + * [in] dir + * Direction location of the element to set + * + * [in] type + * Type of the object to set + * + * [in] size + * Size of the data to set + * + * [in] data + * Data to set + * + * [in] index + * Index to set + * + * Returns: + * 0 - Success + */ +int tf_msg_set_tbl_entry(struct tf *tfp, + enum tf_dir dir, + enum tf_tbl_type type, + uint16_t size, + uint8_t *data, + uint32_t index); + +/** + * Sends get message of a Table Type element to the firmware. + * + * [in] tfp + * Pointer to session handle + * + * [in] dir + * Direction location of the element to get + * + * [in] type + * Type of the object to get + * + * [in] size + * Size of the data read + * + * [in] data + * Data read + * + * [in] index + * Index to get + * + * Returns: + * 0 - Success + */ +int tf_msg_get_tbl_entry(struct tf *tfp, + enum tf_dir dir, + enum tf_tbl_type type, + uint16_t size, + uint8_t *data, + uint32_t index); + #endif /* _TF_MSG_H_ */ diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c new file mode 100644 index 0000000..14bf4ef --- /dev/null +++ b/drivers/net/bnxt/tf_core/tf_tbl.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019-2020 Broadcom + * All rights reserved. + */ + +/* Truflow Table APIs and supporting code */ + +#include +#include +#include +#include +#include +#include +#include +#include "hsi_struct_def_dpdk.h" + +#include "tf_core.h" +#include "tf_session.h" +#include "tf_msg.h" +#include "tfp.h" +#include "hwrm_tf.h" +#include "bnxt.h" +#include "tf_resources.h" +#include "tf_rm.h" + +#define PTU_PTE_VALID 0x1UL +#define PTU_PTE_LAST 0x2UL +#define PTU_PTE_NEXT_TO_LAST 0x4UL + +/* Number of pointers per page_size */ +#define MAX_PAGE_PTRS(page_size) ((page_size) / sizeof(void *)) + +/* API defined in tf_tbl.h */ +void +tf_init_tbl_pool(struct tf_session *session) +{ + enum tf_dir dir; + + for (dir = 0; dir < TF_DIR_MAX; dir++) { + session->ext_pool_2_scope[dir][TF_EXT_POOL_0] = + TF_TBL_SCOPE_INVALID; + } +} -- 2.7.4