RE: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-04 Thread Freddy


-Original Message-
From: Daniel J Blueman [mailto:dan...@quora.org] 
Sent: Sunday, February 03, 2013 10:22 PM
To: Freddy Xin
Cc: Linux Kernel
Subject: Re: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0
to gigabit ethernet adapter driver

> Hi Freddy,

> Michael, could you give me more information about how do you test this
driver?
> I have tried to reproduce the issue by using "ifconfig ethX mtu 1500", but
I didn't confront the same issue.
> Thank you in advance for your help.

> I found the same by just starting with 'ifconfig eth0 1500' and testing as
high as 4000; pinging another host with a large payload of size mtu-40
starts failing; after ~30s, I see the transmit time out trace [1].

> Of course, a default MTU size of 1500 is essential to avoid fragmentation
issues, so should be fixed too. Jumbo frames support is essential these days
too.

Hi Daniel,

The default MTU size will be change to 1500 and the HW jumbo frame function
will be enabled in the next submission of the driver.
Thanks for your help.

Freddy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-06 Thread Freddy

On 02/07/2013 01:45 PM, Stephen Hemminger wrote:

On Thu,  7 Feb 2013 12:36:34 +0800
Freddy Xin  wrote:


+struct {unsigned char ctrl, timer_l, timer_h, size, ifg; }
+AX88179_BULKIN_SIZE[] ={
+   {7, 0x4f, 0,0x12, 0xff},
+   {7, 0xf0, 1,0x15, 0xff},
+   {7, 0xae, 7,0x18, 0xff},
+   {7, 0xcc, 0x4c, 0x18, 8},
+};

  Better to make it static, const, and add a couple
  of line breaks.

  static const struct {
   unsigned char ctrl, timer_l, timer_h, size, ifg;
  } AX88179_BULKIN_SIZE[] = {
{7, 0x4f, 0,0x12, 0xff},
{7, 0xf0, 1,0x15, 0xff},
{7, 0xae, 7,0x18, 0xff},
{7, 0xcc, 0x4c, 0x18, 8},
};

Thank you, Stephen. I will fix these errors.




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-06 Thread Freddy

On 02/07/2013 01:46 PM, Stephen Hemminger wrote:

On Thu,  7 Feb 2013 12:36:34 +0800
Freddy Xin  wrote:


+static struct ethtool_ops ax88179_ethtool_ops = {
+   .get_link   = ethtool_op_get_link,
+   .get_msglevel   = usbnet_get_msglevel,
+   .set_msglevel   = usbnet_set_msglevel,
+   .get_wol= ax88179_get_wol,
+   .set_wol= ax88179_set_wol,
+   .get_eeprom_len = ax88179_get_eeprom_len,
+   .get_eeprom = ax88179_get_eeprom,
+   .get_settings   = ax88179_get_settings,
+   .set_settings   = ax88179_set_settings,
+   .nway_reset = usbnet_nway_reset,
+};
+

ethtool_ops should always be const


Thank you, Stephen. I will fix these errors.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-07 Thread Freddy

On 02/08/2013 04:02 AM, Ben Hutchings wrote:

On Thu, 2013-02-07 at 21:39 +0800, Freddy Xin wrote:

From: Freddy Xin 

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 

[...]

--- /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.


Thank you, Ben. I will fix bugs and test it on a big-endian system.

Freddy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-01-28 Thread Freddy
> I would vote to not accept that driver for mainline as long as this 
> issues are not fixed.


Michael, could you give me more information about how do you test this driver? 
I have tried to reproduce the issue by using "ifconfig ethX mtu 1500", but I 
didn't confront the same issue.
Thank you in advance for your help.


> The vendor should not be able to claim "hooray, hooray, great device, 
> we even have an driver in linux main line" when it is actually such an 
> useless crap.

> Well, that is fortunately not how these things work. The main goal is getting 
> the devices supported in the kernel. Bugs can be fixed.  If a vendor can get 
> any positive gain out of having a driver in mainline, then that is good for 
> everyone, isn't it?  Of course, we can all agree that the > > > effect of a 
> *working* driver is more positive than a non-working driver...


> For now, the main focus should be fixing the issues which has been noted 
> during review.  Your testing feedback is of course very useful, but you 
> probably need to back them up with actual code change proposals if they are 
> going to be dealt with at this stage.

> Of course I'm offering to help with any information or testing, but 
> unfortunately I do not have the knowhow to fix anything myself.

> I believe this is where you are totally wrong.  You obviuously have the 
> ability to create a few simple test cases for yourself and see if the driver 
> behaves as you expect.  That is very useful.

> And you have a device.  That is also useful.

> Now, the driver source code is available.  And there is another Asix driver 
> in the kernel which already has been cleaned up and can be used as an 
> example. And maybe even partly used for the new devices as well, if the code 
> is duplicated?  I have not looked at this in detail, but I > suspect that 
> much of the problem with the ax88179_178a driver is that it has completely 
> ignored all the work that has gone into the asix driver after it was 
> mainlined.  I find it unlikely that there is no reusable code in the 
> asix_devices.c, asix_common.c and ax88172a.c files.  Trying to > rewrite 
> ax88179_178a to share as much code as possible seems like the best way to 
> clean it up and fix bugs.

Bjørn, I am trying to reproduce the issue mentioned by Michael and I have a 
question about submitting this driver.
Should I merge this driver into asix_devices.c and asix_common.c even through 
the usb command, tx_fixup, and rx_fixup functions are totally different?
Thank you in advance for your reply.

Freddy


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] TX throttling bug-fixing patch of AX88179_178A

2013-07-20 Thread freddy
From: Freddy Xin 

Disable TSO and SG network features in reset() and bind() functions,
and check the return value of skb_linearize() in tx_fixup() to prevent
TX throttling.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 1e3c302..eb71331 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1029,7 +1029,7 @@ static int ax88179_bind(struct usbnet *dev, struct 
usb_interface *intf)
dev->mii.supports_gmii = 1;
 
dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
- NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
+ NETIF_F_RXCSUM;
 
dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
 NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
@@ -1173,7 +1173,9 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, 
gfp_t flags)
if (((skb->len + 8) % frame_size) == 0)
tx_hdr2 |= 0x80008000;  /* Enable padding */
 
-   skb_linearize(skb);
+   if (skb_linearize(skb))
+   return NULL;
+
headroom = skb_headroom(skb);
tailroom = skb_tailroom(skb);
 
@@ -1317,7 +1319,7 @@ static int ax88179_reset(struct usbnet *dev)
  1, 1, tmp);
 
dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
- NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
+ NETIF_F_RXCSUM;
 
dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
 NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-01-10 Thread freddy
