summaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x_vfpf.c
blob: 14b1d10a6db35aef64be251037ca70b1566b59f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
/*
 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
 *
 * Copyright (c) 2015 QLogic Corporation.
 * All rights reserved.
 * www.qlogic.com
 *
 * See LICENSE.bnx2x_pmd for copyright and licensing details.
 */

#include "bnx2x.h"

/* calculate the crc in the bulletin board */
static inline uint32_t
bnx2x_vf_crc(struct bnx2x_vf_bulletin *bull)
{
	uint32_t crc_sz = sizeof(bull->crc), length = bull->length - crc_sz;

	return ECORE_CRC32_LE(0, (uint8_t *)bull + crc_sz, length);
}

/* Checks are there mac/channel updates for VF
 * returns TRUE if something was updated
*/
int
bnx2x_check_bull(struct bnx2x_softc *sc)
{
	struct bnx2x_vf_bulletin *bull;
	uint8_t tries = 0;
	uint16_t old_version = sc->old_bulletin.version;
	uint64_t valid_bitmap;

	bull = sc->pf2vf_bulletin;
	if (old_version == bull->version) {
		return FALSE;
	} else {
		/* Check the crc until we get the correct data */
		while (tries < BNX2X_VF_BULLETIN_TRIES) {
			bull = sc->pf2vf_bulletin;
			if (bull->crc == bnx2x_vf_crc(bull))
				break;

			PMD_DRV_LOG(ERR, "bad crc on bulletin board. contained %x computed %x",
					bull->crc, bnx2x_vf_crc(bull));
			++tries;
		}
		if (tries == BNX2X_VF_BULLETIN_TRIES) {
			PMD_DRV_LOG(ERR, "pf to vf bulletin board crc was wrong %d consecutive times. Aborting",
					tries);
			return FALSE;
		}
	}

	valid_bitmap = bull->valid_bitmap;

	/* check the mac address and VLAN and allocate memory if valid */
	if (valid_bitmap & (1 << MAC_ADDR_VALID) && memcmp(bull->mac, sc->old_bulletin.mac, ETH_ALEN))
		rte_memcpy(&sc->link_params.mac_addr, bull->mac, ETH_ALEN);
	if (valid_bitmap & (1 << VLAN_VALID))
		rte_memcpy(&bull->vlan, &sc->old_bulletin.vlan, VLAN_HLEN);

	sc->old_bulletin = *bull;

	return TRUE;
}

/* add tlv to a buffer */
#define BNX2X_TLV_APPEND(_tlvs, _offset, _type, _length) \
	((struct vf_first_tlv *)((unsigned long)_tlvs + _offset))->type   = _type; \
	((struct vf_first_tlv *)((unsigned long)_tlvs + _offset))->length = _length

/* Initiliaze header of the first tlv and clear mailbox*/
static void
bnx2x_init_first_tlv(struct bnx2x_softc *sc, struct vf_first_tlv *tlv,
	uint16_t type, uint16_t len)
{
	struct bnx2x_vf_mbx_msg *mbox = sc->vf2pf_mbox;
	PMD_DRV_LOG(DEBUG, "Preparing %d tlv for sending", type);

	memset(mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));

	BNX2X_TLV_APPEND(tlv, 0, type, len);

	/* Initialize header of the first tlv */
	tlv->reply_offset = sizeof(mbox->query);
}

#define BNX2X_VF_CMD_ADDR_LO PXP_VF_ADDR_CSDM_GLOBAL_START
#define BNX2X_VF_CMD_ADDR_HI BNX2X_VF_CMD_ADDR_LO + 4
#define BNX2X_VF_CMD_TRIGGER BNX2X_VF_CMD_ADDR_HI + 4
#define BNX2X_VF_CHANNEL_DELAY 100
#define BNX2X_VF_CHANNEL_TRIES 100

