net: hns3: Changes required in PF mailbox to support VF reset
authorSalil Mehta <salil.mehta@huawei.com>
Thu, 22 Mar 2018 14:29:00 +0000 (14:29 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Mar 2018 19:29:04 +0000 (15:29 -0400)
PF needs to assert the VF reset when it receives the request to
reset from VF. After receiving request PF ackknowledges the
request by replying back MBX_ASSERTING_RESET message to VF.
VF then goes to pending state and wait for hardware to complete
the reset.

This patch contains code to handle the received VF message, inform
the VF of assertion and reset the VF using cmdq interface.

Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c

index a3e00da3dff079a00dd3c06a2d214ec12379b2e8..bede4117bad9dff1100bdc232393d94df8abf103 100644 (file)
@@ -2749,7 +2749,7 @@ static int hclge_reset_wait(struct hclge_dev *hdev)
        return 0;
 }
 
-static int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id)
+int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id)
 {
        struct hclge_desc desc;
        struct hclge_reset_cmd *req = (struct hclge_reset_cmd *)desc.data;
index 8c14d10c88cb55d7d230835755801be025e16b55..0f4157e7128215467e22b04654046182d8387425 100644 (file)
@@ -657,4 +657,5 @@ void hclge_mbx_handler(struct hclge_dev *hdev);
 void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id);
 void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id);
 int hclge_cfg_flowctrl(struct hclge_dev *hdev);
+int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);
 #endif
index 949da0c993cfe5a605bbd33a36430f304e7ee400..39013334a613202c1bc546530dd90364bb37cfa0 100644 (file)
@@ -79,6 +79,18 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
        return status;
 }
 
+int hclge_inform_reset_assert_to_vf(struct hclge_vport *vport)
+{
+       u8 msg_data[2];
+       u8 dest_vfid;
+
+       dest_vfid = (u8)vport->vport_id;
+
+       /* send this requested info to VF */
+       return hclge_send_mbx_msg(vport, msg_data, sizeof(u8),
+                                 HCLGE_MBX_ASSERTING_RESET, dest_vfid);
+}
+
 static void hclge_free_vector_ring_chain(struct hnae3_ring_chain_node *head)
 {
        struct hnae3_ring_chain_node *chain_tmp, *chain;
@@ -339,6 +351,33 @@ static void hclge_mbx_reset_vf_queue(struct hclge_vport *vport,
        hclge_gen_resp_to_vf(vport, mbx_req, 0, NULL, 0);
 }
 
+static void hclge_reset_vf(struct hclge_vport *vport,
+                          struct hclge_mbx_vf_to_pf_cmd *mbx_req)
+{
+       struct hclge_dev *hdev = vport->back;
+       int ret;
+
+       dev_warn(&hdev->pdev->dev, "PF received VF reset request from VF %d!",
+                mbx_req->mbx_src_vfid);
+
+       /* Acknowledge VF that PF is now about to assert the reset for the VF.
+        * On receiving this message VF will get into pending state and will
+        * start polling for the hardware reset completion status.
+        */
+       ret = hclge_inform_reset_assert_to_vf(vport);
+       if (ret) {
+               dev_err(&hdev->pdev->dev,
+                       "PF fail(%d) to inform VF(%d)of reset, reset failed!\n",
+                       ret, vport->vport_id);
+               return;
+       }
+
+       dev_warn(&hdev->pdev->dev, "PF is now resetting VF %d.\n",
+                mbx_req->mbx_src_vfid);
+       /* reset this virtual function */
+       hclge_func_reset_cmd(hdev, mbx_req->mbx_src_vfid);
+}
+
 void hclge_mbx_handler(struct hclge_dev *hdev)
 {
        struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq;
@@ -416,6 +455,9 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
                case HCLGE_MBX_QUEUE_RESET:
                        hclge_mbx_reset_vf_queue(vport, req);
                        break;
+               case HCLGE_MBX_RESET:
+                       hclge_reset_vf(vport, req);
+                       break;
                default:
                        dev_err(&hdev->pdev->dev,
                                "un-supported mailbox message, code = %d\n",