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 | |
| 27 | #include "sfe.h" |
| 28 | #include "sfe_ipv4.h" |
| 29 | #include "sfe_ipv6.h" |
| 30 | |
| 31 | /* |
| 32 | * sfe_init() |
| 33 | * Initialize SFE engine. |
| 34 | */ |
| 35 | static int __init sfe_init(void) |
| 36 | { |
| 37 | /* |
| 38 | * Initialize SFE IPv4 engine. |
| 39 | */ |
| 40 | if (sfe_ipv4_init()) { |
| 41 | goto fail0; |
| 42 | } |
| 43 | |
| 44 | #ifdef SFE_SUPPORT_IPV6 |
| 45 | |
| 46 | /* |
| 47 | * Initialize SFE IPv6 engine. |
| 48 | */ |
| 49 | if (sfe_ipv6_init()) { |
| 50 | goto fail1; |
| 51 | } |
| 52 | #endif |
| 53 | |
| 54 | /* |
| 55 | * Initialize SFE infrastructure and register SFE hook with Linux stack |
| 56 | */ |
| 57 | if (sfe_init_if()) { |
| 58 | goto fail2; |
| 59 | } |
| 60 | |
| 61 | return 0; |
| 62 | |
| 63 | fail2: |
| 64 | #ifdef SFE_SUPPORT_IPV6 |
| 65 | sfe_ipv6_exit(); |
| 66 | fail1: |
| 67 | #endif |
| 68 | |
| 69 | sfe_ipv4_exit(); |
| 70 | |
| 71 | fail0: |
| 72 | |
| 73 | return -1; |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | * sfe_exit() |
| 78 | */ |
| 79 | static void __exit sfe_exit(void) |
| 80 | { |
| 81 | |
| 82 | sfe_exit_if(); |
| 83 | |
| 84 | #ifdef SFE_SUPPORT_IPV6 |
| 85 | sfe_ipv6_exit(); |
| 86 | #endif |
| 87 | sfe_ipv4_exit(); |
| 88 | } |
| 89 | |
| 90 | module_init(sfe_init) |
| 91 | module_exit(sfe_exit) |
| 92 | |
| 93 | MODULE_AUTHOR("Qualcomm Technologies"); |
| 94 | MODULE_DESCRIPTION("Shortcut Forwarding Engine"); |
| 95 | MODULE_LICENSE("Dual BSD/GPL"); |