net/bnxt: add conditional processing of templates
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.c
index 69f5c10..97e6165 100644 (file)
@@ -27,8 +27,6 @@ tf_open_session(struct tf *tfp,
        int rc;
        unsigned int domain, bus, slot, device;
        struct tf_session_open_session_parms oparms;
-       int name_len;
-       char *name;
 
        TF_CHECK_PARMS2(tfp, parms);
 
@@ -71,13 +69,6 @@ tf_open_session(struct tf *tfp,
                }
        }
 
-       name_len = strlen(parms->ctrl_chan_name);
-       name = &parms->ctrl_chan_name[name_len - strlen("tf_shared")];
-       if (!strncmp(name, "tf_shared", strlen("tf_shared"))) {
-               memset(parms->ctrl_chan_name, 0, strlen(parms->ctrl_chan_name));
-               strcpy(parms->ctrl_chan_name, "tf_share");
-       }
-
        parms->session_id.internal.domain = domain;
        parms->session_id.internal.bus = bus;
        parms->session_id.internal.device = device;
@@ -926,6 +917,110 @@ tf_free_tcam_entry(struct tf *tfp,
        return 0;
 }
 
+#ifdef TF_TCAM_SHARED
+int
+tf_move_tcam_shared_entries(struct tf *tfp,
+                           struct tf_move_tcam_shared_entries_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_move_tcam == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_move_tcam(tfp, parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: TCAM shared entries move failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}
+
+int
+tf_clear_tcam_shared_entries(struct tf *tfp,
+                            struct tf_clear_tcam_shared_entries_parms *parms)
+{
+       int rc;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       if (dev->ops->tf_dev_clear_tcam == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       rc = dev->ops->tf_dev_clear_tcam(tfp, parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: TCAM shared entries clear failed, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return 0;
+}
+#endif /* TF_TCAM_SHARED */
+
 int
 tf_alloc_tbl_entry(struct tf *tfp,
                   struct tf_alloc_tbl_entry_parms *parms)
@@ -1371,6 +1466,58 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
        return rc;
 }
 
+int tf_get_shared_tbl_increment(struct tf *tfp,
+                               struct tf_get_shared_tbl_increment_parms *parms)
+{
+       int rc = 0;
+       struct tf_session *tfs;
+       struct tf_dev_info *dev;
+
+       TF_CHECK_PARMS2(tfp, parms);
+
+       /* Retrieve the session information */
+       rc = tf_session_get_session(tfp, &tfs);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup session, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Retrieve the device information */
+       rc = tf_session_get_device(tfs, &dev);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Failed to lookup device, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       /* Internal table type processing */
+
+       if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) {
+               rc = -EOPNOTSUPP;
+               TFP_DRV_LOG(ERR,
+                           "%s: Operation not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return -EOPNOTSUPP;
+       }
+
+       rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms);
+       if (rc) {
+               TFP_DRV_LOG(ERR,
+                           "%s: Get table increment not supported, rc:%s\n",
+                           tf_dir_2_str(parms->dir),
+                           strerror(-rc));
+               return rc;
+       }
+
+       return rc;
+}
+
 int
 tf_alloc_tbl_scope(struct tf *tfp,
                   struct tf_alloc_tbl_scope_parms *parms)
@@ -1645,7 +1792,6 @@ int tf_get_session_info(struct tf *tfp,
                TFP_DRV_LOG(ERR,
                            "Ident get resc info failed, rc:%s\n",
                            strerror(-rc));
-               return rc;
        }
 
        if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
@@ -1661,7 +1807,6 @@ int tf_get_session_info(struct tf *tfp,
                TFP_DRV_LOG(ERR,
                            "Tbl get resc info failed, rc:%s\n",
                            strerror(-rc));
-               return rc;
        }
 
        if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
@@ -1677,7 +1822,6 @@ int tf_get_session_info(struct tf *tfp,
                TFP_DRV_LOG(ERR,
                            "TCAM get resc info failed, rc:%s\n",
                            strerror(-rc));
-               return rc;
        }
 
        if (dev->ops->tf_dev_get_em_resc_info == NULL) {
@@ -1693,7 +1837,6 @@ int tf_get_session_info(struct tf *tfp,
                TFP_DRV_LOG(ERR,
                            "EM get resc info failed, rc:%s\n",
                            strerror(-rc));
-               return rc;
        }
 
        return 0;