diff options
author | David S. Miller <davem@davemloft.net> | 2018-05-16 11:33:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-16 11:33:09 -0400 |
commit | 7ed19eb9ea54a5639291d07d1c118695e35c6afc (patch) | |
tree | c4fe0791b3fae64ff195b7c44c07837e103b5d7b | |
parent | 0b7d9978406fba914160342be2ed8af0608bc3ec (diff) | |
parent | 6a814413eb9eb76d61de154d4f7b46e2a1558d7a (diff) |
Merge branch 'Misc-Bug-Fixes-and-clean-ups-for-HNS3-Driver'
Salil Mehta says:
====================
Misc. Bug Fixes and clean-ups for HNS3 Driver
This patch-set mainly introduces various bug fixes, cleanups and one
very small enhancement to existing HN3 driver code.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hnae3.c | 44 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hnae3.h | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 78 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 55 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 45 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 10 |
7 files changed, 164 insertions, 78 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 02145f2de820..bd3c232234d7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c | |||
@@ -50,13 +50,22 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client, | |||
50 | /* now, (un-)instantiate client by calling lower layer */ | 50 | /* now, (un-)instantiate client by calling lower layer */ |
51 | if (is_reg) { | 51 | if (is_reg) { |
52 | ret = ae_dev->ops->init_client_instance(client, ae_dev); | 52 | ret = ae_dev->ops->init_client_instance(client, ae_dev); |
53 | if (ret) | 53 | if (ret) { |
54 | dev_err(&ae_dev->pdev->dev, | 54 | dev_err(&ae_dev->pdev->dev, |
55 | "fail to instantiate client\n"); | 55 | "fail to instantiate client\n"); |
56 | return ret; | 56 | return ret; |
57 | } | ||
58 | |||
59 | hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 1); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | if (hnae_get_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B)) { | ||
64 | ae_dev->ops->uninit_client_instance(client, ae_dev); | ||
65 | |||
66 | hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 0); | ||
57 | } | 67 | } |
58 | 68 | ||
59 | ae_dev->ops->uninit_client_instance(client, ae_dev); | ||
60 | return 0; | 69 | return 0; |
61 | } | 70 | } |
62 | 71 | ||
@@ -89,7 +98,7 @@ int hnae3_register_client(struct hnae3_client *client) | |||
89 | exit: | 98 | exit: |
90 | mutex_unlock(&hnae3_common_lock); | 99 | mutex_unlock(&hnae3_common_lock); |
91 | 100 | ||
92 | return ret; | 101 | return 0; |
93 | } | 102 | } |
94 | EXPORT_SYMBOL(hnae3_register_client); | 103 | EXPORT_SYMBOL(hnae3_register_client); |
95 | 104 | ||
@@ -112,7 +121,7 @@ EXPORT_SYMBOL(hnae3_unregister_client); | |||
112 | * @ae_algo: AE algorithm | 121 | * @ae_algo: AE algorithm |
113 | * NOTE: the duplicated name will not be checked | 122 | * NOTE: the duplicated name will not be checked |
114 | */ | 123 | */ |
115 | int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) | 124 | void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) |
116 | { | 125 | { |
117 | const struct pci_device_id *id; | 126 | const struct pci_device_id *id; |
118 | struct hnae3_ae_dev *ae_dev; | 127 | struct hnae3_ae_dev *ae_dev; |
@@ -151,8 +160,6 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) | |||
151 | } | 160 | } |
152 | 161 | ||
153 | mutex_unlock(&hnae3_common_lock); | 162 | mutex_unlock(&hnae3_common_lock); |
154 | |||
155 | return ret; | ||
156 | } | 163 | } |
157 | EXPORT_SYMBOL(hnae3_register_ae_algo); | 164 | EXPORT_SYMBOL(hnae3_register_ae_algo); |
158 | 165 | ||
@@ -168,6 +175,9 @@ void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo) | |||
168 | mutex_lock(&hnae3_common_lock); | 175 | mutex_lock(&hnae3_common_lock); |
169 | /* Check if there are matched ae_dev */ | 176 | /* Check if there are matched ae_dev */ |
170 | list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) { | 177 | list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) { |
178 | if (!hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B)) | ||
179 | continue; | ||
180 | |||
171 | id = pci_match_id(ae_algo->pdev_id_table, ae_dev->pdev); | 181 | id = pci_match_id(ae_algo->pdev_id_table, ae_dev->pdev); |
172 | if (!id) | 182 | if (!id) |
173 | continue; | 183 | continue; |
@@ -191,22 +201,14 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo); | |||
191 | * @ae_dev: the AE device | 201 | * @ae_dev: the AE device |
192 | * NOTE: the duplicated name will not be checked | 202 | * NOTE: the duplicated name will not be checked |
193 | */ | 203 | */ |
194 | int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) | 204 | void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) |
195 | { | 205 | { |
196 | const struct pci_device_id *id; | 206 | const struct pci_device_id *id; |
197 | struct hnae3_ae_algo *ae_algo; | 207 | struct hnae3_ae_algo *ae_algo; |
198 | struct hnae3_client *client; | 208 | struct hnae3_client *client; |
199 | int ret = 0, lock_acquired; | 209 | int ret = 0; |
200 | 210 | ||
201 | /* we can get deadlocked if SRIOV is being enabled in context to probe | 211 | mutex_lock(&hnae3_common_lock); |
202 | * and probe gets called again in same context. This can happen when | ||
203 | * pci_enable_sriov() is called to create VFs from PF probes context. | ||
204 | * Therefore, for simplicity uniformly defering further probing in all | ||
205 | * cases where we detect contention. | ||
206 | */ | ||
207 | lock_acquired = mutex_trylock(&hnae3_common_lock); | ||
208 | if (!lock_acquired) | ||
209 | return -EPROBE_DEFER; | ||
210 | 212 | ||
211 | list_add_tail(&ae_dev->node, &hnae3_ae_dev_list); | 213 | list_add_tail(&ae_dev->node, &hnae3_ae_dev_list); |
212 | 214 | ||
@@ -220,7 +222,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
220 | 222 | ||
221 | if (!ae_dev->ops) { | 223 | if (!ae_dev->ops) { |
222 | dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n"); | 224 | dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n"); |
223 | ret = -EOPNOTSUPP; | ||
224 | goto out_err; | 225 | goto out_err; |
225 | } | 226 | } |
226 | 227 | ||
@@ -247,8 +248,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
247 | 248 | ||
248 | out_err: | 249 | out_err: |
249 | mutex_unlock(&hnae3_common_lock); | 250 | mutex_unlock(&hnae3_common_lock); |
250 | |||
251 | return ret; | ||
252 | } | 251 | } |
253 | EXPORT_SYMBOL(hnae3_register_ae_dev); | 252 | EXPORT_SYMBOL(hnae3_register_ae_dev); |
254 | 253 | ||
@@ -264,6 +263,9 @@ void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
264 | mutex_lock(&hnae3_common_lock); | 263 | mutex_lock(&hnae3_common_lock); |
265 | /* Check if there are matched ae_algo */ | 264 | /* Check if there are matched ae_algo */ |
266 | list_for_each_entry(ae_algo, &hnae3_ae_algo_list, node) { | 265 | list_for_each_entry(ae_algo, &hnae3_ae_algo_list, node) { |
266 | if (!hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B)) | ||
267 | continue; | ||
268 | |||
267 | id = pci_match_id(ae_algo->pdev_id_table, ae_dev->pdev); | 269 | id = pci_match_id(ae_algo->pdev_id_table, ae_dev->pdev); |
268 | if (!id) | 270 | if (!id) |
269 | continue; | 271 | continue; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 804ea83e1713..2f266ef96582 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h | |||
@@ -52,6 +52,7 @@ | |||
52 | #define HNAE3_DEV_INITED_B 0x0 | 52 | #define HNAE3_DEV_INITED_B 0x0 |
53 | #define HNAE3_DEV_SUPPORT_ROCE_B 0x1 | 53 | #define HNAE3_DEV_SUPPORT_ROCE_B 0x1 |
54 | #define HNAE3_DEV_SUPPORT_DCB_B 0x2 | 54 | #define HNAE3_DEV_SUPPORT_DCB_B 0x2 |
55 | #define HNAE3_CLIENT_INITED_B 0x3 | ||
55 | 56 | ||
56 | #define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\ | 57 | #define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\ |
57 | BIT(HNAE3_DEV_SUPPORT_ROCE_B)) | 58 | BIT(HNAE3_DEV_SUPPORT_ROCE_B)) |
@@ -514,11 +515,11 @@ struct hnae3_handle { | |||
514 | #define hnae_get_bit(origin, shift) \ | 515 | #define hnae_get_bit(origin, shift) \ |
515 | hnae_get_field((origin), (0x1 << (shift)), (shift)) | 516 | hnae_get_field((origin), (0x1 << (shift)), (shift)) |
516 | 517 | ||
517 | int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev); | 518 | void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev); |
518 | void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev); | 519 | void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev); |
519 | 520 | ||
520 | void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo); | 521 | void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo); |
521 | int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo); | 522 | void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo); |
522 | 523 | ||
523 | void hnae3_unregister_client(struct hnae3_client *client); | 524 | void hnae3_unregister_client(struct hnae3_client *client); |
524 | int hnae3_register_client(struct hnae3_client *client); | 525 | int hnae3_register_client(struct hnae3_client *client); |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 4031174181a0..e85ff3805c96 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | |||
@@ -1487,6 +1487,45 @@ static const struct net_device_ops hns3_nic_netdev_ops = { | |||
1487 | .ndo_set_vf_vlan = hns3_ndo_set_vf_vlan, | 1487 | .ndo_set_vf_vlan = hns3_ndo_set_vf_vlan, |
1488 | }; | 1488 | }; |
1489 | 1489 | ||
1490 | static bool hns3_is_phys_func(struct pci_dev *pdev) | ||
1491 | { | ||
1492 | u32 dev_id = pdev->device; | ||
1493 | |||
1494 | switch (dev_id) { | ||
1495 | case HNAE3_DEV_ID_GE: | ||
1496 | case HNAE3_DEV_ID_25GE: | ||
1497 | case HNAE3_DEV_ID_25GE_RDMA: | ||
1498 | case HNAE3_DEV_ID_25GE_RDMA_MACSEC: | ||
1499 | case HNAE3_DEV_ID_50GE_RDMA: | ||
1500 | case HNAE3_DEV_ID_50GE_RDMA_MACSEC: | ||
1501 | case HNAE3_DEV_ID_100G_RDMA_MACSEC: | ||
1502 | return true; | ||
1503 | case HNAE3_DEV_ID_100G_VF: | ||
1504 | case HNAE3_DEV_ID_100G_RDMA_DCB_PFC_VF: | ||
1505 | return false; | ||
1506 | default: | ||
1507 | dev_warn(&pdev->dev, "un-recognized pci device-id %d", | ||
1508 | dev_id); | ||
1509 | } | ||
1510 | |||
1511 | return false; | ||
1512 | } | ||
1513 | |||
1514 | static void hns3_disable_sriov(struct pci_dev *pdev) | ||
1515 | { | ||
1516 | /* If our VFs are assigned we cannot shut down SR-IOV | ||
1517 | * without causing issues, so just leave the hardware | ||
1518 | * available but disabled | ||
1519 | */ | ||
1520 | if (pci_vfs_assigned(pdev)) { | ||
1521 | dev_warn(&pdev->dev, | ||
1522 | "disabling driver while VFs are assigned\n"); | ||
1523 | return; | ||
1524 | } | ||
1525 | |||
1526 | pci_disable_sriov(pdev); | ||
1527 | } | ||
1528 | |||
1490 | /* hns3_probe - Device initialization routine | 1529 | /* hns3_probe - Device initialization routine |
1491 | * @pdev: PCI device information struct | 1530 | * @pdev: PCI device information struct |
1492 | * @ent: entry in hns3_pci_tbl | 1531 | * @ent: entry in hns3_pci_tbl |
@@ -1514,7 +1553,9 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1514 | ae_dev->dev_type = HNAE3_DEV_KNIC; | 1553 | ae_dev->dev_type = HNAE3_DEV_KNIC; |
1515 | pci_set_drvdata(pdev, ae_dev); | 1554 | pci_set_drvdata(pdev, ae_dev); |
1516 | 1555 | ||
1517 | return hnae3_register_ae_dev(ae_dev); | 1556 | hnae3_register_ae_dev(ae_dev); |
1557 | |||
1558 | return 0; | ||
1518 | } | 1559 | } |
1519 | 1560 | ||
1520 | /* hns3_remove - Device removal routine | 1561 | /* hns3_remove - Device removal routine |
@@ -1524,14 +1565,49 @@ static void hns3_remove(struct pci_dev *pdev) | |||
1524 | { | 1565 | { |
1525 | struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); | 1566 | struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); |
1526 | 1567 | ||
1568 | if (hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV)) | ||
1569 | hns3_disable_sriov(pdev); | ||
1570 | |||
1527 | hnae3_unregister_ae_dev(ae_dev); | 1571 | hnae3_unregister_ae_dev(ae_dev); |
1528 | } | 1572 | } |
1529 | 1573 | ||
1574 | /** | ||
1575 | * hns3_pci_sriov_configure | ||
1576 | * @pdev: pointer to a pci_dev structure | ||
1577 | * @num_vfs: number of VFs to allocate | ||
1578 | * | ||
1579 | * Enable or change the number of VFs. Called when the user updates the number | ||
1580 | * of VFs in sysfs. | ||
1581 | **/ | ||
1582 | int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs) | ||
1583 | { | ||
1584 | int ret; | ||
1585 | |||
1586 | if (!(hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV))) { | ||
1587 | dev_warn(&pdev->dev, "Can not config SRIOV\n"); | ||
1588 | return -EINVAL; | ||
1589 | } | ||
1590 | |||
1591 | if (num_vfs) { | ||
1592 | ret = pci_enable_sriov(pdev, num_vfs); | ||
1593 | if (ret) | ||
1594 | dev_err(&pdev->dev, "SRIOV enable failed %d\n", ret); | ||
1595 | } else if (!pci_vfs_assigned(pdev)) { | ||
1596 | pci_disable_sriov(pdev); | ||
1597 | } else { | ||
1598 | dev_warn(&pdev->dev, | ||
1599 | "Unable to free VFs because some are assigned to VMs.\n"); | ||
1600 | } | ||
1601 | |||
1602 | return 0; | ||
1603 | } | ||
1604 | |||
1530 | static struct pci_driver hns3_driver = { | 1605 | static struct pci_driver hns3_driver = { |
1531 | .name = hns3_driver_name, | 1606 | .name = hns3_driver_name, |
1532 | .id_table = hns3_pci_tbl, | 1607 | .id_table = hns3_pci_tbl, |
1533 | .probe = hns3_probe, | 1608 | .probe = hns3_probe, |
1534 | .remove = hns3_remove, | 1609 | .remove = hns3_remove, |
1610 | .sriov_configure = hns3_pci_sriov_configure, | ||
1535 | }; | 1611 | }; |
1536 | 1612 | ||
1537 | /* set default feature to hns3 */ | 1613 | /* set default feature to hns3 */ |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 316ec8427891..46435c85b160 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | |||
@@ -1473,21 +1473,8 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) | |||
1473 | hdev->vport = vport; | 1473 | hdev->vport = vport; |
1474 | hdev->num_alloc_vport = num_vport; | 1474 | hdev->num_alloc_vport = num_vport; |
1475 | 1475 | ||
1476 | #ifdef CONFIG_PCI_IOV | 1476 | if (IS_ENABLED(CONFIG_PCI_IOV)) |
1477 | /* Enable SRIOV */ | 1477 | hdev->num_alloc_vfs = hdev->num_req_vfs; |
1478 | if (hdev->num_req_vfs) { | ||
1479 | dev_info(&pdev->dev, "active VFs(%d) found, enabling SRIOV\n", | ||
1480 | hdev->num_req_vfs); | ||
1481 | ret = pci_enable_sriov(hdev->pdev, hdev->num_req_vfs); | ||
1482 | if (ret) { | ||
1483 | hdev->num_alloc_vfs = 0; | ||
1484 | dev_err(&pdev->dev, "SRIOV enable failed %d\n", | ||
1485 | ret); | ||
1486 | return ret; | ||
1487 | } | ||
1488 | } | ||
1489 | hdev->num_alloc_vfs = hdev->num_req_vfs; | ||
1490 | #endif | ||
1491 | 1478 | ||
1492 | for (i = 0; i < num_vport; i++) { | 1479 | for (i = 0; i < num_vport; i++) { |
1493 | vport->back = hdev; | 1480 | vport->back = hdev; |
@@ -2946,21 +2933,6 @@ static void hclge_service_task(struct work_struct *work) | |||
2946 | hclge_service_complete(hdev); | 2933 | hclge_service_complete(hdev); |
2947 | } | 2934 | } |
2948 | 2935 | ||
2949 | static void hclge_disable_sriov(struct hclge_dev *hdev) | ||
2950 | { | ||
2951 | /* If our VFs are assigned we cannot shut down SR-IOV | ||
2952 | * without causing issues, so just leave the hardware | ||
2953 | * available but disabled | ||
2954 | */ | ||
2955 | if (pci_vfs_assigned(hdev->pdev)) { | ||
2956 | dev_warn(&hdev->pdev->dev, | ||
2957 | "disabling driver while VFs are assigned\n"); | ||
2958 | return; | ||
2959 | } | ||
2960 | |||
2961 | pci_disable_sriov(hdev->pdev); | ||
2962 | } | ||
2963 | |||
2964 | struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle) | 2936 | struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle) |
2965 | { | 2937 | { |
2966 | /* VF handle has no client */ | 2938 | /* VF handle has no client */ |
@@ -3784,6 +3756,7 @@ static int hclge_ae_start(struct hnae3_handle *handle) | |||
3784 | hclge_cfg_mac_mode(hdev, true); | 3756 | hclge_cfg_mac_mode(hdev, true); |
3785 | clear_bit(HCLGE_STATE_DOWN, &hdev->state); | 3757 | clear_bit(HCLGE_STATE_DOWN, &hdev->state); |
3786 | mod_timer(&hdev->service_timer, jiffies + HZ); | 3758 | mod_timer(&hdev->service_timer, jiffies + HZ); |
3759 | hdev->hw.mac.link = 0; | ||
3787 | 3760 | ||
3788 | /* reset tqp stats */ | 3761 | /* reset tqp stats */ |
3789 | hclge_reset_tqp_stats(handle); | 3762 | hclge_reset_tqp_stats(handle); |
@@ -3820,7 +3793,6 @@ static void hclge_ae_stop(struct hnae3_handle *handle) | |||
3820 | 3793 | ||
3821 | /* reset tqp stats */ | 3794 | /* reset tqp stats */ |
3822 | hclge_reset_tqp_stats(handle); | 3795 | hclge_reset_tqp_stats(handle); |
3823 | hclge_update_link_status(hdev); | ||
3824 | } | 3796 | } |
3825 | 3797 | ||
3826 | static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport, | 3798 | static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport, |
@@ -5407,7 +5379,7 @@ static int hclge_pci_init(struct hclge_dev *hdev) | |||
5407 | ret = pci_enable_device(pdev); | 5379 | ret = pci_enable_device(pdev); |
5408 | if (ret) { | 5380 | if (ret) { |
5409 | dev_err(&pdev->dev, "failed to enable PCI device\n"); | 5381 | dev_err(&pdev->dev, "failed to enable PCI device\n"); |
5410 | goto err_no_drvdata; | 5382 | return ret; |
5411 | } | 5383 | } |
5412 | 5384 | ||
5413 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); | 5385 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
@@ -5445,8 +5417,6 @@ err_clr_master: | |||
5445 | pci_release_regions(pdev); | 5417 | pci_release_regions(pdev); |
5446 | err_disable_device: | 5418 | err_disable_device: |
5447 | pci_disable_device(pdev); | 5419 | pci_disable_device(pdev); |
5448 | err_no_drvdata: | ||
5449 | pci_set_drvdata(pdev, NULL); | ||
5450 | 5420 | ||
5451 | return ret; | 5421 | return ret; |
5452 | } | 5422 | } |
@@ -5455,6 +5425,7 @@ static void hclge_pci_uninit(struct hclge_dev *hdev) | |||
5455 | { | 5425 | { |
5456 | struct pci_dev *pdev = hdev->pdev; | 5426 | struct pci_dev *pdev = hdev->pdev; |
5457 | 5427 | ||
5428 | pcim_iounmap(pdev, hdev->hw.io_base); | ||
5458 | pci_free_irq_vectors(pdev); | 5429 | pci_free_irq_vectors(pdev); |
5459 | pci_clear_master(pdev); | 5430 | pci_clear_master(pdev); |
5460 | pci_release_mem_regions(pdev); | 5431 | pci_release_mem_regions(pdev); |
@@ -5540,7 +5511,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
5540 | ret = hclge_map_tqp(hdev); | 5511 | ret = hclge_map_tqp(hdev); |
5541 | if (ret) { | 5512 | if (ret) { |
5542 | dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret); | 5513 | dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret); |
5543 | goto err_sriov_disable; | 5514 | goto err_msi_irq_uninit; |
5544 | } | 5515 | } |
5545 | 5516 | ||
5546 | if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) { | 5517 | if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) { |
@@ -5548,7 +5519,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
5548 | if (ret) { | 5519 | if (ret) { |
5549 | dev_err(&hdev->pdev->dev, | 5520 | dev_err(&hdev->pdev->dev, |
5550 | "mdio config fail ret=%d\n", ret); | 5521 | "mdio config fail ret=%d\n", ret); |
5551 | goto err_sriov_disable; | 5522 | goto err_msi_irq_uninit; |
5552 | } | 5523 | } |
5553 | } | 5524 | } |
5554 | 5525 | ||
@@ -5612,9 +5583,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
5612 | err_mdiobus_unreg: | 5583 | err_mdiobus_unreg: |
5613 | if (hdev->hw.mac.phydev) | 5584 | if (hdev->hw.mac.phydev) |
5614 | mdiobus_unregister(hdev->hw.mac.mdio_bus); | 5585 | mdiobus_unregister(hdev->hw.mac.mdio_bus); |
5615 | err_sriov_disable: | ||
5616 | if (IS_ENABLED(CONFIG_PCI_IOV)) | ||
5617 | hclge_disable_sriov(hdev); | ||
5618 | err_msi_irq_uninit: | 5586 | err_msi_irq_uninit: |
5619 | hclge_misc_irq_uninit(hdev); | 5587 | hclge_misc_irq_uninit(hdev); |
5620 | err_msi_uninit: | 5588 | err_msi_uninit: |
@@ -5622,10 +5590,10 @@ err_msi_uninit: | |||
5622 | err_cmd_uninit: | 5590 | err_cmd_uninit: |
5623 | hclge_destroy_cmd_queue(&hdev->hw); | 5591 | hclge_destroy_cmd_queue(&hdev->hw); |
5624 | err_pci_uninit: | 5592 | err_pci_uninit: |
5593 | pcim_iounmap(pdev, hdev->hw.io_base); | ||
5625 | pci_clear_master(pdev); | 5594 | pci_clear_master(pdev); |
5626 | pci_release_regions(pdev); | 5595 | pci_release_regions(pdev); |
5627 | pci_disable_device(pdev); | 5596 | pci_disable_device(pdev); |
5628 | pci_set_drvdata(pdev, NULL); | ||
5629 | out: | 5597 | out: |
5630 | return ret; | 5598 | return ret; |
5631 | } | 5599 | } |
@@ -5717,9 +5685,6 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) | |||
5717 | 5685 | ||
5718 | set_bit(HCLGE_STATE_DOWN, &hdev->state); | 5686 | set_bit(HCLGE_STATE_DOWN, &hdev->state); |
5719 | 5687 | ||
5720 | if (IS_ENABLED(CONFIG_PCI_IOV)) | ||
5721 | hclge_disable_sriov(hdev); | ||
5722 | |||
5723 | if (hdev->service_timer.function) | 5688 | if (hdev->service_timer.function) |
5724 | del_timer_sync(&hdev->service_timer); | 5689 | del_timer_sync(&hdev->service_timer); |
5725 | if (hdev->service_task.func) | 5690 | if (hdev->service_task.func) |
@@ -6287,7 +6252,9 @@ static int hclge_init(void) | |||
6287 | { | 6252 | { |
6288 | pr_info("%s is initializing\n", HCLGE_NAME); | 6253 | pr_info("%s is initializing\n", HCLGE_NAME); |
6289 | 6254 | ||
6290 | return hnae3_register_ae_algo(&ae_algo); | 6255 | hnae3_register_ae_algo(&ae_algo); |
6256 | |||
6257 | return 0; | ||
6291 | } | 6258 | } |
6292 | 6259 | ||
6293 | static void hclge_exit(void) | 6260 | static void hclge_exit(void) |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index c69ecab460f9..262c125f8137 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | |||
@@ -500,7 +500,8 @@ static int hclge_tm_qs_schd_mode_cfg(struct hclge_dev *hdev, u16 qs_id, u8 mode) | |||
500 | return hclge_cmd_send(&hdev->hw, &desc, 1); | 500 | return hclge_cmd_send(&hdev->hw, &desc, 1); |
501 | } | 501 | } |
502 | 502 | ||
503 | static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc) | 503 | static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc, u8 grp_id, |
504 | u32 bit_map) | ||
504 | { | 505 | { |
505 | struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd; | 506 | struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd; |
506 | struct hclge_desc desc; | 507 | struct hclge_desc desc; |
@@ -511,9 +512,8 @@ static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc) | |||
511 | bp_to_qs_map_cmd = (struct hclge_bp_to_qs_map_cmd *)desc.data; | 512 | bp_to_qs_map_cmd = (struct hclge_bp_to_qs_map_cmd *)desc.data; |
512 | 513 | ||
513 | bp_to_qs_map_cmd->tc_id = tc; | 514 | bp_to_qs_map_cmd->tc_id = tc; |
514 | 515 | bp_to_qs_map_cmd->qs_group_id = grp_id; | |
515 | /* Qset and tc is one by one mapping */ | 516 | bp_to_qs_map_cmd->qs_bit_map = cpu_to_le32(bit_map); |
516 | bp_to_qs_map_cmd->qs_bit_map = cpu_to_le32(1 << tc); | ||
517 | 517 | ||
518 | return hclge_cmd_send(&hdev->hw, &desc, 1); | 518 | return hclge_cmd_send(&hdev->hw, &desc, 1); |
519 | } | 519 | } |
@@ -1167,6 +1167,41 @@ static int hclge_pfc_setup_hw(struct hclge_dev *hdev) | |||
1167 | hdev->tm_info.hw_pfc_map); | 1167 | hdev->tm_info.hw_pfc_map); |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | /* Each Tc has a 1024 queue sets to backpress, it divides to | ||
1171 | * 32 group, each group contains 32 queue sets, which can be | ||
1172 | * represented by u32 bitmap. | ||
1173 | */ | ||
1174 | static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc) | ||
1175 | { | ||
1176 | struct hclge_vport *vport = hdev->vport; | ||
1177 | u32 i, k, qs_bitmap; | ||
1178 | int ret; | ||
1179 | |||
1180 | for (i = 0; i < HCLGE_BP_GRP_NUM; i++) { | ||
1181 | qs_bitmap = 0; | ||
1182 | |||
1183 | for (k = 0; k < hdev->num_alloc_vport; k++) { | ||
1184 | u16 qs_id = vport->qs_offset + tc; | ||
1185 | u8 grp, sub_grp; | ||
1186 | |||
1187 | grp = hnae_get_field(qs_id, HCLGE_BP_GRP_ID_M, | ||
1188 | HCLGE_BP_GRP_ID_S); | ||
1189 | sub_grp = hnae_get_field(qs_id, HCLGE_BP_SUB_GRP_ID_M, | ||
1190 | HCLGE_BP_SUB_GRP_ID_S); | ||
1191 | if (i == grp) | ||
1192 | qs_bitmap |= (1 << sub_grp); | ||
1193 | |||
1194 | vport++; | ||
1195 | } | ||
1196 | |||
1197 | ret = hclge_tm_qs_bp_cfg(hdev, tc, i, qs_bitmap); | ||
1198 | if (ret) | ||
1199 | return ret; | ||
1200 | } | ||
1201 | |||
1202 | return 0; | ||
1203 | } | ||
1204 | |||
1170 | static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev) | 1205 | static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev) |
1171 | { | 1206 | { |
1172 | bool tx_en, rx_en; | 1207 | bool tx_en, rx_en; |
@@ -1218,7 +1253,7 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev) | |||
1218 | dev_warn(&hdev->pdev->dev, "set pfc pause failed:%d\n", ret); | 1253 | dev_warn(&hdev->pdev->dev, "set pfc pause failed:%d\n", ret); |
1219 | 1254 | ||
1220 | for (i = 0; i < hdev->tm_info.num_tc; i++) { | 1255 | for (i = 0; i < hdev->tm_info.num_tc; i++) { |
1221 | ret = hclge_tm_qs_bp_cfg(hdev, i); | 1256 | ret = hclge_bp_setup_hw(hdev, i); |
1222 | if (ret) | 1257 | if (ret) |
1223 | return ret; | 1258 | return ret; |
1224 | } | 1259 | } |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h index 2dbe177581e9..c2b6e8a6700f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | |||
@@ -89,6 +89,11 @@ struct hclge_pg_shapping_cmd { | |||
89 | __le32 pg_shapping_para; | 89 | __le32 pg_shapping_para; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | #define HCLGE_BP_GRP_NUM 32 | ||
93 | #define HCLGE_BP_SUB_GRP_ID_S 0 | ||
94 | #define HCLGE_BP_SUB_GRP_ID_M GENMASK(4, 0) | ||
95 | #define HCLGE_BP_GRP_ID_S 5 | ||
96 | #define HCLGE_BP_GRP_ID_M GENMASK(9, 5) | ||
92 | struct hclge_bp_to_qs_map_cmd { | 97 | struct hclge_bp_to_qs_map_cmd { |
93 | u8 tc_id; | 98 | u8 tc_id; |
94 | u8 rsvd[2]; | 99 | u8 rsvd[2]; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 2dbffcef7109..f1f4a17340a5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | |||
@@ -1563,7 +1563,7 @@ static int hclgevf_pci_init(struct hclgevf_dev *hdev) | |||
1563 | ret = pci_enable_device(pdev); | 1563 | ret = pci_enable_device(pdev); |
1564 | if (ret) { | 1564 | if (ret) { |
1565 | dev_err(&pdev->dev, "failed to enable PCI device\n"); | 1565 | dev_err(&pdev->dev, "failed to enable PCI device\n"); |
1566 | goto err_no_drvdata; | 1566 | return ret; |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); | 1569 | ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
@@ -1595,8 +1595,7 @@ err_clr_master: | |||
1595 | pci_release_regions(pdev); | 1595 | pci_release_regions(pdev); |
1596 | err_disable_device: | 1596 | err_disable_device: |
1597 | pci_disable_device(pdev); | 1597 | pci_disable_device(pdev); |
1598 | err_no_drvdata: | 1598 | |
1599 | pci_set_drvdata(pdev, NULL); | ||
1600 | return ret; | 1599 | return ret; |
1601 | } | 1600 | } |
1602 | 1601 | ||
@@ -1608,7 +1607,6 @@ static void hclgevf_pci_uninit(struct hclgevf_dev *hdev) | |||
1608 | pci_clear_master(pdev); | 1607 | pci_clear_master(pdev); |
1609 | pci_release_regions(pdev); | 1608 | pci_release_regions(pdev); |
1610 | pci_disable_device(pdev); | 1609 | pci_disable_device(pdev); |
1611 | pci_set_drvdata(pdev, NULL); | ||
1612 | } | 1610 | } |
1613 | 1611 | ||
1614 | static int hclgevf_init_hdev(struct hclgevf_dev *hdev) | 1612 | static int hclgevf_init_hdev(struct hclgevf_dev *hdev) |
@@ -1854,7 +1852,9 @@ static int hclgevf_init(void) | |||
1854 | { | 1852 | { |
1855 | pr_info("%s is initializing\n", HCLGEVF_NAME); | 1853 | pr_info("%s is initializing\n", HCLGEVF_NAME); |
1856 | 1854 | ||
1857 | return hnae3_register_ae_algo(&ae_algovf); | 1855 | hnae3_register_ae_algo(&ae_algovf); |
1856 | |||
1857 | return 0; | ||
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | static void hclgevf_exit(void) | 1860 | static void hclgevf_exit(void) |