Skip to contentSkip to conversation

iwlwifi: mei: add the driver to allow cooperation with CSME

PATCH Superseded Emmanuel Grumbach 6 participants 24 messages Jun 23, 2021 – Oct 18, 2021

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/4 iwlwifi: mei: add the driver to allow cooperation with CSME

CSME in two words
-----------------
CSME stands for Converged Security and Management Engine. It is a CPU on the chipset and runs a dedicated firmware.
AMT (Active Management Technology) is one of the applications that run on that CPU. AMT allows to control the platform remotely. Here is a partial list of the use cases:
* View the screen of the plaform, with keyboard and mouse (KVM)
* Attach a remote IDE device
* Have a serial console to the device
* Query the state of the platform
* Reset / shut down / boot the platform

Networking in CSME
------------------
For those uses cases, CSME's firmware has an embedded network stack and is able to use the network devices of the system: LAN and WLAN. This is thanks to the CSME's firmware WLAN driver.

One can add a profile (SSID / key / certificate) to the CSME's OS and CSME will connect to that profile. Then, one can use the WLAN link to access the applications that run on CSME (AMT is one of them). Note that CSME is active during power state and power state transitions. For example, it is possible to have a KVM session open to the system while the system is rebooting and actually configure the BIOS remotely over WLAN thanks to AMT.

How all this is related to Linux
--------------------------------
In Linux, there is a driver that allows the OS to talk to the CSME firmware, this driver is drivers/misc/mei. This driver advertises a bus that allows other kernel drivers or even user space) to talk to components inside the CSME firmware. In practice, the system advertises a PCI device that allows to send / receive data to / from the CSME firmware. The mei bus drivers in drivers/misc/mei is an abstration on top of this PCI device.
The driver being added here is called iwlmei and talks to the WLAN driver inside the CSME firmware through the mei bus driver. Note that the mei bus driver only gives bus services, it doesn't define the content of the communication.

Why do we need this driver?
--------------------------
CSME uses the same WLAN device that the OS is expecting to see hence we need an arbitration mechanism. This is what iwlmei is in charge of. iwlmei maintains the communication with the CSME firmware's WLAN driver. The language / protocol that is used between the CSME's firmware WLAN driver and iwlmei is OS agnostic and is called SAP which stands for Software Abritration Protocol. With SAP, iwlmei will be able to tell the CSME firmware's WLAN driver:
1) Please give me the device.
2) Please note that the SW/HW rfkill state change.
3) Please note that I am now associated to X.
4) Please note that I received this packet.
etc...

There are messages that go the opposite direction as well:
1) Please note that AMT is en/disable.
2) Please note that I believe the OS is broken and hence I'll take the device *now*, whether you like it or not, to make sure that connectivity is preserved.
3) Please note that I am willing to give the device if the OS needs it.
4) Please give me any packet that is sent on UDP / TCP on IP address XX.XX.XX.XX and an port ZZ.
5) Please send this packet.
etc...

Please check drivers/net/wireless/intel/iwlwifi/mei/sap.h for the full protocol specification.

Arbitration is not the only purpose of iwlmei and SAP. SAP also allows to maintain the AMT's functionality even when the OS owns the device. To connect to AMT, one needs to initiate an HTTP connection to port 16992. iwlmei will listen to the Rx path and forward (through SAP) to the CSME firmware the data it got. Then, the embedded HTTP server in the chipset will reply to the request and send a SAP notification to ask iwlmei to send the reply. This way, AMT running on the CSME can still work.

In practice this means that all the use cases quoted above (KVM, remote IDE device, etc...) will work even when the OS uses the WLAN device.

How to disable all this?
---------------------------
iwlmei won't be able to do anything if the CSME's networking stack is not enabled. By default, CSME's networking stack is disabled (this is a BIOS setting).
In case the CSME's networking stack is disabled, iwlwifi will just get access to the device because there is no contention with any other actor and, hence, no arbitration is needed.

In this patch, I only add the iwlmei driver. Integration with iwlwifi will be implemented in the next one.

---
v2: fix a few warnings raised by the different bots
v3: rewrite the commit message

---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |   17 +
 drivers/net/wireless/intel/iwlwifi/Makefile   |    1 +
 .../net/wireless/intel/iwlwifi/mei/Makefile   |    8 +
 .../net/wireless/intel/iwlwifi/mei/internal.h |   20 +
 .../net/wireless/intel/iwlwifi/mei/iwl-mei.h  |  467 ++++
 drivers/net/wireless/intel/iwlwifi/mei/main.c | 1976 +++++++++++++++++
 drivers/net/wireless/intel/iwlwifi/mei/net.c  |  409 ++++
 drivers/net/wireless/intel/iwlwifi/mei/sap.h  |  734 ++++++
 .../wireless/intel/iwlwifi/mei/trace-data.h   |   69 +
 .../net/wireless/intel/iwlwifi/mei/trace.c    |   15 +
 .../net/wireless/intel/iwlwifi/mei/trace.h    |   62 +
 11 files changed, 3778 insertions(+)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/Makefile
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/internal.h
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/main.c
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/net.c
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/sap.h
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace-data.h
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.c
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.h
drivers/net/wireless/intel/iwlwifi/Kconfig +17 -0
index 1085afbefba8..629aaa26a230 100644
@@ -92,6 +92,23 @@ config IWLWIFI_BCAST_FILTERING
 	  If unsure, don't enable this option, as some programs might
 	  expect incoming broadcasts for their normal operations.
 
+config IWLMEI
+	tristate "Intel Management Engine communication over WLAN"
+	depends on INTEL_MEI
+	depends on PM
+	depends on IWLMVM
+	help
+	  Enables the iwlmei kernel module. This allows to communicate with
+	  the Intel Management Engine over Wifi. This is supported starting
+	  from Tiger Lake platforms and has been tested on 9260 devices only.
+	  Enabling this option on a platform that has a different device and
+	  has Wireless enabled on AMT can prevent WiFi from working correctly.
+
+	  For more information see
+	  <https://software.intel.com/en-us/manageability/>
+
+	  If unsure, say N.
+
 menu "Debugging Options"
 
 config IWLWIFI_DEBUG
drivers/net/wireless/intel/iwlwifi/Makefile +1 -0
index 14b0db28143b..c033caa0eaa9 100644
@@ -29,5 +29,6 @@ ccflags-y += -I$(src)
 
 obj-$(CONFIG_IWLDVM)	+= dvm/
 obj-$(CONFIG_IWLMVM)	+= mvm/
+obj-$(CONFIG_IWLMEI)	+= mei/
 
 CFLAGS_iwl-devtrace.o := -I$(src)
drivers/net/wireless/intel/iwlwifi/mei/Makefile new file +8 -0
new file mode 100644
index 000000000000..f897951ab21b
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_IWLMEI)	+= iwlmei.o
+iwlmei-y += main.o
+iwlmei-y += net.o
+iwlmei-$(CONFIG_IWLWIFI_DEVICE_TRACING) += trace.o
+CFLAGS_trace.o := -I$(src)
+
+ccflags-y += -I$(src)/../
drivers/net/wireless/intel/iwlwifi/mei/internal.h new file +20 -0
new file mode 100644
index 000000000000..7f0a2e4de0f4
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Intel Corporation
+ */
+
+#ifndef __IWLMEI_INTERNAL_H_
+#define __IWLMEI_INTERNAL_H_
+
+#include <uapi/linux/if_ether.h>
+#include <linux/netdevice.h>
+
+#include "sap.h"
+
+rx_handler_result_t iwl_mei_rx_filter(struct sk_buff *skb,
+				      const struct iwl_sap_oob_filters *filters,
+				      bool *pass_to_csme);
+
+void iwl_mei_add_data_to_ring(struct sk_buff *skb, bool cb_tx);
+
+#endif /* __IWLMEI_INTERNAL_H_ */
drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h new file +467 -0

467 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1976 -0

1,976 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mei/net.c new file +409 -0

409 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mei/sap.h new file +734 -0

