linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hector Martin <marcan@marcan.st>
To: Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Arend van Spriel <aspriel@gmail.com>,
	Franky Lin <franky.lin@broadcom.com>,
	Hante Meuleman <hante.meuleman@broadcom.com>,
	Chi-hsien Lin <chi-hsien.lin@infineon.com>,
	Wright Feng <wright.feng@infineon.com>,
	Chung-hsien Hsu <chung-hsien.hsu@infineon.com>
Cc: "Hector Martin" <marcan@marcan.st>,
	"Sven Peter" <sven@svenpeter.dev>,
	"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
	"Mark Kettenis" <kettenis@openbsd.org>,
	"Rafał Miłecki" <zajec5@gmail.com>,
	"Pieter-Paul Giesberts" <pieter-paul.giesberts@broadcom.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	"Daniel (Deognyoun) Kim" <dekim@broadcom.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com,
	SHA-cyfmac-dev-list@infineon.com
Subject: [PATCH 25/34] brcmfmac: cfg80211: Add support for PMKID_V3 operations
Date: Mon, 27 Dec 2021 00:36:15 +0900	[thread overview]
Message-ID: <20211226153624.162281-26-marcan@marcan.st> (raw)
In-Reply-To: <20211226153624.162281-1-marcan@marcan.st>

Add support for the new PMKID_V3 API, which allows performing PMKID
mutations individually, instead of requiring the driver to keep track of
the full list. This new API is required by at least BCM4387.

Note that PMKID_V2 is not implemented yet.

Signed-off-by: Hector Martin <marcan@marcan.st>
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 49 ++++++++++-
 .../broadcom/brcm80211/brcmfmac/fwil_types.h  | 83 +++++++++++++++++++
 2 files changed, 129 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 71e932a8302c..fd2b8b822f8c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4029,6 +4029,34 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
 	return 0;
 }
 
+static s32
+brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa,
+		  bool alive)
+{
+	struct brcmf_pmk_op_v3_le pmk_op;
+	int length = offsetof(struct brcmf_pmk_op_v3_le, pmk);
+
+	memset(&pmk_op, 0, sizeof(pmk_op));
+	pmk_op.version = cpu_to_le16(BRCMF_PMKSA_VER_3);
+
+	if (!pmksa) {
+		/* Flush operation, operate on entire list */
+		pmk_op.count = cpu_to_le16(0);
+	} else {
+		/* Single PMK operation */
+		pmk_op.count = cpu_to_le16(1);
+		length += sizeof(struct brcmf_pmksa_v3);
+		memcpy(pmk_op.pmk[0].bssid, pmksa->bssid, ETH_ALEN);
+		memcpy(pmk_op.pmk[0].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
+		pmk_op.pmk[0].pmkid_len = WLAN_PMKID_LEN;
+		pmk_op.pmk[0].time_left = alive ? BRCMF_PMKSA_NO_EXPIRY : 0;
+	}
+
+	pmk_op.length = cpu_to_le16(length);
+
+	return brcmf_fil_iovar_data_set(ifp, "pmkid_info", &pmk_op, sizeof(pmk_op));
+}
+
 static __used s32
 brcmf_update_pmklist(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp)
 {
@@ -4065,6 +4093,14 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev,
 	if (!check_vif_up(ifp->vif))
 		return -EIO;
 
+	brcmf_dbg(CONN, "set_pmksa - PMK bssid: %pM =\n", pmksa->bssid);
+	brcmf_dbg(CONN, "%*ph\n", WLAN_PMKID_LEN, pmksa->pmkid);
+
+	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PMKID_V3))
+		return brcmf_pmksa_v3_op(ifp, pmksa, true);
+
+	/* TODO: implement PMKID_V2 */
+
 	npmk = le32_to_cpu(cfg->pmk_list.npmk);
 	for (i = 0; i < npmk; i++)
 		if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
@@ -4081,9 +4117,6 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev,
 		return -EINVAL;
 	}
 
-	brcmf_dbg(CONN, "set_pmksa - PMK bssid: %pM =\n", pmk[npmk].bssid);
-	brcmf_dbg(CONN, "%*ph\n", WLAN_PMKID_LEN, pmk[npmk].pmkid);
-
 	err = brcmf_update_pmklist(cfg, ifp);
 
 	brcmf_dbg(TRACE, "Exit\n");
@@ -4107,6 +4140,11 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev,
 
 	brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", pmksa->bssid);
 