From: Freddy Xin 

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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1457 
 3 files changed, 1476 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ef97621..75af401 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -158,6 +158,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..ce01578 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..47504ea
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1457 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 20011-2012 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX_MCAST_FILTER_SIZE   8
+#define AX_MAX_MCAST   64
+#define AX_RX_CHECKSUM 1
+#define AX_TX_CHECKSUM 2
+#define AX_INT_PPLS_LINK   BIT(0)
+#define AX_RXHDR_L4_TYPE_UDP   1
+#define AX_RXHDR_L4_TYPE_TCP   4
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_ACCESS_EEPROM   0x04
+#define AX_ACCESS_EFUSE0x05
+#define AX_PAUSE_WATERLVL_HIGH 0x54
+#define AX_PAUSE_WATERLVL_LOW  0x55
+
+#define PHYSICAL_LINK_STATUS   0x02
+   #define AX_USB_SS   0x04
+   #define AX_USB_HS   0x02
+   #define AX_USB_FS   0x01
+
+#define GENERAL_STATUS 0x03
+/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
+   #define AX_SECLD0x04
+
+#define AX_SROM_ADDR   0x07
+#define AX_SROM_CMD0x0a
+   #define EEP_RD  0x04
+   #define EEP_BUSY0x10
+
+
+#define AX_SROM_DATA_LOW   0x08
+#define AX_SROM_DATA_HIGH  0x09
+
+#define AX_RX_CTL  0x0b
+   #define AX_RX_CTL_DROPCRCERR0x0100
+   #define AX_RX_CTL_IPE   0x0200
+   #def

RE: [PATCH] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-01-11 Thread Freddy
Hi,

>> +static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16
index,
>> +   u16 size, void *data) {
>> +   int ret;
>> +   ret = usbnet_read_cmd(dev, cmd,
>> +  USB_DIR_IN | USB_TYPE_VENDOR |
USB_RECIP_DEVICE,
>> +  value, index, data, size);
>> +
>> +   if (ret != size && ret >= 0)
>> +   return -EINVAL;
>> +   return ret;
>> +}
>> +
>> +static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16
index,
>> +u16 size, void *data) {
>> +   return usbnet_write_cmd(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR
>> +   | USB_RECIP_DEVICE, value, index, 
>> +data, size); }
>> +
>> +static void
>> +ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16
index,
>> +   u16 size, void *data) {
>> +   usbnet_write_cmd_async(dev, cmd,
>> +  USB_DIR_OUT | USB_TYPE_VENDOR |
USB_RECIP_DEVICE,
>> +  value, index, data, size); }
>> +

ax88179_read_cmd, ax88179_write_cmd, and ax88179_write_cmd_async duplicate
code from asix_common.c.

Do you mean that I should merge this driver into asix_common and
asix_devices, or just reuse the functions that had been implemented?

[...]

>> +static int ax88179_get_eeprom(struct net_device *net,
>> + struct ethtool_eeprom *eeprom, u8 
>> +*data) {
>> +   struct usbnet *dev = netdev_priv(net);
>> +   u16 *ebuf = (u16 *)data;
>> +   int i;
>> +
>> +   /* Crude hack to ensure that we don't overwrite memory
>> +* if an odd length is supplied

Have a look at asix_get_eeprom() in asix_common.c for a better
implementation. There is also code for programming the eeprom
(asix_set_eeprom in asix_common.c), can this be used for the AX88179/178A as
well?

Thanks, I will check whether the eeprom access functions in asix_common.c
can be used in the driver or not.

Regards, Freddy

>> +*/
>> +   if (eeprom->len % 2)
>> +   return -EINVAL;
>> +
>> +   /* ax8817x returns 2 bytes from eeprom on read */
>> +   for (i = 0; i < eeprom->len / 2; i++) {
>> +   if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM,
>> +   eeprom->offset + i, 1, 2, &ebuf[i]) < 0)
>> +   return -EINVAL;
>> +   }
>> +   return 0;
>> +}
>> +

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread freddy
From: Freddy Xin 

Add VID:DID for Lenovo OneLinkDock Gigabit LAN

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 955df81..460e823 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1421,6 +1421,19 @@ static const struct driver_info samsung_info = {
.tx_fixup = ax88179_tx_fixup,
 };
 
+static const struct driver_info lenovo_info = {
+   .description = "Lenovo OneLinkDock Gigabit LAN",
+   .bind = ax88179_bind,
+   .unbind = ax88179_unbind,
+   .status = ax88179_status,
+   .link_reset = ax88179_link_reset,
+   .reset = ax88179_reset,
+   .stop = ax88179_stop,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .rx_fixup = ax88179_rx_fixup,
+   .tx_fixup = ax88179_tx_fixup,
+};
+
 static const struct usb_device_id products[] = {
 {
/* ASIX AX88179 10/100/1000 */
@@ -1438,6 +1451,10 @@ static const struct usb_device_id products[] = {
/* Samsung USB Ethernet Adapter */
USB_DEVICE(0x04e8, 0xa100),
.driver_info = (unsigned long)&samsung_info,
+}, {
+   /* Lenovo OneLinkDock Gigabit LAN */
+   USB_DEVICE(0x17ef, 0x304b),
+   .driver_info = (unsigned long)&lenovo_info,
 },
{ },
 };
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] AX88179_178A: Add FLAG_HW_IPALIGN to determine whether reserving NET_IP_ALIGN bytes for an SKB.

2013-12-13 Thread freddy
From: Freddy Xin 

The AX88179_178A has a hardware feature that it can insert a
2-bytes pseudo header in front of each received frame by setting
the AX_RX_CTL_IPE bit. This feature is used to let the IP header
be aligned on a doubleword-aligned address, so the rx_submit() of
usbnet.c needn't reserve NET_IP_ALIGN bytes for an SKB in the case.

This patch adds a flag of driver_info "FLAG_HW_IPALIGN" which is
used in rx_submit() of usbnet.c to determine whether reserving
NET_IP_ALIGN bytes for an SKB.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c | 8 
 drivers/net/usb/usbnet.c   | 5 -
 include/linux/usb/usbnet.h | 3 +++
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 8e8d0fc..04a2cc9 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1374,7 +1374,7 @@ static const struct driver_info ax88179_info = {
.link_reset = ax88179_link_reset,
.reset = ax88179_reset,
.stop = ax88179_stop,
-   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IPALIGN,
.rx_fixup = ax88179_rx_fixup,
.tx_fixup = ax88179_tx_fixup,
 };
@@ -1387,7 +1387,7 @@ static const struct driver_info ax88178a_info = {
.link_reset = ax88179_link_reset,
.reset = ax88179_reset,
.stop = ax88179_stop,
-   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IPALIGN,
.rx_fixup = ax88179_rx_fixup,
.tx_fixup = ax88179_tx_fixup,
 };
@@ -1400,7 +1400,7 @@ static const struct driver_info sitecom_info = {
.link_reset = ax88179_link_reset,
.reset = ax88179_reset,
.stop = ax88179_stop,
-   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IPALIGN,
.rx_fixup = ax88179_rx_fixup,
.tx_fixup = ax88179_tx_fixup,
 };
@@ -1413,7 +1413,7 @@ static const struct driver_info samsung_info = {
.link_reset = ax88179_link_reset,
.reset = ax88179_reset,
.stop = ax88179_stop,
-   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IPALIGN,
.rx_fixup = ax88179_rx_fixup,
.tx_fixup = ax88179_tx_fixup,
 };
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 8494bb5..8a618b8 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -473,7 +473,10 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, 
gfp_t flags)
return -ENOLINK;
}
 
