From patchwork Sun May 30 08:58:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkat Duvvuru X-Patchwork-Id: 93552 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 41A68A0524; Sun, 30 May 2021 11:00:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE4AD410E0; Sun, 30 May 2021 11:00:33 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (saphodev.broadcom.com [192.19.11.229]) by mails.dpdk.org (Postfix) with ESMTP id 27A6B40E28 for ; Sun, 30 May 2021 11:00:31 +0200 (CEST) Received: from S60.dhcp.broadcom.net (unknown [10.123.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 8734E7DC0; Sun, 30 May 2021 02:00:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 8734E7DC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1622365230; bh=KNVQC4OANG2Q/PLaz9fXON/OdDRoyCLL6mb1HG7ZHsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ug3zoM226cZbt7EOELMST/91NFamsSF2mafIjVoyyGDxIQpvMgDeMXsNU7lYax8YB gq2pn9EnhwHtehNMRG3aMnagB72uc9IijuI9VrmuVCYk7IncgWsk9yJ2aYsvEdTf6S KdEj4+IeZ1OLNM1qjeDwFzkDyUZ7w+QOD5TcW+Yo= From: Venkat Duvvuru To: dev@dpdk.org Cc: Peter Spreadborough , Randy Schacher , Venkat Duvvuru Date: Sun, 30 May 2021 14:28:34 +0530 Message-Id: <20210530085929.29695-4-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com> References: <20210530085929.29695-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 03/58] net/bnxt: add mailbox selection via dev op 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: Peter Spreadborough Add get mailbox dev op so that mailbox offset is based on device rather than hard coded. Signed-off-by: Peter Spreadborough Signed-off-by: Randy Schacher Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith --- drivers/net/bnxt/tf_core/tf_device.c | 21 ++ drivers/net/bnxt/tf_core/tf_device.h | 12 + drivers/net/bnxt/tf_core/tf_device_p4.c | 8 + drivers/net/bnxt/tf_core/tf_device_p58.c | 7 + drivers/net/bnxt/tf_core/tf_msg.c | 410 +++++++++++++++++++++-- drivers/net/bnxt/tf_core/tf_msg.h | 12 +- drivers/net/bnxt/tf_core/tf_rm.c | 2 + drivers/net/bnxt/tf_core/tf_session.c | 22 +- drivers/net/bnxt/tf_core/tf_tcam.c | 4 +- 9 files changed, 463 insertions(+), 35 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 9c63f6d5d4..5116601a69 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -461,6 +461,27 @@ tf_dev_bind(struct tf *tfp __rte_unused, } } +int +tf_dev_bind_ops(enum tf_device_type type, + struct tf_dev_info *dev_handle) +{ + switch (type) { + case TF_DEVICE_TYPE_WH: + case TF_DEVICE_TYPE_SR: + dev_handle->ops = &tf_dev_ops_p4; + break; + case TF_DEVICE_TYPE_THOR: + dev_handle->ops = &tf_dev_ops_p58; + break; + default: + TFP_DRV_LOG(ERR, + "No such device\n"); + return -ENODEV; + } + + return 0; +} + int tf_dev_unbind(struct tf *tfp, struct tf_dev_info *dev_handle) diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index d5ef72309f..cbacc09ea5 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -108,6 +108,10 @@ int tf_dev_bind(struct tf *tfp, int tf_dev_unbind(struct tf *tfp, struct tf_dev_info *dev_handle); +int +tf_dev_bind_ops(enum tf_device_type type, + struct tf_dev_info *dev_handle); + /** * Truflow device specific function hooks structure * @@ -724,6 +728,14 @@ struct tf_dev_ops { */ int (*tf_dev_get_global_cfg)(struct tf *tfp, struct tf_global_cfg_parms *parms); + + /** + * Get mailbox + * + * returns: + * mailbox + */ + int (*tf_dev_get_mailbox)(void); }; /** diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 257a0fb2d0..6b28f6ce59 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -13,6 +13,7 @@ #include "tf_em.h" #include "tf_if_tbl.h" #include "tfp.h" +#include "tf_msg_common.h" #define TF_DEV_P4_PARIF_MAX 16 #define TF_DEV_P4_PF_MASK 0xfUL @@ -241,6 +242,11 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused, return 0; } +static int tf_dev_p4_get_mailbox(void) +{ + return TF_KONG_MB; +} + /** * Truflow P4 device specific functions @@ -278,6 +284,7 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_get_if_tbl = NULL, .tf_dev_set_global_cfg = NULL, .tf_dev_get_global_cfg = NULL, + .tf_dev_get_mailbox = tf_dev_p4_get_mailbox, }; /** @@ -316,4 +323,5 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_get_if_tbl = tf_if_tbl_get, .tf_dev_set_global_cfg = tf_global_cfg_set, .tf_dev_get_global_cfg = tf_global_cfg_get, + .tf_dev_get_mailbox = tf_dev_p4_get_mailbox, }; diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index fb5ad29a5c..b4530f8762 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -13,6 +13,7 @@ #include "tf_em.h" #include "tf_if_tbl.h" #include "tfp.h" +#include "tf_msg_common.h" #define TF_DEV_P58_PARIF_MAX 16 #define TF_DEV_P58_PF_MASK 0xfUL @@ -206,6 +207,10 @@ tf_dev_p58_map_parif(struct tf *tfp __rte_unused, return 0; } +static int tf_dev_p58_get_mailbox(void) +{ + return TF_CHIMP_MB; +} /** * Truflow P58 device specific functions @@ -243,6 +248,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = { .tf_dev_get_if_tbl = NULL, .tf_dev_set_global_cfg = NULL, .tf_dev_get_global_cfg = NULL, + .tf_dev_get_mailbox = tf_dev_p58_get_mailbox, }; /** @@ -281,4 +287,5 @@ const struct tf_dev_ops tf_dev_ops_p58 = { .tf_dev_get_if_tbl = tf_if_tbl_get, .tf_dev_set_global_cfg = tf_global_cfg_set, .tf_dev_get_global_cfg = tf_global_cfg_get, + .tf_dev_get_mailbox = tf_dev_p58_get_mailbox, }; diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index f20a5113bf..1007211363 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -116,7 +116,8 @@ int tf_msg_session_open(struct tf *tfp, char *ctrl_chan_name, uint8_t *fw_session_id, - uint8_t *fw_session_client_id) + uint8_t *fw_session_client_id, + struct tf_dev_info *dev) { int rc; struct hwrm_tf_session_open_input req = { 0 }; @@ -131,7 +132,7 @@ tf_msg_session_open(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -155,6 +156,7 @@ tf_msg_session_attach(struct tf *tfp __rte_unused, int tf_msg_session_client_register(struct tf *tfp, + struct tf_session *tfs, char *ctrl_channel_name, uint8_t *fw_session_client_id) { @@ -163,6 +165,16 @@ tf_msg_session_client_register(struct tf *tfp, struct hwrm_tf_session_register_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; + struct tf_dev_info *dev; + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -183,7 +195,7 @@ tf_msg_session_client_register(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -198,6 +210,7 @@ tf_msg_session_client_register(struct tf *tfp, int tf_msg_session_client_unregister(struct tf *tfp, + struct tf_session *tfs, uint8_t fw_session_client_id) { int rc; @@ -205,6 +218,16 @@ tf_msg_session_client_unregister(struct tf *tfp, struct hwrm_tf_session_unregister_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; + struct tf_dev_info *dev; + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -223,7 +246,7 @@ tf_msg_session_client_unregister(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -232,13 +255,24 @@ tf_msg_session_client_unregister(struct tf *tfp, } int -tf_msg_session_close(struct tf *tfp) +tf_msg_session_close(struct tf *tfp, + struct tf_session *tfs) { int rc; struct hwrm_tf_session_close_input req = { 0 }; struct hwrm_tf_session_close_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; + struct tf_dev_info *dev; + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -256,7 +290,7 @@ tf_msg_session_close(struct tf *tfp) parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -271,6 +305,26 @@ tf_msg_session_qcfg(struct tf *tfp) struct hwrm_tf_session_qcfg_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup session, rc:%s\n", + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -288,7 +342,7 @@ tf_msg_session_qcfg(struct tf *tfp) parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -297,6 +351,7 @@ tf_msg_session_qcfg(struct tf *tfp) int tf_msg_session_resc_qcaps(struct tf *tfp, + struct tf_dev_info *dev, enum tf_dir dir, uint16_t size, struct tf_rm_resc_req_entry *query, @@ -340,7 +395,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); if (rc) @@ -378,6 +433,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp, int tf_msg_session_resc_alloc(struct tf *tfp, + struct tf_dev_info *dev, enum tf_dir dir, uint16_t size, struct tf_rm_resc_req_entry *request, @@ -439,7 +495,7 @@ tf_msg_session_resc_alloc(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); if (rc) @@ -487,9 +543,31 @@ tf_msg_session_resc_flush(struct tf *tfp, struct tf_msg_dma_buf resv_buf = { 0 }; struct tf_rm_resc_entry *resv_data; int dma_size; + struct tf_dev_info *dev; + struct tf_session *tfs; TF_CHECK_PARMS2(tfp, resv); + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(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(dir), + strerror(-rc)); + return rc; + } + rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { TFP_DRV_LOG(ERR, @@ -524,7 +602,7 @@ tf_msg_session_resc_flush(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -549,6 +627,28 @@ tf_msg_insert_em_internal_entry(struct tf *tfp, uint16_t flags; uint8_t fw_session_id; uint8_t msg_key_size; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(em_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(em_parms->dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -593,7 +693,7 @@ tf_msg_insert_em_internal_entry(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -617,6 +717,28 @@ tf_msg_delete_em_entry(struct tf *tfp, struct hwrm_tf_em_delete_output resp = { 0 }; uint16_t flags; uint8_t fw_session_id; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(em_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(em_parms->dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -641,7 +763,7 @@ tf_msg_delete_em_entry(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -664,6 +786,26 @@ tf_msg_em_mem_rgtr(struct tf *tfp, struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 }; struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup session, rc:%s\n", + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } req.page_level = page_lvl; req.page_size = page_size; @@ -674,7 +816,7 @@ tf_msg_em_mem_rgtr(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -694,6 +836,26 @@ tf_msg_em_mem_unrgtr(struct tf *tfp, struct hwrm_tf_ctxt_mem_unrgtr_input req = {0}; struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0}; struct tfp_send_msg_parms parms = { 0 }; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup session, rc:%s\n", + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } req.ctx_id = tfp_cpu_to_le_32(*ctx_id); @@ -702,7 +864,7 @@ tf_msg_em_mem_unrgtr(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -719,6 +881,28 @@ tf_msg_em_qcaps(struct tf *tfp, struct hwrm_tf_ext_em_qcaps_output resp = { 0 }; uint32_t flags; struct tfp_send_msg_parms parms = { 0 }; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(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(dir), + strerror(-rc)); + return rc; + } flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX : HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX); @@ -729,7 +913,7 @@ tf_msg_em_qcaps(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -762,6 +946,28 @@ tf_msg_em_cfg(struct tf *tfp, struct hwrm_tf_ext_em_cfg_output resp = {0}; uint32_t flags; struct tfp_send_msg_parms parms = { 0 }; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(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(dir), + strerror(-rc)); + return rc; + } flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX : HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX); @@ -782,7 +988,7 @@ tf_msg_em_cfg(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -799,6 +1005,28 @@ tf_msg_em_op(struct tf *tfp, struct hwrm_tf_ext_em_op_output resp = {0}; uint32_t flags; struct tfp_send_msg_parms parms = { 0 }; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(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(dir), + strerror(-rc)); + return rc; + } flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX : HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX); @@ -810,7 +1038,7 @@ tf_msg_em_op(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -819,6 +1047,7 @@ tf_msg_em_op(struct tf *tfp, int tf_msg_tcam_entry_set(struct tf *tfp, + struct tf_dev_info *dev, struct tf_tcam_set_parms *parms) { int rc; @@ -877,7 +1106,7 @@ tf_msg_tcam_entry_set(struct tf *tfp, mparms.req_size = sizeof(req); mparms.resp_data = (uint32_t *)&resp; mparms.resp_size = sizeof(resp); - mparms.mailbox = TF_KONG_MB; + mparms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &mparms); @@ -890,6 +1119,7 @@ tf_msg_tcam_entry_set(struct tf *tfp, int tf_msg_tcam_entry_free(struct tf *tfp, + struct tf_dev_info *dev, struct tf_tcam_free_parms *in_parms) { int rc; @@ -920,7 +1150,7 @@ tf_msg_tcam_entry_free(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -940,6 +1170,28 @@ tf_msg_set_tbl_entry(struct tf *tfp, struct hwrm_tf_tbl_type_set_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(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(dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -976,7 +1228,7 @@ tf_msg_set_tbl_entry(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -999,6 +1251,28 @@ tf_msg_get_tbl_entry(struct tf *tfp, struct hwrm_tf_tbl_type_get_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; uint8_t fw_session_id; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(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(dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -1020,7 +1294,7 @@ tf_msg_get_tbl_entry(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -1051,6 +1325,28 @@ tf_msg_get_global_cfg(struct tf *tfp, uint32_t flags = 0; uint8_t fw_session_id; uint16_t resp_size = 0; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(params->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(params->dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -1077,7 +1373,7 @@ tf_msg_get_global_cfg(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); if (rc != 0) @@ -1108,6 +1404,28 @@ tf_msg_set_global_cfg(struct tf *tfp, struct hwrm_tf_global_cfg_set_output resp = { 0 }; uint32_t flags = 0; uint8_t fw_session_id; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "%s: Failed to lookup session, rc:%s\n", + tf_dir_2_str(params->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(params->dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -1156,7 +1474,7 @@ tf_msg_set_global_cfg(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -1181,6 +1499,28 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp, struct tf_tbl_type_bulk_get_output resp = { 0 }; int data_size = 0; uint8_t fw_session_id; + struct tf_dev_info *dev; + struct tf_session *tfs; + + /* 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(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(dir), + strerror(-rc)); + return rc; + } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { @@ -1203,7 +1543,7 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp, req.host_addr = tfp_cpu_to_le_64(physical_mem_addr); MSG_PREP(parms, - TF_KONG_MB, + dev->ops->tf_dev_get_mailbox(), HWRM_TF, HWRM_TFT_TBL_TYPE_BULK_GET, req, @@ -1229,6 +1569,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp, struct hwrm_tf_if_tbl_get_input req = { 0 }; struct hwrm_tf_if_tbl_get_output resp = { 0 }; uint32_t flags = 0; + struct tf_dev_info *dev; struct tf_session *tfs; /* Retrieve the session information */ @@ -1241,6 +1582,16 @@ tf_msg_get_if_tbl_entry(struct tf *tfp, 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(params->dir), + strerror(-rc)); + return rc; + } + flags = (params->dir == TF_DIR_TX ? HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX : HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX); @@ -1258,7 +1609,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); @@ -1268,7 +1619,7 @@ tf_msg_get_if_tbl_entry(struct tf *tfp, if (parms.tf_resp_code != 0) return tfp_le_to_cpu_32(parms.tf_resp_code); - tfp_memcpy(¶ms->data[0], resp.data, req.size); + tfp_memcpy(params->data, resp.data, req.size); return tfp_le_to_cpu_32(parms.tf_resp_code); } @@ -1282,6 +1633,7 @@ tf_msg_set_if_tbl_entry(struct tf *tfp, struct hwrm_tf_if_tbl_set_input req = { 0 }; struct hwrm_tf_if_tbl_get_output resp = { 0 }; uint32_t flags = 0; + struct tf_dev_info *dev; struct tf_session *tfs; /* Retrieve the session information */ @@ -1294,6 +1646,10 @@ tf_msg_set_if_tbl_entry(struct tf *tfp, return rc; } + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) + return rc; flags = (params->dir == TF_DIR_TX ? HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX : @@ -1313,7 +1669,7 @@ tf_msg_set_if_tbl_entry(struct tf *tfp, parms.req_size = sizeof(req); parms.resp_data = (uint32_t *)&resp; parms.resp_size = sizeof(resp); - parms.mailbox = TF_KONG_MB; + parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tfp, &parms); diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h index 0a2566010c..25e29a554f 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.h +++ b/drivers/net/bnxt/tf_core/tf_msg.h @@ -36,7 +36,8 @@ struct tf; int tf_msg_session_open(struct tf *tfp, char *ctrl_chan_name, uint8_t *fw_session_id, - uint8_t *fw_session_client_id); + uint8_t *fw_session_client_id, + struct tf_dev_info *dev); /** * Sends session close request to Firmware @@ -75,6 +76,7 @@ int tf_msg_session_attach(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_session_client_register(struct tf *tfp, + struct tf_session *tfs, char *ctrl_channel_name, uint8_t *fw_session_client_id); @@ -92,6 +94,7 @@ int tf_msg_session_client_register(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_session_client_unregister(struct tf *tfp, + struct tf_session *tfs, uint8_t fw_session_client_id); /** @@ -103,7 +106,8 @@ int tf_msg_session_client_unregister(struct tf *tfp, * Returns: * 0 on Success else internal Truflow error */ -int tf_msg_session_close(struct tf *tfp); +int tf_msg_session_close(struct tf *tfp, + struct tf_session *tfs); /** * Sends session query config request to TF Firmware @@ -139,6 +143,7 @@ int tf_msg_session_qcfg(struct tf *tfp); * 0 on Success else internal Truflow error */ int tf_msg_session_resc_qcaps(struct tf *tfp, + struct tf_dev_info *dev, enum tf_dir dir, uint16_t size, struct tf_rm_resc_req_entry *query, @@ -166,6 +171,7 @@ int tf_msg_session_resc_qcaps(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_session_resc_alloc(struct tf *tfp, + struct tf_dev_info *dev, enum tf_dir dir, uint16_t size, struct tf_rm_resc_req_entry *request, @@ -368,6 +374,7 @@ int tf_msg_em_op(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_tcam_entry_set(struct tf *tfp, + struct tf_dev_info *dev, struct tf_tcam_set_parms *parms); /** @@ -383,6 +390,7 @@ int tf_msg_tcam_entry_set(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_tcam_entry_free(struct tf *tfp, + struct tf_dev_info *dev, struct tf_tcam_free_parms *parms); /** diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c index f93a6d9018..2c08fb80fe 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.c +++ b/drivers/net/bnxt/tf_core/tf_rm.c @@ -415,6 +415,7 @@ tf_rm_create_db(struct tf *tfp, /* Get Firmware Capabilities */ rc = tf_msg_session_resc_qcaps(tfp, + dev, parms->dir, max_types, query, @@ -499,6 +500,7 @@ tf_rm_create_db(struct tf *tfp, } rc = tf_msg_session_resc_alloc(tfp, + dev, parms->dir, hcapi_items, req, diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c index 6335ad358c..b3fa7e13ff 100644 --- a/drivers/net/bnxt/tf_core/tf_session.c +++ b/drivers/net/bnxt/tf_core/tf_session.c @@ -56,14 +56,19 @@ tf_session_create(struct tf *tfp, uint8_t fw_session_id; uint8_t fw_session_client_id; union tf_session_id *session_id; + struct tf_dev_info dev; TF_CHECK_PARMS2(tfp, parms); + tf_dev_bind_ops(parms->open_cfg->device_type, + &dev); + /* Open FW session and get a new session_id */ rc = tf_msg_session_open(tfp, parms->open_cfg->ctrl_chan_name, &fw_session_id, - &fw_session_client_id); + &fw_session_client_id, + &dev); if (rc) { /* Log error */ if (rc == -EEXIST) @@ -177,6 +182,13 @@ tf_session_create(struct tf *tfp, if (rc) return rc; + if (session->dev.ops->tf_dev_get_mailbox == NULL) { + /* Log error */ + TFP_DRV_LOG(ERR, + "No tf_dev_get_mailbox() defined for device\n"); + goto cleanup; + } + session->dev_init = true; return 0; @@ -234,8 +246,9 @@ tf_session_client_create(struct tf *tfp, rc = tf_msg_session_client_register (tfp, - parms->ctrl_chan_name, - &session_client_id.internal.fw_session_client_id); + session, + parms->ctrl_chan_name, + &session_client_id.internal.fw_session_client_id); if (rc) { TFP_DRV_LOG(ERR, "Failed to create client on session, rc:%s\n", @@ -346,6 +359,7 @@ tf_session_client_destroy(struct tf *tfp, rc = tf_msg_session_client_unregister (tfp, + tfs, parms->session_client_id.internal.fw_session_client_id); /* Log error, but continue. If FW fails we do not really have @@ -534,7 +548,7 @@ tf_session_close_session(struct tf *tfp, strerror(-rc)); } - rc = tf_msg_session_close(tfp); + rc = tf_msg_session_close(tfp, tfs); if (rc) { /* Log error */ TFP_DRV_LOG(ERR, diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c index 22bc01c95d..038aa40e92 100644 --- a/drivers/net/bnxt/tf_core/tf_tcam.c +++ b/drivers/net/bnxt/tf_core/tf_tcam.c @@ -428,7 +428,7 @@ tf_tcam_free(struct tf *tfp, if (rc) return rc; - rc = tf_msg_tcam_entry_free(tfp, parms); + rc = tf_msg_tcam_entry_free(tfp, dev, parms); if (rc) { /* Log error */ TFP_DRV_LOG(ERR, @@ -652,7 +652,7 @@ tf_tcam_set(struct tf *tfp __rte_unused, if (rc) return rc; - rc = tf_msg_tcam_entry_set(tfp, parms); + rc = tf_msg_tcam_entry_set(tfp, dev, parms); if (rc) { /* Log error */ TFP_DRV_LOG(ERR,