linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Arik Nemtsov <arik@wizery.com>,
	Matti Gottlieb <matti.gottlieb@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 09/49] iwlwifi: mvm: LAR: Add chub mcc change notify command
Date: Thu, 12 Mar 2015 15:03:54 +0200	[thread overview]
Message-ID: <1426165474-25586-9-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <1426164431.19690.4.camel@egrumbacBox>

From: Arik Nemtsov <arik@wizery.com>

Chub (Communication Hub, CommsHUB) is a HW component that connects to the cellular
and connectivity cores that gets updates of mcc changes, and then notifies the FW
directly of any mcc change.

The ucode notifies the driver (via this command) that it should ask for an mcc update,
and the driver sends the ucode the update mcc command to set the updated regulatory info.

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/fw-api.h   | 20 +++++++++++
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 56 +++++++++++++++++++++++++++++
 drivers/net/wireless/iwlwifi/mvm/mvm.h      |  7 ++++
 drivers/net/wireless/iwlwifi/mvm/nvm.c      | 26 +++++++++++++-
 drivers/net/wireless/iwlwifi/mvm/ops.c      |  1 +
 5 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
index 85afede..c4b59ec 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
@@ -214,6 +214,7 @@ enum {
 
 	/* Location Aware Regulatory */
 	MCC_UPDATE_CMD = 0xc8,
+	MCC_CHUB_UPDATE_CMD = 0xc9,
 
 	MARKER_CMD = 0xcb,
 
@@ -1715,6 +1716,25 @@ struct iwl_mcc_update_resp {
 	__le32 channels[0];
 } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S */
 
+/**
+ * struct iwl_mcc_chub_notif - chub notifies of mcc change
+ * (MCC_CHUB_UPDATE_CMD = 0xc9)
+ * The Chub (Communication Hub, CommsHUB) is a HW component that connects to
+ * the cellular and connectivity cores that gets updates of the mcc, and
+ * notifies the ucode directly of any mcc change.
+ * The ucode requests the driver to request the device to update geographic
+ * regulatory  profile according to the given MCC (Mobile Country Code).
+ * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
+ * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
+ * MCC in the cmd response will be the relevant MCC in the NVM.
+ * @mcc: given mobile country code
+ * @reserved: reserved for alignment
+ */
+struct iwl_mcc_chub_notif {
+	u16 mcc;
+	u16 reserved1;
+} __packed; /* LAR_MCC_NOTIFY_S */
+
 enum iwl_mcc_update_status {
 	MCC_RESP_NEW_CHAN_PROFILE,
 	MCC_RESP_SAME_CHAN_PROFILE,
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 2042554..0da8787 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -86,6 +86,7 @@
 #include "iwl-fw-error-dump.h"
 #include "iwl-prph.h"
 #include "iwl-csr.h"
+#include "iwl-nvm-parse.h"
 
 static const struct ieee80211_iface_limit iwl_mvm_limits[] = {
 	{
@@ -301,6 +302,49 @@ static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm)
 	}
 }
 
+struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
+						  const char *alpha2)
+{
+	struct ieee80211_regdomain *regd = NULL;
+	struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
+	struct iwl_mcc_update_resp *resp;
+
+	IWL_DEBUG_LAR(mvm, "Getting regdomain data for %s from FW\n", alpha2);
+
+	mutex_lock(&mvm->mutex);
+
+	/* change "99" to "ZZ" for the FW */
+	if (alpha2[0] == '9' && alpha2[1] == '9')
+		alpha2 = "ZZ";
+
+	resp = iwl_mvm_update_mcc(mvm, alpha2);
+	if (IS_ERR_OR_NULL(resp)) {
+		IWL_DEBUG_LAR(mvm, "Could not get update from FW %d\n",
+			      PTR_RET(resp));
+		goto out_unlock;
+	}
+
+	regd = iwl_parse_nvm_mcc_info(mvm->trans->dev,
+				      __le32_to_cpu(resp->n_channels),
+				      resp->channels,
+				      __le16_to_cpu(resp->mcc));
+	kfree(resp);
+	if (IS_ERR_OR_NULL(regd)) {
+		IWL_DEBUG_LAR(mvm, "Could not get parse update from FW %d\n",
+			      PTR_RET(resp));
+		goto out_unlock;
+	}
+
+	IWL_DEBUG_LAR(mvm, "setting alpha2 from FW to %s (0x%x, 0x%x)\n",
+		      regd->alpha2, regd->alpha2[0], regd->alpha2[1]);
+	mvm->lar_regdom_set = true;
+
+out_unlock:
+	mutex_unlock(&mvm->mutex);
+	return regd;
+}
+
 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 {
 	struct ieee80211_hw *hw = mvm->hw;
@@ -2245,6 +2289,12 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 
 	mutex_lock(&mvm->mutex);
 
+	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
+		IWL_ERR(mvm, "scan while LAR regdomain is not set\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
 	if (mvm->scan_status != IWL_MVM_SCAN_NONE) {
 		ret = -EBUSY;
 		goto out;
@@ -2583,6 +2633,12 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 
 	mutex_lock(&mvm->mutex);
 
+	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
+		IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n");
+		ret = -EBUSY;
+		goto out;
+	}
+
 	if (!vif->bss_conf.idle) {
 		ret = -EBUSY;
 		goto out;
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index b31f43c..df5a228 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -810,6 +810,8 @@ struct iwl_mvm {
 	/* system time of last beacon (for AP/GO interface) */
 	u32 ap_last_beacon_gp2;
 
+	bool lar_regdom_set;
+
 	u8 low_latency_agg_frame_limit;
 
 	/* TDLS channel switch data */
@@ -1398,6 +1400,11 @@ int iwl_mvm_get_temp(struct iwl_mvm *mvm);
 struct iwl_mcc_update_resp *
 iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2);
 int iwl_mvm_init_mcc(struct iwl_mvm *mvm);
+int iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
+			       struct iwl_rx_cmd_buffer *rxb,
+			       struct iwl_device_cmd *cmd);
+struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
+						  const char *alpha2);
 
 /* smart fifo */
 int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
diff --git a/drivers/net/wireless/iwlwifi/mvm/nvm.c b/drivers/net/wireless/iwlwifi/mvm/nvm.c
index 907e231..b88b4cd 100644
--- a/drivers/net/wireless/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/iwlwifi/mvm/nvm.c
@@ -689,6 +689,30 @@ int iwl_mvm_init_mcc(struct iwl_mvm *mvm)
 	 * unknown-country "99" code. This will also clear the "custom reg"
 	 * flag and allow regdomain changes. It will happen after init since
 	 * RTNL is required.
+	 * Disallow scans that might crash the FW while the LAR regdomain
+	 * is not set.
 	 */
-	return regulatory_hint(mvm->hw->wiphy, "99");
+	mvm->lar_regdom_set = false;
+	return 0;
+}
+
+int iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
+			       struct iwl_rx_cmd_buffer *rxb,
+			       struct iwl_device_cmd *cmd)
+{
+	struct iwl_rx_packet *pkt = rxb_addr(rxb);
+	struct iwl_mcc_chub_notif *notif = (void *)pkt->data;
+	char mcc[3];
+
+	if (WARN_ON_ONCE(!iwl_mvm_is_lar_supported(mvm)))
+		return -EOPNOTSUPP;
+
+	mcc[0] = notif->mcc >> 8;
+	mcc[1] = notif->mcc & 0xff;
+	mcc[2] = '\0';
+
+	IWL_DEBUG_LAR(mvm,
+		      "RX: received chub update mcc command (mcc 0x%x '%s')\n",
+		      notif->mcc, mcc);
+	return 0;
 }
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index 72b8e19..1072f45 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -234,6 +234,7 @@ static const struct iwl_rx_handlers iwl_mvm_rx_handlers[] = {
 		   iwl_mvm_rx_ant_coupling_notif, true),
 
 	RX_HANDLER(TIME_EVENT_NOTIFICATION, iwl_mvm_rx_time_event_notif, false),
