blob: 0c0e435b974b5d20126f146f2caf4cccf12b77e7 [file] [log] [blame]
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001/*
2 * FST module - interface definitions
3 * Copyright (c) 2014, Qualcomm Atheros, Inc.
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#ifndef FST_H
10#define FST_H
11
12#ifdef CONFIG_FST
13
14#include "common/defs.h"
15#include "fst/fst_ctrl_iface.h"
16
17/* FST module hostap integration API */
18
19#define US_IN_MS 1000
20#define LLT_UNIT_US 32 /* See 10.32.2.2 Transitioning between states */
21
22#define FST_LLT_MS_TO_VAL(m) (((u32) (m)) * US_IN_MS / LLT_UNIT_US)
23#define FST_LLT_VAL_TO_MS(v) (((u32) (v)) * LLT_UNIT_US / US_IN_MS)
24
25#define FST_MAX_LLT_MS FST_LLT_VAL_TO_MS(-1)
26#define FST_MAX_PRIO_VALUE ((u8) -1)
27#define FST_MAX_GROUP_ID_LEN IFNAMSIZ
28
29#define FST_DEFAULT_LLT_CFG_VALUE 50
30
31struct hostapd_hw_modes;
32struct ieee80211_mgmt;
33struct fst_iface;
34struct fst_group;
35struct fst_session;
36struct fst_get_peer_ctx;
37struct fst_ctrl_handle;
38
39struct fst_wpa_obj {
40 void *ctx;
41
42 /**
43 * get_bssid - Get BSSID of the interface
44 * @ctx: User context %ctx
45 * Returns: BSSID for success, %NULL for failure.
46 *
47 * NOTE: For AP it returns the own BSSID, while for STA - the BSSID of
48 * the associated AP.
49 */
50 const u8 * (*get_bssid)(void *ctx);
51
52 /**
53 * get_channel_info - Get current channel info
54 * @ctx: User context %ctx
55 * @hw_mode: OUT, current HW mode
56 * @channel: OUT, current channel
57 */
58 void (*get_channel_info)(void *ctx, enum hostapd_hw_mode *hw_mode,
59 u8 *channel);
60
61 /**
62 * get_hw_modes - Get hardware modes
63 * @ctx: User context %ctx
64 * @modes: OUT, pointer on array of hw modes
65 *
66 * Returns: Number of hw modes available.
67 */
68 int (*get_hw_modes)(void *ctx, struct hostapd_hw_modes **modes);
69
70 /**
71 * set_ies - Set interface's MB IE
72 * @ctx: User context %ctx
73 * @fst_ies: MB IE buffer (owned by FST module)
74 */
75 void (*set_ies)(void *ctx, const struct wpabuf *fst_ies);
76
77 /**
78 * send_action - Send FST Action frame via the interface
79 * @ctx: User context %ctx
80 * @addr: Address of the destination STA
81 * @data: Action frame buffer
82 * Returns: 0 for success, negative error code for failure.
83 */
84 int (*send_action)(void *ctx, const u8 *addr, struct wpabuf *data);
85
86 /**
87 * get_mb_ie - Get last MB IE received from STA
88 * @ctx: User context %ctx
89 * @addr: Address of the STA
90 * Returns: MB IE buffer, %NULL if no MB IE received from the STA
91 */
92 const struct wpabuf * (*get_mb_ie)(void *ctx, const u8 *addr);
93
94 /**
95 * update_mb_ie - Update last MB IE received from STA
96 * @ctx: User context %ctx
97 * @addr: Address of the STA
98 * @buf: Buffer that contains the MB IEs data
99 * @size: Size of data in %buf
100 */
101 void (*update_mb_ie)(void *ctx, const u8 *addr,
102 const u8 *buf, size_t size);
103
104 /**
105 * get_peer_first - Get MAC address of the 1st connected STA
106 * @ctx: User context %ctx
107 * @get_ctx: Context to be used for %get_peer_next call
108 * @mb_only: %TRUE if only multi-band capable peer should be reported
109 * Returns: Address of the 1st connected STA, %NULL if no STAs connected
110 */
111 const u8 * (*get_peer_first)(void *ctx,
112 struct fst_get_peer_ctx **get_ctx,
113 Boolean mb_only);
114 /**
115 * get_peer_next - Get MAC address of the next connected STA
116 * @ctx: User context %ctx
117 * @get_ctx: Context received from %get_peer_first or previous
118 * %get_peer_next call
119 * @mb_only: %TRUE if only multi-band capable peer should be reported
120 * Returns: Address of the next connected STA, %NULL if no more STAs
121 * connected
122 */
123 const u8 * (*get_peer_next)(void *ctx,
124 struct fst_get_peer_ctx **get_ctx,
125 Boolean mb_only);
126};
127
128/**
129 * fst_global_init - Global FST module initiator
130 * Returns: 0 for success, negative error code for failure.
131 * Note: The purpose of this function is to allocate and initiate global
132 * FST module data structures (linked lists, static data etc.)
133 * This function should be called prior to the 1st %fst_attach call.
134 */
135int fst_global_init(void);
136
137/**
138 * fst_global_deinit - Global FST module de-initiator
139 * Note: The purpose of this function is to deallocate and de-initiate global
140 * FST module data structures (linked lists, static data etc.)
141 */
142void fst_global_deinit(void);
143
144/**
145 * struct fst_ctrl - Notification interface for FST module
146 */
147struct fst_ctrl {
148 /**
149 * init - Initialize the notification interface
150 * Returns: 0 for success, negative error code for failure.
151 */
152 int (*init)(void);
153
154 /**
155 * deinit - Deinitialize the notification interface
156 */
157 void (*deinit)(void);
158
159 /**
160 * on_group_created - Notify about FST group creation
161 * Returns: 0 for success, negative error code for failure.
162 */
163 int (*on_group_created)(struct fst_group *g);
164
165 /**
166 * on_group_deleted - Notify about FST group deletion
167 */
168 void (*on_group_deleted)(struct fst_group *g);
169
170 /**
171 * on_iface_added - Notify about interface addition
172 * Returns: 0 for success, negative error code for failure.
173 */
174 int (*on_iface_added)(struct fst_iface *i);
175
176 /**
177 * on_iface_removed - Notify about interface removal
178 */
179 void (*on_iface_removed)(struct fst_iface *i);
180
181 /**
182 * on_session_added - Notify about FST session addition
183 * Returns: 0 for success, negative error code for failure.
184 */
185 int (*on_session_added)(struct fst_session *s);
186
187 /**
188 * on_session_removed - Notify about FST session removal
189 */
190 void (*on_session_removed)(struct fst_session *s);
191
192 /**
193 * on_event - Notify about FST event
194 * @event_type: Event type
195 * @i: Interface object that relates to the event or NULL
196 * @g: Group object that relates to the event or NULL
197 * @extra - Event specific data (see fst_ctrl_iface.h for more info)
198 */
199 void (*on_event)(enum fst_event_type event_type, struct fst_iface *i,
200 struct fst_session *s,
201 const union fst_event_extra *extra);
202};
203
204struct fst_ctrl_handle * fst_global_add_ctrl(const struct fst_ctrl *ctrl);
205void fst_global_del_ctrl(struct fst_ctrl_handle *h);
206
207/**
208 * NOTE: These values have to be read from configuration file
209 */
210struct fst_iface_cfg {
211 char group_id[FST_MAX_GROUP_ID_LEN + 1];
212 u8 priority;
213 u32 llt;
214};
215
216/**
217 * fst_attach - Attach interface to an FST group according to configuration read
218 * @ifname: Interface name
219 * @own_addr: Own interface MAC address
220 * @iface_obj: Callbacks to be used by FST module to communicate with
221 * hostapd/wpa_supplicant
222 * @cfg: FST-related interface configuration read from the configuration file
223 * Returns: FST interface object for success, %NULL for failure.
224 */
225struct fst_iface * fst_attach(const char *ifname,
226 const u8 *own_addr,
227 const struct fst_wpa_obj *iface_obj,
228 const struct fst_iface_cfg *cfg);
229
230/**
231 * fst_detach - Detach an interface
232 * @iface: FST interface object
233 */
234void fst_detach(struct fst_iface *iface);
235
236/* FST module inputs */
237/**
238 * fst_rx_action - FST Action frames handler
239 * @iface: FST interface object
240 * @mgmt: Action frame arrived
241 * @len: Action frame length
242 */
243void fst_rx_action(struct fst_iface *iface, const struct ieee80211_mgmt *mgmt,
244 size_t len);
245
246/**
247 * fst_notify_peer_connected - FST STA connect handler
248 * @iface: FST interface object
249 * @addr: Address of the connected STA
250 */
251void fst_notify_peer_connected(struct fst_iface *iface, const u8 *addr);
252
253/**
254 * fst_notify_peer_disconnected - FST STA disconnect handler
255 * @iface: FST interface object
256 * @addr: Address of the disconnected STA
257 */
258void fst_notify_peer_disconnected(struct fst_iface *iface, const u8 *addr);
259
260/* FST module auxiliary routines */
261
262/**
263 * fst_are_ifaces_aggregated - Determines whether 2 interfaces belong to the
264 * same FST group
265 * @iface1: 1st FST interface object
266 * @iface1: 2nd FST interface object
267 *
268 * Returns: %TRUE if the interfaces belong to the same FST group,
269 * %FALSE otherwise
270 */
271Boolean fst_are_ifaces_aggregated(struct fst_iface *iface1,
272 struct fst_iface *iface2);
273
274#else /* CONFIG_FST */
275
276static inline int fst_global_init(void)
277{
278 return 0;
279}
280
281static inline int fst_global_start(void)
282{
283 return 0;
284}
285
286static inline void fst_global_stop(void)
287{
288}
289
290static inline void fst_global_deinit(void)
291{
292}
293
294#endif /* CONFIG_FST */
295
296#endif /* FST_H */