Skip to content

Commit

Permalink
mt7615: add hwnat support in 4.4.2.1 driver
Browse files Browse the repository at this point in the history
Need more testing.
  • Loading branch information
hanwckf committed Sep 30, 2019
1 parent 884726d commit 45bcc5c
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 14 deletions.
37 changes: 35 additions & 2 deletions trunk/configs/boards/DIR-882/kernel-3.4.x.config
Original file line number Diff line number Diff line change
Expand Up @@ -2029,8 +2029,41 @@ CONFIG_MT_MAC=y
#
# Ralink NAT Acceleration Mode
#
CONFIG_RA_NAT_NONE=y
# CONFIG_RA_NAT_HW is not set
# CONFIG_RA_NAT_NONE is not set
CONFIG_RA_NAT_HW=y
CONFIG_RA_HW_NAT=m
CONFIG_HNAT_V2=y
CONFIG_RA_HW_NAT_LAN_VLANID=1
CONFIG_RA_HW_NAT_WAN_VLANID=2
CONFIG_RA_HW_NAT_BINDING_THRESHOLD=30
CONFIG_RA_HW_NAT_QURT_LMT=16383
CONFIG_RA_HW_NAT_HALF_LMT=16383
CONFIG_RA_HW_NAT_FULL_LMT=16383
# CONFIG_RA_HW_NAT_TBL_1K is not set
# CONFIG_RA_HW_NAT_TBL_2K is not set
# CONFIG_RA_HW_NAT_TBL_4K is not set
# CONFIG_RA_HW_NAT_TBL_8K is not set
CONFIG_RA_HW_NAT_TBL_16K=y
# CONFIG_RA_HW_NAT_HASH0 is not set
CONFIG_RA_HW_NAT_HASH1=y
# CONFIG_RA_HW_NAT_HASH2 is not set
# CONFIG_RA_HW_NAT_HASH3 is not set
CONFIG_RA_HW_NAT_TCP_KA=1
CONFIG_RA_HW_NAT_UDP_KA=1
CONFIG_RA_HW_NAT_NTU_KA=1
CONFIG_RA_HW_NAT_UNB_DLTA=3
CONFIG_RA_HW_NAT_UNB_MNP=1000
CONFIG_RA_HW_NAT_UDP_DLTA=5
CONFIG_RA_HW_NAT_TCP_DLTA=5
CONFIG_RA_HW_NAT_FIN_DLTA=5
CONFIG_RA_HW_NAT_NTU_DLTA=5
# CONFIG_RA_HW_NAT_PREBIND is not set
# CONFIG_RA_HW_NAT_IPV6 is not set
# CONFIG_RA_HW_NAT_QDMA is not set
# CONFIG_RA_HW_NAT_MCAST is not set
# CONFIG_RA_HW_NAT_PCI is not set
CONFIG_RA_HW_NAT_WIFI=y
# CONFIG_RA_HW_NAT_DEBUG is not set

#
# Ralink HW Crypto
Expand Down
37 changes: 35 additions & 2 deletions trunk/configs/boards/JCG-AC860M/kernel-3.4.x.config
Original file line number Diff line number Diff line change
Expand Up @@ -2029,8 +2029,41 @@ CONFIG_MT_MAC=y
#
# Ralink NAT Acceleration Mode
#
CONFIG_RA_NAT_NONE=y
# CONFIG_RA_NAT_HW is not set
# CONFIG_RA_NAT_NONE is not set
CONFIG_RA_NAT_HW=y
CONFIG_RA_HW_NAT=m
CONFIG_HNAT_V2=y
CONFIG_RA_HW_NAT_LAN_VLANID=1
CONFIG_RA_HW_NAT_WAN_VLANID=2
CONFIG_RA_HW_NAT_BINDING_THRESHOLD=30
CONFIG_RA_HW_NAT_QURT_LMT=16383
CONFIG_RA_HW_NAT_HALF_LMT=16383
CONFIG_RA_HW_NAT_FULL_LMT=16383
# CONFIG_RA_HW_NAT_TBL_1K is not set
# CONFIG_RA_HW_NAT_TBL_2K is not set
# CONFIG_RA_HW_NAT_TBL_4K is not set
# CONFIG_RA_HW_NAT_TBL_8K is not set
CONFIG_RA_HW_NAT_TBL_16K=y
# CONFIG_RA_HW_NAT_HASH0 is not set
CONFIG_RA_HW_NAT_HASH1=y
# CONFIG_RA_HW_NAT_HASH2 is not set
# CONFIG_RA_HW_NAT_HASH3 is not set
CONFIG_RA_HW_NAT_TCP_KA=1
CONFIG_RA_HW_NAT_UDP_KA=1
CONFIG_RA_HW_NAT_NTU_KA=1
CONFIG_RA_HW_NAT_UNB_DLTA=3
CONFIG_RA_HW_NAT_UNB_MNP=1000
CONFIG_RA_HW_NAT_UDP_DLTA=5
CONFIG_RA_HW_NAT_TCP_DLTA=5
CONFIG_RA_HW_NAT_FIN_DLTA=5
CONFIG_RA_HW_NAT_NTU_DLTA=5
# CONFIG_RA_HW_NAT_PREBIND is not set
# CONFIG_RA_HW_NAT_IPV6 is not set
# CONFIG_RA_HW_NAT_QDMA is not set
# CONFIG_RA_HW_NAT_MCAST is not set
# CONFIG_RA_HW_NAT_PCI is not set
CONFIG_RA_HW_NAT_WIFI=y
# CONFIG_RA_HW_NAT_DEBUG is not set

