]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: hns3: add querying speed and duplex support to VF
authorFuyun Liang <liangfuyun1@huawei.com>
Wed, 21 Mar 2018 07:49:29 +0000 (15:49 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Mar 2018 17:12:02 +0000 (13:12 -0400)
This patch adds support for querying speed and duplex by ethtool ethX
to VF.

Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c

index cef14e73edb8aac7c357874a283ab0c12ce9e4d3..949da0c993cfe5a605bbd33a36430f304e7ee400 100644 (file)
@@ -309,16 +309,20 @@ static int hclge_get_link_info(struct hclge_vport *vport,
 {
        struct hclge_dev *hdev = vport->back;
        u16 link_status;
-       u8 msg_data[2];
+       u8 msg_data[8];
        u8 dest_vfid;
+       u16 duplex;
 
        /* mac.link can only be 0 or 1 */
        link_status = (u16)hdev->hw.mac.link;
+       duplex = hdev->hw.mac.duplex;
        memcpy(&msg_data[0], &link_status, sizeof(u16));
+       memcpy(&msg_data[2], &hdev->hw.mac.speed, sizeof(u32));
+       memcpy(&msg_data[6], &duplex, sizeof(u16));
        dest_vfid = mbx_req->mbx_src_vfid;
 
        /* send this requested info to VF */
-       return hclge_send_mbx_msg(vport, msg_data, sizeof(u8),
+       return hclge_send_mbx_msg(vport, msg_data, sizeof(msg_data),
                                  HCLGE_MBX_LINK_STAT_CHANGE, dest_vfid);
 }
 
index f917a1e9783d70f3c03c0f635e65d88bda9718f2..906dfa3d0fc6e9a680a5c755770b3a13d05fd391 100644 (file)
@@ -1475,6 +1475,27 @@ static int hclgevf_get_status(struct hnae3_handle *handle)
        return hdev->hw.mac.link;
 }
 
+static void hclgevf_get_ksettings_an_result(struct hnae3_handle *handle,
+                                           u8 *auto_neg, u32 *speed,
+                                           u8 *duplex)
+{
+       struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
+
+       if (speed)
+               *speed = hdev->hw.mac.speed;
+       if (duplex)
+               *duplex = hdev->hw.mac.duplex;
+       if (auto_neg)
+               *auto_neg = AUTONEG_DISABLE;
+}
+
+void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed,
+                                u8 duplex)
+{
+       hdev->hw.mac.speed = speed;
+       hdev->hw.mac.duplex = duplex;
+}
+
 static const struct hnae3_ae_ops hclgevf_ops = {
        .init_ae_dev = hclgevf_init_ae_dev,
        .uninit_ae_dev = hclgevf_uninit_ae_dev,
@@ -1508,6 +1529,7 @@ static const struct hnae3_ae_ops hclgevf_ops = {
        .get_channels = hclgevf_get_channels,
        .get_tqps_and_rss_info = hclgevf_get_tqps_and_rss_info,
        .get_status = hclgevf_get_status,
+       .get_ksettings_an_result = hclgevf_get_ksettings_an_result,
 };
 
 static struct hnae3_ae_algo ae_algovf = {
index a63bee4a36744c847d28ba4842795c3fa9a9f5bd..0eaea063e7c5b21b6c89345954c526659dfcc137 100644 (file)
@@ -61,6 +61,8 @@ enum hclgevf_states {
 struct hclgevf_mac {
        u8 mac_addr[ETH_ALEN];
        int link;
+       u8 duplex;
+       u32 speed;
 };
 
 struct hclgevf_hw {
@@ -161,4 +163,6 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode,
                         u8 *resp_data, u16 resp_len);
 void hclgevf_mbx_handler(struct hclgevf_dev *hdev);
 void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state);
+void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed,
+                                u8 duplex);
 #endif
index 9768f71f5b182b34a16e84d1ca468b6ce2b7da91..a63ed3aa2c00534df3e337941ea7bbc0f83a76ab 100644 (file)
@@ -133,6 +133,8 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
        struct hclgevf_cmq_ring *crq;
        struct hclgevf_desc *desc;
        u16 link_status, flag;
+       u32 speed;
+       u8 duplex;
        u8 *temp;
        int i;
 
@@ -164,9 +166,12 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
                        break;
                case HCLGE_MBX_LINK_STAT_CHANGE:
                        link_status = le16_to_cpu(req->msg[1]);
+                       memcpy(&speed, &req->msg[2], sizeof(speed));
+                       duplex = (u8)le16_to_cpu(req->msg[4]);
 
                        /* update upper layer with new link link status */
                        hclgevf_update_link_status(hdev, link_status);
+                       hclgevf_update_speed_duplex(hdev, speed, duplex);
 
                        break;
                default: