- more 2.6.17 port work (still does not build)
[linux-flexiantxendom0-3.2.10.git] / include / scsi / sas / sas_discover.h
1 /*
2  * Serial Attached SCSI (SAS) Discover process header file
3  *
4  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
5  * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
6  *
7  * This file is licensed under GPLv2.
8  *
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.
13  *
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.
18  *
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
22  *
23  * $Id: //depot/sas-class/sas_discover.h#41 $
24  */
25
26 #ifndef _SAS_DISCOVER_H_
27 #define _SAS_DISCOVER_H_
28
29 #include <scsi/sas/sas_class.h>
30 #include <scsi/sas/sas_frames.h>
31
32 /* ---------- SMP ---------- */
33
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
45
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
57
58 /* ---------- Domain Devices ---------- */
59
60 /* See sas_discover.c before changing these.
61  */
62
63 /* ---------- SATA device ---------- */
64
65 enum ata_command_set {
66         ATA_COMMAND_SET   = 0,
67         ATAPI_COMMAND_SET = 1,
68 };
69
70 struct domain_device;
71
72 struct sata_device {
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;
77
78         u8     port_no;        /* port number, if this is a PM (Port) */
79         struct list_head children; /* PM Ports if this is a PM */
80 };
81
82 #include <scsi/sas/sas_expander.h>
83
84 /* ---------- Domain device ---------- */
85
86 struct domain_device {
87         enum sas_dev_type dev_type;
88
89         enum sas_phy_linkrate linkrate;
90         enum sas_phy_linkrate min_linkrate;
91         enum sas_phy_linkrate max_linkrate;
92
93         int  pathways;
94
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 */
98
99         struct list_head dev_list_node;
100
101         enum sas_proto    iproto;
102         enum sas_proto    tproto;
103
104         struct sas_rphy *rphy;
105
106         u8  sas_addr[SAS_ADDR_SIZE];
107         u8  hashed_sas_addr[HASHED_SAS_ADDR_SIZE];
108
109         u8  frame_rcvd[32];
110
111         union {
112                 struct expander_device ex_dev;
113                 struct sata_device     sata_dev; /* STP & directly attached */
114         };
115
116         void *lldd_dev;
117 };
118
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))
124
125
126 static inline void sas_init_dev(struct domain_device *dev)
127 {
128         INIT_LIST_HEAD(&dev->siblings);
129         INIT_LIST_HEAD(&dev->dev_list_node);
130         switch (dev->dev_type) {
131         case SAS_END_DEV:
132                 break;
133         case EDGE_DEV:
134         case FANOUT_DEV:
135                 INIT_LIST_HEAD(&dev->ex_dev.children);
136                 break;
137         case SATA_DEV:
138         case SATA_PM:
139         case SATA_PM_PORT:
140                 INIT_LIST_HEAD(&dev->sata_dev.children);
141                 break;
142         default:
143                 break;
144         }
145 }
146
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);
149
150 int  sas_discover_sata(struct domain_device *dev);
151 int  sas_discover_end_dev(struct domain_device *dev);
152
153 void sas_unregister_dev(struct domain_device *dev);
154
155 void sas_unregister_devices(struct sas_ha_struct *sas_ha);
156
157 #endif /* _SAS_DISCOVER_H_ */