From: Alvin Zhang Date: Wed, 15 Apr 2020 08:48:09 +0000 (+0800) Subject: net/igc: support MAC loopback mode X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8938c4e1ee01384d922a4664fe23eed5e64cdb24;p=dpdk.git net/igc: support MAC loopback mode Enable mac-loopback mode. Signed-off-by: Alvin Zhang Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c index 15b63d1fd3..af910b936a 100644 --- a/drivers/net/igc/igc_ethdev.c +++ b/drivers/net/igc/igc_ethdev.c @@ -50,10 +50,17 @@ /* External VLAN Enable bit mask */ #define IGC_CTRL_EXT_EXT_VLAN (1u << 26) +/* Speed select */ +#define IGC_CTRL_SPEED_MASK (7u << 8) +#define IGC_CTRL_SPEED_2500 (6u << 8) + /* External VLAN Ether Type bit mask and shift */ #define IGC_VET_EXT 0xFFFF0000 #define IGC_VET_EXT_SHIFT 16 +/* Force EEE Auto-negotiation */ +#define IGC_EEER_EEE_FRC_AN (1u << 28) + /* Per Queue Good Packets Received Count */ #define IGC_PQGPRC(idx) (0x10010 + 0x100 * (idx)) /* Per Queue Good Octets Received Count */ @@ -635,6 +642,9 @@ eth_igc_stop(struct rte_eth_dev *dev) /* disable all wake up */ IGC_WRITE_REG(hw, IGC_WUC, 0); + /* disable checking EEE operation in MAC loopback mode */ + igc_read_reg_check_clear_bits(hw, IGC_EEER, IGC_EEER_EEE_FRC_AN); + /* Set bit for Go Link disconnect */ igc_read_reg_check_set_bits(hw, IGC_82580_PHY_POWER_MGMT, IGC_82580_PM_GO_LINKD); @@ -1060,6 +1070,19 @@ eth_igc_start(struct rte_eth_dev *dev) eth_igc_rxtx_control(dev, true); eth_igc_link_update(dev, 0); + /* configure MAC-loopback mode */ + if (dev->data->dev_conf.lpbk_mode == 1) { + uint32_t reg_val; + + reg_val = IGC_READ_REG(hw, IGC_CTRL); + reg_val &= ~IGC_CTRL_SPEED_MASK; + reg_val |= IGC_CTRL_SLU | IGC_CTRL_FRCSPD | + IGC_CTRL_FRCDPX | IGC_CTRL_FD | IGC_CTRL_SPEED_2500; + IGC_WRITE_REG(hw, IGC_CTRL, reg_val); + + igc_read_reg_check_set_bits(hw, IGC_EEER, IGC_EEER_EEE_FRC_AN); + } + return 0; error_invalid_config: diff --git a/drivers/net/igc/igc_txrx.c b/drivers/net/igc/igc_txrx.c index 3832484237..0bdc3f4a8c 100644 --- a/drivers/net/igc/igc_txrx.c +++ b/drivers/net/igc/igc_txrx.c @@ -1142,6 +1142,9 @@ igc_rx_init(struct rte_eth_dev *dev) IGC_RCTL_DPF | (hw->mac.mc_filter_type << IGC_RCTL_MO_SHIFT); + if (dev->data->dev_conf.lpbk_mode == 1) + rctl |= IGC_RCTL_LBM_MAC; + rctl &= ~(IGC_RCTL_HSEL_MSK | IGC_RCTL_CFIEN | IGC_RCTL_CFI | IGC_RCTL_PSP | IGC_RCTL_PMCF);