[dpdk-dev] E1000: fix for forced speed/duplex config

Message ID 1478040424-102624-1-git-send-email-ananda@versa-networks.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Ananda Sathyanarayana Nov. 1, 2016, 10:47 p.m. UTC
  From the code, it looks like, hw->mac.autoneg, variable is used to
switch between calling either autoneg function or forcing
speed/duplex function. But this variable is not modified in
eth_em_start/eth_igb_start routines (it is always set to 1)
even while forcing the link speed.

Following discussion thread has some more information on
this

http://dpdk.org/ml/archives/dev/2016-October/049272.html

Signed-off-by: Ananda Sathyanarayana <ananda@versa-networks.com>
---
 drivers/net/e1000/em_ethdev.c  | 16 ++++++++++++++--
 drivers/net/e1000/igb_ethdev.c | 16 ++++++++++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)
  

Comments

Wenzhuo Lu Nov. 2, 2016, 12:37 a.m. UTC | #1
Hi Ananda,

> -----Original Message-----
> From: Ananda Sathyanarayana [mailto:ananda@versa-networks.com]
> Sent: Wednesday, November 2, 2016 6:47 AM
> To: Lu, Wenzhuo
> Cc: dev@dpdk.org; Ananda Sathyanarayana
> Subject: [PATCH] E1000: fix for forced speed/duplex config
> 
> From the code, it looks like, hw->mac.autoneg, variable is used to switch
> between calling either autoneg function or forcing speed/duplex function. But
> this variable is not modified in eth_em_start/eth_igb_start routines (it is always
> set to 1) even while forcing the link speed.
> 
> Following discussion thread has some more information on this
> 
> http://dpdk.org/ml/archives/dev/2016-October/049272.html
> 
> Signed-off-by: Ananda Sathyanarayana <ananda@versa-networks.com>
Thanks for the patch. It looks fine to me. But as it's a fix, would you like to add a Fixes tag for it?
  
Ferruh Yigit Nov. 2, 2016, 5:36 p.m. UTC | #2
Hi Ananda,

Thank you for the patch. Can you please take care a few minor issues?

Patch tag should be: "net/e1000:", so patch title becomes:
"net/e1000: fix for forced speed/duplex config"

On 11/1/2016 10:47 PM, Ananda Sathyanarayana wrote:
> From the code, it looks like, hw->mac.autoneg, variable is used to
> switch between calling either autoneg function or forcing
> speed/duplex function. But this variable is not modified in
> eth_em_start/eth_igb_start routines (it is always set to 1)
> even while forcing the link speed.
> 
> Following discussion thread has some more information on
> this
> 
> http://dpdk.org/ml/archives/dev/2016-October/049272.html

Requires a fixes line:
http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-body

> 
> Signed-off-by: Ananda Sathyanarayana <ananda@versa-networks.com>

You can keep Wenzhuo's ack for next version of the patch.
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

> ---
>  drivers/net/e1000/em_ethdev.c  | 16 ++++++++++++++--
>  drivers/net/e1000/igb_ethdev.c | 16 ++++++++++++++--
>  2 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
> index 7cf5f0c..a2412f5 100644
> --- a/drivers/net/e1000/em_ethdev.c
> +++ b/drivers/net/e1000/em_ethdev.c
> @@ -639,6 +639,7 @@ eth_em_start(struct rte_eth_dev *dev)
>  	speeds = &dev->data->dev_conf.link_speeds;
>  	if (*speeds == ETH_LINK_SPEED_AUTONEG) {
>  		hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
> +                hw->mac.autoneg = 1;

checkpatch gives many whitespace errors.
From coding style document:
"Global whitespace rule in DPDK, use tabs for indentation, spaces for
alignment."

And how to use checkpatch:
http://dpdk.org/doc/guides/contributing/patches.html#checking-the-patches

>  	} else {
>  		num_speeds = 0;
>  		autoneg = (*speeds & ETH_LINK_SPEED_FIXED) == 0;
> @@ -672,9 +673,20 @@ eth_em_start(struct rte_eth_dev *dev)
>  			hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
>  			num_speeds++;
>  		}
> -		if (num_speeds == 0 || (!autoneg && (num_speeds > 1)))
> +		if (num_speeds == 0 || (!autoneg && (num_speeds > 1))) {

No need to update this line, dpdk coding style doesn't require
parenthesis for single line statement:
http://dpdk.org/doc/guides/contributing/coding_style.html#control-statements-and-loops

>  			goto error_invalid_config;
> -	}
> +                }
> +                /*
> +                 * Set/reset the mac.autoneg based on the link speed,
> +                 * fixed or not
> +                 */
> +                if (!autoneg) {
> +                        hw->mac.autoneg = 0;
> +                        hw->mac.forced_speed_duplex = hw->phy.autoneg_advertised;

This line over 80 character limit.

> +                } else {
> +                        hw->mac.autoneg = 1;
> +                }
> +        }
>  
>  	e1000_setup_link(hw);
>  
> diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c

Same comments valid for this file too.

Thanks,
ferruh
  

Patch

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 7cf5f0c..a2412f5 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -639,6 +639,7 @@  eth_em_start(struct rte_eth_dev *dev)
 	speeds = &dev->data->dev_conf.link_speeds;
 	if (*speeds == ETH_LINK_SPEED_AUTONEG) {
 		hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
+                hw->mac.autoneg = 1;
 	} else {
 		num_speeds = 0;
 		autoneg = (*speeds & ETH_LINK_SPEED_FIXED) == 0;
@@ -672,9 +673,20 @@  eth_em_start(struct rte_eth_dev *dev)
 			hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
 			num_speeds++;
 		}
-		if (num_speeds == 0 || (!autoneg && (num_speeds > 1)))
+		if (num_speeds == 0 || (!autoneg && (num_speeds > 1))) {
 			goto error_invalid_config;
-	}
+                }
+                /*
+                 * Set/reset the mac.autoneg based on the link speed,
+                 * fixed or not
+                 */
+                if (!autoneg) {
+                        hw->mac.autoneg = 0;
+                        hw->mac.forced_speed_duplex = hw->phy.autoneg_advertised;
+                } else {
+                        hw->mac.autoneg = 1;
+                }
+        }
 
 	e1000_setup_link(hw);
 
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 4924396..9fb498f 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -1327,6 +1327,7 @@  eth_igb_start(struct rte_eth_dev *dev)
 	speeds = &dev->data->dev_conf.link_speeds;
 	if (*speeds == ETH_LINK_SPEED_AUTONEG) {
 		hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
+                hw->mac.autoneg = 1;
 	} else {
 		num_speeds = 0;
 		autoneg = (*speeds & ETH_LINK_SPEED_FIXED) == 0;
@@ -1360,9 +1361,20 @@  eth_igb_start(struct rte_eth_dev *dev)
 			hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
 			num_speeds++;
 		}
-		if (num_speeds == 0 || (!autoneg && (num_speeds > 1)))
+		if (num_speeds == 0 || (!autoneg && (num_speeds > 1))) {
 			goto error_invalid_config;
-	}
+                }
+                /*
+                 * Set/reset the mac.autoneg based on the link speed,
+                 * fixed or not
+                 */
+                if (!autoneg) {
+                        hw->mac.autoneg = 0;
+                        hw->mac.forced_speed_duplex = hw->phy.autoneg_advertised;
+                } else {
+                        hw->mac.autoneg = 1;
+                }
+        }
 
 	e1000_setup_link(hw);