From 0de1678211e710c2cd33e3aea98b1271cae9bd98 Mon Sep 17 00:00:00 2001 From: Luoyouming Date: Tue, 20 Sep 2022 11:47:45 +0800 Subject: [PATCH v4 01/10] libhns: Use a constant instead of sizeof operation The sge size is known to be constant, so it's unnecessary to use sizeof to calculate. Signed-off-by: Luoyouming Reviewed-by: Yangyang Li --- providers/hns/hns_roce_u_hw_v2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 0169250..d9ea18e 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -847,13 +847,12 @@ static int fill_ext_sge_inl_data(struct hns_roce_qp *qp, uint32_t num_buf, enum hns_roce_wr_buf_type buf_type) { - unsigned int sge_sz = sizeof(struct hns_roce_v2_wqe_data_seg); unsigned int sge_mask = qp->ex_sge.sge_cnt - 1; void *dst_addr, *src_addr, *tail_bound_addr; uint32_t src_len, tail_len; int i; - if (sge_info->total_len > qp->sq.max_gs * sge_sz) + if (sge_info->total_len > qp->sq.max_gs * HNS_ROCE_SGE_SIZE) return EINVAL; dst_addr = get_send_sge_ex(qp, sge_info->start_idx & sge_mask); @@ -880,7 +879,7 @@ static int fill_ext_sge_inl_data(struct hns_roce_qp *qp, } } - sge_info->valid_num = DIV_ROUND_UP(sge_info->total_len, sge_sz); + sge_info->valid_num = DIV_ROUND_UP(sge_info->total_len, HNS_ROCE_SGE_SIZE); sge_info->start_idx += sge_info->valid_num; return 0; -- 2.30.0