iwlwifi: mvm: configure seq_num to D0i3
authorEliad Peller <eliad@wizery.com>
Thu, 21 Nov 2013 17:19:52 +0000 (19:19 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Sun, 16 Mar 2014 11:45:23 +0000 (13:45 +0200)
Configure the QoS counters when entering D0i3.

The fw might use them later when performing protocol
offloading (we'll update the the counters back on
d0i3 exit in a following patch).

Non-QoS counter is handled internally in the fw, so
no need to configure it.

Also, add support for a new version of WOWLAN_CONFIG_CMD

Signed-off-by: Eliad Peller <eliad@wizery.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/iwlwifi/iwl-fw.h
drivers/net/wireless/iwlwifi/mvm/Makefile
drivers/net/wireless/iwlwifi/mvm/d3.c
drivers/net/wireless/iwlwifi/mvm/fw-api-d3.h
drivers/net/wireless/iwlwifi/mvm/mvm.h
drivers/net/wireless/iwlwifi/mvm/offloading.c [new file with mode: 0644]
drivers/net/wireless/iwlwifi/mvm/ops.c

index 18f867c4df555c642113f0b2264244d9ad709cf9..d14f19339d6140607c99d1b6660b039f9ac4aa66 100644 (file)
@@ -125,6 +125,14 @@ enum iwl_ucode_tlv_flag {
        IWL_UCODE_TLV_FLAGS_GO_UAPSD            = BIT(30),
 };
 
+/**
+ * enum iwl_ucode_tlv_api - ucode api
+ * @IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID: wowlan config includes tid field.
+ */
+enum iwl_ucode_tlv_api {
+       IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID     = BIT(0),
+};
+
 /**
  * enum iwl_ucode_tlv_capa - ucode capabilities
  * @IWL_UCODE_TLV_CAPA_D0I3_SUPPORT: supports D0i3
index 9798aa5b76458a9c9bdffaa12b2f55f93fca1cee..ccdd3b7c4cce38fb10caf66326e7c439f0c079ee 100644 (file)
@@ -3,7 +3,7 @@ iwlmvm-y += fw.o mac80211.o nvm.o ops.o phy-ctxt.o mac-ctxt.o
 iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o sf.o
 iwlmvm-y += scan.o time-event.o rs.o
 iwlmvm-y += power.o coex.o
-iwlmvm-y += led.o tt.o
+iwlmvm-y += led.o tt.o offloading.o
 iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o
 iwlmvm-$(CONFIG_PM_SLEEP) += d3.o
 
index a08756456e10987c0aa3fbce5b7067a83066544b..02fb950c031c17cd34601ac5a09486e1a018ea4a 100644 (file)
@@ -376,139 +376,6 @@ static int iwl_mvm_send_patterns(struct iwl_mvm *mvm,
        return err;
 }
 
-static int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
-                                     struct ieee80211_vif *vif)
-{
-       union {
-               struct iwl_proto_offload_cmd_v1 v1;
-               struct iwl_proto_offload_cmd_v2 v2;
-               struct iwl_proto_offload_cmd_v3_small v3s;
-               struct iwl_proto_offload_cmd_v3_large v3l;
-       } cmd = {};
-       struct iwl_host_cmd hcmd = {
-               .id = PROT_OFFLOAD_CONFIG_CMD,
-               .flags = CMD_SYNC,
-               .data[0] = &cmd,
-               .dataflags[0] = IWL_HCMD_DFL_DUP,
-       };
-       struct iwl_proto_offload_cmd_common *common;
-       u32 enabled = 0, size;
-       u32 capa_flags = mvm->fw->ucode_capa.flags;
-#if IS_ENABLED(CONFIG_IPV6)
-       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-       int i;
-
-       if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL ||
-           capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
-               struct iwl_ns_config *nsc;
-               struct iwl_targ_addr *addrs;
-               int n_nsc, n_addrs;
-               int c;
-
-               if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
-                       nsc = cmd.v3s.ns_config;
-                       n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S;
-                       addrs = cmd.v3s.targ_addrs;
-                       n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S;
-               } else {
-                       nsc = cmd.v3l.ns_config;
-                       n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L;
-                       addrs = cmd.v3l.targ_addrs;
-                       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
-                * solicited node addresses.
-                */
-               for (i = 0, c = 0;
-                    i < mvmvif->num_target_ipv6_addrs &&
-                    i < n_addrs && c < n_nsc; i++) {
-                       struct in6_addr solicited_addr;
-                       int j;
-
-                       addrconf_addr_solict_mult(&mvmvif->target_ipv6_addrs[i],
-                                                 &solicited_addr);
-                       for (j = 0; j < c; j++)
-                               if (ipv6_addr_cmp(&nsc[j].dest_ipv6_addr,
-                                                 &solicited_addr) == 0)
-                                       break;
-                       if (j == c)
-                               c++;
-                       addrs[i].addr = mvmvif->target_ipv6_addrs[i];
-                       addrs[i].config_num = cpu_to_le32(j);
-                       nsc[j].dest_ipv6_addr = solicited_addr;
-                       memcpy(nsc[j].target_mac_addr, vif->addr, ETH_ALEN);
-               }
-
-               if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL)
-                       cmd.v3s.num_valid_ipv6_addrs = cpu_to_le32(i);
-               else
-                       cmd.v3l.num_valid_ipv6_addrs = cpu_to_le32(i);
-       } 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);
-               }
-
-               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++)
-                       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);
-               }
-
-               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++)
-                       memcpy(cmd.v1.target_ipv6_addr[i],
-                              &mvmvif->target_ipv6_addrs[i],
-                              sizeof(cmd.v1.target_ipv6_addr[i]));
-       }
-#endif
-
-       if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
-               common = &cmd.v3s.common;
-               size = sizeof(cmd.v3s);
-       } else if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
-               common = &cmd.v3l.common;
-               size = sizeof(cmd.v3l);
-       } else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
-               common = &cmd.v2.common;
-               size = sizeof(cmd.v2);
-       } else {
-               common = &cmd.v1.common;
-               size = sizeof(cmd.v1);
-       }
-
-       if (vif->bss_conf.arp_addr_cnt) {
-               enabled |= IWL_D3_PROTO_OFFLOAD_ARP;
-               common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0];
-               memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN);
-       }
-
-       if (!enabled)
-               return 0;
-
-       common->enabled = cpu_to_le32(enabled);
-
-       hcmd.len[0] = size;
-       return iwl_mvm_send_cmd(mvm, &hcmd);
-}
-
 enum iwl_mvm_tcp_packet_type {
        MVM_TCP_TX_SYN,
        MVM_TCP_RX_SYNACK,
@@ -927,6 +794,20 @@ void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
                IWL_ERR(mvm, "failed to set non-QoS seqno\n");
 }
 
