From: Steve Glendinning <steve.glendinning@smsc.com>
To: netdev@vger.kernel.org
Subject: [PATCH 4/4] smsc75xx: add TX segmentation offload support
Date: Wed, 10 Mar 2010 18:26:57 +0000 [thread overview]
Message-ID: <1268245617-13698-5-git-send-email-steve.glendinning@smsc.com> (raw)
In-Reply-To: <1268245617-13698-4-git-send-email-steve.glendinning@smsc.com>
Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
---
drivers/net/usb/smsc75xx.c | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 8841643..300e3e7 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -42,6 +42,7 @@
#define EEPROM_MAC_OFFSET (0x01)
#define DEFAULT_TX_CSUM_ENABLE (true)
#define DEFAULT_RX_CSUM_ENABLE (true)
+#define DEFAULT_TSO_ENABLE (true)
#define SMSC75XX_INTERNAL_PHY_ID (1)
#define SMSC75XX_TX_OVERHEAD (8)
#define MAX_RX_FIFO_SIZE (20 * 1024)
@@ -615,6 +616,16 @@ static int smsc75xx_ethtool_set_rx_csum(struct net_device *netdev, u32 val)
return smsc75xx_set_rx_csum_offload(dev);
}
+static int smsc75xx_ethtool_set_tso(struct net_device *netdev, u32 data)
+{
+ if (data)
+ netdev->features |= NETIF_F_TSO | NETIF_F_TSO6;
+ else
+ netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
+
+ return 0;
+}
+
static const struct ethtool_ops smsc75xx_ethtool_ops = {
.get_link = usbnet_get_link,
.nway_reset = usbnet_nway_reset,
@@ -630,6 +641,8 @@ static const struct ethtool_ops smsc75xx_ethtool_ops = {
.set_tx_csum = ethtool_op_set_tx_hw_csum,
.get_rx_csum = smsc75xx_ethtool_get_rx_csum,
.set_rx_csum = smsc75xx_ethtool_set_rx_csum,
+ .get_tso = ethtool_op_get_tso,
+ .set_tso = smsc75xx_ethtool_set_tso,
};
static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
@@ -950,6 +963,8 @@ static int smsc75xx_reset(struct usbnet *dev)
ret = smsc75xx_set_rx_csum_offload(dev);
check_warn_return(ret, "Failed to set rx csum offload: %d", ret);
+ smsc75xx_ethtool_set_tso(dev->net, DEFAULT_TSO_ENABLE);
+
smsc75xx_set_multicast(dev->net);
ret = smsc75xx_phy_initialize(dev);
@@ -1051,6 +1066,9 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
pdata->use_rx_csum = DEFAULT_RX_CSUM_ENABLE;
+ /* We have to advertise SG otherwise TSO cannot be enabled */
+ dev->net->features |= NETIF_F_SG;
+
/* Init all registers */
ret = smsc75xx_reset(dev);
@@ -1180,8 +1198,7 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev,
{
u32 tx_cmd_a, tx_cmd_b;
- /* We do not advertise SG, so skbs should be already linearized */
- BUG_ON(skb_shinfo(skb)->nr_frags);
+ skb_linearize(skb);
if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) {
struct sk_buff *skb2 =
@@ -1197,7 +1214,14 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev,
if (skb->ip_summed == CHECKSUM_PARTIAL)
tx_cmd_a |= TX_CMD_A_IPE | TX_CMD_A_TPE;
- tx_cmd_b = 0;
+ if (skb_is_gso(skb)) {
+ u16 mss = max(skb_shinfo(skb)->gso_size, TX_MSS_MIN);
+ tx_cmd_b = (mss << TX_CMD_B_MSS_SHIFT) & TX_CMD_B_MSS;
+
+ tx_cmd_a |= TX_CMD_A_LSO;
+ } else {
+ tx_cmd_b = 0;
+ }
skb_push(skb, 4);
cpu_to_le32s(&tx_cmd_b);
--
1.6.6.1
next prev parent reply other threads:[~2010-03-10 18:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-10 18:26 [PATCH 0/4] SMSC LAN75xx USB gigabit ethernet adapter driver Steve Glendinning
2010-03-10 18:26 ` [PATCH 1/4] smsc75xx: " Steve Glendinning
2010-03-10 18:26 ` [PATCH 2/4] smsc75xx: add RX checksum offload Steve Glendinning
2010-03-10 18:26 ` [PATCH 3/4] smsc75xx: add TX " Steve Glendinning
2010-03-10 18:26 ` Steve Glendinning [this message]
2010-03-15 22:40 ` [PATCH 0/4] SMSC LAN75xx USB gigabit ethernet adapter driver 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=1268245617-13698-5-git-send-email-steve.glendinning@smsc.com \
--to=steve.glendinning@smsc.com \
--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).