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