blob: f22c503295286d6f227a44447f40de30f423b84a [file] [log] [blame]
Shyam Sunder66e889d2015-11-02 15:31:20 +05301/*
2 **************************************************************************
Stephen Wangaed46332016-12-12 17:29:03 -08003 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Shyam Sunder66e889d2015-11-02 15:31:20 +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 <net/sock.h>
18#include "nss_tx_rx_common.h"
19
Shyam Sundere351f1b2015-12-17 14:11:51 +053020#define NSS_PPTP_TX_TIMEOUT 3000 /* 3 Seconds */
21
Shyam Sunder66e889d2015-11-02 15:31:20 +053022/*
23 * Data structures to store pptp nss debug stats
24 */
25static DEFINE_SPINLOCK(nss_pptp_session_debug_stats_lock);
26static struct nss_stats_pptp_session_debug nss_pptp_session_debug_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES];
27
28/*
Shyam Sundere351f1b2015-12-17 14:11:51 +053029 * Private data structure
30 */
31static struct nss_pptp_pvt {
32 struct semaphore sem;
33 struct completion complete;
34 int response;
35 void *cb;
36 void *app_data;
37} pptp_pvt;
38
39/*
Shyam Sunder66e889d2015-11-02 15:31:20 +053040 * nss_pptp_session_debug_stats_sync
41 * Per session debug stats for pptp
42 */
43void nss_pptp_session_debug_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pptp_sync_session_stats_msg *stats_msg, uint16_t if_num)
44{
45 int i;
46 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
47 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
48 if (nss_pptp_session_debug_stats[i].if_num == if_num) {
Shyam Sundere351f1b2015-12-17 14:11:51 +053049 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_ENCAP_RX_PACKETS] += stats_msg->encap_stats.rx_packets;
50 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_ENCAP_RX_BYTES] += stats_msg->encap_stats.rx_bytes;
51 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_ENCAP_TX_PACKETS] += stats_msg->encap_stats.tx_packets;
52 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_ENCAP_TX_BYTES] += stats_msg->encap_stats.tx_bytes;
53 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_ENCAP_RX_DROP] += stats_msg->encap_stats.rx_dropped;
54 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_DECAP_RX_PACKETS] += stats_msg->decap_stats.rx_packets;
55 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_DECAP_RX_BYTES] += stats_msg->decap_stats.rx_bytes;
56 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_DECAP_TX_PACKETS] += stats_msg->decap_stats.tx_packets;
57 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_DECAP_TX_BYTES] += stats_msg->decap_stats.tx_bytes;
58 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_DECAP_RX_DROP] += stats_msg->decap_stats.rx_dropped;
59 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_ENCAP_HEADROOM_ERR] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_HEADROOM_ERR];
60 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_ENCAP_SMALL_SIZE] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_SMALL_SIZE];
61 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_ENCAP_PNODE_ENQUEUE_FAIL] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_PNODE_ENQUEUE_FAIL];
62 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_NO_SEQ_NOR_ACK] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_NO_SEQ_NOR_ACK];
63 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_INVAL_GRE_FLAGS] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_FLAGS];
64 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_INVAL_GRE_PROTO] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_PROTO];
65 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_WRONG_SEQ] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_WRONG_SEQ];
66 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_INVAL_PPP_HDR] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_PPP_HDR];
67 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_PPP_LCP] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_PPP_LCP];
68 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_UNSUPPORTED_PPP_PROTO] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_UNSUPPORTED_PPP_PROTO];
69 nss_pptp_session_debug_stats[i].stats[NSS_STATS_PPTP_SESSION_DECAP_PNODE_ENQUEUE_FAIL] += stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_PNODE_ENQUEUE_FAIL];
Shyam Sunder66e889d2015-11-02 15:31:20 +053070 break;
71 }
72 }
73 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
74}
75
76/*
77 * nss_pptp_global_session_stats_get()
78 * Get session pptp statitics.
79 */
80void nss_pptp_session_debug_stats_get(void *stats_mem)
81{
82 struct nss_stats_pptp_session_debug *stats = (struct nss_stats_pptp_session_debug *)stats_mem;
83 int i;
84
85 if (!stats) {
86 nss_warning("No memory to copy pptp session stats");
87 return;
88 }
89
90 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
91 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
92 if (nss_pptp_session_debug_stats[i].valid) {
93 memcpy(stats, &nss_pptp_session_debug_stats[i], sizeof(struct nss_stats_pptp_session_debug));
94 stats++;
95 }
96 }
97 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
98}
99
100/*
101 * nss_pptp_handler()
102 * Handle NSS -> HLOS messages for pptp tunnel
103 */
104static void nss_pptp_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data)
105{
106 struct nss_pptp_msg *ntm = (struct nss_pptp_msg *)ncm;
107 void *ctx;
108
109 nss_pptp_msg_callback_t cb;
110
111 BUG_ON(!(nss_is_dynamic_interface(ncm->interface) || ncm->interface == NSS_PPTP_INTERFACE));
112
113 /*
114 * Is this a valid request/response packet?
115 */
116 if (ncm->type >= NSS_PPTP_MSG_MAX) {
117 nss_warning("%p: received invalid message %d for PPTP interface", nss_ctx, ncm->type);
118 return;
119 }
120
Suruchi Agarwalef8a8702016-01-08 12:40:08 -0800121 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pptp_msg)) {
122 nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
Shyam Sunder66e889d2015-11-02 15:31:20 +0530123 return;
124 }
125
126 switch (ntm->cm.type) {
127
128 case NSS_PPTP_MSG_SYNC_STATS:
129 /*
130 * session debug stats embeded in session stats msg
131 */
132 nss_pptp_session_debug_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface);
133 break;
134 }
135
136 /*
137 * Update the callback and app_data for NOTIFY messages, pptp sends all notify messages
138 * to the same callback/app_data.
139 */
140 if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
Stephen Wangaed46332016-12-12 17:29:03 -0800141 ncm->cb = (nss_ptr_t)nss_ctx->nss_top->pptp_msg_callback;
Stephen Wang84e0e992016-09-07 12:31:40 -0700142 ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530143 }
144
145 /*
146 * Log failures
147 */
148 nss_core_log_msg_failures(nss_ctx, ncm);
149
150 /*
151 * Do we have a call back
152 */
153 if (!ncm->cb) {
154 return;
155 }
156
157 /*
158 * callback
159 */
160 cb = (nss_pptp_msg_callback_t)ncm->cb;
Shyam Sundere351f1b2015-12-17 14:11:51 +0530161 ctx = (void *)ncm->app_data;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530162
163 /*
164 * call pptp tunnel callback
165 */
Shyam Sundere351f1b2015-12-17 14:11:51 +0530166 if (!cb) {
Shyam Sunder66e889d2015-11-02 15:31:20 +0530167 nss_warning("%p: Event received for pptp tunnel interface %d before registration", nss_ctx, ncm->interface);
168 return;
169 }
170
171 cb(ctx, ntm);
172}
173
174/*
Shyam Sundere351f1b2015-12-17 14:11:51 +0530175 * nss_pptp_tx_msg()
Shyam Sunder66e889d2015-11-02 15:31:20 +0530176 * Transmit a pptp message to NSS firmware
177 */
Shyam Sundere351f1b2015-12-17 14:11:51 +0530178static nss_tx_status_t nss_pptp_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_pptp_msg *msg)
Shyam Sunder66e889d2015-11-02 15:31:20 +0530179{
180 struct nss_pptp_msg *nm;
181 struct nss_cmn_msg *ncm = &msg->cm;
182 struct sk_buff *nbuf;
183 int32_t status;
184
185 NSS_VERIFY_CTX_MAGIC(nss_ctx);
186 if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
187 nss_warning("%p: pptp msg dropped as core not ready", nss_ctx);
188 return NSS_TX_FAILURE_NOT_READY;
189 }
190
191 /*
192 * Sanity check the message
193 */
194 if (!nss_is_dynamic_interface(ncm->interface)) {
195 nss_warning("%p: tx request for non dynamic interface: %d", nss_ctx, ncm->interface);
196 return NSS_TX_FAILURE;
197 }
198
199 if (ncm->type > NSS_PPTP_MSG_MAX) {
200 nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type);
201 return NSS_TX_FAILURE;
202 }
203
Suruchi Agarwalef8a8702016-01-08 12:40:08 -0800204 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pptp_msg)) {
205 nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
Shyam Sunder66e889d2015-11-02 15:31:20 +0530206 return NSS_TX_FAILURE;
207 }
208
209 nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE);
210 if (unlikely(!nbuf)) {
211 NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]);
212 nss_warning("%p: msg dropped as command allocation failed", nss_ctx);
213 return NSS_TX_FAILURE;
214 }
215
216 /*
217 * Copy the message to our skb
218 */
219 nm = (struct nss_pptp_msg *)skb_put(nbuf, sizeof(struct nss_pptp_msg));
220 memcpy(nm, msg, sizeof(struct nss_pptp_msg));
221
222 status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0);
223 if (status != NSS_CORE_STATUS_SUCCESS) {
224 dev_kfree_skb_any(nbuf);
225 nss_warning("%p: Unable to enqueue 'pptp message'\n", nss_ctx);
226 if (status == NSS_CORE_STATUS_FAILURE_QUEUE) {
227 return NSS_TX_FAILURE_QUEUE;
228 }
229 return NSS_TX_FAILURE;
230 }
231
Stephen Wang90c67de2016-04-26 15:15:59 -0700232 nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530233
234 NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_CMD_REQ]);
235 return NSS_TX_SUCCESS;
236}
237
238/*
Shyam Sundere351f1b2015-12-17 14:11:51 +0530239 * nss_pptp_sync_msg_callback()
240 * Callback to handle the completion of NSS->HLOS messages.
Shyam Sunder66e889d2015-11-02 15:31:20 +0530241 */
Shyam Sundere351f1b2015-12-17 14:11:51 +0530242static void nss_pptp_sync_msg_callback(void *app_data, struct nss_pptp_msg *nim)
243{
244 nss_pptp_msg_callback_t callback = (nss_pptp_msg_callback_t)pptp_pvt.cb;
245 void *data = pptp_pvt.app_data;
246
247 pptp_pvt.cb = NULL;
248 pptp_pvt.app_data = NULL;
249
250 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
251 nss_warning("pptp Error response %d\n", nim->cm.response);
252
253 pptp_pvt.response = NSS_TX_FAILURE;
254 if (callback) {
255 callback(data, nim);
256 }
257
258 complete(&pptp_pvt.complete);
259 return;
260 }
261
262 pptp_pvt.response = NSS_TX_SUCCESS;
263 if (callback) {
264 callback(data, nim);
265 }
266
267 complete(&pptp_pvt.complete);
268}
269
270/*
271 * nss_pptp_tx_msg()
272 * Transmit a pptp message to NSS firmware synchronously.
273 */
274nss_tx_status_t nss_pptp_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_pptp_msg *msg)
Shyam Sunder66e889d2015-11-02 15:31:20 +0530275{
276
Shyam Sundere351f1b2015-12-17 14:11:51 +0530277 nss_tx_status_t status;
278 int ret = 0;
279
280 down(&pptp_pvt.sem);
281 pptp_pvt.cb = (void *)msg->cm.cb;
282 pptp_pvt.app_data = (void *)msg->cm.app_data;
283
Stephen Wangaed46332016-12-12 17:29:03 -0800284 msg->cm.cb = (nss_ptr_t)nss_pptp_sync_msg_callback;
285 msg->cm.app_data = (nss_ptr_t)NULL;
Shyam Sundere351f1b2015-12-17 14:11:51 +0530286
287 status = nss_pptp_tx_msg(nss_ctx, msg);
288 if (status != NSS_TX_SUCCESS) {
289 nss_warning("%p: pptp_tx_msg failed\n", nss_ctx);
290 up(&pptp_pvt.sem);
291 return status;
292 }
293
294 ret = wait_for_completion_timeout(&pptp_pvt.complete, msecs_to_jiffies(NSS_PPTP_TX_TIMEOUT));
295
296 if (!ret) {
297 nss_warning("%p: PPTP msg tx failed due to timeout\n", nss_ctx);
298 pptp_pvt.response = NSS_TX_FAILURE;
299 }
300
301 status = pptp_pvt.response;
302 up(&pptp_pvt.sem);
303 return status;
304}
305
306/*
307 * nss_pptp_tx_buf()
308 * Send packet to pptp interface owned by NSS
309 */
310nss_tx_status_t nss_pptp_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb)
311{
312 int32_t status;
313
314 nss_trace("%p: pptp If Tx packet, id:%d, data=%p", nss_ctx, if_num, skb->data);
315
316 NSS_VERIFY_CTX_MAGIC(nss_ctx);
317 if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) {
318 nss_warning("%p: 'PPTP' packet dropped as core not ready", nss_ctx);
319 return NSS_TX_FAILURE_NOT_READY;
320 }
321
322 status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_DATA_QUEUE_0, H2N_BUFFER_PACKET, H2N_BIT_FLAG_VIRTUAL_BUFFER);
323 if (unlikely(status != NSS_CORE_STATUS_SUCCESS)) {
324 nss_warning("%p: Unable to enqueue 'PPTP' packet\n", nss_ctx);
325 return NSS_TX_FAILURE_QUEUE;
326 }
327
328 /*
329 * Kick the NSS awake so it can process our new entry.
330 */
Stephen Wang90c67de2016-04-26 15:15:59 -0700331 nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE);
Shyam Sundere351f1b2015-12-17 14:11:51 +0530332
333 NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_PACKET]);
334 return NSS_TX_SUCCESS;
335}
336
337/*
338 * nss_register_pptp_if()
339 */
340struct nss_ctx_instance *nss_register_pptp_if(uint32_t if_num,
341 nss_pptp_callback_t pptp_data_callback,
342 nss_pptp_msg_callback_t notification_callback,
343 struct net_device *netdev,
344 uint32_t features,
345 void *app_ctx)
346{
Stephen Wang84e0e992016-09-07 12:31:40 -0700347 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id];
Shyam Sundere351f1b2015-12-17 14:11:51 +0530348 int i = 0;
Stephen Wang84e0e992016-09-07 12:31:40 -0700349
350 nss_assert(nss_ctx);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530351 nss_assert(nss_is_dynamic_interface(if_num));
352
Stephen Wang84e0e992016-09-07 12:31:40 -0700353 nss_ctx->subsys_dp_register[if_num].ndev = netdev;
354 nss_ctx->subsys_dp_register[if_num].cb = pptp_data_callback;
355 nss_ctx->subsys_dp_register[if_num].app_data = app_ctx;
356 nss_ctx->subsys_dp_register[if_num].features = features;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530357
Shyam Sundere351f1b2015-12-17 14:11:51 +0530358 nss_top_main.pptp_msg_callback = notification_callback;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530359
360 nss_core_register_handler(if_num, nss_pptp_handler, NULL);
361
Shyam Sundere351f1b2015-12-17 14:11:51 +0530362 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
363 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
364 if (!nss_pptp_session_debug_stats[i].valid) {
365 nss_pptp_session_debug_stats[i].valid = true;
366 nss_pptp_session_debug_stats[i].if_num = if_num;
367 nss_pptp_session_debug_stats[i].if_index = netdev->ifindex;
368 break;
369 }
370 }
371 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
372
Stephen Wang84e0e992016-09-07 12:31:40 -0700373 return nss_ctx;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530374}
375
376/*
377 * nss_unregister_pptp_if()
378 */
379void nss_unregister_pptp_if(uint32_t if_num)
380{
Stephen Wang84e0e992016-09-07 12:31:40 -0700381 struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id];
Shyam Sundere351f1b2015-12-17 14:11:51 +0530382 int i;
383
Stephen Wang84e0e992016-09-07 12:31:40 -0700384 nss_assert(nss_ctx);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530385 nss_assert(nss_is_dynamic_interface(if_num));
386
Shyam Sundere351f1b2015-12-17 14:11:51 +0530387 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
388 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
389 nss_pptp_session_debug_stats[i].valid = false;
390 nss_pptp_session_debug_stats[i].if_num = 0;
391 nss_pptp_session_debug_stats[i].if_index = 0;
392 }
393 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
394
Stephen Wang84e0e992016-09-07 12:31:40 -0700395 nss_ctx->subsys_dp_register[if_num].ndev = NULL;
396 nss_ctx->subsys_dp_register[if_num].cb = NULL;
397 nss_ctx->subsys_dp_register[if_num].app_data = NULL;
398 nss_ctx->subsys_dp_register[if_num].features = 0;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530399
400 nss_top_main.pptp_msg_callback = NULL;
401
402 nss_core_unregister_handler(if_num);
403}
404
405/*
406 * nss_get_pptp_context()
407 */
408struct nss_ctx_instance *nss_pptp_get_context()
409{
410 return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id];
411}
412
413/*
414 * nss_pptp_msg_init()
415 * Initialize nss_pptp msg.
416 */
417void nss_pptp_msg_init(struct nss_pptp_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data)
418{
419 nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data);
420}
421
422/* nss_pptp_register_handler()
423 * debugfs stats msg handler received on static pptp interface
424 */
425void nss_pptp_register_handler(void)
426{
Shyam Sundere351f1b2015-12-17 14:11:51 +0530427 int i;
428
Shyam Sunder66e889d2015-11-02 15:31:20 +0530429 nss_info("nss_pptp_register_handler");
430 nss_core_register_handler(NSS_PPTP_INTERFACE, nss_pptp_handler, NULL);
Shyam Sundere351f1b2015-12-17 14:11:51 +0530431
432 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
433 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
434 nss_pptp_session_debug_stats[i].valid = false;
435 nss_pptp_session_debug_stats[i].if_num = 0;
436 nss_pptp_session_debug_stats[i].if_index = 0;
437 }
438 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
439
440 sema_init(&pptp_pvt.sem, 1);
441 init_completion(&pptp_pvt.complete);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530442}
443
444EXPORT_SYMBOL(nss_pptp_get_context);
Shyam Sundere351f1b2015-12-17 14:11:51 +0530445EXPORT_SYMBOL(nss_pptp_tx_msg_sync);
446EXPORT_SYMBOL(nss_pptp_tx_buf);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530447EXPORT_SYMBOL(nss_unregister_pptp_if);
448EXPORT_SYMBOL(nss_pptp_msg_init);
449EXPORT_SYMBOL(nss_register_pptp_if);