Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6

* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (89 commits)
myri10ge: update driver version
myri10ge: report when the link partner is running in Myrinet mode
myri10ge: limit the number of recoveries
NetXen: Fix link status messages
Revert "[netdrvr e100] experiment with doing RX in a similar manner to eepro100"
[PATCH] libertas: convert libertas_mpp into anycast_mask
[PATCH] libertas: actually send mesh frames to mesh netdev
[PATCH] libertas: deauthenticate from AP in channel switch
[PATCH] libertas: pull current channel from firmware on mesh autostart
[PATCH] libertas: reduce SSID and BSSID mixed-case abuse
[PATCH] libertas: remove WPA_SUPPLICANT structure
[PATCH] libertas: remove structure WLAN_802_11_SSID and libertas_escape_essid
[PATCH] libertas: tweak association debug output
[PATCH] libertas: fix big-endian associate command.
[PATCH] libertas: don't byte-swap firmware version number. It's a byte array.
[PATCH] libertas: more endianness fixes, in tx.c this time
[PATCH] libertas: More endianness fixes.
[PATCH] libertas: first pass at fixing up endianness issues
[PATCH] libertas: sparse fixes
[PATCH] libertas: fix character set in README
...

+4008 -3785
+63 -9
drivers/net/e100.c
··· 285 285 rus_mask = 0x3C, 286 286 }; 287 287 288 + enum ru_state { 289 + RU_SUSPENDED = 0, 290 + RU_RUNNING = 1, 291 + RU_UNINITIALIZED = -1, 292 + }; 293 + 288 294 enum scb_stat_ack { 289 295 stat_ack_not_ours = 0x00, 290 296 stat_ack_sw_gen = 0x04, ··· 532 526 struct rx *rx_to_use; 533 527 struct rx *rx_to_clean; 534 528 struct rfd blank_rfd; 529 + enum ru_state ru_running; 535 530 536 531 spinlock_t cb_lock ____cacheline_aligned; 537 532 spinlock_t cmd_lock; ··· 954 947 ((nic->mac >= mac_82558_D101_A4) ? cb_cid : cb_i)); 955 948 956 949 /* Template for a freshly allocated RFD */ 957 - nic->blank_rfd.command = cpu_to_le16(cb_el & cb_s); 950 + nic->blank_rfd.command = cpu_to_le16(cb_el); 958 951 nic->blank_rfd.rbd = 0xFFFFFFFF; 959 952 nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN); 960 953 ··· 1749 1742 return 0; 1750 1743 } 1751 1744 1752 - static inline void e100_start_receiver(struct nic *nic) 1745 + static inline void e100_start_receiver(struct nic *nic, struct rx *rx) 1753 1746 { 1754 - /* Start if RFA is non-NULL */ 1755 - if(nic->rx_to_clean->skb) 1756 - e100_exec_cmd(nic, ruc_start, nic->rx_to_clean->dma_addr); 1747 + if(!nic->rxs) return; 1748 + if(RU_SUSPENDED != nic->ru_running) return; 1749 + 1750 + /* handle init time starts */ 1751 + if(!rx) rx = nic->rxs; 1752 + 1753 + /* (Re)start RU if suspended or idle and RFA is non-NULL */ 1754 + if(rx->skb) { 1755 + e100_exec_cmd(nic, ruc_start, rx->dma_addr); 1756 + nic->ru_running = RU_RUNNING; 1757 + } 1757 1758 } 1758 1759 1759 1760 #define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN) ··· 1790 1775 put_unaligned(cpu_to_le32(rx->dma_addr), 1791 1776 (u32 *)&prev_rfd->link); 1792 1777 wmb(); 1793 - prev_rfd->command &= ~cpu_to_le16(cb_el & cb_s); 1778 + prev_rfd->command &= ~cpu_to_le16(cb_el); 1794 1779 pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, 1795 1780 sizeof(struct rfd), PCI_DMA_TODEVICE); 1796 1781 } ··· 1828 1813 pci_unmap_single(nic->pdev, rx->dma_addr, 1829 1814 RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 1830 1815 1816 + /* this allows for a fast restart without re-enabling interrupts */ 1817 + if(le16_to_cpu(rfd->command) & cb_el) 1818 + nic->ru_running = RU_SUSPENDED; 1819 + 1831 1820 /* Pull off the RFD and put the actual data (minus eth hdr) */ 1832 1821 skb_reserve(skb, sizeof(struct rfd)); 1833 1822 skb_put(skb, actual_size); ··· 1862 1843 unsigned int work_to_do) 1863 1844 { 1864 1845 struct rx *rx; 1846 + int restart_required = 0; 1847 + struct rx *rx_to_start = NULL; 1848 + 1849 + /* are we already rnr? then pay attention!!! this ensures that 1850 + * the state machine progression never allows a start with a 1851 + * partially cleaned list, avoiding a race between hardware 1852 + * and rx_to_clean when in NAPI mode */ 1853 + if(RU_SUSPENDED == nic->ru_running) 1854 + restart_required = 1; 1865 1855 1866 1856 /* Indicate newly arrived packets */ 1867 1857 for(rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) { 1868 - if(e100_rx_indicate(nic, rx, work_done, work_to_do)) 1858 + int err = e100_rx_indicate(nic, rx, work_done, work_to_do); 1859 + if(-EAGAIN == err) { 1860 + /* hit quota so have more work to do, restart once 1861 + * cleanup is complete */ 1862 + restart_required = 0; 1863 + break; 1864 + } else if(-ENODATA == err) 1869 1865 break; /* No more to clean */ 1870 1866 } 1867 + 1868 + /* save our starting point as the place we'll restart the receiver */ 1869 + if(restart_required) 1870 + rx_to_start = nic->rx_to_clean; 1871 1871 1872 1872 /* Alloc new skbs to refill list */ 1873 1873 for(rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) { 1874 1874 if(unlikely(e100_rx_alloc_skb(nic, rx))) 1875 1875 break; /* Better luck next time (see watchdog) */ 1876 + } 1877 + 1878 + if(restart_required) { 1879 + // ack the rnr? 1880 + writeb(stat_ack_rnr, &nic->csr->scb.stat_ack); 1881 + e100_start_receiver(nic, rx_to_start); 1882 + if(work_done) 1883 + (*work_done)++; 1876 1884 } 1877 1885 } 1878 1886 ··· 1907 1861 { 1908 1862 struct rx *rx; 1909 1863 unsigned int i, count = nic->params.rfds.count; 1864 + 1865 + nic->ru_running = RU_UNINITIALIZED; 1910 1866 1911 1867 if(nic->rxs) { 1912 1868 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { ··· 1931 1883 unsigned int i, count = nic->params.rfds.count; 1932 1884 1933 1885 nic->rx_to_use = nic->rx_to_clean = NULL; 1886 + nic->ru_running = RU_UNINITIALIZED; 1934 1887 1935 1888 if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC))) 1936 1889 return -ENOMEM; ··· 1946 1897 } 1947 1898 1948 1899 nic->rx_to_use = nic->rx_to_clean = nic->rxs; 1900 + nic->ru_running = RU_SUSPENDED; 1949 1901 1950 1902 return 0; 1951 1903 } ··· 1965 1915 1966 1916 /* Ack interrupt(s) */ 1967 1917 iowrite8(stat_ack, &nic->csr->scb.stat_ack); 1918 + 1919 + /* We hit Receive No Resource (RNR); restart RU after cleaning */ 1920 + if(stat_ack & stat_ack_rnr) 1921 + nic->ru_running = RU_SUSPENDED; 1968 1922 1969 1923 if(likely(netif_rx_schedule_prep(netdev))) { 1970 1924 e100_disable_irq(nic); ··· 2061 2007 if((err = e100_hw_init(nic))) 2062 2008 goto err_clean_cbs; 2063 2009 e100_set_multicast_list(nic->netdev); 2064 - e100_start_receiver(nic); 2010 + e100_start_receiver(nic, NULL); 2065 2011 mod_timer(&nic->watchdog, jiffies); 2066 2012 if((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED, 2067 2013 nic->netdev->name, nic->netdev))) ··· 2142 2088 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 2143 2089 BMCR_LOOPBACK); 2144 2090 2145 - e100_start_receiver(nic); 2091 + e100_start_receiver(nic, NULL); 2146 2092 2147 2093 if(!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) { 2148 2094 err = -ENOMEM;
+1 -1
drivers/net/ehea/ehea.h
··· 39 39 #include <asm/io.h> 40 40 41 41 #define DRV_NAME "ehea" 42 - #define DRV_VERSION "EHEA_0061" 42 + #define DRV_VERSION "EHEA_0064" 43 43 44 44 #define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ 45 45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
+5 -7
drivers/net/ehea/ehea_main.c
··· 451 451 processed_rq3++; 452 452 } 453 453 454 - if (cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) 454 + if ((cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) 455 + && port->vgrp) 455 456 vlan_hwaccel_receive_skb(skb, port->vgrp, 456 457 cqe->vlan_tag); 457 458 else ··· 1911 1910 goto out; 1912 1911 } 1913 1912 1914 - if (grp) 1915 - memset(cb1->vlan_filter, 0, sizeof(cb1->vlan_filter)); 1916 - else 1917 - memset(cb1->vlan_filter, 0xFF, sizeof(cb1->vlan_filter)); 1913 + memset(cb1->vlan_filter, 0, sizeof(cb1->vlan_filter)); 1918 1914 1919 1915 hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id, 1920 1916 H_PORT_CB1, H_PORT_CB1_ALL, cb1); ··· 1945 1947 } 1946 1948 1947 1949 index = (vid / 64); 1948 - cb1->vlan_filter[index] |= ((u64)(1 << (vid & 0x3F))); 1950 + cb1->vlan_filter[index] |= ((u64)(0x8000000000000000 >> (vid & 0x3F))); 1949 1951 1950 1952 hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id, 1951 1953 H_PORT_CB1, H_PORT_CB1_ALL, cb1); ··· 1980 1982 } 1981 1983 1982 1984 index = (vid / 64); 1983 - cb1->vlan_filter[index] &= ~((u64)(1 << (vid & 0x3F))); 1985 + cb1->vlan_filter[index] &= ~((u64)(0x8000000000000000 >> (vid & 0x3F))); 1984 1986 1985 1987 hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id, 1986 1988 H_PORT_CB1, H_PORT_CB1_ALL, cb1);
+54 -26
drivers/net/ibmveth.c
··· 915 915 { 916 916 struct ibmveth_adapter *adapter = dev->priv; 917 917 int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH; 918 - int i; 918 + int reinit = 0; 919 + int i, rc; 919 920 920 921 if (new_mtu < IBMVETH_MAX_MTU) 921 922 return -EINVAL; 922 923 924 + for (i = 0; i < IbmVethNumBufferPools; i++) 925 + if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) 926 + break; 927 + 928 + if (i == IbmVethNumBufferPools) 929 + return -EINVAL; 930 + 923 931 /* Look for an active buffer pool that can hold the new MTU */ 924 932 for(i = 0; i<IbmVethNumBufferPools; i++) { 925 - if (!adapter->rx_buff_pool[i].active) 926 - continue; 933 + if (!adapter->rx_buff_pool[i].active) { 934 + adapter->rx_buff_pool[i].active = 1; 935 + reinit = 1; 936 + } 937 + 927 938 if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) { 928 - dev->mtu = new_mtu; 939 + if (reinit && netif_running(adapter->netdev)) { 940 + adapter->pool_config = 1; 941 + ibmveth_close(adapter->netdev); 942 + adapter->pool_config = 0; 943 + dev->mtu = new_mtu; 944 + if ((rc = ibmveth_open(adapter->netdev))) 945 + return rc; 946 + } else 947 + dev->mtu = new_mtu; 929 948 return 0; 930 949 } 931 950 } ··· 1262 1243 1263 1244 if (attr == &veth_active_attr) { 1264 1245 if (value && !pool->active) { 1265 - if(ibmveth_alloc_buffer_pool(pool)) { 1266 - ibmveth_error_printk("unable to alloc pool\n"); 1267 - return -ENOMEM; 1268 - } 1269 - pool->active = 1; 1270 - adapter->pool_config = 1; 1271 - ibmveth_close(netdev); 1272 - adapter->pool_config = 0; 1273 - if ((rc = ibmveth_open(netdev))) 1274 - return rc; 1246 + if (netif_running(netdev)) { 1247 + if(ibmveth_alloc_buffer_pool(pool)) { 1248 + ibmveth_error_printk("unable to alloc pool\n"); 1249 + return -ENOMEM; 1250 + } 1251 + pool->active = 1; 1252 + adapter->pool_config = 1; 1253 + ibmveth_close(netdev); 1254 + adapter->pool_config = 0; 1255 + if ((rc = ibmveth_open(netdev))) 1256 + return rc; 1257 + } else 1258 + pool->active = 1; 1275 1259 } else if (!value && pool->active) { 1276 1260 int mtu = netdev->mtu + IBMVETH_BUFF_OH; 1277 1261 int i; ··· 1303 1281 if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT) 1304 1282 return -EINVAL; 1305 1283 else { 1306 - adapter->pool_config = 1; 1307 - ibmveth_close(netdev); 1308 - adapter->pool_config = 0; 1309 - pool->size = value; 1310 - if ((rc = ibmveth_open(netdev))) 1311 - return rc; 1284 + if (netif_running(netdev)) { 1285 + adapter->pool_config = 1; 1286 + ibmveth_close(netdev); 1287 + adapter->pool_config = 0; 1288 + pool->size = value; 1289 + if ((rc = ibmveth_open(netdev))) 1290 + return rc; 1291 + } else 1292 + pool->size = value; 1312 1293 } 1313 1294 } else if (attr == &veth_size_attr) { 1314 1295 if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE) 1315 1296 return -EINVAL; 1316 1297 else { 1317 - adapter->pool_config = 1; 1318 - ibmveth_close(netdev); 1319 - adapter->pool_config = 0; 1320 - pool->buff_size = value; 1321 - if ((rc = ibmveth_open(netdev))) 1322 - return rc; 1298 + if (netif_running(netdev)) { 1299 + adapter->pool_config = 1; 1300 + ibmveth_close(netdev); 1301 + adapter->pool_config = 0; 1302 + pool->buff_size = value; 1303 + if ((rc = ibmveth_open(netdev))) 1304 + return rc; 1305 + } else 1306 + pool->buff_size = value; 1323 1307 } 1324 1308 } 1325 1309
+21 -8
drivers/net/myri10ge/myri10ge.c
··· 71 71 #include "myri10ge_mcp.h" 72 72 #include "myri10ge_mcp_gen_header.h" 73 73 74 - #define MYRI10GE_VERSION_STR "1.3.0-1.233" 74 + #define MYRI10GE_VERSION_STR "1.3.1-1.248" 75 75 76 76 MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); 77 77 MODULE_AUTHOR("Maintainer: help@myri.com"); ··· 278 278 static int myri10ge_fill_thresh = 256; 279 279 module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR); 280 280 MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed\n"); 281 + 282 + static int myri10ge_reset_recover = 1; 281 283 282 284 static int myri10ge_wcfifo = 0; 283 285 module_param(myri10ge_wcfifo, int, S_IRUGO); ··· 1156 1154 struct mcp_irq_data *stats = mgp->fw_stats; 1157 1155 1158 1156 if (unlikely(stats->stats_updated)) { 1159 - if (mgp->link_state != stats->link_up) { 1160 - mgp->link_state = stats->link_up; 1161 - if (mgp->link_state) { 1157 + unsigned link_up = ntohl(stats->link_up); 1158 + if (mgp->link_state != link_up) { 1159 + mgp->link_state = link_up; 1160 + 1161 + if (mgp->link_state == MXGEFW_LINK_UP) { 1162 1162 if (netif_msg_link(mgp)) 1163 1163 printk(KERN_INFO 1164 1164 "myri10ge: %s: link up\n", ··· 1170 1166 } else { 1171 1167 if (netif_msg_link(mgp)) 1172 1168 printk(KERN_INFO 1173 - "myri10ge: %s: link down\n", 1174 - mgp->dev->name); 1169 + "myri10ge: %s: link %s\n", 1170 + mgp->dev->name, 1171 + (link_up == MXGEFW_LINK_MYRINET ? 1172 + "mismatch (Myrinet detected)" : 1173 + "down")); 1175 1174 netif_carrier_off(mgp->dev); 1176 1175 mgp->link_changes++; 1177 1176 } ··· 2737 2730 * For now, just report it */ 2738 2731 reboot = myri10ge_read_reboot(mgp); 2739 2732 printk(KERN_ERR 2740 - "myri10ge: %s: NIC rebooted (0x%x), resetting\n", 2741 - mgp->dev->name, reboot); 2733 + "myri10ge: %s: NIC rebooted (0x%x),%s resetting\n", 2734 + mgp->dev->name, reboot, 2735 + myri10ge_reset_recover ? " " : " not"); 2736 + if (myri10ge_reset_recover == 0) 2737 + return; 2738 + 2739 + myri10ge_reset_recover--; 2740 + 2742 2741 /* 2743 2742 * A rebooted nic will come back with config space as 2744 2743 * it was after power was applied to PCIe bus.
+24 -22
drivers/net/netxen/netxen_nic.h
··· 68 68 #define _NETXEN_NIC_LINUX_SUBVERSION 2 69 69 #define NETXEN_NIC_LINUX_VERSIONID "3.4.2" 70 70 71 - #define NUM_FLASH_SECTORS (64) 72 - #define FLASH_SECTOR_SIZE (64 * 1024) 73 - #define FLASH_TOTAL_SIZE (NUM_FLASH_SECTORS * FLASH_SECTOR_SIZE) 71 + #define NETXEN_NUM_FLASH_SECTORS (64) 72 + #define NETXEN_FLASH_SECTOR_SIZE (64 * 1024) 73 + #define NETXEN_FLASH_TOTAL_SIZE (NETXEN_NUM_FLASH_SECTORS \ 74 + * NETXEN_FLASH_SECTOR_SIZE) 74 75 75 76 #define PHAN_VENDOR_ID 0x4040 76 77 ··· 678 677 679 678 /* Flash memory map */ 680 679 typedef enum { 681 - CRBINIT_START = 0, /* Crbinit section */ 682 - BRDCFG_START = 0x4000, /* board config */ 683 - INITCODE_START = 0x6000, /* pegtune code */ 684 - BOOTLD_START = 0x10000, /* bootld */ 685 - IMAGE_START = 0x43000, /* compressed image */ 686 - SECONDARY_START = 0x200000, /* backup images */ 687 - PXE_START = 0x3E0000, /* user defined region */ 688 - USER_START = 0x3E8000, /* User defined region for new boards */ 689 - FIXED_START = 0x3F0000 /* backup of crbinit */ 680 + NETXEN_CRBINIT_START = 0, /* Crbinit section */ 681 + NETXEN_BRDCFG_START = 0x4000, /* board config */ 682 + NETXEN_INITCODE_START = 0x6000, /* pegtune code */ 683 + NETXEN_BOOTLD_START = 0x10000, /* bootld */ 684 + NETXEN_IMAGE_START = 0x43000, /* compressed image */ 685 + NETXEN_SECONDARY_START = 0x200000, /* backup images */ 686 + NETXEN_PXE_START = 0x3E0000, /* user defined region */ 687 + NETXEN_USER_START = 0x3E8000, /* User defined region for new boards */ 688 + NETXEN_FIXED_START = 0x3F0000 /* backup of crbinit */ 690 689 } netxen_flash_map_t; 691 690 692 - #define USER_START_OLD PXE_START /* for backward compatibility */ 691 + #define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */ 693 692 694 - #define FLASH_START (CRBINIT_START) 695 - #define INIT_SECTOR (0) 696 - #define PRIMARY_START (BOOTLD_START) 697 - #define FLASH_CRBINIT_SIZE (0x4000) 698 - #define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) 699 - #define FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32)) 700 - #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) 701 - #define NUM_PRIMARY_SECTORS (0x20) 702 - #define NUM_CONFIG_SECTORS (1) 693 + #define NETXEN_FLASH_START (NETXEN_CRBINIT_START) 694 + #define NETXEN_INIT_SECTOR (0) 695 + #define NETXEN_PRIMARY_START (NETXEN_BOOTLD_START) 696 + #define NETXEN_FLASH_CRBINIT_SIZE (0x4000) 697 + #define NETXEN_FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) 698 + #define NETXEN_FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32)) 699 + #define NETXEN_FLASH_SECONDARY_SIZE (NETXEN_USER_START-NETXEN_SECONDARY_START) 700 + #define NETXEN_NUM_PRIMARY_SECTORS (0x20) 701 + #define NETXEN_NUM_CONFIG_SECTORS (1) 703 702 #define PFX "NetXen: " 704 703 extern char netxen_nic_driver_name[]; 705 704 ··· 1049 1048 int netxen_do_rom_se(struct netxen_adapter *adapter, int addr); 1050 1049 1051 1050 /* Functions from netxen_nic_isr.c */ 1051 + int netxen_nic_link_ok(struct netxen_adapter *adapter); 1052 1052 void netxen_nic_isr_other(struct netxen_adapter *adapter); 1053 1053 void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 link); 1054 1054 void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable);
+4 -4
drivers/net/netxen/netxen_nic_ethtool.c
··· 94 94 95 95 static int netxen_nic_get_eeprom_len(struct net_device *dev) 96 96 { 97 - return FLASH_TOTAL_SIZE; 97 + return NETXEN_FLASH_TOTAL_SIZE; 98 98 } 99 99 100 100 static void ··· 470 470 return 0; 471 471 } 472 472 473 - if (offset == BOOTLD_START) { 473 + if (offset == NETXEN_BOOTLD_START) { 474 474 ret = netxen_flash_erase_primary(adapter); 475 475 if (ret != FLASH_SUCCESS) { 476 476 printk(KERN_ERR "%s: Flash erase failed.\n", ··· 478 478 return ret; 479 479 } 480 480 481 - ret = netxen_rom_se(adapter, USER_START); 481 + ret = netxen_rom_se(adapter, NETXEN_USER_START); 482 482 if (ret != FLASH_SUCCESS) 483 483 return ret; 484 - ret = netxen_rom_se(adapter, FIXED_START); 484 + ret = netxen_rom_se(adapter, NETXEN_FIXED_START); 485 485 if (ret != FLASH_SUCCESS) 486 486 return ret; 487 487
+6 -6
drivers/net/netxen/netxen_nic_hw.c
··· 257 257 #define ADDR_IN_RANGE(addr, low, high) \ 258 258 (((addr) <= (high)) && ((addr) >= (low))) 259 259 260 - #define NETXEN_FLASH_BASE (BOOTLD_START) 260 + #define NETXEN_FLASH_BASE (NETXEN_BOOTLD_START) 261 261 #define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE) 262 262 #define NETXEN_MAX_MTU 8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE 263 263 #define NETXEN_MIN_MTU 64 ··· 611 611 u32 *pmac = (u32 *) & mac[0]; 612 612 613 613 if (netxen_get_flash_block(adapter, 614 - USER_START + 614 + NETXEN_USER_START + 615 615 offsetof(struct netxen_new_user_info, 616 616 mac_addr), 617 617 FLASH_NUM_PORTS * sizeof(u64), pmac) == -1) { ··· 619 619 } 620 620 if (*mac == ~0ULL) { 621 621 if (netxen_get_flash_block(adapter, 622 - USER_START_OLD + 622 + NETXEN_USER_START_OLD + 623 623 offsetof(struct netxen_user_old_info, 624 624 mac_addr), 625 625 FLASH_NUM_PORTS * sizeof(u64), ··· 942 942 int 943 943 netxen_nic_erase_pxe(struct netxen_adapter *adapter) 944 944 { 945 - if (netxen_rom_fast_write(adapter, PXE_START, 0) == -1) { 945 + if (netxen_rom_fast_write(adapter, NETXEN_PXE_START, 0) == -1) { 946 946 printk(KERN_ERR "%s: erase pxe failed\n", 947 947 netxen_nic_driver_name); 948 948 return -1; ··· 953 953 int netxen_nic_get_board_info(struct netxen_adapter *adapter) 954 954 { 955 955 int rv = 0; 956 - int addr = BRDCFG_START; 956 + int addr = NETXEN_BRDCFG_START; 957 957 struct netxen_board_info *boardinfo; 958 958 int index; 959 959 u32 *ptr32; ··· 1115 1115 u32 fw_build = 0; 1116 1116 char brd_name[NETXEN_MAX_SHORT_NAME]; 1117 1117 struct netxen_new_user_info user_info; 1118 - int i, addr = USER_START; 1118 + int i, addr = NETXEN_USER_START; 1119 1119 __le32 *ptr32; 1120 1120 1121 1121 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
+27 -21
drivers/net/netxen/netxen_nic_init.c
··· 585 585 { 586 586 int ret = FLASH_SUCCESS; 587 587 int val; 588 - char *buffer = kmalloc(FLASH_SECTOR_SIZE, GFP_KERNEL); 588 + char *buffer = kmalloc(NETXEN_FLASH_SECTOR_SIZE, GFP_KERNEL); 589 589 590 590 if (!buffer) 591 591 return -ENOMEM; ··· 601 601 goto out_kfree; 602 602 603 603 /* copy sector 0 to sector 63 */ 604 - ret = netxen_rom_fast_read_words(adapter, CRBINIT_START, 605 - buffer, FLASH_SECTOR_SIZE); 604 + ret = netxen_rom_fast_read_words(adapter, NETXEN_CRBINIT_START, 605 + buffer, NETXEN_FLASH_SECTOR_SIZE); 606 606 if (ret != FLASH_SUCCESS) 607 607 goto out_kfree; 608 608 609 - ret = netxen_rom_fast_write_words(adapter, FIXED_START, 610 - buffer, FLASH_SECTOR_SIZE); 609 + ret = netxen_rom_fast_write_words(adapter, NETXEN_FIXED_START, 610 + buffer, NETXEN_FLASH_SECTOR_SIZE); 611 611 if (ret != FLASH_SUCCESS) 612 612 goto out_kfree; 613 613 ··· 654 654 int count = 0, erased_errors = 0; 655 655 int range; 656 656 657 - range = (addr == USER_START) ? FIXED_START : addr + FLASH_SECTOR_SIZE; 657 + range = (addr == NETXEN_USER_START) ? 658 + NETXEN_FIXED_START : addr + NETXEN_FLASH_SECTOR_SIZE; 658 659 659 660 for (i = addr; i < range; i += 4) { 660 661 netxen_rom_fast_read(adapter, i, &val); ··· 690 689 int i; 691 690 692 691 for (i = start; i < end; i++) { 693 - ret = netxen_rom_se(adapter, i * FLASH_SECTOR_SIZE); 692 + ret = netxen_rom_se(adapter, i * NETXEN_FLASH_SECTOR_SIZE); 694 693 if (ret) 695 694 break; 696 695 ret = netxen_rom_wip_poll(adapter); ··· 707 706 int ret = FLASH_SUCCESS; 708 707 int start, end; 709 708 710 - start = SECONDARY_START / FLASH_SECTOR_SIZE; 711 - end = USER_START / FLASH_SECTOR_SIZE; 709 + start = NETXEN_SECONDARY_START / NETXEN_FLASH_SECTOR_SIZE; 710 + end = NETXEN_USER_START / NETXEN_FLASH_SECTOR_SIZE; 712 711 ret = netxen_flash_erase_sections(adapter, start, end); 713 712 714 713 return ret; ··· 720 719 int ret = FLASH_SUCCESS; 721 720 int start, end; 722 721 723 - start = PRIMARY_START / FLASH_SECTOR_SIZE; 724 - end = SECONDARY_START / FLASH_SECTOR_SIZE; 722 + start = NETXEN_PRIMARY_START / NETXEN_FLASH_SECTOR_SIZE; 723 + end = NETXEN_SECONDARY_START / NETXEN_FLASH_SECTOR_SIZE; 725 724 ret = netxen_flash_erase_sections(adapter, start, end); 726 725 727 726 return ret; ··· 1037 1036 if ((adapter->portnum == 0) && netxen_nic_check_temp(adapter)) 1038 1037 return; 1039 1038 1040 - netdev = adapter->netdev; 1041 - if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) { 1042 - printk(KERN_INFO "%s port %d, %s carrier is now ok\n", 1043 - netxen_nic_driver_name, adapter->portnum, netdev->name); 1044 - netif_carrier_on(netdev); 1045 - } 1046 - 1047 - if (netif_queue_stopped(netdev)) 1048 - netif_wake_queue(netdev); 1049 - 1050 1039 if (adapter->handle_phy_intr) 1051 1040 adapter->handle_phy_intr(adapter); 1041 + 1042 + netdev = adapter->netdev; 1043 + if ((netif_running(netdev)) && !netif_carrier_ok(netdev) && 1044 + netxen_nic_link_ok(adapter) ) { 1045 + printk(KERN_INFO "%s %s (port %d), Link is up\n", 1046 + netxen_nic_driver_name, netdev->name, adapter->portnum); 1047 + netif_carrier_on(netdev); 1048 + netif_wake_queue(netdev); 1049 + } else if(!(netif_running(netdev)) && netif_carrier_ok(netdev)) { 1050 + printk(KERN_ERR "%s %s Link is Down\n", 1051 + netxen_nic_driver_name, netdev->name); 1052 + netif_carrier_off(netdev); 1053 + netif_stop_queue(netdev); 1054 + } 1055 + 1052 1056 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 1053 1057 } 1054 1058
+24
drivers/net/netxen/netxen_nic_isr.c
··· 169 169 netxen_nic_isr_other(adapter); 170 170 } 171 171 172 + int netxen_nic_link_ok(struct netxen_adapter *adapter) 173 + { 174 + switch (adapter->ahw.board_type) { 175 + case NETXEN_NIC_GBE: 176 + return ((adapter->ahw.qg_linksup) & 1); 177 + 178 + case NETXEN_NIC_XGBE: 179 + return ((adapter->ahw.xg_linkup) & 1); 180 + 181 + default: 182 + printk(KERN_ERR"%s: Function: %s, Unknown board type\n", 183 + netxen_nic_driver_name, __FUNCTION__); 184 + break; 185 + } 186 + 187 + return 0; 188 + } 189 + 172 190 void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter) 173 191 { 174 192 struct net_device *netdev = adapter->netdev; ··· 201 183 printk(KERN_INFO "%s: %s NIC Link is down\n", 202 184 netxen_nic_driver_name, netdev->name); 203 185 adapter->ahw.xg_linkup = 0; 186 + if (netif_running(netdev)) { 187 + netif_carrier_off(netdev); 188 + netif_stop_queue(netdev); 189 + } 204 190 /* read twice to clear sticky bits */ 205 191 /* WINDOW = 0 */ 206 192 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1); ··· 218 196 printk(KERN_INFO "%s: %s NIC Link is up\n", 219 197 netxen_nic_driver_name, netdev->name); 220 198 adapter->ahw.xg_linkup = 1; 199 + netif_carrier_on(netdev); 200 + netif_wake_queue(netdev); 221 201 } 222 202 }
+7
drivers/net/netxen/netxen_nic_main.c
··· 542 542 NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); 543 543 /* Handshake with the card before we register the devices. */ 544 544 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 545 + 546 + /* leave the hw in the same state as reboot */ 547 + writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 548 + netxen_pinit_from_rom(adapter, 0); 549 + udelay(500); 550 + netxen_load_firmware(adapter); 551 + netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 545 552 } 546 553 547 554 /*
+2 -6
drivers/net/netxen/netxen_nic_niu.c
··· 454 454 455 455 int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port) 456 456 { 457 - u32 reg; 458 457 u32 portnum = physical_port[adapter->portnum]; 459 458 460 459 netxen_crb_writelit_adapter(adapter, 461 - NETXEN_NIU_XGE_CONFIG_0+(0x10000*portnum), 0x5); 462 - netxen_nic_hw_read_wx(adapter, 463 - NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), &reg, 4); 464 - reg = (reg & ~0x2000UL); 460 + NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), 0x1447); 465 461 netxen_crb_writelit_adapter(adapter, 466 - NETXEN_NIU_XGE_CONFIG_1+(0x10000*portnum), reg); 462 + NETXEN_NIU_XGE_CONFIG_0+(0x10000*portnum), 0x5); 467 463 468 464 return 0; 469 465 }
+54 -8
drivers/net/phy/marvell.c
··· 54 54 #define MII_M1111_PHY_LED_CONTROL 0x18 55 55 #define MII_M1111_PHY_LED_DIRECT 0x4100 56 56 #define MII_M1111_PHY_LED_COMBINE 0x411c 57 + #define MII_M1111_PHY_EXT_CR 0x14 58 + #define MII_M1111_RX_DELAY 0x80 59 + #define MII_M1111_TX_DELAY 0x2 60 + #define MII_M1111_PHY_EXT_SR 0x1b 61 + #define MII_M1111_HWCFG_MODE_MASK 0xf 62 + #define MII_M1111_HWCFG_MODE_RGMII 0xb 57 63 58 64 MODULE_DESCRIPTION("Marvell PHY driver"); 59 65 MODULE_AUTHOR("Andy Fleming"); ··· 137 131 return err; 138 132 } 139 133 134 + static int m88e1111_config_init(struct phy_device *phydev) 135 + { 136 + int err; 137 + 138 + if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) || 139 + (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)) { 140 + int temp; 141 + 142 + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { 143 + temp = phy_read(phydev, MII_M1111_PHY_EXT_CR); 144 + if (temp < 0) 145 + return temp; 146 + 147 + temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY); 148 + 149 + err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp); 150 + if (err < 0) 151 + return err; 152 + } 153 + 154 + temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); 155 + if (temp < 0) 156 + return temp; 157 + 158 + temp &= ~(MII_M1111_HWCFG_MODE_MASK); 159 + temp |= MII_M1111_HWCFG_MODE_RGMII; 160 + 161 + err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); 162 + if (err < 0) 163 + return err; 164 + } 165 + 166 + err = phy_write(phydev, MII_BMCR, BMCR_RESET); 167 + if (err < 0) 168 + return err; 169 + 170 + return 0; 171 + } 172 + 140 173 static int m88e1145_config_init(struct phy_device *phydev) 141 174 { 142 175 int err; ··· 197 152 if (err < 0) 198 153 return err; 199 154 200 - if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { 155 + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { 201 156 int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR); 202 157 if (temp < 0) 203 158 return temp; ··· 251 206 .driver = {.owner = THIS_MODULE,}, 252 207 }; 253 208 254 - static struct phy_driver m88e1111s_driver = { 209 + static struct phy_driver m88e1111_driver = { 255 210 .phy_id = 0x01410cc0, 256 211 .phy_id_mask = 0xfffffff0, 257 212 .name = "Marvell 88E1111", ··· 261 216 .read_status = &genphy_read_status, 262 217 .ack_interrupt = &marvell_ack_interrupt, 263 218 .config_intr = &marvell_config_intr, 219 + .config_init = &m88e1111_config_init, 264 220 .driver = {.owner = THIS_MODULE,}, 265 221 }; 266 222 ··· 287 241 if (ret) 288 242 return ret; 289 243 290 - ret = phy_driver_register(&m88e1111s_driver); 244 + ret = phy_driver_register(&m88e1111_driver); 291 245 if (ret) 292 - goto err1111s; 246 + goto err1111; 293 247 294 248 ret = phy_driver_register(&m88e1145_driver); 295 249 if (ret) ··· 297 251 298 252 return 0; 299 253 300 - err1145: 301 - phy_driver_unregister(&m88e1111s_driver); 302 - err1111s: 254 + err1145: 255 + phy_driver_unregister(&m88e1111_driver); 256 + err1111: 303 257 phy_driver_unregister(&m88e1101_driver); 304 258 return ret; 305 259 } ··· 307 261 static void __exit marvell_exit(void) 308 262 { 309 263 phy_driver_unregister(&m88e1101_driver); 310 - phy_driver_unregister(&m88e1111s_driver); 264 + phy_driver_unregister(&m88e1111_driver); 311 265 phy_driver_unregister(&m88e1145_driver); 312 266 } 313 267
+2 -2
drivers/net/usb/Kconfig
··· 313 313 boolean "KT Technology KC2190 based cables (InstaNet)" 314 314 depends on USB_NET_CDC_SUBSET && EXPERIMENTAL 315 315 help 316 - �Choose this option if you're using a host-to-host cable 317 - �with one of these chips. 316 + Choose this option if you're using a host-to-host cable 317 + with one of these chips. 318 318 319 319 config USB_NET_ZAURUS 320 320 tristate "Sharp Zaurus (stock ROMs) and compatible"
+1 -1
drivers/net/via-velocity.c
··· 1562 1562 if (vptr->mii_status & VELOCITY_LINK_FAIL) { 1563 1563 VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: failed to detect cable link\n", vptr->dev->name); 1564 1564 } else if (vptr->options.spd_dpx == SPD_DPX_AUTO) { 1565 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link autonegation", vptr->dev->name); 1565 + VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link auto-negotiation", vptr->dev->name); 1566 1566 1567 1567 if (vptr->mii_status & VELOCITY_SPEED_1000) 1568 1568 VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps");
+13 -6
drivers/net/wireless/Kconfig
··· 266 266 267 267 If you are not sure, say N here. 268 268 269 - config LIBERTAS_USB 270 - tristate "Marvell Libertas 8388 802.11a/b/g cards" 271 - depends on USB && WLAN_80211 269 + config LIBERTAS 270 + tristate "Marvell 8xxx Libertas WLAN driver support" 271 + depends on WLAN_80211 272 + select IEEE80211 272 273 select FW_LOADER 274 + ---help--- 275 + A library for Marvell Libertas 8xxx devices. 276 + 277 + config LIBERTAS_USB 278 + tristate "Marvell Libertas 8388 USB 802.11b/g cards" 279 + depends on LIBERTAS && USB 273 280 ---help--- 274 281 A driver for Marvell Libertas 8388 USB devices. 275 282 276 - config LIBERTAS_USB_DEBUG 277 - bool "Enable full debugging output in the Libertas USB module." 278 - depends on LIBERTAS_USB 283 + config LIBERTAS_DEBUG 284 + bool "Enable full debugging output in the Libertas module." 285 + depends on LIBERTAS 279 286 ---help--- 280 287 Debugging support. 281 288
+78 -74
drivers/net/wireless/libertas/11d.c
··· 95 95 96 96 for (i = 0; i < cfp_no; i++) { 97 97 if ((cfp + i)->channel == firstchan) { 98 - lbs_pr_debug(1, "firstchan found\n"); 98 + lbs_deb_11d("firstchan found\n"); 99 99 break; 100 100 } 101 101 } ··· 129 129 130 130 for (i = 0; i < nr_chan; i++) { 131 131 if (chan == chanpwr[i].chan) { 132 - lbs_pr_debug(1, "11D: Found Chan:%d\n", chan); 132 + lbs_deb_11d("11D: Found Chan:%d\n", chan); 133 133 return 1; 134 134 } 135 135 } 136 136 137 - lbs_pr_debug(1, "11D: Not Find Chan:%d\n", chan); 137 + lbs_deb_11d("11D: Not Find Chan:%d\n", chan); 138 138 return 0; 139 139 } 140 140 ··· 174 174 memcpy(domaininfo->countrycode, parsed_region_chan->countrycode, 175 175 COUNTRY_CODE_LEN); 176 176 177 - lbs_pr_debug(1, "11D:nrchan=%d\n", nr_chan); 177 + lbs_deb_11d("11D:nrchan=%d\n", nr_chan); 178 178 lbs_dbg_hex("11D:parsed_region_chan:", (char *)parsed_region_chan, 179 179 sizeof(struct parsed_region_chan_11d)); 180 180 ··· 212 212 } 213 213 domaininfo->nr_subband = nr_subband; 214 214 215 - lbs_pr_debug(1, "nr_subband=%x\n", domaininfo->nr_subband); 215 + lbs_deb_11d("nr_subband=%x\n", domaininfo->nr_subband); 216 216 lbs_dbg_hex("11D:domaininfo:", (char *)domaininfo, 217 217 COUNTRY_CODE_LEN + 1 + 218 218 sizeof(struct ieeetypes_subbandset) * nr_subband); ··· 233 233 struct chan_freq_power *cfp; 234 234 235 235 if (region_chan == NULL) { 236 - lbs_pr_debug(1, "11D: region_chan is NULL\n"); 236 + lbs_deb_11d("11D: region_chan is NULL\n"); 237 237 return; 238 238 } 239 239 240 240 cfp = region_chan->CFP; 241 241 if (cfp == NULL) { 242 - lbs_pr_debug(1, "11D: cfp equal NULL \n"); 242 + lbs_deb_11d("11D: cfp equal NULL \n"); 243 243 return; 244 244 } 245 245 ··· 248 248 memcpy(parsed_region_chan->countrycode, 249 249 wlan_code_2_region(region_chan->region), COUNTRY_CODE_LEN); 250 250 251 - lbs_pr_debug(1, "11D: region[0x%x] band[%d]\n", parsed_region_chan->region, 251 + lbs_deb_11d("11D: region[0x%x] band[%d]\n", parsed_region_chan->region, 252 252 parsed_region_chan->band); 253 253 254 254 for (i = 0; i < region_chan->nrcfp; i++, cfp++) { 255 255 parsed_region_chan->chanpwr[i].chan = cfp->channel; 256 256 parsed_region_chan->chanpwr[i].pwr = cfp->maxtxpower; 257 - lbs_pr_debug(1, "11D: Chan[%d] Pwr[%d]\n", 257 + lbs_deb_11d("11D: Chan[%d] Pwr[%d]\n", 258 258 parsed_region_chan->chanpwr[i].chan, 259 259 parsed_region_chan->chanpwr[i].pwr); 260 260 } 261 261 parsed_region_chan->nr_chan = region_chan->nrcfp; 262 262 263 - lbs_pr_debug(1, "11D: nrchan[%d]\n", parsed_region_chan->nr_chan); 263 + lbs_deb_11d("11D: nrchan[%d]\n", parsed_region_chan->nr_chan); 264 264 265 265 return; 266 266 } ··· 277 277 struct chan_freq_power *cfp; 278 278 int cfp_no; 279 279 u8 idx; 280 + int ret = 0; 280 281 281 - ENTER(); 282 + lbs_deb_enter(LBS_DEB_11D); 282 283 283 284 cfp = libertas_get_region_cfp_table(region, band, &cfp_no); 284 285 if (cfp == NULL) ··· 289 288 if (chan == (cfp + idx)->channel) { 290 289 /* If Mrvl Chip Supported? */ 291 290 if ((cfp + idx)->unsupported) { 292 - return 0; 291 + ret = 0; 293 292 } else { 294 - return 1; 293 + ret = 1; 295 294 } 295 + goto done; 296 296 } 297 297 } 298 298 299 299 /*chan is not in the region table */ 300 - LEAVE(); 301 - return 0; 300 + 301 + done: 302 + lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret); 303 + return ret; 302 304 } 303 305 304 306 /** ··· 325 321 326 322 u8 j, i; 327 323 328 - ENTER(); 324 + lbs_deb_enter(LBS_DEB_11D); 329 325 330 326 /*validation Rules: 331 327 1. valid region Code ··· 341 337 if ((*(countryinfo->countrycode)) == 0 342 338 || (countryinfo->len <= COUNTRY_CODE_LEN)) { 343 339 /* No region Info or Wrong region info: treat as No 11D info */ 344 - LEAVE(); 345 - return 0; 340 + goto done; 346 341 } 347 342 348 343 /*Step1: check region_code */ 349 344 parsed_region_chan->region = region = 350 345 wlan_region_2_code(countryinfo->countrycode); 351 346 352 - lbs_pr_debug(1, "regioncode=%x\n", (u8) parsed_region_chan->region); 347 + lbs_deb_11d("regioncode=%x\n", (u8) parsed_region_chan->region); 353 348 lbs_dbg_hex("CountryCode:", (char *)countryinfo->countrycode, 354 349 COUNTRY_CODE_LEN); 355 350 ··· 364 361 365 362 if (countryinfo->subband[j].firstchan <= lastchan) { 366 363 /*Step2&3. Check First Chan Num increment and no overlap */ 367 - lbs_pr_debug(1, "11D: Chan[%d>%d] Overlap\n", 364 + lbs_deb_11d("11D: Chan[%d>%d] Overlap\n", 368 365 countryinfo->subband[j].firstchan, lastchan); 369 366 continue; 370 367 } ··· 377 374 378 375 if (!wlan_get_chan_11d(band, firstchan, i, &curchan)) { 379 376 /* Chan is not found in UN table */ 380 - lbs_pr_debug(1, "chan is not supported: %d \n", i); 377 + lbs_deb_11d("chan is not supported: %d \n", i); 381 378 break; 382 379 } 383 380 ··· 392 389 idx++; 393 390 } else { 394 391 /*not supported and ignore the chan */ 395 - lbs_pr_debug(1, 392 + lbs_deb_11d( 396 393 "11D:i[%d] chan[%d] unsupported in region[%x] band[%d]\n", 397 394 i, curchan, region, band); 398 395 } ··· 404 401 405 402 parsed_region_chan->nr_chan = idx; 406 403 407 - lbs_pr_debug(1, "nrchan=%x\n", parsed_region_chan->nr_chan); 404 + lbs_deb_11d("nrchan=%x\n", parsed_region_chan->nr_chan); 408 405 lbs_dbg_hex("11D:parsed_region_chan:", (u8 *) parsed_region_chan, 409 406 2 + COUNTRY_CODE_LEN + sizeof(struct parsed_region_chan_11d) * idx); 410 407 411 - LEAVE(); 408 + done: 409 + lbs_deb_enter(LBS_DEB_11D); 412 410 return 0; 413 411 } 414 412 ··· 424 420 { 425 421 u8 scan_type = cmd_scan_type_passive; 426 422 427 - ENTER(); 423 + lbs_deb_enter(LBS_DEB_11D); 428 424 429 425 if (wlan_channel_known_11d(chan, parsed_region_chan)) { 430 - lbs_pr_debug(1, "11D: Found and do Active Scan\n"); 426 + lbs_deb_11d("11D: Found and do Active Scan\n"); 431 427 scan_type = cmd_scan_type_active; 432 428 } else { 433 - lbs_pr_debug(1, "11D: Not Find and do Passive Scan\n"); 429 + lbs_deb_11d("11D: Not Find and do Passive Scan\n"); 434 430 } 435 431 436 - LEAVE(); 432 + lbs_deb_leave_args(LBS_DEB_11D, "ret scan_type %d", scan_type); 437 433 return scan_type; 438 434 439 435 } ··· 460 456 OID_802_11D_ENABLE, 461 457 &priv->adapter->enable11d); 462 458 if (ret) 463 - lbs_pr_debug(1, "11D: Fail to enable 11D \n"); 459 + lbs_deb_11d("11D: Fail to enable 11D \n"); 464 460 465 461 return 0; 466 462 } ··· 475 471 int ret; 476 472 477 473 if (!priv->adapter->enable11d) { 478 - lbs_pr_debug(1, "11D: dnld domain Info with 11d disabled\n"); 474 + lbs_deb_11d("11D: dnld domain Info with 11d disabled\n"); 479 475 return 0; 480 476 } 481 477 ··· 483 479 cmd_act_set, 484 480 cmd_option_waitforrsp, 0, NULL); 485 481 if (ret) 486 - lbs_pr_debug(1, "11D: Fail to dnld domain Info\n"); 482 + lbs_deb_11d("11D: Fail to dnld domain Info\n"); 487 483 488 484 return ret; 489 485 } ··· 505 501 506 502 adapter->universal_channel[i].nrcfp = 507 503 sizeof(channel_freq_power_UN_BG) / size; 508 - lbs_pr_debug(1, "11D: BG-band nrcfp=%d\n", 504 + lbs_deb_11d("11D: BG-band nrcfp=%d\n", 509 505 adapter->universal_channel[i].nrcfp); 510 506 511 507 adapter->universal_channel[i].CFP = channel_freq_power_UN_BG; ··· 535 531 wlan_adapter *adapter = priv->adapter; 536 532 u8 nr_subband = adapter->domainreg.nr_subband; 537 533 538 - ENTER(); 534 + lbs_deb_enter(LBS_DEB_11D); 539 535 540 - lbs_pr_debug(1, "nr_subband=%x\n", nr_subband); 536 + lbs_deb_11d("nr_subband=%x\n", nr_subband); 541 537 542 538 cmd->command = cpu_to_le16(cmdno); 543 539 pdomaininfo->action = cpu_to_le16(cmdoption); ··· 546 542 cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN); 547 543 lbs_dbg_hex("11D: 802_11D_DOMAIN_INFO:", (u8 *) cmd, 548 544 (int)(cmd->size)); 549 - LEAVE(); 550 - return 0; 545 + goto done; 551 546 } 552 547 553 548 domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN); ··· 570 567 cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN); 571 568 } 572 569 573 - lbs_dbg_hex("11D:802_11D_DOMAIN_INFO:", (u8 *) cmd, (int)(cmd->size)); 570 + lbs_dbg_hex("11D:802_11D_DOMAIN_INFO:", (u8 *) cmd, le16_to_cpu(cmd->size)); 574 571 575 - LEAVE(); 576 - 572 + done: 573 + lbs_deb_enter(LBS_DEB_11D); 577 574 return 0; 578 575 } 579 576 ··· 588 585 int data = 0; 589 586 int *val; 590 587 591 - ENTER(); 588 + lbs_deb_enter(LBS_DEB_11D); 592 589 data = SUBCMD_DATA(wrq); 593 590 594 - lbs_pr_debug(1, "enable 11D: %s\n", 591 + lbs_deb_11d("enable 11D: %s\n", 595 592 (data == 1) ? "enable" : "Disable"); 596 593 597 594 wlan_enable_11d(priv, data); 598 595 val = (int *)wrq->u.name; 599 596 *val = priv->adapter->enable11d; 600 597 601 - LEAVE(); 598 + lbs_deb_enter(LBS_DEB_11D); 602 599 return 0; 603 600 } 604 601 ··· 611 608 int libertas_ret_802_11d_domain_info(wlan_private * priv, 612 609 struct cmd_ds_command *resp) 613 610 { 614 - struct cmd_ds_802_11d_domain_info 615 - *domaininfo = &resp->params.domaininforesp; 611 + struct cmd_ds_802_11d_domain_info *domaininfo = &resp->params.domaininforesp; 616 612 struct mrvlietypes_domainparamset *domain = &domaininfo->domain; 617 613 u16 action = le16_to_cpu(domaininfo->action); 618 614 s16 ret = 0; 619 615 u8 nr_subband = 0; 620 616 621 - ENTER(); 617 + lbs_deb_enter(LBS_DEB_11D); 622 618 623 619 lbs_dbg_hex("11D DOMAIN Info Rsp Data:", (u8 *) resp, 624 620 (int)le16_to_cpu(resp->size)); 625 621 626 - nr_subband = (domain->header.len - 3) / sizeof(struct ieeetypes_subbandset); 627 - /* countrycode 3 bytes */ 622 + nr_subband = (le16_to_cpu(domain->header.len) - COUNTRY_CODE_LEN) / 623 + sizeof(struct ieeetypes_subbandset); 628 624 629 - lbs_pr_debug(1, "11D Domain Info Resp: nr_subband=%d\n", nr_subband); 625 + lbs_deb_11d("11D Domain Info Resp: nr_subband=%d\n", nr_subband); 630 626 631 627 if (nr_subband > MRVDRV_MAX_SUBBAND_802_11D) { 632 - lbs_pr_debug(1, "Invalid Numrer of Subband returned!!\n"); 628 + lbs_deb_11d("Invalid Numrer of Subband returned!!\n"); 633 629 return -1; 634 630 } 635 631 ··· 639 637 case cmd_act_get: 640 638 break; 641 639 default: 642 - lbs_pr_debug(1, "Invalid action:%d\n", domaininfo->action); 640 + lbs_deb_11d("Invalid action:%d\n", domaininfo->action); 643 641 ret = -1; 644 642 break; 645 643 } 646 644 647 - LEAVE(); 645 + lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret); 648 646 return ret; 649 647 } 650 648 ··· 653 651 * @param priv pointer to wlan_private 654 652 * @return 0; -1 655 653 */ 656 - int libertas_parse_dnld_countryinfo_11d(wlan_private * priv) 654 + int libertas_parse_dnld_countryinfo_11d(wlan_private * priv, 655 + struct bss_descriptor * bss) 657 656 { 658 657 int ret; 659 658 wlan_adapter *adapter = priv->adapter; 660 659 661 - ENTER(); 660 + lbs_deb_enter(LBS_DEB_11D); 662 661 if (priv->adapter->enable11d) { 663 662 memset(&adapter->parsed_region_chan, 0, 664 663 sizeof(struct parsed_region_chan_11d)); 665 - ret = parse_domain_info_11d(&adapter->pattemptedbssdesc-> 666 - countryinfo, 0, 664 + ret = parse_domain_info_11d(&bss->countryinfo, 0, 667 665 &adapter->parsed_region_chan); 668 666 669 667 if (ret == -1) { 670 - lbs_pr_debug(1, "11D: Err Parse domain_info from AP..\n"); 671 - LEAVE(); 672 - return ret; 668 + lbs_deb_11d("11D: Err Parse domain_info from AP..\n"); 669 + goto done; 673 670 } 674 671 675 672 memset(&adapter->domainreg, 0, ··· 679 678 ret = set_domain_info_11d(priv); 680 679 681 680 if (ret) { 682 - lbs_pr_debug(1, "11D: Err set domainInfo to FW\n"); 683 - LEAVE(); 684 - return ret; 681 + lbs_deb_11d("11D: Err set domainInfo to FW\n"); 682 + goto done; 685 683 } 686 684 } 687 - LEAVE(); 688 - return 0; 685 + ret = 0; 686 + 687 + done: 688 + lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret); 689 + return ret; 689 690 } 690 691 691 692 /** ··· 702 699 struct region_channel *region_chan; 703 700 u8 j; 704 701 705 - ENTER(); 706 - lbs_pr_debug(1, "11D:curbssparams.band[%d]\n", adapter->curbssparams.band); 702 + lbs_deb_enter(LBS_DEB_11D); 703 + lbs_deb_11d("11D:curbssparams.band[%d]\n", adapter->curbssparams.band); 707 704 708 705 if (priv->adapter->enable11d) { 709 706 /* update parsed_region_chan_11; dnld domaininf to FW */ ··· 712 709 sizeof(adapter->region_channel[0]); j++) { 713 710 region_chan = &adapter->region_channel[j]; 714 711 715 - lbs_pr_debug(1, "11D:[%d] region_chan->band[%d]\n", j, 712 + lbs_deb_11d("11D:[%d] region_chan->band[%d]\n", j, 716 713 region_chan->band); 717 714 718 715 if (!region_chan || !region_chan->valid ··· 725 722 726 723 if (j >= sizeof(adapter->region_channel) / 727 724 sizeof(adapter->region_channel[0])) { 728 - lbs_pr_debug(1, "11D:region_chan not found. band[%d]\n", 725 + lbs_deb_11d("11D:region_chan not found. band[%d]\n", 729 726 adapter->curbssparams.band); 730 - LEAVE(); 731 - return -1; 727 + ret = -1; 728 + goto done; 732 729 } 733 730 734 731 memset(&adapter->parsed_region_chan, 0, ··· 745 742 ret = set_domain_info_11d(priv); 746 743 747 744 if (ret) { 748 - lbs_pr_debug(1, "11D: Err set domainInfo to FW\n"); 749 - LEAVE(); 750 - return ret; 745 + lbs_deb_11d("11D: Err set domainInfo to FW\n"); 746 + goto done; 751 747 } 752 748 753 749 } 750 + ret = 0; 754 751 755 - LEAVE(); 756 - return 0; 752 + done: 753 + lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret); 754 + return ret; 757 755 }
+4 -2
drivers/net/wireless/libertas/11d.h
··· 47 47 } __attribute__ ((packed)); 48 48 49 49 struct cmd_ds_802_11d_domain_info { 50 - u16 action; 50 + __le16 action; 51 51 struct mrvlietypes_domainparamset domain; 52 52 } __attribute__ ((packed)); 53 53 ··· 98 98 int libertas_ret_802_11d_domain_info(wlan_private * priv, 99 99 struct cmd_ds_command *resp); 100 100 101 - int libertas_parse_dnld_countryinfo_11d(wlan_private * priv); 101 + struct bss_descriptor; 102 + int libertas_parse_dnld_countryinfo_11d(wlan_private * priv, 103 + struct bss_descriptor * bss); 102 104 103 105 int libertas_create_dnld_countryinfo_11d(wlan_private * priv); 104 106
+2 -2
drivers/net/wireless/libertas/Makefile
··· 1 - usb8xxx-objs := main.o fw.o wext.o \ 1 + libertas-objs := main.o fw.o wext.o \ 2 2 rx.o tx.o cmd.o \ 3 3 cmdresp.o scan.o \ 4 4 join.o 11d.o \ ··· 8 8 usb8xxx-objs += if_bootcmd.o 9 9 usb8xxx-objs += if_usb.o 10 10 11 + obj-$(CONFIG_LIBERTAS) += libertas.o 11 12 obj-$(CONFIG_LIBERTAS_USB) += usb8xxx.o 12 -
+20 -32
drivers/net/wireless/libertas/README
··· 1 1 ================================================================================ 2 2 README for USB8388 3 3 4 - (c) Copyright � 2003-2006, Marvell International Ltd. 4 + (c) Copyright © 2003-2006, Marvell International Ltd. 5 5 All Rights Reserved 6 6 7 7 This software file (the "File") is distributed by Marvell International ··· 47 47 iwpriv ethX ledgpio <n> 48 48 49 49 BT Commands: 50 - The blinding table (BT) contains a list of mac addresses that should be 51 - ignored by the firmware. It is primarily used for debugging and 52 - testing networks. It can be edited and inspected with the following 53 - commands: 50 + The blinding table (BT) contains a list of mac addresses that will be, 51 + by default, ignored by the firmware. It is also possible to invert this 52 + behavior so that we will ignore all traffic except for the portion 53 + coming from mac addresess in the list. It is primarily used for 54 + debugging and testing networks. It can be edited and inspected with 55 + the following commands: 54 56 55 57 iwpriv ethX bt_reset 56 58 iwpriv ethX bt_add <mac_address> 57 59 iwpriv ethX bt_del <mac_address> 58 60 iwpriv ethX bt_list <id> 61 + iwpriv ethX bt_get_invert <n> 62 + iwpriv ethX bt_set_invert <n> 59 63 60 64 FWT Commands: 61 65 The forwarding table (FWT) is a feature used to manage mesh network ··· 139 135 This command is used to insert an entry into the FWT table. The list of 140 136 parameters must follow the following structure: 141 137 142 - iwpriv ethX fwt_add da ra [metric dir ssn dsn hopcount ttl expiration sleepmode snr] 138 + iwpriv ethX fwt_add da ra [metric dir rate ssn dsn hopcount ttl expiration sleepmode snr] 143 139 144 140 The parameters between brackets are optional, but they must appear in 145 141 the order specified. For example, if you want to specify the metric, ··· 154 150 preferred, default is 0) 155 151 dir -- direction (1 for direct, 0 for reverse, 156 152 default is 1) 153 + rate -- data rate used for transmission to the RA, 154 + as specified for the rateadapt command, 155 + default is 3 (11Mbps) 157 156 ssn -- Source Sequence Number (time at the RA for 158 157 reverse routes. Default is 0) 159 158 dsn -- Destination Sequence Number (time at the DA ··· 214 207 215 208 The output is a string of the following form: 216 209 217 - da ra metric dir ssn dsn hopcount ttl expiration sleepmode snr 210 + da ra valid metric dir rate ssn dsn hopcount ttl expiration 211 + sleepmode snr precursor 218 212 219 213 where the different fields are:- 220 214 da -- DA MAC address (in the form "00:11:22:33:44:55") 221 215 ra -- RA MAC address (in the form "00:11:22:33:44:55") 216 + valid -- whether the route is valid (0 if not valid) 222 217 metric -- route metric (cost: smaller-metric routes are preferred) 223 218 dir -- direction (1 for direct, 0 for reverse) 219 + rate -- data rate used for transmission to the RA, 220 + as specified for the rateadapt command 224 221 ssn -- Source Sequence Number (time at the RA for reverse routes) 225 222 dsn -- Destination Sequence Number (time at the DA for direct routes) 226 223 hopcount -- hop count (currently unused) ··· 232 221 expiration -- entry expiration (in ticks, where a tick is 1024us, or ~ 1ms. Use 0 for an indefinite entry) 233 222 sleepmode -- RA's sleep mode (currently unused) 234 223 snr -- SNR in the link to RA (currently unused) 224 + precursor -- predecessor in direct routes 235 225 236 226 fwt_list_route 237 - This command is used to list a route from the FWT table. The only 238 - parameter is the route ID. If you want to list all the routes in a 239 - table, start with rid=0, and keep incrementing rid until you get a 240 - "(null)" string. This function is similar to fwt_list. The only 241 - difference is the output format. Also note that this command is meant 242 - for debugging. It is expected that users will use fwt_lookup and 243 - fwt_list. One important reason for this is that the route id may change 244 - as the route table is altered. 245 - 246 - iwpriv ethX fwt_list_route rid 247 - 248 - The output is a string of the following form: 249 - 250 - da metric dir nid ssn dsn hopcount ttl expiration 251 - 252 - where the different fields are:- 253 - da -- DA MAC address (in the form "00:11:22:33:44:55") 254 - metric -- route metric (cost: smaller-metric routes are preferred) 255 - dir -- direction (1 for direct, 0 for reverse) 256 - nid -- Next-hop (neighbor) host ID (nid) 257 - ssn -- Source Sequence Number (time at the RA for reverse routes) 258 - dsn -- Destination Sequence Number (time at the DA for direct routes) 259 - hopcount -- hop count (currently unused) 260 - ttl -- TTL count (only used in reverse entries) 261 - expiration -- entry expiration (in ticks, where a tick is 1024us, or ~ 1ms. Use 0 for an indefinite entry) 227 + This command is equivalent to fwt_list. 262 228 263 229 fwt_list_neigh 264 230 This command is used to list a neighbor from the FWT table. The only
+242 -116
drivers/net/wireless/libertas/assoc.c
··· 2 2 3 3 #include <linux/bitops.h> 4 4 #include <net/ieee80211.h> 5 + #include <linux/etherdevice.h> 5 6 6 7 #include "assoc.h" 7 8 #include "join.h" ··· 14 13 static const u8 bssid_any[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 15 14 static const u8 bssid_off[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 16 15 16 + static void print_assoc_req(const char * extra, struct assoc_request * assoc_req) 17 + { 18 + lbs_deb_assoc( 19 + "#### Association Request: %s\n" 20 + " flags: 0x%08lX\n" 21 + " SSID: '%s'\n" 22 + " channel: %d\n" 23 + " band: %d\n" 24 + " mode: %d\n" 25 + " BSSID: " MAC_FMT "\n" 26 + " Encryption:%s%s%s\n" 27 + " auth: %d\n", 28 + extra, assoc_req->flags, 29 + escape_essid(assoc_req->ssid, assoc_req->ssid_len), 30 + assoc_req->channel, assoc_req->band, assoc_req->mode, 31 + MAC_ARG(assoc_req->bssid), 32 + assoc_req->secinfo.WPAenabled ? " WPA" : "", 33 + assoc_req->secinfo.WPA2enabled ? " WPA2" : "", 34 + assoc_req->secinfo.wep_enabled ? " WEP" : "", 35 + assoc_req->secinfo.auth_mode); 36 + } 37 + 38 + 17 39 static int assoc_helper_essid(wlan_private *priv, 18 40 struct assoc_request * assoc_req) 19 41 { 20 42 wlan_adapter *adapter = priv->adapter; 21 43 int ret = 0; 22 - int i; 44 + struct bss_descriptor * bss; 45 + int channel = -1; 23 46 24 - ENTER(); 47 + lbs_deb_enter(LBS_DEB_ASSOC); 25 48 26 - lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); 49 + /* FIXME: take channel into account when picking SSIDs if a channel 50 + * is set. 51 + */ 52 + 53 + if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) 54 + channel = assoc_req->channel; 55 + 56 + lbs_deb_assoc("New SSID requested: '%s'\n", 57 + escape_essid(assoc_req->ssid, assoc_req->ssid_len)); 27 58 if (assoc_req->mode == IW_MODE_INFRA) { 28 59 if (adapter->prescan) { 29 - libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); 60 + libertas_send_specific_ssid_scan(priv, assoc_req->ssid, 61 + assoc_req->ssid_len, 0); 30 62 } 31 63 32 - i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, 33 - NULL, IW_MODE_INFRA); 34 - if (i >= 0) { 35 - lbs_pr_debug(1, 36 - "SSID found in scan list ... associating...\n"); 37 - 38 - ret = wlan_associate(priv, &adapter->scantable[i]); 39 - if (ret == 0) { 40 - memcpy(&assoc_req->bssid, 41 - &adapter->scantable[i].macaddress, 42 - ETH_ALEN); 43 - } 64 + bss = libertas_find_ssid_in_list(adapter, assoc_req->ssid, 65 + assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel); 66 + if (bss != NULL) { 67 + lbs_deb_assoc("SSID found in scan list, associating\n"); 68 + memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); 69 + ret = wlan_associate(priv, assoc_req); 44 70 } else { 45 - lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", 46 - assoc_req->ssid.ssid); 71 + lbs_deb_assoc("SSID not found; cannot associate\n"); 47 72 } 48 73 } else if (assoc_req->mode == IW_MODE_ADHOC) { 49 74 /* Scan for the network, do not save previous results. Stale 50 75 * scan data will cause us to join a non-existant adhoc network 51 76 */ 52 - libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 0); 77 + libertas_send_specific_ssid_scan(priv, assoc_req->ssid, 78 + assoc_req->ssid_len, 1); 53 79 54 80 /* Search for the requested SSID in the scan table */ 55 - i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, 56 - IW_MODE_ADHOC); 57 - if (i >= 0) { 58 - lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); 59 - libertas_join_adhoc_network(priv, &adapter->scantable[i]); 81 + bss = libertas_find_ssid_in_list(adapter, assoc_req->ssid, 82 + assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel); 83 + if (bss != NULL) { 84 + lbs_deb_assoc("SSID found, will join\n"); 85 + memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); 86 + libertas_join_adhoc_network(priv, assoc_req); 60 87 } else { 61 88 /* else send START command */ 62 - lbs_pr_debug(1, "SSID not found in list, so creating adhoc" 63 - " with SSID '%s'\n", assoc_req->ssid.ssid); 64 - libertas_start_adhoc_network(priv, &assoc_req->ssid); 89 + lbs_deb_assoc("SSID not found, creating adhoc network\n"); 90 + memcpy(&assoc_req->bss.ssid, &assoc_req->ssid, 91 + IW_ESSID_MAX_SIZE); 92 + assoc_req->bss.ssid_len = assoc_req->ssid_len; 93 + libertas_start_adhoc_network(priv, assoc_req); 65 94 } 66 - memcpy(&assoc_req->bssid, &adapter->current_addr, ETH_ALEN); 67 95 } 68 96 69 - LEAVE(); 97 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 70 98 return ret; 71 99 } 72 100 ··· 104 74 struct assoc_request * assoc_req) 105 75 { 106 76 wlan_adapter *adapter = priv->adapter; 107 - int i, ret = 0; 77 + int ret = 0; 78 + struct bss_descriptor * bss; 108 79 109 - ENTER(); 110 - 111 - lbs_pr_debug(1, "ASSOC: WAP: BSSID = " MAC_FMT "\n", 80 + lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID " MAC_FMT, 112 81 MAC_ARG(assoc_req->bssid)); 113 82 114 83 /* Search for index position in list for requested MAC */ 115 - i = libertas_find_BSSID_in_list(adapter, assoc_req->bssid, 84 + bss = libertas_find_bssid_in_list(adapter, assoc_req->bssid, 116 85 assoc_req->mode); 117 - if (i < 0) { 118 - lbs_pr_debug(1, "ASSOC: WAP: BSSID " MAC_FMT " not found, " 86 + if (bss == NULL) { 87 + lbs_deb_assoc("ASSOC: WAP: BSSID " MAC_FMT " not found, " 119 88 "cannot associate.\n", MAC_ARG(assoc_req->bssid)); 120 89 goto out; 121 90 } 122 91 92 + memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); 123 93 if (assoc_req->mode == IW_MODE_INFRA) { 124 - ret = wlan_associate(priv, &adapter->scantable[i]); 125 - lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); 94 + ret = wlan_associate(priv, assoc_req); 95 + lbs_deb_assoc("ASSOC: wlan_associate(bssid) returned %d\n", ret); 126 96 } else if (assoc_req->mode == IW_MODE_ADHOC) { 127 - libertas_join_adhoc_network(priv, &adapter->scantable[i]); 97 + libertas_join_adhoc_network(priv, assoc_req); 128 98 } 129 - memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, 130 - sizeof(struct WLAN_802_11_SSID)); 131 99 132 100 out: 133 - LEAVE(); 101 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 134 102 return ret; 135 103 } 136 104 ··· 141 113 /* If we're given and 'any' BSSID, try associating based on SSID */ 142 114 143 115 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { 144 - if (memcmp(bssid_any, assoc_req->bssid, ETH_ALEN) 145 - && memcmp(bssid_off, assoc_req->bssid, ETH_ALEN)) { 116 + if (compare_ether_addr(bssid_any, assoc_req->bssid) 117 + && compare_ether_addr(bssid_off, assoc_req->bssid)) { 146 118 ret = assoc_helper_bssid(priv, assoc_req); 147 119 done = 1; 148 120 if (ret) { 149 - lbs_pr_debug(1, "ASSOC: bssid: ret = %d\n", ret); 121 + lbs_deb_assoc("ASSOC: bssid: ret = %d\n", ret); 150 122 } 151 123 } 152 124 } ··· 154 126 if (!done && test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { 155 127 ret = assoc_helper_essid(priv, assoc_req); 156 128 if (ret) { 157 - lbs_pr_debug(1, "ASSOC: bssid: ret = %d\n", ret); 129 + lbs_deb_assoc("ASSOC: bssid: ret = %d\n", ret); 158 130 } 159 131 } 160 132 ··· 168 140 wlan_adapter *adapter = priv->adapter; 169 141 int ret = 0; 170 142 171 - ENTER(); 143 + lbs_deb_enter(LBS_DEB_ASSOC); 172 144 173 - if (assoc_req->mode == adapter->mode) { 174 - LEAVE(); 175 - return 0; 176 - } 145 + if (assoc_req->mode == adapter->mode) 146 + goto done; 177 147 178 148 if (assoc_req->mode == IW_MODE_INFRA) { 179 149 if (adapter->psstate != PS_STATE_FULL_POWER) ··· 184 158 cmd_802_11_snmp_mib, 185 159 0, cmd_option_waitforrsp, 186 160 OID_802_11_INFRASTRUCTURE_MODE, 187 - (void *) (size_t) assoc_req->mode); 161 + /* Shoot me now */ (void *) (size_t) assoc_req->mode); 188 162 189 - LEAVE(); 163 + done: 164 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 165 + return ret; 166 + } 167 + 168 + 169 + static int update_channel(wlan_private * priv) 170 + { 171 + /* the channel in f/w could be out of sync, get the current channel */ 172 + return libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel, 173 + cmd_opt_802_11_rf_channel_get, 174 + cmd_option_waitforrsp, 0, NULL); 175 + } 176 + 177 + void libertas_sync_channel(struct work_struct *work) 178 + { 179 + wlan_private *priv = container_of(work, wlan_private, sync_channel); 180 + 181 + if (update_channel(priv) != 0) 182 + lbs_pr_info("Channel synchronization failed."); 183 + } 184 + 185 + static int assoc_helper_channel(wlan_private *priv, 186 + struct assoc_request * assoc_req) 187 + { 188 + wlan_adapter *adapter = priv->adapter; 189 + int ret = 0; 190 + 191 + lbs_deb_enter(LBS_DEB_ASSOC); 192 + 193 + ret = update_channel(priv); 194 + if (ret < 0) { 195 + lbs_deb_assoc("ASSOC: channel: error getting channel."); 196 + } 197 + 198 + if (assoc_req->channel == adapter->curbssparams.channel) 199 + goto done; 200 + 201 + lbs_deb_assoc("ASSOC: channel: %d -> %d\n", 202 + adapter->curbssparams.channel, assoc_req->channel); 203 + 204 + ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel, 205 + cmd_opt_802_11_rf_channel_set, 206 + cmd_option_waitforrsp, 0, &assoc_req->channel); 207 + if (ret < 0) { 208 + lbs_deb_assoc("ASSOC: channel: error setting channel."); 209 + } 210 + 211 + ret = update_channel(priv); 212 + if (ret < 0) { 213 + lbs_deb_assoc("ASSOC: channel: error getting channel."); 214 + } 215 + 216 + if (assoc_req->channel != adapter->curbssparams.channel) { 217 + lbs_deb_assoc("ASSOC: channel: failed to update channel to %d", 218 + assoc_req->channel); 219 + goto done; 220 + } 221 + 222 + if ( assoc_req->secinfo.wep_enabled 223 + && (assoc_req->wep_keys[0].len 224 + || assoc_req->wep_keys[1].len 225 + || assoc_req->wep_keys[2].len 226 + || assoc_req->wep_keys[3].len)) { 227 + /* Make sure WEP keys are re-sent to firmware */ 228 + set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); 229 + } 230 + 231 + /* Must restart/rejoin adhoc networks after channel change */ 232 + set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); 233 + 234 + done: 235 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 190 236 return ret; 191 237 } 192 238 ··· 270 172 int i; 271 173 int ret = 0; 272 174 273 - ENTER(); 175 + lbs_deb_enter(LBS_DEB_ASSOC); 274 176 275 177 /* Set or remove WEP keys */ 276 178 if ( assoc_req->wep_keys[0].len ··· 314 216 mutex_unlock(&adapter->lock); 315 217 316 218 out: 317 - LEAVE(); 219 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 318 220 return ret; 319 221 } 320 222 ··· 324 226 wlan_adapter *adapter = priv->adapter; 325 227 int ret = 0; 326 228 327 - ENTER(); 229 + lbs_deb_enter(LBS_DEB_ASSOC); 328 230 329 231 memcpy(&adapter->secinfo, &assoc_req->secinfo, 330 232 sizeof(struct wlan_802_11_security)); 331 233 332 234 ret = libertas_set_mac_packet_filter(priv); 235 + if (ret) 236 + goto out; 333 237 334 - LEAVE(); 238 + /* enable/disable RSN */ 239 + ret = libertas_prepare_and_send_command(priv, 240 + cmd_802_11_enable_rsn, 241 + cmd_act_set, 242 + cmd_option_waitforrsp, 243 + 0, assoc_req); 244 + 245 + out: 246 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 335 247 return ret; 336 248 } 337 249 ··· 351 243 { 352 244 int ret = 0; 353 245 354 - ENTER(); 355 - 356 - /* enable/Disable RSN */ 357 - ret = libertas_prepare_and_send_command(priv, 358 - cmd_802_11_enable_rsn, 359 - cmd_act_set, 360 - cmd_option_waitforrsp, 361 - 0, assoc_req); 362 - if (ret) 363 - goto out; 246 + lbs_deb_enter(LBS_DEB_ASSOC); 364 247 365 248 ret = libertas_prepare_and_send_command(priv, 366 249 cmd_802_11_key_material, ··· 359 260 cmd_option_waitforrsp, 360 261 0, assoc_req); 361 262 362 - out: 363 - LEAVE(); 263 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 364 264 return ret; 365 265 } 366 266 ··· 370 272 wlan_adapter *adapter = priv->adapter; 371 273 int ret = 0; 372 274 373 - ENTER(); 275 + lbs_deb_enter(LBS_DEB_ASSOC); 374 276 375 277 if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { 376 278 memcpy(&adapter->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len); ··· 380 282 adapter->wpa_ie_len = 0; 381 283 } 382 284 383 - LEAVE(); 285 + lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 384 286 return ret; 385 287 } 386 288 ··· 392 294 return 0; 393 295 394 296 if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { 395 - lbs_pr_debug(1, "Deauthenticating due to new SSID in " 297 + lbs_deb_assoc("Deauthenticating due to new SSID in " 396 298 " configuration request.\n"); 397 299 return 1; 398 300 } 399 301 400 302 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { 401 303 if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { 402 - lbs_pr_debug(1, "Deauthenticating due to updated security " 304 + lbs_deb_assoc("Deauthenticating due to updated security " 403 305 "info in configuration request.\n"); 404 306 return 1; 405 307 } 406 308 } 407 309 408 310 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { 409 - lbs_pr_debug(1, "Deauthenticating due to new BSSID in " 311 + lbs_deb_assoc("Deauthenticating due to new BSSID in " 410 312 " configuration request.\n"); 313 + return 1; 314 + } 315 + 316 + if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { 317 + lbs_deb_assoc("Deauthenticating due to channel switch.\n"); 411 318 return 1; 412 319 } 413 320 ··· 432 329 if (adapter->connect_status != libertas_connected) 433 330 return 0; 434 331 435 - if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) 436 - return 1; 437 - if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, 438 - adapter->curbssparams.ssid.ssidlength)) 332 + if (libertas_ssid_cmp(adapter->curbssparams.ssid, 333 + adapter->curbssparams.ssid_len, 334 + assoc_req->ssid, assoc_req->ssid_len) != 0) 439 335 return 1; 440 336 441 337 /* FIXME: deal with 'auto' mode somehow */ ··· 443 341 return 1; 444 342 } 445 343 344 + if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { 345 + if (assoc_req->channel != adapter->curbssparams.channel) 346 + return 1; 347 + } 348 + 446 349 return 0; 447 350 } 448 351 449 352 450 - void wlan_association_worker(struct work_struct *work) 353 + void libertas_association_worker(struct work_struct *work) 451 354 { 452 355 wlan_private *priv = container_of(work, wlan_private, assoc_work.work); 453 356 wlan_adapter *adapter = priv->adapter; ··· 460 353 int ret = 0; 461 354 int find_any_ssid = 0; 462 355 463 - ENTER(); 356 + lbs_deb_enter(LBS_DEB_ASSOC); 464 357 465 358 mutex_lock(&adapter->lock); 466 - assoc_req = adapter->assoc_req; 467 - adapter->assoc_req = NULL; 359 + assoc_req = adapter->pending_assoc_req; 360 + adapter->pending_assoc_req = NULL; 361 + adapter->in_progress_assoc_req = assoc_req; 468 362 mutex_unlock(&adapter->lock); 469 363 470 - if (!assoc_req) { 471 - LEAVE(); 472 - return; 473 - } 364 + if (!assoc_req) 365 + goto done; 474 366 475 - lbs_pr_debug(1, "ASSOC: starting new association request: flags = 0x%lX\n", 476 - assoc_req->flags); 367 + print_assoc_req(__func__, assoc_req); 477 368 478 369 /* If 'any' SSID was specified, find an SSID to associate with */ 479 370 if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags) 480 - && !assoc_req->ssid.ssidlength) 371 + && !assoc_req->ssid_len) 481 372 find_any_ssid = 1; 482 373 483 374 /* But don't use 'any' SSID if there's a valid locked BSSID to use */ 484 375 if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { 485 - if (memcmp(&assoc_req->bssid, bssid_any, ETH_ALEN) 486 - && memcmp(&assoc_req->bssid, bssid_off, ETH_ALEN)) 376 + if (compare_ether_addr(assoc_req->bssid, bssid_any) 377 + && compare_ether_addr(assoc_req->bssid, bssid_off)) 487 378 find_any_ssid = 0; 488 379 } 489 380 490 381 if (find_any_ssid) { 491 382 u8 new_mode; 492 383 493 - ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, 494 - assoc_req->mode, &new_mode); 384 + ret = libertas_find_best_network_ssid(priv, assoc_req->ssid, 385 + &assoc_req->ssid_len, assoc_req->mode, &new_mode); 495 386 if (ret) { 496 - lbs_pr_debug(1, "Could not find best network\n"); 387 + lbs_deb_assoc("Could not find best network\n"); 497 388 ret = -ENETUNREACH; 498 389 goto out; 499 390 } ··· 511 406 if (should_deauth_infrastructure(adapter, assoc_req)) { 512 407 ret = libertas_send_deauthentication(priv); 513 408 if (ret) { 514 - lbs_pr_debug(1, "Deauthentication due to new " 409 + lbs_deb_assoc("Deauthentication due to new " 515 410 "configuration request failed: %d\n", 516 411 ret); 517 412 } ··· 520 415 if (should_stop_adhoc(adapter, assoc_req)) { 521 416 ret = libertas_stop_adhoc_network(priv); 522 417 if (ret) { 523 - lbs_pr_debug(1, "Teardown of AdHoc network due to " 418 + lbs_deb_assoc("Teardown of AdHoc network due to " 524 419 "new configuration request failed: %d\n", 525 420 ret); 526 421 } ··· 532 427 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { 533 428 ret = assoc_helper_mode(priv, assoc_req); 534 429 if (ret) { 535 - lbs_pr_debug(1, "ASSOC(:%d) mode: ret = %d\n", __LINE__, ret); 430 + lbs_deb_assoc("ASSOC(:%d) mode: ret = %d\n", __LINE__, ret); 431 + goto out; 432 + } 433 + } 434 + 435 + if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { 436 + ret = assoc_helper_channel(priv, assoc_req); 437 + if (ret) { 438 + lbs_deb_assoc("ASSOC(:%d) channel: ret = %d\n", 439 + __LINE__, ret); 536 440 goto out; 537 441 } 538 442 } ··· 550 436 || test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) { 551 437 ret = assoc_helper_wep_keys(priv, assoc_req); 552 438 if (ret) { 553 - lbs_pr_debug(1, "ASSOC(:%d) wep_keys: ret = %d\n", __LINE__, ret); 439 + lbs_deb_assoc("ASSOC(:%d) wep_keys: ret = %d\n", __LINE__, ret); 554 440 goto out; 555 441 } 556 442 } ··· 558 444 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { 559 445 ret = assoc_helper_secinfo(priv, assoc_req); 560 446 if (ret) { 561 - lbs_pr_debug(1, "ASSOC(:%d) secinfo: ret = %d\n", __LINE__, ret); 447 + lbs_deb_assoc("ASSOC(:%d) secinfo: ret = %d\n", __LINE__, ret); 562 448 goto out; 563 449 } 564 450 } ··· 566 452 if (test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) { 567 453 ret = assoc_helper_wpa_ie(priv, assoc_req); 568 454 if (ret) { 569 - lbs_pr_debug(1, "ASSOC(:%d) wpa_ie: ret = %d\n", __LINE__, ret); 455 + lbs_deb_assoc("ASSOC(:%d) wpa_ie: ret = %d\n", __LINE__, ret); 570 456 goto out; 571 457 } 572 458 } ··· 575 461 || test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { 576 462 ret = assoc_helper_wpa_keys(priv, assoc_req); 577 463 if (ret) { 578 - lbs_pr_debug(1, "ASSOC(:%d) wpa_keys: ret = %d\n", __LINE__, ret); 464 + lbs_deb_assoc("ASSOC(:%d) wpa_keys: ret = %d\n", __LINE__, ret); 579 465 goto out; 580 466 } 581 467 } ··· 589 475 590 476 ret = assoc_helper_associate(priv, assoc_req); 591 477 if (ret) { 592 - lbs_pr_debug(1, "ASSOC: association attempt unsuccessful: %d\n", 478 + lbs_deb_assoc("ASSOC: association attempt unsuccessful: %d\n", 593 479 ret); 594 480 success = 0; 595 481 } 596 482 597 483 if (adapter->connect_status != libertas_connected) { 598 - lbs_pr_debug(1, "ASSOC: assoication attempt unsuccessful, " 484 + lbs_deb_assoc("ASSOC: assoication attempt unsuccessful, " 599 485 "not connected.\n"); 600 486 success = 0; 601 487 } 602 488 603 489 if (success) { 604 - lbs_pr_debug(1, "ASSOC: association attempt successful. " 490 + lbs_deb_assoc("ASSOC: association attempt successful. " 605 491 "Associated to '%s' (" MAC_FMT ")\n", 606 - assoc_req->ssid.ssid, MAC_ARG(assoc_req->bssid)); 492 + escape_essid(adapter->curbssparams.ssid, 493 + adapter->curbssparams.ssid_len), 494 + MAC_ARG(adapter->curbssparams.bssid)); 607 495 libertas_prepare_and_send_command(priv, 608 496 cmd_802_11_rssi, 609 497 0, cmd_option_waitforrsp, 0, NULL); ··· 614 498 cmd_802_11_get_log, 615 499 0, cmd_option_waitforrsp, 0, NULL); 616 500 } else { 617 - 618 501 ret = -1; 619 502 } 620 503 } 621 504 622 505 out: 623 506 if (ret) { 624 - lbs_pr_debug(1, "ASSOC: reconfiguration attempt unsuccessful: %d\n", 507 + lbs_deb_assoc("ASSOC: reconfiguration attempt unsuccessful: %d\n", 625 508 ret); 626 509 } 510 + 511 + mutex_lock(&adapter->lock); 512 + adapter->in_progress_assoc_req = NULL; 513 + mutex_unlock(&adapter->lock); 627 514 kfree(assoc_req); 628 - LEAVE(); 515 + 516 + done: 517 + lbs_deb_leave(LBS_DEB_ASSOC); 629 518 } 630 519 631 520 ··· 641 520 { 642 521 struct assoc_request * assoc_req; 643 522 644 - if (!adapter->assoc_req) { 645 - adapter->assoc_req = kzalloc(sizeof(struct assoc_request), GFP_KERNEL); 646 - if (!adapter->assoc_req) { 523 + if (!adapter->pending_assoc_req) { 524 + adapter->pending_assoc_req = kzalloc(sizeof(struct assoc_request), 525 + GFP_KERNEL); 526 + if (!adapter->pending_assoc_req) { 647 527 lbs_pr_info("Not enough memory to allocate association" 648 528 " request!\n"); 649 529 return NULL; ··· 654 532 /* Copy current configuration attributes to the association request, 655 533 * but don't overwrite any that are already set. 656 534 */ 657 - assoc_req = adapter->assoc_req; 535 + assoc_req = adapter->pending_assoc_req; 658 536 if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { 659 - memcpy(&assoc_req->ssid, adapter->curbssparams.ssid.ssid, 660 - adapter->curbssparams.ssid.ssidlength); 537 + memcpy(&assoc_req->ssid, &adapter->curbssparams.ssid, 538 + IW_ESSID_MAX_SIZE); 539 + assoc_req->ssid_len = adapter->curbssparams.ssid_len; 661 540 } 662 541 663 542 if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) 664 543 assoc_req->channel = adapter->curbssparams.channel; 544 + 545 + if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags)) 546 + assoc_req->band = adapter->curbssparams.band; 665 547 666 548 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) 667 549 assoc_req->mode = adapter->mode; ··· 707 581 assoc_req->wpa_ie_len = adapter->wpa_ie_len; 708 582 } 709 583 584 + print_assoc_req(__func__, assoc_req); 585 + 710 586 return assoc_req; 711 587 } 712 - 713 -
+6 -4
drivers/net/wireless/libertas/assoc.h
··· 5 5 6 6 #include "dev.h" 7 7 8 - void wlan_association_worker(struct work_struct *work); 8 + void libertas_association_worker(struct work_struct *work); 9 9 10 10 struct assoc_request * wlan_get_association_request(wlan_adapter *adapter); 11 + 12 + void libertas_sync_channel(struct work_struct *work); 11 13 12 14 #define ASSOC_DELAY (HZ / 2) 13 15 static inline void wlan_postpone_association_work(wlan_private *priv) ··· 23 21 static inline void wlan_cancel_association_work(wlan_private *priv) 24 22 { 25 23 cancel_delayed_work(&priv->assoc_work); 26 - if (priv->adapter->assoc_req) { 27 - kfree(priv->adapter->assoc_req); 28 - priv->adapter->assoc_req = NULL; 24 + if (priv->adapter->pending_assoc_req) { 25 + kfree(priv->adapter->pending_assoc_req); 26 + priv->adapter->pending_assoc_req = NULL; 29 27 } 30 28 } 31 29
+259 -300
drivers/net/wireless/libertas/cmd.c
··· 6 6 #include <net/iw_handler.h> 7 7 #include "host.h" 8 8 #include "hostcmd.h" 9 - #include "sbi.h" 10 9 #include "decl.h" 11 10 #include "defs.h" 12 11 #include "dev.h" ··· 25 26 * @param command the command ID 26 27 * @return TRUE or FALSE 27 28 */ 28 - static u8 is_command_allowed_in_ps(u16 command) 29 + static u8 is_command_allowed_in_ps(__le16 command) 29 30 { 30 - int count = sizeof(commands_allowed_in_ps) 31 - / sizeof(commands_allowed_in_ps[0]); 32 31 int i; 33 32 34 - for (i = 0; i < count; i++) { 33 + for (i = 0; i < ARRAY_SIZE(commands_allowed_in_ps); i++) { 35 34 if (command == cpu_to_le16(commands_allowed_in_ps[i])) 36 35 return 1; 37 36 } ··· 41 44 { 42 45 struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec; 43 46 44 - ENTER(); 47 + lbs_deb_enter(LBS_DEB_CMD); 45 48 46 49 cmd->command = cpu_to_le16(cmd_get_hw_spec); 47 - cmd->size = 48 - cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN); 50 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN); 49 51 memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN); 50 52 51 - LEAVE(); 53 + lbs_deb_leave(LBS_DEB_CMD); 52 54 return 0; 53 55 } 54 56 ··· 56 60 u16 cmd_action) 57 61 { 58 62 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode; 59 - u16 action = cmd_action; 60 63 wlan_adapter *adapter = priv->adapter; 61 64 62 - ENTER(); 65 + lbs_deb_enter(LBS_DEB_CMD); 63 66 64 67 cmd->command = cpu_to_le16(cmd_802_11_ps_mode); 65 - cmd->size = 66 - cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) + 67 - S_DS_GEN); 68 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) + 69 + S_DS_GEN); 68 70 psm->action = cpu_to_le16(cmd_action); 69 71 psm->multipledtim = 0; 70 - switch (action) { 72 + switch (cmd_action) { 71 73 case cmd_subcmd_enter_ps: 72 - lbs_pr_debug(1, "PS command:" "SubCode- Enter PS\n"); 73 - lbs_pr_debug(1, "locallisteninterval = %d\n", 74 + lbs_deb_cmd("PS command:" "SubCode- Enter PS\n"); 75 + lbs_deb_cmd("locallisteninterval = %d\n", 74 76 adapter->locallisteninterval); 75 77 76 78 psm->locallisteninterval = ··· 80 86 break; 81 87 82 88 case cmd_subcmd_exit_ps: 83 - lbs_pr_debug(1, "PS command:" "SubCode- Exit PS\n"); 89 + lbs_deb_cmd("PS command:" "SubCode- Exit PS\n"); 84 90 break; 85 91 86 92 case cmd_subcmd_sleep_confirmed: 87 - lbs_pr_debug(1, "PS command: SubCode- sleep confirm\n"); 93 + lbs_deb_cmd("PS command: SubCode- sleep confirm\n"); 88 94 break; 89 95 90 96 default: 91 97 break; 92 98 } 93 99 94 - LEAVE(); 100 + lbs_deb_leave(LBS_DEB_CMD); 95 101 return 0; 96 102 } 97 103 ··· 109 115 cmd->params.inactivity_timeout.action = cpu_to_le16(cmd_action); 110 116 111 117 if (cmd_action) 112 - cmd->params.inactivity_timeout.timeout = 113 - cpu_to_le16(*timeout); 118 + cmd->params.inactivity_timeout.timeout = cpu_to_le16(*timeout); 114 119 else 115 120 cmd->params.inactivity_timeout.timeout = 0; 116 121 ··· 123 130 wlan_adapter *adapter = priv->adapter; 124 131 struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params; 125 132 126 - ENTER(); 133 + lbs_deb_enter(LBS_DEB_CMD); 127 134 128 - cmd->size = 129 - cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) + 130 - S_DS_GEN); 135 + cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) + 136 + S_DS_GEN); 131 137 cmd->command = cpu_to_le16(cmd_802_11_sleep_params); 132 138 133 139 if (cmd_action == cmd_act_get) { ··· 143 151 sp->reserved = cpu_to_le16(adapter->sp.sp_reserved); 144 152 } 145 153 146 - LEAVE(); 154 + lbs_deb_leave(LBS_DEB_CMD); 147 155 return 0; 148 156 } 149 157 ··· 157 165 int ret = 0; 158 166 struct assoc_request * assoc_req = pdata_buf; 159 167 160 - ENTER(); 168 + lbs_deb_enter(LBS_DEB_CMD); 161 169 162 170 cmd->command = cpu_to_le16(cmd_802_11_set_wep); 163 - cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_set_wep)) 164 - + S_DS_GEN); 171 + cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN); 165 172 166 173 if (cmd_act == cmd_act_add) { 167 174 int i; 168 175 169 176 if (!assoc_req) { 170 - lbs_pr_debug(1, "Invalid association request!"); 177 + lbs_deb_cmd("Invalid association request!"); 171 178 ret = -1; 172 179 goto done; 173 180 } ··· 174 183 wep->action = cpu_to_le16(cmd_act_add); 175 184 176 185 /* default tx key index */ 177 - wep->keyindex = cpu_to_le16((u16) 178 - (assoc_req->wep_tx_keyidx & 179 - (u32)cmd_WEP_KEY_INDEX_MASK)); 186 + wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx & 187 + (u32)cmd_WEP_KEY_INDEX_MASK)); 180 188 181 - lbs_pr_debug(1, "Tx key Index: %u\n", wep->keyindex); 189 + lbs_deb_cmd("Tx key Index: %u\n", le16_to_cpu(wep->keyindex)); 182 190 183 191 /* Copy key types and material to host command structure */ 184 192 for (i = 0; i < 4; i++) { ··· 185 195 186 196 switch (pkey->len) { 187 197 case KEY_LEN_WEP_40: 188 - wep->keytype[i] = cmd_type_wep_40_bit; 198 + wep->keytype[i] = 199 + cpu_to_le16(cmd_type_wep_40_bit); 189 200 memmove(&wep->keymaterial[i], pkey->key, 190 201 pkey->len); 191 202 break; 192 203 case KEY_LEN_WEP_104: 193 - wep->keytype[i] = cmd_type_wep_104_bit; 204 + wep->keytype[i] = 205 + cpu_to_le16(cmd_type_wep_104_bit); 194 206 memmove(&wep->keymaterial[i], pkey->key, 195 207 pkey->len); 196 208 break; 197 209 case 0: 198 210 break; 199 211 default: 200 - lbs_pr_debug(1, "Invalid WEP key %d length of %d\n", 212 + lbs_deb_cmd("Invalid WEP key %d length of %d\n", 201 213 i, pkey->len); 202 214 ret = -1; 203 215 goto done; ··· 211 219 wep->action = cpu_to_le16(cmd_act_remove); 212 220 213 221 /* default tx key index */ 214 - wep->keyindex = cpu_to_le16((u16) 215 - (adapter->wep_tx_keyidx & 216 - (u32)cmd_WEP_KEY_INDEX_MASK)); 222 + wep->keyindex = cpu_to_le16((u16)(adapter->wep_tx_keyidx & 223 + (u32)cmd_WEP_KEY_INDEX_MASK)); 217 224 } 218 225 219 226 ret = 0; 220 227 221 228 done: 222 - LEAVE(); 229 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 223 230 return ret; 224 231 } 225 232 226 233 static int wlan_cmd_802_11_enable_rsn(wlan_private * priv, 227 234 struct cmd_ds_command *cmd, 228 - u16 cmd_action) 235 + u16 cmd_action, 236 + void * pdata_buf) 229 237 { 230 238 struct cmd_ds_802_11_enable_rsn *penableRSN = &cmd->params.enbrsn; 231 - wlan_adapter *adapter = priv->adapter; 239 + struct assoc_request * assoc_req = pdata_buf; 240 + 241 + lbs_deb_enter(LBS_DEB_CMD); 232 242 233 243 cmd->command = cpu_to_le16(cmd_802_11_enable_rsn); 234 - cmd->size = 235 - cpu_to_le16(sizeof(struct cmd_ds_802_11_enable_rsn) + 236 - S_DS_GEN); 244 + cmd->size = cpu_to_le16(sizeof(*penableRSN) + S_DS_GEN); 237 245 penableRSN->action = cpu_to_le16(cmd_action); 238 - if (adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { 246 + if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { 239 247 penableRSN->enable = cpu_to_le16(cmd_enable_rsn); 240 248 } else { 241 249 penableRSN->enable = cpu_to_le16(cmd_disable_rsn); 242 250 } 243 251 252 + lbs_deb_leave(LBS_DEB_CMD); 244 253 return 0; 245 254 } 246 255 ··· 252 259 pkeyparamset->keytypeid = cpu_to_le16(pkey->type); 253 260 254 261 if (pkey->flags & KEY_INFO_WPA_ENABLED) { 255 - pkeyparamset->keyinfo = cpu_to_le16(KEY_INFO_WPA_ENABLED); 256 - } else { 257 - pkeyparamset->keyinfo = cpu_to_le16(!KEY_INFO_WPA_ENABLED); 262 + pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED); 258 263 } 259 - 260 264 if (pkey->flags & KEY_INFO_WPA_UNICAST) { 261 265 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_UNICAST); 262 - } else if (pkey->flags & KEY_INFO_WPA_MCAST) { 266 + } 267 + if (pkey->flags & KEY_INFO_WPA_MCAST) { 263 268 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_MCAST); 264 269 } 265 270 ··· 275 284 u16 cmd_action, 276 285 u32 cmd_oid, void *pdata_buf) 277 286 { 278 - wlan_adapter *adapter = priv->adapter; 279 287 struct cmd_ds_802_11_key_material *pkeymaterial = 280 288 &cmd->params.keymaterial; 289 + struct assoc_request * assoc_req = pdata_buf; 281 290 int ret = 0; 282 291 int index = 0; 283 292 284 - ENTER(); 293 + lbs_deb_enter(LBS_DEB_CMD); 285 294 286 295 cmd->command = cpu_to_le16(cmd_802_11_key_material); 287 296 pkeymaterial->action = cpu_to_le16(cmd_action); 288 297 289 298 if (cmd_action == cmd_act_get) { 290 - cmd->size = cpu_to_le16( S_DS_GEN 291 - + sizeof (pkeymaterial->action)); 299 + cmd->size = cpu_to_le16(S_DS_GEN + sizeof (pkeymaterial->action)); 292 300 ret = 0; 293 301 goto done; 294 302 } 295 303 296 304 memset(&pkeymaterial->keyParamSet, 0, sizeof(pkeymaterial->keyParamSet)); 297 305 298 - if (adapter->wpa_unicast_key.len) { 306 + if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { 299 307 set_one_wpa_key(&pkeymaterial->keyParamSet[index], 300 - &adapter->wpa_unicast_key); 308 + &assoc_req->wpa_unicast_key); 301 309 index++; 302 310 } 303 311 304 - if (adapter->wpa_mcast_key.len) { 312 + if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { 305 313 set_one_wpa_key(&pkeymaterial->keyParamSet[index], 306 - &adapter->wpa_mcast_key); 314 + &assoc_req->wpa_mcast_key); 307 315 index++; 308 316 } 309 317 310 318 cmd->size = cpu_to_le16( S_DS_GEN 311 - + sizeof (pkeymaterial->action) 312 - + index * sizeof(struct MrvlIEtype_keyParamSet)); 319 + + sizeof (pkeymaterial->action) 320 + + (index * sizeof(struct MrvlIEtype_keyParamSet))); 313 321 314 322 ret = 0; 315 323 316 324 done: 317 - LEAVE(); 325 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 318 326 return ret; 319 327 } 320 328 ··· 344 354 { 345 355 cmd->command = cpu_to_le16(cmd_802_11_get_stat); 346 356 cmd->size = 347 - cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + 348 - S_DS_GEN); 357 + cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN); 349 358 350 359 return 0; 351 360 } ··· 358 369 wlan_adapter *adapter = priv->adapter; 359 370 u8 ucTemp; 360 371 361 - ENTER(); 372 + lbs_deb_enter(LBS_DEB_CMD); 362 373 363 - lbs_pr_debug(1, "SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); 374 + lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); 364 375 365 376 cmd->command = cpu_to_le16(cmd_802_11_snmp_mib); 366 - cmd->size = 367 - cpu_to_le16(sizeof(struct cmd_ds_802_11_snmp_mib) + 368 - S_DS_GEN); 377 + cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN); 369 378 370 379 switch (cmd_oid) { 371 380 case OID_802_11_INFRASTRUCTURE_MODE: ··· 394 407 pSNMPMIB->querytype = cmd_act_set; 395 408 pSNMPMIB->bufsize = sizeof(u16); 396 409 ulTemp = *(u32 *)pdata_buf; 397 - *((unsigned short *)(pSNMPMIB->value)) = 410 + *((__le16 *)(pSNMPMIB->value)) = 398 411 cpu_to_le16((u16) ulTemp); 399 412 } 400 413 break; ··· 407 420 pSNMPMIB->oid = cpu_to_le16((u16) fragthresh_i); 408 421 409 422 if (cmd_action == cmd_act_get) { 410 - pSNMPMIB->querytype = 411 - cpu_to_le16(cmd_act_get); 423 + pSNMPMIB->querytype = cpu_to_le16(cmd_act_get); 412 424 } else if (cmd_action == cmd_act_set) { 413 - pSNMPMIB->querytype = 414 - cpu_to_le16(cmd_act_set); 415 - pSNMPMIB->bufsize = 416 - cpu_to_le16(sizeof(u16)); 425 + pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); 426 + pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); 417 427 ulTemp = *((u32 *) pdata_buf); 418 - *((unsigned short *)(pSNMPMIB->value)) = 428 + *((__le16 *)(pSNMPMIB->value)) = 419 429 cpu_to_le16((u16) ulTemp); 420 430 421 431 } ··· 427 443 pSNMPMIB->oid = le16_to_cpu((u16) rtsthresh_i); 428 444 429 445 if (cmd_action == cmd_act_get) { 430 - pSNMPMIB->querytype = 431 - cpu_to_le16(cmd_act_get); 446 + pSNMPMIB->querytype = cpu_to_le16(cmd_act_get); 432 447 } else if (cmd_action == cmd_act_set) { 433 - pSNMPMIB->querytype = 434 - cpu_to_le16(cmd_act_set); 435 - pSNMPMIB->bufsize = 436 - cpu_to_le16(sizeof(u16)); 437 - ulTemp = *((u32 *) 438 - pdata_buf); 439 - *(unsigned short *)(pSNMPMIB->value) = 448 + pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); 449 + pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); 450 + ulTemp = *((u32 *)pdata_buf); 451 + *(__le16 *)(pSNMPMIB->value) = 440 452 cpu_to_le16((u16) ulTemp); 441 453 442 454 } ··· 442 462 pSNMPMIB->oid = cpu_to_le16((u16) short_retrylim_i); 443 463 444 464 if (cmd_action == cmd_act_get) { 445 - pSNMPMIB->querytype = 446 - cpu_to_le16(cmd_act_get); 465 + pSNMPMIB->querytype = cpu_to_le16(cmd_act_get); 447 466 } else if (cmd_action == cmd_act_set) { 448 - pSNMPMIB->querytype = 449 - cpu_to_le16(cmd_act_set); 467 + pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); 450 468 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); 451 - *((unsigned short *)(pSNMPMIB->value)) = 469 + *((__le16 *)(pSNMPMIB->value)) = 452 470 cpu_to_le16((u16) adapter->txretrycount); 453 471 } 454 472 ··· 455 477 break; 456 478 } 457 479 458 - lbs_pr_debug(1, 480 + lbs_deb_cmd( 459 481 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n", 460 - cmd->command, cmd->size, cmd->seqnum, cmd->result); 482 + le16_to_cpu(cmd->command), le16_to_cpu(cmd->size), 483 + le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result)); 461 484 462 - lbs_pr_debug(1, 485 + lbs_deb_cmd( 463 486 "SNMP_CMD: action=0x%x, oid=0x%x, oidsize=0x%x, value=0x%x\n", 464 - pSNMPMIB->querytype, pSNMPMIB->oid, pSNMPMIB->bufsize, 465 - *(u16 *) pSNMPMIB->value); 487 + le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid), 488 + le16_to_cpu(pSNMPMIB->bufsize), 489 + le16_to_cpu(*(__le16 *) pSNMPMIB->value)); 466 490 467 - LEAVE(); 491 + lbs_deb_leave(LBS_DEB_CMD); 468 492 return 0; 469 493 } 470 494 ··· 475 495 int cmd_action) 476 496 { 477 497 wlan_adapter *adapter = priv->adapter; 478 - struct cmd_ds_802_11_radio_control *pradiocontrol = 479 - &cmd->params.radio; 498 + struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio; 480 499 481 - ENTER(); 500 + lbs_deb_enter(LBS_DEB_CMD); 482 501 483 502 cmd->size = 484 503 cpu_to_le16((sizeof(struct cmd_ds_802_11_radio_control)) + ··· 506 527 else 507 528 pradiocontrol->control &= cpu_to_le16(~TURN_ON_RF); 508 529 509 - LEAVE(); 530 + lbs_deb_leave(LBS_DEB_CMD); 510 531 return 0; 511 532 } 512 533 ··· 517 538 518 539 struct cmd_ds_802_11_rf_tx_power *prtp = &cmd->params.txp; 519 540 520 - ENTER(); 541 + lbs_deb_enter(LBS_DEB_CMD); 521 542 522 543 cmd->size = 523 - cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + 524 - S_DS_GEN); 544 + cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + S_DS_GEN); 525 545 cmd->command = cpu_to_le16(cmd_802_11_rf_tx_power); 526 - prtp->action = cmd_action; 546 + prtp->action = cpu_to_le16(cmd_action); 527 547 528 - lbs_pr_debug(1, "RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n", cmd->size, 529 - cmd->command, prtp->action); 548 + lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n", 549 + le16_to_cpu(cmd->size), le16_to_cpu(cmd->command), 550 + le16_to_cpu(prtp->action)); 530 551 531 552 switch (cmd_action) { 532 553 case cmd_act_tx_power_opt_get: ··· 536 557 537 558 case cmd_act_tx_power_opt_set_high: 538 559 prtp->action = cpu_to_le16(cmd_act_set); 539 - prtp->currentlevel = 540 - cpu_to_le16(cmd_act_tx_power_index_high); 560 + prtp->currentlevel = cpu_to_le16(cmd_act_tx_power_index_high); 541 561 break; 542 562 543 563 case cmd_act_tx_power_opt_set_mid: 544 564 prtp->action = cpu_to_le16(cmd_act_set); 545 - prtp->currentlevel = 546 - cpu_to_le16(cmd_act_tx_power_index_mid); 565 + prtp->currentlevel = cpu_to_le16(cmd_act_tx_power_index_mid); 547 566 break; 548 567 549 568 case cmd_act_tx_power_opt_set_low: ··· 549 572 prtp->currentlevel = cpu_to_le16(*((u16 *) pdata_buf)); 550 573 break; 551 574 } 552 - LEAVE(); 575 + 576 + lbs_deb_leave(LBS_DEB_CMD); 553 577 return 0; 554 578 } 555 579 ··· 561 583 struct cmd_ds_802_11_rf_antenna *rant = &cmd->params.rant; 562 584 563 585 cmd->command = cpu_to_le16(cmd_802_11_rf_antenna); 564 - cmd->size = 565 - cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_antenna) + 566 - S_DS_GEN); 586 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_antenna) + 587 + S_DS_GEN); 567 588 568 589 rant->action = cpu_to_le16(cmd_action); 569 - if ((cmd_action == cmd_act_set_rx) || 570 - (cmd_action == cmd_act_set_tx)) { 571 - rant->antennamode = 572 - cpu_to_le16((u16) (*(u32 *) pdata_buf)); 590 + if ((cmd_action == cmd_act_set_rx) || (cmd_action == cmd_act_set_tx)) { 591 + rant->antennamode = cpu_to_le16((u16) (*(u32 *) pdata_buf)); 573 592 } 574 593 575 594 return 0; ··· 585 610 + S_DS_GEN); 586 611 cmd->command = cpu_to_le16(cmd_802_11_rate_adapt_rateset); 587 612 588 - ENTER(); 613 + lbs_deb_enter(LBS_DEB_CMD); 589 614 590 - rateadapt->action = cmd_action; 591 - rateadapt->enablehwauto = adapter->enablehwauto; 592 - rateadapt->bitmap = adapter->ratebitmap; 615 + rateadapt->action = cpu_to_le16(cmd_action); 616 + rateadapt->enablehwauto = cpu_to_le16(adapter->enablehwauto); 617 + rateadapt->bitmap = cpu_to_le16(adapter->ratebitmap); 593 618 594 - LEAVE(); 619 + lbs_deb_leave(LBS_DEB_CMD); 595 620 return 0; 596 621 } 597 622 ··· 601 626 { 602 627 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate; 603 628 wlan_adapter *adapter = priv->adapter; 604 - u16 action = cmd_action; 605 629 606 - ENTER(); 630 + lbs_deb_enter(LBS_DEB_CMD); 607 631 608 - cmd->size = 609 - cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) + 632 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) + 610 633 S_DS_GEN); 611 634 612 635 cmd->command = cpu_to_le16(cmd_802_11_data_rate); ··· 613 640 614 641 pdatarate->action = cpu_to_le16(cmd_action); 615 642 616 - if (action == cmd_act_set_tx_fix_rate) { 643 + if (cmd_action == cmd_act_set_tx_fix_rate) { 617 644 pdatarate->datarate[0] = libertas_data_rate_to_index(adapter->datarate); 618 - lbs_pr_debug(1, "Setting FW for fixed rate 0x%02X\n", 645 + lbs_deb_cmd("Setting FW for fixed rate 0x%02X\n", 619 646 adapter->datarate); 620 - } else if (action == cmd_act_set_tx_auto) { 621 - lbs_pr_debug(1, "Setting FW for AUTO rate\n"); 647 + } else if (cmd_action == cmd_act_set_tx_auto) { 648 + lbs_deb_cmd("Setting FW for AUTO rate\n"); 622 649 } 623 650 624 - LEAVE(); 651 + lbs_deb_leave(LBS_DEB_CMD); 625 652 return 0; 626 653 } 627 654 ··· 632 659 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr; 633 660 wlan_adapter *adapter = priv->adapter; 634 661 635 - cmd->size = 636 - cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) + 662 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) + 637 663 S_DS_GEN); 638 664 cmd->command = cpu_to_le16(cmd_mac_multicast_adr); 639 665 ··· 652 680 struct cmd_ds_802_11_rf_channel *rfchan = &cmd->params.rfchannel; 653 681 654 682 cmd->command = cpu_to_le16(cmd_802_11_rf_channel); 655 - cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) 656 - + S_DS_GEN); 683 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) + 684 + S_DS_GEN); 657 685 658 686 if (option == cmd_opt_802_11_rf_channel_set) { 659 687 rfchan->currentchannel = cpu_to_le16(*((u16 *) pdata_buf)); ··· 670 698 wlan_adapter *adapter = priv->adapter; 671 699 672 700 cmd->command = cpu_to_le16(cmd_802_11_rssi); 673 - cmd->size = 674 - cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN); 675 - cmd->params.rssi.N = priv->adapter->bcn_avg_factor; 701 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN); 702 + cmd->params.rssi.N = cpu_to_le16(priv->adapter->bcn_avg_factor); 676 703 677 704 /* reset Beacon SNR/NF/RSSI values */ 678 705 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0; ··· 690 719 { 691 720 struct wlan_offset_value *offval; 692 721 693 - ENTER(); 722 + lbs_deb_enter(LBS_DEB_CMD); 694 723 695 724 offval = (struct wlan_offset_value *)pdata_buf; 696 725 ··· 700 729 struct cmd_ds_mac_reg_access *macreg; 701 730 702 731 cmdptr->size = 703 - cpu_to_le16(sizeof 704 - (struct cmd_ds_mac_reg_access) 705 - + S_DS_GEN); 732 + cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access) 733 + + S_DS_GEN); 706 734 macreg = 707 735 (struct cmd_ds_mac_reg_access *)&cmdptr->params. 708 736 macreg; ··· 755 785 break; 756 786 } 757 787 758 - LEAVE(); 788 + lbs_deb_leave(LBS_DEB_CMD); 759 789 return 0; 760 790 } 761 791 ··· 766 796 wlan_adapter *adapter = priv->adapter; 767 797 768 798 cmd->command = cpu_to_le16(cmd_802_11_mac_address); 769 - cmd->size = 770 - cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) + 799 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) + 771 800 S_DS_GEN); 772 801 cmd->result = 0; 773 802 ··· 787 818 { 788 819 struct wlan_ioctl_regrdwr *ea = pdata_buf; 789 820 790 - ENTER(); 821 + lbs_deb_enter(LBS_DEB_CMD); 791 822 792 823 cmd->command = cpu_to_le16(cmd_802_11_eeprom_access); 793 - cmd->size = 794 - cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) + 795 - S_DS_GEN); 824 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) + 825 + S_DS_GEN); 796 826 cmd->result = 0; 797 827 798 828 cmd->params.rdeeprom.action = cpu_to_le16(ea->action); ··· 807 839 u16 cmd_action, void *pdata_buf) 808 840 { 809 841 struct cmd_ds_bt_access *bt_access = &cmd->params.bt; 810 - lbs_pr_debug(1, "BT CMD(%d)\n", cmd_action); 842 + lbs_deb_cmd("BT CMD(%d)\n", cmd_action); 811 843 812 844 cmd->command = cpu_to_le16(cmd_bt_access); 813 - cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) 814 - + S_DS_GEN); 845 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + S_DS_GEN); 815 846 cmd->result = 0; 816 847 bt_access->action = cpu_to_le16(cmd_action); 817 848 ··· 828 861 break; 829 862 case cmd_act_bt_access_reset: 830 863 break; 864 + case cmd_act_bt_access_set_invert: 865 + bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); 866 + break; 867 + case cmd_act_bt_access_get_invert: 868 + break; 831 869 default: 832 870 break; 833 871 } ··· 844 872 u16 cmd_action, void *pdata_buf) 845 873 { 846 874 struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; 847 - lbs_pr_debug(1, "FWT CMD(%d)\n", cmd_action); 875 + lbs_deb_cmd("FWT CMD(%d)\n", cmd_action); 848 876 849 877 cmd->command = cpu_to_le16(cmd_fwt_access); 850 - cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) 851 - + S_DS_GEN); 878 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + S_DS_GEN); 852 879 cmd->result = 0; 853 880 854 881 if (pdata_buf) ··· 865 894 u16 cmd_action, void *pdata_buf) 866 895 { 867 896 struct cmd_ds_mesh_access *mesh_access = &cmd->params.mesh; 868 - lbs_pr_debug(1, "FWT CMD(%d)\n", cmd_action); 897 + lbs_deb_cmd("FWT CMD(%d)\n", cmd_action); 869 898 870 899 cmd->command = cpu_to_le16(cmd_mesh_access); 871 - cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) 872 - + S_DS_GEN); 900 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) + S_DS_GEN); 873 901 cmd->result = 0; 874 902 875 903 if (pdata_buf) ··· 886 916 unsigned long flags; 887 917 struct cmd_ds_command *cmdptr; 888 918 889 - ENTER(); 919 + lbs_deb_enter(LBS_DEB_CMD); 890 920 891 921 if (!cmdnode) { 892 - lbs_pr_debug(1, "QUEUE_CMD: cmdnode is NULL\n"); 922 + lbs_deb_cmd("QUEUE_CMD: cmdnode is NULL\n"); 893 923 goto done; 894 924 } 895 925 896 926 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 897 927 if (!cmdptr) { 898 - lbs_pr_debug(1, "QUEUE_CMD: cmdptr is NULL\n"); 928 + lbs_deb_cmd("QUEUE_CMD: cmdptr is NULL\n"); 899 929 goto done; 900 930 } 901 931 902 932 /* Exit_PS command needs to be queued in the header always. */ 903 933 if (cmdptr->command == cmd_802_11_ps_mode) { 904 934 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode; 905 - if (psm->action == cmd_subcmd_exit_ps) { 935 + if (psm->action == cpu_to_le16(cmd_subcmd_exit_ps)) { 906 936 if (adapter->psstate != PS_STATE_FULL_POWER) 907 937 addtail = 0; 908 938 } ··· 918 948 919 949 spin_unlock_irqrestore(&adapter->driver_lock, flags); 920 950 921 - lbs_pr_debug(1, "QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n", 951 + lbs_deb_cmd("QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n", 922 952 cmdnode, 923 - ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); 953 + le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command)); 924 954 925 955 done: 926 - LEAVE(); 927 - return; 956 + lbs_deb_leave(LBS_DEB_CMD); 928 957 } 929 958 930 959 /* ··· 943 974 u16 cmdsize; 944 975 u16 command; 945 976 946 - ENTER(); 977 + lbs_deb_enter(LBS_DEB_CMD); 947 978 948 979 if (!adapter || !cmdnode) { 949 - lbs_pr_debug(1, "DNLD_CMD: adapter = %p, cmdnode = %p\n", 980 + lbs_deb_cmd("DNLD_CMD: adapter = %p, cmdnode = %p\n", 950 981 adapter, cmdnode); 951 982 if (cmdnode) { 952 983 spin_lock_irqsave(&adapter->driver_lock, flags); ··· 962 993 963 994 spin_lock_irqsave(&adapter->driver_lock, flags); 964 995 if (!cmdptr || !cmdptr->size) { 965 - lbs_pr_debug(1, "DNLD_CMD: cmdptr is Null or cmd size is Zero, " 996 + lbs_deb_cmd("DNLD_CMD: cmdptr is Null or cmd size is Zero, " 966 997 "Not sending\n"); 967 998 __libertas_cleanup_and_insert_cmd(priv, cmdnode); 968 999 spin_unlock_irqrestore(&adapter->driver_lock, flags); ··· 973 1004 adapter->cur_cmd = cmdnode; 974 1005 adapter->cur_cmd_retcode = 0; 975 1006 spin_unlock_irqrestore(&adapter->driver_lock, flags); 976 - lbs_pr_debug(1, "DNLD_CMD:: Before download, size of cmd = %d\n", 977 - cmdptr->size); 1007 + lbs_deb_cmd("DNLD_CMD:: Before download, size of cmd = %d\n", 1008 + le16_to_cpu(cmdptr->size)); 978 1009 979 1010 cmdsize = cmdptr->size; 980 1011 ··· 983 1014 cmdnode->cmdwaitqwoken = 0; 984 1015 cmdsize = cpu_to_le16(cmdsize); 985 1016 986 - ret = libertas_sbi_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize); 1017 + ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize); 987 1018 988 1019 if (ret != 0) { 989 - lbs_pr_debug(1, "DNLD_CMD: Host to Card failed\n"); 1020 + lbs_deb_cmd("DNLD_CMD: Host to Card failed\n"); 990 1021 spin_lock_irqsave(&adapter->driver_lock, flags); 991 1022 __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 992 1023 adapter->cur_cmd = NULL; ··· 995 1026 goto done; 996 1027 } 997 1028 998 - lbs_pr_debug(1, "DNLD_CMD: Sent command 0x%x @ %lu\n", command, jiffies); 1029 + lbs_deb_cmd("DNLD_CMD: Sent command 0x%x @ %lu\n", command, jiffies); 999 1030 lbs_dbg_hex("DNLD_CMD: command", cmdnode->bufvirtualaddr, cmdsize); 1000 1031 1001 1032 /* Setup the timer after transmit command */ 1002 - if (command == cmd_802_11_scan 1003 - || command == cmd_802_11_authenticate 1033 + if (command == cmd_802_11_scan || command == cmd_802_11_authenticate 1004 1034 || command == cmd_802_11_associate) 1005 1035 mod_timer(&adapter->command_timer, jiffies + (10*HZ)); 1006 1036 else ··· 1007 1039 1008 1040 ret = 0; 1009 1041 1010 - done: 1011 - LEAVE(); 1042 + done: 1043 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1012 1044 return ret; 1013 1045 } 1014 1046 ··· 1017 1049 { 1018 1050 struct cmd_ds_mac_control *mac = &cmd->params.macctrl; 1019 1051 1020 - ENTER(); 1052 + lbs_deb_enter(LBS_DEB_CMD); 1021 1053 1022 1054 cmd->command = cpu_to_le16(cmd_mac_control); 1023 - cmd->size = 1024 - cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN); 1055 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN); 1025 1056 mac->action = cpu_to_le16(priv->adapter->currentpacketfilter); 1026 1057 1027 - lbs_pr_debug(1, "wlan_cmd_mac_control(): action=0x%X size=%d\n", 1028 - mac->action, cmd->size); 1058 + lbs_deb_cmd("wlan_cmd_mac_control(): action=0x%X size=%d\n", 1059 + le16_to_cpu(mac->action), le16_to_cpu(cmd->size)); 1029 1060 1030 - LEAVE(); 1061 + lbs_deb_leave(LBS_DEB_CMD); 1031 1062 return 0; 1032 1063 } 1033 1064 ··· 1060 1093 { 1061 1094 int ret = 0; 1062 1095 1063 - ENTER(); 1096 + lbs_deb_enter(LBS_DEB_CMD); 1064 1097 1065 1098 ret = libertas_prepare_and_send_command(priv, 1066 1099 cmd_802_11_radio_control, 1067 1100 cmd_act_set, 1068 1101 cmd_option_waitforrsp, 0, NULL); 1069 1102 1070 - lbs_pr_debug(1, "RADIO_SET: on or off: 0x%X, preamble = 0x%X\n", 1103 + lbs_deb_cmd("RADIO_SET: on or off: 0x%X, preamble = 0x%X\n", 1071 1104 priv->adapter->radioon, priv->adapter->preamble); 1072 1105 1073 - LEAVE(); 1106 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1074 1107 return ret; 1075 1108 } 1076 1109 ··· 1078 1111 { 1079 1112 int ret = 0; 1080 1113 1081 - ENTER(); 1114 + lbs_deb_enter(LBS_DEB_CMD); 1082 1115 1083 - lbs_pr_debug(1, "libertas_set_mac_packet_filter value = %x\n", 1116 + lbs_deb_cmd("libertas_set_mac_packet_filter value = %x\n", 1084 1117 priv->adapter->currentpacketfilter); 1085 1118 1086 1119 /* Send MAC control command to station */ 1087 1120 ret = libertas_prepare_and_send_command(priv, 1088 1121 cmd_mac_control, 0, 0, 0, NULL); 1089 1122 1090 - LEAVE(); 1123 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1091 1124 return ret; 1092 1125 } 1093 1126 ··· 1113 1146 struct cmd_ds_command *cmdptr; 1114 1147 unsigned long flags; 1115 1148 1116 - ENTER(); 1149 + lbs_deb_enter(LBS_DEB_CMD); 1117 1150 1118 1151 if (!adapter) { 1119 - lbs_pr_debug(1, "PREP_CMD: adapter is Null\n"); 1152 + lbs_deb_cmd("PREP_CMD: adapter is Null\n"); 1120 1153 ret = -1; 1121 1154 goto done; 1122 1155 } 1123 1156 1124 1157 if (adapter->surpriseremoved) { 1125 - lbs_pr_debug(1, "PREP_CMD: Card is Removed\n"); 1158 + lbs_deb_cmd("PREP_CMD: Card is Removed\n"); 1126 1159 ret = -1; 1127 1160 goto done; 1128 1161 } ··· 1130 1163 cmdnode = libertas_get_free_cmd_ctrl_node(priv); 1131 1164 1132 1165 if (cmdnode == NULL) { 1133 - lbs_pr_debug(1, "PREP_CMD: No free cmdnode\n"); 1166 + lbs_deb_cmd("PREP_CMD: No free cmdnode\n"); 1134 1167 1135 1168 /* Wake up main thread to execute next command */ 1136 1169 wake_up_interruptible(&priv->mainthread.waitq); ··· 1142 1175 1143 1176 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1144 1177 1145 - lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr=%p, command=0x%X\n", 1178 + lbs_deb_cmd("PREP_CMD: Val of cmd ptr=%p, command=0x%X\n", 1146 1179 cmdptr, cmd_no); 1147 1180 1148 1181 if (!cmdptr) { 1149 - lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); 1182 + lbs_deb_cmd("PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); 1150 1183 libertas_cleanup_and_insert_cmd(priv, cmdnode); 1151 1184 ret = -1; 1152 1185 goto done; ··· 1156 1189 adapter->seqnum++; 1157 1190 cmdptr->seqnum = cpu_to_le16(adapter->seqnum); 1158 1191 1159 - cmdptr->command = cmd_no; 1192 + cmdptr->command = cpu_to_le16(cmd_no); 1160 1193 cmdptr->result = 0; 1161 1194 1162 1195 switch (cmd_no) { ··· 1265 1298 break; 1266 1299 1267 1300 case cmd_802_11_enable_rsn: 1268 - ret = wlan_cmd_802_11_enable_rsn(priv, cmdptr, cmd_action); 1301 + ret = wlan_cmd_802_11_enable_rsn(priv, cmdptr, cmd_action, 1302 + pdata_buf); 1269 1303 break; 1270 1304 1271 1305 case cmd_802_11_key_material: 1272 - ret = wlan_cmd_802_11_key_material(priv, cmdptr, 1273 - cmd_action, cmd_oid, 1274 - pdata_buf); 1306 + ret = wlan_cmd_802_11_key_material(priv, cmdptr, cmd_action, 1307 + cmd_oid, pdata_buf); 1275 1308 break; 1276 1309 1277 1310 case cmd_802_11_pairwise_tsc: ··· 1292 1325 case cmd_802_11_get_afc: 1293 1326 1294 1327 cmdptr->command = cpu_to_le16(cmd_no); 1295 - cmdptr->size = 1296 - cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) + 1297 - S_DS_GEN); 1328 + cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) + 1329 + S_DS_GEN); 1298 1330 1299 1331 memmove(&cmdptr->params.afc, 1300 1332 pdata_buf, sizeof(struct cmd_ds_802_11_afc)); ··· 1372 1406 1373 1407 case cmd_get_tsf: 1374 1408 cmdptr->command = cpu_to_le16(cmd_get_tsf); 1375 - cmdptr->size = 1376 - cpu_to_le16(sizeof(struct cmd_ds_get_tsf) 1377 - + S_DS_GEN); 1409 + cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_get_tsf) + 1410 + S_DS_GEN); 1378 1411 ret = 0; 1379 1412 break; 1380 1413 case cmd_802_11_tx_rate_query: 1381 - cmdptr->command = 1382 - cpu_to_le16(cmd_802_11_tx_rate_query); 1383 - cmdptr->size = 1384 - cpu_to_le16(sizeof(struct cmd_tx_rate_query) + 1385 - S_DS_GEN); 1414 + cmdptr->command = cpu_to_le16(cmd_802_11_tx_rate_query); 1415 + cmdptr->size = cpu_to_le16(sizeof(struct cmd_tx_rate_query) + 1416 + S_DS_GEN); 1386 1417 adapter->txrate = 0; 1387 1418 ret = 0; 1388 1419 break; 1389 1420 default: 1390 - lbs_pr_debug(1, "PREP_CMD: unknown command- %#x\n", cmd_no); 1421 + lbs_deb_cmd("PREP_CMD: unknown command- %#x\n", cmd_no); 1391 1422 ret = -1; 1392 1423 break; 1393 1424 } 1394 1425 1395 1426 /* return error, since the command preparation failed */ 1396 1427 if (ret != 0) { 1397 - lbs_pr_debug(1, "PREP_CMD: command preparation failed\n"); 1428 + lbs_deb_cmd("PREP_CMD: command preparation failed\n"); 1398 1429 libertas_cleanup_and_insert_cmd(priv, cmdnode); 1399 1430 ret = -1; 1400 1431 goto done; ··· 1404 1441 wake_up_interruptible(&priv->mainthread.waitq); 1405 1442 1406 1443 if (wait_option & cmd_option_waitforrsp) { 1407 - lbs_pr_debug(1, "PREP_CMD: Wait for CMD response\n"); 1444 + lbs_deb_cmd("PREP_CMD: Wait for CMD response\n"); 1408 1445 might_sleep(); 1409 1446 wait_event_interruptible(cmdnode->cmdwait_q, 1410 1447 cmdnode->cmdwaitqwoken); ··· 1412 1449 1413 1450 spin_lock_irqsave(&adapter->driver_lock, flags); 1414 1451 if (adapter->cur_cmd_retcode) { 1415 - lbs_pr_debug(1, "PREP_CMD: command failed with return code=%d\n", 1452 + lbs_deb_cmd("PREP_CMD: command failed with return code=%d\n", 1416 1453 adapter->cur_cmd_retcode); 1417 1454 adapter->cur_cmd_retcode = 0; 1418 1455 ret = -1; ··· 1420 1457 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1421 1458 1422 1459 done: 1423 - LEAVE(); 1460 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1424 1461 return ret; 1425 1462 } 1463 + EXPORT_SYMBOL_GPL(libertas_prepare_and_send_command); 1426 1464 1427 1465 /** 1428 1466 * @brief This function allocates the command buffer and link ··· 1441 1477 u8 *ptempvirtualaddr; 1442 1478 wlan_adapter *adapter = priv->adapter; 1443 1479 1444 - ENTER(); 1480 + lbs_deb_enter(LBS_DEB_CMD); 1445 1481 1446 1482 /* Allocate and initialize cmdCtrlNode */ 1447 1483 ulbufsize = sizeof(struct cmd_ctrl_node) * MRVDRV_NUM_OF_CMD_BUFFER; 1448 1484 1449 - if (!(tempcmd_array = kmalloc(ulbufsize, GFP_KERNEL))) { 1450 - lbs_pr_debug(1, 1485 + if (!(tempcmd_array = kzalloc(ulbufsize, GFP_KERNEL))) { 1486 + lbs_deb_cmd( 1451 1487 "ALLOC_CMD_BUF: failed to allocate tempcmd_array\n"); 1452 1488 ret = -1; 1453 1489 goto done; 1454 1490 } 1455 - 1456 1491 adapter->cmd_array = tempcmd_array; 1457 - memset(adapter->cmd_array, 0, ulbufsize); 1458 1492 1459 1493 /* Allocate and initialize command buffers */ 1460 1494 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER; 1461 1495 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) { 1462 - if (!(ptempvirtualaddr = kmalloc(ulbufsize, GFP_KERNEL))) { 1463 - lbs_pr_debug(1, 1496 + if (!(ptempvirtualaddr = kzalloc(ulbufsize, GFP_KERNEL))) { 1497 + lbs_deb_cmd( 1464 1498 "ALLOC_CMD_BUF: ptempvirtualaddr: out of memory\n"); 1465 1499 ret = -1; 1466 1500 goto done; 1467 1501 } 1468 - 1469 - memset(ptempvirtualaddr, 0, ulbufsize); 1470 1502 1471 1503 /* Update command buffer virtual */ 1472 1504 tempcmd_array[i].bufvirtualaddr = ptempvirtualaddr; ··· 1474 1514 } 1475 1515 1476 1516 ret = 0; 1477 - done: 1478 - LEAVE(); 1517 + 1518 + done: 1519 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1479 1520 return ret; 1480 1521 } 1481 1522 ··· 1488 1527 */ 1489 1528 int libertas_free_cmd_buffer(wlan_private * priv) 1490 1529 { 1491 - u32 ulbufsize; 1530 + u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */ 1492 1531 unsigned int i; 1493 1532 struct cmd_ctrl_node *tempcmd_array; 1494 1533 wlan_adapter *adapter = priv->adapter; 1495 1534 1496 - ENTER(); 1535 + lbs_deb_enter(LBS_DEB_CMD); 1497 1536 1498 1537 /* need to check if cmd array is allocated or not */ 1499 1538 if (adapter->cmd_array == NULL) { 1500 - lbs_pr_debug(1, "FREE_CMD_BUF: cmd_array is Null\n"); 1539 + lbs_deb_cmd("FREE_CMD_BUF: cmd_array is Null\n"); 1501 1540 goto done; 1502 1541 } 1503 1542 ··· 1507 1546 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER; 1508 1547 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) { 1509 1548 if (tempcmd_array[i].bufvirtualaddr) { 1510 - lbs_pr_debug(1, "Free all the array\n"); 1549 + lbs_deb_cmd("Free all the array\n"); 1511 1550 kfree(tempcmd_array[i].bufvirtualaddr); 1512 1551 tempcmd_array[i].bufvirtualaddr = NULL; 1513 1552 } ··· 1515 1554 1516 1555 /* Release cmd_ctrl_node */ 1517 1556 if (adapter->cmd_array) { 1518 - lbs_pr_debug(1, "Free cmd_array\n"); 1557 + lbs_deb_cmd("Free cmd_array\n"); 1519 1558 kfree(adapter->cmd_array); 1520 1559 adapter->cmd_array = NULL; 1521 1560 } 1522 1561 1523 1562 done: 1524 - LEAVE(); 1563 + lbs_deb_leave(LBS_DEB_CMD); 1525 1564 return 0; 1526 1565 } 1527 1566 ··· 1547 1586 tempnode = (struct cmd_ctrl_node *)adapter->cmdfreeq.next; 1548 1587 list_del((struct list_head *)tempnode); 1549 1588 } else { 1550 - lbs_pr_debug(1, "GET_CMD_NODE: cmd_ctrl_node is not available\n"); 1589 + lbs_deb_cmd("GET_CMD_NODE: cmd_ctrl_node is not available\n"); 1551 1590 tempnode = NULL; 1552 1591 } 1553 1592 1554 1593 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1555 1594 1556 1595 if (tempnode) { 1596 + /* 1557 1597 lbs_pr_debug(3, "GET_CMD_NODE: cmdCtrlNode available\n"); 1558 1598 lbs_pr_debug(3, "GET_CMD_NODE: cmdCtrlNode Address = %p\n", 1559 1599 tempnode); 1600 + */ 1560 1601 cleanup_cmdnode(tempnode); 1561 1602 } 1562 1603 ··· 1601 1638 struct cmd_ctrl_node *ptempnode, 1602 1639 u32 cmd_oid, u16 wait_option, void *pdata_buf) 1603 1640 { 1604 - ENTER(); 1641 + lbs_deb_enter(LBS_DEB_CMD); 1605 1642 1606 1643 if (!ptempnode) 1607 1644 return; ··· 1610 1647 ptempnode->wait_option = wait_option; 1611 1648 ptempnode->pdata_buf = pdata_buf; 1612 1649 1613 - LEAVE(); 1650 + lbs_deb_leave(LBS_DEB_CMD); 1614 1651 } 1615 1652 1616 1653 /** ··· 1629 1666 unsigned long flags; 1630 1667 int ret = 0; 1631 1668 1632 - lbs_pr_debug(1, "libertas_execute_next_command\n"); 1669 + lbs_deb_enter(LBS_DEB_CMD); 1633 1670 1634 1671 spin_lock_irqsave(&adapter->driver_lock, flags); 1635 1672 ··· 1648 1685 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1649 1686 1650 1687 if (cmdnode) { 1651 - lbs_pr_debug(1, 1688 + lbs_deb_cmd( 1652 1689 "EXEC_NEXT_CMD: Got next command from cmdpendingq\n"); 1653 1690 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1654 1691 1655 1692 if (is_command_allowed_in_ps(cmdptr->command)) { 1656 - if ((adapter->psstate == PS_STATE_SLEEP) 1657 - || (adapter->psstate == PS_STATE_PRE_SLEEP) 1658 - ) { 1659 - lbs_pr_debug(1, 1693 + if ((adapter->psstate == PS_STATE_SLEEP) || 1694 + (adapter->psstate == PS_STATE_PRE_SLEEP)) { 1695 + lbs_deb_cmd( 1660 1696 "EXEC_NEXT_CMD: Cannot send cmd 0x%x in psstate %d\n", 1661 - cmdptr->command, adapter->psstate); 1697 + le16_to_cpu(cmdptr->command), 1698 + adapter->psstate); 1662 1699 ret = -1; 1663 1700 goto done; 1664 1701 } 1665 - lbs_pr_debug(1, "EXEC_NEXT_CMD: OK to send command " 1702 + lbs_deb_cmd("EXEC_NEXT_CMD: OK to send command " 1666 1703 "0x%x in psstate %d\n", 1667 - cmdptr->command, adapter->psstate); 1704 + le16_to_cpu(cmdptr->command), 1705 + adapter->psstate); 1668 1706 } else if (adapter->psstate != PS_STATE_FULL_POWER) { 1669 1707 /* 1670 1708 * 1. Non-PS command: ··· 1701 1737 struct cmd_ds_802_11_ps_mode *psm = 1702 1738 &cmdptr->params.psmode; 1703 1739 1704 - lbs_pr_debug(1, 1740 + lbs_deb_cmd( 1705 1741 "EXEC_NEXT_CMD: PS cmd- action=0x%x\n", 1706 1742 psm->action); 1707 1743 if (psm->action != 1708 1744 cpu_to_le16(cmd_subcmd_exit_ps)) { 1709 - lbs_pr_debug(1, 1745 + lbs_deb_cmd( 1710 1746 "EXEC_NEXT_CMD: Ignore Enter PS cmd\n"); 1711 1747 list_del((struct list_head *)cmdnode); 1712 1748 libertas_cleanup_and_insert_cmd(priv, cmdnode); ··· 1715 1751 goto done; 1716 1752 } 1717 1753 1718 - if ((adapter->psstate == PS_STATE_SLEEP) 1719 - || (adapter->psstate == PS_STATE_PRE_SLEEP) 1720 - ) { 1721 - lbs_pr_debug(1, 1754 + if ((adapter->psstate == PS_STATE_SLEEP) || 1755 + (adapter->psstate == PS_STATE_PRE_SLEEP)) { 1756 + lbs_deb_cmd( 1722 1757 "EXEC_NEXT_CMD: Ignore ExitPS cmd in sleep\n"); 1723 1758 list_del((struct list_head *)cmdnode); 1724 1759 libertas_cleanup_and_insert_cmd(priv, cmdnode); ··· 1727 1764 goto done; 1728 1765 } 1729 1766 1730 - lbs_pr_debug(1, 1767 + lbs_deb_cmd( 1731 1768 "EXEC_NEXT_CMD: Sending Exit_PS down...\n"); 1732 1769 } 1733 1770 } 1734 1771 list_del((struct list_head *)cmdnode); 1735 - lbs_pr_debug(1, "EXEC_NEXT_CMD: Sending 0x%04X command\n", 1736 - cmdptr->command); 1772 + lbs_deb_cmd("EXEC_NEXT_CMD: Sending 0x%04X command\n", 1773 + le16_to_cpu(cmdptr->command)); 1737 1774 DownloadcommandToStation(priv, cmdnode); 1738 1775 } else { 1739 1776 /* ··· 1743 1780 if ((adapter->psmode != wlan802_11powermodecam) && 1744 1781 (adapter->psstate == PS_STATE_FULL_POWER) && 1745 1782 (adapter->connect_status == libertas_connected)) { 1746 - if (adapter->secinfo.WPAenabled 1747 - || adapter->secinfo.WPA2enabled) { 1783 + if (adapter->secinfo.WPAenabled || 1784 + adapter->secinfo.WPA2enabled) { 1748 1785 /* check for valid WPA group keys */ 1749 - if (adapter->wpa_mcast_key.len 1750 - || adapter->wpa_unicast_key.len) { 1751 - lbs_pr_debug(1, 1786 + if (adapter->wpa_mcast_key.len || 1787 + adapter->wpa_unicast_key.len) { 1788 + lbs_deb_cmd( 1752 1789 "EXEC_NEXT_CMD: WPA enabled and GTK_SET" 1753 1790 " go back to PS_SLEEP"); 1754 1791 libertas_ps_sleep(priv, 0); 1755 1792 } 1756 1793 } else { 1757 - lbs_pr_debug(1, 1794 + lbs_deb_cmd( 1758 1795 "EXEC_NEXT_CMD: command PendQ is empty," 1759 1796 " go back to PS_SLEEP"); 1760 1797 libertas_ps_sleep(priv, 0); ··· 1764 1801 1765 1802 ret = 0; 1766 1803 done: 1804 + lbs_deb_leave(LBS_DEB_CMD); 1767 1805 return ret; 1768 1806 } 1769 1807 ··· 1773 1809 union iwreq_data iwrq; 1774 1810 u8 buf[50]; 1775 1811 1776 - ENTER(); 1812 + lbs_deb_enter(LBS_DEB_CMD); 1777 1813 1778 1814 memset(&iwrq, 0, sizeof(union iwreq_data)); 1779 1815 memset(buf, 0, sizeof(buf)); ··· 1783 1819 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN; 1784 1820 1785 1821 /* Send Event to upper layer */ 1786 - lbs_pr_debug(1, "Event Indication string = %s\n", 1787 - (char *)buf); 1788 - lbs_pr_debug(1, "Event Indication String length = %d\n", iwrq.data.length); 1822 + lbs_deb_cmd("Event Indication string = %s\n", (char *)buf); 1823 + lbs_deb_cmd("Event Indication String length = %d\n", iwrq.data.length); 1789 1824 1790 - lbs_pr_debug(1, "Sending wireless event IWEVCUSTOM for %s\n", str); 1791 - wireless_send_event(priv->wlan_dev.netdev, IWEVCUSTOM, &iwrq, buf); 1825 + lbs_deb_cmd("Sending wireless event IWEVCUSTOM for %s\n", str); 1826 + wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf); 1792 1827 1793 - LEAVE(); 1794 - return; 1828 + lbs_deb_leave(LBS_DEB_CMD); 1795 1829 } 1796 1830 1797 1831 static int sendconfirmsleep(wlan_private * priv, u8 * cmdptr, u16 size) ··· 1798 1836 wlan_adapter *adapter = priv->adapter; 1799 1837 int ret = 0; 1800 1838 1801 - ENTER(); 1839 + lbs_deb_enter(LBS_DEB_CMD); 1802 1840 1803 - lbs_pr_debug(1, "SEND_SLEEPC_CMD: Before download, size of cmd = %d\n", 1841 + lbs_deb_cmd("SEND_SLEEPC_CMD: Before download, size of cmd = %d\n", 1804 1842 size); 1805 1843 1806 1844 lbs_dbg_hex("SEND_SLEEPC_CMD: Sleep confirm command", cmdptr, size); 1807 1845 1808 - ret = libertas_sbi_host_to_card(priv, MVMS_CMD, cmdptr, size); 1809 - priv->wlan_dev.dnld_sent = DNLD_RES_RECEIVED; 1846 + ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size); 1847 + priv->dnld_sent = DNLD_RES_RECEIVED; 1810 1848 1811 1849 spin_lock_irqsave(&adapter->driver_lock, flags); 1812 1850 if (adapter->intcounter || adapter->currenttxskb) 1813 - lbs_pr_debug(1, "SEND_SLEEPC_CMD: intcounter=%d currenttxskb=%p\n", 1851 + lbs_deb_cmd("SEND_SLEEPC_CMD: intcounter=%d currenttxskb=%p\n", 1814 1852 adapter->intcounter, adapter->currenttxskb); 1815 1853 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1816 1854 ··· 1822 1860 if (!adapter->intcounter) { 1823 1861 adapter->psstate = PS_STATE_SLEEP; 1824 1862 } else { 1825 - lbs_pr_debug(1, "SEND_SLEEPC_CMD: After sent,IntC=%d\n", 1863 + lbs_deb_cmd("SEND_SLEEPC_CMD: After sent,IntC=%d\n", 1826 1864 adapter->intcounter); 1827 1865 } 1828 1866 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1829 1867 1830 - lbs_pr_debug(1, "SEND_SLEEPC_CMD: Sent Confirm Sleep command\n"); 1831 - lbs_pr_debug(1, "+"); 1868 + lbs_deb_cmd("SEND_SLEEPC_CMD: Sent Confirm Sleep command\n"); 1869 + lbs_deb_cmd("+"); 1832 1870 } 1833 1871 1834 - LEAVE(); 1872 + lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1835 1873 return ret; 1836 1874 } 1837 1875 1838 1876 void libertas_ps_sleep(wlan_private * priv, int wait_option) 1839 1877 { 1840 - 1841 - ENTER(); 1878 + lbs_deb_enter(LBS_DEB_CMD); 1842 1879 1843 1880 /* 1844 1881 * PS is currently supported only in Infrastructure mode ··· 1847 1886 libertas_prepare_and_send_command(priv, cmd_802_11_ps_mode, 1848 1887 cmd_subcmd_enter_ps, wait_option, 0, NULL); 1849 1888 1850 - LEAVE(); 1851 - return; 1889 + lbs_deb_leave(LBS_DEB_CMD); 1852 1890 } 1853 1891 1854 1892 /** ··· 1859 1899 */ 1860 1900 void libertas_ps_wakeup(wlan_private * priv, int wait_option) 1861 1901 { 1862 - enum WLAN_802_11_POWER_MODE Localpsmode; 1902 + __le32 Localpsmode; 1863 1903 1864 - ENTER(); 1904 + lbs_deb_enter(LBS_DEB_CMD); 1865 1905 1866 - Localpsmode = wlan802_11powermodecam; 1906 + Localpsmode = cpu_to_le32(wlan802_11powermodecam); 1867 1907 1868 - lbs_pr_debug(1, "Exit_PS: Localpsmode = %d\n", Localpsmode); 1908 + lbs_deb_cmd("Exit_PS: Localpsmode = %d\n", wlan802_11powermodecam); 1869 1909 1870 1910 libertas_prepare_and_send_command(priv, cmd_802_11_ps_mode, 1871 1911 cmd_subcmd_exit_ps, 1872 1912 wait_option, 0, &Localpsmode); 1873 1913 1874 - LEAVE(); 1875 - return; 1914 + lbs_deb_leave(LBS_DEB_CMD); 1876 1915 } 1877 1916 1878 1917 /** ··· 1888 1929 wlan_adapter *adapter = priv->adapter; 1889 1930 u8 allowed = 1; 1890 1931 1891 - ENTER(); 1932 + lbs_deb_enter(LBS_DEB_CMD); 1892 1933 1893 - if (priv->wlan_dev.dnld_sent) { 1934 + if (priv->dnld_sent) { 1894 1935 allowed = 0; 1895 - lbs_pr_debug(1, "D"); 1936 + lbs_deb_cmd("D"); 1896 1937 } 1897 1938 1898 1939 spin_lock_irqsave(&adapter->driver_lock, flags); 1899 1940 if (adapter->cur_cmd) { 1900 1941 allowed = 0; 1901 - lbs_pr_debug(1, "C"); 1942 + lbs_deb_cmd("C"); 1902 1943 } 1903 1944 if (adapter->intcounter > 0) { 1904 1945 allowed = 0; 1905 - lbs_pr_debug(1, "I%d", adapter->intcounter); 1946 + lbs_deb_cmd("I%d", adapter->intcounter); 1906 1947 } 1907 1948 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1908 1949 1909 1950 if (allowed) { 1910 - lbs_pr_debug(1, "Sending libertas_ps_confirm_sleep\n"); 1951 + lbs_deb_cmd("Sending libertas_ps_confirm_sleep\n"); 1911 1952 sendconfirmsleep(priv, (u8 *) & adapter->libertas_ps_confirm_sleep, 1912 1953 sizeof(struct PS_CMD_ConfirmSleep)); 1913 1954 } else { 1914 - lbs_pr_debug(1, "Sleep Confirm has been delayed\n"); 1955 + lbs_deb_cmd("Sleep Confirm has been delayed\n"); 1915 1956 } 1916 1957 1917 - LEAVE(); 1958 + lbs_deb_leave(LBS_DEB_CMD); 1918 1959 }
+176 -200
drivers/net/wireless/libertas/cmdresp.c
··· 9 9 #include <net/iw_handler.h> 10 10 11 11 #include "host.h" 12 - #include "sbi.h" 13 12 #include "decl.h" 14 13 #include "defs.h" 15 14 #include "dev.h" ··· 31 32 if (adapter->connect_status != libertas_connected) 32 33 return; 33 34 34 - lbs_pr_debug(1, "Handles disconnect event.\n"); 35 + lbs_deb_cmd("Handles disconnect event.\n"); 35 36 36 37 memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN); 37 38 wrqu.ap_addr.sa_family = ARPHRD_ETHER; ··· 42 43 */ 43 44 44 45 msleep_interruptible(1000); 45 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL); 46 + wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 46 47 47 48 /* Free Tx and Rx packets */ 48 49 kfree_skb(priv->adapter->currenttxskb); 49 50 priv->adapter->currenttxskb = NULL; 50 51 51 52 /* report disconnect to upper layer */ 52 - netif_stop_queue(priv->wlan_dev.netdev); 53 - netif_carrier_off(priv->wlan_dev.netdev); 53 + netif_stop_queue(priv->dev); 54 + netif_carrier_off(priv->dev); 54 55 55 56 /* reset SNR/NF/RSSI values */ 56 57 memset(adapter->SNR, 0x00, sizeof(adapter->SNR)); ··· 61 62 adapter->nextSNRNF = 0; 62 63 adapter->numSNRNF = 0; 63 64 adapter->rxpd_rate = 0; 64 - lbs_pr_debug(1, "Current SSID=%s, ssid length=%u\n", 65 - adapter->curbssparams.ssid.ssid, 66 - adapter->curbssparams.ssid.ssidlength); 67 - lbs_pr_debug(1, "Previous SSID=%s, ssid length=%u\n", 68 - adapter->previousssid.ssid, adapter->previousssid.ssidlength); 69 - 70 - /* reset internal flags */ 71 - adapter->secinfo.WPAenabled = 0; 72 - adapter->secinfo.WPA2enabled = 0; 73 - adapter->wpa_ie_len = 0; 65 + lbs_deb_cmd("Current SSID='%s', ssid length=%u\n", 66 + escape_essid(adapter->curbssparams.ssid, 67 + adapter->curbssparams.ssid_len), 68 + adapter->curbssparams.ssid_len); 69 + lbs_deb_cmd("Previous SSID='%s', ssid length=%u\n", 70 + escape_essid(adapter->prev_ssid, adapter->prev_ssid_len), 71 + adapter->prev_ssid_len); 74 72 75 73 adapter->connect_status = libertas_disconnected; 76 74 77 - /* 78 - * memorize the previous SSID and BSSID 79 - * it could be used for re-assoc 80 - */ 81 - memcpy(&adapter->previousssid, 82 - &adapter->curbssparams.ssid, sizeof(struct WLAN_802_11_SSID)); 83 - memcpy(adapter->previousbssid, 84 - adapter->curbssparams.bssid, ETH_ALEN); 75 + /* Save previous SSID and BSSID for possible reassociation */ 76 + memcpy(&adapter->prev_ssid, &adapter->curbssparams.ssid, 77 + IW_ESSID_MAX_SIZE); 78 + adapter->prev_ssid_len = adapter->curbssparams.ssid_len; 79 + memcpy(adapter->prev_bssid, adapter->curbssparams.bssid, ETH_ALEN); 85 80 86 - /* need to erase the current SSID and BSSID info */ 87 - adapter->pattemptedbssdesc = NULL; 88 - memset(&adapter->curbssparams, 0, sizeof(adapter->curbssparams)); 81 + /* Clear out associated SSID and BSSID since connection is 82 + * no longer valid. 83 + */ 84 + memset(&adapter->curbssparams.bssid, 0, ETH_ALEN); 85 + memset(&adapter->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE); 86 + adapter->curbssparams.ssid_len = 0; 89 87 90 88 if (adapter->psstate != PS_STATE_FULL_POWER) { 91 89 /* make firmware to exit PS mode */ 92 - lbs_pr_debug(1, "Disconnected, so exit PS mode.\n"); 90 + lbs_deb_cmd("Disconnected, so exit PS mode.\n"); 93 91 libertas_ps_wakeup(priv, 0); 94 92 } 95 93 } ··· 118 122 static int wlan_ret_reg_access(wlan_private * priv, 119 123 u16 type, struct cmd_ds_command *resp) 120 124 { 125 + int ret = 0; 121 126 wlan_adapter *adapter = priv->adapter; 122 127 123 - ENTER(); 128 + lbs_deb_enter(LBS_DEB_CMD); 124 129 125 130 switch (type) { 126 131 case cmd_ret_mac_reg_access: 127 132 { 128 - struct cmd_ds_mac_reg_access *reg; 133 + struct cmd_ds_mac_reg_access *reg = &resp->params.macreg; 129 134 130 - reg = 131 - (struct cmd_ds_mac_reg_access *)&resp->params. 132 - macreg; 133 - 134 - adapter->offsetvalue.offset = reg->offset; 135 - adapter->offsetvalue.value = reg->value; 135 + adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); 136 + adapter->offsetvalue.value = le32_to_cpu(reg->value); 136 137 break; 137 138 } 138 139 139 140 case cmd_ret_bbp_reg_access: 140 141 { 141 - struct cmd_ds_bbp_reg_access *reg; 142 - reg = 143 - (struct cmd_ds_bbp_reg_access *)&resp->params. 144 - bbpreg; 142 + struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg; 145 143 146 - adapter->offsetvalue.offset = reg->offset; 144 + adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); 147 145 adapter->offsetvalue.value = reg->value; 148 146 break; 149 147 } 150 148 151 149 case cmd_ret_rf_reg_access: 152 150 { 153 - struct cmd_ds_rf_reg_access *reg; 154 - reg = 155 - (struct cmd_ds_rf_reg_access *)&resp->params. 156 - rfreg; 151 + struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg; 157 152 158 - adapter->offsetvalue.offset = reg->offset; 153 + adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); 159 154 adapter->offsetvalue.value = reg->value; 160 155 break; 161 156 } 162 157 163 158 default: 164 - LEAVE(); 165 - return -1; 159 + ret = -1; 166 160 } 167 161 168 - LEAVE(); 169 - return 0; 162 + lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); 163 + return ret; 170 164 } 171 165 172 166 static int wlan_ret_get_hw_spec(wlan_private * priv, ··· 167 181 wlan_adapter *adapter = priv->adapter; 168 182 int ret = 0; 169 183 170 - ENTER(); 184 + lbs_deb_enter(LBS_DEB_CMD); 171 185 172 186 adapter->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo); 173 187 174 - adapter->fwreleasenumber = hwspec->fwreleasenumber; 188 + memcpy(adapter->fwreleasenumber, hwspec->fwreleasenumber, 4); 175 189 176 - lbs_pr_debug(1, "GET_HW_SPEC: FWReleaseVersion- 0x%X\n", 177 - adapter->fwreleasenumber); 178 - lbs_pr_debug(1, "GET_HW_SPEC: Permanent addr- %2x:%2x:%2x:%2x:%2x:%2x\n", 190 + lbs_deb_cmd("GET_HW_SPEC: FWReleaseVersion- %u.%u.%u.p%u\n", 191 + adapter->fwreleasenumber[2], adapter->fwreleasenumber[1], 192 + adapter->fwreleasenumber[0], adapter->fwreleasenumber[3]); 193 + lbs_deb_cmd("GET_HW_SPEC: Permanent addr- %2x:%2x:%2x:%2x:%2x:%2x\n", 179 194 hwspec->permanentaddr[0], hwspec->permanentaddr[1], 180 195 hwspec->permanentaddr[2], hwspec->permanentaddr[3], 181 196 hwspec->permanentaddr[4], hwspec->permanentaddr[5]); 182 - lbs_pr_debug(1, "GET_HW_SPEC: hwifversion=0x%X version=0x%X\n", 197 + lbs_deb_cmd("GET_HW_SPEC: hwifversion=0x%X version=0x%X\n", 183 198 hwspec->hwifversion, hwspec->version); 184 199 185 200 adapter->regioncode = le16_to_cpu(hwspec->regioncode); ··· 197 210 if (i >= MRVDRV_MAX_REGION_CODE) { 198 211 adapter->regioncode = 0x10; 199 212 adapter->regiontableindex = 0; 200 - lbs_pr_info( 201 - "unidentified region code, use the default (USA)\n"); 213 + lbs_pr_info("unidentified region code; using the default (USA)\n"); 202 214 } 203 215 204 - if (adapter->current_addr[0] == 0xff) { 205 - memmove(adapter->current_addr, hwspec->permanentaddr, 206 - ETH_ALEN); 207 - } 216 + if (adapter->current_addr[0] == 0xff) 217 + memmove(adapter->current_addr, hwspec->permanentaddr, ETH_ALEN); 208 218 209 - memcpy(priv->wlan_dev.netdev->dev_addr, adapter->current_addr, ETH_ALEN); 210 - memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); 219 + memcpy(priv->dev->dev_addr, adapter->current_addr, ETH_ALEN); 220 + if (priv->mesh_dev) 221 + memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); 211 222 212 223 if (libertas_set_regiontable(priv, adapter->regioncode, 0)) { 213 224 ret = -1; ··· 217 232 goto done; 218 233 } 219 234 220 - done: 221 - LEAVE(); 235 + done: 236 + lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); 222 237 return ret; 223 238 } 224 239 ··· 228 243 struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params; 229 244 wlan_adapter *adapter = priv->adapter; 230 245 231 - ENTER(); 246 + lbs_deb_enter(LBS_DEB_CMD); 232 247 233 - lbs_pr_debug(1, "error=%x offset=%x stabletime=%x calcontrol=%x\n" 234 - " extsleepclk=%x\n", sp->error, sp->offset, 235 - sp->stabletime, sp->calcontrol, sp->externalsleepclk); 248 + lbs_deb_cmd("error=%x offset=%x stabletime=%x calcontrol=%x\n" 249 + " extsleepclk=%x\n", le16_to_cpu(sp->error), 250 + le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime), 251 + sp->calcontrol, sp->externalsleepclk); 252 + 236 253 adapter->sp.sp_error = le16_to_cpu(sp->error); 237 254 adapter->sp.sp_offset = le16_to_cpu(sp->offset); 238 255 adapter->sp.sp_stabletime = le16_to_cpu(sp->stabletime); 239 - adapter->sp.sp_calcontrol = le16_to_cpu(sp->calcontrol); 240 - adapter->sp.sp_extsleepclk = le16_to_cpu(sp->externalsleepclk); 256 + adapter->sp.sp_calcontrol = sp->calcontrol; 257 + adapter->sp.sp_extsleepclk = sp->externalsleepclk; 241 258 adapter->sp.sp_reserved = le16_to_cpu(sp->reserved); 242 259 243 - LEAVE(); 260 + lbs_deb_enter(LBS_DEB_CMD); 244 261 return 0; 245 262 } 246 263 ··· 268 281 u16 oid = le16_to_cpu(smib->oid); 269 282 u16 querytype = le16_to_cpu(smib->querytype); 270 283 271 - ENTER(); 284 + lbs_deb_enter(LBS_DEB_CMD); 272 285 273 - lbs_pr_debug(1, "SNMP_RESP: value of the oid = %x, querytype=%x\n", oid, 286 + lbs_deb_cmd("SNMP_RESP: value of the oid = %x, querytype=%x\n", oid, 274 287 querytype); 275 - lbs_pr_debug(1, "SNMP_RESP: Buf size = %x\n", 276 - le16_to_cpu(smib->bufsize)); 288 + lbs_deb_cmd("SNMP_RESP: Buf size = %x\n", le16_to_cpu(smib->bufsize)); 277 289 278 290 if (querytype == cmd_act_get) { 279 291 switch (oid) { 280 292 case fragthresh_i: 281 293 priv->adapter->fragthsd = 282 - le16_to_cpu(* 283 - ((unsigned short *)(smib->value))); 284 - lbs_pr_debug(1, "SNMP_RESP: fragthsd =%u\n", 285 - priv->adapter->fragthsd); 294 + le16_to_cpu(*((__le16 *)(smib->value))); 295 + lbs_deb_cmd("SNMP_RESP: fragthsd =%u\n", 296 + priv->adapter->fragthsd); 286 297 break; 287 298 case rtsthresh_i: 288 299 priv->adapter->rtsthsd = 289 - le16_to_cpu(* 290 - ((unsigned short *)(smib->value))); 291 - lbs_pr_debug(1, "SNMP_RESP: rtsthsd =%u\n", 292 - priv->adapter->rtsthsd); 300 + le16_to_cpu(*((__le16 *)(smib->value))); 301 + lbs_deb_cmd("SNMP_RESP: rtsthsd =%u\n", 302 + priv->adapter->rtsthsd); 293 303 break; 294 304 case short_retrylim_i: 295 305 priv->adapter->txretrycount = 296 - le16_to_cpu(* 297 - ((unsigned short *)(smib->value))); 298 - lbs_pr_debug(1, "SNMP_RESP: txretrycount =%u\n", 299 - priv->adapter->rtsthsd); 306 + le16_to_cpu(*((__le16 *)(smib->value))); 307 + lbs_deb_cmd("SNMP_RESP: txretrycount =%u\n", 308 + priv->adapter->rtsthsd); 300 309 break; 301 310 default: 302 311 break; 303 312 } 304 313 } 305 314 306 - LEAVE(); 315 + lbs_deb_enter(LBS_DEB_CMD); 307 316 return 0; 308 317 } 309 318 ··· 311 328 wlan_adapter *adapter = priv->adapter; 312 329 u16 action = le16_to_cpu(pkeymaterial->action); 313 330 314 - ENTER(); 331 + lbs_deb_enter(LBS_DEB_CMD); 315 332 316 333 /* Copy the returned key to driver private data */ 317 334 if (action == cmd_act_get) { ··· 354 371 } 355 372 } 356 373 357 - LEAVE(); 374 + lbs_deb_enter(LBS_DEB_CMD); 358 375 return 0; 359 376 } 360 377 ··· 364 381 struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd; 365 382 wlan_adapter *adapter = priv->adapter; 366 383 367 - ENTER(); 384 + lbs_deb_enter(LBS_DEB_CMD); 368 385 369 386 memcpy(adapter->current_addr, macadd->macadd, ETH_ALEN); 370 387 371 - LEAVE(); 388 + lbs_deb_enter(LBS_DEB_CMD); 372 389 return 0; 373 390 } 374 391 ··· 378 395 struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp; 379 396 wlan_adapter *adapter = priv->adapter; 380 397 381 - ENTER(); 398 + lbs_deb_enter(LBS_DEB_CMD); 382 399 383 400 adapter->txpowerlevel = le16_to_cpu(rtp->currentlevel); 384 401 385 - lbs_pr_debug(1, "Current TxPower Level = %d\n", adapter->txpowerlevel); 402 + lbs_deb_cmd("Current TxPower Level = %d\n", adapter->txpowerlevel); 386 403 387 - LEAVE(); 404 + lbs_deb_enter(LBS_DEB_CMD); 388 405 return 0; 389 406 } 390 407 ··· 396 413 u16 action = le16_to_cpu(pAntenna->action); 397 414 398 415 if (action == cmd_act_get_rx) 399 - adapter->rxantennamode = 400 - le16_to_cpu(pAntenna->antennamode); 416 + adapter->rxantennamode = le16_to_cpu(pAntenna->antennamode); 401 417 402 418 if (action == cmd_act_get_tx) 403 - adapter->txantennamode = 404 - le16_to_cpu(pAntenna->antennamode); 419 + adapter->txantennamode = le16_to_cpu(pAntenna->antennamode); 405 420 406 - lbs_pr_debug(1, "RF_ANT_RESP: action = 0x%x, mode = 0x%04x\n", 421 + lbs_deb_cmd("RF_ANT_RESP: action = 0x%x, mode = 0x%04x\n", 407 422 action, le16_to_cpu(pAntenna->antennamode)); 408 423 409 424 return 0; ··· 410 429 static int wlan_ret_802_11_rate_adapt_rateset(wlan_private * priv, 411 430 struct cmd_ds_command *resp) 412 431 { 413 - struct cmd_ds_802_11_rate_adapt_rateset *rates = 414 - &resp->params.rateset; 432 + struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset; 415 433 wlan_adapter *adapter = priv->adapter; 416 434 417 - ENTER(); 435 + lbs_deb_enter(LBS_DEB_CMD); 418 436 419 437 if (rates->action == cmd_act_get) { 420 - adapter->enablehwauto = rates->enablehwauto; 421 - adapter->ratebitmap = rates->bitmap; 438 + adapter->enablehwauto = le16_to_cpu(rates->enablehwauto); 439 + adapter->ratebitmap = le16_to_cpu(rates->bitmap); 422 440 } 423 441 424 - LEAVE(); 425 - 442 + lbs_deb_enter(LBS_DEB_CMD); 426 443 return 0; 427 444 } 428 445 ··· 431 452 wlan_adapter *adapter = priv->adapter; 432 453 u8 dot11datarate; 433 454 434 - ENTER(); 455 + lbs_deb_enter(LBS_DEB_CMD); 435 456 436 457 lbs_dbg_hex("DATA_RATE_RESP: data_rate- ", 437 458 (u8 *) pdatarate, sizeof(struct cmd_ds_802_11_data_rate)); 438 459 439 460 dot11datarate = pdatarate->datarate[0]; 440 - if (pdatarate->action == cmd_act_get_tx_rate) { 461 + if (pdatarate->action == cpu_to_le16(cmd_act_get_tx_rate)) { 441 462 memcpy(adapter->libertas_supported_rates, pdatarate->datarate, 442 463 sizeof(adapter->libertas_supported_rates)); 443 464 } 444 465 adapter->datarate = libertas_index_to_data_rate(dot11datarate); 445 466 446 - LEAVE(); 467 + lbs_deb_enter(LBS_DEB_CMD); 447 468 return 0; 448 469 } 449 470 450 471 static int wlan_ret_802_11_rf_channel(wlan_private * priv, 451 472 struct cmd_ds_command *resp) 452 473 { 453 - struct cmd_ds_802_11_rf_channel *rfchannel = 454 - &resp->params.rfchannel; 474 + struct cmd_ds_802_11_rf_channel *rfchannel = &resp->params.rfchannel; 455 475 wlan_adapter *adapter = priv->adapter; 456 476 u16 action = le16_to_cpu(rfchannel->action); 457 477 u16 newchannel = le16_to_cpu(rfchannel->currentchannel); 458 478 459 - ENTER(); 479 + lbs_deb_enter(LBS_DEB_CMD); 460 480 461 481 if (action == cmd_opt_802_11_rf_channel_get 462 482 && adapter->curbssparams.channel != newchannel) { 463 - lbs_pr_debug(1, "channel Switch: %d to %d\n", 483 + lbs_deb_cmd("channel Switch: %d to %d\n", 464 484 adapter->curbssparams.channel, newchannel); 465 485 466 486 /* Update the channel again */ 467 487 adapter->curbssparams.channel = newchannel; 468 488 } 469 489 470 - LEAVE(); 490 + lbs_deb_enter(LBS_DEB_CMD); 471 491 return 0; 472 492 } 473 493 ··· 478 500 479 501 /* store the non average value */ 480 502 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR); 481 - adapter->NF[TYPE_BEACON][TYPE_NOAVG] = 482 - le16_to_cpu(rssirsp->noisefloor); 503 + adapter->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor); 483 504 484 505 adapter->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR); 485 - adapter->NF[TYPE_BEACON][TYPE_AVG] = 486 - le16_to_cpu(rssirsp->avgnoisefloor); 506 + adapter->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor); 487 507 488 508 adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = 489 509 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], ··· 491 515 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE, 492 516 adapter->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE); 493 517 494 - lbs_pr_debug(1, "Beacon RSSI value = 0x%x\n", 518 + lbs_deb_cmd("Beacon RSSI value = 0x%x\n", 495 519 adapter->RSSI[TYPE_BEACON][TYPE_AVG]); 496 520 497 521 return 0; ··· 504 528 struct wlan_ioctl_regrdwr *pbuf; 505 529 pbuf = (struct wlan_ioctl_regrdwr *) adapter->prdeeprom; 506 530 507 - lbs_pr_debug(1, "eeprom read len=%x\n", 531 + lbs_deb_cmd("eeprom read len=%x\n", 508 532 le16_to_cpu(resp->params.rdeeprom.bytecount)); 509 533 if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) { 510 534 pbuf->NOB = 0; 511 - lbs_pr_debug(1, "eeprom read return length is too big\n"); 535 + lbs_deb_cmd("eeprom read return length is too big\n"); 512 536 return -1; 513 537 } 514 538 pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount); ··· 525 549 static int wlan_ret_get_log(wlan_private * priv, 526 550 struct cmd_ds_command *resp) 527 551 { 528 - struct cmd_ds_802_11_get_log *logmessage = 529 - (struct cmd_ds_802_11_get_log *)&resp->params.glog; 552 + struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog; 530 553 wlan_adapter *adapter = priv->adapter; 531 554 532 - ENTER(); 555 + lbs_deb_enter(LBS_DEB_CMD); 533 556 534 - /* TODO Convert it to Big Endian before copy */ 535 - memcpy(&adapter->logmsg, logmessage, 536 - sizeof(struct cmd_ds_802_11_get_log)); 557 + /* Stored little-endian */ 558 + memcpy(&adapter->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log)); 537 559 538 - LEAVE(); 560 + lbs_deb_enter(LBS_DEB_CMD); 539 561 return 0; 540 562 } 541 563 ··· 594 620 case cmd_ret_802_11_set_afc: 595 621 case cmd_ret_802_11_get_afc: 596 622 spin_lock_irqsave(&adapter->driver_lock, flags); 597 - memmove(adapter->cur_cmd->pdata_buf, 598 - &resp->params.afc, 623 + memmove(adapter->cur_cmd->pdata_buf, &resp->params.afc, 599 624 sizeof(struct cmd_ds_802_11_afc)); 600 625 spin_unlock_irqrestore(&adapter->driver_lock, flags); 601 626 ··· 636 663 break; 637 664 638 665 case cmd_ret_802_11_key_material: 639 - lbs_pr_debug(1, "CMD_RESP: KEY_MATERIAL command response\n"); 666 + lbs_deb_cmd("CMD_RESP: KEY_MATERIAL command response\n"); 640 667 ret = wlan_ret_802_11_key_material(priv, resp); 641 668 break; 642 669 ··· 660 687 661 688 case cmd_ret_802_11_tpc_cfg: 662 689 spin_lock_irqsave(&adapter->driver_lock, flags); 663 - memmove(adapter->cur_cmd->pdata_buf, 664 - &resp->params.tpccfg, 690 + memmove(adapter->cur_cmd->pdata_buf, &resp->params.tpccfg, 665 691 sizeof(struct cmd_ds_802_11_tpc_cfg)); 666 692 spin_unlock_irqrestore(&adapter->driver_lock, flags); 667 693 break; 668 694 case cmd_ret_802_11_led_gpio_ctrl: 669 695 spin_lock_irqsave(&adapter->driver_lock, flags); 670 - memmove(adapter->cur_cmd->pdata_buf, 671 - &resp->params.ledgpio, 696 + memmove(adapter->cur_cmd->pdata_buf, &resp->params.ledgpio, 672 697 sizeof(struct cmd_ds_802_11_led_ctrl)); 673 698 spin_unlock_irqrestore(&adapter->driver_lock, flags); 674 699 break; 675 700 case cmd_ret_802_11_pwr_cfg: 676 701 spin_lock_irqsave(&adapter->driver_lock, flags); 677 - memmove(adapter->cur_cmd->pdata_buf, 678 - &resp->params.pwrcfg, 702 + memmove(adapter->cur_cmd->pdata_buf, &resp->params.pwrcfg, 679 703 sizeof(struct cmd_ds_802_11_pwr_cfg)); 680 704 spin_unlock_irqrestore(&adapter->driver_lock, flags); 681 705 ··· 694 724 case cmd_ret_fwt_access: 695 725 spin_lock_irqsave(&adapter->driver_lock, flags); 696 726 if (adapter->cur_cmd->pdata_buf) 697 - memcpy(adapter->cur_cmd->pdata_buf, 698 - &resp->params.fwt, 699 - sizeof(resp->params.fwt)); 727 + memcpy(adapter->cur_cmd->pdata_buf, &resp->params.fwt, 728 + sizeof(resp->params.fwt)); 700 729 spin_unlock_irqrestore(&adapter->driver_lock, flags); 701 730 break; 702 731 case cmd_ret_mesh_access: 703 732 if (adapter->cur_cmd->pdata_buf) 704 - memcpy(adapter->cur_cmd->pdata_buf, 705 - &resp->params.mesh, 733 + memcpy(adapter->cur_cmd->pdata_buf, &resp->params.mesh, 706 734 sizeof(resp->params.mesh)); 707 735 break; 708 736 case cmd_rte_802_11_tx_rate_query: 709 737 priv->adapter->txrate = resp->params.txrate.txrate; 710 738 break; 711 739 default: 712 - lbs_pr_debug(1, "CMD_RESP: Unknown command response %#x\n", 713 - resp->command); 740 + lbs_deb_cmd("CMD_RESP: Unknown command response %#x\n", 741 + resp->command); 714 742 break; 715 743 } 716 744 return ret; ··· 723 755 ulong flags; 724 756 u16 result; 725 757 726 - ENTER(); 758 + lbs_deb_enter(LBS_DEB_CMD); 727 759 728 - lbs_pr_debug(1, "CMD_RESP: @ %lu\n", jiffies); 760 + lbs_deb_cmd("CMD_RESP: @ %lu\n", jiffies); 729 761 730 762 /* Now we got response from FW, cancel the command timer */ 731 763 del_timer(&adapter->command_timer); ··· 734 766 spin_lock_irqsave(&adapter->driver_lock, flags); 735 767 736 768 if (!adapter->cur_cmd) { 737 - lbs_pr_debug(1, "CMD_RESP: NULL cur_cmd=%p\n", adapter->cur_cmd); 769 + lbs_deb_cmd("CMD_RESP: NULL cur_cmd=%p\n", adapter->cur_cmd); 738 770 ret = -1; 739 771 spin_unlock_irqrestore(&adapter->driver_lock, flags); 740 772 goto done; ··· 742 774 resp = (struct cmd_ds_command *)(adapter->cur_cmd->bufvirtualaddr); 743 775 744 776 lbs_dbg_hex("CMD_RESP:", adapter->cur_cmd->bufvirtualaddr, 745 - priv->wlan_dev.upld_len); 777 + priv->upld_len); 746 778 747 779 respcmd = le16_to_cpu(resp->command); 748 780 749 781 result = le16_to_cpu(resp->result); 750 782 751 - lbs_pr_debug(1, "CMD_RESP: %x result: %d length: %d\n", respcmd, 752 - result, priv->wlan_dev.upld_len); 783 + lbs_deb_cmd("CMD_RESP: %x result: %d length: %d\n", respcmd, 784 + result, priv->upld_len); 753 785 754 786 if (!(respcmd & 0x8000)) { 755 - lbs_pr_debug(1, "Invalid response to command!"); 787 + lbs_deb_cmd("Invalid response to command!"); 756 788 adapter->cur_cmd_retcode = -1; 757 789 __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 758 790 adapter->nr_cmd_pending--; ··· 763 795 } 764 796 765 797 /* Store the response code to cur_cmd_retcode. */ 766 - adapter->cur_cmd_retcode = le16_to_cpu(resp->result); 798 + adapter->cur_cmd_retcode = result;; 767 799 768 800 if (respcmd == cmd_ret_802_11_ps_mode) { 769 - struct cmd_ds_802_11_ps_mode *psmode; 801 + struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode; 802 + u16 action = le16_to_cpu(psmode->action); 770 803 771 - psmode = &resp->params.psmode; 772 - lbs_pr_debug(1, 804 + lbs_deb_cmd( 773 805 "CMD_RESP: PS_MODE cmd reply result=%#x action=0x%X\n", 774 - resp->result, psmode->action); 775 - psmode->action = cpu_to_le16(psmode->action); 806 + result, action); 776 807 777 808 if (result) { 778 - lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", 779 - resp->result); 780 - if (adapter->mode == IW_MODE_ADHOC) { 781 - /* 782 - * We should not re-try enter-ps command in 783 - * ad-hoc mode. It takes place in 784 - * libertas_execute_next_command(). 785 - */ 786 - if (psmode->action == cmd_subcmd_enter_ps) 787 - adapter->psmode = 788 - wlan802_11powermodecam; 789 - } 790 - } else if (psmode->action == cmd_subcmd_enter_ps) { 809 + lbs_deb_cmd("CMD_RESP: PS command failed- %#x \n", 810 + result); 811 + /* 812 + * We should not re-try enter-ps command in 813 + * ad-hoc mode. It takes place in 814 + * libertas_execute_next_command(). 815 + */ 816 + if (adapter->mode == IW_MODE_ADHOC && 817 + action == cmd_subcmd_enter_ps) 818 + adapter->psmode = wlan802_11powermodecam; 819 + } else if (action == cmd_subcmd_enter_ps) { 791 820 adapter->needtowakeup = 0; 792 821 adapter->psstate = PS_STATE_AWAKE; 793 822 794 - lbs_pr_debug(1, "CMD_RESP: Enter_PS command response\n"); 823 + lbs_deb_cmd("CMD_RESP: Enter_PS command response\n"); 795 824 if (adapter->connect_status != libertas_connected) { 796 825 /* 797 826 * When Deauth Event received before Enter_PS command 798 827 * response, We need to wake up the firmware. 799 828 */ 800 - lbs_pr_debug(1, 829 + lbs_deb_cmd( 801 830 "Disconnected, Going to invoke libertas_ps_wakeup\n"); 802 831 803 - mutex_unlock(&adapter->lock); 804 832 spin_unlock_irqrestore(&adapter->driver_lock, flags); 833 + mutex_unlock(&adapter->lock); 805 834 libertas_ps_wakeup(priv, 0); 806 835 mutex_lock(&adapter->lock); 807 836 spin_lock_irqsave(&adapter->driver_lock, flags); 808 837 } 809 - } else if (psmode->action == cmd_subcmd_exit_ps) { 838 + } else if (action == cmd_subcmd_exit_ps) { 810 839 adapter->needtowakeup = 0; 811 840 adapter->psstate = PS_STATE_FULL_POWER; 812 - lbs_pr_debug(1, "CMD_RESP: Exit_PS command response\n"); 841 + lbs_deb_cmd("CMD_RESP: Exit_PS command response\n"); 813 842 } else { 814 - lbs_pr_debug(1, "CMD_RESP: PS- action=0x%X\n", 815 - psmode->action); 843 + lbs_deb_cmd("CMD_RESP: PS- action=0x%X\n", action); 816 844 } 817 845 818 846 __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); ··· 829 865 830 866 /* If the command is not successful, cleanup and return failure */ 831 867 if ((result != 0 || !(respcmd & 0x8000))) { 832 - lbs_pr_debug(1, "CMD_RESP: command reply %#x result=%#x\n", 833 - resp->command, resp->result); 868 + lbs_deb_cmd("CMD_RESP: command reply %#x result=%#x\n", 869 + respcmd, result); 834 870 /* 835 871 * Handling errors here 836 872 */ 837 873 switch (respcmd) { 838 874 case cmd_ret_hw_spec_info: 839 875 case cmd_ret_802_11_reset: 840 - lbs_pr_debug(1, "CMD_RESP: Reset command failed\n"); 876 + lbs_deb_cmd("CMD_RESP: Reset command failed\n"); 841 877 break; 842 878 843 879 } ··· 867 903 868 904 done: 869 905 mutex_unlock(&adapter->lock); 870 - LEAVE(); 906 + lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); 871 907 return ret; 872 908 } 873 909 ··· 881 917 eventcause = adapter->eventcause; 882 918 spin_unlock_irq(&adapter->driver_lock); 883 919 884 - ENTER(); 920 + lbs_deb_enter(LBS_DEB_CMD); 885 921 886 - lbs_pr_debug(1, "EVENT Cause %x\n", eventcause); 922 + lbs_deb_cmd("EVENT Cause %x\n", eventcause); 887 923 888 924 switch (eventcause >> SBI_EVENT_CAUSE_SHIFT) { 889 925 case MACREG_INT_CODE_LINK_SENSED: 890 - lbs_pr_debug(1, "EVENT: MACREG_INT_CODE_LINK_SENSED\n"); 926 + lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n"); 891 927 break; 892 928 893 929 case MACREG_INT_CODE_DEAUTHENTICATED: 894 - lbs_pr_debug(1, "EVENT: Deauthenticated\n"); 930 + lbs_deb_cmd("EVENT: Deauthenticated\n"); 895 931 libertas_mac_event_disconnected(priv); 896 932 break; 897 933 898 934 case MACREG_INT_CODE_DISASSOCIATED: 899 - lbs_pr_debug(1, "EVENT: Disassociated\n"); 935 + lbs_deb_cmd("EVENT: Disassociated\n"); 900 936 libertas_mac_event_disconnected(priv); 901 937 break; 902 938 903 939 case MACREG_INT_CODE_LINK_LOSE_NO_SCAN: 904 - lbs_pr_debug(1, "EVENT: Link lost\n"); 940 + lbs_deb_cmd("EVENT: Link lost\n"); 905 941 libertas_mac_event_disconnected(priv); 906 942 break; 907 943 908 944 case MACREG_INT_CODE_PS_SLEEP: 909 - lbs_pr_debug(1, "EVENT: SLEEP\n"); 910 - lbs_pr_debug(1, "_"); 945 + lbs_deb_cmd("EVENT: SLEEP\n"); 946 + lbs_deb_cmd("_"); 911 947 912 948 /* handle unexpected PS SLEEP event */ 913 949 if (adapter->psstate == PS_STATE_FULL_POWER) { 914 - lbs_pr_debug(1, 950 + lbs_deb_cmd( 915 951 "EVENT: In FULL POWER mode - ignore PS SLEEP\n"); 916 952 break; 917 953 } ··· 922 958 break; 923 959 924 960 case MACREG_INT_CODE_PS_AWAKE: 925 - lbs_pr_debug(1, "EVENT: AWAKE \n"); 926 - lbs_pr_debug(1, "|"); 961 + lbs_deb_cmd("EVENT: AWAKE \n"); 962 + lbs_deb_cmd("|"); 927 963 928 964 /* handle unexpected PS AWAKE event */ 929 965 if (adapter->psstate == PS_STATE_FULL_POWER) { 930 - lbs_pr_debug(1, 966 + lbs_deb_cmd( 931 967 "EVENT: In FULL POWER mode - ignore PS AWAKE\n"); 932 968 break; 933 969 } ··· 941 977 * adapter->needtowakeup will be set to FALSE 942 978 * in libertas_ps_wakeup() 943 979 */ 944 - lbs_pr_debug(1, "Waking up...\n"); 980 + lbs_deb_cmd("Waking up...\n"); 945 981 libertas_ps_wakeup(priv, 0); 946 982 } 947 983 break; 948 984 949 985 case MACREG_INT_CODE_MIC_ERR_UNICAST: 950 - lbs_pr_debug(1, "EVENT: UNICAST MIC ERROR\n"); 986 + lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n"); 951 987 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST); 952 988 break; 953 989 954 990 case MACREG_INT_CODE_MIC_ERR_MULTICAST: 955 - lbs_pr_debug(1, "EVENT: MULTICAST MIC ERROR\n"); 991 + lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n"); 956 992 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST); 957 993 break; 958 994 case MACREG_INT_CODE_MIB_CHANGED: ··· 960 996 break; 961 997 962 998 case MACREG_INT_CODE_ADHOC_BCN_LOST: 963 - lbs_pr_debug(1, "EVENT: HWAC - ADHOC BCN LOST\n"); 999 + lbs_deb_cmd("EVENT: HWAC - ADHOC BCN LOST\n"); 964 1000 break; 965 1001 966 1002 case MACREG_INT_CODE_RSSI_LOW: ··· 979 1015 lbs_pr_alert( "EVENT: SNR_HIGH\n"); 980 1016 break; 981 1017 1018 + case MACREG_INT_CODE_MESH_AUTO_STARTED: 1019 + lbs_pr_alert( "EVENT: MESH_AUTO_STARTED\n"); 1020 + adapter->connect_status = libertas_connected ; 1021 + if (priv->mesh_open == 1) { 1022 + netif_wake_queue(priv->mesh_dev) ; 1023 + netif_carrier_on(priv->mesh_dev) ; 1024 + } 1025 + adapter->mode = IW_MODE_ADHOC ; 1026 + schedule_work(&priv->sync_channel); 1027 + break; 1028 + 982 1029 default: 983 1030 lbs_pr_alert( "EVENT: unknown event id: %#x\n", 984 1031 eventcause >> SBI_EVENT_CAUSE_SHIFT); ··· 999 1024 spin_lock_irq(&adapter->driver_lock); 1000 1025 adapter->eventcause = 0; 1001 1026 spin_unlock_irq(&adapter->driver_lock); 1002 - LEAVE(); 1027 + 1028 + lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); 1003 1029 return ret; 1004 1030 }
+207 -225
drivers/net/wireless/libertas/debugfs.c
··· 4 4 #include <linux/delay.h> 5 5 #include <linux/mm.h> 6 6 #include <net/iw_handler.h> 7 + 7 8 #include "dev.h" 8 9 #include "decl.h" 9 10 #include "host.h" ··· 16 15 "Disconnected" 17 16 }; 18 17 19 - void libertas_debug_init(wlan_private * priv, struct net_device *dev); 18 + #ifdef PROC_DEBUG 19 + static void libertas_debug_init(wlan_private * priv, struct net_device *dev); 20 + #endif 20 21 21 22 static int open_file_generic(struct inode *inode, struct file *file) 22 23 { ··· 63 60 int numscansdone = 0, res; 64 61 unsigned long addr = get_zeroed_page(GFP_KERNEL); 65 62 char *buf = (char *)addr; 63 + struct bss_descriptor * iter_bss; 66 64 67 - pos += snprintf(buf+pos, len-pos, 68 - "---------------------------------------"); 69 - pos += snprintf(buf+pos, len-pos, 70 - "---------------------------------------\n"); 71 65 pos += snprintf(buf+pos, len-pos, 72 66 "# | ch | ss | bssid | cap | TSF | Qual | SSID \n"); 73 - pos += snprintf(buf+pos, len-pos, 74 - "---------------------------------------"); 75 - pos += snprintf(buf+pos, len-pos, 76 - "---------------------------------------\n"); 77 67 78 - while (numscansdone < priv->adapter->numinscantable) { 79 - struct bss_descriptor *pbssinfo; 68 + mutex_lock(&priv->adapter->lock); 69 + list_for_each_entry (iter_bss, &priv->adapter->network_list, list) { 80 70 u16 cap; 81 71 82 - pbssinfo = &priv->adapter->scantable[numscansdone]; 83 - memcpy(&cap, &pbssinfo->cap, sizeof(cap)); 72 + memcpy(&cap, &iter_bss->cap, sizeof(cap)); 84 73 pos += snprintf(buf+pos, len-pos, 85 - "%02u| %03d | %03ld | %02x:%02x:%02x:%02x:%02x:%02x |", 86 - numscansdone, pbssinfo->channel, pbssinfo->rssi, 87 - pbssinfo->macaddress[0], pbssinfo->macaddress[1], 88 - pbssinfo->macaddress[2], pbssinfo->macaddress[3], 89 - pbssinfo->macaddress[4], pbssinfo->macaddress[5]); 74 + "%02u| %03d | %03ld | " MAC_FMT " |", 75 + numscansdone, iter_bss->channel, iter_bss->rssi, 76 + MAC_ARG(iter_bss->bssid)); 90 77 pos += snprintf(buf+pos, len-pos, " %04x-", cap); 91 78 pos += snprintf(buf+pos, len-pos, "%c%c%c |", 92 - pbssinfo->cap.ibss ? 'A' : 'I', 93 - pbssinfo->cap.privacy ? 'P' : ' ', 94 - pbssinfo->cap.spectrummgmt ? 'S' : ' '); 95 - pos += snprintf(buf+pos, len-pos, " %08llx |", pbssinfo->networktsf); 96 - pos += snprintf(buf+pos, len-pos, " %d |", 97 - SCAN_RSSI(priv->adapter->scantable[numscansdone].rssi)); 98 - 99 - pos += snprintf(buf+pos, len-pos, " %s\n", pbssinfo->ssid.ssid); 79 + iter_bss->cap.ibss ? 'A' : 'I', 80 + iter_bss->cap.privacy ? 'P' : ' ', 81 + iter_bss->cap.spectrummgmt ? 'S' : ' '); 82 + pos += snprintf(buf+pos, len-pos, " %08llx |", iter_bss->networktsf); 83 + pos += snprintf(buf+pos, len-pos, " %d |", SCAN_RSSI(iter_bss->rssi)); 84 + pos += snprintf(buf+pos, len-pos, " %s\n", 85 + escape_essid(iter_bss->ssid, iter_bss->ssid_len)); 100 86 101 87 numscansdone++; 102 88 } 89 + mutex_unlock(&priv->adapter->lock); 103 90 104 91 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 105 92 ··· 104 111 wlan_private *priv = file->private_data; 105 112 ssize_t buf_size, res; 106 113 int p1, p2, p3, p4, p5, p6; 107 - struct sleep_params sp; 108 114 unsigned long addr = get_zeroed_page(GFP_KERNEL); 109 115 char *buf = (char *)addr; 110 116 ··· 117 125 res = -EFAULT; 118 126 goto out_unlock; 119 127 } 120 - sp.sp_error = p1; 121 - sp.sp_offset = p2; 122 - sp.sp_stabletime = p3; 123 - sp.sp_calcontrol = p4; 124 - sp.sp_extsleepclk = p5; 125 - sp.sp_reserved = p6; 126 - 127 - memcpy(&priv->adapter->sp, &sp, sizeof(struct sleep_params)); 128 + priv->adapter->sp.sp_error = p1; 129 + priv->adapter->sp.sp_offset = p2; 130 + priv->adapter->sp.sp_stabletime = p3; 131 + priv->adapter->sp.sp_calcontrol = p4; 132 + priv->adapter->sp.sp_extsleepclk = p5; 133 + priv->adapter->sp.sp_reserved = p6; 128 134 129 135 res = libertas_prepare_and_send_command(priv, 130 136 cmd_802_11_sleep_params, ··· 175 185 { 176 186 wlan_private *priv = file->private_data; 177 187 ssize_t res, buf_size; 178 - struct WLAN_802_11_SSID extscan_ssid; 179 188 union iwreq_data wrqu; 180 189 unsigned long addr = get_zeroed_page(GFP_KERNEL); 181 190 char *buf = (char *)addr; ··· 185 196 goto out_unlock; 186 197 } 187 198 188 - memcpy(&extscan_ssid.ssid, buf, strlen(buf)-1); 189 - extscan_ssid.ssidlength = strlen(buf)-1; 190 - 191 - libertas_send_specific_SSID_scan(priv, &extscan_ssid, 1); 199 + libertas_send_specific_ssid_scan(priv, buf, strlen(buf)-1, 0); 192 200 193 201 memset(&wrqu, 0, sizeof(union iwreq_data)); 194 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWSCAN, &wrqu, NULL); 202 + wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); 195 203 196 204 out_unlock: 197 205 free_page(addr); ··· 237 251 { 238 252 char *hold; 239 253 unsigned int mac[ETH_ALEN]; 240 - int i; 241 254 242 255 hold = strstr(buf, "bssid="); 243 256 if (!hold) 244 257 return; 245 258 hold += 6; 246 - sscanf(hold, "%2x:%2x:%2x:%2x:%2x:%2x", mac, mac+1, mac+2, mac+3, 247 - mac+4, mac+5); 248 - for(i=0;i<ETH_ALEN;i++) 249 - scan_cfg->specificBSSID[i] = mac[i]; 259 + sscanf(hold, MAC_FMT, mac, mac+1, mac+2, mac+3, mac+4, mac+5); 260 + memcpy(scan_cfg->bssid, mac, ETH_ALEN); 250 261 } 251 262 252 263 static void libertas_parse_ssid(char *buf, size_t count, ··· 261 278 end = buf + count - 1; 262 279 263 280 size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold)); 264 - strncpy(scan_cfg->specificSSID, hold, size); 281 + strncpy(scan_cfg->ssid, hold, size); 265 282 266 283 return; 267 284 } 268 285 269 - static void libertas_parse_keep(char *buf, size_t count, 270 - struct wlan_ioctl_user_scan_cfg *scan_cfg) 286 + static int libertas_parse_clear(char *buf, size_t count, const char *tag) 271 287 { 272 288 char *hold; 273 289 int val; 274 290 275 - hold = strstr(buf, "keep="); 291 + hold = strstr(buf, tag); 276 292 if (!hold) 277 - return; 278 - hold += 5; 293 + return 0; 294 + hold += strlen(tag); 279 295 sscanf(hold, "%d", &val); 280 296 281 297 if (val != 0) 282 298 val = 1; 283 299 284 - scan_cfg->keeppreviousscan = val; 285 - return; 300 + return val; 286 301 } 287 302 288 303 static int libertas_parse_dur(char *buf, size_t count, ··· 363 382 dur = libertas_parse_dur(buf, count, scan_cfg); 364 383 libertas_parse_chan(buf, count, scan_cfg, dur); 365 384 libertas_parse_bssid(buf, count, scan_cfg); 385 + scan_cfg->clear_bssid = libertas_parse_clear(buf, count, "clear_bssid="); 366 386 libertas_parse_ssid(buf, count, scan_cfg); 367 - libertas_parse_keep(buf, count, scan_cfg); 387 + scan_cfg->clear_ssid = libertas_parse_clear(buf, count, "clear_ssid="); 368 388 libertas_parse_probes(buf, count, scan_cfg); 369 389 libertas_parse_type(buf, count, scan_cfg); 370 390 371 - wlan_scan_networks(priv, scan_cfg); 391 + wlan_scan_networks(priv, scan_cfg, 1); 372 392 wait_event_interruptible(priv->adapter->cmd_pending, 373 393 !priv->adapter->nr_cmd_pending); 374 394 375 395 memset(&wrqu, 0x00, sizeof(union iwreq_data)); 376 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWSCAN, &wrqu, NULL); 396 + wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); 377 397 378 398 out_unlock: 379 399 free_page(addr); ··· 389 407 u16 wait_option = cmd_option_waitforrsp; 390 408 391 409 if (!(*cmdnode = libertas_get_free_cmd_ctrl_node(priv))) { 392 - lbs_pr_debug(1, "failed libertas_get_free_cmd_ctrl_node\n"); 410 + lbs_deb_debugfs("failed libertas_get_free_cmd_ctrl_node\n"); 393 411 return -ENOMEM; 394 412 } 395 413 if (!(*response_buf = kmalloc(3000, GFP_KERNEL))) { 396 - lbs_pr_debug(1, "failed to allocate response buffer!\n"); 414 + lbs_deb_debugfs("failed to allocate response buffer!\n"); 397 415 return -ENOMEM; 398 416 } 399 417 libertas_set_cmd_ctrl_node(priv, *cmdnode, 0, wait_option, NULL); ··· 402 420 (*cmdnode)->cmdflags |= CMD_F_HOSTCMD; 403 421 (*cmdnode)->cmdwaitqwoken = 0; 404 422 *cmd = (struct cmd_ds_command *)(*cmdnode)->bufvirtualaddr; 405 - (*cmd)->command = cmd_802_11_subscribe_event; 406 - (*cmd)->seqnum = ++priv->adapter->seqnum; 423 + (*cmd)->command = cpu_to_le16(cmd_802_11_subscribe_event); 424 + (*cmd)->seqnum = cpu_to_le16(++priv->adapter->seqnum); 407 425 (*cmd)->result = 0; 408 426 return 0; 409 427 } ··· 429 447 } 430 448 431 449 event = &pcmdptr->params.subscribe_event; 432 - event->action = cmd_act_get; 433 - pcmdptr->size = 434 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 450 + event->action = cpu_to_le16(cmd_act_get); 451 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 435 452 libertas_queue_cmd(adapter, pcmdnode, 1); 436 453 wake_up_interruptible(&priv->mainthread.waitq); 437 454 438 455 /* Sleep until response is generated by FW */ 439 456 wait_event_interruptible(pcmdnode->cmdwait_q, 440 - pcmdnode->cmdwaitqwoken); 457 + pcmdnode->cmdwaitqwoken); 441 458 442 459 pcmdptr = response_buf; 443 460 if (pcmdptr->result) { 444 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 445 - pcmdptr->result); 461 + lbs_pr_err("%s: fail, result=%d\n", __func__, 462 + le16_to_cpu(pcmdptr->result)); 446 463 kfree(response_buf); 447 464 free_page(addr); 448 465 return 0; 449 466 } 450 467 451 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 468 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 452 469 lbs_pr_err("command response incorrect!\n"); 453 470 kfree(response_buf); 454 471 free_page(addr); ··· 455 474 } 456 475 457 476 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 458 - event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 459 - while (cmd_len < pcmdptr->size) { 460 - struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 461 - switch(header->type) { 477 + event = (void *)(response_buf + S_DS_GEN); 478 + while (cmd_len < le16_to_cpu(pcmdptr->size)) { 479 + struct mrvlietypesheader *header = (void *)(response_buf + cmd_len); 480 + switch (header->type) { 462 481 struct mrvlietypes_rssithreshold *Lowrssi; 463 - case TLV_TYPE_RSSI_LOW: 464 - Lowrssi = (struct mrvlietypes_rssithreshold *)(response_buf + cmd_len); 465 - pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 466 - Lowrssi->rssivalue, 467 - Lowrssi->rssifreq, 468 - (event->events & 0x0001)?1:0); 482 + case __constant_cpu_to_le16(TLV_TYPE_RSSI_LOW): 483 + Lowrssi = (void *)(response_buf + cmd_len); 484 + pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 485 + Lowrssi->rssivalue, 486 + Lowrssi->rssifreq, 487 + (event->events & cpu_to_le16(0x0001))?1:0); 469 488 default: 470 489 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 471 490 break; ··· 493 512 return res; 494 513 495 514 event = &pcmdptr->params.subscribe_event; 496 - event->action = cmd_act_get; 497 - pcmdptr->size = 498 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 515 + event->action = cpu_to_le16(cmd_act_get); 516 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 499 517 libertas_queue_cmd(adapter, pcmdnode, 1); 500 518 wake_up_interruptible(&priv->mainthread.waitq); 501 519 502 520 /* Sleep until response is generated by FW */ 503 521 wait_event_interruptible(pcmdnode->cmdwait_q, 504 - pcmdnode->cmdwaitqwoken); 522 + pcmdnode->cmdwaitqwoken); 505 523 506 524 pcmdptr = response_buf; 507 525 508 526 if (pcmdptr->result) { 509 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 510 - pcmdptr->result); 527 + lbs_pr_err("%s: fail, result=%d\n", __func__, 528 + le16_to_cpu(pcmdptr->result)); 511 529 kfree(response_buf); 512 530 return 0; 513 531 } ··· 518 538 } 519 539 520 540 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 521 - event_bitmap = event->events; 541 + event_bitmap = le16_to_cpu(event->events); 522 542 kfree(response_buf); 523 543 return event_bitmap; 524 544 } ··· 559 579 goto out_unlock; 560 580 561 581 event = &pcmdptr->params.subscribe_event; 562 - event->action = cmd_act_set; 582 + event->action = cpu_to_le16(cmd_act_set); 563 583 pcmdptr->size = cpu_to_le16(S_DS_GEN + 564 584 sizeof(struct cmd_ds_802_11_subscribe_event) + 565 585 sizeof(struct mrvlietypes_rssithreshold)); ··· 568 588 ptr = (u8*) pcmdptr+cmd_len; 569 589 rssi_threshold = (struct mrvlietypes_rssithreshold *)(ptr); 570 590 rssi_threshold->header.type = cpu_to_le16(0x0104); 571 - rssi_threshold->header.len = 2; 572 - rssi_threshold->rssivalue = cpu_to_le16(value); 573 - rssi_threshold->rssifreq = cpu_to_le16(freq); 591 + rssi_threshold->header.len = cpu_to_le16(2); 592 + rssi_threshold->rssivalue = value; 593 + rssi_threshold->rssifreq = freq; 574 594 event_bitmap |= subscribed ? 0x0001 : 0x0; 575 - event->events = event_bitmap; 595 + event->events = cpu_to_le16(event_bitmap); 576 596 577 597 libertas_queue_cmd(adapter, pcmdnode, 1); 578 598 wake_up_interruptible(&priv->mainthread.waitq); 579 599 580 600 /* Sleep until response is generated by FW */ 581 601 wait_event_interruptible(pcmdnode->cmdwait_q, 582 - pcmdnode->cmdwaitqwoken); 602 + pcmdnode->cmdwaitqwoken); 583 603 584 604 pcmdptr = response_buf; 585 605 586 606 if (pcmdptr->result) { 587 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 588 - pcmdptr->result); 607 + lbs_pr_err("%s: fail, result=%d\n", __func__, 608 + le16_to_cpu(pcmdptr->result)); 589 609 kfree(response_buf); 590 610 free_page(addr); 591 611 return 0; 592 612 } 593 613 594 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 614 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 595 615 lbs_pr_err("command response incorrect!\n"); 596 616 kfree(response_buf); 597 617 free_page(addr); ··· 625 645 } 626 646 627 647 event = &pcmdptr->params.subscribe_event; 628 - event->action = cmd_act_get; 629 - pcmdptr->size = 630 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 648 + event->action = cpu_to_le16(cmd_act_get); 649 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 631 650 libertas_queue_cmd(adapter, pcmdnode, 1); 632 651 wake_up_interruptible(&priv->mainthread.waitq); 633 652 634 653 /* Sleep until response is generated by FW */ 635 654 wait_event_interruptible(pcmdnode->cmdwait_q, 636 - pcmdnode->cmdwaitqwoken); 655 + pcmdnode->cmdwaitqwoken); 637 656 638 657 pcmdptr = response_buf; 639 658 640 659 if (pcmdptr->result) { 641 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 642 - pcmdptr->result); 660 + lbs_pr_err("%s: fail, result=%d\n", __func__, 661 + le16_to_cpu(pcmdptr->result)); 643 662 kfree(response_buf); 644 663 free_page(addr); 645 664 return 0; 646 665 } 647 666 648 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 667 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 649 668 lbs_pr_err("command response incorrect!\n"); 650 669 kfree(response_buf); 651 670 free_page(addr); ··· 652 673 } 653 674 654 675 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 655 - event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 656 - while (cmd_len < pcmdptr->size) { 657 - struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 658 - switch(header->type) { 676 + event = (void *)(response_buf + S_DS_GEN); 677 + while (cmd_len < le16_to_cpu(pcmdptr->size)) { 678 + struct mrvlietypesheader *header = (void *)(response_buf + cmd_len); 679 + switch (header->type) { 659 680 struct mrvlietypes_snrthreshold *LowSnr; 660 - case TLV_TYPE_SNR_LOW: 661 - LowSnr = (struct mrvlietypes_snrthreshold *)(response_buf + cmd_len); 662 - pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 663 - LowSnr->snrvalue, 664 - LowSnr->snrfreq, 665 - (event->events & 0x0002)?1:0); 681 + case __constant_cpu_to_le16(TLV_TYPE_SNR_LOW): 682 + LowSnr = (void *)(response_buf + cmd_len); 683 + pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 684 + LowSnr->snrvalue, 685 + LowSnr->snrfreq, 686 + (event->events & cpu_to_le16(0x0002))?1:0); 666 687 default: 667 688 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 668 689 break; ··· 712 733 goto out_unlock; 713 734 714 735 event = &pcmdptr->params.subscribe_event; 715 - event->action = cmd_act_set; 736 + event->action = cpu_to_le16(cmd_act_set); 716 737 pcmdptr->size = cpu_to_le16(S_DS_GEN + 717 738 sizeof(struct cmd_ds_802_11_subscribe_event) + 718 739 sizeof(struct mrvlietypes_snrthreshold)); ··· 720 741 ptr = (u8*) pcmdptr+cmd_len; 721 742 snr_threshold = (struct mrvlietypes_snrthreshold *)(ptr); 722 743 snr_threshold->header.type = cpu_to_le16(TLV_TYPE_SNR_LOW); 723 - snr_threshold->header.len = 2; 724 - snr_threshold->snrvalue = cpu_to_le16(value); 725 - snr_threshold->snrfreq = cpu_to_le16(freq); 744 + snr_threshold->header.len = cpu_to_le16(2); 745 + snr_threshold->snrvalue = value; 746 + snr_threshold->snrfreq = freq; 726 747 event_bitmap |= subscribed ? 0x0002 : 0x0; 727 - event->events = event_bitmap; 748 + event->events = cpu_to_le16(event_bitmap); 728 749 729 750 libertas_queue_cmd(adapter, pcmdnode, 1); 730 751 wake_up_interruptible(&priv->mainthread.waitq); 731 752 732 753 /* Sleep until response is generated by FW */ 733 754 wait_event_interruptible(pcmdnode->cmdwait_q, 734 - pcmdnode->cmdwaitqwoken); 755 + pcmdnode->cmdwaitqwoken); 735 756 736 757 pcmdptr = response_buf; 737 758 738 759 if (pcmdptr->result) { 739 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 740 - pcmdptr->result); 760 + lbs_pr_err("%s: fail, result=%d\n", __func__, 761 + le16_to_cpu(pcmdptr->result)); 741 762 kfree(response_buf); 742 763 free_page(addr); 743 764 return 0; 744 765 } 745 766 746 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 767 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 747 768 lbs_pr_err("command response incorrect!\n"); 748 769 kfree(response_buf); 749 770 free_page(addr); ··· 778 799 } 779 800 780 801 event = &pcmdptr->params.subscribe_event; 781 - event->action = cmd_act_get; 782 - pcmdptr->size = 783 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 802 + event->action = cpu_to_le16(cmd_act_get); 803 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 784 804 libertas_queue_cmd(adapter, pcmdnode, 1); 785 805 wake_up_interruptible(&priv->mainthread.waitq); 786 806 787 807 /* Sleep until response is generated by FW */ 788 808 wait_event_interruptible(pcmdnode->cmdwait_q, 789 - pcmdnode->cmdwaitqwoken); 809 + pcmdnode->cmdwaitqwoken); 790 810 791 811 pcmdptr = response_buf; 792 812 793 813 if (pcmdptr->result) { 794 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 795 - pcmdptr->result); 814 + lbs_pr_err("%s: fail, result=%d\n", __func__, 815 + le16_to_cpu(pcmdptr->result)); 796 816 kfree(response_buf); 797 817 free_page(addr); 798 818 return 0; 799 819 } 800 820 801 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 821 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 802 822 lbs_pr_err("command response incorrect!\n"); 803 823 kfree(response_buf); 804 824 free_page(addr); ··· 805 827 } 806 828 807 829 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 808 - event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 809 - while (cmd_len < pcmdptr->size) { 810 - struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 811 - switch(header->type) { 830 + event = (void *)(response_buf + S_DS_GEN); 831 + while (cmd_len < le16_to_cpu(pcmdptr->size)) { 832 + struct mrvlietypesheader *header = (void *)(response_buf + cmd_len); 833 + switch (header->type) { 812 834 struct mrvlietypes_failurecount *failcount; 813 - case TLV_TYPE_FAILCOUNT: 814 - failcount = (struct mrvlietypes_failurecount *)(response_buf + cmd_len); 815 - pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 816 - failcount->failvalue, 817 - failcount->Failfreq, 818 - (event->events & 0x0004)?1:0); 835 + case __constant_cpu_to_le16(TLV_TYPE_FAILCOUNT): 836 + failcount = (void *)(response_buf + cmd_len); 837 + pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 838 + failcount->failvalue, 839 + failcount->Failfreq, 840 + (event->events & cpu_to_le16(0x0004))?1:0); 819 841 default: 820 842 cmd_len += sizeof(struct mrvlietypes_failurecount); 821 843 break; ··· 864 886 goto out_unlock; 865 887 866 888 event = &pcmdptr->params.subscribe_event; 867 - event->action = cmd_act_set; 889 + event->action = cpu_to_le16(cmd_act_set); 868 890 pcmdptr->size = cpu_to_le16(S_DS_GEN + 869 891 sizeof(struct cmd_ds_802_11_subscribe_event) + 870 892 sizeof(struct mrvlietypes_failurecount)); ··· 872 894 ptr = (u8*) pcmdptr+cmd_len; 873 895 failcount = (struct mrvlietypes_failurecount *)(ptr); 874 896 failcount->header.type = cpu_to_le16(TLV_TYPE_FAILCOUNT); 875 - failcount->header.len = 2; 876 - failcount->failvalue = cpu_to_le16(value); 877 - failcount->Failfreq = cpu_to_le16(freq); 897 + failcount->header.len = cpu_to_le16(2); 898 + failcount->failvalue = value; 899 + failcount->Failfreq = freq; 878 900 event_bitmap |= subscribed ? 0x0004 : 0x0; 879 - event->events = event_bitmap; 901 + event->events = cpu_to_le16(event_bitmap); 880 902 881 903 libertas_queue_cmd(adapter, pcmdnode, 1); 882 904 wake_up_interruptible(&priv->mainthread.waitq); 883 905 884 906 /* Sleep until response is generated by FW */ 885 907 wait_event_interruptible(pcmdnode->cmdwait_q, 886 - pcmdnode->cmdwaitqwoken); 908 + pcmdnode->cmdwaitqwoken); 887 909 888 910 pcmdptr = (struct cmd_ds_command *)response_buf; 889 911 890 912 if (pcmdptr->result) { 891 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 892 - pcmdptr->result); 913 + lbs_pr_err("%s: fail, result=%d\n", __func__, 914 + le16_to_cpu(pcmdptr->result)); 893 915 kfree(response_buf); 894 916 free_page(addr); 895 917 return 0; 896 918 } 897 919 898 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 920 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 899 921 lbs_pr_err("command response incorrect!\n"); 900 922 kfree(response_buf); 901 923 free_page(addr); ··· 929 951 } 930 952 931 953 event = &pcmdptr->params.subscribe_event; 932 - event->action = cmd_act_get; 933 - pcmdptr->size = 934 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 954 + event->action = cpu_to_le16(cmd_act_get); 955 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 935 956 libertas_queue_cmd(adapter, pcmdnode, 1); 936 957 wake_up_interruptible(&priv->mainthread.waitq); 937 958 938 959 /* Sleep until response is generated by FW */ 939 960 wait_event_interruptible(pcmdnode->cmdwait_q, 940 - pcmdnode->cmdwaitqwoken); 961 + pcmdnode->cmdwaitqwoken); 941 962 942 963 pcmdptr = response_buf; 943 964 944 965 if (pcmdptr->result) { 945 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 946 - pcmdptr->result); 966 + lbs_pr_err("%s: fail, result=%d\n", __func__, 967 + le16_to_cpu(pcmdptr->result)); 947 968 free_page(addr); 948 969 kfree(response_buf); 949 970 return 0; 950 971 } 951 972 952 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 973 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 953 974 lbs_pr_err("command response incorrect!\n"); 954 975 free_page(addr); 955 976 kfree(response_buf); ··· 956 979 } 957 980 958 981 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 959 - event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 960 - while (cmd_len < pcmdptr->size) { 961 - struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 962 - switch(header->type) { 982 + event = (void *)(response_buf + S_DS_GEN); 983 + while (cmd_len < le16_to_cpu(pcmdptr->size)) { 984 + struct mrvlietypesheader *header = (void *)(response_buf + cmd_len); 985 + switch (header->type) { 963 986 struct mrvlietypes_beaconsmissed *bcnmiss; 964 - case TLV_TYPE_BCNMISS: 965 - bcnmiss = (struct mrvlietypes_beaconsmissed *)(response_buf + cmd_len); 966 - pos += snprintf(buf+pos, len-pos, "%d N/A %d\n", 967 - bcnmiss->beaconmissed, 968 - (event->events & 0x0008)?1:0); 987 + case __constant_cpu_to_le16(TLV_TYPE_BCNMISS): 988 + bcnmiss = (void *)(response_buf + cmd_len); 989 + pos += snprintf(buf+pos, len-pos, "%d N/A %d\n", 990 + bcnmiss->beaconmissed, 991 + (event->events & cpu_to_le16(0x0008))?1:0); 969 992 default: 970 993 cmd_len += sizeof(struct mrvlietypes_beaconsmissed); 971 994 break; ··· 1015 1038 goto out_unlock; 1016 1039 1017 1040 event = &pcmdptr->params.subscribe_event; 1018 - event->action = cmd_act_set; 1041 + event->action = cpu_to_le16(cmd_act_set); 1019 1042 pcmdptr->size = cpu_to_le16(S_DS_GEN + 1020 1043 sizeof(struct cmd_ds_802_11_subscribe_event) + 1021 1044 sizeof(struct mrvlietypes_beaconsmissed)); ··· 1023 1046 ptr = (u8*) pcmdptr+cmd_len; 1024 1047 bcnmiss = (struct mrvlietypes_beaconsmissed *)(ptr); 1025 1048 bcnmiss->header.type = cpu_to_le16(TLV_TYPE_BCNMISS); 1026 - bcnmiss->header.len = 2; 1027 - bcnmiss->beaconmissed = cpu_to_le16(value); 1049 + bcnmiss->header.len = cpu_to_le16(2); 1050 + bcnmiss->beaconmissed = value; 1028 1051 event_bitmap |= subscribed ? 0x0008 : 0x0; 1029 - event->events = event_bitmap; 1052 + event->events = cpu_to_le16(event_bitmap); 1030 1053 1031 1054 libertas_queue_cmd(adapter, pcmdnode, 1); 1032 1055 wake_up_interruptible(&priv->mainthread.waitq); 1033 1056 1034 1057 /* Sleep until response is generated by FW */ 1035 1058 wait_event_interruptible(pcmdnode->cmdwait_q, 1036 - pcmdnode->cmdwaitqwoken); 1059 + pcmdnode->cmdwaitqwoken); 1037 1060 1038 1061 pcmdptr = response_buf; 1039 1062 1040 1063 if (pcmdptr->result) { 1041 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1042 - pcmdptr->result); 1064 + lbs_pr_err("%s: fail, result=%d\n", __func__, 1065 + le16_to_cpu(pcmdptr->result)); 1043 1066 kfree(response_buf); 1044 1067 free_page(addr); 1045 1068 return 0; 1046 1069 } 1047 1070 1048 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1071 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 1049 1072 lbs_pr_err("command response incorrect!\n"); 1050 1073 free_page(addr); 1051 1074 kfree(response_buf); ··· 1079 1102 } 1080 1103 1081 1104 event = &pcmdptr->params.subscribe_event; 1082 - event->action = cmd_act_get; 1083 - pcmdptr->size = 1084 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 1105 + event->action = cpu_to_le16(cmd_act_get); 1106 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 1085 1107 libertas_queue_cmd(adapter, pcmdnode, 1); 1086 1108 wake_up_interruptible(&priv->mainthread.waitq); 1087 1109 1088 1110 /* Sleep until response is generated by FW */ 1089 1111 wait_event_interruptible(pcmdnode->cmdwait_q, 1090 - pcmdnode->cmdwaitqwoken); 1112 + pcmdnode->cmdwaitqwoken); 1091 1113 1092 1114 pcmdptr = response_buf; 1093 1115 1094 1116 if (pcmdptr->result) { 1095 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1096 - pcmdptr->result); 1117 + lbs_pr_err("%s: fail, result=%d\n", __func__, 1118 + le16_to_cpu(pcmdptr->result)); 1097 1119 kfree(response_buf); 1098 1120 free_page(addr); 1099 1121 return 0; 1100 1122 } 1101 1123 1102 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1124 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 1103 1125 lbs_pr_err("command response incorrect!\n"); 1104 1126 kfree(response_buf); 1105 1127 free_page(addr); ··· 1106 1130 } 1107 1131 1108 1132 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 1109 - event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 1110 - while (cmd_len < pcmdptr->size) { 1111 - struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 1112 - switch(header->type) { 1133 + event = (void *)(response_buf + S_DS_GEN); 1134 + while (cmd_len < le16_to_cpu(pcmdptr->size)) { 1135 + struct mrvlietypesheader *header = (void *)(response_buf + cmd_len); 1136 + switch (header->type) { 1113 1137 struct mrvlietypes_rssithreshold *Highrssi; 1114 - case TLV_TYPE_RSSI_HIGH: 1115 - Highrssi = (struct mrvlietypes_rssithreshold *)(response_buf + cmd_len); 1116 - pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 1117 - Highrssi->rssivalue, 1118 - Highrssi->rssifreq, 1119 - (event->events & 0x0010)?1:0); 1138 + case __constant_cpu_to_le16(TLV_TYPE_RSSI_HIGH): 1139 + Highrssi = (void *)(response_buf + cmd_len); 1140 + pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 1141 + Highrssi->rssivalue, 1142 + Highrssi->rssifreq, 1143 + (event->events & cpu_to_le16(0x0010))?1:0); 1120 1144 default: 1121 1145 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 1122 1146 break; ··· 1166 1190 goto out_unlock; 1167 1191 1168 1192 event = &pcmdptr->params.subscribe_event; 1169 - event->action = cmd_act_set; 1193 + event->action = cpu_to_le16(cmd_act_set); 1170 1194 pcmdptr->size = cpu_to_le16(S_DS_GEN + 1171 1195 sizeof(struct cmd_ds_802_11_subscribe_event) + 1172 1196 sizeof(struct mrvlietypes_rssithreshold)); ··· 1174 1198 ptr = (u8*) pcmdptr+cmd_len; 1175 1199 rssi_threshold = (struct mrvlietypes_rssithreshold *)(ptr); 1176 1200 rssi_threshold->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH); 1177 - rssi_threshold->header.len = 2; 1178 - rssi_threshold->rssivalue = cpu_to_le16(value); 1179 - rssi_threshold->rssifreq = cpu_to_le16(freq); 1201 + rssi_threshold->header.len = cpu_to_le16(2); 1202 + rssi_threshold->rssivalue = value; 1203 + rssi_threshold->rssifreq = freq; 1180 1204 event_bitmap |= subscribed ? 0x0010 : 0x0; 1181 - event->events = event_bitmap; 1205 + event->events = cpu_to_le16(event_bitmap); 1182 1206 1183 1207 libertas_queue_cmd(adapter, pcmdnode, 1); 1184 1208 wake_up_interruptible(&priv->mainthread.waitq); 1185 1209 1186 1210 /* Sleep until response is generated by FW */ 1187 1211 wait_event_interruptible(pcmdnode->cmdwait_q, 1188 - pcmdnode->cmdwaitqwoken); 1212 + pcmdnode->cmdwaitqwoken); 1189 1213 1190 1214 pcmdptr = response_buf; 1191 1215 1192 1216 if (pcmdptr->result) { 1193 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1194 - pcmdptr->result); 1217 + lbs_pr_err("%s: fail, result=%d\n", __func__, 1218 + le16_to_cpu(pcmdptr->result)); 1195 1219 kfree(response_buf); 1196 1220 return 0; 1197 1221 } 1198 1222 1199 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1223 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 1200 1224 lbs_pr_err("command response incorrect!\n"); 1201 1225 kfree(response_buf); 1202 1226 return 0; ··· 1229 1253 } 1230 1254 1231 1255 event = &pcmdptr->params.subscribe_event; 1232 - event->action = cmd_act_get; 1233 - pcmdptr->size = 1234 - cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN); 1256 + event->action = cpu_to_le16(cmd_act_get); 1257 + pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN); 1235 1258 libertas_queue_cmd(adapter, pcmdnode, 1); 1236 1259 wake_up_interruptible(&priv->mainthread.waitq); 1237 1260 1238 1261 /* Sleep until response is generated by FW */ 1239 1262 wait_event_interruptible(pcmdnode->cmdwait_q, 1240 - pcmdnode->cmdwaitqwoken); 1263 + pcmdnode->cmdwaitqwoken); 1241 1264 1242 1265 pcmdptr = response_buf; 1243 1266 1244 1267 if (pcmdptr->result) { 1245 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1246 - pcmdptr->result); 1268 + lbs_pr_err("%s: fail, result=%d\n", __func__, 1269 + le16_to_cpu(pcmdptr->result)); 1247 1270 kfree(response_buf); 1248 1271 free_page(addr); 1249 1272 return 0; 1250 1273 } 1251 1274 1252 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1275 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 1253 1276 lbs_pr_err("command response incorrect!\n"); 1254 1277 kfree(response_buf); 1255 1278 free_page(addr); ··· 1256 1281 } 1257 1282 1258 1283 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 1259 - event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 1260 - while (cmd_len < pcmdptr->size) { 1261 - struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 1262 - switch(header->type) { 1284 + event = (void *)(response_buf + S_DS_GEN); 1285 + while (cmd_len < le16_to_cpu(pcmdptr->size)) { 1286 + struct mrvlietypesheader *header = (void *)(response_buf + cmd_len); 1287 + switch (header->type) { 1263 1288 struct mrvlietypes_snrthreshold *HighSnr; 1264 - case TLV_TYPE_SNR_HIGH: 1265 - HighSnr = (struct mrvlietypes_snrthreshold *)(response_buf + cmd_len); 1266 - pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 1267 - HighSnr->snrvalue, 1268 - HighSnr->snrfreq, 1269 - (event->events & 0x0020)?1:0); 1289 + case __constant_cpu_to_le16(TLV_TYPE_SNR_HIGH): 1290 + HighSnr = (void *)(response_buf + cmd_len); 1291 + pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 1292 + HighSnr->snrvalue, 1293 + HighSnr->snrfreq, 1294 + (event->events & cpu_to_le16(0x0020))?1:0); 1270 1295 default: 1271 1296 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 1272 1297 break; ··· 1316 1341 goto out_unlock; 1317 1342 1318 1343 event = &pcmdptr->params.subscribe_event; 1319 - event->action = cmd_act_set; 1344 + event->action = cpu_to_le16(cmd_act_set); 1320 1345 pcmdptr->size = cpu_to_le16(S_DS_GEN + 1321 1346 sizeof(struct cmd_ds_802_11_subscribe_event) + 1322 1347 sizeof(struct mrvlietypes_snrthreshold)); ··· 1324 1349 ptr = (u8*) pcmdptr+cmd_len; 1325 1350 snr_threshold = (struct mrvlietypes_snrthreshold *)(ptr); 1326 1351 snr_threshold->header.type = cpu_to_le16(TLV_TYPE_SNR_HIGH); 1327 - snr_threshold->header.len = 2; 1328 - snr_threshold->snrvalue = cpu_to_le16(value); 1329 - snr_threshold->snrfreq = cpu_to_le16(freq); 1352 + snr_threshold->header.len = cpu_to_le16(2); 1353 + snr_threshold->snrvalue = value; 1354 + snr_threshold->snrfreq = freq; 1330 1355 event_bitmap |= subscribed ? 0x0020 : 0x0; 1331 - event->events = event_bitmap; 1356 + event->events = cpu_to_le16(event_bitmap); 1332 1357 1333 1358 libertas_queue_cmd(adapter, pcmdnode, 1); 1334 1359 wake_up_interruptible(&priv->mainthread.waitq); 1335 1360 1336 1361 /* Sleep until response is generated by FW */ 1337 1362 wait_event_interruptible(pcmdnode->cmdwait_q, 1338 - pcmdnode->cmdwaitqwoken); 1363 + pcmdnode->cmdwaitqwoken); 1339 1364 1340 1365 pcmdptr = response_buf; 1341 1366 1342 1367 if (pcmdptr->result) { 1343 - lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1344 - pcmdptr->result); 1368 + lbs_pr_err("%s: fail, result=%d\n", __func__, 1369 + le16_to_cpu(pcmdptr->result)); 1345 1370 kfree(response_buf); 1346 1371 free_page(addr); 1347 1372 return 0; 1348 1373 } 1349 1374 1350 - if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1375 + if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) { 1351 1376 lbs_pr_err("command response incorrect!\n"); 1352 1377 kfree(response_buf); 1353 1378 free_page(addr); ··· 1735 1760 1736 1761 debugfs_remove(priv->regs_dir); 1737 1762 1738 - for(i=0; i<ARRAY_SIZE(debugfs_files); i++) 1763 + for(i=0; i<ARRAY_SIZE(debugfs_events_files); i++) 1739 1764 debugfs_remove(priv->debugfs_events_files[i]); 1740 1765 1741 1766 debugfs_remove(priv->events_dir); ··· 1744 1769 #endif 1745 1770 for(i=0; i<ARRAY_SIZE(debugfs_files); i++) 1746 1771 debugfs_remove(priv->debugfs_files[i]); 1772 + debugfs_remove(priv->debugfs_dir); 1747 1773 } 1774 + 1775 + 1748 1776 1749 1777 /* debug entry */ 1750 1778 1779 + #ifdef PROC_DEBUG 1780 + 1751 1781 #define item_size(n) (FIELD_SIZEOF(wlan_adapter, n)) 1752 1782 #define item_addr(n) (offsetof(wlan_adapter, n)) 1783 + 1753 1784 1754 1785 struct debug_data { 1755 1786 char name[32]; ··· 1844 1863 return 0; 1845 1864 1846 1865 if (copy_from_user(pdata, buf, cnt)) { 1847 - lbs_pr_debug(1, "Copy from user failed\n"); 1866 + lbs_deb_debugfs("Copy from user failed\n"); 1848 1867 kfree(pdata); 1849 1868 return 0; 1850 1869 } ··· 1894 1913 * @param dev pointer net_device 1895 1914 * @return N/A 1896 1915 */ 1897 - void libertas_debug_init(wlan_private * priv, struct net_device *dev) 1916 + static void libertas_debug_init(wlan_private * priv, struct net_device *dev) 1898 1917 { 1899 1918 int i; 1900 1919 ··· 1908 1927 priv->debugfs_dir, &items[0], 1909 1928 &libertas_debug_fops); 1910 1929 } 1930 + #endif 1911 1931
+14 -6
drivers/net/wireless/libertas/decl.h
··· 6 6 #ifndef _WLAN_DECL_H_ 7 7 #define _WLAN_DECL_H_ 8 8 9 + #include <linux/device.h> 10 + 9 11 #include "defs.h" 10 12 11 13 /** Function Prototype Declaration */ ··· 68 66 69 67 void libertas_tx_runqueue(wlan_private *priv); 70 68 71 - extern struct chan_freq_power *libertas_find_cfp_by_band_and_channel( 69 + struct chan_freq_power *libertas_find_cfp_by_band_and_channel( 72 70 wlan_adapter * adapter, u8 band, u16 channel); 73 71 74 - extern void libertas_mac_event_disconnected(wlan_private * priv); 72 + void libertas_mac_event_disconnected(wlan_private * priv); 75 73 76 74 void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str); 77 75 78 - int reset_device(wlan_private *priv); 76 + /* fw.c */ 77 + int libertas_init_fw(wlan_private * priv, char *fw_name); 78 + 79 79 /* main.c */ 80 - extern struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band, 80 + struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band, 81 81 int *cfp_no); 82 - wlan_private *wlan_add_card(void *card); 83 - int wlan_remove_card(void *card); 82 + wlan_private *libertas_add_card(void *card, struct device *dmdev); 83 + int libertas_activate_card(wlan_private *priv, char *fw_name); 84 + int libertas_remove_card(wlan_private *priv); 85 + int libertas_add_mesh(wlan_private *priv, struct device *dev); 86 + void libertas_remove_mesh(wlan_private *priv); 87 + 84 88 85 89 #endif /* _WLAN_DECL_H_ */
+80 -21
drivers/net/wireless/libertas/defs.h
··· 7 7 8 8 #include <linux/spinlock.h> 9 9 10 - extern unsigned int libertas_debug; 11 - 12 10 #ifdef CONFIG_LIBERTAS_DEBUG 13 11 #define DEBUG 14 12 #define PROC_DEBUG 15 13 #endif 16 14 17 - #define DRV_NAME "usb8xxx" 15 + #ifndef DRV_NAME 16 + #define DRV_NAME "libertas" 17 + #endif 18 + 19 + 20 + #define LBS_DEB_ENTER 0x00000001 21 + #define LBS_DEB_LEAVE 0x00000002 22 + #define LBS_DEB_MAIN 0x00000004 23 + #define LBS_DEB_NET 0x00000008 24 + #define LBS_DEB_MESH 0x00000010 25 + #define LBS_DEB_WEXT 0x00000020 26 + #define LBS_DEB_IOCTL 0x00000040 27 + #define LBS_DEB_SCAN 0x00000080 28 + #define LBS_DEB_ASSOC 0x00000100 29 + #define LBS_DEB_JOIN 0x00000200 30 + #define LBS_DEB_11D 0x00000400 31 + #define LBS_DEB_DEBUGFS 0x00000800 32 + #define LBS_DEB_ETHTOOL 0x00001000 33 + #define LBS_DEB_HOST 0x00002000 34 + #define LBS_DEB_CMD 0x00004000 35 + #define LBS_DEB_RX 0x00008000 36 + #define LBS_DEB_TX 0x00010000 37 + #define LBS_DEB_USB 0x00020000 38 + #define LBS_DEB_CS 0x00040000 39 + #define LBS_DEB_FW 0x00080000 40 + #define LBS_DEB_THREAD 0x00100000 41 + #define LBS_DEB_HEX 0x00200000 42 + 43 + extern unsigned int libertas_debug; 44 + 45 + #ifdef DEBUG 46 + #define LBS_DEB_LL(grp, fmt, args...) \ 47 + do { if ((libertas_debug & (grp)) == (grp)) \ 48 + printk(KERN_DEBUG DRV_NAME "%s: " fmt, \ 49 + in_interrupt() ? " (INT)" : "", ## args); } while (0) 50 + #else 51 + #define LBS_DEB_LL(grp, fmt, args...) do {} while (0) 52 + #endif 53 + 54 + #define lbs_deb_enter(grp) \ 55 + LBS_DEB_LL(grp | LBS_DEB_ENTER, "%s():%d enter\n", __FUNCTION__, __LINE__); 56 + #define lbs_deb_enter_args(grp, fmt, args...) \ 57 + LBS_DEB_LL(grp | LBS_DEB_ENTER, "%s(" fmt "):%d\n", __FUNCTION__, ## args, __LINE__); 58 + #define lbs_deb_leave(grp) \ 59 + LBS_DEB_LL(grp | LBS_DEB_LEAVE, "%s():%d leave\n", __FUNCTION__, __LINE__); 60 + #define lbs_deb_leave_args(grp, fmt, args...) \ 61 + LBS_DEB_LL(grp | LBS_DEB_LEAVE, "%s():%d leave, " fmt "\n", \ 62 + __FUNCTION__, __LINE__, ##args); 63 + #define lbs_deb_main(fmt, args...) LBS_DEB_LL(LBS_DEB_MAIN, fmt, ##args) 64 + #define lbs_deb_net(fmt, args...) LBS_DEB_LL(LBS_DEB_NET, fmt, ##args) 65 + #define lbs_deb_mesh(fmt, args...) LBS_DEB_LL(LBS_DEB_MESH, fmt, ##args) 66 + #define lbs_deb_wext(fmt, args...) LBS_DEB_LL(LBS_DEB_WEXT, fmt, ##args) 67 + #define lbs_deb_ioctl(fmt, args...) LBS_DEB_LL(LBS_DEB_IOCTL, fmt, ##args) 68 + #define lbs_deb_scan(fmt, args...) LBS_DEB_LL(LBS_DEB_SCAN, fmt, ##args) 69 + #define lbs_deb_assoc(fmt, args...) LBS_DEB_LL(LBS_DEB_ASSOC, fmt, ##args) 70 + #define lbs_deb_join(fmt, args...) LBS_DEB_LL(LBS_DEB_JOIN, fmt, ##args) 71 + #define lbs_deb_11d(fmt, args...) LBS_DEB_LL(LBS_DEB_11D, fmt, ##args) 72 + #define lbs_deb_debugfs(fmt, args...) LBS_DEB_LL(LBS_DEB_DEBUGFS, fmt, ##args) 73 + #define lbs_deb_ethtool(fmt, args...) LBS_DEB_LL(LBS_DEB_ETHTOOL, fmt, ##args) 74 + #define lbs_deb_host(fmt, args...) LBS_DEB_LL(LBS_DEB_HOST, fmt, ##args) 75 + #define lbs_deb_cmd(fmt, args...) LBS_DEB_LL(LBS_DEB_CMD, fmt, ##args) 76 + #define lbs_deb_rx(fmt, args...) LBS_DEB_LL(LBS_DEB_RX, fmt, ##args) 77 + #define lbs_deb_tx(fmt, args...) LBS_DEB_LL(LBS_DEB_TX, fmt, ##args) 78 + #define lbs_deb_fw(fmt, args...) LBS_DEB_LL(LBS_DEB_FW, fmt, ##args) 79 + #define lbs_deb_usb(fmt, args...) LBS_DEB_LL(LBS_DEB_USB, fmt, ##args) 80 + #define lbs_deb_usbd(dev, fmt, args...) LBS_DEB_LL(LBS_DEB_USB, "%s:" fmt, (dev)->bus_id, ##args) 81 + #define lbs_deb_cs(fmt, args...) LBS_DEB_LL(LBS_DEB_CS, fmt, ##args) 82 + #define lbs_deb_thread(fmt, args...) LBS_DEB_LL(LBS_DEB_THREAD, fmt, ##args) 18 83 19 84 #define lbs_pr_info(format, args...) \ 20 85 printk(KERN_INFO DRV_NAME": " format, ## args) ··· 89 24 printk(KERN_ALERT DRV_NAME": " format, ## args) 90 25 91 26 #ifdef DEBUG 92 - #define lbs_pr_debug(level, format, args...) \ 93 - do { if (libertas_debug >= level) \ 94 - printk(KERN_INFO DRV_NAME": " format, ##args); } while (0) 95 - #define lbs_dev_dbg(level, device, format, args...) \ 96 - lbs_pr_debug(level, "%s: " format, \ 97 - (device)->bus_id , ## args) 98 - 99 27 static inline void lbs_dbg_hex(char *prompt, u8 * buf, int len) 100 28 { 101 29 int i = 0; 102 30 103 - if (!libertas_debug) 31 + if (!(libertas_debug & LBS_DEB_HEX)) 104 32 return; 105 33 106 34 printk(KERN_DEBUG "%s: ", prompt); 107 35 for (i = 1; i <= len; i++) { 108 - printk(KERN_DEBUG "%02x ", (u8) * buf); 36 + printk("%02x ", (u8) * buf); 109 37 buf++; 110 38 } 111 39 printk("\n"); 112 40 } 113 41 #else 114 - #define lbs_pr_debug(level, format, args...) do {} while (0) 115 - #define lbs_dev_dbg(level, device, format, args...) do {} while (0) 116 42 #define lbs_dbg_hex(x,y,z) do {} while (0) 117 43 #endif 118 44 119 - #define ENTER() lbs_pr_debug(1, "Enter: %s, %s:%i\n", \ 120 - __FUNCTION__, __FILE__, __LINE__) 121 - #define LEAVE() lbs_pr_debug(1, "Leave: %s, %s:%i\n", \ 122 - __FUNCTION__, __FILE__, __LINE__) 45 + 123 46 124 47 /** Buffer Constants */ 125 48 ··· 127 74 #define MRVDRV_NUM_OF_CMD_BUFFER 10 128 75 #define MRVDRV_SIZE_OF_CMD_BUFFER (2 * 1024) 129 76 #define MRVDRV_MAX_CHANNEL_SIZE 14 130 - #define MRVDRV_MAX_BSSID_LIST 64 131 77 #define MRVDRV_ASSOCIATION_TIME_OUT 255 132 78 #define MRVDRV_SNAP_HEADER_LEN 8 133 79 ··· 155 103 #define MRVDRV_MIN_BEACON_INTERVAL 20 156 104 #define MRVDRV_MAX_BEACON_INTERVAL 1000 157 105 #define MRVDRV_BEACON_INTERVAL 100 106 + 107 + /** INT status Bit Definition*/ 108 + #define his_cmddnldrdy 0x01 109 + #define his_cardevent 0x02 110 + #define his_cmdupldrdy 0x04 111 + 112 + #define SBI_EVENT_CAUSE_SHIFT 3 158 113 159 114 /** TxPD status */ 160 115 ··· 263 204 typedef struct _wlan_adapter wlan_adapter; 264 205 extern const char libertas_driver_version[]; 265 206 extern u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE]; 266 - 267 - extern u8 libertas_wlan_data_rates[WLAN_SUPPORTED_RATES]; 268 207 269 208 extern u8 libertas_supported_rates[G_SUPPORTED_RATES]; 270 209 ··· 373 316 /* Default values for fwt commands. */ 374 317 #define FWT_DEFAULT_METRIC 0 375 318 #define FWT_DEFAULT_DIR 1 319 + /* Default Rate, 11Mbps */ 320 + #define FWT_DEFAULT_RATE 3 376 321 #define FWT_DEFAULT_SSN 0xffffffff 377 322 #define FWT_DEFAULT_DSN 0 378 323 #define FWT_DEFAULT_HOPCOUNT 0
+53 -46
drivers/net/wireless/libertas/dev.h
··· 63 63 64 64 /** Current Basic Service Set State Structure */ 65 65 struct current_bss_params { 66 - struct bss_descriptor bssdescriptor; 67 66 /** bssid */ 68 67 u8 bssid[ETH_ALEN]; 69 68 /** ssid */ 70 - struct WLAN_802_11_SSID ssid; 69 + u8 ssid[IW_ESSID_MAX_SIZE + 1]; 70 + u8 ssid_len; 71 71 72 72 /** band */ 73 73 u8 band; ··· 89 89 u16 sp_reserved; 90 90 }; 91 91 92 - /** Data structure for the Marvell WLAN device */ 93 - typedef struct _wlan_dev { 94 - /** device name */ 95 - char name[DEV_NAME_LEN]; 96 - /** card pointer */ 97 - void *card; 98 - /** IO port */ 99 - u32 ioport; 100 - /** Upload received */ 101 - u32 upld_rcv; 102 - /** Upload type */ 103 - u32 upld_typ; 104 - /** Upload length */ 105 - u32 upld_len; 106 - /** netdev pointer */ 107 - struct net_device *netdev; 108 - /* Upload buffer */ 109 - u8 upld_buf[WLAN_UPLD_SIZE]; 110 - /* Download sent: 111 - bit0 1/0=data_sent/data_tx_done, 112 - bit1 1/0=cmd_sent/cmd_tx_done, 113 - all other bits reserved 0 */ 114 - u8 dnld_sent; 115 - } wlan_dev_t, *pwlan_dev_t; 116 - 117 92 /* Mesh statistics */ 118 93 struct wlan_mesh_stats { 119 94 u32 fwd_bcast_cnt; /* Fwd: Broadcast counter */ ··· 98 123 u32 fwd_drop_noroute; /* Fwd: No route to Destination */ 99 124 u32 fwd_drop_nobuf; /* Fwd: Run out of internal buffers */ 100 125 u32 drop_blind; /* Rx: Dropped by blinding table */ 126 + u32 tx_failed_cnt; /* Tx: Failed transmissions */ 101 127 }; 102 128 103 129 /** Private structure for the MV device */ ··· 107 131 int mesh_open; 108 132 int infra_open; 109 133 134 + char name[DEV_NAME_LEN]; 135 + 136 + void *card; 110 137 wlan_adapter *adapter; 111 - wlan_dev_t wlan_dev; 138 + struct net_device *dev; 112 139 113 140 struct net_device_stats stats; 114 141 struct net_device *mesh_dev ; /* Virtual device */ ··· 132 153 u32 bbp_offset; 133 154 u32 rf_offset; 134 155 156 + /** Upload length */ 157 + u32 upld_len; 158 + /* Upload buffer */ 159 + u8 upld_buf[WLAN_UPLD_SIZE]; 160 + /* Download sent: 161 + bit0 1/0=data_sent/data_tx_done, 162 + bit1 1/0=cmd_sent/cmd_tx_done, 163 + all other bits reserved 0 */ 164 + u8 dnld_sent; 165 + 135 166 const struct firmware *firmware; 136 167 struct device *hotplug_device; 137 168 ··· 150 161 151 162 struct delayed_work assoc_work; 152 163 struct workqueue_struct *assoc_thread; 164 + struct work_struct sync_channel; 165 + 166 + /** Hardware access */ 167 + int (*hw_register_dev) (wlan_private * priv); 168 + int (*hw_unregister_dev) (wlan_private *); 169 + int (*hw_prog_firmware) (wlan_private *); 170 + int (*hw_host_to_card) (wlan_private * priv, u8 type, u8 * payload, u16 nb); 171 + int (*hw_get_int_status) (wlan_private * priv, u8 *); 172 + int (*hw_read_event_cause) (wlan_private *); 153 173 }; 154 174 155 175 /** Association request ··· 169 171 struct assoc_request { 170 172 #define ASSOC_FLAG_SSID 1 171 173 #define ASSOC_FLAG_CHANNEL 2 172 - #define ASSOC_FLAG_MODE 3 173 - #define ASSOC_FLAG_BSSID 4 174 - #define ASSOC_FLAG_WEP_KEYS 5 175 - #define ASSOC_FLAG_WEP_TX_KEYIDX 6 176 - #define ASSOC_FLAG_WPA_MCAST_KEY 7 177 - #define ASSOC_FLAG_WPA_UCAST_KEY 8 178 - #define ASSOC_FLAG_SECINFO 9 179 - #define ASSOC_FLAG_WPA_IE 10 174 + #define ASSOC_FLAG_BAND 3 175 + #define ASSOC_FLAG_MODE 4 176 + #define ASSOC_FLAG_BSSID 5 177 + #define ASSOC_FLAG_WEP_KEYS 6 178 + #define ASSOC_FLAG_WEP_TX_KEYIDX 7 179 + #define ASSOC_FLAG_WPA_MCAST_KEY 8 180 + #define ASSOC_FLAG_WPA_UCAST_KEY 9 181 + #define ASSOC_FLAG_SECINFO 10 182 + #define ASSOC_FLAG_WPA_IE 11 180 183 unsigned long flags; 181 184 182 - struct WLAN_802_11_SSID ssid; 185 + u8 ssid[IW_ESSID_MAX_SIZE + 1]; 186 + u8 ssid_len; 183 187 u8 channel; 188 + u8 band; 184 189 u8 mode; 185 190 u8 bssid[ETH_ALEN]; 186 191 ··· 200 199 /** WPA Information Elements*/ 201 200 u8 wpa_ie[MAX_WPA_IE_LEN]; 202 201 u8 wpa_ie_len; 202 + 203 + /* BSS to associate with for infrastructure of Ad-Hoc join */ 204 + struct bss_descriptor bss; 203 205 }; 204 206 205 207 /** Wlan adapter data structure*/ 206 208 struct _wlan_adapter { 207 209 /** STATUS variables */ 208 - u32 fwreleasenumber; 210 + u8 fwreleasenumber[4]; 209 211 u32 fwcapinfo; 210 212 /* protected with big lock */ 211 213 ··· 259 255 /* IW_MODE_* */ 260 256 u8 mode; 261 257 262 - struct bss_descriptor *pattemptedbssdesc; 258 + u8 prev_ssid[IW_ESSID_MAX_SIZE + 1]; 259 + u8 prev_ssid_len; 260 + u8 prev_bssid[ETH_ALEN]; 263 261 264 - struct WLAN_802_11_SSID previousssid; 265 - u8 previousbssid[ETH_ALEN]; 266 - 267 - struct bss_descriptor *scantable; 268 - u32 numinscantable; 262 + /* Scan results list */ 263 + struct list_head network_list; 264 + struct list_head network_free_list; 265 + struct bss_descriptor *networks; 269 266 270 267 u8 scantype; 271 268 u32 scanmode; ··· 293 288 u32 txantenna; 294 289 u32 rxantenna; 295 290 296 - u8 adhocchannel; 297 291 u32 fragthsd; 298 292 u32 rtsthsd; 299 293 ··· 328 324 u16 locallisteninterval; 329 325 u16 nullpktinterval; 330 326 331 - struct assoc_request * assoc_req; 327 + struct assoc_request * pending_assoc_req; 328 + struct assoc_request * in_progress_assoc_req; 332 329 333 330 /** Encryption parameter */ 334 331 struct wlan_802_11_security secinfo; ··· 401 396 u32 radiomode; 402 397 u32 debugmode; 403 398 u8 fw_ready; 399 + 400 + u8 last_scanned_channel; 404 401 }; 405 402 406 403 #endif /* _WLAN_DEV_H_ */
+32 -23
drivers/net/wireless/libertas/ethtool.c
··· 1 - 2 1 #include <linux/netdevice.h> 3 2 #include <linux/ethtool.h> 4 3 #include <linux/delay.h> 5 4 6 5 #include "host.h" 7 - #include "sbi.h" 8 6 #include "decl.h" 9 7 #include "defs.h" 10 8 #include "dev.h" ··· 15 17 "drop_no_buffers", 16 18 "fwded_unicast_cnt", 17 19 "fwded_bcast_cnt", 18 - "drop_blind_table" 20 + "drop_blind_table", 21 + "tx_failed_cnt" 19 22 }; 20 23 21 24 static void libertas_ethtool_get_drvinfo(struct net_device *dev, ··· 68 69 69 70 /* +14 is for action, offset, and NOB in 70 71 * response */ 71 - lbs_pr_debug(1, "action:%d offset: %x NOB: %02x\n", 72 + lbs_deb_ethtool("action:%d offset: %x NOB: %02x\n", 72 73 regctrl.action, regctrl.offset, regctrl.NOB); 73 74 74 75 ret = libertas_prepare_and_send_command(priv, ··· 80 81 if (ret) { 81 82 if (adapter->prdeeprom) 82 83 kfree(adapter->prdeeprom); 83 - LEAVE(); 84 - return ret; 84 + goto done; 85 85 } 86 86 87 87 mdelay(10); ··· 99 101 kfree(adapter->prdeeprom); 100 102 // mutex_unlock(&priv->mutex); 101 103 102 - return 0; 104 + ret = 0; 105 + 106 + done: 107 + lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret); 108 + return ret; 103 109 } 104 110 105 111 static void libertas_ethtool_get_stats(struct net_device * dev, ··· 111 109 { 112 110 wlan_private *priv = dev->priv; 113 111 114 - ENTER(); 112 + lbs_deb_enter(LBS_DEB_ETHTOOL); 115 113 116 114 stats->cmd = ETHTOOL_GSTATS; 117 115 BUG_ON(stats->n_stats != MESH_STATS_NUM); ··· 123 121 data[4] = priv->mstats.fwd_unicast_cnt; 124 122 data[5] = priv->mstats.fwd_bcast_cnt; 125 123 data[6] = priv->mstats.drop_blind; 124 + data[7] = priv->mstats.tx_failed_cnt; 126 125 127 - LEAVE(); 126 + lbs_deb_enter(LBS_DEB_ETHTOOL); 128 127 } 129 128 130 129 static int libertas_ethtool_get_stats_count(struct net_device * dev) ··· 134 131 wlan_private *priv = dev->priv; 135 132 struct cmd_ds_mesh_access mesh_access; 136 133 137 - ENTER(); 134 + lbs_deb_enter(LBS_DEB_ETHTOOL); 135 + 138 136 /* Get Mesh Statistics */ 139 137 ret = libertas_prepare_and_send_command(priv, 140 138 cmd_mesh_access, cmd_act_mesh_get_stats, 141 139 cmd_option_waitforrsp, 0, &mesh_access); 142 140 143 141 if (ret) { 144 - LEAVE(); 145 - return 0; 142 + ret = 0; 143 + goto done; 146 144 } 147 145 148 - priv->mstats.fwd_drop_rbt = mesh_access.data[0]; 149 - priv->mstats.fwd_drop_ttl = mesh_access.data[1]; 150 - priv->mstats.fwd_drop_noroute = mesh_access.data[2]; 151 - priv->mstats.fwd_drop_nobuf = mesh_access.data[3]; 152 - priv->mstats.fwd_unicast_cnt = mesh_access.data[4]; 153 - priv->mstats.fwd_bcast_cnt = mesh_access.data[5]; 154 - priv->mstats.drop_blind = mesh_access.data[6]; 146 + priv->mstats.fwd_drop_rbt = le32_to_cpu(mesh_access.data[0]); 147 + priv->mstats.fwd_drop_ttl = le32_to_cpu(mesh_access.data[1]); 148 + priv->mstats.fwd_drop_noroute = le32_to_cpu(mesh_access.data[2]); 149 + priv->mstats.fwd_drop_nobuf = le32_to_cpu(mesh_access.data[3]); 150 + priv->mstats.fwd_unicast_cnt = le32_to_cpu(mesh_access.data[4]); 151 + priv->mstats.fwd_bcast_cnt = le32_to_cpu(mesh_access.data[5]); 152 + priv->mstats.drop_blind = le32_to_cpu(mesh_access.data[6]); 153 + priv->mstats.tx_failed_cnt = le32_to_cpu(mesh_access.data[7]); 155 154 156 - LEAVE(); 157 - return MESH_STATS_NUM; 155 + ret = MESH_STATS_NUM; 156 + 157 + done: 158 + lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret); 159 + return ret; 158 160 } 159 161 160 162 static void libertas_ethtool_get_strings (struct net_device * dev, ··· 168 160 { 169 161 int i; 170 162 171 - ENTER(); 163 + lbs_deb_enter(LBS_DEB_ETHTOOL); 164 + 172 165 switch (stringset) { 173 166 case ETH_SS_STATS: 174 167 for (i=0; i < MESH_STATS_NUM; i++) { ··· 179 170 } 180 171 break; 181 172 } 182 - LEAVE(); 173 + lbs_deb_enter(LBS_DEB_ETHTOOL); 183 174 } 184 175 185 176 struct ethtool_ops libertas_ethtool_ops = {
+49 -62
drivers/net/wireless/libertas/fw.c
··· 1 1 /** 2 2 * This file contains the initialization for FW and HW 3 3 */ 4 - #include <linux/module.h> 5 - #include <linux/moduleparam.h> 6 - 7 - #include <linux/vmalloc.h> 8 4 #include <linux/firmware.h> 9 - #include <linux/version.h> 10 5 11 6 #include "host.h" 12 - #include "sbi.h" 13 7 #include "defs.h" 14 8 #include "decl.h" 15 9 #include "dev.h" 16 - #include "fw.h" 17 10 #include "wext.h" 18 11 #include "if_usb.h" 19 - 20 - char *libertas_fw_name = NULL; 21 - module_param_named(fw_name, libertas_fw_name, charp, 0644); 22 - 23 - unsigned int libertas_debug = 0; 24 - module_param(libertas_debug, int, 0); 25 12 26 13 /** 27 14 * @brief This function checks the validity of Boot2/FW image. ··· 19 32 */ 20 33 static int check_fwfile_format(u8 *data, u32 totlen) 21 34 { 22 - u8 bincmd, exit; 35 + u32 bincmd, exit; 23 36 u32 blksize, offset, len; 24 37 int ret; 25 38 ··· 27 40 exit = len = 0; 28 41 29 42 do { 30 - bincmd = *data; 31 - blksize = *(u32*)(data + offsetof(struct fwheader, datalength)); 43 + struct fwheader *fwh = (void *)data; 44 + 45 + bincmd = le32_to_cpu(fwh->dnldcmd); 46 + blksize = le32_to_cpu(fwh->datalength); 32 47 switch (bincmd) { 33 48 case FW_HAS_DATA_TO_RECV: 34 49 offset = sizeof(struct fwheader) + blksize; ··· 50 61 } while (!exit); 51 62 52 63 if (ret) 53 - lbs_pr_err("bin file format check FAIL...\n"); 64 + lbs_pr_err("firmware file format check FAIL\n"); 54 65 else 55 - lbs_pr_debug(1, "bin file format check PASS...\n"); 66 + lbs_deb_fw("firmware file format check PASS\n"); 56 67 57 68 return ret; 58 69 } ··· 65 76 * @param priv A pointer to wlan_private structure 66 77 * @return 0 or -1 67 78 */ 68 - static int wlan_setup_station_hw(wlan_private * priv) 79 + static int wlan_setup_station_hw(wlan_private * priv, char *fw_name) 69 80 { 70 81 int ret = -1; 71 82 wlan_adapter *adapter = priv->adapter; 72 83 73 - ENTER(); 84 + lbs_deb_enter(LBS_DEB_FW); 74 85 75 - if ((ret = request_firmware(&priv->firmware, libertas_fw_name, 86 + if ((ret = request_firmware(&priv->firmware, fw_name, 76 87 priv->hotplug_device)) < 0) { 77 - lbs_pr_err("request_firmware() failed, error code = %#x\n", 78 - ret); 79 - lbs_pr_err("%s not found in /lib/firmware\n", libertas_fw_name); 88 + lbs_pr_err("request_firmware() failed with %#x\n", ret); 89 + lbs_pr_err("firmware %s not found\n", fw_name); 80 90 goto done; 81 91 } 82 92 83 - if(check_fwfile_format(priv->firmware->data, priv->firmware->size)) { 93 + if (check_fwfile_format(priv->firmware->data, priv->firmware->size)) { 84 94 release_firmware(priv->firmware); 85 95 goto done; 86 96 } 87 97 88 - ret = libertas_sbi_prog_firmware(priv); 98 + ret = priv->hw_prog_firmware(priv); 89 99 90 100 release_firmware(priv->firmware); 91 101 92 102 if (ret) { 93 - lbs_pr_debug(1, "Bootloader in invalid state!\n"); 103 + lbs_deb_fw("bootloader in invalid state\n"); 94 104 ret = -1; 95 105 goto done; 96 106 } ··· 121 133 122 134 ret = 0; 123 135 done: 124 - LEAVE(); 125 - 126 - return (ret); 136 + lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); 137 + return ret; 127 138 } 128 139 129 140 static int wlan_allocate_adapter(wlan_private * priv) 130 141 { 131 - u32 ulbufsize; 142 + size_t bufsize; 132 143 wlan_adapter *adapter = priv->adapter; 133 144 134 - struct bss_descriptor *ptempscantable; 135 - 136 145 /* Allocate buffer to store the BSSID list */ 137 - ulbufsize = sizeof(struct bss_descriptor) * MRVDRV_MAX_BSSID_LIST; 138 - if (!(ptempscantable = kmalloc(ulbufsize, GFP_KERNEL))) { 146 + bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor); 147 + adapter->networks = kzalloc(bufsize, GFP_KERNEL); 148 + if (!adapter->networks) { 149 + lbs_pr_err("Out of memory allocating beacons\n"); 139 150 libertas_free_adapter(priv); 140 - return -1; 151 + return -ENOMEM; 141 152 } 142 - 143 - adapter->scantable = ptempscantable; 144 - memset(adapter->scantable, 0, ulbufsize); 145 153 146 154 /* Allocate the command buffers */ 147 155 libertas_allocate_cmd_buffer(priv); ··· 186 202 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 187 203 adapter->mode = IW_MODE_INFRA; 188 204 189 - adapter->assoc_req = NULL; 205 + adapter->pending_assoc_req = NULL; 206 + adapter->in_progress_assoc_req = NULL; 190 207 191 - adapter->numinscantable = 0; 192 - adapter->pattemptedbssdesc = NULL; 208 + /* Initialize scan result lists */ 209 + INIT_LIST_HEAD(&adapter->network_free_list); 210 + INIT_LIST_HEAD(&adapter->network_list); 211 + for (i = 0; i < MAX_NETWORK_COUNT; i++) { 212 + list_add_tail(&adapter->networks[i].list, 213 + &adapter->network_free_list); 214 + } 215 + 193 216 mutex_init(&adapter->lock); 194 217 195 218 adapter->prescan = 1; 196 219 197 220 memset(&adapter->curbssparams, 0, sizeof(adapter->curbssparams)); 221 + adapter->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; 198 222 199 223 /* PnP and power profile */ 200 224 adapter->surpriseremoved = 0; ··· 221 229 #define SHORT_PREAMBLE_ALLOWED 1 222 230 memset(&adapter->capinfo, 0, sizeof(adapter->capinfo)); 223 231 adapter->capinfo.shortpreamble = SHORT_PREAMBLE_ALLOWED; 224 - 225 - adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL; 226 232 227 233 adapter->psmode = wlan802_11powermodecam; 228 234 adapter->multipledtim = MRVDRV_DEFAULT_MULTIPLE_DTIM; ··· 249 259 250 260 static void command_timer_fn(unsigned long data); 251 261 252 - int libertas_init_fw(wlan_private * priv) 262 + int libertas_init_fw(wlan_private * priv, char *fw_name) 253 263 { 254 264 int ret = -1; 255 265 wlan_adapter *adapter = priv->adapter; 256 266 257 - ENTER(); 267 + lbs_deb_enter(LBS_DEB_FW); 258 268 259 269 /* Allocate adapter structure */ 260 270 if ((ret = wlan_allocate_adapter(priv)) != 0) ··· 268 278 (unsigned long)priv); 269 279 270 280 /* download fimrware etc. */ 271 - if ((ret = wlan_setup_station_hw(priv)) != 0) { 281 + if ((ret = wlan_setup_station_hw(priv, fw_name)) != 0) { 272 282 del_timer_sync(&adapter->command_timer); 273 283 goto done; 274 284 } ··· 278 288 279 289 ret = 0; 280 290 done: 281 - LEAVE(); 291 + lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); 282 292 return ret; 283 293 } 284 294 ··· 287 297 wlan_adapter *adapter = priv->adapter; 288 298 289 299 if (!adapter) { 290 - lbs_pr_debug(1, "Why double free adapter?:)\n"); 300 + lbs_deb_fw("why double free adapter?\n"); 291 301 return; 292 302 } 293 303 294 - lbs_pr_debug(1, "Free command buffer\n"); 304 + lbs_deb_fw("free command buffer\n"); 295 305 libertas_free_cmd_buffer(priv); 296 306 297 - lbs_pr_debug(1, "Free commandTimer\n"); 307 + lbs_deb_fw("free command_timer\n"); 298 308 del_timer(&adapter->command_timer); 299 309 300 - lbs_pr_debug(1, "Free scantable\n"); 301 - if (adapter->scantable) { 302 - kfree(adapter->scantable); 303 - adapter->scantable = NULL; 304 - } 305 - 306 - lbs_pr_debug(1, "Free adapter\n"); 310 + lbs_deb_fw("free scan results table\n"); 311 + kfree(adapter->networks); 312 + adapter->networks = NULL; 307 313 308 314 /* Free the adapter object itself */ 315 + lbs_deb_fw("free adapter\n"); 309 316 kfree(adapter); 310 317 priv->adapter = NULL; 311 318 } ··· 321 334 322 335 ptempnode = adapter->cur_cmd; 323 336 if (ptempnode == NULL) { 324 - lbs_pr_debug(1, "PTempnode Empty\n"); 337 + lbs_deb_fw("ptempnode empty\n"); 325 338 return; 326 339 } 327 340 328 341 cmd = (struct cmd_ds_command *)ptempnode->bufvirtualaddr; 329 342 if (!cmd) { 330 - lbs_pr_debug(1, "cmd is NULL\n"); 343 + lbs_deb_fw("cmd is NULL\n"); 331 344 return; 332 345 } 333 346 334 - lbs_pr_info("command_timer_fn fired (%x)\n", cmd->command); 347 + lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command); 335 348 336 349 if (!adapter->fw_ready) 337 350 return; ··· 340 353 adapter->cur_cmd = NULL; 341 354 spin_unlock_irqrestore(&adapter->driver_lock, flags); 342 355 343 - lbs_pr_debug(1, "Re-sending same command as it timeout...!\n"); 356 + lbs_deb_fw("re-sending same command because of timeout\n"); 344 357 libertas_queue_cmd(adapter, ptempnode, 0); 345 358 346 359 wake_up_interruptible(&priv->mainthread.waitq);
-13
drivers/net/wireless/libertas/fw.h
··· 1 - /** 2 - * This header file contains FW interface related definitions. 3 - */ 4 - #ifndef _WLAN_FW_H_ 5 - #define _WLAN_FW_H_ 6 - 7 - #ifndef DEV_NAME_LEN 8 - #define DEV_NAME_LEN 32 9 - #endif 10 - 11 - int libertas_init_fw(wlan_private * priv); 12 - 13 - #endif /* _WLAN_FW_H_ */
+10 -7
drivers/net/wireless/libertas/host.h
··· 99 99 #define cmd_bt_access 0x0087 100 100 #define cmd_ret_bt_access 0x8087 101 101 102 - #define cmd_fwt_access 0x0088 103 - #define cmd_ret_fwt_access 0x8088 102 + #define cmd_fwt_access 0x0095 103 + #define cmd_ret_fwt_access 0x8095 104 104 105 - #define cmd_mesh_access 0x0090 106 - #define cmd_ret_mesh_access 0x8090 105 + #define cmd_mesh_access 0x009b 106 + #define cmd_ret_mesh_access 0x809b 107 107 108 108 /* For the IEEE Power Save */ 109 109 #define cmd_subcmd_enter_ps 0x0030 ··· 287 287 cmd_act_bt_access_add = 5, 288 288 cmd_act_bt_access_del, 289 289 cmd_act_bt_access_list, 290 - cmd_act_bt_access_reset 290 + cmd_act_bt_access_reset, 291 + cmd_act_bt_access_set_invert, 292 + cmd_act_bt_access_get_invert 291 293 }; 292 294 293 295 /* Define action or option for cmd_fwt_access */ ··· 310 308 cmd_act_mesh_get_ttl = 1, 311 309 cmd_act_mesh_set_ttl, 312 310 cmd_act_mesh_get_stats, 313 - cmd_act_mesh_get_mpp, 314 - cmd_act_mesh_set_mpp, 311 + cmd_act_mesh_get_anycast, 312 + cmd_act_mesh_set_anycast, 315 313 }; 316 314 317 315 /** Card Event definition */ ··· 336 334 #define MACREG_INT_CODE_MAX_FAIL 0x0000001b 337 335 #define MACREG_INT_CODE_RSSI_HIGH 0x0000001c 338 336 #define MACREG_INT_CODE_SNR_HIGH 0x0000001d 337 + #define MACREG_INT_CODE_MESH_AUTO_STARTED 0x00000023 339 338 340 339 #endif /* _HOST_H_ */
+192 -200
drivers/net/wireless/libertas/hostcmd.h
··· 14 14 /* TxPD descriptor */ 15 15 struct txpd { 16 16 /* Current Tx packet status */ 17 - u32 tx_status; 17 + __le32 tx_status; 18 18 /* Tx control */ 19 - u32 tx_control; 20 - u32 tx_packet_location; 19 + __le32 tx_control; 20 + __le32 tx_packet_location; 21 21 /* Tx packet length */ 22 - u16 tx_packet_length; 22 + __le16 tx_packet_length; 23 23 /* First 2 byte of destination MAC address */ 24 24 u8 tx_dest_addr_high[2]; 25 25 /* Last 4 byte of destination MAC address */ ··· 37 37 /* RxPD Descriptor */ 38 38 struct rxpd { 39 39 /* Current Rx packet status */ 40 - u16 status; 40 + __le16 status; 41 41 42 42 /* SNR */ 43 43 u8 snr; ··· 46 46 u8 rx_control; 47 47 48 48 /* Pkt length */ 49 - u16 pkt_len; 49 + __le16 pkt_len; 50 50 51 51 /* Noise Floor */ 52 52 u8 nf; ··· 55 55 u8 rx_rate; 56 56 57 57 /* Pkt addr */ 58 - u32 pkt_ptr; 58 + __le32 pkt_ptr; 59 59 60 60 /* Next Rx RxPD addr */ 61 - u32 next_rxpd_ptr; 61 + __le32 next_rxpd_ptr; 62 62 63 63 /* Pkt Priority */ 64 64 u8 priority; ··· 89 89 * is determined from the keylength field. 90 90 */ 91 91 struct WLAN_802_11_KEY { 92 - u32 len; 93 - u32 flags; /* KEY_INFO_* from wlan_defs.h */ 92 + __le32 len; 93 + __le32 flags; /* KEY_INFO_* from wlan_defs.h */ 94 94 u8 key[MRVL_MAX_KEY_WPA_KEY_LENGTH]; 95 - u16 type; /* KEY_TYPE_* from wlan_defs.h */ 95 + __le16 type; /* KEY_TYPE_* from wlan_defs.h */ 96 96 }; 97 97 98 98 struct IE_WPA { 99 99 u8 elementid; 100 100 u8 len; 101 101 u8 oui[4]; 102 - u16 version; 103 - }; 104 - 105 - struct WLAN_802_11_SSID { 106 - /* SSID length */ 107 - u32 ssidlength; 108 - 109 - /* SSID information field */ 110 - u8 ssid[IW_ESSID_MAX_SIZE]; 111 - }; 112 - 113 - struct WPA_SUPPLICANT { 114 - u8 wpa_ie[256]; 115 - u8 wpa_ie_len; 102 + __le16 version; 116 103 }; 117 104 118 105 /* wlan_offset_value */ ··· 109 122 }; 110 123 111 124 struct WLAN_802_11_FIXED_IEs { 112 - u8 timestamp[8]; 113 - u16 beaconinterval; 114 - u16 capabilities; 125 + __le64 timestamp; 126 + __le16 beaconinterval; 127 + u16 capabilities; /* Actually struct ieeetypes_capinfo */ 115 128 }; 116 129 117 130 struct WLAN_802_11_VARIABLE_IEs { ··· 123 136 /* Define general data structure */ 124 137 /* cmd_DS_GEN */ 125 138 struct cmd_ds_gen { 126 - u16 command; 127 - u16 size; 128 - u16 seqnum; 129 - u16 result; 139 + __le16 command; 140 + __le16 size; 141 + __le16 seqnum; 142 + __le16 result; 130 143 }; 131 144 132 145 #define S_DS_GEN sizeof(struct cmd_ds_gen) ··· 136 149 */ 137 150 struct cmd_ds_get_hw_spec { 138 151 /* HW Interface version number */ 139 - u16 hwifversion; 152 + __le16 hwifversion; 140 153 /* HW version number */ 141 - u16 version; 154 + __le16 version; 142 155 /* Max number of TxPD FW can handle */ 143 - u16 nr_txpd; 156 + __le16 nr_txpd; 144 157 /* Max no of Multicast address */ 145 - u16 nr_mcast_adr; 158 + __le16 nr_mcast_adr; 146 159 /* MAC address */ 147 160 u8 permanentaddr[6]; 148 161 149 162 /* region Code */ 150 - u16 regioncode; 163 + __le16 regioncode; 151 164 152 165 /* Number of antenna used */ 153 - u16 nr_antenna; 166 + __le16 nr_antenna; 154 167 155 - /* FW release number, example 0x1234=1.2.3.4 */ 156 - u32 fwreleasenumber; 168 + /* FW release number, example 1,2,3,4 = 3.2.1p4 */ 169 + u8 fwreleasenumber[4]; 157 170 158 171 /* Base Address of TxPD queue */ 159 - u32 wcb_base; 172 + __le32 wcb_base; 160 173 /* Read Pointer of RxPd queue */ 161 - u32 rxpd_rdptr; 174 + __le32 rxpd_rdptr; 162 175 163 176 /* Write Pointer of RxPd queue */ 164 - u32 rxpd_wrptr; 177 + __le32 rxpd_wrptr; 165 178 166 179 /*FW/HW capability */ 167 - u32 fwcapinfo; 180 + __le32 fwcapinfo; 168 181 } __attribute__ ((packed)); 169 182 170 183 struct cmd_ds_802_11_reset { 171 - u16 action; 184 + __le16 action; 172 185 }; 173 186 174 187 struct cmd_ds_802_11_subscribe_event { 175 - u16 action; 176 - u16 events; 188 + __le16 action; 189 + __le16 events; 177 190 }; 178 191 179 192 /* ··· 192 205 }; 193 206 194 207 struct cmd_ds_802_11_scan_rsp { 195 - u16 bssdescriptsize; 208 + __le16 bssdescriptsize; 196 209 u8 nr_sets; 197 210 u8 bssdesc_and_tlvbuffer[1]; 198 211 }; 199 212 200 213 struct cmd_ds_802_11_get_log { 201 - u32 mcasttxframe; 202 - u32 failed; 203 - u32 retry; 204 - u32 multiretry; 205 - u32 framedup; 206 - u32 rtssuccess; 207 - u32 rtsfailure; 208 - u32 ackfailure; 209 - u32 rxfrag; 210 - u32 mcastrxframe; 211 - u32 fcserror; 212 - u32 txframe; 213 - u32 wepundecryptable; 214 + __le32 mcasttxframe; 215 + __le32 failed; 216 + __le32 retry; 217 + __le32 multiretry; 218 + __le32 framedup; 219 + __le32 rtssuccess; 220 + __le32 rtsfailure; 221 + __le32 ackfailure; 222 + __le32 rxfrag; 223 + __le32 mcastrxframe; 224 + __le32 fcserror; 225 + __le32 txframe; 226 + __le32 wepundecryptable; 214 227 }; 215 228 216 229 struct cmd_ds_mac_control { 217 - u16 action; 218 - u16 reserved; 230 + __le16 action; 231 + __le16 reserved; 219 232 }; 220 233 221 234 struct cmd_ds_mac_multicast_adr { 222 - u16 action; 223 - u16 nr_of_adrs; 235 + __le16 action; 236 + __le16 nr_of_adrs; 224 237 u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE]; 225 238 }; 226 239 ··· 232 245 233 246 struct cmd_ds_802_11_deauthenticate { 234 247 u8 macaddr[6]; 235 - u16 reasoncode; 248 + __le16 reasoncode; 236 249 }; 237 250 238 251 struct cmd_ds_802_11_associate { 239 252 u8 peerstaaddr[6]; 240 253 struct ieeetypes_capinfo capinfo; 241 - u16 listeninterval; 242 - u16 bcnperiod; 254 + __le16 listeninterval; 255 + __le16 bcnperiod; 243 256 u8 dtimperiod; 244 257 245 258 #if 0 ··· 252 265 253 266 struct cmd_ds_802_11_disassociate { 254 267 u8 destmacaddr[6]; 255 - u16 reasoncode; 268 + __le16 reasoncode; 256 269 }; 257 270 258 271 struct cmd_ds_802_11_associate_rsp { ··· 266 279 267 280 struct cmd_ds_802_11_set_wep { 268 281 /* ACT_ADD, ACT_REMOVE or ACT_ENABLE */ 269 - u16 action; 282 + __le16 action; 270 283 271 284 /* key Index selected for Tx */ 272 - u16 keyindex; 285 + __le16 keyindex; 273 286 274 287 /* 40, 128bit or TXWEP */ 275 288 u8 keytype[4]; ··· 277 290 }; 278 291 279 292 struct cmd_ds_802_3_get_stat { 280 - u32 xmitok; 281 - u32 rcvok; 282 - u32 xmiterror; 283 - u32 rcverror; 284 - u32 rcvnobuffer; 285 - u32 rcvcrcerror; 293 + __le32 xmitok; 294 + __le32 rcvok; 295 + __le32 xmiterror; 296 + __le32 rcverror; 297 + __le32 rcvnobuffer; 298 + __le32 rcvcrcerror; 286 299 }; 287 300 288 301 struct cmd_ds_802_11_get_stat { 289 - u32 txfragmentcnt; 290 - u32 mcasttxframecnt; 291 - u32 failedcnt; 292 - u32 retrycnt; 293 - u32 Multipleretrycnt; 294 - u32 rtssuccesscnt; 295 - u32 rtsfailurecnt; 296 - u32 ackfailurecnt; 297 - u32 frameduplicatecnt; 298 - u32 rxfragmentcnt; 299 - u32 mcastrxframecnt; 300 - u32 fcserrorcnt; 301 - u32 bcasttxframecnt; 302 - u32 bcastrxframecnt; 303 - u32 txbeacon; 304 - u32 rxbeacon; 305 - u32 wepundecryptable; 302 + __le32 txfragmentcnt; 303 + __le32 mcasttxframecnt; 304 + __le32 failedcnt; 305 + __le32 retrycnt; 306 + __le32 Multipleretrycnt; 307 + __le32 rtssuccesscnt; 308 + __le32 rtsfailurecnt; 309 + __le32 ackfailurecnt; 310 + __le32 frameduplicatecnt; 311 + __le32 rxfragmentcnt; 312 + __le32 mcastrxframecnt; 313 + __le32 fcserrorcnt; 314 + __le32 bcasttxframecnt; 315 + __le32 bcastrxframecnt; 316 + __le32 txbeacon; 317 + __le32 rxbeacon; 318 + __le32 wepundecryptable; 306 319 }; 307 320 308 321 struct cmd_ds_802_11_snmp_mib { 309 - u16 querytype; 310 - u16 oid; 311 - u16 bufsize; 322 + __le16 querytype; 323 + __le16 oid; 324 + __le16 bufsize; 312 325 u8 value[128]; 313 326 }; 314 327 315 328 struct cmd_ds_mac_reg_map { 316 - u16 buffersize; 329 + __le16 buffersize; 317 330 u8 regmap[128]; 318 - u16 reserved; 331 + __le16 reserved; 319 332 }; 320 333 321 334 struct cmd_ds_bbp_reg_map { 322 - u16 buffersize; 335 + __le16 buffersize; 323 336 u8 regmap[128]; 324 - u16 reserved; 337 + __le16 reserved; 325 338 }; 326 339 327 340 struct cmd_ds_rf_reg_map { 328 - u16 buffersize; 341 + __le16 buffersize; 329 342 u8 regmap[64]; 330 - u16 reserved; 343 + __le16 reserved; 331 344 }; 332 345 333 346 struct cmd_ds_mac_reg_access { 334 - u16 action; 335 - u16 offset; 336 - u32 value; 347 + __le16 action; 348 + __le16 offset; 349 + __le32 value; 337 350 }; 338 351 339 352 struct cmd_ds_bbp_reg_access { 340 - u16 action; 341 - u16 offset; 353 + __le16 action; 354 + __le16 offset; 342 355 u8 value; 343 356 u8 reserved[3]; 344 357 }; 345 358 346 359 struct cmd_ds_rf_reg_access { 347 - u16 action; 348 - u16 offset; 360 + __le16 action; 361 + __le16 offset; 349 362 u8 value; 350 363 u8 reserved[3]; 351 364 }; 352 365 353 366 struct cmd_ds_802_11_radio_control { 354 - u16 action; 355 - u16 control; 367 + __le16 action; 368 + __le16 control; 356 369 }; 357 370 358 371 struct cmd_ds_802_11_sleep_params { 359 372 /* ACT_GET/ACT_SET */ 360 - u16 action; 373 + __le16 action; 361 374 362 375 /* Sleep clock error in ppm */ 363 - u16 error; 376 + __le16 error; 364 377 365 378 /* Wakeup offset in usec */ 366 - u16 offset; 379 + __le16 offset; 367 380 368 381 /* Clock stabilization time in usec */ 369 - u16 stabletime; 382 + __le16 stabletime; 370 383 371 384 /* control periodic calibration */ 372 385 u8 calcontrol; ··· 375 388 u8 externalsleepclk; 376 389 377 390 /* reserved field, should be set to zero */ 378 - u16 reserved; 391 + __le16 reserved; 379 392 }; 380 393 381 394 struct cmd_ds_802_11_inactivity_timeout { 382 395 /* ACT_GET/ACT_SET */ 383 - u16 action; 396 + __le16 action; 384 397 385 398 /* Inactivity timeout in msec */ 386 - u16 timeout; 399 + __le16 timeout; 387 400 }; 388 401 389 402 struct cmd_ds_802_11_rf_channel { 390 - u16 action; 391 - u16 currentchannel; 392 - u16 rftype; 393 - u16 reserved; 403 + __le16 action; 404 + __le16 currentchannel; 405 + __le16 rftype; 406 + __le16 reserved; 394 407 u8 channellist[32]; 395 408 }; 396 409 397 410 struct cmd_ds_802_11_rssi { 398 411 /* weighting factor */ 399 - u16 N; 412 + __le16 N; 400 413 401 - u16 reserved_0; 402 - u16 reserved_1; 403 - u16 reserved_2; 414 + __le16 reserved_0; 415 + __le16 reserved_1; 416 + __le16 reserved_2; 404 417 }; 405 418 406 419 struct cmd_ds_802_11_rssi_rsp { 407 - u16 SNR; 408 - u16 noisefloor; 409 - u16 avgSNR; 410 - u16 avgnoisefloor; 420 + __le16 SNR; 421 + __le16 noisefloor; 422 + __le16 avgSNR; 423 + __le16 avgnoisefloor; 411 424 }; 412 425 413 426 struct cmd_ds_802_11_mac_address { 414 - u16 action; 427 + __le16 action; 415 428 u8 macadd[ETH_ALEN]; 416 429 }; 417 430 418 431 struct cmd_ds_802_11_rf_tx_power { 419 - u16 action; 420 - u16 currentlevel; 432 + __le16 action; 433 + __le16 currentlevel; 421 434 }; 422 435 423 436 struct cmd_ds_802_11_rf_antenna { 424 - u16 action; 437 + __le16 action; 425 438 426 439 /* Number of antennas or 0xffff(diversity) */ 427 - u16 antennamode; 440 + __le16 antennamode; 428 441 429 442 }; 430 443 431 444 struct cmd_ds_802_11_ps_mode { 432 - u16 action; 433 - u16 nullpktinterval; 434 - u16 multipledtim; 435 - u16 reserved; 436 - u16 locallisteninterval; 445 + __le16 action; 446 + __le16 nullpktinterval; 447 + __le16 multipledtim; 448 + __le16 reserved; 449 + __le16 locallisteninterval; 437 450 }; 438 451 439 452 struct PS_CMD_ConfirmSleep { 440 - u16 command; 441 - u16 size; 442 - u16 seqnum; 443 - u16 result; 453 + __le16 command; 454 + __le16 size; 455 + __le16 seqnum; 456 + __le16 result; 444 457 445 - u16 action; 446 - u16 reserved1; 447 - u16 multipledtim; 448 - u16 reserved; 449 - u16 locallisteninterval; 458 + __le16 action; 459 + __le16 reserved1; 460 + __le16 multipledtim; 461 + __le16 reserved; 462 + __le16 locallisteninterval; 450 463 }; 451 464 452 465 struct cmd_ds_802_11_data_rate { 453 - u16 action; 454 - u16 reserverd; 466 + __le16 action; 467 + __le16 reserverd; 455 468 u8 datarate[G_SUPPORTED_RATES]; 456 469 }; 457 470 458 471 struct cmd_ds_802_11_rate_adapt_rateset { 459 - u16 action; 460 - u16 enablehwauto; 461 - u16 bitmap; 472 + __le16 action; 473 + __le16 enablehwauto; 474 + __le16 bitmap; 462 475 }; 463 476 464 477 struct cmd_ds_802_11_ad_hoc_start { 465 478 u8 SSID[IW_ESSID_MAX_SIZE]; 466 479 u8 bsstype; 467 - u16 beaconperiod; 480 + __le16 beaconperiod; 468 481 u8 dtimperiod; 469 482 union IEEEtypes_ssparamset ssparamset; 470 483 union ieeetypes_phyparamset phyparamset; 471 - u16 probedelay; 484 + __le16 probedelay; 472 485 struct ieeetypes_capinfo cap; 473 486 u8 datarate[G_SUPPORTED_RATES]; 474 487 u8 tlv_memory_size_pad[100]; ··· 478 491 u8 BSSID[6]; 479 492 u8 SSID[32]; 480 493 u8 bsstype; 481 - u16 beaconperiod; 494 + __le16 beaconperiod; 482 495 u8 dtimperiod; 483 - u8 timestamp[8]; 484 - u8 localtime[8]; 496 + __le64 timestamp; 497 + __le64 localtime; 485 498 union ieeetypes_phyparamset phyparamset; 486 499 union IEEEtypes_ssparamset ssparamset; 487 500 struct ieeetypes_capinfo cap; ··· 495 508 496 509 struct cmd_ds_802_11_ad_hoc_join { 497 510 struct adhoc_bssdesc bssdescriptor; 498 - u16 failtimeout; 499 - u16 probedelay; 511 + __le16 failtimeout; 512 + __le16 probedelay; 500 513 501 514 } __attribute__ ((packed)); 502 515 503 516 struct cmd_ds_802_11_enable_rsn { 504 - u16 action; 505 - u16 enable; 517 + __le16 action; 518 + __le16 enable; 506 519 }; 507 520 508 521 struct MrvlIEtype_keyParamSet { 509 522 /* type ID */ 510 - u16 type; 523 + __le16 type; 511 524 512 525 /* length of Payload */ 513 - u16 length; 526 + __le16 length; 514 527 515 528 /* type of key: WEP=0, TKIP=1, AES=2 */ 516 - u16 keytypeid; 529 + __le16 keytypeid; 517 530 518 531 /* key control Info specific to a keytypeid */ 519 - u16 keyinfo; 532 + __le16 keyinfo; 520 533 521 534 /* length of key */ 522 - u16 keylen; 535 + __le16 keylen; 523 536 524 537 /* key material of size keylen */ 525 538 u8 key[32]; 526 539 }; 527 540 528 541 struct cmd_ds_802_11_key_material { 529 - u16 action; 542 + __le16 action; 530 543 struct MrvlIEtype_keyParamSet keyParamSet[2]; 531 544 } __attribute__ ((packed)); 532 545 533 546 struct cmd_ds_802_11_eeprom_access { 534 - u16 action; 547 + __le16 action; 535 548 536 549 /* multiple 4 */ 537 - u16 offset; 538 - u16 bytecount; 550 + __le16 offset; 551 + __le16 bytecount; 539 552 u8 value; 540 553 } __attribute__ ((packed)); 541 554 542 555 struct cmd_ds_802_11_tpc_cfg { 543 - u16 action; 556 + __le16 action; 544 557 u8 enable; 545 558 s8 P0; 546 559 s8 P1; ··· 549 562 } __attribute__ ((packed)); 550 563 551 564 struct cmd_ds_802_11_led_ctrl { 552 - u16 action; 553 - u16 numled; 565 + __le16 action; 566 + __le16 numled; 554 567 u8 data[256]; 555 568 } __attribute__ ((packed)); 556 569 557 570 struct cmd_ds_802_11_pwr_cfg { 558 - u16 action; 571 + __le16 action; 559 572 u8 enable; 560 573 s8 PA_P0; 561 574 s8 PA_P1; ··· 563 576 } __attribute__ ((packed)); 564 577 565 578 struct cmd_ds_802_11_afc { 566 - u16 afc_auto; 579 + __le16 afc_auto; 567 580 union { 568 581 struct { 569 - u16 threshold; 570 - u16 period; 582 + __le16 threshold; 583 + __le16 period; 571 584 }; 572 585 struct { 573 - s16 timing_offset; 574 - s16 carrier_offset; 586 + __le16 timing_offset; /* signed */ 587 + __le16 carrier_offset; /* signed */ 575 588 }; 576 589 }; 577 590 } __attribute__ ((packed)); 578 591 579 592 struct cmd_tx_rate_query { 580 - u16 txrate; 593 + __le16 txrate; 581 594 } __attribute__ ((packed)); 582 595 583 596 struct cmd_ds_get_tsf { ··· 585 598 } __attribute__ ((packed)); 586 599 587 600 struct cmd_ds_bt_access { 588 - u16 action; 589 - u32 id; 601 + __le16 action; 602 + __le32 id; 590 603 u8 addr1[ETH_ALEN]; 591 604 u8 addr2[ETH_ALEN]; 592 605 } __attribute__ ((packed)); 593 606 594 607 struct cmd_ds_fwt_access { 595 - u16 action; 596 - u32 id; 608 + __le16 action; 609 + __le32 id; 610 + u8 valid; 597 611 u8 da[ETH_ALEN]; 598 612 u8 dir; 599 613 u8 ra[ETH_ALEN]; 600 - u32 ssn; 601 - u32 dsn; 602 - u32 metric; 614 + __le32 ssn; 615 + __le32 dsn; 616 + __le32 metric; 617 + u8 rate; 603 618 u8 hopcount; 604 619 u8 ttl; 605 - u32 expiration; 620 + __le32 expiration; 606 621 u8 sleepmode; 607 - u32 snr; 608 - u32 references; 622 + __le32 snr; 623 + __le32 references; 624 + u8 prec[ETH_ALEN]; 609 625 } __attribute__ ((packed)); 610 626 611 - #define MESH_STATS_NUM 7 612 627 struct cmd_ds_mesh_access { 613 - u16 action; 614 - u32 data[MESH_STATS_NUM + 1]; /* last position reserved */ 628 + __le16 action; 629 + __le32 data[32]; /* last position reserved */ 615 630 } __attribute__ ((packed)); 631 + 632 + /* Number of stats counters returned by the firmware */ 633 + #define MESH_STATS_NUM 8 616 634 617 635 struct cmd_ds_command { 618 636 /* command header */ 619 - u16 command; 620 - u16 size; 621 - u16 seqnum; 622 - u16 result; 637 + __le16 command; 638 + __le16 size; 639 + __le16 seqnum; 640 + __le16 result; 623 641 624 642 /* command Body */ 625 643 union {
+4 -2
drivers/net/wireless/libertas/if_bootcmd.c
··· 8 8 #include <linux/netdevice.h> 9 9 #include <linux/usb.h> 10 10 11 + #define DRV_NAME "usb8xxx" 12 + 11 13 #include "defs.h" 12 14 #include "dev.h" 13 15 #include "if_usb.h" ··· 22 20 */ 23 21 int if_usb_issue_boot_command(wlan_private *priv, int ivalue) 24 22 { 25 - struct usb_card_rec *cardp = priv->wlan_dev.card; 23 + struct usb_card_rec *cardp = priv->card; 26 24 struct bootcmdstr sbootcmd; 27 25 int i; 28 26 29 27 /* Prepare command */ 30 - sbootcmd.u32magicnumber = BOOT_CMD_MAGIC_NUMBER; 28 + sbootcmd.u32magicnumber = cpu_to_le32(BOOT_CMD_MAGIC_NUMBER); 31 29 sbootcmd.u8cmd_tag = ivalue; 32 30 for (i=0; i<11; i++) 33 31 sbootcmd.au8dumy[i]=0x00;
+243 -207
drivers/net/wireless/libertas/if_usb.c
··· 2 2 * This file contains functions used in USB interface module. 3 3 */ 4 4 #include <linux/delay.h> 5 + #include <linux/moduleparam.h> 5 6 #include <linux/firmware.h> 6 7 #include <linux/netdevice.h> 8 + #include <linux/list.h> 7 9 #include <linux/usb.h> 8 10 11 + #define DRV_NAME "usb8xxx" 12 + 9 13 #include "host.h" 10 - #include "sbi.h" 11 14 #include "decl.h" 12 15 #include "defs.h" 13 16 #include "dev.h" ··· 19 16 #define MESSAGE_HEADER_LEN 4 20 17 21 18 static const char usbdriver_name[] = "usb8xxx"; 19 + static u8 *default_fw_name = "usb8388.bin"; 20 + 21 + char *libertas_fw_name = NULL; 22 + module_param_named(fw_name, libertas_fw_name, charp, 0644); 23 + 24 + /* 25 + * We need to send a RESET command to all USB devices before 26 + * we tear down the USB connection. Otherwise we would not 27 + * be able to re-init device the device if the module gets 28 + * loaded again. This is a list of all initialized USB devices, 29 + * for the reset code see if_usb_reset_device() 30 + */ 31 + static LIST_HEAD(usb_devices); 22 32 23 33 static struct usb_device_id if_usb_table[] = { 24 34 /* Enter the device signature inside */ 25 - { 26 - USB_DEVICE(USB8388_VID_1, USB8388_PID_1), 27 - }, 28 - { 29 - USB_DEVICE(USB8388_VID_2, USB8388_PID_2), 30 - }, 35 + { USB_DEVICE(0x1286, 0x2001) }, 36 + { USB_DEVICE(0x05a3, 0x8388) }, 31 37 {} /* Terminating entry */ 32 38 }; 33 39 ··· 44 32 45 33 static void if_usb_receive(struct urb *urb); 46 34 static void if_usb_receive_fwload(struct urb *urb); 35 + static int if_usb_reset_device(wlan_private *priv); 36 + static int if_usb_register_dev(wlan_private * priv); 37 + static int if_usb_unregister_dev(wlan_private *); 38 + static int if_usb_prog_firmware(wlan_private *); 39 + static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb); 40 + static int if_usb_get_int_status(wlan_private * priv, u8 *); 41 + static int if_usb_read_event_cause(wlan_private *); 47 42 48 43 /** 49 44 * @brief call back function to handle the status of the URB ··· 61 42 { 62 43 wlan_private *priv = (wlan_private *) (urb->context); 63 44 wlan_adapter *adapter = priv->adapter; 64 - struct net_device *dev = priv->wlan_dev.netdev; 45 + struct net_device *dev = priv->dev; 65 46 66 47 /* handle the transmission complete validations */ 67 48 68 49 if (urb->status != 0) { 69 50 /* print the failure status number for debug */ 70 - lbs_pr_info("URB in failure status\n"); 51 + lbs_pr_info("URB in failure status: %d\n", urb->status); 71 52 } else { 72 - lbs_dev_dbg(2, &urb->dev->dev, "URB status is successfull\n"); 73 - lbs_dev_dbg(2, &urb->dev->dev, "Actual length transmitted %d\n", 53 + /* 54 + lbs_deb_usbd(&urb->dev->dev, "URB status is successfull\n"); 55 + lbs_deb_usbd(&urb->dev->dev, "Actual length transmitted %d\n", 74 56 urb->actual_length); 75 - priv->wlan_dev.dnld_sent = DNLD_RES_RECEIVED; 57 + */ 58 + priv->dnld_sent = DNLD_RES_RECEIVED; 76 59 /* Wake main thread if commands are pending */ 77 60 if (!adapter->cur_cmd) 78 61 wake_up_interruptible(&priv->mainthread.waitq); 79 - if ((adapter->connect_status == libertas_connected)) 62 + if ((adapter->connect_status == libertas_connected)) { 80 63 netif_wake_queue(dev); 64 + netif_wake_queue(priv->mesh_dev); 65 + } 81 66 } 82 67 83 68 return; ··· 94 71 */ 95 72 void if_usb_free(struct usb_card_rec *cardp) 96 73 { 97 - ENTER(); 74 + lbs_deb_enter(LBS_DEB_USB); 98 75 99 76 /* Unlink tx & rx urb */ 100 77 usb_kill_urb(cardp->tx_urb); ··· 109 86 kfree(cardp->bulk_out_buffer); 110 87 cardp->bulk_out_buffer = NULL; 111 88 112 - LEAVE(); 113 - return; 89 + lbs_deb_leave(LBS_DEB_USB); 114 90 } 115 91 116 92 /** ··· 124 102 struct usb_device *udev; 125 103 struct usb_host_interface *iface_desc; 126 104 struct usb_endpoint_descriptor *endpoint; 127 - wlan_private *pwlanpriv; 128 - struct usb_card_rec *usb_cardp; 105 + wlan_private *priv; 106 + struct usb_card_rec *cardp; 129 107 int i; 130 108 131 109 udev = interface_to_usbdev(intf); 132 110 133 - usb_cardp = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL); 134 - if (!usb_cardp) { 111 + cardp = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL); 112 + if (!cardp) { 135 113 lbs_pr_err("Out of memory allocating private data.\n"); 136 114 goto error; 137 115 } 138 116 139 - usb_cardp->udev = udev; 117 + cardp->udev = udev; 140 118 iface_desc = intf->cur_altsetting; 141 119 142 - lbs_dev_dbg(1, &udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" 120 + lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" 143 121 " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X\n", 144 - udev->descriptor.bcdUSB, 145 - udev->descriptor.bDeviceClass, 146 - udev->descriptor.bDeviceSubClass, 147 - udev->descriptor.bDeviceProtocol); 122 + le16_to_cpu(udev->descriptor.bcdUSB), 123 + udev->descriptor.bDeviceClass, 124 + udev->descriptor.bDeviceSubClass, 125 + udev->descriptor.bDeviceProtocol); 148 126 149 127 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 150 128 endpoint = &iface_desc->endpoint[i].desc; ··· 152 130 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 153 131 USB_ENDPOINT_XFER_BULK)) { 154 132 /* we found a bulk in endpoint */ 155 - lbs_dev_dbg(1, &udev->dev, "Bulk in size is %d\n", 156 - endpoint->wMaxPacketSize); 157 - if (! 158 - (usb_cardp->rx_urb = 159 - usb_alloc_urb(0, GFP_KERNEL))) { 160 - lbs_dev_dbg(1, &udev->dev, 133 + lbs_deb_usbd(&udev->dev, "Bulk in size is %d\n", 134 + le16_to_cpu(endpoint->wMaxPacketSize)); 135 + if (!(cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL))) { 136 + lbs_deb_usbd(&udev->dev, 161 137 "Rx URB allocation failed\n"); 162 138 goto dealloc; 163 139 } 164 - usb_cardp->rx_urb_recall = 0; 140 + cardp->rx_urb_recall = 0; 165 141 166 - usb_cardp->bulk_in_size = 167 - endpoint->wMaxPacketSize; 168 - usb_cardp->bulk_in_endpointAddr = 142 + cardp->bulk_in_size = 143 + le16_to_cpu(endpoint->wMaxPacketSize); 144 + cardp->bulk_in_endpointAddr = 169 145 (endpoint-> 170 146 bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 171 - lbs_dev_dbg(1, &udev->dev, "in_endpoint = %d\n", 147 + lbs_deb_usbd(&udev->dev, "in_endpoint = %d\n", 172 148 endpoint->bEndpointAddress); 173 149 } 174 150 ··· 176 156 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 177 157 USB_ENDPOINT_XFER_BULK)) { 178 158 /* We found bulk out endpoint */ 179 - if (! 180 - (usb_cardp->tx_urb = 181 - usb_alloc_urb(0, GFP_KERNEL))) { 182 - lbs_dev_dbg(1,&udev->dev, 159 + if (!(cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL))) { 160 + lbs_deb_usbd(&udev->dev, 183 161 "Tx URB allocation failed\n"); 184 162 goto dealloc; 185 163 } 186 164 187 - usb_cardp->bulk_out_size = 188 - endpoint->wMaxPacketSize; 189 - lbs_dev_dbg(1, &udev->dev, 190 - "Bulk out size is %d\n", 191 - endpoint->wMaxPacketSize); 192 - usb_cardp->bulk_out_endpointAddr = 165 + cardp->bulk_out_size = 166 + le16_to_cpu(endpoint->wMaxPacketSize); 167 + lbs_deb_usbd(&udev->dev, 168 + "Bulk out size is %d\n", 169 + le16_to_cpu(endpoint->wMaxPacketSize)); 170 + cardp->bulk_out_endpointAddr = 193 171 endpoint->bEndpointAddress; 194 - lbs_dev_dbg(1, &udev->dev, "out_endpoint = %d\n", 172 + lbs_deb_usbd(&udev->dev, "out_endpoint = %d\n", 195 173 endpoint->bEndpointAddress); 196 - usb_cardp->bulk_out_buffer = 174 + cardp->bulk_out_buffer = 197 175 kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, 198 176 GFP_KERNEL); 199 177 200 - if (!usb_cardp->bulk_out_buffer) { 201 - lbs_dev_dbg(1, &udev->dev, 178 + if (!cardp->bulk_out_buffer) { 179 + lbs_deb_usbd(&udev->dev, 202 180 "Could not allocate buffer\n"); 203 181 goto dealloc; 204 182 } 205 183 } 206 184 } 207 185 208 - 209 - /* At this point wlan_add_card() will be called. Don't worry 210 - * about keeping pwlanpriv around since it will be set on our 211 - * usb device data in -> add() -> libertas_sbi_register_dev(). 212 - */ 213 - if (!(pwlanpriv = wlan_add_card(usb_cardp))) 186 + if (!(priv = libertas_add_card(cardp, &udev->dev))) 214 187 goto dealloc; 215 188 216 - usb_get_dev(udev); 217 - usb_set_intfdata(intf, usb_cardp); 189 + if (libertas_add_mesh(priv, &udev->dev)) 190 + goto err_add_mesh; 218 191 219 - /* 220 - * return card structure, which can be got back in the 221 - * diconnect function as the ptr 222 - * argument. 223 - */ 192 + priv->hw_register_dev = if_usb_register_dev; 193 + priv->hw_unregister_dev = if_usb_unregister_dev; 194 + priv->hw_prog_firmware = if_usb_prog_firmware; 195 + priv->hw_host_to_card = if_usb_host_to_card; 196 + priv->hw_get_int_status = if_usb_get_int_status; 197 + priv->hw_read_event_cause = if_usb_read_event_cause; 198 + 199 + if (libertas_activate_card(priv, libertas_fw_name)) 200 + goto err_activate_card; 201 + 202 + list_add_tail(&cardp->list, &usb_devices); 203 + 204 + usb_get_dev(udev); 205 + usb_set_intfdata(intf, cardp); 206 + 224 207 return 0; 225 208 209 + err_activate_card: 210 + libertas_remove_mesh(priv); 211 + err_add_mesh: 212 + free_netdev(priv->dev); 213 + kfree(priv->adapter); 226 214 dealloc: 227 - if_usb_free(usb_cardp); 215 + if_usb_free(cardp); 228 216 229 217 error: 230 218 return -ENOMEM; ··· 240 212 241 213 /** 242 214 * @brief free resource and cleanup 243 - * @param udev pointer to usb_device 244 - * @param ptr pointer to usb_cardp 215 + * @param intf USB interface structure 245 216 * @return N/A 246 217 */ 247 218 static void if_usb_disconnect(struct usb_interface *intf) ··· 256 229 */ 257 230 adapter->surpriseremoved = 1; 258 231 232 + list_del(&cardp->list); 233 + 259 234 /* card is removed and we can call wlan_remove_card */ 260 - lbs_dev_dbg(1, &cardp->udev->dev, "call remove card\n"); 261 - wlan_remove_card(cardp); 235 + lbs_deb_usbd(&cardp->udev->dev, "call remove card\n"); 236 + libertas_remove_mesh(priv); 237 + libertas_remove_card(priv); 262 238 263 239 /* Unlink and free urb */ 264 240 if_usb_free(cardp); ··· 279 249 */ 280 250 static int if_prog_firmware(wlan_private * priv) 281 251 { 282 - struct usb_card_rec *cardp = priv->wlan_dev.card; 252 + struct usb_card_rec *cardp = priv->card; 283 253 struct FWData *fwdata; 284 254 struct fwheader *fwheader; 285 255 u8 *firmware = priv->firmware->data; ··· 296 266 cardp->fwseqnum = cardp->lastseqnum - 1; 297 267 } 298 268 299 - lbs_dev_dbg(2, &cardp->udev->dev, "totalbytes = %d\n", 269 + /* 270 + lbs_deb_usbd(&cardp->udev->dev, "totalbytes = %d\n", 300 271 cardp->totalbytes); 272 + */ 301 273 302 274 memcpy(fwheader, &firmware[cardp->totalbytes], 303 275 sizeof(struct fwheader)); ··· 307 275 cardp->fwlastblksent = cardp->totalbytes; 308 276 cardp->totalbytes += sizeof(struct fwheader); 309 277 310 - lbs_dev_dbg(2, &cardp->udev->dev,"Copy Data\n"); 278 + /* lbs_deb_usbd(&cardp->udev->dev,"Copy Data\n"); */ 311 279 memcpy(fwdata->data, &firmware[cardp->totalbytes], 312 - fwdata->fwheader.datalength); 280 + le32_to_cpu(fwdata->fwheader.datalength)); 313 281 314 - lbs_dev_dbg(2, &cardp->udev->dev, 315 - "Data length = %d\n", fwdata->fwheader.datalength); 282 + /* 283 + lbs_deb_usbd(&cardp->udev->dev, 284 + "Data length = %d\n", le32_to_cpu(fwdata->fwheader.datalength)); 285 + */ 316 286 317 287 cardp->fwseqnum = cardp->fwseqnum + 1; 318 288 319 - fwdata->seqnum = cardp->fwseqnum; 320 - cardp->lastseqnum = fwdata->seqnum; 321 - cardp->totalbytes += fwdata->fwheader.datalength; 289 + fwdata->seqnum = cpu_to_le32(cardp->fwseqnum); 290 + cardp->lastseqnum = cardp->fwseqnum; 291 + cardp->totalbytes += le32_to_cpu(fwdata->fwheader.datalength); 322 292 323 - if (fwheader->dnldcmd == FW_HAS_DATA_TO_RECV) { 324 - lbs_dev_dbg(2, &cardp->udev->dev, "There is data to follow\n"); 325 - lbs_dev_dbg(2, &cardp->udev->dev, 293 + if (fwheader->dnldcmd == cpu_to_le32(FW_HAS_DATA_TO_RECV)) { 294 + /* 295 + lbs_deb_usbd(&cardp->udev->dev, "There are data to follow\n"); 296 + lbs_deb_usbd(&cardp->udev->dev, 326 297 "seqnum = %d totalbytes = %d\n", cardp->fwseqnum, 327 298 cardp->totalbytes); 299 + */ 328 300 memcpy(cardp->bulk_out_buffer, fwheader, FW_DATA_XMIT_SIZE); 329 301 usb_tx_block(priv, cardp->bulk_out_buffer, FW_DATA_XMIT_SIZE); 330 302 331 - } else if (fwdata->fwheader.dnldcmd == FW_HAS_LAST_BLOCK) { 332 - lbs_dev_dbg(2, &cardp->udev->dev, 303 + } else if (fwdata->fwheader.dnldcmd == cpu_to_le32(FW_HAS_LAST_BLOCK)) { 304 + /* 305 + lbs_deb_usbd(&cardp->udev->dev, 333 306 "Host has finished FW downloading\n"); 334 - lbs_dev_dbg(2, &cardp->udev->dev, 307 + lbs_deb_usbd(&cardp->udev->dev, 335 308 "Donwloading FW JUMP BLOCK\n"); 309 + */ 336 310 memcpy(cardp->bulk_out_buffer, fwheader, FW_DATA_XMIT_SIZE); 337 311 usb_tx_block(priv, cardp->bulk_out_buffer, FW_DATA_XMIT_SIZE); 338 312 cardp->fwfinalblk = 1; 339 313 } 340 314 341 - lbs_dev_dbg(2, &cardp->udev->dev, 315 + /* 316 + lbs_deb_usbd(&cardp->udev->dev, 342 317 "The firmware download is done size is %d\n", 343 318 cardp->totalbytes); 319 + */ 344 320 345 321 kfree(fwdata); 346 322 ··· 358 318 static int libertas_do_reset(wlan_private *priv) 359 319 { 360 320 int ret; 361 - struct usb_card_rec *cardp = priv->wlan_dev.card; 321 + struct usb_card_rec *cardp = priv->card; 322 + 323 + lbs_deb_enter(LBS_DEB_USB); 362 324 363 325 ret = usb_reset_device(cardp->udev); 364 326 if (!ret) { 365 327 msleep(10); 366 - reset_device(priv); 328 + if_usb_reset_device(priv); 367 329 msleep(10); 368 330 } 331 + 332 + lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); 333 + 369 334 return ret; 370 335 } 371 336 ··· 384 339 int usb_tx_block(wlan_private * priv, u8 * payload, u16 nb) 385 340 { 386 341 /* pointer to card structure */ 387 - struct usb_card_rec *cardp = priv->wlan_dev.card; 342 + struct usb_card_rec *cardp = priv->card; 388 343 int ret = -1; 389 344 390 345 /* check if device is removed */ 391 346 if (priv->adapter->surpriseremoved) { 392 - lbs_dev_dbg(1, &cardp->udev->dev, "Device removed\n"); 347 + lbs_deb_usbd(&cardp->udev->dev, "Device removed\n"); 393 348 goto tx_ret; 394 349 } 395 350 ··· 402 357 403 358 if ((ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC))) { 404 359 /* transfer failed */ 405 - lbs_dev_dbg(1, &cardp->udev->dev, "usb_submit_urb failed\n"); 360 + lbs_deb_usbd(&cardp->udev->dev, "usb_submit_urb failed\n"); 406 361 ret = -1; 407 362 } else { 408 - lbs_dev_dbg(2, &cardp->udev->dev, "usb_submit_urb success\n"); 363 + /* lbs_deb_usbd(&cardp->udev->dev, "usb_submit_urb success\n"); */ 409 364 ret = 0; 410 365 } 411 366 ··· 417 372 void (*callbackfn) 418 373 (struct urb *urb)) 419 374 { 420 - struct usb_card_rec *cardp = priv->wlan_dev.card; 375 + struct usb_card_rec *cardp = priv->card; 421 376 struct sk_buff *skb; 422 377 struct read_cb_info *rinfo = &cardp->rinfo; 423 378 int ret = -1; ··· 439 394 440 395 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; 441 396 442 - lbs_dev_dbg(2, &cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb); 397 + /* lbs_deb_usbd(&cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb); */ 443 398 if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) { 444 399 /* handle failure conditions */ 445 - lbs_dev_dbg(1, &cardp->udev->dev, "Submit Rx URB failed\n"); 400 + lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB failed\n"); 446 401 ret = -1; 447 402 } else { 448 - lbs_dev_dbg(2, &cardp->udev->dev, "Submit Rx URB success\n"); 403 + /* lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB success\n"); */ 449 404 ret = 0; 450 405 } 451 406 ··· 468 423 struct read_cb_info *rinfo = (struct read_cb_info *)urb->context; 469 424 wlan_private *priv = rinfo->priv; 470 425 struct sk_buff *skb = rinfo->skb; 471 - struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card; 426 + struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card; 472 427 struct fwsyncheader *syncfwheader; 473 428 struct bootcmdrespStr bootcmdresp; 474 429 475 430 if (urb->status) { 476 - lbs_dev_dbg(1, &cardp->udev->dev, 431 + lbs_deb_usbd(&cardp->udev->dev, 477 432 "URB status is failed during fw load\n"); 478 433 kfree_skb(skb); 479 434 return; ··· 482 437 if (cardp->bootcmdresp == 0) { 483 438 memcpy (&bootcmdresp, skb->data + IPFIELD_ALIGN_OFFSET, 484 439 sizeof(bootcmdresp)); 485 - if (cardp->udev->descriptor.bcdDevice < 0x3106) { 440 + if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) { 486 441 kfree_skb(skb); 487 442 if_usb_submit_rx_urb_fwload(priv); 488 443 cardp->bootcmdresp = 1; 489 - lbs_dev_dbg(1, &cardp->udev->dev, 444 + lbs_deb_usbd(&cardp->udev->dev, 490 445 "Received valid boot command response\n"); 491 446 return; 492 447 } 493 - if (bootcmdresp.u32magicnumber != BOOT_CMD_MAGIC_NUMBER) { 448 + if (bootcmdresp.u32magicnumber != cpu_to_le32(BOOT_CMD_MAGIC_NUMBER)) { 494 449 lbs_pr_info( 495 450 "boot cmd response wrong magic number (0x%x)\n", 496 - bootcmdresp.u32magicnumber); 451 + le32_to_cpu(bootcmdresp.u32magicnumber)); 497 452 } else if (bootcmdresp.u8cmd_tag != BOOT_CMD_FW_BY_USB) { 498 453 lbs_pr_info( 499 454 "boot cmd response cmd_tag error (%d)\n", ··· 504 459 bootcmdresp.u8result); 505 460 } else { 506 461 cardp->bootcmdresp = 1; 507 - lbs_dev_dbg(1, &cardp->udev->dev, 462 + lbs_deb_usbd(&cardp->udev->dev, 508 463 "Received valid boot command response\n"); 509 464 } 510 465 kfree_skb(skb); ··· 514 469 515 470 syncfwheader = kmalloc(sizeof(struct fwsyncheader), GFP_ATOMIC); 516 471 if (!syncfwheader) { 517 - lbs_dev_dbg(1, &cardp->udev->dev, "Failure to allocate syncfwheader\n"); 472 + lbs_deb_usbd(&cardp->udev->dev, "Failure to allocate syncfwheader\n"); 518 473 kfree_skb(skb); 519 474 return; 520 475 } ··· 523 478 sizeof(struct fwsyncheader)); 524 479 525 480 if (!syncfwheader->cmd) { 526 - lbs_dev_dbg(2, &cardp->udev->dev, 481 + /* 482 + lbs_deb_usbd(&cardp->udev->dev, 527 483 "FW received Blk with correct CRC\n"); 528 - lbs_dev_dbg(2, &cardp->udev->dev, 484 + lbs_deb_usbd(&cardp->udev->dev, 529 485 "FW received Blk seqnum = %d\n", 530 486 syncfwheader->seqnum); 487 + */ 531 488 cardp->CRC_OK = 1; 532 489 } else { 533 - lbs_dev_dbg(1, &cardp->udev->dev, 490 + lbs_deb_usbd(&cardp->udev->dev, 534 491 "FW received Blk with CRC error\n"); 535 492 cardp->CRC_OK = 0; 536 493 } ··· 562 515 { 563 516 if (recvlength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + 564 517 MESSAGE_HEADER_LEN || recvlength < MRVDRV_MIN_PKT_LEN) { 565 - lbs_dev_dbg(1, &cardp->udev->dev, 518 + lbs_deb_usbd(&cardp->udev->dev, 566 519 "Packet length is Invalid\n"); 567 520 kfree_skb(skb); 568 521 return; ··· 572 525 skb_put(skb, recvlength); 573 526 skb_pull(skb, MESSAGE_HEADER_LEN); 574 527 libertas_process_rxed_packet(priv, skb); 575 - priv->wlan_dev.upld_len = (recvlength - MESSAGE_HEADER_LEN); 528 + priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); 576 529 } 577 530 578 531 static inline void process_cmdrequest(int recvlength, u8 *recvbuff, ··· 582 535 { 583 536 u8 *cmdbuf; 584 537 if (recvlength > MRVDRV_SIZE_OF_CMD_BUFFER) { 585 - lbs_dev_dbg(1, &cardp->udev->dev, 538 + lbs_deb_usbd(&cardp->udev->dev, 586 539 "The receive buffer is too large\n"); 587 540 kfree_skb(skb); 588 541 return; ··· 595 548 /* take care of cur_cmd = NULL case by reading the 596 549 * data to clear the interrupt */ 597 550 if (!priv->adapter->cur_cmd) { 598 - cmdbuf = priv->wlan_dev.upld_buf; 551 + cmdbuf = priv->upld_buf; 599 552 priv->adapter->hisregcpy &= ~his_cmdupldrdy; 600 553 } else 601 554 cmdbuf = priv->adapter->cur_cmd->bufvirtualaddr; 602 555 603 556 cardp->usb_int_cause |= his_cmdupldrdy; 604 - priv->wlan_dev.upld_len = (recvlength - MESSAGE_HEADER_LEN); 557 + priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); 605 558 memcpy(cmdbuf, recvbuff + MESSAGE_HEADER_LEN, 606 - priv->wlan_dev.upld_len); 559 + priv->upld_len); 607 560 608 561 kfree_skb(skb); 609 - libertas_interrupt(priv->wlan_dev.netdev); 562 + libertas_interrupt(priv->dev); 610 563 spin_unlock(&priv->adapter->driver_lock); 611 564 612 - lbs_dev_dbg(1, &cardp->udev->dev, 565 + lbs_deb_usbd(&cardp->udev->dev, 613 566 "Wake up main thread to handle cmd response\n"); 614 567 615 568 return; ··· 627 580 struct read_cb_info *rinfo = (struct read_cb_info *)urb->context; 628 581 wlan_private *priv = rinfo->priv; 629 582 struct sk_buff *skb = rinfo->skb; 630 - struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card; 583 + struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card; 631 584 632 585 int recvlength = urb->actual_length; 633 586 u8 *recvbuff = NULL; 634 587 u32 recvtype; 635 588 636 - ENTER(); 589 + lbs_deb_enter(LBS_DEB_USB); 637 590 638 591 if (recvlength) { 639 592 if (urb->status) { 640 - lbs_dev_dbg(1, &cardp->udev->dev, 593 + lbs_deb_usbd(&cardp->udev->dev, 641 594 "URB status is failed\n"); 642 595 kfree_skb(skb); 643 596 goto setup_for_next; ··· 645 598 646 599 recvbuff = skb->data + IPFIELD_ALIGN_OFFSET; 647 600 memcpy(&recvtype, recvbuff, sizeof(u32)); 648 - lbs_dev_dbg(1, &cardp->udev->dev, 601 + lbs_deb_usbd(&cardp->udev->dev, 649 602 "Recv length = 0x%x\n", recvlength); 650 - lbs_dev_dbg(1, &cardp->udev->dev, 603 + lbs_deb_usbd(&cardp->udev->dev, 651 604 "Receive type = 0x%X\n", recvtype); 652 605 recvtype = le32_to_cpu(recvtype); 653 - lbs_dev_dbg(1, &cardp->udev->dev, 606 + lbs_deb_usbd(&cardp->udev->dev, 654 607 "Receive type after = 0x%X\n", recvtype); 655 608 } else if (urb->status) 656 609 goto rx_exit; ··· 668 621 case CMD_TYPE_INDICATION: 669 622 /* Event cause handling */ 670 623 spin_lock(&priv->adapter->driver_lock); 671 - cardp->usb_event_cause = *(u32 *) (recvbuff + MESSAGE_HEADER_LEN); 672 - lbs_dev_dbg(1, &cardp->udev->dev,"**EVENT** 0x%X\n", 624 + cardp->usb_event_cause = le32_to_cpu(*(__le32 *) (recvbuff + MESSAGE_HEADER_LEN)); 625 + lbs_deb_usbd(&cardp->udev->dev,"**EVENT** 0x%X\n", 673 626 cardp->usb_event_cause); 674 627 if (cardp->usb_event_cause & 0xffff0000) { 675 628 libertas_send_tx_feedback(priv); 676 629 spin_unlock(&priv->adapter->driver_lock); 677 630 break; 678 631 } 679 - cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; 632 + cardp->usb_event_cause <<= 3; 680 633 cardp->usb_int_cause |= his_cardevent; 681 634 kfree_skb(skb); 682 - libertas_interrupt(priv->wlan_dev.netdev); 635 + libertas_interrupt(priv->dev); 683 636 spin_unlock(&priv->adapter->driver_lock); 684 637 goto rx_exit; 685 638 default: ··· 690 643 setup_for_next: 691 644 if_usb_submit_rx_urb(priv); 692 645 rx_exit: 693 - LEAVE(); 694 - return; 646 + lbs_deb_leave(LBS_DEB_USB); 695 647 } 696 648 697 649 /** ··· 701 655 * @param len number of bytes 702 656 * @return 0 or -1 703 657 */ 704 - int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb) 658 + static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb) 705 659 { 706 660 int ret = -1; 707 661 u32 tmp; 708 - struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card; 662 + struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card; 709 663 710 - lbs_dev_dbg(1, &cardp->udev->dev,"*** type = %u\n", type); 711 - lbs_dev_dbg(1, &cardp->udev->dev,"size after = %d\n", nb); 664 + lbs_deb_usbd(&cardp->udev->dev,"*** type = %u\n", type); 665 + lbs_deb_usbd(&cardp->udev->dev,"size after = %d\n", nb); 712 666 713 667 if (type == MVMS_CMD) { 714 668 tmp = cpu_to_le32(CMD_TYPE_REQUEST); 715 - priv->wlan_dev.dnld_sent = DNLD_CMD_SENT; 669 + priv->dnld_sent = DNLD_CMD_SENT; 716 670 memcpy(cardp->bulk_out_buffer, (u8 *) & tmp, 717 671 MESSAGE_HEADER_LEN); 718 672 719 673 } else { 720 674 tmp = cpu_to_le32(CMD_TYPE_DATA); 721 - priv->wlan_dev.dnld_sent = DNLD_DATA_SENT; 675 + priv->dnld_sent = DNLD_DATA_SENT; 722 676 memcpy(cardp->bulk_out_buffer, (u8 *) & tmp, 723 677 MESSAGE_HEADER_LEN); 724 678 } ··· 732 686 } 733 687 734 688 /* called with adapter->driver_lock held */ 735 - int libertas_sbi_get_int_status(wlan_private * priv, u8 * ireg) 689 + static int if_usb_get_int_status(wlan_private * priv, u8 * ireg) 736 690 { 737 - struct usb_card_rec *cardp = priv->wlan_dev.card; 691 + struct usb_card_rec *cardp = priv->card; 738 692 739 693 *ireg = cardp->usb_int_cause; 740 694 cardp->usb_int_cause = 0; 741 695 742 - lbs_dev_dbg(1, &cardp->udev->dev,"Int cause is 0x%X\n", *ireg); 696 + lbs_deb_usbd(&cardp->udev->dev,"Int cause is 0x%X\n", *ireg); 743 697 744 698 return 0; 745 699 } 746 700 747 - int libertas_sbi_read_event_cause(wlan_private * priv) 701 + static int if_usb_read_event_cause(wlan_private * priv) 748 702 { 749 - struct usb_card_rec *cardp = priv->wlan_dev.card; 703 + struct usb_card_rec *cardp = priv->card; 750 704 priv->adapter->eventcause = cardp->usb_event_cause; 751 705 /* Re-submit rx urb here to avoid event lost issue */ 752 706 if_usb_submit_rx_urb(priv); 753 707 return 0; 754 708 } 755 709 756 - int reset_device(wlan_private *priv) 710 + static int if_usb_reset_device(wlan_private *priv) 757 711 { 758 712 int ret; 759 713 714 + lbs_deb_enter(LBS_DEB_USB); 760 715 ret = libertas_prepare_and_send_command(priv, cmd_802_11_reset, 761 716 cmd_act_halt, 0, 0, NULL); 762 717 msleep_interruptible(10); 763 718 719 + lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); 764 720 return ret; 765 721 } 766 722 767 - int libertas_sbi_unregister_dev(wlan_private * priv) 723 + static int if_usb_unregister_dev(wlan_private * priv) 768 724 { 769 725 int ret = 0; 770 726 ··· 775 727 * again. 776 728 */ 777 729 if (priv) 778 - reset_device(priv); 730 + if_usb_reset_device(priv); 779 731 780 732 return ret; 781 733 } ··· 786 738 * @param priv pointer to wlan_private 787 739 * @return 0 or -1 788 740 */ 789 - int libertas_sbi_register_dev(wlan_private * priv) 741 + static int if_usb_register_dev(wlan_private * priv) 790 742 { 743 + struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card; 791 744 792 - struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card; 793 - ENTER(); 745 + lbs_deb_enter(LBS_DEB_USB); 794 746 795 747 cardp->priv = priv; 796 - cardp->eth_dev = priv->wlan_dev.netdev; 748 + cardp->eth_dev = priv->dev; 797 749 priv->hotplug_device = &(cardp->udev->dev); 798 750 799 - SET_NETDEV_DEV(cardp->eth_dev, &(cardp->udev->dev)); 800 - 801 - lbs_dev_dbg(1, &cardp->udev->dev, "udev pointer is at %p\n", 751 + lbs_deb_usbd(&cardp->udev->dev, "udev pointer is at %p\n", 802 752 cardp->udev); 803 753 804 - LEAVE(); 754 + lbs_deb_leave(LBS_DEB_USB); 805 755 return 0; 806 756 } 807 757 808 758 809 759 810 - int libertas_sbi_prog_firmware(wlan_private * priv) 760 + static int if_usb_prog_firmware(wlan_private * priv) 811 761 { 812 - struct usb_card_rec *cardp = priv->wlan_dev.card; 762 + struct usb_card_rec *cardp = priv->card; 813 763 int i = 0; 814 764 static int reset_count = 10; 765 + int ret = 0; 815 766 816 - ENTER(); 767 + lbs_deb_enter(LBS_DEB_USB); 817 768 818 769 cardp->rinfo.priv = priv; 819 770 820 771 restart: 821 772 if (if_usb_submit_rx_urb_fwload(priv) < 0) { 822 - lbs_dev_dbg(1, &cardp->udev->dev, "URB submission is failed\n"); 823 - LEAVE(); 824 - return -1; 773 + lbs_deb_usbd(&cardp->udev->dev, "URB submission is failed\n"); 774 + ret = -1; 775 + goto done; 825 776 } 826 777 827 778 cardp->bootcmdresp = 0; ··· 858 811 if_prog_firmware(priv); 859 812 860 813 do { 861 - lbs_dev_dbg(1, &cardp->udev->dev,"Wlan sched timeout\n"); 814 + lbs_deb_usbd(&cardp->udev->dev,"Wlan sched timeout\n"); 862 815 i++; 863 816 msleep_interruptible(100); 864 817 if (priv->adapter->surpriseremoved || i >= 20) ··· 873 826 } 874 827 875 828 lbs_pr_info("FW download failure, time = %d ms\n", i * 100); 876 - LEAVE(); 877 - return -1; 829 + ret = -1; 830 + goto done; 878 831 } 879 832 880 833 if_usb_submit_rx_urb(priv); ··· 884 837 885 838 priv->adapter->fw_ready = 1; 886 839 887 - LEAVE(); 888 - return 0; 840 + done: 841 + lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); 842 + return ret; 889 843 } 890 - 891 - /** 892 - * @brief Given a usb_card_rec return its wlan_private 893 - * @param card pointer to a usb_card_rec 894 - * @return pointer to wlan_private 895 - */ 896 - wlan_private *libertas_sbi_get_priv(void *card) 897 - { 898 - struct usb_card_rec *cardp = card; 899 - return cardp->priv; 900 - } 901 - 902 - #ifdef ENABLE_PM 903 - int libertas_sbi_suspend(wlan_private * priv) 904 - { 905 - return 0; 906 - } 907 - 908 - int libertas_sbi_resume(wlan_private * priv) 909 - { 910 - return 0; 911 - } 912 - #endif 913 844 914 845 #ifdef CONFIG_PM 915 846 static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) ··· 895 870 struct usb_card_rec *cardp = usb_get_intfdata(intf); 896 871 wlan_private *priv = cardp->priv; 897 872 898 - ENTER(); 873 + lbs_deb_enter(LBS_DEB_USB); 899 874 900 875 if (priv->adapter->psstate != PS_STATE_FULL_POWER) 901 876 return -1; 902 877 903 878 netif_device_detach(cardp->eth_dev); 879 + netif_device_detach(priv->mesh_dev); 904 880 905 881 /* Unlink tx & rx urb */ 906 882 usb_kill_urb(cardp->tx_urb); ··· 909 883 910 884 cardp->rx_urb_recall = 1; 911 885 912 - LEAVE(); 886 + lbs_deb_leave(LBS_DEB_USB); 913 887 return 0; 914 888 } 915 889 916 890 static int if_usb_resume(struct usb_interface *intf) 917 891 { 918 892 struct usb_card_rec *cardp = usb_get_intfdata(intf); 893 + wlan_private *priv = cardp->priv; 919 894 920 - ENTER(); 895 + lbs_deb_enter(LBS_DEB_USB); 921 896 922 897 cardp->rx_urb_recall = 0; 923 898 924 899 if_usb_submit_rx_urb(cardp->priv); 925 900 926 901 netif_device_attach(cardp->eth_dev); 902 + netif_device_attach(priv->mesh_dev); 927 903 928 - LEAVE(); 904 + lbs_deb_leave(LBS_DEB_USB); 929 905 return 0; 930 906 } 931 907 #else ··· 948 920 .resume = if_usb_resume, 949 921 }; 950 922 951 - /** 952 - * @brief This function registers driver. 953 - * @param add pointer to add_card callback function 954 - * @param remove pointer to remove card callback function 955 - * @param arg pointer to call back function parameter 956 - * @return dummy success variable 957 - */ 958 - int libertas_sbi_register(void) 923 + static int if_usb_init_module(void) 959 924 { 960 - /* 961 - * API registers the Marvell USB driver 962 - * to the USB system 963 - */ 964 - usb_register(&if_usb_driver); 925 + int ret = 0; 965 926 966 - /* Return success to wlan layer */ 967 - return 0; 927 + lbs_deb_enter(LBS_DEB_MAIN); 928 + 929 + if (libertas_fw_name == NULL) { 930 + libertas_fw_name = default_fw_name; 931 + } 932 + 933 + ret = usb_register(&if_usb_driver); 934 + 935 + lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); 936 + return ret; 968 937 } 969 938 970 - /** 971 - * @brief This function removes usb driver. 972 - * @return N/A 973 - */ 974 - void libertas_sbi_unregister(void) 939 + static void if_usb_exit_module(void) 975 940 { 941 + struct usb_card_rec *cardp, *cardp_temp; 942 + 943 + lbs_deb_enter(LBS_DEB_MAIN); 944 + 945 + list_for_each_entry_safe(cardp, cardp_temp, &usb_devices, list) 946 + if_usb_reset_device((wlan_private *) cardp->priv); 947 + 976 948 /* API unregisters the driver from USB subsystem */ 977 949 usb_deregister(&if_usb_driver); 978 - return; 950 + 951 + lbs_deb_leave(LBS_DEB_MAIN); 979 952 } 953 + 954 + module_init(if_usb_init_module); 955 + module_exit(if_usb_exit_module); 956 + 957 + MODULE_DESCRIPTION("8388 USB WLAN Driver"); 958 + MODULE_AUTHOR("Marvell International Ltd."); 959 + MODULE_LICENSE("GPL");
+17 -15
drivers/net/wireless/libertas/if_usb.h
··· 1 + #ifndef _LIBERTAS_IF_USB_H 2 + #define _LIBERTAS_IF_USB_H 3 + 4 + #include <linux/list.h> 5 + 1 6 /** 2 7 * This file contains definition for USB interface. 3 8 */ ··· 12 7 13 8 #define IPFIELD_ALIGN_OFFSET 2 14 9 15 - #define USB8388_VID_1 0x1286 16 - #define USB8388_PID_1 0x2001 17 - #define USB8388_VID_2 0x05a3 18 - #define USB8388_PID_2 0x8388 19 - 20 10 #define BOOT_CMD_FW_BY_USB 0x01 21 11 #define BOOT_CMD_FW_IN_EEPROM 0x02 22 12 #define BOOT_CMD_UPDATE_BOOT2 0x03 ··· 20 20 21 21 struct bootcmdstr 22 22 { 23 - u32 u32magicnumber; 23 + __le32 u32magicnumber; 24 24 u8 u8cmd_tag; 25 25 u8 au8dumy[11]; 26 26 }; ··· 30 30 31 31 struct bootcmdrespStr 32 32 { 33 - u32 u32magicnumber; 33 + __le32 u32magicnumber; 34 34 u8 u8cmd_tag; 35 35 u8 u8result; 36 36 u8 au8dumy[2]; ··· 44 44 45 45 /** USB card description structure*/ 46 46 struct usb_card_rec { 47 + struct list_head list; 47 48 struct net_device *eth_dev; 48 49 struct usb_device *udev; 49 50 struct urb *rx_urb, *tx_urb; ··· 76 75 77 76 /** fwheader */ 78 77 struct fwheader { 79 - u32 dnldcmd; 80 - u32 baseaddr; 81 - u32 datalength; 82 - u32 CRC; 78 + __le32 dnldcmd; 79 + __le32 baseaddr; 80 + __le32 datalength; 81 + __le32 CRC; 83 82 }; 84 83 85 84 #define FW_MAX_DATA_BLK_SIZE 600 86 85 /** FWData */ 87 86 struct FWData { 88 87 struct fwheader fwheader; 89 - u32 seqnum; 88 + __le32 seqnum; 90 89 u8 data[FW_MAX_DATA_BLK_SIZE]; 91 90 }; 92 91 93 92 /** fwsyncheader */ 94 93 struct fwsyncheader { 95 - u32 cmd; 96 - u32 seqnum; 94 + __le32 cmd; 95 + __le32 seqnum; 97 96 }; 98 97 99 98 #define FW_HAS_DATA_TO_RECV 0x00000001 100 99 #define FW_HAS_LAST_BLOCK 0x00000004 101 100 102 101 #define FW_DATA_XMIT_SIZE \ 103 - sizeof(struct fwheader) + fwdata->fwheader.datalength + sizeof(u32) 102 + sizeof(struct fwheader) + le32_to_cpu(fwdata->fwheader.datalength) + sizeof(u32) 104 103 105 104 int usb_tx_block(wlan_private *priv, u8 *payload, u16 nb); 106 105 void if_usb_free(struct usb_card_rec *cardp); 107 106 int if_usb_issue_boot_command(wlan_private *priv, int ivalue); 108 107 108 + #endif
+188 -98
drivers/net/wireless/libertas/ioctl.c
··· 30 30 static int wlan_set_region(wlan_private * priv, u16 region_code) 31 31 { 32 32 int i; 33 + int ret = 0; 33 34 34 35 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { 35 36 // use the region code to search for the index ··· 43 42 44 43 // if it's unidentified region code 45 44 if (i >= MRVDRV_MAX_REGION_CODE) { 46 - lbs_pr_debug(1, "region Code not identified\n"); 47 - LEAVE(); 48 - return -1; 45 + lbs_deb_ioctl("region Code not identified\n"); 46 + ret = -1; 47 + goto done; 49 48 } 50 49 51 50 if (libertas_set_regiontable(priv, priv->adapter->regioncode, 0)) { 52 - LEAVE(); 53 - return -EINVAL; 51 + ret = -EINVAL; 54 52 } 55 53 56 - return 0; 54 + done: 55 + lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret); 56 + return ret; 57 57 } 58 58 59 59 static inline int hex2int(char c) ··· 127 125 char ethaddrs_str[18]; 128 126 char *pos; 129 127 u8 ethaddr[ETH_ALEN]; 128 + int ret; 130 129 131 - ENTER(); 130 + lbs_deb_enter(LBS_DEB_IOCTL); 131 + 132 132 if (copy_from_user(ethaddrs_str, wrq->u.data.pointer, 133 133 sizeof(ethaddrs_str))) 134 134 return -EFAULT; ··· 140 136 return -EINVAL; 141 137 } 142 138 143 - lbs_pr_debug(1, "BT: adding %s\n", ethaddrs_str); 144 - LEAVE(); 145 - return (libertas_prepare_and_send_command(priv, cmd_bt_access, 139 + lbs_deb_ioctl("BT: adding %s\n", ethaddrs_str); 140 + ret = libertas_prepare_and_send_command(priv, cmd_bt_access, 146 141 cmd_act_bt_access_add, 147 - cmd_option_waitforrsp, 0, ethaddr)); 142 + cmd_option_waitforrsp, 0, ethaddr); 143 + lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret); 144 + return ret; 148 145 } 149 146 150 147 /** ··· 161 156 u8 ethaddr[ETH_ALEN]; 162 157 char *pos; 163 158 164 - ENTER(); 159 + lbs_deb_enter(LBS_DEB_IOCTL); 160 + 165 161 if (copy_from_user(ethaddrs_str, wrq->u.data.pointer, 166 162 sizeof(ethaddrs_str))) 167 163 return -EFAULT; ··· 172 166 return -EINVAL; 173 167 } 174 168 175 - lbs_pr_debug(1, "BT: deleting %s\n", ethaddrs_str); 169 + lbs_deb_ioctl("BT: deleting %s\n", ethaddrs_str); 176 170 177 171 return (libertas_prepare_and_send_command(priv, 178 172 cmd_bt_access, 179 173 cmd_act_bt_access_del, 180 174 cmd_option_waitforrsp, 0, ethaddr)); 181 - LEAVE(); 175 + 176 + lbs_deb_leave(LBS_DEB_IOCTL); 182 177 return 0; 183 178 } 184 179 ··· 190 183 */ 191 184 static int wlan_bt_reset_ioctl(wlan_private * priv) 192 185 { 193 - ENTER(); 186 + lbs_deb_enter(LBS_DEB_IOCTL); 194 187 195 188 lbs_pr_alert( "BT: resetting\n"); 196 189 ··· 199 192 cmd_act_bt_access_reset, 200 193 cmd_option_waitforrsp, 0, NULL)); 201 194 202 - LEAVE(); 195 + lbs_deb_leave(LBS_DEB_IOCTL); 203 196 return 0; 204 197 } 205 198 ··· 216 209 struct iwreq *wrq = (struct iwreq *)req; 217 210 /* used to pass id and store the bt entry returned by the FW */ 218 211 union { 219 - int id; 212 + u32 id; 220 213 char addr1addr2[2 * ETH_ALEN]; 221 214 } param; 222 215 static char outstr[64]; 223 216 char *pbuf = outstr; 224 217 int ret; 225 218 226 - ENTER(); 219 + lbs_deb_enter(LBS_DEB_IOCTL); 227 220 228 221 if (copy_from_user(outstr, wrq->u.data.pointer, sizeof(outstr))) { 229 - lbs_pr_debug(1, "Copy from user failed\n"); 222 + lbs_deb_ioctl("Copy from user failed\n"); 230 223 return -1; 231 224 } 232 225 param.id = simple_strtoul(outstr, NULL, 10); ··· 241 234 if (ret == 0) { 242 235 addr1 = param.addr1addr2; 243 236 244 - pos = sprintf(pbuf, "ignoring traffic from "); 237 + pos = sprintf(pbuf, "BT includes node "); 245 238 pbuf += pos; 246 239 pos = eth_addr2str(addr1, pbuf); 247 240 pbuf += pos; ··· 253 246 wrq->u.data.length = strlen(outstr); 254 247 if (copy_to_user(wrq->u.data.pointer, (char *)outstr, 255 248 wrq->u.data.length)) { 256 - lbs_pr_debug(1, "BT_LIST: Copy to user failed!\n"); 249 + lbs_deb_ioctl("BT_LIST: Copy to user failed!\n"); 257 250 return -EFAULT; 258 251 } 259 252 260 - LEAVE(); 253 + lbs_deb_leave(LBS_DEB_IOCTL); 254 + return 0 ; 255 + } 256 + 257 + /** 258 + * @brief Sets inverted state of blacklist (non-zero if inverted) 259 + * @param priv A pointer to wlan_private structure 260 + * @param req A pointer to ifreq structure 261 + * @return 0 --success, otherwise fail 262 + */ 263 + static int wlan_bt_set_invert_ioctl(wlan_private * priv, struct ifreq *req) 264 + { 265 + int ret; 266 + struct iwreq *wrq = (struct iwreq *)req; 267 + union { 268 + u32 id; 269 + char addr1addr2[2 * ETH_ALEN]; 270 + } param; 271 + 272 + lbs_deb_enter(LBS_DEB_IOCTL); 273 + 274 + param.id = SUBCMD_DATA(wrq) ; 275 + ret = libertas_prepare_and_send_command(priv, cmd_bt_access, 276 + cmd_act_bt_access_set_invert, 277 + cmd_option_waitforrsp, 0, 278 + (char *)&param); 279 + if (ret != 0) 280 + return -EFAULT; 281 + lbs_deb_leave(LBS_DEB_IOCTL); 282 + return 0; 283 + } 284 + 285 + /** 286 + * @brief Gets inverted state of blacklist (non-zero if inverted) 287 + * @param priv A pointer to wlan_private structure 288 + * @param req A pointer to ifreq structure 289 + * @return 0 --success, otherwise fail 290 + */ 291 + static int wlan_bt_get_invert_ioctl(wlan_private * priv, struct ifreq *req) 292 + { 293 + struct iwreq *wrq = (struct iwreq *)req; 294 + int ret; 295 + union { 296 + u32 id; 297 + char addr1addr2[2 * ETH_ALEN]; 298 + } param; 299 + 300 + lbs_deb_enter(LBS_DEB_IOCTL); 301 + 302 + ret = libertas_prepare_and_send_command(priv, cmd_bt_access, 303 + cmd_act_bt_access_get_invert, 304 + cmd_option_waitforrsp, 0, 305 + (char *)&param); 306 + 307 + if (ret == 0) 308 + wrq->u.param.value = le32_to_cpu(param.id); 309 + else 310 + return -EFAULT; 311 + 312 + lbs_deb_leave(LBS_DEB_IOCTL); 261 313 return 0; 262 314 } 263 315 ··· 344 278 char in_str[128]; 345 279 static struct cmd_ds_fwt_access fwt_access; 346 280 char *ptr; 281 + int ret; 347 282 348 - ENTER(); 283 + lbs_deb_enter(LBS_DEB_IOCTL); 284 + 349 285 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) 350 286 return -EFAULT; 351 287 ··· 365 297 fwt_access.metric = 366 298 cpu_to_le32(simple_strtoul(ptr, &ptr, 10)); 367 299 else 368 - fwt_access.metric = FWT_DEFAULT_METRIC; 300 + fwt_access.metric = cpu_to_le32(FWT_DEFAULT_METRIC); 369 301 370 302 if ((ptr = next_param(ptr))) 371 303 fwt_access.dir = (u8)simple_strtoul(ptr, &ptr, 10); ··· 373 305 fwt_access.dir = FWT_DEFAULT_DIR; 374 306 375 307 if ((ptr = next_param(ptr))) 308 + fwt_access.rate = (u8) simple_strtoul(ptr, &ptr, 10); 309 + else 310 + fwt_access.rate = FWT_DEFAULT_RATE; 311 + 312 + if ((ptr = next_param(ptr))) 376 313 fwt_access.ssn = 377 314 cpu_to_le32(simple_strtoul(ptr, &ptr, 10)); 378 315 else 379 - fwt_access.ssn = FWT_DEFAULT_SSN; 316 + fwt_access.ssn = cpu_to_le32(FWT_DEFAULT_SSN); 380 317 381 318 if ((ptr = next_param(ptr))) 382 319 fwt_access.dsn = 383 320 cpu_to_le32(simple_strtoul(ptr, &ptr, 10)); 384 321 else 385 - fwt_access.dsn = FWT_DEFAULT_DSN; 322 + fwt_access.dsn = cpu_to_le32(FWT_DEFAULT_DSN); 386 323 387 324 if ((ptr = next_param(ptr))) 388 325 fwt_access.hopcount = simple_strtoul(ptr, &ptr, 10); ··· 403 330 fwt_access.expiration = 404 331 cpu_to_le32(simple_strtoul(ptr, &ptr, 10)); 405 332 else 406 - fwt_access.expiration = FWT_DEFAULT_EXPIRATION; 333 + fwt_access.expiration = cpu_to_le32(FWT_DEFAULT_EXPIRATION); 407 334 408 335 if ((ptr = next_param(ptr))) 409 336 fwt_access.sleepmode = (u8)simple_strtoul(ptr, &ptr, 10); ··· 414 341 fwt_access.snr = 415 342 cpu_to_le32(simple_strtoul(ptr, &ptr, 10)); 416 343 else 417 - fwt_access.snr = FWT_DEFAULT_SNR; 344 + fwt_access.snr = cpu_to_le32(FWT_DEFAULT_SNR); 418 345 419 346 #ifdef DEBUG 420 347 { 421 348 char ethaddr1_str[18], ethaddr2_str[18]; 422 349 eth_addr2str(fwt_access.da, ethaddr1_str); 423 350 eth_addr2str(fwt_access.ra, ethaddr2_str); 424 - lbs_pr_debug(1, "FWT_ADD: adding (da:%s,%i,ra:%s)\n", ethaddr1_str, 351 + lbs_deb_ioctl("FWT_ADD: adding (da:%s,%i,ra:%s)\n", ethaddr1_str, 425 352 fwt_access.dir, ethaddr2_str); 426 - lbs_pr_debug(1, "FWT_ADD: ssn:%u dsn:%u met:%u hop:%u ttl:%u exp:%u slp:%u snr:%u\n", 353 + lbs_deb_ioctl("FWT_ADD: ssn:%u dsn:%u met:%u hop:%u ttl:%u exp:%u slp:%u snr:%u\n", 427 354 fwt_access.ssn, fwt_access.dsn, fwt_access.metric, 428 355 fwt_access.hopcount, fwt_access.ttl, fwt_access.expiration, 429 356 fwt_access.sleepmode, fwt_access.snr); 430 357 } 431 358 #endif 432 359 433 - LEAVE(); 434 - return (libertas_prepare_and_send_command(priv, cmd_fwt_access, 435 - cmd_act_fwt_access_add, 436 - cmd_option_waitforrsp, 0, 437 - (void *)&fwt_access)); 360 + ret = libertas_prepare_and_send_command(priv, cmd_fwt_access, 361 + cmd_act_fwt_access_add, 362 + cmd_option_waitforrsp, 0, 363 + (void *)&fwt_access); 364 + 365 + lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret); 366 + return ret; 438 367 } 439 368 440 369 /** ··· 451 376 char in_str[64]; 452 377 static struct cmd_ds_fwt_access fwt_access; 453 378 char *ptr; 379 + int ret; 454 380 455 - ENTER(); 381 + lbs_deb_enter(LBS_DEB_IOCTL); 382 + 456 383 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) 457 384 return -EFAULT; 458 385 ··· 476 399 #ifdef DEBUG 477 400 { 478 401 char ethaddr1_str[18], ethaddr2_str[18]; 479 - lbs_pr_debug(1, "FWT_DEL: line is %s\n", in_str); 402 + lbs_deb_ioctl("FWT_DEL: line is %s\n", in_str); 480 403 eth_addr2str(fwt_access.da, ethaddr1_str); 481 404 eth_addr2str(fwt_access.ra, ethaddr2_str); 482 - lbs_pr_debug(1, "FWT_DEL: removing (da:%s,ra:%s,dir:%d)\n", ethaddr1_str, 405 + lbs_deb_ioctl("FWT_DEL: removing (da:%s,ra:%s,dir:%d)\n", ethaddr1_str, 483 406 ethaddr2_str, fwt_access.dir); 484 407 } 485 408 #endif 486 409 487 - LEAVE(); 488 - return (libertas_prepare_and_send_command(priv, 489 - cmd_fwt_access, 490 - cmd_act_fwt_access_del, 491 - cmd_option_waitforrsp, 0, 492 - (void *)&fwt_access)); 410 + ret = libertas_prepare_and_send_command(priv, 411 + cmd_fwt_access, 412 + cmd_act_fwt_access_del, 413 + cmd_option_waitforrsp, 0, 414 + (void *)&fwt_access); 415 + lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret); 416 + return ret; 493 417 } 494 418 495 419 ··· 505 427 buf += eth_addr2str(fwt_access.da, buf); 506 428 buf += sprintf(buf, " "); 507 429 buf += eth_addr2str(fwt_access.ra, buf); 430 + buf += sprintf(buf, " %u", fwt_access.valid); 508 431 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.metric)); 509 432 buf += sprintf(buf, " %u", fwt_access.dir); 433 + buf += sprintf(buf, " %u", fwt_access.rate); 510 434 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.ssn)); 511 435 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.dsn)); 512 436 buf += sprintf(buf, " %u", fwt_access.hopcount); 513 437 buf += sprintf(buf, " %u", fwt_access.ttl); 514 438 buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.expiration)); 515 439 buf += sprintf(buf, " %u", fwt_access.sleepmode); 516 - buf += sprintf(buf, " %u", le32_to_cpu(fwt_access.snr)); 440 + buf += sprintf(buf, " %u ", le32_to_cpu(fwt_access.snr)); 441 + buf += eth_addr2str(fwt_access.prec, buf); 517 442 } 518 443 519 444 /** ··· 534 453 static char out_str[128]; 535 454 int ret; 536 455 537 - ENTER(); 456 + lbs_deb_enter(LBS_DEB_IOCTL); 457 + 538 458 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) 539 459 return -EFAULT; 540 460 ··· 547 465 #ifdef DEBUG 548 466 { 549 467 char ethaddr1_str[18]; 550 - lbs_pr_debug(1, "FWT_LOOKUP: line is %s\n", in_str); 468 + lbs_deb_ioctl("FWT_LOOKUP: line is %s\n", in_str); 551 469 eth_addr2str(fwt_access.da, ethaddr1_str); 552 - lbs_pr_debug(1, "FWT_LOOKUP: looking for (da:%s)\n", ethaddr1_str); 470 + lbs_deb_ioctl("FWT_LOOKUP: looking for (da:%s)\n", ethaddr1_str); 553 471 } 554 472 #endif 555 473 ··· 567 485 wrq->u.data.length = strlen(out_str); 568 486 if (copy_to_user(wrq->u.data.pointer, (char *)out_str, 569 487 wrq->u.data.length)) { 570 - lbs_pr_debug(1, "FWT_LOOKUP: Copy to user failed!\n"); 488 + lbs_deb_ioctl("FWT_LOOKUP: Copy to user failed!\n"); 571 489 return -EFAULT; 572 490 } 573 491 574 - LEAVE(); 492 + lbs_deb_leave(LBS_DEB_IOCTL); 575 493 return 0; 576 494 } 577 495 ··· 582 500 */ 583 501 static int wlan_fwt_reset_ioctl(wlan_private * priv) 584 502 { 585 - lbs_pr_debug(1, "FWT: resetting\n"); 503 + lbs_deb_ioctl("FWT: resetting\n"); 586 504 587 505 return (libertas_prepare_and_send_command(priv, 588 506 cmd_fwt_access, ··· 604 522 char *ptr = in_str; 605 523 static char out_str[128]; 606 524 char *pbuf = out_str; 607 - int ret; 525 + int ret = 0; 608 526 609 - ENTER(); 610 - if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) 611 - return -EFAULT; 527 + lbs_deb_enter(LBS_DEB_IOCTL); 528 + 529 + if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) { 530 + ret = -EFAULT; 531 + goto out; 532 + } 612 533 613 534 fwt_access.id = cpu_to_le32(simple_strtoul(ptr, &ptr, 10)); 614 535 615 536 #ifdef DEBUG 616 537 { 617 - lbs_pr_debug(1, "FWT_LIST: line is %s\n", in_str); 618 - lbs_pr_debug(1, "FWT_LIST: listing id:%i\n", le32_to_cpu(fwt_access.id)); 538 + lbs_deb_ioctl("FWT_LIST: line is %s\n", in_str); 539 + lbs_deb_ioctl("FWT_LIST: listing id:%i\n", le32_to_cpu(fwt_access.id)); 619 540 } 620 541 #endif 621 542 ··· 634 549 wrq->u.data.length = strlen(out_str); 635 550 if (copy_to_user(wrq->u.data.pointer, (char *)out_str, 636 551 wrq->u.data.length)) { 637 - lbs_pr_debug(1, "FWT_LIST: Copy to user failed!\n"); 638 - return -EFAULT; 552 + lbs_deb_ioctl("FWT_LIST: Copy to user failed!\n"); 553 + ret = -EFAULT; 554 + goto out; 639 555 } 640 556 641 - LEAVE(); 642 - return 0; 557 + ret = 0; 558 + 559 + out: 560 + lbs_deb_leave(LBS_DEB_IOCTL); 561 + return ret; 643 562 } 644 563 645 564 /** ··· 662 573 char *pbuf = out_str; 663 574 int ret; 664 575 665 - ENTER(); 576 + lbs_deb_enter(LBS_DEB_IOCTL); 577 + 666 578 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) 667 579 return -EFAULT; 668 580 ··· 671 581 672 582 #ifdef DEBUG 673 583 { 674 - lbs_pr_debug(1, "FWT_LIST_ROUTE: line is %s\n", in_str); 675 - lbs_pr_debug(1, "FWT_LIST_ROUTE: listing id:%i\n", le32_to_cpu(fwt_access.id)); 584 + lbs_deb_ioctl("FWT_LIST_ROUTE: line is %s\n", in_str); 585 + lbs_deb_ioctl("FWT_LIST_ROUTE: listing id:%i\n", le32_to_cpu(fwt_access.id)); 676 586 } 677 587 #endif 678 588 ··· 681 591 cmd_option_waitforrsp, 0, (void *)&fwt_access); 682 592 683 593 if (ret == 0) { 684 - pbuf += sprintf(pbuf, " "); 685 - pbuf += eth_addr2str(fwt_access.da, pbuf); 686 - pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.metric)); 687 - pbuf += sprintf(pbuf, " %u", fwt_access.dir); 688 - /* note that the firmware returns the nid in the id field */ 689 - pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.id)); 690 - pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.ssn)); 691 - pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.dsn)); 692 - pbuf += sprintf(pbuf, " hop %u", fwt_access.hopcount); 693 - pbuf += sprintf(pbuf, " ttl %u", fwt_access.ttl); 694 - pbuf += sprintf(pbuf, " %u", le32_to_cpu(fwt_access.expiration)); 594 + print_route(fwt_access, pbuf); 695 595 } else 696 596 pbuf += sprintf(pbuf, " (null)"); 697 597 698 598 wrq->u.data.length = strlen(out_str); 699 599 if (copy_to_user(wrq->u.data.pointer, (char *)out_str, 700 600 wrq->u.data.length)) { 701 - lbs_pr_debug(1, "FWT_LIST_ROUTE: Copy to user failed!\n"); 601 + lbs_deb_ioctl("FWT_LIST_ROUTE: Copy to user failed!\n"); 702 602 return -EFAULT; 703 603 } 704 604 705 - LEAVE(); 605 + lbs_deb_leave(LBS_DEB_IOCTL); 706 606 return 0; 707 607 } 708 608 ··· 712 632 char *pbuf = out_str; 713 633 int ret; 714 634 715 - ENTER(); 635 + lbs_deb_enter(LBS_DEB_IOCTL); 636 + 716 637 if (copy_from_user(in_str, wrq->u.data.pointer, sizeof(in_str))) 717 638 return -EFAULT; 718 639 ··· 722 641 723 642 #ifdef DEBUG 724 643 { 725 - lbs_pr_debug(1, "FWT_LIST_NEIGHBOR: line is %s\n", in_str); 726 - lbs_pr_debug(1, "FWT_LIST_NEIGHBOR: listing id:%i\n", le32_to_cpu(fwt_access.id)); 644 + lbs_deb_ioctl("FWT_LIST_NEIGHBOR: line is %s\n", in_str); 645 + lbs_deb_ioctl("FWT_LIST_NEIGHBOR: listing id:%i\n", le32_to_cpu(fwt_access.id)); 727 646 } 728 647 #endif 729 648 ··· 744 663 wrq->u.data.length = strlen(out_str); 745 664 if (copy_to_user(wrq->u.data.pointer, (char *)out_str, 746 665 wrq->u.data.length)) { 747 - lbs_pr_debug(1, "FWT_LIST_NEIGHBOR: Copy to user failed!\n"); 666 + lbs_deb_ioctl("FWT_LIST_NEIGHBOR: Copy to user failed!\n"); 748 667 return -EFAULT; 749 668 } 750 669 751 - LEAVE(); 670 + lbs_deb_leave(LBS_DEB_IOCTL); 752 671 return 0; 753 672 } 754 673 ··· 765 684 static struct cmd_ds_fwt_access fwt_access; 766 685 int ret; 767 686 768 - ENTER(); 687 + lbs_deb_enter(LBS_DEB_IOCTL); 769 688 770 - lbs_pr_debug(1, "FWT: cleaning up\n"); 689 + lbs_deb_ioctl("FWT: cleaning up\n"); 771 690 772 691 memset(&fwt_access, 0, sizeof(fwt_access)); 773 692 ··· 781 700 else 782 701 return -EFAULT; 783 702 784 - LEAVE(); 703 + lbs_deb_leave(LBS_DEB_IOCTL); 785 704 return 0; 786 705 } 787 706 ··· 797 716 static struct cmd_ds_fwt_access fwt_access; 798 717 int ret; 799 718 800 - ENTER(); 719 + lbs_deb_enter(LBS_DEB_IOCTL); 801 720 802 - lbs_pr_debug(1, "FWT: getting time\n"); 721 + lbs_deb_ioctl("FWT: getting time\n"); 803 722 804 723 memset(&fwt_access, 0, sizeof(fwt_access)); 805 724 ··· 813 732 else 814 733 return -EFAULT; 815 734 816 - LEAVE(); 735 + lbs_deb_leave(LBS_DEB_IOCTL); 817 736 return 0; 818 737 } 819 738 ··· 829 748 struct cmd_ds_mesh_access mesh_access; 830 749 int ret; 831 750 832 - ENTER(); 751 + lbs_deb_enter(LBS_DEB_IOCTL); 833 752 834 753 memset(&mesh_access, 0, sizeof(mesh_access)); 835 754 ··· 843 762 else 844 763 return -EFAULT; 845 764 846 - LEAVE(); 765 + lbs_deb_leave(LBS_DEB_IOCTL); 847 766 return 0; 848 767 } 849 768 ··· 858 777 struct cmd_ds_mesh_access mesh_access; 859 778 int ret; 860 779 861 - ENTER(); 780 + lbs_deb_enter(LBS_DEB_IOCTL); 862 781 863 782 if( (ttl > 0xff) || (ttl < 0) ) 864 783 return -EINVAL; 865 784 866 785 memset(&mesh_access, 0, sizeof(mesh_access)); 867 - mesh_access.data[0] = ttl; 786 + mesh_access.data[0] = cpu_to_le32(ttl); 868 787 869 788 ret = libertas_prepare_and_send_command(priv, cmd_mesh_access, 870 789 cmd_act_mesh_set_ttl, ··· 874 793 if (ret != 0) 875 794 ret = -EFAULT; 876 795 877 - LEAVE(); 796 + lbs_deb_leave(LBS_DEB_IOCTL); 878 797 return ret; 879 798 } 880 799 ··· 896 815 wlan_adapter *adapter = priv->adapter; 897 816 struct iwreq *wrq = (struct iwreq *)req; 898 817 899 - ENTER(); 818 + lbs_deb_enter(LBS_DEB_IOCTL); 900 819 901 - lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); 820 + lbs_deb_ioctl("libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); 902 821 switch (cmd) { 903 822 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ 904 823 switch (wrq->u.data.flags) { ··· 928 847 idata = SUBCMD_DATA(wrq); 929 848 ret = wlan_mesh_set_ttl_ioctl(priv, idata); 930 849 break; 850 + 851 + case WLAN_SUBCMD_BT_SET_INVERT: 852 + ret = wlan_bt_set_invert_ioctl(priv, req); 853 + break ; 931 854 932 855 default: 933 856 ret = -EOPNOTSUPP; ··· 990 905 ret = wlan_mesh_get_ttl_ioctl(priv, req); 991 906 break; 992 907 908 + case WLAN_SUBCMD_BT_GET_INVERT: 909 + ret = wlan_bt_get_invert_ioctl(priv, req); 910 + break ; 911 + 993 912 default: 994 913 ret = -EOPNOTSUPP; 995 914 ··· 1026 937 (data, wrq->u.data.pointer, 1027 938 sizeof(int) * 1028 939 wrq->u.data.length)) { 1029 - lbs_pr_debug(1, 940 + lbs_deb_ioctl( 1030 941 "Copy from user failed\n"); 1031 942 return -EFAULT; 1032 943 } ··· 1059 970 if (copy_to_user(wrq->u.data.pointer, data, 1060 971 sizeof(int) * 1061 972 gpio->header.len)) { 1062 - lbs_pr_debug(1, "Copy to user failed\n"); 973 + lbs_deb_ioctl("Copy to user failed\n"); 1063 974 return -EFAULT; 1064 975 } 1065 976 ··· 1073 984 ret = -EINVAL; 1074 985 break; 1075 986 } 1076 - LEAVE(); 987 + 988 + lbs_deb_leave_args(LBS_DEB_IOCTL, "ret %d", ret); 1077 989 return ret; 1078 990 } 1079 991
+206 -258
drivers/net/wireless/libertas/join.c
··· 7 7 #include <linux/netdevice.h> 8 8 #include <linux/if_arp.h> 9 9 #include <linux/wireless.h> 10 + #include <linux/etherdevice.h> 10 11 11 12 #include <net/iw_handler.h> 12 13 ··· 15 14 #include "decl.h" 16 15 #include "join.h" 17 16 #include "dev.h" 17 + #include "assoc.h" 18 18 19 19 #define AD_HOC_CAP_PRIVACY_ON 1 20 20 ··· 62 60 lbs_dbg_hex("rate1 (AP) rates:", tmp, sizeof(tmp)); 63 61 lbs_dbg_hex("rate2 (Card) rates:", rate2, rate2_size); 64 62 lbs_dbg_hex("Common rates:", ptr, rate1_size); 65 - lbs_pr_debug(1, "Tx datarate is set to 0x%X\n", adapter->datarate); 63 + lbs_deb_join("Tx datarate is set to 0x%X\n", adapter->datarate); 66 64 67 65 if (!adapter->is_datarate_auto) { 68 66 while (*ptr) { ··· 106 104 * 107 105 * @return 0-success, otherwise fail 108 106 */ 109 - int wlan_associate(wlan_private * priv, struct bss_descriptor * pbssdesc) 107 + int wlan_associate(wlan_private * priv, struct assoc_request * assoc_req) 110 108 { 111 109 wlan_adapter *adapter = priv->adapter; 112 110 int ret; 113 111 114 - ENTER(); 112 + lbs_deb_enter(LBS_DEB_JOIN); 115 113 116 114 ret = libertas_prepare_and_send_command(priv, cmd_802_11_authenticate, 117 115 0, cmd_option_waitforrsp, 118 - 0, pbssdesc->macaddress); 116 + 0, assoc_req->bss.bssid); 119 117 120 - if (ret) { 121 - LEAVE(); 122 - return ret; 123 - } 118 + if (ret) 119 + goto done; 124 120 125 121 /* set preamble to firmware */ 126 - if (adapter->capinfo.shortpreamble && pbssdesc->cap.shortpreamble) 122 + if (adapter->capinfo.shortpreamble && assoc_req->bss.cap.shortpreamble) 127 123 adapter->preamble = cmd_type_short_preamble; 128 124 else 129 125 adapter->preamble = cmd_type_long_preamble; ··· 129 129 libertas_set_radio_control(priv); 130 130 131 131 ret = libertas_prepare_and_send_command(priv, cmd_802_11_associate, 132 - 0, cmd_option_waitforrsp, 0, pbssdesc); 132 + 0, cmd_option_waitforrsp, 0, assoc_req); 133 133 134 - LEAVE(); 134 + done: 135 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 135 136 return ret; 136 137 } 137 138 ··· 143 142 * @param adhocssid The ssid of the Adhoc Network 144 143 * @return 0--success, -1--fail 145 144 */ 146 - int libertas_start_adhoc_network(wlan_private * priv, struct WLAN_802_11_SSID *adhocssid) 145 + int libertas_start_adhoc_network(wlan_private * priv, struct assoc_request * assoc_req) 147 146 { 148 147 wlan_adapter *adapter = priv->adapter; 149 148 int ret = 0; ··· 151 150 adapter->adhoccreate = 1; 152 151 153 152 if (!adapter->capinfo.shortpreamble) { 154 - lbs_pr_debug(1, "AdhocStart: Long preamble\n"); 153 + lbs_deb_join("AdhocStart: Long preamble\n"); 155 154 adapter->preamble = cmd_type_long_preamble; 156 155 } else { 157 - lbs_pr_debug(1, "AdhocStart: Short preamble\n"); 156 + lbs_deb_join("AdhocStart: Short preamble\n"); 158 157 adapter->preamble = cmd_type_short_preamble; 159 158 } 160 159 161 160 libertas_set_radio_control(priv); 162 161 163 - lbs_pr_debug(1, "Adhoc channel = %d\n", adapter->adhocchannel); 164 - lbs_pr_debug(1, "curbssparams.channel = %d\n", 165 - adapter->curbssparams.channel); 166 - lbs_pr_debug(1, "curbssparams.band = %d\n", adapter->curbssparams.band); 162 + lbs_deb_join("AdhocStart: channel = %d\n", assoc_req->channel); 163 + lbs_deb_join("AdhocStart: band = %d\n", assoc_req->band); 167 164 168 165 ret = libertas_prepare_and_send_command(priv, cmd_802_11_ad_hoc_start, 169 - 0, cmd_option_waitforrsp, 0, adhocssid); 166 + 0, cmd_option_waitforrsp, 0, assoc_req); 170 167 171 168 return ret; 172 169 } ··· 178 179 * 179 180 * @return 0--success, -1--fail 180 181 */ 181 - int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor * pbssdesc) 182 + int libertas_join_adhoc_network(wlan_private * priv, struct assoc_request * assoc_req) 182 183 { 183 184 wlan_adapter *adapter = priv->adapter; 185 + struct bss_descriptor * bss = &assoc_req->bss; 184 186 int ret = 0; 185 187 186 - lbs_pr_debug(1, "libertas_join_adhoc_network: CurBss.ssid =%s\n", 187 - adapter->curbssparams.ssid.ssid); 188 - lbs_pr_debug(1, "libertas_join_adhoc_network: CurBss.ssid_len =%u\n", 189 - adapter->curbssparams.ssid.ssidlength); 190 - lbs_pr_debug(1, "libertas_join_adhoc_network: ssid =%s\n", pbssdesc->ssid.ssid); 191 - lbs_pr_debug(1, "libertas_join_adhoc_network: ssid len =%u\n", 192 - pbssdesc->ssid.ssidlength); 188 + lbs_deb_join("%s: Current SSID '%s', ssid length %u\n", 189 + __func__, 190 + escape_essid(adapter->curbssparams.ssid, 191 + adapter->curbssparams.ssid_len), 192 + adapter->curbssparams.ssid_len); 193 + lbs_deb_join("%s: requested ssid '%s', ssid length %u\n", 194 + __func__, escape_essid(bss->ssid, bss->ssid_len), 195 + bss->ssid_len); 193 196 194 197 /* check if the requested SSID is already joined */ 195 - if (adapter->curbssparams.ssid.ssidlength 196 - && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) 198 + if (adapter->curbssparams.ssid_len 199 + && !libertas_ssid_cmp(adapter->curbssparams.ssid, 200 + adapter->curbssparams.ssid_len, 201 + bss->ssid, bss->ssid_len) 197 202 && (adapter->mode == IW_MODE_ADHOC)) { 198 - 199 - lbs_pr_debug(1, 203 + lbs_deb_join( 200 204 "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " 201 205 "not attempting to re-join"); 202 - 203 206 return -1; 204 207 } 205 208 206 209 /*Use shortpreamble only when both creator and card supports 207 210 short preamble */ 208 - if (!pbssdesc->cap.shortpreamble || !adapter->capinfo.shortpreamble) { 209 - lbs_pr_debug(1, "AdhocJoin: Long preamble\n"); 211 + if (!bss->cap.shortpreamble || !adapter->capinfo.shortpreamble) { 212 + lbs_deb_join("AdhocJoin: Long preamble\n"); 210 213 adapter->preamble = cmd_type_long_preamble; 211 214 } else { 212 - lbs_pr_debug(1, "AdhocJoin: Short preamble\n"); 215 + lbs_deb_join("AdhocJoin: Short preamble\n"); 213 216 adapter->preamble = cmd_type_short_preamble; 214 217 } 215 218 216 219 libertas_set_radio_control(priv); 217 220 218 - lbs_pr_debug(1, "curbssparams.channel = %d\n", 219 - adapter->curbssparams.channel); 220 - lbs_pr_debug(1, "curbssparams.band = %c\n", adapter->curbssparams.band); 221 + lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel); 222 + lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band); 221 223 222 224 adapter->adhoccreate = 0; 223 225 224 226 ret = libertas_prepare_and_send_command(priv, cmd_802_11_ad_hoc_join, 225 227 0, cmd_option_waitforrsp, 226 - OID_802_11_SSID, pbssdesc); 228 + OID_802_11_SSID, assoc_req); 227 229 228 230 return ret; 229 231 } ··· 265 265 int ret = -1; 266 266 u8 *bssid = pdata_buf; 267 267 268 + lbs_deb_enter(LBS_DEB_JOIN); 269 + 268 270 cmd->command = cpu_to_le16(cmd_802_11_authenticate); 269 271 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) 270 272 + S_DS_GEN); ··· 283 281 pauthenticate->authtype = 0x80; 284 282 break; 285 283 default: 286 - lbs_pr_debug(1, "AUTH_CMD: invalid auth alg 0x%X\n", 284 + lbs_deb_join("AUTH_CMD: invalid auth alg 0x%X\n", 287 285 adapter->secinfo.auth_mode); 288 286 goto out; 289 287 } 290 288 291 289 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); 292 290 293 - lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", 294 - bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); 291 + lbs_deb_join("AUTH_CMD: BSSID is : " MAC_FMT " auth=0x%X\n", 292 + MAC_ARG(bssid), pauthenticate->authtype); 295 293 ret = 0; 296 294 297 295 out: 296 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 298 297 return ret; 299 298 } 300 299 ··· 305 302 wlan_adapter *adapter = priv->adapter; 306 303 struct cmd_ds_802_11_deauthenticate *dauth = &cmd->params.deauth; 307 304 308 - ENTER(); 305 + lbs_deb_enter(LBS_DEB_JOIN); 309 306 310 307 cmd->command = cpu_to_le16(cmd_802_11_deauthenticate); 311 - cmd->size = 312 - cpu_to_le16(sizeof(struct cmd_ds_802_11_deauthenticate) + 308 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_deauthenticate) + 313 309 S_DS_GEN); 314 310 315 311 /* set AP MAC address */ 316 - memmove(dauth->macaddr, adapter->curbssparams.bssid, 317 - ETH_ALEN); 312 + memmove(dauth->macaddr, adapter->curbssparams.bssid, ETH_ALEN); 318 313 319 314 /* Reason code 3 = Station is leaving */ 320 315 #define REASON_CODE_STA_LEAVING 3 321 316 dauth->reasoncode = cpu_to_le16(REASON_CODE_STA_LEAVING); 322 317 323 - LEAVE(); 318 + lbs_deb_leave(LBS_DEB_JOIN); 324 319 return 0; 325 320 } 326 321 ··· 328 327 wlan_adapter *adapter = priv->adapter; 329 328 struct cmd_ds_802_11_associate *passo = &cmd->params.associate; 330 329 int ret = 0; 331 - struct bss_descriptor *pbssdesc; 330 + struct assoc_request * assoc_req = pdata_buf; 331 + struct bss_descriptor * bss = &assoc_req->bss; 332 332 u8 *card_rates; 333 333 u8 *pos; 334 334 int card_rates_size; 335 - u16 tmpcap; 335 + u16 tmpcap, tmplen; 336 336 struct mrvlietypes_ssidparamset *ssid; 337 337 struct mrvlietypes_phyparamset *phy; 338 338 struct mrvlietypes_ssparamset *ss; 339 339 struct mrvlietypes_ratesparamset *rates; 340 340 struct mrvlietypes_rsnparamset *rsn; 341 341 342 - ENTER(); 342 + lbs_deb_enter(LBS_DEB_JOIN); 343 343 344 - pbssdesc = pdata_buf; 345 344 pos = (u8 *) passo; 346 345 347 346 if (!adapter) { ··· 351 350 352 351 cmd->command = cpu_to_le16(cmd_802_11_associate); 353 352 354 - /* Save so we know which BSS Desc to use in the response handler */ 355 - adapter->pattemptedbssdesc = pbssdesc; 356 - 357 - memcpy(passo->peerstaaddr, 358 - pbssdesc->macaddress, sizeof(passo->peerstaaddr)); 353 + memcpy(passo->peerstaaddr, bss->bssid, sizeof(passo->peerstaaddr)); 359 354 pos += sizeof(passo->peerstaaddr); 360 355 361 356 /* set the listen interval */ 362 - passo->listeninterval = adapter->listeninterval; 357 + passo->listeninterval = cpu_to_le16(adapter->listeninterval); 363 358 364 359 pos += sizeof(passo->capinfo); 365 360 pos += sizeof(passo->listeninterval); ··· 364 367 365 368 ssid = (struct mrvlietypes_ssidparamset *) pos; 366 369 ssid->header.type = cpu_to_le16(TLV_TYPE_SSID); 367 - ssid->header.len = pbssdesc->ssid.ssidlength; 368 - memcpy(ssid->ssid, pbssdesc->ssid.ssid, ssid->header.len); 369 - pos += sizeof(ssid->header) + ssid->header.len; 370 - ssid->header.len = cpu_to_le16(ssid->header.len); 370 + tmplen = bss->ssid_len; 371 + ssid->header.len = cpu_to_le16(tmplen); 372 + memcpy(ssid->ssid, bss->ssid, tmplen); 373 + pos += sizeof(ssid->header) + tmplen; 371 374 372 375 phy = (struct mrvlietypes_phyparamset *) pos; 373 376 phy->header.type = cpu_to_le16(TLV_TYPE_PHY_DS); 374 - phy->header.len = sizeof(phy->fh_ds.dsparamset); 377 + tmplen = sizeof(phy->fh_ds.dsparamset); 378 + phy->header.len = cpu_to_le16(tmplen); 375 379 memcpy(&phy->fh_ds.dsparamset, 376 - &pbssdesc->phyparamset.dsparamset.currentchan, 377 - sizeof(phy->fh_ds.dsparamset)); 378 - pos += sizeof(phy->header) + phy->header.len; 379 - phy->header.len = cpu_to_le16(phy->header.len); 380 + &bss->phyparamset.dsparamset.currentchan, 381 + tmplen); 382 + pos += sizeof(phy->header) + tmplen; 380 383 381 384 ss = (struct mrvlietypes_ssparamset *) pos; 382 385 ss->header.type = cpu_to_le16(TLV_TYPE_CF); 383 - ss->header.len = sizeof(ss->cf_ibss.cfparamset); 384 - pos += sizeof(ss->header) + ss->header.len; 385 - ss->header.len = cpu_to_le16(ss->header.len); 386 + tmplen = sizeof(ss->cf_ibss.cfparamset); 387 + ss->header.len = cpu_to_le16(tmplen); 388 + pos += sizeof(ss->header) + tmplen; 386 389 387 390 rates = (struct mrvlietypes_ratesparamset *) pos; 388 391 rates->header.type = cpu_to_le16(TLV_TYPE_RATES); 389 392 390 - memcpy(&rates->rates, &pbssdesc->libertas_supported_rates, WLAN_SUPPORTED_RATES); 393 + memcpy(&rates->rates, &bss->libertas_supported_rates, WLAN_SUPPORTED_RATES); 391 394 392 395 card_rates = libertas_supported_rates; 393 396 card_rates_size = sizeof(libertas_supported_rates); ··· 398 401 goto done; 399 402 } 400 403 401 - rates->header.len = min_t(size_t, strlen(rates->rates), WLAN_SUPPORTED_RATES); 402 - adapter->curbssparams.numofrates = rates->header.len; 404 + tmplen = min_t(size_t, strlen(rates->rates), WLAN_SUPPORTED_RATES); 405 + adapter->curbssparams.numofrates = tmplen; 403 406 404 - pos += sizeof(rates->header) + rates->header.len; 405 - rates->header.len = cpu_to_le16(rates->header.len); 407 + pos += sizeof(rates->header) + tmplen; 408 + rates->header.len = cpu_to_le16(tmplen); 406 409 407 - if (adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { 410 + if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { 408 411 rsn = (struct mrvlietypes_rsnparamset *) pos; 409 - rsn->header.type = (u16) adapter->wpa_ie[0]; /* WPA_IE or WPA2_IE */ 410 - rsn->header.type = cpu_to_le16(rsn->header.type); 411 - rsn->header.len = (u16) adapter->wpa_ie[1]; 412 - memcpy(rsn->rsnie, &adapter->wpa_ie[2], rsn->header.len); 412 + /* WPA_IE or WPA2_IE */ 413 + rsn->header.type = cpu_to_le16((u16) assoc_req->wpa_ie[0]); 414 + tmplen = (u16) assoc_req->wpa_ie[1]; 415 + rsn->header.len = cpu_to_le16(tmplen); 416 + memcpy(rsn->rsnie, &assoc_req->wpa_ie[2], tmplen); 413 417 lbs_dbg_hex("ASSOC_CMD: RSN IE", (u8 *) rsn, 414 - sizeof(rsn->header) + rsn->header.len); 415 - pos += sizeof(rsn->header) + rsn->header.len; 416 - rsn->header.len = cpu_to_le16(rsn->header.len); 418 + sizeof(rsn->header) + tmplen); 419 + pos += sizeof(rsn->header) + tmplen; 417 420 } 418 421 419 422 /* update curbssparams */ 420 - adapter->curbssparams.channel = 421 - (pbssdesc->phyparamset.dsparamset.currentchan); 423 + adapter->curbssparams.channel = bss->phyparamset.dsparamset.currentchan; 422 424 423 425 /* Copy the infra. association rates into Current BSS state structure */ 424 426 memcpy(&adapter->curbssparams.datarates, &rates->rates, 425 - min_t(size_t, sizeof(adapter->curbssparams.datarates), rates->header.len)); 427 + min_t(size_t, sizeof(adapter->curbssparams.datarates), 428 + cpu_to_le16(rates->header.len))); 426 429 427 - lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); 430 + lbs_deb_join("ASSOC_CMD: rates->header.len = %d\n", 431 + cpu_to_le16(rates->header.len)); 428 432 429 433 /* set IBSS field */ 430 - if (pbssdesc->mode == IW_MODE_INFRA) { 434 + if (bss->mode == IW_MODE_INFRA) { 431 435 #define CAPINFO_ESS_MODE 1 432 436 passo->capinfo.ess = CAPINFO_ESS_MODE; 433 437 } 434 438 435 - if (libertas_parse_dnld_countryinfo_11d(priv)) { 439 + if (libertas_parse_dnld_countryinfo_11d(priv, bss)) { 436 440 ret = -1; 437 441 goto done; 438 442 } ··· 441 443 cmd->size = cpu_to_le16((u16) (pos - (u8 *) passo) + S_DS_GEN); 442 444 443 445 /* set the capability info at last */ 444 - memcpy(&tmpcap, &pbssdesc->cap, sizeof(passo->capinfo)); 446 + memcpy(&tmpcap, &bss->cap, sizeof(passo->capinfo)); 445 447 tmpcap &= CAPINFO_MASK; 446 - lbs_pr_debug(1, "ASSOC_CMD: tmpcap=%4X CAPINFO_MASK=%4X\n", 447 - tmpcap, CAPINFO_MASK); 448 - tmpcap = cpu_to_le16(tmpcap); 448 + lbs_deb_join("ASSOC_CMD: tmpcap=%4X CAPINFO_MASK=%4X\n", 449 + tmpcap, CAPINFO_MASK); 449 450 memcpy(&passo->capinfo, &tmpcap, sizeof(passo->capinfo)); 450 451 451 - done: 452 - LEAVE(); 452 + done: 453 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 453 454 return ret; 454 455 } 455 456 456 457 int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, 457 - struct cmd_ds_command *cmd, void *pssid) 458 + struct cmd_ds_command *cmd, void *pdata_buf) 458 459 { 459 460 wlan_adapter *adapter = priv->adapter; 460 461 struct cmd_ds_802_11_ad_hoc_start *adhs = &cmd->params.ads; 461 462 int ret = 0; 462 463 int cmdappendsize = 0; 463 464 int i; 464 - u16 tmpcap; 465 - struct bss_descriptor *pbssdesc; 466 - struct WLAN_802_11_SSID *ssid = pssid; 465 + struct assoc_request * assoc_req = pdata_buf; 467 466 468 - ENTER(); 467 + lbs_deb_enter(LBS_DEB_JOIN); 469 468 470 469 if (!adapter) { 471 470 ret = -1; ··· 470 475 } 471 476 472 477 cmd->command = cpu_to_le16(cmd_802_11_ad_hoc_start); 473 - 474 - pbssdesc = &adapter->curbssparams.bssdescriptor; 475 - adapter->pattemptedbssdesc = pbssdesc; 476 478 477 479 /* 478 480 * Fill in the parameters for 2 data structures: ··· 484 492 */ 485 493 486 494 memset(adhs->SSID, 0, IW_ESSID_MAX_SIZE); 495 + memcpy(adhs->SSID, assoc_req->ssid, assoc_req->ssid_len); 487 496 488 - memcpy(adhs->SSID, ssid->ssid, ssid->ssidlength); 489 - 490 - lbs_pr_debug(1, "ADHOC_S_CMD: SSID = %s\n", adhs->SSID); 491 - 492 - memset(pbssdesc->ssid.ssid, 0, IW_ESSID_MAX_SIZE); 493 - memcpy(pbssdesc->ssid.ssid, ssid->ssid, ssid->ssidlength); 494 - 495 - pbssdesc->ssid.ssidlength = ssid->ssidlength; 497 + lbs_deb_join("ADHOC_S_CMD: SSID '%s', ssid length %u\n", 498 + escape_essid(assoc_req->ssid, assoc_req->ssid_len), 499 + assoc_req->ssid_len); 496 500 497 501 /* set the BSS type */ 498 502 adhs->bsstype = cmd_bss_type_ibss; 499 - pbssdesc->mode = IW_MODE_ADHOC; 500 - adhs->beaconperiod = adapter->beaconperiod; 503 + adapter->mode = IW_MODE_ADHOC; 504 + adhs->beaconperiod = cpu_to_le16(adapter->beaconperiod); 501 505 502 506 /* set Physical param set */ 503 507 #define DS_PARA_IE_ID 3 ··· 502 514 adhs->phyparamset.dsparamset.elementid = DS_PARA_IE_ID; 503 515 adhs->phyparamset.dsparamset.len = DS_PARA_IE_LEN; 504 516 505 - WARN_ON(!adapter->adhocchannel); 517 + WARN_ON(!assoc_req->channel); 506 518 507 - lbs_pr_debug(1, "ADHOC_S_CMD: Creating ADHOC on channel %d\n", 508 - adapter->adhocchannel); 519 + lbs_deb_join("ADHOC_S_CMD: Creating ADHOC on channel %d\n", 520 + assoc_req->channel); 509 521 510 - adapter->curbssparams.channel = adapter->adhocchannel; 511 - 512 - pbssdesc->channel = adapter->adhocchannel; 513 - adhs->phyparamset.dsparamset.currentchan = adapter->adhocchannel; 514 - 515 - memcpy(&pbssdesc->phyparamset, 516 - &adhs->phyparamset, sizeof(union ieeetypes_phyparamset)); 522 + adhs->phyparamset.dsparamset.currentchan = assoc_req->channel; 517 523 518 524 /* set IBSS param set */ 519 525 #define IBSS_PARA_IE_ID 6 ··· 515 533 516 534 adhs->ssparamset.ibssparamset.elementid = IBSS_PARA_IE_ID; 517 535 adhs->ssparamset.ibssparamset.len = IBSS_PARA_IE_LEN; 518 - adhs->ssparamset.ibssparamset.atimwindow = adapter->atimwindow; 519 - memcpy(&pbssdesc->ssparamset, 520 - &adhs->ssparamset, sizeof(union IEEEtypes_ssparamset)); 536 + adhs->ssparamset.ibssparamset.atimwindow = cpu_to_le16(adapter->atimwindow); 521 537 522 538 /* set capability info */ 523 539 adhs->cap.ess = 0; 524 540 adhs->cap.ibss = 1; 525 - pbssdesc->cap.ibss = 1; 526 541 527 542 /* probedelay */ 528 543 adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); 529 544 530 545 /* set up privacy in adapter->scantable[i] */ 531 - if (adapter->secinfo.wep_enabled) { 532 - lbs_pr_debug(1, "ADHOC_S_CMD: WEP enabled, setting privacy on\n"); 533 - pbssdesc->privacy = wlan802_11privfilter8021xWEP; 546 + if (assoc_req->secinfo.wep_enabled) { 547 + lbs_deb_join("ADHOC_S_CMD: WEP enabled, setting privacy on\n"); 534 548 adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; 535 549 } else { 536 - lbs_pr_debug(1, "ADHOC_S_CMD: WEP disabled, setting privacy off\n"); 537 - pbssdesc->privacy = wlan802_11privfilteracceptall; 550 + lbs_deb_join("ADHOC_S_CMD: WEP disabled, setting privacy off\n"); 538 551 } 539 552 540 553 memset(adhs->datarate, 0, sizeof(adhs->datarate)); ··· 551 574 memcpy(&adapter->curbssparams.datarates, 552 575 &adhs->datarate, adapter->curbssparams.numofrates); 553 576 554 - lbs_pr_debug(1, "ADHOC_S_CMD: rates=%02x %02x %02x %02x \n", 577 + lbs_deb_join("ADHOC_S_CMD: rates=%02x %02x %02x %02x \n", 555 578 adhs->datarate[0], adhs->datarate[1], 556 579 adhs->datarate[2], adhs->datarate[3]); 557 580 558 - lbs_pr_debug(1, "ADHOC_S_CMD: AD HOC Start command is ready\n"); 581 + lbs_deb_join("ADHOC_S_CMD: AD HOC Start command is ready\n"); 559 582 560 583 if (libertas_create_dnld_countryinfo_11d(priv)) { 561 - lbs_pr_debug(1, "ADHOC_S_CMD: dnld_countryinfo_11d failed\n"); 584 + lbs_deb_join("ADHOC_S_CMD: dnld_countryinfo_11d failed\n"); 562 585 ret = -1; 563 586 goto done; 564 587 } 565 588 566 - cmd->size = 567 - cpu_to_le16(sizeof(struct cmd_ds_802_11_ad_hoc_start) 568 - + S_DS_GEN + cmdappendsize); 569 - 570 - memcpy(&tmpcap, &adhs->cap, sizeof(u16)); 571 - tmpcap = cpu_to_le16(tmpcap); 572 - memcpy(&adhs->cap, &tmpcap, sizeof(u16)); 589 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ad_hoc_start) + 590 + S_DS_GEN + cmdappendsize); 573 591 574 592 ret = 0; 575 593 done: 576 - LEAVE(); 594 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 577 595 return ret; 578 596 } 579 597 ··· 586 614 { 587 615 wlan_adapter *adapter = priv->adapter; 588 616 struct cmd_ds_802_11_ad_hoc_join *padhocjoin = &cmd->params.adj; 589 - struct bss_descriptor *pbssdesc = pdata_buf; 617 + struct assoc_request * assoc_req = pdata_buf; 618 + struct bss_descriptor *bss = &assoc_req->bss; 590 619 int cmdappendsize = 0; 591 620 int ret = 0; 592 621 u8 *card_rates; ··· 595 622 u16 tmpcap; 596 623 int i; 597 624 598 - ENTER(); 599 - 600 - adapter->pattemptedbssdesc = pbssdesc; 625 + lbs_deb_enter(LBS_DEB_JOIN); 601 626 602 627 cmd->command = cpu_to_le16(cmd_802_11_ad_hoc_join); 603 628 604 629 padhocjoin->bssdescriptor.bsstype = cmd_bss_type_ibss; 605 630 606 - padhocjoin->bssdescriptor.beaconperiod = pbssdesc->beaconperiod; 631 + padhocjoin->bssdescriptor.beaconperiod = cpu_to_le16(bss->beaconperiod); 607 632 608 - memcpy(&padhocjoin->bssdescriptor.BSSID, 609 - &pbssdesc->macaddress, ETH_ALEN); 610 - 611 - memcpy(&padhocjoin->bssdescriptor.SSID, 612 - &pbssdesc->ssid.ssid, pbssdesc->ssid.ssidlength); 633 + memcpy(&padhocjoin->bssdescriptor.BSSID, &bss->bssid, ETH_ALEN); 634 + memcpy(&padhocjoin->bssdescriptor.SSID, &bss->ssid, bss->ssid_len); 613 635 614 636 memcpy(&padhocjoin->bssdescriptor.phyparamset, 615 - &pbssdesc->phyparamset, sizeof(union ieeetypes_phyparamset)); 637 + &bss->phyparamset, sizeof(union ieeetypes_phyparamset)); 616 638 617 639 memcpy(&padhocjoin->bssdescriptor.ssparamset, 618 - &pbssdesc->ssparamset, sizeof(union IEEEtypes_ssparamset)); 640 + &bss->ssparamset, sizeof(union IEEEtypes_ssparamset)); 619 641 620 - memcpy(&tmpcap, &pbssdesc->cap, sizeof(struct ieeetypes_capinfo)); 642 + memcpy(&tmpcap, &bss->cap, sizeof(struct ieeetypes_capinfo)); 621 643 tmpcap &= CAPINFO_MASK; 622 644 623 - lbs_pr_debug(1, "ADHOC_J_CMD: tmpcap=%4X CAPINFO_MASK=%4X\n", 645 + lbs_deb_join("ADHOC_J_CMD: tmpcap=%4X CAPINFO_MASK=%4X\n", 624 646 tmpcap, CAPINFO_MASK); 625 647 memcpy(&padhocjoin->bssdescriptor.cap, &tmpcap, 626 648 sizeof(struct ieeetypes_capinfo)); 627 649 628 650 /* information on BSSID descriptor passed to FW */ 629 - lbs_pr_debug(1, 630 - "ADHOC_J_CMD: BSSID = %2x-%2x-%2x-%2x-%2x-%2x, SSID = %s\n", 631 - padhocjoin->bssdescriptor.BSSID[0], 632 - padhocjoin->bssdescriptor.BSSID[1], 633 - padhocjoin->bssdescriptor.BSSID[2], 634 - padhocjoin->bssdescriptor.BSSID[3], 635 - padhocjoin->bssdescriptor.BSSID[4], 636 - padhocjoin->bssdescriptor.BSSID[5], 651 + lbs_deb_join( 652 + "ADHOC_J_CMD: BSSID = " MAC_FMT ", SSID = '%s'\n", 653 + MAC_ARG(padhocjoin->bssdescriptor.BSSID), 637 654 padhocjoin->bssdescriptor.SSID); 638 655 639 656 /* failtimeout */ 640 657 padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); 641 658 642 659 /* probedelay */ 643 - padhocjoin->probedelay = 644 - cpu_to_le16(cmd_scan_probe_delay_time); 660 + padhocjoin->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); 645 661 646 662 /* Copy Data rates from the rates recorded in scan response */ 647 663 memset(padhocjoin->bssdescriptor.datarates, 0, 648 664 sizeof(padhocjoin->bssdescriptor.datarates)); 649 - memcpy(padhocjoin->bssdescriptor.datarates, pbssdesc->datarates, 665 + memcpy(padhocjoin->bssdescriptor.datarates, bss->datarates, 650 666 min(sizeof(padhocjoin->bssdescriptor.datarates), 651 - sizeof(pbssdesc->datarates))); 667 + sizeof(bss->datarates))); 652 668 653 669 card_rates = libertas_supported_rates; 654 670 card_rates_size = sizeof(libertas_supported_rates); 655 671 656 - adapter->curbssparams.channel = pbssdesc->channel; 672 + adapter->curbssparams.channel = bss->channel; 657 673 658 674 if (get_common_rates(adapter, padhocjoin->bssdescriptor.datarates, 659 675 sizeof(padhocjoin->bssdescriptor.datarates), 660 676 card_rates, card_rates_size)) { 661 - lbs_pr_debug(1, "ADHOC_J_CMD: get_common_rates returns error.\n"); 677 + lbs_deb_join("ADHOC_J_CMD: get_common_rates returns error.\n"); 662 678 ret = -1; 663 679 goto done; 664 680 } ··· 666 704 adapter->curbssparams.numofrates); 667 705 668 706 padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = 669 - cpu_to_le16(pbssdesc->atimwindow); 707 + cpu_to_le16(bss->atimwindow); 670 708 671 - if (adapter->secinfo.wep_enabled) { 709 + if (assoc_req->secinfo.wep_enabled) { 672 710 padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; 673 711 } 674 712 675 713 if (adapter->psmode == wlan802_11powermodemax_psp) { 676 714 /* wake up first */ 677 - enum WLAN_802_11_POWER_MODE Localpsmode; 715 + __le32 Localpsmode; 678 716 679 - Localpsmode = wlan802_11powermodecam; 717 + Localpsmode = cpu_to_le32(wlan802_11powermodecam); 680 718 ret = libertas_prepare_and_send_command(priv, 681 719 cmd_802_11_ps_mode, 682 720 cmd_act_set, ··· 688 726 } 689 727 } 690 728 691 - if (libertas_parse_dnld_countryinfo_11d(priv)) { 729 + if (libertas_parse_dnld_countryinfo_11d(priv, bss)) { 692 730 ret = -1; 693 731 goto done; 694 732 } 695 733 696 - cmd->size = 697 - cpu_to_le16(sizeof(struct cmd_ds_802_11_ad_hoc_join) 698 - + S_DS_GEN + cmdappendsize); 734 + cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ad_hoc_join) + 735 + S_DS_GEN + cmdappendsize); 699 736 700 - memcpy(&tmpcap, &padhocjoin->bssdescriptor.cap, 701 - sizeof(struct ieeetypes_capinfo)); 702 - tmpcap = cpu_to_le16(tmpcap); 703 - 704 - memcpy(&padhocjoin->bssdescriptor.cap, 705 - &tmpcap, sizeof(struct ieeetypes_capinfo)); 706 - 707 - done: 708 - LEAVE(); 737 + done: 738 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 709 739 return ret; 710 740 } 711 741 ··· 708 754 int ret = 0; 709 755 union iwreq_data wrqu; 710 756 struct ieeetypes_assocrsp *passocrsp; 711 - struct bss_descriptor *pbssdesc; 757 + struct bss_descriptor * bss; 712 758 713 - ENTER(); 759 + lbs_deb_enter(LBS_DEB_JOIN); 760 + 761 + if (!adapter->in_progress_assoc_req) { 762 + lbs_deb_join("ASSOC_RESP: no in-progress association request\n"); 763 + ret = -1; 764 + goto done; 765 + } 766 + bss = &adapter->in_progress_assoc_req->bss; 714 767 715 768 passocrsp = (struct ieeetypes_assocrsp *) & resp->params; 716 769 717 - if (passocrsp->statuscode) { 718 - 770 + if (le16_to_cpu(passocrsp->statuscode)) { 719 771 libertas_mac_event_disconnected(priv); 720 772 721 - lbs_pr_debug(1, 722 - "ASSOC_RESP: Association failed, status code = %d\n", 723 - passocrsp->statuscode); 773 + lbs_deb_join("ASSOC_RESP: Association failed, status code = %d\n", 774 + le16_to_cpu(passocrsp->statuscode)); 724 775 725 776 ret = -1; 726 777 goto done; ··· 737 778 /* Send a Media Connected event, according to the Spec */ 738 779 adapter->connect_status = libertas_connected; 739 780 740 - /* Set the attempted BSSID Index to current */ 741 - pbssdesc = adapter->pattemptedbssdesc; 781 + lbs_deb_join("ASSOC_RESP: assocated to '%s'\n", 782 + escape_essid(bss->ssid, bss->ssid_len)); 742 783 743 - lbs_pr_debug(1, "ASSOC_RESP: %s\n", pbssdesc->ssid.ssid); 784 + /* Update current SSID and BSSID */ 785 + memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); 786 + adapter->curbssparams.ssid_len = bss->ssid_len; 787 + memcpy(adapter->curbssparams.bssid, bss->bssid, ETH_ALEN); 744 788 745 - /* Set the new SSID to current SSID */ 746 - memcpy(&adapter->curbssparams.ssid, 747 - &pbssdesc->ssid, sizeof(struct WLAN_802_11_SSID)); 748 - 749 - /* Set the new BSSID (AP's MAC address) to current BSSID */ 750 - memcpy(adapter->curbssparams.bssid, 751 - pbssdesc->macaddress, ETH_ALEN); 752 - 753 - /* Make a copy of current BSSID descriptor */ 754 - memcpy(&adapter->curbssparams.bssdescriptor, 755 - pbssdesc, sizeof(struct bss_descriptor)); 756 - 757 - lbs_pr_debug(1, "ASSOC_RESP: currentpacketfilter is %x\n", 789 + lbs_deb_join("ASSOC_RESP: currentpacketfilter is %x\n", 758 790 adapter->currentpacketfilter); 759 791 760 792 adapter->SNR[TYPE_RXPD][TYPE_AVG] = 0; ··· 756 806 adapter->nextSNRNF = 0; 757 807 adapter->numSNRNF = 0; 758 808 759 - netif_carrier_on(priv->wlan_dev.netdev); 760 - netif_wake_queue(priv->wlan_dev.netdev); 809 + netif_carrier_on(priv->dev); 810 + netif_wake_queue(priv->dev); 761 811 762 - lbs_pr_debug(1, "ASSOC_RESP: Associated \n"); 812 + netif_carrier_on(priv->mesh_dev); 813 + netif_wake_queue(priv->mesh_dev); 814 + 815 + lbs_deb_join("ASSOC_RESP: Associated \n"); 763 816 764 817 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN); 765 818 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 766 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL); 819 + wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 767 820 768 - done: 769 - LEAVE(); 821 + done: 822 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 770 823 return ret; 771 824 } 772 825 773 826 int libertas_ret_80211_disassociate(wlan_private * priv, 774 827 struct cmd_ds_command *resp) 775 828 { 776 - ENTER(); 829 + lbs_deb_enter(LBS_DEB_JOIN); 777 830 778 831 libertas_mac_event_disconnected(priv); 779 832 780 - LEAVE(); 833 + lbs_deb_leave(LBS_DEB_JOIN); 781 834 return 0; 782 835 } 783 836 ··· 793 840 u16 result = le16_to_cpu(resp->result); 794 841 struct cmd_ds_802_11_ad_hoc_result *padhocresult; 795 842 union iwreq_data wrqu; 796 - struct bss_descriptor *pbssdesc; 843 + struct bss_descriptor *bss; 797 844 798 - ENTER(); 845 + lbs_deb_enter(LBS_DEB_JOIN); 799 846 800 847 padhocresult = &resp->params.result; 801 848 802 - lbs_pr_debug(1, "ADHOC_S_RESP: size = %d\n", le16_to_cpu(resp->size)); 803 - lbs_pr_debug(1, "ADHOC_S_RESP: command = %x\n", command); 804 - lbs_pr_debug(1, "ADHOC_S_RESP: result = %x\n", result); 849 + lbs_deb_join("ADHOC_RESP: size = %d\n", le16_to_cpu(resp->size)); 850 + lbs_deb_join("ADHOC_RESP: command = %x\n", command); 851 + lbs_deb_join("ADHOC_RESP: result = %x\n", result); 805 852 806 - pbssdesc = adapter->pattemptedbssdesc; 853 + if (!adapter->in_progress_assoc_req) { 854 + lbs_deb_join("ADHOC_RESP: no in-progress association request\n"); 855 + ret = -1; 856 + goto done; 857 + } 858 + bss = &adapter->in_progress_assoc_req->bss; 807 859 808 860 /* 809 861 * Join result code 0 --> SUCCESS 810 862 */ 811 863 if (result) { 812 - lbs_pr_debug(1, "ADHOC_RESP failed\n"); 864 + lbs_deb_join("ADHOC_RESP: failed\n"); 813 865 if (adapter->connect_status == libertas_connected) { 814 866 libertas_mac_event_disconnected(priv); 815 867 } 816 - 817 - memset(&adapter->curbssparams.bssdescriptor, 818 - 0x00, sizeof(adapter->curbssparams.bssdescriptor)); 819 - 820 - LEAVE(); 821 - return -1; 868 + ret = -1; 869 + goto done; 822 870 } 823 871 824 872 /* 825 873 * Now the join cmd should be successful 826 874 * If BSSID has changed use SSID to compare instead of BSSID 827 875 */ 828 - lbs_pr_debug(1, "ADHOC_J_RESP %s\n", pbssdesc->ssid.ssid); 876 + lbs_deb_join("ADHOC_RESP: associated to '%s'\n", 877 + escape_essid(bss->ssid, bss->ssid_len)); 829 878 830 879 /* Send a Media Connected event, according to the Spec */ 831 880 adapter->connect_status = libertas_connected; 832 881 833 882 if (command == cmd_ret_802_11_ad_hoc_start) { 834 883 /* Update the created network descriptor with the new BSSID */ 835 - memcpy(pbssdesc->macaddress, 836 - padhocresult->BSSID, ETH_ALEN); 837 - } else { 838 - 839 - /* Make a copy of current BSSID descriptor, only needed for join since 840 - * the current descriptor is already being used for adhoc start 841 - */ 842 - memmove(&adapter->curbssparams.bssdescriptor, 843 - pbssdesc, sizeof(struct bss_descriptor)); 884 + memcpy(bss->bssid, padhocresult->BSSID, ETH_ALEN); 844 885 } 845 886 846 887 /* Set the BSSID from the joined/started descriptor */ 847 - memcpy(&adapter->curbssparams.bssid, 848 - pbssdesc->macaddress, ETH_ALEN); 888 + memcpy(&adapter->curbssparams.bssid, bss->bssid, ETH_ALEN); 849 889 850 890 /* Set the new SSID to current SSID */ 851 - memcpy(&adapter->curbssparams.ssid, 852 - &pbssdesc->ssid, sizeof(struct WLAN_802_11_SSID)); 891 + memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); 892 + adapter->curbssparams.ssid_len = bss->ssid_len; 853 893 854 - netif_carrier_on(priv->wlan_dev.netdev); 855 - netif_wake_queue(priv->wlan_dev.netdev); 894 + netif_carrier_on(priv->dev); 895 + netif_wake_queue(priv->dev); 896 + 897 + netif_carrier_on(priv->mesh_dev); 898 + netif_wake_queue(priv->mesh_dev); 856 899 857 900 memset(&wrqu, 0, sizeof(wrqu)); 858 901 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN); 859 902 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 860 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL); 903 + wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 861 904 862 - lbs_pr_debug(1, "ADHOC_RESP: - Joined/Started Ad Hoc\n"); 863 - lbs_pr_debug(1, "ADHOC_RESP: channel = %d\n", adapter->adhocchannel); 864 - lbs_pr_debug(1, "ADHOC_RESP: BSSID = %02x:%02x:%02x:%02x:%02x:%02x\n", 865 - padhocresult->BSSID[0], padhocresult->BSSID[1], 866 - padhocresult->BSSID[2], padhocresult->BSSID[3], 867 - padhocresult->BSSID[4], padhocresult->BSSID[5]); 905 + lbs_deb_join("ADHOC_RESP: - Joined/Started Ad Hoc\n"); 906 + lbs_deb_join("ADHOC_RESP: channel = %d\n", adapter->curbssparams.channel); 907 + lbs_deb_join("ADHOC_RESP: BSSID = " MAC_FMT "\n", 908 + MAC_ARG(padhocresult->BSSID)); 868 909 869 - LEAVE(); 910 + done: 911 + lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret); 870 912 return ret; 871 913 } 872 914 873 915 int libertas_ret_80211_ad_hoc_stop(wlan_private * priv, 874 916 struct cmd_ds_command *resp) 875 917 { 876 - ENTER(); 918 + lbs_deb_enter(LBS_DEB_JOIN); 877 919 878 920 libertas_mac_event_disconnected(priv); 879 921 880 - LEAVE(); 922 + lbs_deb_leave(LBS_DEB_JOIN); 881 923 return 0; 882 924 }
+6 -7
drivers/net/wireless/libertas/join.h
··· 9 9 #define _WLAN_JOIN_H 10 10 11 11 #include "defs.h" 12 + #include "dev.h" 12 13 13 14 struct cmd_ds_command; 14 15 extern int libertas_cmd_80211_authenticate(wlan_private * priv, ··· 22 21 struct cmd_ds_command *cmd); 23 22 extern int libertas_cmd_80211_ad_hoc_start(wlan_private * priv, 24 23 struct cmd_ds_command *cmd, 25 - void *pssid); 24 + void *pdata_buf); 26 25 extern int libertas_cmd_80211_deauthenticate(wlan_private * priv, 27 26 struct cmd_ds_command *cmd); 28 27 extern int libertas_cmd_80211_associate(wlan_private * priv, ··· 40 39 41 40 extern int libertas_reassociation_thread(void *data); 42 41 43 - struct WLAN_802_11_SSID; 44 - struct bss_descriptor; 45 - 46 42 extern int libertas_start_adhoc_network(wlan_private * priv, 47 - struct WLAN_802_11_SSID *adhocssid); 48 - extern int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor *pbssdesc); 43 + struct assoc_request * assoc_req); 44 + extern int libertas_join_adhoc_network(wlan_private * priv, 45 + struct assoc_request * assoc_req); 49 46 extern int libertas_stop_adhoc_network(wlan_private * priv); 50 47 51 48 extern int libertas_send_deauthentication(wlan_private * priv); ··· 51 52 52 53 extern int libertas_do_adhocstop_ioctl(wlan_private * priv); 53 54 54 - int wlan_associate(wlan_private * priv, struct bss_descriptor * pbssdesc); 55 + int wlan_associate(wlan_private * priv, struct assoc_request * assoc_req); 55 56 56 57 #endif
+307 -391
drivers/net/wireless/libertas/main.c
··· 4 4 * thread etc.. 5 5 */ 6 6 7 + #include <linux/moduleparam.h> 7 8 #include <linux/delay.h> 8 9 #include <linux/freezer.h> 9 10 #include <linux/etherdevice.h> ··· 12 11 #include <linux/if_arp.h> 13 12 14 13 #include <net/iw_handler.h> 14 + #include <net/ieee80211.h> 15 15 16 16 #include "host.h" 17 - #include "sbi.h" 18 17 #include "decl.h" 19 18 #include "dev.h" 20 - #include "fw.h" 21 19 #include "wext.h" 22 20 #include "debugfs.h" 23 21 #include "assoc.h" 24 22 25 - #define DRIVER_RELEASE_VERSION "320.p0" 23 + #define DRIVER_RELEASE_VERSION "322.p0" 26 24 const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION 27 25 #ifdef DEBUG 28 26 "-dbg" 29 27 #endif 30 28 ""; 31 29 32 - #ifdef ENABLE_PM 33 - static struct pm_dev *wlan_pm_dev = NULL; 34 - #endif 30 + 31 + /* Module parameters */ 32 + unsigned int libertas_debug = 0; 33 + module_param(libertas_debug, int, 0644); 34 + EXPORT_SYMBOL_GPL(libertas_debug); 35 + 35 36 36 37 #define WLAN_TX_PWR_DEFAULT 20 /*100mW */ 37 38 #define WLAN_TX_PWR_US_DEFAULT 20 /*100mW */ ··· 149 146 }; 150 147 151 148 /** 152 - * the rates supported by the card 153 - */ 154 - u8 libertas_wlan_data_rates[WLAN_SUPPORTED_RATES] = 155 - { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12, 156 - 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00 157 - }; 158 - 159 - /** 160 149 * the rates supported 161 150 */ 162 151 u8 libertas_supported_rates[G_SUPPORTED_RATES] = ··· 168 173 u8 libertas_adhoc_rates_b[4] = { 0x82, 0x84, 0x8b, 0x96 }; 169 174 170 175 /** 171 - * the global variable of a pointer to wlan_private 172 - * structure variable 173 - */ 174 - static wlan_private *wlanpriv = NULL; 175 - 176 - #define MAX_DEVS 5 177 - static struct net_device *libertas_devs[MAX_DEVS]; 178 - static int libertas_found = 0; 179 - 180 - /** 181 176 * the table to keep region code 182 177 */ 183 178 u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE] = 184 179 { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 }; 185 - 186 - static u8 *default_fw_name = "usb8388.bin"; 187 180 188 181 /** 189 182 * Attributes exported through sysfs 190 183 */ 191 184 192 185 /** 193 - * @brief Get function for sysfs attribute libertas_mpp 186 + * @brief Get function for sysfs attribute anycast_mask 194 187 */ 195 - static ssize_t libertas_mpp_get(struct device * dev, 188 + static ssize_t libertas_anycast_get(struct device * dev, 196 189 struct device_attribute *attr, char * buf) { 197 190 struct cmd_ds_mesh_access mesh_access; 198 191 199 192 memset(&mesh_access, 0, sizeof(mesh_access)); 200 193 libertas_prepare_and_send_command(to_net_dev(dev)->priv, 201 194 cmd_mesh_access, 202 - cmd_act_mesh_get_mpp, 195 + cmd_act_mesh_get_anycast, 203 196 cmd_option_waitforrsp, 0, (void *)&mesh_access); 204 197 205 - return snprintf(buf, 3, "%d\n", mesh_access.data[0]); 198 + return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0])); 206 199 } 207 200 208 201 /** 209 - * @brief Set function for sysfs attribute libertas_mpp 202 + * @brief Set function for sysfs attribute anycast_mask 210 203 */ 211 - static ssize_t libertas_mpp_set(struct device * dev, 204 + static ssize_t libertas_anycast_set(struct device * dev, 212 205 struct device_attribute *attr, const char * buf, size_t count) { 213 206 struct cmd_ds_mesh_access mesh_access; 214 - 207 + uint32_t datum; 215 208 216 209 memset(&mesh_access, 0, sizeof(mesh_access)); 217 - sscanf(buf, "%d", &(mesh_access.data[0])); 210 + sscanf(buf, "%x", &datum); 211 + mesh_access.data[0] = cpu_to_le32(datum); 212 + 218 213 libertas_prepare_and_send_command((to_net_dev(dev))->priv, 219 214 cmd_mesh_access, 220 - cmd_act_mesh_set_mpp, 215 + cmd_act_mesh_set_anycast, 221 216 cmd_option_waitforrsp, 0, (void *)&mesh_access); 222 217 return strlen(buf); 223 218 } 224 219 225 220 /** 226 - * libertas_mpp attribute to be exported per mshX interface 227 - * through sysfs (/sys/class/net/mshX/libertas-mpp) 221 + * anycast_mask attribute to be exported per mshX interface 222 + * through sysfs (/sys/class/net/mshX/anycast_mask) 228 223 */ 229 - static DEVICE_ATTR(libertas_mpp, 0644, libertas_mpp_get, 230 - libertas_mpp_set ); 224 + static DEVICE_ATTR(anycast_mask, 0644, libertas_anycast_get, libertas_anycast_set); 231 225 232 226 /** 233 227 * @brief Check if the device can be open and wait if necessary. ··· 229 245 * function to work around the issue. 230 246 * 231 247 */ 232 - static int pre_open_check(struct net_device *dev) { 248 + static int pre_open_check(struct net_device *dev) 249 + { 233 250 wlan_private *priv = (wlan_private *) dev->priv; 234 251 wlan_adapter *adapter = priv->adapter; 235 252 int i = 0; ··· 240 255 msleep_interruptible(100); 241 256 } 242 257 if (!adapter->fw_ready) { 243 - lbs_pr_info("FW not ready, pre_open_check() return failure\n"); 244 - LEAVE(); 258 + lbs_pr_err("firmware not ready\n"); 245 259 return -1; 246 260 } 247 261 ··· 258 274 wlan_private *priv = (wlan_private *) dev->priv; 259 275 wlan_adapter *adapter = priv->adapter; 260 276 261 - ENTER(); 262 - 277 + lbs_deb_enter(LBS_DEB_NET); 263 278 264 279 priv->open = 1; 265 280 266 281 if (adapter->connect_status == libertas_connected) { 267 - netif_carrier_on(priv->wlan_dev.netdev); 268 - } else 269 - netif_carrier_off(priv->wlan_dev.netdev); 282 + netif_carrier_on(priv->dev); 283 + netif_carrier_on(priv->mesh_dev); 284 + } else { 285 + netif_carrier_off(priv->dev); 286 + netif_carrier_off(priv->mesh_dev); 287 + } 270 288 271 - LEAVE(); 289 + lbs_deb_leave(LBS_DEB_NET); 272 290 return 0; 273 291 } 274 292 /** ··· 283 297 { 284 298 wlan_private *priv = (wlan_private *) dev->priv ; 285 299 286 - if(pre_open_check(dev) == -1) 300 + if (pre_open_check(dev) == -1) 287 301 return -1; 288 302 priv->mesh_open = 1 ; 289 - netif_start_queue(priv->mesh_dev); 303 + netif_wake_queue(priv->mesh_dev); 290 304 if (priv->infra_open == 0) 291 - return wlan_dev_open(priv->wlan_dev.netdev) ; 305 + return wlan_dev_open(priv->dev) ; 292 306 return 0; 293 307 } 294 308 ··· 305 319 if(pre_open_check(dev) == -1) 306 320 return -1; 307 321 priv->infra_open = 1 ; 308 - netif_wake_queue(priv->wlan_dev.netdev); 322 + netif_wake_queue(priv->dev); 309 323 if (priv->open == 0) 310 - return wlan_dev_open(priv->wlan_dev.netdev) ; 324 + return wlan_dev_open(priv->dev) ; 311 325 return 0; 312 326 } 313 327 ··· 315 329 { 316 330 wlan_private *priv = dev->priv; 317 331 318 - ENTER(); 332 + lbs_deb_enter(LBS_DEB_NET); 319 333 320 - netif_carrier_off(priv->wlan_dev.netdev); 334 + netif_carrier_off(priv->dev); 321 335 priv->open = 0; 322 336 323 - LEAVE(); 337 + lbs_deb_leave(LBS_DEB_NET); 324 338 return 0; 325 339 } 326 340 ··· 337 351 priv->mesh_open = 0; 338 352 netif_stop_queue(priv->mesh_dev); 339 353 if (priv->infra_open == 0) 340 - return wlan_dev_close( ((wlan_private *) dev->priv)->wlan_dev.netdev) ; 354 + return wlan_dev_close(dev); 341 355 else 342 356 return 0; 343 357 } ··· 348 362 * @param dev A pointer to net_device structure 349 363 * @return 0 350 364 */ 351 - static int wlan_close(struct net_device *dev) { 365 + static int wlan_close(struct net_device *dev) 366 + { 352 367 wlan_private *priv = (wlan_private *) dev->priv; 353 368 354 - netif_stop_queue(priv->wlan_dev.netdev); 369 + netif_stop_queue(dev); 355 370 priv->infra_open = 0; 356 371 if (priv->mesh_open == 0) 357 - return wlan_dev_close( ((wlan_private *) dev->priv)->wlan_dev.netdev) ; 372 + return wlan_dev_close(dev); 358 373 else 359 374 return 0; 360 375 } 361 376 362 - 363 - #ifdef ENABLE_PM 364 - 365 - /** 366 - * @brief This function is a callback function. it is called by 367 - * kernel to enter or exit power saving mode. 368 - * 369 - * @param pmdev A pointer to pm_dev 370 - * @param pmreq pm_request_t 371 - * @param pmdata A pointer to pmdata 372 - * @return 0 or -1 373 - */ 374 - static int wlan_pm_callback(struct pm_dev *pmdev, pm_request_t pmreq, 375 - void *pmdata) 376 - { 377 - wlan_private *priv = wlanpriv; 378 - wlan_adapter *adapter = priv->adapter; 379 - struct net_device *dev = priv->wlan_dev.netdev; 380 - 381 - lbs_pr_debug(1, "WPRM_PM_CALLBACK: pmreq = %d.\n", pmreq); 382 - 383 - switch (pmreq) { 384 - case PM_SUSPEND: 385 - lbs_pr_debug(1, "WPRM_PM_CALLBACK: enter PM_SUSPEND.\n"); 386 - 387 - /* in associated mode */ 388 - if (adapter->connect_status == libertas_connected) { 389 - if ((adapter->psstate != PS_STATE_SLEEP) 390 - ) { 391 - lbs_pr_debug(1, 392 - "wlan_pm_callback: can't enter sleep mode\n"); 393 - return -1; 394 - } else { 395 - 396 - /* 397 - * Detach the network interface 398 - * if the network is running 399 - */ 400 - if (netif_running(dev)) { 401 - netif_device_detach(dev); 402 - lbs_pr_debug(1, 403 - "netif_device_detach().\n"); 404 - } 405 - libertas_sbi_suspend(priv); 406 - } 407 - break; 408 - } 409 - 410 - /* in non associated mode */ 411 - 412 - /* 413 - * Detach the network interface 414 - * if the network is running 415 - */ 416 - if (netif_running(dev)) 417 - netif_device_detach(dev); 418 - 419 - /* 420 - * Storing and restoring of the regs be taken care 421 - * at the driver rest will be done at wlan driver 422 - * this makes driver independent of the card 423 - */ 424 - 425 - libertas_sbi_suspend(priv); 426 - 427 - break; 428 - 429 - case PM_RESUME: 430 - /* in associated mode */ 431 - if (adapter->connect_status == libertas_connected) { 432 - { 433 - /* 434 - * Bring the inteface up first 435 - * This case should not happen still ... 436 - */ 437 - libertas_sbi_resume(priv); 438 - 439 - /* 440 - * Attach the network interface 441 - * if the network is running 442 - */ 443 - if (netif_running(dev)) { 444 - netif_device_attach(dev); 445 - lbs_pr_debug(1, 446 - "after netif_device_attach().\n"); 447 - } 448 - lbs_pr_debug(1, 449 - "After netif attach, in associated mode.\n"); 450 - } 451 - break; 452 - } 453 - 454 - /* in non associated mode */ 455 - 456 - /* 457 - * Bring the inteface up first 458 - * This case should not happen still ... 459 - */ 460 - 461 - libertas_sbi_resume(priv); 462 - 463 - if (netif_running(dev)) 464 - netif_device_attach(dev); 465 - 466 - lbs_pr_debug(1, "after netif attach, in NON associated mode.\n"); 467 - break; 468 - } 469 - 470 - return 0; 471 - } 472 - #endif /* ENABLE_PM */ 473 377 474 378 static int wlan_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 475 379 { 476 380 int ret = 0; 477 381 wlan_private *priv = dev->priv; 478 382 479 - ENTER(); 383 + lbs_deb_enter(LBS_DEB_NET); 480 384 481 - if (priv->wlan_dev.dnld_sent || priv->adapter->TxLockFlag) { 385 + if (priv->dnld_sent || priv->adapter->TxLockFlag) { 482 386 priv->stats.tx_dropped++; 483 387 goto done; 484 388 } 485 389 486 - netif_stop_queue(priv->wlan_dev.netdev); 390 + netif_stop_queue(priv->dev); 391 + netif_stop_queue(priv->mesh_dev); 487 392 488 393 if (libertas_process_tx(priv, skb) == 0) 489 394 dev->trans_start = jiffies; 490 395 done: 491 - LEAVE(); 396 + lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); 492 397 return ret; 493 398 } 494 399 ··· 390 513 static int mesh_pre_start_xmit(struct sk_buff *skb, struct net_device *dev) 391 514 { 392 515 wlan_private *priv = dev->priv; 393 - ENTER(); 394 - SET_MESH_FRAME(skb); 395 - LEAVE(); 516 + int ret; 396 517 397 - return wlan_hard_start_xmit(skb, priv->wlan_dev.netdev); 518 + lbs_deb_enter(LBS_DEB_MESH); 519 + 520 + SET_MESH_FRAME(skb); 521 + 522 + ret = wlan_hard_start_xmit(skb, priv->dev); 523 + lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); 524 + return ret; 398 525 } 399 526 400 527 /** 401 528 * @brief Mark non-mesh packets and handover them to wlan_hard_start_xmit 402 529 * 403 530 */ 404 - static int wlan_pre_start_xmit(struct sk_buff *skb, struct net_device *dev) { 405 - ENTER(); 531 + static int wlan_pre_start_xmit(struct sk_buff *skb, struct net_device *dev) 532 + { 533 + int ret; 534 + 535 + lbs_deb_enter(LBS_DEB_NET); 536 + 406 537 UNSET_MESH_FRAME(skb); 407 - LEAVE(); 408 - return wlan_hard_start_xmit(skb, dev); 538 + 539 + ret = wlan_hard_start_xmit(skb, dev); 540 + lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); 541 + return ret; 409 542 } 410 543 411 544 static void wlan_tx_timeout(struct net_device *dev) 412 545 { 413 546 wlan_private *priv = (wlan_private *) dev->priv; 414 547 415 - ENTER(); 548 + lbs_deb_enter(LBS_DEB_TX); 416 549 417 - lbs_pr_err("tx watch dog timeout!\n"); 550 + lbs_pr_err("tx watch dog timeout\n"); 418 551 419 - priv->wlan_dev.dnld_sent = DNLD_RES_RECEIVED; 552 + priv->dnld_sent = DNLD_RES_RECEIVED; 420 553 dev->trans_start = jiffies; 421 554 422 555 if (priv->adapter->currenttxskb) { ··· 437 550 libertas_send_tx_feedback(priv); 438 551 } else 439 552 wake_up_interruptible(&priv->mainthread.waitq); 440 - } else if (priv->adapter->connect_status == libertas_connected) 441 - netif_wake_queue(priv->wlan_dev.netdev); 553 + } else if (priv->adapter->connect_status == libertas_connected) { 554 + netif_wake_queue(priv->dev); 555 + netif_wake_queue(priv->mesh_dev); 556 + } 442 557 443 - LEAVE(); 558 + lbs_deb_leave(LBS_DEB_TX); 444 559 } 445 560 446 561 /** ··· 465 576 wlan_adapter *adapter = priv->adapter; 466 577 struct sockaddr *phwaddr = addr; 467 578 468 - ENTER(); 579 + lbs_deb_enter(LBS_DEB_NET); 580 + 581 + /* In case it was called from the mesh device */ 582 + dev = priv->dev ; 469 583 470 584 memset(adapter->current_addr, 0, ETH_ALEN); 471 585 ··· 483 591 cmd_option_waitforrsp, 0, NULL); 484 592 485 593 if (ret) { 486 - lbs_pr_debug(1, "set mac address failed.\n"); 594 + lbs_deb_net("set MAC address failed\n"); 487 595 ret = -1; 488 596 goto done; 489 597 } 490 598 491 599 lbs_dbg_hex("adapter->macaddr:", adapter->current_addr, ETH_ALEN); 492 600 memcpy(dev->dev_addr, adapter->current_addr, ETH_ALEN); 493 - memcpy(((wlan_private *) dev->priv)->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); 601 + if (priv->mesh_dev) 602 + memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); 494 603 495 604 done: 496 - LEAVE(); 605 + lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); 497 606 return ret; 498 607 } 499 608 ··· 519 626 wlan_adapter *adapter = priv->adapter; 520 627 int oldpacketfilter; 521 628 522 - ENTER(); 629 + lbs_deb_enter(LBS_DEB_NET); 523 630 524 631 oldpacketfilter = adapter->currentpacketfilter; 525 632 526 633 if (dev->flags & IFF_PROMISC) { 527 - lbs_pr_debug(1, "enable Promiscuous mode\n"); 634 + lbs_deb_net("enable promiscuous mode\n"); 528 635 adapter->currentpacketfilter |= 529 636 cmd_act_mac_promiscuous_enable; 530 637 adapter->currentpacketfilter &= ··· 537 644 538 645 if (dev->flags & IFF_ALLMULTI || dev->mc_count > 539 646 MRVDRV_MAX_MULTICAST_LIST_SIZE) { 540 - lbs_pr_debug(1, "Enabling All Multicast!\n"); 647 + lbs_deb_net( "enabling all multicast\n"); 541 648 adapter->currentpacketfilter |= 542 649 cmd_act_mac_all_multicast_enable; 543 650 adapter->currentpacketfilter &= ··· 547 654 ~cmd_act_mac_all_multicast_enable; 548 655 549 656 if (!dev->mc_count) { 550 - lbs_pr_debug(1, "No multicast addresses - " 551 - "disabling multicast!\n"); 657 + lbs_deb_net("no multicast addresses, " 658 + "disabling multicast\n"); 552 659 adapter->currentpacketfilter &= 553 660 ~cmd_act_mac_multicast_enable; 554 661 } else { ··· 560 667 adapter->nr_of_multicastmacaddr = 561 668 wlan_copy_multicast_address(adapter, dev); 562 669 563 - lbs_pr_debug(1, "Multicast addresses: %d\n", 670 + lbs_deb_net("multicast addresses: %d\n", 564 671 dev->mc_count); 565 672 566 673 for (i = 0; i < dev->mc_count; i++) { 567 - lbs_pr_debug(1, "Multicast address %d:" 568 - "%x %x %x %x %x %x\n", i, 674 + lbs_deb_net("Multicast address %d:" 675 + MAC_FMT "\n", i, 569 676 adapter->multicastlist[i][0], 570 677 adapter->multicastlist[i][1], 571 678 adapter->multicastlist[i][2], ··· 573 680 adapter->multicastlist[i][4], 574 681 adapter->multicastlist[i][5]); 575 682 } 576 - /* set multicast addresses to firmware */ 683 + /* send multicast addresses to firmware */ 577 684 libertas_prepare_and_send_command(priv, 578 685 cmd_mac_multicast_adr, 579 686 cmd_act_set, 0, 0, ··· 586 693 libertas_set_mac_packet_filter(priv); 587 694 } 588 695 589 - LEAVE(); 696 + lbs_deb_leave(LBS_DEB_NET); 590 697 } 591 698 592 699 /** 593 - * @brief This function hanldes the major job in WLAN driver. 594 - * it handles the event generated by firmware, rx data received 595 - * from firmware and tx data sent from kernel. 700 + * @brief This function handles the major jobs in the WLAN driver. 701 + * It handles all events generated by firmware, RX data received 702 + * from firmware and TX data sent from kernel. 596 703 * 597 704 * @param data A pointer to wlan_thread structure 598 705 * @return 0 ··· 605 712 wait_queue_t wait; 606 713 u8 ireg = 0; 607 714 608 - ENTER(); 715 + lbs_deb_enter(LBS_DEB_THREAD); 609 716 610 717 wlan_activate_thread(thread); 611 718 612 719 init_waitqueue_entry(&wait, current); 613 720 614 721 for (;;) { 615 - lbs_pr_debug(1, "main-thread 111: intcounter=%d " 722 + lbs_deb_thread( "main-thread 111: intcounter=%d " 616 723 "currenttxskb=%p dnld_sent=%d\n", 617 724 adapter->intcounter, 618 - adapter->currenttxskb, priv->wlan_dev.dnld_sent); 725 + adapter->currenttxskb, priv->dnld_sent); 619 726 620 727 add_wait_queue(&thread->waitq, &wait); 621 728 set_current_state(TASK_INTERRUPTIBLE); 622 729 spin_lock_irq(&adapter->driver_lock); 623 730 if ((adapter->psstate == PS_STATE_SLEEP) || 624 731 (!adapter->intcounter 625 - && (priv->wlan_dev.dnld_sent || adapter->cur_cmd || 732 + && (priv->dnld_sent || adapter->cur_cmd || 626 733 list_empty(&adapter->cmdpendingq)))) { 627 - lbs_pr_debug(1, 734 + lbs_deb_thread( 628 735 "main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n", 629 736 adapter->connect_status, adapter->intcounter, 630 737 adapter->psmode, adapter->psstate); ··· 634 741 spin_unlock_irq(&adapter->driver_lock); 635 742 636 743 637 - lbs_pr_debug(1, 744 + lbs_deb_thread( 638 745 "main-thread 222 (waking up): intcounter=%d currenttxskb=%p " 639 746 "dnld_sent=%d\n", adapter->intcounter, 640 - adapter->currenttxskb, priv->wlan_dev.dnld_sent); 747 + adapter->currenttxskb, priv->dnld_sent); 641 748 642 749 set_current_state(TASK_RUNNING); 643 750 remove_wait_queue(&thread->waitq, &wait); 644 751 try_to_freeze(); 645 752 646 - lbs_pr_debug(1, "main-thread 333: intcounter=%d currenttxskb=%p " 753 + lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p " 647 754 "dnld_sent=%d\n", 648 755 adapter->intcounter, 649 - adapter->currenttxskb, priv->wlan_dev.dnld_sent); 756 + adapter->currenttxskb, priv->dnld_sent); 650 757 651 758 if (kthread_should_stop() 652 759 || adapter->surpriseremoved) { 653 - lbs_pr_debug(1, 760 + lbs_deb_thread( 654 761 "main-thread: break from main thread: surpriseremoved=0x%x\n", 655 762 adapter->surpriseremoved); 656 763 break; ··· 661 768 if (adapter->intcounter) { 662 769 u8 int_status; 663 770 adapter->intcounter = 0; 664 - int_status = libertas_sbi_get_int_status(priv, &ireg); 771 + int_status = priv->hw_get_int_status(priv, &ireg); 665 772 666 773 if (int_status) { 667 - lbs_pr_debug(1, 774 + lbs_deb_thread( 668 775 "main-thread: reading HOST_INT_STATUS_REG failed\n"); 669 776 spin_unlock_irq(&adapter->driver_lock); 670 777 continue; ··· 672 779 adapter->hisregcpy |= ireg; 673 780 } 674 781 675 - lbs_pr_debug(1, "main-thread 444: intcounter=%d currenttxskb=%p " 782 + lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p " 676 783 "dnld_sent=%d\n", 677 784 adapter->intcounter, 678 - adapter->currenttxskb, priv->wlan_dev.dnld_sent); 785 + adapter->currenttxskb, priv->dnld_sent); 679 786 680 787 /* command response? */ 681 788 if (adapter->hisregcpy & his_cmdupldrdy) { 682 - lbs_pr_debug(1, "main-thread: cmd response ready.\n"); 789 + lbs_deb_thread("main-thread: cmd response ready\n"); 683 790 684 791 adapter->hisregcpy &= ~his_cmdupldrdy; 685 792 spin_unlock_irq(&adapter->driver_lock); ··· 689 796 690 797 /* Any Card Event */ 691 798 if (adapter->hisregcpy & his_cardevent) { 692 - lbs_pr_debug(1, "main-thread: Card Event Activity.\n"); 799 + lbs_deb_thread("main-thread: Card Event Activity\n"); 693 800 694 801 adapter->hisregcpy &= ~his_cardevent; 695 802 696 - if (libertas_sbi_read_event_cause(priv)) { 803 + if (priv->hw_read_event_cause(priv)) { 697 804 lbs_pr_alert( 698 - "main-thread: libertas_sbi_read_event_cause failed.\n"); 805 + "main-thread: hw_read_event_cause failed\n"); 699 806 spin_unlock_irq(&adapter->driver_lock); 700 807 continue; 701 808 } ··· 706 813 707 814 /* Check if we need to confirm Sleep Request received previously */ 708 815 if (adapter->psstate == PS_STATE_PRE_SLEEP) { 709 - if (!priv->wlan_dev.dnld_sent && !adapter->cur_cmd) { 816 + if (!priv->dnld_sent && !adapter->cur_cmd) { 710 817 if (adapter->connect_status == 711 818 libertas_connected) { 712 - lbs_pr_debug(1, 819 + lbs_deb_thread( 713 820 "main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p " 714 821 "dnld_sent=%d cur_cmd=%p, confirm now\n", 715 822 adapter->intcounter, 716 823 adapter->currenttxskb, 717 - priv->wlan_dev.dnld_sent, 824 + priv->dnld_sent, 718 825 adapter->cur_cmd); 719 826 720 827 libertas_ps_confirm_sleep(priv, ··· 740 847 continue; 741 848 742 849 /* Execute the next command */ 743 - if (!priv->wlan_dev.dnld_sent && !priv->adapter->cur_cmd) 850 + if (!priv->dnld_sent && !priv->adapter->cur_cmd) 744 851 libertas_execute_next_command(priv); 745 852 746 853 /* Wake-up command waiters which can't sleep in ··· 757 864 wake_up_all(&adapter->cmd_pending); 758 865 wlan_deactivate_thread(thread); 759 866 760 - LEAVE(); 867 + lbs_deb_leave(LBS_DEB_THREAD); 761 868 return 0; 762 869 } 763 870 ··· 768 875 * @param card A pointer to card 769 876 * @return A pointer to wlan_private structure 770 877 */ 771 - wlan_private *wlan_add_card(void *card) 878 + wlan_private *libertas_add_card(void *card, struct device *dmdev) 772 879 { 773 880 struct net_device *dev = NULL; 774 - struct net_device *mesh_dev = NULL; 775 881 wlan_private *priv = NULL; 776 882 777 - ENTER(); 883 + lbs_deb_enter(LBS_DEB_NET); 778 884 779 885 /* Allocate an Ethernet device and register it */ 780 886 if (!(dev = alloc_etherdev(sizeof(wlan_private)))) { 781 - lbs_pr_alert( "Init ethernet device failed!\n"); 887 + lbs_pr_err("init ethX device failed\n"); 782 888 return NULL; 783 889 } 784 - 785 890 priv = dev->priv; 786 891 787 892 /* allocate buffer for wlan_adapter */ 788 - if (!(priv->adapter = kmalloc(sizeof(wlan_adapter), GFP_KERNEL))) { 789 - lbs_pr_alert( "Allocate buffer for wlan_adapter failed!\n"); 790 - goto err_kmalloc; 893 + if (!(priv->adapter = kzalloc(sizeof(wlan_adapter), GFP_KERNEL))) { 894 + lbs_pr_err("allocate buffer for wlan_adapter failed\n"); 895 + goto err_kzalloc; 791 896 } 792 897 793 - /* Allocate a virtual mesh device */ 794 - if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) { 795 - lbs_pr_debug(1, "Init ethernet device failed!\n"); 796 - return NULL; 797 - } 798 - 799 - /* Both intervaces share the priv structure */ 800 - mesh_dev->priv = priv; 801 - 802 - /* init wlan_adapter */ 803 - memset(priv->adapter, 0, sizeof(wlan_adapter)); 804 - 805 - priv->wlan_dev.netdev = dev; 806 - priv->wlan_dev.card = card; 898 + priv->dev = dev; 899 + priv->card = card; 807 900 priv->mesh_open = 0; 808 901 priv->infra_open = 0; 809 - priv->mesh_dev = mesh_dev; 810 - wlanpriv = priv; 811 902 812 903 SET_MODULE_OWNER(dev); 813 - SET_MODULE_OWNER(mesh_dev); 814 904 815 905 /* Setup the OS Interface to our functions */ 816 906 dev->open = wlan_open; ··· 801 925 dev->stop = wlan_close; 802 926 dev->do_ioctl = libertas_do_ioctl; 803 927 dev->set_mac_address = wlan_set_mac_address; 804 - mesh_dev->open = mesh_open; 805 - mesh_dev->hard_start_xmit = mesh_pre_start_xmit; 806 - mesh_dev->stop = mesh_close; 807 - mesh_dev->do_ioctl = libertas_do_ioctl; 808 - memcpy(mesh_dev->dev_addr, wlanpriv->wlan_dev.netdev->dev_addr, 809 - sizeof(wlanpriv->wlan_dev.netdev->dev_addr)); 810 - 811 - #define WLAN_WATCHDOG_TIMEOUT (5 * HZ) 812 - 813 928 dev->tx_timeout = wlan_tx_timeout; 814 929 dev->get_stats = wlan_get_stats; 815 - dev->watchdog_timeo = WLAN_WATCHDOG_TIMEOUT; 930 + dev->watchdog_timeo = 5 * HZ; 816 931 dev->ethtool_ops = &libertas_ethtool_ops; 817 - mesh_dev->get_stats = wlan_get_stats; 818 - mesh_dev->ethtool_ops = &libertas_ethtool_ops; 819 - 820 932 #ifdef WIRELESS_EXT 821 933 dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; 822 - mesh_dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def; 823 934 #endif 824 935 #define NETIF_F_DYNALLOC 16 825 936 dev->features |= NETIF_F_DYNALLOC; 826 937 dev->flags |= IFF_BROADCAST | IFF_MULTICAST; 827 938 dev->set_multicast_list = wlan_set_multicast_list; 939 + 940 + SET_NETDEV_DEV(dev, dmdev); 828 941 829 942 INIT_LIST_HEAD(&priv->adapter->cmdfreeq); 830 943 INIT_LIST_HEAD(&priv->adapter->cmdpendingq); ··· 821 956 spin_lock_init(&priv->adapter->driver_lock); 822 957 init_waitqueue_head(&priv->adapter->cmd_pending); 823 958 priv->adapter->nr_cmd_pending = 0; 959 + goto done; 824 960 825 - lbs_pr_debug(1, "Starting kthread...\n"); 961 + err_kzalloc: 962 + free_netdev(dev); 963 + priv = NULL; 964 + done: 965 + lbs_deb_leave_args(LBS_DEB_NET, "priv %p", priv); 966 + return priv; 967 + } 968 + EXPORT_SYMBOL_GPL(libertas_add_card); 969 + 970 + int libertas_activate_card(wlan_private *priv, char *fw_name) 971 + { 972 + struct net_device *dev = priv->dev; 973 + int ret = -1; 974 + 975 + lbs_deb_enter(LBS_DEB_MAIN); 976 + 977 + lbs_deb_thread("Starting kthread...\n"); 826 978 priv->mainthread.priv = priv; 827 979 wlan_create_thread(wlan_service_main_thread, 828 980 &priv->mainthread, "wlan_main_service"); 829 981 830 982 priv->assoc_thread = 831 983 create_singlethread_workqueue("libertas_assoc"); 832 - INIT_DELAYED_WORK(&priv->assoc_work, wlan_association_worker); 984 + INIT_DELAYED_WORK(&priv->assoc_work, libertas_association_worker); 985 + INIT_WORK(&priv->sync_channel, libertas_sync_channel); 833 986 834 987 /* 835 988 * Register the device. Fillup the private data structure with 836 989 * relevant information from the card and request for the required 837 990 * IRQ. 838 991 */ 839 - if (libertas_sbi_register_dev(priv) < 0) { 840 - lbs_pr_info("failed to register wlan device!\n"); 992 + if (priv->hw_register_dev(priv) < 0) { 993 + lbs_pr_err("failed to register WLAN device\n"); 841 994 goto err_registerdev; 842 995 } 843 996 844 997 /* init FW and HW */ 845 - if (libertas_init_fw(priv)) { 846 - lbs_pr_debug(1, "Firmware Init failed\n"); 998 + if (fw_name && libertas_init_fw(priv, fw_name)) { 999 + lbs_pr_err("firmware init failed\n"); 847 1000 goto err_registerdev; 848 1001 } 849 1002 850 1003 if (register_netdev(dev)) { 851 - lbs_pr_err("Cannot register network device!\n"); 1004 + lbs_pr_err("cannot register ethX device\n"); 852 1005 goto err_init_fw; 853 1006 } 854 1007 855 - /* Register virtual mesh interface */ 856 - if (register_netdev(mesh_dev)) { 857 - lbs_pr_info("Cannot register mesh virtual interface!\n"); 858 - goto err_init_fw; 859 - } 860 - 861 - lbs_pr_info("%s: Marvell Wlan 802.11 adapter ", dev->name); 1008 + lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name); 862 1009 863 1010 libertas_debugfs_init_one(priv, dev); 864 1011 865 - if (libertas_found == MAX_DEVS) 866 - goto err_init_fw; 867 - libertas_devs[libertas_found] = dev; 868 - libertas_found++; 869 - #ifdef ENABLE_PM 870 - if (!(wlan_pm_dev = pm_register(PM_UNKNOWN_DEV, 0, wlan_pm_callback))) 871 - lbs_pr_alert( "failed to register PM callback\n"); 872 - #endif 873 - if (device_create_file(&(mesh_dev->dev), &dev_attr_libertas_mpp)) 874 - goto err_create_file; 1012 + ret = 0; 1013 + goto done; 875 1014 876 - LEAVE(); 877 - return priv; 878 - 879 - err_create_file: 880 - device_remove_file(&(mesh_dev->dev), &dev_attr_libertas_mpp); 881 1015 err_init_fw: 882 - libertas_sbi_unregister_dev(priv); 1016 + priv->hw_unregister_dev(priv); 883 1017 err_registerdev: 884 1018 destroy_workqueue(priv->assoc_thread); 885 1019 /* Stop the thread servicing the interrupts */ 886 1020 wake_up_interruptible(&priv->mainthread.waitq); 887 1021 wlan_terminate_thread(&priv->mainthread); 888 - kfree(priv->adapter); 889 - err_kmalloc: 890 - free_netdev(dev); 891 - free_netdev(mesh_dev); 892 - wlanpriv = NULL; 893 - 894 - LEAVE(); 895 - return NULL; 1022 + done: 1023 + lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); 1024 + return ret; 896 1025 } 1026 + EXPORT_SYMBOL_GPL(libertas_activate_card); 1027 + 1028 + 1029 + /** 1030 + * @brief This function adds mshX interface 1031 + * 1032 + * @param priv A pointer to the wlan_private structure 1033 + * @return 0 if successful, -X otherwise 1034 + */ 1035 + int libertas_add_mesh(wlan_private *priv, struct device *dev) 1036 + { 1037 + struct net_device *mesh_dev = NULL; 1038 + int ret = 0; 1039 + 1040 + lbs_deb_enter(LBS_DEB_MESH); 1041 + 1042 + /* Allocate a virtual mesh device */ 1043 + if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) { 1044 + lbs_deb_mesh("init mshX device failed\n"); 1045 + ret = -ENOMEM; 1046 + goto done; 1047 + } 1048 + mesh_dev->priv = priv; 1049 + priv->mesh_dev = mesh_dev; 1050 + 1051 + SET_MODULE_OWNER(mesh_dev); 1052 + 1053 + mesh_dev->open = mesh_open; 1054 + mesh_dev->hard_start_xmit = mesh_pre_start_xmit; 1055 + mesh_dev->stop = mesh_close; 1056 + mesh_dev->do_ioctl = libertas_do_ioctl; 1057 + mesh_dev->get_stats = wlan_get_stats; 1058 + mesh_dev->set_mac_address = wlan_set_mac_address; 1059 + mesh_dev->ethtool_ops = &libertas_ethtool_ops; 1060 + memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, 1061 + sizeof(priv->dev->dev_addr)); 1062 + 1063 + SET_NETDEV_DEV(priv->mesh_dev, dev); 1064 + 1065 + #ifdef WIRELESS_EXT 1066 + mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; 1067 + #endif 1068 + #define NETIF_F_DYNALLOC 16 1069 + 1070 + /* Register virtual mesh interface */ 1071 + ret = register_netdev(mesh_dev); 1072 + if (ret) { 1073 + lbs_pr_err("cannot register mshX virtual interface\n"); 1074 + goto err_free; 1075 + } 1076 + 1077 + ret = device_create_file(&(mesh_dev->dev), &dev_attr_anycast_mask); 1078 + if (ret) 1079 + goto err_unregister; 1080 + 1081 + /* Everything successful */ 1082 + ret = 0; 1083 + goto done; 1084 + 1085 + 1086 + err_unregister: 1087 + unregister_netdev(mesh_dev); 1088 + 1089 + err_free: 1090 + free_netdev(mesh_dev); 1091 + 1092 + done: 1093 + lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); 1094 + return ret; 1095 + } 1096 + EXPORT_SYMBOL_GPL(libertas_add_mesh); 897 1097 898 1098 static void wake_pending_cmdnodes(wlan_private *priv) 899 1099 { 900 1100 struct cmd_ctrl_node *cmdnode; 901 1101 unsigned long flags; 1102 + 1103 + lbs_deb_enter(LBS_DEB_CMD); 902 1104 903 1105 spin_lock_irqsave(&priv->adapter->driver_lock, flags); 904 1106 list_for_each_entry(cmdnode, &priv->adapter->cmdpendingq, list) { ··· 976 1044 } 977 1045 978 1046 979 - int wlan_remove_card(void *card) 1047 + int libertas_remove_card(wlan_private *priv) 980 1048 { 981 - wlan_private *priv = libertas_sbi_get_priv(card); 982 1049 wlan_adapter *adapter; 983 1050 struct net_device *dev; 984 - struct net_device *mesh_dev; 985 1051 union iwreq_data wrqu; 986 - int i; 987 1052 988 - ENTER(); 1053 + lbs_deb_enter(LBS_DEB_NET); 989 1054 990 - if (!priv) { 991 - LEAVE(); 992 - return 0; 993 - } 1055 + if (!priv) 1056 + goto out; 994 1057 995 1058 adapter = priv->adapter; 996 1059 997 - if (!adapter) { 998 - LEAVE(); 999 - return 0; 1000 - } 1060 + if (!adapter) 1061 + goto out; 1001 1062 1002 - dev = priv->wlan_dev.netdev; 1003 - mesh_dev = priv->mesh_dev; 1063 + dev = priv->dev; 1004 1064 1005 - netif_stop_queue(mesh_dev); 1006 - netif_stop_queue(priv->wlan_dev.netdev); 1007 - netif_carrier_off(priv->wlan_dev.netdev); 1065 + netif_stop_queue(priv->dev); 1066 + netif_carrier_off(priv->dev); 1008 1067 1009 1068 wake_pending_cmdnodes(priv); 1010 1069 1011 - device_remove_file(&(mesh_dev->dev), &dev_attr_libertas_mpp); 1012 - unregister_netdev(mesh_dev); 1013 1070 unregister_netdev(dev); 1014 1071 1015 1072 cancel_delayed_work(&priv->assoc_work); ··· 1011 1090 1012 1091 memset(wrqu.ap_addr.sa_data, 0xaa, ETH_ALEN); 1013 1092 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 1014 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL); 1015 - 1016 - #ifdef ENABLE_PM 1017 - pm_unregister(wlan_pm_dev); 1018 - #endif 1093 + wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 1019 1094 1020 1095 adapter->surpriseremoved = 1; 1021 1096 ··· 1020 1103 1021 1104 libertas_debugfs_remove_one(priv); 1022 1105 1023 - lbs_pr_debug(1, "Free adapter\n"); 1106 + lbs_deb_net("free adapter\n"); 1024 1107 libertas_free_adapter(priv); 1025 1108 1026 - for (i = 0; i<libertas_found; i++) { 1027 - if (libertas_devs[i]==priv->wlan_dev.netdev) { 1028 - libertas_devs[i] = libertas_devs[--libertas_found]; 1029 - libertas_devs[libertas_found] = NULL ; 1030 - break ; 1031 - } 1032 - } 1109 + lbs_deb_net("unregister finish\n"); 1033 1110 1034 - lbs_pr_debug(1, "Unregister finish\n"); 1035 - 1036 - priv->wlan_dev.netdev = NULL; 1037 - priv->mesh_dev = NULL ; 1038 - free_netdev(mesh_dev); 1111 + priv->dev = NULL; 1039 1112 free_netdev(dev); 1040 - wlanpriv = NULL; 1041 1113 1042 - LEAVE(); 1114 + out: 1115 + lbs_deb_leave(LBS_DEB_NET); 1043 1116 return 0; 1044 1117 } 1118 + EXPORT_SYMBOL_GPL(libertas_remove_card); 1119 + 1120 + 1121 + void libertas_remove_mesh(wlan_private *priv) 1122 + { 1123 + struct net_device *mesh_dev; 1124 + 1125 + lbs_deb_enter(LBS_DEB_NET); 1126 + 1127 + if (!priv) 1128 + goto out; 1129 + 1130 + mesh_dev = priv->mesh_dev; 1131 + 1132 + netif_stop_queue(mesh_dev); 1133 + netif_carrier_off(priv->mesh_dev); 1134 + 1135 + device_remove_file(&(mesh_dev->dev), &dev_attr_anycast_mask); 1136 + unregister_netdev(mesh_dev); 1137 + 1138 + priv->mesh_dev = NULL ; 1139 + free_netdev(mesh_dev); 1140 + 1141 + out: 1142 + lbs_deb_leave(LBS_DEB_NET); 1143 + } 1144 + EXPORT_SYMBOL_GPL(libertas_remove_mesh); 1045 1145 1046 1146 /** 1047 1147 * @brief This function finds the CFP in ··· 1073 1139 { 1074 1140 int i, end; 1075 1141 1076 - ENTER(); 1142 + lbs_deb_enter(LBS_DEB_MAIN); 1077 1143 1078 1144 end = sizeof(region_cfp_table)/sizeof(struct region_cfp_table); 1079 1145 1080 1146 for (i = 0; i < end ; i++) { 1081 - lbs_pr_debug(1, "region_cfp_table[i].region=%d\n", 1147 + lbs_deb_main("region_cfp_table[i].region=%d\n", 1082 1148 region_cfp_table[i].region); 1083 1149 if (region_cfp_table[i].region == region) { 1084 1150 *cfp_no = region_cfp_table[i].cfp_no_BG; 1085 - LEAVE(); 1151 + lbs_deb_leave(LBS_DEB_MAIN); 1086 1152 return region_cfp_table[i].cfp_BG; 1087 1153 } 1088 1154 } 1089 1155 1090 - LEAVE(); 1156 + lbs_deb_leave_args(LBS_DEB_MAIN, "ret NULL"); 1091 1157 return NULL; 1092 1158 } 1093 1159 1094 1160 int libertas_set_regiontable(wlan_private * priv, u8 region, u8 band) 1095 1161 { 1096 1162 wlan_adapter *adapter = priv->adapter; 1163 + int ret = 0; 1097 1164 int i = 0; 1098 1165 1099 1166 struct chan_freq_power *cfp; 1100 1167 int cfp_no; 1101 1168 1102 - ENTER(); 1169 + lbs_deb_enter(LBS_DEB_MAIN); 1103 1170 1104 1171 memset(adapter->region_channel, 0, sizeof(adapter->region_channel)); 1105 1172 ··· 1110 1175 adapter->region_channel[i].nrcfp = cfp_no; 1111 1176 adapter->region_channel[i].CFP = cfp; 1112 1177 } else { 1113 - lbs_pr_debug(1, "wrong region code %#x in band B-G\n", 1178 + lbs_deb_main("wrong region code %#x in band B/G\n", 1114 1179 region); 1115 - return -1; 1180 + ret = -1; 1181 + goto out; 1116 1182 } 1117 1183 adapter->region_channel[i].valid = 1; 1118 1184 adapter->region_channel[i].region = region; 1119 1185 adapter->region_channel[i].band = band; 1120 1186 i++; 1121 1187 } 1122 - LEAVE(); 1123 - return 0; 1188 + out: 1189 + lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); 1190 + return ret; 1124 1191 } 1125 1192 1126 1193 /** ··· 1137 1200 { 1138 1201 wlan_private *priv = dev->priv; 1139 1202 1140 - ENTER(); 1203 + lbs_deb_enter(LBS_DEB_THREAD); 1141 1204 1142 - lbs_pr_debug(1, "libertas_interrupt: intcounter=%d\n", 1205 + lbs_deb_thread("libertas_interrupt: intcounter=%d\n", 1143 1206 priv->adapter->intcounter); 1144 1207 1145 1208 priv->adapter->intcounter++; ··· 1147 1210 if (priv->adapter->psstate == PS_STATE_SLEEP) { 1148 1211 priv->adapter->psstate = PS_STATE_AWAKE; 1149 1212 netif_wake_queue(dev); 1213 + netif_wake_queue(priv->mesh_dev); 1150 1214 } 1151 1215 1152 1216 wake_up_interruptible(&priv->mainthread.waitq); 1153 1217 1154 - LEAVE(); 1218 + lbs_deb_leave(LBS_DEB_THREAD); 1155 1219 } 1220 + EXPORT_SYMBOL_GPL(libertas_interrupt); 1156 1221 1157 - static int wlan_init_module(void) 1222 + static int libertas_init_module(void) 1158 1223 { 1159 - int ret = 0; 1160 - 1161 - ENTER(); 1162 - 1163 - if (libertas_fw_name == NULL) { 1164 - libertas_fw_name = default_fw_name; 1165 - } 1166 - 1224 + lbs_deb_enter(LBS_DEB_MAIN); 1167 1225 libertas_debugfs_init(); 1168 - 1169 - if (libertas_sbi_register()) { 1170 - ret = -1; 1171 - libertas_debugfs_remove(); 1172 - goto done; 1173 - } 1174 - 1175 - done: 1176 - LEAVE(); 1177 - return ret; 1226 + lbs_deb_leave(LBS_DEB_MAIN); 1227 + return 0; 1178 1228 } 1179 1229 1180 - static void wlan_cleanup_module(void) 1230 + static void libertas_exit_module(void) 1181 1231 { 1182 - int i; 1232 + lbs_deb_enter(LBS_DEB_MAIN); 1183 1233 1184 - ENTER(); 1185 - 1186 - for (i = 0; i<libertas_found; i++) { 1187 - wlan_private *priv = libertas_devs[i]->priv; 1188 - reset_device(priv); 1189 - } 1190 - 1191 - libertas_sbi_unregister(); 1192 1234 libertas_debugfs_remove(); 1193 1235 1194 - LEAVE(); 1236 + lbs_deb_leave(LBS_DEB_MAIN); 1195 1237 } 1196 1238 1197 - module_init(wlan_init_module); 1198 - module_exit(wlan_cleanup_module); 1239 + module_init(libertas_init_module); 1240 + module_exit(libertas_exit_module); 1199 1241 1200 - MODULE_DESCRIPTION("M-WLAN Driver"); 1242 + MODULE_DESCRIPTION("Libertas WLAN Driver Library"); 1201 1243 MODULE_AUTHOR("Marvell International Ltd."); 1202 1244 MODULE_LICENSE("GPL");
+32 -32
drivers/net/wireless/libertas/rx.c
··· 106 106 { 107 107 wlan_adapter *adapter = priv->adapter; 108 108 109 - ENTER(); 109 + lbs_deb_enter(LBS_DEB_RX); 110 110 111 - lbs_pr_debug(1, "rxpd: SNR = %d, NF = %d\n", p_rx_pd->snr, p_rx_pd->nf); 112 - lbs_pr_debug(1, "Before computing SNR: SNR- avg = %d, NF-avg = %d\n", 111 + lbs_deb_rx("rxpd: SNR %d, NF %d\n", p_rx_pd->snr, p_rx_pd->nf); 112 + lbs_deb_rx("before computing SNR: SNR-avg = %d, NF-avg = %d\n", 113 113 adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, 114 114 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); 115 115 ··· 121 121 122 122 adapter->SNR[TYPE_RXPD][TYPE_AVG] = wlan_getavgsnr(priv) * AVG_SCALE; 123 123 adapter->NF[TYPE_RXPD][TYPE_AVG] = wlan_getavgnf(priv) * AVG_SCALE; 124 - lbs_pr_debug(1, "After computing SNR: SNR-avg = %d, NF-avg = %d\n", 124 + lbs_deb_rx("after computing SNR: SNR-avg = %d, NF-avg = %d\n", 125 125 adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, 126 126 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); 127 127 ··· 133 133 CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, 134 134 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); 135 135 136 - LEAVE(); 136 + lbs_deb_leave(LBS_DEB_RX); 137 137 } 138 138 139 139 void libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb) 140 140 { 141 - lbs_pr_debug(1, "skb->data=%p\n", skb->data); 141 + lbs_deb_rx("skb->data %p\n", skb->data); 142 142 143 - if(IS_MESH_FRAME(skb)) 144 - skb->dev = priv->mesh_dev; 143 + if (priv->mesh_dev && IS_MESH_FRAME(skb)) 144 + skb->protocol = eth_type_trans(skb, priv->mesh_dev); 145 145 else 146 - skb->dev = priv->wlan_dev.netdev; 147 - skb->protocol = eth_type_trans(skb, priv->wlan_dev.netdev); 146 + skb->protocol = eth_type_trans(skb, priv->dev); 148 147 skb->ip_summed = CHECKSUM_UNNECESSARY; 149 148 150 149 netif_rx(skb); ··· 170 171 171 172 const u8 rfc1042_eth_hdr[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; 172 173 173 - ENTER(); 174 + lbs_deb_enter(LBS_DEB_RX); 174 175 175 176 if (priv->adapter->debugmode & MRVDRV_DEBUG_RX_PATH) 176 177 lbs_dbg_hex("RX packet: ", skb->data, ··· 190 191 min_t(unsigned int, skb->len, 100)); 191 192 192 193 if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) { 193 - lbs_pr_debug(1, "RX error: FRAME RECEIVED WITH BAD LENGTH\n"); 194 + lbs_deb_rx("rx err: frame received with bad length\n"); 194 195 priv->stats.rx_length_errors++; 195 196 ret = 0; 196 197 goto done; ··· 199 200 /* 200 201 * Check rxpd status and update 802.3 stat, 201 202 */ 202 - if (!(p_rx_pd->status & MRVDRV_RXPD_STATUS_OK)) { 203 - lbs_pr_debug(1, "RX error: frame received with bad status\n"); 204 - lbs_pr_alert("rxpd Not OK\n"); 203 + if (!(p_rx_pd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) { 204 + lbs_deb_rx("rx err: frame received with bad status\n"); 205 + lbs_pr_alert("rxpd not ok\n"); 205 206 priv->stats.rx_errors++; 206 207 ret = 0; 207 208 goto done; 208 209 } 209 210 210 - lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", 211 + lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n", 211 212 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 212 213 213 214 lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, ··· 265 266 266 267 wlan_compute_rssi(priv, p_rx_pd); 267 268 268 - lbs_pr_debug(1, "RX Data: size of actual packet = %d\n", skb->len); 269 + lbs_deb_rx("rx data: size of actual packet %d\n", skb->len); 269 270 priv->stats.rx_bytes += skb->len; 270 271 priv->stats.rx_packets++; 271 272 ··· 273 274 274 275 ret = 0; 275 276 done: 276 - LEAVE(); 277 - 277 + lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); 278 278 return ret; 279 279 } 280 + EXPORT_SYMBOL_GPL(libertas_process_rxed_packet); 280 281 281 282 /** 282 283 * @brief This function converts Tx/Rx rates from the Marvell WLAN format ··· 313 314 case 11: /* 54 Mbps */ 314 315 return 108; 315 316 } 316 - lbs_pr_alert( "Invalid Marvell WLAN rate (%i)\n", rate); 317 + lbs_pr_alert("Invalid Marvell WLAN rate %i\n", rate); 317 318 return 0; 318 319 } 319 320 ··· 335 336 struct rx_radiotap_hdr radiotap_hdr; 336 337 struct rx_radiotap_hdr *pradiotap_hdr; 337 338 338 - ENTER(); 339 + lbs_deb_enter(LBS_DEB_RX); 339 340 340 341 p_rx_pkt = (struct rx80211packethdr *) skb->data; 341 342 prxpd = &p_rx_pkt->rx_pd; ··· 343 344 // lbs_dbg_hex("RX Data: Before chop rxpd", skb->data, min(skb->len, 100)); 344 345 345 346 if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) { 346 - lbs_pr_debug(1, "RX error: FRAME RECEIVED WITH BAD LENGTH\n"); 347 + lbs_deb_rx("rx err: frame received wit bad length\n"); 347 348 priv->stats.rx_length_errors++; 348 349 ret = 0; 349 350 goto done; ··· 352 353 /* 353 354 * Check rxpd status and update 802.3 stat, 354 355 */ 355 - if (!(prxpd->status & MRVDRV_RXPD_STATUS_OK)) { 356 - //lbs_pr_debug(1, "RX error: frame received with bad status\n"); 356 + if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) { 357 + //lbs_deb_rx("rx err: frame received with bad status\n"); 357 358 priv->stats.rx_errors++; 358 359 } 359 360 360 - lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n", 361 + lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n", 361 362 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 362 363 363 364 /* create the exported radio header */ ··· 385 386 /* XXX must check no carryout */ 386 387 radiotap_hdr.antsignal = prxpd->snr + prxpd->nf; 387 388 radiotap_hdr.rx_flags = 0; 388 - if (!(prxpd->status & MRVDRV_RXPD_STATUS_OK)) 389 + if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK))) 389 390 radiotap_hdr.rx_flags |= IEEE80211_RADIOTAP_F_RX_BADFCS; 390 391 //memset(radiotap_hdr.pad, 0x11, IEEE80211_RADIOTAP_HDRLEN - 18); 391 392 ··· 398 399 if ((skb_headroom(skb) < sizeof(struct rx_radiotap_hdr)) && 399 400 pskb_expand_head(skb, sizeof(struct rx_radiotap_hdr), 0, 400 401 GFP_ATOMIC)) { 401 - lbs_pr_alert( "%s: couldn't pskb_expand_head\n", 402 + lbs_pr_alert("%s: couldn't pskb_expand_head\n", 402 403 __func__); 403 404 } 404 405 ··· 413 414 414 415 default: 415 416 /* unknown header */ 416 - lbs_pr_alert( "Unknown radiomode (%i)\n", 417 + lbs_pr_alert("Unknown radiomode %i\n", 417 418 priv->adapter->radiomode); 418 419 /* don't export any header */ 419 420 /* chop the rxpd */ ··· 430 431 431 432 wlan_compute_rssi(priv, prxpd); 432 433 433 - lbs_pr_debug(1, "RX Data: size of actual packet = %d\n", skb->len); 434 + lbs_deb_rx("rx data: size of actual packet %d\n", skb->len); 434 435 priv->stats.rx_bytes += skb->len; 435 436 priv->stats.rx_packets++; 436 437 437 438 libertas_upload_rx_packet(priv, skb); 438 439 439 440 ret = 0; 440 - done: 441 - LEAVE(); 442 441 443 - return (ret); 442 + done: 443 + skb->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */ 444 + lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); 445 + return ret; 444 446 }
-40
drivers/net/wireless/libertas/sbi.h
··· 1 - /** 2 - * This file contains IF layer definitions. 3 - */ 4 - 5 - #ifndef _SBI_H_ 6 - #define _SBI_H_ 7 - 8 - #include <linux/interrupt.h> 9 - 10 - #include "defs.h" 11 - 12 - /** INT status Bit Definition*/ 13 - #define his_cmddnldrdy 0x01 14 - #define his_cardevent 0x02 15 - #define his_cmdupldrdy 0x04 16 - 17 - #ifndef DEV_NAME_LEN 18 - #define DEV_NAME_LEN 32 19 - #endif 20 - 21 - #define SBI_EVENT_CAUSE_SHIFT 3 22 - 23 - /* Probe and Check if the card is present*/ 24 - int libertas_sbi_register_dev(wlan_private * priv); 25 - int libertas_sbi_unregister_dev(wlan_private *); 26 - int libertas_sbi_get_int_status(wlan_private * priv, u8 *); 27 - int libertas_sbi_register(void); 28 - void libertas_sbi_unregister(void); 29 - int libertas_sbi_prog_firmware(wlan_private *); 30 - 31 - int libertas_sbi_read_event_cause(wlan_private *); 32 - int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb); 33 - wlan_private *libertas_sbi_get_priv(void *card); 34 - 35 - #ifdef ENABLE_PM 36 - int libertas_sbi_suspend(wlan_private *); 37 - int libertas_sbi_resume(wlan_private *); 38 - #endif 39 - 40 - #endif /* _SBI_H */
+721 -808
drivers/net/wireless/libertas/scan.c
··· 8 8 #include <linux/if.h> 9 9 #include <linux/netdevice.h> 10 10 #include <linux/wireless.h> 11 + #include <linux/etherdevice.h> 11 12 12 13 #include <net/ieee80211.h> 13 14 #include <net/iw_handler.h> ··· 59 58 //! Scan time specified in the channel TLV for each channel for active scans 60 59 #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 61 60 62 - //! Macro to enable/disable SSID checking before storing a scan table 63 - #ifdef DISCARD_BAD_SSID 64 - #define CHECK_SSID_IS_VALID(x) ssid_valid(&bssidEntry.ssid) 65 - #else 66 - #define CHECK_SSID_IS_VALID(x) 1 67 - #endif 61 + static const u8 zeromac[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 62 + static const u8 bcastmac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 63 + 64 + static inline void clear_bss_descriptor (struct bss_descriptor * bss) 65 + { 66 + /* Don't blow away ->list, just BSS data */ 67 + memset(bss, 0, offsetof(struct bss_descriptor, list)); 68 + } 69 + 70 + static inline int match_bss_no_security(struct wlan_802_11_security * secinfo, 71 + struct bss_descriptor * match_bss) 72 + { 73 + if ( !secinfo->wep_enabled 74 + && !secinfo->WPAenabled 75 + && !secinfo->WPA2enabled 76 + && match_bss->wpa_ie[0] != WPA_IE 77 + && match_bss->rsn_ie[0] != WPA2_IE 78 + && !match_bss->privacy) { 79 + return 1; 80 + } 81 + return 0; 82 + } 83 + 84 + static inline int match_bss_static_wep(struct wlan_802_11_security * secinfo, 85 + struct bss_descriptor * match_bss) 86 + { 87 + if ( secinfo->wep_enabled 88 + && !secinfo->WPAenabled 89 + && !secinfo->WPA2enabled 90 + && match_bss->privacy) { 91 + return 1; 92 + } 93 + return 0; 94 + } 95 + 96 + static inline int match_bss_wpa(struct wlan_802_11_security * secinfo, 97 + struct bss_descriptor * match_bss) 98 + { 99 + if ( !secinfo->wep_enabled 100 + && secinfo->WPAenabled 101 + && (match_bss->wpa_ie[0] == WPA_IE) 102 + /* privacy bit may NOT be set in some APs like LinkSys WRT54G 103 + && bss->privacy */ 104 + ) { 105 + return 1; 106 + } 107 + return 0; 108 + } 109 + 110 + static inline int match_bss_wpa2(struct wlan_802_11_security * secinfo, 111 + struct bss_descriptor * match_bss) 112 + { 113 + if ( !secinfo->wep_enabled 114 + && secinfo->WPA2enabled 115 + && (match_bss->rsn_ie[0] == WPA2_IE) 116 + /* privacy bit may NOT be set in some APs like LinkSys WRT54G 117 + && bss->privacy */ 118 + ) { 119 + return 1; 120 + } 121 + return 0; 122 + } 123 + 124 + static inline int match_bss_dynamic_wep(struct wlan_802_11_security * secinfo, 125 + struct bss_descriptor * match_bss) 126 + { 127 + if ( !secinfo->wep_enabled 128 + && !secinfo->WPAenabled 129 + && !secinfo->WPA2enabled 130 + && (match_bss->wpa_ie[0] != WPA_IE) 131 + && (match_bss->rsn_ie[0] != WPA2_IE) 132 + && match_bss->privacy) { 133 + return 1; 134 + } 135 + return 0; 136 + } 68 137 69 138 /** 70 139 * @brief Check if a scanned network compatible with the driver settings ··· 155 84 * 156 85 * @return Index in scantable, or error code if negative 157 86 */ 158 - static int is_network_compatible(wlan_adapter * adapter, int index, u8 mode) 87 + static int is_network_compatible(wlan_adapter * adapter, 88 + struct bss_descriptor * bss, u8 mode) 159 89 { 160 - ENTER(); 90 + int matched = 0; 161 91 162 - if (adapter->scantable[index].mode == mode) { 163 - if ( !adapter->secinfo.wep_enabled 164 - && !adapter->secinfo.WPAenabled 165 - && !adapter->secinfo.WPA2enabled 166 - && adapter->scantable[index].wpa_ie[0] != WPA_IE 167 - && adapter->scantable[index].rsn_ie[0] != WPA2_IE 168 - && !adapter->scantable[index].privacy) { 169 - /* no security */ 170 - LEAVE(); 171 - return index; 172 - } else if ( adapter->secinfo.wep_enabled 173 - && !adapter->secinfo.WPAenabled 174 - && !adapter->secinfo.WPA2enabled 175 - && adapter->scantable[index].privacy) { 176 - /* static WEP enabled */ 177 - LEAVE(); 178 - return index; 179 - } else if ( !adapter->secinfo.wep_enabled 180 - && adapter->secinfo.WPAenabled 181 - && !adapter->secinfo.WPA2enabled 182 - && (adapter->scantable[index].wpa_ie[0] == WPA_IE) 183 - /* privacy bit may NOT be set in some APs like LinkSys WRT54G 184 - && adapter->scantable[index].privacy */ 185 - ) { 186 - /* WPA enabled */ 187 - lbs_pr_debug(1, 188 - "is_network_compatible() WPA: index=%d wpa_ie=%#x " 189 - "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " 190 - "privacy=%#x\n", index, 191 - adapter->scantable[index].wpa_ie[0], 192 - adapter->scantable[index].rsn_ie[0], 193 - adapter->secinfo.wep_enabled ? "e" : "d", 194 - adapter->secinfo.WPAenabled ? "e" : "d", 195 - adapter->secinfo.WPA2enabled ? "e" : "d", 196 - adapter->scantable[index].privacy); 197 - LEAVE(); 198 - return index; 199 - } else if ( !adapter->secinfo.wep_enabled 200 - && !adapter->secinfo.WPAenabled 201 - && adapter->secinfo.WPA2enabled 202 - && (adapter->scantable[index].rsn_ie[0] == WPA2_IE) 203 - /* privacy bit may NOT be set in some APs like LinkSys WRT54G 204 - && adapter->scantable[index].privacy */ 205 - ) { 206 - /* WPA2 enabled */ 207 - lbs_pr_debug(1, 208 - "is_network_compatible() WPA2: index=%d wpa_ie=%#x " 209 - "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " 210 - "privacy=%#x\n", index, 211 - adapter->scantable[index].wpa_ie[0], 212 - adapter->scantable[index].rsn_ie[0], 213 - adapter->secinfo.wep_enabled ? "e" : "d", 214 - adapter->secinfo.WPAenabled ? "e" : "d", 215 - adapter->secinfo.WPA2enabled ? "e" : "d", 216 - adapter->scantable[index].privacy); 217 - LEAVE(); 218 - return index; 219 - } else if ( !adapter->secinfo.wep_enabled 220 - && !adapter->secinfo.WPAenabled 221 - && !adapter->secinfo.WPA2enabled 222 - && (adapter->scantable[index].wpa_ie[0] != WPA_IE) 223 - && (adapter->scantable[index].rsn_ie[0] != WPA2_IE) 224 - && adapter->scantable[index].privacy) { 225 - /* dynamic WEP enabled */ 226 - lbs_pr_debug(1, 227 - "is_network_compatible() dynamic WEP: index=%d " 228 - "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n", 229 - index, 230 - adapter->scantable[index].wpa_ie[0], 231 - adapter->scantable[index].rsn_ie[0], 232 - adapter->scantable[index].privacy); 233 - LEAVE(); 234 - return index; 235 - } 92 + lbs_deb_enter(LBS_DEB_ASSOC); 236 93 237 - /* security doesn't match */ 238 - lbs_pr_debug(1, 239 - "is_network_compatible() FAILED: index=%d wpa_ie=%#x " 240 - "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n", 241 - index, 242 - adapter->scantable[index].wpa_ie[0], 243 - adapter->scantable[index].rsn_ie[0], 94 + if (bss->mode != mode) 95 + goto done; 96 + 97 + if ((matched = match_bss_no_security(&adapter->secinfo, bss))) { 98 + goto done; 99 + } else if ((matched = match_bss_static_wep(&adapter->secinfo, bss))) { 100 + goto done; 101 + } else if ((matched = match_bss_wpa(&adapter->secinfo, bss))) { 102 + lbs_deb_scan( 103 + "is_network_compatible() WPA: wpa_ie=%#x " 104 + "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " 105 + "privacy=%#x\n", bss->wpa_ie[0], bss->rsn_ie[0], 244 106 adapter->secinfo.wep_enabled ? "e" : "d", 245 107 adapter->secinfo.WPAenabled ? "e" : "d", 246 108 adapter->secinfo.WPA2enabled ? "e" : "d", 247 - adapter->scantable[index].privacy); 248 - LEAVE(); 249 - return -ECONNREFUSED; 109 + bss->privacy); 110 + goto done; 111 + } else if ((matched = match_bss_wpa2(&adapter->secinfo, bss))) { 112 + lbs_deb_scan( 113 + "is_network_compatible() WPA2: wpa_ie=%#x " 114 + "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " 115 + "privacy=%#x\n", bss->wpa_ie[0], bss->rsn_ie[0], 116 + adapter->secinfo.wep_enabled ? "e" : "d", 117 + adapter->secinfo.WPAenabled ? "e" : "d", 118 + adapter->secinfo.WPA2enabled ? "e" : "d", 119 + bss->privacy); 120 + goto done; 121 + } else if ((matched = match_bss_dynamic_wep(&adapter->secinfo, bss))) { 122 + lbs_deb_scan( 123 + "is_network_compatible() dynamic WEP: " 124 + "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n", 125 + bss->wpa_ie[0], 126 + bss->rsn_ie[0], 127 + bss->privacy); 128 + goto done; 250 129 } 251 130 252 - /* mode doesn't match */ 253 - LEAVE(); 254 - return -ENETUNREACH; 255 - } 131 + /* bss security settings don't match those configured on card */ 132 + lbs_deb_scan( 133 + "is_network_compatible() FAILED: wpa_ie=%#x " 134 + "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n", 135 + bss->wpa_ie[0], bss->rsn_ie[0], 136 + adapter->secinfo.wep_enabled ? "e" : "d", 137 + adapter->secinfo.WPAenabled ? "e" : "d", 138 + adapter->secinfo.WPA2enabled ? "e" : "d", 139 + bss->privacy); 256 140 257 - /** 258 - * @brief This function validates a SSID as being able to be printed 259 - * 260 - * @param pssid SSID structure to validate 261 - * 262 - * @return TRUE or FALSE 263 - */ 264 - static u8 ssid_valid(struct WLAN_802_11_SSID *pssid) 265 - { 266 - int ssididx; 267 - 268 - for (ssididx = 0; ssididx < pssid->ssidlength; ssididx++) { 269 - if (!isprint(pssid->ssid[ssididx])) { 270 - return 0; 271 - } 272 - } 273 - 274 - return 1; 141 + done: 142 + lbs_deb_leave(LBS_DEB_SCAN); 143 + return matched; 275 144 } 276 145 277 146 /** ··· 231 220 static void wlan_scan_process_results(wlan_private * priv) 232 221 { 233 222 wlan_adapter *adapter = priv->adapter; 234 - int foundcurrent; 235 - int i; 223 + struct bss_descriptor * iter_bss; 224 + int i = 0; 236 225 237 - foundcurrent = 0; 226 + if (adapter->connect_status == libertas_connected) 227 + return; 238 228 239 - if (adapter->connect_status == libertas_connected) { 240 - /* try to find the current BSSID in the new scan list */ 241 - for (i = 0; i < adapter->numinscantable; i++) { 242 - if (!libertas_SSID_cmp(&adapter->scantable[i].ssid, 243 - &adapter->curbssparams.ssid) && 244 - !memcmp(adapter->curbssparams.bssid, 245 - adapter->scantable[i].macaddress, 246 - ETH_ALEN)) { 247 - foundcurrent = 1; 248 - } 249 - } 250 - 251 - if (foundcurrent) { 252 - /* Make a copy of current BSSID descriptor */ 253 - memcpy(&adapter->curbssparams.bssdescriptor, 254 - &adapter->scantable[i], 255 - sizeof(adapter->curbssparams.bssdescriptor)); 256 - } 229 + mutex_lock(&adapter->lock); 230 + list_for_each_entry (iter_bss, &adapter->network_list, list) { 231 + lbs_deb_scan("Scan:(%02d) " MAC_FMT ", RSSI[%03d], SSID[%s]\n", 232 + i++, MAC_ARG(iter_bss->bssid), (s32) iter_bss->rssi, 233 + escape_essid(iter_bss->ssid, iter_bss->ssid_len)); 257 234 } 258 - 259 - for (i = 0; i < adapter->numinscantable; i++) { 260 - lbs_pr_debug(1, "Scan:(%02d) %02x:%02x:%02x:%02x:%02x:%02x, " 261 - "RSSI[%03d], SSID[%s]\n", 262 - i, 263 - adapter->scantable[i].macaddress[0], 264 - adapter->scantable[i].macaddress[1], 265 - adapter->scantable[i].macaddress[2], 266 - adapter->scantable[i].macaddress[3], 267 - adapter->scantable[i].macaddress[4], 268 - adapter->scantable[i].macaddress[5], 269 - (s32) adapter->scantable[i].rssi, 270 - adapter->scantable[i].ssid.ssid); 271 - } 235 + mutex_unlock(&adapter->lock); 272 236 } 273 237 274 238 /** ··· 324 338 325 339 if (scantype == cmd_scan_type_passive) { 326 340 scanchanlist[chanidx].maxscantime = 327 - cpu_to_le16 328 - (MRVDRV_PASSIVE_SCAN_CHAN_TIME); 341 + cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME); 329 342 scanchanlist[chanidx].chanscanmode.passivescan = 330 343 1; 331 344 } else { 332 345 scanchanlist[chanidx].maxscantime = 333 - cpu_to_le16 334 - (MRVDRV_ACTIVE_SCAN_CHAN_TIME); 346 + cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME); 335 347 scanchanlist[chanidx].chanscanmode.passivescan = 336 348 0; 337 349 } ··· 392 408 u8 * pscancurrentonly) 393 409 { 394 410 wlan_adapter *adapter = priv->adapter; 395 - const u8 zeromac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; 396 411 struct mrvlietypes_numprobes *pnumprobestlv; 397 412 struct mrvlietypes_ssidparamset *pssidtlv; 398 413 struct wlan_scan_cmd_config * pscancfgout = NULL; 399 414 u8 *ptlvpos; 400 415 u16 numprobes; 401 - u16 ssidlen; 402 416 int chanidx; 403 417 int scantype; 404 418 int scandur; ··· 453 471 * Set the BSSID filter to the incoming configuration, 454 472 * if non-zero. If not set, it will remain disabled (all zeros). 455 473 */ 456 - memcpy(pscancfgout->specificBSSID, 457 - puserscanin->specificBSSID, 458 - sizeof(pscancfgout->specificBSSID)); 474 + memcpy(pscancfgout->bssid, puserscanin->bssid, 475 + sizeof(pscancfgout->bssid)); 459 476 460 - ssidlen = strlen(puserscanin->specificSSID); 461 - 462 - if (ssidlen) { 477 + if (puserscanin->ssid_len) { 463 478 pssidtlv = 464 479 (struct mrvlietypes_ssidparamset *) pscancfgout-> 465 480 tlvbuffer; 466 481 pssidtlv->header.type = cpu_to_le16(TLV_TYPE_SSID); 467 - pssidtlv->header.len = cpu_to_le16(ssidlen); 468 - memcpy(pssidtlv->ssid, puserscanin->specificSSID, 469 - ssidlen); 470 - ptlvpos += sizeof(pssidtlv->header) + ssidlen; 482 + pssidtlv->header.len = cpu_to_le16(puserscanin->ssid_len); 483 + memcpy(pssidtlv->ssid, puserscanin->ssid, 484 + puserscanin->ssid_len); 485 + ptlvpos += sizeof(pssidtlv->header) + puserscanin->ssid_len; 471 486 } 472 487 473 488 /* ··· 473 494 * scan results. That is not an issue with an SSID or BSSID 474 495 * filter applied to the scan results in the firmware. 475 496 */ 476 - if (ssidlen || (memcmp(pscancfgout->specificBSSID, 477 - &zeromac, sizeof(zeromac)) != 0)) { 497 + if ( puserscanin->ssid_len 498 + || (compare_ether_addr(pscancfgout->bssid, &zeromac[0]) != 0)) { 478 499 *pmaxchanperscan = MRVDRV_MAX_CHANNELS_PER_SCAN; 479 500 *pfilteredscan = 1; 480 501 } ··· 486 507 /* If the input config or adapter has the number of Probes set, add tlv */ 487 508 if (numprobes) { 488 509 pnumprobestlv = (struct mrvlietypes_numprobes *) ptlvpos; 489 - pnumprobestlv->header.type = 490 - cpu_to_le16(TLV_TYPE_NUMPROBES); 491 - pnumprobestlv->header.len = sizeof(pnumprobestlv->numprobes); 510 + pnumprobestlv->header.type = cpu_to_le16(TLV_TYPE_NUMPROBES); 511 + pnumprobestlv->header.len = cpu_to_le16(2); 492 512 pnumprobestlv->numprobes = cpu_to_le16(numprobes); 493 513 494 - ptlvpos += 495 - sizeof(pnumprobestlv->header) + pnumprobestlv->header.len; 496 - 497 - pnumprobestlv->header.len = 498 - cpu_to_le16(pnumprobestlv->header.len); 514 + ptlvpos += sizeof(*pnumprobestlv); 499 515 } 500 516 501 517 /* ··· 503 529 504 530 if (puserscanin && puserscanin->chanlist[0].channumber) { 505 531 506 - lbs_pr_debug(1, "Scan: Using supplied channel list\n"); 532 + lbs_deb_scan("Scan: Using supplied channel list\n"); 507 533 508 534 for (chanidx = 0; 509 535 chanidx < WLAN_IOCTL_USER_SCAN_CHAN_MAX ··· 547 573 == 548 574 priv->adapter->curbssparams.channel)) { 549 575 *pscancurrentonly = 1; 550 - lbs_pr_debug(1, "Scan: Scanning current channel only"); 576 + lbs_deb_scan("Scan: Scanning current channel only"); 551 577 } 552 578 553 579 } else { 554 - lbs_pr_debug(1, "Scan: Creating full region channel list\n"); 580 + lbs_deb_scan("Scan: Creating full region channel list\n"); 555 581 wlan_scan_create_channel_list(priv, pscanchanlist, 556 582 *pfilteredscan); 557 583 } ··· 587 613 u8 filteredscan, 588 614 struct wlan_scan_cmd_config * pscancfgout, 589 615 struct mrvlietypes_chanlistparamset * pchantlvout, 590 - struct chanscanparamset * pscanchanlist) 616 + struct chanscanparamset * pscanchanlist, 617 + const struct wlan_ioctl_user_scan_cfg * puserscanin, 618 + int full_scan) 591 619 { 592 620 struct chanscanparamset *ptmpchan; 593 621 struct chanscanparamset *pstartchan; ··· 597 621 int doneearly; 598 622 int tlvidx; 599 623 int ret = 0; 624 + int scanned = 0; 625 + union iwreq_data wrqu; 600 626 601 - ENTER(); 627 + lbs_deb_enter(LBS_DEB_ASSOC); 602 628 603 629 if (pscancfgout == 0 || pchantlvout == 0 || pscanchanlist == 0) { 604 - lbs_pr_debug(1, "Scan: Null detect: %p, %p, %p\n", 630 + lbs_deb_scan("Scan: Null detect: %p, %p, %p\n", 605 631 pscancfgout, pchantlvout, pscanchanlist); 606 632 return -1; 607 633 } ··· 612 634 613 635 /* Set the temp channel struct pointer to the start of the desired list */ 614 636 ptmpchan = pscanchanlist; 637 + 638 + if (priv->adapter->last_scanned_channel && !puserscanin) 639 + ptmpchan += priv->adapter->last_scanned_channel; 615 640 616 641 /* Loop through the desired channel list, sending a new firmware scan 617 642 * commands for each maxchanperscan channels (or for 1,6,11 individually ··· 635 654 * - doneearly is set (controlling individual scanning of 1,6,11) 636 655 */ 637 656 while (tlvidx < maxchanperscan && ptmpchan->channumber 638 - && !doneearly) { 657 + && !doneearly && scanned < 2) { 639 658 640 - lbs_pr_debug(1, 659 + lbs_deb_scan( 641 660 "Scan: Chan(%3d), Radio(%d), mode(%d,%d), Dur(%d)\n", 642 661 ptmpchan->channumber, ptmpchan->radiotype, 643 662 ptmpchan->chanscanmode.passivescan, ··· 649 668 ptmpchan, sizeof(pchantlvout->chanscanparam)); 650 669 651 670 /* Increment the TLV header length by the size appended */ 652 - pchantlvout->header.len += 653 - sizeof(pchantlvout->chanscanparam); 671 + /* Ew, it would be _so_ nice if we could just declare the 672 + variable little-endian and let GCC handle it for us */ 673 + pchantlvout->header.len = 674 + cpu_to_le16(le16_to_cpu(pchantlvout->header.len) + 675 + sizeof(pchantlvout->chanscanparam)); 654 676 655 677 /* 656 678 * The tlv buffer length is set to the number of bytes of the ··· 667 683 /* Add the size of the channel tlv header and the data length */ 668 684 pscancfgout->tlvbufferlen += 669 685 (sizeof(pchantlvout->header) 670 - + pchantlvout->header.len); 686 + + le16_to_cpu(pchantlvout->header.len)); 671 687 672 688 /* Increment the index to the channel tlv we are constructing */ 673 689 tlvidx++; ··· 685 701 686 702 /* Increment the tmp pointer to the next channel to be scanned */ 687 703 ptmpchan++; 704 + scanned++; 688 705 689 706 /* Stop the loop if the *next* channel is in the 1,6,11 set. 690 707 * This will cause it to be the only channel scanned on the next ··· 701 716 /* Send the scan command to the firmware with the specified cfg */ 702 717 ret = libertas_prepare_and_send_command(priv, cmd_802_11_scan, 0, 703 718 0, 0, pscancfgout); 719 + if (scanned >= 2 && !full_scan) { 720 + ret = 0; 721 + goto done; 722 + } 723 + scanned = 0; 704 724 } 705 725 706 - LEAVE(); 726 + done: 727 + priv->adapter->last_scanned_channel = ptmpchan->channumber; 728 + 729 + /* Tell userspace the scan table has been updated */ 730 + memset(&wrqu, 0, sizeof(union iwreq_data)); 731 + wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); 732 + 733 + lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 707 734 return ret; 708 735 } 736 + 737 + static void 738 + clear_selected_scan_list_entries(wlan_adapter * adapter, 739 + const struct wlan_ioctl_user_scan_cfg * scan_cfg) 740 + { 741 + struct bss_descriptor * bss; 742 + struct bss_descriptor * safe; 743 + u32 clear_ssid_flag = 0, clear_bssid_flag = 0; 744 + 745 + if (!scan_cfg) 746 + return; 747 + 748 + if (scan_cfg->clear_ssid && scan_cfg->ssid_len) 749 + clear_ssid_flag = 1; 750 + 751 + if (scan_cfg->clear_bssid 752 + && (compare_ether_addr(scan_cfg->bssid, &zeromac[0]) != 0) 753 + && (compare_ether_addr(scan_cfg->bssid, &bcastmac[0]) != 0)) { 754 + clear_bssid_flag = 1; 755 + } 756 + 757 + if (!clear_ssid_flag && !clear_bssid_flag) 758 + return; 759 + 760 + mutex_lock(&adapter->lock); 761 + list_for_each_entry_safe (bss, safe, &adapter->network_list, list) { 762 + u32 clear = 0; 763 + 764 + /* Check for an SSID match */ 765 + if ( clear_ssid_flag 766 + && (bss->ssid_len == scan_cfg->ssid_len) 767 + && !memcmp(bss->ssid, scan_cfg->ssid, bss->ssid_len)) 768 + clear = 1; 769 + 770 + /* Check for a BSSID match */ 771 + if ( clear_bssid_flag 772 + && !compare_ether_addr(bss->bssid, scan_cfg->bssid)) 773 + clear = 1; 774 + 775 + if (clear) { 776 + list_move_tail (&bss->list, &adapter->network_free_list); 777 + clear_bss_descriptor(bss); 778 + } 779 + } 780 + mutex_unlock(&adapter->lock); 781 + } 782 + 709 783 710 784 /** 711 785 * @brief Internal function used to start a scan based on an input config ··· 780 736 * @return 0 or < 0 if error 781 737 */ 782 738 int wlan_scan_networks(wlan_private * priv, 783 - const struct wlan_ioctl_user_scan_cfg * puserscanin) 739 + const struct wlan_ioctl_user_scan_cfg * puserscanin, 740 + int full_scan) 784 741 { 785 - wlan_adapter *adapter = priv->adapter; 742 + wlan_adapter * adapter = priv->adapter; 786 743 struct mrvlietypes_chanlistparamset *pchantlvout; 787 744 struct chanscanparamset * scan_chan_list = NULL; 788 745 struct wlan_scan_cmd_config * scan_cfg = NULL; 789 - u8 keeppreviousscan; 790 746 u8 filteredscan; 791 747 u8 scancurrentchanonly; 792 748 int maxchanperscan; 793 749 int ret; 794 750 795 - ENTER(); 751 + lbs_deb_enter(LBS_DEB_ASSOC); 796 752 797 753 scan_chan_list = kzalloc(sizeof(struct chanscanparamset) * 798 754 WLAN_IOCTL_USER_SCAN_CHAN_MAX, GFP_KERNEL); ··· 813 769 goto out; 814 770 } 815 771 816 - keeppreviousscan = 0; 817 - 818 - if (puserscanin) { 819 - keeppreviousscan = puserscanin->keeppreviousscan; 820 - } 821 - 822 - if (!keeppreviousscan) { 823 - memset(adapter->scantable, 0x00, 824 - sizeof(struct bss_descriptor) * MRVDRV_MAX_BSSID_LIST); 825 - adapter->numinscantable = 0; 826 - } 772 + clear_selected_scan_list_entries(adapter, puserscanin); 827 773 828 774 /* Keep the data path active if we are only scanning our current channel */ 829 775 if (!scancurrentchanonly) { 830 - netif_stop_queue(priv->wlan_dev.netdev); 831 - netif_carrier_off(priv->wlan_dev.netdev); 776 + netif_stop_queue(priv->dev); 777 + netif_carrier_off(priv->dev); 778 + netif_stop_queue(priv->mesh_dev); 779 + netif_carrier_off(priv->mesh_dev); 832 780 } 833 781 834 782 ret = wlan_scan_channel_list(priv, ··· 828 792 filteredscan, 829 793 scan_cfg, 830 794 pchantlvout, 831 - scan_chan_list); 795 + scan_chan_list, 796 + puserscanin, 797 + full_scan); 832 798 833 799 /* Process the resulting scan table: 834 800 * - Remove any bad ssids ··· 839 801 wlan_scan_process_results(priv); 840 802 841 803 if (priv->adapter->connect_status == libertas_connected) { 842 - netif_carrier_on(priv->wlan_dev.netdev); 843 - netif_wake_queue(priv->wlan_dev.netdev); 804 + netif_carrier_on(priv->dev); 805 + netif_wake_queue(priv->dev); 806 + netif_carrier_on(priv->mesh_dev); 807 + netif_wake_queue(priv->mesh_dev); 844 808 } 845 809 846 810 out: ··· 852 812 if (scan_chan_list) 853 813 kfree(scan_chan_list); 854 814 855 - LEAVE(); 815 + lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 856 816 return ret; 857 817 } 858 818 ··· 883 843 tlvbufleft = tlvbufsize; 884 844 *ptsftlv = NULL; 885 845 886 - lbs_pr_debug(1, "SCAN_RESP: tlvbufsize = %d\n", tlvbufsize); 846 + lbs_deb_scan("SCAN_RESP: tlvbufsize = %d\n", tlvbufsize); 887 847 lbs_dbg_hex("SCAN_RESP: TLV Buf", (u8 *) ptlv, tlvbufsize); 888 848 889 849 while (tlvbufleft >= sizeof(struct mrvlietypesheader)) { ··· 896 856 break; 897 857 898 858 default: 899 - lbs_pr_debug(1, "SCAN_RESP: Unhandled TLV = %d\n", 859 + lbs_deb_scan("SCAN_RESP: Unhandled TLV = %d\n", 900 860 tlvtype); 901 861 /* Give up, this seems corrupted */ 902 862 return; ··· 915 875 * response or beacon from the scan command. Record information as needed 916 876 * in the scan table struct bss_descriptor for that entry. 917 877 * 918 - * @param pBSSIDEntry Output parameter: Pointer to the BSS Entry 878 + * @param bss Output parameter: Pointer to the BSS Entry 919 879 * 920 880 * @return 0 or -1 921 881 */ 922 - static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry, 923 - u8 ** pbeaconinfo, int *bytesleft) 882 + static int libertas_process_bss(struct bss_descriptor * bss, 883 + u8 ** pbeaconinfo, int *bytesleft) 924 884 { 925 885 enum ieeetypes_elementid elemID; 926 886 struct ieeetypes_fhparamset *pFH; ··· 937 897 u16 beaconsize; 938 898 u8 founddatarateie; 939 899 int bytesleftforcurrentbeacon; 900 + int ret; 940 901 941 902 struct IE_WPA *pIe; 942 903 const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; 943 904 944 905 struct ieeetypes_countryinfoset *pcountryinfo; 945 906 946 - ENTER(); 907 + lbs_deb_enter(LBS_DEB_ASSOC); 947 908 948 909 founddatarateie = 0; 949 910 ratesize = 0; ··· 952 911 953 912 if (*bytesleft >= sizeof(beaconsize)) { 954 913 /* Extract & convert beacon size from the command buffer */ 955 - memcpy(&beaconsize, *pbeaconinfo, sizeof(beaconsize)); 956 - beaconsize = le16_to_cpu(beaconsize); 914 + beaconsize = le16_to_cpup((void *)*pbeaconinfo); 957 915 *bytesleft -= sizeof(beaconsize); 958 916 *pbeaconinfo += sizeof(beaconsize); 959 917 } ··· 974 934 975 935 bytesleftforcurrentbeacon = beaconsize; 976 936 977 - memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); 978 - lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", 979 - pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], 980 - pBSSEntry->macaddress[2], pBSSEntry->macaddress[3], 981 - pBSSEntry->macaddress[4], pBSSEntry->macaddress[5]); 937 + memcpy(bss->bssid, pcurrentptr, ETH_ALEN); 938 + lbs_deb_scan("process_bss: AP BSSID " MAC_FMT "\n", MAC_ARG(bss->bssid)); 982 939 983 940 pcurrentptr += ETH_ALEN; 984 941 bytesleftforcurrentbeacon -= ETH_ALEN; 985 942 986 943 if (bytesleftforcurrentbeacon < 12) { 987 - lbs_pr_debug(1, "InterpretIE: Not enough bytes left\n"); 944 + lbs_deb_scan("process_bss: Not enough bytes left\n"); 988 945 return -1; 989 946 } 990 947 ··· 991 954 */ 992 955 993 956 /* RSSI is 1 byte long */ 994 - pBSSEntry->rssi = le32_to_cpu((long)(*pcurrentptr)); 995 - lbs_pr_debug(1, "InterpretIE: RSSI=%02X\n", *pcurrentptr); 957 + bss->rssi = *pcurrentptr; 958 + lbs_deb_scan("process_bss: RSSI=%02X\n", *pcurrentptr); 996 959 pcurrentptr += 1; 997 960 bytesleftforcurrentbeacon -= 1; 998 961 999 962 /* time stamp is 8 bytes long */ 1000 - memcpy(fixedie.timestamp, pcurrentptr, 8); 1001 - memcpy(pBSSEntry->timestamp, pcurrentptr, 8); 963 + fixedie.timestamp = bss->timestamp = le64_to_cpup((void *)pcurrentptr); 1002 964 pcurrentptr += 8; 1003 965 bytesleftforcurrentbeacon -= 8; 1004 966 1005 967 /* beacon interval is 2 bytes long */ 1006 - memcpy(&fixedie.beaconinterval, pcurrentptr, 2); 1007 - pBSSEntry->beaconperiod = le16_to_cpu(fixedie.beaconinterval); 968 + fixedie.beaconinterval = bss->beaconperiod = le16_to_cpup((void *)pcurrentptr); 1008 969 pcurrentptr += 2; 1009 970 bytesleftforcurrentbeacon -= 2; 1010 971 1011 972 /* capability information is 2 bytes long */ 1012 - memcpy(&fixedie.capabilities, pcurrentptr, 2); 1013 - lbs_pr_debug(1, "InterpretIE: fixedie.capabilities=0x%X\n", 973 + memcpy(&fixedie.capabilities, pcurrentptr, 2); 974 + lbs_deb_scan("process_bss: fixedie.capabilities=0x%X\n", 1014 975 fixedie.capabilities); 1015 - fixedie.capabilities = le16_to_cpu(fixedie.capabilities); 1016 976 pcap = (struct ieeetypes_capinfo *) & fixedie.capabilities; 1017 - memcpy(&pBSSEntry->cap, pcap, sizeof(struct ieeetypes_capinfo)); 977 + memcpy(&bss->cap, pcap, sizeof(struct ieeetypes_capinfo)); 1018 978 pcurrentptr += 2; 1019 979 bytesleftforcurrentbeacon -= 2; 1020 980 1021 981 /* rest of the current buffer are IE's */ 1022 - lbs_pr_debug(1, "InterpretIE: IElength for this AP = %d\n", 982 + lbs_deb_scan("process_bss: IE length for this AP = %d\n", 1023 983 bytesleftforcurrentbeacon); 1024 984 1025 - lbs_dbg_hex("InterpretIE: IE info", (u8 *) pcurrentptr, 985 + lbs_dbg_hex("process_bss: IE info", (u8 *) pcurrentptr, 1026 986 bytesleftforcurrentbeacon); 1027 987 1028 988 if (pcap->privacy) { 1029 - lbs_pr_debug(1, "InterpretIE: AP WEP enabled\n"); 1030 - pBSSEntry->privacy = wlan802_11privfilter8021xWEP; 989 + lbs_deb_scan("process_bss: AP WEP enabled\n"); 990 + bss->privacy = wlan802_11privfilter8021xWEP; 1031 991 } else { 1032 - pBSSEntry->privacy = wlan802_11privfilteracceptall; 992 + bss->privacy = wlan802_11privfilteracceptall; 1033 993 } 1034 994 1035 995 if (pcap->ibss == 1) { 1036 - pBSSEntry->mode = IW_MODE_ADHOC; 996 + bss->mode = IW_MODE_ADHOC; 1037 997 } else { 1038 - pBSSEntry->mode = IW_MODE_INFRA; 998 + bss->mode = IW_MODE_INFRA; 1039 999 } 1040 1000 1041 1001 /* process variable IE */ ··· 1041 1007 elemlen = *((u8 *) pcurrentptr + 1); 1042 1008 1043 1009 if (bytesleftforcurrentbeacon < elemlen) { 1044 - lbs_pr_debug(1, "InterpretIE: error in processing IE, " 1010 + lbs_deb_scan("process_bss: error in processing IE, " 1045 1011 "bytes left < IE length\n"); 1046 1012 bytesleftforcurrentbeacon = 0; 1047 1013 continue; 1048 1014 } 1049 1015 1050 1016 switch (elemID) { 1051 - 1052 1017 case SSID: 1053 - pBSSEntry->ssid.ssidlength = elemlen; 1054 - memcpy(pBSSEntry->ssid.ssid, (pcurrentptr + 2), 1055 - elemlen); 1056 - lbs_pr_debug(1, "ssid: %32s", pBSSEntry->ssid.ssid); 1018 + bss->ssid_len = elemlen; 1019 + memcpy(bss->ssid, (pcurrentptr + 2), elemlen); 1020 + lbs_deb_scan("ssid '%s', ssid length %u\n", 1021 + escape_essid(bss->ssid, bss->ssid_len), 1022 + bss->ssid_len); 1057 1023 break; 1058 1024 1059 1025 case SUPPORTED_RATES: 1060 - memcpy(pBSSEntry->datarates, (pcurrentptr + 2), 1061 - elemlen); 1062 - memmove(pBSSEntry->libertas_supported_rates, (pcurrentptr + 2), 1026 + memcpy(bss->datarates, (pcurrentptr + 2), elemlen); 1027 + memmove(bss->libertas_supported_rates, (pcurrentptr + 2), 1063 1028 elemlen); 1064 1029 ratesize = elemlen; 1065 1030 founddatarateie = 1; 1066 1031 break; 1067 1032 1068 1033 case EXTRA_IE: 1069 - lbs_pr_debug(1, "InterpretIE: EXTRA_IE Found!\n"); 1070 - pBSSEntry->extra_ie = 1; 1034 + lbs_deb_scan("process_bss: EXTRA_IE Found!\n"); 1071 1035 break; 1072 1036 1073 1037 case FH_PARAM_SET: 1074 1038 pFH = (struct ieeetypes_fhparamset *) pcurrentptr; 1075 - memmove(&pBSSEntry->phyparamset.fhparamset, pFH, 1039 + memmove(&bss->phyparamset.fhparamset, pFH, 1076 1040 sizeof(struct ieeetypes_fhparamset)); 1077 - pBSSEntry->phyparamset.fhparamset.dwelltime 1078 - = 1079 - le16_to_cpu(pBSSEntry->phyparamset.fhparamset. 1080 - dwelltime); 1041 + #if 0 /* I think we can store these LE */ 1042 + bss->phyparamset.fhparamset.dwelltime 1043 + = le16_to_cpu(bss->phyparamset.fhparamset.dwelltime); 1044 + #endif 1081 1045 break; 1082 1046 1083 1047 case DS_PARAM_SET: 1084 1048 pDS = (struct ieeetypes_dsparamset *) pcurrentptr; 1085 - 1086 - pBSSEntry->channel = pDS->currentchan; 1087 - 1088 - memcpy(&pBSSEntry->phyparamset.dsparamset, pDS, 1049 + bss->channel = pDS->currentchan; 1050 + memcpy(&bss->phyparamset.dsparamset, pDS, 1089 1051 sizeof(struct ieeetypes_dsparamset)); 1090 1052 break; 1091 1053 1092 1054 case CF_PARAM_SET: 1093 1055 pCF = (struct ieeetypes_cfparamset *) pcurrentptr; 1094 - 1095 - memcpy(&pBSSEntry->ssparamset.cfparamset, pCF, 1056 + memcpy(&bss->ssparamset.cfparamset, pCF, 1096 1057 sizeof(struct ieeetypes_cfparamset)); 1097 1058 break; 1098 1059 1099 1060 case IBSS_PARAM_SET: 1100 1061 pibss = (struct ieeetypes_ibssparamset *) pcurrentptr; 1101 - pBSSEntry->atimwindow = 1102 - le32_to_cpu(pibss->atimwindow); 1103 - 1104 - memmove(&pBSSEntry->ssparamset.ibssparamset, pibss, 1062 + bss->atimwindow = le32_to_cpu(pibss->atimwindow); 1063 + memmove(&bss->ssparamset.ibssparamset, pibss, 1105 1064 sizeof(struct ieeetypes_ibssparamset)); 1106 - 1107 - pBSSEntry->ssparamset.ibssparamset.atimwindow 1108 - = 1109 - le16_to_cpu(pBSSEntry->ssparamset.ibssparamset. 1110 - atimwindow); 1065 + #if 0 1066 + bss->ssparamset.ibssparamset.atimwindow 1067 + = le16_to_cpu(bss->ssparamset.ibssparamset.atimwindow); 1068 + #endif 1111 1069 break; 1112 1070 1113 1071 /* Handle Country Info IE */ 1114 1072 case COUNTRY_INFO: 1115 - pcountryinfo = 1116 - (struct ieeetypes_countryinfoset *) pcurrentptr; 1117 - 1118 - if (pcountryinfo->len < 1119 - sizeof(pcountryinfo->countrycode) 1073 + pcountryinfo = (struct ieeetypes_countryinfoset *) pcurrentptr; 1074 + if (pcountryinfo->len < sizeof(pcountryinfo->countrycode) 1120 1075 || pcountryinfo->len > 254) { 1121 - lbs_pr_debug(1, "InterpretIE: 11D- Err " 1076 + lbs_deb_scan("process_bss: 11D- Err " 1122 1077 "CountryInfo len =%d min=%zd max=254\n", 1123 1078 pcountryinfo->len, 1124 1079 sizeof(pcountryinfo->countrycode)); 1125 - LEAVE(); 1126 - return -1; 1080 + ret = -1; 1081 + goto done; 1127 1082 } 1128 1083 1129 - memcpy(&pBSSEntry->countryinfo, 1084 + memcpy(&bss->countryinfo, 1130 1085 pcountryinfo, pcountryinfo->len + 2); 1131 - lbs_dbg_hex("InterpretIE: 11D- CountryInfo:", 1086 + lbs_dbg_hex("process_bss: 11D- CountryInfo:", 1132 1087 (u8 *) pcountryinfo, 1133 1088 (u32) (pcountryinfo->len + 2)); 1134 1089 break; ··· 1137 1114 bytestocopy = elemlen; 1138 1115 } 1139 1116 1140 - pRate = (u8 *) pBSSEntry->datarates; 1117 + pRate = (u8 *) bss->datarates; 1141 1118 pRate += ratesize; 1142 1119 memmove(pRate, (pcurrentptr + 2), bytestocopy); 1143 - 1144 - pRate = (u8 *) pBSSEntry->libertas_supported_rates; 1145 - 1120 + pRate = (u8 *) bss->libertas_supported_rates; 1146 1121 pRate += ratesize; 1147 1122 memmove(pRate, (pcurrentptr + 2), bytestocopy); 1148 1123 } ··· 1153 1132 if (memcmp(pIe->oui, oui01, sizeof(oui01))) 1154 1133 break; 1155 1134 1156 - pBSSEntry->wpa_ie_len = min_t(size_t, 1157 - elemlen + IE_ID_LEN_FIELDS_BYTES, 1158 - sizeof(pBSSEntry->wpa_ie)); 1159 - memcpy(pBSSEntry->wpa_ie, pcurrentptr, 1160 - pBSSEntry->wpa_ie_len); 1161 - lbs_dbg_hex("InterpretIE: Resp WPA_IE", 1162 - pBSSEntry->wpa_ie, elemlen); 1135 + bss->wpa_ie_len = min(elemlen + IE_ID_LEN_FIELDS_BYTES, 1136 + MAX_WPA_IE_LEN); 1137 + memcpy(bss->wpa_ie, pcurrentptr, bss->wpa_ie_len); 1138 + lbs_dbg_hex("process_bss: WPA IE", bss->wpa_ie, elemlen); 1163 1139 break; 1164 1140 case WPA2_IE: 1165 1141 pIe = (struct IE_WPA *)pcurrentptr; 1166 - 1167 - pBSSEntry->rsn_ie_len = min_t(size_t, 1168 - elemlen + IE_ID_LEN_FIELDS_BYTES, 1169 - sizeof(pBSSEntry->rsn_ie)); 1170 - memcpy(pBSSEntry->rsn_ie, pcurrentptr, 1171 - pBSSEntry->rsn_ie_len); 1172 - lbs_dbg_hex("InterpretIE: Resp WPA2_IE", 1173 - pBSSEntry->rsn_ie, elemlen); 1142 + bss->rsn_ie_len = min(elemlen + IE_ID_LEN_FIELDS_BYTES, 1143 + MAX_WPA_IE_LEN); 1144 + memcpy(bss->rsn_ie, pcurrentptr, bss->rsn_ie_len); 1145 + lbs_dbg_hex("process_bss: RSN_IE", bss->rsn_ie, elemlen); 1174 1146 break; 1175 1147 case TIM: 1176 1148 break; ··· 1179 1165 1180 1166 } /* while (bytesleftforcurrentbeacon > 2) */ 1181 1167 1182 - return 0; 1168 + /* Timestamp */ 1169 + bss->last_scanned = jiffies; 1170 + 1171 + ret = 0; 1172 + 1173 + done: 1174 + lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 1175 + return ret; 1183 1176 } 1184 1177 1185 1178 /** ··· 1197 1176 * 1198 1177 * @return 0--ssid is same, otherwise is different 1199 1178 */ 1200 - int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *ssid2) 1179 + int libertas_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len) 1201 1180 { 1202 - if (!ssid1 || !ssid2) 1181 + if (ssid1_len != ssid2_len) 1203 1182 return -1; 1204 1183 1205 - if (ssid1->ssidlength != ssid2->ssidlength) 1206 - return -1; 1207 - 1208 - return memcmp(ssid1->ssid, ssid2->ssid, ssid1->ssidlength); 1184 + return memcmp(ssid1, ssid2, ssid1_len); 1209 1185 } 1210 1186 1211 1187 /** ··· 1214 1196 * 1215 1197 * @return index in BSSID list, or error return code (< 0) 1216 1198 */ 1217 - int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode) 1199 + struct bss_descriptor * libertas_find_bssid_in_list(wlan_adapter * adapter, 1200 + u8 * bssid, u8 mode) 1218 1201 { 1219 - int ret = -ENETUNREACH; 1220 - int i; 1202 + struct bss_descriptor * iter_bss; 1203 + struct bss_descriptor * found_bss = NULL; 1221 1204 1222 1205 if (!bssid) 1223 - return -EFAULT; 1206 + return NULL; 1224 1207 1225 - lbs_pr_debug(1, "FindBSSID: Num of BSSIDs = %d\n", 1226 - adapter->numinscantable); 1208 + lbs_dbg_hex("libertas_find_BSSID_in_list: looking for ", 1209 + bssid, ETH_ALEN); 1227 1210 1228 - /* Look through the scan table for a compatible match. The ret return 1229 - * variable will be equal to the index in the scan table (greater 1230 - * than zero) if the network is compatible. The loop will continue 1231 - * past a matched bssid that is not compatible in case there is an 1232 - * AP with multiple SSIDs assigned to the same BSSID 1211 + /* Look through the scan table for a compatible match. The loop will 1212 + * continue past a matched bssid that is not compatible in case there 1213 + * is an AP with multiple SSIDs assigned to the same BSSID 1233 1214 */ 1234 - for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { 1235 - if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { 1236 - switch (mode) { 1237 - case IW_MODE_INFRA: 1238 - case IW_MODE_ADHOC: 1239 - ret = is_network_compatible(adapter, i, mode); 1215 + mutex_lock(&adapter->lock); 1216 + list_for_each_entry (iter_bss, &adapter->network_list, list) { 1217 + if (compare_ether_addr(iter_bss->bssid, bssid)) 1218 + continue; /* bssid doesn't match */ 1219 + switch (mode) { 1220 + case IW_MODE_INFRA: 1221 + case IW_MODE_ADHOC: 1222 + if (!is_network_compatible(adapter, iter_bss, mode)) 1240 1223 break; 1241 - default: 1242 - ret = i; 1243 - break; 1244 - } 1224 + found_bss = iter_bss; 1225 + break; 1226 + default: 1227 + found_bss = iter_bss; 1228 + break; 1245 1229 } 1246 1230 } 1231 + mutex_unlock(&adapter->lock); 1247 1232 1248 - return ret; 1233 + return found_bss; 1249 1234 } 1250 1235 1251 1236 /** ··· 1261 1240 * 1262 1241 * @return index in BSSID list 1263 1242 */ 1264 - int libertas_find_SSID_in_list(wlan_adapter * adapter, 1265 - struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode) 1243 + struct bss_descriptor * libertas_find_ssid_in_list(wlan_adapter * adapter, 1244 + u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, 1245 + int channel) 1266 1246 { 1267 - int net = -ENETUNREACH; 1268 1247 u8 bestrssi = 0; 1269 - int i; 1270 - int j; 1248 + struct bss_descriptor * iter_bss = NULL; 1249 + struct bss_descriptor * found_bss = NULL; 1250 + struct bss_descriptor * tmp_oldest = NULL; 1271 1251 1272 - lbs_pr_debug(1, "Num of Entries in Table = %d\n", adapter->numinscantable); 1252 + mutex_lock(&adapter->lock); 1273 1253 1274 - for (i = 0; i < adapter->numinscantable; i++) { 1275 - if (!libertas_SSID_cmp(&adapter->scantable[i].ssid, ssid) && 1276 - (!bssid || 1277 - !memcmp(adapter->scantable[i]. 1278 - macaddress, bssid, ETH_ALEN))) { 1279 - switch (mode) { 1280 - case IW_MODE_INFRA: 1281 - case IW_MODE_ADHOC: 1282 - j = is_network_compatible(adapter, i, mode); 1254 + list_for_each_entry (iter_bss, &adapter->network_list, list) { 1255 + if ( !tmp_oldest 1256 + || (iter_bss->last_scanned < tmp_oldest->last_scanned)) 1257 + tmp_oldest = iter_bss; 1283 1258 1284 - if (j >= 0) { 1285 - if (bssid) { 1286 - return i; 1287 - } 1259 + if (libertas_ssid_cmp(iter_bss->ssid, iter_bss->ssid_len, 1260 + ssid, ssid_len) != 0) 1261 + continue; /* ssid doesn't match */ 1262 + if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0) 1263 + continue; /* bssid doesn't match */ 1264 + if ((channel > 0) && (iter_bss->channel != channel)) 1265 + continue; /* channel doesn't match */ 1288 1266 1289 - if (SCAN_RSSI 1290 - (adapter->scantable[i].rssi) 1291 - > bestrssi) { 1292 - bestrssi = 1293 - SCAN_RSSI(adapter-> 1294 - scantable[i]. 1295 - rssi); 1296 - net = i; 1297 - } 1298 - } else { 1299 - if (net == -ENETUNREACH) { 1300 - net = j; 1301 - } 1302 - } 1267 + switch (mode) { 1268 + case IW_MODE_INFRA: 1269 + case IW_MODE_ADHOC: 1270 + if (!is_network_compatible(adapter, iter_bss, mode)) 1303 1271 break; 1304 - case IW_MODE_AUTO: 1305 - default: 1306 - if (SCAN_RSSI(adapter->scantable[i].rssi) 1307 - > bestrssi) { 1308 - bestrssi = 1309 - SCAN_RSSI(adapter->scantable[i]. 1310 - rssi); 1311 - net = i; 1312 - } 1313 - break; 1272 + 1273 + if (bssid) { 1274 + /* Found requested BSSID */ 1275 + found_bss = iter_bss; 1276 + goto out; 1314 1277 } 1278 + 1279 + if (SCAN_RSSI(iter_bss->rssi) > bestrssi) { 1280 + bestrssi = SCAN_RSSI(iter_bss->rssi); 1281 + found_bss = iter_bss; 1282 + } 1283 + break; 1284 + case IW_MODE_AUTO: 1285 + default: 1286 + if (SCAN_RSSI(iter_bss->rssi) > bestrssi) { 1287 + bestrssi = SCAN_RSSI(iter_bss->rssi); 1288 + found_bss = iter_bss; 1289 + } 1290 + break; 1315 1291 } 1316 1292 } 1317 1293 1318 - return net; 1294 + out: 1295 + mutex_unlock(&adapter->lock); 1296 + return found_bss; 1319 1297 } 1320 1298 1321 1299 /** ··· 1327 1307 * 1328 1308 * @return index in BSSID list 1329 1309 */ 1330 - int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode) 1310 + struct bss_descriptor * libertas_find_best_ssid_in_list(wlan_adapter * adapter, 1311 + u8 mode) 1331 1312 { 1332 - int bestnet = -ENETUNREACH; 1333 1313 u8 bestrssi = 0; 1334 - int i; 1314 + struct bss_descriptor * iter_bss; 1315 + struct bss_descriptor * best_bss = NULL; 1335 1316 1336 - ENTER(); 1317 + mutex_lock(&adapter->lock); 1337 1318 1338 - lbs_pr_debug(1, "Num of BSSIDs = %d\n", adapter->numinscantable); 1339 - 1340 - for (i = 0; i < adapter->numinscantable; i++) { 1319 + list_for_each_entry (iter_bss, &adapter->network_list, list) { 1341 1320 switch (mode) { 1342 1321 case IW_MODE_INFRA: 1343 1322 case IW_MODE_ADHOC: 1344 - if (is_network_compatible(adapter, i, mode) >= 0) { 1345 - if (SCAN_RSSI(adapter->scantable[i].rssi) > 1346 - bestrssi) { 1347 - bestrssi = 1348 - SCAN_RSSI(adapter->scantable[i]. 1349 - rssi); 1350 - bestnet = i; 1351 - } 1352 - } 1323 + if (!is_network_compatible(adapter, iter_bss, mode)) 1324 + break; 1325 + if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) 1326 + break; 1327 + bestrssi = SCAN_RSSI(iter_bss->rssi); 1328 + best_bss = iter_bss; 1353 1329 break; 1354 1330 case IW_MODE_AUTO: 1355 1331 default: 1356 - if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { 1357 - bestrssi = 1358 - SCAN_RSSI(adapter->scantable[i].rssi); 1359 - bestnet = i; 1360 - } 1332 + if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) 1333 + break; 1334 + bestrssi = SCAN_RSSI(iter_bss->rssi); 1335 + best_bss = iter_bss; 1361 1336 break; 1362 1337 } 1363 1338 } 1364 1339 1365 - LEAVE(); 1366 - return bestnet; 1340 + mutex_unlock(&adapter->lock); 1341 + return best_bss; 1367 1342 } 1368 1343 1369 1344 /** ··· 1369 1354 * 1370 1355 * @return 0--success, otherwise--fail 1371 1356 */ 1372 - int libertas_find_best_network_SSID(wlan_private * priv, 1373 - struct WLAN_802_11_SSID *pSSID, 1374 - u8 preferred_mode, u8 *out_mode) 1357 + int libertas_find_best_network_ssid(wlan_private * priv, 1358 + u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode) 1375 1359 { 1376 1360 wlan_adapter *adapter = priv->adapter; 1377 - int ret = 0; 1378 - struct bss_descriptor *preqbssid; 1379 - int i; 1361 + int ret = -1; 1362 + struct bss_descriptor * found; 1380 1363 1381 - ENTER(); 1364 + lbs_deb_enter(LBS_DEB_ASSOC); 1382 1365 1383 - memset(pSSID, 0, sizeof(struct WLAN_802_11_SSID)); 1384 - 1385 - wlan_scan_networks(priv, NULL); 1366 + wlan_scan_networks(priv, NULL, 1); 1386 1367 if (adapter->surpriseremoved) 1387 1368 return -1; 1369 + 1388 1370 wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending); 1389 1371 1390 - i = libertas_find_best_SSID_in_list(adapter, preferred_mode); 1391 - if (i < 0) { 1392 - ret = -1; 1393 - goto out; 1372 + found = libertas_find_best_ssid_in_list(adapter, preferred_mode); 1373 + if (found && (found->ssid_len > 0)) { 1374 + memcpy(out_ssid, &found->ssid, IW_ESSID_MAX_SIZE); 1375 + *out_ssid_len = found->ssid_len; 1376 + *out_mode = found->mode; 1377 + ret = 0; 1394 1378 } 1395 1379 1396 - preqbssid = &adapter->scantable[i]; 1397 - memcpy(pSSID, &preqbssid->ssid, 1398 - sizeof(struct WLAN_802_11_SSID)); 1399 - *out_mode = preqbssid->mode; 1400 - 1401 - if (!pSSID->ssidlength) { 1402 - ret = -1; 1403 - } 1404 - 1405 - out: 1406 - LEAVE(); 1380 + lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 1407 1381 return ret; 1408 1382 } 1409 1383 ··· 1411 1407 { 1412 1408 wlan_private *priv = dev->priv; 1413 1409 wlan_adapter *adapter = priv->adapter; 1414 - union iwreq_data wrqu; 1415 1410 1416 - ENTER(); 1411 + lbs_deb_enter(LBS_DEB_SCAN); 1417 1412 1418 - if (!wlan_scan_networks(priv, NULL)) { 1419 - memset(&wrqu, 0, sizeof(union iwreq_data)); 1420 - wireless_send_event(priv->wlan_dev.netdev, SIOCGIWSCAN, &wrqu, 1421 - NULL); 1422 - } 1413 + wlan_scan_networks(priv, NULL, 0); 1423 1414 1424 1415 if (adapter->surpriseremoved) 1425 1416 return -1; 1426 1417 1427 - LEAVE(); 1418 + lbs_deb_leave(LBS_DEB_SCAN); 1428 1419 return 0; 1429 1420 } 1430 1421 ··· 1432 1433 * 1433 1434 * @return 0-success, otherwise fail 1434 1435 */ 1435 - int libertas_send_specific_SSID_scan(wlan_private * priv, 1436 - struct WLAN_802_11_SSID *prequestedssid, 1437 - u8 keeppreviousscan) 1436 + int libertas_send_specific_ssid_scan(wlan_private * priv, 1437 + u8 *ssid, u8 ssid_len, u8 clear_ssid) 1438 1438 { 1439 1439 wlan_adapter *adapter = priv->adapter; 1440 1440 struct wlan_ioctl_user_scan_cfg scancfg; 1441 + int ret = 0; 1441 1442 1442 - ENTER(); 1443 + lbs_deb_enter(LBS_DEB_ASSOC); 1443 1444 1444 - if (prequestedssid == NULL) { 1445 - return -1; 1446 - } 1445 + if (!ssid_len) 1446 + goto out; 1447 1447 1448 1448 memset(&scancfg, 0x00, sizeof(scancfg)); 1449 + memcpy(scancfg.ssid, ssid, ssid_len); 1450 + scancfg.ssid_len = ssid_len; 1451 + scancfg.clear_ssid = clear_ssid; 1449 1452 1450 - memcpy(scancfg.specificSSID, prequestedssid->ssid, 1451 - prequestedssid->ssidlength); 1452 - scancfg.keeppreviousscan = keeppreviousscan; 1453 - 1454 - wlan_scan_networks(priv, &scancfg); 1453 + wlan_scan_networks(priv, &scancfg, 1); 1455 1454 if (adapter->surpriseremoved) 1456 1455 return -1; 1457 1456 wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending); 1458 1457 1459 - LEAVE(); 1460 - return 0; 1458 + out: 1459 + lbs_deb_leave(LBS_DEB_ASSOC); 1460 + return ret; 1461 1461 } 1462 1462 1463 1463 /** ··· 1468 1470 * 1469 1471 * @return 0-success, otherwise fail 1470 1472 */ 1471 - int libertas_send_specific_BSSID_scan(wlan_private * priv, u8 * bssid, u8 keeppreviousscan) 1473 + int libertas_send_specific_bssid_scan(wlan_private * priv, u8 * bssid, u8 clear_bssid) 1472 1474 { 1473 1475 struct wlan_ioctl_user_scan_cfg scancfg; 1474 1476 1475 - ENTER(); 1477 + lbs_deb_enter(LBS_DEB_ASSOC); 1476 1478 1477 - if (bssid == NULL) { 1478 - return -1; 1479 - } 1479 + if (bssid == NULL) 1480 + goto out; 1480 1481 1481 1482 memset(&scancfg, 0x00, sizeof(scancfg)); 1482 - memcpy(scancfg.specificBSSID, bssid, sizeof(scancfg.specificBSSID)); 1483 - scancfg.keeppreviousscan = keeppreviousscan; 1483 + memcpy(scancfg.bssid, bssid, ETH_ALEN); 1484 + scancfg.clear_bssid = clear_bssid; 1484 1485 1485 - wlan_scan_networks(priv, &scancfg); 1486 + wlan_scan_networks(priv, &scancfg, 1); 1486 1487 if (priv->adapter->surpriseremoved) 1487 1488 return -1; 1488 1489 wait_event_interruptible(priv->adapter->cmd_pending, 1489 1490 !priv->adapter->nr_cmd_pending); 1490 1491 1491 - LEAVE(); 1492 + out: 1493 + lbs_deb_leave(LBS_DEB_ASSOC); 1492 1494 return 0; 1495 + } 1496 + 1497 + static inline char *libertas_translate_scan(wlan_private *priv, 1498 + char *start, char *stop, 1499 + struct bss_descriptor *bss) 1500 + { 1501 + wlan_adapter *adapter = priv->adapter; 1502 + struct chan_freq_power *cfp; 1503 + char *current_val; /* For rates */ 1504 + struct iw_event iwe; /* Temporary buffer */ 1505 + int j; 1506 + #define PERFECT_RSSI ((u8)50) 1507 + #define WORST_RSSI ((u8)0) 1508 + #define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI)) 1509 + u8 rssi; 1510 + 1511 + cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, bss->channel); 1512 + if (!cfp) { 1513 + lbs_deb_scan("Invalid channel number %d\n", bss->channel); 1514 + return NULL; 1515 + } 1516 + 1517 + /* First entry *MUST* be the AP BSSID */ 1518 + iwe.cmd = SIOCGIWAP; 1519 + iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 1520 + memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN); 1521 + start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN); 1522 + 1523 + /* SSID */ 1524 + iwe.cmd = SIOCGIWESSID; 1525 + iwe.u.data.flags = 1; 1526 + iwe.u.data.length = min((u32) bss->ssid_len, (u32) IW_ESSID_MAX_SIZE); 1527 + start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); 1528 + 1529 + /* Mode */ 1530 + iwe.cmd = SIOCGIWMODE; 1531 + iwe.u.mode = bss->mode; 1532 + start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN); 1533 + 1534 + /* Frequency */ 1535 + iwe.cmd = SIOCGIWFREQ; 1536 + iwe.u.freq.m = (long)cfp->freq * 100000; 1537 + iwe.u.freq.e = 1; 1538 + start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN); 1539 + 1540 + /* Add quality statistics */ 1541 + iwe.cmd = IWEVQUAL; 1542 + iwe.u.qual.updated = IW_QUAL_ALL_UPDATED; 1543 + iwe.u.qual.level = SCAN_RSSI(bss->rssi); 1544 + 1545 + rssi = iwe.u.qual.level - MRVDRV_NF_DEFAULT_SCAN_VALUE; 1546 + iwe.u.qual.qual = 1547 + (100 * RSSI_DIFF * RSSI_DIFF - (PERFECT_RSSI - rssi) * 1548 + (15 * (RSSI_DIFF) + 62 * (PERFECT_RSSI - rssi))) / 1549 + (RSSI_DIFF * RSSI_DIFF); 1550 + if (iwe.u.qual.qual > 100) 1551 + iwe.u.qual.qual = 100; 1552 + 1553 + if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { 1554 + iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; 1555 + } else { 1556 + iwe.u.qual.noise = 1557 + CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 1558 + } 1559 + 1560 + /* Locally created ad-hoc BSSs won't have beacons if this is the 1561 + * only station in the adhoc network; so get signal strength 1562 + * from receive statistics. 1563 + */ 1564 + if ((adapter->mode == IW_MODE_ADHOC) 1565 + && adapter->adhoccreate 1566 + && !libertas_ssid_cmp(adapter->curbssparams.ssid, 1567 + adapter->curbssparams.ssid_len, 1568 + bss->ssid, bss->ssid_len)) { 1569 + int snr, nf; 1570 + snr = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; 1571 + nf = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; 1572 + iwe.u.qual.level = CAL_RSSI(snr, nf); 1573 + } 1574 + start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN); 1575 + 1576 + /* Add encryption capability */ 1577 + iwe.cmd = SIOCGIWENCODE; 1578 + if (bss->privacy) { 1579 + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 1580 + } else { 1581 + iwe.u.data.flags = IW_ENCODE_DISABLED; 1582 + } 1583 + iwe.u.data.length = 0; 1584 + start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); 1585 + 1586 + current_val = start + IW_EV_LCP_LEN; 1587 + 1588 + iwe.cmd = SIOCGIWRATE; 1589 + iwe.u.bitrate.fixed = 0; 1590 + iwe.u.bitrate.disabled = 0; 1591 + iwe.u.bitrate.value = 0; 1592 + 1593 + for (j = 0; j < sizeof(bss->libertas_supported_rates); j++) { 1594 + u8 rate = bss->libertas_supported_rates[j]; 1595 + if (rate == 0) 1596 + break; /* no more rates */ 1597 + /* Bit rate given in 500 kb/s units (+ 0x80) */ 1598 + iwe.u.bitrate.value = (rate & 0x7f) * 500000; 1599 + current_val = iwe_stream_add_value(start, current_val, 1600 + stop, &iwe, IW_EV_PARAM_LEN); 1601 + } 1602 + if ((bss->mode == IW_MODE_ADHOC) 1603 + && !libertas_ssid_cmp(adapter->curbssparams.ssid, 1604 + adapter->curbssparams.ssid_len, 1605 + bss->ssid, bss->ssid_len) 1606 + && adapter->adhoccreate) { 1607 + iwe.u.bitrate.value = 22 * 500000; 1608 + current_val = iwe_stream_add_value(start, current_val, 1609 + stop, &iwe, IW_EV_PARAM_LEN); 1610 + } 1611 + /* Check if we added any event */ 1612 + if((current_val - start) > IW_EV_LCP_LEN) 1613 + start = current_val; 1614 + 1615 + memset(&iwe, 0, sizeof(iwe)); 1616 + if (bss->wpa_ie_len) { 1617 + char buf[MAX_WPA_IE_LEN]; 1618 + memcpy(buf, bss->wpa_ie, bss->wpa_ie_len); 1619 + iwe.cmd = IWEVGENIE; 1620 + iwe.u.data.length = bss->wpa_ie_len; 1621 + start = iwe_stream_add_point(start, stop, &iwe, buf); 1622 + } 1623 + 1624 + memset(&iwe, 0, sizeof(iwe)); 1625 + if (bss->rsn_ie_len) { 1626 + char buf[MAX_WPA_IE_LEN]; 1627 + memcpy(buf, bss->rsn_ie, bss->rsn_ie_len); 1628 + iwe.cmd = IWEVGENIE; 1629 + iwe.u.data.length = bss->rsn_ie_len; 1630 + start = iwe_stream_add_point(start, stop, &iwe, buf); 1631 + } 1632 + 1633 + return start; 1493 1634 } 1494 1635 1495 1636 /** ··· 1644 1507 int libertas_get_scan(struct net_device *dev, struct iw_request_info *info, 1645 1508 struct iw_point *dwrq, char *extra) 1646 1509 { 1510 + #define SCAN_ITEM_SIZE 128 1647 1511 wlan_private *priv = dev->priv; 1648 1512 wlan_adapter *adapter = priv->adapter; 1649 - int ret = 0; 1650 - char *current_ev = extra; 1651 - char *end_buf = extra + IW_SCAN_MAX_DATA; 1652 - struct chan_freq_power *cfp; 1653 - struct bss_descriptor *pscantable; 1654 - char *current_val; /* For rates */ 1655 - struct iw_event iwe; /* Temporary buffer */ 1656 - int i; 1657 - int j; 1658 - int rate; 1659 - #define PERFECT_RSSI ((u8)50) 1660 - #define WORST_RSSI ((u8)0) 1661 - #define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI)) 1662 - u8 rssi; 1513 + int err = 0; 1514 + char *ev = extra; 1515 + char *stop = ev + dwrq->length; 1516 + struct bss_descriptor * iter_bss; 1517 + struct bss_descriptor * safe; 1663 1518 1664 - u8 buf[16 + 256 * 2]; 1665 - u8 *ptr; 1519 + lbs_deb_enter(LBS_DEB_ASSOC); 1666 1520 1667 - ENTER(); 1521 + /* If we've got an uncompleted scan, schedule the next part */ 1522 + if (!adapter->nr_cmd_pending && adapter->last_scanned_channel) 1523 + wlan_scan_networks(priv, NULL, 0); 1668 1524 1669 - /* 1670 - * if there's either commands in the queue or one being 1671 - * processed return -EAGAIN for iwlist to retry later. 1672 - */ 1673 - if (adapter->nr_cmd_pending) 1674 - return -EAGAIN; 1525 + /* Update RSSI if current BSS is a locally created ad-hoc BSS */ 1526 + if ((adapter->mode == IW_MODE_ADHOC) && adapter->adhoccreate) { 1527 + libertas_prepare_and_send_command(priv, cmd_802_11_rssi, 0, 1528 + cmd_option_waitforrsp, 0, NULL); 1529 + } 1675 1530 1676 - if (adapter->connect_status == libertas_connected) 1677 - lbs_pr_debug(1, "Current ssid: %32s\n", 1678 - adapter->curbssparams.ssid.ssid); 1531 + mutex_lock(&adapter->lock); 1532 + list_for_each_entry_safe (iter_bss, safe, &adapter->network_list, list) { 1533 + char * next_ev; 1534 + unsigned long stale_time; 1679 1535 1680 - lbs_pr_debug(1, "Scan: Get: numinscantable = %d\n", 1681 - adapter->numinscantable); 1682 - 1683 - /* The old API using SIOCGIWAPLIST had a hard limit of IW_MAX_AP. 1684 - * The new API using SIOCGIWSCAN is only limited by buffer size 1685 - * WE-14 -> WE-16 the buffer is limited to IW_SCAN_MAX_DATA bytes 1686 - * which is 4096. 1687 - */ 1688 - for (i = 0; i < adapter->numinscantable; i++) { 1689 - if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { 1690 - lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " 1691 - "MAX_SCAN_CELL_SIZE=%zd\n", 1692 - i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); 1536 + if (stop - ev < SCAN_ITEM_SIZE) { 1537 + err = -E2BIG; 1693 1538 break; 1694 1539 } 1695 1540 1696 - pscantable = &adapter->scantable[i]; 1697 - 1698 - lbs_pr_debug(1, "i=%d ssid: %32s\n", i, pscantable->ssid.ssid); 1699 - 1700 - cfp = 1701 - libertas_find_cfp_by_band_and_channel(adapter, 0, 1702 - pscantable->channel); 1703 - if (!cfp) { 1704 - lbs_pr_debug(1, "Invalid channel number %d\n", 1705 - pscantable->channel); 1541 + /* Prune old an old scan result */ 1542 + stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; 1543 + if (time_after(jiffies, stale_time)) { 1544 + list_move_tail (&iter_bss->list, 1545 + &adapter->network_free_list); 1546 + clear_bss_descriptor(iter_bss); 1706 1547 continue; 1707 1548 } 1708 1549 1709 - if (!ssid_valid(&adapter->scantable[i].ssid)) { 1550 + /* Translate to WE format this entry */ 1551 + next_ev = libertas_translate_scan(priv, ev, stop, iter_bss); 1552 + if (next_ev == NULL) 1710 1553 continue; 1711 - } 1712 - 1713 - /* First entry *MUST* be the AP MAC address */ 1714 - iwe.cmd = SIOCGIWAP; 1715 - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 1716 - memcpy(iwe.u.ap_addr.sa_data, 1717 - &adapter->scantable[i].macaddress, ETH_ALEN); 1718 - 1719 - iwe.len = IW_EV_ADDR_LEN; 1720 - current_ev = 1721 - iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); 1722 - 1723 - //Add the ESSID 1724 - iwe.u.data.length = adapter->scantable[i].ssid.ssidlength; 1725 - 1726 - if (iwe.u.data.length > 32) { 1727 - iwe.u.data.length = 32; 1728 - } 1729 - 1730 - iwe.cmd = SIOCGIWESSID; 1731 - iwe.u.data.flags = 1; 1732 - iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1733 - current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, 1734 - adapter->scantable[i].ssid. 1735 - ssid); 1736 - 1737 - //Add mode 1738 - iwe.cmd = SIOCGIWMODE; 1739 - iwe.u.mode = adapter->scantable[i].mode; 1740 - iwe.len = IW_EV_UINT_LEN; 1741 - current_ev = 1742 - iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); 1743 - 1744 - //frequency 1745 - iwe.cmd = SIOCGIWFREQ; 1746 - iwe.u.freq.m = (long)cfp->freq * 100000; 1747 - iwe.u.freq.e = 1; 1748 - iwe.len = IW_EV_FREQ_LEN; 1749 - current_ev = 1750 - iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); 1751 - 1752 - /* Add quality statistics */ 1753 - iwe.cmd = IWEVQUAL; 1754 - iwe.u.qual.updated = IW_QUAL_ALL_UPDATED; 1755 - iwe.u.qual.level = SCAN_RSSI(adapter->scantable[i].rssi); 1756 - 1757 - rssi = iwe.u.qual.level - MRVDRV_NF_DEFAULT_SCAN_VALUE; 1758 - iwe.u.qual.qual = 1759 - (100 * RSSI_DIFF * RSSI_DIFF - (PERFECT_RSSI - rssi) * 1760 - (15 * (RSSI_DIFF) + 62 * (PERFECT_RSSI - rssi))) / 1761 - (RSSI_DIFF * RSSI_DIFF); 1762 - if (iwe.u.qual.qual > 100) 1763 - iwe.u.qual.qual = 100; 1764 - else if (iwe.u.qual.qual < 1) 1765 - iwe.u.qual.qual = 0; 1766 - 1767 - if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { 1768 - iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; 1769 - } else { 1770 - iwe.u.qual.noise = 1771 - CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 1772 - } 1773 - if ((adapter->mode == IW_MODE_ADHOC) && 1774 - !libertas_SSID_cmp(&adapter->curbssparams.ssid, 1775 - &adapter->scantable[i].ssid) 1776 - && adapter->adhoccreate) { 1777 - ret = libertas_prepare_and_send_command(priv, 1778 - cmd_802_11_rssi, 1779 - 0, 1780 - cmd_option_waitforrsp, 1781 - 0, NULL); 1782 - 1783 - if (!ret) { 1784 - iwe.u.qual.level = 1785 - CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / 1786 - AVG_SCALE, 1787 - adapter->NF[TYPE_RXPD][TYPE_AVG] / 1788 - AVG_SCALE); 1789 - } 1790 - } 1791 - iwe.len = IW_EV_QUAL_LEN; 1792 - current_ev = 1793 - iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); 1794 - 1795 - /* Add encryption capability */ 1796 - iwe.cmd = SIOCGIWENCODE; 1797 - if (adapter->scantable[i].privacy) { 1798 - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 1799 - } else { 1800 - iwe.u.data.flags = IW_ENCODE_DISABLED; 1801 - } 1802 - iwe.u.data.length = 0; 1803 - iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1804 - current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, 1805 - adapter->scantable->ssid. 1806 - ssid); 1807 - 1808 - current_val = current_ev + IW_EV_LCP_LEN; 1809 - 1810 - iwe.cmd = SIOCGIWRATE; 1811 - 1812 - iwe.u.bitrate.fixed = 0; 1813 - iwe.u.bitrate.disabled = 0; 1814 - iwe.u.bitrate.value = 0; 1815 - 1816 - /* Bit rate given in 500 kb/s units (+ 0x80) */ 1817 - for (j = 0; j < sizeof(adapter->scantable[i].libertas_supported_rates); 1818 - j++) { 1819 - if (adapter->scantable[i].libertas_supported_rates[j] == 0) { 1820 - break; 1821 - } 1822 - rate = 1823 - (adapter->scantable[i].libertas_supported_rates[j] & 0x7F) * 1824 - 500000; 1825 - if (rate > iwe.u.bitrate.value) { 1826 - iwe.u.bitrate.value = rate; 1827 - } 1828 - 1829 - iwe.u.bitrate.value = 1830 - (adapter->scantable[i].libertas_supported_rates[j] 1831 - & 0x7f) * 500000; 1832 - iwe.len = IW_EV_PARAM_LEN; 1833 - current_ev = 1834 - iwe_stream_add_value(current_ev, current_val, 1835 - end_buf, &iwe, iwe.len); 1836 - 1837 - } 1838 - if ((adapter->scantable[i].mode == IW_MODE_ADHOC) 1839 - && !libertas_SSID_cmp(&adapter->curbssparams.ssid, 1840 - &adapter->scantable[i].ssid) 1841 - && adapter->adhoccreate) { 1842 - iwe.u.bitrate.value = 22 * 500000; 1843 - } 1844 - iwe.len = IW_EV_PARAM_LEN; 1845 - current_ev = 1846 - iwe_stream_add_value(current_ev, current_val, end_buf, &iwe, 1847 - iwe.len); 1848 - 1849 - /* Add new value to event */ 1850 - current_val = current_ev + IW_EV_LCP_LEN; 1851 - 1852 - if (adapter->scantable[i].rsn_ie[0] == WPA2_IE) { 1853 - memset(&iwe, 0, sizeof(iwe)); 1854 - memset(buf, 0, sizeof(buf)); 1855 - memcpy(buf, adapter->scantable[i].rsn_ie, 1856 - adapter->scantable[i].rsn_ie_len); 1857 - iwe.cmd = IWEVGENIE; 1858 - iwe.u.data.length = adapter->scantable[i].rsn_ie_len; 1859 - iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1860 - current_ev = iwe_stream_add_point(current_ev, end_buf, 1861 - &iwe, buf); 1862 - } 1863 - if (adapter->scantable[i].wpa_ie[0] == WPA_IE) { 1864 - memset(&iwe, 0, sizeof(iwe)); 1865 - memset(buf, 0, sizeof(buf)); 1866 - memcpy(buf, adapter->scantable[i].wpa_ie, 1867 - adapter->scantable[i].wpa_ie_len); 1868 - iwe.cmd = IWEVGENIE; 1869 - iwe.u.data.length = adapter->scantable[i].wpa_ie_len; 1870 - iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1871 - current_ev = iwe_stream_add_point(current_ev, end_buf, 1872 - &iwe, buf); 1873 - } 1874 - 1875 - 1876 - if (adapter->scantable[i].extra_ie != 0) { 1877 - memset(&iwe, 0, sizeof(iwe)); 1878 - memset(buf, 0, sizeof(buf)); 1879 - ptr = buf; 1880 - ptr += sprintf(ptr, "extra_ie"); 1881 - iwe.u.data.length = strlen(buf); 1882 - 1883 - lbs_pr_debug(1, "iwe.u.data.length %d\n", 1884 - iwe.u.data.length); 1885 - lbs_pr_debug(1, "BUF: %s \n", buf); 1886 - 1887 - iwe.cmd = IWEVCUSTOM; 1888 - iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1889 - current_ev = 1890 - iwe_stream_add_point(current_ev, end_buf, &iwe, 1891 - buf); 1892 - } 1893 - 1894 - current_val = current_ev + IW_EV_LCP_LEN; 1895 - 1896 - /* 1897 - * Check if we added any event 1898 - */ 1899 - if ((current_val - current_ev) > IW_EV_LCP_LEN) 1900 - current_ev = current_val; 1554 + ev = next_ev; 1901 1555 } 1556 + mutex_unlock(&adapter->lock); 1902 1557 1903 - dwrq->length = (current_ev - extra); 1558 + dwrq->length = (ev - extra); 1904 1559 dwrq->flags = 0; 1905 1560 1906 - LEAVE(); 1907 - return 0; 1561 + lbs_deb_leave(LBS_DEB_ASSOC); 1562 + return err; 1908 1563 } 1909 1564 1910 1565 /** ··· 1725 1796 struct cmd_ds_802_11_scan *pscan = &cmd->params.scan; 1726 1797 struct wlan_scan_cmd_config *pscancfg; 1727 1798 1728 - ENTER(); 1799 + lbs_deb_enter(LBS_DEB_ASSOC); 1729 1800 1730 1801 pscancfg = pdata_buf; 1731 1802 1732 1803 /* Set fixed field variables in scan command */ 1733 1804 pscan->bsstype = pscancfg->bsstype; 1734 - memcpy(pscan->BSSID, pscancfg->specificBSSID, sizeof(pscan->BSSID)); 1805 + memcpy(pscan->BSSID, pscancfg->bssid, sizeof(pscan->BSSID)); 1735 1806 memcpy(pscan->tlvbuffer, pscancfg->tlvbuffer, pscancfg->tlvbufferlen); 1736 1807 1737 1808 cmd->command = cpu_to_le16(cmd_802_11_scan); ··· 1741 1812 + sizeof(pscan->BSSID) 1742 1813 + pscancfg->tlvbufferlen + S_DS_GEN); 1743 1814 1744 - lbs_pr_debug(1, "SCAN_CMD: command=%x, size=%x, seqnum=%x\n", 1745 - cmd->command, cmd->size, cmd->seqnum); 1746 - LEAVE(); 1815 + lbs_deb_scan("SCAN_CMD: command=%x, size=%x, seqnum=%x\n", 1816 + le16_to_cpu(cmd->command), le16_to_cpu(cmd->size), 1817 + le16_to_cpu(cmd->seqnum)); 1818 + 1819 + lbs_deb_leave(LBS_DEB_ASSOC); 1747 1820 return 0; 1821 + } 1822 + 1823 + static inline int is_same_network(struct bss_descriptor *src, 1824 + struct bss_descriptor *dst) 1825 + { 1826 + /* A network is only a duplicate if the channel, BSSID, and ESSID 1827 + * all match. We treat all <hidden> with the same BSSID and channel 1828 + * as one network */ 1829 + return ((src->ssid_len == dst->ssid_len) && 1830 + (src->channel == dst->channel) && 1831 + !compare_ether_addr(src->bssid, dst->bssid) && 1832 + !memcmp(src->ssid, dst->ssid, src->ssid_len)); 1748 1833 } 1749 1834 1750 1835 /** ··· 1789 1846 { 1790 1847 wlan_adapter *adapter = priv->adapter; 1791 1848 struct cmd_ds_802_11_scan_rsp *pscan; 1792 - struct bss_descriptor newbssentry; 1793 1849 struct mrvlietypes_data *ptlv; 1794 1850 struct mrvlietypes_tsftimestamp *ptsftlv; 1851 + struct bss_descriptor * iter_bss; 1852 + struct bss_descriptor * safe; 1795 1853 u8 *pbssinfo; 1796 1854 u16 scanrespsize; 1797 1855 int bytesleft; 1798 - int numintable; 1799 - int bssIdx; 1800 1856 int idx; 1801 1857 int tlvbufsize; 1802 - u64 tsfval; 1858 + int ret; 1803 1859 1804 - ENTER(); 1860 + lbs_deb_enter(LBS_DEB_ASSOC); 1861 + 1862 + /* Prune old entries from scan table */ 1863 + list_for_each_entry_safe (iter_bss, safe, &adapter->network_list, list) { 1864 + unsigned long stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; 1865 + if (time_before(jiffies, stale_time)) 1866 + continue; 1867 + list_move_tail (&iter_bss->list, &adapter->network_free_list); 1868 + clear_bss_descriptor(iter_bss); 1869 + } 1805 1870 1806 1871 pscan = &resp->params.scanresp; 1807 1872 1808 - if (pscan->nr_sets > MRVDRV_MAX_BSSID_LIST) { 1809 - lbs_pr_debug(1, 1810 - "SCAN_RESP: Invalid number of AP returned (%d)!!\n", 1811 - pscan->nr_sets); 1812 - LEAVE(); 1813 - return -1; 1873 + if (pscan->nr_sets > MAX_NETWORK_COUNT) { 1874 + lbs_deb_scan( 1875 + "SCAN_RESP: too many scan results (%d, max %d)!!\n", 1876 + pscan->nr_sets, MAX_NETWORK_COUNT); 1877 + ret = -1; 1878 + goto done; 1814 1879 } 1815 1880 1816 1881 bytesleft = le16_to_cpu(pscan->bssdescriptsize); 1817 - lbs_pr_debug(1, "SCAN_RESP: bssdescriptsize %d\n", bytesleft); 1882 + lbs_deb_scan("SCAN_RESP: bssdescriptsize %d\n", bytesleft); 1818 1883 1819 1884 scanrespsize = le16_to_cpu(resp->size); 1820 - lbs_pr_debug(1, "SCAN_RESP: returned %d AP before parsing\n", 1885 + lbs_deb_scan("SCAN_RESP: returned %d AP before parsing\n", 1821 1886 pscan->nr_sets); 1822 1887 1823 - numintable = adapter->numinscantable; 1824 1888 pbssinfo = pscan->bssdesc_and_tlvbuffer; 1825 1889 1826 1890 /* The size of the TLV buffer is equal to the entire command response ··· 1851 1901 * or as an addition at the end of the table 1852 1902 */ 1853 1903 for (idx = 0; idx < pscan->nr_sets && bytesleft; idx++) { 1854 - /* Zero out the newbssentry we are about to store info in */ 1855 - memset(&newbssentry, 0x00, sizeof(newbssentry)); 1904 + struct bss_descriptor new; 1905 + struct bss_descriptor * found = NULL; 1906 + struct bss_descriptor * oldest = NULL; 1856 1907 1857 1908 /* Process the data fields and IEs returned for this BSS */ 1858 - if ((InterpretBSSDescriptionWithIE(&newbssentry, 1859 - &pbssinfo, 1860 - &bytesleft) == 1861 - 0) 1862 - && CHECK_SSID_IS_VALID(&newbssentry.ssid)) { 1863 - 1864 - lbs_pr_debug(1, 1865 - "SCAN_RESP: BSSID = %02x:%02x:%02x:%02x:%02x:%02x\n", 1866 - newbssentry.macaddress[0], 1867 - newbssentry.macaddress[1], 1868 - newbssentry.macaddress[2], 1869 - newbssentry.macaddress[3], 1870 - newbssentry.macaddress[4], 1871 - newbssentry.macaddress[5]); 1872 - 1873 - /* 1874 - * Search the scan table for the same bssid 1875 - */ 1876 - for (bssIdx = 0; bssIdx < numintable; bssIdx++) { 1877 - if (memcmp(newbssentry.macaddress, 1878 - adapter->scantable[bssIdx]. 1879 - macaddress, 1880 - sizeof(newbssentry.macaddress)) == 1881 - 0) { 1882 - /* 1883 - * If the SSID matches as well, it is a duplicate of 1884 - * this entry. Keep the bssIdx set to this 1885 - * entry so we replace the old contents in the table 1886 - */ 1887 - if ((newbssentry.ssid.ssidlength == 1888 - adapter->scantable[bssIdx].ssid. 1889 - ssidlength) 1890 - && 1891 - (memcmp 1892 - (newbssentry.ssid.ssid, 1893 - adapter->scantable[bssIdx].ssid. 1894 - ssid, 1895 - newbssentry.ssid.ssidlength) == 1896 - 0)) { 1897 - lbs_pr_debug(1, 1898 - "SCAN_RESP: Duplicate of index: %d\n", 1899 - bssIdx); 1900 - break; 1901 - } 1902 - } 1903 - } 1904 - /* 1905 - * If the bssIdx is equal to the number of entries in the table, 1906 - * the new entry was not a duplicate; append it to the scan 1907 - * table 1908 - */ 1909 - if (bssIdx == numintable) { 1910 - /* Range check the bssIdx, keep it limited to the last entry */ 1911 - if (bssIdx == MRVDRV_MAX_BSSID_LIST) { 1912 - bssIdx--; 1913 - } else { 1914 - numintable++; 1915 - } 1916 - } 1917 - 1918 - /* 1919 - * If the TSF TLV was appended to the scan results, save the 1920 - * this entries TSF value in the networktsf field. The 1921 - * networktsf is the firmware's TSF value at the time the 1922 - * beacon or probe response was received. 1923 - */ 1924 - if (ptsftlv) { 1925 - memcpy(&tsfval, &ptsftlv->tsftable[idx], 1926 - sizeof(tsfval)); 1927 - tsfval = le64_to_cpu(tsfval); 1928 - 1929 - memcpy(&newbssentry.networktsf, 1930 - &tsfval, sizeof(newbssentry.networktsf)); 1931 - } 1932 - 1933 - /* Copy the locally created newbssentry to the scan table */ 1934 - memcpy(&adapter->scantable[bssIdx], 1935 - &newbssentry, 1936 - sizeof(adapter->scantable[bssIdx])); 1937 - 1938 - } else { 1939 - 1940 - /* error parsing/interpreting the scan response, skipped */ 1941 - lbs_pr_debug(1, "SCAN_RESP: " 1942 - "InterpretBSSDescriptionWithIE returned ERROR\n"); 1909 + memset(&new, 0, sizeof (struct bss_descriptor)); 1910 + if (libertas_process_bss(&new, &pbssinfo, &bytesleft) != 0) { 1911 + /* error parsing the scan response, skipped */ 1912 + lbs_deb_scan("SCAN_RESP: process_bss returned ERROR\n"); 1913 + continue; 1943 1914 } 1915 + 1916 + /* Try to find this bss in the scan table */ 1917 + list_for_each_entry (iter_bss, &adapter->network_list, list) { 1918 + if (is_same_network(iter_bss, &new)) { 1919 + found = iter_bss; 1920 + break; 1921 + } 1922 + 1923 + if ((oldest == NULL) || 1924 + (iter_bss->last_scanned < oldest->last_scanned)) 1925 + oldest = iter_bss; 1926 + } 1927 + 1928 + if (found) { 1929 + /* found, clear it */ 1930 + clear_bss_descriptor(found); 1931 + } else if (!list_empty(&adapter->network_free_list)) { 1932 + /* Pull one from the free list */ 1933 + found = list_entry(adapter->network_free_list.next, 1934 + struct bss_descriptor, list); 1935 + list_move_tail(&found->list, &adapter->network_list); 1936 + } else if (oldest) { 1937 + /* If there are no more slots, expire the oldest */ 1938 + found = oldest; 1939 + clear_bss_descriptor(found); 1940 + list_move_tail(&found->list, &adapter->network_list); 1941 + } else { 1942 + continue; 1943 + } 1944 + 1945 + lbs_deb_scan("SCAN_RESP: BSSID = " MAC_FMT "\n", 1946 + new.bssid[0], new.bssid[1], new.bssid[2], 1947 + new.bssid[3], new.bssid[4], new.bssid[5]); 1948 + 1949 + /* 1950 + * If the TSF TLV was appended to the scan results, save the 1951 + * this entries TSF value in the networktsf field. The 1952 + * networktsf is the firmware's TSF value at the time the 1953 + * beacon or probe response was received. 1954 + */ 1955 + if (ptsftlv) { 1956 + new.networktsf = le64_to_cpup(&ptsftlv->tsftable[idx]); 1957 + } 1958 + 1959 + /* Copy the locally created newbssentry to the scan table */ 1960 + memcpy(found, &new, offsetof(struct bss_descriptor, list)); 1944 1961 } 1945 1962 1946 - lbs_pr_debug(1, "SCAN_RESP: Scanned %2d APs, %d valid, %d total\n", 1947 - pscan->nr_sets, numintable - adapter->numinscantable, 1948 - numintable); 1963 + ret = 0; 1949 1964 1950 - /* Update the total number of BSSIDs in the scan table */ 1951 - adapter->numinscantable = numintable; 1952 - 1953 - LEAVE(); 1954 - return 0; 1965 + done: 1966 + lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 1967 + return ret; 1955 1968 }
+43 -38
drivers/net/wireless/libertas/scan.h
··· 51 51 /** 52 52 * @brief Specific BSSID used to filter scan results in the firmware 53 53 */ 54 - u8 specificBSSID[ETH_ALEN]; 54 + u8 bssid[ETH_ALEN]; 55 55 56 56 /** 57 57 * @brief length of TLVs sent in command starting at tlvBuffer ··· 91 91 * @sa libertas_set_user_scan_ioctl 92 92 */ 93 93 struct wlan_ioctl_user_scan_cfg { 94 - 95 - /** 96 - * @brief Flag set to keep the previous scan table intact 97 - * 98 - * If set, the scan results will accumulate, replacing any previous 99 - * matched entries for a BSS with the new scan data 100 - */ 101 - u8 keeppreviousscan; //!< Do not erase the existing scan results 102 - 103 94 /** 104 95 * @brief BSS type to be sent in the firmware command 105 96 * ··· 108 117 */ 109 118 u8 numprobes; 110 119 111 - /** 112 - * @brief BSSID filter sent in the firmware command to limit the results 113 - */ 114 - u8 specificBSSID[ETH_ALEN]; 120 + /** 121 + * @brief BSSID filter sent in the firmware command to limit the results 122 + */ 123 + u8 bssid[ETH_ALEN]; 115 124 116 - /** 117 - * @brief SSID filter sent in the firmware command to limit the results 118 - */ 119 - char specificSSID[IW_ESSID_MAX_SIZE + 1]; 125 + /* Clear existing scan results matching this BSSID */ 126 + u8 clear_bssid; 127 + 128 + /** 129 + * @brief SSID filter sent in the firmware command to limit the results 130 + */ 131 + char ssid[IW_ESSID_MAX_SIZE]; 132 + u8 ssid_len; 133 + 134 + /* Clear existing scan results matching this SSID */ 135 + u8 clear_ssid; 120 136 121 137 /** 122 138 * @brief Variable number (fixed maximum) of channels to scan up ··· 135 137 * @brief Structure used to store information for each beacon/probe response 136 138 */ 137 139 struct bss_descriptor { 138 - u8 macaddress[ETH_ALEN]; 140 + u8 bssid[ETH_ALEN]; 139 141 140 - struct WLAN_802_11_SSID ssid; 142 + u8 ssid[IW_ESSID_MAX_SIZE + 1]; 143 + u8 ssid_len; 141 144 142 145 /* WEP encryption requirement */ 143 146 u32 privacy; ··· 155 156 u8 mode; 156 157 u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; 157 158 158 - int extra_ie; 159 + __le64 timestamp; //!< TSF value included in the beacon/probe response 160 + unsigned long last_scanned; 159 161 160 - u8 timestamp[8]; //!< TSF value included in the beacon/probe response 161 162 union ieeetypes_phyparamset phyparamset; 162 163 union IEEEtypes_ssparamset ssparamset; 163 164 struct ieeetypes_capinfo cap; 164 165 u8 datarates[WLAN_SUPPORTED_RATES]; 165 166 166 - __le64 networktsf; //!< TSF timestamp from the current firmware TSF 167 + u64 networktsf; //!< TSF timestamp from the current firmware TSF 167 168 168 169 struct ieeetypes_countryinfofullset countryinfo; 169 170 ··· 171 172 size_t wpa_ie_len; 172 173 u8 rsn_ie[MAX_WPA_IE_LEN]; 173 174 size_t rsn_ie_len; 175 + 176 + struct list_head list; 174 177 }; 175 178 176 - extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, 177 - struct WLAN_802_11_SSID *ssid2); 178 - extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, 179 - u8 * bssid, u8 mode); 180 - int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode); 181 - extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode); 179 + extern int libertas_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len); 182 180 183 - int libertas_find_best_network_SSID(wlan_private * priv, 184 - struct WLAN_802_11_SSID *pSSID, 185 - u8 preferred_mode, u8 *out_mode); 181 + struct bss_descriptor * libertas_find_ssid_in_list(wlan_adapter * adapter, 182 + u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, 183 + int channel); 186 184 187 - extern int libertas_send_specific_SSID_scan(wlan_private * priv, 188 - struct WLAN_802_11_SSID *prequestedssid, 189 - u8 keeppreviousscan); 190 - extern int libertas_send_specific_BSSID_scan(wlan_private * priv, 191 - u8 * bssid, u8 keeppreviousscan); 185 + struct bss_descriptor * libertas_find_best_ssid_in_list(wlan_adapter * adapter, 186 + u8 mode); 187 + 188 + extern struct bss_descriptor * libertas_find_bssid_in_list(wlan_adapter * adapter, 189 + u8 * bssid, u8 mode); 190 + 191 + int libertas_find_best_network_ssid(wlan_private * priv, u8 *out_ssid, 192 + u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode); 193 + 194 + extern int libertas_send_specific_ssid_scan(wlan_private * priv, u8 *ssid, 195 + u8 ssid_len, u8 clear_ssid); 196 + extern int libertas_send_specific_bssid_scan(wlan_private * priv, 197 + u8 * bssid, u8 clear_bssid); 192 198 193 199 extern int libertas_cmd_80211_scan(wlan_private * priv, 194 200 struct cmd_ds_command *cmd, ··· 203 199 struct cmd_ds_command *resp); 204 200 205 201 int wlan_scan_networks(wlan_private * priv, 206 - const struct wlan_ioctl_user_scan_cfg * puserscanin); 202 + const struct wlan_ioctl_user_scan_cfg * puserscanin, 203 + int full_scan); 207 204 208 205 struct ifreq; 209 206
+4 -4
drivers/net/wireless/libertas/thread.h
··· 21 21 22 22 static inline void wlan_deactivate_thread(struct wlan_thread * thr) 23 23 { 24 - ENTER(); 24 + lbs_deb_enter(LBS_DEB_THREAD); 25 25 26 26 thr->pid = 0; 27 27 28 - LEAVE(); 28 + lbs_deb_leave(LBS_DEB_THREAD); 29 29 } 30 30 31 31 static inline void wlan_create_thread(int (*wlanfunc) (void *), ··· 36 36 37 37 static inline int wlan_terminate_thread(struct wlan_thread * thr) 38 38 { 39 - ENTER(); 39 + lbs_deb_enter(LBS_DEB_THREAD); 40 40 41 41 /* Check if the thread is active or not */ 42 42 if (!thr->pid) { ··· 45 45 } 46 46 kthread_stop(thr->task); 47 47 48 - LEAVE(); 48 + lbs_deb_leave(LBS_DEB_THREAD); 49 49 return 0; 50 50 } 51 51
+40 -34
drivers/net/wireless/libertas/tx.c
··· 5 5 6 6 #include "hostcmd.h" 7 7 #include "radiotap.h" 8 - #include "sbi.h" 9 8 #include "decl.h" 10 9 #include "defs.h" 11 10 #include "dev.h" ··· 67 68 u32 new_rate; 68 69 u8 *ptr = priv->adapter->tmptxbuf; 69 70 70 - ENTER(); 71 + lbs_deb_enter(LBS_DEB_TX); 71 72 72 73 if (priv->adapter->surpriseremoved) 73 74 return -1; ··· 77 78 min_t(unsigned int, skb->len, 100)); 78 79 79 80 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { 80 - lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n", 81 + lbs_deb_tx("tx err: skb length %d 0 or > %zd\n", 81 82 skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); 82 83 ret = -1; 83 84 goto done; ··· 85 86 86 87 memset(plocaltxpd, 0, sizeof(struct txpd)); 87 88 88 - plocaltxpd->tx_packet_length = skb->len; 89 + plocaltxpd->tx_packet_length = cpu_to_le16(skb->len); 89 90 90 91 /* offset of actual data */ 91 - plocaltxpd->tx_packet_location = sizeof(struct txpd); 92 + plocaltxpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd)); 92 93 93 94 /* TxCtrl set by user or default */ 94 - plocaltxpd->tx_control = adapter->pkttxctrl; 95 + plocaltxpd->tx_control = cpu_to_le32(adapter->pkttxctrl); 95 96 96 97 p802x_hdr = skb->data; 97 98 if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP) { ··· 102 103 /* set txpd fields from the radiotap header */ 103 104 new_rate = convert_radiotap_rate_to_mv(pradiotap_hdr->rate); 104 105 if (new_rate != 0) { 105 - /* erase tx_control[4:0] */ 106 - plocaltxpd->tx_control &= ~0x1f; 107 - /* write new tx_control[4:0] */ 108 - plocaltxpd->tx_control |= new_rate; 106 + /* use new tx_control[4:0] */ 107 + new_rate |= (adapter->pkttxctrl & ~0x1f); 108 + plocaltxpd->tx_control = cpu_to_le32(new_rate); 109 109 } 110 110 111 111 /* skip the radiotap header */ 112 112 p802x_hdr += sizeof(struct tx_radiotap_hdr); 113 - plocaltxpd->tx_packet_length -= sizeof(struct tx_radiotap_hdr); 113 + plocaltxpd->tx_packet_length = 114 + cpu_to_le16(le16_to_cpu(plocaltxpd->tx_packet_length) 115 + - sizeof(struct tx_radiotap_hdr)); 114 116 115 117 } 116 118 /* copy destination address from 802.3 or 802.11 header */ ··· 123 123 lbs_dbg_hex("txpd", (u8 *) plocaltxpd, sizeof(struct txpd)); 124 124 125 125 if (IS_MESH_FRAME(skb)) { 126 - plocaltxpd->tx_control |= TxPD_MESH_FRAME; 126 + plocaltxpd->tx_control |= cpu_to_le32(TxPD_MESH_FRAME); 127 127 } 128 128 129 129 memcpy(ptr, plocaltxpd, sizeof(struct txpd)); 130 130 131 131 ptr += sizeof(struct txpd); 132 132 133 - lbs_dbg_hex("Tx Data", (u8 *) p802x_hdr, plocaltxpd->tx_packet_length); 134 - memcpy(ptr, p802x_hdr, plocaltxpd->tx_packet_length); 135 - ret = libertas_sbi_host_to_card(priv, MVMS_DAT, 136 - priv->adapter->tmptxbuf, 137 - plocaltxpd->tx_packet_length + 138 - sizeof(struct txpd)); 133 + lbs_dbg_hex("Tx Data", (u8 *) p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length)); 134 + memcpy(ptr, p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length)); 135 + ret = priv->hw_host_to_card(priv, MVMS_DAT, 136 + priv->adapter->tmptxbuf, 137 + le16_to_cpu(plocaltxpd->tx_packet_length) + 138 + sizeof(struct txpd)); 139 139 140 140 if (ret) { 141 - lbs_pr_debug(1, "Tx error: libertas_sbi_host_to_card failed: 0x%X\n", ret); 141 + lbs_deb_tx("tx err: hw_host_to_card returned 0x%X\n", ret); 142 142 goto done; 143 143 } 144 144 145 - lbs_pr_debug(1, "SendSinglePacket succeeds\n"); 145 + lbs_deb_tx("SendSinglePacket succeeds\n"); 146 146 147 - done: 147 + done: 148 148 if (!ret) { 149 149 priv->stats.tx_packets++; 150 150 priv->stats.tx_bytes += skb->len; ··· 158 158 received from FW */ 159 159 skb_orphan(skb); 160 160 /* stop processing outgoing pkts */ 161 - netif_stop_queue(priv->wlan_dev.netdev); 161 + netif_stop_queue(priv->dev); 162 + netif_stop_queue(priv->mesh_dev); 162 163 /* freeze any packets already in our queues */ 163 164 priv->adapter->TxLockFlag = 1; 164 165 } else { ··· 167 166 priv->adapter->currenttxskb = NULL; 168 167 } 169 168 170 - LEAVE(); 169 + lbs_deb_leave_args(LBS_DEB_TX, "ret %d", ret); 171 170 return ret; 172 171 } 173 172 ··· 196 195 197 196 WARN_ON(priv->adapter->tx_queue_idx >= NR_TX_QUEUE); 198 197 adapter->tx_queue_ps[adapter->tx_queue_idx++] = skb; 199 - if (adapter->tx_queue_idx == NR_TX_QUEUE) 200 - netif_stop_queue(priv->wlan_dev.netdev); 201 - else 202 - netif_start_queue(priv->wlan_dev.netdev); 198 + if (adapter->tx_queue_idx == NR_TX_QUEUE) { 199 + netif_stop_queue(priv->dev); 200 + netif_stop_queue(priv->mesh_dev); 201 + } else { 202 + netif_start_queue(priv->dev); 203 + netif_start_queue(priv->mesh_dev); 204 + } 203 205 204 206 spin_unlock(&adapter->txqueue_lock); 205 207 } ··· 218 214 { 219 215 int ret = -1; 220 216 221 - ENTER(); 222 - 217 + lbs_deb_enter(LBS_DEB_TX); 223 218 lbs_dbg_hex("TX Data", skb->data, min_t(unsigned int, skb->len, 100)); 224 219 225 - if (priv->wlan_dev.dnld_sent) { 220 + if (priv->dnld_sent) { 226 221 lbs_pr_alert( "TX error: dnld_sent = %d, not sending\n", 227 - priv->wlan_dev.dnld_sent); 222 + priv->dnld_sent); 228 223 goto done; 229 224 } 230 225 ··· 237 234 238 235 ret = SendSinglePacket(priv, skb); 239 236 done: 240 - LEAVE(); 237 + lbs_deb_leave_args(LBS_DEB_TX, "ret %d", ret); 241 238 return ret; 242 239 } 243 240 ··· 283 280 libertas_upload_rx_packet(priv, adapter->currenttxskb); 284 281 adapter->currenttxskb = NULL; 285 282 priv->adapter->TxLockFlag = 0; 286 - if (priv->adapter->connect_status == libertas_connected) 287 - netif_wake_queue(priv->wlan_dev.netdev); 283 + if (priv->adapter->connect_status == libertas_connected) { 284 + netif_wake_queue(priv->dev); 285 + netif_wake_queue(priv->mesh_dev); 286 + } 288 287 } 288 + EXPORT_SYMBOL_GPL(libertas_send_tx_feedback);
+46 -17
drivers/net/wireless/libertas/types.h
··· 5 5 #define _WLAN_TYPES_ 6 6 7 7 #include <linux/if_ether.h> 8 + #include <asm/byteorder.h> 8 9 9 10 /** IEEE type definitions */ 10 11 enum ieeetypes_elementid { ··· 30 29 EXTRA_IE = 133, 31 30 } __attribute__ ((packed)); 32 31 32 + #ifdef __BIG_ENDIAN 33 33 #define CAPINFO_MASK (~(0xda00)) 34 + #else 35 + #define CAPINFO_MASK (~(0x00da)) 36 + #endif 34 37 35 38 struct ieeetypes_capinfo { 39 + #ifdef __BIG_ENDIAN_BITFIELD 40 + u8 chanagility:1; 41 + u8 pbcc:1; 42 + u8 shortpreamble:1; 43 + u8 privacy:1; 44 + u8 cfpollrqst:1; 45 + u8 cfpollable:1; 46 + u8 ibss:1; 47 + u8 ess:1; 48 + u8 rsrvd1:2; 49 + u8 dsssofdm:1; 50 + u8 rsvrd2:1; 51 + u8 apsd:1; 52 + u8 shortslottime:1; 53 + u8 rsrvd3:1; 54 + u8 spectrummgmt:1; 55 + #else 36 56 u8 ess:1; 37 57 u8 ibss:1; 38 58 u8 cfpollable:1; ··· 69 47 u8 rsvrd2:1; 70 48 u8 dsssofdm:1; 71 49 u8 rsrvd1:2; 50 + #endif 72 51 } __attribute__ ((packed)); 73 52 74 53 struct ieeetypes_cfparamset { ··· 77 54 u8 len; 78 55 u8 cfpcnt; 79 56 u8 cfpperiod; 80 - u16 cfpmaxduration; 81 - u16 cfpdurationremaining; 57 + __le16 cfpmaxduration; 58 + __le16 cfpdurationremaining; 82 59 } __attribute__ ((packed)); 83 60 84 61 85 62 struct ieeetypes_ibssparamset { 86 63 u8 elementid; 87 64 u8 len; 88 - u16 atimwindow; 65 + __le16 atimwindow; 89 66 } __attribute__ ((packed)); 90 67 91 68 union IEEEtypes_ssparamset { ··· 96 73 struct ieeetypes_fhparamset { 97 74 u8 elementid; 98 75 u8 len; 99 - u16 dwelltime; 76 + __le16 dwelltime; 100 77 u8 hopset; 101 78 u8 hoppattern; 102 79 u8 hopindex; ··· 115 92 116 93 struct ieeetypes_assocrsp { 117 94 struct ieeetypes_capinfo capability; 118 - u16 statuscode; 119 - u16 aid; 95 + __le16 statuscode; 96 + __le16 aid; 120 97 u8 iebuffer[1]; 121 98 } __attribute__ ((packed)); 122 99 ··· 161 138 162 139 /** TLV related data structures*/ 163 140 struct mrvlietypesheader { 164 - u16 type; 165 - u16 len; 141 + __le16 type; 142 + __le16 len; 166 143 } __attribute__ ((packed)); 167 144 168 145 struct mrvlietypes_data { ··· 187 164 } __attribute__ ((packed)); 188 165 189 166 struct chanscanmode { 167 + #ifdef __BIG_ENDIAN_BITFIELD 168 + u8 reserved_2_7:6; 169 + u8 disablechanfilt:1; 170 + u8 passivescan:1; 171 + #else 190 172 u8 passivescan:1; 191 173 u8 disablechanfilt:1; 192 174 u8 reserved_2_7:6; 175 + #endif 193 176 } __attribute__ ((packed)); 194 177 195 178 struct chanscanparamset { 196 179 u8 radiotype; 197 180 u8 channumber; 198 181 struct chanscanmode chanscanmode; 199 - u16 minscantime; 200 - u16 maxscantime; 182 + __le16 minscantime; 183 + __le16 maxscantime; 201 184 } __attribute__ ((packed)); 202 185 203 186 struct mrvlietypes_chanlistparamset { ··· 214 185 struct cfparamset { 215 186 u8 cfpcnt; 216 187 u8 cfpperiod; 217 - u16 cfpmaxduration; 218 - u16 cfpdurationremaining; 188 + __le16 cfpmaxduration; 189 + __le16 cfpdurationremaining; 219 190 } __attribute__ ((packed)); 220 191 221 192 struct ibssparamset { 222 - u16 atimwindow; 193 + __le16 atimwindow; 223 194 } __attribute__ ((packed)); 224 195 225 196 struct mrvlietypes_ssparamset { ··· 231 202 } __attribute__ ((packed)); 232 203 233 204 struct fhparamset { 234 - u16 dwelltime; 205 + __le16 dwelltime; 235 206 u8 hopset; 236 207 u8 hoppattern; 237 208 u8 hopindex; ··· 292 263 293 264 struct mrvlietypes_numprobes { 294 265 struct mrvlietypesheader header; 295 - u16 numprobes; 266 + __le16 numprobes; 296 267 } __attribute__ ((packed)); 297 268 298 269 struct mrvlietypes_bcastprobe { 299 270 struct mrvlietypesheader header; 300 - u16 bcastprobe; 271 + __le16 bcastprobe; 301 272 } __attribute__ ((packed)); 302 273 303 274 struct mrvlietypes_numssidprobe { 304 275 struct mrvlietypesheader header; 305 - u16 numssidprobe; 276 + __le16 numssidprobe; 306 277 } __attribute__ ((packed)); 307 278 308 279 struct led_pin {
+411 -369
drivers/net/wireless/libertas/wext.c
··· 22 22 23 23 24 24 /** 25 + * the rates supported by the card 26 + */ 27 + static u8 libertas_wlan_data_rates[WLAN_SUPPORTED_RATES] = 28 + { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12, 29 + 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00 30 + }; 31 + 32 + /** 25 33 * @brief Convert mw value to dbm value 26 34 * 27 35 * @param mw the value of mw ··· 110 102 } 111 103 112 104 if (!cfp && channel) 113 - lbs_pr_debug(1, "libertas_find_cfp_by_band_and_channel(): cannot find " 114 - "cfp by band %d & channel %d\n", band, channel); 105 + lbs_deb_wext("libertas_find_cfp_by_band_and_channel: can't find " 106 + "cfp by band %d / channel %d\n", band, channel); 115 107 116 108 return cfp; 117 109 } ··· 151 143 } 152 144 153 145 if (!cfp && freq) 154 - lbs_pr_debug(1, "find_cfp_by_band_and_freql(): cannot find cfp by " 155 - "band %d & freq %d\n", band, freq); 146 + lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by " 147 + "band %d / freq %d\n", band, freq); 156 148 157 149 return cfp; 158 150 } 159 151 160 - static int updatecurrentchannel(wlan_private * priv) 161 - { 162 - int ret; 163 - 164 - /* 165 - ** the channel in f/w could be out of sync, get the current channel 166 - */ 167 - ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel, 168 - cmd_opt_802_11_rf_channel_get, 169 - cmd_option_waitforrsp, 0, NULL); 170 - 171 - lbs_pr_debug(1, "Current channel = %d\n", 172 - priv->adapter->curbssparams.channel); 173 - 174 - return ret; 175 - } 176 - 177 - static int setcurrentchannel(wlan_private * priv, int channel) 178 - { 179 - lbs_pr_debug(1, "Set channel = %d\n", channel); 180 - 181 - /* 182 - ** Current channel is not set to adhocchannel requested, set channel 183 - */ 184 - return (libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel, 185 - cmd_opt_802_11_rf_channel_set, 186 - cmd_option_waitforrsp, 0, &channel)); 187 - } 188 - 189 - static int changeadhocchannel(wlan_private * priv, int channel) 190 - { 191 - int ret = 0; 192 - wlan_adapter *adapter = priv->adapter; 193 - 194 - adapter->adhocchannel = channel; 195 - 196 - updatecurrentchannel(priv); 197 - 198 - if (adapter->curbssparams.channel == adapter->adhocchannel) { 199 - /* adhocchannel is set to the current channel already */ 200 - LEAVE(); 201 - return 0; 202 - } 203 - 204 - lbs_pr_debug(1, "Updating channel from %d to %d\n", 205 - adapter->curbssparams.channel, adapter->adhocchannel); 206 - 207 - setcurrentchannel(priv, adapter->adhocchannel); 208 - 209 - updatecurrentchannel(priv); 210 - 211 - if (adapter->curbssparams.channel != adapter->adhocchannel) { 212 - lbs_pr_debug(1, "failed to updated channel to %d, channel = %d\n", 213 - adapter->adhocchannel, adapter->curbssparams.channel); 214 - LEAVE(); 215 - return -1; 216 - } 217 - 218 - if (adapter->connect_status == libertas_connected) { 219 - int i; 220 - struct WLAN_802_11_SSID curadhocssid; 221 - 222 - lbs_pr_debug(1, "channel Changed while in an IBSS\n"); 223 - 224 - /* Copy the current ssid */ 225 - memcpy(&curadhocssid, &adapter->curbssparams.ssid, 226 - sizeof(struct WLAN_802_11_SSID)); 227 - 228 - /* Exit Adhoc mode */ 229 - lbs_pr_debug(1, "In changeadhocchannel(): Sending Adhoc Stop\n"); 230 - ret = libertas_stop_adhoc_network(priv); 231 - 232 - if (ret) { 233 - LEAVE(); 234 - return ret; 235 - } 236 - /* Scan for the network, do not save previous results. Stale 237 - * scan data will cause us to join a non-existant adhoc network 238 - */ 239 - libertas_send_specific_SSID_scan(priv, &curadhocssid, 0); 240 - 241 - // find out the BSSID that matches the current SSID 242 - i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, 243 - IW_MODE_ADHOC); 244 - 245 - if (i >= 0) { 246 - lbs_pr_debug(1, "SSID found at %d in List," 247 - "so join\n", i); 248 - libertas_join_adhoc_network(priv, &adapter->scantable[i]); 249 - } else { 250 - // else send START command 251 - lbs_pr_debug(1, "SSID not found in list, " 252 - "so creating adhoc with ssid = %s\n", 253 - curadhocssid.ssid); 254 - libertas_start_adhoc_network(priv, &curadhocssid); 255 - } // end of else (START command) 256 - } 257 - 258 - LEAVE(); 259 - return 0; 260 - } 261 152 262 153 /** 263 154 * @brief Set Radio On/OFF ··· 170 263 int ret = 0; 171 264 wlan_adapter *adapter = priv->adapter; 172 265 173 - ENTER(); 266 + lbs_deb_enter(LBS_DEB_WEXT); 174 267 175 268 if (adapter->radioon != option) { 176 - lbs_pr_debug(1, "Switching %s the Radio\n", option ? "On" : "Off"); 269 + lbs_deb_wext("switching radio %s\n", option ? "on" : "off"); 177 270 adapter->radioon = option; 178 271 179 272 ret = libertas_prepare_and_send_command(priv, ··· 182 275 cmd_option_waitforrsp, 0, NULL); 183 276 } 184 277 185 - LEAVE(); 278 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 186 279 return ret; 187 280 } 188 281 ··· 219 312 { 220 313 int k = 0; 221 314 222 - ENTER(); 315 + lbs_deb_enter(LBS_DEB_WEXT); 223 316 224 317 if (adapter->connect_status != libertas_connected) { 225 318 if (adapter->mode == IW_MODE_INFRA) { 226 - lbs_pr_debug(1, "Infra\n"); 319 + lbs_deb_wext("infra\n"); 227 320 k = copyrates(rates, k, libertas_supported_rates, 228 321 sizeof(libertas_supported_rates)); 229 322 } else { 230 - lbs_pr_debug(1, "Adhoc G\n"); 323 + lbs_deb_wext("Adhoc G\n"); 231 324 k = copyrates(rates, k, libertas_adhoc_rates_g, 232 325 sizeof(libertas_adhoc_rates_g)); 233 326 } ··· 236 329 adapter->curbssparams.numofrates); 237 330 } 238 331 239 - LEAVE(); 240 - 332 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", k); 241 333 return k; 242 334 } 243 335 ··· 248 342 char mrvl[6] = { "MRVL-" }; 249 343 int cnt; 250 344 251 - ENTER(); 345 + lbs_deb_enter(LBS_DEB_WEXT); 252 346 253 347 strcpy(cwrq, mrvl); 254 348 ··· 266 360 } 267 361 *cwrq = '\0'; 268 362 269 - LEAVE(); 270 - 363 + lbs_deb_leave(LBS_DEB_WEXT); 271 364 return 0; 272 365 } 273 366 ··· 277 372 wlan_adapter *adapter = priv->adapter; 278 373 struct chan_freq_power *cfp; 279 374 280 - ENTER(); 375 + lbs_deb_enter(LBS_DEB_WEXT); 281 376 282 377 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, 283 378 adapter->curbssparams.channel); 284 379 285 380 if (!cfp) { 286 381 if (adapter->curbssparams.channel) 287 - lbs_pr_debug(1, "Invalid channel=%d\n", 382 + lbs_deb_wext("invalid channel %d\n", 288 383 adapter->curbssparams.channel); 289 384 return -EINVAL; 290 385 } ··· 292 387 fwrq->m = (long)cfp->freq * 100000; 293 388 fwrq->e = 1; 294 389 295 - lbs_pr_debug(1, "freq=%u\n", fwrq->m); 296 - 297 - LEAVE(); 390 + lbs_deb_wext("freq %u\n", fwrq->m); 391 + lbs_deb_leave(LBS_DEB_WEXT); 298 392 return 0; 299 393 } 300 394 ··· 303 399 wlan_private *priv = dev->priv; 304 400 wlan_adapter *adapter = priv->adapter; 305 401 306 - ENTER(); 402 + lbs_deb_enter(LBS_DEB_WEXT); 307 403 308 404 if (adapter->connect_status == libertas_connected) { 309 405 memcpy(awrq->sa_data, adapter->curbssparams.bssid, ETH_ALEN); ··· 312 408 } 313 409 awrq->sa_family = ARPHRD_ETHER; 314 410 315 - LEAVE(); 411 + lbs_deb_leave(LBS_DEB_WEXT); 316 412 return 0; 317 413 } 318 414 ··· 322 418 wlan_private *priv = dev->priv; 323 419 wlan_adapter *adapter = priv->adapter; 324 420 325 - ENTER(); 421 + lbs_deb_enter(LBS_DEB_WEXT); 326 422 327 423 /* 328 424 * Check the size of the string ··· 337 433 memcpy(adapter->nodename, extra, dwrq->length); 338 434 mutex_unlock(&adapter->lock); 339 435 340 - LEAVE(); 436 + lbs_deb_leave(LBS_DEB_WEXT); 341 437 return 0; 342 438 } 343 439 ··· 347 443 wlan_private *priv = dev->priv; 348 444 wlan_adapter *adapter = priv->adapter; 349 445 350 - ENTER(); 446 + lbs_deb_enter(LBS_DEB_WEXT); 351 447 352 448 /* 353 449 * Get the Nick Name saved ··· 368 464 */ 369 465 dwrq->length = strlen(extra) + 1; 370 466 371 - LEAVE(); 467 + lbs_deb_leave(LBS_DEB_WEXT); 372 468 return 0; 373 469 } 374 470 471 + static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info, 472 + struct iw_point *dwrq, char *extra) 473 + { 474 + wlan_private *priv = dev->priv; 475 + wlan_adapter *adapter = priv->adapter; 476 + 477 + lbs_deb_enter(LBS_DEB_WEXT); 478 + 479 + /* Use nickname to indicate that mesh is on */ 480 + 481 + if (adapter->connect_status == libertas_connected) { 482 + strncpy(extra, "Mesh", 12); 483 + extra[12] = '\0'; 484 + dwrq->length = strlen(extra) + 1; 485 + } 486 + 487 + else { 488 + extra[0] = '\0'; 489 + dwrq->length = 1 ; 490 + } 491 + 492 + lbs_deb_leave(LBS_DEB_WEXT); 493 + return 0; 494 + } 375 495 static int wlan_set_rts(struct net_device *dev, struct iw_request_info *info, 376 496 struct iw_param *vwrq, char *extra) 377 497 { 378 498 int ret = 0; 379 499 wlan_private *priv = dev->priv; 380 500 wlan_adapter *adapter = priv->adapter; 381 - int rthr = vwrq->value; 501 + u32 rthr = vwrq->value; 382 502 383 - ENTER(); 503 + lbs_deb_enter(LBS_DEB_WEXT); 384 504 385 505 if (vwrq->disabled) { 386 506 adapter->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE; ··· 418 490 cmd_act_set, cmd_option_waitforrsp, 419 491 OID_802_11_RTS_THRESHOLD, &rthr); 420 492 421 - LEAVE(); 493 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 422 494 return ret; 423 495 } 424 496 ··· 429 501 wlan_private *priv = dev->priv; 430 502 wlan_adapter *adapter = priv->adapter; 431 503 432 - ENTER(); 504 + lbs_deb_enter(LBS_DEB_WEXT); 433 505 434 506 adapter->rtsthsd = 0; 435 507 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib, 436 508 cmd_act_get, cmd_option_waitforrsp, 437 509 OID_802_11_RTS_THRESHOLD, NULL); 438 - if (ret) { 439 - LEAVE(); 440 - return ret; 441 - } 510 + if (ret) 511 + goto out; 442 512 443 513 vwrq->value = adapter->rtsthsd; 444 514 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE) 445 515 || (vwrq->value > MRVDRV_RTS_MAX_VALUE)); 446 516 vwrq->fixed = 1; 447 517 448 - LEAVE(); 449 - return 0; 518 + out: 519 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 520 + return ret; 450 521 } 451 522 452 523 static int wlan_set_frag(struct net_device *dev, struct iw_request_info *info, 453 524 struct iw_param *vwrq, char *extra) 454 525 { 455 526 int ret = 0; 456 - int fthr = vwrq->value; 527 + u32 fthr = vwrq->value; 457 528 wlan_private *priv = dev->priv; 458 529 wlan_adapter *adapter = priv->adapter; 459 530 460 - ENTER(); 531 + lbs_deb_enter(LBS_DEB_WEXT); 461 532 462 533 if (vwrq->disabled) { 463 534 adapter->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE; ··· 470 543 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib, 471 544 cmd_act_set, cmd_option_waitforrsp, 472 545 OID_802_11_FRAGMENTATION_THRESHOLD, &fthr); 473 - LEAVE(); 546 + 547 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 474 548 return ret; 475 549 } 476 550 ··· 482 554 wlan_private *priv = dev->priv; 483 555 wlan_adapter *adapter = priv->adapter; 484 556 485 - ENTER(); 557 + lbs_deb_enter(LBS_DEB_WEXT); 486 558 487 559 adapter->fragthsd = 0; 488 560 ret = libertas_prepare_and_send_command(priv, 489 561 cmd_802_11_snmp_mib, 490 562 cmd_act_get, cmd_option_waitforrsp, 491 563 OID_802_11_FRAGMENTATION_THRESHOLD, NULL); 492 - if (ret) { 493 - LEAVE(); 494 - return ret; 495 - } 564 + if (ret) 565 + goto out; 496 566 497 567 vwrq->value = adapter->fragthsd; 498 568 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE) 499 569 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE)); 500 570 vwrq->fixed = 1; 501 571 502 - LEAVE(); 572 + out: 573 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 503 574 return ret; 504 575 } 505 576 ··· 508 581 wlan_private *priv = dev->priv; 509 582 wlan_adapter *adapter = priv->adapter; 510 583 511 - ENTER(); 584 + lbs_deb_enter(LBS_DEB_WEXT); 512 585 513 586 *uwrq = adapter->mode; 514 587 515 - LEAVE(); 588 + lbs_deb_leave(LBS_DEB_WEXT); 589 + return 0; 590 + } 591 + 592 + static int mesh_wlan_get_mode(struct net_device *dev, 593 + struct iw_request_info *info, u32 * uwrq, 594 + char *extra) 595 + { 596 + lbs_deb_enter(LBS_DEB_WEXT); 597 + 598 + *uwrq = IW_MODE_REPEAT ; 599 + 600 + lbs_deb_leave(LBS_DEB_WEXT); 516 601 return 0; 517 602 } 518 603 ··· 536 597 wlan_private *priv = dev->priv; 537 598 wlan_adapter *adapter = priv->adapter; 538 599 539 - ENTER(); 600 + lbs_deb_enter(LBS_DEB_WEXT); 540 601 541 602 ret = libertas_prepare_and_send_command(priv, 542 603 cmd_802_11_rf_tx_power, 543 604 cmd_act_tx_power_opt_get, 544 605 cmd_option_waitforrsp, 0, NULL); 545 606 546 - if (ret) { 547 - LEAVE(); 548 - return ret; 549 - } 607 + if (ret) 608 + goto out; 550 609 551 - lbs_pr_debug(1, "TXPOWER GET %d dbm.\n", adapter->txpowerlevel); 610 + lbs_deb_wext("tx power level %d dbm\n", adapter->txpowerlevel); 552 611 vwrq->value = adapter->txpowerlevel; 553 612 vwrq->fixed = 1; 554 613 if (adapter->radioon) { ··· 556 619 vwrq->disabled = 1; 557 620 } 558 621 559 - LEAVE(); 560 - return 0; 622 + out: 623 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 624 + return ret; 561 625 } 562 626 563 627 static int wlan_set_retry(struct net_device *dev, struct iw_request_info *info, ··· 568 630 wlan_private *priv = dev->priv; 569 631 wlan_adapter *adapter = priv->adapter; 570 632 571 - ENTER(); 633 + lbs_deb_enter(LBS_DEB_WEXT); 572 634 573 635 if (vwrq->flags == IW_RETRY_LIMIT) { 574 636 /* The MAC has a 4-bit Total_Tx_Count register ··· 586 648 cmd_option_waitforrsp, 587 649 OID_802_11_TX_RETRYCOUNT, NULL); 588 650 589 - if (ret) { 590 - LEAVE(); 591 - return ret; 592 - } 651 + if (ret) 652 + goto out; 593 653 } else { 594 654 return -EOPNOTSUPP; 595 655 } 596 656 597 - LEAVE(); 598 - return 0; 657 + out: 658 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 659 + return ret; 599 660 } 600 661 601 662 static int wlan_get_retry(struct net_device *dev, struct iw_request_info *info, ··· 604 667 wlan_adapter *adapter = priv->adapter; 605 668 int ret = 0; 606 669 607 - ENTER(); 670 + lbs_deb_enter(LBS_DEB_WEXT); 671 + 608 672 adapter->txretrycount = 0; 609 673 ret = libertas_prepare_and_send_command(priv, 610 674 cmd_802_11_snmp_mib, 611 675 cmd_act_get, cmd_option_waitforrsp, 612 676 OID_802_11_TX_RETRYCOUNT, NULL); 613 - if (ret) { 614 - LEAVE(); 615 - return ret; 616 - } 677 + if (ret) 678 + goto out; 679 + 617 680 vwrq->disabled = 0; 618 681 if (!vwrq->flags) { 619 682 vwrq->flags = IW_RETRY_LIMIT; ··· 621 684 vwrq->value = adapter->txretrycount - 1; 622 685 } 623 686 624 - LEAVE(); 625 - return 0; 687 + out: 688 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 689 + return ret; 626 690 } 627 691 628 692 static inline void sort_channels(struct iw_freq *freq, int num) ··· 677 739 678 740 u8 flag = 0; 679 741 680 - ENTER(); 742 + lbs_deb_enter(LBS_DEB_WEXT); 681 743 682 744 dwrq->length = sizeof(struct iw_range); 683 745 memset(range, 0, sizeof(struct iw_range)); ··· 693 755 range->bitrate[i] = (rates[i] & 0x7f) * 500000; 694 756 } 695 757 range->num_bitrates = i; 696 - lbs_pr_debug(1, "IW_MAX_BITRATES=%d num_bitrates=%d\n", IW_MAX_BITRATES, 758 + lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES, 697 759 range->num_bitrates); 698 760 699 761 range->num_frequency = 0; ··· 706 768 &adapter->parsed_region_chan; 707 769 708 770 if (parsed_region_chan == NULL) { 709 - lbs_pr_debug(1, "11D:parsed_region_chan is NULL\n"); 710 - LEAVE(); 711 - return 0; 771 + lbs_deb_wext("11d: parsed_region_chan is NULL\n"); 772 + goto out; 712 773 } 713 774 band = parsed_region_chan->band; 714 - lbs_pr_debug(1, "band=%d NoOfChan=%d\n", band, 775 + lbs_deb_wext("band %d, nr_char %d\n", band, 715 776 parsed_region_chan->nr_chan); 716 777 717 778 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES) 718 779 && (i < parsed_region_chan->nr_chan); i++) { 719 780 chan_no = parsed_region_chan->chanpwr[i].chan; 720 - lbs_pr_debug(1, "chan_no=%d\n", chan_no); 781 + lbs_deb_wext("chan_no %d\n", chan_no); 721 782 range->freq[range->num_frequency].i = (long)chan_no; 722 783 range->freq[range->num_frequency].m = 723 784 (long)libertas_chan_2_freq(chan_no, band) * 100000; ··· 745 808 } 746 809 } 747 810 748 - lbs_pr_debug(1, "IW_MAX_FREQUENCIES=%d num_frequency=%d\n", 811 + lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n", 749 812 IW_MAX_FREQUENCIES, range->num_frequency); 750 813 751 814 range->num_channels = range->num_frequency; ··· 840 903 | IW_ENC_CAPA_CIPHER_CCMP; 841 904 } 842 905 843 - LEAVE(); 906 + out: 907 + lbs_deb_leave(LBS_DEB_WEXT); 844 908 return 0; 845 909 } 846 910 ··· 851 913 wlan_private *priv = dev->priv; 852 914 wlan_adapter *adapter = priv->adapter; 853 915 854 - ENTER(); 916 + lbs_deb_enter(LBS_DEB_WEXT); 855 917 856 918 /* PS is currently supported only in Infrastructure mode 857 919 * Remove this check if it is to be supported in IBSS mode also ··· 867 929 } 868 930 869 931 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { 870 - lbs_pr_debug(1, 871 - "Setting power timeout command is not supported\n"); 932 + lbs_deb_wext( 933 + "setting power timeout is not supported\n"); 872 934 return -EINVAL; 873 935 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { 874 - lbs_pr_debug(1, "Setting power period command is not supported\n"); 936 + lbs_deb_wext("setting power period not supported\n"); 875 937 return -EINVAL; 876 938 } 877 939 ··· 885 947 libertas_ps_sleep(priv, cmd_option_waitforrsp); 886 948 } 887 949 888 - LEAVE(); 950 + lbs_deb_leave(LBS_DEB_WEXT); 889 951 return 0; 890 952 } 891 953 ··· 896 958 wlan_adapter *adapter = priv->adapter; 897 959 int mode; 898 960 899 - ENTER(); 961 + lbs_deb_enter(LBS_DEB_WEXT); 900 962 901 963 mode = adapter->psmode; 902 964 903 965 if ((vwrq->disabled = (mode == wlan802_11powermodecam)) 904 - || adapter->connect_status == libertas_disconnected) { 905 - LEAVE(); 906 - return 0; 966 + || adapter->connect_status == libertas_disconnected) 967 + { 968 + goto out; 907 969 } 908 970 909 971 vwrq->value = 0; 910 972 911 - LEAVE(); 973 + out: 974 + lbs_deb_leave(LBS_DEB_WEXT); 912 975 return 0; 913 976 } 914 977 ··· 1002 1063 IW_PRIV_TYPE_CHAR | 128, 1003 1064 IW_PRIV_TYPE_CHAR | 128, 1004 1065 "bt_list"}, 1066 + { 1067 + WLAN_SUBCMD_BT_SET_INVERT, 1068 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1069 + IW_PRIV_TYPE_NONE, 1070 + "bt_set_invert"}, 1071 + { 1072 + WLAN_SUBCMD_BT_GET_INVERT, 1073 + IW_PRIV_TYPE_NONE, 1074 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1075 + "bt_get_invert"}, 1005 1076 /* FWT Management */ 1006 1077 { 1007 1078 WLAN_SUBCMD_FWT_ADD, ··· 1074 1125 u8 rssi; 1075 1126 u32 tx_retries; 1076 1127 1077 - ENTER(); 1128 + lbs_deb_enter(LBS_DEB_WEXT); 1078 1129 1079 1130 priv->wstats.status = adapter->mode; 1080 1131 ··· 1094 1145 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 1095 1146 } 1096 1147 1097 - lbs_pr_debug(1, "Signal Level = %#x\n", priv->wstats.qual.level); 1098 - lbs_pr_debug(1, "Noise = %#x\n", priv->wstats.qual.noise); 1148 + lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level); 1149 + lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise); 1099 1150 1100 1151 rssi = priv->wstats.qual.level - priv->wstats.qual.noise; 1101 1152 if (rssi < 15) ··· 1115 1166 /* Quality by TX errors */ 1116 1167 priv->wstats.discard.retries = priv->stats.tx_errors; 1117 1168 1118 - tx_retries = adapter->logmsg.retry; 1169 + tx_retries = le16_to_cpu(adapter->logmsg.retry); 1119 1170 1120 1171 if (tx_retries > 75) 1121 1172 tx_qual = (90 - tx_retries) * POOR / 15; ··· 1131 1182 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; 1132 1183 quality = min(quality, tx_qual); 1133 1184 1134 - priv->wstats.discard.code = adapter->logmsg.wepundecryptable; 1135 - priv->wstats.discard.fragment = adapter->logmsg.fcserror; 1185 + priv->wstats.discard.code = le16_to_cpu(adapter->logmsg.wepundecryptable); 1186 + priv->wstats.discard.fragment = le16_to_cpu(adapter->logmsg.rxfrag); 1136 1187 priv->wstats.discard.retries = tx_retries; 1137 - priv->wstats.discard.misc = adapter->logmsg.ackfailure; 1188 + priv->wstats.discard.misc = le16_to_cpu(adapter->logmsg.ackfailure); 1138 1189 1139 1190 /* Calculate quality */ 1140 1191 priv->wstats.qual.qual = max(quality, (u32)100); ··· 1158 1209 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; 1159 1210 } 1160 1211 1161 - LEAVE (); 1212 + lbs_deb_leave(LBS_DEB_WEXT); 1162 1213 return &priv->wstats; 1163 1214 1164 1215 ··· 1167 1218 static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info, 1168 1219 struct iw_freq *fwrq, char *extra) 1169 1220 { 1170 - int ret = 0; 1221 + int ret = -EINVAL; 1171 1222 wlan_private *priv = dev->priv; 1172 1223 wlan_adapter *adapter = priv->adapter; 1173 - int rc = -EINPROGRESS; /* Call commit handler */ 1174 1224 struct chan_freq_power *cfp; 1225 + struct assoc_request * assoc_req; 1175 1226 1176 - ENTER(); 1227 + lbs_deb_enter(LBS_DEB_WEXT); 1177 1228 1178 - /* 1179 - * If setting by frequency, convert to a channel 1180 - */ 1229 + mutex_lock(&adapter->lock); 1230 + assoc_req = wlan_get_association_request(adapter); 1231 + if (!assoc_req) { 1232 + ret = -ENOMEM; 1233 + goto out; 1234 + } 1235 + 1236 + /* If setting by frequency, convert to a channel */ 1181 1237 if (fwrq->e == 1) { 1182 - 1183 1238 long f = fwrq->m / 100000; 1184 - int c = 0; 1185 1239 1186 1240 cfp = find_cfp_by_band_and_freq(adapter, 0, f); 1187 1241 if (!cfp) { 1188 - lbs_pr_debug(1, "Invalid freq=%ld\n", f); 1189 - return -EINVAL; 1242 + lbs_deb_wext("invalid freq %ld\n", f); 1243 + goto out; 1190 1244 } 1191 - 1192 - c = (int)cfp->channel; 1193 - 1194 - if (c < 0) 1195 - return -EINVAL; 1196 1245 1197 1246 fwrq->e = 0; 1198 - fwrq->m = c; 1247 + fwrq->m = (int) cfp->channel; 1199 1248 } 1200 1249 1201 - /* 1202 - * Setting by channel number 1203 - */ 1250 + /* Setting by channel number */ 1204 1251 if (fwrq->m > 1000 || fwrq->e > 0) { 1205 - rc = -EOPNOTSUPP; 1206 - } else { 1207 - int channel = fwrq->m; 1208 - 1209 - cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, channel); 1210 - if (!cfp) { 1211 - rc = -EINVAL; 1212 - } else { 1213 - if (adapter->mode == IW_MODE_ADHOC) { 1214 - rc = changeadhocchannel(priv, channel); 1215 - /* If station is WEP enabled, send the 1216 - * command to set WEP in firmware 1217 - */ 1218 - if (adapter->secinfo.wep_enabled) { 1219 - lbs_pr_debug(1, "set_freq: WEP enabled\n"); 1220 - ret = libertas_prepare_and_send_command(priv, 1221 - cmd_802_11_set_wep, 1222 - cmd_act_add, 1223 - cmd_option_waitforrsp, 1224 - 0, 1225 - NULL); 1226 - 1227 - if (ret) { 1228 - LEAVE(); 1229 - return ret; 1230 - } 1231 - 1232 - adapter->currentpacketfilter |= 1233 - cmd_act_mac_wep_enable; 1234 - 1235 - libertas_set_mac_packet_filter(priv); 1236 - } 1237 - } else { 1238 - rc = -EOPNOTSUPP; 1239 - } 1240 - } 1252 + goto out; 1241 1253 } 1242 1254 1243 - LEAVE(); 1244 - return rc; 1255 + cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, fwrq->m); 1256 + if (!cfp) { 1257 + goto out; 1258 + } 1259 + 1260 + assoc_req->channel = fwrq->m; 1261 + ret = 0; 1262 + 1263 + out: 1264 + if (ret == 0) { 1265 + set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags); 1266 + wlan_postpone_association_work(priv); 1267 + } else { 1268 + wlan_cancel_association_work(priv); 1269 + } 1270 + mutex_unlock(&adapter->lock); 1271 + 1272 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1273 + return ret; 1245 1274 } 1246 1275 1247 1276 /** ··· 1265 1338 u8 rates[WLAN_SUPPORTED_RATES]; 1266 1339 u8 *rate; 1267 1340 1268 - ENTER(); 1341 + lbs_deb_enter(LBS_DEB_WEXT); 1269 1342 1270 - lbs_pr_debug(1, "Vwrq->value = %d\n", vwrq->value); 1343 + lbs_deb_wext("vwrq->value %d\n", vwrq->value); 1271 1344 1272 1345 if (vwrq->value == -1) { 1273 1346 action = cmd_act_set_tx_auto; // Auto ··· 1284 1357 get_active_data_rates(adapter, rates); 1285 1358 rate = rates; 1286 1359 while (*rate) { 1287 - lbs_pr_debug(1, "Rate=0x%X Wanted=0x%X\n", *rate, 1360 + lbs_deb_wext("rate=0x%X, wanted data_rate 0x%X\n", *rate, 1288 1361 data_rate); 1289 1362 if ((*rate & 0x7f) == (data_rate & 0x7f)) 1290 1363 break; 1291 1364 rate++; 1292 1365 } 1293 1366 if (!*rate) { 1294 - lbs_pr_alert( "The fixed data rate 0x%X is out " 1295 - "of range.\n", data_rate); 1367 + lbs_pr_alert("fixed data rate 0x%X out " 1368 + "of range\n", data_rate); 1296 1369 return -EINVAL; 1297 1370 } 1298 1371 ··· 1304 1377 ret = libertas_prepare_and_send_command(priv, cmd_802_11_data_rate, 1305 1378 action, cmd_option_waitforrsp, 0, NULL); 1306 1379 1307 - LEAVE(); 1380 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1308 1381 return ret; 1309 1382 } 1310 1383 ··· 1314 1387 wlan_private *priv = dev->priv; 1315 1388 wlan_adapter *adapter = priv->adapter; 1316 1389 1317 - ENTER(); 1390 + lbs_deb_enter(LBS_DEB_WEXT); 1318 1391 1319 1392 if (adapter->is_datarate_auto) { 1320 1393 vwrq->fixed = 0; ··· 1324 1397 1325 1398 vwrq->value = adapter->datarate * 500000; 1326 1399 1327 - LEAVE(); 1400 + lbs_deb_leave(LBS_DEB_WEXT); 1328 1401 return 0; 1329 1402 } 1330 1403 ··· 1336 1409 wlan_adapter *adapter = priv->adapter; 1337 1410 struct assoc_request * assoc_req; 1338 1411 1339 - ENTER(); 1412 + lbs_deb_enter(LBS_DEB_WEXT); 1340 1413 1341 1414 if ( (*uwrq != IW_MODE_ADHOC) 1342 1415 && (*uwrq != IW_MODE_INFRA) 1343 1416 && (*uwrq != IW_MODE_AUTO)) { 1344 - lbs_pr_debug(1, "Invalid mode: 0x%x\n", *uwrq); 1417 + lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq); 1345 1418 ret = -EINVAL; 1346 1419 goto out; 1347 1420 } ··· 1355 1428 assoc_req->mode = *uwrq; 1356 1429 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); 1357 1430 wlan_postpone_association_work(priv); 1358 - lbs_pr_debug(1, "Switching to mode: 0x%x\n", *uwrq); 1431 + lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq); 1359 1432 } 1360 1433 mutex_unlock(&adapter->lock); 1361 1434 1362 1435 out: 1363 - LEAVE(); 1436 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1364 1437 return ret; 1365 1438 } 1366 1439 ··· 1382 1455 wlan_adapter *adapter = priv->adapter; 1383 1456 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 1384 1457 1385 - ENTER(); 1458 + lbs_deb_enter(LBS_DEB_WEXT); 1386 1459 1387 - lbs_pr_debug(1, "flags=0x%x index=%d length=%d wep_tx_keyidx=%d\n", 1460 + lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n", 1388 1461 dwrq->flags, index, dwrq->length, adapter->wep_tx_keyidx); 1389 1462 1390 1463 dwrq->flags = 0; ··· 1440 1513 1441 1514 dwrq->flags |= IW_ENCODE_NOKEY; 1442 1515 1443 - lbs_pr_debug(1, "key:%02x:%02x:%02x:%02x:%02x:%02x keylen=%d\n", 1516 + lbs_deb_wext("key: " MAC_FMT ", keylen %d\n", 1444 1517 extra[0], extra[1], extra[2], 1445 1518 extra[3], extra[4], extra[5], dwrq->length); 1446 1519 1447 - lbs_pr_debug(1, "Return flags=0x%x\n", dwrq->flags); 1520 + lbs_deb_wext("return flags 0x%x\n", dwrq->flags); 1448 1521 1449 - LEAVE(); 1522 + lbs_deb_leave(LBS_DEB_WEXT); 1450 1523 return 0; 1451 1524 } 1452 1525 ··· 1466 1539 u16 index, 1467 1540 int set_tx_key) 1468 1541 { 1542 + int ret = 0; 1469 1543 struct WLAN_802_11_KEY *pkey; 1470 1544 1471 - ENTER(); 1545 + lbs_deb_enter(LBS_DEB_WEXT); 1472 1546 1473 1547 /* Paranoid validation of key index */ 1474 1548 if (index > 3) { 1475 - LEAVE(); 1476 - return -EINVAL; 1549 + ret = -EINVAL; 1550 + goto out; 1477 1551 } 1478 1552 1479 1553 /* validate max key length */ 1480 1554 if (key_length > KEY_LEN_WEP_104) { 1481 - LEAVE(); 1482 - return -EINVAL; 1555 + ret = -EINVAL; 1556 + goto out; 1483 1557 } 1484 1558 1485 1559 pkey = &assoc_req->wep_keys[index]; ··· 1498 1570 if (set_tx_key) { 1499 1571 /* Ensure the chosen key is valid */ 1500 1572 if (!pkey->len) { 1501 - lbs_pr_debug(1, "key not set, so cannot enable it\n"); 1502 - LEAVE(); 1503 - return -EINVAL; 1573 + lbs_deb_wext("key not set, so cannot enable it\n"); 1574 + ret = -EINVAL; 1575 + goto out; 1504 1576 } 1505 1577 assoc_req->wep_tx_keyidx = index; 1506 1578 } 1507 1579 1508 1580 assoc_req->secinfo.wep_enabled = 1; 1509 1581 1510 - LEAVE(); 1511 - return 0; 1582 + out: 1583 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1584 + return ret; 1512 1585 } 1513 1586 1514 1587 static int validate_key_index(u16 def_index, u16 raw_index, ··· 1534 1605 { 1535 1606 int i; 1536 1607 1608 + lbs_deb_enter(LBS_DEB_WEXT); 1609 + 1537 1610 /* Set Open System auth mode */ 1538 1611 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 1539 1612 ··· 1546 1615 1547 1616 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); 1548 1617 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); 1618 + 1619 + lbs_deb_leave(LBS_DEB_WEXT); 1620 + } 1621 + 1622 + static void disable_wpa(struct assoc_request *assoc_req) 1623 + { 1624 + lbs_deb_enter(LBS_DEB_WEXT); 1625 + 1626 + memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct WLAN_802_11_KEY)); 1627 + assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST; 1628 + set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); 1629 + 1630 + memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct WLAN_802_11_KEY)); 1631 + assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST; 1632 + set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); 1633 + 1634 + assoc_req->secinfo.WPAenabled = 0; 1635 + assoc_req->secinfo.WPA2enabled = 0; 1636 + set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); 1637 + 1638 + lbs_deb_leave(LBS_DEB_WEXT); 1549 1639 } 1550 1640 1551 1641 /** ··· 1588 1636 struct assoc_request * assoc_req; 1589 1637 u16 is_default = 0, index = 0, set_tx_key = 0; 1590 1638 1591 - ENTER(); 1639 + lbs_deb_enter(LBS_DEB_WEXT); 1592 1640 1593 1641 mutex_lock(&adapter->lock); 1594 1642 assoc_req = wlan_get_association_request(adapter); ··· 1599 1647 1600 1648 if (dwrq->flags & IW_ENCODE_DISABLED) { 1601 1649 disable_wep (assoc_req); 1650 + disable_wpa (assoc_req); 1602 1651 goto out; 1603 1652 } 1604 1653 ··· 1641 1688 } 1642 1689 mutex_unlock(&adapter->lock); 1643 1690 1644 - LEAVE(); 1691 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1645 1692 return ret; 1646 1693 } 1647 1694 ··· 1665 1712 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1666 1713 int index, max_key_len; 1667 1714 1668 - ENTER(); 1715 + lbs_deb_enter(LBS_DEB_WEXT); 1669 1716 1670 1717 max_key_len = dwrq->length - sizeof(*ext); 1671 1718 if (max_key_len < 0) ··· 1701 1748 if ( adapter->secinfo.wep_enabled 1702 1749 && !adapter->secinfo.WPAenabled 1703 1750 && !adapter->secinfo.WPA2enabled) { 1751 + /* WEP */ 1704 1752 ext->alg = IW_ENCODE_ALG_WEP; 1705 1753 ext->key_len = adapter->wep_keys[index].len; 1706 1754 key = &adapter->wep_keys[index].key[0]; ··· 1709 1755 && (adapter->secinfo.WPAenabled || 1710 1756 adapter->secinfo.WPA2enabled)) { 1711 1757 /* WPA */ 1712 - ext->alg = IW_ENCODE_ALG_TKIP; 1713 - ext->key_len = 0; 1758 + struct WLAN_802_11_KEY * pkey = NULL; 1759 + 1760 + if ( adapter->wpa_mcast_key.len 1761 + && (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED)) 1762 + pkey = &adapter->wpa_mcast_key; 1763 + else if ( adapter->wpa_unicast_key.len 1764 + && (adapter->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED)) 1765 + pkey = &adapter->wpa_unicast_key; 1766 + 1767 + if (pkey) { 1768 + if (pkey->type == KEY_TYPE_ID_AES) { 1769 + ext->alg = IW_ENCODE_ALG_CCMP; 1770 + } else { 1771 + ext->alg = IW_ENCODE_ALG_TKIP; 1772 + } 1773 + ext->key_len = pkey->len; 1774 + key = &pkey->key[0]; 1775 + } else { 1776 + ext->alg = IW_ENCODE_ALG_TKIP; 1777 + ext->key_len = 0; 1778 + } 1714 1779 } else { 1715 1780 goto out; 1716 1781 } ··· 1748 1775 ret = 0; 1749 1776 1750 1777 out: 1751 - LEAVE(); 1778 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1752 1779 return ret; 1753 1780 } 1754 1781 ··· 1773 1800 int alg = ext->alg; 1774 1801 struct assoc_request * assoc_req; 1775 1802 1776 - ENTER(); 1803 + lbs_deb_enter(LBS_DEB_WEXT); 1777 1804 1778 1805 mutex_lock(&adapter->lock); 1779 1806 assoc_req = wlan_get_association_request(adapter); ··· 1784 1811 1785 1812 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) { 1786 1813 disable_wep (assoc_req); 1814 + disable_wpa (assoc_req); 1787 1815 } else if (alg == IW_ENCODE_ALG_WEP) { 1788 1816 u16 is_default = 0, index, set_tx_key = 0; 1789 1817 ··· 1820 1846 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); 1821 1847 if (set_tx_key) 1822 1848 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); 1823 - 1824 1849 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) { 1825 1850 struct WLAN_802_11_KEY * pkey; 1826 1851 ··· 1828 1855 && (ext->key_len != KEY_LEN_WPA_TKIP)) 1829 1856 || ((alg == IW_ENCODE_ALG_CCMP) 1830 1857 && (ext->key_len != KEY_LEN_WPA_AES))) { 1831 - lbs_pr_debug(1, "Invalid size %d for key of alg" 1832 - "type %d.\n", 1858 + lbs_deb_wext("invalid size %d for key of alg" 1859 + "type %d\n", 1833 1860 ext->key_len, 1834 1861 alg); 1835 1862 ret = -EINVAL; 1836 1863 goto out; 1837 1864 } 1838 1865 1839 - if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) 1866 + if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { 1840 1867 pkey = &assoc_req->wpa_mcast_key; 1841 - else 1868 + set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); 1869 + } else { 1842 1870 pkey = &assoc_req->wpa_unicast_key; 1871 + set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); 1872 + } 1843 1873 1844 1874 memset(pkey, 0, sizeof (struct WLAN_802_11_KEY)); 1845 1875 memcpy(pkey->key, ext->key, ext->key_len); 1846 1876 pkey->len = ext->key_len; 1847 - pkey->flags = KEY_INFO_WPA_ENABLED; 1877 + if (pkey->len) 1878 + pkey->flags |= KEY_INFO_WPA_ENABLED; 1848 1879 1880 + /* Do this after zeroing key structure */ 1849 1881 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { 1850 1882 pkey->flags |= KEY_INFO_WPA_MCAST; 1851 - set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags); 1852 1883 } else { 1853 1884 pkey->flags |= KEY_INFO_WPA_UNICAST; 1854 - set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); 1855 1885 } 1856 1886 1857 - if (alg == IW_ENCODE_ALG_TKIP) 1887 + if (alg == IW_ENCODE_ALG_TKIP) { 1858 1888 pkey->type = KEY_TYPE_ID_TKIP; 1859 - else if (alg == IW_ENCODE_ALG_CCMP) 1889 + } else if (alg == IW_ENCODE_ALG_CCMP) { 1860 1890 pkey->type = KEY_TYPE_ID_AES; 1891 + } else { 1892 + ret = -EINVAL; 1893 + goto out; 1894 + } 1861 1895 1862 1896 /* If WPA isn't enabled yet, do that now */ 1863 1897 if ( assoc_req->secinfo.WPAenabled == 0 ··· 1885 1905 } 1886 1906 mutex_unlock(&adapter->lock); 1887 1907 1888 - LEAVE(); 1908 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1889 1909 return ret; 1890 1910 } 1891 1911 ··· 1900 1920 int ret = 0; 1901 1921 struct assoc_request * assoc_req; 1902 1922 1903 - ENTER(); 1923 + lbs_deb_enter(LBS_DEB_WEXT); 1904 1924 1905 1925 mutex_lock(&adapter->lock); 1906 1926 assoc_req = wlan_get_association_request(adapter); ··· 1932 1952 } 1933 1953 mutex_unlock(&adapter->lock); 1934 1954 1935 - LEAVE(); 1955 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1936 1956 return ret; 1937 1957 } 1938 1958 ··· 1941 1961 struct iw_point *dwrq, 1942 1962 char *extra) 1943 1963 { 1964 + int ret = 0; 1944 1965 wlan_private *priv = dev->priv; 1945 1966 wlan_adapter *adapter = priv->adapter; 1946 1967 1947 - ENTER(); 1968 + lbs_deb_enter(LBS_DEB_WEXT); 1948 1969 1949 1970 if (adapter->wpa_ie_len == 0) { 1950 1971 dwrq->length = 0; 1951 - LEAVE(); 1952 - return 0; 1972 + goto out; 1953 1973 } 1954 1974 1955 1975 if (dwrq->length < adapter->wpa_ie_len) { 1956 - LEAVE(); 1957 - return -E2BIG; 1976 + ret = -E2BIG; 1977 + goto out; 1958 1978 } 1959 1979 1960 1980 dwrq->length = adapter->wpa_ie_len; 1961 1981 memcpy(extra, &adapter->wpa_ie[0], adapter->wpa_ie_len); 1962 1982 1963 - LEAVE(); 1964 - return 0; 1983 + out: 1984 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1985 + return ret; 1965 1986 } 1966 1987 1967 1988 ··· 1977 1996 int ret = 0; 1978 1997 int updated = 0; 1979 1998 1980 - ENTER(); 1999 + lbs_deb_enter(LBS_DEB_WEXT); 1981 2000 1982 2001 mutex_lock(&adapter->lock); 1983 2002 assoc_req = wlan_get_association_request(adapter); ··· 1991 2010 case IW_AUTH_CIPHER_PAIRWISE: 1992 2011 case IW_AUTH_CIPHER_GROUP: 1993 2012 case IW_AUTH_KEY_MGMT: 2013 + case IW_AUTH_DROP_UNENCRYPTED: 1994 2014 /* 1995 2015 * libertas does not use these parameters 1996 2016 */ ··· 2001 2019 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) { 2002 2020 assoc_req->secinfo.WPAenabled = 0; 2003 2021 assoc_req->secinfo.WPA2enabled = 0; 2022 + disable_wpa (assoc_req); 2004 2023 } 2005 2024 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { 2006 2025 assoc_req->secinfo.WPAenabled = 1; ··· 2012 2029 assoc_req->secinfo.WPA2enabled = 1; 2013 2030 assoc_req->secinfo.wep_enabled = 0; 2014 2031 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 2015 - } 2016 - updated = 1; 2017 - break; 2018 - 2019 - case IW_AUTH_DROP_UNENCRYPTED: 2020 - if (dwrq->value) { 2021 - adapter->currentpacketfilter |= 2022 - cmd_act_mac_strict_protection_enable; 2023 - } else { 2024 - adapter->currentpacketfilter &= 2025 - ~cmd_act_mac_strict_protection_enable; 2026 2032 } 2027 2033 updated = 1; 2028 2034 break; ··· 2041 2069 } else { 2042 2070 assoc_req->secinfo.WPAenabled = 0; 2043 2071 assoc_req->secinfo.WPA2enabled = 0; 2072 + disable_wpa (assoc_req); 2044 2073 } 2045 2074 updated = 1; 2046 2075 break; ··· 2061 2088 } 2062 2089 mutex_unlock(&adapter->lock); 2063 2090 2064 - LEAVE(); 2091 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 2065 2092 return ret; 2066 2093 } 2067 2094 ··· 2070 2097 struct iw_param *dwrq, 2071 2098 char *extra) 2072 2099 { 2100 + int ret = 0; 2073 2101 wlan_private *priv = dev->priv; 2074 2102 wlan_adapter *adapter = priv->adapter; 2075 2103 2076 - ENTER(); 2104 + lbs_deb_enter(LBS_DEB_WEXT); 2077 2105 2078 2106 switch (dwrq->flags & IW_AUTH_INDEX) { 2079 2107 case IW_AUTH_WPA_VERSION: ··· 2087 2113 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED; 2088 2114 break; 2089 2115 2090 - case IW_AUTH_DROP_UNENCRYPTED: 2091 - dwrq->value = 0; 2092 - if (adapter->currentpacketfilter & 2093 - cmd_act_mac_strict_protection_enable) 2094 - dwrq->value = 1; 2095 - break; 2096 - 2097 2116 case IW_AUTH_80211_AUTH_ALG: 2098 2117 dwrq->value = adapter->secinfo.auth_mode; 2099 2118 break; ··· 2097 2130 break; 2098 2131 2099 2132 default: 2100 - LEAVE(); 2101 - return -EOPNOTSUPP; 2133 + ret = -EOPNOTSUPP; 2102 2134 } 2103 2135 2104 - LEAVE(); 2105 - return 0; 2136 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 2137 + return ret; 2106 2138 } 2107 2139 2108 2140 ··· 2114 2148 2115 2149 u16 dbm; 2116 2150 2117 - ENTER(); 2151 + lbs_deb_enter(LBS_DEB_WEXT); 2118 2152 2119 2153 if (vwrq->disabled) { 2120 2154 wlan_radio_ioctl(priv, RADIO_OFF); ··· 2135 2169 if (vwrq->fixed == 0) 2136 2170 dbm = 0xffff; 2137 2171 2138 - lbs_pr_debug(1, "<1>TXPOWER SET %d dbm.\n", dbm); 2172 + lbs_deb_wext("txpower set %d dbm\n", dbm); 2139 2173 2140 2174 ret = libertas_prepare_and_send_command(priv, 2141 2175 cmd_802_11_rf_tx_power, 2142 2176 cmd_act_tx_power_opt_set_low, 2143 2177 cmd_option_waitforrsp, 0, (void *)&dbm); 2144 2178 2145 - LEAVE(); 2179 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 2146 2180 return ret; 2147 2181 } 2148 2182 ··· 2152 2186 wlan_private *priv = dev->priv; 2153 2187 wlan_adapter *adapter = priv->adapter; 2154 2188 2155 - ENTER(); 2189 + lbs_deb_enter(LBS_DEB_WEXT); 2190 + 2156 2191 /* 2157 2192 * Note : if dwrq->flags != 0, we should get the relevant SSID from 2158 2193 * the SSID list... ··· 2163 2196 * Get the current SSID 2164 2197 */ 2165 2198 if (adapter->connect_status == libertas_connected) { 2166 - memcpy(extra, adapter->curbssparams.ssid.ssid, 2167 - adapter->curbssparams.ssid.ssidlength); 2168 - extra[adapter->curbssparams.ssid.ssidlength] = '\0'; 2199 + memcpy(extra, adapter->curbssparams.ssid, 2200 + adapter->curbssparams.ssid_len); 2201 + extra[adapter->curbssparams.ssid_len] = '\0'; 2169 2202 } else { 2170 2203 memset(extra, 0, 32); 2171 - extra[adapter->curbssparams.ssid.ssidlength] = '\0'; 2204 + extra[adapter->curbssparams.ssid_len] = '\0'; 2172 2205 } 2173 2206 /* 2174 2207 * If none, we may want to get the one that was set ··· 2176 2209 2177 2210 /* To make the driver backward compatible with WPA supplicant v0.2.4 */ 2178 2211 if (dwrq->length == 32) /* check with WPA supplicant buffer size */ 2179 - dwrq->length = min_t(size_t, adapter->curbssparams.ssid.ssidlength, 2212 + dwrq->length = min_t(size_t, adapter->curbssparams.ssid_len, 2180 2213 IW_ESSID_MAX_SIZE); 2181 2214 else 2182 - dwrq->length = adapter->curbssparams.ssid.ssidlength + 1; 2215 + dwrq->length = adapter->curbssparams.ssid_len + 1; 2183 2216 2184 2217 dwrq->flags = 1; /* active */ 2185 2218 2186 - LEAVE(); 2219 + lbs_deb_leave(LBS_DEB_WEXT); 2187 2220 return 0; 2188 2221 } 2189 2222 ··· 2193 2226 wlan_private *priv = dev->priv; 2194 2227 wlan_adapter *adapter = priv->adapter; 2195 2228 int ret = 0; 2196 - struct WLAN_802_11_SSID ssid; 2229 + u8 ssid[IW_ESSID_MAX_SIZE]; 2230 + u8 ssid_len = 0; 2197 2231 struct assoc_request * assoc_req; 2198 - int ssid_len = dwrq->length; 2232 + int in_ssid_len = dwrq->length; 2199 2233 2200 - ENTER(); 2234 + lbs_deb_enter(LBS_DEB_WEXT); 2201 2235 2202 2236 /* 2203 2237 * WE-20 and earlier NULL pad the end of the SSID and increment 2204 2238 * SSID length so it can be used like a string. WE-21 and later don't, 2205 2239 * but some userspace tools aren't able to cope with the change. 2206 2240 */ 2207 - if ((ssid_len > 0) && (extra[ssid_len - 1] == '\0')) 2208 - ssid_len--; 2241 + if ((in_ssid_len > 0) && (extra[in_ssid_len - 1] == '\0')) 2242 + in_ssid_len--; 2209 2243 2210 2244 /* Check the size of the string */ 2211 - if (ssid_len > IW_ESSID_MAX_SIZE) { 2245 + if (in_ssid_len > IW_ESSID_MAX_SIZE) { 2212 2246 ret = -E2BIG; 2213 2247 goto out; 2214 2248 } 2215 2249 2216 - memset(&ssid, 0, sizeof(struct WLAN_802_11_SSID)); 2250 + memset(&ssid, 0, sizeof(ssid)); 2217 2251 2218 - if (!dwrq->flags || !ssid_len) { 2252 + if (!dwrq->flags || !in_ssid_len) { 2219 2253 /* "any" SSID requested; leave SSID blank */ 2220 2254 } else { 2221 2255 /* Specific SSID requested */ 2222 - memcpy(&ssid.ssid, extra, ssid_len); 2223 - ssid.ssidlength = ssid_len; 2256 + memcpy(&ssid, extra, in_ssid_len); 2257 + ssid_len = in_ssid_len; 2224 2258 } 2225 2259 2226 - lbs_pr_debug(1, "Requested new SSID = %s\n", 2227 - (ssid.ssidlength > 0) ? (char *)ssid.ssid : "any"); 2260 + if (!ssid_len) { 2261 + lbs_deb_wext("requested any SSID\n"); 2262 + } else { 2263 + lbs_deb_wext("requested SSID '%s'\n", 2264 + escape_essid(ssid, ssid_len)); 2265 + } 2228 2266 2229 2267 out: 2230 2268 mutex_lock(&adapter->lock); ··· 2240 2268 ret = -ENOMEM; 2241 2269 } else { 2242 2270 /* Copy the SSID to the association request */ 2243 - memcpy(&assoc_req->ssid, &ssid, sizeof(struct WLAN_802_11_SSID)); 2271 + memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE); 2272 + assoc_req->ssid_len = ssid_len; 2244 2273 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags); 2245 2274 wlan_postpone_association_work(priv); 2246 2275 } ··· 2254 2281 2255 2282 mutex_unlock(&adapter->lock); 2256 2283 2257 - LEAVE(); 2284 + lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 2258 2285 return ret; 2259 2286 } 2260 2287 ··· 2275 2302 struct assoc_request * assoc_req; 2276 2303 int ret = 0; 2277 2304 2278 - ENTER(); 2305 + lbs_deb_enter(LBS_DEB_WEXT); 2279 2306 2280 2307 if (awrq->sa_family != ARPHRD_ETHER) 2281 2308 return -EINVAL; 2282 2309 2283 - lbs_pr_debug(1, "ASSOC: WAP: sa_data: " MAC_FMT "\n", MAC_ARG(awrq->sa_data)); 2310 + lbs_deb_wext("ASSOC: WAP: sa_data " MAC_FMT "\n", MAC_ARG(awrq->sa_data)); 2284 2311 2285 2312 mutex_lock(&adapter->lock); 2286 2313 ··· 2303 2330 2304 2331 void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen) 2305 2332 { 2306 - union { 2307 - u32 l; 2308 - u8 c[4]; 2309 - } ver; 2310 2333 char fwver[32]; 2311 2334 2312 2335 mutex_lock(&adapter->lock); 2313 - ver.l = adapter->fwreleasenumber; 2314 - mutex_unlock(&adapter->lock); 2315 2336 2316 - if (ver.c[3] == 0) 2317 - sprintf(fwver, "%u.%u.%u", ver.c[2], ver.c[1], ver.c[0]); 2337 + if (adapter->fwreleasenumber[3] == 0) 2338 + sprintf(fwver, "%u.%u.%u", 2339 + adapter->fwreleasenumber[2], 2340 + adapter->fwreleasenumber[1], 2341 + adapter->fwreleasenumber[0]); 2318 2342 else 2319 2343 sprintf(fwver, "%u.%u.%u.p%u", 2320 - ver.c[2], ver.c[1], ver.c[0], ver.c[3]); 2344 + adapter->fwreleasenumber[2], 2345 + adapter->fwreleasenumber[1], 2346 + adapter->fwreleasenumber[0], 2347 + adapter->fwreleasenumber[3]); 2321 2348 2349 + mutex_unlock(&adapter->lock); 2322 2350 snprintf(fwversion, maxlen, fwver); 2323 2351 } 2324 2352 ··· 2385 2411 (iw_handler) NULL, /* SIOCSIWPMKSA */ 2386 2412 }; 2387 2413 2414 + static const iw_handler mesh_wlan_handler[] = { 2415 + (iw_handler) NULL, /* SIOCSIWCOMMIT */ 2416 + (iw_handler) wlan_get_name, /* SIOCGIWNAME */ 2417 + (iw_handler) NULL, /* SIOCSIWNWID */ 2418 + (iw_handler) NULL, /* SIOCGIWNWID */ 2419 + (iw_handler) wlan_set_freq, /* SIOCSIWFREQ */ 2420 + (iw_handler) wlan_get_freq, /* SIOCGIWFREQ */ 2421 + (iw_handler) NULL, /* SIOCSIWMODE */ 2422 + (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */ 2423 + (iw_handler) NULL, /* SIOCSIWSENS */ 2424 + (iw_handler) NULL, /* SIOCGIWSENS */ 2425 + (iw_handler) NULL, /* SIOCSIWRANGE */ 2426 + (iw_handler) wlan_get_range, /* SIOCGIWRANGE */ 2427 + (iw_handler) NULL, /* SIOCSIWPRIV */ 2428 + (iw_handler) NULL, /* SIOCGIWPRIV */ 2429 + (iw_handler) NULL, /* SIOCSIWSTATS */ 2430 + (iw_handler) NULL, /* SIOCGIWSTATS */ 2431 + iw_handler_set_spy, /* SIOCSIWSPY */ 2432 + iw_handler_get_spy, /* SIOCGIWSPY */ 2433 + iw_handler_set_thrspy, /* SIOCSIWTHRSPY */ 2434 + iw_handler_get_thrspy, /* SIOCGIWTHRSPY */ 2435 + (iw_handler) NULL, /* SIOCSIWAP */ 2436 + (iw_handler) NULL, /* SIOCGIWAP */ 2437 + (iw_handler) NULL, /* SIOCSIWMLME */ 2438 + (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */ 2439 + (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */ 2440 + (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */ 2441 + (iw_handler) NULL, /* SIOCSIWESSID */ 2442 + (iw_handler) NULL, /* SIOCGIWESSID */ 2443 + (iw_handler) NULL, /* SIOCSIWNICKN */ 2444 + (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */ 2445 + (iw_handler) NULL, /* -- hole -- */ 2446 + (iw_handler) NULL, /* -- hole -- */ 2447 + (iw_handler) wlan_set_rate, /* SIOCSIWRATE */ 2448 + (iw_handler) wlan_get_rate, /* SIOCGIWRATE */ 2449 + (iw_handler) wlan_set_rts, /* SIOCSIWRTS */ 2450 + (iw_handler) wlan_get_rts, /* SIOCGIWRTS */ 2451 + (iw_handler) wlan_set_frag, /* SIOCSIWFRAG */ 2452 + (iw_handler) wlan_get_frag, /* SIOCGIWFRAG */ 2453 + (iw_handler) wlan_set_txpow, /* SIOCSIWTXPOW */ 2454 + (iw_handler) wlan_get_txpow, /* SIOCGIWTXPOW */ 2455 + (iw_handler) wlan_set_retry, /* SIOCSIWRETRY */ 2456 + (iw_handler) wlan_get_retry, /* SIOCGIWRETRY */ 2457 + (iw_handler) wlan_set_encode, /* SIOCSIWENCODE */ 2458 + (iw_handler) wlan_get_encode, /* SIOCGIWENCODE */ 2459 + (iw_handler) wlan_set_power, /* SIOCSIWPOWER */ 2460 + (iw_handler) wlan_get_power, /* SIOCGIWPOWER */ 2461 + (iw_handler) NULL, /* -- hole -- */ 2462 + (iw_handler) NULL, /* -- hole -- */ 2463 + (iw_handler) wlan_set_genie, /* SIOCSIWGENIE */ 2464 + (iw_handler) wlan_get_genie, /* SIOCGIWGENIE */ 2465 + (iw_handler) wlan_set_auth, /* SIOCSIWAUTH */ 2466 + (iw_handler) wlan_get_auth, /* SIOCGIWAUTH */ 2467 + (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */ 2468 + (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */ 2469 + (iw_handler) NULL, /* SIOCSIWPMKSA */ 2470 + }; 2388 2471 struct iw_handler_def libertas_handler_def = { 2389 2472 .num_standard = sizeof(wlan_handler) / sizeof(iw_handler), 2390 2473 .num_private = sizeof(wlan_private_handler) / sizeof(iw_handler), 2391 2474 .num_private_args = sizeof(wlan_private_args) / 2392 2475 sizeof(struct iw_priv_args), 2393 2476 .standard = (iw_handler *) wlan_handler, 2477 + .private = (iw_handler *) wlan_private_handler, 2478 + .private_args = (struct iw_priv_args *)wlan_private_args, 2479 + .get_wireless_stats = wlan_get_wireless_stats, 2480 + }; 2481 + 2482 + struct iw_handler_def mesh_handler_def = { 2483 + .num_standard = sizeof(mesh_wlan_handler) / sizeof(iw_handler), 2484 + .num_private = sizeof(wlan_private_handler) / sizeof(iw_handler), 2485 + .num_private_args = sizeof(wlan_private_args) / 2486 + sizeof(struct iw_priv_args), 2487 + .standard = (iw_handler *) mesh_wlan_handler, 2394 2488 .private = (iw_handler *) wlan_private_handler, 2395 2489 .private_args = (struct iw_priv_args *)wlan_private_args, 2396 2490 .get_wireless_stats = wlan_get_wireless_stats,
+8 -5
drivers/net/wireless/libertas/wext.h
··· 20 20 #define WLAN_SUBCMD_FWT_CLEANUP 15 21 21 #define WLAN_SUBCMD_FWT_TIME 16 22 22 #define WLAN_SUBCMD_MESH_GET_TTL 17 23 + #define WLAN_SUBCMD_BT_GET_INVERT 18 23 24 24 25 #define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) 25 26 #define WLANSETREGION 8 26 27 #define WLAN_SUBCMD_MESH_SET_TTL 18 28 + #define WLAN_SUBCMD_BT_SET_INVERT 19 27 29 28 30 #define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) 29 31 #define WLAN_SUBCMD_BT_ADD 18 30 32 #define WLAN_SUBCMD_BT_DEL 19 31 33 #define WLAN_SUBCMD_BT_LIST 20 32 - #define WLAN_SUBCMD_FWT_ADD 21 33 - #define WLAN_SUBCMD_FWT_DEL 22 34 - #define WLAN_SUBCMD_FWT_LOOKUP 23 35 - #define WLAN_SUBCMD_FWT_LIST_NEIGHBOR 24 34 + #define WLAN_SUBCMD_FWT_ADD 21 35 + #define WLAN_SUBCMD_FWT_DEL 22 36 + #define WLAN_SUBCMD_FWT_LOOKUP 23 37 + #define WLAN_SUBCMD_FWT_LIST_NEIGHBOR 24 36 38 #define WLAN_SUBCMD_FWT_LIST 25 37 - #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 39 + #define WLAN_SUBCMD_FWT_LIST_ROUTE 26 38 40 39 41 #define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) 40 42 #define WLAN_LED_GPIO_CTRL 5 ··· 58 56 }; 59 57 60 58 extern struct iw_handler_def libertas_handler_def; 59 + extern struct iw_handler_def mesh_handler_def; 61 60 int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int i); 62 61 int wlan_radio_ioctl(wlan_private * priv, u8 option); 63 62