-   skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
+   if (dev->driver_info->flags & FLAG_HW_IPALIGN)
+   skb = __netdev_alloc_skb(dev->net, size, flags);
+   else
+   skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
if (!skb) {
netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index e303eef..e4855cf 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -116,6 +116,9 @@ struct driver_info {
 #define FLAG_MULTI_PACKET  0x2000
 #define FLAG_RX_ASSEMBLE   0x4000  /* rx packets may span >1 frames */
 #define FLAG_NOARP 0x8000  /* device can't do ARP */
+#define FLAG_HW_IPALIGN0x1 /* hardware adds headers to let 
the
+* IP header align on a dword-aligned
+* address */
 
/* init device ... can sleep, or cause probe() failure */
int (*bind)(struct usbnet *, struct usb_interface *);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] AX88179_178A: Add ethtool ops for EEE support

2014-07-31 Thread freddy
From: Freddy Xin 

Add functions to support ethtool EEE manipulating, and the EEE
is disabled in default setting to enhance the compatibility
with certain switch.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c | 264 +
 1 file changed, 264 insertions(+)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 054e59c..be42757 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define AX88179_PHY_ID 0x03
 #define AX_EEPROM_LEN  0x100
@@ -170,8 +172,12 @@
 #define GMII_PHY_PAGE_SELECT   0x1f
#define GMII_PHY_PGSEL_EXT  0x0007
#define GMII_PHY_PGSEL_PAGE00x
+   #define GMII_PHY_PGSEL_PAGE30x0003
+   #define GMII_PHY_PGSEL_PAGE50x0005
 
 struct ax88179_data {
+   u8  eee_enabled;
+   u8  eee_active;
u16 rxctl;
u16 reserved;
 };
@@ -373,6 +379,60 @@ static void ax88179_mdio_write(struct net_device *netdev, 
int phy_id, int loc,
ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res);
 }
 
+static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad,
+  u16 devad)
+{
+   u16 tmp16;
+   int ret;
+
+   tmp16 = devad;
+   ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+   MII_MMD_CTRL, 2, &tmp16);
+
+   tmp16 = prtad;
+   ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+   MII_MMD_DATA, 2, &tmp16);
+
+   tmp16 = devad | MII_MMD_CTRL_NOINCR;
+   ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+   MII_MMD_CTRL, 2, &tmp16);
+
+   return ret;
+}
+
+static int
+ax88179_phy_read_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad)
+{
+   int ret;
+   u16 tmp16;
+
+   ax88179_phy_mmd_indirect(dev, prtad, devad);
+
+   ret = ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+  MII_MMD_DATA, 2, &tmp16);
+   if (ret < 0)
+   return ret;
+
+   return tmp16;
+}
+
+static int
+ax88179_phy_write_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad,
+  u16 data)
+{
+   int ret;
+
+   ax88179_phy_mmd_indirect(dev, prtad, devad);
+
+   ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID,
+   MII_MMD_DATA, 2, &data);
+
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
 static int ax88179_suspend(struct usb_interface *intf, pm_message_t message)
 {
struct usbnet *dev = usb_get_intfdata(intf);
@@ -572,6 +632,185 @@ static int ax88179_set_settings(struct net_device *net, 
struct ethtool_cmd *cmd)
return mii_ethtool_sset(&dev->mii, cmd);
 }
 
