[dpdk-dev,6/7] net/bnxt: fix some link related issues

Message ID 20170629025142.19404-7-ajit.khaparde@broadcom.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde June 29, 2017, 2:51 a.m. UTC
  This patch fixes some link related issues that can occur because:

bnxt_hwrm_port_phy_cfg() was setting enables inappropriately.
bnxt_hwrm_port_phy_qcfg() was overly complex.
bnxt_get_hwrm_link_config() was basing the speed on the link status.
bnxt_get_hwrm_link_config() was using the incorrect macros for auto_mode
we are not using supported speeds from phy_qcfg for auto mask.

Fixes: 7bc8e9a227cc ("net/bnxt: support async link notification")

Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_hwrm.c | 48 ++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 19 deletions(-)
  

Comments

Ferruh Yigit June 29, 2017, 10:55 a.m. UTC | #1
On 6/29/2017 3:51 AM, Ajit Khaparde wrote:
> This patch fixes some link related issues that can occur because:
> 
> bnxt_hwrm_port_phy_cfg() was setting enables inappropriately.
> bnxt_hwrm_port_phy_qcfg() was overly complex.
> bnxt_get_hwrm_link_config() was basing the speed on the link status.
> bnxt_get_hwrm_link_config() was using the incorrect macros for auto_mode
> we are not using supported speeds from phy_qcfg for auto mask.

Does it make sense to split patch per issue fixed?

> 
> Fixes: 7bc8e9a227cc ("net/bnxt: support async link notification")
> 
> Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
<...>
  
Ajit Khaparde June 30, 2017, 2:27 a.m. UTC | #2
On Thu, Jun 29, 2017 at 5:55 AM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 6/29/2017 3:51 AM, Ajit Khaparde wrote:
> > This patch fixes some link related issues that can occur because:
> >
> > bnxt_hwrm_port_phy_cfg() was setting enables inappropriately.
> > bnxt_hwrm_port_phy_qcfg() was overly complex.
> > bnxt_get_hwrm_link_config() was basing the speed on the link status.
> > bnxt_get_hwrm_link_config() was using the incorrect macros for auto_mode
> > we are not using supported speeds from phy_qcfg for auto mask.
>
> Does it make sense to split patch per issue fixed?
>
Sure. Working on that. Thanks
​


>
> >
> > Fixes: 7bc8e9a227cc ("net/bnxt: support async link notification")
> >
> > Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
> > Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> <...>
>
>
  
Ajit Khaparde June 30, 2017, 2:20 p.m. UTC | #3
The first patch of the series adds support for a new device.
Rest of the patches in the patchset fix some of the issues
found during testing.

v1->v2: incorporate review comments

  net/bnxt: add support for Stratus VF device
  net/bnxt: fix mtu configuration for the function
  net/bnxt: fix calculation of VNICs
  net/bnxt: pass func_default flag to VNIC_ALLOC
  net/bnxt: fix automatic clearing of VF stats
  net/bnxt: fix get link config
  net/bnxt: fix autoneg on 10GBase-T links
  net/bnxt: fix set link config
  net/bnxt: fix copy/pasted error message

 drivers/net/bnxt/bnxt.h                   |   5 ++
 drivers/net/bnxt/bnxt_ethdev.c            |   6 +-
 drivers/net/bnxt/bnxt_hwrm.c              | 132 +++++++++++++++++++++++-------
 drivers/net/bnxt/bnxt_hwrm.h              |   5 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h    |  19 +++++
 drivers/net/bnxt/rte_pmd_bnxt.c           |  63 ++++++++++++--
 drivers/net/bnxt/rte_pmd_bnxt.h           |  18 ++++
 drivers/net/bnxt/rte_pmd_bnxt_version.map |   1 +
 8 files changed, 209 insertions(+), 40 deletions(-)
  
Ferruh Yigit July 3, 2017, 9:40 a.m. UTC | #4
On 6/30/2017 3:20 PM, Ajit Khaparde wrote:
> The first patch of the series adds support for a new device.
> Rest of the patches in the patchset fix some of the issues
> found during testing.
> 
> v1->v2: incorporate review comments
> 
>   net/bnxt: add support for Stratus VF device
>   net/bnxt: fix mtu configuration for the function
>   net/bnxt: fix calculation of VNICs
>   net/bnxt: pass func_default flag to VNIC_ALLOC
>   net/bnxt: fix automatic clearing of VF stats
>   net/bnxt: fix get link config
>   net/bnxt: fix autoneg on 10GBase-T links
>   net/bnxt: fix set link config
>   net/bnxt: fix copy/pasted error message

