nilfs2: unbreak compat ioctl
[zen-stable.git] / drivers / scsi / isci / port.h
blobcb5ffbc386038136812da1e596ca5059ff391615
1 /*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
5 * GPL LICENSE SUMMARY
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
24 * BSD LICENSE
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 #ifndef _ISCI_PORT_H_
57 #define _ISCI_PORT_H_
59 #include <scsi/libsas.h>
60 #include "isci.h"
61 #include "sas.h"
62 #include "phy.h"
64 #define SCIC_SDS_DUMMY_PORT 0xFF
66 struct isci_phy;
67 struct isci_host;
69 enum isci_status {
70 isci_freed = 0x00,
71 isci_starting = 0x01,
72 isci_ready = 0x02,
73 isci_ready_for_io = 0x03,
74 isci_stopping = 0x04,
75 isci_stopped = 0x05,
78 /**
79 * struct isci_port - isci direct attached sas port object
80 * @ready_exit: several states constitute 'ready'. When exiting ready we
81 * need to take extra port-teardown actions that are
82 * skipped when exiting to another 'ready' state.
83 * @logical_port_index: software port index
84 * @physical_port_index: hardware port index
85 * @active_phy_mask: identifies phy members
86 * @reserved_tag:
87 * @reserved_rni: reserver for port task scheduler workaround
88 * @started_request_count: reference count for outstanding commands
89 * @not_ready_reason: set during state transitions and notified
90 * @timer: timeout start/stop operations
92 struct isci_port {
93 enum isci_status status;
94 struct isci_host *isci_host;
95 struct asd_sas_port sas_port;
96 struct list_head remote_dev_list;
97 spinlock_t state_lock;
98 struct list_head domain_dev_list;
99 struct completion start_complete;
100 struct completion hard_reset_complete;
101 enum sci_status hard_reset_status;
102 struct sci_base_state_machine sm;
103 bool ready_exit;
104 u8 logical_port_index;
105 u8 physical_port_index;
106 u8 active_phy_mask;
107 u8 last_active_phy;
108 u16 reserved_rni;
109 u16 reserved_tag;
110 u32 started_request_count;
111 u32 assigned_device_count;
112 u32 not_ready_reason;
113 struct isci_phy *phy_table[SCI_MAX_PHYS];
114 struct isci_host *owning_controller;
115 struct sci_timer timer;
116 struct scu_port_task_scheduler_registers __iomem *port_task_scheduler_registers;
117 /* XXX rework: only one register, no need to replicate per-port */
118 u32 __iomem *port_pe_configuration_register;
119 struct scu_viit_entry __iomem *viit_registers;
122 enum sci_port_not_ready_reason_code {
123 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS,
124 SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED,
125 SCIC_PORT_NOT_READY_INVALID_PORT_CONFIGURATION,
126 SCIC_PORT_NOT_READY_RECONFIGURING,
128 SCIC_PORT_NOT_READY_REASON_CODE_MAX
131 struct sci_port_end_point_properties {
132 struct sci_sas_address sas_address;
133 struct sci_phy_proto protocols;
136 struct sci_port_properties {
137 u32 index;
138 struct sci_port_end_point_properties local;
139 struct sci_port_end_point_properties remote;
140 u32 phy_mask;
144 * enum sci_port_states - This enumeration depicts all the states for the
145 * common port state machine.
149 enum sci_port_states {
151 * This state indicates that the port has successfully been stopped.
152 * In this state no new IO operations are permitted.
153 * This state is entered from the STOPPING state.
155 SCI_PORT_STOPPED,
158 * This state indicates that the port is in the process of stopping.
159 * In this state no new IO operations are permitted, but existing IO
160 * operations are allowed to complete.
161 * This state is entered from the READY state.
163 SCI_PORT_STOPPING,
166 * This state indicates the port is now ready. Thus, the user is
167 * able to perform IO operations on this port.
168 * This state is entered from the STARTING state.
170 SCI_PORT_READY,
173 * The substate where the port is started and ready but has no
174 * active phys.
176 SCI_PORT_SUB_WAITING,
179 * The substate where the port is started and ready and there is
180 * at least one phy operational.
182 SCI_PORT_SUB_OPERATIONAL,
185 * The substate where the port is started and there was an
186 * add/remove phy event. This state is only used in Automatic
187 * Port Configuration Mode (APC)
189 SCI_PORT_SUB_CONFIGURING,
192 * This state indicates the port is in the process of performing a hard
193 * reset. Thus, the user is unable to perform IO operations on this
194 * port.
195 * This state is entered from the READY state.
197 SCI_PORT_RESETTING,
200 * This state indicates the port has failed a reset request. This state
201 * is entered when a port reset request times out.
202 * This state is entered from the RESETTING state.
204 SCI_PORT_FAILED,
209 static inline void sci_port_decrement_request_count(struct isci_port *iport)
211 if (WARN_ONCE(iport->started_request_count == 0,
212 "%s: tried to decrement started_request_count past 0!?",
213 __func__))
214 /* pass */;
215 else
216 iport->started_request_count--;
219 #define sci_port_active_phy(port, phy) \
220 (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0)
222 void sci_port_construct(
223 struct isci_port *iport,
224 u8 port_index,
225 struct isci_host *ihost);
227 enum sci_status sci_port_start(struct isci_port *iport);
228 enum sci_status sci_port_stop(struct isci_port *iport);
230 enum sci_status sci_port_add_phy(
231 struct isci_port *iport,
232 struct isci_phy *iphy);
234 enum sci_status sci_port_remove_phy(
235 struct isci_port *iport,
236 struct isci_phy *iphy);
238 void sci_port_setup_transports(
239 struct isci_port *iport,
240 u32 device_id);
242 void isci_port_bcn_enable(struct isci_host *, struct isci_port *);
244 void sci_port_deactivate_phy(
245 struct isci_port *iport,
246 struct isci_phy *iphy,
247 bool do_notify_user);
249 bool sci_port_link_detected(
250 struct isci_port *iport,
251 struct isci_phy *iphy);
253 enum sci_status sci_port_link_up(struct isci_port *iport,
254 struct isci_phy *iphy);
255 enum sci_status sci_port_link_down(struct isci_port *iport,
256 struct isci_phy *iphy);
258 struct isci_request;
259 struct isci_remote_device;
260 enum sci_status sci_port_start_io(
261 struct isci_port *iport,
262 struct isci_remote_device *idev,
263 struct isci_request *ireq);
265 enum sci_status sci_port_complete_io(
266 struct isci_port *iport,
267 struct isci_remote_device *idev,
268 struct isci_request *ireq);
270 enum sas_linkrate sci_port_get_max_allowed_speed(
271 struct isci_port *iport);
273 void sci_port_broadcast_change_received(
274 struct isci_port *iport,
275 struct isci_phy *iphy);
277 bool sci_port_is_valid_phy_assignment(
278 struct isci_port *iport,
279 u32 phy_index);
281 void sci_port_get_sas_address(
282 struct isci_port *iport,
283 struct sci_sas_address *sas_address);
285 void sci_port_get_attached_sas_address(
286 struct isci_port *iport,
287 struct sci_sas_address *sas_address);
289 enum isci_status isci_port_get_state(
290 struct isci_port *isci_port);
292 void isci_port_formed(struct asd_sas_phy *);
293 void isci_port_deformed(struct asd_sas_phy *);
295 void isci_port_init(
296 struct isci_port *port,
297 struct isci_host *host,
298 int index);
300 int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport,
301 struct isci_phy *iphy);
302 #endif /* !defined(_ISCI_PORT_H_) */