+static int
+ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_eee *data)
+{
+   int val;
+
+   /* Get Supported EEE */
+   val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE,
+   MDIO_MMD_PCS);
+   if (val < 0)
+   return val;
+   data->supported = mmd_eee_cap_to_ethtool_sup_t(val);
+
+   /* Get advertisement EEE */
+   val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV,
+   MDIO_MMD_AN);
+   if (val < 0)
+   return val;
+   data->advertised = mmd_eee_adv_to_ethtool_adv_t(val);
+
+   /* Get LP advertisement EEE */
+   val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE,
+   MDIO_MMD_AN);
+   if (val < 0)
+   return val;
+   data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val);
+
+   return 0;
+}
+
+static int
+ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data)
+{
+   u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
+
+   return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV,
+ MDIO_MMD_AN, tmp16);
+}
+
+static int ax88179_chk_eee(struct usbnet *dev)
+{
+   struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
+   struct ax88179_data *priv = (struct ax88179_data *)dev->data;
+
+   mii_ethtool_gset(&dev->mii, &ecmd);
+
+   if (ecmd.duplex & DUPLEX_FULL) {
+   int eee_lp, eee_cap, eee_adv;
+   u32 lp, cap, adv, supported = 0;
+
+   eee_cap = ax88179_phy_read_mmd_indirect(dev,
+   MDIO_PCS_EEE_ABLE,
+   MDIO_MMD_PCS);
+   if (eee_cap < 0) {
+   priv->eee_active 

[PATCH 1/1] [PATCH] ax88179_178a: Correct the RX error definition in RX header

2013-10-21 Thread freddy
From: Freddy Xin 

Correct the definition of AX_RXHDR_CRC_ERR and
AX_RXHDR_DROP_ERR. They are BIT29 and BIT31 in pkt_hdr
seperately.
Add VID:DID for Samsung USB Ethernet Adapter.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |   23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 3569293..846cc19 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -36,8 +36,8 @@
 #define AX_RXHDR_L4_TYPE_TCP   16
 #define AX_RXHDR_L3CSUM_ERR2
 #define AX_RXHDR_L4CSUM_ERR1
-#define AX_RXHDR_CRC_ERR   ((u32)BIT(31))
-#define AX_RXHDR_DROP_ERR  ((u32)BIT(30))
+#define AX_RXHDR_CRC_ERR   ((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR  ((u32)BIT(31))
 #define AX_ACCESS_MAC  0x01
 #define AX_ACCESS_PHY  0x02
 #define AX_ACCESS_EEPROM   0x04
@@ -1406,6 +1406,19 @@ static const struct driver_info sitecom_info = {
.tx_fixup = ax88179_tx_fixup,
 };
 
+static const struct driver_info samsung_info = {
+   .description = "Samsung USB Ethernet Adapter",
+   .bind = ax88179_bind,
+   .unbind = ax88179_unbind,
+   .status = ax88179_status,
+   .link_reset = ax88179_link_reset,
+   .reset = ax88179_reset,
+   .stop = ax88179_stop,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .rx_fixup = ax88179_rx_fixup,
+   .tx_fixup = ax88179_tx_fixup,
+};
+
 static const struct usb_device_id products[] = {
 {
/* ASIX AX88179 10/100/1000 */
@@ -1418,7 +1431,11 @@ static const struct usb_device_id products[] = {
 }, {
/* Sitecom USB 3.0 to Gigabit Adapter */
USB_DEVICE(0x0df6, 0x0072),
-   .driver_info = (unsigned long) &sitecom_info,
+   .driver_info = (unsigned long)&sitecom_info,
+}, {
+   /* Samsung USB Ethernet Adapter */
+   USB_DEVICE(0x04e8, 0xa100),
+   .driver_info = (unsigned long)&samsung_info,
 },
{ },
 };
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [PATCH resubmit] ax88179_178a: Correct the RX error definition in RX header

2013-10-21 Thread freddy
From: Freddy Xin 

Correct the definition of AX_RXHDR_CRC_ERR and
AX_RXHDR_DROP_ERR. They are BIT29 and BIT31 in pkt_hdr
seperately.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 3569293..3bcd0d9 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -36,8 +36,8 @@
 #define AX_RXHDR_L4_TYPE_TCP   16
 #define AX_RXHDR_L3CSUM_ERR2
 #define AX_RXHDR_L4CSUM_ERR1
-#define AX_RXHDR_CRC_ERR   ((u32)BIT(31))
-#define AX_RXHDR_DROP_ERR  ((u32)BIT(30))
+#define AX_RXHDR_CRC_ERR   ((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR  ((u32)BIT(31))
 #define AX_ACCESS_MAC  0x01
 #define AX_ACCESS_PHY  0x02
 #define AX_ACCESS_EEPROM   0x04
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] [PATCH] ax88179_178a: Add VID:DID for Samsung USB Ethernet Adapter

2013-10-21 Thread freddy
From: Freddy Xin 

Add VID:DID for Samsung USB Ethernet Adapter.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |   19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 3569293..3d166ae 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1406,6 +1406,19 @@ static const struct driver_info sitecom_info = {
.tx_fixup = ax88179_tx_fixup,
 };
 
+static const struct driver_info samsung_info = {
+   .description = "Samsung USB Ethernet Adapter",
+   .bind = ax88179_bind,
+   .unbind = ax88179_unbind,
+   .status = ax88179_status,
+   .link_reset = ax88179_link_reset,
+   .reset = ax88179_reset,
+   .stop = ax88179_stop,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .rx_fixup = ax88179_rx_fixup,
+   .tx_fixup = ax88179_tx_fixup,
+};
+
 static const struct usb_device_id products[] = {
 {
/* ASIX AX88179 10/100/1000 */
@@ -1418,7 +1431,11 @@ static const struct usb_device_id products[] = {
 }, {
/* Sitecom USB 3.0 to Gigabit Adapter */
USB_DEVICE(0x0df6, 0x0072),
-   .driver_info = (unsigned long) &sitecom_info,
+   .driver_info = (unsigned long)&sitecom_info,
+}, {
+   /* Samsung USB Ethernet Adapter */
+   USB_DEVICE(0x04e8, 0xa100),
+   .driver_info = (unsigned long)&samsung_info,
 },
{ },
 };
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] [PATCH] ax88179_178a: Correct the RX error definition in RX header

2013-10-22 Thread freddy
From: Freddy Xin 

Correct the definition of AX_RXHDR_CRC_ERR and
AX_RXHDR_DROP_ERR. They are BIT29 and BIT31 in pkt_hdr
seperately.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 3569293..3bcd0d9 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -36,8 +36,8 @@
 #define AX_RXHDR_L4_TYPE_TCP   16
 #define AX_RXHDR_L3CSUM_ERR2
 #define AX_RXHDR_L4CSUM_ERR1
-#define AX_RXHDR_CRC_ERR   ((u32)BIT(31))
-#define AX_RXHDR_DROP_ERR  ((u32)BIT(30))
+#define AX_RXHDR_CRC_ERR   ((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR  ((u32)BIT(31))
 #define AX_ACCESS_MAC  0x01
 #define AX_ACCESS_PHY  0x02
 #define AX_ACCESS_EEPROM   0x04
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] [PATCH] ax88179_178a: Add VID:DID for Samsung USB Ethernet Adapter

2013-10-22 Thread freddy
From: Freddy Xin 

Add VID:DID for Samsung USB Ethernet Adapter.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |   19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 3bcd0d9..846cc19 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1406,6 +1406,19 @@ static const struct driver_info sitecom_info = {
.tx_fixup = ax88179_tx_fixup,
 };
 
+static const struct driver_info samsung_info = {
+   .description = "Samsung USB Ethernet Adapter",
+   .bind = ax88179_bind,
+   .unbind = ax88179_unbind,
+   .status = ax88179_status,
+   .link_reset = ax88179_link_reset,
+   .reset = ax88179_reset,
+   .stop = ax88179_stop,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .rx_fixup = ax88179_rx_fixup,
+   .tx_fixup = ax88179_tx_fixup,
+};
+
 static const struct usb_device_id products[] = {
 {
/* ASIX AX88179 10/100/1000 */
@@ -1418,7 +1431,11 @@ static const struct usb_device_id products[] = {
 }, {
/* Sitecom USB 3.0 to Gigabit Adapter */
USB_DEVICE(0x0df6, 0x0072),
-   .driver_info = (unsigned long) &sitecom_info,
+   .driver_info = (unsigned long)&sitecom_info,
+}, {
+   /* Samsung USB Ethernet Adapter */
+   USB_DEVICE(0x04e8, 0xa100),
+   .driver_info = (unsigned long)&samsung_info,
 },
{ },
 };
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] ax88179_178a: Remove AX_MEDIUM_ALWAYS_ONE bit in AX_MEDIUM_STATUS_MODE register to avoid TX throttling

2013-10-24 Thread freddy
From: Freddy Xin 

Remove AX_MEDIUM_ALWAYS_ONE in AX_MEDIUM_STATUS_MODE register.
Setting this bit may cause TX throttling in Half-Duplex mode.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 846cc19..8e8d0fc 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -78,7 +78,6 @@
 #define AX_MEDIUM_STATUS_MODE  0x22
#define AX_MEDIUM_GIGAMODE  0x01
#define AX_MEDIUM_FULL_DUPLEX   0x02
-   #define AX_MEDIUM_ALWAYS_ONE0x04
#define AX_MEDIUM_EN_125MHZ 0x08
#define AX_MEDIUM_RXFLOW_CTRLEN 0x10
#define AX_MEDIUM_TXFLOW_CTRLEN 0x20
@@ -1065,8 +1064,8 @@ static int ax88179_bind(struct usbnet *dev, struct 
usb_interface *intf)
 
/* Configure default medium type => giga */
*tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN |
-AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_ALWAYS_ONE |
-AX_MEDIUM_FULL_DUPLEX | AX_MEDIUM_GIGAMODE;
+AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX |
+AX_MEDIUM_GIGAMODE;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
  2, 2, tmp16);
 
@@ -1225,7 +1224,7 @@ static int ax88179_link_reset(struct usbnet *dev)
}
 
mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN |
-  AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_ALWAYS_ONE;
+  AX_MEDIUM_RXFLOW_CTRLEN;
 
ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS,
 1, 1, &link_sts);
@@ -1339,8 +1338,8 @@ static int ax88179_reset(struct usbnet *dev)
 
/* Configure default medium type => giga */
*tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN |
-AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_ALWAYS_ONE |
-AX_MEDIUM_FULL_DUPLEX | AX_MEDIUM_GIGAMODE;
+AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX |
+AX_MEDIUM_GIGAMODE;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
  2, 2, tmp16);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] AX88179_178A: Enable the hardware pseudo header in case of the NET_IP_ALIGN equals 0

2013-12-06 Thread freddy
From: Freddy Xin 

The AX88179_178A has a hardware feature that it can insert a 2-bytes pseudo
header in front of each received frame by setting the AX_RX_CTL_IPE bit.
This feature is used to let the IP header be aligned on a doubleword-aligned 
address,
but the NET_IP_ALIGN may equals to 2 and the __netdev_alloc_skb_ip_align in 
USBNET will
reserve 2 bytes also, so in this case the driver shouldn't enable this bit.

This patch modifies the driver to set AX_RX_CTL_IPE just in case of the 
NET_IP_ALIGN equals 0.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 8e8d0fc..d84f0e0 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -473,8 +473,10 @@ static int ax88179_resume(struct usb_interface *intf)
msleep(100);
 
/* Configure RX control register => start operation */
-   tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START |
-   AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+   tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
+   AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+   if (NET_IP_ALIGN == 0)
+   tmp16 |= AX_RX_CTL_IPE;
ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16);
 
