1 /* 2 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 /** 28 * @file cdp_txrx_ctrl.h 29 * @brief Define the host data path control API functions 30 * called by the host control SW and the OS interface module 31 */ 32 33 #ifndef _CDP_TXRX_CTRL_H_ 34 #define _CDP_TXRX_CTRL_H_ 35 #include "cdp_txrx_handle.h" 36 37 static inline int cdp_is_target_ar900b 38 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 39 { 40 if (soc->ops->ctrl_ops->txrx_is_target_ar900b) 41 return soc->ops->ctrl_ops->txrx_is_target_ar900b(vdev); 42 return 0; 43 } 44 45 46 /* WIN */ 47 static inline int 48 cdp_mempools_attach(ol_txrx_soc_handle soc, void *ctrl_pdev) 49 { 50 if (soc->ops->ctrl_ops->txrx_mempools_attach) 51 return soc->ops->ctrl_ops->txrx_mempools_attach(ctrl_pdev); 52 return 0; 53 } 54 55 /** 56 * @brief set filter neighbour peers 57 * @details 58 * This defines interface function to set neighbour peer filtering. 59 * 60 * @param soc - the pointer to soc object 61 * @param pdev - the pointer physical device object 62 * @param val - the enable/disable value 63 * @return - int 64 */ 65 static inline int 66 cdp_set_filter_neighbour_peers(ol_txrx_soc_handle soc, 67 struct cdp_pdev *pdev, u_int32_t val) 68 { 69 if (soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers) 70 return soc->ops->ctrl_ops->txrx_set_filter_neighbour_peers 71 (pdev, val); 72 return 0; 73 } 74 75 /** 76 * @brief update the neighbour peer addresses 77 * @details 78 * This defines interface function to update neighbour peers addresses 79 * which needs to be filtered 80 * 81 * @param soc - the pointer to soc object 82 * @param pdev - the pointer to physical device object 83 * @param cmd - add/del entry into peer table 84 * @param macaddr - the address of neighbour peer 85 * @return - int 86 */ 87 static inline int 88 cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc, 89 struct cdp_pdev *pdev, uint32_t cmd, uint8_t *macaddr) 90 { 91 if (soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers) 92 return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers 93 (pdev, cmd, macaddr); 94 return 0; 95 } 96 97 /** 98 * @brief set the safemode of the device 99 * @details 100 * This flag is used to bypass the encrypt and decrypt processes when send and 101 * receive packets. It works like open AUTH mode, HW will treate all packets 102 * as non-encrypt frames because no key installed. For rx fragmented frames, 103 * it bypasses all the rx defragmentaion. 104 * 105 * @param vdev - the data virtual device object 106 * @param val - the safemode state 107 * @return - void 108 */ 109 static inline void 110 cdp_set_safemode(ol_txrx_soc_handle soc, 111 struct cdp_vdev *vdev, u_int32_t val) 112 { 113 if (soc->ops->ctrl_ops->txrx_set_safemode) 114 return soc->ops->ctrl_ops->txrx_set_safemode(vdev, val); 115 return; 116 } 117 /** 118 * @brief configure the drop unencrypted frame flag 119 * @details 120 * Rx related. When set this flag, all the unencrypted frames 121 * received over a secure connection will be discarded 122 * 123 * @param vdev - the data virtual device object 124 * @param val - flag 125 * @return - void 126 */ 127 static inline void 128 cdp_set_drop_unenc(ol_txrx_soc_handle soc, 129 struct cdp_vdev *vdev, u_int32_t val) 130 { 131 if (soc->ops->ctrl_ops->txrx_set_drop_unenc) 132 return soc->ops->ctrl_ops->txrx_set_drop_unenc(vdev, val); 133 return; 134 } 135 136 137 /** 138 * @brief set the Tx encapsulation type of the VDEV 139 * @details 140 * This will be used to populate the HTT desc packet type field during Tx 141 * 142 * @param vdev - the data virtual device object 143 * @param val - the Tx encap type (htt_cmn_pkt_type) 144 * @return - void 145 */ 146 static inline void 147 cdp_set_tx_encap_type(ol_txrx_soc_handle soc, 148 struct cdp_vdev *vdev, enum htt_cmn_pkt_type val) 149 { 150 if (soc->ops->ctrl_ops->txrx_set_tx_encap_type) 151 return soc->ops->ctrl_ops->txrx_set_tx_encap_type(vdev, val); 152 return; 153 } 154 155 /** 156 * @brief set the Rx decapsulation type of the VDEV 157 * @details 158 * This will be used to configure into firmware and hardware which format to 159 * decap all Rx packets into, for all peers under the VDEV. 160 * 161 * @param vdev - the data virtual device object 162 * @param val - the Rx decap mode (htt_cmn_pkt_type) 163 * @return - void 164 */ 165 static inline void 166 cdp_set_vdev_rx_decap_type(ol_txrx_soc_handle soc, 167 struct cdp_vdev *vdev, enum htt_cmn_pkt_type val) 168 { 169 if (soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type) 170 return soc->ops->ctrl_ops->txrx_set_vdev_rx_decap_type 171 (vdev, val); 172 return; 173 } 174 175 /** 176 * @brief get the Rx decapsulation type of the VDEV 177 * 178 * @param vdev - the data virtual device object 179 * @return - the Rx decap type (htt_cmn_pkt_type) 180 */ 181 static inline enum htt_cmn_pkt_type 182 cdp_get_vdev_rx_decap_type(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 183 { 184 if (soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type) 185 return soc->ops->ctrl_ops->txrx_get_vdev_rx_decap_type(vdev); 186 return 0; 187 } 188 189 /** 190 * @brief set the Reo Destination ring for the pdev 191 * @details 192 * This will be used to configure the Reo Destination ring for this pdev. 193 * 194 * @param soc - pointer to the soc 195 * @param pdev - the data physical device object 196 * @param val - the Reo destination ring index (1 to 4) 197 * @return - void 198 */ 199 static inline void 200 cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc, 201 struct cdp_pdev *pdev, enum cdp_host_reo_dest_ring val) 202 { 203 if (soc->ops->ctrl_ops->txrx_set_pdev_reo_dest) 204 return soc->ops->ctrl_ops->txrx_set_pdev_reo_dest 205 (pdev, val); 206 return; 207 } 208 209 /** 210 * @brief get the Reo Destination ring for the pdev 211 * 212 * @param soc - pointer to the soc 213 * @param pdev - the data physical device object 214 * @return - the Reo destination ring index (1 to 4), 0 if not supported. 215 */ 216 static inline enum cdp_host_reo_dest_ring 217 cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, struct cdp_pdev *pdev) 218 { 219 if (soc->ops->ctrl_ops->txrx_get_pdev_reo_dest) 220 return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(pdev); 221 return cdp_host_reo_dest_ring_unknown; 222 } 223 224 /* Is this similar to ol_txrx_peer_state_update() in MCL */ 225 /** 226 * @brief Update the authorize peer object at association time 227 * @details 228 * For the host-based implementation of rate-control, it 229 * updates the peer/node-related parameters within rate-control 230 * context of the peer at association. 231 * 232 * @param peer - pointer to the node's object 233 * @authorize - either to authorize or unauthorize peer 234 * 235 * @return none 236 */ 237 static inline void 238 cdp_peer_authorize(ol_txrx_soc_handle soc, 239 struct ol_txrx_peer_t *peer, u_int32_t authorize) 240 { 241 if (soc->ops->ctrl_ops->txrx_peer_authorize) 242 return soc->ops->ctrl_ops->txrx_peer_authorize 243 (peer, authorize); 244 return; 245 } 246 247 static inline bool 248 cdp_set_inact_params(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 249 u_int16_t inact_check_interval, 250 u_int16_t inact_normal, 251 u_int16_t inact_overload) 252 { 253 if (soc->ops->ctrl_ops->txrx_set_inact_params) 254 return soc->ops->ctrl_ops->txrx_set_inact_params 255 (pdev, inact_check_interval, inact_normal, 256 inact_overload); 257 return false; 258 } 259 static inline bool 260 cdp_start_inact_timer(ol_txrx_soc_handle soc, 261 struct cdp_pdev *pdev, 262 bool enable) 263 { 264 if (soc->ops->ctrl_ops->txrx_start_inact_timer) 265 return soc->ops->ctrl_ops->txrx_start_inact_timer 266 (pdev, enable); 267 return false; 268 } 269 270 /** 271 * @brief Set the overload status of the radio 272 * @details 273 * Set the overload status of the radio, updating the inactivity 274 * threshold and inactivity count for each node. 275 * 276 * @param pdev - the data physical device object 277 * @param overload - whether the radio is overloaded or not 278 */ 279 static inline void 280 cdp_set_overload(ol_txrx_soc_handle soc, struct cdp_pdev *pdev, 281 bool overload) 282 { 283 if (soc->ops->ctrl_ops->txrx_set_overload) 284 return soc->ops->ctrl_ops->txrx_set_overload(pdev, overload); 285 return; 286 } 287 288 /** 289 * @brief Check the inactivity status of the peer/node 290 * 291 * @param peer - pointer to the node's object 292 * @return true if the node is inactive; otherwise return false 293 */ 294 static inline bool 295 cdp_peer_is_inact(ol_txrx_soc_handle soc, void *peer) 296 { 297 if (soc->ops->ctrl_ops->txrx_peer_is_inact) 298 return soc->ops->ctrl_ops->txrx_peer_is_inact(peer); 299 return false; 300 } 301 302 /** 303 * @brief Mark inactivity status of the peer/node 304 * @details 305 * If it becomes active, reset inactivity count to reload value; 306 * if the inactivity status changed, notify umac band steering. 307 * 308 * @param peer - pointer to the node's object 309 * @param inactive - whether the node is inactive or not 310 */ 311 static inline void 312 cdp_mark_peer_inact(ol_txrx_soc_handle soc, 313 void *peer, 314 bool inactive) 315 { 316 if (soc->ops->ctrl_ops->txrx_mark_peer_inact) 317 return soc->ops->ctrl_ops->txrx_mark_peer_inact 318 (peer, inactive); 319 return; 320 } 321 322 323 /* Should be ol_txrx_ctrl_api.h */ 324 static inline void cdp_set_mesh_mode 325 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev, u_int32_t val) 326 { 327 if (soc->ops->ctrl_ops->txrx_set_mesh_mode) 328 return soc->ops->ctrl_ops->txrx_set_mesh_mode(vdev, val); 329 return; 330 } 331 332 /** 333 * @brief set mesh rx filter 334 * @details based on the bits enabled in the filter packets has to be dropped. 335 * 336 * @param soc - pointer to the soc 337 * @param vdev - the data virtual device object 338 * @param val - value to be set 339 * @return - void 340 */ 341 static inline 342 void cdp_set_mesh_rx_filter(ol_txrx_soc_handle soc, 343 struct cdp_vdev *vdev, uint32_t val) 344 { 345 if (soc->ops->ctrl_ops->txrx_set_mesh_rx_filter) 346 return soc->ops->ctrl_ops->txrx_set_mesh_rx_filter(vdev, val); 347 return; 348 } 349 350 static inline void cdp_tx_flush_buffers 351 (ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 352 { 353 if (soc->ops->ctrl_ops->tx_flush_buffers) 354 return soc->ops->ctrl_ops->tx_flush_buffers(vdev); 355 return; 356 } 357 358 static inline void cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc, 359 struct cdp_vdev *vdev, enum cdp_vdev_param_type type, 360 uint32_t val) 361 { 362 if (soc->ops->ctrl_ops->txrx_set_vdev_param) 363 return soc->ops->ctrl_ops->txrx_set_vdev_param(vdev, type, val); 364 return; 365 } 366 367 static inline void 368 cdp_peer_set_nawds(ol_txrx_soc_handle soc, 369 struct ol_txrx_peer_t *peer, uint8_t value) 370 { 371 if (soc->ops->ctrl_ops->txrx_peer_set_nawds) 372 return soc->ops->ctrl_ops->txrx_peer_set_nawds 373 (peer, value); 374 return; 375 } 376 377 /** 378 * @brief Subscribe to a specified WDI event. 379 * @details 380 * This function adds the provided wdi_event_subscribe object to a list of 381 * subscribers for the specified WDI event. 382 * When the event in question happens, each subscriber for the event will 383 * have their callback function invoked. 384 * The order in which callback functions from multiple subscribers are 385 * invoked is unspecified. 386 * 387 * @param soc - pointer to the soc 388 * @param pdev - the data physical device object 389 * @param event_cb_sub - the callback and context for the event subscriber 390 * @param event - which event's notifications are being subscribed to 391 * @return - int 392 */ 393 static inline int 394 cdp_wdi_event_sub(ol_txrx_soc_handle soc, 395 struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event) 396 { 397 if (!soc || !soc->ops || !soc->ops->ctrl_ops) { 398 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 399 "%s invalid instance", __func__); 400 return 0; 401 } 402 403 if (soc->ops->ctrl_ops->txrx_wdi_event_sub) 404 return soc->ops->ctrl_ops->txrx_wdi_event_sub 405 (pdev, event_cb_sub, event); 406 return 0; 407 } 408 409 /** 410 * @brief Unsubscribe from a specified WDI event. 411 * @details 412 * This function removes the provided event subscription object from the 413 * list of subscribers for its event. 414 * This function shall only be called if there was a successful prior call 415 * to event_sub() on the same wdi_event_subscribe object. 416 * 417 * @param soc - pointer to the soc 418 * @param pdev - the data physical device object 419 * @param event_cb_sub - the callback and context for the event subscriber 420 * @param event - which event's notifications are being subscribed to 421 * @return - int 422 */ 423 static inline int 424 cdp_wdi_event_unsub(ol_txrx_soc_handle soc, 425 struct cdp_pdev *pdev, void *event_cb_sub, uint32_t event) 426 { 427 if (!soc || !soc->ops || !soc->ops->ctrl_ops) { 428 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 429 "%s invalid instance", __func__); 430 return 0; 431 } 432 433 if (soc->ops->ctrl_ops->txrx_wdi_event_unsub) 434 return soc->ops->ctrl_ops->txrx_wdi_event_unsub 435 (pdev, event_cb_sub, event); 436 return 0; 437 } 438 #endif 439