wan: new driver retina
Subsystems (2)
PATCH 1/1 wan: new driver retina
From: Matti Linnanvuori <[email protected]>
Retina G.703 and G.SHDSL driver.
---
Fixed Kconfig and the body of the explanation.
diff -Napur
linux-2.6.23/drivers/net/wan/Kconfig
linux-2.6.24/drivers/net/wan/Kconfig
drivers/net/wan/Kconfig +11 -0
@@ -494,4 +494,15 @@ config SBNI_MULTILINE If unsure, say N. +config RETINA + tristate "Retina support" + depends on m && PCI + help + Driver for Retina C5400 and E2200 network cards, which + support G.703, G.SHDSL, Ethernet encapsulation and PCI. + + The driver will be compiled as a module: the + module will be called retina. + + endif # WAN
drivers/net/wan/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_C101) += c101.o obj-$(CONFIG_WANXL) += wanxl.o obj-$(CONFIG_PCI200SYN) += pci200syn.o obj-$(CONFIG_PC300TOO) += pc300too.o +obj-$(CONFIG_RETINA) += retina.o clean-files := wanxlfw.inc $(obj)/wanxl.o: $(obj)/wanxlfw.inc
drivers/net/wan/retina.c +4502 -0
2,978 lines not on this page · raw message
drivers/net/wan/retina.h +164 -0
164 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
__________________________________ Ihr erstes Baby? Holen Sie sich Tipps von anderen Eltern. www.yahoo.de/clever
Part of the diff is not shown here. View the raw message.
Quoted 6 lines · On Mon, 22 Oct 2007 04:14:57 -0700 (PDT) Matti Linnanvuori wrote:
From: Matti Linnanvuori <[email protected]>
Retina G.703 and G.SHDSL driver.
Signed-off-by Matti Linnanvuori <[email protected]>---
Hi,
Just a few basic questions... I'm not reviewing any of the code parts.
Quoted 10 lines
Fixed
Kconfigand the body of the explanation.diff -Napur
linux-2.6.23/drivers/net/wan/Kconfig
linux-2.6.24/drivers/net/wan/Kconfigdrivers/net/wan/Kconfig +0
-0@@ -494,4 +494,15 @@ config SBNI_MULTILINE If unsure, say N.
drivers/net/wan/Kconfig config SBNI_MULTILINE · line 505
Quoted 10 lines
drivers/net/wan/Kconfig +9
-0+config RETINA + tristate "Retina support" + depends on m && PCI + help + Driver for Retina C5400 and E2200 network cards, which + support G.703, G.SHDSL, Ethernet encapsulation and PCI. + + The driver will be compiled as a module: the + module will be called retina.
Why is the driver restricted/limited to module only?
Quoted 7 lines
drivers/net/wan/Kconfig +1
-0+ endif # WANdiff -Napur
linux-2.6.23/drivers/net/wan/retina.clinux-2.6.24/drivers/net/wan/retina.c
drivers/net/wan/retina.c line 60
Quoted 9 lines
drivers/net/wan/retina.c +8
-0@@ -0,0 +1,4503 @@ +/* V1.2.4 */ + +/* retina.c: */ + + +#define DRV_NAME "retina" +#define DRV_VERSION "1.2.5" +#define DRV_RELDATE "November 14, 2003"
huh?
drivers/net/wan/retina.c line 138
Quoted 5 lines
drivers/net/wan/retina.c +5
-0+#if !defined(__OPTIMIZE__) +#warning You must compile this file with correct options. +#warning See the last lines of the source file. +#error You have to compile this driver with "-O". +#endif
What defines __OPTIMIZE__ in the kernel build environment?
Quoted 8 lines
diff -Napur
linux-2.6.23/drivers/net/wan/retina.hlinux-2.6.24/drivers/net/wan/retina.hdrivers/net/wan/retina.h +0
-0@@ -0,0 +1,164 @@diff -Napur linux-2.6.23/MAINTAINERS linux-2.6.24/MAINTAINERS
MAINTAINERS L: [email protected] · line 3154
Quoted 6 lines
MAINTAINERS +3
-0@@ -3149,6 +3149,11 @@ L: [email protected] W: http://www.namesys.com S: Supported +RETINA DRIVER +P: Matti Linnanvuori +M: [email protected]
and what mailing list?
MAINTAINERS L: [email protected] · line 3159
Quoted 5 lines
MAINTAINERS +2
-0+S: Supported + ROCKETPORT DRIVER P: Comtrol Corp. W: http://www.comtrol.com
---
~Randy
A quick look only:
Quoted 7 lines · Matti Linnanvuori
+++
linux-2.6.24/drivers/net/wan/retina.cdrivers/net/wan/retina.c +5
-0+CHANGES + ------- + + v1.0.0 (JK) - May 27, 2003: + * Original driver.
drivers/net/wan/retina.c line 40
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+ + v1.1.0 (JK) - June, 2003: + * final Flexibilis driver + + v1.2.0: NO_ARP option back again + + v1.2.1: (JT) - Aug 21, 2003: + * Added support for Retina C5400 card including PROC stuff. + + v1.2.2: (Petri Ahonen) - Sep 19, 2003:
And so on - I'm not sure such logs belong here.
drivers/net/wan/retina.c line 60
Quoted 3 lines
drivers/net/wan/retina.c +3
-0+#define DRV_NAME "retina" +#define DRV_VERSION "1.2.5" +#define DRV_RELDATE "November 14, 2003"
Hmm...
drivers/net/wan/retina.c line 70
Quoted 3 lines
drivers/net/wan/retina.c +3
-0+/* obsolete +see retina_noarp_with_ptp +define FEPCI_NO_ARP */
If it's obsolete (or rather unused), just drop it.
drivers/net/wan/retina.c line 181
Quoted 12 lines
drivers/net/wan/retina.c +12
-0+#undef inb +#undef inw +#undef inl +#undef outb +#undef outw +#undef outl +#define inb nonexistent/* force using only 32bit access */ +#define inw nonexistent/* force using only 32bit access */ +#define inl (x) le32_to_cpu(readl(x)) +#define outb nonexistent/* force using only 32bit access */ +#define outw nonexistent/* force using only 32bit access */ +#define outl (value, address) writel(cpu_to_le32(value), address)
Any code like that is write-only, why don't just use readl()/ writel() in the actual code?
Are you sure about this cpu_to_le32? readl()/writel() already preserve the value.
Quoted 1 line
+#define
VMA_OFFSET(vma)((vma)->vm_pgoff <<PAGE_SHIFT)
Not sure about such things in a driver.
drivers/net/wan/retina.c line 194
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+enum pci_id_flags_bits { +/* Set PCI command register bits before calling probe */ +PCI_USES_IO =1 ,PCI_USES_MEM =2 ,PCI_USES_MASTER =4 , +/* Read and map the single following PCI BAR */ +PCI_ADDR0 =0 <<4 ,PCI_ADDR1 =1 <<4 ,PCI_ADDR2 = +2 <<4 ,PCI_ADDR3 =3 <<4 , +PCI_ADDR_64BITS =0x100 ,PCI_NO_ACPI_WAKE = +0x200 ,PCI_NO_MIN_LATENCY =0x400 , +PCI_UNUSED_IRQ =0x800 , +};
We already have such things in PCI headers, don't we?
Quoted 1 line
+/* Linux 2.4 appears to drop POINTOPOINT,BROADCAST and NOARP flags
Linux 2.4?
Quoted 1 line
+/* proc filesystem functions introduced: */
I'm not sure we're adding new /proc files.
Perhaps you should investigate sysfs and friends?
Quoted 14 lines
drivers/net/wan/retina.c +14
-0+case FEPCI_IOCTL_R_SHARED_MEM : +DBG_PRINT (" %s: ioctl read shared mem commanded.\n" , + fepci_NAME); +fepci_copy_to_user (arg, ioaddr +FEPCI_SHARED_MEM_OFFSETT , +_IOC_SIZE (cmd),0 ); +break ; +case FEPCI_IOCTL_W_SHARED_MEM : +DBG_PRINT (" %s: ioctl write shared mem commanded.\n" , + fepci_NAME); +fepci_copy_from_user (ioaddr +FEPCI_SHARED_MEM_OFFSETT , + arg,_IOC_SIZE (cmd),0 ); +break ; +case FEPCI_IOCTL_G_IDENTIFICATION : + DBG_PRINT(" %s: IOCTL_G_IDENTIFICATION commanded.\n",
drivers/net/wan/retina.c line 861
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+ fepci_NAME); +fepci_copy_to_user (arg, + ioaddr +FEPCI_IDENTIFICATION_OFFSETT , +_IOC_SIZE (cmd),1 ); +break ; +case FEPCI_IOCTL_G_FEATURES : +DBG_PRINT (" %s: IOCTL_G_FEATURES commanded.\n" , fepci_NAME); +fepci_copy_to_user (arg, ioaddr +FEPCI_FEATURES_OFFSETT , +_IOC_SIZE (cmd),1 ); +break ;
Are you sure these ioctls are a good idea? Perhaps sysfs attributes would be much better?
drivers/net/wan/retina.c line 1595
Quoted 11 lines
drivers/net/wan/retina.c +11
-0+if (length ==0 ) { + fp->rx_packets_of_size_0_stream++; + }else if (length ==1 ) { + fp->rx_packets_of_size_1_stream++; + }else if (length ==2 ) { + fp->rx_packets_of_size_2_stream++; + }else if (length ==3 ) { + fp->rx_packets_of_size_3_stream++; + }else if (length <8 ) { + fp->rx_packets_of_size_4_7_stream++; + }else if (length <16 ) {
...
I think style details are really a personal thing but this would look much better without the braces.
drivers/net/wan/retina.c line 1701
Quoted 7 lines
drivers/net/wan/retina.c +7
-0+ } + temp_tx = (temp_tx +1 ) & (TX_RING_SIZE -1 ); + temp_tx_unit = (temp_tx_unit +1 ); + temp_tx_unit *= temp_tx_unit < fp->units; + } + +return IRQ_HANDLED ;
No unhandled IRQ protection anymore?
Quoted 5 lines
drivers/net/wan/retina.c +5
-0+#ifdef FEPCI_POINT_TO_POINT +static int is_ptp_interface (struct net_device *dev) +{ +char **p_ptp_if_name = retina_ptp_interfaces; +unsigned int i = interfaces;
drivers/net/wan/retina.c line 1758
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+while (i >0 && *p_ptp_if_name !=NULL ) { +if (!strncmp (dev->name, *p_ptp_if_name,sizeof (dev->name))) { +return 1 ; + }else { + } + p_ptp_if_name++; + i--; + } +return 0 ; +}
A bit weird, isn't it?
Quoted 8 lines
drivers/net/wan/retina.c +8
-0+static int __devinit fepci_init_one (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +struct net_device *dev =NULL ; +struct fepci_ch_private *fp =NULL ; +int chip_idx = ent->driver_data; +int drv_flags = pci_id_tbl[chip_idx].drv_flags; +int i =pci_enable_device (pdev);
drivers/net/wan/retina.c line 1778
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+u32 j; +resource_size_t real_ioaddr; +void *ioaddr; +unsigned position; + +if (i) { +printk (KERN_WARNING "%s: pci_enable_device returned %x.\n" , + fepci_NAME, i); +return i; + }
Didn't spot that pci_enable_device() at first. I think we shouldn't put state-changing functions in variable declarations, especially when there are many variables.
drivers/net/wan/retina.c line 1833
Quoted 2 lines
drivers/net/wan/retina.c +2
-0+ goto err_2; + FOUND:
The labels can be hard to spot, too.
drivers/net/wan/retina.c line 1882
Quoted 5 lines
drivers/net/wan/retina.c +5
-0+/* dev->name[3]= j+0x30; channel number -> ascii */ +/* minor number -> ascii */ + dev->name[4 ] = ((fp->minor *CHANNELS + j) %10 ) +0x30 ; +/* minor number -> ascii */ + dev->name[3 ] = ((fp->minor *CHANNELS + j) /10 ) +0x30 ;
That 0x30 could be written as plain '0'.
drivers/net/wan/retina.c line 1893
Quoted 4 lines
drivers/net/wan/retina.c +4
-0+/* HW_ADDR: 00:rnd:rnd:rnd:rnd:05 */ + dev->dev_addr[0 ] =0 ; +get_random_bytes (&(dev->dev_addr[1 ]),4 ); + dev->dev_addr[5 ] =5 ;
I think we already have a function for this.
Quoted 4 lines
drivers/net/wan/retina.c +4
-0+ +static int fepci_start_xmit (struct sk_buff *skb,struct net_device *dev) +{ +struct fepci_ch_private *fp = dev->priv;
drivers/net/wan/retina.c line 2223
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+const unsigned cur_tx = fp->cur_tx; + + fp->tx_skbuffs_in++; + + { +u32 tx_length = skb->len; +u32 bus_address; +struct sk_buff *old; +if (unlikely (tx_length <ETH_ZLEN )) { + struct sk_buff *bigger =
Why don't you just move the variables to the beginning of this function? The extra indentation isn't good for readability.
Quoted 12 lines
drivers/net/wan/retina.c +12
-0+if (intr_status & IntrFrameTransmitted) { + fp->tx_interrupts_since_last_timer++; +if (netif_tx_trylock (dev)) { +unsigned i =TX_RING_SIZE -1 ; + do { + u32 desc_b; + if ((fp->tx_skbuff[i] != NULL) + && + (((desc_b = + inl(&fp->tx_desc[i]. + desc_b)) & transfer_not_done) == + 0)) {
drivers/net/wan/retina.c line 2311
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+/* has been sent */ +pci_unmap_single (fp-> + this_card_priv-> + pci_dev, +inl (&fp-> + tx_desc[i]. + desc_a), + desc_b & + frame_length, +PCI_DMA_TODEVICE );
The above looks like a hardcopy printout with missing CRs (carriage returns) :-)
Why not split it?
Quoted 6 lines
drivers/net/wan/retina.c +6
-0+ [line]++; +/* small packet counters */ +if (length ==0 ) + fp->rx_packets_of_size_0++; +else if (length ==1 ) + fp->rx_packets_of_size_1++;
drivers/net/wan/retina.c line 2394
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+else if (length ==2 ) + fp->rx_packets_of_size_2++; +else if (length ==3 ) + fp->rx_packets_of_size_3++; +else if (length <8 ) + fp->rx_packets_of_size_4_7++; +else if (length <16 ) + fp->rx_packets_of_size_8_15++; +else if (length <32 ) + fp->rx_packets_of_size_16_31++;
Is there a specific reason to have such detailed counters?
Quoted 61 lines
drivers/net/wan/retina.c +61
-0+int get_line_data_rate_value (unsigned char line_rate) +{ +switch (line_rate) { +case 0x00 : +return 0 ; +case 0x01 : +return 1 ; +case 0x05 : +return 8 ; +case 0x06 : +return 10 ; +case 0x14 : +return 256 ; +case 0x15 : +return 300 ; +case 0x20 : +return 1 ; +case 0x28 : +return 8 ; +case 0x29 : +return 10 ; +case 0x30 : +return 32 ; +case 0x34 : +return 56 ; +case 0x36 : +return 64 ; +case 0x60 : +return 1 ; +case 0xa0 : +return 1 ; +default : +return -1 ; + } +} + +char get_line_data_rate_unit (unsigned char line_rate) +{ +switch (line_rate) { +case 0x00 : +return 0 ; +case 0x01 : +return 0 ; +case 0x05 : +return 0 ; +case 0x06 : +return 0 ; +case 0x14 : +return 0 ; +case 0x15 : +return 0 ; +case 0x20 : +return 'k' ; +case 0x28 : +return 'k' ; +case 0x29 : +return 'k' ; +case 0x30 : +return 'k' ; +case 0x34 : +return 'k' ;
drivers/net/wan/retina.c line 3212
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+case 0x36 : +return 'k' ; +case 0x60 : +return 'M' ; +case 0xa0 : +return 'G' ; +default : +return 0 ; + } +}
Are you sure you really want this?
Quoted 22 lines
drivers/net/wan/retina.c +22
-0+int print_line_type (unsigned char type,char *buf,int pos) +{ +DBG_PRINT ("print_line_type %c\n" , type); +switch (type) { +case 0 : + pos +=sprintf (buf + pos,"NONE" ); +break ; +case 1 : + pos +=sprintf (buf + pos,"DCombus management bus" ); +break ; +case 2 : + pos +=sprintf (buf + pos,"V.24" ); +break ; +case 3 : + pos +=sprintf (buf + pos,"X.21" ); +break ; +case 4 : + pos +=sprintf (buf + pos,"V.35" ); +break ; +case 5 : + pos +=sprintf (buf + pos,"V.11" ); +break ;
drivers/net/wan/retina.c line 3245
Quoted 10 lines
drivers/net/wan/retina.c +10
-0+case 6 : + pos +=sprintf (buf + pos,"IDSL (ISDN Basic Rate" ); +break ; +case 7 : + pos +=sprintf (buf + pos,"E1 nonframed/framed" ); +break ; +case 8 : + pos +=sprintf (buf + pos,"E2 nonframed/framed" ); +break ; +case 9 :
A table would be more readable I think.
Review
Quoted 2 lines
+++
linux-2.6.24/drivers/net/wan/retina.h(quoted diff) +0
-0@@ -0,0 +1,164 @@
Short header file included by single .c - is it worth it?
Wow, really long.
Signature · 1 line
Krzysztof Halasa