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 68AA6A04AC; Tue, 1 Sep 2020 13:52:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD1F61C11C; Tue, 1 Sep 2020 13:51:20 +0200 (CEST) Received: from smtpproxy21.qq.com (smtpbg702.qq.com [203.205.195.102]) by dpdk.org (Postfix) with ESMTP id 381AE1C0B0 for ; Tue, 1 Sep 2020 13:51:15 +0200 (CEST) X-QQ-mid: bizesmtp5t1598961069tbqzd5nf2 Received: from localhost.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Tue, 01 Sep 2020 19:51:09 +0800 (CST) X-QQ-SSF: 01400000000000B0C000000A0000000 X-QQ-FEAT: uPKj8ga2w7Ga4j61Z/cCXoUs+G0Bv6e3fGneeZlgin++pv8+ytGam45TxBxrV Ztt1HgVgLt7+kVodIlTBzmfeMYYX9mlRnAk7oFqVcX4tOURRnYmtopB+G12Dz33aKAGskJX d+NkFCGUJBrlBvi0UNt9znj1uiFDZi7JuAHbuy8pmBwk4IZp9EZprSEh7pTtKBkbEg6gaqa MwSDNMGvihRbI8O2xN2+NcZiNtGs/hXo8JzhYDYFVVHnFDOCaMHfs/ZLBCvHm6IYdwnM0ax KpGJj9GvnA+jq+h1/gy/K31WBAZ9yUNA90FouFhBM19rKK955Dt+g/4fDY9g1BBcdus9Rp3 eVbcZYFwf1ZtnVkK966wci4y1A0HA== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Tue, 1 Sep 2020 19:50:38 +0800 Message-Id: <20200901115113.1529675-7-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200901115113.1529675-1-jiawenwu@trustnetic.com> References: <20200901115113.1529675-1-jiawenwu@trustnetic.com> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v1 07/42] net/txgbe: add HW init function 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" Add hardware init function in mac layer. Signed-off-by: Jiawen Wu --- drivers/net/txgbe/base/txgbe_hw.c | 103 ++++++++++++++++++++++++++-- drivers/net/txgbe/base/txgbe_hw.h | 4 ++ drivers/net/txgbe/base/txgbe_type.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 2 +- 4 files changed, 102 insertions(+), 8 deletions(-) diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 358872d30..c644de864 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -7,6 +7,68 @@ #include "txgbe_eeprom.h" #include "txgbe_hw.h" +/** + * txgbe_start_hw - Prepare hardware for Tx/Rx + * @hw: pointer to hardware structure + * + * Starts the hardware by filling the bus info structure and media type, clears + * all on chip counters, initializes receive address registers, multicast + * table, VLAN filter table, calls routine to set up link and flow control + * settings, and leaves transmit and receive units disabled and uninitialized + **/ +s32 txgbe_start_hw(struct txgbe_hw *hw) +{ + RTE_SET_USED(hw); + + return 0; +} + +/** + * txgbe_start_hw_gen2 - Init sequence for common device family + * @hw: pointer to hw structure + * + * Performs the init sequence common to the second generation + * of 10 GbE devices. + **/ +s32 txgbe_start_hw_gen2(struct txgbe_hw *hw) +{ + RTE_SET_USED(hw); + + return 0; +} + +/** + * txgbe_init_hw - Generic hardware initialization + * @hw: pointer to hardware structure + * + * Initialize the hardware by resetting the hardware, filling the bus info + * structure and media type, clears all on chip counters, initializes receive + * address registers, multicast table, VLAN filter table, calls routine to set + * up link and flow control settings, and leaves transmit and receive units + * disabled and uninitialized + **/ +s32 txgbe_init_hw(struct txgbe_hw *hw) +{ + s32 status; + + DEBUGFUNC("txgbe_init_hw"); + + /* Reset the hardware */ + status = hw->mac.reset_hw(hw); + if (status == 0 || status == TXGBE_ERR_SFP_NOT_PRESENT) { + /* Start the HW */ + status = hw->mac.start_hw(hw); + } + + /* Initialize the LED link active for LED blink support */ + hw->mac.init_led_link_act(hw); + + if (status != 0) + DEBUGOUT("Failed to initialize HW, STATUS = %d\n", status); + + return status; +} + s32 txgbe_set_rar(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, u32 enable_addr) { @@ -98,13 +160,6 @@ s32 txgbe_set_mac_type(struct txgbe_hw *hw) return err; } -s32 txgbe_init_hw(struct txgbe_hw *hw) -{ - RTE_SET_USED(hw); - return 0; -} - - /** * txgbe_init_ops_pf - Inits func ptrs and MAC type * @hw: pointer to hardware structure @@ -114,6 +169,7 @@ s32 txgbe_init_hw(struct txgbe_hw *hw) **/ s32 txgbe_init_ops_pf(struct txgbe_hw *hw) { + struct txgbe_mac_info *mac = &hw->mac; struct txgbe_rom_info *rom = &hw->rom; /* EEPROM */ @@ -130,6 +186,39 @@ s32 txgbe_init_ops_pf(struct txgbe_hw *hw) rom->update_checksum = txgbe_update_eeprom_checksum; rom->calc_checksum = txgbe_calc_eeprom_checksum; + /* MAC */ + mac->init_hw = txgbe_init_hw; + mac->start_hw = txgbe_start_hw_raptor; + return 0; } +/** + * txgbe_start_hw_raptor - Prepare hardware for Tx/Rx + * @hw: pointer to hardware structure + * + * Starts the hardware using the generic start_hw function + * and the generation start_hw function. + * Then performs revision-specific operations, if any. + **/ +s32 txgbe_start_hw_raptor(struct txgbe_hw *hw) +{ + s32 err = 0; + + DEBUGFUNC("txgbe_start_hw_raptor"); + + err = txgbe_start_hw(hw); + if (err != 0) + goto out; + + err = txgbe_start_hw_gen2(hw); + if (err != 0) + goto out; + + /* We need to run link autotry after the driver loads */ + hw->mac.autotry_restart = true; + +out: + return err; +} + diff --git a/drivers/net/txgbe/base/txgbe_hw.h b/drivers/net/txgbe/base/txgbe_hw.h index adcc5fc48..55b1b60de 100644 --- a/drivers/net/txgbe/base/txgbe_hw.h +++ b/drivers/net/txgbe/base/txgbe_hw.h @@ -8,6 +8,10 @@ #include "txgbe_type.h" s32 txgbe_init_hw(struct txgbe_hw *hw); +s32 txgbe_start_hw(struct txgbe_hw *hw); +s32 txgbe_stop_hw(struct txgbe_hw *hw); +s32 txgbe_start_hw_gen2(struct txgbe_hw *hw); +s32 txgbe_start_hw_raptor(struct txgbe_hw *hw); s32 txgbe_set_rar(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, u32 enable_addr); diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index 8b7cfd8ff..92068b6f7 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -318,6 +318,7 @@ struct txgbe_mac_info { u8 san_addr[ETH_ADDR_LEN]; u32 num_rar_entries; + bool autotry_restart; u32 max_link_up_time; }; diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 1cae321f1..921a75f25 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -151,7 +151,7 @@ eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) return -EIO; } - err = txgbe_init_hw(hw); + err = hw->mac.init_hw(hw); /* Reset the hw statistics */ txgbe_dev_stats_reset(eth_dev); -- 2.18.4