Lines Matching +full:num +full:- +full:ports

1 // SPDX-License-Identifier: GPL-2.0-only
30 u8 num; member
34 u8 num; member
62 data->v4.src_addr, data->src_port, in mtk_flow_set_ipv4_addr()
63 data->v4.dst_addr, data->dst_port); in mtk_flow_set_ipv4_addr()
69 void *dest = eth + act->mangle.offset; in mtk_flow_offload_mangle_eth()
70 const void *src = &act->mangle.val; in mtk_flow_offload_mangle_eth()
72 if (act->mangle.offset > 8) in mtk_flow_offload_mangle_eth()
75 if (act->mangle.mask == 0xffff) { in mtk_flow_offload_mangle_eth()
80 memcpy(dest, src, act->mangle.mask ? 2 : 4); in mtk_flow_offload_mangle_eth()
88 u32 val = ntohl(act->mangle.val); in mtk_flow_mangle_ports()
90 switch (act->mangle.offset) { in mtk_flow_mangle_ports()
92 if (act->mangle.mask == ~htonl(0xffff)) in mtk_flow_mangle_ports()
93 data->dst_port = cpu_to_be16(val); in mtk_flow_mangle_ports()
95 data->src_port = cpu_to_be16(val >> 16); in mtk_flow_mangle_ports()
98 data->dst_port = cpu_to_be16(val); in mtk_flow_mangle_ports()
101 return -EINVAL; in mtk_flow_mangle_ports()
113 switch (act->mangle.offset) { in mtk_flow_mangle_ipv4()
115 dest = &data->v4.src_addr; in mtk_flow_mangle_ipv4()
118 dest = &data->v4.dst_addr; in mtk_flow_mangle_ipv4()
121 return -EINVAL; in mtk_flow_mangle_ipv4()
124 memcpy(dest, &act->mangle.val, sizeof(u32)); in mtk_flow_mangle_ipv4()
137 return -ENODEV; in mtk_flow_get_dsa_port()
139 if (dp->cpu_dp->tag_ops->proto != DSA_TAG_PROTO_MTK) in mtk_flow_get_dsa_port()
140 return -ENODEV; in mtk_flow_get_dsa_port()
142 *dev = dp->cpu_dp->master; in mtk_flow_get_dsa_port()
144 return dp->index; in mtk_flow_get_dsa_port()
146 return -ENODEV; in mtk_flow_get_dsa_port()
160 if (dev == eth->netdev[0]) in mtk_flow_set_output_device()
162 else if (dev == eth->netdev[1]) in mtk_flow_set_output_device()
165 return -EOPNOTSUPP; in mtk_flow_set_output_device()
189 if (rhashtable_lookup(&eth->flow_table, &f->cookie, mtk_flow_ht_params)) in mtk_flow_offload_replace()
190 return -EEXIST; in mtk_flow_offload_replace()
197 return -EOPNOTSUPP; in mtk_flow_offload_replace()
204 addr_type = match.key->addr_type; in mtk_flow_offload_replace()
206 return -EOPNOTSUPP; in mtk_flow_offload_replace()
213 l4proto = match.key->ip_proto; in mtk_flow_offload_replace()
215 return -EOPNOTSUPP; in mtk_flow_offload_replace()
218 flow_action_for_each(i, act, &rule->action) { in mtk_flow_offload_replace()
219 switch (act->id) { in mtk_flow_offload_replace()
221 if (act->mangle.htype == FLOW_ACT_MANGLE_HDR_TYPE_ETH) in mtk_flow_offload_replace()
225 odev = act->dev; in mtk_flow_offload_replace()
230 if (data.vlan.num == 1 || in mtk_flow_offload_replace()
231 act->vlan.proto != htons(ETH_P_8021Q)) in mtk_flow_offload_replace()
232 return -EOPNOTSUPP; in mtk_flow_offload_replace()
234 data.vlan.id = act->vlan.vid; in mtk_flow_offload_replace()
235 data.vlan.proto = act->vlan.proto; in mtk_flow_offload_replace()
236 data.vlan.num++; in mtk_flow_offload_replace()
241 if (data.pppoe.num == 1) in mtk_flow_offload_replace()
242 return -EOPNOTSUPP; in mtk_flow_offload_replace()
244 data.pppoe.sid = act->pppoe.sid; in mtk_flow_offload_replace()
245 data.pppoe.num++; in mtk_flow_offload_replace()
248 return -EOPNOTSUPP; in mtk_flow_offload_replace()
257 return -EOPNOTSUPP; in mtk_flow_offload_replace()
262 return -EINVAL; in mtk_flow_offload_replace()
271 struct flow_match_ports ports; in mtk_flow_offload_replace() local
273 flow_rule_match_ports(rule, &ports); in mtk_flow_offload_replace()
274 data.src_port = ports.key->src; in mtk_flow_offload_replace()
275 data.dst_port = ports.key->dst; in mtk_flow_offload_replace()
277 return -EOPNOTSUPP; in mtk_flow_offload_replace()
285 data.v4.src_addr = addrs.key->src; in mtk_flow_offload_replace()
286 data.v4.dst_addr = addrs.key->dst; in mtk_flow_offload_replace()
291 flow_action_for_each(i, act, &rule->action) { in mtk_flow_offload_replace()
292 if (act->id != FLOW_ACTION_MANGLE) in mtk_flow_offload_replace()
295 switch (act->mangle.htype) { in mtk_flow_offload_replace()
307 return -EOPNOTSUPP; in mtk_flow_offload_replace()
320 if (data.vlan.num == 1) { in mtk_flow_offload_replace()
322 return -EOPNOTSUPP; in mtk_flow_offload_replace()
326 if (data.pppoe.num == 1) in mtk_flow_offload_replace()
335 return -ENOMEM; in mtk_flow_offload_replace()
337 entry->cookie = f->cookie; in mtk_flow_offload_replace()
339 hash = mtk_foe_entry_commit(&eth->ppe, &foe, timestamp); in mtk_flow_offload_replace()
345 entry->hash = hash; in mtk_flow_offload_replace()
346 err = rhashtable_insert_fast(&eth->flow_table, &entry->node, in mtk_flow_offload_replace()
353 mtk_foe_entry_clear(&eth->ppe, hash); in mtk_flow_offload_replace()
364 entry = rhashtable_lookup(&eth->flow_table, &f->cookie, in mtk_flow_offload_destroy()
367 return -ENOENT; in mtk_flow_offload_destroy()
369 mtk_foe_entry_clear(&eth->ppe, entry->hash); in mtk_flow_offload_destroy()
370 rhashtable_remove_fast(&eth->flow_table, &entry->node, in mtk_flow_offload_destroy()
384 entry = rhashtable_lookup(&eth->flow_table, &f->cookie, in mtk_flow_offload_stats()
387 return -ENOENT; in mtk_flow_offload_stats()
389 timestamp = mtk_foe_entry_timestamp(&eth->ppe, entry->hash); in mtk_flow_offload_stats()
391 return -ETIMEDOUT; in mtk_flow_offload_stats()
393 idle = mtk_eth_timestamp(eth) - timestamp; in mtk_flow_offload_stats()
394 f->stats.lastused = jiffies - idle * HZ; in mtk_flow_offload_stats()
407 struct mtk_eth *eth = mac->hw; in mtk_eth_setup_tc_block_cb()
411 return -EOPNOTSUPP; in mtk_eth_setup_tc_block_cb()
414 return -EOPNOTSUPP; in mtk_eth_setup_tc_block_cb()
417 switch (cls->command) { in mtk_eth_setup_tc_block_cb()
428 err = -EOPNOTSUPP; in mtk_eth_setup_tc_block_cb()
440 struct mtk_eth *eth = mac->hw; in mtk_eth_setup_tc_block()
445 if (!eth->ppe.foe_table) in mtk_eth_setup_tc_block()
446 return -EOPNOTSUPP; in mtk_eth_setup_tc_block()
448 if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) in mtk_eth_setup_tc_block()
449 return -EOPNOTSUPP; in mtk_eth_setup_tc_block()
452 f->driver_block_list = &block_cb_list; in mtk_eth_setup_tc_block()
454 switch (f->command) { in mtk_eth_setup_tc_block()
456 block_cb = flow_block_cb_lookup(f->block, cb, dev); in mtk_eth_setup_tc_block()
466 list_add_tail(&block_cb->driver_list, &block_cb_list); in mtk_eth_setup_tc_block()
469 block_cb = flow_block_cb_lookup(f->block, cb, dev); in mtk_eth_setup_tc_block()
471 return -ENOENT; in mtk_eth_setup_tc_block()
475 list_del(&block_cb->driver_list); in mtk_eth_setup_tc_block()
479 return -EOPNOTSUPP; in mtk_eth_setup_tc_block()
489 return -EOPNOTSUPP; in mtk_eth_setup_tc()
494 if (!eth->ppe.foe_table) in mtk_eth_offload_init()
497 return rhashtable_init(&eth->flow_table, &mtk_flow_ht_params); in mtk_eth_offload_init()