From patchwork Wed Apr 27 16:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12829202 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 9A8A3C433EF for ; Wed, 27 Apr 2022 16:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243456AbiD0QvA (ORCPT ); Wed, 27 Apr 2022 12:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243518AbiD0Qul (ORCPT ); Wed, 27 Apr 2022 12:50:41 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AE83BDE4C; Wed, 27 Apr 2022 09:47:21 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id DE6D7100008; Wed, 27 Apr 2022 16:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651078040; 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=BIiG20WZvkHQ4ep4wdahDp0PX+zvyjhFTQ2/0CC9xKE=; b=dkfZlUwUt9kqDyy5AKoaowaBywT+wnU+nZcW6YYhZnwqsEgYBn1BkilD2IV3TyBR3SAA0J 1xniS1RC05PgLqyPC7pTpDgaPHQSx37CcuC5EWxFzicHs+MkShn7KTWf21sh6G6OVaN88m ddUY3QB+byws1Yp4nR9i1rnx9lTaKuaG+k+Du8v/lVgSSQ/Sc0Bm4RsSPX9iwi7r5Amc5f CS0IPnojUrqvGJ+LK1pLxgypt6XKNqOM6Kmy5WyNoKm8Yv7i+YMbRIJnoSwwRAu8t+gPcr 6u4S6EVLw0g/gDLdRxVdoSsH9tzS9Ce3tmmutpV+Up+5E26kJ8TgMKOoRiN7ug== 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 11/11] net: mac802154: Introduce a synchronous API for MLME commands Date: Wed, 27 Apr 2022 18:46:59 +0200 Message-Id: <20220427164659.106447-12-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com> References: <20220427164659.106447-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org This is the slow path, we need to wait for each command to be processed before continuing so let's introduce an helper which does the transmission and blocks until it gets notified of its asynchronous completion. This helper is going to be used when introducing scan support. Signed-off-by: Miquel Raynal --- net/mac802154/ieee802154_i.h | 1 + net/mac802154/tx.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index c87c7fa04435..8aa8d0dd9c41 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -125,6 +125,7 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan; void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb); void ieee802154_xmit_sync_worker(struct work_struct *work); int ieee802154_sync_and_hold_queue(struct ieee802154_local *local); +int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb); netdev_tx_t ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 5f94973b57e4..17244293c59a 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -143,6 +143,25 @@ int ieee802154_sync_and_hold_queue(struct ieee802154_local *local) return ieee802154_sync_queue(local); } +int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb) +{ + bool queue_held = ieee802154_queue_is_held(local); + int ret; + + if (!queue_held) + ieee802154_sync_and_hold_queue(local); + + ieee802154_tx(local, skb); + ret = ieee802154_sync_queue(local); + + if (!queue_held) + ieee802154_release_queue(local); + + ieee802154_wake_queue(local); + + return ret; +} + static netdev_tx_t ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb) {