static int
bnx2x_do_req4pf(struct bnx2x_softc *sc, phys_addr_t phys_addr)
{
	uint8_t *status = &sc->vf2pf_mbox->resp.common_reply.status;
	uint8_t i;

	if (!*status) {
		bnx2x_check_bull(sc);
		if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
			PMD_DRV_LOG(ERR, "channel is down. Aborting message sending");
			*status = BNX2X_VF_STATUS_SUCCESS;
			return 0;
		}

		REG_WR(sc, BNX2X_VF_CMD_ADDR_LO, U64_LO(phys_addr));
		REG_WR(sc, BNX2X_VF_CMD_ADDR_HI, U64_HI(phys_addr));

		/* memory barrier to ensure that FW can read phys_addr */
		wmb();

		REG_WR8(sc, BNX2X_VF_CMD_TRIGGER, 1);

		/* Do several attempts until PF completes
		 * "." is used to show progress
		 */
		for (i = 0; i < BNX2X_VF_CHANNEL_TRIES; i++) {
			DELAY_MS(BNX2X_VF_CHANNEL_DELAY);
			if (*status)
				break;
		}

		if (!*status) {
			PMD_DRV_LOG(ERR, "Response from PF timed out");
			return -EAGAIN;
		}
	} else {
		PMD_DRV_LOG(ERR, "status should be zero before message"
				"to pf was sent");
		return -EINVAL;
	}

	PMD_DRV_LOG(DEBUG, "Response from PF was received");
	return 0;
}

static inline uint16_t bnx2x_check_me_flags(uint32_t val)
{
	if (((val) & ME_REG_VF_VALID) && (!((val) & ME_REG_VF_ERR)))
		return ME_REG_VF_VALID;
	else
		return 0;
}

#define BNX2X_ME_ANSWER_DELAY 100
#define BNX2X_ME_ANSWER_TRIES 10

static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc)
{
	uint32_t val;
	uint8_t i = 0;

	while (i <= BNX2X_ME_ANSWER_TRIES) {
		val = BNX2X_DB_READ(DOORBELL_ADDR(sc, 0));
		if (bnx2x_check_me_flags(val))
			return VF_ID(val);

		DELAY_MS(BNX2X_ME_ANSWER_DELAY);
		i++;
	}

	return -EINVAL;
}

#define BNX2X_VF_OBTAIN_MAX_TRIES 3
#define BNX2X_VF_OBTAIN_MAC_FILTERS 1
#define BNX2X_VF_OBTAIN_MC_FILTERS 10

struct bnx2x_obtain_status {
	int success;
	int err_code;
};

static
struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
{
	int tries = 0;
	struct vf_acquire_resp_tlv *resp = &sc->vf2pf_mbox->resp.acquire_resp,
								 *sc_resp = &sc->acquire_resp;
	struct vf_resource_query    *res_query;
	struct vf_resc            *resc;
	struct bnx2x_obtain_status     status;
	int res_obtained = false;

	do {
		PMD_DRV_LOG(DEBUG, "trying to get resources");

		if (bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr)) {
			/* timeout */
			status.success = 0;
			status.err_code = -EAGAIN;
			return status;
		}

		memcpy(sc_resp, resp, sizeof(sc->acquire_resp));

		tries++;

		/* check PF to request acceptance */
		if (sc_resp->status == BNX2X_VF_STATUS_SUCCESS) {
			PMD_DRV_LOG(DEBUG, "resources obtained successfully");
			res_obtained = true;
		} else if (sc_resp->status == BNX2X_VF_STATUS_NO_RESOURCES &&
			tries < BNX2X_VF_OBTAIN_MAX_TRIES) {
			PMD_DRV_LOG(DEBUG,
			   "PF cannot allocate requested amount of resources");

			res_query = &sc->vf2pf_mbox->query[0].acquire.res_query;
			resc     = &sc_resp->resc;

			/* PF refused our request. Try to decrease request params */
			res_query->num_txqs         = min(res_query->num_txqs, resc->num_txqs);
			res_query->num_rxqs         = min(res_query->num_rxqs, resc->num_rxqs);
			res_query->num_sbs          = min(res_query->num_sbs, resc->num_sbs);
			res_query->num_mac_filters  = min(res_query->num_mac_filters, resc->num_mac_filters);
			res_query->num_vlan_filters = min(res_query->num_vlan_filters, resc->num_vlan_filters);
			res_query->num_mc_filters   = min(res_query->num_mc_filters, resc->num_mc_filters);

			memset(&sc->vf2pf_mbox->resp, 0, sizeof(union resp_tlvs));
		} else {
			PMD_DRV_LOG(ERR, "Resources cannot be obtained. Status of handling: %d. Aborting",
					sc_resp->status);
			status.success = 0;
			status.err_code = -EAGAIN;
			return status;
		}
	} while (!res_obtained);

	status.success = 1;
	return status;
}

