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