wl12xx: support IBSS vif type
authorEliad Peller <eliad@wizery.com>
Sun, 14 Aug 2011 10:17:26 +0000 (13:17 +0300)
committerLuciano Coelho <coelho@ti.com>
Mon, 22 Aug 2011 09:35:28 +0000 (12:35 +0300)
Start IBSS role when the interface type is IBSS.
As with sta role, use the dev role until the role
is started.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
drivers/net/wireless/wl12xx/main.c
drivers/net/wireless/wl12xx/scan.c
drivers/net/wireless/wl12xx/tx.c
drivers/net/wireless/wl12xx/wl12xx.h

index 27333d1afd0d67ac0b9a3204554cd9887f7a24bc..e280d9d7911b2871fd2f2dc613410de6e92396f6 100644 (file)
@@ -1770,6 +1770,9 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl)
        case BSS_TYPE_STA_BSS:
                return WL1271_ROLE_STA;
 
+       case BSS_TYPE_IBSS:
+               return WL1271_ROLE_IBSS;
+
        default:
                wl1271_error("invalid bss_type: %d", wl->bss_type);
        }
@@ -1848,7 +1851,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
                if (ret < 0)
                        goto power_off;
 
-               if (wl->bss_type == BSS_TYPE_STA_BSS) {
+               if (wl->bss_type == BSS_TYPE_STA_BSS ||
+                   wl->bss_type == BSS_TYPE_IBSS) {
                        /*
                         * The device role is a special role used for
                         * rx and tx frames prior to association (as
@@ -2078,6 +2082,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
 static int wl1271_join(struct wl1271 *wl, bool set_assoc)
 {
        int ret;
+       bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
 
        /*
         * One of the side effects of the JOIN command is that is clears
@@ -2094,7 +2099,10 @@ static int wl1271_join(struct wl1271 *wl, bool set_assoc)
        if (set_assoc)
                set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags);
 
-       ret = wl12xx_cmd_role_start_sta(wl);
+       if (is_ibss)
+               ret = wl12xx_cmd_role_start_ibss(wl);
+       else
+               ret = wl12xx_cmd_role_start_sta(wl);
        if (ret < 0)
                goto out;
 
@@ -3128,6 +3136,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl,
 {
        bool do_join = false, set_assoc = false;
        bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
+       bool ibss_joined = false;
        u32 sta_rate_set = 0;
        int ret;
        struct ieee80211_sta *sta;
@@ -3141,14 +3150,28 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl,
                        goto out;
        }
 
-       if ((changed & BSS_CHANGED_BEACON_INT)  && is_ibss)
+       if (changed & BSS_CHANGED_IBSS) {
+               if (bss_conf->ibss_joined) {
+                       set_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags);
+                       ibss_joined = true;
+               } else {
+                       if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED,
+                                              &wl->flags)) {
+                               wl1271_unjoin(wl);
+                               wl12xx_cmd_role_start_dev(wl);
+                               wl12xx_roc(wl, wl->dev_role_id);
+                       }
+               }
+       }
+
+       if ((changed & BSS_CHANGED_BEACON_INT) && ibss_joined)
                do_join = true;
 
        /* Need to update the SSID (for filtering etc) */
-       if ((changed & BSS_CHANGED_BEACON) && is_ibss)
+       if ((changed & BSS_CHANGED_BEACON) && ibss_joined)
                do_join = true;
 
-       if ((changed & BSS_CHANGED_BEACON_ENABLED) && is_ibss) {
+       if ((changed & BSS_CHANGED_BEACON_ENABLED) && ibss_joined) {
                wl1271_debug(DEBUG_ADHOC, "ad-hoc beaconing: %s",
                             bss_conf->enable_beacon ? "enabled" : "disabled");
 
index 653091a38dce3266abe7ab32b029feebedd03fd2..7229eaa8901807576ddb5e2ecdd820b61763a4f0 100644 (file)
@@ -34,6 +34,7 @@ void wl1271_scan_complete_work(struct work_struct *work)
        struct delayed_work *dwork;
        struct wl1271 *wl;
        int ret;
+       bool is_sta, is_ibss;
 
        dwork = container_of(work, struct delayed_work, work);
        wl = container_of(dwork, struct wl1271, scan_complete_work);
@@ -59,7 +60,13 @@ void wl1271_scan_complete_work(struct work_struct *work)
        if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) {
                /* restore hardware connection monitoring template */
                wl1271_cmd_build_ap_probe_req(wl, wl->probereq);
-       } else {
+       }
+
+       /* return to ROC if needed */
+       is_sta = (wl->bss_type == BSS_TYPE_STA_BSS);
+       is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
+       if ((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) ||
+           (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) {
                /* restore remain on channel */
                wl12xx_cmd_role_start_dev(wl);
                wl12xx_roc(wl, wl->dev_role_id);
index 1240f4094a8bf1a7fea438cb2cdb0a2563bf8277..8fdffd08d492e4d9c5f65a459d42e777b378c9a1 100644 (file)
@@ -182,7 +182,8 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct sk_buff *skb)
        if (wl->bss_type == BSS_TYPE_AP_BSS)
                return wl12xx_tx_get_hlid_ap(wl, skb);
 
-       if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
+       if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) ||
+           test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))
                return wl->sta_hlid;
        else
                return wl->dev_hlid;
index 487c3c7e0273bfc890d45698262dddad36e9940a..416d68ed95cf6d46b6bed15ea2c9cb17bf071491 100644 (file)
@@ -324,6 +324,7 @@ struct wl1271_ap_key {
 
 enum wl12xx_flags {
        WL1271_FLAG_STA_ASSOCIATED,
+       WL1271_FLAG_IBSS_JOINED,
        WL1271_FLAG_GPIO_POWER,
        WL1271_FLAG_TX_QUEUE_STOPPED,
        WL1271_FLAG_TX_PENDING,