2 * Serial Attached SCSI (SAS) Discover process header file
4 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
7 * This file is licensed under GPLv2.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * $Id: //depot/sas-class/sas_discover.h#41 $
26 #ifndef _SAS_DISCOVER_H_
27 #define _SAS_DISCOVER_H_
29 #include <scsi/sas/sas_class.h>
30 #include <scsi/sas/sas_frames.h>
32 /* ---------- SMP ---------- */
34 #define SMP_REPORT_GENERAL 0x00
35 #define SMP_REPORT_MANUF_INFO 0x01
36 #define SMP_READ_GPIO_REG 0x02
37 #define SMP_DISCOVER 0x10
38 #define SMP_REPORT_PHY_ERR_LOG 0x11
39 #define SMP_REPORT_PHY_SATA 0x12
40 #define SMP_REPORT_ROUTE_INFO 0x13
41 #define SMP_WRITE_GPIO_REG 0x82
42 #define SMP_CONF_ROUTE_INFO 0x90
43 #define SMP_PHY_CONTROL 0x91
44 #define SMP_PHY_TEST_FUNCTION 0x92
46 #define SMP_RESP_FUNC_ACC 0x00
47 #define SMP_RESP_FUNC_UNK 0x01
48 #define SMP_RESP_FUNC_FAILED 0x02
49 #define SMP_RESP_INV_FRM_LEN 0x03
50 #define SMP_RESP_NO_PHY 0x10
51 #define SMP_RESP_NO_INDEX 0x11
52 #define SMP_RESP_PHY_NO_SATA 0x12
53 #define SMP_RESP_PHY_UNK_OP 0x13
54 #define SMP_RESP_PHY_UNK_TESTF 0x14
55 #define SMP_RESP_PHY_TEST_INPROG 0x15
56 #define SMP_RESP_PHY_VACANT 0x16
58 /* ---------- Domain Devices ---------- */
60 /* See sas_discover.c before changing these.
63 /* ---------- SATA device ---------- */
65 enum ata_command_set {
67 ATAPI_COMMAND_SET = 1,
73 enum ata_command_set command_set;
74 struct smp_resp rps_resp; /* report_phy_sata_resp */
75 __le16 *identify_device;
76 __le16 *identify_packet_device;
78 u8 port_no; /* port number, if this is a PM (Port) */
79 struct list_head children; /* PM Ports if this is a PM */
82 #include <scsi/sas/sas_expander.h>
84 /* ---------- Domain device ---------- */
86 struct domain_device {
87 enum sas_dev_type dev_type;
89 enum sas_phy_linkrate linkrate;
90 enum sas_phy_linkrate min_linkrate;
91 enum sas_phy_linkrate max_linkrate;
95 struct domain_device *parent;
96 struct list_head siblings; /* devices on the same level */
97 struct sas_port *port; /* shortcut to root of the tree */
99 struct list_head dev_list_node;
101 enum sas_proto iproto;
102 enum sas_proto tproto;
104 struct sas_rphy *rphy;
106 u8 sas_addr[SAS_ADDR_SIZE];
107 u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
112 struct expander_device ex_dev;
113 struct sata_device sata_dev; /* STP & directly attached */
119 #define list_for_each_entry_reverse_safe(pos, n, head, member) \
120 for (pos = list_entry((head)->prev, typeof(*pos), member), \
121 n = list_entry(pos->member.prev, typeof(*pos), member); \
122 &pos->member != (head); \
123 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
126 static inline void sas_init_dev(struct domain_device *dev)
128 INIT_LIST_HEAD(&dev->siblings);
129 INIT_LIST_HEAD(&dev->dev_list_node);
130 switch (dev->dev_type) {
135 INIT_LIST_HEAD(&dev->ex_dev.children);
140 INIT_LIST_HEAD(&dev->sata_dev.children);
147 void sas_init_disc(struct sas_discovery *disc, struct sas_port *port);
148 int sas_discover_event(struct sas_port *sas_port, enum discover_event ev);
150 int sas_discover_sata(struct domain_device *dev);
151 int sas_discover_end_dev(struct domain_device *dev);
153 void sas_unregister_dev(struct domain_device *dev);
155 void sas_unregister_devices(struct sas_ha_struct *sas_ha);
157 #endif /* _SAS_DISCOVER_H_ */