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 853BCA04DD; Tue, 20 Oct 2020 11:10:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 295ACCFB1; Tue, 20 Oct 2020 10:50:32 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 2D244BBC2 for ; Tue, 20 Oct 2020 10:49:08 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.61]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 947686008F for ; Tue, 20 Oct 2020 08:49:06 +0000 (UTC) Received: from us4-mdac16-75.ut7.mdlocal (unknown [10.7.64.194]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 953168009E for ; Tue, 20 Oct 2020 08:49:06 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.199]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 23A4680057 for ; Tue, 20 Oct 2020 08:49:05 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id CE5BE18005B for ; Tue, 20 Oct 2020 08:49:04 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Oct 2020 09:48:50 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 20 Oct 2020 09:48:50 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 09K8moXo030863; Tue, 20 Oct 2020 09:48:50 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id EE6471613BE; Tue, 20 Oct 2020 09:48:49 +0100 (BST) From: Andrew Rybchenko To: CC: , Ivan Malov Date: Tue, 20 Oct 2020 09:48:09 +0100 Message-ID: <1603183709-23420-43-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> References: <1603183709-23420-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25736.003 X-TM-AS-Result: No-3.017700-8.000000-10 X-TMASE-MatchedRID: sYi+h+oAOhT90dfary0jKDPF07YFM7bTa01mhnn7t6TplCKCpVh6EKq9 0Gjn1y697hDaMZWnA/ExXjnD5osbhP1PYuSZ5yXpqJSK+HSPY+/pVMb1xnESMgaYevV4zG3ZQBz oPKhLasitcw7GcMT4xCU0wC5DqKBIeEvDBxAaKu0Pe5gzF3TVt7qGBW9J0Yqje7ijHq7g9oY6ZF n4DNCez5Mtkj+Hp5J39OL9KY9jgW4YB2fOueQzjxRFJJyf5BJe0AMabguiKJP6C0ePs7A07X1Hh KzShSYnctGEZzK2aB7esV1a3n7zixIep12qiNx4E2x16uMCY42SEWPXfMCsVPtRkLrI9ieM4L6E wG9oaSm4DRfskASiEDLh4ElT3qLg2kC7SwvGlKhDwb7Jglhh1lFkOwaJdCKgGObbx/Uctjc= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.017700-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25736.003 X-MDID: 1603183745-CMylSaI6B9ds X-PPE-DISP: 1603183745;CMylSaI6B9ds Subject: [dpdk-dev] [PATCH 42/62] net/sfc: add HW switch ID helpers 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: Ivan Malov The driver will need a means to figure out relationship between RTE ethdev instances and underlying HW switch entities. For now, use board serial number string as a unique HW switch identifier. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.c | 44 +++++++++++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc.h | 8 ++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 3b896490f7..a4fe495788 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -1259,3 +1259,47 @@ sfc_register_logtype(const struct rte_pci_addr *pci_addr, return ret; } + +struct sfc_hw_switch_id { + char board_sn[RTE_SIZEOF_FIELD(efx_nic_board_info_t, enbi_serial)]; +}; + +int +sfc_hw_switch_id_init(struct sfc_adapter *sa, + struct sfc_hw_switch_id **idp) +{ + efx_nic_board_info_t board_info; + struct sfc_hw_switch_id *id; + int rc; + + if (idp == NULL) + return EINVAL; + + id = rte_zmalloc("sfc_hw_switch_id", sizeof(*id), 0); + if (id == NULL) + return ENOMEM; + + rc = efx_nic_get_board_info(sa->nic, &board_info); + if (rc != 0) + return rc; + + memcpy(id->board_sn, board_info.enbi_serial, sizeof(id->board_sn)); + + *idp = id; + + return 0; +} + +void +sfc_hw_switch_id_fini(__rte_unused struct sfc_adapter *sa, + struct sfc_hw_switch_id *id) +{ + rte_free(id); +} + +bool +sfc_hw_switch_ids_equal(const struct sfc_hw_switch_id *left, + const struct sfc_hw_switch_id *right) +{ + return strcmp(left->board_sn, right->board_sn) == 0; +} diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 4b5d687108..ed059e142f 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -403,6 +403,14 @@ int sfc_port_reset_mac_stats(struct sfc_adapter *sa); int sfc_set_rx_mode(struct sfc_adapter *sa); int sfc_set_rx_mode_unchecked(struct sfc_adapter *sa); +struct sfc_hw_switch_id; + +int sfc_hw_switch_id_init(struct sfc_adapter *sa, + struct sfc_hw_switch_id **idp); +void sfc_hw_switch_id_fini(struct sfc_adapter *sa, + struct sfc_hw_switch_id *idp); +bool sfc_hw_switch_ids_equal(const struct sfc_hw_switch_id *left, + const struct sfc_hw_switch_id *right); #ifdef __cplusplus } -- 2.17.1