Re: [net-next PATCH v4 1/2] octeontx2-af: Add new mbox to support multicast/mirror offload

From: Wojciech Drewek
Date: Mon Nov 27 2023 - 04:48:21 EST




On 26.11.2023 19:43, Suman Ghosh wrote:
> A new mailbox is added to support offloading of multicast/mirror
> functionality. The mailbox also supports dynamic updation of the
> multicast/mirror list.
>
> Signed-off-by: Suman Ghosh <sumang@xxxxxxxxxxx>
> ---
> .../net/ethernet/marvell/octeontx2/af/mbox.h | 72 ++
> .../net/ethernet/marvell/octeontx2/af/rvu.c | 6 +-
> .../net/ethernet/marvell/octeontx2/af/rvu.h | 39 +-
> .../ethernet/marvell/octeontx2/af/rvu_nix.c | 701 +++++++++++++++++-
> .../ethernet/marvell/octeontx2/af/rvu_npc.c | 14 +-
> .../marvell/octeontx2/af/rvu_npc_fs.c | 73 +-
> 6 files changed, 867 insertions(+), 38 deletions(-)
>

<...>

> +
> +static int nix_add_mce_list_entry(struct rvu *rvu,
> + struct nix_hw *nix_hw,
> + struct nix_mcast_grp_elem *elem,
> + struct nix_mcast_grp_update_req *req)
> +{
> + u32 num_entry = req->num_mce_entry;
> + struct nix_mce_list *mce_list;
> + struct mce *mce;
> + int i;
> +
> + mce_list = &elem->mcast_mce_list;
> + for (i = 0; i < num_entry; i++) {
> + mce = kzalloc(sizeof(*mce), GFP_KERNEL);
> + if (!mce)
> + goto free_mce;
> +
> + mce->pcifunc = req->pcifunc[i];
> + mce->channel = req->channel[i];
> + mce->rq_rss_index = req->rq_rss_index[i];
> + mce->dest_type = req->dest_type[i];
> + mce->is_active = 1;
> + hlist_add_head(&mce->node, &mce_list->head);
> + mce_list->count++;
> + }
> +
> + mce_list->max += num_entry;
> +
> + /* Dump the updated list to HW */
> + if (elem->dir == NIX_MCAST_INGRESS)
> + return nix_update_ingress_mce_list_hw(rvu, nix_hw, elem);
> +
> + nix_update_egress_mce_list_hw(rvu, nix_hw, elem);
> + return 0;
> +
> +free_mce:
> + hlist_for_each_entry(mce, &mce_list->head, node) {

I belive that hlist_for_each_entry_safe should be used when deleting list entries.

> + hlist_del(&mce->node);
> + kfree(mce);
> + mce_list->count--;
> + }
> +
> + return -ENOMEM;
> +}
> +
> static int nix_update_mce_list_entry(struct nix_mce_list *mce_list,
> u16 pcifunc, bool add)
> {
> @@ -3079,6 +3301,7 @@ int nix_update_mce_list(struct rvu *rvu, u16 pcifunc,
> /* EOL should be set in last MCE */
> err = nix_blk_setup_mce(rvu, nix_hw, idx, NIX_AQ_INSTOP_WRITE,
> mce->pcifunc, next_idx,
> + 0, 1,
> (next_idx > last_idx) ? true : false);
> if (err)
> goto end;

<...>