- Update to 2.6.25-rc3.
[linux-flexiantxendom0-3.2.10.git] / drivers / net / wireless / libertas / wext.c
index 395b788..e8bfc26 100644 (file)
 #include "join.h"
 #include "wext.h"
 #include "assoc.h"
+#include "cmd.h"
+
+
+static inline void lbs_postpone_association_work(struct lbs_private *priv)
+{
+       if (priv->surpriseremoved)
+               return;
+       cancel_delayed_work(&priv->assoc_work);
+       queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
+}
+
+static inline void lbs_cancel_association_work(struct lbs_private *priv)
+{
+       cancel_delayed_work(&priv->assoc_work);
+       kfree(priv->pending_assoc_req);
+       priv->pending_assoc_req = NULL;
+}
 
 
 /**
  *  @brief Find the channel frequency power info with specific channel
  *
- *  @param adapter     A pointer to wlan_adapter structure
+ *  @param priv        A pointer to struct lbs_private structure
  *  @param band                it can be BAND_A, BAND_G or BAND_B
  *  @param channel      the channel for looking
  *  @return            A pointer to struct chan_freq_power structure or NULL if not find.
  */
-struct chan_freq_power *libertas_find_cfp_by_band_and_channel(wlan_adapter * adapter,
-                                                u8 band, u16 channel)
+struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
+       struct lbs_private *priv,
+       u8 band,
+       u16 channel)
 {
        struct chan_freq_power *cfp = NULL;
        struct region_channel *rc;
-       int count = sizeof(adapter->region_channel) /
-           sizeof(adapter->region_channel[0]);
        int i, j;
 
-       for (j = 0; !cfp && (j < count); j++) {
-               rc = &adapter->region_channel[j];
+       for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
+               rc = &priv->region_channel[j];
 
-               if (adapter->enable11d)
-                       rc = &adapter->universal_channel[j];
+               if (priv->enable11d)
+                       rc = &priv->universal_channel[j];
                if (!rc->valid || !rc->CFP)
                        continue;
                if (rc->band != band)
@@ -56,7 +73,7 @@ struct chan_freq_power *libertas_find_cfp_by_band_and_channel(wlan_adapter * ada
        }
 
        if (!cfp && channel)
-               lbs_deb_wext("libertas_find_cfp_by_band_and_channel: can't find "
+               lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
                       "cfp by band %d / channel %d\n", band, channel);
 
        return cfp;
@@ -65,25 +82,25 @@ struct chan_freq_power *libertas_find_cfp_by_band_and_channel(wlan_adapter * ada
 /**
  *  @brief Find the channel frequency power info with specific frequency
  *
- *  @param adapter     A pointer to wlan_adapter structure
+ *  @param priv        A pointer to struct lbs_private structure
  *  @param band                it can be BAND_A, BAND_G or BAND_B
  *  @param freq                the frequency for looking
  *  @return            A pointer to struct chan_freq_power structure or NULL if not find.
  */
-static struct chan_freq_power *find_cfp_by_band_and_freq(wlan_adapter * adapter,
-                                                    u8 band, u32 freq)
+static struct chan_freq_power *find_cfp_by_band_and_freq(
+       struct lbs_private *priv,
+       u8 band,
+       u32 freq)
 {
        struct chan_freq_power *cfp = NULL;
        struct region_channel *rc;
-       int count = sizeof(adapter->region_channel) /
-           sizeof(adapter->region_channel[0]);
        int i, j;
 
-       for (j = 0; !cfp && (j < count); j++) {
-               rc = &adapter->region_channel[j];
+       for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
+               rc = &priv->region_channel[j];
 
-               if (adapter->enable11d)
-                       rc = &adapter->universal_channel[j];
+               if (priv->enable11d)
+                       rc = &priv->universal_channel[j];
                if (!rc->valid || !rc->CFP)
                        continue;
                if (rc->band != band)
@@ -107,22 +124,21 @@ static struct chan_freq_power *find_cfp_by_band_and_freq(wlan_adapter * adapter,
 /**
  *  @brief Set Radio On/OFF
  *
- *  @param priv                 A pointer to wlan_private structure
+ *  @param priv                 A pointer to struct lbs_private structure
  *  @option                    Radio Option
  *  @return                    0 --success, otherwise fail
  */
-static int wlan_radio_ioctl(wlan_private * priv, u8 option)
+static int lbs_radio_ioctl(struct lbs_private *priv, u8 option)
 {
        int ret = 0;
-       wlan_adapter *adapter = priv->adapter;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       if (adapter->radioon != option) {
+       if (priv->radioon != option) {
                lbs_deb_wext("switching radio %s\n", option ? "on" : "off");
-               adapter->radioon = option;
+               priv->radioon = option;
 
-               ret = libertas_prepare_and_send_command(priv,
+               ret = lbs_prepare_and_send_command(priv,
                                            CMD_802_11_RADIO_CONTROL,
                                            CMD_ACT_SET,
                                            CMD_OPTION_WAITFORRSP, 0, NULL);
@@ -135,22 +151,23 @@ static int wlan_radio_ioctl(wlan_private * priv, u8 option)
 /**
  *  @brief Copy active data rates based on adapter mode and status
  *
- *  @param adapter              A pointer to wlan_adapter structure
+ *  @param priv              A pointer to struct lbs_private structure
  *  @param rate                        The buf to return the active rates
  */
-static void copy_active_data_rates(wlan_adapter * adapter, u8 * rates)
+static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
 {
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       if (adapter->connect_status != LIBERTAS_CONNECTED)
-               memcpy(rates, libertas_bg_rates, MAX_RATES);
+       if ((priv->connect_status != LBS_CONNECTED) &&
+               (priv->mesh_connect_status != LBS_CONNECTED))
+               memcpy(rates, lbs_bg_rates, MAX_RATES);
        else
-               memcpy(rates, adapter->curbssparams.rates, MAX_RATES);
+               memcpy(rates, priv->curbssparams.rates, MAX_RATES);
 
        lbs_deb_leave(LBS_DEB_WEXT);
 }
 
-static int wlan_get_name(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
                         char *cwrq, char *extra)
 {
 
@@ -163,22 +180,21 @@ static int wlan_get_name(struct net_device *dev, struct iw_request_info *info,
        return 0;
 }
 
-static int wlan_get_freq(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
                         struct iw_freq *fwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct chan_freq_power *cfp;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       cfp = libertas_find_cfp_by_band_and_channel(adapter, 0,
-                                          adapter->curbssparams.channel);
+       cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
+                                          priv->curbssparams.channel);
 
        if (!cfp) {
-               if (adapter->curbssparams.channel)
+               if (priv->curbssparams.channel)
                        lbs_deb_wext("invalid channel %d\n",
-                              adapter->curbssparams.channel);
+                              priv->curbssparams.channel);
                return -EINVAL;
        }
 
@@ -190,16 +206,15 @@ static int wlan_get_freq(struct net_device *dev, struct iw_request_info *info,
        return 0;
 }
 
-static int wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
                        struct sockaddr *awrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       if (adapter->connect_status == LIBERTAS_CONNECTED) {
-               memcpy(awrq->sa_data, adapter->curbssparams.bssid, ETH_ALEN);
+       if (priv->connect_status == LBS_CONNECTED) {
+               memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
        } else {
                memset(awrq->sa_data, 0, ETH_ALEN);
        }
@@ -209,11 +224,10 @@ static int wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
        return 0;
 }
 
-static int wlan_set_nick(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
                         struct iw_point *dwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
@@ -225,25 +239,24 @@ static int wlan_set_nick(struct net_device *dev, struct iw_request_info *info,
                return -E2BIG;
        }
 
-       mutex_lock(&adapter->lock);
-       memset(adapter->nodename, 0, sizeof(adapter->nodename));
-       memcpy(adapter->nodename, extra, dwrq->length);
-       mutex_unlock(&adapter->lock);
+       mutex_lock(&priv->lock);
+       memset(priv->nodename, 0, sizeof(priv->nodename));
+       memcpy(priv->nodename, extra, dwrq->length);
+       mutex_unlock(&priv->lock);
 
        lbs_deb_leave(LBS_DEB_WEXT);
        return 0;
 }
 
-static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
                         struct iw_point *dwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       dwrq->length = strlen(adapter->nodename);
-       memcpy(extra, adapter->nodename, dwrq->length);
+       dwrq->length = strlen(priv->nodename);
+       memcpy(extra, priv->nodename, dwrq->length);
        extra[dwrq->length] = '\0';
 
        dwrq->flags = 1;        /* active */
@@ -255,14 +268,13 @@ static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info,
 static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
                         struct iw_point *dwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
        /* Use nickname to indicate that mesh is on */
 
-       if (adapter->connect_status == LIBERTAS_CONNECTED) {
+       if (priv->mesh_connect_status == LBS_CONNECTED) {
                strncpy(extra, "Mesh", 12);
                extra[12] = '\0';
                dwrq->length = strlen(extra);
@@ -277,25 +289,24 @@ static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
        return 0;
 }
 
-static int wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
                        struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        u32 rthr = vwrq->value;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
        if (vwrq->disabled) {
-               adapter->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE;
+               priv->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE;
        } else {
                if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE)
                        return -EINVAL;
-               adapter->rtsthsd = rthr;
+               priv->rtsthsd = rthr;
        }
 
-       ret = libertas_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
+       ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
                                    CMD_ACT_SET, CMD_OPTION_WAITFORRSP,
                                    OID_802_11_RTS_THRESHOLD, &rthr);
 
@@ -303,23 +314,22 @@ static int wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
        return ret;
 }
 
-static int wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
                        struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       adapter->rtsthsd = 0;
-       ret = libertas_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
+       priv->rtsthsd = 0;
+       ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
                                    CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
                                    OID_802_11_RTS_THRESHOLD, NULL);
        if (ret)
                goto out;
 
-       vwrq->value = adapter->rtsthsd;
+       vwrq->value = priv->rtsthsd;
        vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE)
                          || (vwrq->value > MRVDRV_RTS_MAX_VALUE));
        vwrq->fixed = 1;
@@ -329,26 +339,25 @@ out:
        return ret;
 }
 
-static int wlan_set_frag(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
                         struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
        u32 fthr = vwrq->value;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
        if (vwrq->disabled) {
-               adapter->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE;
+               priv->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE;
        } else {
                if (fthr < MRVDRV_FRAG_MIN_VALUE
                    || fthr > MRVDRV_FRAG_MAX_VALUE)
                        return -EINVAL;
-               adapter->fragthsd = fthr;
+               priv->fragthsd = fthr;
        }
 
-       ret = libertas_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
+       ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
                                    CMD_ACT_SET, CMD_OPTION_WAITFORRSP,
                                    OID_802_11_FRAGMENTATION_THRESHOLD, &fthr);
 
@@ -356,24 +365,23 @@ static int wlan_set_frag(struct net_device *dev, struct iw_request_info *info,
        return ret;
 }
 
-static int wlan_get_frag(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
                         struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       adapter->fragthsd = 0;
-       ret = libertas_prepare_and_send_command(priv,
+       priv->fragthsd = 0;
+       ret = lbs_prepare_and_send_command(priv,
                                    CMD_802_11_SNMP_MIB,
                                    CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
                                    OID_802_11_FRAGMENTATION_THRESHOLD, NULL);
        if (ret)
                goto out;
 
-       vwrq->value = adapter->fragthsd;
+       vwrq->value = priv->fragthsd;
        vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE)
                          || (vwrq->value > MRVDRV_FRAG_MAX_VALUE));
        vwrq->fixed = 1;
@@ -383,15 +391,14 @@ out:
        return ret;
 }
 
-static int wlan_get_mode(struct net_device *dev,
+static int lbs_get_mode(struct net_device *dev,
                         struct iw_request_info *info, u32 * uwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       *uwrq = adapter->mode;
+       *uwrq = priv->mode;
 
        lbs_deb_leave(LBS_DEB_WEXT);
        return 0;
@@ -409,17 +416,16 @@ static int mesh_wlan_get_mode(struct net_device *dev,
        return 0;
 }
 
-static int wlan_get_txpow(struct net_device *dev,
+static int lbs_get_txpow(struct net_device *dev,
                          struct iw_request_info *info,
                          struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       ret = libertas_prepare_and_send_command(priv,
+       ret = lbs_prepare_and_send_command(priv,
                                    CMD_802_11_RF_TX_POWER,
                                    CMD_ACT_TX_POWER_OPT_GET,
                                    CMD_OPTION_WAITFORRSP, 0, NULL);
@@ -427,10 +433,10 @@ static int wlan_get_txpow(struct net_device *dev,
        if (ret)
                goto out;
 
-       lbs_deb_wext("tx power level %d dbm\n", adapter->txpowerlevel);
-       vwrq->value = adapter->txpowerlevel;
+       lbs_deb_wext("tx power level %d dbm\n", priv->txpowerlevel);
+       vwrq->value = priv->txpowerlevel;
        vwrq->fixed = 1;
-       if (adapter->radioon) {
+       if (priv->radioon) {
                vwrq->disabled = 0;
                vwrq->flags = IW_TXPOW_DBM;
        } else {
@@ -442,12 +448,11 @@ out:
        return ret;
 }
 
-static int wlan_set_retry(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
                          struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
@@ -460,9 +465,9 @@ static int wlan_set_retry(struct net_device *dev, struct iw_request_info *info,
                        return -EINVAL;
 
                /* Adding 1 to convert retry count to try count */
-               adapter->txretrycount = vwrq->value + 1;
+               priv->txretrycount = vwrq->value + 1;
 
-               ret = libertas_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
+               ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
                                            CMD_ACT_SET,
                                            CMD_OPTION_WAITFORRSP,
                                            OID_802_11_TX_RETRYCOUNT, NULL);
@@ -478,17 +483,16 @@ out:
        return ret;
 }
 
-static int wlan_get_retry(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
                          struct iw_param *vwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        int ret = 0;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       adapter->txretrycount = 0;
-       ret = libertas_prepare_and_send_command(priv,
+       priv->txretrycount = 0;
+       ret = lbs_prepare_and_send_command(priv,
                                    CMD_802_11_SNMP_MIB,
                                    CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
                                    OID_802_11_TX_RETRYCOUNT, NULL);
@@ -499,7 +503,7 @@ static int wlan_get_retry(struct net_device *dev, struct iw_request_info *info,
        if (!vwrq->flags) {
                vwrq->flags = IW_RETRY_LIMIT;
                /* Subtract 1 to convert try count to retry count */
-               vwrq->value = adapter->txretrycount - 1;
+               vwrq->value = priv->txretrycount - 1;
        }
 
 out:
@@ -546,12 +550,11 @@ static inline void sort_channels(struct iw_freq *freq, int num)
  *  @param extra               A pointer to extra data buf
  *  @return                    0 --success, otherwise fail
  */
-static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
                          struct iw_point *dwrq, char *extra)
 {
        int i, j;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct iw_range *range = (struct iw_range *)extra;
        struct chan_freq_power *cfp;
        u8 rates[MAX_RATES + 1];
@@ -567,7 +570,7 @@ static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
        range->max_nwid = 0;
 
        memset(rates, 0, sizeof(rates));
-       copy_active_data_rates(adapter, rates);
+       copy_active_data_rates(priv, rates);
        range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
        for (i = 0; i < range->num_bitrates; i++)
                range->bitrate[i] = rates[i] * 500000;
@@ -576,13 +579,14 @@ static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
               range->num_bitrates);
 
        range->num_frequency = 0;
-       if (priv->adapter->enable11d &&
-           adapter->connect_status == LIBERTAS_CONNECTED) {
+       if (priv->enable11d &&
+           (priv->connect_status == LBS_CONNECTED ||
+           priv->mesh_connect_status == LBS_CONNECTED)) {
                u8 chan_no;
                u8 band;
 
                struct parsed_region_chan_11d *parsed_region_chan =
-                   &adapter->parsed_region_chan;
+                   &priv->parsed_region_chan;
 
                if (parsed_region_chan == NULL) {
                        lbs_deb_wext("11d: parsed_region_chan is NULL\n");
@@ -598,7 +602,7 @@ static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
                        lbs_deb_wext("chan_no %d\n", chan_no);
                        range->freq[range->num_frequency].i = (long)chan_no;
                        range->freq[range->num_frequency].m =
-                           (long)libertas_chan_2_freq(chan_no, band) * 100000;
+                           (long)lbs_chan_2_freq(chan_no, band) * 100000;
                        range->freq[range->num_frequency].e = 1;
                        range->num_frequency++;
                }
@@ -606,13 +610,12 @@ static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
        }
        if (!flag) {
                for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
-                    && (j < sizeof(adapter->region_channel)
-                        / sizeof(adapter->region_channel[0])); j++) {
-                       cfp = adapter->region_channel[j].CFP;
+                    && (j < ARRAY_SIZE(priv->region_channel)); j++) {
+                       cfp = priv->region_channel[j].CFP;
                        for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
-                            && adapter->region_channel[j].valid
+                            && priv->region_channel[j].valid
                             && cfp
-                            && (i < adapter->region_channel[j].nrcfp); i++) {
+                            && (i < priv->region_channel[j].nrcfp); i++) {
                                range->freq[range->num_frequency].i =
                                    (long)cfp->channel;
                                range->freq[range->num_frequency].m =
@@ -712,7 +715,7 @@ static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
                                IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
        range->event_capa[1] = IW_EVENT_CAPA_K_1;
 
-       if (adapter->fwcapinfo & FW_CAPINFO_WPA) {
+       if (priv->fwcapinfo & FW_CAPINFO_WPA) {
                range->enc_capa =   IW_ENC_CAPA_WPA
                                  | IW_ENC_CAPA_WPA2
                                  | IW_ENC_CAPA_CIPHER_TKIP
@@ -724,22 +727,28 @@ out:
        return 0;
 }
 
-static int wlan_set_power(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
                          struct iw_param *vwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
+       if (!priv->ps_supported) {
+               if (vwrq->disabled)
+                       return 0;
+               else
+                       return -EINVAL;
+       }
+
        /* PS is currently supported only in Infrastructure mode
         * Remove this check if it is to be supported in IBSS mode also
         */
 
        if (vwrq->disabled) {
-               adapter->psmode = WLAN802_11POWERMODECAM;
-               if (adapter->psstate != PS_STATE_FULL_POWER) {
-                       libertas_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
+               priv->psmode = LBS802_11POWERMODECAM;
+               if (priv->psstate != PS_STATE_FULL_POWER) {
+                       lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
                }
 
                return 0;
@@ -754,33 +763,32 @@ static int wlan_set_power(struct net_device *dev, struct iw_request_info *info,
                return -EINVAL;
        }
 
-       if (adapter->psmode != WLAN802_11POWERMODECAM) {
+       if (priv->psmode != LBS802_11POWERMODECAM) {
                return 0;
        }
 
-       adapter->psmode = WLAN802_11POWERMODEMAX_PSP;
+       priv->psmode = LBS802_11POWERMODEMAX_PSP;
 
-       if (adapter->connect_status == LIBERTAS_CONNECTED) {
-               libertas_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
+       if (priv->connect_status == LBS_CONNECTED) {
+               lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
        }
 
        lbs_deb_leave(LBS_DEB_WEXT);
        return 0;
 }
 
-static int wlan_get_power(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
                          struct iw_param *vwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        int mode;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       mode = adapter->psmode;
+       mode = priv->psmode;
 
-       if ((vwrq->disabled = (mode == WLAN802_11POWERMODECAM))
-           || adapter->connect_status == LIBERTAS_DISCONNECTED)
+       if ((vwrq->disabled = (mode == LBS802_11POWERMODECAM))
+           || priv->connect_status == LBS_DISCONNECTED)
        {
                goto out;
        }
@@ -792,7 +800,7 @@ out:
        return 0;
 }
 
-static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
+static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
 {
        enum {
                POOR = 30,
@@ -802,8 +810,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
                EXCELLENT = 95,
                PERFECT = 100
        };
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        u32 rssi_qual;
        u32 tx_qual;
        u32 quality = 0;
@@ -813,22 +820,23 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       priv->wstats.status = adapter->mode;
+       priv->wstats.status = priv->mode;
 
        /* If we're not associated, all quality values are meaningless */
-       if (adapter->connect_status != LIBERTAS_CONNECTED)
+       if ((priv->connect_status != LBS_CONNECTED) &&
+           (priv->mesh_connect_status != LBS_CONNECTED))
                goto out;
 
        /* Quality by RSSI */
        priv->wstats.qual.level =
-           CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
-            adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
+           CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
+            priv->NF[TYPE_BEACON][TYPE_NOAVG]);
 
-       if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
+       if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
                priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
        } else {
                priv->wstats.qual.noise =
-                   CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
+                   CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
        }
 
        lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
@@ -852,7 +860,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
        /* Quality by TX errors */
        priv->wstats.discard.retries = priv->stats.tx_errors;
 
-       tx_retries = le32_to_cpu(adapter->logmsg.retry);
+       tx_retries = le32_to_cpu(priv->logmsg.retry);
 
        if (tx_retries > 75)
                tx_qual = (90 - tx_retries) * POOR / 15;
@@ -868,10 +876,10 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
                    (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
        quality = min(quality, tx_qual);
 
-       priv->wstats.discard.code = le32_to_cpu(adapter->logmsg.wepundecryptable);
-       priv->wstats.discard.fragment = le32_to_cpu(adapter->logmsg.rxfrag);
+       priv->wstats.discard.code = le32_to_cpu(priv->logmsg.wepundecryptable);
+       priv->wstats.discard.fragment = le32_to_cpu(priv->logmsg.rxfrag);
        priv->wstats.discard.retries = tx_retries;
-       priv->wstats.discard.misc = le32_to_cpu(adapter->logmsg.ackfailure);
+       priv->wstats.discard.misc = le32_to_cpu(priv->logmsg.ackfailure);
 
        /* Calculate quality */
        priv->wstats.qual.qual = min_t(u8, quality, 100);
@@ -879,9 +887,9 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
        stats_valid = 1;
 
        /* update stats asynchronously for future calls */
-       libertas_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
+       lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
                                        0, 0, NULL);
-       libertas_prepare_and_send_command(priv, CMD_802_11_GET_LOG, 0,
+       lbs_prepare_and_send_command(priv, CMD_802_11_GET_LOG, 0,
                                        0, 0, NULL);
 out:
        if (!stats_valid) {
@@ -901,19 +909,18 @@ out:
 
 }
 
-static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
                  struct iw_freq *fwrq, char *extra)
 {
        int ret = -EINVAL;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct chan_freq_power *cfp;
        struct assoc_request * assoc_req;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       mutex_lock(&adapter->lock);
-       assoc_req = wlan_get_association_request(adapter);
+       mutex_lock(&priv->lock);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
                ret = -ENOMEM;
                goto out;
@@ -923,7 +930,7 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
        if (fwrq->e == 1) {
                long f = fwrq->m / 100000;
 
-               cfp = find_cfp_by_band_and_freq(adapter, 0, f);
+               cfp = find_cfp_by_band_and_freq(priv, 0, f);
                if (!cfp) {
                        lbs_deb_wext("invalid freq %ld\n", f);
                        goto out;
@@ -938,7 +945,7 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
                goto out;
        }
 
-       cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, fwrq->m);
+       cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
        if (!cfp) {
                goto out;
        }
@@ -949,23 +956,71 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
 out:
        if (ret == 0) {
                set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
        } else {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
+       }
+       mutex_unlock(&priv->lock);
+
+       lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
+       return ret;
+}
+
+static int lbs_mesh_set_freq(struct net_device *dev,
+                            struct iw_request_info *info,
+                            struct iw_freq *fwrq, char *extra)
+{
+       struct lbs_private *priv = dev->priv;
+       struct chan_freq_power *cfp;
+       int ret = -EINVAL;
+
+       lbs_deb_enter(LBS_DEB_WEXT);
+
+       /* If setting by frequency, convert to a channel */
+       if (fwrq->e == 1) {
+               long f = fwrq->m / 100000;
+
+               cfp = find_cfp_by_band_and_freq(priv, 0, f);
+               if (!cfp) {
+                       lbs_deb_wext("invalid freq %ld\n", f);
+                       goto out;
+               }
+
+               fwrq->e = 0;
+               fwrq->m = (int) cfp->channel;
+       }
+
+       /* Setting by channel number */
+       if (fwrq->m > 1000 || fwrq->e > 0) {
+               goto out;
+       }
+
+       cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
+       if (!cfp) {
+               goto out;
+       }
+
+       if (fwrq->m != priv->curbssparams.channel) {
+               lbs_deb_wext("mesh channel change forces eth disconnect\n");
+               if (priv->mode == IW_MODE_INFRA)
+                       lbs_send_deauthentication(priv);
+               else if (priv->mode == IW_MODE_ADHOC)
+                       lbs_stop_adhoc_network(priv);
        }
-       mutex_unlock(&adapter->lock);
+       lbs_mesh_config(priv, 1, fwrq->m);
+       lbs_update_channel(priv);
+       ret = 0;
 
+out:
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
 }
 
-static int wlan_set_rate(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
                  struct iw_param *vwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
-       u32 new_rate;
-       u16 action;
+       struct lbs_private *priv = dev->priv;
+       u8 new_rate = 0;
        int ret = -EINVAL;
        u8 rates[MAX_RATES + 1];
 
@@ -974,15 +1029,14 @@ static int wlan_set_rate(struct net_device *dev, struct iw_request_info *info,
 
        /* Auto rate? */
        if (vwrq->value == -1) {
-               action = CMD_ACT_SET_TX_AUTO;
-               adapter->auto_rate = 1;
-               adapter->cur_rate = 0;
+               priv->auto_rate = 1;
+               priv->cur_rate = 0;
        } else {
                if (vwrq->value % 100000)
                        goto out;
 
                memset(rates, 0, sizeof(rates));
-               copy_active_data_rates(adapter, rates);
+               copy_active_data_rates(priv, rates);
                new_rate = vwrq->value / 500000;
                if (!memchr(rates, new_rate, sizeof(rates))) {
                        lbs_pr_alert("fixed data rate 0x%X out of range\n",
@@ -990,31 +1044,28 @@ static int wlan_set_rate(struct net_device *dev, struct iw_request_info *info,
                        goto out;
                }
 
-               adapter->cur_rate = new_rate;
-               action = CMD_ACT_SET_TX_FIX_RATE;
-               adapter->auto_rate = 0;
+               priv->cur_rate = new_rate;
+               priv->auto_rate = 0;
        }
 
-       ret = libertas_prepare_and_send_command(priv, CMD_802_11_DATA_RATE,
-                                   action, CMD_OPTION_WAITFORRSP, 0, NULL);
+       ret = lbs_set_data_rate(priv, new_rate);
 
 out:
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
 }
 
-static int wlan_get_rate(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
                  struct iw_param *vwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       if (adapter->connect_status == LIBERTAS_CONNECTED) {
-               vwrq->value = adapter->cur_rate * 500000;
+       if (priv->connect_status == LBS_CONNECTED) {
+               vwrq->value = priv->cur_rate * 500000;
 
-               if (adapter->auto_rate)
+               if (priv->auto_rate)
                        vwrq->fixed = 0;
                else
                        vwrq->fixed = 1;
@@ -1028,12 +1079,11 @@ static int wlan_get_rate(struct net_device *dev, struct iw_request_info *info,
        return 0;
 }
 
-static int wlan_set_mode(struct net_device *dev,
+static int lbs_set_mode(struct net_device *dev,
                  struct iw_request_info *info, u32 * uwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct assoc_request * assoc_req;
 
        lbs_deb_enter(LBS_DEB_WEXT);
@@ -1046,18 +1096,18 @@ static int wlan_set_mode(struct net_device *dev,
                goto out;
        }
 
-       mutex_lock(&adapter->lock);
-       assoc_req = wlan_get_association_request(adapter);
+       mutex_lock(&priv->lock);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
                ret = -ENOMEM;
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
        } else {
                assoc_req->mode = *uwrq;
                set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
                lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
        }
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
 
 out:
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
@@ -1074,23 +1124,22 @@ out:
  *  @param extra               A pointer to extra data buf
  *  @return                    0 --success, otherwise fail
  */
-static int wlan_get_encode(struct net_device *dev,
+static int lbs_get_encode(struct net_device *dev,
                           struct iw_request_info *info,
                           struct iw_point *dwrq, u8 * extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
        lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
-              dwrq->flags, index, dwrq->length, adapter->wep_tx_keyidx);
+              dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
 
        dwrq->flags = 0;
 
        /* Authentication method */
-       switch (adapter->secinfo.auth_mode) {
+       switch (priv->secinfo.auth_mode) {
        case IW_AUTH_ALG_OPEN_SYSTEM:
                dwrq->flags = IW_ENCODE_OPEN;
                break;
@@ -1104,41 +1153,32 @@ static int wlan_get_encode(struct net_device *dev,
                break;
        }
 
-       if (   adapter->secinfo.wep_enabled
-           || adapter->secinfo.WPAenabled
-           || adapter->secinfo.WPA2enabled) {
-               dwrq->flags &= ~IW_ENCODE_DISABLED;
-       } else {
-               dwrq->flags |= IW_ENCODE_DISABLED;
-       }
-
        memset(extra, 0, 16);
 
-       mutex_lock(&adapter->lock);
+       mutex_lock(&priv->lock);
 
        /* Default to returning current transmit key */
        if (index < 0)
-               index = adapter->wep_tx_keyidx;
+               index = priv->wep_tx_keyidx;
 
-       if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) {
-               memcpy(extra, adapter->wep_keys[index].key,
-                      adapter->wep_keys[index].len);
-               dwrq->length = adapter->wep_keys[index].len;
+       if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
+               memcpy(extra, priv->wep_keys[index].key,
+                      priv->wep_keys[index].len);
+               dwrq->length = priv->wep_keys[index].len;
 
                dwrq->flags |= (index + 1);
                /* Return WEP enabled */
                dwrq->flags &= ~IW_ENCODE_DISABLED;
-       } else if ((adapter->secinfo.WPAenabled)
-                  || (adapter->secinfo.WPA2enabled)) {
+       } else if ((priv->secinfo.WPAenabled)
+                  || (priv->secinfo.WPA2enabled)) {
                /* return WPA enabled */
                dwrq->flags &= ~IW_ENCODE_DISABLED;
+               dwrq->flags |= IW_ENCODE_NOKEY;
        } else {
                dwrq->flags |= IW_ENCODE_DISABLED;
        }
 
-       mutex_unlock(&adapter->lock);
-
-       dwrq->flags |= IW_ENCODE_NOKEY;
+       mutex_unlock(&priv->lock);
 
        lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
               extra[0], extra[1], extra[2],
@@ -1160,7 +1200,7 @@ static int wlan_get_encode(struct net_device *dev,
  *  @param set_tx_key          Force set TX key (1 = yes, 0 = no)
  *  @return                    0 --success, otherwise fail
  */
-static int wlan_set_wep_key(struct assoc_request *assoc_req,
+static int lbs_set_wep_key(struct assoc_request *assoc_req,
                            const char *key_material,
                            u16 key_length,
                            u16 index,
@@ -1278,20 +1318,19 @@ static void disable_wpa(struct assoc_request *assoc_req)
  *  @param extra               A pointer to extra data buf
  *  @return                    0 --success, otherwise fail
  */
-static int wlan_set_encode(struct net_device *dev,
+static int lbs_set_encode(struct net_device *dev,
                    struct iw_request_info *info,
                    struct iw_point *dwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct assoc_request * assoc_req;
        u16 is_default = 0, index = 0, set_tx_key = 0;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       mutex_lock(&adapter->lock);
-       assoc_req = wlan_get_association_request(adapter);
+       mutex_lock(&priv->lock);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
                ret = -ENOMEM;
                goto out;
@@ -1317,7 +1356,7 @@ static int wlan_set_encode(struct net_device *dev,
        if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
                set_tx_key = 1;
 
-       ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
+       ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
        if (ret)
                goto out;
 
@@ -1335,11 +1374,11 @@ static int wlan_set_encode(struct net_device *dev,
 out:
        if (ret == 0) {
                set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
        } else {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
        }
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
 
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
@@ -1354,14 +1393,13 @@ out:
  *  @param extra               A pointer to extra data buf
  *  @return                    0 on success, otherwise failure
  */
-static int wlan_get_encodeext(struct net_device *dev,
+static int lbs_get_encodeext(struct net_device *dev,
                              struct iw_request_info *info,
                              struct iw_point *dwrq,
                              char *extra)
 {
        int ret = -EINVAL;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
        int index, max_key_len;
 
@@ -1377,46 +1415,46 @@ static int wlan_get_encodeext(struct net_device *dev,
                        goto out;
                index--;
        } else {
-               index = adapter->wep_tx_keyidx;
+               index = priv->wep_tx_keyidx;
        }
 
-       if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
+       if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
            ext->alg != IW_ENCODE_ALG_WEP) {
-               if (index != 0 || adapter->mode != IW_MODE_INFRA)
+               if (index != 0 || priv->mode != IW_MODE_INFRA)
                        goto out;
        }
 
        dwrq->flags = index + 1;
        memset(ext, 0, sizeof(*ext));
 
-       if (   !adapter->secinfo.wep_enabled
-           && !adapter->secinfo.WPAenabled
-           && !adapter->secinfo.WPA2enabled) {
+       if (   !priv->secinfo.wep_enabled
+           && !priv->secinfo.WPAenabled
+           && !priv->secinfo.WPA2enabled) {
                ext->alg = IW_ENCODE_ALG_NONE;
                ext->key_len = 0;
                dwrq->flags |= IW_ENCODE_DISABLED;
        } else {
                u8 *key = NULL;
 
-               if (   adapter->secinfo.wep_enabled
-                   && !adapter->secinfo.WPAenabled
-                   && !adapter->secinfo.WPA2enabled) {
+               if (   priv->secinfo.wep_enabled
+                   && !priv->secinfo.WPAenabled
+                   && !priv->secinfo.WPA2enabled) {
                        /* WEP */
                        ext->alg = IW_ENCODE_ALG_WEP;
-                       ext->key_len = adapter->wep_keys[index].len;
-                       key = &adapter->wep_keys[index].key[0];
-               } else if (   !adapter->secinfo.wep_enabled
-                          && (adapter->secinfo.WPAenabled ||
-                              adapter->secinfo.WPA2enabled)) {
+                       ext->key_len = priv->wep_keys[index].len;
+                       key = &priv->wep_keys[index].key[0];
+               } else if (   !priv->secinfo.wep_enabled
+                          && (priv->secinfo.WPAenabled ||
+                              priv->secinfo.WPA2enabled)) {
                        /* WPA */
                        struct enc_key * pkey = NULL;
 
-                       if (   adapter->wpa_mcast_key.len
-                           && (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
-                               pkey = &adapter->wpa_mcast_key;
-                       else if (   adapter->wpa_unicast_key.len
-                                && (adapter->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
-                               pkey = &adapter->wpa_unicast_key;
+                       if (   priv->wpa_mcast_key.len
+                           && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
+                               pkey = &priv->wpa_mcast_key;
+                       else if (   priv->wpa_unicast_key.len
+                                && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
+                               pkey = &priv->wpa_unicast_key;
 
                        if (pkey) {
                                if (pkey->type == KEY_TYPE_ID_AES) {
@@ -1461,22 +1499,21 @@ out:
  *  @param extra               A pointer to extra data buf
  *  @return                    0 --success, otherwise fail
  */
-static int wlan_set_encodeext(struct net_device *dev,
+static int lbs_set_encodeext(struct net_device *dev,
                              struct iw_request_info *info,
                              struct iw_point *dwrq,
                              char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
        int alg = ext->alg;
        struct assoc_request * assoc_req;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       mutex_lock(&adapter->lock);
-       assoc_req = wlan_get_association_request(adapter);
+       mutex_lock(&priv->lock);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
                ret = -ENOMEM;
                goto out;
@@ -1503,7 +1540,7 @@ static int wlan_set_encodeext(struct net_device *dev,
                        set_tx_key = 1;
 
                /* Copy key to driver */
-               ret = wlan_set_wep_key (assoc_req, ext->key, ext->key_len, index,
+               ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
                                        set_tx_key);
                if (ret)
                        goto out;
@@ -1576,31 +1613,30 @@ static int wlan_set_encodeext(struct net_device *dev,
 
 out:
        if (ret == 0) {
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
        } else {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
        }
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
 
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
 }
 
 
-static int wlan_set_genie(struct net_device *dev,
+static int lbs_set_genie(struct net_device *dev,
                          struct iw_request_info *info,
                          struct iw_point *dwrq,
                          char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        int ret = 0;
        struct assoc_request * assoc_req;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       mutex_lock(&adapter->lock);
-       assoc_req = wlan_get_association_request(adapter);
+       mutex_lock(&priv->lock);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
                ret = -ENOMEM;
                goto out;
@@ -1616,46 +1652,45 @@ static int wlan_set_genie(struct net_device *dev,
                memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
                assoc_req->wpa_ie_len = dwrq->length;
        } else {
-               memset(&assoc_req->wpa_ie[0], 0, sizeof(adapter->wpa_ie));
+               memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
                assoc_req->wpa_ie_len = 0;
        }
 
 out:
        if (ret == 0) {
                set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
        } else {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
        }
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
 
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
 }
 
-static int wlan_get_genie(struct net_device *dev,
+static int lbs_get_genie(struct net_device *dev,
                          struct iw_request_info *info,
                          struct iw_point *dwrq,
                          char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       if (adapter->wpa_ie_len == 0) {
+       if (priv->wpa_ie_len == 0) {
                dwrq->length = 0;
                goto out;
        }
 
-       if (dwrq->length < adapter->wpa_ie_len) {
+       if (dwrq->length < priv->wpa_ie_len) {
                ret = -E2BIG;
                goto out;
        }
 
-       dwrq->length = adapter->wpa_ie_len;
-       memcpy(extra, &adapter->wpa_ie[0], adapter->wpa_ie_len);
+       dwrq->length = priv->wpa_ie_len;
+       memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
 
 out:
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
@@ -1663,21 +1698,20 @@ out:
 }
 
 
-static int wlan_set_auth(struct net_device *dev,
+static int lbs_set_auth(struct net_device *dev,
                         struct iw_request_info *info,
                         struct iw_param *dwrq,
                         char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct assoc_request * assoc_req;
        int ret = 0;
        int updated = 0;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
-       mutex_lock(&adapter->lock);
-       assoc_req = wlan_get_association_request(adapter);
+       mutex_lock(&priv->lock);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
                ret = -ENOMEM;
                goto out;
@@ -1752,44 +1786,43 @@ out:
        if (ret == 0) {
                if (updated)
                        set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
        } else if (ret != -EOPNOTSUPP) {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
        }
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
 
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
 }
 
-static int wlan_get_auth(struct net_device *dev,
+static int lbs_get_auth(struct net_device *dev,
                         struct iw_request_info *info,
                         struct iw_param *dwrq,
                         char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
        switch (dwrq->flags & IW_AUTH_INDEX) {
        case IW_AUTH_WPA_VERSION:
                dwrq->value = 0;
-               if (adapter->secinfo.WPAenabled)
+               if (priv->secinfo.WPAenabled)
                        dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
-               if (adapter->secinfo.WPA2enabled)
+               if (priv->secinfo.WPA2enabled)
                        dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
                if (!dwrq->value)
                        dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
                break;
 
        case IW_AUTH_80211_AUTH_ALG:
-               dwrq->value = adapter->secinfo.auth_mode;
+               dwrq->value = priv->secinfo.auth_mode;
                break;
 
        case IW_AUTH_WPA_ENABLED:
-               if (adapter->secinfo.WPAenabled && adapter->secinfo.WPA2enabled)
+               if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
                        dwrq->value = 1;
                break;
 
@@ -1802,25 +1835,24 @@ static int wlan_get_auth(struct net_device *dev,
 }
 
 
-static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
                   struct iw_param *vwrq, char *extra)
 {
        int ret = 0;
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        u16 dbm;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
        if (vwrq->disabled) {
-               wlan_radio_ioctl(priv, RADIO_OFF);
+               lbs_radio_ioctl(priv, RADIO_OFF);
                return 0;
        }
 
-       adapter->preamble = CMD_TYPE_AUTO_PREAMBLE;
+       priv->preamble = CMD_TYPE_AUTO_PREAMBLE;
 
-       wlan_radio_ioctl(priv, RADIO_ON);
+       lbs_radio_ioctl(priv, RADIO_ON);
 
        /* Userspace check in iwrange if it should use dBm or mW,
         * therefore this should never happen... Jean II */
@@ -1836,7 +1868,7 @@ static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info,
 
        lbs_deb_wext("txpower set %d dbm\n", dbm);
 
-       ret = libertas_prepare_and_send_command(priv,
+       ret = lbs_prepare_and_send_command(priv,
                                    CMD_802_11_RF_TX_POWER,
                                    CMD_ACT_TX_POWER_OPT_SET_LOW,
                                    CMD_OPTION_WAITFORRSP, 0, (void *)&dbm);
@@ -1845,11 +1877,10 @@ static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info,
        return ret;
 }
 
-static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info,
+static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
                   struct iw_point *dwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
@@ -1861,19 +1892,19 @@ static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info,
        /*
         * Get the current SSID
         */
-       if (adapter->connect_status == LIBERTAS_CONNECTED) {
-               memcpy(extra, adapter->curbssparams.ssid,
-                      adapter->curbssparams.ssid_len);
-               extra[adapter->curbssparams.ssid_len] = '\0';
+       if (priv->connect_status == LBS_CONNECTED) {
+               memcpy(extra, priv->curbssparams.ssid,
+                      priv->curbssparams.ssid_len);
+               extra[priv->curbssparams.ssid_len] = '\0';
        } else {
                memset(extra, 0, 32);
-               extra[adapter->curbssparams.ssid_len] = '\0';
+               extra[priv->curbssparams.ssid_len] = '\0';
        }
        /*
         * If none, we may want to get the one that was set
         */
 
-       dwrq->length = adapter->curbssparams.ssid_len;
+       dwrq->length = priv->curbssparams.ssid_len;
 
        dwrq->flags = 1;        /* active */
 
@@ -1881,11 +1912,10 @@ static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info,
        return 0;
 }
 
-static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
                   struct iw_point *dwrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        int ret = 0;
        u8 ssid[IW_ESSID_MAX_SIZE];
        u8 ssid_len = 0;
@@ -1918,10 +1948,10 @@ static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info,
        }
 
 out:
-       mutex_lock(&adapter->lock);
+       mutex_lock(&priv->lock);
        if (ret == 0) {
                /* Get or create the current association request */
-               assoc_req = wlan_get_association_request(adapter);
+               assoc_req = lbs_get_association_request(priv);
                if (!assoc_req) {
                        ret = -ENOMEM;
                } else {
@@ -1929,17 +1959,65 @@ out:
                        memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
                        assoc_req->ssid_len = ssid_len;
                        set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
-                       wlan_postpone_association_work(priv);
+                       lbs_postpone_association_work(priv);
                }
        }
 
        /* Cancel the association request if there was an error */
        if (ret != 0) {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
+       }
+
+       mutex_unlock(&priv->lock);
+
+       lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
+       return ret;
+}
+
+static int lbs_mesh_get_essid(struct net_device *dev,
+                             struct iw_request_info *info,
+                             struct iw_point *dwrq, char *extra)
+{
+       struct lbs_private *priv = dev->priv;
+
+       lbs_deb_enter(LBS_DEB_WEXT);
+
+       memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
+
+       dwrq->length = priv->mesh_ssid_len;
+
+       dwrq->flags = 1;        /* active */
+
+       lbs_deb_leave(LBS_DEB_WEXT);
+       return 0;
+}
+
+static int lbs_mesh_set_essid(struct net_device *dev,
+                             struct iw_request_info *info,
+                             struct iw_point *dwrq, char *extra)
+{
+       struct lbs_private *priv = dev->priv;
+       int ret = 0;
+
+       lbs_deb_enter(LBS_DEB_WEXT);
+
+       /* Check the size of the string */
+       if (dwrq->length > IW_ESSID_MAX_SIZE) {
+               ret = -E2BIG;
+               goto out;
        }
 
-       mutex_unlock(&adapter->lock);
+       if (!dwrq->flags || !dwrq->length) {
+               ret = -EINVAL;
+               goto out;
+       } else {
+               /* Specific SSID requested */
+               memcpy(priv->mesh_ssid, extra, dwrq->length);
+               priv->mesh_ssid_len = dwrq->length;
+       }
 
+       lbs_mesh_config(priv, 1, priv->curbssparams.channel);
+ out:
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;
 }
@@ -1953,11 +2031,10 @@ out:
  *  @param extra        A pointer to extra data buf
  *  @return             0 --success, otherwise fail
  */
-static int wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
+static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
                 struct sockaddr *awrq, char *extra)
 {
-       wlan_private *priv = dev->priv;
-       wlan_adapter *adapter = priv->adapter;
+       struct lbs_private *priv = dev->priv;
        struct assoc_request * assoc_req;
        int ret = 0;
        DECLARE_MAC_BUF(mac);
@@ -1969,44 +2046,38 @@ static int wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
 
        lbs_deb_wext("ASSOC: WAP: sa_data %s\n", print_mac(mac, awrq->sa_data));
 
-       mutex_lock(&adapter->lock);
+       mutex_lock(&priv->lock);
 
        /* Get or create the current association request */
-       assoc_req = wlan_get_association_request(adapter);
+       assoc_req = lbs_get_association_request(priv);
        if (!assoc_req) {
-               wlan_cancel_association_work(priv);
+               lbs_cancel_association_work(priv);
                ret = -ENOMEM;
        } else {
                /* Copy the BSSID to the association request */
                memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
                set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
-               wlan_postpone_association_work(priv);
+               lbs_postpone_association_work(priv);
        }
 
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
 
        return ret;
 }
 
-void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen)
+void lbs_get_fwversion(struct lbs_private *priv, char *fwversion, int maxlen)
 {
        char fwver[32];
 
-       mutex_lock(&adapter->lock);
+       mutex_lock(&priv->lock);
 
-       if (adapter->fwreleasenumber[3] == 0)
-               sprintf(fwver, "%u.%u.%u",
-                       adapter->fwreleasenumber[2],
-                       adapter->fwreleasenumber[1],
-                       adapter->fwreleasenumber[0]);
-       else
-               sprintf(fwver, "%u.%u.%u.p%u",
-                       adapter->fwreleasenumber[2],
-                       adapter->fwreleasenumber[1],
-                       adapter->fwreleasenumber[0],
-                       adapter->fwreleasenumber[3]);
+       sprintf(fwver, "%u.%u.%u.p%u",
+               priv->fwrelease >> 24 & 0xff,
+               priv->fwrelease >> 16 & 0xff,
+               priv->fwrelease >>  8 & 0xff,
+               priv->fwrelease       & 0xff);
 
-       mutex_unlock(&adapter->lock);
+       mutex_unlock(&priv->lock);
        snprintf(fwversion, maxlen, fwver);
 }
 
@@ -2014,19 +2085,19 @@ void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen)
 /*
  * iwconfig settable callbacks
  */
-static const iw_handler wlan_handler[] = {
+static const iw_handler lbs_handler[] = {
        (iw_handler) NULL,      /* SIOCSIWCOMMIT */
-       (iw_handler) wlan_get_name,     /* SIOCGIWNAME */
+       (iw_handler) lbs_get_name,      /* SIOCGIWNAME */
        (iw_handler) NULL,      /* SIOCSIWNWID */
        (iw_handler) NULL,      /* SIOCGIWNWID */
-       (iw_handler) wlan_set_freq,     /* SIOCSIWFREQ */
-       (iw_handler) wlan_get_freq,     /* SIOCGIWFREQ */
-       (iw_handler) wlan_set_mode,     /* SIOCSIWMODE */
-       (iw_handler) wlan_get_mode,     /* SIOCGIWMODE */
+       (iw_handler) lbs_set_freq,      /* SIOCSIWFREQ */
+       (iw_handler) lbs_get_freq,      /* SIOCGIWFREQ */
+       (iw_handler) lbs_set_mode,      /* SIOCSIWMODE */
+       (iw_handler) lbs_get_mode,      /* SIOCGIWMODE */
        (iw_handler) NULL,      /* SIOCSIWSENS */
        (iw_handler) NULL,      /* SIOCGIWSENS */
        (iw_handler) NULL,      /* SIOCSIWRANGE */
-       (iw_handler) wlan_get_range,    /* SIOCGIWRANGE */
+       (iw_handler) lbs_get_range,     /* SIOCGIWRANGE */
        (iw_handler) NULL,      /* SIOCSIWPRIV */
        (iw_handler) NULL,      /* SIOCGIWPRIV */
        (iw_handler) NULL,      /* SIOCSIWSTATS */
@@ -2035,56 +2106,56 @@ static const iw_handler wlan_handler[] = {
        iw_handler_get_spy,     /* SIOCGIWSPY */
        iw_handler_set_thrspy,  /* SIOCSIWTHRSPY */
        iw_handler_get_thrspy,  /* SIOCGIWTHRSPY */
-       (iw_handler) wlan_set_wap,      /* SIOCSIWAP */
-       (iw_handler) wlan_get_wap,      /* SIOCGIWAP */
+       (iw_handler) lbs_set_wap,       /* SIOCSIWAP */
+       (iw_handler) lbs_get_wap,       /* SIOCGIWAP */
        (iw_handler) NULL,      /* SIOCSIWMLME */
        (iw_handler) NULL,      /* SIOCGIWAPLIST - deprecated */
-       (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */
-       (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */
-       (iw_handler) wlan_set_essid,    /* SIOCSIWESSID */
-       (iw_handler) wlan_get_essid,    /* SIOCGIWESSID */
-       (iw_handler) wlan_set_nick,     /* SIOCSIWNICKN */
-       (iw_handler) wlan_get_nick,     /* SIOCGIWNICKN */
+       (iw_handler) lbs_set_scan,      /* SIOCSIWSCAN */
+       (iw_handler) lbs_get_scan,      /* SIOCGIWSCAN */
+       (iw_handler) lbs_set_essid,     /* SIOCSIWESSID */
+       (iw_handler) lbs_get_essid,     /* SIOCGIWESSID */
+       (iw_handler) lbs_set_nick,      /* SIOCSIWNICKN */
+       (iw_handler) lbs_get_nick,      /* SIOCGIWNICKN */
        (iw_handler) NULL,      /* -- hole -- */
        (iw_handler) NULL,      /* -- hole -- */
-       (iw_handler) wlan_set_rate,     /* SIOCSIWRATE */
-       (iw_handler) wlan_get_rate,     /* SIOCGIWRATE */
-       (iw_handler) wlan_set_rts,      /* SIOCSIWRTS */
-       (iw_handler) wlan_get_rts,      /* SIOCGIWRTS */
-       (iw_handler) wlan_set_frag,     /* SIOCSIWFRAG */
-       (iw_handler) wlan_get_frag,     /* SIOCGIWFRAG */
-       (iw_handler) wlan_set_txpow,    /* SIOCSIWTXPOW */
-       (iw_handler) wlan_get_txpow,    /* SIOCGIWTXPOW */
-       (iw_handler) wlan_set_retry,    /* SIOCSIWRETRY */
-       (iw_handler) wlan_get_retry,    /* SIOCGIWRETRY */
-       (iw_handler) wlan_set_encode,   /* SIOCSIWENCODE */
-       (iw_handler) wlan_get_encode,   /* SIOCGIWENCODE */
-       (iw_handler) wlan_set_power,    /* SIOCSIWPOWER */
-       (iw_handler) wlan_get_power,    /* SIOCGIWPOWER */
+       (iw_handler) lbs_set_rate,      /* SIOCSIWRATE */
+       (iw_handler) lbs_get_rate,      /* SIOCGIWRATE */
+       (iw_handler) lbs_set_rts,       /* SIOCSIWRTS */
+       (iw_handler) lbs_get_rts,       /* SIOCGIWRTS */
+       (iw_handler) lbs_set_frag,      /* SIOCSIWFRAG */
+       (iw_handler) lbs_get_frag,      /* SIOCGIWFRAG */
+       (iw_handler) lbs_set_txpow,     /* SIOCSIWTXPOW */
+       (iw_handler) lbs_get_txpow,     /* SIOCGIWTXPOW */
+       (iw_handler) lbs_set_retry,     /* SIOCSIWRETRY */
+       (iw_handler) lbs_get_retry,     /* SIOCGIWRETRY */
+       (iw_handler) lbs_set_encode,    /* SIOCSIWENCODE */
+       (iw_handler) lbs_get_encode,    /* SIOCGIWENCODE */
+       (iw_handler) lbs_set_power,     /* SIOCSIWPOWER */
+       (iw_handler) lbs_get_power,     /* SIOCGIWPOWER */
        (iw_handler) NULL,      /* -- hole -- */
        (iw_handler) NULL,      /* -- hole -- */
-       (iw_handler) wlan_set_genie,    /* SIOCSIWGENIE */
-       (iw_handler) wlan_get_genie,    /* SIOCGIWGENIE */
-       (iw_handler) wlan_set_auth,     /* SIOCSIWAUTH */
-       (iw_handler) wlan_get_auth,     /* SIOCGIWAUTH */
-       (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */
-       (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */
+       (iw_handler) lbs_set_genie,     /* SIOCSIWGENIE */
+       (iw_handler) lbs_get_genie,     /* SIOCGIWGENIE */
+       (iw_handler) lbs_set_auth,      /* SIOCSIWAUTH */
+       (iw_handler) lbs_get_auth,      /* SIOCGIWAUTH */
+       (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
+       (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
        (iw_handler) NULL,              /* SIOCSIWPMKSA */
 };
 
 static const iw_handler mesh_wlan_handler[] = {
        (iw_handler) NULL,      /* SIOCSIWCOMMIT */
-       (iw_handler) wlan_get_name,     /* SIOCGIWNAME */
+       (iw_handler) lbs_get_name,      /* SIOCGIWNAME */
        (iw_handler) NULL,      /* SIOCSIWNWID */
        (iw_handler) NULL,      /* SIOCGIWNWID */
-       (iw_handler) wlan_set_freq,     /* SIOCSIWFREQ */
-       (iw_handler) wlan_get_freq,     /* SIOCGIWFREQ */
+       (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
+       (iw_handler) lbs_get_freq,      /* SIOCGIWFREQ */
        (iw_handler) NULL,              /* SIOCSIWMODE */
        (iw_handler) mesh_wlan_get_mode,        /* SIOCGIWMODE */
        (iw_handler) NULL,      /* SIOCSIWSENS */
        (iw_handler) NULL,      /* SIOCGIWSENS */
        (iw_handler) NULL,      /* SIOCSIWRANGE */
-       (iw_handler) wlan_get_range,    /* SIOCGIWRANGE */
+       (iw_handler) lbs_get_range,     /* SIOCGIWRANGE */
        (iw_handler) NULL,      /* SIOCSIWPRIV */
        (iw_handler) NULL,      /* SIOCGIWPRIV */
        (iw_handler) NULL,      /* SIOCSIWSTATS */
@@ -2097,46 +2168,46 @@ static const iw_handler mesh_wlan_handler[] = {
        (iw_handler) NULL,      /* SIOCGIWAP */
        (iw_handler) NULL,      /* SIOCSIWMLME */
        (iw_handler) NULL,      /* SIOCGIWAPLIST - deprecated */
-       (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */
-       (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */
-       (iw_handler) NULL,              /* SIOCSIWESSID */
-       (iw_handler) NULL,              /* SIOCGIWESSID */
+       (iw_handler) lbs_set_scan,      /* SIOCSIWSCAN */
+       (iw_handler) lbs_get_scan,      /* SIOCGIWSCAN */
+       (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
+       (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
        (iw_handler) NULL,              /* SIOCSIWNICKN */
        (iw_handler) mesh_get_nick,     /* SIOCGIWNICKN */
        (iw_handler) NULL,      /* -- hole -- */
        (iw_handler) NULL,      /* -- hole -- */
-       (iw_handler) wlan_set_rate,     /* SIOCSIWRATE */
-       (iw_handler) wlan_get_rate,     /* SIOCGIWRATE */
-       (iw_handler) wlan_set_rts,      /* SIOCSIWRTS */
-       (iw_handler) wlan_get_rts,      /* SIOCGIWRTS */
-       (iw_handler) wlan_set_frag,     /* SIOCSIWFRAG */
-       (iw_handler) wlan_get_frag,     /* SIOCGIWFRAG */
-       (iw_handler) wlan_set_txpow,    /* SIOCSIWTXPOW */
-       (iw_handler) wlan_get_txpow,    /* SIOCGIWTXPOW */
-       (iw_handler) wlan_set_retry,    /* SIOCSIWRETRY */
-       (iw_handler) wlan_get_retry,    /* SIOCGIWRETRY */
-       (iw_handler) wlan_set_encode,   /* SIOCSIWENCODE */
-       (iw_handler) wlan_get_encode,   /* SIOCGIWENCODE */
-       (iw_handler) wlan_set_power,    /* SIOCSIWPOWER */
-       (iw_handler) wlan_get_power,    /* SIOCGIWPOWER */
+       (iw_handler) lbs_set_rate,      /* SIOCSIWRATE */
+       (iw_handler) lbs_get_rate,      /* SIOCGIWRATE */
+       (iw_handler) lbs_set_rts,       /* SIOCSIWRTS */
+       (iw_handler) lbs_get_rts,       /* SIOCGIWRTS */
+       (iw_handler) lbs_set_frag,      /* SIOCSIWFRAG */
+       (iw_handler) lbs_get_frag,      /* SIOCGIWFRAG */
+       (iw_handler) lbs_set_txpow,     /* SIOCSIWTXPOW */
+       (iw_handler) lbs_get_txpow,     /* SIOCGIWTXPOW */
+       (iw_handler) lbs_set_retry,     /* SIOCSIWRETRY */
+       (iw_handler) lbs_get_retry,     /* SIOCGIWRETRY */
+       (iw_handler) lbs_set_encode,    /* SIOCSIWENCODE */
+       (iw_handler) lbs_get_encode,    /* SIOCGIWENCODE */
+       (iw_handler) lbs_set_power,     /* SIOCSIWPOWER */
+       (iw_handler) lbs_get_power,     /* SIOCGIWPOWER */
        (iw_handler) NULL,      /* -- hole -- */
        (iw_handler) NULL,      /* -- hole -- */
-       (iw_handler) wlan_set_genie,    /* SIOCSIWGENIE */
-       (iw_handler) wlan_get_genie,    /* SIOCGIWGENIE */
-       (iw_handler) wlan_set_auth,     /* SIOCSIWAUTH */
-       (iw_handler) wlan_get_auth,     /* SIOCGIWAUTH */
-       (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */
-       (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */
+       (iw_handler) lbs_set_genie,     /* SIOCSIWGENIE */
+       (iw_handler) lbs_get_genie,     /* SIOCGIWGENIE */
+       (iw_handler) lbs_set_auth,      /* SIOCSIWAUTH */
+       (iw_handler) lbs_get_auth,      /* SIOCGIWAUTH */
+       (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
+       (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
        (iw_handler) NULL,              /* SIOCSIWPMKSA */
 };
-struct iw_handler_def libertas_handler_def = {
-       .num_standard   = ARRAY_SIZE(wlan_handler),
-       .standard       = (iw_handler *) wlan_handler,
-       .get_wireless_stats = wlan_get_wireless_stats,
+struct iw_handler_def lbs_handler_def = {
+       .num_standard   = ARRAY_SIZE(lbs_handler),
+       .standard       = (iw_handler *) lbs_handler,
+       .get_wireless_stats = lbs_get_wireless_stats,
 };
 
 struct iw_handler_def mesh_handler_def = {
        .num_standard   = ARRAY_SIZE(mesh_wlan_handler),
        .standard       = (iw_handler *) mesh_wlan_handler,
-       .get_wireless_stats = wlan_get_wireless_stats,
+       .get_wireless_stats = lbs_get_wireless_stats,
 };