blob: f3aedc5198eb1c3721135186f99bd267b6b77324 [file] [log] [blame]
Tushar Mathurff8741b2015-12-02 20:28:59 +05301/*
2 **************************************************************************
Stephen Wang3e2dbd12018-03-14 17:28:17 -07003 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
Tushar Mathurff8741b2015-12-02 20:28:59 +05304 * 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 copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17#include "nss_tx_rx_common.h"
18#include "nss_dtls_stats.h"
Sachin Shashidhardd91a4d2018-06-04 14:52:12 -070019#include "nss_dtls_log.h"
Tushar Mathurff8741b2015-12-02 20:28:59 +053020
21#define NSS_DTLS_TX_TIMEOUT 3000 /* 3 Seconds */
22
23/*
24 * Data structures to store DTLS nss debug stats
25 */
Yu Huang8c107082017-07-24 14:58:26 -070026static DEFINE_SPINLOCK(nss_dtls_session_stats_lock);
27static struct nss_dtls_stats_session session_stats[NSS_MAX_DTLS_SESSIONS];
Tushar Mathurff8741b2015-12-02 20:28:59 +053028
29/*
30 * Private data structure
31 */
32static struct nss_dtls_pvt {
33 struct semaphore sem;
34 struct completion complete;
35 int response;
36 void *cb;
37 void *app_data;
38} dtls_pvt;
39
Tushar Mathurff8741b2015-12-02 20:28:59 +053040/*
41 * nss_dtls_verify_if_num()
42 * Verify if_num passed to us.
43 */
44static bool nss_dtls_verify_if_num(uint32_t if_num)
45{
46 if (nss_is_dynamic_interface(if_num) == false)
47 return false;
48
Stephen Wange8b8d0d2017-02-24 17:05:22 -080049 if (nss_dynamic_interface_get_type(nss_dtls_get_context(), if_num)
Tushar Mathurff8741b2015-12-02 20:28:59 +053050 != NSS_DYNAMIC_INTERFACE_TYPE_DTLS)
51 return false;
52
53 return true;
54}
55
56/*
57 * nss_dtls_session_stats_sync
58 * Per DTLS session debug stats
59 */
60static void nss_dtls_session_stats_sync(struct nss_ctx_instance *nss_ctx,
61 struct nss_dtls_session_stats *stats_msg,
62 uint16_t if_num)
63{
64 int i;
Yu Huang8c107082017-07-24 14:58:26 -070065 struct nss_dtls_stats_session *s = NULL;
Tushar Mathurff8741b2015-12-02 20:28:59 +053066
67 NSS_VERIFY_CTX_MAGIC(nss_ctx);
68
Yu Huang8c107082017-07-24 14:58:26 -070069 spin_lock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +053070 for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) {
Yu Huang8c107082017-07-24 14:58:26 -070071 if (session_stats[i].if_num != if_num) {
Tushar Mathurff8741b2015-12-02 20:28:59 +053072 continue;
73 }
74
Yu Huang8c107082017-07-24 14:58:26 -070075 s = &session_stats[i];
Tushar Mathurff8741b2015-12-02 20:28:59 +053076 break;
77 }
78
79 if (!s) {
Yu Huang8c107082017-07-24 14:58:26 -070080 spin_unlock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +053081 return;
82 }
83
Yu Huang8c107082017-07-24 14:58:26 -070084 s->stats[NSS_DTLS_STATS_SESSION_RX_PKTS] += stats_msg->node_stats.rx_packets;
85 s->stats[NSS_DTLS_STATS_SESSION_TX_PKTS] += stats_msg->node_stats.tx_packets;
ratheesh kannoth93ba95c2017-07-13 15:52:52 +053086 for (i = 0; i < NSS_MAX_NUM_PRI; i++) {
Yu Huang8c107082017-07-24 14:58:26 -070087 s->stats[NSS_DTLS_STATS_SESSION_RX_QUEUE_0_DROPPED + i] += stats_msg->node_stats.rx_dropped[i];
ratheesh kannoth93ba95c2017-07-13 15:52:52 +053088 }
Yu Huang8c107082017-07-24 14:58:26 -070089 s->stats[NSS_DTLS_STATS_SESSION_RX_AUTH_DONE] += stats_msg->rx_auth_done;
90 s->stats[NSS_DTLS_STATS_SESSION_TX_AUTH_DONE] += stats_msg->tx_auth_done;
91 s->stats[NSS_DTLS_STATS_SESSION_RX_CIPHER_DONE] += stats_msg->rx_cipher_done;
92 s->stats[NSS_DTLS_STATS_SESSION_TX_CIPHER_DONE] += stats_msg->tx_cipher_done;
93 s->stats[NSS_DTLS_STATS_SESSION_RX_CBUF_ALLOC_FAIL] += stats_msg->rx_cbuf_alloc_fail;
94 s->stats[NSS_DTLS_STATS_SESSION_TX_CBUF_ALLOC_FAIL] += stats_msg->tx_cbuf_alloc_fail;
95 s->stats[NSS_DTLS_STATS_SESSION_TX_CENQUEUE_FAIL] += stats_msg->tx_cenqueue_fail;
96 s->stats[NSS_DTLS_STATS_SESSION_RX_CENQUEUE_FAIL] += stats_msg->rx_cenqueue_fail;
97 s->stats[NSS_DTLS_STATS_SESSION_TX_DROPPED_HROOM] += stats_msg->tx_dropped_hroom;
98 s->stats[NSS_DTLS_STATS_SESSION_TX_DROPPED_TROOM] += stats_msg->tx_dropped_troom;
99 s->stats[NSS_DTLS_STATS_SESSION_TX_FORWARD_ENQUEUE_FAIL] += stats_msg->tx_forward_enqueue_fail;
100 s->stats[NSS_DTLS_STATS_SESSION_RX_FORWARD_ENQUEUE_FAIL] += stats_msg->rx_forward_enqueue_fail;
101 s->stats[NSS_DTLS_STATS_SESSION_RX_INVALID_VERSION] += stats_msg->rx_invalid_version;
102 s->stats[NSS_DTLS_STATS_SESSION_RX_INVALID_EPOCH] += stats_msg->rx_invalid_epoch;
103 s->stats[NSS_DTLS_STATS_SESSION_RX_MALFORMED] += stats_msg->rx_malformed;
104 s->stats[NSS_DTLS_STATS_SESSION_RX_CIPHER_FAIL] += stats_msg->rx_cipher_fail;
105 s->stats[NSS_DTLS_STATS_SESSION_RX_AUTH_FAIL] += stats_msg->rx_auth_fail;
106 s->stats[NSS_DTLS_STATS_SESSION_RX_CAPWAP_CLASSIFY_FAIL] += stats_msg->rx_capwap_classify_fail;
107 s->stats[NSS_DTLS_STATS_SESSION_RX_SINGLE_REC_DGRAM] += stats_msg->rx_single_rec_dgram;
108 s->stats[NSS_DTLS_STATS_SESSION_RX_MULTI_REC_DGRAM] += stats_msg->rx_multi_rec_dgram;
109 s->stats[NSS_DTLS_STATS_SESSION_RX_REPLAY_FAIL] += stats_msg->rx_replay_fail;
110 s->stats[NSS_DTLS_STATS_SESSION_RX_REPLAY_DUPLICATE] += stats_msg->rx_replay_duplicate;
111 s->stats[NSS_DTLS_STATS_SESSION_RX_REPLAY_OUT_OF_WINDOW] += stats_msg->rx_replay_out_of_window;
112 s->stats[NSS_DTLS_STATS_SESSION_OUTFLOW_QUEUE_FULL] += stats_msg->outflow_queue_full;
113 s->stats[NSS_DTLS_STATS_SESSION_DECAP_QUEUE_FULL] += stats_msg->decap_queue_full;
114 s->stats[NSS_DTLS_STATS_SESSION_PBUF_ALLOC_FAIL] += stats_msg->pbuf_alloc_fail;
115 s->stats[NSS_DTLS_STATS_SESSION_PBUF_COPY_FAIL] += stats_msg->pbuf_copy_fail;
116 s->stats[NSS_DTLS_STATS_SESSION_EPOCH] = stats_msg->epoch;
117 s->stats[NSS_DTLS_STATS_SESSION_TX_SEQ_HIGH] = stats_msg->tx_seq_high;
118 s->stats[NSS_DTLS_STATS_SESSION_TX_SEQ_LOW] = stats_msg->tx_seq_low;
119 spin_unlock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530120}
121
122/*
Yu Huang8c107082017-07-24 14:58:26 -0700123 * nss_dtls_session_stats_get()
Tushar Mathurff8741b2015-12-02 20:28:59 +0530124 * Get session DTLS statitics.
125 */
Yu Huang8c107082017-07-24 14:58:26 -0700126void nss_dtls_session_stats_get(struct nss_dtls_stats_session *stats)
Tushar Mathurff8741b2015-12-02 20:28:59 +0530127{
128 int i;
129
130 if (!stats) {
131 nss_warning("No memory to copy dtls session stats");
132 return;
133 }
134
Yu Huang8c107082017-07-24 14:58:26 -0700135 spin_lock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530136 for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) {
Yu Huang8c107082017-07-24 14:58:26 -0700137 if (session_stats[i].valid) {
138 memcpy(stats, &session_stats[i],
139 sizeof(struct nss_dtls_stats_session));
Tushar Mathurff8741b2015-12-02 20:28:59 +0530140 stats++;
141 }
142 }
Yu Huang8c107082017-07-24 14:58:26 -0700143 spin_unlock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530144}
145
146/*
147 * nss_dtls_handler()
148 * Handle NSS -> HLOS messages for dtls tunnel
149 */
150static void nss_dtls_handler(struct nss_ctx_instance *nss_ctx,
151 struct nss_cmn_msg *ncm,
152 __attribute__((unused))void *app_data)
153{
154 struct nss_dtls_msg *ntm = (struct nss_dtls_msg *)ncm;
155 void *ctx;
156
157 nss_dtls_msg_callback_t cb;
158
159 NSS_VERIFY_CTX_MAGIC(nss_ctx);
160 BUG_ON(!nss_dtls_verify_if_num(ncm->interface));
161
162 /*
163 * Is this a valid request/response packet?
164 */
165 if (ncm->type >= NSS_DTLS_MSG_MAX) {
166 nss_warning("%p: received invalid message %d "
167 "for DTLS interface %d",
168 nss_ctx, ncm->type, ncm->interface);
169 return;
170 }
171
Suruchi Agarwalef8a8702016-01-08 12:40:08 -0800172 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_dtls_msg)) {
Tushar Mathurff8741b2015-12-02 20:28:59 +0530173 nss_warning("%p: dtls message length is invalid: %d",
174 nss_ctx, ncm->len);
175 return;
176 }
177
178 switch (ntm->cm.type) {
179 case NSS_DTLS_MSG_SESSION_STATS:
180 nss_dtls_session_stats_sync(nss_ctx,
181 &ntm->msg.stats,
182 ncm->interface);
183 break;
184 }
185
186 /*
187 * Update the callback and app_data for NOTIFY messages
188 */
Suruchi Agarwale4ad24a2018-06-11 12:03:46 +0530189 if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) {
Stephen Wangaed46332016-12-12 17:29:03 -0800190 ncm->cb = (nss_ptr_t)nss_ctx->nss_top->dtls_msg_callback;
Stephen Wang84e0e992016-09-07 12:31:40 -0700191 ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data;
Tushar Mathurff8741b2015-12-02 20:28:59 +0530192 }
193
194 /*
195 * Log failures
196 */
197 nss_core_log_msg_failures(nss_ctx, ncm);
198
199 /*
Sachin Shashidhardd91a4d2018-06-04 14:52:12 -0700200 * Trace messages.
201 */
202 nss_dtls_log_rx_msg(ntm);
203
204 /*
Tushar Mathurff8741b2015-12-02 20:28:59 +0530205 * callback
206 */
207 cb = (nss_dtls_msg_callback_t)ncm->cb;
208 ctx = (void *)ncm->app_data;
209
210 /*
211 * call dtls session callback
212 */
213 if (!cb) {
214 nss_warning("%p: No callback for dtls session interface %d",
215 nss_ctx, ncm->interface);
216 return;
217 }
218
219 cb(ctx, ntm);
220}
221
222/*
223 * nss_dtls_callback()
224 * Callback to handle the completion of NSS->HLOS messages.
225 */
226static void nss_dtls_callback(void *app_data, struct nss_dtls_msg *nim)
227{
228 nss_dtls_msg_callback_t callback = (nss_dtls_msg_callback_t)dtls_pvt.cb;
229 void *data = dtls_pvt.app_data;
230
231 dtls_pvt.cb = NULL;
232 dtls_pvt.app_data = NULL;
233
234 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
235 nss_warning("dtls Error response %d\n", nim->cm.response);
236
237 dtls_pvt.response = NSS_TX_FAILURE;
238 if (callback) {
239 callback(data, nim);
240 }
241
242 complete(&dtls_pvt.complete);
243 return;
244 }
245
246 dtls_pvt.response = NSS_TX_SUCCESS;
247 if (callback) {
248 callback(data, nim);
249 }
250
251 complete(&dtls_pvt.complete);
252}
253
254/*
255 * nss_dtls_tx_buf()
256 * Transmit buffer over DTLS interface
257 */
258nss_tx_status_t nss_dtls_tx_buf(struct sk_buff *skb, uint32_t if_num,
259 struct nss_ctx_instance *nss_ctx)
260{
Tushar Mathurff8741b2015-12-02 20:28:59 +0530261 BUG_ON(!nss_dtls_verify_if_num(if_num));
262
Stephen Wang3e2dbd12018-03-14 17:28:17 -0700263 return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530264}
265EXPORT_SYMBOL(nss_dtls_tx_buf);
266
267/*
268 * nss_dtls_tx_msg()
269 * Transmit a DTLS message to NSS firmware
270 */
271nss_tx_status_t nss_dtls_tx_msg(struct nss_ctx_instance *nss_ctx,
272 struct nss_dtls_msg *msg)
273{
Tushar Mathurff8741b2015-12-02 20:28:59 +0530274 struct nss_cmn_msg *ncm = &msg->cm;
Tushar Mathurff8741b2015-12-02 20:28:59 +0530275
276 /*
277 * Sanity check the message
278 */
279 BUG_ON(!nss_dtls_verify_if_num(ncm->interface));
280
Tushar Mathurff8741b2015-12-02 20:28:59 +0530281 if (ncm->type > NSS_DTLS_MSG_MAX) {
282 nss_warning("%p: dtls message type out of range: %d",
283 nss_ctx, ncm->type);
284 return NSS_TX_FAILURE;
285 }
286
Sachin Shashidhardd91a4d2018-06-04 14:52:12 -0700287 /*
288 * Trace messages.
289 */
290 nss_dtls_log_tx_msg(msg);
291
Stephen Wang3e2dbd12018-03-14 17:28:17 -0700292 return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530293}
294EXPORT_SYMBOL(nss_dtls_tx_msg);
295
296/*
297 * nss_dtls_tx_msg()
298 * Transmit a DTLS message to NSS firmware synchronously.
299 */
300nss_tx_status_t nss_dtls_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_dtls_msg *msg)
301{
302
303 nss_tx_status_t status;
304 int ret = 0;
305
306 down(&dtls_pvt.sem);
307 dtls_pvt.cb = (void *)msg->cm.cb;
308 dtls_pvt.app_data = (void *)msg->cm.app_data;
309
Stephen Wangaed46332016-12-12 17:29:03 -0800310 msg->cm.cb = (nss_ptr_t)nss_dtls_callback;
311 msg->cm.app_data = (nss_ptr_t)NULL;
Tushar Mathurff8741b2015-12-02 20:28:59 +0530312
313 status = nss_dtls_tx_msg(nss_ctx, msg);
314 if (status != NSS_TX_SUCCESS) {
315 nss_warning("%p: dtls_tx_msg failed\n", nss_ctx);
316 up(&dtls_pvt.sem);
317 return status;
318 }
319
320 ret = wait_for_completion_timeout(&dtls_pvt.complete, msecs_to_jiffies(NSS_DTLS_TX_TIMEOUT));
321
322 if (!ret) {
323 nss_warning("%p: DTLS msg tx failed due to timeout\n", nss_ctx);
324 dtls_pvt.response = NSS_TX_FAILURE;
325 }
326
327 status = dtls_pvt.response;
328 up(&dtls_pvt.sem);
329 return status;
330}
331EXPORT_SYMBOL(nss_dtls_tx_msg_sync);
332
333/*
334 ***********************************
335 * Register/Unregister/Miscellaneous APIs
336 ***********************************
337 */
338
339/*
340 * nss_dtls_register_if()
341 */
342struct nss_ctx_instance *nss_dtls_register_if(uint32_t if_num,
343 nss_dtls_data_callback_t cb,
344 nss_dtls_msg_callback_t ev_cb,
345 struct net_device *netdev,
346 uint32_t features,
347 void *app_ctx)
348{
349 int32_t i;
350
351 struct nss_ctx_instance *nss_ctx = nss_dtls_get_context();
352
353 BUG_ON(!nss_dtls_verify_if_num(if_num));
354
Yu Huang8c107082017-07-24 14:58:26 -0700355 spin_lock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530356 for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) {
Yu Huang8c107082017-07-24 14:58:26 -0700357 if (!session_stats[i].valid) {
358 session_stats[i].valid = true;
359 session_stats[i].if_num = if_num;
360 session_stats[i].if_index = netdev->ifindex;
Tushar Mathurff8741b2015-12-02 20:28:59 +0530361 break;
362 }
363 }
Yu Huang8c107082017-07-24 14:58:26 -0700364 spin_unlock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530365
366 if (i == NSS_MAX_DTLS_SESSIONS) {
367 nss_warning("%p: Cannot find free slot for "
368 "DTLS session stats, I/F:%u\n", nss_ctx, if_num);
369 return NULL;
370 }
371
Stephen Wang84e0e992016-09-07 12:31:40 -0700372 if (nss_ctx->subsys_dp_register[if_num].ndev) {
Tushar Mathurff8741b2015-12-02 20:28:59 +0530373 nss_warning("%p: Cannot find free slot for "
374 "DTLS NSS I/F:%u\n", nss_ctx, if_num);
375
376 return NULL;
377 }
378
Jackson Bockus7ca70ec2017-07-17 13:47:29 -0700379 nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, app_ctx, netdev, features);
Tanmay V Jagdalea8533d52018-04-24 21:40:02 +0530380 nss_ctx->subsys_dp_register[if_num].type = NSS_DYNAMIC_INTERFACE_TYPE_DTLS;
Tushar Mathurff8741b2015-12-02 20:28:59 +0530381
382 nss_top_main.dtls_msg_callback = ev_cb;
Thomas Wu91f4bdf2017-06-09 12:03:02 -0700383 nss_core_register_handler(nss_ctx, if_num, nss_dtls_handler, app_ctx);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530384
Stephen Wang90c67de2016-04-26 15:15:59 -0700385 return nss_ctx;
Tushar Mathurff8741b2015-12-02 20:28:59 +0530386}
387EXPORT_SYMBOL(nss_dtls_register_if);
388
389/*
390 * nss_dtls_unregister_if()
391 */
392void nss_dtls_unregister_if(uint32_t if_num)
393{
Stephen Wang84e0e992016-09-07 12:31:40 -0700394 struct nss_ctx_instance *nss_ctx = nss_dtls_get_context();
Tushar Mathurff8741b2015-12-02 20:28:59 +0530395 int32_t i;
396
Tushar Mathurff8741b2015-12-02 20:28:59 +0530397 BUG_ON(!nss_dtls_verify_if_num(if_num));
398
Yu Huang8c107082017-07-24 14:58:26 -0700399 spin_lock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530400 for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) {
Yu Huang8c107082017-07-24 14:58:26 -0700401 if (session_stats[i].if_num == if_num) {
402 memset(&session_stats[i], 0,
403 sizeof(struct nss_dtls_stats_session));
Tushar Mathurff8741b2015-12-02 20:28:59 +0530404 break;
405 }
406 }
Yu Huang8c107082017-07-24 14:58:26 -0700407 spin_unlock_bh(&nss_dtls_session_stats_lock);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530408
409 if (i == NSS_MAX_DTLS_SESSIONS) {
Stephen Wang84e0e992016-09-07 12:31:40 -0700410 nss_warning("%p: Cannot find debug stats for DTLS session %d\n", nss_ctx, if_num);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530411 return;
412 }
413
Stephen Wang84e0e992016-09-07 12:31:40 -0700414 if (!nss_ctx->subsys_dp_register[if_num].ndev) {
415 nss_warning("%p: Cannot find registered netdev for DTLS NSS I/F:%u\n", nss_ctx, if_num);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530416
417 return;
418 }
419
Jackson Bockus7ca70ec2017-07-17 13:47:29 -0700420 nss_core_unregister_subsys_dp(nss_ctx, if_num);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530421
422 nss_top_main.dtls_msg_callback = NULL;
Thomas Wu91f4bdf2017-06-09 12:03:02 -0700423 nss_core_unregister_handler(nss_ctx, if_num);
Tushar Mathurff8741b2015-12-02 20:28:59 +0530424}
425EXPORT_SYMBOL(nss_dtls_unregister_if);
426
427/*
428 * nss_get_dtls_context()
429 */
430struct nss_ctx_instance *nss_dtls_get_context(void)
431{
432 return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.dtls_handler_id];
433}
434EXPORT_SYMBOL(nss_dtls_get_context);
435
436/*
437 * nss_dtls_msg_init()
438 * Initialize nss_dtls msg.
439 */
440void nss_dtls_msg_init(struct nss_dtls_msg *ncm, uint16_t if_num,
441 uint32_t type, uint32_t len, void *cb, void *app_data)
442{
443 nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data);
444}
445EXPORT_SYMBOL(nss_dtls_msg_init);
446
447/*
448 * nss_dtls_get_ifnum_with_coreid()
449 */
450int32_t nss_dtls_get_ifnum_with_coreid(int32_t if_num)
451{
452 struct nss_ctx_instance *nss_ctx = nss_dtls_get_context();
453
454 NSS_VERIFY_CTX_MAGIC(nss_ctx);
455 return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num);
456}
457EXPORT_SYMBOL(nss_dtls_get_ifnum_with_coreid);
458
459/*
460 * nss_dtls_register_handler()
461 */
462void nss_dtls_register_handler(void)
463{
464 sema_init(&dtls_pvt.sem, 1);
465 init_completion(&dtls_pvt.complete);
Yu Huang8c107082017-07-24 14:58:26 -0700466
467 nss_dtls_stats_dentry_create();
Tushar Mathurff8741b2015-12-02 20:28:59 +0530468}