[PATCH] Add join implementation for connecting to BSS

Eugene Krasnikov k.eugene.e at gmail.com
Mon Apr 15 11:49:43 EDT 2013


>From 845b14661e4d798d916edd3f8a009374e7d75896 Mon Sep 17 00:00:00 2001
From: Eugene Krasnikov <k.eugene.e at gmail.com>
Date: Mon, 15 Apr 2013 11:25:21 +0200
Subject: [PATCH] Add join implementation for connecting to BSS

Send CONFIG_BSS and JOIN before sending AUTH frame

Signed-off-by: Eugene Krasnikov <k.eugene.e at gmail.com>
---
 main.c |   23 ++++++++++++++++++-
 smd.c  |   79 ++++++++++++++++++++++++++++++++++++++++++----------------------
 smd.h  |    2 +-
 3 files changed, 75 insertions(+), 29 deletions(-)

diff --git a/main.c b/main.c
index 8117733..e55e958 100644
--- a/main.c
+++ b/main.c
@@ -102,6 +102,7 @@ static int wcn36xx_config(struct ieee80211_hw *hw,
u32 changed)
  ENTER();
  if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  wcn->ch = ieee80211_frequency_to_channel(hw->conf.channel->center_freq);
+ wcn36xx_info("wcn36xx_config channel switch=%d", wcn->ch);
  }

  return 0;
