From patchwork Sun Jun 13 00:06:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 94116 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EFA13A0C41; Sun, 13 Jun 2021 02:10:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7DA9411C0; Sun, 13 Jun 2021 02:07:32 +0200 (CEST) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 7A8B541124 for ; Sun, 13 Jun 2021 02:07:27 +0200 (CEST) Received: by mail-pl1-f178.google.com with SMTP id u18so4061300plc.0 for ; Sat, 12 Jun 2021 17:07:27 -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 :mime-version; bh=zjQZ76Eim8tsdqtorgdXXSDIuePsLPYyrOL7i2GtWmA=; b=LYVCkrc24cxKfJB8tZXDIvNmOvXPPyIMyflfktgjzyZpRkkl2IexW3mKhihICQjDD1 jOdxWw8X0VPKYHUvbHjCrHbeSzuC4dFtf/mmacoTXV4ngcBEDaxuoE9HLIzPvo5JwXp1 W0d+mjpIYvrj5TQ2jhGwWYae+5axZK4Am1iRM= 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:mime-version; bh=zjQZ76Eim8tsdqtorgdXXSDIuePsLPYyrOL7i2GtWmA=; b=FicHRZYGTsIWxYHYKQLjg9RAWznzQDVZ0HQN2qVZme3930HvE+xDwr37/P0sv/0kG2 YDci6sQEUmw/TcLTyiD2kDg4XqSqEaqfrPhCVxaYOZMCdzOfVWBJkCO82goI3flQ6/bU vee9ir+6TZU25kxiX7qcIcIni3ZQZRQq6VdP5EuSGmnx3dpTcsSm5VSffL3UdzfPVwJh sXdN9pl3B/JmREhczvZZB9HJKoyIimr59f+FVmeyJd1OwZ1+nPfZvmR4Gvx+5qkZ5saw dBRyM3DWbTCVBZI+tZpTAhLwDzLuScDTQAPtht63cGCMw+agGbDjvn8IBbTNz1VvuRZc YoJA== X-Gm-Message-State: AOAM532sTFgyWfQzlT6yUOGgZp8P2k3dQIhMc3aEVEPQjLlCdky5zrFa ZMUt9Z3D4Oy6QCl4T44XATVIYwSz5NM7U8b54Ebz461+gE8qQZYXs3U8m9oiFdTDT0KvlrObNHl bFhsO0Q8JR9WO0ktrWF9hjl4tat6pj59MPd3r6P8Yss50phwtHC1DLUDg8aNrSaA= X-Google-Smtp-Source: ABdhPJw7a5BzYr8MXlpInoNT4ek83iu2EY9tyUCXd+LILIpAD3R6j1opRmF3ZMR0dv9D3eDmxjEX2Q== X-Received: by 2002:a17:902:728e:b029:101:c3b7:a47f with SMTP id d14-20020a170902728eb0290101c3b7a47fmr10320823pll.21.1623542846177; Sat, 12 Jun 2021 17:07:26 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id gg22sm12774609pjb.17.2021.06.12.17.07.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Jun 2021 17:07:25 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Farah Smith , Venkat Duvvuru , Randy Schacher Date: Sat, 12 Jun 2021 17:06:15 -0700 Message-Id: <20210613000652.28191-22-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20210613000652.28191-1-ajit.khaparde@broadcom.com> References: <20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com> <20210613000652.28191-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH v2 21/58] net/bnxt: add API to get shared table increments X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Farah Smith Add TRUFLOW API to get the shared table increment value for a given TRUFLOW table type. The API is being added for Wh+ and Thor devices. Signed-off-by: Farah Smith Signed-off-by: Venkat Duvvuru Reviewed-by: Randy Schacher Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_core/tf_core.c | 52 +++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_core.h | 34 ++++++++++++++- drivers/net/bnxt/tf_core/tf_device.h | 17 ++++++++ drivers/net/bnxt/tf_core/tf_device_p4.c | 25 +++++++++++ drivers/net/bnxt/tf_core/tf_device_p58.c | 44 +++++++++++++++++++ drivers/net/bnxt/tf_core/tf_tcam_shared.c | 22 +++++++--- 6 files changed, 188 insertions(+), 6 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 73dbee2940..0fbbd40252 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -1415,6 +1415,58 @@ tf_bulk_get_tbl_entry(struct tf *tfp, return rc; } +int tf_get_shared_tbl_increment(struct tf *tfp, + struct tf_get_shared_tbl_increment_parms *parms) +{ + int rc = 0; + struct tf_session *tfs; + struct tf_dev_info *dev; + + TF_CHECK_PARMS2(tfp, parms); + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup device, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + /* Internal table type processing */ + + if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "%s: Operation not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return -EOPNOTSUPP; + } + + rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Get table increment not supported, rc:%s\n", + tf_dir_2_str(parms->dir), + strerror(-rc)); + return rc; + } + + return rc; +} + int tf_alloc_tbl_scope(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms) diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 95cde2e8eb..44c30fa904 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -848,7 +848,6 @@ struct tf_get_session_info_parms { */ int tf_get_session_info(struct tf *tfp, struct tf_get_session_info_parms *parms); - /** * Experimental * @@ -1594,6 +1593,8 @@ int tf_move_tcam_shared_entries(struct tf *tfp, * @ref tf_get_tbl_entry * * @ref tf_bulk_get_tbl_entry + * + * @ref tf_get_shared_tbl_increment */ /** @@ -1844,6 +1845,37 @@ struct tf_set_tbl_entry_parms { int tf_set_tbl_entry(struct tf *tfp, struct tf_set_tbl_entry_parms *parms); +/** + * tf_get_shared_tbl_increment parameter definition + */ +struct tf_get_shared_tbl_increment_parms { + /** + * [in] Receive or transmit direction + */ + enum tf_dir dir; + /** + * [in] Type of object to set + */ + enum tf_tbl_type type; + /** + * [out] Value to increment by for resource type + */ + uint32_t increment_cnt; +}; + +/** + * tf_get_shared_tbl_increment + * + * This API is currently only required for use in the shared + * session for Thor (p58) actions. An increment count is returned per + * type to indicate how much to increment the start by for each + * entry (see tf_resource_info) + * + * Returns success or failure code. + */ +int tf_get_shared_tbl_increment(struct tf *tfp, + struct tf_get_shared_tbl_increment_parms *parms); + /** * tf_get_tbl_entry parameter definition */ diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index 48ab17d56b..1893f630e7 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -446,6 +446,23 @@ struct tf_dev_ops { int (*tf_dev_get_bulk_tbl)(struct tf *tfp, struct tf_tbl_get_bulk_parms *parms); + /** + * Gets the increment value to add to the shared session resource + * start offset by for each count in the "stride" + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to get shared tbl increment parameters + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ + int (*tf_dev_get_shared_tbl_increment)(struct tf *tfp, + struct tf_get_shared_tbl_increment_parms *parms); + /** * Retrieves the table resource info. * diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 67ef765236..239784897d 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -190,6 +190,26 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused, return 0; } +/** + * Device specific function that retrieves the increment + * required for certain table types in a shared session + * + * [in] tfp + * tf handle + * + * [in/out] parms + * pointer to parms structure + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int tf_dev_p4_get_shared_tbl_increment(struct tf *tfp __rte_unused, + struct tf_get_shared_tbl_increment_parms *parms) +{ + parms->increment_cnt = 1; + return 0; +} static int tf_dev_p4_get_mailbox(void) { return TF_KONG_MB; @@ -221,12 +241,16 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_set_ext_tbl = NULL, .tf_dev_get_tbl = NULL, .tf_dev_get_bulk_tbl = NULL, + .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment, .tf_dev_get_tbl_resc_info = NULL, .tf_dev_alloc_tcam = NULL, .tf_dev_free_tcam = NULL, .tf_dev_alloc_search_tcam = NULL, .tf_dev_set_tcam = NULL, .tf_dev_get_tcam = NULL, +#ifdef TF_TCAM_SHARED + .tf_dev_move_tcam = NULL, +#endif /* TF_TCAM_SHARED */ .tf_dev_get_tcam_resc_info = NULL, .tf_dev_insert_int_em_entry = NULL, .tf_dev_delete_int_em_entry = NULL, @@ -266,6 +290,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_set_ext_tbl = tf_tbl_ext_common_set, .tf_dev_get_tbl = tf_tbl_get, .tf_dev_get_bulk_tbl = tf_tbl_bulk_get, + .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment, .tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info, #ifdef TF_TCAM_SHARED .tf_dev_alloc_tcam = tf_tcam_shared_alloc, diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index fd2703129f..483f771999 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -151,6 +151,48 @@ static int tf_dev_p58_word_align(uint16_t size) return ((((size) + 63) >> 6) * 8); } +/** + * Device specific function that retrieves the increment + * required for certain table types in a shared session + * + * [in] tfp + * tf handle + * + * [in/out] parms + * pointer to parms structure + * + * Returns + * - (0) if successful. + * - (-EINVAL) on failure. + */ +static int tf_dev_p58_get_shared_tbl_increment(struct tf *tfp __rte_unused, + struct tf_get_shared_tbl_increment_parms *parms) +{ + switch (parms->type) { + case TF_TBL_TYPE_FULL_ACT_RECORD: + case TF_TBL_TYPE_COMPACT_ACT_RECORD: + case TF_TBL_TYPE_ACT_ENCAP_8B: + case TF_TBL_TYPE_ACT_ENCAP_16B: + case TF_TBL_TYPE_ACT_ENCAP_32B: + case TF_TBL_TYPE_ACT_ENCAP_64B: + case TF_TBL_TYPE_ACT_SP_SMAC: + case TF_TBL_TYPE_ACT_SP_SMAC_IPV4: + case TF_TBL_TYPE_ACT_SP_SMAC_IPV6: + case TF_TBL_TYPE_ACT_STATS_64: + case TF_TBL_TYPE_ACT_MODIFY_IPV4: + case TF_TBL_TYPE_ACT_MODIFY_8B: + case TF_TBL_TYPE_ACT_MODIFY_16B: + case TF_TBL_TYPE_ACT_MODIFY_32B: + case TF_TBL_TYPE_ACT_MODIFY_64B: + parms->increment_cnt = 8; + break; + default: + parms->increment_cnt = 1; + break; + } + return 0; +} + #define TF_DEV_P58_BANK_SZ_64B 2048 /** * Get SRAM table information. @@ -243,6 +285,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = { .tf_dev_set_ext_tbl = NULL, .tf_dev_get_tbl = NULL, .tf_dev_get_bulk_tbl = NULL, + .tf_dev_get_shared_tbl_increment = tf_dev_p58_get_shared_tbl_increment, .tf_dev_get_tbl_resc_info = NULL, .tf_dev_alloc_tcam = NULL, .tf_dev_free_tcam = NULL, @@ -288,6 +331,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = { .tf_dev_set_ext_tbl = tf_tbl_ext_common_set, .tf_dev_get_tbl = tf_tbl_get, .tf_dev_get_bulk_tbl = tf_tbl_bulk_get, + .tf_dev_get_shared_tbl_increment = tf_dev_p58_get_shared_tbl_increment, .tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info, #ifdef TF_TCAM_SHARED .tf_dev_alloc_tcam = tf_tcam_shared_alloc, diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c index 0e8cb78f8d..f0727cea80 100644 --- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c +++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c @@ -858,6 +858,10 @@ union tf_tmp_key { uint8_t bytes[(TF_TMP_MAX_KEY_BITLEN + 7) / 8]; }; +/** p58 has an enable bit, p4 does not + */ +#define TF_TCAM_SHARED_ENTRY_ENABLE 0x8 + /** Move a WC TCAM entry from the high offset to the same low offset */ static int @@ -869,7 +873,8 @@ tf_tcam_shared_move_entry(struct tf *tfp, int dphy_idx, int key_sz_bytes, int remap_sz_bytes, - uint16_t num_slices) + uint16_t num_slices, + bool set_enable_bit) { int rc = 0; struct tf_tcam_get_parms gparms; @@ -911,6 +916,9 @@ tf_tcam_shared_move_entry(struct tf *tfp, return rc; } + if (set_enable_bit) + tcam_key_obj.bytes[0] |= TF_TCAM_SHARED_ENTRY_ENABLE; + /* Override HI/LO type with parent WC TCAM type */ sparms.hcapi_type = hcapi_type; sparms.dir = dir; @@ -960,7 +968,8 @@ static int tf_tcam_shared_move(struct tf *tfp, struct tf_move_tcam_shared_entries_parms *parms, int key_sz_bytes, - int remap_sz_bytes) + int remap_sz_bytes, + bool set_enable_bit) { int rc; struct tf_session *tfs; @@ -1084,7 +1093,8 @@ int tf_tcam_shared_move(struct tf *tfp, lo_start + log_idx, key_sz_bytes, remap_sz_bytes, - num_slices); + num_slices, + set_enable_bit); if (rc) { TFP_DRV_LOG(ERR, "Cannot allocate %s index %d\n", @@ -1125,7 +1135,8 @@ int tf_tcam_shared_move_p4(struct tf *tfp, rc = tf_tcam_shared_move(tfp, parms, TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4, - TF_TCAM_SHARED_REMAP_SZ_BYTES_P4); + TF_TCAM_SHARED_REMAP_SZ_BYTES_P4, + false); /* no enable bit */ return rc; } @@ -1139,6 +1150,7 @@ int tf_tcam_shared_move_p58(struct tf *tfp, rc = tf_tcam_shared_move(tfp, parms, TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58, - TF_TCAM_SHARED_REMAP_SZ_BYTES_P58); + TF_TCAM_SHARED_REMAP_SZ_BYTES_P58, + true); /* set enable bit */ return rc; }