0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
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
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
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
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
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
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 ;
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