[dpdk-dev] [RFC 4/5] Enable port representor PMD and broker for fortville PMD driver

Mohammad Abdul Awal mohammad.abdul.awal at intel.com
Thu Sep 7 10:35:38 CEST 2017


Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal at intel.com>
Signed-off-by: Remy Horton <remy.horton at intel.com>
Signed-off-by: Declan Doherty <declan.doherty at intel.com>
---
 drivers/net/i40e/Makefile        |   1 +
 drivers/net/i40e/i40e_ethdev.c   |  17 ++
 drivers/net/i40e/i40e_prep_ops.c | 402 +++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_prep_ops.h |  41 ++++
 drivers/net/i40e/rte_pmd_i40e.c  |  47 +++++
 drivers/net/i40e/rte_pmd_i40e.h  |  18 ++
 6 files changed, 526 insertions(+)
 create mode 100644 drivers/net/i40e/i40e_prep_ops.c
 create mode 100644 drivers/net/i40e/i40e_prep_ops.h

diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 55c79a6..a299a1e 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -110,6 +110,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_fdir.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += rte_pmd_i40e.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_tm.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_prep_ops.c
 
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 5f26e24..942a587 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -65,6 +65,7 @@
 #include "i40e_rxtx.h"
 #include "i40e_pf.h"
 #include "i40e_regs.h"
+#include "i40e_prep_ops.h"
 
 #define ETH_I40E_FLOATING_VEB_ARG	"enable_floating_veb"
 #define ETH_I40E_FLOATING_VEB_LIST_ARG	"floating_veb_list"
@@ -1045,6 +1046,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	int ret;
 	uint32_t len;
 	uint8_t aq_fail = 0;
+	struct rte_port_representor_broker *rb;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1088,6 +1090,17 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	hw->bus.func = pci_dev->addr.function;
 	hw->adapter_stopped = 0;
 
+	/* init representor broker */
+	if (rte_representor_enabled()) {
+		rb = rte_representor_broker_init(dev, pci_dev->max_vfs,
+			rte_i40e_prep_ops);
+		if (rb == NULL) {
+			PMD_INIT_LOG(ERR, "Cannot allocate memory for "
+				"representor broker data\n");
+			return errno;
+		}
+	}
+
 	/* Make sure all is clean before doing PF reset */
 	i40e_clear_hw(hw);
 
