DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side
@ 2016-01-28  8:40 Helin Zhang
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host Helin Zhang
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Helin Zhang @ 2016-01-28  8:40 UTC (permalink / raw)
  To: dev

It adds pre-setting i40e VF MAC addresses from DPDK PF host side,
during host port initialization, by introduing a new port
configuration element. It then can pre-set VF MAC addresses
before any launching VFs, and the VF MAC addresses will not be
random each time launching a VF.
There should be no ABI broken, as ABI changes
in 'struct rte_eth_conf' has already been announced in R2.2.

Helin Zhang (3):
  i40e: add setting VF MAC address in DPDK PF host
  i40evf: use ether interface for validating MAC address
  app/testpmd: set default MAC addresses for each VF

 app/test-pmd/testpmd.c               | 19 +++++++++++++++++++
 doc/guides/rel_notes/release_2_3.rst |  9 +++++++++
 drivers/net/i40e/i40e_ethdev.c       | 21 +++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h       |  1 +
 drivers/net/i40e/i40e_ethdev_vf.c    | 14 +++++++-------
 drivers/net/i40e/i40e_pf.c           |  2 ++
 lib/librte_ether/rte_ethdev.h        | 10 ++++++++++
 7 files changed, 69 insertions(+), 7 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host
  2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
@ 2016-01-28  8:40 ` Helin Zhang
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 2/3] i40evf: use ether interface for validating MAC address Helin Zhang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Helin Zhang @ 2016-01-28  8:40 UTC (permalink / raw)
  To: dev

It adds pre-setting the VF MAC addresses from DPDK PF host
side before any VF being initialized, by introducing a new
element of 'struct rte_vf_conf' in 'struct rte_eth_conf'.
It supports up to 128 VFs per physical port of setting VF
MAC addresses.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 doc/guides/rel_notes/release_2_3.rst |  9 +++++++++
 drivers/net/i40e/i40e_ethdev.c       | 21 +++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h       |  1 +
 drivers/net/i40e/i40e_pf.c           |  2 ++
 lib/librte_ether/rte_ethdev.h        | 10 ++++++++++
 5 files changed, 43 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_3.rst b/doc/guides/rel_notes/release_2_3.rst
index 99de186..8ba3594 100644
--- a/doc/guides/rel_notes/release_2_3.rst
+++ b/doc/guides/rel_notes/release_2_3.rst
@@ -4,6 +4,11 @@ DPDK Release 2.3
 New Features
 ------------
 
+* **Added setting default MAC address for i40e VF.**
+
+  Added setting default MAC address for i40e VF before in PF host
+  driver, by providing those MAC addresses in PF port configuration.
+
 
 Resolved Issues
 ---------------
@@ -39,6 +44,10 @@ API Changes
 ABI Changes
 -----------
 
+* The ethdev structure of ``rte_eth_dev``, ``rte_eth_dev_data`` and
+  ``rte_eth_conf`` were changed to support setting default MAC address
+  for i40e VF, by DPDK PF host.
+
 
 Shared Library Versions
 -----------------------
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf6220d..f7cec39 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1020,6 +1020,7 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	enum rte_eth_rx_mq_mode mq_mode = dev->data->dev_conf.rxmode.mq_mode;
+	struct ether_addr *p_mac_addr;
 	int i, ret;
 
 	/* Initialize to TRUE. If any of Rx queues doesn't meet the
@@ -1074,6 +1075,26 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 		}
 	}
 
+	/* Store the configured VF MAC address */
+	for (i = 0; i < RTE_MIN(pf->vf_num, ETH_VF_NUM_MAX); i++) {
+		p_mac_addr = &(dev->data->dev_conf.vf_conf[i].mac_addr);
+		if (is_valid_assigned_ether_addr(p_mac_addr)) {
+			ether_addr_copy(p_mac_addr, &(pf->vfs[i].mac_addr));
+			PMD_DRV_LOG(INFO, "MAC address "
+				    "%02x:%02x:%02x:%02x:%02x:%02x will be "
+				    "used as default address of VF[%d]",
+				    p_mac_addr->addr_bytes[0],
+				    p_mac_addr->addr_bytes[1],
+				    p_mac_addr->addr_bytes[2],
+				    p_mac_addr->addr_bytes[3],
+				    p_mac_addr->addr_bytes[4],
+				    p_mac_addr->addr_bytes[5], i);
+		} else {
+			PMD_DRV_LOG(WARNING, "Invalid MAC address configured "
+				    "for VF[%d], use zero instead", i);
+		}
+	}
+
 	return 0;
 
 err_dcb:
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 1f9792b..66aad4d 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -312,6 +312,7 @@ struct i40e_pf_vf {
 	uint16_t vf_idx; /* VF index in pf->vfs */
 	uint16_t lan_nb_qps; /* Actual queues allocated */
 	uint16_t reset_cnt; /* Total vf reset times */
+	struct ether_addr mac_addr;  /* Default MAC address */
 };
 
 /*
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index cbf4e5b..be7cbf7 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -315,6 +315,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf)
 	/* As assume Vf only has single VSI now, always return 0 */
 	vf_res->vsi_res[0].vsi_id = 0;
 	vf_res->vsi_res[0].num_queue_pairs = vf->vsi->nb_qps;
+	ether_addr_copy(&vf->mac_addr,
+		(struct ether_addr *)vf_res->vsi_res[0].default_mac_addr);
 
 send_msg:
 	i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index bada8ad..88f1d9b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -754,6 +754,15 @@ struct rte_intr_conf {
 	uint16_t rxq;
 };
 
+#define ETH_VF_NUM_MAX 128 /* Maximum number of Virtual Functions supported */
+
+/**
+ * A structure to define VF configurations to be used in PF host driver.
+ */
+struct rte_vf_conf {
+	struct ether_addr mac_addr; /* Pre-configured VF MAC address. */
+};
+
 /**
  * A structure used to configure an Ethernet port.
  * Depending upon the RX multi-queue mode, extra advanced
@@ -793,6 +802,7 @@ struct rte_eth_conf {
 	uint32_t dcb_capability_en;
 	struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */
 	struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */
+	struct rte_vf_conf vf_conf[ETH_VF_NUM_MAX]; /**< VF configuration. */
 };
 
 /**
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH 2/3] i40evf: use ether interface for validating MAC address
  2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host Helin Zhang
@ 2016-01-28  8:40 ` Helin Zhang
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set default MAC addresses for each VF Helin Zhang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Helin Zhang @ 2016-01-28  8:40 UTC (permalink / raw)
  To: dev

