Support setting VF MAC address from PF.
User can call the API on PF to set a speific VF's
MAC address.
Signed-off-by: Ferruh Yigit
---
app/test/Makefile | 8 +++
app/test/test_pmd_i40e.c | 96 +++
drivers/net/i40e/i40e_ethdev.c| 42 ++
drivers/net/i40e/rte_pmd_i40e.h | 19 ++
drivers/net/i40e/rte_pmd_i40e_version.map | 2 +
5 files changed, 167 insertions(+)
create mode 100644 app/test/test_pmd_i40e.c
diff --git a/app/test/Makefile b/app/test/Makefile
index 5be023a..b3f6ecb 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -199,6 +199,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
SRCS-$(CONFIG_RTE_LIBRTE_KVARGS) += test_kvargs.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += test_pmd_i40e.c
+
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
@@ -228,6 +230,12 @@ endif
endif
endif
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+ifeq ($(CONFIG_RTE_LIBRTE_I40E_PMD),y)
+LDLIBS += -lrte_pmd_i40e
+endif
+endif
+
ifeq ($(CONFIG_RTE_APP_TEST_RESOURCE_TAR),y)
LDLIBS += -larchive
endif
diff --git a/app/test/test_pmd_i40e.c b/app/test/test_pmd_i40e.c
new file mode 100644
index 000..c901e89
--- /dev/null
+++ b/app/test/test_pmd_i40e.c
@@ -0,0 +1,96 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright(c) 2016 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
+#include
+#include
+#include
+
+#include
+#include
+
+#include "test.h"
+
+#define I40E_DRV_NAME "net_i40e"
+
+static struct ether_addr mac_addr = {
+ { 0xAA, 0xBB, 0xCC, 0xDD, 0x00, 0x00 }
+};
+
+static const int max_vfs = 3;
+
+static int
+test_i40e(void)
+{
+ struct rte_eth_dev_info dev_info;
+ struct ether_addr current_mac_addr;
+ uint8_t nb_ports;
+ uint8_t port;
+ int ret = 0;
+ int i;
+
+ nb_ports = rte_eth_dev_count();
+ printf("nb_ports=%d\n", nb_ports);
+
+ for (port = 0; port < nb_ports; port++) {
+ rte_eth_dev_info_get(port, _info);
+
+ printf("%d: %s\n", port, dev_info.driver_name);
+
+ if (strcmp(dev_info.driver_name, I40E_DRV_NAME))
+ continue;
+
+ rte_eth_macaddr_get(port, _mac_addr);
+
+ printf("%d: mac address:", port);
+ for (i = 0; i < ETHER_ADDR_LEN - 1; i++)
+ printf("%x:", current_mac_addr.addr_bytes[i]);
+ printf("%x\n", current_mac_addr.addr_bytes[ETHER_ADDR_LEN - 1]);
+
+ for (i = 0; i < max_vfs; i++) {
+ if (i >= dev_info.max_vfs)
+ break;
+
+ mac_addr.addr_bytes[ETHER_ADDR_LEN - 2] = port + 1;
+ mac_addr.addr_bytes[ETHER_ADDR_LEN - 1] = i + 1;
+
+ ret = rte_pmd_i40e_set_vf_mac_addr(port, i, _addr);
+ printf("port:%d vf:%d set mac %s\n",
+ port, i, ret ? "failed" : "succeed");
+ }
+ }
+
+ return 0;
+}
+
+REGISTER_TEST_COMMAND(i40e_autotest, test_i40e);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 319080e..bfc9169 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -10293,3 +10293,45 @@ static void