Skip to contentSkip to conversation

Merge USB 1.1 Ethernet Adapter SR9700 Device Driver into the Linux Kernel

PATCH-SR9700 liujunliang_ljl 3 participants 4 messages Aug 20, 2013 – Aug 22, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Dear Gregkh & all :

I am the software engineer Liu Junliang from ShenZhen CoreChips high technology company, on the market of SR9700 chip is designed and owned by us.
SR9700 is a type of USB to Ethernet Converter and is compatible with USB 1.1 protocol, We want to merge SR9700 device driver into the Linux Kernel. The following is the Linux 3.10.7 version patch for SR9700, Please give us the assessment and support. Thanks a lot.

[PATCH] :

drivers/net/usb/Kconfig +8 -0
index 287cc62..a94b196 100644
@@ -272,6 +272,14 @@ config USB_NET_DM9601
 	  This option adds support for Davicom DM9601 based USB 1.1
 	  10/100 Ethernet adapters.
 
+config USB_NET_SR9700
+	tristate "CoreChip-sz SR9700 based USB 1.1 10/100 ethernet devices"
+	depends on USB_USBNET
+	select CRC32
+	help
+	  This option adds support for CoreChip-sz SR9700 based USB 1.1
+	  10/100 Ethernet adapters.
+
 config USB_NET_SMSC75XX
 	tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices"
 	depends on USB_USBNET
drivers/net/usb/Makefile +1 -0
index 9ab5c9d..bba87a2 100644
@@ -14,6 +14,7 @@ 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
+obj-$(CONFIG_USB_NET_SR9700)	+= sr9700.o
 obj-$(CONFIG_USB_NET_SMSC75XX)	+= smsc75xx.o
 obj-$(CONFIG_USB_NET_SMSC95XX)	+= smsc95xx.o
 obj-$(CONFIG_USB_NET_GL620A)	+= gl620a.o
drivers/net/usb/sr9700.c new file +557 -0

557 lines not on this page · raw message

drivers/net/usb/sr9700.h new file +152 -0

152 lines not on this page · raw message

--------------------------------------------------
2013-08-20
liujunliang_ljl
www.corechip-sz.com

#1 lore raw
Quoted 5 lines · liujunliang_ljl

Dear Gregkh & all :

I am the software engineer Liu Junliang from ShenZhen CoreChips high technology company, on the market of SR9700 chip is designed and owned by us.
SR9700 is a type of USB to Ethernet Converter and is compatible with USB 1.1 protocol, We want to merge SR9700 device driver into the Linux Kernel. The following is the Linux 3.10.7 version patch for SR9700, Please give us the assessment and support. Thanks a lot.

As this is a net driver, the relevant maintainer is David Miller and not Greg.

There are some style errors here which can be found using scripts/checkpatch.pl. You'll need to fix those and re-submit. I'll point out some more problems inline.

Quoted 2 lines
drivers/net/usb/sr9700.c new file +0 -0

[...]

drivers/net/usb/sr9700.c line 172

