blob: 16ea4c62c185c445181a69da19b744753eec5be7 [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
Chaithanya Garrepallid203e2d2018-09-18 14:23:17 +053096struct dp_ast_entry *dp_peer_ast_hash_find_by_pdevid(struct dp_soc *soc,
97 uint8_t *ast_mac_addr,
98 uint8_t pdev_id);
99
Tallapragada Kalyan1c14d5d2017-07-26 00:31:35 +0530100struct dp_ast_entry *dp_peer_ast_hash_find(struct dp_soc *soc,
Tallapragada Kalyan57b6bb32018-01-02 12:58:33 +0530101 uint8_t *ast_mac_addr);
102
103uint8_t dp_peer_ast_get_pdev_id(struct dp_soc *soc,
104 struct dp_ast_entry *ast_entry);
105
106
107uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
108 struct dp_ast_entry *ast_entry);
109
110void dp_peer_ast_set_type(struct dp_soc *soc,
111 struct dp_ast_entry *ast_entry,
112 enum cdp_txrx_ast_entry_type type);
Pamidipati, Vijayb8bbf162017-06-26 23:47:39 +0530113
Kiran Venkatappaed35f442018-07-19 22:22:29 +0530114#if defined(FEATURE_AST) && defined(AST_HKV1_WORKAROUND)
115void dp_peer_ast_set_cp_ctx(struct dp_soc *soc,
116 struct dp_ast_entry *ast_entry,
117 void *cp_ctx);
118
119void *dp_peer_ast_get_cp_ctx(struct dp_soc *soc,
120 struct dp_ast_entry *ast_entry);
121
122void dp_peer_ast_send_wds_del(struct dp_soc *soc,
123 struct dp_ast_entry *ast_entry);
124
125bool dp_peer_ast_get_wmi_sent(struct dp_soc *soc,
126 struct dp_ast_entry *ast_entry);
127
128void dp_peer_ast_free_entry(struct dp_soc *soc,
129 struct dp_ast_entry *ast_entry);
130
131#endif
132
Pramod Simhab17d0672017-03-06 17:20:13 -0800133/*
134 * dp_get_vdev_from_soc_vdev_id_wifi3() -
135 * Returns vdev object given the vdev id
136 * vdev id is unique across pdev's
137 *
138 * @soc : core DP soc context
139 * @vdev_id : vdev id from vdev object can be retrieved
140 *
141 * Return: struct dp_vdev*: Pointer to DP vdev object
142 */
143static inline struct dp_vdev *
144dp_get_vdev_from_soc_vdev_id_wifi3(struct dp_soc *soc,
145 uint8_t vdev_id)
146{
147 struct dp_pdev *pdev = NULL;
148 struct dp_vdev *vdev = NULL;
149 int i;
150
151 for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
152 pdev = soc->pdev_list[i];
153 TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
154 if (vdev->vdev_id == vdev_id) {
155 QDF_TRACE(QDF_MODULE_ID_DP,
156 QDF_TRACE_LEVEL_INFO,
Aditya Sathishded018e2018-07-02 16:25:21 +0530157 FL("Found vdev 0x%pK on pdev %d"),
Pramod Simhab17d0672017-03-06 17:20:13 -0800158 vdev, i);
159 return vdev;
160 }
161 }
162 }
163 return NULL;
164
165}
Jeff Johnson2cb8fc72016-12-17 10:45:08 -0800166#endif /* _DP_PEER_H_ */