Add ability to filter and change MACs

Added new functions to change the MAC address and filter multicast MAC
addresses.

Change-Id: Iddf518e57dc889800a2f706fda51ee4e5c5142f2
Signed-off-by: Todd Foggoa (tfoggoa) <tfoggoa@cisco.com>
diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c
index d68c5ab..a93e9f4 100644
--- a/vnet/vnet/devices/dpdk/device.c
+++ b/vnet/vnet/devices/dpdk/device.c
@@ -43,6 +43,40 @@
 #undef _
 };
 
+clib_error_t *
+dpdk_set_mac_address (vnet_hw_interface_t * hi, char * address)
+{
+   int error;
+   dpdk_main_t * dm = &dpdk_main;
+   dpdk_device_t * xd = vec_elt_at_index (dm->devices, hi->dev_instance);
+
+   error=rte_eth_dev_default_mac_addr_set(xd->device_index,
+                                          (struct ether_addr *) address);
+
+   if (error) {
+     return clib_error_return (0, "mac address set failed: %d", error);
+   } else {
+     return NULL;
+  }
+}
+
+clib_error_t *
+dpdk_set_mc_filter (vnet_hw_interface_t * hi,
+                    struct ether_addr mc_addr_vec[], int naddr)
+{
+  int error;
+  dpdk_main_t * dm = &dpdk_main;
+  dpdk_device_t * xd = vec_elt_at_index (dm->devices, hi->dev_instance);
+
+  error=rte_eth_dev_set_mc_addr_list(xd->device_index, mc_addr_vec, naddr);
+
+  if (error) {
+    return clib_error_return (0, "mc addr list failed: %d", error);
+  } else {
+    return NULL;
+  }
+}
+
 static struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b)
 {
   vlib_main_t * vm = vlib_get_main();
diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h
index b35425c..e90f403 100644
--- a/vnet/vnet/devices/dpdk/dpdk.h
+++ b/vnet/vnet/devices/dpdk/dpdk.h
@@ -424,6 +424,11 @@
 
 void dpdk_set_next_node (dpdk_rx_next_t, char *);
 
+clib_error_t * dpdk_set_mac_address (vnet_hw_interface_t * hi, char * address);
+
+clib_error_t * dpdk_set_mc_filter (vnet_hw_interface_t * hi,
+                                   struct ether_addr mc_addr_vec[], int naddr);
+
 typedef void (*dpdk_io_thread_callback_t) (vlib_main_t *vm);
 
 void dpdk_io_thread (vlib_worker_thread_t * w,
diff --git a/vnet/vnet/plugin/p1.c b/vnet/vnet/plugin/p1.c
index b93ce37..69f8f5c 100644
--- a/vnet/vnet/plugin/p1.c
+++ b/vnet/vnet/plugin/p1.c
@@ -110,7 +110,9 @@
 _(rte_eal_get_configuration)                    \
 _(post_sw_interface_set_flags)                  \
 _(dpdk_get_admin_up_down_in_progress)           \
-_(efd_config)
+_(efd_config)                                   \
+_(dpdk_set_mac_address)                         \
+_(dpdk_set_mc_filter)
 #else
 #define foreach_dpdk_plugin_reference
 #endif