[Feature] Merge MR0.5 from MTK
Change-Id: I77f817d2d58dfa7a69b4af32123f2929c724356e
diff --git a/src/extended/hw_nat/hw_nat.c b/src/extended/hw_nat/hw_nat.c
index 555d451..5974c75 100644
--- a/src/extended/hw_nat/hw_nat.c
+++ b/src/extended/hw_nat/hw_nat.c
@@ -21,18 +21,18 @@
void show_usage(void)
{
printf("Add Static Entry\n");
- printf("hw_nat -a -h [SMAC] -i [DMAC] -1 [type:hnapt(0)/ipv6_rout(5)]-j [Sip] -2 [Dip] -l [Sp] -3 [Dp]\n");
+ printf("hw_nat -a -P [PPE_INDEX] -h [SMAC] -i [DMAC] -1 [type:hnapt(0)/ipv6_rout(5)]-j [Sip] -2 [Dip] -l [Sp] -3 [Dp]\n");
printf(" -n [New_Sip] -o [New_Dip] -p [New_Sp] -q [New_Dp] -4 [Vlan_layer] -5 [dscp]\n");
printf(" -s [VLAN1_ID] -S [VLAN2_ID] -v [Tcp/Udp] -w [OutIf:CPU/GE1/GE2]\n");
- printf("Ex(ipv4): hw_nat -a -h 00:0C:43:28:80:11 -i E0:18:77:BD:D5:18 -1 0 -j 10.10.10.3 -2 10.10.20.3\n");
+ printf("Ex(ipv4): hw_nat -a -P 0 -h 00:0C:43:28:80:11 -i E0:18:77:BD:D5:18 -1 0 -j 10.10.10.3 -2 10.10.20.3\n");
printf("-l 1000 -3 2000 -n 10.10.20.254 -o 10.10.20.3 -p 1000 -q 2000 -4 1 -s 1 -v Tcp -w GE2 -5 32\n\n");
- printf("Ex(ipv6): hw_nat -a -h 00:0C:43:28:02:14 -i 00:1B:21:00:9B:03 -1 5 -6 2001:1111:2222:3333:0000:0000:0000:2\n");
+ printf("Ex(ipv6): hw_nat -a -P 0 -h 00:0C:43:28:02:14 -i 00:1B:21:00:9B:03 -1 5 -6 2001:1111:2222:3333:0000:0000:0000:2\n");
printf("-7 2001:aaa:6401:101:8000:0000:0000:2 -l 3000 -3 2000 -4 0 -v Tcp -w GE1 -5 32\n\n");
printf("Del Static Entry\n");
- printf("hw_nat -b -1 [type:hnapt(0)/ipv6_rout(5)] -j [Sip] -2 [Dip] -l [Sp] -3 [Dp] -v [Tcp/Udp] \n");
- printf("Ex: hw_nat -b -j 10.10.10.3 -k 10.10.20.3 -l 30 -m 40 -v Tcp\n\n");
+ printf("hw_nat -b -P [PPE_INDEX] -1 [type:hnapt(0)/ipv6_rout(5)] -j [Sip] -2 [Dip] -l [Sp] -3 [Dp] -v [Tcp/Udp] \n");
+ printf("Ex: hw_nat -b -P 0 -j 10.10.10.3 -k 10.10.20.3 -l 30 -m 40 -v Tcp\n\n");
#if defined (CONFIG_HW_NAT_SEMI_AUTO_MODE)
printf("Add semi-auto Entry\n");
printf("hw_nat -a -1 [type:hnapt(0)/ipv6_rout(5)]-j [Sip] -2 [Dip] -l [Sp] -m [Dp]\n");
@@ -43,8 +43,8 @@
printf("hw_nat -b -1 5 -j 2001:1111:2222:3333:0000:0000:0000:2 -2 2001:aaa:6401:101:8000:0000:0000:2 -l 3000 -3 2000\n");
#endif
printf("Show Foe Entry\n");
- printf("hw_nat -c [entry_num]\n");
- printf("Ex: hw_nat -c 1234\n\n");
+ printf("hw_nat -c [entry_num] -P [ppe_index]\n");
+ printf("Ex: hw_nat -c 1234 -P 0\n\n");
printf("Set Debug Level (0:disable) \n");
printf("hw_nat -d [0~7]\n");
@@ -59,13 +59,17 @@
printf("Show All Foe Binded Entry\n");
printf("Ex: hw_nat -g\n\n");
+ printf("Invalid Foe Entry\n");
+ printf("hw_nat -I [entry_num] -P [ppe_index]\n");
+ printf("Ex: hw_nat -I 1234 -P 0\n\n");
+
printf("Unbind Foe Entry\n");
- printf("hw_nat -x [entry_num]\n");
- printf("Ex: hw_nat -x 1234\n\n");
+ printf("hw_nat -x [entry_num] -P [ppe_index]\n");
+ printf("Ex: hw_nat -x 1234 -P 0\n\n");
printf("Set Foe Entry to PacketDrop\n");
- printf("hw_nat -k [entry_num]\n");
- printf("Ex: hw_nat -k 1234\n\n");
+ printf("hw_nat -k [entry_num] -P [ppe_index]\n");
+ printf("Ex: hw_nat -k 1234 -P 0\n\n");
#if defined (CONFIG_PPE_MCAST)
@@ -87,17 +91,17 @@
printf("Set HNAT TCP/UDP keepalive interval (d=1, 1)(unit:4sec)\n");
printf("Ex: hw_nat -Q [1~255][1~255]\n\n");
- printf("Disable Hook API (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT)\n");
- printf("Ex: hw_nat -O <hook_id>, hwnat -O [0/1/2/3/4]\n\n");
+ printf("Disable Hook API (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT, 5=SNPS)\n");
+ printf("Ex: hw_nat -O <hook_id>, hwnat -O [0/1/2/3/4/5]\n\n");
- printf("Restore Hook API (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT)\n");
- printf("Ex: hw_nat -T <hook_id>, hwnat -T [0/1/2/3/4]\n\n");
+ printf("Restore Hook API (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT, 5=SNPS)\n");
+ printf("Ex: hw_nat -T <hook_id>, hwnat -T [0/1/2/3/4/5]\n\n");
- printf("Disable Hook API on specific direction (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT) (dir: 1:rx, 2:tx)\n");
- printf("Ex: hw_nat -O <hook_id> -P <dir_id>, hwnat -O [0/1/2/3/4] -P[1/2]\n\n");
+ printf("Disable Hook API on specific direction (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT, 5=SNPS) (dir: 1:rx, 2:tx)\n");
+ printf("Ex: hw_nat -O <hook_id> -P <dir_id>, hwnat -O [0/1/2/3/4/5] -P[1/2]\n\n");
- printf("Restore Hook API on specific direction (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT) (dir: 1:rx, 2:tx)\n");
- printf("Ex: hw_nat -T <hook_id> -P <dir_id>, hwnat -T [0/1/2/3/4] -P[1/2]\n\n");
+ printf("Restore Hook API on specific direction (hook_id: 0=ETH, 1=MD, 2=WIFI, 3=RNDIS, 4=EXT, 5=SNPS) (dir: 1:rx, 2:tx)\n");
+ printf("Ex: hw_nat -T <hook_id> -P <dir_id>, hwnat -T [0/1/2/3/4/5] -P[1/2]\n\n");
printf("Set HNAT Life time of Binded TCP/UDP/FIN entry(d=5, 5, 5)(unit:1Sec) \n");
printf("Ex: hw_nat -U [1~65535][1~65535][1~65535]\n\n");
@@ -170,7 +174,7 @@
unsigned int entry_num;
unsigned int debug;
unsigned int type;
- struct hwnat_args *args;
+ struct hwnat_args *args = {0};
struct hwnat_tuple args2 = {0};
struct hwnat_ac_args args3;
struct hwnat_config_args args4;
@@ -288,7 +292,7 @@
break;
#if defined CONFIG_COLGIN_SUPPORT
case 'P':
- args2.etype = strtoll(optarg, NULL, 16);
+ args2.set_idx = strtoll(optarg, NULL, 16);
break;
#endif
case 't':
@@ -325,10 +329,12 @@
args2.dst_port=1;
}else if(strcasecmp(optarg,"GE2")==0){
args2.dst_port=2;
- }else if(strcasecmp(optarg,"P9")==0){
- args2.dst_port=9;
+ }else if(strcasecmp(optarg,"P7")==0){
+ args2.dst_port=7;
}else if(strcasecmp(optarg,"P8")==0){
args2.dst_port=8;
+ }else if(strcasecmp(optarg,"P9")==0){
+ args2.dst_port=9;
}else if(strcasecmp(optarg,"p10")==0){
args2.dst_port=10;
}else if(strcasecmp(optarg,"p11")==0){
@@ -336,7 +342,7 @@
}else if(strcasecmp(optarg,"p12")==0){
args2.dst_port=12;
}else {
- printf("Error: -w CPU/GE1/GE2\n");
+ printf("Error: -w CPU/GE1/GE2/P7/P8/P9/P10/P11/P12\n");
free(args);
close(fd);
return 0;
@@ -717,13 +723,13 @@
result = HwNatCacheDumpEntry();
break;
case HW_NAT_DUMP_ENTRY:
- result = HwNatDumpEntry(entry_num);
+ result = HwNatDumpEntry(entry_num, args2.set_idx);
break;
case HW_NAT_UNBIND_ENTRY:
- result = HwNatUnBindEntry(entry_num);
+ result = HwNatUnBindEntry(entry_num, args2.set_idx);
break;
case HW_NAT_DROP_ENTRY:
- result = HwNatDropEntry(entry_num);
+ result = HwNatDropEntry(entry_num, args2.set_idx);
break;
case HW_NAT_DEBUG:
result = HwNatDebug(debug);
@@ -820,7 +826,7 @@
result = HwNatDumpDport();
break;
case HW_NAT_INVALID_ENTRY:
- result = HwNatInvalEntry(entry_num);
+ result = HwNatInvalEntry(entry_num, args2.set_idx);
break;
case HW_NAT_CLEAR_HOOK:
result = HwNatHookModify(&args2, 1);