Message ID | 20250407-airoha-flowtable-l2b-v1-2-18777778e568@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add L2 hw acceleration for airoha_eth driver | expand |
On Mon, Apr 07, 2025 at 04:18:31PM +0200, Lorenzo Bianconi wrote: > Introduce airoha_ppe_foe_flow_remove_entry_locked utility routine > in order to run airoha_ppe_foe_flow_remove_entry holding ppe_lock. > This is a preliminary patch to L2 offloading support to airoha_eth > driver. > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Could you please explain the reason of introducing the *_remove_entry_locked function if "airoha_ppe_foe_flow_remove_entry()" is still never called out of "airoha_ppe_foe_flow_remove_entry_locked()" context (at least in this series)? I would expect that it can be useful if you have an use case when you want to call "airoha_ppe_foe_flow_remove_entry()" from another function that has already taken the lock, but I haven't found such a context. Thanks, Michal
> On Mon, Apr 07, 2025 at 04:18:31PM +0200, Lorenzo Bianconi wrote: > > Introduce airoha_ppe_foe_flow_remove_entry_locked utility routine > > in order to run airoha_ppe_foe_flow_remove_entry holding ppe_lock. > > This is a preliminary patch to L2 offloading support to airoha_eth > > driver. > > > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> > > Could you please explain the reason of introducing the *_remove_entry_locked > function if "airoha_ppe_foe_flow_remove_entry()" is still never called out of > "airoha_ppe_foe_flow_remove_entry_locked()" context (at least in this > series)? > I would expect that it can be useful if you have an use case when you want > to call "airoha_ppe_foe_flow_remove_entry()" from another function that > has already taken the lock, but I haven't found such a context. ack, you are right. I guess we can drop airoha_ppe_foe_flow_remove_entry_locked(). I will fix it in v2. Regards, Lorenzo > > Thanks, > Michal >
diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c index aed4a22f3a8b8737f18509b48fc47eae594b9d5f..8f75752c6714cc211a8efd0b6fdf5565ffa23c14 100644 --- a/drivers/net/ethernet/airoha/airoha_ppe.c +++ b/drivers/net/ethernet/airoha/airoha_ppe.c @@ -483,6 +483,26 @@ static int airoha_ppe_foe_commit_entry(struct airoha_ppe *ppe, return 0; } +static void airoha_ppe_foe_flow_remove_entry(struct airoha_ppe *ppe, + struct airoha_flow_table_entry *e) +{ + lockdep_assert_held(&ppe_lock); + + if (e->type == FLOW_TYPE_L2) { + rhashtable_remove_fast(&ppe->l2_flows, &e->l2_node, + airoha_l2_flow_table_params); + } else { + hlist_del_init(&e->list); + if (e->hash != 0xffff) { + e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE; + e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, + AIROHA_FOE_STATE_INVALID); + airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash); + e->hash = 0xffff; + } + } +} + static void airoha_ppe_foe_insert_entry(struct airoha_ppe *ppe, u32 hash) { struct airoha_flow_table_entry *e; @@ -551,25 +571,12 @@ static int airoha_ppe_foe_flow_commit_entry(struct airoha_ppe *ppe, return 0; } -static void airoha_ppe_foe_flow_remove_entry(struct airoha_ppe *ppe, - struct airoha_flow_table_entry *e) +static void +airoha_ppe_foe_flow_remove_entry_locked(struct airoha_ppe *ppe, + struct airoha_flow_table_entry *e) { spin_lock_bh(&ppe_lock); - - if (e->type == FLOW_TYPE_L2) { - rhashtable_remove_fast(&ppe->l2_flows, &e->l2_node, - airoha_l2_flow_table_params); - } else { - hlist_del_init(&e->list); - if (e->hash != 0xffff) { - e->data.ib1 &= ~AIROHA_FOE_IB1_BIND_STATE; - e->data.ib1 |= FIELD_PREP(AIROHA_FOE_IB1_BIND_STATE, - AIROHA_FOE_STATE_INVALID); - airoha_ppe_foe_commit_entry(ppe, &e->data, e->hash); - e->hash = 0xffff; - } - } - + airoha_ppe_foe_flow_remove_entry(ppe, e); spin_unlock_bh(&ppe_lock); } @@ -762,7 +769,7 @@ static int airoha_ppe_flow_offload_replace(struct airoha_gdm_port *port, return 0; remove_foe_entry: - airoha_ppe_foe_flow_remove_entry(eth->ppe, e); + airoha_ppe_foe_flow_remove_entry_locked(eth->ppe, e); free_entry: kfree(e); @@ -780,7 +787,7 @@ static int airoha_ppe_flow_offload_destroy(struct airoha_gdm_port *port, if (!e) return -ENOENT; - airoha_ppe_foe_flow_remove_entry(eth->ppe, e); + airoha_ppe_foe_flow_remove_entry_locked(eth->ppe, e); rhashtable_remove_fast(ð->flow_table, &e->node, airoha_flow_table_params); kfree(e);
Introduce airoha_ppe_foe_flow_remove_entry_locked utility routine in order to run airoha_ppe_foe_flow_remove_entry holding ppe_lock. This is a preliminary patch to L2 offloading support to airoha_eth driver. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> --- drivers/net/ethernet/airoha/airoha_ppe.c | 45 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-)