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: Sara Sharon <sara.sharon@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 21/45] iwlwifi: mvm: change protocol offload flows
Date: Mon, 21 Dec 2015 22:50:22 +0200	[thread overview]
Message-ID: <1450731046-2796-21-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <0BA3FCBA62E2DC44AF3030971E174FB32E949792@hasmsx107.ger.corp.intel.com>

From: Sara Sharon <sara.sharon@intel.com>

RFC4862 states that "In all cases, a node MUST NOT respond to
a Neighbor Solicitation for a tentative address".
Currently the driver configures the NS offload and does not wait
for address to become permanent, thus violating the RFC.
Just removing the address from the address list is not good enough
for all cases, since the NS messages are needed for the duplicate
address detection and should not be discarded.

For d0i3 disable NS offload. Put tentative address in the address
list so the NS packet will not be filtered out by ucode.
For D3 the platform will not wake from NS packets - so enable
NS offload while removing the tentative address from the list.

Given that now NS offload might be disabled, and that the ucode
uses the IP data for other puroposes (L3 filtering) add two
independent flags indicating if IPv4\IPv6 data is valid.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c        |  6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h |  4 ++
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h       |  2 +
 .../net/wireless/intel/iwlwifi/mvm/offloading.c    | 74 ++++++++++++++++------
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c       |  3 +-
 5 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index b1c9992..8824a89 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -104,9 +104,13 @@ void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
 	struct inet6_ifaddr *ifa;
 	int idx = 0;
 
+	memset(mvmvif->tentative_addrs, 0, sizeof(mvmvif->tentative_addrs));
+
 	read_lock_bh(&idev->lock);
 	list_for_each_entry(ifa, &idev->addr_list, if_list) {
 		mvmvif->target_ipv6_addrs[idx] = ifa->addr;
+		if (ifa->flags & IFA_F_TENTATIVE)
+			__set_bit(idx, mvmvif->tentative_addrs);
 		idx++;
 		if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)
 			break;
