RX NFC support for hash-based filters
Subsystems (6)
v2 cover RX NFC support for hash-based filters
1. Fix gianfar's validation of filter rule locations. In the previous version of this series, this was a requirement for part 2, but that's no longer the case.
2. Extend ethtool RX NFC rules API to support hash-based filter hardware in which rule locations should be selected by the driver or firmware.
3. Change the sfc driver to implement this API instead of RX n-tuple.
4. Remove support for RX n-tuple, now that there are no in-tree implementations.
Ben.
Ben Hutchings (8):
gianfar: Reject out-of-range RX NFC locations
ethtool: Allow drivers to select RX NFC rule locations
sfc: Change filter ID generation to satisfy priority semantics of RX
NFC
sfc: Use consistent types for filter IDs, indices and search depths
sfc: Add support for retrieving and removing filters by ID
sfc: Implement ethtool RX NFC rules API instead of n-tuple API
sfc: Remove now-unused filter function
ethtool: Remove ethtool_ops::set_rx_ntuple operation
drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 +- drivers/net/ethernet/sfc/efx.h | 16 +- drivers/net/ethernet/sfc/ethtool.c | 188 +++++++++++--- drivers/net/ethernet/sfc/filter.c | 310 +++++++++++++++++++--- drivers/net/ethernet/sfc/filter.h | 12 + include/linux/ethtool.h | 30 ++- net/core/ethtool.c | 66 +---- net/socket.c | 2 +- 8 files changed, 484 insertions(+), 145 deletions(-)
Signature · 7 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 1/8 gianfar: Reject out-of-range RX NFC locations
Currently the driver only uses location values to maintain an ordered list of filters. Make it reject location values >= MAX_FILER_IDX passed to the ETHTOOL_SRXCLSRLINS command, consistent with the range it reports for the ETHTOOL_GRXCLSRLALL command.
---
Sebastian, I took your private reply as an ack; please shout if that's wrong.
Ben.
drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +3 -2
@@ -1692,8 +1692,9 @@ static int gfar_set_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd) ret =gfar_set_hash_opts (priv, cmd);break ;case ETHTOOL_SRXCLSRLINS : -if (cmd->fs.ring_cookie !=RX_CLS_FLOW_DISC && - cmd->fs.ring_cookie >= priv->num_rx_queues) { +if ((cmd->fs.ring_cookie !=RX_CLS_FLOW_DISC && + cmd->fs.ring_cookie >= priv->num_rx_queues) || + cmd->fs.location >=MAX_FILER_IDX ) { ret = -EINVAL ;break ; }
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 2/8 ethtool: Allow drivers to select RX NFC rule locations
In reply to Ben HutchingsDefine special location values for RX NFC that request the driver to select the actual rule location. This allows for implementation on devices that use hash-based filter lookup, whereas currently the API is more suited to devices with TCAM lookup or linear search.
In ethtool_set_rxnfc() and the compat wrapper ethtool_ioctl(), copy the structure back to user-space after insertion so that the actual location is returned.
---
Drivers are now required to report that they recognise special location values and userland is expected to check this before using them. This should allow me to use them in the ethtool utility without breaking compatibility with the current gianfar driver.
Ben.
include/linux/ethtool.h | 26 ++++++++++++++++++++++++-- net/core/ethtool.c | 11 ++++++++++- net/socket.c | 2 +- 3 files changed, 35 insertions(+), 4 deletions(-)
include/linux/ethtool.h +24 -2
@@ -489,7 +489,10 @@ struct ethtool_rx_flow_spec {* on return. * * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined -* rules on return. +* rules on return. If @data is non-zero on return then it is the +* size of the rule table, plus the flag %RX_CLS_LOC_SPECIAL if the +* driver supports any special location values. If that flag is not +* set in @data then special location values should not be used. * * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an * existing rule on entry and @fs contains the rule on return.
@@ -501,10 +504,23 @@ struct ethtool_rx_flow_spec {* must use the second parameter to get_rxnfc() instead of @rule_locs. * * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update. -* @fs.@location specifies the location to use and must not be ignored. +* @fs.@location either specifies the location to use or is a special +* location value with %RX_CLS_LOC_SPECIAL flag set. On return, +* @fs.@location is the actual rule location. * * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an * existing rule on entry. +* +* A driver supporting the special location values for +* %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused +* location, and may remove a rule at a later location (lower +* priority) that matches exactly the same set of flows. The special +* values are: %RX_CLS_LOC_ANY, selecting any location; +* %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum +* priority); and %RX_CLS_LOC_LAST, selecting the last suitable +* location (minimum priority). Additional special values may be +* defined in future and drivers must return -%EINVAL for any +* unrecognised value. */ struct ethtool_rxnfc {__u32 cmd;
@@ -1141,6 +1157,12 @@ struct ethtool_ops {#define RX_CLS_FLOW_DISC 0xffffffffffffffffULL +/* Special RX classification rule insert location values */ +#define RX_CLS_LOC_SPECIAL 0x80000000/* flag */ +#define RX_CLS_LOC_ANY 0xffffffff +#define RX_CLS_LOC_FIRST 0xfffffffe +#define RX_CLS_LOC_LAST 0xfffffffd +/* Reset flags */ /* The reset() operation must clear the flags for the components which * were actually reset. On successful return, the flags indicate the
net/core/ethtool.c +10 -1
@@ -439,6 +439,7 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, {struct ethtool_rxnfc info;size_t info_size =sizeof (info); +int rc;if (!dev->ethtool_ops->set_rxnfc)return -EOPNOTSUPP ;
@@ -454,7 +455,15 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,if (copy_from_user (&info, useraddr, info_size))return -EFAULT ; -return dev->ethtool_ops->set_rxnfc (dev, &info); + rc = dev->ethtool_ops->set_rxnfc (dev, &info); +if (rc) +return rc; + +if (cmd ==ETHTOOL_SRXCLSRLINS && +copy_to_user (useraddr, &info, info_size)) +return -EFAULT ; + +return 0 ; } static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
net/socket.c +1 -1
@@ -2758,10 +2758,10 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)case ETHTOOL_GRXRINGS :case ETHTOOL_GRXCLSRLCNT :case ETHTOOL_GRXCLSRULE : +case ETHTOOL_SRXCLSRLINS : convert_out = true;/* fall through */ case ETHTOOL_SRXCLSRLDEL : -case ETHTOOL_SRXCLSRLINS : buf_size +=sizeof (struct ethtool_rxnfc ); convert_in = true;break ;
Signature · 1 line
1.7.4.4
PATCH v2 3/8 sfc: Change filter ID generation to satisfy priority semantics of RX NFC
In reply to Ben HutchingsAlso add note that the efx_filter_spec::priority field has nothing to do with priority between multiple matching filters.
--- drivers/net/ethernet/sfc/filter.c | 43 ++++++++++++++++++++++++++++++++---- drivers/net/ethernet/sfc/filter.h | 5 ++++ 2 files changed, 43 insertions(+), 5 deletions(-)
drivers/net/ethernet/sfc/filter.c +38 -5
@@ -366,12 +366,45 @@ static int efx_filter_search(struct efx_filter_table *table, } } -/* Construct/deconstruct external filter IDs */ +/* +* Construct/deconstruct external filter IDs. These must be ordered +* by matching priority, for RX NFC semantics. +* +* Each RX MAC filter entry has a flag for whether it can override an +* RX IP filter that also matches. So we assign locations for MAC +* filters with overriding behaviour, then for IP filters, then for +* MAC filters without overriding behaviour. +*/ + +#define EFX_FILTER_INDEX_WIDTH 13 +#define EFX_FILTER_INDEX_MASK ((1 << EFX_FILTER_INDEX_WIDTH) - 1) + +static inline u32 efx_filter_make_id (enum efx_filter_table_id table_id, +unsigned int index,u8 flags) +{ +return (table_id ==EFX_FILTER_TABLE_RX_MAC && + flags &EFX_FILTER_FLAG_RX_OVERRIDE_IP ) ? + index : + (table_id +1 ) <<EFX_FILTER_INDEX_WIDTH | index; +} + +static inline enum efx_filter_table_id efx_filter_id_table_id (u32 id) +{ +return (id <=EFX_FILTER_INDEX_MASK ) ? +EFX_FILTER_TABLE_RX_MAC : + (id >>EFX_FILTER_INDEX_WIDTH ) -1 ; +} + +static inline unsigned int efx_filter_id_index (u32 id) +{ +return id &EFX_FILTER_INDEX_MASK ; +} -static inline int -efx_filter_make_id (enum efx_filter_table_id table_id,unsigned index) +static inline u8 efx_filter_id_flags (u32 id) { -return table_id <<16 | index; +return (id <=EFX_FILTER_INDEX_MASK ) ? +EFX_FILTER_FLAG_RX |EFX_FILTER_FLAG_RX_OVERRIDE_IP : +EFX_FILTER_FLAG_RX ; }/**
@@ -439,7 +472,7 @@ int efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec,netif_vdbg (efx, hw, efx->net_dev,"%s: filter type %d index %d rxq %u set" , __func__, spec->type, filter_idx, spec->dmaq_id); - rc =efx_filter_make_id (table->id, filter_idx); + rc =efx_filter_make_id (table->id, filter_idx, spec->flags); out:spin_unlock_bh (&state->lock);
drivers/net/ethernet/sfc/filter.h +5 -0
@@ -78,6 +78,11 @@ enum efx_filter_flags {* * Use the efx_filter_set_*() functions to initialise the @type and * @data fields. +* +* The @priority field is used by software to determine whether a new +* filter may replace an old one. The hardware priority of a filter +* depends on the filter type and %EFX_FILTER_FLAG_RX_OVERRIDE_IP +* flag. */ struct efx_filter_spec {u8 type:4 ;
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 4/8 sfc: Use consistent types for filter IDs, indices and search depths
In reply to Ben HutchingsFilter IDs are u32 (but never very large) so an ID/error return value should have type s32.
Filter indices and search depths are never negative, so should have type unsigned int.
--- drivers/net/ethernet/sfc/efx.h | 2 +- drivers/net/ethernet/sfc/filter.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/sfc/efx.h +1 -1
@@ -61,7 +61,7 @@ extern void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue);extern int efx_probe_filters (struct efx_nic *efx);extern void efx_restore_filters (struct efx_nic *efx);extern void efx_remove_filters (struct efx_nic *efx); -extern int efx_filter_insert_filter (struct efx_nic *efx, +extern s32 efx_filter_insert_filter (struct efx_nic *efx,struct efx_filter_spec *spec,bool replace); extern int efx_filter_remove_filter(struct efx_nic *efx,
drivers/net/ethernet/sfc/filter.c +7 -7
@@ -332,7 +332,7 @@ static bool efx_filter_equal(const struct efx_filter_spec *left,static int efx_filter_search (struct efx_filter_table *table,struct efx_filter_spec *spec,u32 key, -bool for_insert,int *depth_required) +bool for_insert,unsigned int *depth_required) {unsigned hash, incr, filter_idx, depth, depth_max;
@@ -417,14 +417,14 @@ static inline u8 efx_filter_id_flags(u32 id)* On success, return the filter ID. * On failure, return a negative error code. */ -int efx_filter_insert_filter (struct efx_nic *efx,struct efx_filter_spec *spec, +s32 efx_filter_insert_filter (struct efx_nic *efx,struct efx_filter_spec *spec,bool replace) {struct efx_filter_state *state = efx->filter_state;struct efx_filter_table *table =efx_filter_spec_table (state, spec);struct efx_filter_spec *saved_spec;efx_oword_t filter; -int filter_idx, depth; +unsigned int filter_idx, depth;u32 key;int rc;
@@ -481,7 +481,7 @@ out:static void efx_filter_table_clear_entry (struct efx_nic *efx,struct efx_filter_table *table, -int filter_idx) +unsigned int filter_idx) {static efx_oword_t filter;
@@ -509,7 +509,7 @@ int efx_filter_remove_filter(struct efx_nic *efx, struct efx_filter_spec *spec)struct efx_filter_table *table =efx_filter_spec_table (state, spec);struct efx_filter_spec *saved_spec;efx_oword_t filter; -int filter_idx, depth; +unsigned int filter_idx, depth;u32 key;int rc;
@@ -547,7 +547,7 @@ static void efx_filter_table_clear(struct efx_nic *efx, {struct efx_filter_state *state = efx->filter_state;struct efx_filter_table *table = &state->table[table_id]; -int filter_idx; +unsigned int filter_idx;spin_lock_bh (&state->lock);
@@ -578,7 +578,7 @@ void efx_restore_filters(struct efx_nic *efx)enum efx_filter_table_id table_id;struct efx_filter_table *table;efx_oword_t filter; -int filter_idx; +unsigned int filter_idx;spin_lock_bh (&state->lock);
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 5/8 sfc: Add support for retrieving and removing filters by ID
In reply to Ben HutchingsThese new functions will support an implementation of the ethtool RX NFC rules API.
--- drivers/net/ethernet/sfc/efx.h | 12 ++ drivers/net/ethernet/sfc/filter.c | 247 +++++++++++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/filter.h | 7 + 3 files changed, 266 insertions(+), 0 deletions(-)
drivers/net/ethernet/sfc/efx.h +12 -0
@@ -66,8 +66,20 @@ extern s32 efx_filter_insert_filter(struct efx_nic *efx, bool replace);extern int efx_filter_remove_filter (struct efx_nic *efx,struct efx_filter_spec *spec); +extern int efx_filter_remove_id_safe (struct efx_nic *efx, +enum efx_filter_priority priority, +u32 filter_id); +extern int efx_filter_get_filter_safe (struct efx_nic *efx, +enum efx_filter_priority priority, +u32 filter_id,struct efx_filter_spec *);extern void efx_filter_clear_rx (struct efx_nic *efx,enum efx_filter_priority priority); +extern u32 efx_filter_count_rx_used (struct efx_nic *efx, +enum efx_filter_priority priority); +extern u32 efx_filter_get_rx_id_limit (struct efx_nic *efx); +extern s32 efx_filter_get_rx_ids (struct efx_nic *efx, +enum efx_filter_priority priority, +u32 *buf,u32 size);#ifdef CONFIG_RFS_ACCEL extern int efx_filter_rfs (struct net_device *net_dev,const struct sk_buff *skb,u16 rxq_index,u32 flow_id);
drivers/net/ethernet/sfc/filter.c +247 -0
289 lines not on this page · raw message
drivers/net/ethernet/sfc/filter.h +7 -0
@@ -105,11 +105,18 @@ static inline void efx_filter_init_rx(struct efx_filter_spec *spec,extern int efx_filter_set_ipv4_local (struct efx_filter_spec *spec,u8 proto,__be32 host,__be16 port); +extern int efx_filter_get_ipv4_local (const struct efx_filter_spec *spec, +u8 *proto,__be32 *host,__be16 *port);extern int efx_filter_set_ipv4_full (struct efx_filter_spec *spec,u8 proto,__be32 host,__be16 port,__be32 rhost,__be16 rport); +extern int efx_filter_get_ipv4_full (const struct efx_filter_spec *spec, +u8 *proto,__be32 *host,__be16 *port, +__be32 *rhost,__be16 *rport);extern int efx_filter_set_eth_local (struct efx_filter_spec *spec,u16 vid,const u8 *addr); +extern int efx_filter_get_eth_local (const struct efx_filter_spec *spec, +u16 *vid,u8 *addr);enum {EFX_FILTER_VID_UNSPEC =0xffff , };
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 6/8 sfc: Implement ethtool RX NFC rules API instead of n-tuple API
In reply to Ben Hutchings--- drivers/net/ethernet/sfc/ethtool.c | 188 ++++++++++++++++++++++++++++-------- 1 files changed, 149 insertions(+), 39 deletions(-)
drivers/net/ethernet/sfc/ethtool.c +149 -39
@@ -818,9 +818,58 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)return efx_reset (efx, rc); } +static int efx_ethtool_get_class_rule (struct efx_nic *efx, +struct ethtool_rx_flow_spec *rule) +{ +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 efx_filter_spec spec; +u16 vid; +u8 proto; +int rc; + + rc =efx_filter_get_filter_safe (efx,EFX_FILTER_PRI_MANUAL , + rule->location, &spec); +if (rc) +return rc; + +if (spec.dmaq_id ==0xfff ) + rule->ring_cookie =RX_CLS_FLOW_DISC ; +else + rule->ring_cookie = spec.dmaq_id; + + rc =efx_filter_get_eth_local (&spec, &vid, + rule->h_u.ether_spec.h_dest); +if (rc ==0 ) { + rule->flow_type =ETHER_FLOW ; +memset (rule->m_u.ether_spec.h_dest, ~0 ,ETH_ALEN ); +if (vid !=EFX_FILTER_VID_UNSPEC ) { + rule->flow_type |=FLOW_EXT ; + rule->h_ext.vlan_tci =htons (vid); + rule->m_ext.vlan_tci =htons (0xfff ); + } +return 0 ; + } + + rc =efx_filter_get_ipv4_local (&spec, &proto, + &ip_entry->ip4dst, &ip_entry->pdst); +if (rc !=0 ) { + rc =efx_filter_get_ipv4_full ( + &spec, &proto, &ip_entry->ip4src, &ip_entry->psrc, + &ip_entry->ip4dst, &ip_entry->pdst); +EFX_WARN_ON_PARANOID (rc); + ip_mask->ip4src = ~0 ; + ip_mask->psrc = ~0 ; + } + rule->flow_type = (proto ==IPPROTO_TCP ) ?TCP_V4_FLOW :UDP_V4_FLOW ; + ip_mask->ip4dst = ~0 ; + ip_mask->pdst = ~0 ; +return rc; +} +static int efx_ethtool_get_rxnfc (struct net_device *net_dev, -struct ethtool_rxnfc *info,u32 *rules__always_unused ) +struct ethtool_rxnfc *info,u32 *rule_locs) {struct efx_nic *efx =netdev_priv (net_dev);
@@ -862,42 +911,80 @@ efx_ethtool_get_rxnfc(struct net_device *net_dev,return 0 ; } +case ETHTOOL_GRXCLSRLCNT : + info->data =efx_filter_get_rx_id_limit (efx); +if (info->data ==0 ) +return -EOPNOTSUPP ; + info->data |=RX_CLS_LOC_SPECIAL ; + info->rule_cnt = +efx_filter_count_rx_used (efx,EFX_FILTER_PRI_MANUAL ); +return 0 ; + +case ETHTOOL_GRXCLSRULE : +if (efx_filter_get_rx_id_limit (efx) ==0 ) +return -EOPNOTSUPP ; +return efx_ethtool_get_class_rule (efx, &info->fs); + +case ETHTOOL_GRXCLSRLALL : { +s32 rc; + info->data =efx_filter_get_rx_id_limit (efx); +if (info->data ==0 ) +return -EOPNOTSUPP ; + rc =efx_filter_get_rx_ids (efx,EFX_FILTER_PRI_MANUAL , + rule_locs, info->rule_cnt); +if (rc <0 ) +return rc; + info->rule_cnt = rc; +return 0 ; + } +default :return -EOPNOTSUPP ; } } -static int efx_ethtool_set_rx_ntuple (struct net_device *net_dev, -struct ethtool_rx_ntuple *ntuple) +static int efx_ethtool_set_class_rule (struct efx_nic *efx, +struct ethtool_rx_flow_spec *rule) { -struct efx_nic *efx =netdev_priv (net_dev); -struct ethtool_tcpip4_spec *ip_entry = &ntuple->fs.h_u.tcp_ip4_spec; -struct ethtool_tcpip4_spec *ip_mask = &ntuple->fs.m_u.tcp_ip4_spec; -struct ethhdr *mac_entry = &ntuple->fs.h_u.ether_spec; -struct ethhdr *mac_mask = &ntuple->fs.m_u.ether_spec; -struct efx_filter_spec filter; +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 ethhdr *mac_entry = &rule->h_u.ether_spec; +struct ethhdr *mac_mask = &rule->m_u.ether_spec; +struct efx_filter_spec spec;int rc; -/* Range-check action */ -if (ntuple->fs.action <ETHTOOL_RXNTUPLE_ACTION_CLEAR || - ntuple->fs.action >= (s32 )efx->n_rx_channels) +/* Check that user wants us to choose the location */ +if (rule->location !=RX_CLS_LOC_ANY && + rule->location !=RX_CLS_LOC_FIRST && + rule->location !=RX_CLS_LOC_LAST )return -EINVAL ; -if (~ntuple->fs.data_mask) +/* Range-check ring_cookie */ +if (rule->ring_cookie >= efx->n_rx_channels && + rule->ring_cookie !=RX_CLS_FLOW_DISC )return -EINVAL ; -efx_filter_init_rx (&filter,EFX_FILTER_PRI_MANUAL ,0 , - (ntuple->fs.action ==ETHTOOL_RXNTUPLE_ACTION_DROP ) ? -0xfff : ntuple->fs.action); +/* Check for unsupported extensions */ +if ((rule->flow_type &FLOW_EXT ) && + (rule->m_ext.vlan_etype | rule->m_ext.data[0 ] | + rule->m_ext.data[1 ])) +return -EINVAL ; + +efx_filter_init_rx (&spec,EFX_FILTER_PRI_MANUAL , + (rule->location ==RX_CLS_LOC_FIRST ) ? +EFX_FILTER_FLAG_RX_OVERRIDE_IP :0 , + (rule->ring_cookie ==RX_CLS_FLOW_DISC ) ? +0xfff : rule->ring_cookie); -switch (ntuple->fs.flow_type) { +switch (rule->flow_type) {case TCP_V4_FLOW :case UDP_V4_FLOW : { -u8 proto = (ntuple->fs.flow_type ==TCP_V4_FLOW ? +u8 proto = (rule->flow_type ==TCP_V4_FLOW ?IPPROTO_TCP :IPPROTO_UDP );/* Must match all of destination, */ -if (ip_mask->ip4dst | ip_mask->pdst) +if ((__force u32 )~ip_mask->ip4dst | + (__force u16 )~ip_mask->pdst)return -EINVAL ;/* all or none of source, */ if ((ip_mask->ip4src | ip_mask->psrc) &&
@@ -905,17 +992,17 @@ static int efx_ethtool_set_rx_ntuple(struct net_device *net_dev, (__force u16)~ip_mask->psrc))return -EINVAL ;/* and nothing else */ -if ((u8 )~ip_mask->tos | (u16 )~ntuple->fs.vlan_tag_mask) +if (ip_mask->tos | rule->m_ext.vlan_tci)return -EINVAL ; -if (!ip_mask->ip4src) - rc =efx_filter_set_ipv4_full (&filter, proto, +if (ip_mask->ip4src) + rc =efx_filter_set_ipv4_full (&spec, proto, ip_entry->ip4dst, ip_entry->pdst, ip_entry->ip4src, ip_entry->psrc);else - rc =efx_filter_set_ipv4_local (&filter, proto, + rc =efx_filter_set_ipv4_local (&spec, proto, ip_entry->ip4dst, ip_entry->pdst);if (rc)
@@ -923,23 +1010,24 @@ static int efx_ethtool_set_rx_ntuple(struct net_device *net_dev,break ; } -case ETHER_FLOW : -/* Must match all of destination, */ -if (!is_zero_ether_addr (mac_mask->h_dest)) +case ETHER_FLOW |FLOW_EXT : +/* Must match all or none of VID */ +if (rule->m_ext.vlan_tci !=htons (0xfff ) && + rule->m_ext.vlan_tci !=0 )return -EINVAL ; -/* all or none of VID, */ -if (ntuple->fs.vlan_tag_mask !=0xf000 && - ntuple->fs.vlan_tag_mask !=0xffff ) +case ETHER_FLOW : +/* Must match all of destination */ +if (!is_broadcast_ether_addr (mac_mask->h_dest))return -EINVAL ;/* and nothing else */ -if (!is_broadcast_ether_addr (mac_mask->h_source) || - mac_mask->h_proto !=htons (0xffff )) +if (!is_zero_ether_addr (mac_mask->h_source) || + mac_mask->h_proto)return -EINVAL ; rc =efx_filter_set_eth_local ( - &filter, - (ntuple->fs.vlan_tag_mask ==0xf000 ) ? - ntuple->fs.vlan_tag :EFX_FILTER_VID_UNSPEC , + &spec, + (rule->flow_type &FLOW_EXT && rule->m_ext.vlan_tci) ? +ntohs (rule->h_ext.vlan_tci) :EFX_FILTER_VID_UNSPEC , mac_entry->h_dest);if (rc)return rc;
@@ -949,11 +1037,33 @@ static int efx_ethtool_set_rx_ntuple(struct net_device *net_dev,return -EINVAL ; } -if (ntuple->fs.action ==ETHTOOL_RXNTUPLE_ACTION_CLEAR ) -return efx_filter_remove_filter (efx, &filter); + rc =efx_filter_insert_filter (efx, &spec, true); +if (rc <0 ) +return rc; - rc =efx_filter_insert_filter (efx, &filter, true); -return rc <0 ? rc :0 ; + rule->location = rc; +return 0 ; +} + +static int efx_ethtool_set_rxnfc (struct net_device *net_dev, +struct ethtool_rxnfc *info) +{ +struct efx_nic *efx =netdev_priv (net_dev); + +if (efx_filter_get_rx_id_limit (efx) ==0 ) +return -EOPNOTSUPP ; + +switch (info->cmd) { +case ETHTOOL_SRXCLSRLINS : +return efx_ethtool_set_class_rule (efx, &info->fs); + +case ETHTOOL_SRXCLSRLDEL : +return efx_filter_remove_id_safe (efx,EFX_FILTER_PRI_MANUAL , + info->fs.location); + +default : +return -EOPNOTSUPP ; + } }static u32 efx_ethtool_get_rxfh_indir_size (struct net_device *net_dev)
@@ -1007,7 +1117,7 @@ const struct ethtool_ops efx_ethtool_ops = { .set_wol = efx_ethtool_set_wol, .reset = efx_ethtool_reset, .get_rxnfc = efx_ethtool_get_rxnfc, - .set_rx_ntuple = efx_ethtool_set_rx_ntuple, + .set_rxnfc = efx_ethtool_set_rxnfc, .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size, .get_rxfh_indir = efx_ethtool_get_rxfh_indir, .set_rxfh_indir = efx_ethtool_set_rxfh_indir,
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 7/8 sfc: Remove now-unused filter function
In reply to Ben Hutchings--- drivers/net/ethernet/sfc/efx.h | 2 - drivers/net/ethernet/sfc/filter.c | 46 ------------------------------------- 2 files changed, 0 insertions(+), 48 deletions(-)
drivers/net/ethernet/sfc/efx.h +0 -2
@@ -64,8 +64,6 @@ extern void efx_remove_filters(struct efx_nic *efx);extern s32 efx_filter_insert_filter (struct efx_nic *efx,struct efx_filter_spec *spec,bool replace); -extern int efx_filter_remove_filter (struct efx_nic *efx, -struct efx_filter_spec *spec);extern int efx_filter_remove_id_safe (struct efx_nic *efx,enum efx_filter_priority priority,u32 filter_id);
drivers/net/ethernet/sfc/filter.c +0 -46
52 lines not on this page · raw message
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 8/8 ethtool: Remove ethtool_ops::set_rx_ntuple operation
In reply to Ben HutchingsAll implementations have been converted to implement set_rxnfc instead.
--- include/linux/ethtool.h | 4 --- net/core/ethtool.c | 55 ----------------------------------------------- 2 files changed, 0 insertions(+), 59 deletions(-)
include/linux/ethtool.h +0 -4
@@ -859,8 +859,6 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)* @reset: Reset (part of) the device, as specified by a bitmask of * flags from &enum ethtool_reset_flags. Returns a negative * error code or zero. -* @set_rx_ntuple: Set an RX n-tuple rule. Returns a negative error code -* or zero. * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table. * Returns zero if not supported for this specific device. * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
@@ -929,8 +927,6 @@ struct ethtool_ops {int (*set_rxnfc)(struct net_device *,struct ethtool_rxnfc *);int (*flash_device)(struct net_device *,struct ethtool_flash *);int (*reset)(struct net_device *,u32 *); -int (*set_rx_ntuple)(struct net_device *, -struct ethtool_rx_ntuple *);u32 (*get_rxfh_indir_size)(struct net_device *);int (*get_rxfh_indir)(struct net_device *,u32 *);int (*set_rxfh_indir)(struct net_device *,const u32 *);
net/core/ethtool.c +0 -55
67 lines not on this page · raw message
Signature · 7 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 1/3 ethtool-copy.h: sync with net-next
In reply to Ben HutchingsThis covers kernel changes up to:
commit XXX NOT YET PULLED
Author: Ben Hutchings <[email protected]> Date: Tue Sep 6 21:58:27 2011 +0100
ethtool: Remove ethtool_ops::set_rx_ntuple operation
--- ethtool-copy.h | 38 ++++++++++++++++++++++++++++++++++---- 1 files changed, 34 insertions(+), 4 deletions(-)
ethtool-copy.h +34 -4
@@ -486,7 +486,10 @@ struct ethtool_rx_flow_spec {* on return. * * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined -* rules on return. +* rules on return. If @data is non-zero on return then it is the +* size of the rule table, plus the flag %RX_CLS_LOC_SPECIAL if the +* driver supports any special location values. If that flag is not +* set in @data then special location values should not be used. * * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an * existing rule on entry and @fs contains the rule on return.
@@ -498,10 +501,23 @@ struct ethtool_rx_flow_spec {* must use the second parameter to get_rxnfc() instead of @rule_locs. * * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update. -* @fs.@location specifies the location to use and must not be ignored. +* @fs.@location either specifies the location to use or is a special +* location value with %RX_CLS_LOC_SPECIAL flag set. On return, +* @fs.@location is the actual rule location. * * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an * existing rule on entry. +* +* A driver supporting the special location values for +* %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused +* location, and may remove a rule at a later location (lower +* priority) that matches exactly the same set of flows. The special +* values are: %RX_CLS_LOC_ANY, selecting any location; +* %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum +* priority); and %RX_CLS_LOC_LAST, selecting the last suitable +* location (minimum priority). Additional special values may be +* defined in future and drivers must return -%EINVAL for any +* unrecognised value. */ struct ethtool_rxnfc {__u32 cmd;
@@ -516,9 +532,15 @@ struct ethtool_rxnfc {/** * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR -* @size: On entry, the array size of the user buffer. On return from -* %ETHTOOL_GRXFHINDIR, the array size of the hardware indirection table. +* @size: On entry, the array size of the user buffer, which may be zero. +* On return from %ETHTOOL_GRXFHINDIR, the array size of the hardware +* indirection table. * @ring_index: RX ring/queue index for each hash value +* +* For %ETHTOOL_GRXFHINDIR, a @size of zero means that only the size +* should be returned. For %ETHTOOL_SRXFHINDIR, a @size of zero means +* the table should be reset to default values. This last feature +* is not supported by the original implementations. */ struct ethtool_rxfh_indir {__u32 cmd;
@@ -831,10 +853,12 @@ enum ethtool_sfeatures_retval_bits {#define SPEED_1000 1000#define SPEED_2500 2500#define SPEED_10000 10000 +#define SPEED_UNKNOWN -1/* Duplex, half or full. */ #define DUPLEX_HALF 0x00#define DUPLEX_FULL 0x01 +#define DUPLEX_UNKNOWN 0xff/* Which connector port. */ #define PORT_TP 0x00
@@ -905,6 +929,12 @@ enum ethtool_sfeatures_retval_bits {#define RX_CLS_FLOW_DISC 0xffffffffffffffffULL +/* Special RX classification rule insert location values */ +#define RX_CLS_LOC_SPECIAL 0x80000000/* flag */ +#define RX_CLS_LOC_ANY 0xffffffff +#define RX_CLS_LOC_FIRST 0xfffffffe +#define RX_CLS_LOC_LAST 0xfffffffd +/* Reset flags */ /* The reset() operation must clear the flags for the components which * were actually reset. On successful return, the flags indicate the
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 2/3 rxclass: Use RX_CLS_LOC_{ANY,SPECIAL} in place of RX_CLS_LOC_UNSPEC
In reply to Ben HutchingsThe macro RX_CLS_LOC_ANY is now defined in ethtool(-copy).h with the same intended semantics and same value as RX_CLS_LOC_UNSPEC.
Change some equality tests to check for the flag RX_CLS_LOC_SPECIAL, to allow for future support of other special location value.
Remove the special case for RX_CLS_LOC_UNSPEC inrxclass_print_nfc_rule(), since it is dead code.
--- ethtool.c | 2 +- internal.h | 2 -- rxclass.c | 11 ++++------- 3 files changed, 5 insertions(+), 10 deletions(-)
ethtool.c +1 -1
@@ -2719,7 +2719,7 @@ static int flow_spec_to_ntuple(struct ethtool_rx_flow_spec *fsp,size_t i;/* verify location is not specified */ -if (fsp->location !=RX_CLS_LOC_UNSPEC ) +if (fsp->location !=RX_CLS_LOC_ANY )return -1 ;/* verify ring cookie can transfer to action */
internal.h +0 -2
@@ -86,8 +86,6 @@ static inline int test_bit(unsigned int nr, const unsigned long *addr)#define SIOCETHTOOL 0x8946#endif -#define RX_CLS_LOC_UNSPEC 0xffffffffUL -/* Context for sub-commands */ struct cmd_context {const char *devname;/* net device name */
rxclass.c +4 -7
@@ -68,10 +68,7 @@ static void rxclass_print_nfc_rule(struct ethtool_rx_flow_spec *fsp)unsigned char *smac, *smacm, *dmac, *dmacm;__u32 flow_type; -if (fsp->location !=RX_CLS_LOC_UNSPEC ) -fprintf (stdout,"Filter: %d\n" , fsp->location); -else -fprintf (stdout,"Filter: Unspecified\n" ); +fprintf (stdout,"Filter: %d\n" , fsp->location); flow_type = fsp->flow_type & ~FLOW_EXT ;
@@ -465,7 +462,7 @@ int rxclass_rule_ins(struct cmd_context *ctx,* if location is unspecified pull rules from device * and allocate a free rule for our use */ -if (loc ==RX_CLS_LOC_UNSPEC ) { +if (loc &RX_CLS_LOC_SPECIAL ) { err =rmgr_set_location (ctx, fsp);if (err <0 )return err;
@@ -477,7 +474,7 @@ int rxclass_rule_ins(struct cmd_context *ctx, err =send_ioctl (ctx, &nfccmd);if (err <0 )perror ("rmgr: Cannot insert RX class rule" ); -else if (loc ==RX_CLS_LOC_UNSPEC ) +else if (loc &RX_CLS_LOC_SPECIAL )printf ("Added rule with ID %d\n" , fsp->location);return 0 ;
@@ -998,7 +995,7 @@ int rxclass_parse_ruleopts(struct cmd_context *ctx,memset (p,0 ,sizeof (*fsp)); fsp->flow_type = flow_type; - fsp->location =RX_CLS_LOC_UNSPEC ; + fsp->location =RX_CLS_LOC_ANY ;for (i =1 ; i < argc;) {const struct rule_opts *opt;
Signature · 8 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH v2 3/3 rxclass: Allow driver to select RX NFC rule location
In reply to Ben HutchingsIf the user does not specify a location for an RX NFC rule to be added and the result of the ETHTOOL_GRXCLSRLCNT command indicates that the driver supports special rule locations, let the driver select the location.
--- rxclass.c | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-)
rxclass.c +20 -9
@@ -200,16 +200,17 @@ static void rxclass_print_rule(struct ethtool_rx_flow_spec *fsp) } } -static int rxclass_get_count (struct cmd_context *ctx,__u32 *count) +static int rxclass_get_dev_info (struct cmd_context *ctx,__u32 *count, +int *driver_select) {struct ethtool_rxnfc nfccmd;int err; -/* request count and store */ nfccmd.cmd =ETHTOOL_GRXCLSRLCNT ; - nfccmd.rule_cnt =0 ; err =send_ioctl (ctx, &nfccmd); *count = nfccmd.rule_cnt; +if (driver_select) + *driver_select = !!(nfccmd.data &RX_CLS_LOC_SPECIAL );if (err <0 )perror ("rxclass: Cannot get RX class rule count" );
@@ -244,7 +245,7 @@ int rxclass_rule_getall(struct cmd_context *ctx)__u32 count;/* determine rule count */ - err =rxclass_get_count (ctx, &count); + err =rxclass_get_dev_info (ctx, &count,NULL );if (err <0 )return err;
@@ -290,6 +291,8 @@ int rxclass_rule_getall(struct cmd_context *ctx)*/ struct rmgr_ctrl { +/* flag for device/driver that can select locations itself */ +int driver_select;/* slot contains a bitmap indicating which filters are valid */ unsigned long *slot;__u32 n_rules;
@@ -316,6 +319,10 @@ static int rmgr_find_empty_slot(struct rmgr_ctrl *rmgr,__u32 loc;__u32 slot_num; +/* leave this to the driver if possible */ +if (rmgr->driver_select) +return 0 ; +/* start at the end of the list since it is lowest priority */ loc = rmgr->size -1 ;
@@ -373,11 +380,15 @@ static int rmgr_init(struct cmd_context *ctx, struct rmgr_ctrl *rmgr)/* clear rule manager settings */ memset (rmgr,0 ,sizeof (*rmgr)); -/* request count and store in rmgr->n_rules */ - err =rxclass_get_count (ctx, &rmgr->n_rules); +/* request device/driver information */ + err =rxclass_get_dev_info (ctx, &rmgr->n_rules, &rmgr->driver_select);if (err <0 )return err; +/* do not get the table if the device/driver can select locations */ +if (rmgr->driver_select) +return 0 ; +/* alloc memory for request of location list */ nfccmd =calloc (1 ,sizeof (*nfccmd) + (rmgr->n_rules *sizeof (__u32)));if (!nfccmd) {
@@ -459,8 +470,8 @@ int rxclass_rule_ins(struct cmd_context *ctx,int err;/* -* if location is unspecified pull rules from device -* and allocate a free rule for our use +* if location is unspecified and driver cannot select locations, pull +* rules from device and allocate a free rule for our use */ if (loc &RX_CLS_LOC_SPECIAL ) { err =rmgr_set_location (ctx, fsp);
@@ -475,7 +486,7 @@ int rxclass_rule_ins(struct cmd_context *ctx,if (err <0 )perror ("rmgr: Cannot insert RX class rule" );else if (loc &RX_CLS_LOC_SPECIAL ) -printf ("Added rule with ID %d\n" , fsp->location); +printf ("Added rule with ID %d\n" , nfccmd.fs.location);return 0 ; }
Signature · 7 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
David Miller
maintainerFrom: Ben Hutchings <[email protected]>
Date: Tue, 3 Jan 2012 21:56:59 +0000
Quoted 11 lines
1. Fix gianfar's validation of filter rule locations. In the previous version of this series, this was a requirement for part 2, but that's no longer the case.
2. Extend ethtool RX NFC rules API to support hash-based filter hardware in which rule locations should be selected by the driver or firmware.
3. Change the sfc driver to implement this API instead of RX n-tuple.
4. Remove support for RX n-tuple, now that there are no in-tree implementations.
All applied, I had to fix some trailing whitespace errors in patches 5 and 6.
Quoted 10 lines · David Miller
From: Ben Hutchings <[email protected]>
Date: Tue, 3 Jan 2012 21:56:59 +0000Quoted 7 lines
1. Fix gianfar's validation of filter rule locations. In the previous version of this series, this was a requirement for part 2, but that's no longer the case.
2. Extend ethtool RX NFC rules API to support hash-based filter hardware in which rule locations should be selected by the driver or firmware.
Quoted 7 lines
Quoted 4 lines
3. Change the sfc driver to implement this API instead of RX n-tuple.
4. Remove support for RX n-tuple, now that there are no in-tree implementations.
All applied, I had to fix some trailing whitespace errors in patches 5 and 6.
Thanks, and sorry about the formatting. I should try to work out why git didn't alert me to that earlier...
Ben.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.