Skip to contentSkip to conversation

net/i40e: i40e support mac loopback

PATCH Superseded Yanglong Wu 4 participants 12 messages Nov 20, 2017 – Jan 7, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: i40e support mac loopback

According to loopback mode, setup loopback link or not. If loopback link is setted, packets will be sent to rx_q from tx_q directly.Loopback mode can be used to support testing task.

---
 drivers/net/i40e/base/i40e_adminq_cmd.h |  1 +
 drivers/net/i40e/i40e_ethdev.c          | 12 +++++++++++
 2 files changed, 13 insertions(+)
drivers/net/i40e/base/i40e_adminq_cmd.h +1 -0
index c36da2a32..8171f877b 100644
@@ -2128,6 +2128,7 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_an_advt_reg);
 /* Set Loopback mode (0x0618) */
 struct i40e_aqc_set_lb_mode {
 	__le16	lb_mode;
+#define I40E_AQ_LB_MODE_NONE   0x0
 #define I40E_AQ_LB_PHY_LOCAL	0x01
 #define I40E_AQ_LB_PHY_REMOTE	0x02
 #define I40E_AQ_LB_MAC_LOCAL	0x04
drivers/net/i40e/i40e_ethdev.c +12 -0
index f40c463aa..2e6aa9d0d 100644
@@ -2048,6 +2048,17 @@ i40e_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Enable mac loopback mode */
+	if (hw->mac.type == I40E_MAC_XL710 &&
+	    (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(INFO, "fail to set loopback link");
+			goto err_up;
+		}
+	}
+
 	/* Apply link configure */
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |

ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |

Signature · 1 line
2.11.0
Tested-by on v1 1/1
#1 lore raw

- Tested Branch: dpdk master dpdk-17.11-rc1
- Tested Commit: 87607f45bdecc31c33e9b7666b918dc685a10093
- OS: 4.4.0-62-generic
- GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
- CPU: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
- NIC: Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+ [8086:1583]
- Default x86_64-native-linuxapp-gcc configuration
- Prerequisites:
- Total 2cases, 2passed, 0 failed

- Prerequisites command / instruction:
Two 40Gb Ethernet ports of the DUT are directly connected and link is up.

- Case:
Case1: loopback mode
enable loopback mode:
In dpdk/test/test/test_pmd_perf.c
set::

    .lpbk_mode=1
    #define MAX_TRAFFIC_BURST              32
then make test
start test::
    ./test/test/test -c f -n 4 -- -i
    RTE>>pmd_perf_autotest

The final output of the test will be matrix of average cycles of IO used per packet, and "Test OK" is printed out.
the peer port can't receive any packet.

case2: physical link mode
disable lookback mode:
In dpdk/test/test/test_pmd_perf.c
set::

    .lpbk_mode=0
    #define MAX_TRAFFIC_BURST              32
then make test
start test::
    ./test/test/test -c f -n 4 -- -i
    RTE>>pmd_perf_autotest

there is not "Test OK" presented.
the peer port can receive all the 32 packets.

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Monday, November 20, 2017 12:06 PM
To: [email protected]
Cc: Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: i40e support mac loopback

According to loopback mode, setup loopback link or not.
If loopback link is setted, packets will be sent to rx_q from tx_q directly.Loopback mode can be used to support testing task.

---
 drivers/net/i40e/base/i40e_adminq_cmd.h |  1 +
 drivers/net/i40e/i40e_ethdev.c          | 12 +++++++++++
 2 files changed, 13 insertions(+)
drivers/net/i40e/base/i40e_adminq_cmd.h +1 -0
index c36da2a32..8171f877b 100644
@@ -2128,6 +2128,7 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_an_advt_reg);
 /* Set Loopback mode (0x0618) */
 struct i40e_aqc_set_lb_mode {
 	__le16	lb_mode;
+#define I40E_AQ_LB_MODE_NONE   0x0
 #define I40E_AQ_LB_PHY_LOCAL	0x01
 #define I40E_AQ_LB_PHY_REMOTE	0x02
 #define I40E_AQ_LB_MAC_LOCAL	0x04
drivers/net/i40e/i40e_ethdev.c +12 -0
@@ -2048,6 +2048,17 @@ i40e_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Enable mac loopback mode */
+	if (hw->mac.type == I40E_MAC_XL710 &&
+	    (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(INFO, "fail to set loopback link");
+			goto err_up;
+		}
+	}
+
 	/* Apply link configure */
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |

ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
--
2.11.0

#2 lore raw
In reply to Yanglong Wu

Hi Yanglong

It seems your patch cannot be applied on my system. Please do a check on your patch. In addition, please make sure your local git repo was cloned from the right sub-tree. e.g. 'git clone http://dpdk.org/git/next/dpdk-next-net-intel'

Hi maintainers

I need your comments, ACK or NACK. Thanks!

Regards,
Helin

Quoted 59 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Monday, November 20, 2017 12:06 PM
To: [email protected]
Cc: Wu, Yanglong
Subject: [dpdk-dev] [PATCH] net/i40e: i40e support mac loopback

According to loopback mode, setup loopback link or not. If loopback link is setted, packets will be sent to rx_q from tx_q directly.Loopback mode can be used to support testing task.

---
 drivers/net/i40e/base/i40e_adminq_cmd.h |  1 +
 drivers/net/i40e/i40e_ethdev.c          | 12 +++++++++++
 2 files changed, 13 insertions(+)
drivers/net/i40e/base/i40e_adminq_cmd.h +1 -0
index c36da2a32..8171f877b 100644
@@ -2128,6 +2128,7 @@
 I40E_CHECK_CMD_LENGTH(i40e_aqc_an_advt_reg);
 /* Set Loopback mode (0x0618) */
 struct i40e_aqc_set_lb_mode {
 	__le16	lb_mode;
+#define I40E_AQ_LB_MODE_NONE   0x0
 #define I40E_AQ_LB_PHY_LOCAL	0x01
 #define I40E_AQ_LB_PHY_REMOTE	0x02

#define I40E_AQ_LB_MAC_LOCAL 0x04

drivers/net/i40e/i40e_ethdev.c +12 -0
index f40c463aa..2e6aa9d0d 100644
@@ -2048,6 +2048,17 @@ i40e_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Enable mac loopback mode */
+	if (hw->mac.type == I40E_MAC_XL710 &&
+	    (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(INFO, "fail to set loopback link");
+			goto err_up;
+		}
+	}
+
 	/* Apply link configure */
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
 				ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G

|
--
2.11.0

#3 lore raw
In reply to Yanglong Wu
Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Monday, November 20, 2017 12:06 PM
To: [email protected]
Cc: Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: i40e support mac loopback

"i40e" in the title can be omitted.

Quoted 17 lines

According to loopback mode, setup loopback link or not. If loopback link is setted, packets will be sent to rx_q from tx_q directly.Loopback mode can be used to support testing task.

---
 drivers/net/i40e/base/i40e_adminq_cmd.h |  1 +
 drivers/net/i40e/i40e_ethdev.c          | 12 +++++++++++
 2 files changed, 13 insertions(+)
drivers/net/i40e/base/i40e_adminq_cmd.h +0 -0
index c36da2a32..8171f877b 100644

drivers/net/i40e/base/i40e_adminq_cmd.h line 2132

Quoted 5 lines
drivers/net/i40e/base/i40e_adminq_cmd.h +1 -0
@@ -2128,6 +2128,7 @@
 I40E_CHECK_CMD_LENGTH(i40e_aqc_an_advt_reg);
 /* Set Loopback mode (0x0618) */
 struct i40e_aqc_set_lb_mode {
 	__le16	lb_mode;
+#define I40E_AQ_LB_MODE_NONE   0x0

Don't define it in base code, can move it to i40e PMD.

drivers/net/i40e/i40e_ethdev.c i40e_dev_start(struct rte_eth_dev *dev) · line 2052

Quoted 13 lines
drivers/net/i40e/base/i40e_adminq_cmd.h +0 -0
 #define I40E_AQ_LB_PHY_LOCAL	0x01
 #define I40E_AQ_LB_PHY_REMOTE	0x02

#define I40E_AQ_LB_MAC_LOCAL 0x04

drivers/net/i40e/i40e_ethdev.c +2 -0
index f40c463aa..2e6aa9d0d 100644
@@ -2048,6 +2048,17 @@ i40e_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Enable mac loopback mode */
+	if (hw->mac.type == I40E_MAC_XL710 &&

Only I40E_MAC_XL710 supports loopback mode?

drivers/net/i40e/i40e_ethdev.c i40e_dev_start(struct rte_eth_dev *dev) · line 2058

Quoted 9 lines
drivers/net/i40e/i40e_ethdev.c +1 -0
+	    (dev->data->dev_conf.lpbk_mode == I40E_AQ_LB_MODE_NONE

||

drivers/net/i40e/i40e_ethdev.c +1 -0
+		dev->data->dev_conf.lpbk_mode ==

I40E_AQ_LB_PHY_LOCAL)) {

drivers/net/i40e/i40e_ethdev.c +2 -0
+		ret = i40e_aq_set_lb_modes(hw,
+					   dev->data->dev_conf.lpbk_mode,

NULL);

drivers/net/i40e/i40e_ethdev.c +2 -0
+			if (ret != I40E_SUCCESS) {
+			PMD_DRV_LOG(INFO, "fail to set loopback link");

Better to use 'ERR' to replace 'INFO'.

Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +4 -0
+			goto err_up;
+		}
+	}
+
 	/* Apply link configure */
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
 				ETH_LINK_SPEED_1G |

ETH_LINK_SPEED_10G |
--
2.11.0

#4 lore raw

PATCH v2 1/1 net/i40e: support mac loopback

In reply to Yanglong Wu

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

---
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(-)
drivers/net/i40e/i40e_ethdev.c +10 -0
index 0739f65a8..e8bdb335a 100644
@@ -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 |
drivers/net/i40e/i40e_ethdev.h +2 -1
index cd67453d1..2ad9858e4 100644
@@ -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.
Signature · 1 line
2.11.0
#5 lore raw

Re: [PATCH v2] net/i40e: support mac loopback

Doc update is needed. /Helin

Quoted 58 lines

-----Original Message-----
From: Wu, Yanglong
Sent: Wednesday, December 20, 2017 3:29 PM
To: [email protected]
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

---
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(-)
drivers/net/i40e/i40e_ethdev.c +10 -0
index 0739f65a8..e8bdb335a 100644
@@ -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 */
drivers/net/i40e/i40e_ethdev.c +0 -0
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
drivers/net/i40e/i40e_ethdev.h +2 -2
index cd67453d1..2ad9858e4 100644
@@ -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

Tested-by on v2 1/1
#6 lore raw

Re: [PATCH v2] net/i40e: support mac loopback

In reply to Yanglong Wu

- Tested Branch: dpdk master
- Tested Commit: e976052a1106153c93c802e5ffd2f6c8a29f239f
- OS: 4.4.0-62-generic
- GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
- CPU: Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
- NIC: Intel Corporation Ethernet Controller XL710 for 40GbE QSFP+ [8086:1583]
- Default x86_64-native-linuxapp-gcc configuration
- Prerequisites:
- Total 2cases, 2passed, 0 failed

- Prerequisites command / instruction:
Two 40Gb Ethernet ports of the DUT are directly connected and link is up.

- Case:
Case1: loopback mode
enable loopback mode:
In dpdk/test/test/test_pmd_perf.c
set::

    .lpbk_mode=1
    #define MAX_TRAFFIC_BURST              32
then make test
    ./usertools/dpdk-devbind.py -b igb_uio 05:00.0
start test::
    ./test/test/test -c f -n 4 -- -i
    RTE>>pmd_perf_autotest

The final output of the test will be matrix of average cycles of IO used per packet, and "Test OK" is printed out. the peer port can't receive any packet.

case2: physical link mode
disable lookback mode:
In dpdk/test/test/test_pmd_perf.c
set::

    .lpbk_mode=0
    #define MAX_TRAFFIC_BURST              32
then make test
start test::
    ./test/test/test -c f -n 4 -- -i
    RTE>>pmd_perf_autotest

there is not "Test OK" presented.
the peer port can receive all the 32 packets.

When run the two test cases on XXV710 with same dpdk version, the cases passed too.

-----Original Message-----
From: Wu, Yanglong
Sent: Wednesday, December 20, 2017 3:29 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Zhang, Helin <[email protected]>; Peng, Yuan <[email protected]>; Wu, Yanglong <[email protected]>
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

---
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(-)
drivers/net/i40e/i40e_ethdev.c +10 -0
@@ -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
drivers/net/i40e/i40e_ethdev.h +2 -1
@@ -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

#7 lore raw

PATCH v3 1/1 net/i40e: support mac loopback

In reply to Yanglong Wu

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

---
v2:
fix coding style issue
---
v3:
update release DOC

---
 doc/guides/rel_notes/release_18_02.rst |  6 ++++++
 drivers/net/i40e/i40e_ethdev.c         | 10 ++++++++++
 drivers/net/i40e/i40e_ethdev.h         |  3 ++-
 3 files changed, 18 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_18_02.rst +6 -0
index 24b67bb8b..1bd747b49 100644
@@ -41,6 +41,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added a mac loopback function for the FVL.**
+
+  Added a mac loopback function for the FVL in order to support test
+  task asked by users. According to device configuration, it will
+  setup TX->RX loopback link or not. If loopback link is setted,
+  packets in tx will be sent to rx directly.
 
 API Changes
 -----------
drivers/net/i40e/i40e_ethdev.c +10 -0
index 0739f65a8..e8bdb335a 100644
@@ -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 |
drivers/net/i40e/i40e_ethdev.h +2 -1
index cd67453d1..2ad9858e4 100644
@@ -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.
Signature · 1 line
2.11.0
#8 lore raw

PATCH v4 1/1 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

---
v2:
fix coding style issue
---
v3:
update release DOC
---
v4:
remove 'FVL'

---
 doc/guides/rel_notes/release_18_02.rst |  6 ++++++
 drivers/net/i40e/i40e_ethdev.c         | 10 ++++++++++
 drivers/net/i40e/i40e_ethdev.h         |  3 ++-
 3 files changed, 18 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_18_02.rst +6 -0
index 24b67bb8b..81be184db 100644
@@ -41,6 +41,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added a mac loopback function for the i40e.**
+
+  Add a mac loopback function for the i40e in order to support test 
+  task asked by users. According to device configuration, it will 
+  setup TX->RX loopback link or not. If loopback link is setted, 
+  packets in tx will be sent to rx directly.
 
 API Changes
 -----------
drivers/net/i40e/i40e_ethdev.c +10 -0
index 0739f65a8..e8bdb335a 100644
@@ -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 |
drivers/net/i40e/i40e_ethdev.h +2 -1
index cd67453d1..2ad9858e4 100644
@@ -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.
Signature · 1 line
2.11.0
#9 lore raw

PATCH v5 1/1 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

---
v2:
fix coding style issue
---
v3:
update release DOC
---
v4:
remove 'FVL'
---
v5:
fix coding style isssue

---
 doc/guides/rel_notes/release_18_02.rst |  6 ++++++
 drivers/net/i40e/i40e_ethdev.c         | 10 ++++++++++
 drivers/net/i40e/i40e_ethdev.h         |  3 ++-
 3 files changed, 18 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_18_02.rst +6 -0
index 24b67bb8b..81be184db 100644
@@ -41,6 +41,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added a mac loopback function for the i40e.**
+
+  Add a mac loopback function for the i40e in order to support test
+  task asked by users. According to device configuration, it will
+  setup TX->RX loopback link or not. If loopback link is setted,
+  packets in tx will be sent to rx directly.
 
 API Changes
 -----------
drivers/net/i40e/i40e_ethdev.c +10 -0
index 0739f65a8..e8bdb335a 100644
@@ -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 |
drivers/net/i40e/i40e_ethdev.h +2 -1
index cd67453d1..2ad9858e4 100644
@@ -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.
Signature · 1 line
2.11.0
Acked-by on v5 1/1
#10 lore raw

Re: [PATCH v5] net/i40e: support mac loopback

Quoted 9 lines

-----Original Message-----
From: Wu, Yanglong
Sent: Tuesday, January 2, 2018 10:41 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [PATCH v5] net/i40e: support mac loopback

Quoted 5 lines

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

Applied
#11 lore raw

Re: [PATCH v5] net/i40e: support mac loopback

Quoted 17 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xing, Beilei
Sent: Tuesday, January 2, 2018 10:47 AM
To: Wu, Yanglong; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5] net/i40e: support mac loopback

Quoted 8 lines

-----Original Message-----
From: Wu, Yanglong
Sent: Tuesday, January 2, 2018 10:41 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [PATCH v5] net/i40e: support mac loopback

Quoted 7 lines
Quoted 5 lines

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

Applied to dpdk-next-net-intel, with minor word changes. Thanks!

/Helin