Skip to content

Commit 7df7dad

Browse files
321lipengdavem330
authored andcommitted
net: hns3: Refactor the mapping of tqp to vport
This patch refactor the mapping of tqp to vport, making the maping function can be used both in the reset process and initialization process. Signed-off-by: qumingguang <[email protected]> Signed-off-by: Lipeng <[email protected]> Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9691cea commit 7df7dad

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,11 +1184,7 @@ static int hclge_assign_tqp(struct hclge_vport *vport,
11841184
struct hnae3_queue **tqp, u16 num_tqps)
11851185
{
11861186
struct hclge_dev *hdev = vport->back;
1187-
int i, alloced, func_id, ret;
1188-
bool is_pf;
1189-
1190-
func_id = vport->vport_id;
1191-
is_pf = (vport->vport_id == 0) ? true : false;
1187+
int i, alloced;
11921188

11931189
for (i = 0, alloced = 0; i < hdev->num_tqps &&
11941190
alloced < num_tqps; i++) {
@@ -1197,12 +1193,6 @@ static int hclge_assign_tqp(struct hclge_vport *vport,
11971193
hdev->htqp[i].q.tqp_index = alloced;
11981194
tqp[alloced] = &hdev->htqp[i].q;
11991195
hdev->htqp[i].alloced = true;
1200-
ret = hclge_map_tqps_to_func(hdev, func_id,
1201-
hdev->htqp[i].index,
1202-
alloced, is_pf);
1203-
if (ret)
1204-
return ret;
1205-
12061196
alloced++;
12071197
}
12081198
}
@@ -1254,6 +1244,49 @@ static int hclge_knic_setup(struct hclge_vport *vport, u16 num_tqps)
12541244
return 0;
12551245
}
12561246

1247+
static int hclge_map_tqp_to_vport(struct hclge_dev *hdev,
1248+
struct hclge_vport *vport)
1249+
{
1250+
struct hnae3_handle *nic = &vport->nic;
1251+
struct hnae3_knic_private_info *kinfo;
1252+
u16 i;
1253+
1254+
kinfo = &nic->kinfo;
1255+
for (i = 0; i < kinfo->num_tqps; i++) {
1256+
struct hclge_tqp *q =
1257+
container_of(kinfo->tqp[i], struct hclge_tqp, q);
1258+
bool is_pf;
1259+
int ret;
1260+
1261+
is_pf = !(vport->vport_id);
1262+
ret = hclge_map_tqps_to_func(hdev, vport->vport_id, q->index,
1263+
i, is_pf);
1264+
if (ret)
1265+
return ret;
1266+
}
1267+
1268+
return 0;
1269+
}
1270+
1271+
static int hclge_map_tqp(struct hclge_dev *hdev)
1272+
{
1273+
struct hclge_vport *vport = hdev->vport;
1274+
u16 i, num_vport;
1275+
1276+
num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1;
1277+
for (i = 0; i < num_vport; i++) {
1278+
int ret;
1279+
1280+
ret = hclge_map_tqp_to_vport(hdev, vport);
1281+
if (ret)
1282+
return ret;
1283+
1284+
vport++;
1285+
}
1286+
1287+
return 0;
1288+
}
1289+
12571290
static void hclge_unic_setup(struct hclge_vport *vport, u16 num_tqps)
12581291
{
12591292
/* this would be initialized later */
@@ -4459,6 +4492,12 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
44594492
return ret;
44604493
}
44614494

4495+
ret = hclge_map_tqp(hdev);
4496+
if (ret) {
4497+
dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret);
4498+
return ret;
4499+
}
4500+
44624501
ret = hclge_mac_init(hdev);
44634502
if (ret) {
44644503
dev_err(&pdev->dev, "Mac init error, ret = %d\n", ret);

0 commit comments

Comments
 (0)