2018-04-02 22:34:32 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2017-2018 Broadcom
|
|
|
|
* All rights reserved.
|
2017-06-01 17:07:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdbool.h>
|
2017-06-01 17:07:17 +00:00
|
|
|
#include <unistd.h>
|
2017-06-01 17:07:16 +00:00
|
|
|
|
|
|
|
#include <rte_dev.h>
|
2018-01-22 00:16:22 +00:00
|
|
|
#include <rte_ethdev_driver.h>
|
2017-06-01 17:07:16 +00:00
|
|
|
#include <rte_malloc.h>
|
|
|
|
#include <rte_cycles.h>
|
|
|
|
#include <rte_byteorder.h>
|
|
|
|
|
|
|
|
#include "bnxt.h"
|
|
|
|
#include "bnxt_filter.h"
|
|
|
|
#include "bnxt_hwrm.h"
|
|
|
|
#include "bnxt_vnic.h"
|
|
|
|
#include "rte_pmd_bnxt.h"
|
|
|
|
#include "hsi_struct_def_dpdk.h"
|
|
|
|
|
2017-06-09 04:24:46 +00:00
|
|
|
int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg)
|
|
|
|
{
|
2017-07-31 16:24:23 +00:00
|
|
|
struct rte_pmd_bnxt_mb_event_param ret_param;
|
2017-06-09 04:24:46 +00:00
|
|
|
|
2017-07-31 16:24:23 +00:00
|
|
|
ret_param.retval = RTE_PMD_BNXT_MB_EVENT_PROCEED;
|
|
|
|
ret_param.vf_id = vf_id;
|
|
|
|
ret_param.msg = msg;
|
2017-06-09 04:24:46 +00:00
|
|
|
|
|
|
|
_rte_eth_dev_callback_process(bp->eth_dev, RTE_ETH_EVENT_VF_MBOX,
|
2018-01-04 16:01:08 +00:00
|
|
|
&ret_param);
|
2017-06-09 04:24:46 +00:00
|
|
|
|
|
|
|
/* Default to approve */
|
2017-07-31 16:24:23 +00:00
|
|
|
if (ret_param.retval == RTE_PMD_BNXT_MB_EVENT_PROCEED)
|
|
|
|
ret_param.retval = RTE_PMD_BNXT_MB_EVENT_NOOP_ACK;
|
2017-06-09 04:24:46 +00:00
|
|
|
|
2017-07-31 16:24:23 +00:00
|
|
|
return ret_param.retval == RTE_PMD_BNXT_MB_EVENT_NOOP_ACK ?
|
|
|
|
true : false;
|
2017-06-09 04:24:46 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_tx_loopback(uint16_t port, uint8_t on)
|
2017-06-01 17:07:16 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
if (on > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
eth_dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(eth_dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = eth_dev->data->dev_private;
|
2017-06-01 17:07:16 +00:00
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:16 +00:00
|
|
|
"Attempt to set Tx loopback on non-PF port %d!\n",
|
|
|
|
port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (on)
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->evb_mode = BNXT_EVB_MODE_VEB;
|
2017-06-01 17:07:16 +00:00
|
|
|
else
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->evb_mode = BNXT_EVB_MODE_VEPA;
|
2017-06-01 17:07:16 +00:00
|
|
|
|
|
|
|
rc = bnxt_hwrm_pf_evb_mode(bp);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rte_pmd_bnxt_set_all_queues_drop_en_cb(struct bnxt_vnic_info *vnic, void *onptr)
|
|
|
|
{
|
|
|
|
uint8_t *on = onptr;
|
|
|
|
vnic->bd_stall = !(*on);
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_all_queues_drop_en(uint16_t port, uint8_t on)
|
2017-06-01 17:07:16 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
struct bnxt *bp;
|
|
|
|
uint32_t i;
|
2017-09-11 15:13:24 +00:00
|
|
|
int rc = -EINVAL;
|
2017-06-01 17:07:16 +00:00
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
if (on > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
eth_dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(eth_dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = eth_dev->data->dev_private;
|
2017-06-01 17:07:16 +00:00
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:16 +00:00
|
|
|
"Attempt to set all queues drop on non-PF port!\n");
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bp->vnic_info == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* Stall PF */
|
|
|
|
for (i = 0; i < bp->nr_vnics; i++) {
|
|
|
|
bp->vnic_info[i].bd_stall = !on;
|
|
|
|
rc = bnxt_hwrm_vnic_cfg(bp, &bp->vnic_info[i]);
|
|
|
|
if (rc) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Failed to update PF VNIC %d.\n", i);
|
2017-06-01 17:07:16 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stall all active VFs */
|
2020-05-15 11:10:41 +00:00
|
|
|
for (i = 0; i < bp->pf->active_vfs; i++) {
|
2017-06-01 17:07:16 +00:00
|
|
|
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) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Failed to update VF VNIC %d.\n", i);
|
2017-06-01 17:07:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_mac_addr(uint16_t port, uint16_t vf,
|
2019-05-21 16:13:03 +00:00
|
|
|
struct rte_ether_addr *mac_addr)
|
2017-06-01 17:07:16 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:16 +00:00
|
|
|
|
|
|
|
if (vf >= dev_info.max_vfs || mac_addr == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:16 +00:00
|
|
|
"Attempt to set VF %d mac address on non-PF port %d!\n",
|
|
|
|
vf, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = bnxt_hwrm_func_vf_mac(bp, vf, (uint8_t *)mac_addr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2017-06-01 17:07:17 +00:00
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf,
|
2017-06-01 17:07:17 +00:00
|
|
|
uint16_t tx_rate, uint64_t q_msk)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
|
|
|
uint16_t tot_rate = 0;
|
|
|
|
uint64_t idx;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
eth_dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(eth_dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = eth_dev->data->dev_private;
|
2017-06-01 17:07:17 +00:00
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
if (!bp->pf->active_vfs)
|
2017-06-01 17:07:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
if (vf >= bp->pf->max_vfs)
|
2017-06-01 17:07:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Add up the per queue BW and configure MAX BW of the VF */
|
|
|
|
for (idx = 0; idx < 64; idx++) {
|
|
|
|
if ((1ULL << idx) & q_msk)
|
|
|
|
tot_rate += tx_rate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Requested BW can't be greater than link speed */
|
|
|
|
if (tot_rate > eth_dev->data->dev_link.link_speed) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Rate > Link speed. Set to %d\n", tot_rate);
|
2017-06-01 17:07:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Requested BW already configured */
|
2020-05-15 11:10:41 +00:00
|
|
|
if (tot_rate == bp->pf->vf_info[vf].max_tx_rate)
|
2017-06-01 17:07:17 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
rc = bnxt_hwrm_func_bw_cfg(bp, vf, tot_rate,
|
|
|
|
HWRM_FUNC_CFG_INPUT_ENABLES_MAX_BW);
|
|
|
|
|
|
|
|
if (!rc)
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].max_tx_rate = tot_rate;
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on)
|
2017-06-01 17:07:17 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
uint32_t func_flags;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
if (on > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:17 +00:00
|
|
|
"Attempt to set mac spoof on non-PF port %d!\n", port);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vf >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Prev setting same as new setting. */
|
2020-05-15 11:10:41 +00:00
|
|
|
if (on == bp->pf->vf_info[vf].mac_spoof_en)
|
2017-06-01 17:07:17 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
func_flags = bp->pf->vf_info[vf].func_cfg_flags;
|
2017-06-30 14:20:17 +00:00
|
|
|
func_flags &= ~(HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_ENABLE |
|
|
|
|
HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_DISABLE);
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
if (on)
|
|
|
|
func_flags |=
|
|
|
|
HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_ENABLE;
|
|
|
|
else
|
|
|
|
func_flags |=
|
|
|
|
HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_DISABLE;
|
|
|
|
|
2017-06-30 14:20:17 +00:00
|
|
|
rc = bnxt_hwrm_func_cfg_vf_set_flags(bp, vf, func_flags);
|
|
|
|
if (!rc) {
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].mac_spoof_en = on;
|
|
|
|
bp->pf->vf_info[vf].func_cfg_flags = func_flags;
|
2017-06-30 14:20:17 +00:00
|
|
|
}
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on)
|
2017-06-01 17:07:17 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
if (on > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-30 14:20:21 +00:00
|
|
|
"Attempt to set VLAN spoof on non-PF port %d!\n", port);
|
2017-06-01 17:07:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vf >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rc = bnxt_hwrm_func_cfg_vf_set_vlan_anti_spoof(bp, vf, on);
|
|
|
|
if (!rc) {
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].vlan_spoof_en = on;
|
2017-06-01 17:07:17 +00:00
|
|
|
if (on) {
|
2017-07-21 03:22:31 +00:00
|
|
|
if (bnxt_hwrm_cfa_vlan_antispoof_cfg(bp,
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->first_vf_id + vf,
|
|
|
|
bp->pf->vf_info[vf].vlan_count,
|
|
|
|
bp->pf->vf_info[vf].vlan_as_table))
|
2017-07-21 03:22:31 +00:00
|
|
|
rc = -1;
|
2017-06-01 17:07:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Failed to update VF VNIC %d.\n", vf);
|
2017-06-01 17:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rte_pmd_bnxt_set_vf_vlan_stripq_cb(struct bnxt_vnic_info *vnic, void *onptr)
|
|
|
|
{
|
|
|
|
uint8_t *on = onptr;
|
|
|
|
vnic->vlan_strip = *on;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-09-29 07:17:24 +00:00
|
|
|
rte_pmd_bnxt_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on)
|
2017-06-01 17:07:17 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
if (vf >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:17 +00:00
|
|
|
"Attempt to set VF %d stripq on non-PF port %d!\n",
|
|
|
|
vf, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf,
|
|
|
|
rte_pmd_bnxt_set_vf_vlan_stripq_cb, &on,
|
|
|
|
bnxt_hwrm_vnic_cfg);
|
|
|
|
if (rc)
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Failed to update VF VNIC %d.\n", vf);
|
2017-06-01 17:07:17 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_rxmode(uint16_t port, uint16_t vf,
|
2017-06-01 17:07:22 +00:00
|
|
|
uint16_t rx_mask, uint8_t on)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
uint16_t flag = 0;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:22 +00:00
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
if (!bp->pf->vf_info)
|
2017-06-01 17:07:22 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (vf >= bp->pdev->max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-09-28 21:43:29 +00:00
|
|
|
if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Currently cannot toggle this setting\n");
|
2017-06-01 17:07:22 +00:00
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2017-09-28 21:43:29 +00:00
|
|
|
/* Is this really the correct mapping? VFd seems to think it is. */
|
|
|
|
if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
|
|
|
|
flag |= BNXT_VNIC_INFO_PROMISC;
|
2017-06-01 17:07:22 +00:00
|
|
|
|
|
|
|
if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
|
|
|
|
flag |= BNXT_VNIC_INFO_BCAST;
|
|
|
|
if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
|
2017-09-28 21:43:29 +00:00
|
|
|
flag |= BNXT_VNIC_INFO_ALLMULTI | BNXT_VNIC_INFO_MCAST;
|
2017-06-01 17:07:22 +00:00
|
|
|
|
|
|
|
if (on)
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].l2_rx_mask |= flag;
|
2017-06-01 17:07:22 +00:00
|
|
|
else
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].l2_rx_mask &= ~flag;
|
2017-06-01 17:07:22 +00:00
|
|
|
|
|
|
|
rc = bnxt_hwrm_func_vf_vnic_query_and_config(bp, vf,
|
|
|
|
vf_vnic_set_rxmask_cb,
|
2020-05-15 11:10:41 +00:00
|
|
|
&bp->pf->vf_info[vf].l2_rx_mask,
|
2017-06-01 17:07:22 +00:00
|
|
|
bnxt_set_rx_mask_no_vlan);
|
|
|
|
if (rc)
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "bnxt_hwrm_func_vf_vnic_set_rxmask failed\n");
|
2017-06-01 17:07:22 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-07-21 03:22:31 +00:00
|
|
|
static int bnxt_set_vf_table(struct bnxt *bp, uint16_t vf)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
int dflt_vnic;
|
|
|
|
struct bnxt_vnic_info vnic;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-07-21 03:22:31 +00:00
|
|
|
"Attempt to set VLAN table on non-PF port!\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vf >= bp->pdev->max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf);
|
|
|
|
if (dflt_vnic < 0) {
|
|
|
|
/* This simply indicates there's no driver loaded.
|
|
|
|
* This is not an error.
|
|
|
|
*/
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR, "Unable to get default VNIC for VF %d\n", vf);
|
2017-07-21 03:22:31 +00:00
|
|
|
} else {
|
|
|
|
memset(&vnic, 0, sizeof(vnic));
|
|
|
|
vnic.fw_vnic_id = dflt_vnic;
|
|
|
|
if (bnxt_hwrm_vnic_qcfg(bp, &vnic,
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->first_vf_id + vf) == 0) {
|
2017-07-21 03:22:31 +00:00
|
|
|
if (bnxt_hwrm_cfa_l2_set_rx_mask(bp, &vnic,
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].vlan_count,
|
|
|
|
bp->pf->vf_info[vf].vlan_table))
|
2017-07-21 03:22:31 +00:00
|
|
|
rc = -1;
|
|
|
|
} else {
|
|
|
|
rc = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_vlan_filter(uint16_t port, uint16_t vlan,
|
2017-06-01 17:07:17 +00:00
|
|
|
uint64_t vf_mask, uint8_t vlan_on)
|
|
|
|
{
|
|
|
|
struct bnxt_vlan_table_entry *ve;
|
2017-07-21 03:22:31 +00:00
|
|
|
struct bnxt_vlan_antispoof_table_entry *vase;
|
2017-06-01 17:07:17 +00:00
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct bnxt *bp;
|
|
|
|
uint16_t cnt;
|
|
|
|
int rc = 0;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2020-05-15 11:10:41 +00:00
|
|
|
if (!bp->pf->vf_info)
|
2017-06-01 17:07:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
for (i = 0; vf_mask; i++, vf_mask >>= 1) {
|
2020-05-15 11:10:41 +00:00
|
|
|
cnt = bp->pf->vf_info[i].vlan_count;
|
2017-07-21 03:22:27 +00:00
|
|
|
if ((vf_mask & 1) == 0)
|
|
|
|
continue;
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
if (bp->pf->vf_info[i].vlan_table == NULL) {
|
2017-07-21 03:22:27 +00:00
|
|
|
rc = -1;
|
|
|
|
continue;
|
|
|
|
}
|
2020-05-15 11:10:41 +00:00
|
|
|
if (bp->pf->vf_info[i].vlan_as_table == NULL) {
|
2017-07-21 03:22:31 +00:00
|
|
|
rc = -1;
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-21 03:22:27 +00:00
|
|
|
if (vlan_on) {
|
|
|
|
/* First, search for a duplicate... */
|
|
|
|
for (j = 0; j < cnt; j++) {
|
|
|
|
if (rte_be_to_cpu_16(
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[i].vlan_table[j].vid) ==
|
|
|
|
vlan)
|
2017-07-21 03:22:27 +00:00
|
|
|
break;
|
2017-06-01 17:07:17 +00:00
|
|
|
}
|
2017-07-21 03:22:27 +00:00
|
|
|
if (j == cnt) {
|
|
|
|
/* Now check that there's space */
|
2017-07-21 03:22:31 +00:00
|
|
|
if (cnt == getpagesize() / sizeof(struct
|
|
|
|
bnxt_vlan_antispoof_table_entry)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-07-21 03:22:31 +00:00
|
|
|
"VLAN anti-spoof table is full\n");
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-07-21 03:22:31 +00:00
|
|
|
"VF %d cannot add VLAN %u\n",
|
|
|
|
i, vlan);
|
2017-07-21 03:22:27 +00:00
|
|
|
rc = -1;
|
|
|
|
continue;
|
2017-06-01 17:07:17 +00:00
|
|
|
}
|
2017-07-21 03:22:27 +00:00
|
|
|
|
|
|
|
/* cnt is one less than vlan_count */
|
2020-05-15 11:10:41 +00:00
|
|
|
cnt = bp->pf->vf_info[i].vlan_count++;
|
2017-07-21 03:22:27 +00:00
|
|
|
/*
|
|
|
|
* And finally, add to the
|
|
|
|
* end of the table
|
|
|
|
*/
|
2020-05-15 11:10:41 +00:00
|
|
|
vase = &bp->pf->vf_info[i].vlan_as_table[cnt];
|
2017-07-21 03:22:31 +00:00
|
|
|
// 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);
|
2020-05-15 11:10:41 +00:00
|
|
|
ve = &bp->pf->vf_info[i].vlan_table[cnt];
|
2017-07-21 03:22:27 +00:00
|
|
|
/* TODO: Hardcoded TPID */
|
|
|
|
ve->tpid = rte_cpu_to_be_16(0x8100);
|
|
|
|
ve->vid = rte_cpu_to_be_16(vlan);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (j = 0; j < cnt; j++) {
|
|
|
|
if (rte_be_to_cpu_16(
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[i].vlan_table[j].vid) !=
|
|
|
|
vlan)
|
2017-07-21 03:22:27 +00:00
|
|
|
continue;
|
2020-05-15 11:10:41 +00:00
|
|
|
memmove(&bp->pf->vf_info[i].vlan_table[j],
|
|
|
|
&bp->pf->vf_info[i].vlan_table[j + 1],
|
2017-07-21 03:22:27 +00:00
|
|
|
getpagesize() - ((j + 1) *
|
|
|
|
sizeof(struct bnxt_vlan_table_entry)));
|
2020-05-15 11:10:41 +00:00
|
|
|
memmove(&bp->pf->vf_info[i].vlan_as_table[j],
|
|
|
|
&bp->pf->vf_info[i].vlan_as_table[j + 1],
|
2017-07-21 03:22:31 +00:00
|
|
|
getpagesize() - ((j + 1) * sizeof(struct
|
|
|
|
bnxt_vlan_antispoof_table_entry)));
|
2017-07-21 03:22:27 +00:00
|
|
|
j--;
|
2020-05-15 11:10:41 +00:00
|
|
|
cnt = --bp->pf->vf_info[i].vlan_count;
|
2017-06-01 17:07:17 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-21 03:22:31 +00:00
|
|
|
bnxt_set_vf_table(bp, i);
|
2017-06-01 17:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2017-06-01 17:07:18 +00:00
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_get_vf_stats(uint16_t port,
|
2017-06-01 17:07:18 +00:00
|
|
|
uint16_t vf_id,
|
|
|
|
struct rte_eth_stats *stats)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
2019-09-12 16:42:23 +00:00
|
|
|
int rc;
|
2017-06-01 17:07:18 +00:00
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:18 +00:00
|
|
|
|
|
|
|
if (vf_id >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:18 +00:00
|
|
|
"Attempt to get VF %d stats on non-PF port %d!\n",
|
|
|
|
vf_id, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
return bnxt_hwrm_func_qstats(bp, bp->pf->first_vf_id + vf_id, stats,
|
2020-04-02 05:26:29 +00:00
|
|
|
NULL);
|
2017-06-01 17:07:18 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_reset_vf_stats(uint16_t port,
|
2017-06-01 17:07:18 +00:00
|
|
|
uint16_t vf_id)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
2019-09-12 16:42:23 +00:00
|
|
|
int rc;
|
2017-06-01 17:07:18 +00:00
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:18 +00:00
|
|
|
|
|
|
|
if (vf_id >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:18 +00:00
|
|
|
"Attempt to reset VF %d stats on non-PF port %d!\n",
|
|
|
|
vf_id, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
return bnxt_hwrm_func_clr_stats(bp, bp->pf->first_vf_id + vf_id);
|
2017-06-01 17:07:18 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_get_vf_rx_status(uint16_t port, uint16_t vf_id)
|
2017-06-01 17:07:19 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
2019-09-12 16:42:23 +00:00
|
|
|
int rc;
|
2017-06-01 17:07:19 +00:00
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:19 +00:00
|
|
|
|
|
|
|
if (vf_id >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:19 +00:00
|
|
|
"Attempt to query VF %d RX stats on non-PF port %d!\n",
|
|
|
|
vf_id, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2017-06-30 14:20:15 +00:00
|
|
|
return bnxt_vf_vnic_count(bp, vf_id);
|
2017-06-01 17:07:19 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_get_vf_tx_drop_count(uint16_t port, uint16_t vf_id,
|
2017-06-01 17:07:18 +00:00
|
|
|
uint64_t *count)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
2019-09-12 16:42:23 +00:00
|
|
|
int rc;
|
2017-06-01 17:07:18 +00:00
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:18 +00:00
|
|
|
|
|
|
|
if (vf_id >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:18 +00:00
|
|
|
"Attempt to query VF %d TX drops on non-PF port %d!\n",
|
|
|
|
vf_id, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
return bnxt_hwrm_func_qstats_tx_drop(bp, bp->pf->first_vf_id + vf_id,
|
2017-06-01 17:07:18 +00:00
|
|
|
count);
|
|
|
|
}
|
2017-06-01 17:07:20 +00:00
|
|
|
|
2019-05-21 16:13:03 +00:00
|
|
|
int rte_pmd_bnxt_mac_addr_add(uint16_t port, struct rte_ether_addr *addr,
|
2017-06-01 17:07:20 +00:00
|
|
|
uint32_t vf_id)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
|
|
|
struct bnxt_filter_info *filter;
|
|
|
|
struct bnxt_vnic_info vnic;
|
2019-05-21 16:13:03 +00:00
|
|
|
struct rte_ether_addr dflt_mac;
|
2017-06-01 17:07:20 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:20 +00:00
|
|
|
|
|
|
|
if (vf_id >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:20 +00:00
|
|
|
"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 */
|
2020-05-15 11:10:41 +00:00
|
|
|
if (bp->pf->vf_info[vf_id].random_mac) {
|
2017-06-01 17:07:20 +00:00
|
|
|
if (rte_pmd_bnxt_get_vf_rx_status(port, vf_id) <= 0)
|
2017-10-24 21:19:52 +00:00
|
|
|
bnxt_hwrm_func_vf_mac(bp, vf_id, (uint8_t *)addr);
|
2017-06-01 17:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* query the default VNIC id used by the function */
|
|
|
|
rc = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf_id);
|
|
|
|
if (rc < 0)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
|
|
|
|
vnic.fw_vnic_id = rte_le_to_cpu_16(rc);
|
2020-05-15 11:10:41 +00:00
|
|
|
rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf->first_vf_id + vf_id);
|
2017-06-01 17:07:20 +00:00
|
|
|
if (rc < 0)
|
|
|
|
goto exit;
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
STAILQ_FOREACH(filter, &bp->pf->vf_info[vf_id].filter, next) {
|
2017-06-01 17:07:20 +00:00
|
|
|
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) &&
|
2019-05-21 16:13:05 +00:00
|
|
|
memcmp(addr, filter->l2_addr, RTE_ETHER_ADDR_LEN) == 0) {
|
2017-09-28 21:43:39 +00:00
|
|
|
bnxt_hwrm_clear_l2_filter(bp, filter);
|
2017-06-01 17:07:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter == NULL)
|
|
|
|
filter = bnxt_alloc_vf_filter(bp, vf_id);
|
|
|
|
|
|
|
|
filter->fw_l2_filter_id = UINT64_MAX;
|
|
|
|
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;
|
2019-05-21 16:13:05 +00:00
|
|
|
memcpy(filter->l2_addr, addr, RTE_ETHER_ADDR_LEN);
|
|
|
|
memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
|
2017-06-01 17:07:20 +00:00
|
|
|
|
|
|
|
/* Do not add a filter for the default MAC */
|
|
|
|
if (bnxt_hwrm_func_qcfg_vf_default_mac(bp, vf_id, &dflt_mac) ||
|
2019-05-21 16:13:05 +00:00
|
|
|
memcmp(filter->l2_addr, dflt_mac.addr_bytes, RTE_ETHER_ADDR_LEN))
|
2017-09-28 21:43:39 +00:00
|
|
|
rc = bnxt_hwrm_set_l2_filter(bp, vnic.fw_vnic_id, filter);
|
2017-06-01 17:07:20 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return rc;
|
|
|
|
}
|
2017-06-01 17:07:21 +00:00
|
|
|
|
|
|
|
int
|
2017-09-29 07:17:24 +00:00
|
|
|
rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf,
|
2017-06-01 17:07:21 +00:00
|
|
|
uint16_t vlan_id)
|
|
|
|
{
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
|
|
|
if (!is_bnxt_supported(dev))
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-01 17:07:21 +00:00
|
|
|
|
|
|
|
if (vf >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-01 17:07:21 +00:00
|
|
|
"Attempt to set VF %d vlan insert on non-PF port %d!\n",
|
|
|
|
vf, port);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].dflt_vlan = vlan_id;
|
2017-06-01 17:07:21 +00:00
|
|
|
if (bnxt_hwrm_func_qcfg_current_vf_vlan(bp, vf) ==
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].dflt_vlan)
|
2017-06-01 17:07:21 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
rc = bnxt_hwrm_set_vf_vlan(bp, vf);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2017-06-30 14:20:17 +00:00
|
|
|
|
2017-09-29 07:17:24 +00:00
|
|
|
int rte_pmd_bnxt_set_vf_persist_stats(uint16_t port, uint16_t vf, uint8_t on)
|
2017-06-30 14:20:17 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev_info dev_info;
|
|
|
|
struct rte_eth_dev *dev;
|
|
|
|
uint32_t func_flags;
|
|
|
|
struct bnxt *bp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
|
|
|
|
|
|
|
|
if (on > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev = &rte_eth_devices[port];
|
2019-09-12 16:42:23 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-05-29 19:14:53 +00:00
|
|
|
bp = dev->data->dev_private;
|
2017-06-30 14:20:17 +00:00
|
|
|
|
|
|
|
if (!BNXT_PF(bp)) {
|
2018-01-26 17:31:55 +00:00
|
|
|
PMD_DRV_LOG(ERR,
|
2017-06-30 14:20:17 +00:00
|
|
|
"Attempt to set persist stats on non-PF port %d!\n",
|
|
|
|
port);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vf >= dev_info.max_vfs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Prev setting same as new setting. */
|
2020-05-15 11:10:41 +00:00
|
|
|
if (on == bp->pf->vf_info[vf].persist_stats)
|
2017-06-30 14:20:17 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-05-15 11:10:41 +00:00
|
|
|
func_flags = bp->pf->vf_info[vf].func_cfg_flags;
|
2017-06-30 14:20:17 +00:00
|
|
|
|
|
|
|
if (on)
|
|
|
|
func_flags |=
|
|
|
|
HWRM_FUNC_CFG_INPUT_FLAGS_NO_AUTOCLEAR_STATISTIC;
|
|
|
|
else
|
|
|
|
func_flags &=
|
|
|
|
~HWRM_FUNC_CFG_INPUT_FLAGS_NO_AUTOCLEAR_STATISTIC;
|
|
|
|
|
|
|
|
rc = bnxt_hwrm_func_cfg_vf_set_flags(bp, vf, func_flags);
|
|
|
|
if (!rc) {
|
2020-05-15 11:10:41 +00:00
|
|
|
bp->pf->vf_info[vf].persist_stats = on;
|
|
|
|
bp->pf->vf_info[vf].func_cfg_flags = func_flags;
|
2017-06-30 14:20:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|