Skip to content

Commit 13aa13d

Browse files
Weihang Lijgunthorpe
authored andcommitted
RDMA/hns: Change variables representing quantity to unsigned
Number of sge/eqe is always non-negative, they should be defined in type of unsigned. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 82d07a4 commit 13aa13d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ struct hns_roce_wq {
408408
};
409409

410410
struct hns_roce_sge {
411-
int sge_cnt; /* SGE num */
411+
unsigned int sge_cnt; /* SGE num */
412412
int offset;
413413
int sge_shift; /* SGE size */
414414
};
@@ -734,7 +734,7 @@ struct hns_roce_eq {
734734
int arm_st;
735735
int hop_num;
736736
struct hns_roce_mtr mtr;
737-
int eq_max_cnt;
737+
u16 eq_max_cnt;
738738
int eq_period;
739739
int shift;
740740
int event_type;

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void set_frmr_seg(struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
130130

131131
static void set_atomic_seg(const struct ib_send_wr *wr, void *wqe,
132132
struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
133-
int valid_num_sge)
133+
unsigned int valid_num_sge)
134134
{
135135
struct hns_roce_wqe_atomic_seg *aseg;
136136

@@ -151,12 +151,12 @@ static void set_atomic_seg(const struct ib_send_wr *wr, void *wqe,
151151
}
152152

153153
static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,
154-
unsigned int *sge_ind, int valid_num_sge)
154+
unsigned int *sge_ind, unsigned int valid_num_sge)
155155
{
156156
struct hns_roce_v2_wqe_data_seg *dseg;
157+
unsigned int cnt = valid_num_sge;
157158
struct ib_sge *sge = wr->sg_list;
158159
unsigned int idx = *sge_ind;
159-
int cnt = valid_num_sge;
160160

161161
if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) {
162162
cnt -= HNS_ROCE_SGE_IN_WQE;
@@ -177,7 +177,7 @@ static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,
177177
static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
178178
struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
179179
void *wqe, unsigned int *sge_ind,
180-
int valid_num_sge)
180+
unsigned int valid_num_sge)
181181
{
182182
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
183183
struct hns_roce_v2_wqe_data_seg *dseg = wqe;
@@ -269,10 +269,11 @@ static int check_send_valid(struct hns_roce_dev *hr_dev,
269269
return 0;
270270
}
271271

272-
static inline int calc_wr_sge_num(const struct ib_send_wr *wr, u32 *sge_len)
272+
static unsigned int calc_wr_sge_num(const struct ib_send_wr *wr,
273+
unsigned int *sge_len)
273274
{
274-
int valid_num = 0;
275-
u32 len = 0;
275+
unsigned int valid_num = 0;
276+
unsigned int len = 0;
276277
int i;
277278

278279
for (i = 0; i < wr->num_sge; i++) {
@@ -403,7 +404,7 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,
403404
{
404405
struct hns_roce_v2_rc_send_wqe *rc_sq_wqe = wqe;
405406
unsigned int curr_idx = *sge_idx;
406-
int valid_num_sge;
407+
unsigned int valid_num_sge;
407408
u32 msg_len = 0;
408409
int ret = 0;
409410

0 commit comments

Comments
 (0)