mtk_ppe_offload.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2020 Felix Fietkau <nbd@nbd.name>
  4. */
  5. #include <linux/if_ether.h>
  6. #include <linux/rhashtable.h>
  7. #include <linux/ip.h>
  8. #include <linux/ipv6.h>
  9. #include <net/flow_offload.h>
  10. #include <net/pkt_cls.h>
  11. #include <net/dsa.h>
  12. #include "mtk_eth_soc.h"
  13. #include "mtk_wed.h"
  14. struct mtk_flow_data {
  15. struct ethhdr eth;
  16. union {
  17. struct {
  18. __be32 src_addr;
  19. __be32 dst_addr;
  20. } v4;
  21. struct {
  22. struct in6_addr src_addr;
  23. struct in6_addr dst_addr;
  24. } v6;
  25. };
  26. __be16 src_port;
  27. __be16 dst_port;
  28. u16 vlan_in;
  29. struct {
  30. struct {
  31. u16 id;
  32. __be16 proto;
  33. } vlans[2];
  34. u8 num;
  35. } vlan;
  36. struct {
  37. u16 sid;
  38. u8 num;
  39. } pppoe;
  40. };
  41. static const struct rhashtable_params mtk_flow_ht_params = {
  42. .head_offset = offsetof(struct mtk_flow_entry, node),
  43. .key_offset = offsetof(struct mtk_flow_entry, cookie),
  44. .key_len = sizeof(unsigned long),
  45. .automatic_shrinking = true,
  46. };
  47. static int
  48. mtk_flow_set_ipv4_addr(struct mtk_eth *eth, struct mtk_foe_entry *foe,
  49. struct mtk_flow_data *data, bool egress)
  50. {
  51. return mtk_foe_entry_set_ipv4_tuple(eth, foe, egress,
  52. data->v4.src_addr, data->src_port,
  53. data->v4.dst_addr, data->dst_port);
  54. }
  55. static int
  56. mtk_flow_set_ipv6_addr(struct mtk_eth *eth, struct mtk_foe_entry *foe,
  57. struct mtk_flow_data *data)
  58. {
  59. return mtk_foe_entry_set_ipv6_tuple(eth, foe,
  60. data->v6.src_addr.s6_addr32, data->src_port,
  61. data->v6.dst_addr.s6_addr32, data->dst_port);
  62. }
  63. static void
  64. mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth)
  65. {
  66. void *dest = eth + act->mangle.offset;
  67. const void *src = &act->mangle.val;
  68. if (act->mangle.offset > 8)
  69. return;
  70. if (act->mangle.mask == 0xffff) {
  71. src += 2;
  72. dest += 2;
  73. }
  74. memcpy(dest, src, act->mangle.mask ? 2 : 4);
  75. }
  76. static int
  77. mtk_flow_get_wdma_info(struct net_device *dev, const u8 *addr, struct mtk_wdma_info *info)
  78. {
  79. struct net_device_path_stack stack;
  80. struct net_device_path *path;
  81. int err;
  82. if (!dev)
  83. return -ENODEV;
  84. if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))
  85. return -1;
  86. rcu_read_lock();
  87. err = dev_fill_forward_path(dev, addr, &stack);
  88. rcu_read_unlock();
  89. if (err)
  90. return err;
  91. path = &stack.path[stack.num_paths - 1];
  92. if (path->type != DEV_PATH_MTK_WDMA)
  93. return -1;
  94. info->wdma_idx = path->mtk_wdma.wdma_idx;
  95. info->queue = path->mtk_wdma.queue;
  96. info->bss = path->mtk_wdma.bss;
  97. info->wcid = path->mtk_wdma.wcid;
  98. info->amsdu = path->mtk_wdma.amsdu;
  99. return 0;
  100. }
  101. static int
  102. mtk_flow_mangle_ports(const struct flow_action_entry *act,
  103. struct mtk_flow_data *data)
  104. {
  105. u32 val = ntohl(act->mangle.val);
  106. switch (act->mangle.offset) {
  107. case 0:
  108. if (act->mangle.mask == ~htonl(0xffff))
  109. data->dst_port = cpu_to_be16(val);
  110. else
  111. data->src_port = cpu_to_be16(val >> 16);
  112. break;
  113. case 2:
  114. data->dst_port = cpu_to_be16(val);
  115. break;
  116. default:
  117. return -EINVAL;
  118. }
  119. return 0;
  120. }
  121. static int
  122. mtk_flow_mangle_ipv4(const struct flow_action_entry *act,
  123. struct mtk_flow_data *data)
  124. {
  125. __be32 *dest;
  126. switch (act->mangle.offset) {
  127. case offsetof(struct iphdr, saddr):
  128. dest = &data->v4.src_addr;
  129. break;
  130. case offsetof(struct iphdr, daddr):
  131. dest = &data->v4.dst_addr;
  132. break;
  133. default:
  134. return -EINVAL;
  135. }
  136. memcpy(dest, &act->mangle.val, sizeof(u32));
  137. return 0;
  138. }
  139. static int
  140. mtk_flow_get_dsa_port(struct net_device **dev)
  141. {
  142. #if IS_ENABLED(CONFIG_NET_DSA)
  143. struct dsa_port *dp;
  144. dp = dsa_port_from_netdev(*dev);
  145. if (IS_ERR(dp))
  146. return -ENODEV;
  147. if (dp->cpu_dp->tag_ops->proto != DSA_TAG_PROTO_MTK)
  148. return -ENODEV;
  149. *dev = dsa_port_to_conduit(dp);
  150. return dp->index;
  151. #else
  152. return -ENODEV;
  153. #endif
  154. }
  155. static int
  156. mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe,
  157. struct net_device *dev, const u8 *dest_mac,
  158. int *wed_index)
  159. {
  160. struct mtk_wdma_info info = {};
  161. int pse_port, dsa_port, queue;
  162. if (mtk_flow_get_wdma_info(dev, dest_mac, &info) == 0) {
  163. mtk_foe_entry_set_wdma(eth, foe, info.wdma_idx, info.queue,
  164. info.bss, info.wcid, info.amsdu);
  165. if (mtk_is_netsys_v2_or_greater(eth)) {
  166. switch (info.wdma_idx) {
  167. case 0:
  168. pse_port = PSE_WDMA0_PORT;
  169. break;
  170. case 1:
  171. pse_port = PSE_WDMA1_PORT;
  172. break;
  173. case 2:
  174. pse_port = PSE_WDMA2_PORT;
  175. break;
  176. default:
  177. return -EINVAL;
  178. }
  179. } else {
  180. pse_port = 3;
  181. }
  182. *wed_index = info.wdma_idx;
  183. goto out;
  184. }
  185. dsa_port = mtk_flow_get_dsa_port(&dev);
  186. if (dev == eth->netdev[0])
  187. pse_port = PSE_GDM1_PORT;
  188. else if (dev == eth->netdev[1])
  189. pse_port = PSE_GDM2_PORT;
  190. else if (dev == eth->netdev[2])
  191. pse_port = PSE_GDM3_PORT;
  192. else
  193. return -EOPNOTSUPP;
  194. if (dsa_port >= 0) {
  195. mtk_foe_entry_set_dsa(eth, foe, dsa_port);
  196. queue = 3 + dsa_port;
  197. } else {
  198. queue = pse_port - 1;
  199. }
  200. mtk_foe_entry_set_queue(eth, foe, queue);
  201. out:
  202. mtk_foe_entry_set_pse_port(eth, foe, pse_port);
  203. return 0;
  204. }
  205. static bool
  206. mtk_flow_is_valid_idev(const struct mtk_eth *eth, const struct net_device *idev)
  207. {
  208. size_t i;
  209. if (!idev)
  210. return false;
  211. for (i = 0; i < ARRAY_SIZE(eth->netdev); i++) {
  212. if (!eth->netdev[i])
  213. continue;
  214. if (idev->netdev_ops == eth->netdev[i]->netdev_ops)
  215. return true;
  216. }
  217. return false;
  218. }
  219. static int
  220. mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f,
  221. int ppe_index)
  222. {
  223. struct flow_rule *rule = flow_cls_offload_flow_rule(f);
  224. struct net_device *idev = NULL, *odev = NULL;
  225. struct flow_action_entry *act;
  226. struct mtk_flow_data data = {};
  227. struct mtk_foe_entry foe;
  228. struct mtk_flow_entry *entry;
  229. int offload_type = 0;
  230. int wed_index = -1;
  231. u16 addr_type = 0;
  232. u8 l4proto = 0;
  233. int err = 0;
  234. int i;
  235. if (rhashtable_lookup(&eth->flow_table, &f->cookie, mtk_flow_ht_params))
  236. return -EEXIST;
  237. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_META)) {
  238. struct flow_match_meta match;
  239. flow_rule_match_meta(rule, &match);
  240. if (mtk_is_netsys_v2_or_greater(eth)) {
  241. idev = __dev_get_by_index(&init_net, match.key->ingress_ifindex);
  242. if (mtk_flow_is_valid_idev(eth, idev)) {
  243. struct mtk_mac *mac = netdev_priv(idev);
  244. if (WARN_ON(mac->ppe_idx >= eth->soc->ppe_num))
  245. return -EINVAL;
  246. ppe_index = mac->ppe_idx;
  247. }
  248. }
  249. } else {
  250. return -EOPNOTSUPP;
  251. }
  252. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
  253. struct flow_match_control match;
  254. flow_rule_match_control(rule, &match);
  255. addr_type = match.key->addr_type;
  256. if (flow_rule_has_control_flags(match.mask->flags,
  257. f->common.extack))
  258. return -EOPNOTSUPP;
  259. } else {
  260. return -EOPNOTSUPP;
  261. }
  262. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
  263. struct flow_match_basic match;
  264. flow_rule_match_basic(rule, &match);
  265. l4proto = match.key->ip_proto;
  266. } else {
  267. return -EOPNOTSUPP;
  268. }
  269. switch (addr_type) {
  270. case 0:
  271. offload_type = MTK_PPE_PKT_TYPE_BRIDGE;
  272. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
  273. struct flow_match_eth_addrs match;
  274. flow_rule_match_eth_addrs(rule, &match);
  275. memcpy(data.eth.h_dest, match.key->dst, ETH_ALEN);
  276. memcpy(data.eth.h_source, match.key->src, ETH_ALEN);
  277. } else {
  278. return -EOPNOTSUPP;
  279. }
  280. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) {
  281. struct flow_match_vlan match;
  282. flow_rule_match_vlan(rule, &match);
  283. if (match.key->vlan_tpid != cpu_to_be16(ETH_P_8021Q))
  284. return -EOPNOTSUPP;
  285. data.vlan_in = match.key->vlan_id;
  286. }
  287. break;
  288. case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
  289. offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT;
  290. break;
  291. case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
  292. offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T;
  293. break;
  294. default:
  295. return -EOPNOTSUPP;
  296. }
  297. flow_action_for_each(i, act, &rule->action) {
  298. switch (act->id) {
  299. case FLOW_ACTION_MANGLE:
  300. if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  301. return -EOPNOTSUPP;
  302. if (act->mangle.htype == FLOW_ACT_MANGLE_HDR_TYPE_ETH)
  303. mtk_flow_offload_mangle_eth(act, &data.eth);
  304. break;
  305. case FLOW_ACTION_REDIRECT:
  306. odev = act->dev;
  307. break;
  308. case FLOW_ACTION_CSUM:
  309. break;
  310. case FLOW_ACTION_VLAN_PUSH:
  311. if (data.vlan.num + data.pppoe.num == 2 ||
  312. act->vlan.proto != htons(ETH_P_8021Q))
  313. return -EOPNOTSUPP;
  314. data.vlan.vlans[data.vlan.num].id = act->vlan.vid;
  315. data.vlan.vlans[data.vlan.num].proto = act->vlan.proto;
  316. data.vlan.num++;
  317. break;
  318. case FLOW_ACTION_VLAN_POP:
  319. break;
  320. case FLOW_ACTION_PPPOE_PUSH:
  321. if (data.pppoe.num == 1 ||
  322. data.vlan.num == 2)
  323. return -EOPNOTSUPP;
  324. data.pppoe.sid = act->pppoe.sid;
  325. data.pppoe.num++;
  326. break;
  327. default:
  328. return -EOPNOTSUPP;
  329. }
  330. }
  331. if (!is_valid_ether_addr(data.eth.h_source) ||
  332. !is_valid_ether_addr(data.eth.h_dest))
  333. return -EINVAL;
  334. err = mtk_foe_entry_prepare(eth, &foe, offload_type, l4proto, 0,
  335. data.eth.h_source, data.eth.h_dest);
  336. if (err)
  337. return err;
  338. if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
  339. struct flow_match_ports ports;
  340. if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  341. return -EOPNOTSUPP;
  342. flow_rule_match_ports(rule, &ports);
  343. data.src_port = ports.key->src;
  344. data.dst_port = ports.key->dst;
  345. } else if (offload_type != MTK_PPE_PKT_TYPE_BRIDGE) {
  346. return -EOPNOTSUPP;
  347. }
  348. if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
  349. struct flow_match_ipv4_addrs addrs;
  350. flow_rule_match_ipv4_addrs(rule, &addrs);
  351. data.v4.src_addr = addrs.key->src;
  352. data.v4.dst_addr = addrs.key->dst;
  353. mtk_flow_set_ipv4_addr(eth, &foe, &data, false);
  354. }
  355. if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
  356. struct flow_match_ipv6_addrs addrs;
  357. flow_rule_match_ipv6_addrs(rule, &addrs);
  358. data.v6.src_addr = addrs.key->src;
  359. data.v6.dst_addr = addrs.key->dst;
  360. mtk_flow_set_ipv6_addr(eth, &foe, &data);
  361. }
  362. flow_action_for_each(i, act, &rule->action) {
  363. if (act->id != FLOW_ACTION_MANGLE)
  364. continue;
  365. if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  366. return -EOPNOTSUPP;
  367. switch (act->mangle.htype) {
  368. case FLOW_ACT_MANGLE_HDR_TYPE_TCP:
  369. case FLOW_ACT_MANGLE_HDR_TYPE_UDP:
  370. err = mtk_flow_mangle_ports(act, &data);
  371. break;
  372. case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
  373. err = mtk_flow_mangle_ipv4(act, &data);
  374. break;
  375. case FLOW_ACT_MANGLE_HDR_TYPE_ETH:
  376. /* handled earlier */
  377. break;
  378. default:
  379. return -EOPNOTSUPP;
  380. }
  381. if (err)
  382. return err;
  383. }
  384. if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
  385. err = mtk_flow_set_ipv4_addr(eth, &foe, &data, true);
  386. if (err)
  387. return err;
  388. }
  389. if (offload_type == MTK_PPE_PKT_TYPE_BRIDGE)
  390. foe.bridge.vlan = data.vlan_in;
  391. for (i = 0; i < data.vlan.num; i++)
  392. mtk_foe_entry_set_vlan(eth, &foe, data.vlan.vlans[i].id);
  393. if (data.pppoe.num == 1)
  394. mtk_foe_entry_set_pppoe(eth, &foe, data.pppoe.sid);
  395. err = mtk_flow_set_output_device(eth, &foe, odev, data.eth.h_dest,
  396. &wed_index);
  397. if (err)
  398. return err;
  399. if (wed_index >= 0 && (err = mtk_wed_flow_add(wed_index)) < 0)
  400. return err;
  401. entry = kzalloc_obj(*entry);
  402. if (!entry)
  403. return -ENOMEM;
  404. entry->cookie = f->cookie;
  405. memcpy(&entry->data, &foe, sizeof(entry->data));
  406. entry->wed_index = wed_index;
  407. entry->ppe_index = ppe_index;
  408. err = mtk_foe_entry_commit(eth->ppe[entry->ppe_index], entry);
  409. if (err < 0)
  410. goto free;
  411. err = rhashtable_insert_fast(&eth->flow_table, &entry->node,
  412. mtk_flow_ht_params);
  413. if (err < 0)
  414. goto clear;
  415. return 0;
  416. clear:
  417. mtk_foe_entry_clear(eth->ppe[entry->ppe_index], entry);
  418. free:
  419. kfree(entry);
  420. if (wed_index >= 0)
  421. mtk_wed_flow_remove(wed_index);
  422. return err;
  423. }
  424. static int
  425. mtk_flow_offload_destroy(struct mtk_eth *eth, struct flow_cls_offload *f)
  426. {
  427. struct mtk_flow_entry *entry;
  428. entry = rhashtable_lookup(&eth->flow_table, &f->cookie,
  429. mtk_flow_ht_params);
  430. if (!entry)
  431. return -ENOENT;
  432. mtk_foe_entry_clear(eth->ppe[entry->ppe_index], entry);
  433. rhashtable_remove_fast(&eth->flow_table, &entry->node,
  434. mtk_flow_ht_params);
  435. if (entry->wed_index >= 0)
  436. mtk_wed_flow_remove(entry->wed_index);
  437. kfree(entry);
  438. return 0;
  439. }
  440. static int
  441. mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f)
  442. {
  443. struct mtk_flow_entry *entry;
  444. struct mtk_foe_accounting diff;
  445. u32 idle;
  446. entry = rhashtable_lookup(&eth->flow_table, &f->cookie,
  447. mtk_flow_ht_params);
  448. if (!entry)
  449. return -ENOENT;
  450. idle = mtk_foe_entry_idle_time(eth->ppe[entry->ppe_index], entry);
  451. f->stats.lastused = jiffies - idle * HZ;
  452. if (entry->hash != 0xFFFF &&
  453. mtk_foe_entry_get_mib(eth->ppe[entry->ppe_index], entry->hash,
  454. &diff)) {
  455. f->stats.pkts += diff.packets;
  456. f->stats.bytes += diff.bytes;
  457. }
  458. return 0;
  459. }
  460. static DEFINE_MUTEX(mtk_flow_offload_mutex);
  461. int mtk_flow_offload_cmd(struct mtk_eth *eth, struct flow_cls_offload *cls,
  462. int ppe_index)
  463. {
  464. int err;
  465. mutex_lock(&mtk_flow_offload_mutex);
  466. switch (cls->command) {
  467. case FLOW_CLS_REPLACE:
  468. err = mtk_flow_offload_replace(eth, cls, ppe_index);
  469. break;
  470. case FLOW_CLS_DESTROY:
  471. err = mtk_flow_offload_destroy(eth, cls);
  472. break;
  473. case FLOW_CLS_STATS:
  474. err = mtk_flow_offload_stats(eth, cls);
  475. break;
  476. default:
  477. err = -EOPNOTSUPP;
  478. break;
  479. }
  480. mutex_unlock(&mtk_flow_offload_mutex);
  481. return err;
  482. }
  483. static int
  484. mtk_eth_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)
  485. {
  486. struct flow_cls_offload *cls = type_data;
  487. struct net_device *dev = cb_priv;
  488. struct mtk_mac *mac;
  489. struct mtk_eth *eth;
  490. mac = netdev_priv(dev);
  491. eth = mac->hw;
  492. if (!tc_can_offload(dev))
  493. return -EOPNOTSUPP;
  494. if (type != TC_SETUP_CLSFLOWER)
  495. return -EOPNOTSUPP;
  496. return mtk_flow_offload_cmd(eth, cls, 0);
  497. }
  498. static int
  499. mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
  500. {
  501. struct mtk_mac *mac = netdev_priv(dev);
  502. struct mtk_eth *eth = mac->hw;
  503. static LIST_HEAD(block_cb_list);
  504. struct flow_block_cb *block_cb;
  505. flow_setup_cb_t *cb;
  506. if (!eth->soc->offload_version)
  507. return -EOPNOTSUPP;
  508. if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
  509. return -EOPNOTSUPP;
  510. cb = mtk_eth_setup_tc_block_cb;
  511. f->driver_block_list = &block_cb_list;
  512. switch (f->command) {
  513. case FLOW_BLOCK_BIND:
  514. block_cb = flow_block_cb_lookup(f->block, cb, dev);
  515. if (block_cb) {
  516. flow_block_cb_incref(block_cb);
  517. return 0;
  518. }
  519. block_cb = flow_block_cb_alloc(cb, dev, dev, NULL);
  520. if (IS_ERR(block_cb))
  521. return PTR_ERR(block_cb);
  522. flow_block_cb_incref(block_cb);
  523. flow_block_cb_add(block_cb, f);
  524. list_add_tail(&block_cb->driver_list, &block_cb_list);
  525. return 0;
  526. case FLOW_BLOCK_UNBIND:
  527. block_cb = flow_block_cb_lookup(f->block, cb, dev);
  528. if (!block_cb)
  529. return -ENOENT;
  530. if (!flow_block_cb_decref(block_cb)) {
  531. flow_block_cb_remove(block_cb, f);
  532. list_del(&block_cb->driver_list);
  533. }
  534. return 0;
  535. default:
  536. return -EOPNOTSUPP;
  537. }
  538. }
  539. int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type,
  540. void *type_data)
  541. {
  542. switch (type) {
  543. case TC_SETUP_BLOCK:
  544. case TC_SETUP_FT:
  545. return mtk_eth_setup_tc_block(dev, type_data);
  546. default:
  547. return -EOPNOTSUPP;
  548. }
  549. }
  550. int mtk_eth_offload_init(struct mtk_eth *eth, u8 id)
  551. {
  552. if (!eth->ppe[id] || !eth->ppe[id]->foe_table)
  553. return 0;
  554. return rhashtable_init(&eth->flow_table, &mtk_flow_ht_params);
  555. }