Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1557659imm; Tue, 2 Oct 2018 10:04:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV60O+1jaNV2uT7pLsZ6nuMGOoBJqZjJGnX9wMVJTdVnXSs+QqXoG73/VIC9Xvh10//JOjWhj X-Received: by 2002:a63:6507:: with SMTP id z7-v6mr14995668pgb.200.1538499873033; Tue, 02 Oct 2018 10:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538499872; cv=none; d=google.com; s=arc-20160816; b=rYJD4p8rgpmU8f+RKaMl8dp4ApdPD0wwiNEK8BLVNHkDU0DwDW8YczpTaCN4p0R2eV 7BSBVg2NsEMKWuP6TEge62TzM1lFPuikBaRCMCL4IOqUXLhzBvThNquHhBKT5FpFIIQo HJsRo6qSNCrU/CHMtgySTrib1cmSl/Wn0JrbhgBm/ZOUAPQhiyGiHBYcMfHTsr4dtjuX oBEBIBkqPagECYQTerUTSaWD2bRv9rVANLVspatqYMfnT9EpeAEBlEHSYWto0UcbFqsB uhtaz+cqpHCfJYLkCDvmWmbJb5Vzdu559FW5om0wxtLdsCWE4kp2axXRnYCPf58UH911 8r5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OXT9djH4SvTtrwSjAAqulD9BKGZmwueLX0GyhIjBKR4=; b=Te8bFtu0HzwvNPI76Ql1BjE0ww/dHgIg8mJ7Hg2AeKhmnWohPQEkoxa5uE4EcVN0sI R2IF2/eVKB8Dcqh3lZHl27m7QEevNiaUbgr/GQPEHo79Zf002bY8bMCi86mqO8A7o+08 47gsdlOfBZXJpb9TGPx7nxlghXba3JN3M4mau0DSO4NrjXVsVW3zdzxST2foQR8TRTpv KSh9OB4C5NIjnu96O6+LRB7qZH2yvTD3jmEFwfk9/gUfi+MeX+wZrs2zL2zXJPIcnEvB tfqYixbCQPd/Q82iSJy9lKa1E06ulIOVJeTkqcZioyynUTFWCc5c3JXtkT+KBdZYfub6 1tsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si15871944plr.267.2018.10.02.10.04.16; Tue, 02 Oct 2018 10:04:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727650AbeJBXkb (ORCPT + 99 others); Tue, 2 Oct 2018 19:40:31 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:38360 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbeJBXkb (ORCPT ); Tue, 2 Oct 2018 19:40:31 -0400 Received: from [148.252.241.226] (helo=rainbowdash) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1g7Nxr-0000Ve-Mm; Tue, 02 Oct 2018 17:56:03 +0100 Received: from ben by rainbowdash with local (Exim 4.91) (envelope-from ) id 1g7Nxr-0005Ty-B8; Tue, 02 Oct 2018 17:56:03 +0100 From: Ben Dooks To: netdev@vger.kernel.org Cc: David.Laight@ACULAB.COM, oneukum@suse.com, davem@davemloft.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel@lists.codethink.co.uk, Ben Dooks Subject: [PATCH] usbnet: smsc95xx: simplify tx_fixup code Date: Tue, 2 Oct 2018 17:56:02 +0100 Message-Id: <20181002165602.21033-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.19.0 In-Reply-To: <59988ed22559410881addfecf58335eb@AcuMS.aculab.com> References: <59988ed22559410881addfecf58335eb@AcuMS.aculab.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The smsc95xx_tx_fixup is doing multiple calls to skb_push() to put an 8-byte command header onto the packet. It would be easier to do one skb_push() and then copy the data in once the push is done. Signed-off-by: Ben Dooks --- drivers/net/usb/smsc95xx.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index cb19aea139d3..813ab93ee2c3 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -2006,6 +2006,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, bool csum = skb->ip_summed == CHECKSUM_PARTIAL; int overhead = csum ? SMSC95XX_TX_OVERHEAD_CSUM : SMSC95XX_TX_OVERHEAD; u32 tx_cmd_a, tx_cmd_b; + void *ptr; /* We do not advertise SG, so skbs should be already linearized */ BUG_ON(skb_shinfo(skb)->nr_frags); @@ -2019,6 +2020,9 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, return NULL; } + tx_cmd_b = (u32)skb->len; + tx_cmd_a = tx_cmd_b | TX_CMD_A_FIRST_SEG_ | TX_CMD_A_LAST_SEG_; + if (csum) { if (skb->len <= 45) { /* workaround - hardware tx checksum does not work @@ -2035,21 +2039,18 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, skb_push(skb, 4); cpu_to_le32s(&csum_preamble); memcpy(skb->data, &csum_preamble, 4); + + tx_cmd_a += 4; + tx_cmd_b += 4; + tx_cmd_b |= TX_CMD_B_CSUM_ENABLE; } } - skb_push(skb, 4); - tx_cmd_b = (u32)(skb->len - 4); - if (csum) - tx_cmd_b |= TX_CMD_B_CSUM_ENABLE; - cpu_to_le32s(&tx_cmd_b); - memcpy(skb->data, &tx_cmd_b, 4); - - skb_push(skb, 4); - tx_cmd_a = (u32)(skb->len - 8) | TX_CMD_A_FIRST_SEG_ | - TX_CMD_A_LAST_SEG_; - cpu_to_le32s(&tx_cmd_a); - memcpy(skb->data, &tx_cmd_a, 4); + ptr = skb_push(skb, 8); + tx_cmd_a = cpu_to_le32(tx_cmd_a); + tx_cmd_b = cpu_to_le32(tx_cmd_b); + memcpy(ptr, &tx_cmd_a, 4); + memcpy(ptr+4, &tx_cmd_b, 4); return skb; } -- 2.19.0