@@ -2130,6 +2143,10 @@ i40e_dev_close(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	/* free port representor pmds */
+	if (rte_representor_enabled())
+		rte_representor_broker_free(dev->data->port_id);
+
 	i40e_dev_stop(dev);
 	i40e_dev_free_queues(dev);
 
diff --git a/drivers/net/i40e/i40e_prep_ops.c b/drivers/net/i40e/i40e_prep_ops.c
new file mode 100644
index 0000000..15aaeb3
--- /dev/null
+++ b/drivers/net/i40e/i40e_prep_ops.c
@@ -0,0 +1,402 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <rte_ethdev.h>
+#include <rte_pci.h>
+
+#include "base/i40e_type.h"
+#include "base/virtchnl.h"
+#include "i40e_ethdev.h"
+#include "i40e_rxtx.h"
+#include "rte_pmd_i40e.h"
+
+#include "i40e_prep_ops.h"
+
+static int i40e_prep_link_update(
+	__rte_unused struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, int wait_to_complete)
+{
+	struct rte_eth_dev *pfdev;
+
+	pfdev = prep->pdev;
+
+	return i40e_dev_link_update(pfdev, wait_to_complete);
+}
+
+static void i40e_prep_promiscuous_enable(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_set_vf_unicast_promisc(pfid, vf_index, 1);
+	/* 1 for enable */
+}
+
+static void i40e_prep_promiscuous_disable(
+	struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_set_vf_unicast_promisc(pfid, vf_index, 0);
+	/* 0 for disable */
+}
+
+static void i40e_prep_allmulticast_enable(
+	struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_set_vf_multicast_promisc(pfid, vf_index, 1);
+	/* 1 for enable */
+}
+
+static void i40e_prep_allmulticast_disable(
+	struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_set_vf_multicast_promisc(pfid, vf_index, 0);
+	/* 0 for disable*/
+}
+
+static void i40e_prep_mac_addr_remove(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, uint32_t index)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+	struct rte_eth_dev *vdev;
+	struct ether_addr mac_addr;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+	vdev = prep->vdev;
+	memcpy(&mac_addr, &vdev->data->mac_addrs[index], ETHER_ADDR_LEN);
+
+	rte_pmd_i40e_remove_vf_mac_addr(pfid, vf_index, &mac_addr);
+}
+
+/* for now, the VF can have only one mac addr, which can be set by
+ * i40e_prep_mac_addr_set(...) function
+ */
+static int i40e_prep_mac_addr_add(
+	__rte_unused struct rte_port_representor_broker *rb,
+	__rte_unused struct rte_port_representor *prep,
+	__rte_unused struct ether_addr *mac_addr, __rte_unused uint32_t index,
+	__rte_unused uint32_t vmdq)
+{
+	return -ENOTSUP;
+}
+
+static void i40e_prep_mac_addr_set(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, struct ether_addr *mac_addr)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_set_vf_mac_addr(pfid, vf_index, mac_addr);
+}
+
+static int i40e_prep_stats_get(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, struct rte_eth_stats *stats)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	return rte_pmd_i40e_get_vf_stats(pfid, vf_index, stats);
+}
+
+static void i40e_prep_stats_reset(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_reset_vf_stats(pfid, vf_index);
+}
+
+static void i40e_prep_dev_infos_get(
+	__rte_unused struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, struct rte_eth_dev_info *dev_info)
+{
+	struct rte_eth_dev *pdev;
+	struct rte_eth_dev *vdev;
+	struct i40e_pf_vf *vf;
+	struct i40e_vsi *vsi;
+	struct i40e_pf *pf;
+	uint32_t vf_index;
+
+	pdev = prep->pdev;
+	vdev = prep->vdev;
+	vf_index = prep->vf_index;
+
+	if (!is_i40e_supported(pdev)) {
+		PMD_DRV_LOG(ERR, "Invalid PF dev.");
+		return;
+	}
+
+	pf = I40E_DEV_PRIVATE_TO_PF(pdev->data->dev_private);
+
+	if (vf_index >= pf->vf_num || !pf->vfs) {
+		PMD_DRV_LOG(ERR, "Invalid VF ID.");
+		return;
+	}
+
+	vf = &pf->vfs[vf_index];
+	vsi = vf->vsi;
+	if (!vsi) {
+		PMD_DRV_LOG(ERR, "Invalid VSI.");
+		return;
+	}
+
+	/* get dev info for the vdev */
+	memset(dev_info, 0, sizeof(*dev_info));
+	dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(vdev);
+	dev_info->max_rx_queues = vsi->nb_qps;
+	dev_info->max_tx_queues = vsi->nb_qps;
+	dev_info->min_rx_bufsize = I40E_BUF_SIZE_MIN;
+	dev_info->max_rx_pktlen = I40E_FRAME_SIZE_MAX;
+	dev_info->hash_key_size = (I40E_VFQF_HKEY_MAX_INDEX + 1) *
+		sizeof(uint32_t);
+	dev_info->reta_size = ETH_RSS_RETA_SIZE_64;
+	dev_info->flow_type_rss_offloads = I40E_RSS_OFFLOAD_ALL;
+	dev_info->max_mac_addrs = I40E_NUM_MACADDR_MAX;
+	dev_info->rx_offload_capa =
+		DEV_RX_OFFLOAD_VLAN_STRIP |
+		DEV_RX_OFFLOAD_QINQ_STRIP |
+		DEV_RX_OFFLOAD_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_UDP_CKSUM |
+		DEV_RX_OFFLOAD_TCP_CKSUM;
+	dev_info->tx_offload_capa =
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_QINQ_INSERT |
+		DEV_TX_OFFLOAD_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM |
+		DEV_TX_OFFLOAD_SCTP_CKSUM;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_thresh = {
+			.pthresh = I40E_DEFAULT_RX_PTHRESH,
+			.hthresh = I40E_DEFAULT_RX_HTHRESH,
+			.wthresh = I40E_DEFAULT_RX_WTHRESH,
+		},
+		.rx_free_thresh = I40E_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_thresh = {
+			.pthresh = I40E_DEFAULT_TX_PTHRESH,
+			.hthresh = I40E_DEFAULT_TX_HTHRESH,
+			.wthresh = I40E_DEFAULT_TX_WTHRESH,
+		},
+		.tx_free_thresh = I40E_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = I40E_DEFAULT_TX_RSBIT_THRESH,
+		.txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
+				ETH_TXQ_FLAGS_NOOFFLOADS,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = I40E_MAX_RING_DESC,
+		.nb_min = I40E_MIN_RING_DESC,
+		.nb_align = I40E_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = I40E_MAX_RING_DESC,
+		.nb_min = I40E_MIN_RING_DESC,
+		.nb_align = I40E_ALIGN_RING_DESC,
+	};
+}
+
+static int i40e_prep_vlan_filter_set(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, uint16_t vlan_id, int on)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+	uint64_t vf_mask;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+	vf_mask = 1ULL << vf_index;
+
+	return rte_pmd_i40e_set_vf_vlan_filter(pfid, vlan_id, vf_mask, on);
+}
+
+static int i40e_prep_vlan_tpid_set(
+	__rte_unused struct rte_port_representor_broker *rb,
+	__rte_unused struct rte_port_representor *prep,
+	__rte_unused enum rte_vlan_type type, __rte_unused uint16_t tpid)
+{
+	return -ENOTSUP;
+}
+
+static void i40e_prep_vlan_offload_set(
+	__rte_unused struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, int mask)
+{
+	struct rte_eth_dev *pdev;
+	struct rte_eth_dev *vdev;
+	struct i40e_pf_vf *vf;
+	struct i40e_vsi *vsi;
+	struct i40e_pf *pf;
+	uint32_t vf_index;
+
+	pdev = prep->pdev;
+	vdev = prep->vdev;
+	vf_index = prep->vf_index;
+
+	if (!is_i40e_supported(pdev)) {
+		PMD_DRV_LOG(ERR, "Invalid PF dev.");
+		return;
+	}
+
+	pf = I40E_DEV_PRIVATE_TO_PF(pdev->data->dev_private);
+
+	if (vf_index >= pf->vf_num || !pf->vfs) {
+		PMD_DRV_LOG(ERR, "Invalid VF ID.");
+		return;
+	}
+
+	vf = &pf->vfs[vf_index];
+	vsi = vf->vsi;
+	if (!vsi) {
+		PMD_DRV_LOG(ERR, "Invalid VSI.");
+		return;
+	}
+
+	/* Fixme: even though there 3 kinds of hw offloads, hw_vlan_filter,
+	 * hw_vlan_strip, and hw_vlan_extend.
+	 * currently the hw_vlan_extend offload by vsi is not implemented.
+	 */
+
+	if (mask & ETH_VLAN_FILTER_MASK) {
+		/* Enable or disable VLAN filtering offload */
+		if (vdev->data->dev_conf.rxmode.hw_vlan_filter)
+			i40e_vsi_config_vlan_filter(vsi, TRUE);
+		else
+			i40e_vsi_config_vlan_filter(vsi, FALSE);
+	}
+
+	if (mask & ETH_VLAN_STRIP_MASK) {
+		/* Enable or disable VLAN stripping offload */
+		if (vdev->data->dev_conf.rxmode.hw_vlan_strip)
+			i40e_vsi_config_vlan_stripping(vsi, TRUE);
+		else
+			i40e_vsi_config_vlan_stripping(vsi, FALSE);
+	}
+}
+
+static void i40e_prep_vlan_strip_queue_set(
+	struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, int on)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	rte_pmd_i40e_set_vf_vlan_stripq(pfid, vf_index, on);
+}
+
+static int i40e_prep_vlan_pvid_set(struct rte_port_representor_broker *rb,
+	struct rte_port_representor *prep, uint16_t vlan_id)
+{
+	uint32_t pfid;
+	uint32_t vf_index;
+
+	pfid = rb->pfid;
+	vf_index = prep->vf_index;
+
+	return rte_pmd_i40e_set_vf_vlan_insert(pfid, vf_index, vlan_id);
+}
+
+struct representor_ops i40e_prep_ops = {
+	.link_update                  = i40e_prep_link_update,
+
+	.promiscuous_enable           = i40e_prep_promiscuous_enable,
+	.promiscuous_disable          = i40e_prep_promiscuous_disable,
+	.allmulticast_enable          = i40e_prep_allmulticast_enable,
+	.allmulticast_disable         = i40e_prep_allmulticast_disable,
+
+	.mac_addr_remove              = i40e_prep_mac_addr_remove,
+	.mac_addr_add                 = i40e_prep_mac_addr_add,
+	.mac_addr_set                 = i40e_prep_mac_addr_set,
+
+	.stats_get                    = i40e_prep_stats_get,
+	.stats_reset                  = i40e_prep_stats_reset,
+
+	.dev_infos_get                = i40e_prep_dev_infos_get,
+
+	.vlan_filter_set              = i40e_prep_vlan_filter_set,
+	.vlan_tpid_set                = i40e_prep_vlan_tpid_set,
+	.vlan_offload_set             = i40e_prep_vlan_offload_set,
+	.vlan_strip_queue_set         = i40e_prep_vlan_strip_queue_set,
+	.vlan_pvid_set                = i40e_prep_vlan_pvid_set,
+
+	.flow_validate                = NULL,
+	.flow_create                  = NULL,
+	.flow_destroy                 = NULL,
+	.flow_flush                   = NULL,
+};
+
+struct representor_ops *rte_i40e_prep_ops = &i40e_prep_ops;
diff --git a/drivers/net/i40e/i40e_prep_ops.h b/drivers/net/i40e/i40e_prep_ops.h
new file mode 100644
index 0000000..d756407
--- /dev/null
+++ b/drivers/net/i40e/i40e_prep_ops.h
@@ -0,0 +1,41 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _I40E_PREP_OPS_H_
+#define _I40E_PREP_OPS_H_
+
+#include <rte_port_representor.h>
+
+extern struct representor_ops *rte_i40e_prep_ops;
+
+#endif /* _I40E_PREP_OPS_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index f12b7f4..70d8f2e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -596,6 +596,53 @@ rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
 	return 0;
 }
 
