Skip to contentSkip to conversation

ieee802154: A bunch of fixes

PATCH In review Miquel Raynal 3 participants 14 messages Jan 25, 2022 – Jan 27, 2022

Subsystems (5)
lore
Share & tools
lore

Miquel Raynal

author maintainer
#0 lore raw

v3 cover ieee802154: A bunch of fixes

In preparation to a wider series, here are a number of small and random fixes across the subsystem.

Changes in v2:
* Fixed the wrong RCU usage when updating the default channel at probe time in hwsim.
* Actually fixed the skb leak fix in the at86rf230 driver as suggested by Alexander.
* Also reordered the calls to free the skb then wake the queue everywhere else.
* Added a missing Fixes tag (for the meaningful error codes patch).

Miquel Raynal (6):
net: ieee802154: hwsim: Ensure proper channel selection at probe time
net: ieee802154: mcr20a: Fix lifs/sifs periods
net: ieee802154: at86rf230: Stop leaking skb's
net: ieee802154: ca8210: Stop leaking skb's
net: ieee802154: Return meaningful error codes from the netlink
helpers
MAINTAINERS: Remove Harry Morris bouncing address

 MAINTAINERS                              |  3 +--
 drivers/net/ieee802154/at86rf230.c       | 13 +++++++++++--
 drivers/net/ieee802154/ca8210.c          |  1 +
 drivers/net/ieee802154/mac802154_hwsim.c |  1 +
 drivers/net/ieee802154/mcr20a.c          |  4 ++--
 net/ieee802154/nl802154.c                |  8 ++++----
 6 files changed, 20 insertions(+), 10 deletions(-)
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH v3 1/6 net: ieee802154: hwsim: Ensure proper channel selection at probe time

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
 drivers/net/ieee802154/mac802154_hwsim.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ieee802154/mac802154_hwsim.c +1 -0
index 8caa61ec718f..00ec188a3257 100644
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
 		goto err_pib;
 	}
 
+	pib->page = 13;
 	rcu_assign_pointer(phy->pib, pib);
 	phy->idx = idx;
 	INIT_LIST_HEAD(&phy->edges);
Signature · 1 line
2.27.0
maintainer
#2 lore raw

Re: [wpan v3 1/6] net: ieee802154: hwsim: Ensure proper channel selection at probe time

Hello.

Quoted 18 lines · Miquel Raynal

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
  drivers/net/ieee802154/mac802154_hwsim.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 8caa61ec718f..00ec188a3257 100644

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 789

Quoted 4 lines
drivers/net/ieee802154/mac802154_hwsim.c +1 -0
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
  		goto err_pib;
  	}
 
+	pib->page = 13;

You want to set channel not page here.

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 792

Quoted 4 lines
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
  	rcu_assign_pointer(phy->pib, pib);
  	phy->idx = idx;
  	INIT_LIST_HEAD(&phy->edges);

regards
Stefan Schmidt

author maintainer
#3 lore raw

Re: [wpan v3 1/6] net: ieee802154: hwsim: Ensure proper channel selection at probe time

Hi Stefan,

[email protected] wrote on Tue, 25 Jan 2022 15:28:11 +0100:

Quoted 16 lines

Hello.

Quoted 13 lines · Miquel Raynal

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
  drivers/net/ieee802154/mac802154_hwsim.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 10 lines

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 788

Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 8caa61ec718f..00ec188a3257 100644
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
  		goto err_pib;
  	}  
  > +	pib->page = 13;  

You want to set channel not page here.

Oh crap /o\ I've messed that update badly. Of course I meant pib->channel here, as it is in the commit log.

I'll wait for Alexander's feedback before re-spinning. Unless the rest looks good for you both, I don't know if your policy allows you to fix it when applying, anyhow I'll do what is necessary.

Thanks,
Miquèl

maintainer
#4 lore raw

Re: [wpan v3 1/6] net: ieee802154: hwsim: Ensure proper channel selection at probe time

Hello.

Quoted 31 lines · Miquel Raynal

Hi Stefan,

[email protected] wrote on Tue, 25 Jan 2022 15:28:11 +0100:

Quoted 16 lines

Hello.

Quoted 13 lines · Miquel Raynal

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
   drivers/net/ieee802154/mac802154_hwsim.c | 1 +
   1 file changed, 1 insertion(+)
Quoted 10 lines

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 788

Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 8caa61ec718f..00ec188a3257 100644
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
   		goto err_pib;
   	}
   > +	pib->page = 13;

You want to set channel not page here.

