DPDK patches and discussions
 help / color / mirror / Atom feed
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host
Date: Thu, 28 Jan 2016 16:40:21 +0800	[thread overview]
Message-ID: <1453970423-15234-2-git-send-email-helin.zhang@intel.com> (raw)
In-Reply-To: <1453970423-15234-1-git-send-email-helin.zhang@intel.com>

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

  reply	other threads:[~2016-01-28  8:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453970423-15234-2-git-send-email-helin.zhang@intel.com \
    --to=helin.zhang@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).