blob: da524a2e4ef0760031d541c1f43a04696c1aa164 [file] [log] [blame]
Shyam Sunder66e889d2015-11-02 15:31:20 +05301/*
2 **************************************************************************
Stephen Wang3e2dbd12018-03-14 17:28:17 -07003 * Copyright (c) 2015-2018, 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"
Yu Huang8c107082017-07-24 14:58:26 -070019#include "nss_pptp_stats.h"
Shyam Sunder66e889d2015-11-02 15:31:20 +053020
Shyam Sundere351f1b2015-12-17 14:11:51 +053021#define NSS_PPTP_TX_TIMEOUT 3000 /* 3 Seconds */
22
Shyam Sunder66e889d2015-11-02 15:31:20 +053023/*
24 * Data structures to store pptp nss debug stats
25 */
26static DEFINE_SPINLOCK(nss_pptp_session_debug_stats_lock);
Yu Huang8c107082017-07-24 14:58:26 -070027static struct nss_pptp_stats_session_debug nss_pptp_session_debug_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES];
Shyam Sunder66e889d2015-11-02 15:31:20 +053028
29/*
Shyam Sundere351f1b2015-12-17 14:11:51 +053030 * Private data structure
31 */
32static struct nss_pptp_pvt {
33 struct semaphore sem;
34 struct completion complete;
35 int response;
36 void *cb;
37 void *app_data;
38} pptp_pvt;
39
40/*
Shyam Sunder66e889d2015-11-02 15:31:20 +053041 * nss_pptp_session_debug_stats_sync
42 * Per session debug stats for pptp
43 */
Swaraj Sha11f9e7c2018-08-21 17:53:49 +053044void nss_pptp_session_debug_stats_sync(struct nss_ctx_instance *nss_ctx,
45 struct nss_pptp_sync_session_stats_msg *stats_msg, uint16_t if_num)
Shyam Sunder66e889d2015-11-02 15:31:20 +053046{
Swaraj Sha11f9e7c2018-08-21 17:53:49 +053047 int i, j, if_type;
48
49 if_type = nss_dynamic_interface_get_type(nss_pptp_get_context(), if_num);
Shyam Sunder66e889d2015-11-02 15:31:20 +053050 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
51 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
52 if (nss_pptp_session_debug_stats[i].if_num == if_num) {
Shyam Sunder66e889d2015-11-02 15:31:20 +053053 break;
54 }
55 }
Swaraj Sha11f9e7c2018-08-21 17:53:49 +053056
57 if (i == NSS_MAX_PPTP_DYNAMIC_INTERFACES) {
58 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
59 return;
60 }
61
62 if (if_type == NSS_DYNAMIC_INTERFACE_TYPE_PPTP_OUTER) {
63 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_RX_PACKETS] +=
64 stats_msg->node_stats.rx_packets;
65 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_RX_BYTES] +=
66 stats_msg->node_stats.rx_bytes;
67 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_TX_PACKETS] +=
68 stats_msg->node_stats.tx_packets;
69 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_TX_BYTES] +=
70 stats_msg->node_stats.tx_bytes;
71 for (j = 0; j < NSS_MAX_NUM_PRI; j++) {
72 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_RX_QUEUE_0_DROP + j] +=
73 stats_msg->node_stats.rx_dropped[j];
74 }
75 } else {
76 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_RX_PACKETS] +=
77 stats_msg->node_stats.rx_packets;
78 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_RX_BYTES] +=
79 stats_msg->node_stats.rx_bytes;
80 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_TX_PACKETS] +=
81 stats_msg->node_stats.tx_packets;
82 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_TX_BYTES] +=
83 stats_msg->node_stats.tx_bytes;
84 for (j = 0; j < NSS_MAX_NUM_PRI; j++) {
85 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_RX_QUEUE_0_DROP + j] +=
86 stats_msg->node_stats.rx_dropped[j];
87 }
88 }
89
90 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_ENCAP_HEADROOM_ERR] +=
91 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_HEADROOM_ERR];
92 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_ENCAP_SMALL_SIZE] +=
93 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_SMALL_SIZE];
94 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_ENCAP_PNODE_ENQUEUE_FAIL] +=
95 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_PNODE_ENQUEUE_FAIL];
96 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_NO_SEQ_NOR_ACK] +=
97 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_NO_SEQ_NOR_ACK];
98 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_INVAL_GRE_FLAGS] +=
99 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_FLAGS];
100 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_INVAL_GRE_PROTO] +=
101 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_PROTO];
102 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_WRONG_SEQ] +=
103 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_WRONG_SEQ];
104 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_INVAL_PPP_HDR] +=
105 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_PPP_HDR];
106 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_PPP_LCP] +=
107 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_PPP_LCP];
108 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_UNSUPPORTED_PPP_PROTO] +=
109 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_UNSUPPORTED_PPP_PROTO];
110 nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_PNODE_ENQUEUE_FAIL] +=
111 stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_PNODE_ENQUEUE_FAIL];
112
Shyam Sunder66e889d2015-11-02 15:31:20 +0530113 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
114}
115
116/*
117 * nss_pptp_global_session_stats_get()
118 * Get session pptp statitics.
119 */
120void nss_pptp_session_debug_stats_get(void *stats_mem)
121{
Yu Huang8c107082017-07-24 14:58:26 -0700122 struct nss_pptp_stats_session_debug *stats = (struct nss_pptp_stats_session_debug *)stats_mem;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530123 int i;
124
125 if (!stats) {
126 nss_warning("No memory to copy pptp session stats");
127 return;
128 }
129
130 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
131 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
132 if (nss_pptp_session_debug_stats[i].valid) {
Yu Huang8c107082017-07-24 14:58:26 -0700133 memcpy(stats, &nss_pptp_session_debug_stats[i], sizeof(struct nss_pptp_stats_session_debug));
Shyam Sunder66e889d2015-11-02 15:31:20 +0530134 stats++;
135 }
136 }
137 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
138}
139
140/*
Swaraj Sha11f9e7c2018-08-21 17:53:49 +0530141 * nss_pptp_verify_if_num()
142 * Verify if_num passed to us.
143 */
144static bool nss_pptp_verify_if_num(uint32_t if_num)
145{
146 uint32_t if_type;
147
148 if (nss_is_dynamic_interface(if_num) == false) {
149 return false;
150 }
151
152 if_type = nss_dynamic_interface_get_type(nss_pptp_get_context(), if_num);
153 switch(if_type) {
154 case NSS_DYNAMIC_INTERFACE_TYPE_PPTP_INNER:
155 case NSS_DYNAMIC_INTERFACE_TYPE_PPTP_OUTER:
156 case NSS_DYNAMIC_INTERFACE_TYPE_PPTP_HOST_INNER:
157 return true;
158 }
159
160 return false;
161}
162
163/*
Shyam Sunder66e889d2015-11-02 15:31:20 +0530164 * nss_pptp_handler()
165 * Handle NSS -> HLOS messages for pptp tunnel
166 */
167static void nss_pptp_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data)
168{
169 struct nss_pptp_msg *ntm = (struct nss_pptp_msg *)ncm;
170 void *ctx;
171
172 nss_pptp_msg_callback_t cb;
173
Swaraj Sha11f9e7c2018-08-21 17:53:49 +0530174 BUG_ON(!nss_pptp_verify_if_num(ncm->interface));
Shyam Sunder66e889d2015-11-02 15:31:20 +0530175
176 /*
177 * Is this a valid request/response packet?
178 */
179 if (ncm->type >= NSS_PPTP_MSG_MAX) {
180 nss_warning("%p: received invalid message %d for PPTP interface", nss_ctx, ncm->type);
181 return;
182 }
183
Suruchi Agarwalef8a8702016-01-08 12:40:08 -0800184 if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pptp_msg)) {
185 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 +0530186 return;
187 }
188
189 switch (ntm->cm.type) {
190
191 case NSS_PPTP_MSG_SYNC_STATS:
192 /*
193 * session debug stats embeded in session stats msg
194 */
195 nss_pptp_session_debug_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface);
196 break;
197 }
198
199 /*
200 * Update the callback and app_data for NOTIFY messages, pptp sends all notify messages
201 * to the same callback/app_data.
202 */
Suruchi Agarwale4ad24a2018-06-11 12:03:46 +0530203 if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) {
Stephen Wangaed46332016-12-12 17:29:03 -0800204 ncm->cb = (nss_ptr_t)nss_ctx->nss_top->pptp_msg_callback;
Stephen Wang84e0e992016-09-07 12:31:40 -0700205 ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530206 }
207
208 /*
209 * Log failures
210 */
211 nss_core_log_msg_failures(nss_ctx, ncm);
212
213 /*
214 * Do we have a call back
215 */
216 if (!ncm->cb) {
217 return;
218 }
219
220 /*
221 * callback
222 */
223 cb = (nss_pptp_msg_callback_t)ncm->cb;
Shyam Sundere351f1b2015-12-17 14:11:51 +0530224 ctx = (void *)ncm->app_data;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530225
226 /*
227 * call pptp tunnel callback
228 */
Shyam Sundere351f1b2015-12-17 14:11:51 +0530229 if (!cb) {
Shyam Sunder66e889d2015-11-02 15:31:20 +0530230 nss_warning("%p: Event received for pptp tunnel interface %d before registration", nss_ctx, ncm->interface);
231 return;
232 }
233
234 cb(ctx, ntm);
235}
236
237/*
Shyam Sundere351f1b2015-12-17 14:11:51 +0530238 * nss_pptp_tx_msg()
Shyam Sunder66e889d2015-11-02 15:31:20 +0530239 * Transmit a pptp message to NSS firmware
240 */
Shyam Sundere351f1b2015-12-17 14:11:51 +0530241static 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 +0530242{
Shyam Sunder66e889d2015-11-02 15:31:20 +0530243 struct nss_cmn_msg *ncm = &msg->cm;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530244
245 /*
246 * Sanity check the message
247 */
248 if (!nss_is_dynamic_interface(ncm->interface)) {
249 nss_warning("%p: tx request for non dynamic interface: %d", nss_ctx, ncm->interface);
250 return NSS_TX_FAILURE;
251 }
252
253 if (ncm->type > NSS_PPTP_MSG_MAX) {
254 nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type);
255 return NSS_TX_FAILURE;
256 }
257
Stephen Wang3e2dbd12018-03-14 17:28:17 -0700258 return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530259}
260
261/*
Shyam Sundere351f1b2015-12-17 14:11:51 +0530262 * nss_pptp_sync_msg_callback()
263 * Callback to handle the completion of NSS->HLOS messages.
Shyam Sunder66e889d2015-11-02 15:31:20 +0530264 */
Shyam Sundere351f1b2015-12-17 14:11:51 +0530265static void nss_pptp_sync_msg_callback(void *app_data, struct nss_pptp_msg *nim)
266{
267 nss_pptp_msg_callback_t callback = (nss_pptp_msg_callback_t)pptp_pvt.cb;
268 void *data = pptp_pvt.app_data;
269
270 pptp_pvt.cb = NULL;
271 pptp_pvt.app_data = NULL;
272
273 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
274 nss_warning("pptp Error response %d\n", nim->cm.response);
275
276 pptp_pvt.response = NSS_TX_FAILURE;
277 if (callback) {
278 callback(data, nim);
279 }
280
281 complete(&pptp_pvt.complete);
282 return;
283 }
284
285 pptp_pvt.response = NSS_TX_SUCCESS;
286 if (callback) {
287 callback(data, nim);
288 }
289
290 complete(&pptp_pvt.complete);
291}
292
293/*
294 * nss_pptp_tx_msg()
295 * Transmit a pptp message to NSS firmware synchronously.
296 */
297nss_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 +0530298{
299
Shyam Sundere351f1b2015-12-17 14:11:51 +0530300 nss_tx_status_t status;
301 int ret = 0;
302
303 down(&pptp_pvt.sem);
304 pptp_pvt.cb = (void *)msg->cm.cb;
305 pptp_pvt.app_data = (void *)msg->cm.app_data;
306
Stephen Wangaed46332016-12-12 17:29:03 -0800307 msg->cm.cb = (nss_ptr_t)nss_pptp_sync_msg_callback;
308 msg->cm.app_data = (nss_ptr_t)NULL;
Shyam Sundere351f1b2015-12-17 14:11:51 +0530309
310 status = nss_pptp_tx_msg(nss_ctx, msg);
311 if (status != NSS_TX_SUCCESS) {
312 nss_warning("%p: pptp_tx_msg failed\n", nss_ctx);
313 up(&pptp_pvt.sem);
314 return status;
315 }
316
317 ret = wait_for_completion_timeout(&pptp_pvt.complete, msecs_to_jiffies(NSS_PPTP_TX_TIMEOUT));
318
319 if (!ret) {
320 nss_warning("%p: PPTP msg tx failed due to timeout\n", nss_ctx);
321 pptp_pvt.response = NSS_TX_FAILURE;
322 }
323
324 status = pptp_pvt.response;
325 up(&pptp_pvt.sem);
326 return status;
327}
328
329/*
330 * nss_pptp_tx_buf()
331 * Send packet to pptp interface owned by NSS
332 */
333nss_tx_status_t nss_pptp_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb)
334{
Shyam Sundere351f1b2015-12-17 14:11:51 +0530335 nss_trace("%p: pptp If Tx packet, id:%d, data=%p", nss_ctx, if_num, skb->data);
336
Swaraj Sha11f9e7c2018-08-21 17:53:49 +0530337 return nss_core_send_packet(nss_ctx, skb, if_num, 0);
Shyam Sundere351f1b2015-12-17 14:11:51 +0530338}
339
340/*
341 * nss_register_pptp_if()
342 */
343struct nss_ctx_instance *nss_register_pptp_if(uint32_t if_num,
Swaraj Sha11f9e7c2018-08-21 17:53:49 +0530344 uint32_t type,
345 nss_pptp_callback_t pptp_data_callback,
346 nss_pptp_msg_callback_t notification_callback,
347 struct net_device *netdev,
348 uint32_t features,
349 void *app_ctx)
Shyam Sundere351f1b2015-12-17 14:11:51 +0530350{
Stephen Wang84e0e992016-09-07 12:31:40 -0700351 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 +0530352 int i = 0;
Stephen Wang84e0e992016-09-07 12:31:40 -0700353
354 nss_assert(nss_ctx);
Swaraj Sha11f9e7c2018-08-21 17:53:49 +0530355 nss_assert(nss_pptp_verify_if_num());
356
357 nss_ctx->subsys_dp_register[if_num].type = type;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530358
Jackson Bockus7ca70ec2017-07-17 13:47:29 -0700359 nss_core_register_subsys_dp(nss_ctx, if_num, pptp_data_callback, NULL, app_ctx, netdev, features);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530360
Shyam Sundere351f1b2015-12-17 14:11:51 +0530361 nss_top_main.pptp_msg_callback = notification_callback;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530362
Thomas Wu91f4bdf2017-06-09 12:03:02 -0700363 nss_core_register_handler(nss_ctx, if_num, nss_pptp_handler, NULL);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530364
Shyam Sundere351f1b2015-12-17 14:11:51 +0530365 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
366 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
367 if (!nss_pptp_session_debug_stats[i].valid) {
368 nss_pptp_session_debug_stats[i].valid = true;
369 nss_pptp_session_debug_stats[i].if_num = if_num;
370 nss_pptp_session_debug_stats[i].if_index = netdev->ifindex;
371 break;
372 }
373 }
374 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
375
Stephen Wang84e0e992016-09-07 12:31:40 -0700376 return nss_ctx;
Shyam Sunder66e889d2015-11-02 15:31:20 +0530377}
378
379/*
380 * nss_unregister_pptp_if()
381 */
382void nss_unregister_pptp_if(uint32_t if_num)
383{
Stephen Wang84e0e992016-09-07 12:31:40 -0700384 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 +0530385 int i;
adil irfanb9a45f02018-04-09 19:13:53 +0530386 int j;
Shyam Sundere351f1b2015-12-17 14:11:51 +0530387
Stephen Wang84e0e992016-09-07 12:31:40 -0700388 nss_assert(nss_ctx);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530389 nss_assert(nss_is_dynamic_interface(if_num));
390
Shyam Sundere351f1b2015-12-17 14:11:51 +0530391 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
392 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
adil irfanb9a45f02018-04-09 19:13:53 +0530393 if (nss_pptp_session_debug_stats[i].valid == true &&
394 nss_pptp_session_debug_stats[i].if_num == if_num) {
395 nss_pptp_session_debug_stats[i].valid = false;
396 nss_pptp_session_debug_stats[i].if_num = 0;
397 nss_pptp_session_debug_stats[i].if_index = 0;
398 for (j = 0; j < NSS_PPTP_STATS_SESSION_MAX; j++)
399 nss_pptp_session_debug_stats[i].stats[j] = 0;
400 break;
401 }
Shyam Sundere351f1b2015-12-17 14:11:51 +0530402 }
403 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
404
Jackson Bockus7ca70ec2017-07-17 13:47:29 -0700405 nss_core_unregister_subsys_dp(nss_ctx, if_num);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530406
407 nss_top_main.pptp_msg_callback = NULL;
408
Thomas Wu91f4bdf2017-06-09 12:03:02 -0700409 nss_core_unregister_handler(nss_ctx, if_num);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530410}
411
412/*
413 * nss_get_pptp_context()
414 */
415struct nss_ctx_instance *nss_pptp_get_context()
416{
417 return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id];
418}
419
420/*
421 * nss_pptp_msg_init()
422 * Initialize nss_pptp msg.
423 */
424void nss_pptp_msg_init(struct nss_pptp_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data)
425{
426 nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data);
427}
428
429/* nss_pptp_register_handler()
430 * debugfs stats msg handler received on static pptp interface
431 */
432void nss_pptp_register_handler(void)
433{
Shyam Sundere351f1b2015-12-17 14:11:51 +0530434 int i;
435
Shyam Sunder66e889d2015-11-02 15:31:20 +0530436 nss_info("nss_pptp_register_handler");
Thomas Wu91f4bdf2017-06-09 12:03:02 -0700437 nss_core_register_handler(nss_pptp_get_context(), NSS_PPTP_INTERFACE, nss_pptp_handler, NULL);
Shyam Sundere351f1b2015-12-17 14:11:51 +0530438
439 spin_lock_bh(&nss_pptp_session_debug_stats_lock);
440 for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) {
441 nss_pptp_session_debug_stats[i].valid = false;
442 nss_pptp_session_debug_stats[i].if_num = 0;
443 nss_pptp_session_debug_stats[i].if_index = 0;
444 }
445 spin_unlock_bh(&nss_pptp_session_debug_stats_lock);
446
447 sema_init(&pptp_pvt.sem, 1);
448 init_completion(&pptp_pvt.complete);
Yu Huang8c107082017-07-24 14:58:26 -0700449
450 nss_pptp_stats_dentry_create();
Shyam Sunder66e889d2015-11-02 15:31:20 +0530451}
452
453EXPORT_SYMBOL(nss_pptp_get_context);
Shyam Sundere351f1b2015-12-17 14:11:51 +0530454EXPORT_SYMBOL(nss_pptp_tx_msg_sync);
455EXPORT_SYMBOL(nss_pptp_tx_buf);
Shyam Sunder66e889d2015-11-02 15:31:20 +0530456EXPORT_SYMBOL(nss_unregister_pptp_if);
457EXPORT_SYMBOL(nss_pptp_msg_init);
458EXPORT_SYMBOL(nss_register_pptp_if);