Commit 6eef5242 authored by Yixing Liu's avatar Yixing Liu Committed by Jason Gunthorpe

RDMA/hns: Replace not intuitive function/macro names

Replace "sw2hw" and "hw2sw" which is hard to understand with "create" and
"destroy".

Link: https://lore.kernel.org/r/1572952082-6681-6-git-send-email-liweihang@hisilicon.comSigned-off-by: default avatarYixing Liu <liuyixing1@huawei.com>
Signed-off-by: default avatarWeihang Li <liweihang@hisilicon.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent d938d785
...@@ -115,12 +115,12 @@ enum { ...@@ -115,12 +115,12 @@ enum {
enum { enum {
/* TPT commands */ /* TPT commands */
HNS_ROCE_CMD_SW2HW_MPT = 0xd, HNS_ROCE_CMD_CREATE_MPT = 0xd,
HNS_ROCE_CMD_HW2SW_MPT = 0xf, HNS_ROCE_CMD_DESTROY_MPT = 0xf,
/* CQ commands */ /* CQ commands */
HNS_ROCE_CMD_SW2HW_CQ = 0x16, HNS_ROCE_CMD_CREATE_CQ = 0x16,
HNS_ROCE_CMD_HW2SW_CQ = 0x17, HNS_ROCE_CMD_DESTROY_CQ = 0x17,
/* QP/EE commands */ /* QP/EE commands */
HNS_ROCE_CMD_RST2INIT_QP = 0x19, HNS_ROCE_CMD_RST2INIT_QP = 0x19,
...@@ -129,14 +129,14 @@ enum { ...@@ -129,14 +129,14 @@ enum {
HNS_ROCE_CMD_RTS2RTS_QP = 0x1c, HNS_ROCE_CMD_RTS2RTS_QP = 0x1c,
HNS_ROCE_CMD_2ERR_QP = 0x1e, HNS_ROCE_CMD_2ERR_QP = 0x1e,
HNS_ROCE_CMD_RTS2SQD_QP = 0x1f, HNS_ROCE_CMD_RTS2SQD_QP = 0x1f,
HNS_ROCE_CMD_SQD2SQD_QP = 0x38,
HNS_ROCE_CMD_SQD2RTS_QP = 0x20, HNS_ROCE_CMD_SQD2RTS_QP = 0x20,
HNS_ROCE_CMD_2RST_QP = 0x21, HNS_ROCE_CMD_2RST_QP = 0x21,
HNS_ROCE_CMD_QUERY_QP = 0x22, HNS_ROCE_CMD_QUERY_QP = 0x22,
HNS_ROCE_CMD_SW2HW_SRQ = 0x70, HNS_ROCE_CMD_SQD2SQD_QP = 0x38,
HNS_ROCE_CMD_CREATE_SRQ = 0x70,
HNS_ROCE_CMD_MODIFY_SRQC = 0x72, HNS_ROCE_CMD_MODIFY_SRQC = 0x72,
HNS_ROCE_CMD_QUERY_SRQC = 0x73, HNS_ROCE_CMD_QUERY_SRQC = 0x73,
HNS_ROCE_CMD_HW2SW_SRQ = 0x74, HNS_ROCE_CMD_DESTROY_SRQ = 0x74,
}; };
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,
......
...@@ -73,12 +73,13 @@ static void hns_roce_ib_cq_event(struct hns_roce_cq *hr_cq, ...@@ -73,12 +73,13 @@ static void hns_roce_ib_cq_event(struct hns_roce_cq *hr_cq,
} }
} }
static int hns_roce_sw2hw_cq(struct hns_roce_dev *dev, static int hns_roce_hw_create_cq(struct hns_roce_dev *dev,
struct hns_roce_cmd_mailbox *mailbox, struct hns_roce_cmd_mailbox *mailbox,
unsigned long cq_num) unsigned long cq_num)
{ {
return hns_roce_cmd_mbox(dev, mailbox->dma, 0, cq_num, 0, return hns_roce_cmd_mbox(dev, mailbox->dma, 0, cq_num, 0,
HNS_ROCE_CMD_SW2HW_CQ, HNS_ROCE_CMD_TIMEOUT_MSECS); HNS_ROCE_CMD_CREATE_CQ,
HNS_ROCE_CMD_TIMEOUT_MSECS);
} }
static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent, static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
...@@ -144,7 +145,7 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent, ...@@ -144,7 +145,7 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
nent, vector); nent, vector);
/* Send mailbox to hw */ /* Send mailbox to hw */
ret = hns_roce_sw2hw_cq(hr_dev, mailbox, hr_cq->cqn); ret = hns_roce_hw_create_cq(hr_dev, mailbox, hr_cq->cqn);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
if (ret) { if (ret) {
dev_err(dev, "CQ alloc.Failed to cmd mailbox.\n"); dev_err(dev, "CQ alloc.Failed to cmd mailbox.\n");
...@@ -170,12 +171,12 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent, ...@@ -170,12 +171,12 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
return ret; return ret;
} }
static int hns_roce_hw2sw_cq(struct hns_roce_dev *dev, static int hns_roce_hw_destroy_cq(struct hns_roce_dev *dev,
struct hns_roce_cmd_mailbox *mailbox, struct hns_roce_cmd_mailbox *mailbox,
unsigned long cq_num) unsigned long cq_num)
{ {
return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, cq_num, return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, cq_num,
mailbox ? 0 : 1, HNS_ROCE_CMD_HW2SW_CQ, mailbox ? 0 : 1, HNS_ROCE_CMD_DESTROY_CQ,
HNS_ROCE_CMD_TIMEOUT_MSECS); HNS_ROCE_CMD_TIMEOUT_MSECS);
} }
...@@ -185,9 +186,9 @@ void hns_roce_free_cq(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) ...@@ -185,9 +186,9 @@ void hns_roce_free_cq(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_hw2sw_cq(hr_dev, NULL, hr_cq->cqn); ret = hns_roce_hw_destroy_cq(hr_dev, NULL, hr_cq->cqn);
if (ret) if (ret)
dev_err(dev, "HW2SW_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);
xa_erase(&cq_table->array, hr_cq->cqn); xa_erase(&cq_table->array, hr_cq->cqn);
......
...@@ -1184,9 +1184,9 @@ struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, ...@@ -1184,9 +1184,9 @@ struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
unsigned int *sg_offset); unsigned int *sg_offset);
int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
int hns_roce_hw2sw_mpt(struct hns_roce_dev *hr_dev, int hns_roce_hw_destroy_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);
unsigned long key_to_hw_index(u32 key); unsigned long key_to_hw_index(u32 key);
struct ib_mw *hns_roce_alloc_mw(struct ib_pd *pd, enum ib_mw_type, struct ib_mw *hns_roce_alloc_mw(struct ib_pd *pd, enum ib_mw_type,
......
...@@ -1114,9 +1114,10 @@ static int hns_roce_v1_dereg_mr(struct hns_roce_dev *hr_dev, ...@@ -1114,9 +1114,10 @@ static int hns_roce_v1_dereg_mr(struct hns_roce_dev *hr_dev,
free_mr = &priv->free_mr; free_mr = &priv->free_mr;
if (mr->enabled) { if (mr->enabled) {
if (hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mr->key) if (hns_roce_hw_destroy_mpt(hr_dev, NULL,
& (hr_dev->caps.num_mtpts - 1))) key_to_hw_index(mr->key) &
dev_warn(dev, "HW2SW_MPT failed!\n"); (hr_dev->caps.num_mtpts - 1)))
dev_warn(dev, "DESTROY_MPT failed!\n");
} }
mr_work = kzalloc(sizeof(*mr_work), GFP_KERNEL); mr_work = kzalloc(sizeof(*mr_work), GFP_KERNEL);
......
...@@ -48,21 +48,21 @@ unsigned long key_to_hw_index(u32 key) ...@@ -48,21 +48,21 @@ unsigned long key_to_hw_index(u32 key)
return (key << 24) | (key >> 8); return (key << 24) | (key >> 8);
} }
static int hns_roce_sw2hw_mpt(struct hns_roce_dev *hr_dev, 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, 0, return hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, mpt_index, 0,
HNS_ROCE_CMD_SW2HW_MPT, HNS_ROCE_CMD_CREATE_MPT,
HNS_ROCE_CMD_TIMEOUT_MSECS); HNS_ROCE_CMD_TIMEOUT_MSECS);
} }
int hns_roce_hw2sw_mpt(struct hns_roce_dev *hr_dev, int hns_roce_hw_destroy_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, 0, mailbox ? mailbox->dma : 0, return hns_roce_cmd_mbox(hr_dev, 0, mailbox ? mailbox->dma : 0,
mpt_index, !mailbox, HNS_ROCE_CMD_HW2SW_MPT, mpt_index, !mailbox, HNS_ROCE_CMD_DESTROY_MPT,
HNS_ROCE_CMD_TIMEOUT_MSECS); HNS_ROCE_CMD_TIMEOUT_MSECS);
} }
...@@ -707,10 +707,11 @@ static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, ...@@ -707,10 +707,11 @@ static void hns_roce_mr_free(struct hns_roce_dev *hr_dev,
int ret; int ret;
if (mr->enabled) { if (mr->enabled) {
ret = hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mr->key) ret = hns_roce_hw_destroy_mpt(hr_dev, NULL,
& (hr_dev->caps.num_mtpts - 1)); key_to_hw_index(mr->key) &
(hr_dev->caps.num_mtpts - 1));
if (ret) if (ret)
dev_warn(dev, "HW2SW_MPT failed (%d)\n", ret); dev_warn(dev, "DESTROY_MPT failed (%d)\n", ret);
} }
if (mr->size != ~0ULL) { if (mr->size != ~0ULL) {
...@@ -763,10 +764,10 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev, ...@@ -763,10 +764,10 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
goto err_page; goto err_page;
} }
ret = hns_roce_sw2hw_mpt(hr_dev, mailbox, ret = hns_roce_hw_create_mpt(hr_dev, mailbox,
mtpt_idx & (hr_dev->caps.num_mtpts - 1)); mtpt_idx & (hr_dev->caps.num_mtpts - 1));
if (ret) { if (ret) {
dev_err(dev, "SW2HW_MPT failed (%d)\n", ret); dev_err(dev, "CREATE_MPT failed (%d)\n", ret);
goto err_page; goto err_page;
} }
...@@ -1308,9 +1309,9 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length, ...@@ -1308,9 +1309,9 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
if (ret) if (ret)
goto free_cmd_mbox; goto free_cmd_mbox;
ret = hns_roce_hw2sw_mpt(hr_dev, NULL, mtpt_idx); ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, mtpt_idx);
if (ret) if (ret)
dev_warn(dev, "HW2SW_MPT failed (%d)\n", ret); dev_warn(dev, "DESTROY_MPT failed (%d)\n", ret);
mr->enabled = 0; mr->enabled = 0;
...@@ -1332,9 +1333,9 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length, ...@@ -1332,9 +1333,9 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
goto free_cmd_mbox; goto free_cmd_mbox;
} }
ret = hns_roce_sw2hw_mpt(hr_dev, mailbox, mtpt_idx); ret = hns_roce_hw_create_mpt(hr_dev, mailbox, mtpt_idx);
if (ret) { if (ret) {
dev_err(dev, "SW2HW_MPT failed (%d)\n", ret); dev_err(dev, "CREATE_MPT failed (%d)\n", ret);
ib_umem_release(mr->umem); ib_umem_release(mr->umem);
goto free_cmd_mbox; goto free_cmd_mbox;
} }
...@@ -1448,10 +1449,11 @@ static void hns_roce_mw_free(struct hns_roce_dev *hr_dev, ...@@ -1448,10 +1449,11 @@ static void hns_roce_mw_free(struct hns_roce_dev *hr_dev,
int ret; int ret;
if (mw->enabled) { if (mw->enabled) {
ret = hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mw->rkey) ret = hns_roce_hw_destroy_mpt(hr_dev, NULL,
& (hr_dev->caps.num_mtpts - 1)); key_to_hw_index(mw->rkey) &
(hr_dev->caps.num_mtpts - 1));
if (ret) if (ret)
dev_warn(dev, "MW HW2SW_MPT failed (%d)\n", ret); dev_warn(dev, "MW DESTROY_MPT failed (%d)\n", ret);
hns_roce_table_put(hr_dev, &hr_dev->mr_table.mtpt_table, hns_roce_table_put(hr_dev, &hr_dev->mr_table.mtpt_table,
key_to_hw_index(mw->rkey)); key_to_hw_index(mw->rkey));
...@@ -1487,10 +1489,10 @@ static int hns_roce_mw_enable(struct hns_roce_dev *hr_dev, ...@@ -1487,10 +1489,10 @@ static int hns_roce_mw_enable(struct hns_roce_dev *hr_dev,
goto err_page; goto err_page;
} }
ret = hns_roce_sw2hw_mpt(hr_dev, mailbox, ret = hns_roce_hw_create_mpt(hr_dev, mailbox,
mtpt_idx & (hr_dev->caps.num_mtpts - 1)); mtpt_idx & (hr_dev->caps.num_mtpts - 1));
if (ret) { if (ret) {
dev_err(dev, "MW sw2hw_mpt failed (%d)\n", ret); dev_err(dev, "MW CREATE_MPT failed (%d)\n", ret);
goto err_page; goto err_page;
} }
......
...@@ -59,21 +59,21 @@ static void hns_roce_ib_srq_event(struct hns_roce_srq *srq, ...@@ -59,21 +59,21 @@ static void hns_roce_ib_srq_event(struct hns_roce_srq *srq,
} }
} }
static int hns_roce_sw2hw_srq(struct hns_roce_dev *dev, 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, 0, return hns_roce_cmd_mbox(dev, mailbox->dma, 0, srq_num, 0,
HNS_ROCE_CMD_SW2HW_SRQ, HNS_ROCE_CMD_CREATE_SRQ,
HNS_ROCE_CMD_TIMEOUT_MSECS); HNS_ROCE_CMD_TIMEOUT_MSECS);
} }
static int hns_roce_hw2sw_srq(struct hns_roce_dev *dev, static int hns_roce_hw_destroy_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, 0, mailbox ? mailbox->dma : 0, srq_num, return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, srq_num,
mailbox ? 0 : 1, HNS_ROCE_CMD_HW2SW_SRQ, mailbox ? 0 : 1, HNS_ROCE_CMD_DESTROY_SRQ,
HNS_ROCE_CMD_TIMEOUT_MSECS); HNS_ROCE_CMD_TIMEOUT_MSECS);
} }
...@@ -134,7 +134,7 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn, ...@@ -134,7 +134,7 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn,
mtts_wqe, mtts_idx, dma_handle_wqe, mtts_wqe, mtts_idx, dma_handle_wqe,
dma_handle_idx); dma_handle_idx);
ret = hns_roce_sw2hw_srq(hr_dev, mailbox, srq->srqn); ret = hns_roce_hw_create_srq(hr_dev, mailbox, srq->srqn);
hns_roce_free_cmd_mailbox(hr_dev, mailbox); hns_roce_free_cmd_mailbox(hr_dev, mailbox);
if (ret) if (ret)
goto err_xa; goto err_xa;
...@@ -160,9 +160,9 @@ static void hns_roce_srq_free(struct hns_roce_dev *hr_dev, ...@@ -160,9 +160,9 @@ static void hns_roce_srq_free(struct hns_roce_dev *hr_dev,
struct hns_roce_srq_table *srq_table = &hr_dev->srq_table; struct hns_roce_srq_table *srq_table = &hr_dev->srq_table;
int ret; int ret;
ret = hns_roce_hw2sw_srq(hr_dev, NULL, srq->srqn); ret = hns_roce_hw_destroy_srq(hr_dev, NULL, srq->srqn);
if (ret) if (ret)
dev_err(hr_dev->dev, "HW2SW_SRQ failed (%d) for CQN %06lx\n", dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n",
ret, srq->srqn); ret, srq->srqn);
xa_erase(&srq_table->xa, srq->srqn); xa_erase(&srq_table->xa, srq->srqn);
......
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