Commit c274d65c authored by Ben Hutchings's avatar Ben Hutchings

sfc: Add support for configuring RX unicast/multicast default filters

On Siena all received packets that don't match a more specific filter
will match the unicast or multicast default filter.  Currently we
leave these set to the default values (RSS with base queue number of
0).  Allow them to be reconfigured to select a single RX queue.

These default filters are programmed through the FILTER_CTL register,
but we represent them internally as an additional table of size 2.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent 7c43161c
...@@ -808,11 +808,16 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags) ...@@ -808,11 +808,16 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
return efx_reset(efx, rc); return efx_reset(efx, rc);
} }
/* MAC address mask including only MC flag */
static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
static int efx_ethtool_get_class_rule(struct efx_nic *efx, static int efx_ethtool_get_class_rule(struct efx_nic *efx,
struct ethtool_rx_flow_spec *rule) struct ethtool_rx_flow_spec *rule)
{ {
struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
struct ethhdr *mac_entry = &rule->h_u.ether_spec;
struct ethhdr *mac_mask = &rule->m_u.ether_spec;
struct efx_filter_spec spec; struct efx_filter_spec spec;
u16 vid; u16 vid;
u8 proto; u8 proto;
...@@ -828,11 +833,18 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx, ...@@ -828,11 +833,18 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx,
else else
rule->ring_cookie = spec.dmaq_id; rule->ring_cookie = spec.dmaq_id;
rc = efx_filter_get_eth_local(&spec, &vid, if (spec.type == EFX_FILTER_MC_DEF || spec.type == EFX_FILTER_UC_DEF) {
rule->h_u.ether_spec.h_dest); rule->flow_type = ETHER_FLOW;
memcpy(mac_mask->h_dest, mac_addr_mc_mask, ETH_ALEN);
if (spec.type == EFX_FILTER_MC_DEF)
memcpy(mac_entry->h_dest, mac_addr_mc_mask, ETH_ALEN);
return 0;
}
rc = efx_filter_get_eth_local(&spec, &vid, mac_entry->h_dest);
if (rc == 0) { if (rc == 0) {
rule->flow_type = ETHER_FLOW; rule->flow_type = ETHER_FLOW;
memset(rule->m_u.ether_spec.h_dest, ~0, ETH_ALEN); memset(mac_mask->h_dest, ~0, ETH_ALEN);
if (vid != EFX_FILTER_VID_UNSPEC) { if (vid != EFX_FILTER_VID_UNSPEC) {
rule->flow_type |= FLOW_EXT; rule->flow_type |= FLOW_EXT;
rule->h_ext.vlan_tci = htons(vid); rule->h_ext.vlan_tci = htons(vid);
...@@ -1001,27 +1013,40 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx, ...@@ -1001,27 +1013,40 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
} }
case ETHER_FLOW | FLOW_EXT: case ETHER_FLOW | FLOW_EXT:
/* Must match all or none of VID */ case ETHER_FLOW: {
if (rule->m_ext.vlan_tci != htons(0xfff) && u16 vlan_tag_mask = (rule->flow_type & FLOW_EXT ?
rule->m_ext.vlan_tci != 0) ntohs(rule->m_ext.vlan_tci) : 0);
return -EINVAL;
case ETHER_FLOW: /* Must not match on source address or Ethertype */
/* Must match all of destination */
if (!is_broadcast_ether_addr(mac_mask->h_dest))
return -EINVAL;
/* and nothing else */
if (!is_zero_ether_addr(mac_mask->h_source) || if (!is_zero_ether_addr(mac_mask->h_source) ||
mac_mask->h_proto) mac_mask->h_proto)
return -EINVAL; return -EINVAL;
rc = efx_filter_set_eth_local( /* Is it a default UC or MC filter? */
&spec, if (!compare_ether_addr(mac_mask->h_dest, mac_addr_mc_mask) &&
(rule->flow_type & FLOW_EXT && rule->m_ext.vlan_tci) ? vlan_tag_mask == 0) {
ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC, if (is_multicast_ether_addr(mac_entry->h_dest))
mac_entry->h_dest); rc = efx_filter_set_mc_def(&spec);
else
rc = efx_filter_set_uc_def(&spec);
}
/* Otherwise, it must match all of destination and all
* or none of VID.
*/
else if (is_broadcast_ether_addr(mac_mask->h_dest) &&
(vlan_tag_mask == 0xfff || vlan_tag_mask == 0)) {
rc = efx_filter_set_eth_local(
&spec,
vlan_tag_mask ?
ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC,
mac_entry->h_dest);
} else {
rc = -EINVAL;
}
if (rc) if (rc)
return rc; return rc;
break; break;
}
default: default:
return -EINVAL; return -EINVAL;
......
This diff is collapsed.
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
* @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port) * @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port)
* @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID * @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID
* @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address * @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address
* @EFX_FILTER_UC_DEF: Matching all otherwise unmatched unicast
* @EFX_FILTER_MC_DEF: Matching all otherwise unmatched multicast
* @EFX_FILTER_UNSPEC: Match type is unspecified * @EFX_FILTER_UNSPEC: Match type is unspecified
* *
* Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types. * Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types.
...@@ -31,6 +33,8 @@ enum efx_filter_type { ...@@ -31,6 +33,8 @@ enum efx_filter_type {
EFX_FILTER_UDP_WILD, EFX_FILTER_UDP_WILD,
EFX_FILTER_MAC_FULL = 4, EFX_FILTER_MAC_FULL = 4,
EFX_FILTER_MAC_WILD, EFX_FILTER_MAC_WILD,
EFX_FILTER_UC_DEF = 8,
EFX_FILTER_MC_DEF,
EFX_FILTER_TYPE_COUNT, /* number of specific types */ EFX_FILTER_TYPE_COUNT, /* number of specific types */
EFX_FILTER_UNSPEC = 0xf, EFX_FILTER_UNSPEC = 0xf,
}; };
...@@ -117,6 +121,8 @@ extern int efx_filter_set_eth_local(struct efx_filter_spec *spec, ...@@ -117,6 +121,8 @@ extern int efx_filter_set_eth_local(struct efx_filter_spec *spec,
u16 vid, const u8 *addr); u16 vid, const u8 *addr);
extern int efx_filter_get_eth_local(const struct efx_filter_spec *spec, extern int efx_filter_get_eth_local(const struct efx_filter_spec *spec,
u16 *vid, u8 *addr); u16 *vid, u8 *addr);
extern int efx_filter_set_uc_def(struct efx_filter_spec *spec);
extern int efx_filter_set_mc_def(struct efx_filter_spec *spec);
enum { enum {
EFX_FILTER_VID_UNSPEC = 0xffff, EFX_FILTER_VID_UNSPEC = 0xffff,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment