net: hns3: fix an issue for hclgevf_ae_get_hdev
authorPeng Li <lipeng321@huawei.com>
Wed, 30 Jan 2019 20:55:50 +0000 (04:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2019 08:21:17 +0000 (09:21 +0100)
[ Upstream commit eed9535f9f716a532ec0c5d6cc7a48584acdf435 ]

HNS3 VF driver support NIC and Roce, hdev stores NIC
handle and Roce handle, should use correct parameter for
container_of.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

index beae1e2..67db197 100644 (file)
@@ -26,7 +26,12 @@ MODULE_DEVICE_TABLE(pci, ae_algovf_pci_tbl);
 static inline struct hclgevf_dev *hclgevf_ae_get_hdev(
        struct hnae3_handle *handle)
 {
-       return container_of(handle, struct hclgevf_dev, nic);
+       if (!handle->client)
+               return container_of(handle, struct hclgevf_dev, nic);
+       else if (handle->client->type == HNAE3_CLIENT_ROCE)
+               return container_of(handle, struct hclgevf_dev, roce);
+       else
+               return container_of(handle, struct hclgevf_dev, nic);
 }
 
 static int hclgevf_tqps_update_stats(struct hnae3_handle *handle)