eal: remove sys/queue.h from public headers
[dpdk.git] / drivers / net / bnxt / tf_core / tf_tcam.c
index 5c018f7..273f208 100644 (file)
@@ -43,7 +43,7 @@ tf_tcam_bind(struct tf *tfp,
        struct tf_shadow_tcam_free_db_parms fshadow;
        struct tf_shadow_tcam_cfg_parms shadow_cfg;
        struct tf_shadow_tcam_create_db_parms shadow_cdb;
-       uint16_t num_slices = 1;
+       uint16_t num_slices = parms->wc_num_slices;
        struct tf_session *tfs;
        struct tf_dev_info *dev;
        struct tcam_rm_db *tcam_db;
@@ -61,7 +61,7 @@ tf_tcam_bind(struct tf *tfp,
        if (rc)
                return rc;
 
-       if (dev->ops->tf_dev_get_tcam_slice_info == NULL) {
+       if (dev->ops->tf_dev_set_tcam_slice_info == NULL) {
                rc = -EOPNOTSUPP;
                TFP_DRV_LOG(ERR,
                            "Operation not supported, rc:%s\n",
@@ -69,10 +69,8 @@ tf_tcam_bind(struct tf *tfp,
                return rc;
        }
 
-       rc = dev->ops->tf_dev_get_tcam_slice_info(tfp,
-                                                 TF_TCAM_TBL_TYPE_WC_TCAM,
-                                                 0,
-                                                 &num_slices);
+       rc = dev->ops->tf_dev_set_tcam_slice_info(tfp,
+                                                 num_slices);
        if (rc)
                return rc;
 
@@ -113,16 +111,13 @@ tf_tcam_bind(struct tf *tfp,
                        db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
                else
                        db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
-               if (db_rc[d]) {
-                       TFP_DRV_LOG(INFO,
-                                   "%s: no TCAM DB required\n",
-                                   tf_dir_2_str(d));
-               }
        }
 
        /* No db created */
-       if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+       if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {
+               TFP_DRV_LOG(ERR, "No TCAM DB created\n");
                return db_rc[TF_DIR_RX];
+       }
 
        /* check if reserved resource for WC is multiple of num_slices */
        for (d = 0; d < TF_DIR_MAX; d++) {
@@ -227,9 +222,6 @@ tf_tcam_unbind(struct tf *tfp)
 
        rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
        if (rc) {
-               TFP_DRV_LOG(INFO,
-                           "Tcam_db is not initialized, rc:%s\n",
-                           strerror(-rc));
                return 0;
        }
        tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
@@ -305,7 +297,7 @@ tf_tcam_alloc(struct tf *tfp,
        rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
        if (rc) {
                TFP_DRV_LOG(ERR,
-                           "Failed to get em_ext_db from session, rc:%s\n",
+                           "Failed to get tcam_db from session, rc:%s\n",
                            strerror(-rc));
                return rc;
        }
@@ -331,8 +323,12 @@ tf_tcam_alloc(struct tf *tfp,
                }
 
                /* return the start index of each row */
-               if (i == 0)
+               if (parms->priority == 0) {
+                       if (i == 0)
+                               parms->idx = index;
+               } else {
                        parms->idx = index;
+               }
        }
 
        return 0;
@@ -824,16 +820,20 @@ tf_tcam_get_resc_info(struct tf *tfp,
        TF_CHECK_PARMS2(tfp, tcam);
 
        rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
-       if (rc) {
-               TFP_DRV_LOG(INFO,
-                           "No resource allocated for tcam from session\n");
-               return 0;
-       }
+       if (rc == -ENOMEM)
+               return 0;  /* db doesn't exist */
+       else if (rc)
+               return rc; /* error getting db */
+
        tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
 
        /* check if reserved resource for WC is multiple of num_slices */
        for (d = 0; d < TF_DIR_MAX; d++) {
                ainfo.rm_db = tcam_db->tcam_db[d];
+
+               if (!ainfo.rm_db)
+                       continue;
+
                dinfo = tcam[d].info;
 
                ainfo.info = (struct tf_rm_alloc_info *)dinfo;