1230557Sjimharris/*-
2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license.  When using or
3230557Sjimharris * redistributing this file, you may do so under either license.
4230557Sjimharris *
5230557Sjimharris * GPL LICENSE SUMMARY
6230557Sjimharris *
7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8230557Sjimharris *
9230557Sjimharris * This program is free software; you can redistribute it and/or modify
10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as
11230557Sjimharris * published by the Free Software Foundation.
12230557Sjimharris *
13230557Sjimharris * This program is distributed in the hope that it will be useful, but
14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of
15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16230557Sjimharris * General Public License for more details.
17230557Sjimharris *
18230557Sjimharris * You should have received a copy of the GNU General Public License
19230557Sjimharris * along with this program; if not, write to the Free Software
20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21230557Sjimharris * The full GNU General Public License is included in this distribution
22230557Sjimharris * in the file called LICENSE.GPL.
23230557Sjimharris *
24230557Sjimharris * BSD LICENSE
25230557Sjimharris *
26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27230557Sjimharris * All rights reserved.
28230557Sjimharris *
29230557Sjimharris * Redistribution and use in source and binary forms, with or without
30230557Sjimharris * modification, are permitted provided that the following conditions
31230557Sjimharris * are met:
32230557Sjimharris *
33230557Sjimharris *   * Redistributions of source code must retain the above copyright
34230557Sjimharris *     notice, this list of conditions and the following disclaimer.
35230557Sjimharris *   * Redistributions in binary form must reproduce the above copyright
36230557Sjimharris *     notice, this list of conditions and the following disclaimer in
37230557Sjimharris *     the documentation and/or other materials provided with the
38230557Sjimharris *     distribution.
39230557Sjimharris *
40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51230557Sjimharris *
52230557Sjimharris * $FreeBSD$
53230557Sjimharris */
54230557Sjimharris#ifndef _SCIC_PORT_H_
55230557Sjimharris#define _SCIC_PORT_H_
56230557Sjimharris
57230557Sjimharris/**
58230557Sjimharris * @file
59230557Sjimharris *
60230557Sjimharris * @brief This file contains all of the interface methods that can be called
61230557Sjimharris *        by an SCI Core user on a SAS or SATA port.
62230557Sjimharris */
63230557Sjimharris
64230557Sjimharris#ifdef __cplusplus
65230557Sjimharrisextern "C" {
66230557Sjimharris#endif // __cplusplus
67230557Sjimharris
68230557Sjimharris#include <dev/isci/scil/sci_types.h>
69230557Sjimharris#include <dev/isci/scil/sci_status.h>
70230557Sjimharris#include <dev/isci/scil/intel_sas.h>
71230557Sjimharris
72230557Sjimharrisenum SCIC_PORT_NOT_READY_REASON_CODE
73230557Sjimharris{
74230557Sjimharris   SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS,
75230557Sjimharris   SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED,
76230557Sjimharris   SCIC_PORT_NOT_READY_INVALID_PORT_CONFIGURATION,
77230557Sjimharris   SCIC_PORT_NOT_READY_RECONFIGURING,
78230557Sjimharris
79230557Sjimharris   SCIC_PORT_NOT_READY_REASON_CODE_MAX
80230557Sjimharris};
81230557Sjimharris
82230557Sjimharris/**
83230557Sjimharris * @struct SCIC_PORT_END_POINT_PROPERTIES
84230557Sjimharris * @brief  This structure defines the properties that can be retrieved
85230557Sjimharris *         for each end-point local or remote (attached) port in the
86230557Sjimharris *         controller.
87230557Sjimharris */
88230557Sjimharristypedef struct SCIC_PORT_END_POINT_PROPERTIES
89230557Sjimharris{
90230557Sjimharris   /**
91230557Sjimharris    * This field indicates the SAS address for the associated end
92230557Sjimharris    * point in the port.
93230557Sjimharris    */
94230557Sjimharris   SCI_SAS_ADDRESS_T  sas_address;
95230557Sjimharris
96230557Sjimharris   /**
97230557Sjimharris    * This field indicates the protocols supported by the associated
98230557Sjimharris    * end-point in the port.
99230557Sjimharris    */
100230557Sjimharris   SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T  protocols;
101230557Sjimharris
102230557Sjimharris} SCIC_PORT_END_POINT_PROPERTIES_T;
103230557Sjimharris
104230557Sjimharris/**
105230557Sjimharris * @struct SCIC_PORT_PROPERTIES
106230557Sjimharris * @brief  This structure defines the properties that can be retrieved
107230557Sjimharris *         for each port in the controller.
108230557Sjimharris */
109230557Sjimharristypedef struct SCIC_PORT_PROPERTIES
110230557Sjimharris{
111230557Sjimharris   /**
112230557Sjimharris    * This field specifies the logical index of the port (0 relative).
113230557Sjimharris    */
114230557Sjimharris   U32  index;
115230557Sjimharris
116230557Sjimharris   /**
117230557Sjimharris    * This field indicates the local end-point properties for port.
118230557Sjimharris    */
119230557Sjimharris   SCIC_PORT_END_POINT_PROPERTIES_T  local;
120230557Sjimharris
121230557Sjimharris   /**
122230557Sjimharris    * This field indicates the remote (attached) end-point properties
123230557Sjimharris    * for the port.
124230557Sjimharris    */
125230557Sjimharris   SCIC_PORT_END_POINT_PROPERTIES_T  remote;
126230557Sjimharris
127230557Sjimharris   /**
128230557Sjimharris    * This field specifies the phys contained inside the port.
129230557Sjimharris    */
130230557Sjimharris   U32  phy_mask;
131230557Sjimharris
132230557Sjimharris} SCIC_PORT_PROPERTIES_T;
133230557Sjimharris
134230557Sjimharris/**
135230557Sjimharris * @brief This method simply returns the properties regarding the
136230557Sjimharris *        port, such as: physical index, protocols, sas address, etc.
137230557Sjimharris *
138230557Sjimharris * @param[in]  port this parameter specifies the port for which to retrieve
139230557Sjimharris *             the physical index.
140230557Sjimharris * @param[out] properties This parameter specifies the properties
141230557Sjimharris *             structure into which to copy the requested information.
142230557Sjimharris *
143230557Sjimharris * @return Indicate if the user specified a valid port.
144230557Sjimharris * @retval SCI_SUCCESS This value is returned if the specified port was valid.
145230557Sjimharris * @retval SCI_FAILURE_INVALID_PORT This value is returned if the specified port
146230557Sjimharris *         is not valid.  When this value is returned, no data is copied to the
147230557Sjimharris *         properties output parameter.
148230557Sjimharris */
149230557SjimharrisSCI_STATUS scic_port_get_properties(
150230557Sjimharris   SCI_PORT_HANDLE_T        port,
151230557Sjimharris   SCIC_PORT_PROPERTIES_T * properties
152230557Sjimharris);
153230557Sjimharris
154230557Sjimharris/**
155230557Sjimharris * @brief This method will add a phy to an existing port.
156230557Sjimharris *
157230557Sjimharris * @param[in]  port This parameter specifies the port in which to add a new
158230557Sjimharris *             phy.
159230557Sjimharris * @param[in]  phy This parameter specifies the phy to be added to the port.
160230557Sjimharris *
161230557Sjimharris * @return Indicate if the phy was successfully added to the port.
162230557Sjimharris * @retval SCI_SUCCESS This value is returned if the phy was successfully
163230557Sjimharris *         added to the port.
164230557Sjimharris * @retval SCI_FAILURE_INVALID_PORT This value is returned if the supplied
165230557Sjimharris *         port is not valid.
166230557Sjimharris * @retval SCI_FAILURE_INVALID_PHY This value is returned if the supplied
167230557Sjimharris *         phy is either invalid or already contained in another port.
168230557Sjimharris */
169230557SjimharrisSCI_STATUS scic_port_add_phy(
170230557Sjimharris   SCI_PORT_HANDLE_T port,
171230557Sjimharris   SCI_PHY_HANDLE_T  phy
172230557Sjimharris);
173230557Sjimharris
174230557Sjimharris/**
175230557Sjimharris * @brief This method will remove a phy from an existing port.
176230557Sjimharris *
177230557Sjimharris * @param[in]  port This parameter specifies the port in which to remove a
178230557Sjimharris *             phy.
179230557Sjimharris * @param[in]  phy This parameter specifies the phy to be removed from the
180230557Sjimharris *             port.
181230557Sjimharris *
182230557Sjimharris * @return Indicate if the phy was successfully removed from the port.
183230557Sjimharris * @retval SCI_SUCCESS This value is returned if the phy was successfully
184230557Sjimharris *         removed from the port.
185230557Sjimharris * @retval SCI_FAILURE_INVALID_PORT This value is returned if the supplied
186230557Sjimharris *         port is not valid.
187230557Sjimharris * @retval SCI_FAILURE_INVALID_PHY This value is returned if the supplied
188230557Sjimharris *         phy is either invalid or
189230557Sjimharris *         not contained in the port.
190230557Sjimharris */
191230557SjimharrisSCI_STATUS scic_port_remove_phy(
192230557Sjimharris   SCI_PORT_HANDLE_T  port,
193230557Sjimharris   SCI_PHY_HANDLE_T   phy
194230557Sjimharris);
195230557Sjimharris
196230557Sjimharris/**
197230557Sjimharris * @brief This method will request the SCI implementation to perform a
198230557Sjimharris *        HARD RESET on the SAS Port.  If/When the HARD RESET completes
199230557Sjimharris *        the SCI user will be notified via an SCI OS callback indicating
200230557Sjimharris *        a direct attached device was found.
201230557Sjimharris *
202230557Sjimharris * @note The SCI User callback in SCIC_USER_CALLBACKS_T will only be called
203230557Sjimharris *       once for each phy in the SAS Port at completion of the hard reset
204230557Sjimharris *       sequence.
205230557Sjimharris *
206230557Sjimharris * @param[in]  port a handle corresponding to the SAS port to be
207230557Sjimharris *             hard reset.
208230557Sjimharris * @param[in]  reset_timeout This parameter specifies the number of
209230557Sjimharris *             milliseconds in which the port reset operation should complete.
210230557Sjimharris *
211230557Sjimharris * @return Return a status indicating whether the hard reset started
212230557Sjimharris *         successfully.
213230557Sjimharris * @retval SCI_SUCCESS This value is returned if the hard reset operation
214230557Sjimharris *         started successfully.
215230557Sjimharris */
216230557SjimharrisSCI_STATUS scic_port_hard_reset(
217230557Sjimharris   SCI_PORT_HANDLE_T port,
218230557Sjimharris   U32               reset_timeout
219230557Sjimharris);
220230557Sjimharris
221230557Sjimharris/**
222230557Sjimharris * @brief This API method enables the broadcast change notification from
223230557Sjimharris *        underneath hardware.
224230557Sjimharris *
225230557Sjimharris * @param[in] port The port upon which broadcast change notifications
226230557Sjimharris *            (BCN) are to be enabled.
227230557Sjimharris *
228230557Sjimharris * @return none
229230557Sjimharris */
230230557Sjimharrisvoid scic_port_enable_broadcast_change_notification(
231230557Sjimharris   SCI_PORT_HANDLE_T  port
232230557Sjimharris);
233230557Sjimharris
234230557Sjimharris#ifdef __cplusplus
235230557Sjimharris}
236230557Sjimharris#endif // __cplusplus
237230557Sjimharris
238230557Sjimharris#endif // _SCIC_PORT_H_
239230557Sjimharris
240