cmd.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. /*
  2. * drivers/net/ethernet/mellanox/mlxsw/cmd.h
  3. * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2015 Jiri Pirko <jiri@mellanox.com>
  5. * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the names of the copyright holders nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * Alternatively, this software may be distributed under the terms of the
  20. * GNU General Public License ("GPL") version 2 as published by the Free
  21. * Software Foundation.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef _MLXSW_CMD_H
  36. #define _MLXSW_CMD_H
  37. #include "item.h"
  38. #define MLXSW_CMD_MBOX_SIZE 4096
  39. static inline char *mlxsw_cmd_mbox_alloc(void)
  40. {
  41. return kzalloc(MLXSW_CMD_MBOX_SIZE, GFP_KERNEL);
  42. }
  43. static inline void mlxsw_cmd_mbox_free(char *mbox)
  44. {
  45. kfree(mbox);
  46. }
  47. static inline void mlxsw_cmd_mbox_zero(char *mbox)
  48. {
  49. memset(mbox, 0, MLXSW_CMD_MBOX_SIZE);
  50. }
  51. struct mlxsw_core;
  52. int mlxsw_cmd_exec(struct mlxsw_core *mlxsw_core, u16 opcode, u8 opcode_mod,
  53. u32 in_mod, bool out_mbox_direct,
  54. char *in_mbox, size_t in_mbox_size,
  55. char *out_mbox, size_t out_mbox_size);
  56. static inline int mlxsw_cmd_exec_in(struct mlxsw_core *mlxsw_core, u16 opcode,
  57. u8 opcode_mod, u32 in_mod, char *in_mbox,
  58. size_t in_mbox_size)
  59. {
  60. return mlxsw_cmd_exec(mlxsw_core, opcode, opcode_mod, in_mod, false,
  61. in_mbox, in_mbox_size, NULL, 0);
  62. }
  63. static inline int mlxsw_cmd_exec_out(struct mlxsw_core *mlxsw_core, u16 opcode,
  64. u8 opcode_mod, u32 in_mod,
  65. bool out_mbox_direct,
  66. char *out_mbox, size_t out_mbox_size)
  67. {
  68. return mlxsw_cmd_exec(mlxsw_core, opcode, opcode_mod, in_mod,
  69. out_mbox_direct, NULL, 0,
  70. out_mbox, out_mbox_size);
  71. }
  72. static inline int mlxsw_cmd_exec_none(struct mlxsw_core *mlxsw_core, u16 opcode,
  73. u8 opcode_mod, u32 in_mod)
  74. {
  75. return mlxsw_cmd_exec(mlxsw_core, opcode, opcode_mod, in_mod, false,
  76. NULL, 0, NULL, 0);
  77. }
  78. enum mlxsw_cmd_opcode {
  79. MLXSW_CMD_OPCODE_QUERY_FW = 0x004,
  80. MLXSW_CMD_OPCODE_QUERY_BOARDINFO = 0x006,
  81. MLXSW_CMD_OPCODE_QUERY_AQ_CAP = 0x003,
  82. MLXSW_CMD_OPCODE_MAP_FA = 0xFFF,
  83. MLXSW_CMD_OPCODE_UNMAP_FA = 0xFFE,
  84. MLXSW_CMD_OPCODE_CONFIG_PROFILE = 0x100,
  85. MLXSW_CMD_OPCODE_ACCESS_REG = 0x040,
  86. MLXSW_CMD_OPCODE_SW2HW_DQ = 0x201,
  87. MLXSW_CMD_OPCODE_HW2SW_DQ = 0x202,
  88. MLXSW_CMD_OPCODE_2ERR_DQ = 0x01E,
  89. MLXSW_CMD_OPCODE_QUERY_DQ = 0x022,
  90. MLXSW_CMD_OPCODE_SW2HW_CQ = 0x016,
  91. MLXSW_CMD_OPCODE_HW2SW_CQ = 0x017,
  92. MLXSW_CMD_OPCODE_QUERY_CQ = 0x018,
  93. MLXSW_CMD_OPCODE_SW2HW_EQ = 0x013,
  94. MLXSW_CMD_OPCODE_HW2SW_EQ = 0x014,
  95. MLXSW_CMD_OPCODE_QUERY_EQ = 0x015,
  96. };
  97. static inline const char *mlxsw_cmd_opcode_str(u16 opcode)
  98. {
  99. switch (opcode) {
  100. case MLXSW_CMD_OPCODE_QUERY_FW:
  101. return "QUERY_FW";
  102. case MLXSW_CMD_OPCODE_QUERY_BOARDINFO:
  103. return "QUERY_BOARDINFO";
  104. case MLXSW_CMD_OPCODE_QUERY_AQ_CAP:
  105. return "QUERY_AQ_CAP";
  106. case MLXSW_CMD_OPCODE_MAP_FA:
  107. return "MAP_FA";
  108. case MLXSW_CMD_OPCODE_UNMAP_FA:
  109. return "UNMAP_FA";
  110. case MLXSW_CMD_OPCODE_CONFIG_PROFILE:
  111. return "CONFIG_PROFILE";
  112. case MLXSW_CMD_OPCODE_ACCESS_REG:
  113. return "ACCESS_REG";
  114. case MLXSW_CMD_OPCODE_SW2HW_DQ:
  115. return "SW2HW_DQ";
  116. case MLXSW_CMD_OPCODE_HW2SW_DQ:
  117. return "HW2SW_DQ";
  118. case MLXSW_CMD_OPCODE_2ERR_DQ:
  119. return "2ERR_DQ";
  120. case MLXSW_CMD_OPCODE_QUERY_DQ:
  121. return "QUERY_DQ";
  122. case MLXSW_CMD_OPCODE_SW2HW_CQ:
  123. return "SW2HW_CQ";
  124. case MLXSW_CMD_OPCODE_HW2SW_CQ:
  125. return "HW2SW_CQ";
  126. case MLXSW_CMD_OPCODE_QUERY_CQ:
  127. return "QUERY_CQ";
  128. case MLXSW_CMD_OPCODE_SW2HW_EQ:
  129. return "SW2HW_EQ";
  130. case MLXSW_CMD_OPCODE_HW2SW_EQ:
  131. return "HW2SW_EQ";
  132. case MLXSW_CMD_OPCODE_QUERY_EQ:
  133. return "QUERY_EQ";
  134. default:
  135. return "*UNKNOWN*";
  136. }
  137. }
  138. enum mlxsw_cmd_status {
  139. /* Command execution succeeded. */
  140. MLXSW_CMD_STATUS_OK = 0x00,
  141. /* Internal error (e.g. bus error) occurred while processing command. */
  142. MLXSW_CMD_STATUS_INTERNAL_ERR = 0x01,
  143. /* Operation/command not supported or opcode modifier not supported. */
  144. MLXSW_CMD_STATUS_BAD_OP = 0x02,
  145. /* Parameter not supported, parameter out of range. */
  146. MLXSW_CMD_STATUS_BAD_PARAM = 0x03,
  147. /* System was not enabled or bad system state. */
  148. MLXSW_CMD_STATUS_BAD_SYS_STATE = 0x04,
  149. /* Attempt to access reserved or unallocated resource, or resource in
  150. * inappropriate ownership.
  151. */
  152. MLXSW_CMD_STATUS_BAD_RESOURCE = 0x05,
  153. /* Requested resource is currently executing a command. */
  154. MLXSW_CMD_STATUS_RESOURCE_BUSY = 0x06,
  155. /* Required capability exceeds device limits. */
  156. MLXSW_CMD_STATUS_EXCEED_LIM = 0x08,
  157. /* Resource is not in the appropriate state or ownership. */
  158. MLXSW_CMD_STATUS_BAD_RES_STATE = 0x09,
  159. /* Index out of range (might be beyond table size or attempt to
  160. * access a reserved resource).
  161. */
  162. MLXSW_CMD_STATUS_BAD_INDEX = 0x0A,
  163. /* NVMEM checksum/CRC failed. */
  164. MLXSW_CMD_STATUS_BAD_NVMEM = 0x0B,
  165. /* Bad management packet (silently discarded). */
  166. MLXSW_CMD_STATUS_BAD_PKT = 0x30,
  167. };
  168. static inline const char *mlxsw_cmd_status_str(u8 status)
  169. {
  170. switch (status) {
  171. case MLXSW_CMD_STATUS_OK:
  172. return "OK";
  173. case MLXSW_CMD_STATUS_INTERNAL_ERR:
  174. return "INTERNAL_ERR";
  175. case MLXSW_CMD_STATUS_BAD_OP:
  176. return "BAD_OP";
  177. case MLXSW_CMD_STATUS_BAD_PARAM:
  178. return "BAD_PARAM";
  179. case MLXSW_CMD_STATUS_BAD_SYS_STATE:
  180. return "BAD_SYS_STATE";
  181. case MLXSW_CMD_STATUS_BAD_RESOURCE:
  182. return "BAD_RESOURCE";
  183. case MLXSW_CMD_STATUS_RESOURCE_BUSY:
  184. return "RESOURCE_BUSY";
  185. case MLXSW_CMD_STATUS_EXCEED_LIM:
  186. return "EXCEED_LIM";
  187. case MLXSW_CMD_STATUS_BAD_RES_STATE:
  188. return "BAD_RES_STATE";
  189. case MLXSW_CMD_STATUS_BAD_INDEX:
  190. return "BAD_INDEX";
  191. case MLXSW_CMD_STATUS_BAD_NVMEM:
  192. return "BAD_NVMEM";
  193. case MLXSW_CMD_STATUS_BAD_PKT:
  194. return "BAD_PKT";
  195. default:
  196. return "*UNKNOWN*";
  197. }
  198. }
  199. /* QUERY_FW - Query Firmware
  200. * -------------------------
  201. * OpMod == 0, INMmod == 0
  202. * -----------------------
  203. * The QUERY_FW command retrieves information related to firmware, command
  204. * interface version and the amount of resources that should be allocated to
  205. * the firmware.
  206. */
  207. static inline int mlxsw_cmd_query_fw(struct mlxsw_core *mlxsw_core,
  208. char *out_mbox)
  209. {
  210. return mlxsw_cmd_exec_out(mlxsw_core, MLXSW_CMD_OPCODE_QUERY_FW,
  211. 0, 0, false, out_mbox, MLXSW_CMD_MBOX_SIZE);
  212. }
  213. /* cmd_mbox_query_fw_fw_pages
  214. * Amount of physical memory to be allocatedfor firmware usage in 4KB pages.
  215. */
  216. MLXSW_ITEM32(cmd_mbox, query_fw, fw_pages, 0x00, 16, 16);
  217. /* cmd_mbox_query_fw_fw_rev_major
  218. * Firmware Revision - Major
  219. */
  220. MLXSW_ITEM32(cmd_mbox, query_fw, fw_rev_major, 0x00, 0, 16);
  221. /* cmd_mbox_query_fw_fw_rev_subminor
  222. * Firmware Sub-minor version (Patch level)
  223. */
  224. MLXSW_ITEM32(cmd_mbox, query_fw, fw_rev_subminor, 0x04, 16, 16);
  225. /* cmd_mbox_query_fw_fw_rev_minor
  226. * Firmware Revision - Minor
  227. */
  228. MLXSW_ITEM32(cmd_mbox, query_fw, fw_rev_minor, 0x04, 0, 16);
  229. /* cmd_mbox_query_fw_core_clk
  230. * Internal Clock Frequency (in MHz)
  231. */
  232. MLXSW_ITEM32(cmd_mbox, query_fw, core_clk, 0x08, 16, 16);
  233. /* cmd_mbox_query_fw_cmd_interface_rev
  234. * Command Interface Interpreter Revision ID. This number is bumped up
  235. * every time a non-backward-compatible change is done for the command
  236. * interface. The current cmd_interface_rev is 1.
  237. */
  238. MLXSW_ITEM32(cmd_mbox, query_fw, cmd_interface_rev, 0x08, 0, 16);
  239. /* cmd_mbox_query_fw_dt
  240. * If set, Debug Trace is supported
  241. */
  242. MLXSW_ITEM32(cmd_mbox, query_fw, dt, 0x0C, 31, 1);
  243. /* cmd_mbox_query_fw_api_version
  244. * Indicates the version of the API, to enable software querying
  245. * for compatibility. The current api_version is 1.
  246. */
  247. MLXSW_ITEM32(cmd_mbox, query_fw, api_version, 0x0C, 0, 16);
  248. /* cmd_mbox_query_fw_fw_hour
  249. * Firmware timestamp - hour
  250. */
  251. MLXSW_ITEM32(cmd_mbox, query_fw, fw_hour, 0x10, 24, 8);
  252. /* cmd_mbox_query_fw_fw_minutes
  253. * Firmware timestamp - minutes
  254. */
  255. MLXSW_ITEM32(cmd_mbox, query_fw, fw_minutes, 0x10, 16, 8);
  256. /* cmd_mbox_query_fw_fw_seconds
  257. * Firmware timestamp - seconds
  258. */
  259. MLXSW_ITEM32(cmd_mbox, query_fw, fw_seconds, 0x10, 8, 8);
  260. /* cmd_mbox_query_fw_fw_year
  261. * Firmware timestamp - year
  262. */
  263. MLXSW_ITEM32(cmd_mbox, query_fw, fw_year, 0x14, 16, 16);
  264. /* cmd_mbox_query_fw_fw_month
  265. * Firmware timestamp - month
  266. */
  267. MLXSW_ITEM32(cmd_mbox, query_fw, fw_month, 0x14, 8, 8);
  268. /* cmd_mbox_query_fw_fw_day
  269. * Firmware timestamp - day
  270. */
  271. MLXSW_ITEM32(cmd_mbox, query_fw, fw_day, 0x14, 0, 8);
  272. /* cmd_mbox_query_fw_clr_int_base_offset
  273. * Clear Interrupt register's offset from clr_int_bar register
  274. * in PCI address space.
  275. */
  276. MLXSW_ITEM64(cmd_mbox, query_fw, clr_int_base_offset, 0x20, 0, 64);
  277. /* cmd_mbox_query_fw_clr_int_bar
  278. * PCI base address register (BAR) where clr_int register is located.
  279. * 00 - BAR 0-1 (64 bit BAR)
  280. */
  281. MLXSW_ITEM32(cmd_mbox, query_fw, clr_int_bar, 0x28, 30, 2);
  282. /* cmd_mbox_query_fw_error_buf_offset
  283. * Read Only buffer for internal error reports of offset
  284. * from error_buf_bar register in PCI address space).
  285. */
  286. MLXSW_ITEM64(cmd_mbox, query_fw, error_buf_offset, 0x30, 0, 64);
  287. /* cmd_mbox_query_fw_error_buf_size
  288. * Internal error buffer size in DWORDs
  289. */
  290. MLXSW_ITEM32(cmd_mbox, query_fw, error_buf_size, 0x38, 0, 32);
  291. /* cmd_mbox_query_fw_error_int_bar
  292. * PCI base address register (BAR) where error buffer
  293. * register is located.
  294. * 00 - BAR 0-1 (64 bit BAR)
  295. */
  296. MLXSW_ITEM32(cmd_mbox, query_fw, error_int_bar, 0x3C, 30, 2);
  297. /* cmd_mbox_query_fw_doorbell_page_offset
  298. * Offset of the doorbell page
  299. */
  300. MLXSW_ITEM64(cmd_mbox, query_fw, doorbell_page_offset, 0x40, 0, 64);
  301. /* cmd_mbox_query_fw_doorbell_page_bar
  302. * PCI base address register (BAR) of the doorbell page
  303. * 00 - BAR 0-1 (64 bit BAR)
  304. */
  305. MLXSW_ITEM32(cmd_mbox, query_fw, doorbell_page_bar, 0x48, 30, 2);
  306. /* QUERY_BOARDINFO - Query Board Information
  307. * -----------------------------------------
  308. * OpMod == 0 (N/A), INMmod == 0 (N/A)
  309. * -----------------------------------
  310. * The QUERY_BOARDINFO command retrieves adapter specific parameters.
  311. */
  312. static inline int mlxsw_cmd_boardinfo(struct mlxsw_core *mlxsw_core,
  313. char *out_mbox)
  314. {
  315. return mlxsw_cmd_exec_out(mlxsw_core, MLXSW_CMD_OPCODE_QUERY_BOARDINFO,
  316. 0, 0, false, out_mbox, MLXSW_CMD_MBOX_SIZE);
  317. }
  318. /* cmd_mbox_boardinfo_intapin
  319. * When PCIe interrupt messages are being used, this value is used for clearing
  320. * an interrupt. When using MSI-X, this register is not used.
  321. */
  322. MLXSW_ITEM32(cmd_mbox, boardinfo, intapin, 0x10, 24, 8);
  323. /* cmd_mbox_boardinfo_vsd_vendor_id
  324. * PCISIG Vendor ID (www.pcisig.com/membership/vid_search) of the vendor
  325. * specifying/formatting the VSD. The vsd_vendor_id identifies the management
  326. * domain of the VSD/PSID data. Different vendors may choose different VSD/PSID
  327. * format and encoding as long as they use their assigned vsd_vendor_id.
  328. */
  329. MLXSW_ITEM32(cmd_mbox, boardinfo, vsd_vendor_id, 0x1C, 0, 16);
  330. /* cmd_mbox_boardinfo_vsd
  331. * Vendor Specific Data. The VSD string that is burnt to the Flash
  332. * with the firmware.
  333. */
  334. #define MLXSW_CMD_BOARDINFO_VSD_LEN 208
  335. MLXSW_ITEM_BUF(cmd_mbox, boardinfo, vsd, 0x20, MLXSW_CMD_BOARDINFO_VSD_LEN);
  336. /* cmd_mbox_boardinfo_psid
  337. * The PSID field is a 16-ascii (byte) character string which acts as
  338. * the board ID. The PSID format is used in conjunction with
  339. * Mellanox vsd_vendor_id (15B3h).
  340. */
  341. #define MLXSW_CMD_BOARDINFO_PSID_LEN 16
  342. MLXSW_ITEM_BUF(cmd_mbox, boardinfo, psid, 0xF0, MLXSW_CMD_BOARDINFO_PSID_LEN);
  343. /* QUERY_AQ_CAP - Query Asynchronous Queues Capabilities
  344. * -----------------------------------------------------
  345. * OpMod == 0 (N/A), INMmod == 0 (N/A)
  346. * -----------------------------------
  347. * The QUERY_AQ_CAP command returns the device asynchronous queues
  348. * capabilities supported.
  349. */
  350. static inline int mlxsw_cmd_query_aq_cap(struct mlxsw_core *mlxsw_core,
  351. char *out_mbox)
  352. {
  353. return mlxsw_cmd_exec_out(mlxsw_core, MLXSW_CMD_OPCODE_QUERY_AQ_CAP,
  354. 0, 0, false, out_mbox, MLXSW_CMD_MBOX_SIZE);
  355. }
  356. /* cmd_mbox_query_aq_cap_log_max_sdq_sz
  357. * Log (base 2) of max WQEs allowed on SDQ.
  358. */
  359. MLXSW_ITEM32(cmd_mbox, query_aq_cap, log_max_sdq_sz, 0x00, 24, 8);
  360. /* cmd_mbox_query_aq_cap_max_num_sdqs
  361. * Maximum number of SDQs.
  362. */
  363. MLXSW_ITEM32(cmd_mbox, query_aq_cap, max_num_sdqs, 0x00, 0, 8);
  364. /* cmd_mbox_query_aq_cap_log_max_rdq_sz
  365. * Log (base 2) of max WQEs allowed on RDQ.
  366. */
  367. MLXSW_ITEM32(cmd_mbox, query_aq_cap, log_max_rdq_sz, 0x04, 24, 8);
  368. /* cmd_mbox_query_aq_cap_max_num_rdqs
  369. * Maximum number of RDQs.
  370. */
  371. MLXSW_ITEM32(cmd_mbox, query_aq_cap, max_num_rdqs, 0x04, 0, 8);
  372. /* cmd_mbox_query_aq_cap_log_max_cq_sz
  373. * Log (base 2) of max CQEs allowed on CQ.
  374. */
  375. MLXSW_ITEM32(cmd_mbox, query_aq_cap, log_max_cq_sz, 0x08, 24, 8);
  376. /* cmd_mbox_query_aq_cap_max_num_cqs
  377. * Maximum number of CQs.
  378. */
  379. MLXSW_ITEM32(cmd_mbox, query_aq_cap, max_num_cqs, 0x08, 0, 8);
  380. /* cmd_mbox_query_aq_cap_log_max_eq_sz
  381. * Log (base 2) of max EQEs allowed on EQ.
  382. */
  383. MLXSW_ITEM32(cmd_mbox, query_aq_cap, log_max_eq_sz, 0x0C, 24, 8);
  384. /* cmd_mbox_query_aq_cap_max_num_eqs
  385. * Maximum number of EQs.
  386. */
  387. MLXSW_ITEM32(cmd_mbox, query_aq_cap, max_num_eqs, 0x0C, 0, 8);
  388. /* cmd_mbox_query_aq_cap_max_sg_sq
  389. * The maximum S/G list elements in an DSQ. DSQ must not contain
  390. * more S/G entries than indicated here.
  391. */
  392. MLXSW_ITEM32(cmd_mbox, query_aq_cap, max_sg_sq, 0x10, 8, 8);
  393. /* cmd_mbox_query_aq_cap_
  394. * The maximum S/G list elements in an DRQ. DRQ must not contain
  395. * more S/G entries than indicated here.
  396. */
  397. MLXSW_ITEM32(cmd_mbox, query_aq_cap, max_sg_rq, 0x10, 0, 8);
  398. /* MAP_FA - Map Firmware Area
  399. * --------------------------
  400. * OpMod == 0 (N/A), INMmod == Number of VPM entries
  401. * -------------------------------------------------
  402. * The MAP_FA command passes physical pages to the switch. These pages
  403. * are used to store the device firmware. MAP_FA can be executed multiple
  404. * times until all the firmware area is mapped (the size that should be
  405. * mapped is retrieved through the QUERY_FW command). All required pages
  406. * must be mapped to finish the initialization phase. Physical memory
  407. * passed in this command must be pinned.
  408. */
  409. #define MLXSW_CMD_MAP_FA_VPM_ENTRIES_MAX 32
  410. static inline int mlxsw_cmd_map_fa(struct mlxsw_core *mlxsw_core,
  411. char *in_mbox, u32 vpm_entries_count)
  412. {
  413. return mlxsw_cmd_exec_in(mlxsw_core, MLXSW_CMD_OPCODE_MAP_FA,
  414. 0, vpm_entries_count,
  415. in_mbox, MLXSW_CMD_MBOX_SIZE);
  416. }
  417. /* cmd_mbox_map_fa_pa
  418. * Physical Address.
  419. */
  420. MLXSW_ITEM64_INDEXED(cmd_mbox, map_fa, pa, 0x00, 12, 52, 0x08, 0x00, true);
  421. /* cmd_mbox_map_fa_log2size
  422. * Log (base 2) of the size in 4KB pages of the physical and contiguous memory
  423. * that starts at PA_L/H.
  424. */
  425. MLXSW_ITEM32_INDEXED(cmd_mbox, map_fa, log2size, 0x00, 0, 5, 0x08, 0x04, false);
  426. /* UNMAP_FA - Unmap Firmware Area
  427. * ------------------------------
  428. * OpMod == 0 (N/A), INMmod == 0 (N/A)
  429. * -----------------------------------
  430. * The UNMAP_FA command unload the firmware and unmaps all the
  431. * firmware area. After this command is completed the device will not access
  432. * the pages that were mapped to the firmware area. After executing UNMAP_FA
  433. * command, software reset must be done prior to execution of MAP_FW command.
  434. */
  435. static inline int mlxsw_cmd_unmap_fa(struct mlxsw_core *mlxsw_core)
  436. {
  437. return mlxsw_cmd_exec_none(mlxsw_core, MLXSW_CMD_OPCODE_UNMAP_FA, 0, 0);
  438. }
  439. /* CONFIG_PROFILE (Set) - Configure Switch Profile
  440. * ------------------------------
  441. * OpMod == 1 (Set), INMmod == 0 (N/A)
  442. * -----------------------------------
  443. * The CONFIG_PROFILE command sets the switch profile. The command can be
  444. * executed on the device only once at startup in order to allocate and
  445. * configure all switch resources and prepare it for operational mode.
  446. * It is not possible to change the device profile after the chip is
  447. * in operational mode.
  448. * Failure of the CONFIG_PROFILE command leaves the hardware in an indeterminate
  449. * state therefore it is required to perform software reset to the device
  450. * following an unsuccessful completion of the command. It is required
  451. * to perform software reset to the device to change an existing profile.
  452. */
  453. static inline int mlxsw_cmd_config_profile_set(struct mlxsw_core *mlxsw_core,
  454. char *in_mbox)
  455. {
  456. return mlxsw_cmd_exec_in(mlxsw_core, MLXSW_CMD_OPCODE_CONFIG_PROFILE,
  457. 1, 0, in_mbox, MLXSW_CMD_MBOX_SIZE);
  458. }
  459. /* cmd_mbox_config_profile_set_max_vepa_channels
  460. * Capability bit. Setting a bit to 1 configures the profile
  461. * according to the mailbox contents.
  462. */
  463. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_vepa_channels, 0x0C, 0, 1);
  464. /* cmd_mbox_config_profile_set_max_lag
  465. * Capability bit. Setting a bit to 1 configures the profile
  466. * according to the mailbox contents.
  467. */
  468. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_lag, 0x0C, 1, 1);
  469. /* cmd_mbox_config_profile_set_max_port_per_lag
  470. * Capability bit. Setting a bit to 1 configures the profile
  471. * according to the mailbox contents.
  472. */
  473. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_port_per_lag, 0x0C, 2, 1);
  474. /* cmd_mbox_config_profile_set_max_mid
  475. * Capability bit. Setting a bit to 1 configures the profile
  476. * according to the mailbox contents.
  477. */
  478. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_mid, 0x0C, 3, 1);
  479. /* cmd_mbox_config_profile_set_max_pgt
  480. * Capability bit. Setting a bit to 1 configures the profile
  481. * according to the mailbox contents.
  482. */
  483. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_pgt, 0x0C, 4, 1);
  484. /* cmd_mbox_config_profile_set_max_system_port
  485. * Capability bit. Setting a bit to 1 configures the profile
  486. * according to the mailbox contents.
  487. */
  488. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_system_port, 0x0C, 5, 1);
  489. /* cmd_mbox_config_profile_set_max_vlan_groups
  490. * Capability bit. Setting a bit to 1 configures the profile
  491. * according to the mailbox contents.
  492. */
  493. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_vlan_groups, 0x0C, 6, 1);
  494. /* cmd_mbox_config_profile_set_max_regions
  495. * Capability bit. Setting a bit to 1 configures the profile
  496. * according to the mailbox contents.
  497. */
  498. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_regions, 0x0C, 7, 1);
  499. /* cmd_mbox_config_profile_set_flood_mode
  500. * Capability bit. Setting a bit to 1 configures the profile
  501. * according to the mailbox contents.
  502. */
  503. MLXSW_ITEM32(cmd_mbox, config_profile, set_flood_mode, 0x0C, 8, 1);
  504. /* cmd_mbox_config_profile_set_max_flood_tables
  505. * Capability bit. Setting a bit to 1 configures the profile
  506. * according to the mailbox contents.
  507. */
  508. MLXSW_ITEM32(cmd_mbox, config_profile, set_flood_tables, 0x0C, 9, 1);
  509. /* cmd_mbox_config_profile_set_max_ib_mc
  510. * Capability bit. Setting a bit to 1 configures the profile
  511. * according to the mailbox contents.
  512. */
  513. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_ib_mc, 0x0C, 12, 1);
  514. /* cmd_mbox_config_profile_set_max_pkey
  515. * Capability bit. Setting a bit to 1 configures the profile
  516. * according to the mailbox contents.
  517. */
  518. MLXSW_ITEM32(cmd_mbox, config_profile, set_max_pkey, 0x0C, 13, 1);
  519. /* cmd_mbox_config_profile_set_adaptive_routing_group_cap
  520. * Capability bit. Setting a bit to 1 configures the profile
  521. * according to the mailbox contents.
  522. */
  523. MLXSW_ITEM32(cmd_mbox, config_profile,
  524. set_adaptive_routing_group_cap, 0x0C, 14, 1);
  525. /* cmd_mbox_config_profile_set_ar_sec
  526. * Capability bit. Setting a bit to 1 configures the profile
  527. * according to the mailbox contents.
  528. */
  529. MLXSW_ITEM32(cmd_mbox, config_profile, set_ar_sec, 0x0C, 15, 1);
  530. /* cmd_mbox_config_profile_max_vepa_channels
  531. * Maximum number of VEPA channels per port (0 through 16)
  532. * 0 - multi-channel VEPA is disabled
  533. */
  534. MLXSW_ITEM32(cmd_mbox, config_profile, max_vepa_channels, 0x10, 0, 8);
  535. /* cmd_mbox_config_profile_max_lag
  536. * Maximum number of LAG IDs requested.
  537. */
  538. MLXSW_ITEM32(cmd_mbox, config_profile, max_lag, 0x14, 0, 16);
  539. /* cmd_mbox_config_profile_max_port_per_lag
  540. * Maximum number of ports per LAG requested.
  541. */
  542. MLXSW_ITEM32(cmd_mbox, config_profile, max_port_per_lag, 0x18, 0, 16);
  543. /* cmd_mbox_config_profile_max_mid
  544. * Maximum Multicast IDs.
  545. * Multicast IDs are allocated from 0 to max_mid-1
  546. */
  547. MLXSW_ITEM32(cmd_mbox, config_profile, max_mid, 0x1C, 0, 16);
  548. /* cmd_mbox_config_profile_max_pgt
  549. * Maximum records in the Port Group Table per Switch Partition.
  550. * Port Group Table indexes are from 0 to max_pgt-1
  551. */
  552. MLXSW_ITEM32(cmd_mbox, config_profile, max_pgt, 0x20, 0, 16);
  553. /* cmd_mbox_config_profile_max_system_port
  554. * The maximum number of system ports that can be allocated.
  555. */
  556. MLXSW_ITEM32(cmd_mbox, config_profile, max_system_port, 0x24, 0, 16);
  557. /* cmd_mbox_config_profile_max_vlan_groups
  558. * Maximum number VLAN Groups for VLAN binding.
  559. */
  560. MLXSW_ITEM32(cmd_mbox, config_profile, max_vlan_groups, 0x28, 0, 12);
  561. /* cmd_mbox_config_profile_max_regions
  562. * Maximum number of TCAM Regions.
  563. */
  564. MLXSW_ITEM32(cmd_mbox, config_profile, max_regions, 0x2C, 0, 16);
  565. /* cmd_mbox_config_profile_max_flood_tables
  566. * Maximum number of single-entry flooding tables. Different flooding tables
  567. * can be associated with different packet types.
  568. */
  569. MLXSW_ITEM32(cmd_mbox, config_profile, max_flood_tables, 0x30, 16, 4);
  570. /* cmd_mbox_config_profile_max_vid_flood_tables
  571. * Maximum number of per-vid flooding tables. Flooding tables are associated
  572. * to the different packet types for the different switch partitions.
  573. * Table size is 4K entries covering all VID space.
  574. */
  575. MLXSW_ITEM32(cmd_mbox, config_profile, max_vid_flood_tables, 0x30, 8, 4);
  576. /* cmd_mbox_config_profile_flood_mode
  577. * Flooding mode to use.
  578. * 0-2 - Backward compatible modes for SwitchX devices.
  579. * 3 - Mixed mode, where:
  580. * max_flood_tables indicates the number of single-entry tables.
  581. * max_vid_flood_tables indicates the number of per-VID tables.
  582. * max_fid_offset_flood_tables indicates the number of FID-offset tables.
  583. * max_fid_flood_tables indicates the number of per-FID tables.
  584. */
  585. MLXSW_ITEM32(cmd_mbox, config_profile, flood_mode, 0x30, 0, 2);
  586. /* cmd_mbox_config_profile_max_fid_offset_flood_tables
  587. * Maximum number of FID-offset flooding tables.
  588. */
  589. MLXSW_ITEM32(cmd_mbox, config_profile,
  590. max_fid_offset_flood_tables, 0x34, 24, 4);
  591. /* cmd_mbox_config_profile_fid_offset_flood_table_size
  592. * The size (number of entries) of each FID-offset flood table.
  593. */
  594. MLXSW_ITEM32(cmd_mbox, config_profile,
  595. fid_offset_flood_table_size, 0x34, 0, 16);
  596. /* cmd_mbox_config_profile_max_fid_flood_tables
  597. * Maximum number of per-FID flooding tables.
  598. *
  599. * Note: This flooding tables cover special FIDs only (vFIDs), starting at
  600. * FID value 4K and higher.
  601. */
  602. MLXSW_ITEM32(cmd_mbox, config_profile, max_fid_flood_tables, 0x38, 24, 4);
  603. /* cmd_mbox_config_profile_fid_flood_table_size
  604. * The size (number of entries) of each per-FID table.
  605. */
  606. MLXSW_ITEM32(cmd_mbox, config_profile, fid_flood_table_size, 0x38, 0, 16);
  607. /* cmd_mbox_config_profile_max_ib_mc
  608. * Maximum number of multicast FDB records for InfiniBand
  609. * FDB (in 512 chunks) per InfiniBand switch partition.
  610. */
  611. MLXSW_ITEM32(cmd_mbox, config_profile, max_ib_mc, 0x40, 0, 15);
  612. /* cmd_mbox_config_profile_max_pkey
  613. * Maximum per port PKEY table size (for PKEY enforcement)
  614. */
  615. MLXSW_ITEM32(cmd_mbox, config_profile, max_pkey, 0x44, 0, 15);
  616. /* cmd_mbox_config_profile_ar_sec
  617. * Primary/secondary capability
  618. * Describes the number of adaptive routing sub-groups
  619. * 0 - disable primary/secondary (single group)
  620. * 1 - enable primary/secondary (2 sub-groups)
  621. * 2 - 3 sub-groups: Not supported in SwitchX, SwitchX-2
  622. * 3 - 4 sub-groups: Not supported in SwitchX, SwitchX-2
  623. */
  624. MLXSW_ITEM32(cmd_mbox, config_profile, ar_sec, 0x4C, 24, 2);
  625. /* cmd_mbox_config_profile_adaptive_routing_group_cap
  626. * Adaptive Routing Group Capability. Indicates the number of AR groups
  627. * supported. Note that when Primary/secondary is enabled, each
  628. * primary/secondary couple consumes 2 adaptive routing entries.
  629. */
  630. MLXSW_ITEM32(cmd_mbox, config_profile, adaptive_routing_group_cap, 0x4C, 0, 16);
  631. /* cmd_mbox_config_profile_arn
  632. * Adaptive Routing Notification Enable
  633. * Not supported in SwitchX, SwitchX-2
  634. */
  635. MLXSW_ITEM32(cmd_mbox, config_profile, arn, 0x50, 31, 1);
  636. /* cmd_mbox_config_profile_swid_config_mask
  637. * Modify Switch Partition Configuration mask. When set, the configu-
  638. * ration value for the Switch Partition are taken from the mailbox.
  639. * When clear, the current configuration values are used.
  640. * Bit 0 - set type
  641. * Bit 1 - properties
  642. * Other - reserved
  643. */
  644. MLXSW_ITEM32_INDEXED(cmd_mbox, config_profile, swid_config_mask,
  645. 0x60, 24, 8, 0x08, 0x00, false);
  646. /* cmd_mbox_config_profile_swid_config_type
  647. * Switch Partition type.
  648. * 0000 - disabled (Switch Partition does not exist)
  649. * 0001 - InfiniBand
  650. * 0010 - Ethernet
  651. * 1000 - router port (SwitchX-2 only)
  652. * Other - reserved
  653. */
  654. MLXSW_ITEM32_INDEXED(cmd_mbox, config_profile, swid_config_type,
  655. 0x60, 20, 4, 0x08, 0x00, false);
  656. /* cmd_mbox_config_profile_swid_config_properties
  657. * Switch Partition properties.
  658. */
  659. MLXSW_ITEM32_INDEXED(cmd_mbox, config_profile, swid_config_properties,
  660. 0x60, 0, 8, 0x08, 0x00, false);
  661. /* ACCESS_REG - Access EMAD Supported Register
  662. * ----------------------------------
  663. * OpMod == 0 (N/A), INMmod == 0 (N/A)
  664. * -------------------------------------
  665. * The ACCESS_REG command supports accessing device registers. This access
  666. * is mainly used for bootstrapping.
  667. */
  668. static inline int mlxsw_cmd_access_reg(struct mlxsw_core *mlxsw_core,
  669. char *in_mbox, char *out_mbox)
  670. {
  671. return mlxsw_cmd_exec(mlxsw_core, MLXSW_CMD_OPCODE_ACCESS_REG,
  672. 0, 0, false, in_mbox, MLXSW_CMD_MBOX_SIZE,
  673. out_mbox, MLXSW_CMD_MBOX_SIZE);
  674. }
  675. /* SW2HW_DQ - Software to Hardware DQ
  676. * ----------------------------------
  677. * OpMod == 0 (send DQ) / OpMod == 1 (receive DQ)
  678. * INMmod == DQ number
  679. * ----------------------------------------------
  680. * The SW2HW_DQ command transitions a descriptor queue from software to
  681. * hardware ownership. The command enables posting WQEs and ringing DoorBells
  682. * on the descriptor queue.
  683. */
  684. static inline int __mlxsw_cmd_sw2hw_dq(struct mlxsw_core *mlxsw_core,
  685. char *in_mbox, u32 dq_number,
  686. u8 opcode_mod)
  687. {
  688. return mlxsw_cmd_exec_in(mlxsw_core, MLXSW_CMD_OPCODE_SW2HW_DQ,
  689. opcode_mod, dq_number,
  690. in_mbox, MLXSW_CMD_MBOX_SIZE);
  691. }
  692. enum {
  693. MLXSW_CMD_OPCODE_MOD_SDQ = 0,
  694. MLXSW_CMD_OPCODE_MOD_RDQ = 1,
  695. };
  696. static inline int mlxsw_cmd_sw2hw_sdq(struct mlxsw_core *mlxsw_core,
  697. char *in_mbox, u32 dq_number)
  698. {
  699. return __mlxsw_cmd_sw2hw_dq(mlxsw_core, in_mbox, dq_number,
  700. MLXSW_CMD_OPCODE_MOD_SDQ);
  701. }
  702. static inline int mlxsw_cmd_sw2hw_rdq(struct mlxsw_core *mlxsw_core,
  703. char *in_mbox, u32 dq_number)
  704. {
  705. return __mlxsw_cmd_sw2hw_dq(mlxsw_core, in_mbox, dq_number,
  706. MLXSW_CMD_OPCODE_MOD_RDQ);
  707. }
  708. /* cmd_mbox_sw2hw_dq_cq
  709. * Number of the CQ that this Descriptor Queue reports completions to.
  710. */
  711. MLXSW_ITEM32(cmd_mbox, sw2hw_dq, cq, 0x00, 24, 8);
  712. /* cmd_mbox_sw2hw_dq_sdq_tclass
  713. * SDQ: CPU Egress TClass
  714. * RDQ: Reserved
  715. */
  716. MLXSW_ITEM32(cmd_mbox, sw2hw_dq, sdq_tclass, 0x00, 16, 6);
  717. /* cmd_mbox_sw2hw_dq_log2_dq_sz
  718. * Log (base 2) of the Descriptor Queue size in 4KB pages.
  719. */
  720. MLXSW_ITEM32(cmd_mbox, sw2hw_dq, log2_dq_sz, 0x00, 0, 6);
  721. /* cmd_mbox_sw2hw_dq_pa
  722. * Physical Address.
  723. */
  724. MLXSW_ITEM64_INDEXED(cmd_mbox, sw2hw_dq, pa, 0x10, 12, 52, 0x08, 0x00, true);
  725. /* HW2SW_DQ - Hardware to Software DQ
  726. * ----------------------------------
  727. * OpMod == 0 (send DQ) / OpMod == 1 (receive DQ)
  728. * INMmod == DQ number
  729. * ----------------------------------------------
  730. * The HW2SW_DQ command transitions a descriptor queue from hardware to
  731. * software ownership. Incoming packets on the DQ are silently discarded,
  732. * SW should not post descriptors on nonoperational DQs.
  733. */
  734. static inline int __mlxsw_cmd_hw2sw_dq(struct mlxsw_core *mlxsw_core,
  735. u32 dq_number, u8 opcode_mod)
  736. {
  737. return mlxsw_cmd_exec_none(mlxsw_core, MLXSW_CMD_OPCODE_HW2SW_DQ,
  738. opcode_mod, dq_number);
  739. }
  740. static inline int mlxsw_cmd_hw2sw_sdq(struct mlxsw_core *mlxsw_core,
  741. u32 dq_number)
  742. {
  743. return __mlxsw_cmd_hw2sw_dq(mlxsw_core, dq_number,
  744. MLXSW_CMD_OPCODE_MOD_SDQ);
  745. }
  746. static inline int mlxsw_cmd_hw2sw_rdq(struct mlxsw_core *mlxsw_core,
  747. u32 dq_number)
  748. {
  749. return __mlxsw_cmd_hw2sw_dq(mlxsw_core, dq_number,
  750. MLXSW_CMD_OPCODE_MOD_RDQ);
  751. }
  752. /* 2ERR_DQ - To Error DQ
  753. * ---------------------
  754. * OpMod == 0 (send DQ) / OpMod == 1 (receive DQ)
  755. * INMmod == DQ number
  756. * ----------------------------------------------
  757. * The 2ERR_DQ command transitions the DQ into the error state from the state
  758. * in which it has been. While the command is executed, some in-process
  759. * descriptors may complete. Once the DQ transitions into the error state,
  760. * if there are posted descriptors on the RDQ/SDQ, the hardware writes
  761. * a completion with error (flushed) for all descriptors posted in the RDQ/SDQ.
  762. * When the command is completed successfully, the DQ is already in
  763. * the error state.
  764. */
  765. static inline int __mlxsw_cmd_2err_dq(struct mlxsw_core *mlxsw_core,
  766. u32 dq_number, u8 opcode_mod)
  767. {
  768. return mlxsw_cmd_exec_none(mlxsw_core, MLXSW_CMD_OPCODE_2ERR_DQ,
  769. opcode_mod, dq_number);
  770. }
  771. static inline int mlxsw_cmd_2err_sdq(struct mlxsw_core *mlxsw_core,
  772. u32 dq_number)
  773. {
  774. return __mlxsw_cmd_2err_dq(mlxsw_core, dq_number,
  775. MLXSW_CMD_OPCODE_MOD_SDQ);
  776. }
  777. static inline int mlxsw_cmd_2err_rdq(struct mlxsw_core *mlxsw_core,
  778. u32 dq_number)
  779. {
  780. return __mlxsw_cmd_2err_dq(mlxsw_core, dq_number,
  781. MLXSW_CMD_OPCODE_MOD_RDQ);
  782. }
  783. /* QUERY_DQ - Query DQ
  784. * ---------------------
  785. * OpMod == 0 (send DQ) / OpMod == 1 (receive DQ)
  786. * INMmod == DQ number
  787. * ----------------------------------------------
  788. * The QUERY_DQ command retrieves a snapshot of DQ parameters from the hardware.
  789. *
  790. * Note: Output mailbox has the same format as SW2HW_DQ.
  791. */
  792. static inline int __mlxsw_cmd_query_dq(struct mlxsw_core *mlxsw_core,
  793. char *out_mbox, u32 dq_number,
  794. u8 opcode_mod)
  795. {
  796. return mlxsw_cmd_exec_out(mlxsw_core, MLXSW_CMD_OPCODE_2ERR_DQ,
  797. opcode_mod, dq_number, false,
  798. out_mbox, MLXSW_CMD_MBOX_SIZE);
  799. }
  800. static inline int mlxsw_cmd_query_sdq(struct mlxsw_core *mlxsw_core,
  801. char *out_mbox, u32 dq_number)
  802. {
  803. return __mlxsw_cmd_query_dq(mlxsw_core, out_mbox, dq_number,
  804. MLXSW_CMD_OPCODE_MOD_SDQ);
  805. }
  806. static inline int mlxsw_cmd_query_rdq(struct mlxsw_core *mlxsw_core,
  807. char *out_mbox, u32 dq_number)
  808. {
  809. return __mlxsw_cmd_query_dq(mlxsw_core, out_mbox, dq_number,
  810. MLXSW_CMD_OPCODE_MOD_RDQ);
  811. }
  812. /* SW2HW_CQ - Software to Hardware CQ
  813. * ----------------------------------
  814. * OpMod == 0 (N/A), INMmod == CQ number
  815. * -------------------------------------
  816. * The SW2HW_CQ command transfers ownership of a CQ context entry from software
  817. * to hardware. The command takes the CQ context entry from the input mailbox
  818. * and stores it in the CQC in the ownership of the hardware. The command fails
  819. * if the requested CQC entry is already in the ownership of the hardware.
  820. */
  821. static inline int mlxsw_cmd_sw2hw_cq(struct mlxsw_core *mlxsw_core,
  822. char *in_mbox, u32 cq_number)
  823. {
  824. return mlxsw_cmd_exec_in(mlxsw_core, MLXSW_CMD_OPCODE_SW2HW_CQ,
  825. 0, cq_number, in_mbox, MLXSW_CMD_MBOX_SIZE);
  826. }
  827. /* cmd_mbox_sw2hw_cq_cv
  828. * CQE Version.
  829. * 0 - CQE Version 0, 1 - CQE Version 1
  830. */
  831. MLXSW_ITEM32(cmd_mbox, sw2hw_cq, cv, 0x00, 28, 4);
  832. /* cmd_mbox_sw2hw_cq_c_eqn
  833. * Event Queue this CQ reports completion events to.
  834. */
  835. MLXSW_ITEM32(cmd_mbox, sw2hw_cq, c_eqn, 0x00, 24, 1);
  836. /* cmd_mbox_sw2hw_cq_oi
  837. * When set, overrun ignore is enabled. When set, updates of
  838. * CQ consumer counter (poll for completion) or Request completion
  839. * notifications (Arm CQ) DoorBells should not be rung on that CQ.
  840. */
  841. MLXSW_ITEM32(cmd_mbox, sw2hw_cq, oi, 0x00, 12, 1);
  842. /* cmd_mbox_sw2hw_cq_st
  843. * Event delivery state machine
  844. * 0x0 - FIRED
  845. * 0x1 - ARMED (Request for Notification)
  846. */
  847. MLXSW_ITEM32(cmd_mbox, sw2hw_cq, st, 0x00, 8, 1);
  848. /* cmd_mbox_sw2hw_cq_log_cq_size
  849. * Log (base 2) of the CQ size (in entries).
  850. */
  851. MLXSW_ITEM32(cmd_mbox, sw2hw_cq, log_cq_size, 0x00, 0, 4);
  852. /* cmd_mbox_sw2hw_cq_producer_counter
  853. * Producer Counter. The counter is incremented for each CQE that is
  854. * written by the HW to the CQ.
  855. * Maintained by HW (valid for the QUERY_CQ command only)
  856. */
  857. MLXSW_ITEM32(cmd_mbox, sw2hw_cq, producer_counter, 0x04, 0, 16);
  858. /* cmd_mbox_sw2hw_cq_pa
  859. * Physical Address.
  860. */
  861. MLXSW_ITEM64_INDEXED(cmd_mbox, sw2hw_cq, pa, 0x10, 11, 53, 0x08, 0x00, true);
  862. /* HW2SW_CQ - Hardware to Software CQ
  863. * ----------------------------------
  864. * OpMod == 0 (N/A), INMmod == CQ number
  865. * -------------------------------------
  866. * The HW2SW_CQ command transfers ownership of a CQ context entry from hardware
  867. * to software. The CQC entry is invalidated as a result of this command.
  868. */
  869. static inline int mlxsw_cmd_hw2sw_cq(struct mlxsw_core *mlxsw_core,
  870. u32 cq_number)
  871. {
  872. return mlxsw_cmd_exec_none(mlxsw_core, MLXSW_CMD_OPCODE_HW2SW_CQ,
  873. 0, cq_number);
  874. }
  875. /* QUERY_CQ - Query CQ
  876. * ----------------------------------
  877. * OpMod == 0 (N/A), INMmod == CQ number
  878. * -------------------------------------
  879. * The QUERY_CQ command retrieves a snapshot of the current CQ context entry.
  880. * The command stores the snapshot in the output mailbox in the software format.
  881. * Note that the CQ context state and values are not affected by the QUERY_CQ
  882. * command. The QUERY_CQ command is for debug purposes only.
  883. *
  884. * Note: Output mailbox has the same format as SW2HW_CQ.
  885. */
  886. static inline int mlxsw_cmd_query_cq(struct mlxsw_core *mlxsw_core,
  887. char *out_mbox, u32 cq_number)
  888. {
  889. return mlxsw_cmd_exec_out(mlxsw_core, MLXSW_CMD_OPCODE_QUERY_CQ,
  890. 0, cq_number, false,
  891. out_mbox, MLXSW_CMD_MBOX_SIZE);
  892. }
  893. /* SW2HW_EQ - Software to Hardware EQ
  894. * ----------------------------------
  895. * OpMod == 0 (N/A), INMmod == EQ number
  896. * -------------------------------------
  897. * The SW2HW_EQ command transfers ownership of an EQ context entry from software
  898. * to hardware. The command takes the EQ context entry from the input mailbox
  899. * and stores it in the EQC in the ownership of the hardware. The command fails
  900. * if the requested EQC entry is already in the ownership of the hardware.
  901. */
  902. static inline int mlxsw_cmd_sw2hw_eq(struct mlxsw_core *mlxsw_core,
  903. char *in_mbox, u32 eq_number)
  904. {
  905. return mlxsw_cmd_exec_in(mlxsw_core, MLXSW_CMD_OPCODE_SW2HW_EQ,
  906. 0, eq_number, in_mbox, MLXSW_CMD_MBOX_SIZE);
  907. }
  908. /* cmd_mbox_sw2hw_eq_int_msix
  909. * When set, MSI-X cycles will be generated by this EQ.
  910. * When cleared, an interrupt will be generated by this EQ.
  911. */
  912. MLXSW_ITEM32(cmd_mbox, sw2hw_eq, int_msix, 0x00, 24, 1);
  913. /* cmd_mbox_sw2hw_eq_int_oi
  914. * When set, overrun ignore is enabled.
  915. */
  916. MLXSW_ITEM32(cmd_mbox, sw2hw_eq, oi, 0x00, 12, 1);
  917. /* cmd_mbox_sw2hw_eq_int_st
  918. * Event delivery state machine
  919. * 0x0 - FIRED
  920. * 0x1 - ARMED (Request for Notification)
  921. * 0x11 - Always ARMED
  922. * other - reserved
  923. */
  924. MLXSW_ITEM32(cmd_mbox, sw2hw_eq, st, 0x00, 8, 2);
  925. /* cmd_mbox_sw2hw_eq_int_log_eq_size
  926. * Log (base 2) of the EQ size (in entries).
  927. */
  928. MLXSW_ITEM32(cmd_mbox, sw2hw_eq, log_eq_size, 0x00, 0, 4);
  929. /* cmd_mbox_sw2hw_eq_int_producer_counter
  930. * Producer Counter. The counter is incremented for each EQE that is written
  931. * by the HW to the EQ.
  932. * Maintained by HW (valid for the QUERY_EQ command only)
  933. */
  934. MLXSW_ITEM32(cmd_mbox, sw2hw_eq, producer_counter, 0x04, 0, 16);
  935. /* cmd_mbox_sw2hw_eq_int_pa
  936. * Physical Address.
  937. */
  938. MLXSW_ITEM64_INDEXED(cmd_mbox, sw2hw_eq, pa, 0x10, 11, 53, 0x08, 0x00, true);
  939. /* HW2SW_EQ - Hardware to Software EQ
  940. * ----------------------------------
  941. * OpMod == 0 (N/A), INMmod == EQ number
  942. * -------------------------------------
  943. */
  944. static inline int mlxsw_cmd_hw2sw_eq(struct mlxsw_core *mlxsw_core,
  945. u32 eq_number)
  946. {
  947. return mlxsw_cmd_exec_none(mlxsw_core, MLXSW_CMD_OPCODE_HW2SW_EQ,
  948. 0, eq_number);
  949. }
  950. /* QUERY_EQ - Query EQ
  951. * ----------------------------------
  952. * OpMod == 0 (N/A), INMmod == EQ number
  953. * -------------------------------------
  954. *
  955. * Note: Output mailbox has the same format as SW2HW_EQ.
  956. */
  957. static inline int mlxsw_cmd_query_eq(struct mlxsw_core *mlxsw_core,
  958. char *out_mbox, u32 eq_number)
  959. {
  960. return mlxsw_cmd_exec_out(mlxsw_core, MLXSW_CMD_OPCODE_QUERY_EQ,
  961. 0, eq_number, false,
  962. out_mbox, MLXSW_CMD_MBOX_SIZE);
  963. }
  964. #endif