From: "Michael Chan" <mchan@broadcom.com>
To: "David Miller" <davem@davemloft.net>
Cc: "netdev" <netdev@vger.kernel.org>
Subject: [PATCH v2 8/16][BNX2]: Add ipv6 TSO and checksum for 5709.
Date: Thu, 03 May 2007 00:29:53 -0700 [thread overview]
Message-ID: <1178177393.4909.71.camel@dell> (raw)
In-Reply-To: <1178068303.4820.35.camel@dell>
[BNX2]: Add ipv6 TSO and checksum for 5709.
Signed-off-by: Michael Chan <mchan@broadcom.com>
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 89681b3..01977de 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -4537,35 +4537,49 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
u32 tcp_opt_len, ip_tcp_len;
struct iphdr *iph;
- if (skb_header_cloned(skb) &&
- pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
- dev_kfree_skb(skb);
- return NETDEV_TX_OK;
- }
-
vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;
- tcp_opt_len = 0;
- if (tcp_hdr(skb)->doff > 5)
- tcp_opt_len = tcp_optlen(skb);
+ tcp_opt_len = tcp_optlen(skb);
+
+ if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) {
+ u32 tcp_off = skb_transport_offset(skb) -
+ sizeof(struct ipv6hdr) - ETH_HLEN;
- ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
+ vlan_tag_flags |= ((tcp_opt_len >> 2) << 8) |
+ TX_BD_FLAGS_SW_FLAGS;
+ if (likely(tcp_off == 0))
+ vlan_tag_flags &= ~TX_BD_FLAGS_TCP6_OFF0_MSK;
+ else {
+ tcp_off >>= 3;
+ vlan_tag_flags |= ((tcp_off & 0x3) <<
+ TX_BD_FLAGS_TCP6_OFF0_SHL) |
+ ((tcp_off & 0x10) <<
+ TX_BD_FLAGS_TCP6_OFF4_SHL);
+ mss |= (tcp_off & 0xc) << TX_BD_TCP6_OFF2_SHL;
+ }
+ } else {
+ if (skb_header_cloned(skb) &&
+ pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
+ dev_kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
- iph = ip_hdr(skb);
- iph->check = 0;
- iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
- tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
- iph->daddr, 0,
- IPPROTO_TCP, 0);
- if (tcp_opt_len || (iph->ihl > 5)) {
- vlan_tag_flags |= ((iph->ihl - 5) +
- (tcp_opt_len >> 2)) << 8;
+ ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
+
+ iph = ip_hdr(skb);
+ iph->check = 0;
+ iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
+ tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
+ iph->daddr, 0,
+ IPPROTO_TCP,
+ 0);
+ if (tcp_opt_len || (iph->ihl > 5)) {
+ vlan_tag_flags |= ((iph->ihl - 5) +
+ (tcp_opt_len >> 2)) << 8;
+ }
}
- }
- else
- {
+ } else
mss = 0;
- }
mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE);
@@ -5233,10 +5247,15 @@ bnx2_set_rx_csum(struct net_device *dev, u32 data)
static int
bnx2_set_tso(struct net_device *dev, u32 data)
{
- if (data)
+ struct bnx2 *bp = netdev_priv(dev);
+
+ if (data) {
dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
- else
- dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO_ECN);
+ if (CHIP_NUM(bp) == CHIP_NUM_5709)
+ dev->features |= NETIF_F_TSO6;
+ } else
+ dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6 |
+ NETIF_F_TSO_ECN);
return 0;
}
@@ -5534,6 +5553,17 @@ bnx2_phys_id(struct net_device *dev, u32 data)
return 0;
}
+static int
+bnx2_set_tx_csum(struct net_device *dev, u32 data)
+{
+ struct bnx2 *bp = netdev_priv(dev);
+
+ if (CHIP_NUM(bp) == CHIP_NUM_5709)
+ return (ethtool_op_set_tx_hw_csum(dev, data));
+ else
+ return (ethtool_op_set_tx_csum(dev, data));
+}
+
static const struct ethtool_ops bnx2_ethtool_ops = {
.get_settings = bnx2_get_settings,
.set_settings = bnx2_set_settings,
@@ -5556,7 +5586,7 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
.get_rx_csum = bnx2_get_rx_csum,
.set_rx_csum = bnx2_set_rx_csum,
.get_tx_csum = ethtool_op_get_tx_csum,
- .set_tx_csum = ethtool_op_set_tx_csum,
+ .set_tx_csum = bnx2_set_tx_csum,
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
.get_tso = ethtool_op_get_tso,
@@ -6094,11 +6124,16 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
memcpy(dev->perm_addr, bp->mac_addr, 6);
bp->name = board_info[ent->driver_data].name;
- dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
+ if (CHIP_NUM(bp) == CHIP_NUM_5709)
+ dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
+ else
+ dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
#ifdef BCM_VLAN
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
#endif
dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
+ if (CHIP_NUM(bp) == CHIP_NUM_5709)
+ dev->features |= NETIF_F_TSO6;
if ((rc = register_netdev(dev))) {
dev_err(&pdev->dev, "Cannot register net device\n");
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 8e7b29a..70fb639 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -24,8 +24,11 @@ struct tx_bd {
u32 tx_bd_haddr_hi;
u32 tx_bd_haddr_lo;
u32 tx_bd_mss_nbytes;
+ #define TX_BD_TCP6_OFF2_SHL (14)
u32 tx_bd_vlan_tag_flags;
#define TX_BD_FLAGS_CONN_FAULT (1<<0)
+ #define TX_BD_FLAGS_TCP6_OFF0_MSK (3<<1)
+ #define TX_BD_FLAGS_TCP6_OFF0_SHL (1)
#define TX_BD_FLAGS_TCP_UDP_CKSUM (1<<1)
#define TX_BD_FLAGS_IP_CKSUM (1<<2)
#define TX_BD_FLAGS_VLAN_TAG (1<<3)
@@ -34,6 +37,7 @@ struct tx_bd {
#define TX_BD_FLAGS_END (1<<6)
#define TX_BD_FLAGS_START (1<<7)
#define TX_BD_FLAGS_SW_OPTION_WORD (0x1f<<8)
+ #define TX_BD_FLAGS_TCP6_OFF4_SHL (12)
#define TX_BD_FLAGS_SW_FLAGS (1<<13)
#define TX_BD_FLAGS_SW_SNAP (1<<14)
#define TX_BD_FLAGS_SW_LSO (1<<15)
next prev parent reply other threads:[~2007-05-03 6:42 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-02 1:11 [PATCH 0/20][BNX2]: Bug fixes and more 5709 suppot Michael Chan
2007-05-02 7:10 ` Jeff Garzik
2007-05-02 7:14 ` David Miller
2007-05-03 7:25 ` [ETHTOOL]: Add 2.5G bit definitions Michael Chan
2007-05-03 11:11 ` Jeff Garzik
2007-05-03 20:07 ` David Miller
2007-05-03 20:17 ` David Miller
2007-05-03 7:27 ` [PATCH] ethtool: Add 2.5G support Michael Chan
2007-05-03 11:11 ` Jeff Garzik
2007-05-11 20:46 ` Jeff Garzik
2007-05-03 7:27 ` [PATCH v2 0/16][BNX2]: Bug fixes and more 5709 suppot Michael Chan
2007-05-03 7:28 ` [PATCH v2 1/16][BNX2]: Block MII access when ifdown Michael Chan
2007-05-03 20:18 ` David Miller
2007-05-03 7:28 ` [PATCH v2 2/16][BNX2]: Fix register and memory test on 5709 Michael Chan
2007-05-03 20:18 ` David Miller
2007-05-03 7:28 ` [PATCH v2 3/16][BNX2]: Add 40-bit DMA workaround for 5708 Michael Chan
2007-05-03 20:19 ` David Miller
2007-05-03 7:29 ` [PATCH v2 4/16][BNX2]: Fix race conditions when calling register_netdev() Michael Chan
2007-05-03 20:20 ` David Miller
2007-05-03 7:29 ` [PATCH v2 5/16][BNX2]: Save PCI state during suspend Michael Chan
2007-05-03 20:20 ` David Miller
2007-05-03 7:29 ` [PATCH v2 6/16][BNX2]: Update 5708 firmware Michael Chan
2007-05-03 20:21 ` David Miller
2007-05-03 7:29 ` Michael Chan [this message]
2007-05-03 20:22 ` [PATCH v2 8/16][BNX2]: Add ipv6 TSO and checksum for 5709 David Miller
2007-05-03 7:30 ` [PATCH v2 9/16][BNX2]: Put MII register offsets in the bnx2 struct Michael Chan
2007-05-03 20:23 ` David Miller
2007-05-03 7:30 ` [PATCH v2 10/16][BNX2]: Re-structure the 2.5G Serdes code Michael Chan
2007-05-03 20:23 ` David Miller
2007-05-03 7:30 ` [PATCH v2 11/16][BNX2]: Add support for 5709 Serdes Michael Chan
2007-05-03 20:23 ` David Miller
2007-05-03 7:30 ` [PATCH v2 12/16][BNX2]: Add indirect spinlock Michael Chan
2007-05-03 20:24 ` David Miller
2007-05-03 7:31 ` [PATCH v2 13/16][BNX2]: Restructure PHY event handling Michael Chan
2007-05-03 20:24 ` David Miller
2007-05-03 7:31 ` [PATCH v2 14/16][BNX2]: Add 1-shot MSI handler for 5709 Michael Chan
2007-05-03 20:24 ` David Miller
2007-05-03 7:31 ` [PATCH v2 15/16][BNX2]: Print bus information for PCIE devices Michael Chan
2007-05-03 20:25 ` David Miller
2007-05-03 7:32 ` [PATCH v2 16/16][BNX2]: Update version and reldate Michael Chan
2007-05-03 12:40 ` Jeff Garzik
2007-05-03 20:25 ` David Miller
[not found] ` <1178177565.4909.80.camel@dell>
2007-05-03 20:21 ` [PATCH v2 7/16][BNX2]: Update 5709 firmware David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1178177393.4909.71.camel@dell \
--to=mchan@broadcom.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).