Skip to contentSkip to conversation

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

PATCH Superseded Emmanuel Grumbach 6 participants 10 messages Jun 21, 2021 – Jun 24, 2021

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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

iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.

---
v2: fix a few warnings raised by the different bots

---
 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 v2 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.

---
v2: generate the HOST ASSOC / DISASSOC from the kernel
fix a few warnings raised by the different bots

---
 .../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 v2 2/4] iwlwifi: integrate with iwlmei

Thank you for the patch! Yet something to improve:

Hi Emmanuel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on wireless-drivers/master mac80211-next/master mac80211/master v5.13-rc7 next-20210618] [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/20210621-160318
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/6d71c3e1548b6ebe15ecb36efcbac1516d170f46
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Emmanuel-Grumbach/iwlwifi-mei-add-the-driver-to-allow-cooperation-with-CSME/20210621-160318 git checkout 6d71c3e1548b6ebe15ecb36efcbac1516d170f46
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64

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

All errors (new ones prefixed by >>):

drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c: In function 'iwl_parse_mei_nvm_data':

>> drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c:1117:2: error: too many arguments to function 'iwl_init_sbands'
    1117 |  iwl_init_sbands(trans, data, mei_nvm->channels, tx_chains, rx_chains,
         |  ^~~~~~~~~~~~~~~

drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c:797:13: note: declared here
797 | static void iwl_init_sbands(struct iwl_trans *trans,
| ^~~~~~~~~~~~~~~

vim +/iwl_init_sbands +1117 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c

1063
1064 struct iwl_nvm_data *
1065 iwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
1066 const struct iwl_mei_nvm *mei_nvm,
1067 const struct iwl_fw *fw)
1068 {
1069 struct iwl_nvm_data *data;
1070 u32 sbands_flags = 0;
1071 u8 rx_chains = fw->valid_rx_ant;
1072 u8 tx_chains = fw->valid_rx_ant;
1073
1074 if (cfg->uhb_supported)
1075 data = kzalloc(struct_size(data, channels,
1076 IWL_NVM_NUM_CHANNELS_UHB),
1077 GFP_KERNEL);
1078 else
1079 data = kzalloc(struct_size(data, channels,
1080 IWL_NVM_NUM_CHANNELS_EXT),
1081 GFP_KERNEL);
1082 if (!data)
1083 return NULL;
1084
1085 BUILD_BUG_ON(ARRAY_SIZE(mei_nvm->channels) !=
1086 IWL_NVM_NUM_CHANNELS_UHB);
1087 data->nvm_version = mei_nvm->nvm_version;
1088
1089 iwl_set_radio_cfg(cfg, data, mei_nvm->radio_cfg);
1090 if (data->valid_tx_ant)
1091 tx_chains &= data->valid_tx_ant;
1092 if (data->valid_rx_ant)
1093 rx_chains &= data->valid_rx_ant;
1094
1095 data->sku_cap_mimo_disabled = false;
1096 data->sku_cap_band_24ghz_enable = true;
1097 data->sku_cap_band_52ghz_enable = true;
1098 data->sku_cap_11n_enable =
1099 !(iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_ALL);
1100 data->sku_cap_11ac_enable = true;
1101 data->sku_cap_11ax_enable =
1102 mei_nvm->caps & MEI_NVM_CAPS_11AX_SUPPORT;
1103
1104 data->lar_enabled = mei_nvm->caps & MEI_NVM_CAPS_LARI_SUPPORT;
1105
1106 data->n_hw_addrs = mei_nvm->n_hw_addrs;
1107 /* If no valid mac address was found - bail out */
1108 if (iwl_set_hw_address(trans, cfg, data, NULL, NULL)) {
1109 kfree(data);
1110 return NULL;
1111 }
1112
1113 if (data->lar_enabled &&
1114 fw_has_capa(&fw->ucode_capa, IWL_UCODE_TLV_CAPA_LAR_SUPPORT))
1115 sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
1116

> 1117		iwl_init_sbands(trans, data, mei_nvm->channels, tx_chains, rx_chains,

1118 sbands_flags, true, fw);
1119
1120 return data;
1121 }
1122 IWL_EXPORT_SYMBOL(iwl_parse_mei_nvm_data);
1123

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

#3 lore raw

PATCH v2 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
#4 lore raw

PATCH v2 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
#5 lore raw
In reply to Emmanuel Grumbach
Quoted 7 lines · Emmanuel Grumbach

iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.

4 patches applied to iwlwifi-next.git, thanks.

f90c5b67155b iwlwifi: mei: add the driver to allow cooperation with CSME 1d29ed03260a iwlwifi: integrate with iwlmei
eb69dbb955ea nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage 25b74f1897c8 iwlwifi: mvm: add vendor commands needed for iwlmei

#6 lore raw
Quoted 10 lines · Luca Coelho
Quoted 7 lines · Emmanuel Grumbach

iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.

Quoted 6 lines

4 patches applied to iwlwifi-next.git, thanks.

f90c5b67155b iwlwifi: mei: add the driver to allow cooperation with CSME 1d29ed03260a iwlwifi: integrate with iwlmei
eb69dbb955ea nl80211: vendor-cmd: add Intel vendor commands for iwlmei usage 25b74f1897c8 iwlwifi: mvm: add vendor commands needed for iwlmei

For the record, I dropped this from this release on Kalle's request.

--
Cheers,
Luca.

#7 lore raw
In reply to Emmanuel Grumbach
Quoted 3 lines · Emmanuel Grumbach

iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.

A complicated new feature and just two sentences in the commit log? The commit log should give a proper overview what the patch does and why. This commit log really says to the reader "I don't care, find out yourself".

And being nice I did try to read few paragraphs from the patch but as I didn't even see any explanation for CSME or SAP I gave up.

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

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#8 lore raw
Quoted 7 lines · Kalle Valo
Quoted 3 lines · Emmanuel Grumbach

iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.

Quoted 8 lines

A complicated new feature and just two sentences in the commit log? The commit log should give a proper overview what the patch does and why. This commit log really says to the reader "I don't care, find out yourself".

And being nice I did try to read few paragraphs from the patch but as I didn't even see any explanation for CSME or SAP I gave up.

CSME stands for converged security and management engine. It is well known and has a driver in the kernel under drivers/misc/mei

CSME is a CPU inside the chipset that runs a firmware that is also able to control the WLAN device. iwlwifi needs to negotiate with the firmware that runs on the CSME to take the device. The language they talk is SAP which is just a command based protocol.
I can add that to the commit message.

Quoted 4 lines

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

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

#9 lore raw
Quoted 13 lines · Emmanuel Grumbach
Quoted 12 lines · Kalle Valo
Quoted 3 lines · Emmanuel Grumbach

iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.

A complicated new feature and just two sentences in the commit log? The commit log should give a proper overview what the patch does and why. This commit log really says to the reader "I don't care, find out yourself".

Quoted 6 lines
Quoted 3 lines

And being nice I did try to read few paragraphs from the patch but as I didn't even see any explanation for CSME or SAP I gave up.

CSME stands for converged security and management engine. It is well known and has a driver in the kernel under drivers/misc/mei

It maybe well known to you but it's not for me, and I'm pretty sure I'm not the only one. Remember that not everyone work for Intel and this is a community project, so please write commit logs accordingly.

But I see that you submitted v3, good. I'm reading that right now.

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

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