+static int
+iwl_mvm_send_wowlan_config_cmd(struct iwl_mvm *mvm,
+                              const struct iwl_wowlan_config_cmd_v3 *cmd)
+{
+       /* start only with the v2 part of the command */
+       u16 cmd_len = sizeof(cmd->common);
+
+       if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID)
+               cmd_len = sizeof(*cmd);
+
+       return iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION, CMD_SYNC,
+                                   cmd_len, cmd);
+}
+
 static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
                             struct cfg80211_wowlan *wowlan,
                             bool test)
@@ -939,7 +820,7 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
        struct iwl_mvm_vif *mvmvif;
        struct ieee80211_sta *ap_sta;
        struct iwl_mvm_sta *mvm_ap_sta;
-       struct iwl_wowlan_config_cmd wowlan_config_cmd = {};
+       struct iwl_wowlan_config_cmd_v3 wowlan_config_cmd = {};
        struct iwl_wowlan_kek_kck_material_cmd kek_kck_cmd = {};
        struct iwl_wowlan_tkip_params_cmd tkip_cmd = {};
        struct iwl_d3_manager_config d3_cfg_cmd_data = {
@@ -961,7 +842,7 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
                .tkip = &tkip_cmd,
                .use_tkip = false,
        };
-       int ret, i;
+       int ret;
        int len __maybe_unused;
 
        if (!wowlan) {
@@ -1002,49 +883,41 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
 
        mvm_ap_sta = (struct iwl_mvm_sta *)ap_sta->drv_priv;
 
-       /* TODO: wowlan_config_cmd.wowlan_ba_teardown_tids */
+       /* TODO: wowlan_config_cmd.common.wowlan_ba_teardown_tids */
 
-       wowlan_config_cmd.is_11n_connection = ap_sta->ht_cap.ht_supported;
+       wowlan_config_cmd.common.is_11n_connection =
+                                       ap_sta->ht_cap.ht_supported;
 
        /* Query the last used seqno and set it */
        ret = iwl_mvm_get_last_nonqos_seq(mvm, vif);
        if (ret < 0)
                goto out_noreset;
-       wowlan_config_cmd.non_qos_seq = cpu_to_le16(ret);
+       wowlan_config_cmd.common.non_qos_seq = cpu_to_le16(ret);
 
-       /*
-        * For QoS counters, we store the one to use next, so subtract 0x10
-        * since the uCode will add 0x10 *before* using the value while we
-        * increment after using the value (i.e. store the next value to use).
-        */
-       for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
-               u16 seq = mvm_ap_sta->tid_data[i].seq_number;
-               seq -= 0x10;
-               wowlan_config_cmd.qos_seq[i] = cpu_to_le16(seq);
-       }
+       iwl_mvm_set_wowlan_qos_seq(mvm_ap_sta, &wowlan_config_cmd.common);
 
        if (wowlan->disconnect)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_BEACON_MISS |
                                    IWL_WOWLAN_WAKEUP_LINK_CHANGE);
        if (wowlan->magic_pkt)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_MAGIC_PACKET);
        if (wowlan->gtk_rekey_failure)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL);
        if (wowlan->eap_identity_req)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ);
        if (wowlan->four_way_handshake)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE);
        if (wowlan->n_patterns)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_PATTERN_MATCH);
 
        if (wowlan->rfkill_release)
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT);
 
        if (wowlan->tcp) {
@@ -1052,7 +925,7 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
                 * Set the "link change" (really "link lost") flag as well
                 * since that implies losing the TCP connection.
                 */
-               wowlan_config_cmd.wakeup_filter |=
+               wowlan_config_cmd.common.wakeup_filter |=
                        cpu_to_le32(IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS |
                                    IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE |
                                    IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET |
@@ -1150,9 +1023,7 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
                }
        }
 
