#include "bnxt_txr.h"
#include "bnxt_hwrm.h"
#include "hsi_struct_def_dpdk.h"
+#include "bnxt_tf_common.h"
+#include "ulp_port_db.h"
+#include "ulp_flow_db.h"
static const struct eth_dev_ops bnxt_vf_rep_dev_ops = {
.dev_infos_get = bnxt_vf_rep_dev_info_get_op,
};
uint16_t
-bnxt_vfr_recv(struct bnxt *bp, uint16_t cfa_code, uint16_t queue_id,
- struct rte_mbuf *mbuf)
+bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
{
struct bnxt_sw_rx_bd *prod_rx_buf;
struct bnxt_rx_ring_info *rep_rxr;
struct bnxt_rx_queue *rep_rxq;
struct rte_eth_dev *vfr_eth_dev;
struct bnxt_vf_representor *vfr_bp;
- uint16_t vf_id;
uint16_t mask;
uint8_t que;
- vf_id = bp->cfa_code_map[cfa_code];
- /* cfa_code is invalid OR vf_id > MAX REP. Assume normal Rx */
- if (vf_id == BNXT_VF_IDX_INVALID || vf_id > BNXT_MAX_VF_REPS)
- return 1;
- vfr_eth_dev = bp->rep_info[vf_id].vfr_eth_dev;
+ vfr_eth_dev = &rte_eth_devices[port_id];
if (!vfr_eth_dev)
return 1;
vfr_bp = vfr_eth_dev->data->dev_private;
- if (vfr_bp->rx_cfa_code != cfa_code) {
- /* cfa_code not meant for this VF rep!!?? */
- return 1;
- }
/* If rxq_id happens to be > max rep_queue, use rxq0 */
que = queue_id < BNXT_MAX_VF_REP_RINGS ? queue_id : 0;
rep_rxq = vfr_bp->rx_queues[que];
pthread_mutex_lock(&parent->rep_info->vfr_lock);
ptxq = parent->tx_queues[qid];
- ptxq->tx_cfa_action = vf_rep_bp->tx_cfa_action;
+ ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action;
for (i = 0; i < nb_pkts; i++) {
vf_rep_bp->tx_bytes[qid] += tx_pkts[i]->pkt_len;
}
rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts);
- ptxq->tx_cfa_action = 0;
+ ptxq->vfr_tx_cfa_action = 0;
pthread_mutex_unlock(&parent->rep_info->vfr_lock);
return rc;
return rc;
}
-static int bnxt_vfr_alloc(struct bnxt_vf_representor *vfr)
+static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
+{
+ int rc;
+ struct bnxt_vf_representor *vfr = vfr_ethdev->data->dev_private;
+ struct rte_eth_dev *parent_dev = vfr->parent_dev;
+ struct bnxt *parent_bp = parent_dev->data->dev_private;
+ uint16_t vfr_port_id = vfr_ethdev->data->port_id;
+ struct ulp_tlv_param param_list[] = {
+ {
+ .type = BNXT_ULP_DF_PARAM_TYPE_DEV_PORT_ID,
+ .length = 2,
+ .value = {(vfr_port_id >> 8) & 0xff, vfr_port_id & 0xff}
+ },
+ {
+ .type = BNXT_ULP_DF_PARAM_TYPE_LAST,
+ .length = 0,
+ .value = {0}
+ }
+ };
+
+ ulp_port_db_dev_port_intf_update(parent_bp->ulp_ctx, vfr_ethdev);
+
+ rc = ulp_default_flow_create(parent_dev, param_list,
+ BNXT_ULP_DF_TPL_VFREP_TO_VF,
+ &vfr->rep2vf_flow_id);
+ if (rc) {
+ BNXT_TF_DBG(DEBUG,
+ "Default flow rule creation for VFR->VF failed!\n");
+ return -EIO;
+ }
+
+ BNXT_TF_DBG(DEBUG, "*** Default flow rule created for VFR->VF! ***\n");
+ BNXT_TF_DBG(DEBUG, "rep2vf_flow_id = %d\n", vfr->rep2vf_flow_id);
+ rc = ulp_default_flow_db_cfa_action_get(parent_bp->ulp_ctx,
+ vfr->rep2vf_flow_id,
+ &vfr->vfr_tx_cfa_action);
+ if (rc) {
+ BNXT_TF_DBG(DEBUG,
+ "Failed to get action_ptr for VFR->VF dflt rule\n");
+ return -EIO;
+ }
+ BNXT_TF_DBG(DEBUG, "tx_cfa_action = %d\n", vfr->vfr_tx_cfa_action);
+ rc = ulp_default_flow_create(parent_dev, param_list,
+ BNXT_ULP_DF_TPL_VF_TO_VFREP,
+ &vfr->vf2rep_flow_id);
+ if (rc) {
+ BNXT_TF_DBG(DEBUG,
+ "Default flow rule creation for VF->VFR failed!\n");
+ return -EIO;
+ }
+
+ BNXT_TF_DBG(DEBUG, "*** Default flow rule created for VF->VFR! ***\n");
+ BNXT_TF_DBG(DEBUG, "vfr2rep_flow_id = %d\n", vfr->vf2rep_flow_id);
+
+ return 0;
+}
+
+static int bnxt_vfr_alloc(struct rte_eth_dev *vfr_ethdev)
{
int rc = 0;
- struct bnxt *parent_bp;
+ struct bnxt_vf_representor *vfr = vfr_ethdev->data->dev_private;
if (!vfr || !vfr->parent_dev) {
PMD_DRV_LOG(ERR,
return -ENOMEM;
}
- parent_bp = vfr->parent_dev->data->dev_private;
-
/* Check if representor has been already allocated in FW */
- if (vfr->tx_cfa_action && vfr->rx_cfa_code)
+ if (vfr->vfr_tx_cfa_action && vfr->rx_cfa_code)
return 0;
/*
* Otherwise the FW will create the VF-rep rules with
* default drop action.
*/
-
- /*
- * This is where we need to replace invoking an HWRM cmd
- * with the new TFLIB ULP API to do more/less the same job
- rc = bnxt_hwrm_cfa_vfr_alloc(parent_bp,
- vfr->vf_id,
- &vfr->tx_cfa_action,
- &vfr->rx_cfa_code);
- */
- if (!rc) {
- parent_bp->cfa_code_map[vfr->rx_cfa_code] = vfr->vf_id;
+ rc = bnxt_tf_vfr_alloc(vfr_ethdev);
+ if (!rc)
PMD_DRV_LOG(DEBUG, "allocated representor %d in FW\n",
vfr->vf_id);
- } else {
+ else
PMD_DRV_LOG(ERR,
"Failed to alloc representor %d in FW\n",
vfr->vf_id);
- }
return rc;
}
struct bnxt_vf_representor *rep_bp = eth_dev->data->dev_private;
int rc;
- rc = bnxt_vfr_alloc(rep_bp);
+ rc = bnxt_vfr_alloc(eth_dev);
if (!rc) {
eth_dev->rx_pkt_burst = &bnxt_vf_rep_rx_burst;
return rc;
}
+static int bnxt_tf_vfr_free(struct bnxt_vf_representor *vfr)
+{
+ int rc = 0;
+
+ rc = ulp_default_flow_destroy(vfr->parent_dev,
+ vfr->rep2vf_flow_id);
+ if (rc)
+ PMD_DRV_LOG(ERR,
+ "default flow destroy failed rep2vf flowid: %d\n",
+ vfr->rep2vf_flow_id);
+ rc = ulp_default_flow_destroy(vfr->parent_dev,
+ vfr->vf2rep_flow_id);
+ if (rc)
+ PMD_DRV_LOG(ERR,
+ "default flow destroy failed vf2rep flowid: %d\n",
+ vfr->vf2rep_flow_id);
+ return 0;
+}
+
static int bnxt_vfr_free(struct bnxt_vf_representor *vfr)
{
int rc = 0;
parent_bp = vfr->parent_dev->data->dev_private;
/* Check if representor has been already freed in FW */
- if (!vfr->tx_cfa_action && !vfr->rx_cfa_code)
+ if (!vfr->vfr_tx_cfa_action && !vfr->rx_cfa_code)
return 0;
- /*
- * This is where we need to replace invoking an HWRM cmd
- * with the new TFLIB ULP API to do more/less the same job
- rc = bnxt_hwrm_cfa_vfr_free(parent_bp,
- vfr->vf_id);
- */
+ rc = bnxt_tf_vfr_free(vfr);
if (rc) {
PMD_DRV_LOG(ERR,
"Failed to free representor %d in FW\n",
parent_bp->cfa_code_map[vfr->rx_cfa_code] = BNXT_VF_IDX_INVALID;
PMD_DRV_LOG(DEBUG, "freed representor %d in FW\n",
vfr->vf_id);
- vfr->tx_cfa_action = 0;
+ vfr->vfr_tx_cfa_action = 0;
vfr->rx_cfa_code = 0;
return rc;
}
#endif
-static void
+static uint32_t
bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
- struct rte_mbuf *mbuf)
+ struct rte_mbuf *mbuf, uint32_t *vfr_flag)
{
uint32_t cfa_code;
uint32_t meta_fmt;
uint32_t flags2;
uint32_t gfid_support = 0;
int rc;
- uint32_t vfr_flag;
-
if (BNXT_GFID_ENABLED(bp))
gfid_support = 1;
}
rc = ulp_mark_db_mark_get(bp->ulp_ctx, gfid,
- cfa_code, &vfr_flag, &mark_id);
+ cfa_code, vfr_flag, &mark_id);
if (!rc) {
/* Got the mark, write it to the mbuf and return */
mbuf->hash.fdir.hi = mark_id;
mbuf->udata64 = (cfa_code & 0xffffffffull) << 32;
mbuf->hash.fdir.id = rxcmp1->cfa_code;
mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
- return;
+ return mark_id;
}
skip_mark:
mbuf->hash.fdir.hi = 0;
mbuf->hash.fdir.id = 0;
+
+ return 0;
}
void bnxt_set_mark_in_mbuf(struct bnxt *bp,
int rc = 0;
uint8_t agg_buf = 0;
uint16_t cmp_type;
- uint32_t flags2_f = 0;
+ uint32_t flags2_f = 0, vfr_flag = 0, mark_id = 0;
uint16_t flags_type;
struct bnxt *bp = rxq->bp;
}
if (BNXT_TRUFLOW_EN(bp))
- bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
+ mark_id = bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf,
+ &vfr_flag);
else
bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
rx:
*rx_pkt = mbuf;
- if ((BNXT_VF_IS_TRUSTED(rxq->bp) || BNXT_PF(rxq->bp)) &&
- rxq->bp->cfa_code_map && rxcmp1->cfa_code) {
- if (!bnxt_vfr_recv(rxq->bp, rxcmp1->cfa_code, rxq->queue_id,
- mbuf)) {
+ if (BNXT_TRUFLOW_EN(bp) &&
+ (BNXT_VF_IS_TRUSTED(bp) || BNXT_PF(bp)) &&
+ vfr_flag) {
+ if (!bnxt_vfr_recv(mark_id, rxq->queue_id, mbuf)) {
/* Now return an error so that nb_rx_pkts is not
* incremented.
* This packet was meant to be given to the representor.