netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Alexander Aring <aahringo@redhat.com>
Cc: Alexander Aring <alex.aring@gmail.com>,
	Stefan Schmidt <stefan@datenfreihafen.org>,
	linux-wpan@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, David Girault <david.girault@qorvo.com>,
	Romuald Despres <romuald.despres@qorvo.com>,
	Frederic Blain <frederic.blain@qorvo.com>,
	Nicolas Schodet <nico@ni.fr.eu.org>,
	Guilhem Imberton <guilhem.imberton@qorvo.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH wpan-next 1/6] ieee802154: Add support for user scanning requests
Date: Mon, 6 Feb 2023 10:12:35 +0100	[thread overview]
Message-ID: <20230206101235.0371da87@xps-13> (raw)
In-Reply-To: <CAK-6q+iwqVx+6qQ-ctynykdrbN+SHxzk91gQCSdYCUD-FornZA@mail.gmail.com>

Hi Alexander,

aahringo@redhat.com wrote on Sun, 5 Feb 2023 20:39:32 -0500:

> Hi,
> 
> On Tue, Nov 29, 2022 at 11:02 AM Miquel Raynal
> <miquel.raynal@bootlin.com> wrote:
> >
> > The ieee802154 layer should be able to scan a set of channels in order
> > to look for beacons advertizing PANs. Supporting this involves adding
> > two user commands: triggering scans and aborting scans. The user should
> > also be notified when a new beacon is received and also upon scan
> > termination.
> >
> > A scan request structure is created to list the requirements and to be
> > accessed asynchronously when changing channels or receiving beacons.
> >
> > Mac layers may now implement the ->trigger_scan() and ->abort_scan()
> > hooks.
> >
> > Co-developed-by: David Girault <david.girault@qorvo.com>
> > Signed-off-by: David Girault <david.girault@qorvo.com>
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >  include/linux/ieee802154.h |   3 +
> >  include/net/cfg802154.h    |  25 +++++
> >  include/net/nl802154.h     |  49 +++++++++
> >  net/ieee802154/nl802154.c  | 215 +++++++++++++++++++++++++++++++++++++
> >  net/ieee802154/nl802154.h  |   3 +
> >  net/ieee802154/rdev-ops.h  |  28 +++++
> >  net/ieee802154/trace.h     |  40 +++++++
> >  7 files changed, 363 insertions(+)
> >
> > diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> > index 0303eb84d596..b22e4147d334 100644
> > --- a/include/linux/ieee802154.h
> > +++ b/include/linux/ieee802154.h
> > @@ -44,6 +44,9 @@
> >  #define IEEE802154_SHORT_ADDR_LEN      2
> >  #define IEEE802154_PAN_ID_LEN          2
> >
> > +/* Duration in superframe order */
> > +#define IEEE802154_MAX_SCAN_DURATION   14
> > +#define IEEE802154_ACTIVE_SCAN_DURATION        15
> >  #define IEEE802154_LIFS_PERIOD         40
> >  #define IEEE802154_SIFS_PERIOD         12
> >  #define IEEE802154_MAX_SIFS_FRAME_SIZE 18
> > diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> > index d09c393d229f..76d4f95e9974 100644
> > --- a/include/net/cfg802154.h
> > +++ b/include/net/cfg802154.h
> > @@ -18,6 +18,7 @@
> >
> >  struct wpan_phy;
> >  struct wpan_phy_cca;
> > +struct cfg802154_scan_request;
> >
> >  #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
> >  struct ieee802154_llsec_device_key;
> > @@ -67,6 +68,10 @@ struct cfg802154_ops {
> >                                 struct wpan_dev *wpan_dev, bool mode);
> >         int     (*set_ackreq_default)(struct wpan_phy *wpan_phy,
> >                                       struct wpan_dev *wpan_dev, bool ackreq);
> > +       int     (*trigger_scan)(struct wpan_phy *wpan_phy,
> > +                               struct cfg802154_scan_request *request);
> > +       int     (*abort_scan)(struct wpan_phy *wpan_phy,
> > +                             struct wpan_dev *wpan_dev);
> >  #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
> >         void    (*get_llsec_table)(struct wpan_phy *wpan_phy,
> >                                    struct wpan_dev *wpan_dev,
> > @@ -278,6 +283,26 @@ struct ieee802154_coord_desc {
> >         bool gts_permit;
> >  };
> >
> > +/**
> > + * struct cfg802154_scan_request - Scan request
> > + *
> > + * @type: type of scan to be performed
> > + * @page: page on which to perform the scan
> > + * @channels: channels in te %page to be scanned
> > + * @duration: time spent on each channel, calculated with:
> > + *            aBaseSuperframeDuration * (2 ^ duration + 1)
> > + * @wpan_dev: the wpan device on which to perform the scan
> > + * @wpan_phy: the wpan phy on which to perform the scan
> > + */
> > +struct cfg802154_scan_request {
> > +       enum nl802154_scan_types type;
> > +       u8 page;
> > +       u32 channels;
> > +       u8 duration;
> > +       struct wpan_dev *wpan_dev;
> > +       struct wpan_phy *wpan_phy;
> > +};
> > +
> >  struct ieee802154_llsec_key_id {
> >         u8 mode;
> >         u8 id;
> > diff --git a/include/net/nl802154.h b/include/net/nl802154.h
> > index b79a89d5207c..79fbd820b25a 100644
> > --- a/include/net/nl802154.h
> > +++ b/include/net/nl802154.h
> > @@ -73,6 +73,9 @@ enum nl802154_commands {
> >         NL802154_CMD_DEL_SEC_LEVEL,
> >
> >         NL802154_CMD_SCAN_EVENT,
> > +       NL802154_CMD_TRIGGER_SCAN,
> > +       NL802154_CMD_ABORT_SCAN,
> > +       NL802154_CMD_SCAN_DONE,
> >
> >         /* add new commands above here */
> >
> > @@ -134,6 +137,12 @@ enum nl802154_attrs {
> >         NL802154_ATTR_NETNS_FD,
> >
> >         NL802154_ATTR_COORDINATOR,
> > +       NL802154_ATTR_SCAN_TYPE,
> > +       NL802154_ATTR_SCAN_FLAGS,
> > +       NL802154_ATTR_SCAN_CHANNELS,
> > +       NL802154_ATTR_SCAN_PREAMBLE_CODES,
> > +       NL802154_ATTR_SCAN_MEAN_PRF,
> > +       NL802154_ATTR_SCAN_DURATION,
> >
> >         /* add attributes here, update the policy in nl802154.c */
> >
> > @@ -259,6 +268,46 @@ enum nl802154_coord {
> >         NL802154_COORD_MAX,
> >  };
> >
> > +/**
> > + * enum nl802154_scan_types - Scan types
> > + *
> > + * @__NL802154_SCAN_INVALID: scan type number 0 is reserved
> > + * @NL802154_SCAN_ED: An ED scan allows a device to obtain a measure of the peak
> > + *     energy in each requested channel
> > + * @NL802154_SCAN_ACTIVE: Locate any coordinator transmitting Beacon frames using
> > + *     a Beacon Request command
> > + * @NL802154_SCAN_PASSIVE: Locate any coordinator transmitting Beacon frames
> > + * @NL802154_SCAN_ORPHAN: Relocate coordinator following a loss of synchronisation
> > + * @NL802154_SCAN_ENHANCED_ACTIVE: Same as Active using Enhanced Beacon Request
> > + *     command instead of Beacon Request command
> > + * @NL802154_SCAN_RIT_PASSIVE: Passive scan for RIT Data Request command frames
> > + *     instead of Beacon frames
> > + * @NL802154_SCAN_ATTR_MAX: Maximum SCAN attribute number
> > + */
> > +enum nl802154_scan_types {
> > +       __NL802154_SCAN_INVALID,
> > +       NL802154_SCAN_ED,
> > +       NL802154_SCAN_ACTIVE,
> > +       NL802154_SCAN_PASSIVE,
> > +       NL802154_SCAN_ORPHAN,
> > +       NL802154_SCAN_ENHANCED_ACTIVE,
> > +       NL802154_SCAN_RIT_PASSIVE,
> > +
> > +       /* keep last */
> > +       NL802154_SCAN_ATTR_MAX,
> > +};
> > +
> > +/**
> > + * enum nl802154_scan_flags - Scan request control flags
> > + *
> > + * @NL802154_SCAN_FLAG_RANDOM_ADDR: use a random MAC address for this scan (ie.
> > + *     a different one for every scan iteration). When the flag is set, full
> > + *     randomisation is assumed.
> > + */
> > +enum nl802154_scan_flags {
> > +       NL802154_SCAN_FLAG_RANDOM_ADDR = BIT(0),
> > +};
> > +
> >  /**
> >   * enum nl802154_cca_modes - cca modes
> >   *
> > diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
> > index 80dc73182785..c497ffd8e897 100644
> > --- a/net/ieee802154/nl802154.c
> > +++ b/net/ieee802154/nl802154.c
> > @@ -221,6 +221,12 @@ static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX+1] = {
> >
> >         [NL802154_ATTR_COORDINATOR] = { .type = NLA_NESTED },
> >
> > +       [NL802154_ATTR_SCAN_TYPE] = { .type = NLA_U8 },
> > +       [NL802154_ATTR_SCAN_CHANNELS] = { .type = NLA_U32 },
> > +       [NL802154_ATTR_SCAN_PREAMBLE_CODES] = { .type = NLA_U64 },
> > +       [NL802154_ATTR_SCAN_MEAN_PRF] = { .type = NLA_U8 },
> > +       [NL802154_ATTR_SCAN_DURATION] = { .type = NLA_U8 },
> > +
> >  #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
> >         [NL802154_ATTR_SEC_ENABLED] = { .type = NLA_U8, },
> >         [NL802154_ATTR_SEC_OUT_LEVEL] = { .type = NLA_U32, },
> > @@ -1384,6 +1390,199 @@ int nl802154_scan_event(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
> >  }
> >  EXPORT_SYMBOL_GPL(nl802154_scan_event);
> >
> > +static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
> > +{
> > +       struct cfg802154_registered_device *rdev = info->user_ptr[0];
> > +       struct net_device *dev = info->user_ptr[1];
> > +       struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
> > +       struct wpan_phy *wpan_phy = &rdev->wpan_phy;
> > +       struct cfg802154_scan_request *request;
> > +       u8 type;
> > +       int err;
> > +
> > +       /* Monitors are not allowed to perform scans */
> > +       if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
> > +               return -EPERM;  
> 
> btw: why are monitors not allowed?

I guess I had the "active scan" use case in mind which of course does
not work with monitors. Maybe I can relax this a little bit indeed,
right now I don't remember why I strongly refused scans on monitors.

Thanks,
Miquèl

  reply	other threads:[~2023-02-06  9:13 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 16:00 [PATCH wpan-next 0/6] IEEE 802.15.4 passive scan support Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 1/6] ieee802154: Add support for user scanning requests Miquel Raynal
2022-12-04 22:44   ` Alexander Aring
2022-12-05  9:57     ` Miquel Raynal
2022-12-07 13:27       ` Alexander Aring
2022-12-07 13:44         ` Miquel Raynal
2022-12-08  2:22           ` Alexander Aring
2023-02-04  4:19   ` Jakub Kicinski
2023-02-10 10:18     ` Miquel Raynal
2023-02-10 10:26       ` Stefan Schmidt
2023-02-10 10:35         ` Miquel Raynal
2023-02-10 18:59       ` Jakub Kicinski
2023-02-10 22:47         ` Miquel Raynal
2023-02-06  1:39   ` Alexander Aring
2023-02-06  9:12     ` Miquel Raynal [this message]
2023-02-07  0:33       ` Alexander Aring
2023-02-07 12:55         ` Alexander Aring
2023-02-07 12:57           ` Alexander Aring
2023-02-13 17:35           ` Miquel Raynal
2023-02-14 13:34             ` Alexander Aring
2023-02-14 13:53               ` Alexander Aring
2023-02-14 14:06                 ` Miquel Raynal
2023-02-14 14:46                   ` Miquel Raynal
2023-02-17  4:37                     ` Alexander Aring
2023-02-17  8:49                       ` Miquel Raynal
2023-02-17  4:34                   ` Alexander Aring
2023-02-17  9:02                     ` Miquel Raynal
2023-02-21  2:43                       ` Alexander Aring
2023-02-10 17:21         ` Miquel Raynal
2023-02-12 20:15           ` Alexander Aring
2023-02-13 10:15             ` Miquel Raynal
2023-02-14 13:51               ` Alexander Aring
2023-02-14 14:28                 ` Miquel Raynal
2023-02-17  4:46                   ` Alexander Aring
2023-02-17  8:52                     ` Miquel Raynal
2023-02-21  2:54                       ` Alexander Aring
2023-02-21  3:05                         ` Alexander Aring
2023-02-24 13:57                         ` Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 2/6] ieee802154: Define a beacon frame header Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 3/6] ieee802154: Introduce a helper to validate a channel Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 4/6] mac802154: Prepare forcing specific symbol duration Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 5/6] mac802154: Add MLME Tx locked helpers Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 6/6] mac802154: Handle passive scanning Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230206101235.0371da87@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=aahringo@redhat.com \
    --cc=alex.aring@gmail.com \
    --cc=davem@davemloft.net \
    --cc=david.girault@qorvo.com \
    --cc=edumazet@google.com \
    --cc=frederic.blain@qorvo.com \
    --cc=guilhem.imberton@qorvo.com \
    --cc=kuba@kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nico@ni.fr.eu.org \
    --cc=pabeni@redhat.com \
    --cc=romuald.despres@qorvo.com \
    --cc=stefan@datenfreihafen.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).