Add hardware init function in mac layer. Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com> --- 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