91 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mei/trace-data.h new file +69 -0

69 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mei/trace.c new file +15 -0
new file mode 100644
index 000000000000..47ac32ef9f69

Lines of this file are not shown. View the raw message.

drivers/net/wireless/intel/iwlwifi/mei/trace.h new file +62 -0

62 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#1 lore raw

PATCH v3 2/4 iwlwifi: integrate with iwlmei

iwlmei needs to know about the follwing events:

* Association
* De-association
* Country Code change
* SW Rfkill change
* SAR table changes

iwlmei can take the device away from us, so report the new rfkill type when this happens.
Advertise the required data from the CSME firmware to the
usersapce: mostly, the AP that the CSME firmware is currently associated to in case there is an active link protection session.
Generate the HOST_ASSOC / HOST_DISSASSOC messages.

Don't support WPA1 (non-RSNA) for now.
Don't support shared wep either.
We can then determine the AUTH parameter by checking the AKM. Feed the cipher from the key installation.

SW Rfkill will be implemented later when cfg80211 will allow us to read the SW Rfkill state.

---
 .../wireless/intel/iwlwifi/iwl-nvm-parse.c    |  61 ++++++
 .../wireless/intel/iwlwifi/iwl-nvm-parse.h    |  11 +-
 .../net/wireless/intel/iwlwifi/iwl-trans.h    |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   |   3 +-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 114 +++++++++-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  73 +++++++
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  | 205 +++++++++++++++++-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h  |   4 +-
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c   |   7 +-
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c |  25 +++
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  16 +-
 11 files changed, 499 insertions(+), 22 deletions(-)
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +61 -0
index 850648ebd61c..4c2817c94d05 100644
@@ -22,6 +22,7 @@
 #include "fw/api/commands.h"
 #include "fw/api/cmdhdr.h"
 #include "fw/img.h"
+#include "mei/iwl-mei.h"
 
 /* NVM offsets (in words) definitions */
 enum nvm_offsets {
@@ -1088,6 +1089,66 @@ iwl_nvm_no_wide_in_5ghz(struct iwl_trans *trans, const struct iwl_cfg *cfg,
 	return false;
 }
 
+struct iwl_nvm_data *
+iwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
+		       const struct iwl_mei_nvm *mei_nvm,
+		       const struct iwl_fw *fw)
+{
+	struct iwl_nvm_data *data;
+	u32 sbands_flags = 0;
+	u8 rx_chains = fw->valid_rx_ant;
+	u8 tx_chains = fw->valid_rx_ant;
+
+	if (cfg->uhb_supported)
+		data = kzalloc(struct_size(data, channels,
+					   IWL_NVM_NUM_CHANNELS_UHB),
+					   GFP_KERNEL);
+	else
+		data = kzalloc(struct_size(data, channels,
+					   IWL_NVM_NUM_CHANNELS_EXT),
+					   GFP_KERNEL);
+	if (!data)
+		return NULL;
+
+	BUILD_BUG_ON(ARRAY_SIZE(mei_nvm->channels) !=
+		     IWL_NVM_NUM_CHANNELS_UHB);
+	data->nvm_version = mei_nvm->nvm_version;
+
+	iwl_set_radio_cfg(cfg, data, mei_nvm->radio_cfg);
+	if (data->valid_tx_ant)
+		tx_chains &= data->valid_tx_ant;
+	if (data->valid_rx_ant)
+		rx_chains &= data->valid_rx_ant;
+
+	data->sku_cap_mimo_disabled = false;
+	data->sku_cap_band_24ghz_enable = true;
+	data->sku_cap_band_52ghz_enable = true;
+	data->sku_cap_11n_enable =
+		!(iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_ALL);
+	data->sku_cap_11ac_enable = true;
+	data->sku_cap_11ax_enable =
+		mei_nvm->caps & MEI_NVM_CAPS_11AX_SUPPORT;
+
+	data->lar_enabled = mei_nvm->caps & MEI_NVM_CAPS_LARI_SUPPORT;
+
+	data->n_hw_addrs = mei_nvm->n_hw_addrs;
+	/* If no valid mac address was found - bail out */
+	if (iwl_set_hw_address(trans, cfg, data, NULL, NULL)) {
+		kfree(data);
+		return NULL;
+	}
+
+	if (data->lar_enabled &&
+	    fw_has_capa(&fw->ucode_capa, IWL_UCODE_TLV_CAPA_LAR_SUPPORT))
+		sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
+
+	iwl_init_sbands(trans, data, mei_nvm->channels, tx_chains, rx_chains,
+			sbands_flags, true, fw);
+
+	return data;
+}
+IWL_EXPORT_SYMBOL(iwl_parse_mei_nvm_data);
+
 struct iwl_nvm_data *
 iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
 		   const struct iwl_fw *fw,
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h +10 -1
index e1f5a9741850..e01f7751cf11 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2005-2015, 2018-2020 Intel Corporation
+ * Copyright (C) 2005-2015, 2018-2021 Intel Corporation
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
 #ifndef __iwl_nvm_parse_h__
@@ -8,6 +8,7 @@
 
 #include <net/cfg80211.h>
 #include "iwl-eeprom-parse.h"
+#include "mei/iwl-mei.h"
 
 /**
  * enum iwl_nvm_sbands_flags - modification flags for the channel profiles
@@ -81,4 +82,12 @@ void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data,
 struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans,
 				 const struct iwl_fw *fw);
 
+/**
+ * iwl_parse_mei_nvm_data - parse the mei_nvm_data and get an iwl_nvm_data
+ */
+struct iwl_nvm_data *
+iwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
+		       const struct iwl_mei_nvm *mei_nvm,
+		       const struct iwl_fw *fw);
+
 #endif /* __iwl_nvm_parse_h__ */
drivers/net/wireless/intel/iwlwifi/iwl-trans.h +2 -0
index bf569f856ad8..a642f5920146 100644
@@ -902,6 +902,7 @@ struct iwl_trans_txqs {
 /**
  * struct iwl_trans - transport common data
  *
+ * @csme_own - true if we couldn't get ownership on the device
  * @ops - pointer to iwl_trans_ops
  * @op_mode - pointer to the op_mode
  * @trans_cfg: the trans-specific configuration part
@@ -936,6 +937,7 @@ struct iwl_trans_txqs {
  * @iwl_trans_txqs: transport tx queues data.
  */
 struct iwl_trans {
+	bool csme_own;
 	const struct iwl_trans_ops *ops;
 	struct iwl_op_mode *op_mode;
 	const struct iwl_cfg_trans_params *trans_cfg;
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +2 -1
index 38fd5886af2d..36ccfa302406 100644
@@ -750,6 +750,8 @@ int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)
 	if (ret)
 		return ret;
 
+	iwl_mei_set_power_limit(per_chain);
+
 	IWL_DEBUG_RADIO(mvm, "Sending REDUCE_TX_POWER_CMD per chain\n");
 	return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
 }
@@ -1317,7 +1319,6 @@ static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)
 	if (iwl_mvm_has_unified_ucode(mvm))
 		return iwl_run_unified_mvm_ucode(mvm);
 
