multicast address filtering
cover multicast address filtering
Introduce PMD API to set the list of multicast MAC addresses filtered by a port.
Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf. Implementation for physical PMDs i40e, i40evf, enic, and fm10k left to their respective maintainers.
Ivan Boule (5):
ethdev: add multicast address filtering
app/testpmd: new command to add/remove multicast MAC addresses
e1000: add multicast MAC address filtering
ixgbe: add multicast MAC address filtering app/testpmd: fix reply to a multicast ICMP request
app/test-pmd/cmdline.c | 52 ++++++++++++++ app/test-pmd/config.c | 142 ++++++++++++++++++++++++++++++++++++++ app/test-pmd/icmpecho.c | 65 +++++++++++++++-- app/test-pmd/testpmd.h | 6 ++ drivers/net/e1000/em_ethdev.c | 17 +++++ drivers/net/e1000/igb_ethdev.c | 18 +++++ drivers/net/ixgbe/ixgbe_ethdev.c | 32 +++++++++ lib/librte_ether/rte_ethdev.c | 17 +++++ lib/librte_ether/rte_ethdev.h | 26 +++++++ 9 files changed, 369 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/5 ethdev: add multicast address filtering
With the current PMD API, the receipt of multicast packets on a given port can only be enabled by invoking the "rte_eth_allmulticast_enable" function.
This method may not work on Virtual Functions in SR-IOV architectures when the host PF driver does not allow such operation on VFs. In such cases, joined multicast addresses must be individually added in the set of multicast addresses that are filtered by the [VF] port.
For this purpose, a new function "set_mc_addr_list" is introduced into the set of functions that are exported by a Poll Mode Driver.
--- lib/librte_ether/rte_ethdev.c | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
lib/librte_ether/rte_ethdev.c +17 -0
@@ -3628,3 +3628,20 @@ rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,/* Callback wasn't found. */ return -EINVAL ; } + +int +rte_eth_dev_set_mc_addr_list (uint8_t port_id, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr) +{ +struct rte_eth_dev *dev; + +if (port_id >= nb_ports) { +PMD_DEBUG_TRACE ("Invalid port_id=%d\n" , port_id); +return -ENODEV ; + } + + dev = &rte_eth_devices[port_id]; +FUNC_PTR_OR_ERR_RET (*dev->dev_ops->set_mc_addr_list, -ENOTSUP ); +return dev->dev_ops->set_mc_addr_list (dev, mc_addr_set, nb_mc_addr); +}
lib/librte_ether/rte_ethdev.h +26 -0
@@ -1228,6 +1228,10 @@ typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *tunnel_udp);/**< @internal Delete tunneling UDP info */ +typedef int (*eth_set_mc_addr_list_t )(struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +/**< @internal set the list of multicast addresses on an Ethernet device */ #ifdef RTE_NIC_BYPASS
@@ -1386,6 +1390,7 @@ struct eth_dev_ops {/** Get current RSS hash configuration. */ rss_hash_conf_get_t rss_hash_conf_get;eth_filter_ctrl_t filter_ctrl;/**< common filter control*/ +eth_set_mc_addr_list_t set_mc_addr_list;/**< set list of mcast addrs */ };/**
@@ -3615,4 +3620,25 @@ int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id, }#endif +/** +* Set the list of multicast addresses to filter on an Ethernet device. +* +* @param port_id +* The port identifier of the Ethernet device. +* @param mc_addr_set +* The array of multicast addresses to set. Equal to NULL when the function +* is invoked to flush the set of filtered addresses. +* @param nb_mc_addr +* The number of multicast addresses in the *mc_addr_set* array. Equal to 0 +* when the function is invoked to flush the set of filtered addresses. +* @return +* - (0) if successful. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering. +* - (-ENOSPC) if *port_id* has not enough multicast filtering resources. +*/ +int rte_eth_dev_set_mc_addr_list (uint8_t port_id, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +#endif /* _RTE_ETHDEV_H_ */
Signature · 1 line
1.7.10.4
PATCH 2/5 app/testpmd: new command to add/remove multicast MAC addresses
In reply to Ivan BouleAdd the new interactive command:
mcast_addr add|remove X <mcast_addr>
to add/remove the multicast MAC address <mcast_addr> to/from the set of multicast addresses filtered by port <X>.
Command used to test the function "rte_eth_dev_set_mc_addr_list" that has been added to the API of PMDs.
--- app/test-pmd/cmdline.c | 52 ++++++++++++++++++ app/test-pmd/config.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++ 3 files changed, 200 insertions(+)
app/test-pmd/cmdline.c +52 -0
@@ -8733,6 +8733,57 @@ cmdline_parse_inst_t cmd_set_hash_global_config = { }, }; +/* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ +struct cmd_mcast_addr_result { +cmdline_fixed_string_t mcast_addr_cmd; +cmdline_fixed_string_t what; +uint8_t port_num; +struct ether_addr mc_addr; +}; + +static void cmd_mcast_addr_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_mcast_addr_result *res = parsed_result; + +if (!is_multicast_ether_addr (&res->mc_addr)) { +printf ("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n" , + res->mc_addr.addr_bytes[0 ], res->mc_addr.addr_bytes[1 ], + res->mc_addr.addr_bytes[2 ], res->mc_addr.addr_bytes[3 ], + res->mc_addr.addr_bytes[4 ], res->mc_addr.addr_bytes[5 ]); +return ; + } +if (strcmp (res->what,"add" ) ==0 ) +mcast_addr_add (res->port_num, &res->mc_addr); +else +mcast_addr_remove (res->port_num, &res->mc_addr); +} + +cmdline_parse_token_string_t cmd_mcast_addr_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, + mcast_addr_cmd,"mcast_addr" ); +cmdline_parse_token_string_t cmd_mcast_addr_what = + TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, +"add#remove" ); +cmdline_parse_token_num_t cmd_mcast_addr_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8); +cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); + +cmdline_parse_inst_t cmd_mcast_addr = { + .f = cmd_mcast_addr_parsed, + .data = (void *)0 , + .help_str ="mcast_addr add|remove X <mcast_addr>: add/remove multicast MAC address on port X" , + .tokens = { + (void *)&cmd_mcast_addr_cmd, + (void *)&cmd_mcast_addr_what, + (void *)&cmd_mcast_addr_portnum, + (void *)&cmd_mcast_addr_addr, +NULL , + }, +}; +/* ******************************************************************************** */ /* list of instructions */
@@ -8862,6 +8913,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, (cmdline_parse_inst_t *)&cmd_get_hash_global_config, (cmdline_parse_inst_t *)&cmd_set_hash_global_config, + (cmdline_parse_inst_t *)&cmd_mcast_addr, NULL, };
app/test-pmd/config.c +142 -0
145 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -162,6 +162,8 @@ struct rte_port {uint8_t dcb_flag;/**< enable dcb */ struct rte_eth_rxconf rx_conf;/**< rx configuration */ struct rte_eth_txconf tx_conf;/**< tx configuration */ +struct ether_addr *mc_addr_pool;/**< pool of multicast addrs */ +uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ };extern portid_t __rte_unused
@@ -563,6 +565,10 @@ void get_5tuple_filter(uint8_t port_id, uint16_t index);int rx_queue_id_is_invalid (queueid_t rxq_id);int tx_queue_id_is_invalid (queueid_t txq_id); +/* Functions to manage the set of filtered Multicast MAC addresses */ +void mcast_addr_add (uint8_t port_id,struct ether_addr *mc_addr); +void mcast_addr_remove (uint8_t port_id,struct ether_addr *mc_addr); +enum print_warning {ENABLED_WARN =0 ,DISABLED_WARN
Signature · 1 line
1.7.10.4
PATCH 3/5 e1000: add multicast MAC address filtering
In reply to Ivan BouleSupport the PMD function "set_mc_addr_list" in the "igb", "igb-vf", and "em" Poll Mode Drivers.
--- drivers/net/e1000/em_ethdev.c | 17 +++++++++++++++++ drivers/net/e1000/igb_ethdev.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+)
drivers/net/e1000/em_ethdev.c +17 -0
@@ -116,6 +116,10 @@ static void eth_em_rar_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr, uint32_t index, uint32_t pool);static void eth_em_rar_clear (struct rte_eth_dev *dev,uint32_t index); +static int eth_em_set_mc_addr_list (struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +#define EM_FC_PAUSE_TIME 0x0680#define EM_LINK_UPDATE_CHECK_TIMEOUT 90/* 9s */ #define EM_LINK_UPDATE_CHECK_INTERVAL 100/* ms */
@@ -161,6 +165,7 @@ static const struct eth_dev_ops eth_em_ops = { .flow_ctrl_set = eth_em_flow_ctrl_set, .mac_addr_add = eth_em_rar_set, .mac_addr_remove = eth_em_rar_clear, + .set_mc_addr_list = eth_em_set_mc_addr_list, };/**
@@ -1522,6 +1527,18 @@ eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)return 0 ; } +static int +eth_em_set_mc_addr_list (struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr) +{ +struct e1000_hw *hw; + + hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); +e1000_update_mc_addr_list (hw, (u8 *)mc_addr_set, nb_mc_addr); +return 0 ; +} +struct rte_driver em_pmd_drv = { .type =PMD_PDEV , .init = rte_em_pmd_init,
drivers/net/e1000/igb_ethdev.c +18 -0
@@ -194,6 +194,10 @@ static int eth_igb_filter_ctrl(struct rte_eth_dev *dev,enum rte_filter_op filter_op, void *arg); +static int eth_igb_set_mc_addr_list (struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +/* * Define VF Stats MACRO for Non "cleared on read" register */
@@ -269,6 +273,7 @@ static const struct eth_dev_ops eth_igb_ops = { .rss_hash_update = eth_igb_rss_hash_update, .rss_hash_conf_get = eth_igb_rss_hash_conf_get, .filter_ctrl = eth_igb_filter_ctrl, + .set_mc_addr_list = eth_igb_set_mc_addr_list, };/*
@@ -289,6 +294,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = { .rx_queue_release = eth_igb_rx_queue_release, .tx_queue_setup = eth_igb_tx_queue_setup, .tx_queue_release = eth_igb_tx_queue_release, + .set_mc_addr_list = eth_igb_set_mc_addr_list, };/**
@@ -3642,6 +3648,18 @@ eth_igb_filter_ctrl(struct rte_eth_dev *dev,return ret; } +static int +eth_igb_set_mc_addr_list (struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr) +{ +struct e1000_hw *hw; + + hw =E1000_DEV_PRIVATE_TO_HW (dev->data->dev_private); +e1000_update_mc_addr_list (hw, (u8 *)mc_addr_set, nb_mc_addr); +return 0 ; +} +static struct rte_driver pmd_igb_drv = { .type =PMD_PDEV , .init = rte_igb_pmd_init,
Signature · 1 line
1.7.10.4
PATCH 4/5 ixgbe: add multicast MAC address filtering
In reply to Ivan BouleSupport the function "set_mc_addr_list" in the "ixgbe" and in the "ixgbe-vf" Poll Mode Drivers.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.c +32 -0
@@ -257,6 +257,10 @@ static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev, void *arg);static int ixgbevf_dev_set_mtu (struct rte_eth_dev *dev,uint16_t mtu); +static int ixgbe_dev_set_mc_addr_list (struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +/* * Define VF Stats MACRO for Non "cleared on read" register */
@@ -381,6 +385,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = { .rss_hash_update = ixgbe_dev_rss_hash_update, .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get, .filter_ctrl = ixgbe_dev_filter_ctrl, + .set_mc_addr_list = ixgbe_dev_set_mc_addr_list, };/*
@@ -406,6 +411,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = { .tx_queue_release = ixgbe_dev_tx_queue_release, .mac_addr_add = ixgbevf_add_mac_addr, .mac_addr_remove = ixgbevf_remove_mac_addr, + .set_mc_addr_list = ixgbe_dev_set_mc_addr_list, };/**
@@ -4439,6 +4445,32 @@ ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,return ret; } +static u8 * +ixgbe_dev_addr_list_itr (__attribute__((unused))struct ixgbe_hw *hw, +u8 **mc_addr_ptr,u32 *vmdq) +{ +u8 *mc_addr; + + *vmdq =0 ; + mc_addr = *mc_addr_ptr; + *mc_addr_ptr = (mc_addr +sizeof (struct ether_addr )); +return mc_addr; +} + +static int +ixgbe_dev_set_mc_addr_list (struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr) +{ +struct ixgbe_hw *hw; +u8 *mc_addr_list; + + hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); + mc_addr_list = (u8 *)mc_addr_set; +return ixgbe_update_mc_addr_list (hw, mc_addr_list, nb_mc_addr, + ixgbe_dev_addr_list_itr, TRUE); +} +static struct rte_driver rte_ixgbe_driver = { .type =PMD_PDEV , .init = rte_ixgbe_pmd_init,
Signature · 1 line
1.7.10.4
PATCH 5/5 app/testpmd: fix reply to a multicast ICMP request
In reply to Ivan BouleSet the IP source and destination addresses in the IP header of the ICMP reply as follows:
- Use the request IP source address as the reply IP destination address
- If the request IP destination address is a multicast IP address
- choose a reply IP source address different from the request IP source address,
- re-compute the IP header checksum.
Otherwise
- switch the request IP source and destination addresses in the reply,
- keep the IP header checksum unchanged.
--- app/test-pmd/icmpecho.c | 65 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 6 deletions(-)
app/test-pmd/icmpecho.c +59 -6
@@ -272,6 +272,30 @@ ipv4_addr_dump(const char *what, uint32_t be_ipv4_addr)printf ("%s" , buf); } +static uint16_t +ipv4_hdr_cksum (struct ipv4_hdr *ip_h) +{ +uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header, +* skipping the checksum field of the header. +*/ + v16_h = (uint16_t *) ip_h; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ]; + +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (~ip_cksum) &0x0000FFFF ; +return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum; +} + +#define is_multicast_ipv4_addr (ipv4_addr) \ + (((rte_be_to_cpu_32((ipv4_addr)) >> 24) & 0x000000FF) == 0xE0) +/* * Receive a burst of packets, lookup for ICMP echo requets, and, if any, * send back ICMP echo replies.
@@ -295,6 +319,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)uint16_t vlan_id;uint16_t arp_op;uint16_t arp_pro; +uint32_t cksum;uint8_t i;int l2_len;#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
@@ -442,19 +467,47 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)/* * Prepare ICMP echo reply to be sent back. * - switch ethernet source and destinations addresses, -* - switch IPv4 source and destinations addresses, +* - use the request IP source address as the reply IP +* destination address, +* - if the request IP destination address is a multicast +* address: +* - choose a reply IP source address different from the +* request IP source address, +* - re-compute the IP header checksum. +* Otherwise: +* - switch the request IP source and destination +* addresses in the reply IP header, +* - keep the IP header checksum unchanged. * - set IP_ICMP_ECHO_REPLY in ICMP header. -* No need to re-compute the IP header checksum. -* Reset ICMP checksum. +* ICMP checksum is computed by assuming it is valid in the +* echo request and not verified. */ ether_addr_copy (ð_h->s_addr, ð_addr);ether_addr_copy (ð_h->d_addr, ð_h->s_addr);ether_addr_copy (ð_addr, ð_h->d_addr); ip_addr = ip_h->src_addr; - ip_h->src_addr = ip_h->dst_addr; - ip_h->dst_addr = ip_addr; +if (is_multicast_ipv4_addr (ip_h->dst_addr)) { +uint32_t ip_src; + + ip_src =rte_be_to_cpu_32 (ip_addr); +if ((ip_src &0x00000003 ) ==1 ) + ip_src = (ip_src &0xFFFFFFFC ) |0x00000002 ; +else + ip_src = (ip_src &0xFFFFFFFC ) |0x00000001 ; + ip_h->src_addr =rte_cpu_to_be_32 (ip_src); + ip_h->dst_addr = ip_addr; + ip_h->hdr_checksum =ipv4_hdr_cksum (ip_h); + }else { + ip_h->src_addr = ip_h->dst_addr; + ip_h->dst_addr = ip_addr; + } icmp_h->icmp_type =IP_ICMP_ECHO_REPLY ; - icmp_h->icmp_cksum =0 ; + cksum = ~icmp_h->icmp_cksum &0xffff ; + cksum += ~htons (IP_ICMP_ECHO_REQUEST <<8 ) &0xffff ; + cksum +=htons (IP_ICMP_ECHO_REPLY <<8 ); + cksum = (cksum &0xffff ) + (cksum >>16 ); + cksum = (cksum &0xffff ) + (cksum >>16 ); + icmp_h->icmp_cksum = ~cksum; pkts_burst[nb_replies++] = pkt; }
Signature · 1 line
1.7.10.4
Quoted 13 lines · On Thu, 28 May 2015 17:05:18 +0200 Ivan Boule <[email protected]> wrote:
Introduce PMD API to set the list of multicast MAC addresses filtered by a port.
Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf. Implementation for physical PMDs i40e, i40evf, enic, and fm10k left to their respective maintainers.Ivan Boule (5):
ethdev: add multicast address filtering
app/testpmd: new command to add/remove multicast MAC addresses
e1000: add multicast MAC address filtering
ixgbe: add multicast MAC address filtering app/testpmd: fix reply to a multicast ICMP request
Quoted 11 lines
app/test-pmd/cmdline.c | 52 ++++++++++++++ app/test-pmd/config.c | 142 ++++++++++++++++++++++++++++++++++++++ app/test-pmd/icmpecho.c | 65 +++++++++++++++-- app/test-pmd/testpmd.h | 6 ++ drivers/net/e1000/em_ethdev.c | 17 +++++ drivers/net/e1000/igb_ethdev.c | 18 +++++ drivers/net/ixgbe/ixgbe_ethdev.c | 32 +++++++++ lib/librte_ether/rte_ethdev.c | 17 +++++ lib/librte_ether/rte_ethdev.h | 26 +++++++ 9 files changed, 369 insertions(+), 6 deletions(-)
Looks good, could you also add support for virtio and vmxnet3?
Re: [PATCH 1/5] ethdev: add multicast address filtering
In reply to Ivan Boulelib/librte_ether/rte_ethdev.c rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id, · line 3643
Quoted 5 lines · On Thu, 28 May 2015 17:05:19 +0200 Ivan Boule <[email protected]> wrote:
lib/librte_ether/rte_ethdev.c +5
-0+if (port_id >= nb_ports) { +PMD_DEBUG_TRACE ("Invalid port_id=%d\n" , port_id); +return -ENODEV ; + } +
Use rte_eth_dev_is_valid_port() function instead.
Re: [PATCH 1/5] ethdev: add multicast address filtering
Quoted 11 lines · Stephen Hemminger
lib/librte_ether/rte_ethdev.c rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id, · line 3643
Quoted 5 lines · On Thu, 28 May 2015 17:05:19 +0200 Ivan Boule <[email protected]> wrote:
lib/librte_ether/rte_ethdev.c +5
-0+if (port_id >= nb_ports) { +PMD_DEBUG_TRACE ("Invalid port_id=%d\n" , port_id); +return -ENODEV ; + } +Use
rte_eth_dev_is_valid_port()function instead.
I missed that.
Thanks.
PATCH v2 1/5 ethdev: add multicast address filtering
In reply to Stephen HemmingerWith the current PMD API, the receipt of multicast packets on a given port can only be enabled by invoking the "rte_eth_allmulticast_enable" function.
This method may not work on Virtual Functions in SR-IOV architectures when the host PF driver does not allow such operation on VFs. In such cases, joined multicast addresses must be individually added in the set of multicast addresses that are filtered by the [VF] port.
For this purpose, a new function "set_mc_addr_list" is introduced into the set of functions that are exported by a Poll Mode Driver.
---
v2:
Use the dedicated function "rte_eth_dev_is_valid_port" to check the "port_id" parameter in "rte_eth_dev_set_mc_addr_list".
lib/librte_ether/rte_ethdev.c | 17 +++++++++++++++++ lib/librte_ether/rte_ethdev.h | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
lib/librte_ether/rte_ethdev.c +17 -0
@@ -3628,3 +3628,20 @@ rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,/* Callback wasn't found. */ return -EINVAL ; } + +int +rte_eth_dev_set_mc_addr_list (uint8_t port_id, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr) +{ +struct rte_eth_dev *dev; + +if (!rte_eth_dev_is_valid_port (port_id)) { +PMD_DEBUG_TRACE ("Invalid port_id=%d\n" , port_id); +return -ENODEV ; + } + + dev = &rte_eth_devices[port_id]; +FUNC_PTR_OR_ERR_RET (*dev->dev_ops->set_mc_addr_list, -ENOTSUP ); +return dev->dev_ops->set_mc_addr_list (dev, mc_addr_set, nb_mc_addr); +}
lib/librte_ether/rte_ethdev.h +26 -0
@@ -1228,6 +1228,10 @@ typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *tunnel_udp);/**< @internal Delete tunneling UDP info */ +typedef int (*eth_set_mc_addr_list_t )(struct rte_eth_dev *dev, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +/**< @internal set the list of multicast addresses on an Ethernet device */ #ifdef RTE_NIC_BYPASS
@@ -1386,6 +1390,7 @@ struct eth_dev_ops {/** Get current RSS hash configuration. */ rss_hash_conf_get_t rss_hash_conf_get;eth_filter_ctrl_t filter_ctrl;/**< common filter control*/ +eth_set_mc_addr_list_t set_mc_addr_list;/**< set list of mcast addrs */ };/**
@@ -3615,4 +3620,25 @@ int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id, }#endif +/** +* Set the list of multicast addresses to filter on an Ethernet device. +* +* @param port_id +* The port identifier of the Ethernet device. +* @param mc_addr_set +* The array of multicast addresses to set. Equal to NULL when the function +* is invoked to flush the set of filtered addresses. +* @param nb_mc_addr +* The number of multicast addresses in the *mc_addr_set* array. Equal to 0 +* when the function is invoked to flush the set of filtered addresses. +* @return +* - (0) if successful. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering. +* - (-ENOSPC) if *port_id* has not enough multicast filtering resources. +*/ +int rte_eth_dev_set_mc_addr_list (uint8_t port_id, +struct ether_addr *mc_addr_set, +uint32_t nb_mc_addr); +#endif /* _RTE_ETHDEV_H_ */
Signature · 1 line
1.7.10.4
Quoted 28 lines · Stephen Hemminger
Quoted 13 lines · On Thu, 28 May 2015 17:05:18 +0200 Ivan Boule <[email protected]> wrote:
Introduce PMD API to set the list of multicast MAC addresses filtered by a port.
Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf. Implementation for physical PMDs i40e, i40evf, enic, and fm10k left to their respective maintainers.Ivan Boule (5):
ethdev: add multicast address filtering
app/testpmd: new command to add/remove multicast MAC addresses
e1000: add multicast MAC address filtering
ixgbe: add multicast MAC address filtering app/testpmd: fix reply to a multicast ICMP requestQuoted 11 lines
app/test-pmd/cmdline.c | 52 ++++++++++++++ app/test-pmd/config.c | 142 ++++++++++++++++++++++++++++++++++++++ app/test-pmd/icmpecho.c | 65 +++++++++++++++-- app/test-pmd/testpmd.h | 6 ++ drivers/net/e1000/em_ethdev.c | 17 +++++ drivers/net/e1000/igb_ethdev.c | 18 +++++ drivers/net/ixgbe/ixgbe_ethdev.c | 32 +++++++++ lib/librte_ether/rte_ethdev.c | 17 +++++ lib/librte_ether/rte_ethdev.h | 26 +++++++ 9 files changed, 369 insertions(+), 6 deletions(-)
Quoted 2 lines
Looks good, could you also add support for virtio and vmxnet3?
As for physical NICs (i40e, etc.) listed above, I let the maintainers of the remaining NICs where this function is relevant to implement and to test it.
By the way, I supposed that Guest front-end vNICs were always in promiscuous mode by construction.
Said differently: that all packets supplied "from the outside" to the Host vNIC back-end driver were systematically delivered to the Guest vNIC front-end, whatever their destination MAC address, VLAN id., etc. Did I missed something ?
Re: default unicast mac address - was: add multicast address filtering
In reply to Stephen HemmingerHi Stephen,
Looking at mac address management, you and Changchun added an entry in driver ops to be able to change the default mac address with virtio:
http://dpdk.org/browse/dpdk/commit/?id=5186fb1f37fe986 Other ops functions (mac_addr_add/remove) manage the secondary unicast mac addresses and have a wrapper function in the API: http://dpdk.org/doc/api/rte__ethdev_8h.html#aa2b81750086f5f9e55cf65e5cf9f2c58
It seems now that the review of the above patch was too weak and I'd like these issues to be fixed:
- mac_addr_set must be wrapped by rte_eth_dev_mac_addr_set()
- eth_mac_addr_set_t must be fixed to explicitly state that it
replaces the default address
I'm wondering what was the first intent since virtio_mac_addr_set() is never called?
Quoted 31 lines · On Fri, 29 May 2015 11:33:54 +0200 Ivan Boule <[email protected]> wrote:
Quoted 28 lines · Stephen Hemminger
Quoted 13 lines · On Thu, 28 May 2015 17:05:18 +0200 Ivan Boule <[email protected]> wrote:
Introduce PMD API to set the list of multicast MAC addresses filtered by a port.
Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf. Implementation for physical PMDs i40e, i40evf, enic, and fm10k left to their respective maintainers.Ivan Boule (5):
ethdev: add multicast address filtering
app/testpmd: new command to add/remove multicast MAC addresses
e1000: add multicast MAC address filtering
ixgbe: add multicast MAC address filtering app/testpmd: fix reply to a multicast ICMP requestQuoted 11 lines
app/test-pmd/cmdline.c | 52 ++++++++++++++ app/test-pmd/config.c | 142 ++++++++++++++++++++++++++++++++++++++ app/test-pmd/icmpecho.c | 65 +++++++++++++++-- app/test-pmd/testpmd.h | 6 ++ drivers/net/e1000/em_ethdev.c | 17 +++++ drivers/net/e1000/igb_ethdev.c | 18 +++++ drivers/net/ixgbe/ixgbe_ethdev.c | 32 +++++++++ lib/librte_ether/rte_ethdev.c | 17 +++++ lib/librte_ether/rte_ethdev.h | 26 +++++++ 9 files changed, 369 insertions(+), 6 deletions(-)Quoted 2 lines
Looks good, could you also add support for virtio and vmxnet3?
Quoted 10 lines
As for physical NICs (i40e, etc.) listed above, I let the maintainers of the remaining NICs where this function is relevant to implement and to test it.
By the way, I supposed that Guest front-end vNICs were always in promiscuous mode by construction.
Said differently: that all packets supplied "from the outside" to the Host vNIC back-end driver were systematically delivered to the Guest vNIC front-end, whatever their destination MAC address, VLAN id., etc. Did I missed something ?
For virtio, there is a mac address table, and Multicast filtering is done by adding the multicast address to the macs table.
For vmxnet3, ther is multicast address table (shared with host) so that multicast filtering can be done hypervisor.
Re: default unicast mac address - was: add multicast address filtering
In reply to Thomas MonjalonQuoted 9 lines · On Fri, 29 May 2015 15:12:28 +0200 Thomas Monjalon <[email protected]>…
Hi Stephen,
Looking at mac address management, you and Changchun added an entry in driver ops to be able to change the default mac address with virtio:
http://dpdk.org/browse/dpdk/commit/?id=5186fb1f37fe986 Other ops functions (mac_addr_add/remove) manage the secondary unicast mac addresses and have a wrapper function in the API: http://dpdk.org/doc/api/rte__ethdev_8h.html#aa2b81750086f5f9e55cf65e5cf9f2c58
Quoted 5 lines
It seems now that the review of the above patch was too weak and I'd like these issues to be fixed:
-mac_addr_setmust be wrapped byrte_eth_dev_mac_addr_set()
-eth_mac_addr_set_tmust be fixed to explicitly state that it
replaces the default address
Sure, also some other drivers need mac_addr_set hook.
2015-05-28 17:05, Ivan Boule:
Quoted 6 lines
Introduce PMD API to set the list of multicast MAC addresses filtered by a port.
Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf. Implementation for physical PMDs i40e, i40evf, enic, and fm10k left to their respective maintainers.
Quoted 6 lines
Ivan Boule (5):
ethdev: add multicast address filtering
app/testpmd: new command to add/remove multicast MAC addresses
e1000: add multicast MAC address filtering
ixgbe: add multicast MAC address filtering app/testpmd: fix reply to a multicast ICMP request
The new symbol was not exported in the .map file (fixed before push). Applied, thanks