Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | #ifndef _WLAN_HDD_WOWL_H |
| 29 | #define _WLAN_HDD_WOWL_H |
| 30 | |
| 31 | /** |
| 32 | * DOC: wlan_hdd_wowl |
| 33 | * |
| 34 | * This module houses all the logic for WOWL in HDD. |
| 35 | * |
| 36 | * It provides the following APIs |
| 37 | * |
| 38 | * - Ability to enable/disable following WoWL modes |
| 39 | * 1) Magic packet (MP) mode |
| 40 | * 2) Pattern Byte Matching (PBM) mode |
| 41 | * - Ability to add/remove patterns for PBM |
| 42 | * |
| 43 | * A Magic Packet is a packet that contains 6 0xFFs followed by 16 |
| 44 | * contiguous copies of the receiving NIC's Ethernet address. There is |
| 45 | * no API to configure Magic Packet Pattern. |
| 46 | * |
| 47 | * Wakeup pattern (used for PBM) is defined as following: |
| 48 | * typedef struct |
| 49 | * { |
| 50 | * U8 PatternSize; // Non-Zero pattern size |
| 51 | * U8 PatternMaskSize; // Non-zero pattern mask size |
| 52 | * U8 PatternMask[PatternMaskSize]; // Pattern mask |
| 53 | * U8 Pattern[PatternSize]; // Pattern |
| 54 | * } hdd_wowl_ptrn_t; |
| 55 | * |
| 56 | * PatternSize and PatternMaskSize indicate size of the variable |
| 57 | * length Pattern and PatternMask. PatternMask indicates which bytes |
| 58 | * of an incoming packet should be compared with corresponding bytes |
| 59 | * in the pattern. |
| 60 | * |
| 61 | * Maximum allowed pattern size is 128 bytes. Maximum allowed |
| 62 | * PatternMaskSize is 16 bytes. |
| 63 | * |
| 64 | * Maximum number of patterns that can be configured is 8 |
| 65 | * |
| 66 | * HDD will add following 2 commonly used patterns for PBM by default: |
| 67 | * 1) ARP Broadcast Pattern |
| 68 | * 2) Unicast Pattern |
| 69 | * |
| 70 | * However note that WoWL will not be enabled by default by HDD. WoWL |
| 71 | * needs to enabled explcitly by exercising the iwpriv command. |
| 72 | * |
| 73 | * HDD will expose an API that accepts patterns as Hex string in the |
| 74 | * following format: |
| 75 | * "PatternSize:PatternMaskSize:PatternMask:Pattern" |
| 76 | * |
| 77 | * Multiple patterns can be specified by deleimiting each pattern with |
| 78 | * the ';' token: |
| 79 | * "PatternSize1:PatternMaskSize1:PatternMask1:Pattern1;PatternSize2:..." |
| 80 | * |
| 81 | * Patterns can be configured dynamically via iwpriv cmd or statically |
| 82 | * via qcom_cfg.ini file |
| 83 | * |
| 84 | * PBM (when enabled) can perform filtering on unicast data or |
| 85 | * broadcast data or both. These configurations are part of factory |
| 86 | * defaults (cfg.dat) and the deafult behavior is to perform filtering |
| 87 | * on both unicast and data frames. |
| 88 | * |
| 89 | * MP filtering (when enabled) is performed ALWAYS on both unicast and |
| 90 | * broadcast data frames. |
| 91 | * |
| 92 | * Mangement frames are not subjected to WoWL filtering and are |
| 93 | * discarded when WoWL is enabled. |
| 94 | * |
| 95 | * Whenever a patern match succeeds, RX path is restored and packets |
| 96 | * (both management and data) will be pushed to the host from that |
| 97 | * point onwards. Therefore, exit from WoWL is implicit and happens |
| 98 | * automatically when the first packet match succeeds. |
| 99 | * |
| 100 | * WoWL works on top of BMPS. So when WoWL is requested, SME will |
| 101 | * attempt to put the device in BMPS mode (if not already in BMPS). If |
| 102 | * attempt to BMPS fails, request for WoWL will be rejected. |
| 103 | */ |
| 104 | |
| 105 | #include <cdf_types.h> |
| 106 | |
| 107 | #define WOWL_PTRN_MAX_SIZE 146 |
| 108 | #define WOWL_PTRN_MASK_MAX_SIZE 19 |
| 109 | #define WOWL_MAX_PTRNS_ALLOWED CFG_MAX_WOW_FILTERS_MAX |
| 110 | |
| 111 | /** |
| 112 | * hdd_add_wowl_ptrn() - Function which will add the WoWL pattern to be |
| 113 | * used when PBM filtering is enabled |
| 114 | * @pAdapter: pointer to the adapter |
| 115 | * @ptrn: pointer to the pattern string to be added |
| 116 | * |
| 117 | * Return: false if any errors encountered, true otherwise |
| 118 | */ |
| 119 | bool hdd_add_wowl_ptrn(hdd_adapter_t *pAdapter, const char *ptrn); |
| 120 | |
| 121 | /** |
| 122 | * hdd_del_wowl_ptrn() - Function which will remove a WoWL pattern |
| 123 | * @pAdapter: pointer to the adapter |
| 124 | * @ptrn: pointer to the pattern string to be removed |
| 125 | * |
| 126 | * Return: false if any errors encountered, true otherwise |
| 127 | */ |
| 128 | bool hdd_del_wowl_ptrn(hdd_adapter_t *pAdapter, const char *ptrn); |
| 129 | |
| 130 | /** |
| 131 | * hdd_add_wowl_ptrn_debugfs() - Function which will add a WoW pattern |
| 132 | * sent from debugfs interface |
| 133 | * @pAdapter: pointer to the adapter |
| 134 | * @pattern_idx: index of the pattern to be added |
| 135 | * @pattern_offset: offset of the pattern in the frame payload |
| 136 | * @pattern_buf: pointer to the pattern hex string to be added |
| 137 | * @pattern_mask: pointer to the pattern mask hex string |
| 138 | * |
| 139 | * Return: false if any errors encountered, true otherwise |
| 140 | */ |
| 141 | bool hdd_add_wowl_ptrn_debugfs(hdd_adapter_t *pAdapter, uint8_t pattern_idx, |
| 142 | uint8_t pattern_offset, char *pattern_buf, |
| 143 | char *pattern_mask); |
| 144 | |
| 145 | /** |
| 146 | * hdd_del_wowl_ptrn_debugfs() - Function which will remove a WoW pattern |
| 147 | * sent from debugfs interface |
| 148 | * @pAdapter: pointer to the adapter |
| 149 | * @pattern_idx: index of the pattern to be removed |
| 150 | * |
| 151 | * Return: false if any errors encountered, true otherwise |
| 152 | */ |
| 153 | bool hdd_del_wowl_ptrn_debugfs(hdd_adapter_t *pAdapter, uint8_t pattern_idx); |
| 154 | |
| 155 | /** |
| 156 | * hdd_enter_wowl() - Function which will enable WoWL. At least one |
| 157 | * of MP and PBM must be enabled |
| 158 | * @pAdapter: pointer to the adapter |
| 159 | * @enable_mp: Whether to enable magic packet WoWL mode |
| 160 | * @enable_pbm: Whether to enable pattern byte matching WoWL mode |
| 161 | * |
| 162 | * Return: false if any errors encountered, true otherwise |
| 163 | */ |
| 164 | bool hdd_enter_wowl(hdd_adapter_t *pAdapter, bool enable_mp, bool enable_pbm); |
| 165 | |
| 166 | /** |
| 167 | * hdd_exit_wowl() - Function which will disable WoWL |
| 168 | * @pAdapter: pointer to the adapter |
| 169 | * |
| 170 | * Return: false if any errors encountered, true otherwise |
| 171 | */ |
| 172 | bool hdd_exit_wowl(hdd_adapter_t *pAdapter); |
| 173 | |
| 174 | /** |
| 175 | * hdd_init_wowl() - Init function which will initialize the WoWL module |
| 176 | * and perform any required initial configuration |
| 177 | * @pAdapter: pointer to the adapter |
| 178 | * |
| 179 | * Return: false if any errors encountered, true otherwise |
| 180 | */ |
| 181 | bool hdd_init_wowl(hdd_adapter_t *pAdapter); |
| 182 | |
| 183 | #endif /* #ifndef _WLAN_HDD_WOWL_H */ |