Commit 2ffecf1a authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge tag 'ieee802154-for-net-next-2023-06-23' of...

Merge tag 'ieee802154-for-net-next-2023-06-23' of gitolite.kernel.org:pub/scm/linux/kernel/git/wpan/wpan-next

Miquel Raynal says:

====================
Core WPAN changes:
 - Support for active scans
 - Support for answering BEACON_REQ
 - Specific MLME handling for limited devices

WPAN driver changes:
 - ca8210:
   - Flag the devices as limited
   - Remove stray gpiod_unexport() call

* tag 'ieee802154-for-net-next-2023-06-23' of gitolite.kernel.org:pub/scm/linux/kernel/git/wpan/wpan-next:
  ieee802154: ca8210: Remove stray gpiod_unexport() call
  ieee802154: ca8210: Flag the driver as being limited
  net: ieee802154: Handle limited devices with only datagram support
  mac802154: Handle received BEACON_REQ
  ieee802154: Add support for allowing to answer BEACON_REQ
  mac802154: Handle active scanning
  ieee802154: Add support for user active scan requests
====================

Link: https://lore.kernel.org/r/20230623195506.40b87b5f@xps-13


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 14fd5e0d 18b849f1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2855,7 +2855,6 @@ static int ca8210_interrupt_init(struct spi_device *spi)
	);
	if (ret) {
		dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id);
		gpiod_unexport(gpio_to_desc(pdata->gpio_irq));
		gpio_free(pdata->gpio_irq);
	}

@@ -2945,7 +2944,8 @@ static void ca8210_hw_setup(struct ieee802154_hw *ca8210_hw)
	ca8210_hw->phy->flags =
		WPAN_PHY_FLAG_TXPOWER |
		WPAN_PHY_FLAG_CCA_ED_LEVEL |
		WPAN_PHY_FLAG_CCA_MODE;
		WPAN_PHY_FLAG_CCA_MODE |
		WPAN_PHY_FLAG_DATAGRAMS_ONLY;
}

/**
+3 −0
Original line number Diff line number Diff line
@@ -178,12 +178,15 @@ wpan_phy_cca_cmp(const struct wpan_phy_cca *a, const struct wpan_phy_cca *b)
 *	setting.
 * @WPAN_PHY_FLAG_STATE_QUEUE_STOPPED: Indicates that the transmit queue was
 *	temporarily stopped.
 * @WPAN_PHY_FLAG_DATAGRAMS_ONLY: Indicates that transceiver is only able to
 *	send/receive datagrams.
 */
enum wpan_phy_flags {
	WPAN_PHY_FLAG_TXPOWER		= BIT(1),
	WPAN_PHY_FLAG_CCA_ED_LEVEL	= BIT(2),
	WPAN_PHY_FLAG_CCA_MODE		= BIT(3),
	WPAN_PHY_FLAG_STATE_QUEUE_STOPPED = BIT(4),
	WPAN_PHY_FLAG_DATAGRAMS_ONLY	= BIT(5),
};

struct wpan_phy {
+19 −1
Original line number Diff line number Diff line
@@ -74,6 +74,10 @@ struct ieee802154_beacon_hdr {
#endif
} __packed;

struct ieee802154_mac_cmd_pl {
	u8  cmd_id;
} __packed;

struct ieee802154_sechdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
	u8 level:3,
@@ -149,6 +153,16 @@ struct ieee802154_beacon_frame {
	struct ieee802154_beacon_hdr mac_pl;
};

struct ieee802154_mac_cmd_frame {
	struct ieee802154_hdr mhr;
	struct ieee802154_mac_cmd_pl mac_pl;
};

struct ieee802154_beacon_req_frame {
	struct ieee802154_hdr mhr;
	struct ieee802154_mac_cmd_pl mac_pl;
};

/* pushes hdr onto the skb. fields of hdr->fc that can be calculated from
 * the contents of hdr will be, and the actual value of those bits in
 * hdr->fc will be ignored. this includes the INTRA_PAN bit and the frame
@@ -174,9 +188,13 @@ int ieee802154_hdr_peek_addrs(const struct sk_buff *skb,
 */
int ieee802154_hdr_peek(const struct sk_buff *skb, struct ieee802154_hdr *hdr);

/* pushes a beacon frame into an skb */
/* pushes/pulls various frame types into/from an skb */
int ieee802154_beacon_push(struct sk_buff *skb,
			   struct ieee802154_beacon_frame *beacon);
int ieee802154_mac_cmd_push(struct sk_buff *skb, void *frame,
			    const void *pl, unsigned int pl_len);
int ieee802154_mac_cmd_pl_pull(struct sk_buff *skb,
			       struct ieee802154_mac_cmd_pl *mac_pl);

int ieee802154_max_payload(const struct ieee802154_hdr *hdr);

+36 −0
Original line number Diff line number Diff line
@@ -120,6 +120,29 @@ ieee802154_hdr_push(struct sk_buff *skb, struct ieee802154_hdr *hdr)
}
EXPORT_SYMBOL_GPL(ieee802154_hdr_push);

