xref: /linux/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/nfp6000.h (revision 3eb66e91a25497065c5322b1268cbc3953642227)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2015-2017 Netronome Systems, Inc. */
3 
4 #ifndef NFP6000_NFP6000_H
5 #define NFP6000_NFP6000_H
6 
7 #include <linux/errno.h>
8 #include <linux/types.h>
9 
10 /* CPP Target IDs */
11 #define NFP_CPP_TARGET_INVALID          0
12 #define NFP_CPP_TARGET_NBI              1
13 #define NFP_CPP_TARGET_QDR              2
14 #define NFP_CPP_TARGET_ILA              6
15 #define NFP_CPP_TARGET_MU               7
16 #define NFP_CPP_TARGET_PCIE             9
17 #define NFP_CPP_TARGET_ARM              10
18 #define NFP_CPP_TARGET_CRYPTO           12
19 #define NFP_CPP_TARGET_ISLAND_XPB       14      /* Shared with CAP */
20 #define NFP_CPP_TARGET_ISLAND_CAP       14      /* Shared with XPB */
21 #define NFP_CPP_TARGET_CT_XPB           14
22 #define NFP_CPP_TARGET_LOCAL_SCRATCH    15
23 #define NFP_CPP_TARGET_CLS              NFP_CPP_TARGET_LOCAL_SCRATCH
24 
25 #define NFP_ISL_EMEM0			24
26 
27 #define NFP_MU_ADDR_ACCESS_TYPE_MASK	3ULL
28 #define NFP_MU_ADDR_ACCESS_TYPE_DIRECT	2ULL
29 
30 #define PUSHPULL(_pull, _push)		((_pull) << 4 | (_push) << 0)
31 #define PUSH_WIDTH(_pushpull)		pushpull_width((_pushpull) >> 0)
32 #define PULL_WIDTH(_pushpull)		pushpull_width((_pushpull) >> 4)
33 
pushpull_width(int pp)34 static inline int pushpull_width(int pp)
35 {
36 	pp &= 0xf;
37 
38 	if (pp == 0)
39 		return -EINVAL;
40 	return 2 << pp;
41 }
42 
nfp_cppat_mu_locality_lsb(int mode,bool addr40)43 static inline int nfp_cppat_mu_locality_lsb(int mode, bool addr40)
44 {
45 	switch (mode) {
46 	case 0 ... 3:
47 		return addr40 ? 38 : 30;
48 	default:
49 		return -EINVAL;
50 	}
51 }
52 
53 int nfp_target_pushpull(u32 cpp_id, u64 address);
54 int nfp_target_cpp(u32 cpp_island_id, u64 cpp_island_address,
55 		   u32 *cpp_target_id, u64 *cpp_target_address,
56 		   const u32 *imb_table);
57 
58 #endif /* NFP6000_NFP6000_H */
59