b3fcceb750384c845f3fce2f6d11c9db48b97d20
[dpdk.git] / drivers / net / bnx2x / bnx2x_vfpf.c
1 /*
2  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
3  *
4  * Copyright (c) 2015 QLogic Corporation.
5  * All rights reserved.
6  * www.qlogic.com
7  *
8  * See LICENSE.bnx2x_pmd for copyright and licensing details.
9  */
10
11 #include "bnx2x.h"
12
13 /* calculate the crc in the bulletin board */
14 static inline uint32_t
15 bnx2x_vf_crc(struct bnx2x_vf_bulletin *bull)
16 {
17         uint32_t crc_sz = sizeof(bull->crc), length = bull->length - crc_sz;
18
19         return ECORE_CRC32_LE(0, (uint8_t *)bull + crc_sz, length);
20 }
21
22 /* Checks are there mac/channel updates for VF
23  * returns TRUE if something was updated
24 */
25 int
26 bnx2x_check_bull(struct bnx2x_softc *sc)
27 {
28         struct bnx2x_vf_bulletin *bull;
29         uint8_t tries = 0;
30         uint16_t old_version = sc->old_bulletin.version;
31         uint64_t valid_bitmap;
32
33         bull = sc->pf2vf_bulletin;
34         if (old_version == bull->version) {
35                 return FALSE;
36         } else {
37                 /* Check the crc until we get the correct data */
38                 while (tries < BNX2X_VF_BULLETIN_TRIES) {
39                         bull = sc->pf2vf_bulletin;
40                         if (bull->crc == bnx2x_vf_crc(bull))
41                                 break;
42
43                         PMD_DRV_LOG(ERR, "bad crc on bulletin board. contained %x computed %x",
44                                         bull->crc, bnx2x_vf_crc(bull));
45                         ++tries;
46                 }
47                 if (tries == BNX2X_VF_BULLETIN_TRIES) {
48                         PMD_DRV_LOG(ERR, "pf to vf bulletin board crc was wrong %d consecutive times. Aborting",
49                                         tries);
50                         return FALSE;
51                 }
52         }
53
54         valid_bitmap = bull->valid_bitmap;
55
56         /* check the mac address and VLAN and allocate memory if valid */
57         if (valid_bitmap & (1 << MAC_ADDR_VALID) && memcmp(bull->mac, sc->old_bulletin.mac, ETH_ALEN))
58                 rte_memcpy(&sc->link_params.mac_addr, bull->mac, ETH_ALEN);
59         if (valid_bitmap & (1 << VLAN_VALID))
60                 rte_memcpy(&bull->vlan, &sc->old_bulletin.vlan, VLAN_HLEN);
61
62         sc->old_bulletin = *bull;
63
64         return TRUE;
65 }
66
67 /* add tlv to a buffer */
68 #define BNX2X_TLV_APPEND(_tlvs, _offset, _type, _length) \
69         ((struct vf_first_tlv *)((uint64_t)_tlvs + _offset))->type   = _type; \
70         ((struct vf_first_tlv *)((uint64_t)_tlvs + _offset))->length = _length
71
72 /* Initiliaze header of the first tlv and clear mailbox*/
73 static void
74 bnx2x_init_first_tlv(struct bnx2x_softc *sc, struct vf_first_tlv *tlv,
75         uint16_t type, uint16_t len)
76 {
77         struct bnx2x_vf_mbx_msg *mbox = sc->vf2pf_mbox;
78         PMD_DRV_LOG(DEBUG, "Preparing %d tlv for sending", type);
79
80         memset(mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
81
82         BNX2X_TLV_APPEND(tlv, 0, type, len);
83
84         /* Initialize header of the first tlv */
85         tlv->reply_offset = sizeof(mbox->query);
86 }
87
88 #define BNX2X_VF_CMD_ADDR_LO PXP_VF_ADDR_CSDM_GLOBAL_START
89 #define BNX2X_VF_CMD_ADDR_HI BNX2X_VF_CMD_ADDR_LO + 4
90 #define BNX2X_VF_CMD_TRIGGER BNX2X_VF_CMD_ADDR_HI + 4
91 #define BNX2X_VF_CHANNEL_DELAY 100
92 #define BNX2X_VF_CHANNEL_TRIES 100
93
94 static int
95 bnx2x_do_req4pf(struct bnx2x_softc *sc, phys_addr_t phys_addr)
96 {
97         uint8_t *status = &sc->vf2pf_mbox->resp.common_reply.status;
98         uint8_t i;
99
100         if (!*status) {
101                 bnx2x_check_bull(sc);
102                 if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
103                         PMD_DRV_LOG(ERR, "channel is down. Aborting message sending");
104                         *status = BNX2X_VF_STATUS_SUCCESS;
105                         return 0;
106                 }
107
108                 REG_WR(sc, BNX2X_VF_CMD_ADDR_LO, U64_LO(phys_addr));
109                 REG_WR(sc, BNX2X_VF_CMD_ADDR_HI, U64_HI(phys_addr));
110
111                 /* memory barrier to ensure that FW can read phys_addr */
112                 wmb();
113
114                 REG_WR8(sc, BNX2X_VF_CMD_TRIGGER, 1);
115
116                 /* Do several attempts until PF completes
117                  * "." is used to show progress
118                  */
119                 for (i = 0; i < BNX2X_VF_CHANNEL_TRIES; i++) {
120                         DELAY_MS(BNX2X_VF_CHANNEL_DELAY);
121                         if (*status)
122                                 break;
123                 }
124
125                 if (i == BNX2X_VF_CHANNEL_TRIES) {
126                         PMD_DRV_LOG(ERR, "Response from PF timed out");
127                         return -EAGAIN;
128                 }
129
130                 if (BNX2X_VF_STATUS_SUCCESS != *status) {
131                         PMD_DRV_LOG(ERR, "Bad reply from PF : %u",
132                                         *status);
133                         return -EINVAL;
134                 }
135         } else {
136                 PMD_DRV_LOG(ERR, "status should be zero before message"
137                                 "to pf was sent");
138                 return -EINVAL;
139         }
140
141         PMD_DRV_LOG(DEBUG, "Response from PF was received");
142         return 0;
143 }
144
145 static inline uint16_t bnx2x_check_me_flags(uint32_t val)
146 {
147         if (((val) & ME_REG_VF_VALID) && (!((val) & ME_REG_VF_ERR)))
148                 return ME_REG_VF_VALID;
149         else
150                 return 0;
151 }
152
153 #define BNX2X_ME_ANSWER_DELAY 100
154 #define BNX2X_ME_ANSWER_TRIES 10
155
156 static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc)
157 {
158         uint32_t val;
159         uint8_t i = 0;
160
161         while (i <= BNX2X_ME_ANSWER_TRIES) {
162                 val = BNX2X_DB_READ(DOORBELL_ADDR(sc, 0));
163                 if (bnx2x_check_me_flags(val))
164                         return VF_ID(val);
165
166                 DELAY_MS(BNX2X_ME_ANSWER_DELAY);
167                 i++;
168         }
169
170         return -EINVAL;
171 }
172
173 #define BNX2X_VF_OBTAIN_MAX_TRIES 3
174 #define BNX2X_VF_OBTAIN_MAC_FILTERS 1
175 #define BNX2X_VF_OBTAIN_MC_FILTERS 10
176
177 struct bnx2x_obtain_status {
178         int success;
179         int err_code;
180 };
181
182 static
183 struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
184 {
185         int tries = 0;
186         struct vf_acquire_resp_tlv *resp = &sc->vf2pf_mbox->resp.acquire_resp,
187                                                                  *sc_resp = &sc->acquire_resp;
188         struct vf_resource_query    *res_query;
189         struct vf_resc            *resc;
190         struct bnx2x_obtain_status     status;
191         int res_obtained = false;
192
193         do {
194                 PMD_DRV_LOG(DEBUG, "trying to get resources");
195
196                 if ( bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr) ) {
197                         /* timeout */
198                         status.success = 0;
199                         status.err_code = 0;
200                         return status;
201                 }
202
203                 memcpy(sc_resp, resp, sizeof(sc->acquire_resp));
204
205                 tries++;
206
207                 /* check PF to request acceptance */
208                 if (sc_resp->status == BNX2X_VF_STATUS_SUCCESS) {
209                         PMD_DRV_LOG(DEBUG, "resources obtained successfully");
210                         res_obtained = true;
211                 } else if (sc_resp->status == BNX2X_VF_STATUS_NO_RESOURCES &&
212                         tries < BNX2X_VF_OBTAIN_MAX_TRIES) {
213                         PMD_DRV_LOG(DEBUG,
214                            "PF cannot allocate requested amount of resources");
215
216                         res_query = &sc->vf2pf_mbox->query[0].acquire.res_query;
217                         resc     = &sc_resp->resc;
218
219                         /* PF refused our request. Try to decrease request params */
220                         res_query->num_txqs         = min(res_query->num_txqs, resc->num_txqs);
221                         res_query->num_rxqs         = min(res_query->num_rxqs, resc->num_rxqs);
222                         res_query->num_sbs          = min(res_query->num_sbs, resc->num_sbs);
223                         res_query->num_mac_filters  = min(res_query->num_mac_filters, resc->num_mac_filters);
224                         res_query->num_vlan_filters = min(res_query->num_vlan_filters, resc->num_vlan_filters);
225                         res_query->num_mc_filters   = min(res_query->num_mc_filters, resc->num_mc_filters);
226
227                         memset(&sc->vf2pf_mbox->resp, 0, sizeof(union resp_tlvs));
228                 } else {
229                         PMD_DRV_LOG(ERR, "Resources cannot be obtained. Status of handling: %d. Aborting",
230                                         sc_resp->status);
231                         status.success = 0;
232                         status.err_code = -EAGAIN;
233                         return status;
234                 }
235         } while (!res_obtained);
236
237         status.success = 1;
238         return status;
239 }
240
241 int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_count)
242 {
243         struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire;
244         int vf_id;
245         struct bnx2x_obtain_status obtain_status;
246
247         bnx2x_vf_close(sc);
248         bnx2x_init_first_tlv(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));
249
250         vf_id = bnx2x_read_vf_id(sc);
251         if (vf_id < 0)
252                 return -EAGAIN;
253
254         acq->vf_id = vf_id;
255
256         acq->res_query.num_rxqs = rx_count;
257         acq->res_query.num_txqs = tx_count;
258         acq->res_query.num_sbs = sc->igu_sb_cnt;
259         acq->res_query.num_mac_filters = BNX2X_VF_OBTAIN_MAC_FILTERS;
260         acq->res_query.num_mc_filters = BNX2X_VF_OBTAIN_MC_FILTERS;
261
262         acq->bulletin_addr = sc->pf2vf_bulletin_mapping.paddr;
263
264         /* Request physical port identifier */
265         BNX2X_TLV_APPEND(acq, acq->first_tlv.length,
266                          BNX2X_VF_TLV_PHYS_PORT_ID,
267                          sizeof(struct channel_tlv));
268
269         BNX2X_TLV_APPEND(acq,
270                          (acq->first_tlv.length + sizeof(struct channel_tlv)),
271                          BNX2X_VF_TLV_LIST_END,
272                          sizeof(struct channel_list_end_tlv));
273
274         /* requesting the resources in loop */
275         obtain_status = bnx2x_loop_obtain_resources(sc);
276         if (!obtain_status.success)
277                 return obtain_status.err_code;
278
279         struct vf_acquire_resp_tlv sc_resp = sc->acquire_resp;
280
281         sc->devinfo.chip_id        |= (sc_resp.chip_num & 0xFFFF);
282         sc->devinfo.int_block       = INT_BLOCK_IGU;
283         sc->devinfo.chip_port_mode  = CHIP_2_PORT_MODE;
284         sc->devinfo.mf_info.mf_ov   = 0;
285         sc->devinfo.mf_info.mf_mode = 0;
286         sc->devinfo.flash_size      = 0;
287
288         sc->igu_sb_cnt  = sc_resp.resc.num_sbs;
289         sc->igu_base_sb = sc_resp.resc.hw_sbs[0] & 0xFF;
290         sc->igu_dsb_id  = -1;
291
292         sc->link_params.chip_id = sc->devinfo.chip_id;
293         sc->doorbell_size = sc_resp.db_size;
294         sc->flags |= BNX2X_NO_WOL_FLAG | BNX2X_NO_ISCSI_OOO_FLAG | BNX2X_NO_ISCSI_FLAG | BNX2X_NO_FCOE_FLAG;
295
296         PMD_DRV_LOG(DEBUG, "status block count = %d, base status block = %x",
297                 sc->igu_sb_cnt, sc->igu_base_sb);
298         strncpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver));
299
300         if (is_valid_ether_addr(sc_resp.resc.current_mac_addr))
301                 (void)rte_memcpy(sc->link_params.mac_addr,
302                        sc_resp.resc.current_mac_addr,
303                        ETH_ALEN);
304
305         return 0;
306 }
307
308 /* Ask PF to release VF's resources */
309 void
310 bnx2x_vf_close(struct bnx2x_softc *sc)
311 {
312         struct vf_release_tlv *query;
313         int vf_id = bnx2x_read_vf_id(sc);
314         int ret;
315
316         if (vf_id >= 0) {
317                 query = &sc->vf2pf_mbox->query[0].release;
318                 bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
319                                 sizeof(*query));
320
321                 query->vf_id = vf_id;
322                 BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
323                                 sizeof(struct channel_list_end_tlv));
324
325                 ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
326
327                 if (ret) {
328                         PMD_DRV_LOG(ERR, "Failed to release VF");
329                 }
330         }
331 }
332
333 /* Let PF know the VF status blocks phys_addrs */
334 int
335 bnx2x_vf_init(struct bnx2x_softc *sc)
336 {
337         struct vf_init_tlv *query;
338         int i, ret;
339
340         query = &sc->vf2pf_mbox->query[0].init;
341         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_INIT,
342                         sizeof(*query));
343
344         FOR_EACH_QUEUE(sc, i) {
345                 query->sb_addr[i] = (unsigned long)(sc->fp[i].sb_dma.paddr);
346         }
347
348         query->stats_step = sizeof(struct per_queue_stats);
349         query->stats_addr = sc->fw_stats_data_mapping +
350                 offsetof(struct bnx2x_fw_stats_data, queue_stats);
351
352         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
353                         sizeof(struct channel_list_end_tlv));
354
355         ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
356
357         if (ret) {
358                 PMD_DRV_LOG(ERR, "Failed to init VF");
359                 return ret;
360         }
361
362         PMD_DRV_LOG(DEBUG, "VF was initialized");
363         return 0;
364 }
365
366 void
367 bnx2x_vf_unload(struct bnx2x_softc *sc)
368 {
369         struct vf_close_tlv *query;
370         struct vf_q_op_tlv *query_op;
371         int i, vf_id, ret;
372
373         vf_id = bnx2x_read_vf_id(sc);
374         if (vf_id > 0) {
375                 FOR_EACH_QUEUE(sc, i) {
376                         query_op = &sc->vf2pf_mbox->query[0].q_op;
377                         bnx2x_init_first_tlv(sc, &query_op->first_tlv,
378                                         BNX2X_VF_TLV_TEARDOWN_Q,
379                                         sizeof(*query_op));
380
381                         query_op->vf_qid = i;
382
383                         BNX2X_TLV_APPEND(query_op, query_op->first_tlv.length,
384                                         BNX2X_VF_TLV_LIST_END,
385                                         sizeof(struct channel_list_end_tlv));
386
387                         ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
388                         if (ret)
389                                 PMD_DRV_LOG(ERR,
390                                                 "Bad reply for vf_q %d teardown", i);
391                 }
392
393                 bnx2x_vf_set_mac(sc, false);
394
395                 query = &sc->vf2pf_mbox->query[0].close;
396                 bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_CLOSE,
397                                 sizeof(*query));
398
399                 query->vf_id = vf_id;
400
401                 BNX2X_TLV_APPEND(query, query->first_tlv.length,
402                                 BNX2X_VF_TLV_LIST_END,
403                                 sizeof(struct channel_list_end_tlv));
404
405                 ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
406
407                 if (ret)
408                         PMD_DRV_LOG(ERR,
409                                 "Bad reply from PF for close message");
410         }
411 }
412
413 static inline uint16_t
414 bnx2x_vf_q_flags(uint8_t leading)
415 {
416         uint16_t flags = leading ? BNX2X_VF_Q_FLAG_LEADING_RSS : 0;
417
418         flags |= BNX2X_VF_Q_FLAG_CACHE_ALIGN;
419         flags |= BNX2X_VF_Q_FLAG_STATS;
420         flags |= BNX2X_VF_Q_FLAG_VLAN;
421
422         return flags;
423 }
424
425 static void
426 bnx2x_vf_rx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
427                 struct vf_rxq_params *rxq_init, uint16_t flags)
428 {
429         struct bnx2x_rx_queue *rxq;
430
431         rxq = sc->rx_queues[fp->index];
432         if (!rxq) {
433                 PMD_DRV_LOG(ERR, "RX queue %d is NULL", fp->index);
434                 return;
435         }
436
437         rxq_init->rcq_addr = rxq->cq_ring_phys_addr;
438         rxq_init->rcq_np_addr = rxq->cq_ring_phys_addr + BNX2X_PAGE_SIZE;
439         rxq_init->rxq_addr = rxq->rx_ring_phys_addr;
440         rxq_init->vf_sb_id = fp->index;
441         rxq_init->sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS;
442         rxq_init->mtu = sc->mtu;
443         rxq_init->buf_sz = fp->rx_buf_size;
444         rxq_init->flags = flags;
445         rxq_init->stat_id = -1;
446         rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT;
447 }
448
449 static void
450 bnx2x_vf_tx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
451                 struct vf_txq_params *txq_init, uint16_t flags)
452 {
453         struct bnx2x_tx_queue *txq;
454
455         txq = sc->tx_queues[fp->index];
456         if (!txq) {
457                 PMD_DRV_LOG(ERR, "TX queue %d is NULL", fp->index);
458                 return;
459         }
460
461         txq_init->txq_addr = txq->tx_ring_phys_addr;
462         txq_init->sb_index = HC_INDEX_ETH_TX_CQ_CONS_COS0;
463         txq_init->flags = flags;
464         txq_init->traffic_type = LLFC_TRAFFIC_TYPE_NW;
465         txq_init->vf_sb_id = fp->index;
466 }
467
468 int
469 bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int leading)
470 {
471         struct vf_setup_q_tlv *query;
472         uint16_t flags = bnx2x_vf_q_flags(leading);
473         int ret;
474
475         query = &sc->vf2pf_mbox->query[0].setup_q;
476         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q,
477                         sizeof(*query));
478
479         query->vf_qid = fp->index;
480         query->param_valid = VF_RXQ_VALID | VF_TXQ_VALID;
481
482         bnx2x_vf_rx_q_prep(sc, fp, &query->rxq, flags);
483         bnx2x_vf_tx_q_prep(sc, fp, &query->txq, flags);
484
485         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
486                         sizeof(struct channel_list_end_tlv));
487
488         ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
489
490         if (ret) {
491                 PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]",
492                                 fp->index);
493                 return -EINVAL;
494         }
495
496         return 0;
497 }
498
499 int
500 bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
501 {
502         struct vf_set_q_filters_tlv *query;
503         struct vf_common_reply_tlv *reply;
504
505         query = &sc->vf2pf_mbox->query[0].set_q_filters;
506         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
507                         sizeof(*query));
508
509         query->vf_qid = sc->fp->index;
510         query->mac_filters_cnt = 1;
511         query->flags = BNX2X_VF_MAC_VLAN_CHANGED;
512
513         query->filters[0].flags = (set ? BNX2X_VF_Q_FILTER_SET_MAC : 0) |
514                 BNX2X_VF_Q_FILTER_DEST_MAC_VALID;
515
516         bnx2x_check_bull(sc);
517
518         rte_memcpy(query->filters[0].mac, sc->link_params.mac_addr, ETH_ALEN);
519
520         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
521                         sizeof(struct channel_list_end_tlv));
522
523         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
524         reply = &sc->vf2pf_mbox->resp.common_reply;
525
526         while (BNX2X_VF_STATUS_FAILURE == reply->status &&
527                         bnx2x_check_bull(sc)) {
528                 /* A new mac was configured by PF for us */
529                 rte_memcpy(sc->link_params.mac_addr, sc->pf2vf_bulletin->mac,
530                                 ETH_ALEN);
531                 rte_memcpy(query->filters[0].mac, sc->pf2vf_bulletin->mac,
532                                 ETH_ALEN);
533
534                 bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
535         }
536
537         if (BNX2X_VF_STATUS_SUCCESS != reply->status) {
538                 PMD_DRV_LOG(ERR, "Bad reply from PF for SET MAC message: %d",
539                                 reply->status);
540                 return -EINVAL;
541         }
542
543         return 0;
544 }
545
546 int
547 bnx2x_vf_config_rss(struct bnx2x_softc *sc,
548                           struct ecore_config_rss_params *params)
549 {
550         struct vf_rss_tlv *query;
551         int ret;
552
553         query = &sc->vf2pf_mbox->query[0].update_rss;
554
555         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_UPDATE_RSS,
556                         sizeof(*query));
557
558         /* add list termination tlv */
559         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
560                         sizeof(struct channel_list_end_tlv));
561
562         rte_memcpy(query->rss_key, params->rss_key, sizeof(params->rss_key));
563         query->rss_key_size = T_ETH_RSS_KEY;
564
565         rte_memcpy(query->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
566         query->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;
567
568         query->rss_result_mask = params->rss_result_mask;
569         query->rss_flags = params->rss_flags;
570
571         ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
572         if (ret) {
573                 PMD_DRV_LOG(ERR, "Failed to send message to PF, rc %d", ret);
574                 return ret;
575         }
576
577         return 0;
578 }
579
580 int
581 bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
582 {
583         struct vf_set_q_filters_tlv *query;
584         unsigned long tx_mask;
585         int ret;
586
587         query = &sc->vf2pf_mbox->query[0].set_q_filters;
588         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
589                         sizeof(*query));
590
591         query->vf_qid = 0;
592         query->flags = BNX2X_VF_RX_MASK_CHANGED;
593
594         if (bnx2x_fill_accept_flags(sc, sc->rx_mode, &query->rx_mask, &tx_mask)) {
595                 return -EINVAL;
596         }
597
598         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
599                         sizeof(struct channel_list_end_tlv));
600
601         ret = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
602         if (ret) {
603                 PMD_DRV_LOG(ERR, "Failed to send message to PF, rc %d", ret);
604                 return ret;
605         }
606
607         return 0;
608 }