Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1466014pxb; Wed, 12 Jan 2022 15:43:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWAQ04z3TA26hhsGfgRkhQ5PKUrVVIqVSwjkoflqdi9Ko1MHxRL6NPV/X+TXgjH17WhBzl X-Received: by 2002:a17:902:6b0a:b0:149:9fb2:8631 with SMTP id o10-20020a1709026b0a00b001499fb28631mr1827135plk.73.1642031021366; Wed, 12 Jan 2022 15:43:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642031021; cv=none; d=google.com; s=arc-20160816; b=vr8PRkADfFykdTx9eeEbd8ZbwhNHHUyHmiz7GaLMVz2mUyCXcx2cXGKqtjUdO96TpJ ql4jhDPMCoSjyp+ZxoMpDh1erMM0j3yrl/iFJvVoOKiS7lWsWsF78VO9IC6PzmqCxOyI KBETE8gjsnGtMyxrbpOTsmzSn/kRxR++E98hR1GFQimaEkfUo7GXJdCa5cysZr7lNBic AqTJU/KKxRCU7cb704F0/4eK0xuu0BEwd4CoyFE/36Gra+4ybsQ2M3oiqg3aei3o/SGo oVwRXHH09qgU5PRLF5SZ2V1ekSuN9++/v98+Q1j1/Vvvnglcg0rj48cxJNNWM7YuP/vR uMEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/mPqEh+kkoXnuYCQX8PApN6E5gEoRV1tAp3oGC95zD8=; b=pJntkUj5QkbNWFfN7557cVP+D12/fqaNPwOQ+6PmqRKcwAQmuHbjX1SsZSc0MoTzDv MysgtmKz7JUg58S7diQLv6vqd+Vz57/pPlqcV0FdHMd4BvjZX9vp8WVHKf+UM0UlDQmz FdUkBxY8lXWJAyBcgNKdDdwufCzldzmsJx/pS13HhwJ4/BPE7qA/itglcGMoYvNsPEt0 MD3eQdEPIF6QakTbqyW0OorOziyVQxiAUFJlVemuOAyiqiHktnsX4j88F6PQLd8uCENy TDkK3IllciLSEA4Suk0YHtWuHBFGWYVPnc03cAD4OYNATHW1CvdqHyR3skGKeTmy1m/6 sY+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si1199924pfm.274.2022.01.12.15.43.32; Wed, 12 Jan 2022 15:43:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355626AbiALRd3 (ORCPT + 71 others); Wed, 12 Jan 2022 12:33:29 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:48927 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355606AbiALRdX (ORCPT ); Wed, 12 Jan 2022 12:33:23 -0500 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 9E37320004; Wed, 12 Jan 2022 17:33:17 +0000 (UTC) From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org, "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Michael Hennerich , Harry Morris , Varka Bhadram , Xue Liu , Alan Ott , David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , linux-wireless@vger.kernel.org, Miquel Raynal Subject: [wpan-next v2 02/27] net: mac802154: Ensure proper channel selection at probe time Date: Wed, 12 Jan 2022 18:32:47 +0100 Message-Id: <20220112173312.764660-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220112173312.764660-1-miquel.raynal@bootlin.com> References: <20220112173312.764660-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Right now device drivers are encouraged to just set the ->current_page and ->current_channel to indicate about the current state of the hardware but this is far from ideal given the fact that we might want to configure a few things internally, such as the symbol duration. Call the ieee802154_change_channel() helper from the code section registering the hardware to ensure proper channel selection and configuration both on the device side and the core side. This change somehow "fixes" the hwsim driver which advertises using page 0 channel 13, but does not actually update its own internal pib structure to reflect that configuration. Signed-off-by: Miquel Raynal --- net/mac802154/cfg.c | 3 +-- net/mac802154/ieee802154_i.h | 1 + net/mac802154/main.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index 870e442bbff0..6969f1330ccd 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c @@ -102,8 +102,7 @@ ieee802154_del_iface(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev) return 0; } -static int -ieee802154_change_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) +int ieee802154_change_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) { struct ieee802154_local *local = wpan_phy_priv(wpan_phy); int ret; diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 702560acc8ce..8a7f4c83c5b6 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -127,6 +127,7 @@ ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer); +int ieee802154_change_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel); /* MIB callbacks */ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); diff --git a/net/mac802154/main.c b/net/mac802154/main.c index 520cedc594e1..12ab1545e871 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c @@ -157,6 +157,14 @@ int ieee802154_register_hw(struct ieee802154_hw *hw) ieee802154_setup_wpan_phy_pib(local->phy); + /* Ensure proper channel selection */ + rtnl_lock(); + rc = ieee802154_change_channel(local->phy, local->phy->current_page, + local->phy->current_channel); + rtnl_unlock(); + if (rc) + goto out_wq; + if (!(hw->flags & IEEE802154_HW_CSMA_PARAMS)) { local->phy->supported.min_csma_backoffs = 4; local->phy->supported.max_csma_backoffs = 4; -- 2.27.0