3 #include <linux/module.h>
4 #include <linux/crc7.h>
5 #include <linux/spi/spi.h>
8 #include "wl12xx_80211.h"
13 int wl12xx_acx_frame_rates(struct wl12xx
*wl
, u8 ctrl_rate
, u8 ctrl_mod
,
14 u8 mgt_rate
, u8 mgt_mod
)
17 struct acx_fw_gen_frame_rates rates
;
19 wl12xx_debug(DEBUG_ACX
, "acx frame rates");
21 rates
.header
.id
= ACX_FW_GEN_FRAME_RATES
;
22 rates
.header
.len
= sizeof(struct acx_fw_gen_frame_rates
) -
23 sizeof(struct acx_header
);
25 rates
.tx_ctrl_frame_rate
= ctrl_rate
;
26 rates
.tx_ctrl_frame_mod
= ctrl_mod
;
27 rates
.tx_mgt_frame_rate
= mgt_rate
;
28 rates
.tx_mgt_frame_mod
= mgt_mod
;
30 ret
= wl12xx_cmd_configure(wl
, &rates
, sizeof(rates
));
32 wl12xx_error("Failed to set FW rates and modulation");
40 int wl12xx_acx_station_id(struct wl12xx
*wl
)
43 struct dot11_station_id mac
;
45 wl12xx_debug(DEBUG_ACX
, "acx dot11_station_id");
47 mac
.header
.id
= DOT11_STATION_ID
;
48 mac
.header
.len
= sizeof(mac
) - sizeof(struct acx_header
);
50 for (i
= 0; i
< ETH_ALEN
; i
++)
51 mac
.mac
[i
] = wl
->mac_addr
[ETH_ALEN
- 1 - i
];
53 ret
= wl12xx_cmd_configure(wl
, &mac
, sizeof(mac
));
60 int wl12xx_acx_default_key(struct wl12xx
*wl
, u8 key_id
)
62 struct acx_dot11_default_key default_key
;
65 wl12xx_debug(DEBUG_ACX
, "acx dot11_default_key (%d)", key_id
);
67 default_key
.header
.id
= DOT11_DEFAULT_KEY
;
68 default_key
.header
.len
= sizeof(default_key
) -
69 sizeof(struct acx_header
);
71 default_key
.id
= key_id
;
73 ret
= wl12xx_cmd_configure(wl
, &default_key
, sizeof(default_key
));
75 wl12xx_error("Couldnt set default key");
79 wl
->default_key
= key_id
;
84 int wl12xx_acx_wake_up_conditions(struct wl12xx
*wl
, u8 listen_interval
)
86 struct acx_wake_up_condition wake_up
;
88 wl12xx_debug(DEBUG_ACX
, "acx wake up conditions");
90 wake_up
.header
.id
= ACX_WAKE_UP_CONDITIONS
;
91 wake_up
.header
.len
= sizeof(wake_up
) - sizeof(struct acx_header
);
93 wake_up
.wake_up_event
= WAKE_UP_EVENT_DTIM_BITMAP
;
94 wake_up
.listen_interval
= listen_interval
;
96 return wl12xx_cmd_configure(wl
, &wake_up
, sizeof(wake_up
));
99 int wl12xx_acx_sleep_auth(struct wl12xx
*wl
, u8 sleep_auth
)
102 struct acx_sleep_auth auth
;
104 wl12xx_debug(DEBUG_ACX
, "acx sleep auth");
106 auth
.header
.id
= ACX_SLEEP_AUTH
;
107 auth
.header
.len
= sizeof(auth
) - sizeof(struct acx_header
);
109 auth
.sleep_auth
= sleep_auth
;
111 ret
= wl12xx_cmd_configure(wl
, &auth
, sizeof(auth
));
118 int wl12xx_acx_fw_version(struct wl12xx
*wl
, char *buf
, size_t len
)
120 struct wl12xx_command cmd
;
121 struct acx_revision
*rev
;
124 wl12xx_debug(DEBUG_ACX
, "acx fw rev");
126 memset(&cmd
, 0, sizeof(cmd
));
128 ret
= wl12xx_cmd_interrogate(wl
, ACX_FW_REV
, sizeof(*rev
), &cmd
);
130 wl12xx_warning("ACX_FW_REV interrogate failed");
134 rev
= (struct acx_revision
*) &cmd
.parameters
;
136 /* be careful with the buffer sizes */
137 strncpy(buf
, rev
->fw_version
, min(len
, sizeof(rev
->fw_version
)));
140 * if the firmware version string is exactly
141 * sizeof(rev->fw_version) long or fw_len is less than
142 * sizeof(rev->fw_version) it won't be null terminated
144 buf
[min(len
, sizeof(rev
->fw_version
)) - 1] = '\0';
149 int wl12xx_acx_tx_power(struct wl12xx
*wl
, int power
)
151 struct acx_current_tx_power ie
;
154 wl12xx_debug(DEBUG_ACX
, "acx dot11_cur_tx_pwr");
156 if (power
< 0 || power
> 25)
159 memset(&ie
, 0, sizeof(ie
));
161 ie
.header
.id
= DOT11_CUR_TX_PWR
;
162 ie
.header
.len
= sizeof(ie
) - sizeof(struct acx_header
);
163 ie
.current_tx_power
= power
* 10;
165 ret
= wl12xx_cmd_configure(wl
, &ie
, sizeof(ie
));
167 wl12xx_warning("configure of tx power failed: %d", ret
);
174 int wl12xx_acx_feature_cfg(struct wl12xx
*wl
)
176 struct acx_feature_config feature
;
179 wl12xx_debug(DEBUG_ACX
, "acx feature cfg");
181 memset(&feature
, 0, sizeof(feature
));
183 feature
.header
.id
= ACX_FEATURE_CFG
;
184 feature
.header
.len
= sizeof(feature
) - sizeof(struct acx_header
);
186 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
187 feature
.data_flow_options
= 0;
190 ret
= wl12xx_cmd_configure(wl
, &feature
, sizeof(feature
));
192 wl12xx_error("Couldnt set HW encryption");
197 int wl12xx_acx_mem_map(struct wl12xx
*wl
, void *mem_map
, size_t len
)
199 struct wl12xx_command cmd
;
202 wl12xx_debug(DEBUG_ACX
, "acx mem map");
204 ret
= wl12xx_cmd_interrogate(wl
, ACX_MEM_MAP
, len
, &cmd
);
207 else if (cmd
.status
!= CMD_STATUS_SUCCESS
)
210 memcpy(mem_map
, &cmd
.parameters
, len
);
215 int wl12xx_acx_data_path_params(struct wl12xx
*wl
,
216 struct acx_data_path_params_resp
*data_path
)
218 struct acx_data_path_params params
;
219 struct wl12xx_command cmd
;
222 wl12xx_debug(DEBUG_ACX
, "acx data path params");
224 params
.rx_packet_ring_chunk_size
= DP_RX_PACKET_RING_CHUNK_SIZE
;
225 params
.tx_packet_ring_chunk_size
= DP_TX_PACKET_RING_CHUNK_SIZE
;
227 params
.rx_packet_ring_chunk_num
= DP_RX_PACKET_RING_CHUNK_NUM
;
228 params
.tx_packet_ring_chunk_num
= DP_TX_PACKET_RING_CHUNK_NUM
;
230 params
.tx_complete_threshold
= 1;
232 params
.tx_complete_ring_depth
= FW_TX_CMPLT_BLOCK_SIZE
;
234 params
.tx_complete_timeout
= DP_TX_COMPLETE_TIME_OUT
;
236 params
.header
.id
= ACX_DATA_PATH_PARAMS
;
237 params
.header
.len
= sizeof(params
) - sizeof(struct acx_header
);
239 ret
= wl12xx_cmd_configure(wl
, ¶ms
, sizeof(params
));
244 ret
= wl12xx_cmd_interrogate(wl
, ACX_DATA_PATH_PARAMS
,
245 sizeof(struct acx_data_path_params_resp
),
249 wl12xx_warning("failed to read data path parameters: %d", ret
);
251 } else if (cmd
.status
!= CMD_STATUS_SUCCESS
) {
252 wl12xx_warning("data path parameter acx status failed");
256 memcpy(data_path
, &cmd
.parameters
, sizeof(*data_path
));
261 int wl12xx_acx_rx_msdu_life_time(struct wl12xx
*wl
, u32 life_time
)
263 struct rx_msdu_lifetime msdu_lifetime
;
266 wl12xx_debug(DEBUG_ACX
, "acx rx msdu life time");
268 msdu_lifetime
.header
.id
= DOT11_RX_MSDU_LIFE_TIME
;
269 msdu_lifetime
.header
.len
= sizeof(msdu_lifetime
) -
270 sizeof(struct acx_header
);
271 msdu_lifetime
.lifetime
= life_time
;
273 ret
= wl12xx_cmd_configure(wl
, &msdu_lifetime
, sizeof(msdu_lifetime
));
275 wl12xx_warning("failed to set rx msdu life time: %d", ret
);
282 int wl12xx_acx_rx_config(struct wl12xx
*wl
, u32 config
, u32 filter
)
284 struct acx_rx_config rx_config
;
287 wl12xx_debug(DEBUG_ACX
, "acx rx config");
289 rx_config
.header
.id
= ACX_RX_CFG
;
290 rx_config
.header
.len
= sizeof(rx_config
) - sizeof(struct acx_header
);
291 rx_config
.config_options
= config
;
292 rx_config
.filter_options
= filter
;
294 ret
= wl12xx_cmd_configure(wl
, &rx_config
, sizeof(rx_config
));
296 wl12xx_warning("failed to set rx config: %d", ret
);
303 int wl12xx_acx_pd_threshold(struct wl12xx
*wl
)
305 struct acx_packet_detection packet_detection
;
308 wl12xx_debug(DEBUG_ACX
, "acx data pd threshold");
310 /* FIXME: threshold value not set */
311 packet_detection
.header
.id
= ACX_PD_THRESHOLD
;
312 packet_detection
.header
.len
= sizeof(packet_detection
) -
313 sizeof(struct acx_header
);
315 ret
= wl12xx_cmd_configure(wl
, &packet_detection
,
316 sizeof(packet_detection
));
318 wl12xx_warning("failed to set pd threshold: %d", ret
);
325 int wl12xx_acx_slot(struct wl12xx
*wl
, enum acx_slot_type slot_time
)
327 struct acx_slot slot
;
330 wl12xx_debug(DEBUG_ACX
, "acx slot");
332 slot
.header
.id
= ACX_SLOT
;
333 slot
.header
.len
= sizeof(slot
) - sizeof(struct acx_header
);
335 slot
.wone_index
= STATION_WONE_INDEX
;
336 slot
.slot_time
= slot_time
;
338 ret
= wl12xx_cmd_configure(wl
, &slot
, sizeof(slot
));
340 wl12xx_warning("failed to set slot time: %d", ret
);
347 int wl12xx_acx_group_address_tbl(struct wl12xx
*wl
)
349 struct multicast_grp_addr_start multicast
;
352 wl12xx_debug(DEBUG_ACX
, "acx group address tbl");
355 multicast
.header
.id
= DOT11_GROUP_ADDRESS_TBL
;
356 multicast
.header
.len
= sizeof(multicast
) - sizeof(struct acx_header
);
358 multicast
.enabled
= 0;
359 multicast
.num_groups
= 0;
360 memset(multicast
.mac_table
, 0, ADDRESS_GROUP_MAX_LEN
);
362 ret
= wl12xx_cmd_configure(wl
, &multicast
, sizeof(multicast
));
364 wl12xx_warning("failed to set group addr table: %d", ret
);
371 int wl12xx_acx_service_period_timeout(struct wl12xx
*wl
)
373 struct acx_rx_timeout rx_timeout
;
376 wl12xx_debug(DEBUG_ACX
, "acx service period timeout");
379 rx_timeout
.header
.id
= ACX_SERVICE_PERIOD_TIMEOUT
;
380 rx_timeout
.header
.len
= sizeof(rx_timeout
) - sizeof(struct acx_header
);
382 rx_timeout
.ps_poll_timeout
= RX_TIMEOUT_PS_POLL_DEF
;
383 rx_timeout
.upsd_timeout
= RX_TIMEOUT_UPSD_DEF
;
385 ret
= wl12xx_cmd_configure(wl
, &rx_timeout
, sizeof(rx_timeout
));
387 wl12xx_warning("failed to set service period timeout: %d",
395 int wl12xx_acx_rts_threshold(struct wl12xx
*wl
, u16 rts_threshold
)
397 struct acx_rts_threshold rts
;
400 wl12xx_debug(DEBUG_ACX
, "acx rts threshold");
402 rts
.header
.id
= DOT11_RTS_THRESHOLD
;
403 rts
.header
.len
= sizeof(rts
) - sizeof(struct acx_header
);
405 rts
.threshold
= rts_threshold
;
407 ret
= wl12xx_cmd_configure(wl
, &rts
, sizeof(rts
));
409 wl12xx_warning("failed to set rts threshold: %d", ret
);
416 int wl12xx_acx_beacon_filter_opt(struct wl12xx
*wl
)
418 struct acx_beacon_filter_option beacon_filter
;
421 wl12xx_debug(DEBUG_ACX
, "acx beacon filter opt");
423 beacon_filter
.header
.id
= ACX_BEACON_FILTER_OPT
;
424 beacon_filter
.header
.len
= sizeof(beacon_filter
) -
425 sizeof(struct acx_header
);
427 beacon_filter
.enable
= 0;
428 beacon_filter
.max_num_beacons
= 0;
430 ret
= wl12xx_cmd_configure(wl
, &beacon_filter
, sizeof(beacon_filter
));
432 wl12xx_warning("failed to set beacon filter opt: %d", ret
);
439 int wl12xx_acx_beacon_filter_table(struct wl12xx
*wl
)
441 struct acx_beacon_filter_ie_table ie_table
;
444 wl12xx_debug(DEBUG_ACX
, "acx beacon filter table");
446 ie_table
.header
.id
= ACX_BEACON_FILTER_TABLE
;
447 ie_table
.header
.len
= sizeof(ie_table
) - sizeof(struct acx_header
);
450 memset(ie_table
.table
, 0, BEACON_FILTER_TABLE_MAX_SIZE
);
452 ret
= wl12xx_cmd_configure(wl
, &ie_table
, sizeof(ie_table
));
454 wl12xx_warning("failed to set beacon filter table: %d", ret
);
461 int wl12xx_acx_sg_enable(struct wl12xx
*wl
)
463 struct acx_bt_wlan_coex pta
;
466 wl12xx_debug(DEBUG_ACX
, "acx sg enable");
468 pta
.header
.id
= ACX_SG_ENABLE
;
469 pta
.header
.len
= sizeof(pta
) - sizeof(struct acx_header
);
471 pta
.enable
= SG_ENABLE
;
473 ret
= wl12xx_cmd_configure(wl
, &pta
, sizeof(pta
));
475 wl12xx_warning("failed to set softgemini enable: %d", ret
);
482 int wl12xx_acx_sg_cfg(struct wl12xx
*wl
)
484 struct acx_bt_wlan_coex_param param
;
487 wl12xx_debug(DEBUG_ACX
, "acx sg cfg");
489 /* BT-WLAN coext parameters */
490 param
.header
.id
= ACX_SG_CFG
;
491 param
.header
.len
= sizeof(param
) - sizeof(struct acx_header
);
493 param
.min_rate
= RATE_INDEX_24MBPS
;
494 param
.bt_hp_max_time
= PTA_BT_HP_MAXTIME_DEF
;
495 param
.wlan_hp_max_time
= PTA_WLAN_HP_MAX_TIME_DEF
;
496 param
.sense_disable_timer
= PTA_SENSE_DISABLE_TIMER_DEF
;
497 param
.rx_time_bt_hp
= PTA_PROTECTIVE_RX_TIME_DEF
;
498 param
.tx_time_bt_hp
= PTA_PROTECTIVE_TX_TIME_DEF
;
499 param
.rx_time_bt_hp_fast
= PTA_PROTECTIVE_RX_TIME_FAST_DEF
;
500 param
.tx_time_bt_hp_fast
= PTA_PROTECTIVE_TX_TIME_FAST_DEF
;
501 param
.wlan_cycle_fast
= PTA_CYCLE_TIME_FAST_DEF
;
502 param
.bt_anti_starvation_period
= PTA_ANTI_STARVE_PERIOD_DEF
;
503 param
.next_bt_lp_packet
= PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF
;
504 param
.wake_up_beacon
= PTA_TIME_BEFORE_BEACON_DEF
;
505 param
.hp_dm_max_guard_time
= PTA_HPDM_MAX_TIME_DEF
;
506 param
.next_wlan_packet
= PTA_TIME_OUT_NEXT_WLAN_DEF
;
507 param
.antenna_type
= PTA_ANTENNA_TYPE_DEF
;
508 param
.signal_type
= PTA_SIGNALING_TYPE_DEF
;
509 param
.afh_leverage_on
= PTA_AFH_LEVERAGE_ON_DEF
;
510 param
.quiet_cycle_num
= PTA_NUMBER_QUIET_CYCLE_DEF
;
511 param
.max_cts
= PTA_MAX_NUM_CTS_DEF
;
512 param
.wlan_packets_num
= PTA_NUMBER_OF_WLAN_PACKETS_DEF
;
513 param
.bt_packets_num
= PTA_NUMBER_OF_BT_PACKETS_DEF
;
514 param
.missed_rx_avalanche
= PTA_RX_FOR_AVALANCHE_DEF
;
515 param
.wlan_elp_hp
= PTA_ELP_HP_DEF
;
516 param
.bt_anti_starvation_cycles
= PTA_ANTI_STARVE_NUM_CYCLE_DEF
;
517 param
.ack_mode_dual_ant
= PTA_ACK_MODE_DEF
;
518 param
.pa_sd_enable
= PTA_ALLOW_PA_SD_DEF
;
519 param
.pta_auto_mode_enable
= PTA_AUTO_MODE_NO_CTS_DEF
;
520 param
.bt_hp_respected_num
= PTA_BT_HP_RESPECTED_DEF
;
522 ret
= wl12xx_cmd_configure(wl
, ¶m
, sizeof(param
));
524 wl12xx_warning("failed to set sg config: %d", ret
);
531 int wl12xx_acx_cca_threshold(struct wl12xx
*wl
)
533 struct acx_energy_detection detection
;
536 wl12xx_debug(DEBUG_ACX
, "acx cca threshold");
538 detection
.header
.id
= ACX_CCA_THRESHOLD
;
539 detection
.header
.len
= sizeof(detection
) - sizeof(struct acx_header
);
541 detection
.rx_cca_threshold
= CCA_THRSH_DISABLE_ENERGY_D
;
542 detection
.tx_energy_detection
= 0;
544 ret
= wl12xx_cmd_configure(wl
, &detection
, sizeof(detection
));
546 wl12xx_warning("failed to set cca threshold: %d", ret
);
553 int wl12xx_acx_bcn_dtim_options(struct wl12xx
*wl
)
555 struct acx_beacon_broadcast bb
;
558 wl12xx_debug(DEBUG_ACX
, "acx bcn dtim options");
560 bb
.header
.id
= ACX_BCN_DTIM_OPTIONS
;
561 bb
.header
.len
= sizeof(bb
) - sizeof(struct acx_header
);
563 bb
.beacon_rx_timeout
= BCN_RX_TIMEOUT_DEF_VALUE
;
564 bb
.broadcast_timeout
= BROADCAST_RX_TIMEOUT_DEF_VALUE
;
565 bb
.rx_broadcast_in_ps
= RX_BROADCAST_IN_PS_DEF_VALUE
;
566 bb
.ps_poll_threshold
= CONSECUTIVE_PS_POLL_FAILURE_DEF
;
568 ret
= wl12xx_cmd_configure(wl
, &bb
, sizeof(bb
));
570 wl12xx_warning("failed to set rx config: %d", ret
);
577 int wl12xx_acx_aid(struct wl12xx
*wl
, u16 aid
)
579 struct acx_aid acx_aid
;
582 wl12xx_debug(DEBUG_ACX
, "acx aid");
584 acx_aid
.header
.id
= ACX_AID
;
585 acx_aid
.header
.len
= sizeof(acx_aid
) - sizeof(struct acx_header
);
589 ret
= wl12xx_cmd_configure(wl
, &acx_aid
, sizeof(acx_aid
));
591 wl12xx_warning("failed to set aid: %d", ret
);
598 int wl12xx_acx_event_mbox_mask(struct wl12xx
*wl
, u32 event_mask
)
600 struct acx_event_mask mask
;
603 wl12xx_debug(DEBUG_ACX
, "acx event mbox mask");
605 mask
.header
.id
= ACX_EVENT_MBOX_MASK
;
606 mask
.header
.len
= sizeof(mask
) - sizeof(struct acx_header
);
608 /* high event mask is unused */
609 mask
.high_event_mask
= 0xffffffff;
611 mask
.event_mask
= event_mask
;
613 ret
= wl12xx_cmd_configure(wl
, &mask
, sizeof(mask
));
615 wl12xx_warning("failed to set aid: %d", ret
);
622 int wl12xx_acx_set_preamble(struct wl12xx
*wl
, enum acx_preamble_type preamble
)
624 struct acx_preamble ie
;
627 wl12xx_debug(DEBUG_ACX
, "acx_set_preamble");
629 memset(&ie
, 0, sizeof(ie
));
631 ie
.header
.id
= ACX_PREAMBLE_TYPE
;
632 ie
.header
.len
= sizeof(ie
) - sizeof(struct acx_header
);
633 ie
.preamble
= preamble
;
634 ret
= wl12xx_cmd_configure(wl
, &ie
, sizeof(ie
));
636 wl12xx_warning("Setting of preamble failed: %d", ret
);
642 int wl12xx_acx_cts_protect(struct wl12xx
*wl
,
643 enum acx_ctsprotect_type ctsprotect
)
645 struct acx_ctsprotect ie
;
648 wl12xx_debug(DEBUG_ACX
, "acx_set_ctsprotect");
650 memset(&ie
, 0, sizeof(ie
));
652 ie
.header
.id
= ACX_CTS_PROTECTION
;
653 ie
.header
.len
= sizeof(ie
) - sizeof(struct acx_header
);
654 ie
.ctsprotect
= ctsprotect
;
655 ret
= wl12xx_cmd_configure(wl
, &ie
, sizeof(ie
));
657 wl12xx_warning("Setting of ctsprotect failed: %d", ret
);
663 int wl12xx_acx_statistics(struct wl12xx
*wl
, struct acx_statistics
*stats
)
665 struct wl12xx_command
*answer
;
668 wl12xx_debug(DEBUG_ACX
, "acx statistics");
670 answer
= kmalloc(sizeof(*answer
), GFP_KERNEL
);
672 wl12xx_warning("could not allocate memory for acx statistics");
677 ret
= wl12xx_cmd_interrogate(wl
, ACX_STATISTICS
, sizeof(*answer
),
680 wl12xx_warning("acx statistics failed: %d", ret
);
684 memcpy(stats
, answer
->parameters
, sizeof(*stats
));