Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2011, 2015 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 | /** |
| 29 | * @file ol_txrx_peer_find.h |
| 30 | * @brief Define the API for the rx peer lookup datapath module. |
| 31 | */ |
| 32 | #ifndef _OL_TXRX_PEER_FIND__H_ |
| 33 | #define _OL_TXRX_PEER_FIND__H_ |
| 34 | |
| 35 | #include <htt.h> /* HTT_INVALID_PEER */ |
| 36 | #include <ol_txrx_types.h> /* ol_txrx_pdev_t, etc. */ |
| 37 | #include <ol_txrx_internal.h> /* TXRX_ASSERT */ |
| 38 | |
| 39 | int ol_txrx_peer_find_attach(struct ol_txrx_pdev_t *pdev); |
| 40 | |
| 41 | void ol_txrx_peer_find_detach(struct ol_txrx_pdev_t *pdev); |
| 42 | |
| 43 | static inline |
| 44 | int |
| 45 | ol_txrx_peer_find_mac_addr_cmp(union ol_txrx_align_mac_addr_t *mac_addr1, |
| 46 | union ol_txrx_align_mac_addr_t *mac_addr2) |
| 47 | { |
| 48 | return !((mac_addr1->align4.bytes_abcd == mac_addr2->align4.bytes_abcd) |
| 49 | /* |
| 50 | * Intentionally use & rather than &&. |
| 51 | * because the operands are binary rather than generic bool, |
| 52 | * the functionality is equivalent. |
| 53 | * Using && has the advantage of short-circuited evaluation, |
| 54 | * but using & has the advantage of no conditional branching, |
| 55 | * which is a more significant benefit. |
| 56 | */ |
| 57 | & (mac_addr1->align4.bytes_ef == mac_addr2->align4.bytes_ef)); |
| 58 | } |
| 59 | |
| 60 | static inline |
| 61 | struct ol_txrx_peer_t *ol_txrx_peer_find_by_id(struct ol_txrx_pdev_t *pdev, |
| 62 | uint16_t peer_id) |
| 63 | { |
| 64 | struct ol_txrx_peer_t *peer; |
| 65 | peer = (peer_id > ol_cfg_max_peer_id(pdev->ctrl_pdev)) ? NULL : |
| 66 | pdev->peer_id_to_obj_map[peer_id]; |
| 67 | /* |
| 68 | * Currently, peer IDs are assigned to vdevs as well as peers. |
| 69 | * If the peer ID is for a vdev, the peer_id_to_obj_map entry |
| 70 | * will hold NULL rather than a valid peer pointer. |
| 71 | */ |
| 72 | /* TXRX_ASSERT2(peer != NULL); */ |
| 73 | /* |
| 74 | * Only return the peer object if it is valid, |
| 75 | * i.e. it has not already been detached. |
| 76 | * If it has already been detached, then returning the |
| 77 | * peer object could result in unpausing the peer's tx queues |
| 78 | * in HL systems, which is an invalid operation following peer_detach. |
| 79 | */ |
| 80 | if (peer && peer->valid) |
| 81 | return peer; |
| 82 | |
| 83 | return NULL; |
| 84 | } |
| 85 | |
| 86 | void |
| 87 | ol_txrx_peer_find_hash_add(struct ol_txrx_pdev_t *pdev, |
| 88 | struct ol_txrx_peer_t *peer); |
| 89 | |
| 90 | struct ol_txrx_peer_t *ol_txrx_peer_find_hash_find(struct ol_txrx_pdev_t *pdev, |
| 91 | uint8_t *peer_mac_addr, |
| 92 | int mac_addr_is_aligned, |
| 93 | uint8_t check_valid); |
| 94 | |
| 95 | struct |
| 96 | ol_txrx_peer_t *ol_txrx_peer_vdev_find_hash(struct ol_txrx_pdev_t *pdev, |
| 97 | struct ol_txrx_vdev_t *vdev, |
| 98 | uint8_t *peer_mac_addr, |
| 99 | int mac_addr_is_aligned, |
| 100 | uint8_t check_valid); |
| 101 | |
| 102 | void |
| 103 | ol_txrx_peer_find_hash_remove(struct ol_txrx_pdev_t *pdev, |
| 104 | struct ol_txrx_peer_t *peer); |
| 105 | |
| 106 | void ol_txrx_peer_find_hash_erase(struct ol_txrx_pdev_t *pdev); |
| 107 | |
| 108 | struct ol_txrx_peer_t *ol_txrx_assoc_peer_find(struct ol_txrx_vdev_t *vdev); |
| 109 | |
| 110 | #if defined(TXRX_DEBUG_LEVEL) && TXRX_DEBUG_LEVEL > 5 |
| 111 | void ol_txrx_peer_find_display(ol_txrx_pdev_handle pdev, int indent); |
| 112 | #else |
| 113 | #define ol_txrx_peer_find_display(pdev, indent) |
| 114 | #endif /* TXRX_DEBUG_LEVEL */ |
| 115 | |
| 116 | #endif /* _OL_TXRX_PEER_FIND__H_ */ |