return usbnet_resume(intf);
@@ -599,7 +601,9 @@ static void ax88179_set_multicast(struct net_device *net)
struct ax88179_data *data = (struct ax88179_data *)dev->data;
u8 *m_filter = ((u8 *)dev->data) + 12;
 
-   data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
+   data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB);
+   if (NET_IP_ALIGN == 0)
+   data->rxctl |= AX_RX_CTL_IPE;
 
if (net->flags & IFF_PROMISC) {
data->rxctl |= AX_RX_CTL_PRO;
@@ -1054,8 +1058,10 @@ static int ax88179_bind(struct usbnet *dev, struct 
usb_interface *intf)
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp);
 
/* Configure RX control register => start operation */
-   *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START |
-AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+   *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
+AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+   if (NET_IP_ALIGN == 0)
+   *tmp16 |= AX_RX_CTL_IPE;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);
 
*tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL |
@@ -1143,7 +1149,8 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct 
sk_buff *skb)
 
if (pkt_cnt == 0) {
/* Skip IP alignment psudo header */
-   skb_pull(skb, 2);
+   if (NET_IP_ALIGN == 0)
+   skb_pull(skb, 2);
skb->len = pkt_len;
skb_set_tail_pointer(skb, pkt_len);
skb->truesize = pkt_len + sizeof(struct sk_buff);
@@ -1154,7 +1161,8 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct 
sk_buff *skb)
ax_skb = skb_clone(skb, GFP_ATOMIC);
if (ax_skb) {
ax_skb->len = pkt_len;
-   ax_skb->data = skb->data + 2;
+   if (NET_IP_ALIGN == 0)
+   ax_skb->data = skb->data + 2;
skb_set_tail_pointer(ax_skb, pkt_len);
ax_skb->truesize = pkt_len + sizeof(struct sk_buff);
ax88179_rx_checksum(ax_skb, pkt_hdr);
@@ -1328,8 +1336,10 @@ static int ax88179_reset(struct usbnet *dev)
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp);
 
/* Configure RX control register => start operation */
-   *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START |
-AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+   *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
+AX_RX_CTL_AMALL | AX_RX_CTL_AB;
+   if (NET_IP_ALIGN == 0)
+   *tmp16 |= AX_RX_CTL_IPE;
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);
 
*tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL |
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-06 Thread Freddy Xin
From: Freddy Xin 

This is a resubmission.
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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1398 
 3 files changed, 1417 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ef97621..75af401 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -158,6 +158,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..119b06c 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)  += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..6862e47
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1398 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX88179_EEPROM_MAGIC   0x17900b95
+#define AX_MCAST_FLTSIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   BIT(0)
+#define AX_RXHDR_L4_TYPE_UDP   1
+#define AX_RXHDR_L4_TYPE_TCP   4
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_ACCESS_EEPROM   0x04
+#define AX_ACCESS_EFUS 0x05
+#define AX_PAUSE_WATERLVL_HIGH 0x54
+#define AX_PAUSE_WATERLVL_LOW  0x55
+
+#define PHYSICAL_LINK_STATUS   0x02
+   #define AX_USB_SS   0x04
+   #define AX_USB_HS   0x02
+
+#define GENERAL_STATUS 0x03
+/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
+   #define AX_SECLD0x04
+
+#define AX_SROM_ADDR   0x07
+#define AX_SROM_C

[PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-07 Thread Freddy Xin
From: Freddy Xin 

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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1399 
 3 files changed, 1418 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ef97621..75af401 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -158,6 +158,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..119b06c 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)  += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..545151a
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1399 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX88179_EEPROM_MAGIC   0x17900b95
+#define AX_MCAST_FLTSIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   BIT(0)
+#define AX_RXHDR_L4_TYPE_UDP   1
+#define AX_RXHDR_L4_TYPE_TCP   4
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_ACCESS_EEPROM   0x04
+#define AX_ACCESS_EFUS 0x05
+#define AX_PAUSE_WATERLVL_HIGH 0x54
+#define AX_PAUSE_WATERLVL_LOW  0x55
+
+#define PHYSICAL_LINK_STATUS   0x02
+   #define AX_USB_SS   0x04
+   #define AX_USB_HS   0x02
+
+#define GENERAL_STATUS 0x03
+/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
+   

[PATCH resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-27 Thread Freddy Xin
From: Freddy Xin 

This is a resubmission.
Fixed endianness issue on big endian systems and verified this driver on iBook 
G4.
Removed steps that change net->features in ax88179_set_features function.
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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1455 
 3 files changed, 1474 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index da92ed3..21e084d 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -156,6 +156,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..119b06c 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)  += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..ed1ab2f
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1455 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX88179_EEPROM_MAGIC   0x17900b95
+#define AX_MCAST_FLTSIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   ((u32)BIT(16))
+#define AX_RXHDR_L4_TYPE_MASK  0x1c
+#define AX_RXHDR_L4_TYPE_UDP   4
+#define AX_RXHDR_L4_TYPE_TCP   16
+#define AX_RXHDR_L3CSUM_ERR2
+#define AX_RXHDR_L4CSUM_ERR1
+#define AX_RXHDR_CRC_ERR   ((u32)BIT(31))
+#define AX_RXHDR_DROP_ERR  ((u32)BIT(30))
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_A

[PATCH resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-03-02 Thread Freddy Xin
From: Freddy Xin 

This is a resubmission.
Added kfree() in ax88179_get_eeprom to prevent memory leakage.
Modified "__le16 rxctl" to "u16 rxctl" in "struct ax88179_data" and removed 
pointless casts.
Removed asix_init and asix_exit functions and added 
"module_usb_driver(ax88179_178a_driver)".
Fixed endianness issue on big endian systems and verified this driver on iBook 
G4.
Removed steps that change net->features in ax88179_set_features function.
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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1448 
 3 files changed, 1467 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index da92ed3..21e084d 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -156,6 +156,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..119b06c 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)  += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..71c27d8
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1448 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX88179_EEPROM_MAGIC   0x17900b95
+#define AX_MCAST_FLTSIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   ((u32)BIT(16))
+#define AX_RXHDR_L4_TYPE_MASK  0x1c
+#define AX_RXHDR_L4_TYPE_UDP   4
+#define AX_RXHDR_L4_TYPE_TCP   16
+#define AX_RXHDR_L3CSUM_ERR2
+#define AX_RXHDR_

[PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-01-22 Thread Freddy Xin
From: Freddy Xin 

This is a resubmission.
Fixed 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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1361 
 3 files changed, 1380 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ef97621..75af401 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -158,6 +158,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..119b06c 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)  += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..95d79bd
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1361 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 20011-2012 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX88179_EEPROM_MAGIC   0x17900b95
+#define AX_MCAST_FLTSIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   BIT(0)
+#define AX_RXHDR_L4_TYPE_UDP   1
+#define AX_RXHDR_L4_TYPE_TCP   4
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_ACCESS_EEPROM   0x04
+#define AX_ACCESS_EFUS 0x05
+#define AX_PAUSE_WATERLVL_HIGH 0x54
+#define AX_PAUSE_WATERLVL_LOW  0x55
+
+#define PHYSICAL_LINK_STATUS   0x02
+   #define AX_USB_SS   0x04
+   #define AX_USB_HS   0x02
+
+#define GENERAL_STATUS 0x03
+/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
+   #define AX_SECLD0x04
+
+#define AX_SROM_ADDR   0x07
+#define AX_SROM_CMD0x0a
+   #define EEP_RD  0x04
+   #define EEP_BUSY0x10
+
+#define AX_SROM_DATA_LOW   0x08
+#