@@ -206,12 +207,17 @@ static void wcn36xx_bss_info_changed(struct
ieee80211_hw *hw,
  ENTER();

  if(changed & BSS_CHANGED_BSSID) {
+ wcn36xx_info("wcn36xx_bss_info_changed
BSS_CHANGED_BSSID=%02x,%02x,%02x,%02x,%02x,%02x",bss_conf->bssid[0],
bss_conf->bssid[1], bss_conf->bssid[2], bss_conf->bssid[3],
bss_conf->bssid[4], bss_conf->bssid[5]);
+ wcn36xx_smd_enter_imps(wcn);
+ wcn36xx_smd_exit_imps(wcn);
+
  wcn36xx_smd_join(wcn, (u8*)bss_conf->bssid, vif->addr, wcn->ch);
+ wcn36xx_smd_config_bss(wcn, true, (u8*)bss_conf->bssid);
  } else if (changed & BSS_CHANGED_BEACON_ENABLED){
  if(!wcn->beacon_enable) {
  wcn->beacon_enable = true;
  skb = ieee80211_beacon_get_tim(hw, vif, &tim_off, &tim_len);
- wcn36xx_smd_config_bss(wcn);
+ wcn36xx_smd_config_bss(wcn, false, NULL);
  wcn36xx_smd_send_beacon(wcn, skb, tim_off, 0);
  }
  } else {
@@ -301,6 +307,19 @@ static int wcn36xx_add_interface(struct ieee80211_hw *hw,

  return 0;
 }
+static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+       struct ieee80211_sta *sta)
+{
+ ENTER();
+ return 0;
+}
+static int wcn36xx_sta_remove(struct ieee80211_hw *hw, struct
ieee80211_vif *vif,
+  struct ieee80211_sta *sta)
+{
+ ENTER();
+ return 0;
+}
+
 static const struct ieee80211_ops wcn36xx_ops = {
  .start = wcn36xx_start,
  .stop = wcn36xx_stop,
@@ -322,6 +341,8 @@ static const struct ieee80211_ops wcn36xx_ops = {
  .bss_info_changed = wcn36xx_bss_info_changed,
  .set_frag_threshold = wcn36xx_set_frag_threshold,
  .set_rts_threshold = wcn36xx_set_rts_threshold,
+ .sta_add = wcn36xx_sta_add,
+ .sta_remove = wcn36xx_sta_remove,
  .get_survey = wcn36xx_get_survey,
  .ampdu_action = wcn36xx_ampdu_action,
  .tx_frames_pending = wcn36xx_tx_frames_pending,
diff --git a/smd.c b/smd.c
index ea374a0..74f551e 100644
--- a/smd.c
+++ b/smd.c
@@ -292,7 +292,7 @@ int wcn36xx_smd_join(struct wcn36xx *wcn, u8
*bssid, u8 *vif, u8 ch)
  memcpy(&msg_body.sta_mac, vif, ETH_ALEN);
  msg_body.ch = ch;
  msg_body.link_state = 1;
-
+ msg_body.max_power = 0xbf;
  PREPARE_BUF(wcn->smd_buf, msg_header, &msg_body)

  return wcn36xx_smd_send_and_wait(wcn, msg_header.msg_len);
@@ -311,45 +311,65 @@ static int wcn36xx_smd_join_rsp(void *buf, size_t len)
  rsp->status, rsp->power);
  return 0;
 }
-int wcn36xx_smd_config_bss(struct wcn36xx *wcn)
+int wcn36xx_smd_config_bss(struct wcn36xx *wcn, bool sta_mode, u8 *bssid)
 {
  struct wcn36xx_fw_msg_config_bss_req msg_body;
  struct wcn36xx_fw_msg_header msg_header;

  INIT_MSG(msg_header, &msg_body, WCN36XX_FW_MSG_TYPE_CONFIG_BSS_REQ)

- memcpy(&msg_body.bssid, &wcn->addresses[0], ETH_ALEN);
- memcpy(&msg_body.self_mac, &wcn->addresses[0], ETH_ALEN);
-
- //TODO do all this configurabel
- msg_body.bss_type = WCN36XX_FW_MSG_BSS_TYPE_AP;
- msg_body.oper_mode = 0; //0 - AP,  1-STA
- msg_body.net_type = WCN36XX_FW_MSG_NET_TYPE_11G;
- msg_body.short_slot_time = 1;
- msg_body.beacon_interval = 0x64;
- msg_body.dtim_period = 2;
- msg_body.cur_op_ch = 1;
- msg_body.ssid.len = 1;
- msg_body.ssid.ssid[0] = 'K';
- msg_body.obss_prot = 1;
- msg_body.hal_pers = 1;
- msg_body.max_tx_power = 0x10;
-
- memcpy(&msg_body.sta_context.bssid, &wcn->addresses[0], ETH_ALEN);
- msg_body.sta_context.short_pream_sup = 1;
- memcpy(&msg_body.sta_context.sta_mac, &wcn->addresses[0], ETH_ALEN);
- msg_body.sta_context.listen_int = 8;
+ if(true == sta_mode) {
+ memcpy(&msg_body.bssid, bssid, ETH_ALEN);
+ memcpy(&msg_body.self_mac, &wcn->addresses[0], ETH_ALEN);
+ msg_body.bss_type = WCN36XX_FW_MSG_BSS_TYPE_STA;
+ msg_body.oper_mode = 1;  //0 - AP,  1-STA
+ msg_body.net_type = WCN36XX_FW_MSG_NET_TYPE_11G;
+ msg_body.coex_11g = 1;
+ msg_body.beacon_interval = 0x64;
+ msg_body.dtim_period = 1;
+ msg_body.cur_op_ch = wcn->ch;
+ memcpy(&msg_body.sta_context.bssid, bssid, ETH_ALEN);
+ msg_body.sta_context.sta_type = 1;
+ msg_body.sta_context.listen_int = 0x64;
+ msg_body.sta_context.wmm_en = 1;
+
+ msg_body.sta_context.max_ampdu_size = 3;
+ msg_body.sta_context.max_ampdu_dens = 5;
+ msg_body.sta_context.dsss_cck_mode_40mhz = 1;
+ msg_body.max_tx_power = 0x14;
+ } else {
+ memcpy(&msg_body.bssid, &wcn->addresses[0], ETH_ALEN);
+ memcpy(&msg_body.self_mac, &wcn->addresses[0], ETH_ALEN);
+
+ //TODO do all this configurabel
+ msg_body.bss_type = WCN36XX_FW_MSG_BSS_TYPE_AP;
+ msg_body.oper_mode = 0; //0 - AP,  1-STA
+ msg_body.net_type = WCN36XX_FW_MSG_NET_TYPE_11G;
+ msg_body.short_slot_time = 1;
+ msg_body.beacon_interval = 0x64;
+ msg_body.dtim_period = 2;
+ msg_body.cur_op_ch = 1;
+ msg_body.ssid.len = 1;
+ msg_body.ssid.ssid[0] = 'K';
+ msg_body.obss_prot = 1;
+ msg_body.hal_pers = 1;
+ msg_body.max_tx_power = 0x10;
+
+ memcpy(&msg_body.sta_context.bssid, &wcn->addresses[0], ETH_ALEN);
+ msg_body.sta_context.short_pream_sup = 1;
+ memcpy(&msg_body.sta_context.sta_mac, &wcn->addresses[0], ETH_ALEN);
+ msg_body.sta_context.listen_int = 8;
+
+ }
  msg_body.sta_context.ht_cap = 1;
+
  msg_body.sta_context.short_gi40mhz = 1;
  msg_body.sta_context.short_gi20mhz = 1;
+
  msg_body.sta_context.sta_id = 0xff;
  msg_body.sta_context.bss_id = 0xff;

  msg_body.sta_context.supported_rates.sta_rate_mode =
WCN36XX_FW_MSG_STA_RATE_MODE_11N;
- msg_body.sta_context.supported_rates.rates_11b[0] = 0x82;
- msg_body.sta_context.supported_rates.rates_11b[1] = 0x84;
- msg_body.sta_context.supported_rates.rates_11b[2] = 0x8b;
- msg_body.sta_context.supported_rates.rates_11b[3] = 0x96;

  msg_body.sta_context.supported_rates.rates_11a[0] = 0x0C;
  msg_body.sta_context.supported_rates.rates_11a[1] = 0x12;
@@ -360,6 +380,11 @@ int wcn36xx_smd_config_bss(struct wcn36xx *wcn)
  msg_body.sta_context.supported_rates.rates_11a[6] = 0x60;
  msg_body.sta_context.supported_rates.rates_11a[7] = 0x6C;

+ msg_body.sta_context.supported_rates.rates_11b[0] = 0x82;
+ msg_body.sta_context.supported_rates.rates_11b[1] = 0x84;
+ msg_body.sta_context.supported_rates.rates_11b[2] = 0x8b;
+ msg_body.sta_context.supported_rates.rates_11b[3] = 0x96;
+
  msg_body.sta_context.supported_rates.supported_mcs_set[0] = 0xFF;
  PREPARE_BUF(wcn->smd_buf, msg_header, &msg_body)

diff --git a/smd.h b/smd.h
index d1cef07..e80394b 100644
--- a/smd.h
+++ b/smd.h
@@ -421,7 +421,7 @@ int wcn36xx_smd_add_sta(struct wcn36xx *wcn,
struct mac_address addr, u32 status
 int wcn36xx_smd_enter_imps(struct wcn36xx *wcn);
 int wcn36xx_smd_exit_imps(struct wcn36xx *wcn);
 int wcn36xx_smd_join(struct wcn36xx *wcn, u8 *bssid, u8 *vif, u8 ch);
-int wcn36xx_smd_config_bss(struct wcn36xx *wcn);
+int wcn36xx_smd_config_bss(struct wcn36xx *wcn, bool sta_mode, u8 *bssid);
 int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct sk_buff
*skb_beacon, u16 tim_off, u16 p2p_off);

 // WCN36XX configuration parameters
--
1.7.10



More information about the wcn36xx mailing list