@@ -3373,11 +3373,33 @@ static int get_op_for_set_hem(struct hns_roce_dev *hr_dev, u32 type,
3373
3373
return op + step_idx ;
3374
3374
}
3375
3375
3376
+ static int set_hem_to_hw (struct hns_roce_dev * hr_dev , int obj , u64 bt_ba ,
3377
+ u32 hem_type , int step_idx )
3378
+ {
3379
+ struct hns_roce_cmd_mailbox * mailbox ;
3380
+ int ret ;
3381
+ int op ;
3382
+
3383
+ op = get_op_for_set_hem (hr_dev , hem_type , step_idx );
3384
+ if (op < 0 )
3385
+ return 0 ;
3386
+
3387
+ mailbox = hns_roce_alloc_cmd_mailbox (hr_dev );
3388
+ if (IS_ERR (mailbox ))
3389
+ return PTR_ERR (mailbox );
3390
+
3391
+ ret = hns_roce_cmd_mbox (hr_dev , bt_ba , mailbox -> dma , obj ,
3392
+ 0 , op , HNS_ROCE_CMD_TIMEOUT_MSECS );
3393
+
3394
+ hns_roce_free_cmd_mailbox (hr_dev , mailbox );
3395
+
3396
+ return ret ;
3397
+ }
3398
+
3376
3399
static int hns_roce_v2_set_hem (struct hns_roce_dev * hr_dev ,
3377
3400
struct hns_roce_hem_table * table , int obj ,
3378
3401
int step_idx )
3379
3402
{
3380
- struct hns_roce_cmd_mailbox * mailbox ;
3381
3403
struct hns_roce_hem_iter iter ;
3382
3404
struct hns_roce_hem_mhop mhop ;
3383
3405
struct hns_roce_hem * hem ;
@@ -3389,7 +3411,6 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,
3389
3411
u64 bt_ba = 0 ;
3390
3412
u32 chunk_ba_num ;
3391
3413
u32 hop_num ;
3392
- int op ;
3393
3414
3394
3415
if (!hns_roce_check_whether_mhop (hr_dev , table -> type ))
3395
3416
return 0 ;
@@ -3411,14 +3432,6 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,
3411
3432
hem_idx = i ;
3412
3433
}
3413
3434
3414
- op = get_op_for_set_hem (hr_dev , table -> type , step_idx );
3415
- if (op == - EINVAL )
3416
- return 0 ;
3417
-
3418
- mailbox = hns_roce_alloc_cmd_mailbox (hr_dev );
3419
- if (IS_ERR (mailbox ))
3420
- return PTR_ERR (mailbox );
3421
-
3422
3435
if (table -> type == HEM_TYPE_SCCC )
3423
3436
obj = mhop .l0_idx ;
3424
3437
@@ -3427,24 +3440,18 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,
3427
3440
for (hns_roce_hem_first (hem , & iter );
3428
3441
!hns_roce_hem_last (& iter ); hns_roce_hem_next (& iter )) {
3429
3442
bt_ba = hns_roce_hem_addr (& iter );
3430
-
3431
- /* configure the ba, tag, and op */
3432
- ret = hns_roce_cmd_mbox (hr_dev , bt_ba , mailbox -> dma ,
3433
- obj , 0 , op ,
3434
- HNS_ROCE_CMD_TIMEOUT_MSECS );
3443
+ ret = set_hem_to_hw (hr_dev , obj , bt_ba , table -> type ,
3444
+ step_idx );
3435
3445
}
3436
3446
} else {
3437
3447
if (step_idx == 0 )
3438
3448
bt_ba = table -> bt_l0_dma_addr [i ];
3439
3449
else if (step_idx == 1 && hop_num == 2 )
3440
3450
bt_ba = table -> bt_l1_dma_addr [l1_idx ];
3441
3451
3442
- /* configure the ba, tag, and op */
3443
- ret = hns_roce_cmd_mbox (hr_dev , bt_ba , mailbox -> dma , obj ,
3444
- 0 , op , HNS_ROCE_CMD_TIMEOUT_MSECS );
3452
+ ret = set_hem_to_hw (hr_dev , obj , bt_ba , table -> type , step_idx );
3445
3453
}
3446
3454
3447
- hns_roce_free_cmd_mailbox (hr_dev , mailbox );
3448
3455
return ret ;
3449
3456
}
3450
3457
0 commit comments