1/* 2 ************************************************************************** 3 * Copyright (c) 2015 The Linux Foundation. All rights reserved. 4 * 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 <linux/version.h> 18#include <linux/module.h> 19#include <linux/of.h> 20#include <linux/debugfs.h> 21#include <linux/inet.h> 22#include <linux/etherdevice.h> 23#include <net/netfilter/nf_conntrack.h> 24#include <net/ip.h> 25#include <net/ipv6.h> 26 27/* 28 * Debug output levels 29 * 0 = OFF 30 * 1 = ASSERTS / ERRORS 31 * 2 = 1 + WARN 32 * 3 = 2 + INFO 33 * 4 = 3 + TRACE 34 */ 35#define DEBUG_LEVEL ECM_FRONT_END_IPV4_DEBUG_LEVEL 36 37#include "ecm_types.h" 38#include "ecm_db_types.h" 39#include "ecm_state.h" 40#include "ecm_tracker.h" 41#include "ecm_classifier.h" 42#include "ecm_front_end_types.h" 43#include "ecm_tracker_datagram.h" 44#include "ecm_tracker_udp.h" 45#include "ecm_tracker_tcp.h" 46#include "ecm_db.h" 47#include "ecm_front_end_ipv4.h" 48 49/* 50 * ecm_front_end_ipv4_stop() 51 */ 52void ecm_front_end_ipv4_stop(int num) 53{ 54 /* 55 * If the device tree is used, check which accel engine will be stopped. 56 * For ipq8064 platforms, we will stop NSS. 57 */ 58#ifdef CONFIG_OF 59 /* 60 * Check the other platforms and use the correct APIs for those platforms. 61 */ 62 if (!of_machine_is_compatible("qcom,ipq8064")) { 63 ecm_sfe_ipv4_stop(num); 64 } else { 65 ecm_nss_ipv4_stop(num); 66 } 67#else 68 ecm_nss_ipv4_stop(num); 69#endif 70 71} 72 73/* 74 * ecm_front_end_ipv4_init() 75 */ 76int ecm_front_end_ipv4_init(struct dentry *dentry) 77{ 78 /* 79 * If the device tree is used, check which accel engine can be used. 80 * For ipq8064 platform, we will use NSS. 81 */ 82#ifdef CONFIG_OF 83 /* 84 * Check the other platforms and use the correct APIs for those platforms. 85 */ 86 if (!of_machine_is_compatible("qcom,ipq8064")) { 87 return ecm_sfe_ipv4_init(dentry); 88 } else { 89 return ecm_nss_ipv4_init(dentry); 90 } 91#else 92 return ecm_nss_ipv4_init(dentry); 93#endif 94} 95 96/* 97 * ecm_front_end_ipv4_exit() 98 */ 99void ecm_front_end_ipv4_exit(void) 100{ 101 /* 102 * If the device tree is used, check which accel engine will be exited. 103 * For ipq8064 platforms, we will exit NSS. 104 */ 105#ifdef CONFIG_OF 106 /* 107 * Check the other platforms and use the correct APIs for those platforms. 108 */ 109 if (!of_machine_is_compatible("qcom,ipq8064")) { 110 ecm_sfe_ipv4_exit(); 111 } else { 112 ecm_nss_ipv4_exit(); 113 } 114#else 115 ecm_nss_ipv4_exit(); 116#endif 117} 118 119