4 * Copyright(c) 2017 Broadcom Limited.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Broadcom Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_ethdev.h>
39 #include <rte_malloc.h>
40 #include <rte_cycles.h>
41 #include <rte_byteorder.h>
44 #include "bnxt_filter.h"
45 #include "bnxt_hwrm.h"
46 #include "bnxt_vnic.h"
47 #include "rte_pmd_bnxt.h"
48 #include "hsi_struct_def_dpdk.h"
50 int rte_pmd_bnxt_set_tx_loopback(uint8_t port, uint8_t on)
52 struct rte_eth_dev *eth_dev;
56 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
61 eth_dev = &rte_eth_devices[port];
62 if (!is_bnxt_supported(eth_dev))
65 bp = (struct bnxt *)eth_dev->data->dev_private;
69 "Attempt to set Tx loopback on non-PF port %d!\n",
75 bp->pf.evb_mode = BNXT_EVB_MODE_VEB;
77 bp->pf.evb_mode = BNXT_EVB_MODE_VEPA;
79 rc = bnxt_hwrm_pf_evb_mode(bp);
85 rte_pmd_bnxt_set_all_queues_drop_en_cb(struct bnxt_vnic_info *vnic, void *onptr)
88 vnic->bd_stall = !(*on);
91 int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on)
93 struct rte_eth_dev *eth_dev;
98 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
103 eth_dev = &rte_eth_devices[port];
104 if (!is_bnxt_supported(eth_dev))
107 bp = (struct bnxt *)eth_dev->data->dev_private;
111 "Attempt to set all queues drop on non-PF port!\n");
115 if (bp->vnic_info == NULL)
119 for (i = 0; i < bp->nr_vnics; i++) {
120 bp->vnic_info[i].bd_stall = !on;
121 rc = bnxt_hwrm_vnic_cfg(bp, &bp->vnic_info[i]);
123 RTE_LOG(ERR, PMD, "Failed to update PF VNIC %d.\n", i);
128 /* Stall all active VFs */
129 for (i = 0; i < bp->pf.active_vfs; i++) {
130 rc = bnxt_hwrm_func_vf_vnic_query_and_config(bp, i,
131 rte_pmd_bnxt_set_all_queues_drop_en_cb, &on,
134 RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", i);
142 int rte_pmd_bnxt_set_vf_mac_addr(uint8_t port, uint16_t vf,
143 struct ether_addr *mac_addr)
145 struct rte_eth_dev *dev;
146 struct rte_eth_dev_info dev_info;
150 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
152 dev = &rte_eth_devices[port];
153 if (!is_bnxt_supported(dev))
156 rte_eth_dev_info_get(port, &dev_info);
157 bp = (struct bnxt *)dev->data->dev_private;
159 if (vf >= dev_info.max_vfs || mac_addr == NULL)
164 "Attempt to set VF %d mac address on non-PF port %d!\n",
169 rc = bnxt_hwrm_func_vf_mac(bp, vf, (uint8_t *)mac_addr);