xref: /dpdk/drivers/raw/ntb/ntb_hw_intel.h (revision 834d99f388ca99507b124d1fb49059c265dfa18e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation.
3  */
4 
5 #ifndef _NTB_HW_INTEL_H_
6 #define _NTB_HW_INTEL_H_
7 
8 /* Supported PCI device revision ID range for ICX */
9 #define NTB_PCI_DEV_REVISION_ICX_MIN	0x02
10 #define NTB_PCI_DEV_REVISION_ICX_MAX	0x0F
11 
12 #define NTB_PCI_DEV_REVISION_ID_REG	0x08
13 #define NTB_PCI_DEV_REVISION_ID_LEN	1
14 
15 /* Ntb control and link status */
16 #define NTB_CTL_CFG_LOCK		1
17 #define NTB_CTL_DISABLE			2
18 #define NTB_CTL_S2P_BAR2_SNOOP		(1 << 2)
19 #define NTB_CTL_P2S_BAR2_SNOOP		(1 << 4)
20 #define NTB_CTL_S2P_BAR4_SNOOP		(1 << 6)
21 #define NTB_CTL_P2S_BAR4_SNOOP		(1 << 8)
22 #define NTB_CTL_S2P_BAR5_SNOOP		(1 << 12)
23 #define NTB_CTL_P2S_BAR5_SNOOP		(1 << 14)
24 
25 #define NTB_LNK_STA_ACTIVE_BIT		0x2000
26 #define NTB_LNK_STA_SPEED_MASK		0x000f
27 #define NTB_LNK_STA_WIDTH_MASK		0x03f0
28 #define NTB_LNK_STA_ACTIVE(x)		(!!((x) & NTB_LNK_STA_ACTIVE_BIT))
29 #define NTB_LNK_STA_SPEED(x)		((x) & NTB_LNK_STA_SPEED_MASK)
30 #define NTB_LNK_STA_WIDTH(x)		(((x) & NTB_LNK_STA_WIDTH_MASK) >> 4)
31 
32 /* Intel Xeon hardware */
33 #define XEON_IMBAR1SZ_OFFSET		0x00d0
34 #define XEON_IMBAR2SZ_OFFSET		0x00d1
35 #define XEON_EMBAR1SZ_OFFSET		0x00d2
36 #define XEON_EMBAR2SZ_OFFSET		0x00d3
37 #define XEON_DEVCTRL_OFFSET		0x0098
38 #define XEON_DEVSTS_OFFSET		0x009a
39 #define XEON_UNCERRSTS_OFFSET		0x014c
40 #define XEON_CORERRSTS_OFFSET		0x0158
41 #define XEON_GEN3_LINK_STATUS_OFFSET	0x01a2
42 /* Link status and PPD are in MMIO but not config space for Gen4 NTB */
43 #define XEON_GEN4_PPD0_OFFSET		0xb0d4
44 #define XEON_GEN4_PPD1_OFFSET		0xb4c0
45 #define XEON_GEN4_LINK_CTRL_OFFSET	0xb050
46 #define XEON_GEN4_LINK_STATUS_OFFSET	0xb052
47 #define XEON_GEN4_LINK_CTRL_LINK_DIS	0x0010
48 
49 #define XEON_NTBCNTL_OFFSET		0x0000
50 #define XEON_BAR_INTERVAL_OFFSET	0x0010
51 #define XEON_IMBAR1XBASE_OFFSET		0x0010		/* SBAR2XLAT */
52 #define XEON_IMBAR1XLMT_OFFSET		0x0018		/* SBAR2LMT */
53 #define XEON_IMBAR2XBASE_OFFSET		0x0020		/* SBAR4XLAT */
54 #define XEON_IMBAR2XLMT_OFFSET		0x0028		/* SBAR4LMT */
55 #define XEON_GEN4_XBASEIDX_INTERVAL	0x0002
56 #define XEON_GEN4_IM1XBASEIDX_OFFSET	0x0074
57 #define XEON_GEN4_IM2XBASEIDX_OFFSET	0x0076
58 #define XEON_IM_INT_STATUS_OFFSET	0x0040
59 #define XEON_IM_INT_DISABLE_OFFSET	0x0048
60 #define XEON_IM_SPAD_OFFSET		0x0080		/* SPAD */
61 #define XEON_GEN3_B2B_SPAD_OFFSET	0x0180		/* GEN3 B2B SPAD */
62 #define XEON_GEN4_B2B_SPAD_OFFSET	0x8080		/* GEN4 B2B SPAD */
63 #define XEON_USMEMMISS_OFFSET		0x0070
64 #define XEON_GEN3_INTVEC_OFFSET		0x00d0
65 #define XEON_GEN4_INTVEC_OFFSET		0x0050
66 #define XEON_IM_DOORBELL_OFFSET		0x0100		/* SDOORBELL0 */
67 #define XEON_EMBAR0XBASE_OFFSET		0x4008		/* B2B_XLAT */
68 #define XEON_EMBAR1XBASE_OFFSET		0x4010		/* PBAR2XLAT */
69 #define XEON_EMBAR1XLMT_OFFSET		0x4018		/* PBAR2LMT */
70 #define XEON_EMBAR2XBASE_OFFSET		0x4020		/* PBAR4XLAT */
71 #define XEON_EMBAR2XLMT_OFFSET		0x4028		/* PBAR4LMT */
72 #define XEON_EM_INT_STATUS_OFFSET	0x4040
73 #define XEON_EM_INT_DISABLE_OFFSET	0x4048
74 #define XEON_EM_SPAD_OFFSET		0x4080		/* remote SPAD */
75 #define XEON_EM_DOORBELL_OFFSET		0x4100		/* PDOORBELL0 */
76 #define XEON_SPCICMD_OFFSET		0x4504		/* SPCICMD */
77 #define XEON_EMBAR0_OFFSET		0x4510		/* SBAR0BASE */
78 #define XEON_EMBAR1_OFFSET		0x4518		/* SBAR23BASE */
79 #define XEON_EMBAR2_OFFSET		0x4520		/* SBAR45BASE */
80 
81 #define XEON_PPD_OFFSET			0x00d4
82 #define XEON_PPD_CONN_MASK		0x03
83 #define XEON_PPD_CONN_TRANSPARENT	0x00
84 #define XEON_PPD_CONN_B2B		0x01
85 #define XEON_PPD_CONN_RP		0x02
86 #define XEON_PPD_DEV_MASK		0x10
87 #define XEON_PPD_DEV_USD		0x00
88 #define XEON_PPD_DEV_DSD		0x10
89 #define XEON_PPD_SPLIT_BAR_MASK		0x40
90 
91 #define XEON_GEN4_PPD_CONN_MASK		0x0300
92 #define XEON_GEN4_PPD_CONN_B2B		0x0200
93 #define XEON_GEN4_PPD_DEV_MASK		0x1000
94 #define XEON_GEN4_PPD_DEV_DSD		0x1000
95 #define XEON_GEN4_PPD_DEV_USD		0x0000
96 #define XEON_GEN4_PPD_LINKTRN		0x0008
97 #define XEON_GEN4_SLOTSTS		0xb05a
98 #define XEON_GEN4_SLOTSTS_DLLSCS	0x100
99 
100 #define XEON_SPR_PPD_CONN_MASK		0x0700
101 #define XEON_SPR_PPD_CONN_B2B		0x0200
102 #define XEON_SPR_PPD_DEV_MASK		0x4000
103 #define XEON_SPR_PPD_DEV_DSD		0x4000
104 #define XEON_SPR_PPD_DEV_USD		0x0000
105 
106 #define XEON_MW_COUNT			2
107 
108 #define XEON_DB_COUNT			32
109 #define XEON_DB_LINK			32
110 #define XEON_DB_LINK_BIT		(1ULL << XEON_DB_LINK)
111 #define XEON_DB_MSIX_VECTOR_COUNT	33
112 #define XEON_DB_MSIX_VECTOR_SHIFT	1
113 #define XEON_DB_TOTAL_SHIFT		33
114 #define XEON_SPAD_COUNT			16
115 
116 extern const struct ntb_dev_ops intel_ntb_ops;
117 
118 #endif /* _NTB_HW_INTEL_H_ */
119