struct bnxt_flow_stat_info *flow_stat;
uint8_t flow_xstat;
uint16_t max_num_kflows;
+ uint16_t tx_cfa_action;
};
#define BNXT_FC_TIMER 1 /* Timer freq in Sec Flow Counters */
uint16_t fw_fid;
uint16_t dflt_vnic_id;
uint16_t svif;
- uint32_t vfr_tx_cfa_action;
+ uint16_t vfr_tx_cfa_action;
uint16_t rx_cfa_code;
uint32_t rep2vf_flow_id;
uint32_t vf2rep_flow_id;
extern const struct rte_flow_ops bnxt_ulp_rte_flow_ops;
int32_t bnxt_ulp_init(struct bnxt *bp);
void bnxt_ulp_deinit(struct bnxt *bp);
+int32_t bnxt_ulp_create_df_rules(struct bnxt *bp);
+void bnxt_ulp_destroy_df_rules(struct bnxt *bp, bool global);
uint16_t bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type);
uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif,
return rc;
}
-static int32_t
-bnxt_create_port_app_df_rule(struct bnxt *bp, uint8_t flow_type,
- uint32_t *flow_id)
-{
- uint16_t port_id = bp->eth_dev->data->port_id;
- struct ulp_tlv_param param_list[] = {
- {
- .type = BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID,
- .length = 2,
- .value = {(port_id >> 8) & 0xff, port_id & 0xff}
- },
- {
- .type = BNXT_ULP_DF_PARAM_TYPE_LAST,
- .length = 0,
- .value = {0}
- }
- };
-
- return ulp_default_flow_create(bp->eth_dev, param_list, flow_type,
- flow_id);
-}
-
-static int32_t
-bnxt_create_df_rules(struct bnxt *bp)
-{
- struct bnxt_ulp_data *cfg_data;
- int rc;
-
- cfg_data = bp->ulp_ctx->cfg_data;
- rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_PORT_TO_VS,
- &cfg_data->port_to_app_flow_id);
- if (rc) {
- PMD_DRV_LOG(ERR,
- "Failed to create port to app default rule\n");
- return rc;
- }
-
- BNXT_TF_DBG(DEBUG, "***** created port to app default rule ******\n");
- rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_VS_TO_PORT,
- &cfg_data->app_to_port_flow_id);
- if (!rc) {
- rc = ulp_default_flow_db_cfa_action_get(bp->ulp_ctx,
- cfg_data->app_to_port_flow_id,
- &cfg_data->tx_cfa_action);
- if (rc)
- goto err;
-
- BNXT_TF_DBG(DEBUG,
- "***** created app to port default rule *****\n");
- return 0;
- }
-
-err:
- BNXT_TF_DBG(DEBUG, "Failed to create app to port default rule\n");
- return rc;
-}
-
-static void
-bnxt_destroy_df_rules(struct bnxt *bp)
-{
- struct bnxt_ulp_data *cfg_data;
-
- cfg_data = bp->ulp_ctx->cfg_data;
- ulp_default_flow_destroy(bp->eth_dev, cfg_data->port_to_app_flow_id);
- ulp_default_flow_destroy(bp->eth_dev, cfg_data->app_to_port_flow_id);
-}
-
static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
bnxt_schedule_fw_health_check(bp);
pthread_mutex_unlock(&bp->def_cp_lock);
- if (BNXT_TRUFLOW_EN(bp))
- bnxt_ulp_init(bp);
+ bnxt_ulp_init(bp);
return 0;
/* disable uio/vfio intr/eventfd mapping */
rte_intr_disable(intr_handle);
+ bnxt_ulp_destroy_df_rules(bp, false);
+ bnxt_ulp_deinit(bp);
+
bnxt_cancel_fw_health_check(bp);
bnxt_dev_set_link_down_op(eth_dev);
rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp);
bnxt_cancel_fc_thread(bp);
- if (BNXT_TRUFLOW_EN(bp)) {
- bnxt_destroy_df_rules(bp);
- bnxt_ulp_deinit(bp);
- }
-
if (eth_dev->data->dev_started)
bnxt_dev_stop_op(eth_dev);
if (rc != 0)
vnic->flags = old_flags;
- if (BNXT_TRUFLOW_EN(bp))
- bnxt_create_df_rules(bp);
+ bnxt_ulp_create_df_rules(bp);
return rc;
}
struct bnxt *bp;
int index;
int tx_wake_thresh;
- uint32_t tx_cfa_action;
uint32_t vfr_tx_cfa_action;
struct bnxt_tx_ring_info *tx_ring;
PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST |
PKT_TX_QINQ_PKT) ||
(BNXT_TRUFLOW_EN(txq->bp) &&
- (txq->bp->ulp_ctx->cfg_data->tx_cfa_action ||
- txq->vfr_tx_cfa_action)))
+ (txq->bp->tx_cfa_action || txq->vfr_tx_cfa_action)))
long_bd = true;
nr_bds = long_bd + tx_pkt->nb_segs;
if (txq->vfr_tx_cfa_action)
cfa_action = txq->vfr_tx_cfa_action;
else
- cfa_action =
- txq->bp->ulp_ctx->cfg_data->tx_cfa_action;
+ cfa_action = txq->bp->tx_cfa_action;
}
/* HW can accelerate only outer vlan in QinQ mode */
#include <rte_flow_driver.h>
#include <rte_tailq.h>
+#include "bnxt.h"
#include "bnxt_ulp.h"
#include "bnxt_tf_common.h"
-#include "bnxt.h"
#include "tf_core.h"
#include "tf_ext_flow_handle.h"
(void)ulp_ctx_deinit(bp, session);
return rc;
}
+
bnxt_ulp_cntxt_tfp_set(bp->ulp_ctx, session->g_tfp);
return rc;
}
bool init;
int rc;
+ if (!BNXT_TRUFLOW_EN(bp))
+ return 0;
+
if (bp->ulp_ctx) {
BNXT_TF_DBG(DEBUG, "ulp ctx already allocated\n");
return -EINVAL;
struct rte_pci_device *pci_dev;
struct rte_pci_addr *pci_addr;
+ if (!BNXT_TRUFLOW_EN(bp))
+ return;
+
/* Get the session first */
pci_dev = RTE_DEV_TO_PCI(bp->eth_dev->device);
pci_addr = &pci_dev->addr;
if (!session)
return;
+ /* clean up default flows */
+ bnxt_ulp_destroy_df_rules(bp, true);
+
/* clean up regular flows */
ulp_flow_db_flush_flows(bp->ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
#define BNXT_ULP_VF_REP_ENABLED 0x1
#define ULP_VF_REP_IS_ENABLED(flag) ((flag) & BNXT_ULP_VF_REP_ENABLED)
+struct bnxt_ulp_df_rule_info {
+ uint32_t port_to_app_flow_id;
+ uint32_t app_to_port_flow_id;
+ uint8_t valid;
+};
+
struct bnxt_ulp_data {
uint32_t tbl_scope_id;
struct bnxt_ulp_mark_tbl *mark_tbl;
struct bnxt_ulp_port_db *port_db;
struct bnxt_ulp_fc_info *fc_info;
uint32_t ulp_flags;
- uint32_t port_to_app_flow_id;
- uint32_t app_to_port_flow_id;
- uint32_t tx_cfa_action;
+ struct bnxt_ulp_df_rule_info df_rule_info[RTE_MAX_ETHPORTS];
};
struct bnxt_ulp_context {
bnxt_ulp_cntxt_ptr2_ulp_flags_get(struct bnxt_ulp_context *ulp_ctx,
uint32_t *flags);
+int32_t
+bnxt_ulp_get_df_rule_info(uint8_t port_id, struct bnxt_ulp_context *ulp_ctx,
+ struct bnxt_ulp_df_rule_info *info);
+
#endif /* _BNXT_ULP_H_ */
return rc;
}
+
+void
+bnxt_ulp_destroy_df_rules(struct bnxt *bp, bool global)
+{
+ struct bnxt_ulp_df_rule_info *info;
+ uint8_t port_id;
+
+ if (!BNXT_TRUFLOW_EN(bp) ||
+ BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+ return;
+
+ if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
+ return;
+
+ /* Delete default rules per port */
+ if (!global) {
+ port_id = bp->eth_dev->data->port_id;
+ info = &bp->ulp_ctx->cfg_data->df_rule_info[port_id];
+ if (!info->valid)
+ return;
+
+ ulp_default_flow_destroy(bp->eth_dev,
+ info->port_to_app_flow_id);
+ ulp_default_flow_destroy(bp->eth_dev,
+ info->app_to_port_flow_id);
+ info->valid = false;
+ return;
+ }
+
+ /* Delete default rules for all ports */
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ info = &bp->ulp_ctx->cfg_data->df_rule_info[port_id];
+ if (!info->valid)
+ continue;
+
+ ulp_default_flow_destroy(bp->eth_dev,
+ info->port_to_app_flow_id);
+ ulp_default_flow_destroy(bp->eth_dev,
+ info->app_to_port_flow_id);
+ info->valid = false;
+ }
+}
+
+static int32_t
+bnxt_create_port_app_df_rule(struct bnxt *bp, uint8_t flow_type,
+ uint32_t *flow_id)
+{
+ uint16_t port_id = bp->eth_dev->data->port_id;
+ struct ulp_tlv_param param_list[] = {
+ {
+ .type = BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID,
+ .length = 2,
+ .value = {(port_id >> 8) & 0xff, port_id & 0xff}
+ },
+ {
+ .type = BNXT_ULP_DF_PARAM_TYPE_LAST,
+ .length = 0,
+ .value = {0}
+ }
+ };
+
+ return ulp_default_flow_create(bp->eth_dev, param_list, flow_type,
+ flow_id);
+}
+
+int32_t
+bnxt_ulp_create_df_rules(struct bnxt *bp)
+{
+ struct bnxt_ulp_df_rule_info *info;
+ uint8_t port_id;
+ int rc;
+
+ if (!BNXT_TRUFLOW_EN(bp) ||
+ BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+ return 0;
+
+ port_id = bp->eth_dev->data->port_id;
+ info = &bp->ulp_ctx->cfg_data->df_rule_info[port_id];
+ BNXT_TF_DBG(INFO, "*** creating port to app default rule ***\n");
+ rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_PORT_TO_VS,
+ &info->port_to_app_flow_id);
+ if (rc) {
+ PMD_DRV_LOG(ERR,
+ "Failed to create port to app default rule\n");
+ return rc;
+ }
+ BNXT_TF_DBG(INFO, "*** created port to app default rule ***\n");
+
+ bp->tx_cfa_action = 0;
+ BNXT_TF_DBG(INFO, "*** creating app to port default rule ***\n");
+ rc = bnxt_create_port_app_df_rule(bp, BNXT_ULP_DF_TPL_VS_TO_PORT,
+ &info->app_to_port_flow_id);
+ if (rc) {
+ PMD_DRV_LOG(ERR,
+ "Failed to create app to port default rule\n");
+ goto port_to_app_free;
+ }
+
+ rc = ulp_default_flow_db_cfa_action_get(bp->ulp_ctx,
+ info->app_to_port_flow_id,
+ &bp->tx_cfa_action);
+ if (rc)
+ goto app_to_port_free;
+
+ info->valid = true;
+ BNXT_TF_DBG(INFO, "*** created app to port default rule ***\n");
+ return 0;
+
+app_to_port_free:
+ ulp_default_flow_destroy(bp->eth_dev, info->app_to_port_flow_id);
+port_to_app_free:
+ ulp_default_flow_destroy(bp->eth_dev, info->port_to_app_flow_id);
+ info->valid = false;
+
+ return rc;
+}
int32_t
ulp_default_flow_db_cfa_action_get(struct bnxt_ulp_context *ulp_ctx,
uint32_t flow_id,
- uint32_t *cfa_action)
+ uint16_t *cfa_action)
{
uint8_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_CFA_ACTION;
uint64_t hndl;
int32_t
ulp_default_flow_db_cfa_action_get(struct bnxt_ulp_context *ulp_ctx,
uint32_t flow_id,
- uint32_t *cfa_action);
+ uint16_t *cfa_action);
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
/*