int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_count)
{
	struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire;
	int vf_id;
	struct bnx2x_obtain_status obtain_status;

	bnx2x_vf_close(sc);
	bnx2x_init_first_tlv(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));

	vf_id = bnx2x_read_vf_id(sc);
	if (vf_id < 0)
		return -EAGAIN;

	acq->vf_id = vf_id;

	acq->res_query.num_rxqs = rx_count;
	acq->res_query.num_txqs = tx_count;
	acq->res_query.num_sbs = sc->igu_sb_cnt;
	acq->res_query.num_mac_filters = BNX2X_VF_OBTAIN_MAC_FILTERS;
	acq->res_query.num_mc_filters = BNX2X_VF_OBTAIN_MC_FILTERS;

	acq->bulletin_addr = sc->pf2vf_bulletin_mapping.paddr;

	/* Request physical port identifier */
	BNX2X_TLV_APPEND(acq, acq->first_tlv.length,
			 BNX2X_VF_TLV_PHYS_PORT_ID,
			 sizeof(struct channel_tlv));

	BNX2X_TLV_APPEND(acq,
			 (acq->first_tlv.length + sizeof(struct channel_tlv)),
			 BNX2X_VF_TLV_LIST_END,
			 sizeof(struct channel_list_end_tlv));

	/* requesting the resources in loop */
	obtain_status = bnx2x_loop_obtain_resources(sc);
	if (!obtain_status.success)
		return obtain_status.err_code;

	struct vf_acquire_resp_tlv sc_resp = sc->acquire_resp;

	sc->devinfo.chip_id        |= (sc_resp.chip_num & 0xFFFF);
	sc->devinfo.int_block       = INT_BLOCK_IGU;
	sc->devinfo.chip_port_mode  = CHIP_2_PORT_MODE;
	sc->devinfo.mf_info.mf_ov   = 0;
	sc->devinfo.mf_info.mf_mode = 0;
	sc->devinfo.flash_size      = 0;

	sc->igu_sb_cnt  = sc_resp.resc.num_sbs;
	sc->igu_base_sb = sc_resp.resc.hw_sbs[0] & 0xFF;
	sc->igu_dsb_id  = -1;
	sc->max_tx_queues = sc_resp.resc.num_txqs;
	sc->max_rx_queues = sc_resp.resc.num_rxqs;

	sc->link_params.chip_id = sc->devinfo.chip_id;
	sc->doorbell_size = sc_resp.db_size;
	sc->flags |= BNX2X_NO_WOL_FLAG | BNX2X_NO_ISCSI_OOO_FLAG | BNX2X_NO_ISCSI_FLAG | BNX2X_NO_FCOE_FLAG;

	PMD_DRV_LOG(DEBUG, "status block count = %d, base status block = %x",
		sc->igu_sb_cnt, sc->igu_base_sb);
	strncpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver));

	if (is_valid_ether_addr(sc_resp.resc.current_mac_addr))
		(void)rte_memcpy(sc->link_params.mac_addr,
		       sc_resp.resc.current_mac_addr,
		       ETH_ALEN);

	return 0;
}

/* Ask PF to release VF's resources */
void
bnx2x_vf_close(struct bnx2x_softc *sc)
{
	struct vf_release_tlv *query;
	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
	int vf_id = bnx2x_read_vf_id(sc);

	if (vf_id >= 0) {
		query = &sc->vf2pf_mbox->query[0].release;
		bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
				sizeof(*query));

		query->vf_id = vf_id;
		BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
				sizeof(struct channel_list_end_tlv));

		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
			PMD_DRV_LOG(ERR, "Failed to release VF");
	}
}