#
# Ralink HW Crypto
Expand Down
37 changes: 35 additions & 2 deletions trunk/configs/boards/K2P/kernel-3.4.x.config
Original file line number Diff line number Diff line change
Expand Up @@ -1648,8 +1648,41 @@ CONFIG_MT_MAC=y
#
# Ralink NAT Acceleration Mode
#
CONFIG_RA_NAT_NONE=y
# CONFIG_RA_NAT_HW is not set
# CONFIG_RA_NAT_NONE is not set
CONFIG_RA_NAT_HW=y
CONFIG_RA_HW_NAT=m
CONFIG_HNAT_V2=y
CONFIG_RA_HW_NAT_LAN_VLANID=1
CONFIG_RA_HW_NAT_WAN_VLANID=2
CONFIG_RA_HW_NAT_BINDING_THRESHOLD=30
CONFIG_RA_HW_NAT_QURT_LMT=16383
CONFIG_RA_HW_NAT_HALF_LMT=16383
CONFIG_RA_HW_NAT_FULL_LMT=16383
# CONFIG_RA_HW_NAT_TBL_1K is not set
# CONFIG_RA_HW_NAT_TBL_2K is not set
# CONFIG_RA_HW_NAT_TBL_4K is not set
# CONFIG_RA_HW_NAT_TBL_8K is not set
CONFIG_RA_HW_NAT_TBL_16K=y
# CONFIG_RA_HW_NAT_HASH0 is not set
CONFIG_RA_HW_NAT_HASH1=y
# CONFIG_RA_HW_NAT_HASH2 is not set
# CONFIG_RA_HW_NAT_HASH3 is not set
CONFIG_RA_HW_NAT_TCP_KA=1
CONFIG_RA_HW_NAT_UDP_KA=1
CONFIG_RA_HW_NAT_NTU_KA=1
CONFIG_RA_HW_NAT_UNB_DLTA=3
CONFIG_RA_HW_NAT_UNB_MNP=1000
CONFIG_RA_HW_NAT_UDP_DLTA=5
CONFIG_RA_HW_NAT_TCP_DLTA=5
CONFIG_RA_HW_NAT_FIN_DLTA=5
CONFIG_RA_HW_NAT_NTU_DLTA=5
# CONFIG_RA_HW_NAT_PREBIND is not set
# CONFIG_RA_HW_NAT_IPV6 is not set
# CONFIG_RA_HW_NAT_QDMA is not set
# CONFIG_RA_HW_NAT_MCAST is not set
# CONFIG_RA_HW_NAT_PCI is not set
CONFIG_RA_HW_NAT_WIFI=y
# CONFIG_RA_HW_NAT_DEBUG is not set

#
# Ralink HW Crypto
Expand Down
22 changes: 22 additions & 0 deletions trunk/proprietary/rt_ppe/hw_nat/ra_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,28 @@ void PpeSetDstPort(uint32_t Ebl)
#if defined (HWNAT_USE_IF_MESH)
DstPort[DP_MESHI0] = ra_dev_get_by_name("meshi0");
#endif
#endif

