53 #include <linux/module.h>
55 #include <linux/kernel.h>
56 #include <linux/sched.h>
57 #include <linux/types.h>
59 #include <linux/slab.h>
60 #include <linux/wireless.h>
61 #include <linux/netdevice.h>
64 #include <linux/ctype.h>
68 #include <asm/byteorder.h>
69 #include <linux/if_arp.h>
70 #include <linux/if_ether.h>
71 #include <linux/bitops.h>
87 #define wlan_mkprintstr(buf, buflen, str, strlen) \
91 memset(str, 0, (strlen)); \
92 for (i = 0; i < (buflen); i++) { \
93 if (isprint((buf)[i])) { \
94 (str)[j] = (buf)[i]; \
99 (str)[j+2] = hex_asc_hi((buf)[i]); \
100 (str)[j+3] = hex_asc_lo((buf)[i]); \
106 static char *
dev_info =
"prism2_usb";
112 static int prism2_doreset;
135 static int prism2sta_getcardinfo(
wlandevice_t *wlandev);
136 static int prism2sta_globalsetup(
wlandevice_t *wlandev);
139 static void prism2sta_inf_handover(
wlandevice_t *wlandev,
141 static void prism2sta_inf_tallies(
wlandevice_t *wlandev,
143 static void prism2sta_inf_hostscanresults(
wlandevice_t *wlandev,
145 static void prism2sta_inf_scanresults(
wlandevice_t *wlandev,
147 static void prism2sta_inf_chinforesults(
wlandevice_t *wlandev,
149 static void prism2sta_inf_linkstatus(
wlandevice_t *wlandev,
151 static void prism2sta_inf_assocstatus(
wlandevice_t *wlandev,
153 static void prism2sta_inf_authreq(
wlandevice_t *wlandev,
155 static void prism2sta_inf_authreq_defer(
wlandevice_t *wlandev,
157 static void prism2sta_inf_psusercnt(
wlandevice_t *wlandev,
272 hfa384x_t *
hw = (hfa384x_t *) wlandev->
priv;
312 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
318 pr_debug(
"Received mibget request\n");
322 pr_debug(
"Received mibset request\n");
326 pr_debug(
"Received scan request\n");
330 pr_debug(
"Received scan_results request\n");
334 pr_debug(
"Received mlme start request\n");
341 pr_debug(
"Received mlme readpda request\n");
345 pr_debug(
"Received mlme ramdl_state request\n");
349 pr_debug(
"Received mlme ramdl_write request\n");
353 pr_debug(
"Received mlme flashdl_state request\n");
357 pr_debug(
"Received mlme flashdl_write request\n");
368 pr_debug(
"Received mlme ifstate request\n");
380 pr_debug(
"Received mlme wlansniff request\n");
384 pr_debug(
"Received mlme autojoin request\n");
390 pr_debug(
"Received commsquality request\n");
440 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
445 pr_debug(
"Current MSD state(%d), requesting(%d)\n",
459 "hfa384x_drvr_start() failed,"
460 "result=%d\n", (
int)
result);
475 "Cannot enter fwload state from enable state,"
476 "you must disable first.\n");
504 "hfa384x_drvr_start() failed,"
505 "result=%d\n", (
int)
result);
512 result = prism2sta_getcardinfo(wlandev);
515 "prism2sta_getcardinfo() failed,"
516 "result=%d\n", (
int)
result);
523 result = prism2sta_globalsetup(wlandev);
526 "prism2sta_globalsetup() failed,"
527 "result=%d\n", (
int)
result);
536 hw->join_retries = 60;
615 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
633 hw->ident_nic.variant =
le16_to_cpu(hw->ident_nic.variant);
634 hw->ident_nic.major =
le16_to_cpu(hw->ident_nic.major);
635 hw->ident_nic.minor =
le16_to_cpu(hw->ident_nic.minor);
638 hw->ident_nic.id, hw->ident_nic.major,
639 hw->ident_nic.minor, hw->ident_nic.variant);
651 hw->ident_pri_fw.id =
le16_to_cpu(hw->ident_pri_fw.id);
652 hw->ident_pri_fw.variant =
le16_to_cpu(hw->ident_pri_fw.variant);
653 hw->ident_pri_fw.major =
le16_to_cpu(hw->ident_pri_fw.major);
654 hw->ident_pri_fw.minor =
le16_to_cpu(hw->ident_pri_fw.minor);
657 hw->ident_pri_fw.id, hw->ident_pri_fw.major,
658 hw->ident_pri_fw.minor, hw->ident_pri_fw.variant);
669 if (hw->ident_nic.id < 0x8000) {
671 "FATAL: Card is not an Intersil Prism2/2.5/3\n");
677 hw->ident_sta_fw.id =
le16_to_cpu(hw->ident_sta_fw.id);
678 hw->ident_sta_fw.variant =
le16_to_cpu(hw->ident_sta_fw.variant);
679 hw->ident_sta_fw.major =
le16_to_cpu(hw->ident_sta_fw.major);
680 hw->ident_sta_fw.minor =
le16_to_cpu(hw->ident_sta_fw.minor);
683 hw->mm_mods = hw->ident_sta_fw.variant & (
BIT(14) |
BIT(15));
684 hw->ident_sta_fw.variant &= ~((
u16) (
BIT(14) |
BIT(15)));
686 if (hw->ident_sta_fw.id == 0x1f) {
688 "ident: sta f/w: id=0x%02x %d.%d.%d\n",
689 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
690 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
693 "ident: ap f/w: id=0x%02x %d.%d.%d\n",
694 hw->ident_sta_fw.id, hw->ident_sta_fw.major,
695 hw->ident_sta_fw.minor, hw->ident_sta_fw.variant);
711 hw->cap_sup_mfi.role =
le16_to_cpu(hw->cap_sup_mfi.role);
712 hw->cap_sup_mfi.id =
le16_to_cpu(hw->cap_sup_mfi.id);
713 hw->cap_sup_mfi.variant =
le16_to_cpu(hw->cap_sup_mfi.variant);
714 hw->cap_sup_mfi.bottom =
le16_to_cpu(hw->cap_sup_mfi.bottom);
715 hw->cap_sup_mfi.top =
le16_to_cpu(hw->cap_sup_mfi.top);
718 "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
719 hw->cap_sup_mfi.role, hw->cap_sup_mfi.id,
720 hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom,
721 hw->cap_sup_mfi.top);
734 hw->cap_sup_cfi.role =
le16_to_cpu(hw->cap_sup_cfi.role);
735 hw->cap_sup_cfi.id =
le16_to_cpu(hw->cap_sup_cfi.id);
736 hw->cap_sup_cfi.variant =
le16_to_cpu(hw->cap_sup_cfi.variant);
737 hw->cap_sup_cfi.bottom =
le16_to_cpu(hw->cap_sup_cfi.bottom);
738 hw->cap_sup_cfi.top =
le16_to_cpu(hw->cap_sup_cfi.top);
741 "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
742 hw->cap_sup_cfi.role, hw->cap_sup_cfi.id,
743 hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom,
744 hw->cap_sup_cfi.top);
757 hw->cap_sup_pri.role =
le16_to_cpu(hw->cap_sup_pri.role);
758 hw->cap_sup_pri.id =
le16_to_cpu(hw->cap_sup_pri.id);
759 hw->cap_sup_pri.variant =
le16_to_cpu(hw->cap_sup_pri.variant);
760 hw->cap_sup_pri.bottom =
le16_to_cpu(hw->cap_sup_pri.bottom);
761 hw->cap_sup_pri.top =
le16_to_cpu(hw->cap_sup_pri.top);
764 "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
765 hw->cap_sup_pri.role, hw->cap_sup_pri.id,
766 hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom,
767 hw->cap_sup_pri.top);
780 hw->cap_sup_sta.role =
le16_to_cpu(hw->cap_sup_sta.role);
781 hw->cap_sup_sta.id =
le16_to_cpu(hw->cap_sup_sta.id);
782 hw->cap_sup_sta.variant =
le16_to_cpu(hw->cap_sup_sta.variant);
783 hw->cap_sup_sta.bottom =
le16_to_cpu(hw->cap_sup_sta.bottom);
784 hw->cap_sup_sta.top =
le16_to_cpu(hw->cap_sup_sta.top);
786 if (hw->cap_sup_sta.id == 0x04) {
788 "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
789 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
790 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
791 hw->cap_sup_sta.top);
794 "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
795 hw->cap_sup_sta.role, hw->cap_sup_sta.id,
796 hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom,
797 hw->cap_sup_sta.top);
802 &hw->cap_act_pri_cfi,
811 hw->cap_act_pri_cfi.role =
le16_to_cpu(hw->cap_act_pri_cfi.role);
812 hw->cap_act_pri_cfi.id =
le16_to_cpu(hw->cap_act_pri_cfi.id);
813 hw->cap_act_pri_cfi.variant =
le16_to_cpu(hw->cap_act_pri_cfi.variant);
814 hw->cap_act_pri_cfi.bottom =
le16_to_cpu(hw->cap_act_pri_cfi.bottom);
815 hw->cap_act_pri_cfi.top =
le16_to_cpu(hw->cap_act_pri_cfi.top);
818 "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
819 hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id,
820 hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom,
821 hw->cap_act_pri_cfi.top);
825 &hw->cap_act_sta_cfi,
834 hw->cap_act_sta_cfi.role =
le16_to_cpu(hw->cap_act_sta_cfi.role);
835 hw->cap_act_sta_cfi.id =
le16_to_cpu(hw->cap_act_sta_cfi.id);
836 hw->cap_act_sta_cfi.variant =
le16_to_cpu(hw->cap_act_sta_cfi.variant);
837 hw->cap_act_sta_cfi.bottom =
le16_to_cpu(hw->cap_act_sta_cfi.bottom);
838 hw->cap_act_sta_cfi.top =
le16_to_cpu(hw->cap_act_sta_cfi.top);
841 "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
842 hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id,
843 hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom,
844 hw->cap_act_sta_cfi.top);
848 &hw->cap_act_sta_mfi,
857 hw->cap_act_sta_mfi.role =
le16_to_cpu(hw->cap_act_sta_mfi.role);
858 hw->cap_act_sta_mfi.id =
le16_to_cpu(hw->cap_act_sta_mfi.id);
859 hw->cap_act_sta_mfi.variant =
le16_to_cpu(hw->cap_act_sta_mfi.variant);
860 hw->cap_act_sta_mfi.bottom =
le16_to_cpu(hw->cap_act_sta_mfi.bottom);
861 hw->cap_act_sta_mfi.top =
le16_to_cpu(hw->cap_act_sta_mfi.top);
864 "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n",
865 hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id,
866 hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom,
867 hw->cap_act_sta_mfi.top);
899 hw->dbmadjust =
temp;
903 hw->ident_sta_fw.minor,
904 hw->ident_sta_fw.variant) <
938 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
948 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
986 static void prism2sta_inf_handover(
wlandevice_t *wlandev,
989 pr_debug(
"received infoframe:HANDOVER (unhandled)\n");
1009 static void prism2sta_inf_tallies(
wlandevice_t *wlandev,
1012 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1026 dst = (
u32 *) &hw->tallies;
1028 for (
i = 0;
i <
cnt;
i++,
dst++, src32++)
1031 dst = (
u32 *) &hw->tallies;
1033 for (
i = 0;
i <
cnt;
i++, dst++, src16++)
1055 static void prism2sta_inf_scanresults(
wlandevice_t *wlandev,
1059 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1072 pr_debug(
"rx scanresults, reason=%d, nbss=%d:\n",
1074 for (i = 0; i < nbss; i++) {
1075 pr_debug(
"chid=%d anl=%d sl=%d bcnint=%d\n",
1078 sr->result[i].sl,
sr->result[i].bcnint);
1079 pr_debug(
" capinfo=0x%04x proberesp_rate=%d\n",
1080 sr->result[i].capinfo,
sr->result[i].proberesp_rate);
1111 static void prism2sta_inf_hostscanresults(
wlandevice_t *wlandev,
1114 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1118 pr_debug(
"Received %d hostscan results\n", nbss);
1123 kfree(hw->scanresults);
1132 hw->scanflag = nbss;
1153 static void prism2sta_inf_chinforesults(
wlandevice_t *wlandev,
1156 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1159 hw->channel_info.results.scanchannels =
1163 if (hw->channel_info.results.scanchannels & (1 << i)) {
1168 &hw->channel_info.results.result[
channel];
1178 (
"chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n",
1182 :
"noise", chinforesult->
anl, chinforesult->
pnl,
1190 hw->channel_info.count =
n;
1195 hfa384x_t *hw =
container_of(data,
struct hfa384x, link_bh);
1207 prism2sta_inf_authreq_defer(wlandev, inf);
1213 if (hw->link_status == hw->link_status_new)
1216 hw->link_status = hw->link_status_new;
1218 switch (hw->link_status) {
1247 if (hw->join_ap == 1)
1249 hw->join_retries = 60;
1266 (
"getconfig(0x%02x) failed, result = %d\n",
1273 &ssid,
sizeof(ssid));
1276 (
"getconfig(0x%02x) failed, result = %d\n",
1285 result = hfa384x_drvr_getconfig16(hw,
1290 (
"getconfig(0x%02x) failed, result = %d\n",
1318 "linkstatus=DISCONNECTED (unhandled)\n");
1349 pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
1356 &ssid,
sizeof(ssid));
1358 pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
1414 if (hw->join_ap && --hw->join_retries > 0) {
1416 joinreq = hw->joinreq;
1423 "linkstatus=ASSOCFAIL (re-submitting join)\n");
1438 "unknown linkstatus=0x%02x\n", hw->link_status);
1462 static void prism2sta_inf_linkstatus(
wlandevice_t *wlandev,
1465 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1490 static void prism2sta_inf_assocstatus(
wlandevice_t *wlandev,
1493 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1513 for (i = 0; i < hw->authlist.cnt; i++)
1517 if (i >= hw->authlist.cnt) {
1520 "assocstatus info frame received for non-authenticated station.\n");
1522 hw->authlist.assoc[
i] =
1528 "authfail assocstatus info frame received for authenticated station.\n");
1551 static void prism2sta_inf_authreq(
wlandevice_t *wlandev,
1554 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1557 skb = dev_alloc_skb(
sizeof(*inf));
1566 static void prism2sta_inf_authreq_defer(
wlandevice_t *wlandev,
1569 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1572 int i, added, result, cnt;
1587 switch (hw->accessmode) {
1588 case WLAN_ACCESS_NONE:
1595 for (i = 0; i < hw->authlist.cnt; i++)
1596 if (
memcmp(rec.address, hw->authlist.addr[i],
1604 case WLAN_ACCESS_ALL:
1613 case WLAN_ACCESS_ALLOW:
1625 if (hw->allow.modify == 0) {
1626 cnt = hw->allow.cnt;
1629 cnt = hw->allow.cnt1;
1630 addr = hw->allow.addr1[0];
1641 case WLAN_ACCESS_DENY:
1653 if (hw->deny.modify == 0) {
1655 addr = hw->deny.addr[0];
1657 cnt = hw->deny.cnt1;
1658 addr = hw->deny.addr1[0];
1684 for (i = 0; i < hw->authlist.cnt; i++)
1689 if (i >= hw->authlist.cnt) {
1690 if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
1693 memcpy(hw->authlist.addr[hw->authlist.cnt],
1716 "setconfig(authenticatestation) failed, result=%d\n",
1739 static void prism2sta_inf_psusercnt(
wlandevice_t *wlandev,
1742 hfa384x_t *hw = (hfa384x_t *) wlandev->
priv;
1770 prism2sta_inf_handover(wlandev, inf);
1773 prism2sta_inf_tallies(wlandev, inf);
1776 prism2sta_inf_hostscanresults(wlandev, inf);
1779 prism2sta_inf_scanresults(wlandev, inf);
1782 prism2sta_inf_chinforesults(wlandev, inf);
1785 prism2sta_inf_linkstatus(wlandev, inf);
1788 prism2sta_inf_assocstatus(wlandev, inf);
1791 prism2sta_inf_authreq(wlandev, inf);
1794 prism2sta_inf_psusercnt(wlandev, inf);
1807 "Unknown info type=0x%02x\n", inf->
infotype);
1833 pr_debug(
"TxExc status=0x%x.\n", status);
1854 pr_debug(
"Tx Complete, status=0x%04x\n", status);
1898 netif_wake_queue(wlandev->
netdev);
1923 hfa384x_t *hw =
NULL;
1929 if (!wlandev || !hw) {
1940 wlandev->
open = prism2sta_open;
1941 wlandev->
close = prism2sta_close;
1942 wlandev->
reset = prism2sta_reset;
1943 wlandev->
txframe = prism2sta_txframe;
1951 hw->dot11_desired_bss_type = 1;
1958 hfa384x_t *hw =
container_of(data,
struct hfa384x, commsqual_bh);
1966 if (hw->wlandev->hwremoved)
1998 pr_debug(
"get signal rate failed, result = %d\n",
2003 switch (mibitem->data) {
2017 pr_debug(
"Bad ratebit (%d)\n", mibitem->data);
2025 pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
2032 &ssid,
sizeof(ssid));
2034 pr_debug(
"getconfig(0x%02x) failed, result = %d\n",
2047 hfa384x_t *hw = (hfa384x_t *) data;