2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 * This file contains isci module object implementation.
69 * scic_cb_timer_create() - This callback method asks the user to create a
70 * timer and provide a handle for this timer for use in further timer
71 * interactions. The appropriate isci timer object function is called to
72 * create a timer object.
73 * @timer_callback: This parameter specifies the callback method to be invoked
74 * whenever the timer expires.
75 * @controller: This parameter specifies the controller with which this timer
76 * is to be associated.
77 * @cookie: This parameter specifies a piece of information that the user must
78 * retain. This cookie is to be supplied by the user anytime a timeout
79 * occurs for the created timer.
81 * This method returns a handle to a timer object created by the user. The
82 * handle will be utilized for all further interactions relating to this timer.
84 void *scic_cb_timer_create(
85 struct scic_sds_controller *controller,
86 void (*timer_callback)(void *),
89 struct isci_host *isci_host;
90 struct isci_timer *timer = NULL;
92 isci_host = (struct isci_host *)sci_object_get_association(controller);
94 dev_dbg(&isci_host->pdev->dev,
98 timer = isci_timer_create(&isci_host->timer_list_struct,
103 dev_dbg(&isci_host->pdev->dev, "%s: timer = %p\n", __func__, timer);
105 return (void *)timer;
110 * scic_cb_timer_start() - This callback method asks the user to start the
111 * supplied timer. The appropriate isci timer object function is called to
113 * @controller: This parameter specifies the controller with which this timer
115 * @timer: This parameter specifies the timer to be started.
116 * @milliseconds: This parameter specifies the number of milliseconds for which
117 * to stall. The operating system driver is allowed to round this value up
121 void scic_cb_timer_start(
122 struct scic_sds_controller *controller,
126 struct isci_host *isci_host;
129 (struct isci_host *)sci_object_get_association(controller);
131 dev_dbg(&isci_host->pdev->dev,
132 "%s: isci_host = %p, timer = %p, milliseconds = %d\n",
133 __func__, isci_host, timer, milliseconds);
135 isci_timer_start((struct isci_timer *)timer, milliseconds);
140 * scic_cb_timer_stop() - This callback method asks the user to stop the
141 * supplied timer. The appropriate isci timer object function is called to
143 * @controller: This parameter specifies the controller with which this timer
145 * @timer: This parameter specifies the timer to be stopped.
148 void scic_cb_timer_stop(
149 struct scic_sds_controller *controller,
152 struct isci_host *isci_host;
155 (struct isci_host *)sci_object_get_association(controller);
157 dev_dbg(&isci_host->pdev->dev,
158 "%s: isci_host = %p, timer = %p\n",
159 __func__, isci_host, timer);
161 isci_timer_stop((struct isci_timer *)timer);
165 * scic_cb_controller_start_complete() - This user callback will inform the
166 * user that the controller has finished the start process. The associated
167 * isci host adapter's start_complete function is called.
168 * @controller: This parameter specifies the controller that was started.
169 * @completion_status: This parameter specifies the results of the start
170 * operation. SCI_SUCCESS indicates successful completion.
173 void scic_cb_controller_start_complete(
174 struct scic_sds_controller *controller,
175 enum sci_status completion_status)
177 struct isci_host *isci_host =
178 (struct isci_host *)sci_object_get_association(controller);
180 dev_dbg(&isci_host->pdev->dev,
181 "%s: isci_host = %p\n", __func__, isci_host);
183 isci_host_start_complete(isci_host, completion_status);
187 * scic_cb_controller_stop_complete() - This user callback will inform the user
188 * that the controller has finished the stop process. The associated isci
189 * host adapter's start_complete function is called.
190 * @controller: This parameter specifies the controller that was stopped.
191 * @completion_status: This parameter specifies the results of the stop
192 * operation. SCI_SUCCESS indicates successful completion.
195 void scic_cb_controller_stop_complete(
196 struct scic_sds_controller *controller,
197 enum sci_status completion_status)
199 struct isci_host *isci_host =
200 (struct isci_host *)sci_object_get_association(controller);
202 dev_dbg(&isci_host->pdev->dev,
203 "%s: status = 0x%x\n", __func__, completion_status);
204 isci_host_stop_complete(isci_host, completion_status);
208 * scic_cb_io_request_complete() - This user callback will inform the user that
209 * an IO request has completed.
210 * @controller: This parameter specifies the controller on which the IO is
212 * @remote_device: This parameter specifies the remote device on which this IO
213 * request is completing.
214 * @io_request: This parameter specifies the IO request that has completed.
215 * @completion_status: This parameter specifies the results of the IO request
216 * operation. SCI_SUCCESS indicates successful completion.
219 void scic_cb_io_request_complete(
220 struct scic_sds_controller *controller,
221 struct scic_sds_remote_device *remote_device,
222 struct scic_sds_request *scic_io_request,
223 enum sci_io_status completion_status)
225 struct isci_request *request;
226 struct isci_host *isci_host;
229 (struct isci_host *)sci_object_get_association(controller);
232 (struct isci_request *)sci_object_get_association(
236 isci_request_io_request_complete(isci_host,
242 * scic_cb_task_request_complete() - This user callback will inform the user
243 * that a task management request completed.
244 * @controller: This parameter specifies the controller on which the task
245 * management request is completing.
246 * @remote_device: This parameter specifies the remote device on which this
247 * task management request is completing.
248 * @task_request: This parameter specifies the task management request that has
250 * @completion_status: This parameter specifies the results of the IO request
251 * operation. SCI_SUCCESS indicates successful completion.
254 void scic_cb_task_request_complete(
255 struct scic_sds_controller *controller,
256 struct scic_sds_remote_device *remote_device,
257 struct scic_sds_request *scic_task_request,
258 enum sci_task_status completion_status)
260 struct isci_request *request;
261 struct isci_host *isci_host;
264 (struct isci_host *)sci_object_get_association(controller);
267 (struct isci_request *)sci_object_get_association(
270 isci_task_request_complete(isci_host, request, completion_status);
274 * scic_cb_port_stop_complete() - This method informs the user when a stop
275 * operation on the port has completed.
276 * @controller: This parameter represents the controller which contains the
278 * @port: This parameter specifies the SCI port object for which the callback
280 * @completion_status: This parameter specifies the status for the operation
284 void scic_cb_port_stop_complete(
285 struct scic_sds_controller *controller,
286 struct scic_sds_port *port,
287 enum sci_status completion_status)
289 pr_warn("%s:************************************************\n",
294 * scic_cb_port_hard_reset_complete() - This method informs the user when a
295 * hard reset on the port has completed. This hard reset could have been
296 * initiated by the user or by the remote port.
297 * @controller: This parameter represents the controller which contains the
299 * @port: This parameter specifies the SCI port object for which the callback
301 * @completion_status: This parameter specifies the status for the operation
305 void scic_cb_port_hard_reset_complete(
306 struct scic_sds_controller *controller,
307 struct scic_sds_port *port,
308 enum sci_status completion_status)
310 struct isci_port *isci_port
311 = (struct isci_port *)sci_object_get_association(port);
313 isci_port_hard_reset_complete(isci_port, completion_status);
317 * scic_cb_port_ready() - This method informs the user that the port is now in
318 * a ready state and can be utilized to issue IOs.
319 * @controller: This parameter represents the controller which contains the
321 * @port: This parameter specifies the SCI port object for which the callback
325 void scic_cb_port_ready(
326 struct scic_sds_controller *controller,
327 struct scic_sds_port *port)
329 struct isci_port *isci_port;
330 struct isci_host *isci_host;
333 (struct isci_host *)sci_object_get_association(controller);
336 (struct isci_port *)sci_object_get_association(port);
338 dev_dbg(&isci_host->pdev->dev,
339 "%s: isci_port = %p\n", __func__, isci_port);
341 isci_port_ready(isci_host, isci_port);
345 * scic_cb_port_not_ready() - This method informs the user that the port is now
346 * not in a ready (i.e. busy) state and can't be utilized to issue IOs.
347 * @controller: This parameter represents the controller which contains the
349 * @port: This parameter specifies the SCI port object for which the callback
353 void scic_cb_port_not_ready(
354 struct scic_sds_controller *controller,
355 struct scic_sds_port *port,
358 struct isci_port *isci_port;
359 struct isci_host *isci_host;
362 (struct isci_host *)sci_object_get_association(controller);
365 (struct isci_port *)sci_object_get_association(port);
367 dev_dbg(&isci_host->pdev->dev,
368 "%s: isci_port = %p\n", __func__, isci_port);
370 isci_port_not_ready(isci_host, isci_port);
374 * scic_cb_port_invalid_link_up() - This method informs the SCI Core user that
375 * a phy/link became ready, but the phy is not allowed in the port. In some
376 * situations the underlying hardware only allows for certain phy to port
377 * mappings. If these mappings are violated, then this API is invoked.
378 * @controller: This parameter represents the controller which contains the
380 * @port: This parameter specifies the SCI port object for which the callback
382 * @phy: This parameter specifies the phy that came ready, but the phy can't be
383 * a valid member of the port.
386 void scic_cb_port_invalid_link_up(
387 struct scic_sds_controller *controller,
388 struct scic_sds_port *port,
389 struct scic_sds_phy *phy)
391 pr_warn("%s:************************************************\n",
396 * scic_cb_port_bc_change_primitive_received() - This callback method informs
397 * the user that a broadcast change primitive was received.
398 * @controller: This parameter represents the controller which contains the
400 * @port: This parameter specifies the SCI port object for which the callback
401 * is being invoked. For instances where the phy on which the primitive was
402 * received is not part of a port, this parameter will be
403 * SCI_INVALID_HANDLE_T.
404 * @phy: This parameter specifies the phy on which the primitive was received.
407 void scic_cb_port_bc_change_primitive_received(
408 struct scic_sds_controller *controller,
409 struct scic_sds_port *port,
410 struct scic_sds_phy *phy)
412 struct isci_host *isci_host;
415 (struct isci_host *)sci_object_get_association(controller);
417 dev_dbg(&isci_host->pdev->dev,
418 "%s: port = %p, phy = %p\n", __func__, port, phy);
419 isci_port_bc_change_received(isci_host, port, phy);
426 * scic_cb_port_link_up() - This callback method informs the user that a phy
427 * has become operational and is capable of communicating with the remote
429 * @controller: This parameter represents the controller associated with the
431 * @port: This parameter specifies the port object for which the user callback
432 * is being invoked. There may be conditions where this parameter can be
434 * @phy: This parameter specifies the phy object for which the user callback is
439 void scic_cb_port_link_up(
440 struct scic_sds_controller *controller,
441 struct scic_sds_port *port,
442 struct scic_sds_phy *phy)
444 struct isci_host *isci_host;
447 (struct isci_host *)sci_object_get_association(controller);
449 dev_dbg(&isci_host->pdev->dev,
450 "%s: phy = %p\n", __func__, phy);
452 isci_port_link_up(isci_host, port, phy);
456 * scic_cb_port_link_down() - This callback method informs the user that a phy
457 * is no longer operational and is not capable of communicating with the
459 * @controller: This parameter represents the controller associated with the
461 * @port: This parameter specifies the port object for which the user callback
462 * is being invoked. There may be conditions where this parameter can be
464 * @phy: This parameter specifies the phy object for which the user callback is
469 void scic_cb_port_link_down(
470 struct scic_sds_controller *controller,
471 struct scic_sds_port *port,
472 struct scic_sds_phy *phy)
474 struct isci_host *isci_host;
475 struct isci_phy *isci_phy;
476 struct isci_port *isci_port;
479 (struct isci_host *)sci_object_get_association(controller);
482 (struct isci_phy *)sci_object_get_association(phy);
485 (struct isci_port *)sci_object_get_association(port);
487 dev_dbg(&isci_host->pdev->dev,
488 "%s: isci_port = %p\n", __func__, isci_port);
490 isci_port_link_down(isci_host, isci_phy, isci_port);
494 * scic_cb_remote_device_start_complete() - This user callback method will
495 * inform the user that a start operation has completed.
496 * @controller: This parameter specifies the core controller associated with
497 * the completion callback.
498 * @remote_device: This parameter specifies the remote device associated with
499 * the completion callback.
500 * @completion_status: This parameter specifies the completion status for the
504 void scic_cb_remote_device_start_complete(
505 struct scic_sds_controller *controller,
506 struct scic_sds_remote_device *remote_device,
507 enum sci_status completion_status)
509 struct isci_host *isci_host;
510 struct isci_remote_device *isci_device;
513 (struct isci_host *)sci_object_get_association(controller);
516 (struct isci_remote_device *)sci_object_get_association(
520 dev_dbg(&isci_host->pdev->dev,
521 "%s: isci_device = %p\n", __func__, isci_device);
523 isci_remote_device_start_complete(
524 isci_host, isci_device, completion_status);
529 * scic_cb_remote_device_stop_complete() - This user callback method will
530 * inform the user that a stop operation has completed.
531 * @controller: This parameter specifies the core controller associated with
532 * the completion callback.
533 * @remote_device: This parameter specifies the remote device associated with
534 * the completion callback.
535 * @completion_status: This parameter specifies the completion status for the
539 void scic_cb_remote_device_stop_complete(
540 struct scic_sds_controller *controller,
541 struct scic_sds_remote_device *remote_device,
542 enum sci_status completion_status)
544 struct isci_host *isci_host;
545 struct isci_remote_device *isci_device;
548 (struct isci_host *)sci_object_get_association(controller);
551 (struct isci_remote_device *)sci_object_get_association(
555 dev_dbg(&isci_host->pdev->dev,
556 "%s: isci_device = %p\n", __func__, isci_device);
558 isci_remote_device_stop_complete(
559 isci_host, isci_device, completion_status);
564 * scic_cb_remote_device_ready() - This user callback method will inform the
565 * user that a remote device is now capable of handling IO requests.
566 * @controller: This parameter specifies the core controller associated with
567 * the completion callback.
568 * @remote_device: This parameter specifies the remote device associated with
572 void scic_cb_remote_device_ready(
573 struct scic_sds_controller *controller,
574 struct scic_sds_remote_device *remote_device)
576 struct isci_remote_device *isci_device =
577 (struct isci_remote_device *)
578 sci_object_get_association(remote_device);
580 dev_dbg(&isci_device->isci_port->isci_host->pdev->dev,
581 "%s: isci_device = %p\n", __func__, isci_device);
583 isci_remote_device_ready(isci_device);
587 * scic_cb_remote_device_not_ready() - This user callback method will inform
588 * the user that a remote device is no longer capable of handling IO
589 * requests (until a ready callback is invoked).
590 * @controller: This parameter specifies the core controller associated with
591 * the completion callback.
592 * @remote_device: This parameter specifies the remote device associated with
594 * @reason_code: This parameter specifies the reason for the remote device
595 * going to a not ready state.
598 void scic_cb_remote_device_not_ready(
599 struct scic_sds_controller *controller,
600 struct scic_sds_remote_device *remote_device,
603 struct isci_remote_device *isci_device =
604 (struct isci_remote_device *)
605 sci_object_get_association(remote_device);
607 struct isci_host *isci_host;
610 (struct isci_host *)sci_object_get_association(controller);
612 dev_dbg(&isci_host->pdev->dev,
613 "%s: isci_device = %p, reason_code = %x\n",
614 __func__, isci_device, reason_code);
616 isci_remote_device_not_ready(isci_device, reason_code);