[RFC] net/i[xgb|40]e: set VF MAC address from host

Message ID 20191101001824.17534-1-thomas@monjalon.net (mailing list archive)
State RFC, archived
Delegated to: Ferruh Yigit
Headers
Series [RFC] net/i[xgb|40]e: set VF MAC address from host |

Checks

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

Commit Message

Thomas Monjalon Nov. 1, 2019, 12:18 a.m. UTC
  Allow to configure the default MAC address of a VF
via its representor port in the host,
when the VF is explicitly targeted with RTE_ETH_PORT_VF_FLAG.

In the long term, the representor behaviour should be changed
to configure itself when the VF is not targeted.

This RFC patch will be split for ixgbe and i40e.
If we can agree on implementing this VF API,
OVS will be have a generic solution.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/i40e/i40e_vf_representor.c   | 19 ++++++++++++++++++-
 drivers/net/ixgbe/ixgbe_vf_representor.c | 19 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c
index b07b35c03f..e944288959 100644
--- a/drivers/net/i40e/i40e_vf_representor.c
+++ b/drivers/net/i40e/i40e_vf_representor.c
@@ -325,7 +325,7 @@  i40e_vf_representor_mac_addr_remove(struct rte_eth_dev *ethdev, uint32_t index)
 }
 
 static int
-i40e_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
+i40e_remote_vf_mac_addr_set(struct rte_eth_dev *ethdev,
 		struct rte_ether_addr *mac_addr)
 {
 	struct i40e_vf_representor *representor = ethdev->data->dev_private;
@@ -335,6 +335,17 @@  i40e_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
 		representor->vf_id, mac_addr);
 }
 
+static int
+i40e_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
+		struct rte_ether_addr *mac_addr)
+{
+	/* Should configure the representor port
+	 * but configure the VF port instead,
+	 * for compatibility purpose.
+	 */
+	return i40e_remote_vf_mac_addr_set(ethdev, mac_addr);
+}
+
 static int
 i40e_vf_representor_vlan_filter_set(struct rte_eth_dev *ethdev,
 		uint16_t vlan_id, int on)
@@ -453,6 +464,11 @@  static const struct eth_dev_ops i40e_representor_dev_ops = {
 
 };
 
+/* operations on VF from representor */
+const struct eth_dev_ops i40e_remote_vf_ops = {
+	.mac_addr_set = i40e_remote_vf_mac_addr_set,
+};
+
 static uint16_t
 i40e_vf_representor_rx_burst(__rte_unused void *rx_queue,
 	__rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
@@ -491,6 +507,7 @@  i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
 
 	/* Set representor device ops */
 	ethdev->dev_ops = &i40e_representor_dev_ops;
+	ethdev->vf_ops = &i40e_remote_vf_ops;
 
 	/* No data-path, but need stub Rx/Tx functions to avoid crash
 	 * when testing with the likes of testpmd.
diff --git a/drivers/net/ixgbe/ixgbe_vf_representor.c b/drivers/net/ixgbe/ixgbe_vf_representor.c
index dbbef294ae..17fccaf4f3 100644
--- a/drivers/net/ixgbe/ixgbe_vf_representor.c
+++ b/drivers/net/ixgbe/ixgbe_vf_representor.c
@@ -24,7 +24,7 @@  ixgbe_vf_representor_link_update(struct rte_eth_dev *ethdev,
 }
 
 static int
-ixgbe_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
+ixgbe_remote_vf_mac_addr_set(struct rte_eth_dev *ethdev,
 	struct rte_ether_addr *mac_addr)
 {
 	struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
@@ -34,6 +34,17 @@  ixgbe_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
 		representor->vf_id, mac_addr);
 }
 
+static int
+ixgbe_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
+	struct rte_ether_addr *mac_addr)
+{
+	/* Should configure the representor port
+	 * but configure the VF port instead,
+	 * for compatibility purpose.
+	 */
+	return ixgbe_remote_vf_mac_addr_set(ethdev, mac_addr);
+}
+
 static int
 ixgbe_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *dev_info)
@@ -155,6 +166,11 @@  static const struct eth_dev_ops ixgbe_vf_representor_dev_ops = {
 	.mac_addr_set		= ixgbe_vf_representor_mac_addr_set,
 };
 
+/* operations on VF from representor */
+const struct eth_dev_ops ixgbe_remote_vf_ops = {
+	.mac_addr_set = ixgbe_remote_vf_mac_addr_set,
+};
+
 static uint16_t
 ixgbe_vf_representor_rx_burst(__rte_unused void *rx_queue,
 	__rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
@@ -198,6 +214,7 @@  ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
 
 	/* Set representor device ops */
 	ethdev->dev_ops = &ixgbe_vf_representor_dev_ops;
+	ethdev->vf_ops = &ixgbe_remote_vf_ops;
 
 	/* No data-path, but need stub Rx/Tx functions to avoid crash
 	 * when testing with the likes of testpmd.