summaryrefslogtreecommitdiff
path: root/msm8998/ipanat
diff options
context:
space:
mode:
authorThierry Strudel <tstrudel@google.com>2017-05-22 14:18:23 -0700
committerThierry Strudel <tstrudel@google.com>2017-05-22 14:18:24 -0700
commitd512f4232dc6c7105b0f8088c56f277132ca2ab3 (patch)
tree92e5650804f89878294ad2ed53aa69037ad6b309 /msm8998/ipanat
parent5b5af67d19baf862f5a8d6a7226feb630ec2f81a (diff)
downloadipacfg-mgr-d512f4232dc6c7105b0f8088c56f277132ca2ab3.tar.gz
msm8998: Update to 07.00.00.279.143
msm8998: from vendor/qcom/opensource/data-ipa-cfg-mgr cf6536c Promotion of data.lnx.3.0-00012. a916529 IPACM: enable IPACM for IPAv3 on Napali efa42d8 Promotion of data.lnx.3.0-00008. 590a0a8 ipacm: disable ipacm/ipanat on data.lnx.3.0 311752b ipacm: disable IPACM compile on 8996 8f39d1b Promotion of data.lnx.3.0-00006. f21db72 ipacm: disable IPACM compile on 8998 6ddffed Promotion of data.lnx.3.0-00003. b421102 FastForwarding data.lnx.3.0-dev from data.lnx.2.1-dev c61c4c6 IPACM: add static ARP entry d229e54 IPACM: resolving the UPSTEAM_DEL event timing issue edb6616 Promotion of data.lnx.2.0-00104. c1ac885 Promotion of data.lnx.2.0-00101. c5c50a7 ipacm: Fix KW issues 95f9c82 Merge "ipacm: Fix race condition between nat delete rule and update timestamp" 258d039 Promotion of data.lnx.2.0-00100. b550768 ipacm: Fix KW issues 46e9c26 IPACM: Handle 2 consecutive default route events 6b65103 Promotion of data.lnx.2.0-00098. dd76eeb Merge "Merge data.lnx.2.0-rel on remote branch" ac31b4e Merge data.lnx.2.0-rel on remote branch 38b9a0f lunch command change to msm8998 60c945f IPACM: fix the crash due to unsupport tether ifaces 57d61bb Promotion of data.lnx.2.0-00072. 8756392 IPACM: change DL routing rule to be non-hashable 9c7076b ipacm: Fix race condition between nat delete rule and update timestamp 6172f4f IPACM: fix the logic in WLAN AP-AP use case d73f0e7 Promotion of data.lnx.2.0-00069. cb202c9 IPACM: fix compilation error on IPAv2 98f1764 Promotion of data.lnx.2.0-00067. ff6a1f9 Merge "IPACM: add support for new QMI message" 033aef1 IPACM: delete client header when interface goes down 3e7c692 Promotion of data.lnx.2.0-00062. 96620a9 Promotion of data.lnx.2.0-00061. 5f55d12 IPACM: Fix the logic of inter-interface communication 203ebcf Promotion of data.lnx.2.0-00058. 06e7c06 IPACM: add support for new QMI message 89365a0 Merge "IPACM: not clean the mac entry in neighbor module" 21f7f88 IPACM: not clean the mac entry in neighbor module e4aebe9 ipacm: Fix race condition between nat delete and update timestamp d3eecde Promotion of data.lnx.2.0-00053. 7b7d16a Merge "ipacm: Enable IPACM for msm8940" 4d0e9fd Promotion of data.lnx.2.0-00052. 476d30b IPACM: add STA offload support on Android platform 488bbc8 ipacm: Enable IPACM for msm8940 cad3451 IPACM: adjust ip type maintenance logic 8138e1d Merge "IPACM: ignore early IPv6 default route event" 214a286 Merge "IPACM: fix the ip type issue" 3af7488 Promotion of data.lnx.2.0-00050. 8540322 Merge "IPACM: add wlan2 and wlan3 in xml file" 001391e Merge "IPACM: ignore invalid new neighbor message" 1468b49 IPACM: ignore early IPv6 default route event f4e88b3 IPACM: fix KW issues c8c6755 IPACM: fix the ip type issue a614891 Merge "IPACM: Cache non nat ifaces only for backhaul mode" 2b6c742 Merge "IPACM: fix KW issue" fe1f3ba Merge "IPACM: change WLAN category back to UNKNOWN_IF" 8242bfa Merge "ipacm: changes related to IP Passhthrough" d485dd9 Merge "IPACM: call ioctl IPA_IOC_PUT_RT_TBL" d9b2eaa IPACM: Cache non nat ifaces only for backhaul mode a9d53ce IPACM: Add dummy nat rules only for modem backhaul 18ed683 ipacm: changes related to IP Passhthrough df178de IPACM: change WLAN category back to UNKNOWN_IF 8c5a6d9 IPACM: fix KW issue f35038b IPACM: add wlan2 and wlan3 in xml file 7ca34e7 IPACM: ignore invalid new neighbor message 615dfb0 IPACM: fix KW issue b720974 ipacm: Fix NULL pointer and boundary check 6fb842a IPACM: Fix the dangling reference d930392 IPACM: call ioctl IPA_IOC_PUT_RT_TBL edfee47 ipacm: Buffer overflow 34b018d IPACM: fix hashable filtering rule issue bf2f775 Merge "IPACM: increase modem UL filtering rule cache" into data.lnx.2.0-dev 0262ca1 IPACM: increase modem UL filtering rule cache ba6fe11 IPACM: Add support for cobalt target ce89939 IPACM: Add Ethernet bridging central controller 00cdfd1 IPACM: add structure of two message queues c7ca219 IPACM: disable firewall monitor for Android 2f11160 IPACM: fix KW issues 6ae5e61 IPACM: refactoring filtering on LAN/WLAN interfaces b81a389 IPACM: Fix hashable fields to behave in boolean form bbb3c92 IPACM: fix compilation issue 1254fa1 IPACM: Add support for non IPA data path 48c4dd4 IPACM: add ethernet header for ipv6 DL traffic 9281509 IPACM: add support for CLANG compile de812b4 Promotion of data.lnx.1.0-00023. b8c5cad ipacm: Fix KW Errors b4deebb Merge "IPACM: clean the modem UL rules after SSR" 2dd08ba Merge "IPACM: change src mac to bridge0" 254de9d IPACM: clean the modem UL rules after SSR c251b38 Merge "IPACM: populate header handle" 25cef5e Merge "IPACM: fix ipv6 prefix problem" 2ee955c Merge "IPACM: Routing/Filtering support for IPAv3" 135b3da IPACM: populate header handle 37e0de9 IPACM: change src mac to bridge0 a26c8ec IPACM: fix ipv6 prefix problem 195d007 IPACM: wrong destination for ipv6 wan clients 0246824 Merge "IPACM: Fix to clean up default LL routes" ff639a2 IPACM: Routing/Filtering support for IPAv3 deb2acb Merge "IPACM: Fix the UL traffic taking SW-exception" bc093fe IPACM: Fix to clean up default LL routes a3cc814 IPACM: Fix the UL traffic taking SW-exception 6003744 Merge "IPACM: Fix the ipv6-only AP+STA use-case" 5cbcdf9 Merge "Opt out of clang till issues are fixed" 6d768a0 IPACM: Add support to get tether stats 06de5f1 IPACM: Fix the ipv6-only AP+STA use-case b06d13d Opt out of clang till issues are fixed aec4d3a Merge "IPACM: Fix a check of mmap call" 6673fc3 Merge "IPACM: enable logging only for debug builds" 77158c4 Merge "IPACM: Handle NEIGH_EVENT for linklocal IP/IPv6 address" b94558c IPACM: Handle NEIGH_EVENT for linklocal IP/IPv6 address 5a8c0fd IPACM: fix memory leak during client connect 9331f6e IPACM: Fix a check of mmap call 75da2ca IPACM: enable logging only for debug builds b707257 Merge "IPACM: Fix the nat timeout update issue" f9b4ce2 Merge "IPACM: fix the ipv6 rmnet-tethering FTP issue" 21c78b5 IPACM: Fix the nat timeout update issue 272a435 IPACM: Fix the compilation errors 3245b62 Merge "IPACM: Fix the nat iface missing when cfg change" ea8df80 IPACM: fix the ipv6 rmnet-tethering FTP issue b7bc7a8 Merge "IPACM: Handle new neighbor event" fafb397 IPACM: Fix the nat iface missing when cfg change fcfc079 Merge "IPACM: Fix the KW errors" b10242a IPACM: Handle new neighbor event db3f581 IPACM: fix icmpv4 filter rule not clean 3ca1627 Merge "IPACM: Handle AF_BRIDGE netlink message" e75695a Merge "IPACM: Fix the filter index while deleting the rule" cd1a76d IPACM: Fix the KW errors 6344d49 Merge "IPACM: fix incorrect filter index issue" 6d88f62 IPACM: fix incorrect filter index issue 5132d8c Merge "IPACM: fix lan2lan ipv6 issue" db99143 IPACM: Handle AF_BRIDGE netlink message d5611c7 IPACM: Fix the filter index while deleting the rule 5d2b750 Merge "IPACM: Suppor IPA stats update in ENFORCE mode" 600cc4b IPACM: fix lan2lan ipv6 issue 77a827e IPACM: Suppor IPA stats update in ENFORCE mode a5af1b1 Merge "IPACM: Support ipv6 android tethering statistics" 848c918 Merge "IPACM: Code cleanup for the WLAN guest ap filtering rule" c8488e1 Merge "IPACM: add TCP SYN/FIN/RST flt rules" 7a81cf6 IPACM: Support ipv6 android tethering statistics b989026 IPACM: add TCP SYN/FIN/RST flt rules 004093c IPACM: Code cleanup for the WLAN guest ap filtering rule 5d3f2e8 IPACM: Support android tethering statistics 1b7a7a8 Merge "IPACM: Add error check while querying TX and RX properties" aed53c4 Merge "IPACM: Enable meta-data in ICMP/ICMPv6 filtering rule on DL path" 7d83ed1 Merge "IPACM: Change the defualt access mode of WLAN interface" 7bd8f86 Merge "IPACM: Add support for HW path between Guest AP clients" aa624e6 IPACM: Enable meta-data in ICMP/ICMPv6 filtering rule on DL path 445f2ca IPACM: Add error check while querying TX and RX properties 0f224e5 IPACM: Add support for HW path between Guest AP clients e14d043 IPACM: Change the defualt access mode of WLAN interface 5cf6509 IPACM: Add support for Ethernet bridge Mode 269ef41 IPACM: Fix the correct syntax for ODU configuration e25e786 IPACM: Add initial support for HW path between CPE and USB clients 53251c6 Merge "IPACM: Delete nat entries from cache" 343fefc Merge "ipa : Addition of diag log messages for IPA NAT" 0f02b6d Merge "IPACM: Increase the neighbor mac cache" bc9fa75 IPACM: Delete nat entries from cache e6eecf7 IPACM: Increase the neighbor mac cache 421f006 ipa : Addition of diag log messages for IPA NAT d2c7e32 Merge "msm: ipa: Compile ipacm for specific targets only" 0440891 Merge "IPACM: First AP+STA connection is taking sw path" 9b85a07 IPACM: First AP+STA connection is taking sw path cb6a649 Merge "IPACM: Delete IPv6 filtering table when xlat PDN goes down" cb36a6c msm: ipa: Compile ipacm for specific targets only 207927e Merge "IPACM: Fix for LAN ICMP and ICMPv6 traffic to take HW path" e145724 IPACM: Fix for LAN ICMP and ICMPv6 traffic to take HW path e861a01 IPACM: Delete IPv6 filtering table when xlat PDN goes down 82e8c94 Merge "IPACM: Add support for AP-AP mode with internet only guest profile" 53cfe0b IPACM: Add support for AP-AP mode with internet only guest profile 26ef486 Merge "IPACM: fix rndis/ecm routing rule missing" 8e64030 IPACM: fix rndis/ecm routing rule missing b33445b Merge "IPACM: Add support for IHL based filtering of IPv6 fragement packets" d5fa7a9 Merge "IPACM: fix the wlan MCC mode failed" a03a3d7 Merge "IPACM: update dst mac address correctly" a569b82 Merge "IPACM: fix the CPE client header issue" 5196ce7 IPACM: fix the wlan MCC mode failed 5fcbe90 Merge "IPACM: support CPE<->WLAN through Ethernet Bridging data path" 7fb9f9b Merge "IPACM: prevent crash if iface not register Tx/Rx property" c3aabc9 IPACM: Add support for IHL based filtering of IPv6 fragement packets f3223b2 IPACM: update dst mac address correctly 864f9da IPACM: support CPE<->WLAN through Ethernet Bridging data path 534cee8 IPACM: prevent crash if iface not register Tx/Rx property 7eae4c0 Merge "IPACM : Add support for the XLAT feature" b6878a8 IPACM: fix the CPE client header issue f18c791 Merge "IPACM: Add support for new WDI events" 67d90b4 Merge "IPACM: fix the configuration file missing issue" 03c76cd Merge "IPACM: Add change to make IPv4 ICMP traffic to take SW path" 4b58536 IPACM : Add support for the XLAT feature 43cf93d IPACM: Add change to make IPv4 ICMP traffic to take SW path 5a5b310 IPACM: Add support for new WDI events 14ccbc5 IPACM: fix the configuration file missing issue ba5eefb Merge "IPACM: Add QMAP header in routing rule" 3759d35 Merge "IPACM: eMBMS traffic take offload path on ODU only" 602478e IPACM: Add QMAP header in routing rule b13808c Merge "IPACM: resolve the compile issue on 8952" 5b11a25 Merge "IPACM: add flt rule counter on each prod client" 5c4ed51 Merge "IPACM: enable ipacm daemon for user build" 9532e63 Merge "IPACM: support external-AP running bridge mode" 61061e1 IPACM: resolve the compile issue on 8952 a2e5d95 Merge "IPACM: Add support for Ethernet bridging in MCC Mode" 01b3070 Merge "IPACM: add support for cradle in msmzirc" b2d6cf9 IPACM: support external-AP running bridge mode e00fad9 IPACM: add flt rule counter on each prod client 2912b25 IPACM: enable ipacm daemon for user build 367a1d2 IPACM: add support for cradle in msmzirc bc0cbc8 IPACM: Add support for Ethernet bridging in MCC Mode ca22ece Merge "IPACM: fix the cpe bootup crash issue" ee56f1e Merge "IPACM: restore old connections when LTE up again" f735509 IPACM: eMBMS traffic take offload path on ODU only a8bce2c IPACM: fix the cpe bootup crash issue 8fa1c46 IPACM: restore old connections when LTE up again d772db4 Merge "IPACM: fix external AP switch issue" 1ef6f33 Merge "IPACM: check if the upstream_route_add is expected" f0c0448 Merge "IPACM: Remove meta data equation for ALG rules" b181b7e IPACM: fix external AP switch issue 97ea9bd IPACM: check if the upstream_route_add is expected c91d34c IPACM: Remove meta data equation for ALG rules 9dcd13f Merge "IPACM: Remove meta data equation for Ethernet bridging" f20d7f8 Merge "IPACM : Set a unique name for each thread in ipacm" 86d787e Merge "IPACM: fix memory leak issue" ccc12ed Merge "IPACM: fix the exception pipe issue in WAN interface" ca08e94 Merge "IPACM: Reset nat memory before posting init command" de35e43 IPACM : Set a unique name for each thread in ipacm c2d8533 IPACM: fix the exception pipe issue in WAN interface f7de8e2 IPACM: Remove meta data equation for Ethernet bridging 3674f70 IPACM: fix memory leak issue 9fb80f6 IPACM: Reset nat memory before posting init command a96aeda Merge "IPACM: fix the IPv6 DL fragment packet issue" d426f93 IPACM: fix the IPv6 DL fragment packet issue 524f777 Merge "IPACM: fix the embedded call issue in msmzirc" 936fd5d Merge "IPACM: support IPA_RM dependency for CPE project" 51203f8 Merge "IPACM: fix pointer init/free issue" 3df4de9 IPACM: fix the embedded call issue in msmzirc 19ef4cd Merge "IPACM: Change the TCP control filtering rule" 47d322e IPACM: fix pointer init/free issue 7a35164 Merge "IPACM: Handle no ALG ports case" ecdf7a3 IPACM: Handle no ALG ports case 381d2e7 IPACM: Change the TCP control filtering rule f59e9c4 IPACM: support IPA_RM dependency for CPE project e9218d9 Merge "IPACM: fix modem assert issue after eMBMS goes down" ee92e14 Merge "IPACM: add MCC/SCC switch support in ipacm" f5efb4f IPACM: fix modem assert issue after eMBMS goes down 2b094f5 IPACM: add MCC/SCC switch support in ipacm 14f34c6 Merge "IPACM: fix ecm cradle mode unexpected link-down event" ae0436d IPACM: fix ecm cradle mode unexpected link-down event 63c52f5 Merge "IPACM: fix the issue of missing first new neighbor message" 6d07433 Merge "IPACM: fix the issue of missing first new neighbor message" b7c587d Merge "IPACM: Fix lan2lan RT rule failed issue" e9d9b15 IPACM: fix the issue of missing first new neighbor message ea725c4 Merge "IPACM: add support for Ethernet Bridging" 1f7e9ab Merge "IPACM: Fix IPv6 DL fragmented packet issue" af8ebea IPACM: add support for Ethernet Bridging e7824f7 Merge "IPACM: fix the exception pipe index" 392b33f Merge "IPACM: Increase the maximum number of modem UL filtering rules" 65a2990 IPACM: Fix lan2lan RT rule failed issue 273d5f6 IPACM: Fix IPv6 DL fragmented packet issue a6a7021 IPACM: Increase the maximum number of modem UL filtering rules 89683ee Merge "Data compilation fix:" 8bff703 Data compilation fix: 69b032b IPACM: fix the exception pipe index a48dcd3 Merge "IPACM: Fixes memory leak issue when wlan up/down" af99b77 Merge "IPACM: Move ipacm.pid file to /data/misc/ipa" f9397fa IPACM: Fixes memory leak issue when wlan up/down 55901d0 Merge "IPACM: Fixes IPA_RM dependency issue on cradle" cca4f44 IPACM: Fixes IPA_RM dependency issue on cradle a7ec26b Merge " IPACM: Fixes for Wi-Fi offload for AP-STA mode" e13f5ee IPACM: Move ipacm.pid file to /data/misc/ipa c63fb0e Merge "IPACM: Fix KW issue" 4f24417 Merge "IPACM: Fix RNDIS ipv6 ping issue" c09b0f1 IPACM: Fixes for Wi-Fi offload for AP-STA mode 8098376 IPACM: Fix RNDIS ipv6 ping issue 377db1a IPACM: Fix KW issue f0a69fe Merge "IPACM: support ODU project in LE" fa4e388 IPACM: support ODU project in LE 0d977bd Merge "IPACM: move the socket location in Android" 543b701 Merge "IPACM: filter out AF_BRIDGE netlink message" 31762e1 IPACM: move the socket location in Android 2736e16 IPACM: filter out AF_BRIDGE netlink message d0dd21c Merge "IPACM: change filter rule deletion order" 010b92e Merge "IPACM: Fix AP+STA mode FTP loca-subnet disconnect issue" c059387 Merge "IPACM: speed up to construct wifi-client RT rules" ccb6972 IPACM: speed up to construct wifi-client RT rules 2c7d962 IPACM: Fix AP+STA mode FTP loca-subnet disconnect issue defdef0 IPACM: change filter rule deletion order e36f332 Merge "ipanat: move ipaNatTable device node creation" 3d5511d Merge "ipanat: Add IPANT tests" fa15031 Merge "IPACM: ignore SW-routing enable/disable msgs" 46f513e IPACM: ignore SW-routing enable/disable msgs b1863ff Merge " Compile out for TARGET_USES_AOSP" b2f6530 Merge "IPACM: Add dynamic support for swtiching between SW/HW path" 2ace013 ipanat: Add IPANT tests 244b846 IPACM: Add dynamic support for swtiching between SW/HW path 1630672 Merge "IPACM: get upstream and tethered iface in Android" 6b6b53b Merge "IPACM: Change the method for preventing multiple instances of ipacm" 785a59f Merge "IPACM: Clean the NAT rules before delete RT rules" 49e65ab ipanat: move ipaNatTable device node creation d1e8dd8 IPACM: get upstream and tethered iface in Android 13fe7ba Compile out for TARGET_USES_AOSP 6a1e1fc Merge "IPACM: not contruct rules in wlan STA mode for msm8994" 866dbb8 IPACM: Clean the NAT rules before delete RT rules f31d506 IPACM: not contruct rules in wlan STA mode for msm8994 6f5c0bd IPACM: Change the method for preventing multiple instances of ipacm 585dc59 Merge "IPACM: Warn messages seen on Apps processor and follows the Data stall" 464d17b Merge "IPACM: workaround to get upstream iface from netlink" 13d56bf Merge "IPACM: Fix klocwork issue on master branch" 9fba0cf IPACM: workaround to get upstream iface from netlink 1db816f IPACM: Warn messages seen on Apps processor and follows the Data stall e8c9d24 IPACM: Fix klocwork issue on master branch 87735cb Merge "IPACM: fix the index issue of incorrect modem UL filtering rule" 04998a1 Merge "IPANAT: fix for loop issue" 7c7b9f2 IPACM: fix the index issue of incorrect modem UL filtering rule 0ad0798 Merge "IPACM: add more ALG ports for Android platform" 5d10837 Merge "IPACM: Update QMAP ID in USB/WLAN pipes only for Internet PDN" c56fc32 IPACM: add more ALG ports for Android platform 6290421 IPANAT: fix for loop issue 5b2d3ff IPACM: Update QMAP ID in USB/WLAN pipes only for Internet PDN 09f9bde Merge "IPACM: fix cradle mode plug-in/plug-out issue" afd3444 Merge "IPACM: fix Q6 Rx rules not clean issue" 820aea6 Merge "IPACM: reduce the prints in QXDM" f388580 IPACM: fix cradle mode plug-in/plug-out issue ec90eb2 Merge "IPACM: Fix fragment exception rule should be first" 57c11b7 IPACM: reduce the prints in QXDM b53825f IPACM: fix Q6 Rx rules not clean issue 670c6c3 IPACM: Fix fragment exception rule should be first c451a9c Merge "IPACM: try to continue read msg from ipa-driver" e9608f5 Merge "IPACM: fix IPv6 embedded call not working issue" 9c6dc9b Merge "IPACM: support upstream wan iface in Android" 5d3b03c IPACM: try to continue read msg from ipa-driver 7ac041a IPACM: fix IPv6 embedded call not working issue 2b78d90 Merge "IPACM: fix QXDM log not working in Android" 3c50380 Merge "IPANAT: remove the syslog usage" d048888 Merge "IPACM: fix ipv6 rules issue for usb/wlan client" 5c05ce4 Merge "IPACM: Fix end2end ipv6 ping issue" a77b544 IPACM: fix QXDM log not working in Android ee2cd35 IPACM: support upstream wan iface in Android 4300e0b Merge "ipa-cfg-mgr: Add Android.mk files for IPACM and IPANAT" a1d886d ipa-cfg-mgr: Add Android.mk files for IPACM and IPANAT ebe3f62 Merge "IPACM: Add support for closing wwan_ioctl" c800a6a Merge "IPACM: fix file descriptor issue" 43b4138 IPACM: fix ipv6 rules issue for usb/wlan client c4a7135 IPACM: Fix end2end ipv6 ping issue b367620 Merge "IPACM: fix crash issue in LE" 0bd8968 IPACM: fix crash issue in LE 025d3ad Merge "IPACM: add backup support to reset upstream iface" 9f22bea IPACM: add backup support to reset upstream iface 96deecd IPANAT: remove the syslog usage 2eeab69 IPACM: fix file descriptor issue 62ce019 Merge "IPACM: Fix conntrack event comes earlier than new neighbor" 8d6de24 Merge "IPACM: fix missing RTM_NEWNEIGH for WLAN channel change" 21f6687 IPACM: Fix conntrack event comes earlier than new neighbor f69c46a IPACM: fix missing RTM_NEWNEIGH for WLAN channel change 209c08f Merge "IPACM: Fix IPv4 firewall not working issue" bbe16ae IPACM: Fix IPv4 firewall not working issue 4a22524 Merge "IPACM: support QXDM diag via socket" 55f064d IPACM: support QXDM diag via socket 2225698 Merge "IPANAT: fix IPANAT deletion issue" a664021 Merge "IPANAT: Fix checkpatch errors" 9110118 IPANAT: fix IPANAT deletion issue c8e3c33 IPANAT: Fix checkpatch errors ef6b669 IPACM: Add support for closing wwan_ioctl 9724bb8 Merge "IPACM: fix ipv6 ecm-backhaul issue" 0708393 Merge "IPACM: fix crash issue in Android" 288da49 IPACM: fix ipv6 ecm-backhaul issue 6cc1c79 IPACM: fix crash issue in Android 9819939 Merge "IPACM: support 8994 private subnet change" 8a61e2e Merge "IPACM: fix wlan-event issue from ipa-driver" 85968e6 IPACM: fix wlan-event issue from ipa-driver 18a55e0 IPACM: support 8994 private subnet change 76134e8 Merge "IPACM: add support for multi-PDN" 8780420 Merge "IPACM: read XML configuration for bridge name" fc43b4d IPACM: add support for multi-PDN 1124056 IPACM: read XML configuration for bridge name 9e7caf9 Merge "IPACM: fix klocwork issue" fcb575d IPACM: fix klocwork issue 30c1b45 Merge "IPACM: support usb dynamic config w.o plug-in/out" 5a569ca IPACM: support usb dynamic config w.o plug-in/out f13f7ae Merge "IPACM: add conntrack optimization for lan2lan module" d4d49c6 IPACM: add conntrack optimization for lan2lan module ef15eec Merge "ipacm: CR652134 fix - Decreasing total_num_wifi_clients" 8adfae2 ipacm: CR652134 fix - Decreasing total_num_wifi_clients 87e61a0 Merge "IPANAT: fix AP+STA mode packets take SW path" 29eec61 IPANAT: fix AP+STA mode packets take SW path c719700 Merge "IPACM: support dynamic ipacm configuration" d3cf8bf IPACM: support dynamic ipacm configuration f2b8209 Merge "IPACM: fix filtering rule index for WLAN APAP mode" 580dcfb IPACM: fix filtering rule index for WLAN APAP mode a3347b2 Merge "IPACM: clean up q6 static UL filter rules" 58befd2 IPACM: clean up q6 static UL filter rules f41c21e Merge "IPACM: fix v6 wan link-down up issue" b728822 IPACM: fix v6 wan link-down up issue e01e7e3 Merge "IPACM: fix wlan new_addr comes earlier issue" 316c852 IPACM: fix wlan new_addr comes earlier issue 2b7ae1b Merge "IPACM: fix WLAN mode switch and AP+STA mode STA LINK_DOWN issue" 3c708f5 IPACM: fix WLAN mode switch and AP+STA mode STA LINK_DOWN issue 25e0177 Merge "IPACM: Fix firewall rule IP address order problem" 1582b87 IPACM: Fix firewall rule IP address order problem 1a013dd Merge "IPACM: fix for lan2lan hw path" 5c36c2f IPACM: fix for lan2lan hw path 8849451 Merge "IPACM: enable LAN2LAN traffic using HW-path" b371dda IPACM: enable LAN2LAN traffic using HW-path 58e5591 Merge "IPACM: handle multiple ETH usb clients" 071a9b3 Merge "IPACM: support multiple ETH usb clients" 4b2d725 IPACM: handle multiple ETH usb clients 8cc9c72 Merge "IPANAT: Not add embedded connections in AP+STA mode" 3d02680 IPANAT: Not add embedded connections in AP+STA mode 8f381e6 Merge "IPACM: avoid duplicate instance" 873cc34 Merge "IPACM: Fix NAT table didn't delete when LTE down" 1318fb1 IPACM: Fix NAT table didn't delete when LTE down 050cb17 IPACM: avoid duplicate instance 15deef6 Merge "IPACM: support 8994 linux Android build" 1247ec2 Merge "Include unistd.h" 2642ee0 Include unistd.h 346eeeb IPACM: support multiple ETH usb clients b17124f IPACM: support 8994 linux Android build 4105bdb Merge "IPANAT: fix double NAT issue for embedded traffic" db6ab80 Merge "IPACM: fix dynamic firewall rule issue" 150a82c Merge "IPACM: support IPA power save feature" 96232de Merge "IPACM: fix ipv6 backhaul up again crash issue" ae94f35 IPACM: fix dynamic firewall rule issue 8c7397d IPANAT: fix double NAT issue for embedded traffic d6a64e0 IPACM: fix ipv6 backhaul up again crash issue b5e927c IPACM: support IPA power save feature 6031154 Merge "IPACM: fix v6 DL traffic going through SW path" 21f4e5e IPACM: fix v6 DL traffic going through SW path 3433990 Merge "IPANAT: fix nat entry is not clean when usb-client unplug" c0089bc IPANAT: fix nat entry is not clean when usb-client unplug 945e148 Merge "PACM: fix missing RTM_NEWLINK for ECM disconnect" 6f4512a PACM: fix missing RTM_NEWLINK for ECM disconnect 2df7909 Merge "IPACM: remove a2_service related dependency" 135424d Merge "IPACM: fix no default route v4/v6 rule with Q6 backhaul" 3e301ab IPACM: remove a2_service related dependency 6ab27d4 IPACM: fix no default route v4/v6 rule with Q6 backhaul 182de2c Merge "IPACM: Fix for AP + STA mode" 82d7068 IPACM: Fix for AP + STA mode 80383af Merge "IPACM: fix firewall rule, ecm RT rule missing" b02ce8e IPACM: fix firewall rule, ecm RT rule missing 8ab9b2b Merge "Fix rule index notification to modem: take into account the private subnet filtering rules" cd1732e Fix rule index notification to modem: take into account the private subnet filtering rules d3f4266 Merge "IPACM: Added support for 9x35 HW/SW architecture" 05ad9f3 IPACM: Added support for 9x35 HW/SW architecture a1c9c9d Merge "IPACM: fix file-descriptor not clean issue" bad7599 Merge "IPACM: fix lan/wan calloc free issue" a9f45d3 IPACM: fix lan/wan calloc free issue 8dda3a9 IPACM: fix file-descriptor not clean issue 6def911 Merge "IPACM: increase netlink socket buffer size" 0a84f13 IPACM: increase netlink socket buffer size 38361ab Merge "IPACM: fix v6-firewall rule issue" 1a82ff2 IPACM: fix v6-firewall rule issue d31030c Merge "IPACM: IPANAT changes for 9x35" 63b0a80 Merge "IPANAT fix: delete IPANAT entry when ECM client went away" 03b4ade Merge "ipanat: fix wifi-client reconnect nat miss" e9f5938 IPANAT fix: delete IPANAT entry when ECM client went away 89d1ebe ipanat: fix wifi-client reconnect nat miss 57fbbb5 IPACM: IPANAT changes for 9x35 98bd07d Merge "IPACM: fix wlan client out of power-mode v6 issue" 7877ea1 IPACM: fix wlan client out of power-mode v6 issue 58089b1 Merge "IPACM: fix nat entries not clean in IPA hardware" b7c1dd4 IPACM: fix nat entries not clean in IPA hardware 04f5273 Merge "IPACM: Fix wifi-client header not clean issue" 3be1d2a IPACM: Fix wifi-client header not clean issue c5eca64 Merge "IPACM: delete dependency before free Rx-property" 4f5072b IPACM: delete dependency before free Rx-property 0b4716f Merge "IPACM: delete dependency even wlan rules are not clean" 74c1d7b IPACM: delete dependency even wlan rules are not clean d84a338 Merge "IPACM: fix AP+STA mode header not clean issue" 44f01b5 IPACM: fix AP+STA mode header not clean issue 944c93f Merge "IPACM/IPANAT: Fix using syslog causing crash" da7c82d IPACM/IPANAT: Fix using syslog causing crash a1289c2 Merge "IPACM: fix NAT-rules deleted before RT-rules when power-save" 38c09d6 IPACM: fix NAT-rules deleted before RT-rules when power-save f3bd1e6 Merge "Fix loop issue in IPANAT table" a781bcc Fix loop issue in IPANAT table 3dc1e75 Merge "1. Only interfaces that register rx or tx properties should be nat by ipahw 2. Change NAT-logic in IPACM to only do NATTING for NAT-iface clients 3. Instaed of blocking NON-NAT iface clients" add7763 Merge " 1. update timeout for both tcp and udp connections 2. To update udp connections timeout value use ip_conntrack_udp_timeout_stream 3. To update tcp connection timeout value use ip_conntrack_tcp_timeout_established 4. Start inotify thread to read update udp/tcp timeout values"" 34655b1 1. Only interfaces that register rx or tx properties should be nat by ipahw 2. Change NAT-logic in IPACM to only do NATTING for NAT-iface clients 3. Instaed of blocking NON-NAT iface clients 3342e48 1. update timeout for both tcp and udp connections 2. To update udp connections timeout value use ip_conntrack_udp_timeout_stream 3. To update tcp connection timeout value use ip_conntrack_tcp_timeout_established 4. Start inotify thread to read update udp/tcp timeout values" 366a700 Merge "To fix kw errors" c2df049 Merge "Listen for AP_disconnect/STA_disconnect from WLAN-Driver and post link-down event to IPACM CMD_queue" a40f99f To fix kw errors 384df79 Listen for AP_disconnect/STA_disconnect from WLAN-Driver and post link-down event to IPACM CMD_queue 92881cd Merge "Create IPACM_ConntrackClient instance as part of global variable initialization to avoid race conditions" cb4ce7f Merge "Create IPACM_ConntrackClient instance as part of global variable initialization to avoid race conditions" d26fca0 Merge "Remove the hack in makefile, now IPACM will support dynamically both WLAN has RX_prop or none" 9cf6a54 Create IPACM_ConntrackClient instance as part of global variable initialization to avoid race conditions 371dbc4 Remove the hack in makefile, now IPACM will support dynamically both WLAN has RX_prop or none f1e2f79 Merge "(1) In ECM use-case, if doing fast plug-in/plug-out within 2s, the IPACM sometimes will crash due to rmnet0 didn't have TX-property, add checking there (2) Event-dispatcher has some bugs when instance closes, somehow IPACM will access the freed memory location try to find next link-list cell" 9e47e84 (1) In ECM use-case, if doing fast plug-in/plug-out within 2s, the IPACM sometimes will crash due to rmnet0 didn't have TX-property, add checking there (2) Event-dispatcher has some bugs when instance closes, somehow IPACM will access the freed memory location try to find next link-list cell 2c125f5 Merge "(1) In AP+STA mode, if the default gw route event comes later than new_neighbor event for wlan0 (STA iface), IPACM received new_neighbor will check if header-construction is done already or not, won't insert multiple STA_header" 6fe0dc7 (1) In AP+STA mode, if the default gw route event comes later than new_neighbor event for wlan0 (STA iface), IPACM received new_neighbor will check if header-construction is done already or not, won't insert multiple STA_header c7a21d0 Merge "(1) Support QCMAP feature: Guest_AP can.t talk to Primary_AP etc (2) Solution is to put all LAN traffic to A5" b1dceb6 (1) Support QCMAP feature: Guest_AP can.t talk to Primary_AP etc (2) Solution is to put all LAN traffic to A5 f0470eb Merge "(1) support ECM plug/unplug behavior to configure/delete ECM related filter and routing rules without monitoring iface up/down. Current USB-team didn.t bring up/down ecm0 ifaces. (2) Solve the ECM usb-unplug, RT-rules are not clean issue." 686c676 (1) support ECM plug/unplug behavior to configure/delete ECM related filter and routing rules without monitoring iface up/down. Current USB-team didn.t bring up/down ecm0 ifaces. (2) Solve the ECM usb-unplug, RT-rules are not clean issue. 40295a4 Merge "Support ipv4 brdige0 changes, IPACM will get all wifi-client/ecm-client with ipv4-address coming from bridge0" 93a8d96 Support ipv4 brdige0 changes, IPACM will get all wifi-client/ecm-client with ipv4-address coming from bridge0 7285a48 Merge "Enabling sys log by default using start_ipacm_le script for more control" 014d447 Enabling sys log by default using start_ipacm_le script for more control f1c3b34 Merge "Fixes for: (1) default wan filtering rule missing due to the mobileap_firewall.xml file is not specified. (2) add hack in IPACM to not add dependency between WLAN-RX endpoint to ECM/A2-Tx endpoints by only changing makefile in the future (AM_CPPFLAGS += -DWLAN_SW_RX)." d9b927d Fixes for: (1) default wan filtering rule missing due to the mobileap_firewall.xml file is not specified. (2) add hack in IPACM to not add dependency between WLAN-RX endpoint to ECM/A2-Tx endpoints by only changing makefile in the future (AM_CPPFLAGS += -DWLAN_SW_RX). ecce84a Merge "Don't overwrite mobileap_firewall.xml from QCMAP team" cc3546f Merge "Support if wlan ipv4 new_addr comes earlier than AP_connect from WLAN_driver" c0c3e5f Merge "1. adding sys log support 2. added dynamic enabled/disable file/sys log 3. added circular file log" d778aca Merge "code changes for IPACM support A2-power-collapse by add/delete dependency between ifaces (A2/HSIC/ECM)" 003f942 Don't overwrite mobileap_firewall.xml from QCMAP team 129c14c Support if wlan ipv4 new_addr comes earlier than AP_connect from WLAN_driver 87b30d9 1. adding sys log support 2. added dynamic enabled/disable file/sys log 3. added circular file log 4367ae1 code changes for IPACM support A2-power-collapse by add/delete dependency between ifaces (A2/HSIC/ECM) ee653a1 Merge "Enable nat entry in cache after adding nat entry successfully" 7484a35 Merge "Filter out rndis connections at user space not using netfilter conntrack filters" 270db22 Enable nat entry in cache after adding nat entry successfully 0920d49 Filter out rndis connections at user space not using netfilter conntrack filters 48c1c38 Merge "fix the ipv6 default route missing when v6 firewall rules appear" 2ba5eba Merge "Here is some code-change for 1. fix the header not clean issue in AP+STA mode for v6 2. checking the wifi client RT rule is setup or not when receive power-save mode to delete" 8ef5307 fix the ipv6 default route missing when v6 firewall rules appear 97293ae Here is some code-change for 1. fix the header not clean issue in AP+STA mode for v6 2. checking the wifi client RT rule is setup or not when receive power-save mode to delete b966da7 Merge "This fix includes:" 67ae799 This fix includes: c10fd7a Merge "Issue fixed:" 590f1f8 Merge "Fix the ipv6 default route" 339e031 Issue fixed: 77df222 Fix the ipv6 default route 35dcc1d Merge "From Skylar "There are some modification on netlink things to process new_neighbor messages, also IPACM_neighbor is to handle construct correct iface name. The WLAN changes will be 1. Duplicated table 2. Increase 2 filtering-rules which we discussed this afternoon"" 3d7f2a2 From Skylar "There are some modification on netlink things to process new_neighbor messages, also IPACM_neighbor is to handle construct correct iface name. The WLAN changes will be 1. Duplicated table 2. Increase 2 filtering-rules which we discussed this afternoon" 3f20a2f Merge "Here is the fix for support wifi-client dynamically changing their ipv4 and IPACM will handle it when receive new_neighbor messages." bf25d12 Here is the fix for support wifi-client dynamically changing their ipv4 and IPACM will handle it when receive new_neighbor messages. 6da8dfc Merge "Additional fixes from bringup:" a15bf78 Merge "Fixes from bringup:" 4671a55 Additional fixes from bringup: fdad00d Fixes from bringup: 76f9bfc Merge "Various fixes from bringup:" 5a9a114 Various fixes from bringup: c1e7bca Merge "Various fixes from bring-up:" 4e23a83 Merge "Add ipv6 header config, firewall enhancement" 373d33d Various fixes from bring-up: 82e2b24 Merge "Use sanitized headers in data-ipa-cfg-mgr makefiles" a1644d1 Add ipv6 header config, firewall enhancement 70267d3 Use sanitized headers in data-ipa-cfg-mgr makefiles ef2ae2a Merge "Fix include path to point to sysroot" 04bdae7 Merge "Additional fixes from bring-up:" 18067b9 Additional fixes from bring-up: 17889f9 Fix include path to point to sysroot fe84c85 Merge "Rename data-ipa to data-ipa-cfg-mgr to align with manifest path" f487a7b Rename data-ipa to data-ipa-cfg-mgr to align with manifest path 1979fa8 Merge "Fixed crashes found during Bring up" 72c8c60 Fixed crashes found during Bring up 6e625fd Merge "Fixed below issues found during IPA bring up:" 402ba24 Fixed below issues found during IPA bring up: ac1ba53 Merge "IPA configuration manager daemon and IPA NAT library." 5dcfae2 IPA configuration manager daemon and IPA NAT library. ca61ebf Initial empty repository Test: build, boot, sanity checks Bug: 38282057 Change-Id: Ia59c4422a2feba90de4b3d37d30d16bbc5c6b470 Signed-off-by: Thierry Strudel <tstrudel@google.com>
Diffstat (limited to 'msm8998/ipanat')
-rw-r--r--msm8998/ipanat/inc/ipa_nat_drv.h116
-rw-r--r--msm8998/ipanat/inc/ipa_nat_drvi.h482
-rw-r--r--msm8998/ipanat/inc/ipa_nat_logi.h73
-rw-r--r--msm8998/ipanat/src/Android.mk27
-rw-r--r--msm8998/ipanat/src/Makefile.am21
-rw-r--r--msm8998/ipanat/src/ipa_nat_drv.c175
-rw-r--r--msm8998/ipanat/src/ipa_nat_drvi.c2368
-rw-r--r--msm8998/ipanat/src/ipa_nat_logi.c49
-rw-r--r--msm8998/ipanat/test/Android.mk52
-rw-r--r--msm8998/ipanat/test/Makefile.am42
-rw-r--r--msm8998/ipanat/test/README.txt18
-rw-r--r--msm8998/ipanat/test/ipa_nat_test.h104
-rw-r--r--msm8998/ipanat/test/ipa_nat_test000.c69
-rw-r--r--msm8998/ipanat/test/ipa_nat_test001.c77
-rw-r--r--msm8998/ipanat/test/ipa_nat_test002.c85
-rw-r--r--msm8998/ipanat/test/ipa_nat_test003.c82
-rw-r--r--msm8998/ipanat/test/ipa_nat_test004.c70
-rw-r--r--msm8998/ipanat/test/ipa_nat_test005.c83
-rw-r--r--msm8998/ipanat/test/ipa_nat_test006.c91
-rw-r--r--msm8998/ipanat/test/ipa_nat_test007.c88
-rw-r--r--msm8998/ipanat/test/ipa_nat_test008.c94
-rw-r--r--msm8998/ipanat/test/ipa_nat_test009.c96
-rw-r--r--msm8998/ipanat/test/ipa_nat_test010.c108
-rw-r--r--msm8998/ipanat/test/ipa_nat_test011.c108
-rw-r--r--msm8998/ipanat/test/ipa_nat_test012.c109
-rw-r--r--msm8998/ipanat/test/ipa_nat_test013.c108
-rw-r--r--msm8998/ipanat/test/ipa_nat_test014.c95
-rw-r--r--msm8998/ipanat/test/ipa_nat_test015.c97
-rw-r--r--msm8998/ipanat/test/ipa_nat_test016.c96
-rw-r--r--msm8998/ipanat/test/ipa_nat_test017.c96
-rw-r--r--msm8998/ipanat/test/ipa_nat_test018.c96
-rw-r--r--msm8998/ipanat/test/ipa_nat_test019.c96
-rw-r--r--msm8998/ipanat/test/ipa_nat_test020.c100
-rw-r--r--msm8998/ipanat/test/ipa_nat_test021.c81
-rw-r--r--msm8998/ipanat/test/ipa_nat_test022.c118
-rw-r--r--msm8998/ipanat/test/main.c640
36 files changed, 6310 insertions, 0 deletions
diff --git a/msm8998/ipanat/inc/ipa_nat_drv.h b/msm8998/ipanat/inc/ipa_nat_drv.h
new file mode 100644
index 0000000..04e3af9
--- /dev/null
+++ b/msm8998/ipanat/inc/ipa_nat_drv.h
@@ -0,0 +1,116 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "string.h" /* memset */
+#include "stdlib.h" /* free, malloc */
+#include "stdint.h" /* uint32_t */
+
+/**
+ * struct ipa_nat_ipv4_rule - To hold ipv4 nat rule
+ * @target_ip: destination ip address
+ * @private_ip: private ip address
+ * @target_port: destination port
+ * @private_port: private port
+ * @protocol: protocol of rule (tcp/udp)
+ */
+typedef struct {
+ uint32_t target_ip;
+ uint32_t private_ip;
+ uint16_t target_port;
+ uint16_t private_port;
+ uint16_t public_port;
+ uint8_t protocol;
+} ipa_nat_ipv4_rule;
+
+/**
+ * ipa_nat_add_ipv4_tbl() - create ipv4 nat table
+ * @public_ip_addr: [in] public ipv4 address
+ * @number_of_entries: [in] number of nat entries
+ * @table_handle: [out] Handle of new ipv4 nat table
+ *
+ * To create new ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_add_ipv4_tbl(uint32_t public_ip_addr,
+ uint16_t number_of_entries,
+ uint32_t *table_handle);
+
+/**
+ * ipa_nat_del_ipv4_tbl() - delete ipv4 table
+ * @table_handle: [in] Handle of ipv4 nat table
+ *
+ * To delete given ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_del_ipv4_tbl(uint32_t table_handle);
+
+/**
+ * ipa_nat_add_ipv4_rule() - to insert new ipv4 rule
+ * @table_handle: [in] handle of ipv4 nat table
+ * @rule: [in] Pointer to new rule
+ * @rule_handle: [out] Return the handle to rule
+ *
+ * To insert new ipv4 nat rule into ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_add_ipv4_rule(uint32_t table_handle,
+ const ipa_nat_ipv4_rule * rule,
+ uint32_t *rule_handle);
+
+/**
+ * ipa_nat_del_ipv4_rule() - to delete ipv4 nat rule
+ * @table_handle: [in] handle of ipv4 nat table
+ * @rule_handle: [in] ipv4 nat rule handle
+ *
+ * To insert new ipv4 nat rule into ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_del_ipv4_rule(uint32_t table_handle,
+ uint32_t rule_handle);
+
+
+/**
+ * ipa_nat_query_timestamp() - to query timestamp
+ * @table_handle: [in] handle of ipv4 nat table
+ * @rule_handle: [in] ipv4 nat rule handle
+ * @time_stamp: [out] time stamp of rule
+ *
+ * To retrieve the timestamp that lastly the
+ * nat rule was accessed
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_query_timestamp(uint32_t table_handle,
+ uint32_t rule_handle,
+ uint32_t *time_stamp);
+
diff --git a/msm8998/ipanat/inc/ipa_nat_drvi.h b/msm8998/ipanat/inc/ipa_nat_drvi.h
new file mode 100644
index 0000000..6f9b1bd
--- /dev/null
+++ b/msm8998/ipanat/inc/ipa_nat_drvi.h
@@ -0,0 +1,482 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IPA_NAT_DRVI_H
+#define IPA_NAT_DRVI_H
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <linux/msm_ipa.h>
+#include <netinet/in.h>
+#include <sys/inotify.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include "ipa_nat_logi.h"
+
+#define NAT_DUMP
+
+/*======= IMPLEMENTATION related data structures and functions ======= */
+#ifdef IPA_ON_R3PC
+#define NAT_MMAP_MEM_SIZE (2 * 1024UL * 1024UL - 1)
+#endif
+
+#define IPA_DEV_NAME "/dev/ipa"
+#define NAT_DEV_DIR "/dev"
+#define NAT_DEV_NAME "ipaNatTable"
+#define NAT_DEV_FULL_NAME "/dev/ipaNatTable"
+
+#define IPA_NAT_TABLE_VALID 1
+#define IPA_NAT_MAX_IP4_TBLS 1
+#define IPA_NAT_BASE_TABLE_PERCENTAGE .8
+#define IPA_NAT_EXPANSION_TABLE_PERCENTAGE .2
+
+#define IPA_NAT_NUM_OF_BASE_TABLES 2
+#define IPA_NAT_UNUSED_BASE_ENTRIES 2
+
+#define IPA_NAT_RULE_FLAG_FIELD_OFFSET 18
+#define IPA_NAT_RULE_NEXT_FIELD_OFFSET 8
+#define IPA_NAT_RULE_PROTO_FIELD_OFFSET 22
+
+#define IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET 2
+#define IPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET 0
+
+#define IPA_NAT_RULE_FLAG_FIELD_SIZE 2
+#define IPA_NAT_RULE_NEXTFIELD_FIELD_SIZE 2
+
+#define IPA_NAT_FLAG_ENABLE_BIT_MASK 0x8000
+#define IPA_NAT_FLAG_DISABLE_BIT_MASK 0x0000
+
+#define IPA_NAT_FLAG_ENABLE_BIT 1
+#define IPA_NAT_FLAG_DISABLE_BIT 0
+
+#define IPA_NAT_INVALID_PROTO_FIELD_VALUE 0xFF00
+#define IPA_NAT_INVALID_PROTO_FIELD_CMP 0xFF
+
+#define IPA_NAT_INVALID_INDEX 0xFF
+#define IPA_NAT_INVALID_NAT_ENTRY 0x0
+
+#define INDX_TBL_ENTRY_SIZE_IN_BITS 16
+
+/* ----------- Rule id -----------------------
+
+ ------------------------------------------------
+ | 3bits | 12 bits | 1 bit |
+ ------------------------------------------------
+ | reserved | index into table | 0 - base |
+ | | | 1 - expansion |
+ ------------------------------------------------
+
+*/
+#define IPA_NAT_RULE_HDL_TBL_TYPE_BITS 0x1
+#define IPA_NAT_RULE_HDL_TBL_TYPE_MASK 0x1
+
+/* ----------- sw specif parameter -----
+ ------------------------------------
+ | 16 bits | 16 bits |
+ ------------------------------------
+ | index table | prev index |
+ | entry | |
+ ------------------------------------
+-----------------------------------------*/
+#define IPA_NAT_SW_PARAM_PREV_INDX_BYTE 0
+#define IPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE 1
+
+typedef enum {
+ IPA_NAT_BASE_TBL = 0,
+ IPA_NAT_EXPN_TBL = 1,
+ IPA_NAT_INDX_TBL = 2,
+ IPA_NAT_INDEX_EXPN_TBL = 3,
+} nat_table_type;
+
+typedef enum {
+ NEXT_INDEX_FIELD,
+ PUBLIC_PORT_FILED,
+ PRIVATE_PORT_FIELD,
+ TARGET_PORT_FIELD,
+ IP_CHKSUM_FIELD,
+ ENABLE_FIELD,
+ TIME_STAMP_FIELD,
+ PROTOCOL_FIELD,
+ TCP_UDP_CHKSUM_FIELD,
+ SW_SPEC_PARAM_PREV_INDEX_FIELD,
+ SW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD,
+ INDX_TBL_TBL_ENTRY_FIELD,
+ INDX_TBL_NEXT_INDEX_FILED
+} ipa_nat_rule_field_type;
+
+/*
+ ---------------------------------------------
+ | 3 | 2 | 1 | 0 |
+ ---------------------------------------------
+ | Public Port(2B) | Next Index(2B) |
+ ---------------------------------------------
+*/
+typedef struct {
+ uint32_t next_index:16;
+ uint32_t public_port:16;
+} next_index_pub_port;
+
+
+/*
+ ---------------------------------------------
+ | 3 | 2 | 1 | 0 |
+ ---------------------------------------------
+ | Flags(2B) | IP check sum Diff(2B)|
+ |EN|FIN|Resv | | |
+ ---------------------------------------------
+*/
+typedef struct {
+ uint32_t ip_chksum:16;
+ uint32_t rsvd1:14;
+ uint32_t redirect:1;
+ uint32_t enable:1;
+} ipcksum_enbl;
+
+
+/*
+ ---------------------------------------
+ | 7 | 6 | 5 | 4 |
+ ---------------------------------------
+ | Proto | TimeStamp(3B) |
+ | (1B) | |
+ ---------------------------------------
+*/
+typedef struct {
+ uint32_t time_stamp:24;
+ uint32_t protocol:8;
+} time_stamp_proto;
+
+
+/*
+ ---------------------------------------------
+ | 3 | 2 | 1 | 0 |
+ ---------------------------------------------
+ | next_index | Table entry |
+ ----------------------------------------------
+*/
+typedef struct {
+ uint16_t tbl_entry;
+ uint16_t next_index;
+} tbl_ent_nxt_indx;
+
+/*--------------------------------------------------
+ 32 bit sw_spec_params is interpreted as follows
+ ------------------------------------
+ | 16 bits | 16 bits |
+ ------------------------------------
+ | index table | prev index |
+ | entry | |
+ ------------------------------------
+--------------------------------------------------*/
+typedef struct {
+ uint16_t prev_index;
+ uint16_t index_table_entry;
+} sw_spec_params;
+
+/*------------------------ NAT Table Entry ---------------------------------------
+
+ -----------------------------------------------------------------------------------
+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+ -----------------------------------------------------------------------------------
+ | Target IP(4B) | Private IP(4B) |
+ -----------------------------------------------------------------------------------
+ |Target Port(2B) | Private Port(2B) | Public Port(2B) | Next Index(2B) |
+ -----------------------------------------------------------------------------------
+ | Proto | TimeStamp(3B) | Flags(2B) | IP check sum Diff(2B)|
+ | (1B) | |EN|FIN|Resv | | |
+ -----------------------------------------------------------------------------------
+ | TCP/UDP checksum | Reserved(2B) | SW Specific Parameters(4B) |
+ | diff (2B) | |
+ -----------------------------------------------------------------------------------
+
+ Dont change below structure definition.
+ It should be same as above(little endian order)
+ -------------------------------------------------------------------------------*/
+struct ipa_nat_rule {
+ uint64_t private_ip:32;
+ uint64_t target_ip:32;
+
+ uint64_t nxt_indx_pub_port:32;
+ uint64_t private_port:16;
+ uint64_t target_port:16;
+
+ uint64_t ip_cksm_enbl:32;
+ uint64_t ts_proto:32;
+
+ /*--------------------------------------------------
+ 32 bit sw_spec_params is interpreted as follows
+ ------------------------------------
+ | 16 bits | 16 bits |
+ ------------------------------------
+ | index table | prev index |
+ | entry | |
+ ------------------------------------
+ --------------------------------------------------*/
+ uint64_t sw_spec_params:32;
+
+ uint64_t rsvd2:16;
+ uint64_t tcp_udp_chksum:16;
+};
+
+struct ipa_nat_sw_rule {
+ uint64_t private_ip:32;
+ uint64_t target_ip:32;
+
+ uint64_t next_index:16;
+ uint64_t public_port:16;
+ uint64_t private_port:16;
+ uint64_t target_port:16;
+
+ uint64_t ip_chksum:16;
+ uint64_t rsvd1:14;
+ uint64_t redirect:1;
+ uint64_t enable:1;
+ uint64_t time_stamp:24;
+ uint64_t protocol:8;
+
+ /*--------------------------------------------------
+ 32 bit sw_spec_params is interpreted as follows
+ ------------------------------------
+ | 16 bits | 16 bits |
+ ------------------------------------
+ | index table | prev index |
+ | entry | |
+ ------------------------------------
+ --------------------------------------------------*/
+ uint64_t prev_index:16;
+ uint64_t indx_tbl_entry:16;
+ uint64_t rsvd2:16;
+ uint64_t tcp_udp_chksum:16;
+};
+#define IPA_NAT_TABLE_ENTRY_SIZE 32
+#define IPA_NAT_INDEX_TABLE_ENTRY_SIZE 4
+
+struct ipa_nat_indx_tbl_rule {
+ uint32_t tbl_entry_nxt_indx;
+};
+
+struct ipa_nat_sw_indx_tbl_rule {
+ uint16_t tbl_entry;
+ uint16_t next_index;
+};
+
+struct ipa_nat_indx_tbl_meta_info {
+ uint16_t prev_index;
+};
+
+struct ipa_nat_ip4_table_cache {
+ uint8_t valid;
+ uint32_t public_addr;
+
+ int nat_fd;
+ int size;
+ uint32_t tbl_addr_offset;
+ char table_name[IPA_RESOURCE_NAME_MAX];
+
+ char *ipv4_rules_addr;
+ char *index_table_addr;
+ uint16_t table_entries;
+
+ char *ipv4_expn_rules_addr;
+ char *index_table_expn_addr;
+ uint16_t expn_table_entries;
+
+ struct ipa_nat_indx_tbl_meta_info *index_expn_table_meta;
+
+ uint16_t *rule_id_array;
+#ifdef IPA_ON_R3PC
+ uint32_t mmap_offset;
+#endif
+
+ uint16_t cur_tbl_cnt;
+ uint16_t cur_expn_tbl_cnt;
+};
+
+struct ipa_nat_cache {
+ struct ipa_nat_ip4_table_cache ip4_tbl[IPA_NAT_MAX_IP4_TBLS];
+ int ipa_fd;
+ uint8_t table_cnt;
+};
+
+struct ipa_nat_indx_tbl_sw_rule {
+ uint16_t tbl_entry;
+ uint16_t next_index;
+ uint16_t prev_index;
+};
+
+typedef enum {
+ IPA_NAT_DEL_TYPE_ONLY_ONE,
+ IPA_NAT_DEL_TYPE_HEAD,
+ IPA_NAT_DEL_TYPE_MIDDLE,
+ IPA_NAT_DEL_TYPE_LAST,
+} del_type;
+
+/**
+ * ipa_nati_parse_ipv4_rule_hdl() - prase rule handle
+ * @tbl_hdl: [in] nat table rule
+ * @rule_hdl: [in] nat rule handle
+ * @expn_tbl: [out] expansion table or not
+ * @tbl_entry: [out] index into table
+ *
+ * Parse the rule handle to retrieve the nat table
+ * type and entry of nat table
+ *
+ * Returns: None
+ */
+void ipa_nati_parse_ipv4_rule_hdl(uint8_t tbl_hdl,
+ uint16_t rule_hdl,
+ uint8_t *expn_tbl,
+ uint16_t *tbl_entry);
+
+/**
+ * ipa_nati_make_rule_hdl() - makes nat rule handle
+ * @tbl_hdl: [in] nat table handle
+ * @tbl_entry: [in] nat table entry
+ *
+ * Calculate the nat rule handle which from
+ * nat entry which will be returned to client of
+ * nat driver
+ *
+ * Returns: >0 nat rule handle
+ */
+uint16_t ipa_nati_make_rule_hdl(uint16_t tbl_hdl,
+ uint16_t tbl_entry);
+
+uint32_t ipa_nati_get_index_entry_offset(
+ struct ipa_nat_ip4_table_cache*,
+ nat_table_type tbl_type,
+ uint16_t indx_tbl_entry);
+uint32_t ipa_nati_get_entry_offset(
+ struct ipa_nat_ip4_table_cache*,
+ nat_table_type tbl_type,
+ uint16_t tbl_entry);
+
+int ipa_nati_add_ipv4_tbl(uint32_t public_ip_addr,
+ uint16_t number_of_entries,
+ uint32_t *table_hanle);
+
+int ipa_nati_alloc_table(uint16_t number_of_entries,
+ struct ipa_ioc_nat_alloc_mem *mem,
+ uint16_t*, uint16_t*);
+
+int ipa_nati_update_cache(struct ipa_ioc_nat_alloc_mem *,
+ uint32_t public_ip_addr,
+ uint16_t tbl_entries,
+ uint16_t expn_tbl_entries);
+
+int ipa_nati_del_ipv4_table(uint32_t tbl_hdl);
+int ipa_nati_reset_ipv4_table(uint32_t tbl_hdl);
+int ipa_nati_post_ipv4_init_cmd(uint8_t tbl_index);
+
+int ipa_nati_query_timestamp(uint32_t tbl_hdl,
+ uint32_t rule_hdl,
+ uint32_t *time_stamp);
+
+int ipa_nati_add_ipv4_rule(uint32_t tbl_hdl,
+ const ipa_nat_ipv4_rule *clnt_rule,
+ uint32_t *rule_hdl);
+
+int ipa_nati_generate_rule(uint32_t tbl_hdl,
+ const ipa_nat_ipv4_rule *clnt_rule,
+ struct ipa_nat_sw_rule *rule,
+ struct ipa_nat_indx_tbl_sw_rule *index_sw_rule,
+ uint16_t *tbl_entry,
+ uint16_t *indx_tbl_entry);
+
+uint16_t ipa_nati_expn_tbl_free_entry(struct ipa_nat_rule *expn_tbl,
+ uint16_t size);
+
+uint16_t ipa_nati_generate_tbl_rule(const ipa_nat_ipv4_rule *clnt_rule,
+ struct ipa_nat_sw_rule *sw_rule,
+ struct ipa_nat_ip4_table_cache *tbl_ptr);
+
+uint16_t ipa_nati_generate_index_rule(const ipa_nat_ipv4_rule *clnt_rule,
+ struct ipa_nat_indx_tbl_sw_rule *sw_rule,
+ struct ipa_nat_ip4_table_cache *tbl_ptr);
+
+uint16_t ipa_nati_index_expn_get_free_entry(struct ipa_nat_indx_tbl_rule *tbl,
+ uint16_t size);
+
+void ipa_nati_copy_ipv4_rule_to_hw(
+ struct ipa_nat_ip4_table_cache *ipv4_cache,
+ struct ipa_nat_sw_rule *rule,
+ uint16_t entry, uint8_t tbl_index);
+
+void ipa_nati_copy_ipv4_index_rule_to_hw(
+ struct ipa_nat_ip4_table_cache *ipv4_cache,
+ struct ipa_nat_indx_tbl_sw_rule *indx_sw_rule,
+ uint16_t entry, uint8_t tbl_index);
+
+void ipa_nati_write_next_index(uint8_t tbl_indx,
+ nat_table_type tbl_type,
+ uint16_t value,
+ uint32_t offset);
+
+int ipa_nati_post_ipv4_dma_cmd(uint8_t tbl_indx,
+ uint16_t entry);
+
+int ipa_nati_del_ipv4_rule(uint32_t tbl_hdl,
+ uint32_t rule_hdl);
+
+int ipa_nati_post_del_dma_cmd(uint8_t tbl_indx,
+ uint16_t tbl_entry,
+ uint8_t expn_tbl,
+ del_type rule_pos);
+
+void ipa_nati_find_index_rule_pos(
+ struct ipa_nat_ip4_table_cache *cache_ptr,
+ uint16_t tbl_entry,
+ del_type *rule_pos);
+
+void ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx);
+void ipa_nati_find_rule_pos(struct ipa_nat_ip4_table_cache *cache_ptr,
+ uint8_t expn_tbl,
+ uint16_t tbl_entry,
+ del_type *rule_pos);
+void ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx);
+
+uint16_t Read16BitFieldValue(uint32_t param,
+ ipa_nat_rule_field_type fld_type);
+
+/* ========================================================
+ Debug functions
+ ========================================================*/
+#ifdef NAT_DUMP
+void ipa_nati_print_rule(struct ipa_nat_rule*, uint32_t);
+void ipa_nat_dump_ipv4_table(uint32_t);
+void ipa_nati_print_index_rule(struct ipa_nat_indx_tbl_rule*,
+ uint32_t, uint16_t);
+int ipa_nati_query_nat_rules(uint32_t, nat_table_type);
+#endif
+
+#endif /* #ifndef IPA_NAT_DRVI_H */
diff --git a/msm8998/ipanat/inc/ipa_nat_logi.h b/msm8998/ipanat/inc/ipa_nat_logi.h
new file mode 100644
index 0000000..5f79cc6
--- /dev/null
+++ b/msm8998/ipanat/inc/ipa_nat_logi.h
@@ -0,0 +1,73 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ ipa_nat_logi.h
+
+ @brief
+ This file implements the IPAM log functionality.
+
+ @Author
+
+
+*/
+
+#ifndef IPA_NAT_LOGI_H
+#define IPA_NAT_LOGI_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+
+#define PERROR(fmt) printf("%s:%d %s()", __FILE__, __LINE__, __FUNCTION__);\
+ perror(fmt);
+
+#define IPAERR(fmt, ...) printf("ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+
+#ifdef DEBUG
+#define IPADBG(fmt, ...) printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+
+#define IPADUMP(fmt, ...) printf(fmt, ##__VA_ARGS__);
+
+#else
+#define IPADBG(fmt, ...)
+#define IPADUMP(fmt, ...)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IPA_NAT_LOGI_H */
diff --git a/msm8998/ipanat/src/Android.mk b/msm8998/ipanat/src/Android.mk
new file mode 100644
index 0000000..905e901
--- /dev/null
+++ b/msm8998/ipanat/src/Android.mk
@@ -0,0 +1,27 @@
+BOARD_PLATFORM_LIST := test
+ifeq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true)
+ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
+ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH)))
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../inc
+LOCAL_C_INCLUDES += $(LOCAL_PATH)
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+LOCAL_SRC_FILES := ipa_nat_drv.c \
+ ipa_nat_drvi.c
+
+LOCAL_CFLAGS := -DDEBUG
+LOCAL_MODULE := libipanat
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CLANG := true
+include $(BUILD_SHARED_LIBRARY)
+
+endif # $(TARGET_ARCH)
+endif
+endif
diff --git a/msm8998/ipanat/src/Makefile.am b/msm8998/ipanat/src/Makefile.am
new file mode 100644
index 0000000..8bdb9b8
--- /dev/null
+++ b/msm8998/ipanat/src/Makefile.am
@@ -0,0 +1,21 @@
+AM_CFLAGS = -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
+AM_CFLAGS += -I./../inc
+#AM_CFLAGS += -DDEBUG -g
+
+common_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@
+common_LDFLAGS = -lrt @GLIB_LIBS@
+
+c_sources = ipa_nat_drv.c \
+ ipa_nat_drvi.c \
+ ipa_nat_logi.c
+
+library_includedir = $(pkgincludedir)
+library_include_HEADERS = ./../inc/ipa_nat_drvi.h \
+ ./../inc/ipa_nat_drv.h \
+ ./../inc/ipa_nat_logi.h
+
+lib_LTLIBRARIES = libipanat.la
+libipanat_la_C = @C@
+libipanat_la_SOURCES = $(c_sources)
+libipanat_la_CFLAGS = $(AM_CFLAGS) $(common_CFLAGS)
+libipanat_la_LDFLAGS = -shared $(common_LDFLAGS) -version-info 1:0:0
diff --git a/msm8998/ipanat/src/ipa_nat_drv.c b/msm8998/ipanat/src/ipa_nat_drv.c
new file mode 100644
index 0000000..66504e1
--- /dev/null
+++ b/msm8998/ipanat/src/ipa_nat_drv.c
@@ -0,0 +1,175 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "ipa_nat_drv.h"
+#include "ipa_nat_drvi.h"
+
+/**
+ * ipa_nat_add_ipv4_tbl() - create ipv4 nat table
+ * @public_ip_addr: [in] public ipv4 address
+ * @number_of_entries: [in] number of nat entries
+ * @table_handle: [out] Handle of new ipv4 nat table
+ *
+ * To create new ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_add_ipv4_tbl(uint32_t public_ip_addr,
+ uint16_t number_of_entries,
+ uint32_t *tbl_hdl)
+{
+ int ret;
+
+ if (NULL == tbl_hdl || 0 == number_of_entries) {
+ IPAERR("Invalid parameters \n");
+ return -EINVAL;
+ }
+
+ ret = ipa_nati_add_ipv4_tbl(public_ip_addr,
+ number_of_entries,
+ tbl_hdl);
+ if (ret != 0) {
+ IPAERR("unable to add table \n");
+ return -EINVAL;
+ }
+ IPADBG("Returning table handle 0x%x\n", *tbl_hdl);
+
+ return ret;
+} /* __ipa_nat_add_ipv4_tbl() */
+
+/**
+ * ipa_nat_del_ipv4_tbl() - delete ipv4 table
+ * @table_handle: [in] Handle of ipv4 nat table
+ *
+ * To delete given ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_del_ipv4_tbl(uint32_t tbl_hdl)
+{
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed \n");
+ return -EINVAL;
+ }
+ IPADBG("Passed Table Handle: 0x%x\n", tbl_hdl);
+
+ return ipa_nati_del_ipv4_table(tbl_hdl);
+}
+
+/**
+ * ipa_nat_add_ipv4_rule() - to insert new ipv4 rule
+ * @table_handle: [in] handle of ipv4 nat table
+ * @rule: [in] Pointer to new rule
+ * @rule_handle: [out] Return the handle to rule
+ *
+ * To insert new ipv4 nat rule into ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_add_ipv4_rule(uint32_t tbl_hdl,
+ const ipa_nat_ipv4_rule *clnt_rule,
+ uint32_t *rule_hdl)
+{
+ int result = -EINVAL;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS || NULL == rule_hdl ||
+ NULL == clnt_rule) {
+ IPAERR("invalide table handle passed \n");
+ return result;
+ }
+ IPADBG("Passed Table handle: 0x%x\n", tbl_hdl);
+
+ if (ipa_nati_add_ipv4_rule(tbl_hdl, clnt_rule, rule_hdl) != 0) {
+ return result;
+ }
+
+ IPADBG("returning rule handle 0x%x\n", *rule_hdl);
+ return 0;
+}
+
+
+/**
+ * ipa_nat_del_ipv4_rule() - to delete ipv4 nat rule
+ * @table_handle: [in] handle of ipv4 nat table
+ * @rule_handle: [in] ipv4 nat rule handle
+ *
+ * To insert new ipv4 nat rule into ipv4 nat table
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_del_ipv4_rule(uint32_t tbl_hdl,
+ uint32_t rule_hdl)
+{
+ int result = -EINVAL;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ IPA_NAT_INVALID_NAT_ENTRY == rule_hdl) {
+ IPAERR("invalide parameters\n");
+ return result;
+ }
+ IPADBG("Passed Table: 0x%x and rule handle 0x%x\n", tbl_hdl, rule_hdl);
+
+ result = ipa_nati_del_ipv4_rule(tbl_hdl, rule_hdl);
+ if (result) {
+ IPAERR("unable to delete rule from hw \n");
+ return result;
+ }
+
+ return 0;
+}
+
+/**
+ * ipa_nat_query_timestamp() - to query timestamp
+ * @table_handle: [in] handle of ipv4 nat table
+ * @rule_handle: [in] ipv4 nat rule handle
+ * @time_stamp: [out] time stamp of rule
+ *
+ * To retrieve the timestamp that lastly the
+ * nat rule was accessed
+ *
+ * Returns: 0 On Success, negative on failure
+ */
+int ipa_nat_query_timestamp(uint32_t tbl_hdl,
+ uint32_t rule_hdl,
+ uint32_t *time_stamp)
+{
+
+ if (0 == tbl_hdl || tbl_hdl > IPA_NAT_MAX_IP4_TBLS ||
+ NULL == time_stamp) {
+ IPAERR("invalid parameters passed \n");
+ return -EINVAL;
+ }
+ IPADBG("Passed Table: 0x%x and rule handle 0x%x\n", tbl_hdl, rule_hdl);
+
+ return ipa_nati_query_timestamp(tbl_hdl, rule_hdl, time_stamp);
+}
+
+
diff --git a/msm8998/ipanat/src/ipa_nat_drvi.c b/msm8998/ipanat/src/ipa_nat_drvi.c
new file mode 100644
index 0000000..9b96c44
--- /dev/null
+++ b/msm8998/ipanat/src/ipa_nat_drvi.c
@@ -0,0 +1,2368 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "ipa_nat_drv.h"
+#include "ipa_nat_drvi.h"
+
+#ifdef USE_GLIB
+#include <glib.h>
+#define strlcpy g_strlcpy
+#endif
+
+struct ipa_nat_cache ipv4_nat_cache;
+pthread_mutex_t nat_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* ------------------------------------------
+ UTILITY FUNCTIONS START
+ --------------------------------------------*/
+
+/**
+ * UpdateSwSpecParams() - updates sw specific params
+ * @rule: [in/out] nat table rule
+ * @param_type: [in] which param need to update
+ * @value: [in] value of param
+ *
+ * Update SW specific params in the passed rule.
+ *
+ * Returns: None
+ */
+void UpdateSwSpecParams(struct ipa_nat_rule *rule,
+ uint8_t param_type,
+ uint32_t value)
+{
+ uint32_t temp = rule->sw_spec_params;
+
+ if (IPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE == param_type) {
+ value = (value << INDX_TBL_ENTRY_SIZE_IN_BITS);
+ temp &= 0x0000FFFF;
+ } else {
+ temp &= 0xFFFF0000;
+ }
+
+ temp = (temp | value);
+ rule->sw_spec_params = temp;
+ return;
+}
+
+/**
+ * Read8BitFieldValue()
+ * @rule: [in/out]
+ * @param_type: [in]
+ * @value: [in]
+ *
+ *
+ *
+ * Returns: None
+ */
+
+uint8_t Read8BitFieldValue(uint32_t param,
+ ipa_nat_rule_field_type fld_type)
+{
+ void *temp = (void *)&param;
+
+ switch (fld_type) {
+
+ case PROTOCOL_FIELD:
+ return ((time_stamp_proto *)temp)->protocol;
+
+ default:
+ IPAERR("Invalid Field type passed\n");
+ return 0;
+ }
+}
+
+uint16_t Read16BitFieldValue(uint32_t param,
+ ipa_nat_rule_field_type fld_type)
+{
+ void *temp = (void *)&param;
+
+ switch (fld_type) {
+
+ case NEXT_INDEX_FIELD:
+ return ((next_index_pub_port *)temp)->next_index;
+
+ case PUBLIC_PORT_FILED:
+ return ((next_index_pub_port *)temp)->public_port;
+
+ case ENABLE_FIELD:
+ return ((ipcksum_enbl *)temp)->enable;
+
+ case SW_SPEC_PARAM_PREV_INDEX_FIELD:
+ return ((sw_spec_params *)temp)->prev_index;
+
+ case SW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD:
+ return ((sw_spec_params *)temp)->index_table_entry;
+
+ case INDX_TBL_TBL_ENTRY_FIELD:
+ return ((tbl_ent_nxt_indx *)temp)->tbl_entry;
+
+ case INDX_TBL_NEXT_INDEX_FILED:
+ return ((tbl_ent_nxt_indx *)temp)->next_index;
+
+#ifdef NAT_DUMP
+ case IP_CHKSUM_FIELD:
+ return ((ipcksum_enbl *)temp)->ip_chksum;
+#endif
+
+ default:
+ IPAERR("Invalid Field type passed\n");
+ return 0;
+ }
+}
+
+uint32_t Read32BitFieldValue(uint32_t param,
+ ipa_nat_rule_field_type fld_type)
+{
+
+ void *temp = (void *)&param;
+
+ switch (fld_type) {
+
+ case TIME_STAMP_FIELD:
+ return ((time_stamp_proto *)temp)->time_stamp;
+
+ default:
+ IPAERR("Invalid Field type passed\n");
+ return 0;
+ }
+}
+
+
+/**
+ * CreateNatDevice() - Create nat devices
+ * @mem: [in] name of device that need to create
+ *
+ * Create Nat device and Register for file create
+ * notification in given directory and wait till
+ * receive notification
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int CreateNatDevice(struct ipa_ioc_nat_alloc_mem *mem)
+{
+ int ret;
+
+ ret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_ALLOC_NAT_MEM, mem);
+ if (ret != 0) {
+ perror("CreateNatDevice(): ioctl error value");
+ IPAERR("unable to post nat mem init. Error ;%d\n", ret);
+ IPADBG("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ return -EINVAL;
+ }
+ IPADBG("posted IPA_IOC_ALLOC_NAT_MEM to kernel successfully\n");
+ return 0;
+}
+
+/**
+ * GetNearest2Power() - Returns the nearest power of 2
+ * @num: [in] given number
+ * @ret: [out] nearest power of 2
+ *
+ * Returns the nearest power of 2 for a
+ * given number
+ *
+ * Returns: 0 on success, negative on failure
+ */
+int GetNearest2Power(uint16_t num, uint16_t *ret)
+{
+ uint16_t number = num;
+ uint16_t tmp = 1;
+ *ret = 0;
+
+ if (0 == num) {
+ return -EINVAL;
+ }
+
+ if (1 == num) {
+ *ret = 2;
+ return 0;
+ }
+
+ for (;;) {
+ if (1 == num) {
+ if (number != tmp) {
+ tmp *= 2;
+ }
+
+ *ret = tmp;
+ return 0;
+ }
+
+ num >>= 1;
+ tmp *= 2;
+ }
+
+ return -EINVAL;
+}
+
+/**
+ * GetNearestEven() - Returns the nearest even number
+ * @num: [in] given number
+ * @ret: [out] nearest even number
+ *
+ * Returns the nearest even number for a given number
+ *
+ * Returns: 0 on success, negative on failure
+ */
+void GetNearestEven(uint16_t num, uint16_t *ret)
+{
+
+ if (num < 2) {
+ *ret = 2;
+ return;
+ }
+
+ while ((num % 2) != 0) {
+ num = num + 1;
+ }
+
+ *ret = num;
+ return;
+}
+
+/**
+ * dst_hash() - Find the index into ipv4 base table
+ * @trgt_ip: [in] Target IP address
+ * @trgt_port: [in] Target port
+ * @public_port: [in] Public port
+ * @proto: [in] Protocol (TCP/IP)
+ * @size: [in] size of the ipv4 base Table
+ *
+ * This hash method is used to find the hash index of new nat
+ * entry into ipv4 base table. In case of zero index, the
+ * new entry will be stored into N-1 index where N is size of
+ * ipv4 base table
+ *
+ * Returns: >0 index into ipv4 base table, negative on failure
+ */
+static uint16_t dst_hash(uint32_t trgt_ip, uint16_t trgt_port,
+ uint16_t public_port, uint8_t proto,
+ uint16_t size)
+{
+ uint16_t hash = ((uint16_t)(trgt_ip)) ^ ((uint16_t)(trgt_ip >> 16)) ^
+ (trgt_port) ^ (public_port) ^ (proto);
+
+ IPADBG("trgt_ip: 0x%x trgt_port: 0x%x\n", trgt_ip, trgt_port);
+ IPADBG("public_port: 0x%x\n", public_port);
+ IPADBG("proto: 0x%x size: 0x%x\n", proto, size);
+
+ hash = (hash & size);
+
+ /* If the hash resulted to zero then set it to maximum value
+ as zero is unused entry in nat tables */
+ if (0 == hash) {
+ return size;
+ }
+
+ IPADBG("dst_hash returning value: %d\n", hash);
+ return hash;
+}
+
+/**
+ * src_hash() - Find the index into ipv4 index base table
+ * @priv_ip: [in] Private IP address
+ * @priv_port: [in] Private port
+ * @trgt_ip: [in] Target IP address
+ * @trgt_port: [in] Target Port
+ * @proto: [in] Protocol (TCP/IP)
+ * @size: [in] size of the ipv4 index base Table
+ *
+ * This hash method is used to find the hash index of new nat
+ * entry into ipv4 index base table. In case of zero index, the
+ * new entry will be stored into N-1 index where N is size of
+ * ipv4 index base table
+ *
+ * Returns: >0 index into ipv4 index base table, negative on failure
+ */
+static uint16_t src_hash(uint32_t priv_ip, uint16_t priv_port,
+ uint32_t trgt_ip, uint16_t trgt_port,
+ uint8_t proto, uint16_t size)
+{
+ uint16_t hash = ((uint16_t)(priv_ip)) ^ ((uint16_t)(priv_ip >> 16)) ^
+ (priv_port) ^
+ ((uint16_t)(trgt_ip)) ^ ((uint16_t)(trgt_ip >> 16)) ^
+ (trgt_port) ^ (proto);
+
+ IPADBG("priv_ip: 0x%x priv_port: 0x%x\n", priv_ip, priv_port);
+ IPADBG("trgt_ip: 0x%x trgt_port: 0x%x\n", trgt_ip, trgt_port);
+ IPADBG("proto: 0x%x size: 0x%x\n", proto, size);
+
+ hash = (hash & size);
+
+ /* If the hash resulted to zero then set it to maximum value
+ as zero is unused entry in nat tables */
+ if (0 == hash) {
+ return size;
+ }
+
+ IPADBG("src_hash returning value: %d\n", hash);
+ return hash;
+}
+
+/**
+ * ipa_nati_calc_ip_cksum() - Calculate the source nat
+ * IP checksum diff
+ * @pub_ip_addr: [in] public ip address
+ * @priv_ip_addr: [in] Private ip address
+ *
+ * source nat ip checksum different is calculated as
+ * public_ip_addr - private_ip_addr
+ * Here we are using 1's complement to represent -ve number.
+ * So take 1's complement of private ip addr and add it
+ * to public ip addr.
+ *
+ * Returns: >0 ip checksum diff
+ */
+static uint16_t ipa_nati_calc_ip_cksum(uint32_t pub_ip_addr,
+ uint32_t priv_ip_addr)
+{
+ uint16_t ret;
+ uint32_t cksum = 0;
+
+ /* Add LSB(2 bytes) of public ip address to cksum */
+ cksum += (pub_ip_addr & 0xFFFF);
+
+ /* Add MSB(2 bytes) of public ip address to cksum
+ and check for carry forward(CF), if any add it
+ */
+ cksum += (pub_ip_addr>>16);
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Calculate the 1's complement of private ip address */
+ priv_ip_addr = (~priv_ip_addr);
+
+ /* Add LSB(2 bytes) of private ip address to cksum
+ and check for carry forward(CF), if any add it
+ */
+ cksum += (priv_ip_addr & 0xFFFF);
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Add MSB(2 bytes) of private ip address to cksum
+ and check for carry forward(CF), if any add it
+ */
+ cksum += (priv_ip_addr>>16);
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Return the LSB(2 bytes) of checksum */
+ ret = (uint16_t)cksum;
+ return ret;
+}
+
+/**
+ * ipa_nati_calc_tcp_udp_cksum() - Calculate the source nat
+ * TCP/UDP checksum diff
+ * @pub_ip_addr: [in] public ip address
+ * @pub_port: [in] public tcp/udp port
+ * @priv_ip_addr: [in] Private ip address
+ * @priv_port: [in] Private tcp/udp prot
+ *
+ * source nat tcp/udp checksum is calculated as
+ * (pub_ip_addr + pub_port) - (priv_ip_addr + priv_port)
+ * Here we are using 1's complement to represent -ve number.
+ * So take 1's complement of prviate ip addr &private port
+ * and add it public ip addr & public port.
+ *
+ * Returns: >0 tcp/udp checksum diff
+ */
+static uint16_t ipa_nati_calc_tcp_udp_cksum(uint32_t pub_ip_addr,
+ uint16_t pub_port,
+ uint32_t priv_ip_addr,
+ uint16_t priv_port)
+{
+ uint16_t ret = 0;
+ uint32_t cksum = 0;
+
+ /* Add LSB(2 bytes) of public ip address to cksum */
+ cksum += (pub_ip_addr & 0xFFFF);
+
+ /* Add MSB(2 bytes) of public ip address to cksum
+ and check for carry forward(CF), if any add it
+ */
+ cksum += (pub_ip_addr>>16);
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Add public port to cksum and
+ check for carry forward(CF), if any add it */
+ cksum += pub_port;
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Calculate the 1's complement of private ip address */
+ priv_ip_addr = (~priv_ip_addr);
+
+ /* Add LSB(2 bytes) of private ip address to cksum
+ and check for carry forward(CF), if any add it
+ */
+ cksum += (priv_ip_addr & 0xFFFF);
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Add MSB(2 bytes) of private ip address to cksum
+ and check for carry forward(CF), if any add
+ */
+ cksum += (priv_ip_addr>>16);
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* Calculate the 1's complement of private port */
+ priv_port = (~priv_port);
+
+ /* Add public port to cksum and
+ check for carry forward(CF), if any add it */
+ cksum += priv_port;
+ if (cksum >> 16) {
+ cksum = (cksum & 0x0000FFFF);
+ cksum += 1;
+ }
+
+ /* return the LSB(2 bytes) of checksum */
+ ret = (uint16_t)cksum;
+ return ret;
+}
+
+/**
+ * ipa_nati_make_rule_hdl() - makes nat rule handle
+ * @tbl_hdl: [in] nat table handle
+ * @tbl_entry: [in] nat table entry
+ *
+ * Calculate the nat rule handle which from
+ * nat entry which will be returned to client of
+ * nat driver
+ *
+ * Returns: >0 nat rule handle
+ */
+uint16_t ipa_nati_make_rule_hdl(uint16_t tbl_hdl,
+ uint16_t tbl_entry)
+{
+ struct ipa_nat_ip4_table_cache *tbl_ptr;
+ uint16_t rule_hdl = 0;
+ uint16_t cnt = 0;
+
+ tbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_hdl-1];
+
+ if (tbl_entry >= tbl_ptr->table_entries) {
+ /* Increase the current expansion table count */
+ tbl_ptr->cur_expn_tbl_cnt++;
+
+ /* Update the index into table */
+ rule_hdl = tbl_entry - tbl_ptr->table_entries;
+ rule_hdl = (rule_hdl << IPA_NAT_RULE_HDL_TBL_TYPE_BITS);
+ /* Update the table type mask */
+ rule_hdl = (rule_hdl | IPA_NAT_RULE_HDL_TBL_TYPE_MASK);
+ } else {
+ /* Increase the current count */
+ tbl_ptr->cur_tbl_cnt++;
+
+ rule_hdl = tbl_entry;
+ rule_hdl = (rule_hdl << IPA_NAT_RULE_HDL_TBL_TYPE_BITS);
+ }
+
+ for (; cnt < (tbl_ptr->table_entries + tbl_ptr->expn_table_entries); cnt++) {
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_ptr->rule_id_array[cnt]) {
+ tbl_ptr->rule_id_array[cnt] = rule_hdl;
+ return cnt + 1;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * ipa_nati_parse_ipv4_rule_hdl() - prase rule handle
+ * @tbl_hdl: [in] nat table rule
+ * @rule_hdl: [in] nat rule handle
+ * @expn_tbl: [out] expansion table or not
+ * @tbl_entry: [out] index into table
+ *
+ * Parse the rule handle to retrieve the nat table
+ * type and entry of nat table
+ *
+ * Returns: None
+ */
+void ipa_nati_parse_ipv4_rule_hdl(uint8_t tbl_index,
+ uint16_t rule_hdl, uint8_t *expn_tbl,
+ uint16_t *tbl_entry)
+{
+ struct ipa_nat_ip4_table_cache *tbl_ptr;
+ uint16_t rule_id;
+
+ *expn_tbl = 0;
+ *tbl_entry = IPA_NAT_INVALID_NAT_ENTRY;
+ tbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_index];
+
+ if (rule_hdl >= (tbl_ptr->table_entries + tbl_ptr->expn_table_entries)) {
+ IPAERR("invalid rule handle\n");
+ return;
+ }
+
+ rule_id = tbl_ptr->rule_id_array[rule_hdl-1];
+
+ /* Retrieve the table type */
+ *expn_tbl = 0;
+ if (rule_id & IPA_NAT_RULE_HDL_TBL_TYPE_MASK) {
+ *expn_tbl = 1;
+ }
+
+ /* Retrieve the table entry */
+ *tbl_entry = (rule_id >> IPA_NAT_RULE_HDL_TBL_TYPE_BITS);
+ return;
+}
+
+uint32_t ipa_nati_get_entry_offset(struct ipa_nat_ip4_table_cache *cache_ptr,
+ nat_table_type tbl_type,
+ uint16_t tbl_entry)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ uint32_t ret = 0;
+
+ if (IPA_NAT_EXPN_TBL == tbl_type) {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;
+ } else {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;
+ }
+
+ ret = (char *)&tbl_ptr[tbl_entry] - (char *)tbl_ptr;
+ ret += cache_ptr->tbl_addr_offset;
+ return ret;
+}
+
+uint32_t ipa_nati_get_index_entry_offset(struct ipa_nat_ip4_table_cache *cache_ptr,
+ nat_table_type tbl_type,
+ uint16_t indx_tbl_entry)
+{
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ uint32_t ret = 0;
+
+ if (IPA_NAT_INDEX_EXPN_TBL == tbl_type) {
+ indx_tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;
+ } else {
+ indx_tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;
+ }
+
+ ret = (char *)&indx_tbl_ptr[indx_tbl_entry] - (char *)indx_tbl_ptr;
+ ret += cache_ptr->tbl_addr_offset;
+ return ret;
+}
+
+/* ------------------------------------------
+ UTILITY FUNCTIONS END
+--------------------------------------------*/
+
+/* ------------------------------------------
+ Main Functions
+--------------------------------------------**/
+void ipa_nati_reset_tbl(uint8_t tbl_indx)
+{
+ uint16_t table_entries = ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries;
+ uint16_t expn_table_entries = ipv4_nat_cache.ip4_tbl[tbl_indx].expn_table_entries;
+
+ /* Base table */
+ IPADBG("memset() base table to 0, %p\n",
+ ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr);
+
+ memset(ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr,
+ 0,
+ IPA_NAT_TABLE_ENTRY_SIZE * table_entries);
+
+ /* Base expansino table */
+ IPADBG("memset() expn base table to 0, %p\n",
+ ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_expn_rules_addr);
+
+ memset(ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_expn_rules_addr,
+ 0,
+ IPA_NAT_TABLE_ENTRY_SIZE * expn_table_entries);
+
+ /* Index table */
+ IPADBG("memset() index table to 0, %p\n",
+ ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_addr);
+
+ memset(ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_addr,
+ 0,
+ IPA_NAT_INDEX_TABLE_ENTRY_SIZE * table_entries);
+
+ /* Index expansion table */
+ IPADBG("memset() index expn table to 0, %p\n",
+ ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_expn_addr);
+
+ memset(ipv4_nat_cache.ip4_tbl[tbl_indx].index_table_expn_addr,
+ 0,
+ IPA_NAT_INDEX_TABLE_ENTRY_SIZE * expn_table_entries);
+
+ IPADBG("returning from ipa_nati_reset_tbl()\n");
+ return;
+}
+
+int ipa_nati_add_ipv4_tbl(uint32_t public_ip_addr,
+ uint16_t number_of_entries,
+ uint32_t *tbl_hdl)
+{
+ struct ipa_ioc_nat_alloc_mem mem;
+ uint8_t tbl_indx = ipv4_nat_cache.table_cnt;
+ uint16_t table_entries, expn_table_entries;
+ int ret;
+
+ *tbl_hdl = 0;
+ /* Allocate table */
+ memset(&mem, 0, sizeof(mem));
+ ret = ipa_nati_alloc_table(number_of_entries,
+ &mem,
+ &table_entries,
+ &expn_table_entries);
+ if (0 != ret) {
+ IPAERR("unable to allocate nat table\n");
+ return -ENOMEM;
+ }
+
+ /* Update the cache
+ The (IPA_NAT_UNUSED_BASE_ENTRIES/2) indicates zero entry entries
+ for both base and expansion table
+ */
+ ret = ipa_nati_update_cache(&mem,
+ public_ip_addr,
+ table_entries,
+ expn_table_entries);
+ if (0 != ret) {
+ IPAERR("unable to update cache Error: %d\n", ret);
+ return -EINVAL;
+ }
+
+ /* Reset the nat table before posting init cmd */
+ ipa_nati_reset_tbl(tbl_indx);
+
+ /* Initialize the ipa hw with nat table dimensions */
+ ret = ipa_nati_post_ipv4_init_cmd(tbl_indx);
+ if (0 != ret) {
+ IPAERR("unable to post nat_init command Error %d\n", ret);
+ return -EINVAL;
+ }
+
+ /* Return table handle */
+ ipv4_nat_cache.table_cnt++;
+ *tbl_hdl = ipv4_nat_cache.table_cnt;
+
+#ifdef NAT_DUMP
+ ipa_nat_dump_ipv4_table(*tbl_hdl);
+#endif
+ return 0;
+}
+
+int ipa_nati_alloc_table(uint16_t number_of_entries,
+ struct ipa_ioc_nat_alloc_mem *mem,
+ uint16_t *table_entries,
+ uint16_t *expn_table_entries)
+{
+ int fd = 0, ret;
+ uint16_t total_entries;
+
+ /* Copy the table name */
+ strlcpy(mem->dev_name, NAT_DEV_NAME, IPA_RESOURCE_NAME_MAX);
+
+ /* Calculate the size for base table and expansion table */
+ *table_entries = (uint16_t)(number_of_entries * IPA_NAT_BASE_TABLE_PERCENTAGE);
+ if (*table_entries == 0) {
+ *table_entries = 1;
+ }
+ if (GetNearest2Power(*table_entries, table_entries)) {
+ IPAERR("unable to calculate power of 2\n");
+ return -EINVAL;
+ }
+
+ *expn_table_entries = (uint16_t)(number_of_entries * IPA_NAT_EXPANSION_TABLE_PERCENTAGE);
+ GetNearestEven(*expn_table_entries, expn_table_entries);
+
+ total_entries = (*table_entries)+(*expn_table_entries);
+
+ /* Calclate the memory size for both table and index table entries */
+ mem->size = (IPA_NAT_TABLE_ENTRY_SIZE * total_entries);
+ IPADBG("Nat Table size: %d\n", mem->size);
+ mem->size += (IPA_NAT_INDEX_TABLE_ENTRY_SIZE * total_entries);
+ IPADBG("Nat Base and Index Table size: %d\n", mem->size);
+
+ if (!ipv4_nat_cache.ipa_fd) {
+ fd = open(IPA_DEV_NAME, O_RDONLY);
+ if (fd < 0) {
+ perror("ipa_nati_alloc_table(): open error value:");
+ IPAERR("unable to open ipa device\n");
+ return -EIO;
+ }
+ ipv4_nat_cache.ipa_fd = fd;
+ }
+
+ ret = CreateNatDevice(mem);
+ return ret;
+}
+
+
+int ipa_nati_update_cache(struct ipa_ioc_nat_alloc_mem *mem,
+ uint32_t public_addr,
+ uint16_t tbl_entries,
+ uint16_t expn_tbl_entries)
+{
+ uint32_t index = ipv4_nat_cache.table_cnt;
+ char *ipv4_rules_addr = NULL;
+
+ int fd = 0;
+ int flags = MAP_SHARED;
+ int prot = PROT_READ | PROT_WRITE;
+ off_t offset = 0;
+#ifdef IPA_ON_R3PC
+ int ret = 0;
+ uint32_t nat_mem_offset = 0;
+#endif
+
+ ipv4_nat_cache.ip4_tbl[index].valid = IPA_NAT_TABLE_VALID;
+ ipv4_nat_cache.ip4_tbl[index].public_addr = public_addr;
+ ipv4_nat_cache.ip4_tbl[index].size = mem->size;
+ ipv4_nat_cache.ip4_tbl[index].tbl_addr_offset = mem->offset;
+
+ ipv4_nat_cache.ip4_tbl[index].table_entries = tbl_entries;
+ ipv4_nat_cache.ip4_tbl[index].expn_table_entries = expn_tbl_entries;
+
+ IPADBG("num of ipv4 rules:%d\n", tbl_entries);
+ IPADBG("num of ipv4 expn rules:%d\n", expn_tbl_entries);
+
+ /* allocate memory for nat index expansion table */
+ if (NULL == ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta) {
+ ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta =
+ malloc(sizeof(struct ipa_nat_indx_tbl_meta_info) * expn_tbl_entries);
+
+ if (NULL == ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta) {
+ IPAERR("Fail to allocate ipv4 index expansion table meta\n");
+ return 0;
+ }
+
+ memset(ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta,
+ 0,
+ sizeof(struct ipa_nat_indx_tbl_meta_info) * expn_tbl_entries);
+ }
+
+ /* Allocate memory for rule_id_array */
+ if (NULL == ipv4_nat_cache.ip4_tbl[index].rule_id_array) {
+ ipv4_nat_cache.ip4_tbl[index].rule_id_array =
+ malloc(sizeof(uint16_t) * (tbl_entries + expn_tbl_entries));
+
+ if (NULL == ipv4_nat_cache.ip4_tbl[index].rule_id_array) {
+ IPAERR("Fail to allocate rule id array\n");
+ return 0;
+ }
+
+ memset(ipv4_nat_cache.ip4_tbl[index].rule_id_array,
+ 0,
+ sizeof(uint16_t) * (tbl_entries + expn_tbl_entries));
+ }
+
+
+ /* open the nat table */
+ strlcpy(mem->dev_name, NAT_DEV_FULL_NAME, IPA_RESOURCE_NAME_MAX);
+ fd = open(mem->dev_name, O_RDWR);
+ if (fd < 0) {
+ perror("ipa_nati_update_cache(): open error value:");
+ IPAERR("unable to open nat device. Error:%d\n", fd);
+ return -EIO;
+ }
+
+ /* copy the nat table name */
+ strlcpy(ipv4_nat_cache.ip4_tbl[index].table_name,
+ mem->dev_name,
+ IPA_RESOURCE_NAME_MAX);
+ ipv4_nat_cache.ip4_tbl[index].nat_fd = fd;
+
+ /* open the nat device Table */
+#ifndef IPA_ON_R3PC
+ ipv4_rules_addr = (void *)mmap(NULL, mem->size,
+ prot, flags,
+ fd, offset);
+#else
+ IPADBG("user space r3pc\n");
+ ipv4_rules_addr = (void *)mmap((caddr_t)0, NAT_MMAP_MEM_SIZE,
+ prot, flags,
+ fd, offset);
+#endif
+ if (MAP_FAILED == ipv4_rules_addr) {
+ perror("unable to mmap the memory\n");
+ return -EINVAL;
+ }
+
+#ifdef IPA_ON_R3PC
+ ret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_GET_NAT_OFFSET, &nat_mem_offset);
+ if (ret != 0) {
+ perror("ipa_nati_post_ipv4_init_cmd(): ioctl error value");
+ IPAERR("unable to post ant offset cmd Error: %d\n", ret);
+ IPADBG("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ return -EIO;
+ }
+ ipv4_rules_addr += nat_mem_offset;
+ ipv4_nat_cache.ip4_tbl[index].mmap_offset = nat_mem_offset;
+#endif
+
+ IPADBG("mmap return value 0x%lx\n", (long unsigned int)ipv4_rules_addr);
+
+ ipv4_nat_cache.ip4_tbl[index].ipv4_rules_addr = ipv4_rules_addr;
+
+ ipv4_nat_cache.ip4_tbl[index].ipv4_expn_rules_addr =
+ ipv4_rules_addr + (IPA_NAT_TABLE_ENTRY_SIZE * tbl_entries);
+
+ ipv4_nat_cache.ip4_tbl[index].index_table_addr =
+ ipv4_rules_addr + (IPA_NAT_TABLE_ENTRY_SIZE * (tbl_entries + expn_tbl_entries));
+
+ ipv4_nat_cache.ip4_tbl[index].index_table_expn_addr =
+ ipv4_rules_addr +
+ (IPA_NAT_TABLE_ENTRY_SIZE * (tbl_entries + expn_tbl_entries))+
+ (IPA_NAT_INDEX_TABLE_ENTRY_SIZE * tbl_entries);
+
+ return 0;
+}
+
+/* comment: check the implementation once
+ offset should be in terms of byes */
+int ipa_nati_post_ipv4_init_cmd(uint8_t tbl_index)
+{
+ struct ipa_ioc_v4_nat_init cmd;
+ uint32_t offset = ipv4_nat_cache.ip4_tbl[tbl_index].tbl_addr_offset;
+ int ret;
+
+ cmd.tbl_index = tbl_index;
+
+ cmd.ipv4_rules_offset = offset;
+ cmd.expn_rules_offset = cmd.ipv4_rules_offset +
+ (ipv4_nat_cache.ip4_tbl[tbl_index].table_entries * IPA_NAT_TABLE_ENTRY_SIZE);
+
+ cmd.index_offset = cmd.expn_rules_offset +
+ (ipv4_nat_cache.ip4_tbl[tbl_index].expn_table_entries * IPA_NAT_TABLE_ENTRY_SIZE);
+
+ cmd.index_expn_offset = cmd.index_offset +
+ (ipv4_nat_cache.ip4_tbl[tbl_index].table_entries * IPA_NAT_INDEX_TABLE_ENTRY_SIZE);
+
+ cmd.table_entries = ipv4_nat_cache.ip4_tbl[tbl_index].table_entries - 1;
+ cmd.expn_table_entries = ipv4_nat_cache.ip4_tbl[tbl_index].expn_table_entries;
+
+ cmd.ip_addr = ipv4_nat_cache.ip4_tbl[tbl_index].public_addr;
+
+ ret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_V4_INIT_NAT, &cmd);
+ if (ret != 0) {
+ perror("ipa_nati_post_ipv4_init_cmd(): ioctl error value");
+ IPAERR("unable to post init cmd Error: %d\n", ret);
+ IPADBG("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ return -EINVAL;
+ }
+ IPADBG("Posted IPA_IOC_V4_INIT_NAT to kernel successfully\n");
+
+ return 0;
+}
+
+int ipa_nati_del_ipv4_table(uint32_t tbl_hdl)
+{
+ uint8_t index = (uint8_t)(tbl_hdl - 1);
+ void *addr = (void *)ipv4_nat_cache.ip4_tbl[index].ipv4_rules_addr;
+ struct ipa_ioc_v4_nat_del del_cmd;
+ int ret;
+
+ if (!ipv4_nat_cache.ip4_tbl[index].valid) {
+ IPAERR("invalid table handle passed\n");
+ ret = -EINVAL;
+ goto fail;
+ }
+
+ if (pthread_mutex_lock(&nat_mutex) != 0) {
+ ret = -1;
+ goto lock_mutex_fail;
+ }
+
+ /* unmap the device memory from user space */
+#ifndef IPA_ON_R3PC
+ munmap(addr, ipv4_nat_cache.ip4_tbl[index].size);
+#else
+ addr = (char *)addr - ipv4_nat_cache.ip4_tbl[index].mmap_offset;
+ munmap(addr, NAT_MMAP_MEM_SIZE);
+#endif
+
+ /* close the file descriptor of nat device */
+ if (close(ipv4_nat_cache.ip4_tbl[index].nat_fd)) {
+ IPAERR("unable to close the file descriptor\n");
+ ret = -EINVAL;
+ if (pthread_mutex_unlock(&nat_mutex) != 0)
+ goto unlock_mutex_fail;
+ goto fail;
+ }
+
+ del_cmd.table_index = index;
+ del_cmd.public_ip_addr = ipv4_nat_cache.ip4_tbl[index].public_addr;
+ ret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_V4_DEL_NAT, &del_cmd);
+ if (ret != 0) {
+ perror("ipa_nati_del_ipv4_table(): ioctl error value");
+ IPAERR("unable to post nat del command init Error: %d\n", ret);
+ IPADBG("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ ret = -EINVAL;
+ if (pthread_mutex_unlock(&nat_mutex) != 0)
+ goto unlock_mutex_fail;
+ goto fail;
+ }
+ IPAERR("posted IPA_IOC_V4_DEL_NAT to kernel successfully\n");
+
+ free(ipv4_nat_cache.ip4_tbl[index].index_expn_table_meta);
+ free(ipv4_nat_cache.ip4_tbl[index].rule_id_array);
+
+ memset(&ipv4_nat_cache.ip4_tbl[index],
+ 0,
+ sizeof(ipv4_nat_cache.ip4_tbl[index]));
+
+ /* Decrease the table count by 1*/
+ ipv4_nat_cache.table_cnt--;
+
+ if (pthread_mutex_unlock(&nat_mutex) != 0) {
+ ret = -1;
+ goto unlock_mutex_fail;
+ }
+
+ return 0;
+
+lock_mutex_fail:
+ IPAERR("unable to lock the nat mutex\n");
+ return ret;
+
+unlock_mutex_fail:
+ IPAERR("unable to unlock the nat mutex\n");
+
+fail:
+ return ret;
+}
+
+int ipa_nati_query_timestamp(uint32_t tbl_hdl,
+ uint32_t rule_hdl,
+ uint32_t *time_stamp)
+{
+ uint8_t tbl_index = (uint8_t)(tbl_hdl - 1);
+ uint8_t expn_tbl = 0;
+ uint16_t tbl_entry = 0;
+ struct ipa_nat_rule *tbl_ptr = NULL;
+
+ if (!ipv4_nat_cache.ip4_tbl[tbl_index].valid) {
+ IPAERR("invalid table handle\n");
+ return -EINVAL;
+ }
+
+ if (pthread_mutex_lock(&nat_mutex) != 0) {
+ IPAERR("unable to lock the nat mutex\n");
+ return -1;
+ }
+
+ ipa_nati_parse_ipv4_rule_hdl(tbl_index, (uint16_t)rule_hdl,
+ &expn_tbl, &tbl_entry);
+
+ tbl_ptr =
+ (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_index].ipv4_rules_addr;
+ if (expn_tbl) {
+ tbl_ptr =
+ (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_index].ipv4_expn_rules_addr;
+ }
+
+ if (tbl_ptr)
+ *time_stamp = Read32BitFieldValue(tbl_ptr[tbl_entry].ts_proto,
+ TIME_STAMP_FIELD);
+
+ if (pthread_mutex_unlock(&nat_mutex) != 0) {
+ IPAERR("unable to unlock the nat mutex\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int ipa_nati_add_ipv4_rule(uint32_t tbl_hdl,
+ const ipa_nat_ipv4_rule *clnt_rule,
+ uint32_t *rule_hdl)
+{
+ struct ipa_nat_ip4_table_cache *tbl_ptr;
+ struct ipa_nat_sw_rule sw_rule;
+ struct ipa_nat_indx_tbl_sw_rule index_sw_rule;
+ uint16_t new_entry, new_index_tbl_entry;
+
+ memset(&sw_rule, 0, sizeof(sw_rule));
+ memset(&index_sw_rule, 0, sizeof(index_sw_rule));
+
+ /* Generate rule from client input */
+ if (ipa_nati_generate_rule(tbl_hdl, clnt_rule,
+ &sw_rule, &index_sw_rule,
+ &new_entry, &new_index_tbl_entry)) {
+ IPAERR("unable to generate rule\n");
+ return -EINVAL;
+ }
+
+ tbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_hdl-1];
+ ipa_nati_copy_ipv4_rule_to_hw(tbl_ptr, &sw_rule, new_entry, (uint8_t)(tbl_hdl-1));
+ ipa_nati_copy_ipv4_index_rule_to_hw(tbl_ptr,
+ &index_sw_rule,
+ new_index_tbl_entry,
+ (uint8_t)(tbl_hdl-1));
+
+ IPADBG("new entry:%d, new index entry: %d\n", new_entry, new_index_tbl_entry);
+ if (ipa_nati_post_ipv4_dma_cmd((uint8_t)(tbl_hdl - 1), new_entry)) {
+ IPAERR("unable to post dma command\n");
+ return -EIO;
+ }
+
+ /* Generate rule handle */
+ *rule_hdl = ipa_nati_make_rule_hdl((uint16_t)tbl_hdl, new_entry);
+ if (!(*rule_hdl)) {
+ IPAERR("unable to generate rule handle\n");
+ return -EINVAL;
+ }
+
+#ifdef NAT_DUMP
+ ipa_nat_dump_ipv4_table(tbl_hdl);
+#endif
+
+ return 0;
+}
+
+int ipa_nati_generate_rule(uint32_t tbl_hdl,
+ const ipa_nat_ipv4_rule *clnt_rule,
+ struct ipa_nat_sw_rule *rule,
+ struct ipa_nat_indx_tbl_sw_rule *index_sw_rule,
+ uint16_t *tbl_entry,
+ uint16_t *indx_tbl_entry)
+{
+ struct ipa_nat_ip4_table_cache *tbl_ptr;
+ uint16_t tmp;
+
+ if (NULL == clnt_rule || NULL == index_sw_rule ||
+ NULL == rule || NULL == tbl_entry ||
+ NULL == indx_tbl_entry) {
+ IPAERR("invalid parameters\n");
+ return -EINVAL;
+ }
+
+ tbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_hdl-1];
+
+ *tbl_entry = ipa_nati_generate_tbl_rule(clnt_rule,
+ rule,
+ tbl_ptr);
+ if (IPA_NAT_INVALID_NAT_ENTRY == *tbl_entry) {
+ IPAERR("unable to generate table entry\n");
+ return -EINVAL;
+ }
+
+ index_sw_rule->tbl_entry = *tbl_entry;
+ *indx_tbl_entry = ipa_nati_generate_index_rule(clnt_rule,
+ index_sw_rule,
+ tbl_ptr);
+ if (IPA_NAT_INVALID_NAT_ENTRY == *indx_tbl_entry) {
+ IPAERR("unable to generate index table entry\n");
+ return -EINVAL;
+ }
+
+ rule->indx_tbl_entry = *indx_tbl_entry;
+ if (*indx_tbl_entry >= tbl_ptr->table_entries) {
+ tmp = *indx_tbl_entry - tbl_ptr->table_entries;
+ tbl_ptr->index_expn_table_meta[tmp].prev_index = index_sw_rule->prev_index;
+ }
+
+ return 0;
+}
+
+uint16_t ipa_nati_generate_tbl_rule(const ipa_nat_ipv4_rule *clnt_rule,
+ struct ipa_nat_sw_rule *sw_rule,
+ struct ipa_nat_ip4_table_cache *tbl_ptr)
+{
+ uint32_t pub_ip_addr;
+ uint16_t prev = 0, nxt_indx = 0, new_entry;
+ struct ipa_nat_rule *tbl = NULL, *expn_tbl = NULL;
+
+ pub_ip_addr = tbl_ptr->public_addr;
+
+ tbl = (struct ipa_nat_rule *)tbl_ptr->ipv4_rules_addr;
+ expn_tbl = (struct ipa_nat_rule *)tbl_ptr->ipv4_expn_rules_addr;
+
+ /* copy the values from client rule to sw rule */
+ sw_rule->private_ip = clnt_rule->private_ip;
+ sw_rule->private_port = clnt_rule->private_port;
+ sw_rule->protocol = clnt_rule->protocol;
+ sw_rule->public_port = clnt_rule->public_port;
+ sw_rule->target_ip = clnt_rule->target_ip;
+ sw_rule->target_port = clnt_rule->target_port;
+
+ /* consider only public and private ip fields */
+ sw_rule->ip_chksum = ipa_nati_calc_ip_cksum(pub_ip_addr,
+ clnt_rule->private_ip);
+
+ if (IPPROTO_TCP == sw_rule->protocol ||
+ IPPROTO_UDP == sw_rule->protocol) {
+ /* consider public and private ip & port fields */
+ sw_rule->tcp_udp_chksum = ipa_nati_calc_tcp_udp_cksum(
+ pub_ip_addr,
+ clnt_rule->public_port,
+ clnt_rule->private_ip,
+ clnt_rule->private_port);
+ }
+
+ sw_rule->rsvd1 = 0;
+ sw_rule->enable = IPA_NAT_FLAG_DISABLE_BIT;
+ sw_rule->next_index = 0;
+
+ /*
+ SW sets this timer to 0.
+ The assumption is that 0 is an invalid clock value and no clock
+ wraparounds are expected
+ */
+ sw_rule->time_stamp = 0;
+ sw_rule->rsvd2 = 0;
+ sw_rule->prev_index = 0;
+ sw_rule->indx_tbl_entry = 0;
+
+ new_entry = dst_hash(clnt_rule->target_ip,
+ clnt_rule->target_port,
+ clnt_rule->public_port,
+ clnt_rule->protocol,
+ tbl_ptr->table_entries-1);
+
+ /* check whether there is any collision
+ if no collision return */
+ if (!Read16BitFieldValue(tbl[new_entry].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ sw_rule->prev_index = 0;
+ IPADBG("Destination Nat New Entry Index %d\n", new_entry);
+ return new_entry;
+ }
+
+ /* First collision */
+ if (Read16BitFieldValue(tbl[new_entry].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {
+ sw_rule->prev_index = new_entry;
+ } else { /* check for more than one collision */
+ /* Find the IPA_NAT_DEL_TYPE_LAST entry in list */
+ nxt_indx = Read16BitFieldValue(tbl[new_entry].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+
+ while (nxt_indx != IPA_NAT_INVALID_NAT_ENTRY) {
+ prev = nxt_indx;
+
+ nxt_indx -= tbl_ptr->table_entries;
+ nxt_indx = Read16BitFieldValue(expn_tbl[nxt_indx].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+
+ /* Handling error case */
+ if (prev == nxt_indx) {
+ IPAERR("Error: Prev index:%d and next:%d index should not be same\n", prev, nxt_indx);
+ return IPA_NAT_INVALID_NAT_ENTRY;
+ }
+ }
+
+ sw_rule->prev_index = prev;
+ }
+
+ /* On collision check for the free entry in expansion table */
+ new_entry = ipa_nati_expn_tbl_free_entry(expn_tbl,
+ tbl_ptr->expn_table_entries);
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == new_entry) {
+ /* Expansion table is full return*/
+ IPAERR("Expansion table is full\n");
+ IPAERR("Current Table: %d & Expn Entries: %d\n",
+ tbl_ptr->cur_tbl_cnt, tbl_ptr->cur_expn_tbl_cnt);
+ return IPA_NAT_INVALID_NAT_ENTRY;
+ }
+ new_entry += tbl_ptr->table_entries;
+
+ IPADBG("new entry index %d\n", new_entry);
+ return new_entry;
+}
+
+/* returns expn table entry index */
+uint16_t ipa_nati_expn_tbl_free_entry(struct ipa_nat_rule *expn_tbl,
+ uint16_t size)
+{
+ int cnt;
+
+ for (cnt = 1; cnt < size; cnt++) {
+ if (!Read16BitFieldValue(expn_tbl[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ IPADBG("new expansion table entry index %d\n", cnt);
+ return cnt;
+ }
+ }
+
+ IPAERR("nat expansion table is full\n");
+ return 0;
+}
+
+uint16_t ipa_nati_generate_index_rule(const ipa_nat_ipv4_rule *clnt_rule,
+ struct ipa_nat_indx_tbl_sw_rule *sw_rule,
+ struct ipa_nat_ip4_table_cache *tbl_ptr)
+{
+ struct ipa_nat_indx_tbl_rule *indx_tbl, *indx_expn_tbl;
+ uint16_t prev = 0, nxt_indx = 0, new_entry;
+
+ indx_tbl =
+ (struct ipa_nat_indx_tbl_rule *)tbl_ptr->index_table_addr;
+ indx_expn_tbl =
+ (struct ipa_nat_indx_tbl_rule *)tbl_ptr->index_table_expn_addr;
+
+ new_entry = src_hash(clnt_rule->private_ip,
+ clnt_rule->private_port,
+ clnt_rule->target_ip,
+ clnt_rule->target_port,
+ clnt_rule->protocol,
+ tbl_ptr->table_entries-1);
+
+ /* check whether there is any collision
+ if no collision return */
+ if (!Read16BitFieldValue(indx_tbl[new_entry].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ sw_rule->prev_index = 0;
+ IPADBG("Source Nat Index Table Entry %d\n", new_entry);
+ return new_entry;
+ }
+
+ /* check for more than one collision */
+ if (Read16BitFieldValue(indx_tbl[new_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == IPA_NAT_INVALID_NAT_ENTRY) {
+ sw_rule->prev_index = new_entry;
+ IPADBG("First collosion. Entry %d\n", new_entry);
+ } else {
+ /* Find the IPA_NAT_DEL_TYPE_LAST entry in list */
+ nxt_indx = Read16BitFieldValue(indx_tbl[new_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ while (nxt_indx != IPA_NAT_INVALID_NAT_ENTRY) {
+ prev = nxt_indx;
+
+ nxt_indx -= tbl_ptr->table_entries;
+ nxt_indx = Read16BitFieldValue(indx_expn_tbl[nxt_indx].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ /* Handling error case */
+ if (prev == nxt_indx) {
+ IPAERR("Error: Prev:%d and next:%d index should not be same\n", prev, nxt_indx);
+ return IPA_NAT_INVALID_NAT_ENTRY;
+ }
+ }
+
+ sw_rule->prev_index = prev;
+ }
+
+ /* On collision check for the free entry in expansion table */
+ new_entry = ipa_nati_index_expn_get_free_entry(indx_expn_tbl,
+ tbl_ptr->expn_table_entries);
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == new_entry) {
+ /* Expansion table is full return*/
+ IPAERR("Index expansion table is full\n");
+ IPAERR("Current Table: %d & Expn Entries: %d\n",
+ tbl_ptr->cur_tbl_cnt, tbl_ptr->cur_expn_tbl_cnt);
+ return IPA_NAT_INVALID_NAT_ENTRY;
+ }
+ new_entry += tbl_ptr->table_entries;
+
+
+ if (sw_rule->prev_index == new_entry) {
+ IPAERR("Error: prev_entry:%d ", sw_rule->prev_index);
+ IPAERR("and new_entry:%d should not be same ", new_entry);
+ IPAERR("infinite loop detected\n");
+ return IPA_NAT_INVALID_NAT_ENTRY;
+ }
+
+ IPADBG("index table entry %d\n", new_entry);
+ return new_entry;
+}
+
+/* returns index expn table entry index */
+uint16_t ipa_nati_index_expn_get_free_entry(
+ struct ipa_nat_indx_tbl_rule *indx_tbl,
+ uint16_t size)
+{
+ int cnt;
+ for (cnt = 1; cnt < size; cnt++) {
+ if (!Read16BitFieldValue(indx_tbl[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ return cnt;
+ }
+ }
+
+ IPAERR("nat index expansion table is full\n");
+ return 0;
+}
+
+void ipa_nati_write_next_index(uint8_t tbl_indx,
+ nat_table_type tbl_type,
+ uint16_t value,
+ uint32_t offset)
+{
+ struct ipa_ioc_nat_dma_cmd *cmd;
+
+ IPADBG("Updating next index field of table %d on collosion using dma\n", tbl_type);
+ IPADBG("table index: %d, value: %d offset;%d\n", tbl_indx, value, offset);
+
+ cmd = (struct ipa_ioc_nat_dma_cmd *)
+ malloc(sizeof(struct ipa_ioc_nat_dma_cmd)+
+ sizeof(struct ipa_ioc_nat_dma_one));
+ if (NULL == cmd) {
+ IPAERR("unable to allocate memory\n");
+ return;
+ }
+
+ cmd->dma[0].table_index = tbl_indx;
+ cmd->dma[0].base_addr = tbl_type;
+ cmd->dma[0].data = value;
+ cmd->dma[0].offset = offset;
+
+ cmd->entries = 1;
+ if (ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_NAT_DMA, cmd)) {
+ perror("ipa_nati_post_ipv4_dma_cmd(): ioctl error value");
+ IPAERR("unable to call dma icotl to update next index\n");
+ IPAERR("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ goto fail;
+ }
+
+fail:
+ free(cmd);
+
+ return;
+}
+
+void ipa_nati_copy_ipv4_rule_to_hw(
+ struct ipa_nat_ip4_table_cache *ipv4_cache,
+ struct ipa_nat_sw_rule *rule,
+ uint16_t entry, uint8_t tbl_index)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ uint16_t prev_entry = rule->prev_index;
+ nat_table_type tbl_type;
+ uint32_t offset = 0;
+
+ if (entry < ipv4_cache->table_entries) {
+ tbl_ptr = (struct ipa_nat_rule *)ipv4_cache->ipv4_rules_addr;
+
+ memcpy(&tbl_ptr[entry],
+ rule,
+ sizeof(struct ipa_nat_rule));
+ } else {
+ tbl_ptr = (struct ipa_nat_rule *)ipv4_cache->ipv4_expn_rules_addr;
+ memcpy(&tbl_ptr[entry - ipv4_cache->table_entries],
+ rule,
+ sizeof(struct ipa_nat_rule));
+ }
+
+ /* Update the previos entry next_index */
+ if (IPA_NAT_INVALID_NAT_ENTRY != prev_entry) {
+
+ if (prev_entry < ipv4_cache->table_entries) {
+ tbl_type = IPA_NAT_BASE_TBL;
+ tbl_ptr = (struct ipa_nat_rule *)ipv4_cache->ipv4_rules_addr;
+ } else {
+ tbl_type = IPA_NAT_EXPN_TBL;
+ /* tbp_ptr is already pointing to expansion table
+ no need to initialize it */
+ prev_entry = prev_entry - ipv4_cache->table_entries;
+ }
+
+ offset = ipa_nati_get_entry_offset(ipv4_cache, tbl_type, prev_entry);
+ offset += IPA_NAT_RULE_NEXT_FIELD_OFFSET;
+
+ ipa_nati_write_next_index(tbl_index, tbl_type, entry, offset);
+ }
+
+ return;
+}
+
+void ipa_nati_copy_ipv4_index_rule_to_hw(
+ struct ipa_nat_ip4_table_cache *ipv4_cache,
+ struct ipa_nat_indx_tbl_sw_rule *indx_sw_rule,
+ uint16_t entry,
+ uint8_t tbl_index)
+{
+ struct ipa_nat_indx_tbl_rule *tbl_ptr;
+ struct ipa_nat_sw_indx_tbl_rule sw_rule;
+ uint16_t prev_entry = indx_sw_rule->prev_index;
+ nat_table_type tbl_type;
+ uint16_t offset = 0;
+
+ sw_rule.next_index = indx_sw_rule->next_index;
+ sw_rule.tbl_entry = indx_sw_rule->tbl_entry;
+
+ if (entry < ipv4_cache->table_entries) {
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)ipv4_cache->index_table_addr;
+
+ memcpy(&tbl_ptr[entry],
+ &sw_rule,
+ sizeof(struct ipa_nat_indx_tbl_rule));
+ } else {
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)ipv4_cache->index_table_expn_addr;
+
+ memcpy(&tbl_ptr[entry - ipv4_cache->table_entries],
+ &sw_rule,
+ sizeof(struct ipa_nat_indx_tbl_rule));
+ }
+
+ /* Update the next field of previous entry on collosion */
+ if (IPA_NAT_INVALID_NAT_ENTRY != prev_entry) {
+ if (prev_entry < ipv4_cache->table_entries) {
+ tbl_type = IPA_NAT_INDX_TBL;
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)ipv4_cache->index_table_addr;
+ } else {
+ tbl_type = IPA_NAT_INDEX_EXPN_TBL;
+ /* tbp_ptr is already pointing to expansion table
+ no need to initialize it */
+ prev_entry = prev_entry - ipv4_cache->table_entries;
+ }
+
+ offset = ipa_nati_get_index_entry_offset(ipv4_cache, tbl_type, prev_entry);
+ offset += IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;
+
+ IPADBG("Updating next index field of index table on collosion using dma()\n");
+ ipa_nati_write_next_index(tbl_index, tbl_type, entry, offset);
+ }
+
+ return;
+}
+
+int ipa_nati_post_ipv4_dma_cmd(uint8_t tbl_indx,
+ uint16_t entry)
+{
+ struct ipa_ioc_nat_dma_cmd *cmd;
+ struct ipa_nat_rule *tbl_ptr;
+ uint32_t offset = ipv4_nat_cache.ip4_tbl[tbl_indx].tbl_addr_offset;
+ int ret = 0;
+
+ cmd = (struct ipa_ioc_nat_dma_cmd *)
+ malloc(sizeof(struct ipa_ioc_nat_dma_cmd)+
+ sizeof(struct ipa_ioc_nat_dma_one));
+ if (NULL == cmd) {
+ IPAERR("unable to allocate memory\n");
+ return -ENOMEM;
+ }
+
+ if (entry < ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries) {
+ tbl_ptr =
+ (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr;
+
+ cmd->dma[0].table_index = tbl_indx;
+ cmd->dma[0].base_addr = IPA_NAT_BASE_TBL;
+ cmd->dma[0].data = IPA_NAT_FLAG_ENABLE_BIT_MASK;
+
+ cmd->dma[0].offset = (char *)&tbl_ptr[entry] - (char *)tbl_ptr;
+ cmd->dma[0].offset += IPA_NAT_RULE_FLAG_FIELD_OFFSET;
+ } else {
+ tbl_ptr =
+ (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_expn_rules_addr;
+ entry = entry - ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries;
+
+ cmd->dma[0].table_index = tbl_indx;
+ cmd->dma[0].base_addr = IPA_NAT_EXPN_TBL;
+ cmd->dma[0].data = IPA_NAT_FLAG_ENABLE_BIT_MASK;
+
+ cmd->dma[0].offset = (char *)&tbl_ptr[entry] - (char *)tbl_ptr;
+ cmd->dma[0].offset += IPA_NAT_RULE_FLAG_FIELD_OFFSET;
+ cmd->dma[0].offset += offset;
+ }
+
+ cmd->entries = 1;
+ if (ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_NAT_DMA, cmd)) {
+ perror("ipa_nati_post_ipv4_dma_cmd(): ioctl error value");
+ IPAERR("unable to call dma icotl\n");
+ IPADBG("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ ret = -EIO;
+ goto fail;
+ }
+ IPADBG("posted IPA_IOC_NAT_DMA to kernel successfully during add operation\n");
+
+
+fail:
+ free(cmd);
+
+ return ret;
+}
+
+
+int ipa_nati_del_ipv4_rule(uint32_t tbl_hdl,
+ uint32_t rule_hdl)
+{
+ uint8_t expn_tbl;
+ uint16_t tbl_entry;
+ struct ipa_nat_ip4_table_cache *tbl_ptr;
+ del_type rule_pos;
+ uint8_t tbl_indx = (uint8_t)(tbl_hdl - 1);
+ int ret;
+
+ /* Parse the rule handle */
+ ipa_nati_parse_ipv4_rule_hdl(tbl_indx, (uint16_t)rule_hdl,
+ &expn_tbl, &tbl_entry);
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_entry) {
+ IPAERR("Invalid Rule Entry\n");
+ ret = -EINVAL;
+ goto fail;
+ }
+
+ if (pthread_mutex_lock(&nat_mutex) != 0) {
+ ret = -1;
+ goto mutex_lock_error;
+ }
+
+ IPADBG("Delete below rule\n");
+ IPADBG("tbl_entry:%d expn_tbl:%d\n", tbl_entry, expn_tbl);
+
+ tbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_indx];
+ if (!tbl_ptr->valid) {
+ IPAERR("invalid table handle\n");
+ ret = -EINVAL;
+ if (pthread_mutex_unlock(&nat_mutex) != 0)
+ goto mutex_unlock_error;
+ goto fail;
+ }
+
+ ipa_nati_find_rule_pos(tbl_ptr, expn_tbl,
+ tbl_entry, &rule_pos);
+ IPADBG("rule_pos:%d\n", rule_pos);
+
+ if (ipa_nati_post_del_dma_cmd(tbl_indx, tbl_entry,
+ expn_tbl, rule_pos)) {
+ ret = -EINVAL;
+ if (pthread_mutex_unlock(&nat_mutex) != 0)
+ goto mutex_unlock_error;
+ goto fail;
+ }
+
+ ipa_nati_del_dead_ipv4_head_nodes(tbl_indx);
+
+ /* Reset rule_id_array entry */
+ ipv4_nat_cache.ip4_tbl[tbl_indx].rule_id_array[rule_hdl-1] =
+ IPA_NAT_INVALID_NAT_ENTRY;
+
+#ifdef NAT_DUMP
+ IPADBG("Dumping Table after deleting rule\n");
+ ipa_nat_dump_ipv4_table(tbl_hdl);
+#endif
+
+ if (pthread_mutex_unlock(&nat_mutex) != 0) {
+ ret = -1;
+ goto mutex_unlock_error;
+ }
+
+ return 0;
+
+mutex_lock_error:
+ IPAERR("unable to lock the nat mutex\n");
+ return ret;
+
+mutex_unlock_error:
+ IPAERR("unable to unlock the nat mutex\n");
+
+fail:
+ return ret;
+}
+
+void ReorderCmds(struct ipa_ioc_nat_dma_cmd *cmd, int size)
+{
+ int indx_tbl_start = 0, cnt, cnt1;
+ struct ipa_ioc_nat_dma_cmd *tmp;
+
+ IPADBG("called ReorderCmds() with entries :%d\n", cmd->entries);
+
+ for (cnt = 0; cnt < cmd->entries; cnt++) {
+ if (cmd->dma[cnt].base_addr == IPA_NAT_INDX_TBL ||
+ cmd->dma[cnt].base_addr == IPA_NAT_INDEX_EXPN_TBL) {
+ indx_tbl_start = cnt;
+ break;
+ }
+ }
+
+ if (indx_tbl_start == 0) {
+ IPADBG("Reorder not needed\n");
+ return;
+ }
+
+ tmp = (struct ipa_ioc_nat_dma_cmd *)malloc(size);
+ if (tmp == NULL) {
+ IPAERR("unable to allocate memory\n");
+ return;
+ }
+
+ cnt1 = 0;
+ tmp->entries = cmd->entries;
+ for (cnt = indx_tbl_start; cnt < cmd->entries; cnt++) {
+ tmp->dma[cnt1] = cmd->dma[cnt];
+ cnt1++;
+ }
+
+ for (cnt = 0; cnt < indx_tbl_start; cnt++) {
+ tmp->dma[cnt1] = cmd->dma[cnt];
+ cnt1++;
+ }
+
+ memset(cmd, 0, size);
+ memcpy(cmd, tmp, size);
+ free(tmp);
+
+ return;
+}
+
+int ipa_nati_post_del_dma_cmd(uint8_t tbl_indx,
+ uint16_t cur_tbl_entry,
+ uint8_t expn_tbl,
+ del_type rule_pos)
+{
+
+#define MAX_DMA_ENTRIES_FOR_DEL 3
+
+ struct ipa_nat_ip4_table_cache *cache_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ struct ipa_nat_rule *tbl_ptr;
+ int ret = 0, size = 0;
+
+ uint16_t indx_tbl_entry = IPA_NAT_INVALID_NAT_ENTRY;
+ del_type indx_rule_pos;
+
+ struct ipa_ioc_nat_dma_cmd *cmd;
+ uint8_t no_of_cmds = 0;
+
+ uint16_t prev_entry = IPA_NAT_INVALID_NAT_ENTRY;
+ uint16_t next_entry = IPA_NAT_INVALID_NAT_ENTRY;
+ uint16_t indx_next_entry = IPA_NAT_INVALID_NAT_ENTRY;
+ uint16_t indx_next_next_entry = IPA_NAT_INVALID_NAT_ENTRY;
+ uint16_t table_entry;
+
+ size = sizeof(struct ipa_ioc_nat_dma_cmd)+
+ (MAX_DMA_ENTRIES_FOR_DEL * sizeof(struct ipa_ioc_nat_dma_one));
+
+ cmd = (struct ipa_ioc_nat_dma_cmd *)malloc(size);
+ if (NULL == cmd) {
+ IPAERR("unable to allocate memory\n");
+ return -ENOMEM;
+ }
+
+ cache_ptr = &ipv4_nat_cache.ip4_tbl[tbl_indx];
+ if (!expn_tbl) {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;
+ } else {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;
+ }
+
+
+ if (!Read16BitFieldValue(tbl_ptr[cur_tbl_entry].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ IPAERR("Deleting invalid(not enabled) rule\n");
+ ret = -EINVAL;
+ goto fail;
+ }
+
+ indx_tbl_entry =
+ Read16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,
+ SW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD);
+
+ /* ================================================
+ Base Table rule Deletion
+ ================================================*/
+ /* Just delete the current rule by disabling the flag field */
+ if (IPA_NAT_DEL_TYPE_ONLY_ONE == rule_pos) {
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;
+ cmd->dma[no_of_cmds].data = IPA_NAT_FLAG_DISABLE_BIT_MASK;
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr,
+ cur_tbl_entry);
+ cmd->dma[no_of_cmds].offset += IPA_NAT_RULE_FLAG_FIELD_OFFSET;
+ }
+
+ /* Just update the protocol field to invalid */
+ else if (IPA_NAT_DEL_TYPE_HEAD == rule_pos) {
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;
+ cmd->dma[no_of_cmds].data = IPA_NAT_INVALID_PROTO_FIELD_VALUE;
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr,
+ cur_tbl_entry);
+ cmd->dma[no_of_cmds].offset += IPA_NAT_RULE_PROTO_FIELD_OFFSET;
+
+ IPADBG("writing invalid proto: 0x%x\n", cmd->dma[no_of_cmds].data);
+ }
+
+ /*
+ Update the previous entry of next_index field value
+ with current entry next_index field value
+ */
+ else if (IPA_NAT_DEL_TYPE_MIDDLE == rule_pos) {
+ prev_entry =
+ Read16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,
+ SW_SPEC_PARAM_PREV_INDEX_FIELD);
+
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].data =
+ Read16BitFieldValue(tbl_ptr[cur_tbl_entry].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;
+ if (prev_entry >= cache_ptr->table_entries) {
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_EXPN_TBL;
+ prev_entry -= cache_ptr->table_entries;
+ }
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr, prev_entry);
+
+ cmd->dma[no_of_cmds].offset += IPA_NAT_RULE_NEXT_FIELD_OFFSET;
+ }
+
+ /*
+ Reset the previous entry of next_index field with 0
+ */
+ else if (IPA_NAT_DEL_TYPE_LAST == rule_pos) {
+ prev_entry =
+ Read16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,
+ SW_SPEC_PARAM_PREV_INDEX_FIELD);
+
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].data = IPA_NAT_INVALID_NAT_ENTRY;
+
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_BASE_TBL;
+ if (prev_entry >= cache_ptr->table_entries) {
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_EXPN_TBL;
+ prev_entry -= cache_ptr->table_entries;
+ }
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr, prev_entry);
+
+ cmd->dma[no_of_cmds].offset += IPA_NAT_RULE_NEXT_FIELD_OFFSET;
+ }
+
+ /* ================================================
+ Base Table rule Deletion End
+ ================================================*/
+
+ /* ================================================
+ Index Table rule Deletion
+ ================================================*/
+ ipa_nati_find_index_rule_pos(cache_ptr,
+ indx_tbl_entry,
+ &indx_rule_pos);
+ IPADBG("Index table entry: 0x%x\n", indx_tbl_entry);
+ IPADBG("and position: %d\n", indx_rule_pos);
+ if (indx_tbl_entry >= cache_ptr->table_entries) {
+ indx_tbl_entry -= cache_ptr->table_entries;
+ indx_tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;
+ } else {
+ indx_tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;
+ }
+
+ /* Just delete the current rule by resetting nat_table_index field to 0 */
+ if (IPA_NAT_DEL_TYPE_ONLY_ONE == indx_rule_pos) {
+ no_of_cmds++;
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].data = IPA_NAT_INVALID_NAT_ENTRY;
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_index_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr,
+ indx_tbl_entry);
+
+ cmd->dma[no_of_cmds].offset +=
+ IPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET;
+ }
+
+ /* copy the next entry values to current entry */
+ else if (IPA_NAT_DEL_TYPE_HEAD == indx_rule_pos) {
+ next_entry =
+ Read16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ next_entry -= cache_ptr->table_entries;
+
+ no_of_cmds++;
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+
+ /* Copy the nat_table_index field value of next entry */
+ indx_tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;
+ cmd->dma[no_of_cmds].data =
+ Read16BitFieldValue(indx_tbl_ptr[next_entry].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD);
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_index_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr,
+ indx_tbl_entry);
+
+ cmd->dma[no_of_cmds].offset +=
+ IPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET;
+
+ /* Copy the next_index field value of next entry */
+ no_of_cmds++;
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].data =
+ Read16BitFieldValue(indx_tbl_ptr[next_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_index_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr, indx_tbl_entry);
+
+ cmd->dma[no_of_cmds].offset +=
+ IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;
+ indx_next_entry = next_entry;
+ }
+
+ /*
+ Update the previous entry of next_index field value
+ with current entry next_index field value
+ */
+ else if (IPA_NAT_DEL_TYPE_MIDDLE == indx_rule_pos) {
+ prev_entry = cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index;
+
+ no_of_cmds++;
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].data =
+ Read16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;
+ if (prev_entry >= cache_ptr->table_entries) {
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDEX_EXPN_TBL;
+ prev_entry -= cache_ptr->table_entries;
+ }
+
+ IPADBG("prev_entry: %d update with cur next_index: %d\n",
+ prev_entry, cmd->dma[no_of_cmds].data);
+ IPADBG("prev_entry: %d exist in table_type:%d\n",
+ prev_entry, cmd->dma[no_of_cmds].base_addr);
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_index_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr, prev_entry);
+
+ cmd->dma[no_of_cmds].offset +=
+ IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;
+ }
+
+ /* Reset the previous entry next_index field with 0 */
+ else if (IPA_NAT_DEL_TYPE_LAST == indx_rule_pos) {
+ prev_entry = cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index;
+
+ no_of_cmds++;
+ cmd->dma[no_of_cmds].table_index = tbl_indx;
+ cmd->dma[no_of_cmds].data = IPA_NAT_INVALID_NAT_ENTRY;
+
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDX_TBL;
+ if (prev_entry >= cache_ptr->table_entries) {
+ cmd->dma[no_of_cmds].base_addr = IPA_NAT_INDEX_EXPN_TBL;
+ prev_entry -= cache_ptr->table_entries;
+ }
+
+ IPADBG("Reseting prev_entry: %d next_index\n", prev_entry);
+ IPADBG("prev_entry: %d exist in table_type:%d\n",
+ prev_entry, cmd->dma[no_of_cmds].base_addr);
+
+ cmd->dma[no_of_cmds].offset =
+ ipa_nati_get_index_entry_offset(cache_ptr,
+ cmd->dma[no_of_cmds].base_addr, prev_entry);
+
+ cmd->dma[no_of_cmds].offset +=
+ IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET;
+ }
+
+ /* ================================================
+ Index Table rule Deletion End
+ ================================================*/
+ cmd->entries = no_of_cmds + 1;
+
+ if (cmd->entries > 1) {
+ ReorderCmds(cmd, size);
+ }
+ if (ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_NAT_DMA, cmd)) {
+ perror("ipa_nati_post_del_dma_cmd(): ioctl error value");
+ IPAERR("unable to post cmd\n");
+ IPADBG("ipa fd %d\n", ipv4_nat_cache.ipa_fd);
+ ret = -EIO;
+ goto fail;
+ }
+
+ /* if entry exist in IPA_NAT_DEL_TYPE_MIDDLE of list
+ Update the previous entry in sw specific parameters
+ */
+ if (IPA_NAT_DEL_TYPE_MIDDLE == rule_pos) {
+ /* Retrieve the current entry prev_entry value */
+ prev_entry =
+ Read16BitFieldValue(tbl_ptr[cur_tbl_entry].sw_spec_params,
+ SW_SPEC_PARAM_PREV_INDEX_FIELD);
+
+ /* Retrieve the next entry */
+ next_entry =
+ Read16BitFieldValue(tbl_ptr[cur_tbl_entry].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+
+ next_entry -= cache_ptr->table_entries;
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;
+
+ /* copy the current entry prev_entry value to next entry*/
+ UpdateSwSpecParams(&tbl_ptr[next_entry],
+ IPA_NAT_SW_PARAM_PREV_INDX_BYTE,
+ prev_entry);
+ }
+
+ /* Reset the other field values of current delete entry
+ In case of IPA_NAT_DEL_TYPE_HEAD, don't reset */
+ if (IPA_NAT_DEL_TYPE_HEAD != rule_pos) {
+ memset(&tbl_ptr[cur_tbl_entry], 0, sizeof(struct ipa_nat_rule));
+ }
+
+ if (indx_rule_pos == IPA_NAT_DEL_TYPE_HEAD) {
+
+ /* Update next next entry previous value to current
+ entry as we moved the next entry values
+ to current entry */
+ indx_next_next_entry =
+ Read16BitFieldValue(indx_tbl_ptr[indx_next_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ if (indx_next_next_entry != 0 &&
+ indx_next_next_entry >= cache_ptr->table_entries) {
+
+ IPADBG("Next Next entry: %d\n", indx_next_next_entry);
+ indx_next_next_entry -= cache_ptr->table_entries;
+
+ IPADBG("Updating entry: %d prev index to: %d\n",
+ indx_next_next_entry, indx_tbl_entry);
+ cache_ptr->index_expn_table_meta[indx_next_next_entry].prev_index =
+ indx_tbl_entry;
+ }
+
+ /* Now reset the next entry as we copied
+ the next entry to current entry */
+ IPADBG("Resetting, index table entry(Proper): %d\n",
+ (cache_ptr->table_entries + indx_next_entry));
+
+ /* This resets both table entry and next index values */
+ indx_tbl_ptr[indx_next_entry].tbl_entry_nxt_indx = 0;
+
+ /*
+ In case of IPA_NAT_DEL_TYPE_HEAD, update the sw specific parameters
+ (index table entry) of base table entry
+ */
+ indx_tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;
+ table_entry =
+ Read16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD);
+
+ if (table_entry >= cache_ptr->table_entries) {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;
+ table_entry -= cache_ptr->table_entries;
+ } else {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;
+ }
+
+ UpdateSwSpecParams(&tbl_ptr[table_entry],
+ IPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE,
+ indx_tbl_entry);
+ } else {
+ /* Update the prev_entry value (in index_expn_table_meta)
+ for the next_entry in list with current entry prev_entry value
+ */
+ if (IPA_NAT_DEL_TYPE_MIDDLE == indx_rule_pos) {
+ next_entry =
+ Read16BitFieldValue(indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+
+ if (next_entry >= cache_ptr->table_entries) {
+ next_entry -= cache_ptr->table_entries;
+ }
+
+ cache_ptr->index_expn_table_meta[next_entry].prev_index =
+ cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index;
+
+ cache_ptr->index_expn_table_meta[indx_tbl_entry].prev_index =
+ IPA_NAT_INVALID_NAT_ENTRY;
+ }
+
+ IPADBG("At, indx_tbl_entry value: %d\n", indx_tbl_entry);
+ IPADBG("At, indx_tbl_entry member address: %p\n",
+ &indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx);
+
+ indx_tbl_ptr[indx_tbl_entry].tbl_entry_nxt_indx = 0;
+
+ }
+
+fail:
+ free(cmd);
+
+ return ret;
+}
+
+void ipa_nati_find_index_rule_pos(
+ struct ipa_nat_ip4_table_cache *cache_ptr,
+ uint16_t tbl_entry,
+ del_type *rule_pos)
+{
+ struct ipa_nat_indx_tbl_rule *tbl_ptr;
+
+ if (tbl_entry >= cache_ptr->table_entries) {
+ tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_expn_addr;
+
+ tbl_entry -= cache_ptr->table_entries;
+ if (Read16BitFieldValue(tbl_ptr[tbl_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == IPA_NAT_INVALID_NAT_ENTRY) {
+ *rule_pos = IPA_NAT_DEL_TYPE_LAST;
+ } else {
+ *rule_pos = IPA_NAT_DEL_TYPE_MIDDLE;
+ }
+ } else {
+ tbl_ptr =
+ (struct ipa_nat_indx_tbl_rule *)cache_ptr->index_table_addr;
+
+ if (Read16BitFieldValue(tbl_ptr[tbl_entry].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == IPA_NAT_INVALID_NAT_ENTRY) {
+ *rule_pos = IPA_NAT_DEL_TYPE_ONLY_ONE;
+ } else {
+ *rule_pos = IPA_NAT_DEL_TYPE_HEAD;
+ }
+ }
+}
+
+void ipa_nati_find_rule_pos(struct ipa_nat_ip4_table_cache *cache_ptr,
+ uint8_t expn_tbl,
+ uint16_t tbl_entry,
+ del_type *rule_pos)
+{
+ struct ipa_nat_rule *tbl_ptr;
+
+ if (expn_tbl) {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_expn_rules_addr;
+ if (Read16BitFieldValue(tbl_ptr[tbl_entry].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {
+ *rule_pos = IPA_NAT_DEL_TYPE_LAST;
+ } else {
+ *rule_pos = IPA_NAT_DEL_TYPE_MIDDLE;
+ }
+ } else {
+ tbl_ptr = (struct ipa_nat_rule *)cache_ptr->ipv4_rules_addr;
+ if (Read16BitFieldValue(tbl_ptr[tbl_entry].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {
+ *rule_pos = IPA_NAT_DEL_TYPE_ONLY_ONE;
+ } else {
+ *rule_pos = IPA_NAT_DEL_TYPE_HEAD;
+ }
+ }
+}
+
+void ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ uint16_t cnt;
+
+ tbl_ptr =
+ (struct ipa_nat_rule *)ipv4_nat_cache.ip4_tbl[tbl_indx].ipv4_rules_addr;
+
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_indx].table_entries;
+ cnt++) {
+
+ if (Read8BitFieldValue(tbl_ptr[cnt].ts_proto,
+ PROTOCOL_FIELD) == IPA_NAT_INVALID_PROTO_FIELD_CMP
+ &&
+ Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == IPA_NAT_INVALID_NAT_ENTRY) {
+ /* Delete the IPA_NAT_DEL_TYPE_HEAD node */
+ IPADBG("deleting the dead node 0x%x\n", cnt);
+ memset(&tbl_ptr[cnt], 0, sizeof(struct ipa_nat_rule));
+ }
+ } /* end of for loop */
+
+ return;
+}
+
+
+/* ========================================================
+ Debug functions
+ ========================================================*/
+#ifdef NAT_DUMP
+void ipa_nat_dump_ipv4_table(uint32_t tbl_hdl)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ int cnt;
+ uint8_t atl_one = 0;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed\n");
+ return;
+ }
+
+ /* Print ipv4 rules */
+ IPADBG("Dumping ipv4 active rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ atl_one = 1;
+ ipa_nati_print_rule(&tbl_ptr[cnt], cnt);
+ }
+ }
+ if (!atl_one) {
+ IPADBG("No active base rules, total: %d\n",
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries);
+ }
+ atl_one = 0;
+
+ /* Print ipv4 expansion rules */
+ IPADBG("Dumping ipv4 active expansion rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ atl_one = 1;
+ ipa_nati_print_rule(&tbl_ptr[cnt],
+ (cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries));
+ }
+ }
+ if (!atl_one) {
+ IPADBG("No active base expansion rules, total: %d\n",
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries);
+ }
+ atl_one = 0;
+
+ /* Print ipv4 index rules */
+ IPADBG("Dumping ipv4 index active rules:\n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ atl_one = 1;
+ ipa_nati_print_index_rule(&indx_tbl_ptr[cnt], cnt, 0);
+ }
+ }
+ if (!atl_one) {
+ IPADBG("No active index table rules, total:%d\n",
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries);
+ }
+ atl_one = 0;
+
+
+ /* Print ipv4 index expansion rules */
+ IPADBG("Dumping ipv4 index expansion active rules:\n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ atl_one = 1;
+ ipa_nati_print_index_rule(&indx_tbl_ptr[cnt],
+ (cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries),
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_expn_table_meta[cnt].prev_index);
+ }
+ }
+ if (!atl_one) {
+ IPADBG("No active index expansion rules, total:%d\n",
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries);
+ }
+ atl_one = 0;
+
+}
+
+void ipa_nati_print_rule(
+ struct ipa_nat_rule *param,
+ uint32_t rule_id)
+{
+ struct ipa_nat_sw_rule sw_rule;
+ memcpy(&sw_rule, param, sizeof(sw_rule));
+ uint32_t ip_addr;
+
+ IPADUMP("rule-id:%d ", rule_id);
+ ip_addr = sw_rule.target_ip;
+ IPADUMP("Trgt-IP:%d.%d.%d.%d ",
+ ((ip_addr & 0xFF000000) >> 24), ((ip_addr & 0x00FF0000) >> 16),
+ ((ip_addr & 0x0000FF00) >> 8), ((ip_addr & 0x000000FF)));
+
+ IPADUMP("Trgt-Port:%d Priv-Port:%d ", sw_rule.target_port, sw_rule.private_port);
+
+ ip_addr = sw_rule.private_ip;
+ IPADUMP("Priv-IP:%d.%d.%d.%d ",
+ ((ip_addr & 0xFF000000) >> 24), ((ip_addr & 0x00FF0000) >> 16),
+ ((ip_addr & 0x0000FF00) >> 8), ((ip_addr & 0x000000FF)));
+
+ IPADUMP("Pub-Port:%d Nxt-indx:%d ", sw_rule.public_port, sw_rule.next_index);
+ IPADUMP("IP-cksm-delta:0x%x En-bit:0x%x ", sw_rule.ip_chksum, sw_rule.enable);
+ IPADUMP("TS:0x%x Proto:0x%x ", sw_rule.time_stamp, sw_rule.protocol);
+ IPADUMP("Prv-indx:%d indx_tbl_entry:%d ", sw_rule.prev_index, sw_rule.indx_tbl_entry);
+ IPADUMP("Tcp-udp-cksum-delta:0x%x", sw_rule.tcp_udp_chksum);
+ IPADUMP("\n");
+ return;
+}
+
+void ipa_nati_print_index_rule(
+ struct ipa_nat_indx_tbl_rule *param,
+ uint32_t rule_id, uint16_t prev_indx)
+{
+ struct ipa_nat_sw_indx_tbl_rule sw_rule;
+ memcpy(&sw_rule, param, sizeof(sw_rule));
+
+ IPADUMP("rule-id:%d Table_entry:%d Next_index:%d, prev_indx:%d",
+ rule_id, sw_rule.tbl_entry, sw_rule.next_index, prev_indx);
+ IPADUMP("\n");
+ return;
+}
+
+int ipa_nati_query_nat_rules(
+ uint32_t tbl_hdl,
+ nat_table_type tbl_type)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ int cnt = 0, ret = 0;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed\n");
+ return ret;
+ }
+
+ /* Print ipv4 rules */
+ if (tbl_type == IPA_NAT_BASE_TBL) {
+ IPADBG("Counting ipv4 active rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].ipv4_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ ret++;
+ }
+ }
+ if (!ret) {
+ IPADBG("No active base rules\n");
+ }
+
+ IPADBG("Number of active base rules: %d\n", ret);
+ }
+
+ /* Print ipv4 expansion rules */
+ if (tbl_type == IPA_NAT_EXPN_TBL) {
+ IPADBG("Counting ipv4 active expansion rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].ipv4_expn_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ ret++;
+ }
+ }
+ if (!ret) {
+ IPADBG("No active base expansion rules\n");
+ }
+
+ IPADBG("Number of active base expansion rules: %d\n", ret);
+ }
+
+ /* Print ipv4 index rules */
+ if (tbl_type == IPA_NAT_INDX_TBL) {
+ IPADBG("Counting ipv4 index active rules:\n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_table_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ ret++;
+ }
+ }
+ if (!ret) {
+ IPADBG("No active index table rules\n");
+ }
+
+ IPADBG("Number of active index table rules: %d\n", ret);
+ }
+
+ /* Print ipv4 index expansion rules */
+ if (tbl_type == IPA_NAT_INDEX_EXPN_TBL) {
+ IPADBG("Counting ipv4 index expansion active rules:\n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_table_expn_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ ret++;
+ }
+ }
+
+ if (!ret)
+ IPADBG("No active index expansion rules\n");
+
+ IPADBG("Number of active index expansion rules: %d\n", ret);
+ }
+
+ return ret;
+}
+#endif
diff --git a/msm8998/ipanat/src/ipa_nat_logi.c b/msm8998/ipanat/src/ipa_nat_logi.c
new file mode 100644
index 0000000..b829b78
--- /dev/null
+++ b/msm8998/ipanat/src/ipa_nat_logi.c
@@ -0,0 +1,49 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_log.cpp
+
+ @brief
+ This file implements the IPAM log functionality.
+
+ @Author
+ Skylar Chang
+
+*/
+#include "ipa_nat_logi.h"
+#include <stdlib.h>
+#include <unistd.h>
+
+void log_nat_message(char *msg)
+{
+ return;
+}
+
+
diff --git a/msm8998/ipanat/test/Android.mk b/msm8998/ipanat/test/Android.mk
new file mode 100644
index 0000000..b8ae6a4
--- /dev/null
+++ b/msm8998/ipanat/test/Android.mk
@@ -0,0 +1,52 @@
+BOARD_PLATFORM_LIST := test
+ifeq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true)
+ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
+ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH)))
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ipanat/inc
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+LOCAL_MODULE := ipa_nat_test
+LOCAL_SRC_FILES := ipa_nat_test000.c \
+ ipa_nat_test001.c \
+ ipa_nat_test002.c \
+ ipa_nat_test003.c \
+ ipa_nat_test004.c \
+ ipa_nat_test005.c \
+ ipa_nat_test006.c \
+ ipa_nat_test007.c \
+ ipa_nat_test008.c \
+ ipa_nat_test009.c \
+ ipa_nat_test010.c \
+ ipa_nat_test011.c \
+ ipa_nat_test012.c \
+ ipa_nat_test013.c \
+ ipa_nat_test014.c \
+ ipa_nat_test015.c \
+ ipa_nat_test016.c \
+ ipa_nat_test017.c \
+ ipa_nat_test018.c \
+ ipa_nat_test019.c \
+ ipa_nat_test020.c \
+ ipa_nat_test021.c \
+ ipa_nat_test022.c \
+ main.c
+
+
+LOCAL_SHARED_LIBRARIES := libipanat
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/kernel-tests/ip_accelerator
+
+include $(BUILD_EXECUTABLE)
+
+endif # $(TARGET_ARCH)
+endif
+endif
diff --git a/msm8998/ipanat/test/Makefile.am b/msm8998/ipanat/test/Makefile.am
new file mode 100644
index 0000000..3aec070
--- /dev/null
+++ b/msm8998/ipanat/test/Makefile.am
@@ -0,0 +1,42 @@
+AM_CPPFLAGS = -I./../inc \
+ -I$(top_srcdir)/ipanat/inc
+
+AM_CPPFLAGS += -Wall -Wundef -Wno-trigraphs
+AM_CPPFLAGS += -g
+
+ipanattest_SOURCES = ipa_nat_test000.c \
+ ipa_nat_test001.c \
+ ipa_nat_test002.c \
+ ipa_nat_test003.c \
+ ipa_nat_test004.c \
+ ipa_nat_test005.c \
+ ipa_nat_test006.c \
+ ipa_nat_test007.c \
+ ipa_nat_test008.c \
+ ipa_nat_test009.c \
+ ipa_nat_test010.c \
+ ipa_nat_test011.c \
+ ipa_nat_test012.c \
+ ipa_nat_test013.c \
+ ipa_nat_test014.c \
+ ipa_nat_test015.c \
+ ipa_nat_test016.c \
+ ipa_nat_test017.c \
+ ipa_nat_test018.c \
+ ipa_nat_test019.c \
+ ipa_nat_test020.c \
+ ipa_nat_test021.c \
+ ipa_nat_test022.c \
+ main.c
+
+
+bin_PROGRAMS = ipanattest
+
+requiredlibs = ../src/libipanat.la
+
+ipanattest_LDADD = $(requiredlibs)
+
+LOCAL_MODULE := libipanat
+LOCAL_PRELINK_MODULE := false
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/msm8998/ipanat/test/README.txt b/msm8998/ipanat/test/README.txt
new file mode 100644
index 0000000..4e87121
--- /dev/null
+++ b/msm8998/ipanat/test/README.txt
@@ -0,0 +1,18 @@
+1 To run this suite separately(each test case creates table and delete table) use below command
+ - To execute test suite nt times with n entries, command "ipanatest sep nt n"
+
+ Example: To execute test suite 1 time with 100 entries, command "ipanattest sep 100"
+
+
+2. To run test suite not separately(creates table and delete table only once) use below command
+ - To execute test suite nt times with n entries, command "ipanatest reg nt n"
+
+ Example: To execute test suite 5 times with 32 entries, command "ipanattest reg 5 32"
+
+
+3. To run inotify regression test use command, "ipanattest inotify nt"
+
+ Example: To execute inotify 5 times, command "ipanattest inotify 5"
+
+
+4. if we just give command "ipanattest", runs test suite 1 time with 100 entries (non separate)
diff --git a/msm8998/ipanat/test/ipa_nat_test.h b/msm8998/ipanat/test/ipa_nat_test.h
new file mode 100644
index 0000000..d5ac0d5
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*===========================================================================
+
+ INCLUDE FILES FOR MODULE
+
+===========================================================================*/
+#include "stdint.h" /* uint32_t */
+#include "stdio.h"
+#include <netinet/in.h> /* for proto definitions */
+
+#define u32 uint32_t
+#define u16 uint16_t
+#define u8 uint8_t
+
+/*============ Preconditions to run NAT Test cases =========*/
+#define IPA_NAT_TEST_PRE_COND_TE 20
+
+#define CHECK_ERR1(x, tbl_hdl) \
+ if(ipa_nat_validate_ipv4_table(tbl_hdl)) { \
+ if(sep) {\
+ ipa_nat_del_ipv4_tbl(tbl_hdl); \
+ }\
+ return -1;\
+ }\
+ if(x) { \
+ IPAERR("%d\n", ret); \
+ if(sep) {\
+ ipa_nat_del_ipv4_tbl(tbl_hdl); \
+ }\
+ return -1; \
+ }
+
+#define CHECK_ERR(x) if(x) { \
+ IPAERR("%d\n", ret); \
+ return -1;\
+ }
+
+#if 0
+#define CHECK_ERR(x) if(x) { \
+ IPAERR("%d\n", ret); \
+ if(sep) {\
+ ipa_nat_del_ipv4_tbl(tbl_hdl); \
+ }\
+ return -1;\
+ }
+#endif
+
+#define IPADBG(fmt, args...) printf(" %s:%d " fmt, __FUNCTION__, __LINE__, ## args)
+#define IPAERR(fmt, args...) printf(" %s:%d " fmt, __FUNCTION__, __LINE__, ## args)
+
+#define NAT_DUMP
+int ipa_nat_validate_ipv4_table(u32);
+
+int ipa_nat_test000(int, u32, u8);
+int ipa_nat_test001(int, u32, u8);
+int ipa_nat_test002(int, u32, u8);
+int ipa_nat_test003(int, u32, u8);
+int ipa_nat_test004(int, u32, u8);
+int ipa_nat_test005(int, u32, u8);
+int ipa_nat_test006(int, u32, u8);
+int ipa_nat_test007(int, u32, u8);
+int ipa_nat_test008(int, u32, u8);
+int ipa_nat_test009(int, u32, u8);
+int ipa_nat_test010(int, u32, u8);
+int ipa_nat_test011(int, u32, u8);
+int ipa_nat_test012(int, u32, u8);
+int ipa_nat_test013(int, u32, u8);
+int ipa_nat_test014(int, u32, u8);
+int ipa_nat_test015(int, u32, u8);
+int ipa_nat_test016(int, u32, u8);
+int ipa_nat_test017(int, u32, u8);
+int ipa_nat_test018(int, u32, u8);
+int ipa_nat_test019(int, u32, u8);
+int ipa_nat_test020(int, u32, u8);
+int ipa_nat_test021(int, int);
+int ipa_nat_test022(int, u32, u8);
diff --git a/msm8998/ipanat/test/ipa_nat_test000.c b/msm8998/ipanat/test/ipa_nat_test000.c
new file mode 100644
index 0000000..09914ea
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test000.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test000.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Delete ipv4 table
+*/
+/*===========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test000(int total_entries, u32 tbl_hdl, u8 sep)
+{
+
+ int ret;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("unable to create ipv4 nat table and returning Error:%d\n", ret);
+ return -1;
+ }
+ IPADBG("create nat ipv4 table successfully() \n");
+
+ IPADBG("calling ipa_nat_del_ipv4_tbl() \n");
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("Unable to delete ipv4 nat table %d\n", ret);
+ return -1;
+ }
+ IPADBG("deleted ipv4 nat table successfully. Test passed \n");
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test001.c b/msm8998/ipanat/test/ipa_nat_test001.c
new file mode 100644
index 0000000..8daef33
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test001.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test001.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. Delete ipv4 table
+*/
+/*===========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test001(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s()\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test002.c b/msm8998/ipanat/test/ipa_nat_test002.c
new file mode 100644
index 0000000..e6f5ae3
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test002.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test002.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. delete ipv4 rule
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test002(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s()\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test003.c b/msm8998/ipanat/test/ipa_nat_test003.c
new file mode 100644
index 0000000..0634265
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test003.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ IPA_NAT_ipa_nat_test003.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. Add ipv4 rule
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test003(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test004.c b/msm8998/ipanat/test/ipa_nat_test004.c
new file mode 100644
index 0000000..02378ff
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test004.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test004.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Query nat table handle
+ 3. Delete ipv4 table
+*/
+/*===========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test004(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret = 0;
+ u32 tbl_hdl1 = 0;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl1);
+ if(ret == 0)
+ {
+ IPAERR("able to delete table using invalid table handle\n");
+ return -1;
+ }
+ }
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test005.c b/msm8998/ipanat/test/ipa_nat_test005.c
new file mode 100644
index 0000000..12228d1
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test005.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test005.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. Delete ipv4 rule
+ 4. Add ipv4 rule
+ 5. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test005(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret = 0;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ if (sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test006.c b/msm8998/ipanat/test/ipa_nat_test006.c
new file mode 100644
index 0000000..36f0171
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test006.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test006.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same ipv rules
+ 3. delete first followed by second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test006(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret=0;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test007.c b/msm8998/ipanat/test/ipa_nat_test007.c
new file mode 100644
index 0000000..4160c02
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test007.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test007.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same ipv rules
+ 3. delete second followed by first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test007(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test008.c b/msm8998/ipanat/test/ipa_nat_test008.c
new file mode 100644
index 0000000..d016055
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test008.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test008.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 2 distinct rules
+ 3. delete first followed by second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test008(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+ ipv4_rule1.target_ip = 0xC1171602; /* 193.23.22.2 */
+ ipv4_rule1.target_port = 1234;
+ ipv4_rule1.private_ip = 0xC2171602; /* 194.23.22.2 */
+ ipv4_rule1.private_port = 5678;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test009.c b/msm8998/ipanat/test/ipa_nat_test009.c
new file mode 100644
index 0000000..cf3c40f
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test009.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test009.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 2 distinct rules
+ 3. delete second followed by first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test009(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xC1171602; /* 193.23.22.2 */
+ ipv4_rule1.target_port = 1234;
+ ipv4_rule1.private_ip = 0xC2171602; /* 194.23.22.2 */
+ ipv4_rule1.private_port = 5678;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test010.c b/msm8998/ipanat/test/ipa_nat_test010.c
new file mode 100644
index 0000000..42d7fee
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test010.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test010.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. delete first, second followed by last
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test010(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule1.target_port = 1235;
+ ipv4_rule1.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule1.private_port = 5679;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9051;
+
+ ipv4_rule2.target_ip = 0xC1171602; /* 193.23.22.2 */
+ ipv4_rule2.target_port = 1235;
+ ipv4_rule2.private_ip = 0xC2171602; /* 194.23.22.2 */
+ ipv4_rule2.private_port = 5679;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 9051;
+
+ IPADBG("%s():\n",__FUNCTION__);
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test011.c b/msm8998/ipanat/test/ipa_nat_test011.c
new file mode 100644
index 0000000..bcce76c
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test011.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test011.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. delete second, first followed by last
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test011(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xF1181601;
+ ipv4_rule1.target_port = 1555;
+ ipv4_rule1.private_ip = 0xF2151601;
+ ipv4_rule1.private_port = 5999;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9111;
+
+ ipv4_rule2.target_ip = 0xC1166602;
+ ipv4_rule2.target_port = 1555;
+ ipv4_rule2.private_ip = 0xC2155602;
+ ipv4_rule2.private_port = 5777;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 9000;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test012.c b/msm8998/ipanat/test/ipa_nat_test012.c
new file mode 100644
index 0000000..9d3c835
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test012.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test012.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. Delete third, second, first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+
+int ipa_nat_test012(int totoal_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xD1171601;
+ ipv4_rule1.target_port = 3512;
+ ipv4_rule1.private_ip = 0xD2471601;
+ ipv4_rule1.private_port = 9997;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 8881;
+
+ ipv4_rule2.target_ip = 0xC1172452;
+ ipv4_rule2.target_port = 1895;
+ ipv4_rule2.private_ip = 0xC2172452;
+ ipv4_rule2.private_port = 6668;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 5551;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, totoal_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test013.c b/msm8998/ipanat/test/ipa_nat_test013.c
new file mode 100644
index 0000000..2b9b005
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test013.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test013.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. Delete third, first and second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test013(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xC1171609; /* 193.23.22.9 */
+ ipv4_rule1.target_port = 1235;
+ ipv4_rule1.private_ip = 0xC2171609; /* 194.23.22.9 */
+ ipv4_rule1.private_port = 6579;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 8951;
+
+ ipv4_rule2.target_ip = 0xC1171606; /* 193.23.22.6 */
+ ipv4_rule2.target_port = 1235;
+ ipv4_rule2.private_ip = 0xC2171606; /* 194.23.22.6 */
+ ipv4_rule2.private_port = 7956;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 5109;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test014.c b/msm8998/ipanat/test/ipa_nat_test014.c
new file mode 100644
index 0000000..fd30317
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test014.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test014.cpp
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete first, second and third
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test014(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s()\n", __FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test015.c b/msm8998/ipanat/test/ipa_nat_test015.c
new file mode 100644
index 0000000..eaef923
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test015.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test015.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete first, third and second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+
+int ipa_nat_test015(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test016.c b/msm8998/ipanat/test/ipa_nat_test016.c
new file mode 100644
index 0000000..23157e2
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test016.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test016.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete second, first and third
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test016(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test017.c b/msm8998/ipanat/test/ipa_nat_test017.c
new file mode 100644
index 0000000..d88e611
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test017.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test017.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete second, third and first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test017(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test018.c b/msm8998/ipanat/test/ipa_nat_test018.c
new file mode 100644
index 0000000..c885d4d
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test018.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test018.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete third, second and first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test018(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test019.c b/msm8998/ipanat/test/ipa_nat_test019.c
new file mode 100644
index 0000000..3ba3119
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test019.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test019.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete third, first and second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test019(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test020.c b/msm8998/ipanat/test/ipa_nat_test020.c
new file mode 100644
index 0000000..e6871b5
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test020.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test020.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 4 ipv rules
+ 3. delete third, second, fourth and first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test020(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3, rule_hdl4;
+ ipa_nat_ipv4_rule ipv4_rule;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl4);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl4);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test021.c b/msm8998/ipanat/test/ipa_nat_test021.c
new file mode 100644
index 0000000..48c4321
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test021.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test021.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test021(int total_entries, int reg)
+{
+
+ int ret, i;
+ u32 tbl_hdl;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ for(i=0; i<reg; i++)
+ {
+ IPADBG("executing %d th time:\n",i);
+
+ IPADBG("calling ipa_nat_add_ipv4_tbl() \n");
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("unable to create ipv4 nat table and returning Error:%d\n", ret);
+ IPADBG("executed %d times:\n",i);
+ return -1;
+ }
+ IPADBG("create nat ipv4 table successfully() \n");
+
+ IPADBG("calling ipa_nat_del_ipv4_tbl() \n");
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("Unable to delete ipv4 nat table %d\n", ret);
+ IPADBG("executed %d times:\n",i);
+ return -1;
+ }
+ IPADBG("deleted ipv4 nat table successfully. Test passed \n");
+ }
+
+ IPADBG("executed %d times:\n",(i+1));
+ return 0;
+}
diff --git a/msm8998/ipanat/test/ipa_nat_test022.c b/msm8998/ipanat/test/ipa_nat_test022.c
new file mode 100644
index 0000000..ebdd291
--- /dev/null
+++ b/msm8998/ipanat/test/ipa_nat_test022.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test022.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete Head and last entry
+ 4. add 2 new same ip4 entries
+ 5. Add head entry again
+ 6. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test022(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule2;
+ u32 rule_hdl21, rule_hdl22;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ /* Rule 1 */
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ /* Rule 2*/
+ ipv4_rule.target_ip = 0xC1171604; /* 193.23.22.4 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171603; /* 194.23.22.3 */
+ ipv4_rule.private_port = 5680;
+ ipv4_rule.protocol = IPPROTO_UDP;
+ ipv4_rule.public_port = 9066;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR1(ret, tbl_hdl);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Delete head entry */
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Delete Last Entry */
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Add 2 different Entries */
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl21);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl22);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Add first entry again */
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR1(ret, tbl_hdl);
+ }
+
+ return 0;
+}
diff --git a/msm8998/ipanat/test/main.c b/msm8998/ipanat/test/main.c
new file mode 100644
index 0000000..c49ce3b
--- /dev/null
+++ b/msm8998/ipanat/test/main.c
@@ -0,0 +1,640 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "ipa_nat_drv.h"
+#include "ipa_nat_drvi.h"
+#include "ipa_nat_test.h"
+
+extern struct ipa_nat_cache ipv4_nat_cache;
+
+int chk_for_loop(u32 tbl_hdl)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ int cnt;
+ uint16_t cur_entry;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed \n");
+ return -EINVAL;
+ }
+
+ IPADBG("checking ipv4 rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,ENABLE_FIELD)) {
+ if(Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == cnt)
+ {
+ IPAERR("Infinite loop detected, entry\n");
+ ipa_nati_print_rule(&tbl_ptr[cnt], cnt);
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* Print ipv4 expansion rules */
+ IPADBG("checking ipv4 active expansion rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ cur_entry =
+ cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ if (Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == cur_entry)
+ {
+ IPAERR("Infinite loop detected\n");
+ ipa_nati_print_rule(&tbl_ptr[cnt],
+ (cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries));
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* Print ipv4 index rules */
+ IPADBG("checking ipv4 index active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == cnt)
+ {
+ IPAERR("Infinite loop detected\n");
+ ipa_nati_print_index_rule(&indx_tbl_ptr[cnt], cnt, 0);
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* Print ipv4 index expansion rules */
+ IPADBG("Checking ipv4 index expansion active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ cur_entry =
+ cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == cur_entry)
+ {
+ IPAERR("Infinite loop detected\n");
+ ipa_nati_print_index_rule(&indx_tbl_ptr[cnt],
+ (cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries),
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_expn_table_meta[cnt].prev_index);
+ return -EINVAL;
+ }
+ }
+ }
+ return 0;
+}
+
+uint8_t is_base_entry_valid(u32 tbl_hdl, u16 entry)
+{
+ struct ipa_nat_rule *tbl_ptr;
+
+ if (entry >
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries)
+ {
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ entry -=
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ }
+ else
+ {
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ }
+ return (Read16BitFieldValue(tbl_ptr[entry].ip_cksm_enbl,
+ ENABLE_FIELD));
+}
+
+uint8_t is_index_entry_valid(u32 tbl_hdl, u16 entry)
+{
+ struct ipa_nat_indx_tbl_rule *tbl_ptr;
+
+ if (entry >
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries)
+ {
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ entry -=
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ }
+ else
+ {
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ }
+ if (Read16BitFieldValue(tbl_ptr[entry].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+int chk_for_validity(u32 tbl_hdl)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ uint16_t nxt_index, prv_index;
+ int cnt;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed \n");
+ return -EINVAL;
+ }
+
+ /* Validate base table next_indx and prev_indx values */
+ IPADBG("Validating ipv4 active rules: \n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ nxt_index =
+ Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+ if (!is_base_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ IPADBG("Validating ipv4 expansion active rules: \n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ /* Validate next index */
+ nxt_index =
+ Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+ if (!is_base_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+ /* Validate previous index */
+ prv_index =
+ Read16BitFieldValue(tbl_ptr[cnt].sw_spec_params,
+ SW_SPEC_PARAM_PREV_INDEX_FIELD);
+ if (!is_base_entry_valid(tbl_hdl, prv_index)) {
+ IPAERR("Invalid Previous index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ IPADBG("Validating ipv4 index active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ nxt_index =
+ Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+ if (!is_index_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ IPADBG("Validating ipv4 index expansion active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ /* Validate next index*/
+ nxt_index =
+ Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+ if (!is_index_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+
+ /* Validate previous index*/
+ prv_index =
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_expn_table_meta[cnt].prev_index;
+
+ if (!is_index_entry_valid(tbl_hdl, prv_index)) {
+ IPAERR("Invalid Previous index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int ipa_nat_validate_ipv4_table(u32 tbl_hdl)
+{
+ int ret = 0;
+
+ ret = chk_for_loop(tbl_hdl);
+ if (ret)
+ return ret;
+ ret = chk_for_validity(tbl_hdl);
+
+ return ret;
+}
+
+int main(int argc, char* argv[])
+{
+ int exec = 0, pass = 0, ret;
+ int cnt, nt=1;
+ int total_entries = 100;
+ u8 sep = 0;
+ u32 tbl_hdl = 0;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ IPADBG("ipa_nat_testing user space nat driver\n");
+
+ if (argc == 4)
+ {
+ if (!strncmp(argv[1], "reg", 3))
+ {
+ nt = atoi(argv[2]);
+ total_entries = atoi(argv[3]);
+ IPADBG("Reg: %d, Nat Entries: %d\n", nt, total_entries);
+ }
+ else if (!strncmp(argv[1], "sep", 3))
+ {
+ sep = 1;
+ nt = atoi(argv[2]);
+ total_entries = atoi(argv[3]);
+ }
+ }
+ else if (argc == 3)
+ {
+ if (!strncmp(argv[1], "inotify", 7))
+ {
+ ipa_nat_test021(total_entries, atoi(argv[2]));
+ return 0;
+ }
+ else if (!strncmp(argv[1], "sep", 3))
+ {
+ sep = 1;
+ total_entries = atoi(argv[2]);
+ }
+ }
+ else if (argc == 2)
+ {
+ total_entries = atoi(argv[1]);
+ IPADBG("Nat Entries: %d\n", total_entries);
+ }
+
+
+ for (cnt=0; cnt<nt; cnt++)
+ {
+ IPADBG("%s():Executing %d time \n",__FUNCTION__, cnt);
+
+ if (!sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ if (sep)
+ {
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test000(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test001(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+ }
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test002(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ if (sep)
+ {
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test003(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test004(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test005(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+ }
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test006(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test007(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test008(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test009(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ if (total_entries >= IPA_NAT_TEST_PRE_COND_TE)
+ {
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test010(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test011(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test012(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test013(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test014(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test015(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test016(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test017(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test018(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test019(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test020(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test022(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+ }
+
+ if (!sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+ }
+ /*======= Printing Results ==========*/
+ IPADBG("Total ipa_nat Tests Run:%d, Pass:%d, Fail:%d\n",exec, pass, exec-pass);
+ return 0;
+}