Ratheesh Kannoth | 24fb1db | 2021-10-20 07:28:06 +0530 | [diff] [blame] | 1 | /* |
| 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 Kannoth | 89302a7 | 2021-10-20 08:10:37 +0530 | [diff] [blame] | 27 | #include "sfe_api.h" |
Ratheesh Kannoth | 24fb1db | 2021-10-20 07:28:06 +0530 | [diff] [blame] | 28 | #include "sfe.h" |
| 29 | #include "sfe_ipv4.h" |
| 30 | #include "sfe_ipv6.h" |
| 31 | |
Ratheesh Kannoth | 7a6a4ae | 2021-10-20 08:24:05 +0530 | [diff] [blame] | 32 | int max_ipv4_conn = SFE_MAX_CONNECTION_NUM; |
| 33 | module_param(max_ipv4_conn, int, S_IRUGO); |
| 34 | MODULE_PARM_DESC(max_ipv4_conn, "Max number of IPv4 connections"); |
| 35 | |
| 36 | int max_ipv6_conn = SFE_MAX_CONNECTION_NUM; |
| 37 | module_param(max_ipv6_conn, int, S_IRUGO); |
| 38 | MODULE_PARM_DESC(max_ipv6_conn, "Max number of IPv6 connections"); |
| 39 | |
Ratheesh Kannoth | 24fb1db | 2021-10-20 07:28:06 +0530 | [diff] [blame] | 40 | /* |
| 41 | * sfe_init() |
| 42 | * Initialize SFE engine. |
| 43 | */ |
| 44 | static 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 | |
| 72 | fail2: |
| 73 | #ifdef SFE_SUPPORT_IPV6 |
| 74 | sfe_ipv6_exit(); |
| 75 | fail1: |
| 76 | #endif |
| 77 | |
| 78 | sfe_ipv4_exit(); |
| 79 | |
| 80 | fail0: |
| 81 | |
| 82 | return -1; |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | * sfe_exit() |
| 87 | */ |
| 88 | static 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 | |
| 99 | module_init(sfe_init) |
| 100 | module_exit(sfe_exit) |
| 101 | |
| 102 | MODULE_AUTHOR("Qualcomm Technologies"); |
| 103 | MODULE_DESCRIPTION("Shortcut Forwarding Engine"); |
| 104 | MODULE_LICENSE("Dual BSD/GPL"); |