#if defined (HWNAT_USE_IF_DBDC)
DstPort[DP_RAX0] = ra_dev_get_by_name("rax0");
#if defined (HWNAT_USE_IF_MBSS)
DstPort[DP_RAX1] = ra_dev_get_by_name("rax1");
DstPort[DP_RAX2] = ra_dev_get_by_name("rax2");
DstPort[DP_RAX3] = ra_dev_get_by_name("rax3");
DstPort[DP_RAX4] = ra_dev_get_by_name("rax4");
DstPort[DP_RAX5] = ra_dev_get_by_name("rax5");
DstPort[DP_RAX6] = ra_dev_get_by_name("rax6");
DstPort[DP_RAX7] = ra_dev_get_by_name("rax7");
#endif
#if defined (HWNAT_USE_IF_WDS)
DstPort[DP_WDSX0] = ra_dev_get_by_name("wdsx0");
DstPort[DP_WDSX1] = ra_dev_get_by_name("wdsx1");
DstPort[DP_WDSX2] = ra_dev_get_by_name("wdsx2");
DstPort[DP_WDSX3] = ra_dev_get_by_name("wdsx3");
#endif
#if defined (HWNAT_USE_IF_APCLI)
DstPort[DP_APCLIX0] = ra_dev_get_by_name("apclix0");
#endif
#endif

