Xiaoping Fan | d44a5b4 | 2015-05-26 17:37:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sfe_cm.h |
| 3 | * Shortcut forwarding engine. |
| 4 | * |
| 5 | * Copyright (c) 2013-2015 Qualcomm Atheros, Inc. |
| 6 | * |
| 7 | * All Rights Reserved. |
| 8 | * Qualcomm Atheros Confidential and Proprietary. |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * connection flags. |
| 13 | */ |
| 14 | #define SFE_CREATE_FLAG_NO_SEQ_CHECK 0x1 |
| 15 | /* Indicates that we should not check sequence numbers */ |
| 16 | |
| 17 | /* |
| 18 | * IPv6 address structure |
| 19 | */ |
| 20 | struct sfe_ipv6_addr { |
| 21 | __be32 addr[4]; |
| 22 | }; |
| 23 | |
| 24 | typedef union { |
| 25 | __be32 ip; |
| 26 | struct sfe_ipv6_addr ip6[1]; |
| 27 | } sfe_ip_addr_t; |
| 28 | |
| 29 | /* |
| 30 | * connection creation structure. |
| 31 | */ |
| 32 | struct sfe_connection_create { |
| 33 | int protocol; |
| 34 | struct net_device *src_dev; |
| 35 | struct net_device *dest_dev; |
| 36 | uint32_t flags; |
| 37 | uint32_t src_mtu; |
| 38 | uint32_t dest_mtu; |
| 39 | sfe_ip_addr_t src_ip; |
| 40 | sfe_ip_addr_t src_ip_xlate; |
| 41 | sfe_ip_addr_t dest_ip; |
| 42 | sfe_ip_addr_t dest_ip_xlate; |
| 43 | __be16 src_port; |
| 44 | __be16 src_port_xlate; |
| 45 | __be16 dest_port; |
| 46 | __be16 dest_port_xlate; |
| 47 | uint8_t src_mac[ETH_ALEN]; |
| 48 | uint8_t src_mac_xlate[ETH_ALEN]; |
| 49 | uint8_t dest_mac[ETH_ALEN]; |
| 50 | uint8_t dest_mac_xlate[ETH_ALEN]; |
| 51 | uint8_t src_td_window_scale; |
| 52 | uint32_t src_td_max_window; |
| 53 | uint32_t src_td_end; |
| 54 | uint32_t src_td_max_end; |
| 55 | uint8_t dest_td_window_scale; |
| 56 | uint32_t dest_td_max_window; |
| 57 | uint32_t dest_td_end; |
| 58 | uint32_t dest_td_max_end; |
| 59 | uint32_t mark; |
| 60 | }; |
| 61 | |
| 62 | /* |
| 63 | * connection destruction structure. |
| 64 | */ |
| 65 | struct sfe_connection_destroy { |
| 66 | int protocol; |
| 67 | sfe_ip_addr_t src_ip; |
| 68 | sfe_ip_addr_t dest_ip; |
| 69 | __be16 src_port; |
| 70 | __be16 dest_port; |
| 71 | }; |
| 72 | |
| 73 | /* |
| 74 | * Structure used to sync connection stats/state back within the system. |
| 75 | * |
| 76 | * NOTE: The addresses here are NON-NAT addresses, i.e. the true endpoint addressing. |
| 77 | * 'src' is the creator of the connection. |
| 78 | */ |
| 79 | struct sfe_connection_sync { |
| 80 | struct net_device *src_dev; |
| 81 | struct net_device *dest_dev; |
| 82 | int is_v6; /* Is it for ipv6? */ |
| 83 | int protocol; /* IP protocol number (IPPROTO_...) */ |
| 84 | sfe_ip_addr_t src_ip; /* Non-NAT source address, i.e. the creator of the connection */ |
| 85 | __be16 src_port; /* Non-NAT source port */ |
| 86 | sfe_ip_addr_t dest_ip; /* Non-NAT destination address, i.e. to whom the connection was created */ |
| 87 | __be16 dest_port; /* Non-NAT destination port */ |
| 88 | uint32_t src_td_max_window; |
| 89 | uint32_t src_td_end; |
| 90 | uint32_t src_td_max_end; |
| 91 | uint64_t src_packet_count; |
| 92 | uint64_t src_byte_count; |
| 93 | uint32_t src_new_packet_count; |
| 94 | uint32_t src_new_byte_count; |
| 95 | uint32_t dest_td_max_window; |
| 96 | uint32_t dest_td_end; |
| 97 | uint32_t dest_td_max_end; |
| 98 | uint64_t dest_packet_count; |
| 99 | uint64_t dest_byte_count; |
| 100 | uint32_t dest_new_packet_count; |
| 101 | uint32_t dest_new_byte_count; |
| 102 | uint64_t delta_jiffies; /* Time to be added to the current timeout to keep the connection alive */ |
| 103 | }; |
| 104 | |
| 105 | /* |
| 106 | * connection mark structure |
| 107 | */ |
| 108 | struct sfe_connection_mark { |
| 109 | int protocol; |
| 110 | sfe_ip_addr_t src_ip; |
| 111 | sfe_ip_addr_t dest_ip; |
| 112 | __be16 src_port; |
| 113 | __be16 dest_port; |
| 114 | uint32_t mark; |
| 115 | }; |
| 116 | |
| 117 | /* |
| 118 | * Type used for a sync rule callback. |
| 119 | */ |
| 120 | typedef void (*sfe_sync_rule_callback_t)(struct sfe_connection_sync *); |
| 121 | |
| 122 | /* |
| 123 | * IPv4 APIs used by connection manager |
| 124 | */ |
| 125 | extern int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb); |
| 126 | extern int sfe_ipv4_create_rule(struct sfe_connection_create *sic); |
| 127 | extern void sfe_ipv4_destroy_rule(struct sfe_connection_destroy *sid); |
| 128 | extern void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev); |
| 129 | extern void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callback); |
| 130 | extern void sfe_ipv4_update_rule(struct sfe_connection_create *sic); |
| 131 | extern void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark); |
Xiaoping Fan | 978b377 | 2015-05-27 14:15:18 -0700 | [diff] [blame^] | 132 | |
| 133 | #ifdef SFE_SUPPORT_IPV6 |
| 134 | /* |
| 135 | * IPv6 APIs used by connection manager |
| 136 | */ |
| 137 | extern int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb); |
| 138 | extern int sfe_ipv6_create_rule(struct sfe_connection_create *sic); |
| 139 | extern void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid); |
| 140 | extern void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev); |
| 141 | extern void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback); |
| 142 | extern void sfe_ipv6_update_rule(struct sfe_connection_create *sic); |
| 143 | extern void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark); |
| 144 | #else |
| 145 | static inline int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb) |
| 146 | { |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | static inline int sfe_ipv6_create_rule(struct sfe_connection_create *sic) |
| 151 | { |
| 152 | return -1; |
| 153 | } |
| 154 | |
| 155 | static inline void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid) |
| 156 | { |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | static inline void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev) |
| 161 | { |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | static inline void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback) |
| 166 | { |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | static inline void sfe_ipv6_update_rule(struct sfe_connection_create *sic) |
| 171 | { |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | static inline void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark) |
| 176 | { |
| 177 | return; |
| 178 | } |
| 179 | #endif |