-       ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION,
-                                  CMD_SYNC, sizeof(wowlan_config_cmd),
-                                  &wowlan_config_cmd);
+       ret = iwl_mvm_send_wowlan_config_cmd(mvm, &wowlan_config_cmd);
        if (ret)
                goto out;
 
index 521997669c999cdd989899ea84bc3ac535327c28..10fcc1a79ebddf3087d7de7c2c29389849a425fa 100644 (file)
@@ -239,7 +239,7 @@ enum iwl_wowlan_wakeup_filters {
        IWL_WOWLAN_WAKEUP_BCN_FILTERING                 = BIT(16),
 }; /* WOWLAN_WAKEUP_FILTER_API_E_VER_4 */
 
-struct iwl_wowlan_config_cmd {
+struct iwl_wowlan_config_cmd_v2 {
        __le32 wakeup_filter;
        __le16 non_qos_seq;
        __le16 qos_seq[8];
@@ -247,6 +247,12 @@ struct iwl_wowlan_config_cmd {
        u8 is_11n_connection;
 } __packed; /* WOWLAN_CONFIG_API_S_VER_2 */
 
+struct iwl_wowlan_config_cmd_v3 {
+       struct iwl_wowlan_config_cmd_v2 common;
+       u8 offloading_tid;
+       u8 reserved[3];
+} __packed; /* WOWLAN_CONFIG_API_S_VER_3 */
+
 /*
  * WOWLAN_TSC_RSC_PARAMS
  */
index f77be762ebd9e614086bafab76b2296c367a9532..095bc26696101b42f9fa66343069421a324f808c 100644 (file)
@@ -317,13 +317,13 @@ struct iwl_mvm_vif {
 
        bool seqno_valid;
        u16 seqno;
+#endif
 
 #if IS_ENABLED(CONFIG_IPV6)
        /* IPv6 addresses for WoWLAN */
        struct in6_addr target_ipv6_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX];
        int num_target_ipv6_addrs;
 #endif
-#endif
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        struct iwl_mvm *mvm;
@@ -896,6 +896,9 @@ iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
 }
 #endif
+void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
+                               struct iwl_wowlan_config_cmd_v2 *cmd);
+int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
 
 /* D0i3 */
 void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