@@ -964,7 +968,7 @@ iwl_mvm_wowlan_config(struct iwl_mvm *mvm,
 	if (ret)
 		return ret;
 
-	ret = iwl_mvm_send_proto_offload(mvm, vif, false, 0);
+	ret = iwl_mvm_send_proto_offload(mvm, vif, false, true, 0);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
index 228684c..c36c956 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw-api-d3.h
@@ -94,10 +94,14 @@ struct iwl_d3_manager_config {
  * enum iwl_d3_proto_offloads - enabled protocol offloads
  * @IWL_D3_PROTO_OFFLOAD_ARP: ARP data is enabled
  * @IWL_D3_PROTO_OFFLOAD_NS: NS (Neighbor Solicitation) is enabled
+ * @IWL_D3_PROTO_IPV4_VALID: IPv4 data is valid
+ * @IWL_D3_PROTO_IPV6_VALID: IPv6 data is valid
  */
 enum iwl_proto_offloads {
 	IWL_D3_PROTO_OFFLOAD_ARP = BIT(0),
 	IWL_D3_PROTO_OFFLOAD_NS = BIT(1),
+	IWL_D3_PROTO_IPV4_VALID = BIT(2),
+	IWL_D3_PROTO_IPV6_VALID = BIT(3),
 };
 
 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1	2
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 3fc7199..d8760fa 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -422,6 +422,7 @@ struct iwl_mvm_vif {
 #if IS_ENABLED(CONFIG_IPV6)
 	/* IPv6 addresses for WoWLAN */
 	struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
+	unsigned long tentative_addrs[BITS_TO_LONGS(IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)];
 	int num_target_ipv6_addrs;
 #endif
 
@@ -1299,6 +1300,7 @@ void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
 int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 			       struct ieee80211_vif *vif,
 			       bool disable_offloading,
+			       bool offload_ns,
 			       u32 cmd_flags);
 
 /* D0i3 */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/offloading.c b/drivers/net/wireless/intel/iwlwifi/mvm/offloading.c
index f83e2bc..6338d9c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/offloading.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/offloading.c
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -33,6 +34,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -64,6 +66,7 @@
  *****************************************************************************/
 #include <net/ipv6.h>
 #include <net/addrconf.h>
+#include <linux/bitops.h>
 #include "mvm.h"
 
 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
@@ -86,6 +89,7 @@ void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
 int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 			       struct ieee80211_vif *vif,
 			       bool disable_offloading,
+			       bool offload_ns,
 			       u32 cmd_flags)
 {
 	union {
@@ -106,6 +110,13 @@ int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 #if IS_ENABLED(CONFIG_IPV6)
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	int i;
+	/*
+	 * Skip tentative address when ns offload is enabled to avoid
+	 * violating RFC4862.
+	 * Keep tentative address when ns offload is disabled so the NS packets
+	 * will not be filtered out and will wake up the host.
+	 */
+	bool skip_tentative = offload_ns;
 
 	if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL ||
 	    capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
@@ -113,6 +124,7 @@ int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 		struct iwl_targ_addr *addrs;
 		int n_nsc, n_addrs;
 		int c;
+		int num_skipped = 0;
 
 		if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
 			nsc = cmd.v3s.ns_config;
@@ -126,9 +138,6 @@ int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 			n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L;
 		}
 
-		if (mvmvif->num_target_ipv6_addrs)
-			enabled |= IWL_D3_PROTO_OFFLOAD_NS;
-
 		/*
 		 * For each address we have (and that will fit) fill a target
 		 * address struct and combine for NS offload structs with the
@@ -140,6 +149,12 @@ int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 			struct in6_addr solicited_addr;
 			int j;
 
+			if (skip_tentative &&
+			    test_bit(i, mvmvif->tentative_addrs)) {
+				num_skipped++;
+				continue;
+			}
+
 			addrconf_addr_solict_mult(&mvmvif->target_ipv6_addrs[i],
 						  &solicited_addr);
 			for (j = 0; j < c; j++)
@@ -154,41 +169,64 @@ int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 			memcpy(nsc[j].target_mac_addr, vif->addr, ETH_ALEN);
 		}
 
+		if (mvmvif->num_target_ipv6_addrs - num_skipped)
+			enabled |= IWL_D3_PROTO_IPV6_VALID;
+
 		if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL)
-			cmd.v3s.num_valid_ipv6_addrs = cpu_to_le32(i);
+			cmd.v3s.num_valid_ipv6_addrs =
+				cpu_to_le32(i - num_skipped);
 		else
-			cmd.v3l.num_valid_ipv6_addrs = cpu_to_le32(i);
+			cmd.v3l.num_valid_ipv6_addrs =
+				cpu_to_le32(i - num_skipped);
 	} else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
-		if (mvmvif->num_target_ipv6_addrs) {
-			enabled |= IWL_D3_PROTO_OFFLOAD_NS;
-			memcpy(cmd.v2.ndp_mac_addr, vif->addr, ETH_ALEN);
-		}
+		bool found = false;
 
 		BUILD_BUG_ON(sizeof(cmd.v2.target_ipv6_addr[0]) !=
 			     sizeof(mvmvif->target_ipv6_addrs[0]));
 
 		for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
-				    IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2); i++)
+				    IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2); i++) {
+			if (skip_tentative &&
+			    test_bit(i, mvmvif->tentative_addrs))
+				continue;
+
 			memcpy(cmd.v2.target_ipv6_addr[i],
 			       &mvmvif->target_ipv6_addrs[i],
 			       sizeof(cmd.v2.target_ipv6_addr[i]));
-	} else {
-		if (mvmvif->num_target_ipv6_addrs) {
-			enabled |= IWL_D3_PROTO_OFFLOAD_NS;
-			memcpy(cmd.v1.ndp_mac_addr, vif->addr, ETH_ALEN);
-		}
 
+			found = true;
+		}
+		if (found) {
+			enabled |= IWL_D3_PROTO_IPV6_VALID;
+			memcpy(cmd.v2.ndp_mac_addr, vif->addr, ETH_ALEN);
+		}
+	} else {
+		bool found = false;
 		BUILD_BUG_ON(sizeof(cmd.v1.target_ipv6_addr[0]) !=
 			     sizeof(mvmvif->target_ipv6_addrs[0]));
 
 		for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
-				    IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1); i++)
+				    IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1); i++) {
+			if (skip_tentative &&
+			    test_bit(i, mvmvif->tentative_addrs))
+				continue;
+
 			memcpy(cmd.v1.target_ipv6_addr[i],
 			       &mvmvif->target_ipv6_addrs[i],
 			       sizeof(cmd.v1.target_ipv6_addr[i]));
+
+			found = true;
+		}
+
+		if (found) {
+			enabled |= IWL_D3_PROTO_IPV6_VALID;
+			memcpy(cmd.v1.ndp_mac_addr, vif->addr, ETH_ALEN);
+		}
 	}
-#endif
 
+	if (offload_ns && (enabled & IWL_D3_PROTO_IPV6_VALID))
+		enabled |= IWL_D3_PROTO_OFFLOAD_NS;
+#endif
 	if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
 		common = &cmd.v3s.common;
 		size = sizeof(cmd.v3s);
@@ -204,7 +242,7 @@ int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
 	}
 
 	if (vif->bss_conf.arp_addr_cnt) {
-		enabled |= IWL_D3_PROTO_OFFLOAD_ARP;
+		enabled |= IWL_D3_PROTO_OFFLOAD_ARP | IWL_D3_PROTO_IPV4_VALID;
 		common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0];
 		memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN);
 	}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 31c16a1..4753ecd 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -1153,7 +1153,8 @@ static void iwl_mvm_enter_d0i3_iterator(void *_data, u8 *mac,
 		data->disable_offloading = true;
 
 	iwl_mvm_update_d0i3_power_mode(mvm, vif, true, flags);
-	iwl_mvm_send_proto_offload(mvm, vif, data->disable_offloading, flags);
+	iwl_mvm_send_proto_offload(mvm, vif, data->disable_offloading,
+				   false, flags);
 
 	/*
 	 * on init/association, mvm already configures POWER_TABLE_CMD
-- 
2.5.0


  parent reply	other threads:[~2015-12-21 20:51 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-21 20:48 pull request: iwlwifi-next-2015-12-21 Grumbach, Emmanuel
2015-12-21 20:50 ` [PATCH 01/45] iwlwifi: mvm: don't keep an mvm ref when the interface is down Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 02/45] iwlwifi: mvm: add an option to start rs from HT/VHT rates Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 03/45] iwlwifi: mvm: set default new STA as non-aggregated Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 04/45] iwlwifi: mvm: configure scheduled scan according to traffic conditions Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 05/45] iwlwifi: mvm: rs: fix a potential out of bounds access Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 06/45] iwlwifi: mvm: advertise NETIF_F_SG Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 07/45] iwlwifi: dvm: " Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 08/45] iwlwifi: mvm: remove an extra tab Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 09/45] iwlwifi: mvm: cleanup roc te on restart cleanup Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 10/45] iwlwifi: mvm: check iwl_mvm_wowlan_config_key_params() return value Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 11/45] iwlwifi: pcie: allow the op_mode to block the tx queues Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 12/45] iwlwifi: trans: support a callback for ASYNC commands Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 13/45] iwlwifi: block the queues when we send ADD_STA for uAPSD Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 14/45] iwlwifi: uninline iwl_trans_send_cmd Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 15/45] iwlwifi: update host command messages to new format Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 16/45] iwlwifi: mvm: close the SP if we send fewer frames than expected in SP Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 17/45] iwlwifi: avoid d0i3 commands when no/init ucode is loaded Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 18/45] iwlwifi: mvm: remove the vif parameter of iwl_mvm_configure_bcast_filter() Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 19/45] iwlwifi: replace d0i3_mode and wowlan_d0i3 with more generic variables Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 20/45] iwlwifi: expose fw usniffer mode to more utilities Emmanuel Grumbach
2015-12-21 20:50 ` Emmanuel Grumbach [this message]
2015-12-21 20:50 ` [PATCH 22/45] iwlwifi: dvm: fix compare_const_fl.cocci warnings Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 23/45] iwlwifi: change the Intel Wireless email address Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 24/45] iwlwifi: pcie: allow to pretend to have Tx CSUM for debug Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 25/45] iwlwifi: mvm: prepare the code towards TSO implementation Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 26/45] iwlwifi: pcie: re-organize code towards TSO Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 27/45] iwlwifi: clear ieee80211_tx_info->driver_data in the op_mode Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 28/45] iwlwifi: pcie: build an A-MSDU using TSO core Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 29/45] iwlwifi: 9000: increase the number of queues Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 30/45] iwlwifi: mvm: refactor the way fw_key_table is handled Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 31/45] iwlwifi: mvm: enable L3 filtering Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 32/45] iwlwifi: mvm: support description for user triggered fw dbg collection Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 33/45] iwlwifi: mvm: small update in the firmware API Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 34/45] iwlwifi: mvm: add extended dwell time Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 35/45] iwlwifi: mvm: Add a station in monitor mode Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 36/45] iwlwifi: mvm: change iwl_mvm_get_key_sta_id() to return the station Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 37/45] iwlwifi: mvm: add 9000 series RX processing Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 38/45] iwlwifi: mvm: infrastructure for frame-release message Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 39/45] iwlwifi: mvm: dump more registers upon error Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 40/45] iwlwifi: Update PCI IDs for 8000 and 9000 series Emmanuel Grumbach
2015-12-29 16:06   ` Kalle Valo
2015-12-21 20:50 ` [PATCH 41/45] iwlwifi: mvm: Change number of associated stations when station becomes associated Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 42/45] iwlwifi: update key params on d0i3 entrance/exit Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 43/45] iwlwifi: remove unused parameter from grab_nic_access Emmanuel Grumbach
2015-12-21 20:50 ` [PATCH 44/45] iwlwifi: fix printf specifier Emmanuel Grumbach
2015-12-23  4:08   ` Joe Perches
2015-12-23  6:28     ` Grumbach, Emmanuel
2015-12-21 20:50 ` [PATCH 45/45] iwlwifi: bail out in case of bad trans state Emmanuel Grumbach
2015-12-21 20:54 ` pull request: iwlwifi-next-2015-12-21 Grumbach, Emmanuel
2015-12-29 16:47 ` 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=1450731046-2796-21-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=sara.sharon@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).