xref: /wlan-driver/qcacld-3.0/components/dp/core/src/wlan_dp_nud_tracking.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
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  */
18 
19 /**
20  * DOC: contains nud event tracking function declarations
21  */
22 
23 #ifndef _WLAN_DP_NUD_TRACKING_H_
24 #define _WLAN_DP_NUD_TRACKING_H_
25 
26 #ifdef WLAN_NUD_TRACKING
27 
28 /**
29  * struct dp_nud_tx_rx_stats - Capture tx and rx count during NUD tracking
30  * @pre_tx_packets: Number of tx packets at NUD_PROBE event
31  * @pre_tx_acked: Number of tx acked at NUD_PROBE event
32  * @pre_rx_packets: Number of rx packets at NUD_PROBE event
33  * @post_tx_packets: Number of tx packets at NUD_FAILED event
34  * @post_tx_acked: Number of tx acked at NUD_FAILED event
35  * @post_rx_packets: Number of rx packets at NUD_FAILED event
36  * @gw_rx_packets: Number of rx packets from the registered gateway
37  *                 during the period from NUD_PROBE to NUD_FAILED
38  */
39 struct dp_nud_tx_rx_stats {
40 	uint32_t pre_tx_packets;
41 	uint32_t pre_tx_acked;
42 	uint32_t pre_rx_packets;
43 	uint32_t post_tx_packets;
44 	uint32_t post_tx_acked;
45 	uint32_t post_rx_packets;
46 	qdf_atomic_t gw_rx_packets;
47 };
48 
49  /**
50   * struct dp_nud_tracking_info - structure to keep track for NUD information
51   * @curr_state: current state of NUD machine
52   * @ignore_nud_tracking: true if nud tracking is not required else false
53   * @tx_rx_stats: Number of packets during NUD tracking
54   * @gw_mac_addr: gateway mac address for which NUD events are tracked
55   * @nud_event_work: work to be scheduled during NUD_FAILED
56   * @is_gw_rx_pkt_track_enabled: true if rx pkt capturing is enabled for GW,
57   *                              else false
58   * @is_gw_updated: true if GW is updated for NUD Tracking
59   */
60 struct dp_nud_tracking_info {
61 	uint8_t curr_state;
62 	bool ignore_nud_tracking;
63 	struct dp_nud_tx_rx_stats tx_rx_stats;
64 	struct qdf_mac_addr gw_mac_addr;
65 	qdf_work_t nud_event_work;
66 	bool is_gw_rx_pkt_track_enabled;
67 	bool is_gw_updated;
68 };
69 
70 /**
71  * dp_nud_set_gateway_addr() - set gateway mac address
72  * @vdev: vdev handle
73  * @gw_mac_addr: mac address to be set
74  *
75  * Return: none
76  */
77 void dp_nud_set_gateway_addr(struct wlan_objmgr_vdev *vdev,
78 			     struct qdf_mac_addr gw_mac_addr);
79 
80 /**
81  * dp_nud_incr_gw_rx_pkt_cnt() - Increment rx count for gateway
82  * @dp_intf: Pointer to DP interface
83  * @mac_addr: Gateway mac address
84  *
85  * Return: None
86  */
87 void dp_nud_incr_gw_rx_pkt_cnt(struct wlan_dp_intf *dp_intf,
88 			       struct qdf_mac_addr *mac_addr);
89 
90 /**
91  * dp_nud_init_tracking() - initialize NUD tracking
92  * @dp_intf: Pointer to dp interface
93  *
94  * Return: None
95  */
96 void dp_nud_init_tracking(struct wlan_dp_intf *dp_intf);
97 
98 /**
99  * dp_nud_reset_tracking() - reset NUD tracking
100  * @dp_intf: Pointer to dp interface
101  *
102  * Return: None
103  */
104 void dp_nud_reset_tracking(struct wlan_dp_intf *dp_intf);
105 
106 /**
107  * dp_nud_deinit_tracking() - deinitialize NUD tracking
108  * @dp_intf: Pointer to dp interface
109  *
110  * Return: None
111  */
112 void dp_nud_deinit_tracking(struct wlan_dp_intf *dp_intf);
113 
114 /**
115  * dp_nud_ignore_tracking() - set/reset nud trackig status
116  * @dp_intf: Pointer to dp interface
117  * @ignoring: Ignore status to set
118  *
119  * Return: None
120  */
121 void dp_nud_ignore_tracking(struct wlan_dp_intf *dp_intf,
122 			    bool ignoring);
123 
124 /**
125  * dp_nud_flush_work() - flush pending nud work
126  * @dp_intf: Pointer to dp interface
127  *
128  * Return: None
129  */
130 void dp_nud_flush_work(struct wlan_dp_intf *dp_intf);
131 
132 /**
133  * dp_nud_indicate_roam() - reset NUD when roaming happens
134  * @vdev: vdev handle
135  *
136  * Return: None
137  */
138 void dp_nud_indicate_roam(struct wlan_objmgr_vdev *vdev);
139 
140 /**
141  * dp_nud_netevent_cb() - netevent callback
142  * @netdev_addr: netdev_addr
143  * @gw_mac_addr: Gateway MAC address
144  * @nud_state : NUD State
145  *
146  * Return: None
147  */
148 void dp_nud_netevent_cb(struct qdf_mac_addr *netdev_addr,
149 			struct qdf_mac_addr *gw_mac_addr, uint8_t nud_state);
150 #else
dp_nud_set_gateway_addr(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr gw_mac_addr)151 static inline void dp_nud_set_gateway_addr(struct wlan_objmgr_vdev *vdev,
152 					   struct qdf_mac_addr gw_mac_addr)
153 {
154 }
155 
dp_nud_incr_gw_rx_pkt_cnt(struct wlan_dp_intf * dp_intf,struct qdf_mac_addr * mac_addr)156 static inline void dp_nud_incr_gw_rx_pkt_cnt(struct wlan_dp_intf *dp_intf,
157 					     struct qdf_mac_addr *mac_addr)
158 {
159 }
160 
dp_nud_init_tracking(struct wlan_dp_intf * dp_intf)161 static inline void dp_nud_init_tracking(struct wlan_dp_intf *dp_intf)
162 {
163 }
164 
dp_nud_reset_tracking(struct wlan_dp_intf * dp_intf)165 static inline void dp_nud_reset_tracking(struct wlan_dp_intf *dp_intf)
166 {
167 }
168 
dp_nud_deinit_tracking(struct wlan_dp_intf * dp_intf)169 static inline void dp_nud_deinit_tracking(struct wlan_dp_intf *dp_intf)
170 {
171 }
172 
dp_nud_ignore_tracking(struct wlan_dp_intf * dp_intf,bool status)173 static inline void dp_nud_ignore_tracking(struct wlan_dp_intf *dp_intf,
174 					  bool status)
175 {
176 }
177 
178 static inline void
dp_nud_flush_work(struct wlan_dp_intf * dp_intf)179 dp_nud_flush_work(struct wlan_dp_intf *dp_intf)
180 {
181 }
182 
183 static inline void
dp_nud_indicate_roam(struct wlan_objmgr_vdev * vdev)184 dp_nud_indicate_roam(struct wlan_objmgr_vdev *vdev)
185 {
186 }
187 
188 static inline
dp_nud_netevent_cb(struct qdf_mac_addr * netdev_addr,struct qdf_mac_addr * gw_mac_addr,uint8_t nud_state)189 void dp_nud_netevent_cb(struct qdf_mac_addr *netdev_addr,
190 			struct qdf_mac_addr *gw_mac_addr, uint8_t nud_state)
191 {
192 }
193 #endif /* WLAN_NUD_TRACKING */
194 #endif /* end  of _WLAN_NUD_TRACKING_H_ */
195