1936b7af6Sjw /* 2936b7af6Sjw * CDDL HEADER START 3936b7af6Sjw * 4936b7af6Sjw * The contents of this file are subject to the terms of the 5936b7af6Sjw * Common Development and Distribution License (the "License"). 6936b7af6Sjw * You may not use this file except in compliance with the License. 7936b7af6Sjw * 8936b7af6Sjw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9936b7af6Sjw * or http://www.opensolaris.org/os/licensing. 10936b7af6Sjw * See the License for the specific language governing permissions 11936b7af6Sjw * and limitations under the License. 12936b7af6Sjw * 13936b7af6Sjw * When distributing Covered Code, include this CDDL HEADER in each 14936b7af6Sjw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15936b7af6Sjw * If applicable, add the following below this CDDL HEADER, with the 16936b7af6Sjw * fields enclosed by brackets "[]" replaced with your own identifying 17936b7af6Sjw * information: Portions Copyright [yyyy] [name of copyright owner] 18936b7af6Sjw * 19936b7af6Sjw * CDDL HEADER END 20936b7af6Sjw */ 21936b7af6Sjw /* 22658280b6SDavid Hollister * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 23936b7af6Sjw */ 24936b7af6Sjw 2596c4a178SChris Horne #ifndef _SYS_SCSI_IMPL_SCSI_SAS_H 2696c4a178SChris Horne #define _SYS_SCSI_IMPL_SCSI_SAS_H 27936b7af6Sjw 28936b7af6Sjw #include <sys/types.h> 29936b7af6Sjw #include <sys/scsi/impl/usmp.h> 30936b7af6Sjw 31936b7af6Sjw #ifdef __cplusplus 32936b7af6Sjw extern "C" { 33936b7af6Sjw #endif 34936b7af6Sjw 35936b7af6Sjw #if defined(_KERNEL) 364c06356bSdh /* 374c06356bSdh * Phymap support 384c06356bSdh */ 394c06356bSdh typedef struct __sas_phymap sas_phymap_t; 404c06356bSdh typedef enum { PHYMAP_MODE_SIMPLE } sas_phymap_mode_t; 414c06356bSdh typedef void (*sas_phymap_activate_cb_t) 424c06356bSdh (void *phymap_priv, char *ua, void **ua_privp); 434c06356bSdh typedef void (*sas_phymap_deactivate_cb_t) 444c06356bSdh (void *phymap_priv, char *ua, void *ua_priv); 454c06356bSdh 464c06356bSdh extern int sas_phymap_create(dev_info_t *hba_dip, 47*60aabb4cSChris Horne int settle_usec, 484c06356bSdh sas_phymap_mode_t mode, 494c06356bSdh void *mode_argument, 504c06356bSdh void *phymap_priv, 514c06356bSdh sas_phymap_activate_cb_t activate_cb, 524c06356bSdh sas_phymap_deactivate_cb_t deactivate_cb, 534c06356bSdh sas_phymap_t **phymapp); 544c06356bSdh void sas_phymap_destroy(sas_phymap_t *phymap); 554c06356bSdh 564c06356bSdh extern int sas_phymap_phy_add(sas_phymap_t *phymap, 574c06356bSdh int phy, 584c06356bSdh uint64_t local_sas_address, 594c06356bSdh uint64_t remote_sas_address); 604c06356bSdh extern int sas_phymap_phy_rem(sas_phymap_t *phymap, 614c06356bSdh int phy); 624c06356bSdh 634c06356bSdh extern char *sas_phymap_lookup_ua(sas_phymap_t *phymap, 644c06356bSdh uint64_t local_sas_address, 654c06356bSdh uint64_t remote_sas_address); 664c06356bSdh extern void *sas_phymap_lookup_uapriv(sas_phymap_t *phymap, 674c06356bSdh char *ua); 684c06356bSdh 6996c4a178SChris Horne extern char *sas_phymap_phy2ua(sas_phymap_t *phymap, 7096c4a178SChris Horne int phy); 7196c4a178SChris Horne void sas_phymap_ua_free(char *); 7296c4a178SChris Horne 734c06356bSdh extern int sas_phymap_uahasphys(sas_phymap_t *phymap, 744c06356bSdh char *ua); 754c06356bSdh 764c06356bSdh typedef struct __sas_phymap_phys sas_phymap_phys_t; 7796c4a178SChris Horne extern sas_phymap_phys_t *sas_phymap_ua2phys(sas_phymap_t *phymap, 7896c4a178SChris Horne char *ua); 7996c4a178SChris Horne extern int sas_phymap_phys_next(sas_phymap_phys_t *phys); 8096c4a178SChris Horne void sas_phymap_phys_free(sas_phymap_phys_t *phys); 81936b7af6Sjw #endif /* defined(_KERNEL) */ 82936b7af6Sjw 83936b7af6Sjw 844c06356bSdh 8596c4a178SChris Horne #define KSTAT_SAS_PHY_CLASS "SAS_phy_stat" 864c06356bSdh /* 874c06356bSdh * Format of the ks_name field for SAS Phy Stat 884c06356bSdh * 894c06356bSdh * driver_name.initiator_port_SAS_address.initiator_port_instance_number.phyid 904c06356bSdh * Example: pmcs.5000c50000d756aa.2.0 914c06356bSdh * 924c06356bSdh * driver_name: 934c06356bSdh * driver name from di_driver_name() on SAS initiator port devinfo node. 9496c4a178SChris Horne * 954c06356bSdh * initiator_port_SAS_address: 964c06356bSdh * SAS address of the initiator port that phy stat is reported for. 9796c4a178SChris Horne * 984c06356bSdh * initiator_port_instance_number: 994c06356bSdh * instance number of the initiator port that phy stat is reported for. 10096c4a178SChris Horne * 1014c06356bSdh * phyid: 1024c06356bSdh * prop phyIdentifier under initiator port node. 1034c06356bSdh */ 1044c06356bSdh 1054c06356bSdh /* Port Protocol - kstat structure definition */ 1064c06356bSdh typedef struct sas_port_protocol_stats { 1074c06356bSdh kstat_named_t seconds_since_last_reset; 1084c06356bSdh kstat_named_t input_requests; 1094c06356bSdh kstat_named_t output_requests; 1104c06356bSdh kstat_named_t control_requests; 1114c06356bSdh kstat_named_t input_megabytes; 1124c06356bSdh kstat_named_t output_megabytes; 1134c06356bSdh } sas_port_protocol_stats_t; 1144c06356bSdh 1154c06356bSdh /* Port - kstat structure definition */ 1164c06356bSdh typedef struct sas_port_stats { 1174c06356bSdh kstat_named_t seconds_since_last_reset; 1184c06356bSdh kstat_named_t tx_frames; 1194c06356bSdh kstat_named_t tx_words; 1204c06356bSdh kstat_named_t rx_frames; 1214c06356bSdh kstat_named_t rx_words; 1224c06356bSdh } sas_port_stats_t; 1234c06356bSdh 1244c06356bSdh /* PHY - kstat structure definition */ 1254c06356bSdh typedef struct sas_phy_stats { 1264c06356bSdh kstat_named_t seconds_since_last_reset; 1274c06356bSdh kstat_named_t tx_frames; 1284c06356bSdh kstat_named_t tx_words; 1294c06356bSdh kstat_named_t rx_frames; 1304c06356bSdh kstat_named_t rx_words; 1314c06356bSdh kstat_named_t invalid_dword_count; 1324c06356bSdh kstat_named_t running_disparity_error_count; 1334c06356bSdh kstat_named_t loss_of_dword_sync_count; 1344c06356bSdh kstat_named_t phy_reset_problem_count; 1354c06356bSdh } sas_phy_stats_t; 1364c06356bSdh 1374c06356bSdh /* 1384c06356bSdh * Supported Protocol property 1394c06356bSdh */ 1404c06356bSdh #define SAS_PROTOCOL_SSP 0x00000001 1414c06356bSdh #define SAS_PROTOCOL_STP 0x00000010 1424c06356bSdh #define SAS_PROTOCOL_SMP 0x00000100 1434c06356bSdh #define SAS_PROTOCOL_SATA 0x00001000 1444c06356bSdh 1454c06356bSdh 1464c06356bSdh /* 1474c06356bSdh * Definition - Negotiated Physical Link Rate 1484c06356bSdh * Based on Table 288 (Section 10.4.3.10) of the spec (SAS-2 r-15), these 1494c06356bSdh * constants represent "Negotiated physical link rate" 1504c06356bSdh * (and implicitly the State of the phy). 1514c06356bSdh */ 1524c06356bSdh #define SAS_LINK_RATE_UNKNOWN 0x0 /* Phy is enabled. */ 1534c06356bSdh /* Speed is unknown */ 1544c06356bSdh #define SAS_LINK_RATE_DISABLED 0x1 /* Phy is disabled. */ 1554c06356bSdh /* Speed is undefined */ 1564c06356bSdh #define SAS_LINK_RATE_FAILED 0x2 /* Phy is enabled. */ 1574c06356bSdh /* Failed speed negotiation. */ 1584c06356bSdh #define SAS_LINK_RATE_SATASPINUP 0x3 /* Phy is enabled. */ 1594c06356bSdh /* Detected a SATA device and */ 1604c06356bSdh /* entered the SATA Spinup hold */ 1614c06356bSdh /* state */ 1624c06356bSdh #define SAS_LINK_RATE_SATAPORTSEL 0x4 /* Phy enabled. */ 1634c06356bSdh /* The phy is attached to a */ 1644c06356bSdh /* Port Selector (SATA-2.6). */ 1654c06356bSdh #define SAS_LINK_RATE_RESET_IN_PROGRESS 0x5 /* Phy is enabled. */ 1664c06356bSdh /* Expander is performing SMP */ 1674c06356bSdh /* PHY CONTROL Link/Hard Reset */ 1684c06356bSdh #define SAS_LINK_RATE_PHY_UNSUPPORTED 0x6 /* Phy is enabled. */ 1694c06356bSdh /* Unsupported phy settings */ 1704c06356bSdh #define SAS_LINK_RATE_RESERVED 0x7 /* Undefined. Reserved. */ 1714c06356bSdh #define SAS_LINK_RATE_1_5GBIT 0x8 /* Phy enabled at 1.5 GBit/sec */ 1724c06356bSdh #define SAS_LINK_RATE_3GBIT 0x9 /* Phy enabled at 3 GBit/sec */ 1734c06356bSdh #define SAS_LINK_RATE_6GBIT 0xA /* Phy enabled at 6 GBit/sec. */ 1744c06356bSdh 1754c06356bSdh 1764c06356bSdh /* 1774c06356bSdh * Definition - "phy-info" property 1784c06356bSdh * 1794c06356bSdh * The property is an nvlist_array that represents an array of the 1804c06356bSdh * nvlists on a per HBA basis. The individual elements of the array 1814c06356bSdh * (the nvlists) represent the following properties for each phy of the HBA 1824c06356bSdh */ 1834c06356bSdh #define SAS_PHY_INFO "phy-info" /* Phy property name */ 1844c06356bSdh #define SAS_PHY_INFO_NVL "phy-info-nvl" /* NVL array name */ 1854c06356bSdh 1864c06356bSdh #define SAS_PHY_ID "PhyIdentifier" /* DATA_TYPE_UINT8 */ 1874c06356bSdh #define SAS_NEG_LINK_RATE "NegotiatedLinkRate" /* DATA_TYPE_INT8 */ 1884c06356bSdh #define SAS_PROG_MIN_LINK_RATE "ProgrammedMinLinkRate" /* DATA_TYPE_INT8 */ 1894c06356bSdh #define SAS_HW_MIN_LINK_RATE "HardwareMinLinkRate" /* DATA_TYPE_INT8 */ 1904c06356bSdh #define SAS_PROG_MAX_LINK_RATE "ProgrammedMaxLinkRate" /* DATA_TYPE_INT8 */ 1914c06356bSdh #define SAS_HW_MAX_LINK_RATE "HardwareMaxLinkRate" /* DATA_TYPE_INT8 */ 1924c06356bSdh 1934c06356bSdh 194499cfd15SDavid Hollister /* 195658280b6SDavid Hollister * Phy-mask property names for the target port, attached port and receptacle 196499cfd15SDavid Hollister */ 197499cfd15SDavid Hollister #define SCSI_ADDR_PROP_TARGET_PORT_PM "target-port-pm" 198499cfd15SDavid Hollister #define SCSI_ADDR_PROP_ATTACHED_PORT_PM "attached-port-pm" 199658280b6SDavid Hollister #define SCSI_HBA_PROP_RECEPTACLE_PM "receptacle-pm" 200658280b6SDavid Hollister 201658280b6SDavid Hollister /* 202658280b6SDavid Hollister * Target port depth property names - Indicates the number of expanders 203658280b6SDavid Hollister * between the initiator port and the target port 204658280b6SDavid Hollister */ 205658280b6SDavid Hollister #define SCSI_ADDR_PROP_TARGET_PORT_DEPTH "target-port-depth" 206499cfd15SDavid Hollister 207499cfd15SDavid Hollister 2084c06356bSdh /* 2094c06356bSdh * Event definitions 2104c06356bSdh */ 2114c06356bSdh /* Event Class */ 2124c06356bSdh #define EC_HBA "EC_hba" 2134c06356bSdh 2144c06356bSdh /* Event Sub-Class */ 2154c06356bSdh #define ESC_SAS_HBA_PORT_BROADCAST "ESC_sas_hba_port_broadcast" 2164c06356bSdh /* Event Types for above Subclass */ 2174c06356bSdh #define SAS_PORT_BROADCAST_CHANGE "port_broadcast_change" 2184c06356bSdh #define SAS_PORT_BROADCAST_SES "port_broadcast_ses" 2194c06356bSdh #define SAS_PORT_BROADCAST_D24_0 "port_broadcast_d24_0" 2204c06356bSdh #define SAS_PORT_BROADCAST_D27_4 "port_broadcast_d27_4" 2214c06356bSdh #define SAS_PORT_BROADCAST_D01_4 "port_broadcast_d01_4" 2224c06356bSdh #define SAS_PORT_BROADCAST_D04_7 "port_broadcast_d04_7" 2234c06356bSdh #define SAS_PORT_BROADCAST_D16_7 "port_broadcast_d16_7" 2244c06356bSdh #define SAS_PORT_BROADCAST_D29_7 "port_broadcast_d29_7" 2254c06356bSdh 2264c06356bSdh /* Event Sub-Class */ 2274c06356bSdh #define ESC_SAS_PHY_EVENT "ESC_sas_phy_event" 2284c06356bSdh /* Event Types for above Subclass */ 2294c06356bSdh #define SAS_PHY_ONLINE "port_online" 2304c06356bSdh #define SAS_PHY_OFFLINE "port_offline" 2314c06356bSdh #define SAS_PHY_REMOVE "port_remove" 2324c06356bSdh 2334c06356bSdh /* Event Payload Names */ 2344c06356bSdh #define SAS_DRV_INST "driver_instance" 2354c06356bSdh #define SAS_PORT_ADDR "port_address" 2364c06356bSdh #define SAS_DEVFS_PATH "devfs_path" 2374c06356bSdh #define SAS_EVENT_TYPE "event_type" 2384c06356bSdh #define SAS_LINK_RATE "link_rate" 2394c06356bSdh /* SAS_PHY_ID - Defined Above */ 2404c06356bSdh 241936b7af6Sjw #ifdef __cplusplus 242936b7af6Sjw } 243936b7af6Sjw #endif 244936b7af6Sjw 24596c4a178SChris Horne #endif /* _SYS_SCSI_IMPL_SCSI_SAS_H */ 246