From patchwork Fri Mar 18 18:56:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12785800 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 818C3C43217 for ; Fri, 18 Mar 2022 18:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240272AbiCRS6Y (ORCPT ); Fri, 18 Mar 2022 14:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240273AbiCRS6V (ORCPT ); Fri, 18 Mar 2022 14:58:21 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A14231910; Fri, 18 Mar 2022 11:56:54 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E3061C000A; Fri, 18 Mar 2022 18:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1647629813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n5jr2HZibOMccdD7IWSqEplpempekA+Ea10O2Ew10SE=; b=opg6y/RqsEd9UjBX5HapLUQ6+J1U6jb8qAEWn5kcK5+BXuzMxfvt0jie+vd7/67ShDt9YR bpXnrY2IsLgAJzaiPI6Hs8SXx4iHzjabqjISgWc5VsJW8IGfSH0++mpxtjQ3QKWF+OUZPC A1f+gThpTAw3LDOA74FdrzZo5/gNkqhokaxak9USK+70uOLQawJ0TzTL1PnWuMDwM7eLcU zB8E8UDfZSSPjTGsksvSNunB9JJ4wvfzHqaDz/VHJ0JMsJ/rdELsBcMRpsvsRFC6pOManj 0lj9M+DftTC3CW0IX2Zv4U3msMapQlOzpWW3vudkhxiZooSvbe28fcLMrQ2eHQ== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next v4 04/11] net: mac802154: Create a transmit error helper Date: Fri, 18 Mar 2022 19:56:37 +0100 Message-Id: <20220318185644.517164-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220318185644.517164-1-miquel.raynal@bootlin.com> References: <20220318185644.517164-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- include/net/mac802154.h | 10 ++++++++++ net/mac802154/util.c | 11 +++++++++++ 2 files changed, 21 insertions(+) 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 0bf46f174de3..ec523335336c 100644 --- a/net/mac802154/util.c +++ b/net/mac802154/util.c @@ -91,6 +91,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);