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 CA084A04FD; Wed, 22 Jun 2022 08:48:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59A354280C; Wed, 22 Jun 2022 08:48:14 +0200 (CEST) Received: from smtpbgsg1.qq.com. (smtpbgsg1.qq.com [54.254.200.92]) by mails.dpdk.org (Postfix) with ESMTP id E28B8427F8 for ; Wed, 22 Jun 2022 08:48:12 +0200 (CEST) X-QQ-mid: bizesmtp66t1655880482tmqkmqp2 Received: from wxdbg.localdomain.com ( [183.129.236.74]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 22 Jun 2022 14:48:01 +0800 (CST) X-QQ-SSF: 01400000002000F0Q000B00A0000000 X-QQ-FEAT: TskX/GkkryD6csM+0w+uMvW8t3eQ84NRNrMzNocyzI4eUgzbtbyPGUHJLGpxd JHA+6gT1RdZG0Jnixud+wH9vtPiIP1nF+T2jS7bEXH55l3FXXKmi3wAm/uTweEWC+mztib/ slG8qdzOgaWQ/Bqzf6yWmEHhjI6AaTrCLsIkgCzUeBfpo1F/IydyJpfiXEaa5IhdK0xxIQA LOW+Vq2VEFQzw55pw0hlUuIKKb1nYBqe8d+AWIvwC8iu9A1CwURyuyCSGKZlG/xOBP01Z5W juJU0IlmtU00OcN8SiDw6L4YpKlZ/t6oi9MOUiRQs3yjy7389PgByu9mwlvjfvLv4crzdKs tTaN89t2SrW5Gdvfve02kA8s2ED9BqDD40jsxDy X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Subject: [PATCH v2 1/7] net/txgbe: support OEM subsystem vendor ID Date: Wed, 22 Jun 2022 14:56:07 +0800 Message-Id: <20220622065613.661679-2-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220622065613.661679-1-jiawenwu@trustnetic.com> References: <20220622065613.661679-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 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 Add support for OEM subsystem vendor ID. Signed-off-by: Jiawen Wu --- doc/guides/rel_notes/release_22_07.rst | 4 +++ drivers/net/txgbe/base/txgbe_hw.c | 39 ++++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_hw.h | 2 ++ drivers/net/txgbe/base/txgbe_type.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 13 +++++++++ 5 files changed, 59 insertions(+) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index 6fc044edaa..96db85a707 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -167,6 +167,10 @@ New Features * Added support for yt8531s PHY. +* **Updated Wangxun txgbe driver.** + + * Added support for OEM subsystem vendor ID. + * **Added Elliptic Curve Diffie-Hellman (ECDH) algorithm in cryptodev.** Added support for Elliptic Curve Diffie Hellman (ECDH) asymmetric diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 6a045cba79..8966453a03 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -2608,6 +2608,45 @@ s32 txgbe_prot_autoc_write_raptor(struct txgbe_hw *hw, bool locked, u64 autoc) return err; } +/* cmd_addr is used for some special command: + * 1. to be sector address, when implemented erase sector command + * 2. to be flash address when implemented read, write flash address + * + * Return 0 on success, return 1 on failure. + */ +u32 txgbe_fmgr_cmd_op(struct txgbe_hw *hw, u32 cmd, u32 cmd_addr) +{ + u32 cmd_val, i; + + cmd_val = TXGBE_SPICMD_CMD(cmd) | TXGBE_SPICMD_CLK(3) | cmd_addr; + wr32(hw, TXGBE_SPICMD, cmd_val); + + for (i = 0; i < TXGBE_SPI_TIMEOUT; i++) { + if (rd32(hw, TXGBE_SPISTAT) & TXGBE_SPISTAT_OPDONE) + break; + + usec_delay(10); + } + + if (i == TXGBE_SPI_TIMEOUT) + return 1; + + return 0; +} + +u32 txgbe_flash_read_dword(struct txgbe_hw *hw, u32 addr) +{ + u32 status; + + status = txgbe_fmgr_cmd_op(hw, 1, addr); + if (status == 0x1) { + DEBUGOUT("Read flash timeout."); + return status; + } + + return rd32(hw, TXGBE_SPIDAT); +} + /** * txgbe_init_ops_pf - Inits func ptrs and MAC type * @hw: pointer to hardware structure diff --git a/drivers/net/txgbe/base/txgbe_hw.h b/drivers/net/txgbe/base/txgbe_hw.h index fd2f7d784c..7031589f7c 100644 --- a/drivers/net/txgbe/base/txgbe_hw.h +++ b/drivers/net/txgbe/base/txgbe_hw.h @@ -111,4 +111,6 @@ s32 txgbe_prot_autoc_read_raptor(struct txgbe_hw *hw, bool *locked, u64 *value); s32 txgbe_prot_autoc_write_raptor(struct txgbe_hw *hw, bool locked, u64 value); s32 txgbe_reinit_fdir_tables(struct txgbe_hw *hw); bool txgbe_verify_lesm_fw_enabled_raptor(struct txgbe_hw *hw); +u32 txgbe_fmgr_cmd_op(struct txgbe_hw *hw, u32 cmd, u32 cmd_addr); +u32 txgbe_flash_read_dword(struct txgbe_hw *hw, u32 addr); #endif /* _TXGBE_HW_H_ */ diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index d95467f9f8..343279127f 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -28,6 +28,7 @@ #define TXGBE_FDIR_INIT_DONE_POLL 10 #define TXGBE_FDIRCMD_CMD_POLL 10 #define TXGBE_VF_INIT_TIMEOUT 200 /* Number of retries to clear RSTI */ +#define TXGBE_SPI_TIMEOUT 10000 #define TXGBE_ALIGN 128 /* as intel did */ diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index f0994f028d..dc8c3c70a9 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -594,6 +594,19 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) /* Vendor and Device ID need to be set before init of shared code */ hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; + if (pci_dev->id.subsystem_vendor_id == PCI_VENDOR_ID_WANGXUN) { + hw->subsystem_device_id = pci_dev->id.subsystem_device_id; + } else { + u32 ssid; + + ssid = txgbe_flash_read_dword(hw, 0xFFFDC); + if (ssid == 0x1) { + PMD_INIT_LOG(ERR, + "Read of internal subsystem device id failed\n"); + return -ENODEV; + } + hw->subsystem_device_id = (u16)ssid >> 8 | (u16)ssid << 8; + } hw->hw_addr = (void *)pci_dev->mem_resource[0].addr; hw->allow_unsupported_sfp = 1; -- 2.27.0