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