diff mbox

[dpdk-dev,v2] net/i40e: support mac loopback

Message ID 20171220072915.118907-1-yanglong.wu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Helin Zhang
Headers show

Checks

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

Commit Message

Yanglong Wu Dec. 20, 2017, 7:29 a.m. UTC
According to loopback mode, setup loopback link or not.
If loopback link is setted, packets in tx will be sent to rx directly.
Loopback mode can be used to support testing task

Signed-off-by: Yanglong Wu <yanglong.wu@intel.com>
---
v2:
fix coding style issue
---
 drivers/net/i40e/i40e_ethdev.c | 10 ++++++++++
 drivers/net/i40e/i40e_ethdev.h |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Helin Zhang Dec. 20, 2017, 8:09 a.m. UTC | #1
Doc update is needed. /Helin

> -----Original Message-----
> From: Wu, Yanglong
> Sent: Wednesday, December 20, 2017 3:29 PM
> To: dev@dpdk.org
> Cc: Xing, Beilei; Zhang, Helin; Peng, Yuan; Wu, Yanglong
> Subject: [PATCH v2] net/i40e: support mac loopback
> 
> According to loopback mode, setup loopback link or not.
> If loopback link is setted, packets in tx will be sent to rx directly.
> Loopback mode can be used to support testing task
> 
> Signed-off-by: Yanglong Wu <yanglong.wu@intel.com>
> ---
> v2:
> fix coding style issue
> ---
>  drivers/net/i40e/i40e_ethdev.c | 10 ++++++++++
> drivers/net/i40e/i40e_ethdev.h |  3 ++-
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 0739f65a8..e8bdb335a 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -2047,6 +2047,16 @@ i40e_dev_start(struct rte_eth_dev *dev)
>  						     true, NULL);
>  		}
>  	}
> +
> +	/* Enable mac loopback mode */
> +	if (dev->data->dev_conf.lpbk_mode == I40E_AQ_LB_MODE_NONE ||
> +	    dev->data->dev_conf.lpbk_mode == I40E_AQ_LB_PHY_LOCAL) {
> +		ret = i40e_aq_set_lb_modes(hw, dev->data-
> >dev_conf.lpbk_mode, NULL);
> +		if (ret != I40E_SUCCESS) {
> +			PMD_DRV_LOG(ERR, "fail to set loopback link");
> +			goto err_up;
> +		}
> +	}
> 
>  	/* Apply link configure */
>  	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
> diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
> index cd67453d1..2ad9858e4 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -61,7 +61,8 @@
>  #define I40E_NUM_MACADDR_MAX       64
>  /* Maximum number of VFs */
>  #define I40E_MAX_VF               128
> -
> +/*flag of no loopback*/
> +#define I40E_AQ_LB_MODE_NONE	  0x0
>  /*
>   * vlan_id is a 12 bit number.
>   * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
> --
> 2.11.0
diff mbox

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 0739f65a8..e8bdb335a 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2047,6 +2047,16 @@  i40e_dev_start(struct rte_eth_dev *dev)
 						     true, NULL);
 		}
 	}
+
+	/* Enable mac loopback mode */
+	if (dev->data->dev_conf.lpbk_mode == I40E_AQ_LB_MODE_NONE ||
+	    dev->data->dev_conf.lpbk_mode == I40E_AQ_LB_PHY_LOCAL) {
+		ret = i40e_aq_set_lb_modes(hw, dev->data->dev_conf.lpbk_mode, NULL);
+		if (ret != I40E_SUCCESS) {
+			PMD_DRV_LOG(ERR, "fail to set loopback link");
+			goto err_up;
+		}
+	}
 
 	/* Apply link configure */
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cd67453d1..2ad9858e4 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -61,7 +61,8 @@ 
 #define I40E_NUM_MACADDR_MAX       64
 /* Maximum number of VFs */
 #define I40E_MAX_VF               128
-
+/*flag of no loopback*/
+#define I40E_AQ_LB_MODE_NONE	  0x0
 /*
  * vlan_id is a 12 bit number.
  * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.