Commit 162e29fe authored by Chengchang Tang's avatar Chengchang Tang Committed by Jason Gunthorpe

RDMA/hns: Refactor mailbox functions

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.

Link: https://lore.kernel.org/r/20220302064830.61706-6-liangwenpeng@huawei.comSigned-off-by: default avatarChengchang Tang <tangchengchang@huawei.com>
Signed-off-by: default avatarWenpeng Liang <liangwenpeng@huawei.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent e50cda2b
...@@ -38,42 +38,36 @@ ...@@ -38,42 +38,36 @@
#define CMD_POLL_TOKEN 0xffff #define CMD_POLL_TOKEN 0xffff
#define CMD_MAX_NUM 32 #define CMD_MAX_NUM 32
static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev, u64 in_param, static int hns_roce_cmd_mbox_post_hw(struct hns_roce_dev *hr_dev,
u64 out_param, u32 in_modifier, u8 op, struct hns_roce_mbox_msg *mbox_msg)
u16 token, int event)
{ {
return hr_dev->hw->post_mbox(hr_dev, in_param, out_param, in_modifier, return hr_dev->hw->post_mbox(hr_dev, mbox_msg);
op, token, event);
} }
/* this should be called with "poll_sem" */ /* this should be called with "poll_sem" */
static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param, static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev,
u64 out_param, unsigned long in_modifier, struct hns_roce_mbox_msg *mbox_msg)
u8 op)
{ {
int ret; int ret;
ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param, ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg);
in_modifier, op, CMD_POLL_TOKEN, 0);
if (ret) { if (ret) {
dev_err_ratelimited(hr_dev->dev, dev_err_ratelimited(hr_dev->dev,
"failed to post mailbox 0x%x in poll mode, ret = %d.\n", "failed to post mailbox 0x%x in poll mode, ret = %d.\n",
op, ret); mbox_msg->cmd, ret);
return ret; return ret;
} }
return hr_dev->hw->poll_mbox_done(hr_dev); return hr_dev->hw->poll_mbox_done(hr_dev);
} }
static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param, static int hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev,
u64 out_param, unsigned long in_modifier, struct hns_roce_mbox_msg *mbox_msg)
u8 op)
{ {
int ret; int ret;
down(&hr_dev->cmd.poll_sem); down(&hr_dev->cmd.poll_sem);
ret = __hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param, in_modifier, ret = __hns_roce_cmd_mbox_poll(hr_dev, mbox_msg);
op);
up(&hr_dev->cmd.poll_sem); up(&hr_dev->cmd.poll_sem);
return ret; return ret;
...@@ -97,9 +91,8 @@ void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status, ...@@ -97,9 +91,8 @@ void hns_roce_cmd_event(struct hns_roce_dev *hr_dev, u16 token, u8 status,
complete(&context->done); complete(&context->done);
} }
static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev,
u64 out_param, unsigned long in_modifier, struct hns_roce_mbox_msg *mbox_msg)
u8 op)
{ {
struct hns_roce_cmdq *cmd = &hr_dev->cmd; struct hns_roce_cmdq *cmd = &hr_dev->cmd;
struct hns_roce_cmd_context *context; struct hns_roce_cmd_context *context;
...@@ -120,19 +113,19 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, ...@@ -120,19 +113,19 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
reinit_completion(&context->done); reinit_completion(&context->done);
ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param, mbox_msg->token = context->token;
in_modifier, op, context->token, 1); ret = hns_roce_cmd_mbox_post_hw(hr_dev, mbox_msg);
if (ret) { if (ret) {
dev_err_ratelimited(dev, dev_err_ratelimited(dev,
"failed to post mailbox 0x%x in event mode, ret = %d.\n", "failed to post mailbox 0x%x in event mode, ret = %d.\n",
op, ret); mbox_msg->cmd, ret);
goto out; goto out;
} }
if (!wait_for_completion_timeout(&context->done, if (!wait_for_completion_timeout(&context->done,
msecs_to_jiffies(HNS_ROCE_CMD_TIMEOUT_MSECS))) { msecs_to_jiffies(HNS_ROCE_CMD_TIMEOUT_MSECS))) {
dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x timeout.\n", dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x timeout.\n",
context->token, op); context->token, mbox_msg->cmd);
ret = -EBUSY; ret = -EBUSY;
goto out; goto out;
} }
...@@ -140,42 +133,50 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, ...@@ -140,42 +133,50 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
ret = context->result; ret = context->result;
if (ret) if (ret)
dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x error %d.\n", dev_err_ratelimited(dev, "[cmd] token 0x%x mailbox 0x%x error %d.\n",
context->token, op, ret); context->token, mbox_msg->cmd, ret);
out: out:
context->busy = 0; context->busy = 0;
return ret; return ret;
} }
static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param, static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev,
u64 out_param, unsigned long in_modifier, struct hns_roce_mbox_msg *mbox_msg)
u8 op)
{ {
int ret; int ret;
down(&hr_dev->cmd.event_sem); down(&hr_dev->cmd.event_sem);
ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, in_modifier, ret = __hns_roce_cmd_mbox_wait(hr_dev, mbox_msg);
op);
up(&hr_dev->cmd.event_sem); up(&hr_dev->cmd.event_sem);
return ret; return ret;
} }
int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,
unsigned long in_modifier, u8 op) u8 cmd, unsigned long tag)
{ {
struct hns_roce_mbox_msg mbox_msg = {};
bool is_busy; bool is_busy;
if (hr_dev->hw->chk_mbox_avail) if (hr_dev->hw->chk_mbox_avail)
if (!hr_dev->hw->chk_mbox_avail(hr_dev, &is_busy)) if (!hr_dev->hw->chk_mbox_avail(hr_dev, &is_busy))
return is_busy ? -EBUSY : 0; return is_busy ? -EBUSY : 0;
if (hr_dev->cmd.use_events) mbox_msg.in_param = in_param;
return hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param, mbox_msg.out_param = out_param;
in_modifier, op); mbox_msg.cmd = cmd;
else mbox_msg.tag = tag;
return hns_roce_cmd_mbox_poll(hr_dev, in_param, out_param,
in_modifier, op); if (hr_dev->cmd.use_events) {
mbox_msg.event_en = 1;
return hns_roce_cmd_mbox_wait(hr_dev, &mbox_msg);
} else {
mbox_msg.event_en = 0;
mbox_msg.token = CMD_POLL_TOKEN;
return hns_roce_cmd_mbox_poll(hr_dev, &mbox_msg);
}
} }
int hns_roce_cmd_init(struct hns_roce_dev *hr_dev) int hns_roce_cmd_init(struct hns_roce_dev *hr_dev)
......
...@@ -140,7 +140,7 @@ enum { ...@@ -140,7 +140,7 @@ enum {
}; };
int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param, int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,
unsigned long in_modifier, u8 op); u8 cmd, unsigned long tag);
struct hns_roce_cmd_mailbox * struct hns_roce_cmd_mailbox *
hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev); hns_roce_alloc_cmd_mailbox(struct hns_roce_dev *hr_dev);
......
...@@ -139,9 +139,8 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) ...@@ -139,9 +139,8 @@ static int alloc_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
hr_dev->hw->write_cqc(hr_dev, hr_cq, mailbox->buf, mtts, dma_handle); hr_dev->hw->write_cqc(hr_dev, hr_cq, mailbox->buf, mtts, dma_handle);
/* Send mailbox to hw */ ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0,
ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, HNS_ROCE_CMD_CREATE_CQC, hr_cq->cqn);
HNS_ROCE_CMD_CREATE_CQC);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
if (ret) { if (ret) {
ibdev_err(ibdev, ibdev_err(ibdev,
...@@ -174,8 +173,8 @@ static void free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) ...@@ -174,8 +173,8 @@ static void free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
struct device *dev = hr_dev->dev; struct device *dev = hr_dev->dev;
int ret; int ret;
ret = hns_roce_cmd_mbox(hr_dev, 0, 0, hr_cq->cqn, ret = hns_roce_cmd_mbox(hr_dev, 0, 0, HNS_ROCE_CMD_DESTROY_CQC,
HNS_ROCE_CMD_DESTROY_CQC); hr_cq->cqn);
if (ret) if (ret)
dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret, dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret,
hr_cq->cqn); hr_cq->cqn);
......
...@@ -561,6 +561,15 @@ struct hns_roce_cmd_mailbox { ...@@ -561,6 +561,15 @@ struct hns_roce_cmd_mailbox {
dma_addr_t dma; dma_addr_t dma;
}; };
struct hns_roce_mbox_msg {
u64 in_param;
u64 out_param;
u8 cmd;
u32 tag;
u16 token;
u8 event_en;
};
struct hns_roce_dev; struct hns_roce_dev;
struct hns_roce_rinl_sge { struct hns_roce_rinl_sge {
...@@ -851,9 +860,8 @@ struct hns_roce_hw { ...@@ -851,9 +860,8 @@ struct hns_roce_hw {
int (*hw_profile)(struct hns_roce_dev *hr_dev); int (*hw_profile)(struct hns_roce_dev *hr_dev);
int (*hw_init)(struct hns_roce_dev *hr_dev); int (*hw_init)(struct hns_roce_dev *hr_dev);
void (*hw_exit)(struct hns_roce_dev *hr_dev); void (*hw_exit)(struct hns_roce_dev *hr_dev);
int (*post_mbox)(struct hns_roce_dev *hr_dev, u64 in_param, int (*post_mbox)(struct hns_roce_dev *hr_dev,
u64 out_param, u32 in_modifier, u8 op, struct hns_roce_mbox_msg *mbox_msg);
u16 token, int event);
int (*poll_mbox_done)(struct hns_roce_dev *hr_dev); int (*poll_mbox_done)(struct hns_roce_dev *hr_dev);
bool (*chk_mbox_avail)(struct hns_roce_dev *hr_dev, bool *is_busy); bool (*chk_mbox_avail)(struct hns_roce_dev *hr_dev, bool *is_busy);
int (*set_gid)(struct hns_roce_dev *hr_dev, int gid_index, int (*set_gid)(struct hns_roce_dev *hr_dev, int gid_index,
......
...@@ -1344,16 +1344,17 @@ static int hns_roce_cmq_send(struct hns_roce_dev *hr_dev, ...@@ -1344,16 +1344,17 @@ static int hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
return ret; return ret;
} }
static int config_hem_ba_to_hw(struct hns_roce_dev *hr_dev, unsigned long obj, static int config_hem_ba_to_hw(struct hns_roce_dev *hr_dev,
dma_addr_t base_addr, u8 op) dma_addr_t base_addr, u8 cmd, unsigned long tag)
{ {
struct hns_roce_cmd_mailbox *mbox = hns_roce_alloc_cmd_mailbox(hr_dev); struct hns_roce_cmd_mailbox *mbox;
int ret; int ret;
mbox = hns_roce_alloc_cmd_mailbox(hr_dev);
if (IS_ERR(mbox)) if (IS_ERR(mbox))
return PTR_ERR(mbox); return PTR_ERR(mbox);
ret = hns_roce_cmd_mbox(hr_dev, base_addr, mbox->dma, obj, op); ret = hns_roce_cmd_mbox(hr_dev, base_addr, mbox->dma, cmd, tag);
hns_roce_free_cmd_mailbox(hr_dev, mbox); hns_roce_free_cmd_mailbox(hr_dev, mbox);
return ret; return ret;
} }
...@@ -2779,21 +2780,21 @@ static void hns_roce_v2_exit(struct hns_roce_dev *hr_dev) ...@@ -2779,21 +2780,21 @@ static void hns_roce_v2_exit(struct hns_roce_dev *hr_dev)
free_dip_list(hr_dev); free_dip_list(hr_dev);
} }
static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev, u64 in_param, static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev,
u64 out_param, u32 in_modifier, struct hns_roce_mbox_msg *mbox_msg)
u8 op, u16 token, int event)
{ {
struct hns_roce_cmq_desc desc; struct hns_roce_cmq_desc desc;
struct hns_roce_post_mbox *mb = (struct hns_roce_post_mbox *)desc.data; struct hns_roce_post_mbox *mb = (struct hns_roce_post_mbox *)desc.data;
hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_POST_MB, false); hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_POST_MB, false);
mb->in_param_l = cpu_to_le32(in_param); mb->in_param_l = cpu_to_le32(mbox_msg->in_param);
mb->in_param_h = cpu_to_le32(in_param >> 32); mb->in_param_h = cpu_to_le32(mbox_msg->in_param >> 32);
mb->out_param_l = cpu_to_le32(out_param); mb->out_param_l = cpu_to_le32(mbox_msg->out_param);
mb->out_param_h = cpu_to_le32(out_param >> 32); mb->out_param_h = cpu_to_le32(mbox_msg->out_param >> 32);
mb->cmd_tag = cpu_to_le32(in_modifier << 8 | op); mb->cmd_tag = cpu_to_le32(mbox_msg->tag << 8 | mbox_msg->cmd);
mb->token_event_en = cpu_to_le32(event << 16 | token); mb->token_event_en = cpu_to_le32(mbox_msg->event_en << 16 |
mbox_msg->token);
return hns_roce_cmq_send(hr_dev, &desc, 1); return hns_roce_cmq_send(hr_dev, &desc, 1);
} }
...@@ -2846,9 +2847,8 @@ static int v2_wait_mbox_complete(struct hns_roce_dev *hr_dev, u32 timeout, ...@@ -2846,9 +2847,8 @@ static int v2_wait_mbox_complete(struct hns_roce_dev *hr_dev, u32 timeout,
return ret; return ret;
} }
static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param, static int v2_post_mbox(struct hns_roce_dev *hr_dev,
u64 out_param, u32 in_modifier, struct hns_roce_mbox_msg *mbox_msg)
u8 op, u16 token, int event)
{ {
u8 status = 0; u8 status = 0;
int ret; int ret;
...@@ -2864,8 +2864,7 @@ static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param, ...@@ -2864,8 +2864,7 @@ static int v2_post_mbox(struct hns_roce_dev *hr_dev, u64 in_param,
} }
/* Post new message to mbox */ /* Post new message to mbox */
ret = hns_roce_mbox_post(hr_dev, in_param, out_param, in_modifier, ret = hns_roce_mbox_post(hr_dev, mbox_msg);
op, token, event);
if (ret) if (ret)
dev_err_ratelimited(hr_dev->dev, dev_err_ratelimited(hr_dev->dev,
"failed to post mailbox, ret = %d.\n", ret); "failed to post mailbox, ret = %d.\n", ret);
...@@ -3818,38 +3817,38 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries, ...@@ -3818,38 +3817,38 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries,
} }
static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type, static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,
u32 step_idx, u8 *mbox_op) u32 step_idx, u8 *mbox_cmd)
{ {
u8 op; u8 cmd;
switch (type) { switch (type) {
case HEM_TYPE_QPC: case HEM_TYPE_QPC:
op = HNS_ROCE_CMD_WRITE_QPC_BT0; cmd = HNS_ROCE_CMD_WRITE_QPC_BT0;
break; break;
case HEM_TYPE_MTPT: case HEM_TYPE_MTPT:
op = HNS_ROCE_CMD_WRITE_MPT_BT0; cmd = HNS_ROCE_CMD_WRITE_MPT_BT0;
break; break;
case HEM_TYPE_CQC: case HEM_TYPE_CQC:
op = HNS_ROCE_CMD_WRITE_CQC_BT0; cmd = HNS_ROCE_CMD_WRITE_CQC_BT0;
break; break;
case HEM_TYPE_SRQC: case HEM_TYPE_SRQC:
op = HNS_ROCE_CMD_WRITE_SRQC_BT0; cmd = HNS_ROCE_CMD_WRITE_SRQC_BT0;
break; break;
case HEM_TYPE_SCCC: case HEM_TYPE_SCCC:
op = HNS_ROCE_CMD_WRITE_SCCC_BT0; cmd = HNS_ROCE_CMD_WRITE_SCCC_BT0;
break; break;
case HEM_TYPE_QPC_TIMER: case HEM_TYPE_QPC_TIMER:
op = HNS_ROCE_CMD_WRITE_QPC_TIMER_BT0; cmd = HNS_ROCE_CMD_WRITE_QPC_TIMER_BT0;
break; break;
case HEM_TYPE_CQC_TIMER: case HEM_TYPE_CQC_TIMER:
op = HNS_ROCE_CMD_WRITE_CQC_TIMER_BT0; cmd = HNS_ROCE_CMD_WRITE_CQC_TIMER_BT0;
break; break;
default: default:
dev_warn(hr_dev->dev, "failed to check hem type %u.\n", type); dev_warn(hr_dev->dev, "failed to check hem type %u.\n", type);
return -EINVAL; return -EINVAL;
} }
*mbox_op = op + step_idx; *mbox_cmd = cmd + step_idx;
return 0; return 0;
} }
...@@ -3875,7 +3874,7 @@ static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj, ...@@ -3875,7 +3874,7 @@ static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj,
dma_addr_t base_addr, u32 hem_type, u32 step_idx) dma_addr_t base_addr, u32 hem_type, u32 step_idx)
{ {
int ret; int ret;
u8 op; u8 cmd;
if (unlikely(hem_type == HEM_TYPE_GMV)) if (unlikely(hem_type == HEM_TYPE_GMV))
return config_gmv_ba_to_hw(hr_dev, obj, base_addr); return config_gmv_ba_to_hw(hr_dev, obj, base_addr);
...@@ -3883,11 +3882,11 @@ static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj, ...@@ -3883,11 +3882,11 @@ static int set_hem_to_hw(struct hns_roce_dev *hr_dev, int obj,
if (unlikely(hem_type == HEM_TYPE_SCCC && step_idx)) if (unlikely(hem_type == HEM_TYPE_SCCC && step_idx))
return 0; return 0;
ret = get_op_for_set_hem(hr_dev, hem_type, step_idx, &op); ret = get_op_for_set_hem(hr_dev, hem_type, step_idx, &cmd);
if (ret < 0) if (ret < 0)
return ret; return ret;
return config_hem_ba_to_hw(hr_dev, obj, base_addr, op); return config_hem_ba_to_hw(hr_dev, base_addr, cmd, obj);
} }
static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,
...@@ -3950,12 +3949,12 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev, ...@@ -3950,12 +3949,12 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,
} }
static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev,
struct hns_roce_hem_table *table, int obj, struct hns_roce_hem_table *table,
u32 step_idx) int tag, u32 step_idx)
{ {
struct hns_roce_cmd_mailbox *mailbox; struct hns_roce_cmd_mailbox *mailbox;
struct device *dev = hr_dev->dev; struct device *dev = hr_dev->dev;
u8 op = 0xff; u8 cmd = 0xff;
int ret; int ret;
if (!hns_roce_check_whether_mhop(hr_dev, table->type)) if (!hns_roce_check_whether_mhop(hr_dev, table->type))
...@@ -3963,16 +3962,16 @@ static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, ...@@ -3963,16 +3962,16 @@ static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev,
switch (table->type) { switch (table->type) {
case HEM_TYPE_QPC: case HEM_TYPE_QPC:
op = HNS_ROCE_CMD_DESTROY_QPC_BT0; cmd = HNS_ROCE_CMD_DESTROY_QPC_BT0;
break; break;
case HEM_TYPE_MTPT: case HEM_TYPE_MTPT:
op = HNS_ROCE_CMD_DESTROY_MPT_BT0; cmd = HNS_ROCE_CMD_DESTROY_MPT_BT0;
break; break;
case HEM_TYPE_CQC: case HEM_TYPE_CQC:
op = HNS_ROCE_CMD_DESTROY_CQC_BT0; cmd = HNS_ROCE_CMD_DESTROY_CQC_BT0;
break; break;
case HEM_TYPE_SRQC: case HEM_TYPE_SRQC:
op = HNS_ROCE_CMD_DESTROY_SRQC_BT0; cmd = HNS_ROCE_CMD_DESTROY_SRQC_BT0;
break; break;
case HEM_TYPE_SCCC: case HEM_TYPE_SCCC:
case HEM_TYPE_QPC_TIMER: case HEM_TYPE_QPC_TIMER:
...@@ -3985,14 +3984,13 @@ static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev, ...@@ -3985,14 +3984,13 @@ static int hns_roce_v2_clear_hem(struct hns_roce_dev *hr_dev,
return 0; return 0;
} }
op += step_idx; cmd += step_idx;
mailbox = hns_roce_alloc_cmd_mailbox(hr_dev); mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
if (IS_ERR(mailbox)) if (IS_ERR(mailbox))
return PTR_ERR(mailbox); return PTR_ERR(mailbox);
/* configure the tag and op */ ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, cmd, tag);
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, obj, op);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
return ret; return ret;
...@@ -4016,8 +4014,8 @@ static int hns_roce_v2_qp_modify(struct hns_roce_dev *hr_dev, ...@@ -4016,8 +4014,8 @@ static int hns_roce_v2_qp_modify(struct hns_roce_dev *hr_dev,
memcpy(mailbox->buf, context, qpc_size); memcpy(mailbox->buf, context, qpc_size);
memcpy(mailbox->buf + qpc_size, qpc_mask, qpc_size); memcpy(mailbox->buf + qpc_size, qpc_mask, qpc_size);
ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_qp->qpn, ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0,
HNS_ROCE_CMD_MODIFY_QPC); HNS_ROCE_CMD_MODIFY_QPC, hr_qp->qpn);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
...@@ -5090,8 +5088,8 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev, ...@@ -5090,8 +5088,8 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev,
if (IS_ERR(mailbox)) if (IS_ERR(mailbox))
return PTR_ERR(mailbox); return PTR_ERR(mailbox);
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, hr_qp->qpn, ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_QPC,
HNS_ROCE_CMD_QUERY_QPC); hr_qp->qpn);
if (ret) if (ret)
goto out; goto out;
...@@ -5457,8 +5455,8 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq, ...@@ -5457,8 +5455,8 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq,
hr_reg_write(srq_context, SRQC_LIMIT_WL, srq_attr->srq_limit); hr_reg_write(srq_context, SRQC_LIMIT_WL, srq_attr->srq_limit);
hr_reg_clear(srqc_mask, SRQC_LIMIT_WL); hr_reg_clear(srqc_mask, SRQC_LIMIT_WL);
ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, srq->srqn, ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0,
HNS_ROCE_CMD_MODIFY_SRQC); HNS_ROCE_CMD_MODIFY_SRQC, srq->srqn);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
if (ret) { if (ret) {
ibdev_err(&hr_dev->ib_dev, ibdev_err(&hr_dev->ib_dev,
...@@ -5484,8 +5482,8 @@ static int hns_roce_v2_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr) ...@@ -5484,8 +5482,8 @@ static int hns_roce_v2_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr)
return PTR_ERR(mailbox); return PTR_ERR(mailbox);
srq_context = mailbox->buf; srq_context = mailbox->buf;
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, srq->srqn, ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma,
HNS_ROCE_CMD_QUERY_SRQC); HNS_ROCE_CMD_QUERY_SRQC, srq->srqn);
if (ret) { if (ret) {
ibdev_err(&hr_dev->ib_dev, ibdev_err(&hr_dev->ib_dev,
"failed to process cmd of querying SRQ, ret = %d.\n", "failed to process cmd of querying SRQ, ret = %d.\n",
...@@ -5535,8 +5533,8 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period) ...@@ -5535,8 +5533,8 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period); hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period);
hr_reg_clear(cqc_mask, CQC_CQ_PERIOD); hr_reg_clear(cqc_mask, CQC_CQ_PERIOD);
ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, hr_cq->cqn, ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0,
HNS_ROCE_CMD_MODIFY_CQC); HNS_ROCE_CMD_MODIFY_CQC, hr_cq->cqn);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
if (ret) if (ret)
ibdev_err(&hr_dev->ib_dev, ibdev_err(&hr_dev->ib_dev,
...@@ -5863,13 +5861,14 @@ static void hns_roce_v2_destroy_eqc(struct hns_roce_dev *hr_dev, u32 eqn) ...@@ -5863,13 +5861,14 @@ static void hns_roce_v2_destroy_eqc(struct hns_roce_dev *hr_dev, u32 eqn)
{ {
struct device *dev = hr_dev->dev; struct device *dev = hr_dev->dev;
int ret; int ret;
u8 cmd;
if (eqn < hr_dev->caps.num_comp_vectors) if (eqn < hr_dev->caps.num_comp_vectors)
ret = hns_roce_cmd_mbox(hr_dev, 0, 0, eqn & HNS_ROCE_V2_EQN_M, cmd = HNS_ROCE_CMD_DESTROY_CEQC;
HNS_ROCE_CMD_DESTROY_CEQC);
else else
ret = hns_roce_cmd_mbox(hr_dev, 0, 0, eqn & HNS_ROCE_V2_EQN_M, cmd = HNS_ROCE_CMD_DESTROY_AEQC;
HNS_ROCE_CMD_DESTROY_AEQC);
ret = hns_roce_cmd_mbox(hr_dev, 0, 0, cmd, eqn & HNS_ROCE_V2_EQN_M);
if (ret) if (ret)
dev_err(dev, "[mailbox cmd] destroy eqc(%u) failed.\n", eqn); dev_err(dev, "[mailbox cmd] destroy eqc(%u) failed.\n", eqn);
} }
...@@ -5993,7 +5992,7 @@ static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev, ...@@ -5993,7 +5992,7 @@ static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev,
if (ret) if (ret)
goto err_cmd_mbox; goto err_cmd_mbox;
ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, eq->eqn, eq_cmd); ret = hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, eq_cmd, eq->eqn);
if (ret) { if (ret) {
dev_err(hr_dev->dev, "[mailbox cmd] create eqc failed.\n"); dev_err(hr_dev->dev, "[mailbox cmd] create eqc failed.\n");
goto err_cmd_mbox; goto err_cmd_mbox;
......
...@@ -18,8 +18,8 @@ int hns_roce_v2_query_cqc_info(struct hns_roce_dev *hr_dev, u32 cqn, ...@@ -18,8 +18,8 @@ int hns_roce_v2_query_cqc_info(struct hns_roce_dev *hr_dev, u32 cqn,
return PTR_ERR(mailbox); return PTR_ERR(mailbox);
cq_context = mailbox->buf; cq_context = mailbox->buf;
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, cqn, ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_CQC,
HNS_ROCE_CMD_QUERY_CQC); cqn);
if (ret) { if (ret) {
dev_err(hr_dev->dev, "QUERY cqc cmd process error\n"); dev_err(hr_dev->dev, "QUERY cqc cmd process error\n");
goto err_mailbox; goto err_mailbox;
......
...@@ -51,15 +51,15 @@ static int hns_roce_hw_create_mpt(struct hns_roce_dev *hr_dev, ...@@ -51,15 +51,15 @@ static int hns_roce_hw_create_mpt(struct hns_roce_dev *hr_dev,
struct hns_roce_cmd_mailbox *mailbox, struct hns_roce_cmd_mailbox *mailbox,
unsigned long mpt_index) unsigned long mpt_index)
{ {
return hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, mpt_index, return hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0,
HNS_ROCE_CMD_CREATE_MPT); HNS_ROCE_CMD_CREATE_MPT, mpt_index);
} }
int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev, int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev,
unsigned long mpt_index) unsigned long mpt_index)
{ {
return hns_roce_cmd_mbox(hr_dev, 0, 0, mpt_index, return hns_roce_cmd_mbox(hr_dev, 0, 0, HNS_ROCE_CMD_DESTROY_MPT,
HNS_ROCE_CMD_DESTROY_MPT); mpt_index);
} }
static int alloc_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) static int alloc_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr)
...@@ -300,8 +300,9 @@ struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, ...@@ -300,8 +300,9 @@ struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start,
return ERR_CAST(mailbox); return ERR_CAST(mailbox);
mtpt_idx = key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1); mtpt_idx = key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1);
ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, mtpt_idx,
HNS_ROCE_CMD_QUERY_MPT); ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_MPT,
mtpt_idx);
if (ret) if (ret)
goto free_cmd_mbox; goto free_cmd_mbox;
......
...@@ -63,14 +63,14 @@ static int hns_roce_hw_create_srq(struct hns_roce_dev *dev, ...@@ -63,14 +63,14 @@ static int hns_roce_hw_create_srq(struct hns_roce_dev *dev,
struct hns_roce_cmd_mailbox *mailbox, struct hns_roce_cmd_mailbox *mailbox,
unsigned long srq_num) unsigned long srq_num)
{ {
return hns_roce_cmd_mbox(dev, mailbox->dma, 0, srq_num, return hns_roce_cmd_mbox(dev, mailbox->dma, 0, HNS_ROCE_CMD_CREATE_SRQ,
HNS_ROCE_CMD_CREATE_SRQ); srq_num);
} }
static int hns_roce_hw_destroy_srq(struct hns_roce_dev *dev, static int hns_roce_hw_destroy_srq(struct hns_roce_dev *dev,
unsigned long srq_num) unsigned long srq_num)
{ {
return hns_roce_cmd_mbox(dev, 0, 0, srq_num, HNS_ROCE_CMD_DESTROY_SRQ); return hns_roce_cmd_mbox(dev, 0, 0, HNS_ROCE_CMD_DESTROY_SRQ, srq_num);
} }
static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment