mac80211: introduce hw config change flags
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / p54 / p54common.c
index 117c7d3a52b0ca4beb7e78f41da62d7a08797cae..b3c297ed00cd84dc16523367ac3522abe42f7ba4 100644 (file)
@@ -306,8 +306,8 @@ static int p54_convert_rev1(struct ieee80211_hw *dev,
        return 0;
 }
 
-static const char *p54_rf_chips[] = { "NULL", "Indigo?", "Duette",
-                              "Frisbee", "Xbow", "Longbow" };
+static const char *p54_rf_chips[] = { "NULL", "Duette3", "Duette2",
+                              "Frisbee", "Xbow", "Longbow", "NULL", "NULL" };
 static int p54_init_xbow_synth(struct ieee80211_hw *dev);
 
 static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
@@ -319,7 +319,7 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
        void *tmp;
        int err;
        u8 *end = (u8 *)eeprom + len;
-       DECLARE_MAC_BUF(mac);
+       u16 synth = 0;
 
        wrap = (struct eeprom_pda_wrap *) eeprom;
        entry = (void *)wrap->data + le16_to_cpu(wrap->len);
@@ -400,8 +400,8 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
                        tmp = entry->data;
                        while ((u8 *)tmp < entry->data + data_len) {
                                struct bootrec_exp_if *exp_if = tmp;
-                               if (le16_to_cpu(exp_if->if_id) == 0xF)
-                                       priv->rxhw = le16_to_cpu(exp_if->variant) & 0x07;
+                               if (le16_to_cpu(exp_if->if_id) == 0xf)
+                                       synth = le16_to_cpu(exp_if->variant);
                                tmp += sizeof(struct bootrec_exp_if);
                        }
                        break;
@@ -421,28 +421,20 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
                entry = (void *)entry + (entry_len + 1)*2;
        }
 
-       if (!priv->iq_autocal || !priv->output_limit || !priv->curve_data) {
+       if (!synth || !priv->iq_autocal || !priv->output_limit ||
+           !priv->curve_data) {
                printk(KERN_ERR "p54: not all required entries found in eeprom!\n");
                err = -EINVAL;
                goto err;
        }
 
-       switch (priv->rxhw) {
-       case 4: /* XBow */
+       priv->rxhw = synth & 0x07;
+       if (priv->rxhw == 4)
                p54_init_xbow_synth(dev);
-       case 1: /* Indigo? */
-       case 2: /* Duette */
-               dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz;
-       case 3: /* Frisbee */
-       case 5: /* Longbow */
+       if (!(synth & 0x40))
                dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz;
-               break;
-       default:
-               printk(KERN_ERR "%s: unsupported RF-Chip\n",
-                       wiphy_name(dev->wiphy));
-               err = -EINVAL;
-               goto err;
-       }
+       if (!(synth & 0x80))
+               dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz;
 
        if (!is_valid_ether_addr(dev->wiphy->perm_addr)) {
                u8 perm_addr[ETH_ALEN];
@@ -453,9 +445,9 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
                SET_IEEE80211_PERM_ADDR(dev, perm_addr);
        }
 
-       printk(KERN_INFO "%s: hwaddr %s, MAC:isl38%02x RF:%s\n",
+       printk(KERN_INFO "%s: hwaddr %pM, MAC:isl38%02x RF:%s\n",
                wiphy_name(dev->wiphy),
-               print_mac(mac, dev->wiphy->perm_addr),
+               dev->wiphy->perm_addr,
                priv->version, p54_rf_chips[priv->rxhw]);
 
        return 0;
@@ -909,12 +901,10 @@ static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type,
                memset(filter->bssid, ~0, ETH_ALEN);
        else
                memcpy(filter->bssid, bssid, ETH_ALEN);
-
        filter->rx_antenna = priv->rx_antenna;
-
        if (priv->fw_var < 0x500) {
                data_len = P54_TX_CONTROL_FILTER_V1_LEN;
-               filter->v1.basic_rate_mask = cpu_to_le32(0x15F);
+               filter->v1.basic_rate_mask = cpu_to_le32(0x15f);
                filter->v1.rx_addr = cpu_to_le32(priv->rx_end);
                filter->v1.max_rx = cpu_to_le16(priv->rx_mtu);
                filter->v1.rxhw = cpu_to_le16(priv->rxhw);
@@ -926,7 +916,6 @@ static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type,
                filter->v2.rxhw = cpu_to_le16(priv->rxhw);
                filter->v2.timer = cpu_to_le16(1000);
        }
-
        hdr->len = cpu_to_le16(data_len);
        p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + data_len);
        priv->tx(dev, hdr, sizeof(*hdr) + data_len, 1);
@@ -1096,7 +1085,7 @@ static void p54_set_vdcf(struct ieee80211_hw *dev)
 
        vdcf = (struct p54_tx_control_vdcf *) hdr->data;
 
-       if (dev->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME) {
+       if (priv->use_short_slot) {
                vdcf->slottime = 9;
                vdcf->magic1 = 0x10;
                vdcf->magic2 = 0x00;
@@ -1143,7 +1132,6 @@ static int p54_start(struct ieee80211_hw *dev)
                priv->mode = NL80211_IFTYPE_MONITOR;
 
        p54_init_vdcf(dev);
-
        mod_timer(&priv->stats_timer, jiffies + HZ);
        return err;
 }
@@ -1204,14 +1192,14 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
        p54_set_filter(dev, 0, NULL);
 }
 
-static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
+static int p54_config(struct ieee80211_hw *dev, u32 changed)
 {
        int ret;
        struct p54_common *priv = dev->priv;
+       struct ieee80211_conf *conf = &dev->conf;
 
        mutex_lock(&priv->conf_mutex);
-       priv->rx_antenna = (conf->antenna_sel_rx == 0) ?
-               2 : conf->antenna_sel_tx - 1;
+       priv->rx_antenna = 2; /* automatic */
        priv->output_power = conf->power_level << 2;
        ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq));
        p54_set_vdcf(dev);
@@ -1359,6 +1347,19 @@ static int p54_get_tx_stats(struct ieee80211_hw *dev,
        return 0;
 }
 
+static void p54_bss_info_changed(struct ieee80211_hw *dev,
+                                struct ieee80211_vif *vif,
+                                struct ieee80211_bss_conf *info,
+                                u32 changed)
+{
+       struct p54_common *priv = dev->priv;
+
+       if (changed & BSS_CHANGED_ERP_SLOT) {
+               priv->use_short_slot = info->use_short_slot;
+               p54_set_vdcf(dev);
+       }
+}
+
 static const struct ieee80211_ops p54_ops = {
        .tx                     = p54_tx,
        .start                  = p54_start,
@@ -1367,6 +1368,7 @@ static const struct ieee80211_ops p54_ops = {
        .remove_interface       = p54_remove_interface,
        .config                 = p54_config,
        .config_interface       = p54_config_interface,
+       .bss_info_changed       = p54_bss_info_changed,
        .configure_filter       = p54_configure_filter,
        .conf_tx                = p54_conf_tx,
        .get_stats              = p54_get_stats,
@@ -1393,7 +1395,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
        dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 
        dev->channel_change_time = 1000;        /* TODO: find actual value */
-
        priv->tx_stats[0].limit = 1;
        priv->tx_stats[1].limit = 1;
        priv->tx_stats[2].limit = 1;