bcmpcie.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*
  2. * Broadcom PCIE
  3. * Software-specific definitions shared between device and host side
  4. * Explains the shared area between host and dongle
  5. *
  6. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  7. *
  8. * Copyright (C) 1999-2020, Broadcom Corporation
  9. *
  10. * Unless you and Broadcom execute a separate written software license
  11. * agreement governing use of this software, this software is licensed to you
  12. * under the terms of the GNU General Public License version 2 (the "GPL"),
  13. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  14. * following added to such license:
  15. *
  16. * As a special exception, the copyright holders of this software give you
  17. * permission to link this software with independent modules, and to copy and
  18. * distribute the resulting executable under terms of your choice, provided that
  19. * you also meet, for each linked independent module, the terms and conditions of
  20. * the license of that module. An independent module is a module which is not
  21. * derived from this software. The special exception does not apply to any
  22. * modifications of the software.
  23. *
  24. * Notwithstanding the above, under no circumstances may you combine this
  25. * software in any way with any other Broadcom software provided under a license
  26. * other than the GPL, without Broadcom's express prior written consent.
  27. *
  28. *
  29. * <<Broadcom-WL-IPTag/Open:>>
  30. *
  31. * $Id: bcmpcie.h 715563 2019-05-24 18:41:57Z $
  32. */
  33. #ifndef _bcmpcie_h_
  34. #define _bcmpcie_h_
  35. #include <typedefs.h>
  36. #define ADDR_64(x) (x.addr)
  37. #define HIGH_ADDR_32(x) ((uint32) (((sh_addr_t) x).high_addr))
  38. #define LOW_ADDR_32(x) ((uint32) (((sh_addr_t) x).low_addr))
  39. typedef struct {
  40. uint32 low_addr;
  41. uint32 high_addr;
  42. } sh_addr_t;
  43. /* May be overridden by 43xxxxx-roml.mk */
  44. #if !defined(BCMPCIE_MAX_TX_FLOWS)
  45. #define BCMPCIE_MAX_TX_FLOWS 40
  46. #endif /* ! BCMPCIE_MAX_TX_FLOWS */
  47. #define PCIE_SHARED_VERSION_7 0x00007
  48. #define PCIE_SHARED_VERSION_6 0x00006 /* rev6 is compatible with rev 5 */
  49. #define PCIE_SHARED_VERSION_5 0x00005 /* rev6 is compatible with rev 5 */
  50. /**
  51. * Feature flags enabled in dongle. Advertised by dongle to DHD via the PCIe Shared structure that
  52. * is located in device memory.
  53. */
  54. #define PCIE_SHARED_VERSION_MASK 0x000FF
  55. #define PCIE_SHARED_ASSERT_BUILT 0x00100
  56. #define PCIE_SHARED_ASSERT 0x00200
  57. #define PCIE_SHARED_TRAP 0x00400
  58. #define PCIE_SHARED_IN_BRPT 0x00800
  59. #define PCIE_SHARED_SET_BRPT 0x01000
  60. #define PCIE_SHARED_PENDING_BRPT 0x02000
  61. /* BCMPCIE_SUPPORT_TX_PUSH_RING 0x04000 obsolete */
  62. #define PCIE_SHARED_EVT_SEQNUM 0x08000
  63. #define PCIE_SHARED_DMA_INDEX 0x10000
  64. /**
  65. * There are host types where a device interrupt can 'race ahead' of data written by the device into
  66. * host memory. The dongle can avoid this condition using a variety of techniques (read barrier,
  67. * using PCIe Message Signalled Interrupts, or by using the PCIE_DMA_INDEX feature). Unfortunately
  68. * these techniques have drawbacks on router platforms. For these platforms, it was decided to not
  69. * avoid the condition, but to detect the condition instead and act on it.
  70. * D2H M2M DMA Complete Sync mechanism: Modulo-253-SeqNum or XORCSUM
  71. */
  72. #define PCIE_SHARED_D2H_SYNC_SEQNUM 0x20000
  73. #define PCIE_SHARED_D2H_SYNC_XORCSUM 0x40000
  74. #define PCIE_SHARED_D2H_SYNC_MODE_MASK \
  75. (PCIE_SHARED_D2H_SYNC_SEQNUM | PCIE_SHARED_D2H_SYNC_XORCSUM)
  76. #define PCIE_SHARED_IDLE_FLOW_RING 0x80000
  77. #define PCIE_SHARED_2BYTE_INDICES 0x100000
  78. #define PCIE_SHARED2_EXTENDED_TRAP_DATA 0x00000001 /* using flags2 in shared area */
  79. #define PCIE_SHARED2_TXSTATUS_METADATA 0x00000002
  80. #define PCIE_SHARED2_BT_LOGGING 0x00000004 /* BT logging support */
  81. #define PCIE_SHARED2_SNAPSHOT_UPLOAD 0x00000008 /* BT/WLAN snapshot upload support */
  82. #define PCIE_SHARED2_SUBMIT_COUNT_WAR 0x00000010 /* submission count WAR */
  83. #define PCIE_SHARED2_FW_SMALL_MEMDUMP 0x00000200 /* FW small memdump */
  84. #define PCIE_SHARED2_DEBUG_BUF_DEST 0x00002000 /* debug buf dest support */
  85. #define PCIE_SHARED_FAST_DELETE_RING 0x00000020 /* Fast Delete Ring */
  86. #define PCIE_SHARED_EVENT_BUF_POOL_MAX 0x000000c0 /* event buffer pool max bits */
  87. #define PCIE_SHARED_EVENT_BUF_POOL_MAX_POS 6 /* event buffer pool max bit position */
  88. /* dongle supports fatal buf log collection */
  89. #define PCIE_SHARED_FATAL_LOGBUG_VALID 0x200000
  90. /* Implicit DMA with corerev 19 and after */
  91. #define PCIE_SHARED_IDMA 0x400000
  92. /* MSI support */
  93. #define PCIE_SHARED_D2H_MSI_MULTI_MSG 0x800000
  94. /* IFRM with corerev 19 and after */
  95. #define PCIE_SHARED_IFRM 0x1000000
  96. /**
  97. * From Rev6 and above, suspend/resume can be done using two handshake methods.
  98. * 1. Using ctrl post/ctrl cmpl messages (Default rev6)
  99. * 2. Using Mailbox data (old method as used in rev5)
  100. * This shared flag indicates whether to overide rev6 default method and use mailbox for
  101. * suspend/resume.
  102. */
  103. #define PCIE_SHARED_USE_MAILBOX 0x2000000
  104. /* Firmware compiled for mfgbuild purposes */
  105. #define PCIE_SHARED_MFGBUILD_FW 0x4000000
  106. /* Firmware could use DB0 value as host timestamp */
  107. #define PCIE_SHARED_TIMESTAMP_DB0 0x8000000
  108. /* Firmware could use Hostready (IPC rev7) */
  109. #define PCIE_SHARED_HOSTRDY_SUPPORT 0x10000000
  110. /* When set, Firmwar does not support OOB Device Wake based DS protocol */
  111. #define PCIE_SHARED_NO_OOB_DW 0x20000000
  112. /* When set, Firmwar supports Inband DS protocol */
  113. #define PCIE_SHARED_INBAND_DS 0x40000000
  114. /* use DAR registers */
  115. #define PCIE_SHARED_DAR 0x80000000
  116. /**
  117. * Following are the shared2 flags. All bits in flags have been used. A flags2
  118. * field got added and the definition for these flags come here:
  119. */
  120. /* WAR: D11 txstatus through unused status field of PCIe completion header */
  121. #define PCIE_SHARED2_D2H_D11_TX_STATUS 0x40000000
  122. #define PCIE_SHARED2_H2D_D11_TX_STATUS 0x80000000
  123. #define PCIE_SHARED2_EXTENDED_TRAP_DATA 0x00000001
  124. #define PCIE_SHARED2_TXSTATUS_METADATA 0x00000002
  125. /* BT logging support */
  126. #define PCIE_SHARED2_BT_LOGGING 0x00000004
  127. /* BT/WLAN snapshot upload support */
  128. #define PCIE_SHARED2_SNAPSHOT_UPLOAD 0x00000008
  129. /* submission count WAR */
  130. #define PCIE_SHARED2_SUBMIT_COUNT_WAR 0x00000010
  131. /* Fast Delete ring support */
  132. #define PCIE_SHARED2_FAST_DELETE_RING 0x00000020
  133. /* Host SCB support */
  134. #define PCIE_SHARED2_HSCB 0x00000800
  135. #define PCIE_SHARED_D2H_MAGIC 0xFEDCBA09
  136. #define PCIE_SHARED_H2D_MAGIC 0x12345678
  137. #define PCIE_SHARED2_PKT_TX_STATUS 0x00000100 /* using flags2 to indicate
  138. firmware support added to reuse
  139. timesync to update PKT txstatus
  140. */
  141. /* Support Enhanced Debug Lane */
  142. #define PCIE_SHARED2_EDL_RING 0x00001000
  143. /* BT producer index reset WAR */
  144. #define PCIE_SHARED2_PCIE_ENUM_RESET_FLR 0x00004000
  145. /* Timestamp in packet */
  146. #define PCIE_SHARED2_PKT_TIMESTAMP 0x00008000
  147. /* HP2P feature */
  148. #define PCIE_SHARED2_HP2P 0x00010000u
  149. #define PCIE_SHARED2_DURATION_SCALE 0x00100000u
  150. /* HWA feature */
  151. #define PCIE_SHARED2_HWA 0x00020000
  152. typedef uint16 pcie_hwa_db_index_t; /* 16 bit HWA index (IPC Rev 7) */
  153. #define PCIE_HWA_DB_INDEX_SZ (2u) /* 2 bytes sizeof(pcie_hwa_db_index_t) */
  154. /**
  155. * Message rings convey messages between host and device. They are unidirectional, and are located
  156. * in host memory.
  157. *
  158. * This is the minimal set of message rings, known as 'common message rings':
  159. */
  160. #define BCMPCIE_H2D_MSGRING_CONTROL_SUBMIT 0
  161. #define BCMPCIE_H2D_MSGRING_RXPOST_SUBMIT 1
  162. #define BCMPCIE_D2H_MSGRING_CONTROL_COMPLETE 2
  163. #define BCMPCIE_D2H_MSGRING_TX_COMPLETE 3
  164. #define BCMPCIE_D2H_MSGRING_RX_COMPLETE 4
  165. #define BCMPCIE_COMMON_MSGRING_MAX_ID 4
  166. #define BCMPCIE_H2D_COMMON_MSGRINGS 2
  167. #define BCMPCIE_D2H_COMMON_MSGRINGS 3
  168. #define BCMPCIE_COMMON_MSGRINGS 5
  169. #define BCMPCIE_H2D_MSGRINGS(max_tx_flows) \
  170. (BCMPCIE_H2D_COMMON_MSGRINGS + (max_tx_flows))
  171. /* different ring types */
  172. #define BCMPCIE_H2D_RING_TYPE_CTRL_SUBMIT 0x1
  173. #define BCMPCIE_H2D_RING_TYPE_TXFLOW_RING 0x2
  174. #define BCMPCIE_H2D_RING_TYPE_RXBUFPOST 0x3
  175. #define BCMPCIE_H2D_RING_TYPE_TXSUBMIT 0x4
  176. #define BCMPCIE_H2D_RING_TYPE_DBGBUF_SUBMIT 0x5
  177. #define BCMPCIE_H2D_RING_TYPE_BTLOG_SUBMIT 0x6
  178. #define BCMPCIE_D2H_RING_TYPE_CTRL_CPL 0x1
  179. #define BCMPCIE_D2H_RING_TYPE_TX_CPL 0x2
  180. #define BCMPCIE_D2H_RING_TYPE_RX_CPL 0x3
  181. #define BCMPCIE_D2H_RING_TYPE_DBGBUF_CPL 0x4
  182. #define BCMPCIE_D2H_RING_TYPE_AC_RX_COMPLETE 0x5
  183. #define BCMPCIE_D2H_RING_TYPE_BTLOG_CPL 0x6
  184. #define BCMPCIE_D2H_RING_TYPE_EDL 0x7
  185. #define BCMPCIE_D2H_RING_TYPE_HPP_TX_CPL 0x8
  186. #define BCMPCIE_D2H_RING_TYPE_HPP_RX_CPL 0x9
  187. /**
  188. * H2D and D2H, WR and RD index, are maintained in the following arrays:
  189. * - Array of all H2D WR Indices
  190. * - Array of all H2D RD Indices
  191. * - Array of all D2H WR Indices
  192. * - Array of all D2H RD Indices
  193. *
  194. * The offset of the WR or RD indexes (for common rings) in these arrays are
  195. * listed below. Arrays ARE NOT indexed by a ring's id.
  196. *
  197. * D2H common rings WR and RD index start from 0, even though their ringids
  198. * start from BCMPCIE_H2D_COMMON_MSGRINGS
  199. */
  200. #define BCMPCIE_H2D_RING_IDX(h2d_ring_id) (h2d_ring_id)
  201. enum h2dring_idx {
  202. /* H2D common rings */
  203. BCMPCIE_H2D_MSGRING_CONTROL_SUBMIT_IDX =
  204. BCMPCIE_H2D_RING_IDX(BCMPCIE_H2D_MSGRING_CONTROL_SUBMIT),
  205. BCMPCIE_H2D_MSGRING_RXPOST_SUBMIT_IDX =
  206. BCMPCIE_H2D_RING_IDX(BCMPCIE_H2D_MSGRING_RXPOST_SUBMIT),
  207. /* First TxPost's WR or RD index starts after all H2D common rings */
  208. BCMPCIE_H2D_MSGRING_TXFLOW_IDX_START =
  209. BCMPCIE_H2D_RING_IDX(BCMPCIE_H2D_COMMON_MSGRINGS)
  210. };
  211. #define BCMPCIE_D2H_RING_IDX(d2h_ring_id) \
  212. ((d2h_ring_id) - BCMPCIE_H2D_COMMON_MSGRINGS)
  213. enum d2hring_idx {
  214. /* D2H Common Rings */
  215. BCMPCIE_D2H_MSGRING_CONTROL_COMPLETE_IDX =
  216. BCMPCIE_D2H_RING_IDX(BCMPCIE_D2H_MSGRING_CONTROL_COMPLETE),
  217. BCMPCIE_D2H_MSGRING_TX_COMPLETE_IDX =
  218. BCMPCIE_D2H_RING_IDX(BCMPCIE_D2H_MSGRING_TX_COMPLETE),
  219. BCMPCIE_D2H_MSGRING_RX_COMPLETE_IDX =
  220. BCMPCIE_D2H_RING_IDX(BCMPCIE_D2H_MSGRING_RX_COMPLETE)
  221. };
  222. /**
  223. * Macros for managing arrays of RD WR indices:
  224. * rw_index_sz:
  225. * - in dongle, rw_index_sz is known at compile time
  226. * - in host/DHD, rw_index_sz is derived from advertized pci_shared flags
  227. *
  228. * ring_idx: See h2dring_idx and d2hring_idx
  229. */
  230. /** Offset of a RD or WR index in H2D or D2H indices array */
  231. #define BCMPCIE_RW_INDEX_OFFSET(rw_index_sz, ring_idx) \
  232. ((rw_index_sz) * (ring_idx))
  233. /** Fetch the address of RD or WR index in H2D or D2H indices array */
  234. #define BCMPCIE_RW_INDEX_ADDR(indices_array_base, rw_index_sz, ring_idx) \
  235. (void *)((uint32)(indices_array_base) + \
  236. BCMPCIE_RW_INDEX_OFFSET((rw_index_sz), (ring_idx)))
  237. /** H2D DMA Indices array size: given max flow rings */
  238. #define BCMPCIE_H2D_RW_INDEX_ARRAY_SZ(rw_index_sz, max_tx_flows) \
  239. ((rw_index_sz) * BCMPCIE_H2D_MSGRINGS(max_tx_flows))
  240. /** D2H DMA Indices array size */
  241. #define BCMPCIE_D2H_RW_INDEX_ARRAY_SZ(rw_index_sz) \
  242. ((rw_index_sz) * BCMPCIE_D2H_COMMON_MSGRINGS)
  243. /**
  244. * This type is used by a 'message buffer' (which is a FIFO for messages). Message buffers are used
  245. * for host<->device communication and are instantiated on both sides. ring_mem_t is instantiated
  246. * both in host as well as device memory.
  247. */
  248. typedef struct ring_mem {
  249. uint16 idx; /* ring id */
  250. uint8 type;
  251. uint8 rsvd;
  252. uint16 max_item; /* Max number of items in flow ring */
  253. uint16 len_items; /* Items are fixed size. Length in bytes of one item */
  254. sh_addr_t base_addr; /* 64 bits address, either in host or device memory */
  255. } ring_mem_t;
  256. /**
  257. * Per flow ring, information is maintained in device memory, eg at what address the ringmem and
  258. * ringstate are located. The flow ring itself can be instantiated in either host or device memory.
  259. *
  260. * Perhaps this type should be renamed to make clear that it resides in device memory only.
  261. */
  262. typedef struct ring_info {
  263. uint32 ringmem_ptr; /* ring mem location in dongle memory */
  264. /* Following arrays are indexed using h2dring_idx and d2hring_idx, and not
  265. * by a ringid.
  266. */
  267. /* 32bit ptr to arrays of WR or RD indices for all rings in dongle memory */
  268. uint32 h2d_w_idx_ptr; /* Array of all H2D ring's WR indices */
  269. uint32 h2d_r_idx_ptr; /* Array of all H2D ring's RD indices */
  270. uint32 d2h_w_idx_ptr; /* Array of all D2H ring's WR indices */
  271. uint32 d2h_r_idx_ptr; /* Array of all D2H ring's RD indices */
  272. /* PCIE_DMA_INDEX feature: Dongle uses mem2mem DMA to sync arrays in host.
  273. * Host may directly fetch WR and RD indices from these host-side arrays.
  274. *
  275. * 64bit ptr to arrays of WR or RD indices for all rings in host memory.
  276. */
  277. sh_addr_t h2d_w_idx_hostaddr; /* Array of all H2D ring's WR indices */
  278. sh_addr_t h2d_r_idx_hostaddr; /* Array of all H2D ring's RD indices */
  279. sh_addr_t d2h_w_idx_hostaddr; /* Array of all D2H ring's WR indices */
  280. sh_addr_t d2h_r_idx_hostaddr; /* Array of all D2H ring's RD indices */
  281. uint16 max_tx_flowrings; /* maximum number of H2D rings: common + flow */
  282. uint16 max_submission_queues; /* maximum number of H2D rings: common + flow */
  283. uint16 max_completion_rings; /* maximum number of H2D rings: common + flow */
  284. uint16 max_vdevs; /* max number of virtual interfaces supported */
  285. sh_addr_t ifrm_w_idx_hostaddr; /* Array of all H2D ring's WR indices for IFRM */
  286. /* 32bit ptr to arrays of HWA DB indices for all rings in dongle memory */
  287. uint32 h2d_hwa_db_idx_ptr; /* Array of all H2D ring's HWA DB indices */
  288. uint32 d2h_hwa_db_idx_ptr; /* Array of all D2H ring's HWA DB indices */
  289. } ring_info_t;
  290. /**
  291. * A structure located in TCM that is shared between host and device, primarily used during
  292. * initialization.
  293. */
  294. typedef struct {
  295. /** shared area version captured at flags 7:0 */
  296. uint32 flags;
  297. uint32 trap_addr;
  298. uint32 assert_exp_addr;
  299. uint32 assert_file_addr;
  300. uint32 assert_line;
  301. uint32 console_addr; /**< Address of hnd_cons_t */
  302. uint32 msgtrace_addr;
  303. uint32 fwid;
  304. /* Used for debug/flow control */
  305. uint16 total_lfrag_pkt_cnt;
  306. uint16 max_host_rxbufs; /* rsvd in spec */
  307. uint32 dma_rxoffset; /* rsvd in spec */
  308. /** these will be used for sleep request/ack, d3 req/ack */
  309. uint32 h2d_mb_data_ptr;
  310. uint32 d2h_mb_data_ptr;
  311. /* information pertinent to host IPC/msgbuf channels */
  312. /** location in the TCM memory which has the ring_info */
  313. uint32 rings_info_ptr;
  314. /** block of host memory for the scratch buffer */
  315. uint32 host_dma_scratch_buffer_len;
  316. sh_addr_t host_dma_scratch_buffer;
  317. /* location in host memory for scb host offload structures */
  318. sh_addr_t host_scb_addr;
  319. uint32 host_scb_size;
  320. /* anonymous union for overloading fields in structure */
  321. union {
  322. uint32 buzz_dbg_ptr; /* BUZZZ state format strings and trace buffer */
  323. struct {
  324. /* Host provided trap buffer length in words */
  325. uint16 device_trap_debug_buffer_len;
  326. uint16 rsvd2;
  327. };
  328. };
  329. /* rev6 compatible changes */
  330. uint32 flags2;
  331. uint32 host_cap;
  332. /* location in the host address space to write trap indication.
  333. * At this point for the current rev of the spec, firmware will
  334. * support only indications to 32 bit host addresses.
  335. * This essentially is device_trap_debug_buffer_addr
  336. */
  337. sh_addr_t host_trap_addr;
  338. /* location for host fatal error log buffer start address */
  339. uint32 device_fatal_logbuf_start;
  340. /* location in host memory for offloaded modules */
  341. sh_addr_t hoffload_addr;
  342. uint32 flags3;
  343. uint32 host_cap2;
  344. uint32 host_cap3;
  345. } pciedev_shared_t;
  346. /* Device F/W provides the following access function:
  347. * pciedev_shared_t *hnd_get_pciedev_shared(void);
  348. */
  349. /* host capabilities */
  350. #define HOSTCAP_PCIEAPI_VERSION_MASK 0x000000FF
  351. #define HOSTCAP_H2D_VALID_PHASE 0x00000100
  352. #define HOSTCAP_H2D_ENABLE_TRAP_ON_BADPHASE 0x00000200
  353. #define HOSTCAP_H2D_ENABLE_HOSTRDY 0x00000400
  354. #define HOSTCAP_DB0_TIMESTAMP 0x00000800
  355. #define HOSTCAP_DS_NO_OOB_DW 0x00001000
  356. #define HOSTCAP_DS_INBAND_DW 0x00002000
  357. #define HOSTCAP_H2D_IDMA 0x00004000
  358. #define HOSTCAP_H2D_IFRM 0x00008000
  359. #define HOSTCAP_H2D_DAR 0x00010000
  360. #define HOSTCAP_EXTENDED_TRAP_DATA 0x00020000
  361. #define HOSTCAP_TXSTATUS_METADATA 0x00040000
  362. #define HOSTCAP_BT_LOGGING 0x00080000
  363. #define HOSTCAP_SNAPSHOT_UPLOAD 0x00100000
  364. #define HOSTCAP_FAST_DELETE_RING 0x00200000
  365. #define HOSTCAP_PKT_TXSTATUS 0x00400000
  366. #define HOSTCAP_UR_FW_NO_TRAP 0x00800000 /* Don't trap on UR */
  367. #define HOSTCAP_HSCB 0x02000000
  368. /* Host support for extended device trap debug buffer */
  369. #define HOSTCAP_EXT_TRAP_DBGBUF 0x04000000
  370. /* Host support for enhanced debug lane */
  371. #define HOSTCAP_EDL_RING 0x10000000
  372. #define HOSTCAP_PKT_TIMESTAMP 0x20000000
  373. #define HOSTCAP_PKT_HP2P 0x40000000
  374. #define HOSTCAP_HWA 0x80000000
  375. #define HOSTCAP2_DURATION_SCALE_MASK 0x0000003Fu
  376. /* extended trap debug buffer allocation sizes. Note that this buffer can be used for
  377. * other trap related purposes also.
  378. */
  379. #define BCMPCIE_HOST_EXT_TRAP_DBGBUF_LEN_MIN (64u * 1024u)
  380. #define BCMPCIE_HOST_EXT_TRAP_DBGBUF_LEN_MAX (256u * 1024u)
  381. /**
  382. * Mailboxes notify a remote party that an event took place, using interrupts. They use hardware
  383. * support.
  384. */
  385. /* H2D mail box Data */
  386. #define H2D_HOST_D3_INFORM 0x00000001
  387. #define H2D_HOST_DS_ACK 0x00000002
  388. #define H2D_HOST_DS_NAK 0x00000004
  389. #define H2D_HOST_D0_INFORM_IN_USE 0x00000008
  390. #define H2D_HOST_D0_INFORM 0x00000010
  391. #define H2DMB_DS_ACTIVE 0x00000020
  392. #define H2DMB_DS_DEVICE_WAKE 0x00000040
  393. #define H2D_HOST_IDMA_INITED 0x00000080
  394. #define H2D_HOST_ACK_NOINT 0x00010000 /* d2h_ack interrupt ignore */
  395. #define H2D_HOST_CONS_INT 0x80000000 /**< h2d int for console cmds */
  396. #define H2D_FW_TRAP 0x20000000 /**< h2d force TRAP */
  397. #define H2DMB_DS_HOST_SLEEP_INFORM H2D_HOST_D3_INFORM
  398. #define H2DMB_DS_DEVICE_SLEEP_ACK H2D_HOST_DS_ACK
  399. #define H2DMB_DS_DEVICE_SLEEP_NAK H2D_HOST_DS_NAK
  400. #define H2DMB_D0_INFORM_IN_USE H2D_HOST_D0_INFORM_IN_USE
  401. #define H2DMB_D0_INFORM H2D_HOST_D0_INFORM
  402. #define H2DMB_FW_TRAP H2D_FW_TRAP
  403. #define H2DMB_HOST_CONS_INT H2D_HOST_CONS_INT
  404. #define H2DMB_DS_DEVICE_WAKE_ASSERT H2DMB_DS_DEVICE_WAKE
  405. #define H2DMB_DS_DEVICE_WAKE_DEASSERT H2DMB_DS_ACTIVE
  406. /* D2H mail box Data */
  407. #define D2H_DEV_D3_ACK 0x00000001
  408. #define D2H_DEV_DS_ENTER_REQ 0x00000002
  409. #define D2H_DEV_DS_EXIT_NOTE 0x00000004
  410. #define D2HMB_DS_HOST_SLEEP_EXIT_ACK 0x00000008
  411. #define D2H_DEV_IDMA_INITED 0x00000010
  412. #define D2H_DEV_FWHALT 0x10000000
  413. #define D2H_DEV_TRAP_PING_HOST_FAILURE 0x08000000
  414. #define D2H_DEV_EXT_TRAP_DATA 0x20000000
  415. #define D2H_DEV_TRAP_IN_TRAP 0x40000000
  416. #define D2H_DEV_TRAP_DUE_TO_BT 0x01000000
  417. /* Indicates trap due to HMAP violation */
  418. #define D2H_DEV_TRAP_DUE_TO_HMAP 0x02000000
  419. /* Indicates whether HMAP violation was Write */
  420. #define D2H_DEV_TRAP_HMAP_WRITE 0x04000000
  421. #define D2HMB_DS_HOST_SLEEP_ACK D2H_DEV_D3_ACK
  422. #define D2HMB_DS_DEVICE_SLEEP_ENTER_REQ D2H_DEV_DS_ENTER_REQ
  423. #define D2HMB_DS_DEVICE_SLEEP_EXIT D2H_DEV_DS_EXIT_NOTE
  424. #define D2HMB_FWHALT D2H_DEV_FWHALT
  425. #define D2HMB_TRAP_IN_TRAP D2H_DEV_TRAP_IN_TRAP
  426. #define D2HMB_EXT_TRAP_DATA D2H_DEV_EXT_TRAP_DATA
  427. #define D2H_FWTRAP_MASK 0x0000001F /* Adding maskbits for TRAP information */
  428. #define D2H_DEV_MB_MASK (D2H_DEV_D3_ACK | D2H_DEV_DS_ENTER_REQ | \
  429. D2H_DEV_DS_EXIT_NOTE | D2H_DEV_IDMA_INITED | D2H_DEV_FWHALT | \
  430. D2H_FWTRAP_MASK | D2H_DEV_EXT_TRAP_DATA | D2H_DEV_TRAP_IN_TRAP)
  431. #define D2H_DEV_MB_INVALIDATED(x) ((!x) || (x & ~D2H_DEV_MB_MASK))
  432. /* Size of Extended Trap data Buffer */
  433. #define BCMPCIE_EXT_TRAP_DATA_MAXLEN 4096
  434. /** These macro's operate on type 'inuse_lclbuf_pool_t' and are used by firmware only */
  435. #define PREVTXP(i, d) (((i) == 0) ? ((d) - 1) : ((i) - 1))
  436. #define NEXTTXP(i, d) ((((i)+1) >= (d)) ? 0 : ((i)+1))
  437. #define NEXTNTXP(i, n, d) ((((i)+(n)) >= (d)) ? 0 : ((i)+(n)))
  438. #define NTXPACTIVE(r, w, d) (((r) <= (w)) ? ((w)-(r)) : ((d)-(r)+(w)))
  439. #define NTXPAVAIL(r, w, d) (((d) - NTXPACTIVE((r), (w), (d))) > 1)
  440. /* Function can be used to notify host of FW halt */
  441. #define READ_AVAIL_SPACE(w, r, d) ((w >= r) ? (uint32)(w - r) : (uint32)(d - r))
  442. #define WRITE_SPACE_AVAIL_CONTINUOUS(r, w, d) ((w >= r) ? (d - w) : (r - w))
  443. #define WRITE_SPACE_AVAIL(r, w, d) (d - (NTXPACTIVE(r, w, d)) - 1)
  444. #define CHECK_WRITE_SPACE(r, w, d) ((r) > (w)) ? \
  445. (uint32)((r) - (w) - 1) : ((r) == 0 || (w) == 0) ? \
  446. (uint32)((d) - (w) - 1) : (uint32)((d) - (w))
  447. #define CHECK_NOWRITE_SPACE(r, w, d) \
  448. (((uint32)(r) == (uint32)((w) + 1)) || (((r) == 0) && ((w) == ((d) - 1))))
  449. #define WRT_PEND(x) ((x)->wr_pending)
  450. #define DNGL_RING_WPTR(msgbuf) (*((msgbuf)->tcm_rs_w_ptr)) /**< advanced by producer */
  451. #define BCMMSGBUF_RING_SET_W_PTR(msgbuf, a) (DNGL_RING_WPTR(msgbuf) = (a))
  452. #define DNGL_RING_RPTR(msgbuf) (*((msgbuf)->tcm_rs_r_ptr)) /**< advanced by consumer */
  453. #define BCMMSGBUF_RING_SET_R_PTR(msgbuf, a) (DNGL_RING_RPTR(msgbuf) = (a))
  454. #define MODULO_RING_IDX(x, y) ((x) % (y)->bitmap_size)
  455. #define RING_READ_PTR(x) ((x)->ringstate->r_offset)
  456. #define RING_WRITE_PTR(x) ((x)->ringstate->w_offset)
  457. #define RING_START_PTR(x) ((x)->ringmem->base_addr.low_addr)
  458. #define RING_MAX_ITEM(x) ((x)->ringmem->max_item)
  459. #define RING_LEN_ITEMS(x) ((x)->ringmem->len_items)
  460. #define HOST_RING_BASE(x) ((x)->dma_buf.va)
  461. #define HOST_RING_END(x) ((uint8 *)HOST_RING_BASE((x)) + \
  462. ((RING_MAX_ITEM((x))-1)*RING_LEN_ITEMS((x))))
  463. /* Trap types copied in the pciedev_shared.trap_addr */
  464. #define FW_INITIATED_TRAP_TYPE (0x1 << 7)
  465. #define HEALTHCHECK_NODS_TRAP_TYPE (0x1 << 6)
  466. #endif /* _bcmpcie_h_ */