xref: /freebsd/sys/dev/mlx/mlxreg.h (revision 1ac4b82b11c460d0ef82bf760b71a8b4d34be28a)
11ac4b82bSMike Smith /*-
21ac4b82bSMike Smith  * Copyright (c) 1999 Michael Smith
31ac4b82bSMike Smith  * All rights reserved.
41ac4b82bSMike Smith  *
51ac4b82bSMike Smith  * Redistribution and use in source and binary forms, with or without
61ac4b82bSMike Smith  * modification, are permitted provided that the following conditions
71ac4b82bSMike Smith  * are met:
81ac4b82bSMike Smith  * 1. Redistributions of source code must retain the above copyright
91ac4b82bSMike Smith  *    notice, this list of conditions and the following disclaimer.
101ac4b82bSMike Smith  * 2. Redistributions in binary form must reproduce the above copyright
111ac4b82bSMike Smith  *    notice, this list of conditions and the following disclaimer in the
121ac4b82bSMike Smith  *    documentation and/or other materials provided with the distribution.
131ac4b82bSMike Smith  *
141ac4b82bSMike Smith  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151ac4b82bSMike Smith  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161ac4b82bSMike Smith  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171ac4b82bSMike Smith  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181ac4b82bSMike Smith  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191ac4b82bSMike Smith  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201ac4b82bSMike Smith  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211ac4b82bSMike Smith  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221ac4b82bSMike Smith  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231ac4b82bSMike Smith  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241ac4b82bSMike Smith  * SUCH DAMAGE.
251ac4b82bSMike Smith  *
261ac4b82bSMike Smith  *	$FreeBSD$
271ac4b82bSMike Smith  */
281ac4b82bSMike Smith 
291ac4b82bSMike Smith /*
301ac4b82bSMike Smith  * Selected command codes.
311ac4b82bSMike Smith  */
321ac4b82bSMike Smith #define MLX_CMD_ENQUIRY		0x53
331ac4b82bSMike Smith #define MLX_CMD_ENQUIRY2	0x1c
341ac4b82bSMike Smith #define MLX_CMD_ENQSYSDRIVE	0x19
351ac4b82bSMike Smith #define MLX_CMD_READOLDSG	0xb6
361ac4b82bSMike Smith #define MLX_CMD_WRITEOLDSG	0xb7
371ac4b82bSMike Smith #define MLX_CMD_FLUSH		0x0a
381ac4b82bSMike Smith #define MLX_CMD_LOGOP		0x72
391ac4b82bSMike Smith #define MLX_CMD_REBUILDASYNC	0x16
401ac4b82bSMike Smith #define MLX_CMD_CHECKASYNC	0x1e
411ac4b82bSMike Smith #define MLX_CMD_REBUILDSTAT	0x0c
421ac4b82bSMike Smith #define MLX_CMD_STOPCHANNEL	0x13
431ac4b82bSMike Smith #define MLX_CMD_STARTCHANNEL	0x12
441ac4b82bSMike Smith 
451ac4b82bSMike Smith /*
461ac4b82bSMike Smith  * Status values.
471ac4b82bSMike Smith  */
481ac4b82bSMike Smith #define MLX_STATUS_OK		0x0000
491ac4b82bSMike Smith #define MLX_STATUS_RDWROFFLINE	0x0002	/* read/write claims drive is offline */
501ac4b82bSMike Smith #define MLX_STATUS_WEDGED	0xdead	/* controller not listening */
511ac4b82bSMike Smith #define MLX_STATUS_BUSY		0xffff	/* command is in controller */
521ac4b82bSMike Smith 
531ac4b82bSMike Smith /*
541ac4b82bSMike Smith  * Scatter-gather list format, type 1, kind 00.
551ac4b82bSMike Smith  */
561ac4b82bSMike Smith struct mlx_sgentry
571ac4b82bSMike Smith {
581ac4b82bSMike Smith     u_int32_t	sg_addr;
591ac4b82bSMike Smith     u_int32_t	sg_count;
601ac4b82bSMike Smith } __attribute__ ((packed));
611ac4b82bSMike Smith 
621ac4b82bSMike Smith /*
631ac4b82bSMike Smith  * Command result buffers, as placed in system memory by the controller.
641ac4b82bSMike Smith  */
651ac4b82bSMike Smith struct mlx_enquiry	/* MLX_CMD_ENQUIRY */
661ac4b82bSMike Smith {
671ac4b82bSMike Smith     u_int8_t		me_num_sys_drvs;
681ac4b82bSMike Smith     u_int8_t		res1[3];
691ac4b82bSMike Smith     u_int32_t		me_drvsize[32];
701ac4b82bSMike Smith     u_int16_t		me_flash_age;
711ac4b82bSMike Smith     u_int8_t		me_status_flags;
721ac4b82bSMike Smith #define MLX_ENQ_SFLAG_DEFWRERR	(1<<0)	/* deferred write error indicator */
731ac4b82bSMike Smith #define MLX_ENQ_SFLAG_BATTLOW	(1<<1)	/* battery low */
741ac4b82bSMike Smith     u_int8_t		res2;
751ac4b82bSMike Smith     u_int8_t		me_fwminor;
761ac4b82bSMike Smith     u_int8_t		me_fwmajor;
771ac4b82bSMike Smith     u_int8_t		me_rebuild_flag;
781ac4b82bSMike Smith     u_int8_t		me_max_commands;
791ac4b82bSMike Smith     u_int8_t		me_offline_sd_count;
801ac4b82bSMike Smith     u_int8_t		res3;
811ac4b82bSMike Smith     u_int16_t		me_event_log_seq_num;
821ac4b82bSMike Smith     u_int8_t		me_critical_sd_count;
831ac4b82bSMike Smith     u_int8_t		res4[3];
841ac4b82bSMike Smith     u_int8_t		me_dead_count;
851ac4b82bSMike Smith     u_int8_t		res5;
861ac4b82bSMike Smith     u_int8_t		me_rebuild_count;
871ac4b82bSMike Smith     u_int8_t		me_misc_flags;
881ac4b82bSMike Smith #define MLX_ENQ_MISC_BBU	(1<<3)	/* battery backup present */
891ac4b82bSMike Smith     struct
901ac4b82bSMike Smith     {
911ac4b82bSMike Smith 	u_int8_t	dd_targ;
921ac4b82bSMike Smith 	u_int8_t	dd_chan;
931ac4b82bSMike Smith     } __attribute__ ((packed)) me_dead[20];
941ac4b82bSMike Smith } __attribute__ ((packed));
951ac4b82bSMike Smith 
961ac4b82bSMike Smith struct mlx_enquiry2	/* MLX_CMD_ENQUIRY2 */
971ac4b82bSMike Smith {
981ac4b82bSMike Smith     u_int32_t		me_hardware_id;
991ac4b82bSMike Smith     u_int32_t		me_firmware_id;
1001ac4b82bSMike Smith     u_int32_t		res1;
1011ac4b82bSMike Smith     u_int8_t		me_configured_channels;
1021ac4b82bSMike Smith     u_int8_t		me_actual_channels;
1031ac4b82bSMike Smith     u_int8_t		me_max_targets;
1041ac4b82bSMike Smith     u_int8_t		me_max_tags;
1051ac4b82bSMike Smith     u_int8_t		me_max_sys_drives;
1061ac4b82bSMike Smith     u_int8_t		me_max_arms;
1071ac4b82bSMike Smith     u_int8_t		me_max_spans;
1081ac4b82bSMike Smith     u_int8_t		res2;
1091ac4b82bSMike Smith     u_int32_t		res3;
1101ac4b82bSMike Smith     u_int32_t		me_mem_size;
1111ac4b82bSMike Smith     u_int32_t		me_cache_size;
1121ac4b82bSMike Smith     u_int32_t		me_flash_size;
1131ac4b82bSMike Smith     u_int32_t		me_nvram_size;
1141ac4b82bSMike Smith     u_int16_t		me_mem_type;
1151ac4b82bSMike Smith     u_int16_t		me_clock_speed;
1161ac4b82bSMike Smith     u_int16_t		me_mem_speed;
1171ac4b82bSMike Smith     u_int16_t		me_hardware_speed;
1181ac4b82bSMike Smith     u_int8_t		res4[10];
1191ac4b82bSMike Smith     u_int16_t		me_max_commands;
1201ac4b82bSMike Smith     u_int16_t		me_max_sg;
1211ac4b82bSMike Smith     u_int16_t		me_max_dp;
1221ac4b82bSMike Smith     u_int16_t		me_max_iod;
1231ac4b82bSMike Smith     u_int16_t		me_max_comb;
1241ac4b82bSMike Smith     u_int8_t		me_latency;
1251ac4b82bSMike Smith     u_int8_t		res5;
1261ac4b82bSMike Smith     u_int8_t		me_scsi_timeout;
1271ac4b82bSMike Smith     u_int8_t		res6;
1281ac4b82bSMike Smith     u_int16_t		me_min_freelines;
1291ac4b82bSMike Smith     u_int8_t		res7[8];
1301ac4b82bSMike Smith     u_int8_t		me_rate_const;
1311ac4b82bSMike Smith     u_int8_t		res8[11];
1321ac4b82bSMike Smith     u_int16_t		me_physblk;
1331ac4b82bSMike Smith     u_int16_t		me_logblk;
1341ac4b82bSMike Smith     u_int16_t		me_maxblk;
1351ac4b82bSMike Smith     u_int16_t		me_blocking_factor;
1361ac4b82bSMike Smith     u_int16_t		me_cacheline;
1371ac4b82bSMike Smith     u_int8_t		me_scsi_cap;
1381ac4b82bSMike Smith     u_int8_t		res9[5];
1391ac4b82bSMike Smith     u_int16_t		me_fimware_build;
1401ac4b82bSMike Smith     u_int8_t		me_fault_mgmt_type;
1411ac4b82bSMike Smith     u_int8_t		res10;
1421ac4b82bSMike Smith     u_int32_t		me_firmware_features;
1431ac4b82bSMike Smith     u_int8_t		res11[8];
1441ac4b82bSMike Smith } __attribute__ ((packed));
1451ac4b82bSMike Smith 
1461ac4b82bSMike Smith struct mlx_enq_sys_drive /* MLX_CMD_ENQSYSDRIVE returns an array of 32 of these */
1471ac4b82bSMike Smith {
1481ac4b82bSMike Smith     u_int32_t		sd_size;
1491ac4b82bSMike Smith     u_int8_t		sd_state;
1501ac4b82bSMike Smith     u_int8_t		sd_raidlevel;
1511ac4b82bSMike Smith     u_int16_t		res1;
1521ac4b82bSMike Smith } __attribute__ ((packed));
1531ac4b82bSMike Smith 
1541ac4b82bSMike Smith struct mlx_eventlog_entry	/* MLX_CMD_LOGOP/MLX_LOGOP_GET */
1551ac4b82bSMike Smith {
1561ac4b82bSMike Smith     u_int8_t		el_type;
1571ac4b82bSMike Smith     u_int8_t		el_length;
1581ac4b82bSMike Smith     u_char		el_target:5;
1591ac4b82bSMike Smith     u_char		el_channel:3;
1601ac4b82bSMike Smith     u_char		el_lun:6;
1611ac4b82bSMike Smith     u_char		res1:2;
1621ac4b82bSMike Smith     u_int16_t		el_seqno;
1631ac4b82bSMike Smith     u_char		el_errorcode:7;
1641ac4b82bSMike Smith     u_char		el_valid:1;
1651ac4b82bSMike Smith     u_int8_t		el_segment;
1661ac4b82bSMike Smith     u_char		el_sensekey:4;
1671ac4b82bSMike Smith     u_char		res2:1;
1681ac4b82bSMike Smith     u_char		el_ILI:1;
1691ac4b82bSMike Smith     u_char		el_EOM:1;
1701ac4b82bSMike Smith     u_char		el_filemark:1;
1711ac4b82bSMike Smith     u_int8_t		el_information[4];
1721ac4b82bSMike Smith     u_int8_t		el_addsense;
1731ac4b82bSMike Smith     u_int8_t		el_csi[4];
1741ac4b82bSMike Smith     u_int8_t		el_asc;
1751ac4b82bSMike Smith     u_int8_t		el_asq;
1761ac4b82bSMike Smith     u_int8_t		res3[12];
1771ac4b82bSMike Smith } __attribute__ ((packed));
1781ac4b82bSMike Smith 
1791ac4b82bSMike Smith #define MLX_LOGOP_GET		0x00	/* operation codes for MLX_CMD_LOGOP */
1801ac4b82bSMike Smith #define MLX_LOGMSG_SENSE	0x00	/* log message contents codes */
1811ac4b82bSMike Smith 
1821ac4b82bSMike Smith struct mlx_rebuild_stat	/* MLX_CMD_REBUILDSTAT */
1831ac4b82bSMike Smith {
1841ac4b82bSMike Smith     u_int32_t	rb_drive;
1851ac4b82bSMike Smith     u_int32_t	rb_size;
1861ac4b82bSMike Smith     u_int32_t	rb_remaining;
1871ac4b82bSMike Smith } __attribute__ ((packed));
1881ac4b82bSMike Smith 
189