developer | 1a2d776 | 2023-09-21 22:15:12 +0800 | [diff] [blame] | 1 | --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
| 2 | +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
| 3 | @@ -245,6 +245,9 @@ static const char * const mtk_clks_source_name[] = {
|
| 4 | "top_netsys_warp_sel",
|
| 5 | };
|
| 6 |
|
| 7 | +struct net_device *(*mtk_get_tnl_dev)(int tnl_idx) = NULL;
|
| 8 | +EXPORT_SYMBOL(mtk_get_tnl_dev);
|
| 9 | +
|
| 10 | void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
|
| 11 | {
|
| 12 | __raw_writel(val, eth->base + reg);
|
| 13 | @@ -2186,6 +2189,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
|
| 14 | u64 addr64 = 0;
|
| 15 | u8 *data, *new_data;
|
| 16 | struct mtk_rx_dma_v2 *rxd, trxd;
|
| 17 | + int tnl_idx = 0;
|
| 18 | int done = 0;
|
| 19 |
|
| 20 | if (unlikely(!ring))
|
| 21 | @@ -2229,11 +2233,20 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
|
| 22 | 0 : RX_DMA_GET_SPORT(trxd.rxd4) - 1;
|
| 23 | }
|
| 24 |
|
| 25 | - if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
|
| 26 | - !eth->netdev[mac]))
|
| 27 | - goto release_desc;
|
| 28 | + tnl_idx = RX_DMA_GET_TOPS_CRSN(trxd.rxd6);
|
| 29 | + if (mtk_get_tnl_dev && tnl_idx) {
|
| 30 | + netdev = mtk_get_tnl_dev(tnl_idx);
|
| 31 | + if (unlikely(IS_ERR(netdev)))
|
| 32 | + netdev = NULL;
|
| 33 | + }
|
| 34 |
|
| 35 | - netdev = eth->netdev[mac];
|
| 36 | + if (!netdev) {
|
| 37 | + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
|
| 38 | + !eth->netdev[mac]))
|
| 39 | + goto release_desc;
|
| 40 | +
|
| 41 | + netdev = eth->netdev[mac];
|
| 42 | + }
|
| 43 |
|
| 44 | if (unlikely(test_bit(MTK_RESETTING, ð->state)))
|
| 45 | goto release_desc;
|
| 46 | @@ -2318,6 +2331,8 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
|
| 47 | skb_hnat_alg(skb) = 0;
|
| 48 | skb_hnat_filled(skb) = 0;
|
| 49 | skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
|
| 50 | + skb_hnat_set_tops(skb, 0);
|
| 51 | + skb_hnat_set_is_decap(skb, 0);
|
| 52 |
|
| 53 | if (skb_hnat_reason(skb) == HIT_BIND_FORCE_TO_CPU) {
|
| 54 | trace_printk("[%s] reason=0x%x(force to CPU) from WAN to Ext\n",
|
| 55 | --- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
|
| 56 | +++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
|
| 57 | @@ -43,6 +43,12 @@ void (*ppe_dev_register_hook)(struct net_device *dev) = NULL;
|
| 58 | EXPORT_SYMBOL(ppe_dev_register_hook);
|
| 59 | void (*ppe_dev_unregister_hook)(struct net_device *dev) = NULL;
|
| 60 | EXPORT_SYMBOL(ppe_dev_unregister_hook);
|
| 61 | +int (*mtk_tnl_encap_offload)(struct sk_buff *skb) = NULL;
|
| 62 | +EXPORT_SYMBOL(mtk_tnl_encap_offload);
|
| 63 | +int (*mtk_tnl_decap_offload)(struct sk_buff *skb) = NULL;
|
| 64 | +EXPORT_SYMBOL(mtk_tnl_decap_offload);
|
| 65 | +bool (*mtk_tnl_decap_offloadable)(struct sk_buff *skb) = NULL;
|
| 66 | +EXPORT_SYMBOL(mtk_tnl_decap_offloadable);
|
| 67 |
|
| 68 | static void hnat_sma_build_entry(struct timer_list *t)
|
| 69 | {
|
| 70 | @@ -53,6 +59,16 @@ static void hnat_sma_build_entry(struct timer_list *t)
|
| 71 | SMA, SMA_FWD_CPU_BUILD_ENTRY);
|
| 72 | }
|
| 73 |
|
| 74 | +struct foe_entry *hnat_get_foe_entry(u32 ppe_id, u32 index)
|
| 75 | +{
|
| 76 | + if (index == 0x7fff || index >= hnat_priv->foe_etry_num
|
| 77 | + || ppe_id >= CFG_PPE_NUM)
|
| 78 | + return ERR_PTR(-EINVAL);
|
| 79 | +
|
| 80 | + return &hnat_priv->foe_table_cpu[ppe_id][index];
|
| 81 | +}
|
| 82 | +EXPORT_SYMBOL(hnat_get_foe_entry);
|
| 83 | +
|
| 84 | void hnat_cache_ebl(int enable)
|
| 85 | {
|
| 86 | int i;
|
| 87 | @@ -63,6 +79,7 @@ void hnat_cache_ebl(int enable)
|
| 88 | cr_set_field(hnat_priv->ppe_base[i] + PPE_CAH_CTRL, CAH_EN, enable);
|
| 89 | }
|
| 90 | }
|
| 91 | +EXPORT_SYMBOL(hnat_cache_ebl);
|
| 92 |
|
| 93 | static void hnat_reset_timestamp(struct timer_list *t)
|
| 94 | {
|
| 95 | --- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat.h
|
| 96 | +++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat.h
|
| 97 | @@ -1133,6 +1133,8 @@ enum FoeIpAct {
|
| 98 | #define NR_WDMA1_PORT 9
|
| 99 | #define NR_WDMA2_PORT 13
|
| 100 | #define NR_GMAC3_PORT 15
|
| 101 | +#define NR_TDMA_TPORT 4
|
| 102 | +#define NR_TDMA_QDMA_TPORT 5
|
| 103 | #define LAN_DEV_NAME hnat_priv->lan
|
| 104 | #define LAN2_DEV_NAME hnat_priv->lan2
|
| 105 | #define IS_WAN(dev) \
|
| 106 | @@ -1256,6 +1258,8 @@ static inline bool hnat_dsa_is_enable(struct mtk_hnat *priv)
|
| 107 | }
|
| 108 | #endif
|
| 109 |
|
| 110 | +struct foe_entry *hnat_get_foe_entry(u32 ppe_id, u32 index);
|
| 111 | +
|
| 112 | void hnat_deinit_debugfs(struct mtk_hnat *h);
|
| 113 | int hnat_init_debugfs(struct mtk_hnat *h);
|
| 114 | int hnat_register_nf_hooks(void);
|
| 115 | @@ -1272,6 +1276,9 @@ extern int qos_ul_toggle;
|
| 116 | extern int hook_toggle;
|
| 117 | extern int mape_toggle;
|
| 118 | extern int qos_toggle;
|
| 119 | +extern int (*mtk_tnl_encap_offload)(struct sk_buff *skb);
|
| 120 | +extern int (*mtk_tnl_decap_offload)(struct sk_buff *skb);
|
| 121 | +extern bool (*mtk_tnl_decap_offloadable)(struct sk_buff *skb);
|
| 122 |
|
| 123 | int ext_if_add(struct extdev_entry *ext_entry);
|
| 124 | int ext_if_del(struct extdev_entry *ext_entry);
|
| 125 | --- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
|
| 126 | +++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
|
| 127 | @@ -726,10 +726,14 @@ static unsigned int is_ppe_support_type(struct sk_buff *skb)
|
| 128 | case ETH_P_IP:
|
| 129 | iph = ip_hdr(skb);
|
| 130 |
|
| 131 | - /* do not accelerate non tcp/udp traffic */
|
| 132 | - if ((iph->protocol == IPPROTO_TCP) ||
|
| 133 | + if (mtk_tnl_decap_offloadable && mtk_tnl_decap_offloadable(skb)) {
|
| 134 | + /* tunnel protocol is offloadable */
|
| 135 | + skb_hnat_set_is_decap(skb, 1);
|
| 136 | + return 1;
|
| 137 | + } else if ((iph->protocol == IPPROTO_TCP) ||
|
| 138 | (iph->protocol == IPPROTO_UDP) ||
|
| 139 | (iph->protocol == IPPROTO_IPV6)) {
|
| 140 | + /* do not accelerate non tcp/udp traffic */
|
| 141 | return 1;
|
| 142 | }
|
| 143 |
|
| 144 | @@ -846,6 +850,13 @@ mtk_hnat_ipv4_nf_pre_routing(void *priv, struct sk_buff *skb,
|
| 145 |
|
| 146 | hnat_set_head_frags(state, skb, -1, hnat_set_iif);
|
| 147 |
|
| 148 | + if (skb_hnat_tops(skb) && skb_hnat_is_decap(skb)
|
| 149 | + && is_magic_tag_valid(skb)
|
| 150 | + && skb_hnat_iface(skb) == FOE_MAGIC_GE_VIRTUAL
|
| 151 | + && mtk_tnl_decap_offload && mtk_tnl_decap_offload(skb)) {
|
| 152 | + return NF_ACCEPT;
|
| 153 | + }
|
| 154 | +
|
| 155 | /*
|
| 156 | * Avoid mistakenly binding of outer IP, ports in SW L2TP decap flow.
|
| 157 | * In pre-routing, if dev is virtual iface, TOPS module is not loaded,
|
| 158 | @@ -921,6 +932,13 @@ mtk_hnat_br_nf_local_in(void *priv, struct sk_buff *skb,
|
| 159 |
|
| 160 | hnat_set_head_frags(state, skb, -1, hnat_set_iif);
|
| 161 |
|
| 162 | + if (skb_hnat_tops(skb) && skb_hnat_is_decap(skb)
|
| 163 | + && is_magic_tag_valid(skb)
|
| 164 | + && skb_hnat_iface(skb) == FOE_MAGIC_GE_VIRTUAL
|
| 165 | + && mtk_tnl_decap_offload && mtk_tnl_decap_offload(skb)) {
|
| 166 | + return NF_ACCEPT;
|
| 167 | + }
|
| 168 | +
|
| 169 | pre_routing_print(skb, state->in, state->out, __func__);
|
| 170 |
|
| 171 | if (unlikely(debug_level >= 7)) {
|
| 172 | @@ -1073,9 +1091,22 @@ static unsigned int hnat_ipv4_get_nexthop(struct sk_buff *skb,
|
| 173 | return -1;
|
| 174 | }
|
| 175 |
|
| 176 | + /*
|
| 177 | + * if this packet is a tunnel packet and is about to construct
|
| 178 | + * outer header, we must update its outer mac header pointer
|
| 179 | + * before filling outer mac or it may screw up inner mac
|
| 180 | + */
|
| 181 | + if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb)) {
|
| 182 | + skb_push(skb, sizeof(struct ethhdr));
|
| 183 | + skb_reset_mac_header(skb);
|
| 184 | + }
|
| 185 | +
|
| 186 | memcpy(eth_hdr(skb)->h_dest, neigh->ha, ETH_ALEN);
|
| 187 | memcpy(eth_hdr(skb)->h_source, out->dev_addr, ETH_ALEN);
|
| 188 |
|
| 189 | + if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb))
|
| 190 | + skb_pull(skb, sizeof(struct ethhdr));
|
| 191 | +
|
| 192 | rcu_read_unlock_bh();
|
| 193 |
|
| 194 | return 0;
|
| 195 | @@ -1201,6 +1232,81 @@ static struct ethhdr *get_ipv6_ipip_ethhdr(struct sk_buff *skb,
|
| 196 | return eth;
|
| 197 | }
|
| 198 |
|
| 199 | +static inline void hnat_get_filled_unbind_entry(struct sk_buff *skb,
|
| 200 | + struct foe_entry *entry)
|
| 201 | +{
|
| 202 | + if (unlikely(!skb || !entry))
|
| 203 | + return;
|
| 204 | +
|
| 205 | + memcpy(entry,
|
| 206 | + &hnat_priv->foe_table_cpu[skb_hnat_ppe(skb)][skb_hnat_entry(skb)],
|
| 207 | + sizeof(*entry));
|
| 208 | +
|
| 209 | +#if defined(CONFIG_MEDIATEK_NETSYS_V2) || defined(CONFIG_MEDIATEK_NETSYS_V3)
|
| 210 | + entry->bfib1.mc = 0;
|
| 211 | +#endif /* defined(CONFIG_MEDIATEK_NETSYS_V2) || defined(CONFIG_MEDIATEK_NETSYS_V3) */
|
| 212 | + entry->bfib1.ka = 0;
|
| 213 | + entry->bfib1.vlan_layer = 0;
|
| 214 | + entry->bfib1.psn = 0;
|
| 215 | + entry->bfib1.vpm = 0;
|
| 216 | + entry->bfib1.ps = 0;
|
| 217 | +}
|
| 218 | +
|
| 219 | +static inline void hnat_qos_tnl(u32 id, const struct net_device *dev)
|
| 220 | +{
|
| 221 | + u32 cfg;
|
| 222 | + u32 max_man = 0;
|
| 223 | + u32 max_exp = 0;
|
| 224 | + const struct mtk_mac *mac;
|
| 225 | +
|
| 226 | + if (!dev)
|
| 227 | + return;
|
| 228 | + mac = netdev_priv(dev);
|
| 229 | +
|
| 230 | + switch (mac->speed) {
|
| 231 | + case SPEED_100:
|
| 232 | + case SPEED_1000:
|
| 233 | + case SPEED_2500:
|
| 234 | + case SPEED_5000:
|
| 235 | + case SPEED_10000:
|
| 236 | + max_man = mac->speed / SPEED_100;
|
| 237 | + max_exp = 5;
|
| 238 | + break;
|
| 239 | + default:
|
| 240 | + return;
|
| 241 | + }
|
| 242 | +
|
| 243 | + cfg = QTX_SCH_MIN_RATE_EN | QTX_SCH_MAX_RATE_EN;
|
| 244 | + cfg |= (1 << QTX_SCH_MIN_RATE_MAN_OFFSET) |
|
| 245 | + (4 << QTX_SCH_MIN_RATE_EXP_OFFSET) |
|
| 246 | + (max_man << QTX_SCH_MAX_RATE_MAN_OFFSET) |
|
| 247 | + (max_exp << QTX_SCH_MAX_RATE_EXP_OFFSET) |
|
| 248 | + (4 << QTX_SCH_MAX_RATE_WGHT_OFFSET);
|
| 249 | + writel(cfg, hnat_priv->fe_base + QTX_SCH(id % NUM_OF_Q_PER_PAGE));
|
| 250 | +}
|
| 251 | +
|
| 252 | +static inline void hnat_fill_offload_engine_entry(struct sk_buff *skb,
|
| 253 | + struct foe_entry *entry,
|
| 254 | + const struct net_device *dev)
|
| 255 | +{
|
| 256 | +#if defined(CONFIG_MEDIATEK_NETSYS_V3)
|
| 257 | + if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb)) {
|
| 258 | + /*
|
| 259 | + * if skb_hnat_tops(skb) is setup for encapsulation,
|
| 260 | + * we fill in hnat tport and tops_entry for tunnel encapsulation
|
| 261 | + * offloading
|
| 262 | + */
|
| 263 | + entry->ipv4_hnapt.tport_id = NR_TDMA_QDMA_TPORT;
|
| 264 | + entry->ipv4_hnapt.tops_entry = skb_hnat_tops(skb);
|
| 265 | + } else {
|
| 266 | + return;
|
| 267 | + }
|
| 268 | +
|
| 269 | + entry->ipv4_hnapt.iblk2.qid = 12; /* offload engine use QID 12 */
|
| 270 | + hnat_qos_tnl(12, dev); /* set rate limit to line rate */
|
| 271 | +#endif /* defined(CONFIG_MEDIATEK_NETSYS_V3) */
|
| 272 | +}
|
| 273 | +
|
| 274 | static unsigned int skb_to_hnat_info(struct sk_buff *skb,
|
| 275 | const struct net_device *dev,
|
| 276 | struct foe_entry *foe,
|
| 277 | @@ -1237,6 +1343,11 @@ static unsigned int skb_to_hnat_info(struct sk_buff *skb,
|
| 278 | if (whnat && is_hnat_pre_filled(foe))
|
| 279 | return 0;
|
| 280 |
|
| 281 | + if (skb_hnat_tops(skb) && !(hw_path->flags & FLOW_OFFLOAD_PATH_TNL)) {
|
| 282 | + hnat_get_filled_unbind_entry(skb, &entry);
|
| 283 | + goto hnat_entry_bind;
|
| 284 | + }
|
| 285 | +
|
| 286 | entry.bfib1.pkt_type = foe->udib1.pkt_type; /* Get packte type state*/
|
| 287 | entry.bfib1.state = foe->udib1.state;
|
| 288 |
|
| 289 | @@ -1679,6 +1790,10 @@ static unsigned int skb_to_hnat_info(struct sk_buff *skb,
|
| 290 | /* Fill Layer2 Info.*/
|
| 291 | entry = ppe_fill_L2_info(eth, entry, hw_path);
|
| 292 |
|
| 293 | + if (skb_hnat_tops(skb) && hw_path->flags & FLOW_OFFLOAD_PATH_TNL)
|
| 294 | + goto hnat_entry_skip_bind;
|
| 295 | +
|
| 296 | +hnat_entry_bind:
|
| 297 | /* Fill Info Blk*/
|
| 298 | entry = ppe_fill_info_blk(eth, entry, hw_path);
|
| 299 |
|
| 300 | @@ -1879,7 +1994,20 @@ static unsigned int skb_to_hnat_info(struct sk_buff *skb,
|
| 301 | entry.ipv6_5t_route.act_dp |= UDF_HNAT_PRE_FILLED;
|
| 302 | }
|
| 303 |
|
| 304 | +#if defined(CONFIG_MEDIATEK_NETSYS_V3)
|
| 305 | + hnat_fill_offload_engine_entry(skb, &entry, dev);
|
| 306 | +#endif
|
| 307 | +
|
| 308 | +hnat_entry_skip_bind:
|
| 309 | wmb();
|
| 310 | +
|
| 311 | + /*
|
| 312 | + * final check before we write BIND info.
|
| 313 | + * If this entry is already bound, we should not modify it right now
|
| 314 | + */
|
| 315 | + if (entry_hnat_is_bound(foe))
|
| 316 | + return 0;
|
| 317 | +
|
| 318 | memcpy(foe, &entry, sizeof(entry));
|
| 319 | /*reset statistic for this entry*/
|
| 320 | if (hnat_priv->data->per_flow_accounting &&
|
| 321 | @@ -1951,6 +2079,12 @@ int mtk_sw_nat_hook_tx(struct sk_buff *skb, int gmac_no)
|
| 322 | switch ((int)entry.bfib1.pkt_type) {
|
| 323 | case IPV4_HNAPT:
|
| 324 | case IPV4_HNAT:
|
| 325 | + /*
|
| 326 | + * skip if packet is an encap tnl packet or it may
|
| 327 | + * screw up inner mac header
|
| 328 | + */
|
| 329 | + if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb))
|
| 330 | + break;
|
| 331 | entry.ipv4_hnapt.smac_hi = swab32(*((u32 *)eth->h_source));
|
| 332 | entry.ipv4_hnapt.smac_lo = swab16(*((u16 *)ð->h_source[4]));
|
| 333 | break;
|
| 334 | @@ -2112,6 +2246,10 @@ int mtk_sw_nat_hook_tx(struct sk_buff *skb, int gmac_no)
|
| 335 | entry.ipv6_5t_route.iblk2.dp = gmac_no;
|
| 336 | }
|
| 337 |
|
| 338 | +#if defined(CONFIG_MEDIATEK_NETSYS_V3)
|
| 339 | + hnat_fill_offload_engine_entry(skb, &entry, NULL);
|
| 340 | +#endif
|
| 341 | +
|
| 342 | entry.bfib1.ttl = 1;
|
| 343 | entry.bfib1.state = BIND;
|
| 344 |
|
| 345 | @@ -2187,6 +2325,7 @@ int mtk_sw_nat_hook_rx(struct sk_buff *skb)
|
| 346 | }
|
| 347 |
|
| 348 | skb_hnat_alg(skb) = 0;
|
| 349 | + skb_hnat_set_tops(skb, 0);
|
| 350 | skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
|
| 351 |
|
| 352 | if (skb_hnat_iface(skb) == FOE_MAGIC_WED0)
|
| 353 | @@ -2636,6 +2775,7 @@ static unsigned int mtk_hnat_nf_post_routing(
|
| 354 | struct flow_offload_hw_path hw_path = { .dev = (struct net_device*)out,
|
| 355 | .virt_dev = (struct net_device*)out };
|
| 356 | const struct net_device *arp_dev = out;
|
| 357 | + bool is_virt_dev = false;
|
| 358 |
|
| 359 | if (xlat_toggle && !mtk_464xlat_post_process(skb, out))
|
| 360 | return 0;
|
| 361 | @@ -2652,10 +2792,29 @@ static unsigned int mtk_hnat_nf_post_routing(
|
| 362 |
|
| 363 | if (out->netdev_ops->ndo_flow_offload_check) {
|
| 364 | out->netdev_ops->ndo_flow_offload_check(&hw_path);
|
| 365 | +
|
| 366 | out = (IS_GMAC1_MODE) ? hw_path.virt_dev : hw_path.dev;
|
| 367 | + if (hw_path.flags & FLOW_OFFLOAD_PATH_TNL && mtk_tnl_encap_offload) {
|
| 368 | + if (ntohs(skb->protocol) == ETH_P_IP
|
| 369 | + && ip_hdr(skb)->protocol == IPPROTO_TCP) {
|
| 370 | + skb_hnat_set_tops(skb, hw_path.tnl_type + 1);
|
| 371 | + } else {
|
| 372 | + /*
|
| 373 | + * we are not support protocols other than IPv4 TCP
|
| 374 | + * for tunnel protocol offload yet
|
| 375 | + */
|
| 376 | + skb_hnat_alg(skb) = 1;
|
| 377 | + return 0;
|
| 378 | + }
|
| 379 | + }
|
| 380 | }
|
| 381 |
|
| 382 | if (!IS_LAN_GRP(out) && !IS_WAN(out) && !IS_EXT(out))
|
| 383 | + is_virt_dev = true;
|
| 384 | +
|
| 385 | + if (is_virt_dev
|
| 386 | + && !(skb_hnat_tops(skb) && skb_hnat_is_encap(skb)
|
| 387 | + && (hw_path.flags & FLOW_OFFLOAD_PATH_TNL)))
|
| 388 | return 0;
|
| 389 |
|
| 390 | trace_printk("[%s] case hit, %x-->%s, reason=%x\n", __func__,
|
| 391 | @@ -2675,9 +2834,18 @@ static unsigned int mtk_hnat_nf_post_routing(
|
| 392 | if (fn && !mtk_hnat_accel_type(skb))
|
| 393 | break;
|
| 394 |
|
| 395 | - if (fn && fn(skb, arp_dev, &hw_path))
|
| 396 | + if (!is_virt_dev && fn && fn(skb, arp_dev, &hw_path))
|
| 397 | break;
|
| 398 |
|
| 399 | + /* skb_hnat_tops(skb) is updated in mtk_tnl_offload() */
|
| 400 | + if (skb_hnat_tops(skb)) {
|
| 401 | + if (skb_hnat_is_encap(skb) && !is_virt_dev
|
| 402 | + && mtk_tnl_encap_offload && mtk_tnl_encap_offload(skb))
|
| 403 | + break;
|
| 404 | + if (skb_hnat_is_decap(skb))
|
| 405 | + break;
|
| 406 | + }
|
| 407 | +
|
| 408 | spin_lock(&hnat_priv->entry_lock);
|
| 409 | skb_to_hnat_info(skb, out, entry, &hw_path);
|
| 410 | spin_unlock(&hnat_priv->entry_lock);
|
| 411 | @@ -2951,7 +3119,7 @@ mtk_hnat_ipv4_nf_local_out(void *priv, struct sk_buff *skb,
|
| 412 | if (iph->protocol == IPPROTO_IPV6) {
|
| 413 | entry->udib1.pkt_type = IPV6_6RD;
|
| 414 | hnat_set_head_frags(state, skb, 0, hnat_set_alg);
|
| 415 | - } else {
|
| 416 | + } else if (!skb_hnat_tops(skb)) {
|
| 417 | hnat_set_head_frags(state, skb, 1, hnat_set_alg);
|
| 418 | }
|
| 419 |
|
| 420 | --- a/drivers/net/ethernet/mediatek/mtk_hnat/nf_hnat_mtk.h
|
| 421 | +++ b/drivers/net/ethernet/mediatek/mtk_hnat/nf_hnat_mtk.h
|
| 422 | @@ -44,7 +44,9 @@ struct hnat_desc {
|
| 423 | u32 is_sp : 1;
|
| 424 | u32 hf : 1;
|
| 425 | u32 amsdu : 1;
|
| 426 | - u32 resv3 : 19;
|
| 427 | + u32 tops : 6;
|
| 428 | + u32 is_decap : 1;
|
| 429 | + u32 resv3 : 12;
|
| 430 | u32 magic_tag_protect : 16;
|
| 431 | } __packed;
|
| 432 | #elif defined(CONFIG_MEDIATEK_NETSYS_RX_V2)
|
| 433 | @@ -91,6 +93,19 @@ struct hnat_desc {
|
| 434 | ((((skb_headroom(skb) >= FOE_INFO_LEN) ? 1 : 0)))
|
| 435 |
|
| 436 | #define skb_hnat_info(skb) ((struct hnat_desc *)(skb->head))
|
| 437 | +#if defined(CONFIG_MEDIATEK_NETSYS_V3)
|
| 438 | +#define skb_hnat_tops(skb) (((struct hnat_desc *)((skb)->head))->tops)
|
| 439 | +#define skb_hnat_is_decap(skb) (((struct hnat_desc *)((skb)->head))->is_decap)
|
| 440 | +#define skb_hnat_is_encap(skb) (!skb_hnat_is_decap(skb))
|
| 441 | +#define skb_hnat_set_tops(skb, tops) ((skb_hnat_tops(skb)) = (tops))
|
| 442 | +#define skb_hnat_set_is_decap(skb, is_decap) ((skb_hnat_is_decap(skb)) = (is_decap))
|
| 443 | +#else /* !defined(CONFIG_MEDIATEK_NETSYS_V3) */
|
| 444 | +#define skb_hnat_tops(skb) (0)
|
| 445 | +#define skb_hnat_is_decap(skb) (0)
|
| 446 | +#define skb_hnat_is_encap(skb) (0)
|
| 447 | +#define skb_hnat_set_tops(skb, tops)
|
| 448 | +#define skb_hnat_set_is_decap(skb, is_decap)
|
| 449 | +#endif /* defined(CONFIG_MEDIATEK_NETSYS_V3) */
|
| 450 | #define skb_hnat_magic(skb) (((struct hnat_desc *)(skb->head))->magic)
|
| 451 | #define skb_hnat_reason(skb) (((struct hnat_desc *)(skb->head))->crsn)
|
| 452 | #define skb_hnat_entry(skb) (((struct hnat_desc *)(skb->head))->entry)
|
| 453 | --- a/include/net/netfilter/nf_flow_table.h
|
| 454 | +++ b/include/net/netfilter/nf_flow_table.h
|
| 455 | @@ -98,10 +98,22 @@ struct flow_offload {
|
| 456 | #define FLOW_OFFLOAD_PATH_6RD BIT(5)
|
| 457 | #define FLOW_OFFLOAD_PATH_TNL BIT(6)
|
| 458 |
|
| 459 | +enum flow_offload_tnl {
|
| 460 | + FLOW_OFFLOAD_TNL_GRETAP,
|
| 461 | + FLOW_OFFLOAD_TNL_PPTP,
|
| 462 | + FLOW_OFFLOAD_TNL_IP_L2TP,
|
| 463 | + FLOW_OFFLOAD_TNL_UDP_L2TP_CTRL,
|
| 464 | + FLOW_OFFLOAD_TNL_UDP_L2TP_DATA,
|
| 465 | + FLOW_OFFLOAD_VXLAN,
|
| 466 | + FLOW_OFFLOAD_NATT,
|
| 467 | + __FLOW_OFFLOAD_MAX,
|
| 468 | +};
|
| 469 | +
|
| 470 | struct flow_offload_hw_path {
|
| 471 | struct net_device *dev;
|
| 472 | struct net_device *virt_dev;
|
| 473 | u32 flags;
|
| 474 | + u32 tnl_type;
|
| 475 |
|
| 476 | u8 eth_src[ETH_ALEN];
|
| 477 | u8 eth_dest[ETH_ALEN];
|
| 478 | --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
| 479 | +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
| 480 | @@ -1904,6 +1904,9 @@ extern const struct of_device_id of_mtk_match[];
|
| 481 | extern u32 mtk_hwlro_stats_ebl;
|
| 482 | extern u32 dbg_show_level;
|
| 483 |
|
| 484 | +/* tunnel offload related */
|
| 485 | +extern struct net_device *(*mtk_get_tnl_dev)(int tnl_idx);
|
| 486 | +
|
| 487 | /* read the hardware status register */
|
| 488 | void mtk_stats_update_mac(struct mtk_mac *mac);
|
| 489 |
|