summaryrefslogtreecommitdiff
path: root/net/mac802154/iface.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac802154/iface.c')
-rw-r--r--net/mac802154/iface.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index dafb2c3ac109..0b21413081f1 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -142,6 +142,46 @@ void mac802154_get_mac_params(struct net_device *dev,
mutex_unlock(&sdata->local->iflist_mtx);
}
+static int mac802154_slave_open(struct net_device *dev)
+{
+ struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+ struct ieee802154_sub_if_data *subif;
+ struct ieee802154_local *local = sdata->local;
+ int res = 0;
+
+ ASSERT_RTNL();
+
+ if (sdata->type == IEEE802154_DEV_WPAN) {
+ mutex_lock(&sdata->local->iflist_mtx);
+ list_for_each_entry(subif, &sdata->local->interfaces, list) {
+ if (subif != sdata && subif->type == sdata->type &&
+ subif->running) {
+ mutex_unlock(&sdata->local->iflist_mtx);
+ return -EBUSY;
+ }
+ }
+ mutex_unlock(&sdata->local->iflist_mtx);
+ }
+
+ mutex_lock(&sdata->local->iflist_mtx);
+ sdata->running = true;
+ mutex_unlock(&sdata->local->iflist_mtx);
+
+ if (local->open_count++ == 0) {
+ res = local->ops->start(&local->hw);
+ WARN_ON(res);
+ if (res)
+ goto err;
+ }
+
+ netif_start_queue(dev);
+ return 0;
+err:
+ sdata->local->open_count--;
+
+ return res;
+}
+
static int mac802154_wpan_open(struct net_device *dev)
{
int rc;
@@ -201,6 +241,25 @@ out:
return rc;
}
+static int mac802154_slave_close(struct net_device *dev)
+{
+ struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+ struct ieee802154_local *local = sdata->local;
+
+ ASSERT_RTNL();
+
+ netif_stop_queue(dev);
+
+ mutex_lock(&sdata->local->iflist_mtx);
+ sdata->running = false;
+ mutex_unlock(&sdata->local->iflist_mtx);
+
+ if (!--local->open_count)
+ local->ops->stop(&local->hw);
+
+ return 0;
+}
+
static int mac802154_set_header_security(struct ieee802154_sub_if_data *sdata,
struct ieee802154_hdr *hdr,
const struct ieee802154_mac_cb *cb)