xref: /dpdk/drivers/common/cnxk/roc_nix_inl_dp.h (revision 8df859aabebba2625db95f16d4a2968754733bbc)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2022 Marvell.
3  */
4 #ifndef _ROC_NIX_INL_DP_H_
5 #define _ROC_NIX_INL_DP_H_
6 
7 /* OT INB HW area */
8 #define ROC_NIX_INL_OT_IPSEC_INB_HW_SZ                                         \
9 	PLT_ALIGN(sizeof(struct roc_ot_ipsec_inb_sa), ROC_ALIGN)
10 /* OT INB SW reserved area */
11 #define ROC_NIX_INL_OT_IPSEC_INB_SW_RSVD 128
12 #define ROC_NIX_INL_OT_IPSEC_INB_SA_SZ                                         \
13 	(ROC_NIX_INL_OT_IPSEC_INB_HW_SZ + ROC_NIX_INL_OT_IPSEC_INB_SW_RSVD)
14 #define ROC_NIX_INL_OT_IPSEC_INB_SA_SZ_LOG2 10
15 
16 /* OT OUTB HW area */
17 #define ROC_NIX_INL_OT_IPSEC_OUTB_HW_SZ                                        \
18 	PLT_ALIGN(sizeof(struct roc_ot_ipsec_outb_sa), ROC_ALIGN)
19 
20 /* OT OUTB SW reserved area */
21 #define ROC_NIX_INL_OT_IPSEC_OUTB_SW_RSVD 128
22 #define ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ                                        \
23 	(ROC_NIX_INL_OT_IPSEC_OUTB_HW_SZ + ROC_NIX_INL_OT_IPSEC_OUTB_SW_RSVD)
24 #define ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ_LOG2 9
25 
26 /* Alignment of SA Base */
27 #define ROC_NIX_INL_SA_BASE_ALIGN BIT_ULL(16)
28 
29 static inline struct roc_ot_ipsec_inb_sa *
roc_nix_inl_ot_ipsec_inb_sa(uintptr_t base,uint64_t idx)30 roc_nix_inl_ot_ipsec_inb_sa(uintptr_t base, uint64_t idx)
31 {
32 	uint64_t off = idx << ROC_NIX_INL_OT_IPSEC_INB_SA_SZ_LOG2;
33 
34 	return PLT_PTR_ADD(base, off);
35 }
36 
37 static inline struct roc_ot_ipsec_outb_sa *
roc_nix_inl_ot_ipsec_outb_sa(uintptr_t base,uint64_t idx)38 roc_nix_inl_ot_ipsec_outb_sa(uintptr_t base, uint64_t idx)
39 {
40 	uint64_t off = idx << ROC_NIX_INL_OT_IPSEC_OUTB_SA_SZ_LOG2;
41 
42 	return PLT_PTR_ADD(base, off);
43 }
44 
45 static inline void *
roc_nix_inl_ot_ipsec_inb_sa_sw_rsvd(void * sa)46 roc_nix_inl_ot_ipsec_inb_sa_sw_rsvd(void *sa)
47 {
48 	return PLT_PTR_ADD(sa, ROC_NIX_INL_OT_IPSEC_INB_HW_SZ);
49 }
50 
51 static inline void *
roc_nix_inl_ot_ipsec_outb_sa_sw_rsvd(void * sa)52 roc_nix_inl_ot_ipsec_outb_sa_sw_rsvd(void *sa)
53 {
54 	return PLT_PTR_ADD(sa, ROC_NIX_INL_OT_IPSEC_OUTB_HW_SZ);
55 }
56 
57 #endif /* _ROC_NIX_INL_DP_H_ */
58