It uses ether interface of 'is_valid_assigned_ether_addr' for
validating MAC address. In the meanwhile, more annotations are
added for obtaining/generating VF MAC address.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 14d2a50..2a54596 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1180,6 +1180,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 	int i, err, bufsz;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct ether_addr *p_mac_addr;
 
 	vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	vf->dev_data = dev->data;
@@ -1249,13 +1250,12 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 	vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
 	vf->vsi.adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
-	/* check mac addr, if it's not valid, genrate one */
-	if (I40E_SUCCESS != i40e_validate_mac_addr(\
-			vf->vsi_res->default_mac_addr))
-		eth_random_addr(vf->vsi_res->default_mac_addr);
-
-	ether_addr_copy((struct ether_addr *)vf->vsi_res->default_mac_addr,
-					(struct ether_addr *)hw->mac.addr);
+	/* Store the MAC address configured by host, or generate random one */
+	p_mac_addr = (struct ether_addr *)(vf->vsi_res->default_mac_addr);
+	if (is_valid_assigned_ether_addr(p_mac_addr)) /* Configured by host */
+		ether_addr_copy(p_mac_addr, (struct ether_addr *)hw->mac.addr);
+	else
+		eth_random_addr(hw->mac.addr); /* Generate a random one */
 
 	return 0;
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH 3/3] app/testpmd: set default MAC addresses for each VF
  2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host Helin Zhang
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 2/3] i40evf: use ether interface for validating MAC address Helin Zhang
@ 2016-01-28  8:40 ` Helin Zhang
  2016-02-26  8:14 ` [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Pei, Yulong
  2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
  4 siblings, 0 replies; 10+ messages in thread
From: Helin Zhang @ 2016-01-28  8:40 UTC (permalink / raw)
  To: dev

It generates MAC addresses during host port initialization, which
will be set as default MAC addresses for corresponding VFs.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 app/test-pmd/testpmd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1319917..f7aac81 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1762,6 +1762,23 @@ rxtx_port_config(struct rte_port *port)
 		port->tx_conf.txq_flags = txq_flags;
 }
 
