{ .vendor_id = 0, /* sentinel */ },
};
-#define BNXT_DEVARG_TRUFLOW "host-based-truflow"
+#define BNXT_DEVARG_ACCUM_STATS "accum-stats"
#define BNXT_DEVARG_FLOW_XSTAT "flow-xstat"
#define BNXT_DEVARG_MAX_NUM_KFLOWS "max-num-kflows"
#define BNXT_DEVARG_REPRESENTOR "representor"
#define BNXT_DEVARG_REP_Q_F2R "rep-q-f2r"
#define BNXT_DEVARG_REP_FC_R2F "rep-fc-r2f"
#define BNXT_DEVARG_REP_FC_F2R "rep-fc-f2r"
+#define BNXT_DEVARG_APP_ID "app-id"
static const char *const bnxt_dev_args[] = {
BNXT_DEVARG_REPRESENTOR,
- BNXT_DEVARG_TRUFLOW,
+ BNXT_DEVARG_ACCUM_STATS,
BNXT_DEVARG_FLOW_XSTAT,
BNXT_DEVARG_MAX_NUM_KFLOWS,
BNXT_DEVARG_REP_BASED_PF,
BNXT_DEVARG_REP_Q_F2R,
BNXT_DEVARG_REP_FC_R2F,
BNXT_DEVARG_REP_FC_F2R,
+ BNXT_DEVARG_APP_ID,
NULL
};
/*
- * truflow == false to disable the feature
- * truflow == true to enable the feature
+ * accum-stats == false to disable flow counter accumulation
+ * accum-stats == true to enable flow counter accumulation
*/
-#define BNXT_DEVARG_TRUFLOW_INVALID(truflow) ((truflow) > 1)
+#define BNXT_DEVARG_ACCUM_STATS_INVALID(accum_stats) ((accum_stats) > 1)
+
+/*
+ * app-id = an non-negative 8-bit number
+ */
+#define BNXT_DEVARG_APP_ID_INVALID(val) ((val) > 255)
/*
* flow_xstat == false to disable the feature
return rc;
}
+static void bnxt_free_prev_ring_stats(struct bnxt *bp)
+{
+ rte_free(bp->prev_rx_ring_stats);
+ rte_free(bp->prev_tx_ring_stats);
+
+ bp->prev_rx_ring_stats = NULL;
+ bp->prev_tx_ring_stats = NULL;
+}
+
+static int bnxt_alloc_prev_ring_stats(struct bnxt *bp)
+{
+ bp->prev_rx_ring_stats = rte_zmalloc("bnxt_prev_rx_ring_stats",
+ sizeof(struct bnxt_ring_stats) *
+ bp->rx_cp_nr_rings,
+ 0);
+ if (bp->prev_rx_ring_stats == NULL)
+ return -ENOMEM;
+
+ bp->prev_tx_ring_stats = rte_zmalloc("bnxt_prev_tx_ring_stats",
+ sizeof(struct bnxt_ring_stats) *
+ bp->tx_cp_nr_rings,
+ 0);
+ if (bp->prev_tx_ring_stats == NULL)
+ goto error;
+
+ return 0;
+
+error:
+ bnxt_free_prev_ring_stats(bp);
+ return -ENOMEM;
+}
+
static int bnxt_start_nic(struct bnxt *bp)
{
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(bp->eth_dev);
dev_info->speed_capa = bnxt_get_speed_capabilities(bp);
- /* *INDENT-OFF* */
dev_info->default_rxconf = (struct rte_eth_rxconf) {
.rx_thresh = {
.pthresh = 8,
BNXT_SWITCH_PORT_ID_TRUSTED_VF;
}
- /* *INDENT-ON* */
-
/*
* TODO: default_rxconf, default_txconf, rx_desc_lim, and tx_desc_lim
* need further investigation.
bnxt_shutdown_nic(bp);
bnxt_hwrm_if_change(bp, false);
+ bnxt_free_prev_ring_stats(bp);
rte_free(bp->mark_table);
bp->mark_table = NULL;
if (rc)
goto error;
+ rc = bnxt_alloc_prev_ring_stats(bp);
+ if (rc)
+ goto error;
+
eth_dev->data->dev_started = 1;
bnxt_link_update_op(eth_dev, 1);
BNXT_HWRM_CMD_TO_FORWARD(HWRM_OEM_CMD);
}
+struct bnxt *
+bnxt_get_bp(uint16_t port)
+{
+ struct bnxt *bp;
+ struct rte_eth_dev *dev;
+
+ if (!rte_eth_dev_is_valid_port(port)) {
+ PMD_DRV_LOG(ERR, "Invalid port %d\n", port);
+ return NULL;
+ }
+
+ dev = &rte_eth_devices[port];
+ if (!is_bnxt_supported(dev)) {
+ PMD_DRV_LOG(ERR, "Device %d not supported\n", port);
+ return NULL;
+ }
+
+ bp = (struct bnxt *)dev->data->dev_private;
+ if (!BNXT_TRUFLOW_EN(bp)) {
+ PMD_DRV_LOG(ERR, "TRUFLOW not enabled\n");
+ return NULL;
+ }
+
+ return bp;
+}
+
uint16_t
bnxt_get_svif(uint16_t port_id, bool func_svif,
enum bnxt_ulp_intf_type type)
return func_svif ? bp->func_svif : bp->port_svif;
}
+void
+bnxt_get_iface_mac(uint16_t port, enum bnxt_ulp_intf_type type,
+ uint8_t *mac, uint8_t *parent_mac)
+{
+ struct rte_eth_dev *eth_dev;
+ struct bnxt *bp;
+
+ if (type != BNXT_ULP_INTF_TYPE_TRUSTED_VF &&
+ type != BNXT_ULP_INTF_TYPE_PF)
+ return;
+
+ eth_dev = &rte_eth_devices[port];
+ bp = eth_dev->data->dev_private;
+ memcpy(mac, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+ if (type == BNXT_ULP_INTF_TYPE_TRUSTED_VF)
+ memcpy(parent_mac, bp->parent->mac_addr, RTE_ETHER_ADDR_LEN);
+}
+
+uint16_t
+bnxt_get_parent_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type)
+{
+ struct rte_eth_dev *eth_dev;
+ struct bnxt *bp;
+
+ if (type != BNXT_ULP_INTF_TYPE_TRUSTED_VF)
+ return 0;
+
+ eth_dev = &rte_eth_devices[port];
+ bp = eth_dev->data->dev_private;
+
+ return bp->parent->vnic;
+}
uint16_t
bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type)
{
}
static int
-bnxt_parse_devarg_truflow(__rte_unused const char *key,
- const char *value, void *opaque_arg)
+bnxt_parse_devarg_accum_stats(__rte_unused const char *key,
+ const char *value, void *opaque_arg)
{
struct bnxt *bp = opaque_arg;
- unsigned long truflow;
+ unsigned long accum_stats;
char *end = NULL;
if (!value || !opaque_arg) {
PMD_DRV_LOG(ERR,
- "Invalid parameter passed to truflow devargs.\n");
+ "Invalid parameter passed to accum-stats devargs.\n");
return -EINVAL;
}
- truflow = strtoul(value, &end, 10);
+ accum_stats = strtoul(value, &end, 10);
if (end == NULL || *end != '\0' ||
- (truflow == ULONG_MAX && errno == ERANGE)) {
+ (accum_stats == ULONG_MAX && errno == ERANGE)) {
PMD_DRV_LOG(ERR,
- "Invalid parameter passed to truflow devargs.\n");
+ "Invalid parameter passed to accum-stats devargs.\n");
return -EINVAL;
}
- if (BNXT_DEVARG_TRUFLOW_INVALID(truflow)) {
+ if (BNXT_DEVARG_ACCUM_STATS_INVALID(accum_stats)) {
PMD_DRV_LOG(ERR,
- "Invalid value passed to truflow devargs.\n");
+ "Invalid value passed to accum-stats devargs.\n");
return -EINVAL;
}
- if (truflow) {
- bp->flags |= BNXT_FLAG_TRUFLOW_EN;
- PMD_DRV_LOG(INFO, "Host-based truflow feature enabled.\n");
+ if (accum_stats) {
+ bp->flags2 |= BNXT_FLAGS2_ACCUM_STATS_EN;
+ PMD_DRV_LOG(INFO, "Host-based accum-stats feature enabled.\n");
} else {
- bp->flags &= ~BNXT_FLAG_TRUFLOW_EN;
- PMD_DRV_LOG(INFO, "Host-based truflow feature disabled.\n");
+ bp->flags2 &= ~BNXT_FLAGS2_ACCUM_STATS_EN;
+ PMD_DRV_LOG(INFO, "Host-based accum-stats feature disabled.\n");
}
return 0;
return 0;
}
+static int
+bnxt_parse_devarg_app_id(__rte_unused const char *key,
+ const char *value, void *opaque_arg)
+{
+ struct bnxt *bp = opaque_arg;
+ unsigned long app_id;
+ char *end = NULL;
+
+ if (!value || !opaque_arg) {
+ PMD_DRV_LOG(ERR,
+ "Invalid parameter passed to app-id "
+ "devargs.\n");
+ return -EINVAL;
+ }
+
+ app_id = strtoul(value, &end, 10);
+ if (end == NULL || *end != '\0' ||
+ (app_id == ULONG_MAX && errno == ERANGE)) {
+ PMD_DRV_LOG(ERR,
+ "Invalid parameter passed to app_id "
+ "devargs.\n");
+ return -EINVAL;
+ }
+
+ if (BNXT_DEVARG_APP_ID_INVALID(app_id)) {
+ PMD_DRV_LOG(ERR, "Invalid app-id(%d) devargs.\n",
+ (uint16_t)app_id);
+ return -EINVAL;
+ }
+
+ bp->app_id = app_id;
+ PMD_DRV_LOG(INFO, "app-id=%d feature enabled.\n", (uint16_t)app_id);
+
+ return 0;
+}
+
static int
bnxt_parse_devarg_rep_is_pf(__rte_unused const char *key,
const char *value, void *opaque_arg)
if (kvlist == NULL)
return -EINVAL;
- /*
- * Handler for "truflow" devarg.
- * Invoked as for ex: "-a 0000:00:0d.0,host-based-truflow=1"
- */
- ret = rte_kvargs_process(kvlist, BNXT_DEVARG_TRUFLOW,
- bnxt_parse_devarg_truflow, bp);
- if (ret)
- goto err;
-
/*
* Handler for "flow_xstat" devarg.
* Invoked as for ex: "-a 0000:00:0d.0,flow_xstat=1"
if (ret)
goto err;
+ /*
+ * Handler for "accum-stats" devarg.
+ * Invoked as for ex: "-a 0000:00:0d.0,accum-stats=1"
+ */
+ rte_kvargs_process(kvlist, BNXT_DEVARG_ACCUM_STATS,
+ bnxt_parse_devarg_accum_stats, bp);
/*
* Handler for "max_num_kflows" devarg.
* Invoked as for ex: "-a 000:00:0d.0,max_num_kflows=32"
goto err;
err:
+ /*
+ * Handler for "app-id" devarg.
+ * Invoked as for ex: "-a 000:00:0d.0,app-id=1"
+ */
+ rte_kvargs_process(kvlist, BNXT_DEVARG_APP_ID,
+ bnxt_parse_devarg_app_id, bp);
+
rte_kvargs_free(kvlist);
return ret;
}
goto error_free;
PMD_DRV_LOG(INFO,
- DRV_MODULE_NAME "found at mem %" PRIX64 ", node addr %pM\n",
+ "Found %s device at mem %" PRIX64 ", node addr %pM\n",
+ DRV_MODULE_NAME,
pci_dev->mem_resource[0].phys_addr,
pci_dev->mem_resource[0].addr);