+	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PMKID_V3))
+		return brcmf_pmksa_v3_op(ifp, pmksa, false);
+
+	/* TODO: implement PMKID_V2 */
+
 	npmk = le32_to_cpu(cfg->pmk_list.npmk);
 	for (i = 0; i < npmk; i++)
 		if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
@@ -4143,6 +4181,11 @@ brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev)
 	if (!check_vif_up(ifp->vif))
 		return -EIO;
 
+	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PMKID_V3))
+		return brcmf_pmksa_v3_op(ifp, NULL, false);
+
+	/* TODO: implement PMKID_V2 */
+
 	memset(&cfg->pmk_list, 0, sizeof(cfg->pmk_list));
 	err = brcmf_update_pmklist(cfg, ifp);
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
index 19d300dadc28..2c8063a546b6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
@@ -174,6 +174,10 @@
 
 #define BRCMF_HE_CAP_MCS_MAP_NSS_MAX	8
 
+#define BRCMF_PMKSA_VER_2		2
+#define BRCMF_PMKSA_VER_3		3
+#define BRCMF_PMKSA_NO_EXPIRY		0xffffffff
+
 /* MAX_CHUNK_LEN is the maximum length for data passing to firmware in each
  * ioctl. It is relatively small because firmware has small maximum size input
  * playload restriction for ioctls.
@@ -355,6 +359,12 @@ struct brcmf_ssid_le {
 	unsigned char SSID[IEEE80211_MAX_SSID_LEN];
 };
 
+/* Alternate SSID structure used in some places... */
+struct brcmf_ssid8_le {
+	u8 SSID_len;
+	unsigned char SSID[IEEE80211_MAX_SSID_LEN];
+};
+
 struct brcmf_scan_params_le {
 	struct brcmf_ssid_le ssid_le;	/* default: {0, ""} */
 	u8 bssid[ETH_ALEN];	/* default: bcast */
@@ -875,6 +885,51 @@ struct brcmf_pmksa {
 	u8 pmkid[WLAN_PMKID_LEN];
 };
 
+/**
+ * struct brcmf_pmksa_v2 - PMK Security Association
+ *
+ * @length: Length of the structure.
+ * @bssid: The AP's BSSID.
+ * @pmkid: The PMK ID.
+ * @pmk: PMK material for FILS key derivation.
+ * @pmk_len: Length of PMK data.
+ * @ssid: The AP's SSID.
+ * @fils_cache_id: FILS cache identifier
+ */
+struct brcmf_pmksa_v2 {
+	__le16 length;
+	u8 bssid[ETH_ALEN];
+	u8 pmkid[WLAN_PMKID_LEN];
+	u8 pmk[WLAN_PMK_LEN_SUITE_B_192];
+	__le16 pmk_len;
+	struct brcmf_ssid8_le ssid;
+	u16 fils_cache_id;
+};
+
+/**
+ * struct brcmf_pmksa_v3 - PMK Security Association
+ *
+ * @bssid: The AP's BSSID.
+ * @pmkid: The PMK ID.
+ * @pmkid_len: The length of the PMK ID.
+ * @pmk: PMK material for FILS key derivation.
+ * @pmk_len: Length of PMK data.
+ * @fils_cache_id: FILS cache identifier
+ * @ssid: The AP's SSID.
+ * @time_left: Remaining time until expiry. 0 = expired, ~0 = no expiry.
+ */
+struct brcmf_pmksa_v3 {
+	u8 bssid[ETH_ALEN];
+	u8 pmkid[WLAN_PMKID_LEN];
+	u8 pmkid_len;
+	u8 pmk[WLAN_PMK_LEN_SUITE_B_192];
+	u8 pmk_len;
+	__le16 fils_cache_id;
+	u8 pad;
+	struct brcmf_ssid8_le ssid;
+	__le32 time_left;
+};
+
 /**
  * struct brcmf_pmk_list_le - List of pmksa's.
  *
@@ -886,6 +941,34 @@ struct brcmf_pmk_list_le {
 	struct brcmf_pmksa pmk[BRCMF_MAXPMKID];
 };
 
+/**
+ * struct brcmf_pmk_list_v2_le - List of pmksa's.
+ *
+ * @version: Request version.
+ * @length: Length of this structure.
+ * @pmk: PMK SA information.
+ */
+struct brcmf_pmk_list_v2_le {
+	__le16 version;
+	__le16 length;
+	struct brcmf_pmksa_v2 pmk[BRCMF_MAXPMKID];
+};
+
+/**
+ * struct brcmf_pmk_op_v3_le - Operation on PMKSA list.
+ *
+ * @version: Request version.
+ * @length: Length of this structure.
+ * @pmk: PMK SA information.
+ */
+struct brcmf_pmk_op_v3_le {
+	__le16 version;
+	__le16 length;
+	__le16 count;
+	__le16 pad;
+	struct brcmf_pmksa_v3 pmk[BRCMF_MAXPMKID];
+};
+
 /**
  * struct brcmf_pno_param_le - PNO scan configuration parameters
  *
-- 
2.33.0


  parent reply	other threads:[~2021-12-26 15:40 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-26 15:35 [RFC PATCH 00/34] brcmfmac: Support Apple T2 and M1 platforms Hector Martin
2021-12-26 15:35 ` [PATCH 01/34] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips Hector Martin
2021-12-26 21:02   ` Linus Walleij
2021-12-26 23:34   ` Rob Herring
2021-12-27 16:36   ` Rob Herring
2021-12-27 17:23     ` Hector Martin
2021-12-29 16:38       ` Mark Kettenis
2022-01-02 14:12         ` Hector Martin
2021-12-29 16:42   ` Mark Kettenis
2022-01-04  5:47     ` Hector Martin
2021-12-26 15:35 ` [PATCH 02/34] brcmfmac: pcie: Declare missing firmware files in pcie.c Hector Martin
2021-12-26 21:04   ` Linus Walleij
2021-12-26 15:35 ` [PATCH 03/34] brcmfmac: firmware: Support having multiple alt paths Hector Martin
2022-01-02  5:31   ` Linus Walleij
2022-01-02  7:10     ` Dmitry Osipenko
2022-01-02  6:38   ` Dmitry Osipenko
2022-01-02  6:45   ` Dmitry Osipenko
2022-01-02 14:18     ` Hector Martin
2022-01-02 20:11       ` Dmitry Osipenko
2022-01-03  0:41         ` Hector Martin
2022-01-03  1:26           ` Dmitry Osipenko
2022-01-03  6:17             ` Hector Martin
2022-01-02  6:55   ` Dmitry Osipenko
2022-01-03  6:18     ` Hector Martin
2022-01-02  7:08   ` Dmitry Osipenko
2022-01-02  7:20     ` Dmitry Osipenko
2022-01-02 14:25     ` Hector Martin
2022-01-02 20:12       ` Dmitry Osipenko
2021-12-26 15:35 ` [PATCH 04/34] brcmfmac: firmware: Handle per-board clm_blob files Hector Martin
2022-01-02  6:21   ` Linus Walleij
2021-12-26 15:35 ` [PATCH 05/34] brcmfmac: pcie/sdio/usb: Get CLM blob via standard firmware mechanism Hector Martin
2022-01-02  6:22   ` Linus Walleij
2021-12-26 15:35 ` [PATCH 06/34] brcmfmac: firmware: Support passing in multiple board_types Hector Martin
2022-01-02  5:34   ` Linus Walleij
2021-12-26 15:35 ` [PATCH 07/34] brcmfmac: pcie: Read Apple OTP information Hector Martin
2022-01-02  5:38   ` Linus Walleij
2022-01-03  5:51     ` Hector Martin
2022-01-03 11:13       ` Linus Walleij
2021-12-26 15:35 ` [PATCH 08/34] brcmfmac: of: Fetch Apple properties Hector Martin
2022-01-02  5:40   ` Linus Walleij
2021-12-26 15:35 ` [PATCH 09/34] brcmfmac: pcie: Perform firmware selection for Apple platforms Hector Martin
2022-01-02  5:44   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 10/34] brcmfmac: firmware: Allow platform to override macaddr Hector Martin
2022-01-02  5:50   ` Linus Walleij
2022-01-03  5:42     ` Hector Martin
2021-12-26 15:36 ` [PATCH 11/34] brcmfmac: msgbuf: Increase RX ring sizes to 1024 Hector Martin
2022-01-02  5:50   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 12/34] brcmfmac: pcie: Fix crashes due to early IRQs Hector Martin
2022-01-02  5:51   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 13/34] brcmfmac: pcie: Support PCIe core revisions >= 64 Hector Martin
2022-01-02  5:53   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 14/34] brcmfmac: pcie: Add IDs/properties for BCM4378 Hector Martin
2022-01-02  5:53   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 15/34] ACPI / property: Support strings in Apple _DSM props Hector Martin
2021-12-26 18:20   ` Lukas Wunner
2022-01-02  6:20   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 16/34] brcmfmac: acpi: Add support for fetching Apple ACPI properties Hector Martin
2022-01-02  5:58   ` Linus Walleij
2022-01-03  6:03     ` Hector Martin
2022-01-03 11:14       ` Linus Walleij
     [not found]   ` <CAHp75VcZcJ+zCDL-J+w8gEeKXGYdJajjLoa1JTj_kkJixrV12Q@mail.gmail.com>
2022-01-03 17:22     ` Hector Martin
     [not found]       ` <CAHp75Vedgs_zTH2O120jtUuQiuseA0VN62TJiJ7kAi1f5nDQ6Q@mail.gmail.com>
2022-01-04  5:22         ` Hector Martin
2022-01-10  9:59     ` Kalle Valo
2021-12-26 15:36 ` [PATCH 17/34] brcmfmac: pcie: Provide a buffer of random bytes to the device Hector Martin
2022-01-02  5:59   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 18/34] brcmfmac: pcie: Add IDs/properties for BCM4355 Hector Martin
2022-01-02  6:00   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 19/34] brcmfmac: pcie: Add IDs/properties for BCM4377 Hector Martin
2022-01-02  6:01   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 20/34] brcmfmac: pcie: Perform correct BCM4364 firmware selection Hector Martin
2022-01-02  6:02   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 21/34] brcmfmac: chip: Only disable D11 cores; handle an arbitrary number Hector Martin
2022-01-02  6:03   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 22/34] brcmfmac: chip: Handle 1024-unit sizes for TCM blocks Hector Martin
2022-01-02  6:09   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 23/34] brcmfmac: cfg80211: Add support for scan params v2 Hector Martin
2022-01-02  6:23   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 24/34] brcmfmac: feature: Add support for setting feats based on WLC version Hector Martin
2022-01-02  6:11   ` Linus Walleij
2021-12-26 15:36 ` Hector Martin [this message]
2022-01-02  6:12   ` [PATCH 25/34] brcmfmac: cfg80211: Add support for PMKID_V3 operations Linus Walleij
2021-12-26 15:36 ` [PATCH 26/34] brcmfmac: cfg80211: Pass the PMK in binary instead of hex Hector Martin
2022-01-02  6:13   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 27/34] brcmfmac: pcie: Add IDs/properties for BCM4387 Hector Martin
2022-01-02  6:13   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 28/34] brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio Hector Martin
2022-01-02  6:15   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 29/34] brcmfmac: pcie: Read the console on init and shutdown Hector Martin
2022-01-02  6:16   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 30/34] brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path Hector Martin
2022-01-02  6:16   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 31/34] brcmfmac: fwil: Constify iovar name arguments Hector Martin
2022-01-02  6:17   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 32/34] brcmfmac: common: Add support for downloading TxCap blobs Hector Martin
2022-01-02  6:18   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 33/34] brcmfmac: pcie: Load and provide " Hector Martin
2022-01-02  6:19   ` Linus Walleij
2021-12-26 15:36 ` [PATCH 34/34] brcmfmac: common: Add support for external calibration blobs Hector Martin
2022-01-02  6:19   ` Linus Walleij
2021-12-26 19:17 ` [RFC PATCH 00/34] brcmfmac: Support Apple T2 and M1 platforms Lukas Wunner
2021-12-26 21:42   ` Hans de Goede
2021-12-27 11:53     ` Hector Martin
2022-01-02  6:25 ` Linus Walleij
2022-01-03  6:27   ` Hector Martin
2022-01-03 10:20     ` Arend van Spriel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211226153624.162281-26-marcan@marcan.st \
    --to=marcan@marcan.st \
    --cc=SHA-cyfmac-dev-list@infineon.com \
    --cc=alyssa@rosenzweig.io \
    --cc=aspriel@gmail.com \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=chi-hsien.lin@infineon.com \
    --cc=chung-hsien.hsu@infineon.com \
    --cc=davem@davemloft.net \
    --cc=dekim@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=franky.lin@broadcom.com \
    --cc=hante.meuleman@broadcom.com \
    --cc=hdegoede@redhat.com \
    --cc=kettenis@openbsd.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=lenb@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=pieter-paul.giesberts@broadcom.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sandals@crustytoothpaste.net \
    --cc=sven@svenpeter.dev \
    --cc=wright.feng@infineon.com \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).