ipa_uc_offload_i.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _IPA_UC_OFFLOAD_I_H_
  6. #define _IPA_UC_OFFLOAD_I_H_
  7. #include <linux/ipa.h>
  8. #include "ipa_i.h"
  9. /*
  10. * Neutrino protocol related data structures
  11. */
  12. #define IPA_UC_MAX_NTN_TX_CHANNELS 1
  13. #define IPA_UC_MAX_NTN_RX_CHANNELS 1
  14. #define IPA_NTN_TX_DIR 1
  15. #define IPA_NTN_RX_DIR 2
  16. #define MAX_CH_STATS_SUPPORTED 5
  17. #define DIR_CONSUMER 0
  18. #define DIR_PRODUCER 1
  19. #define MAX_AQC_CHANNELS 2
  20. #define MAX_11AD_CHANNELS 5
  21. #define MAX_WDI2_CHANNELS 2
  22. #define MAX_WDI3_CHANNELS 2
  23. #define MAX_MHIP_CHANNELS 4
  24. #define MAX_USB_CHANNELS 2
  25. #define BW_QUOTA_MONITORING_MAX_ADDR_OFFSET 8
  26. #define BW_MONITORING_MAX_THRESHOLD 3
  27. /**
  28. * @brief Enum value determined based on the feature it
  29. * corresponds to
  30. * +----------------+----------------+
  31. * | 3 bits | 5 bits |
  32. * +----------------+----------------+
  33. * | HW_FEATURE | OPCODE |
  34. * +----------------+----------------+
  35. *
  36. */
  37. #define FEATURE_ENUM_VAL(feature, opcode) ((feature << 5) | opcode)
  38. #define EXTRACT_UC_FEATURE(value) (value >> 5)
  39. #define IPA_HW_NUM_FEATURES 0x8
  40. /**
  41. * enum ipa3_hw_features - Values that represent the features supported
  42. * in IPA HW
  43. * @IPA_HW_FEATURE_COMMON : Feature related to common operation of IPA HW
  44. * @IPA_HW_FEATURE_MHI : Feature related to MHI operation in IPA HW
  45. * @IPA_HW_FEATURE_POWER_COLLAPSE: Feature related to IPA Power collapse
  46. * @IPA_HW_FEATURE_WDI : Feature related to WDI operation in IPA HW
  47. * @IPA_HW_FEATURE_NTN : Feature related to NTN operation in IPA HW
  48. * @IPA_HW_FEATURE_OFFLOAD : Feature related to several protocols operation in
  49. * IPA HW. use protocol field to
  50. * determine (e.g. IPA_HW_PROTOCOL_11ad).
  51. */
  52. enum ipa3_hw_features {
  53. IPA_HW_FEATURE_COMMON = 0x0,
  54. IPA_HW_FEATURE_MHI = 0x1,
  55. IPA_HW_FEATURE_POWER_COLLAPSE = 0x2,
  56. IPA_HW_FEATURE_WDI = 0x3,
  57. IPA_HW_FEATURE_ZIP = 0x4,
  58. IPA_HW_FEATURE_NTN = 0x5,
  59. IPA_HW_FEATURE_OFFLOAD = 0x6,
  60. IPA_HW_FEATURE_MAX = IPA_HW_NUM_FEATURES
  61. };
  62. /**
  63. * enum ipa4_hw_protocol - Values that represent the protocols supported
  64. * in IPA HW when using the IPA_HW_FEATURE_OFFLOAD feature.
  65. * @IPA_HW_FEATURE_COMMON : protocol related to common operation of IPA HW
  66. * @IPA_HW_PROTOCOL_AQC : protocol related to AQC operation in IPA HW
  67. * @IPA_HW_PROTOCOL_11ad: protocol related to 11ad operation in IPA HW
  68. * @IPA_HW_PROTOCOL_WDI : protocol related to WDI operation in IPA HW
  69. * @IPA_HW_PROTOCOL_WDI3: protocol related to WDI3 operation in IPA HW
  70. * @IPA_HW_PROTOCOL_ETH : protocol related to ETH operation in IPA HW
  71. * @IPA_HW_PROTOCOL_MHIP: protocol related to MHIP operation in IPA HW
  72. * @IPA_HW_PROTOCOL_USB : protocol related to USB operation in IPA HW
  73. */
  74. enum ipa4_hw_protocol {
  75. IPA_HW_PROTOCOL_COMMON = 0x0,
  76. IPA_HW_PROTOCOL_AQC = 0x1,
  77. IPA_HW_PROTOCOL_11ad = 0x2,
  78. IPA_HW_PROTOCOL_WDI = 0x3,
  79. IPA_HW_PROTOCOL_WDI3 = 0x4,
  80. IPA_HW_PROTOCOL_ETH = 0x5,
  81. IPA_HW_PROTOCOL_MHIP = 0x6,
  82. IPA_HW_PROTOCOL_USB = 0x7,
  83. IPA_HW_PROTOCOL_MAX
  84. };
  85. /**
  86. * enum ipa3_hw_2_cpu_events - Values that represent HW event to be sent to CPU.
  87. * @IPA_HW_2_CPU_EVENT_NO_OP : No event present
  88. * @IPA_HW_2_CPU_EVENT_ERROR : Event specify a system error is detected by the
  89. * device
  90. * @IPA_HW_2_CPU_EVENT_LOG_INFO : Event providing logging specific information
  91. * @IPA_HW_2_CPU_POST_EVNT_RING_NOTIFICAITON : Event to notify APPS
  92. */
  93. enum ipa3_hw_2_cpu_events {
  94. IPA_HW_2_CPU_EVENT_NO_OP =
  95. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 0),
  96. IPA_HW_2_CPU_EVENT_ERROR =
  97. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 1),
  98. IPA_HW_2_CPU_EVENT_LOG_INFO =
  99. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 2),
  100. IPA_HW_2_CPU_EVNT_RING_NOTIFY =
  101. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 3),
  102. };
  103. /**
  104. * enum ipa3_hw_errors - Common error types.
  105. * @IPA_HW_ERROR_NONE : No error persists
  106. * @IPA_HW_INVALID_DOORBELL_ERROR : Invalid data read from doorbell
  107. * @IPA_HW_DMA_ERROR : Unexpected DMA error
  108. * @IPA_HW_FATAL_SYSTEM_ERROR : HW has crashed and requires reset.
  109. * @IPA_HW_INVALID_OPCODE : Invalid opcode sent
  110. * @IPA_HW_INVALID_PARAMS : Invalid params for the requested command
  111. * @IPA_HW_GSI_CH_NOT_EMPTY_FAILURE : GSI channel emptiness validation failed
  112. * @IPA_HW_CONS_STOP_FAILURE : NTN/ETH CONS stop failed
  113. * @IPA_HW_PROD_STOP_FAILURE : NTN/ETH PROD stop failed
  114. */
  115. enum ipa3_hw_errors {
  116. IPA_HW_ERROR_NONE =
  117. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 0),
  118. IPA_HW_INVALID_DOORBELL_ERROR =
  119. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 1),
  120. IPA_HW_DMA_ERROR =
  121. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 2),
  122. IPA_HW_FATAL_SYSTEM_ERROR =
  123. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 3),
  124. IPA_HW_INVALID_OPCODE =
  125. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 4),
  126. IPA_HW_INVALID_PARAMS =
  127. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 5),
  128. IPA_HW_CONS_DISABLE_CMD_GSI_STOP_FAILURE =
  129. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 6),
  130. IPA_HW_PROD_DISABLE_CMD_GSI_STOP_FAILURE =
  131. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 7),
  132. IPA_HW_GSI_CH_NOT_EMPTY_FAILURE =
  133. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 8),
  134. IPA_HW_CONS_STOP_FAILURE =
  135. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 9),
  136. IPA_HW_PROD_STOP_FAILURE =
  137. FEATURE_ENUM_VAL(IPA_HW_FEATURE_COMMON, 10)
  138. };
  139. /**
  140. * struct IpaHwSharedMemCommonMapping_t - Structure referring to the common
  141. * section in 128B shared memory located in offset zero of SW Partition in IPA
  142. * SRAM.
  143. * @cmdOp : CPU->HW command opcode. See IPA_CPU_2_HW_COMMANDS
  144. * @cmdParams : CPU->HW command parameter lower 32bit.
  145. * @cmdParams_hi : CPU->HW command parameter higher 32bit.
  146. * of parameters (immediate parameters) and point on structure in system memory
  147. * (in such case the address must be accessible for HW)
  148. * @responseOp : HW->CPU response opcode. See IPA_HW_2_CPU_RESPONSES
  149. * @responseParams : HW->CPU response parameter. The parameter filed can hold 32
  150. * bits of parameters (immediate parameters) and point on structure in system
  151. * memory
  152. * @eventOp : HW->CPU event opcode. See IPA_HW_2_CPU_EVENTS
  153. * @eventParams : HW->CPU event parameter. The parameter filed can hold 32
  154. * bits of parameters (immediate parameters) and point on
  155. * structure in system memory
  156. * @firstErrorAddress : Contains the address of first error-source on SNOC
  157. * @hwState : State of HW. The state carries information regarding the
  158. * error type.
  159. * @warningCounter : The warnings counter. The counter carries information
  160. * regarding non fatal errors in HW
  161. * @interfaceVersionCommon : The Common interface version as reported by HW
  162. * @responseParams_1: offset addr for uC stats
  163. *
  164. * The shared memory is used for communication between IPA HW and CPU.
  165. */
  166. struct IpaHwSharedMemCommonMapping_t {
  167. u8 cmdOp;
  168. u8 reserved_01;
  169. u16 reserved_03_02;
  170. u32 cmdParams;
  171. u32 cmdParams_hi;
  172. u8 responseOp;
  173. u8 reserved_0D;
  174. u16 reserved_0F_0E;
  175. u32 responseParams;
  176. u8 eventOp;
  177. u8 reserved_15;
  178. u16 reserved_17_16;
  179. u32 eventParams;
  180. u32 firstErrorAddress;
  181. u8 hwState;
  182. u8 warningCounter;
  183. u16 reserved_23_22;
  184. u16 interfaceVersionCommon;
  185. u16 reserved_27_26;
  186. u32 responseParams_1;
  187. } __packed;
  188. /**
  189. * union Ipa3HwFeatureInfoData_t - parameters for stats/config blob
  190. *
  191. * @offset : Location of a feature within the EventInfoData
  192. * @size : Size of the feature
  193. */
  194. union Ipa3HwFeatureInfoData_t {
  195. struct IpaHwFeatureInfoParams_t {
  196. u32 offset:16;
  197. u32 size:16;
  198. } __packed params;
  199. u32 raw32b;
  200. } __packed;
  201. /**
  202. * union IpaHwErrorEventData_t - HW->CPU Common Events
  203. * @errorType : Entered when a system error is detected by the HW. Type of
  204. * error is specified by IPA_HW_ERRORS
  205. * @reserved : Reserved
  206. */
  207. union IpaHwErrorEventData_t {
  208. struct IpaHwErrorEventParams_t {
  209. u32 errorType:8;
  210. u32 reserved:24;
  211. } __packed params;
  212. u32 raw32b;
  213. } __packed;
  214. /**
  215. * struct Ipa3HwEventInfoData_t - Structure holding the parameters for
  216. * statistics and config info
  217. *
  218. * @baseAddrOffset : Base Address Offset of the statistics or config
  219. * structure from IPA_WRAPPER_BASE
  220. * @Ipa3HwFeatureInfoData_t : Location and size of each feature within
  221. * the statistics or config structure
  222. *
  223. * @note Information about each feature in the featureInfo[]
  224. * array is populated at predefined indices per the IPA_HW_FEATURES
  225. * enum definition
  226. */
  227. struct Ipa3HwEventInfoData_t {
  228. u32 baseAddrOffset;
  229. union Ipa3HwFeatureInfoData_t featureInfo[IPA_HW_NUM_FEATURES];
  230. } __packed;
  231. /**
  232. * struct IpaHwEventLogInfoData_t - Structure holding the parameters for
  233. * IPA_HW_2_CPU_EVENT_LOG_INFO Event
  234. *
  235. * @protocolMask : Mask indicating the protocols enabled in HW.
  236. * Refer IPA_HW_FEATURE_MASK
  237. * @circBuffBaseAddrOffset : Base Address Offset of the Circular Event
  238. * Log Buffer structure
  239. * @statsInfo : Statistics related information
  240. * @configInfo : Configuration related information
  241. *
  242. * @note The offset location of this structure from IPA_WRAPPER_BASE
  243. * will be provided as Event Params for the IPA_HW_2_CPU_EVENT_LOG_INFO
  244. * Event
  245. */
  246. struct IpaHwEventLogInfoData_t {
  247. u32 protocolMask;
  248. u32 circBuffBaseAddrOffset;
  249. struct Ipa3HwEventInfoData_t statsInfo;
  250. struct Ipa3HwEventInfoData_t configInfo;
  251. } __packed;
  252. /**
  253. * struct ipa3_uc_ntn_ctx
  254. * @ntn_uc_stats_ofst: Neutrino stats offset
  255. * @ntn_uc_stats_mmio: Neutrino stats
  256. * @priv: private data of client
  257. * @uc_ready_cb: uc Ready cb
  258. */
  259. struct ipa3_uc_ntn_ctx {
  260. u32 ntn_uc_stats_ofst;
  261. struct Ipa3HwStatsNTNInfoData_t *ntn_uc_stats_mmio;
  262. void *priv;
  263. ipa_uc_ready_cb uc_ready_cb;
  264. };
  265. /**
  266. * enum ipa3_hw_ntn_channel_states - Values that represent NTN
  267. * channel state machine.
  268. * @IPA_HW_NTN_CHANNEL_STATE_INITED_DISABLED : Channel is
  269. * initialized but disabled
  270. * @IPA_HW_NTN_CHANNEL_STATE_RUNNING : Channel is running.
  271. * Entered after SET_UP_COMMAND is processed successfully
  272. * @IPA_HW_NTN_CHANNEL_STATE_ERROR : Channel is in error state
  273. * @IPA_HW_NTN_CHANNEL_STATE_INVALID : Invalid state. Shall not
  274. * be in use in operational scenario
  275. *
  276. * These states apply to both Tx and Rx paths. These do not reflect the
  277. * sub-state the state machine may be in.
  278. */
  279. enum ipa3_hw_ntn_channel_states {
  280. IPA_HW_NTN_CHANNEL_STATE_INITED_DISABLED = 1,
  281. IPA_HW_NTN_CHANNEL_STATE_RUNNING = 2,
  282. IPA_HW_NTN_CHANNEL_STATE_ERROR = 3,
  283. IPA_HW_NTN_CHANNEL_STATE_INVALID = 0xFF
  284. };
  285. /**
  286. * enum ipa3_hw_ntn_channel_errors - List of NTN Channel error
  287. * types. This is present in the event param
  288. * @IPA_HW_NTN_CH_ERR_NONE: No error persists
  289. * @IPA_HW_NTN_TX_FSM_ERROR: Error in the state machine
  290. * transition
  291. * @IPA_HW_NTN_TX_COMP_RE_FETCH_FAIL: Error while calculating
  292. * num RE to bring
  293. * @IPA_HW_NTN_RX_RING_WP_UPDATE_FAIL: Write pointer update
  294. * failed in Rx ring
  295. * @IPA_HW_NTN_RX_FSM_ERROR: Error in the state machine
  296. * transition
  297. * @IPA_HW_NTN_RX_CACHE_NON_EMPTY:
  298. * @IPA_HW_NTN_CH_ERR_RESERVED:
  299. *
  300. * These states apply to both Tx and Rx paths. These do not
  301. * reflect the sub-state the state machine may be in.
  302. */
  303. enum ipa3_hw_ntn_channel_errors {
  304. IPA_HW_NTN_CH_ERR_NONE = 0,
  305. IPA_HW_NTN_TX_RING_WP_UPDATE_FAIL = 1,
  306. IPA_HW_NTN_TX_FSM_ERROR = 2,
  307. IPA_HW_NTN_TX_COMP_RE_FETCH_FAIL = 3,
  308. IPA_HW_NTN_RX_RING_WP_UPDATE_FAIL = 4,
  309. IPA_HW_NTN_RX_FSM_ERROR = 5,
  310. IPA_HW_NTN_RX_CACHE_NON_EMPTY = 6,
  311. IPA_HW_NTN_CH_ERR_RESERVED = 0xFF
  312. };
  313. /**
  314. * struct Ipa3HwNtnSetUpCmdData_t - Ntn setup command data
  315. * @ring_base_pa: physical address of the base of the Tx/Rx NTN
  316. * ring
  317. * @buff_pool_base_pa: physical address of the base of the Tx/Rx
  318. * buffer pool
  319. * @ntn_ring_size: size of the Tx/Rx NTN ring
  320. * @num_buffers: Rx/tx buffer pool size
  321. * @ntn_reg_base_ptr_pa: physical address of the Tx/Rx NTN
  322. * Ring's tail pointer
  323. * @ipa_pipe_number: IPA pipe number that has to be used for the
  324. * Tx/Rx path
  325. * @dir: Tx/Rx Direction
  326. * @data_buff_size: size of the each data buffer allocated in
  327. * DDR
  328. */
  329. struct Ipa3HwNtnSetUpCmdData_t {
  330. u32 ring_base_pa;
  331. u32 buff_pool_base_pa;
  332. u16 ntn_ring_size;
  333. u16 num_buffers;
  334. u32 ntn_reg_base_ptr_pa;
  335. u8 ipa_pipe_number;
  336. u8 dir;
  337. u16 data_buff_size;
  338. } __packed;
  339. /**
  340. * struct Ipa3HwNtnCommonChCmdData_t - Structure holding the
  341. * parameters for Ntn Tear down command data params
  342. *
  343. *@ipa_pipe_number: IPA pipe number. This could be Tx or an Rx pipe
  344. */
  345. union Ipa3HwNtnCommonChCmdData_t {
  346. struct IpaHwNtnCommonChCmdParams_t {
  347. u32 ipa_pipe_number :8;
  348. u32 reserved :24;
  349. } __packed params;
  350. uint32_t raw32b;
  351. } __packed;
  352. /**
  353. * struct NTN3RxInfoData_t - NTN Structure holding the Rx pipe
  354. * information
  355. *
  356. *@num_pkts_processed: Number of packets processed - cumulative
  357. *
  358. *@ring_stats:
  359. *@gsi_stats:
  360. *@num_db: Number of times the doorbell was rung
  361. *@num_qmb_int_handled: Number of QMB interrupts handled
  362. *@ipa_pipe_number: The IPA Rx/Tx pipe number.
  363. */
  364. struct NTN3RxInfoData_t {
  365. u32 num_pkts_processed;
  366. struct IpaHwRingStats_t ring_stats;
  367. struct IpaHwBamStats_t gsi_stats;
  368. u32 num_db;
  369. u32 num_qmb_int_handled;
  370. u32 ipa_pipe_number;
  371. } __packed;
  372. /**
  373. * struct NTN3TxInfoData_t - Structure holding the NTN Tx channel
  374. * Ensure that this is always word aligned
  375. *
  376. *@num_pkts_processed: Number of packets processed - cumulative
  377. *@tail_ptr_val: Latest value of doorbell written to copy engine
  378. *@num_db_fired: Number of DB from uC FW to Copy engine
  379. *
  380. *@tx_comp_ring_stats:
  381. *@bam_stats:
  382. *@num_db: Number of times the doorbell was rung
  383. *@num_qmb_int_handled: Number of QMB interrupts handled
  384. */
  385. struct NTN3TxInfoData_t {
  386. u32 num_pkts_processed;
  387. struct IpaHwRingStats_t ring_stats;
  388. struct IpaHwBamStats_t gsi_stats;
  389. u32 num_db;
  390. u32 num_qmb_int_handled;
  391. u32 ipa_pipe_number;
  392. } __packed;
  393. /**
  394. * struct Ipa3HwStatsNTNInfoData_t - Structure holding the NTN Tx
  395. * channel Ensure that this is always word aligned
  396. *
  397. */
  398. struct Ipa3HwStatsNTNInfoData_t {
  399. struct NTN3RxInfoData_t rx_ch_stats[IPA_UC_MAX_NTN_RX_CHANNELS];
  400. struct NTN3TxInfoData_t tx_ch_stats[IPA_UC_MAX_NTN_TX_CHANNELS];
  401. } __packed;
  402. /*
  403. * uC offload related data structures
  404. */
  405. #define IPA_UC_OFFLOAD_CONNECTED BIT(0)
  406. #define IPA_UC_OFFLOAD_ENABLED BIT(1)
  407. #define IPA_UC_OFFLOAD_RESUMED BIT(2)
  408. /**
  409. * enum ipa_cpu_2_hw_offload_commands - Values that represent
  410. * the offload commands from CPU
  411. * @IPA_CPU_2_HW_CMD_OFFLOAD_CHANNEL_SET_UP : Command to set up
  412. * Offload protocol's Tx/Rx Path
  413. * @IPA_CPU_2_HW_CMD_OFFLOAD_TEAR_DOWN : Command to tear down
  414. * Offload protocol's Tx/ Rx Path
  415. * @IPA_CPU_2_HW_CMD_PERIPHERAL_INIT :Command to initialize peripheral
  416. * @IPA_CPU_2_HW_CMD_PERIPHERAL_DEINIT : Command to deinitialize peripheral
  417. * @IPA_CPU_2_HW_CMD_OFFLOAD_STATS_ALLOC: Command to start the
  418. * uC stats calculation for a particular protocol
  419. * @IPA_CPU_2_HW_CMD_OFFLOAD_STATS_DEALLOC: Command to stop the
  420. * uC stats calculation for a particular protocol
  421. * @IPA_CPU_2_HW_CMD_QUOTA_MONITORING : Command to start the Quota monitoring
  422. * @IPA_CPU_2_HW_CMD_BW_MONITORING : Command to start the BW monitoring
  423. */
  424. enum ipa_cpu_2_hw_offload_commands {
  425. IPA_CPU_2_HW_CMD_OFFLOAD_CHANNEL_SET_UP =
  426. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 1),
  427. IPA_CPU_2_HW_CMD_OFFLOAD_TEAR_DOWN =
  428. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 2),
  429. IPA_CPU_2_HW_CMD_PERIPHERAL_INIT =
  430. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 3),
  431. IPA_CPU_2_HW_CMD_PERIPHERAL_DEINIT =
  432. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 4),
  433. IPA_CPU_2_HW_CMD_OFFLOAD_STATS_ALLOC =
  434. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 5),
  435. IPA_CPU_2_HW_CMD_OFFLOAD_STATS_DEALLOC =
  436. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 6),
  437. IPA_CPU_2_HW_CMD_QUOTA_MONITORING =
  438. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 7),
  439. IPA_CPU_2_HW_CMD_BW_MONITORING =
  440. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 8),
  441. };
  442. /**
  443. * struct IpaHwOffloadStatsDeAllocCmdData_t - protocol info for
  444. * uC stats stop
  445. * @protocol: Enum that indicates the protocol type
  446. */
  447. struct IpaHwOffloadStatsDeAllocCmdData_t {
  448. uint32_t protocol;
  449. } __packed;
  450. /**
  451. * enum ipa3_hw_offload_channel_states - Values that represent
  452. * offload channel state machine.
  453. * @IPA_HW_OFFLOAD_CHANNEL_STATE_INITED_DISABLED : Channel is
  454. * initialized but disabled
  455. * @IPA_HW_OFFLOAD_CHANNEL_STATE_RUNNING : Channel is running.
  456. * Entered after SET_UP_COMMAND is processed successfully
  457. * @IPA_HW_OFFLOAD_CHANNEL_STATE_ERROR : Channel is in error state
  458. * @IPA_HW_OFFLOAD_CHANNEL_STATE_INVALID : Invalid state. Shall not
  459. * be in use in operational scenario
  460. *
  461. * These states apply to both Tx and Rx paths. These do not
  462. * reflect the sub-state the state machine may be in
  463. */
  464. enum ipa3_hw_offload_channel_states {
  465. IPA_HW_OFFLOAD_CHANNEL_STATE_INITED_DISABLED = 1,
  466. IPA_HW_OFFLOAD_CHANNEL_STATE_RUNNING = 2,
  467. IPA_HW_OFFLOAD_CHANNEL_STATE_ERROR = 3,
  468. IPA_HW_OFFLOAD_CHANNEL_STATE_INVALID = 0xFF
  469. };
  470. /**
  471. * enum ipa3_hw_2_cpu_cmd_resp_status - Values that represent
  472. * offload related command response status to be sent to CPU.
  473. */
  474. enum ipa3_hw_2_cpu_offload_cmd_resp_status {
  475. IPA_HW_2_CPU_OFFLOAD_CMD_STATUS_SUCCESS =
  476. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 0),
  477. IPA_HW_2_CPU_OFFLOAD_MAX_TX_CHANNELS =
  478. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 1),
  479. IPA_HW_2_CPU_OFFLOAD_TX_RING_OVERRUN_POSSIBILITY =
  480. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 2),
  481. IPA_HW_2_CPU_OFFLOAD_TX_RING_SET_UP_FAILURE =
  482. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 3),
  483. IPA_HW_2_CPU_OFFLOAD_TX_RING_PARAMS_UNALIGNED =
  484. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 4),
  485. IPA_HW_2_CPU_OFFLOAD_UNKNOWN_TX_CHANNEL =
  486. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 5),
  487. IPA_HW_2_CPU_OFFLOAD_TX_INVALID_FSM_TRANSITION =
  488. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 6),
  489. IPA_HW_2_CPU_OFFLOAD_TX_FSM_TRANSITION_ERROR =
  490. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 7),
  491. IPA_HW_2_CPU_OFFLOAD_MAX_RX_CHANNELS =
  492. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 8),
  493. IPA_HW_2_CPU_OFFLOAD_RX_RING_PARAMS_UNALIGNED =
  494. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 9),
  495. IPA_HW_2_CPU_OFFLOAD_RX_RING_SET_UP_FAILURE =
  496. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 10),
  497. IPA_HW_2_CPU_OFFLOAD_UNKNOWN_RX_CHANNEL =
  498. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 11),
  499. IPA_HW_2_CPU_OFFLOAD_RX_INVALID_FSM_TRANSITION =
  500. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 12),
  501. IPA_HW_2_CPU_OFFLOAD_RX_FSM_TRANSITION_ERROR =
  502. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 13),
  503. IPA_HW_2_CPU_OFFLOAD_RX_RING_OVERRUN_POSSIBILITY =
  504. FEATURE_ENUM_VAL(IPA_HW_FEATURE_OFFLOAD, 14),
  505. };
  506. /**
  507. * struct IpaHw11adSetupCmdData_t - 11ad setup channel command data
  508. * @dir: Direction RX/TX
  509. * @wifi_ch: 11ad peripheral pipe number
  510. * @gsi_ch: GSI Channel number
  511. * @reserved: 8 bytes padding
  512. * @wifi_hp_addr_lsb: Head/Tail pointer absolute address
  513. * @wifi_hp_addr_msb: Head/Tail pointer absolute address
  514. */
  515. struct IpaHw11adSetupCmdData_t {
  516. u8 dir;
  517. u8 wifi_ch;
  518. u8 gsi_ch;
  519. u8 reserved;
  520. u32 wifi_hp_addr_lsb;
  521. u32 wifi_hp_addr_msb;
  522. } __packed;
  523. /**
  524. * struct IpaHw11adCommonChCmdData_t - 11ad tear down channel command data
  525. * @gsi_ch: GSI Channel number
  526. * @reserved_0: padding
  527. * @reserved_1: padding
  528. */
  529. struct IpaHw11adCommonChCmdData_t {
  530. u8 gsi_ch;
  531. u8 reserved_0;
  532. u16 reserved_1;
  533. } __packed;
  534. /**
  535. * struct IpaHw11adInitCmdData_t - 11ad peripheral init command data
  536. * @periph_baddr_lsb: Peripheral Base Address LSB (pa/IOVA)
  537. * @periph_baddr_msb: Peripheral Base Address MSB (pa/IOVA)
  538. */
  539. struct IpaHw11adInitCmdData_t {
  540. u32 periph_baddr_lsb;
  541. u32 periph_baddr_msb;
  542. } __packed;
  543. /**
  544. * struct IpaHw11adDeinitCmdData_t - 11ad peripheral deinit command data
  545. * @reserved: Reserved for future
  546. */
  547. struct IpaHw11adDeinitCmdData_t {
  548. u32 reserved;
  549. };
  550. /**
  551. * struct IpaHwSetUpCmd - Structure holding the parameters
  552. * for IPA_CPU_2_HW_CMD_OFFLOAD_CHANNEL_SET_UP
  553. *
  554. *
  555. */
  556. union IpaHwSetUpCmd {
  557. struct Ipa3HwNtnSetUpCmdData_t NtnSetupCh_params;
  558. struct IpaHw11adSetupCmdData_t W11AdSetupCh_params;
  559. } __packed;
  560. struct IpaHwOffloadSetUpCmdData_t {
  561. u8 protocol;
  562. union IpaHwSetUpCmd SetupCh_params;
  563. } __packed;
  564. struct IpaCommonMonitoringParams_t {
  565. /* max 8 */
  566. uint8_t Num;
  567. /* Sampling interval in ms */
  568. uint8_t Interval;
  569. uint16_t Offset[BW_QUOTA_MONITORING_MAX_ADDR_OFFSET];
  570. } __packed; // 18 bytes
  571. struct IpaWdiQuotaMonitoringParams_t {
  572. uint64_t Quota;
  573. struct IpaCommonMonitoringParams_t info;
  574. } __packed;
  575. struct IpaWdiBwMonitoringParams_t {
  576. uint64_t BwThreshold[BW_MONITORING_MAX_THRESHOLD];
  577. struct IpaCommonMonitoringParams_t info;
  578. uint8_t NumThresh;
  579. /*Variable to Start Stop Bw Monitoring*/
  580. uint8_t Stop;
  581. } __packed;
  582. union IpaQuotaMonitoringParams_t {
  583. struct IpaWdiQuotaMonitoringParams_t WdiQM;
  584. } __packed;
  585. union IpaBwMonitoringParams_t {
  586. struct IpaWdiBwMonitoringParams_t WdiBw;
  587. } __packed;
  588. struct IpaQuotaMonitoring_t {
  589. /* indicates below union needs to be interpreted */
  590. uint32_t protocol;
  591. union IpaQuotaMonitoringParams_t params;
  592. } __packed;
  593. struct IpaBwMonitoring_t {
  594. /* indicates below union needs to be interpreted */
  595. uint32_t protocol;
  596. union IpaBwMonitoringParams_t params;
  597. } __packed;
  598. struct IpaHwOffloadSetUpCmdData_t_v4_0 {
  599. u32 protocol;
  600. union IpaHwSetUpCmd SetupCh_params;
  601. } __packed;
  602. /**
  603. * struct IpaHwCommonChCmd - Structure holding the parameters
  604. * for IPA_CPU_2_HW_CMD_OFFLOAD_TEAR_DOWN
  605. *
  606. *
  607. */
  608. union IpaHwCommonChCmd {
  609. union Ipa3HwNtnCommonChCmdData_t NtnCommonCh_params;
  610. struct IpaHw11adCommonChCmdData_t W11AdCommonCh_params;
  611. } __packed;
  612. struct IpaHwOffloadCommonChCmdData_t {
  613. u8 protocol;
  614. union IpaHwCommonChCmd CommonCh_params;
  615. } __packed;
  616. enum EVENT_2_CPU_OPCODE {
  617. BW_NOTIFY = 0x0,
  618. QUOTA_NOTIFY = 0x1,
  619. };
  620. struct EventStructureBwMonitoring_t {
  621. uint32_t ThresholdIndex;
  622. uint64_t throughput;
  623. } __packed;
  624. struct EventStructureQuotaMonitoring_t {
  625. /* indicate threshold has reached */
  626. uint32_t ThreasholdReached;
  627. uint64_t usage;
  628. } __packed;
  629. union EventParamFormat_t {
  630. struct EventStructureBwMonitoring_t bw_param;
  631. struct EventStructureQuotaMonitoring_t quota_param;
  632. } __packed;
  633. /* EVT RING STRUCTURE
  634. * | Word| bit | Field |
  635. * -----------------------------
  636. * | 0 |0 - 8| Protocol|
  637. * | |8 - 16| Reserved0|
  638. * | |16 - 24| Opcode |
  639. * | |24 - 31| Reserved1|
  640. * | 1 |0 - 31| Word1 |
  641. * | 2 |0 - 31| Word2 |
  642. * | 3 |0 - 31| Word3 |
  643. */
  644. struct eventElement_t {
  645. uint8_t Protocol;
  646. uint8_t Reserved0;
  647. uint8_t Opcode;
  648. uint8_t Reserved1;
  649. union EventParamFormat_t Value;
  650. } __packed;
  651. struct IpaHwOffloadCommonChCmdData_t_v4_0 {
  652. u32 protocol;
  653. union IpaHwCommonChCmd CommonCh_params;
  654. } __packed;
  655. /**
  656. * union IpaHwPeripheralInitCmd - Structure holding the parameters
  657. * for IPA_CPU_2_HW_CMD_PERIPHERAL_INIT
  658. *
  659. */
  660. union IpaHwPeripheralInitCmd {
  661. struct IpaHw11adInitCmdData_t W11AdInit_params;
  662. } __packed;
  663. struct IpaHwPeripheralInitCmdData_t {
  664. u32 protocol;
  665. union IpaHwPeripheralInitCmd Init_params;
  666. } __packed;
  667. /**
  668. * union IpaHwPeripheralDeinitCmd - Structure holding the parameters
  669. * for IPA_CPU_2_HW_CMD_PERIPHERAL_DEINIT
  670. *
  671. */
  672. union IpaHwPeripheralDeinitCmd {
  673. struct IpaHw11adDeinitCmdData_t W11AdDeinit_params;
  674. } __packed;
  675. struct IpaHwPeripheralDeinitCmdData_t {
  676. u32 protocol;
  677. union IpaHwPeripheralDeinitCmd PeripheralDeinit_params;
  678. } __packed;
  679. #endif /* _IPA_UC_OFFLOAD_I_H_ */