Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8cd0989 authored by Tom Herbert's avatar Tom Herbert Committed by David S. Miller
Browse files

net: Eliminate NETIF_F_GEN_CSUM and NETIF_F_V[46]_CSUM



These netif flags are unnecessary convolutions. It is more
straightforward to just use NETIF_F_HW_CSUM, NETIF_F_IP_CSUM,
and NETIF_F_IPV6_CSUM directly.

This patch also:
    - Cleans up can_checksum_protocol
    - Simplifies netdev_intersect_features

Signed-off-by: default avatarTom Herbert <tom@herbertland.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a188222b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3128,7 +3128,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
	net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
	net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
			      NETIF_F_HIGHDMA | NETIF_F_TSO |
			      NETIF_F_HIGHDMA | NETIF_F_TSO |
			      NETIF_F_RXCSUM);
			      NETIF_F_RXCSUM);
	if (efx->type->offload_features & NETIF_F_V6_CSUM)
	if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
		net_dev->features |= NETIF_F_TSO6;
		net_dev->features |= NETIF_F_TSO6;
	/* Mask for features that also apply to VLAN devices */
	/* Mask for features that also apply to VLAN devices */
	net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
	net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
+1 −1
Original line number Original line Diff line number Diff line
@@ -758,7 +758,7 @@ static struct lock_class_key macvlan_netdev_xmit_lock_key;
static struct lock_class_key macvlan_netdev_addr_lock_key;
static struct lock_class_key macvlan_netdev_addr_lock_key;


#define ALWAYS_ON_FEATURES \
#define ALWAYS_ON_FEATURES \
	(NETIF_F_SG | NETIF_F_GEN_CSUM | NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX | \
	(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX | \
	 NETIF_F_GSO_ROBUST)
	 NETIF_F_GSO_ROBUST)


#define MACVLAN_FEATURES \
#define MACVLAN_FEATURES \
+1 −1
Original line number Original line Diff line number Diff line
@@ -621,7 +621,7 @@ static inline netdev_features_t vlan_features_check(const struct sk_buff *skb,
						     NETIF_F_SG |
						     NETIF_F_SG |
						     NETIF_F_HIGHDMA |
						     NETIF_F_HIGHDMA |
						     NETIF_F_FRAGLIST |
						     NETIF_F_FRAGLIST |
						     NETIF_F_GEN_CSUM |
						     NETIF_F_HW_CSUM |
						     NETIF_F_HW_VLAN_CTAG_TX |
						     NETIF_F_HW_VLAN_CTAG_TX |
						     NETIF_F_HW_VLAN_STAG_TX);
						     NETIF_F_HW_VLAN_STAG_TX);


+3 −6
Original line number Original line Diff line number Diff line
@@ -146,15 +146,12 @@ enum {
#define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
#define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
				 NETIF_F_TSO6 | NETIF_F_UFO)
				 NETIF_F_TSO6 | NETIF_F_UFO)


#define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
/* List of IP checksum features. Note that NETIF_F_ HW_CSUM should not be
#define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
#define NETIF_F_V6_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)

/* List of IP checksum features. Note that NETIF_HW_CSUM should not be
 * set in features when NETIF_F_IP_CSUM or NETIF_F_IPV6_CSUM are set--
 * set in features when NETIF_F_IP_CSUM or NETIF_F_IPV6_CSUM are set--
 * this would be contradictory
 * this would be contradictory
 */
 */
#define NETIF_F_CSUM_MASK	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
#define NETIF_F_CSUM_MASK	(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
				 NETIF_F_HW_CSUM)


#define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
#define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)


+25 −15
Original line number Original line Diff line number Diff line
@@ -3691,13 +3691,24 @@ __be16 skb_network_protocol(struct sk_buff *skb, int *depth);
static inline bool can_checksum_protocol(netdev_features_t features,
static inline bool can_checksum_protocol(netdev_features_t features,
					 __be16 protocol)
					 __be16 protocol)
{
{
	return ((features & NETIF_F_GEN_CSUM) ||
	if (protocol == htons(ETH_P_FCOE))
		((features & NETIF_F_V4_CSUM) &&
		return !!(features & NETIF_F_FCOE_CRC);
		 protocol == htons(ETH_P_IP)) ||

		((features & NETIF_F_V6_CSUM) &&
	/* Assume this is an IP checksum (not SCTP CRC) */
		 protocol == htons(ETH_P_IPV6)) ||

		((features & NETIF_F_FCOE_CRC) &&
	if (features & NETIF_F_HW_CSUM) {
		 protocol == htons(ETH_P_FCOE)));
		/* Can checksum everything */
		return true;
	}

	switch (protocol) {
	case htons(ETH_P_IP):
		return !!(features & NETIF_F_IP_CSUM);
	case htons(ETH_P_IPV6):
		return !!(features & NETIF_F_IPV6_CSUM);
	default:
		return false;
	}
}
}


#ifdef CONFIG_BUG
#ifdef CONFIG_BUG
@@ -3762,15 +3773,14 @@ void linkwatch_run_queue(void);
static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
							  netdev_features_t f2)
							  netdev_features_t f2)
{
{
	if (f1 & NETIF_F_GEN_CSUM)
	if ((f1 ^ f2) & NETIF_F_HW_CSUM) {
		f1 |= (NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM);
		if (f1 & NETIF_F_HW_CSUM)
	if (f2 & NETIF_F_GEN_CSUM)
			f1 |= (NETIF_F_IP_CSUM|NETIF_F_IP_CSUM);
		f2 |= (NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM);
		else
	f1 &= f2;
			f2 |= (NETIF_F_IP_CSUM|NETIF_F_IP_CSUM);
	if (f1 & NETIF_F_GEN_CSUM)
	}
		f1 &= ~(NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM);


	return f1;
	return f1 & f2;
}
}


static inline netdev_features_t netdev_get_wanted_features(
static inline netdev_features_t netdev_get_wanted_features(
Loading