int ieee802154_mac_cmd_push(struct sk_buff *skb, void *f,
			    const void *pl, unsigned int pl_len)
{
	struct ieee802154_mac_cmd_frame *frame = f;
	struct ieee802154_mac_cmd_pl *mac_pl = &frame->mac_pl;
	struct ieee802154_hdr *mhr = &frame->mhr;
	int ret;

	skb_reserve(skb, sizeof(*mhr));
	ret = ieee802154_hdr_push(skb, mhr);
	if (ret < 0)
		return ret;

	skb_reset_mac_header(skb);
	skb->mac_len = ret;

	skb_put_data(skb, mac_pl, sizeof(*mac_pl));
	skb_put_data(skb, pl, pl_len);

	return 0;
}
EXPORT_SYMBOL_GPL(ieee802154_mac_cmd_push);

int ieee802154_beacon_push(struct sk_buff *skb,
			   struct ieee802154_beacon_frame *beacon)
{
@@ -284,6 +307,19 @@ ieee802154_hdr_pull(struct sk_buff *skb, struct ieee802154_hdr *hdr)
}
EXPORT_SYMBOL_GPL(ieee802154_hdr_pull);

int ieee802154_mac_cmd_pl_pull(struct sk_buff *skb,
			       struct ieee802154_mac_cmd_pl *mac_pl)
{
	if (!pskb_may_pull(skb, sizeof(*mac_pl)))
		return -EINVAL;

	memcpy(mac_pl, skb->data, sizeof(*mac_pl));
	skb_pull(skb, sizeof(*mac_pl));

	return 0;
}
EXPORT_SYMBOL_GPL(ieee802154_mac_cmd_pl_pull);

int
ieee802154_hdr_peek_addrs(const struct sk_buff *skb, struct ieee802154_hdr *hdr)
{
+12 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX+1] = {
		NLA_POLICY_RANGE(NLA_U8, NL802154_SCAN_DONE_REASON_FINISHED,
				 NL802154_SCAN_DONE_REASON_ABORTED),
	[NL802154_ATTR_BEACON_INTERVAL] =
		NLA_POLICY_MAX(NLA_U8, IEEE802154_MAX_SCAN_DURATION),
		NLA_POLICY_MAX(NLA_U8, IEEE802154_ACTIVE_SCAN_DURATION),

#ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
	[NL802154_ATTR_SEC_ENABLED] = { .type = NLA_U8, },
@@ -1417,6 +1417,11 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
		return -EINVAL;
	}

	if (wpan_phy->flags & WPAN_PHY_FLAG_DATAGRAMS_ONLY) {
		NL_SET_ERR_MSG(info->extack, "PHY only supports datagrams");
		return -EOPNOTSUPP;
	}

	request = kzalloc(sizeof(*request), GFP_KERNEL);
	if (!request)
		return -ENOMEM;
@@ -1426,6 +1431,7 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)

	type = nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE]);
	switch (type) {
	case NL802154_SCAN_ACTIVE:
	case NL802154_SCAN_PASSIVE:
		request->type = type;
		break;
@@ -1583,6 +1589,11 @@ nl802154_send_beacons(struct sk_buff *skb, struct genl_info *info)
		return -EPERM;
	}

	if (wpan_phy->flags & WPAN_PHY_FLAG_DATAGRAMS_ONLY) {
		NL_SET_ERR_MSG(info->extack, "PHY only supports datagrams");
		return -EOPNOTSUPP;
	}

	request = kzalloc(sizeof(*request), GFP_KERNEL);
	if (!request)
		return -ENOMEM;
Loading