Quoted 6 lines

Oh crap /o\ I've messed that update badly. Of course I meant pib->channel here, as it is in the commit log.

I'll wait for Alexander's feedback before re-spinning. Unless the rest looks good for you both, I don't know if your policy allows you to fix it when applying, anyhow I'll do what is necessary.

If Alex has nothing else and there is no re-spin I fix this when applying, no worries.

regards
Stefan Schmidt

maintainer Acked-by
#5 lore raw

Re: [wpan v3 1/6] net: ieee802154: hwsim: Ensure proper channel selection at probe time

Hi,

Quoted 39 lines · Stefan Schmidt

Hello.

Quoted 34 lines · Miquel Raynal

Hi Stefan,

[email protected] wrote on Tue, 25 Jan 2022 15:28:11 +0100:

Quoted 16 lines

Hello.

Quoted 13 lines · Miquel Raynal

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
   drivers/net/ieee802154/mac802154_hwsim.c | 1 +
   1 file changed, 1 insertion(+)
Quoted 10 lines

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 788

Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 8caa61ec718f..00ec188a3257 100644
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
            goto err_pib;
    }
   > +      pib->page = 13;

You want to set channel not page here.

Oh crap /o\ I've messed that update badly. Of course I meant pib->channel here, as it is in the commit log.

Quoted 6 lines
Quoted 3 lines

I'll wait for Alexander's feedback before re-spinning. Unless the rest looks good for you both, I don't know if your policy allows you to fix it when applying, anyhow I'll do what is necessary.

If Alex has nothing else and there is no re-spin I fix this when applying, no worries.

Everything is fine.

On the whole series. Thanks.

- Alex

maintainer
#6 lore raw

Re: [wpan v3 1/6] net: ieee802154: hwsim: Ensure proper channel selection at probe time

Hello.

Quoted 47 lines · Alexander Aring

Hi,

Quoted 43 lines · Stefan Schmidt

Hello.

Quoted 37 lines · Miquel Raynal

Hi Stefan,

[email protected] wrote on Tue, 25 Jan 2022 15:28:11 +0100:

Quoted 16 lines

Hello.

Quoted 13 lines · Miquel Raynal

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
    drivers/net/ieee802154/mac802154_hwsim.c | 1 +
    1 file changed, 1 insertion(+)
Quoted 10 lines

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 788

Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 8caa61ec718f..00ec188a3257 100644
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
             goto err_pib;
     }
    > +      pib->page = 13;

You want to set channel not page here.

Oh crap /o\ I've messed that update badly. Of course I meant pib->channel here, as it is in the commit log.

I'll wait for Alexander's feedback before re-spinning. Unless the rest looks good for you both, I don't know if your policy allows you to fix it when applying, anyhow I'll do what is necessary.

Quoted 8 lines
Quoted 2 lines

If Alex has nothing else and there is no re-spin I fix this when applying, no worries.

Everything is fine.

On the whole series. Thanks.

Fixed up this commit and applied the whole patchset.

Next one we should look at would be the 3 split out cleanup patches.

regards
Stefan Schmidt

author maintainer
#7 lore raw

Re: [wpan v3 1/6] net: ieee802154: hwsim: Ensure proper channel selection at probe time

Hi Stefan,

[email protected] wrote on Thu, 27 Jan 2022 08:33:15 +0100:

Quoted 55 lines

Hello.

Quoted 52 lines · Alexander Aring

Hi,

Quoted 39 lines · Stefan Schmidt

Hello.

Quoted 34 lines · Miquel Raynal

Hi Stefan,

[email protected] wrote on Tue, 25 Jan 2022 15:28:11 +0100:

Quoted 16 lines

Hello.

Quoted 13 lines · Miquel Raynal

Drivers are expected to set the PHY current_channel and current_page according to their default state. The hwsim driver is advertising being configured on channel 13 by default but that is not reflected in its own internal pib structure. In order to ensure that this driver consider the current channel as being 13 internally, we at least need to set the pib->channel field to 13.

Fixes f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
---
    drivers/net/ieee802154/mac802154_hwsim.c | 1 +
    1 file changed, 1 insertion(+)
Quoted 10 lines

drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 788

Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c +0 -0
index 8caa61ec718f..00ec188a3257 100644
@@ -786,6 +786,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
             goto err_pib;
     }  
    > +      pib->page = 13;  

You want to set channel not page here.

Oh crap /o\ I've messed that update badly. Of course I meant pib->channel here, as it is in the commit log.

Quoted 6 lines
Quoted 3 lines

