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