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