I'll wait for Alexander's feedback before re-spinning. Unless the rest looks good for you both, I don't know if your policy allows you to fix it when applying, anyhow I'll do what is necessary.

If Alex has nothing else and there is no re-spin I fix this when applying, no worries.

Everything is fine.

Quoted 7 lines
Quoted 3 lines

On the whole series. Thanks.

Fixed up this commit and applied the whole patchset.

Next one we should look at would be the 3 split out cleanup patches.

Great!

Thanks,
Miquèl

author maintainer
#8 lore raw

PATCH v3 2/6 net: ieee802154: mcr20a: Fix lifs/sifs periods

In reply to Miquel Raynal

These periods are expressed in time units (microseconds) while 40 and 12 are the number of symbol durations these periods will last. We need to multiply them both with phy->symbol_duration in order to get these values in microseconds.

Fixes 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
---
 drivers/net/ieee802154/mcr20a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ieee802154/mcr20a.c +2 -2
index 8dc04e2590b1..383231b85464 100644
@@ -976,8 +976,8 @@ static void mcr20a_hw_setup(struct mcr20a_local *lp)
 	dev_dbg(printdev(lp), "%s\n", __func__);
 
 	phy->symbol_duration = 16;
-	phy->lifs_period = 40;
-	phy->sifs_period = 12;
+	phy->lifs_period = 40 * phy->symbol_duration;
+	phy->sifs_period = 12 * phy->symbol_duration;
 
 	hw->flags = IEEE802154_HW_TX_OMIT_CKSUM |
 			IEEE802154_HW_AFILT |
Signature · 1 line
2.27.0
author maintainer
#9 lore raw

PATCH v3 3/6 net: ieee802154: at86rf230: Stop leaking skb's

In reply to Miquel Raynal

Upon error the ieee802154_xmit_complete() helper is not called. Only ieee802154_wake_queue() is called manually. In the Tx case we then leak the skb structure.

Free the skb structure upon error before returning when appropriate.

As the 'is_tx = 0' cannot be moved in the complete handler because of a possible race between the delay in switching to STATE_RX_AACK_ON and a new interrupt, we introduce an intermediate 'was_tx' boolean just for this purpose.

There is no Fixes tag applying here, many changes have been made on this area and the issue kind of always existed.

---
 drivers/net/ieee802154/at86rf230.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/ieee802154/at86rf230.c +11 -2
index 7d67f41387f5..4f5ef8a9a9a8 100644
@@ -100,6 +100,7 @@ struct at86rf230_local {
 	unsigned long cal_timeout;
 	bool is_tx;
 	bool is_tx_from_off;
+	bool was_tx;
 	u8 tx_retry;
 	struct sk_buff *tx_skb;
 	struct at86rf230_state_change tx;
@@ -343,7 +344,11 @@ at86rf230_async_error_recover_complete(void *context)
 	if (ctx->free)
 		kfree(ctx);
 
-	ieee802154_wake_queue(lp->hw);
+	if (lp->was_tx) {
+		lp->was_tx = 0;
+		dev_kfree_skb_any(lp->tx_skb);
+		ieee802154_wake_queue(lp->hw);
+	}
 }
 
 static void
@@ -352,7 +357,11 @@ at86rf230_async_error_recover(void *context)
 	struct at86rf230_state_change *ctx = context;
 	struct at86rf230_local *lp = ctx->lp;
 
-	lp->is_tx = 0;
+	if (lp->is_tx) {
+		lp->was_tx = 1;
+		lp->is_tx = 0;
+	}
+
 	at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON,
 				     at86rf230_async_error_recover_complete);
 }
Signature · 1 line
2.27.0
author maintainer
#10 lore raw

PATCH v3 4/6 net: ieee802154: ca8210: Stop leaking skb's

In reply to Miquel Raynal

Upon error the ieee802154_xmit_complete() helper is not called. Only ieee802154_wake_queue() is called manually. We then leak the skb structure.

Free the skb structure upon error before returning.

Fixes ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
---
 drivers/net/ieee802154/ca8210.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ieee802154/ca8210.c +1 -0
index ece6ff6049f6..f3438d3e104a 100644
@@ -1771,6 +1771,7 @@ static int ca8210_async_xmit_complete(
 			status
 		);
 		if (status != MAC_TRANSACTION_OVERFLOW) {
+			dev_kfree_skb_any(priv->tx_skb);
 			ieee802154_wake_queue(priv->hw);
 			return 0;
 		}
