aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAriel Elior <ariele@broadcom.com>2013-01-01 00:22:28 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-02 04:45:05 -0500
commit9b176b6b63ed07472c26b6833a0ac23b373e6bf8 (patch)
tree69c2761456b08b9ef2fdfa4077e2c439c7fd0b82 /drivers
parent8d9ac297d18dbe05b6e7cb4378da51e67143b452 (diff)
bnx2x: Add teardown_q and close to VF <-> PF channel
When a VF is being closed its queues are released via the 'teardown_q' and the VF itself is closed with 'close'. These are essentially the unload counterparts of 'init' and 'setup_q' from the load flow. Signed-off-by: Ariel Elior <ariele@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c9
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c85
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h18
4 files changed, 112 insertions, 2 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 5c64d1dc6279..82c6233bcace 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -2225,7 +2225,9 @@ int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping);
2225int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count); 2225int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count);
2226int bnx2x_vfpf_release(struct bnx2x *bp); 2226int bnx2x_vfpf_release(struct bnx2x *bp);
2227int bnx2x_vfpf_init(struct bnx2x *bp); 2227int bnx2x_vfpf_init(struct bnx2x *bp);
2228void bnx2x_vfpf_close_vf(struct bnx2x *bp);
2228int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx); 2229int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx);
2230int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx);
2229int bnx2x_vfpf_set_mac(struct bnx2x *bp); 2231int bnx2x_vfpf_set_mac(struct bnx2x *bp);
2230int bnx2x_nic_load_analyze_req(struct bnx2x *bp, u32 load_code); 2232int bnx2x_nic_load_analyze_req(struct bnx2x *bp, u32 load_code);
2231/* Congestion management fairness mode */ 2233/* Congestion management fairness mode */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index f7b23c26f3e8..362451d6033a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -2790,8 +2790,13 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
2790 /* wait till consumers catch up with producers in all queues */ 2790 /* wait till consumers catch up with producers in all queues */
2791 bnx2x_drain_tx_queues(bp); 2791 bnx2x_drain_tx_queues(bp);
2792 2792
2793 /* Cleanup the chip if needed */ 2793 /* if VF indicate to PF this function is going down (PF will delete sp
2794 if (unload_mode != UNLOAD_RECOVERY) 2794 * elements and clear initializations
2795 */
2796 if (IS_VF(bp))
2797 bnx2x_vfpf_close_vf(bp);
2798 else if (unload_mode != UNLOAD_RECOVERY)
2799 /* if this is a normal/close unload need to clean up chip*/
2795 bnx2x_chip_cleanup(bp, unload_mode, keep_link); 2800 bnx2x_chip_cleanup(bp, unload_mode, keep_link);
2796 else { 2801 else {
2797 /* Send the UNLOAD_REQUEST to the MCP */ 2802 /* Send the UNLOAD_REQUEST to the MCP */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 8ba054aeff97..2bf7dcca397d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -13469,6 +13469,55 @@ int bnx2x_vfpf_init(struct bnx2x *bp)
13469 return 0; 13469 return 0;
13470} 13470}
13471 13471
13472/* CLOSE VF - opposite to INIT_VF */
13473void bnx2x_vfpf_close_vf(struct bnx2x *bp)
13474{
13475 struct vfpf_close_tlv *req = &bp->vf2pf_mbox->req.close;
13476 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
13477 int i, rc;
13478 u32 vf_id;
13479
13480 /* If we haven't got a valid VF id, there is no sense to
13481 * continue with sending messages
13482 */
13483 if (bnx2x_get_vf_id(bp, &vf_id))
13484 goto free_irq;
13485
13486 /* Close the queues */
13487 for_each_queue(bp, i)
13488 bnx2x_vfpf_teardown_queue(bp, i);
13489
13490 /* clear mailbox and prep first tlv */
13491 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_CLOSE, sizeof(*req));
13492
13493 req->vf_id = vf_id;
13494
13495 /* add list termination tlv */
13496 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
13497 sizeof(struct channel_list_end_tlv));
13498
13499 /* output tlvs list */
13500 bnx2x_dp_tlv_list(bp, req);
13501
13502 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
13503
13504 if (rc)
13505 BNX2X_ERR("Sending CLOSE failed. rc was: %d\n", rc);
13506
13507 else if (resp->hdr.status != PFVF_STATUS_SUCCESS)
13508 BNX2X_ERR("Sending CLOSE failed: pf response was %d\n",
13509 resp->hdr.status);
13510
13511free_irq:
13512 /* Disable HW interrupts, NAPI */
13513 bnx2x_netif_stop(bp, 0);
13514 /* Delete all NAPI objects */
13515 bnx2x_del_all_napi(bp);
13516
13517 /* Release IRQs */
13518 bnx2x_free_irq(bp);
13519}
13520
13472/* ask the pf to open a queue for the vf */ 13521/* ask the pf to open a queue for the vf */
13473int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx) 13522int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx)
13474{ 13523{
@@ -13549,6 +13598,42 @@ int bnx2x_vfpf_setup_q(struct bnx2x *bp, int fp_idx)
13549 return rc; 13598 return rc;
13550} 13599}
13551 13600
13601int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx)
13602{
13603 struct vfpf_q_op_tlv *req = &bp->vf2pf_mbox->req.q_op;
13604 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
13605 int rc;
13606
13607 /* clear mailbox and prep first tlv */
13608 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_TEARDOWN_Q,
13609 sizeof(*req));
13610
13611 req->vf_qid = qidx;
13612
13613 /* add list termination tlv */
13614 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
13615 sizeof(struct channel_list_end_tlv));
13616
13617 /* output tlvs list */
13618 bnx2x_dp_tlv_list(bp, req);
13619
13620 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
13621
13622 if (rc) {
13623 BNX2X_ERR("Sending TEARDOWN for queue %d failed: %d\n", qidx,
13624 rc);
13625 return rc;
13626 }
13627
13628 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
13629 BNX2X_ERR("TEARDOWN for queue %d failed: %d\n", qidx,
13630 resp->hdr.status);
13631 return -EINVAL;
13632 }
13633
13634 return 0;
13635}
13636
13552/* request pf to add a mac for the vf */ 13637/* request pf to add a mac for the vf */
13553int bnx2x_vfpf_set_mac(struct bnx2x *bp) 13638int bnx2x_vfpf_set_mac(struct bnx2x *bp)
13554{ 13639{
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h
index 12889f052299..ed4a61815175 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h
@@ -111,6 +111,13 @@ struct vfpf_acquire_tlv {
111 aligned_u64 bulletin_addr; 111 aligned_u64 bulletin_addr;
112}; 112};
113 113
114/* simple operation request on queue */
115struct vfpf_q_op_tlv {
116 struct vfpf_first_tlv first_tlv;
117 u8 vf_qid;
118 u8 padding[3];
119};
120
114/* acquire response tlv - carries the allocated resources */ 121/* acquire response tlv - carries the allocated resources */
115struct pfvf_acquire_resp_tlv { 122struct pfvf_acquire_resp_tlv {
116 struct pfvf_tlv hdr; 123 struct pfvf_tlv hdr;
@@ -247,6 +254,13 @@ struct vfpf_set_q_filters_tlv {
247 u32 rx_mask; /* see mask constants at the top of the file */ 254 u32 rx_mask; /* see mask constants at the top of the file */
248}; 255};
249 256
257/* close VF (disable VF) */
258struct vfpf_close_tlv {
259 struct vfpf_first_tlv first_tlv;
260 u16 vf_id; /* for debug */
261 u8 padding[2];
262};
263
250/* release the VF's acquired resources */ 264/* release the VF's acquired resources */
251struct vfpf_release_tlv { 265struct vfpf_release_tlv {
252 struct vfpf_first_tlv first_tlv; 266 struct vfpf_first_tlv first_tlv;
@@ -262,6 +276,8 @@ union vfpf_tlvs {
262 struct vfpf_first_tlv first_tlv; 276 struct vfpf_first_tlv first_tlv;
263 struct vfpf_acquire_tlv acquire; 277 struct vfpf_acquire_tlv acquire;
264 struct vfpf_init_tlv init; 278 struct vfpf_init_tlv init;
279 struct vfpf_close_tlv close;
280 struct vfpf_q_op_tlv q_op;
265 struct vfpf_setup_q_tlv setup_q; 281 struct vfpf_setup_q_tlv setup_q;
266 struct vfpf_set_q_filters_tlv set_q_filters; 282 struct vfpf_set_q_filters_tlv set_q_filters;
267 struct vfpf_release_tlv release; 283 struct vfpf_release_tlv release;
@@ -284,6 +300,8 @@ enum channel_tlvs {
284 CHANNEL_TLV_INIT, 300 CHANNEL_TLV_INIT,
285 CHANNEL_TLV_SETUP_Q, 301 CHANNEL_TLV_SETUP_Q,
286 CHANNEL_TLV_SET_Q_FILTERS, 302 CHANNEL_TLV_SET_Q_FILTERS,
303 CHANNEL_TLV_TEARDOWN_Q,
304 CHANNEL_TLV_CLOSE,
287 CHANNEL_TLV_RELEASE, 305 CHANNEL_TLV_RELEASE,
288 CHANNEL_TLV_LIST_END, 306 CHANNEL_TLV_LIST_END,
289 CHANNEL_TLV_MAX 307 CHANNEL_TLV_MAX