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/* 18 * This macro converts ECM ip_addr_t to SFE IPv6 address 19 */ 20#define ECM_IP_ADDR_TO_SFE_IPV6_ADDR(sfe6, ipaddrt) \ 21 { \ 22 ecm_type_check_ae_ipv6(sfe6); \ 23 ecm_type_check_ecm_ip_addr(ipaddrt); \ 24 sfe6[0] = htonl(ipaddrt[3]); \ 25 sfe6[1] = htonl(ipaddrt[2]); \ 26 sfe6[2] = htonl(ipaddrt[1]); \ 27 sfe6[3] = htonl(ipaddrt[0]); \ 28 } 29 30/* 31 * This macro converts SFE IPv6 address to ECM ip_addr_t 32 */ 33#define ECM_SFE_IPV6_ADDR_TO_IP_ADDR(ipaddrt, sfe6) \ 34 { \ 35 ecm_type_check_ecm_ip_addr(ipaddrt); \ 36 ecm_type_check_ae_ipv6(sfe6); \ 37 ipaddrt[0] = ntohl(sfe6[3]); \ 38 ipaddrt[1] = ntohl(sfe6[2]); \ 39 ipaddrt[2] = ntohl(sfe6[1]); \ 40 ipaddrt[3] = ntohl(sfe6[0]); \ 41 } 42 43/* 44 * ecm_sfe_common_get_interface_number_by_dev() 45 * Returns the acceleration engine interface number based on the net_device object. 46 */ 47static inline int32_t ecm_sfe_common_get_interface_number_by_dev(struct net_device *dev) 48{ 49 /* 50 * sfe_interface_num for all IPsec tunnels will always be the one specific to acceleration engine. 51 */ 52 if (dev->type == ECM_ARPHRD_IPSEC_TUNNEL_TYPE) { 53 return SFE_SPECIAL_INTERFACE_IPSEC; 54 } 55 56 return dev->ifindex; 57} 58 59