-	WARN_ON(!mvm->nvm_data);
 	ret = iwl_run_init_mvm_ucode(mvm);
 
 	if (ret) {
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +110 -4

198 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +73 -0

107 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/ops.c +193 -12

305 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/sta.h +3 -1
index 32b4d1935788..e34b82b2a288 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
  * Copyright (C) 2015-2016 Intel Deutschland GmbH
  */
@@ -373,6 +373,7 @@ struct iwl_mvm_rxq_dup_data {
  * @tx_ant: the index of the antenna to use for data tx to this station. Only
  *	used during connection establishment (e.g. for the 4 way handshake
  *	exchange).
+ * @pairwise_cipher: used to feed iwlmei upon authorization
  *
  * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  * in the structure for use by driver. This structure is placed in that
@@ -415,6 +416,7 @@ struct iwl_mvm_sta {
 	u8 sleep_tx_count;
 	u8 avg_energy;
 	u8 tx_ant;
+	u32 pairwise_cipher;
 };
 
 u16 iwl_mvm_tid_queued(struct iwl_mvm *mvm, struct iwl_mvm_tid_data *tid_data);
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +6 -1
index 1ad621d13ad3..8075d4a51692 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -1117,6 +1117,11 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
 	/* From now on, we cannot access info->control */
 	iwl_mvm_skb_prepare_status(skb, dev_cmd);
 
+	if (ieee80211_is_data(fc))
+		iwl_mvm_mei_tx_copy_to_csme(mvm, skb,
+					    info->control.hw_key ?
+					    info->control.hw_key->iv_len : 0);
+
 	if (iwl_trans_tx(mvm->trans, skb, dev_cmd, txq_id))
 		goto drop_unlock_sta;
 
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +25 -0
index a92c5f0044cd..d7106a51e8bf 100644
@@ -1149,6 +1149,27 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans);
 
+	/*
+	 * Let's try to grab NIC access early here. Sometimes, NICs may
+	 * fail to initialize, and if that happens it's better if we see
+	 * issues early on (and can reprobe, per the logic inside), than
+	 * first trying to load the firmware etc. and potentially only
+	 * detecting any problems when the first interface is brought up.
+	 */
+	ret = iwl_pcie_prepare_card_hw(iwl_trans);
+	if (!ret) {
+		ret = iwl_finish_nic_init(iwl_trans, trans);
+		if (ret)
+			goto out_free_trans;
+		if (iwl_trans_grab_nic_access(iwl_trans)) {
+			/* all good */
+			iwl_trans_release_nic_access(iwl_trans);
+		} else {
+			ret = -EIO;
+			goto out_free_trans;
+		}
+	}
+
 	iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID);
 
 	for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
@@ -1286,6 +1307,10 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto out_free_trans;
 
 	pci_set_drvdata(pdev, iwl_trans);
+
+	/* try to get ownership so that we'll know if we don't own it */
+	iwl_pcie_prepare_card_hw(iwl_trans);
+
 	iwl_trans->drv = iwl_drv_start(iwl_trans);
 
 	if (IS_ERR(iwl_trans->drv)) {
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +14 -2
index 1331a6bfd767..a4d6988b50a6 100644
@@ -24,6 +24,7 @@
 #include "fw/error-dump.h"
 #include "fw/dbg.h"
 #include "fw/api/tx.h"
+#include "mei/iwl-mei.h"
 #include "internal.h"
 #include "iwl-fh.h"
 #include "iwl-context-info-gen3.h"
@@ -576,8 +577,10 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
 
 	ret = iwl_pcie_set_hw_ready(trans);
 	/* If the card is ready, exit 0 */
-	if (ret >= 0)
+	if (ret >= 0) {
+		trans->csme_own = false;
 		return 0;
+	}
 
 	iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG,
 		    CSR_RESET_LINK_PWR_MGMT_DISABLED);
@@ -590,8 +593,17 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
 
 		do {
 			ret = iwl_pcie_set_hw_ready(trans);
-			if (ret >= 0)
+			if (ret >= 0) {
+				trans->csme_own = false;
 				return 0;
+			}
+
+			if (iwl_mei_is_connected()) {
+				IWL_WARN(trans,
+					 "Couldn't prepare the card but SAP is connected\n");
+				trans->csme_own = true;
+				return -EBUSY;
+			}
 
 			usleep_range(200, 1000);
 			t += 200;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 2/4] iwlwifi: integrate with iwlmei

Thank you for the patch! Perhaps something to improve:

Hi Emmanuel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on wireless-drivers/master mac80211-next/master mac80211/master linus/master v5.13-rc7 next-20210623] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/iwlwifi-mei-add-the-driver-to-allow-cooperation-with-CSME/20210623-221301
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: x86_64-randconfig-c022-20210622 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate

cocci warnings: (new ones prefixed by >>)

>> drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3131:2-3: Unneeded semicolon

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

[PATCH] iwlwifi: fix semicolon.cocci warnings

In reply to Emmanuel Grumbach
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3131:2-3: Unneeded semicolon

From: kernel test robot <[email protected]>

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3131:2-3: Unneeded semicolon

Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

---

url:    https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/iwlwifi-mei-add-the-driver-to-allow-cooperation-with-CSME/20210623-221301
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master

:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago

 mac80211.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 -1
@@ -3128,7 +3128,7 @@ static void iwl_mvm_mei_host_associated(
 	default:
 		/* cipher not supported, don't send anything to iwlmei */
 		return;
-	};
+	}
 
 	switch (mvmvif->rekey_data.akm) {
 	case WLAN_AKM_SUITE_SAE & 0xff:
#4 lore raw

PATCH v3 3/4 nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

In reply to Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

---
 include/uapi/linux/nl80211-vnd-intel.h | 80 ++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 include/uapi/linux/nl80211-vnd-intel.h
include/uapi/linux/nl80211-vnd-intel.h new file +80 -0
new file mode 100644
index 000000000000..d41c34b84f25
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
+ * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
+ * Copyright (C) 2016-2017 Intel Deutschland GmbH
+ */
+#ifndef __VENDOR_CMD_INTEL_H__
+#define __VENDOR_CMD_INTEL_H__
+
+#define INTEL_OUI	0x001735
+
+/**
+ * enum iwl_mvm_vendor_cmd - supported vendor commands
+ * @IWL_MVM_VENDOR_CMD_GET_CSME_CONN_INFO: reports CSME connection info.
+ * @IWL_MVM_VENDOR_CMD_HOST_GET_OWNERSHIP: asks for ownership on the device.
+ * @IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT: notifies if roaming is allowed.
+ *	It contains a &IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN and a
+ *	&IWL_MVM_VENDOR_ATTR_VIF_ADDR attributes.
+ */
+
+enum iwl_mvm_vendor_cmd {
+	IWL_MVM_VENDOR_CMD_GET_CSME_CONN_INFO			= 0x2d,
+	IWL_MVM_VENDOR_CMD_HOST_GET_OWNERSHIP			= 0x30,
+	IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT		= 0x32,
+};
+
+enum iwl_vendor_auth_akm_mode {
+	IWL_VENDOR_AUTH_OPEN,
+	IWL_VENDOR_AUTH_SHARED,
+	IWL_VENDOR_AUTH_WPA = 0x3,
+	IWL_VENDOR_AUTH_WPA_PSK,
+	IWL_VENDOR_AUTH_RSNA = 0x6,
+	IWL_VENDOR_AUTH_RSNA_PSK,
+	IWL_VENDOR_AUTH_SAE = 0x9,
+	IWL_VENDOR_AUTH_MAX,
+};
+
+/**
+ * enum iwl_mvm_vendor_attr - attributes used in vendor commands
+ * @__IWL_MVM_VENDOR_ATTR_INVALID: attribute 0 is invalid
+ * @IWL_MVM_VENDOR_ATTR_VIF_ADDR: interface MAC address
+ * @IWL_MVM_VENDOR_ATTR_ADDR: MAC address
+ * @IWL_MVM_VENDOR_ATTR_SSID: SSID (binary attribute, 0..32 octets)
+ * @IWL_MVM_VENDOR_ATTR_STA_CIPHER: the cipher to use for the station with the
+ *	mac address specified in &IWL_MVM_VENDOR_ATTR_ADDR.
+ * @IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN: u8 attribute. Indicates whether
+ *	roaming is forbidden or not. Value 1 means roaming is forbidden,
+ *	0 mean roaming is allowed.
+ * @IWL_MVM_VENDOR_ATTR_AUTH_MODE: u32 attribute. Authentication mode type
+ *	as specified in &enum iwl_vendor_auth_akm_mode.
+ * @IWL_MVM_VENDOR_ATTR_CHANNEL_NUM: u8 attribute. Contains channel number.
+ * @IWL_MVM_VENDOR_ATTR_BAND: u8 attribute.
+ *	0 for 2.4 GHz band, 1 for 5.2GHz band and 2 for 6GHz band.
+ * @IWL_MVM_VENDOR_ATTR_COLLOC_CHANNEL: u32 attribute. Channel number of
+ *	collocated AP. Relevant for 6GHz AP info.
+ * @IWL_MVM_VENDOR_ATTR_COLLOC_ADDR: MAC address of a collocated AP.
+ *	Relevant for 6GHz AP info.
+ *
+ * @NUM_IWL_MVM_VENDOR_ATTR: number of vendor attributes
+ * @MAX_IWL_MVM_VENDOR_ATTR: highest vendor attribute number
+
+ */
+enum iwl_mvm_vendor_attr {
+	__IWL_MVM_VENDOR_ATTR_INVALID				= 0x00,
+	IWL_MVM_VENDOR_ATTR_VIF_ADDR				= 0x02,
+	IWL_MVM_VENDOR_ATTR_ADDR				= 0x0a,
+	IWL_MVM_VENDOR_ATTR_SSID				= 0x3d,
+	IWL_MVM_VENDOR_ATTR_STA_CIPHER				= 0x51,
+	IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN			= 0x64,
+	IWL_MVM_VENDOR_ATTR_AUTH_MODE				= 0x65,
+	IWL_MVM_VENDOR_ATTR_CHANNEL_NUM				= 0x66,
+	IWL_MVM_VENDOR_ATTR_BAND				= 0x69,
+	IWL_MVM_VENDOR_ATTR_COLLOC_CHANNEL			= 0x70,
+	IWL_MVM_VENDOR_ATTR_COLLOC_ADDR				= 0x71,
+
+	NUM_IWL_MVM_VENDOR_ATTR,
+	MAX_IWL_MVM_VENDOR_ATTR = NUM_IWL_MVM_VENDOR_ATTR - 1,
+};
+
+#endif /* __VENDOR_CMD_INTEL_H__ */
Signature · 1 line
2.25.1
maintainer
#5 lore raw

Re: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

Quoted 12 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Quoted 4 lines

---
 include/uapi/linux/nl80211-vnd-intel.h | 80 ++++++++++++++++++++++++++

This was supposed to be submitted separately [1] so people see it more easily, so *bump* - everyone take a look please.

johannes

[1] https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#vendor-specific_api

Patches introducing such commands shall be submitted separately, not “buried” in big driver patchsets. Give them a “nl80211: vendor-cmd: ” prefix to make them easily identifiable.

Though I guess we can debate if this is a "big" patchset :)

