blob: 2fe34d751e0562448b63eccee548db564f95dfa2 [file] [log] [blame]
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05301/*
2 * sfe_init.c
3 * Shortcut forwarding engine initialization.
4 *
5 * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <linux/sysfs.h>
21#include <linux/skbuff.h>
22#include <linux/icmp.h>
23#include <net/tcp.h>
24#include <linux/etherdevice.h>
25#include <linux/version.h>
26
Ratheesh Kannoth89302a72021-10-20 08:10:37 +053027#include "sfe_api.h"
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053028#include "sfe.h"
29#include "sfe_ipv4.h"
30#include "sfe_ipv6.h"
31
Ratheesh Kannoth7a6a4ae2021-10-20 08:24:05 +053032int max_ipv4_conn = SFE_MAX_CONNECTION_NUM;
33module_param(max_ipv4_conn, int, S_IRUGO);
34MODULE_PARM_DESC(max_ipv4_conn, "Max number of IPv4 connections");
35
36int max_ipv6_conn = SFE_MAX_CONNECTION_NUM;
37module_param(max_ipv6_conn, int, S_IRUGO);
38MODULE_PARM_DESC(max_ipv6_conn, "Max number of IPv6 connections");
39
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053040/*
41 * sfe_init()
42 * Initialize SFE engine.
43 */
44static int __init sfe_init(void)
45{
46 /*
47 * Initialize SFE IPv4 engine.
48 */
49 if (sfe_ipv4_init()) {
50 goto fail0;
51 }
52
53#ifdef SFE_SUPPORT_IPV6
54
55 /*
56 * Initialize SFE IPv6 engine.
57 */
58 if (sfe_ipv6_init()) {
59 goto fail1;
60 }
61#endif
62
63 /*
64 * Initialize SFE infrastructure and register SFE hook with Linux stack
65 */
66 if (sfe_init_if()) {
67 goto fail2;
68 }
69
70 return 0;
71
72fail2:
73#ifdef SFE_SUPPORT_IPV6
74 sfe_ipv6_exit();
75fail1:
76#endif
77
78 sfe_ipv4_exit();
79
80fail0:
81
82 return -1;
83}
84
85/*
86 * sfe_exit()
87 */
88static void __exit sfe_exit(void)
89{
90
91 sfe_exit_if();
92
93#ifdef SFE_SUPPORT_IPV6
94 sfe_ipv6_exit();
95#endif
96 sfe_ipv4_exit();
97}
98
99module_init(sfe_init)
100module_exit(sfe_exit)
101
102MODULE_AUTHOR("Qualcomm Technologies");
103MODULE_DESCRIPTION("Shortcut Forwarding Engine");
104MODULE_LICENSE("Dual BSD/GPL");