[PATCH, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-01-17 Thread Freddy Xin

This is a resubmission.
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 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1424 
 3 files changed, 1443 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ef97621..75af401 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -158,6 +158,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..ce01578 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..4aa9f28
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1424 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 20011-2012 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX_MCAST_FILTER_SIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   BIT(0)
+#define AX_RXHDR_L4_TYPE_UDP   1
+#define AX_RXHDR_L4_TYPE_TCP   4
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_ACCESS_EEPROM   0x04
+#define AX_ACCESS_EFUSE0x05
+#define AX_PAUSE_WATERLVL_HIGH 0x54
+#define AX_PAUSE_WATERLVL_LOW  0x55
+
+#define PHYSICAL_LINK_STATUS   0x02
+   #define AX_USB_SS   0x04
+   #define AX_USB_HS   0x02
+
+#define GENERAL_STATUS 0x03
+/* Check AX88179 version. UA1:Bit2 = 0,  UA2:Bit2 = 1 */
+   #define AX_SECLD0x04
+
+#define AX_SROM_ADDR   0x07
+#define AX_SROM_CMD0x0a
+   #define EEP_RD  0x04
+   #define EEP_BUSY0x10
+
+
+#define AX_SROM_DATA_LOW   0x08
+#define AX_SROM_DATA_HIGH  0x09
+
+#define AX_RX_CTL 

Comparing buffer cache algorithms on 2.2.17. Suggestions?

2001-02-17 Thread Fireball Freddy

Howdy,

  Trying to implement some different buffer caching
algorithms in Linux.  This is just for comparison
purposes for a thesis, not suggesting any problem with
the current scheme.  Here is what I'm attempting:

  o Eliminate BUF_CLEAN, BUF_DIRTY, and BUF_LOCKED
lists in favor of a single BUF_LRU list.  This because
I don't see the point of maintaining three lists...
the only time I need to find all the dirty blocks is
on a sync of some sort.  I don't mind if the sync
takes a while longer if the normal operating condition
is faster.

  Once I have the cache working on a single list
(assuming I can!) I plan on using an I/O generator to
get some repeatable traces so I can compare the
following:

  o LRU vs SLRU with static region percentages vs SLRU
with dynamic region percentages
  o Periodic flushing of dirty blocks enabled vs
disabled
  o Write-through caching vs write-back caching vs
adaptive (switching between wt and wb based on recent
activity) vs my own method (write to disk on first
write, only to buffer after that, write to disk again
when block is flushed, if dirty)
  o Of course, I'll also do a run with the default
Linux 2.2.17 to see how it compares with the others

  It looks like the ext2 fs is going to complicate
this somewhat, as it sets blocks dirty and/or writes
them itself sometimes.  Not sure how I'm going to get
around this... will probably ignore it for now.

  I'd appreciate any advice on this undertaking. 
Specifically, how many things (tools, etc) is this
going to break, warnings about common pitfalls, and
other suggestions.  I would like to have started this
on 2.4, but I wanted to work on a release that had
been out for a bit, so I'd know that any problems were
caused by *me* and not just kernel bugs.  :)

  Also, are there any specific people to whom I should
direct memory management questions?  I've had some in
the past few months but haven't been able to get
answers.  Or should I post them to this list (I assume
not).  Finally, I have noticed references to a
kernelnewbies chat room.  I prefer newsgroups to
chat... is there a good mailing list devoted to kernel
newbies?

  Thanks to everyone for your hard work, and apologies
for adding one more e-mail to the pile.

Andy Cottrell

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



Re: Average number of instructions per line of kernel code

2007-08-30 Thread Freddy Spierenburg
Hi all,

On Thu, 30 Aug 2007, Mohamed Bamakhrama wrote:
> I have a question regarding the average number of assembly
> instructions per line of kernel code.

I may completely miss out on this one, but what's the point in
knowing?


-- 
$ cat ~/.signature
Freddy Spierenburg <[EMAIL PROTECTED]>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!


signature.asc
Description: Digital signature


[PATCH v2 1/1] watchdog: mtk_wdt: Remove mtk_wdt_stop() in probe() to prevent the system freeze and it doesn't reboot by watchdog problem

2020-12-30 Thread Freddy Hsin
From: "freddy.hsin" 

Before user space daemon start to access the watchdog device,
there is a time interval that watchdog is disabled in the
original flow. If the system freezing at this interval, it
cannot be rebooted by watchdog hardware automatically.

In order to solve this problem, the watchdog hardware should be
kept working, and start hrtimer in framework to ping it by
setting max_hw_heartbeat_ms and HW_RUNNING used in
watchdog_need_worker to determine whether the worker should be
started or not. Besides the redundant setting of max_timeout is
also removed.

Signed-off-by: freddy.hsin 
---
 drivers/watchdog/mtk_wdt.c |   17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index d6a6393..0c869b7 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -195,6 +195,19 @@ static int mtk_wdt_set_timeout(struct watchdog_device 
*wdt_dev,
return 0;
 }
 
+static void mtk_wdt_init(struct watchdog_device *wdt_dev)
+{
+   struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdt_dev);
+   void __iomem *wdt_base;
+
+   wdt_base = mtk_wdt->wdt_base;
+
+   if (readl(wdt_base + WDT_MODE) & WDT_MODE_EN) {
+   set_bit(WDOG_HW_RUNNING, &wdt_dev->status);
+   mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
+   }
+}
+
 static int mtk_wdt_stop(struct watchdog_device *wdt_dev)
 {
struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdt_dev);
@@ -264,7 +277,7 @@ static int mtk_wdt_probe(struct platform_device *pdev)
mtk_wdt->wdt_dev.info = &mtk_wdt_info;
mtk_wdt->wdt_dev.ops = &mtk_wdt_ops;
mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT;
-   mtk_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT;
+   mtk_wdt->wdt_dev.max_hw_heartbeat_ms = WDT_MAX_TIMEOUT * 1000;
mtk_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT;
mtk_wdt->wdt_dev.parent = dev;
 
@@ -274,7 +287,7 @@ static int mtk_wdt_probe(struct platform_device *pdev)
 
watchdog_set_drvdata(&mtk_wdt->wdt_dev, mtk_wdt);
 
-   mtk_wdt_stop(&mtk_wdt->wdt_dev);
+   mtk_wdt_init(&mtk_wdt->wdt_dev);
 
watchdog_stop_on_reboot(&mtk_wdt->wdt_dev);
err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
-- 
1.7.9.5



driver: watchdog: Remove mtk_wdt_stop() in probe() to prevent the system freeze and it doesn't reboot by watchdog problem

2020-12-24 Thread Freddy Hsin
Before user space daemon start to access the watchdog device,
there is a time interval that watchdog is disabled in the
original flow. If the system freezing at this interval, it
cannot be rebooted by watchdog hardware automatically.

In order to solve this problem, the watchdog hardware should be
kept working, and start hrtimer in framework to ping it by
setting max_hw_heartbeat_ms and HW_RUNNING used in
watchdog_need_worker to determine whether the worker should be
started or not



[PATCH v1 1/1] driver: watchdog: Remove mtk_wdt_stop() in probe() to prevent the system freeze and it doesn't reboot by watchdog problem

2020-12-24 Thread Freddy Hsin
From: "freddy.hsin" 