Quoted 9 lines
drivers/net/usb/sr9700.c new file +9 -0
+static int sr9700_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 * data)
+{
+	struct usbnet *dev = netdev_priv(net);
+	__le16 *ebuf = (__le16 *) data;
+	int i;
+
+	/* access is 16bit */
+	if ((eeprom->offset % 2) || (eeprom->len % 2))
+		return -EINVAL;

You're really supposed to handle these cases by shifting as necessary.

drivers/net/usb/sr9700.c line 176

Quoted 3 lines
drivers/net/usb/sr9700.c new file +3 -0
+	for (i = 0; i < eeprom->len / 2; i++) {
+		if (sr_read_eeprom_word(dev, eeprom->offset / 2 + i, &ebuf[i]) < 0)
+			return -EINVAL;

You should pass up the error code, not substitute -EINVAL.

[...]

drivers/net/usb/sr9700.c line 236

Quoted 5 lines
drivers/net/usb/sr9700.c new file +5 -0
+static void sr9700_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
+{
+	/* Inherit standard device info */
+	usbnet_get_drvinfo(net, info);
+	info->eedump_len = SR_EEPROM_LEN;

You don't need to set eedump_len; the ethtool core will set it after calling sr9700_get_eeprom_len(). So you don't need your own implementation of get_drvinfo at all.

[...]

Quoted 2 lines
drivers/net/usb/sr9700.c new file +2 -0
+static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf)
+{

[...]

drivers/net/usb/sr9700.c line 360

Quoted 6 lines
drivers/net/usb/sr9700.c new file +6 -0
+	/* read MAC */
+	if (sr_read(dev, PAR, ETH_ALEN, dev->net->dev_addr) < 0) {
+		printk(KERN_ERR "Error reading MAC address\n");
+		ret = -ENODEV;
+		goto out;
+	}

[...]

I think this should read the MAC address from EEPROM and copy it to both dev_addr to perm_addr. MAC address changes should not persist if the driver is reloaded.

Ben.

Signature · 3 lines
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.
#2 lore raw

Re: Re: [PATCH-SR9700] Merge USB 1.1 Ethernet Adapter SR9700 DeviceDriver into the Linux Kernel

In reply to liujunliang_ljl

Dear Ben :

1, please give me email address of David Miller, and Thanks a lot.

2, please check the new sr9700 device driver which is checked by the script tools

scripts/checkpatch.pl
and the attachment file is the result of scripts/checkpatch.pl patch-commit-20130821

I'm sorry that I'm still finding the way to signed-off

3, Thanks again for your correct suggestion and Please check the new device driver patch.

[PATCH] :

drivers/net/usb/Kconfig +8 -0
index 287cc62..a94b196 100644
@@ -272,6 +272,14 @@ config USB_NET_DM9601
 	  This option adds support for Davicom DM9601 based USB 1.1
 	  10/100 Ethernet adapters.
 
+config USB_NET_SR9700
+	tristate "CoreChip-sz SR9700 based USB 1.1 10/100 ethernet devices"
+	depends on USB_USBNET
+	select CRC32
+	help
+	  This option adds support for CoreChip-sz SR9700 based USB 1.1
+	  10/100 Ethernet adapters.
+
 config USB_NET_SMSC75XX
 	tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices"
 	depends on USB_USBNET
drivers/net/usb/Makefile +1 -0
index 9ab5c9d..bba87a2 100644
@@ -14,6 +14,7 @@ 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
+obj-$(CONFIG_USB_NET_SR9700)	+= sr9700.o
 obj-$(CONFIG_USB_NET_SMSC75XX)	+= smsc75xx.o
 obj-$(CONFIG_USB_NET_SMSC95XX)	+= smsc95xx.o
 obj-$(CONFIG_USB_NET_GL620A)	+= gl620a.o
drivers/net/usb/sr9700.c new file +536 -0

536 lines not on this page · raw message

drivers/net/usb/sr9700.h new file +172 -0

172 lines not on this page · raw message

2013-08-21

liujunliang_ljl

发件人: Ben Hutchings
发送时间: 2013-08-20 21:36:50
收件人: liujunliang_ljl
抄送: gregkh; linux-usb; netdev; linux-kernel; sunhecheng
主题: Re: [PATCH-SR9700] Merge USB 1.1 Ethernet Adapter SR9700 DeviceDriver into the Linux Kernel

Quoted 5 lines · liujunliang_ljl

Dear Gregkh & all :

I am the software engineer Liu Junliang from ShenZhen CoreChips high technology company, on the market of SR9700 chip is designed and owned by us.
SR9700 is a type of USB to Ethernet Converter and is compatible with USB 1.1 protocol, We want to merge SR9700 device driver into the Linux Kernel. The following is the Linux 3.10.7 version patch for SR9700, Please give us the assessment and support. Thanks a lot.

As this is a net driver, the relevant maintainer is David Miller and not Greg.
There are some style errors here which can be found using scripts/checkpatch.pl. You'll need to fix those and re-submit. I'll point out some more problems inline.

Quoted 2 lines
drivers/net/usb/sr9700.c new file +0 -0

[...]

drivers/net/usb/sr9700.c

Quoted 9 lines
drivers/net/usb/sr9700.c new file +9 -0
+static int sr9700_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8 * data)
+{
+ struct usbnet *dev = netdev_priv(net);
+ __le16 *ebuf = (__le16 *) data;
+ int i;
+
+ /* access is 16bit */
+ if ((eeprom->offset % 2) || (eeprom->len % 2))
+ return -EINVAL;

You're really supposed to handle these cases by shifting as necessary.

Quoted 3 lines

+ for (i = 0; i < eeprom->len / 2; i++) {
+ if (sr_read_eeprom_word(dev, eeprom->offset / 2 + i, &ebuf[i]) < 0)
+ return -EINVAL;

You should pass up the error code, not substitute -EINVAL. [...]

drivers/net/usb/sr9700.c

Quoted 5 lines
drivers/net/usb/sr9700.c new file +5 -0
+static void sr9700_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
+{
+ /* Inherit standard device info */
+ usbnet_get_drvinfo(net, info);
+ info->eedump_len = SR_EEPROM_LEN;

You don't need to set eedump_len; the ethtool core will set it after calling sr9700_get_eeprom_len(). So you don't need your own implementation of get_drvinfo at all.
[...]

Quoted 2 lines
drivers/net/usb/sr9700.c new file +2 -0
+static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf)
+{

[...]

Quoted 6 lines

+ /* read MAC */
+ if (sr_read(dev, PAR, ETH_ALEN, dev->net->dev_addr) < 0) {
+ printk(KERN_ERR "Error reading MAC address\n");
+ ret = -ENODEV;
+ goto out;
+ }

[...]
I think this should read the MAC address from EEPROM and copy it to both dev_addr to perm_addr. MAC address changes should not persist if the driver is reloaded.
Ben.

Signature · 3 lines
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.
#3 lore raw

Re: Re: [PATCH-SR9700] Merge USB 1.1 Ethernet Adapter SR9700 DeviceDriver into the Linux Kernel

Quoted 3 lines · liujunliang_ljl

Dear Ben :

1, please give me email address of David Miller, and Thanks a lot.

You can find him in the MAINTAINERS file.
He should also show up if you use scripts/get_maintainer.pl