blob: 6fda9c7f1f584f445abad2b016698d4fcce94ac2 [file] [log] [blame]
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +05301/*
2 **************************************************************************
3 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE
16 **************************************************************************
17 */
18
19#include "nss_tx_rx_common.h"
20#include "nss_tls_log.h"
21
22#define NSS_TLS_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES)
23#define NSS_TLS_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32)
24#define NSS_TLS_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_TLS_STATS_MAX_LINES)
25#define NSS_TLS_TX_TIMEOUT 3000 /* 3 Seconds */
26
27/*
28 * Private data structure for handling synchronous messaging.
29 */
30static struct nss_tls_pvt {
31 struct semaphore sem;
32 struct completion complete;
33 struct nss_tls_msg ntcm;
34 unsigned long if_map[NSS_TLS_INTERFACE_MAX_LONG];
35} tls_pvt;
36
37/*
38 * nss_tls_stats_sync()
39 * Update tls node statistics.
40 */
41static void nss_tls_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm)
42{
43 struct nss_tls_msg *ndcm = (struct nss_tls_msg *)ncm;
44 struct nss_top_instance *nss_top = nss_ctx->nss_top;
45 struct nss_tls_ctx_stats *msg_stats = &ndcm->msg.stats;
46 uint64_t *if_stats;
47 int i;
48
49 spin_lock_bh(&nss_top->stats_lock);
50
51 /*
52 * Update common node stats,
53 * Note: TLS only supports a single queue for RX
54 */
55 if_stats = nss_top->stats_node[ncm->interface];
56 if_stats[NSS_STATS_NODE_RX_PKTS] += msg_stats->pkt.rx_packets;
57 if_stats[NSS_STATS_NODE_RX_BYTES] += msg_stats->pkt.rx_bytes;
58
59 for (i = 0; i < NSS_MAX_NUM_PRI; i++)
60 if_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += msg_stats->pkt.rx_dropped[i];
61
62 if_stats[NSS_STATS_NODE_TX_PKTS] += msg_stats->pkt.tx_packets;
63 if_stats[NSS_STATS_NODE_TX_BYTES] += msg_stats->pkt.tx_bytes;
64
65 spin_unlock_bh(&nss_top->stats_lock);
66}
67
68/*
69 * nss_tls_stats_read()
70 * Read tls node statiistics.
71 */
72static ssize_t nss_tls_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
73{
74 struct nss_ctx_instance *nss_ctx = nss_tls_get_context();
75 enum nss_dynamic_interface_type type;
76 ssize_t bytes_read = 0;
77 size_t len = 0, size;
78 uint32_t if_num;
79 char *buf;
80
81 size = NSS_TLS_STATS_SIZE_PER_IF * bitmap_weight(tls_pvt.if_map, NSS_MAX_NET_INTERFACES);
82
83 buf = kzalloc(size, GFP_KERNEL);
84 if (!buf) {
85 nss_warning("Could not allocate memory for local statistics buffer");
86 return 0;
87 }
88
89 /*
90 * Common node stats for each TLS dynamic interface.
91 */
92 for_each_set_bit(if_num, tls_pvt.if_map, NSS_MAX_NET_INTERFACES) {
93 type = nss_dynamic_interface_get_type(nss_ctx, if_num);
94
95 switch (type) {
96 case NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER:
97 len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num);
98 break;
99
100 case NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER:
101 len += scnprintf(buf + len, size - len, "\nOuter if_num:%03u", if_num);
102 break;
103
104 default:
105 len += scnprintf(buf + len, size - len, "\nUnknown(%d) if_num:%03u", type, if_num);
106 break;
107 }
108
109 len += scnprintf(buf + len, size - len, "\n-------------------\n");
110 len = nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "tls");
111 }
112
113 bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len);
114 kfree(buf);
115
116 return bytes_read;
117}
118
119/*
120 * nss_tls_stats_ops
121 */
122NSS_STATS_DECLARE_FILE_OPERATIONS(tls)
123
124/*
125 * nss_tls_verify_ifnum()
126 * Verify if the interface number is a TLS interface.
127 */
128static bool nss_tls_verify_ifnum(struct nss_ctx_instance *nss_ctx, uint32_t if_num)
129{
130 enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, if_num);
131
132 if (type == NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER)
133 return true;
134
135 if (type == NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER)
136 return true;
137
138 if (if_num == NSS_TLS_INTERFACE)
139 return true;
140
141 return false;
142}
143
144/*
145 * nss_tls_handler()
146 * Handle NSS -> HLOS messages for tls tunnel
147 */
148static void nss_tls_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *data)
149{
150 nss_tls_msg_callback_t cb;
151 void *app_data;
152
153 NSS_VERIFY_CTX_MAGIC(nss_ctx);
154
Kyle Swensondd7b2962021-03-16 13:46:32 -0600155 nss_trace("%px: handle event for interface num :%u", nss_ctx, ncm->interface);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530156
157 /*
158 * Is this a valid request/response packet?
159 */
160 if (ncm->type >= NSS_TLS_MSG_MAX) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600161 nss_warning("%px:Bad message type(%d) for TLS interface %d", nss_ctx, ncm->type, ncm->interface);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530162 return;
163 }
164
165 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tls_msg)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600166 nss_warning("%px:Bad message length(%d)", nss_ctx, ncm->len);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530167 return;
168 }
169
170 if (ncm->type == NSS_TLS_MSG_TYPE_CTX_SYNC)
171 nss_tls_stats_sync(nss_ctx, ncm);
172
173 /*
174 * Update the callback and app_data for NOTIFY messages
175 */
176 if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600177 ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface);
178 ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data;
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530179 }
180
181 /*
182 * Log failures
183 */
184 nss_core_log_msg_failures(nss_ctx, ncm);
185
186 /*
187 * Trace messages.
188 */
189 nss_tls_log_rx_msg((struct nss_tls_msg *)ncm);
190
191 /*
192 * Callback
193 */
194 cb = (nss_tls_msg_callback_t)ncm->cb;
195 app_data = (void *)ncm->app_data;
196
197 /*
198 * Call TLS session callback
199 */
200 if (!cb) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600201 nss_warning("%px: No callback for tls session interface %d", nss_ctx, ncm->interface);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530202 return;
203 }
204
Kyle Swensondd7b2962021-03-16 13:46:32 -0600205 nss_trace("%px: calling tlsmgr event handler(%u)", nss_ctx, ncm->interface);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530206 cb(app_data, ncm);
207}
208
209/*
210 * nss_tls_sync_resp()
211 * Callback to handle the completion of HLOS-->NSS messages.
212 */
213static void nss_tls_sync_resp(void *app_data, struct nss_cmn_msg *ncm)
214{
215 struct nss_tls_msg *pvt_msg = app_data;
216 struct nss_tls_msg *resp_msg = container_of(ncm, struct nss_tls_msg, cm);
217
218 /*
219 * Copy response message to pvt message
220 */
221 memcpy(pvt_msg, resp_msg, sizeof(*resp_msg));
222
223 /*
224 * Write memory barrier
225 */
226 smp_wmb();
227
228 complete(&tls_pvt.complete);
229}
230
231/*
232 * nss_tls_tx_buf()
233 * Transmit buffer over TLS interface
234 */
235nss_tx_status_t nss_tls_tx_buf(struct sk_buff *skb, uint32_t if_num, struct nss_ctx_instance *nss_ctx)
236{
237 int32_t status;
238
239 if (!nss_tls_verify_ifnum(nss_ctx, if_num))
240 return NSS_TX_FAILURE;
241
242 NSS_VERIFY_CTX_MAGIC(nss_ctx);
243
244 if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600245 nss_warning("%px: tx_data packet dropped as core not ready", nss_ctx);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530246 return NSS_TX_FAILURE_NOT_READY;
247 }
248
249 status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_H2N_DATA_QUEUE, H2N_BUFFER_PACKET, 0);
250 switch (status) {
251 case NSS_CORE_STATUS_SUCCESS:
252 break;
253
254 case NSS_CORE_STATUS_FAILURE_QUEUE: /* queue full condition */
Kyle Swensondd7b2962021-03-16 13:46:32 -0600255 nss_warning("%px: H2N queue full for tx_buf", nss_ctx);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530256 return NSS_TX_FAILURE_QUEUE;
257
258 default:
Kyle Swensondd7b2962021-03-16 13:46:32 -0600259 nss_warning("%px: general failure for tx_buf", nss_ctx);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530260 return NSS_TX_FAILURE;
261 }
262
263 /*
264 * Kick the NSS awake so it can process our new entry.
265 */
266 nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE);
267
268 return NSS_TX_SUCCESS;
269}
270EXPORT_SYMBOL(nss_tls_tx_buf);
271
272/*
273 * nss_tls_tx_msg()
274 * Transmit a TLS message to NSS firmware
275 */
276nss_tx_status_t nss_tls_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_tls_msg *msg)
277{
278 struct nss_cmn_msg *ncm = &msg->cm;
279
280 if (ncm->type >= NSS_TLS_MSG_MAX) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600281 nss_warning("%px: tls message type out of range: %d", nss_ctx, ncm->type);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530282 return NSS_TX_FAILURE;
283 }
284
285 if (!nss_tls_verify_ifnum(nss_ctx, ncm->interface)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600286 nss_warning("%px: tls message interface is bad: %u", nss_ctx, ncm->interface);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530287 return NSS_TX_FAILURE;
288 }
289
290 /*
291 * Trace messages.
292 */
293 nss_tls_log_tx_msg(msg);
294
295 return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE);
296}
297EXPORT_SYMBOL(nss_tls_tx_msg);
298
299/*
300 * nss_tls_tx_msg_sync()
301 * Transmit a TLS message to NSS firmware synchronously.
302 */
303nss_tx_status_t nss_tls_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num,
304 enum nss_tls_msg_type type, uint16_t len,
305 struct nss_tls_msg *ntcm)
306{
307 struct nss_tls_msg *local_ntcm = &tls_pvt.ntcm;
308 nss_tx_status_t status;
309 int ret = 0;
310
311 /*
312 * Length of the message should be the based on type
313 */
314 if (len > sizeof(struct nss_tls_msg)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600315 nss_warning("%px: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530316 return NSS_TX_FAILURE;
317 }
318
319 down(&tls_pvt.sem);
320
321 /*
322 * We need to copy the message content into the actual message
323 * to be sent to NSS
324 */
325 memset(local_ntcm, 0, sizeof(*local_ntcm));
326
327 nss_tls_msg_init(local_ntcm, if_num, type, len, nss_tls_sync_resp, local_ntcm);
328 memcpy(&local_ntcm->msg, &ntcm->msg, len);
329
330 status = nss_tls_tx_msg(nss_ctx, local_ntcm);
331 if (status != NSS_TX_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600332 nss_warning("%px: Failed to send message\n", nss_ctx);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530333 goto done;
334 }
335
336 ret = wait_for_completion_timeout(&tls_pvt.complete, msecs_to_jiffies(NSS_TLS_TX_TIMEOUT));
337 if (!ret) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600338 nss_warning("%px: Failed to receive response, timeout(%d)\n", nss_ctx, ret);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530339 status = NSS_TX_FAILURE_NOT_READY;
340 goto done;
341 }
342
343 /*
344 * Read memory barrier
345 */
346 smp_rmb();
347
348 if (local_ntcm->cm.response != NSS_CMN_RESPONSE_ACK) {
349 status = NSS_TX_FAILURE;
350 ntcm->cm.response = local_ntcm->cm.response;
351 ntcm->cm.error = local_ntcm->cm.error;
352 goto done;
353 }
354
355 /*
356 * Copy the message received
357 */
358 memcpy(&ntcm->msg, &local_ntcm->msg, len);
359
360done:
361 up(&tls_pvt.sem);
362 return status;
363}
364EXPORT_SYMBOL(nss_tls_tx_msg_sync);
365
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530366/*
367 * nss_tls_notify_register()
368 * Register a handler for notification from NSS firmware.
369 */
370struct nss_ctx_instance *nss_tls_notify_register(uint32_t if_num, nss_tls_msg_callback_t ev_cb, void *app_data)
371{
372 struct nss_ctx_instance *nss_ctx = nss_tls_get_context();
373 uint32_t ret;
374
375 BUG_ON(!nss_ctx);
376
377 ret = nss_core_register_handler(nss_ctx, if_num, nss_tls_handler, app_data);
378 if (ret != NSS_CORE_STATUS_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600379 nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530380 return NULL;
381 }
382
Kyle Swensondd7b2962021-03-16 13:46:32 -0600383 ret = nss_core_register_msg_handler(nss_ctx, if_num, ev_cb);
384 if (ret != NSS_CORE_STATUS_SUCCESS) {
385 nss_core_unregister_handler(nss_ctx, if_num);
386 nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num);
387 return NULL;
388 }
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530389
390 return nss_ctx;
391}
392EXPORT_SYMBOL(nss_tls_notify_register);
393
394/*
395 * nss_tls_notify_unregister()
396 * Unregister notification callback handler.
397 */
398void nss_tls_notify_unregister(uint32_t if_num)
399{
400 struct nss_ctx_instance *nss_ctx = nss_tls_get_context();
401 uint32_t ret;
402
403 BUG_ON(!nss_ctx);
404
Kyle Swensondd7b2962021-03-16 13:46:32 -0600405 ret = nss_core_unregister_msg_handler(nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530406 if (ret != NSS_CORE_STATUS_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600407 nss_warning("%px: unable to un register event handler for interface(%u)", nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530408 return;
409 }
410
Kyle Swensondd7b2962021-03-16 13:46:32 -0600411 ret = nss_core_unregister_handler(nss_ctx, if_num);
412 if (ret != NSS_CORE_STATUS_SUCCESS) {
413 nss_warning("%px: unable to un register event handler for interface(%u)", nss_ctx, if_num);
414 return;
415 }
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530416
417 return;
418}
419EXPORT_SYMBOL(nss_tls_notify_unregister);
420
421/*
422 * nss_tls_register_if()
423 * Register data and event callback handlers for dynamic interface.
424 */
425struct nss_ctx_instance *nss_tls_register_if(uint32_t if_num,
426 nss_tls_data_callback_t data_cb,
427 nss_tls_msg_callback_t ev_cb,
428 struct net_device *netdev,
429 uint32_t features,
430 uint32_t type,
431 void *app_data)
432{
433 struct nss_ctx_instance *nss_ctx = nss_tls_get_context();
434 uint32_t ret;
435
436 if (!nss_tls_verify_ifnum(nss_ctx, if_num)) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600437 nss_warning("%px: TLS Interface is not dynamic:%u", nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530438 return NULL;
439 }
440
441 if (nss_ctx->subsys_dp_register[if_num].ndev) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600442 nss_warning("%px: Cannot find free slot for TLS NSS I/F:%u", nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530443 return NULL;
444 }
445
446 nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, app_data, netdev, features);
447 nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type);
448
449 ret = nss_core_register_handler(nss_ctx, if_num, nss_tls_handler, app_data);
450 if (ret != NSS_CORE_STATUS_SUCCESS) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600451 nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530452 return NULL;
453 }
454
Kyle Swensondd7b2962021-03-16 13:46:32 -0600455 ret = nss_core_register_msg_handler(nss_ctx, if_num, ev_cb);
456 if (ret != NSS_CORE_STATUS_SUCCESS) {
457 nss_core_unregister_handler(nss_ctx, if_num);
458 nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num);
459 return NULL;
460 }
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530461
462 /*
463 * Atomically set the bitmap for the interface number
464 */
465 set_bit(if_num, tls_pvt.if_map);
466 return nss_ctx;
467}
468EXPORT_SYMBOL(nss_tls_register_if);
469
470/*
471 * nss_tls_unregister_if()
472 * Unregister data and event callback handlers for the interface.
473 */
474void nss_tls_unregister_if(uint32_t if_num)
475{
476 struct nss_ctx_instance *nss_ctx = nss_tls_get_context();
Kyle Swensondd7b2962021-03-16 13:46:32 -0600477 uint32_t ret;
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530478
479 if (!nss_ctx->subsys_dp_register[if_num].ndev) {
Kyle Swensondd7b2962021-03-16 13:46:32 -0600480 nss_warning("%px: Cannot find registered netdev for TLS NSS I/F:%u", nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530481 return;
482 }
483
484 /*
485 * Atomically clear the bitmap for the interface number
486 */
487 clear_bit(if_num, tls_pvt.if_map);
488
Kyle Swensondd7b2962021-03-16 13:46:32 -0600489 ret = nss_core_unregister_msg_handler(nss_ctx, if_num);
490 if (ret != NSS_CORE_STATUS_SUCCESS) {
491 nss_warning("%px: unable to un register event handler for interface(%u)", nss_ctx, if_num);
492 return;
493 }
494
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530495 nss_core_unregister_handler(nss_ctx, if_num);
Ratheesh Kannoth65edb2d2020-01-23 09:08:46 +0530496
497 nss_core_unregister_subsys_dp(nss_ctx, if_num);
498}
499EXPORT_SYMBOL(nss_tls_unregister_if);
500
501/*
502 * nss_tls_get_context()
503 * Return TLS NSS context.
504 */
505struct nss_ctx_instance *nss_tls_get_context(void)
506{
507 return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tls_handler_id];
508}
509EXPORT_SYMBOL(nss_tls_get_context);
510
511/*
512 * nss_tls_get_device()
513 * Gets the original device from probe.
514 */
515struct device *nss_tls_get_dev(struct nss_ctx_instance *nss_ctx)
516{
517 return nss_ctx->dev;
518}
519EXPORT_SYMBOL(nss_tls_get_dev);
520
521/*
522 * nss_tls_msg_init()
523 * Initialize nss_tls msg to be sent asynchronously.
524 */
525void nss_tls_msg_init(struct nss_tls_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data)
526{
527 nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data);
528}
529EXPORT_SYMBOL(nss_tls_msg_init);
530
531/*
532 * nss_tls_msg_sync_init()
533 * Initialize nss_tls_msg to be sent synchronously.
534 */
535void nss_tls_msg_sync_init(struct nss_tls_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len)
536{
537 nss_cmn_msg_sync_init(&ncm->cm, if_num, type, len);
538}
539EXPORT_SYMBOL(nss_tls_msg_sync_init);
540
541/*
542 * nss_tls_register_handler()
543 * TLS initialization.
544 */
545void nss_tls_register_handler(void)
546{
547 sema_init(&tls_pvt.sem, 1);
548 init_completion(&tls_pvt.complete);
549 nss_stats_create_dentry("tls", &nss_tls_stats_ops);
550}