提交 0e0c3408 编写于 作者: B Ben Hutchings

sfc: Fix byte order warnings for ethtool RX filter interface

sparse has got a bit more picky since I last ran it over this.  Add
forced casts for use of ~0 as a big-endian value.  Undo the pointless
optimisation of parameter validation with '|'; using '||' avoids these
warnings.
Signed-off-by: NBen Hutchings <bhutchings@solarflare.com>
上级 bb728820
...@@ -816,6 +816,9 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags) ...@@ -816,6 +816,9 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
/* MAC address mask including only MC flag */ /* MAC address mask including only MC flag */
static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
#define IP4_ADDR_FULL_MASK ((__force __be32)~0)
#define PORT_FULL_MASK ((__force __be16)~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)
{ {
...@@ -865,12 +868,12 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx, ...@@ -865,12 +868,12 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx,
&spec, &proto, &ip_entry->ip4dst, &ip_entry->pdst, &spec, &proto, &ip_entry->ip4dst, &ip_entry->pdst,
&ip_entry->ip4src, &ip_entry->psrc); &ip_entry->ip4src, &ip_entry->psrc);
EFX_WARN_ON_PARANOID(rc); EFX_WARN_ON_PARANOID(rc);
ip_mask->ip4src = ~0; ip_mask->ip4src = IP4_ADDR_FULL_MASK;
ip_mask->psrc = ~0; ip_mask->psrc = PORT_FULL_MASK;
} }
rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW; rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW;
ip_mask->ip4dst = ~0; ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
ip_mask->pdst = ~0; ip_mask->pdst = PORT_FULL_MASK;
return rc; return rc;
} }
...@@ -971,7 +974,7 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx, ...@@ -971,7 +974,7 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
/* Check for unsupported extensions */ /* Check for unsupported extensions */
if ((rule->flow_type & FLOW_EXT) && if ((rule->flow_type & FLOW_EXT) &&
(rule->m_ext.vlan_etype | rule->m_ext.data[0] | (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
rule->m_ext.data[1])) rule->m_ext.data[1]))
return -EINVAL; return -EINVAL;
...@@ -986,16 +989,16 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx, ...@@ -986,16 +989,16 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
IPPROTO_TCP : IPPROTO_UDP); IPPROTO_TCP : IPPROTO_UDP);
/* Must match all of destination, */ /* Must match all of destination, */
if ((__force u32)~ip_mask->ip4dst | if (!(ip_mask->ip4dst == IP4_ADDR_FULL_MASK &&
(__force u16)~ip_mask->pdst) ip_mask->pdst == PORT_FULL_MASK))
return -EINVAL; return -EINVAL;
/* all or none of source, */ /* all or none of source, */
if ((ip_mask->ip4src | ip_mask->psrc) && if ((ip_mask->ip4src || ip_mask->psrc) &&
((__force u32)~ip_mask->ip4src | !(ip_mask->ip4src == IP4_ADDR_FULL_MASK &&
(__force u16)~ip_mask->psrc)) ip_mask->psrc == PORT_FULL_MASK))
return -EINVAL; return -EINVAL;
/* and nothing else */ /* and nothing else */
if (ip_mask->tos | rule->m_ext.vlan_tci) if (ip_mask->tos || rule->m_ext.vlan_tci)
return -EINVAL; return -EINVAL;
if (ip_mask->ip4src) if (ip_mask->ip4src)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册