aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2019-07-12 11:55:26 -0500
committerDamjan Marion <dmarion@me.com>2019-10-16 18:37:11 +0000
commit153727743b9193f39410bc8445e09f1b93cbd07f (patch)
tree67fe4768b100ebf4d26477de66dca6f7bcef6d9f /src/plugins/dpdk
parent812afe712b62484b4390fa048c76fe8bf4cd0a12 (diff)
dpdk: add function to add/del extra MAC addrs
Type: feature Add a callback to install or remove an additional MAC address on a DPDK-managed device. Note that some PMDs don't have support for this so YMMV. Change-Id: I7b0cb3fb0af0d66fbdb7b894a712897f889520a5 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Diffstat (limited to 'src/plugins/dpdk')
-rw-r--r--src/plugins/dpdk/device/device.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c
index e9c1a557a75..3b41e93e01a 100644
--- a/src/plugins/dpdk/device/device.c
+++ b/src/plugins/dpdk/device/device.c
@@ -43,6 +43,29 @@ static char *dpdk_tx_func_error_strings[] = {
};
static clib_error_t *
+dpdk_add_del_mac_address (vnet_hw_interface_t * hi,
+ const u8 * address, u8 is_add)
+{
+ int error;
+ dpdk_main_t *dm = &dpdk_main;
+ dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance);
+
+ if (is_add)
+ error = rte_eth_dev_mac_addr_add (xd->port_id,
+ (struct rte_ether_addr *) address, 0);
+ else
+ error = rte_eth_dev_mac_addr_remove (xd->port_id,
+ (struct rte_ether_addr *) address);
+
+ if (error)
+ {
+ return clib_error_return (0, "mac address add/del failed: %d", error);
+ }
+
+ return NULL;
+}
+
+static clib_error_t *
dpdk_set_mac_address (vnet_hw_interface_t * hi,
const u8 * old_address, const u8 * address)
{
@@ -600,6 +623,7 @@ VNET_DEVICE_CLASS (dpdk_device_class) = {
.subif_add_del_function = dpdk_subif_add_del_function,
.rx_redirect_to_node = dpdk_set_interface_next_node,
.mac_addr_change_function = dpdk_set_mac_address,
+ .mac_addr_add_del_function = dpdk_add_del_mac_address,
.format_flow = format_dpdk_flow,
.flow_ops_function = dpdk_flow_ops_fn,
};