net/bnx2x: get cache line size from build configuration
[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 *)((unsigned long)_tlvs + _offset))->type   = _type; \
70         ((struct vf_first_tlv *)((unsigned long)_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 (!*status) {
126                         PMD_DRV_LOG(ERR, "Response from PF timed out");
127                         return -EAGAIN;
128                 }
129         } else {
130                 PMD_DRV_LOG(ERR, "status should be zero before message"
131                                 "to pf was sent");
132                 return -EINVAL;
133         }
134
135         PMD_DRV_LOG(DEBUG, "Response from PF was received");
136         return 0;
137 }
138
139 static inline uint16_t bnx2x_check_me_flags(uint32_t val)
140 {
141         if (((val) & ME_REG_VF_VALID) && (!((val) & ME_REG_VF_ERR)))
142                 return ME_REG_VF_VALID;
143         else
144                 return 0;
145 }
146
147 #define BNX2X_ME_ANSWER_DELAY 100
148 #define BNX2X_ME_ANSWER_TRIES 10
149
150 static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc)
151 {
152         uint32_t val;
153         uint8_t i = 0;
154
155         while (i <= BNX2X_ME_ANSWER_TRIES) {
156                 val = BNX2X_DB_READ(DOORBELL_ADDR(sc, 0));
157                 if (bnx2x_check_me_flags(val))
158                         return VF_ID(val);
159
160                 DELAY_MS(BNX2X_ME_ANSWER_DELAY);
161                 i++;
162         }
163
164         return -EINVAL;
165 }
166
167 #define BNX2X_VF_OBTAIN_MAX_TRIES 3
168 #define BNX2X_VF_OBTAIN_MAC_FILTERS 1
169 #define BNX2X_VF_OBTAIN_MC_FILTERS 10
170
171 struct bnx2x_obtain_status {
172         int success;
173         int err_code;
174 };
175
176 static
177 struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
178 {
179         int tries = 0;
180         struct vf_acquire_resp_tlv *resp = &sc->vf2pf_mbox->resp.acquire_resp,
181                                                                  *sc_resp = &sc->acquire_resp;
182         struct vf_resource_query    *res_query;
183         struct vf_resc            *resc;
184         struct bnx2x_obtain_status     status;
185         int res_obtained = false;
186
187         do {
188                 PMD_DRV_LOG(DEBUG, "trying to get resources");
189
190                 if (bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr)) {
191                         /* timeout */
192                         status.success = 0;
193                         status.err_code = -EAGAIN;
194                         return status;
195                 }
196
197                 memcpy(sc_resp, resp, sizeof(sc->acquire_resp));
198
199                 tries++;
200
201                 /* check PF to request acceptance */
202                 if (sc_resp->status == BNX2X_VF_STATUS_SUCCESS) {
203                         PMD_DRV_LOG(DEBUG, "resources obtained successfully");
204                         res_obtained = true;
205                 } else if (sc_resp->status == BNX2X_VF_STATUS_NO_RESOURCES &&
206                         tries < BNX2X_VF_OBTAIN_MAX_TRIES) {
207                         PMD_DRV_LOG(DEBUG,
208                            "PF cannot allocate requested amount of resources");
209
210                         res_query = &sc->vf2pf_mbox->query[0].acquire.res_query;
211                         resc     = &sc_resp->resc;
212
213                         /* PF refused our request. Try to decrease request params */
214                         res_query->num_txqs         = min(res_query->num_txqs, resc->num_txqs);
215                         res_query->num_rxqs         = min(res_query->num_rxqs, resc->num_rxqs);
216                         res_query->num_sbs          = min(res_query->num_sbs, resc->num_sbs);
217                         res_query->num_mac_filters  = min(res_query->num_mac_filters, resc->num_mac_filters);
218                         res_query->num_vlan_filters = min(res_query->num_vlan_filters, resc->num_vlan_filters);
219                         res_query->num_mc_filters   = min(res_query->num_mc_filters, resc->num_mc_filters);
220
221                         memset(&sc->vf2pf_mbox->resp, 0, sizeof(union resp_tlvs));
222                 } else {
223                         PMD_DRV_LOG(ERR, "Resources cannot be obtained. Status of handling: %d. Aborting",
224                                         sc_resp->status);
225                         status.success = 0;
226                         status.err_code = -EAGAIN;
227                         return status;
228                 }
229         } while (!res_obtained);
230
231         status.success = 1;
232         return status;
233 }
234
235 int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_count)
236 {
237         struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire;
238         int vf_id;
239         struct bnx2x_obtain_status obtain_status;
240
241         bnx2x_vf_close(sc);
242         bnx2x_init_first_tlv(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));
243
244         vf_id = bnx2x_read_vf_id(sc);
245         if (vf_id < 0)
246                 return -EAGAIN;
247
248         acq->vf_id = vf_id;
249
250         acq->res_query.num_rxqs = rx_count;
251         acq->res_query.num_txqs = tx_count;
252         acq->res_query.num_sbs = sc->igu_sb_cnt;
253         acq->res_query.num_mac_filters = BNX2X_VF_OBTAIN_MAC_FILTERS;
254         acq->res_query.num_mc_filters = BNX2X_VF_OBTAIN_MC_FILTERS;
255
256         acq->bulletin_addr = sc->pf2vf_bulletin_mapping.paddr;
257
258         /* Request physical port identifier */
259         BNX2X_TLV_APPEND(acq, acq->first_tlv.length,
260                          BNX2X_VF_TLV_PHYS_PORT_ID,
261                          sizeof(struct channel_tlv));
262
263         BNX2X_TLV_APPEND(acq,
264                          (acq->first_tlv.length + sizeof(struct channel_tlv)),
265                          BNX2X_VF_TLV_LIST_END,
266                          sizeof(struct channel_list_end_tlv));
267
268         /* requesting the resources in loop */
269         obtain_status = bnx2x_loop_obtain_resources(sc);
270         if (!obtain_status.success)
271                 return obtain_status.err_code;
272
273         struct vf_acquire_resp_tlv sc_resp = sc->acquire_resp;
274
275         sc->devinfo.chip_id        |= (sc_resp.chip_num & 0xFFFF);
276         sc->devinfo.int_block       = INT_BLOCK_IGU;
277         sc->devinfo.chip_port_mode  = CHIP_2_PORT_MODE;
278         sc->devinfo.mf_info.mf_ov   = 0;
279         sc->devinfo.mf_info.mf_mode = 0;
280         sc->devinfo.flash_size      = 0;
281
282         sc->igu_sb_cnt  = sc_resp.resc.num_sbs;
283         sc->igu_base_sb = sc_resp.resc.hw_sbs[0] & 0xFF;
284         sc->igu_dsb_id  = -1;
285         sc->max_tx_queues = sc_resp.resc.num_txqs;
286         sc->max_rx_queues = sc_resp.resc.num_rxqs;
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_assigned_ether_addr(&sc_resp.resc.current_mac_addr))
297                 ether_addr_copy(&sc_resp.resc.current_mac_addr,
298                                 (struct ether_addr *)sc->link_params.mac_addr);
299         else
300                 eth_random_addr(sc->link_params.mac_addr);
301
302         return 0;
303 }
304
305 /* Ask PF to release VF's resources */
306 void
307 bnx2x_vf_close(struct bnx2x_softc *sc)
308 {
309         struct vf_release_tlv *query;
310         struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
311         int vf_id = bnx2x_read_vf_id(sc);
312
313         if (vf_id >= 0) {
314                 query = &sc->vf2pf_mbox->query[0].release;
315                 bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
316                                 sizeof(*query));
317
318                 query->vf_id = vf_id;
319                 BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
320                                 sizeof(struct channel_list_end_tlv));
321
322                 bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
323                 if (reply->status != BNX2X_VF_STATUS_SUCCESS)
324                         PMD_DRV_LOG(ERR, "Failed to release VF");
325         }
326 }
327
328 /* Let PF know the VF status blocks phys_addrs */
329 int
330 bnx2x_vf_init(struct bnx2x_softc *sc)
331 {
332         struct vf_init_tlv *query;
333         struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
334         int i;
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         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
352         if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
353                 PMD_DRV_LOG(ERR, "Failed to init VF");
354                 return -EINVAL;
355         }
356
357         PMD_DRV_LOG(DEBUG, "VF was initialized");
358         return 0;
359 }
360
361 void
362 bnx2x_vf_unload(struct bnx2x_softc *sc)
363 {
364         struct vf_close_tlv *query;
365         struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
366         struct vf_q_op_tlv *query_op;
367         int i, vf_id;
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                         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
384                         if (reply->status != BNX2X_VF_STATUS_SUCCESS)
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                 bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
402                 if (reply->status != BNX2X_VF_STATUS_SUCCESS)
403                         PMD_DRV_LOG(ERR,
404                                     "Bad reply from PF for close message");
405         }
406 }
407
408 static inline uint16_t
409 bnx2x_vf_q_flags(uint8_t leading)
410 {
411         uint16_t flags = leading ? BNX2X_VF_Q_FLAG_LEADING_RSS : 0;
412
413         flags |= BNX2X_VF_Q_FLAG_CACHE_ALIGN;
414         flags |= BNX2X_VF_Q_FLAG_STATS;
415         flags |= BNX2X_VF_Q_FLAG_VLAN;
416
417         return flags;
418 }
419
420 static void
421 bnx2x_vf_rx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
422                 struct vf_rxq_params *rxq_init, uint16_t flags)
423 {
424         struct bnx2x_rx_queue *rxq;
425
426         rxq = sc->rx_queues[fp->index];
427         if (!rxq) {
428                 PMD_DRV_LOG(ERR, "RX queue %d is NULL", fp->index);
429                 return;
430         }
431
432         rxq_init->rcq_addr = rxq->cq_ring_phys_addr;
433         rxq_init->rcq_np_addr = rxq->cq_ring_phys_addr + BNX2X_PAGE_SIZE;
434         rxq_init->rxq_addr = rxq->rx_ring_phys_addr;
435         rxq_init->vf_sb_id = fp->index;
436         rxq_init->sb_cq_index = HC_INDEX_ETH_RX_CQ_CONS;
437         rxq_init->mtu = sc->mtu;
438         rxq_init->buf_sz = fp->rx_buf_size;
439         rxq_init->flags = flags;
440         rxq_init->stat_id = -1;
441         rxq_init->cache_line_log = BNX2X_RX_ALIGN_SHIFT;
442 }
443
444 static void
445 bnx2x_vf_tx_q_prep(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
446                 struct vf_txq_params *txq_init, uint16_t flags)
447 {
448         struct bnx2x_tx_queue *txq;
449
450         txq = sc->tx_queues[fp->index];
451         if (!txq) {
452                 PMD_DRV_LOG(ERR, "TX queue %d is NULL", fp->index);
453                 return;
454         }
455
456         txq_init->txq_addr = txq->tx_ring_phys_addr;
457         txq_init->sb_index = HC_INDEX_ETH_TX_CQ_CONS_COS0;
458         txq_init->flags = flags;
459         txq_init->traffic_type = LLFC_TRAFFIC_TYPE_NW;
460         txq_init->vf_sb_id = fp->index;
461 }
462
463 int
464 bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int leading)
465 {
466         struct vf_setup_q_tlv *query;
467         struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
468         uint16_t flags = bnx2x_vf_q_flags(leading);
469
470         query = &sc->vf2pf_mbox->query[0].setup_q;
471         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q,
472                         sizeof(*query));
473
474         query->vf_qid = fp->index;
475         query->param_valid = VF_RXQ_VALID | VF_TXQ_VALID;
476
477         bnx2x_vf_rx_q_prep(sc, fp, &query->rxq, flags);
478         bnx2x_vf_tx_q_prep(sc, fp, &query->txq, flags);
479
480         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
481                         sizeof(struct channel_list_end_tlv));
482
483         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
484         if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
485                 PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]",
486                                  fp->index);
487                 return -EINVAL;
488         }
489
490         return 0;
491 }
492
493 int
494 bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
495 {
496         struct vf_set_q_filters_tlv *query;
497         struct vf_common_reply_tlv *reply;
498
499         query = &sc->vf2pf_mbox->query[0].set_q_filters;
500         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
501                         sizeof(*query));
502
503         query->vf_qid = sc->fp->index;
504         query->mac_filters_cnt = 1;
505         query->flags = BNX2X_VF_MAC_VLAN_CHANGED;
506
507         query->filters[0].flags = (set ? BNX2X_VF_Q_FILTER_SET_MAC : 0) |
508                 BNX2X_VF_Q_FILTER_DEST_MAC_VALID;
509
510         bnx2x_check_bull(sc);
511
512         rte_memcpy(query->filters[0].mac, sc->link_params.mac_addr, ETH_ALEN);
513
514         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
515                         sizeof(struct channel_list_end_tlv));
516
517         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
518         reply = &sc->vf2pf_mbox->resp.common_reply;
519
520         while (BNX2X_VF_STATUS_FAILURE == reply->status &&
521                         bnx2x_check_bull(sc)) {
522                 /* A new mac was configured by PF for us */
523                 rte_memcpy(sc->link_params.mac_addr, sc->pf2vf_bulletin->mac,
524                                 ETH_ALEN);
525                 rte_memcpy(query->filters[0].mac, sc->pf2vf_bulletin->mac,
526                                 ETH_ALEN);
527
528                 bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
529         }
530
531         if (BNX2X_VF_STATUS_SUCCESS != reply->status) {
532                 PMD_DRV_LOG(ERR, "Bad reply from PF for SET MAC message: %d",
533                                 reply->status);
534                 return -EINVAL;
535         }
536
537         return 0;
538 }
539
540 int
541 bnx2x_vf_config_rss(struct bnx2x_softc *sc,
542                           struct ecore_config_rss_params *params)
543 {
544         struct vf_rss_tlv *query;
545         struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
546
547         query = &sc->vf2pf_mbox->query[0].update_rss;
548
549         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_UPDATE_RSS,
550                         sizeof(*query));
551
552         /* add list termination tlv */
553         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
554                         sizeof(struct channel_list_end_tlv));
555
556         rte_memcpy(query->rss_key, params->rss_key, sizeof(params->rss_key));
557         query->rss_key_size = T_ETH_RSS_KEY;
558
559         rte_memcpy(query->ind_table, params->ind_table, T_ETH_INDIRECTION_TABLE_SIZE);
560         query->ind_table_size = T_ETH_INDIRECTION_TABLE_SIZE;
561
562         query->rss_result_mask = params->rss_result_mask;
563         query->rss_flags = params->rss_flags;
564
565         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
566         if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
567                 PMD_DRV_LOG(ERR, "Failed to configure RSS");
568                 return -EINVAL;
569         }
570
571         return 0;
572 }
573
574 int
575 bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
576 {
577         struct vf_set_q_filters_tlv *query;
578         struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
579         unsigned long tx_mask;
580
581         query = &sc->vf2pf_mbox->query[0].set_q_filters;
582         bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
583                         sizeof(*query));
584
585         query->vf_qid = 0;
586         query->flags = BNX2X_VF_RX_MASK_CHANGED;
587
588         if (bnx2x_fill_accept_flags(sc, sc->rx_mode, &query->rx_mask, &tx_mask)) {
589                 return -EINVAL;
590         }
591
592         BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
593                         sizeof(struct channel_list_end_tlv));
594
595         bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
596         if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
597                 PMD_DRV_LOG(ERR, "Failed to set RX mode");
598                 return -EINVAL;
599         }
600
601         return 0;
602 }