/* Let PF know the VF status blocks phys_addrs */
int
bnx2x_vf_init(struct bnx2x_softc *sc)
{
	struct vf_init_tlv *query;
	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
	int i;

	query = &sc->vf2pf_mbox->query[0].init;
	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_INIT,
			sizeof(*query));

	FOR_EACH_QUEUE(sc, i) {
		query->sb_addr[i] = (unsigned long)(sc->fp[i].sb_dma.paddr);
	}

	query->stats_step = sizeof(struct per_queue_stats);
	query->stats_addr = sc->fw_stats_data_mapping +
		offsetof(struct bnx2x_fw_stats_data, queue_stats);

	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
			sizeof(struct channel_list_end_tlv));

	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
		PMD_DRV_LOG(ERR, "Failed to init VF");
		return -EINVAL;
	}

	PMD_DRV_LOG(DEBUG, "VF was initialized");
	return 0;
}

void
bnx2x_vf_unload(struct bnx2x_softc *sc)
{
	struct vf_close_tlv *query;
	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
	struct vf_q_op_tlv *query_op;
	int i, vf_id;

	vf_id = bnx2x_read_vf_id(sc);
	if (vf_id > 0) {
		FOR_EACH_QUEUE(sc, i) {
			query_op = &sc->vf2pf_mbox->query[0].q_op;
			bnx2x_init_first_tlv(sc, &query_op->first_tlv,
					BNX2X_VF_TLV_TEARDOWN_Q,
					sizeof(*query_op));

			query_op->vf_qid = i;

			BNX2X_TLV_APPEND(query_op, query_op->first_tlv.length,
					BNX2X_VF_TLV_LIST_END,
					sizeof(struct channel_list_end_tlv));

			bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
			if (reply->status != BNX2X_VF_STATUS_SUCCESS)
				PMD_DRV_LOG(ERR,
					    "Bad reply for vf_q %d teardown", i);
		}

		bnx2x_vf_set_mac(sc, false);

		query = &sc->vf2pf_mbox->query[0].close;
		bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_CLOSE,
				sizeof(*query));

		query->vf_id = vf_id;

		BNX2X_TLV_APPEND(query, query->first_tlv.length,
				BNX2X_VF_TLV_LIST_END,
				sizeof(struct channel_list_end_tlv));

		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
			PMD_DRV_LOG(ERR,
				    "Bad reply from PF for close message");
	}
}

static inline uint16_t
bnx2x_vf_q_flags(uint8_t leading)
{
	uint16_t flags = leading ? BNX2X_VF_Q_FLAG_LEADING_RSS : 0;

	flags |= BNX2X_VF_Q_FLAG_CACHE_ALIGN;
	flags |= BNX2X_VF_Q_FLAG_STATS;
	flags |= BNX2X_VF_Q_FLAG_VLAN;

	return flags;
}

static void
bnx2x_vf_rx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
		struct vf_rxq_params *rxq_init, uint16_t flags)
{
	struct bnx2x_rx_queue *rxq;

	rxq = sc->rx_queues[fp->index];
	if (!rxq) {
		PMD_DRV_LOG(ERR, "RX queue %d is NULL", fp->index);
		return;
	}

	rxq_init->rcq_addr = rxq->cq_ring_phys_addr;
	rxq_init->rcq_np_addr = rxq->cq_ring_phys_addr + BNX2X_PAGE_SIZE;
	rxq_init->rxq_addr = rxq->rx_ring_phys_addr;
	rxq_init->vf_sb_id = fp->index;
	rxq_init->sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS;
	rxq_init->mtu = sc->mtu;
	rxq_init->buf_sz = fp->rx_buf_size;
	rxq_init->flags = flags;
	rxq_init->stat_id = -1;
	rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT;
}

static void
bnx2x_vf_tx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
		struct vf_txq_params *txq_init, uint16_t flags)
{
	struct bnx2x_tx_queue *txq;

	txq = sc->tx_queues[fp->index];
	if (!txq) {
		PMD_DRV_LOG(ERR, "TX queue %d is NULL", fp->index);
		return;
	}

