2 * Copyright (c) 2014 Redpine Signals Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/etherdevice.h>
19 #include "rsi_common.h"
21 static struct bootup_params boot_params_20
= {
22 .magic_number
= cpu_to_le16(0x5aa5),
23 .crystal_good_time
= 0x0,
24 .valid
= cpu_to_le32(VALID_20
),
25 .reserved_for_valids
= 0x0,
26 .bootup_mode_info
= 0x0,
27 .digital_loop_back_params
= 0x0,
28 .rtls_timestamp_en
= 0x0,
29 .host_spi_intr_cfg
= 0x0,
33 .pll_reg_1
= cpu_to_le16((TA_PLL_N_VAL_20
<< 8)|
35 .pll_reg_2
= cpu_to_le16(TA_PLL_P_VAL_20
),
38 .pll_reg_1
= cpu_to_le16((PLL960_P_VAL_20
<< 8)|
40 .pll_reg_2
= cpu_to_le16(PLL960_M_VAL_20
),
44 .pll_reg
= cpu_to_le16(0x9f0),
48 .switch_clk_info
= cpu_to_le16(0xb),
49 .bbp_lmac_clk_reg_val
= cpu_to_le16(0x111),
50 .umac_clock_reg_config
= cpu_to_le16(0x48),
51 .qspi_uart_clock_reg_config
= cpu_to_le16(0x1211)
57 .pll_reg_1
= cpu_to_le16((TA_PLL_N_VAL_20
<< 8)|
59 .pll_reg_2
= cpu_to_le16(TA_PLL_P_VAL_20
),
62 .pll_reg_1
= cpu_to_le16((PLL960_P_VAL_20
<< 8)|
64 .pll_reg_2
= cpu_to_le16(PLL960_M_VAL_20
),
68 .pll_reg
= cpu_to_le16(0x9f0),
72 .switch_clk_info
= 0x0,
73 .bbp_lmac_clk_reg_val
= 0x0,
74 .umac_clock_reg_config
= 0x0,
75 .qspi_uart_clock_reg_config
= 0x0
81 .pll_reg_1
= cpu_to_le16((TA_PLL_N_VAL_20
<< 8)|
83 .pll_reg_2
= cpu_to_le16(TA_PLL_P_VAL_20
),
86 .pll_reg_1
= cpu_to_le16((PLL960_P_VAL_20
<< 8)|
88 .pll_reg_2
= cpu_to_le16(PLL960_M_VAL_20
),
92 .pll_reg
= cpu_to_le16(0x9f0),
96 .switch_clk_info
= 0x0,
97 .bbp_lmac_clk_reg_val
= 0x0,
98 .umac_clock_reg_config
= 0x0,
99 .qspi_uart_clock_reg_config
= 0x0
102 .buckboost_wakeup_cnt
= 0x0,
103 .pmu_wakeup_wait
= 0x0,
104 .shutdown_wait_time
= 0x0,
105 .pmu_slp_clkout_sel
= 0x0,
106 .wdt_prog_value
= 0x0,
107 .wdt_soc_rst_delay
= 0x0,
108 .dcdc_operation_mode
= 0x0,
109 .soc_reset_wait_cnt
= 0x0,
110 .waiting_time_at_fresh_sleep
= 0x0,
111 .max_threshold_to_avoid_sleep
= 0x0,
112 .beacon_resedue_alg_en
= 0,
115 static struct bootup_params boot_params_40
= {
116 .magic_number
= cpu_to_le16(0x5aa5),
117 .crystal_good_time
= 0x0,
118 .valid
= cpu_to_le32(VALID_40
),
119 .reserved_for_valids
= 0x0,
120 .bootup_mode_info
= 0x0,
121 .digital_loop_back_params
= 0x0,
122 .rtls_timestamp_en
= 0x0,
123 .host_spi_intr_cfg
= 0x0,
124 .device_clk_info
= {{
127 .pll_reg_1
= cpu_to_le16((TA_PLL_N_VAL_40
<< 8)|
129 .pll_reg_2
= cpu_to_le16(TA_PLL_P_VAL_40
),
132 .pll_reg_1
= cpu_to_le16((PLL960_P_VAL_40
<< 8)|
134 .pll_reg_2
= cpu_to_le16(PLL960_M_VAL_40
),
138 .pll_reg
= cpu_to_le16(0x9f0),
142 .switch_clk_info
= cpu_to_le16(0x09),
143 .bbp_lmac_clk_reg_val
= cpu_to_le16(0x1121),
144 .umac_clock_reg_config
= cpu_to_le16(0x48),
145 .qspi_uart_clock_reg_config
= cpu_to_le16(0x1211)
151 .pll_reg_1
= cpu_to_le16((TA_PLL_N_VAL_40
<< 8)|
153 .pll_reg_2
= cpu_to_le16(TA_PLL_P_VAL_40
),
156 .pll_reg_1
= cpu_to_le16((PLL960_P_VAL_40
<< 8)|
158 .pll_reg_2
= cpu_to_le16(PLL960_M_VAL_40
),
162 .pll_reg
= cpu_to_le16(0x9f0),
166 .switch_clk_info
= 0x0,
167 .bbp_lmac_clk_reg_val
= 0x0,
168 .umac_clock_reg_config
= 0x0,
169 .qspi_uart_clock_reg_config
= 0x0
175 .pll_reg_1
= cpu_to_le16((TA_PLL_N_VAL_40
<< 8)|
177 .pll_reg_2
= cpu_to_le16(TA_PLL_P_VAL_40
),
180 .pll_reg_1
= cpu_to_le16((PLL960_P_VAL_40
<< 8)|
182 .pll_reg_2
= cpu_to_le16(PLL960_M_VAL_40
),
186 .pll_reg
= cpu_to_le16(0x9f0),
190 .switch_clk_info
= 0x0,
191 .bbp_lmac_clk_reg_val
= 0x0,
192 .umac_clock_reg_config
= 0x0,
193 .qspi_uart_clock_reg_config
= 0x0
196 .buckboost_wakeup_cnt
= 0x0,
197 .pmu_wakeup_wait
= 0x0,
198 .shutdown_wait_time
= 0x0,
199 .pmu_slp_clkout_sel
= 0x0,
200 .wdt_prog_value
= 0x0,
201 .wdt_soc_rst_delay
= 0x0,
202 .dcdc_operation_mode
= 0x0,
203 .soc_reset_wait_cnt
= 0x0,
204 .waiting_time_at_fresh_sleep
= 0x0,
205 .max_threshold_to_avoid_sleep
= 0x0,
206 .beacon_resedue_alg_en
= 0,
209 static u16 mcs
[] = {13, 26, 39, 52, 78, 104, 117, 130};
212 * rsi_set_default_parameters() - This function sets default parameters.
213 * @common: Pointer to the driver private structure.
217 static void rsi_set_default_parameters(struct rsi_common
*common
)
219 common
->band
= NL80211_BAND_2GHZ
;
220 common
->channel_width
= BW_20MHZ
;
221 common
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
223 common
->min_rate
= 0xffff;
224 common
->fsm_state
= FSM_CARD_NOT_READY
;
225 common
->iface_down
= true;
226 common
->endpoint
= EP_2GHZ_20MHZ
;
230 * rsi_set_contention_vals() - This function sets the contention values for the
232 * @common: Pointer to the driver private structure.
236 static void rsi_set_contention_vals(struct rsi_common
*common
)
240 for (; ii
< NUM_EDCA_QUEUES
; ii
++) {
241 common
->tx_qinfo
[ii
].wme_params
=
242 (((common
->edca_params
[ii
].cw_min
/ 2) +
243 (common
->edca_params
[ii
].aifs
)) *
244 WMM_SHORT_SLOT_TIME
+ SIFS_DURATION
);
245 common
->tx_qinfo
[ii
].weight
= common
->tx_qinfo
[ii
].wme_params
;
246 common
->tx_qinfo
[ii
].pkt_contended
= 0;
251 * rsi_send_internal_mgmt_frame() - This function sends management frames to
252 * firmware.Also schedules packet to queue
254 * @common: Pointer to the driver private structure.
255 * @skb: Pointer to the socket buffer structure.
257 * Return: 0 on success, -1 on failure.
259 static int rsi_send_internal_mgmt_frame(struct rsi_common
*common
,
262 struct skb_info
*tx_params
;
265 rsi_dbg(ERR_ZONE
, "%s: Unable to allocate skb\n", __func__
);
268 tx_params
= (struct skb_info
*)&IEEE80211_SKB_CB(skb
)->driver_data
;
269 tx_params
->flags
|= INTERNAL_MGMT_PKT
;
270 skb_queue_tail(&common
->tx_queue
[MGMT_SOFT_Q
], skb
);
271 rsi_set_event(&common
->tx_thread
.event
);
276 * rsi_load_radio_caps() - This function is used to send radio capabilities
277 * values to firmware.
278 * @common: Pointer to the driver private structure.
280 * Return: 0 on success, corresponding negative error code on failure.
282 static int rsi_load_radio_caps(struct rsi_common
*common
)
284 struct rsi_radio_caps
*radio_caps
;
285 struct rsi_hw
*adapter
= common
->priv
;
289 u16 gc
[20] = {0xf0, 0xf0, 0xf0, 0xf0,
290 0xf0, 0xf0, 0xf0, 0xf0,
291 0xf0, 0xf0, 0xf0, 0xf0,
292 0xf0, 0xf0, 0xf0, 0xf0,
293 0xf0, 0xf0, 0xf0, 0xf0};
296 rsi_dbg(INFO_ZONE
, "%s: Sending rate symbol req frame\n", __func__
);
298 skb
= dev_alloc_skb(sizeof(struct rsi_radio_caps
));
301 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
306 memset(skb
->data
, 0, sizeof(struct rsi_radio_caps
));
307 radio_caps
= (struct rsi_radio_caps
*)skb
->data
;
309 radio_caps
->desc_word
[1] = cpu_to_le16(RADIO_CAPABILITIES
);
310 radio_caps
->desc_word
[4] = cpu_to_le16(RSI_RF_TYPE
<< 8);
312 if (common
->channel_width
== BW_40MHZ
) {
313 radio_caps
->desc_word
[7] |= cpu_to_le16(RSI_LMAC_CLOCK_80MHZ
);
314 radio_caps
->desc_word
[7] |= cpu_to_le16(RSI_ENABLE_40MHZ
);
316 if (common
->fsm_state
== FSM_MAC_INIT_DONE
) {
317 struct ieee80211_hw
*hw
= adapter
->hw
;
318 struct ieee80211_conf
*conf
= &hw
->conf
;
319 if (conf_is_ht40_plus(conf
)) {
320 radio_caps
->desc_word
[5] =
321 cpu_to_le16(LOWER_20_ENABLE
);
322 radio_caps
->desc_word
[5] |=
323 cpu_to_le16(LOWER_20_ENABLE
>> 12);
324 } else if (conf_is_ht40_minus(conf
)) {
325 radio_caps
->desc_word
[5] =
326 cpu_to_le16(UPPER_20_ENABLE
);
327 radio_caps
->desc_word
[5] |=
328 cpu_to_le16(UPPER_20_ENABLE
>> 12);
330 radio_caps
->desc_word
[5] =
331 cpu_to_le16(BW_40MHZ
<< 12);
332 radio_caps
->desc_word
[5] |=
333 cpu_to_le16(FULL40M_ENABLE
);
338 radio_caps
->sifs_tx_11n
= cpu_to_le16(SIFS_TX_11N_VALUE
);
339 radio_caps
->sifs_tx_11b
= cpu_to_le16(SIFS_TX_11B_VALUE
);
340 radio_caps
->slot_rx_11n
= cpu_to_le16(SHORT_SLOT_VALUE
);
341 radio_caps
->ofdm_ack_tout
= cpu_to_le16(OFDM_ACK_TOUT_VALUE
);
342 radio_caps
->cck_ack_tout
= cpu_to_le16(CCK_ACK_TOUT_VALUE
);
343 radio_caps
->preamble_type
= cpu_to_le16(LONG_PREAMBLE
);
345 radio_caps
->desc_word
[7] |= cpu_to_le16(radio_id
<< 8);
347 for (ii
= 0; ii
< MAX_HW_QUEUES
; ii
++) {
348 radio_caps
->qos_params
[ii
].cont_win_min_q
= cpu_to_le16(3);
349 radio_caps
->qos_params
[ii
].cont_win_max_q
= cpu_to_le16(0x3f);
350 radio_caps
->qos_params
[ii
].aifsn_val_q
= cpu_to_le16(2);
351 radio_caps
->qos_params
[ii
].txop_q
= 0;
354 for (ii
= 0; ii
< MAX_HW_QUEUES
- 4; ii
++) {
355 radio_caps
->qos_params
[ii
].cont_win_min_q
=
356 cpu_to_le16(common
->edca_params
[ii
].cw_min
);
357 radio_caps
->qos_params
[ii
].cont_win_max_q
=
358 cpu_to_le16(common
->edca_params
[ii
].cw_max
);
359 radio_caps
->qos_params
[ii
].aifsn_val_q
=
360 cpu_to_le16((common
->edca_params
[ii
].aifs
) << 8);
361 radio_caps
->qos_params
[ii
].txop_q
=
362 cpu_to_le16(common
->edca_params
[ii
].txop
);
365 memcpy(&common
->rate_pwr
[0], &gc
[0], 40);
366 for (ii
= 0; ii
< 20; ii
++)
367 radio_caps
->gcpd_per_rate
[inx
++] =
368 cpu_to_le16(common
->rate_pwr
[ii
] & 0x00FF);
370 radio_caps
->desc_word
[0] = cpu_to_le16((sizeof(struct rsi_radio_caps
) -
372 (RSI_WIFI_MGMT_Q
<< 12));
375 skb_put(skb
, (sizeof(struct rsi_radio_caps
)));
377 return rsi_send_internal_mgmt_frame(common
, skb
);
381 * rsi_mgmt_pkt_to_core() - This function is the entry point for Mgmt module.
382 * @common: Pointer to the driver private structure.
383 * @msg: Pointer to received packet.
384 * @msg_len: Length of the recieved packet.
385 * @type: Type of recieved packet.
387 * Return: 0 on success, -1 on failure.
389 static int rsi_mgmt_pkt_to_core(struct rsi_common
*common
,
394 struct rsi_hw
*adapter
= common
->priv
;
395 struct ieee80211_tx_info
*info
;
396 struct skb_info
*rx_params
;
397 u8 pad_bytes
= msg
[4];
402 if (type
== RX_DOT11_MGMT
) {
403 if (!adapter
->sc_nvifs
)
406 msg_len
-= pad_bytes
;
408 rsi_dbg(MGMT_RX_ZONE
,
409 "%s: Invalid rx msg of len = %d\n",
414 skb
= dev_alloc_skb(msg_len
);
416 rsi_dbg(ERR_ZONE
, "%s: Failed to allocate skb\n",
421 buffer
= skb_put(skb
, msg_len
);
424 (u8
*)(msg
+ FRAME_DESC_SZ
+ pad_bytes
),
427 pkt_recv
= buffer
[0];
429 info
= IEEE80211_SKB_CB(skb
);
430 rx_params
= (struct skb_info
*)info
->driver_data
;
431 rx_params
->rssi
= rsi_get_rssi(msg
);
432 rx_params
->channel
= rsi_get_channel(msg
);
433 rsi_indicate_pkt_to_os(common
, skb
);
435 rsi_dbg(MGMT_TX_ZONE
, "%s: Internal Packet\n", __func__
);
442 * rsi_hal_send_sta_notify_frame() - This function sends the station notify
444 * @common: Pointer to the driver private structure.
445 * @opmode: Operating mode of device.
446 * @notify_event: Notification about station connection.
448 * @qos_enable: Qos is enabled.
449 * @aid: Aid (unique for all STA).
451 * Return: status: 0 on success, corresponding negative error code on failure.
453 static int rsi_hal_send_sta_notify_frame(struct rsi_common
*common
,
456 const unsigned char *bssid
,
460 struct sk_buff
*skb
= NULL
;
461 struct rsi_peer_notify
*peer_notify
;
465 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending sta notify frame\n", __func__
);
467 skb
= dev_alloc_skb(sizeof(struct rsi_peer_notify
));
470 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
475 memset(skb
->data
, 0, sizeof(struct rsi_peer_notify
));
476 peer_notify
= (struct rsi_peer_notify
*)skb
->data
;
478 peer_notify
->command
= cpu_to_le16(opmode
<< 1);
480 switch (notify_event
) {
482 peer_notify
->command
|= cpu_to_le16(RSI_ADD_PEER
);
484 case STA_DISCONNECTED
:
485 peer_notify
->command
|= cpu_to_le16(RSI_DELETE_PEER
);
491 peer_notify
->command
|= cpu_to_le16((aid
& 0xfff) << 4);
492 ether_addr_copy(peer_notify
->mac_addr
, bssid
);
494 peer_notify
->sta_flags
= cpu_to_le32((qos_enable
) ? 1 : 0);
496 peer_notify
->desc_word
[0] =
497 cpu_to_le16((sizeof(struct rsi_peer_notify
) - FRAME_DESC_SZ
) |
498 (RSI_WIFI_MGMT_Q
<< 12));
499 peer_notify
->desc_word
[1] = cpu_to_le16(PEER_NOTIFY
);
500 peer_notify
->desc_word
[7] |= cpu_to_le16(vap_id
<< 8);
502 skb_put(skb
, sizeof(struct rsi_peer_notify
));
504 status
= rsi_send_internal_mgmt_frame(common
, skb
);
506 if (!status
&& qos_enable
) {
507 rsi_set_contention_vals(common
);
508 status
= rsi_load_radio_caps(common
);
514 * rsi_send_aggregation_params_frame() - This function sends the ampdu
515 * indication frame to firmware.
516 * @common: Pointer to the driver private structure.
517 * @tid: traffic identifier.
519 * @buf_size: buffer size.
520 * @event: notification about station connection.
522 * Return: 0 on success, corresponding negative error code on failure.
524 int rsi_send_aggregation_params_frame(struct rsi_common
*common
,
530 struct sk_buff
*skb
= NULL
;
531 struct rsi_mac_frame
*mgmt_frame
;
534 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
537 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
542 memset(skb
->data
, 0, FRAME_DESC_SZ
);
543 mgmt_frame
= (struct rsi_mac_frame
*)skb
->data
;
545 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending AMPDU indication frame\n", __func__
);
547 mgmt_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
548 mgmt_frame
->desc_word
[1] = cpu_to_le16(AMPDU_IND
);
550 if (event
== STA_TX_ADDBA_DONE
) {
551 mgmt_frame
->desc_word
[4] = cpu_to_le16(ssn
);
552 mgmt_frame
->desc_word
[5] = cpu_to_le16(buf_size
);
553 mgmt_frame
->desc_word
[7] =
554 cpu_to_le16((tid
| (START_AMPDU_AGGR
<< 4) | (peer_id
<< 8)));
555 } else if (event
== STA_RX_ADDBA_DONE
) {
556 mgmt_frame
->desc_word
[4] = cpu_to_le16(ssn
);
557 mgmt_frame
->desc_word
[7] = cpu_to_le16(tid
|
558 (START_AMPDU_AGGR
<< 4) |
559 (RX_BA_INDICATION
<< 5) |
561 } else if (event
== STA_TX_DELBA
) {
562 mgmt_frame
->desc_word
[7] = cpu_to_le16(tid
|
563 (STOP_AMPDU_AGGR
<< 4) |
565 } else if (event
== STA_RX_DELBA
) {
566 mgmt_frame
->desc_word
[7] = cpu_to_le16(tid
|
567 (STOP_AMPDU_AGGR
<< 4) |
568 (RX_BA_INDICATION
<< 5) |
572 skb_put(skb
, FRAME_DESC_SZ
);
574 return rsi_send_internal_mgmt_frame(common
, skb
);
578 * rsi_program_bb_rf() - This function starts base band and RF programming.
579 * This is called after initial configurations are done.
580 * @common: Pointer to the driver private structure.
582 * Return: 0 on success, corresponding negative error code on failure.
584 static int rsi_program_bb_rf(struct rsi_common
*common
)
587 struct rsi_mac_frame
*mgmt_frame
;
589 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending program BB/RF frame\n", __func__
);
591 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
593 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
598 memset(skb
->data
, 0, FRAME_DESC_SZ
);
599 mgmt_frame
= (struct rsi_mac_frame
*)skb
->data
;
601 mgmt_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
602 mgmt_frame
->desc_word
[1] = cpu_to_le16(BBP_PROG_IN_TA
);
603 mgmt_frame
->desc_word
[4] = cpu_to_le16(common
->endpoint
);
605 if (common
->rf_reset
) {
606 mgmt_frame
->desc_word
[7] = cpu_to_le16(RF_RESET_ENABLE
);
607 rsi_dbg(MGMT_TX_ZONE
, "%s: ===> RF RESET REQUEST SENT <===\n",
609 common
->rf_reset
= 0;
611 common
->bb_rf_prog_count
= 1;
612 mgmt_frame
->desc_word
[7] |= cpu_to_le16(PUT_BBP_RESET
|
613 BBP_REG_WRITE
| (RSI_RF_TYPE
<< 4));
614 skb_put(skb
, FRAME_DESC_SZ
);
616 return rsi_send_internal_mgmt_frame(common
, skb
);
620 * rsi_set_vap_capabilities() - This function send vap capability to firmware.
621 * @common: Pointer to the driver private structure.
622 * @opmode: Operating mode of device.
624 * Return: 0 on success, corresponding negative error code on failure.
626 int rsi_set_vap_capabilities(struct rsi_common
*common
,
630 struct sk_buff
*skb
= NULL
;
631 struct rsi_vap_caps
*vap_caps
;
632 struct rsi_hw
*adapter
= common
->priv
;
633 struct ieee80211_hw
*hw
= adapter
->hw
;
634 struct ieee80211_conf
*conf
= &hw
->conf
;
637 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending VAP capabilities frame\n", __func__
);
639 skb
= dev_alloc_skb(sizeof(struct rsi_vap_caps
));
641 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
646 memset(skb
->data
, 0, sizeof(struct rsi_vap_caps
));
647 vap_caps
= (struct rsi_vap_caps
*)skb
->data
;
649 vap_caps
->desc_word
[0] = cpu_to_le16((sizeof(struct rsi_vap_caps
) -
651 (RSI_WIFI_MGMT_Q
<< 12));
652 vap_caps
->desc_word
[1] = cpu_to_le16(VAP_CAPABILITIES
);
653 vap_caps
->desc_word
[2] = cpu_to_le16(vap_status
<< 8);
654 vap_caps
->desc_word
[4] = cpu_to_le16(mode
|
655 (common
->channel_width
<< 8));
656 vap_caps
->desc_word
[7] = cpu_to_le16((vap_id
<< 8) |
657 (common
->mac_id
<< 4) |
660 memcpy(vap_caps
->mac_addr
, common
->mac_addr
, IEEE80211_ADDR_LEN
);
661 vap_caps
->keep_alive_period
= cpu_to_le16(90);
662 vap_caps
->frag_threshold
= cpu_to_le16(IEEE80211_MAX_FRAG_THRESHOLD
);
664 vap_caps
->rts_threshold
= cpu_to_le16(common
->rts_threshold
);
665 vap_caps
->default_mgmt_rate
= cpu_to_le32(RSI_RATE_6
);
667 if (common
->band
== NL80211_BAND_5GHZ
) {
668 vap_caps
->default_ctrl_rate
= cpu_to_le32(RSI_RATE_6
);
669 if (conf_is_ht40(&common
->priv
->hw
->conf
)) {
670 vap_caps
->default_ctrl_rate
|=
671 cpu_to_le32(FULL40M_ENABLE
<< 16);
674 vap_caps
->default_ctrl_rate
= cpu_to_le32(RSI_RATE_1
);
675 if (conf_is_ht40_minus(conf
))
676 vap_caps
->default_ctrl_rate
|=
677 cpu_to_le32(UPPER_20_ENABLE
<< 16);
678 else if (conf_is_ht40_plus(conf
))
679 vap_caps
->default_ctrl_rate
|=
680 cpu_to_le32(LOWER_20_ENABLE
<< 16);
683 vap_caps
->default_data_rate
= 0;
684 vap_caps
->beacon_interval
= cpu_to_le16(200);
685 vap_caps
->dtim_period
= cpu_to_le16(4);
687 skb_put(skb
, sizeof(*vap_caps
));
689 return rsi_send_internal_mgmt_frame(common
, skb
);
693 * rsi_hal_load_key() - This function is used to load keys within the firmware.
694 * @common: Pointer to the driver private structure.
695 * @data: Pointer to the key data.
696 * @key_len: Key length to be loaded.
697 * @key_type: Type of key: GROUP/PAIRWISE.
698 * @key_id: Key index.
699 * @cipher: Type of cipher used.
701 * Return: 0 on success, -1 on failure.
703 int rsi_hal_load_key(struct rsi_common
*common
,
710 struct sk_buff
*skb
= NULL
;
711 struct rsi_set_key
*set_key
;
712 u16 key_descriptor
= 0;
714 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending load key frame\n", __func__
);
716 skb
= dev_alloc_skb(sizeof(struct rsi_set_key
));
718 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
723 memset(skb
->data
, 0, sizeof(struct rsi_set_key
));
724 set_key
= (struct rsi_set_key
*)skb
->data
;
726 if ((cipher
== WLAN_CIPHER_SUITE_WEP40
) ||
727 (cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
729 key_descriptor
|= BIT(2);
731 key_descriptor
|= BIT(3);
732 } else if (cipher
!= KEY_TYPE_CLEAR
) {
733 key_descriptor
|= BIT(4);
734 if (key_type
== RSI_PAIRWISE_KEY
)
736 if (cipher
== WLAN_CIPHER_SUITE_TKIP
)
737 key_descriptor
|= BIT(5);
739 key_descriptor
|= (key_type
| BIT(13) | (key_id
<< 14));
741 set_key
->desc_word
[0] = cpu_to_le16((sizeof(struct rsi_set_key
) -
743 (RSI_WIFI_MGMT_Q
<< 12));
744 set_key
->desc_word
[1] = cpu_to_le16(SET_KEY_REQ
);
745 set_key
->desc_word
[4] = cpu_to_le16(key_descriptor
);
747 if ((cipher
== WLAN_CIPHER_SUITE_WEP40
) ||
748 (cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
749 memcpy(&set_key
->key
[key_id
][1],
753 memcpy(&set_key
->key
[0][0], data
, key_len
);
756 memcpy(set_key
->tx_mic_key
, &data
[16], 8);
757 memcpy(set_key
->rx_mic_key
, &data
[24], 8);
759 skb_put(skb
, sizeof(struct rsi_set_key
));
761 return rsi_send_internal_mgmt_frame(common
, skb
);
765 * rsi_load_bootup_params() - This function send bootup params to the firmware.
766 * @common: Pointer to the driver private structure.
768 * Return: 0 on success, corresponding error code on failure.
770 static int rsi_load_bootup_params(struct rsi_common
*common
)
773 struct rsi_boot_params
*boot_params
;
775 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending boot params frame\n", __func__
);
776 skb
= dev_alloc_skb(sizeof(struct rsi_boot_params
));
778 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
783 memset(skb
->data
, 0, sizeof(struct rsi_boot_params
));
784 boot_params
= (struct rsi_boot_params
*)skb
->data
;
786 rsi_dbg(MGMT_TX_ZONE
, "%s:\n", __func__
);
788 if (common
->channel_width
== BW_40MHZ
) {
789 memcpy(&boot_params
->bootup_params
,
791 sizeof(struct bootup_params
));
792 rsi_dbg(MGMT_TX_ZONE
, "%s: Packet 40MHZ <=== %d\n", __func__
,
794 boot_params
->desc_word
[7] = cpu_to_le16(UMAC_CLK_40BW
);
796 memcpy(&boot_params
->bootup_params
,
798 sizeof(struct bootup_params
));
799 if (boot_params_20
.valid
!= cpu_to_le32(VALID_20
)) {
800 boot_params
->desc_word
[7] = cpu_to_le16(UMAC_CLK_20BW
);
801 rsi_dbg(MGMT_TX_ZONE
,
802 "%s: Packet 20MHZ <=== %d\n", __func__
,
805 boot_params
->desc_word
[7] = cpu_to_le16(UMAC_CLK_40MHZ
);
806 rsi_dbg(MGMT_TX_ZONE
,
807 "%s: Packet 20MHZ <=== %d\n", __func__
,
813 * Bit{0:11} indicates length of the Packet
814 * Bit{12:15} indicates host queue number
816 boot_params
->desc_word
[0] = cpu_to_le16(sizeof(struct bootup_params
) |
817 (RSI_WIFI_MGMT_Q
<< 12));
818 boot_params
->desc_word
[1] = cpu_to_le16(BOOTUP_PARAMS_REQUEST
);
820 skb_put(skb
, sizeof(struct rsi_boot_params
));
822 return rsi_send_internal_mgmt_frame(common
, skb
);
826 * rsi_send_reset_mac() - This function prepares reset MAC request and sends an
827 * internal management frame to indicate it to firmware.
828 * @common: Pointer to the driver private structure.
830 * Return: 0 on success, corresponding error code on failure.
832 static int rsi_send_reset_mac(struct rsi_common
*common
)
835 struct rsi_mac_frame
*mgmt_frame
;
837 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending reset MAC frame\n", __func__
);
839 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
841 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
846 memset(skb
->data
, 0, FRAME_DESC_SZ
);
847 mgmt_frame
= (struct rsi_mac_frame
*)skb
->data
;
849 mgmt_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
850 mgmt_frame
->desc_word
[1] = cpu_to_le16(RESET_MAC_REQ
);
851 mgmt_frame
->desc_word
[4] = cpu_to_le16(RETRY_COUNT
<< 8);
853 skb_put(skb
, FRAME_DESC_SZ
);
855 return rsi_send_internal_mgmt_frame(common
, skb
);
859 * rsi_band_check() - This function programs the band
860 * @common: Pointer to the driver private structure.
862 * Return: 0 on success, corresponding error code on failure.
864 int rsi_band_check(struct rsi_common
*common
)
866 struct rsi_hw
*adapter
= common
->priv
;
867 struct ieee80211_hw
*hw
= adapter
->hw
;
868 u8 prev_bw
= common
->channel_width
;
869 u8 prev_ep
= common
->endpoint
;
870 struct ieee80211_channel
*curchan
= hw
->conf
.chandef
.chan
;
873 if (common
->band
!= curchan
->band
) {
874 common
->rf_reset
= 1;
875 common
->band
= curchan
->band
;
878 if ((hw
->conf
.chandef
.width
== NL80211_CHAN_WIDTH_20_NOHT
) ||
879 (hw
->conf
.chandef
.width
== NL80211_CHAN_WIDTH_20
))
880 common
->channel_width
= BW_20MHZ
;
882 common
->channel_width
= BW_40MHZ
;
884 if (common
->band
== NL80211_BAND_2GHZ
) {
885 if (common
->channel_width
)
886 common
->endpoint
= EP_2GHZ_40MHZ
;
888 common
->endpoint
= EP_2GHZ_20MHZ
;
890 if (common
->channel_width
)
891 common
->endpoint
= EP_5GHZ_40MHZ
;
893 common
->endpoint
= EP_5GHZ_20MHZ
;
896 if (common
->endpoint
!= prev_ep
) {
897 status
= rsi_program_bb_rf(common
);
902 if (common
->channel_width
!= prev_bw
) {
903 status
= rsi_load_bootup_params(common
);
907 status
= rsi_load_radio_caps(common
);
916 * rsi_set_channel() - This function programs the channel.
917 * @common: Pointer to the driver private structure.
918 * @channel: Channel value to be set.
920 * Return: 0 on success, corresponding error code on failure.
922 int rsi_set_channel(struct rsi_common
*common
,
923 struct ieee80211_channel
*channel
)
925 struct sk_buff
*skb
= NULL
;
926 struct rsi_mac_frame
*mgmt_frame
;
928 rsi_dbg(MGMT_TX_ZONE
,
929 "%s: Sending scan req frame\n", __func__
);
931 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
933 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
942 memset(skb
->data
, 0, FRAME_DESC_SZ
);
943 mgmt_frame
= (struct rsi_mac_frame
*)skb
->data
;
945 mgmt_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
946 mgmt_frame
->desc_word
[1] = cpu_to_le16(SCAN_REQUEST
);
947 mgmt_frame
->desc_word
[4] = cpu_to_le16(channel
->hw_value
);
949 mgmt_frame
->desc_word
[4] |=
950 cpu_to_le16(((char)(channel
->max_antenna_gain
)) << 8);
951 mgmt_frame
->desc_word
[5] =
952 cpu_to_le16((char)(channel
->max_antenna_gain
));
954 mgmt_frame
->desc_word
[7] = cpu_to_le16(PUT_BBP_RESET
|
958 if (!(channel
->flags
& IEEE80211_CHAN_NO_IR
) &&
959 !(channel
->flags
& IEEE80211_CHAN_RADAR
)) {
960 if (common
->tx_power
< channel
->max_power
)
961 mgmt_frame
->desc_word
[6] = cpu_to_le16(common
->tx_power
);
963 mgmt_frame
->desc_word
[6] = cpu_to_le16(channel
->max_power
);
965 mgmt_frame
->desc_word
[7] = cpu_to_le16(common
->priv
->dfs_region
);
967 if (common
->channel_width
== BW_40MHZ
)
968 mgmt_frame
->desc_word
[5] |= cpu_to_le16(0x1 << 8);
970 common
->channel
= channel
->hw_value
;
972 skb_put(skb
, FRAME_DESC_SZ
);
974 return rsi_send_internal_mgmt_frame(common
, skb
);
978 * rsi_send_radio_params_update() - This function sends the radio
979 * parameters update to device
980 * @common: Pointer to the driver private structure.
981 * @channel: Channel value to be set.
983 * Return: 0 on success, corresponding error code on failure.
985 int rsi_send_radio_params_update(struct rsi_common
*common
)
987 struct rsi_mac_frame
*cmd_frame
;
988 struct sk_buff
*skb
= NULL
;
990 rsi_dbg(MGMT_TX_ZONE
,
991 "%s: Sending Radio Params update frame\n", __func__
);
993 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
995 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
1000 memset(skb
->data
, 0, FRAME_DESC_SZ
);
1001 cmd_frame
= (struct rsi_mac_frame
*)skb
->data
;
1003 cmd_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
1004 cmd_frame
->desc_word
[1] = cpu_to_le16(RADIO_PARAMS_UPDATE
);
1005 cmd_frame
->desc_word
[3] = cpu_to_le16(BIT(0));
1007 cmd_frame
->desc_word
[3] |= cpu_to_le16(common
->tx_power
<< 8);
1009 skb_put(skb
, FRAME_DESC_SZ
);
1011 return rsi_send_internal_mgmt_frame(common
, skb
);
1015 * rsi_compare() - This function is used to compare two integers
1016 * @a: pointer to the first integer
1017 * @b: pointer to the second integer
1019 * Return: 0 if both are equal, -1 if the first is smaller, else 1
1021 static int rsi_compare(const void *a
, const void *b
)
1023 u16 _a
= *(const u16
*)(a
);
1024 u16 _b
= *(const u16
*)(b
);
1036 * rsi_map_rates() - This function is used to map selected rates to hw rates.
1037 * @rate: The standard rate to be mapped.
1038 * @offset: Offset that will be returned.
1040 * Return: 0 if it is a mcs rate, else 1
1042 static bool rsi_map_rates(u16 rate
, int *offset
)
1045 for (kk
= 0; kk
< ARRAY_SIZE(rsi_mcsrates
); kk
++) {
1046 if (rate
== mcs
[kk
]) {
1052 for (kk
= 0; kk
< ARRAY_SIZE(rsi_rates
); kk
++) {
1053 if (rate
== rsi_rates
[kk
].bitrate
/ 5) {
1062 * rsi_send_auto_rate_request() - This function is to set rates for connection
1063 * and send autorate request to firmware.
1064 * @common: Pointer to the driver private structure.
1066 * Return: 0 on success, corresponding error code on failure.
1068 static int rsi_send_auto_rate_request(struct rsi_common
*common
)
1070 struct sk_buff
*skb
;
1071 struct rsi_auto_rate
*auto_rate
;
1072 int ii
= 0, jj
= 0, kk
= 0;
1073 struct ieee80211_hw
*hw
= common
->priv
->hw
;
1074 u8 band
= hw
->conf
.chandef
.chan
->band
;
1075 u8 num_supported_rates
= 0;
1076 u8 rate_table_offset
, rate_offset
= 0;
1077 u32 rate_bitmap
= common
->bitrate_mask
[band
];
1079 u16
*selected_rates
, min_rate
;
1081 skb
= dev_alloc_skb(sizeof(struct rsi_auto_rate
));
1083 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
1088 selected_rates
= kzalloc(2 * RSI_TBL_SZ
, GFP_KERNEL
);
1089 if (!selected_rates
) {
1090 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of mem\n",
1096 memset(skb
->data
, 0, sizeof(struct rsi_auto_rate
));
1098 auto_rate
= (struct rsi_auto_rate
*)skb
->data
;
1100 auto_rate
->aarf_rssi
= cpu_to_le16(((u16
)3 << 6) | (u16
)(18 & 0x3f));
1101 auto_rate
->collision_tolerance
= cpu_to_le16(3);
1102 auto_rate
->failure_limit
= cpu_to_le16(3);
1103 auto_rate
->initial_boundary
= cpu_to_le16(3);
1104 auto_rate
->max_threshold_limt
= cpu_to_le16(27);
1106 auto_rate
->desc_word
[1] = cpu_to_le16(AUTO_RATE_IND
);
1108 if (common
->channel_width
== BW_40MHZ
)
1109 auto_rate
->desc_word
[7] |= cpu_to_le16(1);
1111 if (band
== NL80211_BAND_2GHZ
) {
1112 min_rate
= RSI_RATE_1
;
1113 rate_table_offset
= 0;
1115 min_rate
= RSI_RATE_6
;
1116 rate_table_offset
= 4;
1119 for (ii
= 0, jj
= 0;
1120 ii
< (ARRAY_SIZE(rsi_rates
) - rate_table_offset
); ii
++) {
1121 if (rate_bitmap
& BIT(ii
)) {
1122 selected_rates
[jj
++] =
1123 (rsi_rates
[ii
+ rate_table_offset
].bitrate
/ 5);
1127 num_supported_rates
= jj
;
1129 if (common
->vif_info
[0].is_ht
) {
1130 for (ii
= 0; ii
< ARRAY_SIZE(mcs
); ii
++)
1131 selected_rates
[jj
++] = mcs
[ii
];
1132 num_supported_rates
+= ARRAY_SIZE(mcs
);
1133 rate_offset
+= ARRAY_SIZE(mcs
);
1136 sort(selected_rates
, jj
, sizeof(u16
), &rsi_compare
, NULL
);
1138 /* mapping the rates to RSI rates */
1139 for (ii
= 0; ii
< jj
; ii
++) {
1140 if (rsi_map_rates(selected_rates
[ii
], &kk
)) {
1141 auto_rate
->supported_rates
[ii
] =
1142 cpu_to_le16(rsi_rates
[kk
].hw_value
);
1144 auto_rate
->supported_rates
[ii
] =
1145 cpu_to_le16(rsi_mcsrates
[kk
]);
1149 /* loading HT rates in the bottom half of the auto rate table */
1150 if (common
->vif_info
[0].is_ht
) {
1151 for (ii
= rate_offset
, kk
= ARRAY_SIZE(rsi_mcsrates
) - 1;
1152 ii
< rate_offset
+ 2 * ARRAY_SIZE(rsi_mcsrates
); ii
++) {
1153 if (common
->vif_info
[0].sgi
||
1154 conf_is_ht40(&common
->priv
->hw
->conf
))
1155 auto_rate
->supported_rates
[ii
++] =
1156 cpu_to_le16(rsi_mcsrates
[kk
] | BIT(9));
1157 auto_rate
->supported_rates
[ii
] =
1158 cpu_to_le16(rsi_mcsrates
[kk
--]);
1161 for (; ii
< (RSI_TBL_SZ
- 1); ii
++) {
1162 auto_rate
->supported_rates
[ii
] =
1163 cpu_to_le16(rsi_mcsrates
[0]);
1167 for (; ii
< RSI_TBL_SZ
; ii
++)
1168 auto_rate
->supported_rates
[ii
] = cpu_to_le16(min_rate
);
1170 auto_rate
->num_supported_rates
= cpu_to_le16(num_supported_rates
* 2);
1171 auto_rate
->moderate_rate_inx
= cpu_to_le16(num_supported_rates
/ 2);
1172 auto_rate
->desc_word
[7] |= cpu_to_le16(0 << 8);
1173 num_supported_rates
*= 2;
1175 auto_rate
->desc_word
[0] = cpu_to_le16((sizeof(*auto_rate
) -
1177 (RSI_WIFI_MGMT_Q
<< 12));
1180 sizeof(struct rsi_auto_rate
));
1181 kfree(selected_rates
);
1183 return rsi_send_internal_mgmt_frame(common
, skb
);
1187 * rsi_inform_bss_status() - This function informs about bss status with the
1188 * help of sta notify params by sending an internal
1189 * management frame to firmware.
1190 * @common: Pointer to the driver private structure.
1191 * @status: Bss status type.
1193 * @qos_enable: Qos is enabled.
1194 * @aid: Aid (unique for all STAs).
1198 void rsi_inform_bss_status(struct rsi_common
*common
,
1200 const unsigned char *bssid
,
1205 rsi_hal_send_sta_notify_frame(common
,
1211 if (common
->min_rate
== 0xffff)
1212 rsi_send_auto_rate_request(common
);
1214 rsi_hal_send_sta_notify_frame(common
,
1224 * rsi_eeprom_read() - This function sends a frame to read the mac address
1226 * @common: Pointer to the driver private structure.
1228 * Return: 0 on success, -1 on failure.
1230 static int rsi_eeprom_read(struct rsi_common
*common
)
1232 struct rsi_mac_frame
*mgmt_frame
;
1233 struct sk_buff
*skb
;
1235 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending EEPROM read req frame\n", __func__
);
1237 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
1239 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
1244 memset(skb
->data
, 0, FRAME_DESC_SZ
);
1245 mgmt_frame
= (struct rsi_mac_frame
*)skb
->data
;
1248 mgmt_frame
->desc_word
[1] = cpu_to_le16(EEPROM_READ_TYPE
);
1249 mgmt_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
1250 /* Number of bytes to read */
1251 mgmt_frame
->desc_word
[3] = cpu_to_le16(ETH_ALEN
+
1252 WLAN_MAC_MAGIC_WORD_LEN
+
1253 WLAN_HOST_MODE_LEN
+
1254 WLAN_FW_VERSION_LEN
);
1255 /* Address to read */
1256 mgmt_frame
->desc_word
[4] = cpu_to_le16(WLAN_MAC_EEPROM_ADDR
);
1258 skb_put(skb
, FRAME_DESC_SZ
);
1260 return rsi_send_internal_mgmt_frame(common
, skb
);
1264 * This function sends a frame to block/unblock
1265 * data queues in the firmware
1267 * @param common Pointer to the driver private structure.
1268 * @param block event - block if true, unblock if false
1269 * @return 0 on success, -1 on failure.
1271 int rsi_send_block_unblock_frame(struct rsi_common
*common
, bool block_event
)
1273 struct rsi_mac_frame
*mgmt_frame
;
1274 struct sk_buff
*skb
;
1276 rsi_dbg(MGMT_TX_ZONE
, "%s: Sending block/unblock frame\n", __func__
);
1278 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
1280 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
1285 memset(skb
->data
, 0, FRAME_DESC_SZ
);
1286 mgmt_frame
= (struct rsi_mac_frame
*)skb
->data
;
1288 mgmt_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
1289 mgmt_frame
->desc_word
[1] = cpu_to_le16(BLOCK_HW_QUEUE
);
1292 rsi_dbg(INFO_ZONE
, "blocking the data qs\n");
1293 mgmt_frame
->desc_word
[4] = cpu_to_le16(0xf);
1295 rsi_dbg(INFO_ZONE
, "unblocking the data qs\n");
1296 mgmt_frame
->desc_word
[5] = cpu_to_le16(0xf);
1299 skb_put(skb
, FRAME_DESC_SZ
);
1301 return rsi_send_internal_mgmt_frame(common
, skb
);
1306 * rsi_send_rx_filter_frame() - Sends a frame to filter the RX packets
1308 * @common: Pointer to the driver private structure.
1309 * @rx_filter_word: Flags of filter packets
1311 * @Return: 0 on success, -1 on failure.
1313 int rsi_send_rx_filter_frame(struct rsi_common
*common
, u16 rx_filter_word
)
1315 struct rsi_mac_frame
*cmd_frame
;
1316 struct sk_buff
*skb
;
1318 rsi_dbg(MGMT_TX_ZONE
, "Sending RX filter frame\n");
1320 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
1322 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
1327 memset(skb
->data
, 0, FRAME_DESC_SZ
);
1328 cmd_frame
= (struct rsi_mac_frame
*)skb
->data
;
1330 cmd_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
1331 cmd_frame
->desc_word
[1] = cpu_to_le16(SET_RX_FILTER
);
1332 cmd_frame
->desc_word
[4] = cpu_to_le16(rx_filter_word
);
1334 skb_put(skb
, FRAME_DESC_SZ
);
1336 return rsi_send_internal_mgmt_frame(common
, skb
);
1340 * rsi_set_antenna() - This fuction send antenna configuration request
1343 * @common: Pointer to the driver private structure.
1344 * @antenna: bitmap for tx antenna selection
1346 * Return: 0 on Success, negative error code on failure
1348 int rsi_set_antenna(struct rsi_common
*common
, u8 antenna
)
1350 struct rsi_mac_frame
*cmd_frame
;
1351 struct sk_buff
*skb
;
1353 skb
= dev_alloc_skb(FRAME_DESC_SZ
);
1355 rsi_dbg(ERR_ZONE
, "%s: Failed in allocation of skb\n",
1360 memset(skb
->data
, 0, FRAME_DESC_SZ
);
1361 cmd_frame
= (struct rsi_mac_frame
*)skb
->data
;
1363 cmd_frame
->desc_word
[1] = cpu_to_le16(ANT_SEL_FRAME
);
1364 cmd_frame
->desc_word
[3] = cpu_to_le16(antenna
& 0x00ff);
1365 cmd_frame
->desc_word
[0] = cpu_to_le16(RSI_WIFI_MGMT_Q
<< 12);
1367 skb_put(skb
, FRAME_DESC_SZ
);
1369 return rsi_send_internal_mgmt_frame(common
, skb
);
1373 * rsi_handle_ta_confirm_type() - This function handles the confirm frames.
1374 * @common: Pointer to the driver private structure.
1375 * @msg: Pointer to received packet.
1377 * Return: 0 on success, -1 on failure.
1379 static int rsi_handle_ta_confirm_type(struct rsi_common
*common
,
1382 u8 sub_type
= (msg
[15] & 0xff);
1385 case BOOTUP_PARAMS_REQUEST
:
1386 rsi_dbg(FSM_ZONE
, "%s: Boot up params confirm received\n",
1388 if (common
->fsm_state
== FSM_BOOT_PARAMS_SENT
) {
1389 if (rsi_eeprom_read(common
)) {
1390 common
->fsm_state
= FSM_CARD_NOT_READY
;
1393 common
->fsm_state
= FSM_EEPROM_READ_MAC_ADDR
;
1397 "%s: Received bootup params cfm in %d state\n",
1398 __func__
, common
->fsm_state
);
1403 case EEPROM_READ_TYPE
:
1404 if (common
->fsm_state
== FSM_EEPROM_READ_MAC_ADDR
) {
1405 if (msg
[16] == MAGIC_WORD
) {
1406 u8 offset
= (FRAME_DESC_SZ
+ WLAN_HOST_MODE_LEN
1407 + WLAN_MAC_MAGIC_WORD_LEN
);
1408 memcpy(common
->mac_addr
,
1411 memcpy(&common
->fw_ver
,
1412 &msg
[offset
+ ETH_ALEN
],
1413 sizeof(struct version_info
));
1416 common
->fsm_state
= FSM_CARD_NOT_READY
;
1419 if (rsi_send_reset_mac(common
))
1422 common
->fsm_state
= FSM_RESET_MAC_SENT
;
1425 "%s: Received eeprom mac addr in %d state\n",
1426 __func__
, common
->fsm_state
);
1432 if (common
->fsm_state
== FSM_RESET_MAC_SENT
) {
1433 rsi_dbg(FSM_ZONE
, "%s: Reset MAC cfm received\n",
1436 if (rsi_load_radio_caps(common
))
1439 common
->fsm_state
= FSM_RADIO_CAPS_SENT
;
1442 "%s: Received reset mac cfm in %d state\n",
1443 __func__
, common
->fsm_state
);
1448 case RADIO_CAPABILITIES
:
1449 if (common
->fsm_state
== FSM_RADIO_CAPS_SENT
) {
1450 common
->rf_reset
= 1;
1451 if (rsi_program_bb_rf(common
)) {
1454 common
->fsm_state
= FSM_BB_RF_PROG_SENT
;
1455 rsi_dbg(FSM_ZONE
, "%s: Radio cap cfm received\n",
1460 "%s: Received radio caps cfm in %d state\n",
1461 __func__
, common
->fsm_state
);
1466 case BB_PROG_VALUES_REQUEST
:
1467 case RF_PROG_VALUES_REQUEST
:
1468 case BBP_PROG_IN_TA
:
1469 rsi_dbg(FSM_ZONE
, "%s: BB/RF cfm received\n", __func__
);
1470 if (common
->fsm_state
== FSM_BB_RF_PROG_SENT
) {
1471 common
->bb_rf_prog_count
--;
1472 if (!common
->bb_rf_prog_count
) {
1473 common
->fsm_state
= FSM_MAC_INIT_DONE
;
1474 return rsi_mac80211_attach(common
);
1478 "%s: Received bbb_rf cfm in %d state\n",
1479 __func__
, common
->fsm_state
);
1485 rsi_dbg(INFO_ZONE
, "%s: Invalid TA confirm pkt received\n",
1491 rsi_dbg(ERR_ZONE
, "%s: Unable to send pkt/Invalid frame received\n",
1497 * rsi_mgmt_pkt_recv() - This function processes the management packets
1498 * recieved from the hardware.
1499 * @common: Pointer to the driver private structure.
1500 * @msg: Pointer to the received packet.
1502 * Return: 0 on success, -1 on failure.
1504 int rsi_mgmt_pkt_recv(struct rsi_common
*common
, u8
*msg
)
1506 s32 msg_len
= (le16_to_cpu(*(__le16
*)&msg
[0]) & 0x0fff);
1507 u16 msg_type
= (msg
[2]);
1510 rsi_dbg(FSM_ZONE
, "%s: Msg Len: %d, Msg Type: %4x\n",
1511 __func__
, msg_len
, msg_type
);
1513 if (msg_type
== TA_CONFIRM_TYPE
) {
1514 return rsi_handle_ta_confirm_type(common
, msg
);
1515 } else if (msg_type
== CARD_READY_IND
) {
1516 rsi_dbg(FSM_ZONE
, "%s: Card ready indication received\n",
1518 if (common
->fsm_state
== FSM_CARD_NOT_READY
) {
1519 rsi_set_default_parameters(common
);
1521 ret
= rsi_load_bootup_params(common
);
1525 common
->fsm_state
= FSM_BOOT_PARAMS_SENT
;
1529 } else if (msg_type
== TX_STATUS_IND
) {
1530 if (msg
[15] == PROBEREQ_CONFIRM
) {
1531 common
->mgmt_q_block
= false;
1532 rsi_dbg(FSM_ZONE
, "%s: Probe confirm received\n",
1536 return rsi_mgmt_pkt_to_core(common
, msg
, msg_len
, msg_type
);