+static const struct ether_addr null_mac_addr;
+
+int
+rte_pmd_i40e_remove_vf_mac_addr(uint8_t port, uint16_t vf_id,
+	struct ether_addr *mac_addr)
+{
+	struct rte_eth_dev *dev;
+	struct i40e_pf_vf *vf;
+	struct i40e_vsi *vsi;
+	struct i40e_pf *pf;
+
+	if (i40e_validate_mac_addr((u8 *)mac_addr) != I40E_SUCCESS)
+		return -EINVAL;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_i40e_supported(dev))
+		return -ENOTSUP;
+
+	pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+	if (vf_id >= pf->vf_num || !pf->vfs)
+		return -EINVAL;
+
+	vf = &pf->vfs[vf_id];
+	vsi = vf->vsi;
+	if (!vsi) {
+		PMD_DRV_LOG(ERR, "Invalid VSI.");
+		return -EINVAL;
+	}
+
+	if (!is_same_ether_addr(mac_addr, &vf->mac_addr)) {
+		PMD_DRV_LOG(ERR, "Mac address does not match.");
+		return -EINVAL;
+	}
+
+	/* reset the mac with null mac */
+	ether_addr_copy(&null_mac_addr, &vf->mac_addr);
+
+	/* Remove the mac */
+	i40e_vsi_delete_mac(vsi, mac_addr);
+
+	return 0;
+}
+
 /* Set vlan strip on/off for specific VF from host */
 int
 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf_id, uint8_t on)
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 356fa89..812d4dc 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -275,6 +275,24 @@ int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
 				 struct ether_addr *mac_addr);
 
 /**
+ * Remove the VF MAC address.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param vf_id
+ *   VF id.
+ * @param mac_addr
+ *   VF MAC address.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
+ */
+int
+rte_pmd_i40e_remove_vf_mac_addr(uint8_t port, uint16_t vf_id,
+	struct ether_addr *mac_addr);
+
+/**
  * Enable/Disable vf vlan strip for all queues in a pool
  *
  * @param port
-- 
2.7.4



More information about the dev mailing list