Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/93768/?format=api
http://patches.dpdk.org/api/patches/93768/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210602094108.1575640-8-jiawenwu@trustnetic.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20210602094108.1575640-8-jiawenwu@trustnetic.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210602094108.1575640-8-jiawenwu@trustnetic.com", "date": "2021-06-02T09:40:51", "name": "[v5,07/24] net/ngbe: set MAC type and LAN id", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "f65d19d11b7eac622af19e508997a0a3ab338800", "submitter": { "id": 1932, "url": "http://patches.dpdk.org/api/people/1932/?format=api", "name": "Jiawen Wu", "email": "jiawenwu@trustnetic.com" }, "delegate": { "id": 3961, "url": "http://patches.dpdk.org/api/users/3961/?format=api", "username": "arybchenko", "first_name": "Andrew", "last_name": "Rybchenko", "email": "andrew.rybchenko@oktetlabs.ru" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20210602094108.1575640-8-jiawenwu@trustnetic.com/mbox/", "series": [ { "id": 17206, "url": "http://patches.dpdk.org/api/series/17206/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=17206", "date": "2021-06-02T09:40:44", "name": "net: ngbe PMD", "version": 5, "mbox": "http://patches.dpdk.org/series/17206/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/93768/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/93768/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id E6B37A0524;\n\tWed, 2 Jun 2021 11:40:23 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 849764111E;\n\tWed, 2 Jun 2021 11:39:48 +0200 (CEST)", "from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130])\n by mails.dpdk.org (Postfix) with ESMTP id 88F60410F8\n for <dev@dpdk.org>; Wed, 2 Jun 2021 11:39:45 +0200 (CEST)", "from wxdbg.localdomain.com (unknown [183.129.236.74])\n by esmtp6.qq.com (ESMTP) with\n id ; Wed, 02 Jun 2021 17:39:40 +0800 (CST)" ], "X-QQ-mid": "bizesmtp32t1622626780tfzrzl5s", "X-QQ-SSF": "01400000000000D0E000B00A0000000", "X-QQ-FEAT": "xmzaef4TE3dtr6ROoWXKmX+7VQGoOm7fTlP2xxQkQReMnTWne7UJMzylUM/ur\n MtzKdMndpp8lS1EPuSkAlEazIKhrZbX7URQprkm6TqEqtnHjkblooLMZYgRShMhUso7beBq\n CQe0qyJsq/luBWADtEwzvZYlbMdCNTJeVsXvRn8Jq9j8i5CGKQt8LDTagC39+jKReaEwXHL\n gRLRQrWK32iK3cUpgqI7jcvyCv7nU/6hUJgRyffSTjirw5l+ukRpOzsgWGuzZwGwbcNVGZV\n aJCyGdz9qTJdmAJKjCC8SmCajb1uBgxAdbOzJ0BOKubbZCE4jyWRCeVM/pO7I4Yl8MArK5I\n KRG5/PIPy+D7N3o38GIS/sg7YAu6g==", "X-QQ-GoodBg": "2", "From": "Jiawen Wu <jiawenwu@trustnetic.com>", "To": "dev@dpdk.org", "Cc": "Jiawen Wu <jiawenwu@trustnetic.com>", "Date": "Wed, 2 Jun 2021 17:40:51 +0800", "Message-Id": "<20210602094108.1575640-8-jiawenwu@trustnetic.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20210602094108.1575640-1-jiawenwu@trustnetic.com>", "References": "<20210602094108.1575640-1-jiawenwu@trustnetic.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-QQ-SENDSIZE": "520", "Feedback-ID": "bizesmtp:trustnetic.com:qybgforeign:qybgforeign5", "X-QQ-Bgrelay": "1", "Subject": "[dpdk-dev] [PATCH v5 07/24] net/ngbe: set MAC type and LAN id", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Initialize the shared code.\n\nSigned-off-by: Jiawen Wu <jiawenwu@trustnetic.com>\n---\n drivers/net/ngbe/base/ngbe_dummy.h | 37 +++++++++\n drivers/net/ngbe/base/ngbe_hw.c | 122 +++++++++++++++++++++++++++++\n drivers/net/ngbe/base/ngbe_hw.h | 5 ++\n drivers/net/ngbe/base/ngbe_osdep.h | 2 +\n drivers/net/ngbe/base/ngbe_type.h | 53 +++++++++++++\n drivers/net/ngbe/ngbe_ethdev.c | 8 ++\n 6 files changed, 227 insertions(+)\n create mode 100644 drivers/net/ngbe/base/ngbe_dummy.h", "diff": "diff --git a/drivers/net/ngbe/base/ngbe_dummy.h b/drivers/net/ngbe/base/ngbe_dummy.h\nnew file mode 100644\nindex 0000000000..75b4e50bca\n--- /dev/null\n+++ b/drivers/net/ngbe/base/ngbe_dummy.h\n@@ -0,0 +1,37 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2018-2020 Beijing WangXun Technology Co., Ltd.\n+ */\n+\n+#ifndef _NGBE_TYPE_DUMMY_H_\n+#define _NGBE_TYPE_DUMMY_H_\n+\n+#ifdef TUP\n+#elif defined(__GNUC__)\n+#define TUP(x) x##_unused ngbe_unused\n+#elif defined(__LCLINT__)\n+#define TUP(x) x /*@unused@*/\n+#else\n+#define TUP(x) x\n+#endif /*TUP*/\n+#define TUP0 TUP(p0)\n+#define TUP1 TUP(p1)\n+#define TUP2 TUP(p2)\n+#define TUP3 TUP(p3)\n+#define TUP4 TUP(p4)\n+#define TUP5 TUP(p5)\n+#define TUP6 TUP(p6)\n+#define TUP7 TUP(p7)\n+#define TUP8 TUP(p8)\n+#define TUP9 TUP(p9)\n+\n+/* struct ngbe_bus_operations */\n+static inline void ngbe_bus_set_lan_id_dummy(struct ngbe_hw *TUP0)\n+{\n+}\n+static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw)\n+{\n+\thw->bus.set_lan_id = ngbe_bus_set_lan_id_dummy;\n+}\n+\n+#endif /* _NGBE_TYPE_DUMMY_H_ */\n+\ndiff --git a/drivers/net/ngbe/base/ngbe_hw.c b/drivers/net/ngbe/base/ngbe_hw.c\nindex 0fab47f272..014bb0faee 100644\n--- a/drivers/net/ngbe/base/ngbe_hw.c\n+++ b/drivers/net/ngbe/base/ngbe_hw.c\n@@ -3,8 +3,74 @@\n * Copyright(c) 2010-2017 Intel Corporation\n */\n \n+#include \"ngbe_type.h\"\n #include \"ngbe_hw.h\"\n \n+/**\n+ * ngbe_set_lan_id_multi_port - Set LAN id for PCIe multiple port devices\n+ * @hw: pointer to the HW structure\n+ *\n+ * Determines the LAN function id by reading memory-mapped registers and swaps\n+ * the port value if requested, and set MAC instance for devices.\n+ **/\n+void ngbe_set_lan_id_multi_port(struct ngbe_hw *hw)\n+{\n+\tstruct ngbe_bus_info *bus = &hw->bus;\n+\tu32 reg = 0;\n+\n+\tDEBUGFUNC(\"ngbe_set_lan_id_multi_port\");\n+\n+\treg = rd32(hw, NGBE_PORTSTAT);\n+\tbus->lan_id = NGBE_PORTSTAT_ID(reg);\n+\tbus->func = bus->lan_id;\n+}\n+\n+/**\n+ * ngbe_set_mac_type - Sets MAC type\n+ * @hw: pointer to the HW structure\n+ *\n+ * This function sets the mac type of the adapter based on the\n+ * vendor ID and device ID stored in the hw structure.\n+ **/\n+s32 ngbe_set_mac_type(struct ngbe_hw *hw)\n+{\n+\ts32 err = 0;\n+\n+\tDEBUGFUNC(\"ngbe_set_mac_type\");\n+\n+\tif (hw->vendor_id != PCI_VENDOR_ID_WANGXUN) {\n+\t\tDEBUGOUT(\"Unsupported vendor id: %x\", hw->vendor_id);\n+\t\treturn NGBE_ERR_DEVICE_NOT_SUPPORTED;\n+\t}\n+\n+\tswitch (hw->sub_device_id) {\n+\tcase NGBE_SUB_DEV_ID_EM_RTL_SGMII:\n+\tcase NGBE_SUB_DEV_ID_EM_MVL_RGMII:\n+\t\thw->phy.media_type = ngbe_media_type_copper;\n+\t\thw->mac.type = ngbe_mac_em;\n+\t\tbreak;\n+\tcase NGBE_SUB_DEV_ID_EM_MVL_SFP:\n+\tcase NGBE_SUB_DEV_ID_EM_YT8521S_SFP:\n+\t\thw->phy.media_type = ngbe_media_type_fiber;\n+\t\thw->mac.type = ngbe_mac_em;\n+\t\tbreak;\n+\tcase NGBE_SUB_DEV_ID_EM_VF:\n+\t\thw->phy.media_type = ngbe_media_type_virtual;\n+\t\thw->mac.type = ngbe_mac_em_vf;\n+\t\tbreak;\n+\tdefault:\n+\t\terr = NGBE_ERR_DEVICE_NOT_SUPPORTED;\n+\t\thw->phy.media_type = ngbe_media_type_unknown;\n+\t\thw->mac.type = ngbe_mac_unknown;\n+\t\tDEBUGOUT(\"Unsupported device id: %x\", hw->device_id);\n+\t\tbreak;\n+\t}\n+\n+\tDEBUGOUT(\"found mac: %d media: %d, returns: %d\\n\",\n+\t\t hw->mac.type, hw->phy.media_type, err);\n+\treturn err;\n+}\n+\n void ngbe_map_device_id(struct ngbe_hw *hw)\n {\n \tu16 oem = hw->sub_system_id & NGBE_OEM_MASK;\n@@ -58,3 +124,59 @@ void ngbe_map_device_id(struct ngbe_hw *hw)\n \t}\n }\n \n+/**\n+ * ngbe_init_ops_pf - Inits func ptrs and MAC type\n+ * @hw: pointer to hardware structure\n+ *\n+ * Initialize the function pointers and assign the MAC type.\n+ * Does not touch the hardware.\n+ **/\n+s32 ngbe_init_ops_pf(struct ngbe_hw *hw)\n+{\n+\tstruct ngbe_bus_info *bus = &hw->bus;\n+\n+\tDEBUGFUNC(\"ngbe_init_ops_pf\");\n+\n+\t/* BUS */\n+\tbus->set_lan_id = ngbe_set_lan_id_multi_port;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ngbe_init_shared_code - Initialize the shared code\n+ * @hw: pointer to hardware structure\n+ *\n+ * This will assign function pointers and assign the MAC type and PHY code.\n+ * Does not touch the hardware. This function must be called prior to any\n+ * other function in the shared code. The ngbe_hw structure should be\n+ * memset to 0 prior to calling this function. The following fields in\n+ * hw structure should be filled in prior to calling this function:\n+ * hw_addr, back, device_id, vendor_id, subsystem_device_id\n+ **/\n+s32 ngbe_init_shared_code(struct ngbe_hw *hw)\n+{\n+\ts32 status = 0;\n+\n+\tDEBUGFUNC(\"ngbe_init_shared_code\");\n+\n+\t/*\n+\t * Set the mac type\n+\t */\n+\tngbe_set_mac_type(hw);\n+\n+\tngbe_init_ops_dummy(hw);\n+\tswitch (hw->mac.type) {\n+\tcase ngbe_mac_em:\n+\t\tngbe_init_ops_pf(hw);\n+\t\tbreak;\n+\tdefault:\n+\t\tstatus = NGBE_ERR_DEVICE_NOT_SUPPORTED;\n+\t\tbreak;\n+\t}\n+\n+\thw->bus.set_lan_id(hw);\n+\n+\treturn status;\n+}\n+\ndiff --git a/drivers/net/ngbe/base/ngbe_hw.h b/drivers/net/ngbe/base/ngbe_hw.h\nindex b320d126ec..7d5de49248 100644\n--- a/drivers/net/ngbe/base/ngbe_hw.h\n+++ b/drivers/net/ngbe/base/ngbe_hw.h\n@@ -8,6 +8,11 @@\n \n #include \"ngbe_type.h\"\n \n+void ngbe_set_lan_id_multi_port(struct ngbe_hw *hw);\n+\n+s32 ngbe_init_shared_code(struct ngbe_hw *hw);\n+s32 ngbe_set_mac_type(struct ngbe_hw *hw);\n+s32 ngbe_init_ops_pf(struct ngbe_hw *hw);\n void ngbe_map_device_id(struct ngbe_hw *hw);\n \n #endif /* _NGBE_HW_H_ */\ndiff --git a/drivers/net/ngbe/base/ngbe_osdep.h b/drivers/net/ngbe/base/ngbe_osdep.h\nindex ef3d3d9180..94cc10315e 100644\n--- a/drivers/net/ngbe/base/ngbe_osdep.h\n+++ b/drivers/net/ngbe/base/ngbe_osdep.h\n@@ -19,6 +19,8 @@\n #include <rte_config.h>\n #include <rte_io.h>\n \n+#include \"../ngbe_logs.h\"\n+\n #define RTE_LIBRTE_NGBE_TM DCPV(1, 0)\n #define TMZ_PADDR(mz) ((mz)->iova)\n #define TMZ_VADDR(mz) ((mz)->addr)\ndiff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h\nindex 4243e04eef..15f1778d6a 100644\n--- a/drivers/net/ngbe/base/ngbe_type.h\n+++ b/drivers/net/ngbe/base/ngbe_type.h\n@@ -12,8 +12,60 @@\n #include \"ngbe_osdep.h\"\n #include \"ngbe_devids.h\"\n \n+enum ngbe_mac_type {\n+\tngbe_mac_unknown = 0,\n+\tngbe_mac_em,\n+\tngbe_mac_em_vf,\n+\tngbe_num_macs\n+};\n+\n+enum ngbe_phy_type {\n+\tngbe_phy_unknown = 0,\n+\tngbe_phy_none,\n+\tngbe_phy_rtl,\n+\tngbe_phy_mvl,\n+\tngbe_phy_mvl_sfi,\n+\tngbe_phy_yt8521s,\n+\tngbe_phy_yt8521s_sfi,\n+\tngbe_phy_zte,\n+\tngbe_phy_cu_mtd,\n+};\n+\n+enum ngbe_media_type {\n+\tngbe_media_type_unknown = 0,\n+\tngbe_media_type_fiber,\n+\tngbe_media_type_fiber_qsfp,\n+\tngbe_media_type_copper,\n+\tngbe_media_type_backplane,\n+\tngbe_media_type_cx4,\n+\tngbe_media_type_virtual\n+};\n+\n+struct ngbe_hw;\n+\n+/* Bus parameters */\n+struct ngbe_bus_info {\n+\tvoid (*set_lan_id)(struct ngbe_hw *hw);\n+\n+\tu16 func;\n+\tu8 lan_id;\n+};\n+\n+struct ngbe_mac_info {\n+\tenum ngbe_mac_type type;\n+};\n+\n+struct ngbe_phy_info {\n+\tenum ngbe_media_type media_type;\n+\tenum ngbe_phy_type type;\n+};\n+\n struct ngbe_hw {\n \tvoid IOMEM *hw_addr;\n+\tvoid *back;\n+\tstruct ngbe_mac_info mac;\n+\tstruct ngbe_phy_info phy;\n+\tstruct ngbe_bus_info bus;\n \tu16 device_id;\n \tu16 vendor_id;\n \tu16 sub_device_id;\n@@ -27,5 +79,6 @@ struct ngbe_hw {\n };\n \n #include \"ngbe_regs.h\"\n+#include \"ngbe_dummy.h\"\n \n #endif /* _NGBE_TYPE_H_ */\ndiff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c\nindex f24c3e173e..12b80ec695 100644\n--- a/drivers/net/ngbe/ngbe_ethdev.c\n+++ b/drivers/net/ngbe/ngbe_ethdev.c\n@@ -37,6 +37,7 @@ eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)\n \tstruct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);\n \tstruct ngbe_hw *hw = NGBE_DEV_HW(eth_dev);\n \tconst struct rte_memzone *mz;\n+\tint err;\n \n \tPMD_INIT_FUNC_TRACE();\n \n@@ -62,6 +63,13 @@ eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)\n \thw->isb_dma = TMZ_PADDR(mz);\n \thw->isb_mem = TMZ_VADDR(mz);\n \n+\t/* Initialize the shared code (base driver) */\n+\terr = ngbe_init_shared_code(hw);\n+\tif (err != 0) {\n+\t\tPMD_INIT_LOG(ERR, \"Shared code init failed: %d\", err);\n+\t\treturn -EIO;\n+\t}\n+\n \treturn 0;\n }\n \n", "prefixes": [ "v5", "07/24" ] }{ "id": 93768, "url": "