diff --git a/drivers/net/wireless/iwlwifi/mvm/offloading.c b/drivers/net/wireless/iwlwifi/mvm/offloading.c
new file mode 100644 (file)
index 0000000..9ec5a59
--- /dev/null
@@ -0,0 +1,214 @@
+/******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#include <net/ipv6.h>
+#include <net/addrconf.h>
+#include "mvm.h"
+
+void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta,
+                               struct iwl_wowlan_config_cmd_v2 *cmd)
+{
+       int i;
+
+       /*
+        * For QoS counters, we store the one to use next, so subtract 0x10
+        * since the uCode will add 0x10 *before* using the value while we
+        * increment after using the value (i.e. store the next value to use).
+        */
+       for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
+               u16 seq = mvm_ap_sta->tid_data[i].seq_number;
+               seq -= 0x10;
+               cmd->qos_seq[i] = cpu_to_le16(seq);
+       }
+}
+
+int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+{
+       union {
+               struct iwl_proto_offload_cmd_v1 v1;
+               struct iwl_proto_offload_cmd_v2 v2;
+               struct iwl_proto_offload_cmd_v3_small v3s;
+               struct iwl_proto_offload_cmd_v3_large v3l;
+       } cmd = {};
+       struct iwl_host_cmd hcmd = {
+               .id = PROT_OFFLOAD_CONFIG_CMD,
+               .flags = CMD_SYNC,
+               .data[0] = &cmd,
+               .dataflags[0] = IWL_HCMD_DFL_DUP,
+       };
+       struct iwl_proto_offload_cmd_common *common;
+       u32 enabled = 0, size;
+       u32 capa_flags = mvm->fw->ucode_capa.flags;
+#if IS_ENABLED(CONFIG_IPV6)
+       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       int i;
+
+       if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL ||
+           capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
+               struct iwl_ns_config *nsc;
+               struct iwl_targ_addr *addrs;
+               int n_nsc, n_addrs;
+               int c;
+
+               if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
+                       nsc = cmd.v3s.ns_config;
+                       n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S;
+                       addrs = cmd.v3s.targ_addrs;
+                       n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S;
+               } else {
+                       nsc = cmd.v3l.ns_config;
+                       n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L;
+                       addrs = cmd.v3l.targ_addrs;
+                       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
+                * solicited node addresses.
+                */
+               for (i = 0, c = 0;
+                    i < mvmvif->num_target_ipv6_addrs &&
+                    i < n_addrs && c < n_nsc; i++) {
+                       struct in6_addr solicited_addr;
+                       int j;
+
+                       addrconf_addr_solict_mult(&mvmvif->target_ipv6_addrs[i],
+                                                 &solicited_addr);
+                       for (j = 0; j < c; j++)
+                               if (ipv6_addr_cmp(&nsc[j].dest_ipv6_addr,
+                                                 &solicited_addr) == 0)
+                                       break;
+                       if (j == c)
+                               c++;
+                       addrs[i].addr = mvmvif->target_ipv6_addrs[i];
+                       addrs[i].config_num = cpu_to_le32(j);
+                       nsc[j].dest_ipv6_addr = solicited_addr;
+                       memcpy(nsc[j].target_mac_addr, vif->addr, ETH_ALEN);
+               }
+
+               if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL)
+                       cmd.v3s.num_valid_ipv6_addrs = cpu_to_le32(i);
+               else
+                       cmd.v3l.num_valid_ipv6_addrs = cpu_to_le32(i);
+       } 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);
+               }
+
+               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++)
+                       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);
+               }
+
+               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++)
+                       memcpy(cmd.v1.target_ipv6_addr[i],
+                              &mvmvif->target_ipv6_addrs[i],
+                              sizeof(cmd.v1.target_ipv6_addr[i]));
+       }
+#endif
+
+       if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
+               common = &cmd.v3s.common;
+               size = sizeof(cmd.v3s);
+       } else if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
+               common = &cmd.v3l.common;
+               size = sizeof(cmd.v3l);
+       } else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
+               common = &cmd.v2.common;
+               size = sizeof(cmd.v2);
+       } else {
+               common = &cmd.v1.common;
+               size = sizeof(cmd.v1);
+       }
+
+       if (vif->bss_conf.arp_addr_cnt) {
+               enabled |= IWL_D3_PROTO_OFFLOAD_ARP;
+               common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0];
+               memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN);
+       }
+
+       if (!enabled)
+               return 0;
+
+       common->enabled = cpu_to_le32(enabled);
+
+       hcmd.len[0] = size;
+       return iwl_mvm_send_cmd(mvm, &hcmd);
+}
index 75fbc40541730fe59ee36c0d9cbc64417a8ea8e6..87c32e80904c563a655b022e4763b57a349385a1 100644 (file)
@@ -850,6 +850,33 @@ static void iwl_mvm_enter_d0i3_iterator(void *_data, u8 *mac,
        data->vif_count++;
 }
 
