blob: 83bd0f55546dfce7db890ad36f90d87acaa37997 [file] [log] [blame]
Amir Levy479cfdd2017-10-26 12:23:14 +03001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _IPAHAL_NAT_I_H_
14#define _IPAHAL_NAT_I_H_
15
16#include <linux/msm_ipa.h>
17
18/* ----------------------- IPv4 NAT Table Entry -------------------------
19 *
20 * -----------------------------------------------------------------------
21 * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
22 * -----------------------------------------------------------------------
23 * | Target IP(4B) | Private IP(4B) |
24 * -----------------------------------------------------------------------
25 * |Target Port(2B) |Private Port(2B)| Public Port(2B) | Next Index(2B) |
26 * -----------------------------------------------------------------------
27 * |Proto| TimeStamp(3B) | Flags(2B) |IP check sum Diff|
28 * |(1B) | |EN|Redirect|Resv | (2B) |
29 * -----------------------------------------------------------------------
30 * |TCP/UDP checksum| PDN info(2B) | SW Specific Parameters(4B) |
31 * | diff (2B) |Info|Resv |index table entry| prev index |
32 * -----------------------------------------------------------------------
33 */
34struct ipa_nat_hw_ipv4_entry {
35 /* An IP address can't be bit-field, because its address is used */
36 u32 private_ip;
37 u32 target_ip;
38
39 u32 next_index : 16;
40 u32 public_port : 16;
41 u32 private_port : 16;
42 u32 target_port : 16;
43 u32 ip_chksum : 16;
44
45 u32 rsvd1 : 14;
46 u32 redirect : 1;
47 u32 enable : 1;
48
49 u32 time_stamp : 24;
50 u32 protocol : 8;
51
52 u32 prev_index : 16;
53 u32 indx_tbl_entry : 16;
54
55 u32 rsvd2 : 12;
56 u32 pdn_index : 4; /* IPA 4.0 and greater */
57
58 u32 tcp_udp_chksum : 16;
59};
60
61/*--- IPV4 NAT Index Table Entry --
62 *---------------------------------
63 *| 3 | 2 | 1 | 0 |
64 *---------------------------------
65 *|next index(2B) |table entry(2B)|
66 *---------------------------------
67 */
68struct ipa_nat_hw_indx_entry {
69 u16 tbl_entry;
70 u16 next_index;
71};
72
73/**
74 * struct ipa_nat_hw_pdn_entry - IPA PDN config table entry
75 * @public_ip: the PDN's public ip
76 * @src_metadata: the PDN's metadata to be replaced for source NAT
77 * @dst_metadata: the PDN's metadata to be replaced for destination NAT
78 * @resrvd: reserved field
79 * ---------------------------------
80 * | 3 | 2 | 1 | 0 |
81 * ---------------------------------
82 * | public_ip (4B) |
83 * ---------------------------------
84 * | src_metadata (4B) |
85 * ---------------------------------
86 * | dst_metadata (4B) |
87 * ---------------------------------
88 * | resrvd (4B) |
89 * ---------------------------------
90 */
91struct ipa_nat_hw_pdn_entry {
92 u32 public_ip;
93 u32 src_metadata;
94 u32 dst_metadata;
95 u32 resrvd;
96};
97
98/*------------------------- IPV6CT Table Entry ------------------------------
99 *-----------------------------------------------------------------------------
100 *| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
101 *-----------------------------------------------------------------------------
102 *| Outbound Src IPv6 Address (8 LSB Bytes) |
103 *-----------------------------------------------------------------------------
104 *| Outbound Src IPv6 Address (8 MSB Bytes) |
105 *-----------------------------------------------------------------------------
106 *| Outbound Dest IPv6 Address (8 LSB Bytes) |
107 *-----------------------------------------------------------------------------
108 *| Outbound Dest IPv6 Address (8 MSB Bytes) |
109 *-----------------------------------------------------------------------------
110 *|Protocol| TimeStamp (3B) | Flags (2B) |Reserved (2B) |
111 *| (1B) | |Enable|Redirect|Resv | |
112 *-----------------------------------------------------------------------------
113 *|Reserved|Direction(1B)|Src Port(2B)| Dest Port (2B) |Next Index(2B)|
114 *| (1B) |IN|OUT|Resv | | | |
115 *-----------------------------------------------------------------------------
116 *| SW Specific Parameters(4B) | Reserved (4B) |
117 *| Prev Index (2B) |Reserved(2B)| |
118 *-----------------------------------------------------------------------------
119 *| Reserved (8B) |
120 *-----------------------------------------------------------------------------
121 */
122struct ipa_nat_hw_ipv6ct_entry {
123 /* An IP address can't be bit-field, because its address is used */
124 u64 src_ipv6_lsb;
125 u64 src_ipv6_msb;
126 u64 dest_ipv6_lsb;
127 u64 dest_ipv6_msb;
128
129 u64 rsvd1 : 30;
130 u64 redirect : 1;
131 u64 enable : 1;
132
133 u64 time_stamp : 24;
134 u64 protocol : 8;
135
136 u64 next_index : 16;
137 u64 dest_port : 16;
138 u64 src_port : 16;
139 u64 rsvd2 : 6;
140 u64 out_allowed : 1;
141 u64 in_allowed : 1;
142 u64 rsvd3 : 8;
143
144 u64 rsvd4 : 48;
145 u64 prev_index : 16;
146
147 u64 rsvd5 : 64;
148};
149
150int ipahal_nat_init(enum ipa_hw_type ipa_hw_type);
151
152#endif /* _IPAHAL_NAT_I_H_ */
153