702-v5.19-10-net-ethernet-mtk_eth_soc-support-creating-mac-addres.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. From: Felix Fietkau <[email protected]>
  2. Date: Wed, 23 Feb 2022 10:56:34 +0100
  3. Subject: [PATCH] net: ethernet: mtk_eth_soc: support creating mac
  4. address based offload entries
  5. This will be used to implement a limited form of bridge offloading.
  6. Since the hardware does not support flow table entries with just source
  7. and destination MAC address, the driver has to emulate it.
  8. The hardware automatically creates entries entries for incoming flows, even
  9. when they are bridged instead of routed, and reports when packets for these
  10. flows have reached the minimum PPS rate for offloading.
  11. After this happens, we look up the L2 flow offload entry based on the MAC
  12. header and fill in the output routing information in the flow table.
  13. The dynamically created per-flow entries are automatically removed when
  14. either the hardware flowtable entry expires, is replaced, or if the offload
  15. rule they belong to is removed
  16. Signed-off-by: Felix Fietkau <[email protected]>
  17. ---
  18. --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
  19. +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
  20. @@ -6,12 +6,22 @@
  21. #include <linux/iopoll.h>
  22. #include <linux/etherdevice.h>
  23. #include <linux/platform_device.h>
  24. +#include <linux/if_ether.h>
  25. +#include <linux/if_vlan.h>
  26. +#include <net/dsa.h>
  27. #include "mtk_eth_soc.h"
  28. #include "mtk_ppe.h"
  29. #include "mtk_ppe_regs.h"
  30. static DEFINE_SPINLOCK(ppe_lock);
  31. +static const struct rhashtable_params mtk_flow_l2_ht_params = {
  32. + .head_offset = offsetof(struct mtk_flow_entry, l2_node),
  33. + .key_offset = offsetof(struct mtk_flow_entry, data.bridge),
  34. + .key_len = offsetof(struct mtk_foe_bridge, key_end),
  35. + .automatic_shrinking = true,
  36. +};
  37. +
  38. static void ppe_w32(struct mtk_ppe *ppe, u32 reg, u32 val)
  39. {
  40. writel(val, ppe->base + reg);
  41. @@ -123,6 +133,9 @@ mtk_foe_entry_l2(struct mtk_foe_entry *e
  42. {
  43. int type = FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, entry->ib1);
  44. + if (type == MTK_PPE_PKT_TYPE_BRIDGE)
  45. + return &entry->bridge.l2;
  46. +
  47. if (type >= MTK_PPE_PKT_TYPE_IPV4_DSLITE)
  48. return &entry->ipv6.l2;
  49. @@ -134,6 +147,9 @@ mtk_foe_entry_ib2(struct mtk_foe_entry *
  50. {
  51. int type = FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, entry->ib1);
  52. + if (type == MTK_PPE_PKT_TYPE_BRIDGE)
  53. + return &entry->bridge.ib2;
  54. +
  55. if (type >= MTK_PPE_PKT_TYPE_IPV4_DSLITE)
  56. return &entry->ipv6.ib2;
  57. @@ -168,7 +184,12 @@ int mtk_foe_entry_prepare(struct mtk_foe
  58. if (type == MTK_PPE_PKT_TYPE_IPV6_ROUTE_3T)
  59. entry->ipv6.ports = ports_pad;
  60. - if (type >= MTK_PPE_PKT_TYPE_IPV4_DSLITE) {
  61. + if (type == MTK_PPE_PKT_TYPE_BRIDGE) {
  62. + ether_addr_copy(entry->bridge.src_mac, src_mac);
  63. + ether_addr_copy(entry->bridge.dest_mac, dest_mac);
  64. + entry->bridge.ib2 = val;
  65. + l2 = &entry->bridge.l2;
  66. + } else if (type >= MTK_PPE_PKT_TYPE_IPV4_DSLITE) {
  67. entry->ipv6.ib2 = val;
  68. l2 = &entry->ipv6.l2;
  69. } else {
  70. @@ -372,12 +393,96 @@ mtk_flow_entry_match(struct mtk_flow_ent
  71. }
  72. static void
  73. +__mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  74. +{
  75. + struct hlist_head *head;
  76. + struct hlist_node *tmp;
  77. +
  78. + if (entry->type == MTK_FLOW_TYPE_L2) {
  79. + rhashtable_remove_fast(&ppe->l2_flows, &entry->l2_node,
  80. + mtk_flow_l2_ht_params);
  81. +
  82. + head = &entry->l2_flows;
  83. + hlist_for_each_entry_safe(entry, tmp, head, l2_data.list)
  84. + __mtk_foe_entry_clear(ppe, entry);
  85. + return;
  86. + }
  87. +
  88. + hlist_del_init(&entry->list);
  89. + if (entry->hash != 0xffff) {
  90. + ppe->foe_table[entry->hash].ib1 &= ~MTK_FOE_IB1_STATE;
  91. + ppe->foe_table[entry->hash].ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE,
  92. + MTK_FOE_STATE_BIND);
  93. + dma_wmb();
  94. + }
  95. + entry->hash = 0xffff;
  96. +
  97. + if (entry->type != MTK_FLOW_TYPE_L2_SUBFLOW)
  98. + return;
  99. +
  100. + hlist_del_init(&entry->l2_data.list);
  101. + kfree(entry);
  102. +}
  103. +
  104. +static int __mtk_foe_entry_idle_time(struct mtk_ppe *ppe, u32 ib1)
  105. +{
  106. + u16 timestamp;
  107. + u16 now;
  108. +
  109. + now = mtk_eth_timestamp(ppe->eth) & MTK_FOE_IB1_BIND_TIMESTAMP;
  110. + timestamp = ib1 & MTK_FOE_IB1_BIND_TIMESTAMP;
  111. +
  112. + if (timestamp > now)
  113. + return MTK_FOE_IB1_BIND_TIMESTAMP + 1 - timestamp + now;
  114. + else
  115. + return now - timestamp;
  116. +}
  117. +
  118. +static void
  119. +mtk_flow_entry_update_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  120. +{
  121. + struct mtk_flow_entry *cur;
  122. + struct mtk_foe_entry *hwe;
  123. + struct hlist_node *tmp;
  124. + int idle;
  125. +
  126. + idle = __mtk_foe_entry_idle_time(ppe, entry->data.ib1);
  127. + hlist_for_each_entry_safe(cur, tmp, &entry->l2_flows, l2_data.list) {
  128. + int cur_idle;
  129. + u32 ib1;
  130. +
  131. + hwe = &ppe->foe_table[cur->hash];
  132. + ib1 = READ_ONCE(hwe->ib1);
  133. +
  134. + if (FIELD_GET(MTK_FOE_IB1_STATE, ib1) != MTK_FOE_STATE_BIND) {
  135. + cur->hash = 0xffff;
  136. + __mtk_foe_entry_clear(ppe, cur);
  137. + continue;
  138. + }
  139. +
  140. + cur_idle = __mtk_foe_entry_idle_time(ppe, ib1);
  141. + if (cur_idle >= idle)
  142. + continue;
  143. +
  144. + idle = cur_idle;
  145. + entry->data.ib1 &= ~MTK_FOE_IB1_BIND_TIMESTAMP;
  146. + entry->data.ib1 |= hwe->ib1 & MTK_FOE_IB1_BIND_TIMESTAMP;
  147. + }
  148. +}
  149. +
  150. +static void
  151. mtk_flow_entry_update(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  152. {
  153. struct mtk_foe_entry *hwe;
  154. struct mtk_foe_entry foe;
  155. spin_lock_bh(&ppe_lock);
  156. +
  157. + if (entry->type == MTK_FLOW_TYPE_L2) {
  158. + mtk_flow_entry_update_l2(ppe, entry);
  159. + goto out;
  160. + }
  161. +
  162. if (entry->hash == 0xffff)
  163. goto out;
  164. @@ -419,21 +524,28 @@ __mtk_foe_entry_commit(struct mtk_ppe *p
  165. void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  166. {
  167. spin_lock_bh(&ppe_lock);
  168. - hlist_del_init(&entry->list);
  169. - if (entry->hash != 0xffff) {
  170. - ppe->foe_table[entry->hash].ib1 &= ~MTK_FOE_IB1_STATE;
  171. - ppe->foe_table[entry->hash].ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE,
  172. - MTK_FOE_STATE_BIND);
  173. - dma_wmb();
  174. - }
  175. - entry->hash = 0xffff;
  176. + __mtk_foe_entry_clear(ppe, entry);
  177. spin_unlock_bh(&ppe_lock);
  178. }
  179. +static int
  180. +mtk_foe_entry_commit_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  181. +{
  182. + entry->type = MTK_FLOW_TYPE_L2;
  183. +
  184. + return rhashtable_insert_fast(&ppe->l2_flows, &entry->l2_node,
  185. + mtk_flow_l2_ht_params);
  186. +}
  187. +
  188. int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  189. {
  190. - u32 hash = mtk_ppe_hash_entry(&entry->data);
  191. + int type = FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, entry->data.ib1);
  192. + u32 hash;
  193. +
  194. + if (type == MTK_PPE_PKT_TYPE_BRIDGE)
  195. + return mtk_foe_entry_commit_l2(ppe, entry);
  196. + hash = mtk_ppe_hash_entry(&entry->data);
  197. entry->hash = 0xffff;
  198. spin_lock_bh(&ppe_lock);
  199. hlist_add_head(&entry->list, &ppe->foe_flow[hash / 2]);
  200. @@ -442,18 +554,72 @@ int mtk_foe_entry_commit(struct mtk_ppe
  201. return 0;
  202. }
  203. +static void
  204. +mtk_foe_entry_commit_subflow(struct mtk_ppe *ppe, struct mtk_flow_entry *entry,
  205. + u16 hash)
  206. +{
  207. + struct mtk_flow_entry *flow_info;
  208. + struct mtk_foe_entry foe, *hwe;
  209. + struct mtk_foe_mac_info *l2;
  210. + u32 ib1_mask = MTK_FOE_IB1_PACKET_TYPE | MTK_FOE_IB1_UDP;
  211. + int type;
  212. +
  213. + flow_info = kzalloc(offsetof(struct mtk_flow_entry, l2_data.end),
  214. + GFP_ATOMIC);
  215. + if (!flow_info)
  216. + return;
  217. +
  218. + flow_info->l2_data.base_flow = entry;
  219. + flow_info->type = MTK_FLOW_TYPE_L2_SUBFLOW;
  220. + flow_info->hash = hash;
  221. + hlist_add_head(&flow_info->list, &ppe->foe_flow[hash / 2]);
  222. + hlist_add_head(&flow_info->l2_data.list, &entry->l2_flows);
  223. +
  224. + hwe = &ppe->foe_table[hash];
  225. + memcpy(&foe, hwe, sizeof(foe));
  226. + foe.ib1 &= ib1_mask;
  227. + foe.ib1 |= entry->data.ib1 & ~ib1_mask;
  228. +
  229. + l2 = mtk_foe_entry_l2(&foe);
  230. + memcpy(l2, &entry->data.bridge.l2, sizeof(*l2));
  231. +
  232. + type = FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, foe.ib1);
  233. + if (type == MTK_PPE_PKT_TYPE_IPV4_HNAPT)
  234. + memcpy(&foe.ipv4.new, &foe.ipv4.orig, sizeof(foe.ipv4.new));
  235. + else if (type >= MTK_PPE_PKT_TYPE_IPV6_ROUTE_3T && l2->etype == ETH_P_IP)
  236. + l2->etype = ETH_P_IPV6;
  237. +
  238. + *mtk_foe_entry_ib2(&foe) = entry->data.bridge.ib2;
  239. +
  240. + __mtk_foe_entry_commit(ppe, &foe, hash);
  241. +}
  242. +
  243. void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash)
  244. {
  245. struct hlist_head *head = &ppe->foe_flow[hash / 2];
  246. - struct mtk_flow_entry *entry;
  247. struct mtk_foe_entry *hwe = &ppe->foe_table[hash];
  248. + struct mtk_flow_entry *entry;
  249. + struct mtk_foe_bridge key = {};
  250. + struct ethhdr *eh;
  251. bool found = false;
  252. -
  253. - if (hlist_empty(head))
  254. - return;
  255. + u8 *tag;
  256. spin_lock_bh(&ppe_lock);
  257. +
  258. + if (FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == MTK_FOE_STATE_BIND)
  259. + goto out;
  260. +
  261. hlist_for_each_entry(entry, head, list) {
  262. + if (entry->type == MTK_FLOW_TYPE_L2_SUBFLOW) {
  263. + if (unlikely(FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) ==
  264. + MTK_FOE_STATE_BIND))
  265. + continue;
  266. +
  267. + entry->hash = 0xffff;
  268. + __mtk_foe_entry_clear(ppe, entry);
  269. + continue;
  270. + }
  271. +
  272. if (found || !mtk_flow_entry_match(entry, hwe)) {
  273. if (entry->hash != 0xffff)
  274. entry->hash = 0xffff;
  275. @@ -464,21 +630,50 @@ void __mtk_ppe_check_skb(struct mtk_ppe
  276. __mtk_foe_entry_commit(ppe, &entry->data, hash);
  277. found = true;
  278. }
  279. +
  280. + if (found)
  281. + goto out;
  282. +
  283. + eh = eth_hdr(skb);
  284. + ether_addr_copy(key.dest_mac, eh->h_dest);
  285. + ether_addr_copy(key.src_mac, eh->h_source);
  286. + tag = skb->data - 2;
  287. + key.vlan = 0;
  288. + switch (skb->protocol) {
  289. +#if IS_ENABLED(CONFIG_NET_DSA)
  290. + case htons(ETH_P_XDSA):
  291. + if (!netdev_uses_dsa(skb->dev) ||
  292. + skb->dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK)
  293. + goto out;
  294. +
  295. + tag += 4;
  296. + if (get_unaligned_be16(tag) != ETH_P_8021Q)
  297. + break;
  298. +
  299. + fallthrough;
  300. +#endif
  301. + case htons(ETH_P_8021Q):
  302. + key.vlan = get_unaligned_be16(tag + 2) & VLAN_VID_MASK;
  303. + break;
  304. + default:
  305. + break;
  306. + }
  307. +
  308. + entry = rhashtable_lookup_fast(&ppe->l2_flows, &key, mtk_flow_l2_ht_params);
  309. + if (!entry)
  310. + goto out;
  311. +
  312. + mtk_foe_entry_commit_subflow(ppe, entry, hash);
  313. +
  314. +out:
  315. spin_unlock_bh(&ppe_lock);
  316. }
  317. int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
  318. {
  319. - u16 now = mtk_eth_timestamp(ppe->eth) & MTK_FOE_IB1_BIND_TIMESTAMP;
  320. - u16 timestamp;
  321. -
  322. mtk_flow_entry_update(ppe, entry);
  323. - timestamp = entry->data.ib1 & MTK_FOE_IB1_BIND_TIMESTAMP;
  324. - if (timestamp > now)
  325. - return MTK_FOE_IB1_BIND_TIMESTAMP + 1 - timestamp + now;
  326. - else
  327. - return now - timestamp;
  328. + return __mtk_foe_entry_idle_time(ppe, entry->data.ib1);
  329. }
  330. struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base,
  331. @@ -492,6 +687,8 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_
  332. if (!ppe)
  333. return NULL;
  334. + rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params);
  335. +
  336. /* need to allocate a separate device, since it PPE DMA access is
  337. * not coherent.
  338. */
  339. --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
  340. +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
  341. @@ -6,6 +6,7 @@
  342. #include <linux/kernel.h>
  343. #include <linux/bitfield.h>
  344. +#include <linux/rhashtable.h>
  345. #define MTK_ETH_PPE_BASE 0xc00
  346. @@ -84,19 +85,16 @@ struct mtk_foe_mac_info {
  347. u16 src_mac_lo;
  348. };
  349. +/* software-only entry type */
  350. struct mtk_foe_bridge {
  351. - u32 dest_mac_hi;
  352. -
  353. - u16 src_mac_lo;
  354. - u16 dest_mac_lo;
  355. + u8 dest_mac[ETH_ALEN];
  356. + u8 src_mac[ETH_ALEN];
  357. + u16 vlan;
  358. - u32 src_mac_hi;
  359. + struct {} key_end;
  360. u32 ib2;
  361. - u32 _rsv[5];
  362. -
  363. - u32 udf_tsid;
  364. struct mtk_foe_mac_info l2;
  365. };
  366. @@ -235,13 +233,33 @@ enum {
  367. MTK_PPE_CPU_REASON_INVALID = 0x1f,
  368. };
  369. +enum {
  370. + MTK_FLOW_TYPE_L4,
  371. + MTK_FLOW_TYPE_L2,
  372. + MTK_FLOW_TYPE_L2_SUBFLOW,
  373. +};
  374. +
  375. struct mtk_flow_entry {
  376. + union {
  377. + struct hlist_node list;
  378. + struct {
  379. + struct rhash_head l2_node;
  380. + struct hlist_head l2_flows;
  381. + };
  382. + };
  383. + u8 type;
  384. + s8 wed_index;
  385. + u16 hash;
  386. + union {
  387. + struct mtk_foe_entry data;
  388. + struct {
  389. + struct mtk_flow_entry *base_flow;
  390. + struct hlist_node list;
  391. + struct {} end;
  392. + } l2_data;
  393. + };
  394. struct rhash_head node;
  395. - struct hlist_node list;
  396. unsigned long cookie;
  397. - struct mtk_foe_entry data;
  398. - u16 hash;
  399. - s8 wed_index;
  400. };
  401. struct mtk_ppe {
  402. @@ -256,6 +274,8 @@ struct mtk_ppe {
  403. u16 foe_check_time[MTK_PPE_ENTRIES];
  404. struct hlist_head foe_flow[MTK_PPE_ENTRIES / 2];
  405. + struct rhashtable l2_flows;
  406. +
  407. void *acct_table;
  408. };
  409. --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
  410. +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
  411. @@ -31,6 +31,8 @@ struct mtk_flow_data {
  412. __be16 src_port;
  413. __be16 dst_port;
  414. + u16 vlan_in;
  415. +
  416. struct {
  417. u16 id;
  418. __be16 proto;
  419. @@ -257,9 +259,45 @@ mtk_flow_offload_replace(struct mtk_eth
  420. return -EOPNOTSUPP;
  421. }
  422. + switch (addr_type) {
  423. + case 0:
  424. + offload_type = MTK_PPE_PKT_TYPE_BRIDGE;
  425. + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
  426. + struct flow_match_eth_addrs match;
  427. +
  428. + flow_rule_match_eth_addrs(rule, &match);
  429. + memcpy(data.eth.h_dest, match.key->dst, ETH_ALEN);
  430. + memcpy(data.eth.h_source, match.key->src, ETH_ALEN);
  431. + } else {
  432. + return -EOPNOTSUPP;
  433. + }
  434. +
  435. + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) {
  436. + struct flow_match_vlan match;
  437. +
  438. + flow_rule_match_vlan(rule, &match);
  439. +
  440. + if (match.key->vlan_tpid != cpu_to_be16(ETH_P_8021Q))
  441. + return -EOPNOTSUPP;
  442. +
  443. + data.vlan_in = match.key->vlan_id;
  444. + }
  445. + break;
  446. + case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
  447. + offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT;
  448. + break;
  449. + case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
  450. + offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T;
  451. + break;
  452. + default:
  453. + return -EOPNOTSUPP;
  454. + }
  455. +
  456. flow_action_for_each(i, act, &rule->action) {
  457. switch (act->id) {
  458. case FLOW_ACTION_MANGLE:
  459. + if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  460. + return -EOPNOTSUPP;
  461. if (act->mangle.htype == FLOW_ACT_MANGLE_HDR_TYPE_ETH)
  462. mtk_flow_offload_mangle_eth(act, &data.eth);
  463. break;
  464. @@ -291,17 +329,6 @@ mtk_flow_offload_replace(struct mtk_eth
  465. }
  466. }
  467. - switch (addr_type) {
  468. - case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
  469. - offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT;
  470. - break;
  471. - case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
  472. - offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T;
  473. - break;
  474. - default:
  475. - return -EOPNOTSUPP;
  476. - }
  477. -
  478. if (!is_valid_ether_addr(data.eth.h_source) ||
  479. !is_valid_ether_addr(data.eth.h_dest))
  480. return -EINVAL;
  481. @@ -315,10 +342,13 @@ mtk_flow_offload_replace(struct mtk_eth
  482. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
  483. struct flow_match_ports ports;
  484. + if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  485. + return -EOPNOTSUPP;
  486. +
  487. flow_rule_match_ports(rule, &ports);
  488. data.src_port = ports.key->src;
  489. data.dst_port = ports.key->dst;
  490. - } else {
  491. + } else if (offload_type != MTK_PPE_PKT_TYPE_BRIDGE) {
  492. return -EOPNOTSUPP;
  493. }
  494. @@ -348,6 +378,9 @@ mtk_flow_offload_replace(struct mtk_eth
  495. if (act->id != FLOW_ACTION_MANGLE)
  496. continue;
  497. + if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  498. + return -EOPNOTSUPP;
  499. +
  500. switch (act->mangle.htype) {
  501. case FLOW_ACT_MANGLE_HDR_TYPE_TCP:
  502. case FLOW_ACT_MANGLE_HDR_TYPE_UDP:
  503. @@ -373,6 +406,9 @@ mtk_flow_offload_replace(struct mtk_eth
  504. return err;
  505. }
  506. + if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  507. + foe.bridge.vlan = data.vlan_in;
  508. +
  509. if (data.vlan.num == 1) {
  510. if (data.vlan.proto != htons(ETH_P_8021Q))
  511. return -EOPNOTSUPP;