1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * 21 * 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 /* 26 * PMC 8x6G IOMB Definitions 27 */ 28 #ifndef _PMCS_IOMB_H 29 #define _PMCS_IOMB_H 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * An IOMB (IO Message Buffer) is the principle means of communication 36 * between the PMC and the HOST. The host places IOMBs on the Inbound 37 * Queues (IQ) which are in HOST memory and updates a producer index 38 * within the PMC. The PMC pulls the IOMB off the IQ and updates a 39 * consumer index in HOST memory. If appropriate, when the PMC is 40 * done with the action requested by the IOMB, the PMC writes a 41 * reply IOMB to host memory and updates its producer index and 42 * interrupts the HOST. 43 */ 44 /* 45 * The first word of all IOMBs is always laid out thusly: 46 * 47 * |Byte 3 |Byte 2 |Byte 1 |Byte 0 | 48 * +-------------+-------------+----------------------+ 49 * |V Resvd BC|Resvd OBID |CAT | OPCODE | 50 * +--------------------------------------------------+ 51 * 52 * V == Valid 53 * BC = Buffer Count 54 * OBID = Outbound Queue ID 55 * CAT = Category 56 * OPCODE = Well, uh, OPCODE. 57 */ 58 59 #define PMCS_IOMB_VALID (1U << 31) 60 #define PMCS_IOMB_HIPRI (1U << 30) 61 #define PMCS_IOMB_BC_SHIFT (24) 62 #define PMCS_IOMB_BC_MASK (0xf << PMCS_IOMB_BC_SHIFT) 63 #define PMCS_IOMB_OBID_SHIFT (16) 64 #define PMCS_IOMB_OBID_MASK (0xf << PMCS_IOMB_OBID_SHIFT) 65 #define PMCS_IOMB_CAT_SHIFT (12) 66 #define PMCS_IOMB_CAT_MASK (0xf << PMCS_IOMB_CAT_SHIFT) 67 #define PMCS_IOMB_OPCODE_MASK (0xfff) 68 69 70 #define PMCS_IOMB_CAT_NET 0 71 #define PMCS_IOMB_CAT_FC 1 72 #define PMCS_IOMB_CAT_SAS 2 73 #define PMCS_IOMB_CAT_SCSI 3 74 75 /* 76 * Shorthand 77 */ 78 #define PMCS_IOMB_IN_SAS(q, opcode) \ 79 (PMCS_IOMB_VALID | (1 << PMCS_IOMB_BC_SHIFT) | \ 80 (PMCS_IOMB_CAT_SAS << PMCS_IOMB_CAT_SHIFT) | \ 81 ((q << PMCS_IOMB_OBID_SHIFT) & PMCS_IOMB_OBID_MASK) | \ 82 (opcode & PMCS_IOMB_OPCODE_MASK)) 83 84 /* 85 * PMC IOMB Inbound Queue Opcodes 86 */ 87 #define PMCIN_ECHO 0x01 88 #define PMCIN_GET_INFO 0x02 89 #define PMCIN_GET_VPD 0x03 90 #define PMCIN_PHY_START 0x04 91 #define PMCIN_PHY_STOP 0x05 92 #define PMCIN_SSP_INI_IO_START 0x06 93 #define PMCIN_SSP_INI_TM_START 0x07 94 #define PMCIN_SSP_INI_EXT_IO_START 0x08 95 #define PMCIN_DEVICE_HANDLE_ACCEPT 0x09 96 #define PMCIN_SSP_TGT_IO_START 0x0A 97 #define PMCIN_SSP_TGT_RESPONSE_START 0x0B 98 #define PMCIN_SSP_INI_EDC_EXT_IO_START 0x0C 99 #define PMCIN_SSP_INI_EDC_EXT_IO_START1 0x0D 100 #define PMCIN_SSP_TGT_EDC_IO_START 0x0E 101 #define PMCIN_SSP_ABORT 0x0F 102 #define PMCIN_DEREGISTER_DEVICE_HANDLE 0x10 103 #define PMCIN_GET_DEVICE_HANDLE 0x11 104 #define PMCIN_SMP_REQUEST 0x12 105 #define PMCIN_SMP_RESPONSE 0x13 106 #define PMCIN_SMP_ABORT 0x14 107 #define PMCIN_ASSISTED_DISCOVERY 0x15 108 #define PMCIN_REGISTER_DEVICE 0x16 109 #define PMCIN_SATA_HOST_IO_START 0x17 110 #define PMCIN_SATA_ABORT 0x18 111 #define PMCIN_LOCAL_PHY_CONTROL 0x19 112 #define PMCIN_GET_DEVICE_INFO 0x1A 113 #define PMCIN_TWI 0x1B 114 #define PMCIN_FW_FLASH_UPDATE 0x20 115 #define PMCIN_SET_VPD 0x21 116 #define PMCIN_GPIO 0x22 117 #define PMCIN_SAS_DIAG_MODE_START_END 0x23 118 #define PMCIN_SAS_DIAG_EXECUTE 0x24 119 #define PMCIN_SAW_HW_EVENT_ACK 0x25 120 #define PMCIN_GET_TIME_STAMP 0x26 121 #define PMCIN_PORT_CONTROL 0x27 122 #define PMCIN_GET_NVMD_DATA 0x28 123 #define PMCIN_SET_NVMD_DATA 0x29 124 #define PMCIN_SET_DEVICE_STATE 0x2A 125 #define PMCIN_GET_DEVICE_STATE 0x2B 126 127 /* 128 * General Inbound Queue related parameters (DWORD 4) 129 */ 130 #define PMCIN_MESSAGE_REPORT (1 << 2) 131 #define PMCIN_DS_ABORT_TASK (1 << 3) 132 #define PMCIN_DS_IN_RECOVERY (1 << 4) 133 #define PMCIN_DATADIR_NONE (0x00 << 8) 134 #define PMCIN_DATADIR_2_INI (0x01 << 8) 135 #define PMCIN_DATADIR_2_DEV (0x02 << 8) 136 137 138 /* 139 * SATA Host IO Start ATA Protocol Types 140 * (placed into DWORD 4) 141 */ 142 143 #define SATA_PROTOCOL_SRST_ASSERT (0x01 << 10) 144 #define SATA_PROTOCOL_SRT_DEASSERT (0x02 << 10) 145 #define SATA_PROTOCOL_EXECDEVDIAG (0x03 << 10) 146 #define SATA_PROTOCOL_NONDATA (0x04 << 10) 147 #define SATA_PROTOCOL_PIO (0x05 << 10) 148 #define SATA_PROTOCOL_DMA (0x06 << 10) 149 #define SATA_PROTOCOL_FPDMA (0x07 << 10) 150 151 /* 152 * SAS Host IO Start TLR definitions 153 * (placed into DWORD 4) 154 */ 155 #define SAS_TLR_ALL 0 /* SAS 1.1 and SAS 2.0 per device mode page */ 156 #define SAS_TLR_ON 1 /* unconditionally on */ 157 #define SAS_TLR_OFF 2 /* unconditionally off */ 158 #define SAS_TLR_SAS2 3 /* SAS 2.0 per device mode page */ 159 160 /* 161 * IOP SMP Request Information 162 */ 163 #define SMP_INDIRECT_RESPONSE 0x01 164 #define SMP_INDIRECT_REQUEST 0x02 165 #define SMP_PHY_OVERRIDE 0x04 166 #define SMP_REQUEST_LENGTH_SHIFT 16 167 168 /* 169 * PHY Start related definitions 170 */ 171 #define PHY_LINK_1_5 0x01 172 #define PHY_LINK_3 0x02 173 #define PHY_LINK_6 0x04 174 #define PHY_LINK_ALL (PHY_LINK_1_5 | PHY_LINK_3 | PHY_LINK_6) 175 #define PHY_LINK_SHIFT 8 176 177 #define PHY_LM_SAS 1 178 #define PHY_LM_SATA 2 179 #define PHY_LM_AUTO 3 180 #define PHY_MODE_SHIFT 12 181 182 #define PHY_SPINUP_HOLD (1 << 14) 183 184 /* 185 * LOCAL PHY CONTROL related definitions 186 */ 187 188 /* 189 * Device Registration related definitions 190 */ 191 #define PMCS_DEVREG_LINK_RATE_SHIFT 24 192 #define PMCS_DEVREG_TYPE_SATA 0 193 #define PMCS_DEVREG_TYPE_SAS (1 << 28) 194 #define PMCS_DEVREG_TYPE_SATA_DIRECT (1 << 29) 195 196 #define PMCS_PHYID_SHIFT 4 /* level 0 registration only */ 197 #define PMCS_DEVREG_TLR 0x1 /* Transport Layer Retry */ 198 199 #define PMCS_DEVREG_IT_NEXUS_TIMEOUT 200U 200 201 #define PMCS_DEVREG_HA 0x2 /* Host Assigned upper 16 */ 202 /* bits for device ID. */ 203 /* 204 * These are used for getting/setting data in the NVRAM (SEEPROM, VPD, etc.) 205 */ 206 207 typedef struct pmcs_get_nvmd_cmd_s { 208 uint32_t header; /* DWORD 0 */ 209 uint32_t htag; /* DWORD 1 */ 210 uint8_t tdas_nvmd; /* DWORD 2 */ 211 uint8_t tbn_tdps; 212 uint8_t tda; 213 uint8_t ip; 214 uint8_t doa[3]; /* DWORD 3 Data Offset Addr */ 215 uint8_t d_len; /* Direct Pld Data Len */ 216 uint32_t rsvd[8]; /* DWORDS 4-11 */ 217 uint32_t ipbal; /* 12 - Ind Pld buf addr low */ 218 uint32_t ipbah; /* 13 - Ind Pld buf addr high */ 219 uint32_t ipdl; /* 14 - Ind Pld data length */ 220 uint32_t rsvd3; 221 } pmcs_get_nvmd_cmd_t; 222 223 typedef struct pmcs_set_nvmd_cmd_s { 224 uint32_t header; /* DWORD 0 */ 225 uint32_t htag; /* DWORD 1 */ 226 uint8_t tdas_nvmd; /* DWORD 2 */ 227 uint8_t tbn_tdps; 228 uint8_t tda; 229 uint8_t ip; 230 uint8_t doa[3]; /* DWORD 3 Data Offset Addr */ 231 uint8_t d_len; /* Direct Pld Data Len */ 232 uint32_t signature; /* DWORD 4 */ 233 uint32_t rsvd[7]; /* DWORDS 5-11 */ 234 uint32_t ipbal; /* 12 - Ind Pld buf addr low */ 235 uint32_t ipbah; /* 13 - Ind Pld buf addr high */ 236 uint32_t ipdl; /* 14 - Ind Pld data length */ 237 uint32_t rsvd2; 238 } pmcs_set_nvmd_cmd_t; 239 240 #define PMCIN_NVMD_DIRECT_PLD 0x00 241 #define PMCIN_NVMD_INDIRECT_PLD 0x80 242 243 /* TWI bus number is upper 4 bits of tbn_tdps */ 244 #define PMCIN_NVMD_TBN(x) (x << 4) 245 246 /* TWI Device Page Size bits (lower 4 bits of tbn_tdps */ 247 #define PMCIN_NVMD_TDPS_1 0 /* 1 byte */ 248 #define PMCIN_NVMD_TDPS_8 1 /* 8 bytes */ 249 #define PMCIN_NVMD_TDPS_16 2 /* 16 bytes */ 250 #define PMCIN_NVMD_TDPS_32 3 /* 32 bytes */ 251 252 /* TWI Device Address Size (upper 4 bits of tdas_nvmd) */ 253 #define PMCIN_NVMD_TDAS_1 (0 << 4) /* 1 byte */ 254 #define PMCIN_NVMD_TDAS_2 (1 << 4) /* 2 bytes */ 255 256 /* 257 * TWI Device Address 258 * The address used to access TWI device for the 2Kb SEEPROM device is 259 * arranged as follows: 260 * Bits 7-4 are fixed (0xA) 261 * Bits 3-1 are page numbers for each 256 byte page 262 * Bit 0: Set to "1" to read, "0" to write 263 * Bit 0 is set/reset by the firmware based on whether the command is a 264 * SET or a GET. 265 */ 266 #define PMCIN_TDA_BASE 0xA0 267 #define PMCIN_TDA_PAGE(x) (PMCIN_TDA_BASE | (x << 1)) 268 269 /* NVM Device bits (lower 4 bits of tdas_nvmd) */ 270 #define PMCIN_NVMD_TWI 0 /* TWI Device */ 271 #define PMCIN_NVMD_SEEPROM 1 /* SEEPROM Device */ 272 #define PMCIN_NVMD_VPD 4 /* VPD Flash Memory */ 273 #define PMCIN_NVMD_AAP1 5 /* AAP1 Register Dump */ 274 #define PMCIN_NVMD_IOP 6 /* IOP Register Dump */ 275 276 #define PMCS_SEEPROM_PAGE_SIZE 256 277 278 /* 279 * Minimum and maximum sizes of SPCBoot image 280 */ 281 #define PMCS_SPCBOOT_MIN_SIZE 64 282 #define PMCS_SPCBOOT_MAX_SIZE 512 283 284 #define PMCS_SEEPROM_SIGNATURE 0xFEDCBA98 285 286 /* 287 * Register dump information 288 * 289 * There are two 16KB regions for register dump information 290 */ 291 292 #define PMCS_REGISTER_DUMP_FLASH_SIZE (1024 * 16) 293 #define PMCS_REGISTER_DUMP_BLOCK_SIZE 4096 /* Must be read 4K at a time */ 294 #define PMCS_FLASH_CHUNK_SIZE 4096 /* Must be read 4K at a time */ 295 #define PMCS_REG_DUMP_SIZE (1024 * 1024 * 12) 296 #define PMCS_NVMD_EVENT_LOG_OFFSET 0x10000 297 #define PMCS_IQP_TRACE_BUFFER_SIZE (1024 * 512) 298 299 /* 300 * The list of items we can retrieve via the GET_NVMD_DATA command 301 */ 302 303 typedef enum { 304 PMCS_NVMD_VPD = 0, 305 PMCS_NVMD_REG_DUMP, 306 PMCS_NVMD_EVENT_LOG, 307 PMCS_NVMD_SPCBOOT 308 } pmcs_nvmd_type_t; 309 310 /* 311 * Command types, descriptors and offsets for SAS_DIAG_EXECUTE. 312 */ 313 #define PMCS_DIAG_CMD_DESC_SHIFT 8 314 #define PMCS_DIAG_CMD_SHIFT 13 315 #define PMCS_DIAG_REPORT_GET 0x04 /* Get counters */ 316 #define PMCS_ERR_CNT_RESET 0x05 /* Clear counters */ 317 #define PMCS_DISPARITY_ERR_CNT 0x02 /* Disparity error count */ 318 #define PMCS_LOST_DWORD_SYNC_CNT 0x05 /* Lost DWord sync count */ 319 #define PMCS_INVALID_DWORD_CNT 0x06 /* Invalid DWord count */ 320 #define PMCS_RESET_FAILED_CNT 0x0C /* PHY reset failed count */ 321 322 /* 323 * VPD data layout 324 */ 325 326 #define PMCS_VPD_DATA_PAGE 2 /* VPD starts at offset 512 */ 327 #define PMCS_VPD_VERSION 2 /* Expected version number */ 328 #define PMCS_VPD_RO_BYTE 0x90 /* Start of "read-only" data */ 329 #define PMCS_VPD_START 0x82 /* VPD start byte */ 330 #define PMCS_VPD_END 0x78 /* VPD end byte */ 331 332 /* 333 * This structure defines the "header" for the VPD data. Everything 334 * following this structure is self-defining. The consumer just needs 335 * to allocate a buffer large enough for vpd_length + 3 bytes of data. 336 */ 337 338 typedef struct { 339 uint8_t eeprom_version; 340 uint8_t vpd_length[2]; /* # bytes that follow, little-endian */ 341 uint8_t hba_sas_wwid[8]; 342 uint8_t subsys_pid[2]; 343 uint8_t subsys_vid[2]; 344 uint8_t vpd_start_byte; /* 0x82 */ 345 uint8_t strid_length[2]; /* little-endian */ 346 /* strid_length bytes follow */ 347 } pmcs_vpd_header_t; 348 349 typedef struct { 350 char keyword[2]; 351 uint8_t value_length; 352 char value[1]; /* Length is actually value_length */ 353 } pmcs_vpd_kv_t; 354 355 /* 356 * From here on out are definitions related to Outbound Queues 357 * (completions of Inbound Queue requests and async events) 358 */ 359 360 /* 361 * PMC IOMB Outbound Queue Opcodes 362 */ 363 #define PMCOUT_ECHO 0x01 364 #define PMCOUT_GET_INFO 0x02 365 #define PMCOUT_GET_VPD 0x03 366 #define PMCOUT_SAS_HW_EVENT 0x04 367 #define PMCOUT_SSP_COMPLETION 0x05 368 #define PMCOUT_SMP_COMPLETION 0x06 369 #define PMCOUT_LOCAL_PHY_CONTROL 0x07 370 #define PMCOUT_SAS_ASSISTED_DISCOVERY_EVENT 0x08 371 #define PMCOUT_SATA_ASSISTED_DISCOVERY_EVENT 0x09 372 #define PMCOUT_DEVICE_REGISTRATION 0x0A 373 #define PMCOUT_DEREGISTER_DEVICE_HANDLE 0x0B 374 #define PMCOUT_GET_DEVICE_HANDLE 0x0C 375 #define PMCOUT_SATA_COMPLETION 0x0D 376 #define PMCOUT_SATA_EVENT 0x0E 377 #define PMCOUT_SSP_EVENT 0x0F 378 #define PMCOUT_DEVICE_HANDLE_ARRIVED 0x10 379 #define PMCOUT_SMP_REQUEST_RECEIVED 0x11 380 #define PMCOUT_SSP_REQUEST_RECEIVED 0x12 381 #define PMCOUT_DEVICE_INFO 0x13 382 #define PMCOUT_FW_FLASH_UPDATE 0x14 383 #define PMCOUT_SET_VPD 0x15 384 #define PMCOUT_GPIO 0x16 385 #define PMCOUT_GPIO_EVENT 0x17 386 #define PMCOUT_GENERAL_EVENT 0x18 387 #define PMCOUT_TWI 0x19 388 #define PMCOUT_SSP_ABORT 0x1A 389 #define PMCOUT_SATA_ABORT 0x1B 390 #define PMCOUT_SAS_DIAG_MODE_START_END 0x1C 391 #define PMCOUT_SAS_DIAG_EXECUTE 0x1D 392 #define PMCOUT_GET_TIME_STAMP 0x1E 393 #define PMCOUT_SAS_HW_EVENT_ACK_ACK 0x1F 394 #define PMCOUT_PORT_CONTROL 0x20 395 #define PMCOUT_SKIP_ENTRIES 0x21 396 #define PMCOUT_SMP_ABORT 0x22 397 #define PMCOUT_GET_NVMD_DATA 0x23 398 #define PMCOUT_SET_NVMD_DATA 0x24 399 #define PMCOUT_DEVICE_HANDLE_REMOVED 0x25 400 #define PMCOUT_SET_DEVICE_STATE 0x26 401 #define PMCOUT_GET_DEVICE_STATE 0x27 402 #define PMCOUT_SET_DEVICE_INFO 0x28 403 404 /* 405 * General Outbound Status Definitions 406 */ 407 #define PMCOUT_STATUS_OK 0x00 408 #define PMCOUT_STATUS_ABORTED 0x01 409 #define PMCOUT_STATUS_OVERFLOW 0x02 410 #define PMCOUT_STATUS_UNDERFLOW 0x03 411 #define PMCOUT_STATUS_FAILED 0x04 412 #define PMCOUT_STATUS_ABORT_RESET 0x05 413 #define PMCOUT_STATUS_IO_NOT_VALID 0x06 414 #define PMCOUT_STATUS_NO_DEVICE 0x07 415 #define PMCOUT_STATUS_ILLEGAL_PARAMETER 0x08 416 #define PMCOUT_STATUS_LINK_FAILURE 0x09 417 #define PMCOUT_STATUS_PROG_ERROR 0x0A 418 #define PMCOUT_STATUS_EDC_IN_ERROR 0x0B 419 #define PMCOUT_STATUS_EDC_OUT_ERROR 0x0C 420 #define PMCOUT_STATUS_ERROR_HW_TIMEOUT 0x0D 421 #define PMCOUT_STATUS_XFER_ERR_BREAK 0x0E 422 #define PMCOUT_STATUS_XFER_ERR_PHY_NOT_READY 0x0F 423 #define PMCOUT_STATUS_OPEN_CNX_PROTOCOL_NOT_SUPPORTED 0x10 424 #define PMCOUT_STATUS_OPEN_CNX_ERROR_ZONE_VIOLATION 0x11 425 #define PMCOUT_STATUS_OPEN_CNX_ERROR_BREAK 0x12 426 #define PMCOUT_STATUS_OPEN_CNX_ERROR_IT_NEXUS_LOSS 0x13 427 #define PMCOUT_STATUS_OPENCNX_ERROR_BAD_DESTINATION 0x14 428 #define PMCOUT_STATUS_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED 0x15 429 #define PMCOUT_STATUS_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 0x16 430 #define PMCOUT_STATUS_OPEN_CNX_ERROR_WRONG_DESTINATION 0x17 431 #define PMCOUT_STATUS_OPEN_CNX_ERROR_UNKNOWN_EROOR 0x18 432 #define PMCOUT_STATUS_IO_XFER_ERROR_NAK_RECEIVED 0x19 433 #define PMCOUT_STATUS_XFER_ERROR_ACK_NAK_TIMEOUT 0x1A 434 #define PMCOUT_STATUS_XFER_ERROR_PEER_ABORTED 0x1B 435 #define PMCOUT_STATUS_XFER_ERROR_RX_FRAME 0x1C 436 #define PMCOUT_STATUS_IO_XFER_ERROR_DMA 0x1D 437 #define PMCOUT_STATUS_XFER_ERROR_CREDIT_TIMEOUT 0x1E 438 #define PMCOUT_STATUS_XFER_ERROR_SATA_LINK_TIMEOUT 0x1F 439 #define PMCOUT_STATUS_XFER_ERROR_SATA 0x20 440 #define PMCOUT_STATUS_XFER_ERROR_REJECTED_NCQ_MODE 0x21 441 #define PMCOUT_STATUS_XFER_ERROR_ABORTED_DUE_TO_SRST 0x22 442 #define PMCOUT_STATUS_XFER_ERROR_ABORTED_NCQ_MODE 0x23 443 #define PMCOUT_STATUS_IO_XFER_OPEN_RETRY_TIMEOUT 0x24 444 #define PMCOUT_STATUS_SMP_RESP_CONNECTION_ERROR 0x25 445 #define PMCOUT_STATUS_XFER_ERROR_UNEXPECTED_PHASE 0x26 446 #define PMCOUT_STATUS_XFER_ERROR_RDY_OVERRUN 0x27 447 #define PMCOUT_STATUS_XFER_ERROR_RDY_NOT_EXPECTED 0x28 448 /* 0x29 */ 449 /* 0x2A */ 450 /* 0x2B */ 451 /* 0x2C */ 452 /* 0x2D */ 453 /* 0x2E */ 454 /* 0x2F */ 455 #define PMCOUT_STATUS_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT 0x30 456 #define PMCOUT_STATUS_XFER_ERROR_CMD_ISSUE_BREAK_BEFORE_ACK_NACK 0x31 457 #define PMCOUT_STATUS_XFER_ERROR_CMD_ISSUE_PHY_DOWN_BEFORE_ACK_NAK 0x32 458 /* 0x33 */ 459 #define PMCOUT_STATUS_XFER_ERROR_OFFSET_MISMATCH 0x34 460 #define PMCOUT_STATUS_XFER_ERROR_ZERO_DATA_LEN 0x35 461 #define PMCOUT_STATUS_XFER_CMD_FRAME_ISSUED 0x36 462 #define PMCOUT_STATUS_ERROR_INTERNAL_SMP_RESOURCE 0x37 463 #define PMCOUT_STATUS_IO_PORT_IN_RESET 0x38 464 #define PMCOUT_STATUS_IO_DS_NON_OPERATIONAL 0x39 465 #define PMCOUT_STATUS_IO_DS_IN_RECOVERY 0x3A 466 #define PMCOUT_STATUS_IO_ABORT_IN_PROGRESS 0x40 467 468 /* 469 * Device State definitions 470 */ 471 #define PMCS_DEVICE_STATE_NOT_AVAILABLE 0x0 /* Unconfigured tgt */ 472 #define PMCS_DEVICE_STATE_OPERATIONAL 0x1 473 #define PMCS_DEVICE_STATE_PORT_IN_RESET 0x2 474 #define PMCS_DEVICE_STATE_IN_RECOVERY 0x3 475 #define PMCS_DEVICE_STATE_IN_ERROR 0x4 476 #define PMCS_DEVICE_STATE_NON_OPERATIONAL 0x7 477 478 /* 479 * Reset Types 480 */ 481 #define PMCS_SSP_LINK_RESET 0x1 482 #define PMCS_SSP_HARD_RESET 0x2 483 #define PMCS_SMP_HARD_RESET 0x3 484 485 /* 486 * PHYOP for LOCAL_PHY_CONTROL Command 487 */ 488 #define PMCS_PHYOP_LINK_RESET 0x01 489 #define PMCS_PHYOP_HARD_RESET 0x02 490 491 /* 492 * Specialized status values 493 */ 494 /* PHY Stop Status Results */ 495 #define IOP_PHY_STOP_OK 0x0 496 #define IOP_PHY_STOP_INVALID 0x1 497 #define IOP_PHY_STOP_ERROR 0x3 498 #define IOP_PHY_STOP_ALREADY 0x4 499 500 /* PHY Start Status Results */ 501 #define IOP_PHY_START_OK 0 502 #define IOP_PHY_START_INVALID 1 503 #define IOP_PHY_START_ALREADY 2 504 #define IOP_PHY_START_ERROR 3 505 506 /* SET/GET_NVMD status results */ 507 #define PMCS_NVMD_STAT_SUCCESS 0x0000 508 #define PMCS_NVMD_STAT_PLD_NVMD_COMB_ERR 0x0001 509 #define PMCS_NVMD_STAT_PLD_LEN_ERR 0x0002 510 #define PMCS_NVMD_STAT_TWI_DEV_NACK 0x2001 511 #define PMCS_NVMD_STAT_TWI_DEV_LOST_ARB 0x2002 512 #define PMCS_NVMD_STAT_TWI_TIMEOUT 0x2021 513 #define PMCS_NVMD_STAT_TWI_BUS_NACK 0x2081 514 #define PMCS_NVMD_STAT_TWI_DEV_ARB_FAIL 0x2082 515 #define PMCS_NVMD_STAT_TWI_BUS_SER_TIMEO 0x20FF 516 #define PMCS_NVMD_STAT_PART_NOT_IN_FLASH 0x9001 517 #define PMCS_NVMD_STAT_LEN_TOO_LARGE 0x9002 518 #define PMCS_NVMD_STAT_FLASH_PRGRM_FAIL 0x9003 519 #define PMCS_NVMD_STAT_DEVID_MATCH_FAIL 0x9004 520 #define PMCS_NVMD_STAT_VENDID_MATCH_FAIL 0x9005 521 #define PMCS_NVMD_STAT_SEC_ERASE_TIMEO 0x9006 522 #define PMCS_NVMD_STAT_SEC_ERASE_CWE 0x9007 523 #define PMCS_NVMD_STAT_FLASH_DEV_BUSY 0x9008 524 #define PMCS_NVMD_STAT_FLASH_DEV_NOT_SUP 0x9009 525 #define PMCS_NVMD_STAT_FLASH_NO_CFI 0x900A 526 #define PMCS_NVMD_STAT_ERASE_BLOCKS 0x900B 527 #define PMCS_NVMD_STAT_PART_READ_ONLY 0x900C 528 #define PMCS_NVMD_STAT_PART_INV_MAP_TYPE 0x900D 529 #define PMCS_NVMD_STAT_PART_INIT_STR_DIS 0x900E 530 531 /* 532 * General Event Status Codes 533 */ 534 #define INBOUND_IOMB_V_BIT_NOT_SET 0x1 535 #define INBOUND_IOMB_OPC_NOT_SUPPORTED 0x2 536 537 /* Device Register Status Results */ 538 #define PMCS_DEVREG_OK 0x0 539 #define PMCS_DEVREG_DEVICE_ALREADY_REGISTERED 0x2 540 #define PMCS_DEVREG_PHY_ALREADY_REGISTERED 0x4 541 542 /* 543 * Flash Update responses 544 */ 545 #define FLASH_UPDATE_COMPLETE_PENDING_REBOOT 0x0 546 #define FLASH_UPDATE_IN_PROGRESS 0x1 547 #define FLASH_UPDATE_HDR_ERR 0x2 548 #define FLASH_UPDATE_OFFSET_ERR 0x3 549 #define FLASH_UPDATE_UPDATE_CRC_ERR 0x4 550 #define FLASH_UPDATE_LENGTH_ERR 0x5 551 #define FLASH_UPDATE_HW_ERR 0x6 552 #define FLASH_UPDATE_DNLD_NOT_SUPPORTED 0x10 553 #define FLASH_UPDATE_DISABLED 0x11 554 555 /* 556 * IOP SAS HW Event Related definitions 557 */ 558 559 #define IOP_EVENT_LINK_RATE(x) ((x >> 28) & 0xf) 560 #define IOP_EVENT_STATUS(x) ((x >> 24) & 0xf) 561 #define IOP_EVENT_EVENT(x) ((x >> 8) & 0xffff) 562 #define IOP_EVENT_PHYNUM(x) ((x >> 4) & 0xf) 563 #define IOP_EVENT_PORTID(x) ((x) & 0xf) 564 565 566 #define IOP_EVENT_PHY_STOP_STATUS 0x03 567 #define IOP_EVENT_SAS_PHY_UP 0x04 568 #define IOP_EVENT_SATA_PHY_UP 0x05 569 #define IOP_EVENT_SATA_SPINUP_HOLD 0x06 570 #define IOP_EVENT_PHY_DOWN 0x07 571 #define IOP_EVENT_PORT_INVALID 0x08 /* < fw 1.6 */ 572 #define IOP_EVENT_BROADCAST_CHANGE 0x09 573 #define IOP_EVENT_BROADCAST_SES 0x0B 574 #define IOP_EVENT_PHY_ERR_INBOUND_CRC 0x0C 575 #define IOP_EVENT_HARD_RESET_RECEIVED 0x0D 576 #define IOP_EVENT_EVENT_ID_FRAME_TIMO 0x0F 577 #define IOP_EVENT_BROADCAST_EXP 0x10 578 #define IOP_EVENT_PHY_START_STATUS 0x11 579 #define IOP_EVENT_PHY_ERR_INVALID_DWORD 0x12 580 #define IOP_EVENT_PHY_ERR_DISPARITY_ERROR 0x13 581 #define IOP_EVENT_PHY_ERR_CODE_VIOLATION 0x14 582 #define IOP_EVENT_PHY_ERR_LOSS_OF_DWORD_SYN 0x15 583 #define IOP_EVENT_PHY_ERR_PHY_RESET_FAILD 0x16 584 #define IOP_EVENT_PORT_RECOVERY_TIMER_TMO 0x17 585 #define IOP_EVENT_PORT_RECOVER 0x18 586 #define IOP_EVENT_PORT_RESET_TIMER_TMO 0x19 587 #define IOP_EVENT_PORT_RESET_COMPLETE 0x20 588 #define IOP_EVENT_BROADCAST_ASYNC_EVENT 0x21 589 590 591 #define IOP_EVENT_PORT_STATE(x) ((x) & 0xf) 592 #define IOP_EVENT_NPIP(x) (((x) >> 4) & 0xf) 593 594 #define IOP_EVENT_PS_NIL 0x0 /* PORT_ID not valid yet */ 595 #define IOP_EVENT_PS_VALID 0x1 /* PORT_ID now valid */ 596 #define IOP_EVENT_PS_LOSTCOMM 0x2 /* Link temporarily down */ 597 #define IOP_EVENT_PS_IN_RESET 0x4 /* Port in reset */ 598 #define IOP_EVENT_PS_INVALID 0x8 /* PORT_ID now dead */ 599 600 /* 601 * HW Event Acknowledge Response Values 602 */ 603 #define SAS_HW_EVENT_ACK_OK 0x0 604 #define SAS_HW_EVENT_ACK_INVALID_SEA 0x1 605 #define SAS_HW_EVENT_ACK_INVALID_PHY 0x2 606 #define SAS_HW_EVENT_ACK_INVALID_PORT 0x4 607 #define SAS_HW_EVENT_ACK_INVALID_PARAM 0x8 608 609 /* 610 * IOMB Queue definitions and Macros 611 */ 612 613 #define ADDQI(ix, n, qd) ((ix + n) & (qd - 1)) 614 #define INCQI(ix, qd) ix = ADDQI(ix, 1, qd) 615 #define QI2O(ix, n, qd) (ADDQI(ix, n, qd) * PMCS_QENTRY_SIZE) 616 617 /* 618 * Inbound Queue Producer Indices live inside the PMC card. 619 * 620 * Inbound Queue Consumer indices live in host memory. We use the Consumer 621 * Index to return a pointer to an Inbound Queue entry. We then can fill 622 * it with an IOMB. We then update the the Producer index which kicks 623 * card to read the IOMB we just wrote. 624 * 625 * There is one mutex for each inbound queue that is held from the time 626 * we get an entry until we increment the producer index, or released 627 * manually if we don't actually send the message. 628 */ 629 630 /* 631 * NB: the appropriate iqp_lock must be held 632 */ 633 #define GET_IQ_ENTRY(hwp, qnum) \ 634 ((ADDQI(hwp->shadow_iqpi[qnum], 1, hwp->ioq_depth) == \ 635 pmcs_rd_iqci(hwp, qnum)) ? NULL : \ 636 &hwp->iqp[qnum][hwp->shadow_iqpi[qnum] * (PMCS_QENTRY_SIZE >> 2)]) 637 638 /* 639 * NB: This releases the lock on the Inbound Queue that GET_IO_IQ_ENTRY 640 * acquired below. 641 */ 642 #ifdef DEBUG 643 #define INC_IQ_ENTRY(hwp, qnum) \ 644 { \ 645 uint32_t htag; \ 646 ASSERT(mutex_owned(&(hwp)->iqp_lock[qnum])); \ 647 htag = hwp->iqp[qnum][(hwp->shadow_iqpi[qnum] * \ 648 (PMCS_QENTRY_SIZE >> 2)) + 1]; \ 649 mutex_enter(&(hwp)->dbglock); \ 650 pmcs_iqp_trace(hwp, qnum); \ 651 mutex_exit(&(hwp)->dbglock); \ 652 INCQI(hwp->shadow_iqpi[qnum], hwp->ioq_depth); \ 653 if (ddi_dma_sync(hwp->cip_handles, 0, 0, \ 654 DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) { \ 655 pmcs_prt(hwp, PMCS_PRT_DEBUG, NULL, NULL, "Condition " \ 656 "failed at %s():%d", __func__, __LINE__); \ 657 } \ 658 hwp->ftime[hwp->fti] = gethrtime(); \ 659 pmcs_wr_iqpi(hwp, qnum, hwp->shadow_iqpi[qnum]); \ 660 mutex_exit(&(hwp)->iqp_lock[qnum]); \ 661 mutex_enter(&(hwp)->dbglock); \ 662 hwp->ftag_lines[hwp->fti] = __LINE__; \ 663 hwp->ftags[hwp->fti++] = htag; \ 664 mutex_exit(&(hwp)->dbglock); \ 665 } 666 #else 667 #define INC_IQ_ENTRY(hwp, qnum) \ 668 INCQI(hwp->shadow_iqpi[qnum], hwp->ioq_depth); \ 669 if (ddi_dma_sync(hwp->cip_handles, 0, 0, \ 670 DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) { \ 671 pmcs_prt(hwp, PMCS_PRT_DEBUG, NULL, NULL, "Condition " \ 672 "failed at %s():%d", __func__, __LINE__); \ 673 } \ 674 pmcs_wr_iqpi(hwp, qnum, hwp->shadow_iqpi[qnum]); \ 675 mutex_exit(&(hwp)->iqp_lock[qnum]) 676 #endif 677 678 679 /* 680 * NB: sucessfull acquisition of an IO Inbound Queue 681 * entry leaves the lock on that Inbound Queue held. 682 */ 683 #define GET_IO_IQ_ENTRY(pwp, msg, did, iq) \ 684 iq = did & PMCS_IO_IQ_MASK; \ 685 mutex_enter(&(pwp)->iqp_lock[iq]); \ 686 msg = GET_IQ_ENTRY(pwp, iq); \ 687 if (msg == NULL) { \ 688 mutex_exit(&(pwp)->iqp_lock[iq]); \ 689 for (iq = 0; iq <= PMCS_NON_HIPRI_QUEUES; iq++) { \ 690 mutex_enter(&(pwp)->iqp_lock[iq]); \ 691 msg = GET_IQ_ENTRY(pwp, iq); \ 692 if (msg) { \ 693 break; \ 694 } \ 695 mutex_exit(&(pwp->iqp_lock[iq])); \ 696 } \ 697 } 698 699 /* 700 * Outbound Queue Macros 701 * 702 * Outbound Queue Consumer indices live inside the card. 703 * 704 * Outbound Queue Producer indices live in host memory. When the card 705 * wants to send an IOMB, it uses the producer index to find the spot 706 * to write the IOMB. After it's done it updates the producer index 707 * and interrupts the host. The host reads the producer index (from 708 * host memory) and reads IOMBs up to but not including that index. 709 * It writes that index back to the consumer index on the card, 710 * signifying that it has read up to that which the card has sent. 711 */ 712 #define GET_OQ_ENTRY(hwp, qn, ix, o) \ 713 &hwp->oqp[qn][QI2O(ix, o, hwp->ioq_depth) >> 2] 714 715 #define STEP_OQ_ENTRY(hwp, qn, ix, n) ix = ADDQI(ix, n, hwp->ioq_depth) 716 717 #define SYNC_OQ_ENTRY(hwp, qn, ci, pi) \ 718 pmcs_wr_oqci(hwp, qn, ci); \ 719 (hwp)->oqci[qn] = ci; \ 720 (hwp)->oqpi[qn] = pi 721 722 #ifdef __cplusplus 723 } 724 #endif 725 #endif /* _PMCS_IOMB_H */ 726