net/bnxt: fix automatic clearing of VF stats

Add code to avoid automatic clearing of VF stats on a function
reset or a stat context free.

Add rte_pmd_bnxt_set_vf_persist_stats() PMD specific API.

Fixes: dd46c6bbd5d6 ("net/bnxt: support get and clear VF specific stats")

Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
Ajit Khaparde 2017-06-30 09:20:17 -05:00 committed by Ferruh Yigit
parent 28eef5e0a8
commit 44bec7092b
7 changed files with 89 additions and 7 deletions

View File

@ -109,6 +109,7 @@ struct bnxt_child_vf_info {
uint8_t mac_spoof_en;
uint8_t vlan_spoof_en;
bool random_mac;
bool persist_stats;
};
struct bnxt_pf_info {

View File

@ -2367,7 +2367,8 @@ int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, uint16_t port,
return rc;
}
int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf)
int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf,
uint32_t flags)
{
struct hwrm_func_cfg_output *resp = bp->hwrm_cmd_resp_addr;
struct hwrm_func_cfg_input req = {0};
@ -2375,7 +2376,7 @@ int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf)
HWRM_PREP(req, FUNC_CFG, -1, resp);
req.fid = rte_cpu_to_le_16(bp->pf.vf_info[vf].fid);
req.flags = rte_cpu_to_le_32(bp->pf.vf_info[vf].func_cfg_flags);
req.flags = rte_cpu_to_le_32(flags);
rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
HWRM_CHECK_RESULT;

View File

@ -142,7 +142,8 @@ int bnxt_hwrm_port_qstats(struct bnxt *bp);
int bnxt_hwrm_port_clr_stats(struct bnxt *bp);
int bnxt_hwrm_port_led_cfg(struct bnxt *bp, bool led_on);
int bnxt_hwrm_port_led_qcaps(struct bnxt *bp);
int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf);
int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf,
uint32_t flags);
void vf_vnic_set_rxmask_cb(struct bnxt_vnic_info *vnic, void *flagp);
int bnxt_set_rx_mask_no_vlan(struct bnxt *bp, struct bnxt_vnic_info *vnic);
int bnxt_vf_vnic_count(struct bnxt *bp, uint16_t vf);

View File

@ -3190,6 +3190,15 @@ struct hwrm_func_cfg_input {
* command will be persistent over warm boot.
*/
#define HWRM_FUNC_CFG_INPUT_FLAGS_VIRT_MAC_PERSIST UINT32_C(0x800)
/*
* This bit only applies to the VF. If this bit is set, the
* statistic context counters will not be cleared when the
* statistic context is freed or a function reset is called on
* VF. This bit will be cleared when the PF is unloaded or a
* function reset is called on the PF.
*/
#define HWRM_FUNC_CFG_INPUT_FLAGS_NO_AUTOCLEAR_STATISTIC \
UINT32_C(0x1000)
uint32_t enables;
/* This bit must be '1' for the mtu field to be configured. */
#define HWRM_FUNC_CFG_INPUT_ENABLES_MTU UINT32_C(0x1)

View File

@ -274,6 +274,8 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
return 0;
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);
if (on)
func_flags |=
@ -282,11 +284,11 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
func_flags |=
HWRM_FUNC_CFG_INPUT_FLAGS_SRC_MAC_ADDR_CHECK_DISABLE;
bp->pf.vf_info[vf].func_cfg_flags = func_flags;
rc = bnxt_hwrm_func_cfg_vf_set_flags(bp, vf);
if (!rc)
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;
}
return rc;
}
@ -754,3 +756,52 @@ 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)
{
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];
rte_eth_dev_info_get(port, &dev_info);
bp = (struct bnxt *)dev->data->dev_private;
if (!BNXT_PF(bp)) {
RTE_LOG(ERR, PMD,
"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. */
if (on == bp->pf.vf_info[vf].persist_stats)
return 0;
func_flags = bp->pf.vf_info[vf].func_cfg_flags;
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) {
bp->pf.vf_info[vf].persist_stats = on;
bp->pf.vf_info[vf].func_cfg_flags = func_flags;
}
return rc;
}

View File

@ -333,4 +333,22 @@ int rte_pmd_bnxt_get_vf_tx_drop_count(uint8_t port, uint16_t vf_id,
*/
int rte_pmd_bnxt_mac_addr_add(uint8_t port, struct ether_addr *mac_addr,
uint32_t vf_id);
/**
* Enable/Disable VF statistics retention
*
* @param port
* The port identifier of the Ethernet device.
* @param vf
* VF id.
* @param on
* 1 - Prevent VF statistics from automatically resetting
* 0 - Allow VF statistics to automatically reset
*
* @return
* - (0) if successful.
* - (-ENODEV) if *port* invalid.
* - (-EINVAL) if bad parameter.
*/
int rte_pmd_bnxt_set_vf_persist_stats(uint8_t port, uint16_t vf, uint8_t on);
#endif /* _PMD_BNXT_H_ */

View File

@ -16,6 +16,7 @@ DPDK_17.08 {
rte_pmd_bnxt_set_vf_vlan_filter;
rte_pmd_bnxt_set_vf_vlan_insert;
rte_pmd_bnxt_set_vf_vlan_stripq;
rte_pmd_bnxt_set_vf_persist_stats;
local: *;
};