#6 lore raw

Re: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

Quoted 24 lines · Johannes Berg
Quoted 12 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Quoted 4 lines
---
 include/uapi/linux/nl80211-vnd-intel.h | 80 ++++++++++++++++++++++++++

This was supposed to be submitted separately [1] so people see it more easily, so *bump* - everyone take a look please.

johannes

Quoted 8 lines

[1] https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#vendor-specific_api

Patches introducing such commands shall be submitted separately, not “buried” in big driver patchsets. Give them a “nl80211: vendor-cmd: ” prefix to make them easily identifiable.

Though I guess we can debate if this is a "big" patchset :)

Thanks Johannes.
I have a few typos in the commit message so that I can re-send this patch if needed.
In that case, I'd send it as a standalone patch. (Although it'd make the kernel build bots unhappy).

#7 lore raw

Re: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

In reply to Emmanuel Grumbach
Quoted 11 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Vendor command requirements are documented here:

https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#vendor-specific_api

The commit log is not really answering to those. For example, how a user would use this? Or is there a user space tool?

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#8 lore raw

Re: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

Quoted 15 lines · Kalle Valo
Quoted 11 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Quoted 6 lines

Vendor command requirements are documented here:

https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#vendor-specific_api

The commit log is not really answering to those. For example, how a user would use this? Or is there a user space tool?

We intend to send those command from the NetworkManager. I'll write a commit message that explains this better.
The gist of it is that the user space will see that the NIC is not owned by the host thanks to the new RFKILL reason that I added. Then, it can ask CSME what AP it is connected to, check if it has the a profile configure for that AP and connect to that same profile. I'll respin.

Quoted 5 lines

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

#9 lore raw

Re: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

Quoted 16 lines · Emmanuel Grumbach
Quoted 15 lines · Kalle Valo
Quoted 11 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Quoted 8 lines
Quoted 6 lines

Vendor command requirements are documented here:

https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#vendor-specific_api

The commit log is not really answering to those. For example, how a user would use this? Or is there a user space tool?

We intend to send those command from the NetworkManager.

I'm not really fond of the idea that NetworkManager uses nl80211 vendor commands, sounds quite hacky to me. I would prefer that NetworkManager uses generic nl80211 interface so that it works with every driver. But I need to look at v4 to understand more how this all works.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#10 lore raw

RE: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

Quoted 25 lines
Quoted 25 lines · Kalle Valo
Quoted 22 lines
Quoted 11 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Vendor command requirements are documented here:

https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#
vendor-specific_api

The commit log is not really answering to those. For example, how a user would use this? Or is there a user space tool?

Quoted 7 lines
Quoted 1 line

We intend to send those command from the NetworkManager.

I'm not really fond of the idea that NetworkManager uses nl80211 vendor commands, sounds quite hacky to me. I would prefer that NetworkManager uses generic nl80211 interface so that it works with every driver. But I need to look at v4 to understand more how this all works.

You'd need to look at v5 which I already sent.
Nothing of this can be generic, because it is really Intel proprietary. CSME can only use Intel devices by design. It uses a proprietary bus implemented only in Intel devices (and not even all of them, only the ones in systems with the vPRO sticker).
I already touched base with the NetworkManager's maintainers about this. They asked the vendor commands to be upstream in the kernel, so this is what I am doing.

#11 lore raw

Re: [PATCH v3 3/4] nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage

Quoted 33 lines · Emmanuel
Quoted 25 lines
Quoted 25 lines · Kalle Valo
Quoted 22 lines
Quoted 11 lines · Emmanuel Grumbach

iwlmei allows to integrate with the CSME firmware. There are flows that are prioprietary for this purpose:

* Get the information the AP, the CSME firmware is connected to. This is useful when we need to speed up the connection process in case the CSME firmware has an TCP connection that must be kept alive across the ownership transition.
* Forbid roaming, which will happen when the CSME firmware wants to tell the user space not disrupt the connection.
* Request ownership, upon driver boot when the CSME firmware owns the device.

Vendor command requirements are documented here:

https://wireless.wiki.kernel.org/en/developers/documentation/nl80211#
vendor-specific_api

The commit log is not really answering to those. For example, how a user would use this? Or is there a user space tool?

Quoted 7 lines
Quoted 1 line

We intend to send those command from the NetworkManager.

I'm not really fond of the idea that NetworkManager uses nl80211 vendor commands, sounds quite hacky to me. I would prefer that NetworkManager uses generic nl80211 interface so that it works with every driver. But I need to look at v4 to understand more how this all works.

Quoted 3 lines

You'd need to look at v5 which I already sent. Nothing of this can be generic, because it is really Intel proprietary.

Every company always says that their implemention is proprietary :) So that's not really a technical reason....

Quoted 3 lines

CSME can only use Intel devices by design. It uses a proprietary bus implemented only in Intel devices (and not even all of them, only the ones in systems with the vPRO sticker).

Ok, fair enough. I guess this is exotic enough that no other driver ever wants to implement, and I haven't seen any complaints either about this vendor interface. But please do include the justification for the vendor interface in the commit log as well.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#12 lore raw

PATCH v3 4/4 iwlwifi: mvm: add vendor commands needed for iwlmei

In reply to Emmanuel Grumbach

Add the vendor commands that must be used by the network manager to allow proper operation of iwlmei.

* Send information on the AP CSME is connected to
* Notify the userspace when roaming is forbidden
* Allow the userspace to require ownership