+static void
+generate_default_vf_mac_addr(portid_t pid, struct rte_vf_conf *vf_conf,
+			     uint8_t vf_num)
+{
+	uint8_t i;
+	uint8_t addr[ETHER_ADDR_LEN] = {0x68, 0x05, 0xca, 0x25, 0x00, 0x00};
+
+	if (vf_num >= ETH_VF_NUM_MAX)
+		return;
+
+	addr[4] = (uint8_t)pid;
+	for (i = 0; i < vf_num; i++) {
+		addr[5] = i;
+		memcpy(vf_conf[i].mac_addr.addr_bytes, addr, sizeof(addr));
+	}
+}
+
 void
 init_port_config(void)
 {
@@ -1772,6 +1789,8 @@ init_port_config(void)
 		port = &ports[pid];
 		port->dev_conf.rxmode = rx_mode;
 		port->dev_conf.fdir_conf = fdir_conf;
+		generate_default_vf_mac_addr(pid, port->dev_conf.vf_conf, 32);
+
 		if (nb_rxq > 1) {
 			port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL;
 			port->dev_conf.rx_adv_conf.rss_conf.rss_hf = rss_hf;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side
  2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
                   ` (2 preceding siblings ...)
  2016-01-28  8:40 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set default MAC addresses for each VF Helin Zhang
@ 2016-02-26  8:14 ` Pei, Yulong
  2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
  4 siblings, 0 replies; 10+ messages in thread
From: Pei, Yulong @ 2016-02-26  8:14 UTC (permalink / raw)
  To: Zhang, Helin, dev

Tested-by: yulong.pei@intel.com

-----Original Message-----
From: Zhang, Helin 
Sent: Thursday, January 28, 2016 4:40 PM
To: dev@dpdk.org
Cc: Pei, Yulong <yulong.pei@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Tao, Zhe <zhe.tao@intel.com>; Xu, Qian Q <qian.q.xu@intel.com>; Zhang, Helin <helin.zhang@intel.com>
Subject: [PATCH 0/3] support setting i40e VF MAC address from DPDK host side

It adds pre-setting i40e VF MAC addresses from DPDK PF host side, during host port initialization, by introduing a new port configuration element. It then can pre-set VF MAC addresses before any launching VFs, and the VF MAC addresses will not be random each time launching a VF.
There should be no ABI broken, as ABI changes in 'struct rte_eth_conf' has already been announced in R2.2.

Helin Zhang (3):
  i40e: add setting VF MAC address in DPDK PF host
  i40evf: use ether interface for validating MAC address
  app/testpmd: set default MAC addresses for each VF

 app/test-pmd/testpmd.c               | 19 +++++++++++++++++++
 doc/guides/rel_notes/release_2_3.rst |  9 +++++++++
 drivers/net/i40e/i40e_ethdev.c       | 21 +++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h       |  1 +
 drivers/net/i40e/i40e_ethdev_vf.c    | 14 +++++++-------
 drivers/net/i40e/i40e_pf.c           |  2 ++
 lib/librte_ether/rte_ethdev.h        | 10 ++++++++++
 7 files changed, 69 insertions(+), 7 deletions(-)

--
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation
  2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
@ 2016-03-08  0:43   ` Zhe Tao
  2016-03-08 10:48     ` Bruce Richardson
  2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 1/2] i40e: generate MAC address for VF Helin Zhang
  2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address Helin Zhang
  2 siblings, 1 reply; 10+ messages in thread
From: Zhe Tao @ 2016-03-08  0:43 UTC (permalink / raw)
  To: Helin Zhang; +Cc: dev

On Tue, Mar 08, 2016 at 02:42:07PM +0800, Helin Zhang wrote:
> It adds generating a MAC address for each VFs during PF
> host initialization.
> 
> The patch set branches off below commit on branch rel_16_04
> of dpdk-next-net repo.
> 
> commit 4ac366ba647909c3b71818f9be9db86ba5e871da
> Author: Thomas Monjalon <thomas.monjalon@6wind.com>
> Date:   Sat Feb 6 22:51:16 2016 +0100
>     nfp: fix non-x86 build
> 
> v2:
>  - It just adds generating a MAC address for each VFs
>    during PF host initialization, and removes configuring
>    from users.
>  - Reworded the release notes.
>  - Removed the app changes.
> 
> Helin Zhang (2):
>   i40e: generate MAC address for VF
>   i40evf: use ether API to validate MAC address
> 
>  doc/guides/rel_notes/release_16_04.rst |  5 +++++
>  drivers/net/i40e/i40e_ethdev.h         |  1 +
>  drivers/net/i40e/i40e_ethdev_vf.c      | 14 +++++++-------
>  drivers/net/i40e/i40e_pf.c             |  3 +++
>  4 files changed, 16 insertions(+), 7 deletions(-)
> 
> -- 
> 2.5.0
Acked-by: Zhe Tao <zhe.tao@intel.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation
  2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
                   ` (3 preceding siblings ...)
  2016-02-26  8:14 ` [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Pei, Yulong
@ 2016-03-08  6:42 ` Helin Zhang
  2016-03-08  0:43   ` Zhe Tao
                     ` (2 more replies)
  4 siblings, 3 replies; 10+ messages in thread
From: Helin Zhang @ 2016-03-08  6:42 UTC (permalink / raw)
  To: dev

It adds generating a MAC address for each VFs during PF
host initialization.

The patch set branches off below commit on branch rel_16_04
of dpdk-next-net repo.

commit 4ac366ba647909c3b71818f9be9db86ba5e871da
Author: Thomas Monjalon <thomas.monjalon@6wind.com>
Date:   Sat Feb 6 22:51:16 2016 +0100
    nfp: fix non-x86 build

v2:
 - It just adds generating a MAC address for each VFs
   during PF host initialization, and removes configuring
   from users.
 - Reworded the release notes.
 - Removed the app changes.

Helin Zhang (2):
  i40e: generate MAC address for VF
  i40evf: use ether API to validate MAC address

 doc/guides/rel_notes/release_16_04.rst |  5 +++++
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 drivers/net/i40e/i40e_ethdev_vf.c      | 14 +++++++-------
 drivers/net/i40e/i40e_pf.c             |  3 +++
 4 files changed, 16 insertions(+), 7 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] i40e: generate MAC address for VF
  2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
  2016-03-08  0:43   ` Zhe Tao
@ 2016-03-08  6:42   ` Helin Zhang
  2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address Helin Zhang
  2 siblings, 0 replies; 10+ messages in thread
From: Helin Zhang @ 2016-03-08  6:42 UTC (permalink / raw)
  To: dev

It generates a MAC address for each VFs during PF host
initialization.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 doc/guides/rel_notes/release_16_04.rst | 5 +++++
 drivers/net/i40e/i40e_ethdev.h         | 1 +
 drivers/net/i40e/i40e_pf.c             | 3 +++
 3 files changed, 9 insertions(+)

v2:
 - It just generates a MAC address for each VFs during PF host
   initialization, and removes configuring from users.
 - Reworded the release notes.

diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
index 73494f9..1b9061d 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -137,6 +137,11 @@ Drivers
 
 * **vmxnet3: add TSO support.**
 
+* **i40e: Generates MAC address for each VFs.**
+
+  It generates a MAC address for each VFs during PF host initialization,
+  and keeps the VF MAC address the same among different VF launch.
+
 
 Libraries
 ~~~~~~~~~
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index db6173a..9109cd9 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -312,6 +312,7 @@ struct i40e_pf_vf {
 	uint16_t vf_idx; /* VF index in pf->vfs */
 	uint16_t lan_nb_qps; /* Actual queues allocated */
 	uint16_t reset_cnt; /* Total vf reset times */
+	struct ether_addr mac_addr;  /* Default MAC address */
 };
 
 /*
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index cbf4e5b..5790377 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -315,6 +315,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf)
 	/* As assume Vf only has single VSI now, always return 0 */
 	vf_res->vsi_res[0].vsi_id = 0;
 	vf_res->vsi_res[0].num_queue_pairs = vf->vsi->nb_qps;
+	ether_addr_copy(&vf->mac_addr,
+		(struct ether_addr *)vf_res->vsi_res[0].default_mac_addr);
 
 send_msg:
 	i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -1045,6 +1047,7 @@ i40e_pf_host_init(struct rte_eth_dev *dev)
 		ret = i40e_pf_host_vf_reset(&pf->vfs[i], 0);
 		if (ret != I40E_SUCCESS)
 			goto fail;
+		eth_random_addr(pf->vfs[i].mac_addr.addr_bytes);
 	}
 
 	/* restore irq0 */
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address
  2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
  2016-03-08  0:43   ` Zhe Tao
  2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 1/2] i40e: generate MAC address for VF Helin Zhang
@ 2016-03-08  6:42   ` Helin Zhang
  2 siblings, 0 replies; 10+ messages in thread
From: Helin Zhang @ 2016-03-08  6:42 UTC (permalink / raw)
  To: dev

It uses ether API of 'is_valid_assigned_ether_addr' to validate
MAC address. In the meanwhile, more annotations are added.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 13c5b3d..ded7c8b 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1180,6 +1180,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 	int i, err, bufsz;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct ether_addr *p_mac_addr;
 
 	vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	vf->dev_data = dev->data;
@@ -1249,13 +1250,12 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 	vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
 	vf->vsi.adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
-	/* check mac addr, if it's not valid, genrate one */
-	if (I40E_SUCCESS != i40e_validate_mac_addr(\
-			vf->vsi_res->default_mac_addr))
-		eth_random_addr(vf->vsi_res->default_mac_addr);
-
-	ether_addr_copy((struct ether_addr *)vf->vsi_res->default_mac_addr,
-					(struct ether_addr *)hw->mac.addr);
+	/* Store the MAC address configured by host, or generate random one */
+	p_mac_addr = (struct ether_addr *)(vf->vsi_res->default_mac_addr);
+	if (is_valid_assigned_ether_addr(p_mac_addr)) /* Configured by host */
+		ether_addr_copy(p_mac_addr, (struct ether_addr *)hw->mac.addr);
+	else
+		eth_random_addr(hw->mac.addr); /* Generate a random one */
 
 	return 0;
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation
  2016-03-08  0:43   ` Zhe Tao
@ 2016-03-08 10:48     ` Bruce Richardson
  0 siblings, 0 replies; 10+ messages in thread
From: Bruce Richardson @ 2016-03-08 10:48 UTC (permalink / raw)
  To: Zhe Tao; +Cc: dev

On Tue, Mar 08, 2016 at 08:43:31AM +0800, Zhe Tao wrote:
> On Tue, Mar 08, 2016 at 02:42:07PM +0800, Helin Zhang wrote:
> > It adds generating a MAC address for each VFs during PF
> > host initialization.
> > 
> > The patch set branches off below commit on branch rel_16_04
> > of dpdk-next-net repo.
> > 
> > commit 4ac366ba647909c3b71818f9be9db86ba5e871da
> > Author: Thomas Monjalon <thomas.monjalon@6wind.com>
> > Date:   Sat Feb 6 22:51:16 2016 +0100
> >     nfp: fix non-x86 build
> > 
> > v2:
> >  - It just adds generating a MAC address for each VFs
> >    during PF host initialization, and removes configuring
> >    from users.
> >  - Reworded the release notes.
> >  - Removed the app changes.
> > 
> > Helin Zhang (2):
> >   i40e: generate MAC address for VF
> >   i40evf: use ether API to validate MAC address
> > 
> >  doc/guides/rel_notes/release_16_04.rst |  5 +++++
> >  drivers/net/i40e/i40e_ethdev.h         |  1 +
> >  drivers/net/i40e/i40e_ethdev_vf.c      | 14 +++++++-------
> >  drivers/net/i40e/i40e_pf.c             |  3 +++
> >  4 files changed, 16 insertions(+), 7 deletions(-)
> > 
> > -- 
> > 2.5.0
> Acked-by: Zhe Tao <zhe.tao@intel.com>
> 
Applied to dpdk-next-net/rel_16_04

/Bruce

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-03-08 10:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
2016-01-28  8:40 ` [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host Helin Zhang
2016-01-28  8:40 ` [dpdk-dev] [PATCH 2/3] i40evf: use ether interface for validating MAC address Helin Zhang
2016-01-28  8:40 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set default MAC addresses for each VF Helin Zhang
2016-02-26  8:14 ` [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Pei, Yulong
2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
2016-03-08  0:43   ` Zhe Tao
2016-03-08 10:48     ` Bruce Richardson
2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 1/2] i40e: generate MAC address for VF Helin Zhang
2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address Helin Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).