[RAMEN9610-20413][9610] wlbt: SCSC Driver version 10.6.1.0
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / drivers / net / wireless / scsc / test / hip_test.c
1 /******************************************************************************
2 *
3 * Copyright (c) 2012 - 2018 Samsung Electronics Co., Ltd. All rights reserved
4 *
5 *****************************************************************************/
6
7 #include <linux/kthread.h>
8
9 #include "unittest.h"
10 #include "hip.h"
11 #include "sap.h"
12 #include "debug.h"
13 #include "procfs.h"
14 #include "hip4.h"
15
16 #define SLSI_TEST_DEV_SDIO_BLOCK_SIZE 500
17 bool hip4_sampler_sample_start_stop_q = true;
18 struct hip4_hip_control test_hip_control;
19
20 /* SAP implementations container. Local and static to hip */
21 static struct hip_sap {
22 struct sap_api *sap[SAP_TOTAL];
23 } hip_sap_cont;
24
25 /* Register SAP with HIP layer */
26 int slsi_hip_sap_register(struct sap_api *sap_api)
27 {
28 u8 class = sap_api->sap_class;
29
30 if (class >= SAP_TOTAL)
31 return -ENODEV;
32
33 hip_sap_cont.sap[class] = sap_api;
34
35 return 0;
36 }
37
38 /* UNregister SAP with HIP layer */
39 int slsi_hip_sap_unregister(struct sap_api *sap_api)
40 {
41 u8 class = sap_api->sap_class;
42
43 if (class >= SAP_TOTAL)
44 return -ENODEV;
45
46 hip_sap_cont.sap[class] = NULL;
47
48 return 0;
49 }
50
51 int slsi_hip_sap_setup(struct slsi_dev *sdev)
52 {
53 /* Execute callbacks to intorm Supported version */
54 u16 version = 0;
55
56 if (hip_sap_cont.sap[SAP_MLME]->sap_version_supported) {
57 version = scsc_wifi_get_hip_config_version_4_u16(&sdev->hip4_inst.hip_control->config_v4, sap_mlme_ver);
58 if (hip_sap_cont.sap[SAP_MLME]->sap_version_supported(version))
59 return -ENODEV;
60 } else {
61 return -ENODEV;
62 }
63
64 if (hip_sap_cont.sap[SAP_MA]->sap_version_supported) {
65 version = scsc_wifi_get_hip_config_version_4_u16(&sdev->hip4_inst.hip_control->config_v4, sap_ma_ver);
66 if (hip_sap_cont.sap[SAP_MA]->sap_version_supported(version))
67 return -ENODEV;
68 } else {
69 return -ENODEV;
70 }
71
72 if (hip_sap_cont.sap[SAP_DBG]->sap_version_supported) {
73 version = scsc_wifi_get_hip_config_version_4_u16(&sdev->hip4_inst.hip_control->config_v4, sap_debug_ver);
74 if (hip_sap_cont.sap[SAP_DBG]->sap_version_supported(version))
75 return -ENODEV;
76 } else {
77 return -ENODEV;
78 }
79
80 if (hip_sap_cont.sap[SAP_TST]->sap_version_supported) {
81 version = scsc_wifi_get_hip_config_version_4_u16(&sdev->hip4_inst.hip_control->config_v4, sap_test_ver);
82 if (hip_sap_cont.sap[SAP_TST]->sap_version_supported(version))
83 return -ENODEV;
84 } else {
85 return -ENODEV;
86 }
87
88 /* Success */
89 return 0;
90 }
91
92 /* SAP rx proxy */
93 int slsi_hip_rx(struct slsi_dev *sdev, struct sk_buff *skb)
94 {
95 u16 pid;
96
97 /* Udi test : If pid in UDI range then pass to UDI and ignore */
98 slsi_log_clients_log_signal_fast(sdev, &sdev->log_clients, skb, SLSI_LOG_DIRECTION_TO_HOST);
99 pid = fapi_get_u16(skb, receiver_pid);
100 if (pid >= SLSI_TX_PROCESS_ID_UDI_MIN && pid <= SLSI_TX_PROCESS_ID_UDI_MAX) {
101 slsi_kfree_skb(skb);
102 return 0;
103 }
104
105 if (fapi_is_ma(skb))
106 return hip_sap_cont.sap[SAP_MA]->sap_handler(sdev, skb);
107
108 if (fapi_is_mlme(skb))
109 return hip_sap_cont.sap[SAP_MLME]->sap_handler(sdev, skb);
110
111 if (fapi_is_debug(skb))
112 return hip_sap_cont.sap[SAP_DBG]->sap_handler(sdev, skb);
113
114 if (fapi_is_test(skb))
115 return hip_sap_cont.sap[SAP_TST]->sap_handler(sdev, skb);
116
117 return -EIO;
118 }
119
120 /* value used at all levels in the driver */
121 int slsi_hip_init(struct slsi_dev *sdev, struct device *dev)
122 {
123 SLSI_UNUSED_PARAMETER(dev);
124
125 memset(&sdev->hip, 0, sizeof(sdev->hip));
126
127 sdev->hip.sdev = sdev;
128 mutex_init(&sdev->hip.hip_mutex);
129
130 sdev->hip4_inst.hip_control = &test_hip_control;
131 return 0;
132 }
133
134 void slsi_hip_deinit(struct slsi_dev *sdev)
135 {
136 mutex_destroy(&sdev->hip.hip_mutex);
137 }
138
139 int slsi_hip_stop(struct slsi_dev *sdev)
140 {
141 return 0;
142 }
143
144 int hip4_free_ctrl_slots_count(struct slsi_hip4 *hip)
145 {
146 return HIP4_CTL_SLOTS;
147 }
148
149 int scsc_wifi_transmit_frame(struct slsi_hip4 *hip, bool ctrl_packet, struct sk_buff *skb)
150 {
151 struct slsi_dev *sdev = container_of(hip, struct slsi_dev, hip4_inst);
152
153 slsi_log_clients_log_signal_fast(sdev, &sdev->log_clients, skb, SLSI_LOG_DIRECTION_FROM_HOST);
154
155 slsi_kfree_skb(skb);
156
157 return 0;
158 }
159
160 void slsi_test_bh_work_f(struct work_struct *work)
161 {
162 }
163
164 /* ALL Dummies to get UT build through goes below */
165 bool hip4_sampler_sample_q;
166 bool hip4_sampler_sample_qref;
167 bool hip4_sampler_sample_int;
168 bool hip4_sampler_sample_fapi;
169 bool hip4_sampler_sample_through;
170 bool hip4_sampler_sample_start_stop_q;
171 bool hip4_sampler_sample_mbulk;
172 bool hip4_sampler_sample_qfull;
173 bool hip4_sampler_sample_mfull;
174 bool hip4_sampler_vif;
175 bool hip4_sampler_bot;
176 bool hip4_sampler_pkt_tx;
177
178 void hip4_sampler_update_record(u32 minor, u8 param1, u8 param2, u8 param3, u8 param4)
179 {
180 }
181
182 void hip4_sampler_create(struct slsi_dev *sdev, struct scsc_mx *mx)
183 {
184 }
185
186 void hip4_sampler_destroy(struct slsi_dev *sdev, struct scsc_mx *mx)
187 {
188 }
189
190 int hip4_sampler_register_hip(struct scsc_mx *mx)
191 {
192 return 0;
193 }
194
195 int scsc_wifi_fcq_ctrl_q_init(struct scsc_wifi_fcq_ctrl_q *queue)
196 {
197 return 0;
198 }
199
200 void scsc_wifi_fcq_ctrl_q_deinit(struct scsc_wifi_fcq_ctrl_q *queue)
201 {
202 }
203
204 int scsc_wifi_fcq_unicast_qset_init(struct net_device *dev, struct scsc_wifi_fcq_data_qset *qs, u8 qs_num, struct slsi_dev *sdev, u8 vif, struct slsi_peer *peer)
205 {
206 return 0;
207 }
208
209 int scsc_wifi_fcq_multicast_qset_init(struct net_device *dev, struct scsc_wifi_fcq_data_qset *qs, struct slsi_dev *sdev, u8 vif)
210 {
211 return 0;
212 }
213
214 void scsc_wifi_fcq_qset_deinit(struct net_device *dev, struct scsc_wifi_fcq_data_qset *qs, struct slsi_dev *sdev, u8 vif, struct slsi_peer *peer)
215 {
216 }
217
218 int scsc_wifi_fcq_transmit_data(struct net_device *dev, struct scsc_wifi_fcq_data_qset *qs, u16 priority, struct slsi_dev *sdev, u8 vif, u8 peer_index)
219 {
220 return 0;
221 }
222
223 int scsc_wifi_fcq_receive_data(struct net_device *dev, struct scsc_wifi_fcq_data_qset *qs, u16 priority, struct slsi_dev *sdev, u8 vif, u8 peer_index)
224 {
225 return 0;
226 }
227
228 int scsc_wifi_fcq_receive_data_no_peer(struct net_device *dev, u16 priority, struct slsi_dev *sdev, u8 vif, u8 peer_index)
229 {
230 return 0;
231 }
232
233 void scsc_wifi_fcq_pause_queues(struct slsi_dev *sdev)
234 {
235 }
236
237 void scsc_wifi_fcq_unpause_queues(struct slsi_dev *sdev)
238 {
239 }
240
241 int scsc_wifi_fcq_transmit_ctrl(struct net_device *dev, struct scsc_wifi_fcq_ctrl_q *queue)
242 {
243 return 0;
244 }
245
246 int scsc_wifi_fcq_receive_ctrl(struct net_device *dev, struct scsc_wifi_fcq_ctrl_q *queue)
247 {
248 return 0;
249 }
250
251 int scsc_wifi_fcq_update_smod(struct scsc_wifi_fcq_data_qset *qs, enum scsc_wifi_fcq_ps_state peer_ps_state,
252 enum scsc_wifi_fcq_queue_set_type type)
253 {
254 return 0;
255 }
256
257 int scsc_wifi_fcq_8021x_port_state(struct net_device *dev, struct scsc_wifi_fcq_data_qset *qs, enum scsc_wifi_fcq_8021x_state state)
258 {
259 return 0;
260 }
261
262 int scsc_wifi_fcq_stat_queue(struct scsc_wifi_fcq_q_header *queue,
263 struct scsc_wifi_fcq_q_stat *queue_stat,
264 int *qmod, int *qcod)
265 {
266 return 0;
267 }
268
269 int scsc_wifi_fcq_stat_queueset(struct scsc_wifi_fcq_data_qset *queue_set,
270 struct scsc_wifi_fcq_q_stat *queue_stat,
271 int *smod, int *scod, enum scsc_wifi_fcq_8021x_state *cp_state,
272 u32 *peer_ps_state_transitions)
273 {
274 return 0;
275 }
276