net/bnxt: enable filter ctrl ops for port representor
[dpdk.git] / drivers / net / bnxt / tf_ulp / bnxt_ulp.c
index 1b52861..397d0a9 100644 (file)
@@ -18,6 +18,7 @@
 #include "ulp_template_db_enum.h"
 #include "ulp_template_struct.h"
 #include "ulp_mark_mgr.h"
+#include "ulp_fc_mgr.h"
 #include "ulp_flow_db.h"
 #include "ulp_mapper.h"
 #include "ulp_port_db.h"
@@ -102,6 +103,9 @@ ulp_ctx_session_open(struct bnxt *bp,
        /* EM */
        resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 2048;
 
+       /* EEM */
+       resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
+
        /** TX **/
        /* Identifiers */
        resources->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT] = 8;
@@ -126,9 +130,11 @@ ulp_ctx_session_open(struct bnxt *bp,
        resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 8;
 
        /* EEM */
-       resources->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
        resources->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
 
+       /* SP */
+       resources->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = 128;
+
        rc = tf_open_session(&bp->tfp, &params);
        if (rc) {
                BNXT_TF_DBG(ERR, "Failed to open TF session - %s, rc = %d\n",
@@ -588,7 +594,7 @@ bnxt_ulp_init(struct bnxt *bp)
        int rc;
 
        if (bp->ulp_ctx) {
-               BNXT_TF_DBG(ERR, "ulp ctx already allocated\n");
+               BNXT_TF_DBG(DEBUG, "ulp ctx already allocated\n");
                return -EINVAL;
        }
 
@@ -658,7 +664,7 @@ bnxt_ulp_init(struct bnxt *bp)
        rc = ulp_dparms_init(bp, bp->ulp_ctx);
 
        /* create the port database */
-       rc = ulp_port_db_init(bp->ulp_ctx);
+       rc = ulp_port_db_init(bp->ulp_ctx, bp->port_cnt);
        if (rc) {
                BNXT_TF_DBG(ERR, "Failed to create the port database\n");
                goto jump_to_error;
@@ -705,6 +711,12 @@ bnxt_ulp_init(struct bnxt *bp)
                goto jump_to_error;
        }
 
+       rc = ulp_fc_mgr_init(bp->ulp_ctx);
+       if (rc) {
+               BNXT_TF_DBG(ERR, "Failed to initialize ulp flow counter mgr\n");
+               goto jump_to_error;
+       }
+
        return rc;
 
 jump_to_error:
@@ -752,6 +764,9 @@ bnxt_ulp_deinit(struct bnxt *bp)
        /* cleanup the ulp mapper */
        ulp_mapper_deinit(bp->ulp_ctx);
 
+       /* Delete the Flow Counter Manager */
+       ulp_fc_mgr_deinit(bp->ulp_ctx);
+
        /* Delete the Port database */
        ulp_port_db_deinit(bp->ulp_ctx);
 
@@ -908,9 +923,13 @@ bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context    *ulp_ctx)
 struct bnxt_ulp_context        *
 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev     *dev)
 {
-       struct bnxt     *bp;
+       struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
+
+       if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+               struct bnxt_vf_representor *vfr = dev->data->dev_private;
+               bp = vfr->parent_dev->data->dev_private;
+       }
 
-       bp = (struct bnxt *)dev->data->dev_private;
        if (!bp) {
                BNXT_TF_DBG(ERR, "Bnxt private data is not initialized\n");
                return NULL;
@@ -963,3 +982,28 @@ bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context    *ulp_ctx)
 
        return ulp_ctx->cfg_data->port_db;
 }
+
+/* Function to set the flow counter info into the context */
+int32_t
+bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
+                               struct bnxt_ulp_fc_info *ulp_fc_info)
+{
+       if (!ulp_ctx || !ulp_ctx->cfg_data) {
+               BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+               return -EINVAL;
+       }
+
+       ulp_ctx->cfg_data->fc_info = ulp_fc_info;
+
+       return 0;
+}
+
+/* Function to retrieve the flow counter info from the context. */
+struct bnxt_ulp_fc_info *
+bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx)
+{
+       if (!ulp_ctx || !ulp_ctx->cfg_data)
+               return NULL;
+
+       return ulp_ctx->cfg_data->fc_info;
+}