Skip to content

Commit 00a7678

Browse files
LorenzoBianconiPaolo Abeni
authored andcommitted
net: airoha: Introduce flowtable offload support
Introduce netfilter flowtable integration in order to allow airoha_eth driver to offload 5-tuple flower rules learned by the PPE module if the user accelerates them using a nft configuration similar to the one reported below: table inet filter { flowtable ft { hook ingress priority filter devices = { lan1, lan2, lan3, lan4, eth1 } flags offload; } chain forward { type filter hook forward priority filter; policy accept; meta l4proto { tcp, udp } flow add @ft } } Tested-by: Sayantan Nandy <sayantan.nandy@airoha.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 23290c7 commit 00a7678

File tree

5 files changed

+1314
-7
lines changed

5 files changed

+1314
-7
lines changed

drivers/net/ethernet/airoha/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
# Airoha for the Mediatek SoCs built-in ethernet macs
44
#
55

6-
obj-$(CONFIG_NET_AIROHA) += airoha_eth.o
6+
obj-$(CONFIG_NET_AIROHA) += airoha-eth.o
7+
airoha-eth-y := airoha_eth.o airoha_ppe.o
78
obj-$(CONFIG_NET_AIROHA_NPU) += airoha_npu.o

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/platform_device.h>
99
#include <linux/tcp.h>
1010
#include <linux/u64_stats_sync.h>
11-
#include <net/dsa.h>
1211
#include <net/dst_metadata.h>
1312
#include <net/page_pool/helpers.h>
1413
#include <net/pkt_cls.h>
@@ -619,6 +618,7 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget)
619618
while (done < budget) {
620619
struct airoha_queue_entry *e = &q->entry[q->tail];
621620
struct airoha_qdma_desc *desc = &q->desc[q->tail];
621+
u32 hash, reason, msg1 = le32_to_cpu(desc->msg1);
622622
dma_addr_t dma_addr = le32_to_cpu(desc->addr);
623623
u32 desc_ctrl = le32_to_cpu(desc->ctrl);
624624
struct airoha_gdm_port *port;
@@ -681,6 +681,15 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget)
681681
&port->dsa_meta[sptag]->dst);
682682
}
683683

684+
hash = FIELD_GET(AIROHA_RXD4_FOE_ENTRY, msg1);
685+
if (hash != AIROHA_RXD4_FOE_ENTRY)
686+
skb_set_hash(skb, jhash_1word(hash, 0),
687+
PKT_HASH_TYPE_L4);
688+
689+
reason = FIELD_GET(AIROHA_RXD4_PPE_CPU_REASON, msg1);
690+
if (reason == PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
691+
airoha_ppe_check_skb(eth->ppe, hash);
692+
684693
napi_gro_receive(&q->napi, skb);
685694

686695
done++;
@@ -1301,6 +1310,10 @@ static int airoha_hw_init(struct platform_device *pdev,
13011310
return err;
13021311
}
13031312

1313+
err = airoha_ppe_init(eth);
1314+
if (err)
1315+
return err;
1316+
13041317
set_bit(DEV_STATE_INITIALIZED, &eth->state);
13051318

13061319
return 0;
@@ -2168,6 +2181,47 @@ static int airoha_tc_htb_alloc_leaf_queue(struct airoha_gdm_port *port,
21682181
return 0;
21692182
}
21702183

2184+
static int airoha_dev_setup_tc_block(struct airoha_gdm_port *port,
2185+
struct flow_block_offload *f)
2186+
{
2187+
flow_setup_cb_t *cb = airoha_ppe_setup_tc_block_cb;
2188+
static LIST_HEAD(block_cb_list);
2189+
struct flow_block_cb *block_cb;
2190+
2191+
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
2192+
return -EOPNOTSUPP;
2193+
2194+
f->driver_block_list = &block_cb_list;
2195+
switch (f->command) {
2196+
case FLOW_BLOCK_BIND:
2197+
block_cb = flow_block_cb_lookup(f->block, cb, port->dev);
2198+
if (block_cb) {
2199+
flow_block_cb_incref(block_cb);
2200+
return 0;
2201+
}
2202+
block_cb = flow_block_cb_alloc(cb, port->dev, port->dev, NULL);
2203+
if (IS_ERR(block_cb))
2204+
return PTR_ERR(block_cb);
2205+
2206+
flow_block_cb_incref(block_cb);
2207+
flow_block_cb_add(block_cb, f);
2208+
list_add_tail(&block_cb->driver_list, &block_cb_list);
2209+
return 0;
2210+
case FLOW_BLOCK_UNBIND:
2211+
block_cb = flow_block_cb_lookup(f->block, cb, port->dev);
2212+
if (!block_cb)
2213+
return -ENOENT;
2214+
2215+
if (!flow_block_cb_decref(block_cb)) {
2216+
flow_block_cb_remove(block_cb, f);
2217+
list_del(&block_cb->driver_list);
2218+
}
2219+
return 0;
2220+
default:
2221+
return -EOPNOTSUPP;
2222+
}
2223+
}
2224+
21712225
static void airoha_tc_remove_htb_queue(struct airoha_gdm_port *port, int queue)
21722226
{
21732227
struct net_device *dev = port->dev;
@@ -2251,6 +2305,9 @@ static int airoha_dev_tc_setup(struct net_device *dev, enum tc_setup_type type,
22512305
return airoha_tc_setup_qdisc_ets(port, type_data);
22522306
case TC_SETUP_QDISC_HTB:
22532307
return airoha_tc_setup_qdisc_htb(port, type_data);
2308+
case TC_SETUP_BLOCK:
2309+
case TC_SETUP_FT:
2310+
return airoha_dev_setup_tc_block(port, type_data);
22542311
default:
22552312
return -EOPNOTSUPP;
22562313
}
@@ -2507,6 +2564,7 @@ static void airoha_remove(struct platform_device *pdev)
25072564
}
25082565
free_netdev(eth->napi_dev);
25092566

2567+
airoha_ppe_deinit(eth);
25102568
platform_set_drvdata(pdev, NULL);
25112569
}
25122570

0 commit comments

Comments
 (0)