Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.14 hnat #36

Merged
merged 4 commits into from
Jul 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arch/arm/configs/mt7623n_evb_fwu_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m
CONFIG_IP_VS=m
CONFIG_NETFILTER_XT_MATCH_IPVS=m

CONFIG_NET_MEDIATEK_HNAT=m
CONFIG_DEBUG_SECTION_MISMATCH=y

#active ftp-support
CONFIG_NF_CONNTRACK_FTP=m
CONFIG_NF_NAT_FTP=m
Expand Down Expand Up @@ -507,7 +510,6 @@ CONFIG_WLAN_VENDOR_QUANTENNA=n
# CONFIG_NET_VENDOR_CHELSIO is not set
# CONFIG_NET_VENDOR_CIRRUS is not set
# CONFIG_NET_VENDOR_CISCO is not set
# CONFIG_NET_MEDIATEK_HNAT is not set
# CONFIG_NET_VENDOR_MELLANOX is not set
# CONFIG_NET_VENDOR_MICREL is not set
# CONFIG_NET_VENDOR_MICROCHIP is not set
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mediatek/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ config NET_MEDIATEK_HNAT
tristate "MediaTek MT7623 hardware NAT support"
depends on NET_MEDIATEK_SOC && NF_CONNTRACK && NF_CONNTRACK_IPV4 && IP_NF_NAT && IP_NF_TARGET_MASQUERADE
---help---
This driver supports the hardwaer NAT in the
This driver supports the hardware NAT in the
MediaTek MT2701/MT7623 chipset family.

endif #NET_VENDOR_MEDIATEK
18 changes: 18 additions & 0 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,11 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
return -ENOMEM;

/* set the forward port */
#if defined(CONFIG_NET_MEDIATEK_HNAT) || defined(CONFIG_NET_MEDIATEK_HNAT_MODULE)
if (HNAT_SKB_CB2(skb)->magic == 0x78681415)
fport |= 0x4 << TX_DMA_FPORT_SHIFT;
else
#endif
fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT;
txd4 |= fport;

Expand Down Expand Up @@ -1067,6 +1072,10 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
RX_DMA_VID(trxd.rxd3))
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
RX_DMA_VID(trxd.rxd3));
#if defined(CONFIG_NET_MEDIATEK_HNAT) || defined(CONFIG_NET_MEDIATEK_HNAT_MODULE)
*(u32 *)(skb->head) = trxd.rxd4;
skb_hnat_alg(skb) = 0;
#endif
skb_record_rx_queue(skb, 0);
napi_gro_receive(napi, skb);

Expand Down Expand Up @@ -2004,6 +2013,12 @@ static int mtk_hw_init(struct mtk_eth *eth)
val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL);

/* Indicates CDM to parse the MTK special tag from CPU
* which also is working out for untag packets.
*/
val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);

/* Enable RX VLan Offloading */
if (MTK_HW_FEATURES & NETIF_F_HW_VLAN_CTAG_RX)
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
Expand Down Expand Up @@ -2037,6 +2052,9 @@ static int mtk_hw_init(struct mtk_eth *eth)
/* Enable RX checksum */
val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;

/* Enable special tag */
val |= BIT(24);

/* setup the mac dma */
mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mediatek/mtk_hnat/hnat.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ enum FoeEntryState {
extern struct hnat_priv *host;

extern void hnat_deinit_debugfs(struct hnat_priv *h);
extern int __init hnat_init_debugfs(struct hnat_priv *h);
extern int hnat_init_debugfs(struct hnat_priv *h);
//extern int hnat_register_nf_hooks(void);
//extern void hnat_unregister_nf_hooks(void);
extern int hnat_register_nf_hooks(struct net *net);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static const struct debugfs_reg32 hnat_regs[] = {
dump_register(CAH_RDATA),
};

int __init hnat_init_debugfs(struct hnat_priv *h)
int hnat_init_debugfs(struct hnat_priv *h)
{
int ret = 0;
struct dentry *root;
Expand Down
1 change: 1 addition & 0 deletions net/netfilter/nf_conntrack_proto_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <net/ip6_checksum.h>
#include <asm/unaligned.h>

#include <net/ip.h>
#include <net/tcp.h>

#include <linux/netfilter.h>
Expand Down