+	RX_HANDLER(MCC_CHUB_UPDATE_CMD, iwl_mvm_rx_chub_update_mcc, false),
 
 	RX_HANDLER(EOSP_NOTIFICATION, iwl_mvm_rx_eosp_notif, false),
 
-- 
1.9.1


  parent reply	other threads:[~2015-03-12 13:05 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 12:47 pull request: iwlwifi-next 2013-03-12 Grumbach, Emmanuel
2015-03-12 13:03 ` [PATCH 01/49] iwlwifi: mvm: fix compilation with IWLWIFI_DEBUGFS not set Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 02/49] iwlwifi: fix max_ht_ampdu_exponent for older devices Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 03/49] iwlwifi: mvm: add MCC update FW API Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 04/49] iwlwifi: mvm: init country code on init/recovery Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 05/49] iwlwifi: create regdomain from mcc_update_cmd response Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 06/49] iwlwifi: mvm: consider LAR support during NVM parse Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 07/49] iwlwifi: ignore IBSS flag as regulatory NO-IR indication Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 08/49] iwlwifi: don't declare support for 5ghz if not supported Emmanuel Grumbach
2015-03-12 13:03 ` Emmanuel Grumbach [this message]
2015-03-12 13:03 ` [PATCH 10/49] iwlwifi: nvm: init correct nvm channel list for 8000 devices Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 11/49] iwlwifi: change last 5ghz channel to 165 & add support for 8000 family Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 12/49] iwlwifi: use IWL_DEFAULT_MAX_TX_POWER for max_eirp Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 13/49] iwlwifi: iwlmvm: LAR: disable LAR support due to NVM vs TLV conflict Emmanuel Grumbach
2015-03-12 13:03 ` [PATCH 14/49] iwlwifi: disable 11ac if 11n is disabled Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 15/49] iwlwifi: mvm: support new PHY_SKU nvm section for family 8000 B0 Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 16/49] iwlwifi: allow disabling LAR via module param Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 17/49] iwlwifi: mvm: take the MAC address from HW registers Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 18/49] iwlwifi: mvm: support LAR updates from BIOS Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 19/49] iwlwifi: mvm: set LAR MCC on D3/D0 transitions Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 20/49] iwlwifi: bump API to 13 for devices that use iwlmvm Emmanuel Grumbach
2015-05-06  9:14   ` Santiago Gala
2015-03-12 13:04 ` [PATCH 21/49] iwlwifi: mvm: remove IWL_UCODE_TLV_API_DISABLE_STA_TX Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 22/49] iwlwifi: mvm: remove IWL_UCODE_TLV_API_SF_NO_DUMMY_NOTIF Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 23/49] iwlwifi: mvm: BT Coex - disable RRC by default Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 24/49] iwlwifi: mvm: always update the quota after association Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 25/49] iwlwifi: mvm: support family 8000 B2/C steps Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 26/49] iwlwifi: pcie: speed up the Tx DMA stop flow Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 27/49] iwlwifi: pcie: include more registers in the prph dump Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 28/49] iwlwifi: fix smatch warning: warn: inconsistent indenting Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 29/49] iwlwifi: use correct NVM offset for LAR enable for new NVMs Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 30/49] iwlwifi: mvm: remove unneeded include iwl-fw-error-dump.h Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 31/49] iwlwifi: mvm: fix identation Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 32/49] iwlwifi: mvm: reflect TDLS pm state in mvmvif->pm_enabled Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 33/49] iwlwifi: don't allow the FW to return invalid ch indices Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 34/49] iwlwifi: mvm: rs: improve ss_params debug print Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 35/49] iwlwifi: add new 8260 series PCI IDs Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 36/49] iwlwifi: trans: Take ownership on secure machine before FW load Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 37/49] iwlwifi: mvm: remove warning on station exhaustion Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 38/49] iwlwifi: mvm: don't init MCC during CT-kill Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 39/49] iwlwifi: mvm: rs: update Tx statistics when using fixed rate Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 40/49] iwlwifi: pcie: allow the op_mode to freeze the stuck queue timer Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 41/49] iwlwifi: mvm: freeze the non-shared queues when a station goes to sleep Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 42/49] iwlwifi: mvm: fix force NMI for 8000 Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 43/49] iwlwifi: mvm: BT Coex - update the new API Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 44/49] iwlwifi: add more new 8260 series PCI IDs Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 45/49] iwlwifi: update copyright to include 2015 Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 46/49] iwlwifi: mvm: Always enable the smart FIFO Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 47/49] iwlwifi: mvm: clarify time event end handling Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 48/49] iwlwifi: mvm: don't double unlock the mutex in __iwl_mvm_resume() Emmanuel Grumbach
2015-03-12 13:04 ` [PATCH 49/49] iwlwifi: mvm: simplify iwl_mvm_get_wakeup_status() return Emmanuel Grumbach
2015-03-13 13:10 ` pull request: iwlwifi-next 2013-03-12 Kalle Valo

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1426165474-25586-9-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=arik@wizery.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=matti.gottlieb@intel.com \
    /path/to/YOUR_REPLY

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

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