1 Index: linux-4.9.29/drivers/net/ethernet/mediatek/mtk_eth_soc.c
2 ===================================================================
3 --- linux-4.9.29.orig/drivers/net/ethernet/mediatek/mtk_eth_soc.c
4 +++ linux-4.9.29/drivers/net/ethernet/mediatek/mtk_eth_soc.c
6 #include <linux/reset.h>
9 +#if defined(CONFIG_NET_MEDIATEK_HNAT) || defined(CONFIG_NET_MEDIATEK_HNAT_MODULE)
10 +#include "mtk_hnat/nf_hnat_mtk.h"
13 #include "mtk_eth_soc.h"
15 static int mtk_msg_level = -1;
16 @@ -649,6 +653,11 @@ static int mtk_tx_map(struct sk_buff *sk
19 /* set the forward port */
20 +#if defined(CONFIG_NET_MEDIATEK_HNAT) || defined(CONFIG_NET_MEDIATEK_HNAT_MODULE)
21 + if (HNAT_SKB_CB2(skb)->magic == 0x78681415)
22 + fport |= 0x4 << TX_DMA_FPORT_SHIFT;
25 fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT;
28 @@ -945,9 +954,8 @@ static int mtk_poll_rx(struct napi_struc
31 /* find out which mac the packet come from. values start at 1 */
32 - mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) &
35 + mac = (trxd.rxd4 >> 22) & 0x1;
36 + mac = (mac + 1) % 2;
38 netdev = eth->netdev[mac];
40 @@ -971,6 +979,9 @@ static int mtk_poll_rx(struct napi_struc
44 + if (mac < 0 || mac > 2)
47 skb = build_skb(data, ring->frag_size);
49 skb_free_frag(new_data);
50 @@ -994,9 +1005,14 @@ static int mtk_poll_rx(struct napi_struc
51 RX_DMA_VID(trxd.rxd3))
52 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
53 RX_DMA_VID(trxd.rxd3));
54 +#if defined(CONFIG_NET_MEDIATEK_HNAT) || defined(CONFIG_NET_MEDIATEK_HNAT_MODULE)
55 + *(u32 *)(skb->head) = trxd.rxd4;
56 + skb_hnat_alg(skb) = 0;
58 skb_record_rx_queue(skb, 0);
59 napi_gro_receive(napi, skb);
62 ring->data[idx] = new_data;
63 rxd->rxd1 = (unsigned int)dma_addr;
65 @@ -1883,18 +1899,14 @@ static int mtk_hw_init(struct mtk_eth *e
66 val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
67 mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
69 - /* Indicates CDM to parse the MTK special tag from CPU
70 - * which also is working out for untag packets.
72 - val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
73 - mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
75 /* Enable RX VLan Offloading */
76 if (MTK_HW_FEATURES & NETIF_F_HW_VLAN_CTAG_RX)
77 mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
79 mtk_w32(eth, 0, MTK_CDMP_EG_CTRL);
81 + mtk_w32(eth, 0x81000001, MTK_CDMP_IG_CTRL);
83 /* disable delay and normal interrupt */
85 mtk_w32(eth, 0x84048404, MTK_PDMA_DELAY_INT);
86 @@ -1924,6 +1936,9 @@ static int mtk_hw_init(struct mtk_eth *e
87 /* Enable RX checksum */
88 val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
93 /* setup the mac dma */
94 mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
96 Index: linux-4.9.29/drivers/net/ethernet/mediatek/mtk_eth_soc.h
97 ===================================================================
98 --- linux-4.9.29.orig/drivers/net/ethernet/mediatek/mtk_eth_soc.h
99 +++ linux-4.9.29/drivers/net/ethernet/mediatek/mtk_eth_soc.h
101 #define MTK_CDMQ_IG_CTRL 0x1400
102 #define MTK_CDMQ_STAG_EN BIT(0)
104 +/* CDMP Ingress Control Register */
105 +#define MTK_CDMP_IG_CTRL 0x400
107 /* CDMP Exgress Control Register */
108 #define MTK_CDMP_EG_CTRL 0x404
111 #define MTK_GDMA_TCS_EN BIT(21)
112 #define MTK_GDMA_UCS_EN BIT(20)
114 +/* GDMA Ingress Control Register */
115 +#define MTK_GDMA1_IG_CTRL(x) (0x500 + (x * 0x1000))
117 /* Unicast Filter MAC Address Register - Low */
118 #define MTK_GDMA_MAC_ADRL(x) (0x508 + (x * 0x1000))
120 Index: linux-4.9.29/net/netfilter/nf_conntrack_proto_tcp.c
121 ===================================================================
122 --- linux-4.9.29.orig/net/netfilter/nf_conntrack_proto_tcp.c
123 +++ linux-4.9.29/net/netfilter/nf_conntrack_proto_tcp.c
125 #include <linux/types.h>
126 #include <linux/timer.h>
127 #include <linux/module.h>
128 +#include <linux/inetdevice.h>
129 #include <linux/in.h>
130 #include <linux/tcp.h>
131 #include <linux/spinlock.h>
133 #include <net/ip6_checksum.h>
134 #include <asm/unaligned.h>
139 #include <linux/netfilter.h>
140 @@ -53,6 +55,11 @@ static int nf_ct_tcp_max_retrans __read_
141 /* FIXME: Examine ipfilter's timeouts and conntrack transitions more
142 closely. They're more complex. --RR */
144 +#ifndef IPV4_DEVCONF_DFLT
145 + #define IPV4_DEVCONF_DFLT(net, attr) \
146 + IPV4_DEVCONF((*net->ipv4.devconf_dflt), attr)
149 static const char *const tcp_conntrack_names[] = {
152 @@ -519,6 +526,18 @@ static bool tcp_in_window(const struct n
153 if (nf_ct_tcp_no_window_check)
157 + if ((net->ipv4.devconf_all && net->ipv4.devconf_dflt && net->ipv6.devconf_all) &&
158 + net->ipv6.devconf_dflt) {
159 + if ((IPV4_DEVCONF_DFLT(net, FORWARDING) ||
160 + IPV4_DEVCONF_ALL(net, FORWARDING)) ||
161 + (net->ipv6.devconf_all->forwarding ||
162 + net->ipv6.devconf_dflt->forwarding)) {
169 * Get the required data from the packet.