blob: 1a6c35cf398cca2a6da59415e3e85e9303dc511b [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Rajeev Kumard0565362018-03-01 12:02:01 -08002 * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * 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 Dhavali7090c5f2015-11-02 17:55:19 -080019#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 Johnson5e492b42018-05-06 08:03:47 -070077 * defaults (cfg.dat) and the default behavior is to perform filtering
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078 * 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 Johnson9020f0c2018-05-06 08:08:25 -070083 * Management frames are not subjected to WoWL filtering and are
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084 * 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 Chouhan6d760662016-02-20 16:05:43 +053096#include <qdf_types.h>
Wu Gaoffb9c722018-05-31 10:37:11 +080097#include "wlan_pmo_wow_public_struct.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
Dustin Brown0b703ef2018-03-02 15:02:12 -080099#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 Dhavali7090c5f2015-11-02 17:55:19 -0800102
103/**
104 * hdd_add_wowl_ptrn() - Function which will add the WoWL pattern to be
105 * used when PBM filtering is enabled
Jeff Johnsond184d2b2017-10-02 13:13:13 -0700106 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107 * @ptrn: pointer to the pattern string to be added
108 *
109 * Return: false if any errors encountered, true otherwise
110 */
Jeff Johnsond184d2b2017-10-02 13:13:13 -0700111bool hdd_add_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112
113/**
114 * hdd_del_wowl_ptrn() - Function which will remove a WoWL pattern
Jeff Johnsond184d2b2017-10-02 13:13:13 -0700115 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116 * @ptrn: pointer to the pattern string to be removed
117 *
118 * Return: false if any errors encountered, true otherwise
119 */
Jeff Johnsond184d2b2017-10-02 13:13:13 -0700120bool hdd_del_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121
122/**
123 * hdd_add_wowl_ptrn_debugfs() - Function which will add a WoW pattern
124 * sent from debugfs interface
Jeff Johnsond184d2b2017-10-02 13:13:13 -0700125 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126 * @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 Johnsond184d2b2017-10-02 13:13:13 -0700133bool hdd_add_wowl_ptrn_debugfs(struct hdd_adapter *adapter, uint8_t pattern_idx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 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 Johnsond184d2b2017-10-02 13:13:13 -0700140 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 * @pattern_idx: index of the pattern to be removed
142 *
143 * Return: false if any errors encountered, true otherwise
144 */
Jeff Johnson18ef2842017-10-03 11:46:38 -0700145bool hdd_del_wowl_ptrn_debugfs(struct hdd_adapter *adapter,
146 uint8_t pattern_idx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147
148/**
Kabilan Kannan6edafeb2017-11-16 16:34:34 -0800149 * hdd_free_user_wowl_ptrns() - Deinit function to cleanup WoWL allocated memory
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 *
Dustin Brownedce4a52017-05-10 11:59:15 -0700151 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 */
Kabilan Kannan6edafeb2017-11-16 16:34:34 -0800153void hdd_free_user_wowl_ptrns(void);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154
155#endif /* #ifndef _WLAN_HDD_WOWL_H */