Before user space daemon start to access the watchdog device,
there is a time interval that watchdog is disabled in the
original flow. If the system freezing at this interval, it
cannot be rebooted by watchdog hardware automatically.

In order to solve this problem, the watchdog hardware should be
kept working, and start hrtimer in framework to ping it by
setting max_hw_heartbeat_ms and HW_RUNNING used in
watchdog_need_worker to determine whether the worker should be
started or not

Change-Id: I6a041b0922888a90011d7538ee804d80bc8d15ea
Signed-off-by: freddy.hsin 
---
 drivers/watchdog/mtk_wdt.c |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index d6a6393..62f08cd 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -195,6 +195,19 @@ static int mtk_wdt_set_timeout(struct watchdog_device 
*wdt_dev,
return 0;
 }
 
+static void mtk_wdt_init(struct watchdog_device *wdt_dev)
+{
+   struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdt_dev);
+   void __iomem *wdt_base;
+
+   wdt_base = mtk_wdt->wdt_base;
+
+   if (readl(wdt_base + WDT_MODE) & WDT_MODE_EN) {
+   set_bit(WDOG_HW_RUNNING, &wdt_dev->status);
+   mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
+   }
+}
+
 static int mtk_wdt_stop(struct watchdog_device *wdt_dev)
 {
struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdt_dev);
@@ -266,16 +279,17 @@ static int mtk_wdt_probe(struct platform_device *pdev)
mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT;
mtk_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT;
mtk_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT;
+   mtk_wdt->wdt_dev.max_hw_heartbeat_ms = (WDT_MAX_TIMEOUT - 1) * 1000;
mtk_wdt->wdt_dev.parent = dev;
 
+   watchdog_set_drvdata(&mtk_wdt->wdt_dev, mtk_wdt);
+
+   mtk_wdt_init(&mtk_wdt->wdt_dev);
+
watchdog_init_timeout(&mtk_wdt->wdt_dev, timeout, dev);
watchdog_set_nowayout(&mtk_wdt->wdt_dev, nowayout);
watchdog_set_restart_priority(&mtk_wdt->wdt_dev, 128);
 
-   watchdog_set_drvdata(&mtk_wdt->wdt_dev, mtk_wdt);
-
-   mtk_wdt_stop(&mtk_wdt->wdt_dev);
-
watchdog_stop_on_reboot(&mtk_wdt->wdt_dev);
err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
if (unlikely(err))
-- 
1.7.9.5



Re: [PATCH 1/1] AX88179_178A: Add FLAG_HW_IPALIGN to determine whether reserving NET_IP_ALIGN bytes for an SKB.

2013-12-15 Thread Freddy Xin


On 2013年12月13日 18:36, David Laight wrote:

From: fre...@asix.com.tw

...

-   skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
+   if (dev->driver_info->flags & FLAG_HW_IPALIGN)
+   skb = __netdev_alloc_skb(dev->net, size, flags);
+   else
+   skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);

Given the definition:
static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device 
*dev,
 unsigned int length, gfp_t gfp)
{
 struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, 
gfp);

 if (NET_IP_ALIGN && skb)
 skb_reserve(skb, NET_IP_ALIGN);
 return skb;
}

It really ought to be possible to code that without an extra conditional.

David





The AX88179_178A driver do need to know the value of NET_IP_ALIGN
to determine whether enabling the feature that makes IP header align
on a dword-aligned address, but according to the comments from David
Miller, I need to consider all situations, not just for the case that
NET_IP_ALIGN is zero, so the condition added in rx_submit is just used to
determine whether reserving NET_IP_ALIGN bytes for each SKB.

Freddy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] AX88179_178A: Enable the hardware pseudo header in case of the NET_IP_ALIGN equals 0

2013-12-10 Thread Freddy Xin


On 2013年12月10日 09:01, David Miller wrote:

From: fre...@asix.com.tw
Date: Fri,  6 Dec 2013 17:58:18 +0800


From: Freddy Xin 

The AX88179_178A has a hardware feature that it can insert a 2-bytes pseudo
header in front of each received frame by setting the AX_RX_CTL_IPE bit.
This feature is used to let the IP header be aligned on a doubleword-aligned 
address,
but the NET_IP_ALIGN may equals to 2 and the __netdev_alloc_skb_ip_align in 
USBNET will
reserve 2 bytes also, so in this case the driver shouldn't enable this bit.

This patch modifies the driver to set AX_RX_CTL_IPE just in case of the 
NET_IP_ALIGN equals 0.

Signed-off-by: Freddy Xin 

Please avoid larger than 80 column lines in your commit messages,
people use text-only tools to viee these.

Next, it makes no sense to restrict your change to NET_IP_ALIGN==0

Simply handle any case, by undoing the reservation if it's getting
in the way.  If there isn't an appropriate helper for this, add one.


I think there is no way of undoing the reservation in the driver.
Can I add a flag of the driver_info, and use it to determine
whether undoing the reservation in rx_submit of usbnet?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] AX88179_178A: Add FLAG_HW_IPALIGN to determine whether reserving NET_IP_ALIGN bytes for an SKB.

2013-12-18 Thread Freddy Xin


On 2013年12月16日 18:09, David Laight wrote:
I was thinking of something like: skb = netdev_alloc_skb(dev, length 
+ dev->skb_align, gfp); if (NET_IP_ALIGN && skb && !(ev->driver_flags 
& FLAG_HW_IPALIGN)) skb_reserve(skb, NET_IP_ALIGN); It might even be 
reasonable to remove the length adjustment - provided that all the 
later code uses the skb length. David 


Thanks for your advice.
In the way you advised, does the dev->skb_align equal
to NET_IP_ALIGN in the case that HW doesn't supoort
IP alignment?
In other words, dev->skb_align should be initialized to
NET_IP_ALIGN in USBNET, and I can change its value to
0 in AX88179_178A driver, right?

Freddy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v1 1/1] timer: mt6873: remove COMPILE_TEST condition for MTK timer

2020-08-27 Thread Freddy Hsin
MTK timer driver can work on MTK platform normally, so remove
the redundant condition for MTK_TIMER

Signed-off-by: Freddy Hsin 
---
 drivers/clocksource/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 9141838..1ec5d94 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT
bool
 
 config MTK_TIMER
-   bool "Mediatek timer driver" if COMPILE_TEST
+   bool "Mediatek timer driver"
depends on HAS_IOMEM
select TIMER_OF
select CLKSRC_MMIO
-- 
1.7.9.5


[PATCH 0/1] Remove redundant condition for MTK_TIMER

2020-08-27 Thread Freddy Hsin
Remove the redundant condition of MTK_TIMER because the driver
can work on MTK platform normally, so COMPILE_TEST is no longer
needed for development purpose

Freddy Hsin (1):
  timer: mt6873: remove COMPILE_TEST condition for MTK timer

 drivers/clocksource/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[PATCH 0/1] Refine mtk wdt driver init flow

2020-08-28 Thread Freddy Hsin
Add mtk_wdt_init() functin in probe flow to determine
enable/disable the hw watchdog by its original setting

Freddy Hsin (1):
  driver: watchdog: Add mtk_wdt_init for mediatek watchdog hw init

 drivers/watchdog/mtk_wdt.c |   22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)


[PATCH v1 1/1] driver: watchdog: Add mtk_wdt_init for mediatek watchdog hw init

