Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
port.h
Go to the documentation of this file.
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.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
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.
12  *
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.
17  *
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.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
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.
42  *
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.
54  */
55 
56 #ifndef _ISCI_PORT_H_
57 #define _ISCI_PORT_H_
58 
59 #include <scsi/libsas.h>
60 #include "isci.h"
61 #include "sas.h"
62 #include "phy.h"
63 
64 #define SCIC_SDS_DUMMY_PORT 0xFF
65 
66 #define PF_NOTIFY (1 << 0)
67 #define PF_RESUME (1 << 1)
68 
69 struct isci_phy;
70 struct isci_host;
71 
73  isci_freed = 0x00,
74  isci_starting = 0x01,
75  isci_ready = 0x02,
77  isci_stopping = 0x04,
78  isci_stopped = 0x05,
79 };
80 
97 struct isci_port {
100  #define IPORT_RESET_PENDING 0
101  unsigned long state;
118  struct sci_timer timer;
120  /* XXX rework: only one register, no need to replicate per-port */
123 };
124 
130 
132 };
133 
137 };
138 
144 };
145 
174 #define PORT_STATES {\
175  C(PORT_STOPPED),\
176  C(PORT_STOPPING),\
177  C(PORT_READY),\
178  C(PORT_SUB_WAITING),\
179  C(PORT_SUB_OPERATIONAL),\
180  C(PORT_SUB_CONFIGURING),\
181  C(PORT_RESETTING),\
182  C(PORT_FAILED),\
183  }
184 #undef C
185 #define C(a) SCI_##a
186 enum sci_port_states PORT_STATES;
187 #undef C
188 
189 static inline void sci_port_decrement_request_count(struct isci_port *iport)
190 {
191  if (WARN_ONCE(iport->started_request_count == 0,
192  "%s: tried to decrement started_request_count past 0!?",
193  __func__))
194  /* pass */;
195  else
196  iport->started_request_count--;
197 }
198 
199 #define sci_port_active_phy(port, phy) \
200  (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0)
201 
202 void sci_port_construct(
203  struct isci_port *iport,
204  u8 port_index,
205  struct isci_host *ihost);
206 
207 enum sci_status sci_port_start(struct isci_port *iport);
208 enum sci_status sci_port_stop(struct isci_port *iport);
209 
211  struct isci_port *iport,
212  struct isci_phy *iphy);
213 
215  struct isci_port *iport,
216  struct isci_phy *iphy);
217 
219  struct isci_port *iport,
220  u32 device_id);
221 
222 void isci_port_bcn_enable(struct isci_host *, struct isci_port *);
223 
225  struct isci_port *iport,
226  struct isci_phy *iphy,
227  bool do_notify_user);
228 
230  struct isci_port *iport,
231  struct isci_phy *iphy);
232 
234  struct isci_port *iport,
235  struct sci_port_properties *prop);
236 
237 enum sci_status sci_port_link_up(struct isci_port *iport,
238  struct isci_phy *iphy);
239 enum sci_status sci_port_link_down(struct isci_port *iport,
240  struct isci_phy *iphy);
241 
242 struct isci_request;
243 struct isci_remote_device;
245  struct isci_port *iport,
246  struct isci_remote_device *idev,
247  struct isci_request *ireq);
248 
250  struct isci_port *iport,
251  struct isci_remote_device *idev,
252  struct isci_request *ireq);
253 
255  struct isci_port *iport);
256 
258  struct isci_port *iport,
259  struct isci_phy *iphy);
260 
262  struct isci_port *iport,
263  u32 phy_index);
264 
266  struct isci_port *iport,
267  struct sci_sas_address *sas_address);
268 
270  struct isci_port *iport,
271  struct sci_sas_address *sas_address);
272 
274  struct isci_port *isci_port,
275  u32 timeout);
276 
277 void isci_port_formed(struct asd_sas_phy *);
278 void isci_port_deformed(struct asd_sas_phy *);
279 
280 int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport,
281  struct isci_phy *iphy);
283 #endif /* !defined(_ISCI_PORT_H_) */