/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2019-2020 Broadcom
+ * Copyright(c) 2019-2021 Broadcom
* All rights reserved.
*/
#include "bnxt.h"
#include "rand.h"
#include "tf_common.h"
-#include "hwrm_tf.h"
+#include "tf_ext_flow_handle.h"
int
tf_open_session(struct tf *tfp,
* firmware open session succeeds.
*/
if (parms->device_type != TF_DEVICE_TYPE_WH &&
+ parms->device_type != TF_DEVICE_TYPE_THOR &&
parms->device_type != TF_DEVICE_TYPE_SR) {
TFP_DRV_LOG(ERR,
"Unsupported device type %d\n",
/* Verify control channel and build the beginning of session_id */
rc = sscanf(parms->ctrl_chan_name,
- "%x:%x:%x.%d",
+ "%x:%x:%x.%u",
&domain,
&bus,
&slot,
/* Check parsing of bus/slot/device */
rc = sscanf(parms->ctrl_chan_name,
- "%x:%x.%d",
+ "%x:%x.%u",
&bus,
&slot,
&device);
return rc;
TFP_DRV_LOG(INFO,
- "domain:%d, bus:%d, device:%d\n",
+ "domain:%d, bus:%d, device:%u\n",
parms->session_id.internal.domain,
parms->session_id.internal.bus,
parms->session_id.internal.device);
/* Verify control channel */
rc = sscanf(parms->ctrl_chan_name,
- "%x:%x:%x.%d",
+ "%x:%x:%x.%u",
&domain,
&bus,
&slot,
/* Verify 'attach' channel */
rc = sscanf(parms->attach_chan_name,
- "%x:%x:%x.%d",
+ "%x:%x:%x.%u",
&domain,
&bus,
&slot,
struct tf_session *tfs;
struct tf_dev_info *dev;
int rc;
+ unsigned int flag = 0;
TF_CHECK_PARMS2(tfp, parms);
return rc;
}
- if (parms->mem == TF_MEM_EXTERNAL)
- rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
- else if (parms->mem == TF_MEM_INTERNAL)
+ TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
+ if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
else
- return -EINVAL;
+ rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
if (rc) {
TFP_DRV_LOG(ERR,
return rc;
}
- if (dev->ops->tf_dev_set_tcam == NULL) {
+ if (dev->ops->tf_dev_set_tcam == NULL ||
+ dev->ops->tf_dev_word_align == NULL) {
rc = -EOPNOTSUPP;
TFP_DRV_LOG(ERR,
"%s: Operation not supported, rc:%s\n",
sparms.idx = parms->idx;
sparms.key = parms->key;
sparms.mask = parms->mask;
- sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
+ sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
sparms.result = parms->result;
sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
int
tf_get_tcam_entry(struct tf *tfp __rte_unused,
- struct tf_get_tcam_entry_parms *parms __rte_unused)
+ struct tf_get_tcam_entry_parms *parms)
{
+ int rc;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ struct tf_tcam_get_parms gparms;
+
TF_CHECK_PARMS2(tfp, parms);
- return -EOPNOTSUPP;
+
+ memset(&gparms, 0, sizeof(struct tf_tcam_get_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_get_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;
+ }
+
+ gparms.dir = parms->dir;
+ gparms.type = parms->tcam_tbl_type;
+ gparms.idx = parms->idx;
+ gparms.key = parms->key;
+ gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
+ gparms.mask = parms->mask;
+ gparms.result = parms->result;
+ gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
+
+ rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM get failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+ parms->key_sz_in_bits = gparms.key_size * 8;
+ parms->result_sz_in_bits = gparms.result_size * 8;
+
+ return 0;
}
int
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)
return 0;
}
-int
-tf_search_tbl_entry(struct tf *tfp,
- struct tf_search_tbl_entry_parms *parms)
-{
- int rc;
- struct tf_session *tfs;
- struct tf_dev_info *dev;
- struct tf_tbl_alloc_search_parms sparms;
-
- 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_alloc_search_tbl == NULL) {
- rc = -EOPNOTSUPP;
- TFP_DRV_LOG(ERR,
- "%s: Operation not supported, rc:%s\n",
- tf_dir_2_str(parms->dir),
- strerror(-rc));
- return rc;
- }
-
- memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
- sparms.dir = parms->dir;
- sparms.type = parms->type;
- sparms.result = parms->result;
- sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
- sparms.alloc = parms->alloc;
- sparms.tbl_scope_id = parms->tbl_scope_id;
- rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
- if (rc) {
- TFP_DRV_LOG(ERR,
- "%s: TBL allocation failed, rc:%s\n",
- tf_dir_2_str(parms->dir),
- strerror(-rc));
- return rc;
- }
-
- /* Return the outputs from the search */
- parms->hit = sparms.hit;
- parms->search_status = sparms.search_status;
- parms->ref_cnt = sparms.ref_cnt;
- parms->idx = sparms.idx;
-
- return 0;
-}
-
int
tf_free_tbl_entry(struct tf *tfp,
struct tf_free_tbl_entry_parms *parms)
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)
return 0;
}
+
+int tf_get_session_info(struct tf *tfp,
+ struct tf_get_session_info_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,
+ "Failed to lookup session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to lookup device, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ if (dev->ops->tf_dev_get_ident_resc_info == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "Operation not supported, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Ident get resc info failed, rc:%s\n",
+ strerror(-rc));
+ }
+
+ if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "Operation not supported, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Tbl get resc info failed, rc:%s\n",
+ strerror(-rc));
+ }
+
+ if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "Operation not supported, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "TCAM get resc info failed, rc:%s\n",
+ strerror(-rc));
+ }
+
+ if (dev->ops->tf_dev_get_em_resc_info == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "Operation not supported, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "EM get resc info failed, rc:%s\n",
+ strerror(-rc));
+ }
+
+ return 0;
+}