net: hns3: modify the VF network port media type acquisition method
authorliuzhongzhu <liuzhongzhu@huawei.com>
Thu, 4 Apr 2019 08:17:50 +0000 (16:17 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Apr 2019 17:20:38 +0000 (10:20 -0700)
Method for obtaining the media type of the VF network port periodically,
regular tasks will not run until the network port UP. When the network
port is DOWN, the network port cannot obtain the media type.
Modifies the media type obtained when initializing the VF network port.

Signed-off-by: liuzhongzhu <liuzhongzhu@huawei.com>
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>
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
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_mbx.c

index 299b277bc7ae98294d0bf42aeee787e16f7beb8d..9d3d45f02be19cf2fda5035069b153eb07363c8d 100644 (file)
@@ -43,6 +43,7 @@ enum HCLGE_MBX_OPCODE {
        HCLGE_MBX_GET_QID_IN_PF,        /* (VF -> PF) get queue id in pf */
        HCLGE_MBX_LINK_STAT_MODE,       /* (PF -> VF) link mode has changed */
        HCLGE_MBX_GET_LINK_MODE,        /* (VF -> PF) get the link mode of pf */
+       HCLGE_MBX_GET_MEDIA_TYPE,       /* (VF -> PF) get media type */
 
        HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf reset status */
 };
index 306a23e486de522c6f910d05904dd0e35f3259d5..9aa9c643afcd2bfb794959fdf13c4fa32776c388 100644 (file)
@@ -385,24 +385,32 @@ static int hclge_get_vf_queue_depth(struct hclge_vport *vport,
                                    HCLGE_TQPS_DEPTH_INFO_LEN);
 }
 
+static int hclge_get_vf_media_type(struct hclge_vport *vport,
+                                  struct hclge_mbx_vf_to_pf_cmd *mbx_req)
+{
+       struct hclge_dev *hdev = vport->back;
+       u8 resp_data;
+
+       resp_data = hdev->hw.mac.media_type;
+       return hclge_gen_resp_to_vf(vport, mbx_req, 0, &resp_data,
+                                   sizeof(resp_data));
+}
+
 static int hclge_get_link_info(struct hclge_vport *vport,
                               struct hclge_mbx_vf_to_pf_cmd *mbx_req)
 {
        struct hclge_dev *hdev = vport->back;
        u16 link_status;
-       u8 msg_data[10];
-       u16 media_type;
+       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;
-       media_type = hdev->hw.mac.media_type;
        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));
-       memcpy(&msg_data[8], &media_type, sizeof(u16));
        dest_vfid = mbx_req->mbx_src_vfid;
 
        /* send this requested info to VF */
@@ -662,6 +670,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
                        hclge_rm_vport_all_vlan_table(vport, true);
                        mutex_unlock(&hdev->vport_cfg_mutex);
                        break;
+               case HCLGE_MBX_GET_MEDIA_TYPE:
+                       ret = hclge_get_vf_media_type(vport, req);
+                       if (ret)
+                               dev_err(&hdev->pdev->dev,
+                                       "PF fail(%d) to media type for VF\n",
+                                       ret);
+                       break;
                default:
                        dev_err(&hdev->pdev->dev,
                                "un-supported mailbox message, code = %d\n",
index 65bdc689a4cee390ba4839639cb995b3232f65c2..509ff93f8cf504bbce64ce423e7497952a40e66e 100644 (file)
@@ -307,6 +307,25 @@ static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id)
        return qid_in_pf;
 }
 
+static int hclgevf_get_pf_media_type(struct hclgevf_dev *hdev)
+{
+       u8 resp_msg;
+       int ret;
+
+       ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_MEDIA_TYPE, 0, NULL, 0,
+                                  true, &resp_msg, sizeof(resp_msg));
+       if (ret) {
+               dev_err(&hdev->pdev->dev,
+                       "VF request to get the pf port media type failed %d",
+                       ret);
+               return ret;
+       }
+
+       hdev->hw.mac.media_type = resp_msg;
+
+       return 0;
+}
+
 static int hclgevf_alloc_tqps(struct hclgevf_dev *hdev)
 {
        struct hclgevf_tqp *tqp;
@@ -1824,6 +1843,10 @@ static int hclgevf_configure(struct hclgevf_dev *hdev)
        if (ret)
                return ret;
 
+       ret = hclgevf_get_pf_media_type(hdev);
+       if (ret)
+               return ret;
+
        /* get tc configuration from PF */
        return hclgevf_get_tc_info(hdev);
 }
index 7dc3c9f79169f119e53fb44c8ed929611a217878..3bcf49bde11a3c60bdfffb930b97cf726c6a2423 100644 (file)
@@ -272,7 +272,6 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev)
                        link_status = le16_to_cpu(msg_q[1]);
                        memcpy(&speed, &msg_q[2], sizeof(speed));
                        duplex = (u8)le16_to_cpu(msg_q[4]);
-                       hdev->hw.mac.media_type = (u8)le16_to_cpu(msg_q[5]);
 
                        /* update upper layer with new link link status */
                        hclgevf_update_link_status(hdev, link_status);