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

Commit 3ed30676 authored by Dave Graham's avatar Dave Graham Committed by David S. Miller
Browse files

e1000: don't generate bad checksums for tcp packets with 0 csum



When offloading transmit checksums only, the driver was not
correctly configuring the hardware to handle the case of a zero
checksum.  For UDP the correct behavior is to leave it alone, but
for tcp the checksum must be changed from 0x0000 to 0xFFFF.  The
hardware takes care of this case but only if it is told the
packet is tcp.

same patch as e1000e

Signed-off-by: default avatarDave Graham <david.graham@intel.com>
Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af807c82
Loading
Loading
Loading
Loading
+36 −19
Original line number Original line Diff line number Diff line
@@ -2873,8 +2873,28 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter,
	struct e1000_buffer *buffer_info;
	struct e1000_buffer *buffer_info;
	unsigned int i;
	unsigned int i;
	u8 css;
	u8 css;
	u32 cmd_len = E1000_TXD_CMD_DEXT;

	if (skb->ip_summed != CHECKSUM_PARTIAL)
		return false;

	switch (skb->protocol) {
	case __constant_htons(ETH_P_IP):
		if (ip_hdr(skb)->protocol == IPPROTO_TCP)
			cmd_len |= E1000_TXD_CMD_TCP;
		break;
	case __constant_htons(ETH_P_IPV6):
		/* XXX not handling all IPV6 headers */
		if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
			cmd_len |= E1000_TXD_CMD_TCP;
		break;
	default:
		if (unlikely(net_ratelimit()))
			DPRINTK(DRV, WARNING,
			        "checksum_partial proto=%x!\n", skb->protocol);
		break;
	}


	if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
	css = skb_transport_offset(skb);
	css = skb_transport_offset(skb);


	i = tx_ring->next_to_use;
	i = tx_ring->next_to_use;
@@ -2887,7 +2907,7 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter,
		css + skb->csum_offset;
		css + skb->csum_offset;
	context_desc->upper_setup.tcp_fields.tucse = 0;
	context_desc->upper_setup.tcp_fields.tucse = 0;
	context_desc->tcp_seg_setup.data = 0;
	context_desc->tcp_seg_setup.data = 0;
		context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
	context_desc->cmd_and_length = cpu_to_le32(cmd_len);


	buffer_info->time_stamp = jiffies;
	buffer_info->time_stamp = jiffies;
	buffer_info->next_to_watch = i;
	buffer_info->next_to_watch = i;
@@ -2898,9 +2918,6 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter,
	return true;
	return true;
}
}


	return false;
}

#define E1000_MAX_TXD_PWR	12
#define E1000_MAX_TXD_PWR	12
#define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)
#define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)