Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1 | /* |
| 2 | * SAS Transport Layer for MPT (Message Passing Technology) based controllers |
| 3 | * |
| 4 | * This code is based on drivers/scsi/mpt2sas/mpt2_transport.c |
Kashyap, Desai | 31b7f2e | 2010-03-17 16:28:04 +0530 | [diff] [blame] | 5 | * Copyright (C) 2007-2010 LSI Corporation |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 6 | * (mailto:DL-MPTFusionLinux@lsi.com) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * as published by the Free Software Foundation; either version 2 |
| 11 | * of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * NO WARRANTY |
| 19 | * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 20 | * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT |
| 21 | * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, |
| 22 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is |
| 23 | * solely responsible for determining the appropriateness of using and |
| 24 | * distributing the Program and assumes all risks associated with its |
| 25 | * exercise of rights under this Agreement, including but not limited to |
| 26 | * the risks and costs of program errors, damage to or loss of data, |
| 27 | * programs or equipment, and unavailability or interruption of operations. |
| 28 | |
| 29 | * DISCLAIMER OF LIABILITY |
| 30 | * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY |
| 31 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 32 | * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND |
| 33 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
| 34 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 35 | * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED |
| 36 | * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES |
| 37 | |
| 38 | * You should have received a copy of the GNU General Public License |
| 39 | * along with this program; if not, write to the Free Software |
| 40 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| 41 | * USA. |
| 42 | */ |
| 43 | |
| 44 | #include <linux/module.h> |
| 45 | #include <linux/kernel.h> |
| 46 | #include <linux/init.h> |
| 47 | #include <linux/errno.h> |
| 48 | #include <linux/sched.h> |
| 49 | #include <linux/workqueue.h> |
| 50 | #include <linux/delay.h> |
| 51 | #include <linux/pci.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 52 | #include <linux/slab.h> |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 53 | |
| 54 | #include <scsi/scsi.h> |
| 55 | #include <scsi/scsi_cmnd.h> |
| 56 | #include <scsi/scsi_device.h> |
| 57 | #include <scsi/scsi_host.h> |
| 58 | #include <scsi/scsi_transport_sas.h> |
| 59 | #include <scsi/scsi_dbg.h> |
| 60 | |
| 61 | #include "mpt2sas_base.h" |
| 62 | /** |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 63 | * _transport_sas_node_find_by_sas_address - sas node search |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 64 | * @ioc: per adapter object |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 65 | * @sas_address: sas address of expander or sas host |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 66 | * Context: Calling function should acquire ioc->sas_node_lock. |
| 67 | * |
| 68 | * Search for either hba phys or expander device based on handle, then returns |
| 69 | * the sas_node object. |
| 70 | */ |
| 71 | static struct _sas_node * |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 72 | _transport_sas_node_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc, |
| 73 | u64 sas_address) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 74 | { |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 75 | if (ioc->sas_hba.sas_address == sas_address) |
| 76 | return &ioc->sas_hba; |
| 77 | else |
| 78 | return mpt2sas_scsih_expander_find_by_sas_address(ioc, |
| 79 | sas_address); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /** |
| 83 | * _transport_convert_phy_link_rate - |
| 84 | * @link_rate: link rate returned from mpt firmware |
| 85 | * |
| 86 | * Convert link_rate from mpi fusion into sas_transport form. |
| 87 | */ |
| 88 | static enum sas_linkrate |
| 89 | _transport_convert_phy_link_rate(u8 link_rate) |
| 90 | { |
| 91 | enum sas_linkrate rc; |
| 92 | |
| 93 | switch (link_rate) { |
| 94 | case MPI2_SAS_NEG_LINK_RATE_1_5: |
| 95 | rc = SAS_LINK_RATE_1_5_GBPS; |
| 96 | break; |
| 97 | case MPI2_SAS_NEG_LINK_RATE_3_0: |
| 98 | rc = SAS_LINK_RATE_3_0_GBPS; |
| 99 | break; |
| 100 | case MPI2_SAS_NEG_LINK_RATE_6_0: |
| 101 | rc = SAS_LINK_RATE_6_0_GBPS; |
| 102 | break; |
| 103 | case MPI2_SAS_NEG_LINK_RATE_PHY_DISABLED: |
| 104 | rc = SAS_PHY_DISABLED; |
| 105 | break; |
| 106 | case MPI2_SAS_NEG_LINK_RATE_NEGOTIATION_FAILED: |
| 107 | rc = SAS_LINK_RATE_FAILED; |
| 108 | break; |
| 109 | case MPI2_SAS_NEG_LINK_RATE_PORT_SELECTOR: |
| 110 | rc = SAS_SATA_PORT_SELECTOR; |
| 111 | break; |
| 112 | case MPI2_SAS_NEG_LINK_RATE_SMP_RESET_IN_PROGRESS: |
| 113 | rc = SAS_PHY_RESET_IN_PROGRESS; |
| 114 | break; |
| 115 | default: |
| 116 | case MPI2_SAS_NEG_LINK_RATE_SATA_OOB_COMPLETE: |
| 117 | case MPI2_SAS_NEG_LINK_RATE_UNKNOWN_LINK_RATE: |
| 118 | rc = SAS_LINK_RATE_UNKNOWN; |
| 119 | break; |
| 120 | } |
| 121 | return rc; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * _transport_set_identify - set identify for phys and end devices |
| 126 | * @ioc: per adapter object |
| 127 | * @handle: device handle |
| 128 | * @identify: sas identify info |
| 129 | * |
| 130 | * Populates sas identify info. |
| 131 | * |
| 132 | * Returns 0 for success, non-zero for failure. |
| 133 | */ |
| 134 | static int |
| 135 | _transport_set_identify(struct MPT2SAS_ADAPTER *ioc, u16 handle, |
| 136 | struct sas_identify *identify) |
| 137 | { |
| 138 | Mpi2SasDevicePage0_t sas_device_pg0; |
| 139 | Mpi2ConfigReply_t mpi_reply; |
| 140 | u32 device_info; |
| 141 | u32 ioc_status; |
| 142 | |
Eric Moore | 3cb5469 | 2010-07-08 14:44:34 -0600 | [diff] [blame] | 143 | if (ioc->shost_recovery || ioc->pci_error_recovery) { |
Kashyap, Desai | 155dd4c | 2009-08-20 13:22:00 +0530 | [diff] [blame] | 144 | printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", |
| 145 | __func__, ioc->name); |
| 146 | return -EFAULT; |
| 147 | } |
| 148 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 149 | if ((mpt2sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0, |
| 150 | MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { |
| 151 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
Kashyap, Desai | 155dd4c | 2009-08-20 13:22:00 +0530 | [diff] [blame] | 152 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 153 | ioc->name, __FILE__, __LINE__, __func__); |
Kashyap, Desai | 155dd4c | 2009-08-20 13:22:00 +0530 | [diff] [blame] | 154 | return -ENXIO; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & |
| 158 | MPI2_IOCSTATUS_MASK; |
| 159 | if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { |
| 160 | printk(MPT2SAS_ERR_FMT "handle(0x%04x), ioc_status(0x%04x)" |
| 161 | "\nfailure at %s:%d/%s()!\n", ioc->name, handle, ioc_status, |
| 162 | __FILE__, __LINE__, __func__); |
Kashyap, Desai | 155dd4c | 2009-08-20 13:22:00 +0530 | [diff] [blame] | 163 | return -EIO; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 164 | } |
| 165 | |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 166 | memset(identify, 0, sizeof(struct sas_identify)); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 167 | device_info = le32_to_cpu(sas_device_pg0.DeviceInfo); |
| 168 | |
| 169 | /* sas_address */ |
| 170 | identify->sas_address = le64_to_cpu(sas_device_pg0.SASAddress); |
| 171 | |
| 172 | /* device_type */ |
| 173 | switch (device_info & MPI2_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) { |
| 174 | case MPI2_SAS_DEVICE_INFO_NO_DEVICE: |
| 175 | identify->device_type = SAS_PHY_UNUSED; |
| 176 | break; |
| 177 | case MPI2_SAS_DEVICE_INFO_END_DEVICE: |
| 178 | identify->device_type = SAS_END_DEVICE; |
| 179 | break; |
| 180 | case MPI2_SAS_DEVICE_INFO_EDGE_EXPANDER: |
| 181 | identify->device_type = SAS_EDGE_EXPANDER_DEVICE; |
| 182 | break; |
| 183 | case MPI2_SAS_DEVICE_INFO_FANOUT_EXPANDER: |
| 184 | identify->device_type = SAS_FANOUT_EXPANDER_DEVICE; |
| 185 | break; |
| 186 | } |
| 187 | |
| 188 | /* initiator_port_protocols */ |
| 189 | if (device_info & MPI2_SAS_DEVICE_INFO_SSP_INITIATOR) |
| 190 | identify->initiator_port_protocols |= SAS_PROTOCOL_SSP; |
| 191 | if (device_info & MPI2_SAS_DEVICE_INFO_STP_INITIATOR) |
| 192 | identify->initiator_port_protocols |= SAS_PROTOCOL_STP; |
| 193 | if (device_info & MPI2_SAS_DEVICE_INFO_SMP_INITIATOR) |
| 194 | identify->initiator_port_protocols |= SAS_PROTOCOL_SMP; |
| 195 | if (device_info & MPI2_SAS_DEVICE_INFO_SATA_HOST) |
| 196 | identify->initiator_port_protocols |= SAS_PROTOCOL_SATA; |
| 197 | |
| 198 | /* target_port_protocols */ |
| 199 | if (device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET) |
| 200 | identify->target_port_protocols |= SAS_PROTOCOL_SSP; |
| 201 | if (device_info & MPI2_SAS_DEVICE_INFO_STP_TARGET) |
| 202 | identify->target_port_protocols |= SAS_PROTOCOL_STP; |
| 203 | if (device_info & MPI2_SAS_DEVICE_INFO_SMP_TARGET) |
| 204 | identify->target_port_protocols |= SAS_PROTOCOL_SMP; |
| 205 | if (device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) |
| 206 | identify->target_port_protocols |= SAS_PROTOCOL_SATA; |
| 207 | |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * mpt2sas_transport_done - internal transport layer callback handler. |
| 213 | * @ioc: per adapter object |
| 214 | * @smid: system request message index |
Kashyap, Desai | 7b936b0 | 2009-09-25 11:44:41 +0530 | [diff] [blame] | 215 | * @msix_index: MSIX table index supplied by the OS |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 216 | * @reply: reply message frame(lower 32bit addr) |
| 217 | * |
| 218 | * Callback handler when sending internal generated transport cmds. |
| 219 | * The callback index passed is `ioc->transport_cb_idx` |
| 220 | * |
Kashyap, Desai | 77e63ed | 2009-09-14 11:04:23 +0530 | [diff] [blame] | 221 | * Return 1 meaning mf should be freed from _base_interrupt |
| 222 | * 0 means the mf is freed from this function. |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 223 | */ |
Kashyap, Desai | 77e63ed | 2009-09-14 11:04:23 +0530 | [diff] [blame] | 224 | u8 |
Kashyap, Desai | 7b936b0 | 2009-09-25 11:44:41 +0530 | [diff] [blame] | 225 | mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 226 | u32 reply) |
| 227 | { |
| 228 | MPI2DefaultReply_t *mpi_reply; |
| 229 | |
| 230 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); |
| 231 | if (ioc->transport_cmds.status == MPT2_CMD_NOT_USED) |
Kashyap, Desai | 77e63ed | 2009-09-14 11:04:23 +0530 | [diff] [blame] | 232 | return 1; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 233 | if (ioc->transport_cmds.smid != smid) |
Kashyap, Desai | 77e63ed | 2009-09-14 11:04:23 +0530 | [diff] [blame] | 234 | return 1; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 235 | ioc->transport_cmds.status |= MPT2_CMD_COMPLETE; |
| 236 | if (mpi_reply) { |
| 237 | memcpy(ioc->transport_cmds.reply, mpi_reply, |
| 238 | mpi_reply->MsgLength*4); |
| 239 | ioc->transport_cmds.status |= MPT2_CMD_REPLY_VALID; |
| 240 | } |
| 241 | ioc->transport_cmds.status &= ~MPT2_CMD_PENDING; |
| 242 | complete(&ioc->transport_cmds.done); |
Kashyap, Desai | 77e63ed | 2009-09-14 11:04:23 +0530 | [diff] [blame] | 243 | return 1; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /* report manufacture request structure */ |
| 247 | struct rep_manu_request{ |
| 248 | u8 smp_frame_type; |
| 249 | u8 function; |
| 250 | u8 reserved; |
| 251 | u8 request_length; |
| 252 | }; |
| 253 | |
| 254 | /* report manufacture reply structure */ |
| 255 | struct rep_manu_reply{ |
| 256 | u8 smp_frame_type; /* 0x41 */ |
| 257 | u8 function; /* 0x01 */ |
| 258 | u8 function_result; |
| 259 | u8 response_length; |
| 260 | u16 expander_change_count; |
| 261 | u8 reserved0[2]; |
Kashyap, Desai | 463217b | 2009-10-05 15:53:06 +0530 | [diff] [blame] | 262 | u8 sas_format; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 263 | u8 reserved2[3]; |
| 264 | u8 vendor_id[SAS_EXPANDER_VENDOR_ID_LEN]; |
| 265 | u8 product_id[SAS_EXPANDER_PRODUCT_ID_LEN]; |
| 266 | u8 product_rev[SAS_EXPANDER_PRODUCT_REV_LEN]; |
| 267 | u8 component_vendor_id[SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN]; |
| 268 | u16 component_id; |
| 269 | u8 component_revision_id; |
| 270 | u8 reserved3; |
| 271 | u8 vendor_specific[8]; |
| 272 | }; |
| 273 | |
| 274 | /** |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 275 | * _transport_expander_report_manufacture - obtain SMP report_manufacture |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 276 | * @ioc: per adapter object |
| 277 | * @sas_address: expander sas address |
| 278 | * @edev: the sas_expander_device object |
| 279 | * |
| 280 | * Fills in the sas_expander_device object when SMP port is created. |
| 281 | * |
| 282 | * Returns 0 for success, non-zero for failure. |
| 283 | */ |
| 284 | static int |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 285 | _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 286 | u64 sas_address, struct sas_expander_device *edev) |
| 287 | { |
| 288 | Mpi2SmpPassthroughRequest_t *mpi_request; |
| 289 | Mpi2SmpPassthroughReply_t *mpi_reply; |
| 290 | struct rep_manu_reply *manufacture_reply; |
| 291 | struct rep_manu_request *manufacture_request; |
| 292 | int rc; |
| 293 | u16 smid; |
| 294 | u32 ioc_state; |
| 295 | unsigned long timeleft; |
| 296 | void *psge; |
| 297 | u32 sgl_flags; |
| 298 | u8 issue_reset = 0; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 299 | void *data_out = NULL; |
| 300 | dma_addr_t data_out_dma; |
| 301 | u32 sz; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 302 | u16 wait_state_count; |
| 303 | |
Eric Moore | 3cb5469 | 2010-07-08 14:44:34 -0600 | [diff] [blame] | 304 | if (ioc->shost_recovery || ioc->pci_error_recovery) { |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 305 | printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", |
| 306 | __func__, ioc->name); |
| 307 | return -EFAULT; |
| 308 | } |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 309 | |
| 310 | mutex_lock(&ioc->transport_cmds.mutex); |
| 311 | |
| 312 | if (ioc->transport_cmds.status != MPT2_CMD_NOT_USED) { |
| 313 | printk(MPT2SAS_ERR_FMT "%s: transport_cmds in use\n", |
| 314 | ioc->name, __func__); |
| 315 | rc = -EAGAIN; |
| 316 | goto out; |
| 317 | } |
| 318 | ioc->transport_cmds.status = MPT2_CMD_PENDING; |
| 319 | |
| 320 | wait_state_count = 0; |
| 321 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 322 | while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
| 323 | if (wait_state_count++ == 10) { |
| 324 | printk(MPT2SAS_ERR_FMT |
| 325 | "%s: failed due to ioc not operational\n", |
| 326 | ioc->name, __func__); |
| 327 | rc = -EFAULT; |
| 328 | goto out; |
| 329 | } |
| 330 | ssleep(1); |
| 331 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 332 | printk(MPT2SAS_INFO_FMT "%s: waiting for " |
| 333 | "operational state(count=%d)\n", ioc->name, |
| 334 | __func__, wait_state_count); |
| 335 | } |
| 336 | if (wait_state_count) |
| 337 | printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", |
| 338 | ioc->name, __func__); |
| 339 | |
| 340 | smid = mpt2sas_base_get_smid(ioc, ioc->transport_cb_idx); |
| 341 | if (!smid) { |
| 342 | printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", |
| 343 | ioc->name, __func__); |
| 344 | rc = -EAGAIN; |
| 345 | goto out; |
| 346 | } |
| 347 | |
| 348 | rc = 0; |
| 349 | mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); |
| 350 | ioc->transport_cmds.smid = smid; |
| 351 | |
| 352 | sz = sizeof(struct rep_manu_request) + sizeof(struct rep_manu_reply); |
| 353 | data_out = pci_alloc_consistent(ioc->pdev, sz, &data_out_dma); |
| 354 | |
| 355 | if (!data_out) { |
| 356 | printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, |
| 357 | __LINE__, __func__); |
| 358 | rc = -ENOMEM; |
| 359 | mpt2sas_base_free_smid(ioc, smid); |
| 360 | goto out; |
| 361 | } |
| 362 | |
| 363 | manufacture_request = data_out; |
| 364 | manufacture_request->smp_frame_type = 0x40; |
| 365 | manufacture_request->function = 1; |
| 366 | manufacture_request->reserved = 0; |
| 367 | manufacture_request->request_length = 0; |
| 368 | |
| 369 | memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t)); |
| 370 | mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; |
| 371 | mpi_request->PhysicalPort = 0xFF; |
Kashyap, Desai | 7b936b0 | 2009-09-25 11:44:41 +0530 | [diff] [blame] | 372 | mpi_request->VF_ID = 0; /* TODO */ |
| 373 | mpi_request->VP_ID = 0; |
Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 374 | mpi_request->SASAddress = cpu_to_le64(sas_address); |
Kashyap, Desai | 463217b | 2009-10-05 15:53:06 +0530 | [diff] [blame] | 375 | mpi_request->RequestDataLength = |
| 376 | cpu_to_le16(sizeof(struct rep_manu_request)); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 377 | psge = &mpi_request->SGL; |
| 378 | |
| 379 | /* WRITE sgel first */ |
| 380 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 381 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); |
| 382 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
| 383 | ioc->base_add_sg_single(psge, sgl_flags | |
| 384 | sizeof(struct rep_manu_request), data_out_dma); |
| 385 | |
| 386 | /* incr sgel */ |
| 387 | psge += ioc->sge_size; |
| 388 | |
| 389 | /* READ sgel last */ |
| 390 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 391 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | |
| 392 | MPI2_SGE_FLAGS_END_OF_LIST); |
| 393 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
| 394 | ioc->base_add_sg_single(psge, sgl_flags | |
| 395 | sizeof(struct rep_manu_reply), data_out_dma + |
| 396 | sizeof(struct rep_manu_request)); |
| 397 | |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 398 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "report_manufacture - " |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 399 | "send to sas_addr(0x%016llx)\n", ioc->name, |
| 400 | (unsigned long long)sas_address)); |
Kashyap, Desai | bcfb6e6 | 2009-09-14 11:05:24 +0530 | [diff] [blame] | 401 | init_completion(&ioc->transport_cmds.done); |
nagalakshmi.nandigama@lsi.com | f01690d | 2011-12-01 07:43:58 +0530 | [diff] [blame] | 402 | mpt2sas_base_put_smid_default(ioc, smid); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 403 | timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done, |
| 404 | 10*HZ); |
| 405 | |
| 406 | if (!(ioc->transport_cmds.status & MPT2_CMD_COMPLETE)) { |
| 407 | printk(MPT2SAS_ERR_FMT "%s: timeout\n", |
| 408 | ioc->name, __func__); |
| 409 | _debug_dump_mf(mpi_request, |
| 410 | sizeof(Mpi2SmpPassthroughRequest_t)/4); |
| 411 | if (!(ioc->transport_cmds.status & MPT2_CMD_RESET)) |
| 412 | issue_reset = 1; |
| 413 | goto issue_host_reset; |
| 414 | } |
| 415 | |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 416 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "report_manufacture - " |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 417 | "complete\n", ioc->name)); |
| 418 | |
| 419 | if (ioc->transport_cmds.status & MPT2_CMD_REPLY_VALID) { |
| 420 | u8 *tmp; |
| 421 | |
| 422 | mpi_reply = ioc->transport_cmds.reply; |
| 423 | |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 424 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 425 | "report_manufacture - reply data transfer size(%d)\n", |
| 426 | ioc->name, le16_to_cpu(mpi_reply->ResponseDataLength))); |
| 427 | |
| 428 | if (le16_to_cpu(mpi_reply->ResponseDataLength) != |
| 429 | sizeof(struct rep_manu_reply)) |
| 430 | goto out; |
| 431 | |
| 432 | manufacture_reply = data_out + sizeof(struct rep_manu_request); |
| 433 | strncpy(edev->vendor_id, manufacture_reply->vendor_id, |
| 434 | SAS_EXPANDER_VENDOR_ID_LEN); |
| 435 | strncpy(edev->product_id, manufacture_reply->product_id, |
| 436 | SAS_EXPANDER_PRODUCT_ID_LEN); |
| 437 | strncpy(edev->product_rev, manufacture_reply->product_rev, |
| 438 | SAS_EXPANDER_PRODUCT_REV_LEN); |
Kashyap, Desai | 463217b | 2009-10-05 15:53:06 +0530 | [diff] [blame] | 439 | edev->level = manufacture_reply->sas_format & 1; |
| 440 | if (edev->level) { |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 441 | strncpy(edev->component_vendor_id, |
| 442 | manufacture_reply->component_vendor_id, |
| 443 | SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN); |
| 444 | tmp = (u8 *)&manufacture_reply->component_id; |
| 445 | edev->component_id = tmp[0] << 8 | tmp[1]; |
| 446 | edev->component_revision_id = |
| 447 | manufacture_reply->component_revision_id; |
| 448 | } |
| 449 | } else |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 450 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 451 | "report_manufacture - no reply\n", ioc->name)); |
| 452 | |
| 453 | issue_host_reset: |
| 454 | if (issue_reset) |
| 455 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, |
| 456 | FORCE_BIG_HAMMER); |
| 457 | out: |
| 458 | ioc->transport_cmds.status = MPT2_CMD_NOT_USED; |
| 459 | if (data_out) |
| 460 | pci_free_consistent(ioc->pdev, sz, data_out, data_out_dma); |
| 461 | |
| 462 | mutex_unlock(&ioc->transport_cmds.mutex); |
| 463 | return rc; |
| 464 | } |
| 465 | |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 466 | /** |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 467 | * _transport_delete_port - helper function to removing a port |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 468 | * @ioc: per adapter object |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 469 | * @mpt2sas_port: mpt2sas per port object |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 470 | * |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 471 | * Returns nothing. |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 472 | */ |
| 473 | static void |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 474 | _transport_delete_port(struct MPT2SAS_ADAPTER *ioc, |
| 475 | struct _sas_port *mpt2sas_port) |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 476 | { |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 477 | u64 sas_address = mpt2sas_port->remote_identify.sas_address; |
| 478 | enum sas_device_type device_type = |
| 479 | mpt2sas_port->remote_identify.device_type; |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 480 | |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 481 | dev_printk(KERN_INFO, &mpt2sas_port->port->dev, |
| 482 | "remove: sas_addr(0x%016llx)\n", |
| 483 | (unsigned long long) sas_address); |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 484 | |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 485 | ioc->logging_level |= MPT_DEBUG_TRANSPORT; |
| 486 | if (device_type == SAS_END_DEVICE) |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 487 | mpt2sas_device_remove_by_sas_address(ioc, sas_address); |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 488 | else if (device_type == SAS_EDGE_EXPANDER_DEVICE || |
| 489 | device_type == SAS_FANOUT_EXPANDER_DEVICE) |
| 490 | mpt2sas_expander_remove(ioc, sas_address); |
| 491 | ioc->logging_level &= ~MPT_DEBUG_TRANSPORT; |
| 492 | } |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 493 | |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 494 | /** |
| 495 | * _transport_delete_phy - helper function to removing single phy from port |
| 496 | * @ioc: per adapter object |
| 497 | * @mpt2sas_port: mpt2sas per port object |
| 498 | * @mpt2sas_phy: mpt2sas per phy object |
| 499 | * |
| 500 | * Returns nothing. |
| 501 | */ |
| 502 | static void |
| 503 | _transport_delete_phy(struct MPT2SAS_ADAPTER *ioc, |
| 504 | struct _sas_port *mpt2sas_port, struct _sas_phy *mpt2sas_phy) |
| 505 | { |
| 506 | u64 sas_address = mpt2sas_port->remote_identify.sas_address; |
| 507 | |
| 508 | dev_printk(KERN_INFO, &mpt2sas_phy->phy->dev, |
| 509 | "remove: sas_addr(0x%016llx), phy(%d)\n", |
| 510 | (unsigned long long) sas_address, mpt2sas_phy->phy_id); |
| 511 | |
| 512 | list_del(&mpt2sas_phy->port_siblings); |
| 513 | mpt2sas_port->num_phys--; |
| 514 | sas_port_delete_phy(mpt2sas_port->port, mpt2sas_phy->phy); |
| 515 | mpt2sas_phy->phy_belongs_to_port = 0; |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * _transport_add_phy - helper function to adding single phy to port |
| 520 | * @ioc: per adapter object |
| 521 | * @mpt2sas_port: mpt2sas per port object |
| 522 | * @mpt2sas_phy: mpt2sas per phy object |
| 523 | * |
| 524 | * Returns nothing. |
| 525 | */ |
| 526 | static void |
| 527 | _transport_add_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_port *mpt2sas_port, |
| 528 | struct _sas_phy *mpt2sas_phy) |
| 529 | { |
| 530 | u64 sas_address = mpt2sas_port->remote_identify.sas_address; |
| 531 | |
| 532 | dev_printk(KERN_INFO, &mpt2sas_phy->phy->dev, |
| 533 | "add: sas_addr(0x%016llx), phy(%d)\n", (unsigned long long) |
| 534 | sas_address, mpt2sas_phy->phy_id); |
| 535 | |
| 536 | list_add_tail(&mpt2sas_phy->port_siblings, &mpt2sas_port->phy_list); |
| 537 | mpt2sas_port->num_phys++; |
| 538 | sas_port_add_phy(mpt2sas_port->port, mpt2sas_phy->phy); |
| 539 | mpt2sas_phy->phy_belongs_to_port = 1; |
| 540 | } |
| 541 | |
| 542 | /** |
| 543 | * _transport_add_phy_to_an_existing_port - adding new phy to existing port |
| 544 | * @ioc: per adapter object |
| 545 | * @sas_node: sas node object (either expander or sas host) |
| 546 | * @mpt2sas_phy: mpt2sas per phy object |
| 547 | * @sas_address: sas address of device/expander were phy needs to be added to |
| 548 | * |
| 549 | * Returns nothing. |
| 550 | */ |
| 551 | static void |
| 552 | _transport_add_phy_to_an_existing_port(struct MPT2SAS_ADAPTER *ioc, |
| 553 | struct _sas_node *sas_node, struct _sas_phy *mpt2sas_phy, u64 sas_address) |
| 554 | { |
| 555 | struct _sas_port *mpt2sas_port; |
| 556 | struct _sas_phy *phy_srch; |
| 557 | |
| 558 | if (mpt2sas_phy->phy_belongs_to_port == 1) |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 559 | return; |
| 560 | |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 561 | list_for_each_entry(mpt2sas_port, &sas_node->sas_port_list, |
| 562 | port_list) { |
| 563 | if (mpt2sas_port->remote_identify.sas_address != |
| 564 | sas_address) |
| 565 | continue; |
| 566 | list_for_each_entry(phy_srch, &mpt2sas_port->phy_list, |
| 567 | port_siblings) { |
| 568 | if (phy_srch == mpt2sas_phy) |
| 569 | return; |
| 570 | } |
| 571 | _transport_add_phy(ioc, mpt2sas_port, mpt2sas_phy); |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | } |
| 576 | |
| 577 | /** |
| 578 | * _transport_del_phy_from_an_existing_port - delete phy from existing port |
| 579 | * @ioc: per adapter object |
| 580 | * @sas_node: sas node object (either expander or sas host) |
| 581 | * @mpt2sas_phy: mpt2sas per phy object |
| 582 | * |
| 583 | * Returns nothing. |
| 584 | */ |
| 585 | static void |
| 586 | _transport_del_phy_from_an_existing_port(struct MPT2SAS_ADAPTER *ioc, |
| 587 | struct _sas_node *sas_node, struct _sas_phy *mpt2sas_phy) |
| 588 | { |
| 589 | struct _sas_port *mpt2sas_port, *next; |
| 590 | struct _sas_phy *phy_srch; |
| 591 | |
| 592 | if (mpt2sas_phy->phy_belongs_to_port == 0) |
| 593 | return; |
| 594 | |
| 595 | list_for_each_entry_safe(mpt2sas_port, next, &sas_node->sas_port_list, |
| 596 | port_list) { |
| 597 | list_for_each_entry(phy_srch, &mpt2sas_port->phy_list, |
| 598 | port_siblings) { |
| 599 | if (phy_srch != mpt2sas_phy) |
| 600 | continue; |
| 601 | if (mpt2sas_port->num_phys == 1) |
| 602 | _transport_delete_port(ioc, mpt2sas_port); |
| 603 | else |
| 604 | _transport_delete_phy(ioc, mpt2sas_port, |
| 605 | mpt2sas_phy); |
| 606 | return; |
| 607 | } |
| 608 | } |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /** |
| 612 | * _transport_sanity_check - sanity check when adding a new port |
| 613 | * @ioc: per adapter object |
| 614 | * @sas_node: sas node object (either expander or sas host) |
| 615 | * @sas_address: sas address of device being added |
| 616 | * |
| 617 | * See the explanation above from _transport_delete_duplicate_port |
| 618 | */ |
| 619 | static void |
| 620 | _transport_sanity_check(struct MPT2SAS_ADAPTER *ioc, struct _sas_node *sas_node, |
| 621 | u64 sas_address) |
| 622 | { |
| 623 | int i; |
| 624 | |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 625 | for (i = 0; i < sas_node->num_phys; i++) { |
| 626 | if (sas_node->phy[i].remote_identify.sas_address != sas_address) |
| 627 | continue; |
| 628 | if (sas_node->phy[i].phy_belongs_to_port == 1) |
| 629 | _transport_del_phy_from_an_existing_port(ioc, sas_node, |
| 630 | &sas_node->phy[i]); |
| 631 | } |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 632 | } |
| 633 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 634 | /** |
| 635 | * mpt2sas_transport_port_add - insert port to the list |
| 636 | * @ioc: per adapter object |
| 637 | * @handle: handle of attached device |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 638 | * @sas_address: sas address of parent expander or sas host |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 639 | * Context: This function will acquire ioc->sas_node_lock. |
| 640 | * |
| 641 | * Adding new port object to the sas_node->sas_port_list. |
| 642 | * |
| 643 | * Returns mpt2sas_port. |
| 644 | */ |
| 645 | struct _sas_port * |
| 646 | mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle, |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 647 | u64 sas_address) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 648 | { |
| 649 | struct _sas_phy *mpt2sas_phy, *next; |
| 650 | struct _sas_port *mpt2sas_port; |
| 651 | unsigned long flags; |
| 652 | struct _sas_node *sas_node; |
| 653 | struct sas_rphy *rphy; |
| 654 | int i; |
| 655 | struct sas_port *port; |
| 656 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 657 | mpt2sas_port = kzalloc(sizeof(struct _sas_port), |
| 658 | GFP_KERNEL); |
| 659 | if (!mpt2sas_port) { |
| 660 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 661 | ioc->name, __FILE__, __LINE__, __func__); |
| 662 | return NULL; |
| 663 | } |
| 664 | |
| 665 | INIT_LIST_HEAD(&mpt2sas_port->port_list); |
| 666 | INIT_LIST_HEAD(&mpt2sas_port->phy_list); |
| 667 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 668 | sas_node = _transport_sas_node_find_by_sas_address(ioc, sas_address); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 669 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
| 670 | |
| 671 | if (!sas_node) { |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 672 | printk(MPT2SAS_ERR_FMT "%s: Could not find " |
| 673 | "parent sas_address(0x%016llx)!\n", ioc->name, |
| 674 | __func__, (unsigned long long)sas_address); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 675 | goto out_fail; |
| 676 | } |
| 677 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 678 | if ((_transport_set_identify(ioc, handle, |
| 679 | &mpt2sas_port->remote_identify))) { |
| 680 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 681 | ioc->name, __FILE__, __LINE__, __func__); |
| 682 | goto out_fail; |
| 683 | } |
| 684 | |
| 685 | if (mpt2sas_port->remote_identify.device_type == SAS_PHY_UNUSED) { |
| 686 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 687 | ioc->name, __FILE__, __LINE__, __func__); |
| 688 | goto out_fail; |
| 689 | } |
| 690 | |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 691 | _transport_sanity_check(ioc, sas_node, |
| 692 | mpt2sas_port->remote_identify.sas_address); |
| 693 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 694 | for (i = 0; i < sas_node->num_phys; i++) { |
| 695 | if (sas_node->phy[i].remote_identify.sas_address != |
| 696 | mpt2sas_port->remote_identify.sas_address) |
| 697 | continue; |
| 698 | list_add_tail(&sas_node->phy[i].port_siblings, |
| 699 | &mpt2sas_port->phy_list); |
| 700 | mpt2sas_port->num_phys++; |
| 701 | } |
| 702 | |
| 703 | if (!mpt2sas_port->num_phys) { |
| 704 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 705 | ioc->name, __FILE__, __LINE__, __func__); |
| 706 | goto out_fail; |
| 707 | } |
| 708 | |
| 709 | port = sas_port_alloc_num(sas_node->parent_dev); |
| 710 | if ((sas_port_add(port))) { |
| 711 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 712 | ioc->name, __FILE__, __LINE__, __func__); |
| 713 | goto out_fail; |
| 714 | } |
| 715 | |
| 716 | list_for_each_entry(mpt2sas_phy, &mpt2sas_port->phy_list, |
| 717 | port_siblings) { |
| 718 | if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) |
| 719 | dev_printk(KERN_INFO, &port->dev, "add: handle(0x%04x)" |
| 720 | ", sas_addr(0x%016llx), phy(%d)\n", handle, |
| 721 | (unsigned long long) |
| 722 | mpt2sas_port->remote_identify.sas_address, |
| 723 | mpt2sas_phy->phy_id); |
| 724 | sas_port_add_phy(port, mpt2sas_phy->phy); |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 725 | mpt2sas_phy->phy_belongs_to_port = 1; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | mpt2sas_port->port = port; |
| 729 | if (mpt2sas_port->remote_identify.device_type == SAS_END_DEVICE) |
| 730 | rphy = sas_end_device_alloc(port); |
| 731 | else |
| 732 | rphy = sas_expander_alloc(port, |
| 733 | mpt2sas_port->remote_identify.device_type); |
| 734 | |
| 735 | rphy->identify = mpt2sas_port->remote_identify; |
| 736 | if ((sas_rphy_add(rphy))) { |
| 737 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 738 | ioc->name, __FILE__, __LINE__, __func__); |
| 739 | } |
| 740 | if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) |
| 741 | dev_printk(KERN_INFO, &rphy->dev, "add: handle(0x%04x), " |
| 742 | "sas_addr(0x%016llx)\n", handle, |
| 743 | (unsigned long long) |
| 744 | mpt2sas_port->remote_identify.sas_address); |
| 745 | mpt2sas_port->rphy = rphy; |
| 746 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
| 747 | list_add_tail(&mpt2sas_port->port_list, &sas_node->sas_port_list); |
| 748 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
| 749 | |
| 750 | /* fill in report manufacture */ |
| 751 | if (mpt2sas_port->remote_identify.device_type == |
| 752 | MPI2_SAS_DEVICE_INFO_EDGE_EXPANDER || |
| 753 | mpt2sas_port->remote_identify.device_type == |
| 754 | MPI2_SAS_DEVICE_INFO_FANOUT_EXPANDER) |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 755 | _transport_expander_report_manufacture(ioc, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 756 | mpt2sas_port->remote_identify.sas_address, |
| 757 | rphy_to_expander_device(rphy)); |
| 758 | |
| 759 | return mpt2sas_port; |
| 760 | |
| 761 | out_fail: |
| 762 | list_for_each_entry_safe(mpt2sas_phy, next, &mpt2sas_port->phy_list, |
| 763 | port_siblings) |
| 764 | list_del(&mpt2sas_phy->port_siblings); |
| 765 | kfree(mpt2sas_port); |
| 766 | return NULL; |
| 767 | } |
| 768 | |
| 769 | /** |
| 770 | * mpt2sas_transport_port_remove - remove port from the list |
| 771 | * @ioc: per adapter object |
| 772 | * @sas_address: sas address of attached device |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 773 | * @sas_address_parent: sas address of parent expander or sas host |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 774 | * Context: This function will acquire ioc->sas_node_lock. |
| 775 | * |
| 776 | * Removing object and freeing associated memory from the |
| 777 | * ioc->sas_port_list. |
| 778 | * |
| 779 | * Return nothing. |
| 780 | */ |
| 781 | void |
| 782 | mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 783 | u64 sas_address_parent) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 784 | { |
| 785 | int i; |
| 786 | unsigned long flags; |
| 787 | struct _sas_port *mpt2sas_port, *next; |
| 788 | struct _sas_node *sas_node; |
| 789 | u8 found = 0; |
| 790 | struct _sas_phy *mpt2sas_phy, *next_phy; |
| 791 | |
| 792 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 793 | sas_node = _transport_sas_node_find_by_sas_address(ioc, |
| 794 | sas_address_parent); |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 795 | if (!sas_node) { |
| 796 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 797 | return; |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 798 | } |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 799 | list_for_each_entry_safe(mpt2sas_port, next, &sas_node->sas_port_list, |
| 800 | port_list) { |
| 801 | if (mpt2sas_port->remote_identify.sas_address != sas_address) |
| 802 | continue; |
| 803 | found = 1; |
| 804 | list_del(&mpt2sas_port->port_list); |
| 805 | goto out; |
| 806 | } |
| 807 | out: |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 808 | if (!found) { |
| 809 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 810 | return; |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 811 | } |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 812 | |
| 813 | for (i = 0; i < sas_node->num_phys; i++) { |
| 814 | if (sas_node->phy[i].remote_identify.sas_address == sas_address) |
| 815 | memset(&sas_node->phy[i].remote_identify, 0 , |
| 816 | sizeof(struct sas_identify)); |
| 817 | } |
| 818 | |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 819 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 820 | list_for_each_entry_safe(mpt2sas_phy, next_phy, |
| 821 | &mpt2sas_port->phy_list, port_siblings) { |
| 822 | if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) |
| 823 | dev_printk(KERN_INFO, &mpt2sas_port->port->dev, |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 824 | "remove: sas_addr(0x%016llx), phy(%d)\n", |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 825 | (unsigned long long) |
| 826 | mpt2sas_port->remote_identify.sas_address, |
| 827 | mpt2sas_phy->phy_id); |
Kashyap, Desai | 38c2911 | 2010-04-05 14:18:34 +0530 | [diff] [blame] | 828 | mpt2sas_phy->phy_belongs_to_port = 0; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 829 | sas_port_delete_phy(mpt2sas_port->port, mpt2sas_phy->phy); |
| 830 | list_del(&mpt2sas_phy->port_siblings); |
| 831 | } |
| 832 | sas_port_delete(mpt2sas_port->port); |
| 833 | kfree(mpt2sas_port); |
| 834 | } |
| 835 | |
| 836 | /** |
| 837 | * mpt2sas_transport_add_host_phy - report sas_host phy to transport |
| 838 | * @ioc: per adapter object |
| 839 | * @mpt2sas_phy: mpt2sas per phy object |
| 840 | * @phy_pg0: sas phy page 0 |
| 841 | * @parent_dev: parent device class object |
| 842 | * |
| 843 | * Returns 0 for success, non-zero for failure. |
| 844 | */ |
| 845 | int |
| 846 | mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy |
| 847 | *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev) |
| 848 | { |
| 849 | struct sas_phy *phy; |
| 850 | int phy_index = mpt2sas_phy->phy_id; |
| 851 | |
| 852 | |
| 853 | INIT_LIST_HEAD(&mpt2sas_phy->port_siblings); |
| 854 | phy = sas_phy_alloc(parent_dev, phy_index); |
| 855 | if (!phy) { |
| 856 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 857 | ioc->name, __FILE__, __LINE__, __func__); |
| 858 | return -1; |
| 859 | } |
| 860 | if ((_transport_set_identify(ioc, mpt2sas_phy->handle, |
| 861 | &mpt2sas_phy->identify))) { |
| 862 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 863 | ioc->name, __FILE__, __LINE__, __func__); |
| 864 | return -1; |
| 865 | } |
| 866 | phy->identify = mpt2sas_phy->identify; |
| 867 | mpt2sas_phy->attached_handle = le16_to_cpu(phy_pg0.AttachedDevHandle); |
| 868 | if (mpt2sas_phy->attached_handle) |
| 869 | _transport_set_identify(ioc, mpt2sas_phy->attached_handle, |
| 870 | &mpt2sas_phy->remote_identify); |
| 871 | phy->identify.phy_identifier = mpt2sas_phy->phy_id; |
| 872 | phy->negotiated_linkrate = _transport_convert_phy_link_rate( |
| 873 | phy_pg0.NegotiatedLinkRate & MPI2_SAS_NEG_LINK_RATE_MASK_PHYSICAL); |
| 874 | phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( |
| 875 | phy_pg0.HwLinkRate & MPI2_SAS_HWRATE_MIN_RATE_MASK); |
| 876 | phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( |
| 877 | phy_pg0.HwLinkRate >> 4); |
| 878 | phy->minimum_linkrate = _transport_convert_phy_link_rate( |
| 879 | phy_pg0.ProgrammedLinkRate & MPI2_SAS_PRATE_MIN_RATE_MASK); |
| 880 | phy->maximum_linkrate = _transport_convert_phy_link_rate( |
| 881 | phy_pg0.ProgrammedLinkRate >> 4); |
| 882 | |
| 883 | if ((sas_phy_add(phy))) { |
| 884 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 885 | ioc->name, __FILE__, __LINE__, __func__); |
| 886 | sas_phy_free(phy); |
| 887 | return -1; |
| 888 | } |
| 889 | if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) |
| 890 | dev_printk(KERN_INFO, &phy->dev, |
| 891 | "add: handle(0x%04x), sas_addr(0x%016llx)\n" |
| 892 | "\tattached_handle(0x%04x), sas_addr(0x%016llx)\n", |
| 893 | mpt2sas_phy->handle, (unsigned long long) |
| 894 | mpt2sas_phy->identify.sas_address, |
| 895 | mpt2sas_phy->attached_handle, |
| 896 | (unsigned long long) |
| 897 | mpt2sas_phy->remote_identify.sas_address); |
| 898 | mpt2sas_phy->phy = phy; |
| 899 | return 0; |
| 900 | } |
| 901 | |
| 902 | |
| 903 | /** |
| 904 | * mpt2sas_transport_add_expander_phy - report expander phy to transport |
| 905 | * @ioc: per adapter object |
| 906 | * @mpt2sas_phy: mpt2sas per phy object |
| 907 | * @expander_pg1: expander page 1 |
| 908 | * @parent_dev: parent device class object |
| 909 | * |
| 910 | * Returns 0 for success, non-zero for failure. |
| 911 | */ |
| 912 | int |
| 913 | mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy |
| 914 | *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev) |
| 915 | { |
| 916 | struct sas_phy *phy; |
| 917 | int phy_index = mpt2sas_phy->phy_id; |
| 918 | |
| 919 | INIT_LIST_HEAD(&mpt2sas_phy->port_siblings); |
| 920 | phy = sas_phy_alloc(parent_dev, phy_index); |
| 921 | if (!phy) { |
| 922 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 923 | ioc->name, __FILE__, __LINE__, __func__); |
| 924 | return -1; |
| 925 | } |
| 926 | if ((_transport_set_identify(ioc, mpt2sas_phy->handle, |
| 927 | &mpt2sas_phy->identify))) { |
| 928 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 929 | ioc->name, __FILE__, __LINE__, __func__); |
| 930 | return -1; |
| 931 | } |
| 932 | phy->identify = mpt2sas_phy->identify; |
| 933 | mpt2sas_phy->attached_handle = |
| 934 | le16_to_cpu(expander_pg1.AttachedDevHandle); |
| 935 | if (mpt2sas_phy->attached_handle) |
| 936 | _transport_set_identify(ioc, mpt2sas_phy->attached_handle, |
| 937 | &mpt2sas_phy->remote_identify); |
| 938 | phy->identify.phy_identifier = mpt2sas_phy->phy_id; |
| 939 | phy->negotiated_linkrate = _transport_convert_phy_link_rate( |
| 940 | expander_pg1.NegotiatedLinkRate & |
| 941 | MPI2_SAS_NEG_LINK_RATE_MASK_PHYSICAL); |
| 942 | phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( |
| 943 | expander_pg1.HwLinkRate & MPI2_SAS_HWRATE_MIN_RATE_MASK); |
| 944 | phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( |
| 945 | expander_pg1.HwLinkRate >> 4); |
| 946 | phy->minimum_linkrate = _transport_convert_phy_link_rate( |
| 947 | expander_pg1.ProgrammedLinkRate & MPI2_SAS_PRATE_MIN_RATE_MASK); |
| 948 | phy->maximum_linkrate = _transport_convert_phy_link_rate( |
| 949 | expander_pg1.ProgrammedLinkRate >> 4); |
| 950 | |
| 951 | if ((sas_phy_add(phy))) { |
| 952 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 953 | ioc->name, __FILE__, __LINE__, __func__); |
| 954 | sas_phy_free(phy); |
| 955 | return -1; |
| 956 | } |
| 957 | if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) |
| 958 | dev_printk(KERN_INFO, &phy->dev, |
| 959 | "add: handle(0x%04x), sas_addr(0x%016llx)\n" |
| 960 | "\tattached_handle(0x%04x), sas_addr(0x%016llx)\n", |
| 961 | mpt2sas_phy->handle, (unsigned long long) |
| 962 | mpt2sas_phy->identify.sas_address, |
| 963 | mpt2sas_phy->attached_handle, |
| 964 | (unsigned long long) |
| 965 | mpt2sas_phy->remote_identify.sas_address); |
| 966 | mpt2sas_phy->phy = phy; |
| 967 | return 0; |
| 968 | } |
| 969 | |
| 970 | /** |
Kashyap, Desai | cc0f520 | 2009-08-20 13:22:39 +0530 | [diff] [blame] | 971 | * mpt2sas_transport_update_links - refreshing phy link changes |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 972 | * @ioc: per adapter object |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 973 | * @sas_address: sas address of parent expander or sas host |
| 974 | * @handle: attached device handle |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 975 | * @phy_numberv: phy number |
| 976 | * @link_rate: new link rate |
| 977 | * |
| 978 | * Returns nothing. |
| 979 | */ |
| 980 | void |
Kashyap, Desai | cc0f520 | 2009-08-20 13:22:39 +0530 | [diff] [blame] | 981 | mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 982 | u64 sas_address, u16 handle, u8 phy_number, u8 link_rate) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 983 | { |
| 984 | unsigned long flags; |
| 985 | struct _sas_node *sas_node; |
| 986 | struct _sas_phy *mpt2sas_phy; |
| 987 | |
Eric Moore | 3cb5469 | 2010-07-08 14:44:34 -0600 | [diff] [blame] | 988 | if (ioc->shost_recovery || ioc->pci_error_recovery) |
Kashyap, Desai | 155dd4c | 2009-08-20 13:22:00 +0530 | [diff] [blame] | 989 | return; |
Kashyap, Desai | 155dd4c | 2009-08-20 13:22:00 +0530 | [diff] [blame] | 990 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 991 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 992 | sas_node = _transport_sas_node_find_by_sas_address(ioc, sas_address); |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 993 | if (!sas_node) { |
| 994 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 995 | return; |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 996 | } |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 997 | |
| 998 | mpt2sas_phy = &sas_node->phy[phy_number]; |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 999 | mpt2sas_phy->attached_handle = handle; |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1000 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 1001 | if (handle && (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5)) { |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 1002 | _transport_set_identify(ioc, handle, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1003 | &mpt2sas_phy->remote_identify); |
Kashyap, Desai | 7f6f794 | 2010-11-13 04:35:30 +0530 | [diff] [blame] | 1004 | _transport_add_phy_to_an_existing_port(ioc, sas_node, |
| 1005 | mpt2sas_phy, mpt2sas_phy->remote_identify.sas_address); |
| 1006 | } else |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1007 | memset(&mpt2sas_phy->remote_identify, 0 , sizeof(struct |
| 1008 | sas_identify)); |
| 1009 | |
| 1010 | if (mpt2sas_phy->phy) |
| 1011 | mpt2sas_phy->phy->negotiated_linkrate = |
| 1012 | _transport_convert_phy_link_rate(link_rate); |
| 1013 | |
| 1014 | if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) |
| 1015 | dev_printk(KERN_INFO, &mpt2sas_phy->phy->dev, |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 1016 | "refresh: parent sas_addr(0x%016llx),\n" |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1017 | "\tlink_rate(0x%02x), phy(%d)\n" |
| 1018 | "\tattached_handle(0x%04x), sas_addr(0x%016llx)\n", |
Kashyap, Desai | c5e039b | 2009-09-23 17:21:29 +0530 | [diff] [blame] | 1019 | (unsigned long long)sas_address, |
| 1020 | link_rate, phy_number, handle, (unsigned long long) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1021 | mpt2sas_phy->remote_identify.sas_address); |
| 1022 | } |
| 1023 | |
| 1024 | static inline void * |
| 1025 | phy_to_ioc(struct sas_phy *phy) |
| 1026 | { |
| 1027 | struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); |
| 1028 | return shost_priv(shost); |
| 1029 | } |
| 1030 | |
| 1031 | static inline void * |
| 1032 | rphy_to_ioc(struct sas_rphy *rphy) |
| 1033 | { |
| 1034 | struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); |
| 1035 | return shost_priv(shost); |
| 1036 | } |
| 1037 | |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1038 | |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1039 | /* report phy error log structure */ |
| 1040 | struct phy_error_log_request{ |
| 1041 | u8 smp_frame_type; /* 0x40 */ |
| 1042 | u8 function; /* 0x11 */ |
| 1043 | u8 allocated_response_length; |
| 1044 | u8 request_length; /* 02 */ |
| 1045 | u8 reserved_1[5]; |
| 1046 | u8 phy_identifier; |
| 1047 | u8 reserved_2[2]; |
| 1048 | }; |
| 1049 | |
| 1050 | /* report phy error log reply structure */ |
| 1051 | struct phy_error_log_reply{ |
| 1052 | u8 smp_frame_type; /* 0x41 */ |
| 1053 | u8 function; /* 0x11 */ |
| 1054 | u8 function_result; |
| 1055 | u8 response_length; |
Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 1056 | __be16 expander_change_count; |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1057 | u8 reserved_1[3]; |
| 1058 | u8 phy_identifier; |
| 1059 | u8 reserved_2[2]; |
Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 1060 | __be32 invalid_dword; |
| 1061 | __be32 running_disparity_error; |
| 1062 | __be32 loss_of_dword_sync; |
| 1063 | __be32 phy_reset_problem; |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1064 | }; |
| 1065 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1066 | /** |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1067 | * _transport_get_expander_phy_error_log - return expander counters |
| 1068 | * @ioc: per adapter object |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1069 | * @phy: The sas phy object |
| 1070 | * |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1071 | * Returns 0 for success, non-zero for failure. |
| 1072 | * |
| 1073 | */ |
| 1074 | static int |
| 1075 | _transport_get_expander_phy_error_log(struct MPT2SAS_ADAPTER *ioc, |
| 1076 | struct sas_phy *phy) |
| 1077 | { |
| 1078 | Mpi2SmpPassthroughRequest_t *mpi_request; |
| 1079 | Mpi2SmpPassthroughReply_t *mpi_reply; |
| 1080 | struct phy_error_log_request *phy_error_log_request; |
| 1081 | struct phy_error_log_reply *phy_error_log_reply; |
| 1082 | int rc; |
| 1083 | u16 smid; |
| 1084 | u32 ioc_state; |
| 1085 | unsigned long timeleft; |
| 1086 | void *psge; |
| 1087 | u32 sgl_flags; |
| 1088 | u8 issue_reset = 0; |
| 1089 | void *data_out = NULL; |
| 1090 | dma_addr_t data_out_dma; |
| 1091 | u32 sz; |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1092 | u16 wait_state_count; |
| 1093 | |
Eric Moore | 3cb5469 | 2010-07-08 14:44:34 -0600 | [diff] [blame] | 1094 | if (ioc->shost_recovery || ioc->pci_error_recovery) { |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1095 | printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", |
| 1096 | __func__, ioc->name); |
| 1097 | return -EFAULT; |
| 1098 | } |
| 1099 | |
| 1100 | mutex_lock(&ioc->transport_cmds.mutex); |
| 1101 | |
| 1102 | if (ioc->transport_cmds.status != MPT2_CMD_NOT_USED) { |
| 1103 | printk(MPT2SAS_ERR_FMT "%s: transport_cmds in use\n", |
| 1104 | ioc->name, __func__); |
| 1105 | rc = -EAGAIN; |
| 1106 | goto out; |
| 1107 | } |
| 1108 | ioc->transport_cmds.status = MPT2_CMD_PENDING; |
| 1109 | |
| 1110 | wait_state_count = 0; |
| 1111 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 1112 | while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
| 1113 | if (wait_state_count++ == 10) { |
| 1114 | printk(MPT2SAS_ERR_FMT |
| 1115 | "%s: failed due to ioc not operational\n", |
| 1116 | ioc->name, __func__); |
| 1117 | rc = -EFAULT; |
| 1118 | goto out; |
| 1119 | } |
| 1120 | ssleep(1); |
| 1121 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 1122 | printk(MPT2SAS_INFO_FMT "%s: waiting for " |
| 1123 | "operational state(count=%d)\n", ioc->name, |
| 1124 | __func__, wait_state_count); |
| 1125 | } |
| 1126 | if (wait_state_count) |
| 1127 | printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", |
| 1128 | ioc->name, __func__); |
| 1129 | |
| 1130 | smid = mpt2sas_base_get_smid(ioc, ioc->transport_cb_idx); |
| 1131 | if (!smid) { |
| 1132 | printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", |
| 1133 | ioc->name, __func__); |
| 1134 | rc = -EAGAIN; |
| 1135 | goto out; |
| 1136 | } |
| 1137 | |
| 1138 | mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); |
| 1139 | ioc->transport_cmds.smid = smid; |
| 1140 | |
| 1141 | sz = sizeof(struct phy_error_log_request) + |
| 1142 | sizeof(struct phy_error_log_reply); |
| 1143 | data_out = pci_alloc_consistent(ioc->pdev, sz, &data_out_dma); |
| 1144 | if (!data_out) { |
| 1145 | printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, |
| 1146 | __LINE__, __func__); |
| 1147 | rc = -ENOMEM; |
| 1148 | mpt2sas_base_free_smid(ioc, smid); |
| 1149 | goto out; |
| 1150 | } |
| 1151 | |
| 1152 | rc = -EINVAL; |
| 1153 | memset(data_out, 0, sz); |
| 1154 | phy_error_log_request = data_out; |
| 1155 | phy_error_log_request->smp_frame_type = 0x40; |
| 1156 | phy_error_log_request->function = 0x11; |
| 1157 | phy_error_log_request->request_length = 2; |
| 1158 | phy_error_log_request->allocated_response_length = 0; |
| 1159 | phy_error_log_request->phy_identifier = phy->number; |
| 1160 | |
| 1161 | memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t)); |
| 1162 | mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; |
| 1163 | mpi_request->PhysicalPort = 0xFF; |
| 1164 | mpi_request->VF_ID = 0; /* TODO */ |
| 1165 | mpi_request->VP_ID = 0; |
Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 1166 | mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1167 | mpi_request->RequestDataLength = |
| 1168 | cpu_to_le16(sizeof(struct phy_error_log_request)); |
| 1169 | psge = &mpi_request->SGL; |
| 1170 | |
| 1171 | /* WRITE sgel first */ |
| 1172 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 1173 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); |
| 1174 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
| 1175 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1176 | sizeof(struct phy_error_log_request), data_out_dma); |
| 1177 | |
| 1178 | /* incr sgel */ |
| 1179 | psge += ioc->sge_size; |
| 1180 | |
| 1181 | /* READ sgel last */ |
| 1182 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 1183 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | |
| 1184 | MPI2_SGE_FLAGS_END_OF_LIST); |
| 1185 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
| 1186 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1187 | sizeof(struct phy_error_log_reply), data_out_dma + |
| 1188 | sizeof(struct phy_error_log_request)); |
| 1189 | |
| 1190 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "phy_error_log - " |
| 1191 | "send to sas_addr(0x%016llx), phy(%d)\n", ioc->name, |
| 1192 | (unsigned long long)phy->identify.sas_address, phy->number)); |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1193 | init_completion(&ioc->transport_cmds.done); |
nagalakshmi.nandigama@lsi.com | f01690d | 2011-12-01 07:43:58 +0530 | [diff] [blame] | 1194 | mpt2sas_base_put_smid_default(ioc, smid); |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1195 | timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done, |
| 1196 | 10*HZ); |
| 1197 | |
| 1198 | if (!(ioc->transport_cmds.status & MPT2_CMD_COMPLETE)) { |
| 1199 | printk(MPT2SAS_ERR_FMT "%s: timeout\n", |
| 1200 | ioc->name, __func__); |
| 1201 | _debug_dump_mf(mpi_request, |
| 1202 | sizeof(Mpi2SmpPassthroughRequest_t)/4); |
| 1203 | if (!(ioc->transport_cmds.status & MPT2_CMD_RESET)) |
| 1204 | issue_reset = 1; |
| 1205 | goto issue_host_reset; |
| 1206 | } |
| 1207 | |
| 1208 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "phy_error_log - " |
| 1209 | "complete\n", ioc->name)); |
| 1210 | |
| 1211 | if (ioc->transport_cmds.status & MPT2_CMD_REPLY_VALID) { |
| 1212 | |
| 1213 | mpi_reply = ioc->transport_cmds.reply; |
| 1214 | |
| 1215 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
| 1216 | "phy_error_log - reply data transfer size(%d)\n", |
| 1217 | ioc->name, le16_to_cpu(mpi_reply->ResponseDataLength))); |
| 1218 | |
| 1219 | if (le16_to_cpu(mpi_reply->ResponseDataLength) != |
| 1220 | sizeof(struct phy_error_log_reply)) |
| 1221 | goto out; |
| 1222 | |
| 1223 | phy_error_log_reply = data_out + |
| 1224 | sizeof(struct phy_error_log_request); |
| 1225 | |
| 1226 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
| 1227 | "phy_error_log - function_result(%d)\n", |
| 1228 | ioc->name, phy_error_log_reply->function_result)); |
| 1229 | |
| 1230 | phy->invalid_dword_count = |
| 1231 | be32_to_cpu(phy_error_log_reply->invalid_dword); |
| 1232 | phy->running_disparity_error_count = |
| 1233 | be32_to_cpu(phy_error_log_reply->running_disparity_error); |
| 1234 | phy->loss_of_dword_sync_count = |
| 1235 | be32_to_cpu(phy_error_log_reply->loss_of_dword_sync); |
| 1236 | phy->phy_reset_problem_count = |
| 1237 | be32_to_cpu(phy_error_log_reply->phy_reset_problem); |
| 1238 | rc = 0; |
| 1239 | } else |
| 1240 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
| 1241 | "phy_error_log - no reply\n", ioc->name)); |
| 1242 | |
| 1243 | issue_host_reset: |
| 1244 | if (issue_reset) |
| 1245 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, |
| 1246 | FORCE_BIG_HAMMER); |
| 1247 | out: |
| 1248 | ioc->transport_cmds.status = MPT2_CMD_NOT_USED; |
| 1249 | if (data_out) |
| 1250 | pci_free_consistent(ioc->pdev, sz, data_out, data_out_dma); |
| 1251 | |
| 1252 | mutex_unlock(&ioc->transport_cmds.mutex); |
| 1253 | return rc; |
| 1254 | } |
| 1255 | |
| 1256 | /** |
| 1257 | * _transport_get_linkerrors - return phy counters for both hba and expanders |
| 1258 | * @phy: The sas phy object |
| 1259 | * |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1260 | * Returns 0 for success, non-zero for failure. |
| 1261 | * |
| 1262 | */ |
| 1263 | static int |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1264 | _transport_get_linkerrors(struct sas_phy *phy) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1265 | { |
| 1266 | struct MPT2SAS_ADAPTER *ioc = phy_to_ioc(phy); |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1267 | unsigned long flags; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1268 | Mpi2ConfigReply_t mpi_reply; |
| 1269 | Mpi2SasPhyPage1_t phy_pg1; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1270 | |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1271 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
| 1272 | if (_transport_sas_node_find_by_sas_address(ioc, |
| 1273 | phy->identify.sas_address) == NULL) { |
| 1274 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1275 | return -EINVAL; |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1276 | } |
| 1277 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1278 | |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1279 | if (phy->identify.sas_address != ioc->sas_hba.sas_address) |
| 1280 | return _transport_get_expander_phy_error_log(ioc, phy); |
| 1281 | |
| 1282 | /* get hba phy error logs */ |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1283 | if ((mpt2sas_config_get_phy_pg1(ioc, &mpi_reply, &phy_pg1, |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1284 | phy->number))) { |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1285 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1286 | ioc->name, __FILE__, __LINE__, __func__); |
| 1287 | return -ENXIO; |
| 1288 | } |
| 1289 | |
| 1290 | if (mpi_reply.IOCStatus || mpi_reply.IOCLogInfo) |
| 1291 | printk(MPT2SAS_INFO_FMT "phy(%d), ioc_status" |
| 1292 | "(0x%04x), loginfo(0x%08x)\n", ioc->name, |
Kashyap, Desai | d5f491e | 2010-06-17 13:32:54 +0530 | [diff] [blame] | 1293 | phy->number, le16_to_cpu(mpi_reply.IOCStatus), |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1294 | le32_to_cpu(mpi_reply.IOCLogInfo)); |
| 1295 | |
| 1296 | phy->invalid_dword_count = le32_to_cpu(phy_pg1.InvalidDwordCount); |
| 1297 | phy->running_disparity_error_count = |
| 1298 | le32_to_cpu(phy_pg1.RunningDisparityErrorCount); |
| 1299 | phy->loss_of_dword_sync_count = |
| 1300 | le32_to_cpu(phy_pg1.LossDwordSynchCount); |
| 1301 | phy->phy_reset_problem_count = |
| 1302 | le32_to_cpu(phy_pg1.PhyResetProblemCount); |
| 1303 | return 0; |
| 1304 | } |
| 1305 | |
| 1306 | /** |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1307 | * _transport_get_enclosure_identifier - |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1308 | * @phy: The sas phy object |
| 1309 | * |
| 1310 | * Obtain the enclosure logical id for an expander. |
| 1311 | * Returns 0 for success, non-zero for failure. |
| 1312 | */ |
| 1313 | static int |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1314 | _transport_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1315 | { |
| 1316 | struct MPT2SAS_ADAPTER *ioc = rphy_to_ioc(rphy); |
Kashyap, Desai | ab6ce92 | 2010-06-17 13:25:13 +0530 | [diff] [blame] | 1317 | struct _sas_device *sas_device; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1318 | unsigned long flags; |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1319 | int rc; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1320 | |
Kashyap, Desai | ab6ce92 | 2010-06-17 13:25:13 +0530 | [diff] [blame] | 1321 | spin_lock_irqsave(&ioc->sas_device_lock, flags); |
| 1322 | sas_device = mpt2sas_scsih_sas_device_find_by_sas_address(ioc, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1323 | rphy->identify.sas_address); |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1324 | if (sas_device) { |
| 1325 | *identifier = sas_device->enclosure_logical_id; |
| 1326 | rc = 0; |
| 1327 | } else { |
| 1328 | *identifier = 0; |
| 1329 | rc = -ENXIO; |
| 1330 | } |
Kashyap, Desai | ab6ce92 | 2010-06-17 13:25:13 +0530 | [diff] [blame] | 1331 | spin_unlock_irqrestore(&ioc->sas_device_lock, flags); |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1332 | return rc; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | /** |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1336 | * _transport_get_bay_identifier - |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1337 | * @phy: The sas phy object |
| 1338 | * |
| 1339 | * Returns the slot id for a device that resides inside an enclosure. |
| 1340 | */ |
| 1341 | static int |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1342 | _transport_get_bay_identifier(struct sas_rphy *rphy) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1343 | { |
| 1344 | struct MPT2SAS_ADAPTER *ioc = rphy_to_ioc(rphy); |
| 1345 | struct _sas_device *sas_device; |
| 1346 | unsigned long flags; |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1347 | int rc; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1348 | |
| 1349 | spin_lock_irqsave(&ioc->sas_device_lock, flags); |
| 1350 | sas_device = mpt2sas_scsih_sas_device_find_by_sas_address(ioc, |
| 1351 | rphy->identify.sas_address); |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1352 | if (sas_device) |
| 1353 | rc = sas_device->slot; |
| 1354 | else |
| 1355 | rc = -ENXIO; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1356 | spin_unlock_irqrestore(&ioc->sas_device_lock, flags); |
nagalakshmi.nandigama@lsi.com | 09da0b3 | 2012-03-20 12:06:50 +0530 | [diff] [blame^] | 1357 | return rc; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1358 | } |
| 1359 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1360 | /* phy control request structure */ |
| 1361 | struct phy_control_request{ |
| 1362 | u8 smp_frame_type; /* 0x40 */ |
| 1363 | u8 function; /* 0x91 */ |
| 1364 | u8 allocated_response_length; |
| 1365 | u8 request_length; /* 0x09 */ |
| 1366 | u16 expander_change_count; |
| 1367 | u8 reserved_1[3]; |
| 1368 | u8 phy_identifier; |
| 1369 | u8 phy_operation; |
| 1370 | u8 reserved_2[13]; |
| 1371 | u64 attached_device_name; |
| 1372 | u8 programmed_min_physical_link_rate; |
| 1373 | u8 programmed_max_physical_link_rate; |
| 1374 | u8 reserved_3[6]; |
| 1375 | }; |
| 1376 | |
| 1377 | /* phy control reply structure */ |
| 1378 | struct phy_control_reply{ |
| 1379 | u8 smp_frame_type; /* 0x41 */ |
| 1380 | u8 function; /* 0x11 */ |
| 1381 | u8 function_result; |
| 1382 | u8 response_length; |
| 1383 | }; |
| 1384 | |
| 1385 | #define SMP_PHY_CONTROL_LINK_RESET (0x01) |
| 1386 | #define SMP_PHY_CONTROL_HARD_RESET (0x02) |
| 1387 | #define SMP_PHY_CONTROL_DISABLE (0x03) |
| 1388 | |
| 1389 | /** |
| 1390 | * _transport_expander_phy_control - expander phy control |
| 1391 | * @ioc: per adapter object |
| 1392 | * @phy: The sas phy object |
| 1393 | * |
| 1394 | * Returns 0 for success, non-zero for failure. |
| 1395 | * |
| 1396 | */ |
| 1397 | static int |
| 1398 | _transport_expander_phy_control(struct MPT2SAS_ADAPTER *ioc, |
| 1399 | struct sas_phy *phy, u8 phy_operation) |
| 1400 | { |
| 1401 | Mpi2SmpPassthroughRequest_t *mpi_request; |
| 1402 | Mpi2SmpPassthroughReply_t *mpi_reply; |
| 1403 | struct phy_control_request *phy_control_request; |
| 1404 | struct phy_control_reply *phy_control_reply; |
| 1405 | int rc; |
| 1406 | u16 smid; |
| 1407 | u32 ioc_state; |
| 1408 | unsigned long timeleft; |
| 1409 | void *psge; |
| 1410 | u32 sgl_flags; |
| 1411 | u8 issue_reset = 0; |
| 1412 | void *data_out = NULL; |
| 1413 | dma_addr_t data_out_dma; |
| 1414 | u32 sz; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1415 | u16 wait_state_count; |
| 1416 | |
| 1417 | if (ioc->shost_recovery) { |
| 1418 | printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", |
| 1419 | __func__, ioc->name); |
| 1420 | return -EFAULT; |
| 1421 | } |
| 1422 | |
| 1423 | mutex_lock(&ioc->transport_cmds.mutex); |
| 1424 | |
| 1425 | if (ioc->transport_cmds.status != MPT2_CMD_NOT_USED) { |
| 1426 | printk(MPT2SAS_ERR_FMT "%s: transport_cmds in use\n", |
| 1427 | ioc->name, __func__); |
| 1428 | rc = -EAGAIN; |
| 1429 | goto out; |
| 1430 | } |
| 1431 | ioc->transport_cmds.status = MPT2_CMD_PENDING; |
| 1432 | |
| 1433 | wait_state_count = 0; |
| 1434 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 1435 | while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
| 1436 | if (wait_state_count++ == 10) { |
| 1437 | printk(MPT2SAS_ERR_FMT |
| 1438 | "%s: failed due to ioc not operational\n", |
| 1439 | ioc->name, __func__); |
| 1440 | rc = -EFAULT; |
| 1441 | goto out; |
| 1442 | } |
| 1443 | ssleep(1); |
| 1444 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 1445 | printk(MPT2SAS_INFO_FMT "%s: waiting for " |
| 1446 | "operational state(count=%d)\n", ioc->name, |
| 1447 | __func__, wait_state_count); |
| 1448 | } |
| 1449 | if (wait_state_count) |
| 1450 | printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", |
| 1451 | ioc->name, __func__); |
| 1452 | |
| 1453 | smid = mpt2sas_base_get_smid(ioc, ioc->transport_cb_idx); |
| 1454 | if (!smid) { |
| 1455 | printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", |
| 1456 | ioc->name, __func__); |
| 1457 | rc = -EAGAIN; |
| 1458 | goto out; |
| 1459 | } |
| 1460 | |
| 1461 | mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); |
| 1462 | ioc->transport_cmds.smid = smid; |
| 1463 | |
| 1464 | sz = sizeof(struct phy_control_request) + |
| 1465 | sizeof(struct phy_control_reply); |
| 1466 | data_out = pci_alloc_consistent(ioc->pdev, sz, &data_out_dma); |
| 1467 | if (!data_out) { |
| 1468 | printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, |
| 1469 | __LINE__, __func__); |
| 1470 | rc = -ENOMEM; |
| 1471 | mpt2sas_base_free_smid(ioc, smid); |
| 1472 | goto out; |
| 1473 | } |
| 1474 | |
| 1475 | rc = -EINVAL; |
| 1476 | memset(data_out, 0, sz); |
| 1477 | phy_control_request = data_out; |
| 1478 | phy_control_request->smp_frame_type = 0x40; |
| 1479 | phy_control_request->function = 0x91; |
| 1480 | phy_control_request->request_length = 9; |
| 1481 | phy_control_request->allocated_response_length = 0; |
| 1482 | phy_control_request->phy_identifier = phy->number; |
| 1483 | phy_control_request->phy_operation = phy_operation; |
| 1484 | phy_control_request->programmed_min_physical_link_rate = |
| 1485 | phy->minimum_linkrate << 4; |
| 1486 | phy_control_request->programmed_max_physical_link_rate = |
| 1487 | phy->maximum_linkrate << 4; |
| 1488 | |
| 1489 | memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t)); |
| 1490 | mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; |
| 1491 | mpi_request->PhysicalPort = 0xFF; |
| 1492 | mpi_request->VF_ID = 0; /* TODO */ |
| 1493 | mpi_request->VP_ID = 0; |
Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 1494 | mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1495 | mpi_request->RequestDataLength = |
| 1496 | cpu_to_le16(sizeof(struct phy_error_log_request)); |
| 1497 | psge = &mpi_request->SGL; |
| 1498 | |
| 1499 | /* WRITE sgel first */ |
| 1500 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 1501 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); |
| 1502 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
| 1503 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1504 | sizeof(struct phy_control_request), data_out_dma); |
| 1505 | |
| 1506 | /* incr sgel */ |
| 1507 | psge += ioc->sge_size; |
| 1508 | |
| 1509 | /* READ sgel last */ |
| 1510 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 1511 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | |
| 1512 | MPI2_SGE_FLAGS_END_OF_LIST); |
| 1513 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
| 1514 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1515 | sizeof(struct phy_control_reply), data_out_dma + |
| 1516 | sizeof(struct phy_control_request)); |
| 1517 | |
| 1518 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "phy_control - " |
| 1519 | "send to sas_addr(0x%016llx), phy(%d), opcode(%d)\n", ioc->name, |
| 1520 | (unsigned long long)phy->identify.sas_address, phy->number, |
| 1521 | phy_operation)); |
nagalakshmi.nandigama@lsi.com | f01690d | 2011-12-01 07:43:58 +0530 | [diff] [blame] | 1522 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1523 | init_completion(&ioc->transport_cmds.done); |
nagalakshmi.nandigama@lsi.com | f01690d | 2011-12-01 07:43:58 +0530 | [diff] [blame] | 1524 | mpt2sas_base_put_smid_default(ioc, smid); |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1525 | timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done, |
| 1526 | 10*HZ); |
| 1527 | |
| 1528 | if (!(ioc->transport_cmds.status & MPT2_CMD_COMPLETE)) { |
| 1529 | printk(MPT2SAS_ERR_FMT "%s: timeout\n", |
| 1530 | ioc->name, __func__); |
| 1531 | _debug_dump_mf(mpi_request, |
| 1532 | sizeof(Mpi2SmpPassthroughRequest_t)/4); |
| 1533 | if (!(ioc->transport_cmds.status & MPT2_CMD_RESET)) |
| 1534 | issue_reset = 1; |
| 1535 | goto issue_host_reset; |
| 1536 | } |
| 1537 | |
| 1538 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "phy_control - " |
| 1539 | "complete\n", ioc->name)); |
| 1540 | |
| 1541 | if (ioc->transport_cmds.status & MPT2_CMD_REPLY_VALID) { |
| 1542 | |
| 1543 | mpi_reply = ioc->transport_cmds.reply; |
| 1544 | |
| 1545 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
| 1546 | "phy_control - reply data transfer size(%d)\n", |
| 1547 | ioc->name, le16_to_cpu(mpi_reply->ResponseDataLength))); |
| 1548 | |
| 1549 | if (le16_to_cpu(mpi_reply->ResponseDataLength) != |
| 1550 | sizeof(struct phy_control_reply)) |
| 1551 | goto out; |
| 1552 | |
| 1553 | phy_control_reply = data_out + |
| 1554 | sizeof(struct phy_control_request); |
| 1555 | |
| 1556 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
| 1557 | "phy_control - function_result(%d)\n", |
| 1558 | ioc->name, phy_control_reply->function_result)); |
| 1559 | |
| 1560 | rc = 0; |
| 1561 | } else |
| 1562 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
| 1563 | "phy_control - no reply\n", ioc->name)); |
| 1564 | |
| 1565 | issue_host_reset: |
| 1566 | if (issue_reset) |
| 1567 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, |
| 1568 | FORCE_BIG_HAMMER); |
| 1569 | out: |
| 1570 | ioc->transport_cmds.status = MPT2_CMD_NOT_USED; |
| 1571 | if (data_out) |
| 1572 | pci_free_consistent(ioc->pdev, sz, data_out, data_out_dma); |
| 1573 | |
| 1574 | mutex_unlock(&ioc->transport_cmds.mutex); |
| 1575 | return rc; |
| 1576 | } |
| 1577 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1578 | /** |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1579 | * _transport_phy_reset - |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1580 | * @phy: The sas phy object |
| 1581 | * @hard_reset: |
| 1582 | * |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1583 | * Returns 0 for success, non-zero for failure. |
| 1584 | */ |
| 1585 | static int |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1586 | _transport_phy_reset(struct sas_phy *phy, int hard_reset) |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1587 | { |
| 1588 | struct MPT2SAS_ADAPTER *ioc = phy_to_ioc(phy); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1589 | Mpi2SasIoUnitControlReply_t mpi_reply; |
| 1590 | Mpi2SasIoUnitControlRequest_t mpi_request; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1591 | unsigned long flags; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1592 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1593 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
| 1594 | if (_transport_sas_node_find_by_sas_address(ioc, |
| 1595 | phy->identify.sas_address) == NULL) { |
| 1596 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1597 | return -EINVAL; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1598 | } |
| 1599 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1600 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1601 | /* handle expander phys */ |
| 1602 | if (phy->identify.sas_address != ioc->sas_hba.sas_address) |
| 1603 | return _transport_expander_phy_control(ioc, phy, |
| 1604 | (hard_reset == 1) ? SMP_PHY_CONTROL_HARD_RESET : |
| 1605 | SMP_PHY_CONTROL_LINK_RESET); |
| 1606 | |
| 1607 | /* handle hba phys */ |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1608 | memset(&mpi_request, 0, sizeof(Mpi2SasIoUnitControlReply_t)); |
| 1609 | mpi_request.Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; |
| 1610 | mpi_request.Operation = hard_reset ? |
| 1611 | MPI2_SAS_OP_PHY_HARD_RESET : MPI2_SAS_OP_PHY_LINK_RESET; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1612 | mpi_request.PhyNum = phy->number; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1613 | |
| 1614 | if ((mpt2sas_base_sas_iounit_control(ioc, &mpi_reply, &mpi_request))) { |
| 1615 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1616 | ioc->name, __FILE__, __LINE__, __func__); |
| 1617 | return -ENXIO; |
| 1618 | } |
| 1619 | |
| 1620 | if (mpi_reply.IOCStatus || mpi_reply.IOCLogInfo) |
| 1621 | printk(MPT2SAS_INFO_FMT "phy(%d), ioc_status" |
| 1622 | "(0x%04x), loginfo(0x%08x)\n", ioc->name, |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1623 | phy->number, le16_to_cpu(mpi_reply.IOCStatus), |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1624 | le32_to_cpu(mpi_reply.IOCLogInfo)); |
| 1625 | |
| 1626 | return 0; |
| 1627 | } |
| 1628 | |
| 1629 | /** |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1630 | * _transport_phy_enable - enable/disable phys |
| 1631 | * @phy: The sas phy object |
| 1632 | * @enable: enable phy when true |
| 1633 | * |
| 1634 | * Only support sas_host direct attached phys. |
| 1635 | * Returns 0 for success, non-zero for failure. |
| 1636 | */ |
| 1637 | static int |
| 1638 | _transport_phy_enable(struct sas_phy *phy, int enable) |
| 1639 | { |
| 1640 | struct MPT2SAS_ADAPTER *ioc = phy_to_ioc(phy); |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1641 | Mpi2SasIOUnitPage1_t *sas_iounit_pg1 = NULL; |
| 1642 | Mpi2ConfigReply_t mpi_reply; |
| 1643 | u16 ioc_status; |
| 1644 | u16 sz; |
| 1645 | int rc = 0; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1646 | unsigned long flags; |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1647 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1648 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
| 1649 | if (_transport_sas_node_find_by_sas_address(ioc, |
| 1650 | phy->identify.sas_address) == NULL) { |
| 1651 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1652 | return -EINVAL; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1653 | } |
| 1654 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
| 1655 | |
| 1656 | /* handle expander phys */ |
| 1657 | if (phy->identify.sas_address != ioc->sas_hba.sas_address) |
| 1658 | return _transport_expander_phy_control(ioc, phy, |
| 1659 | (enable == 1) ? SMP_PHY_CONTROL_LINK_RESET : |
| 1660 | SMP_PHY_CONTROL_DISABLE); |
| 1661 | |
| 1662 | /* handle hba phys */ |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1663 | |
| 1664 | /* sas_iounit page 1 */ |
| 1665 | sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * |
| 1666 | sizeof(Mpi2SasIOUnit1PhyData_t)); |
| 1667 | sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL); |
| 1668 | if (!sas_iounit_pg1) { |
| 1669 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1670 | ioc->name, __FILE__, __LINE__, __func__); |
| 1671 | rc = -ENOMEM; |
| 1672 | goto out; |
| 1673 | } |
| 1674 | if ((mpt2sas_config_get_sas_iounit_pg1(ioc, &mpi_reply, |
| 1675 | sas_iounit_pg1, sz))) { |
| 1676 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1677 | ioc->name, __FILE__, __LINE__, __func__); |
| 1678 | rc = -ENXIO; |
| 1679 | goto out; |
| 1680 | } |
| 1681 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & |
| 1682 | MPI2_IOCSTATUS_MASK; |
| 1683 | if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { |
| 1684 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1685 | ioc->name, __FILE__, __LINE__, __func__); |
| 1686 | rc = -EIO; |
| 1687 | goto out; |
| 1688 | } |
| 1689 | |
| 1690 | if (enable) |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1691 | sas_iounit_pg1->PhyData[phy->number].PhyFlags |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1692 | &= ~MPI2_SASIOUNIT1_PHYFLAGS_PHY_DISABLE; |
| 1693 | else |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1694 | sas_iounit_pg1->PhyData[phy->number].PhyFlags |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1695 | |= MPI2_SASIOUNIT1_PHYFLAGS_PHY_DISABLE; |
| 1696 | |
| 1697 | mpt2sas_config_set_sas_iounit_pg1(ioc, &mpi_reply, sas_iounit_pg1, sz); |
| 1698 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1699 | /* link reset */ |
| 1700 | if (enable) |
| 1701 | _transport_phy_reset(phy, 0); |
| 1702 | |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1703 | out: |
| 1704 | kfree(sas_iounit_pg1); |
| 1705 | return rc; |
| 1706 | } |
| 1707 | |
| 1708 | /** |
| 1709 | * _transport_phy_speed - set phy min/max link rates |
| 1710 | * @phy: The sas phy object |
| 1711 | * @rates: rates defined in sas_phy_linkrates |
| 1712 | * |
| 1713 | * Only support sas_host direct attached phys. |
| 1714 | * Returns 0 for success, non-zero for failure. |
| 1715 | */ |
| 1716 | static int |
| 1717 | _transport_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates) |
| 1718 | { |
| 1719 | struct MPT2SAS_ADAPTER *ioc = phy_to_ioc(phy); |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1720 | Mpi2SasIOUnitPage1_t *sas_iounit_pg1 = NULL; |
| 1721 | Mpi2SasPhyPage0_t phy_pg0; |
| 1722 | Mpi2ConfigReply_t mpi_reply; |
| 1723 | u16 ioc_status; |
| 1724 | u16 sz; |
| 1725 | int i; |
| 1726 | int rc = 0; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1727 | unsigned long flags; |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1728 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1729 | spin_lock_irqsave(&ioc->sas_node_lock, flags); |
| 1730 | if (_transport_sas_node_find_by_sas_address(ioc, |
| 1731 | phy->identify.sas_address) == NULL) { |
| 1732 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1733 | return -EINVAL; |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1734 | } |
| 1735 | spin_unlock_irqrestore(&ioc->sas_node_lock, flags); |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1736 | |
| 1737 | if (!rates->minimum_linkrate) |
| 1738 | rates->minimum_linkrate = phy->minimum_linkrate; |
| 1739 | else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) |
| 1740 | rates->minimum_linkrate = phy->minimum_linkrate_hw; |
| 1741 | |
| 1742 | if (!rates->maximum_linkrate) |
| 1743 | rates->maximum_linkrate = phy->maximum_linkrate; |
| 1744 | else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) |
| 1745 | rates->maximum_linkrate = phy->maximum_linkrate_hw; |
| 1746 | |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1747 | /* handle expander phys */ |
| 1748 | if (phy->identify.sas_address != ioc->sas_hba.sas_address) { |
| 1749 | phy->minimum_linkrate = rates->minimum_linkrate; |
| 1750 | phy->maximum_linkrate = rates->maximum_linkrate; |
| 1751 | return _transport_expander_phy_control(ioc, phy, |
| 1752 | SMP_PHY_CONTROL_LINK_RESET); |
| 1753 | } |
| 1754 | |
| 1755 | /* handle hba phys */ |
| 1756 | |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1757 | /* sas_iounit page 1 */ |
| 1758 | sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * |
| 1759 | sizeof(Mpi2SasIOUnit1PhyData_t)); |
| 1760 | sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL); |
| 1761 | if (!sas_iounit_pg1) { |
| 1762 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1763 | ioc->name, __FILE__, __LINE__, __func__); |
| 1764 | rc = -ENOMEM; |
| 1765 | goto out; |
| 1766 | } |
| 1767 | if ((mpt2sas_config_get_sas_iounit_pg1(ioc, &mpi_reply, |
| 1768 | sas_iounit_pg1, sz))) { |
| 1769 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1770 | ioc->name, __FILE__, __LINE__, __func__); |
| 1771 | rc = -ENXIO; |
| 1772 | goto out; |
| 1773 | } |
| 1774 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & |
| 1775 | MPI2_IOCSTATUS_MASK; |
| 1776 | if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { |
| 1777 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1778 | ioc->name, __FILE__, __LINE__, __func__); |
| 1779 | rc = -EIO; |
| 1780 | goto out; |
| 1781 | } |
| 1782 | |
| 1783 | for (i = 0; i < ioc->sas_hba.num_phys; i++) { |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1784 | if (phy->number != i) { |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1785 | sas_iounit_pg1->PhyData[i].MaxMinLinkRate = |
| 1786 | (ioc->sas_hba.phy[i].phy->minimum_linkrate + |
| 1787 | (ioc->sas_hba.phy[i].phy->maximum_linkrate << 4)); |
| 1788 | } else { |
| 1789 | sas_iounit_pg1->PhyData[i].MaxMinLinkRate = |
| 1790 | (rates->minimum_linkrate + |
| 1791 | (rates->maximum_linkrate << 4)); |
| 1792 | } |
| 1793 | } |
| 1794 | |
| 1795 | if (mpt2sas_config_set_sas_iounit_pg1(ioc, &mpi_reply, sas_iounit_pg1, |
| 1796 | sz)) { |
| 1797 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
| 1798 | ioc->name, __FILE__, __LINE__, __func__); |
| 1799 | rc = -ENXIO; |
| 1800 | goto out; |
| 1801 | } |
| 1802 | |
| 1803 | /* link reset */ |
| 1804 | _transport_phy_reset(phy, 0); |
| 1805 | |
| 1806 | /* read phy page 0, then update the rates in the sas transport phy */ |
| 1807 | if (!mpt2sas_config_get_phy_pg0(ioc, &mpi_reply, &phy_pg0, |
Kashyap, Desai | b8d7d7b | 2010-06-17 13:34:31 +0530 | [diff] [blame] | 1808 | phy->number)) { |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 1809 | phy->minimum_linkrate = _transport_convert_phy_link_rate( |
| 1810 | phy_pg0.ProgrammedLinkRate & MPI2_SAS_PRATE_MIN_RATE_MASK); |
| 1811 | phy->maximum_linkrate = _transport_convert_phy_link_rate( |
| 1812 | phy_pg0.ProgrammedLinkRate >> 4); |
| 1813 | phy->negotiated_linkrate = _transport_convert_phy_link_rate( |
| 1814 | phy_pg0.NegotiatedLinkRate & |
| 1815 | MPI2_SAS_NEG_LINK_RATE_MASK_PHYSICAL); |
| 1816 | } |
| 1817 | |
| 1818 | out: |
| 1819 | kfree(sas_iounit_pg1); |
| 1820 | return rc; |
| 1821 | } |
| 1822 | |
| 1823 | |
| 1824 | /** |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1825 | * _transport_smp_handler - transport portal for smp passthru |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1826 | * @shost: shost object |
| 1827 | * @rphy: sas transport rphy object |
| 1828 | * @req: |
| 1829 | * |
| 1830 | * This used primarily for smp_utils. |
| 1831 | * Example: |
| 1832 | * smp_rep_general /sys/class/bsg/expander-5:0 |
| 1833 | */ |
| 1834 | static int |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 1835 | _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1836 | struct request *req) |
| 1837 | { |
| 1838 | struct MPT2SAS_ADAPTER *ioc = shost_priv(shost); |
| 1839 | Mpi2SmpPassthroughRequest_t *mpi_request; |
| 1840 | Mpi2SmpPassthroughReply_t *mpi_reply; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1841 | int rc, i; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1842 | u16 smid; |
| 1843 | u32 ioc_state; |
| 1844 | unsigned long timeleft; |
| 1845 | void *psge; |
| 1846 | u32 sgl_flags; |
| 1847 | u8 issue_reset = 0; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1848 | dma_addr_t dma_addr_in = 0; |
| 1849 | dma_addr_t dma_addr_out = 0; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1850 | dma_addr_t pci_dma_in = 0; |
| 1851 | dma_addr_t pci_dma_out = 0; |
| 1852 | void *pci_addr_in = NULL; |
| 1853 | void *pci_addr_out = NULL; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1854 | u16 wait_state_count; |
| 1855 | struct request *rsp = req->next_rq; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1856 | struct bio_vec *bvec = NULL; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1857 | |
| 1858 | if (!rsp) { |
| 1859 | printk(MPT2SAS_ERR_FMT "%s: the smp response space is " |
| 1860 | "missing\n", ioc->name, __func__); |
| 1861 | return -EINVAL; |
| 1862 | } |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1863 | if (ioc->shost_recovery || ioc->pci_error_recovery) { |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1864 | printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", |
| 1865 | __func__, ioc->name); |
| 1866 | return -EFAULT; |
| 1867 | } |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1868 | |
| 1869 | rc = mutex_lock_interruptible(&ioc->transport_cmds.mutex); |
| 1870 | if (rc) |
| 1871 | return rc; |
| 1872 | |
| 1873 | if (ioc->transport_cmds.status != MPT2_CMD_NOT_USED) { |
| 1874 | printk(MPT2SAS_ERR_FMT "%s: transport_cmds in use\n", ioc->name, |
| 1875 | __func__); |
| 1876 | rc = -EAGAIN; |
| 1877 | goto out; |
| 1878 | } |
| 1879 | ioc->transport_cmds.status = MPT2_CMD_PENDING; |
| 1880 | |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1881 | /* Check if the request is split across multiple segments */ |
| 1882 | if (req->bio->bi_vcnt > 1) { |
| 1883 | u32 offset = 0; |
| 1884 | |
| 1885 | /* Allocate memory and copy the request */ |
| 1886 | pci_addr_out = pci_alloc_consistent(ioc->pdev, |
| 1887 | blk_rq_bytes(req), &pci_dma_out); |
| 1888 | if (!pci_addr_out) { |
| 1889 | printk(MPT2SAS_INFO_FMT "%s(): PCI Addr out = NULL\n", |
| 1890 | ioc->name, __func__); |
| 1891 | rc = -ENOMEM; |
| 1892 | goto out; |
| 1893 | } |
| 1894 | |
| 1895 | bio_for_each_segment(bvec, req->bio, i) { |
| 1896 | memcpy(pci_addr_out + offset, |
| 1897 | page_address(bvec->bv_page) + bvec->bv_offset, |
| 1898 | bvec->bv_len); |
| 1899 | offset += bvec->bv_len; |
| 1900 | } |
| 1901 | } else { |
| 1902 | dma_addr_out = pci_map_single(ioc->pdev, bio_data(req->bio), |
| 1903 | blk_rq_bytes(req), PCI_DMA_BIDIRECTIONAL); |
| 1904 | if (!dma_addr_out) { |
| 1905 | printk(MPT2SAS_INFO_FMT "%s(): DMA Addr out = NULL\n", |
| 1906 | ioc->name, __func__); |
| 1907 | rc = -ENOMEM; |
| 1908 | goto free_pci; |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | /* Check if the response needs to be populated across |
| 1913 | * multiple segments */ |
| 1914 | if (rsp->bio->bi_vcnt > 1) { |
| 1915 | pci_addr_in = pci_alloc_consistent(ioc->pdev, blk_rq_bytes(rsp), |
| 1916 | &pci_dma_in); |
| 1917 | if (!pci_addr_in) { |
| 1918 | printk(MPT2SAS_INFO_FMT "%s(): PCI Addr in = NULL\n", |
| 1919 | ioc->name, __func__); |
| 1920 | rc = -ENOMEM; |
| 1921 | goto unmap; |
| 1922 | } |
| 1923 | } else { |
| 1924 | dma_addr_in = pci_map_single(ioc->pdev, bio_data(rsp->bio), |
| 1925 | blk_rq_bytes(rsp), PCI_DMA_BIDIRECTIONAL); |
| 1926 | if (!dma_addr_in) { |
| 1927 | printk(MPT2SAS_INFO_FMT "%s(): DMA Addr in = NULL\n", |
| 1928 | ioc->name, __func__); |
| 1929 | rc = -ENOMEM; |
| 1930 | goto unmap; |
| 1931 | } |
| 1932 | } |
| 1933 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1934 | wait_state_count = 0; |
| 1935 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 1936 | while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
| 1937 | if (wait_state_count++ == 10) { |
| 1938 | printk(MPT2SAS_ERR_FMT |
| 1939 | "%s: failed due to ioc not operational\n", |
| 1940 | ioc->name, __func__); |
| 1941 | rc = -EFAULT; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1942 | goto unmap; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1943 | } |
| 1944 | ssleep(1); |
| 1945 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
| 1946 | printk(MPT2SAS_INFO_FMT "%s: waiting for " |
| 1947 | "operational state(count=%d)\n", ioc->name, |
| 1948 | __func__, wait_state_count); |
| 1949 | } |
| 1950 | if (wait_state_count) |
| 1951 | printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", |
| 1952 | ioc->name, __func__); |
| 1953 | |
| 1954 | smid = mpt2sas_base_get_smid(ioc, ioc->transport_cb_idx); |
| 1955 | if (!smid) { |
| 1956 | printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", |
| 1957 | ioc->name, __func__); |
| 1958 | rc = -EAGAIN; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1959 | goto unmap; |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1960 | } |
| 1961 | |
| 1962 | rc = 0; |
| 1963 | mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); |
| 1964 | ioc->transport_cmds.smid = smid; |
| 1965 | |
| 1966 | memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t)); |
| 1967 | mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; |
| 1968 | mpi_request->PhysicalPort = 0xFF; |
Kashyap, Desai | 7b936b0 | 2009-09-25 11:44:41 +0530 | [diff] [blame] | 1969 | mpi_request->VF_ID = 0; /* TODO */ |
| 1970 | mpi_request->VP_ID = 0; |
Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 1971 | mpi_request->SASAddress = (rphy) ? |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1972 | cpu_to_le64(rphy->identify.sas_address) : |
| 1973 | cpu_to_le64(ioc->sas_hba.sas_address); |
Tejun Heo | b079041 | 2009-05-07 22:24:42 +0900 | [diff] [blame] | 1974 | mpi_request->RequestDataLength = cpu_to_le16(blk_rq_bytes(req) - 4); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1975 | psge = &mpi_request->SGL; |
| 1976 | |
| 1977 | /* WRITE sgel first */ |
| 1978 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 1979 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); |
| 1980 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1981 | if (req->bio->bi_vcnt > 1) { |
| 1982 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1983 | (blk_rq_bytes(req) - 4), pci_dma_out); |
| 1984 | } else { |
| 1985 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1986 | (blk_rq_bytes(req) - 4), dma_addr_out); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1987 | } |
| 1988 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1989 | /* incr sgel */ |
| 1990 | psge += ioc->sge_size; |
| 1991 | |
| 1992 | /* READ sgel last */ |
| 1993 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
| 1994 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | |
| 1995 | MPI2_SGE_FLAGS_END_OF_LIST); |
| 1996 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 1997 | if (rsp->bio->bi_vcnt > 1) { |
| 1998 | ioc->base_add_sg_single(psge, sgl_flags | |
| 1999 | (blk_rq_bytes(rsp) + 4), pci_dma_in); |
| 2000 | } else { |
| 2001 | ioc->base_add_sg_single(psge, sgl_flags | |
| 2002 | (blk_rq_bytes(rsp) + 4), dma_addr_in); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2003 | } |
| 2004 | |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 2005 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "%s - " |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2006 | "sending smp request\n", ioc->name, __func__)); |
| 2007 | |
Kashyap, Desai | bcfb6e6 | 2009-09-14 11:05:24 +0530 | [diff] [blame] | 2008 | init_completion(&ioc->transport_cmds.done); |
nagalakshmi.nandigama@lsi.com | f01690d | 2011-12-01 07:43:58 +0530 | [diff] [blame] | 2009 | mpt2sas_base_put_smid_default(ioc, smid); |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2010 | timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done, |
| 2011 | 10*HZ); |
| 2012 | |
| 2013 | if (!(ioc->transport_cmds.status & MPT2_CMD_COMPLETE)) { |
| 2014 | printk(MPT2SAS_ERR_FMT "%s : timeout\n", |
| 2015 | __func__, ioc->name); |
| 2016 | _debug_dump_mf(mpi_request, |
| 2017 | sizeof(Mpi2SmpPassthroughRequest_t)/4); |
| 2018 | if (!(ioc->transport_cmds.status & MPT2_CMD_RESET)) |
| 2019 | issue_reset = 1; |
| 2020 | goto issue_host_reset; |
| 2021 | } |
| 2022 | |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 2023 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT "%s - " |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2024 | "complete\n", ioc->name, __func__)); |
| 2025 | |
| 2026 | if (ioc->transport_cmds.status & MPT2_CMD_REPLY_VALID) { |
| 2027 | |
| 2028 | mpi_reply = ioc->transport_cmds.reply; |
| 2029 | |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 2030 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2031 | "%s - reply data transfer size(%d)\n", |
| 2032 | ioc->name, __func__, |
| 2033 | le16_to_cpu(mpi_reply->ResponseDataLength))); |
| 2034 | |
| 2035 | memcpy(req->sense, mpi_reply, sizeof(*mpi_reply)); |
| 2036 | req->sense_len = sizeof(*mpi_reply); |
Tejun Heo | 5f49f63 | 2009-05-19 18:33:05 +0900 | [diff] [blame] | 2037 | req->resid_len = 0; |
Kashyap, Desai | e94f674 | 2010-03-17 16:24:52 +0530 | [diff] [blame] | 2038 | rsp->resid_len -= |
| 2039 | le16_to_cpu(mpi_reply->ResponseDataLength); |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 2040 | /* check if the resp needs to be copied from the allocated |
| 2041 | * pci mem */ |
| 2042 | if (rsp->bio->bi_vcnt > 1) { |
| 2043 | u32 offset = 0; |
| 2044 | u32 bytes_to_copy = |
| 2045 | le16_to_cpu(mpi_reply->ResponseDataLength); |
| 2046 | bio_for_each_segment(bvec, rsp->bio, i) { |
| 2047 | if (bytes_to_copy <= bvec->bv_len) { |
| 2048 | memcpy(page_address(bvec->bv_page) + |
| 2049 | bvec->bv_offset, pci_addr_in + |
| 2050 | offset, bytes_to_copy); |
| 2051 | break; |
| 2052 | } else { |
| 2053 | memcpy(page_address(bvec->bv_page) + |
| 2054 | bvec->bv_offset, pci_addr_in + |
| 2055 | offset, bvec->bv_len); |
| 2056 | bytes_to_copy -= bvec->bv_len; |
| 2057 | } |
| 2058 | offset += bvec->bv_len; |
| 2059 | } |
| 2060 | } |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2061 | } else { |
Kashyap, Desai | eabb08a | 2010-06-17 13:43:57 +0530 | [diff] [blame] | 2062 | dtransportprintk(ioc, printk(MPT2SAS_INFO_FMT |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2063 | "%s - no reply\n", ioc->name, __func__)); |
| 2064 | rc = -ENXIO; |
| 2065 | } |
| 2066 | |
| 2067 | issue_host_reset: |
| 2068 | if (issue_reset) { |
| 2069 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, |
| 2070 | FORCE_BIG_HAMMER); |
| 2071 | rc = -ETIMEDOUT; |
| 2072 | } |
| 2073 | |
| 2074 | unmap: |
| 2075 | if (dma_addr_out) |
Tejun Heo | b079041 | 2009-05-07 22:24:42 +0900 | [diff] [blame] | 2076 | pci_unmap_single(ioc->pdev, dma_addr_out, blk_rq_bytes(req), |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2077 | PCI_DMA_BIDIRECTIONAL); |
| 2078 | if (dma_addr_in) |
Tejun Heo | b079041 | 2009-05-07 22:24:42 +0900 | [diff] [blame] | 2079 | pci_unmap_single(ioc->pdev, dma_addr_in, blk_rq_bytes(rsp), |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2080 | PCI_DMA_BIDIRECTIONAL); |
| 2081 | |
nagalakshmi.nandigama@lsi.com | 77a6edf | 2012-03-20 12:04:43 +0530 | [diff] [blame] | 2082 | free_pci: |
| 2083 | if (pci_addr_out) |
| 2084 | pci_free_consistent(ioc->pdev, blk_rq_bytes(req), pci_addr_out, |
| 2085 | pci_dma_out); |
| 2086 | |
| 2087 | if (pci_addr_in) |
| 2088 | pci_free_consistent(ioc->pdev, blk_rq_bytes(rsp), pci_addr_in, |
| 2089 | pci_dma_in); |
| 2090 | |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2091 | out: |
| 2092 | ioc->transport_cmds.status = MPT2_CMD_NOT_USED; |
| 2093 | mutex_unlock(&ioc->transport_cmds.mutex); |
| 2094 | return rc; |
| 2095 | } |
| 2096 | |
| 2097 | struct sas_function_template mpt2sas_transport_functions = { |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 2098 | .get_linkerrors = _transport_get_linkerrors, |
| 2099 | .get_enclosure_identifier = _transport_get_enclosure_identifier, |
| 2100 | .get_bay_identifier = _transport_get_bay_identifier, |
| 2101 | .phy_reset = _transport_phy_reset, |
Kashyap, Desai | 50d5c60 | 2009-12-16 18:55:26 +0530 | [diff] [blame] | 2102 | .phy_enable = _transport_phy_enable, |
| 2103 | .set_phy_speed = _transport_phy_speed, |
Eric Moore | d5d135b | 2009-05-18 13:02:08 -0600 | [diff] [blame] | 2104 | .smp_handler = _transport_smp_handler, |
Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 2105 | }; |
| 2106 | |
| 2107 | struct scsi_transport_template *mpt2sas_transport_template; |