Subject: Re: [PATCH] igb: allow tx of pre-formatted vlan tagged packets

From: Stephen Hemminger <[email-masked]>
Date: Thu, 12 Mar 2009 13:51:19 -0700

On Thu, 12 Mar 2009 13:27:24 -0700
Arthur Jones <[email-masked]> wrote:

> When the 82575 is fed 802.1q packets, it chokes with
> an error of the form:
> 
> igb 0000:08:00.1: partial checksum but proto=81
> 
> As the logic there was not smart enough to look into
> the vlan header to pick out the encapsulated protocol.
> 
> There are times when we'd like to send these packets
> out without having to configure a vlan on the interface.
> Here we check for the vlan tag and allow the packet to
> go out with the correct hardware checksum.
> 
> Thanks to Kand Ly <[email-masked]> for discovering the
> issue and the coming up with a solution.  This patch is
> based upon his work.
> 
> Signed-off-by: Arthur Jones <[email-masked]>
> ---
>  drivers/net/igb/igb_main.c |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)

That code in current igb driver (net-next-2.6) tree no longer has
the whole switch you are changing.

> diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
> index fddeece..99ba3a5 100644
> --- a/drivers/net/igb/igb_main.c
> +++ b/drivers/net/igb/igb_main.c
> @@ -2778,7 +2778,17 @@ static inline bool igb_tx_csum_adv(struct igb_adapter *adapter,
>  		tu_cmd |= (E1000_TXD_CMD_DEXT | E1000_ADVTXD_DTYP_CTXT);
>  
>  		if (skb->ip_summed == CHECKSUM_PARTIAL) {
> -			switch (skb->protocol) {
> +			__be16 protocol;
> +
> +			if (skb->protocol == __constant_htons(ETH_P_8021Q)) {

Don't use __constant_htons() here, macro is smart enough to know when
value is const.

> +				const struct vlan_ethhdr *vhdr =
> +					(const struct vlan_ethhdr *) skb->data;
> +
> +				protocol = vhdr->h_vlan_encapsulated_proto;
> +			} else
> +				protocol = skb->protocol;
> +
> +			switch (protocol) {
>  			case __constant_htons(ETH_P_IP):
>  				tu_cmd |= E1000_ADVTXD_TUCMD_IPV4;
>  				if (ip_hdr(skb)->protocol == IPPROTO_TCP)