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