]> git.droids-corp.org - dpdk.git/commitdiff
net/bnxt: support two-level priority for TCAMs
authorShahaji Bhosle <sbhosle@broadcom.com>
Thu, 2 Jul 2020 23:28:01 +0000 (16:28 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:26 +0000 (23:38 +0200)
Allow TCAM indexes to be allocated from top or bottom.
If the priority is set to 0, allocate from the
lowest tcam indexes i.e. from top. Any other value,
allocate it from the highest tcam indexes i.e. from
bottom.

Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_core/tf_core.c
drivers/net/bnxt/tf_core/tf_core.h
drivers/net/bnxt/tf_core/tf_em.c
drivers/net/bnxt/tf_core/tf_tbl.c

index 81a88e2113b3db76f8ab0d08ae4de902c1ecf2e1..eac57e7bdaaf172b3d1cc5a77a834d55b6209917 100644 (file)
@@ -893,7 +893,7 @@ tf_alloc_tcam_entry(struct tf *tfp,
                    struct tf_alloc_tcam_entry_parms *parms)
 {
        int rc;
-       int index;
+       int index = 0;
        struct tf_session *tfs;
        struct bitalloc *session_pool;
 
@@ -916,12 +916,34 @@ tf_alloc_tcam_entry(struct tf *tfp,
        if (rc)
                return rc;
 
-       index = ba_alloc(session_pool);
-       if (index == BA_FAIL) {
-               PMD_DRV_LOG(ERR, "%s: %s: No resource available\n",
-                           tf_dir_2_str(parms->dir),
-                           tf_tcam_tbl_2_str(parms->tcam_tbl_type));
-               return -ENOMEM;
+       /*
+        * priority  0: allocate from top of the tcam i.e. high
+        * priority !0: allocate index from bottom i.e lowest
+        */
+       if (parms->priority) {
+               for (index = session_pool->size - 1; index >= 0; index--) {
+                       if (ba_inuse(session_pool,
+                                         index) == BA_ENTRY_FREE) {
+                               break;
+                       }
+               }
+               if (ba_alloc_index(session_pool,
+                                  index) == BA_FAIL) {
+                       TFP_DRV_LOG(ERR,
+                                   "%s: %s: ba_alloc index %d failed\n",
+                                   tf_dir_2_str(parms->dir),
+                                   tf_tcam_tbl_2_str(parms->tcam_tbl_type),
+                                   index);
+                       return -ENOMEM;
+               }
+       } else {
+               index = ba_alloc(session_pool);
+               if (index == BA_FAIL) {
+                       TFP_DRV_LOG(ERR, "%s: %s: Out of resource\n",
+                                   tf_dir_2_str(parms->dir),
+                                   tf_tcam_tbl_2_str(parms->tcam_tbl_type));
+                       return -ENOMEM;
+               }
        }
 
        parms->idx = index;
index 74ed24e5ad119b6b952bc9708c590a6e338abff3..f1ef00b304e9cd143330974c869759dfd449d07e 100644 (file)
@@ -799,7 +799,9 @@ struct tf_alloc_tcam_entry_parms {
         */
        uint8_t *mask;
        /**
-        * [in] Priority of entry requested (definition TBD)
+        * [in] Priority of entry requested
+        * 0: index from top i.e. highest priority first
+        * !0: index from bottom i.e lowest priority first
         */
        uint32_t priority;
        /**
index fd1797e39049b261359932fc18d3fbcede80396a..91cbc629975eb7524723d6e0b09e5de06dc77527 100644 (file)
@@ -479,8 +479,7 @@ int tf_insert_em_internal_entry(struct tf *tfp,
        rc = stack_pop(pool, &index);
 
        if (rc != 0) {
-               PMD_DRV_LOG
-                  (ERR,
+               TFP_DRV_LOG(ERR,
                   "dir:%d, EM entry index allocation failed\n",
                   parms->dir);
                return rc;
@@ -495,8 +494,7 @@ int tf_insert_em_internal_entry(struct tf *tfp,
        if (rc != 0)
                return -1;
 
-       PMD_DRV_LOG
-                  (ERR,
+       TFP_DRV_LOG(INFO,
                   "Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
                   index * TF_SESSION_EM_ENTRY_SIZE,
                   rptr_index,
index 26313ed3c214af8cc63469fb2fe41e3dddb968fe..4e236d56c06f7d26272ac4359dd69e32df2fcc22 100644 (file)
@@ -1967,7 +1967,7 @@ void tf_dump_dma(struct tf *tfp, uint32_t tbl_scope_id)
        tbl_scope_cb = tbl_scope_cb_find(session,
                                         tbl_scope_id);
        if (tbl_scope_cb == NULL)
-               PMD_DRV_LOG(ERR, "No table scope\n");
+               TFP_DRV_LOG(ERR, "No table scope\n");
 
        for (dir = 0; dir < TF_DIR_MAX; dir++) {
                printf("Direction %s:\n", (dir == TF_DIR_RX ? "Rx" : "Tx"));