1 /**** (legal) claimer in README
2 ** Copyright (C) 2003 ACX100 Open Source Project
5 #include <linux/version.h>
6 #include <linux/module.h>
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
9 #include <linux/types.h>
10 #include <linux/slab.h>
11 #include <linux/delay.h>
12 #include <linux/proc_fs.h>
13 #include <linux/if_arp.h>
14 #include <linux/rtnetlink.h>
15 #include <linux/netdevice.h>
16 #include <linux/etherdevice.h>
17 #include <linux/wireless.h>
19 #include <linux/vmalloc.h>
20 #include <linux/firmware.h>
21 //#include <net/iw_handler.h>
22 #include <linux/ethtool.h>
23 //#include <linux/utsrelease.h>
28 /***********************************************************************
31 static void acx_l_rx(acx_device_t
* adev
, rxbuffer_t
* rxbuf
);
35 /***********************************************************************
38 unsigned int acx_debug
/* will add __read_mostly later */ = ACX_DEFAULT_MSG
;
39 /* parameter is 'debug', corresponding var is acx_debug */
40 module_param_named(debug
, acx_debug
, uint
, 0);
41 MODULE_PARM_DESC(debug
, "Debug level mask (see L_xxx constants)");
45 MODULE_LICENSE("Dual MPL/GPL");
47 /* USB had this: MODULE_AUTHOR("Martin Wawro <martin.wawro AT uni-dortmund.de>"); */
48 MODULE_AUTHOR("ACX100 Open Source Driver development team");
50 ("Driver for TI ACX1xx based wireless cards (CardBus/PCI/USB)");
53 MODULE_VERSION(ACX_RELEASE
);
56 /***********************************************************************
58 /* Probably a number of acx's intermediate buffers for USB transfers,
59 ** not to be confused with number of descriptors in tx/rx rings
60 ** (which are not directly accessible to host in USB devices) */
65 /***********************************************************************
68 /* minutes to wait until next radio recalibration: */
69 #define RECALIB_PAUSE 5
71 /* Please keep acx_reg_domain_ids_len in sync... */
72 const u8 acx_reg_domain_ids
[acx_reg_domain_ids_len
] =
73 { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40, 0x41, 0x51 };
74 static const u16 reg_domain_channel_masks
[acx_reg_domain_ids_len
] =
75 { 0x07ff, 0x07ff, 0x1fff, 0x0600, 0x1e00, 0x2000, 0x3fff, 0x01fc };
77 acx_reg_domain_strings
[] = {
78 /* 0 */ " 1-11 FCC (USA)",
79 /* 1 */ " 1-11 DOC/IC (Canada)",
80 /* BTW: WLAN use in ETSI is regulated by ETSI standard EN 300 328-2 V1.1.2 */
81 /* 2 */ " 1-13 ETSI (Europe)",
82 /* 3 */ "10-11 Spain",
83 /* 4 */ "10-13 France",
84 /* 5 */ " 14 MKK (Japan)",
86 /* 7 */ " 3-9 Israel (not all firmware versions)",
87 NULL
/* needs to remain as last entry */
92 /***********************************************************************
95 #ifdef PARANOID_LOCKING
96 static unsigned max_lock_time
;
97 static unsigned max_sem_time
;
99 /* Obvious or linux kernel specific derived code follows: */
101 void acx_lock_unhold()
106 void acx_sem_unhold()
111 static inline const char *sanitize_str(const char *s
)
113 const char *t
= strrchr(s
, '/');
119 void acx_lock_debug(acx_device_t
* adev
, const char *where
)
121 unsigned int count
= 100 * 1000 * 1000;
122 where
= sanitize_str(where
);
124 if (!spin_is_locked(&adev
->spinlock
))
129 printk(KERN_EMERG
"LOCKUP: already taken at %s!\n",
133 adev
->last_lock
= where
;
134 rdtscl(adev
->lock_time
);
137 void acx_unlock_debug(acx_device_t
* adev
, const char *where
)
140 if (!spin_is_locked(&adev
->spinlock
)) {
141 where
= sanitize_str(where
);
142 printk(KERN_EMERG
"STRAY UNLOCK at %s!\n", where
);
146 if (acx_debug
& L_LOCK
) {
149 diff
-= adev
->lock_time
;
150 if (diff
> max_lock_time
) {
151 where
= sanitize_str(where
);
152 printk("max lock hold time %ld CPU ticks from %s "
153 "to %s\n", diff
, adev
->last_lock
, where
);
154 max_lock_time
= diff
;
158 #endif /* PARANOID_LOCKING */
161 /***********************************************************************
165 static int acx_debug_func_indent
;
167 #define FUNC_INDENT_INCREMENT 2
170 #define TIMESTAMP(d) unsigned long d; rdtscl(d)
172 #define TIMESTAMP(d) unsigned long d = jiffies
175 static const char spaces
[] = " " " "; /* Nx10 spaces */
177 void log_fn_enter(const char *funcname
)
182 indent
= acx_debug_func_indent
;
183 if (indent
>= sizeof(spaces
))
184 indent
= sizeof(spaces
) - 1;
186 printk("%08ld %s==> %s\n",
187 d
% 100000000, spaces
+ (sizeof(spaces
) - 1) - indent
, funcname
);
189 acx_debug_func_indent
+= FUNC_INDENT_INCREMENT
;
191 void log_fn_exit(const char *funcname
)
196 acx_debug_func_indent
-= FUNC_INDENT_INCREMENT
;
198 indent
= acx_debug_func_indent
;
199 if (indent
>= sizeof(spaces
))
200 indent
= sizeof(spaces
) - 1;
202 printk("%08ld %s<== %s\n",
203 d
% 100000000, spaces
+ (sizeof(spaces
) - 1) - indent
, funcname
);
205 void log_fn_exit_v(const char *funcname
, int v
)
210 acx_debug_func_indent
-= FUNC_INDENT_INCREMENT
;
212 indent
= acx_debug_func_indent
;
213 if (indent
>= sizeof(spaces
))
214 indent
= sizeof(spaces
) - 1;
216 printk("%08ld %s<== %s: %08X\n",
218 spaces
+ (sizeof(spaces
) - 1) - indent
, funcname
, v
);
220 #endif /* ACX_DEBUG > 1 */
223 /***********************************************************************
224 ** Basically a mdelay/msleep with logging
226 void acx_s_mwait(int ms
)
238 /***********************************************************************
239 ** Not inlined: it's larger than it seems
241 void acx_print_mac(const char *head
, const u8
* mac
, const char *tail
)
243 printk("%s" MACSTR
"%s", head
, MAC(mac
), tail
);
249 /***********************************************************************
250 ** acx_cmd_status_str
252 const char *acx_cmd_status_str(unsigned int state
)
254 static const char *const cmd_error_strings
[] = {
258 "Invalid Information Element",
260 "Channel invalid in current regulatory domain",
262 "Command rejected (read-only information element)",
273 return state
< ARRAY_SIZE(cmd_error_strings
) ?
274 cmd_error_strings
[state
] : "?";
277 /***********************************************************************
280 void acx_dump_bytes(const void *data
, int num
)
282 const u8
*ptr
= (const u8
*)data
;
292 printk("%02X %02X %02X %02X %02X %02X %02X %02X "
293 "%02X %02X %02X %02X %02X %02X %02X %02X\n",
294 ptr
[0], ptr
[1], ptr
[2], ptr
[3],
295 ptr
[4], ptr
[5], ptr
[6], ptr
[7],
296 ptr
[8], ptr
[9], ptr
[10], ptr
[11],
297 ptr
[12], ptr
[13], ptr
[14], ptr
[15]);
303 printk("%02X \n", *ptr
++);
304 printk("%02X\n", *ptr
);
313 /***********************************************************************
314 ** acx_s_get_firmware_version
318 void acx_s_get_firmware_version(acx_device_t
* adev
)
321 u8 hexarr
[4] = { 0, 0, 0, 0 };
322 int hexidx
= 0, val
= 0;
328 memset(fw
.fw_id
, 'E', FW_ID_SIZE
);
329 acx_s_interrogate(adev
, &fw
, ACX1xx_IE_FWREV
);
330 memcpy(adev
->firmware_version
, fw
.fw_id
, FW_ID_SIZE
);
331 adev
->firmware_version
[FW_ID_SIZE
] = '\0';
333 log(L_DEBUG
, "fw_ver: fw_id='%s' hw_id=%08X\n",
334 adev
->firmware_version
, fw
.hw_id
);
336 if (strncmp(fw
.fw_id
, "Rev ", 4) != 0) {
337 printk("acx: strange firmware version string "
338 "'%s', please report\n", adev
->firmware_version
);
339 adev
->firmware_numver
= 0x01090407; /* assume 1.9.4.7 */
344 if ((c
== '.') || (c
== '\0')) {
345 hexarr
[hexidx
++] = val
;
346 if ((hexidx
> 3) || (c
== '\0')) /* end? */
351 if ((c
>= '0') && (c
<= '9'))
354 c
= c
- 'a' + (char)10;
358 adev
->firmware_numver
= (u32
) ((hexarr
[0] << 24) |
360 | (hexarr
[2] << 8) | hexarr
[3]);
361 log(L_DEBUG
, "firmware_numver 0x%08X\n", adev
->firmware_numver
);
363 if (IS_ACX111(adev
)) {
364 if (adev
->firmware_numver
== 0x00010011) {
365 /* This one does not survive floodpinging */
366 printk("acx: firmware '%s' is known to be buggy, "
367 "please upgrade\n", adev
->firmware_version
);
371 adev
->firmware_id
= le32_to_cpu(fw
.hw_id
);
373 /* we're able to find out more detailed chip names now */
374 switch (adev
->firmware_id
& 0xffff0000) {
377 adev
->chip_name
= "TNETW1100A";
380 adev
->chip_name
= "TNETW1100B";
384 adev
->chip_name
= "TNETW1130";
386 case 0x04030000: /* 0x04030101 is TNETW1450 */
387 adev
->chip_name
= "TNETW1450";
390 printk("acx: unknown chip ID 0x%08X, "
391 "please report\n", adev
->firmware_id
);
399 /***********************************************************************
400 ** acx_display_hardware_details
402 ** Displays hw/fw version, radio type etc...
406 void acx_display_hardware_details(acx_device_t
* adev
)
408 const char *radio_str
, *form_str
;
412 switch (adev
->radio_type
) {
419 case RADIO_RALINK_15
:
420 radio_str
= "Ralink";
425 case RADIO_UNKNOWN_17
:
426 /* TI seems to have a radio which is
427 * additionally 802.11a capable, too */
428 radio_str
= "802.11a/b/g radio?! Please report";
430 case RADIO_UNKNOWN_19
:
431 radio_str
= "A radio used by Safecom cards?! Please report";
433 case RADIO_UNKNOWN_1B
:
434 radio_str
= "An unknown radio used by TNETW1450 USB adapters";
437 radio_str
= "UNKNOWN, please report radio type name!";
441 switch (adev
->form_factor
) {
443 form_str
= "unspecified";
446 form_str
= "(mini-)PCI / CardBus";
452 form_str
= "Compact Flash";
455 form_str
= "UNKNOWN, please report";
459 printk("acx: chipset %s, radio type 0x%02X (%s), "
460 "form factor 0x%02X (%s), EEPROM version 0x%02X, "
461 "uploaded firmware '%s'\n",
462 adev
->chip_name
, adev
->radio_type
, radio_str
,
463 adev
->form_factor
, form_str
, adev
->eeprom_version
,
464 adev
->firmware_version
);
470 /***********************************************************************
471 ** acx_e_get_stats, acx_e_get_wireless_stats
474 acx_e_get_stats(struct ieee80211_hw
*hw
,
475 struct ieee80211_low_level_stats
*stats
)
477 acx_device_t
*adev
= ieee2adev(hw
);
479 acx_lock(adev
, flags
);
480 memcpy(stats
, &adev
->ieee_stats
, sizeof(*stats
));
481 acx_unlock(adev
, flags
);
486 /***********************************************************************
487 ** maps acx111 tx descr rate field to acx100 one
489 const u8 acx_bitpos2rate100
[] = {
493 RATE100_2
, /* 3, should not happen */
494 RATE100_2
, /* 4, should not happen */
496 RATE100_2
, /* 6, should not happen */
497 RATE100_2
, /* 7, should not happen */
499 RATE100_2
, /* 9, should not happen */
500 RATE100_2
, /* 10, should not happen */
501 RATE100_2
, /* 11, should not happen */
502 RATE100_2
, /* 12, should not happen */
503 RATE100_2
, /* 13, should not happen */
504 RATE100_2
, /* 14, should not happen */
505 RATE100_2
, /* 15, should not happen */
508 u8
acx_rate111to100(u16 r
)
510 return acx_bitpos2rate100
[highest_bit(r
)];
514 /***********************************************************************
515 ** Calculate level like the feb 2003 windows driver seems to do
517 static u8
acx_signal_to_winlevel(u8 rawlevel
)
519 /* u8 winlevel = (u8) (0.5 + 0.625 * rawlevel); */
520 u8 winlevel
= ((4 + (rawlevel
* 5)) / 8);
527 u8
acx_signal_determine_quality(u8 signal
, u8 noise
)
531 qual
= (((signal
- 30) * 100 / 70) + (100 - noise
* 4)) / 2;
541 /***********************************************************************
542 ** Interrogate/configure commands
545 /* FIXME: the lengths given here probably aren't always correct.
546 * They should be gradually replaced by proper "sizeof(acx1XX_ie_XXXX)-4",
547 * unless the firmware actually expects a different length than the struct length */
548 static const u16 acx100_ie_len
[] = {
550 ACX100_IE_ACX_TIMER_LEN
,
551 sizeof(acx100_ie_powersave_t
) - 4, /* is that 6 or 8??? */
552 ACX1xx_IE_QUEUE_CONFIG_LEN
,
553 ACX100_IE_BLOCK_SIZE_LEN
,
554 ACX1xx_IE_MEMORY_CONFIG_OPTIONS_LEN
,
555 ACX1xx_IE_RATE_FALLBACK_LEN
,
556 ACX100_IE_WEP_OPTIONS_LEN
,
557 ACX1xx_IE_MEMORY_MAP_LEN
, /* ACX1xx_IE_SSID_LEN, */
559 ACX1xx_IE_ASSOC_ID_LEN
,
561 ACX111_IE_CONFIG_OPTIONS_LEN
,
563 ACX1xx_IE_FCS_ERROR_COUNT_LEN
,
564 ACX1xx_IE_MEDIUM_USAGE_LEN
,
565 ACX1xx_IE_RXCONFIG_LEN
,
568 sizeof(fw_stats_t
) - 4,
570 ACX1xx_IE_FEATURE_CONFIG_LEN
,
571 ACX111_IE_KEY_CHOOSE_LEN
,
572 ACX1FF_IE_MISC_CONFIG_TABLE_LEN
,
573 ACX1FF_IE_WONE_CONFIG_LEN
,
575 ACX1FF_IE_TID_CONFIG_LEN
,
579 ACX1FF_IE_CALIB_ASSESSMENT_LEN
,
580 ACX1FF_IE_BEACON_FILTER_OPTIONS_LEN
,
581 ACX1FF_IE_LOW_RSSI_THRESH_OPT_LEN
,
582 ACX1FF_IE_NOISE_HISTOGRAM_RESULTS_LEN
,
584 ACX1FF_IE_PACKET_DETECT_THRESH_LEN
,
585 ACX1FF_IE_TX_CONFIG_OPTIONS_LEN
,
586 ACX1FF_IE_CCA_THRESHOLD_LEN
,
587 ACX1FF_IE_EVENT_MASK_LEN
,
588 ACX1FF_IE_DTIM_PERIOD_LEN
,
590 ACX1FF_IE_ACI_CONFIG_SET_LEN
,
597 ACX1FF_IE_EEPROM_VER_LEN
,
600 static const u16 acx100_ie_len_dot11
[] = {
602 ACX1xx_IE_DOT11_STATION_ID_LEN
,
604 ACX100_IE_DOT11_BEACON_PERIOD_LEN
,
605 ACX1xx_IE_DOT11_DTIM_PERIOD_LEN
,
606 ACX1xx_IE_DOT11_SHORT_RETRY_LIMIT_LEN
,
607 ACX1xx_IE_DOT11_LONG_RETRY_LIMIT_LEN
,
608 ACX100_IE_DOT11_WEP_DEFAULT_KEY_WRITE_LEN
,
609 ACX1xx_IE_DOT11_MAX_XMIT_MSDU_LIFETIME_LEN
,
611 ACX1xx_IE_DOT11_CURRENT_REG_DOMAIN_LEN
,
612 ACX1xx_IE_DOT11_CURRENT_ANTENNA_LEN
,
614 ACX1xx_IE_DOT11_TX_POWER_LEVEL_LEN
,
615 ACX1xx_IE_DOT11_CURRENT_CCA_MODE_LEN
,
616 ACX100_IE_DOT11_ED_THRESHOLD_LEN
,
617 ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET_LEN
,
623 static const u16 acx111_ie_len
[] = {
625 ACX100_IE_ACX_TIMER_LEN
,
626 sizeof(acx111_ie_powersave_t
) - 4,
627 ACX1xx_IE_QUEUE_CONFIG_LEN
,
628 ACX100_IE_BLOCK_SIZE_LEN
,
629 ACX1xx_IE_MEMORY_CONFIG_OPTIONS_LEN
,
630 ACX1xx_IE_RATE_FALLBACK_LEN
,
631 ACX100_IE_WEP_OPTIONS_LEN
,
632 ACX1xx_IE_MEMORY_MAP_LEN
, /* ACX1xx_IE_SSID_LEN, */
634 ACX1xx_IE_ASSOC_ID_LEN
,
636 ACX111_IE_CONFIG_OPTIONS_LEN
,
638 ACX1xx_IE_FCS_ERROR_COUNT_LEN
,
639 ACX1xx_IE_MEDIUM_USAGE_LEN
,
640 ACX1xx_IE_RXCONFIG_LEN
,
643 sizeof(fw_stats_t
) - 4,
645 ACX1xx_IE_FEATURE_CONFIG_LEN
,
646 ACX111_IE_KEY_CHOOSE_LEN
,
647 ACX1FF_IE_MISC_CONFIG_TABLE_LEN
,
648 ACX1FF_IE_WONE_CONFIG_LEN
,
650 ACX1FF_IE_TID_CONFIG_LEN
,
654 ACX1FF_IE_CALIB_ASSESSMENT_LEN
,
655 ACX1FF_IE_BEACON_FILTER_OPTIONS_LEN
,
656 ACX1FF_IE_LOW_RSSI_THRESH_OPT_LEN
,
657 ACX1FF_IE_NOISE_HISTOGRAM_RESULTS_LEN
,
659 ACX1FF_IE_PACKET_DETECT_THRESH_LEN
,
660 ACX1FF_IE_TX_CONFIG_OPTIONS_LEN
,
661 ACX1FF_IE_CCA_THRESHOLD_LEN
,
662 ACX1FF_IE_EVENT_MASK_LEN
,
663 ACX1FF_IE_DTIM_PERIOD_LEN
,
665 ACX1FF_IE_ACI_CONFIG_SET_LEN
,
672 ACX1FF_IE_EEPROM_VER_LEN
,
675 static const u16 acx111_ie_len_dot11
[] = {
677 ACX1xx_IE_DOT11_STATION_ID_LEN
,
679 ACX100_IE_DOT11_BEACON_PERIOD_LEN
,
680 ACX1xx_IE_DOT11_DTIM_PERIOD_LEN
,
681 ACX1xx_IE_DOT11_SHORT_RETRY_LIMIT_LEN
,
682 ACX1xx_IE_DOT11_LONG_RETRY_LIMIT_LEN
,
683 ACX100_IE_DOT11_WEP_DEFAULT_KEY_WRITE_LEN
,
684 ACX1xx_IE_DOT11_MAX_XMIT_MSDU_LIFETIME_LEN
,
686 ACX1xx_IE_DOT11_CURRENT_REG_DOMAIN_LEN
,
687 ACX1xx_IE_DOT11_CURRENT_ANTENNA_LEN
,
689 ACX1xx_IE_DOT11_TX_POWER_LEVEL_LEN
,
690 ACX1xx_IE_DOT11_CURRENT_CCA_MODE_LEN
,
691 ACX100_IE_DOT11_ED_THRESHOLD_LEN
,
692 ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET_LEN
,
700 #define FUNC "configure"
702 int acx_s_configure(acx_device_t
* adev
, void *pdr
, int type
)
706 acx_s_configure_debug(acx_device_t
* adev
, void *pdr
, int type
,
714 len
= adev
->ie_len
[type
];
716 len
= adev
->ie_len_dot11
[type
- 0x1000];
718 log(L_CTL
, FUNC
"(type:%s,len:%u)\n", typestr
, len
);
719 if (unlikely(!len
)) {
720 log(L_DEBUG
, "zero-length type %s?!\n", typestr
);
723 ((acx_ie_generic_t
*) pdr
)->type
= cpu_to_le16(type
);
724 ((acx_ie_generic_t
*) pdr
)->len
= cpu_to_le16(len
);
725 res
= acx_s_issue_cmd(adev
, ACX1xx_CMD_CONFIGURE
, pdr
, len
+ 4);
726 if (unlikely(OK
!= res
)) {
728 printk("%s: " FUNC
"(type:%s) FAILED\n", wiphy_name(adev
->ieee
->wiphy
),
731 printk("%s: " FUNC
"(type:0x%X) FAILED\n", wiphy_name(adev
->ieee
->wiphy
),
734 /* dump_stack() is already done in issue_cmd() */
740 #define FUNC "interrogate"
742 int acx_s_interrogate(acx_device_t
* adev
, void *pdr
, int type
)
746 acx_s_interrogate_debug(acx_device_t
* adev
, void *pdr
, int type
,
755 /* FIXME: no check whether this exceeds the array yet.
756 * We should probably remember the number of entries... */
758 len
= adev
->ie_len
[type
];
760 len
= adev
->ie_len_dot11
[type
- 0x1000];
762 log(L_CTL
, FUNC
"(type:%s,len:%u)\n", typestr
, len
);
764 ((acx_ie_generic_t
*) pdr
)->type
= cpu_to_le16(type
);
765 ((acx_ie_generic_t
*) pdr
)->len
= cpu_to_le16(len
);
766 res
= acx_s_issue_cmd(adev
, ACX1xx_CMD_INTERROGATE
, pdr
, len
+ 4);
767 if (unlikely(OK
!= res
)) {
769 printk("%s: " FUNC
"(type:%s) FAILED\n", wiphy_name(adev
->ieee
->wiphy
),
772 printk("%s: " FUNC
"(type:0x%X) FAILED\n", wiphy_name(adev
->ieee
->wiphy
),
775 /* dump_stack() is already done in issue_cmd() */
783 void great_inquisitor(acx_device_t
* adev
)
788 /* 0x200 was too large here: */
795 /* 0..0x20, 0x1000..0x1020 */
796 for (type
= 0; type
<= 0x1020; type
++) {
799 ie
.type
= cpu_to_le16(type
);
800 ie
.len
= cpu_to_le16(sizeof(ie
) - 4);
801 acx_s_issue_cmd(adev
, ACX1xx_CMD_INTERROGATE
, &ie
, sizeof(ie
));
808 #ifdef CONFIG_PROC_FS
809 /***********************************************************************
812 /***********************************************************************
814 ** Generate content for our /proc entry
817 ** buf is a pointer to write output to
818 ** adev is the usual pointer to our private struct acx_device
820 ** number of bytes actually written to buf
824 static int acx_l_proc_output(char *buf
, acx_device_t
* adev
)
831 "acx driver version:\t\t" ACX_RELEASE
"\n"
832 "Wireless extension version:\t" STRING(WIRELESS_EXT
) "\n"
833 "chip name:\t\t\t%s (0x%08X)\n"
834 "radio type:\t\t\t0x%02X\n"
835 "form factor:\t\t\t0x%02X\n"
836 "EEPROM version:\t\t\t0x%02X\n"
837 "firmware version:\t\t%s (0x%08X)\n",
838 adev
->chip_name
, adev
->firmware_id
,
841 adev
->eeprom_version
,
842 adev
->firmware_version
, adev
->firmware_numver
);
849 /***********************************************************************
851 static int acx_s_proc_diag_output(char *buf
, acx_device_t
* adev
)
855 unsigned int len
= 0, partlen
;
861 fw_stats_t
*fw_stats
;
862 char *part_str
= NULL
;
863 fw_stats_tx_t
*tx
= NULL
;
864 fw_stats_rx_t
*rx
= NULL
;
865 fw_stats_dma_t
*dma
= NULL
;
866 fw_stats_irq_t
*irq
= NULL
;
867 fw_stats_wep_t
*wep
= NULL
;
868 fw_stats_pwr_t
*pwr
= NULL
;
869 fw_stats_mic_t
*mic
= NULL
;
870 fw_stats_aes_t
*aes
= NULL
;
871 fw_stats_event_t
*evt
= NULL
;
875 acx_lock(adev
, flags
);
878 p
= acxpci_s_proc_diag_output(p
, adev
);
882 "** network status **\n"
883 "dev_state_mask 0x%04X\n"
884 "mode %u, channel %u, "
885 "reg_dom_id 0x%02X, reg_dom_chanmask 0x%04X, ",
886 adev
->dev_state_mask
,
887 adev
->mode
, adev
->channel
,
888 adev
->reg_dom_id
, adev
->reg_dom_chanmask
);
890 "ESSID \"%s\", essid_active %d, essid_len %d, "
891 "essid_for_assoc \"%s\", nick \"%s\"\n"
892 "WEP ena %d, restricted %d, idx %d\n",
893 adev
->essid
, adev
->essid_active
, (int)adev
->essid_len
,
894 adev
->essid_for_assoc
, adev
->nick
,
895 adev
->wep_enabled
, adev
->wep_restricted
,
896 adev
->wep_current_index
);
897 p
+= sprintf(p
, "dev_addr " MACSTR
"\n", MAC(adev
->dev_addr
));
898 p
+= sprintf(p
, "bssid " MACSTR
"\n", MAC(adev
->bssid
));
899 p
+= sprintf(p
, "ap_filter " MACSTR
"\n", MAC(adev
->ap
));
901 p
+= sprintf(p
, "\n" "** PHY status **\n"
902 "tx_disabled %d, tx_level_dbm %d\n" /* "tx_level_val %d, tx_level_auto %d\n" */
903 "sensitivity %d, antenna 0x%02X, ed_threshold %d, cca %d, preamble_mode %d\n"
904 "rate_basic 0x%04X, rate_oper 0x%04X\n"
905 "rts_threshold %d, frag_threshold %d, short_retry %d, long_retry %d\n"
906 "msdu_lifetime %d, listen_interval %d, beacon_interval %d\n",
907 adev
->tx_disabled
, adev
->tx_level_dbm
, /* adev->tx_level_val, adev->tx_level_auto, */
908 adev
->sensitivity
, adev
->antenna
, adev
->ed_threshold
,
909 adev
->cca
, adev
->preamble_mode
, adev
->rate_basic
, adev
->rate_oper
, adev
->rts_threshold
,
910 adev
->frag_threshold
, adev
->short_retry
, adev
->long_retry
,
911 adev
->msdu_lifetime
, adev
->listen_interval
,
912 adev
->beacon_interval
);
914 acx_unlock(adev
, flags
);
919 "NOTE: version dependent statistics layout, "
920 "please report if you suspect wrong parsing!\n"
921 "\n" "version \"%s\"\n", adev
->firmware_version
);
923 /* TODO: may replace kmalloc/memset with kzalloc once
924 * Linux 2.6.14 is widespread */
925 fw_stats
= kmalloc(sizeof(*fw_stats
), GFP_KERNEL
);
930 memset(fw_stats
, 0, sizeof(*fw_stats
));
932 st
= (u8
*) fw_stats
;
934 part_str
= "statistics query command";
936 if (OK
!= acx_s_interrogate(adev
, st
, ACX1xx_IE_FIRMWARE_STATISTICS
))
942 if (len
> sizeof(*fw_stats
)) {
944 "firmware version with bigger fw_stats struct detected\n"
945 "(%u vs. %u), please report\n", len
,
947 if (len
> sizeof(*fw_stats
)) {
948 p
+= sprintf(p
, "struct size exceeded allocation!\n");
949 len
= sizeof(*fw_stats
);
953 st_end
= st
- 2 * sizeof(u16
) + len
;
956 /* let's make one bold assumption here:
957 * (hopefully!) *all* statistics fields are u32 only,
958 * thus if we need to make endianness corrections
959 * we can simply do them in one go, in advance */
960 st2
= (u8
*) fw_stats
;
961 for (temp1
= 0; temp1
< len
; temp1
+= 4, st2
+= 4)
962 *(u32
*) st2
= le32_to_cpu(*(u32
*) st2
);
967 /* directly at end of a struct part? --> no error! */
971 tx
= (fw_stats_tx_t
*) st
;
972 st
+= sizeof(fw_stats_tx_t
);
973 rx
= (fw_stats_rx_t
*) st
;
974 st
+= sizeof(fw_stats_rx_t
);
975 partlen
= sizeof(fw_stats_tx_t
) + sizeof(fw_stats_rx_t
);
977 if (IS_ACX100(adev
)) {
978 /* at least ACX100 PCI F/W 1.9.8.b
979 * and ACX100 USB F/W 1.0.7-USB
980 * don't have those two fields... */
981 st
-= 2 * sizeof(u32
);
983 /* our parsing doesn't quite match this firmware yet,
987 temp1
= temp2
= 999999999;
991 temp1
= rx
->rx_aci_events
;
992 temp2
= rx
->rx_aci_resets
;
997 " tx_desc_overfl %u\n"
998 " rx_OutOfMem %u, rx_hdr_overfl %u, rx_hw_stuck %u\n"
999 " rx_dropped_frame %u, rx_frame_ptr_err %u, rx_xfr_hint_trig %u\n"
1000 " rx_aci_events %u, rx_aci_resets %u\n",
1006 rx
->rx_dropped_frame
,
1007 rx
->rx_frame_ptr_err
, rx
->rx_xfr_hint_trig
, temp1
, temp2
);
1014 dma
= (fw_stats_dma_t
*) st
;
1015 partlen
= sizeof(fw_stats_dma_t
);
1023 " rx_dma_req %u, rx_dma_err %u, tx_dma_req %u, tx_dma_err %u\n",
1026 dma
->rx_dma_err
, dma
->tx_dma_req
, dma
->tx_dma_err
);
1033 irq
= (fw_stats_irq_t
*) st
;
1034 partlen
= sizeof(fw_stats_irq_t
);
1042 " cmd_cplt %u, fiq %u\n"
1043 " rx_hdrs %u, rx_cmplt %u, rx_mem_overfl %u, rx_rdys %u\n"
1044 " irqs %u, tx_procs %u, decrypt_done %u\n"
1045 " dma_0_done %u, dma_1_done %u, tx_exch_complet %u\n"
1046 " commands %u, rx_procs %u, hw_pm_mode_changes %u\n"
1047 " host_acks %u, pci_pm %u, acm_wakeups %u\n",
1060 irq
->tx_exch_complet
,
1063 irq
->hw_pm_mode_changes
,
1064 irq
->host_acks
, irq
->pci_pm
, irq
->acm_wakeups
);
1071 wep
= (fw_stats_wep_t
*) st
;
1072 partlen
= sizeof(fw_stats_wep_t
);
1075 if ((IS_PCI(adev
) && IS_ACX100(adev
))
1076 || (IS_USB(adev
) && IS_ACX100(adev
))
1078 /* at least ACX100 PCI F/W 1.9.8.b
1079 * and ACX100 USB F/W 1.0.7-USB
1080 * don't have those two fields... */
1081 st
-= 2 * sizeof(u32
);
1084 temp1
= temp2
= 999999999;
1088 temp1
= wep
->wep_pkt_decrypt
;
1089 temp2
= wep
->wep_decrypt_irqs
;
1094 " wep_key_count %u, wep_default_key_count %u, dot11_def_key_mib %u\n"
1095 " wep_key_not_found %u, wep_decrypt_fail %u\n"
1096 " wep_pkt_decrypt %u, wep_decrypt_irqs %u\n",
1099 wep
->wep_default_key_count
,
1100 wep
->dot11_def_key_mib
,
1101 wep
->wep_key_not_found
,
1102 wep
->wep_decrypt_fail
, temp1
, temp2
);
1109 pwr
= (fw_stats_pwr_t
*) st
;
1110 partlen
= sizeof(fw_stats_pwr_t
);
1118 " tx_start_ctr %u, no_ps_tx_too_short %u\n"
1119 " rx_start_ctr %u, no_ps_rx_too_short %u\n"
1120 " lppd_started %u\n"
1121 " no_lppd_too_noisy %u, no_lppd_too_short %u, no_lppd_matching_frame %u\n",
1124 pwr
->no_ps_tx_too_short
,
1126 pwr
->no_ps_rx_too_short
,
1128 pwr
->no_lppd_too_noisy
,
1129 pwr
->no_lppd_too_short
, pwr
->no_lppd_matching_frame
);
1136 mic
= (fw_stats_mic_t
*) st
;
1137 partlen
= sizeof(fw_stats_mic_t
);
1145 " mic_rx_pkts %u, mic_calc_fail %u\n",
1146 part_str
, mic
->mic_rx_pkts
, mic
->mic_calc_fail
);
1153 aes
= (fw_stats_aes_t
*) st
;
1154 partlen
= sizeof(fw_stats_aes_t
);
1162 " aes_enc_fail %u, aes_dec_fail %u\n"
1163 " aes_enc_pkts %u, aes_dec_pkts %u\n"
1164 " aes_enc_irq %u, aes_dec_irq %u\n",
1169 aes
->aes_dec_pkts
, aes
->aes_enc_irq
, aes
->aes_dec_irq
);
1176 evt
= (fw_stats_event_t
*) st
;
1177 partlen
= sizeof(fw_stats_event_t
);
1185 " heartbeat %u, calibration %u\n"
1186 " rx_mismatch %u, rx_mem_empty %u, rx_pool %u\n"
1188 " phy_tx_err %u, tx_stuck %u\n",
1195 evt
->oom_late
, evt
->phy_tx_err
, evt
->tx_stuck
);
1198 goto fw_stats_bigger
;
1205 "failed at %s part (size %u), offset %u (struct size %u), "
1206 "please report\n", part_str
, partlen
,
1207 (int)((void *)st
- (void *)fw_stats
), len
);
1210 for (; st
< st_end
; st
+= 4)
1213 (int)((void *)st
- (void *)fw_stats
), *(u32
*) st
);
1223 /***********************************************************************
1225 static int acx_s_proc_phy_output(char *buf
, acx_device_t
* adev
)
1233 if (RADIO_RFMD_11 != adev->radio_type) {
1234 printk("sorry, not yet adapted for radio types "
1235 "other than RFMD, please verify "
1236 "PHY size etc. first!\n");
1241 /* The PHY area is only 0x80 bytes long; further pages after that
1242 * only have some page number registers with altered value,
1243 * all other registers remain the same. */
1244 for (i
= 0; i
< 0x80; i
++) {
1245 acx_s_read_phy_reg(adev
, i
, p
++);
1253 /***********************************************************************
1254 ** acx_e_read_proc_XXXX
1255 ** Handle our /proc entry
1258 ** standard kernel read_proc interface
1260 ** number of bytes written to buf
1265 acx_e_read_proc(char *buf
, char **start
, off_t offset
, int count
,
1266 int *eof
, void *data
)
1268 acx_device_t
*adev
= (acx_device_t
*) data
;
1269 unsigned long flags
;
1275 acx_lock(adev
, flags
);
1277 length
= acx_l_proc_output(buf
, adev
);
1278 acx_unlock(adev
, flags
);
1279 acx_sem_unlock(adev
);
1282 if (length
<= offset
+ count
)
1284 *start
= buf
+ offset
;
1295 acx_e_read_proc_diag(char *buf
, char **start
, off_t offset
, int count
,
1296 int *eof
, void *data
)
1298 acx_device_t
*adev
= (acx_device_t
*) data
;
1305 length
= acx_s_proc_diag_output(buf
, adev
);
1306 acx_sem_unlock(adev
);
1309 if (length
<= offset
+ count
)
1311 *start
= buf
+ offset
;
1322 acx_e_read_proc_eeprom(char *buf
, char **start
, off_t offset
, int count
,
1323 int *eof
, void *data
)
1325 acx_device_t
*adev
= (acx_device_t
*) data
;
1334 length
= acxpci_proc_eeprom_output(buf
, adev
);
1335 acx_sem_unlock(adev
);
1339 if (length
<= offset
+ count
)
1341 *start
= buf
+ offset
;
1352 acx_e_read_proc_phy(char *buf
, char **start
, off_t offset
, int count
,
1353 int *eof
, void *data
)
1355 acx_device_t
*adev
= (acx_device_t
*) data
;
1362 length
= acx_s_proc_phy_output(buf
, adev
);
1363 acx_sem_unlock(adev
);
1366 if (length
<= offset
+ count
)
1368 *start
= buf
+ offset
;
1379 /***********************************************************************
1380 ** /proc files registration
1382 static const char *const
1383 proc_files
[] = { "", "_diag", "_eeprom", "_phy" };
1385 static read_proc_t
*const
1388 acx_e_read_proc_diag
,
1389 acx_e_read_proc_eeprom
,
1393 static int manage_proc_entries(struct ieee80211_hw
*hw
, int remove
)
1395 acx_device_t
*adev
= ieee2adev(hw
);
1401 for (i
= 0; i
< ARRAY_SIZE(proc_files
); i
++) {
1402 snprintf(procbuf
, sizeof(procbuf
),
1403 "driver/acx%s", proc_files
[i
]);
1404 log(L_INIT
, "%sing /proc entry %s\n",
1405 remove
? "remov" : "creat", procbuf
);
1407 if (!create_proc_read_entry
1408 (procbuf
, 0, NULL
, proc_funcs
[i
], adev
)) {
1409 printk("acx: cannot register /proc entry %s\n",
1415 remove_proc_entry(procbuf
, NULL
);
1422 int acx_proc_register_entries(struct ieee80211_hw
*ieee
)
1424 return manage_proc_entries(ieee
, 0);
1427 int acx_proc_unregister_entries(struct ieee80211_hw
*ieee
)
1429 return manage_proc_entries(ieee
, 1);
1431 #endif /* CONFIG_PROC_FS */
1434 ** Gathered From rt2x00 and bcm43xx_mac80211 projects
1436 void acx_free_modes(acx_device_t
* adev
)
1439 // kfree(adev->modes);
1440 // adev->modes = NULL;
1444 #define RATETAB_ENT(_rate, _rateid, _flags) \
1448 .val2 = (_rateid), \
1449 .flags = (_flags), \
1453 static struct ieee80211_rate __acx_rates
[] = {
1456 .flags
= IEEE80211_RATE_CCK
},
1459 .flags
= IEEE80211_RATE_CCK
},
1462 .flags
= IEEE80211_RATE_CCK
},
1465 .flags
= IEEE80211_RATE_CCK
},
1468 .flags
= IEEE80211_RATE_OFDM
},
1471 .flags
= IEEE80211_RATE_OFDM
},
1474 .flags
= IEEE80211_RATE_OFDM
},
1477 .flags
= IEEE80211_RATE_OFDM
},
1480 .flags
= IEEE80211_RATE_OFDM
},
1483 .flags
= IEEE80211_RATE_OFDM
},
1486 .flags
= IEEE80211_RATE_OFDM
},
1489 .flags
= IEEE80211_RATE_OFDM
},
1492 #define acx_b_ratetable (__acx_rates + 0)
1493 #define acx_g_ratetable (__acx_rates + 0)
1496 #define CHANTAB_ENT(_chanid, _freq) \
1498 .chan = (_chanid), \
1501 .flag = IEEE80211_CHAN_W_SCAN | \
1502 IEEE80211_CHAN_W_ACTIVE_SCAN | \
1503 IEEE80211_CHAN_W_IBSS, \
1504 .power_level = 0xf, \
1505 .antenna_max = 0xFF, \
1508 static struct ieee80211_channel channels
[] = {
1538 static int acx_setup_modes_bphy(acx_device_t * adev)
1541 struct ieee80211_hw *hw = adev->ieee;
1542 struct ieee80211_hw_mode *mode;
1546 mode = &adev->modes[0];
1547 mode->mode = MODE_IEEE80211B;
1548 mode->num_channels = acx_chantable_size;
1549 mode->channels = channels;
1550 mode->num_rates = acx_b_ratetable_size;
1551 mode->rates = acx_b_ratetable;
1552 err = ieee80211_register_hwmode(hw,mode);
1558 static int acx_setup_modes_gphy(acx_device_t * adev)
1561 struct ieee80211_hw *hw = adev->ieee;
1562 struct ieee80211_hw_mode *mode;
1566 mode = &adev->modes[1];
1567 mode->mode = MODE_IEEE80211G;
1568 mode->num_channels = acx_chantable_size;
1569 mode->channels = channels;
1570 mode->num_rates = acx_g_ratetable_size;
1571 mode->rates = acx_g_ratetable;
1572 err = ieee80211_register_hwmode(hw,mode);
1579 int acx_setup_modes(acx_device_t
* adev
)
1581 struct ieee80211_hw
*hw
= adev
->ieee
;
1582 struct ieee80211_hw_mode
*mode
;
1587 if (IS_ACX111(adev
)) {
1589 adev->modes = kzalloc(sizeof(struct ieee80211_hw_mode) * 2, GFP_KERNEL);
1590 err = acx_setup_modes_gphy(adev);
1592 mode
= &adev
->modes
[0];
1594 /* from the zd1211rw driver: - do we need to do the same? */
1596 memcpy(mode->channels, channels, sizeof(channels));
1597 memcpy(mode->rates, __acx_rates, sizeof(__acx_rates));
1600 mode
->mode
= MODE_IEEE80211G
;
1601 mode
->num_channels
= ARRAY_SIZE(channels
);
1602 mode
->num_rates
= 12;
1603 mode
->rates
= acx_g_ratetable
;
1606 adev->modes = kzalloc(sizeof(struct ieee80211_hw_mode), GFP_KERNEL);
1607 err = acx_setup_modes_bphy(adev);
1609 mode
= &adev
->modes
[1];
1611 /* from the zd1211rw driver: - do we need to do the same? */
1613 memcpy(mode->channels, channels, sizeof(channels));
1614 memcpy(mode->rates, __acx_rates, sizeof(__acx_rates));
1617 mode
->mode
= MODE_IEEE80211B
;
1618 mode
->num_channels
= ARRAY_SIZE(channels
);
1619 mode
->num_rates
= 4;
1620 mode
->rates
= acx_b_ratetable
;
1623 /* if (err && adev->modes)
1624 kfree(adev->modes);*/
1626 mode
->channels
= channels
;
1627 err
= ieee80211_register_hwmode(hw
,mode
);
1634 /***********************************************************************
1635 ** acx_fill_beacon_or_proberesp_template
1637 ** Origin: derived from rt2x00 project
1640 acx_fill_beacon_or_proberesp_template(acx_device_t
*adev
,
1641 struct acx_template_beacon
*templ
,
1642 struct sk_buff
* skb
/* in host order! */)
1646 memcpy(templ
,skb
->data
, skb
->len
);
1651 /***********************************************************************
1652 ** acx_s_set_beacon_template
1657 acx_s_set_beacon_template(acx_device_t
*adev
, struct sk_buff
*skb
)
1659 struct acx_template_beacon bcn
;
1663 printk("Size of template: %08X, Size of beacon: %08X\n",sizeof(struct acx_template_beacon
),skb
->len
);
1664 len
= acx_fill_beacon_or_proberesp_template(adev
, &bcn
, skb
);
1665 result
= acx_s_issue_cmd(adev
, ACX1xx_CMD_CONFIG_BEACON
, &bcn
, len
);
1671 /***********************************************************************
1672 ** acx_cmd_join_bssid
1674 ** Common code for both acx100 and acx111.
1676 /* NB: does NOT match RATE100_nn but matches ACX[111]_SCAN_RATE_n */
1677 static const u8 bitpos2genframe_txrate
[] = {
1678 10, /* 0. 1 Mbit/s */
1679 20, /* 1. 2 Mbit/s */
1680 55, /* 2. 5.5 Mbit/s */
1681 0x0B, /* 3. 6 Mbit/s */
1682 0x0F, /* 4. 9 Mbit/s */
1683 110, /* 5. 11 Mbit/s */
1684 0x0A, /* 6. 12 Mbit/s */
1685 0x0E, /* 7. 18 Mbit/s */
1686 220, /* 8. 22 Mbit/s */
1687 0x09, /* 9. 24 Mbit/s */
1688 0x0D, /* 10. 36 Mbit/s */
1689 0x08, /* 11. 48 Mbit/s */
1690 0x0C, /* 12. 54 Mbit/s */
1691 10, /* 13. 1 Mbit/s, should never happen */
1692 10, /* 14. 1 Mbit/s, should never happen */
1693 10, /* 15. 1 Mbit/s, should never happen */
1697 ** Actually, each one compiled into one AND and one SHIFT,
1698 ** 31 bytes in x86 asm (more if uints are replaced by u16/u8) */
1699 static inline unsigned int rate111to5bits(unsigned int rate
)
1702 | ((rate
& RATE111_11
) / (RATE111_11
/ JOINBSS_RATES_11
))
1703 | ((rate
& RATE111_22
) / (RATE111_22
/ JOINBSS_RATES_22
));
1707 void acx_s_cmd_join_bssid(acx_device_t
*adev
, const u8
*bssid
)
1713 if (mac_is_zero(bssid
))
1718 dtim_interval
= (ACX_MODE_0_ADHOC
== adev
->mode
) ?
1719 1 : adev
->dtim_interval
;
1721 memset(&tmp
, 0, sizeof(tmp
));
1723 for (i
= 0; i
< ETH_ALEN
; i
++) {
1724 tmp
.bssid
[i
] = bssid
[ETH_ALEN
-1 - i
];
1727 tmp
.beacon_interval
= cpu_to_le16(adev
->beacon_interval
);
1729 /* Basic rate set. Control frame responses (such as ACK or CTS frames)
1730 ** are sent with one of these rates */
1731 if (IS_ACX111(adev
)) {
1732 /* It was experimentally determined that rates_basic
1733 ** can take 11g rates as well, not only rates
1734 ** defined with JOINBSS_RATES_BASIC111_nnn.
1735 ** Just use RATE111_nnn constants... */
1736 tmp
.u
.acx111
.dtim_interval
= dtim_interval
;
1737 tmp
.u
.acx111
.rates_basic
= cpu_to_le16(adev
->rate_basic
);
1738 log(L_ASSOC
, "rates_basic:%04X, rates_supported:%04X\n",
1739 adev
->rate_basic
, adev
->rate_oper
);
1741 tmp
.u
.acx100
.dtim_interval
= dtim_interval
;
1742 tmp
.u
.acx100
.rates_basic
= rate111to5bits(adev
->rate_basic
);
1743 tmp
.u
.acx100
.rates_supported
= rate111to5bits(adev
->rate_oper
);
1744 log(L_ASSOC
, "rates_basic:%04X->%02X, "
1745 "rates_supported:%04X->%02X\n",
1746 adev
->rate_basic
, tmp
.u
.acx100
.rates_basic
,
1747 adev
->rate_oper
, tmp
.u
.acx100
.rates_supported
);
1750 /* Setting up how Beacon, Probe Response, RTS, and PS-Poll frames
1751 ** will be sent (rate/modulation/preamble) */
1752 tmp
.genfrm_txrate
= bitpos2genframe_txrate
[lowest_bit(adev
->rate_basic
)];
1753 tmp
.genfrm_mod_pre
= 0; /* FIXME: was = adev->capab_short (which was always 0); */
1754 /* we can use short pre *if* all peers can understand it */
1755 /* FIXME #2: we need to correctly set PBCC/OFDM bits here too */
1757 /* we switch fw to STA mode in MONITOR mode, it seems to be
1758 ** the only mode where fw does not emit beacons by itself
1759 ** but allows us to send anything (we really want to retain
1760 ** ability to tx arbitrary frames in MONITOR mode)
1762 tmp
.macmode
= (adev
->mode
!= ACX_MODE_MONITOR
? adev
->mode
: ACX_MODE_2_STA
);
1763 tmp
.channel
= adev
->channel
;
1764 tmp
.essid_len
= adev
->essid_len
;
1766 memcpy(tmp
.essid
, adev
->essid
, tmp
.essid_len
);
1767 acx_s_issue_cmd(adev
, ACX1xx_CMD_JOIN
, &tmp
, tmp
.essid_len
+ 0x11);
1769 log(L_ASSOC
|L_DEBUG
, "BSS_Type = %u\n", tmp
.macmode
);
1770 acxlog_mac(L_ASSOC
|L_DEBUG
, "JoinBSSID MAC:", adev
->bssid
, "\n");
1772 /* acx_update_capabilities(adev); */
1776 /***********************************************************************
1777 ** acxpci_i_set_multicast_list
1778 ** FIXME: most likely needs refinement
1781 void acx_i_set_multicast_list(struct ieee80211_hw
*hw
,
1782 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
1783 unsigned short netflags
, int mc_count
)
1785 unsigned int changed_flags
,
1786 unsigned int *total_flags
,
1787 int mc_count
, struct dev_addr_list
*mc_list
)
1790 acx_device_t
*adev
= ieee2adev(hw
);
1791 unsigned long flags
;
1795 acx_lock(adev
, flags
);
1797 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
1798 changed_flags
&= (FIF_PROMISC_IN_BSS
| FIF_ALLMULTI
| FIF_FCSFAIL
|
1799 FIF_CONTROL
| FIF_OTHER_BSS
);
1800 *total_flags
&= (FIF_PROMISC_IN_BSS
| FIF_ALLMULTI
| FIF_FCSFAIL
|
1801 FIF_CONTROL
| FIF_OTHER_BSS
);
1802 /* if ((changed_flags & (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)) == 0)
1806 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
1807 if (netflags
& (IFF_PROMISC
| IFF_ALLMULTI
)) {
1811 SET_BIT(adev
->rx_config_1
, RX_CFG1_RCV_PROMISCUOUS
);
1812 CLEAR_BIT(adev
->rx_config_1
, RX_CFG1_FILTER_ALL_MULTI
);
1813 SET_BIT(adev
->set_mask
, SET_RXCONFIG
);
1814 /* let kernel know in case *we* needed to set promiscuous */
1816 CLEAR_BIT(adev
->rx_config_1
, RX_CFG1_RCV_PROMISCUOUS
);
1817 SET_BIT(adev
->rx_config_1
, RX_CFG1_FILTER_ALL_MULTI
);
1818 SET_BIT(adev
->set_mask
, SET_RXCONFIG
);
1821 /* cannot update card settings directly here, atomic context */
1822 acx_schedule_task(adev
, ACX_AFTER_IRQ_UPDATE_CARD_CFG
);
1824 acx_unlock(adev
, flags
);
1829 /***********************************************************************
1830 ** acx111 feature config
1835 acx111_s_get_feature_config(acx_device_t
* adev
,
1836 u32
* feature_options
, u32
* data_flow_options
)
1838 struct acx111_ie_feature_config feat
;
1842 if (!IS_ACX111(adev
)) {
1846 memset(&feat
, 0, sizeof(feat
));
1848 if (OK
!= acx_s_interrogate(adev
, &feat
, ACX1xx_IE_FEATURE_CONFIG
)) {
1853 "got Feature option:0x%X, DataFlow option: 0x%X\n",
1854 feat
.feature_options
, feat
.data_flow_options
);
1856 if (feature_options
)
1857 *feature_options
= le32_to_cpu(feat
.feature_options
);
1858 if (data_flow_options
)
1859 *data_flow_options
= le32_to_cpu(feat
.data_flow_options
);
1867 acx111_s_set_feature_config(acx_device_t
* adev
,
1868 u32 feature_options
, u32 data_flow_options
,
1870 /* 0 == remove, 1 == add, 2 == set */ )
1872 struct acx111_ie_feature_config feat
;
1876 if (!IS_ACX111(adev
)) {
1881 if ((mode
< 0) || (mode
> 2)) {
1887 /* need to modify old data */
1888 acx111_s_get_feature_config(adev
, &feat
.feature_options
,
1889 &feat
.data_flow_options
);
1891 /* need to set a completely new value */
1892 feat
.feature_options
= 0;
1893 feat
.data_flow_options
= 0;
1896 if (mode
== 0) { /* remove */
1897 CLEAR_BIT(feat
.feature_options
, cpu_to_le32(feature_options
));
1898 CLEAR_BIT(feat
.data_flow_options
,
1899 cpu_to_le32(data_flow_options
));
1900 } else { /* add or set */
1901 SET_BIT(feat
.feature_options
, cpu_to_le32(feature_options
));
1902 SET_BIT(feat
.data_flow_options
, cpu_to_le32(data_flow_options
));
1906 "old: feature 0x%08X dataflow 0x%08X. mode: %u\n"
1907 "new: feature 0x%08X dataflow 0x%08X\n",
1908 feature_options
, data_flow_options
, mode
,
1909 le32_to_cpu(feat
.feature_options
),
1910 le32_to_cpu(feat
.data_flow_options
));
1912 if (OK
!= acx_s_configure(adev
, &feat
, ACX1xx_IE_FEATURE_CONFIG
)) {
1921 static inline int acx111_s_feature_off(acx_device_t
* adev
, u32 f
, u32 d
)
1923 return acx111_s_set_feature_config(adev
, f
, d
, 0);
1925 static inline int acx111_s_feature_on(acx_device_t
* adev
, u32 f
, u32 d
)
1927 return acx111_s_set_feature_config(adev
, f
, d
, 1);
1929 static inline int acx111_s_feature_set(acx_device_t
* adev
, u32 f
, u32 d
)
1931 return acx111_s_set_feature_config(adev
, f
, d
, 2);
1935 /***********************************************************************
1936 ** acx100_s_init_memory_pools
1939 acx100_s_init_memory_pools(acx_device_t
* adev
, const acx_ie_memmap_t
* mmt
)
1941 acx100_ie_memblocksize_t MemoryBlockSize
;
1942 acx100_ie_memconfigoption_t MemoryConfigOption
;
1943 int TotalMemoryBlocks
;
1945 int TotalRxBlockSize
;
1947 int TotalTxBlockSize
;
1951 /* Let's see if we can follow this:
1952 first we select our memory block size (which I think is
1953 completely arbitrary) */
1954 MemoryBlockSize
.size
= cpu_to_le16(adev
->memblocksize
);
1956 /* Then we alert the card to our decision of block size */
1957 if (OK
!= acx_s_configure(adev
, &MemoryBlockSize
, ACX100_IE_BLOCK_SIZE
)) {
1961 /* We figure out how many total blocks we can create, using
1962 the block size we chose, and the beginning and ending
1963 memory pointers, i.e.: end-start/size */
1965 (le32_to_cpu(mmt
->PoolEnd
) -
1966 le32_to_cpu(mmt
->PoolStart
)) / adev
->memblocksize
;
1968 log(L_DEBUG
, "TotalMemoryBlocks=%u (%u bytes)\n",
1969 TotalMemoryBlocks
, TotalMemoryBlocks
* adev
->memblocksize
);
1971 /* MemoryConfigOption.DMA_config bitmask:
1972 access to ACX memory is to be done:
1973 0x00080000 using PCI conf space?!
1974 0x00040000 using IO instructions?
1975 0x00000000 using memory access instructions
1976 0x00020000 using local memory block linked list (else what?)
1977 0x00010000 using host indirect descriptors (else host must access ACX memory?)
1980 MemoryConfigOption
.DMA_config
= cpu_to_le32(0x30000);
1981 /* Declare start of the Rx host pool */
1982 MemoryConfigOption
.pRxHostDesc
=
1983 cpu2acx(adev
->rxhostdesc_startphy
);
1984 log(L_DEBUG
, "pRxHostDesc 0x%08X, rxhostdesc_startphy 0x%lX\n",
1985 acx2cpu(MemoryConfigOption
.pRxHostDesc
),
1986 (long)adev
->rxhostdesc_startphy
);
1988 MemoryConfigOption
.DMA_config
= cpu_to_le32(0x20000);
1991 /* 50% of the allotment of memory blocks go to tx descriptors */
1992 TxBlockNum
= TotalMemoryBlocks
/ 2;
1993 MemoryConfigOption
.TxBlockNum
= cpu_to_le16(TxBlockNum
);
1995 /* and 50% go to the rx descriptors */
1996 RxBlockNum
= TotalMemoryBlocks
- TxBlockNum
;
1997 MemoryConfigOption
.RxBlockNum
= cpu_to_le16(RxBlockNum
);
1999 /* size of the tx and rx descriptor queues */
2000 TotalTxBlockSize
= TxBlockNum
* adev
->memblocksize
;
2001 TotalRxBlockSize
= RxBlockNum
* adev
->memblocksize
;
2002 log(L_DEBUG
, "TxBlockNum %u RxBlockNum %u TotalTxBlockSize %u "
2003 "TotalTxBlockSize %u\n", TxBlockNum
, RxBlockNum
,
2004 TotalTxBlockSize
, TotalRxBlockSize
);
2007 /* align the tx descriptor queue to an alignment of 0x20 (32 bytes) */
2008 MemoryConfigOption
.rx_mem
=
2009 cpu_to_le32((le32_to_cpu(mmt
->PoolStart
) + 0x1f) & ~0x1f);
2011 /* align the rx descriptor queue to units of 0x20
2012 * and offset it by the tx descriptor queue */
2013 MemoryConfigOption
.tx_mem
=
2014 cpu_to_le32((le32_to_cpu(mmt
->PoolStart
) + TotalRxBlockSize
+
2016 log(L_DEBUG
, "rx_mem %08X rx_mem %08X\n", MemoryConfigOption
.tx_mem
,
2017 MemoryConfigOption
.rx_mem
);
2019 /* alert the device to our decision */
2021 acx_s_configure(adev
, &MemoryConfigOption
,
2022 ACX1xx_IE_MEMORY_CONFIG_OPTIONS
)) {
2026 /* and tell the device to kick it into gear */
2027 if (OK
!= acx_s_issue_cmd(adev
, ACX100_CMD_INIT_MEMORY
, NULL
, 0)) {
2038 /***********************************************************************
2039 ** acx100_s_create_dma_regions
2041 ** Note that this fn messes up heavily with hardware, but we cannot
2042 ** lock it (we need to sleep). Not a problem since IRQs can't happen
2044 /* OLD CODE? - let's rewrite it! */
2045 static int acx100_s_create_dma_regions(acx_device_t
* adev
)
2047 acx100_ie_queueconfig_t queueconf
;
2048 acx_ie_memmap_t memmap
;
2050 u32 tx_queue_start
, rx_queue_start
;
2054 /* read out the acx100 physical start address for the queues */
2055 if (OK
!= acx_s_interrogate(adev
, &memmap
, ACX1xx_IE_MEMORY_MAP
)) {
2059 tx_queue_start
= le32_to_cpu(memmap
.QueueStart
);
2060 rx_queue_start
= tx_queue_start
+ TX_CNT
* sizeof(txdesc_t
);
2062 log(L_DEBUG
, "initializing Queue Indicator\n");
2064 memset(&queueconf
, 0, sizeof(queueconf
));
2066 /* Not needed for PCI, so we can avoid setting them altogether */
2068 queueconf
.NumTxDesc
= USB_TX_CNT
;
2069 queueconf
.NumRxDesc
= USB_RX_CNT
;
2072 /* calculate size of queues */
2073 queueconf
.AreaSize
= cpu_to_le32(TX_CNT
* sizeof(txdesc_t
) +
2074 RX_CNT
* sizeof(rxdesc_t
) + 8);
2075 queueconf
.NumTxQueues
= 1; /* number of tx queues */
2076 /* sets the beginning of the tx descriptor queue */
2077 queueconf
.TxQueueStart
= memmap
.QueueStart
;
2078 /* done by memset: queueconf.TxQueuePri = 0; */
2079 queueconf
.RxQueueStart
= cpu_to_le32(rx_queue_start
);
2080 queueconf
.QueueOptions
= 1; /* auto reset descriptor */
2081 /* sets the end of the rx descriptor queue */
2082 queueconf
.QueueEnd
=
2083 cpu_to_le32(rx_queue_start
+ RX_CNT
* sizeof(rxdesc_t
)
2085 /* sets the beginning of the next queue */
2086 queueconf
.HostQueueEnd
=
2087 cpu_to_le32(le32_to_cpu(queueconf
.QueueEnd
) + 8);
2088 if (OK
!= acx_s_configure(adev
, &queueconf
, ACX1xx_IE_QUEUE_CONFIG
)) {
2093 /* sets the beginning of the rx descriptor queue, after the tx descrs */
2094 if (OK
!= acxpci_s_create_hostdesc_queues(adev
))
2096 acxpci_create_desc_queues(adev
, tx_queue_start
, rx_queue_start
);
2099 if (OK
!= acx_s_interrogate(adev
, &memmap
, ACX1xx_IE_MEMORY_MAP
)) {
2103 memmap
.PoolStart
= cpu_to_le32((le32_to_cpu(memmap
.QueueEnd
) + 4 +
2106 if (OK
!= acx_s_configure(adev
, &memmap
, ACX1xx_IE_MEMORY_MAP
)) {
2110 if (OK
!= acx100_s_init_memory_pools(adev
, &memmap
)) {
2118 acx_s_mwait(1000); /* ? */
2120 acxpci_free_desc_queues(adev
);
2127 /***********************************************************************
2128 ** acx111_s_create_dma_regions
2130 ** Note that this fn messes heavily with hardware, but we cannot
2131 ** lock it (we need to sleep). Not a problem since IRQs can't happen
2133 #define ACX111_PERCENT(percent) ((percent)/5)
2135 static int acx111_s_create_dma_regions(acx_device_t
* adev
)
2137 struct acx111_ie_memoryconfig memconf
;
2138 struct acx111_ie_queueconfig queueconf
;
2139 u32 tx_queue_start
, rx_queue_start
;
2143 /* Calculate memory positions and queue sizes */
2145 /* Set up our host descriptor pool + data pool */
2147 if (OK
!= acxpci_s_create_hostdesc_queues(adev
))
2151 memset(&memconf
, 0, sizeof(memconf
));
2152 /* the number of STAs (STA contexts) to support
2153 ** NB: was set to 1 and everything seemed to work nevertheless... */
2154 memconf
.no_of_stations
= 1; //cpu_to_le16(VEC_SIZE(adev->sta_list));
2155 /* specify the memory block size. Default is 256 */
2156 memconf
.memory_block_size
= cpu_to_le16(adev
->memblocksize
);
2157 /* let's use 50%/50% for tx/rx (specify percentage, units of 5%) */
2158 memconf
.tx_rx_memory_block_allocation
= ACX111_PERCENT(50);
2159 /* set the count of our queues
2160 ** NB: struct acx111_ie_memoryconfig shall be modified
2161 ** if we ever will switch to more than one rx and/or tx queue */
2162 memconf
.count_rx_queues
= 1;
2163 memconf
.count_tx_queues
= 1;
2164 /* 0 == Busmaster Indirect Memory Organization, which is what we want
2165 * (using linked host descs with their allocated mem).
2166 * 2 == Generic Bus Slave */
2167 /* done by memset: memconf.options = 0; */
2168 /* let's use 25% for fragmentations and 75% for frame transfers
2169 * (specified in units of 5%) */
2170 memconf
.fragmentation
= ACX111_PERCENT(75);
2171 /* Rx descriptor queue config */
2172 memconf
.rx_queue1_count_descs
= RX_CNT
;
2173 memconf
.rx_queue1_type
= 7; /* must be set to 7 */
2174 /* done by memset: memconf.rx_queue1_prio = 0; low prio */
2176 memconf
.rx_queue1_host_rx_start
=
2177 cpu2acx(adev
->rxhostdesc_startphy
);
2179 /* Tx descriptor queue config */
2180 memconf
.tx_queue1_count_descs
= TX_CNT
;
2181 /* done by memset: memconf.tx_queue1_attributes = 0; lowest priority */
2183 /* NB1: this looks wrong: (memconf,ACX1xx_IE_QUEUE_CONFIG),
2184 ** (queueconf,ACX1xx_IE_MEMORY_CONFIG_OPTIONS) look swapped, eh?
2185 ** But it is actually correct wrt IE numbers.
2186 ** NB2: sizeof(memconf) == 28 == 0x1c but configure(ACX1xx_IE_QUEUE_CONFIG)
2187 ** writes 0x20 bytes (because same IE for acx100 uses struct acx100_ie_queueconfig
2188 ** which is 4 bytes larger. what a mess. TODO: clean it up) */
2189 if (OK
!= acx_s_configure(adev
, &memconf
, ACX1xx_IE_QUEUE_CONFIG
)) {
2193 acx_s_interrogate(adev
, &queueconf
, ACX1xx_IE_MEMORY_CONFIG_OPTIONS
);
2195 tx_queue_start
= le32_to_cpu(queueconf
.tx1_queue_address
);
2196 rx_queue_start
= le32_to_cpu(queueconf
.rx1_queue_address
);
2198 log(L_INIT
, "dump queue head (from card):\n"
2200 "tx_memory_block_address: %X\n"
2201 "rx_memory_block_address: %X\n"
2202 "tx1_queue address: %X\n"
2203 "rx1_queue address: %X\n",
2204 le16_to_cpu(queueconf
.len
),
2205 le32_to_cpu(queueconf
.tx_memory_block_address
),
2206 le32_to_cpu(queueconf
.rx_memory_block_address
),
2207 tx_queue_start
, rx_queue_start
);
2210 acxpci_create_desc_queues(adev
, tx_queue_start
, rx_queue_start
);
2216 acxpci_free_desc_queues(adev
);
2223 /***********************************************************************
2225 static void acx_s_initialize_rx_config(acx_device_t
* adev
)
2233 switch (adev
->mode
) {
2234 case ACX_MODE_MONITOR
:
2235 adev
->rx_config_1
= (u16
) (0
2236 /* | RX_CFG1_INCLUDE_RXBUF_HDR */
2237 /* | RX_CFG1_FILTER_SSID */
2238 /* | RX_CFG1_FILTER_BCAST */
2239 /* | RX_CFG1_RCV_MC_ADDR1 */
2240 /* | RX_CFG1_RCV_MC_ADDR0 */
2241 /* | RX_CFG1_FILTER_ALL_MULTI */
2242 /* | RX_CFG1_FILTER_BSSID */
2243 /* | RX_CFG1_FILTER_MAC */
2244 | RX_CFG1_RCV_PROMISCUOUS
2245 | RX_CFG1_INCLUDE_FCS
2246 /* | RX_CFG1_INCLUDE_PHY_HDR */
2248 adev
->rx_config_2
= (u16
) (0
2249 | RX_CFG2_RCV_ASSOC_REQ
2250 | RX_CFG2_RCV_AUTH_FRAMES
2251 | RX_CFG2_RCV_BEACON_FRAMES
2252 | RX_CFG2_RCV_CONTENTION_FREE
2253 | RX_CFG2_RCV_CTRL_FRAMES
2254 | RX_CFG2_RCV_DATA_FRAMES
2255 | RX_CFG2_RCV_BROKEN_FRAMES
2256 | RX_CFG2_RCV_MGMT_FRAMES
2257 | RX_CFG2_RCV_PROBE_REQ
2258 | RX_CFG2_RCV_PROBE_RESP
2259 | RX_CFG2_RCV_ACK_FRAMES
2260 | RX_CFG2_RCV_OTHER
);
2263 adev
->rx_config_1
= (u16
) (0
2264 /* | RX_CFG1_INCLUDE_RXBUF_HDR */
2265 /* | RX_CFG1_FILTER_SSID */
2266 /* | RX_CFG1_FILTER_BCAST */
2267 /* | RX_CFG1_RCV_MC_ADDR1 */
2268 /* | RX_CFG1_RCV_MC_ADDR0 */
2269 /* | RX_CFG1_FILTER_ALL_MULTI */
2270 /* | RX_CFG1_FILTER_BSSID */
2271 /* | RX_CFG1_FILTER_MAC */
2272 | RX_CFG1_RCV_PROMISCUOUS
2273 /* | RX_CFG1_INCLUDE_FCS */
2274 /* | RX_CFG1_INCLUDE_PHY_HDR */
2276 adev
->rx_config_2
= (u16
) (0
2277 | RX_CFG2_RCV_ASSOC_REQ
2278 | RX_CFG2_RCV_AUTH_FRAMES
2279 | RX_CFG2_RCV_BEACON_FRAMES
2280 | RX_CFG2_RCV_CONTENTION_FREE
2281 | RX_CFG2_RCV_CTRL_FRAMES
2282 | RX_CFG2_RCV_DATA_FRAMES
2283 /*| RX_CFG2_RCV_BROKEN_FRAMES */
2284 | RX_CFG2_RCV_MGMT_FRAMES
2285 | RX_CFG2_RCV_PROBE_REQ
2286 | RX_CFG2_RCV_PROBE_RESP
2287 | RX_CFG2_RCV_ACK_FRAMES
2288 | RX_CFG2_RCV_OTHER
);
2291 adev
->rx_config_1
|= RX_CFG1_INCLUDE_RXBUF_HDR
;
2293 if ((adev
->rx_config_1
& RX_CFG1_INCLUDE_PHY_HDR
)
2294 || (adev
->firmware_numver
>= 0x02000000))
2295 adev
->phy_header_len
= IS_ACX111(adev
) ? 8 : 4;
2297 adev
->phy_header_len
= 0;
2299 log(L_INIT
, "setting RXconfig to %04X:%04X\n",
2300 adev
->rx_config_1
, adev
->rx_config_2
);
2301 cfg
.rx_cfg1
= cpu_to_le16(adev
->rx_config_1
);
2302 cfg
.rx_cfg2
= cpu_to_le16(adev
->rx_config_2
);
2303 acx_s_configure(adev
, &cfg
, ACX1xx_IE_RXCONFIG
);
2307 /***********************************************************************
2308 ** FIXME: this should be solved in a general way for all radio types
2309 ** by decoding the radio firmware module,
2310 ** since it probably has some standard structure describing how to
2311 ** set the power level of the radio module which it controls.
2312 ** Or maybe not, since the radio module probably has a function interface
2313 ** instead which then manages Tx level programming :-\
2317 static int acx111_s_set_tx_level(acx_device_t
* adev
, u8 level_dbm
)
2319 struct acx111_ie_tx_level tx_level
;
2321 /* my acx111 card has two power levels in its configoptions (== EEPROM):
2324 * For now, just assume all other acx111 cards have the same.
2325 * FIXME: Ideally we would query it here, but we first need a
2326 * standard way to query individual configoptions easily.
2327 * Well, now we have proper cfgopt txpower variables, but this still
2328 * hasn't been done yet, since it also requires dBm <-> mW conversion here... */
2329 if (level_dbm
<= 12) {
2330 tx_level
.level
= 2; /* 10 dBm */
2331 adev
->tx_level_dbm
= 10;
2333 tx_level
.level
= 1; /* 15 dBm */
2334 adev
->tx_level_dbm
= 15;
2336 if (level_dbm
!= adev
->tx_level_dbm
)
2337 log(L_INIT
, "acx111 firmware has specific "
2338 "power levels only: adjusted %d dBm to %d dBm!\n",
2339 level_dbm
, adev
->tx_level_dbm
);
2341 return acx_s_configure(adev
, &tx_level
, ACX1xx_IE_DOT11_TX_POWER_LEVEL
);
2344 static int acx_s_set_tx_level(acx_device_t
*adev
, u8 level_dbm
)
2346 if (IS_ACX111(adev
)) {
2347 return acx111_s_set_tx_level(adev
, level_dbm
);
2350 return acx100pci_s_set_tx_level(adev
, level_dbm
);
2357 /***********************************************************************
2358 ** acx_s_set_defaults
2360 void acx_s_set_defaults(acx_device_t
* adev
)
2362 struct ieee80211_conf
*conf
= &adev
->ieee
->conf
;
2363 unsigned long flags
;
2367 acx_lock(adev
, flags
);
2368 /* do it before getting settings, prevent bogus channel 0 warning */
2371 /* query some settings from the card.
2372 * NOTE: for some settings, e.g. CCA and ED (ACX100!), an initial
2373 * query is REQUIRED, otherwise the card won't work correctly! */
2375 GETSET_ANTENNA
| GETSET_SENSITIVITY
| GETSET_STATION_ID
|
2377 /* Only ACX100 supports ED and CCA */
2378 if (IS_ACX100(adev
))
2379 adev
->get_mask
|= GETSET_CCA
| GETSET_ED_THRESH
;
2381 acx_unlock(adev
, flags
);
2383 acx_s_update_card_settings(adev
);
2385 acx_lock(adev
, flags
);
2387 /* set our global interrupt mask */
2389 acxpci_set_interrupt_mask(adev
);
2391 adev
->led_power
= 1; /* LED is active on startup */
2392 adev
->brange_max_quality
= 60; /* LED blink max quality is 60 */
2393 adev
->brange_time_last_state_change
= jiffies
;
2395 /* copy the MAC address we just got from the card
2396 * into our MAC address used during current 802.11 session */
2397 SET_IEEE80211_PERM_ADDR(adev
->ieee
, adev
->dev_addr
);
2398 MAC_BCAST(adev
->ap
);
2401 snprintf(adev
->essid
, sizeof(adev
->essid
), "STA%02X%02X%02X",
2402 adev
->dev_addr
[3], adev
->dev_addr
[4], adev
->dev_addr
[5]);
2403 adev
->essid_active
= 1;
2405 /* we have a nick field to waste, so why not abuse it
2406 * to announce the driver version? ;-) */
2407 strncpy(adev
->nick
, "acx " ACX_RELEASE
, IW_ESSID_MAX_SIZE
);
2409 if (IS_PCI(adev
)) { /* FIXME: this should be made to apply to USB, too! */
2410 /* first regulatory domain entry in EEPROM == default reg. domain */
2411 adev
->reg_dom_id
= adev
->cfgopt_domains
.list
[0];
2414 /* 0xffff would be better, but then we won't get a "scan complete"
2415 * interrupt, so our current infrastructure will fail: */
2416 adev
->scan_count
= 1;
2417 adev
->scan_mode
= ACX_SCAN_OPT_ACTIVE
;
2418 adev
->scan_duration
= 100;
2419 adev
->scan_probe_delay
= 200;
2420 /* reported to break scanning: adev->scan_probe_delay = adev->cfgopt_probe_delay; */
2421 adev
->scan_rate
= ACX_SCAN_RATE_1
;
2424 adev
->mode
= ACX_MODE_2_STA
;
2425 adev
->listen_interval
= 100;
2426 adev
->beacon_interval
= DEFAULT_BEACON_INTERVAL
;
2427 adev
->dtim_interval
= DEFAULT_DTIM_INTERVAL
;
2429 adev
->msdu_lifetime
= DEFAULT_MSDU_LIFETIME
;
2431 adev
->rts_threshold
= DEFAULT_RTS_THRESHOLD
;
2432 adev
->frag_threshold
= 2346;
2434 /* use standard default values for retry limits */
2435 adev
->short_retry
= 7; /* max. retries for (short) non-RTS packets */
2436 adev
->long_retry
= 4; /* max. retries for long (RTS) packets */
2438 adev
->preamble_mode
= 2; /* auto */
2439 adev
->fallback_threshold
= 3;
2440 adev
->stepup_threshold
= 10;
2441 adev
->rate_bcast
= RATE111_1
;
2442 adev
->rate_bcast100
= RATE100_1
;
2443 adev
->rate_basic
= RATE111_1
| RATE111_2
;
2444 adev
->rate_auto
= 1;
2445 if (IS_ACX111(adev
)) {
2446 adev
->rate_oper
= RATE111_ALL
;
2448 adev
->rate_oper
= RATE111_ACX100_COMPAT
;
2451 /* Supported Rates element - the rates here are given in units of
2452 * 500 kbit/s, plus 0x80 added. See 802.11-1999.pdf item 7.3.2.2 */
2453 acx_l_update_ratevector(adev
);
2455 /* set some more defaults */
2456 if (IS_ACX111(adev
)) {
2457 /* 30mW (15dBm) is default, at least in my acx111 card: */
2458 adev
->tx_level_dbm
= 15;
2459 conf
->power_level
= adev
->tx_level_dbm
;
2460 acx_unlock(adev
, flags
);
2461 acx_s_set_tx_level(adev
, adev
->tx_level_dbm
);
2462 SET_BIT(adev
->set_mask
, GETSET_TXPOWER
);
2463 acx_lock(adev
, flags
);
2465 /* don't use max. level, since it might be dangerous
2466 * (e.g. WRT54G people experience
2467 * excessive Tx power damage!) */
2468 adev
->tx_level_dbm
= 18;
2469 conf
->power_level
= adev
->tx_level_dbm
;
2470 acx_unlock(adev
, flags
);
2471 acx_s_set_tx_level(adev
, adev
->tx_level_dbm
);
2472 SET_BIT(adev
->set_mask
, GETSET_TXPOWER
);
2473 acx_lock(adev
, flags
);
2476 /* adev->tx_level_auto = 1; */
2477 if (IS_ACX111(adev
)) {
2478 /* start with sensitivity level 1 out of 3: */
2479 adev
->sensitivity
= 1;
2482 /* #define ENABLE_POWER_SAVE */
2483 #ifdef ENABLE_POWER_SAVE
2484 adev
->ps_wakeup_cfg
= PS_CFG_ENABLE
| PS_CFG_WAKEUP_ALL_BEAC
;
2485 adev
->ps_listen_interval
= 1;
2487 PS_OPT_ENA_ENHANCED_PS
| PS_OPT_TX_PSPOLL
| PS_OPT_STILL_RCV_BCASTS
;
2488 adev
->ps_hangover_period
= 30;
2489 adev
->ps_enhanced_transition_time
= 0;
2491 adev
->ps_wakeup_cfg
= 0;
2492 adev
->ps_listen_interval
= 0;
2493 adev
->ps_options
= 0;
2494 adev
->ps_hangover_period
= 0;
2495 adev
->ps_enhanced_transition_time
= 0;
2498 /* These settings will be set in fw on ifup */
2499 adev
->set_mask
= 0 | GETSET_RETRY
| SET_MSDU_LIFETIME
2500 /* configure card to do rate fallback when in auto rate mode */
2501 | SET_RATE_FALLBACK
| SET_RXCONFIG
| GETSET_TXPOWER
2502 /* better re-init the antenna value we got above */
2504 #if POWER_SAVE_80211
2505 | GETSET_POWER_80211
2509 acx_unlock(adev
, flags
);
2510 acx_lock_unhold(); /* hold time 844814 CPU ticks @2GHz */
2512 acx_s_initialize_rx_config(adev
);
2518 /***********************************************************************
2519 ** acx_l_process_rxbuf
2521 ** NB: used by USB code also
2523 void acx_l_process_rxbuf(acx_device_t
* adev
, rxbuffer_t
* rxbuf
)
2525 struct ieee80211_hdr
*hdr
;
2527 hdr
= acx_get_wlan_hdr(adev
, rxbuf
);
2528 fc
= le16_to_cpu(hdr
->frame_control
);
2529 /* length of frame from control field to first byte of FCS */
2530 buf_len
= RXBUF_BYTES_RCVD(adev
, rxbuf
);
2532 if (unlikely(acx_debug
& L_DATA
)) {
2533 printk("rx: 802.11 buf[%u]: \n", buf_len
);
2534 acx_dump_bytes(hdr
, buf_len
);
2538 acx_l_rx(adev
, rxbuf
);
2539 /* Now check Rx quality level, AFTER processing packet.
2540 * I tried to figure out how to map these levels to dBm
2541 * values, but for the life of me I really didn't
2542 * manage to get it. Either these values are not meant to
2543 * be expressed in dBm, or it's some pretty complicated
2546 #ifdef FROM_SCAN_SOURCE_ONLY
2547 /* only consider packets originating from the MAC
2548 * address of the device that's managing our BSSID.
2549 * Disable it for now, since it removes information (levels
2550 * from different peers) and slows the Rx path. *//*
2551 if (adev->ap_client && mac_is_equal(hdr->a2, adev->ap_client->address)) {
2557 /***********************************************************************
2558 ** acx_l_handle_txrate_auto
2560 ** Theory of operation:
2561 ** client->rate_cap is a bitmask of rates client is capable of.
2562 ** client->rate_cfg is a bitmask of allowed (configured) rates.
2563 ** It is set as a result of iwconfig rate N [auto]
2564 ** or iwpriv set_rates "N,N,N N,N,N" commands.
2565 ** It can be fixed (e.g. 0x0080 == 18Mbit only),
2566 ** auto (0x00ff == 18Mbit or any lower value),
2567 ** and code handles any bitmask (0x1081 == try 54Mbit,18Mbit,1Mbit _only_).
2569 ** client->rate_cur is a value for rate111 field in tx descriptor.
2570 ** It is always set to txrate_cfg sans zero or more most significant
2571 ** bits. This routine handles selection of new rate_cur value depending on
2572 ** outcome of last tx event.
2574 ** client->rate_100 is a precalculated rate value for acx100
2575 ** (we can do without it, but will need to calculate it on each tx).
2577 ** You cannot configure mixed usage of 5.5 and/or 11Mbit rate
2578 ** with PBCC and CCK modulation. Either both at CCK or both at PBCC.
2579 ** In theory you can implement it, but so far it is considered not worth doing.
2581 ** 22Mbit, of course, is PBCC always. */
2583 /* maps acx100 tx descr rate field to acx111 one */
2585 static u16 rate100to111(u8 r)
2593 case (RATE100_5 | RATE100_PBCC511):
2596 case (RATE100_11 | RATE100_PBCC511):
2601 printk("acx: unexpected acx100 txrate: %u! "
2602 "Please report\n", r);
2610 acx_i_start_xmit(struct ieee80211_hw
*hw
,
2611 struct sk_buff
*skb
, struct ieee80211_tx_control
*ctl
)
2613 acx_device_t
*adev
= ieee2adev(hw
);
2616 unsigned long flags
;
2618 int txresult
= NOT_OK
;
2622 acx_lock(adev
, flags
);
2624 if (unlikely(!skb
)) {
2625 /* indicate success */
2630 if (unlikely(!adev
)) {
2635 if (unlikely(!(adev
->dev_state_mask
& ACX_STATE_IFACE_UP
))) {
2638 if (unlikely(!adev
->initialized
)) {
2642 acx_unlock(adev
, flags
);
2643 tx
= acx_l_alloc_tx(adev
);
2644 acx_lock(adev
, flags
);
2646 if (unlikely(!tx
)) {
2647 printk_ratelimited("%s: start_xmit: txdesc ring is full, "
2648 "dropping tx\n", wiphy_name(adev
->ieee
->wiphy
));
2653 acx_unlock(adev
, flags
);
2655 txbuf
= acx_l_get_txbuf(adev
, tx
);
2657 acx_lock(adev
, flags
);
2659 if (unlikely(!txbuf
)) {
2660 /* Card was removed */
2662 acx_l_dealloc_tx(adev
, tx
);
2665 memcpy(txbuf
, skb
->data
, skb
->len
);
2667 acx_unlock(adev
, flags
);
2669 acx_l_tx_data(adev
, tx
, skb
->len
, ctl
,skb
);
2672 adev
->stats
.tx_packets
++;
2673 adev
->stats
.tx_bytes
+= skb
->len
;
2675 acx_lock(adev
, flags
);
2678 acx_unlock(adev
, flags
);
2683 /***********************************************************************
2684 ** acx_l_update_ratevector
2686 ** Updates adev->rate_supported[_len] according to rate_{basic,oper}
2688 const u8 acx_bitpos2ratebyte
[] = {
2704 void acx_l_update_ratevector(acx_device_t
* adev
)
2706 u16 bcfg
= adev
->rate_basic
;
2707 u16 ocfg
= adev
->rate_oper
;
2708 u8
*supp
= adev
->rate_supported
;
2709 const u8
*dot11
= acx_bitpos2ratebyte
;
2725 adev
->rate_supported_len
= supp
- adev
->rate_supported
;
2726 if (acx_debug
& L_ASSOC
) {
2727 printk("new ratevector: ");
2728 acx_dump_bytes(adev
->rate_supported
, adev
->rate_supported_len
);
2733 /***********************************************************************
2736 ** Fires up periodically. Used to kick scan/auth/assoc if something goes wrong
2740 void acx_i_timer(unsigned long address
)
2742 unsigned long flags
;
2743 acx_device_t
*adev
= (acx_device_t
*) address
;
2747 acx_lock(adev
, flags
);
2750 /* We need calibration and stats gather tasks to perform here */
2752 acx_unlock(adev
, flags
);
2758 /***********************************************************************
2761 ** Sets the 802.11 state management timer's timeout.
2765 void acx_set_timer(acx_device_t
* adev
, int timeout_us
)
2769 log(L_DEBUG
| L_IRQ
, "%s(%u ms)\n", __func__
, timeout_us
/ 1000);
2770 if (!(adev
->dev_state_mask
& ACX_STATE_IFACE_UP
)) {
2771 printk("attempt to set the timer "
2772 "when the card interface is not up!\n");
2776 /* first check if the timer was already initialized, THEN modify it */
2777 if (adev
->mgmt_timer
.function
) {
2778 mod_timer(&adev
->mgmt_timer
,
2779 jiffies
+ (timeout_us
* HZ
/ 1000000));
2785 /** acx_plcp_get_bitrate_cck
2789 static u8
acx_plcp_get_bitrate_cck(u8 plcp
)
2793 return ACX_CCK_RATE_1MB
;
2795 return ACX_CCK_RATE_2MB
;
2797 return ACX_CCK_RATE_5MB
;
2799 return ACX_CCK_RATE_11MB
;
2804 /* Extract the bitrate out of an OFDM PLCP header. */
2806 static u8
acx_plcp_get_bitrate_ofdm(u8 plcp
)
2808 switch (plcp
& 0xF) {
2810 return ACX_OFDM_RATE_6MB
;
2812 return ACX_OFDM_RATE_9MB
;
2814 return ACX_OFDM_RATE_12MB
;
2816 return ACX_OFDM_RATE_18MB
;
2818 return ACX_OFDM_RATE_24MB
;
2820 return ACX_OFDM_RATE_36MB
;
2822 return ACX_OFDM_RATE_48MB
;
2824 return ACX_OFDM_RATE_54MB
;
2830 /***********************************************************************
2833 ** The end of the Rx path. Pulls data from a rxhostdesc into a socket
2834 ** buffer and feeds it to the network stack via netif_rx().
2836 ** Look to bcm43xx or p54
2838 static void acx_l_rx(acx_device_t
* adev
, rxbuffer_t
* rxbuf
)
2841 struct ieee80211_rx_status
* status
= &adev
->rx_status
;
2842 struct ieee80211_hdr
*w_hdr
;
2846 if (likely(adev
->dev_state_mask
& ACX_STATE_IFACE_UP
)) {
2847 struct sk_buff
*skb
;
2848 w_hdr
= acx_get_wlan_hdr(adev
, rxbuf
);
2849 buflen
= RXBUF_BYTES_USED(rxbuf
) - ((u8
*)w_hdr
- (u8
*)rxbuf
);
2850 skb
= dev_alloc_skb(buflen
+ 2);
2851 skb_reserve(skb
, 2);
2852 skb_put(skb
, buflen
);
2853 memcpy(skb
->data
, w_hdr
, buflen
);
2855 // memset(&status, 0, sizeof(status));
2858 status
->mactime
= rxbuf
->time
;
2859 status
->signal
= acx_signal_to_winlevel(rxbuf
->phy_level
);
2860 status
->noise
= acx_signal_to_winlevel(rxbuf
->phy_snr
);
2862 status
->rate
= rxbuf
->phy_plcp_signal
;
2863 status
->antenna
= 1;
2866 qual = acx_signal_determine_quality(adev->wstats.qual.level,
2867 adev->wstats.qual.noise);
2869 qual = (adev->wstats.qual.noise <= 100) ?
2870 100 - adev->wstats.qual.noise : 0;
2872 adev->wstats.qual.qual = qual;
2873 adev->wstats.qual.updated = 7; *//* all 3 indicators updated */
2875 #ifdef FROM_SCAN_SOURCE_ONLY
2879 if (rxbuf
->phy_stat_baseband
& (1 << 3)) /* Uses OFDM */
2881 status
->rate
= acx_plcp_get_bitrate_ofdm(rxbuf
->phy_plcp_signal
);
2884 status
->rate
= acx_plcp_get_bitrate_cck(rxbuf
->phy_plcp_signal
);
2886 ieee80211_rx_irqsafe(adev
->ieee
, skb
, status
);
2887 adev
->stats
.rx_packets
++;
2888 adev
->stats
.rx_bytes
+= skb
->len
;
2896 /***********************************************************************
2899 ** Loads a firmware image
2902 ** 0 unable to load file
2903 ** pointer to firmware success
2905 firmware_image_t
*acx_s_read_fw(struct device
*dev
, const char *file
,
2908 firmware_image_t
*res
;
2909 const struct firmware
*fw_entry
;
2912 log(L_INIT
, "requesting firmware image '%s'\n", file
);
2913 if (!request_firmware(&fw_entry
, file
, dev
)) {
2915 if (fw_entry
->size
>= 8)
2916 *size
= 8 + le32_to_cpu(*(u32
*) (fw_entry
->data
+ 4));
2917 if (fw_entry
->size
!= *size
) {
2918 printk("acx: firmware size does not match "
2919 "firmware header: %d != %d, "
2920 "aborting fw upload\n",
2921 (int)fw_entry
->size
, (int)*size
);
2924 res
= vmalloc(*size
);
2926 printk("acx: no memory for firmware "
2927 "(%u bytes)\n", *size
);
2930 memcpy(res
, fw_entry
->data
, fw_entry
->size
);
2932 release_firmware(fw_entry
);
2935 printk("acx: firmware image '%s' was not provided. "
2936 "Check your hotplug scripts\n", file
);
2938 /* checksum will be verified in write_fw, so don't bother here */
2943 /***********************************************************************
2946 static void acx100_s_set_wepkey(acx_device_t
* adev
)
2948 ie_dot11WEPDefaultKey_t dk
;
2951 for (i
= 0; i
< DOT11_MAX_DEFAULT_WEP_KEYS
; i
++) {
2952 if (adev
->wep_keys
[i
].size
!= 0) {
2953 log(L_INIT
, "setting WEP key: %d with "
2954 "total size: %d\n", i
, (int)adev
->wep_keys
[i
].size
);
2956 dk
.keySize
= adev
->wep_keys
[i
].size
;
2957 dk
.defaultKeyNum
= i
;
2958 memcpy(dk
.key
, adev
->wep_keys
[i
].key
, dk
.keySize
);
2959 acx_s_configure(adev
, &dk
,
2960 ACX100_IE_DOT11_WEP_DEFAULT_KEY_WRITE
);
2965 static void acx111_s_set_wepkey(acx_device_t
* adev
)
2967 acx111WEPDefaultKey_t dk
;
2970 for (i
= 0; i
< DOT11_MAX_DEFAULT_WEP_KEYS
; i
++) {
2971 if (adev
->wep_keys
[i
].size
!= 0) {
2972 log(L_INIT
, "setting WEP key: %d with "
2973 "total size: %d\n", i
, (int)adev
->wep_keys
[i
].size
);
2974 memset(&dk
, 0, sizeof(dk
));
2975 dk
.action
= cpu_to_le16(1); /* "add key"; yes, that's a 16bit value */
2976 dk
.keySize
= adev
->wep_keys
[i
].size
;
2978 /* are these two lines necessary? */
2979 dk
.type
= 0; /* default WEP key */
2980 dk
.index
= 0; /* ignored when setting default key */
2982 dk
.defaultKeyNum
= i
;
2983 memcpy(dk
.key
, adev
->wep_keys
[i
].key
, dk
.keySize
);
2984 acx_s_issue_cmd(adev
, ACX1xx_CMD_WEP_MGMT
, &dk
,
2990 static void acx_s_set_wepkey(acx_device_t
* adev
)
2992 if (IS_ACX111(adev
))
2993 acx111_s_set_wepkey(adev
);
2995 acx100_s_set_wepkey(adev
);
2999 /***********************************************************************
3000 ** acx100_s_init_wep
3002 ** FIXME: this should probably be moved into the new card settings
3003 ** management, but since we're also modifying the memory map layout here
3004 ** due to the WEP key space we want, we should take care...
3006 static int acx100_s_init_wep(acx_device_t
* adev
)
3008 acx100_ie_wep_options_t options
;
3009 ie_dot11WEPDefaultKeyID_t dk
;
3015 if (OK
!= acx_s_interrogate(adev
, &pt
, ACX1xx_IE_MEMORY_MAP
)) {
3019 log(L_DEBUG
, "CodeEnd:%X\n", pt
.CodeEnd
);
3021 pt
.WEPCacheStart
= cpu_to_le32(le32_to_cpu(pt
.CodeEnd
) + 0x4);
3022 pt
.WEPCacheEnd
= cpu_to_le32(le32_to_cpu(pt
.CodeEnd
) + 0x4);
3024 if (OK
!= acx_s_configure(adev
, &pt
, ACX1xx_IE_MEMORY_MAP
)) {
3028 /* let's choose maximum setting: 4 default keys, plus 10 other keys: */
3029 options
.NumKeys
= cpu_to_le16(DOT11_MAX_DEFAULT_WEP_KEYS
+ 10);
3030 options
.WEPOption
= 0x00;
3032 log(L_ASSOC
, "writing WEP options\n");
3033 acx_s_configure(adev
, &options
, ACX100_IE_WEP_OPTIONS
);
3035 acx100_s_set_wepkey(adev
);
3037 if (adev
->wep_keys
[adev
->wep_current_index
].size
!= 0) {
3038 log(L_ASSOC
, "setting active default WEP key number: %d\n",
3039 adev
->wep_current_index
);
3040 dk
.KeyID
= adev
->wep_current_index
;
3041 acx_s_configure(adev
, &dk
, ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET
); /* 0x1010 */
3043 /* FIXME!!! wep_key_struct is filled nowhere! But adev
3044 * is initialized to 0, and we don't REALLY need those keys either */
3045 /* for (i = 0; i < 10; i++) {
3046 if (adev->wep_key_struct[i].len != 0) {
3047 MAC_COPY(wep_mgmt.MacAddr, adev->wep_key_struct[i].addr);
3048 wep_mgmt.KeySize = cpu_to_le16(adev->wep_key_struct[i].len);
3049 memcpy(&wep_mgmt.Key, adev->wep_key_struct[i].key, le16_to_cpu(wep_mgmt.KeySize));
3050 wep_mgmt.Action = cpu_to_le16(1);
3051 log(L_ASSOC, "writing WEP key %d (len %d)\n", i, le16_to_cpu(wep_mgmt.KeySize));
3052 if (OK == acx_s_issue_cmd(adev, ACX1xx_CMD_WEP_MGMT, &wep_mgmt, sizeof(wep_mgmt))) {
3053 adev->wep_key_struct[i].index = i;
3059 /* now retrieve the updated WEPCacheEnd pointer... */
3060 if (OK
!= acx_s_interrogate(adev
, &pt
, ACX1xx_IE_MEMORY_MAP
)) {
3061 printk("%s: ACX1xx_IE_MEMORY_MAP read #2 FAILED\n",
3062 wiphy_name(adev
->ieee
->wiphy
));
3065 /* ...and tell it to start allocating templates at that location */
3066 /* (no endianness conversion needed) */
3067 pt
.PacketTemplateStart
= pt
.WEPCacheEnd
;
3069 if (OK
!= acx_s_configure(adev
, &pt
, ACX1xx_IE_MEMORY_MAP
)) {
3070 printk("%s: ACX1xx_IE_MEMORY_MAP write #2 FAILED\n",
3071 wiphy_name(adev
->ieee
->wiphy
));
3083 acx_s_init_max_template_generic(acx_device_t
* adev
, unsigned int len
,
3088 acx_template_nullframe_t null
;
3089 acx_template_beacon_t b
;
3090 acx_template_tim_t tim
;
3091 acx_template_probereq_t preq
;
3092 acx_template_proberesp_t presp
;
3095 memset(&templ
, 0, len
);
3096 templ
.null
.size
= cpu_to_le16(len
- 2);
3097 res
= acx_s_issue_cmd(adev
, cmd
, &templ
, len
);
3101 static inline int acx_s_init_max_null_data_template(acx_device_t
* adev
)
3103 return acx_s_init_max_template_generic(adev
,
3104 sizeof(acx_template_nullframe_t
),
3105 ACX1xx_CMD_CONFIG_NULL_DATA
);
3108 static inline int acx_s_init_max_beacon_template(acx_device_t
* adev
)
3110 return acx_s_init_max_template_generic(adev
,
3111 sizeof(acx_template_beacon_t
),
3112 ACX1xx_CMD_CONFIG_BEACON
);
3115 static inline int acx_s_init_max_tim_template(acx_device_t
* adev
)
3117 return acx_s_init_max_template_generic(adev
, sizeof(acx_template_tim_t
),
3118 ACX1xx_CMD_CONFIG_TIM
);
3121 static inline int acx_s_init_max_probe_response_template(acx_device_t
* adev
)
3123 return acx_s_init_max_template_generic(adev
,
3124 sizeof(acx_template_proberesp_t
),
3125 ACX1xx_CMD_CONFIG_PROBE_RESPONSE
);
3128 static inline int acx_s_init_max_probe_request_template(acx_device_t
* adev
)
3130 return acx_s_init_max_template_generic(adev
,
3131 sizeof(acx_template_probereq_t
),
3132 ACX1xx_CMD_CONFIG_PROBE_REQUEST
);
3135 /***********************************************************************
3136 ** acx_s_set_tim_template
3138 ** FIXME: In full blown driver we will regularly update partial virtual bitmap
3139 ** by calling this function
3140 ** (it can be done by irq handler on each DTIM irq or by timer...)
3142 [802.11 7.3.2.6] TIM information element:
3146 indicates how many beacons (including this) appear before next DTIM
3147 (0=this one is a DTIM)
3149 number of beacons between successive DTIMs
3150 (0=reserved, 1=all TIMs are DTIMs, 2=every other, etc)
3152 bit0: Traffic Indicator bit associated with Assoc ID 0 (Bcast AID?)
3153 set to 1 in TIM elements with a value of 0 in the DTIM Count field
3154 when one or more broadcast or multicast frames are buffered at the AP.
3155 bit1-7: Bitmap Offset (logically Bitmap_Offset = Bitmap_Control & 0xFE).
3156 4 n Partial Virtual Bitmap
3157 Visible part of traffic-indication bitmap.
3158 Full bitmap consists of 2008 bits (251 octets) such that bit number N
3159 (0<=N<=2007) in the bitmap corresponds to bit number (N mod 8)
3160 in octet number N/8 where the low-order bit of each octet is bit0,
3161 and the high order bit is bit7.
3162 Each set bit in virtual bitmap corresponds to traffic buffered by AP
3163 for a specific station (with corresponding AID?).
3164 Partial Virtual Bitmap shows a part of bitmap which has non-zero.
3165 Bitmap Offset is a number of skipped zero octets (see above).
3166 'Missing' octets at the tail are also assumed to be zero.
3167 Example: Length=6, Bitmap_Offset=2, Partial_Virtual_Bitmap=55 55 55
3168 This means that traffic-indication bitmap is:
3169 00000000 00000000 01010101 01010101 01010101 00000000 00000000...
3170 (is bit0 in the map is always 0 and real value is in Bitmap Control bit0?)
3172 static int acx_s_set_tim_template(acx_device_t
* adev
)
3174 /* For now, configure smallish test bitmap, all zero ("no pending data") */
3175 enum { bitmap_size
= 5 };
3177 acx_template_tim_t t
;
3182 memset(&t
, 0, sizeof(t
));
3183 t
.size
= 5 + bitmap_size
; /* eid+len+count+period+bmap_ctrl + bmap */
3184 t
.tim_eid
= WLAN_EID_TIM
;
3185 t
.len
= 3 + bitmap_size
; /* count+period+bmap_ctrl + bmap */
3186 result
= acx_s_issue_cmd(adev
, ACX1xx_CMD_CONFIG_TIM
, &t
, sizeof(t
));
3194 #if POWER_SAVE_80211
3195 /***********************************************************************
3196 ** acx_s_set_null_data_template
3198 static int acx_s_set_null_data_template(acx_device_t
* adev
)
3200 struct acx_template_nullframe b
;
3205 /* memset(&b, 0, sizeof(b)); not needed, setting all members */
3207 b
.size
= cpu_to_le16(sizeof(b
) - 2);
3208 b
.hdr
.fc
= WF_FTYPE_MGMTi
| WF_FSTYPE_NULLi
;
3210 MAC_BCAST(b
.hdr
.a1
);
3211 MAC_COPY(b
.hdr
.a2
, adev
->dev_addr
);
3212 MAC_COPY(b
.hdr
.a3
, adev
->bssid
);
3216 acx_s_issue_cmd(adev
, ACX1xx_CMD_CONFIG_NULL_DATA
, &b
, sizeof(b
));
3228 /***********************************************************************
3229 ** acx_s_init_packet_templates()
3231 ** NOTE: order is very important here, to have a correct memory layout!
3232 ** init templates: max Probe Request (station mode), max NULL data,
3233 ** max Beacon, max TIM, max Probe Response.
3235 static int acx_s_init_packet_templates(acx_device_t
* adev
)
3237 acx_ie_memmap_t mm
; /* ACX100 only */
3238 int result
= NOT_OK
;
3242 log(L_DEBUG
| L_INIT
, "initializing max packet templates\n");
3244 if (OK
!= acx_s_init_max_probe_request_template(adev
))
3247 if (OK
!= acx_s_init_max_null_data_template(adev
))
3250 if (OK
!= acx_s_init_max_beacon_template(adev
))
3253 if (OK
!= acx_s_init_max_tim_template(adev
))
3256 if (OK
!= acx_s_init_max_probe_response_template(adev
))
3259 if (IS_ACX111(adev
)) {
3260 /* ACX111 doesn't need the memory map magic below,
3261 * and the other templates will be set later (acx_start) */
3266 /* ACX100 will have its TIM template set,
3267 * and we also need to update the memory map */
3269 if (OK
!= acx_s_set_tim_template(adev
))
3272 log(L_DEBUG
, "sizeof(memmap)=%d bytes\n", (int)sizeof(mm
));
3274 if (OK
!= acx_s_interrogate(adev
, &mm
, ACX1xx_IE_MEMORY_MAP
))
3277 mm
.QueueStart
= cpu_to_le32(le32_to_cpu(mm
.PacketTemplateEnd
) + 4);
3278 if (OK
!= acx_s_configure(adev
, &mm
, ACX1xx_IE_MEMORY_MAP
))
3285 log(L_DEBUG
| L_INIT
,
3290 ".WEPCacheStart=0x%X\n"
3291 ".WEPCacheEnd=0x%X\n"
3292 ".PacketTemplateStart=0x%X\n" ".PacketTemplateEnd=0x%X\n",
3294 le32_to_cpu(mm
.CodeStart
),
3295 le32_to_cpu(mm
.CodeEnd
),
3296 le32_to_cpu(mm
.WEPCacheStart
),
3297 le32_to_cpu(mm
.WEPCacheEnd
),
3298 le32_to_cpu(mm
.PacketTemplateStart
),
3299 le32_to_cpu(mm
.PacketTemplateEnd
));
3302 printk("%s: %s() FAILED\n", wiphy_name(adev
->ieee
->wiphy
), __func__
);
3311 /***********************************************************************
3314 int acx_s_init_mac(acx_device_t
* adev
)
3316 int result
= NOT_OK
;
3320 if (IS_ACX111(adev
)) {
3321 adev
->ie_len
= acx111_ie_len
;
3322 adev
->ie_len_dot11
= acx111_ie_len_dot11
;
3324 adev
->ie_len
= acx100_ie_len
;
3325 adev
->ie_len_dot11
= acx100_ie_len_dot11
;
3329 adev
->memblocksize
= 256; /* 256 is default */
3330 /* try to load radio for both ACX100 and ACX111, since both
3331 * chips have at least some firmware versions making use of an
3332 * external radio module */
3333 acxpci_s_upload_radio(adev
);
3335 adev
->memblocksize
= 128;
3338 if (IS_ACX111(adev
)) {
3339 /* for ACX111, the order is different from ACX100
3340 1. init packet templates
3341 2. create station context and create dma regions
3342 3. init wep default keys
3344 if (OK
!= acx_s_init_packet_templates(adev
))
3346 if (OK
!= acx111_s_create_dma_regions(adev
)) {
3347 printk("%s: acx111_create_dma_regions FAILED\n",
3348 wiphy_name(adev
->ieee
->wiphy
));
3352 if (OK
!= acx100_s_init_wep(adev
))
3354 if (OK
!= acx_s_init_packet_templates(adev
))
3356 if (OK
!= acx100_s_create_dma_regions(adev
)) {
3357 printk("%s: acx100_create_dma_regions FAILED\n",
3358 wiphy_name(adev
->ieee
->wiphy
));
3363 SET_IEEE80211_PERM_ADDR(adev
->ieee
, adev
->dev_addr
);
3368 printk("acx: init_mac() FAILED\n");
3375 #if POWER_SAVE_80211
3376 static void acx_s_update_80211_powersave_mode(acx_device_t
* adev
)
3378 /* merge both structs in a union to be able to have common code */
3380 acx111_ie_powersave_t acx111
;
3381 acx100_ie_powersave_t acx100
;
3384 /* change 802.11 power save mode settings */
3385 log(L_INIT
, "updating 802.11 power save mode settings: "
3386 "wakeup_cfg 0x%02X, listen interval %u, "
3387 "options 0x%02X, hangover period %u, "
3388 "enhanced_ps_transition_time %u\n",
3389 adev
->ps_wakeup_cfg
, adev
->ps_listen_interval
,
3390 adev
->ps_options
, adev
->ps_hangover_period
,
3391 adev
->ps_enhanced_transition_time
);
3392 acx_s_interrogate(adev
, &pm
, ACX1xx_IE_POWER_MGMT
);
3393 log(L_INIT
, "Previous PS mode settings: wakeup_cfg 0x%02X, "
3394 "listen interval %u, options 0x%02X, "
3395 "hangover period %u, "
3396 "enhanced_ps_transition_time %u, beacon_rx_time %u\n",
3397 pm
.acx111
.wakeup_cfg
,
3398 pm
.acx111
.listen_interval
,
3400 pm
.acx111
.hangover_period
,
3402 pm
.acx111
.enhanced_ps_transition_time
3403 : pm
.acx100
.enhanced_ps_transition_time
,
3404 IS_ACX111(adev
) ? pm
.acx111
.beacon_rx_time
: (u32
) - 1);
3405 pm
.acx111
.wakeup_cfg
= adev
->ps_wakeup_cfg
;
3406 pm
.acx111
.listen_interval
= adev
->ps_listen_interval
;
3407 pm
.acx111
.options
= adev
->ps_options
;
3408 pm
.acx111
.hangover_period
= adev
->ps_hangover_period
;
3409 if (IS_ACX111(adev
)) {
3410 pm
.acx111
.beacon_rx_time
= cpu_to_le32(adev
->ps_beacon_rx_time
);
3411 pm
.acx111
.enhanced_ps_transition_time
=
3412 cpu_to_le32(adev
->ps_enhanced_transition_time
);
3414 pm
.acx100
.enhanced_ps_transition_time
=
3415 cpu_to_le16(adev
->ps_enhanced_transition_time
);
3417 acx_s_configure(adev
, &pm
, ACX1xx_IE_POWER_MGMT
);
3418 acx_s_interrogate(adev
, &pm
, ACX1xx_IE_POWER_MGMT
);
3419 log(L_INIT
, "wakeup_cfg: 0x%02X\n", pm
.acx111
.wakeup_cfg
);
3421 acx_s_interrogate(adev
, &pm
, ACX1xx_IE_POWER_MGMT
);
3422 log(L_INIT
, "wakeup_cfg: 0x%02X\n", pm
.acx111
.wakeup_cfg
);
3423 log(L_INIT
, "power save mode change %s\n",
3425 wakeup_cfg
& PS_CFG_PENDING
) ? "FAILED" : "was successful");
3426 /* FIXME: maybe verify via PS_CFG_PENDING bit here
3427 * that power save mode change was successful. */
3428 /* FIXME: we shouldn't trigger a scan immediately after
3429 * fiddling with power save mode (since the firmware is sending
3430 * a NULL frame then). */
3435 /***********************************************************************
3436 ** acx_s_update_card_settings
3438 ** Applies accumulated changes in various adev->xxxx members
3439 ** Called by ioctl commit handler, acx_start, acx_set_defaults,
3440 ** acx_s_after_interrupt_task (if IRQ_CMD_UPDATE_CARD_CFG),
3442 void acx_s_set_sane_reg_domain(acx_device_t
*adev
, int do_set
)
3448 for (i
= 0; i
< sizeof(acx_reg_domain_ids
); i
++)
3449 if (acx_reg_domain_ids
[i
] == adev
->reg_dom_id
)
3452 if (sizeof(acx_reg_domain_ids
) == i
) {
3453 log(L_INIT
, "Invalid or unsupported regulatory domain"
3454 " 0x%02X specified, falling back to FCC (USA)!"
3455 " Please report if this sounds fishy!\n",
3458 adev
->reg_dom_id
= acx_reg_domain_ids
[i
];
3460 /* since there was a mismatch, we need to force updating */
3465 acx_ie_generic_t dom
;
3466 dom
.m
.bytes
[0] = adev
->reg_dom_id
;
3467 acx_s_configure(adev
, &dom
, ACX1xx_IE_DOT11_CURRENT_REG_DOMAIN
);
3470 adev
->reg_dom_chanmask
= reg_domain_channel_masks
[i
];
3472 mask
= (1 << (adev
->channel
- 1));
3473 if (!(adev
->reg_dom_chanmask
& mask
)) {
3474 /* hmm, need to adjust our channel to reside within domain */
3476 for (i
= 1; i
<= 14; i
++) {
3477 if (adev
->reg_dom_chanmask
& mask
) {
3478 printk("%s: adjusting selected channel from %d "
3479 "to %d due to new regulatory domain\n",
3480 wiphy_name(adev
->ieee
->wiphy
), adev
->channel
, i
);
3489 static void acx111_s_sens_radio_16_17(acx_device_t
* adev
)
3491 u32 feature1
, feature2
;
3493 if ((adev
->sensitivity
< 1) || (adev
->sensitivity
> 3)) {
3494 printk("%s: invalid sensitivity setting (1..3), "
3495 "setting to 1\n", wiphy_name(adev
->ieee
->wiphy
));
3496 adev
->sensitivity
= 1;
3498 acx111_s_get_feature_config(adev
, &feature1
, &feature2
);
3499 CLEAR_BIT(feature1
, FEATURE1_LOW_RX
| FEATURE1_EXTRA_LOW_RX
);
3500 if (adev
->sensitivity
> 1)
3501 SET_BIT(feature1
, FEATURE1_LOW_RX
);
3502 if (adev
->sensitivity
> 2)
3503 SET_BIT(feature1
, FEATURE1_EXTRA_LOW_RX
);
3504 acx111_s_feature_set(adev
, feature1
, feature2
);
3508 void acx_s_update_card_settings(acx_device_t
*adev
)
3510 unsigned long flags
;
3511 unsigned int start_scan
= 0;
3516 log(L_INIT
, "get_mask 0x%08X, set_mask 0x%08X\n",
3517 adev
->get_mask
, adev
->set_mask
);
3519 /* Track dependencies betweed various settings */
3521 if (adev
->set_mask
& (GETSET_MODE
| GETSET_RESCAN
| GETSET_WEP
)) {
3522 log(L_INIT
, "important setting has been changed. "
3523 "Need to update packet templates, too\n");
3524 SET_BIT(adev
->set_mask
, SET_TEMPLATES
);
3526 if (adev
->set_mask
& GETSET_CHANNEL
) {
3527 /* This will actually tune RX/TX to the channel */
3528 SET_BIT(adev
->set_mask
, GETSET_RX
| GETSET_TX
);
3529 switch (adev
->mode
) {
3530 case ACX_MODE_0_ADHOC
:
3532 /* Beacons contain channel# - update them */
3533 SET_BIT(adev
->set_mask
, SET_TEMPLATES
);
3536 switch (adev
->mode
) {
3537 case ACX_MODE_0_ADHOC
:
3538 case ACX_MODE_2_STA
:
3543 /* Apply settings */
3546 if (adev
->get_mask
& GETSET_STATION_ID
) {
3547 u8 stationID
[4 + ACX1xx_IE_DOT11_STATION_ID_LEN
];
3550 acx_s_interrogate(adev
, &stationID
, ACX1xx_IE_DOT11_STATION_ID
);
3551 paddr
= &stationID
[4];
3552 // memcpy(adev->dev_addr, adev->ndev->dev_addr, ETH_ALEN);
3553 for (i
= 0; i
< ETH_ALEN
; i
++) {
3554 /* we copy the MAC address (reversed in
3555 * the card) to the netdevice's MAC
3556 * address, and on ifup it will be
3557 * copied into iwadev->dev_addr */
3558 adev
->dev_addr
[ETH_ALEN
- 1 - i
] = paddr
[i
];
3560 SET_IEEE80211_PERM_ADDR(adev
->ieee
,adev
->dev_addr
);
3561 CLEAR_BIT(adev
->get_mask
, GETSET_STATION_ID
);
3564 if (adev
->get_mask
& GETSET_SENSITIVITY
) {
3565 if ((RADIO_RFMD_11
== adev
->radio_type
)
3566 || (RADIO_MAXIM_0D
== adev
->radio_type
)
3567 || (RADIO_RALINK_15
== adev
->radio_type
)) {
3568 acx_s_read_phy_reg(adev
, 0x30, &adev
->sensitivity
);
3570 log(L_INIT
, "don't know how to get sensitivity "
3571 "for radio type 0x%02X\n", adev
->radio_type
);
3572 adev
->sensitivity
= 0;
3574 log(L_INIT
, "got sensitivity value %u\n", adev
->sensitivity
);
3576 CLEAR_BIT(adev
->get_mask
, GETSET_SENSITIVITY
);
3579 if (adev
->get_mask
& GETSET_ANTENNA
) {
3580 u8 antenna
[4 + ACX1xx_IE_DOT11_CURRENT_ANTENNA_LEN
];
3582 memset(antenna
, 0, sizeof(antenna
));
3583 acx_s_interrogate(adev
, antenna
,
3584 ACX1xx_IE_DOT11_CURRENT_ANTENNA
);
3585 adev
->antenna
= antenna
[4];
3586 log(L_INIT
, "got antenna value 0x%02X\n", adev
->antenna
);
3587 CLEAR_BIT(adev
->get_mask
, GETSET_ANTENNA
);
3590 if (adev
->get_mask
& GETSET_ED_THRESH
) {
3591 if (IS_ACX100(adev
)) {
3592 u8 ed_threshold
[4 + ACX100_IE_DOT11_ED_THRESHOLD_LEN
];
3594 memset(ed_threshold
, 0, sizeof(ed_threshold
));
3595 acx_s_interrogate(adev
, ed_threshold
,
3596 ACX100_IE_DOT11_ED_THRESHOLD
);
3597 adev
->ed_threshold
= ed_threshold
[4];
3599 log(L_INIT
, "acx111 doesn't support ED\n");
3600 adev
->ed_threshold
= 0;
3602 log(L_INIT
, "got Energy Detect (ED) threshold %u\n",
3603 adev
->ed_threshold
);
3604 CLEAR_BIT(adev
->get_mask
, GETSET_ED_THRESH
);
3607 if (adev
->get_mask
& GETSET_CCA
) {
3608 if (IS_ACX100(adev
)) {
3609 u8 cca
[4 + ACX1xx_IE_DOT11_CURRENT_CCA_MODE_LEN
];
3611 memset(cca
, 0, sizeof(adev
->cca
));
3612 acx_s_interrogate(adev
, cca
,
3613 ACX1xx_IE_DOT11_CURRENT_CCA_MODE
);
3616 log(L_INIT
, "acx111 doesn't support CCA\n");
3619 log(L_INIT
, "got Channel Clear Assessment (CCA) value %u\n",
3621 CLEAR_BIT(adev
->get_mask
, GETSET_CCA
);
3624 if (adev
->get_mask
& GETSET_REG_DOMAIN
) {
3625 acx_ie_generic_t dom
;
3627 acx_s_interrogate(adev
, &dom
,
3628 ACX1xx_IE_DOT11_CURRENT_REG_DOMAIN
);
3629 adev
->reg_dom_id
= dom
.m
.bytes
[0];
3630 acx_s_set_sane_reg_domain(adev
, 0);
3631 log(L_INIT
, "got regulatory domain 0x%02X\n", adev
->reg_dom_id
);
3632 CLEAR_BIT(adev
->get_mask
, GETSET_REG_DOMAIN
);
3635 if (adev
->set_mask
& GETSET_STATION_ID
) {
3636 u8 stationID
[4 + ACX1xx_IE_DOT11_STATION_ID_LEN
];
3639 paddr
= &stationID
[4];
3640 MAC_COPY(adev
->dev_addr
, adev
->ieee
->wiphy
->perm_addr
);
3641 for (i
= 0; i
< ETH_ALEN
; i
++) {
3642 /* copy the MAC address we obtained when we noticed
3643 * that the ethernet iface's MAC changed
3644 * to the card (reversed in
3646 paddr
[i
] = adev
->dev_addr
[ETH_ALEN
- 1 - i
];
3648 acx_s_configure(adev
, &stationID
, ACX1xx_IE_DOT11_STATION_ID
);
3649 CLEAR_BIT(adev
->set_mask
, GETSET_STATION_ID
);
3652 if (adev
->set_mask
& SET_STA_LIST
) {
3653 CLEAR_BIT(adev
->set_mask
, SET_STA_LIST
);
3655 if (adev
->set_mask
& SET_RATE_FALLBACK
) {
3656 u8 rate
[4 + ACX1xx_IE_RATE_FALLBACK_LEN
];
3658 /* configure to not do fallbacks when not in auto rate mode */
3661 rate_auto
) ? /* adev->txrate_fallback_retries */ 1 : 0;
3662 log(L_INIT
, "updating Tx fallback to %u retries\n", rate
[4]);
3663 acx_s_configure(adev
, &rate
, ACX1xx_IE_RATE_FALLBACK
);
3664 CLEAR_BIT(adev
->set_mask
, SET_RATE_FALLBACK
);
3666 if (adev
->set_mask
& GETSET_TXPOWER
) {
3667 log(L_INIT
, "updating transmit power: %u dBm\n",
3668 adev
->tx_level_dbm
);
3669 acx_s_set_tx_level(adev
, adev
->tx_level_dbm
);
3670 CLEAR_BIT(adev
->set_mask
, GETSET_TXPOWER
);
3673 if (adev
->set_mask
& GETSET_SENSITIVITY
) {
3674 log(L_INIT
, "updating sensitivity value: %u\n",
3676 switch (adev
->radio_type
) {
3678 case RADIO_MAXIM_0D
:
3679 case RADIO_RALINK_15
:
3680 acx_s_write_phy_reg(adev
, 0x30, adev
->sensitivity
);
3682 case RADIO_RADIA_16
:
3683 case RADIO_UNKNOWN_17
:
3684 acx111_s_sens_radio_16_17(adev
);
3687 log(L_INIT
, "don't know how to modify sensitivity "
3688 "for radio type 0x%02X\n", adev
->radio_type
);
3690 CLEAR_BIT(adev
->set_mask
, GETSET_SENSITIVITY
);
3693 if (adev
->set_mask
& GETSET_ANTENNA
) {
3695 u8 antenna
[4 + ACX1xx_IE_DOT11_CURRENT_ANTENNA_LEN
];
3697 memset(antenna
, 0, sizeof(antenna
));
3698 antenna
[4] = adev
->antenna
;
3699 log(L_INIT
, "updating antenna value: 0x%02X\n", adev
->antenna
);
3700 acx_s_configure(adev
, &antenna
,
3701 ACX1xx_IE_DOT11_CURRENT_ANTENNA
);
3702 CLEAR_BIT(adev
->set_mask
, GETSET_ANTENNA
);
3705 if (adev
->set_mask
& GETSET_ED_THRESH
) {
3707 log(L_INIT
, "updating Energy Detect (ED) threshold: %u\n",
3708 adev
->ed_threshold
);
3709 if (IS_ACX100(adev
)) {
3710 u8 ed_threshold
[4 + ACX100_IE_DOT11_ED_THRESHOLD_LEN
];
3712 memset(ed_threshold
, 0, sizeof(ed_threshold
));
3713 ed_threshold
[4] = adev
->ed_threshold
;
3714 acx_s_configure(adev
, &ed_threshold
,
3715 ACX100_IE_DOT11_ED_THRESHOLD
);
3717 log(L_INIT
, "acx111 doesn't support ED!\n");
3718 CLEAR_BIT(adev
->set_mask
, GETSET_ED_THRESH
);
3721 if (adev
->set_mask
& GETSET_CCA
) {
3723 log(L_INIT
, "updating Channel Clear Assessment "
3724 "(CCA) value: 0x%02X\n", adev
->cca
);
3725 if (IS_ACX100(adev
)) {
3726 u8 cca
[4 + ACX1xx_IE_DOT11_CURRENT_CCA_MODE_LEN
];
3728 memset(cca
, 0, sizeof(cca
));
3730 acx_s_configure(adev
, &cca
,
3731 ACX1xx_IE_DOT11_CURRENT_CCA_MODE
);
3733 log(L_INIT
, "acx111 doesn't support CCA!\n");
3734 CLEAR_BIT(adev
->set_mask
, GETSET_CCA
);
3737 if (adev
->set_mask
& GETSET_LED_POWER
) {
3739 log(L_INIT
, "updating power LED status: %u\n", adev
->led_power
);
3741 acx_lock(adev
, flags
); /* acxpci_l_power_led expects that the lock is already taken! */
3743 acxpci_l_power_led(adev
, adev
->led_power
);
3744 CLEAR_BIT(adev
->set_mask
, GETSET_LED_POWER
);
3745 acx_unlock(adev
, flags
);
3748 if (adev
->set_mask
& GETSET_POWER_80211
) {
3749 #if POWER_SAVE_80211
3750 acx_s_update_80211_powersave_mode(adev
);
3752 CLEAR_BIT(adev
->set_mask
, GETSET_POWER_80211
);
3755 if (adev
->set_mask
& GETSET_CHANNEL
) {
3757 log(L_INIT
, "updating channel to: %u\n", adev
->channel
);
3758 CLEAR_BIT(adev
->set_mask
, GETSET_CHANNEL
);
3761 if (adev
->set_mask
& GETSET_TX
) {
3763 log(L_INIT
, "updating: %s Tx\n",
3764 adev
->tx_disabled
? "disable" : "enable");
3765 if (adev
->tx_disabled
)
3766 acx_s_issue_cmd(adev
, ACX1xx_CMD_DISABLE_TX
, NULL
, 0);
3768 acx_s_issue_cmd(adev
, ACX1xx_CMD_ENABLE_TX
,
3771 /* This needs to be keyed on WEP? */
3772 /* acx111_s_feature_on(adev, 0,
3773 FEATURE2_NO_TXCRYPT |
3774 FEATURE2_SNIFFER); */
3775 acx_wake_queue(adev
->ieee
, NULL
);
3777 CLEAR_BIT(adev
->set_mask
, GETSET_TX
);
3780 if (adev
->set_mask
& GETSET_RX
) {
3782 log(L_INIT
, "updating: enable Rx on channel: %u\n",
3784 acx_s_issue_cmd(adev
, ACX1xx_CMD_ENABLE_RX
, &adev
->channel
, 1);
3785 CLEAR_BIT(adev
->set_mask
, GETSET_RX
);
3788 if (adev
->set_mask
& GETSET_RETRY
) {
3789 u8 short_retry
[4 + ACX1xx_IE_DOT11_SHORT_RETRY_LIMIT_LEN
];
3790 u8 long_retry
[4 + ACX1xx_IE_DOT11_LONG_RETRY_LIMIT_LEN
];
3793 "updating short retry limit: %u, long retry limit: %u\n",
3794 adev
->short_retry
, adev
->long_retry
);
3795 short_retry
[0x4] = adev
->short_retry
;
3796 long_retry
[0x4] = adev
->long_retry
;
3797 acx_s_configure(adev
, &short_retry
,
3798 ACX1xx_IE_DOT11_SHORT_RETRY_LIMIT
);
3799 acx_s_configure(adev
, &long_retry
,
3800 ACX1xx_IE_DOT11_LONG_RETRY_LIMIT
);
3801 CLEAR_BIT(adev
->set_mask
, GETSET_RETRY
);
3804 if (adev
->set_mask
& SET_MSDU_LIFETIME
) {
3805 u8 xmt_msdu_lifetime
[4 +
3806 ACX1xx_IE_DOT11_MAX_XMIT_MSDU_LIFETIME_LEN
];
3808 log(L_INIT
, "updating tx MSDU lifetime: %u\n",
3809 adev
->msdu_lifetime
);
3810 *(u32
*) & xmt_msdu_lifetime
[4] =
3811 cpu_to_le32((u32
) adev
->msdu_lifetime
);
3812 acx_s_configure(adev
, &xmt_msdu_lifetime
,
3813 ACX1xx_IE_DOT11_MAX_XMIT_MSDU_LIFETIME
);
3814 CLEAR_BIT(adev
->set_mask
, SET_MSDU_LIFETIME
);
3817 if (adev
->set_mask
& GETSET_REG_DOMAIN
) {
3818 log(L_INIT
, "updating regulatory domain: 0x%02X\n",
3820 acx_s_set_sane_reg_domain(adev
, 1);
3821 CLEAR_BIT(adev
->set_mask
, GETSET_REG_DOMAIN
);
3823 if (adev
->set_mask
& GETSET_MODE
) {
3824 acx111_s_feature_on(adev
, 0,
3825 FEATURE2_NO_TXCRYPT
| FEATURE2_SNIFFER
);
3826 switch (adev
->mode
) {
3829 //acx111_s_feature_off(adev, 0,
3830 // FEATURE2_NO_TXCRYPT | FEATURE2_SNIFFER);
3831 MAC_COPY(adev
->bssid
, adev
->dev_addr
);
3832 acx_s_cmd_join_bssid(adev
, adev
->dev_addr
);
3834 case ACX_MODE_MONITOR
:
3835 SET_BIT(adev
->set_mask
, SET_RXCONFIG
| SET_WEP_OPTIONS
);
3837 case ACX_MODE_0_ADHOC
:
3838 case ACX_MODE_2_STA
:
3839 acx111_s_feature_on(adev
, 0, FEATURE2_NO_TXCRYPT
| FEATURE2_SNIFFER
);
3844 CLEAR_BIT(adev
->set_mask
, GETSET_MODE
);
3846 if (adev
->set_mask
& SET_TEMPLATES
) {
3850 acx_s_set_tim_template(adev
);
3855 if (adev
->beacon_cache
)
3857 acx_s_set_beacon_template(adev
, adev
->beacon_cache
);
3858 dev_kfree_skb(adev
->beacon_cache
);
3859 adev
->beacon_cache
= NULL
;
3861 CLEAR_BIT(adev
->set_mask
, SET_TEMPLATES
);
3864 if (adev
->set_mask
& SET_RXCONFIG
) {
3865 acx_s_initialize_rx_config(adev
);
3866 CLEAR_BIT(adev
->set_mask
, SET_RXCONFIG
);
3869 if (adev
->set_mask
& GETSET_RESCAN
) {
3870 /* switch (adev->mode) {
3871 case ACX_MODE_0_ADHOC:
3872 case ACX_MODE_2_STA:
3876 */ CLEAR_BIT(adev
->set_mask
, GETSET_RESCAN
);
3879 if (adev
->set_mask
& GETSET_WEP
) {
3882 ie_dot11WEPDefaultKeyID_t dkey
;
3888 } ACX_PACKED keyindic
;
3890 log(L_INIT
, "updating WEP key settings\n");
3892 acx_s_set_wepkey(adev
);
3893 if (adev
->wep_enabled
) {
3894 dkey
.KeyID
= adev
->wep_current_index
;
3895 log(L_INIT
, "setting WEP key %u as default\n",
3897 acx_s_configure(adev
, &dkey
,
3898 ACX1xx_IE_DOT11_WEP_DEFAULT_KEY_SET
);
3901 acx_s_configure(adev
, &keyindic
, ACX111_IE_KEY_CHOOSE
);
3906 CLEAR_BIT(adev
->set_mask
, GETSET_WEP
);
3909 if (adev
->set_mask
& SET_WEP_OPTIONS
) {
3910 acx100_ie_wep_options_t options
;
3912 if (IS_ACX111(adev
)) {
3914 "setting WEP Options for acx111 is not supported\n");
3916 log(L_INIT
, "setting WEP Options\n");
3918 /* let's choose maximum setting: 4 default keys,
3919 * plus 10 other keys: */
3921 cpu_to_le16(DOT11_MAX_DEFAULT_WEP_KEYS
+ 10);
3922 /* don't decrypt default key only,
3923 * don't override decryption: */
3924 options
.WEPOption
= 0;
3925 if (adev
->mode
== ACX_MODE_3_AP
) {
3926 /* don't decrypt default key only,
3927 * override decryption mechanism: */
3928 options
.WEPOption
= 2;
3931 acx_s_configure(adev
, &options
, ACX100_IE_WEP_OPTIONS
);
3933 CLEAR_BIT(adev
->set_mask
, SET_WEP_OPTIONS
);
3937 /* debug, rate, and nick don't need any handling */
3938 /* what about sniffing mode?? */
3940 /* log(L_INIT, "get_mask 0x%08X, set_mask 0x%08X - after update\n",
3941 adev->get_mask, adev->set_mask);
3948 /***********************************************************************
3949 ** acx_e_after_interrupt_task
3951 static int acx_s_recalib_radio(acx_device_t
* adev
)
3953 if (IS_ACX111(adev
)) {
3954 acx111_cmd_radiocalib_t cal
;
3956 /* automatic recalibration, choose all methods: */
3957 cal
.methods
= cpu_to_le32(0x8000000f);
3958 /* automatic recalibration every 60 seconds (value in TUs)
3959 * I wonder what the firmware default here is? */
3960 cal
.interval
= cpu_to_le32(58594);
3961 return acx_s_issue_cmd_timeo(adev
, ACX111_CMD_RADIOCALIB
,
3963 CMD_TIMEOUT_MS(100));
3965 /* On ACX100, we need to recalibrate the radio
3966 * by issuing a GETSET_TX|GETSET_RX */
3967 if ( /* (OK == acx_s_issue_cmd(adev, ACX1xx_CMD_DISABLE_TX, NULL, 0)) &&
3968 (OK == acx_s_issue_cmd(adev, ACX1xx_CMD_DISABLE_RX, NULL, 0)) && */
3970 acx_s_issue_cmd(adev
, ACX1xx_CMD_ENABLE_TX
,
3973 acx_s_issue_cmd(adev
, ACX1xx_CMD_ENABLE_RX
,
3974 &adev
->channel
, 1)))
3981 static void acx_s_after_interrupt_recalib(acx_device_t
* adev
)
3985 /* this helps with ACX100 at least;
3986 * hopefully ACX111 also does a
3987 * recalibration here */
3989 /* clear flag beforehand, since we want to make sure
3990 * it's cleared; then only set it again on specific circumstances */
3991 CLEAR_BIT(adev
->after_interrupt_jobs
, ACX_AFTER_IRQ_CMD_RADIO_RECALIB
);
3993 /* better wait a bit between recalibrations to
3994 * prevent overheating due to torturing the card
3995 * into working too long despite high temperature
3996 * (just a safety measure) */
3997 if (adev
->recalib_time_last_success
3998 && time_before(jiffies
, adev
->recalib_time_last_success
3999 + RECALIB_PAUSE
* 60 * HZ
)) {
4000 if (adev
->recalib_msg_ratelimit
<= 4) {
4001 printk("%s: less than " STRING(RECALIB_PAUSE
)
4002 " minutes since last radio recalibration, "
4003 "not recalibrating (maybe card is too hot?)\n",
4004 wiphy_name(adev
->ieee
->wiphy
));
4005 adev
->recalib_msg_ratelimit
++;
4006 if (adev
->recalib_msg_ratelimit
== 5)
4007 printk("disabling above message until next recalib\n");
4012 adev
->recalib_msg_ratelimit
= 0;
4014 /* note that commands sometimes fail (card busy),
4015 * so only clear flag if we were fully successful */
4016 res
= acx_s_recalib_radio(adev
);
4018 printk("%s: successfully recalibrated radio\n",
4019 wiphy_name(adev
->ieee
->wiphy
));
4020 adev
->recalib_time_last_success
= jiffies
;
4021 adev
->recalib_failure_count
= 0;
4023 /* failed: resubmit, but only limited
4024 * amount of times within some time range
4025 * to prevent endless loop */
4027 adev
->recalib_time_last_success
= 0; /* we failed */
4029 /* if some time passed between last
4030 * attempts, then reset failure retry counter
4031 * to be able to do next recalib attempt */
4033 (jiffies
, adev
->recalib_time_last_attempt
+ 5 * HZ
))
4034 adev
->recalib_failure_count
= 0;
4036 if (adev
->recalib_failure_count
< 5) {
4037 /* increment inside only, for speedup of outside path */
4038 adev
->recalib_failure_count
++;
4039 adev
->recalib_time_last_attempt
= jiffies
;
4040 acx_schedule_task(adev
,
4041 ACX_AFTER_IRQ_CMD_RADIO_RECALIB
);
4047 void acx_e_after_interrupt_task(struct work_struct
*work
)
4049 acx_device_t
*adev
= container_of(work
, acx_device_t
, after_interrupt_task
);
4050 unsigned long flags
;
4054 acx_lock(adev
, flags
);
4056 if (!adev
->after_interrupt_jobs
|| !adev
->initialized
)
4057 goto end
; /* no jobs to do */
4059 /* we see lotsa tx errors */
4060 if (adev
->after_interrupt_jobs
& ACX_AFTER_IRQ_CMD_RADIO_RECALIB
) {
4061 // acx_s_after_interrupt_recalib(adev);
4064 /* a poor interrupt code wanted to do update_card_settings() */
4065 if (adev
->after_interrupt_jobs
& ACX_AFTER_IRQ_UPDATE_CARD_CFG
) {
4066 if (ACX_STATE_IFACE_UP
& adev
->dev_state_mask
) {
4067 acx_unlock(adev
, flags
);
4068 acx_s_update_card_settings(adev
);
4069 acx_lock(adev
, flags
);
4071 CLEAR_BIT(adev
->after_interrupt_jobs
,
4072 ACX_AFTER_IRQ_UPDATE_CARD_CFG
);
4075 /* 1) we detected that no Scan_Complete IRQ came from fw, or
4076 ** 2) we found too many STAs */
4077 if (adev
->after_interrupt_jobs
& ACX_AFTER_IRQ_CMD_STOP_SCAN
) {
4078 log(L_IRQ
, "sending a stop scan cmd...\n");
4079 acx_unlock(adev
, flags
);
4080 acx_s_issue_cmd(adev
, ACX1xx_CMD_STOP_SCAN
, NULL
, 0);
4081 acx_lock(adev
, flags
);
4082 /* HACK: set the IRQ bit, since we won't get a
4083 * scan complete IRQ any more on ACX111 (works on ACX100!),
4084 * since _we_, not a fw, have stopped the scan */
4085 SET_BIT(adev
->irq_status
, HOST_INT_SCAN_COMPLETE
);
4086 CLEAR_BIT(adev
->after_interrupt_jobs
,
4087 ACX_AFTER_IRQ_CMD_STOP_SCAN
);
4090 /* either fw sent Scan_Complete or we detected that
4091 ** no Scan_Complete IRQ came from fw. Finish scanning,
4092 ** pick join partner if any */
4093 if (adev
->after_interrupt_jobs
& ACX_AFTER_IRQ_COMPLETE_SCAN
) {
4094 /* + scan kills current join status - restore it
4095 ** (do we need it for STA?) */
4096 /* + does it happen only with active scans?
4097 ** active and passive scans? ALL scans including
4098 ** background one? */
4099 /* + was not verified that everything is restored
4100 ** (but at least we start to emit beacons again) */
4101 CLEAR_BIT(adev
->after_interrupt_jobs
,
4102 ACX_AFTER_IRQ_COMPLETE_SCAN
);
4105 /* STA auth or assoc timed out, start over again */
4107 if (adev
->after_interrupt_jobs
& ACX_AFTER_IRQ_RESTART_SCAN
) {
4108 log(L_IRQ
, "sending a start_scan cmd...\n");
4109 CLEAR_BIT(adev
->after_interrupt_jobs
,
4110 ACX_AFTER_IRQ_RESTART_SCAN
);
4113 /* whee, we got positive assoc response! 8) */
4114 if (adev
->after_interrupt_jobs
& ACX_AFTER_IRQ_CMD_ASSOCIATE
) {
4115 CLEAR_BIT(adev
->after_interrupt_jobs
,
4116 ACX_AFTER_IRQ_CMD_ASSOCIATE
);
4119 if(adev
->after_interrupt_jobs
)
4121 printk("Jobs still to be run: %x\n",adev
->after_interrupt_jobs
);
4122 adev
->after_interrupt_jobs
= 0;
4124 acx_unlock(adev
, flags
);
4125 // acx_sem_unlock(adev);
4130 /***********************************************************************
4131 ** acx_schedule_task
4133 ** Schedule the call of the after_interrupt method after leaving
4134 ** the interrupt context.
4136 void acx_schedule_task(acx_device_t
* adev
, unsigned int set_flag
)
4138 if (!adev
->after_interrupt_jobs
)
4140 SET_BIT(adev
->after_interrupt_jobs
, set_flag
);
4141 schedule_work(&adev
->after_interrupt_task
);
4146 /***********************************************************************
4148 void acx_init_task_scheduler(acx_device_t
* adev
)
4150 /* configure task scheduler */
4151 INIT_WORK(&adev
->after_interrupt_task
, acx_interrupt_tasklet
);
4155 /***********************************************************************
4158 void acx_s_start(acx_device_t
* adev
)
4163 * Ok, now we do everything that can possibly be done with ioctl
4164 * calls to make sure that when it was called before the card
4165 * was up we get the changes asked for
4168 SET_BIT(adev
->set_mask
, SET_TEMPLATES
| SET_STA_LIST
| GETSET_WEP
4169 | GETSET_TXPOWER
| GETSET_ANTENNA
| GETSET_ED_THRESH
|
4170 GETSET_CCA
| GETSET_REG_DOMAIN
| GETSET_MODE
| GETSET_CHANNEL
|
4171 GETSET_TX
| GETSET_RX
| GETSET_STATION_ID
);
4173 log(L_INIT
, "updating initial settings on iface activation\n");
4174 acx_s_update_card_settings(adev
);
4180 /***********************************************************************
4181 ** acx_update_capabilities
4183 void acx_update_capabilities(acx_device_t * adev)
4187 switch (adev->mode) {
4189 SET_BIT(cap, WF_MGMT_CAP_ESS);
4191 case ACX_MODE_0_ADHOC:
4192 SET_BIT(cap, WF_MGMT_CAP_IBSS);
4194 */ /* other types of stations do not emit beacons */
4197 if (adev->wep_restricted) {
4198 SET_BIT(cap, WF_MGMT_CAP_PRIVACY);
4200 if (adev->cfgopt_dot11ShortPreambleOption) {
4201 SET_BIT(cap, WF_MGMT_CAP_SHORT);
4203 if (adev->cfgopt_dot11PBCCOption) {
4204 SET_BIT(cap, WF_MGMT_CAP_PBCC);
4206 if (adev->cfgopt_dot11ChannelAgility) {
4207 SET_BIT(cap, WF_MGMT_CAP_AGILITY);
4209 log(L_DEBUG, "caps updated from 0x%04X to 0x%04X\n",
4210 adev->capabilities, cap);
4211 adev->capabilities = cap;
4215 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4218 static void acx_s_select_opmode(acx_device_t
* adev
)
4223 if (adev
->interface
.operating
) {
4224 switch (adev
->interface
.type
) {
4225 case IEEE80211_IF_TYPE_AP
:
4226 if (adev
->mode
!= ACX_MODE_3_AP
)
4228 adev
->mode
= ACX_MODE_3_AP
;
4232 case IEEE80211_IF_TYPE_IBSS
:
4233 if (adev
->mode
!= ACX_MODE_0_ADHOC
)
4235 adev
->mode
= ACX_MODE_0_ADHOC
;
4239 case IEEE80211_IF_TYPE_STA
:
4240 if (adev
->mode
!= ACX_MODE_2_STA
)
4242 adev
->mode
= ACX_MODE_2_STA
;
4246 case IEEE80211_IF_TYPE_WDS
:
4248 if (adev
->mode
!= ACX_MODE_OFF
)
4250 adev
->mode
= ACX_MODE_OFF
;
4256 if (adev
->interface
.type
== IEEE80211_IF_TYPE_MNTR
)
4258 if (adev
->mode
!= ACX_MODE_MONITOR
)
4260 adev
->mode
= ACX_MODE_MONITOR
;
4266 if (adev
->mode
!= ACX_MODE_OFF
)
4268 adev
->mode
= ACX_MODE_OFF
;
4275 SET_BIT(adev
->set_mask
, GETSET_MODE
);
4276 acx_s_update_card_settings(adev
);
4277 // acx_schedule_task(adev, ACX_AFTER_IRQ_UPDATE_CARD_CFG);
4284 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4288 int acx_add_interface(struct ieee80211_hw
*ieee
,
4289 struct ieee80211_if_init_conf
*conf
)
4291 acx_device_t
*adev
= ieee2adev(ieee
);
4292 unsigned long flags
;
4293 int err
= -EOPNOTSUPP
;
4295 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
4296 DECLARE_MAC_BUF(mac
);
4300 acx_lock(adev
, flags
);
4302 if (conf
->type
== IEEE80211_IF_TYPE_MNTR
) {
4303 adev
->interface
.monitor
++;
4305 if (adev
->interface
.operating
)
4307 adev
->interface
.operating
= 1;
4309 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
4310 adev
->vif
= conf
->vif
;
4312 adev
->interface
.if_id
= conf
->if_id
;
4315 adev
->interface
.mac_addr
= conf
->mac_addr
;
4316 adev
->interface
.type
= conf
->type
;
4318 // adev->mode = conf->type;
4320 acx_unlock(adev
, flags
);
4322 if (adev
->initialized
)
4323 acx_s_select_opmode(adev
);
4325 acx_lock(adev
, flags
);
4329 printk(KERN_INFO
"Virtual interface added "
4330 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
4331 "(type: 0x%08X), ID: %pd, MAC: %s\n",
4334 print_mac(mac
, conf
->mac_addr
));
4336 "(type: 0x%08X, ID: %d, MAC: %s)\n",
4339 print_mac(mac
, conf
->mac_addr
));
4343 acx_unlock(adev
, flags
);
4349 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4353 void acx_remove_interface(struct ieee80211_hw
*hw
,
4354 struct ieee80211_if_init_conf
*conf
)
4356 acx_device_t
*adev
= ieee2adev(hw
);
4357 unsigned long flags
;
4359 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
4360 DECLARE_MAC_BUF(mac
);
4365 acx_lock(adev
, flags
);
4366 if (conf
->type
== IEEE80211_IF_TYPE_MNTR
) {
4367 adev
->interface
.monitor
--;
4368 // assert(bcm->interface.monitor >= 0);
4370 adev
->interface
.operating
= 0;
4372 printk("Removing interface: %d %d\n", adev
->interface
.operating
, conf
->type
);
4373 acx_unlock(adev
, flags
);
4375 if (adev
->initialized
)
4376 acx_s_select_opmode(adev
);
4377 flush_scheduled_work();
4379 printk(KERN_INFO
"Virtual interface removed "
4380 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
4381 "(type: 0x%08X, ID: %pd, MAC: %s)\n",
4384 print_mac(mac
, conf
->mac_addr
));
4387 "(type: 0x%08X, ID: %d, MAC: %s)\n",
4388 conf
->type
, conf
->if_id
, print_mac(mac
, conf
->mac_addr
));
4393 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4397 int acx_net_reset(struct ieee80211_hw
*ieee
)
4399 acx_device_t
*adev
= ieee2adev(ieee
);
4402 acxpci_s_reset_dev(adev
);
4411 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4414 int acx_selectchannel(acx_device_t
* adev
, u8 channel
, int freq
)
4421 adev
->rx_status
.channel
= channel
;
4422 adev
->rx_status
.freq
= freq
;
4424 adev
->channel
= channel
;
4425 /* hmm, the following code part is strange, but this is how
4426 * it was being done before... */
4427 log(L_IOCTL
, "Changing to channel %d\n", channel
);
4428 SET_BIT(adev
->set_mask
, GETSET_CHANNEL
);
4429 result
= -EINPROGRESS
; /* need to call commit handler */
4431 acx_sem_unlock(adev
);
4437 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4440 int acx_net_config(struct ieee80211_hw
*hw
, struct ieee80211_conf
*conf
)
4442 acx_device_t
*adev
= ieee2adev(hw
);
4443 unsigned long flags
;
4449 acx_lock(adev
, flags
);
4451 if (!adev
->initialized
) {
4452 acx_unlock(adev
, flags
);
4455 if (conf
->beacon_int
!= adev
->beacon_interval
)
4456 adev
->beacon_interval
= conf
->beacon_int
;
4457 if (conf
->channel
!= adev
->channel
) {
4458 acx_unlock(adev
, flags
);
4459 acx_selectchannel(adev
, conf
->channel
,conf
->freq
);
4460 acx_lock(adev
, flags
);
4461 /* acx_schedule_task(adev,
4462 ACX_AFTER_IRQ_UPDATE_CARD_CFG
4463 */ /*+ ACX_AFTER_IRQ_RESTART_SCAN */ /*);*/
4466 if (conf->short_slot_time != adev->short_slot) {
4467 // assert(phy->type == BCM43xx_PHYTYPE_G);
4468 if (conf->short_slot_time)
4469 acx_short_slot_timing_enable(adev);
4471 acx_short_slot_timing_disable(adev);
4472 acx_schedule_task(adev, ACX_AFTER_IRQ_UPDATE_CARD_CFG);
4475 adev
->tx_disabled
= !conf
->radio_enabled
;
4476 /* if (conf->power_level != 0){
4477 adev->tx_level_dbm = conf->power_level;
4478 acx_s_set_tx_level(adev, adev->tx_level_dbm);
4479 SET_BIT(adev->set_mask,GETSET_TXPOWER);
4480 //acx_schedule_task(adev, ACX_AFTER_IRQ_UPDATE_CARD_CFG);
4483 //FIXME: This does not seem to wake up:
4485 if (conf
->power_level
== 0) {
4487 bcm43xx_radio_turn_off(bcm
);
4489 if (!radio
->enabled
)
4490 bcm43xx_radio_turn_on(bcm
);
4496 if (adev
->set_mask
> 0) {
4497 acx_unlock(adev
, flags
);
4498 acx_s_update_card_settings(adev
);
4499 acx_lock(adev
, flags
);
4501 acx_unlock(adev
, flags
);
4508 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4512 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
4513 extern int acx_config_interface(struct ieee80211_hw
* ieee
,
4514 struct ieee80211_vif
*vif
,
4515 struct ieee80211_if_conf
*conf
)
4517 acx_device_t
*adev
= ieee2adev(ieee
);
4518 unsigned long flags
;
4521 if (!adev
->interface
.operating
)
4524 if (adev
->initialized
)
4525 acx_s_select_opmode(adev
);
4527 acx_lock(adev
, flags
);
4529 if ((conf
->type
!= IEEE80211_IF_TYPE_MNTR
)
4530 && (adev
->vif
== vif
)) {
4533 adev
->interface
.bssid
= conf
->bssid
;
4534 MAC_COPY(adev
->bssid
,conf
->bssid
);
4537 if ((conf
->type
== IEEE80211_IF_TYPE_AP
)
4538 && (adev
->vif
== vif
)) {
4540 int acx_config_interface(struct ieee80211_hw
* ieee
, int if_id
,
4541 struct ieee80211_if_conf
*conf
)
4543 acx_device_t
*adev
= ieee2adev(ieee
);
4544 unsigned long flags
;
4547 if (!adev
->interface
.operating
)
4550 if (adev
->initialized
)
4551 acx_s_select_opmode(adev
);
4553 acx_lock(adev
, flags
);
4555 if ((conf
->type
!= IEEE80211_IF_TYPE_MNTR
)
4556 && (adev
->interface
.if_id
== if_id
)) {
4559 adev
->interface
.bssid
= conf
->bssid
;
4560 MAC_COPY(adev
->bssid
,conf
->bssid
);
4563 if ((conf
->type
== IEEE80211_IF_TYPE_AP
)
4564 && (adev
->interface
.if_id
== if_id
)) {
4567 if ((conf
->ssid_len
> 0) && conf
->ssid
)
4569 adev
->essid_len
= conf
->ssid_len
;
4570 memcpy(adev
->essid
, conf
->ssid
, conf
->ssid_len
);
4571 SET_BIT(adev
->set_mask
, SET_TEMPLATES
);
4574 if (conf
->beacon
!= 0)
4576 adev
->beacon_interval
= DEFAULT_BEACON_INTERVAL
;
4577 adev
->beacon_cache
= conf
->beacon
;
4578 SET_BIT(adev
->set_mask
, SET_TEMPLATES
);
4581 acx_unlock(adev
, flags
);
4583 if (adev
->set_mask
!= 0)
4584 acx_s_update_card_settings(adev
);
4585 // acx_schedule_task(adev, ACX_AFTER_IRQ_UPDATE_CARD_CFG);
4593 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4597 int acx_net_get_tx_stats(struct ieee80211_hw
*hw
,
4598 struct ieee80211_tx_queue_stats
*stats
)
4600 // acx_device_t *adev = ndev2adev(net_dev);
4601 struct ieee80211_tx_queue_stats_data
*data
;
4606 // acx_lock(adev, flags);
4607 data
= &(stats
->data
[0]);
4609 data
->limit
= TX_CNT
;
4611 // acx_unlock(adev, flags);
4617 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4621 int acx_net_conf_tx(struct ieee80211_hw
*hw
,
4622 int queue
, const struct ieee80211_tx_queue_params
*params
)
4630 static void keymac_write(acx_device_t
* adev
, u16 index
, const u32
* addr
)
4632 /* for keys 0-3 there is no associated mac address */
4640 bcm43xx_shm_write32(bcm,
4643 cpu_to_be32(*addr));
4644 bcm43xx_shm_write16(bcm,
4647 cpu_to_be16(*((u16 *)(addr + 1))));
4651 TODO(); /* Put them in the macaddress filter */
4654 /* Put them BCM43xx_SHM_SHARED, stating index 0x0120.
4655 Keep in mind to update the count of keymacs in 0x003 */
4661 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4665 int acx_clear_keys(acx_device_t
* adev
)
4667 static const u32 zero_mac
[2] = { 0 };
4668 unsigned int i
, j
, nr_keys
= 54;
4671 /* FixMe:Check for Number of Keys available */
4673 // assert(nr_keys <= ARRAY_SIZE(adev->key));
4675 for (i
= 0; i
< nr_keys
; i
++) {
4676 adev
->key
[i
].enabled
= 0;
4677 /* returns for i < 4 immediately */
4678 keymac_write(adev
, i
, zero_mac
);
4680 bcm43xx_shm_write16(adev, BCM43xx_SHM_SHARED,
4681 0x100 + (i * 2), 0x0000);
4683 for (j
= 0; j
< 8; j
++) {
4685 adev
->security_offset
+ (j
* 4) +
4686 (i
* ACX_SEC_KEYSIZE
);
4688 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED,
4697 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4701 int acx_key_write(acx_device_t
* adev
,
4702 u16 index
, u8 algorithm
,
4703 const struct ieee80211_key_conf
*key
, const u8
* mac_addr
)
4705 // struct iw_point *dwrq = &wrqu->encoding;
4710 log(L_IOCTL, "set encoding flags=0x%04X, size=%d, key: %s\n",
4711 dwrq->flags, dwrq->length, extra ? "set" : "No key");
4713 // acx_sem_lock(adev);
4715 // index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
4716 if (key
->keylen
> 0) {
4717 /* if index is 0 or invalid, use default key */
4719 index
= (int)adev
->wep_current_index
;
4720 if ((algorithm
== ACX_SEC_ALGO_WEP
) ||
4721 (algorithm
== ACX_SEC_ALGO_WEP104
)) {
4722 switch(key
->keylen
) {
4725 40-bit entered key + 24 bit IV = 64-bit */
4726 adev
->wep_keys
[index
].size
= 13;
4730 104-bit entered key + 24-bit IV = 128-bit */
4731 adev
->wep_keys
[index
].size
= 29;
4735 128-bit entered key + 24 bit IV = 152-bit */
4736 adev
->wep_keys
[index
].size
= 16;
4739 adev
->wep_keys
[index
].size
= 0;
4740 return -EINVAL
; /* shouldn't happen */
4743 memset(adev
->wep_keys
[index
].key
, 0,
4744 sizeof(adev
->wep_keys
[index
].key
));
4745 memcpy(adev
->wep_keys
[index
].key
, key
, key
->keylen
);
4747 /* set transmit key */
4749 adev
->wep_current_index
= index
;
4750 // else if (0 == (dwrq->flags & IW_ENCODE_MODE)) {
4751 /* complain if we were not just setting
4753 // result = -EINVAL;
4759 adev
->wep_enabled
= (algorithm
== ALG_WEP
);
4761 adev->wep_enabled = !(dwrq->flags & IW_ENCODE_DISABLED);
4763 if (algorithm & IW_ENCODE_OPEN) {
4764 adev->auth_alg = WLAN_AUTH_ALG_OPENSYSTEM;
4765 adev->wep_restricted = 0;
4767 } else if (algorithm & IW_ENCODE_RESTRICTED) {
4768 adev->auth_alg = WLAN_AUTH_ALG_SHAREDKEY;
4769 adev->wep_restricted = 1;
4772 // adev->auth_alg = algorithm;
4773 /* set flag to make sure the card WEP settings get updated */
4774 if (adev
->wep_enabled
) {
4775 SET_BIT(adev
->set_mask
, GETSET_WEP
);
4776 acx_s_update_card_settings(adev
);
4777 // acx_schedule_task(adev, ACX_AFTER_IRQ_UPDATE_CARD_CFG);
4780 log(L_IOCTL, "len=%d, key at 0x%p, flags=0x%X\n",
4781 dwrq->length, extra, dwrq->flags);
4782 for (index = 0; index <= 3; index++) {
4783 if (adev->wep_keys[index].size) {
4784 log(L_IOCTL, "index=%d, size=%d, key at 0x%p\n",
4785 adev->wep_keys[index].index,
4786 (int) adev->wep_keys[index].size,
4787 adev->wep_keys[index].key);
4791 result
= -EINPROGRESS
;
4792 // acx_sem_unlock(adev);
4801 ** Derived from mac80211 code, p54, bcm43xx_mac80211
4805 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
4806 int acx_net_set_key(struct ieee80211_hw
*ieee
,
4808 u8
* addr
, struct ieee80211_key_conf
*key
, int aid
)
4810 int acx_net_set_key(struct ieee80211_hw
*ieee
,
4811 enum set_key_cmd cmd
, const u8
*local_addr
,
4812 const u8
* addr
, struct ieee80211_key_conf
*key
)
4816 struct acx_device
*adev
= ieee2adev(ieee
);
4817 unsigned long flags
;
4827 algorithm = ACX_SEC_ALGO_NONE;
4830 if (key
->keylen
== 5)
4831 algorithm
= ACX_SEC_ALGO_WEP
;
4833 algorithm
= ACX_SEC_ALGO_WEP104
;
4836 algorithm
= ACX_SEC_ALGO_TKIP
;
4839 algorithm
= ACX_SEC_ALGO_AES
;
4843 index
= (u8
) (key
->keyidx
);
4844 if (index
>= ARRAY_SIZE(adev
->key
))
4846 acx_lock(adev
, flags
);
4849 err
= acx_key_write(adev
, index
, algorithm
, key
, addr
);
4852 key
->hw_key_idx
= index
;
4853 /* CLEAR_BIT(key->flags, IEEE80211_KEY_FORCE_SW_ENCRYPT);*/
4854 /* if (CHECK_BIT(key->flags, IEEE80211_KEY_DEFAULT_TX_KEY))
4855 adev->default_key_idx = index;*/
4856 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
4857 SET_BIT(key
->flags
, IEEE80211_KEY_FLAG_GENERATE_IV
);
4859 adev
->key
[index
].enabled
= 1;
4862 adev
->key
[index
].enabled
= 0;
4865 /* case ENABLE_COMPRESSION:
4866 case DISABLE_COMPRESSION:
4871 acx_unlock(adev
, flags
);
4879 /***********************************************************************
4880 ** Common function to parse ALL configoption struct formats
4881 ** (ACX100 and ACX111; FIXME: how to make it work with ACX100 USB!?!?).
4882 ** FIXME: logging should be removed here and added to a /proc file instead
4884 ** Look into bcm43xx
4887 acx_s_parse_configoption(acx_device_t
* adev
,
4888 const acx111_ie_configoption_t
* pcfg
)
4892 int is_acx111
= IS_ACX111(adev
);
4894 if (acx_debug
& L_DEBUG
) {
4895 printk("configoption struct content:\n");
4896 acx_dump_bytes(pcfg
, sizeof(*pcfg
));
4899 if ((is_acx111
&& (adev
->eeprom_version
== 5))
4900 || (!is_acx111
&& (adev
->eeprom_version
== 4))
4901 || (!is_acx111
&& (adev
->eeprom_version
== 5))) {
4902 /* these versions are known to be supported */
4904 printk("unknown chip and EEPROM version combination (%s, v%d), "
4905 "don't know how to parse config options yet. "
4906 "Please report\n", is_acx111
? "ACX111" : "ACX100",
4907 adev
->eeprom_version
);
4911 /* first custom-parse the first part which has chip-specific layout */
4913 pEle
= (const u8
*)pcfg
;
4915 pEle
+= 4; /* skip (type,len) header */
4917 memcpy(adev
->cfgopt_NVSv
, pEle
, sizeof(adev
->cfgopt_NVSv
));
4918 pEle
+= sizeof(adev
->cfgopt_NVSv
);
4921 adev
->cfgopt_NVS_vendor_offs
= le16_to_cpu(*(u16
*) pEle
);
4922 pEle
+= sizeof(adev
->cfgopt_NVS_vendor_offs
);
4924 adev
->cfgopt_probe_delay
= 200; /* good default value? */
4925 pEle
+= 2; /* FIXME: unknown, value 0x0001 */
4927 memcpy(adev
->cfgopt_MAC
, pEle
, sizeof(adev
->cfgopt_MAC
));
4928 pEle
+= sizeof(adev
->cfgopt_MAC
);
4930 adev
->cfgopt_probe_delay
= le16_to_cpu(*(u16
*) pEle
);
4931 pEle
+= sizeof(adev
->cfgopt_probe_delay
);
4932 if ((adev
->cfgopt_probe_delay
< 100)
4933 || (adev
->cfgopt_probe_delay
> 500)) {
4934 printk("strange probe_delay value %d, "
4935 "tweaking to 200\n", adev
->cfgopt_probe_delay
);
4936 adev
->cfgopt_probe_delay
= 200;
4940 adev
->cfgopt_eof_memory
= le32_to_cpu(*(u32
*) pEle
);
4941 pEle
+= sizeof(adev
->cfgopt_eof_memory
);
4943 printk("NVS_vendor_offs:%04X probe_delay:%d eof_memory:%d\n",
4944 adev
->cfgopt_NVS_vendor_offs
,
4945 adev
->cfgopt_probe_delay
, adev
->cfgopt_eof_memory
);
4947 adev
->cfgopt_dot11CCAModes
= *pEle
++;
4948 adev
->cfgopt_dot11Diversity
= *pEle
++;
4949 adev
->cfgopt_dot11ShortPreambleOption
= *pEle
++;
4950 adev
->cfgopt_dot11PBCCOption
= *pEle
++;
4951 adev
->cfgopt_dot11ChannelAgility
= *pEle
++;
4952 adev
->cfgopt_dot11PhyType
= *pEle
++;
4953 adev
->cfgopt_dot11TempType
= *pEle
++;
4954 printk("CCAModes:%02X Diversity:%02X ShortPreOpt:%02X "
4955 "PBCC:%02X ChanAgil:%02X PHY:%02X Temp:%02X\n",
4956 adev
->cfgopt_dot11CCAModes
,
4957 adev
->cfgopt_dot11Diversity
,
4958 adev
->cfgopt_dot11ShortPreambleOption
,
4959 adev
->cfgopt_dot11PBCCOption
,
4960 adev
->cfgopt_dot11ChannelAgility
,
4961 adev
->cfgopt_dot11PhyType
, adev
->cfgopt_dot11TempType
);
4963 /* then use common parsing for next part which has common layout */
4965 pEle
++; /* skip table_count (6) */
4967 adev
->cfgopt_antennas
.type
= pEle
[0];
4968 adev
->cfgopt_antennas
.len
= pEle
[1];
4969 printk("AntennaID:%02X Len:%02X Data:",
4970 adev
->cfgopt_antennas
.type
, adev
->cfgopt_antennas
.len
);
4971 for (i
= 0; i
< pEle
[1]; i
++) {
4972 adev
->cfgopt_antennas
.list
[i
] = pEle
[i
+ 2];
4973 printk("%02X ", pEle
[i
+ 2]);
4977 pEle
+= pEle
[1] + 2;
4978 adev
->cfgopt_power_levels
.type
= pEle
[0];
4979 adev
->cfgopt_power_levels
.len
= pEle
[1];
4980 printk("PowerLevelID:%02X Len:%02X Data:",
4981 adev
->cfgopt_power_levels
.type
, adev
->cfgopt_power_levels
.len
);
4982 for (i
= 0; i
< pEle
[1]; i
++) {
4983 adev
->cfgopt_power_levels
.list
[i
] =
4984 le16_to_cpu(*(u16
*) & pEle
[i
* 2 + 2]);
4985 printk("%04X ", adev
->cfgopt_power_levels
.list
[i
]);
4989 pEle
+= pEle
[1] * 2 + 2;
4990 adev
->cfgopt_data_rates
.type
= pEle
[0];
4991 adev
->cfgopt_data_rates
.len
= pEle
[1];
4992 printk("DataRatesID:%02X Len:%02X Data:",
4993 adev
->cfgopt_data_rates
.type
, adev
->cfgopt_data_rates
.len
);
4994 for (i
= 0; i
< pEle
[1]; i
++) {
4995 adev
->cfgopt_data_rates
.list
[i
] = pEle
[i
+ 2];
4996 printk("%02X ", pEle
[i
+ 2]);
5000 pEle
+= pEle
[1] + 2;
5001 adev
->cfgopt_domains
.type
= pEle
[0];
5002 adev
->cfgopt_domains
.len
= pEle
[1];
5003 printk("DomainID:%02X Len:%02X Data:",
5004 adev
->cfgopt_domains
.type
, adev
->cfgopt_domains
.len
);
5005 for (i
= 0; i
< pEle
[1]; i
++) {
5006 adev
->cfgopt_domains
.list
[i
] = pEle
[i
+ 2];
5007 printk("%02X ", pEle
[i
+ 2]);
5011 pEle
+= pEle
[1] + 2;
5012 adev
->cfgopt_product_id
.type
= pEle
[0];
5013 adev
->cfgopt_product_id
.len
= pEle
[1];
5014 for (i
= 0; i
< pEle
[1]; i
++) {
5015 adev
->cfgopt_product_id
.list
[i
] = pEle
[i
+ 2];
5017 printk("ProductID:%02X Len:%02X Data:%.*s\n",
5018 adev
->cfgopt_product_id
.type
, adev
->cfgopt_product_id
.len
,
5019 adev
->cfgopt_product_id
.len
,
5020 (char *)adev
->cfgopt_product_id
.list
);
5022 pEle
+= pEle
[1] + 2;
5023 adev
->cfgopt_manufacturer
.type
= pEle
[0];
5024 adev
->cfgopt_manufacturer
.len
= pEle
[1];
5025 for (i
= 0; i
< pEle
[1]; i
++) {
5026 adev
->cfgopt_manufacturer
.list
[i
] = pEle
[i
+ 2];
5028 printk("ManufacturerID:%02X Len:%02X Data:%.*s\n",
5029 adev
->cfgopt_manufacturer
.type
, adev
->cfgopt_manufacturer
.len
,
5030 adev
->cfgopt_manufacturer
.len
,
5031 (char *)adev
->cfgopt_manufacturer
.list
);
5033 printk("EEPROM part:\n");
5034 for (i=0; i<58; i++) {
5035 printk("%02X =======> 0x%02X\n",
5036 i, (u8 *)adev->cfgopt_NVSv[i-2]);
5042 /***********************************************************************
5043 ** Linux Kernel Specific
5045 static int __init
acx_e_init_module(void)
5049 acx_struct_size_check();
5051 printk("acx: this driver is still EXPERIMENTAL\n"
5052 "acx: reading README file and/or Craig's HOWTO is "
5053 "recommended, visit http://acx100.sourceforge.net/wiki in case "
5054 "of further questions/discussion\n");
5056 #if defined(CONFIG_ACX_MAC80211_PCI)
5057 r1
= acxpci_e_init_module();
5061 #if defined(CONFIG_ACX_MAC80211_USB)
5062 r2
= acxusb_e_init_module();
5066 if (r2
&& r1
) /* both failed! */
5067 return r2
? r2
: r1
;
5068 /* return success if at least one succeeded */
5072 static void __exit
acx_e_cleanup_module(void)
5074 #if defined(CONFIG_ACX_MAC80211_PCI)
5075 acxpci_e_cleanup_module();
5077 #if defined(CONFIG_ACX_MAC80211_USB)
5078 acxusb_e_cleanup_module();
5082 module_init(acx_e_init_module
)
5083 module_exit(acx_e_cleanup_module
)