net: hns3: Cleanup for ROCE capability flag in ae_dev
authorYunsheng Lin <linyunsheng@huawei.com>
Wed, 20 Sep 2017 10:52:50 +0000 (18:52 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Sep 2017 23:15:39 +0000 (16:15 -0700)
This patch add the ROCE supported flag in the driver_data
field of pci_device_id, delete roce_pci_tbl and change
HNAE_DEV_SUPPORT_ROCE_B to HNAE3_DEV_SUPPORT_ROCE_B.
This cleanup is done in order to support adding capability
in pci_device_id and to fix initialization failure when
cmd is not supported.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c

index b2f28ae81273d71a6e31e3a70575570c0aae9ea2..0f7b61a92f4464111ead8319b07a675fa0cb74b2 100644 (file)
 #define HNAE3_CLASS_NAME_SIZE 16
 
 #define HNAE3_DEV_INITED_B                     0x0
-#define HNAE_DEV_SUPPORT_ROCE_B                        0x1
+#define HNAE3_DEV_SUPPORT_ROCE_B               0x1
+
+#define hnae3_dev_roce_supported(hdev) \
+       hnae_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_ROCE_B)
 
 #define ring_ptr_move_fw(ring, p) \
        ((ring)->p = ((ring)->p + 1) % (ring)->desc_num)
index 74008ef231695d11d018cf4d2bca603db24f6e32..6953d19c647526ee5b767afea0d8fcfd1e364eed 100644 (file)
@@ -46,17 +46,7 @@ static const struct pci_device_id ae_algo_pci_tbl[] = {
        {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0},
        {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0},
        {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0},
-       /* Required last entry */
-       {0, }
-};
-
-static const struct pci_device_id roce_pci_tbl[] = {
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0},
-       /* Required last entry */
+       /* required last entry */
        {0, }
 };
 
@@ -894,7 +884,7 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
        hdev->num_tqps = __le16_to_cpu(req->tqp_num);
        hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S;
 
-       if (hnae_get_bit(hdev->ae_dev->flag, HNAE_DEV_SUPPORT_ROCE_B)) {
+       if (hnae3_dev_roce_supported(hdev)) {
                hdev->num_roce_msix =
                hnae_get_field(__le16_to_cpu(req->pf_intr_vector_number),
                               HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
@@ -3932,8 +3922,7 @@ static int hclge_init_client_instance(struct hnae3_client *client,
                                goto err;
 
                        if (hdev->roce_client &&
-                           hnae_get_bit(hdev->ae_dev->flag,
-                                        HNAE_DEV_SUPPORT_ROCE_B)) {
+                           hnae3_dev_roce_supported(hdev)) {
                                struct hnae3_client *rc = hdev->roce_client;
 
                                ret = hclge_init_roce_base_info(vport);
@@ -3956,8 +3945,7 @@ static int hclge_init_client_instance(struct hnae3_client *client,
 
                        break;
                case HNAE3_CLIENT_ROCE:
-                       if (hnae_get_bit(hdev->ae_dev->flag,
-                                        HNAE_DEV_SUPPORT_ROCE_B)) {
+                       if (hnae3_dev_roce_supported(hdev)) {
                                hdev->roce_client = client;
                                vport->roce.client = client;
                        }
@@ -4069,7 +4057,6 @@ static void hclge_pci_uninit(struct hclge_dev *hdev)
 static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
 {
        struct pci_dev *pdev = ae_dev->pdev;
-       const struct pci_device_id *id;
        struct hclge_dev *hdev;
        int ret;
 
@@ -4084,10 +4071,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
        hdev->ae_dev = ae_dev;
        ae_dev->priv = hdev;
 
-       id = pci_match_id(roce_pci_tbl, ae_dev->pdev);
-       if (id)
-               hnae_set_bit(ae_dev->flag, HNAE_DEV_SUPPORT_ROCE_B, 1);
-
        ret = hclge_pci_init(hdev);
        if (ret) {
                dev_err(&pdev->dev, "PCI init failed\n");
index 4d68d6ea5143e3803945bf7d61adc32bb3498398..94d8bb5b92f091561c89ea29bd0110ce4aa2aef2 100644 (file)
@@ -41,11 +41,16 @@ static struct hnae3_client client;
 static const struct pci_device_id hns3_pci_tbl[] = {
        {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_GE), 0},
        {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC), 0},
-       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC), 0},
+       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA),
+        BIT(HNAE3_DEV_SUPPORT_ROCE_B)},
+       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_25GE_RDMA_MACSEC),
+        BIT(HNAE3_DEV_SUPPORT_ROCE_B)},
+       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA),
+        BIT(HNAE3_DEV_SUPPORT_ROCE_B)},
+       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_50GE_RDMA_MACSEC),
+        BIT(HNAE3_DEV_SUPPORT_ROCE_B)},
+       {PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_RDMA_MACSEC),
+        BIT(HNAE3_DEV_SUPPORT_ROCE_B)},
        /* required last entry */
        {0, }
 };
@@ -1348,6 +1353,7 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        ae_dev->pdev = pdev;
+       ae_dev->flag = ent->driver_data;
        ae_dev->dev_type = HNAE3_DEV_KNIC;
        pci_set_drvdata(pdev, ae_dev);