]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mac802154: Allow the creation of coordinator interfaces
authorMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 26 Oct 2022 09:35:02 +0000 (11:35 +0200)
committerStefan Schmidt <stefan@datenfreihafen.org>
Tue, 1 Nov 2022 10:23:38 +0000 (11:23 +0100)
As a first strep in introducing proper PAN management and association,
we need to be able to create coordinator interfaces which might act as
coordinator or PAN coordinator.

Hence, let's add the minimum support to allow the creation of these
interfaces.

Even though the necessary logic to handle several interfaces on the same
device is added to make this future move easier, in practice only
several interfaces of type MONITOR are allowed at the same time. The
other combinations are not allowed (interface creation is possible but
only one can be opened at a time) because, with a single PHY featuring a
single set of address filters, we cannot afford handling two distinct
interfaces (with different address filters or filtering requirements):
* Having 2 NODEs, 2 COORDs or 1 NODE + 1 COORD
  -> cannot work because the address filters would be different
* Having 1 MONITOR + either 1 NODE or 1 COORD
  -> cannot work because the filtering levels are incompatible

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Alexander Aring <aahringo@redhat.com>
Link: https://lore.kernel.org/r/20221026093502.602734-4-miquel.raynal@bootlin.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
net/mac802154/iface.c
net/mac802154/main.c
net/mac802154/rx.c

index f21132dd82cf7eee568dae2fe3abb92bef784eff..7de2f843379c6958728312fe882cbe4baa7438ca 100644 (file)
@@ -261,13 +261,13 @@ ieee802154_check_concurrent_iface(struct ieee802154_sub_if_data *sdata,
                if (nsdata != sdata && ieee802154_sdata_running(nsdata)) {
                        int ret;
 
-                       /* TODO currently we don't support multiple node types
-                        * we need to run skb_clone at rx path. Check if there
-                        * exist really an use case if we need to support
-                        * multiple node types at the same time.
+                       /* TODO currently we don't support multiple node/coord
+                        * types we need to run skb_clone at rx path. Check if
+                        * there exist really an use case if we need to support
+                        * multiple node/coord types at the same time.
                         */
-                       if (sdata->wpan_dev.iftype == NL802154_IFTYPE_NODE &&
-                           nsdata->wpan_dev.iftype == NL802154_IFTYPE_NODE)
+                       if (sdata->wpan_dev.iftype != NL802154_IFTYPE_MONITOR &&
+                           nsdata->wpan_dev.iftype != NL802154_IFTYPE_MONITOR)
                                return -EBUSY;
 
                        /* check all phy mac sublayer settings are the same.
@@ -564,6 +564,7 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
        wpan_dev->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
 
        switch (type) {
+       case NL802154_IFTYPE_COORD:
        case NL802154_IFTYPE_NODE:
                ieee802154_be64_to_le64(&wpan_dev->extended_addr,
                                        sdata->dev->dev_addr);
@@ -623,6 +624,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
        ieee802154_le64_to_be64(ndev->perm_addr,
                                &local->hw.phy->perm_extended_addr);
        switch (type) {
+       case NL802154_IFTYPE_COORD:
        case NL802154_IFTYPE_NODE:
                ndev->type = ARPHRD_IEEE802154;
                if (ieee802154_is_valid_extended_unicast_addr(extended_addr)) {
index 40fab08df24ba5953892a6f79a079db8cbe9ad7c..3ed31daf7b9c51a3ba5856ae871d9d9547cdf0a5 100644 (file)
@@ -107,7 +107,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
        phy->supported.lbt = NL802154_SUPPORTED_BOOL_FALSE;
 
        /* always supported */
-       phy->supported.iftypes = BIT(NL802154_IFTYPE_NODE);
+       phy->supported.iftypes = BIT(NL802154_IFTYPE_NODE) | BIT(NL802154_IFTYPE_COORD);
 
        return &local->hw;
 }
index 499f71df257fff60f79b6c59551a40b1df94ae98..7ca41fd259f13e52dcd4ffaded66d172356de6e6 100644 (file)
@@ -208,6 +208,7 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local,
        int ret;
        struct ieee802154_sub_if_data *sdata;
        struct ieee802154_hdr hdr;
+       struct sk_buff *skb2;
 
        ret = ieee802154_parse_frame_start(skb, &hdr);
        if (ret) {
@@ -217,7 +218,7 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local,
        }
 
        list_for_each_entry_rcu(sdata, &local->interfaces, list) {
-               if (sdata->wpan_dev.iftype != NL802154_IFTYPE_NODE)
+               if (sdata->wpan_dev.iftype == NL802154_IFTYPE_MONITOR)
                        continue;
 
                if (!ieee802154_sdata_running(sdata))
@@ -230,9 +231,11 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local,
                    sdata->required_filtering == IEEE802154_FILTERING_4_FRAME_FIELDS)
                        continue;
 
-               ieee802154_subif_frame(sdata, skb, &hdr);
-               skb = NULL;
-               break;
+               skb2 = skb_clone(skb, GFP_ATOMIC);
+               if (skb2) {
+                       skb2->dev = sdata->dev;
+                       ieee802154_subif_frame(sdata, skb2, &hdr);
+               }
        }
 }