From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 35DE5A034F; Mon, 11 Oct 2021 16:53:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A737411D9; Mon, 11 Oct 2021 16:50:13 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id E5E6F411C3 for ; Mon, 11 Oct 2021 16:50:08 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id B543B7F705; Mon, 11 Oct 2021 17:50:08 +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 890487F719; Mon, 11 Oct 2021 17:49:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 890487F719 Authentication-Results: shelob.oktetlabs.ru/890487F719; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Viacheslav Galaktionov , Andy Moreton Date: Mon, 11 Oct 2021 17:48:53 +0300 Message-Id: <20211011144857.446802-35-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211011144857.446802-1-andrew.rybchenko@oktetlabs.ru> References: <20210827065717.1838258-1-andrew.rybchenko@oktetlabs.ru> <20211011144857.446802-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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 f87188ed7a..b4ff4da60a 100644 --- a/drivers/net/sfc/sfc_repr.c +++ b/drivers/net/sfc/sfc_repr.c @@ -1028,11 +1028,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); -- 2.30.2