aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSalil Mehta <salil.mehta@huawei.com>2018-03-22 10:29:00 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-22 15:29:04 -0400
commit2bfbd35d8ecd97a4a7f1db1754908b54542fa7aa (patch)
treed8e84a2ba3f2621b5d67a1d96d6c3a2637ca3d44
parenta15fa7d43b0b625f018c4f0c5856f9061a6d4c82 (diff)
net: hns3: Changes required in PF mailbox to support VF reset
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>
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c2
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h1
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c42
3 files changed, 44 insertions, 1 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index a3e00da3dff0..bede4117bad9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2749,7 +2749,7 @@ static int hclge_reset_wait(struct hclge_dev *hdev)
2749 return 0; 2749 return 0;
2750} 2750}
2751 2751
2752static int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id) 2752int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id)
2753{ 2753{
2754 struct hclge_desc desc; 2754 struct hclge_desc desc;
2755 struct hclge_reset_cmd *req = (struct hclge_reset_cmd *)desc.data; 2755 struct hclge_reset_cmd *req = (struct hclge_reset_cmd *)desc.data;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 8c14d10c88cb..0f4157e71282 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -657,4 +657,5 @@ void hclge_mbx_handler(struct hclge_dev *hdev);
657void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id); 657void hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id);
658void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id); 658void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id);
659int hclge_cfg_flowctrl(struct hclge_dev *hdev); 659int hclge_cfg_flowctrl(struct hclge_dev *hdev);
660int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);
660#endif 661#endif
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index 949da0c993cf..39013334a613 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
@@ -79,6 +79,18 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
79 return status; 79 return status;
80} 80}
81 81
82int hclge_inform_reset_assert_to_vf(struct hclge_vport *vport)
83{
84 u8 msg_data[2];
85 u8 dest_vfid;
86
87 dest_vfid = (u8)vport->vport_id;
88
89 /* send this requested info to VF */
90 return hclge_send_mbx_msg(vport, msg_data, sizeof(u8),
91 HCLGE_MBX_ASSERTING_RESET, dest_vfid);
92}
93
82static void hclge_free_vector_ring_chain(struct hnae3_ring_chain_node *head) 94static void hclge_free_vector_ring_chain(struct hnae3_ring_chain_node *head)
83{ 95{
84 struct hnae3_ring_chain_node *chain_tmp, *chain; 96 struct hnae3_ring_chain_node *chain_tmp, *chain;
@@ -339,6 +351,33 @@ static void hclge_mbx_reset_vf_queue(struct hclge_vport *vport,
339 hclge_gen_resp_to_vf(vport, mbx_req, 0, NULL, 0); 351 hclge_gen_resp_to_vf(vport, mbx_req, 0, NULL, 0);
340} 352}
341 353
354static void hclge_reset_vf(struct hclge_vport *vport,
355 struct hclge_mbx_vf_to_pf_cmd *mbx_req)
356{
357 struct hclge_dev *hdev = vport->back;
358 int ret;
359
360 dev_warn(&hdev->pdev->dev, "PF received VF reset request from VF %d!",
361 mbx_req->mbx_src_vfid);
362
363 /* Acknowledge VF that PF is now about to assert the reset for the VF.
364 * On receiving this message VF will get into pending state and will
365 * start polling for the hardware reset completion status.
366 */
367 ret = hclge_inform_reset_assert_to_vf(vport);
368 if (ret) {
369 dev_err(&hdev->pdev->dev,
370 "PF fail(%d) to inform VF(%d)of reset, reset failed!\n",
371 ret, vport->vport_id);
372 return;
373 }
374
375 dev_warn(&hdev->pdev->dev, "PF is now resetting VF %d.\n",
376 mbx_req->mbx_src_vfid);
377 /* reset this virtual function */
378 hclge_func_reset_cmd(hdev, mbx_req->mbx_src_vfid);
379}
380
342void hclge_mbx_handler(struct hclge_dev *hdev) 381void hclge_mbx_handler(struct hclge_dev *hdev)
343{ 382{
344 struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq; 383 struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq;
@@ -416,6 +455,9 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
416 case HCLGE_MBX_QUEUE_RESET: 455 case HCLGE_MBX_QUEUE_RESET:
417 hclge_mbx_reset_vf_queue(vport, req); 456 hclge_mbx_reset_vf_queue(vport, req);
418 break; 457 break;
458 case HCLGE_MBX_RESET:
459 hclge_reset_vf(vport, req);
460 break;
419 default: 461 default:
420 dev_err(&hdev->pdev->dev, 462 dev_err(&hdev->pdev->dev,
421 "un-supported mailbox message, code = %d\n", 463 "un-supported mailbox message, code = %d\n",