2020-08-28 Thread Freddy Hsin
1. add a hw initialization function
2. enable/disable the watchdog depends on the original hw setting
3. set WDOD_HW_RUNNING in start function in order to start
   kicker after driver probe and clear the bit in stop function

Change-Id: I25aa797f3b88288f26984455e499e599e27f09fa
Signed-off-by: Freddy Hsin 
---
 drivers/watchdog/mtk_wdt.c |   22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index d6a6393..59b5061 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -57,6 +57,9 @@
 static bool nowayout = WATCHDOG_NOWAYOUT;
 static unsigned int timeout;
 
+static int mtk_wdt_start(struct watchdog_device *wdt_dev);
+static int mtk_wdt_stop(struct watchdog_device *wdt_dev);
+
 struct mtk_wdt_dev {
struct watchdog_device wdt_dev;
void __iomem *wdt_base;
@@ -148,6 +151,19 @@ static int toprgu_register_reset_controller(struct 
platform_device *pdev,
return ret;
 }
 
+static int mtk_wdt_init(struct watchdog_device *wdt_dev)
+{
+   struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdt_dev);
+   void __iomem *wdt_base;
+
+   wdt_base = mtk_wdt->wdt_base;
+
+   if (readl(wdt_base + WDT_MODE) & WDT_MODE_EN)
+   mtk_wdt_start(wdt_dev);
+   else
+   mtk_wdt_stop(wdt_dev);
+}
+
 static int mtk_wdt_restart(struct watchdog_device *wdt_dev,
   unsigned long action, void *data)
 {
@@ -206,6 +222,8 @@ static int mtk_wdt_stop(struct watchdog_device *wdt_dev)
reg |= WDT_MODE_KEY;
iowrite32(reg, wdt_base + WDT_MODE);
 
+   clear_bit(WDOG_HW_RUNNING, &wdt_dev->status);
+
return 0;
 }
 
@@ -225,6 +243,8 @@ static int mtk_wdt_start(struct watchdog_device *wdt_dev)
reg |= (WDT_MODE_EN | WDT_MODE_KEY);
iowrite32(reg, wdt_base + WDT_MODE);
 
+   set_bit(WDOG_HW_RUNNING, &wdt_dev->status);
+
return 0;
 }
 
@@ -274,7 +294,7 @@ static int mtk_wdt_probe(struct platform_device *pdev)
 
watchdog_set_drvdata(&mtk_wdt->wdt_dev, mtk_wdt);
 
-   mtk_wdt_stop(&mtk_wdt->wdt_dev);
+   mtk_wdt_init(&mtk_wdt->wdt_dev);
 
watchdog_stop_on_reboot(&mtk_wdt->wdt_dev);
err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
-- 
1.7.9.5


[PATCH v1 1/2] kernel: time: export sched_clock_register function

2020-07-28 Thread Freddy Hsin
export sched_clock_register function, because the Mediatek timer
loadable module depends on this function

Signed-off-by: Freddy Hsin 
---
 kernel/time/sched_clock.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index fa3f800..e1d5afe 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -239,6 +239,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer 
*hrt)
 
pr_debug("Registered %pS as sched_clock source\n", read);
 }
+EXPORT_SYMBOL(sched_clock_register);
 
 void __init generic_sched_clock_init(void)
 {
-- 
1.7.9.5


[PATCH v1] Porting Mediatek timer driver to kernel module

2020-07-28 Thread Freddy Hsin
Porting Mediatek timer driver to kernel module for GKI
(Generic Kernel Image). Clocksource mmio functions are
exported for Mediatek timer init function.

This patch depends on the timer-of patch submitted by Baolin Wang
https://lkml.org/lkml/2020/3/24/72


Freddy Hsin (2):
  kernel: time: remove init section label of sched_clock_register
  timer: mt6873: porting timer driver to loadable module

 drivers/clocksource/Kconfig  |2 +-
 drivers/clocksource/mmio.c   |4 +++-
 drivers/clocksource/timer-mediatek.c |   39 ++
 kernel/time/sched_clock.c|1 +

[PATCH v1 2/2] timer: mt6873: porting Mediatek timer driver to loadable module

2020-07-28 Thread Freddy Hsin
porting Mediatek timer driver to loadable module

Signed-off-by: Freddy Hsin 
---
 drivers/clocksource/Kconfig  |2 +-
 drivers/clocksource/mmio.c   |4 +++-
 drivers/clocksource/timer-mediatek.c |   39 ++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 9141838..538351a 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -472,7 +472,7 @@ config SYS_SUPPORTS_SH_CMT
bool
 
 config MTK_TIMER
-   bool "Mediatek timer driver" if COMPILE_TEST
+   tristate "Mediatek timer driver"
depends on HAS_IOMEM
select TIMER_OF
select CLKSRC_MMIO
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
index 9de7515..5504569 100644
--- a/drivers/clocksource/mmio.c
+++ b/drivers/clocksource/mmio.c
@@ -21,6 +21,7 @@ u64 clocksource_mmio_readl_up(struct clocksource *c)
 {
return (u64)readl_relaxed(to_mmio_clksrc(c)->reg);
 }
+EXPORT_SYMBOL(clocksource_mmio_readl_up);
 
 u64 clocksource_mmio_readl_down(struct clocksource *c)
 {
@@ -46,7 +47,7 @@ u64 clocksource_mmio_readw_down(struct clocksource *c)
  * @bits:  Number of valid bits
  * @read:  One of clocksource_mmio_read*() above
  */
-int __init clocksource_mmio_init(void __iomem *base, const char *name,
+int clocksource_mmio_init(void __iomem *base, const char *name,
unsigned long hz, int rating, unsigned bits,
u64 (*read)(struct clocksource *))
 {
@@ -68,3 +69,4 @@ int __init clocksource_mmio_init(void __iomem *base, const 
char *name,
 
return clocksource_register_hz(&cs->clksrc, hz);
 }
+EXPORT_SYMBOL(clocksource_mmio_init);
diff --git a/drivers/clocksource/timer-mediatek.c 
b/drivers/clocksource/timer-mediatek.c
index 9318edc..5c89b6b 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -13,6 +13,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include "timer-of.h"
@@ -309,5 +312,41 @@ static int __init mtk_gpt_init(struct device_node *node)
 
return 0;
 }
+
+#ifdef MODULE
+static int mtk_timer_probe(struct platform_device *pdev)
+{
+   int (*timer_init)(struct device_node *node);
+   struct device_node *np = pdev->dev.of_node;
+
+   timer_init = of_device_get_match_data(&pdev->dev);
+   return timer_init(np);
+}
+
+static const struct of_device_id mtk_timer_match_table[] = {
+   {
+   .compatible = "mediatek,mt6577-timer",
+   .data = mtk_gpt_init,
+   },
+   {
+   .compatible = "mediatek,mt6765-timer",
+   .data = mtk_syst_init,
+   },
+   {}
+};
+
+static struct platform_driver mtk_timer_driver = {
+   .probe = mtk_timer_probe,
+   .driver = {
+   .name = "mtk-timer",
+   .of_match_table = mtk_timer_match_table,
+   },
+};
+MODULE_DESCRIPTION("MEDIATEK Module timer driver");
+MODULE_LICENSE("GPL v2");
+
+module_platform_driver(mtk_timer_driver);
+#else
 TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
 TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
+#endif
-- 
1.7.9.5