1 /* bnx2x_vfpf.c: Broadcom Everest network driver.
2  *
3  * Copyright 2009-2013 Broadcom Corporation
4  *
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").
9  *
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
13  * consent.
14  *
15  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
16  * Written by: Shmulik Ravid
17  *	       Ariel Elior <ariel.elior@qlogic.com>
18  */
19 
20 #include "bnx2x.h"
21 #include "bnx2x_cmn.h"
22 #include <linux/crc32.h>
23 
24 static int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx);
25 
26 /* place a given tlv on the tlv buffer at a given offset */
27 static void bnx2x_add_tlv(struct bnx2x *bp, void *tlvs_list,
28 			  u16 offset, u16 type, u16 length)
29 {
30 	struct channel_tlv *tl =
31 		(struct channel_tlv *)(tlvs_list + offset);
32 
33 	tl->type = type;
34 	tl->length = length;
35 }
36 
37 /* Clear the mailbox and init the header of the first tlv */
38 static void bnx2x_vfpf_prep(struct bnx2x *bp, struct vfpf_first_tlv *first_tlv,
39 			    u16 type, u16 length)
40 {
41 	mutex_lock(&bp->vf2pf_mutex);
42 
43 	DP(BNX2X_MSG_IOV, "preparing to send %d tlv over vf pf channel\n",
44 	   type);
45 
46 	/* Clear mailbox */
47 	memset(bp->vf2pf_mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
48 
49 	/* init type and length */
50 	bnx2x_add_tlv(bp, &first_tlv->tl, 0, type, length);
51 
52 	/* init first tlv header */
53 	first_tlv->resp_msg_offset = sizeof(bp->vf2pf_mbox->req);
54 }
55 
56 /* releases the mailbox */
57 static void bnx2x_vfpf_finalize(struct bnx2x *bp,
58 				struct vfpf_first_tlv *first_tlv)
59 {
60 	DP(BNX2X_MSG_IOV, "done sending [%d] tlv over vf pf channel\n",
61 	   first_tlv->tl.type);
62 
63 	mutex_unlock(&bp->vf2pf_mutex);
64 }
65 
66 /* Finds a TLV by type in a TLV buffer; If found, returns pointer to the TLV */
67 static void *bnx2x_search_tlv_list(struct bnx2x *bp, void *tlvs_list,
68 				   enum channel_tlvs req_tlv)
69 {
70 	struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
71 
72 	do {
73 		if (tlv->type == req_tlv)
74 			return tlv;
75 
76 		if (!tlv->length) {
77 			BNX2X_ERR("Found TLV with length 0\n");
78 			return NULL;
79 		}
80 
81 		tlvs_list += tlv->length;
82 		tlv = (struct channel_tlv *)tlvs_list;
83 	} while (tlv->type != CHANNEL_TLV_LIST_END);
84 
85 	DP(BNX2X_MSG_IOV, "TLV list does not contain %d TLV\n", req_tlv);
86 
87 	return NULL;
88 }
89 
90 /* list the types and lengths of the tlvs on the buffer */
91 static void bnx2x_dp_tlv_list(struct bnx2x *bp, void *tlvs_list)
92 {
93 	int i = 1;
94 	struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
95 
96 	while (tlv->type != CHANNEL_TLV_LIST_END) {
97 		/* output tlv */
98 		DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
99 		   tlv->type, tlv->length);
100 
101 		/* advance to next tlv */
102 		tlvs_list += tlv->length;
103 
104 		/* cast general tlv list pointer to channel tlv header*/
105 		tlv = (struct channel_tlv *)tlvs_list;
106 
107 		i++;
108 
109 		/* break condition for this loop */
110 		if (i > MAX_TLVS_IN_LIST) {
111 			WARN(true, "corrupt tlvs");
112 			return;
113 		}
114 	}
115 
116 	/* output last tlv */
117 	DP(BNX2X_MSG_IOV, "TLV number %d: type %d, length %d\n", i,
118 	   tlv->type, tlv->length);
119 }
120 
121 /* test whether we support a tlv type */
122 bool bnx2x_tlv_supported(u16 tlvtype)
123 {
124 	return CHANNEL_TLV_NONE < tlvtype && tlvtype < CHANNEL_TLV_MAX;
125 }
126 
127 static inline int bnx2x_pfvf_status_codes(int rc)
128 {
129 	switch (rc) {
130 	case 0:
131 		return PFVF_STATUS_SUCCESS;
132 	case -ENOMEM:
133 		return PFVF_STATUS_NO_RESOURCE;
134 	default:
135 		return PFVF_STATUS_FAILURE;
136 	}
137 }
138 
139 static int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping)
140 {
141 	struct cstorm_vf_zone_data __iomem *zone_data =
142 		REG_ADDR(bp, PXP_VF_ADDR_CSDM_GLOBAL_START);
143 	int tout = 100, interval = 100; /* wait for 10 seconds */
144 
145 	if (*done) {
146 		BNX2X_ERR("done was non zero before message to pf was sent\n");
147 		WARN_ON(true);
148 		return -EINVAL;
149 	}
150 
151 	/* if PF indicated channel is down avoid sending message. Return success
152 	 * so calling flow can continue
153 	 */
154 	bnx2x_sample_bulletin(bp);
155 	if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
156 		DP(BNX2X_MSG_IOV, "detecting channel down. Aborting message\n");
157 		*done = PFVF_STATUS_SUCCESS;
158 		return -EINVAL;
159 	}
160 
161 	/* Write message address */
162 	writel(U64_LO(msg_mapping),
163 	       &zone_data->non_trigger.vf_pf_channel.msg_addr_lo);
164 	writel(U64_HI(msg_mapping),
165 	       &zone_data->non_trigger.vf_pf_channel.msg_addr_hi);
166 
167 	/* make sure the address is written before FW accesses it */
168 	wmb();
169 
170 	/* Trigger the PF FW */
171 	writeb(1, &zone_data->trigger.vf_pf_channel.addr_valid);
172 
173 	/* Wait for PF to complete */
174 	while ((tout >= 0) && (!*done)) {
175 		msleep(interval);
176 		tout -= 1;
177 
178 		/* progress indicator - HV can take its own sweet time in
179 		 * answering VFs...
180 		 */
181 		DP_CONT(BNX2X_MSG_IOV, ".");
182 	}
183 
184 	if (!*done) {
185 		BNX2X_ERR("PF response has timed out\n");
186 		return -EAGAIN;
187 	}
188 	DP(BNX2X_MSG_SP, "Got a response from PF\n");
189 	return 0;
190 }
191 
192 static int bnx2x_get_vf_id(struct bnx2x *bp, u32 *vf_id)
193 {
194 	u32 me_reg;
195 	int tout = 10, interval = 100; /* Wait for 1 sec */
196 
197 	do {
198 		/* pxp traps vf read of doorbells and returns me reg value */
199 		me_reg = readl(bp->doorbells);
200 		if (GOOD_ME_REG(me_reg))
201 			break;
202 
203 		msleep(interval);
204 
205 		BNX2X_ERR("Invalid ME register value: 0x%08x\n. Is pf driver up?",
206 			  me_reg);
207 	} while (tout-- > 0);
208 
209 	if (!GOOD_ME_REG(me_reg)) {
210 		BNX2X_ERR("Invalid ME register value: 0x%08x\n", me_reg);
211 		return -EINVAL;
212 	}
213 
214 	DP(BNX2X_MSG_IOV, "valid ME register value: 0x%08x\n", me_reg);
215 
216 	*vf_id = (me_reg & ME_REG_VF_NUM_MASK) >> ME_REG_VF_NUM_SHIFT;
217 
218 	return 0;
219 }
220 
221 int bnx2x_vfpf_acquire(struct bnx2x *bp, u8 tx_count, u8 rx_count)
222 {
223 	int rc = 0, attempts = 0;
224 	struct vfpf_acquire_tlv *req = &bp->vf2pf_mbox->req.acquire;
225 	struct pfvf_acquire_resp_tlv *resp = &bp->vf2pf_mbox->resp.acquire_resp;
226 	struct vfpf_port_phys_id_resp_tlv *phys_port_resp;
227 	u32 vf_id;
228 	bool resources_acquired = false;
229 
230 	/* clear mailbox and prep first tlv */
231 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_ACQUIRE, sizeof(*req));
232 
233 	if (bnx2x_get_vf_id(bp, &vf_id)) {
234 		rc = -EAGAIN;
235 		goto out;
236 	}
237 
238 	req->vfdev_info.vf_id = vf_id;
239 	req->vfdev_info.vf_os = 0;
240 
241 	req->resc_request.num_rxqs = rx_count;
242 	req->resc_request.num_txqs = tx_count;
243 	req->resc_request.num_sbs = bp->igu_sb_cnt;
244 	req->resc_request.num_mac_filters = VF_ACQUIRE_MAC_FILTERS;
245 	req->resc_request.num_mc_filters = VF_ACQUIRE_MC_FILTERS;
246 
247 	/* pf 2 vf bulletin board address */
248 	req->bulletin_addr = bp->pf2vf_bulletin_mapping;
249 
250 	/* Request physical port identifier */
251 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length,
252 		      CHANNEL_TLV_PHYS_PORT_ID, sizeof(struct channel_tlv));
253 
254 	/* Bulletin support for bulletin board with length > legacy length */
255 	req->vfdev_info.caps |= VF_CAP_SUPPORT_EXT_BULLETIN;
256 
257 	/* add list termination tlv */
258 	bnx2x_add_tlv(bp, req,
259 		      req->first_tlv.tl.length + sizeof(struct channel_tlv),
260 		      CHANNEL_TLV_LIST_END,
261 		      sizeof(struct channel_list_end_tlv));
262 
263 	/* output tlvs list */
264 	bnx2x_dp_tlv_list(bp, req);
265 
266 	while (!resources_acquired) {
267 		DP(BNX2X_MSG_SP, "attempting to acquire resources\n");
268 
269 		/* send acquire request */
270 		rc = bnx2x_send_msg2pf(bp,
271 				       &resp->hdr.status,
272 				       bp->vf2pf_mbox_mapping);
273 
274 		/* PF timeout */
275 		if (rc)
276 			goto out;
277 
278 		/* copy acquire response from buffer to bp */
279 		memcpy(&bp->acquire_resp, resp, sizeof(bp->acquire_resp));
280 
281 		attempts++;
282 
283 		/* test whether the PF accepted our request. If not, humble
284 		 * the request and try again.
285 		 */
286 		if (bp->acquire_resp.hdr.status == PFVF_STATUS_SUCCESS) {
287 			DP(BNX2X_MSG_SP, "resources acquired\n");
288 			resources_acquired = true;
289 		} else if (bp->acquire_resp.hdr.status ==
290 			   PFVF_STATUS_NO_RESOURCE &&
291 			   attempts < VF_ACQUIRE_THRESH) {
292 			DP(BNX2X_MSG_SP,
293 			   "PF unwilling to fulfill resource request. Try PF recommended amount\n");
294 
295 			/* humble our request */
296 			req->resc_request.num_txqs =
297 				min(req->resc_request.num_txqs,
298 				    bp->acquire_resp.resc.num_txqs);
299 			req->resc_request.num_rxqs =
300 				min(req->resc_request.num_rxqs,
301 				    bp->acquire_resp.resc.num_rxqs);
302 			req->resc_request.num_sbs =
303 				min(req->resc_request.num_sbs,
304 				    bp->acquire_resp.resc.num_sbs);
305 			req->resc_request.num_mac_filters =
306 				min(req->resc_request.num_mac_filters,
307 				    bp->acquire_resp.resc.num_mac_filters);
308 			req->resc_request.num_vlan_filters =
309 				min(req->resc_request.num_vlan_filters,
310 				    bp->acquire_resp.resc.num_vlan_filters);
311 			req->resc_request.num_mc_filters =
312 				min(req->resc_request.num_mc_filters,
313 				    bp->acquire_resp.resc.num_mc_filters);
314 
315 			/* Clear response buffer */
316 			memset(&bp->vf2pf_mbox->resp, 0,
317 			       sizeof(union pfvf_tlvs));
318 		} else {
319 			/* PF reports error */
320 			BNX2X_ERR("Failed to get the requested amount of resources: %d. Breaking...\n",
321 				  bp->acquire_resp.hdr.status);
322 			rc = -EAGAIN;
323 			goto out;
324 		}
325 	}
326 
327 	/* Retrieve physical port id (if possible) */
328 	phys_port_resp = (struct vfpf_port_phys_id_resp_tlv *)
329 			 bnx2x_search_tlv_list(bp, resp,
330 					       CHANNEL_TLV_PHYS_PORT_ID);
331 	if (phys_port_resp) {
332 		memcpy(bp->phys_port_id, phys_port_resp->id, ETH_ALEN);
333 		bp->flags |= HAS_PHYS_PORT_ID;
334 	}
335 
336 	/* get HW info */
337 	bp->common.chip_id |= (bp->acquire_resp.pfdev_info.chip_num & 0xffff);
338 	bp->link_params.chip_id = bp->common.chip_id;
339 	bp->db_size = bp->acquire_resp.pfdev_info.db_size;
340 	bp->common.int_block = INT_BLOCK_IGU;
341 	bp->common.chip_port_mode = CHIP_2_PORT_MODE;
342 	bp->igu_dsb_id = -1;
343 	bp->mf_ov = 0;
344 	bp->mf_mode = 0;
345 	bp->common.flash_size = 0;
346 	bp->flags |=
347 		NO_WOL_FLAG | NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG | NO_FCOE_FLAG;
348 	bp->igu_sb_cnt = bp->acquire_resp.resc.num_sbs;
349 	bp->igu_base_sb = bp->acquire_resp.resc.hw_sbs[0].hw_sb_id;
350 	strlcpy(bp->fw_ver, bp->acquire_resp.pfdev_info.fw_ver,
351 		sizeof(bp->fw_ver));
352 
353 	if (is_valid_ether_addr(bp->acquire_resp.resc.current_mac_addr))
354 		memcpy(bp->dev->dev_addr,
355 		       bp->acquire_resp.resc.current_mac_addr,
356 		       ETH_ALEN);
357 
358 out:
359 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
360 	return rc;
361 }
362 
363 int bnx2x_vfpf_release(struct bnx2x *bp)
364 {
365 	struct vfpf_release_tlv *req = &bp->vf2pf_mbox->req.release;
366 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
367 	u32 rc, vf_id;
368 
369 	/* clear mailbox and prep first tlv */
370 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_RELEASE, sizeof(*req));
371 
372 	if (bnx2x_get_vf_id(bp, &vf_id)) {
373 		rc = -EAGAIN;
374 		goto out;
375 	}
376 
377 	req->vf_id = vf_id;
378 
379 	/* add list termination tlv */
380 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
381 		      sizeof(struct channel_list_end_tlv));
382 
383 	/* output tlvs list */
384 	bnx2x_dp_tlv_list(bp, req);
385 
386 	/* send release request */
387 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
388 
389 	if (rc)
390 		/* PF timeout */
391 		goto out;
392 
393 	if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
394 		/* PF released us */
395 		DP(BNX2X_MSG_SP, "vf released\n");
396 	} else {
397 		/* PF reports error */
398 		BNX2X_ERR("PF failed our release request - are we out of sync? Response status: %d\n",
399 			  resp->hdr.status);
400 		rc = -EAGAIN;
401 		goto out;
402 	}
403 out:
404 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
405 
406 	return rc;
407 }
408 
409 /* Tell PF about SB addresses */
410 int bnx2x_vfpf_init(struct bnx2x *bp)
411 {
412 	struct vfpf_init_tlv *req = &bp->vf2pf_mbox->req.init;
413 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
414 	int rc, i;
415 
416 	/* clear mailbox and prep first tlv */
417 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_INIT, sizeof(*req));
418 
419 	/* status blocks */
420 	for_each_eth_queue(bp, i)
421 		req->sb_addr[i] = (dma_addr_t)bnx2x_fp(bp, i,
422 						       status_blk_mapping);
423 
424 	/* statistics - requests only supports single queue for now */
425 	req->stats_addr = bp->fw_stats_data_mapping +
426 			  offsetof(struct bnx2x_fw_stats_data, queue_stats);
427 
428 	req->stats_stride = sizeof(struct per_queue_stats);
429 
430 	/* add list termination tlv */
431 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
432 		      sizeof(struct channel_list_end_tlv));
433 
434 	/* output tlvs list */
435 	bnx2x_dp_tlv_list(bp, req);
436 
437 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
438 	if (rc)
439 		goto out;
440 
441 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
442 		BNX2X_ERR("INIT VF failed: %d. Breaking...\n",
443 			  resp->hdr.status);
444 		rc = -EAGAIN;
445 		goto out;
446 	}
447 
448 	DP(BNX2X_MSG_SP, "INIT VF Succeeded\n");
449 out:
450 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
451 
452 	return rc;
453 }
454 
455 /* CLOSE VF - opposite to INIT_VF */
456 void bnx2x_vfpf_close_vf(struct bnx2x *bp)
457 {
458 	struct vfpf_close_tlv *req = &bp->vf2pf_mbox->req.close;
459 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
460 	int i, rc;
461 	u32 vf_id;
462 
463 	/* If we haven't got a valid VF id, there is no sense to
464 	 * continue with sending messages
465 	 */
466 	if (bnx2x_get_vf_id(bp, &vf_id))
467 		goto free_irq;
468 
469 	/* Close the queues */
470 	for_each_queue(bp, i)
471 		bnx2x_vfpf_teardown_queue(bp, i);
472 
473 	/* remove mac */
474 	bnx2x_vfpf_config_mac(bp, bp->dev->dev_addr, bp->fp->index, false);
475 
476 	/* clear mailbox and prep first tlv */
477 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_CLOSE, sizeof(*req));
478 
479 	req->vf_id = vf_id;
480 
481 	/* add list termination tlv */
482 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
483 		      sizeof(struct channel_list_end_tlv));
484 
485 	/* output tlvs list */
486 	bnx2x_dp_tlv_list(bp, req);
487 
488 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
489 
490 	if (rc)
491 		BNX2X_ERR("Sending CLOSE failed. rc was: %d\n", rc);
492 
493 	else if (resp->hdr.status != PFVF_STATUS_SUCCESS)
494 		BNX2X_ERR("Sending CLOSE failed: pf response was %d\n",
495 			  resp->hdr.status);
496 
497 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
498 
499 free_irq:
500 	/* Disable HW interrupts, NAPI */
501 	bnx2x_netif_stop(bp, 0);
502 	/* Delete all NAPI objects */
503 	bnx2x_del_all_napi(bp);
504 
505 	/* Release IRQs */
506 	bnx2x_free_irq(bp);
507 }
508 
509 static void bnx2x_leading_vfq_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
510 				   struct bnx2x_vf_queue *q)
511 {
512 	u8 cl_id = vfq_cl_id(vf, q);
513 	u8 func_id = FW_VF_HANDLE(vf->abs_vfid);
514 
515 	/* mac */
516 	bnx2x_init_mac_obj(bp, &q->mac_obj,
517 			   cl_id, q->cid, func_id,
518 			   bnx2x_vf_sp(bp, vf, mac_rdata),
519 			   bnx2x_vf_sp_map(bp, vf, mac_rdata),
520 			   BNX2X_FILTER_MAC_PENDING,
521 			   &vf->filter_state,
522 			   BNX2X_OBJ_TYPE_RX_TX,
523 			   &bp->macs_pool);
524 	/* vlan */
525 	bnx2x_init_vlan_obj(bp, &q->vlan_obj,
526 			    cl_id, q->cid, func_id,
527 			    bnx2x_vf_sp(bp, vf, vlan_rdata),
528 			    bnx2x_vf_sp_map(bp, vf, vlan_rdata),
529 			    BNX2X_FILTER_VLAN_PENDING,
530 			    &vf->filter_state,
531 			    BNX2X_OBJ_TYPE_RX_TX,
532 			    &bp->vlans_pool);
533 
534 	/* mcast */
535 	bnx2x_init_mcast_obj(bp, &vf->mcast_obj, cl_id,
536 			     q->cid, func_id, func_id,
537 			     bnx2x_vf_sp(bp, vf, mcast_rdata),
538 			     bnx2x_vf_sp_map(bp, vf, mcast_rdata),
539 			     BNX2X_FILTER_MCAST_PENDING,
540 			     &vf->filter_state,
541 			     BNX2X_OBJ_TYPE_RX_TX);
542 
543 	/* rss */
544 	bnx2x_init_rss_config_obj(bp, &vf->rss_conf_obj, cl_id, q->cid,
545 				  func_id, func_id,
546 				  bnx2x_vf_sp(bp, vf, rss_rdata),
547 				  bnx2x_vf_sp_map(bp, vf, rss_rdata),
548 				  BNX2X_FILTER_RSS_CONF_PENDING,
549 				  &vf->filter_state,
550 				  BNX2X_OBJ_TYPE_RX_TX);
551 
552 	vf->leading_rss = cl_id;
553 	q->is_leading = true;
554 	q->sp_initialized = true;
555 }
556 
557 /* ask the pf to open a queue for the vf */
558 int bnx2x_vfpf_setup_q(struct bnx2x *bp, struct bnx2x_fastpath *fp,
559 		       bool is_leading)
560 {
561 	struct vfpf_setup_q_tlv *req = &bp->vf2pf_mbox->req.setup_q;
562 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
563 	u8 fp_idx = fp->index;
564 	u16 tpa_agg_size = 0, flags = 0;
565 	int rc;
566 
567 	/* clear mailbox and prep first tlv */
568 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SETUP_Q, sizeof(*req));
569 
570 	/* select tpa mode to request */
571 	if (!fp->disable_tpa) {
572 		flags |= VFPF_QUEUE_FLG_TPA;
573 		flags |= VFPF_QUEUE_FLG_TPA_IPV6;
574 		if (fp->mode == TPA_MODE_GRO)
575 			flags |= VFPF_QUEUE_FLG_TPA_GRO;
576 		tpa_agg_size = TPA_AGG_SIZE;
577 	}
578 
579 	if (is_leading)
580 		flags |= VFPF_QUEUE_FLG_LEADING_RSS;
581 
582 	/* calculate queue flags */
583 	flags |= VFPF_QUEUE_FLG_STATS;
584 	flags |= VFPF_QUEUE_FLG_CACHE_ALIGN;
585 	flags |= VFPF_QUEUE_FLG_VLAN;
586 	DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
587 
588 	/* Common */
589 	req->vf_qid = fp_idx;
590 	req->param_valid = VFPF_RXQ_VALID | VFPF_TXQ_VALID;
591 
592 	/* Rx */
593 	req->rxq.rcq_addr = fp->rx_comp_mapping;
594 	req->rxq.rcq_np_addr = fp->rx_comp_mapping + BCM_PAGE_SIZE;
595 	req->rxq.rxq_addr = fp->rx_desc_mapping;
596 	req->rxq.sge_addr = fp->rx_sge_mapping;
597 	req->rxq.vf_sb = fp_idx;
598 	req->rxq.sb_index = HC_INDEX_ETH_RX_CQ_CONS;
599 	req->rxq.hc_rate = bp->rx_ticks ? 1000000/bp->rx_ticks : 0;
600 	req->rxq.mtu = bp->dev->mtu;
601 	req->rxq.buf_sz = fp->rx_buf_size;
602 	req->rxq.sge_buf_sz = BCM_PAGE_SIZE * PAGES_PER_SGE;
603 	req->rxq.tpa_agg_sz = tpa_agg_size;
604 	req->rxq.max_sge_pkt = SGE_PAGE_ALIGN(bp->dev->mtu) >> SGE_PAGE_SHIFT;
605 	req->rxq.max_sge_pkt = ((req->rxq.max_sge_pkt + PAGES_PER_SGE - 1) &
606 			  (~(PAGES_PER_SGE-1))) >> PAGES_PER_SGE_SHIFT;
607 	req->rxq.flags = flags;
608 	req->rxq.drop_flags = 0;
609 	req->rxq.cache_line_log = BNX2X_RX_ALIGN_SHIFT;
610 	req->rxq.stat_id = -1; /* No stats at the moment */
611 
612 	/* Tx */
613 	req->txq.txq_addr = fp->txdata_ptr[FIRST_TX_COS_INDEX]->tx_desc_mapping;
614 	req->txq.vf_sb = fp_idx;
615 	req->txq.sb_index = HC_INDEX_ETH_TX_CQ_CONS_COS0;
616 	req->txq.hc_rate = bp->tx_ticks ? 1000000/bp->tx_ticks : 0;
617 	req->txq.flags = flags;
618 	req->txq.traffic_type = LLFC_TRAFFIC_TYPE_NW;
619 
620 	/* add list termination tlv */
621 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
622 		      sizeof(struct channel_list_end_tlv));
623 
624 	/* output tlvs list */
625 	bnx2x_dp_tlv_list(bp, req);
626 
627 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
628 	if (rc)
629 		BNX2X_ERR("Sending SETUP_Q message for queue[%d] failed!\n",
630 			  fp_idx);
631 
632 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
633 		BNX2X_ERR("Status of SETUP_Q for queue[%d] is %d\n",
634 			  fp_idx, resp->hdr.status);
635 		rc = -EINVAL;
636 	}
637 
638 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
639 
640 	return rc;
641 }
642 
643 static int bnx2x_vfpf_teardown_queue(struct bnx2x *bp, int qidx)
644 {
645 	struct vfpf_q_op_tlv *req = &bp->vf2pf_mbox->req.q_op;
646 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
647 	int rc;
648 
649 	/* clear mailbox and prep first tlv */
650 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_TEARDOWN_Q,
651 			sizeof(*req));
652 
653 	req->vf_qid = qidx;
654 
655 	/* add list termination tlv */
656 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
657 		      sizeof(struct channel_list_end_tlv));
658 
659 	/* output tlvs list */
660 	bnx2x_dp_tlv_list(bp, req);
661 
662 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
663 
664 	if (rc) {
665 		BNX2X_ERR("Sending TEARDOWN for queue %d failed: %d\n", qidx,
666 			  rc);
667 		goto out;
668 	}
669 
670 	/* PF failed the transaction */
671 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
672 		BNX2X_ERR("TEARDOWN for queue %d failed: %d\n", qidx,
673 			  resp->hdr.status);
674 		rc = -EINVAL;
675 	}
676 
677 out:
678 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
679 
680 	return rc;
681 }
682 
683 /* request pf to add a mac for the vf */
684 int bnx2x_vfpf_config_mac(struct bnx2x *bp, u8 *addr, u8 vf_qid, bool set)
685 {
686 	struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
687 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
688 	struct pf_vf_bulletin_content bulletin = bp->pf2vf_bulletin->content;
689 	int rc = 0;
690 
691 	/* clear mailbox and prep first tlv */
692 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
693 			sizeof(*req));
694 
695 	req->flags = VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED;
696 	req->vf_qid = vf_qid;
697 	req->n_mac_vlan_filters = 1;
698 
699 	req->filters[0].flags = VFPF_Q_FILTER_DEST_MAC_VALID;
700 	if (set)
701 		req->filters[0].flags |= VFPF_Q_FILTER_SET_MAC;
702 
703 	/* sample bulletin board for new mac */
704 	bnx2x_sample_bulletin(bp);
705 
706 	/* copy mac from device to request */
707 	memcpy(req->filters[0].mac, addr, ETH_ALEN);
708 
709 	/* add list termination tlv */
710 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
711 		      sizeof(struct channel_list_end_tlv));
712 
713 	/* output tlvs list */
714 	bnx2x_dp_tlv_list(bp, req);
715 
716 	/* send message to pf */
717 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
718 	if (rc) {
719 		BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
720 		goto out;
721 	}
722 
723 	/* failure may mean PF was configured with a new mac for us */
724 	while (resp->hdr.status == PFVF_STATUS_FAILURE) {
725 		DP(BNX2X_MSG_IOV,
726 		   "vfpf SET MAC failed. Check bulletin board for new posts\n");
727 
728 		/* copy mac from bulletin to device */
729 		memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN);
730 
731 		/* check if bulletin board was updated */
732 		if (bnx2x_sample_bulletin(bp) == PFVF_BULLETIN_UPDATED) {
733 			/* copy mac from device to request */
734 			memcpy(req->filters[0].mac, bp->dev->dev_addr,
735 			       ETH_ALEN);
736 
737 			/* send message to pf */
738 			rc = bnx2x_send_msg2pf(bp, &resp->hdr.status,
739 					       bp->vf2pf_mbox_mapping);
740 		} else {
741 			/* no new info in bulletin */
742 			break;
743 		}
744 	}
745 
746 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
747 		BNX2X_ERR("vfpf SET MAC failed: %d\n", resp->hdr.status);
748 		rc = -EINVAL;
749 	}
750 out:
751 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
752 
753 	return rc;
754 }
755 
756 /* request pf to config rss table for vf queues*/
757 int bnx2x_vfpf_config_rss(struct bnx2x *bp,
758 			  struct bnx2x_config_rss_params *params)
759 {
760 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
761 	struct vfpf_rss_tlv *req = &bp->vf2pf_mbox->req.update_rss;
762 	int rc = 0;
763 
764 	/* clear mailbox and prep first tlv */
765 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_UPDATE_RSS,
766 			sizeof(*req));
767 
768 	/* add list termination tlv */
769 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
770 		      sizeof(struct channel_list_end_tlv));
771 
772 	memcpy(req->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
773 	memcpy(req->rss_key, params->rss_key, sizeof(params->rss_key));
774 	req->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;
775 	req->rss_key_size = T_ETH_RSS_KEY;
776 	req->rss_result_mask = params->rss_result_mask;
777 
778 	/* flags handled individually for backward/forward compatability */
779 	if (params->rss_flags & (1 << BNX2X_RSS_MODE_DISABLED))
780 		req->rss_flags |= VFPF_RSS_MODE_DISABLED;
781 	if (params->rss_flags & (1 << BNX2X_RSS_MODE_REGULAR))
782 		req->rss_flags |= VFPF_RSS_MODE_REGULAR;
783 	if (params->rss_flags & (1 << BNX2X_RSS_SET_SRCH))
784 		req->rss_flags |= VFPF_RSS_SET_SRCH;
785 	if (params->rss_flags & (1 << BNX2X_RSS_IPV4))
786 		req->rss_flags |= VFPF_RSS_IPV4;
787 	if (params->rss_flags & (1 << BNX2X_RSS_IPV4_TCP))
788 		req->rss_flags |= VFPF_RSS_IPV4_TCP;
789 	if (params->rss_flags & (1 << BNX2X_RSS_IPV4_UDP))
790 		req->rss_flags |= VFPF_RSS_IPV4_UDP;
791 	if (params->rss_flags & (1 << BNX2X_RSS_IPV6))
792 		req->rss_flags |= VFPF_RSS_IPV6;
793 	if (params->rss_flags & (1 << BNX2X_RSS_IPV6_TCP))
794 		req->rss_flags |= VFPF_RSS_IPV6_TCP;
795 	if (params->rss_flags & (1 << BNX2X_RSS_IPV6_UDP))
796 		req->rss_flags |= VFPF_RSS_IPV6_UDP;
797 
798 	DP(BNX2X_MSG_IOV, "rss flags %x\n", req->rss_flags);
799 
800 	/* output tlvs list */
801 	bnx2x_dp_tlv_list(bp, req);
802 
803 	/* send message to pf */
804 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
805 	if (rc) {
806 		BNX2X_ERR("failed to send message to pf. rc was %d\n", rc);
807 		goto out;
808 	}
809 
810 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
811 		/* Since older drivers don't support this feature (and VF has
812 		 * no way of knowing other than failing this), don't propagate
813 		 * an error in this case.
814 		 */
815 		DP(BNX2X_MSG_IOV,
816 		   "Failed to send rss message to PF over VF-PF channel [%d]\n",
817 		   resp->hdr.status);
818 	}
819 out:
820 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
821 
822 	return rc;
823 }
824 
825 int bnx2x_vfpf_set_mcast(struct net_device *dev)
826 {
827 	struct bnx2x *bp = netdev_priv(dev);
828 	struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
829 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
830 	int rc, i = 0;
831 	struct netdev_hw_addr *ha;
832 
833 	if (bp->state != BNX2X_STATE_OPEN) {
834 		DP(NETIF_MSG_IFUP, "state is %x, returning\n", bp->state);
835 		return -EINVAL;
836 	}
837 
838 	/* clear mailbox and prep first tlv */
839 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
840 			sizeof(*req));
841 
842 	/* Get Rx mode requested */
843 	DP(NETIF_MSG_IFUP, "dev->flags = %x\n", dev->flags);
844 
845 	netdev_for_each_mc_addr(ha, dev) {
846 		DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
847 		   bnx2x_mc_addr(ha));
848 		memcpy(req->multicast[i], bnx2x_mc_addr(ha), ETH_ALEN);
849 		i++;
850 	}
851 
852 	/* We support four PFVF_MAX_MULTICAST_PER_VF mcast
853 	  * addresses tops
854 	  */
855 	if (i >= PFVF_MAX_MULTICAST_PER_VF) {
856 		DP(NETIF_MSG_IFUP,
857 		   "VF supports not more than %d multicast MAC addresses\n",
858 		   PFVF_MAX_MULTICAST_PER_VF);
859 		return -EINVAL;
860 	}
861 
862 	req->n_multicast = i;
863 	req->flags |= VFPF_SET_Q_FILTERS_MULTICAST_CHANGED;
864 	req->vf_qid = 0;
865 
866 	/* add list termination tlv */
867 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
868 		      sizeof(struct channel_list_end_tlv));
869 
870 	/* output tlvs list */
871 	bnx2x_dp_tlv_list(bp, req);
872 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
873 	if (rc) {
874 		BNX2X_ERR("Sending a message failed: %d\n", rc);
875 		goto out;
876 	}
877 
878 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
879 		BNX2X_ERR("Set Rx mode/multicast failed: %d\n",
880 			  resp->hdr.status);
881 		rc = -EINVAL;
882 	}
883 out:
884 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
885 
886 	return 0;
887 }
888 
889 int bnx2x_vfpf_storm_rx_mode(struct bnx2x *bp)
890 {
891 	int mode = bp->rx_mode;
892 	struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;
893 	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
894 	int rc;
895 
896 	/* clear mailbox and prep first tlv */
897 	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_SET_Q_FILTERS,
898 			sizeof(*req));
899 
900 	DP(NETIF_MSG_IFUP, "Rx mode is %d\n", mode);
901 
902 	/* Ignore everything accept MODE_NONE */
903 	if (mode  == BNX2X_RX_MODE_NONE) {
904 		req->rx_mask = VFPF_RX_MASK_ACCEPT_NONE;
905 	} else {
906 		/* Current PF driver will not look at the specific flags,
907 		 * but they are required when working with older drivers on hv.
908 		 */
909 		req->rx_mask = VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST;
910 		req->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
911 		req->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
912 	}
913 
914 	req->flags |= VFPF_SET_Q_FILTERS_RX_MASK_CHANGED;
915 	req->vf_qid = 0;
916 
917 	/* add list termination tlv */
918 	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
919 		      sizeof(struct channel_list_end_tlv));
920 
921 	/* output tlvs list */
922 	bnx2x_dp_tlv_list(bp, req);
923 
924 	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
925 	if (rc)
926 		BNX2X_ERR("Sending a message failed: %d\n", rc);
927 
928 	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
929 		BNX2X_ERR("Set Rx mode failed: %d\n", resp->hdr.status);
930 		rc = -EINVAL;
931 	}
932 
933 	bnx2x_vfpf_finalize(bp, &req->first_tlv);
934 
935 	return rc;
936 }
937 
938 /* General service functions */
939 static void storm_memset_vf_mbx_ack(struct bnx2x *bp, u16 abs_fid)
940 {
941 	u32 addr = BAR_CSTRORM_INTMEM +
942 		   CSTORM_VF_PF_CHANNEL_STATE_OFFSET(abs_fid);
943 
944 	REG_WR8(bp, addr, VF_PF_CHANNEL_STATE_READY);
945 }
946 
947 static void storm_memset_vf_mbx_valid(struct bnx2x *bp, u16 abs_fid)
948 {
949 	u32 addr = BAR_CSTRORM_INTMEM +
950 		   CSTORM_VF_PF_CHANNEL_VALID_OFFSET(abs_fid);
951 
952 	REG_WR8(bp, addr, 1);
953 }
954 
955 static inline void bnx2x_set_vf_mbxs_valid(struct bnx2x *bp)
956 {
957 	int i;
958 
959 	for_each_vf(bp, i)
960 		storm_memset_vf_mbx_valid(bp, bnx2x_vf(bp, i, abs_vfid));
961 }
962 
963 /* enable vf_pf mailbox (aka vf-pf-channel) */
964 void bnx2x_vf_enable_mbx(struct bnx2x *bp, u8 abs_vfid)
965 {
966 	bnx2x_vf_flr_clnup_epilog(bp, abs_vfid);
967 
968 	/* enable the mailbox in the FW */
969 	storm_memset_vf_mbx_ack(bp, abs_vfid);
970 	storm_memset_vf_mbx_valid(bp, abs_vfid);
971 
972 	/* enable the VF access to the mailbox */
973 	bnx2x_vf_enable_access(bp, abs_vfid);
974 }
975 
976 /* this works only on !E1h */
977 static int bnx2x_copy32_vf_dmae(struct bnx2x *bp, u8 from_vf,
978 				dma_addr_t pf_addr, u8 vfid, u32 vf_addr_hi,
979 				u32 vf_addr_lo, u32 len32)
980 {
981 	struct dmae_command dmae;
982 
983 	if (CHIP_IS_E1x(bp)) {
984 		BNX2X_ERR("Chip revision does not support VFs\n");
985 		return DMAE_NOT_RDY;
986 	}
987 
988 	if (!bp->dmae_ready) {
989 		BNX2X_ERR("DMAE is not ready, can not copy\n");
990 		return DMAE_NOT_RDY;
991 	}
992 
993 	/* set opcode and fixed command fields */
994 	bnx2x_prep_dmae_with_comp(bp, &dmae, DMAE_SRC_PCI, DMAE_DST_PCI);
995 
996 	if (from_vf) {
997 		dmae.opcode_iov = (vfid << DMAE_COMMAND_SRC_VFID_SHIFT) |
998 			(DMAE_SRC_VF << DMAE_COMMAND_SRC_VFPF_SHIFT) |
999 			(DMAE_DST_PF << DMAE_COMMAND_DST_VFPF_SHIFT);
1000 
1001 		dmae.opcode |= (DMAE_C_DST << DMAE_COMMAND_C_FUNC_SHIFT);
1002 
1003 		dmae.src_addr_lo = vf_addr_lo;
1004 		dmae.src_addr_hi = vf_addr_hi;
1005 		dmae.dst_addr_lo = U64_LO(pf_addr);
1006 		dmae.dst_addr_hi = U64_HI(pf_addr);
1007 	} else {
1008 		dmae.opcode_iov = (vfid << DMAE_COMMAND_DST_VFID_SHIFT) |
1009 			(DMAE_DST_VF << DMAE_COMMAND_DST_VFPF_SHIFT) |
1010 			(DMAE_SRC_PF << DMAE_COMMAND_SRC_VFPF_SHIFT);
1011 
1012 		dmae.opcode |= (DMAE_C_SRC << DMAE_COMMAND_C_FUNC_SHIFT);
1013 
1014 		dmae.src_addr_lo = U64_LO(pf_addr);
1015 		dmae.src_addr_hi = U64_HI(pf_addr);
1016 		dmae.dst_addr_lo = vf_addr_lo;
1017 		dmae.dst_addr_hi = vf_addr_hi;
1018 	}
1019 	dmae.len = len32;
1020 
1021 	/* issue the command and wait for completion */
1022 	return bnx2x_issue_dmae_with_comp(bp, &dmae, bnx2x_sp(bp, wb_comp));
1023 }
1024 
1025 static void bnx2x_vf_mbx_resp_single_tlv(struct bnx2x *bp,
1026 					 struct bnx2x_virtf *vf)
1027 {
1028 	struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf->index);
1029 	u16 length, type;
1030 
1031 	/* prepare response */
1032 	type = mbx->first_tlv.tl.type;
1033 	length = type == CHANNEL_TLV_ACQUIRE ?
1034 		sizeof(struct pfvf_acquire_resp_tlv) :
1035 		sizeof(struct pfvf_general_resp_tlv);
1036 	bnx2x_add_tlv(bp, &mbx->msg->resp, 0, type, length);
1037 	bnx2x_add_tlv(bp, &mbx->msg->resp, length, CHANNEL_TLV_LIST_END,
1038 		      sizeof(struct channel_list_end_tlv));
1039 }
1040 
1041 static void bnx2x_vf_mbx_resp_send_msg(struct bnx2x *bp,
1042 				       struct bnx2x_virtf *vf,
1043 				       int vf_rc)
1044 {
1045 	struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf->index);
1046 	struct pfvf_general_resp_tlv *resp = &mbx->msg->resp.general_resp;
1047 	dma_addr_t pf_addr;
1048 	u64 vf_addr;
1049 	int rc;
1050 
1051 	bnx2x_dp_tlv_list(bp, resp);
1052 	DP(BNX2X_MSG_IOV, "mailbox vf address hi 0x%x, lo 0x%x, offset 0x%x\n",
1053 	   mbx->vf_addr_hi, mbx->vf_addr_lo, mbx->first_tlv.resp_msg_offset);
1054 
1055 	resp->hdr.status = bnx2x_pfvf_status_codes(vf_rc);
1056 
1057 	/* send response */
1058 	vf_addr = HILO_U64(mbx->vf_addr_hi, mbx->vf_addr_lo) +
1059 		  mbx->first_tlv.resp_msg_offset;
1060 	pf_addr = mbx->msg_mapping +
1061 		  offsetof(struct bnx2x_vf_mbx_msg, resp);
1062 
1063 	/* Copy the response buffer. The first u64 is written afterwards, as
1064 	 * the vf is sensitive to the header being written
1065 	 */
1066 	vf_addr += sizeof(u64);
1067 	pf_addr += sizeof(u64);
1068 	rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr, vf->abs_vfid,
1069 				  U64_HI(vf_addr),
1070 				  U64_LO(vf_addr),
1071 				  (sizeof(union pfvf_tlvs) - sizeof(u64))/4);
1072 	if (rc) {
1073 		BNX2X_ERR("Failed to copy response body to VF %d\n",
1074 			  vf->abs_vfid);
1075 		goto mbx_error;
1076 	}
1077 	vf_addr -= sizeof(u64);
1078 	pf_addr -= sizeof(u64);
1079 
1080 	/* ack the FW */
1081 	storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
1082 	mmiowb();
1083 
1084 	/* copy the response header including status-done field,
1085 	 * must be last dmae, must be after FW is acked
1086 	 */
1087 	rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr, vf->abs_vfid,
1088 				  U64_HI(vf_addr),
1089 				  U64_LO(vf_addr),
1090 				  sizeof(u64)/4);
1091 
1092 	/* unlock channel mutex */
1093 	bnx2x_unlock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
1094 
1095 	if (rc) {
1096 		BNX2X_ERR("Failed to copy response status to VF %d\n",
1097 			  vf->abs_vfid);
1098 		goto mbx_error;
1099 	}
1100 	return;
1101 
1102 mbx_error:
1103 	bnx2x_vf_release(bp, vf);
1104 }
1105 
1106 static void bnx2x_vf_mbx_resp(struct bnx2x *bp,
1107 			      struct bnx2x_virtf *vf,
1108 			      int rc)
1109 {
1110 	bnx2x_vf_mbx_resp_single_tlv(bp, vf);
1111 	bnx2x_vf_mbx_resp_send_msg(bp, vf, rc);
1112 }
1113 
1114 static void bnx2x_vf_mbx_resp_phys_port(struct bnx2x *bp,
1115 					struct bnx2x_virtf *vf,
1116 					void *buffer,
1117 					u16 *offset)
1118 {
1119 	struct vfpf_port_phys_id_resp_tlv *port_id;
1120 
1121 	if (!(bp->flags & HAS_PHYS_PORT_ID))
1122 		return;
1123 
1124 	bnx2x_add_tlv(bp, buffer, *offset, CHANNEL_TLV_PHYS_PORT_ID,
1125 		      sizeof(struct vfpf_port_phys_id_resp_tlv));
1126 
1127 	port_id = (struct vfpf_port_phys_id_resp_tlv *)
1128 		  (((u8 *)buffer) + *offset);
1129 	memcpy(port_id->id, bp->phys_port_id, ETH_ALEN);
1130 
1131 	/* Offset should continue representing the offset to the tail
1132 	 * of TLV data (outside this function scope)
1133 	 */
1134 	*offset += sizeof(struct vfpf_port_phys_id_resp_tlv);
1135 }
1136 
1137 static void bnx2x_vf_mbx_acquire_resp(struct bnx2x *bp, struct bnx2x_virtf *vf,
1138 				      struct bnx2x_vf_mbx *mbx, int vfop_status)
1139 {
1140 	int i;
1141 	struct pfvf_acquire_resp_tlv *resp = &mbx->msg->resp.acquire_resp;
1142 	struct pf_vf_resc *resc = &resp->resc;
1143 	u8 status = bnx2x_pfvf_status_codes(vfop_status);
1144 	u16 length;
1145 
1146 	memset(resp, 0, sizeof(*resp));
1147 
1148 	/* fill in pfdev info */
1149 	resp->pfdev_info.chip_num = bp->common.chip_id;
1150 	resp->pfdev_info.db_size = bp->db_size;
1151 	resp->pfdev_info.indices_per_sb = HC_SB_MAX_INDICES_E2;
1152 	resp->pfdev_info.pf_cap = (PFVF_CAP_RSS |
1153 				   PFVF_CAP_TPA |
1154 				   PFVF_CAP_TPA_UPDATE);
1155 	bnx2x_fill_fw_str(bp, resp->pfdev_info.fw_ver,
1156 			  sizeof(resp->pfdev_info.fw_ver));
1157 
1158 	if (status == PFVF_STATUS_NO_RESOURCE ||
1159 	    status == PFVF_STATUS_SUCCESS) {
1160 		/* set resources numbers, if status equals NO_RESOURCE these
1161 		 * are max possible numbers
1162 		 */
1163 		resc->num_rxqs = vf_rxq_count(vf) ? :
1164 			bnx2x_vf_max_queue_cnt(bp, vf);
1165 		resc->num_txqs = vf_txq_count(vf) ? :
1166 			bnx2x_vf_max_queue_cnt(bp, vf);
1167 		resc->num_sbs = vf_sb_count(vf);
1168 		resc->num_mac_filters = vf_mac_rules_cnt(vf);
1169 		resc->num_vlan_filters = vf_vlan_rules_visible_cnt(vf);
1170 		resc->num_mc_filters = 0;
1171 
1172 		if (status == PFVF_STATUS_SUCCESS) {
1173 			/* fill in the allocated resources */
1174 			struct pf_vf_bulletin_content *bulletin =
1175 				BP_VF_BULLETIN(bp, vf->index);
1176 
1177 			for_each_vfq(vf, i)
1178 				resc->hw_qid[i] =
1179 					vfq_qzone_id(vf, vfq_get(vf, i));
1180 
1181 			for_each_vf_sb(vf, i) {
1182 				resc->hw_sbs[i].hw_sb_id = vf_igu_sb(vf, i);
1183 				resc->hw_sbs[i].sb_qid = vf_hc_qzone(vf, i);
1184 			}
1185 
1186 			/* if a mac has been set for this vf, supply it */
1187 			if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
1188 				memcpy(resc->current_mac_addr, bulletin->mac,
1189 				       ETH_ALEN);
1190 			}
1191 		}
1192 	}
1193 
1194 	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"
1195 	   "resources- n_rxq-%d, n_txq-%d, n_sbs-%d, n_macs-%d, n_vlans-%d, n_mcs-%d, fw_ver: '%s'\n",
1196 	   vf->abs_vfid,
1197 	   resp->pfdev_info.chip_num,
1198 	   resp->pfdev_info.db_size,
1199 	   resp->pfdev_info.indices_per_sb,
1200 	   resp->pfdev_info.pf_cap,
1201 	   resc->num_rxqs,
1202 	   resc->num_txqs,
1203 	   resc->num_sbs,
1204 	   resc->num_mac_filters,
1205 	   resc->num_vlan_filters,
1206 	   resc->num_mc_filters,
1207 	   resp->pfdev_info.fw_ver);
1208 
1209 	DP_CONT(BNX2X_MSG_IOV, "hw_qids- [ ");
1210 	for (i = 0; i < vf_rxq_count(vf); i++)
1211 		DP_CONT(BNX2X_MSG_IOV, "%d ", resc->hw_qid[i]);
1212 	DP_CONT(BNX2X_MSG_IOV, "], sb_info- [ ");
1213 	for (i = 0; i < vf_sb_count(vf); i++)
1214 		DP_CONT(BNX2X_MSG_IOV, "%d:%d ",
1215 			resc->hw_sbs[i].hw_sb_id,
1216 			resc->hw_sbs[i].sb_qid);
1217 	DP_CONT(BNX2X_MSG_IOV, "]\n");
1218 
1219 	/* prepare response */
1220 	length = sizeof(struct pfvf_acquire_resp_tlv);
1221 	bnx2x_add_tlv(bp, &mbx->msg->resp, 0, CHANNEL_TLV_ACQUIRE, length);
1222 
1223 	/* Handle possible VF requests for physical port identifiers.
1224 	 * 'length' should continue to indicate the offset of the first empty
1225 	 * place in the buffer (i.e., where next TLV should be inserted)
1226 	 */
1227 	if (bnx2x_search_tlv_list(bp, &mbx->msg->req,
1228 				  CHANNEL_TLV_PHYS_PORT_ID))
1229 		bnx2x_vf_mbx_resp_phys_port(bp, vf, &mbx->msg->resp, &length);
1230 
1231 	bnx2x_add_tlv(bp, &mbx->msg->resp, length, CHANNEL_TLV_LIST_END,
1232 		      sizeof(struct channel_list_end_tlv));
1233 
1234 	/* send the response */
1235 	bnx2x_vf_mbx_resp_send_msg(bp, vf, vfop_status);
1236 }
1237 
1238 static void bnx2x_vf_mbx_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
1239 				 struct bnx2x_vf_mbx *mbx)
1240 {
1241 	int rc;
1242 	struct vfpf_acquire_tlv *acquire = &mbx->msg->req.acquire;
1243 
1244 	/* log vfdef info */
1245 	DP(BNX2X_MSG_IOV,
1246 	   "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",
1247 	   vf->abs_vfid, acquire->vfdev_info.vf_id, acquire->vfdev_info.vf_os,
1248 	   acquire->resc_request.num_rxqs, acquire->resc_request.num_txqs,
1249 	   acquire->resc_request.num_sbs, acquire->resc_request.num_mac_filters,
1250 	   acquire->resc_request.num_vlan_filters,
1251 	   acquire->resc_request.num_mc_filters);
1252 
1253 	/* acquire the resources */
1254 	rc = bnx2x_vf_acquire(bp, vf, &acquire->resc_request);
1255 
1256 	/* store address of vf's bulletin board */
1257 	vf->bulletin_map = acquire->bulletin_addr;
1258 	if (acquire->vfdev_info.caps & VF_CAP_SUPPORT_EXT_BULLETIN) {
1259 		DP(BNX2X_MSG_IOV, "VF[%d] supports long bulletin boards\n",
1260 		   vf->abs_vfid);
1261 		vf->cfg_flags |= VF_CFG_EXT_BULLETIN;
1262 	} else {
1263 		vf->cfg_flags &= ~VF_CFG_EXT_BULLETIN;
1264 	}
1265 
1266 	/* response */
1267 	bnx2x_vf_mbx_acquire_resp(bp, vf, mbx, rc);
1268 }
1269 
1270 static void bnx2x_vf_mbx_init_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1271 			      struct bnx2x_vf_mbx *mbx)
1272 {
1273 	struct vfpf_init_tlv *init = &mbx->msg->req.init;
1274 	int rc;
1275 
1276 	/* record ghost addresses from vf message */
1277 	vf->spq_map = init->spq_addr;
1278 	vf->fw_stat_map = init->stats_addr;
1279 	vf->stats_stride = init->stats_stride;
1280 	rc = bnx2x_vf_init(bp, vf, (dma_addr_t *)init->sb_addr);
1281 
1282 	/* set VF multiqueue statistics collection mode */
1283 	if (init->flags & VFPF_INIT_FLG_STATS_COALESCE)
1284 		vf->cfg_flags |= VF_CFG_STATS_COALESCE;
1285 
1286 	/* Update VF's view of link state */
1287 	if (vf->cfg_flags & VF_CFG_EXT_BULLETIN)
1288 		bnx2x_iov_link_update_vf(bp, vf->index);
1289 
1290 	/* response */
1291 	bnx2x_vf_mbx_resp(bp, vf, rc);
1292 }
1293 
1294 /* convert MBX queue-flags to standard SP queue-flags */
1295 static void bnx2x_vf_mbx_set_q_flags(struct bnx2x *bp, u32 mbx_q_flags,
1296 				     unsigned long *sp_q_flags)
1297 {
1298 	if (mbx_q_flags & VFPF_QUEUE_FLG_TPA)
1299 		__set_bit(BNX2X_Q_FLG_TPA, sp_q_flags);
1300 	if (mbx_q_flags & VFPF_QUEUE_FLG_TPA_IPV6)
1301 		__set_bit(BNX2X_Q_FLG_TPA_IPV6, sp_q_flags);
1302 	if (mbx_q_flags & VFPF_QUEUE_FLG_TPA_GRO)
1303 		__set_bit(BNX2X_Q_FLG_TPA_GRO, sp_q_flags);
1304 	if (mbx_q_flags & VFPF_QUEUE_FLG_STATS)
1305 		__set_bit(BNX2X_Q_FLG_STATS, sp_q_flags);
1306 	if (mbx_q_flags & VFPF_QUEUE_FLG_VLAN)
1307 		__set_bit(BNX2X_Q_FLG_VLAN, sp_q_flags);
1308 	if (mbx_q_flags & VFPF_QUEUE_FLG_COS)
1309 		__set_bit(BNX2X_Q_FLG_COS, sp_q_flags);
1310 	if (mbx_q_flags & VFPF_QUEUE_FLG_HC)
1311 		__set_bit(BNX2X_Q_FLG_HC, sp_q_flags);
1312 	if (mbx_q_flags & VFPF_QUEUE_FLG_DHC)
1313 		__set_bit(BNX2X_Q_FLG_DHC, sp_q_flags);
1314 	if (mbx_q_flags & VFPF_QUEUE_FLG_LEADING_RSS)
1315 		__set_bit(BNX2X_Q_FLG_LEADING_RSS, sp_q_flags);
1316 
1317 	/* outer vlan removal is set according to PF's multi function mode */
1318 	if (IS_MF_SD(bp))
1319 		__set_bit(BNX2X_Q_FLG_OV, sp_q_flags);
1320 }
1321 
1322 static void bnx2x_vf_mbx_setup_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
1323 				 struct bnx2x_vf_mbx *mbx)
1324 {
1325 	struct vfpf_setup_q_tlv *setup_q = &mbx->msg->req.setup_q;
1326 	struct bnx2x_vf_queue_construct_params qctor;
1327 	int rc = 0;
1328 
1329 	/* verify vf_qid */
1330 	if (setup_q->vf_qid >= vf_rxq_count(vf)) {
1331 		BNX2X_ERR("vf_qid %d invalid, max queue count is %d\n",
1332 			  setup_q->vf_qid, vf_rxq_count(vf));
1333 		rc = -EINVAL;
1334 		goto response;
1335 	}
1336 
1337 	/* tx queues must be setup alongside rx queues thus if the rx queue
1338 	 * is not marked as valid there's nothing to do.
1339 	 */
1340 	if (setup_q->param_valid & (VFPF_RXQ_VALID|VFPF_TXQ_VALID)) {
1341 		struct bnx2x_vf_queue *q = vfq_get(vf, setup_q->vf_qid);
1342 		unsigned long q_type = 0;
1343 
1344 		struct bnx2x_queue_init_params *init_p;
1345 		struct bnx2x_queue_setup_params *setup_p;
1346 
1347 		if (bnx2x_vfq_is_leading(q))
1348 			bnx2x_leading_vfq_init(bp, vf, q);
1349 
1350 		/* re-init the VF operation context */
1351 		memset(&qctor, 0 ,
1352 		       sizeof(struct bnx2x_vf_queue_construct_params));
1353 		setup_p = &qctor.prep_qsetup;
1354 		init_p =  &qctor.qstate.params.init;
1355 
1356 		/* activate immediately */
1357 		__set_bit(BNX2X_Q_FLG_ACTIVE, &setup_p->flags);
1358 
1359 		if (setup_q->param_valid & VFPF_TXQ_VALID) {
1360 			struct bnx2x_txq_setup_params *txq_params =
1361 				&setup_p->txq_params;
1362 
1363 			__set_bit(BNX2X_Q_TYPE_HAS_TX, &q_type);
1364 
1365 			/* save sb resource index */
1366 			q->sb_idx = setup_q->txq.vf_sb;
1367 
1368 			/* tx init */
1369 			init_p->tx.hc_rate = setup_q->txq.hc_rate;
1370 			init_p->tx.sb_cq_index = setup_q->txq.sb_index;
1371 
1372 			bnx2x_vf_mbx_set_q_flags(bp, setup_q->txq.flags,
1373 						 &init_p->tx.flags);
1374 
1375 			/* tx setup - flags */
1376 			bnx2x_vf_mbx_set_q_flags(bp, setup_q->txq.flags,
1377 						 &setup_p->flags);
1378 
1379 			/* tx setup - general, nothing */
1380 
1381 			/* tx setup - tx */
1382 			txq_params->dscr_map = setup_q->txq.txq_addr;
1383 			txq_params->sb_cq_index = setup_q->txq.sb_index;
1384 			txq_params->traffic_type = setup_q->txq.traffic_type;
1385 
1386 			bnx2x_vfop_qctor_dump_tx(bp, vf, init_p, setup_p,
1387 						 q->index, q->sb_idx);
1388 		}
1389 
1390 		if (setup_q->param_valid & VFPF_RXQ_VALID) {
1391 			struct bnx2x_rxq_setup_params *rxq_params =
1392 							&setup_p->rxq_params;
1393 
1394 			__set_bit(BNX2X_Q_TYPE_HAS_RX, &q_type);
1395 
1396 			/* Note: there is no support for different SBs
1397 			 * for TX and RX
1398 			 */
1399 			q->sb_idx = setup_q->rxq.vf_sb;
1400 
1401 			/* rx init */
1402 			init_p->rx.hc_rate = setup_q->rxq.hc_rate;
1403 			init_p->rx.sb_cq_index = setup_q->rxq.sb_index;
1404 			bnx2x_vf_mbx_set_q_flags(bp, setup_q->rxq.flags,
1405 						 &init_p->rx.flags);
1406 
1407 			/* rx setup - flags */
1408 			bnx2x_vf_mbx_set_q_flags(bp, setup_q->rxq.flags,
1409 						 &setup_p->flags);
1410 
1411 			/* rx setup - general */
1412 			setup_p->gen_params.mtu = setup_q->rxq.mtu;
1413 
1414 			/* rx setup - rx */
1415 			rxq_params->drop_flags = setup_q->rxq.drop_flags;
1416 			rxq_params->dscr_map = setup_q->rxq.rxq_addr;
1417 			rxq_params->sge_map = setup_q->rxq.sge_addr;
1418 			rxq_params->rcq_map = setup_q->rxq.rcq_addr;
1419 			rxq_params->rcq_np_map = setup_q->rxq.rcq_np_addr;
1420 			rxq_params->buf_sz = setup_q->rxq.buf_sz;
1421 			rxq_params->tpa_agg_sz = setup_q->rxq.tpa_agg_sz;
1422 			rxq_params->max_sges_pkt = setup_q->rxq.max_sge_pkt;
1423 			rxq_params->sge_buf_sz = setup_q->rxq.sge_buf_sz;
1424 			rxq_params->cache_line_log =
1425 				setup_q->rxq.cache_line_log;
1426 			rxq_params->sb_cq_index = setup_q->rxq.sb_index;
1427 
1428 			/* rx setup - multicast engine */
1429 			if (bnx2x_vfq_is_leading(q)) {
1430 				u8 mcast_id = FW_VF_HANDLE(vf->abs_vfid);
1431 
1432 				rxq_params->mcast_engine_id = mcast_id;
1433 				__set_bit(BNX2X_Q_FLG_MCAST, &setup_p->flags);
1434 			}
1435 
1436 			bnx2x_vfop_qctor_dump_rx(bp, vf, init_p, setup_p,
1437 						 q->index, q->sb_idx);
1438 		}
1439 		/* complete the preparations */
1440 		bnx2x_vfop_qctor_prep(bp, vf, q, &qctor, q_type);
1441 
1442 		rc = bnx2x_vf_queue_setup(bp, vf, q->index, &qctor);
1443 		if (rc)
1444 			goto response;
1445 	}
1446 response:
1447 	bnx2x_vf_mbx_resp(bp, vf, rc);
1448 }
1449 
1450 static int bnx2x_vf_mbx_macvlan_list(struct bnx2x *bp,
1451 				     struct bnx2x_virtf *vf,
1452 				     struct vfpf_set_q_filters_tlv *tlv,
1453 				     struct bnx2x_vf_mac_vlan_filters **pfl,
1454 				     u32 type_flag)
1455 {
1456 	int i, j;
1457 	struct bnx2x_vf_mac_vlan_filters *fl = NULL;
1458 	size_t fsz;
1459 
1460 	fsz = tlv->n_mac_vlan_filters *
1461 	      sizeof(struct bnx2x_vf_mac_vlan_filter) +
1462 	      sizeof(struct bnx2x_vf_mac_vlan_filters);
1463 
1464 	fl = kzalloc(fsz, GFP_KERNEL);
1465 	if (!fl)
1466 		return -ENOMEM;
1467 
1468 	for (i = 0, j = 0; i < tlv->n_mac_vlan_filters; i++) {
1469 		struct vfpf_q_mac_vlan_filter *msg_filter = &tlv->filters[i];
1470 
1471 		if ((msg_filter->flags & type_flag) != type_flag)
1472 			continue;
1473 		if (type_flag == VFPF_Q_FILTER_DEST_MAC_VALID) {
1474 			fl->filters[j].mac = msg_filter->mac;
1475 			fl->filters[j].type = BNX2X_VF_FILTER_MAC;
1476 		} else {
1477 			fl->filters[j].vid = msg_filter->vlan_tag;
1478 			fl->filters[j].type = BNX2X_VF_FILTER_VLAN;
1479 		}
1480 		fl->filters[j].add =
1481 			(msg_filter->flags & VFPF_Q_FILTER_SET_MAC) ?
1482 			true : false;
1483 		fl->count++;
1484 	}
1485 	if (!fl->count)
1486 		kfree(fl);
1487 	else
1488 		*pfl = fl;
1489 
1490 	return 0;
1491 }
1492 
1493 static void bnx2x_vf_mbx_dp_q_filter(struct bnx2x *bp, int msglvl, int idx,
1494 				       struct vfpf_q_mac_vlan_filter *filter)
1495 {
1496 	DP(msglvl, "MAC-VLAN[%d] -- flags=0x%x\n", idx, filter->flags);
1497 	if (filter->flags & VFPF_Q_FILTER_VLAN_TAG_VALID)
1498 		DP_CONT(msglvl, ", vlan=%d", filter->vlan_tag);
1499 	if (filter->flags & VFPF_Q_FILTER_DEST_MAC_VALID)
1500 		DP_CONT(msglvl, ", MAC=%pM", filter->mac);
1501 	DP_CONT(msglvl, "\n");
1502 }
1503 
1504 static void bnx2x_vf_mbx_dp_q_filters(struct bnx2x *bp, int msglvl,
1505 				       struct vfpf_set_q_filters_tlv *filters)
1506 {
1507 	int i;
1508 
1509 	if (filters->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED)
1510 		for (i = 0; i < filters->n_mac_vlan_filters; i++)
1511 			bnx2x_vf_mbx_dp_q_filter(bp, msglvl, i,
1512 						 &filters->filters[i]);
1513 
1514 	if (filters->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED)
1515 		DP(msglvl, "RX-MASK=0x%x\n", filters->rx_mask);
1516 
1517 	if (filters->flags & VFPF_SET_Q_FILTERS_MULTICAST_CHANGED)
1518 		for (i = 0; i < filters->n_multicast; i++)
1519 			DP(msglvl, "MULTICAST=%pM\n", filters->multicast[i]);
1520 }
1521 
1522 #define VFPF_MAC_FILTER		VFPF_Q_FILTER_DEST_MAC_VALID
1523 #define VFPF_VLAN_FILTER	VFPF_Q_FILTER_VLAN_TAG_VALID
1524 
1525 static int bnx2x_vf_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
1526 {
1527 	int rc = 0;
1528 
1529 	struct vfpf_set_q_filters_tlv *msg =
1530 		&BP_VF_MBX(bp, vf->index)->msg->req.set_q_filters;
1531 
1532 	/* check for any mac/vlan changes */
1533 	if (msg->flags & VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED) {
1534 		/* build mac list */
1535 		struct bnx2x_vf_mac_vlan_filters *fl = NULL;
1536 
1537 		rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
1538 					       VFPF_MAC_FILTER);
1539 		if (rc)
1540 			goto op_err;
1541 
1542 		if (fl) {
1543 
1544 			/* set mac list */
1545 			rc = bnx2x_vf_mac_vlan_config_list(bp, vf, fl,
1546 							   msg->vf_qid,
1547 							   false);
1548 			if (rc)
1549 				goto op_err;
1550 		}
1551 
1552 		/* build vlan list */
1553 		fl = NULL;
1554 
1555 		rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl,
1556 					       VFPF_VLAN_FILTER);
1557 		if (rc)
1558 			goto op_err;
1559 
1560 		if (fl) {
1561 			/* set vlan list */
1562 			rc = bnx2x_vf_mac_vlan_config_list(bp, vf, fl,
1563 							   msg->vf_qid,
1564 							   false);
1565 			if (rc)
1566 				goto op_err;
1567 		}
1568 	}
1569 
1570 	if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) {
1571 		unsigned long accept = 0;
1572 		struct pf_vf_bulletin_content *bulletin =
1573 					BP_VF_BULLETIN(bp, vf->index);
1574 
1575 		/* Ignore VF requested mode; instead set a regular mode */
1576 		if (msg->rx_mask !=  VFPF_RX_MASK_ACCEPT_NONE) {
1577 			__set_bit(BNX2X_ACCEPT_UNICAST, &accept);
1578 			__set_bit(BNX2X_ACCEPT_MULTICAST, &accept);
1579 			__set_bit(BNX2X_ACCEPT_BROADCAST, &accept);
1580 		}
1581 
1582 		/* A packet arriving the vf's mac should be accepted
1583 		 * with any vlan, unless a vlan has already been
1584 		 * configured.
1585 		 */
1586 		if (!(bulletin->valid_bitmap & (1 << VLAN_VALID)))
1587 			__set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept);
1588 
1589 		/* set rx-mode */
1590 		rc = bnx2x_vf_rxmode(bp, vf, msg->vf_qid, accept);
1591 		if (rc)
1592 			goto op_err;
1593 	}
1594 
1595 	if (msg->flags & VFPF_SET_Q_FILTERS_MULTICAST_CHANGED) {
1596 		/* set mcasts */
1597 		rc = bnx2x_vf_mcast(bp, vf, msg->multicast,
1598 				    msg->n_multicast, false);
1599 		if (rc)
1600 			goto op_err;
1601 	}
1602 op_err:
1603 	if (rc)
1604 		BNX2X_ERR("QFILTERS[%d:%d] error: rc %d\n",
1605 			  vf->abs_vfid, msg->vf_qid, rc);
1606 	return rc;
1607 }
1608 
1609 static int bnx2x_filters_validate_mac(struct bnx2x *bp,
1610 				      struct bnx2x_virtf *vf,
1611 				      struct vfpf_set_q_filters_tlv *filters)
1612 {
1613 	struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf->index);
1614 	int rc = 0;
1615 
1616 	/* if a mac was already set for this VF via the set vf mac ndo, we only
1617 	 * accept mac configurations of that mac. Why accept them at all?
1618 	 * because PF may have been unable to configure the mac at the time
1619 	 * since queue was not set up.
1620 	 */
1621 	if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID) {
1622 		/* once a mac was set by ndo can only accept a single mac... */
1623 		if (filters->n_mac_vlan_filters > 1) {
1624 			BNX2X_ERR("VF[%d] requested the addition of multiple macs after set_vf_mac ndo was called\n",
1625 				  vf->abs_vfid);
1626 			rc = -EPERM;
1627 			goto response;
1628 		}
1629 
1630 		/* ...and only the mac set by the ndo */
1631 		if (filters->n_mac_vlan_filters == 1 &&
1632 		    !ether_addr_equal(filters->filters->mac, bulletin->mac)) {
1633 			BNX2X_ERR("VF[%d] requested the addition of a mac address not matching the one configured by set_vf_mac ndo\n",
1634 				  vf->abs_vfid);
1635 
1636 			rc = -EPERM;
1637 			goto response;
1638 		}
1639 	}
1640 
1641 response:
1642 	return rc;
1643 }
1644 
1645 static int bnx2x_filters_validate_vlan(struct bnx2x *bp,
1646 				       struct bnx2x_virtf *vf,
1647 				       struct vfpf_set_q_filters_tlv *filters)
1648 {
1649 	struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf->index);
1650 	int rc = 0;
1651 
1652 	/* if vlan was set by hypervisor we don't allow guest to config vlan */
1653 	if (bulletin->valid_bitmap & 1 << VLAN_VALID) {
1654 		int i;
1655 
1656 		/* search for vlan filters */
1657 		for (i = 0; i < filters->n_mac_vlan_filters; i++) {
1658 			if (filters->filters[i].flags &
1659 			    VFPF_Q_FILTER_VLAN_TAG_VALID) {
1660 				BNX2X_ERR("VF[%d] attempted to configure vlan but one was already set by Hypervisor. Aborting request\n",
1661 					  vf->abs_vfid);
1662 				rc = -EPERM;
1663 				goto response;
1664 			}
1665 		}
1666 	}
1667 
1668 	/* verify vf_qid */
1669 	if (filters->vf_qid > vf_rxq_count(vf)) {
1670 		rc = -EPERM;
1671 		goto response;
1672 	}
1673 
1674 response:
1675 	return rc;
1676 }
1677 
1678 static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp,
1679 				       struct bnx2x_virtf *vf,
1680 				       struct bnx2x_vf_mbx *mbx)
1681 {
1682 	struct vfpf_set_q_filters_tlv *filters = &mbx->msg->req.set_q_filters;
1683 	int rc;
1684 
1685 	rc = bnx2x_filters_validate_mac(bp, vf, filters);
1686 	if (rc)
1687 		goto response;
1688 
1689 	rc = bnx2x_filters_validate_vlan(bp, vf, filters);
1690 	if (rc)
1691 		goto response;
1692 
1693 	DP(BNX2X_MSG_IOV, "VF[%d] Q_FILTERS: queue[%d]\n",
1694 	   vf->abs_vfid,
1695 	   filters->vf_qid);
1696 
1697 	/* print q_filter message */
1698 	bnx2x_vf_mbx_dp_q_filters(bp, BNX2X_MSG_IOV, filters);
1699 
1700 	rc = bnx2x_vf_mbx_qfilters(bp, vf);
1701 response:
1702 	bnx2x_vf_mbx_resp(bp, vf, rc);
1703 }
1704 
1705 static void bnx2x_vf_mbx_teardown_q(struct bnx2x *bp, struct bnx2x_virtf *vf,
1706 				    struct bnx2x_vf_mbx *mbx)
1707 {
1708 	int qid = mbx->msg->req.q_op.vf_qid;
1709 	int rc;
1710 
1711 	DP(BNX2X_MSG_IOV, "VF[%d] Q_TEARDOWN: vf_qid=%d\n",
1712 	   vf->abs_vfid, qid);
1713 
1714 	rc = bnx2x_vf_queue_teardown(bp, vf, qid);
1715 	bnx2x_vf_mbx_resp(bp, vf, rc);
1716 }
1717 
1718 static void bnx2x_vf_mbx_close_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1719 				  struct bnx2x_vf_mbx *mbx)
1720 {
1721 	int rc;
1722 
1723 	DP(BNX2X_MSG_IOV, "VF[%d] VF_CLOSE\n", vf->abs_vfid);
1724 
1725 	rc = bnx2x_vf_close(bp, vf);
1726 	bnx2x_vf_mbx_resp(bp, vf, rc);
1727 }
1728 
1729 static void bnx2x_vf_mbx_release_vf(struct bnx2x *bp, struct bnx2x_virtf *vf,
1730 				    struct bnx2x_vf_mbx *mbx)
1731 {
1732 	int rc;
1733 
1734 	DP(BNX2X_MSG_IOV, "VF[%d] VF_RELEASE\n", vf->abs_vfid);
1735 
1736 	rc = bnx2x_vf_free(bp, vf);
1737 	bnx2x_vf_mbx_resp(bp, vf, rc);
1738 }
1739 
1740 static void bnx2x_vf_mbx_update_rss(struct bnx2x *bp, struct bnx2x_virtf *vf,
1741 				    struct bnx2x_vf_mbx *mbx)
1742 {
1743 	struct bnx2x_config_rss_params rss;
1744 	struct vfpf_rss_tlv *rss_tlv = &mbx->msg->req.update_rss;
1745 	int rc = 0;
1746 
1747 	if (rss_tlv->ind_table_size != T_ETH_INDIRECTION_TABLE_SIZE ||
1748 	    rss_tlv->rss_key_size != T_ETH_RSS_KEY) {
1749 		BNX2X_ERR("failing rss configuration of vf %d due to size mismatch\n",
1750 			  vf->index);
1751 		rc = -EINVAL;
1752 		goto mbx_resp;
1753 	}
1754 
1755 	memset(&rss, 0, sizeof(struct bnx2x_config_rss_params));
1756 
1757 	/* set vfop params according to rss tlv */
1758 	memcpy(rss.ind_table, rss_tlv->ind_table,
1759 	       T_ETH_INDIRECTION_TABLE_SIZE);
1760 	memcpy(rss.rss_key, rss_tlv->rss_key, sizeof(rss_tlv->rss_key));
1761 	rss.rss_obj = &vf->rss_conf_obj;
1762 	rss.rss_result_mask = rss_tlv->rss_result_mask;
1763 
1764 	/* flags handled individually for backward/forward compatability */
1765 	rss.rss_flags = 0;
1766 	rss.ramrod_flags = 0;
1767 
1768 	if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED)
1769 		__set_bit(BNX2X_RSS_MODE_DISABLED, &rss.rss_flags);
1770 	if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR)
1771 		__set_bit(BNX2X_RSS_MODE_REGULAR, &rss.rss_flags);
1772 	if (rss_tlv->rss_flags & VFPF_RSS_SET_SRCH)
1773 		__set_bit(BNX2X_RSS_SET_SRCH, &rss.rss_flags);
1774 	if (rss_tlv->rss_flags & VFPF_RSS_IPV4)
1775 		__set_bit(BNX2X_RSS_IPV4, &rss.rss_flags);
1776 	if (rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP)
1777 		__set_bit(BNX2X_RSS_IPV4_TCP, &rss.rss_flags);
1778 	if (rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP)
1779 		__set_bit(BNX2X_RSS_IPV4_UDP, &rss.rss_flags);
1780 	if (rss_tlv->rss_flags & VFPF_RSS_IPV6)
1781 		__set_bit(BNX2X_RSS_IPV6, &rss.rss_flags);
1782 	if (rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP)
1783 		__set_bit(BNX2X_RSS_IPV6_TCP, &rss.rss_flags);
1784 	if (rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)
1785 		__set_bit(BNX2X_RSS_IPV6_UDP, &rss.rss_flags);
1786 
1787 	if ((!(rss_tlv->rss_flags & VFPF_RSS_IPV4_TCP) &&
1788 	     rss_tlv->rss_flags & VFPF_RSS_IPV4_UDP) ||
1789 	    (!(rss_tlv->rss_flags & VFPF_RSS_IPV6_TCP) &&
1790 	     rss_tlv->rss_flags & VFPF_RSS_IPV6_UDP)) {
1791 		BNX2X_ERR("about to hit a FW assert. aborting...\n");
1792 		rc = -EINVAL;
1793 		goto mbx_resp;
1794 	}
1795 
1796 	rc = bnx2x_vf_rss_update(bp, vf, &rss);
1797 mbx_resp:
1798 	bnx2x_vf_mbx_resp(bp, vf, rc);
1799 }
1800 
1801 static int bnx2x_validate_tpa_params(struct bnx2x *bp,
1802 				       struct vfpf_tpa_tlv *tpa_tlv)
1803 {
1804 	int rc = 0;
1805 
1806 	if (tpa_tlv->tpa_client_info.max_sges_for_packet >
1807 	    U_ETH_MAX_SGES_FOR_PACKET) {
1808 		rc = -EINVAL;
1809 		BNX2X_ERR("TPA update: max_sges received %d, max is %d\n",
1810 			  tpa_tlv->tpa_client_info.max_sges_for_packet,
1811 			  U_ETH_MAX_SGES_FOR_PACKET);
1812 	}
1813 
1814 	if (tpa_tlv->tpa_client_info.max_tpa_queues > MAX_AGG_QS(bp)) {
1815 		rc = -EINVAL;
1816 		BNX2X_ERR("TPA update: max_tpa_queues received %d, max is %d\n",
1817 			  tpa_tlv->tpa_client_info.max_tpa_queues,
1818 			  MAX_AGG_QS(bp));
1819 	}
1820 
1821 	return rc;
1822 }
1823 
1824 static void bnx2x_vf_mbx_update_tpa(struct bnx2x *bp, struct bnx2x_virtf *vf,
1825 				    struct bnx2x_vf_mbx *mbx)
1826 {
1827 	struct bnx2x_queue_update_tpa_params vf_op_params;
1828 	struct vfpf_tpa_tlv *tpa_tlv = &mbx->msg->req.update_tpa;
1829 	int rc = 0;
1830 
1831 	memset(&vf_op_params, 0, sizeof(vf_op_params));
1832 
1833 	if (bnx2x_validate_tpa_params(bp, tpa_tlv))
1834 		goto mbx_resp;
1835 
1836 	vf_op_params.complete_on_both_clients =
1837 		tpa_tlv->tpa_client_info.complete_on_both_clients;
1838 	vf_op_params.dont_verify_thr =
1839 		tpa_tlv->tpa_client_info.dont_verify_thr;
1840 	vf_op_params.max_agg_sz =
1841 		tpa_tlv->tpa_client_info.max_agg_size;
1842 	vf_op_params.max_sges_pkt =
1843 		tpa_tlv->tpa_client_info.max_sges_for_packet;
1844 	vf_op_params.max_tpa_queues =
1845 		tpa_tlv->tpa_client_info.max_tpa_queues;
1846 	vf_op_params.sge_buff_sz =
1847 		tpa_tlv->tpa_client_info.sge_buff_size;
1848 	vf_op_params.sge_pause_thr_high =
1849 		tpa_tlv->tpa_client_info.sge_pause_thr_high;
1850 	vf_op_params.sge_pause_thr_low =
1851 		tpa_tlv->tpa_client_info.sge_pause_thr_low;
1852 	vf_op_params.tpa_mode =
1853 		tpa_tlv->tpa_client_info.tpa_mode;
1854 	vf_op_params.update_ipv4 =
1855 		tpa_tlv->tpa_client_info.update_ipv4;
1856 	vf_op_params.update_ipv6 =
1857 		tpa_tlv->tpa_client_info.update_ipv6;
1858 
1859 	rc = bnx2x_vf_tpa_update(bp, vf, tpa_tlv, &vf_op_params);
1860 
1861 mbx_resp:
1862 	bnx2x_vf_mbx_resp(bp, vf, rc);
1863 }
1864 
1865 /* dispatch request */
1866 static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
1867 				  struct bnx2x_vf_mbx *mbx)
1868 {
1869 	int i;
1870 
1871 	/* check if tlv type is known */
1872 	if (bnx2x_tlv_supported(mbx->first_tlv.tl.type)) {
1873 		/* Lock the per vf op mutex and note the locker's identity.
1874 		 * The unlock will take place in mbx response.
1875 		 */
1876 		bnx2x_lock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
1877 
1878 		/* switch on the opcode */
1879 		switch (mbx->first_tlv.tl.type) {
1880 		case CHANNEL_TLV_ACQUIRE:
1881 			bnx2x_vf_mbx_acquire(bp, vf, mbx);
1882 			return;
1883 		case CHANNEL_TLV_INIT:
1884 			bnx2x_vf_mbx_init_vf(bp, vf, mbx);
1885 			return;
1886 		case CHANNEL_TLV_SETUP_Q:
1887 			bnx2x_vf_mbx_setup_q(bp, vf, mbx);
1888 			return;
1889 		case CHANNEL_TLV_SET_Q_FILTERS:
1890 			bnx2x_vf_mbx_set_q_filters(bp, vf, mbx);
1891 			return;
1892 		case CHANNEL_TLV_TEARDOWN_Q:
1893 			bnx2x_vf_mbx_teardown_q(bp, vf, mbx);
1894 			return;
1895 		case CHANNEL_TLV_CLOSE:
1896 			bnx2x_vf_mbx_close_vf(bp, vf, mbx);
1897 			return;
1898 		case CHANNEL_TLV_RELEASE:
1899 			bnx2x_vf_mbx_release_vf(bp, vf, mbx);
1900 			return;
1901 		case CHANNEL_TLV_UPDATE_RSS:
1902 			bnx2x_vf_mbx_update_rss(bp, vf, mbx);
1903 			return;
1904 		case CHANNEL_TLV_UPDATE_TPA:
1905 			bnx2x_vf_mbx_update_tpa(bp, vf, mbx);
1906 			return;
1907 		}
1908 
1909 	} else {
1910 		/* unknown TLV - this may belong to a VF driver from the future
1911 		 * - a version written after this PF driver was written, which
1912 		 * supports features unknown as of yet. Too bad since we don't
1913 		 * support them. Or this may be because someone wrote a crappy
1914 		 * VF driver and is sending garbage over the channel.
1915 		 */
1916 		BNX2X_ERR("unknown TLV. type %d length %d vf->state was %d. first 20 bytes of mailbox buffer:\n",
1917 			  mbx->first_tlv.tl.type, mbx->first_tlv.tl.length,
1918 			  vf->state);
1919 		for (i = 0; i < 20; i++)
1920 			DP_CONT(BNX2X_MSG_IOV, "%x ",
1921 				mbx->msg->req.tlv_buf_size.tlv_buffer[i]);
1922 	}
1923 
1924 	/* can we respond to VF (do we have an address for it?) */
1925 	if (vf->state == VF_ACQUIRED || vf->state == VF_ENABLED) {
1926 		/* notify the VF that we do not support this request */
1927 		bnx2x_vf_mbx_resp(bp, vf, PFVF_STATUS_NOT_SUPPORTED);
1928 	} else {
1929 		/* can't send a response since this VF is unknown to us
1930 		 * just ack the FW to release the mailbox and unlock
1931 		 * the channel.
1932 		 */
1933 		storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
1934 		/* Firmware ack should be written before unlocking channel */
1935 		mmiowb();
1936 		bnx2x_unlock_vf_pf_channel(bp, vf, mbx->first_tlv.tl.type);
1937 	}
1938 }
1939 
1940 void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
1941 			   struct vf_pf_event_data *vfpf_event)
1942 {
1943 	u8 vf_idx;
1944 
1945 	DP(BNX2X_MSG_IOV,
1946 	   "vf pf event received: vfid %d, address_hi %x, address lo %x",
1947 	   vfpf_event->vf_id, vfpf_event->msg_addr_hi, vfpf_event->msg_addr_lo);
1948 	/* Sanity checks consider removing later */
1949 
1950 	/* check if the vf_id is valid */
1951 	if (vfpf_event->vf_id - BP_VFDB(bp)->sriov.first_vf_in_pf >
1952 	    BNX2X_NR_VIRTFN(bp)) {
1953 		BNX2X_ERR("Illegal vf_id %d max allowed: %d\n",
1954 			  vfpf_event->vf_id, BNX2X_NR_VIRTFN(bp));
1955 		return;
1956 	}
1957 
1958 	vf_idx = bnx2x_vf_idx_by_abs_fid(bp, vfpf_event->vf_id);
1959 
1960 	/* Update VFDB with current message and schedule its handling */
1961 	mutex_lock(&BP_VFDB(bp)->event_mutex);
1962 	BP_VF_MBX(bp, vf_idx)->vf_addr_hi = vfpf_event->msg_addr_hi;
1963 	BP_VF_MBX(bp, vf_idx)->vf_addr_lo = vfpf_event->msg_addr_lo;
1964 	BP_VFDB(bp)->event_occur |= (1ULL << vf_idx);
1965 	mutex_unlock(&BP_VFDB(bp)->event_mutex);
1966 
1967 	bnx2x_schedule_iov_task(bp, BNX2X_IOV_HANDLE_VF_MSG);
1968 }
1969 
1970 /* handle new vf-pf messages */
1971 void bnx2x_vf_mbx(struct bnx2x *bp)
1972 {
1973 	struct bnx2x_vfdb *vfdb = BP_VFDB(bp);
1974 	u64 events;
1975 	u8 vf_idx;
1976 	int rc;
1977 
1978 	if (!vfdb)
1979 		return;
1980 
1981 	mutex_lock(&vfdb->event_mutex);
1982 	events = vfdb->event_occur;
1983 	vfdb->event_occur = 0;
1984 	mutex_unlock(&vfdb->event_mutex);
1985 
1986 	for_each_vf(bp, vf_idx) {
1987 		struct bnx2x_vf_mbx *mbx = BP_VF_MBX(bp, vf_idx);
1988 		struct bnx2x_virtf *vf = BP_VF(bp, vf_idx);
1989 
1990 		/* Handle VFs which have pending events */
1991 		if (!(events & (1ULL << vf_idx)))
1992 			continue;
1993 
1994 		DP(BNX2X_MSG_IOV,
1995 		   "Handling vf pf event vfid %d, address: [%x:%x], resp_offset 0x%x\n",
1996 		   vf_idx, mbx->vf_addr_hi, mbx->vf_addr_lo,
1997 		   mbx->first_tlv.resp_msg_offset);
1998 
1999 		/* dmae to get the VF request */
2000 		rc = bnx2x_copy32_vf_dmae(bp, true, mbx->msg_mapping,
2001 					  vf->abs_vfid, mbx->vf_addr_hi,
2002 					  mbx->vf_addr_lo,
2003 					  sizeof(union vfpf_tlvs)/4);
2004 		if (rc) {
2005 			BNX2X_ERR("Failed to copy request VF %d\n",
2006 				  vf->abs_vfid);
2007 			bnx2x_vf_release(bp, vf);
2008 			return;
2009 		}
2010 
2011 		/* process the VF message header */
2012 		mbx->first_tlv = mbx->msg->req.first_tlv;
2013 
2014 		/* Clean response buffer to refrain from falsely
2015 		 * seeing chains.
2016 		 */
2017 		memset(&mbx->msg->resp, 0, sizeof(union pfvf_tlvs));
2018 
2019 		/* dispatch the request (will prepare the response) */
2020 		bnx2x_vf_mbx_request(bp, vf, mbx);
2021 	}
2022 }
2023 
2024 void bnx2x_vf_bulletin_finalize(struct pf_vf_bulletin_content *bulletin,
2025 				bool support_long)
2026 {
2027 	/* Older VFs contain a bug where they can't check CRC for bulletin
2028 	 * boards of length greater than legacy size.
2029 	 */
2030 	bulletin->length = support_long ? BULLETIN_CONTENT_SIZE :
2031 					  BULLETIN_CONTENT_LEGACY_SIZE;
2032 	bulletin->crc = bnx2x_crc_vf_bulletin(bulletin);
2033 }
2034 
2035 /* propagate local bulletin board to vf */
2036 int bnx2x_post_vf_bulletin(struct bnx2x *bp, int vf)
2037 {
2038 	struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vf);
2039 	dma_addr_t pf_addr = BP_VF_BULLETIN_DMA(bp)->mapping +
2040 		vf * BULLETIN_CONTENT_SIZE;
2041 	dma_addr_t vf_addr = bnx2x_vf(bp, vf, bulletin_map);
2042 	int rc;
2043 
2044 	/* can only update vf after init took place */
2045 	if (bnx2x_vf(bp, vf, state) != VF_ENABLED &&
2046 	    bnx2x_vf(bp, vf, state) != VF_ACQUIRED)
2047 		return 0;
2048 
2049 	/* increment bulletin board version and compute crc */
2050 	bulletin->version++;
2051 	bnx2x_vf_bulletin_finalize(bulletin,
2052 				   (bnx2x_vf(bp, vf, cfg_flags) &
2053 				    VF_CFG_EXT_BULLETIN) ? true : false);
2054 
2055 	/* propagate bulletin board via dmae to vm memory */
2056 	rc = bnx2x_copy32_vf_dmae(bp, false, pf_addr,
2057 				  bnx2x_vf(bp, vf, abs_vfid), U64_HI(vf_addr),
2058 				  U64_LO(vf_addr), bulletin->length / 4);
2059 	return rc;
2060 }
2061