Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2611482imm; Wed, 3 Oct 2018 06:38:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV60pwmf5jUEZmLasX9RLyS6b0kqEb+9oXQuWZc54fm0pgQ/AZjIRbjZkVzlRF3KwPPbwf+0l X-Received: by 2002:a63:f14a:: with SMTP id o10-v6mr1401399pgk.339.1538573891517; Wed, 03 Oct 2018 06:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538573891; cv=none; d=google.com; s=arc-20160816; b=xl45oD/WatQvWZz29BHRPRjMhxx5su3mQdB6iNEZHnXzzYTo/GR1CFs0pVwpLFoGUL HbKUUDkuchWbuT3u36UZM2tKZ4qRXAGfKInkInNfrGFcji1U0uIkigsCcxhFchI+wPn2 ElfUBaECwRPgXKamzik9MB3qeaAu+9yJ1w6js92epgYvdyar5hms5BEDhLITXjqK4mRS Aq7CTROYW0o1TbNucqPseVsxSiFmeRQz1ZDuF5Ma2AkFAugeYNNvKSktjJBfICemgWId 4RLllKdaEvH7wgPSHHXfMCGk2fFGKDWmJsYXsGm6tRnkF6DV/ONZHKdC01QyL1SrNzsQ t3Vg== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=+YrmXQ7izkRaocg192VDQ83afOIsFYBPVprZ70GqgB4=; b=Ag/icbK7Kynxb6WQA5to/ECFRHgRecYmpF0egOv5/zGWyYIke9ZLM9HZGD0Dr6F/p+ CBYmB3OieKmaofp+qOSgpTRA64QY1B8Fy2ikm75SWXGHEuxDFxZYJ0cyIoUktVdjNxxm 0+YRqjcnTdFtG/m3A3qGsRYD8EQlwnOUXZ6qshmMlyVpngKVIkC0qfMlvu2al0INUSkV 1SY5VhvPKJMizM5gVoCpZt7QZB45wA+J6m1plTcXa4ueKSwQAUknsrb8eIIuPvb7sAM4 V+T133MZ3xdUebfJOhiabX4sGZSsHcvY4KhapNPVb8s6RHLgCmumqrtQumUnmzBGoutT 8/rw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si1486571pgr.336.2018.10.03.06.37.56; Wed, 03 Oct 2018 06:38:11 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727016AbeJCUYt convert rfc822-to-8bit (ORCPT + 99 others); Wed, 3 Oct 2018 16:24:49 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:20755 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbeJCUYt (ORCPT ); Wed, 3 Oct 2018 16:24:49 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-70-VCdlQgMINlqyQC5ESQclYg-1; Wed, 03 Oct 2018 14:36:20 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 3 Oct 2018 14:36:20 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 3 Oct 2018 14:36:20 +0100 From: David Laight To: 'Ben Dooks' , "netdev@vger.kernel.org" CC: "oneukum@suse.com" , "davem@davemloft.net" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-kernel@lists.codethink.co.uk" Subject: RE: [PATCH] usbnet: smsc95xx: simplify tx_fixup code Thread-Topic: [PATCH] usbnet: smsc95xx: simplify tx_fixup code Thread-Index: AQHUWx0583bpLHRSvES/p/KDDm+zIA== Date: Wed, 3 Oct 2018 13:36:20 +0000 Message-ID: <55e4b55bae6148b18a27a23aab7d7501@AcuMS.aculab.com> References: <59988ed22559410881addfecf58335eb@AcuMS.aculab.com> <20181002165602.21033-1-ben.dooks@codethink.co.uk> In-Reply-To: <20181002165602.21033-1-ben.dooks@codethink.co.uk> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: VCdlQgMINlqyQC5ESQclYg-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ben Dooks > Sent: 02 October 2018 17:56 > > 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; It might be useful to define a structure for the header. You might need to find the 'store unaligned 32bit word' macro though. (Actually that will probably be better than the memcpy() which might end up doing memory-memory copies rather than storing the register.) Although if/when you add the tx alignment that won't be needed because the header will be aligned. > /* 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); Not related, but csum_preamble = cpu_to_le32(csum_preamble) is likely to generate better code (at least for some architectures). David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)