Series applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 3d2d408..da078f9 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -628,6 +628,8 @@  static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
 	struct hwrm_port_phy_cfg_input req = {0};
 	struct hwrm_port_phy_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 	uint32_t enables = 0;
+	uint32_t link_speed_mask =
+		HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK;
 
 	HWRM_PREP(req, PORT_PHY_CFG, -1, resp);
 
@@ -639,14 +641,20 @@  static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
 		 * any auto mode, even "none".
 		 */
 		if (!conf->link_speed) {
-			req.auto_mode |= conf->auto_mode;
-			enables = HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
-			req.auto_link_speed_mask = conf->auto_link_speed_mask;
-			enables |=
-			   HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK;
-			req.auto_link_speed = bp->link_info.auto_link_speed;
-			enables |=
+			req.auto_mode = conf->auto_mode;
+			enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
+			if (conf->auto_mode ==
+			    HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK) {
+				req.auto_link_speed_mask =
+					conf->auto_link_speed_mask;
+				enables |= link_speed_mask;
+			}
+			if (bp->link_info.auto_link_speed) {
+				req.auto_link_speed =
+					bp->link_info.auto_link_speed;
+				enables |=
 				HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED;
+			}
 		}
 		req.auto_duplex = conf->duplex;
 		enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
@@ -686,13 +694,10 @@  static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
 	HWRM_CHECK_RESULT;
 
 	link_info->phy_link_status = resp->link;
-	if (link_info->phy_link_status == HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) {
-		link_info->link_up = 1;
-		link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
-	} else {
-		link_info->link_up = 0;
-		link_info->link_speed = 0;
-	}
+	link_info->link_up =
+		(link_info->phy_link_status ==
+		 HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) ? 1 : 0;
+	link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
 	link_info->duplex = resp->duplex;
 	link_info->pause = resp->pause;
 	link_info->auto_pause = resp->auto_pause;
@@ -1790,12 +1795,16 @@  static int bnxt_valid_link_speed(uint32_t link_speed, uint8_t port_id)
 	return 0;
 }
 
-static uint16_t bnxt_parse_eth_link_speed_mask(uint32_t link_speed)
+static uint16_t
+bnxt_parse_eth_link_speed_mask(struct bnxt *bp, uint32_t link_speed)
 {
 	uint16_t ret = 0;
 
-	if (link_speed == ETH_LINK_SPEED_AUTONEG)
+	if (link_speed == ETH_LINK_SPEED_AUTONEG) {
+		if (bp->link_info.support_speeds)
+			return bp->link_info.support_speeds;
 		link_speed = BNXT_SUPPORTED_SPEEDS;
+	}
 
 	if (link_speed & ETH_LINK_SPEED_100M)
 		ret |= HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_100MB;
@@ -1887,7 +1896,7 @@  int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link)
 			"Get link config failed with rc %d\n", rc);
 		goto exit;
 	}
-	if (link_info->link_up)
+	if (link_info->link_speed)
 		link->link_speed =
 			bnxt_parse_hw_link_speed(link_info->link_speed);
 	else
@@ -1896,7 +1905,7 @@  int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link)
 	link->link_status = link_info->link_up;
 	link->link_autoneg = link_info->auto_mode ==
 		HWRM_PORT_PHY_QCFG_OUTPUT_AUTO_MODE_NONE ?
-		ETH_LINK_SPEED_FIXED : ETH_LINK_SPEED_AUTONEG;
+		ETH_LINK_FIXED : ETH_LINK_AUTONEG;
 exit:
 	return rc;
 }
@@ -1929,7 +1938,8 @@  int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
 		link_req.auto_mode =
 				HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK;
 		link_req.auto_link_speed_mask =
-			bnxt_parse_eth_link_speed_mask(dev_conf->link_speeds);
+			bnxt_parse_eth_link_speed_mask(bp,
+						       dev_conf->link_speeds);
 	} else {
 		link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
 		link_req.link_speed = speed;