From patchwork Fri Dec 7 01:56:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Gasparakis X-Patchwork-Id: 204374 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9EA782C00A5 for ; Fri, 7 Dec 2012 12:49:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424370Ab2LGBtH (ORCPT ); Thu, 6 Dec 2012 20:49:07 -0500 Received: from mga02.intel.com ([134.134.136.20]:20064 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424330Ab2LGBsx (ORCPT ); Thu, 6 Dec 2012 20:48:53 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 06 Dec 2012 17:48:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,234,1355126400"; d="scan'208";a="230116469" Received: from morpheus.jf.intel.com ([10.23.152.239]) by orsmga001.jf.intel.com with ESMTP; 06 Dec 2012 17:48:51 -0800 From: Joseph Gasparakis To: davem@davemloft.net, shemminger@vyatta.com, chrisw@sous-sol.org, gospo@redhat.com Cc: Joseph Gasparakis , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry@broadcom.com, saeed.bishara@gmail.com, Alexander Duyck Subject: [RFC PATCH v3 4/4] ixgbe: Adding tx encapsulation capability Date: Thu, 6 Dec 2012 17:56:59 -0800 Message-Id: <1354845419-22483-5-git-send-email-joseph.gasparakis@intel.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1354845419-22483-1-git-send-email-joseph.gasparakis@intel.com> References: <1354845419-22483-1-git-send-email-joseph.gasparakis@intel.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch allows ixgbe to recognize encapsulated packets and do the tx checksum offload in hardware. This patch is only for demonstration purposes and should not be applied. Signed-off-by: Joseph Gasparakis Signed-off-by: Alexander Duyck --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 46 ++++++++++++++++++++----- 1 files changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 484bbed..17ebfe0 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -5966,17 +5966,42 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring, if (!(first->tx_flags & IXGBE_TX_FLAGS_TXSW)) return; } + vlan_macip_lens |= skb_network_offset(skb) + << IXGBE_ADVTXD_MACLEN_SHIFT; } else { u8 l4_hdr = 0; - switch (first->protocol) { - case __constant_htons(ETH_P_IP): - vlan_macip_lens |= skb_network_header_len(skb); + union { + struct iphdr *ipv4; + struct ipv6hdr *ipv6; + u8 *raw; + } network_hdr; + union { + struct tcphdr *tcphdr; + u8 *raw; + } transport_hdr; + + if (skb->encapsulation) { + network_hdr.raw = skb_inner_network_header(skb); + transport_hdr.raw = skb_inner_transport_header(skb); + vlan_macip_lens |= skb_inner_network_offset(skb) << + IXGBE_ADVTXD_MACLEN_SHIFT; + } else { + network_hdr.raw = skb_network_header(skb); + transport_hdr.raw = skb_transport_header(skb); + vlan_macip_lens |= skb_network_offset(skb) << + IXGBE_ADVTXD_MACLEN_SHIFT; + } + + /* use first 4 bits to determine IP version */ + switch (network_hdr.ipv4->version) { + case 4: + vlan_macip_lens |= transport_hdr.raw - network_hdr.raw; type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; - l4_hdr = ip_hdr(skb)->protocol; + l4_hdr = network_hdr.ipv4->protocol; break; - case __constant_htons(ETH_P_IPV6): - vlan_macip_lens |= skb_network_header_len(skb); - l4_hdr = ipv6_hdr(skb)->nexthdr; + case 6: + vlan_macip_lens |= transport_hdr.raw - network_hdr.raw; + l4_hdr = network_hdr.ipv6->nexthdr; break; default: if (unlikely(net_ratelimit())) { @@ -5990,7 +6015,7 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring, switch (l4_hdr) { case IPPROTO_TCP: type_tucmd |= IXGBE_ADVTXD_TUCMD_L4T_TCP; - mss_l4len_idx = tcp_hdrlen(skb) << + mss_l4len_idx = (transport_hdr.tcphdr->doff * 4) << IXGBE_ADVTXD_L4LEN_SHIFT; break; case IPPROTO_SCTP: @@ -6016,7 +6041,6 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring, } /* vlan_macip_lens: MACLEN, VLAN tag */ - vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT; vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, @@ -7377,6 +7401,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, netdev->hw_features = netdev->features; + netdev->hw_enc_features = NETIF_F_IP_CSUM | + NETIF_F_IPV6_CSUM | + NETIF_F_SG; + switch (adapter->hw.mac.type) { case ixgbe_mac_82599EB: case ixgbe_mac_X540: