From patchwork Fri Dec 15 12:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 755108 Received: from forward206b.mail.yandex.net (forward206b.mail.yandex.net [178.154.239.151]) (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 7D4472D7AF for ; Fri, 15 Dec 2023 12:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="aK+qwXHz" Received: from forward100c.mail.yandex.net (forward100c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d100]) by forward206b.mail.yandex.net (Yandex) with ESMTP id B317767B92 for ; Fri, 15 Dec 2023 15:43:49 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:47a7:0:640:b27a:0]) by forward100c.mail.yandex.net (Yandex) with ESMTP id 0F68360A9B; Fri, 15 Dec 2023 15:43:42 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id ehk5Ww9j9W20-wk05bFhJ; Fri, 15 Dec 2023 15:43:41 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1702644221; bh=e2HQD4mudrWDZrwhKgt9BFW3NWj+RbEkZP28WFvmv30=; h=Message-ID:Date:Cc:Subject:To:From; b=aK+qwXHzK2ZW1y2gzVurF3Dhvp56V7cJ8iRnEvj5fmwzJIDA8a+rUZmaRcKrehaMO 2NQTejmXs27O44b2/l3jmjyYhnrM7yCtfy5APzzat8VkDOR0Xd70e+NOXZtv5PL9Mn LMjxn5jZ2GNFWe4igzLuucI/+bpUD9yaru9L8KE8= Authentication-Results: mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Johannes Berg Cc: Brian Norris , Ping-Ke Shih , Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH 1/3] wifi: cfg80211: introduce cfg80211_ssid_eq() Date: Fri, 15 Dec 2023 15:38:51 +0300 Message-ID: <20231215123859.196350-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since SSIDs comparison is commonly used across many drivers, introduce generic 'cfg80211_ssid_eq()' to replace driver-private implementations. Signed-off-by: Dmitry Antipov --- include/net/cfg80211.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 602960dafe0f..4d76868c954d 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -7165,6 +7165,23 @@ enum cfg80211_bss_frame_type { int cfg80211_get_ies_channel_number(const u8 *ie, size_t ielen, enum nl80211_band band); +/** + * cfg80211_ssid_eq - compare two SSIDs + * @a: first SSID + * @b: second SSID + * + * Return true if SSIDs are equal, false otherwise. + */ +static inline bool +cfg80211_ssid_eq(struct cfg80211_ssid *a, struct cfg80211_ssid *b) +{ + if (WARN_ON(!a || !b)) + return false; + if (a->ssid_len != b->ssid_len) + return false; + return memcmp(a->ssid, b->ssid, a->ssid_len) ? false : true; +} + /** * cfg80211_inform_bss_data - inform cfg80211 of a new BSS * From patchwork Fri Dec 15 12:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 754835 Received: from forward202b.mail.yandex.net (forward202b.mail.yandex.net [178.154.239.155]) (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 8384B134BF for ; Fri, 15 Dec 2023 12:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="lsmAvTrq" Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d101]) by forward202b.mail.yandex.net (Yandex) with ESMTP id 86B4764A97 for ; Fri, 15 Dec 2023 15:43:50 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:47a7:0:640:b27a:0]) by forward101b.mail.yandex.net (Yandex) with ESMTP id BB76E60906; Fri, 15 Dec 2023 15:43:42 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id ehk5Ww9j9W20-0t0XZDJE; Fri, 15 Dec 2023 15:43:42 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1702644222; bh=TegX+b1MeIhyCw21tTI1d6dy0UZhkzNSn15M6//DtzM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=lsmAvTrqW4tHU36aHXsxgR6yjzx/WKgSUAHTdXkRZR0aN0JYN9s2RdYPm9tsHZmFj F99v2q4ktkeACNfK4R5AdnzGHLDwEG2N4zfH2S8GPpBFJnoYugYXUv9Yo1HTle8C9t jNuGI+kAiBtKNC9184CrEE6pyXkwINuj0I4fIeeg= Authentication-Results: mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Johannes Berg Cc: Brian Norris , Ping-Ke Shih , Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH 2/3] wifi: mwifiex: use cfg80211_ssid_eq() instead of mwifiex_ssid_cmp() Date: Fri, 15 Dec 2023 15:38:52 +0300 Message-ID: <20231215123859.196350-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215123859.196350-1-dmantipov@yandex.ru> References: <20231215123859.196350-1-dmantipov@yandex.ru> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prefer generic 'cfg80211_ssid_eq()' over dropped 'mwifiex_ssid_cmp()'. Compile tested only. Signed-off-by: Dmitry Antipov --- drivers/net/wireless/marvell/mwifiex/join.c | 4 ++-- drivers/net/wireless/marvell/mwifiex/main.h | 1 - drivers/net/wireless/marvell/mwifiex/scan.c | 11 ----------- drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 4 ++-- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/join.c b/drivers/net/wireless/marvell/mwifiex/join.c index a6e254a1185c..9d98a1908dd6 100644 --- a/drivers/net/wireless/marvell/mwifiex/join.c +++ b/drivers/net/wireless/marvell/mwifiex/join.c @@ -1427,8 +1427,8 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv, /* Check if the requested SSID is already joined */ if (priv->curr_bss_params.bss_descriptor.ssid.ssid_len && - !mwifiex_ssid_cmp(&bss_desc->ssid, - &priv->curr_bss_params.bss_descriptor.ssid) && + cfg80211_ssid_eq(&bss_desc->ssid, + &priv->curr_bss_params.bss_descriptor.ssid) && (priv->curr_bss_params.bss_descriptor.bss_mode == NL80211_IFTYPE_ADHOC)) { mwifiex_dbg(priv->adapter, INFO, diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index d263eae6078c..318b42b1896f 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h @@ -1152,7 +1152,6 @@ void mwifiex_queue_scan_cmd(struct mwifiex_private *priv, struct cmd_ctrl_node *cmd_node); int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, struct host_cmd_ds_command *resp); -s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2); int mwifiex_associate(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc); int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index 72904c275461..a2ddac363b10 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -179,17 +179,6 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) return ret; } -/* - * This function compares two SSIDs and checks if they match. - */ -s32 -mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2) -{ - if (!ssid1 || !ssid2 || (ssid1->ssid_len != ssid2->ssid_len)) - return -1; - return memcmp(ssid1->ssid, ssid2->ssid, ssid1->ssid_len); -} - /* * This function checks if wapi is enabled in driver and scanned network is * compatible with it. diff --git a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c index a2ad2b53f016..32a27fad7b79 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c @@ -345,8 +345,8 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, /* Adhoc mode */ /* If the requested SSID matches current SSID, return */ if (bss_desc && bss_desc->ssid.ssid_len && - (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. - ssid, &bss_desc->ssid))) { + cfg80211_ssid_eq(&priv->curr_bss_params.bss_descriptor.ssid, + &bss_desc->ssid)) { ret = 0; goto done; } From patchwork Fri Dec 15 12:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 754834 Received: from forward204b.mail.yandex.net (forward204b.mail.yandex.net [178.154.239.153]) (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 D50352DB76 for ; Fri, 15 Dec 2023 12:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="Iv2g1ItQ" Received: from forward100b.mail.yandex.net (forward100b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d100]) by forward204b.mail.yandex.net (Yandex) with ESMTP id DF49067A70 for ; Fri, 15 Dec 2023 15:43:51 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:47a7:0:640:b27a:0]) by forward100b.mail.yandex.net (Yandex) with ESMTP id 67E93608C6; Fri, 15 Dec 2023 15:43:43 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id ehk5Ww9j9W20-eTXliTtL; Fri, 15 Dec 2023 15:43:42 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1702644223; bh=aVa3Zke5sCHKuOMYsq1zPhiC6v4cpT8L+yCTADRCLIo=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Iv2g1ItQCX5yIwDooOvc3/9zYiXqHpfoS3qviMuiR60/dh5zwycmChKyHbJ/Be6fL hAOtRRe5IBi+2QzDGLAmQ+BVtCYlAy4RwNYc45EBZ2XpVmhXh+yxAhbNpTGqEQtvrB Iq2+hLXxR2wmiwHNwBcklmutb3rQiGxL5oT0R3C0= Authentication-Results: mail-nwsmtp-smtp-production-main-91.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Johannes Berg Cc: Brian Norris , Ping-Ke Shih , Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH 3/3] wifi: rtw88: use cfg80211_ssid_eq() instead of rtw_ssid_equal() Date: Fri, 15 Dec 2023 15:38:53 +0300 Message-ID: <20231215123859.196350-3-dmantipov@yandex.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215123859.196350-1-dmantipov@yandex.ru> References: <20231215123859.196350-1-dmantipov@yandex.ru> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prefer generic 'cfg80211_ssid_eq()' over dropped 'rtw_ssid_equal()'. Compile tested only. Signed-off-by: Dmitry Antipov --- drivers/net/wireless/realtek/rtw88/fw.c | 4 ++-- drivers/net/wireless/realtek/rtw88/main.h | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index acd78311c8c4..3f037ddcecf1 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -998,7 +998,7 @@ static u8 rtw_get_rsvd_page_probe_req_location(struct rtw_dev *rtwdev, if (rsvd_pkt->type != RSVD_PROBE_REQ) continue; if ((!ssid && !rsvd_pkt->ssid) || - rtw_ssid_equal(rsvd_pkt->ssid, ssid)) + cfg80211_ssid_eq(rsvd_pkt->ssid, ssid)) location = rsvd_pkt->page; } @@ -1015,7 +1015,7 @@ static u16 rtw_get_rsvd_page_probe_req_size(struct rtw_dev *rtwdev, if (rsvd_pkt->type != RSVD_PROBE_REQ) continue; if ((!ssid && !rsvd_pkt->ssid) || - rtw_ssid_equal(rsvd_pkt->ssid, ssid)) + cfg80211_ssid_eq(rsvd_pkt->ssid, ssid)) size = rsvd_pkt->probe_req_size; } diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index b6bfd4c02e2d..e14d1da43940 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -2090,18 +2090,6 @@ static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw_vif *rtwvif) return container_of(p, struct ieee80211_vif, drv_priv); } -static inline bool rtw_ssid_equal(struct cfg80211_ssid *a, - struct cfg80211_ssid *b) -{ - if (!a || !b || a->ssid_len != b->ssid_len) - return false; - - if (memcmp(a->ssid, b->ssid, a->ssid_len)) - return false; - - return true; -} - static inline void rtw_chip_efuse_grant_on(struct rtw_dev *rtwdev) { if (rtwdev->chip->ops->efuse_grant)