Some bugfixes and cleanups for hip08
Subsystems (2)
cover Some bugfixes and cleanups for hip08
This patchset fixes two bugs in previous patches, and does some cleanups to increase readability.
Lang Cheng (1):
RDMA/hns: Modify return value of restrack fucntions
Weihang Li (3):
RDMA/hns: remove a redundant le16_to_cpu
RDMA/hns: Fix wrong parameters when initial mtt of srq->idx_que RDMA/hns: Modify variable/field name from vlan to vlan_id
Yixing Liu (1):
RDMA/hns: Fix a spelling mistake in a macro
drivers/infiniband/hw/hns/hns_roce_ah.c | 14 +++++++------- drivers/infiniband/hw/hns/hns_roce_device.h | 4 ++-- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 10 +++++----- drivers/infiniband/hw/hns/hns_roce_qp.c | 24 ++++++++++++------------ drivers/infiniband/hw/hns/hns_roce_restrack.c | 2 +- drivers/infiniband/hw/hns/hns_roce_srq.c | 24 ++++++++++++++---------- 6 files changed, 41 insertions(+), 37 deletions(-)
Signature · 1 line
2.8.1
PATCH 1/5 RDMA/hns: remove a redundant le16_to_cpu
Type of ah->av.vlan is u16, there will be a problem using le16_to_cpu on it.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -1
@@ -389,7 +389,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,roce_set_field (ud_sq_wqe->byte_36,V2_UD_SEND_WQE_BYTE_36_VLAN_M ,V2_UD_SEND_WQE_BYTE_36_VLAN_S , -le16_to_cpu (ah->av.vlan)); + ah->av.vlan); roce_set_field(ud_sq_wqe->byte_36, V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_M, V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_S,
Signature · 1 line
2.8.1
PATCH 2/5 RDMA/hns: Fix wrong parameters when initial mtt of srq->idx_que
In reply to Weihang LiThe parameters npages used to initial mtt of srq->idx_que shouldn't be same with srq's. And page_shift should be calculated from idx_buf_pg_sz. This patch fixes above issuses and use field named npage and page_shift in hns_roce_buf instead of two temporary variables to let us use them anywhere.
--- drivers/infiniband/hw/hns/hns_roce_srq.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/infiniband/hw/hns/hns_roce_srq.c +14 -10
@@ -180,8 +180,7 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata, {struct hns_roce_dev *hr_dev =to_hr_dev (srq->ibsrq.device);struct hns_roce_ib_create_srq ucmd; -u32 page_shift; -u32 npages; +struct hns_roce_buf *buf;int ret;if (ib_copy_from_udata (&ucmd, udata,sizeof (ucmd)))
@@ -191,11 +190,13 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,if (IS_ERR (srq->umem))return PTR_ERR (srq->umem); - npages = (ib_umem_page_count (srq->umem) + - (1 << hr_dev->caps.srqwqe_buf_pg_sz) -1 ) / - (1 << hr_dev->caps.srqwqe_buf_pg_sz); - page_shift =PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz; - ret =hns_roce_mtt_init (hr_dev, npages, page_shift, &srq->mtt); + buf = &srq->buf; + buf->npages = (ib_umem_page_count (srq->umem) + + (1 << hr_dev->caps.srqwqe_buf_pg_sz) -1 ) / + (1 << hr_dev->caps.srqwqe_buf_pg_sz); + buf->page_shift =PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz; + ret =hns_roce_mtt_init (hr_dev, buf->npages, buf->page_shift, + &srq->mtt);if (ret) goto err_user_buf;
@@ -212,9 +213,12 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata, goto err_user_srq_mtt; } - ret =hns_roce_mtt_init (hr_dev,ib_umem_page_count (srq->idx_que.umem), -PAGE_SHIFT , &srq->idx_que.mtt); - + buf = &srq->idx_que.idx_buf; + buf->npages =DIV_ROUND_UP (ib_umem_page_count (srq->idx_que.umem), +1 << hr_dev->caps.idx_buf_pg_sz); + buf->page_shift =PAGE_SHIFT + hr_dev->caps.idx_buf_pg_sz; + ret =hns_roce_mtt_init (hr_dev, buf->npages, buf->page_shift, + &srq->idx_que.mtt);if (ret) {dev_err (hr_dev->dev,"hns_roce_mtt_init error for idx que\n" ); goto err_user_idx_mtt;
Signature · 1 line
2.8.1
PATCH 3/5 RDMA/hns: Modify variable/field name from vlan to vlan_id
In reply to Weihang LiThe name of vlan and vlan_tag is not clear enough, it's actually means vlan id.
--- drivers/infiniband/hw/hns/hns_roce_ah.c | 14 +++++++------- drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_ah.c +7 -7
@@ -46,32 +46,32 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr,const struct ib_gid_attr *gid_attr;struct device *dev = hr_dev->dev;struct hns_roce_ah *ah =to_hr_ah (ibah); -u16 vlan_tag =0xffff ;const struct ib_global_route *grh =rdma_ah_read_grh (ah_attr); +u16 vlan_id =0xffff ;bool vlan_en = false;int ret; gid_attr = ah_attr->grh.sgid_attr; - ret =rdma_read_gid_l2_fields (gid_attr, &vlan_tag,NULL ); + ret =rdma_read_gid_l2_fields (gid_attr, &vlan_id,NULL );if (ret)return ret;/* Get mac address */ memcpy (ah->av.mac, ah_attr->roce.dmac,ETH_ALEN ); -if (vlan_tag <VLAN_CFI_MASK ) { +if (vlan_id <VLAN_N_VID ) { vlan_en = true; - vlan_tag |= (rdma_ah_get_sl (ah_attr) & + vlan_id |= (rdma_ah_get_sl (ah_attr) &HNS_ROCE_VLAN_SL_BIT_MASK ) <<HNS_ROCE_VLAN_SL_SHIFT ; } ah->av.port =rdma_ah_get_port_num (ah_attr); ah->av.gid_index = grh->sgid_index; - ah->av.vlan = vlan_tag; + ah->av.vlan_id = vlan_id; ah->av.vlan_en = vlan_en; -dev_dbg (dev,"gid_index = 0x%x,vlan = 0x%x\n" , ah->av.gid_index, - ah->av.vlan); +dev_dbg (dev,"gid_index = 0x%x,vlan_id = 0x%x\n" , ah->av.gid_index, + ah->av.vlan_id);if (rdma_ah_get_static_rate (ah_attr)) ah->av.stat_rate =IB_RATE_10_GBPS ;
drivers/infiniband/hw/hns/hns_roce_device.h +1 -1
@@ -582,7 +582,7 @@ struct hns_roce_av {u8 tclass;u8 dgid[HNS_ROCE_GID_SIZE ];u8 mac[ETH_ALEN ]; -u16 vlan; +u16 vlan_id;bool vlan_en; };
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +5 -5
@@ -389,7 +389,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,roce_set_field (ud_sq_wqe->byte_36,V2_UD_SEND_WQE_BYTE_36_VLAN_M ,V2_UD_SEND_WQE_BYTE_36_VLAN_S , - ah->av.vlan); + ah->av.vlan_id); roce_set_field(ud_sq_wqe->byte_36, V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_M, V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_S,
@@ -4061,8 +4061,8 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,struct hns_roce_qp *hr_qp =to_hr_qp (ibqp);const struct ib_gid_attr *gid_attr =NULL ;int is_roce_protocol; +u16 vlan_id =0xffff ;bool is_udp = false; -u16 vlan =0xffff ;u8 ib_port;u8 hr_port;int ret;
@@ -4074,7 +4074,7 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,if (is_roce_protocol) { gid_attr = attr->ah_attr.grh.sgid_attr; - ret =rdma_read_gid_l2_fields (gid_attr, &vlan,NULL ); + ret =rdma_read_gid_l2_fields (gid_attr, &vlan_id,NULL );if (ret)return ret;
@@ -4083,7 +4083,7 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp, IB_GID_TYPE_ROCE_UDP_ENCAP); } -if (vlan <VLAN_CFI_MASK ) { +if (vlan_id <VLAN_N_VID ) {roce_set_bit (context->byte_76_srqn_op_en,V2_QPC_BYTE_76_RQ_VLAN_EN_S ,1 ); roce_set_bit(qpc_mask->byte_76_srqn_op_en,
@@ -4095,7 +4095,7 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp, }roce_set_field (context->byte_24_mtu_tc,V2_QPC_BYTE_24_VLAN_ID_M , -V2_QPC_BYTE_24_VLAN_ID_S , vlan); +V2_QPC_BYTE_24_VLAN_ID_S , vlan_id);roce_set_field (qpc_mask->byte_24_mtu_tc,V2_QPC_BYTE_24_VLAN_ID_M ,V2_QPC_BYTE_24_VLAN_ID_S ,0 );
Signature · 1 line
2.8.1
PATCH 4/5 RDMA/hns: Modify return value of restrack fucntions
In reply to Weihang LiFrom: Lang Cheng <[email protected]>
THe restrack function return EINVAL instead of EMSGSIZE when the driver operation fails.
--- drivers/infiniband/hw/hns/hns_roce_restrack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_restrack.c +1 -1
@@ -95,7 +95,7 @@ static int hns_roce_fill_res_cq_entry(struct sk_buff *msg, ret = hr_dev->dfx->query_cqc_info (hr_dev, hr_cq->cqn, (int *)context);if (ret) - goto err; +return -EINVAL ; table_attr =nla_nest_start (msg,RDMA_NLDEV_ATTR_DRIVER );if (!table_attr)
Signature · 1 line
2.8.1
PATCH 5/5 RDMA/hns: Fix a spelling mistake in a macro
In reply to Weihang LiFrom: Yixing Liu <[email protected]>
HNS_ROCE_ALOGN_UP should be HNS_ROCE_ALIGN_UP, this patch fix it.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- drivers/infiniband/hw/hns/hns_roce_qp.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -1
@@ -45,7 +45,7 @@#define HNS_ROCE_MAX_MSG_LEN 0x80000000 -#define HNS_ROCE_ALOGN_UP (a, b) ((((a) + (b) - 1) / (b)) * (b)) +#define HNS_ROCE_ALIGN_UP (a, b) ((((a) + (b) - 1) / (b)) * (b))#define HNS_ROCE_IB_MIN_SQ_STRIDE 6
drivers/infiniband/hw/hns/hns_roce_qp.c +12 -12
@@ -391,37 +391,37 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,/* Get buf size, SQ and RQ are aligned to page_szie */ if (hr_dev->caps.max_sq_sg <=2 ) { - hr_qp->buff_size =HNS_ROCE_ALOGN_UP ((hr_qp->rq.wqe_cnt << + hr_qp->buff_size =HNS_ROCE_ALIGN_UP ((hr_qp->rq.wqe_cnt << hr_qp->rq.wqe_shift),PAGE_SIZE ) + -HNS_ROCE_ALOGN_UP ((hr_qp->sq.wqe_cnt << +HNS_ROCE_ALIGN_UP ((hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift),PAGE_SIZE ); hr_qp->sq.offset =0 ; - hr_qp->rq.offset =HNS_ROCE_ALOGN_UP ((hr_qp->sq.wqe_cnt << + hr_qp->rq.offset =HNS_ROCE_ALIGN_UP ((hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift),PAGE_SIZE ); }else { page_size =1 << (hr_dev->caps.mtt_buf_pg_sz +PAGE_SHIFT ); hr_qp->sge.sge_cnt = ex_sge_num ?max (page_size / (1 << hr_qp->sge.sge_shift), ex_sge_num) :0 ; - hr_qp->buff_size =HNS_ROCE_ALOGN_UP ((hr_qp->rq.wqe_cnt << + hr_qp->buff_size =HNS_ROCE_ALIGN_UP ((hr_qp->rq.wqe_cnt << hr_qp->rq.wqe_shift), page_size) + -HNS_ROCE_ALOGN_UP ((hr_qp->sge.sge_cnt << +HNS_ROCE_ALIGN_UP ((hr_qp->sge.sge_cnt << hr_qp->sge.sge_shift), page_size) + -HNS_ROCE_ALOGN_UP ((hr_qp->sq.wqe_cnt << +HNS_ROCE_ALIGN_UP ((hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift), page_size); hr_qp->sq.offset =0 ;if (ex_sge_num) { - hr_qp->sge.offset =HNS_ROCE_ALOGN_UP ( + hr_qp->sge.offset =HNS_ROCE_ALIGN_UP ( (hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift), page_size); hr_qp->rq.offset = hr_qp->sge.offset + -HNS_ROCE_ALOGN_UP ((hr_qp->sge.sge_cnt << +HNS_ROCE_ALIGN_UP ((hr_qp->sge.sge_cnt << hr_qp->sge.sge_shift), page_size); }else { - hr_qp->rq.offset =HNS_ROCE_ALOGN_UP ( + hr_qp->rq.offset =HNS_ROCE_ALIGN_UP ( (hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift), page_size);
@@ -591,19 +591,19 @@ static int hns_roce_set_kernel_sq_size(struct hns_roce_dev *hr_dev,/* Get buf size, SQ and RQ are aligned to PAGE_SIZE */ page_size =1 << (hr_dev->caps.mtt_buf_pg_sz +PAGE_SHIFT ); hr_qp->sq.offset =0 ; - size =HNS_ROCE_ALOGN_UP (hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift, + size =HNS_ROCE_ALIGN_UP (hr_qp->sq.wqe_cnt << hr_qp->sq.wqe_shift, page_size);if (hr_dev->caps.max_sq_sg >2 && hr_qp->sge.sge_cnt) { hr_qp->sge.sge_cnt =max (page_size/(1 << hr_qp->sge.sge_shift), (u32 )hr_qp->sge.sge_cnt); hr_qp->sge.offset = size; - size +=HNS_ROCE_ALOGN_UP (hr_qp->sge.sge_cnt << + size +=HNS_ROCE_ALIGN_UP (hr_qp->sge.sge_cnt << hr_qp->sge.sge_shift, page_size); } hr_qp->rq.offset = size; - size +=HNS_ROCE_ALOGN_UP ((hr_qp->rq.wqe_cnt << hr_qp->rq.wqe_shift), + size +=HNS_ROCE_ALIGN_UP ((hr_qp->rq.wqe_cnt << hr_qp->rq.wqe_shift), page_size); hr_qp->buff_size = size;
Signature · 1 line
2.8.1
Quoted 15 lines · Weihang Li
This patchset fixes two bugs in previous patches, and does some cleanups
to increase readability.Lang Cheng (1):
RDMA/hns: Modify return value of restrack fucntionsWeihang Li (3):
RDMA/hns: remove a redundantle16_to_cpu
RDMA/hns: Fix wrong parameters when initial mtt ofsrq->idx_queRDMA/hns: Modify variable/field name from vlan tovlan_idYixing Liu (1):
RDMA/hns: Fix a spelling mistake in a macro
Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_ah.c | 14 +++++++------- drivers/infiniband/hw/hns/hns_roce_device.h | 4 ++-- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 10 +++++----- drivers/infiniband/hw/hns/hns_roce_qp.c | 24 ++++++++++++---- -------- drivers/infiniband/hw/hns/hns_roce_restrack.c | 2 +- drivers/infiniband/hw/hns/hns_roce_srq.c | 24 ++++++++++++++-- -------- 6 files changed, 41 insertions(+), 37 deletions(-)
I fixed some typos in the commit messages, but otherwise these look OK. Applied to for-next.
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD