On Fri, Feb 18, 2022 at 07:05:16PM +0800, Wenpeng Liang wrote: > From: Chengchang Tang <tangchengchang@xxxxxxxxxx> > > The current mailbox functions have too many parameters, making the code > difficult to maintain. So construct a new structure mbox_msg to pass the > information needed by mailbox. > > Signed-off-by: Chengchang Tang <tangchengchang@xxxxxxxxxx> > Signed-off-by: Wenpeng Liang <liangwenpeng@xxxxxxxxxx> > --- > drivers/infiniband/hw/hns/hns_roce_cmd.c | 84 +++++++------ > drivers/infiniband/hw/hns/hns_roce_cmd.h | 2 +- > drivers/infiniband/hw/hns/hns_roce_cq.c | 9 +- > drivers/infiniband/hw/hns/hns_roce_device.h | 14 ++- > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 111 +++++++++--------- > .../infiniband/hw/hns/hns_roce_hw_v2_dfx.c | 4 +- > drivers/infiniband/hw/hns/hns_roce_mr.c | 13 +- > drivers/infiniband/hw/hns/hns_roce_srq.c | 6 +- > 8 files changed, 133 insertions(+), 110 deletions(-) > > diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c > index df11acd8030e..0d4766cf6e24 100644 > --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c > +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c > @@ -38,42 +38,60 @@ > #define CMD_POLL_TOKEN 0xffff > #define CMD_MAX_NUM 32 > > -static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param, > - u64 out_param, u32 in_modifier, u8 op, > - u16 token, int event) > +static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, > + struct hns_roce_mbox_msg *mbox_msg) > { > - return hr_dev->hw->post_mbox(hr_dev, in_param, out_param, in_modifier, > - op, token, event); > + return hr_dev->hw->post_mbox(hr_dev, mbox_msg); > +} > + > +static void hns_roce_set_basic_mbox_msg(struct hns_roce_mbox_msg *mbox_msg, > + u64 in_param, u64 out_param, u8 cmd, > + unsigned long tag) > +{ > + mbox_msg->in_param = in_param; > + mbox_msg->out_param = out_param; > + mbox_msg->cmd = cmd; > + mbox_msg->tag = tag; > +} > + > +static void hns_roce_set_poll_mbox_msg(struct hns_roce_mbox_msg *mbox_msg) > +{ > + mbox_msg->event_en = 0; > + mbox_msg->token = CMD_POLL_TOKEN; > +} > + > +static void hns_roce_set_event_mbox_msg(struct hns_roce_mbox_msg *mbox_msg, > + struct hns_roce_cmd_context *context) > +{ > + mbox_msg->event_en = 1; > + mbox_msg->token = context->token; > } I don't see too much value in three functions above. They are called exactly once. Thanks