Commit d9319986 authored by Daniel Drake's avatar Daniel Drake Committed by John W. Linville

libertas: only enable mesh when interface is active

Previously, the mesh was running whenever the appropriate hardware
and firmware was present.

Now we only run the mesh when the interface is running.

Also simplifies interface management a little.
Signed-off-by: default avatarDaniel Drake <dsd@laptop.org>
Acked-by: default avatarDan Williams <dcbw@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3db4f989
...@@ -44,9 +44,7 @@ struct lbs_private { ...@@ -44,9 +44,7 @@ struct lbs_private {
/* Mesh */ /* Mesh */
struct net_device *mesh_dev; /* Virtual device */ struct net_device *mesh_dev; /* Virtual device */
#ifdef CONFIG_LIBERTAS_MESH #ifdef CONFIG_LIBERTAS_MESH
u32 mesh_connect_status;
struct lbs_mesh_stats mstats; struct lbs_mesh_stats mstats;
int mesh_open;
uint16_t mesh_tlv; uint16_t mesh_tlv;
u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 mesh_ssid[IEEE80211_MAX_SSID_LEN + 1];
u8 mesh_ssid_len; u8 mesh_ssid_len;
......
...@@ -511,7 +511,7 @@ static int lbs_thread(void *data) ...@@ -511,7 +511,7 @@ static int lbs_thread(void *data)
if (priv->connect_status == LBS_CONNECTED) if (priv->connect_status == LBS_CONNECTED)
netif_wake_queue(priv->dev); netif_wake_queue(priv->dev);
if (priv->mesh_dev && if (priv->mesh_dev &&
lbs_mesh_connected(priv)) netif_running(priv->mesh_dev))
netif_wake_queue(priv->mesh_dev); netif_wake_queue(priv->mesh_dev);
} }
} }
......
...@@ -269,17 +269,11 @@ static ssize_t lbs_mesh_set(struct device *dev, ...@@ -269,17 +269,11 @@ static ssize_t lbs_mesh_set(struct device *dev,
{ {
struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct lbs_private *priv = to_net_dev(dev)->ml_priv;
int enable; int enable;
int ret, action = CMD_ACT_MESH_CONFIG_STOP;
sscanf(buf, "%x", &enable); sscanf(buf, "%x", &enable);
enable = !!enable; enable = !!enable;
if (enable == !!priv->mesh_dev) if (enable == !!priv->mesh_dev)
return count; return count;
if (enable)
action = CMD_ACT_MESH_CONFIG_START;
ret = lbs_mesh_config(priv, action, priv->channel);
if (ret)
return ret;
if (enable) if (enable)
lbs_add_mesh(priv); lbs_add_mesh(priv);
...@@ -822,8 +816,6 @@ int lbs_init_mesh(struct lbs_private *priv) ...@@ -822,8 +816,6 @@ int lbs_init_mesh(struct lbs_private *priv)
lbs_deb_enter(LBS_DEB_MESH); lbs_deb_enter(LBS_DEB_MESH);
priv->mesh_connect_status = LBS_DISCONNECTED;
/* Determine mesh_fw_ver from fwrelease and fwcapinfo */ /* Determine mesh_fw_ver from fwrelease and fwcapinfo */
/* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */ /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
/* 5.110.22 have mesh command with 0xa3 command id */ /* 5.110.22 have mesh command with 0xa3 command id */
...@@ -863,6 +855,8 @@ int lbs_init_mesh(struct lbs_private *priv) ...@@ -863,6 +855,8 @@ int lbs_init_mesh(struct lbs_private *priv)
priv->mesh_tlv = 0; priv->mesh_tlv = 0;
} }
/* Stop meshing until interface is brought up */
lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, priv->channel);
if (priv->mesh_tlv) { if (priv->mesh_tlv) {
sprintf(priv->mesh_ssid, "mesh"); sprintf(priv->mesh_ssid, "mesh");
...@@ -909,10 +903,9 @@ static int lbs_mesh_stop(struct net_device *dev) ...@@ -909,10 +903,9 @@ static int lbs_mesh_stop(struct net_device *dev)
struct lbs_private *priv = dev->ml_priv; struct lbs_private *priv = dev->ml_priv;
lbs_deb_enter(LBS_DEB_MESH); lbs_deb_enter(LBS_DEB_MESH);
spin_lock_irq(&priv->driver_lock); lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_STOP, priv->channel);
priv->mesh_open = 0; spin_lock_irq(&priv->driver_lock);
priv->mesh_connect_status = LBS_DISCONNECTED;
netif_stop_queue(dev); netif_stop_queue(dev);
netif_carrier_off(dev); netif_carrier_off(dev);
...@@ -942,18 +935,20 @@ static int lbs_mesh_dev_open(struct net_device *dev) ...@@ -942,18 +935,20 @@ static int lbs_mesh_dev_open(struct net_device *dev)
if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) { if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) {
ret = -EBUSY; ret = -EBUSY;
spin_unlock_irq(&priv->driver_lock);
goto out; goto out;
} }
priv->mesh_open = 1;
priv->mesh_connect_status = LBS_CONNECTED;
netif_carrier_on(dev); netif_carrier_on(dev);
if (!priv->tx_pending_len) if (!priv->tx_pending_len)
netif_wake_queue(dev); netif_wake_queue(dev);
out:
spin_unlock_irq(&priv->driver_lock); spin_unlock_irq(&priv->driver_lock);
ret = lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, priv->channel);
out:
lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
return ret; return ret;
} }
......
...@@ -63,11 +63,6 @@ void lbs_mesh_ethtool_get_strings(struct net_device *dev, ...@@ -63,11 +63,6 @@ void lbs_mesh_ethtool_get_strings(struct net_device *dev,
uint32_t stringset, uint8_t *s); uint32_t stringset, uint8_t *s);
/* Accessors */
#define lbs_mesh_open(priv) (priv->mesh_open)
#define lbs_mesh_connected(priv) (priv->mesh_connect_status == LBS_CONNECTED)
#else #else
#define lbs_init_mesh(priv) #define lbs_init_mesh(priv)
...@@ -77,8 +72,6 @@ void lbs_mesh_ethtool_get_strings(struct net_device *dev, ...@@ -77,8 +72,6 @@ void lbs_mesh_ethtool_get_strings(struct net_device *dev,
#define lbs_mesh_set_dev(priv, dev, rxpd) (dev) #define lbs_mesh_set_dev(priv, dev, rxpd) (dev)
#define lbs_mesh_set_txpd(priv, dev, txpd) #define lbs_mesh_set_txpd(priv, dev, txpd)
#define lbs_mesh_config(priv, enable, chan) #define lbs_mesh_config(priv, enable, chan)
#define lbs_mesh_open(priv) (0)
#define lbs_mesh_connected(priv) (0)
#endif #endif
......
...@@ -198,7 +198,7 @@ void lbs_send_tx_feedback(struct lbs_private *priv, u32 try_count) ...@@ -198,7 +198,7 @@ void lbs_send_tx_feedback(struct lbs_private *priv, u32 try_count)
if (priv->connect_status == LBS_CONNECTED) if (priv->connect_status == LBS_CONNECTED)
netif_wake_queue(priv->dev); netif_wake_queue(priv->dev);
if (priv->mesh_dev && lbs_mesh_connected(priv)) if (priv->mesh_dev && netif_running(priv->mesh_dev))
netif_wake_queue(priv->mesh_dev); netif_wake_queue(priv->mesh_dev);
} }
EXPORT_SYMBOL_GPL(lbs_send_tx_feedback); EXPORT_SYMBOL_GPL(lbs_send_tx_feedback);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment