1 /* SPDX-License-Identifier: BSD-3-Clause */
3 * Copyright Gavin Shan, IBM Corporation 2016.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above
10 * copyright notice, this list of conditions and the following
13 * 2. Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * 3. Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33 * OF THE POSSIBILITY OF SUCH DAMAGE.
39 /* from linux/net/ncsi/ncsi-pkt.h */
40 #define __be32 uint32_t
41 #define __be16 uint16_t
44 unsigned char mc_id
; /* Management controller ID */
45 unsigned char revision
; /* NCSI version - 0x01 */
46 unsigned char reserved
; /* Reserved */
47 unsigned char id
; /* Packet sequence number */
48 unsigned char type
; /* Packet type */
49 unsigned char channel
; /* Network controller ID */
50 __be16 length
; /* Payload length */
51 __be32 reserved1
[2]; /* Reserved */
54 struct ncsi_cmd_pkt_hdr
{
55 struct ncsi_pkt_hdr common
; /* Common NCSI packet header */
58 struct ncsi_rsp_pkt_hdr
{
59 struct ncsi_pkt_hdr common
; /* Common NCSI packet header */
60 __be16 code
; /* Response code */
61 __be16 reason
; /* Response reason */
64 struct ncsi_aen_pkt_hdr
{
65 struct ncsi_pkt_hdr common
; /* Common NCSI packet header */
66 unsigned char reserved2
[3]; /* Reserved */
67 unsigned char type
; /* AEN packet type */
70 /* NCSI common command packet */
72 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
73 __be32 checksum
; /* Checksum */
74 unsigned char pad
[26];
78 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
79 __be32 checksum
; /* Checksum */
80 unsigned char pad
[22];
84 struct ncsi_cmd_sp_pkt
{
85 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
86 unsigned char reserved
[3]; /* Reserved */
87 unsigned char hw_arbitration
; /* HW arbitration */
88 __be32 checksum
; /* Checksum */
89 unsigned char pad
[22];
93 struct ncsi_cmd_dc_pkt
{
94 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
95 unsigned char reserved
[3]; /* Reserved */
96 unsigned char ald
; /* Allow link down */
97 __be32 checksum
; /* Checksum */
98 unsigned char pad
[22];
102 struct ncsi_cmd_rc_pkt
{
103 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
104 __be32 reserved
; /* Reserved */
105 __be32 checksum
; /* Checksum */
106 unsigned char pad
[22];
110 struct ncsi_cmd_ae_pkt
{
111 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
112 unsigned char reserved
[3]; /* Reserved */
113 unsigned char mc_id
; /* MC ID */
114 __be32 mode
; /* AEN working mode */
115 __be32 checksum
; /* Checksum */
116 unsigned char pad
[18];
120 struct ncsi_cmd_sl_pkt
{
121 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
122 __be32 mode
; /* Link working mode */
123 __be32 oem_mode
; /* OEM link mode */
124 __be32 checksum
; /* Checksum */
125 unsigned char pad
[18];
128 /* Set VLAN Filter */
129 struct ncsi_cmd_svf_pkt
{
130 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
131 __be16 reserved
; /* Reserved */
132 __be16 vlan
; /* VLAN ID */
133 __be16 reserved1
; /* Reserved */
134 unsigned char index
; /* VLAN table index */
135 unsigned char enable
; /* Enable or disable */
136 __be32 checksum
; /* Checksum */
137 unsigned char pad
[14];
141 struct ncsi_cmd_ev_pkt
{
142 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
143 unsigned char reserved
[3]; /* Reserved */
144 unsigned char mode
; /* VLAN filter mode */
145 __be32 checksum
; /* Checksum */
146 unsigned char pad
[22];
149 /* Set MAC Address */
150 struct ncsi_cmd_sma_pkt
{
151 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
152 unsigned char mac
[6]; /* MAC address */
153 unsigned char index
; /* MAC table index */
154 unsigned char at_e
; /* Addr type and operation */
155 __be32 checksum
; /* Checksum */
156 unsigned char pad
[18];
159 /* Enable Broadcast Filter */
160 struct ncsi_cmd_ebf_pkt
{
161 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
162 __be32 mode
; /* Filter mode */
163 __be32 checksum
; /* Checksum */
164 unsigned char pad
[22];
167 /* Enable Global Multicast Filter */
168 struct ncsi_cmd_egmf_pkt
{
169 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
170 __be32 mode
; /* Global MC mode */
171 __be32 checksum
; /* Checksum */
172 unsigned char pad
[22];
175 /* Set NCSI Flow Control */
176 struct ncsi_cmd_snfc_pkt
{
177 struct ncsi_cmd_pkt_hdr cmd
; /* Command header */
178 unsigned char reserved
[3]; /* Reserved */
179 unsigned char mode
; /* Flow control mode */
180 __be32 checksum
; /* Checksum */
181 unsigned char pad
[22];
184 /* Get Link Status */
185 struct ncsi_rsp_gls_pkt
{
186 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
187 __be32 status
; /* Link status */
188 __be32 other
; /* Other indications */
189 __be32 oem_status
; /* OEM link status */
191 unsigned char pad
[10];
195 struct ncsi_rsp_gvi_pkt
{
196 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
197 __be32 ncsi_version
; /* NCSI version */
198 unsigned char reserved
[3]; /* Reserved */
199 unsigned char alpha2
; /* NCSI version */
200 unsigned char fw_name
[12]; /* f/w name string */
201 __be32 fw_version
; /* f/w version */
202 __be16 pci_ids
[4]; /* PCI IDs */
203 __be32 mf_id
; /* Manufacture ID */
207 /* Get Capabilities */
208 struct ncsi_rsp_gc_pkt
{
209 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
210 __be32 cap
; /* Capabilities */
211 __be32 bc_cap
; /* Broadcast cap */
212 __be32 mc_cap
; /* Multicast cap */
213 __be32 buf_cap
; /* Buffering cap */
214 __be32 aen_cap
; /* AEN cap */
215 unsigned char vlan_cnt
; /* VLAN filter count */
216 unsigned char mixed_cnt
; /* Mix filter count */
217 unsigned char mc_cnt
; /* MC filter count */
218 unsigned char uc_cnt
; /* UC filter count */
219 unsigned char reserved
[2]; /* Reserved */
220 unsigned char vlan_mode
; /* VLAN mode */
221 unsigned char channel_cnt
; /* Channel count */
222 __be32 checksum
; /* Checksum */
226 struct ncsi_rsp_gp_pkt
{
227 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
228 unsigned char mac_cnt
; /* Number of MAC addr */
229 unsigned char reserved
[2]; /* Reserved */
230 unsigned char mac_enable
; /* MAC addr enable flags */
231 unsigned char vlan_cnt
; /* VLAN tag count */
232 unsigned char reserved1
; /* Reserved */
233 __be16 vlan_enable
; /* VLAN tag enable flags */
234 __be32 link_mode
; /* Link setting */
235 __be32 bc_mode
; /* BC filter mode */
236 __be32 valid_modes
; /* Valid mode parameters */
237 unsigned char vlan_mode
; /* VLAN mode */
238 unsigned char fc_mode
; /* Flow control mode */
239 unsigned char reserved2
[2]; /* Reserved */
240 __be32 aen_mode
; /* AEN mode */
241 unsigned char mac
[6]; /* Supported MAC addr */
242 __be16 vlan
; /* Supported VLAN tags */
243 __be32 checksum
; /* Checksum */
246 /* Get Controller Packet Statistics */
247 struct ncsi_rsp_gcps_pkt
{
248 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
249 __be32 cnt_hi
; /* Counter cleared */
250 __be32 cnt_lo
; /* Counter cleared */
251 __be32 rx_bytes
; /* Rx bytes */
252 __be32 tx_bytes
; /* Tx bytes */
253 __be32 rx_uc_pkts
; /* Rx UC packets */
254 __be32 rx_mc_pkts
; /* Rx MC packets */
255 __be32 rx_bc_pkts
; /* Rx BC packets */
256 __be32 tx_uc_pkts
; /* Tx UC packets */
257 __be32 tx_mc_pkts
; /* Tx MC packets */
258 __be32 tx_bc_pkts
; /* Tx BC packets */
259 __be32 fcs_err
; /* FCS errors */
260 __be32 align_err
; /* Alignment errors */
261 __be32 false_carrier
; /* False carrier detection */
262 __be32 runt_pkts
; /* Rx runt packets */
263 __be32 jabber_pkts
; /* Rx jabber packets */
264 __be32 rx_pause_xon
; /* Rx pause XON frames */
265 __be32 rx_pause_xoff
; /* Rx XOFF frames */
266 __be32 tx_pause_xon
; /* Tx XON frames */
267 __be32 tx_pause_xoff
; /* Tx XOFF frames */
268 __be32 tx_s_collision
; /* Single collision frames */
269 __be32 tx_m_collision
; /* Multiple collision frames */
270 __be32 l_collision
; /* Late collision frames */
271 __be32 e_collision
; /* Excessive collision frames */
272 __be32 rx_ctl_frames
; /* Rx control frames */
273 __be32 rx_64_frames
; /* Rx 64-bytes frames */
274 __be32 rx_127_frames
; /* Rx 65-127 bytes frames */
275 __be32 rx_255_frames
; /* Rx 128-255 bytes frames */
276 __be32 rx_511_frames
; /* Rx 256-511 bytes frames */
277 __be32 rx_1023_frames
; /* Rx 512-1023 bytes frames */
278 __be32 rx_1522_frames
; /* Rx 1024-1522 bytes frames */
279 __be32 rx_9022_frames
; /* Rx 1523-9022 bytes frames */
280 __be32 tx_64_frames
; /* Tx 64-bytes frames */
281 __be32 tx_127_frames
; /* Tx 65-127 bytes frames */
282 __be32 tx_255_frames
; /* Tx 128-255 bytes frames */
283 __be32 tx_511_frames
; /* Tx 256-511 bytes frames */
284 __be32 tx_1023_frames
; /* Tx 512-1023 bytes frames */
285 __be32 tx_1522_frames
; /* Tx 1024-1522 bytes frames */
286 __be32 tx_9022_frames
; /* Tx 1523-9022 bytes frames */
287 __be32 rx_valid_bytes
; /* Rx valid bytes */
288 __be32 rx_runt_pkts
; /* Rx error runt packets */
289 __be32 rx_jabber_pkts
; /* Rx error jabber packets */
290 __be32 checksum
; /* Checksum */
293 /* Get NCSI Statistics */
294 struct ncsi_rsp_gns_pkt
{
295 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
296 __be32 rx_cmds
; /* Rx NCSI commands */
297 __be32 dropped_cmds
; /* Dropped commands */
298 __be32 cmd_type_errs
; /* Command type errors */
299 __be32 cmd_csum_errs
; /* Command checksum errors */
300 __be32 rx_pkts
; /* Rx NCSI packets */
301 __be32 tx_pkts
; /* Tx NCSI packets */
302 __be32 tx_aen_pkts
; /* Tx AEN packets */
303 __be32 checksum
; /* Checksum */
306 /* Get NCSI Pass-through Statistics */
307 struct ncsi_rsp_gnpts_pkt
{
308 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
309 __be32 tx_pkts
; /* Tx packets */
310 __be32 tx_dropped
; /* Tx dropped packets */
311 __be32 tx_channel_err
; /* Tx channel errors */
312 __be32 tx_us_err
; /* Tx undersize errors */
313 __be32 rx_pkts
; /* Rx packets */
314 __be32 rx_dropped
; /* Rx dropped packets */
315 __be32 rx_channel_err
; /* Rx channel errors */
316 __be32 rx_us_err
; /* Rx undersize errors */
317 __be32 rx_os_err
; /* Rx oversize errors */
318 __be32 checksum
; /* Checksum */
321 /* Get package status */
322 struct ncsi_rsp_gps_pkt
{
323 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
324 __be32 status
; /* Hardware arbitration status */
328 /* Get package UUID */
329 struct ncsi_rsp_gpuuid_pkt
{
330 struct ncsi_rsp_pkt_hdr rsp
; /* Response header */
331 unsigned char uuid
[16]; /* UUID */
335 /* AEN: Link State Change */
336 struct ncsi_aen_lsc_pkt
{
337 struct ncsi_aen_pkt_hdr aen
; /* AEN header */
338 __be32 status
; /* Link status */
339 __be32 oem_status
; /* OEM link status */
340 __be32 checksum
; /* Checksum */
341 unsigned char pad
[14];
344 /* AEN: Configuration Required */
345 struct ncsi_aen_cr_pkt
{
346 struct ncsi_aen_pkt_hdr aen
; /* AEN header */
347 __be32 checksum
; /* Checksum */
348 unsigned char pad
[22];
351 /* AEN: Host Network Controller Driver Status Change */
352 struct ncsi_aen_hncdsc_pkt
{
353 struct ncsi_aen_pkt_hdr aen
; /* AEN header */
354 __be32 status
; /* Status */
355 __be32 checksum
; /* Checksum */
356 unsigned char pad
[18];
359 /* NCSI packet revision */
360 #define NCSI_PKT_REVISION 0x01
362 /* NCSI packet commands */
363 #define NCSI_PKT_CMD_CIS 0x00 /* Clear Initial State */
364 #define NCSI_PKT_CMD_SP 0x01 /* Select Package */
365 #define NCSI_PKT_CMD_DP 0x02 /* Deselect Package */
366 #define NCSI_PKT_CMD_EC 0x03 /* Enable Channel */
367 #define NCSI_PKT_CMD_DC 0x04 /* Disable Channel */
368 #define NCSI_PKT_CMD_RC 0x05 /* Reset Channel */
369 #define NCSI_PKT_CMD_ECNT 0x06 /* Enable Channel Network Tx */
370 #define NCSI_PKT_CMD_DCNT 0x07 /* Disable Channel Network Tx */
371 #define NCSI_PKT_CMD_AE 0x08 /* AEN Enable */
372 #define NCSI_PKT_CMD_SL 0x09 /* Set Link */
373 #define NCSI_PKT_CMD_GLS 0x0a /* Get Link */
374 #define NCSI_PKT_CMD_SVF 0x0b /* Set VLAN Filter */
375 #define NCSI_PKT_CMD_EV 0x0c /* Enable VLAN */
376 #define NCSI_PKT_CMD_DV 0x0d /* Disable VLAN */
377 #define NCSI_PKT_CMD_SMA 0x0e /* Set MAC address */
378 #define NCSI_PKT_CMD_EBF 0x10 /* Enable Broadcast Filter */
379 #define NCSI_PKT_CMD_DBF 0x11 /* Disable Broadcast Filter */
380 #define NCSI_PKT_CMD_EGMF 0x12 /* Enable Global Multicast Filter */
381 #define NCSI_PKT_CMD_DGMF 0x13 /* Disable Global Multicast Filter */
382 #define NCSI_PKT_CMD_SNFC 0x14 /* Set NCSI Flow Control */
383 #define NCSI_PKT_CMD_GVI 0x15 /* Get Version ID */
384 #define NCSI_PKT_CMD_GC 0x16 /* Get Capabilities */
385 #define NCSI_PKT_CMD_GP 0x17 /* Get Parameters */
386 #define NCSI_PKT_CMD_GCPS 0x18 /* Get Controller Packet Statistics */
387 #define NCSI_PKT_CMD_GNS 0x19 /* Get NCSI Statistics */
388 #define NCSI_PKT_CMD_GNPTS 0x1a /* Get NCSI Pass-throu Statistics */
389 #define NCSI_PKT_CMD_GPS 0x1b /* Get package status */
390 #define NCSI_PKT_CMD_OEM 0x50 /* OEM */
391 #define NCSI_PKT_CMD_PLDM 0x51 /* PLDM request over NCSI over RBT */
392 #define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */
394 /* NCSI packet responses */
395 #define NCSI_PKT_RSP_CIS (NCSI_PKT_CMD_CIS + 0x80)
396 #define NCSI_PKT_RSP_SP (NCSI_PKT_CMD_SP + 0x80)
397 #define NCSI_PKT_RSP_DP (NCSI_PKT_CMD_DP + 0x80)
398 #define NCSI_PKT_RSP_EC (NCSI_PKT_CMD_EC + 0x80)
399 #define NCSI_PKT_RSP_DC (NCSI_PKT_CMD_DC + 0x80)
400 #define NCSI_PKT_RSP_RC (NCSI_PKT_CMD_RC + 0x80)
401 #define NCSI_PKT_RSP_ECNT (NCSI_PKT_CMD_ECNT + 0x80)
402 #define NCSI_PKT_RSP_DCNT (NCSI_PKT_CMD_DCNT + 0x80)
403 #define NCSI_PKT_RSP_AE (NCSI_PKT_CMD_AE + 0x80)
404 #define NCSI_PKT_RSP_SL (NCSI_PKT_CMD_SL + 0x80)
405 #define NCSI_PKT_RSP_GLS (NCSI_PKT_CMD_GLS + 0x80)
406 #define NCSI_PKT_RSP_SVF (NCSI_PKT_CMD_SVF + 0x80)
407 #define NCSI_PKT_RSP_EV (NCSI_PKT_CMD_EV + 0x80)
408 #define NCSI_PKT_RSP_DV (NCSI_PKT_CMD_DV + 0x80)
409 #define NCSI_PKT_RSP_SMA (NCSI_PKT_CMD_SMA + 0x80)
410 #define NCSI_PKT_RSP_EBF (NCSI_PKT_CMD_EBF + 0x80)
411 #define NCSI_PKT_RSP_DBF (NCSI_PKT_CMD_DBF + 0x80)
412 #define NCSI_PKT_RSP_EGMF (NCSI_PKT_CMD_EGMF + 0x80)
413 #define NCSI_PKT_RSP_DGMF (NCSI_PKT_CMD_DGMF + 0x80)
414 #define NCSI_PKT_RSP_SNFC (NCSI_PKT_CMD_SNFC + 0x80)
415 #define NCSI_PKT_RSP_GVI (NCSI_PKT_CMD_GVI + 0x80)
416 #define NCSI_PKT_RSP_GC (NCSI_PKT_CMD_GC + 0x80)
417 #define NCSI_PKT_RSP_GP (NCSI_PKT_CMD_GP + 0x80)
418 #define NCSI_PKT_RSP_GCPS (NCSI_PKT_CMD_GCPS + 0x80)
419 #define NCSI_PKT_RSP_GNS (NCSI_PKT_CMD_GNS + 0x80)
420 #define NCSI_PKT_RSP_GNPTS (NCSI_PKT_CMD_GNPTS + 0x80)
421 #define NCSI_PKT_RSP_GPS (NCSI_PKT_CMD_GPS + 0x80)
422 #define NCSI_PKT_RSP_OEM (NCSI_PKT_CMD_OEM + 0x80)
423 #define NCSI_PKT_RSP_PLDM (NCSI_PKT_CMD_PLDM + 0x80)
424 #define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80)
426 /* NCSI response code/reason */
427 #define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command Completed */
428 #define NCSI_PKT_RSP_C_FAILED 0x0001 /* Command Failed */
429 #define NCSI_PKT_RSP_C_UNAVAILABLE 0x0002 /* Command Unavailable */
430 #define NCSI_PKT_RSP_C_UNSUPPORTED 0x0003 /* Command Unsupported */
431 #define NCSI_PKT_RSP_R_NO_ERROR 0x0000 /* No Error */
432 #define NCSI_PKT_RSP_R_INTERFACE 0x0001 /* Interface not ready */
433 #define NCSI_PKT_RSP_R_PARAM 0x0002 /* Invalid Parameter */
434 #define NCSI_PKT_RSP_R_CHANNEL 0x0003 /* Channel not Ready */
435 #define NCSI_PKT_RSP_R_PACKAGE 0x0004 /* Package not Ready */
436 #define NCSI_PKT_RSP_R_LENGTH 0x0005 /* Invalid payload length */
437 #define NCSI_PKT_RSP_R_UNKNOWN 0x7fff /* Command type unsupported */
439 /* NCSI AEN packet type */
440 #define NCSI_PKT_AEN 0xFF /* AEN Packet */
441 #define NCSI_PKT_AEN_LSC 0x00 /* Link status change */
442 #define NCSI_PKT_AEN_CR 0x01 /* Configuration required */
443 #define NCSI_PKT_AEN_HNCDSC 0x02 /* HNC driver status change */
445 #endif /* NCSI_PKT_H */