bnxt_en: Bug fixes.
cover bnxt_en: Bug fixes.
Fixed autoneg logic and some related cleanups, fixed tx push operation, and reduced default ring sizes.
Michael Chan (5):
bnxt_en: Fix ethtool autoneg logic.
bnxt_en: Cleanup and Fix flow control setup logic
bnxt_en: Remove 20G support and advertise only 40GbaseCR4.
bnxt_en: Fix implementation of tx push operation.
bnxt_en: Reduce default ring sizes.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 62 ++++++++++++----------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 15 ++++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 46 +++++------------ 3 files changed, 56 insertions(+), 67 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/5 bnxt_en: Fix ethtool autoneg logic.
1. Determine autoneg on|off setting from link_info->autoneg. Using the firmware returned setting can be misleading if autoneg is changed and there hasn't been a phy update from the firmware.
2. If autoneg is disabled, link_info->autoneg should be set to 0 to indicate both speed and flow control autoneg are disabled.
3. To enable autoneg flow control, speed autoneg must be enabled.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +6 -4
@@ -561,7 +561,7 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)if (link_info->auto_link_speeds) cmd->supported |= SUPPORTED_Autoneg; -if (BNXT_AUTO_MODE (link_info->auto_mode)) { +if (link_info->autoneg) { cmd->advertising =bnxt_fw_to_ethtool_advertised_spds (link_info); cmd->advertising |= ADVERTISED_Autoneg;
@@ -729,7 +729,7 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) speed =ethtool_cmd_speed (cmd); link_info->req_link_speed =bnxt_get_fw_speed (dev, speed); link_info->req_duplex =BNXT_LINK_DUPLEX_FULL ; - link_info->autoneg &= ~BNXT_AUTONEG_SPEED ; + link_info->autoneg =0 ; link_info->advertising =0 ; }
@@ -748,8 +748,7 @@ static void bnxt_get_pauseparam(struct net_device *dev,if (BNXT_VF (bp))return ; - epause->autoneg = !!(link_info->auto_pause_setting & -BNXT_LINK_PAUSE_BOTH ); + epause->autoneg = !!(link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ); epause->rx_pause = ((link_info->pause &BNXT_LINK_PAUSE_RX ) !=0 ); epause->tx_pause = ((link_info->pause &BNXT_LINK_PAUSE_TX ) !=0 ); }
@@ -765,6 +764,9 @@ static int bnxt_set_pauseparam(struct net_device *dev,return rc;if (epause->autoneg) { +if (!(link_info->autoneg &BNXT_AUTONEG_SPEED )) +return -EINVAL ; + link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; link_info->req_flow_ctrl |=BNXT_LINK_PAUSE_BOTH ; }else {
Signature · 1 line
1.8.3.1
PATCH 2/5 bnxt_en: Cleanup and Fix flow control setup logic
In reply to Michael ChanCleanup bnxt_probe_phy() to cleanly separate 2 code blocks for autoneg on and off. Autoneg flow control is possible only if autoneg is enabled.
In bnxt_get_settings(), Pause and Asym_Pause are always supported. Only the advertisement bits change depending on the ethtool -A setting in auto mode.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 +++++++------------- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 15 ++------------- 2 files changed, 9 insertions(+), 26 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -13
@@ -5670,22 +5670,16 @@ static int bnxt_probe_phy(struct bnxt *bp) }/*initialize the ethool setting copy with NVM settings */ -if (BNXT_AUTO_MODE (link_info->auto_mode)) - link_info->autoneg |=BNXT_AUTONEG_SPEED ; - -if (link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ) { -if (link_info->auto_pause_setting ==BNXT_LINK_PAUSE_BOTH ) - link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; +if (BNXT_AUTO_MODE (link_info->auto_mode)) { + link_info->autoneg =BNXT_AUTONEG_SPEED | +BNXT_AUTONEG_FLOW_CTRL ; + link_info->advertising = link_info->auto_link_speeds; link_info->req_flow_ctrl = link_info->auto_pause_setting; - }else if (link_info->force_pause_setting &BNXT_LINK_PAUSE_BOTH ) { + }else { + link_info->req_link_speed = link_info->force_link_speed; + link_info->req_duplex = link_info->duplex_setting; link_info->req_flow_ctrl = link_info->force_pause_setting; } - link_info->req_duplex = link_info->duplex_setting; -if (link_info->autoneg &BNXT_AUTONEG_SPEED ) - link_info->req_link_speed = link_info->auto_link_speed; -else - link_info->req_link_speed = link_info->force_link_speed; - link_info->advertising = link_info->auto_link_speeds; snprintf(phy_ver, PHY_VER_STR_LEN, " ph %d.%d.%d", link_info->phy_ver[0], link_info->phy_ver[1],
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +2 -13
@@ -557,6 +557,7 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)u16 ethtool_speed; cmd->supported =bnxt_fw_to_ethtool_support_spds (link_info); + cmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;if (link_info->auto_link_speeds) cmd->supported |= SUPPORTED_Autoneg;
@@ -570,28 +571,16 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) cmd->autoneg =AUTONEG_DISABLE ; cmd->advertising =0 ; } -if (link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ) { +if (link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) {if ((link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ) ==BNXT_LINK_PAUSE_BOTH ) { cmd->advertising |= ADVERTISED_Pause; - cmd->supported |= SUPPORTED_Pause; }else { cmd->advertising |= ADVERTISED_Asym_Pause; - cmd->supported |= SUPPORTED_Asym_Pause;if (link_info->auto_pause_setting &BNXT_LINK_PAUSE_RX ) cmd->advertising |= ADVERTISED_Pause; } - }else if (link_info->force_pause_setting &BNXT_LINK_PAUSE_BOTH ) { -if ((link_info->force_pause_setting &BNXT_LINK_PAUSE_BOTH ) == -BNXT_LINK_PAUSE_BOTH ) { - cmd->supported |= SUPPORTED_Pause; - }else { - cmd->supported |= SUPPORTED_Asym_Pause; -if (link_info->force_pause_setting & -BNXT_LINK_PAUSE_RX ) - cmd->supported |= SUPPORTED_Pause; - } } cmd->port =PORT_NONE ;
Signature · 1 line
1.8.3.1
PATCH 3/5 bnxt_en: Remove 20G support and advertise only 40GbaseCR4.
In reply to Michael Chan20G is not supported by production hardware and only the 40GbaseCR4 standard is supported.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +5 -16
@@ -486,15 +486,8 @@ static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info) speed_mask |= SUPPORTED_2500baseX_Full;if (fw_speeds &BNXT_LINK_SPEED_MSK_10GB ) speed_mask |= SUPPORTED_10000baseT_Full; -/* TODO: support 25GB, 50GB with different cable type */ -if (fw_speeds &BNXT_LINK_SPEED_MSK_20GB ) - speed_mask |= SUPPORTED_20000baseMLD2_Full | - SUPPORTED_20000baseKR2_Full;if (fw_speeds &BNXT_LINK_SPEED_MSK_40GB ) - speed_mask |= SUPPORTED_40000baseKR4_Full | - SUPPORTED_40000baseCR4_Full | - SUPPORTED_40000baseSR4_Full | - SUPPORTED_40000baseLR4_Full; + speed_mask |= SUPPORTED_40000baseCR4_Full;return speed_mask; }
@@ -514,15 +507,8 @@ static u32 bnxt_fw_to_ethtool_advertised_spds(struct bnxt_link_info *link_info) speed_mask |= ADVERTISED_2500baseX_Full;if (fw_speeds &BNXT_LINK_SPEED_MSK_10GB ) speed_mask |= ADVERTISED_10000baseT_Full; -/* TODO: how to advertise 20, 25, 40, 50GB with different cable type ?*/ -if (fw_speeds &BNXT_LINK_SPEED_MSK_20GB ) - speed_mask |= ADVERTISED_20000baseMLD2_Full | - ADVERTISED_20000baseKR2_Full;if (fw_speeds &BNXT_LINK_SPEED_MSK_40GB ) - speed_mask |= ADVERTISED_40000baseKR4_Full | - ADVERTISED_40000baseCR4_Full | - ADVERTISED_40000baseSR4_Full | - ADVERTISED_40000baseLR4_Full; + speed_mask |= ADVERTISED_40000baseCR4_Full;return speed_mask; }
@@ -659,6 +645,9 @@ static u16 bnxt_get_fw_auto_link_speeds(u32 advertising)if (advertising & ADVERTISED_10000baseT_Full) fw_speed_mask |=BNXT_LINK_SPEED_MSK_10GB ; +if (advertising & ADVERTISED_40000baseCR4_Full) + fw_speed_mask |=BNXT_LINK_SPEED_MSK_40GB ; +return fw_speed_mask; }
Signature · 1 line
1.8.3.1
PATCH 4/5 bnxt_en: Fix implementation of tx push operation.
In reply to Michael Chantx push is supported for small packets to reduce DMA latency. The following bugs are fixed in this patch:
1. Fix the definition of the push BD which is different from the DMA BD.
2. The push buffer has to be zero padded to the next 64-bit word boundary or tx checksum won't be correct.
3. Increase the tx push packet threshold to 164 bytes (192 bytes with the BD) so that small tunneled packets are within the threshold.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 42 ++++++++++++++++++------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 11 ++++++-- 2 files changed, 34 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +25 -17
@@ -69,7 +69,7 @@ MODULE_VERSION(DRV_MODULE_VERSION);#define BNXT_RX_DMA_OFFSET NET_SKB_PAD#define BNXT_RX_COPY_THRESH 256 -#define BNXT_TX_PUSH_THRESH 92 +#define BNXT_TX_PUSH_THRESH 164enum board_idx {BCM57301 ,
@@ -223,11 +223,12 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) }if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh) { -struct tx_push_bd *push = txr->tx_push; -struct tx_bd *tx_push = &push->txbd1; -struct tx_bd_ext *tx_push1 = &push->txbd2; -void *pdata = tx_push1 +1 ; -int j; +struct tx_push_buffer *tx_push_buf = txr->tx_push; +struct tx_push_bd *tx_push = &tx_push_buf->push_bd; +struct tx_bd_ext *tx_push1 = &tx_push->txbd2; +void *pdata = tx_push_buf->data; +u64 *end; +int j, push_len;/* Set COAL_NOW to be ready quickly for the next push */ tx_push->tx_bd_len_flags_type =
@@ -247,6 +248,9 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) tx_push1->tx_bd_cfa_meta =cpu_to_le32 (vlan_tag_flags); tx_push1->tx_bd_cfa_action =cpu_to_le32 (cfa_action); + end =PTR_ALIGN (pdata + length +1 ,8 ) -1 ; + *end =0 ; +skb_copy_from_linear_data (skb, pdata, len); pdata += len;for (j =0 ; j < last_frag; j++) {
@@ -261,22 +265,29 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) pdata +=skb_frag_size (frag); } -memcpy (txbd, tx_push,sizeof (*txbd)); + txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type; + txbd->tx_bd_haddr = txr->data_mapping; prod =NEXT_TX (prod); txbd = &txr->tx_desc_ring[TX_RING (prod)][TX_IDX (prod)];memcpy (txbd, tx_push1,sizeof (*txbd)); prod =NEXT_TX (prod); - push->doorbell = + tx_push->doorbell =cpu_to_le32 (DB_KEY_TX_PUSH |DB_LONG_TX_PUSH | prod); txr->tx_prod = prod;netdev_tx_sent_queue (txq, skb->len); -__iowrite64_copy (txr->tx_doorbell, push, - (length +sizeof (*push) +8 ) /8 ); + push_len = (length +sizeof (*tx_push) +7 ) /8 ; +if (push_len >16 ) { +__iowrite64_copy (txr->tx_doorbell, tx_push_buf,16 ); +__iowrite64_copy (txr->tx_doorbell +4 , tx_push_buf +1 , + push_len -16 ); + }else { +__iowrite64_copy (txr->tx_doorbell, tx_push_buf, + push_len); + } tx_buf->is_push =1 ; - goto tx_done; }
@@ -1753,7 +1764,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp) push_size =L1_CACHE_ALIGN (sizeof (struct tx_push_bd ) + bp->tx_push_thresh); -if (push_size >128 ) { +if (push_size >256 ) { push_size =0 ; bp->tx_push_thresh =0 ; }
@@ -1772,7 +1783,6 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)return rc;if (bp->tx_push_size) { -struct tx_bd *txbd;dma_addr_t mapping;/* One pre-allocated DMA buffer to backup
@@ -1786,13 +1796,11 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)if (!txr->tx_push)return -ENOMEM ; - txbd = &txr->tx_push->txbd1; - mapping = txr->tx_push_mapping +sizeof (struct tx_push_bd ); - txbd->tx_bd_haddr =cpu_to_le64 (mapping); + txr->data_mapping =cpu_to_le64 (mapping); -memset (txbd +1 ,0 ,sizeof (struct tx_bd_ext )); +memset (txr->tx_push,0 ,sizeof (struct tx_push_bd )); } ring->queue_id = bp->q_info[j].queue_id;if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc -1 ))
drivers/net/ethernet/broadcom/bnxt/bnxt.h +9 -2
@@ -523,10 +523,16 @@ struct bnxt_ring_struct {struct tx_push_bd {__le32 doorbell; -struct tx_bd txbd1; +__le32 tx_bd_len_flags_type; +u32 tx_bd_opaque;struct tx_bd_ext txbd2; }; +struct tx_push_buffer { +struct tx_push_bd push_bd; +u32 data[25 ]; +}; +struct bnxt_tx_ring_info {struct bnxt_napi *bnapi;u16 tx_prod;
@@ -538,8 +544,9 @@ struct bnxt_tx_ring_info {dma_addr_t tx_desc_mapping[MAX_TX_PAGES ]; -struct tx_push_bd *tx_push; +struct tx_push_buffer *tx_push;dma_addr_t tx_push_mapping; +__le64 data_mapping;#define BNXT_DEV_STATE_CLOSING 0x1u32 dev_state;
Signature · 1 line
1.8.3.1
PATCH 5/5 bnxt_en: Reduce default ring sizes.
In reply to Michael ChanThe current default tx ring size of 512 causes an extra page to be allocated for the tx ring with only 1 entry in it. Reduce it to
511. The default rx ring size is also reduced to 511 to use less memory by default.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -2
@@ -411,8 +411,8 @@ struct rx_tpa_end_cmp_ext {#define BNXT_NUM_TESTS (bp) 0 -#define BNXT_DEFAULT_RX_RING_SIZE 1023 -#define BNXT_DEFAULT_TX_RING_SIZE 512 +#define BNXT_DEFAULT_RX_RING_SIZE 511 +#define BNXT_DEFAULT_TX_RING_SIZE 511#define MAX_TPA 64
Signature · 1 line
1.8.3.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Wed, 10 Feb 2016 17:33:45 -0500
Quoted 2 lines
Fixed autoneg logic and some related cleanups, fixed tx push operation, and reduced default ring sizes.
Series applied, thanks Michael.