ath6kl: Implement mgmt_tx
[pandora-kernel.git] / drivers / net / wireless / ath / ath6kl / cfg80211.c
index 4752a76..5c98de3 100644 (file)
@@ -888,6 +888,26 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
                   key_usage, key->seq_len);
 
        ar->def_txkey_index = key_index;
+
+       if (ar->nw_type == AP_NETWORK && !pairwise &&
+           (key_type == TKIP_CRYPT || key_type == AES_CRYPT) && params) {
+               ar->ap_mode_bkey.valid = true;
+               ar->ap_mode_bkey.key_index = key_index;
+               ar->ap_mode_bkey.key_type = key_type;
+               ar->ap_mode_bkey.key_len = key->key_len;
+               memcpy(ar->ap_mode_bkey.key, key->key, key->key_len);
+               if (!test_bit(CONNECTED, &ar->flag)) {
+                       ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delay initial group "
+                                  "key configuration until AP mode has been "
+                                  "started\n");
+                       /*
+                        * The key will be set in ath6kl_connect_ap_mode() once
+                        * the connected event is received from the target.
+                        */
+                       return 0;
+               }
+       }
+
        status = ath6kl_wmi_addkey_cmd(ar->wmi, ar->def_txkey_index,
                                       key_type, key_usage, key->key_len,
                                       key->seq, key->key, KEY_OP_INIT_VAL,
@@ -997,6 +1017,9 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy,
        if (ar->prwise_crypto == WEP_CRYPT)
                key_usage |= TX_USAGE;
 
+       if (ar->nw_type == AP_NETWORK && !test_bit(CONNECTED, &ar->flag))
+               return 0; /* Delay until AP mode has been started */
+
        status = ath6kl_wmi_addkey_cmd(ar->wmi, ar->def_txkey_index,
                                       ar->prwise_crypto, key_usage,
                                       key->key_len, key->seq, key->key,
@@ -1495,6 +1518,8 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev,
        if (!add)
                return 0;
 
+       ar->ap_mode_bkey.valid = false;
+
        /* TODO:
         * info->interval
         * info->dtim_period
@@ -1580,7 +1605,11 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev,
        p.dot11_auth_mode = ar->dot11_auth_mode;
        p.ch = cpu_to_le16(ar->next_chan);
 
-       return ath6kl_wmi_ap_profile_commit(ar->wmi, &p);
+       res = ath6kl_wmi_ap_profile_commit(ar->wmi, &p);
+       if (res < 0)
+               return res;
+
+       return 0;
 }
 
 static int ath6kl_add_beacon(struct wiphy *wiphy, struct net_device *dev,
@@ -1610,6 +1639,77 @@ static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev)
        return 0;
 }
 
+static int ath6kl_change_station(struct wiphy *wiphy, struct net_device *dev,
+                                u8 *mac, struct station_parameters *params)
+{
+       struct ath6kl *ar = ath6kl_priv(dev);
+
+       if (ar->nw_type != AP_NETWORK)
+               return -EOPNOTSUPP;
+
+       /* Use this only for authorizing/unauthorizing a station */
+       if (!(params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)))
+               return -EOPNOTSUPP;
+
+       if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
+               return ath6kl_wmi_ap_set_mlme(ar->wmi, WMI_AP_MLME_AUTHORIZE,
+                                             mac, 0);
+       return ath6kl_wmi_ap_set_mlme(ar->wmi, WMI_AP_MLME_UNAUTHORIZE, mac,
+                                     0);
+}
+
+static int ath6kl_remain_on_channel(struct wiphy *wiphy,
+                                   struct net_device *dev,
+                                   struct ieee80211_channel *chan,
+                                   enum nl80211_channel_type channel_type,
+                                   unsigned int duration,
+                                   u64 *cookie)
+{
+       struct ath6kl *ar = ath6kl_priv(dev);
+
+       /* TODO: if already pending or ongoing remain-on-channel,
+        * return -EBUSY */
+       *cookie = 1; /* only a single pending request is supported */
+
+       return ath6kl_wmi_remain_on_chnl_cmd(ar->wmi, chan->center_freq,
+                                            duration);
+}
+
+static int ath6kl_cancel_remain_on_channel(struct wiphy *wiphy,
+                                          struct net_device *dev,
+                                          u64 cookie)
+{
+       struct ath6kl *ar = ath6kl_priv(dev);
+
+       if (cookie != 1)
+               return -ENOENT;
+
+       return ath6kl_wmi_cancel_remain_on_chnl_cmd(ar->wmi);
+}
+
+static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
+                         struct ieee80211_channel *chan, bool offchan,
+                         enum nl80211_channel_type channel_type,
+                         bool channel_type_valid, unsigned int wait,
+                         const u8 *buf, size_t len, u64 *cookie)
+{
+       struct ath6kl *ar = ath6kl_priv(dev);
+       u32 id;
+
+       id = ar->send_action_id++;
+       if (id == 0) {
+               /*
+                * 0 is a reserved value in the WMI command and shall not be
+                * used for the command.
+                */
+               id = ar->send_action_id++;
+       }
+
+       *cookie = id;
+       return ath6kl_wmi_send_action_cmd(ar->wmi, id, chan->center_freq, wait,
+                                         buf, len);
+}
+
 static struct cfg80211_ops ath6kl_cfg80211_ops = {
        .change_virtual_intf = ath6kl_cfg80211_change_iface,
        .scan = ath6kl_cfg80211_scan,
@@ -1636,6 +1736,10 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = {
        .add_beacon = ath6kl_add_beacon,
        .set_beacon = ath6kl_set_beacon,
        .del_beacon = ath6kl_del_beacon,
+       .change_station = ath6kl_change_station,
+       .remain_on_channel = ath6kl_remain_on_channel,
+       .cancel_remain_on_channel = ath6kl_cancel_remain_on_channel,
+       .mgmt_tx = ath6kl_mgmt_tx,
 };
 
 struct wireless_dev *ath6kl_cfg80211_init(struct device *dev)
@@ -1657,6 +1761,8 @@ struct wireless_dev *ath6kl_cfg80211_init(struct device *dev)
                return NULL;
        }
 
+       wdev->wiphy->max_remain_on_channel_duration = 5000;
+
        /* set device pointer for wiphy */
        set_wiphy_dev(wdev->wiphy, dev);