mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Freddy Xin <freddy@asix.com.tw>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver
Date: Thu, 7 Feb 2013 20:02:55 +0000	[thread overview]
Message-ID: <1360267375.3605.32.camel@bwh-desktop.uk.solarflarecom.com> (raw)
In-Reply-To: <1360244360-2700-1-git-send-email-freddy@asix.com.tw>

On Thu, 2013-02-07 at 21:39 +0800, Freddy Xin wrote:
> From: Freddy Xin <freddy@asix.com.tw>
> 
> This is a resubmission.
> Added "const" to ethtool_ops structure and fixed the coding style of AX88179_BULKIN_SIZE array.
> Fixed the issue that the default MTU is not 1500.
> Added ax88179_change_mtu function and enabled the hardware jumbo frame function to support an
> MTU higher than 1500.
> Fixed indentation and empty line coding style errors.
> The _nopm version usb functions were added to access register in suspend and resume functions.
> Serveral variables allocted dynamically were removed and replaced by stack variables.
> ax88179_get_eeprom were modified from asix_get_eeprom in asix_common.
> 
> This patch adds a driver for ASIX's AX88179 family of USB 3.0/2.0
> to gigabit ethernet adapters. It's based on the AX88xxx driver but
> the usb commands used to access registers for AX88179 are completely different.
> This driver had been verified on x86 system with AX88179/AX88178A and
> Sitcomm LN-032 USB dongles.
> 
> Signed-off-by: Freddy Xin <freddy@asix.com.tw>
[...]
> --- /dev/null
> +++ b/drivers/net/usb/ax88179_178a.c
[...]
> +struct ax88179_data {
> +       u16 rxctl;
> +};

Should also be declared __packed, as on some architectures it may be
padded to 4 bytes.

rxctl is presumably required to be little-endian (__le16)?

> +struct ax88179_int_data {
> +       u16 res1;
> +       u8 link;
> +       u16 res2;
> +       u8 status;
> +       u16 res3;
> +} __packed;

Same here, the u16 fields are presumably little-endian?

[...]
> +struct ax88179_rx_pkt_header {
> +	u8	l4_csum_err:1,
> +		l3_csum_err:1,
> +		l4_type:3,
> +		l3_type:2,
> +		ce:1;
> +
> +	u8	vlan_ind:3,
> +		rx_ok:1,
> +		pri:3,
> +		bmc:1;
> +
> +	u16	len:13,
> +		crc:1,
> +		mii:1,
> +		drop:1;
> +} __packed;

This won't work on both big-endian systems (assuming this works on x86).
You apparently try to convert the structure in-place in
ax88179_rx_fixup() by calling le32_to_cpus(); that may work if you
define all the bitfields to be part of a u32 but it won't work with the
current definition.

[...]
> +static int
> +ax88179_set_features(struct net_device *net, netdev_features_t features)
> +{
> +	u8 tmp;
> +	struct usbnet *dev = netdev_priv(net);
> +	netdev_features_t changed = net->features ^ features;
> +
> +	if (changed & NETIF_F_TSO)
> +		net->features ^= NETIF_F_TSO;
> +
> +	if (changed & NETIF_F_SG)
> +		net->features ^= NETIF_F_SG;

Don't change net->features; the caller will do that for you.

> +       if (changed & NETIF_F_IP_CSUM) {
> +               ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
> +               tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP;
> +               ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp);
> +
> +               net->features ^= NETIF_F_IP_CSUM;
> +       }
[...]

Isn't tmp going to be in little-endian byte order, so this doesn't work
correctly on a big-endian system?

There are a lot of reads and writes of 16-bit registers using
ax88179_{read,write}_cmd(); maybe you should add
ax88179_{read,write}_le16() to handle this specific case.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2013-02-07 20:03 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07 13:39 Freddy Xin
2013-02-07 20:02 ` Ben Hutchings [this message]
2013-02-07 20:05   ` David Miller
2013-02-08  3:41   ` Freddy
2013-02-08 10:23   ` David Laight
2013-02-08 19:23     ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2013-03-02 10:41 [PATCH " Freddy Xin
2013-03-03  6:44 ` David Miller
2013-02-27 12:01 Freddy Xin
2013-03-01 21:15 ` David Miller
2013-02-07  4:36 [PATCH, " Freddy Xin
2013-02-07  5:45 ` Stephen Hemminger
2013-02-07  6:45   ` Freddy
2013-02-07  5:46 ` Stephen Hemminger
2013-02-07  6:50   ` Freddy
2013-02-03 14:21 Daniel J Blueman
2013-12-04 12:48 ` Freddy
2013-01-23  2:32 Freddy Xin
2013-01-23  4:15 ` David Miller
2013-01-26 23:13 ` Michael Leun
2013-01-28  9:07   ` Bjørn Mork
2013-01-28 13:36     ` Freddy
2013-01-28 14:24       ` Bjørn Mork
2013-01-28 16:42       ` Michael Leun
2013-01-17  9:32 Freddy Xin
2013-01-18 19:23 ` David Miller
2013-01-18 20:29   ` Alan Stern

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=1360267375.3605.32.camel@bwh-desktop.uk.solarflarecom.com \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=freddy@asix.com.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®