#include "hcapi_cfa_defs.h"
+#if CHIP_CFG == SR_A
+#define SUPPORT_CFA_HW_P45 1
+#undef SUPPORT_CFA_HW_P4
+#define SUPPORT_CFA_HW_P4 0
+#elif CHIP_CFG == CMB_A
#define SUPPORT_CFA_HW_P4 1
+#else
+#error "Chip not supported"
+#endif
#if SUPPORT_CFA_HW_P4 && SUPPORT_CFA_HW_P58 && SUPPORT_CFA_HW_P59
#define SUPPORT_CFA_HW_ALL 1
/* common CFA register access macros */
#define CFA_REG(x) OFFSETOF(cfa_reg_t, cfa_##x)
-#ifndef REG_WR
-#define REG_WR(_p, x, y) (*((uint32_t volatile *)(x)) = (y))
+#ifndef TF_REG_WR
+#define TF_REG_WR(_p, x, y) (*((uint32_t volatile *)(x)) = (y))
#endif
-#ifndef REG_RD
-#define REG_RD(_p, x) (*((uint32_t volatile *)(x)))
+#ifndef TF_REG_RD
+#define TF_REG_RD(_p, x) (*((uint32_t volatile *)(x)))
+#endif
+#ifndef TF_CFA_REG_RD
+#define TF_CFA_REG_RD(_p, x) \
+ TF_REG_RD(0, (uint32_t)(_p)->base_addr + CFA_REG(x))
+#endif
+#ifndef TF_CFA_REG_WR
+#define TF_CFA_REG_WR(_p, x, y) \
+ TF_REG_WR(0, (uint32_t)(_p)->base_addr + CFA_REG(x), y)
#endif
-#define CFA_REG_RD(_p, x) \
- REG_RD(0, (uint32_t)(_p)->base_addr + CFA_REG(x))
-#define CFA_REG_WR(_p, x, y) \
- REG_WR(0, (uint32_t)(_p)->base_addr + CFA_REG(x), y)
-
/* Constants used by Resource Manager Registration*/
#define RM_CLIENT_NAME_MAX_LEN 32
int hcapi_cfa_p4_global_cfg_hwop(struct hcapi_cfa_hwop *op,
uint32_t type,
struct hcapi_cfa_data *config);
-#endif /* SUPPORT_CFA_HW_P4 */
+/* SUPPORT_CFA_HW_P4 */
+#elif SUPPORT_CFA_HW_P45
+int hcapi_cfa_p45_mirror_hwop(struct hcapi_cfa_hwop *op,
+ struct hcapi_cfa_data *mirror);
+int hcapi_cfa_p45_global_cfg_hwop(struct hcapi_cfa_hwop *op,
+ uint32_t type,
+ struct hcapi_cfa_data *config);
+/* SUPPORT_CFA_HW_P45 */
+#endif
/**
* HCAPI CFA device HW operation function callback definition
* This is standardized function callback hook to install different
#define CFA_RESOURCE_TYPE_P59_LAST CFA_RESOURCE_TYPE_P59_VEB_TCAM
-/* Multicast Group */
-#define CFA_RESOURCE_TYPE_P58_MCG 0x0UL
-/* Encap 8 byte record */
-#define CFA_RESOURCE_TYPE_P58_ENCAP_8B 0x1UL
-/* Encap 16 byte record */
-#define CFA_RESOURCE_TYPE_P58_ENCAP_16B 0x2UL
-/* Encap 64 byte record */
-#define CFA_RESOURCE_TYPE_P58_ENCAP_64B 0x3UL
-/* Source Property MAC */
-#define CFA_RESOURCE_TYPE_P58_SP_MAC 0x4UL
-/* Source Property MAC and IPv4 */
-#define CFA_RESOURCE_TYPE_P58_SP_MAC_IPV4 0x5UL
-/* Source Property MAC and IPv6 */
-#define CFA_RESOURCE_TYPE_P58_SP_MAC_IPV6 0x6UL
-/* Network Address Translation Port */
-#define CFA_RESOURCE_TYPE_P58_NAT_PORT 0x7UL
-/* Network Address Translation IPv4 address */
-#define CFA_RESOURCE_TYPE_P58_NAT_IPV4 0x8UL
/* Meter */
-#define CFA_RESOURCE_TYPE_P58_METER 0x9UL
-/* Flow State */
-#define CFA_RESOURCE_TYPE_P58_FLOW_STATE 0xaUL
-/* Full Action Records */
-#define CFA_RESOURCE_TYPE_P58_FULL_ACTION 0xbUL
-/* Action Record Format 0 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_0_ACTION 0xcUL
-/* Action Record Ext Format 0 */
-#define CFA_RESOURCE_TYPE_P58_EXT_FORMAT_0_ACTION 0xdUL
-/* Action Record Format 1 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_1_ACTION 0xeUL
-/* Action Record Format 2 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_2_ACTION 0xfUL
-/* Action Record Format 3 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_3_ACTION 0x10UL
-/* Action Record Format 4 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_4_ACTION 0x11UL
-/* Action Record Format 5 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_5_ACTION 0x12UL
-/* Action Record Format 6 */
-#define CFA_RESOURCE_TYPE_P58_FORMAT_6_ACTION 0x13UL
+#define CFA_RESOURCE_TYPE_P58_METER 0x0UL
+/* SRAM_Bank_0 */
+#define CFA_RESOURCE_TYPE_P58_SRAM_BANK_0 0x1UL
+/* SRAM_Bank_1 */
+#define CFA_RESOURCE_TYPE_P58_SRAM_BANK_1 0x2UL
+/* SRAM_Bank_2 */
+#define CFA_RESOURCE_TYPE_P58_SRAM_BANK_2 0x3UL
+/* SRAM_Bank_3 */
+#define CFA_RESOURCE_TYPE_P58_SRAM_BANK_3 0x4UL
/* L2 Context TCAM High priority entries */
-#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH 0x14UL
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_HIGH 0x5UL
/* L2 Context TCAM Low priority entries */
-#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW 0x15UL
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_TCAM_LOW 0x6UL
/* L2 Context REMAP high priority entries */
-#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH 0x16UL
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_HIGH 0x7UL
/* L2 Context REMAP Low priority entries */
-#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW 0x17UL
+#define CFA_RESOURCE_TYPE_P58_L2_CTXT_REMAP_LOW 0x8UL
/* Profile Func */
-#define CFA_RESOURCE_TYPE_P58_PROF_FUNC 0x18UL
+#define CFA_RESOURCE_TYPE_P58_PROF_FUNC 0x9UL
/* Profile TCAM */
-#define CFA_RESOURCE_TYPE_P58_PROF_TCAM 0x19UL
+#define CFA_RESOURCE_TYPE_P58_PROF_TCAM 0xaUL
/* Exact Match Profile Id */
-#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID 0x1aUL
+#define CFA_RESOURCE_TYPE_P58_EM_PROF_ID 0xbUL
/* Wildcard Profile Id */
-#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID 0x1bUL
+#define CFA_RESOURCE_TYPE_P58_WC_TCAM_PROF_ID 0xcUL
/* Exact Match Record */
-#define CFA_RESOURCE_TYPE_P58_EM_REC 0x1cUL
+#define CFA_RESOURCE_TYPE_P58_EM_REC 0xdUL
/* Wildcard TCAM */
-#define CFA_RESOURCE_TYPE_P58_WC_TCAM 0x1dUL
+#define CFA_RESOURCE_TYPE_P58_WC_TCAM 0xeUL
/* Meter profile */
-#define CFA_RESOURCE_TYPE_P58_METER_PROF 0x1eUL
+#define CFA_RESOURCE_TYPE_P58_METER_PROF 0xfUL
/* Meter */
-#define CFA_RESOURCE_TYPE_P58_MIRROR 0x1fUL
-/* Source Property TCAM */
-#define CFA_RESOURCE_TYPE_P58_SP_TCAM 0x20UL
+#define CFA_RESOURCE_TYPE_P58_MIRROR 0x10UL
/* Exact Match Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P58_EM_FKB 0x21UL
+#define CFA_RESOURCE_TYPE_P58_EM_FKB 0x11UL
/* Wildcard Flexible Key Builder */
-#define CFA_RESOURCE_TYPE_P58_WC_FKB 0x22UL
+#define CFA_RESOURCE_TYPE_P58_WC_FKB 0x12UL
/* VEB TCAM */
-#define CFA_RESOURCE_TYPE_P58_VEB_TCAM 0x23UL
-#define CFA_RESOURCE_TYPE_P58_LAST CFA_RESOURCE_TYPE_P58_VEB_TCAM
+#define CFA_RESOURCE_TYPE_P58_VEB_TCAM 0x13UL
+#define CFA_RESOURCE_TYPE_P58_LAST CFA_RESOURCE_TYPE_P58_VEB_TCAM
/* Multicast Group */
* side. It is assumed that the Firmware will be supported if
* firmware open session succeeds.
*/
- if (parms->device_type != TF_DEVICE_TYPE_WH) {
+ if (parms->device_type != TF_DEVICE_TYPE_WH &&
+ parms->device_type != TF_DEVICE_TYPE_SR) {
TFP_DRV_LOG(ERR,
"Unsupported device type %d\n",
parms->device_type);
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
-#include "hcapi/hcapi_cfa.h"
+#include "hcapi/hcapi_cfa_defs.h"
#include "tf_project.h"
/**
struct tf_if_tbl_cfg_parms if_tbl_cfg;
struct tf_global_cfg_cfg_parms global_cfg;
- dev_handle->type = TF_DEVICE_TYPE_WH;
/* Initial function initialization */
dev_handle->ops = &tf_dev_ops_p4_init;
* EEM
*/
em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
- em_cfg.cfg = tf_em_ext_p4;
+ if (dev_handle->type == TF_DEVICE_TYPE_WH)
+ em_cfg.cfg = tf_em_ext_p4;
+ else
+ em_cfg.cfg = tf_em_ext_p45;
em_cfg.resources = resources;
em_cfg.mem_type = TF_EEM_MEM_TYPE_HOST;
rc = tf_em_ext_common_bind(tfp, &em_cfg);
{
switch (type) {
case TF_DEVICE_TYPE_WH:
+ case TF_DEVICE_TYPE_SR:
+ dev_handle->type = type;
return tf_dev_bind_p4(tfp,
shadow_copy,
resources,
{
switch (dev_handle->type) {
case TF_DEVICE_TYPE_WH:
+ case TF_DEVICE_TYPE_SR:
return tf_dev_unbind_p4(tfp);
default:
TFP_DRV_LOG(ERR,
* - (-EINVAL) on failure.
*/
static int
-tf_dev_p4_get_max_types(struct tf *tfp __rte_unused,
+tf_dev_p4_get_max_types(struct tf *tfp,
uint16_t *max_types)
{
- if (max_types == NULL)
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ int rc;
+
+ if (max_types == NULL || tfp == NULL)
return -EINVAL;
- *max_types = CFA_RESOURCE_TYPE_P4_LAST + 1;
+ /* Retrieve the session information */
+ rc = tf_session_get_session(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc)
+ return rc;
+
+ if (dev->type == TF_DEVICE_TYPE_WH)
+ *max_types = CFA_RESOURCE_TYPE_P4_LAST + 1;
+ else if (dev->type == TF_DEVICE_TYPE_SR)
+ *max_types = CFA_RESOURCE_TYPE_P45_LAST + 1;
+ else
+ return -ENODEV;
return 0;
}
{ TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_TBL_SCOPE },
};
+struct tf_rm_element_cfg tf_em_ext_p45[TF_EM_TBL_TYPE_MAX] = {
+ /* CFA_RESOURCE_TYPE_P4_EM_REC */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_TBL_SCOPE },
+};
+
struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
{ TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P4_EM_REC },
/* CFA_RESOURCE_TYPE_P4_TBL_SCOPE */
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019-2020 Broadcom
+ * All rights reserved.
+ */
+
+#ifndef _TF_DEVICE_P45_H_
+#define _TF_DEVICE_P45_H_
+
+#include <cfa_resource_types.h>
+
+#include "tf_core.h"
+#include "tf_rm.h"
+#include "tf_if_tbl.h"
+#include "tf_global_cfg.h"
+
+struct tf_rm_element_cfg tf_ident_p4[TF_IDENT_TYPE_MAX] = {
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP_HIGH },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_REMAP_LOW },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_PROF_FUNC },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_WC_TCAM_PROF_ID },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_EM_PROF_ID },
+ /* CFA_RESOURCE_TYPE_P45_L2_FUNC */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
+};
+
+struct tf_rm_element_cfg tf_tcam_p4[TF_TCAM_TBL_TYPE_MAX] = {
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM_HIGH },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_L2_CTXT_TCAM_LOW },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_PROF_TCAM },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_WC_TCAM },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_TCAM },
+ /* CFA_RESOURCE_TYPE_P45_CT_RULE_TCAM */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_VEB_TCAM */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
+};
+
+struct tf_rm_element_cfg tf_tbl_p4[TF_TBL_TYPE_MAX] = {
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_FULL_ACTION },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_MCG },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_ENCAP_8B },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_ENCAP_16B },
+ /* CFA_RESOURCE_TYPE_P45_ENCAP_32B */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_ENCAP_64B },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_MAC },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_MAC_IPV4 },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_SP_MAC_IPV6 },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_COUNTER_64B },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_NAT_PORT },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_NAT_PORT },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_NAT_IPV4 },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_METER_PROF },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_METER },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_MIRROR },
+ /* CFA_RESOURCE_TYPE_P45_UPAR */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_EPOC */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_METADATA */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_CT_STATE */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_RANGE_PROF */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_RANGE_ENTRY */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_LAG */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_VNIC_SVIF */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_EM_FBK */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_WC_FKB */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ /* CFA_RESOURCE_TYPE_P45_EXT */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID }
+};
+
+struct tf_rm_element_cfg tf_em_ext_p4[TF_EM_TBL_TYPE_MAX] = {
+ /* CFA_RESOURCE_TYPE_P45_EM_REC */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+ { TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P45_TBL_SCOPE },
+};
+
+struct tf_rm_element_cfg tf_em_int_p4[TF_EM_TBL_TYPE_MAX] = {
+ { TF_RM_ELEM_CFG_HCAPI, CFA_RESOURCE_TYPE_P45_EM_REC },
+ /* CFA_RESOURCE_TYPE_P45_TBL_SCOPE */
+ { TF_RM_ELEM_CFG_NULL, CFA_RESOURCE_TYPE_INVALID },
+};
+
+struct tf_if_tbl_cfg tf_if_tbl_p4[TF_IF_TBL_TYPE_MAX] = {
+ { TF_IF_TBL_CFG, CFA_P4_TBL_PROF_SPIF_DFLT_L2CTXT },
+ { TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_DFLT_ACT_REC_PTR },
+ { TF_IF_TBL_CFG, CFA_P4_TBL_PROF_PARIF_ERR_ACT_REC_PTR },
+ { TF_IF_TBL_CFG, CFA_P4_TBL_LKUP_PARIF_DFLT_ACT_REC_PTR },
+ { TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID },
+ { TF_IF_TBL_CFG_NULL, CFA_IF_TBL_TYPE_INVALID }
+};
+
+struct tf_global_cfg_cfg tf_global_cfg_p4[TF_GLOBAL_CFG_TYPE_MAX] = {
+ { TF_GLOBAL_CFG_CFG_HCAPI, TF_TUNNEL_ENCAP },
+ { TF_GLOBAL_CFG_CFG_HCAPI, TF_ACTION_BLOCK },
+};
+#endif /* _TF_DEVICE_P45_H_ */
#include "tf_core.h"
#include "tf_session.h"
-
-#define SUPPORT_CFA_HW_P4 1
-#define SUPPORT_CFA_HW_P58 0
-#define SUPPORT_CFA_HW_P59 0
-#define SUPPORT_CFA_HW_ALL 0
-
#include "hcapi/hcapi_cfa_defs.h"
#define TF_EM_MIN_ENTRIES (1 << 15) /* 32K */