Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is provided under a dual BSD/GPLv2 license.  When using or
0003  * redistributing this file, you may do so under either license.
0004  *
0005  * GPL LICENSE SUMMARY
0006  *
0007  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
0008  *
0009  * This program is free software; you can redistribute it and/or modify
0010  * it under the terms of version 2 of the GNU General Public License as
0011  * published by the Free Software Foundation.
0012  *
0013  * This program is distributed in the hope that it will be useful, but
0014  * WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU General Public License
0019  * along with this program; if not, write to the Free Software
0020  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
0021  * The full GNU General Public License is included in this distribution
0022  * in the file called LICENSE.GPL.
0023  *
0024  * BSD LICENSE
0025  *
0026  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
0027  * All rights reserved.
0028  *
0029  * Redistribution and use in source and binary forms, with or without
0030  * modification, are permitted provided that the following conditions
0031  * are met:
0032  *
0033  *   * Redistributions of source code must retain the above copyright
0034  *     notice, this list of conditions and the following disclaimer.
0035  *   * Redistributions in binary form must reproduce the above copyright
0036  *     notice, this list of conditions and the following disclaimer in
0037  *     the documentation and/or other materials provided with the
0038  *     distribution.
0039  *   * Neither the name of Intel Corporation nor the names of its
0040  *     contributors may be used to endorse or promote products derived
0041  *     from this software without specific prior written permission.
0042  *
0043  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0044  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0045  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0046  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0047  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0048  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0049  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0050  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0051  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0052  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0053  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0054  */
0055 
0056 #ifndef _ISCI_PORT_H_
0057 #define _ISCI_PORT_H_
0058 
0059 #include <scsi/libsas.h>
0060 #include "isci.h"
0061 #include "sas.h"
0062 #include "phy.h"
0063 
0064 #define SCIC_SDS_DUMMY_PORT   0xFF
0065 
0066 #define PF_NOTIFY (1 << 0)
0067 #define PF_RESUME (1 << 1)
0068 
0069 struct isci_phy;
0070 struct isci_host;
0071 
0072 enum isci_status {
0073     isci_freed        = 0x00,
0074     isci_starting     = 0x01,
0075     isci_ready        = 0x02,
0076     isci_ready_for_io = 0x03,
0077     isci_stopping     = 0x04,
0078     isci_stopped      = 0x05,
0079 };
0080 
0081 /**
0082  * struct isci_port - isci direct attached sas port object
0083  * @ready_exit: several states constitute 'ready'. When exiting ready we
0084  *              need to take extra port-teardown actions that are
0085  *              skipped when exiting to another 'ready' state.
0086  * @logical_port_index: software port index
0087  * @physical_port_index: hardware port index
0088  * @active_phy_mask: identifies phy members
0089  * @enabled_phy_mask: phy mask for the port
0090  *                    that are already part of the port
0091  * @reserved_tag:
0092  * @reserved_rni: reserver for port task scheduler workaround
0093  * @started_request_count: reference count for outstanding commands
0094  * @not_ready_reason: set during state transitions and notified
0095  * @timer: timeout start/stop operations
0096  */
0097 struct isci_port {
0098     struct isci_host *isci_host;
0099     struct list_head remote_dev_list;
0100     #define IPORT_RESET_PENDING 0
0101     unsigned long state;
0102     enum sci_status hard_reset_status;
0103     struct sci_base_state_machine sm;
0104     bool ready_exit;
0105     u8 logical_port_index;
0106     u8 physical_port_index;
0107     u8 active_phy_mask;
0108     u8 enabled_phy_mask;
0109     u8 last_active_phy;
0110     u16 reserved_rni;
0111     u16 reserved_tag;
0112     u32 started_request_count;
0113     u32 assigned_device_count;
0114     u32 hang_detect_users;
0115     u32 not_ready_reason;
0116     struct isci_phy *phy_table[SCI_MAX_PHYS];
0117     struct isci_host *owning_controller;
0118     struct sci_timer timer;
0119     struct scu_port_task_scheduler_registers __iomem *port_task_scheduler_registers;
0120     /* XXX rework: only one register, no need to replicate per-port */
0121     u32 __iomem *port_pe_configuration_register;
0122     struct scu_viit_entry __iomem *viit_registers;
0123 };
0124 
0125 enum sci_port_not_ready_reason_code {
0126     SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS,
0127     SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED,
0128     SCIC_PORT_NOT_READY_INVALID_PORT_CONFIGURATION,
0129     SCIC_PORT_NOT_READY_RECONFIGURING,
0130 
0131     SCIC_PORT_NOT_READY_REASON_CODE_MAX
0132 };
0133 
0134 struct sci_port_end_point_properties {
0135     struct sci_sas_address sas_address;
0136     struct sci_phy_proto protocols;
0137 };
0138 
0139 struct sci_port_properties {
0140     u32 index;
0141     struct sci_port_end_point_properties local;
0142     struct sci_port_end_point_properties remote;
0143     u32 phy_mask;
0144 };
0145 
0146 /**
0147  * enum sci_port_states - port state machine states
0148  * @SCI_PORT_STOPPED: port has successfully been stopped.  In this state
0149  *            no new IO operations are permitted.  This state is
0150  *            entered from the STOPPING state.
0151  * @SCI_PORT_STOPPING: port is in the process of stopping.  In this
0152  *             state no new IO operations are permitted, but
0153  *             existing IO operations are allowed to complete.
0154  *             This state is entered from the READY state.
0155  * @SCI_PORT_READY: port is now ready.  Thus, the user is able to
0156  *          perform IO operations on this port. This state is
0157  *          entered from the STARTING state.
0158  * @SCI_PORT_SUB_WAITING: port is started and ready but has no active
0159  *            phys.
0160  * @SCI_PORT_SUB_OPERATIONAL: port is started and ready and there is at
0161  *                least one phy operational.
0162  * @SCI_PORT_SUB_CONFIGURING: port is started and there was an
0163  *                add/remove phy event.  This state is only
0164  *                used in Automatic Port Configuration Mode
0165  *                (APC)
0166  * @SCI_PORT_RESETTING: port is in the process of performing a hard
0167  *          reset.  Thus, the user is unable to perform IO
0168  *          operations on this port.  This state is entered
0169  *          from the READY state.
0170  * @SCI_PORT_FAILED: port has failed a reset request.  This state is
0171  *           entered when a port reset request times out. This
0172  *           state is entered from the RESETTING state.
0173  */
0174 #define PORT_STATES {\
0175     C(PORT_STOPPED),\
0176     C(PORT_STOPPING),\
0177     C(PORT_READY),\
0178     C(PORT_SUB_WAITING),\
0179     C(PORT_SUB_OPERATIONAL),\
0180     C(PORT_SUB_CONFIGURING),\
0181     C(PORT_RESETTING),\
0182     C(PORT_FAILED),\
0183     }
0184 #undef C
0185 #define C(a) SCI_##a
0186 enum sci_port_states PORT_STATES;
0187 #undef C
0188 
0189 static inline void sci_port_decrement_request_count(struct isci_port *iport)
0190 {
0191     if (WARN_ONCE(iport->started_request_count == 0,
0192                "%s: tried to decrement started_request_count past 0!?",
0193             __func__))
0194         /* pass */;
0195     else
0196         iport->started_request_count--;
0197 }
0198 
0199 #define sci_port_active_phy(port, phy) \
0200     (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0)
0201 
0202 void sci_port_construct(
0203     struct isci_port *iport,
0204     u8 port_index,
0205     struct isci_host *ihost);
0206 
0207 enum sci_status sci_port_start(struct isci_port *iport);
0208 enum sci_status sci_port_stop(struct isci_port *iport);
0209 
0210 enum sci_status sci_port_add_phy(
0211     struct isci_port *iport,
0212     struct isci_phy *iphy);
0213 
0214 enum sci_status sci_port_remove_phy(
0215     struct isci_port *iport,
0216     struct isci_phy *iphy);
0217 
0218 void sci_port_setup_transports(
0219     struct isci_port *iport,
0220     u32 device_id);
0221 
0222 void isci_port_bcn_enable(struct isci_host *, struct isci_port *);
0223 
0224 void sci_port_deactivate_phy(
0225     struct isci_port *iport,
0226     struct isci_phy *iphy,
0227     bool do_notify_user);
0228 
0229 bool sci_port_link_detected(
0230     struct isci_port *iport,
0231     struct isci_phy *iphy);
0232 
0233 enum sci_status sci_port_get_properties(
0234     struct isci_port *iport,
0235     struct sci_port_properties *prop);
0236 
0237 enum sci_status sci_port_link_up(struct isci_port *iport,
0238                       struct isci_phy *iphy);
0239 enum sci_status sci_port_link_down(struct isci_port *iport,
0240                     struct isci_phy *iphy);
0241 
0242 struct isci_request;
0243 struct isci_remote_device;
0244 enum sci_status sci_port_start_io(
0245     struct isci_port *iport,
0246     struct isci_remote_device *idev,
0247     struct isci_request *ireq);
0248 
0249 enum sci_status sci_port_complete_io(
0250     struct isci_port *iport,
0251     struct isci_remote_device *idev,
0252     struct isci_request *ireq);
0253 
0254 enum sas_linkrate sci_port_get_max_allowed_speed(
0255     struct isci_port *iport);
0256 
0257 void sci_port_broadcast_change_received(
0258     struct isci_port *iport,
0259     struct isci_phy *iphy);
0260 
0261 bool sci_port_is_valid_phy_assignment(
0262     struct isci_port *iport,
0263     u32 phy_index);
0264 
0265 void sci_port_get_sas_address(
0266     struct isci_port *iport,
0267     struct sci_sas_address *sas_address);
0268 
0269 void sci_port_get_attached_sas_address(
0270     struct isci_port *iport,
0271     struct sci_sas_address *sas_address);
0272 
0273 void sci_port_set_hang_detection_timeout(
0274     struct isci_port *isci_port,
0275     u32 timeout);
0276 
0277 void isci_port_formed(struct asd_sas_phy *);
0278 void isci_port_deformed(struct asd_sas_phy *);
0279 
0280 int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport,
0281                  struct isci_phy *iphy);
0282 int isci_ata_check_ready(struct domain_device *dev);
0283 #endif /* !defined(_ISCI_PORT_H_) */