---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |  11 ++
 .../net/wireless/intel/iwlwifi/mvm/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   9 +-
 .../wireless/intel/iwlwifi/mvm/vendor-cmd.c   | 186 ++++++++++++++++++
 5 files changed, 203 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
drivers/net/wireless/intel/iwlwifi/Kconfig +11 -0
index 629aaa26a230..f91516d08b28 100644
@@ -92,11 +92,22 @@ config IWLWIFI_BCAST_FILTERING
 	  If unsure, don't enable this option, as some programs might
 	  expect incoming broadcasts for their normal operations.
 
+config IWLMVM_VENDOR_CMDS
+	bool "Enable vendor commands"
+	depends on IWLMVM
+	help
+	  This option enables support for vendor commands, including some
+	  that don't have their own Kconfig option. Other Kconfig options
+	  depend on this one as well.
+
+	  This is not enabled by default, if unsure, say N.
+
 config IWLMEI
 	tristate "Intel Management Engine communication over WLAN"
 	depends on INTEL_MEI
 	depends on PM
 	depends on IWLMVM
+	select IWLMVM_VENDOR_CMDS
 	help
 	  Enables the iwlmei kernel module. This allows to communicate with
 	  the Intel Management Engine over Wifi. This is supported starting
drivers/net/wireless/intel/iwlwifi/mvm/Makefile +1 -0
index 75fc2d935e5d..02078069d33d 100644
@@ -10,5 +10,6 @@ iwlmvm-y += rfi.o
 iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o
 iwlmvm-$(CONFIG_IWLWIFI_LEDS) += led.o
 iwlmvm-$(CONFIG_PM) += d3.o
+iwlmvm-$(CONFIG_IWLMVM_VENDOR_CMDS) += vendor-cmd.o
 
 ccflags-y += -I $(srctree)/$(src)/../
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +2 -0
index ec6916ba4982..80ab14cacc3c 100644
@@ -719,6 +719,8 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 		wiphy_ext_feature_set(hw->wiphy,
 				      NL80211_EXT_FEATURE_PROTECTED_TWT);
 
+	iwl_mvm_vendor_cmds_register(mvm);
+
 	hw->wiphy->available_antennas_tx = iwl_mvm_get_valid_tx_ant(mvm);
 	hw->wiphy->available_antennas_rx = iwl_mvm_get_valid_rx_ant(mvm);
 
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +3 -6
index 322e9dce7bb0..505cdfb4fcbd 100644
@@ -2212,11 +2212,8 @@ static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm, bool sw_
 		iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm), sw_rfkill);
 }
 
-static inline void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
-							struct ieee80211_vif *vif,
-							bool forbidden)
-{
-	/* TODO */
-}
+void iwl_mvm_send_roaming_forbidden_event(struct iwl_mvm *mvm,
+					  struct ieee80211_vif *vif,
+					  bool forbidden);
 
 #endif /* __IWL_MVM_H__ */
drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH v3 4/4] iwlwifi: mvm: add vendor commands needed for iwlmei

Quoted 25 lines · Emmanuel Grumbach

Add the vendor commands that must be used by the network manager to allow proper operation of iwlmei.

* Send information on the AP CSME is connected to
* Notify the userspace when roaming is forbidden
* Allow the userspace to require ownership

---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |  11 ++
 .../net/wireless/intel/iwlwifi/mvm/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   9 +-
 .../wireless/intel/iwlwifi/mvm/vendor-cmd.c   | 186 ++++++++++++++++++
 5 files changed, 203 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
index 629aaa26a230..f91516d08b28 100644
@@ -92,11 +92,22 @@ config IWLWIFI_BCAST_FILTERING
 	  If unsure, don't enable this option, as some programs might
 	  expect incoming broadcasts for their normal operations.

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 103

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +9 -0
 
+config IWLMVM_VENDOR_CMDS
+	bool "Enable vendor commands"
+	depends on IWLMVM
+	help
+	  This option enables support for vendor commands, including some
+	  that don't have their own Kconfig option. Other Kconfig options
+	  depend on this one as well.
+
+	  This is not enabled by default, if unsure, say N.

Why do we need a new Kconfig option? Why not always include it in the compilation?

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#14 lore raw

Re: [PATCH v3 4/4] iwlwifi: mvm: add vendor commands needed for iwlmei

Quoted 29 lines · Kalle Valo
Quoted 26 lines · Emmanuel Grumbach

Add the vendor commands that must be used by the network manager to allow proper operation of iwlmei.

* Send information on the AP CSME is connected to
* Notify the userspace when roaming is forbidden
* Allow the userspace to require ownership

---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |  11 ++
 .../net/wireless/intel/iwlwifi/mvm/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   9 +-
 .../wireless/intel/iwlwifi/mvm/vendor-cmd.c   | 186 ++++++++++++++++++
 5 files changed, 203 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
index 629aaa26a230..f91516d08b28 100644
@@ -92,11 +92,22 @@ config IWLWIFI_BCAST_FILTERING
        If unsure, don't enable this option, as some programs might
        expect incoming broadcasts for their normal operations.
 
Quoted 12 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 103

Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +9 -0
+config IWLMVM_VENDOR_CMDS
+     bool "Enable vendor commands"
+     depends on IWLMVM
+     help
+       This option enables support for vendor commands, including some
+       that don't have their own Kconfig option. Other Kconfig options
+       depend on this one as well.
+
+       This is not enabled by default, if unsure, say N.

Why do we need a new Kconfig option? Why not always include it in the compilation?

I expect 99.9% of the users to want to disable this.VENDOR_CMDS adds a user space API and in a sense, it increases the attack surface. You can claim that I can reuse the IWLMEI Kconfig option, which is true, but we have other features that need VENDOR_CMDS that are not (yet) upstream. So the idea here is that any feature that needs the VENDOR_CMDS will select it and if none of them are enabled (for 99.9% of the use cases), then, we would disable VENDOR_CMDS and decrease the attack surface.

Makes sense?

#15 lore raw

Re: [PATCH v3 4/4] iwlwifi: mvm: add vendor commands needed for iwlmei

Quoted 52 lines · Emmanuel Grumbach
Quoted 29 lines · Kalle Valo
Quoted 26 lines · Emmanuel Grumbach

Add the vendor commands that must be used by the network manager to allow proper operation of iwlmei.

* Send information on the AP CSME is connected to
* Notify the userspace when roaming is forbidden
* Allow the userspace to require ownership

---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |  11 ++
 .../net/wireless/intel/iwlwifi/mvm/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   9 +-
 .../wireless/intel/iwlwifi/mvm/vendor-cmd.c   | 186 ++++++++++++++++++
 5 files changed, 203 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
index 629aaa26a230..f91516d08b28 100644
@@ -92,11 +92,22 @@ config IWLWIFI_BCAST_FILTERING
        If unsure, don't enable this option, as some programs might
        expect incoming broadcasts for their normal operations.
 
Quoted 12 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 103

Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +9 -0
+config IWLMVM_VENDOR_CMDS
+     bool "Enable vendor commands"
+     depends on IWLMVM
+     help
+       This option enables support for vendor commands, including some
+       that don't have their own Kconfig option. Other Kconfig options
+       depend on this one as well.
+
+       This is not enabled by default, if unsure, say N.

Why do we need a new Kconfig option? Why not always include it in the compilation?

I expect 99.9% of the users to want to disable this.VENDOR_CMDS adds a user space API and in a sense, it increases the attack surface. You can claim that I can reuse the IWLMEI Kconfig option, which is true, but we have other features that need VENDOR_CMDS that are not (yet) upstream. So the idea here is that any feature that needs the VENDOR_CMDS will select it and if none of them are enabled (for 99.9% of the use cases), then, we would disable VENDOR_CMDS and decrease the attack surface.

Quoted 1 line

Makes sense?

How do you prevent users or distros from enabling the feature? They can be in a hurry, lazy or not caring and enable the feature anyway. So no, I'm not really buying this. If the interface is not secure it should not be in upstream, I think only exception to this is the nl80211 testmode interface which is for lab or similar use.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#16 lore raw

