#ifndef __NTMP_PRIVATE_H
#define __NTMP_PRIVATE_H
#include <linux/bitfield.h>
#include <linux/fsl/ntmp.h>
#define NTMP_EID_REQ_LEN 8
#define NTMP_STATUS_RESP_LEN 4
#define NETC_CBDR_BD_NUM 256
#define NETC_CBDRCIR_INDEX GENMASK(9, 0)
#define NETC_CBDRCIR_SBE BIT(31)
#define NETC_CBDR_CLEAN_WORK 16
union netc_cbd {
struct {
__le64 addr;
__le32 len;
#define NTMP_RESP_LEN GENMASK(19, 0)
#define NTMP_REQ_LEN GENMASK(31, 20)
#define NTMP_LEN(req, resp) (FIELD_PREP(NTMP_REQ_LEN, (req)) | \
((resp) & NTMP_RESP_LEN))
u8 cmd;
#define NTMP_CMD_DELETE BIT(0)
#define NTMP_CMD_UPDATE BIT(1)
#define NTMP_CMD_QUERY BIT(2)
#define NTMP_CMD_ADD BIT(3)
#define NTMP_CMD_QU (NTMP_CMD_QUERY | NTMP_CMD_UPDATE)
#define NTMP_CMD_AQ (NTMP_CMD_ADD | NTMP_CMD_QUERY)
u8 access_method;
#define NTMP_ACCESS_METHOD GENMASK(7, 4)
#define NTMP_AM_ENTRY_ID 0
#define NTMP_AM_EXACT_KEY 1
#define NTMP_AM_SEARCH 2
#define NTMP_AM_TERNARY_KEY 3
u8 table_id;
u8 ver_cci_rr;
#define NTMP_HDR_VERSION GENMASK(5, 0)
#define NTMP_HDR_VER2 2
#define NTMP_CCI BIT(6)
#define NTMP_RR BIT(7)
__le32 resv[3];
__le32 npf;
#define NTMP_NPF BIT(15)
} req_hdr;
struct {
__le32 resv0[3];
__le16 num_matched;
__le16 error_rr;
#define NTMP_RESP_ERROR GENMASK(11, 0)
#define NTMP_RESP_RR BIT(15)
__le32 resv1[4];
} resp_hdr;
};
struct ntmp_cmn_req_data {
__le16 update_act;
u8 dbg_opt;
u8 tblv_qact;
#define NTMP_QUERY_ACT GENMASK(3, 0)
#define NTMP_TBL_VER GENMASK(7, 4)
#define NTMP_TBLV_QACT(v, a) (FIELD_PREP(NTMP_TBL_VER, (v)) | \
((a) & NTMP_QUERY_ACT))
};
struct ntmp_cmn_resp_query {
__le32 entry_id;
};
struct ntmp_req_by_eid {
struct ntmp_cmn_req_data crd;
__le32 entry_id;
};
struct maft_req_add {
struct ntmp_req_by_eid rbe;
struct maft_keye_data keye;
struct maft_cfge_data cfge;
};
struct maft_resp_query {
__le32 entry_id;
struct maft_keye_data keye;
struct maft_cfge_data cfge;
};
struct rsst_req_update {
struct ntmp_req_by_eid rbe;
u8 groups[];
};
struct ipft_resp_query {
__le32 status;
__le32 entry_id;
struct ipft_keye_data keye;
__le64 match_count;
struct ipft_cfge_data cfge;
} __packed;
struct ipft_ak_eid {
__le32 entry_id;
__le32 resv[52];
};
union ipft_access_key {
struct ipft_ak_eid eid;
struct ipft_keye_data keye;
};
struct ipft_req_ua {
struct ntmp_cmn_req_data crd;
union ipft_access_key ak;
struct ipft_cfge_data cfge;
};
struct ipft_req_qd {
struct ntmp_req_by_eid rbe;
__le32 resv[52];
};
struct fdbt_ak_eid {
__le32 entry_id;
__le32 resv[7];
};
struct fdbt_ak_exact {
struct fdbt_keye_data keye;
__le32 resv[5];
};
struct fdbt_ak_search {
__le32 resume_eid;
struct fdbt_keye_data keye;
struct fdbt_cfge_data cfge;
u8 acte;
u8 keye_mc;
#define FDBT_KEYE_MAC GENMASK(1, 0)
u8 cfge_mc;
#define FDBT_CFGE_MC GENMASK(2, 0)
#define FDBT_CFGE_MC_ANY 0
#define FDBT_CFGE_MC_DYNAMIC 1
#define FDBT_CFGE_MC_PORT_BITMAP 2
#define FDBT_CFGE_MC_DYNAMIC_AND_PORT_BITMAP 3
u8 acte_mc;
#define FDBT_ACTE_MC BIT(0)
};
union fdbt_access_key {
struct fdbt_ak_eid eid;
struct fdbt_ak_exact exact;
struct fdbt_ak_search search;
};
struct fdbt_req_ua {
struct ntmp_cmn_req_data crd;
union fdbt_access_key ak;
struct fdbt_cfge_data cfge;
};
struct fdbt_req_qd {
struct ntmp_cmn_req_data crd;
union fdbt_access_key ak;
};
struct fdbt_resp_query {
__le32 status;
__le32 entry_id;
struct fdbt_keye_data keye;
struct fdbt_cfge_data cfge;
u8 acte;
u8 resv[3];
};
struct vft_ak_exact {
__le16 vid;
__le16 resv;
};
union vft_access_key {
__le32 entry_id;
struct vft_ak_exact exact;
__le32 resume_entry_id;
};
struct vft_req_ua {
struct ntmp_cmn_req_data crd;
union vft_access_key ak;
struct vft_cfge_data cfge;
};
struct vft_req_qd {
struct ntmp_cmn_req_data crd;
union vft_access_key ak;
};
struct ett_req_ua {
struct ntmp_req_by_eid rbe;
struct ett_cfge_data cfge;
};
struct bpt_req_update {
struct ntmp_req_by_eid rbe;
struct bpt_cfge_data cfge;
};
#endif