1 /* bnx2x_vfpf.c: Broadcom Everest network driver.
3 * Copyright 2009-2013 Broadcom Corporation
5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you
7 * under the terms of the GNU General Public License version 2, available
8 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
10 * Notwithstanding the above, under no circumstances may you combine this
11 * software in any way with any other Broadcom software provided under a
12 * license other than the GPL, without Broadcom's express prior written
15 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Shmulik Ravid <shmulikr@broadcom.com>
17 * Ariel Elior <ariele@broadcom.com>
21 #include "bnx2x_cmn.h"
22 #include <linux/crc32.h>
24 /* place a given tlv on the tlv buffer at a given offset */
25 void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list, u16 offset, u16 type,
28 struct channel_tlv *tl =
29 (struct channel_tlv *)(tlvs_list + offset);
35 /* Clear the mailbox and init the header of the first tlv */
36 void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
39 mutex_lock(&bp->vf2pf_mutex);
41 DP(BNX2X_MSG_IOV, "preparing to send %d tlv over vf pf channel\n",
45 memset(bp->vf2pf_mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
47 /* init type and length */
48 bnx2x_add_tlv(bp, &first_tlv->tl, 0, type, length);
50 /* init first tlv header */
51 first_tlv->resp_msg_offset = sizeof(bp->vf2pf_mbox->req);
54 /* releases the mailbox */
55 void bnx2x_vfpf_finalize(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv)
57 DP(BNX2X_MSG_IOV, "done sending [%d] tlv over vf pf channel\n",
60 mutex_unlock(&bp->vf2pf_mutex);
63 /* list the types and lengths of the tlvs on the buffer */
64 void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list)
67 struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
69 while (tlv->type != CHANNEL_TLV_LIST_END) {
71 DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
72 tlv->type, tlv->length);
74 /* advance to next tlv */
75 tlvs_list += tlv->length;
77 /* cast general tlv list pointer to channel tlv header*/
78 tlv = (struct channel_tlv *)tlvs_list;
82 /* break condition for this loop */
83 if (i > MAX_TLVS_IN_LIST) {
84 WARN(true, "corrupt tlvs");
90 DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
91 tlv->type, tlv->length);
94 /* test whether we support a tlv type */
95 bool bnx2x_tlv_supported(u16 tlvtype)
97 return CHANNEL_TLV_NONE < tlvtype && tlvtype < CHANNEL_TLV_MAX;
100 static inline int bnx2x_pfvf_status_codes(int rc)
104 return PFVF_STATUS_SUCCESS;
106 return PFVF_STATUS_NO_RESOURCE;
108 return PFVF_STATUS_FAILURE;
112 static int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping)
114 struct cstorm_vf_zone_data __iomem *zone_data =
115 REG_ADDR(bp, PXP_VF_ADDR_CSDM_GLOBAL_START);
116 int tout = 100, interval = 100; /* wait for 10 seconds */
119 BNX2X_ERR("done was non zero before message to pf was sent\n");
124 /* if PF indicated channel is down avoid sending message. Return success
125 * so calling flow can continue
127 bnx2x_sample_bulletin(bp);
128 if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
129 DP(BNX2X_MSG_IOV, "detecting channel down. Aborting message\n");
130 *done = PFVF_STATUS_SUCCESS;
134 /* Write message address */
135 writel(U64_LO(msg_mapping),
136 &zone_data->non_trigger.vf_pf_channel.msg_addr_lo);
137 writel(U64_HI(msg_mapping),
138 &zone_data->non_trigger.vf_pf_channel.msg_addr_hi);
140 /* make sure the address is written before FW accesses it */
143 /* Trigger the PF FW */
144 writeb(1, &zone_data->trigger.vf_pf_channel.addr_valid);
146 /* Wait for PF to complete */
147 while ((tout >= 0) && (!*done)) {
151 /* progress indicator - HV can take its own sweet time in
154 DP_CONT(BNX2X_MSG_IOV, ".");
158 BNX2X_ERR("PF response has timed out\n");
161 DP(BNX2X_MSG_SP, "Got a response from PF\n");
165 static int bnx2x_get_vf_id(struct bnx2x *bp, u32 *vf_id)
168 int tout = 10, interval = 100; /* Wait for 1 sec */
171 /* pxp traps vf read of doorbells and returns me reg value */
172 me_reg = readl(bp->doorbells);
173 if (GOOD_ME_REG(me_reg))
178 BNX2X_ERR("Invalid ME register value: 0x%08x\n. Is pf driver up?",
180 } while (tout-- > 0);
182 if (!GOOD_ME_REG(me_reg)) {
183 BNX2X_ERR("Invalid ME register value: 0x%08x\n", me_reg);
187 BNX2X_ERR("valid ME register value: 0x%08x\n", me_reg);
189 *vf_id = (me_reg & ME_REG_VF_NUM_MASK) >> ME_REG_VF_NUM_SHIFT;
194 int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
196 int rc = 0, attempts = 0;
197 struct vfpf_acquire_tlv *req = &bp->vf2pf_mbox->req.acquire;
198 struct pfvf_acquire_resp_tlv *resp = &bp->vf2pf_mbox->resp.acquire_resp;
200 bool resources_acquired = false;
202 /* clear mailbox and prep first tlv */
203 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_ACQUIRE, sizeof(*req));
205 if (bnx2x_get_vf_id(bp, &vf_id)) {
210 req->vfdev_info.vf_id = vf_id;
211 req->vfdev_info.vf_os = 0;
213 req->resc_request.num_rxqs = rx_count;
214 req->resc_request.num_txqs = tx_count;
215 req->resc_request.num_sbs = bp->igu_sb_cnt;
216 req->resc_request.num_mac_filters = VF_ACQUIRE_MAC_FILTERS;
217 req->resc_request.num_mc_filters = VF_ACQUIRE_MC_FILTERS;
219 /* pf 2 vf bulletin board address */
220 req->bulletin_addr = bp->pf2vf_bulletin_mapping;
222 /* add list termination tlv */
223 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
224 sizeof(struct channel_list_end_tlv));
226 /* output tlvs list */
227 bnx2x_dp_tlv_list(bp, req);
229 while (!resources_acquired) {
230 DP(BNX2X_MSG_SP, "attempting to acquire resources\n");
232 /* send acquire request */
233 rc = bnx2x_send_msg2pf(bp,
235 bp->vf2pf_mbox_mapping);
241 /* copy acquire response from buffer to bp */
242 memcpy(&bp->acquire_resp, resp, sizeof(bp->acquire_resp));
246 /* test whether the PF accepted our request. If not, humble
247 * the request and try again.
249 if (bp->acquire_resp.hdr.status == PFVF_STATUS_SUCCESS) {
250 DP(BNX2X_MSG_SP, "resources acquired\n");
251 resources_acquired = true;
252 } else if (bp->acquire_resp.hdr.status ==
253 PFVF_STATUS_NO_RESOURCE &&
254 attempts < VF_ACQUIRE_THRESH) {
256 "PF unwilling to fulfill resource request. Try PF recommended amount\n");
258 /* humble our request */
259 req->resc_request.num_txqs =
260 min(req->resc_request.num_txqs,
261 bp->acquire_resp.resc.num_txqs);
262 req->resc_request.num_rxqs =
263 min(req->resc_request.num_rxqs,
264 bp->acquire_resp.resc.num_rxqs);
265 req->resc_request.num_sbs =
266 min(req->resc_request.num_sbs,
267 bp->acquire_resp.resc.num_sbs);
268 req->resc_request.num_mac_filters =
269 min(req->resc_request.num_mac_filters,
270 bp->acquire_resp.resc.num_mac_filters);
271 req->resc_request.num_vlan_filters =
272 min(req->resc_request.num_vlan_filters,
273 bp->acquire_resp.resc.num_vlan_filters);
274 req->resc_request.num_mc_filters =
275 min(req->resc_request.num_mc_filters,
276 bp->acquire_resp.resc.num_mc_filters);
278 /* Clear response buffer */
279 memset(&bp->vf2pf_mbox->resp, 0,
280 sizeof(union pfvf_tlvs));
282 /* PF reports error */
283 BNX2X_ERR("Failed to get the requested amount of resources: %d. Breaking...\n",
284 bp->acquire_resp.hdr.status);
291 bp->common.chip_id |= (bp->acquire_resp.pfdev_info.chip_num & 0xffff);
292 bp->link_params.chip_id = bp->common.chip_id;
293 bp->db_size = bp->acquire_resp.pfdev_info.db_size;
294 bp->common.int_block = INT_BLOCK_IGU;
295 bp->common.chip_port_mode = CHIP_2_PORT_MODE;
299 bp->common.flash_size = 0;
301 NO_WOL_FLAG | NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG | NO_FCOE_FLAG;
302 bp->igu_sb_cnt = bp->acquire_resp.resc.num_sbs;
303 bp->igu_base_sb = bp->acquire_resp.resc.hw_sbs[0].hw_sb_id;
304 strlcpy(bp->fw_ver, bp->acquire_resp.pfdev_info.fw_ver,
307 if (is_valid_ether_addr(bp->acquire_resp.resc.current_mac_addr))
308 memcpy(bp->dev->dev_addr,
309 bp->acquire_resp.resc.current_mac_addr,
313 bnx2x_vfpf_finalize(bp, &req->first_tlv);
317 int bnx2x_vfpf_release(struct bnx2x *bp)
319 struct vfpf_release_tlv *req = &bp->vf2pf_mbox->req.release;
320 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
323 /* clear mailbox and prep first tlv */
324 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_RELEASE, sizeof(*req));
326 if (bnx2x_get_vf_id(bp, &vf_id)) {
333 /* add list termination tlv */
334 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
335 sizeof(struct channel_list_end_tlv));
337 /* output tlvs list */
338 bnx2x_dp_tlv_list(bp, req);
340 /* send release request */
341 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
347 if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
349 DP(BNX2X_MSG_SP, "vf released\n");
351 /* PF reports error */
352 BNX2X_ERR("PF failed our release request - are we out of sync? Response status: %d\n",
358 bnx2x_vfpf_finalize(bp, &req->first_tlv);
363 /* Tell PF about SB addresses */
364 int bnx2x_vfpf_init(struct bnx2x *bp)
366 struct vfpf_init_tlv *req = &bp->vf2pf_mbox->req.init;
367 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
370 /* clear mailbox and prep first tlv */
371 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_INIT, sizeof(*req));
374 for_each_eth_queue(bp, i)
375 req->sb_addr[i] = (dma_addr_t)bnx2x_fp(bp, i,
378 /* statistics - requests only supports single queue for now */
379 req->stats_addr = bp->fw_stats_data_mapping +
380 offsetof(struct bnx2x_fw_stats_data, queue_stats);
382 req->stats_stride = sizeof(struct per_queue_stats);
384 /* add list termination tlv */
385 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
386 sizeof(struct channel_list_end_tlv));
388 /* output tlvs list */
389 bnx2x_dp_tlv_list(bp, req);
391 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
395 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
396 BNX2X_ERR("INIT VF failed: %d. Breaking...\n",
402 DP(BNX2X_MSG_SP, "INIT VF Succeeded\n");
404 bnx2x_vfpf_finalize(bp, &req->first_tlv);
409 /* CLOSE VF - opposite to INIT_VF */
410 void bnx2x_vfpf_close_vf(struct bnx2x *bp)
412 struct vfpf_close_tlv *req = &bp->vf2pf_mbox->req.close;
413 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
417 /* If we haven't got a valid VF id, there is no sense to
418 * continue with sending messages
420 if (bnx2x_get_vf_id(bp, &vf_id))
423 /* Close the queues */
424 for_each_queue(bp, i)
425 bnx2x_vfpf_teardown_queue(bp, i);
428 bnx2x_vfpf_config_mac(bp, bp->dev->dev_addr, bp->fp->index, false);
430 /* clear mailbox and prep first tlv */
431 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_CLOSE, sizeof(*req));
435 /* add list termination tlv */
436 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
437 sizeof(struct channel_list_end_tlv));
439 /* output tlvs list */
440 bnx2x_dp_tlv_list(bp, req);
442 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
445 BNX2X_ERR("Sending CLOSE failed. rc was: %d\n", rc);
447 else if (resp->hdr.status != PFVF_STATUS_SUCCESS)
448 BNX2X_ERR("Sending CLOSE failed: pf response was %d\n",
451 bnx2x_vfpf_finalize(bp, &req->first_tlv);
454 /* Disable HW interrupts, NAPI */
455 bnx2x_netif_stop(bp, 0);
456 /* Delete all NAPI objects */
457 bnx2x_del_all_napi(bp);
463 static void bnx2x_leading_vfq_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
464 struct bnx2x_vf_queue *q)
466 u8 cl_id = vfq_cl_id(vf, q);
467 u8 func_id = FW_VF_HANDLE(vf->abs_vfid);
470 bnx2x_init_mac_obj(bp, &q->mac_obj,
471 cl_id, q->cid, func_id,
472 bnx2x_vf_sp(bp, vf, mac_rdata),
473 bnx2x_vf_sp_map(bp, vf, mac_rdata),
474 BNX2X_FILTER_MAC_PENDING,
476 BNX2X_OBJ_TYPE_RX_TX,
479 bnx2x_init_vlan_obj(bp, &q->vlan_obj,
480 cl_id, q->cid, func_id,
481 bnx2x_vf_sp(bp, vf, vlan_rdata),
482 bnx2x_vf_sp_map(bp, vf, vlan_rdata),
483 BNX2X_FILTER_VLAN_PENDING,
485 BNX2X_OBJ_TYPE_RX_TX,
489 bnx2x_init_mcast_obj(bp, &vf->mcast_obj, cl_id,
490 q->cid, func_id, func_id,
491 bnx2x_vf_sp(bp, vf, mcast_rdata),
492 bnx2x_vf_sp_map(bp, vf, mcast_rdata),
493 BNX2X_FILTER_MCAST_PENDING,
495 BNX2X_OBJ_TYPE_RX_TX);
498 bnx2x_init_rss_config_obj(bp, &vf->rss_conf_obj, cl_id, q->cid,
500 bnx2x_vf_sp(bp, vf, rss_rdata),
501 bnx2x_vf_sp_map(bp, vf, rss_rdata),
502 BNX2X_FILTER_RSS_CONF_PENDING,
504 BNX2X_OBJ_TYPE_RX_TX);
506 vf->leading_rss = cl_id;
507 q->is_leading = true;
510 /* ask the pf to open a queue for the vf */
511 int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
514 struct vfpf_setup_q_tlv *req = &bp->vf2pf_mbox->req.setup_q;
515 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
516 u8 fp_idx = fp->index;
517 u16 tpa_agg_size = 0, flags = 0;
520 /* clear mailbox and prep first tlv */
521 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SETUP_Q, sizeof(*req));
523 /* select tpa mode to request */
524 if (!fp->disable_tpa) {
525 flags |= VFPF_QUEUE_FLG_TPA;
526 flags |= VFPF_QUEUE_FLG_TPA_IPV6;
527 if (fp->mode == TPA_MODE_GRO)
528 flags |= VFPF_QUEUE_FLG_TPA_GRO;
529 tpa_agg_size = TPA_AGG_SIZE;
533 flags |= VFPF_QUEUE_FLG_LEADING_RSS;
535 /* calculate queue flags */
536 flags |= VFPF_QUEUE_FLG_STATS;
537 flags |= VFPF_QUEUE_FLG_CACHE_ALIGN;
538 flags |= VFPF_QUEUE_FLG_VLAN;
539 DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
542 req->vf_qid = fp_idx;
543 req->param_valid = VFPF_RXQ_VALID | VFPF_TXQ_VALID;
546 req->rxq.rcq_addr = fp->rx_comp_mapping;
547 req->rxq.rcq_np_addr = fp->rx_comp_mapping + BCM_PAGE_SIZE;
548 req->rxq.rxq_addr = fp->rx_desc_mapping;
549 req->rxq.sge_addr = fp->rx_sge_mapping;
550 req->rxq.vf_sb = fp_idx;
551 req->rxq.sb_index = HC_INDEX_ETH_RX_CQ_CONS;
552 req->rxq.hc_rate = bp->rx_ticks ? 1000000/bp->rx_ticks : 0;
553 req->rxq.mtu = bp->dev->mtu;
554 req->rxq.buf_sz = fp->rx_buf_size;
555 req->rxq.sge_buf_sz = BCM_PAGE_SIZE * PAGES_PER_SGE;
556 req->rxq.tpa_agg_sz = tpa_agg_size;
557 req->rxq.max_sge_pkt = SGE_PAGE_ALIGN(bp->dev->mtu) >> SGE_PAGE_SHIFT;
558 req->rxq.max_sge_pkt = ((req->rxq.max_sge_pkt + PAGES_PER_SGE - 1) &
559 (~(PAGES_PER_SGE-1))) >> PAGES_PER_SGE_SHIFT;
560 req->rxq.flags = flags;
561 req->rxq.drop_flags = 0;
562 req->rxq.cache_line_log = BNX2X_RX_ALIGN_SHIFT;
563 req->rxq.stat_id = -1; /* No stats at the moment */
566 req->txq.txq_addr = fp->txdata_ptr[FIRST_TX_COS_INDEX]->tx_desc_mapping;
567 req->txq.vf_sb = fp_idx;
568 req->txq.sb_index = HC_INDEX_ETH_TX_CQ_CONS_COS0;
569 req->txq.hc_rate = bp->tx_ticks ? 1000000/bp->tx_ticks : 0;
570 req->txq.flags = flags;
571 req->txq.traffic_type = LLFC_TRAFFIC_TYPE_NW;
573 /* add list termination tlv */
574 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
575 sizeof(struct channel_list_end_tlv));
577 /* output tlvs list */
578 bnx2x_dp_tlv_list(bp, req);
580 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
582 BNX2X_ERR("Sending SETUP_Q message for queue[%d] failed!\n",
585 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
586 BNX2X_ERR("Status of SETUP_Q for queue[%d] is %d\n",
587 fp_idx, resp->hdr.status);
591 bnx2x_vfpf_finalize(bp, &req->first_tlv);
596 int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx)
598 struct vfpf_q_op_tlv *req = &bp->vf2pf_mbox->req.q_op;
599 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
602 /* clear mailbox and prep first tlv */
603 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_TEARDOWN_Q,
608 /* add list termination tlv */
609 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
610 sizeof(struct channel_list_end_tlv));
612 /* output tlvs list */
613 bnx2x_dp_tlv_list(bp, req);
615 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
618 BNX2X_ERR("Sending TEARDOWN for queue %d failed: %d\n", qidx,
623 /* PF failed the transaction */
624 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
625 BNX2X_ERR("TEARDOWN for queue %d failed: %d\n", qidx,
631 bnx2x_vfpf_finalize(bp, &req->first_tlv);
635 /* request pf to add a mac for the vf */
636 int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set)
638 struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
639 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
640 struct pf_vf_bulletin_content bulletin = bp->pf2vf_bulletin->content;
643 /* clear mailbox and prep first tlv */
644 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
647 req->flags = VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED;
648 req->vf_qid = vf_qid;
649 req->n_mac_vlan_filters = 1;
651 req->filters[0].flags = VFPF_Q_FILTER_DEST_MAC_VALID;
653 req->filters[0].flags |= VFPF_Q_FILTER_SET_MAC;
655 /* sample bulletin board for new mac */
656 bnx2x_sample_bulletin(bp);
658 /* copy mac from device to request */
659 memcpy(req->filters[0].mac, addr, ETH_ALEN);
661 /* add list termination tlv */
662 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
663 sizeof(struct channel_list_end_tlv));
665 /* output tlvs list */
666 bnx2x_dp_tlv_list(bp, req);
668 /* send message to pf */
669 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
671 BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
675 /* failure may mean PF was configured with a new mac for us */
676 while (resp->hdr.status == PFVF_STATUS_FAILURE) {
678 "vfpf SET MAC failed. Check bulletin board for new posts\n");
680 /* copy mac from bulletin to device */
681 memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN);
683 /* check if bulletin board was updated */
684 if (bnx2x_sample_bulletin(bp) == PFVF_BULLETIN_UPDATED) {
685 /* copy mac from device to request */
686 memcpy(req->filters[0].mac, bp->dev->dev_addr,
689 /* send message to pf */
690 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status,
691 bp->vf2pf_mbox_mapping);
693 /* no new info in bulletin */
698 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
699 BNX2X_ERR("vfpf SET MAC failed: %d\n", resp->hdr.status);
703 bnx2x_vfpf_finalize(bp, &req->first_tlv);
708 /* request pf to config rss table for vf queues*/
709 int bnx2x_vfpf_config_rss(struct bnx2x *bp,
710 struct bnx2x_config_rss_params *params)
712 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
713 struct vfpf_rss_tlv *req = &bp->vf2pf_mbox->req.update_rss;
716 /* clear mailbox and prep first tlv */
717 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_UPDATE_RSS,
720 /* add list termination tlv */
721 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
722 sizeof(struct channel_list_end_tlv));
724 memcpy(req->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
725 memcpy(req->rss_key, params->rss_key, sizeof(params->rss_key));
726 req->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;
727 req->rss_key_size = T_ETH_RSS_KEY;
728 req->rss_result_mask = params->rss_result_mask;
730 /* flags handled individually for backward/forward compatability */
731 if (params->rss_flags & (1 << BNX2X_RSS_MODE_DISABLED))
732 req->rss_flags |= VFPF_RSS_MODE_DISABLED;
733 if (params->rss_flags & (1 << BNX2X_RSS_MODE_REGULAR))
734 req->rss_flags |= VFPF_RSS_MODE_REGULAR;
735 if (params->rss_flags & (1 << BNX2X_RSS_SET_SRCH))
736 req->rss_flags |= VFPF_RSS_SET_SRCH;
737 if (params->rss_flags & (1 << BNX2X_RSS_IPV4))
738 req->rss_flags |= VFPF_RSS_IPV4;
739 if (params->rss_flags & (1 << BNX2X_RSS_IPV4_TCP))
740 req->rss_flags |= VFPF_RSS_IPV4_TCP;
741 if (params->rss_flags & (1 << BNX2X_RSS_IPV4_UDP))
742 req->rss_flags |= VFPF_RSS_IPV4_UDP;
743 if (params->rss_flags & (1 << BNX2X_RSS_IPV6))
744 req->rss_flags |= VFPF_RSS_IPV6;
745 if (params->rss_flags & (1 << BNX2X_RSS_IPV6_TCP))
746 req->rss_flags |= VFPF_RSS_IPV6_TCP;
747 if (params->rss_flags & (1 << BNX2X_RSS_IPV6_UDP))
748 req->rss_flags |= VFPF_RSS_IPV6_UDP;
750 DP(BNX2X_MSG_IOV, "rss flags %x\n", req->rss_flags);
752 /* output tlvs list */
753 bnx2x_dp_tlv_list(bp, req);
755 /* send message to pf */
756 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
758 BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
762 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
763 BNX2X_ERR("failed to send rss message to PF over Vf PF channel %d\n",
768 bnx2x_vfpf_finalize(bp, &req->first_tlv);
773 int bnx2x_vfpf_set_mcast(struct net_device *dev)
775 struct bnx2x *bp = netdev_priv(dev);
776 struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
777 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
779 struct netdev_hw_addr *ha;
781 if (bp->state != BNX2X_STATE_OPEN) {
782 DP(NETIF_MSG_IFUP, "state is %x, returning\n", bp->state);
786 /* clear mailbox and prep first tlv */
787 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
790 /* Get Rx mode requested */
791 DP(NETIF_MSG_IFUP, "dev->flags = %x\n", dev->flags);
793 netdev_for_each_mc_addr(ha, dev) {
794 DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
796 memcpy(req->multicast[i], bnx2x_mc_addr(ha), ETH_ALEN);
800 /* We support four PFVF_MAX_MULTICAST_PER_VF mcast
803 if (i >= PFVF_MAX_MULTICAST_PER_VF) {
805 "VF supports not more than %d multicast MAC addresses\n",
806 PFVF_MAX_MULTICAST_PER_VF);
810 req->n_multicast = i;
811 req->flags |= VFPF_SET_Q_FILTERS_MULTICAST_CHANGED;
814 /* add list termination tlv */
815 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
816 sizeof(struct channel_list_end_tlv));
818 /* output tlvs list */
819 bnx2x_dp_tlv_list(bp, req);
820 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
822 BNX2X_ERR("Sending a message failed: %d\n", rc);
826 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
827 BNX2X_ERR("Set Rx mode/multicast failed: %d\n",
832 bnx2x_vfpf_finalize(bp, &req->first_tlv);
837 int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp)
839 int mode = bp->rx_mode;
840 struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
841 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
844 /* clear mailbox and prep first tlv */
845 bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
848 DP(NETIF_MSG_IFUP, "Rx mode is %d\n", mode);
851 case BNX2X_RX_MODE_NONE: /* no Rx */
852 req->rx_mask = VFPF_RX_MASK_ACCEPT_NONE;
854 case BNX2X_RX_MODE_NORMAL:
855 req->rx_mask = VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST;
856 req->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
857 req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
859 case BNX2X_RX_MODE_ALLMULTI:
860 req->rx_mask = VFPF_RX_MASK_ACCEPT_ALL_MULTICAST;
861 req->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
862 req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
864 case BNX2X_RX_MODE_PROMISC:
865 req->rx_mask = VFPF_RX_MASK_ACCEPT_ALL_UNICAST;
866 req->rx_mask |= VFPF_RX_MASK_ACCEPT_ALL_MULTICAST;
867 req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
870 BNX2X_ERR("BAD rx mode (%d)\n", mode);
875 req->flags |= VFPF_SET_Q_FILTERS_RX_MASK_CHANGED;
878 /* add list termination tlv */
879 bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
880 sizeof(struct channel_list_end_tlv));
882 /* output tlvs list */
883 bnx2x_dp_tlv_list(bp, req);
885 rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
887 BNX2X_ERR("Sending a message failed: %d\n", rc);
889 if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
890 BNX2X_ERR("Set Rx mode failed: %d\n", resp->hdr.status);
894 bnx2x_vfpf_finalize(bp, &req->first_tlv);
899 /* General service functions */
900 static void storm_memset_vf_mbx_ack(struct bnx2x *bp, u16 abs_fid)
902 u32 addr = BAR_CSTRORM_INTMEM +
903 CSTORM_VF_PF_CHANNEL_STATE_OFFSET(abs_fid);
905 REG_WR8(bp, addr, VF_PF_CHANNEL_STATE_READY);
908 static void storm_memset_vf_mbx_valid(struct bnx2x *bp, u16 abs_fid)
910 u32 addr = BAR_CSTRORM_INTMEM +
911 CSTORM_VF_PF_CHANNEL_VALID_OFFSET(abs_fid);
913 REG_WR8(bp, addr, 1);
916 static inline void bnx2x_set_vf_mbxs_valid(struct bnx2x *bp)
921 storm_memset_vf_mbx_valid(bp, bnx2x_vf(bp, i, abs_vfid));
924 /* enable vf_pf mailbox (aka vf-pf-channel) */
925 void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid)
927 bnx2x_vf_flr_clnup_epilog(bp, abs_vfid);
929 /* enable the mailbox in the FW */
930 storm_memset_vf_mbx_ack(bp, abs_vfid);
931 storm_memset_vf_mbx_valid(bp, abs_vfid);
933 /* enable the VF access to the mailbox */
934 bnx2x_vf_enable_access(bp, abs_vfid);
937 /* this works only on !E1h */
938 static int bnx2x_copy32_vf_dmae(struct bnx2x *bp, u8 from_vf,
939 dma_addr_t pf_addr, u8 vfid, u32 vf_addr_hi,
940 u32 vf_addr_lo, u32 len32)
942 struct dmae_command dmae;
944 if (CHIP_IS_E1x(bp)) {
945 BNX2X_ERR("Chip revision does not support VFs\n");
949 if (!bp->dmae_ready) {
950 BNX2X_ERR("DMAE is not ready, can not copy\n");
954 /* set opcode and fixed command fields */
955 bnx2x_prep_dmae_with_comp(bp, &dmae, DMAE_SRC_PCI, DMAE_DST_PCI);
958 dmae.opcode_iov = (vfid << DMAE_COMMAND_SRC_VFID_SHIFT) |
959 (DMAE_SRC_VF << DMAE_COMMAND_SRC_VFPF_SHIFT) |
960 (DMAE_DST_PF << DMAE_COMMAND_DST_VFPF_SHIFT);
962 dmae.opcode |= (DMAE_C_DST << DMAE_COMMAND_C_FUNC_SHIFT);
964 dmae.src_addr_lo = vf_addr_lo;
965 dmae.src_addr_hi = vf_addr_hi;
966 dmae.dst_addr_lo = U64_LO(pf_addr);
967 dmae.dst_addr_hi = U64_HI(pf_addr);
969 dmae.opcode_iov = (vfid << DMAE_COMMAND_DST_VFID_SHIFT) |
970 (DMAE_DST_VF << DMAE_COMMAND_DST_VFPF_SHIFT) |
971 (DMAE_SRC_PF << DMAE_COMMAND_SRC_VFPF_SHIFT);
973 dmae.opcode |= (DMAE_C_SRC << DMAE_COMMAND_C_FUNC_SHIFT);
975 dmae.src_addr_lo = U64_LO(pf_addr);
976 dmae.src_addr_hi = U64_HI(pf_addr);
977 dmae.dst_addr_lo = vf_addr_lo;
978 dmae.dst_addr_hi = vf_addr_hi;
982 /* issue the command and wait for completion */
983 return bnx2x_issue_dmae_with_comp(bp, &dmae);
986 static void bnx2x_vf_mbx_resp(struct bnx2x *bp, struct bnx2x_virtf *vf)
988 struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf->index);
993 struct pfvf_general_resp_tlv *resp = &mbx->msg->resp.general_resp;
995 /* prepare response */
996 type = mbx->first_tlv.tl.type;
997 length = type == CHANNEL_TLV_ACQUIRE ?
998 sizeof(struct pfvf_acquire_resp_tlv) :
999 sizeof(struct pfvf_general_resp_tlv);
1000 bnx2x_add_tlv(bp, resp, 0, type, length);
1001 resp->hdr.status = bnx2x_pfvf_status_codes(vf->op_rc);
1002 bnx2x_add_tlv(bp, resp, length, CHANNEL_TLV_LIST_END,
1003 sizeof(struct channel_list_end_tlv));
1004 bnx2x_dp_tlv_list(bp, resp);
1005 DP(BNX2X_MSG_IOV, "mailbox vf address hi 0x%x, lo 0x%x, offset 0x%x\n",
1006 mbx->vf_addr_hi, mbx->vf_addr_lo, mbx->first_tlv.resp_msg_offset);
1009 vf_addr = HILO_U64(mbx->vf_addr_hi, mbx->vf_addr_lo) +
1010 mbx->first_tlv.resp_msg_offset;
1011 pf_addr = mbx->msg_mapping +
1012 offsetof(struct bnx2x_vf_mbx_msg, resp);
1014 /* copy the response body, if there is one, before the header, as the vf
1015 * is sensitive to the header being written
1017 if (resp->hdr.tl.length > sizeof(u64)) {
1018 length = resp->hdr.tl.length - sizeof(u64);
1019 vf_addr += sizeof(u64);
1020 pf_addr += sizeof(u64);
1021 rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr, vf->abs_vfid,
1026 BNX2X_ERR("Failed to copy response body to VF %d\n",
1030 vf_addr -= sizeof(u64);
1031 pf_addr -= sizeof(u64);
1035 storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
1038 /* initiate dmae to send the response */
1039 mbx->flags &= ~VF_MSG_INPROCESS;
1041 /* copy the response header including status-done field,
1042 * must be last dmae, must be after FW is acked
1044 rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr, vf->abs_vfid,
1049 /* unlock channel mutex */
1050 bnx2x_unlock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
1053 BNX2X_ERR("Failed to copy response status to VF %d\n",
1060 bnx2x_vf_release(bp, vf, false); /* non blocking */
1063 static void bnx2x_vf_mbx_acquire_resp(struct bnx2x *bp, struct bnx2x_virtf *vf,
1064 struct bnx2x_vf_mbx *mbx, int vfop_status)
1067 struct pfvf_acquire_resp_tlv *resp = &mbx->msg->resp.acquire_resp;
1068 struct pf_vf_resc *resc = &resp->resc;
1069 u8 status = bnx2x_pfvf_status_codes(vfop_status);
1071 memset(resp, 0, sizeof(*resp));
1073 /* fill in pfdev info */
1074 resp->pfdev_info.chip_num = bp->common.chip_id;
1075 resp->pfdev_info.db_size = bp->db_size;
1076 resp->pfdev_info.indices_per_sb = HC_SB_MAX_INDICES_E2;
1077 resp->pfdev_info.pf_cap = (PFVF_CAP_RSS |
1078 /* PFVF_CAP_DHC |*/ PFVF_CAP_TPA);
1079 bnx2x_fill_fw_str(bp, resp->pfdev_info.fw_ver,
1080 sizeof(resp->pfdev_info.fw_ver));
1082 if (status == PFVF_STATUS_NO_RESOURCE ||
1083 status == PFVF_STATUS_SUCCESS) {
1084 /* set resources numbers, if status equals NO_RESOURCE these
1085 * are max possible numbers
1087 resc->num_rxqs = vf_rxq_count(vf) ? :
1088 bnx2x_vf_max_queue_cnt(bp, vf);
1089 resc->num_txqs = vf_txq_count(vf) ? :
1090 bnx2x_vf_max_queue_cnt(bp, vf);
1091 resc->num_sbs = vf_sb_count(vf);
1092 resc->num_mac_filters = vf_mac_rules_cnt(vf);
1093 resc->num_vlan_filters = vf_vlan_rules_cnt(vf);
1094 resc->num_mc_filters = 0;
1096 if (status == PFVF_STATUS_SUCCESS) {
1097 /* fill in the allocated resources */
1098 struct pf_vf_bulletin_content *bulletin =
1099 BP_VF_BULLETIN(bp, vf->index);
1103 vfq_qzone_id(vf, vfq_get(vf, i));
1105 for_each_vf_sb(vf, i) {
1106 resc->hw_sbs[i].hw_sb_id = vf_igu_sb(vf, i);
1107 resc->hw_sbs[i].sb_qid = vf_hc_qzone(vf, i);
1110 /* if a mac has been set for this vf, supply it */
1111 if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
1112 memcpy(resc->current_mac_addr, bulletin->mac,
1118 DP(BNX2X_MSG_IOV, "VF[%d] ACQUIRE_RESPONSE: pfdev_info- chip_num=0x%x, db_size=%d, idx_per_sb=%d, pf_cap=0x%x\n"
1119 "resources- n_rxq-%d, n_txq-%d, n_sbs-%d, n_macs-%d, n_vlans-%d, n_mcs-%d, fw_ver: '%s'\n",
1121 resp->pfdev_info.chip_num,
1122 resp->pfdev_info.db_size,
1123 resp->pfdev_info.indices_per_sb,
1124 resp->pfdev_info.pf_cap,
1128 resc->num_mac_filters,
1129 resc->num_vlan_filters,
1130 resc->num_mc_filters,
1131 resp->pfdev_info.fw_ver);
1133 DP_CONT(BNX2X_MSG_IOV, "hw_qids- [ ");
1134 for (i = 0; i < vf_rxq_count(vf); i++)
1135 DP_CONT(BNX2X_MSG_IOV, "%d ", resc->hw_qid[i]);
1136 DP_CONT(BNX2X_MSG_IOV, "], sb_info- [ ");
1137 for (i = 0; i < vf_sb_count(vf); i++)
1138 DP_CONT(BNX2X_MSG_IOV, "%d:%d ",
1139 resc->hw_sbs[i].hw_sb_id,
1140 resc->hw_sbs[i].sb_qid);
1141 DP_CONT(BNX2X_MSG_IOV, "]\n");
1143 /* send the response */
1144 vf->op_rc = vfop_status;
1145 bnx2x_vf_mbx_resp(bp, vf);
1148 static void bnx2x_vf_mbx_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
1149 struct bnx2x_vf_mbx *mbx)
1152 struct vfpf_acquire_tlv *acquire = &mbx->msg->req.acquire;
1154 /* log vfdef info */
1156 "VF[%d] ACQUIRE: vfdev_info- vf_id %d, vf_os %d resources- n_rxq-%d, n_txq-%d, n_sbs-%d, n_macs-%d, n_vlans-%d, n_mcs-%d\n",
1157 vf->abs_vfid, acquire->vfdev_info.vf_id, acquire->vfdev_info.vf_os,
1158 acquire->resc_request.num_rxqs, acquire->resc_request.num_txqs,
1159 acquire->resc_request.num_sbs, acquire->resc_request.num_mac_filters,
1160 acquire->resc_request.num_vlan_filters,
1161 acquire->resc_request.num_mc_filters);
1163 /* acquire the resources */
1164 rc = bnx2x_vf_acquire(bp, vf, &acquire->resc_request);
1166 /* store address of vf's bulletin board */
1167 vf->bulletin_map = acquire->bulletin_addr;
1170 bnx2x_vf_mbx_acquire_resp(bp, vf, mbx, rc);
1173 static void bnx2x_vf_mbx_init_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1174 struct bnx2x_vf_mbx *mbx)
1176 struct vfpf_init_tlv *init = &mbx->msg->req.init;
1178 /* record ghost addresses from vf message */
1179 vf->spq_map = init->spq_addr;
1180 vf->fw_stat_map = init->stats_addr;
1181 vf->stats_stride = init->stats_stride;
1182 vf->op_rc = bnx2x_vf_init(bp, vf, (dma_addr_t *)init->sb_addr);
1184 /* set VF multiqueue statistics collection mode */
1185 if (init->flags & VFPF_INIT_FLG_STATS_COALESCE)
1186 vf->cfg_flags |= VF_CFG_STATS_COALESCE;
1189 bnx2x_vf_mbx_resp(bp, vf);
1192 /* convert MBX queue-flags to standard SP queue-flags */
1193 static void bnx2x_vf_mbx_set_q_flags(struct bnx2x *bp, u32 mbx_q_flags,
1194 unsigned long *sp_q_flags)
1196 if (mbx_q_flags & VFPF_QUEUE_FLG_TPA)
1197 __set_bit(BNX2X_Q_FLG_TPA, sp_q_flags);
1198 if (mbx_q_flags & VFPF_QUEUE_FLG_TPA_IPV6)
1199 __set_bit(BNX2X_Q_FLG_TPA_IPV6, sp_q_flags);
1200 if (mbx_q_flags & VFPF_QUEUE_FLG_TPA_GRO)
1201 __set_bit(BNX2X_Q_FLG_TPA_GRO, sp_q_flags);
1202 if (mbx_q_flags & VFPF_QUEUE_FLG_STATS)
1203 __set_bit(BNX2X_Q_FLG_STATS, sp_q_flags);
1204 if (mbx_q_flags & VFPF_QUEUE_FLG_VLAN)
1205 __set_bit(BNX2X_Q_FLG_VLAN, sp_q_flags);
1206 if (mbx_q_flags & VFPF_QUEUE_FLG_COS)
1207 __set_bit(BNX2X_Q_FLG_COS, sp_q_flags);
1208 if (mbx_q_flags & VFPF_QUEUE_FLG_HC)
1209 __set_bit(BNX2X_Q_FLG_HC, sp_q_flags);
1210 if (mbx_q_flags & VFPF_QUEUE_FLG_DHC)
1211 __set_bit(BNX2X_Q_FLG_DHC, sp_q_flags);
1212 if (mbx_q_flags & VFPF_QUEUE_FLG_LEADING_RSS)
1213 __set_bit(BNX2X_Q_FLG_LEADING_RSS, sp_q_flags);
1215 /* outer vlan removal is set according to PF's multi function mode */
1217 __set_bit(BNX2X_Q_FLG_OV, sp_q_flags);
1220 static void bnx2x_vf_mbx_setup_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
1221 struct bnx2x_vf_mbx *mbx)
1223 struct vfpf_setup_q_tlv *setup_q = &mbx->msg->req.setup_q;
1224 struct bnx2x_vfop_cmd cmd = {
1225 .done = bnx2x_vf_mbx_resp,
1230 if (setup_q->vf_qid >= vf_rxq_count(vf)) {
1231 BNX2X_ERR("vf_qid %d invalid, max queue count is %d\n",
1232 setup_q->vf_qid, vf_rxq_count(vf));
1233 vf->op_rc = -EINVAL;
1237 /* tx queues must be setup alongside rx queues thus if the rx queue
1238 * is not marked as valid there's nothing to do.
1240 if (setup_q->param_valid & (VFPF_RXQ_VALID|VFPF_TXQ_VALID)) {
1241 struct bnx2x_vf_queue *q = vfq_get(vf, setup_q->vf_qid);
1242 unsigned long q_type = 0;
1244 struct bnx2x_queue_init_params *init_p;
1245 struct bnx2x_queue_setup_params *setup_p;
1247 if (bnx2x_vfq_is_leading(q))
1248 bnx2x_leading_vfq_init(bp, vf, q);
1250 /* re-init the VF operation context */
1251 memset(&vf->op_params.qctor, 0 , sizeof(vf->op_params.qctor));
1252 setup_p = &vf->op_params.qctor.prep_qsetup;
1253 init_p = &vf->op_params.qctor.qstate.params.init;
1255 /* activate immediately */
1256 __set_bit(BNX2X_Q_FLG_ACTIVE, &setup_p->flags);
1258 if (setup_q->param_valid & VFPF_TXQ_VALID) {
1259 struct bnx2x_txq_setup_params *txq_params =
1260 &setup_p->txq_params;
1262 __set_bit(BNX2X_Q_TYPE_HAS_TX, &q_type);
1264 /* save sb resource index */
1265 q->sb_idx = setup_q->txq.vf_sb;
1268 init_p->tx.hc_rate = setup_q->txq.hc_rate;
1269 init_p->tx.sb_cq_index = setup_q->txq.sb_index;
1271 bnx2x_vf_mbx_set_q_flags(bp, setup_q->txq.flags,
1274 /* tx setup - flags */
1275 bnx2x_vf_mbx_set_q_flags(bp, setup_q->txq.flags,
1278 /* tx setup - general, nothing */
1281 txq_params->dscr_map = setup_q->txq.txq_addr;
1282 txq_params->sb_cq_index = setup_q->txq.sb_index;
1283 txq_params->traffic_type = setup_q->txq.traffic_type;
1285 bnx2x_vfop_qctor_dump_tx(bp, vf, init_p, setup_p,
1286 q->index, q->sb_idx);
1289 if (setup_q->param_valid & VFPF_RXQ_VALID) {
1290 struct bnx2x_rxq_setup_params *rxq_params =
1291 &setup_p->rxq_params;
1293 __set_bit(BNX2X_Q_TYPE_HAS_RX, &q_type);
1295 /* Note: there is no support for different SBs
1298 q->sb_idx = setup_q->rxq.vf_sb;
1301 init_p->rx.hc_rate = setup_q->rxq.hc_rate;
1302 init_p->rx.sb_cq_index = setup_q->rxq.sb_index;
1303 bnx2x_vf_mbx_set_q_flags(bp, setup_q->rxq.flags,
1306 /* rx setup - flags */
1307 bnx2x_vf_mbx_set_q_flags(bp, setup_q->rxq.flags,
1310 /* rx setup - general */
1311 setup_p->gen_params.mtu = setup_q->rxq.mtu;
1314 rxq_params->drop_flags = setup_q->rxq.drop_flags;
1315 rxq_params->dscr_map = setup_q->rxq.rxq_addr;
1316 rxq_params->sge_map = setup_q->rxq.sge_addr;
1317 rxq_params->rcq_map = setup_q->rxq.rcq_addr;
1318 rxq_params->rcq_np_map = setup_q->rxq.rcq_np_addr;
1319 rxq_params->buf_sz = setup_q->rxq.buf_sz;
1320 rxq_params->tpa_agg_sz = setup_q->rxq.tpa_agg_sz;
1321 rxq_params->max_sges_pkt = setup_q->rxq.max_sge_pkt;
1322 rxq_params->sge_buf_sz = setup_q->rxq.sge_buf_sz;
1323 rxq_params->cache_line_log =
1324 setup_q->rxq.cache_line_log;
1325 rxq_params->sb_cq_index = setup_q->rxq.sb_index;
1327 bnx2x_vfop_qctor_dump_rx(bp, vf, init_p, setup_p,
1328 q->index, q->sb_idx);
1330 /* complete the preparations */
1331 bnx2x_vfop_qctor_prep(bp, vf, q, &vf->op_params.qctor, q_type);
1333 vf->op_rc = bnx2x_vfop_qsetup_cmd(bp, vf, &cmd, q->index);
1339 bnx2x_vf_mbx_resp(bp, vf);
1342 enum bnx2x_vfop_filters_state {
1343 BNX2X_VFOP_MBX_Q_FILTERS_MACS,
1344 BNX2X_VFOP_MBX_Q_FILTERS_VLANS,
1345 BNX2X_VFOP_MBX_Q_FILTERS_RXMODE,
1346 BNX2X_VFOP_MBX_Q_FILTERS_MCAST,
1347 BNX2X_VFOP_MBX_Q_FILTERS_DONE
1350 static int bnx2x_vf_mbx_macvlan_list(struct bnx2x *bp,
1351 struct bnx2x_virtf *vf,
1352 struct vfpf_set_q_filters_tlv *tlv,
1353 struct bnx2x_vfop_filters **pfl,
1357 struct bnx2x_vfop_filters *fl = NULL;
1360 fsz = tlv->n_mac_vlan_filters * sizeof(struct bnx2x_vfop_filter) +
1361 sizeof(struct bnx2x_vfop_filters);
1363 fl = kzalloc(fsz, GFP_KERNEL);
1367 INIT_LIST_HEAD(&fl->head);
1369 for (i = 0, j = 0; i < tlv->n_mac_vlan_filters; i++) {
1370 struct vfpf_q_mac_vlan_filter *msg_filter = &tlv->filters[i];
1372 if ((msg_filter->flags & type_flag) != type_flag)
1374 if (type_flag == VFPF_Q_FILTER_DEST_MAC_VALID) {
1375 fl->filters[j].mac = msg_filter->mac;
1376 fl->filters[j].type = BNX2X_VFOP_FILTER_MAC;
1378 fl->filters[j].vid = msg_filter->vlan_tag;
1379 fl->filters[j].type = BNX2X_VFOP_FILTER_VLAN;
1381 fl->filters[j].add =
1382 (msg_filter->flags & VFPF_Q_FILTER_SET_MAC) ?
1384 list_add_tail(&fl->filters[j++].link, &fl->head);
1386 if (list_empty(&fl->head))
1394 static void bnx2x_vf_mbx_dp_q_filter(struct bnx2x *bp, int msglvl, int idx,
1395 struct vfpf_q_mac_vlan_filter *filter)
1397 DP(msglvl, "MAC-VLAN[%d] -- flags=0x%x\n", idx, filter->flags);
1398 if (filter->flags & VFPF_Q_FILTER_VLAN_TAG_VALID)
1399 DP_CONT(msglvl, ", vlan=%d", filter->vlan_tag);
1400 if (filter->flags & VFPF_Q_FILTER_DEST_MAC_VALID)
1401 DP_CONT(msglvl, ", MAC=%pM", filter->mac);
1402 DP_CONT(msglvl, "\n");
1405 static void bnx2x_vf_mbx_dp_q_filters(struct bnx2x *bp, int msglvl,
1406 struct vfpf_set_q_filters_tlv *filters)
1410 if (filters->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED)
1411 for (i = 0; i < filters->n_mac_vlan_filters; i++)
1412 bnx2x_vf_mbx_dp_q_filter(bp, msglvl, i,
1413 &filters->filters[i]);
1415 if (filters->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED)
1416 DP(msglvl, "RX-MASK=0x%x\n", filters->rx_mask);
1418 if (filters->flags & VFPF_SET_Q_FILTERS_MULTICAST_CHANGED)
1419 for (i = 0; i < filters->n_multicast; i++)
1420 DP(msglvl, "MULTICAST=%pM\n", filters->multicast[i]);
1423 #define VFPF_MAC_FILTER VFPF_Q_FILTER_DEST_MAC_VALID
1424 #define VFPF_VLAN_FILTER VFPF_Q_FILTER_VLAN_TAG_VALID
1426 static void bnx2x_vfop_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
1430 struct vfpf_set_q_filters_tlv *msg =
1431 &BP_VF_MBX(bp, vf->index)->msg->req.set_q_filters;
1433 struct bnx2x_vfop *vfop = bnx2x_vfop_cur(bp, vf);
1434 enum bnx2x_vfop_filters_state state = vfop->state;
1436 struct bnx2x_vfop_cmd cmd = {
1437 .done = bnx2x_vfop_mbx_qfilters,
1441 DP(BNX2X_MSG_IOV, "STATE: %d\n", state);
1447 case BNX2X_VFOP_MBX_Q_FILTERS_MACS:
1449 vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_VLANS;
1451 /* check for any vlan/mac changes */
1452 if (msg->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED) {
1453 /* build mac list */
1454 struct bnx2x_vfop_filters *fl = NULL;
1456 vfop->rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
1463 rc = bnx2x_vfop_mac_list_cmd(bp, vf, &cmd, fl,
1475 case BNX2X_VFOP_MBX_Q_FILTERS_VLANS:
1477 vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_RXMODE;
1479 /* check for any vlan/mac changes */
1480 if (msg->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED) {
1481 /* build vlan list */
1482 struct bnx2x_vfop_filters *fl = NULL;
1484 vfop->rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
1491 rc = bnx2x_vfop_vlan_list_cmd(bp, vf, &cmd, fl,
1503 case BNX2X_VFOP_MBX_Q_FILTERS_RXMODE:
1505 vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_MCAST;
1507 if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) {
1508 unsigned long accept = 0;
1510 /* covert VF-PF if mask to bnx2x accept flags */
1511 if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST)
1512 __set_bit(BNX2X_ACCEPT_UNICAST, &accept);
1515 VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST)
1516 __set_bit(BNX2X_ACCEPT_MULTICAST, &accept);
1518 if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_ALL_UNICAST)
1519 __set_bit(BNX2X_ACCEPT_ALL_UNICAST, &accept);
1521 if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_ALL_MULTICAST)
1522 __set_bit(BNX2X_ACCEPT_ALL_MULTICAST, &accept);
1524 if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_BROADCAST)
1525 __set_bit(BNX2X_ACCEPT_BROADCAST, &accept);
1527 /* A packet arriving the vf's mac should be accepted
1530 __set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept);
1533 rc = bnx2x_vfop_rxmode_cmd(bp, vf, &cmd,
1534 msg->vf_qid, accept);
1543 case BNX2X_VFOP_MBX_Q_FILTERS_MCAST:
1545 vfop->state = BNX2X_VFOP_MBX_Q_FILTERS_DONE;
1547 if (msg->flags & VFPF_SET_Q_FILTERS_MULTICAST_CHANGED) {
1549 rc = bnx2x_vfop_mcast_cmd(bp, vf, &cmd, msg->multicast,
1550 msg->n_multicast, false);
1559 case BNX2X_VFOP_MBX_Q_FILTERS_DONE:
1560 bnx2x_vfop_end(bp, vf, vfop);
1563 BNX2X_ERR("QFILTERS[%d:%d] error: rc %d\n",
1564 vf->abs_vfid, msg->vf_qid, vfop->rc);
1568 bnx2x_vfop_default(state);
1572 static int bnx2x_vfop_mbx_qfilters_cmd(struct bnx2x *bp,
1573 struct bnx2x_virtf *vf,
1574 struct bnx2x_vfop_cmd *cmd)
1576 struct bnx2x_vfop *vfop = bnx2x_vfop_add(bp, vf);
1578 bnx2x_vfop_opset(BNX2X_VFOP_MBX_Q_FILTERS_MACS,
1579 bnx2x_vfop_mbx_qfilters, cmd->done);
1580 return bnx2x_vfop_transition(bp, vf, bnx2x_vfop_mbx_qfilters,
1586 static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp,
1587 struct bnx2x_virtf *vf,
1588 struct bnx2x_vf_mbx *mbx)
1590 struct vfpf_set_q_filters_tlv *filters = &mbx->msg->req.set_q_filters;
1591 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf->index);
1592 struct bnx2x_vfop_cmd cmd = {
1593 .done = bnx2x_vf_mbx_resp,
1597 /* if a mac was already set for this VF via the set vf mac ndo, we only
1598 * accept mac configurations of that mac. Why accept them at all?
1599 * because PF may have been unable to configure the mac at the time
1600 * since queue was not set up.
1602 if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
1603 /* once a mac was set by ndo can only accept a single mac... */
1604 if (filters->n_mac_vlan_filters > 1) {
1605 BNX2X_ERR("VF[%d] requested the addition of multiple macs after set_vf_mac ndo was called\n",
1611 /* ...and only the mac set by the ndo */
1612 if (filters->n_mac_vlan_filters == 1 &&
1613 memcmp(filters->filters->mac, bulletin->mac, ETH_ALEN)) {
1614 BNX2X_ERR("VF[%d] requested the addition of a mac address not matching the one configured by set_vf_mac ndo\n",
1623 if (filters->vf_qid > vf_rxq_count(vf))
1626 DP(BNX2X_MSG_IOV, "VF[%d] Q_FILTERS: queue[%d]\n",
1630 /* print q_filter message */
1631 bnx2x_vf_mbx_dp_q_filters(bp, BNX2X_MSG_IOV, filters);
1633 vf->op_rc = bnx2x_vfop_mbx_qfilters_cmd(bp, vf, &cmd);
1639 bnx2x_vf_mbx_resp(bp, vf);
1642 static void bnx2x_vf_mbx_teardown_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
1643 struct bnx2x_vf_mbx *mbx)
1645 int qid = mbx->msg->req.q_op.vf_qid;
1646 struct bnx2x_vfop_cmd cmd = {
1647 .done = bnx2x_vf_mbx_resp,
1651 DP(BNX2X_MSG_IOV, "VF[%d] Q_TEARDOWN: vf_qid=%d\n",
1654 vf->op_rc = bnx2x_vfop_qdown_cmd(bp, vf, &cmd, qid);
1656 bnx2x_vf_mbx_resp(bp, vf);
1659 static void bnx2x_vf_mbx_close_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1660 struct bnx2x_vf_mbx *mbx)
1662 struct bnx2x_vfop_cmd cmd = {
1663 .done = bnx2x_vf_mbx_resp,
1667 DP(BNX2X_MSG_IOV, "VF[%d] VF_CLOSE\n", vf->abs_vfid);
1669 vf->op_rc = bnx2x_vfop_close_cmd(bp, vf, &cmd);
1671 bnx2x_vf_mbx_resp(bp, vf);
1674 static void bnx2x_vf_mbx_release_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1675 struct bnx2x_vf_mbx *mbx)
1677 struct bnx2x_vfop_cmd cmd = {
1678 .done = bnx2x_vf_mbx_resp,
1682 DP(BNX2X_MSG_IOV, "VF[%d] VF_RELEASE\n", vf->abs_vfid);
1684 vf->op_rc = bnx2x_vfop_release_cmd(bp, vf, &cmd);
1686 bnx2x_vf_mbx_resp(bp, vf);
1689 static void bnx2x_vf_mbx_update_rss(struct bnx2x *bp, struct bnx2x_virtf *vf,
1690 struct bnx2x_vf_mbx *mbx)
1692 struct bnx2x_vfop_cmd cmd = {
1693 .done = bnx2x_vf_mbx_resp,
1696 struct bnx2x_config_rss_params *vf_op_params = &vf->op_params.rss;
1697 struct vfpf_rss_tlv *rss_tlv = &mbx->msg->req.update_rss;
1699 if (rss_tlv->ind_table_size != T_ETH_INDIRECTION_TABLE_SIZE ||
1700 rss_tlv->rss_key_size != T_ETH_RSS_KEY) {
1701 BNX2X_ERR("failing rss configuration of vf %d due to size mismatch\n",
1703 vf->op_rc = -EINVAL;
1707 /* set vfop params according to rss tlv */
1708 memcpy(vf_op_params->ind_table, rss_tlv->ind_table,
1709 T_ETH_INDIRECTION_TABLE_SIZE);
1710 memcpy(vf_op_params->rss_key, rss_tlv->rss_key,
1711 sizeof(rss_tlv->rss_key));
1712 vf_op_params->rss_obj = &vf->rss_conf_obj;
1713 vf_op_params->rss_result_mask = rss_tlv->rss_result_mask;
1715 /* flags handled individually for backward/forward compatability */
1716 if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED)
1717 __set_bit(BNX2X_RSS_MODE_DISABLED, &vf_op_params->rss_flags);
1718 if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR)
1719 __set_bit(BNX2X_RSS_MODE_REGULAR, &vf_op_params->rss_flags);
1720 if (rss_tlv->rss_flags & VFPF_RSS_SET_SRCH)
1721 __set_bit(BNX2X_RSS_SET_SRCH, &vf_op_params->rss_flags);
1722 if (rss_tlv->rss_flags & VFPF_RSS_IPV4)
1723 __set_bit(BNX2X_RSS_IPV4, &vf_op_params->rss_flags);
1724 if (rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP)
1725 __set_bit(BNX2X_RSS_IPV4_TCP, &vf_op_params->rss_flags);
1726 if (rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP)
1727 __set_bit(BNX2X_RSS_IPV4_UDP, &vf_op_params->rss_flags);
1728 if (rss_tlv->rss_flags & VFPF_RSS_IPV6)
1729 __set_bit(BNX2X_RSS_IPV6, &vf_op_params->rss_flags);
1730 if (rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP)
1731 __set_bit(BNX2X_RSS_IPV6_TCP, &vf_op_params->rss_flags);
1732 if (rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)
1733 __set_bit(BNX2X_RSS_IPV6_UDP, &vf_op_params->rss_flags);
1735 if ((!(rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP) &&
1736 rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP) ||
1737 (!(rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP) &&
1738 rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)) {
1739 BNX2X_ERR("about to hit a FW assert. aborting...\n");
1740 vf->op_rc = -EINVAL;
1744 vf->op_rc = bnx2x_vfop_rss_cmd(bp, vf, &cmd);
1748 bnx2x_vf_mbx_resp(bp, vf);
1751 /* dispatch request */
1752 static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
1753 struct bnx2x_vf_mbx *mbx)
1757 /* check if tlv type is known */
1758 if (bnx2x_tlv_supported(mbx->first_tlv.tl.type)) {
1759 /* Lock the per vf op mutex and note the locker's identity.
1760 * The unlock will take place in mbx response.
1762 bnx2x_lock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
1764 /* switch on the opcode */
1765 switch (mbx->first_tlv.tl.type) {
1766 case CHANNEL_TLV_ACQUIRE:
1767 bnx2x_vf_mbx_acquire(bp, vf, mbx);
1769 case CHANNEL_TLV_INIT:
1770 bnx2x_vf_mbx_init_vf(bp, vf, mbx);
1772 case CHANNEL_TLV_SETUP_Q:
1773 bnx2x_vf_mbx_setup_q(bp, vf, mbx);
1775 case CHANNEL_TLV_SET_Q_FILTERS:
1776 bnx2x_vf_mbx_set_q_filters(bp, vf, mbx);
1778 case CHANNEL_TLV_TEARDOWN_Q:
1779 bnx2x_vf_mbx_teardown_q(bp, vf, mbx);
1781 case CHANNEL_TLV_CLOSE:
1782 bnx2x_vf_mbx_close_vf(bp, vf, mbx);
1784 case CHANNEL_TLV_RELEASE:
1785 bnx2x_vf_mbx_release_vf(bp, vf, mbx);
1787 case CHANNEL_TLV_UPDATE_RSS:
1788 bnx2x_vf_mbx_update_rss(bp, vf, mbx);
1793 /* unknown TLV - this may belong to a VF driver from the future
1794 * - a version written after this PF driver was written, which
1795 * supports features unknown as of yet. Too bad since we don't
1796 * support them. Or this may be because someone wrote a crappy
1797 * VF driver and is sending garbage over the channel.
1799 BNX2X_ERR("unknown TLV. type %d length %d vf->state was %d. first 20 bytes of mailbox buffer:\n",
1800 mbx->first_tlv.tl.type, mbx->first_tlv.tl.length,
1802 for (i = 0; i < 20; i++)
1803 DP_CONT(BNX2X_MSG_IOV, "%x ",
1804 mbx->msg->req.tlv_buf_size.tlv_buffer[i]);
1806 /* test whether we can respond to the VF (do we have an address
1809 if (vf->state == VF_ACQUIRED || vf->state == VF_ENABLED) {
1810 /* mbx_resp uses the op_rc of the VF */
1811 vf->op_rc = PFVF_STATUS_NOT_SUPPORTED;
1813 /* notify the VF that we do not support this request */
1814 bnx2x_vf_mbx_resp(bp, vf);
1816 /* can't send a response since this VF is unknown to us
1817 * just ack the FW to release the mailbox and unlock
1820 storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
1822 bnx2x_unlock_vf_pf_channel(bp, vf,
1823 mbx->first_tlv.tl.type);
1828 /* handle new vf-pf message */
1829 void bnx2x_vf_mbx(struct bnx2x *bp, struct vf_pf_event_data *vfpf_event)
1831 struct bnx2x_virtf *vf;
1832 struct bnx2x_vf_mbx *mbx;
1837 "vf pf event received: vfid %d, address_hi %x, address lo %x",
1838 vfpf_event->vf_id, vfpf_event->msg_addr_hi, vfpf_event->msg_addr_lo);
1839 /* Sanity checks consider removing later */
1841 /* check if the vf_id is valid */
1842 if (vfpf_event->vf_id - BP_VFDB(bp)->sriov.first_vf_in_pf >
1843 BNX2X_NR_VIRTFN(bp)) {
1844 BNX2X_ERR("Illegal vf_id %d max allowed: %d\n",
1845 vfpf_event->vf_id, BNX2X_NR_VIRTFN(bp));
1848 vf_idx = bnx2x_vf_idx_by_abs_fid(bp, vfpf_event->vf_id);
1849 mbx = BP_VF_MBX(bp, vf_idx);
1851 /* verify an event is not currently being processed -
1852 * debug failsafe only
1854 if (mbx->flags & VF_MSG_INPROCESS) {
1855 BNX2X_ERR("Previous message is still being processed, vf_id %d\n",
1859 vf = BP_VF(bp, vf_idx);
1861 /* save the VF message address */
1862 mbx->vf_addr_hi = vfpf_event->msg_addr_hi;
1863 mbx->vf_addr_lo = vfpf_event->msg_addr_lo;
1864 DP(BNX2X_MSG_IOV, "mailbox vf address hi 0x%x, lo 0x%x, offset 0x%x\n",
1865 mbx->vf_addr_hi, mbx->vf_addr_lo, mbx->first_tlv.resp_msg_offset);
1867 /* dmae to get the VF request */
1868 rc = bnx2x_copy32_vf_dmae(bp, true, mbx->msg_mapping, vf->abs_vfid,
1869 mbx->vf_addr_hi, mbx->vf_addr_lo,
1870 sizeof(union vfpf_tlvs)/4);
1872 BNX2X_ERR("Failed to copy request VF %d\n", vf->abs_vfid);
1876 /* process the VF message header */
1877 mbx->first_tlv = mbx->msg->req.first_tlv;
1879 /* dispatch the request (will prepare the response) */
1880 bnx2x_vf_mbx_request(bp, vf, mbx);
1884 bnx2x_vf_release(bp, vf, false); /* non blocking */
1889 /* propagate local bulletin board to vf */
1890 int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf)
1892 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf);
1893 dma_addr_t pf_addr = BP_VF_BULLETIN_DMA(bp)->mapping +
1894 vf * BULLETIN_CONTENT_SIZE;
1895 dma_addr_t vf_addr = bnx2x_vf(bp, vf, bulletin_map);
1898 /* can only update vf after init took place */
1899 if (bnx2x_vf(bp, vf, state) != VF_ENABLED &&
1900 bnx2x_vf(bp, vf, state) != VF_ACQUIRED)
1903 /* increment bulletin board version and compute crc */
1904 bulletin->version++;
1905 bulletin->length = BULLETIN_CONTENT_SIZE;
1906 bulletin->crc = bnx2x_crc_vf_bulletin(bp, bulletin);
1908 /* propagate bulletin board via dmae to vm memory */
1909 rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr,
1910 bnx2x_vf(bp, vf, abs_vfid), U64_HI(vf_addr),
1911 U64_LO(vf_addr), bulletin->length / 4);