From patchwork Fri Aug 27 06:57:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 97451 X-Patchwork-Delegate: ferruh.yigit@amd.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 D0A48A0C41; Fri, 27 Aug 2021 09:01:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6824F412A2; Fri, 27 Aug 2021 08:59:12 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 3845141269 for ; Fri, 27 Aug 2021 08:59:11 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 00D147F6E6; Fri, 27 Aug 2021 09:59:10 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 8FD887F6F5; Fri, 27 Aug 2021 09:57:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 8FD887F6F5 Authentication-Results: shelob.oktetlabs.ru/8FD887F6F5; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Viacheslav Galaktionov , Andy Moreton Date: Fri, 27 Aug 2021 09:57:13 +0300 Message-Id: <20210827065717.1838258-35-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> References: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 34/38] net/sfc: include controller and port in representor name 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: Viacheslav Galaktionov Make representor names unique on multi-host configurations. Signed-off-by: Viacheslav Galaktionov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_repr.c | 28 ++++++++++++++++++++++++++-- drivers/net/sfc/sfc_switch.c | 28 ++++++++++++++++++++++++++++ drivers/net/sfc/sfc_switch.h | 4 ++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_repr.c b/drivers/net/sfc/sfc_repr.c index a42e70c92c..d50efe6562 100644 --- a/drivers/net/sfc/sfc_repr.c +++ b/drivers/net/sfc/sfc_repr.c @@ -1050,11 +1050,35 @@ sfc_repr_create(struct rte_eth_dev *parent, { struct sfc_repr_init_data repr_data; char name[RTE_ETH_NAME_MAX_LEN]; + int controller; int ret; + int rc; struct rte_eth_dev *dev; - if (snprintf(name, sizeof(name), "net_%s_representor_%u", - parent->device->name, entity->vf) >= (int)sizeof(name)) { + controller = -1; + rc = sfc_mae_switch_domain_get_controller(switch_domain_id, + entity->intf, &controller); + if (rc != 0) { + SFC_GENERIC_LOG(ERR, "%s() failed to get DPDK controller for %d", + __func__, entity->intf); + return -rc; + } + + switch (entity->type) { + case RTE_ETH_REPRESENTOR_VF: + ret = snprintf(name, sizeof(name), "net_%s_representor_c%upf%uvf%u", + parent->device->name, controller, entity->pf, + entity->vf); + break; + case RTE_ETH_REPRESENTOR_PF: + ret = snprintf(name, sizeof(name), "net_%s_representor_c%upf%u", + parent->device->name, controller, entity->pf); + break; + default: + return -ENOTSUP; + } + + if (ret >= (int)sizeof(name)) { SFC_GENERIC_LOG(ERR, "%s() failed name too long", __func__); return -ENAMETOOLONG; } diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c index 7a0b332f33..225d07fa15 100644 --- a/drivers/net/sfc/sfc_switch.c +++ b/drivers/net/sfc/sfc_switch.c @@ -279,6 +279,34 @@ sfc_mae_switch_domain_map_controllers(uint16_t switch_domain_id, return 0; } +int +sfc_mae_switch_domain_get_controller(uint16_t switch_domain_id, + efx_pcie_interface_t intf, + int *controller) +{ + const efx_pcie_interface_t *controllers; + size_t nb_controllers; + size_t i; + int rc; + + rc = sfc_mae_switch_domain_controllers(switch_domain_id, &controllers, + &nb_controllers); + if (rc != 0) + return rc; + + if (controllers == NULL) + return ENOENT; + + for (i = 0; i < nb_controllers; i++) { + if (controllers[i] == intf) { + *controller = i; + return 0; + } + } + + return ENOENT; +} + /* This function expects to be called only when the lock is held */ static struct sfc_mae_switch_port * sfc_mae_find_switch_port_by_entity(const struct sfc_mae_switch_domain *domain, diff --git a/drivers/net/sfc/sfc_switch.h b/drivers/net/sfc/sfc_switch.h index a072507375..294baae9a2 100644 --- a/drivers/net/sfc/sfc_switch.h +++ b/drivers/net/sfc/sfc_switch.h @@ -63,6 +63,10 @@ int sfc_mae_switch_domain_map_controllers(uint16_t switch_domain_id, efx_pcie_interface_t *controllers, size_t nb_controllers); +int sfc_mae_switch_domain_get_controller(uint16_t switch_domain_id, + efx_pcie_interface_t intf, + int *controller); + int sfc_mae_assign_switch_port(uint16_t switch_domain_id, const struct sfc_mae_switch_port_request *req, uint16_t *switch_port_id);