1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3 * Copyright(c) 2010-2017 Intel Corporation
7 #include <ethdev_driver.h>
8 #include <rte_malloc.h>
9 #include <rte_bus_pci.h>
11 #include "base/ngbe.h"
12 #include "ngbe_ethdev.h"
14 #define NGBE_MAX_VFTA (128)
15 #define NGBE_VF_MSG_SIZE_DEFAULT 1
16 #define NGBE_VF_GET_QUEUE_MSG_SIZE 5
18 static inline uint16_t
19 dev_num_vf(struct rte_eth_dev *eth_dev)
21 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
23 /* EM only support 7 VFs. */
24 return pci_dev->max_vfs;
28 int ngbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
30 unsigned char vf_mac_addr[RTE_ETHER_ADDR_LEN];
31 struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(dev);
34 for (vfn = 0; vfn < vf_num; vfn++) {
35 rte_eth_random_addr(vf_mac_addr);
36 /* keep the random address as default */
37 memcpy(vfinfo[vfn].vf_mac_addresses, vf_mac_addr,
45 ngbe_mb_intr_setup(struct rte_eth_dev *dev)
47 struct ngbe_interrupt *intr = ngbe_dev_intr(dev);
49 intr->mask_misc |= NGBE_ICRMISC_VFMBX;
54 int ngbe_pf_host_init(struct rte_eth_dev *eth_dev)
56 struct ngbe_vf_info **vfinfo = NGBE_DEV_VFDATA(eth_dev);
57 struct ngbe_uta_info *uta_info = NGBE_DEV_UTA_INFO(eth_dev);
58 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
63 PMD_INIT_FUNC_TRACE();
65 RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
66 vf_num = dev_num_vf(eth_dev);
70 *vfinfo = rte_zmalloc("vf_info",
71 sizeof(struct ngbe_vf_info) * vf_num, 0);
72 if (*vfinfo == NULL) {
74 "Cannot allocate memory for private VF data\n");
78 ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
81 "failed to allocate switch domain for device %d", ret);
87 memset(uta_info, 0, sizeof(struct ngbe_uta_info));
88 hw->mac.mc_filter_type = 0;
90 RTE_ETH_DEV_SRIOV(eth_dev).active = RTE_ETH_8_POOLS;
91 RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = nb_queue;
92 RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx =
93 (uint16_t)(vf_num * nb_queue);
95 ngbe_vf_perm_addr_gen(eth_dev, vf_num);
97 /* init_mailbox_params */
98 hw->mbx.init_params(hw);
100 /* set mb interrupt mask */
101 ngbe_mb_intr_setup(eth_dev);
106 void ngbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
108 struct ngbe_vf_info **vfinfo;
112 PMD_INIT_FUNC_TRACE();
114 RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
115 RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = 0;
116 RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = 0;
118 vf_num = dev_num_vf(eth_dev);
122 vfinfo = NGBE_DEV_VFDATA(eth_dev);
126 ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id);
128 PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
134 int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev)
136 uint32_t vtctl, fcrth;
137 uint32_t vfre_offset;
139 const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */
140 const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);
141 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
147 vf_num = dev_num_vf(eth_dev);
151 /* set the default pool for PF */
152 vtctl = rd32(hw, NGBE_POOLCTL);
153 vtctl &= ~NGBE_POOLCTL_DEFPL_MASK;
154 vtctl |= NGBE_POOLCTL_DEFPL(vf_num);
155 vtctl |= NGBE_POOLCTL_RPLEN;
156 wr32(hw, NGBE_POOLCTL, vtctl);
158 vfre_offset = vf_num & VFRE_MASK;
160 /* Enable pools reserved to PF only */
161 wr32(hw, NGBE_POOLRXENA(0), (~0U) << vfre_offset);
162 wr32(hw, NGBE_POOLTXENA(0), (~0U) << vfre_offset);
164 wr32(hw, NGBE_PSRCTL, NGBE_PSRCTL_LBENA);
166 /* clear VMDq map to perment rar 0 */
167 hw->mac.clear_vmdq(hw, 0, BIT_MASK32);
169 /* clear VMDq map to scan rar 31 */
170 wr32(hw, NGBE_ETHADDRIDX, hw->mac.num_rar_entries);
171 wr32(hw, NGBE_ETHADDRASS, 0);
173 /* set VMDq map to default PF pool */
174 hw->mac.set_vmdq(hw, 0, vf_num);
177 * SW msut set PORTCTL.VT_Mode the same as GPIE.VT_Mode
179 gpie = rd32(hw, NGBE_GPIE);
180 gpie |= NGBE_GPIE_MSIX;
181 gcr_ext = rd32(hw, NGBE_PORTCTL);
182 gcr_ext &= ~NGBE_PORTCTL_NUMVT_MASK;
184 if (RTE_ETH_DEV_SRIOV(eth_dev).active == RTE_ETH_8_POOLS)
185 gcr_ext |= NGBE_PORTCTL_NUMVT_8;
187 wr32(hw, NGBE_PORTCTL, gcr_ext);
188 wr32(hw, NGBE_GPIE, gpie);
191 * enable vlan filtering and allow all vlan tags through
193 vlanctrl = rd32(hw, NGBE_VLANCTL);
194 vlanctrl |= NGBE_VLANCTL_VFE; /* enable vlan filters */
195 wr32(hw, NGBE_VLANCTL, vlanctrl);
197 /* enable all vlan filters */
198 for (i = 0; i < NGBE_MAX_VFTA; i++)
199 wr32(hw, NGBE_VLANTBL(i), 0xFFFFFFFF);
201 /* Enable MAC Anti-Spoofing */
202 hw->mac.set_mac_anti_spoofing(hw, FALSE, vf_num);
204 /* set flow control threshold to max to avoid tx switch hang */
205 wr32(hw, NGBE_FCWTRLO, 0);
206 fcrth = rd32(hw, NGBE_PBRXSIZE) - 32;
207 wr32(hw, NGBE_FCWTRHI, fcrth);
213 ngbe_set_rx_mode(struct rte_eth_dev *eth_dev)
215 struct rte_eth_dev_data *dev_data = eth_dev->data;
216 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
218 uint16_t vfn = dev_num_vf(eth_dev);
220 /* disable store-bad-packets */
221 wr32m(hw, NGBE_SECRXCTL, NGBE_SECRXCTL_SAVEBAD, 0);
223 /* Check for Promiscuous and All Multicast modes */
224 fctrl = rd32m(hw, NGBE_PSRCTL,
225 ~(NGBE_PSRCTL_UCP | NGBE_PSRCTL_MCP));
226 fctrl |= NGBE_PSRCTL_BCA |
229 vmolr = rd32m(hw, NGBE_POOLETHCTL(vfn),
230 ~(NGBE_POOLETHCTL_UCP |
231 NGBE_POOLETHCTL_MCP |
232 NGBE_POOLETHCTL_UCHA |
233 NGBE_POOLETHCTL_MCHA));
234 vmolr |= NGBE_POOLETHCTL_BCA |
235 NGBE_POOLETHCTL_UTA |
238 if (dev_data->promiscuous) {
239 fctrl |= NGBE_PSRCTL_UCP |
241 /* pf don't want packets routing to vf, so clear UPE */
242 vmolr |= NGBE_POOLETHCTL_MCP;
243 } else if (dev_data->all_multicast) {
244 fctrl |= NGBE_PSRCTL_MCP;
245 vmolr |= NGBE_POOLETHCTL_MCP;
247 vmolr |= NGBE_POOLETHCTL_UCHA;
248 vmolr |= NGBE_POOLETHCTL_MCHA;
251 wr32(hw, NGBE_POOLETHCTL(vfn), vmolr);
253 wr32(hw, NGBE_PSRCTL, fctrl);
255 ngbe_vlan_hw_strip_config(eth_dev);
259 ngbe_vf_reset_event(struct rte_eth_dev *eth_dev, uint16_t vf)
261 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
262 struct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));
263 int rar_entry = hw->mac.num_rar_entries - (vf + 1);
264 uint32_t vmolr = rd32(hw, NGBE_POOLETHCTL(vf));
266 vmolr |= (NGBE_POOLETHCTL_UCHA |
267 NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_UTA);
268 wr32(hw, NGBE_POOLETHCTL(vf), vmolr);
270 wr32(hw, NGBE_POOLTAG(vf), 0);
272 /* reset multicast table array for vf */
273 vfinfo[vf].num_vf_mc_hashes = 0;
276 ngbe_set_rx_mode(eth_dev);
278 hw->mac.clear_rar(hw, rar_entry);
282 ngbe_vf_reset_msg(struct rte_eth_dev *eth_dev, uint16_t vf)
284 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
287 const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */
288 const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);
289 uint8_t nb_q_per_pool;
292 vf_shift = vf & VFRE_MASK;
294 /* enable transmit for vf */
295 reg = rd32(hw, NGBE_POOLTXENA(0));
296 reg |= (1 << vf_shift);
297 wr32(hw, NGBE_POOLTXENA(0), reg);
299 /* enable all queue drop for IOV */
300 nb_q_per_pool = RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool;
301 for (i = vf * nb_q_per_pool; i < (vf + 1) * nb_q_per_pool; i++) {
304 wr32m(hw, NGBE_QPRXDROP, reg, reg);
307 /* enable receive for vf */
308 reg = rd32(hw, NGBE_POOLRXENA(0));
309 reg |= (reg | (1 << vf_shift));
310 wr32(hw, NGBE_POOLRXENA(0), reg);
312 ngbe_vf_reset_event(eth_dev, vf);
316 ngbe_disable_vf_mc_promisc(struct rte_eth_dev *eth_dev, uint32_t vf)
318 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
321 vmolr = rd32(hw, NGBE_POOLETHCTL(vf));
323 PMD_DRV_LOG(INFO, "VF %u: disabling multicast promiscuous\n", vf);
325 vmolr &= ~NGBE_POOLETHCTL_MCP;
327 wr32(hw, NGBE_POOLETHCTL(vf), vmolr);
333 ngbe_vf_reset(struct rte_eth_dev *eth_dev, uint16_t vf, uint32_t *msgbuf)
335 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
336 struct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));
337 unsigned char *vf_mac = vfinfo[vf].vf_mac_addresses;
338 int rar_entry = hw->mac.num_rar_entries - (vf + 1);
339 uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
341 ngbe_vf_reset_msg(eth_dev, vf);
343 hw->mac.set_rar(hw, rar_entry, vf_mac, vf, true);
345 /* Disable multicast promiscuous at reset */
346 ngbe_disable_vf_mc_promisc(eth_dev, vf);
348 /* reply to reset with ack and vf mac address */
349 msgbuf[0] = NGBE_VF_RESET | NGBE_VT_MSGTYPE_ACK;
350 rte_memcpy(new_mac, vf_mac, RTE_ETHER_ADDR_LEN);
352 * Piggyback the multicast filter type so VF can compute the
355 msgbuf[3] = hw->mac.mc_filter_type;
356 ngbe_write_mbx(hw, msgbuf, NGBE_VF_PERMADDR_MSG_LEN, vf);
362 ngbe_vf_set_mac_addr(struct rte_eth_dev *eth_dev,
363 uint32_t vf, uint32_t *msgbuf)
365 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
366 struct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));
367 int rar_entry = hw->mac.num_rar_entries - (vf + 1);
368 uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
369 struct rte_ether_addr *ea = (struct rte_ether_addr *)new_mac;
371 if (rte_is_valid_assigned_ether_addr(ea)) {
372 rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 6);
373 return hw->mac.set_rar(hw, rar_entry, new_mac, vf, true);
379 ngbe_vf_set_multicast(struct rte_eth_dev *eth_dev,
380 uint32_t vf, uint32_t *msgbuf)
382 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
383 struct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));
384 int nb_entries = (msgbuf[0] & NGBE_VT_MSGINFO_MASK) >>
385 NGBE_VT_MSGINFO_SHIFT;
386 uint16_t *hash_list = (uint16_t *)&msgbuf[1];
389 const uint32_t NGBE_MTA_INDEX_MASK = 0x7F;
390 const uint32_t NGBE_MTA_BIT_SHIFT = 5;
391 const uint32_t NGBE_MTA_BIT_MASK = (0x1 << NGBE_MTA_BIT_SHIFT) - 1;
394 u32 vmolr = rd32(hw, NGBE_POOLETHCTL(vf));
396 /* Disable multicast promiscuous first */
397 ngbe_disable_vf_mc_promisc(eth_dev, vf);
399 /* only so many hash values supported */
400 nb_entries = RTE_MIN(nb_entries, NGBE_MAX_VF_MC_ENTRIES);
402 /* store the mc entries */
403 vfinfo->num_vf_mc_hashes = (uint16_t)nb_entries;
404 for (i = 0; i < nb_entries; i++)
405 vfinfo->vf_mc_hashes[i] = hash_list[i];
407 if (nb_entries == 0) {
408 vmolr &= ~NGBE_POOLETHCTL_MCHA;
409 wr32(hw, NGBE_POOLETHCTL(vf), vmolr);
413 for (i = 0; i < vfinfo->num_vf_mc_hashes; i++) {
414 mta_idx = (vfinfo->vf_mc_hashes[i] >> NGBE_MTA_BIT_SHIFT)
415 & NGBE_MTA_INDEX_MASK;
416 mta_shift = vfinfo->vf_mc_hashes[i] & NGBE_MTA_BIT_MASK;
417 reg_val = rd32(hw, NGBE_MCADDRTBL(mta_idx));
418 reg_val |= (1 << mta_shift);
419 wr32(hw, NGBE_MCADDRTBL(mta_idx), reg_val);
422 vmolr |= NGBE_POOLETHCTL_MCHA;
423 wr32(hw, NGBE_POOLETHCTL(vf), vmolr);
429 ngbe_vf_set_vlan(struct rte_eth_dev *eth_dev, uint32_t vf, uint32_t *msgbuf)
432 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
433 struct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));
435 add = (msgbuf[0] & NGBE_VT_MSGINFO_MASK)
436 >> NGBE_VT_MSGINFO_SHIFT;
437 vid = NGBE_PSRVLAN_VID(msgbuf[1]);
440 vfinfo[vf].vlan_count++;
441 else if (vfinfo[vf].vlan_count)
442 vfinfo[vf].vlan_count--;
443 return hw->mac.set_vfta(hw, vid, vf, (bool)add, false);
447 ngbe_set_vf_lpe(struct rte_eth_dev *eth_dev,
448 __rte_unused uint32_t vf, uint32_t *msgbuf)
450 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
451 uint32_t max_frame = msgbuf[1];
454 if (max_frame < RTE_ETHER_MIN_LEN ||
455 max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
458 max_frs = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK);
459 if (max_frs < max_frame) {
460 wr32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK,
461 NGBE_FRMSZ_MAX(max_frame));
468 ngbe_negotiate_vf_api(struct rte_eth_dev *eth_dev,
469 uint32_t vf, uint32_t *msgbuf)
471 uint32_t api_version = msgbuf[1];
472 struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);
474 switch (api_version) {
475 case ngbe_mbox_api_10:
476 case ngbe_mbox_api_11:
477 case ngbe_mbox_api_12:
478 case ngbe_mbox_api_13:
479 vfinfo[vf].api_version = (uint8_t)api_version;
485 PMD_DRV_LOG(ERR, "Negotiate invalid api version %u from VF %d\n",
492 ngbe_get_vf_queues(struct rte_eth_dev *eth_dev, uint32_t vf, uint32_t *msgbuf)
494 struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);
495 uint32_t default_q = 0;
497 /* Verify if the PF supports the mbox APIs version or not */
498 switch (vfinfo[vf].api_version) {
499 case ngbe_mbox_api_20:
500 case ngbe_mbox_api_11:
501 case ngbe_mbox_api_12:
502 case ngbe_mbox_api_13:
508 /* Notify VF of Rx and Tx queue number */
509 msgbuf[NGBE_VF_RX_QUEUES] = RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool;
510 msgbuf[NGBE_VF_TX_QUEUES] = RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool;
512 /* Notify VF of default queue */
513 msgbuf[NGBE_VF_DEF_QUEUE] = default_q;
515 msgbuf[NGBE_VF_TRANS_VLAN] = 0;
521 ngbe_set_vf_mc_promisc(struct rte_eth_dev *eth_dev,
522 uint32_t vf, uint32_t *msgbuf)
524 struct ngbe_vf_info *vfinfo = *(NGBE_DEV_VFDATA(eth_dev));
525 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
526 int xcast_mode = msgbuf[1]; /* msgbuf contains the flag to enable */
527 u32 vmolr, fctrl, disable, enable;
529 switch (vfinfo[vf].api_version) {
530 case ngbe_mbox_api_12:
531 /* promisc introduced in 1.3 version */
532 if (xcast_mode == NGBEVF_XCAST_MODE_PROMISC)
536 case ngbe_mbox_api_13:
542 if (vfinfo[vf].xcast_mode == xcast_mode)
545 switch (xcast_mode) {
546 case NGBEVF_XCAST_MODE_NONE:
547 disable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA |
548 NGBE_POOLETHCTL_MCP | NGBE_POOLETHCTL_UCP |
552 case NGBEVF_XCAST_MODE_MULTI:
553 disable = NGBE_POOLETHCTL_MCP | NGBE_POOLETHCTL_UCP |
555 enable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA;
557 case NGBEVF_XCAST_MODE_ALLMULTI:
558 disable = NGBE_POOLETHCTL_UCP | NGBE_POOLETHCTL_VLP;
559 enable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA |
562 case NGBEVF_XCAST_MODE_PROMISC:
563 fctrl = rd32(hw, NGBE_PSRCTL);
564 if (!(fctrl & NGBE_PSRCTL_UCP)) {
565 /* VF promisc requires PF in promisc */
567 "Enabling VF promisc requires PF in promisc\n");
572 enable = NGBE_POOLETHCTL_BCA | NGBE_POOLETHCTL_MCHA |
573 NGBE_POOLETHCTL_MCP | NGBE_POOLETHCTL_UCP |
580 vmolr = rd32(hw, NGBE_POOLETHCTL(vf));
583 wr32(hw, NGBE_POOLETHCTL(vf), vmolr);
584 vfinfo[vf].xcast_mode = xcast_mode;
587 msgbuf[1] = xcast_mode;
593 ngbe_set_vf_macvlan_msg(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
595 struct ngbe_hw *hw = ngbe_dev_hw(dev);
596 struct ngbe_vf_info *vf_info = *(NGBE_DEV_VFDATA(dev));
597 uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
598 struct rte_ether_addr *ea = (struct rte_ether_addr *)new_mac;
599 int index = (msgbuf[0] & NGBE_VT_MSGINFO_MASK) >>
600 NGBE_VT_MSGINFO_SHIFT;
603 if (!rte_is_valid_assigned_ether_addr(ea)) {
604 PMD_DRV_LOG(ERR, "set invalid mac vf:%d\n", vf);
608 vf_info[vf].mac_count++;
610 hw->mac.set_rar(hw, vf_info[vf].mac_count,
613 if (vf_info[vf].mac_count) {
614 hw->mac.clear_rar(hw, vf_info[vf].mac_count);
615 vf_info[vf].mac_count = 0;
622 ngbe_rcv_msg_from_vf(struct rte_eth_dev *eth_dev, uint16_t vf)
624 uint16_t mbx_size = NGBE_P2VMBX_SIZE;
625 uint16_t msg_size = NGBE_VF_MSG_SIZE_DEFAULT;
626 uint32_t msgbuf[NGBE_P2VMBX_SIZE];
628 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
629 struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);
630 struct ngbe_mb_event_param ret_param;
632 retval = ngbe_read_mbx(hw, msgbuf, mbx_size, vf);
634 PMD_DRV_LOG(ERR, "Error mbx recv msg from VF %d", vf);
638 /* do nothing with the message already been processed */
639 if (msgbuf[0] & (NGBE_VT_MSGTYPE_ACK | NGBE_VT_MSGTYPE_NACK))
642 /* flush the ack before we write any messages back */
646 * initialise structure to send to user application
647 * will return response from user in retval field
649 ret_param.retval = NGBE_MB_EVENT_PROCEED;
651 ret_param.msg_type = msgbuf[0] & 0xFFFF;
652 ret_param.msg = (void *)msgbuf;
654 /* perform VF reset */
655 if (msgbuf[0] == NGBE_VF_RESET) {
656 int ret = ngbe_vf_reset(eth_dev, vf, msgbuf);
658 vfinfo[vf].clear_to_send = true;
660 /* notify application about VF reset */
661 rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_VF_MBOX,
667 * ask user application if we allowed to perform those functions
668 * if we get ret_param.retval == RTE_PMD_COMPAT_MB_EVENT_PROCEED
669 * then business as usual,
670 * if 0, do nothing and send ACK to VF
671 * if ret_param.retval > 1, do nothing and send NAK to VF
673 rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_VF_MBOX,
676 retval = ret_param.retval;
678 /* check & process VF to PF mailbox message */
679 switch ((msgbuf[0] & 0xFFFF)) {
680 case NGBE_VF_SET_MAC_ADDR:
681 if (retval == NGBE_MB_EVENT_PROCEED)
682 retval = ngbe_vf_set_mac_addr(eth_dev, vf, msgbuf);
684 case NGBE_VF_SET_MULTICAST:
685 if (retval == NGBE_MB_EVENT_PROCEED)
686 retval = ngbe_vf_set_multicast(eth_dev, vf, msgbuf);
688 case NGBE_VF_SET_LPE:
689 if (retval == NGBE_MB_EVENT_PROCEED)
690 retval = ngbe_set_vf_lpe(eth_dev, vf, msgbuf);
692 case NGBE_VF_SET_VLAN:
693 if (retval == NGBE_MB_EVENT_PROCEED)
694 retval = ngbe_vf_set_vlan(eth_dev, vf, msgbuf);
696 case NGBE_VF_API_NEGOTIATE:
697 retval = ngbe_negotiate_vf_api(eth_dev, vf, msgbuf);
699 case NGBE_VF_GET_QUEUES:
700 retval = ngbe_get_vf_queues(eth_dev, vf, msgbuf);
701 msg_size = NGBE_VF_GET_QUEUE_MSG_SIZE;
703 case NGBE_VF_UPDATE_XCAST_MODE:
704 if (retval == NGBE_MB_EVENT_PROCEED)
705 retval = ngbe_set_vf_mc_promisc(eth_dev, vf, msgbuf);
707 case NGBE_VF_SET_MACVLAN:
708 if (retval == NGBE_MB_EVENT_PROCEED)
709 retval = ngbe_set_vf_macvlan_msg(eth_dev, vf, msgbuf);
712 PMD_DRV_LOG(DEBUG, "Unhandled Msg %8.8x", (uint32_t)msgbuf[0]);
713 retval = NGBE_ERR_MBX;
717 /* response the VF according to the message process result */
719 msgbuf[0] |= NGBE_VT_MSGTYPE_NACK;
721 msgbuf[0] |= NGBE_VT_MSGTYPE_ACK;
723 msgbuf[0] |= NGBE_VT_MSGTYPE_CTS;
725 ngbe_write_mbx(hw, msgbuf, msg_size, vf);
731 ngbe_rcv_ack_from_vf(struct rte_eth_dev *eth_dev, uint16_t vf)
733 uint32_t msg = NGBE_VT_MSGTYPE_NACK;
734 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
735 struct ngbe_vf_info *vfinfo = *NGBE_DEV_VFDATA(eth_dev);
737 if (!vfinfo[vf].clear_to_send)
738 ngbe_write_mbx(hw, &msg, 1, vf);
741 void ngbe_pf_mbx_process(struct rte_eth_dev *eth_dev)
744 struct ngbe_hw *hw = ngbe_dev_hw(eth_dev);
746 for (vf = 0; vf < dev_num_vf(eth_dev); vf++) {
747 /* check & process vf function level reset */
748 if (!ngbe_check_for_rst(hw, vf))
749 ngbe_vf_reset_event(eth_dev, vf);
751 /* check & process vf mailbox messages */
752 if (!ngbe_check_for_msg(hw, vf))
753 ngbe_rcv_msg_from_vf(eth_dev, vf);
755 /* check & process acks from vf */
756 if (!ngbe_check_for_ack(hw, vf))
757 ngbe_rcv_ack_from_vf(eth_dev, vf);