2 * Copyright (c) 2009 - 2012 Espressif System.
5 #include <net/mac80211.h>
6 #include <net/cfg80211.h>
7 #include <linux/skbuff.h>
8 #include <linux/bitops.h>
9 #include <linux/firmware.h>
15 #include "esp_debug.h"
16 #include "slc_host_register.h"
18 #include "esp_utils.h"
21 #include "esp_android.h"
26 #endif /* TEST_MODE */
27 #include "esp_version.h"
29 extern struct completion *gl_bootup_cplx;
31 #ifdef ESP_RX_COPYBACK_TEST
32 static void sip_show_copyback_buf(void)
34 //show_buf(copyback_buf, copyback_offset);
36 #endif /* ESP_RX_COPYBACK_TEST */
38 static void esp_tx_ba_session_op(struct esp_sip *sip, struct esp_node *node, trc_ampdu_state_t state, u8 tid )
40 struct esp_tx_tid *txtid;
42 txtid = &node->tid[tid];
43 if (state == TRC_TX_AMPDU_STOPPED) {
44 if (txtid->state == ESP_TID_STATE_OPERATIONAL) {
45 esp_dbg(ESP_DBG_TXAMPDU, "%s tid %d TXAMPDU GOT STOP EVT\n", __func__, tid);
47 spin_lock_bh(&sip->epub->tx_ampdu_lock);
48 txtid->state = ESP_TID_STATE_WAIT_STOP;
49 spin_unlock_bh(&sip->epub->tx_ampdu_lock);
50 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28))
51 ieee80211_stop_tx_ba_session(sip->epub->hw, node->addr, (u16)tid, WLAN_BACK_INITIATOR);
52 #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32))
53 ieee80211_stop_tx_ba_session(sip->epub->hw, node->sta->addr, (u16)tid, WLAN_BACK_INITIATOR);
54 #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
55 ieee80211_stop_tx_ba_session(node->sta, (u16)tid, WLAN_BACK_INITIATOR);
57 ieee80211_stop_tx_ba_session(node->sta, (u16)tid);
58 #endif /* KERNEL_VERSION 2.6.39 */
60 esp_dbg(ESP_DBG_TXAMPDU, "%s tid %d TXAMPDU GOT STOP EVT IN WRONG STATE %d\n", __func__, tid, txtid->state);
62 } else if (state == TRC_TX_AMPDU_OPERATIONAL) {
63 if (txtid->state == ESP_TID_STATE_STOP) {
64 esp_dbg(ESP_DBG_TXAMPDU, "%s tid %d TXAMPDU GOT OPERATIONAL\n", __func__, tid);
66 spin_lock_bh(&sip->epub->tx_ampdu_lock);
67 txtid->state = ESP_TID_STATE_TRIGGER;
68 spin_unlock_bh(&sip->epub->tx_ampdu_lock);
69 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28))
70 ieee80211_start_tx_ba_session(sip->epub->hw, node->addr, tid);
71 #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32))
72 ieee80211_start_tx_ba_session(sip->epub->hw, node->sta->addr, tid);
73 #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 37))
74 ieee80211_start_tx_ba_session(node->sta, (u16)tid);
76 ieee80211_start_tx_ba_session(node->sta, (u16)tid, 0);
77 #endif /* KERNEL_VERSION 2.6.39 */
79 } else if(txtid->state == ESP_TID_STATE_OPERATIONAL) {
80 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28))
81 sip_send_ampdu_action(sip->epub, SIP_AMPDU_TX_OPERATIONAL, node->addr, tid, node->ifidx, 0);
83 sip_send_ampdu_action(sip->epub, SIP_AMPDU_TX_OPERATIONAL, node->sta->addr, tid, node->ifidx, 0);
86 esp_dbg(ESP_DBG_TXAMPDU, "%s tid %d TXAMPDU GOT OPERATIONAL EVT IN WRONG STATE %d\n", __func__, tid, txtid->state);
91 int sip_parse_events(struct esp_sip *sip, u8 *buf)
93 struct sip_hdr *hdr = (struct sip_hdr *)buf;
95 switch (hdr->c_evtid) {
96 case SIP_EVT_TARGET_ON: {
97 /* use rx work queue to send... */
98 if (atomic_read(&sip->state) == SIP_PREPARE_BOOT || atomic_read(&sip->state) == SIP_BOOT) {
99 atomic_set(&sip->state, SIP_SEND_INIT);
100 queue_work(sip->epub->esp_wkq, &sip->rx_process_work);
102 esp_dbg(ESP_DBG_ERROR, "%s boot during wrong state %d\n", __func__, atomic_read(&sip->state));
107 case SIP_EVT_BOOTUP: {
108 struct sip_evt_bootup2 *bootup_evt = (struct sip_evt_bootup2 *)(buf + SIP_CTRL_HDR_LEN);
112 sip_post_init(sip, bootup_evt);
115 complete(gl_bootup_cplx);
119 case SIP_EVT_RESETTING:{
120 sip->epub->wait_reset = 1;
122 complete(gl_bootup_cplx);
126 //atomic_set(&sip->epub->ps.state, ESP_PM_ON);
129 case SIP_EVT_TXIDLE:{
130 //struct sip_evt_txidle *txidle = (struct sip_evt_txidle *)(buf + SIP_CTRL_HDR_LEN);
131 //sip_txdone_clear(sip, txidle->last_seq);
134 #ifndef FAST_TX_STATUS
135 case SIP_EVT_TX_STATUS: {
136 struct sip_evt_tx_report *report = (struct sip_evt_tx_report *)(buf + SIP_CTRL_HDR_LEN);
137 sip_txdoneq_process(sip, report);
141 #endif /* FAST_TX_STATUS */
143 case SIP_EVT_SCAN_RESULT: {
144 struct sip_evt_scan_report *report = (struct sip_evt_scan_report *)(buf + SIP_CTRL_HDR_LEN);
145 if (atomic_read(&sip->epub->wl.off)) {
146 esp_dbg(ESP_DBG_ERROR, "%s scan result while wlan off\n", __func__);
149 sip_scandone_process(sip, report);
155 struct sip_evt_roc* report = (struct sip_evt_roc *)(buf + SIP_CTRL_HDR_LEN);
156 esp_rocdone_process(sip->epub->hw, report);
161 #ifdef ESP_RX_COPYBACK_TEST
163 case SIP_EVT_COPYBACK: {
164 u32 len = hdr->len - SIP_CTRL_HDR_LEN;
166 esp_dbg(ESP_DBG_TRACE, "%s copyback len %d seq %u\n", __func__, len, hdr->seq);
168 memcpy(copyback_buf + copyback_offset, pkt->buf + SIP_CTRL_HDR_LEN, len);
169 copyback_offset += len;
171 //show_buf(pkt->buf, 256);
173 //how about totlen % 256 == 0??
174 if (hdr->hdr.len < 256) {
175 //sip_show_copyback_buf();
180 #endif /* ESP_RX_COPYBACK_TEST */
181 case SIP_EVT_CREDIT_RPT:
185 case SIP_EVT_WAKEUP: {
187 struct sip_evt_wakeup* wakeup_evt= (struct sip_evt_wakeup *)(buf + SIP_CTRL_HDR_LEN);
188 sprintf((char *)&check_str, "%d", wakeup_evt->check_data);
189 esp_test_cmd_event(TEST_CMD_WAKEUP, (char *)&check_str);
193 case SIP_EVT_DEBUG: {
196 char * ptr_str = (char *)& check_str;
197 struct sip_evt_debug* debug_evt = (struct sip_evt_debug *)(buf + SIP_CTRL_HDR_LEN);
198 for(i = 0; i < debug_evt->len; i++)
199 ptr_str += sprintf(ptr_str, "0x%x%s", debug_evt->results[i], i == debug_evt->len -1 ? "":" " );
200 esp_test_cmd_event(TEST_CMD_DEBUG, (char *)&check_str);
204 case SIP_EVT_LOOPBACK: {
206 struct sip_evt_loopback *loopback_evt = (struct sip_evt_loopback *)(buf + SIP_CTRL_HDR_LEN);
207 esp_dbg(ESP_DBG_LOG, "%s loopback len %d seq %u\n", __func__,hdr->len, hdr->seq);
209 if(loopback_evt->pack_id!=get_loopback_id()) {
210 sprintf((char *)&check_str, "seq id error %d, expect %d", loopback_evt->pack_id, get_loopback_id());
211 esp_test_cmd_event(TEST_CMD_LOOPBACK, (char *)&check_str);
214 if((loopback_evt->pack_id+1) <get_loopback_num()) {
216 sip_send_loopback_mblk(sip, loopback_evt->txlen, loopback_evt->rxlen, get_loopback_id());
218 sprintf((char *)&check_str, "test over!");
219 esp_test_cmd_event(TEST_CMD_LOOPBACK, (char *)&check_str);
225 case SIP_EVT_SNPRINTF_TO_HOST: {
226 u8 *p = (buf + sizeof(struct sip_hdr) + sizeof(u16));
227 u16 *len = (u16 *)(buf + sizeof(struct sip_hdr));
228 char test_res_str[560];
229 sprintf(test_res_str, "esp_host:%llx\nesp_target: %.*s", DRIVER_VER, *len, p);
231 esp_dbg(ESP_SHOW, "%s\n", test_res_str);
233 if(*len && sip->epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT){
235 if (mod_eagle_path_get() == NULL)
236 sprintf(filename, "%s/%s", FWPATH, "test_results");
238 sprintf(filename, "%s/%s", mod_eagle_path_get(), "test_results");
239 android_readwrite_file(filename, NULL, test_res_str, strlen(test_res_str));
244 case SIP_EVT_TRC_AMPDU: {
245 struct sip_evt_trc_ampdu *ep = (struct sip_evt_trc_ampdu*)(buf + SIP_CTRL_HDR_LEN);
246 struct esp_node *node = NULL;
249 if (atomic_read(&sip->epub->wl.off)) {
250 esp_dbg(ESP_DBG_ERROR, "%s scan result while wlan off\n", __func__);
254 node = esp_get_node_by_addr(sip->epub, ep->addr);
258 esp_tx_ba_session_op(sip, node, ep->state, ep->tid);
260 for (i = 0; i < 8; i++) {
261 if (ep->tid & (1<<i)) {
262 esp_tx_ba_session_op(sip, node, ep->state, i);
270 char *ep = (char *)(buf + SIP_CTRL_HDR_LEN);
271 static int counter = 0;
273 esp_dbg(ESP_ATE, "%s EVT_EP \n\n", __func__);
275 esp_dbg(ESP_ATE, "ATE: %s \n", ep);
278 esp_test_ate_done_cb(ep);
282 case SIP_EVT_INIT_EP: {
283 char *ep = (char *)(buf + SIP_CTRL_HDR_LEN);
284 esp_dbg(ESP_ATE, "Phy Init: %s \n", ep);
288 case SIP_EVT_NOISEFLOOR:{
289 struct sip_evt_noisefloor *ep = (struct sip_evt_noisefloor *)(buf + SIP_CTRL_HDR_LEN);
290 atomic_set(&sip->noise_floor, ep->noise_floor);
301 #include "esp_init_data.h"
303 #define ESP_INIT_NAME "esp_init_data.bin"
304 #endif /* HAS_INIT_DATA */
306 void sip_send_chip_init(struct esp_sip *sip)
309 #ifndef HAS_INIT_DATA
310 const struct firmware *fw_entry;
311 u8 * esp_init_data = NULL;
314 ret = android_request_firmware(&fw_entry, ESP_INIT_NAME, sip->epub->dev);
316 ret = request_firmware(&fw_entry, ESP_INIT_NAME, sip->epub->dev);
320 esp_dbg(ESP_DBG_ERROR, "%s =============ERROR! NO INIT DATA!!=================\n", __func__);
323 esp_init_data = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
325 size = fw_entry->size;
328 android_release_firmware(fw_entry);
330 release_firmware(fw_entry);
333 if (esp_init_data == NULL) {
334 esp_dbg(ESP_DBG_ERROR, "%s =============ERROR! NO MEMORY!!=================\n", __func__);
338 size = sizeof(esp_init_data);
340 #endif /* !HAS_INIT_DATA */
343 //show_init_buf(esp_init_data,size);
344 fix_init_data(esp_init_data, size);
345 //show_init_buf(esp_init_data,size);
347 atomic_sub(1, &sip->tx_credits);
349 sip_send_cmd(sip, SIP_CMD_INIT, size, (void *)esp_init_data);
351 #ifndef HAS_INIT_DATA
352 kfree(esp_init_data);
353 #endif /* !HAS_INIT_DATA */
356 int sip_send_config(struct esp_pub *epub, struct ieee80211_conf * conf)
358 struct sk_buff *skb = NULL;
359 struct sip_cmd_config *configcmd;
361 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_config) + sizeof(struct sip_hdr), SIP_CMD_CONFIG);
364 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0))
365 esp_dbg(ESP_DBG_TRACE, "%s config center freq %d\n", __func__, conf->chandef.chan->center_freq);
367 esp_dbg(ESP_DBG_TRACE, "%s config center freq %d\n", __func__, conf->channel->center_freq);
369 configcmd = (struct sip_cmd_config *)(skb->data + sizeof(struct sip_hdr));
370 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0))
371 configcmd->center_freq= conf->chandef.chan->center_freq;
373 configcmd->center_freq= conf->channel->center_freq;
375 configcmd->duration= 0;
376 return sip_cmd_enqueue(epub->sip, skb);
379 int sip_send_bss_info_update(struct esp_pub *epub, struct esp_vif *evif, u8 *bssid, int assoc)
381 struct sk_buff *skb = NULL;
382 struct sip_cmd_bss_info_update*bsscmd;
384 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_bss_info_update) + sizeof(struct sip_hdr), SIP_CMD_BSS_INFO_UPDATE);
388 bsscmd = (struct sip_cmd_bss_info_update *)(skb->data + sizeof(struct sip_hdr));
389 if (assoc == 2) { //hack for softAP mode
390 bsscmd->beacon_int = evif->beacon_interval;
391 } else if (assoc == 1) {
392 set_bit(ESP_WL_FLAG_CONNECT, &epub->wl.flags);
394 clear_bit(ESP_WL_FLAG_CONNECT, &epub->wl.flags);
396 bsscmd->bssid_no = evif->index;
397 bsscmd->isassoc= assoc;
398 bsscmd->beacon_int = evif->beacon_interval;
399 memcpy(bsscmd->bssid, bssid, ETH_ALEN);
400 return sip_cmd_enqueue(epub->sip, skb);
403 int sip_send_wmm_params(struct esp_pub *epub, u8 aci, const struct ieee80211_tx_queue_params *params)
405 struct sk_buff *skb = NULL;
406 struct sip_cmd_set_wmm_params* bsscmd;
407 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_set_wmm_params) + sizeof(struct sip_hdr), SIP_CMD_SET_WMM_PARAM);
411 bsscmd = (struct sip_cmd_set_wmm_params *)(skb->data + sizeof(struct sip_hdr));
413 bsscmd->aifs=params->aifs;
414 bsscmd->txop_us=params->txop*32;
416 bsscmd->ecw_min = 32 - __builtin_clz(params->cw_min);
417 bsscmd->ecw_max= 32 -__builtin_clz(params->cw_max);
419 return sip_cmd_enqueue(epub->sip, skb);
422 int sip_send_ampdu_action(struct esp_pub *epub, u8 action_num, const u8 * addr, u16 tid, u16 ssn, u8 buf_size)
425 struct sk_buff *skb = NULL;
426 struct sip_cmd_ampdu_action * action;
427 if(action_num == SIP_AMPDU_RX_START){
428 index = esp_get_empty_rxampdu(epub, addr, tid);
429 } else if(action_num == SIP_AMPDU_RX_STOP){
430 index = esp_get_exist_rxampdu(epub, addr, tid);
434 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_ampdu_action) + sizeof(struct sip_hdr), SIP_CMD_AMPDU_ACTION);
438 action = (struct sip_cmd_ampdu_action *)(skb->data + sizeof(struct sip_hdr));
439 action->action = action_num;
440 //for TX, it means interface index
444 case SIP_AMPDU_RX_START:
446 case SIP_AMPDU_RX_STOP:
447 action->index = index;
448 case SIP_AMPDU_TX_OPERATIONAL:
449 case SIP_AMPDU_TX_STOP:
450 action->win_size = buf_size;
452 memcpy(action->addr, addr, ETH_ALEN);
456 return sip_cmd_enqueue(epub->sip, skb);
460 /*send cmd to target, if aborted is true, inform target stop scan, report scan complete imediately
461 return 1: complete over, 0: success, still have next scan, -1: hardware failure
463 int sip_send_scan(struct esp_pub *epub)
465 struct cfg80211_scan_request *scan_req = epub->wl.scan_req;
466 struct sk_buff *skb = NULL;
467 struct sip_cmd_scan *scancmd;
470 u8 append_len, ssid_len;
472 ESSERT(scan_req != NULL);
473 ssid_len = scan_req->n_ssids == 0 ? 0:
474 (scan_req->n_ssids == 1 ? scan_req->ssids->ssid_len: scan_req->ssids->ssid_len + (scan_req->ssids + 1)->ssid_len);
475 append_len = ssid_len + scan_req->n_channels + scan_req->ie_len;
477 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_scan) + sizeof(struct sip_hdr) + append_len, SIP_CMD_SCAN);
483 scancmd = (struct sip_cmd_scan *)(ptr + sizeof(struct sip_hdr));
484 ptr += sizeof(struct sip_hdr);
486 scancmd->aborted= false;
488 if (scancmd->aborted==false) {
489 ptr += sizeof(struct sip_cmd_scan);
490 if (scan_req->n_ssids <=0 || (scan_req->n_ssids == 1&& ssid_len == 0)) {
491 scancmd->ssid_len = 0;
493 scancmd->ssid_len = ssid_len;
494 if(scan_req->ssids->ssid_len == ssid_len)
495 memcpy(ptr, scan_req->ssids->ssid, scancmd->ssid_len);
497 memcpy(ptr, (scan_req->ssids + 1)->ssid, scancmd->ssid_len);
500 ptr += scancmd->ssid_len;
501 scancmd->n_channels=scan_req->n_channels;
502 for (i=0; i<scan_req->n_channels; i++)
503 ptr[i] = scan_req->channels[i]->hw_value;
505 ptr += scancmd->n_channels;
506 if (scan_req->ie_len && scan_req->ie != NULL) {
507 scancmd->ie_len=scan_req->ie_len;
508 memcpy(ptr, scan_req->ie, scan_req->ie_len);
512 //add a flag that support two ssids,
513 if(scan_req->n_ssids > 1)
514 scancmd->ssid_len |= 0x80;
518 return sip_cmd_enqueue(epub->sip, skb);
522 int sip_send_suspend_config(struct esp_pub *epub, u8 suspend)
524 struct sip_cmd_suspend *cmd = NULL;
525 struct sk_buff *skb = NULL;
527 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_suspend) + sizeof(struct sip_hdr), SIP_CMD_SUSPEND);
532 cmd = (struct sip_cmd_suspend *)(skb->data + sizeof(struct sip_hdr));
533 cmd->suspend = suspend;
534 return sip_cmd_enqueue(epub->sip, skb);
537 int sip_send_ps_config(struct esp_pub *epub, struct esp_ps *ps)
539 struct sip_cmd_ps *pscmd = NULL;
540 struct sk_buff *skb = NULL;
541 struct sip_hdr *shdr = NULL;
543 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_ps) + sizeof(struct sip_hdr), SIP_CMD_PS);
549 shdr = (struct sip_hdr *)skb->data;
550 pscmd = (struct sip_cmd_ps *)(skb->data + sizeof(struct sip_hdr));
552 pscmd->dtim_period = ps->dtim_period;
553 pscmd->max_sleep_period = ps->max_sleep_period;
555 return sip_cmd_enqueue(epub->sip, skb);
558 void sip_scandone_process(struct esp_sip *sip, struct sip_evt_scan_report *scan_report)
560 struct esp_pub *epub = sip->epub;
562 esp_dbg(ESP_DBG_TRACE, "eagle hw scan report\n");
564 if (epub->wl.scan_req) {
565 hw_scan_done(epub, scan_report->aborted);
566 epub->wl.scan_req = NULL;
570 int sip_send_setkey(struct esp_pub *epub, u8 bssid_no, u8 *peer_addr, struct ieee80211_key_conf *key, u8 isvalid)
572 struct sip_cmd_setkey *setkeycmd;
573 struct sk_buff *skb = NULL;
575 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_setkey) + sizeof(struct sip_hdr), SIP_CMD_SETKEY);
580 setkeycmd = (struct sip_cmd_setkey *)(skb->data + sizeof(struct sip_hdr));
583 memcpy(setkeycmd->addr, peer_addr, ETH_ALEN);
585 memset(setkeycmd->addr, 0, ETH_ALEN);
588 setkeycmd->bssid_no = bssid_no;
589 setkeycmd->hw_key_idx= key->hw_key_idx;
592 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39))
593 setkeycmd->alg= key->alg;
595 setkeycmd->alg= esp_cipher2alg(key->cipher);
596 #endif /* NEW_KERNEL */
597 setkeycmd->keyidx = key->keyidx;
598 setkeycmd->keylen = key->keylen;
599 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39))
600 if (key->alg == ALG_TKIP) {
602 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
603 #endif /* NEW_KERNEL */
604 memcpy(setkeycmd->key, key->key, 16);
605 memcpy(setkeycmd->key+16,key->key+24,8);
606 memcpy(setkeycmd->key+24,key->key+16,8);
608 memcpy(setkeycmd->key, key->key, key->keylen);
615 return sip_cmd_enqueue(epub->sip, skb);
619 #define LOOPBACK_PKT_LEN 200
620 int sip_send_loopback_cmd_mblk(struct esp_sip *sip)
624 for (cnt = 0; cnt < 4; cnt++) {
625 if (0!=(ret=sip_send_loopback_mblk(sip, LOOPBACK_PKT_LEN, LOOPBACK_PKT_LEN, 0)))
630 #endif /* FPGA_LOOPBACK */
632 int sip_send_loopback_mblk(struct esp_sip *sip, int txpacket_len, int rxpacket_len, int packet_id)
634 struct sk_buff *skb = NULL;
635 struct sip_cmd_loopback *cmd;
639 //send 100 loopback pkt
641 skb = sip_alloc_ctrl_skbuf(sip, sizeof(struct sip_cmd_loopback) + sizeof(struct sip_hdr) + txpacket_len, SIP_CMD_LOOPBACK);
643 skb = sip_alloc_ctrl_skbuf(sip, sizeof(struct sip_cmd_loopback) + sizeof(struct sip_hdr), SIP_CMD_LOOPBACK);
649 cmd = (struct sip_cmd_loopback *)(ptr + sizeof(struct sip_hdr));
650 ptr += sizeof(struct sip_hdr);
651 cmd->txlen = txpacket_len;
652 cmd->rxlen = rxpacket_len;
653 cmd->pack_id = packet_id;
656 ptr += sizeof(struct sip_cmd_loopback);
657 /* fill up pkt payload */
658 for (i = 0; i < txpacket_len; i++) {
663 ret = sip_cmd_enqueue(sip, skb);
671 int sip_send_roc(struct esp_pub *epub, u16 center_freq, u16 duration)
673 struct sk_buff *skb = NULL;
674 struct sip_cmd_config *configcmd;
676 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_config) + sizeof(struct sip_hdr), SIP_CMD_CONFIG);
680 configcmd = (struct sip_cmd_config *)(skb->data + sizeof(struct sip_hdr));
681 configcmd->center_freq= center_freq;
682 configcmd->duration= duration;
683 return sip_cmd_enqueue(epub->sip, skb);
686 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
687 int sip_send_set_sta(struct esp_pub *epub, u8 ifidx, u8 set, struct ieee80211_sta *sta, struct ieee80211_vif *vif, u8 index)
689 int sip_send_set_sta(struct esp_pub *epub, u8 ifidx, u8 set, struct esp_node *node, struct ieee80211_vif *vif, u8 index)
692 struct sk_buff *skb = NULL;
693 struct sip_cmd_setsta *setstacmd;
694 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28))
695 struct ieee80211_ht_info ht_info = node->ht_info;
697 skb = sip_alloc_ctrl_skbuf(epub->sip, sizeof(struct sip_cmd_setsta) + sizeof(struct sip_hdr), SIP_CMD_SETSTA);
701 setstacmd = (struct sip_cmd_setsta *)(skb->data + sizeof(struct sip_hdr));
702 setstacmd->ifidx = ifidx;
703 setstacmd->index = index;
704 setstacmd->set = set;
705 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
707 setstacmd->aid = vif->bss_conf.aid;
709 setstacmd->aid = sta->aid;
710 memcpy(setstacmd->mac, sta->addr, ETH_ALEN);
712 if(sta->ht_cap.ht_supported){
713 if(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20)
714 setstacmd->phymode = ESP_IEEE80211_T_HT20_S;
716 setstacmd->phymode = ESP_IEEE80211_T_HT20_L;
717 setstacmd->ampdu_factor = sta->ht_cap.ampdu_factor;
718 setstacmd->ampdu_density = sta->ht_cap.ampdu_density;
720 if(sta->supp_rates[IEEE80211_BAND_2GHZ] & (~(u32)CONF_HW_BIT_RATE_11B_MASK)){
721 setstacmd->phymode = ESP_IEEE80211_T_OFDM;
723 setstacmd->phymode = ESP_IEEE80211_T_CCK;
728 setstacmd->aid = node->aid;
729 memcpy(setstacmd->mac, node->addr, ETH_ALEN);
731 if(ht_info.ht_supported){
732 if(ht_info.cap & IEEE80211_HT_CAP_SGI_20)
733 setstacmd->phymode = ESP_IEEE80211_T_HT20_S;
735 setstacmd->phymode = ESP_IEEE80211_T_HT20_L;
736 setstacmd->ampdu_factor = ht_info.ampdu_factor;
737 setstacmd->ampdu_density = ht_info.ampdu_density;
739 //note supp_rates is u64[] in 2.6.27
740 if(node->supp_rates[IEEE80211_BAND_2GHZ] & (~(u64)CONF_HW_BIT_RATE_11B_MASK)){
741 setstacmd->phymode = ESP_IEEE80211_T_OFDM;
743 setstacmd->phymode = ESP_IEEE80211_T_CCK;
748 return sip_cmd_enqueue(epub->sip, skb);
751 int sip_cmd(struct esp_pub *epub, enum sip_cmd_id cmd_id, u8 *cmd_buf, u8 cmd_len)
753 struct sk_buff *skb = NULL;
755 skb = sip_alloc_ctrl_skbuf(epub->sip, cmd_len + sizeof(struct sip_hdr), cmd_id);
759 memcpy(skb->data + sizeof(struct sip_hdr), cmd_buf, cmd_len);
761 return sip_cmd_enqueue(epub->sip, skb);