	txq_init->txq_addr = txq->tx_ring_phys_addr;
	txq_init->sb_index = HC_INDEX_ETH_TX_CQ_CONS_COS0;
	txq_init->flags = flags;
	txq_init->traffic_type = LLFC_TRAFFIC_TYPE_NW;
	txq_init->vf_sb_id = fp->index;
}

int
bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int leading)
{
	struct vf_setup_q_tlv *query;
	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
	uint16_t flags = bnx2x_vf_q_flags(leading);

	query = &sc->vf2pf_mbox->query[0].setup_q;
	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q,
			sizeof(*query));

	query->vf_qid = fp->index;
	query->param_valid = VF_RXQ_VALID | VF_TXQ_VALID;

	bnx2x_vf_rx_q_prep(sc, fp, &query->rxq, flags);
	bnx2x_vf_tx_q_prep(sc, fp, &query->txq, flags);

	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
			sizeof(struct channel_list_end_tlv));

	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
		PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]",
				 fp->index);
		return -EINVAL;
	}

	return 0;
}

int
bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
{
	struct vf_set_q_filters_tlv *query;
	struct vf_common_reply_tlv *reply;

	query = &sc->vf2pf_mbox->query[0].set_q_filters;
	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
			sizeof(*query));

	query->vf_qid = sc->fp->index;
	query->mac_filters_cnt = 1;
	query->flags = BNX2X_VF_MAC_VLAN_CHANGED;

	query->filters[0].flags = (set ? BNX2X_VF_Q_FILTER_SET_MAC : 0) |
		BNX2X_VF_Q_FILTER_DEST_MAC_VALID;

	bnx2x_check_bull(sc);

	rte_memcpy(query->filters[0].mac, sc->link_params.mac_addr, ETH_ALEN);

	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
			sizeof(struct channel_list_end_tlv));

	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
	reply = &sc->vf2pf_mbox->resp.common_reply;

	while (BNX2X_VF_STATUS_FAILURE == reply->status &&
			bnx2x_check_bull(sc)) {
		/* A new mac was configured by PF for us */
		rte_memcpy(sc->link_params.mac_addr, sc->pf2vf_bulletin->mac,
				ETH_ALEN);
		rte_memcpy(query->filters[0].mac, sc->pf2vf_bulletin->mac,
				ETH_ALEN);

		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
	}

	if (BNX2X_VF_STATUS_SUCCESS != reply->status) {
		PMD_DRV_LOG(ERR, "Bad reply from PF for SET MAC message: %d",
				reply->status);
		return -EINVAL;
	}

	return 0;
}

int
bnx2x_vf_config_rss(struct bnx2x_softc *sc,
			  struct ecore_config_rss_params *params)
{
	struct vf_rss_tlv *query;
	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;

	query = &sc->vf2pf_mbox->query[0].update_rss;

	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_UPDATE_RSS,
			sizeof(*query));

	/* add list termination tlv */
	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
			sizeof(struct channel_list_end_tlv));

	rte_memcpy(query->rss_key, params->rss_key, sizeof(params->rss_key));
	query->rss_key_size = T_ETH_RSS_KEY;

	rte_memcpy(query->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
	query->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;

	query->rss_result_mask = params->rss_result_mask;
	query->rss_flags = params->rss_flags;

	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
		PMD_DRV_LOG(ERR, "Failed to configure RSS");
		return -EINVAL;
	}

	return 0;
}

int
bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
{
	struct vf_set_q_filters_tlv *query;
	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
	unsigned long tx_mask;

	query = &sc->vf2pf_mbox->query[0].set_q_filters;
	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
			sizeof(*query));

	query->vf_qid = 0;
	query->flags = BNX2X_VF_RX_MASK_CHANGED;

	if (bnx2x_fill_accept_flags(sc, sc->rx_mode, &query->rx_mask, &tx_mask)) {
		return -EINVAL;
	}

	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
			sizeof(struct channel_list_end_tlv));

	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
		PMD_DRV_LOG(ERR, "Failed to set RX mode");
		return -EINVAL;
	}

	return 0;
}