diff options
author | David S. Miller <davem@davemloft.net> | 2018-08-03 12:53:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-08-03 12:53:24 -0400 |
commit | f3184645cb0409d4ab0e63d65a0adcb565f55df4 (patch) | |
tree | 07f508e55176a24b1c4411d97db0e430d3850d67 | |
parent | 54424d3891967b83d707c9300a3509c2ae8f42ee (diff) | |
parent | 375dd5e432128ee071227e3ab0071ca11d01ac8c (diff) |
Merge branch 'hns3-next'
Salil Mehta says:
====================
Some important fixes for HNS3 driver
This patch presents some important fixes related to MSIX allocation
in HNS3 driver.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
7 files changed, 94 insertions, 20 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 6c9e5d62455b..bd031af38a96 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | |||
@@ -50,7 +50,8 @@ static const struct pci_device_id hns3_pci_tbl[] = { | |||
50 | {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), | 50 | {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), |
51 | HNAE3_DEV_SUPPORT_ROCE_DCB_BITS}, | 51 | HNAE3_DEV_SUPPORT_ROCE_DCB_BITS}, |
52 | {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_VF), 0}, | 52 | {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_VF), 0}, |
53 | {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_DCB_PFC_VF), 0}, | 53 | {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_DCB_PFC_VF), |
54 | HNAE3_DEV_SUPPORT_ROCE_DCB_BITS}, | ||
54 | /* required last entry */ | 55 | /* required last entry */ |
55 | {0, } | 56 | {0, } |
56 | }; | 57 | }; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index 5cd22f9bbdec..cd0a4f228470 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | |||
@@ -358,6 +358,8 @@ struct hclge_pf_res_cmd { | |||
358 | __le16 buf_size; | 358 | __le16 buf_size; |
359 | __le16 msixcap_localid_ba_nic; | 359 | __le16 msixcap_localid_ba_nic; |
360 | __le16 msixcap_localid_ba_rocee; | 360 | __le16 msixcap_localid_ba_rocee; |
361 | #define HCLGE_MSIX_OFT_ROCEE_S 0 | ||
362 | #define HCLGE_MSIX_OFT_ROCEE_M GENMASK(15, 0) | ||
361 | #define HCLGE_PF_VEC_NUM_S 0 | 363 | #define HCLGE_PF_VEC_NUM_S 0 |
362 | #define HCLGE_PF_VEC_NUM_M GENMASK(7, 0) | 364 | #define HCLGE_PF_VEC_NUM_M GENMASK(7, 0) |
363 | __le16 pf_intr_vector_number; | 365 | __le16 pf_intr_vector_number; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index a9b888f1544a..fc813b7f20e8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | |||
@@ -932,6 +932,9 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) | |||
932 | hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S; | 932 | hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S; |
933 | 933 | ||
934 | if (hnae3_dev_roce_supported(hdev)) { | 934 | if (hnae3_dev_roce_supported(hdev)) { |
935 | hdev->roce_base_msix_offset = | ||
936 | hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), | ||
937 | HCLGE_MSIX_OFT_ROCEE_M, HCLGE_MSIX_OFT_ROCEE_S); | ||
935 | hdev->num_roce_msi = | 938 | hdev->num_roce_msi = |
936 | hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number), | 939 | hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number), |
937 | HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S); | 940 | HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S); |
@@ -939,7 +942,8 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) | |||
939 | /* PF should have NIC vectors and Roce vectors, | 942 | /* PF should have NIC vectors and Roce vectors, |
940 | * NIC vectors are queued before Roce vectors. | 943 | * NIC vectors are queued before Roce vectors. |
941 | */ | 944 | */ |
942 | hdev->num_msi = hdev->num_roce_msi + HCLGE_ROCE_VECTOR_OFFSET; | 945 | hdev->num_msi = hdev->num_roce_msi + |
946 | hdev->roce_base_msix_offset; | ||
943 | } else { | 947 | } else { |
944 | hdev->num_msi = | 948 | hdev->num_msi = |
945 | hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number), | 949 | hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number), |
@@ -2037,7 +2041,7 @@ static int hclge_init_msi(struct hclge_dev *hdev) | |||
2037 | hdev->num_msi_left = vectors; | 2041 | hdev->num_msi_left = vectors; |
2038 | hdev->base_msi_vector = pdev->irq; | 2042 | hdev->base_msi_vector = pdev->irq; |
2039 | hdev->roce_base_vector = hdev->base_msi_vector + | 2043 | hdev->roce_base_vector = hdev->base_msi_vector + |
2040 | HCLGE_ROCE_VECTOR_OFFSET; | 2044 | hdev->roce_base_msix_offset; |
2041 | 2045 | ||
2042 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, | 2046 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, |
2043 | sizeof(u16), GFP_KERNEL); | 2047 | sizeof(u16), GFP_KERNEL); |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index dfa5c9456d22..1528fb3fa6be 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | |||
@@ -16,8 +16,6 @@ | |||
16 | 16 | ||
17 | #define HCLGE_INVALID_VPORT 0xffff | 17 | #define HCLGE_INVALID_VPORT 0xffff |
18 | 18 | ||
19 | #define HCLGE_ROCE_VECTOR_OFFSET 96 | ||
20 | |||
21 | #define HCLGE_PF_CFG_BLOCK_SIZE 32 | 19 | #define HCLGE_PF_CFG_BLOCK_SIZE 32 |
22 | #define HCLGE_PF_CFG_DESC_NUM \ | 20 | #define HCLGE_PF_CFG_DESC_NUM \ |
23 | (HCLGE_PF_CFG_BLOCK_SIZE / HCLGE_CFG_RD_LEN_BYTES) | 21 | (HCLGE_PF_CFG_BLOCK_SIZE / HCLGE_CFG_RD_LEN_BYTES) |
@@ -509,6 +507,7 @@ struct hclge_dev { | |||
509 | u16 num_msi; | 507 | u16 num_msi; |
510 | u16 num_msi_left; | 508 | u16 num_msi_left; |
511 | u16 num_msi_used; | 509 | u16 num_msi_used; |
510 | u16 roce_base_msix_offset; | ||
512 | u32 base_msi_vector; | 511 | u32 base_msi_vector; |
513 | u16 *vector_status; | 512 | u16 *vector_status; |
514 | int *vector_irq; | 513 | int *vector_irq; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h index 621c6cbacf76..19b32860309c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h | |||
@@ -82,6 +82,7 @@ struct hclgevf_cmq { | |||
82 | enum hclgevf_opcode_type { | 82 | enum hclgevf_opcode_type { |
83 | /* Generic command */ | 83 | /* Generic command */ |
84 | HCLGEVF_OPC_QUERY_FW_VER = 0x0001, | 84 | HCLGEVF_OPC_QUERY_FW_VER = 0x0001, |
85 | HCLGEVF_OPC_QUERY_VF_RSRC = 0x0024, | ||
85 | /* TQP command */ | 86 | /* TQP command */ |
86 | HCLGEVF_OPC_QUERY_TX_STATUS = 0x0B03, | 87 | HCLGEVF_OPC_QUERY_TX_STATUS = 0x0B03, |
87 | HCLGEVF_OPC_QUERY_RX_STATUS = 0x0B13, | 88 | HCLGEVF_OPC_QUERY_RX_STATUS = 0x0B13, |
@@ -134,6 +135,19 @@ struct hclgevf_query_version_cmd { | |||
134 | __le32 firmware_rsv[5]; | 135 | __le32 firmware_rsv[5]; |
135 | }; | 136 | }; |
136 | 137 | ||
138 | #define HCLGEVF_MSIX_OFT_ROCEE_S 0 | ||
139 | #define HCLGEVF_MSIX_OFT_ROCEE_M (0xffff << HCLGEVF_MSIX_OFT_ROCEE_S) | ||
140 | #define HCLGEVF_VEC_NUM_S 0 | ||
141 | #define HCLGEVF_VEC_NUM_M (0xff << HCLGEVF_VEC_NUM_S) | ||
142 | struct hclgevf_query_res_cmd { | ||
143 | __le16 tqp_num; | ||
144 | __le16 reserved; | ||
145 | __le16 msixcap_localid_ba_nic; | ||
146 | __le16 msixcap_localid_ba_rocee; | ||
147 | __le16 vf_intr_vector_number; | ||
148 | __le16 rsv[7]; | ||
149 | }; | ||
150 | |||
137 | #define HCLGEVF_RSS_HASH_KEY_OFFSET 4 | 151 | #define HCLGEVF_RSS_HASH_KEY_OFFSET 4 |
138 | #define HCLGEVF_RSS_HASH_KEY_NUM 16 | 152 | #define HCLGEVF_RSS_HASH_KEY_NUM 16 |
139 | struct hclgevf_rss_config_cmd { | 153 | struct hclgevf_rss_config_cmd { |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index d1f16f0c1646..9c0091f2addf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | |||
@@ -1370,14 +1370,13 @@ static int hclgevf_init_roce_base_info(struct hclgevf_dev *hdev) | |||
1370 | struct hnae3_handle *roce = &hdev->roce; | 1370 | struct hnae3_handle *roce = &hdev->roce; |
1371 | struct hnae3_handle *nic = &hdev->nic; | 1371 | struct hnae3_handle *nic = &hdev->nic; |
1372 | 1372 | ||
1373 | roce->rinfo.num_vectors = HCLGEVF_ROCEE_VECTOR_NUM; | 1373 | roce->rinfo.num_vectors = hdev->num_roce_msix; |
1374 | 1374 | ||
1375 | if (hdev->num_msi_left < roce->rinfo.num_vectors || | 1375 | if (hdev->num_msi_left < roce->rinfo.num_vectors || |
1376 | hdev->num_msi_left == 0) | 1376 | hdev->num_msi_left == 0) |
1377 | return -EINVAL; | 1377 | return -EINVAL; |
1378 | 1378 | ||
1379 | roce->rinfo.base_vector = | 1379 | roce->rinfo.base_vector = hdev->roce_base_vector; |
1380 | hdev->vector_status[hdev->num_msi_used]; | ||
1381 | 1380 | ||
1382 | roce->rinfo.netdev = nic->kinfo.netdev; | 1381 | roce->rinfo.netdev = nic->kinfo.netdev; |
1383 | roce->rinfo.roce_io_base = hdev->hw.io_base; | 1382 | roce->rinfo.roce_io_base = hdev->hw.io_base; |
@@ -1520,10 +1519,15 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) | |||
1520 | if (hclgevf_dev_ongoing_reset(hdev)) | 1519 | if (hclgevf_dev_ongoing_reset(hdev)) |
1521 | return 0; | 1520 | return 0; |
1522 | 1521 | ||
1523 | hdev->num_msi = HCLGEVF_MAX_VF_VECTOR_NUM; | 1522 | if (hnae3_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_ROCE_B)) |
1523 | vectors = pci_alloc_irq_vectors(pdev, | ||
1524 | hdev->roce_base_msix_offset + 1, | ||
1525 | hdev->num_msi, | ||
1526 | PCI_IRQ_MSIX); | ||
1527 | else | ||
1528 | vectors = pci_alloc_irq_vectors(pdev, 1, hdev->num_msi, | ||
1529 | PCI_IRQ_MSI | PCI_IRQ_MSIX); | ||
1524 | 1530 | ||
1525 | vectors = pci_alloc_irq_vectors(pdev, 1, hdev->num_msi, | ||
1526 | PCI_IRQ_MSI | PCI_IRQ_MSIX); | ||
1527 | if (vectors < 0) { | 1531 | if (vectors < 0) { |
1528 | dev_err(&pdev->dev, | 1532 | dev_err(&pdev->dev, |
1529 | "failed(%d) to allocate MSI/MSI-X vectors\n", | 1533 | "failed(%d) to allocate MSI/MSI-X vectors\n", |
@@ -1538,6 +1542,7 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) | |||
1538 | hdev->num_msi = vectors; | 1542 | hdev->num_msi = vectors; |
1539 | hdev->num_msi_left = vectors; | 1543 | hdev->num_msi_left = vectors; |
1540 | hdev->base_msi_vector = pdev->irq; | 1544 | hdev->base_msi_vector = pdev->irq; |
1545 | hdev->roce_base_vector = pdev->irq + hdev->roce_base_msix_offset; | ||
1541 | 1546 | ||
1542 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, | 1547 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, |
1543 | sizeof(u16), GFP_KERNEL); | 1548 | sizeof(u16), GFP_KERNEL); |
@@ -1733,6 +1738,45 @@ static void hclgevf_pci_uninit(struct hclgevf_dev *hdev) | |||
1733 | pci_disable_device(pdev); | 1738 | pci_disable_device(pdev); |
1734 | } | 1739 | } |
1735 | 1740 | ||
1741 | static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) | ||
1742 | { | ||
1743 | struct hclgevf_query_res_cmd *req; | ||
1744 | struct hclgevf_desc desc; | ||
1745 | int ret; | ||
1746 | |||
1747 | hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_QUERY_VF_RSRC, true); | ||
1748 | ret = hclgevf_cmd_send(&hdev->hw, &desc, 1); | ||
1749 | if (ret) { | ||
1750 | dev_err(&hdev->pdev->dev, | ||
1751 | "query vf resource failed, ret = %d.\n", ret); | ||
1752 | return ret; | ||
1753 | } | ||
1754 | |||
1755 | req = (struct hclgevf_query_res_cmd *)desc.data; | ||
1756 | |||
1757 | if (hnae3_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_ROCE_B)) { | ||
1758 | hdev->roce_base_msix_offset = | ||
1759 | hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), | ||
1760 | HCLGEVF_MSIX_OFT_ROCEE_M, | ||
1761 | HCLGEVF_MSIX_OFT_ROCEE_S); | ||
1762 | hdev->num_roce_msix = | ||
1763 | hnae3_get_field(__le16_to_cpu(req->vf_intr_vector_number), | ||
1764 | HCLGEVF_VEC_NUM_M, HCLGEVF_VEC_NUM_S); | ||
1765 | |||
1766 | /* VF should have NIC vectors and Roce vectors, NIC vectors | ||
1767 | * are queued before Roce vectors. The offset is fixed to 64. | ||
1768 | */ | ||
1769 | hdev->num_msi = hdev->num_roce_msix + | ||
1770 | hdev->roce_base_msix_offset; | ||
1771 | } else { | ||
1772 | hdev->num_msi = | ||
1773 | hnae3_get_field(__le16_to_cpu(req->vf_intr_vector_number), | ||
1774 | HCLGEVF_VEC_NUM_M, HCLGEVF_VEC_NUM_S); | ||
1775 | } | ||
1776 | |||
1777 | return 0; | ||
1778 | } | ||
1779 | |||
1736 | static int hclgevf_init_hdev(struct hclgevf_dev *hdev) | 1780 | static int hclgevf_init_hdev(struct hclgevf_dev *hdev) |
1737 | { | 1781 | { |
1738 | struct pci_dev *pdev = hdev->pdev; | 1782 | struct pci_dev *pdev = hdev->pdev; |
@@ -1750,18 +1794,26 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) | |||
1750 | return ret; | 1794 | return ret; |
1751 | } | 1795 | } |
1752 | 1796 | ||
1797 | ret = hclgevf_cmd_init(hdev); | ||
1798 | if (ret) | ||
1799 | goto err_cmd_init; | ||
1800 | |||
1801 | /* Get vf resource */ | ||
1802 | ret = hclgevf_query_vf_resource(hdev); | ||
1803 | if (ret) { | ||
1804 | dev_err(&hdev->pdev->dev, | ||
1805 | "Query vf status error, ret = %d.\n", ret); | ||
1806 | goto err_query_vf; | ||
1807 | } | ||
1808 | |||
1753 | ret = hclgevf_init_msi(hdev); | 1809 | ret = hclgevf_init_msi(hdev); |
1754 | if (ret) { | 1810 | if (ret) { |
1755 | dev_err(&pdev->dev, "failed(%d) to init MSI/MSI-X\n", ret); | 1811 | dev_err(&pdev->dev, "failed(%d) to init MSI/MSI-X\n", ret); |
1756 | goto err_irq_init; | 1812 | goto err_query_vf; |
1757 | } | 1813 | } |
1758 | 1814 | ||
1759 | hclgevf_state_init(hdev); | 1815 | hclgevf_state_init(hdev); |
1760 | 1816 | ||
1761 | ret = hclgevf_cmd_init(hdev); | ||
1762 | if (ret) | ||
1763 | goto err_cmd_init; | ||
1764 | |||
1765 | ret = hclgevf_misc_irq_init(hdev); | 1817 | ret = hclgevf_misc_irq_init(hdev); |
1766 | if (ret) { | 1818 | if (ret) { |
1767 | dev_err(&pdev->dev, "failed(%d) to init Misc IRQ(vector0)\n", | 1819 | dev_err(&pdev->dev, "failed(%d) to init Misc IRQ(vector0)\n", |
@@ -1817,11 +1869,11 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) | |||
1817 | err_config: | 1869 | err_config: |
1818 | hclgevf_misc_irq_uninit(hdev); | 1870 | hclgevf_misc_irq_uninit(hdev); |
1819 | err_misc_irq_init: | 1871 | err_misc_irq_init: |
1820 | hclgevf_cmd_uninit(hdev); | ||
1821 | err_cmd_init: | ||
1822 | hclgevf_state_uninit(hdev); | 1872 | hclgevf_state_uninit(hdev); |
1823 | hclgevf_uninit_msi(hdev); | 1873 | hclgevf_uninit_msi(hdev); |
1824 | err_irq_init: | 1874 | err_query_vf: |
1875 | hclgevf_cmd_uninit(hdev); | ||
1876 | err_cmd_init: | ||
1825 | hclgevf_pci_uninit(hdev); | 1877 | hclgevf_pci_uninit(hdev); |
1826 | return ret; | 1878 | return ret; |
1827 | } | 1879 | } |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 0656e8e5c5f0..b23ba171473c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #define HCLGEVF_MOD_VERSION "1.0" | 12 | #define HCLGEVF_MOD_VERSION "1.0" |
13 | #define HCLGEVF_DRIVER_NAME "hclgevf" | 13 | #define HCLGEVF_DRIVER_NAME "hclgevf" |
14 | 14 | ||
15 | #define HCLGEVF_ROCEE_VECTOR_NUM 0 | ||
16 | #define HCLGEVF_MISC_VECTOR_NUM 0 | 15 | #define HCLGEVF_MISC_VECTOR_NUM 0 |
17 | 16 | ||
18 | #define HCLGEVF_INVALID_VPORT 0xffff | 17 | #define HCLGEVF_INVALID_VPORT 0xffff |
@@ -150,6 +149,9 @@ struct hclgevf_dev { | |||
150 | u16 num_msi; | 149 | u16 num_msi; |
151 | u16 num_msi_left; | 150 | u16 num_msi_left; |
152 | u16 num_msi_used; | 151 | u16 num_msi_used; |
152 | u16 num_roce_msix; /* Num of roce vectors for this VF */ | ||
153 | u16 roce_base_msix_offset; | ||
154 | int roce_base_vector; | ||
153 | u32 base_msi_vector; | 155 | u32 base_msi_vector; |
154 | u16 *vector_status; | 156 | u16 *vector_status; |
155 | int *vector_irq; | 157 | int *vector_irq; |