diff options
author | Christian Dechamplain <cdechamp@cisco.com> | 2016-02-19 12:26:57 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2016-03-01 09:52:15 +0000 |
commit | 2073cfe1e61e3732f944e099bdce905d1237b673 (patch) | |
tree | c94811b231eb7827ade4d1e9a332e01174f1e452 | |
parent | 3a03598aab24500568ecd1e80b1b0d6bb66eb59d (diff) |
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>
-rw-r--r-- | vnet/vnet/devices/dpdk/device.c | 34 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/dpdk.h | 5 | ||||
-rw-r--r-- | vnet/vnet/plugin/p1.c | 4 |
3 files changed, 42 insertions, 1 deletions
diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c index d68c5abb4f0..a93e9f4cf82 100644 --- a/vnet/vnet/devices/dpdk/device.c +++ b/vnet/vnet/devices/dpdk/device.c @@ -43,6 +43,40 @@ static char * dpdk_tx_func_error_strings[] = { #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 b35425c2668..e90f4030ce9 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -424,6 +424,11 @@ void vnet_buffer_needs_dpdk_mb (vlib_buffer_t * b); 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 b93ce375f8f..69f8f5c056a 100644 --- a/vnet/vnet/plugin/p1.c +++ b/vnet/vnet/plugin/p1.c @@ -110,7 +110,9 @@ _(rte_malloc_virt2phy) \ _(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 |