xref: /wlan-driver/qca-wifi-host-cmn/umac/wifi_pos/inc/wifi_pos_utils_pub.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: wifi_pos_utils_pub.h
20  * This file declares public utils of wifi positioning component
21  */
22 #ifndef _WIFI_POS_UTILS_PUB_H_
23 #define _WIFI_POS_UTILS_PUB_H_
24 
25 /* Include files */
26 #include "qdf_types.h"
27 #include "qdf_status.h"
28 #include "qdf_trace.h"
29 #include <wlan_cmn.h>
30 #include <reg_services_public_struct.h>
31 
32 #define WIFIPOS_RESERVE_BYTES      100
33 #define OEM_TARGET_SIGNATURE_LEN   8
34 #define OEM_TARGET_SIGNATURE       "QUALCOMM"
35 
36 #define OEM_CAP_MAX_NUM_CHANNELS   128
37 
38 #define WIFI_POS_RSP_V1_FLAT_MEMORY  0x00000001
39 #define WIFI_POS_RSP_V2_NL  0x00000002
40 
41 #ifdef CNSS_GENL
42 #define WIFI_POS_MAX_NUM_CHANNELS NUM_CHANNELS
43 #else
44 #define WIFI_POS_MAX_NUM_CHANNELS (NUM_CHANNELS * 2)
45 #endif
46 
47 /**
48  * enum wifi_pos_cmd_ids - Wi-Fi Positioning command IDs
49  * @WIFI_POS_CMD_INVALID: invalid command
50  * @WIFI_POS_CMD_REGISTRATION: app registration
51  * @WIFI_POS_CMD_SET_CAPS: set userspace capabilities
52  * @WIFI_POS_CMD_GET_CAPS: get driver capabilities
53  * @WIFI_POS_CMD_GET_CH_INFO: get channel info
54  * @WIFI_POS_CMD_OEM_DATA: oem data req/rsp
55  * @WIFI_POS_CMD_ERROR: error notification
56  * @WIFI_POS_PEER_STATUS_IND: peer status indication
57  * @WIFI_POS_CMD__AFTER_LAST: internal use
58  * @WIFI_POS_CMD_MAX: Max Wi-Fi Positioning command ID
59  */
60 
61 enum wifi_pos_cmd_ids {
62 	WIFI_POS_CMD_INVALID = 0,
63 	WIFI_POS_CMD_REGISTRATION = 1,
64 	WIFI_POS_CMD_SET_CAPS = 2,
65 	WIFI_POS_CMD_GET_CAPS = 3,
66 	WIFI_POS_CMD_GET_CH_INFO = 4,
67 	WIFI_POS_CMD_OEM_DATA = 5,
68 	WIFI_POS_CMD_ERROR = 6,
69 	WIFI_POS_PEER_STATUS_IND = 7,
70 	/* keep last */
71 	WIFI_POS_CMD__AFTER_LAST,
72 	WIFI_POS_CMD_MAX =
73 		WIFI_POS_CMD__AFTER_LAST - 1
74 };
75 
76 
77 /**
78  * struct wifi_pos_driver_version - Driver version identifier (w.x.y.z)
79  * @major: Version ID major number
80  * @minor: Version ID minor number
81  * @patch: Version ID patch number
82  * @build: Version ID build number
83  */
84 struct wifi_pos_driver_version {
85 	uint8_t major;
86 	uint8_t minor;
87 	uint8_t patch;
88 	uint8_t build;
89 } qdf_packed;
90 
91 /**
92  * struct wifi_pos_channel_power - Wi-Fi Positioning channel/power info
93  * @ch_power: channel_power structure object
94  * @band_center_freq1: Center frequency1
95  * @phy_mode: Phymode
96  * @is_dfs_chan: Is DFS channel
97  */
98 struct wifi_pos_channel_power {
99 	struct channel_power ch_power;
100 	uint32_t band_center_freq1;
101 	uint32_t phy_mode;
102 	bool is_dfs_chan;
103 };
104 
105 /**
106  * struct wifi_pos_channel_list - Wi-Fi Positioning channel list
107  * @num_channels: no of valid channels
108  * @chan_info: channel info
109  */
110 struct wifi_pos_channel_list {
111 	uint16_t num_channels;
112 	struct wifi_pos_channel_power chan_info[WIFI_POS_MAX_NUM_CHANNELS];
113 } qdf_packed;
114 
115 /**
116  * struct wifi_pos_driver_caps - OEM Data Capabilities
117  * @oem_target_signature: Signature of chipset vendor
118  * @oem_target_type: Chip type
119  * @oem_fw_version: Firmware version
120  * @driver_version: Host software version
121  * @allowed_dwell_time_min: Channel dwell time - allowed minimum
122  * @allowed_dwell_time_max: Channel dwell time - allowed maximum
123  * @curr_dwell_time_min: Channel dwell time - current minimim
124  * @curr_dwell_time_max: Channel dwell time - current maximum
125  * @supported_bands: Supported bands, 2.4 GHz or 5 GHz
126  * @num_channels: Num of channels IDs to follow
127  * @channel_list: List of channel IDs
128  */
129 struct wifi_pos_driver_caps {
130 	uint8_t oem_target_signature[OEM_TARGET_SIGNATURE_LEN];
131 	uint32_t oem_target_type;
132 	uint32_t oem_fw_version;
133 	struct wifi_pos_driver_version driver_version;
134 	uint16_t allowed_dwell_time_min;
135 	uint16_t allowed_dwell_time_max;
136 	uint16_t curr_dwell_time_min;
137 	uint16_t curr_dwell_time_max;
138 	uint16_t supported_bands;
139 	uint16_t num_channels;
140 	uint8_t channel_list[OEM_CAP_MAX_NUM_CHANNELS];
141 } qdf_packed;
142 
143 /**
144  * struct wifi_pos_user_defined_caps - OEM capability to be exchanged between
145  *                                     host and userspace
146  * @ftm_rr: FTM range report capability bit
147  * @lci_capability: LCI capability bit
148  * @reserved1: reserved
149  * @reserved2: reserved
150  */
151 struct wifi_pos_user_defined_caps {
152 	uint32_t ftm_rr:1;
153 	uint32_t lci_capability:1;
154 	uint32_t reserved1:30;
155 	uint32_t reserved2;
156 };
157 
158 /**
159  * struct wifi_pos_oem_get_cap_rsp - capabilities set by userspace and target.
160  * @driver_cap: target capabilities
161  * @user_defined_cap: capabilities set by userspace via set request
162  */
163 struct wifi_pos_oem_get_cap_rsp {
164 	struct wifi_pos_driver_caps driver_cap;
165 	struct wifi_pos_user_defined_caps user_defined_cap;
166 } qdf_packed;
167 #endif
168