diff mbox series

[wpan-next,v3,03/11] net: mac802154: Create a transmit error helper

Message ID 20220303182508.288136-4-miquel.raynal@bootlin.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series ieee802154: Better Tx error handling | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 3 this patch: 9
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang fail Errors and warnings before: 0 this patch: 6
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 3 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Miquel Raynal March 3, 2022, 6:25 p.m. UTC
So far there is only a helper for successful transmission, which led
device drivers to implement their own handling in case of
error. Unfortunately, we really need all the drivers to give the hand
back to the core once they are done in order to be able to build a
proper synchronous API. So let's create a _xmit_error() helper and take
this opportunity to fill the new device-global field storing Tx
statuses.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 include/net/mac802154.h | 10 ++++++++++
 net/mac802154/util.c    | 11 +++++++++++
 2 files changed, 21 insertions(+)

Comments

Jakub Kicinski March 4, 2022, 4:30 a.m. UTC | #1
On Thu,  3 Mar 2022 19:25:00 +0100 Miquel Raynal wrote:
> So far there is only a helper for successful transmission, which led
> device drivers to implement their own handling in case of
> error. Unfortunately, we really need all the drivers to give the hand
> back to the core once they are done in order to be able to build a
> proper synchronous API. So let's create a _xmit_error() helper and take
> this opportunity to fill the new device-global field storing Tx
> statuses.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

I'm sure kbuild bot will tell you as well but there's a transient build
failure here which will break bisection:

net/mac802154/util.c: In function ‘ieee802154_xmit_error’:
net/mac802154/util.c:96:14: error: ‘struct ieee802154_local’ has no member named ‘tx_result’
   96 |         local->tx_result = reason;
      |              ^~
Miquel Raynal March 4, 2022, 8:04 a.m. UTC | #2
Hi Jakub,

kuba@kernel.org wrote on Thu, 3 Mar 2022 20:30:25 -0800:

> On Thu,  3 Mar 2022 19:25:00 +0100 Miquel Raynal wrote:
> > So far there is only a helper for successful transmission, which led
> > device drivers to implement their own handling in case of
> > error. Unfortunately, we really need all the drivers to give the hand
> > back to the core once they are done in order to be able to build a
> > proper synchronous API. So let's create a _xmit_error() helper and take
> > this opportunity to fill the new device-global field storing Tx
> > statuses.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>  
> 
> I'm sure kbuild bot will tell you as well but there's a transient build
> failure here which will break bisection:
> 
> net/mac802154/util.c: In function ‘ieee802154_xmit_error’:
> net/mac802154/util.c:96:14: error: ‘struct ieee802154_local’ has no member named ‘tx_result’
>    96 |         local->tx_result = reason;
>       |              ^~

Mmmh, crap, it's just that I forgot to swap patch 03 and patch 04
(adding the field before using it...). I will wait for more feedback
and then send a v4 that fixes that. In the mean time, you can
definitely swap patches manually for build coverage purposes, if
needed.

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 2c3bbc6645ba..abbe88dc9df5 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -498,4 +498,14 @@  void ieee802154_stop_queue(struct ieee802154_hw *hw);
 void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
 			      bool ifs_handling);
 
+/**
+ * ieee802154_xmit_error - frame transmission failed
+ *
+ * @hw: pointer as obtained from ieee802154_alloc_hw().
+ * @skb: buffer for transmission
+ * @reason: error code
+ */
+void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
+			   int reason);
+
 #endif /* NET_MAC802154_H */
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index f2078238718b..37d2520804e3 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -88,6 +88,17 @@  void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
 }
 EXPORT_SYMBOL(ieee802154_xmit_complete);
 
+void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
+			   int reason)
+{
+	struct ieee802154_local *local = hw_to_local(hw);
+
+	local->tx_result = reason;
+	ieee802154_wake_queue(hw);
+	dev_kfree_skb_any(skb);
+}
+EXPORT_SYMBOL(ieee802154_xmit_error);
+
 void ieee802154_stop_device(struct ieee802154_local *local)
 {
 	flush_workqueue(local->workqueue);