RE: [PATCH v3 4/4] iwlwifi: mvm: add vendor commands needed for iwlmei

Quoted 58 lines
Quoted 6 lines · Kalle Valo
Quoted 4 lines
Quoted 1 line · Emmanuel Grumbach

Add the vendor commands that must be used by the network manager

to

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

allow proper operation of iwlmei.

* Send information on the AP CSME is connected to
* Notify the userspace when roaming is forbidden
* Allow the userspace to require ownership

Signed-off-by Emmanuel Grumbach

<[email protected]>

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |  11 ++
 .../net/wireless/intel/iwlwifi/mvm/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   9 +-
 .../wireless/intel/iwlwifi/mvm/vendor-cmd.c   | 186

++++++++++++++++++

Quoted 25 lines
Quoted 12 lines
Quoted 12 lines
 5 files changed, 203 insertions(+), 6 deletions(-)  create mode

100644 drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c

drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
index 629aaa26a230..f91516d08b28 100644
@@ -92,11 +92,22 @@ config IWLWIFI_BCAST_FILTERING
        If unsure, don't enable this option, as some programs might
        expect incoming broadcasts for their normal operations.
 
Quoted 12 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 103

Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +9 -0
+config IWLMVM_VENDOR_CMDS
+     bool "Enable vendor commands"
+     depends on IWLMVM
+     help
+       This option enables support for vendor commands, including some
+       that don't have their own Kconfig option. Other Kconfig options
+       depend on this one as well.
+
+       This is not enabled by default, if unsure, say N.

Why do we need a new Kconfig option? Why not always include it in the compilation?

Quoted 7 lines

I expect 99.9% of the users to want to disable this.VENDOR_CMDS adds a user space API and in a sense, it increases the attack surface. You can claim that I can reuse the IWLMEI Kconfig option, which is true, but we have other features that need VENDOR_CMDS that are not (yet) upstream. So the idea here is that any feature that needs the VENDOR_CMDS will select it and if none of them are enabled (for 99.9% of the use cases), then, we would disable VENDOR_CMDS and decrease

the

Quoted 2 lines

attack surface.

Quoted 8 lines
Quoted 1 line

Makes sense?

How do you prevent users or distros from enabling the feature? They can be in a hurry, lazy or not caring and enable the feature anyway. So no, I'm not really buying this. If the interface is not secure it should not be in upstream, I think only exception to this is the nl80211 testmode interface which is for lab or similar use.

So what do you want?
To make it depend on IWLMEI Kconfig knob and not add the VENDOR_CMDS one? Fine.

#17 lore raw

Re: [PATCH v3 4/4] iwlwifi: mvm: add vendor commands needed for iwlmei

Quoted 67 lines · Emmanuel
Quoted 58 lines
Quoted 6 lines · Kalle Valo
Quoted 4 lines
Quoted 1 line · Emmanuel Grumbach

Add the vendor commands that must be used by the network manager

to

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

allow proper operation of iwlmei.

* Send information on the AP CSME is connected to
* Notify the userspace when roaming is forbidden
* Allow the userspace to require ownership

Signed-off-by Emmanuel Grumbach

<[email protected]>

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |  11 ++
 .../net/wireless/intel/iwlwifi/mvm/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   2 +
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   9 +-
 .../wireless/intel/iwlwifi/mvm/vendor-cmd.c   | 186

++++++++++++++++++

Quoted 25 lines
Quoted 12 lines
Quoted 12 lines
 5 files changed, 203 insertions(+), 6 deletions(-)  create mode

100644 drivers/net/wireless/intel/iwlwifi/mvm/vendor-cmd.c

drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
index 629aaa26a230..f91516d08b28 100644
@@ -92,11 +92,22 @@ config IWLWIFI_BCAST_FILTERING
        If unsure, don't enable this option, as some programs might
        expect incoming broadcasts for their normal operations.
 
Quoted 12 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 103

Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +9 -0
+config IWLMVM_VENDOR_CMDS
+     bool "Enable vendor commands"
+     depends on IWLMVM
+     help
+       This option enables support for vendor commands, including some
+       that don't have their own Kconfig option. Other Kconfig options
+       depend on this one as well.
+
+       This is not enabled by default, if unsure, say N.

Why do we need a new Kconfig option? Why not always include it in the compilation?

Quoted 7 lines

I expect 99.9% of the users to want to disable this.VENDOR_CMDS adds a user space API and in a sense, it increases the attack surface. You can claim that I can reuse the IWLMEI Kconfig option, which is true, but we have other features that need VENDOR_CMDS that are not (yet) upstream. So the idea here is that any feature that needs the VENDOR_CMDS will select it and if none of them are enabled (for 99.9% of the use cases), then, we would disable VENDOR_CMDS and decrease

the

Quoted 2 lines

attack surface.

Quoted 8 lines
Quoted 1 line

Makes sense?

How do you prevent users or distros from enabling the feature? They can be in a hurry, lazy or not caring and enable the feature anyway. So no, I'm not really buying this. If the interface is not secure it should not be in upstream, I think only exception to this is the nl80211 testmode interface which is for lab or similar use.

Quoted 2 lines

So what do you want? To make it depend on IWLMEI Kconfig knob and not add the VENDOR_CMDS one? Fine.

Yes, that sounds like a good idea. And I saw you did that already in v6.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#18 lore raw
In reply to Emmanuel Grumbach
Quoted 98 lines · Emmanuel Grumbach

CSME in two words
-----------------
CSME stands for Converged Security and Management Engine. It is a CPU on the chipset and runs a dedicated firmware.
AMT (Active Management Technology) is one of the applications that run on that CPU. AMT allows to control the platform remotely. Here is a partial list of the use cases:
* View the screen of the plaform, with keyboard and mouse (KVM)
* Attach a remote IDE device
* Have a serial console to the device
* Query the state of the platform
* Reset / shut down / boot the platform

Networking in CSME
------------------
For those uses cases, CSME's firmware has an embedded network stack and is able to use the network devices of the system: LAN and WLAN. This is thanks to the CSME's firmware WLAN driver.

One can add a profile (SSID / key / certificate) to the CSME's OS and CSME will connect to that profile. Then, one can use the WLAN link to access the applications that run on CSME (AMT is one of them). Note that CSME is active during power state and power state transitions. For example, it is possible to have a KVM session open to the system while the system is rebooting and actually configure the BIOS remotely over WLAN thanks to AMT.

How all this is related to Linux
--------------------------------
In Linux, there is a driver that allows the OS to talk to the CSME firmware, this driver is drivers/misc/mei. This driver advertises a bus that allows other kernel drivers or even user space) to talk to components inside the CSME firmware. In practice, the system advertises a PCI device that allows to send / receive data to / from the CSME firmware. The mei bus drivers in drivers/misc/mei is an abstration on top of this PCI device.
The driver being added here is called iwlmei and talks to the WLAN driver inside the CSME firmware through the mei bus driver. Note that the mei bus driver only gives bus services, it doesn't define the content of the communication.

Why do we need this driver?
--------------------------
CSME uses the same WLAN device that the OS is expecting to see hence we need an arbitration mechanism. This is what iwlmei is in charge of. iwlmei maintains the communication with the CSME firmware's WLAN driver. The language / protocol that is used between the CSME's firmware WLAN driver and iwlmei is OS agnostic and is called SAP which stands for Software Abritration Protocol. With SAP, iwlmei will be able to tell the CSME firmware's WLAN driver:
1) Please give me the device.
2) Please note that the SW/HW rfkill state change.
3) Please note that I am now associated to X.
4) Please note that I received this packet.
etc...

There are messages that go the opposite direction as well:
1) Please note that AMT is en/disable.
2) Please note that I believe the OS is broken and hence I'll take the device *now*, whether you like it or not, to make sure that connectivity is preserved.
3) Please note that I am willing to give the device if the OS needs it.
4) Please give me any packet that is sent on UDP / TCP on IP address XX.XX.XX.XX and an port ZZ.
5) Please send this packet.
etc...

