1f752780fSAkhil Goyal /* SPDX-License-Identifier: BSD-3-Clause 2f752780fSAkhil Goyal * Copyright(C) 2023 Marvell. 3f752780fSAkhil Goyal */ 4f752780fSAkhil Goyal 5f752780fSAkhil Goyal #ifndef _ROC_MCS_PRIV_H_ 6f752780fSAkhil Goyal #define _ROC_MCS_PRIV_H_ 7f752780fSAkhil Goyal 8f752780fSAkhil Goyal #define MAX_PORTS_PER_MCS 4 9f752780fSAkhil Goyal 10f752780fSAkhil Goyal enum mcs_error_status { 11f752780fSAkhil Goyal MCS_ERR_PARAM = -900, 12f752780fSAkhil Goyal MCS_ERR_HW_NOTSUP = -901, 13f752780fSAkhil Goyal MCS_ERR_DEVICE_NOT_FOUND = -902, 14f752780fSAkhil Goyal }; 15f752780fSAkhil Goyal 16f752780fSAkhil Goyal #define MCS_SUPPORT_CHECK \ 17f752780fSAkhil Goyal do { \ 18f752780fSAkhil Goyal if (!(roc_feature_bphy_has_macsec() || roc_feature_nix_has_macsec())) \ 19f752780fSAkhil Goyal return MCS_ERR_HW_NOTSUP; \ 20f752780fSAkhil Goyal } while (0) 21f752780fSAkhil Goyal 22f752780fSAkhil Goyal struct mcs_sc_conf { 23f752780fSAkhil Goyal struct { 24f752780fSAkhil Goyal uint64_t sci; 25f752780fSAkhil Goyal uint16_t sa_idx0; 26f752780fSAkhil Goyal uint16_t sa_idx1; 27f752780fSAkhil Goyal uint8_t rekey_enb; 28f752780fSAkhil Goyal } tx; 29f752780fSAkhil Goyal struct { 30f752780fSAkhil Goyal uint16_t sa_idx; 31f752780fSAkhil Goyal uint8_t an; 32f752780fSAkhil Goyal } rx; 33f752780fSAkhil Goyal }; 34f752780fSAkhil Goyal 35f752780fSAkhil Goyal struct mcs_rsrc { 36f752780fSAkhil Goyal struct plt_bitmap *tcam_bmap; 37f752780fSAkhil Goyal void *tcam_bmap_mem; 38f752780fSAkhil Goyal struct plt_bitmap *secy_bmap; 39f752780fSAkhil Goyal void *secy_bmap_mem; 40f752780fSAkhil Goyal struct plt_bitmap *sc_bmap; 41f752780fSAkhil Goyal void *sc_bmap_mem; 42f752780fSAkhil Goyal struct plt_bitmap *sa_bmap; 43f752780fSAkhil Goyal void *sa_bmap_mem; 44f752780fSAkhil Goyal struct mcs_sc_conf *sc_conf; 45f752780fSAkhil Goyal }; 46f752780fSAkhil Goyal 47f752780fSAkhil Goyal struct mcs_priv { 48f752780fSAkhil Goyal struct mcs_rsrc *port_rsrc; 49f752780fSAkhil Goyal struct mcs_rsrc dev_rsrc; 50f752780fSAkhil Goyal uint64_t default_sci; 51f752780fSAkhil Goyal uint32_t lmac_bmap; 52f752780fSAkhil Goyal uint8_t num_mcs_blks; 53f752780fSAkhil Goyal uint8_t tcam_entries; 54f752780fSAkhil Goyal uint8_t secy_entries; 55f752780fSAkhil Goyal uint8_t sc_entries; 56f752780fSAkhil Goyal uint16_t sa_entries; 57f752780fSAkhil Goyal }; 58f752780fSAkhil Goyal 59f752780fSAkhil Goyal static inline struct mcs_priv * roc_mcs_to_mcs_priv(struct roc_mcs * roc_mcs)60f752780fSAkhil Goyalroc_mcs_to_mcs_priv(struct roc_mcs *roc_mcs) 61f752780fSAkhil Goyal { 62f752780fSAkhil Goyal return (struct mcs_priv *)&roc_mcs->reserved[0]; 63f752780fSAkhil Goyal } 64f752780fSAkhil Goyal 65*c26d94f2SAkhil Goyal static inline void * roc_mcs_to_mcs_cb_list(struct roc_mcs * roc_mcs)66*c26d94f2SAkhil Goyalroc_mcs_to_mcs_cb_list(struct roc_mcs *roc_mcs) 67*c26d94f2SAkhil Goyal { 68*c26d94f2SAkhil Goyal return (void *)((uintptr_t)roc_mcs->reserved + sizeof(struct mcs_priv)); 69*c26d94f2SAkhil Goyal } 70*c26d94f2SAkhil Goyal 71*c26d94f2SAkhil Goyal int mcs_event_cb_process(struct roc_mcs *mcs, struct roc_mcs_event_desc *desc); 72*c26d94f2SAkhil Goyal 73f752780fSAkhil Goyal #endif /* _ROC_MCS_PRIV_H_ */ 74