Update at76_usb to the start of mac80211 port
cover Update at76_usb to the start of mac80211 port
This brings at76_usb to the point where Kalle Valo started mac80211 conversion.
Further patches that bring the driver to version 0.16 will be submitted once it's clear how the conflicts with Kalle's changes can be resolved (i.e. which patch goes first and which must be rebased).
Signature · 2 lines
Regards, Pavel Roskin
PATCH 1/35 Protect at76_get_op_mode() and at76_get_mib() against short reads
Don't rely on usb_control_msg() returning -EPIPE in absence of working firmware. In some cases, no error is returned, but no data is read.
Interpret short reads as an error, return -EIO.
---
drivers/net/wireless/at76_usb.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)
drivers/net/wireless/at76_usb.c +13 -5
@@ -578,7 +578,10 @@ static int at76_get_op_mode(struct usb_device *udev) USB_CTRL_GET_TIMEOUT);if (ret <0 )return ret; -return op_mode; +else if (ret <1 ) +return -EIO ; +else +return op_mode; }/* Load a block of the second ("external") part of the firmware */
@@ -695,10 +698,15 @@ static struct reg_domain const *at76_get_reg_domain(u16 code)static inline int at76_get_mib (struct usb_device *udev,u16 mib,void *buf,int buf_size) { -return usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 , -USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE , mib <<8 ,0 , buf, buf_size, -USB_CTRL_GET_TIMEOUT ); +int ret; + + ret =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 , +USB_TYPE_VENDOR |USB_DIR_IN | +USB_RECIP_INTERFACE , mib <<8 ,0 , buf, buf_size, +USB_CTRL_GET_TIMEOUT ); +if (ret >=0 && ret != buf_size) +return -EIO ; +return ret; }/* Return positive number for status, negative for an error */
PATCH 2/35 Use existing macros to find bulk in and bulk out endpoints
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
drivers/net/wireless/at76_usb.c +2 -7
@@ -2045,10 +2045,7 @@ static int at76_alloc_urbs(struct at76_priv *priv, __func__, i, endpoint->bEndpointAddress, endpoint->bmAttributes); -if ((endpoint->bEndpointAddress &0x80 ) && - ((endpoint->bmAttributes &3 ) ==0x02 )) { -/* we found a bulk in endpoint */ - +if (usb_endpoint_is_bulk_in (endpoint)) { priv->read_urb =usb_alloc_urb (0 ,GFP_KERNEL );if (!priv->read_urb) {err ("No free urbs available" );
@@ -2058,9 +2055,7 @@ static int at76_alloc_urbs(struct at76_priv *priv,usb_rcvbulkpipe (udev, endpoint->bEndpointAddress); } -if (((endpoint->bEndpointAddress &0x80 ) ==0x00 ) && - ((endpoint->bmAttributes &3 ) ==0x02 )) { -/* we found a bulk out endpoint */ +if (usb_endpoint_is_bulk_out (endpoint)) { priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL );if (!priv->write_urb) {err ("no free urbs available" );
PATCH 3/35 Rewrite at76_alloc_urbs() in a more linear fashion
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 66 +++++++++++++++++++++------------------ 1 files changed, 35 insertions(+), 31 deletions(-)
drivers/net/wireless/at76_usb.c +35 -31
@@ -2026,8 +2026,7 @@ static void at76_delete_device(struct at76_priv *priv)static int at76_alloc_urbs (struct at76_priv *priv,struct usb_interface *interface) { -struct usb_endpoint_descriptor *endpoint; -struct usb_device *udev = priv->udev; +struct usb_endpoint_descriptor *endpoint, *ep_in, *ep_out;int i;int buffer_size;struct usb_host_interface *iface_desc;
@@ -2037,41 +2036,46 @@ static int at76_alloc_urbs(struct at76_priv *priv,at76_dbg (DBG_URB ,"%s: NumEndpoints %d " , __func__, interface->altsetting[0 ].desc.bNumEndpoints); + ep_in =NULL ; + ep_out =NULL ; iface_desc = interface->cur_altsetting;for (i =0 ; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = &iface_desc->endpoint[i].desc;at76_dbg (DBG_URB ,"%s: %d. endpoint: addr 0x%x attr 0x%x" , - __func__, - i, endpoint->bEndpointAddress, endpoint->bmAttributes); - -if (usb_endpoint_is_bulk_in (endpoint)) { - priv->read_urb =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!priv->read_urb) { -err ("No free urbs available" ); -return -ENOMEM ; - } - priv->rx_bulk_pipe = -usb_rcvbulkpipe (udev, endpoint->bEndpointAddress); - } + __func__, i, endpoint->bEndpointAddress, + endpoint->bmAttributes); -if (usb_endpoint_is_bulk_out (endpoint)) { - priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!priv->write_urb) { -err ("no free urbs available" ); -return -ENOMEM ; - } - buffer_size =sizeof (struct at76_tx_buffer ) + -MAX_PADDING_SIZE ; - priv->tx_bulk_pipe = -usb_sndbulkpipe (udev, endpoint->bEndpointAddress); - priv->bulk_out_buffer = -kmalloc (buffer_size,GFP_KERNEL ); -if (!priv->bulk_out_buffer) { -err ("couldn't allocate bulk_out_buffer" ); -return -ENOMEM ; - } - } +if (!ep_in &&usb_endpoint_is_bulk_in (endpoint)) + ep_in = endpoint; + +if (!ep_out &&usb_endpoint_is_bulk_out (endpoint)) + ep_out = endpoint; + } + +if (!ep_in || !ep_out) { + printk(KERN_ERR DRIVER_NAME ": bulk endpoints missing\n"); +return -ENXIO ; + } + + priv->rx_bulk_pipe = +usb_rcvbulkpipe (priv->udev, ep_in->bEndpointAddress); + priv->tx_bulk_pipe = +usb_sndbulkpipe (priv->udev, ep_out->bEndpointAddress); + + priv->read_urb =usb_alloc_urb (0 ,GFP_KERNEL ); + priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!priv->read_urb || !priv->write_urb) { + printk(KERN_ERR DRIVER_NAME ": cannot allocate URB\n"); +return -ENOMEM ; + } + + buffer_size =sizeof (struct at76_tx_buffer ) +MAX_PADDING_SIZE ; + priv->bulk_out_buffer =kmalloc (buffer_size,GFP_KERNEL ); +if (!priv->bulk_out_buffer) { + printk(KERN_ERR DRIVER_NAME + ": cannot allocate output buffer\n"); +return -ENOMEM ; }at76_dbg (DBG_PROC_ENTRY ,"%s: EXIT" , __func__);
PATCH 4/35 Avoid overuse of NULL
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 76 +++++++++++++++++++-------------------- 1 files changed, 37 insertions(+), 39 deletions(-)
drivers/net/wireless/at76_usb.c +37 -39
@@ -313,7 +313,7 @@ static int at76_usbdfu_download(struct usb_device *udev, u8 *dfu_buffer, } block =kmalloc (DFU_PACKETSIZE ,GFP_KERNEL ); -if (block ==NULL ) +if (!block)return -ENOMEM ; do {
@@ -734,11 +734,11 @@ static int at76_download_external_fw(struct usb_device *udev, u8 *buf, int size)if (size <0 )return -EINVAL ; -if ((size >0 ) && (buf ==NULL )) +if (size >0 && !buf)return -EFAULT ; block =kmalloc (EXT_FW_BLOCK_SIZE ,GFP_KERNEL ); -if (block ==NULL ) +if (!block)return -ENOMEM ;at76_dbg (DBG_DEVSTART ,"downloading external firmware" );
@@ -1552,7 +1552,7 @@ static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr) {struct at76_req_join join; -BUG_ON (ptr ==NULL ); +BUG_ON (!ptr);memset (&join,0 ,sizeof (struct at76_req_join ));memcpy (join.bssid, ptr->bssid,ETH_ALEN );
@@ -1739,8 +1739,8 @@ static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,int buf_len = (seq_nr !=3 ?AUTH_FRAME_SIZE :AUTH_FRAME_SIZE +1 +1 + challenge->len); -BUG_ON (bss ==NULL ); -BUG_ON (seq_nr ==3 && challenge ==NULL ); +BUG_ON (!bss); +BUG_ON (seq_nr ==3 && !challenge); tx_buffer =kmalloc (buf_len +MAX_PADDING_SIZE ,GFP_ATOMIC );if (!tx_buffer)return -ENOMEM ;
@@ -1791,7 +1791,7 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)int len;u16 capa; -BUG_ON (bss ==NULL ); +BUG_ON (!bss); tx_buffer =kmalloc (ASSOCREQ_MAX_SIZE +MAX_PADDING_SIZE ,GFP_ATOMIC );if (!tx_buffer)
@@ -1926,7 +1926,7 @@ static void at76_work_assoc_done(struct work_struct *work)mutex_lock (&priv->mtx);WARN_ON (priv->mac_state !=MAC_ASSOC ); -WARN_ON (priv->curr_bss ==NULL ); +WARN_ON (!priv->curr_bss);if (priv->mac_state !=MAC_ASSOC || !priv->curr_bss) goto exit;
@@ -1983,21 +1983,20 @@ static void at76_delete_device(struct at76_priv *priv)/* assuming we used keventd, it must quiesce too */ flush_scheduled_work (); -if (priv->bulk_out_buffer !=NULL ) -kfree (priv->bulk_out_buffer); +kfree (priv->bulk_out_buffer); -if (priv->write_urb !=NULL ) { +if (priv->write_urb) {usb_kill_urb (priv->write_urb);usb_free_urb (priv->write_urb); } -if (priv->read_urb !=NULL ) { +if (priv->read_urb) {usb_kill_urb (priv->read_urb);usb_free_urb (priv->read_urb); }at76_dbg (DBG_PROC_ENTRY ,"%s: unlinked urbs" , __func__); -if (priv->rx_skb !=NULL ) +if (priv->rx_skb)kfree_skb (priv->rx_skb);at76_free_bss_list (priv);
@@ -2011,7 +2010,7 @@ static void at76_delete_device(struct at76_priv *priv)at76_iwevent_bss_disconnect (priv->netdev);for (i =0 ; i <NR_RX_DATA_BUF ; i++) -if (priv->rx_data[i].skb !=NULL ) { +if (priv->rx_data[i].skb) {dev_kfree_skb (priv->rx_data[i].skb); priv->rx_data[i].skb =NULL ; }
@@ -2475,7 +2474,6 @@ static int at76_iw_handler_set_scan(struct net_device *netdev,struct at76_priv *priv =netdev_priv (netdev);unsigned long flags;int ret =0 ; -struct iw_scan_req *req =NULL ;at76_dbg (DBG_IOCTL ,"%s: SIOCSIWSCAN" , netdev->name);
@@ -2517,7 +2515,7 @@ static int at76_iw_handler_set_scan(struct net_device *netdev,/* Try to do passive or active scan if WE asks as. */ if (wrqu->data.length && wrqu->data.length ==sizeof (struct iw_scan_req )) { - req = (struct iw_scan_req *)extra; +struct iw_scan_req *req = (struct iw_scan_req *)extra;if (req->scan_type ==IW_SCAN_TYPE_PASSIVE ) priv->scan_mode =SCAN_TYPE_PASSIVE ;
@@ -3556,14 +3554,14 @@ static int at76_submit_read_urb(struct at76_priv *priv)int size;struct sk_buff *skb = priv->rx_skb; -if (priv->read_urb ==NULL ) { +if (!priv->read_urb) {err ("%s: priv->read_urb is NULL" , __func__);return -EFAULT ; } -if (skb ==NULL ) { +if (!skb) { skb =dev_alloc_skb (sizeof (struct at76_rx_buffer )); -if (skb ==NULL ) { +if (!skb) {err ("%s: unable to allocate rx skbuff." , priv->netdev->name); ret = -ENOMEM ;
@@ -3977,7 +3975,7 @@ static struct bss_info *at76_match_bss(struct at76_priv *priv,struct bss_info *ptr =NULL ;struct list_head *curr; - curr = last !=NULL ? last->list.next : priv->bss_list.next; + curr = last ? last->list.next : priv->bss_list.next;while (curr != &priv->bss_list) { ptr = list_entry(curr, struct bss_info, list); if (at76_match_essid(priv, ptr) && at76_match_mode(priv, ptr)
@@ -4015,7 +4013,7 @@ static void at76_work_join(struct work_struct *work) priv->curr_bss =at76_match_bss (priv, priv->curr_bss);spin_unlock_irqrestore (&priv->bss_list_spinlock, flags); -if (priv->curr_bss ==NULL ) { +if (!priv->curr_bss) {/* here we haven't found a matching (i)bss ... */ if (priv->iw_mode ==IW_MODE_ADHOC ) {at76_set_mac_state (priv,MAC_OWN_IBSS );
@@ -4545,7 +4543,7 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,return ; } -BUG_ON (priv->curr_bss ==NULL ); +BUG_ON (!priv->curr_bss);if (status ==WLAN_STATUS_SUCCESS ) {struct bss_info *ptr = priv->curr_bss;
@@ -4581,7 +4579,7 @@ static void at76_rx_mgmt_disassoc(struct at76_priv *priv,/* We are not connected, ignore */ if (priv->mac_state ==MAC_SCANNING || priv->mac_state ==MAC_INIT - || priv->curr_bss ==NULL ) + || !priv->curr_bss)return ;/* Not our BSSID, ignore */
@@ -4642,7 +4640,7 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv,return ; } -BUG_ON (priv->curr_bss ==NULL ); +BUG_ON (!priv->curr_bss);/* Not our BSSID or not for our STA, ignore */ if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid)
@@ -4696,7 +4694,7 @@ static void at76_rx_mgmt_deauth(struct at76_priv *priv,return ; } -BUG_ON (priv->curr_bss ==NULL ); +BUG_ON (!priv->curr_bss);/* Not our BSSID, ignore */ if (compare_ether_addr (mgmt->addr3, priv->curr_bss->bssid))
@@ -4741,7 +4739,7 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,if (priv->mac_state ==MAC_CONNECTED ) {/* in state MAC_CONNECTED we use the mgmt_timer to control the beacon of the BSS */ -BUG_ON (priv->curr_bss ==NULL ); +BUG_ON (!priv->curr_bss);if (!compare_ether_addr (priv->curr_bss->bssid, mgmt->addr3)) {/* We got our AP's beacon, defer the timeout handler.
@@ -4770,7 +4768,7 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv, } } -if (match ==NULL ) { +if (!match) {/* BSS not in the list - append it */ match =kmalloc (sizeof (struct bss_info ),GFP_ATOMIC );if (!match) {
@@ -4977,10 +4975,10 @@ static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)only read link quality info from management packets. Atmel driver actually averages the present, and previous values, we just present the raw value at the moment - TJS */ -if (priv->iw_mode ==IW_MODE_ADHOC || - (priv->curr_bss !=NULL - && !compare_ether_addr (mgmt->addr3, - priv->curr_bss->bssid))) +if (priv->iw_mode ==IW_MODE_ADHOC + || (priv->curr_bss + && !compare_ether_addr (mgmt->addr3, + priv->curr_bss->bssid)))at76_update_wstats (priv, buf); }
@@ -5183,7 +5181,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv) bptr = priv->rx_data; optr =NULL ;for (i =0 ; i <NR_RX_DATA_BUF ; i++, bptr++) { -if (bptr->skb ==NULL ) { +if (!bptr->skb) { optr = bptr; oldest =0UL ;continue ;
@@ -5192,7 +5190,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)if (!compare_ether_addr (i802_11_hdr->addr2, bptr->sender))break ; -if (optr ==NULL ) { +if (!optr) { optr = bptr; oldest = bptr->last_rx; }else if (bptr->last_rx < oldest)
@@ -5284,8 +5282,8 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)return NULL ; } -BUG_ON (optr ==NULL ); -if (optr->skb !=NULL ) { +BUG_ON (!optr); +if (optr->skb) {/* swap the skb's */ skb = optr->skb; optr->skb = priv->rx_skb;
@@ -5331,7 +5329,7 @@ static void at76_rx_data(struct at76_priv *priv)at76_dbg_dumpbuf ("packet" , skb->data +AT76_RX_HDRLEN , length); skb =at76_check_for_rx_frags (priv); -if (skb ==NULL ) +if (!skb)return ;/* Atmel header and the FCS are already removed */
@@ -5383,7 +5381,7 @@ static void at76_rx_monitor_mode(struct at76_priv *priv) skblen =sizeof (struct at76_rx_radiotap ) + length; skb =dev_alloc_skb (skblen); -if (skb ==NULL ) { +if (!skb) {err ("%s: MONITOR MODE: dev_alloc_skb for radiotap header " "returned NULL" , priv->netdev->name);return ;
@@ -5522,12 +5520,12 @@ exit:static struct at76_priv *at76_alloc_new_device (struct usb_device *udev) {struct net_device *netdev; -struct at76_priv *priv =NULL ; +struct at76_priv *priv;int i;/* allocate memory for our device state and initialize it */ netdev =alloc_etherdev (sizeof (struct at76_priv )); -if (netdev ==NULL ) { +if (!netdev) {err ("out of memory" );return NULL ; }
PATCH 5/35 Add myself to the author list
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/wireless/at76_usb.c +1 -0
@@ -5829,5 +5829,6 @@ MODULE_AUTHOR("Joerg Albert <[email protected]>");MODULE_AUTHOR ("Alex <[email protected]>" );MODULE_AUTHOR ("Nick Jones" );MODULE_AUTHOR ("Balint Seeber <[email protected]>" ); +MODULE_AUTHOR ("Pavel Roskin <[email protected]>" );MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" );
PATCH 6/35 Move (de)initialization functions closer to the end of file
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 496 ++++++++++++++++++++------------------- 1 files changed, 248 insertions(+), 248 deletions(-)
drivers/net/wireless/at76_usb.c +248 -248
@@ -1966,122 +1966,6 @@ exit:mutex_unlock (&priv->mtx); } -static void at76_delete_device (struct at76_priv *priv) -{ -int i; - -at76_dbg (DBG_PROC_ENTRY ,"%s: ENTER" , __func__); - -/* The device is gone, don't bother turning it off */ - priv->device_unplugged =1 ; - -tasklet_kill (&priv->rx_tasklet); - -if (priv->netdev_registered) -unregister_netdev (priv->netdev); - -/* assuming we used keventd, it must quiesce too */ -flush_scheduled_work (); - -kfree (priv->bulk_out_buffer); - -if (priv->write_urb) { -usb_kill_urb (priv->write_urb); -usb_free_urb (priv->write_urb); - } -if (priv->read_urb) { -usb_kill_urb (priv->read_urb); -usb_free_urb (priv->read_urb); - } - -at76_dbg (DBG_PROC_ENTRY ,"%s: unlinked urbs" , __func__); - -if (priv->rx_skb) -kfree_skb (priv->rx_skb); - -at76_free_bss_list (priv); -del_timer_sync (&priv->bss_list_timer); -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc); - -if (priv->mac_state ==MAC_CONNECTED ) -at76_iwevent_bss_disconnect (priv->netdev); - -for (i =0 ; i <NR_RX_DATA_BUF ; i++) -if (priv->rx_data[i].skb) { -dev_kfree_skb (priv->rx_data[i].skb); - priv->rx_data[i].skb =NULL ; - } -usb_put_dev (priv->udev); - -at76_dbg (DBG_PROC_ENTRY ,"%s: before freeing priv/netdev" , __func__); -free_netdev (priv->netdev);/* priv is in netdev */ - -at76_dbg (DBG_PROC_ENTRY ,"%s: EXIT" , __func__); -} - -static int at76_alloc_urbs (struct at76_priv *priv, -struct usb_interface *interface) -{ -struct usb_endpoint_descriptor *endpoint, *ep_in, *ep_out; -int i; -int buffer_size; -struct usb_host_interface *iface_desc; - -at76_dbg (DBG_PROC_ENTRY ,"%s: ENTER" , __func__); - -at76_dbg (DBG_URB ,"%s: NumEndpoints %d " , __func__, - interface->altsetting[0 ].desc.bNumEndpoints); - - ep_in =NULL ; - ep_out =NULL ; - iface_desc = interface->cur_altsetting; -for (i =0 ; i < iface_desc->desc.bNumEndpoints; i++) { - endpoint = &iface_desc->endpoint[i].desc; - -at76_dbg (DBG_URB ,"%s: %d. endpoint: addr 0x%x attr 0x%x" , - __func__, i, endpoint->bEndpointAddress, - endpoint->bmAttributes); - -if (!ep_in &&usb_endpoint_is_bulk_in (endpoint)) - ep_in = endpoint; - -if (!ep_out &&usb_endpoint_is_bulk_out (endpoint)) - ep_out = endpoint; - } - -if (!ep_in || !ep_out) { - printk(KERN_ERR DRIVER_NAME ": bulk endpoints missing\n"); -return -ENXIO ; - } - - priv->rx_bulk_pipe = -usb_rcvbulkpipe (priv->udev, ep_in->bEndpointAddress); - priv->tx_bulk_pipe = -usb_sndbulkpipe (priv->udev, ep_out->bEndpointAddress); - - priv->read_urb =usb_alloc_urb (0 ,GFP_KERNEL ); - priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!priv->read_urb || !priv->write_urb) { - printk(KERN_ERR DRIVER_NAME ": cannot allocate URB\n"); -return -ENOMEM ; - } - - buffer_size =sizeof (struct at76_tx_buffer ) +MAX_PADDING_SIZE ; - priv->bulk_out_buffer =kmalloc (buffer_size,GFP_KERNEL ); -if (!priv->bulk_out_buffer) { - printk(KERN_ERR DRIVER_NAME - ": cannot allocate output buffer\n"); -return -ENOMEM ; - } - -at76_dbg (DBG_PROC_ENTRY ,"%s: EXIT" , __func__); - -return 0 ; -} -/* We only store the new mac address in netdev struct, it gets set when the netdev is opened. */ static int at76_set_mac_address (struct net_device *netdev,void *addr)
@@ -3720,91 +3604,6 @@ static struct ethtool_ops at76_ethtool_ops = { .get_link = at76_ethtool_get_link, }; -/* Register network device and initialize the hardware */ -static int at76_init_new_device (struct at76_priv *priv, -struct usb_interface *interface) -{ -struct net_device *netdev = priv->netdev; -int ret; - -/* set up the endpoint information */ -/* check out the endpoints */ - -at76_dbg (DBG_DEVSTART ,"USB interface: %d endpoints" , - interface->cur_altsetting->desc.bNumEndpoints); - - ret =at76_alloc_urbs (priv, interface); -if (ret <0 ) - goto exit; - -/* MAC address */ - ret =at76_get_hw_config (priv); -if (ret <0 ) { -err ("could not get MAC address" ); - goto exit; - } - - priv->domain =at76_get_reg_domain (priv->regulatory_domain); -/* init. netdev->dev_addr */ -memcpy (netdev->dev_addr, priv->mac_addr,ETH_ALEN ); - -/* initializing */ - priv->international_roaming =IR_OFF ; - priv->channel =DEF_CHANNEL ; - priv->iw_mode =IW_MODE_INFRA ; -memset (priv->essid,0 ,IW_ESSID_MAX_SIZE ); - priv->rts_threshold =DEF_RTS_THRESHOLD ; - priv->frag_threshold =DEF_FRAG_THRESHOLD ; - priv->short_retry_limit =DEF_SHORT_RETRY_LIMIT ; - priv->txrate =TX_RATE_AUTO ; - priv->preamble_type =PREAMBLE_TYPE_LONG ; - priv->beacon_period =100 ; - priv->beacons_last_qual =jiffies_to_msecs (jiffies); - priv->auth_mode =WLAN_AUTH_OPEN ; - priv->scan_min_time =DEF_SCAN_MIN_TIME ; - priv->scan_max_time =DEF_SCAN_MAX_TIME ; - priv->scan_mode =SCAN_TYPE_ACTIVE ; - - netdev->flags &= ~IFF_MULTICAST ;/* not yet or never */ - netdev->open = at76_open; - netdev->stop = at76_stop; - netdev->get_stats = at76_get_stats; - netdev->ethtool_ops = &at76_ethtool_ops; - -/* Add pointers to enable iwspy support. */ - priv->wireless_data.spy_data = &priv->spy_data; - netdev->wireless_data = &priv->wireless_data; - - netdev->hard_start_xmit = at76_tx; - netdev->tx_timeout = at76_tx_timeout; - netdev->watchdog_timeo =2 *HZ ; - netdev->wireless_handlers = &at76_handler_def; - netdev->set_multicast_list = at76_set_multicast; - netdev->set_mac_address = at76_set_mac_address; - - ret =register_netdev (priv->netdev); -if (ret) { -err ("unable to register netdevice %s (status %d)!" , - priv->netdev->name, ret); - goto exit; - } - priv->netdev_registered =1 ; - -printk (KERN_INFO "%s: MAC address %s\n" , netdev->name, -mac2str (priv->mac_addr)); -printk (KERN_INFO "%s: firmware version %d.%d.%d-%d\n" , netdev->name, - priv->fw_version.major, priv->fw_version.minor, - priv->fw_version.patch, priv->fw_version.build); -printk (KERN_INFO "%s: regulatory domain %s (id %d)\n" , netdev->name, - priv->domain->name, priv->regulatory_domain); - -/* we let this timer run the whole time this driver instance lives */ -mod_timer (&priv->bss_list_timer, jiffies +BSS_LIST_TIMEOUT ); - -exit: -return ret; -} -/* Download external firmware */ static int at76_load_external_fw (struct usb_device *udev,struct fwentry *fwe) {
@@ -5516,6 +5315,76 @@ exit:at76_submit_read_urb (priv); } +/* Load firmware into kernel memory and parse it */ +static struct fwentry *at76_load_firmware (struct usb_device *udev, +enum board_type board_type) +{ +int ret; +char *str; +struct at76_fw_header *fwh; +struct fwentry *fwe = &firmwares[board_type]; + +mutex_lock (&fw_mutex); + +if (fwe->loaded) { +at76_dbg (DBG_FW ,"re-using previously loaded fw" ); + goto exit; + } + +at76_dbg (DBG_FW ,"downloading firmware %s" , fwe->fwname); + ret =request_firmware (&fwe->fw, fwe->fwname, &udev->dev); +if (ret <0 ) { +err ("firmware %s not found." , fwe->fwname); +err ("You may need to download the firmware from " +"http://developer.berlios.de/projects/at76c503a/" ); + goto exit; + } + +at76_dbg (DBG_FW ,"got it." ); + fwh = (struct at76_fw_header *)(fwe->fw->data); + +if (fwe->fw->size <=sizeof (*fwh)) { +err ("firmware is too short (0x%zx)" , fwe->fw->size); + goto exit; + } + +/* CRC currently not checked */ + fwe->board_type =le32_to_cpu (fwh->board_type); +if (fwe->board_type != board_type) { +err ("board type mismatch, requested %u, got %u" , board_type, + fwe->board_type); + goto exit; + } + + fwe->fw_version.major = fwh->major; + fwe->fw_version.minor = fwh->minor; + fwe->fw_version.patch = fwh->patch; + fwe->fw_version.build = fwh->build; + + str = (char *)fwh +le32_to_cpu (fwh->str_offset); + fwe->intfw = (u8 *)fwh +le32_to_cpu (fwh->int_fw_offset); + fwe->intfw_size =le32_to_cpu (fwh->int_fw_len); + fwe->extfw = (u8 *)fwh +le32_to_cpu (fwh->ext_fw_offset); + fwe->extfw_size =le32_to_cpu (fwh->ext_fw_len); + + fwe->loaded =1 ; + +at76_dbg (DBG_DEVSTART ,"firmware board %u version %u.%u.%u-%u " +"(int %d:%d, ext %d:%d)" , board_type, + fwh->major, fwh->minor, fwh->patch, fwh->build, +le32_to_cpu (fwh->int_fw_offset),le32_to_cpu (fwh->int_fw_len), +le32_to_cpu (fwh->ext_fw_offset),le32_to_cpu (fwh->ext_fw_len)); +at76_dbg (DBG_DEVSTART ,"firmware id %s" , str); + +exit: +mutex_unlock (&fw_mutex); + +if (fwe->loaded) +return fwe; +else +return NULL ; +} +/* Allocate network device and initialize private data */ static struct at76_priv *at76_alloc_new_device (struct usb_device *udev) {
@@ -5578,74 +5447,205 @@ static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)return priv; } -/* Load firmware into kernel memory and parse it */ -static struct fwentry *at76_load_firmware (struct usb_device *udev, -enum board_type board_type) +static int at76_alloc_urbs (struct at76_priv *priv, +struct usb_interface *interface) +{ +struct usb_endpoint_descriptor *endpoint, *ep_in, *ep_out; +int i; +int buffer_size; +struct usb_host_interface *iface_desc; + +at76_dbg (DBG_PROC_ENTRY ,"%s: ENTER" , __func__); + +at76_dbg (DBG_URB ,"%s: NumEndpoints %d " , __func__, + interface->altsetting[0 ].desc.bNumEndpoints); + + ep_in =NULL ; + ep_out =NULL ; + iface_desc = interface->cur_altsetting; +for (i =0 ; i < iface_desc->desc.bNumEndpoints; i++) { + endpoint = &iface_desc->endpoint[i].desc; + +at76_dbg (DBG_URB ,"%s: %d. endpoint: addr 0x%x attr 0x%x" , + __func__, i, endpoint->bEndpointAddress, + endpoint->bmAttributes); + +if (!ep_in &&usb_endpoint_is_bulk_in (endpoint)) + ep_in = endpoint; + +if (!ep_out &&usb_endpoint_is_bulk_out (endpoint)) + ep_out = endpoint; + } + +if (!ep_in || !ep_out) { + printk(KERN_ERR DRIVER_NAME ": bulk endpoints missing\n"); +return -ENXIO ; + } + + priv->rx_bulk_pipe = +usb_rcvbulkpipe (priv->udev, ep_in->bEndpointAddress); + priv->tx_bulk_pipe = +usb_sndbulkpipe (priv->udev, ep_out->bEndpointAddress); + + priv->read_urb =usb_alloc_urb (0 ,GFP_KERNEL ); + priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!priv->read_urb || !priv->write_urb) { + printk(KERN_ERR DRIVER_NAME ": cannot allocate URB\n"); +return -ENOMEM ; + } + + buffer_size =sizeof (struct at76_tx_buffer ) +MAX_PADDING_SIZE ; + priv->bulk_out_buffer =kmalloc (buffer_size,GFP_KERNEL ); +if (!priv->bulk_out_buffer) { + printk(KERN_ERR DRIVER_NAME + ": cannot allocate output buffer\n"); +return -ENOMEM ; + } + +at76_dbg (DBG_PROC_ENTRY ,"%s: EXIT" , __func__); + +return 0 ; +} + +/* Register network device and initialize the hardware */ +static int at76_init_new_device (struct at76_priv *priv, +struct usb_interface *interface) { +struct net_device *netdev = priv->netdev;int ret; -char *str; -struct at76_fw_header *fwh; -struct fwentry *fwe = &firmwares[board_type]; -mutex_lock (&fw_mutex); +/* set up the endpoint information */ +/* check out the endpoints */ -if (fwe->loaded) { -at76_dbg (DBG_FW ,"re-using previously loaded fw" ); +at76_dbg (DBG_DEVSTART ,"USB interface: %d endpoints" , + interface->cur_altsetting->desc.bNumEndpoints); + + ret =at76_alloc_urbs (priv, interface); +if (ret <0 ) goto exit; - } -at76_dbg (DBG_FW ,"downloading firmware %s" , fwe->fwname); - ret =request_firmware (&fwe->fw, fwe->fwname, &udev->dev); +/* MAC address */ + ret =at76_get_hw_config (priv);if (ret <0 ) { -err ("firmware %s not found." , fwe->fwname); -err ("You may need to download the firmware from " -"http://developer.berlios.de/projects/at76c503a/" ); +err ("could not get MAC address" ); goto exit; } -at76_dbg (DBG_FW ,"got it." ); - fwh = (struct at76_fw_header *)(fwe->fw->data); + priv->domain =at76_get_reg_domain (priv->regulatory_domain); +/* init. netdev->dev_addr */ +memcpy (netdev->dev_addr, priv->mac_addr,ETH_ALEN ); -if (fwe->fw->size <=sizeof (*fwh)) { -err ("firmware is too short (0x%zx)" , fwe->fw->size); +/* initializing */ + priv->international_roaming =IR_OFF ; + priv->channel =DEF_CHANNEL ; + priv->iw_mode =IW_MODE_INFRA ; +memset (priv->essid,0 ,IW_ESSID_MAX_SIZE ); + priv->rts_threshold =DEF_RTS_THRESHOLD ; + priv->frag_threshold =DEF_FRAG_THRESHOLD ; + priv->short_retry_limit =DEF_SHORT_RETRY_LIMIT ; + priv->txrate =TX_RATE_AUTO ; + priv->preamble_type =PREAMBLE_TYPE_LONG ; + priv->beacon_period =100 ; + priv->beacons_last_qual =jiffies_to_msecs (jiffies); + priv->auth_mode =WLAN_AUTH_OPEN ; + priv->scan_min_time =DEF_SCAN_MIN_TIME ; + priv->scan_max_time =DEF_SCAN_MAX_TIME ; + priv->scan_mode =SCAN_TYPE_ACTIVE ; + + netdev->flags &= ~IFF_MULTICAST ;/* not yet or never */ + netdev->open = at76_open; + netdev->stop = at76_stop; + netdev->get_stats = at76_get_stats; + netdev->ethtool_ops = &at76_ethtool_ops; + +/* Add pointers to enable iwspy support. */ + priv->wireless_data.spy_data = &priv->spy_data; + netdev->wireless_data = &priv->wireless_data; + + netdev->hard_start_xmit = at76_tx; + netdev->tx_timeout = at76_tx_timeout; + netdev->watchdog_timeo =2 *HZ ; + netdev->wireless_handlers = &at76_handler_def; + netdev->set_multicast_list = at76_set_multicast; + netdev->set_mac_address = at76_set_mac_address; + + ret =register_netdev (priv->netdev); +if (ret) { +err ("unable to register netdevice %s (status %d)!" , + priv->netdev->name, ret); goto exit; } + priv->netdev_registered =1 ; -/* CRC currently not checked */ - fwe->board_type =le32_to_cpu (fwh->board_type); -if (fwe->board_type != board_type) { -err ("board type mismatch, requested %u, got %u" , board_type, - fwe->board_type); - goto exit; +printk (KERN_INFO "%s: MAC address %s\n" , netdev->name, +mac2str (priv->mac_addr)); +printk (KERN_INFO "%s: firmware version %d.%d.%d-%d\n" , netdev->name, + priv->fw_version.major, priv->fw_version.minor, + priv->fw_version.patch, priv->fw_version.build); +printk (KERN_INFO "%s: regulatory domain %s (id %d)\n" , netdev->name, + priv->domain->name, priv->regulatory_domain); + +/* we let this timer run the whole time this driver instance lives */ +mod_timer (&priv->bss_list_timer, jiffies +BSS_LIST_TIMEOUT ); + +exit: +return ret; +} + +static void at76_delete_device (struct at76_priv *priv) +{ +int i; + +at76_dbg (DBG_PROC_ENTRY ,"%s: ENTER" , __func__); + +/* The device is gone, don't bother turning it off */ + priv->device_unplugged =1 ; + +tasklet_kill (&priv->rx_tasklet); + +if (priv->netdev_registered) +unregister_netdev (priv->netdev); + +/* assuming we used keventd, it must quiesce too */ +flush_scheduled_work (); + +kfree (priv->bulk_out_buffer); + +if (priv->write_urb) { +usb_kill_urb (priv->write_urb); +usb_free_urb (priv->write_urb); + } +if (priv->read_urb) { +usb_kill_urb (priv->read_urb); +usb_free_urb (priv->read_urb); } - fwe->fw_version.major = fwh->major; - fwe->fw_version.minor = fwh->minor; - fwe->fw_version.patch = fwh->patch; - fwe->fw_version.build = fwh->build; +at76_dbg (DBG_PROC_ENTRY ,"%s: unlinked urbs" , __func__); - str = (char *)fwh +le32_to_cpu (fwh->str_offset); - fwe->intfw = (u8 *)fwh +le32_to_cpu (fwh->int_fw_offset); - fwe->intfw_size =le32_to_cpu (fwh->int_fw_len); - fwe->extfw = (u8 *)fwh +le32_to_cpu (fwh->ext_fw_offset); - fwe->extfw_size =le32_to_cpu (fwh->ext_fw_len); +if (priv->rx_skb) +kfree_skb (priv->rx_skb); - fwe->loaded =1 ; +at76_free_bss_list (priv); +del_timer_sync (&priv->bss_list_timer); +cancel_delayed_work (&priv->dwork_get_scan); +cancel_delayed_work (&priv->dwork_beacon); +cancel_delayed_work (&priv->dwork_auth); +cancel_delayed_work (&priv->dwork_assoc); -at76_dbg (DBG_DEVSTART ,"firmware board %u version %u.%u.%u-%u " -"(int %d:%d, ext %d:%d)" , board_type, - fwh->major, fwh->minor, fwh->patch, fwh->build, -le32_to_cpu (fwh->int_fw_offset),le32_to_cpu (fwh->int_fw_len), -le32_to_cpu (fwh->ext_fw_offset),le32_to_cpu (fwh->ext_fw_len)); -at76_dbg (DBG_DEVSTART ,"firmware id %s" , str); +if (priv->mac_state ==MAC_CONNECTED ) +at76_iwevent_bss_disconnect (priv->netdev); -exit: -mutex_unlock (&fw_mutex); +for (i =0 ; i <NR_RX_DATA_BUF ; i++) +if (priv->rx_data[i].skb) { +dev_kfree_skb (priv->rx_data[i].skb); + priv->rx_data[i].skb =NULL ; + } +usb_put_dev (priv->udev); -if (fwe->loaded) -return fwe; -else -return NULL ; +at76_dbg (DBG_PROC_ENTRY ,"%s: before freeing priv/netdev" , __func__); +free_netdev (priv->netdev);/* priv is in netdev */ + +at76_dbg (DBG_PROC_ENTRY ,"%s: EXIT" , __func__); } static int at76_probe(struct usb_interface *interface,
PATCH 7/35 Don't use shift on numeric constants in usb_control_msg() arguments
In reply to Pavel RoskinWe don't know the meaning of 0x0a02 and 0x0902 in at76_get_hw_cfg() and at76_get_hw_cfg_intersil() respectively, so don't pretend that we do.
---
drivers/net/wireless/at76_usb.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/at76_usb.c +2 -2
@@ -599,7 +599,7 @@ static inline int at76_get_hw_cfg(struct usb_device *udev, {return usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 ,USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE , ((0x0a <<8 ) |0x02 ),0 , +USB_RECIP_INTERFACE ,0x0a02 ,0 , buf, buf_size,USB_CTRL_GET_TIMEOUT ); }
@@ -609,7 +609,7 @@ static inline int at76_get_hw_cfg_intersil(struct usb_device *udev, {return usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 ,USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE , ((0x09 <<8 ) |0x02 ),0 , +USB_RECIP_INTERFACE ,0x0902 ,0 , buf, buf_size,USB_CTRL_GET_TIMEOUT ); }
PATCH 8/35 Merge at76_download_external_fw() into at76_load_external_fw()
In reply to Pavel RoskinSimplify logic to ensure that the last block is empty. Unify DFU_PACKETSIZE and EXT_FW_BLOCK_SIZE into FW_BLOCK_SIZE.
---
drivers/net/wireless/at76_usb.c | 98 ++++++++++++++++----------------------- 1 files changed, 39 insertions(+), 59 deletions(-)
drivers/net/wireless/at76_usb.c +39 -59
@@ -232,7 +232,7 @@ static const char *const mac_states[] = {#define DFU_GETSTATE 5#define DFU_ABORT 6 -#define DFU_PACKETSIZE 1024 +#define FW_BLOCK_SIZE 1024struct dfu_status {unsigned char status;
@@ -312,7 +312,7 @@ static int at76_usbdfu_download(struct usb_device *udev, u8 *dfu_buffer,return -EINVAL ; } - block =kmalloc (DFU_PACKETSIZE ,GFP_KERNEL ); + block =kmalloc (FW_BLOCK_SIZE ,GFP_KERNEL );if (!block)return -ENOMEM ;
@@ -353,7 +353,7 @@ static int at76_usbdfu_download(struct usb_device *udev, u8 *dfu_buffer,case STATE_DFU_IDLE :at76_dbg (DBG_DFU ,"DFU IDLE" ); - dfu_block_bytes =min (dfu_bytes_left,DFU_PACKETSIZE ); + dfu_block_bytes =min (dfu_bytes_left,FW_BLOCK_SIZE ); dfu_bytes_left -= dfu_block_bytes;memcpy (block, dfu_buffer + dfu_buffer_offset, dfu_block_bytes);
@@ -725,54 +725,6 @@ static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd)return stat_buf[5 ]; } -#define EXT_FW_BLOCK_SIZE 1024 -static int at76_download_external_fw (struct usb_device *udev,u8 *buf,int size) -{ -int i =0 ; -int ret; -u8 *block; - -if (size <0 ) -return -EINVAL ; -if (size >0 && !buf) -return -EFAULT ; - - block =kmalloc (EXT_FW_BLOCK_SIZE ,GFP_KERNEL ); -if (!block) -return -ENOMEM ; - -at76_dbg (DBG_DEVSTART ,"downloading external firmware" ); - -while (size >0 ) { -int bsize = size >EXT_FW_BLOCK_SIZE ?EXT_FW_BLOCK_SIZE : size; - -memcpy (block, buf, bsize); -at76_dbg (DBG_DEVSTART , -"ext fw, size left = %5d, bsize = %4d, i = %2d" , - size, bsize, i); - ret =at76_load_ext_fw_block (udev, i, block, bsize); -if (ret <0 ) { -err ("loading %dth firmware block failed: %d" , i, ret); - goto exit; - } - buf += bsize; - size -= bsize; - i++; - } - -/* for fw >= 0.100, the device needs -an extra empty block: */ - ret =at76_load_ext_fw_block (udev, i, block,0 ); -if (ret <0 ) { -err ("loading %dth firmware block failed: %d" , ret, i); - goto exit; - } - -exit: -kfree (block); -return ret; -} -static int at76_set_card_command (struct usb_device *udev,int cmd,void *buf,int buf_size) {
@@ -3609,6 +3561,14 @@ static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe) {int ret;int op_mode; +int blockno =0 ; +int bsize; +u8 *block; +u8 *buf = fwe->extfw; +int size = fwe->extfw_size; + +if (!buf || !size) +return -ENOENT ; op_mode =at76_get_op_mode (udev);at76_dbg (DBG_DEVSTART ,"opmode %d" , op_mode);
@@ -3618,20 +3578,40 @@ static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe)return -EINVAL ; } -if (!fwe->extfw || !fwe->extfw_size) -return -ENOENT ; + block =kmalloc (FW_BLOCK_SIZE ,GFP_KERNEL ); +if (!block) +return -ENOMEM ; - ret =at76_download_external_fw (udev, fwe->extfw, fwe->extfw_size); -if (ret <0 ) { -err ("Downloading external firmware failed: %d" , ret); -return ret; - } +at76_dbg (DBG_DEVSTART ,"downloading external firmware" ); + +/* for fw >= 0.100, the device needs an extra empty block */ +do { + bsize =min_t (int, size,FW_BLOCK_SIZE ); +memcpy (block, buf, bsize); +at76_dbg (DBG_DEVSTART , +"ext fw, size left = %5d, bsize = %4d, blockno = %2d" , + size, bsize, blockno); + ret =at76_load_ext_fw_block (udev, blockno, block, bsize); +if (ret != bsize) { +err ("loading %dth firmware block failed: %d" , blockno, + ret); + goto exit; + } + buf += bsize; + size -= bsize; + blockno++; + }while (bsize >0 );if (fwe->board_type ==BOARD_505A_2958 ) {at76_dbg (DBG_DEVSTART ,"200 ms delay for board type 7" );schedule_timeout_interruptible (HZ /5 +1 ); } -return 0 ; + +exit: +kfree (block); +if (ret <0 ) +err ("Downloading external firmware failed: %d" , ret); +return ret; }/* Download internal firmware */
PATCH 9/35 Simplify at76_usbdfu_download()
In reply to Pavel RoskinMake it look similar to at76_load_external_fw()
---
drivers/net/wireless/at76_usb.c | 52 +++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 29 deletions(-)
drivers/net/wireless/at76_usb.c +23 -29
@@ -245,16 +245,10 @@ struct dfu_status {static int at76_load_int_fw_block (struct usb_device *udev,int blockno,void *block,int size) { -int ret; - -at76_dbg (DBG_DFU ,"%s(): block=%p, size=%d, blockno=%d" , __func__, - block, size, blockno); - - ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),DFU_DNLOAD , -USB_TYPE_CLASS |USB_DIR_OUT | -USB_RECIP_INTERFACE , blockno,0 , block, size, -USB_CTRL_GET_TIMEOUT ); -return ret; +return usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),DFU_DNLOAD , +USB_TYPE_CLASS |USB_DIR_OUT | +USB_RECIP_INTERFACE , blockno,0 , block, size, +USB_CTRL_GET_TIMEOUT ); } static int at76_dfu_get_status(struct usb_device *udev,
@@ -289,8 +283,8 @@ static inline u32 at76_get_timeout(struct dfu_status *s)/* Load internal firmware from the buffer. If manifest_sync_timeout > 0, use * its value in msec in the MANIFEST_SYNC state. */ -static int at76_usbdfu_download (struct usb_device *udev,u8 *dfu_buffer, -u32 dfu_len,int manifest_sync_timeout) +static int at76_usbdfu_download (struct usb_device *udev,u8 *buf,u32 size, +int manifest_sync_timeout) {u8 *block;struct dfu_status dfu_stat_buf;
@@ -299,15 +293,13 @@ static int at76_usbdfu_download(struct usb_device *udev, u8 *dfu_buffer,int is_done =0 ;u8 dfu_state =0 ;u32 dfu_timeout =0 ; -int dfu_block_bytes =0 ; -int dfu_bytes_left = dfu_len; -int dfu_buffer_offset =0 ; -int dfu_block_cnt =0 ; +int bsize =0 ; +int blockno =0 ; -at76_dbg (DBG_DFU ,"%s( %p, %u, %d)" , __func__, dfu_buffer, - dfu_len, manifest_sync_timeout); +at76_dbg (DBG_DFU ,"%s( %p, %u, %d)" , __func__, buf, size, + manifest_sync_timeout); -if (dfu_len ==0 ) { +if (!size) {err ("FW Buffer length invalid!" );return -EINVAL ; }
@@ -353,16 +345,18 @@ static int at76_usbdfu_download(struct usb_device *udev, u8 *dfu_buffer,case STATE_DFU_IDLE :at76_dbg (DBG_DFU ,"DFU IDLE" ); - dfu_block_bytes =min (dfu_bytes_left,FW_BLOCK_SIZE ); - dfu_bytes_left -= dfu_block_bytes; -memcpy (block, dfu_buffer + dfu_buffer_offset, - dfu_block_bytes); - ret =at76_load_int_fw_block (udev, dfu_block_cnt, block, - dfu_block_bytes); - dfu_buffer_offset += dfu_block_bytes; - dfu_block_cnt++; - -if (ret <0 ) + bsize =min_t (int, size,FW_BLOCK_SIZE ); +memcpy (block, buf, bsize); +at76_dbg (DBG_DFU ,"int fw, size left = %5d, " +"bsize = %4d, blockno = %2d" , size, bsize, + blockno); + ret = +at76_load_int_fw_block (udev, blockno, block, bsize); + buf += bsize; + size -= bsize; + blockno++; + +if (ret != bsize)err ("dfu_download_block failed with %d" , ret); need_dfu_state =1 ;break ;
PATCH 10/35 Add minimal support to 505AMX
In reply to Pavel RoskinUse inline functions for board classification. Drop "_2958" from BOARD_505A_2958, it's implied.
---
drivers/net/wireless/at76_usb.c | 65 +++++++++++++++++++-------------------- drivers/net/wireless/at76_usb.h | 2 + 2 files changed, 32 insertions(+), 35 deletions(-)
drivers/net/wireless/at76_usb.c +31 -34
@@ -56,7 +56,7 @@ static struct fwentry firmwares[] = { [BOARD_503_ACC] = {"atmel_at76c503-rfmd-acc.bin"}, [BOARD_505] = {"atmel_at76c505-rfmd.bin"}, [BOARD_505_2958] = {"atmel_at76c505-rfmd2958.bin"}, - [BOARD_505A_2958] = {"atmel_at76c505a-rfmd2958.bin"}, + [BOARD_505A] = {"atmel_at76c505a-rfmd2958.bin"}, [BOARD_505AMX] = {"atmel_at76c505amx-rfmd.bin"}, };
@@ -171,11 +171,11 @@ static struct usb_device_id dev_table[] = {* at76c505a-rfmd2958 */ /* Generic AT76C505A device */ - {USB_DEVICE(VID_ATMEL, 0x7614), .driver_info = BOARD_505A_2958}, + {USB_DEVICE(VID_ATMEL, 0x7614), .driver_info = BOARD_505A}, /* Generic AT76C505AS device */ - {USB_DEVICE(VID_ATMEL, 0x7617), .driver_info = BOARD_505A_2958}, + {USB_DEVICE(VID_ATMEL, 0x7617), .driver_info = BOARD_505A}, /* Siemens Gigaset USB WLAN Adapter 11 */ - {USB_DEVICE(VID_GIGASET, 0x0701), .driver_info = BOARD_505A_2958}, + {USB_DEVICE(VID_GIGASET, 0x0701), .driver_info = BOARD_505A},/* * at76c505amx-rfmd */
@@ -241,6 +241,21 @@ struct dfu_status {unsigned char string; } __attribute__((packed)); +static inline int at76_is_intersil (enum board_type board) +{ +return (board ==BOARD_503_ISL3861 || board ==BOARD_503_ISL3863 ); +} + +static inline int at76_is_503rfmd (enum board_type board) +{ +return (board ==BOARD_503 || board ==BOARD_503_ACC ); +} + +static inline int at76_is_505a (enum board_type board) +{ +return (board ==BOARD_505A || board ==BOARD_505AMX ); +} +/* Load a block of the first (internal) part of the firmware */ static int at76_load_int_fw_block (struct usb_device *udev,int blockno,void *block,int size)
@@ -618,45 +633,29 @@ static int at76_get_hw_config(struct at76_priv *priv)if (!hwcfg)return -ENOMEM ; -switch (priv->board_type) { - -case BOARD_503_ISL3861 : -case BOARD_503_ISL3863 : +if (at76_is_intersil (priv->board_type)) { ret =at76_get_hw_cfg_intersil (priv->udev, hwcfg,sizeof (hwcfg->i));if (ret <0 ) -break ; + goto exit;memcpy (priv->mac_addr, hwcfg->i.mac_addr,ETH_ALEN ); priv->regulatory_domain = hwcfg->i.regulatory_domain; -break ; - -case BOARD_503 : -case BOARD_503_ACC : + }else if (at76_is_503rfmd (priv->board_type)) { ret =at76_get_hw_cfg (priv->udev, hwcfg,sizeof (hwcfg->r3));if (ret <0 ) -break ; + goto exit;memcpy (priv->mac_addr, hwcfg->r3.mac_addr,ETH_ALEN ); priv->regulatory_domain = hwcfg->r3.regulatory_domain; -break ; - -case BOARD_505 : -case BOARD_505_2958 : -case BOARD_505A_2958 : + }else { ret =at76_get_hw_cfg (priv->udev, hwcfg,sizeof (hwcfg->r5));if (ret <0 ) -break ; + goto exit;memcpy (priv->mac_addr, hwcfg->r5.mac_addr,ETH_ALEN ); priv->regulatory_domain = hwcfg->r5.regulatory_domain; -break ; - -default : -err ("Bad board type set (%d). Unable to get hardware config." , - priv->board_type); - ret = -EINVAL ; } +exit:kfree (hwcfg); -if (ret <0 )err ("Get HW Config failed (%d)" , ret);
@@ -2445,8 +2444,7 @@ static int at76_iw_handler_get_scan(struct net_device *netdev, iwe->u.qual.level = (curr_bss->rssi *100 /42 );if (iwe->u.qual.level >100 ) iwe->u.qual.level =100 ; -if ((priv->board_type ==BOARD_503_ISL3861 ) || - (priv->board_type ==BOARD_503_ISL3863 )) +if (at76_is_intersil (priv->board_type)) iwe->u.qual.qual = curr_bss->link_qual;else { iwe->u.qual.qual =0 ;
@@ -3596,8 +3594,8 @@ static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe) blockno++; }while (bsize >0 ); -if (fwe->board_type ==BOARD_505A_2958 ) { -at76_dbg (DBG_DEVSTART ,"200 ms delay for board type 7" ); +if (at76_is_505a (fwe->board_type)) { +at76_dbg (DBG_DEVSTART ,"200 ms delay for 505a" );schedule_timeout_interruptible (HZ /5 +1 ); }
@@ -3612,7 +3610,7 @@ exit:static int at76_load_internal_fw (struct usb_device *udev,struct fwentry *fwe) {int ret; -int need_remap = (fwe->board_type !=BOARD_505A_2958 ); +int need_remap = !at76_is_505a (fwe->board_type); ret =at76_usbdfu_download (udev, fwe->intfw, fwe->intfw_size, need_remap ?0 :2000 );
@@ -4688,8 +4686,7 @@ static void at76_calc_level(struct at76_priv *priv, struct at76_rx_buffer *buf,static void at76_calc_qual (struct at76_priv *priv,struct at76_rx_buffer *buf,struct iw_quality *qual) { -if ((priv->board_type ==BOARD_503_ISL3861 ) || - (priv->board_type ==BOARD_503_ISL3863 )) +if (at76_is_intersil (priv->board_type)) qual->qual = buf->link_quality;else {unsigned long msec;
drivers/net/wireless/at76_usb.h +1 -1
@@ -70,7 +70,7 @@ enum board_type {BOARD_503_ACC =4 ,BOARD_505 =5 ,BOARD_505_2958 =6 , -BOARD_505A_2958 =7 , +BOARD_505A =7 , BOARD_505AMX = 8 };
PATCH 11/35 Simplify logic in at76_get_reg_domain()
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/wireless/at76_usb.c +5 -8
@@ -664,6 +664,7 @@ exit:static struct reg_domain const *at76_get_reg_domain (u16 code) { +int i;static struct reg_domain const fd_tab[] = { {0x10 ,"FCC (USA)" ,0x7ff },/* ch 1-11 */ {0x20 ,"IC (Canada)" ,0x7ff },/* ch 1-11 */
@@ -673,19 +674,15 @@ static struct reg_domain const *at76_get_reg_domain(u16 code) {0x40, "MKK (Japan)", 0x2000}, /* ch 14 */ {0x41, "MKK1 (Japan)", 0x3fff}, /* ch 1-14 */ {0x50, "Israel", 0x3fc}, /* ch 3-9 */ + {0x00, "<unknown>", 0xffffffff} /* ch 1-32 */ }; -static int const tab_len =ARRAY_SIZE (fd_tab); - -/* use this if an unknown code comes in */ -static struct reg_domain const unknown = {0 ,"<unknown>" ,0xffffffff }; - -int i; -for (i =0 ; i < tab_len; i++) +/* Last entry is fallback for unknown domain code */ +for (i =0 ; i <ARRAY_SIZE (fd_tab) -1 ; i++)if (code == fd_tab[i].code)break ; -return (i >= tab_len) ? &unknown : &fd_tab[i]; +return &fd_tab[i]; } static inline int at76_get_mib(struct usb_device *udev, u16 mib, void *buf,
PATCH 12/35 Fix hex2str() and mac2str() to avoid buffer overlap
In reply to Pavel RoskinDeclarations for two-dimensional arrays were written backwards.
---
drivers/net/wireless/at76_usb.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/at76_usb.c +2 -2
@@ -474,7 +474,7 @@ static inline void at76_iwevent_bss_disconnect(struct net_device *netdev)static char *hex2str (void *buf,int len) {static atomic_t a =ATOMIC_INIT (0 ); -static char bufs[3 *HEX2STR_MAX_LEN +1 ][HEX2STR_BUFFERS ]; +static char bufs[HEX2STR_BUFFERS ][3 *HEX2STR_MAX_LEN +1 ];char *ret = bufs[atomic_inc_return (&a) & (HEX2STR_BUFFERS -1 )];char *obuf = ret;u8 *ibuf = buf;
@@ -503,7 +503,7 @@ static char *hex2str(void *buf, int len)static inline char *mac2str (u8 *mac) {static atomic_t a =ATOMIC_INIT (0 ); -static char bufs[6 *3 ][MAC2STR_BUFFERS ]; +static char bufs[MAC2STR_BUFFERS ][6 *3 ];char *str; str = bufs[atomic_inc_return (&a) & (MAC2STR_BUFFERS -1 )];
PATCH 13/35 Rename some long functions and fields
In reply to Pavel RoskinMostly try to avoid "bulk", which is a minor technical detail. Also avoid read/write in favor of more common rx/tx.
---
drivers/net/wireless/at76_usb.c | 101 ++++++++++++++++++--------------------- drivers/net/wireless/at76_usb.h | 8 ++- 2 files changed, 50 insertions(+), 59 deletions(-)
drivers/net/wireless/at76_usb.c +46 -55
@@ -1538,7 +1538,7 @@ static inline int at76_calc_padding(int wlen)*/ /* Or maybe because our BH handler is preempting bttv's BH handler.. BHs don't * solve everything.. (alex) */ -static void at76_read_bulk_callback (struct urb *urb) +static void at76_rx_callback (struct urb *urb) {struct at76_priv *priv = urb->context;
@@ -1547,7 +1547,7 @@ static void at76_read_bulk_callback(struct urb *urb)return ; } -static void at76_write_bulk_callback (struct urb *urb) +static void at76_tx_callback (struct urb *urb) {struct at76_priv *priv = urb->context;struct net_device_stats *stats = &priv->stats;
@@ -1564,7 +1564,7 @@ static void at76_write_bulk_callback(struct urb *urb)/* urb has been unlinked */ return ;default : -at76_dbg (DBG_URB ,"%s - nonzero write bulk status received: %d" , +at76_dbg (DBG_URB ,"%s - nonzero tx status received: %d" , __func__, urb->status); stats->tx_errors++;break ;
@@ -1584,11 +1584,11 @@ static void at76_write_bulk_callback(struct urb *urb)to the length */ memcpy (priv->bulk_out_buffer, mgmt_buf,le16_to_cpu (mgmt_buf->wlength) +AT76_TX_HDRLEN ); -usb_fill_bulk_urb (priv->write_urb, priv->udev, priv->tx_bulk_pipe, +usb_fill_bulk_urb (priv->tx_urb, priv->udev, priv->tx_pipe, priv->bulk_out_buffer,le16_to_cpu (mgmt_buf->wlength) + mgmt_buf->padding + -AT76_TX_HDRLEN , at76_write_bulk_callback, priv); - ret =usb_submit_urb (priv->write_urb,GFP_ATOMIC ); +AT76_TX_HDRLEN , at76_tx_callback, priv); + ret =usb_submit_urb (priv->tx_urb,GFP_ATOMIC );if (ret)err ("%s: %s error in tx submit urb: %d" , priv->netdev->name, __func__, ret);
@@ -1596,10 +1596,8 @@ static void at76_write_bulk_callback(struct urb *urb)kfree (mgmt_buf); } -/* Send a management frame on bulk-out. -txbuf->wlength must be set (in LE format !) */ -static int at76_send_mgmt_bulk (struct at76_priv *priv, -struct at76_tx_buffer *txbuf) +/* Send a management frame on bulk-out. txbuf->wlength must be set */ +static int at76_tx_mgmt (struct at76_priv *priv,struct at76_tx_buffer *txbuf) {unsigned long flags;int ret =0 ;
@@ -1611,7 +1609,7 @@ static int at76_send_mgmt_bulk(struct at76_priv *priv,spin_lock_irqsave (&priv->mgmt_spinlock, flags); - urb_status = priv->write_urb->status; + urb_status = priv->tx_urb->status;if (urb_status == -EINPROGRESS ) { oldbuf = priv->next_mgmt_bulk;/* to kfree below */ priv->next_mgmt_bulk = txbuf;
@@ -1648,11 +1646,11 @@ static int at76_send_mgmt_bulk(struct at76_priv *priv,/* txbuf was not consumed above -> send mgmt msg immediately */ memcpy (priv->bulk_out_buffer, txbuf,le16_to_cpu (txbuf->wlength) +AT76_TX_HDRLEN ); -usb_fill_bulk_urb (priv->write_urb, priv->udev, priv->tx_bulk_pipe, +usb_fill_bulk_urb (priv->tx_urb, priv->udev, priv->tx_pipe, priv->bulk_out_buffer,le16_to_cpu (txbuf->wlength) + txbuf->padding + -AT76_TX_HDRLEN , at76_write_bulk_callback, priv); - ret =usb_submit_urb (priv->write_urb,GFP_ATOMIC ); +AT76_TX_HDRLEN , at76_tx_callback, priv); + ret =usb_submit_urb (priv->tx_urb,GFP_ATOMIC );if (ret)err ("%s: %s error in tx submit urb: %d" , priv->netdev->name, __func__, ret);
@@ -1720,7 +1718,7 @@ static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,/* either send immediately (if no data tx is pending or put it in pending list */ -return at76_send_mgmt_bulk (priv, tx_buffer); +return at76_tx_mgmt (priv, tx_buffer); }static int at76_assoc_req (struct at76_priv *priv,struct bss_info *bss)
@@ -1794,7 +1792,7 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)/* either send immediately (if no data tx is pending or put it in pending list */ -return at76_send_mgmt_bulk (priv, tx_buffer); +return at76_tx_mgmt (priv, tx_buffer); }/* We got to check the bss_list for old entries */
@@ -3246,8 +3244,8 @@ static int at76_tx(struct sk_buff *skb, struct net_device *netdev)return 0 ; } -if (priv->write_urb->status == -EINPROGRESS ) { -err ("%s: %s called while priv->write_urb is pending for tx" , +if (priv->tx_urb->status == -EINPROGRESS ) { +err ("%s: %s called while priv->tx_urb is pending for tx" , netdev->name, __func__);/* skip this packet */ dev_kfree_skb (skb);
@@ -3339,20 +3337,16 @@ static int at76_tx(struct sk_buff *skb, struct net_device *netdev)netif_stop_queue (netdev); netdev->trans_start = jiffies; -usb_fill_bulk_urb (priv->write_urb, priv->udev, priv->tx_bulk_pipe, - tx_buffer, submit_len, at76_write_bulk_callback, - priv); - ret =usb_submit_urb (priv->write_urb,GFP_ATOMIC ); +usb_fill_bulk_urb (priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer, + submit_len, at76_tx_callback, priv); + ret =usb_submit_urb (priv->tx_urb,GFP_ATOMIC );if (ret) { stats->tx_errors++;err ("%s: error in tx submit urb: %d" , netdev->name, ret);if (ret == -EINVAL )err ("-EINVAL: urb %p urb->hcpriv %p urb->complete %p" , - priv->write_urb, - priv->write_urb ? priv->write_urb-> - hcpriv : (void *)-1 , - priv->write_urb ? priv->write_urb-> - complete : (void *)-1 ); + priv->tx_urb, priv->tx_urb->hcpriv, + priv->tx_urb->complete); }else { stats->tx_bytes += skb->len;dev_kfree_skb (skb);
@@ -3369,18 +3363,18 @@ static void at76_tx_timeout(struct net_device *netdev)return ;warn ("%s: tx timeout." , netdev->name); -usb_unlink_urb (priv->write_urb); +usb_unlink_urb (priv->tx_urb); priv->stats.tx_errors++; } -static int at76_submit_read_urb (struct at76_priv *priv) +static int at76_submit_rx_urb (struct at76_priv *priv) {int ret;int size;struct sk_buff *skb = priv->rx_skb; -if (!priv->read_urb) { -err ("%s: priv->read_urb is NULL" , __func__); +if (!priv->rx_urb) { +err ("%s: priv->rx_urb is NULL" , __func__);return -EFAULT ; }
@@ -3399,10 +3393,9 @@ static int at76_submit_read_urb(struct at76_priv *priv) } size =skb_tailroom (skb); -usb_fill_bulk_urb (priv->read_urb, priv->udev, priv->rx_bulk_pipe, -skb_put (skb, size), size, at76_read_bulk_callback, - priv); - ret =usb_submit_urb (priv->read_urb,GFP_ATOMIC ); +usb_fill_bulk_urb (priv->rx_urb, priv->udev, priv->rx_pipe, +skb_put (skb, size), size, at76_rx_callback, priv); + ret =usb_submit_urb (priv->rx_urb,GFP_ATOMIC );if (ret <0 ) {if (ret == -ENODEV ) at76_dbg(DBG_DEVSTART,
@@ -3457,9 +3450,9 @@ static int at76_open(struct net_device *netdev) priv->last_scan = jiffies; priv->nr_submit_rx_tries =NR_SUBMIT_RX_TRIES ;/* init counter */ - ret =at76_submit_read_urb (priv); + ret =at76_submit_rx_urb (priv);if (ret <0 ) { -err ("%s: open: submit_read_urb failed: %d" , netdev->name, ret); +err ("%s: open: submit_rx_urb failed: %d" , netdev->name, ret); goto error; }
@@ -3492,9 +3485,9 @@ static int at76_stop(struct net_device *netdev)* device is not available anymore. */ at76_set_radio (priv,0 ); -/* We unlink read_urb because at76_open() re-submits it. +/* We unlink rx_urb because at76_open() re-submits it. * If unplugged, at76_delete_device() takes care of it. */ -usb_kill_urb (priv->read_urb); +usb_kill_urb (priv->rx_urb); }cancel_delayed_work (&priv->dwork_get_scan);
@@ -4285,7 +4278,7 @@ static void at76_work_submit_rx(struct work_struct *work) work_submit_rx);mutex_lock (&priv->mtx); -at76_submit_read_urb (priv); +at76_submit_rx_urb (priv);mutex_unlock (&priv->mtx); }
@@ -5064,7 +5057,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv) }else {/* take the skb from priv->rx_skb */ optr->skb = priv->rx_skb; -/* let at76_submit_read_urb() allocate a new skb */ +/* let at76_submit_rx_urb() allocate a new skb */ priv->rx_skb =NULL ; at76_dbg(DBG_RX_FRAGS, "%s: use a free entry",
@@ -5280,7 +5273,7 @@ static void at76_rx_tasklet(unsigned long param) priv->netdev->name, frame_ctl); } exit: -at76_submit_read_urb (priv); +at76_submit_rx_urb (priv); }/* Load firmware into kernel memory and parse it */
@@ -5450,14 +5443,12 @@ static int at76_alloc_urbs(struct at76_priv *priv,return -ENXIO ; } - priv->rx_bulk_pipe = -usb_rcvbulkpipe (priv->udev, ep_in->bEndpointAddress); - priv->tx_bulk_pipe = -usb_sndbulkpipe (priv->udev, ep_out->bEndpointAddress); + priv->rx_pipe =usb_rcvbulkpipe (priv->udev, ep_in->bEndpointAddress); + priv->tx_pipe =usb_sndbulkpipe (priv->udev, ep_out->bEndpointAddress); - priv->read_urb =usb_alloc_urb (0 ,GFP_KERNEL ); - priv->write_urb =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!priv->read_urb || !priv->write_urb) { + priv->rx_urb =usb_alloc_urb (0 ,GFP_KERNEL ); + priv->tx_urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!priv->rx_urb || !priv->tx_urb) { printk(KERN_ERR DRIVER_NAME ": cannot allocate URB\n");return -ENOMEM ; }
@@ -5579,13 +5570,13 @@ static void at76_delete_device(struct at76_priv *priv)kfree (priv->bulk_out_buffer); -if (priv->write_urb) { -usb_kill_urb (priv->write_urb); -usb_free_urb (priv->write_urb); +if (priv->tx_urb) { +usb_kill_urb (priv->tx_urb); +usb_free_urb (priv->tx_urb); } -if (priv->read_urb) { -usb_kill_urb (priv->read_urb); -usb_free_urb (priv->read_urb); +if (priv->rx_urb) { +usb_kill_urb (priv->rx_urb); +usb_free_urb (priv->rx_urb); }at76_dbg (DBG_PROC_ENTRY ,"%s: unlinked urbs" , __func__);
drivers/net/wireless/at76_usb.h +4 -4
@@ -491,11 +491,11 @@ struct at76_priv {struct sk_buff *rx_skb;/* skbuff for receiving data */ void *bulk_out_buffer;/* buffer for sending data */ -struct urb *write_urb;/* URB for sending data */ -struct urb *read_urb;/* URB for receiving data */ +struct urb *tx_urb;/* URB for sending data */ +struct urb *rx_urb;/* URB for receiving data */ -unsigned int tx_bulk_pipe;/* bulk out endpoint */ -unsigned int rx_bulk_pipe;/* bulk in endpoint */ +unsigned int tx_pipe;/* bulk out pipe */ +unsigned int rx_pipe;/* bulk in pipe */ struct mutex mtx;/* locks this structure */
PATCH 14/35 Fix incorrect queue management in at76_tx_mgmt()
In reply to Pavel RoskinThe old pending buffer should be freed, not the new one. No need to set txbuf to NULL.
---
drivers/net/wireless/at76_usb.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-)
drivers/net/wireless/at76_usb.c +7 -10
@@ -1600,7 +1600,7 @@ static void at76_tx_callback(struct urb *urb)static int at76_tx_mgmt (struct at76_priv *priv,struct at76_tx_buffer *txbuf) {unsigned long flags; -int ret =0 ; +int ret;int urb_status;void *oldbuf =NULL ;
@@ -1611,9 +1611,9 @@ static int at76_tx_mgmt(struct at76_priv *priv, struct at76_tx_buffer *txbuf) urb_status = priv->tx_urb->status;if (urb_status == -EINPROGRESS ) { - oldbuf = priv->next_mgmt_bulk;/* to kfree below */ +/* cannot transmit now, put in the queue */ + oldbuf = priv->next_mgmt_bulk; priv->next_mgmt_bulk = txbuf; - txbuf =NULL ; }spin_unlock_irqrestore (&priv->mgmt_spinlock, flags);
@@ -1621,15 +1621,12 @@ static int at76_tx_mgmt(struct at76_priv *priv, struct at76_tx_buffer *txbuf)/* a data/mgmt tx is already pending in the URB - if this is no error in some situations we must implement a queue or silently modify the old msg */ -err ("%s: %s removed pending mgmt buffer %s" , - priv->netdev->name, __func__, -hex2str (priv->next_mgmt_bulk,64 )); -kfree (priv->next_mgmt_bulk); +err ("%s: %s removed pending mgmt buffer %s" , priv->netdev->name, + __func__,hex2str (oldbuf,64 )); +kfree (oldbuf); +return 0 ; } -if (!txbuf) -return ret; - txbuf->tx_rate =0 ; txbuf->padding =at76_calc_padding (le16_to_cpu (txbuf->wlength));
PATCH 15/35 Introduce at76_quiesce(), use it to stop network activity
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 76 ++++++++++++++------------------------- 1 files changed, 27 insertions(+), 49 deletions(-)
drivers/net/wireless/at76_usb.c +27 -49
@@ -1942,6 +1942,28 @@ static void at76_set_multicast(struct net_device *netdev) } } +/* Stop all network activity, flush all pending tasks */ +static void at76_quiesce (struct at76_priv *priv) +{ +unsigned long flags; + +netif_stop_queue (priv->netdev); +netif_carrier_off (priv->netdev); + +at76_set_mac_state (priv,MAC_INIT ); + +cancel_delayed_work (&priv->dwork_get_scan); +cancel_delayed_work (&priv->dwork_beacon); +cancel_delayed_work (&priv->dwork_auth); +cancel_delayed_work (&priv->dwork_assoc); +cancel_delayed_work (&priv->dwork_restart); + +spin_lock_irqsave (&priv->mgmt_spinlock, flags); +kfree (priv->next_mgmt_bulk); + priv->next_mgmt_bulk =NULL ; +spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); +} +/******************************************************************************* * at76_priv implementations of iw_handler functions: */
@@ -1950,27 +1972,12 @@ static int at76_iw_handler_commit(struct net_device *netdev, void *null, char *extra) { struct at76_priv *priv = netdev_priv(netdev); -unsigned long flags; +at76_dbg (DBG_IOCTL ,"%s %s: restarting the device" , netdev->name, __func__); -/* TODO: stop any pending tx bulk urb */ -if (priv->mac_state !=MAC_INIT ) { -at76_set_mac_state (priv,MAC_INIT ); -/* stop pending management stuff */ -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc); - -spin_lock_irqsave (&priv->mgmt_spinlock, flags); -kfree (priv->next_mgmt_bulk); - priv->next_mgmt_bulk =NULL ; -spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); - -netif_carrier_off (priv->netdev); -netif_stop_queue (priv->netdev); - } +if (priv->mac_state !=MAC_INIT ) +at76_quiesce (priv);/* Wait half second before the restart to process subsequent * requests from the same iwconfig in a single restart */
@@ -2293,7 +2300,6 @@ static int at76_iw_handler_set_scan(struct net_device *netdev, union iwreq_data *wrqu, char *extra) { struct at76_priv *priv = netdev_priv(netdev); -unsigned long flags;int ret =0 ;at76_dbg (DBG_IOCTL ,"%s: SIOCSIWSCAN" , netdev->name);
@@ -2317,22 +2323,8 @@ static int at76_iw_handler_set_scan(struct net_device *netdev, priv->scan_state =SCAN_IN_PROGRESS ; -/* stop pending management stuff */ -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc); - -spin_lock_irqsave (&priv->mgmt_spinlock, flags); -kfree (priv->next_mgmt_bulk); - priv->next_mgmt_bulk =NULL ; -spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); +at76_quiesce (priv); -if (netif_running (priv->netdev)) { -/* pause network activity */ -netif_carrier_off (priv->netdev); -netif_stop_queue (priv->netdev); - }/* Try to do passive or active scan if WE asks as. */ if (wrqu->data.length && wrqu->data.length ==sizeof (struct iw_scan_req )) {
@@ -3465,17 +3457,14 @@ error:static int at76_stop (struct net_device *netdev) {struct at76_priv *priv =netdev_priv (netdev); -unsigned long flags;at76_dbg (DBG_DEVSTART ,"%s: ENTER" , __func__);if (mutex_lock_interruptible (&priv->mtx))return -EINTR ; -netif_stop_queue (netdev); - -at76_set_mac_state (priv,MAC_INIT );tasklet_disable (&priv->rx_tasklet); +at76_quiesce (priv);if (!priv->device_unplugged) {/* We are called by "ifconfig ethX down", not because the
@@ -3487,17 +3476,6 @@ static int at76_stop(struct net_device *netdev)usb_kill_urb (priv->rx_urb); } -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc); -cancel_delayed_work (&priv->dwork_restart); - -spin_lock_irqsave (&priv->mgmt_spinlock, flags); -kfree (priv->next_mgmt_bulk); - priv->next_mgmt_bulk =NULL ; -spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); -/* free the bss_list */ at76_free_bss_list (priv);
PATCH 16/35 Don't disable and enable tasklets, it doesn't work as expected
In reply to Pavel RoskinBringing the interface down causes high CPU utilization. Correct fix should probably disable rx URB, not only the rx tasklet.
---
drivers/net/wireless/at76_usb.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/net/wireless/at76_usb.c +0 -5
@@ -3445,7 +3445,6 @@ static int at76_open(struct net_device *netdev) goto error; } -tasklet_enable (&priv->rx_tasklet);schedule_delayed_work (&priv->dwork_restart,0 );at76_dbg (DBG_PROC_ENTRY ,"%s(): end" , __func__);
@@ -3463,7 +3462,6 @@ static int at76_stop(struct net_device *netdev)if (mutex_lock_interruptible (&priv->mtx))return -EINTR ; -tasklet_disable (&priv->rx_tasklet);at76_quiesce (priv);if (!priv->device_unplugged) {
@@ -5375,7 +5373,6 @@ static struct at76_priv *at76_alloc_new_device(struct usb_device *udev) priv->rx_tasklet.func = at76_rx_tasklet; priv->rx_tasklet.data =0 ; -tasklet_disable (&priv->rx_tasklet); priv->pm_mode =AT76_PM_OFF ; priv->pm_period =0 ;
@@ -5535,8 +5532,6 @@ static void at76_delete_device(struct at76_priv *priv)/* The device is gone, don't bother turning it off */ priv->device_unplugged =1 ; -tasklet_kill (&priv->rx_tasklet); -if (priv->netdev_registered)unregister_netdev (priv->netdev);
PATCH 17/35 Start beacon timeout task when connected
In reply to Pavel RoskinLimit beacon timeout task to the managed mode. Don't warn of the wrong mode or state, just exit.
---
drivers/net/wireless/at76_usb.c | 19 +++++++------------ 1 files changed, 7 insertions(+), 12 deletions(-)
drivers/net/wireless/at76_usb.c +7 -12
@@ -1889,6 +1889,7 @@ static void at76_work_assoc_done(struct work_struct *work)at76_dump_mib_mac_mgmt (priv);#endif } +schedule_delayed_work (&priv->dwork_beacon,BEACON_TIMEOUT ); }at76_set_pm_mode (priv);
@@ -3796,7 +3797,6 @@ static void at76_work_join(struct work_struct *work)netif_start_queue (priv->netdev);/* just to be sure */ cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon);cancel_delayed_work (&priv->dwork_auth);cancel_delayed_work (&priv->dwork_assoc); }else {
@@ -3921,23 +3921,18 @@ static void at76_dwork_beacon(struct work_struct *work) dwork_beacon.work);mutex_lock (&priv->mtx); -WARN_ON (priv->mac_state !=MAC_CONNECTED ); -if (priv->mac_state !=MAC_CONNECTED ) +if (priv->mac_state !=MAC_CONNECTED || priv->iw_mode !=IW_MODE_INFRA ) goto exit;/* We haven't received any beacons from out AP for BEACON_TIMEOUT */ printk (KERN_INFO "%s: lost beacon bssid %s\n" , priv->netdev->name,mac2str (priv->curr_bss->bssid)); -/* jal: starting mgmt_timer in ad-hoc mode is questionable, -but I'll leave it here to debug another lockup problem */ -if (priv->iw_mode !=IW_MODE_ADHOC ) { -netif_carrier_off (priv->netdev); -netif_stop_queue (priv->netdev); -at76_iwevent_bss_disconnect (priv->netdev); -at76_set_mac_state (priv,MAC_SCANNING ); -schedule_work (&priv->work_start_scan); - } +netif_carrier_off (priv->netdev); +netif_stop_queue (priv->netdev); +at76_iwevent_bss_disconnect (priv->netdev); +at76_set_mac_state (priv,MAC_SCANNING ); +schedule_work (&priv->work_start_scan); exit:mutex_unlock (&priv->mtx);
PATCH 18/35 Only cancel correct timeouts for Auth and Assoc replies
In reply to Pavel RoskinDon't cancel all delayed works indiscriminately. In case of at76_rx_mgmt_auth(), cancel the timeout regardless of the status of the reply, as long as the reply is for us.
---
drivers/net/wireless/at76_usb.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/net/wireless/at76_usb.c +2 -8
@@ -4274,6 +4274,7 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,BUG_ON (!priv->curr_bss); +cancel_delayed_work (&priv->dwork_assoc);if (status ==WLAN_STATUS_SUCCESS ) {struct bss_info *ptr = priv->curr_bss; priv->assoc_id = assoc_id &0x3fff ;
@@ -4287,10 +4288,6 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,at76_set_mac_state (priv,MAC_JOINING );schedule_work (&priv->work_join); } -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc); }/* Process disassociation request from the AP */
@@ -4376,11 +4373,8 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv, || compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1))return ; +cancel_delayed_work (&priv->dwork_auth);if (status !=WLAN_STATUS_SUCCESS ) { -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc);/* try to join next bss */ at76_set_mac_state (priv,MAC_JOINING );schedule_work (&priv->work_join);
Johannes Berg
maintainerRe: [PATCH 18/35] Only cancel correct timeouts for Auth and Assoc replies
Quoted 3 lines · Pavel Roskin
Don't cancel all delayed works indiscriminately. In case of
at76_rx_mgmt_auth(), cancel the timeout regardless of the status of the reply, as long as the reply is for us.
Out of curiosity, why are you cleaning up code that needs to be deleted anyhow? The way I see it, the driver ought to be be ported to mac80211, no? It seems to ship with an in-driver softmac.
johannes
Re: [PATCH 18/35] Only cancel correct timeouts for Auth and Assoc replies
Quoted 8 lines · Johannes Berg
Quoted 3 lines · Pavel Roskin
Don't cancel all delayed works indiscriminately. In case of
at76_rx_mgmt_auth(), cancel the timeout regardless of the status of the reply, as long as the reply is for us.Out of curiosity, why are you cleaning up code that needs to be deleted anyhow? The way I see it, the driver ought to be be ported to mac80211, no? It seems to ship with an in-driver softmac.
I understand that. But at the time I did it, I wasn't even sure that the mac80211 conversion is possible. I wanted to have a solid base before starting the risky conversion.
The driver used to have a big event handler that was split into several works and a big timer handler that was split into several timers. In some cases, the code would cancel the "big timer" for some errors. The first step was replace it with the code to cancel all timers. The second step was to remove some unlikely or wrong cases, when the specific timer cannot be running or shouldn't be canceled. I'm not going to do any more cleanup of this kind.
What happened is that the driver in wireless-dev/at76 is a version 57 commits below the top of my repository, and the mac80211 port was started at the point 35 commits above the version in wireless-dev/at76.
It would have been easier if everybody just had started with my current code, but since it didn't happen, I'm trying to fix it. The first step is to go the the point where Kalle started mac80211 conversion. The rest doesn't contain any major fixes, although some changes are pretty intrusive. I'll see what to do with them once I have a chance to play with the mac80211 conversion patch.
The patches I have sent were not meant to be reviewed in this list, since I expected the latest version to be imported as is. But I think it's still better to send the patches separately rather than a single patch. If nothing else, the separate patches could receive some useful comments.
Signature · 2 lines
Regards, Pavel Roskin
Johannes Berg
maintainerRe: [PATCH 18/35] Only cancel correct timeouts for Auth and Assoc replies
Quoted 3 lines · Pavel Roskin
I understand that. But at the time I did it, I wasn't even sure that the mac80211 conversion is possible. I wanted to have a solid base before starting the risky conversion.
[...]
Quoted 5 lines
The patches I have sent were not meant to be reviewed in this list, since I expected the latest version to be imported as is. But I think it's still better to send the patches separately rather than a single patch. If nothing else, the separate patches could receive some useful comments.
Oh sure, it's fine to do this first, just wondered if you were now spending time on it erroneously :)
johannes
Re: [PATCH 18/35] Only cancel correct timeouts for Auth and Assoc replies
In reply to Pavel RoskinQuoted 2 lines · Pavel Roskin
It would have been easier if everybody just had started with my current code, but since it didn't happen, I'm trying to fix it. The first step
No doubt -- my bad. I simply took the patch URL as posted, which admittedly was months ago.
Quoted 4 lines
is to go the the point where Kalle started mac80211 conversion. The rest doesn't contain any major fixes, although some changes are pretty intrusive. I'll see what to do with them once I have a chance to play with the mac80211 conversion patch.
I think we'll just import these into wireless-dev as-is and go from there. If someone spots a huge problem, then hopefully they'll post a patch as well. :-)
Thanks,
John
Signature · 2 lines
John W. Linville [email protected]
Re: [PATCH 18/35] Only cancel correct timeouts for Auth and Assoc replies
Quoting "John W. Linville" <[email protected]>:
Quoted 3 lines
I think we'll just import these into wireless-dev as-is and go from there. If someone spots a huge problem, then hopefully they'll post a patch as well. :-)
If you mean the patches I have posted, then yes, please go ahead. If you mean the rest, I'd like to wait for Kalle's reply, as I don't want to create merge problems for him. I'm not good at making radical changes myself, so I'd like at least not to be a problem for those brave souls who do that part.
Signature · 2 lines
Regards, Pavel Roskin
PATCH 19/35 Improve output of the regdomain id
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/at76_usb.c +2 -2
@@ -5502,8 +5502,8 @@ static int at76_init_new_device(struct at76_priv *priv,printk (KERN_INFO "%s: firmware version %d.%d.%d-%d\n" , netdev->name, priv->fw_version.major, priv->fw_version.minor, priv->fw_version.patch, priv->fw_version.build); -printk (KERN_INFO "%s: regulatory domain %s (id %d)\n" , netdev->name, - priv->domain->name, priv->regulatory_domain); +printk (KERN_INFO "%s: regulatory domain 0x%02x: %s\n" , netdev->name, + priv->regulatory_domain, priv->domain->name);/* we let this timer run the whole time this driver instance lives */ mod_timer (&priv->bss_list_timer, jiffies +BSS_LIST_TIMEOUT );
PATCH 20/35 Protect at76_iw_handler_set_scan() with mutex
In reply to Pavel RoskinThis prevents a race condition when a response from an AP comes before we set state to MAC_SCANNING, but after at76_quiesce().
---
drivers/net/wireless/at76_usb.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/wireless/at76_usb.c +17 -6
@@ -2305,13 +2305,20 @@ static int at76_iw_handler_set_scan(struct net_device *netdev,at76_dbg (DBG_IOCTL ,"%s: SIOCSIWSCAN" , netdev->name); -if (!netif_running (netdev)) -return -ENETDOWN ; +if (mutex_lock_interruptible (&priv->mtx)) +return -EINTR ; + +if (!netif_running (netdev)) { + ret = -ENETDOWN ; + goto exit; + }/* jal: we don't allow "iwlist ethX scan" while we are in monitor mode */ -if (priv->iw_mode ==IW_MODE_MONITOR ) -return -EBUSY ; +if (priv->iw_mode ==IW_MODE_MONITOR ) { + ret = -EBUSY ; + goto exit; + }/* Discard old scan results */ if ((jiffies - priv->last_scan) > (20 *HZ ))
@@ -2319,8 +2326,10 @@ static int at76_iw_handler_set_scan(struct net_device *netdev, priv->last_scan = jiffies;/* Initiate a scan command */ -if (priv->scan_state ==SCAN_IN_PROGRESS ) -return -EBUSY ; +if (priv->scan_state ==SCAN_IN_PROGRESS ) { + ret = -EBUSY ; + goto exit; + } priv->scan_state =SCAN_IN_PROGRESS ;
@@ -2348,6 +2357,8 @@ static int at76_iw_handler_set_scan(struct net_device *netdev,at76_set_mac_state (priv,MAC_SCANNING );schedule_work (&priv->work_start_scan); +exit: +mutex_unlock (&priv->mtx);return ret; }
PATCH 21/35 Eliminate vendor IDs
In reply to Pavel RoskinThey are useless next to comments with full device names.
---
drivers/net/wireless/at76_usb.c | 98 ++++++++++++++++++++------------------- drivers/net/wireless/at76_usb.h | 35 -------------- 2 files changed, 49 insertions(+), 84 deletions(-)
drivers/net/wireless/at76_usb.c +49 -49
@@ -65,122 +65,122 @@ static struct usb_device_id dev_table[] = {* at76c503-i3861 */ /* Generic AT76C503/3861 device */ - {USB_DEVICE(VID_ATMEL, 0x7603), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x03eb, 0x7603), .driver_info = BOARD_503_ISL3861}, /* Linksys WUSB11 v2.1/v2.6 */ - {USB_DEVICE(VID_LINKSYS_OLD, 0x2211), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x066b, 0x2211), .driver_info = BOARD_503_ISL3861}, /* Netgear MA 101 Rev. A */ - {USB_DEVICE(VID_NETGEAR, 0x4100), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x0864, 0x4100), .driver_info = BOARD_503_ISL3861}, /* Tekram U-300C / Allnet ALL0193 */ - {USB_DEVICE(VID_TEKRAM, 0x1612), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x0b3b, 0x1612), .driver_info = BOARD_503_ISL3861}, /* HP HN210W PKW-J7801A */ - {USB_DEVICE(VID_HP, 0x011c), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x03f0, 0x011c), .driver_info = BOARD_503_ISL3861}, /* Sitecom/Z-Com/Zyxel M4Y-750 */ - {USB_DEVICE(VID_ZCOM, 0x0001), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x0cde, 0x0001), .driver_info = BOARD_503_ISL3861}, /* Dynalink/Askey WLL013 (intersil) */ - {USB_DEVICE(VID_ASKEY, 0x0320), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x069a, 0x0320), .driver_info = BOARD_503_ISL3861}, /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W (v1) */ - {USB_DEVICE(VID_SMC_OLD, 0xa001), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x0d5c, 0xa001), .driver_info = BOARD_503_ISL3861}, /* AWL-300 */ - {USB_DEVICE(VID_BENQ, 0x9000), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x04a5, 0x9000), .driver_info = BOARD_503_ISL3861}, /* AWU-120, Compex WLU11 */ - {USB_DEVICE(VID_ADDTRON, 0xff31), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x05dd, 0xff31), .driver_info = BOARD_503_ISL3861}, /* AP310 AnyPoint II USB */ - {USB_DEVICE(VID_INTEL, 0x0200), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x8086, 0x0200), .driver_info = BOARD_503_ISL3861}, /* Dynalink L11U */ - {USB_DEVICE(VID_GLOBAL_SUN, 0x7100), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x0d8e, 0x7100), .driver_info = BOARD_503_ISL3861}, /* Arescom WL-210, FCC id 07J-GL2411USB */ - {USB_DEVICE(VID_GLOBAL_SUN, 0x7110), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x0d8e, 0x7110), .driver_info = BOARD_503_ISL3861}, /* IO-DATA WN-B11/USB */ - {USB_DEVICE(VID_IO_DATA, 0x0919), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x04bb, 0x0919), .driver_info = BOARD_503_ISL3861}, /* BT Voyager 1010 */ - {USB_DEVICE(VID_ASKEY, 0x0821), .driver_info = BOARD_503_ISL3861}, + {USB_DEVICE(0x069a, 0x0821), .driver_info = BOARD_503_ISL3861}, /* at76c503-i3863 */ /* Generic AT76C503/3863 device */ - {USB_DEVICE(VID_ATMEL, 0x7604), .driver_info = BOARD_503_ISL3863}, + {USB_DEVICE(0x03eb, 0x7604), .driver_info = BOARD_503_ISL3863}, /* Samsung SWL-2100U */ - {USB_DEVICE(VID_SAMSUNG, 0xa000), .driver_info = BOARD_503_ISL3863}, + {USB_DEVICE(0x055d, 0xa000), .driver_info = BOARD_503_ISL3863}, /* * at76c503-rfmd */ /* Generic AT76C503/RFMD device */ - {USB_DEVICE(VID_ATMEL, 0x7605), .driver_info = BOARD_503}, + {USB_DEVICE(0x03eb, 0x7605), .driver_info = BOARD_503}, /* Dynalink/Askey WLL013 (rfmd) */ - {USB_DEVICE(VID_ASKEY, 0x0321), .driver_info = BOARD_503}, + {USB_DEVICE(0x069a, 0x0321), .driver_info = BOARD_503}, /* Linksys WUSB11 v2.6 */ - {USB_DEVICE(VID_LINKSYS, 0x2219), .driver_info = BOARD_503}, + {USB_DEVICE(0x077b, 0x2219), .driver_info = BOARD_503}, /* Network Everywhere NWU11B */ - {USB_DEVICE(VID_LINKSYS, 0x2227), .driver_info = BOARD_503}, + {USB_DEVICE(0x077b, 0x2227), .driver_info = BOARD_503}, /* Netgear MA 101 Rev. B */ - {USB_DEVICE(VID_NETGEAR, 0x4102), .driver_info = BOARD_503}, + {USB_DEVICE(0x0864, 0x4102), .driver_info = BOARD_503}, /* DWL-120 rev. E */ - {USB_DEVICE(VID_DLINK, 0x3200), .driver_info = BOARD_503}, + {USB_DEVICE(0x2001, 0x3200), .driver_info = BOARD_503}, /* Actiontec 802UAT1, HWU01150-01UK */ - {USB_DEVICE(VID_ACTIONTEC, 0x7605), .driver_info = BOARD_503}, + {USB_DEVICE(0x1668, 0x7605), .driver_info = BOARD_503}, /* AirVast W-Buddie WN210 */ - {USB_DEVICE(VID_ATMEL, 0x4102), .driver_info = BOARD_503}, + {USB_DEVICE(0x03eb, 0x4102), .driver_info = BOARD_503}, /* XH1153 802.11b USB adapter */ - {USB_DEVICE(VID_DICK_SMITH, 0x5743), .driver_info = BOARD_503}, + {USB_DEVICE(0x1371, 0x5743), .driver_info = BOARD_503}, /* WL-200U */ - {USB_DEVICE(VID_DICK_SMITH, 0x0002), .driver_info = BOARD_503}, + {USB_DEVICE(0x1371, 0x0002), .driver_info = BOARD_503}, /* BenQ AWL-400 USB stick */ - {USB_DEVICE(VID_BENQ, 0x9001), .driver_info = BOARD_503}, + {USB_DEVICE(0x04a5, 0x9001), .driver_info = BOARD_503}, /* 3COM 3CRSHEW696 */ - {USB_DEVICE(VID_3COM, 0x0a01), .driver_info = BOARD_503}, + {USB_DEVICE(0x0506, 0x0a01), .driver_info = BOARD_503}, /* Siemens Santis ADSL WLAN USB adapter WLL 013 */ - {USB_DEVICE(VID_SIEMENS, 0x001b), .driver_info = BOARD_503}, + {USB_DEVICE(0x0681, 0x001b), .driver_info = BOARD_503}, /* Belkin F5D6050, version 2 */ - {USB_DEVICE(VID_BELKIN_2, 0x0050), .driver_info = BOARD_503}, + {USB_DEVICE(0x050d, 0x0050), .driver_info = BOARD_503}, /* iBlitzz, BWU613 (not *B or *SB) */ - {USB_DEVICE(VID_BLITZ, 0xb000), .driver_info = BOARD_503}, + {USB_DEVICE(0x07b8, 0xb000), .driver_info = BOARD_503}, /* Gigabyte GN-WLBM101 */ - {USB_DEVICE(VID_GIGABYTE, 0x8003), .driver_info = BOARD_503}, + {USB_DEVICE(0x1044, 0x8003), .driver_info = BOARD_503}, /* Planex GW-US11S */ - {USB_DEVICE(VID_PLANEX, 0x3220), .driver_info = BOARD_503}, + {USB_DEVICE(0x2019, 0x3220), .driver_info = BOARD_503}, /* Internal WLAN adapter in h5[4,5]xx series iPAQs */ - {USB_DEVICE(VID_COMPAQ, 0x0032), .driver_info = BOARD_503}, + {USB_DEVICE(0x049f, 0x0032), .driver_info = BOARD_503}, /* * at76c503-rfmd-acc */ /* SMC 2664W */ - {USB_DEVICE(VID_SMC, 0x3501), .driver_info = BOARD_503_ACC}, + {USB_DEVICE(0x083a, 0x3501), .driver_info = BOARD_503_ACC}, /* Belkin F5D6050, SMC 2662W v2, SMC 2662W-AR */ - {USB_DEVICE(VID_BELKIN, 0xa002), .driver_info = BOARD_503_ACC}, + {USB_DEVICE(0x0d5c, 0xa002), .driver_info = BOARD_503_ACC}, /* * at76c505-rfmd */ /* Generic AT76C505/RFMD */ - {USB_DEVICE(VID_ATMEL, 0x7606), .driver_info = BOARD_505}, + {USB_DEVICE(0x03eb, 0x7606), .driver_info = BOARD_505}, /* * at76c505-rfmd2958 */ /* Generic AT76C505/RFMD, OvisLink WL-1130USB */ - {USB_DEVICE(VID_ATMEL, 0x7613), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x03eb, 0x7613), .driver_info = BOARD_505_2958}, /* Fiberline WL-240U */ - {USB_DEVICE(VID_CNET, 0x0014), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x1371, 0x0014), .driver_info = BOARD_505_2958}, /* CNet CNUSB 611G */ - {USB_DEVICE(VID_CNET, 0x0013), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x1371, 0x0013), .driver_info = BOARD_505_2958}, /* Linksys WUSB11 v2.8 */ - {USB_DEVICE(VID_LINKSYS_1915, 0x2233), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x1915, 0x2233), .driver_info = BOARD_505_2958}, /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */ - {USB_DEVICE(VID_XTERASYS, 0x1001), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x12fd, 0x1001), .driver_info = BOARD_505_2958}, /* Corega WLAN USB Stick 11 */ - {USB_DEVICE(VID_COREGA, 0x7613), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x07aa, 0x7613), .driver_info = BOARD_505_2958}, /* Microstar MSI Box MS6978 */ - {USB_DEVICE(VID_MSI, 0x1020), .driver_info = BOARD_505_2958}, + {USB_DEVICE(0x0db0, 0x1020), .driver_info = BOARD_505_2958}, /* * at76c505a-rfmd2958 */ /* Generic AT76C505A device */ - {USB_DEVICE(VID_ATMEL, 0x7614), .driver_info = BOARD_505A}, + {USB_DEVICE(0x03eb, 0x7614), .driver_info = BOARD_505A}, /* Generic AT76C505AS device */ - {USB_DEVICE(VID_ATMEL, 0x7617), .driver_info = BOARD_505A}, + {USB_DEVICE(0x03eb, 0x7617), .driver_info = BOARD_505A}, /* Siemens Gigaset USB WLAN Adapter 11 */ - {USB_DEVICE(VID_GIGASET, 0x0701), .driver_info = BOARD_505A}, + {USB_DEVICE(0x1690, 0x0701), .driver_info = BOARD_505A}, /* * at76c505amx-rfmd */ /* Generic AT76C505AMX device */ - {USB_DEVICE(VID_ATMEL, 0x7615), .driver_info = BOARD_505AMX}, + {USB_DEVICE(0x03eb, 0x7615), .driver_info = BOARD_505AMX}, {} };
drivers/net/wireless/at76_usb.h +0 -35
@@ -27,41 +27,6 @@/* current driver version */ #define DRIVER_VERSION "0.16" -/* USB vendor IDs */ -#define VID_3COM 0x0506 -#define VID_ACTIONTEC 0x1668 -#define VID_ADDTRON 0x05dd -#define VID_ASKEY 0x069a -#define VID_ATMEL 0x03eb -#define VID_BELKIN 0x0d5c -#define VID_BELKIN_2 0x050d -#define VID_BENQ 0x04a5 -#define VID_BLITZ 0x07b8 -#define VID_CNET 0x1371 -#define VID_COMPAQ 0x049f -#define VID_GLOBAL_SUN 0x0d8e -#define VID_COREGA 0x07aa -#define VID_DICK_SMITH 0x1371 -#define VID_DLINK 0x2001 -#define VID_GIGABYTE 0x1044 -#define VID_GIGASET 0x1690 -#define VID_HP 0x03f0 -#define VID_INTEL 0x8086 -#define VID_IO_DATA 0x04bb -#define VID_LINKSYS 0x077b -#define VID_LINKSYS_1915 0x1915 -#define VID_LINKSYS_OLD 0x066b -#define VID_MSI 0x0db0 -#define VID_ZCOM 0x0cde -#define VID_NETGEAR 0x0864 -#define VID_SAMSUNG 0x055d -#define VID_SIEMENS 0x0681 -#define VID_SMC 0x083a -#define VID_SMC_OLD 0x0d5c -#define VID_PLANEX 0x2019 -#define VID_TEKRAM 0x0b3b -#define VID_XTERASYS 0x12fd -/* Board types */ enum board_type {BOARD_503_ISL3861 =1 ,
PATCH 22/35 Only retry resubmitting rx_urb once
In reply to Pavel RoskinOther drivers don't even bother resubmitting it with GFP_KERNEL. If it fails with GFP_KERNEL, we have a problem, and restarting the task is not likely to be helpful.
---
drivers/net/wireless/at76_usb.c | 21 +++++---------------- drivers/net/wireless/at76_usb.h | 3 --- 2 files changed, 5 insertions(+), 19 deletions(-)
drivers/net/wireless/at76_usb.c +5 -16
@@ -3407,21 +3407,11 @@ static int at76_submit_rx_urb(struct at76_priv *priv) } exit: -if (ret <0 ) { -if (ret != -ENODEV ) { -/* If we can't submit the URB, the adapter becomes -* completely useless, so try again later */ -if (--priv->nr_submit_rx_tries >0 ) -schedule_work (&priv->work_submit_rx); -else -err ("%s: giving up to submit rx urb after %d " -"failures - please unload the driver " -"and/or power cycle the device" , - priv->netdev->name,NR_SUBMIT_RX_TRIES ); - } - }else -/* reset counter to initial value */ - priv->nr_submit_rx_tries =NR_SUBMIT_RX_TRIES ; +if (ret <0 && ret != -ENODEV ) { +printk (KERN_ERR "%s: cannot submit rx urb - please unload the " +"driver and/or power cycle the device\n" , + priv->netdev->name); + }return ret; }
@@ -3449,7 +3439,6 @@ static int at76_open(struct net_device *netdev) priv->scan_state =SCAN_IDLE ; priv->last_scan = jiffies; - priv->nr_submit_rx_tries =NR_SUBMIT_RX_TRIES ;/* init counter */ ret =at76_submit_rx_urb (priv);if (ret <0 ) {
drivers/net/wireless/at76_usb.h +0 -3
@@ -430,8 +430,6 @@ struct rx_data_buf { };#define NR_RX_DATA_BUF 8 -/* how often do we try to submit a rx urb until giving up */ -#define NR_SUBMIT_RX_TRIES 8/* Data for one loaded firmware file */ struct fwentry {
@@ -477,7 +475,6 @@ struct at76_priv {struct delayed_work dwork_auth;struct delayed_work dwork_assoc; -int nr_submit_rx_tries;/* number of tries to submit an rx urb left */ struct tasklet_struct rx_tasklet;/* the WEP stuff */
PATCH 23/35 Simplify at76_get_mib_mdomain()
In reply to Pavel RoskinThe "error" label is not needed.
---
drivers/net/wireless/at76_usb.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/net/wireless/at76_usb.c +4 -6
@@ -1277,15 +1277,13 @@ static int at76_get_mib_mdomain(struct at76_priv *priv, struct mib_mdomain *val) ret =at76_get_mib (priv->udev,MIB_MDOMAIN , mdomain,sizeof (struct mib_mdomain )); -if (ret <0 ) { +if (ret <0 )err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); - goto error; - } - -memcpy (val, mdomain,sizeof (*val)); +else +memcpy (val, mdomain,sizeof (*val)); -error:kfree (mdomain); + exit:return ret; }
PATCH 24/35 Do implicit scanning only with current ESSID
In reply to Pavel RoskinThis should speed up association. We don't need non-matching APs if ESSID is set.
For user-requested scanning, scan for any essid after that. For international scanning, start with scan_runs 1, as it was meant to be done. Actually use ir_step 0 for international scanning. Adjust debug messages correspondingly.
---
drivers/net/wireless/at76_usb.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/wireless/at76_usb.c +10 -7
@@ -3871,9 +3871,9 @@ static void at76_dwork_get_scan(struct work_struct *work) sizeof(mdomain.channel_list)),hex2str (mdomain.tx_powerlevel, sizeof(mdomain.tx_powerlevel))); - ret =at76_start_scan (priv,0 ,1 ); + ret =at76_start_scan (priv,0 ,0 );if (ret <0 ) -err ("%s: %s: start_scan (ANY) failed with %d" , +err ("%s: %s: start_scan (IR) failed with %d" , priv->netdev->name, __func__, ret); at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
@@ -3883,9 +3883,9 @@ static void at76_dwork_get_scan(struct work_struct *work)break ;case 2 : - ret =at76_start_scan (priv,1 ,1 ); + ret =at76_start_scan (priv,0 ,1 );if (ret <0 ) -err ("%s: %s: start_scan (SSID) failed with %d" , +err ("%s: %s: start_scan (ANY) failed with %d" , priv->netdev->name, __func__, ret); at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
@@ -4195,11 +4195,14 @@ static void at76_work_start_scan(struct work_struct *work)/* only clear the bss list when a scan is actively initiated, * otherwise simply rely on at76_bss_list_timeout */ -if (priv->scan_state ==SCAN_IN_PROGRESS ) +if (priv->scan_state ==SCAN_IN_PROGRESS ) {at76_free_bss_list (priv); + priv->scan_runs = priv->international_roaming ?1 :2 ; + }else + priv->scan_runs =3 ; + + ret =at76_start_scan (priv,1 ,1 ); - priv->scan_runs =2 ; - ret =at76_start_scan (priv,0 ,1 );if (ret <0 )err ("%s: %s: start_scan failed with %d" , priv->netdev->name, __func__, ret);
PATCH 25/35 Don't dump mib_mdomain while scanning, it's done on device startup
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-)
drivers/net/wireless/at76_usb.c +0 -11
@@ -3816,7 +3816,6 @@ static void at76_dwork_get_scan(struct work_struct *work) {int status;int ret; -struct mib_mdomain mdomain; struct at76_priv *priv = container_of(work, struct at76_priv, dwork_get_scan.work);
@@ -3861,16 +3860,6 @@ static void at76_dwork_get_scan(struct work_struct *work)case 1 :WARN_ON (!priv->international_roaming); - ret =at76_get_mib_mdomain (priv, &mdomain); -if (ret <0 ) -err ("at76_get_mib_mdomain returned %d" , ret); -else -at76_dbg (DBG_MIB ,"%s: MIB MDOMAIN: channel_list %s " -"tx_powerlevel %s" , priv->netdev->name, -hex2str (mdomain.channel_list, -sizeof (mdomain.channel_list)), -hex2str (mdomain.tx_powerlevel, -sizeof (mdomain.tx_powerlevel))); ret =at76_start_scan (priv,0 ,0 );if (ret <0 ) err("%s: %s: start_scan (IR) failed with %d",
PATCH 26/35 Improve dump of MAC_ADDR
In reply to Pavel RoskinDon't require DEBUG to be defined. Dump each group address separately, next to the status. Rename MIB_MAC_ADD to MIB_MAC_ADDR.
---
drivers/net/wireless/at76_usb.c | 34 ++++++++++++++++++---------------- drivers/net/wireless/at76_usb.h | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-)
drivers/net/wireless/at76_usb.c +18 -16
@@ -979,7 +979,7 @@ static int at76_add_mac_address(struct at76_priv *priv, void *addr)int ret =0 ;memset (&priv->mib_buf,0 ,sizeof (struct set_mib_buffer )); - priv->mib_buf.type =MIB_MAC_ADD ; + priv->mib_buf.type =MIB_MAC_ADDR ; priv->mib_buf.size =ETH_ALEN ; priv->mib_buf.index = offsetof(struct mib_mac_addr , mac_addr);memcpy (priv->mib_buf.data, addr,ETH_ALEN );
@@ -999,26 +999,26 @@ static int at76_set_group_address(struct at76_priv *priv, u8 *addr, int n)int ret =0 ;memset (&priv->mib_buf,0 ,sizeof (struct set_mib_buffer )); - priv->mib_buf.type =MIB_MAC_ADD ; + priv->mib_buf.type =MIB_MAC_ADDR ; priv->mib_buf.size =ETH_ALEN ; priv->mib_buf.index = offsetof(struct mib_mac_addr , group_addr) + n *ETH_ALEN ;memcpy (priv->mib_buf.data, addr,ETH_ALEN ); ret =at76_set_mib (priv, &priv->mib_buf);if (ret <0 ) -err ("%s: set_mib (MIB_MAC_ADD, group_addr) failed: %d" , +err ("%s: set_mib (MIB_MAC_ADDR, group_addr) failed: %d" , priv->netdev->name, ret);/* I do not know anything about the group_addr_status field... (oku) */ memset (&priv->mib_buf,0 ,sizeof (struct set_mib_buffer )); - priv->mib_buf.type =MIB_MAC_ADD ; + priv->mib_buf.type =MIB_MAC_ADDR ; priv->mib_buf.size =1 ; priv->mib_buf.index = offsetof(struct mib_mac_addr , group_addr_status) + n; priv->mib_buf.data[0 ] =1 ; ret =at76_set_mib (priv, &priv->mib_buf);if (ret <0 ) -err ("%s: set_mib (MIB_MAC_ADD, group_addr_status) failed: %d" , +err ("%s: set_mib (MIB_MAC_ADDR, group_addr_status) failed: %d" , priv->netdev->name, ret);return ret;
@@ -1027,32 +1027,34 @@ static int at76_set_group_address(struct at76_priv *priv, u8 *addr, int n)static int at76_dump_mib_mac_addr (struct at76_priv *priv) { +int i;int ret =0 ; -struct mib_mac_addr *mac_addr = +struct mib_mac_addr *m =kmalloc (sizeof (struct mib_mac_addr ),GFP_KERNEL ); -if (!mac_addr) { +if (!m) { ret = -ENOMEM ; goto exit; } - ret =at76_get_mib (priv->udev,MIB_MAC_ADD , - mac_addr,sizeof (struct mib_mac_addr )); + ret =at76_get_mib (priv->udev,MIB_MAC_ADDR , + m,sizeof (struct mib_mac_addr ));if (ret <0 ) {err ("%s: at76_get_mib (MAC_ADDR) failed: %d" , priv->netdev->name, ret); goto error; } -dbg ("%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x group_addr %s status " -"%d %d %d %d" , priv->netdev->name,mac2str (mac_addr->mac_addr), - mac_addr->res[0 ], mac_addr->res[1 ], -hex2str (mac_addr->group_addr,4 *ETH_ALEN ), - mac_addr->group_addr_status[0 ], mac_addr->group_addr_status[1 ], - mac_addr->group_addr_status[2 ], mac_addr->group_addr_status[3 ]); +at76_dbg (DBG_MIB ,"%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x" , + priv->netdev->name, +mac2str (m->mac_addr), m->res[0 ], m->res[1 ]); +for (i =0 ; i <ARRAY_SIZE (m->group_addr); i++) +at76_dbg (DBG_MIB ,"%s: MIB MAC_ADDR: group addr %d: %s, " +"status %d" , priv->netdev->name, i, +mac2str (m->group_addr[i]), m->group_addr_status[i]); error: -kfree (mac_addr); +kfree (m); exit:return ret; }
drivers/net/wireless/at76_usb.h +1 -1
@@ -86,7 +86,7 @@ enum board_type {#define CMD_GETOPMODE 0x33#define MIB_LOCAL 0x01 -#define MIB_MAC_ADD 0x02 +#define MIB_MAC_ADDR 0x02#define MIB_MAC 0x03#define MIB_MAC_MGMT 0x05#define MIB_MAC_WEP 0x06
PATCH 27/35 Remove unneeded braces, found by checkpatch.pl
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/wireless/at76_usb.c +1 -2
@@ -3407,11 +3407,10 @@ static int at76_submit_rx_urb(struct at76_priv *priv) } exit: -if (ret <0 && ret != -ENODEV ) { +if (ret <0 && ret != -ENODEV )printk (KERN_ERR "%s: cannot submit rx urb - please unload the " "driver and/or power cycle the device\n" , priv->netdev->name); - }return ret; }
PATCH 28/35 Convert dbg() to at76_dbg() or remove it
In reply to Pavel RoskinUsing two debug macros is inconsistent. Besides, dbg() only prints something if DEBUG is defined.
---
drivers/net/wireless/at76_usb.c | 283 ++++++++++++++++++--------------------- 1 files changed, 127 insertions(+), 156 deletions(-)
drivers/net/wireless/at76_usb.c +127 -156
@@ -1063,40 +1063,40 @@ static int at76_dump_mib_mac_wep(struct at76_priv *priv) {int ret =0 ;char *defkey; -struct mib_mac_wep *mac_wep = -kmalloc (sizeof (struct mib_mac_wep ),GFP_KERNEL ); +struct mib_mac_wep *m =kmalloc (sizeof (struct mib_mac_wep ),GFP_KERNEL ); -if (!mac_wep) { +if (!m) { ret = -ENOMEM ; goto exit; } - ret =at76_get_mib (priv->udev,MIB_MAC_WEP , mac_wep, -sizeof (struct mib_mac_wep )); + ret = +at76_get_mib (priv->udev,MIB_MAC_WEP , m, +sizeof (struct mib_mac_wep ));if (ret <0 ) {err ("%s: at76_get_mib (MAC_WEP) failed: %d" , priv->netdev->name, ret); goto error; } -if (mac_wep->wep_default_key_id <4 ) +if (m->wep_default_key_id <4 ) defkey = -hex2str (mac_wep-> - wep_default_keyvalue[mac_wep->wep_default_key_id], - mac_wep->encryption_level ==2 ?13 :5 ); +hex2str (m-> + wep_default_keyvalue[m->wep_default_key_id], + m->encryption_level ==2 ?13 :5 );else defkey ="<invalid key id>" ; -dbg ("%s: MIB MAC_WEP: priv_invoked %u def_key_id %u key_len %u " -"excl_unencr %u wep_icv_err %u wep_excluded %u encr_level %u " -"key %d: %s" , priv->netdev->name, mac_wep->privacy_invoked, - mac_wep->wep_default_key_id, mac_wep->wep_key_mapping_len, - mac_wep->exclude_unencrypted, -le32_to_cpu (mac_wep->wep_icv_error_count), -le32_to_cpu (mac_wep->wep_excluded_count), mac_wep->encryption_level, - mac_wep->wep_default_key_id, defkey); +at76_dbg (DBG_MIB ,"%s: MIB MAC_WEP: priv_invoked %u def_key_id %u " +"key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u " +"encr_level %u key %d: %s" , priv->netdev->name, + m->privacy_invoked, m->wep_default_key_id, + m->wep_key_mapping_len, m->exclude_unencrypted, +le32_to_cpu (m->wep_icv_error_count), +le32_to_cpu (m->wep_excluded_count), m->encryption_level, + m->wep_default_key_id, defkey); error: -kfree (mac_wep); +kfree (m); exit:return ret; }
@@ -1104,51 +1104,43 @@ exit:static int at76_dump_mib_mac_mgmt (struct at76_priv *priv) {int ret =0 ; -struct mib_mac_mgmt *mac_mgmt = +struct mib_mac_mgmt *m =kmalloc (sizeof (struct mib_mac_mgmt ),GFP_KERNEL );char country_string[4 ]; -if (!mac_mgmt) { +if (!m) { ret = -ENOMEM ; goto exit; } - ret =at76_get_mib (priv->udev,MIB_MAC_MGMT , mac_mgmt, + ret =at76_get_mib (priv->udev,MIB_MAC_MGMT , m,sizeof (struct mib_mac_mgmt ));if (ret <0 ) {err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); goto error; } -memcpy (&country_string, mac_mgmt->country_string,3 ); +memcpy (&country_string, m->country_string,3 ); country_string[3 ] ='\0' ; -dbg ("%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration %d " -"medium_occupancy_limit %d station_id 0x%x ATIM_window %d " -"CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d " -"current_bssid %s current_essid %s current_bss_type %d " -"pm_mode %d ibss_change %d res %d " -"multi_domain_capability_implemented %d " -"international_roaming %d country_string %s" , - priv->netdev->name, -le16_to_cpu (mac_mgmt->beacon_period), -le16_to_cpu (mac_mgmt->CFP_max_duration), -le16_to_cpu (mac_mgmt->medium_occupancy_limit), -le16_to_cpu (mac_mgmt->station_id), -le16_to_cpu (mac_mgmt->ATIM_window), - mac_mgmt->CFP_mode, - mac_mgmt->privacy_option_implemented, - mac_mgmt->DTIM_period, - mac_mgmt->CFP_period, -mac2str (mac_mgmt->current_bssid), -hex2str (mac_mgmt->current_essid,IW_ESSID_MAX_SIZE ), - mac_mgmt->current_bss_type, - mac_mgmt->power_mgmt_mode, - mac_mgmt->ibss_change, - mac_mgmt->res, - mac_mgmt->multi_domain_capability_implemented, - mac_mgmt->multi_domain_capability_enabled, country_string); +at76_dbg (DBG_MIB ,"%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration " +"%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d " +"CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d " +"current_bssid %s current_essid %s current_bss_type %d " +"pm_mode %d ibss_change %d res %d " +"multi_domain_capability_implemented %d " +"international_roaming %d country_string %s" , + priv->netdev->name,le16_to_cpu (m->beacon_period), +le16_to_cpu (m->CFP_max_duration), +le16_to_cpu (m->medium_occupancy_limit), +le16_to_cpu (m->station_id),le16_to_cpu (m->ATIM_window), + m->CFP_mode, m->privacy_option_implemented, m->DTIM_period, + m->CFP_period,mac2str (m->current_bssid), +hex2str (m->current_essid,IW_ESSID_MAX_SIZE ), + m->current_bss_type, m->power_mgmt_mode, m->ibss_change, + m->res, m->multi_domain_capability_implemented, + m->multi_domain_capability_enabled, country_string); error: -kfree (mac_mgmt); +kfree (m); exit:return ret; }
@@ -1156,44 +1148,38 @@ exit:static int at76_dump_mib_mac (struct at76_priv *priv) {int ret =0 ; -struct mib_mac *mac =kmalloc (sizeof (struct mib_mac ),GFP_KERNEL ); +struct mib_mac *m =kmalloc (sizeof (struct mib_mac ),GFP_KERNEL ); -if (!mac) { +if (!m) { ret = -ENOMEM ; goto exit; } - ret =at76_get_mib (priv->udev,MIB_MAC , mac,sizeof (struct mib_mac )); + ret =at76_get_mib (priv->udev,MIB_MAC , m,sizeof (struct mib_mac ));if (ret <0 ) {err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); goto error; } -dbg ("%s: MIB MAC: max_tx_msdu_lifetime %d max_rx_lifetime %d " -"frag_threshold %d rts_threshold %d cwmin %d cwmax %d " -"short_retry_time %d long_retry_time %d scan_type %d " -"scan_channel %d probe_delay %u min_channel_time %d " -"max_channel_time %d listen_int %d desired_ssid %s " -"desired_bssid %s desired_bsstype %d" , - priv->netdev->name, -le32_to_cpu (mac->max_tx_msdu_lifetime), -le32_to_cpu (mac->max_rx_lifetime), -le16_to_cpu (mac->frag_threshold), -le16_to_cpu (mac->rts_threshold), -le16_to_cpu (mac->cwmin), -le16_to_cpu (mac->cwmax), - mac->short_retry_time, - mac->long_retry_time, - mac->scan_type, - mac->scan_channel, -le16_to_cpu (mac->probe_delay), -le16_to_cpu (mac->min_channel_time), -le16_to_cpu (mac->max_channel_time), -le16_to_cpu (mac->listen_interval), -hex2str (mac->desired_ssid,IW_ESSID_MAX_SIZE ), -mac2str (mac->desired_bssid), mac->desired_bsstype); +at76_dbg (DBG_MIB ,"%s: MIB MAC: max_tx_msdu_lifetime %d " +"max_rx_lifetime %d frag_threshold %d rts_threshold %d " +"cwmin %d cwmax %d short_retry_time %d long_retry_time %d " +"scan_type %d scan_channel %d probe_delay %u " +"min_channel_time %d max_channel_time %d listen_int %d " +"desired_ssid %s desired_bssid %s desired_bsstype %d" , + priv->netdev->name,le32_to_cpu (m->max_tx_msdu_lifetime), +le32_to_cpu (m->max_rx_lifetime), +le16_to_cpu (m->frag_threshold),le16_to_cpu (m->rts_threshold), +le16_to_cpu (m->cwmin),le16_to_cpu (m->cwmax), + m->short_retry_time, m->long_retry_time, m->scan_type, + m->scan_channel,le16_to_cpu (m->probe_delay), +le16_to_cpu (m->min_channel_time), +le16_to_cpu (m->max_channel_time), +le16_to_cpu (m->listen_interval), +hex2str (m->desired_ssid,IW_ESSID_MAX_SIZE ), +mac2str (m->desired_bssid), m->desired_bsstype); error: -kfree (mac); +kfree (m); exit:return ret; }
@@ -1201,38 +1187,35 @@ exit:static int at76_dump_mib_phy (struct at76_priv *priv) {int ret =0 ; -struct mib_phy *phy =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); +struct mib_phy *m =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); -if (!phy) { +if (!m) { ret = -ENOMEM ; goto exit; } - ret =at76_get_mib (priv->udev,MIB_PHY , phy,sizeof (struct mib_phy )); + ret =at76_get_mib (priv->udev,MIB_PHY , m,sizeof (struct mib_phy ));if (ret <0 ) {err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); goto error; } -dbg ("%s: MIB PHY: ed_threshold %d slot_time %d sifs_time %d " -"preamble_length %d plcp_header_length %d mpdu_max_length %d " -"cca_mode_supported %d operation_rate_set " -"0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d " -"phy_type %d current_reg_domain %d" , - priv->netdev->name, -le32_to_cpu (phy->ed_threshold), -le16_to_cpu (phy->slot_time), -le16_to_cpu (phy->sifs_time), -le16_to_cpu (phy->preamble_length), -le16_to_cpu (phy->plcp_header_length), -le16_to_cpu (phy->mpdu_max_length), -le16_to_cpu (phy->cca_mode_supported), - phy->operation_rate_set[0 ], phy->operation_rate_set[1 ], - phy->operation_rate_set[2 ], phy->operation_rate_set[3 ], - phy->channel_id, - phy->current_cca_mode, phy->phy_type, phy->current_reg_domain); +at76_dbg (DBG_MIB ,"%s: MIB PHY: ed_threshold %d slot_time %d " +"sifs_time %d preamble_length %d plcp_header_length %d " +"mpdu_max_length %d cca_mode_supported %d operation_rate_set " +"0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d " +"phy_type %d current_reg_domain %d" , + priv->netdev->name,le32_to_cpu (m->ed_threshold), +le16_to_cpu (m->slot_time),le16_to_cpu (m->sifs_time), +le16_to_cpu (m->preamble_length), +le16_to_cpu (m->plcp_header_length), +le16_to_cpu (m->mpdu_max_length), +le16_to_cpu (m->cca_mode_supported), m->operation_rate_set[0 ], + m->operation_rate_set[1 ], m->operation_rate_set[2 ], + m->operation_rate_set[3 ], m->channel_id, m->current_cca_mode, + m->phy_type, m->current_reg_domain); error: -kfree (phy); +kfree (m); exit:return ret; }
@@ -1240,28 +1223,26 @@ exit:static int at76_dump_mib_local (struct at76_priv *priv) {int ret =0 ; -struct mib_local *local =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); +struct mib_local *m =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); -if (!local) { +if (!m) { ret = -ENOMEM ; goto exit; } - ret =at76_get_mib (priv->udev,MIB_LOCAL , local, -sizeof (struct mib_local )); + ret =at76_get_mib (priv->udev,MIB_LOCAL , m,sizeof (struct mib_local ));if (ret <0 ) {err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); goto error; } -dbg ("%s: MIB PHY: beacon_enable %d txautorate_fallback %d " -"ssid_size %d promiscuous_mode %d preamble_type %d" , - priv->netdev->name, - local->beacon_enable, - local->txautorate_fallback, - local->ssid_size, local->promiscuous_mode, local->preamble_type); +at76_dbg (DBG_MIB ,"%s: MIB PHY: beacon_enable %d " +"txautorate_fallback %d ssid_size %d promiscuous_mode %d " +"preamble_type %d" , priv->netdev->name, m->beacon_enable, + m->txautorate_fallback, m->ssid_size, m->promiscuous_mode, + m->preamble_type); error: -kfree (local); +kfree (m); exit:return ret; }
@@ -2934,19 +2915,18 @@ static int at76_iw_set_debug(struct net_device *netdev,if (ptr == extra) val =DBG_DEFAULTS ; -dbg ("%s: AT76_SET_DEBUG input %d: %s -> 0x%x" , - netdev->name, data->length, extra, val); +at76_dbg (DBG_IOCTL ,"%s: AT76_SET_DEBUG input %d: %s -> 0x%x" , + netdev->name, data->length, extra, val); }else val =DBG_DEFAULTS ; -dbg ("%s: AT76_SET_DEBUG, old 0x%x, new 0x%x" , - netdev->name, at76_debug, val); +at76_dbg (DBG_IOCTL ,"%s: AT76_SET_DEBUG, old 0x%x, new 0x%x" , + netdev->name, at76_debug, val);/* jal: some more output to pin down lockups */ -dbg ("%s: netif running %d queue_stopped %d carrier_ok %d" , - netdev->name, -netif_running (netdev), -netif_queue_stopped (netdev),netif_carrier_ok (netdev)); +at76_dbg (DBG_IOCTL ,"%s: netif running %d queue_stopped %d " +"carrier_ok %d" , netdev->name,netif_running (netdev), +netif_queue_stopped (netdev),netif_carrier_ok (netdev)); at76_debug = val;
@@ -4025,39 +4005,38 @@ static int at76_startup_device(struct at76_priv *priv) {struct at76_card_config *ccfg = &priv->card_config;int ret; - -if (at76_debug &DBG_PARAMS ) { -char ossid[IW_ESSID_MAX_SIZE +1 ]; - -/* make priv->essid printable */ -BUG_ON (priv->essid_size >IW_ESSID_MAX_SIZE ); -memcpy (ossid, priv->essid, priv->essid_size); - ossid[priv->essid_size] ='\0' ; - -dbg ("%s param: ssid %s (%s) mode %s ch %d wep %s key %d " -"keylen %d" , priv->netdev->name, ossid, -hex2str (priv->essid,IW_ESSID_MAX_SIZE ), - priv->iw_mode ==IW_MODE_ADHOC ?"adhoc" :"infra" , - priv->channel, priv->wep_enabled ?"enabled" :"disabled" , - priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]); -dbg ("%s param: preamble %s rts %d retry %d frag %d " -"txrate %s auth_mode %d" , priv->netdev->name, - preambles[priv->preamble_type], priv->rts_threshold, - priv->short_retry_limit, priv->frag_threshold, - priv->txrate ==TX_RATE_1MBIT ?"1MBit" : priv->txrate == -TX_RATE_2MBIT ?"2MBit" : priv->txrate == -TX_RATE_5_5MBIT ?"5.5MBit" : priv->txrate == -TX_RATE_11MBIT ?"11MBit" : priv->txrate == -TX_RATE_AUTO ?"auto" :"<invalid>" , priv->auth_mode); -dbg ("%s param: pm_mode %d pm_period %d auth_mode %s " -"scan_times %d %d scan_mode %s international_roaming %d" , - priv->netdev->name, priv->pm_mode, priv->pm_period, - priv->auth_mode == -WLAN_AUTH_OPEN ?"open" :"shared_secret" , - priv->scan_min_time, priv->scan_max_time, - priv->scan_mode ==SCAN_TYPE_ACTIVE ?"active" :"passive" , - priv->international_roaming); - } +char ossid[IW_ESSID_MAX_SIZE +1 ]; + +/* make priv->essid printable */ +BUG_ON (priv->essid_size >IW_ESSID_MAX_SIZE ); +memcpy (ossid, priv->essid, priv->essid_size); + ossid[priv->essid_size] ='\0' ; + +at76_dbg (DBG_PARAMS , +"%s param: ssid %s (%s) mode %s ch %d wep %s key %d " +"keylen %d" , priv->netdev->name, ossid, +hex2str (priv->essid,IW_ESSID_MAX_SIZE ), + priv->iw_mode ==IW_MODE_ADHOC ?"adhoc" :"infra" , + priv->channel, priv->wep_enabled ?"enabled" :"disabled" , + priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]); +at76_dbg (DBG_PARAMS , +"%s param: preamble %s rts %d retry %d frag %d " +"txrate %s auth_mode %d" , priv->netdev->name, + preambles[priv->preamble_type], priv->rts_threshold, + priv->short_retry_limit, priv->frag_threshold, + priv->txrate ==TX_RATE_1MBIT ?"1MBit" : priv->txrate == +TX_RATE_2MBIT ?"2MBit" : priv->txrate == +TX_RATE_5_5MBIT ?"5.5MBit" : priv->txrate == +TX_RATE_11MBIT ?"11MBit" : priv->txrate == +TX_RATE_AUTO ?"auto" :"<invalid>" , priv->auth_mode); +at76_dbg (DBG_PARAMS , +"%s param: pm_mode %d pm_period %d auth_mode %s " +"scan_times %d %d scan_mode %s international_roaming %d" , + priv->netdev->name, priv->pm_mode, priv->pm_period, + priv->auth_mode ==WLAN_AUTH_OPEN ?"open" :"shared_secret" , + priv->scan_min_time, priv->scan_max_time, + priv->scan_mode ==SCAN_TYPE_ACTIVE ?"active" :"passive" , + priv->international_roaming);memset (ccfg,0 ,sizeof (struct at76_card_config )); ccfg->promiscuous_mode =0 ;
@@ -4758,9 +4737,6 @@ static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode) i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data; -dbg ("%s: ENTRY skb len %d data %s" , __func__, - skb->len,hex2str (skb->data,64 )); -/* That would be the ethernet header if the hardware converted * the frame for us. Make sure the source and the destination * match the 802.11 header. Which hardware does it? */
@@ -4802,11 +4778,6 @@ static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode) } skb->protocol =eth_type_trans (skb, skb->dev); - -dbg ("%s: EXIT skb da %s sa %s proto 0x%04x len %d data %s" , - __func__,mac2str (eth_hdr (skb)->h_dest), -mac2str (eth_hdr (skb)->h_source),ntohs (skb->protocol), skb->len, -hex2str (skb->data,64 )); }/* Check for fragmented data in priv->rx_skb. If the packet was no fragment
PATCH 29/35 Eliminate at76_dbg_dumpbuf() in favor of hex2str()
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 27 ++++----------------------- 1 files changed, 4 insertions(+), 23 deletions(-)
drivers/net/wireless/at76_usb.c +4 -23
@@ -4708,24 +4708,6 @@ static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)return ; } -static void at76_dbg_dumpbuf (const char *tag,const u8 *buf,int size) -{ -int i; - -if (!at76_debug) -return ; - -for (i =0 ; i < size; i++) { -if ((i %8 ) ==0 ) { -if (i) -pr_debug ("\n" ); -pr_debug (DRIVER_NAME ": %s: " , tag); - } -pr_debug ("%02x " , buf[i]); - } -pr_debug ("\n" ); -} -/* Convert the 802.11 header into an ethernet-style header, make skb * ready for consumption by netif_rx() */ static void at76_ieee80211_to_eth (struct sk_buff *skb,int iw_mode)
@@ -5005,12 +4987,11 @@ static void at76_rx_data(struct at76_priv *priv)struct ieee80211_hdr_3addr *i802_11_hdr;int length =le16_to_cpu (buf->wlength); -at76_dbg (DBG_RX_DATA ,"%s received data packet:" , netdev->name); -if (at76_debug &DBG_RX_DATA ) -at76_dbg_dumpbuf (" rxhdr" , skb->data,AT76_RX_HDRLEN ); +at76_dbg (DBG_RX_DATA ,"%s received data packet: %s" , netdev->name, +hex2str (skb->data,AT76_RX_HDRLEN )); -if (at76_debug &DBG_RX_DATA_CONTENT ) -at76_dbg_dumpbuf ("packet" , skb->data +AT76_RX_HDRLEN , length); +at76_dbg (DBG_RX_DATA_CONTENT ,"rx packet: %s" , +hex2str (skb->data +AT76_RX_HDRLEN , length)); skb =at76_check_for_rx_frags (priv);if (!skb)
PATCH 30/35 Eliminate pr_debug() in favor of at76_dbg()
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-)
drivers/net/wireless/at76_usb.c +9 -10
@@ -1818,19 +1818,18 @@ static void at76_dump_bss_table(struct at76_priv *priv)spin_lock_irqsave (&priv->bss_list_spinlock, flags); -pr_debug ("%s BSS table (curr=%p):" , priv->netdev->name, priv->curr_bss); +at76_dbg (DBG_BSS_TABLE ,"%s BSS table (curr=%p):" , priv->netdev->name, + priv->curr_bss);list_for_each (lptr, &priv->bss_list) { ptr = list_entry(lptr, struct bss_info, list); -pr_debug ("0x%p: bssid %s channel %d ssid %s (%s)" -" capa 0x%04x rates %s rssi %d link %d noise %d" , - ptr,mac2str (ptr->bssid), - ptr->channel, - ptr->ssid, -hex2str (ptr->ssid, ptr->ssid_len), - ptr->capa, -hex2str (ptr->rates, ptr->rates_len), - ptr->rssi, ptr->link_qual, ptr->noise_level); +at76_dbg (DBG_BSS_TABLE , +"0x%p: bssid %s channel %d ssid %s (%s)" +" capa 0x%04x rates %s rssi %d link %d noise %d" , ptr, +mac2str (ptr->bssid), ptr->channel, ptr->ssid, +hex2str (ptr->ssid, ptr->ssid_len), ptr->capa, +hex2str (ptr->rates, ptr->rates_len), ptr->rssi, + ptr->link_qual, ptr->noise_level); }spin_unlock_irqrestore (&priv->bss_list_spinlock, flags); }
PATCH 31/35 Simplify logic in at76_is_hidden_ssid()
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/at76_usb.c +7 -3
@@ -542,9 +542,13 @@ static inline int at76_is_hidden_ssid(u8 *ssid, int length) {static const u8 zeros[32 ]; -return (length ==0 ) || - (length ==1 && *ssid ==' ' ) || - (length >0 && !memcmp (ssid, zeros, length)); +if (length ==0 ) +return 1 ; + +if (length ==1 && ssid[0 ] ==' ' ) +return 1 ; + +return (memcmp (ssid, zeros, length) ==0 ); }static inline void at76_free_bss_list (struct at76_priv *priv)
PATCH 32/35 Massive cleanup of dump functions
In reply to Pavel Roskin---
drivers/net/wireless/at76_usb.c | 195 ++++++++++++++++----------------------- 1 files changed, 79 insertions(+), 116 deletions(-)
drivers/net/wireless/at76_usb.c +79 -116
@@ -1029,24 +1029,22 @@ static int at76_set_group_address(struct at76_priv *priv, u8 *addr, int n) }#endif -static int at76_dump_mib_mac_addr (struct at76_priv *priv) +static void at76_dump_mib_mac_addr (struct at76_priv *priv) {int i; -int ret =0 ; -struct mib_mac_addr *m = -kmalloc (sizeof (struct mib_mac_addr ),GFP_KERNEL ); +int ret; +struct mib_mac_addr *m =kmalloc (sizeof (struct mib_mac_addr ), +GFP_KERNEL ); -if (!m) { - ret = -ENOMEM ; - goto exit; - } +if (!m) +return ; - ret =at76_get_mib (priv->udev,MIB_MAC_ADDR , - m,sizeof (struct mib_mac_addr )); + ret =at76_get_mib (priv->udev,MIB_MAC_ADDR , m, +sizeof (struct mib_mac_addr ));if (ret <0 ) {err ("%s: at76_get_mib (MAC_ADDR) failed: %d" , priv->netdev->name, ret); - goto error; + goto exit; } at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x",
@@ -1056,71 +1054,64 @@ static int at76_dump_mib_mac_addr(struct at76_priv *priv)at76_dbg (DBG_MIB ,"%s: MIB MAC_ADDR: group addr %d: %s, " "status %d" , priv->netdev->name, i,mac2str (m->group_addr[i]), m->group_addr_status[i]); - -error: -kfree (m); exit: -return ret; +kfree (m); } -static int at76_dump_mib_mac_wep (struct at76_priv *priv) +static void at76_dump_mib_mac_wep (struct at76_priv *priv) { -int ret =0 ; -char *defkey; +int i; +int ret; +int key_len;struct mib_mac_wep *m =kmalloc (sizeof (struct mib_mac_wep ),GFP_KERNEL ); -if (!m) { - ret = -ENOMEM ; - goto exit; - } - ret = -at76_get_mib (priv->udev,MIB_MAC_WEP , m, -sizeof (struct mib_mac_wep )); +if (!m) +return ; + + ret =at76_get_mib (priv->udev,MIB_MAC_WEP , m, +sizeof (struct mib_mac_wep ));if (ret <0 ) {err ("%s: at76_get_mib (MAC_WEP) failed: %d" , priv->netdev->name, ret); - goto error; + goto exit; } -if (m->wep_default_key_id <4 ) - defkey = -hex2str (m-> - wep_default_keyvalue[m->wep_default_key_id], - m->encryption_level ==2 ?13 :5 ); -else - defkey ="<invalid key id>" ; -at76_dbg (DBG_MIB ,"%s: MIB MAC_WEP: priv_invoked %u def_key_id %u " "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u " -"encr_level %u key %d: %s" , priv->netdev->name, +"encr_level %u key %d" , priv->netdev->name, m->privacy_invoked, m->wep_default_key_id, m->wep_key_mapping_len, m->exclude_unencrypted,le32_to_cpu (m->wep_icv_error_count),le32_to_cpu (m->wep_excluded_count), m->encryption_level, - m->wep_default_key_id, defkey); + m->wep_default_key_id); -error: -kfree (m); + key_len = (m->encryption_level ==1 ) ? +WEP_SMALL_KEY_LEN :WEP_LARGE_KEY_LEN ; + +for (i =0 ; i <WEP_KEYS ; i++) +at76_dbg (DBG_MIB ,"%s: MIB MAC_WEP: key %d: %s" , + priv->netdev->name, i, +hex2str (m->wep_default_keyvalue[i], key_len)); exit: -return ret; +kfree (m); } -static int at76_dump_mib_mac_mgmt (struct at76_priv *priv) +static void at76_dump_mib_mac_mgmt (struct at76_priv *priv) { -int ret =0 ; -struct mib_mac_mgmt *m = -kmalloc (sizeof (struct mib_mac_mgmt ),GFP_KERNEL ); +int ret; +struct mib_mac_mgmt *m =kmalloc (sizeof (struct mib_mac_mgmt ), +GFP_KERNEL );char country_string[4 ]; -if (!m) { - ret = -ENOMEM ; - goto exit; - } +if (!m) +return ; + ret =at76_get_mib (priv->udev,MIB_MAC_MGMT , m,sizeof (struct mib_mac_mgmt ));if (ret <0 ) { -err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); - goto error; +err ("%s: at76_get_mib (MAC_MGMT) failed: %d" , + priv->netdev->name, ret); + goto exit; }memcpy (&country_string, m->country_string,3 );
@@ -1143,26 +1134,23 @@ static int at76_dump_mib_mac_mgmt(struct at76_priv *priv) m->current_bss_type, m->power_mgmt_mode, m->ibss_change, m->res, m->multi_domain_capability_implemented, m->multi_domain_capability_enabled, country_string); -error: -kfree (m); exit: -return ret; +kfree (m); } -static int at76_dump_mib_mac (struct at76_priv *priv) +static void at76_dump_mib_mac (struct at76_priv *priv) { -int ret =0 ; +int ret;struct mib_mac *m =kmalloc (sizeof (struct mib_mac ),GFP_KERNEL ); -if (!m) { - ret = -ENOMEM ; - goto exit; - } +if (!m) +return ; ret =at76_get_mib (priv->udev,MIB_MAC , m,sizeof (struct mib_mac ));if (ret <0 ) { -err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); - goto error; +err ("%s: at76_get_mib (MAC) failed: %d" , priv->netdev->name, + ret); + goto exit; } at76_dbg(DBG_MIB, "%s: MIB MAC: max_tx_msdu_lifetime %d "
@@ -1182,26 +1170,23 @@ static int at76_dump_mib_mac(struct at76_priv *priv)le16_to_cpu (m->listen_interval),hex2str (m->desired_ssid,IW_ESSID_MAX_SIZE ), mac2str(m->desired_bssid), m->desired_bsstype); -error: -kfree (m); exit: -return ret; +kfree (m); } -static int at76_dump_mib_phy (struct at76_priv *priv) +static void at76_dump_mib_phy (struct at76_priv *priv) { -int ret =0 ; +int ret;struct mib_phy *m =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); -if (!m) { - ret = -ENOMEM ; - goto exit; - } +if (!m) +return ; ret =at76_get_mib (priv->udev,MIB_PHY , m,sizeof (struct mib_phy ));if (ret <0 ) { -err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); - goto error; +err ("%s: at76_get_mib (PHY) failed: %d" , priv->netdev->name, + ret); + goto exit; } at76_dbg(DBG_MIB, "%s: MIB PHY: ed_threshold %d slot_time %d "
@@ -1218,81 +1203,59 @@ static int at76_dump_mib_phy(struct at76_priv *priv) m->operation_rate_set[1 ], m->operation_rate_set[2 ], m->operation_rate_set[3 ], m->channel_id, m->current_cca_mode, m->phy_type, m->current_reg_domain); -error: -kfree (m); exit: -return ret; +kfree (m); } -static int at76_dump_mib_local (struct at76_priv *priv) +static void at76_dump_mib_local (struct at76_priv *priv) { -int ret =0 ; +int ret;struct mib_local *m =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); -if (!m) { - ret = -ENOMEM ; - goto exit; - } +if (!m) +return ; ret =at76_get_mib (priv->udev,MIB_LOCAL , m,sizeof (struct mib_local ));if (ret <0 ) { -err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); - goto error; +err ("%s: at76_get_mib (LOCAL) failed: %d" , priv->netdev->name, + ret); + goto exit; } -at76_dbg (DBG_MIB ,"%s: MIB PHY: beacon_enable %d " +at76_dbg (DBG_MIB ,"%s: MIB LOCAL: beacon_enable %d " "txautorate_fallback %d ssid_size %d promiscuous_mode %d " "preamble_type %d" , priv->netdev->name, m->beacon_enable, m->txautorate_fallback, m->ssid_size, m->promiscuous_mode, m->preamble_type); -error: -kfree (m); -exit: -return ret; -} - -static int at76_get_mib_mdomain (struct at76_priv *priv,struct mib_mdomain *val) -{ -int ret =0 ; -struct mib_mdomain *mdomain = -kmalloc (sizeof (struct mib_mdomain ),GFP_KERNEL ); - -if (!mdomain) { - ret = -ENOMEM ; - goto exit; - } - - ret =at76_get_mib (priv->udev,MIB_MDOMAIN , mdomain, -sizeof (struct mib_mdomain )); -if (ret <0 ) -err ("%s: at76_get_mib failed: %d" , priv->netdev->name, ret); -else -memcpy (val, mdomain,sizeof (*val)); - -kfree (mdomain); - exit: -return ret; +kfree (m); }static void at76_dump_mib_mdomain (struct at76_priv *priv) {int ret; -struct mib_mdomain mdomain; +struct mib_mdomain *m =kmalloc (sizeof (struct mib_mdomain ),GFP_KERNEL ); - ret =at76_get_mib_mdomain (priv, &mdomain); -if (ret <0 ) { -err ("%s: at76_get_mib_mdomain returned %d" , __func__, ret); +if (!m)return ; + + ret =at76_get_mib (priv->udev,MIB_MDOMAIN , m, +sizeof (struct mib_mdomain )); +if (ret <0 ) { +err ("%s: at76_get_mib (MDOMAIN) failed: %d" , priv->netdev->name, + ret); + goto exit; }at76_dbg (DBG_MIB ,"%s: MIB MDOMAIN: channel_list %s" , priv->netdev->name, -hex2str (mdomain.channel_list,sizeof (mdomain.channel_list))); +hex2str (m->channel_list,sizeof (m->channel_list)));at76_dbg (DBG_MIB ,"%s: MIB MDOMAIN: tx_powerlevel %s" , priv->netdev->name, -hex2str (mdomain.tx_powerlevel,sizeof (mdomain.tx_powerlevel))); +hex2str (m->tx_powerlevel,sizeof (m->tx_powerlevel))); +exit: +kfree (m); }static int at76_get_current_bssid (struct at76_priv *priv)
PATCH 33/35 Remove international roaming support
In reply to Pavel RoskinIt's broken beyond repair and legally dubious.
---
drivers/net/wireless/at76_usb.c | 119 ++++----------------------------------- drivers/net/wireless/at76_usb.h | 8 --- 2 files changed, 13 insertions(+), 114 deletions(-)
drivers/net/wireless/at76_usb.c +13 -106
@@ -1310,9 +1310,8 @@ exit:* at76_start_scan - start a scan * * @use_essid - use the configured ESSID in non passive mode -* @ir_step - international roaming step (0, 1) */ -static int at76_start_scan (struct at76_priv *priv,int use_essid,int ir_step) +static int at76_start_scan (struct at76_priv *priv,int use_essid) {struct at76_req_scan scan;
@@ -1331,10 +1330,7 @@ static int at76_start_scan(struct at76_priv *priv, int use_essid, int ir_step)/* atmelwlandriver differs between scan type 0 and 1 (active/passive) For ad-hoc mode, it uses type 0 only. */ -if (priv->international_roaming ==IR_ON && ir_step ==0 ) - scan.scan_type =SCAN_TYPE_PASSIVE ; -else - scan.scan_type = priv->scan_mode; + scan.scan_type = priv->scan_mode;/* INFO: For probe_delay, not multiplying by 1024 as this will be slightly less than min_channel_time
@@ -1342,11 +1338,7 @@ static int at76_start_scan(struct at76_priv *priv, int use_essid, int ir_step) scan.min_channel_time =cpu_to_le16 (priv->scan_min_time); scan.max_channel_time =cpu_to_le16 (priv->scan_max_time); scan.probe_delay =cpu_to_le16 (priv->scan_min_time *1000 ); - -if (priv->international_roaming ==IR_ON && ir_step ==1 ) - scan.international_scan =0 ; -else - scan.international_scan = priv->international_roaming; + scan.international_scan =0 ;/* other values are set to 0 for type 0 */
@@ -1373,7 +1365,7 @@ static int at76_start_monitor(struct at76_priv *priv) scan.channel = priv->channel; scan.scan_type =SCAN_TYPE_PASSIVE ; - scan.international_scan = priv->international_roaming; + scan.international_scan =0 ; ret =at76_set_card_command (priv->udev,CMD_SCAN , &scan,sizeof (scan));if (ret >=0 )
@@ -1976,14 +1968,10 @@ static int at76_iw_handler_set_freq(struct net_device *netdev,* either that or an invalid frequency was * provided by the user */ ret = -EINVAL ; - else if (!priv->international_roaming) { -if (!(priv->domain->channel_map & (1 << (chan -1 )))) { -printk (KERN_INFO -"%s: channel %d not allowed for domain %s " -"(and international_roaming is OFF)\n" , - priv->netdev->name, chan, priv->domain->name); - ret = -EINVAL ; - } + else if (!(priv->domain->channel_map & (1 << (chan - 1)))) { +printk (KERN_INFO "%s: channel %d not allowed for domain %s\n" , + priv->netdev->name, chan, priv->domain->name); + ret = -EINVAL ; }if (ret == -EIWCOMMIT ) {
@@ -3002,59 +2990,6 @@ static int at76_iw_get_scan_mode(struct net_device *netdev,return 0 ; } -static int at76_set_iroaming (struct at76_priv *priv,int onoff) -{ -int ret =0 ; - -memset (&priv->mib_buf,0 ,sizeof (struct set_mib_buffer )); - priv->mib_buf.type =MIB_MAC_MGMT ; - priv->mib_buf.size =1 ; - priv->mib_buf.index = - offsetof(struct mib_mac_mgmt , multi_domain_capability_enabled); - priv->mib_buf.data[0 ] = onoff; - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -err ("%s: set_mib (intl_roaming_enable) failed: %d" , - priv->netdev->name, ret); - -return ret; -} - -static int at76_iw_set_intl_roaming (struct net_device *netdev, -struct iw_request_info *info,char *name, -char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int val = *((int *)name); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_INTL_ROAMING - mode %s" , - netdev->name, (val ==IR_OFF ) ?"off" : - (val ==IR_ON ) ?"on" :"<invalid>" ); - -if (val !=IR_OFF && val !=IR_ON ) - ret = -EINVAL ; -else { -if (priv->international_roaming != val) { - priv->international_roaming = val; -at76_set_iroaming (priv, val); - } - } - -return ret; -} - -static int at76_iw_get_intl_roaming (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int *param = (int *)extra; - - param[0 ] = priv->international_roaming; -return 0 ; -} -#define AT76_SET_HANDLER (h, f) [h - SIOCIWFIRST] = (iw_handler) f/* Standard wireless handlers */
@@ -3105,8 +3040,6 @@ static const iw_handler at76_priv_handlers[] = {AT76_SET_PRIV (AT76_GET_SCAN_TIMES , at76_iw_get_scan_times),AT76_SET_PRIV (AT76_SET_SCAN_MODE , at76_iw_set_scan_mode), AT76_SET_PRIV(AT76_GET_SCAN_MODE, at76_iw_get_scan_mode), -AT76_SET_PRIV (AT76_SET_INTL_ROAMING , at76_iw_set_intl_roaming), - AT76_SET_PRIV(AT76_GET_INTL_ROAMING, at76_iw_get_intl_roaming), };/* Names and arguments of private wireless handlers */
@@ -3146,12 +3079,6 @@ static const struct iw_priv_args at76_priv_args[] = { {AT76_GET_SCAN_MODE , 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_scan_mode"}, - - {AT76_SET_INTL_ROAMING, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_intl_scan"}, - - {AT76_GET_INTL_ROAMING, - 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_intl_scan"} }; static const struct iw_handler_def at76_handler_def = {
@@ -3805,21 +3732,8 @@ static void at76_dwork_get_scan(struct work_struct *work)at76_dump_bss_table (priv);switch (priv->scan_runs) { -case 1 : -WARN_ON (!priv->international_roaming); - ret =at76_start_scan (priv,0 ,0 ); -if (ret <0 ) -err ("%s: %s: start_scan (IR) failed with %d" , - priv->netdev->name, __func__, ret); -at76_dbg (DBG_MGMT_TIMER , -"%s:%d: starting mgmt_timer for %d ticks" , - __func__, __LINE__,SCAN_POLL_INTERVAL ); -schedule_delayed_work (&priv->dwork_get_scan, -SCAN_POLL_INTERVAL ); -break ; -case 2 : - ret =at76_start_scan (priv,0 ,1 ); + ret =at76_start_scan (priv,0 );if (ret <0 )err ("%s: %s: start_scan (ANY) failed with %d" , priv->netdev->name, __func__, ret);
@@ -3997,12 +3911,11 @@ static int at76_startup_device(struct at76_priv *priv) TX_RATE_AUTO ? "auto" : "<invalid>", priv->auth_mode);at76_dbg (DBG_PARAMS ,"%s param: pm_mode %d pm_period %d auth_mode %s " -"scan_times %d %d scan_mode %s international_roaming %d" , +"scan_times %d %d scan_mode %s" , priv->netdev->name, priv->pm_mode, priv->pm_period, priv->auth_mode ==WLAN_AUTH_OPEN ?"open" :"shared_secret" , priv->scan_min_time, priv->scan_max_time, - priv->scan_mode ==SCAN_TYPE_ACTIVE ?"active" :"passive" , - priv->international_roaming); + priv->scan_mode ==SCAN_TYPE_ACTIVE ?"active" :"passive" );memset (ccfg,0 ,sizeof (struct at76_card_config )); ccfg->promiscuous_mode =0 ;
@@ -4075,10 +3988,6 @@ static int at76_startup_device(struct at76_priv *priv)if (ret <0 )return ret; - ret =at76_set_iroaming (priv, priv->international_roaming); -if (ret <0 ) -return ret; -at76_set_monitor_mode (priv);if (at76_debug &DBG_MIB ) {
@@ -4132,11 +4041,11 @@ static void at76_work_start_scan(struct work_struct *work)* otherwise simply rely on at76_bss_list_timeout */ if (priv->scan_state ==SCAN_IN_PROGRESS ) {at76_free_bss_list (priv); - priv->scan_runs = priv->international_roaming ?1 :2 ; + priv->scan_runs =2 ; }else priv->scan_runs =3 ; - ret =at76_start_scan (priv,1 ,1 ); + ret =at76_start_scan (priv,1 );if (ret <0 ) err("%s: %s: start_scan failed with %d",
@@ -5364,8 +5273,6 @@ static int at76_init_new_device(struct at76_priv *priv,/* init. netdev->dev_addr */ memcpy (netdev->dev_addr, priv->mac_addr,ETH_ALEN ); -/* initializing */ - priv->international_roaming =IR_OFF ; priv->channel =DEF_CHANNEL ; priv->iw_mode =IW_MODE_INFRA ;memset (priv->essid,0 ,IW_ESSID_MAX_SIZE );
drivers/net/wireless/at76_usb.h +0 -8
@@ -55,9 +55,6 @@ enum board_type {/* scan mode (0 - active, 1 - passive) */ #define AT76_SET_SCAN_MODE (SIOCIWFIRSTPRIV + 8)#define AT76_GET_SCAN_MODE (SIOCIWFIRSTPRIV + 9) -/* international roaming (0 - disabled, 1 - enabled */ -#define AT76_SET_INTL_ROAMING (SIOCIWFIRSTPRIV + 10) -#define AT76_GET_INTL_ROAMING (SIOCIWFIRSTPRIV + 11)#define CMD_STATUS_IDLE 0x00#define CMD_STATUS_COMPLETE 0x01
@@ -114,10 +111,6 @@ enum board_type {#define AT76_PM_ON 2#define AT76_PM_SMART 3 -/* international roaming state */ -#define IR_OFF 0 -#define IR_ON 1 -struct hwcfg_r505 {u8 cr39_values[14 ];u8 reserved1[14 ];
@@ -535,7 +528,6 @@ struct at76_priv {u32 pm_period;/* power management period in microseconds */ struct reg_domain const *domain;/* reg domain description */ -int international_roaming;/* iwspy support */ spinlock_t spy_spinlock;
PATCH 34/35 Don't do additional MIB dumps if DEBUG is defined
In reply to Pavel RoskinThey are already printed from at76_startup_device(), which should be enough.
---
drivers/net/wireless/at76_usb.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/net/wireless/at76_usb.c +0 -7
@@ -1823,10 +1823,6 @@ static void at76_work_assoc_done(struct work_struct *work)at76_set_associd (priv, priv->assoc_id);at76_set_listen_interval (priv, (u16 )pm_period_beacon); -#ifdef DEBUG -at76_dump_mib_mac (priv); -at76_dump_mib_mac_mgmt (priv); -#endif }schedule_delayed_work (&priv->dwork_beacon,BEACON_TIMEOUT ); }
@@ -3305,9 +3301,6 @@ static int at76_open(struct net_device *netdev)at76_dbg (DBG_PROGRESS ,"%s: set new MAC addr %s" , netdev->name,mac2str (netdev->dev_addr)); } -#ifdef DEBUG -at76_dump_mib_mac_addr (priv); -#endif priv->scan_state =SCAN_IDLE ; priv->last_scan = jiffies;
PATCH 35/35 Replace scan_runs with scan_need_any
In reply to Pavel RoskinIt's more meaningful than a number.
---
drivers/net/wireless/at76_usb.c | 22 +++++++--------------- drivers/net/wireless/at76_usb.h | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-)
drivers/net/wireless/at76_usb.c +7 -15
@@ -3700,9 +3700,9 @@ static void at76_dwork_get_scan(struct work_struct *work)further down the line and stop this cycle */ }at76_dbg (DBG_PROGRESS , -"%s %s: got cmd_status %d (state %s, scan_runs %d)" , +"%s %s: got cmd_status %d (state %s, need_any %d)" , priv->netdev->name, __func__, status, - mac_states[priv->mac_state], priv->scan_runs); + mac_states[priv->mac_state], priv->scan_need_any);if (status !=CMD_STATUS_COMPLETE ) { if ((status != CMD_STATUS_IN_PROGRESS) &&
@@ -3723,9 +3723,8 @@ static void at76_dwork_get_scan(struct work_struct *work)if (at76_debug &DBG_BSS_TABLE )at76_dump_bss_table (priv); -switch (priv->scan_runs) { -case 2 : +if (priv->scan_need_any) { ret =at76_start_scan (priv,0 );if (ret <0 ) err("%s: %s: start_scan (ANY) failed with %d",
@@ -3735,22 +3734,15 @@ static void at76_dwork_get_scan(struct work_struct *work) __func__, __LINE__, SCAN_POLL_INTERVAL);schedule_delayed_work (&priv->dwork_get_scan,SCAN_POLL_INTERVAL ); -break ; - -case 3 : + priv->scan_need_any =0 ; + }else { priv->scan_state =SCAN_COMPLETED ;/* report the end of scan to user space */ at76_iwevent_scan_complete (priv->netdev);at76_set_mac_state (priv,MAC_JOINING );schedule_work (&priv->work_join); -break ; - -default : -err ("unexpected priv->scan_runs %d" , priv->scan_runs); } - priv->scan_runs++; - exit:mutex_unlock (&priv->mtx); }
@@ -4034,9 +4026,9 @@ static void at76_work_start_scan(struct work_struct *work)* otherwise simply rely on at76_bss_list_timeout */ if (priv->scan_state ==SCAN_IN_PROGRESS ) {at76_free_bss_list (priv); - priv->scan_runs =2 ; + priv->scan_need_any =1 ; }else - priv->scan_runs =3 ; + priv->scan_need_any =0 ; ret =at76_start_scan (priv,1 );
drivers/net/wireless/at76_usb.h +1 -1
@@ -495,7 +495,7 @@ struct at76_priv {int scan_min_time;/* scan min channel time */ int scan_max_time;/* scan max channel time */ int scan_mode;/* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */ -int scan_runs;/* counts how many scans are started */ +int scan_need_any;/* if set, need to scan for any ESSID */ /* the list we got from scanning */ spinlock_t bss_list_spinlock;/* protects bss_list operations */