diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2012-09-05 21:11:04 -0400 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2012-11-30 19:26:06 -0500 |
commit | 0e0c3408a5414d4e1f8ca7fadcb513c13bd747e8 (patch) | |
tree | dbaaeb442cdd4657880ad35ac6cd2f68226b60dc /drivers/net/ethernet | |
parent | bb728820fe7c42fdb838ab2745fb5fe6b18b5ffa (diff) |
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: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/sfc/ethtool.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 90f078eff8e6..8e61cd06f66a 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c | |||
@@ -816,6 +816,9 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags) | |||
816 | /* MAC address mask including only MC flag */ | 816 | /* MAC address mask including only MC flag */ |
817 | static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; | 817 | static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; |
818 | 818 | ||
819 | #define IP4_ADDR_FULL_MASK ((__force __be32)~0) | ||
820 | #define PORT_FULL_MASK ((__force __be16)~0) | ||
821 | |||
819 | static int efx_ethtool_get_class_rule(struct efx_nic *efx, | 822 | static int efx_ethtool_get_class_rule(struct efx_nic *efx, |
820 | struct ethtool_rx_flow_spec *rule) | 823 | struct ethtool_rx_flow_spec *rule) |
821 | { | 824 | { |
@@ -865,12 +868,12 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx, | |||
865 | &spec, &proto, &ip_entry->ip4dst, &ip_entry->pdst, | 868 | &spec, &proto, &ip_entry->ip4dst, &ip_entry->pdst, |
866 | &ip_entry->ip4src, &ip_entry->psrc); | 869 | &ip_entry->ip4src, &ip_entry->psrc); |
867 | EFX_WARN_ON_PARANOID(rc); | 870 | EFX_WARN_ON_PARANOID(rc); |
868 | ip_mask->ip4src = ~0; | 871 | ip_mask->ip4src = IP4_ADDR_FULL_MASK; |
869 | ip_mask->psrc = ~0; | 872 | ip_mask->psrc = PORT_FULL_MASK; |
870 | } | 873 | } |
871 | rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW; | 874 | rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW; |
872 | ip_mask->ip4dst = ~0; | 875 | ip_mask->ip4dst = IP4_ADDR_FULL_MASK; |
873 | ip_mask->pdst = ~0; | 876 | ip_mask->pdst = PORT_FULL_MASK; |
874 | return rc; | 877 | return rc; |
875 | } | 878 | } |
876 | 879 | ||
@@ -971,7 +974,7 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx, | |||
971 | 974 | ||
972 | /* Check for unsupported extensions */ | 975 | /* Check for unsupported extensions */ |
973 | if ((rule->flow_type & FLOW_EXT) && | 976 | if ((rule->flow_type & FLOW_EXT) && |
974 | (rule->m_ext.vlan_etype | rule->m_ext.data[0] | | 977 | (rule->m_ext.vlan_etype || rule->m_ext.data[0] || |
975 | rule->m_ext.data[1])) | 978 | rule->m_ext.data[1])) |
976 | return -EINVAL; | 979 | return -EINVAL; |
977 | 980 | ||
@@ -986,16 +989,16 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx, | |||
986 | IPPROTO_TCP : IPPROTO_UDP); | 989 | IPPROTO_TCP : IPPROTO_UDP); |
987 | 990 | ||
988 | /* Must match all of destination, */ | 991 | /* Must match all of destination, */ |
989 | if ((__force u32)~ip_mask->ip4dst | | 992 | if (!(ip_mask->ip4dst == IP4_ADDR_FULL_MASK && |
990 | (__force u16)~ip_mask->pdst) | 993 | ip_mask->pdst == PORT_FULL_MASK)) |
991 | return -EINVAL; | 994 | return -EINVAL; |
992 | /* all or none of source, */ | 995 | /* all or none of source, */ |
993 | if ((ip_mask->ip4src | ip_mask->psrc) && | 996 | if ((ip_mask->ip4src || ip_mask->psrc) && |
994 | ((__force u32)~ip_mask->ip4src | | 997 | !(ip_mask->ip4src == IP4_ADDR_FULL_MASK && |
995 | (__force u16)~ip_mask->psrc)) | 998 | ip_mask->psrc == PORT_FULL_MASK)) |
996 | return -EINVAL; | 999 | return -EINVAL; |
997 | /* and nothing else */ | 1000 | /* and nothing else */ |
998 | if (ip_mask->tos | rule->m_ext.vlan_tci) | 1001 | if (ip_mask->tos || rule->m_ext.vlan_tci) |
999 | return -EINVAL; | 1002 | return -EINVAL; |
1000 | 1003 | ||
1001 | if (ip_mask->ip4src) | 1004 | if (ip_mask->ip4src) |