From patchwork Mon Sep 2 08:43:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lin X-Patchwork-Id: 826286 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012005.outbound.protection.outlook.com [52.101.66.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9525717C9B3; Mon, 2 Sep 2024 08:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725266617; cv=fail; b=UUEsasZhMwG2JUqAEHBSVA1EX2T5G2SHTvx6QzvoObnpKc4VXCoDgA5aQP6kSOv9aAsdgsBzQsGsROrL/7AOru3W/836ai2H0nzKI9ZuAFDZeKK7wm3b0unpyHYvHls2RtU6kO00p7nOnl46znyQmKwJCLf5MIct66xU+tLhf9Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725266617; c=relaxed/simple; bh=b3RXCAQHOOdhM0M5CmldBELhDhY6lSnD1eEoR1FsLhE=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=b36dsGnekZs2BTC3y1ys5jw/ZZqCKld/gWQkCNTOCwUQ6BgnWlNwNSrZiKjS72ESCYm05nOyuu03peQ09JgdmFrweJ1GAtvLrZrxjtZhLfNBjM69/EZaB1rqwYpbmsteagB6+uuVSFvKp+sPzGRvjURNG8w+7Cww0no2eYv1obs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=ahXGpis6; arc=fail smtp.client-ip=52.101.66.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="ahXGpis6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RamH+pf3YFvDWVdhoBwjJNnmD4O2YlRaqITOelvUIJpz+hdzEaCAhbiF9lQOspYbidCpeCRJY6PJR6ADuqneoY/fqMiXFrZQ7ckfHwWe7c+T13sCfgfcDkw1Gdz4ymRCtngDOcg88rC2P1jlN2oZJfl/vEqnjGG6jUuOshPkPDt3bXEVc11dHGOiv8oAbpiVm7nm7RrgfcUDSeMDzHOSfE4UI93BWGYujzLc+mF/R51ljv2if/mlcL0DVUKH/7lXNk9LuP22EZkBz2olprcdyrrYFtAUoO0TJraQCCO3TqPW3cWqpI7A1DPCYICKWgFK7LHdwC3rSeZsGOILi7oEKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e2ZiwTQOfaloPkx8qIRjoksUT+6RoELbjKxOcQpY50Y=; b=tbI8iF44hVsE2hjg1W7wZPru+cfdzcLJyWdIa9ZuyH2k4xTDVjjxbWa+CziuJ24yGxdpiIQieSw2Q2iULKtbdVGllmnZrsz8wDsSoaYz4+WHuSMKFDZQIzUI9ch6Qi3d8ZlpAz3oPaiOxNdSVF83hSbXZVNBvFLkV6sxuGY3t7L7s+1CU5x8DZm0n5qFlrIPdqUOvwG0bM5AY+t0vcjdXAqd8mgUS7j/tgw+17sHguy/M8TbLUBG39RExhaMRHJUM80ud4w5IO6KNb4ZS1TjWxLyd0Is4wRJmWwrPGjM1PstY8vCedHZA58gyweyvz2MM4UzB7kCCVQKsu6dUxR2DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e2ZiwTQOfaloPkx8qIRjoksUT+6RoELbjKxOcQpY50Y=; b=ahXGpis6k4Hc76sPBPSx6LGLPe0bot+FLzgA5m7suCZANQJYsNgT86fDjHJbY/UeglCgRFp6pUR0VJ1R8cq7QOZR9MtmY2pzTb2h3HN/XXPqKOmnUh3piLz3w1TG0jLmG6a5aNJTNWlAyymWuWVn2O0wqHAH+hK5K/4T5lQfJk4magk7P3LuI1Qxu9+C8GsNrxJZdRKoCXVn7Hf+7gnMTIQzwEdsByVdBryHmQeto/dKfPTuVTCfSWLqEOv4QC5si47tnvJpC4NH3p6lvPU9ANR5FDouv8HKuH+CwdbncwvxMeEzhSfPY/UnhXBOFKXAJGZMPdLbrdvd/+R5Q2mDew== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PA4PR04MB9638.eurprd04.prod.outlook.com (2603:10a6:102:273::20) by VI0PR04MB10856.eurprd04.prod.outlook.com (2603:10a6:800:267::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Mon, 2 Sep 2024 08:43:31 +0000 Received: from PA4PR04MB9638.eurprd04.prod.outlook.com ([fe80::f950:3bb6:6848:2257]) by PA4PR04MB9638.eurprd04.prod.outlook.com ([fe80::f950:3bb6:6848:2257%5]) with mapi id 15.20.7918.020; Mon, 2 Sep 2024 08:43:31 +0000 From: David Lin To: linux-wireless@vger.kernel.org Cc: linux-kernel@vger.kernel.org, briannorris@chromium.org, kvalo@kernel.org, francesco@dolcini.it, tsung-hsien.hsieh@nxp.com, s.hauer@pengutronix.de, David Lin Subject: [PATCH v2] wifi: mwifiex: avoid AP and STA running on different channel Date: Mon, 2 Sep 2024 16:43:11 +0800 Message-Id: <20240902084311.2607-1-yu-hao.lin@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SGXP274CA0018.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::30) To PA4PR04MB9638.eurprd04.prod.outlook.com (2603:10a6:102:273::20) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9638:EE_|VI0PR04MB10856:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c037058-23e0-49a7-d895-08dccb2b5281 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: zdT7k/TZHojPYTz5GqmxrT57Hgkdjh0TD7bJKESRslKZyeJnbtV9DgKhwJI4SEjagB2wpYSnG6aHmThIQVHxZPZo612ByZj7HXQlFHIlYofQWbSHAb89FnV8dX+OCB9l6EUKmKiiM1B9HtduFT1era/Je2A82w+yUG/m5omNkXwtYKwKVcnQiuLx5DcTrGj9zk3IcBp2gvkEwMy6zVcgpEiO/9asrQZZ7GbewwUaxQLl2m0snBRSrqlmzvHqjf1V4PdFIm1d9wfUNBEv3vhp3UqNdHWkL3Oc5hAAAIftNWAIKmwlH/0V5Ex7Syu2nWCbeJ3S5KXRMtsjvj+EPHgXyXpx9qdPvFDTYXXT1DnH8E/ADGYTwW5EUqgFQR777nMBkz6weKdLtLL/nHbK233JGd3n8Q0p+DStKvNMBiTnF6kriRq+bV54fPgUOBZiZ4KjmnPMRzFUuYztNkO/3EkZjyz6m03uAK8S91M2esL2oCAzSoz8ewxOd5QoY5fcF92SVj3+3CjB1gse6apSVhO8Hg6TUpjo3t2BruDwHHfPVc/mDJUcBIW7gmZ93TMOGzQCWJeHm/2iVCe88NABzPcV5Mh2Xc2c/wIzrtQYV160788UV30x1Hmi2EazLbZge5eQA1wJB+i4tclpfnpi38BLK7GwUCVlgMPAlvWnQdu/Rx1dPFDKK4Esed75KlShPU47ZEsN0upToc+MmQOERQ3P6EDIBMCMOVE9WfcfB8ka9On3DYAZvjOg8+uWilMfR7IG2UHiEKwAMIqOENWH3IXBhlt9Dv08Xcj5j/21ZUPaUeIGP4O5PWzRf/HCEHrdntiN/pPnVy5CCzb9wH3P/IwklZ2PHaKmnYuYPn9JPS1d1GoQrrvBMWzooaDh1IjffgQ4mlyVckxZGfJ94flKfDOql44mNG4mIuthAkxlrQ2dRqFSiB+EXMUeALDoRUab4rZv5a/Rtl7JuQhfSk/QivAIB4XCEopczVW5ipJ8LLYsFZ6J9DYgFOWmTot1vpBUPXpZCHnPUhQO3Z57uK5/qjAEVBlGcTbSk7IHnINFi1KTXMphgbR3a/9xYa/FA4CwTu43jQN2I480gfy2Hrl+uNgjfJRpaYZEUv/ypZ+Jt2jNTLfttV3tNSM0QyqnSDh6MYANlctvOyCEem0nGLg/N/kQ2BfJf5BsgW0v/P7XSk5Fix0f1BDVdK6xkwkcd0PHQzlpZDcRPaDW6srxQgmuljLdUOFCARB3m5tGq3ozXDn0jK0xN8wZVJu73bCHrtgB/bOQT9V50xwM73BsyZn5+ihFrpVddIhuJZCjg31ke2HzFLA31KbtqcwYlL8gHUhhD6QXR/hq0ekqTwp5qsEnewxqnQWrQWkzbl/s2IeT2J4xERATfXbmhhAHphbqan/U2vCqYC2SYuJA8/eRtSTKR+uVaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR04MB9638.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NKXxupDqnIujRAdMwT+a/CLhNJQi0M20ASIPkOTLA5+4h2BuT4yBHbxUmhEktXEm9cpMzVz1KpS97HUBtYjVz+AHmde1h4hIid9grM8PK6RvE4YsO3E4QLBO59j/qCvoLgrzbQYyBOAcWt3HQzp6BX3SSIj/U3iSOIy1zO1zKC/kIGfDdeShe7uPNpVsZvq0ismsqiq8vu6mBESFEUVdjsdZdObJ5lrMhXhcyRNYXrQB9RNVrDgqyfikK21/FwBwSxmqTKuUJF8wJNmq51KBMlMjhDPkfCmUSYnHpOrfI1m8kF9Qb57IdhlaC35G3OcVmrX+EgyX70zuTypvOVN1XRlydhDVe29VcMVVS9d/B7cpY9LWSGhc6SBMG0MvaS8x7O30XJSwxyY6sx2qmr2eKabWlSAWWEsVlNLGcHx6J83+vfwH/9e5++cP4XwbYxMG7fCw7Q4CfcDkjBL5cRqSH0oStaW6oG2Ni1GeMAyihQupXVS8b8Hxq38m4Y+iB3nxmzMbUYtT6vBUWXbjkaXX7eRsfLPTE/99LbLjDr7XVe//dwuXu+1ZG+61ysZGL39OM7kUJW0XkaUVC5GZymr8GiCtvyDXRTJ/WCkzwuX6ArBmb0HHlefIxQG1mUPzwB7vTIbqorhEXOSqGlJG2MjuU4q+EJksQMkBe9SfE4pu1/dDi6JAsAudMHi8JEVGOhEGhLgbwoTNLLVZB4oIqEk27rvwxK1uArJYYezxcOH4QuHgv28fNREWn51Ek9OF2s78LfV6YtdnN873nNizNHNLIwfytO+rZy7No91Fs4do+xvexh2lS4RurIu9spo4iX0d95OMyIeFNsyqxP0n0sOuuqcrm481qracW6CWRFzYSrdpNOUp3ur52aCw0/4bL3uGllza/3jMuh88/oSejN4OL62tM7/rHLN44qrURGKguM+2AUR1ISQQkAfjSG4acoWJmvJBQjrE8UsFEVujJjerrNS31EoSUC1XDQQa6edwuaps80s9HkP3zSBpiTVluL1XPpQb80XFACjtir1htOP7EDo/HtG/nfczmoRzgja2fjO0cZg658Jy4sBvywSpJ/9WoVOcpBldLjlJnFKDpjY+9XPS6RPHC7ers1rue6/E5tGgrR9bM9oTI50YVR7+zZ8DEwV09Wx7t/d0wjtDHikBzerMukbMf6GnWUouC/PtERFg176h3I2rsTfAlW2uUowoLRJ4/UX0B+NsuEjGBoXV8cmwyyGfHa3IumwxyJysa5Vn9qQMfEhR42pdbzvQp+EqzB45b6TR3xrrzNiEaij2J8tM6+TlRlaqH2TEXiH/dEuBW12vH4fiw2UZv0JSgs2CS9R6KjXB/0lkBLeyM3ZvaXxkfGEHVI6/m3kaAf1o3uddJrTOIeJ+H7IELgnnnUce3TkTkrVfys/ee4G85EHpIw6vP37g3NVakT0S5w7h/NrnVsw+FnXZNt0urvvpaDsYLsHPEW/53b8y9r/Mk/h5UqjSQ1hGb02ZrkwqBjV1G18Q07AkR10IQbFK2zJ795vqRA3tf8oNYzagARbNf5uWROntmrtXz7lOuwYQR9TxLXLxnYsUR+nqOObWGVQzGkPC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c037058-23e0-49a7-d895-08dccb2b5281 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9638.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2024 08:43:31.1068 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9zOajsvam+K6UmaKJ1F//nmafV4GpigkJBCrt/dL4hObLcfE7VhsZZ6Rcz90HXgpuOSQaLPL4CxgghIYauqReQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10856 Current firmware doesn't support AP and STA running on different channels simultaneously. FW crash would occur in such case. This patch avoids the issue by disabling AP and STA to run on different channels. Signed-off-by: David Lin --- v2: - clean up code. --- .../net/wireless/marvell/mwifiex/cfg80211.c | 17 ++++--- drivers/net/wireless/marvell/mwifiex/util.c | 44 +++++++++++++++++++ drivers/net/wireless/marvell/mwifiex/util.h | 13 ++++++ 3 files changed, 69 insertions(+), 5 deletions(-) base-commit: ae98f5c9fd8ba84cd408b41faa77e65bf1b4cdfa diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 722ead51e912..3dbcab463445 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -781,11 +781,9 @@ mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) break; case MWIFIEX_BSS_ROLE_STA: - if (priv->media_connected) { - mwifiex_dbg(adapter, ERROR, - "cannot change wiphy params when connected"); - return -EINVAL; - } + if (priv->media_connected) + break; + if (changed & WIPHY_PARAM_RTS_THRESHOLD) { ret = mwifiex_set_rts(priv, wiphy->rts_threshold); @@ -2069,6 +2067,9 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_UAP) return -1; + if (!mwifiex_is_channel_setting_allowable(priv, params->chandef.chan)) + return -EOPNOTSUPP; + bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param), GFP_KERNEL); if (!bss_cfg) return -ENOMEM; @@ -2463,6 +2464,9 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return -EFAULT; } + if (!mwifiex_is_channel_setting_allowable(priv, sme->channel)) + return -EOPNOTSUPP; + mwifiex_dbg(adapter, INFO, "info: Trying to associate to bssid %pM\n", sme->bssid); @@ -4298,6 +4302,9 @@ mwifiex_cfg80211_authenticate(struct wiphy *wiphy, return -EINVAL; } + if (!mwifiex_is_channel_setting_allowable(priv, req->bss->channel)) + return -EOPNOTSUPP; + if (priv->auth_alg != WLAN_AUTH_SAE && (priv->auth_flag & HOST_MLME_AUTH_PENDING)) { mwifiex_dbg(priv->adapter, ERROR, "Pending auth on going\n"); diff --git a/drivers/net/wireless/marvell/mwifiex/util.c b/drivers/net/wireless/marvell/mwifiex/util.c index 42c04bf858da..6512562c9fb4 100644 --- a/drivers/net/wireless/marvell/mwifiex/util.c +++ b/drivers/net/wireless/marvell/mwifiex/util.c @@ -323,6 +323,50 @@ int mwifiex_debug_info_to_buffer(struct mwifiex_private *priv, char *buf, return p - buf; } +bool mwifiex_is_channel_setting_allowable(struct mwifiex_private *priv, + struct ieee80211_channel *check_chan) +{ + struct mwifiex_adapter *adapter = priv->adapter; + int i; + struct mwifiex_private *tmp_priv; + u8 bss_role = GET_BSS_ROLE(priv); + struct ieee80211_channel *set_chan; + + for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) { + tmp_priv = adapter->priv[i]; + if (tmp_priv == priv) + continue; + + set_chan = NULL; + if (bss_role == MWIFIEX_BSS_ROLE_STA) { + if (GET_BSS_ROLE(tmp_priv) == MWIFIEX_BSS_ROLE_UAP && + netif_carrier_ok(tmp_priv->netdev) && + cfg80211_chandef_valid(&tmp_priv->bss_chandef)) + set_chan = tmp_priv->bss_chandef.chan; + } else if (bss_role == MWIFIEX_BSS_ROLE_UAP) { + struct mwifiex_current_bss_params *bss_params = + &tmp_priv->curr_bss_params; + int channel = bss_params->bss_descriptor.channel; + enum nl80211_band band = + mwifiex_band_to_radio_type(bss_params->band); + int freq = + ieee80211_channel_to_frequency(channel, band); + + if (GET_BSS_ROLE(tmp_priv) == MWIFIEX_BSS_ROLE_STA && + tmp_priv->media_connected) + set_chan = ieee80211_get_channel(adapter->wiphy, freq); + } + + if (set_chan && !ieee80211_channel_equal(check_chan, set_chan)) { + mwifiex_dbg(adapter, ERROR, + "AP/STA must run on the same channel\n"); + return false; + } + } + + return true; +} + static int mwifiex_parse_mgmt_packet(struct mwifiex_private *priv, u8 *payload, u16 len, struct rxpd *rx_pd) diff --git a/drivers/net/wireless/marvell/mwifiex/util.h b/drivers/net/wireless/marvell/mwifiex/util.h index 4699c505c0a0..16f092bb0823 100644 --- a/drivers/net/wireless/marvell/mwifiex/util.h +++ b/drivers/net/wireless/marvell/mwifiex/util.h @@ -86,4 +86,17 @@ static inline void le16_unaligned_add_cpu(__le16 *var, u16 val) put_unaligned_le16(get_unaligned_le16(var) + val, var); } +/* Current firmware doesn't support AP and STA running on different + * channels simultaneously in normal mode. + * FW crash would occur in such case. + * This function is used to check if check_chan can be set to FW or not. + * + * Return: + * %true if check_chan can be set to FW without issues. + * %false there is already other channel is set to FW, setting of + * check_chan is not allowable. + */ +bool mwifiex_is_channel_setting_allowable(struct mwifiex_private *priv, + struct ieee80211_channel *check_chan); + #endif /* !_MWIFIEX_UTIL_H_ */