X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Frte_pmd_bnxt.c;h=77ecbef04c3da50d81dd07b0d9546ace435c23fd;hb=295968d1740760337e16b0d7914875c5cac52850;hp=82b9baca67f841231a90a10bced8023c7db7c88a;hpb=5ef3b79fdfe6f16289d6cd3cee0c9a68bb85c606;p=dpdk.git diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c index 82b9baca67..77ecbef04c 100644 --- a/drivers/net/bnxt/rte_pmd_bnxt.c +++ b/drivers/net/bnxt/rte_pmd_bnxt.c @@ -1,34 +1,6 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2017 Broadcom Limited. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Broadcom Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017-2021 Broadcom + * All rights reserved. */ #include @@ -36,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -56,8 +28,8 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg) ret_param.vf_id = vf_id; ret_param.msg = msg; - _rte_eth_dev_callback_process(bp->eth_dev, RTE_ETH_EVENT_VF_MBOX, - NULL, &ret_param); + rte_eth_dev_callback_process(bp->eth_dev, RTE_ETH_EVENT_VF_MBOX, + &ret_param); /* Default to approve */ if (ret_param.retval == RTE_PMD_BNXT_MB_EVENT_PROCEED) @@ -67,7 +39,7 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg) true : false; } -int rte_pmd_bnxt_set_tx_loopback(uint8_t port, uint8_t on) +int rte_pmd_bnxt_set_tx_loopback(uint16_t port, uint8_t on) { struct rte_eth_dev *eth_dev; struct bnxt *bp; @@ -82,19 +54,19 @@ int rte_pmd_bnxt_set_tx_loopback(uint8_t port, uint8_t on) if (!is_bnxt_supported(eth_dev)) return -ENOTSUP; - bp = (struct bnxt *)eth_dev->data->dev_private; + bp = eth_dev->data->dev_private; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set Tx loopback on non-PF port %d!\n", port); return -ENOTSUP; } if (on) - bp->pf.evb_mode = BNXT_EVB_MODE_VEB; + bp->pf->evb_mode = BNXT_EVB_MODE_VEB; else - bp->pf.evb_mode = BNXT_EVB_MODE_VEPA; + bp->pf->evb_mode = BNXT_EVB_MODE_VEPA; rc = bnxt_hwrm_pf_evb_mode(bp); @@ -108,12 +80,12 @@ rte_pmd_bnxt_set_all_queues_drop_en_cb(struct bnxt_vnic_info *vnic, void *onptr) vnic->bd_stall = !(*on); } -int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on) +int rte_pmd_bnxt_set_all_queues_drop_en(uint16_t port, uint8_t on) { struct rte_eth_dev *eth_dev; struct bnxt *bp; uint32_t i; - int rc; + int rc = -EINVAL; RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); @@ -124,10 +96,10 @@ int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on) if (!is_bnxt_supported(eth_dev)) return -ENOTSUP; - bp = (struct bnxt *)eth_dev->data->dev_private; + bp = eth_dev->data->dev_private; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set all queues drop on non-PF port!\n"); return -ENOTSUP; } @@ -140,18 +112,18 @@ int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on) bp->vnic_info[i].bd_stall = !on; rc = bnxt_hwrm_vnic_cfg(bp, &bp->vnic_info[i]); if (rc) { - RTE_LOG(ERR, PMD, "Failed to update PF VNIC %d.\n", i); + PMD_DRV_LOG(ERR, "Failed to update PF VNIC %d.\n", i); return rc; } } /* Stall all active VFs */ - for (i = 0; i < bp->pf.active_vfs; i++) { + for (i = 0; i < bp->pf->active_vfs; i++) { rc = bnxt_hwrm_func_vf_vnic_query_and_config(bp, i, rte_pmd_bnxt_set_all_queues_drop_en_cb, &on, bnxt_hwrm_vnic_cfg); if (rc) { - RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", i); + PMD_DRV_LOG(ERR, "Failed to update VF VNIC %d.\n", i); break; } } @@ -159,8 +131,8 @@ int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on) return rc; } -int rte_pmd_bnxt_set_vf_mac_addr(uint8_t port, uint16_t vf, - struct ether_addr *mac_addr) +int rte_pmd_bnxt_set_vf_mac_addr(uint16_t port, uint16_t vf, + struct rte_ether_addr *mac_addr) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; @@ -173,14 +145,22 @@ int rte_pmd_bnxt_set_vf_mac_addr(uint8_t port, uint16_t vf, if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + + bp = dev->data->dev_private; if (vf >= dev_info.max_vfs || mac_addr == NULL) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set VF %d mac address on non-PF port %d!\n", vf, port); return -ENOTSUP; @@ -191,7 +171,7 @@ int rte_pmd_bnxt_set_vf_mac_addr(uint8_t port, uint16_t vf, return rc; } -int rte_pmd_bnxt_set_vf_rate_limit(uint8_t port, uint16_t vf, +int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf, uint16_t tx_rate, uint64_t q_msk) { struct rte_eth_dev *eth_dev; @@ -207,13 +187,20 @@ int rte_pmd_bnxt_set_vf_rate_limit(uint8_t port, uint16_t vf, if (!is_bnxt_supported(eth_dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)eth_dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); - if (!bp->pf.active_vfs) + return rc; + } + bp = eth_dev->data->dev_private; + + if (!bp->pf->active_vfs) return -EINVAL; - if (vf >= bp->pf.max_vfs) + if (vf >= bp->pf->max_vfs) return -EINVAL; /* Add up the per queue BW and configure MAX BW of the VF */ @@ -224,24 +211,24 @@ int rte_pmd_bnxt_set_vf_rate_limit(uint8_t port, uint16_t vf, /* Requested BW can't be greater than link speed */ if (tot_rate > eth_dev->data->dev_link.link_speed) { - RTE_LOG(ERR, PMD, "Rate > Link speed. Set to %d\n", tot_rate); + PMD_DRV_LOG(ERR, "Rate > Link speed. Set to %d\n", tot_rate); return -EINVAL; } /* Requested BW already configured */ - if (tot_rate == bp->pf.vf_info[vf].max_tx_rate) + if (tot_rate == bp->pf->vf_info[vf].max_tx_rate) return 0; rc = bnxt_hwrm_func_bw_cfg(bp, vf, tot_rate, HWRM_FUNC_CFG_INPUT_ENABLES_MAX_BW); if (!rc) - bp->pf.vf_info[vf].max_tx_rate = tot_rate; + bp->pf->vf_info[vf].max_tx_rate = tot_rate; return rc; } -int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) +int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev_info dev_info; struct rte_eth_dev *dev; @@ -258,11 +245,18 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set mac spoof on non-PF port %d!\n", port); return -EINVAL; } @@ -271,10 +265,10 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) return -EINVAL; /* Prev setting same as new setting. */ - if (on == bp->pf.vf_info[vf].mac_spoof_en) + if (on == bp->pf->vf_info[vf].mac_spoof_en) return 0; - func_flags = bp->pf.vf_info[vf].func_cfg_flags; + func_flags = bp->pf->vf_info[vf].func_cfg_flags; func_flags &= ~(HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_ENABLE | HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_DISABLE); @@ -287,14 +281,14 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) rc = bnxt_hwrm_func_cfg_vf_set_flags(bp, vf, func_flags); if (!rc) { - bp->pf.vf_info[vf].mac_spoof_en = on; - bp->pf.vf_info[vf].func_cfg_flags = func_flags; + bp->pf->vf_info[vf].mac_spoof_en = on; + bp->pf->vf_info[vf].func_cfg_flags = func_flags; } return rc; } -int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) +int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev_info dev_info; struct rte_eth_dev *dev; @@ -310,11 +304,18 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set VLAN spoof on non-PF port %d!\n", port); return -EINVAL; } @@ -322,21 +323,18 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) if (vf >= dev_info.max_vfs) return -EINVAL; - if (on == bp->pf.vf_info[vf].vlan_spoof_en) - return 0; - rc = bnxt_hwrm_func_cfg_vf_set_vlan_anti_spoof(bp, vf, on); if (!rc) { - bp->pf.vf_info[vf].vlan_spoof_en = on; + bp->pf->vf_info[vf].vlan_spoof_en = on; if (on) { if (bnxt_hwrm_cfa_vlan_antispoof_cfg(bp, - bp->pf.first_vf_id + vf, - bp->pf.vf_info[vf].vlan_count, - bp->pf.vf_info[vf].vlan_as_table)) + bp->pf->first_vf_id + vf, + bp->pf->vf_info[vf].vlan_count, + bp->pf->vf_info[vf].vlan_as_table)) rc = -1; } } else { - RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", vf); + PMD_DRV_LOG(ERR, "Failed to update VF VNIC %d.\n", vf); } return rc; @@ -350,7 +348,7 @@ rte_pmd_bnxt_set_vf_vlan_stripq_cb(struct bnxt_vnic_info *vnic, void *onptr) } int -rte_pmd_bnxt_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on) +rte_pmd_bnxt_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; @@ -363,14 +361,21 @@ rte_pmd_bnxt_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on) if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set VF %d stripq on non-PF port %d!\n", vf, port); return -ENOTSUP; @@ -380,12 +385,12 @@ rte_pmd_bnxt_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on) rte_pmd_bnxt_set_vf_vlan_stripq_cb, &on, bnxt_hwrm_vnic_cfg); if (rc) - RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", vf); + PMD_DRV_LOG(ERR, "Failed to update VF VNIC %d.\n", vf); return rc; } -int rte_pmd_bnxt_set_vf_rxmode(uint8_t port, uint16_t vf, +int rte_pmd_bnxt_set_vf_rxmode(uint16_t port, uint16_t vf, uint16_t rx_mask, uint8_t on) { struct rte_eth_dev *dev; @@ -400,40 +405,47 @@ int rte_pmd_bnxt_set_vf_rxmode(uint8_t port, uint16_t vf, if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; - if (!bp->pf.vf_info) + if (!bp->pf->vf_info) return -EINVAL; if (vf >= bp->pdev->max_vfs) return -EINVAL; - if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG) { - RTE_LOG(ERR, PMD, "Currently cannot toggle this setting\n"); + if (rx_mask & RTE_ETH_VMDQ_ACCEPT_UNTAG) { + PMD_DRV_LOG(ERR, "Currently cannot toggle this setting\n"); return -ENOTSUP; } /* Is this really the correct mapping? VFd seems to think it is. */ - if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC) + if (rx_mask & RTE_ETH_VMDQ_ACCEPT_HASH_UC) flag |= BNXT_VNIC_INFO_PROMISC; - if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST) + if (rx_mask & RTE_ETH_VMDQ_ACCEPT_BROADCAST) flag |= BNXT_VNIC_INFO_BCAST; - if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST) + if (rx_mask & RTE_ETH_VMDQ_ACCEPT_MULTICAST) flag |= BNXT_VNIC_INFO_ALLMULTI | BNXT_VNIC_INFO_MCAST; if (on) - bp->pf.vf_info[vf].l2_rx_mask |= flag; + bp->pf->vf_info[vf].l2_rx_mask |= flag; else - bp->pf.vf_info[vf].l2_rx_mask &= ~flag; + bp->pf->vf_info[vf].l2_rx_mask &= ~flag; rc = bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf, vf_vnic_set_rxmask_cb, - &bp->pf.vf_info[vf].l2_rx_mask, + &bp->pf->vf_info[vf].l2_rx_mask, bnxt_set_rx_mask_no_vlan); if (rc) - RTE_LOG(ERR, PMD, "bnxt_hwrm_func_vf_vnic_set_rxmask failed\n"); + PMD_DRV_LOG(ERR, "bnxt_hwrm_func_vf_vnic_set_rxmask failed\n"); return rc; } @@ -445,7 +457,7 @@ static int bnxt_set_vf_table(struct bnxt *bp, uint16_t vf) struct bnxt_vnic_info vnic; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set VLAN table on non-PF port!\n"); return -EINVAL; } @@ -458,15 +470,15 @@ static int bnxt_set_vf_table(struct bnxt *bp, uint16_t vf) /* This simply indicates there's no driver loaded. * This is not an error. */ - RTE_LOG(ERR, PMD, "Unable to get default VNIC for VF %d\n", vf); + PMD_DRV_LOG(ERR, "Unable to get default VNIC for VF %d\n", vf); } else { memset(&vnic, 0, sizeof(vnic)); vnic.fw_vnic_id = dflt_vnic; if (bnxt_hwrm_vnic_qcfg(bp, &vnic, - bp->pf.first_vf_id + vf) == 0) { + bp->pf->first_vf_id + vf) == 0) { if (bnxt_hwrm_cfa_l2_set_rx_mask(bp, &vnic, - bp->pf.vf_info[vf].vlan_count, - bp->pf.vf_info[vf].vlan_table)) + bp->pf->vf_info[vf].vlan_count, + bp->pf->vf_info[vf].vlan_table)) rc = -1; } else { rc = -1; @@ -476,7 +488,7 @@ static int bnxt_set_vf_table(struct bnxt *bp, uint16_t vf) return rc; } -int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan, +int rte_pmd_bnxt_set_vf_vlan_filter(uint16_t port, uint16_t vlan, uint64_t vf_mask, uint8_t vlan_on) { struct bnxt_vlan_table_entry *ve; @@ -493,20 +505,20 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan, if (!is_bnxt_supported(dev)) return -ENOTSUP; - bp = (struct bnxt *)dev->data->dev_private; - if (!bp->pf.vf_info) + bp = dev->data->dev_private; + if (!bp->pf->vf_info) return -EINVAL; for (i = 0; vf_mask; i++, vf_mask >>= 1) { - cnt = bp->pf.vf_info[i].vlan_count; + cnt = bp->pf->vf_info[i].vlan_count; if ((vf_mask & 1) == 0) continue; - if (bp->pf.vf_info[i].vlan_table == NULL) { + if (bp->pf->vf_info[i].vlan_table == NULL) { rc = -1; continue; } - if (bp->pf.vf_info[i].vlan_as_table == NULL) { + if (bp->pf->vf_info[i].vlan_as_table == NULL) { rc = -1; continue; } @@ -514,16 +526,17 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan, /* First, search for a duplicate... */ for (j = 0; j < cnt; j++) { if (rte_be_to_cpu_16( - bp->pf.vf_info[i].vlan_table[j].vid) == vlan) + bp->pf->vf_info[i].vlan_table[j].vid) == + vlan) break; } if (j == cnt) { /* Now check that there's space */ if (cnt == getpagesize() / sizeof(struct bnxt_vlan_antispoof_table_entry)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "VLAN anti-spoof table is full\n"); - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "VF %d cannot add VLAN %u\n", i, vlan); rc = -1; @@ -531,17 +544,17 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan, } /* cnt is one less than vlan_count */ - cnt = bp->pf.vf_info[i].vlan_count++; + cnt = bp->pf->vf_info[i].vlan_count++; /* * And finally, add to the * end of the table */ - vase = &bp->pf.vf_info[i].vlan_as_table[cnt]; + vase = &bp->pf->vf_info[i].vlan_as_table[cnt]; // TODO: Hardcoded TPID vase->tpid = rte_cpu_to_be_16(0x8100); vase->vid = rte_cpu_to_be_16(vlan); vase->mask = rte_cpu_to_be_16(0xfff); - ve = &bp->pf.vf_info[i].vlan_table[cnt]; + ve = &bp->pf->vf_info[i].vlan_table[cnt]; /* TODO: Hardcoded TPID */ ve->tpid = rte_cpu_to_be_16(0x8100); ve->vid = rte_cpu_to_be_16(vlan); @@ -549,18 +562,19 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan, } else { for (j = 0; j < cnt; j++) { if (rte_be_to_cpu_16( - bp->pf.vf_info[i].vlan_table[j].vid) != vlan) + bp->pf->vf_info[i].vlan_table[j].vid) != + vlan) continue; - memmove(&bp->pf.vf_info[i].vlan_table[j], - &bp->pf.vf_info[i].vlan_table[j + 1], + memmove(&bp->pf->vf_info[i].vlan_table[j], + &bp->pf->vf_info[i].vlan_table[j + 1], getpagesize() - ((j + 1) * sizeof(struct bnxt_vlan_table_entry))); - memmove(&bp->pf.vf_info[i].vlan_as_table[j], - &bp->pf.vf_info[i].vlan_as_table[j + 1], + memmove(&bp->pf->vf_info[i].vlan_as_table[j], + &bp->pf->vf_info[i].vlan_as_table[j + 1], getpagesize() - ((j + 1) * sizeof(struct bnxt_vlan_antispoof_table_entry))); j--; - cnt = --bp->pf.vf_info[i].vlan_count; + cnt = --bp->pf->vf_info[i].vlan_count; } } bnxt_set_vf_table(bp, i); @@ -569,79 +583,104 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan, return rc; } -int rte_pmd_bnxt_get_vf_stats(uint8_t port, +int rte_pmd_bnxt_get_vf_stats(uint16_t port, uint16_t vf_id, struct rte_eth_stats *stats) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct bnxt *bp; + int rc; dev = &rte_eth_devices[port]; if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf_id >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to get VF %d stats on non-PF port %d!\n", vf_id, port); return -ENOTSUP; } - return bnxt_hwrm_func_qstats(bp, bp->pf.first_vf_id + vf_id, stats); + return bnxt_hwrm_func_qstats(bp, bp->pf->first_vf_id + vf_id, stats, + NULL); } -int rte_pmd_bnxt_reset_vf_stats(uint8_t port, +int rte_pmd_bnxt_reset_vf_stats(uint16_t port, uint16_t vf_id) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct bnxt *bp; + int rc; dev = &rte_eth_devices[port]; if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf_id >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to reset VF %d stats on non-PF port %d!\n", vf_id, port); return -ENOTSUP; } - return bnxt_hwrm_func_clr_stats(bp, bp->pf.first_vf_id + vf_id); + return bnxt_hwrm_func_clr_stats(bp, bp->pf->first_vf_id + vf_id); } -int rte_pmd_bnxt_get_vf_rx_status(uint8_t port, uint16_t vf_id) +int rte_pmd_bnxt_get_vf_rx_status(uint16_t port, uint16_t vf_id) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct bnxt *bp; + int rc; dev = &rte_eth_devices[port]; if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf_id >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to query VF %d RX stats on non-PF port %d!\n", vf_id, port); return -ENOTSUP; @@ -650,35 +689,43 @@ int rte_pmd_bnxt_get_vf_rx_status(uint8_t port, uint16_t vf_id) return bnxt_vf_vnic_count(bp, vf_id); } -int rte_pmd_bnxt_get_vf_tx_drop_count(uint8_t port, uint16_t vf_id, +int rte_pmd_bnxt_get_vf_tx_drop_count(uint16_t port, uint16_t vf_id, uint64_t *count) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct bnxt *bp; + int rc; dev = &rte_eth_devices[port]; if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf_id >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to query VF %d TX drops on non-PF port %d!\n", vf_id, port); return -ENOTSUP; } - return bnxt_hwrm_func_qstats_tx_drop(bp, bp->pf.first_vf_id + vf_id, + return bnxt_hwrm_func_qstats_tx_drop(bp, bp->pf->first_vf_id + vf_id, count); } -int rte_pmd_bnxt_mac_addr_add(uint8_t port, struct ether_addr *addr, +int rte_pmd_bnxt_mac_addr_add(uint16_t port, struct rte_ether_addr *addr, uint32_t vf_id) { struct rte_eth_dev *dev; @@ -686,30 +733,37 @@ int rte_pmd_bnxt_mac_addr_add(uint8_t port, struct ether_addr *addr, struct bnxt *bp; struct bnxt_filter_info *filter; struct bnxt_vnic_info vnic; - struct ether_addr dflt_mac; + struct rte_ether_addr dflt_mac; int rc; dev = &rte_eth_devices[port]; if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf_id >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to config VF %d MAC on non-PF port %d!\n", vf_id, port); return -ENOTSUP; } /* If the VF currently uses a random MAC, update default to this one */ - if (bp->pf.vf_info[vf_id].random_mac) { + if (bp->pf->vf_info[vf_id].random_mac) { if (rte_pmd_bnxt_get_vf_rx_status(port, vf_id) <= 0) - rc = bnxt_hwrm_func_vf_mac(bp, vf_id, (uint8_t *)addr); + bnxt_hwrm_func_vf_mac(bp, vf_id, (uint8_t *)addr); } /* query the default VNIC id used by the function */ @@ -719,17 +773,17 @@ int rte_pmd_bnxt_mac_addr_add(uint8_t port, struct ether_addr *addr, memset(&vnic, 0, sizeof(struct bnxt_vnic_info)); vnic.fw_vnic_id = rte_le_to_cpu_16(rc); - rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf.first_vf_id + vf_id); + rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf_id); if (rc < 0) goto exit; - STAILQ_FOREACH(filter, &bp->pf.vf_info[vf_id].filter, next) { + STAILQ_FOREACH(filter, &bp->pf->vf_info[vf_id].filter, next) { if (filter->flags == HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX && filter->enables == (HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK) && - memcmp(addr, filter->l2_addr, ETHER_ADDR_LEN) == 0) { + memcmp(addr, filter->l2_addr, RTE_ETHER_ADDR_LEN) == 0) { bnxt_hwrm_clear_l2_filter(bp, filter); break; } @@ -742,12 +796,12 @@ int rte_pmd_bnxt_mac_addr_add(uint8_t port, struct ether_addr *addr, filter->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX; filter->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK; - memcpy(filter->l2_addr, addr, ETHER_ADDR_LEN); - memset(filter->l2_addr_mask, 0xff, ETHER_ADDR_LEN); + memcpy(filter->l2_addr, addr, RTE_ETHER_ADDR_LEN); + memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN); /* Do not add a filter for the default MAC */ if (bnxt_hwrm_func_qcfg_vf_default_mac(bp, vf_id, &dflt_mac) || - memcmp(filter->l2_addr, dflt_mac.addr_bytes, ETHER_ADDR_LEN)) + memcmp(filter->l2_addr, dflt_mac.addr_bytes, RTE_ETHER_ADDR_LEN)) rc = bnxt_hwrm_set_l2_filter(bp, vnic.fw_vnic_id, filter); exit: @@ -755,7 +809,7 @@ exit: } int -rte_pmd_bnxt_set_vf_vlan_insert(uint8_t port, uint16_t vf, +rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf, uint16_t vlan_id) { struct rte_eth_dev *dev; @@ -769,22 +823,29 @@ rte_pmd_bnxt_set_vf_vlan_insert(uint8_t port, uint16_t vf, if (!is_bnxt_supported(dev)) return -ENOTSUP; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (vf >= dev_info.max_vfs) return -EINVAL; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set VF %d vlan insert on non-PF port %d!\n", vf, port); return -ENOTSUP; } - bp->pf.vf_info[vf].dflt_vlan = vlan_id; + bp->pf->vf_info[vf].dflt_vlan = vlan_id; if (bnxt_hwrm_func_qcfg_current_vf_vlan(bp, vf) == - bp->pf.vf_info[vf].dflt_vlan) + bp->pf->vf_info[vf].dflt_vlan) return 0; rc = bnxt_hwrm_set_vf_vlan(bp, vf); @@ -792,7 +853,7 @@ rte_pmd_bnxt_set_vf_vlan_insert(uint8_t port, uint16_t vf, return rc; } -int rte_pmd_bnxt_set_vf_persist_stats(uint8_t port, uint16_t vf, uint8_t on) +int rte_pmd_bnxt_set_vf_persist_stats(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev_info dev_info; struct rte_eth_dev *dev; @@ -806,11 +867,18 @@ int rte_pmd_bnxt_set_vf_persist_stats(uint8_t port, uint16_t vf, uint8_t on) return -EINVAL; dev = &rte_eth_devices[port]; - rte_eth_dev_info_get(port, &dev_info); - bp = (struct bnxt *)dev->data->dev_private; + rc = rte_eth_dev_info_get(port, &dev_info); + if (rc != 0) { + PMD_DRV_LOG(ERR, + "Error during getting device (port %u) info: %s\n", + port, strerror(-rc)); + + return rc; + } + bp = dev->data->dev_private; if (!BNXT_PF(bp)) { - RTE_LOG(ERR, PMD, + PMD_DRV_LOG(ERR, "Attempt to set persist stats on non-PF port %d!\n", port); return -EINVAL; @@ -820,10 +888,10 @@ int rte_pmd_bnxt_set_vf_persist_stats(uint8_t port, uint16_t vf, uint8_t on) return -EINVAL; /* Prev setting same as new setting. */ - if (on == bp->pf.vf_info[vf].persist_stats) + if (on == bp->pf->vf_info[vf].persist_stats) return 0; - func_flags = bp->pf.vf_info[vf].func_cfg_flags; + func_flags = bp->pf->vf_info[vf].func_cfg_flags; if (on) func_flags |= @@ -834,8 +902,8 @@ int rte_pmd_bnxt_set_vf_persist_stats(uint8_t port, uint16_t vf, uint8_t on) rc = bnxt_hwrm_func_cfg_vf_set_flags(bp, vf, func_flags); if (!rc) { - bp->pf.vf_info[vf].persist_stats = on; - bp->pf.vf_info[vf].func_cfg_flags = func_flags; + bp->pf->vf_info[vf].persist_stats = on; + bp->pf->vf_info[vf].func_cfg_flags = func_flags; } return rc;