DstPort[DP_GMAC1] = ra_dev_get_by_name("eth2");
Expand Down
24 changes: 24 additions & 0 deletions trunk/proprietary/rt_ppe/hw_nat/ra_nat.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ enum DstPort {
DP_APCLII0 = 53,
DP_MESHI0 = 54,
MAX_WIFI_IF_NUM = 55,
#elif defined (HWNAT_USE_IF_DBDC)
DP_RAX0 = 33,
DP_RAX1 = 34,
DP_RAX2 = 35,
DP_RAX3 = 36,
DP_RAX4 = 37,
DP_RAX5 = 38,
DP_RAX6 = 39,
DP_RAX7 = 40,
DP_RAX8 = 41,
DP_RAX9 = 42,
DP_RAX10 = 43,
DP_RAX11 = 44,
DP_RAX12 = 45,
DP_RAX13 = 46,
DP_RAX14 = 47,
DP_RAX15 = 48,
DP_WDSX0 = 49,
DP_WDSX1 = 50,
DP_WDSX2 = 51,
DP_WDSX3 = 52,
DP_APCLIX0 = 53,
DP_MESHX0 = 54,
MAX_WIFI_IF_NUM = 55,
#else
MAX_WIFI_IF_NUM = 33,
#endif
Expand Down
30 changes: 26 additions & 4 deletions trunk/proprietary/rt_ppe/hw_nat/ra_nat_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,57 @@
#if defined (CONFIG_RT3090_AP_MBSS) || defined (CONFIG_RT5392_AP_MBSS) || \
defined (CONFIG_RT5592_AP_MBSS) || defined (CONFIG_RT3593_AP_MBSS) || \
defined (CONFIG_MT7610_AP_MBSS) || defined (CONFIG_MT76X2_AP_MBSS) || \
defined (CONFIG_MT76X3_AP_MBSS) || defined (CONFIG_MT7615_AP_MBSS) || \
defined (CONFIG_MT76X3_AP_MBSS) || \
defined (CONFIG_RT2860V2_AP_MBSS)
#define HWNAT_USE_IF_MBSS
#endif

#if defined (CONFIG_RT3090_AP_WDS) || defined (CONFIG_RT5392_AP_WDS) || \
defined (CONFIG_RT5592_AP_WDS) || defined (CONFIG_RT3593_AP_WDS) || \
defined (CONFIG_MT7610_AP_WDS) || defined (CONFIG_MT76X2_AP_WDS) || \
defined (CONFIG_MT76X3_AP_WDS) || defined (CONFIG_MT7615_AP_WDS) || \
defined (CONFIG_MT76X3_AP_WDS) || \
defined (CONFIG_RT2860V2_AP_WDS)
#define HWNAT_USE_IF_WDS
#endif

#if defined (CONFIG_RT3090_AP_APCLI) || defined (CONFIG_RT5392_AP_APCLI) || \
defined (CONFIG_RT5592_AP_APCLI) || defined (CONFIG_RT3593_AP_APCLI) || \
defined (CONFIG_MT7610_AP_APCLI) || defined (CONFIG_MT76X2_AP_APCLI) || \
defined (CONFIG_MT76X3_AP_APCLI) || defined (CONFIG_MT7615_AP_APCLI) || \
defined (CONFIG_MT76X3_AP_APCLI) || \
defined (CONFIG_RT2860V2_AP_APCLI)
#define HWNAT_USE_IF_APCLI
#endif

#if defined (CONFIG_RT3090_AP_MESH) || defined (CONFIG_RT5392_AP_MESH) || \
defined (CONFIG_RT5592_AP_MESH) || defined (CONFIG_RT3593_AP_MESH) || \
defined (CONFIG_MT7610_AP_MESH) || defined (CONFIG_MT76X2_AP_MESH) || \
defined (CONFIG_MT76X3_AP_MESH) || defined (CONFIG_MT7615_AP_MESH) || \
defined (CONFIG_MT76X3_AP_MESH) || \
defined (CONFIG_RT2860V2_AP_MESH)
#define HWNAT_USE_IF_MESH
#endif

#if defined (CONFIG_CHIP_MT7615E)

#if defined (CONFIG_MBSS_SUPPORT)
#define HWNAT_USE_IF_MBSS
#endif

#if defined (CONFIG_WDS_SUPPORT)
#define HWNAT_USE_IF_WDS
#endif

#if defined (CONFIG_APCLI_SUPPORT)
#define HWNAT_USE_IF_APCLI
#endif

#if defined (CONFIG_DBDC_MODE)
#if defined (CONFIG_RT_SECOND_IF_NONE)
#define HWNAT_USE_IF_DBDC
#endif
#endif

#endif

/* old drivers send skb via ra0/rai0 and use skb->cb[CB_OFF+6] for store type */
#if defined (CONFIG_RT_FIRST_IF_RT3090) || defined (CONFIG_RT_FIRST_IF_RT5392) || \
defined (CONFIG_RT_FIRST_IF_RT5592) || defined (CONFIG_RT_FIRST_IF_RT3593) || \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ INT wdev_tx_pkts(NDIS_HANDLE dev_hnd, PPNDIS_PACKET pkt_list, UINT pkt_cnt, stru
unsigned long flags;

RTMP_IRQ_LOCK(&pAd->page_lock, flags);
ra_sw_nat_hook_tx(pPacket);
ra_sw_nat_hook_tx(pPacket, 0);
RTMP_IRQ_UNLOCK(&pAd->page_lock, flags);
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ do { \

#ifdef CONFIG_RAETH
#if !defined(CONFIG_RA_NAT_NONE)
extern int (*ra_sw_nat_hook_tx)(VOID *skb);
extern int (*ra_sw_nat_hook_tx)(VOID *skb, int gmac_no);
extern int (*ra_sw_nat_hook_rx)(VOID *skb);
#if defined (CONFIG_RA_HW_NAT_WIFI_NEW_ARCH)
extern void (*ppe_dev_register_hook) (VOID *dev);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,7 @@ VOID RtmpOsPktNatMagicTag(IN PNDIS_PACKET pNetPkt)
#if !defined(CONFIG_RA_NAT_NONE)
#if defined (CONFIG_RA_HW_NAT) || defined (CONFIG_RA_HW_NAT_MODULE)
struct sk_buff *pRxPkt = RTPKT_TO_OSPKT(pNetPkt);
FOE_MAGIC_TAG(pRxPkt) = FOE_MAGIC_WLAN;
FOE_MAGIC_TAG(pRxPkt) = FOE_MAGIC_EXTIF;
#endif /* CONFIG_RA_HW_NAT || CONFIG_RA_HW_NAT_MODULE */
#endif /* CONFIG_RA_NAT_NONE */
}
Expand Down
6 changes: 5 additions & 1 deletion trunk/user/shared/defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,13 @@ struct nvram_pair router_defaults[] = {
#endif

#if defined(CONFIG_RALINK_MT7621) || (defined(CONFIG_RALINK_MT7620) && !defined(BOARD_N14U))
{ "hw_nat_mode", "4" },
#if defined(USE_MT7615_AP) // hwnat is disabled by default
{ "hw_nat_mode", "2" },
#else
{ "hw_nat_mode", "4" },
#endif
#else
{ "hw_nat_mode", "1" },
#endif
{ "sw_nat_mode", "0" },
{ "sfe_enable", "0" },
Expand Down

0 comments on commit 45bcc5c

Please sign in to comment.