Signature · 1 line
2.27.0
author maintainer
#11 lore raw

PATCH v3 5/6 net: ieee802154: Return meaningful error codes from the netlink helpers

In reply to Miquel Raynal

Returning -1 does not indicate anything useful.

Use a standard and meaningful error code instead.

Fixes a26c5fd7622d ("nl802154: add support for security layer")
---
 net/ieee802154/nl802154.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/ieee802154/nl802154.c +4 -4
index 277124f206e0..e0b072aecf0f 100644
@@ -1441,7 +1441,7 @@ static int nl802154_send_key(struct sk_buff *msg, u32 cmd, u32 portid,
 
 	hdr = nl802154hdr_put(msg, portid, seq, flags, cmd);
 	if (!hdr)
-		return -1;
+		return -ENOBUFS;
 
 	if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex))
 		goto nla_put_failure;
@@ -1634,7 +1634,7 @@ static int nl802154_send_device(struct sk_buff *msg, u32 cmd, u32 portid,
 
 	hdr = nl802154hdr_put(msg, portid, seq, flags, cmd);
 	if (!hdr)
-		return -1;
+		return -ENOBUFS;
 
 	if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex))
 		goto nla_put_failure;
@@ -1812,7 +1812,7 @@ static int nl802154_send_devkey(struct sk_buff *msg, u32 cmd, u32 portid,
 
 	hdr = nl802154hdr_put(msg, portid, seq, flags, cmd);
 	if (!hdr)
-		return -1;
+		return -ENOBUFS;
 
 	if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex))
 		goto nla_put_failure;
@@ -1988,7 +1988,7 @@ static int nl802154_send_seclevel(struct sk_buff *msg, u32 cmd, u32 portid,
 
 	hdr = nl802154hdr_put(msg, portid, seq, flags, cmd);
 	if (!hdr)
-		return -1;
+		return -ENOBUFS;
 
 	if (nla_put_u32(msg, NL802154_ATTR_IFINDEX, dev->ifindex))
 		goto nla_put_failure;
Signature · 1 line
2.27.0
author maintainer
#12 lore raw

PATCH v3 6/6 MAINTAINERS: Remove Harry Morris bouncing address

In reply to Miquel Raynal

Harry's e-mail address from Cascoda bounces, I have not found any contributions from him since 2018 so let's drop the Maintainer entry from the CA8210 driver and mark it Orphan.

---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
MAINTAINERS +1 -2
index 4d479b554361..ab2b32080b73 100644
@@ -4099,9 +4099,8 @@ N:	csky
 K:	csky
 
 CA8210 IEEE-802.15.4 RADIO DRIVER
-M:	Harry Morris <[email protected]>
 L:	[email protected]
-S:	Maintained
+S:	Orphan
 W:	https://github.com/Cascoda/ca8210-linux.git
 F:	Documentation/devicetree/bindings/net/ieee802154/ca8210.txt
 F:	drivers/net/ieee802154/ca8210.c
Signature · 1 line
2.27.0
maintainer
#13 lore raw
In reply to Miquel Raynal

Hello.

Quoted 21 lines · Miquel Raynal

In preparation to a wider series, here are a number of small and random fixes across the subsystem.

Changes in v2:
* Fixed the wrong RCU usage when updating the default channel at probe time in hwsim.
* Actually fixed the skb leak fix in the at86rf230 driver as suggested by Alexander.
* Also reordered the calls to free the skb then wake the queue everywhere else.
* Added a missing Fixes tag (for the meaningful error codes patch).

Miquel Raynal (6):
net: ieee802154: hwsim: Ensure proper channel selection at probe time
net: ieee802154: mcr20a: Fix lifs/sifs periods
net: ieee802154: at86rf230: Stop leaking skb's
net: ieee802154: ca8210: Stop leaking skb's
net: ieee802154: Return meaningful error codes from the netlink
helpers
MAINTAINERS: Remove Harry Morris bouncing address

Quoted 8 lines
  MAINTAINERS                              |  3 +--
  drivers/net/ieee802154/at86rf230.c       | 13 +++++++++++--
  drivers/net/ieee802154/ca8210.c          |  1 +
  drivers/net/ieee802154/mac802154_hwsim.c |  1 +
  drivers/net/ieee802154/mcr20a.c          |  4 ++--
  net/ieee802154/nl802154.c                |  8 ++++----
  6 files changed, 20 insertions(+), 10 deletions(-)

This series has been applied to the wpan tree and will be part of the next pull request to net. Thanks!

regards
Stefan Schmidt