ipwireless: driver for 3G PC Card
PATCH 1/1 ipwireless: driver for 3G PC Card
Hi Linus,
I'm submitting driver for IPWireless PC Card modem for inclusion to 2.6.25.
The driver has been in -mm series as ipwireless_cs.git tree for some time and has passed through lkml (http://lkml.org/lkml/2007/12/12/165).
The PCMCIA subsystem is unmaintained, so I'm sending it directly as Andrew suggested.
David Sterba
---
From: David Sterba <[email protected]>
ipwireless: driver for PC Card, 3G internet connection
The driver is manufactured by IPWireless.
--- MAINTAINERS | 8 drivers/char/pcmcia/Kconfig | 9 drivers/char/pcmcia/Makefile | 2 drivers/char/pcmcia/ipwireless/Makefile | 10 drivers/char/pcmcia/ipwireless/hardware.c | 1784 ++++++++++++++++++++++++ drivers/char/pcmcia/ipwireless/hardware.h | 63 drivers/char/pcmcia/ipwireless/main.c | 496 ++++++ drivers/char/pcmcia/ipwireless/main.h | 70 drivers/char/pcmcia/ipwireless/network.c | 513 ++++++ drivers/char/pcmcia/ipwireless/network.h | 54 drivers/char/pcmcia/ipwireless/setup_protocol.h | 108 + drivers/char/pcmcia/ipwireless/tty.c | 687 +++++++++ drivers/char/pcmcia/ipwireless/tty.h | 48 13 files changed, 3852 insertions(+)
---
MAINTAINERS +8 -0
@@ -2007,6 +2007,14 @@ M: [email protected] L: [email protected] S: Maintained +IPWIRELESS DRIVER +P: Jiri Kosina +M: [email protected] +P: David Sterba +M: [email protected] +S: Maintained +T: git://git.kernel.org/pub/scm/linux/kernel/git/jikos/ipwireless_cs.git + IRDA SUBSYSTEM P: Samuel Ortiz M: [email protected]
drivers/char/pcmcia/Kconfig +9 -0
@@ -43,5 +43,14 @@ config CARDMAN_4040 (http://www.omnikey.com/), or a current development version of OpenCT (http://www.opensc.org/). +config IPWIRELESS + tristate "IPWireless 3G UMTS PCMCIA card support" + depends on PCMCIA + select PPP + help + This is a driver for 3G UMTS PCMCIA card from IPWireless company. In + some countries (for example Czech Republic, T-Mobile ISP) this card + is shipped for service called UMTS 4G. + endmenu
drivers/char/pcmcia/Makefile +2 -0
@@ -4,6 +4,8 @@ # Makefile for the Linux PCMCIA char device drivers. # +obj-y += ipwireless/ + obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o obj-$(CONFIG_CARDMAN_4000) += cm4000_cs.o obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o
drivers/char/pcmcia/ipwireless/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# +# drivers/char/pcmcia/ipwireless/Makefile +# +# Makefile for the IPWireless driver +# + +obj-$(CONFIG_IPWIRELESS) += ipwireless.o + +ipwireless-objs := hardware.o main.o network.o tty.o +
drivers/char/pcmcia/ipwireless/hardware.c new file +1784 -0
1,784 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/hardware.h new file +63 -0
63 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/main.c new file +496 -0
496 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/main.h new file +70 -0
70 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/network.c new file +513 -0
513 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/network.h new file +54 -0
28 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/setup_protocol.h new file +108 -0
108 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/tty.c new file +687 -0
687 lines not on this page · raw message
drivers/char/pcmcia/ipwireless/tty.h new file +48 -0
48 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 17 lines · David Sterba
ipwireless: driver for PC Card, 3G internet connection
drivers/char/pcmcia/ipwireless/hardware.c new file +15
-0+struct nl_first_paket_header { +#if defined(__BIG_ENDIAN) +unsigned char packet_rank:2 ; +unsigned char address:3 ; +unsigned char protocol:3 ; +#else +unsigned char protocol:3 ; +unsigned char address:3 ; +unsigned char packet_rank:2 ; +#endif +unsigned char length_lsb; +unsigned char length_msb; +}; + +struct nl_packet_header {
drivers/char/pcmcia/ipwireless/hardware.c line 160
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+#if defined(__BIG_ENDIAN) + unsigned char packet_rank:2; + unsigned char address:3; + unsigned char protocol:3; +#else + unsigned char protocol:3; + unsigned char address:3; + unsigned char packet_rank:2; +#endif +};
You want __BIG_ENDIAN_BITFIELD here.
Quoted 22 lines · Alexey Dobriyan
Quoted 21 lines · David Sterba
ipwireless: driver for PC Card, 3G internet connection
drivers/char/pcmcia/ipwireless/hardware.c new file +19
-0+struct nl_first_paket_header { +#if defined(__BIG_ENDIAN) +unsigned char packet_rank:2 ; +unsigned char address:3 ; +unsigned char protocol:3 ; +#else +unsigned char protocol:3 ; +unsigned char address:3 ; +unsigned char packet_rank:2 ; +#endif +unsigned char length_lsb; +unsigned char length_msb; +}; + +struct nl_packet_header { +#if defined(__BIG_ENDIAN) +unsigned char packet_rank:2 ; +unsigned char address:3 ; +unsigned char protocol:3 ;
Quoted 8 lines
drivers/char/pcmcia/ipwireless/hardware.c line 148
Quoted 6 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +6
-0+#else + unsigned char protocol:3; + unsigned char address:3; + unsigned char packet_rank:2; +#endif +};You want
__BIG_ENDIAN_BITFIELDhere.
Actually, you probably want to avoid bitfields here, and just do bit arithmetics by hand.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
On Mon, 28 Jan 2008 18:19:29 +0100 David Sterba wrote:
[resending due to send problems, sorry about any dups]
Quoted 96 lines
Hi Linus,
I'm submitting driver for IPWireless PC Card modem for inclusion to 2.6.25.
The driver has been in -mm series as ipwireless_cs.git tree for some time and has passed through lkml (http://lkml.org/lkml/2007/12/12/165).
The PCMCIA subsystem is unmaintained, so I'm sending it directly as Andrew suggested.David Sterba
---
From: David Sterba <[email protected]>ipwireless: driver for PC Card, 3G internet connection
The driver is manufactured by IPWireless.
Rewieved-by Jiri Slaby <[email protected]>Signed-off-by Ben Martel <[email protected]>Signed-off-by Stephen Blackheath <[email protected]>Signed-off-by David Sterba <[email protected]>Signed-off-by Jiri Kosina <[email protected]>--- MAINTAINERS | 8 drivers/char/pcmcia/Kconfig | 9 drivers/char/pcmcia/Makefile | 2 drivers/char/pcmcia/ipwireless/Makefile | 10 drivers/char/pcmcia/ipwireless/hardware.c | 1784 ++++++++++++++++++++++++ drivers/char/pcmcia/ipwireless/hardware.h | 63 drivers/char/pcmcia/ipwireless/main.c | 496 ++++++ drivers/char/pcmcia/ipwireless/main.h | 70 drivers/char/pcmcia/ipwireless/network.c | 513 ++++++ drivers/char/pcmcia/ipwireless/network.h | 54 drivers/char/pcmcia/ipwireless/setup_protocol.h | 108 + drivers/char/pcmcia/ipwireless/tty.c | 687 +++++++++ drivers/char/pcmcia/ipwireless/tty.h | 48 13 files changed, 3852 insertions(+)---
drivers/char/pcmcia/ipwireless/hardware.c new file +52
-0@@ -0,0 +1,1784 @@ +/* +* IPWireless 3G PCMCIA Network Driver +* +* Original code +* by Stephen Blackheath <[email protected]>, +* Ben Martel <[email protected]> +* +* Copyrighted as follows: +* Copyright (C) 2004 by Symmetric Systems Ltd (NZ) +* +* Various driver changes and rewrites, port to new kernels +* Copyright (C) 2006-2007 Jiri Kosina +* +* Misc code cleanups and updates +* Copyright (C) 2007 David Sterba +*/ + +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/kernel.h> +#include <linux/list.h> +#include <linux/slab.h> + +#include "hardware.h" +#include "setup_protocol.h" +#include "network.h" +#include "main.h" + +/* Function prototypes */ +static void ipw_send_setup_packet (struct ipw_hardware *hw); +static void handle_received_SETUP_packet (struct ipw_hardware *ipw, +unsigned int address, +unsigned char *data,int len, +int is_last); +static void ipwireless_setup_timer (unsigned long data); +static void handle_received_CTRL_packet (struct ipw_hardware *hw, +unsigned int channel_idx,unsigned char *data,int len); + +/*#define TIMING_DIAGNOSTICS*/ + +#ifdef TIMING_DIAGNOSTICS + +static struct timing_stats { +unsigned long last_report_time; +unsigned long read_time; +unsigned long write_time; +unsigned long read_bytes; +unsigned long write_bytes; +unsigned long start_time; +}; +
...
drivers/char/pcmcia/ipwireless/hardware.c line 128
Quoted 13 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +13
-0+/* Protocol ids */ +enum { +/* Identifier for the Com Data protocol */ +TL_PROTOCOLID_COM_DATA =0 , + +/* Identifier for the Com Control protocol */ +TL_PROTOCOLID_COM_CTRL =1 , + +/* Identifier for the Setup protocol */ +TL_PROTOCOLID_SETUP =2 +}; + +/* Number of bytes in NL packet header (can not do
cannot
drivers/char/pcmcia/ipwireless/hardware.c line 132
Quoted 4 lines
+ *
sizeof(nl_packet_header)since it's a bitfield) */drivers/char/pcmcia/ipwireless/hardware.c new file +3
-0+#define NL_FIRST_PACKET_HEADER_SIZE 3 + +/* Number of bytes in NL packet header (can not do
cannot
drivers/char/pcmcia/ipwireless/hardware.c line 136
Quoted 4 lines
+ *
sizeof(nl_packet_header)since it's a bitfield) */drivers/char/pcmcia/ipwireless/hardware.c new file +3
-0+#define NL_FOLLOWING_PACKET_HEADER_SIZE 1 + +struct nl_first_paket_header {
packet ?
Quoted 11 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +9
-0+#if defined(__BIG_ENDIAN) + unsigned char packet_rank:2; + unsigned char address:3; + unsigned char protocol:3; +#else + unsigned char protocol:3; + unsigned char address:3; + unsigned char packet_rank:2; +#endif From C99 spec:
"The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined."
so if the order/location of these bitfields is important (from one system to another), you should use bit masks instead of bitfields for them.
Quoted 34 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +34
-0+unsigned char length_lsb; +unsigned char length_msb; +}; + +struct nl_packet_header { +#if defined(__BIG_ENDIAN) +unsigned char packet_rank:2 ; +unsigned char address:3 ; +unsigned char protocol:3 ; +#else +unsigned char protocol:3 ; +unsigned char address:3 ; +unsigned char packet_rank:2 ; +#endif +}; + +/* Value of 'packet_rank' above */ +#define NL_INTERMEDIATE_PACKET 0x0 +#define NL_LAST_PACKET 0x1 +#define NL_FIRST_PACKET 0x2 + +union nl_packet { +/* Network packet header of the first packet (a special case) */ +struct nl_first_paket_header hdr_first; +/* Network packet header of the following packets (if any) */ +struct nl_packet_header hdr; +/* Complete network packet (header + data) */ +unsigned char rawpkt[LL_MTU_MAX ]; +} __attribute__ ((__packed__ )); + +#define HW_VERSION_UNKNOWN -1 +#define HW_VERSION_1 1 +#define HW_VERSION_2 2 +
...
Quoted 66 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +66
-0+ +/* +* Packet info structure for tx packets. +* Note: not all the fields defined here are required for all protocols +*/ +struct ipw_tx_packet { +struct list_head queue; +/* channel idx + 1 */ +unsigned char dest_addr; +/* SETUP, CTRL or DATA */ +unsigned char protocol; +/* Length of data block, which starts at the end of this structure */ +unsigned short length; +/* Sending state */ +/* Offset of where we've sent up to so far */ +unsigned long offset; +/* Count of packet fragments, starting at 0 */ +int fragment_count; + +/* Called after packet is sent and before is freed */ +void (*packet_callback) (void *cb_data,unsigned int packet_length); +void *callback_data; +}; + +/* Signals from DTE */ +enum ComCtrl_DTESignal { + ComCtrl_RTS =0 , + ComCtrl_DTR =1 +}; + +/* Signals from DCE */ +enum ComCtrl_DCESignal { + ComCtrl_CTS =2 , + ComCtrl_DCD =3 , + ComCtrl_DSR =4 , + ComCtrl_RI =5 +}; + +struct ipw_control_packet_body { +/* ComCtrl_DTESignal or ComCtrl_DCESignal */ +unsigned char sig_no; +/* ComCtrl_SET(0) or ComCtrl_CLEAR(1) */ +unsigned char value; +} __attribute__ ((__packed__ )); + +struct ipw_control_packet { +struct ipw_tx_packet header; +struct ipw_control_packet_body body; +}; + +struct ipw_rx_packet { +struct list_head queue; +unsigned int capacity; +unsigned int length; +unsigned int protocol; +unsigned int channel_idx; +}; + +#ifdef IPWIRELESS_STATE_DEBUG +int ipwireless_dump_hardware_state (char *p,struct ipw_hardware *hw) +{ +int idx =0 ; + + idx +=sprintf (p + idx,"debug: initializing=%d\n" , hw->initializing); + idx +=sprintf (p + idx,"debug: tx_ready=%d\n" , hw->tx_ready); + idx +=sprintf (p + idx,"debug: tx_queued=%d\n" , hw->tx_queued);
drivers/char/pcmcia/ipwireless/hardware.c line 380
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+ idx +=sprintf (p + idx,"debug: rx_ready=%d\n" , hw->rx_ready); + idx +=sprintf (p + idx,"debug: rx_bytes_queued=%d\n" , + hw->rx_bytes_queued); + idx +=sprintf (p + idx,"debug: blocking_rx=%d\n" , hw->blocking_rx); + idx +=sprintf (p + idx,"debug: removed=%d\n" , hw->removed); + idx +=sprintf (p + idx,"debug: hardware.shutting_down=%d\n" , + hw->shutting_down); + idx +=sprintf (p + idx,"debug: to_setup=%d\n" , + hw->to_setup); +return idx;
check for/prevent overflow of <p> ?
Quoted 34 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +34
-0+} +#endif + +static char *data_type (const unsigned char *buf,unsigned length) +{ +struct nl_packet_header *hdr = (struct nl_packet_header *) buf; + +if (length ==0 ) +return " " ; + +if (hdr->packet_rank &NL_FIRST_PACKET ) { +switch (hdr->protocol) { +case TL_PROTOCOLID_COM_DATA :return "DATA " ; +case TL_PROTOCOLID_COM_CTRL :return "CTRL " ; +case TL_PROTOCOLID_SETUP :return "SETUP" ; +default :return "???? " ; + } + }else +return " " ; +} + +#define DUMP_MAX_BYTES 64 + +static void dump_data_bytes (const char *type,const unsigned char *data, +unsigned length) +{ +char prefix[56 ]; + +sprintf (prefix,IPWIRELESS_PCCARD_NAME ": %s %s " , + type,data_type (data, length)); +print_hex_dump_bytes (prefix,0 , (void *)data, + length <DUMP_MAX_BYTES ? length :DUMP_MAX_BYTES ); +} +
...
Quoted 69 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +69
-0+ +/* +* Retrieve a packet from the IPW hardware. +*/ +static void do_receive_packet (struct ipw_hardware *hw) +{ +unsigned short len; +unsigned int i; +unsigned char pkt[LL_MTU_MAX ]; + +start_timing (); + +if (hw->hw_version ==HW_VERSION_1 ) { + len =inw (hw->base_port +IODRR ); +if (len > hw->ll_mtu) { + printk(KERN_INFO IPWIRELESS_PCCARD_NAME +": received a packet of %d bytes - " + "longer than the MTU!\n", (unsigned int)len); +outw (DCR_RXDONE |DCR_RXRESET , hw->base_port +IODCR ); +return ; + } + +for (i =0 ; i < len; i +=2 ) { +__le16 raw_data =inw (hw->base_port +IODRR ); +unsigned short data =le16_to_cpu (raw_data); + + pkt[i] = (unsigned char ) data; + pkt[i +1 ] = (unsigned char ) (data >>8 ); + } + }else { + len =inw (hw->base_port +IODMADPR ); +if (len > hw->ll_mtu) { + printk(KERN_INFO IPWIRELESS_PCCARD_NAME +": received a packet of %d bytes - " + "longer than the MTU!\n", (unsigned int)len); +writew (MEMRX_PCINTACKK , + &hw->memory_info_regs->memreg_pc_interrupt_ack); +return ; + } + +for (i =0 ; i < len; i +=2 ) { +__le16 raw_data =inw (hw->base_port +IODMADPR ); +unsigned short data =le16_to_cpu (raw_data); + + pkt[i] = (unsigned char ) data; + pkt[i +1 ] = (unsigned char ) (data >>8 ); + } + +while ((i &3 ) !=2 ) { +inw (hw->base_port +IODMADPR ); + i +=2 ; + } + } + +acknowledge_data_read (hw); + +if (ipwireless_debug) +dump_data_bytes ("recv" , pkt, len); + +handle_received_packet (hw, (union nl_packet *) pkt, len); + +end_read_timing (len); +} + +static int get_current_packet_priority (struct ipw_hardware *hw) +{ +/* +* If we're initializing, don't send anything of higher priority than +* PRIO_SETUP. The network layer therefore need not care about
drivers/char/pcmcia/ipwireless/hardware.c line 945
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+* hardware initialization - any of its stuff will simply be queued +* until setup is complete. +*/ +return (hw->to_setup || hw->initializing + ?PRIO_SETUP +1 : +NL_NUM_OF_PRIORITIES ); +} + +/* +* @return 1 if something has been received from hw
What's with the '@'?
Quoted 16 lines
+ */
drivers/char/pcmcia/ipwireless/hardware.c new file +15
-0+static int get_packets_from_hw (struct ipw_hardware *hw) +{ +int received =0 ; +unsigned long flags; + +spin_lock_irqsave (&hw->spinlock, flags); +while (hw->rx_ready && !hw->blocking_rx) { + received =1 ; + hw->rx_ready--; +spin_unlock_irqrestore (&hw->spinlock, flags); + +do_receive_packet (hw); + +spin_lock_irqsave (&hw->spinlock, flags); + }
drivers/char/pcmcia/ipwireless/hardware.c line 971
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+spin_unlock_irqrestore (&hw->spinlock, flags); + +return received; +} + +/* +* Send pending packet up to given priority, prioritize SETUP data until +* hardware is fully setup. +* +* @return 1 if more packets can be sent
ditto.
Quoted 82 lines
+ */
drivers/char/pcmcia/ipwireless/hardware.c new file +81
-0+static int send_pending_packet (struct ipw_hardware *hw,int priority_limit) +{ +int more_to_send =0 ; +unsigned long flags; + +spin_lock_irqsave (&hw->spinlock, flags); +if (hw->tx_queued && hw->tx_ready !=0 ) { +int priority; +struct ipw_tx_packet *packet =NULL ; + + hw->tx_ready--; + +/* Pick a packet */ +for (priority =0 ; priority < priority_limit; priority++) { +if (!list_empty (&hw->tx_queue[priority])) { + packet =list_first_entry ( + &hw->tx_queue[priority], + struct ipw_tx_packet, + queue); + +list_del (&packet->queue); + +break ; + } + } +if (!packet) { + hw->tx_queued =0 ; +spin_unlock_irqrestore (&hw->spinlock, flags); +return 0 ; + } +spin_unlock_irqrestore (&hw->spinlock, flags); + +/* Send */ +do_send_packet (hw, packet); + +/* Check if more to send */ +spin_lock_irqsave (&hw->spinlock, flags); +for (priority =0 ; priority < priority_limit; priority++) +if (!list_empty (&hw->tx_queue[priority])) { + more_to_send =1 ; +break ; + } + +if (!more_to_send) + hw->tx_queued =0 ; + } +spin_unlock_irqrestore (&hw->spinlock, flags); + +return more_to_send; +} + +/* +* Send and receive all queued packets. +*/ +static void ipwireless_do_tasklet (unsigned long hw_) +{ +struct ipw_hardware *hw = (struct ipw_hardware *) hw_; +unsigned long flags; + +spin_lock_irqsave (&hw->spinlock, flags); +if (hw->shutting_down) { +spin_unlock_irqrestore (&hw->spinlock, flags); +return ; + } + +if (hw->to_setup ==1 ) { +/* +* Initial setup data sent to hardware +*/ + hw->to_setup =2 ; +spin_unlock_irqrestore (&hw->spinlock, flags); + +ipw_setup_hardware (hw); +ipw_send_setup_packet (hw); + +send_pending_packet (hw,PRIO_SETUP +1 ); +get_packets_from_hw (hw); + }else { +int priority_limit =get_current_packet_priority (hw); +int again; +
drivers/char/pcmcia/ipwireless/hardware.c line 1063
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+spin_unlock_irqrestore (&hw->spinlock, flags); + +do { + again =send_pending_packet (hw, priority_limit); + again |=get_packets_from_hw (hw); + }while (again); + } +} + +/*!
and the '!' ?
Quoted 11 lines
+ * @return true if the card is physically present.
+ */drivers/char/pcmcia/ipwireless/hardware.c new file +9
-0+static int is_card_present (struct ipw_hardware *hw) +{ +if (hw->hw_version ==HW_VERSION_1 ) +return inw (hw->base_port +IOIR ) != (unsigned short )0xFFFF ; +else +return readl (&hw->memory_info_regs->memreg_card_present) == +CARD_PRESENT_VALUE ; +} +
...
Quoted 85 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +85
-0+/* This handles the actual initialization of the card */ +static void __handle_setup_get_version_rsp (struct ipw_hardware *hw) +{ +struct ipw_setup_config_packet *config_packet; +struct ipw_setup_config_done_packet *config_done_packet; +struct ipw_setup_open_packet *open_packet; +struct ipw_setup_info_packet *info_packet; +int port; +unsigned int channel_idx; + +/* generate config packet */ +for (port =1 ; port <=NL_NUM_OF_ADDRESSES ; port++) { + config_packet =alloc_ctrl_packet ( +sizeof (struct ipw_setup_config_packet ), +ADDR_SETUP_PROT , +TL_PROTOCOLID_SETUP , +TL_SETUP_SIGNO_CONFIG_MSG ); +if (!config_packet) + goto exit_nomem; + config_packet->header.length =sizeof (struct TlSetupConfigMsg ); + config_packet->body.port_no = port; + config_packet->body.prio_data =PRIO_DATA ; + config_packet->body.prio_ctrl =PRIO_CTRL ; +send_packet (hw,PRIO_SETUP , &config_packet->header); + } + config_done_packet =alloc_ctrl_packet ( +sizeof (struct ipw_setup_config_done_packet ), +ADDR_SETUP_PROT , +TL_PROTOCOLID_SETUP , +TL_SETUP_SIGNO_CONFIG_DONE_MSG ); +if (!config_done_packet) + goto exit_nomem; + config_done_packet->header.length =sizeof (struct TlSetupConfigDoneMsg ); +send_packet (hw,PRIO_SETUP , &config_done_packet->header); + +/* generate open packet */ +for (port =1 ; port <=NL_NUM_OF_ADDRESSES ; port++) { + open_packet =alloc_ctrl_packet ( +sizeof (struct ipw_setup_open_packet ), +ADDR_SETUP_PROT , +TL_PROTOCOLID_SETUP , +TL_SETUP_SIGNO_OPEN_MSG ); +if (!open_packet) + goto exit_nomem; + open_packet->header.length =sizeof (struct TlSetupOpenMsg ); + open_packet->body.port_no = port; +send_packet (hw,PRIO_SETUP , &open_packet->header); + } +for (channel_idx =0 ; + channel_idx <NL_NUM_OF_ADDRESSES ; channel_idx++) { +int ret; + + ret =set_DTR (hw,PRIO_SETUP , channel_idx, + (hw->control_lines[channel_idx] & +IPW_CONTROL_LINE_DTR ) !=0 ); +if (ret) { + printk(KERN_ERR IPWIRELESS_PCCARD_NAME + "error setting DTR (%d)\n", ret); +return ; + } + +set_RTS (hw,PRIO_SETUP , channel_idx, + (hw->control_lines [channel_idx] & +IPW_CONTROL_LINE_RTS ) !=0 ); +if (ret) { + printk(KERN_ERR IPWIRELESS_PCCARD_NAME + "error setting RTS (%d)\n", ret); +return ; + } + } +/* +* For NDIS we assume that we are using sync PPP frames, for COM async. +* This driver uses NDIS mode too. We don't bother with translation +* from async -> sync PPP. +*/ + info_packet =alloc_ctrl_packet (sizeof (struct ipw_setup_info_packet ), +ADDR_SETUP_PROT , +TL_PROTOCOLID_SETUP , +TL_SETUP_SIGNO_INFO_MSG ); +if (!info_packet) + goto exit_nomem; + info_packet->header.length =sizeof (struct TlSetupInfoMsg ); + info_packet->body.driver_type =NDISWAN_DRIVER ; + info_packet->body.major_version =NDISWAN_DRIVER_MAJOR_VERSION ; + info_packet->body.minor_version =NDISWAN_DRIVER_MINOR_VERSION ;
drivers/char/pcmcia/ipwireless/hardware.c line 1513
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+send_packet (hw,PRIO_SETUP , &info_packet->header); + +/* Initialization is now complete, so we clear the 'to_setup' flag */ + hw->to_setup =0 ; + +return ; + +exit_nomem: + printk(KERN_ERR IPWIRELESS_PCCARD_NAME + "not enough memory to alloc control packet\n");
Need ":" and/or space between CARD_NAME and following string. (in several places)
Quoted 19 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +19
-0+ hw->to_setup =-1 ; +} + +static void handle_setup_get_version_rsp (struct ipw_hardware *hw, +unsigned char vers_no) +{ +del_timer (&hw->setup_timer); + hw->initializing =0 ; + printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": card is ready.\n"); + +if (vers_no ==TL_SETUP_VERSION ) +__handle_setup_get_version_rsp (hw); +else + printk(KERN_ERR +IPWIRELESS_PCCARD_NAME +": invalid hardware version no %u\n" , + (unsigned int ) vers_no); +} +
...
Quoted 56 lines
drivers/char/pcmcia/ipwireless/main.c new file +50
-0@@ -0,0 +1,496 @@ +/* +* IPWireless 3G PCMCIA Network Driver +* +* Original code +* by Stephen Blackheath <[email protected]>, +* Ben Martel <[email protected]> +* +* Copyrighted as follows: +* Copyright (C) 2004 by Symmetric Systems Ltd (NZ) +* +* Various driver changes and rewrites, port to new kernels +* Copyright (C) 2006-2007 Jiri Kosina +* +* Misc code cleanups and updates +* Copyright (C) 2007 David Sterba +*/ + +#include "hardware.h" +#include "network.h" +#include "main.h" +#include "tty.h" + +#include <linux/delay.h> +#include <linux/init.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/sched.h> +#include <linux/slab.h> + +#include <pcmcia/version.h> +#include <pcmcia/cisreg.h> +#include <pcmcia/device_id.h> +#include <pcmcia/ss.h> +#include <pcmcia/ds.h> +#include <pcmcia/cs.h> + +static struct pcmcia_device_id ipw_ids[] = { +PCMCIA_DEVICE_MANF_CARD (0x02f2 ,0x0100 ), +PCMCIA_DEVICE_MANF_CARD (0x02f2 ,0x0200 ), +PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE (pcmcia, ipw_ids); + +static void ipwireless_detach (struct pcmcia_device *link); + +/* Module params */ +int ipwireless_debug; +int ipwireless_loopback; +int ipwireless_out_queue =1 ;
drivers/char/pcmcia/ipwireless/main.c line 60
Quoted 10 lines
drivers/char/pcmcia/ipwireless/main.c new file +10
-0+static int major; + +module_param (major, int,0 ); +module_param (ipwireless_debug, int,0 ); +module_param (ipwireless_loopback, int,0 ); +module_param (ipwireless_out_queue, int,0 ); +MODULE_PARM_DESC (major,"ttyIPWp major number [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on debug messages [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on loopback mode [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"set size of outgoing queue [1]" );
Will these parameters be documented anywhere?
HERE:
Quoted 68 lines
drivers/char/pcmcia/ipwireless/network.c new file +62
-0@@ -0,0 +1,513 @@ +/* +* IPWireless 3G PCMCIA Network Driver +* +* Original code +* by Stephen Blackheath <[email protected]>, +* Ben Martel <[email protected]> +* +* Copyrighted as follows: +* Copyright (C) 2004 by Symmetric Systems Ltd (NZ) +* +* Various driver changes and rewrites, port to new kernels +* Copyright (C) 2006-2007 Jiri Kosina +* +* Misc code cleanups and updates +* Copyright (C) 2007 David Sterba +*/ + +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mutex.h> +#include <linux/netdevice.h> +#include <linux/ppp_channel.h> +#include <linux/ppp_defs.h> +#include <linux/if_ppp.h> +#include <linux/skbuff.h> + +#include "network.h" +#include "hardware.h" +#include "main.h" +#include "tty.h" + +struct ipw_network { +/* Hardware context, used for calls to hardware layer. */ +struct ipw_hardware *hardware; +/* Context for kernel 'generic_ppp' functionality */ +struct ppp_channel *ppp_channel; +/* tty context connected with IPW console */ +struct ipw_tty *associated_ttys[NO_OF_IPW_CHANNELS ][MAX_ASSOCIATED_TTYS ]; +/* True if ppp needs waking up once we're ready to xmit */ +int ppp_blocked; +/* Number of packets queued up in hardware module. */ +int outgoing_packets_queued; +/* Spinlock to avoid interrupts during shutdown */ +spinlock_t spinlock; +struct mutex close_lock; + +/* PPP ioctl data, not actually used anywere */ +unsigned int flags; +unsigned int rbits; +u32 xaccm[8 ]; +u32 raccm; +int mru; + +int shutting_down; +unsigned int ras_control_lines; + +struct work_struct work_go_online; +struct work_struct work_go_offline; +}; + + +#ifdef IPWIRELESS_STATE_DEBUG
drivers/char/pcmcia/ipwireless/network.c line 72
Quoted 10 lines
drivers/char/pcmcia/ipwireless/network.c new file +10
-0+int ipwireless_dump_network_state (char *p,struct ipw_network *network) +{ +int idx =0 ; + + idx +=sprintf (p + idx,"debug: ppp_blocked=%d\n" , + network->ppp_blocked); + idx +=sprintf (p + idx,"debug: outgoing_packets_queued=%d\n" , + network->outgoing_packets_queued); + idx +=sprintf (p + idx,"debug: network.shutting_down=%d\n" , + network->shutting_down);
check for overflow of 'p'?
Quoted 43 lines
drivers/char/pcmcia/ipwireless/network.c new file +4
-0+ return idx; +} +#endif +drivers/char/pcmcia/ipwireless/setup_protocol.h new file +31
-0@@ -0,0 +1,108 @@ +/* +* IPWireless 3G PCMCIA Network Driver +* +* Original code +* by Stephen Blackheath <[email protected]>, +* Ben Martel <[email protected]> +* +* Copyrighted as follows: +* Copyright (C) 2004 by Symmetric Systems Ltd (NZ) +* +* Various driver changes and rewrites, port to new kernels +* Copyright (C) 2006-2007 Jiri Kosina +* +* Misc code cleanups and updates +* Copyright (C) 2007 David Sterba +*/ + +#ifndef _IPWIRELESS_CS_SETUP_PROTOCOL_H_ +#define _IPWIRELESS_CS_SETUP_PROTOCOL_H_ + +/* Version of the setup protocol and transport protocols */ +#define TL_SETUP_VERSION 1 + +#define TL_SETUP_VERSION_QRY_TMO 1000 +#define TL_SETUP_MAX_VERSION_QRY 30 + +/* Message numbers 0-9 are obsoleted and must not be reused! */ +#define TL_SETUP_SIGNO_GET_VERSION_QRY 10 +#define TL_SETUP_SIGNO_GET_VERSION_RSP 11 +#define TL_SETUP_SIGNO_CONFIG_MSG 12 +#define TL_SETUP_SIGNO_CONFIG_DONE_MSG 13
drivers/char/pcmcia/ipwireless/setup_protocol.h line 41
Quoted 10 lines
drivers/char/pcmcia/ipwireless/setup_protocol.h new file +10
-0+#define TL_SETUP_SIGNO_OPEN_MSG 14 +#define TL_SETUP_SIGNO_CLOSE_MSG 15 + +#define TL_SETUP_SIGNO_INFO_MSG 20 +#define TL_SETUP_SIGNO_INFO_MSG_ACK 21 + +#define TL_SETUP_SIGNO_REBOOT_MSG 22 +#define TL_SETUP_SIGNO_REBOOT_MSG_ACK 23 + +/* Syncronous start-messages */
Synchronous
drivers/char/pcmcia/ipwireless/setup_protocol.h line 45
Quoted 4 lines
drivers/char/pcmcia/ipwireless/setup_protocol.h new file +4
-0+struct TlSetupGetVersionQry { +unsigned char sig_no;/* TL_SETUP_SIGNO_GET_VERSION_QRY */ +} __attribute__ ((__packed__ )); +
---
~Randy
Quoted 4 lines · Randy Dunlap
Quoted 2 lines
+/*
+ * @return 1 if something has been received from hwWhat's with the '@'?
...
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/*!and the '!' ?
Quoted 2 lines
+ * @return true if the card is physically present.
+ */
What exactly is wrong with @ and !? It's perfectly doxygen-styled.
Quoted 6 lines
Quoted 6 lines
drivers/char/pcmcia/ipwireless/main.c new file +0
-0@@ -0,0 +1,496 @@
[...]
Quoted 10 lines
drivers/char/pcmcia/ipwireless/main.c line 60
Quoted 8 lines
drivers/char/pcmcia/ipwireless/main.c new file +8
-0+module_param (major, int,0 ); +module_param (ipwireless_debug, int,0 ); +module_param (ipwireless_loopback, int,0 ); +module_param (ipwireless_out_queue, int,0 ); +MODULE_PARM_DESC (major,"ttyIPWp major number [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on debug messages [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on loopback mode [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"set size of outgoing queue [1]" );Will these parameters be documented anywhere?
Anyway the descs are wrong. Those 3 are for the only one variable.
Quoted 11 lines · On Tue, 29 Jan 2008 00:18:03 +0100 Jiri Slaby wrote:
Quoted 4 lines · Randy Dunlap
Quoted 2 lines
+/*
+ * @return 1 if something has been received from hwWhat's with the '@'?
...
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/*!and the '!' ?
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
+ * @return true if the card is physically present.
+ */What exactly is wrong with @ and !? It's perfectly doxygen-styled.
What part of kernel documentation uses doxygen?
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
drivers/char/pcmcia/ipwireless/main.c new file +0
-0@@ -0,0 +1,496 @@[...]
Quoted 10 lines
drivers/char/pcmcia/ipwireless/main.c line 60
Quoted 8 lines
drivers/char/pcmcia/ipwireless/main.c new file +8
-0+module_param (major, int,0 ); +module_param (ipwireless_debug, int,0 ); +module_param (ipwireless_loopback, int,0 ); +module_param (ipwireless_out_queue, int,0 ); +MODULE_PARM_DESC (major,"ttyIPWp major number [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on debug messages [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on loopback mode [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"set size of outgoing queue [1]" );Will these parameters be documented anywhere?
Quoted 1 line
Anyway the descs are wrong. Those 3 are for the only one variable.
Ack, thanks.
---
~Randy
Quoted 11 lines · Randy Dunlap
Quoted 9 lines · On Tue, 29 Jan 2008 00:18:03 +0100 Jiri Slaby wrote:
Quoted 3 lines · Randy Dunlap
Quoted 2 lines
+/*
+ * @return 1 if something has been received from hwWhat's with the '@'?
...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/*!and the '!' ?
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
+ * @return true if the card is physically present.
+ */What exactly is wrong with @ and !? It's perfectly doxygen-styled.
What part of kernel documentation uses doxygen?
So then, what's the problem?
Quoted 12 lines · On Tue, 29 Jan 2008 00:29:19 +0100 Jiri Slaby wrote:
Quoted 11 lines · Randy Dunlap
Quoted 9 lines · On Tue, 29 Jan 2008 00:18:03 +0100 Jiri Slaby wrote:
Quoted 3 lines · Randy Dunlap
Quoted 2 lines
+/*
+ * @return 1 if something has been received from hwWhat's with the '@'?
...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/*!and the '!' ?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
+ * @return true if the card is physically present.
+ */What exactly is wrong with @ and !? It's perfectly doxygen-styled.
What part of kernel documentation uses doxygen?
So then, what's the problem?
Why is it there? We have a kernel documentation language. Please use it or plain text.
---
~Randy
Hi,
Quoted 6 lines · Randy Dunlap
Quoted 3 lines
Quoted 1 line
What part of kernel documentation uses doxygen?
So then, what's the problem?
Why is it there? We have a kernel documentation language. Please use it or plain text.
Yes please.
Pekka
Quoted 13 lines · On Tuesday 29 of January 2008 00:18:03 Jiri Slaby wrote:
Quoted 4 lines · Randy Dunlap
Quoted 2 lines
+/*
+ * @return 1 if something has been received from hwWhat's with the '@'?
...
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/*!and the '!' ?
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
+ * @return true if the card is physically present.
+ */What exactly is wrong with @ and !? It's perfectly doxygen-styled.
Well, I've removed them, this was not consistent neither within the driver nor with kernel documenting style.
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +0
-0
b/drivers/char/pcmcia/ipwireless/main.cnew file mode 100644 index 0000000..cab5722drivers/char/pcmcia/ipwireless/main.c new file +0
-0@@ -0,0 +1,496 @@[...]
Quoted 10 lines
drivers/char/pcmcia/ipwireless/main.c line 60
Quoted 8 lines
drivers/char/pcmcia/ipwireless/main.c new file +8
-0+module_param (major, int,0 ); +module_param (ipwireless_debug, int,0 ); +module_param (ipwireless_loopback, int,0 ); +module_param (ipwireless_out_queue, int,0 ); +MODULE_PARM_DESC (major,"ttyIPWp major number [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on debug messages [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on loopback mode [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"set size of outgoing queue [1]" );Will these parameters be documented anywhere?
Quoted 1 line
Anyway the descs are wrong. Those 3 are for the only one variable.
Yes this was my copy&paste error, thanks.
Dave
Quoted 3 lines · On Monday 28 of January 2008 19:08:54 Randy Dunlap wrote:
Quoted 1 line
+/* Number of bytes in NL packet header (can not do
cannot
Fixed.
Quoted 7 lines
drivers/char/pcmcia/ipwireless/hardware.c line 136
Quoted 5 lines
+ *
sizeof(nl_packet_header)since it's a bitfield) */drivers/char/pcmcia/ipwireless/hardware.c new file +3
-0+#define NL_FOLLOWING_PACKET_HEADER_SIZE 1 + +struct nl_first_paket_header {packet ?
Yes, packet of course.
Quoted 15 lines
drivers/char/pcmcia/ipwireless/hardware.c line 145
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +9
-0+#if defined(__BIG_ENDIAN) + unsigned char packet_rank:2; + unsigned char address:3; + unsigned char protocol:3; +#else + unsigned char protocol:3; + unsigned char address:3; + unsigned char packet_rank:2; +#endif From C99 spec:
"The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined."
Quoted 3 lines
so if the order/location of these bitfields is important (from one system to another), you should use bit masks instead of bitfields for them.
I've changed it to __BIG_ENDIAN_BITFIELDS, as suggested by Alexey. The order is important. I'll add it to my todo to convert it to bitmasks.
Quoted 4 lines
Quoted 2 lines
+/*
+ * @return 1 if something has been received from hwWhat's with the '@'?
Removed, and converted to plaintext as suggested by others.
Quoted 2 lines
Need ":" and/or space between
CARD_NAMEand following string. (in several places)
Found a few of them and fixed.
Quoted 10 lines
drivers/char/pcmcia/ipwireless/main.c line 60
Quoted 8 lines
drivers/char/pcmcia/ipwireless/main.c new file +8
-0+module_param (major, int,0 ); +module_param (ipwireless_debug, int,0 ); +module_param (ipwireless_loopback, int,0 ); +module_param (ipwireless_out_queue, int,0 ); +MODULE_PARM_DESC (major,"ttyIPWp major number [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on debug messages [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"switch on loopback mode [0]" ); +MODULE_PARM_DESC (ipwireless_debug,"set size of outgoing queue [1]" );Will these parameters be documented anywhere?
The options are intended for debugging. Normal user does not need to tweak them. Adjusted the description to reflect their debugging purpose.
Quoted 5 lines
Quoted 5 lines
drivers/char/pcmcia/ipwireless/network.c new file +5
-0+#ifdef IPWIRELESS_STATE_DEBUG +int ipwireless_dump_network_state (char *p,struct ipw_network *network) +{ +int idx =0 ; +
Quoted 8 lines
drivers/char/pcmcia/ipwireless/network.c line 77
Quoted 6 lines
drivers/char/pcmcia/ipwireless/network.c new file +6
-0+ idx +=sprintf (p + idx,"debug: ppp_blocked=%d\n" , + network->ppp_blocked); + idx +=sprintf (p + idx,"debug: outgoing_packets_queued=%d\n" , + network->outgoing_packets_queued); + idx +=sprintf (p + idx,"debug: network.shutting_down=%d\n" , + network->shutting_down);check for overflow of 'p'?
Converted to one snprintf too.
Quoted 3 lines
Quoted 1 line
+/* Syncronous start-messages */
Synchronous
Fixed.
Updated patch will follow.
Thank you for comments.
Dave
Hi!
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+/* I/O ports and bit definitions for version 1 of the hardware */ + +/* IER bits*/ +#define IER_RXENABLED ((unsigned short) 0x1) +#define IER_TXENABLED ((unsigned short) 0x2)
drivers/char/pcmcia/ipwireless/hardware.c line 204
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+ +/* ISR bits */ +#define IR_RXINTR ((unsigned short) 0x1) +#define IR_TXINTR ((unsigned short) 0x2) + +/* DCR bits */ +#define DCR_RXDONE ((unsigned short) 0x1) +#define DCR_TXDONE ((unsigned short) 0x2) +#define DCR_RXRESET ((unsigned short) 0x4) +#define DCR_TXRESET ((unsigned short) 0x8)
Are those casts neccessary?
drivers/char/pcmcia/ipwireless/hardware.c line 215
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+/* I/O ports and bit definitions for version 2 of the hardware */ + +struct MEMCCR { +unsigned short PCCOR;/* Configuration Option Register */ +unsigned short PCCSR;/* Configuration and Status Register */ +unsigned short PCPRR;/* Pin Replacemant Register */ +unsigned short PCSCR;/* Socket and Copy Register */ +unsigned short PCESR;/* Extendend Status Register */ +unsigned short PCIOB;/* I/O Base Register */ +};
Could we get better names? PCIOB is cryptic, pci_io_base is pretty good.
drivers/char/pcmcia/ipwireless/hardware.c line 333
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+/* Signals from DTE */ +enum ComCtrl_DTESignal { + ComCtrl_RTS =0 , + ComCtrl_DTR =1 +};
CamelCaseIsEvil.
Quoted 13 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +13
-0+static irqreturn_t ipwireless_handle_v1_interrupt (int irq, +struct ipw_hardware *hw) +{ +unsigned short irqn; +unsigned short ack; + + irqn =inw (hw->base_port +IOIR ); + +/* Check if card is present */ +if (irqn == (unsigned short )0xFFFF ) { +if (++hw->bad_interrupt_count >=100 ) { +/* +* It is necessary to disable the interrupt at this
drivers/char/pcmcia/ipwireless/hardware.c line 1097
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+* point, or the kernel hangs, interrupting repeatedly +* forever. +*/ + hw->irq = irq; + hw->removed =1 ; +disable_irq_nosync (irq); + printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME + ": Mr. Fluffy is not happy!\n"); + } +return IRQ_HANDLED ;
Not sure how this is supposed to work. If you assume unshared interrupts, it should be possible to return something and make core care.
If you are assuming shared interrupts, either you should disable on first 0xFFFF (are you sure cast is needed, btw?), or not at all, because it could be the other device sedning you 100 of those...
...so which one is it?
Is some locking needed around *hw?
drivers/char/pcmcia/ipwireless/hardware.c line 1324
Quoted 12 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +12
-0+int ipwireless_send_packet (struct ipw_hardware *hw,unsigned int channel_idx, +unsigned char *data,unsigned int length, +void (*callback) (void *cb,unsigned int length), +void *callback_data) +{ +struct ipw_tx_packet *packet; + + packet =alloc_data_packet (length, + (unsigned char ) (channel_idx +1 ), +TL_PROTOCOLID_COM_DATA ); +if (!packet) +return -1 ;
-ENOMEM would be more usual calling convention.
drivers/char/pcmcia/ipwireless/hardware.c line 1392
Quoted 4 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +4
-0+struct ipw_setup_get_version_query_packet { +struct ipw_tx_packet header; +struct TlSetupGetVersionQry body; +};
MoreEvilCamelCase.
drivers/char/pcmcia/ipwireless/main.c line 94
Quoted 11 lines
drivers/char/pcmcia/ipwireless/main.c new file +11
-0+static int config_ipwireless (struct ipw_dev *ipw) +{ +struct pcmcia_device *link = ipw->link; +int ret; +config_info_t conf; +tuple_t tuple; +unsigned short buf[64 ]; +cisparse_t parse; +unsigned short cor_value; +win_req_t reqAM; +win_req_t reqCM;
Hiding structs BehindTypedefsIsEvil.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Pavel & all,
Quoted 6 lines · Pavel Machek
Quoted 6 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +6
-0+/* I/O ports and bit definitions for version 2 of the hardware */ + +struct MEMCCR { +unsigned short PCCOR;/* Configuration Option Register */ +unsigned short PCCSR;/* Configuration and Status Register */ +unsigned short PCPRR;/* Pin Replacemant Register */
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c line 215
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +4
-0+unsigned short PCSCR ;/* Socket and Copy Register */ +unsigned short PCESR ;/* Extendend Status Register */ +unsigned short PCIOB ;/* I/O Base Register */ +};Could we get better names? PCIOB is cryptic,
pci_io_baseis pretty good.
We should keep these names because they are part of the interface between host and card defined by the manufacturer.
Quoted 29 lines
Quoted 14 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +13
-0+static irqreturn_t ipwireless_handle_v1_interrupt (int irq, +struct ipw_hardware *hw) +{ +unsigned short irqn; +unsigned short ack; + + irqn =inw (hw->base_port +IOIR ); + +/* Check if card is present */ +if (irqn == (unsigned short )0xFFFF ) { +if (++hw->bad_interrupt_count >=100 ) { +/* +* It is necessary to disable the interrupt at this drivers/char/pcmcia/ipwireless/hardware.c line 1097
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+* point, or the kernel hangs, interrupting repeatedly +* forever. +*/ + hw->irq = irq; + hw->removed =1 ; +disable_irq_nosync (irq); + printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME + ": Mr. Fluffy is not happy!\n"); + } +return IRQ_HANDLED ;Not sure how this is supposed to work. If you assume unshared interrupts, it should be possible to return something and make core care.
Quoted 6 lines
If you are assuming shared interrupts, either you should disable on first
0xFFFF(are you sure cast is needed, btw?), or not at all, because it could be the other device sedning you 100 of those......so which one is it?
This code is obsolete (a workaround to an embedded system bug) and should be removed - sorry I didn't step on it earlier. It can removed with minimal risk of destabilizing the driver. It should look like this:
static irqreturn_t ipwireless_handle_v1_interrupt(int irq, ipw_hardware_t *hw)
{
u_short irqn;
u_short ack;
irqn = inw(hw->base_port + IOIR);
if (irqn == (u_short) 0xFFFF)
return IRQ_NONE;
else if (irqn != 0) {
ack = 0;
/* Transmit complete. */
if (irqn & IR_TXINTR) {
hw->tx_ready++;
ack |= IR_TXINTR;
}
/* Received data */
if (irqn & IR_RXINTR) {
ack |= IR_RXINTR;
hw->rx_ready++;
}
if (ack != 0) {
outw(ack, hw->base_port + IOIR);
/* Perform the I/O retrieval in a tasklet,
because the ppp_generic
may be called from a tasklet, but not from a
hardware interrupt. */
if (!hw->tasklet_pending) {
hw->tasklet_pending = 1;
tasklet_schedule(&hw->tasklet);
}
}
return IRQ_HANDLED;
} else
return IRQ_NONE;}
The v2_v3 handler should not have it either, and should start like this:
static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq, ipw_hardware_t *hw)
{
int tx = 0;
int rx = 0;
int rx_repeat = 0;
int b_try_MemTX_OLD;
do {
u_short memtx = ioread16(hw->MemTX);
u_short memtx_serial;
u_short memrxdone = ioread16(&hw->memInfReg->MemRXDone);
b_try_MemTX_OLD = 0;
/* check whether the interrupt was generated by ipwireless card */
if (!(memtx & MEMTX_TX) && !(memrxdone & MEMRX_RX_DONE))
return IRQ_NONE;
/* See if the card is physically present. Note that while it is
* powering up, it appears not to be present. */
if (ioread32(&hw->memInfReg->MemCardPresent) !=
CARD_PRESENT_VALUE) {
u_short csr = ioread16(&hw->memCCR->PCCSR);
csr &= 0xfffd;
iowrite16(csr, &hw->memCCR->PCCSR);
return IRQ_HANDLED;
}Quoted 2 lines
Is some locking needed around *hw?
I don't think so, but I'm happy to be corrected.
Steve
Quoted 20 lines · Stephen Blackheath [to Foxconn]
Pavel & all,
Quoted 5 lines · Pavel Machek
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+/* I/O ports and bit definitions for version 2 of the hardware */ + +struct MEMCCR { +unsigned short PCCOR;/* Configuration Option Register */ +unsigned short PCCSR;/* Configuration and Status Register */ Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c line 215
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+unsigned short PCPRR ;/* Pin Replacemant Register */ +unsigned short PCSCR ;/* Socket and Copy Register */ +unsigned short PCESR ;/* Extendend Status Register */ +unsigned short PCIOB ;/* I/O Base Register */ +};Could we get better names? PCIOB is cryptic,
pci_io_baseis pretty good.
Quoted 2 lines
We should keep these names because they are part of the interface between host and card defined by the manufacturer.
No. Use sensible names, and put manufacturer-defined 5-letter crap in the comments. Heck, notice that they just took first letter of each word of good name....
Quoted 3 lines
Quoted 2 lines
Is some locking needed around *hw?
I don't think so, but I'm happy to be corrected.
You have a structure, and are accessing its fields from interrupts. I assume you access the fields outside interrupt, too? As the fields are not of atomic_t, I believe you need locking.
(Oh, and I should have said that earlier: Thanks for the driver and congratulations for getting it this far).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi,
Quoted 7 lines
drivers/char/pcmcia/ipwireless/hardware.c line 204
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+/* DCR bits */ +#define DCR_RXDONE ((unsigned short) 0x1) +#define DCR_TXDONE ((unsigned short) 0x2) +#define DCR_RXRESET ((unsigned short) 0x4) +#define DCR_TXRESET ((unsigned short) 0x8)Are those casts neccessary?
No, removed.
Quoted 5 lines
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+/* I/O ports and bit definitions for version 2 of the hardware */ + +struct MEMCCR { +unsigned short PCCOR;/* Configuration Option Register */ +unsigned short PCCSR;/* Configuration and Status Register */
Quoted 8 lines
drivers/char/pcmcia/ipwireless/hardware.c line 215
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+unsigned short PCPRR ;/* Pin Replacemant Register */ +unsigned short PCSCR ;/* Socket and Copy Register */ +unsigned short PCESR ;/* Extendend Status Register */ +unsigned short PCIOB ;/* I/O Base Register */ +};Could we get better names? PCIOB is cryptic,
pci_io_baseis pretty good.
Ok, changed to eg. reg_config_and_status.
Quoted 7 lines
drivers/char/pcmcia/ipwireless/hardware.c line 333
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +5
-0+/* Signals from DTE */ +enum ComCtrl_DTESignal { + ComCtrl_RTS =0 , + ComCtrl_DTR =1 +};CamelCaseIsEvil.
Converted to underscores.
Quoted 29 lines
Quoted 14 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +13
-0+static irqreturn_t ipwireless_handle_v1_interrupt (int irq, +struct ipw_hardware *hw) +{ +unsigned short irqn; +unsigned short ack; + + irqn =inw (hw->base_port +IOIR ); + +/* Check if card is present */ +if (irqn == (unsigned short )0xFFFF ) { +if (++hw->bad_interrupt_count >=100 ) { +/* +* It is necessary to disable the interrupt at this drivers/char/pcmcia/ipwireless/hardware.c line 1097
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+* point, or the kernel hangs, interrupting repeatedly +* forever. +*/ + hw->irq = irq; + hw->removed =1 ; +disable_irq_nosync (irq); + printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME + ": Mr. Fluffy is not happy!\n"); + } +return IRQ_HANDLED ;Not sure how this is supposed to work. If you assume unshared interrupts, it should be possible to return something and make core care.
Quoted 5 lines
If you are assuming shared interrupts, either you should disable on first
0xFFFF(are you sure cast is needed, btw?), or not at all, because it could be the other device sedning you 100 of those......so which one is it?
Shared. It'll check if device has interrupt pending, else exit.
Quoted 1 line
Is some locking needed around *hw?
Some items are set during initial phase and read only afterwards. This don't need to be protected. Nevetheless, I've found some missing locking around tx_ready and rx_ready which might cause bugs (eg. hangs).
Quoted 15 lines
drivers/char/pcmcia/ipwireless/hardware.c line 1324
Quoted 13 lines
+int ipwireless_send_packet(struct
ipw_hardware*hw, unsigned intchannel_idx, + unsigned char *data, unsigned int length,drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+void (*callback) (void *cb,unsigned int length), + void *callback_data) +{ + struct ipw_tx_packet *packet; + + packet =alloc_data_packet (length, + (unsigned char ) (channel_idx +1 ), +TL_PROTOCOLID_COM_DATA ); +if (!packet) +return -1 ;
-ENOMEMwould be more usual calling convention.
Done.
Quoted 7 lines
drivers/char/pcmcia/ipwireless/hardware.c line 1392
Quoted 5 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +4
-0+struct ipw_setup_get_version_query_packet { +struct ipw_tx_packet header; +struct TlSetupGetVersionQry body; +};MoreEvilCamelCase.
Converted.
Quoted 5 lines
Quoted 5 lines
drivers/char/pcmcia/ipwireless/main.c new file +5
-0+static int config_ipwireless (struct ipw_dev *ipw) +{ +struct pcmcia_device *link = ipw->link; +int ret; +config_info_t conf;
Quoted 8 lines
drivers/char/pcmcia/ipwireless/main.c line 94
Quoted 6 lines
drivers/char/pcmcia/ipwireless/main.c new file +6
-0+tuple_t tuple; +unsigned short buf[64 ]; +cisparse_t parse; +unsigned short cor_value; +win_req_t reqAM; +win_req_t reqCM;Hiding structs BehindTypedefsIsEvil.
Unfortunatelly PCMCIA subsystem is full of these and all drivers use them. I'll stay consistent for now.
Updated patch v4 will follow.
dave
Hi!
Quoted 28 lines
Quoted 28 lines
Quoted 13 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +13
-0+static irqreturn_t ipwireless_handle_v1_interrupt (int irq, +struct ipw_hardware *hw) +{ +unsigned short irqn; +unsigned short ack; + + irqn =inw (hw->base_port +IOIR ); + +/* Check if card is present */ +if (irqn == (unsigned short )0xFFFF ) { +if (++hw->bad_interrupt_count >=100 ) { +/* +* It is necessary to disable the interrupt at this drivers/char/pcmcia/ipwireless/hardware.c line 1097
Quoted 10 lines
drivers/char/pcmcia/ipwireless/hardware.c new file +10
-0+* point, or the kernel hangs, interrupting repeatedly +* forever. +*/ + hw->irq = irq; + hw->removed =1 ; +disable_irq_nosync (irq); + printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME + ": Mr. Fluffy is not happy!\n"); + } +return IRQ_HANDLED ;Not sure how this is supposed to work. If you assume unshared interrupts, it should be possible to return something and make core care.
Quoted 7 lines
Quoted 5 lines
If you are assuming shared interrupts, either you should disable on first
0xFFFF(are you sure cast is needed, btw?), or not at all, because it could be the other device sedning you 100 of those......so which one is it?
Shared. It'll check if device has interrupt pending, else exit.
can you remove bad_interrupt_count? It seems very random in presence of shared interrupt.
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/char/pcmcia/ipwireless/main.c new file +5
-0+static int config_ipwireless (struct ipw_dev *ipw) +{ +struct pcmcia_device *link = ipw->link; +int ret; +config_info_t conf;Quoted 8 lines
drivers/char/pcmcia/ipwireless/main.c line 94
Quoted 6 lines
drivers/char/pcmcia/ipwireless/main.c new file +6
-0+tuple_t tuple; +unsigned short buf[64 ]; +cisparse_t parse; +unsigned short cor_value; +win_req_t reqAM; +win_req_t reqCM;Hiding structs BehindTypedefsIsEvil.
Quoted 2 lines
Unfortunatelly PCMCIA subsystem is full of these and all drivers use them. I'll stay consistent for now.
Sorry if they were not yours.
Quoted 1 line
Updated patch v4 will follow.
Thanks!
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html