All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Ben Dooks' <ben.dooks@codethink.co.uk>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "oneukum@suse.com" <oneukum@suse.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kernel@lists.codethink.co.uk" 
	<linux-kernel@lists.codethink.co.uk>
Subject: RE: [PATCH] usbnet: smsc95xx: simplify tx_fixup code
Date: Wed, 3 Oct 2018 13:36:20 +0000	[thread overview]
Message-ID: <55e4b55bae6148b18a27a23aab7d7501@AcuMS.aculab.com> (raw)
In-Reply-To: <20181002165602.21033-1-ben.dooks@codethink.co.uk>

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 <ben.dooks@codethink.co.uk>
> ---
>  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)


WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: 'Ben Dooks' <ben.dooks@codethink.co.uk>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "oneukum@suse.com" <oneukum@suse.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kernel@lists.codethink.co.uk"
	<linux-kernel@lists.codethink.co.uk>
Subject: usbnet: smsc95xx: simplify tx_fixup code
Date: Wed, 3 Oct 2018 13:36:20 +0000	[thread overview]
Message-ID: <55e4b55bae6148b18a27a23aab7d7501@AcuMS.aculab.com> (raw)

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 <ben.dooks@codethink.co.uk>
> ---
>  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)

  reply	other threads:[~2018-10-03 13:36 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02  9:26 SMSC95XX driver updates Ben Dooks
2018-10-02  9:26 ` [PATCH 1/4] usbnet: smsc95xx: add kconfig for turbo mode Ben Dooks
2018-10-02  9:26   ` [1/4] " Ben Dooks
2018-10-02 12:46   ` [PATCH 1/4] " Andrew Lunn
2018-10-02 12:46     ` [1/4] " Andrew Lunn
2018-10-02  9:26 ` [PATCH 2/4] usbnet: smsc95xx: align tx-buffer to word Ben Dooks
2018-10-02  9:26   ` [2/4] " Ben Dooks
2018-10-02 13:19   ` [PATCH 2/4] " David Laight
2018-10-02 13:19     ` [2/4] " David Laight
2018-10-02 13:19     ` [PATCH 2/4] " David Laight
2018-10-02 13:35     ` Ben Dooks
2018-10-02 13:35       ` [2/4] " Ben Dooks
2018-10-02 13:35       ` [PATCH 2/4] " Ben Dooks
2018-10-02 16:56     ` [PATCH] usbnet: smsc95xx: simplify tx_fixup code Ben Dooks
2018-10-02 16:56       ` Ben Dooks
2018-10-03 13:36       ` David Laight [this message]
2018-10-03 13:36         ` David Laight
2018-10-03 13:36         ` [PATCH] " David Laight
2018-10-03 16:25         ` Ben Dooks
2018-10-03 16:25           ` Ben Dooks
2018-10-05 21:24       ` [PATCH] " David Miller
2018-10-05 21:24         ` David Miller
2018-10-06 11:27         ` [PATCH] " Ben Dooks
2018-10-06 11:27           ` Ben Dooks
2018-10-06 17:28           ` [PATCH] " David Miller
2018-10-06 17:28             ` David Miller
2018-10-08  8:41         ` [PATCH] " David Laight
2018-10-08  8:41           ` David Laight
2018-10-08  8:41           ` [PATCH] " David Laight
2018-10-04 16:53   ` [Linux-kernel] [PATCH 2/4] usbnet: smsc95xx: align tx-buffer to word Ben Hutchings
2018-10-04 16:53     ` [2/4] " Ben Hutchings
2018-10-04 16:53     ` [PATCH 2/4] " Ben Hutchings
2018-10-02  9:26 ` [PATCH 3/4] usbnet: smsc95xx: check for csum being in last four bytes Ben Dooks
2018-10-02  9:26   ` [3/4] " Ben Dooks
2018-10-02  9:45   ` [PATCH 3/4] " Sergei Shtylyov
2018-10-02  9:45     ` [3/4] " Sergei Shtylyov
2018-10-04 16:55   ` [Linux-kernel] [PATCH 3/4] " Ben Hutchings
2018-10-04 16:55     ` [3/4] " Ben Hutchings
2018-10-04 16:55     ` [PATCH 3/4] " Ben Hutchings
2018-10-02  9:26 ` [PATCH 4/4] usbnet: smsc95xx: fix rx packet alignment Ben Dooks
2018-10-02  9:26   ` [4/4] " Ben Dooks

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=55e4b55bae6148b18a27a23aab7d7501@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.