+static void iwl_mvm_set_wowlan_data(struct iwl_mvm *mvm,
+                                   struct iwl_wowlan_config_cmd_v3 *cmd,
+                                   struct iwl_d0i3_iter_data *iter_data)
+{
+       struct ieee80211_sta *ap_sta;
+       struct iwl_mvm_sta *mvm_ap_sta;
+
+       if (iter_data->ap_sta_id == IWL_MVM_STATION_COUNT)
+               return;
+
+       rcu_read_lock();
+
+       ap_sta = rcu_dereference(mvm->fw_id_to_mac_id[iter_data->ap_sta_id]);
+       if (IS_ERR_OR_NULL(ap_sta))
+               goto out;
+
+       mvm_ap_sta = iwl_mvm_sta_from_mac80211(ap_sta);
+       cmd->common.is_11n_connection = ap_sta->ht_cap.ht_supported;
+
+       /*
+        * The d0i3 uCode takes care of the nonqos counters,
+        * so configure only the qos seq ones.
+        */
+       iwl_mvm_set_wowlan_qos_seq(mvm_ap_sta, &cmd->common);
+out:
+       rcu_read_unlock();
+}
 static int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
 {
        struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
@@ -858,11 +885,14 @@ static int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
        struct iwl_d0i3_iter_data d0i3_iter_data = {
                .mvm = mvm,
        };
-       struct iwl_wowlan_config_cmd wowlan_config_cmd = {
-               .wakeup_filter = cpu_to_le32(IWL_WOWLAN_WAKEUP_RX_FRAME |
-                                            IWL_WOWLAN_WAKEUP_BEACON_MISS |
-                                            IWL_WOWLAN_WAKEUP_LINK_CHANGE |
-                                            IWL_WOWLAN_WAKEUP_BCN_FILTERING),
+       struct iwl_wowlan_config_cmd_v3 wowlan_config_cmd = {
+               .common = {
+                       .wakeup_filter =
+                               cpu_to_le32(IWL_WOWLAN_WAKEUP_RX_FRAME |
+                                           IWL_WOWLAN_WAKEUP_BEACON_MISS |
+                                           IWL_WOWLAN_WAKEUP_LINK_CHANGE |
+                                           IWL_WOWLAN_WAKEUP_BCN_FILTERING),
+               },
        };
        struct iwl_d3_manager_config d3_cfg_cmd = {
                .min_sleep_time = cpu_to_le32(1000),
@@ -881,6 +911,7 @@ static int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
                mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT;
        }
 
+       iwl_mvm_set_wowlan_data(mvm, &wowlan_config_cmd, &d0i3_iter_data);
        ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION, flags,
                                   sizeof(wowlan_config_cmd),
                                   &wowlan_config_cmd);