Please check drivers/net/wireless/intel/iwlwifi/mei/sap.h for the full protocol specification.

Arbitration is not the only purpose of iwlmei and SAP. SAP also allows to maintain the AMT's functionality even when the OS owns the device. To connect to AMT, one needs to initiate an HTTP connection to port 16992. iwlmei will listen to the Rx path and forward (through SAP) to the CSME firmware the data it got. Then, the embedded HTTP server in the chipset will reply to the request and send a SAP notification to ask iwlmei to send the reply. This way, AMT running on the CSME can still work.

In practice this means that all the use cases quoted above (KVM, remote IDE device, etc...) will work even when the OS uses the WLAN device.

How to disable all this?
---------------------------
iwlmei won't be able to do anything if the CSME's networking stack is not enabled. By default, CSME's networking stack is disabled (this is a BIOS setting).
In case the CSME's networking stack is disabled, iwlwifi will just get access to the device because there is no contention with any other actor and, hence, no arbitration is needed.

In this patch, I only add the iwlmei driver. Integration with iwlwifi will be implemented in the next one.

Quoted 6 lines

---
v2: fix a few warnings raised by the different bots
v3: rewrite the commit message

Thank you for the great commit log, now I understand what this is about. I'm not able to do thorough review but my first quick comments.

[...]

Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7 -0
+	BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_OPEN !=
+		     (u32)SAP_WIFI_AUTH_TYPE_OPEN);
+	BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA !=
+		     (u32)SAP_WIFI_AUTH_TYPE_RSNA);
+	BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA_PSK !=
+		     (u32)SAP_WIFI_AUTH_TYPE_RSNA_PSK);
+	BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_SAE !=

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1379

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10 -0
+		     (u32)SAP_WIFI_AUTH_TYPE_SAE);
+
+	BUILD_BUG_ON((u32)IWL_MEI_CIPHER_NONE !=
+		     (u32)SAP_WIFI_CIPHER_ALG_NONE);
+	BUILD_BUG_ON((u32)IWL_MEI_CIPHER_CCMP !=
+		     (u32)SAP_WIFI_CIPHER_ALG_CCMP);
+	BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP !=
+		     (u32)SAP_WIFI_CIPHER_ALG_GCMP);
+	BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP_256 !=
+		     (u32)SAP_WIFI_CIPHER_ALG_GCMP_256);

These look just weird, and suspicious. You are using two different enums but they have to be same values, or what?

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6 -0
+static void iwl_mei_dbgfs_register(struct iwl_mei *mei)
+{
+	mei->dbgfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
+
+	if (!mei->dbgfs_dir)
+		return;

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1762

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10 -0
+
+	init_waitqueue_head(&mei->debugfs_wq);
+
+	debugfs_create_ulong("status", S_IRUSR,
+			     mei->dbgfs_dir, &iwl_mei_status);
+	debugfs_create_file("send_start_message", S_IWUSR, mei->dbgfs_dir,
+			    mei, &iwl_mei_dbgfs_send_start_message_ops);
+	debugfs_create_file("req_ownserhip", S_IWUSR, mei->dbgfs_dir,
+			    mei, &iwl_mei_dbgfs_req_ownership_ops);
+}

The commit log mentions nothing about debugfs interface. I recommend moving them to a separate patch for easier review and explaining what these do.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#19 lore raw
Quoted 108 lines · Kalle Valo
Quoted 98 lines · Emmanuel Grumbach

CSME in two words
-----------------
CSME stands for Converged Security and Management Engine. It is a CPU on the chipset and runs a dedicated firmware.
AMT (Active Management Technology) is one of the applications that run on that CPU. AMT allows to control the platform remotely. Here is a partial list of the use cases:
* View the screen of the plaform, with keyboard and mouse (KVM)
* Attach a remote IDE device
* Have a serial console to the device
* Query the state of the platform
* Reset / shut down / boot the platform

Networking in CSME
------------------
For those uses cases, CSME's firmware has an embedded network stack and is able to use the network devices of the system: LAN and WLAN. This is thanks to the CSME's firmware WLAN driver.

One can add a profile (SSID / key / certificate) to the CSME's OS and CSME will connect to that profile. Then, one can use the WLAN link to access the applications that run on CSME (AMT is one of them). Note that CSME is active during power state and power state transitions. For example, it is possible to have a KVM session open to the system while the system is rebooting and actually configure the BIOS remotely over WLAN thanks to AMT.

How all this is related to Linux
--------------------------------
In Linux, there is a driver that allows the OS to talk to the CSME firmware, this driver is drivers/misc/mei. This driver advertises a bus that allows other kernel drivers or even user space) to talk to components inside the CSME firmware. In practice, the system advertises a PCI device that allows to send / receive data to / from the CSME firmware. The mei bus drivers in drivers/misc/mei is an abstration on top of this PCI device.
The driver being added here is called iwlmei and talks to the WLAN driver inside the CSME firmware through the mei bus driver. Note that the mei bus driver only gives bus services, it doesn't define the content of the communication.

Why do we need this driver?
--------------------------
CSME uses the same WLAN device that the OS is expecting to see hence we need an arbitration mechanism. This is what iwlmei is in charge of. iwlmei maintains the communication with the CSME firmware's WLAN driver. The language / protocol that is used between the CSME's firmware WLAN driver and iwlmei is OS agnostic and is called SAP which stands for Software Abritration Protocol. With SAP, iwlmei will be able to tell the CSME firmware's WLAN driver:
1) Please give me the device.
2) Please note that the SW/HW rfkill state change.
3) Please note that I am now associated to X.
4) Please note that I received this packet.
etc...

There are messages that go the opposite direction as well:
1) Please note that AMT is en/disable.
2) Please note that I believe the OS is broken and hence I'll take the device *now*, whether you like it or not, to make sure that connectivity is preserved.
3) Please note that I am willing to give the device if the OS needs it.
4) Please give me any packet that is sent on UDP / TCP on IP address XX.XX.XX.XX and an port ZZ.
5) Please send this packet.
etc...

Please check drivers/net/wireless/intel/iwlwifi/mei/sap.h for the full protocol specification.

Arbitration is not the only purpose of iwlmei and SAP. SAP also allows to maintain the AMT's functionality even when the OS owns the device. To connect to AMT, one needs to initiate an HTTP connection to port 16992. iwlmei will listen to the Rx path and forward (through SAP) to the CSME firmware the data it got. Then, the embedded HTTP server in the chipset will reply to the request and send a SAP notification to ask iwlmei to send the reply. This way, AMT running on the CSME can still work.

In practice this means that all the use cases quoted above (KVM, remote IDE device, etc...) will work even when the OS uses the WLAN device.

How to disable all this?
---------------------------
iwlmei won't be able to do anything if the CSME's networking stack is not enabled. By default, CSME's networking stack is disabled (this is a BIOS setting).
In case the CSME's networking stack is disabled, iwlwifi will just get access to the device because there is no contention with any other actor and, hence, no arbitration is needed.

In this patch, I only add the iwlmei driver. Integration with iwlwifi will be implemented in the next one.

Quoted 6 lines

---
v2: fix a few warnings raised by the different bots
v3: rewrite the commit message

Quoted 2 lines

Thank you for the great commit log, now I understand what this is about. I'm not able to do thorough review but my first quick comments.

Glad it helped.

Quoted 22 lines

[...]

Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7 -0
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_OPEN !=
+                  (u32)SAP_WIFI_AUTH_TYPE_OPEN);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA_PSK !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA_PSK);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_SAE !=

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1379

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10 -0
+                  (u32)SAP_WIFI_AUTH_TYPE_SAE);
+
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_NONE !=
+                  (u32)SAP_WIFI_CIPHER_ALG_NONE);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_CCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_CCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP_256 !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP_256);
Quoted 2 lines

These look just weird, and suspicious. You are using two different enums but they have to be same values, or what?

Exactly. I don't want the userspace to have to include all the SAP protocol header file. OTOH, I don't want to have to translate between vendor commands attributes values and the SAP values. So I want them to be exactly the same. Note that the SAP values are not contiguous:
enum iwl_sap_wifi_cipher_alg {

