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 CBC59A0577; Mon, 13 Apr 2020 21:44:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA2061C0C0; Mon, 13 Apr 2020 21:42:11 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id EE5D41C08E for ; Mon, 13 Apr 2020 21:42:10 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id x3so4724427pfp.7 for ; Mon, 13 Apr 2020 12:42:10 -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=mMzswSloNz8mGDNhS/vrKvXLnzvf93Smnnh3H4ZTsSM=; b=PTuCX3sSMZoyy52XfmXTYRstq9V53ONEdA24+mTKqKftQYFmLc0Qq4Zahej5hLDA9N /b1UGpFdPwQxtlH4Mf+yFnFaNx15s6Td/6w+7JIFiDYEkEccydoadprI4hKYr6I1ykgj 8vYepgQtqw6/qj0PhETy9Ws+4nplXm2kmRFNQ= 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=mMzswSloNz8mGDNhS/vrKvXLnzvf93Smnnh3H4ZTsSM=; b=iEkIqj/7UiqPhFMXSdqxPUU8QNcHCMDIjN/OXhbR7ogne0vgob7KHwiN+uys1UHFQB jT9mfubG+rSvsnyuLww41pigu40bTSFeSiAGqLj9lTnf3P3KMkK0nfReyXgMdrd5YgYH yzTpcbVWcSSYYX/g0JSSKJ6Q5EbTSFMOCtnvqD2Suclv4DYpLv+ithMI81fUuX0Rehv9 hj4c1Neq3AcYhsKs3sQP8KMAh6/iv679sCFdmMsHDlkxNqlFzAkPYL/ZQm4iN3zYCHdE sf5maYghZink12cMeP161x9jeJexe9Ckx1kxSJ0wJ6kkljQMX3YPlSihSPdFD60IClBN j0AQ== X-Gm-Message-State: AGi0PuaF0P666hv1S9QMXSCiul0E9izH77jbXQkCI7qyn3YbMvDlNh2Q fLw48IH3dG0umKyKokltpOk4tUP+5/uzX2jNxnLzgmnvqjKuPLccZY6f0RX0mojQv2FUHHaTNb1 eiJ0fUmf42vCAUM5/W0azVXSG30nYko4bSXADE40hgKGoScmBJEsx7NfBsd+wdoC7uwnL X-Google-Smtp-Source: APiQypLsIgboBotbZhdidf3Ij5xCush0WjkeIYjyjQEH+QU6ueWITuI4MRSL9YKOY5SQ36lF+eZ+4w== X-Received: by 2002:a63:cc06:: with SMTP id x6mr9828907pgf.143.1586806929283; Mon, 13 Apr 2020 12:42:09 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 9sm1381663pfn.204.2020.04.13.12.42.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2020 12:42:08 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Farah Smith , Michael Wildt Date: Tue, 14 Apr 2020 01:09:48 +0530 Message-Id: <1586806811-21736-12-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1584459511-5353-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586806811-21736-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v2 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 152cfa2..2833de2 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" @@ -172,6 +173,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 f4b2f4c..b9ed127 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