blob: 2a456b81bca95973d3421e6d3feb93dd4ca750cf [file] [log] [blame]
Debashis Duttc4c52dc2016-10-04 17:12:23 -07001/*
Tallapragada Kalyan57b6bb32018-01-02 12:58:33 +05302 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Debashis Duttc4c52dc2016-10-04 17:12:23 -07003 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
Jeff Johnson2cb8fc72016-12-17 10:45:08 -080018#ifndef _DP_PEER_H_
19#define _DP_PEER_H_
Debashis Duttc4c52dc2016-10-04 17:12:23 -070020
21#include <qdf_types.h>
22#include <qdf_lock.h>
23#include "dp_types.h"
24
25#define DP_INVALID_PEER_ID 0xffff
Debashis Duttc4c52dc2016-10-04 17:12:23 -070026/**
Chaithanya Garrepalli974da262018-02-22 20:32:19 +053027 * __dp_peer_find_by_id() - Returns peer object given the peer id
Debashis Duttc4c52dc2016-10-04 17:12:23 -070028 *
29 * @soc : core DP soc context
30 * @peer_id : peer id from peer object can be retrieved
31 *
32 * Return: struct dp_peer*: Pointer to DP peer object
33 */
34static inline struct dp_peer *
Chaithanya Garrepalli974da262018-02-22 20:32:19 +053035__dp_peer_find_by_id(struct dp_soc *soc,
Debashis Duttc4c52dc2016-10-04 17:12:23 -070036 uint16_t peer_id)
37{
38 struct dp_peer *peer;
39
40 /* TODO: Hold lock */
41 peer = (peer_id >= soc->max_peers) ? NULL :
42 soc->peer_id_to_obj_map[peer_id];
43
44 return peer;
45}
Jeff Johnson2cb8fc72016-12-17 10:45:08 -080046
Chaithanya Garrepalli974da262018-02-22 20:32:19 +053047/**
48 * dp_peer_find_by_id() - Returns peer object given the peer id
49 * if delete_in_progress in not set for peer
50 *
51 * @soc : core DP soc context
52 * @peer_id : peer id from peer object can be retrieved
53 *
54 * Return: struct dp_peer*: Pointer to DP peer object
55 */
56static inline struct dp_peer *
57dp_peer_find_by_id(struct dp_soc *soc,
58 uint16_t peer_id)
59{
60 struct dp_peer *peer;
61
62 peer = __dp_peer_find_by_id (soc, peer_id);
63
64 if (peer && peer->delete_in_progress) {
65 return NULL;
66 }
67
68 return peer;
69}
70
Jeff Johnson2cb8fc72016-12-17 10:45:08 -080071void dp_rx_peer_map_handler(void *soc_handle, uint16_t peer_id,
Chaithanya Garrepalli3e93e5f2018-09-12 17:02:31 +053072 uint16_t hw_peer_id, uint8_t vdev_id,
73 uint8_t *peer_mac_addr, uint16_t ast_hash,
74 uint8_t is_wds);
75void dp_rx_peer_unmap_handler(void *soc_handle, uint16_t peer_id,
76 uint8_t vdev_id, uint8_t *peer_mac_addr,
77 uint8_t is_wds);
Jeff Johnson2cb8fc72016-12-17 10:45:08 -080078void dp_rx_sec_ind_handler(void *soc_handle, uint16_t peer_id,
79 enum htt_sec_type sec_type, int is_unicast,
80 u_int32_t *michael_key, u_int32_t *rx_pn);
Ishank Jain1e7401c2017-02-17 15:38:39 +053081uint8_t dp_get_peer_mac_addr_frm_id(struct cdp_soc_t *soc_handle,
82 uint16_t peer_id, uint8_t *peer_mac);
Jeff Johnson2cb8fc72016-12-17 10:45:08 -080083
Pamidipati, Vijayb8bbf162017-06-26 23:47:39 +053084int dp_peer_add_ast(struct dp_soc *soc, struct dp_peer *peer,
Tallapragada Kalyan57b6bb32018-01-02 12:58:33 +053085 uint8_t *mac_addr, enum cdp_txrx_ast_entry_type type,
86 uint32_t flags);
87
88void dp_peer_del_ast(struct dp_soc *soc, struct dp_ast_entry *ast_entry);
89
Chaithanya Garrepalli3e93e5f2018-09-12 17:02:31 +053090void dp_peer_ast_unmap_handler(struct dp_soc *soc,
91 struct dp_ast_entry *ast_entry);
92
Tallapragada Kalyan57b6bb32018-01-02 12:58:33 +053093int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
94 struct dp_ast_entry *ast_entry, uint32_t flags);
95
Tallapragada Kalyan1c14d5d2017-07-26 00:31:35 +053096struct dp_ast_entry *dp_peer_ast_hash_find(struct dp_soc *soc,
Tallapragada Kalyan57b6bb32018-01-02 12:58:33 +053097 uint8_t *ast_mac_addr);
98
99uint8_t dp_peer_ast_get_pdev_id(struct dp_soc *soc,
100 struct dp_ast_entry *ast_entry);
101
102
103uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
104 struct dp_ast_entry *ast_entry);
105
106void dp_peer_ast_set_type(struct dp_soc *soc,
107 struct dp_ast_entry *ast_entry,
108 enum cdp_txrx_ast_entry_type type);
Pamidipati, Vijayb8bbf162017-06-26 23:47:39 +0530109
Pramod Simhab17d0672017-03-06 17:20:13 -0800110/*
111 * dp_get_vdev_from_soc_vdev_id_wifi3() -
112 * Returns vdev object given the vdev id
113 * vdev id is unique across pdev's
114 *
115 * @soc : core DP soc context
116 * @vdev_id : vdev id from vdev object can be retrieved
117 *
118 * Return: struct dp_vdev*: Pointer to DP vdev object
119 */
120static inline struct dp_vdev *
121dp_get_vdev_from_soc_vdev_id_wifi3(struct dp_soc *soc,
122 uint8_t vdev_id)
123{
124 struct dp_pdev *pdev = NULL;
125 struct dp_vdev *vdev = NULL;
126 int i;
127
128 for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
129 pdev = soc->pdev_list[i];
130 TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
131 if (vdev->vdev_id == vdev_id) {
132 QDF_TRACE(QDF_MODULE_ID_DP,
133 QDF_TRACE_LEVEL_INFO,
Aditya Sathishded018e2018-07-02 16:25:21 +0530134 FL("Found vdev 0x%pK on pdev %d"),
Pramod Simhab17d0672017-03-06 17:20:13 -0800135 vdev, i);
136 return vdev;
137 }
138 }
139 }
140 return NULL;
141
142}
Jeff Johnson2cb8fc72016-12-17 10:45:08 -0800143#endif /* _DP_PEER_H_ */