        SAP_WIFI_CIPHER_ALG_NONE        = 0,
        SAP_WIFI_CIPHER_ALG_CCMP        = 4,
        SAP_WIFI_CIPHER_ALG_GCMP        = 8,
        SAP_WIFI_CIPHER_ALG_GCMP_256    = 9,

};

Hint, hint, there are ciphers that we don't want to support, like... WEP, TKIP and alike. There are also values here that are really surprising, but I didn't write the API... It is the CSME firmware's. Making sure that the vendor commands attributes values and the SAP values are the same here allows me to externalize only the vendor command attribute enumeratoin to the userspace and be safe that we won't need to translate any value before sending those through SAP.

Quoted 13 lines
Quoted 13 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +12 -0
+static void iwl_mei_dbgfs_register(struct iwl_mei *mei)
+{
+     mei->dbgfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
+
+     if (!mei->dbgfs_dir)
+             return;
+
+     init_waitqueue_head(&mei->debugfs_wq);
+
+     debugfs_create_ulong("status", S_IRUSR,
+                          mei->dbgfs_dir, &iwl_mei_status);
+     debugfs_create_file("send_start_message", S_IWUSR, mei->dbgfs_dir,
Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1762

Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +4 -0
+                         mei, &iwl_mei_dbgfs_send_start_message_ops);
+     debugfs_create_file("req_ownserhip", S_IWUSR, mei->dbgfs_dir,
+                         mei, &iwl_mei_dbgfs_req_ownership_ops);
+}

The commit log mentions nothing about debugfs interface. I recommend moving them to a separate patch for easier review and explaining what these do.

Doable I guess.
Next week.

#20 lore raw
Quoted 18 lines · Emmanuel Grumbach
Quoted 18 lines
Quoted 17 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +17 -0
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_OPEN !=
+                  (u32)SAP_WIFI_AUTH_TYPE_OPEN);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA_PSK !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA_PSK);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_SAE !=
+                  (u32)SAP_WIFI_AUTH_TYPE_SAE);
+
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_NONE !=
+                  (u32)SAP_WIFI_CIPHER_ALG_NONE);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_CCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_CCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP_256 !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP_256);
Quoted 6 lines
Quoted 2 lines

These look just weird, and suspicious. You are using two different enums but they have to be same values, or what?

Exactly. I don't want the userspace to have to include all the SAP protocol header file. OTOH, I don't want to have to translate between vendor commands attributes values and the SAP values.

Why not? I assume you would just need a helper function with switch statements to "translate" between enums, not much more lines of code but a lot cleaner code.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#21 lore raw
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7 -0
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_OPEN !=
+                  (u32)SAP_WIFI_AUTH_TYPE_OPEN);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA_PSK !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA_PSK);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_SAE !=

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1379

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10 -0
+                  (u32)SAP_WIFI_AUTH_TYPE_SAE);
+
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_NONE !=
+                  (u32)SAP_WIFI_CIPHER_ALG_NONE);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_CCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_CCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP_256 !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP_256);

These look just weird, and suspicious. You are using two different enums but they have to be same values, or what?

Quoted 8 lines
Quoted 3 lines

Exactly. I don't want the userspace to have to include all the SAP protocol header file. OTOH, I don't want to have to translate between vendor commands attributes values and the SAP values.

Why not? I assume you would just need a helper function with switch statements to "translate" between enums, not much more lines of code but a lot cleaner code.

I disagree that it'll give us a cleaner code.
What we'll have is two different enums with two different values and functions that translate from one value to another. This is very bug prone. When you want to debug, you get a value, you always need to think of what type of enum you're dealing with.
I believe your suggestion is not good, but since I am tired arguing I will do it to make you happy.

#22 lore raw
Quoted 31 lines · Emmanuel
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7 -0
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_OPEN !=
+                  (u32)SAP_WIFI_AUTH_TYPE_OPEN);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA_PSK !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA_PSK);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_SAE !=

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1379

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10 -0
+                  (u32)SAP_WIFI_AUTH_TYPE_SAE);
+
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_NONE !=
+                  (u32)SAP_WIFI_CIPHER_ALG_NONE);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_CCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_CCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP_256 !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP_256);

These look just weird, and suspicious. You are using two different enums but they have to be same values, or what?

Quoted 8 lines
Quoted 3 lines

Exactly. I don't want the userspace to have to include all the SAP protocol header file. OTOH, I don't want to have to translate between vendor commands attributes values and the SAP values.

Why not? I assume you would just need a helper function with switch statements to "translate" between enums, not much more lines of code but a lot cleaner code.

Quoted 7 lines

I disagree that it'll give us a cleaner code.
What we'll have is two different enums with two different values and functions that translate from one value to another. This is very bug prone. When you want to debug, you get a value, you always need to think of what type of enum you're dealing with.
I believe your suggestion is not good, but since I am tired arguing I will do it to make you happy.

I don't want to flare up this fire further, but have you considered to declare the enum values needed by user-space in uapi header and simply declare the SAP enum using those values:

#include <uapi/iwlmei.h>

enum sap_cipher {
SAP_WIFI_CIPHER_ALG_NONE = IWL_MEI_CIPHER_NONE, SAP_WIFI_CIPHER_ALG_CCMP = IWL_MEI_CIPHER_CCMP,
:
};

Seems like assurance enough that user-space api is cleanly separated and using the same values.

Regards,
Arend

Signature · 1 line
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
#23 lore raw
Quoted 51 lines · Emmanuel
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7 -0
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_OPEN !=
+                  (u32)SAP_WIFI_AUTH_TYPE_OPEN);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_RSNA_PSK !=
+                  (u32)SAP_WIFI_AUTH_TYPE_RSNA_PSK);
+     BUILD_BUG_ON((u32)IWL_MEI_AKM_AUTH_SAE !=

drivers/net/wireless/intel/iwlwifi/mei/main.c line 1379

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10 -0
+                  (u32)SAP_WIFI_AUTH_TYPE_SAE);
+
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_NONE !=
+                  (u32)SAP_WIFI_CIPHER_ALG_NONE);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_CCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_CCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP);
+     BUILD_BUG_ON((u32)IWL_MEI_CIPHER_GCMP_256 !=
+                  (u32)SAP_WIFI_CIPHER_ALG_GCMP_256);

These look just weird, and suspicious. You are using two different enums but they have to be same values, or what?

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Exactly. I don't want the userspace to have to include all the SAP protocol header file. OTOH, I don't want to have to translate between vendor commands attributes values and the SAP values.

Why not? I assume you would just need a helper function with switch statements to "translate" between enums, not much more lines of code

but

Quoted 5 lines
Quoted 2 lines

a lot cleaner code.

I disagree that it'll give us a cleaner code.
What we'll have is two different enums with two different values and

functions

Quoted 1 line

that translate from one value to another. This is very bug prone. When you

want

Quoted 1 line

to debug, you get a value, you always need to think of what type of enum

you're

Quoted 2 lines

dealing with.
I believe your suggestion is not good, but since I am tired arguing I will do it

to

Quoted 1 line

make you happy.

I don't want to flare up this fire further, but have you considered to declare the enum values needed by user-space in uapi header and simply declare the SAP enum using those values:

#include <uapi/iwlmei.h>

Quoted 9 lines

enum sap_cipher {
SAP_WIFI_CIPHER_ALG_NONE = IWL_MEI_CIPHER_NONE, SAP_WIFI_CIPHER_ALG_CCMP = IWL_MEI_CIPHER_CCMP,
:
};

Seems like assurance enough that user-space api is cleanly separated and using the same values.

Yeah, I'll take that option. Although it is weird to have the CSME firmware API values defined by the uapi, but I guess it is the best we can do here. I'll need to add a comment on the uapi to make sure that if anybody wants to add a value, he'll first check the CSME firmware value.

Thanks for the suggestion!

Kalle, anything else before I send v6?