ncsi-pkt.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*
  2. * Copyright Gavin Shan, IBM Corporation 2016.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #ifndef __NCSI_PKT_H__
  10. #define __NCSI_PKT_H__
  11. struct ncsi_pkt_hdr {
  12. unsigned char mc_id; /* Management controller ID */
  13. unsigned char revision; /* NCSI version - 0x01 */
  14. unsigned char reserved; /* Reserved */
  15. unsigned char id; /* Packet sequence number */
  16. unsigned char type; /* Packet type */
  17. unsigned char channel; /* Network controller ID */
  18. __be16 length; /* Payload length */
  19. __be32 reserved1[2]; /* Reserved */
  20. };
  21. struct ncsi_cmd_pkt_hdr {
  22. struct ncsi_pkt_hdr common; /* Common NCSI packet header */
  23. };
  24. struct ncsi_rsp_pkt_hdr {
  25. struct ncsi_pkt_hdr common; /* Common NCSI packet header */
  26. __be16 code; /* Response code */
  27. __be16 reason; /* Response reason */
  28. };
  29. struct ncsi_aen_pkt_hdr {
  30. struct ncsi_pkt_hdr common; /* Common NCSI packet header */
  31. unsigned char reserved2[3]; /* Reserved */
  32. unsigned char type; /* AEN packet type */
  33. };
  34. /* NCSI common command packet */
  35. struct ncsi_cmd_pkt {
  36. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  37. __be32 checksum; /* Checksum */
  38. unsigned char pad[26];
  39. };
  40. struct ncsi_rsp_pkt {
  41. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  42. __be32 checksum; /* Checksum */
  43. unsigned char pad[22];
  44. };
  45. /* Select Package */
  46. struct ncsi_cmd_sp_pkt {
  47. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  48. unsigned char reserved[3]; /* Reserved */
  49. unsigned char hw_arbitration; /* HW arbitration */
  50. __be32 checksum; /* Checksum */
  51. unsigned char pad[22];
  52. };
  53. /* Disable Channel */
  54. struct ncsi_cmd_dc_pkt {
  55. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  56. unsigned char reserved[3]; /* Reserved */
  57. unsigned char ald; /* Allow link down */
  58. __be32 checksum; /* Checksum */
  59. unsigned char pad[22];
  60. };
  61. /* Reset Channel */
  62. struct ncsi_cmd_rc_pkt {
  63. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  64. __be32 reserved; /* Reserved */
  65. __be32 checksum; /* Checksum */
  66. unsigned char pad[22];
  67. };
  68. /* AEN Enable */
  69. struct ncsi_cmd_ae_pkt {
  70. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  71. unsigned char reserved[3]; /* Reserved */
  72. unsigned char mc_id; /* MC ID */
  73. __be32 mode; /* AEN working mode */
  74. __be32 checksum; /* Checksum */
  75. unsigned char pad[18];
  76. };
  77. /* Set Link */
  78. struct ncsi_cmd_sl_pkt {
  79. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  80. __be32 mode; /* Link working mode */
  81. __be32 oem_mode; /* OEM link mode */
  82. __be32 checksum; /* Checksum */
  83. unsigned char pad[18];
  84. };
  85. /* Set VLAN Filter */
  86. struct ncsi_cmd_svf_pkt {
  87. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  88. __be16 reserved; /* Reserved */
  89. __be16 vlan; /* VLAN ID */
  90. __be16 reserved1; /* Reserved */
  91. unsigned char index; /* VLAN table index */
  92. unsigned char enable; /* Enable or disable */
  93. __be32 checksum; /* Checksum */
  94. unsigned char pad[14];
  95. };
  96. /* Enable VLAN */
  97. struct ncsi_cmd_ev_pkt {
  98. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  99. unsigned char reserved[3]; /* Reserved */
  100. unsigned char mode; /* VLAN filter mode */
  101. __be32 checksum; /* Checksum */
  102. unsigned char pad[22];
  103. };
  104. /* Set MAC Address */
  105. struct ncsi_cmd_sma_pkt {
  106. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  107. unsigned char mac[6]; /* MAC address */
  108. unsigned char index; /* MAC table index */
  109. unsigned char at_e; /* Addr type and operation */
  110. __be32 checksum; /* Checksum */
  111. unsigned char pad[18];
  112. };
  113. /* Enable Broadcast Filter */
  114. struct ncsi_cmd_ebf_pkt {
  115. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  116. __be32 mode; /* Filter mode */
  117. __be32 checksum; /* Checksum */
  118. unsigned char pad[22];
  119. };
  120. /* Enable Global Multicast Filter */
  121. struct ncsi_cmd_egmf_pkt {
  122. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  123. __be32 mode; /* Global MC mode */
  124. __be32 checksum; /* Checksum */
  125. unsigned char pad[22];
  126. };
  127. /* Set NCSI Flow Control */
  128. struct ncsi_cmd_snfc_pkt {
  129. struct ncsi_cmd_pkt_hdr cmd; /* Command header */
  130. unsigned char reserved[3]; /* Reserved */
  131. unsigned char mode; /* Flow control mode */
  132. __be32 checksum; /* Checksum */
  133. unsigned char pad[22];
  134. };
  135. /* Get Link Status */
  136. struct ncsi_rsp_gls_pkt {
  137. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  138. __be32 status; /* Link status */
  139. __be32 other; /* Other indications */
  140. __be32 oem_status; /* OEM link status */
  141. __be32 checksum;
  142. unsigned char pad[10];
  143. };
  144. /* Get Version ID */
  145. struct ncsi_rsp_gvi_pkt {
  146. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  147. __be32 ncsi_version; /* NCSI version */
  148. unsigned char reserved[3]; /* Reserved */
  149. unsigned char alpha2; /* NCSI version */
  150. unsigned char fw_name[12]; /* f/w name string */
  151. __be32 fw_version; /* f/w version */
  152. __be16 pci_ids[4]; /* PCI IDs */
  153. __be32 mf_id; /* Manufacture ID */
  154. __be32 checksum;
  155. };
  156. /* Get Capabilities */
  157. struct ncsi_rsp_gc_pkt {
  158. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  159. __be32 cap; /* Capabilities */
  160. __be32 bc_cap; /* Broadcast cap */
  161. __be32 mc_cap; /* Multicast cap */
  162. __be32 buf_cap; /* Buffering cap */
  163. __be32 aen_cap; /* AEN cap */
  164. unsigned char vlan_cnt; /* VLAN filter count */
  165. unsigned char mixed_cnt; /* Mix filter count */
  166. unsigned char mc_cnt; /* MC filter count */
  167. unsigned char uc_cnt; /* UC filter count */
  168. unsigned char reserved[2]; /* Reserved */
  169. unsigned char vlan_mode; /* VLAN mode */
  170. unsigned char channel_cnt; /* Channel count */
  171. __be32 checksum; /* Checksum */
  172. };
  173. /* Get Parameters */
  174. struct ncsi_rsp_gp_pkt {
  175. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  176. unsigned char mac_cnt; /* Number of MAC addr */
  177. unsigned char reserved[2]; /* Reserved */
  178. unsigned char mac_enable; /* MAC addr enable flags */
  179. unsigned char vlan_cnt; /* VLAN tag count */
  180. unsigned char reserved1; /* Reserved */
  181. __be16 vlan_enable; /* VLAN tag enable flags */
  182. __be32 link_mode; /* Link setting */
  183. __be32 bc_mode; /* BC filter mode */
  184. __be32 valid_modes; /* Valid mode parameters */
  185. unsigned char vlan_mode; /* VLAN mode */
  186. unsigned char fc_mode; /* Flow control mode */
  187. unsigned char reserved2[2]; /* Reserved */
  188. __be32 aen_mode; /* AEN mode */
  189. unsigned char mac[6]; /* Supported MAC addr */
  190. __be16 vlan; /* Supported VLAN tags */
  191. __be32 checksum; /* Checksum */
  192. };
  193. /* Get Controller Packet Statistics */
  194. struct ncsi_rsp_gcps_pkt {
  195. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  196. __be32 cnt_hi; /* Counter cleared */
  197. __be32 cnt_lo; /* Counter cleared */
  198. __be32 rx_bytes; /* Rx bytes */
  199. __be32 tx_bytes; /* Tx bytes */
  200. __be32 rx_uc_pkts; /* Rx UC packets */
  201. __be32 rx_mc_pkts; /* Rx MC packets */
  202. __be32 rx_bc_pkts; /* Rx BC packets */
  203. __be32 tx_uc_pkts; /* Tx UC packets */
  204. __be32 tx_mc_pkts; /* Tx MC packets */
  205. __be32 tx_bc_pkts; /* Tx BC packets */
  206. __be32 fcs_err; /* FCS errors */
  207. __be32 align_err; /* Alignment errors */
  208. __be32 false_carrier; /* False carrier detection */
  209. __be32 runt_pkts; /* Rx runt packets */
  210. __be32 jabber_pkts; /* Rx jabber packets */
  211. __be32 rx_pause_xon; /* Rx pause XON frames */
  212. __be32 rx_pause_xoff; /* Rx XOFF frames */
  213. __be32 tx_pause_xon; /* Tx XON frames */
  214. __be32 tx_pause_xoff; /* Tx XOFF frames */
  215. __be32 tx_s_collision; /* Single collision frames */
  216. __be32 tx_m_collision; /* Multiple collision frames */
  217. __be32 l_collision; /* Late collision frames */
  218. __be32 e_collision; /* Excessive collision frames */
  219. __be32 rx_ctl_frames; /* Rx control frames */
  220. __be32 rx_64_frames; /* Rx 64-bytes frames */
  221. __be32 rx_127_frames; /* Rx 65-127 bytes frames */
  222. __be32 rx_255_frames; /* Rx 128-255 bytes frames */
  223. __be32 rx_511_frames; /* Rx 256-511 bytes frames */
  224. __be32 rx_1023_frames; /* Rx 512-1023 bytes frames */
  225. __be32 rx_1522_frames; /* Rx 1024-1522 bytes frames */
  226. __be32 rx_9022_frames; /* Rx 1523-9022 bytes frames */
  227. __be32 tx_64_frames; /* Tx 64-bytes frames */
  228. __be32 tx_127_frames; /* Tx 65-127 bytes frames */
  229. __be32 tx_255_frames; /* Tx 128-255 bytes frames */
  230. __be32 tx_511_frames; /* Tx 256-511 bytes frames */
  231. __be32 tx_1023_frames; /* Tx 512-1023 bytes frames */
  232. __be32 tx_1522_frames; /* Tx 1024-1522 bytes frames */
  233. __be32 tx_9022_frames; /* Tx 1523-9022 bytes frames */
  234. __be32 rx_valid_bytes; /* Rx valid bytes */
  235. __be32 rx_runt_pkts; /* Rx error runt packets */
  236. __be32 rx_jabber_pkts; /* Rx error jabber packets */
  237. __be32 checksum; /* Checksum */
  238. };
  239. /* Get NCSI Statistics */
  240. struct ncsi_rsp_gns_pkt {
  241. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  242. __be32 rx_cmds; /* Rx NCSI commands */
  243. __be32 dropped_cmds; /* Dropped commands */
  244. __be32 cmd_type_errs; /* Command type errors */
  245. __be32 cmd_csum_errs; /* Command checksum errors */
  246. __be32 rx_pkts; /* Rx NCSI packets */
  247. __be32 tx_pkts; /* Tx NCSI packets */
  248. __be32 tx_aen_pkts; /* Tx AEN packets */
  249. __be32 checksum; /* Checksum */
  250. };
  251. /* Get NCSI Pass-through Statistics */
  252. struct ncsi_rsp_gnpts_pkt {
  253. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  254. __be32 tx_pkts; /* Tx packets */
  255. __be32 tx_dropped; /* Tx dropped packets */
  256. __be32 tx_channel_err; /* Tx channel errors */
  257. __be32 tx_us_err; /* Tx undersize errors */
  258. __be32 rx_pkts; /* Rx packets */
  259. __be32 rx_dropped; /* Rx dropped packets */
  260. __be32 rx_channel_err; /* Rx channel errors */
  261. __be32 rx_us_err; /* Rx undersize errors */
  262. __be32 rx_os_err; /* Rx oversize errors */
  263. __be32 checksum; /* Checksum */
  264. };
  265. /* Get package status */
  266. struct ncsi_rsp_gps_pkt {
  267. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  268. __be32 status; /* Hardware arbitration status */
  269. __be32 checksum;
  270. };
  271. /* Get package UUID */
  272. struct ncsi_rsp_gpuuid_pkt {
  273. struct ncsi_rsp_pkt_hdr rsp; /* Response header */
  274. unsigned char uuid[16]; /* UUID */
  275. __be32 checksum;
  276. };
  277. /* AEN: Link State Change */
  278. struct ncsi_aen_lsc_pkt {
  279. struct ncsi_aen_pkt_hdr aen; /* AEN header */
  280. __be32 status; /* Link status */
  281. __be32 oem_status; /* OEM link status */
  282. __be32 checksum; /* Checksum */
  283. unsigned char pad[14];
  284. };
  285. /* AEN: Configuration Required */
  286. struct ncsi_aen_cr_pkt {
  287. struct ncsi_aen_pkt_hdr aen; /* AEN header */
  288. __be32 checksum; /* Checksum */
  289. unsigned char pad[22];
  290. };
  291. /* AEN: Host Network Controller Driver Status Change */
  292. struct ncsi_aen_hncdsc_pkt {
  293. struct ncsi_aen_pkt_hdr aen; /* AEN header */
  294. __be32 status; /* Status */
  295. __be32 checksum; /* Checksum */
  296. unsigned char pad[18];
  297. };
  298. /* NCSI packet revision */
  299. #define NCSI_PKT_REVISION 0x01
  300. /* NCSI packet commands */
  301. #define NCSI_PKT_CMD_CIS 0x00 /* Clear Initial State */
  302. #define NCSI_PKT_CMD_SP 0x01 /* Select Package */
  303. #define NCSI_PKT_CMD_DP 0x02 /* Deselect Package */
  304. #define NCSI_PKT_CMD_EC 0x03 /* Enable Channel */
  305. #define NCSI_PKT_CMD_DC 0x04 /* Disable Channel */
  306. #define NCSI_PKT_CMD_RC 0x05 /* Reset Channel */
  307. #define NCSI_PKT_CMD_ECNT 0x06 /* Enable Channel Network Tx */
  308. #define NCSI_PKT_CMD_DCNT 0x07 /* Disable Channel Network Tx */
  309. #define NCSI_PKT_CMD_AE 0x08 /* AEN Enable */
  310. #define NCSI_PKT_CMD_SL 0x09 /* Set Link */
  311. #define NCSI_PKT_CMD_GLS 0x0a /* Get Link */
  312. #define NCSI_PKT_CMD_SVF 0x0b /* Set VLAN Filter */
  313. #define NCSI_PKT_CMD_EV 0x0c /* Enable VLAN */
  314. #define NCSI_PKT_CMD_DV 0x0d /* Disable VLAN */
  315. #define NCSI_PKT_CMD_SMA 0x0e /* Set MAC address */
  316. #define NCSI_PKT_CMD_EBF 0x10 /* Enable Broadcast Filter */
  317. #define NCSI_PKT_CMD_DBF 0x11 /* Disable Broadcast Filter */
  318. #define NCSI_PKT_CMD_EGMF 0x12 /* Enable Global Multicast Filter */
  319. #define NCSI_PKT_CMD_DGMF 0x13 /* Disable Global Multicast Filter */
  320. #define NCSI_PKT_CMD_SNFC 0x14 /* Set NCSI Flow Control */
  321. #define NCSI_PKT_CMD_GVI 0x15 /* Get Version ID */
  322. #define NCSI_PKT_CMD_GC 0x16 /* Get Capabilities */
  323. #define NCSI_PKT_CMD_GP 0x17 /* Get Parameters */
  324. #define NCSI_PKT_CMD_GCPS 0x18 /* Get Controller Packet Statistics */
  325. #define NCSI_PKT_CMD_GNS 0x19 /* Get NCSI Statistics */
  326. #define NCSI_PKT_CMD_GNPTS 0x1a /* Get NCSI Pass-throu Statistics */
  327. #define NCSI_PKT_CMD_GPS 0x1b /* Get package status */
  328. #define NCSI_PKT_CMD_OEM 0x50 /* OEM */
  329. #define NCSI_PKT_CMD_PLDM 0x51 /* PLDM request over NCSI over RBT */
  330. #define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */
  331. /* NCSI packet responses */
  332. #define NCSI_PKT_RSP_CIS (NCSI_PKT_CMD_CIS + 0x80)
  333. #define NCSI_PKT_RSP_SP (NCSI_PKT_CMD_SP + 0x80)
  334. #define NCSI_PKT_RSP_DP (NCSI_PKT_CMD_DP + 0x80)
  335. #define NCSI_PKT_RSP_EC (NCSI_PKT_CMD_EC + 0x80)
  336. #define NCSI_PKT_RSP_DC (NCSI_PKT_CMD_DC + 0x80)
  337. #define NCSI_PKT_RSP_RC (NCSI_PKT_CMD_RC + 0x80)
  338. #define NCSI_PKT_RSP_ECNT (NCSI_PKT_CMD_ECNT + 0x80)
  339. #define NCSI_PKT_RSP_DCNT (NCSI_PKT_CMD_DCNT + 0x80)
  340. #define NCSI_PKT_RSP_AE (NCSI_PKT_CMD_AE + 0x80)
  341. #define NCSI_PKT_RSP_SL (NCSI_PKT_CMD_SL + 0x80)
  342. #define NCSI_PKT_RSP_GLS (NCSI_PKT_CMD_GLS + 0x80)
  343. #define NCSI_PKT_RSP_SVF (NCSI_PKT_CMD_SVF + 0x80)
  344. #define NCSI_PKT_RSP_EV (NCSI_PKT_CMD_EV + 0x80)
  345. #define NCSI_PKT_RSP_DV (NCSI_PKT_CMD_DV + 0x80)
  346. #define NCSI_PKT_RSP_SMA (NCSI_PKT_CMD_SMA + 0x80)
  347. #define NCSI_PKT_RSP_EBF (NCSI_PKT_CMD_EBF + 0x80)
  348. #define NCSI_PKT_RSP_DBF (NCSI_PKT_CMD_DBF + 0x80)
  349. #define NCSI_PKT_RSP_EGMF (NCSI_PKT_CMD_EGMF + 0x80)
  350. #define NCSI_PKT_RSP_DGMF (NCSI_PKT_CMD_DGMF + 0x80)
  351. #define NCSI_PKT_RSP_SNFC (NCSI_PKT_CMD_SNFC + 0x80)
  352. #define NCSI_PKT_RSP_GVI (NCSI_PKT_CMD_GVI + 0x80)
  353. #define NCSI_PKT_RSP_GC (NCSI_PKT_CMD_GC + 0x80)
  354. #define NCSI_PKT_RSP_GP (NCSI_PKT_CMD_GP + 0x80)
  355. #define NCSI_PKT_RSP_GCPS (NCSI_PKT_CMD_GCPS + 0x80)
  356. #define NCSI_PKT_RSP_GNS (NCSI_PKT_CMD_GNS + 0x80)
  357. #define NCSI_PKT_RSP_GNPTS (NCSI_PKT_CMD_GNPTS + 0x80)
  358. #define NCSI_PKT_RSP_GPS (NCSI_PKT_CMD_GPS + 0x80)
  359. #define NCSI_PKT_RSP_OEM (NCSI_PKT_CMD_OEM + 0x80)
  360. #define NCSI_PKT_RSP_PLDM (NCSI_PKT_CMD_PLDM + 0x80)
  361. #define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80)
  362. /* NCSI response code/reason */
  363. #define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command Completed */
  364. #define NCSI_PKT_RSP_C_FAILED 0x0001 /* Command Failed */
  365. #define NCSI_PKT_RSP_C_UNAVAILABLE 0x0002 /* Command Unavailable */
  366. #define NCSI_PKT_RSP_C_UNSUPPORTED 0x0003 /* Command Unsupported */
  367. #define NCSI_PKT_RSP_R_NO_ERROR 0x0000 /* No Error */
  368. #define NCSI_PKT_RSP_R_INTERFACE 0x0001 /* Interface not ready */
  369. #define NCSI_PKT_RSP_R_PARAM 0x0002 /* Invalid Parameter */
  370. #define NCSI_PKT_RSP_R_CHANNEL 0x0003 /* Channel not Ready */
  371. #define NCSI_PKT_RSP_R_PACKAGE 0x0004 /* Package not Ready */
  372. #define NCSI_PKT_RSP_R_LENGTH 0x0005 /* Invalid payload length */
  373. #define NCSI_PKT_RSP_R_UNKNOWN 0x7fff /* Command type unsupported */
  374. /* NCSI AEN packet type */
  375. #define NCSI_PKT_AEN 0xFF /* AEN Packet */
  376. #define NCSI_PKT_AEN_LSC 0x00 /* Link status change */
  377. #define NCSI_PKT_AEN_CR 0x01 /* Configuration required */
  378. #define NCSI_PKT_AEN_HNCDSC 0x02 /* HNC driver status change */
  379. #endif /* __NCSI_PKT_H__ */