Re: [PATCH net-next v10 7/8] hinic3: Mailbox management interfaces

From: Simon Horman
Date: Wed Jul 23 2025 - 06:53:16 EST


On Tue, Jul 22, 2025 at 03:18:46PM +0800, Fan Gong wrote:

...

> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c

...

> @@ -25,6 +42,20 @@
> #define MBOX_LAST_SEG_MAX_LEN \
> (MBOX_MAX_BUF_SZ - MBOX_SEQ_ID_MAX_VAL * MBOX_SEG_LEN)
>
> +/* mbox write back status is 16B, only first 4B is used */
> +#define MBOX_WB_STATUS_ERRCODE_MASK 0xFFFF
> +#define MBOX_WB_STATUS_MASK 0xFF
> +#define MBOX_WB_ERROR_CODE_MASK 0xFF00
> +#define MBOX_WB_STATUS_FINISHED_SUCCESS 0xFF
> +#define MBOX_WB_STATUS_NOT_FINISHED 0x00
> +
> +#define MBOX_STATUS_FINISHED(wb) \
> + (((wb) & MBOX_WB_STATUS_MASK) != MBOX_WB_STATUS_NOT_FINISHED)
> +#define MBOX_STATUS_SUCCESS(wb) \
> + (((wb) & MBOX_WB_STATUS_MASK) == MBOX_WB_STATUS_FINISHED_SUCCESS)
> +#define MBOX_STATUS_ERRCODE(wb) \
> + ((wb) & MBOX_WB_ERROR_CODE_MASK)

These look ripe for using FIELD_PREP.

...

> +static bool is_msg_queue_full(struct mbox_dma_queue *mq)
> +{
> + return (MBOX_MQ_ID_MASK(mq, (mq)->prod_idx + 1) ==
> + MBOX_MQ_ID_MASK(mq, (mq)->cons_idx));

nit: unnecessary outer parentheses.

...

> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.h b/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.h
> index ec4cae0a0929..2bf7a70251bb 100644
> --- a/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.h
> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.h
> @@ -48,6 +48,7 @@ static inline void *get_q_element(const struct hinic3_queue_pages *qpages,
> *remaining_in_page = elem_per_pg - elem_idx;
> ofs = elem_idx << qpages->elem_size_shift;
> page = qpages->pages + page_idx;
> +
> return (char *)page->align_vaddr + ofs;
> }

nit: This hunk seems unrelated to the rest of the patch.