isci: core
Subsystems (2)
cover isci: core
As first introduced in "[RFC PATCH 0/6] isci: initial driver release (part1: intro and lldd) " [1], the isci driver is split into an lldd layer that interfaces with libsas and a core layer that interfaces with the hardware. Quoting from the original introduction:
Driver overview:
The hardware accelerates all the protocol fast paths (SSP, STP FPDMA and UDMA), and relies on the the driver for everything else. One example is legacy sata pio reads which are managed "manually" by their own state machine in the driver. The driver submits the read and when the data fis comes back the hardware, not having acceleration for pio operations, assigns it to an unidentified frame queue. The core then associates that frame with the pending pio request, copies the data into the location specified by the original sgl, and completes the command up to the lldd.
Since the initial import the core has shed about 10k lines of code. The todo list has also shrunk, we have eliminated the os abstractions (formerly in drivers/scsi/isci/deprecated.c), and usages of phys_to_virt and virt_to_phys have been replaced with proper dma api and kmap calls.
The full driver and history is available in git:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git master
The libsas-pending branch contains proposed libsas fixes (pending acceptance into scsi-misc):
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git libsas-pending
The x86-pending branch contains a proposed api for mapping bios roms so the driver can retrieve configuration parameters (pending acceptance into -tip):
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git x86-pending
--
Dan for the isci driver team
[1]: http://marc.info/?l=linux-scsi&m=129703780424729&w=2
---
Dan Williams (10):
isci/core: controller
isci/core: phy
isci/core: port
isci/core: remote device
isci/core: remote node context
isci/core: stp
isci/core: request (general, ssp and smp) isci/core: unsolicited frame handling and registers isci/core: base state machine and memory descriptors isci/core: common definitions and utility functions
drivers/scsi/isci/core/intel_ata.h | 554 +++ drivers/scsi/isci/core/intel_sas.h | 948 +++++ drivers/scsi/isci/core/intel_sat.h | 95 drivers/scsi/isci/core/intel_sata.h | 280 + drivers/scsi/isci/core/intel_scsi.h | 474 ++ drivers/scsi/isci/core/sati_device.h | 156 + drivers/scsi/isci/core/sati_translator_sequence.h | 304 ++ drivers/scsi/isci/core/sati_types.h | 145 + drivers/scsi/isci/core/sci_base_controller.h | 306 ++ .../isci/core/sci_base_memory_descriptor_list.c | 159 + .../isci/core/sci_base_memory_descriptor_list.h | 153 + drivers/scsi/isci/core/sci_base_phy.h | 200 + drivers/scsi/isci/core/sci_base_port.h | 203 + drivers/scsi/isci/core/sci_base_remote_device.h | 274 + drivers/scsi/isci/core/sci_base_request.h | 195 + drivers/scsi/isci/core/sci_base_state.h | 90 drivers/scsi/isci/core/sci_base_state_machine.c | 182 + drivers/scsi/isci/core/sci_base_state_machine.h | 141 + drivers/scsi/isci/core/sci_controller.h | 98 + drivers/scsi/isci/core/sci_controller_constants.h | 215 + .../scsi/isci/core/sci_memory_descriptor_list.h | 168 + drivers/scsi/isci/core/sci_object.h | 98 + drivers/scsi/isci/core/sci_pool.h | 199 + drivers/scsi/isci/core/sci_status.h | 409 ++ drivers/scsi/isci/core/sci_util.c | 101 + drivers/scsi/isci/core/sci_util.h | 108 + drivers/scsi/isci/core/scic_config_parameters.h | 346 ++ drivers/scsi/isci/core/scic_controller.h | 495 +++ drivers/scsi/isci/core/scic_io_request.h | 511 +++ drivers/scsi/isci/core/scic_phy.h | 305 ++ drivers/scsi/isci/core/scic_port.h | 195 + drivers/scsi/isci/core/scic_remote_device.h | 294 ++ drivers/scsi/isci/core/scic_sds_controller.c | 3804 ++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_controller.h | 722 ++++ .../scsi/isci/core/scic_sds_controller_registers.h | 463 ++ drivers/scsi/isci/core/scic_sds_pci.h | 94 drivers/scsi/isci/core/scic_sds_phy.c | 2726 ++++++++++++++ drivers/scsi/isci/core/scic_sds_phy.h | 476 +++ drivers/scsi/isci/core/scic_sds_phy_registers.h | 248 + drivers/scsi/isci/core/scic_sds_port.c | 2915 +++++++++++++++ drivers/scsi/isci/core/scic_sds_port.h | 499 +++ .../isci/core/scic_sds_port_configuration_agent.c | 863 +++++ .../isci/core/scic_sds_port_configuration_agent.h | 108 + drivers/scsi/isci/core/scic_sds_port_registers.h | 147 + drivers/scsi/isci/core/scic_sds_remote_device.c | 2079 +++++++++++ drivers/scsi/isci/core/scic_sds_remote_device.h | 570 +++ .../scsi/isci/core/scic_sds_remote_node_context.c | 1247 +++++++ .../scsi/isci/core/scic_sds_remote_node_context.h | 323 ++ .../scsi/isci/core/scic_sds_remote_node_table.c | 600 +++ .../scsi/isci/core/scic_sds_remote_node_table.h | 195 + drivers/scsi/isci/core/scic_sds_request.c | 2174 +++++++++++ drivers/scsi/isci/core/scic_sds_request.h | 469 ++ .../scsi/isci/core/scic_sds_smp_remote_device.c | 325 ++ drivers/scsi/isci/core/scic_sds_smp_request.c | 669 ++++ drivers/scsi/isci/core/scic_sds_smp_request.h | 69 drivers/scsi/isci/core/scic_sds_ssp_request.c | 268 + .../scsi/isci/core/scic_sds_stp_packet_request.c | 834 ++++ .../scsi/isci/core/scic_sds_stp_packet_request.h | 153 + drivers/scsi/isci/core/scic_sds_stp_pio_request.h | 116 + .../scsi/isci/core/scic_sds_stp_remote_device.c | 908 +++++ drivers/scsi/isci/core/scic_sds_stp_request.c | 1941 ++++++++++ drivers/scsi/isci/core/scic_sds_stp_request.h | 221 + .../isci/core/scic_sds_unsolicited_frame_control.c | 383 ++ .../isci/core/scic_sds_unsolicited_frame_control.h | 286 ++ drivers/scsi/isci/core/scic_task_request.h | 147 + drivers/scsi/isci/core/scu_completion_codes.h | 283 + drivers/scsi/isci/core/scu_constants.h | 151 + drivers/scsi/isci/core/scu_event_codes.h | 336 ++ drivers/scsi/isci/core/scu_registers.h | 1830 ++++++++++ drivers/scsi/isci/core/scu_remote_node_context.h | 229 + drivers/scsi/isci/core/scu_task_context.h | 942 +++++ drivers/scsi/isci/core/scu_unsolicited_frame.h | 117 + drivers/scsi/isci/core/scu_viit_data.h | 178 + 73 files changed, 39509 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/intel_ata.h create mode 100644 drivers/scsi/isci/core/intel_sas.h create mode 100644 drivers/scsi/isci/core/intel_sat.h create mode 100644 drivers/scsi/isci/core/intel_sata.h create mode 100644 drivers/scsi/isci/core/intel_scsi.h create mode 100644 drivers/scsi/isci/core/sati_device.h create mode 100644 drivers/scsi/isci/core/sati_translator_sequence.h create mode 100644 drivers/scsi/isci/core/sati_types.h create mode 100644 drivers/scsi/isci/core/sci_base_controller.h create mode 100644 drivers/scsi/isci/core/sci_base_memory_descriptor_list.c create mode 100644 drivers/scsi/isci/core/sci_base_memory_descriptor_list.h create mode 100644 drivers/scsi/isci/core/sci_base_phy.h create mode 100644 drivers/scsi/isci/core/sci_base_port.h create mode 100644 drivers/scsi/isci/core/sci_base_remote_device.h create mode 100644 drivers/scsi/isci/core/sci_base_request.h create mode 100644 drivers/scsi/isci/core/sci_base_state.h create mode 100644 drivers/scsi/isci/core/sci_base_state_machine.c create mode 100644 drivers/scsi/isci/core/sci_base_state_machine.h create mode 100644 drivers/scsi/isci/core/sci_controller.h create mode 100644 drivers/scsi/isci/core/sci_controller_constants.h create mode 100644 drivers/scsi/isci/core/sci_memory_descriptor_list.h create mode 100644 drivers/scsi/isci/core/sci_object.h create mode 100644 drivers/scsi/isci/core/sci_pool.h create mode 100644 drivers/scsi/isci/core/sci_status.h create mode 100644 drivers/scsi/isci/core/sci_util.c create mode 100644 drivers/scsi/isci/core/sci_util.h create mode 100644 drivers/scsi/isci/core/scic_config_parameters.h create mode 100644 drivers/scsi/isci/core/scic_controller.h create mode 100644 drivers/scsi/isci/core/scic_io_request.h create mode 100644 drivers/scsi/isci/core/scic_phy.h create mode 100644 drivers/scsi/isci/core/scic_port.h create mode 100644 drivers/scsi/isci/core/scic_remote_device.h create mode 100644 drivers/scsi/isci/core/scic_sds_controller.c create mode 100644 drivers/scsi/isci/core/scic_sds_controller.h create mode 100644 drivers/scsi/isci/core/scic_sds_controller_registers.h create mode 100644 drivers/scsi/isci/core/scic_sds_pci.h create mode 100644 drivers/scsi/isci/core/scic_sds_phy.c create mode 100644 drivers/scsi/isci/core/scic_sds_phy.h create mode 100644 drivers/scsi/isci/core/scic_sds_phy_registers.h create mode 100644 drivers/scsi/isci/core/scic_sds_port.c create mode 100644 drivers/scsi/isci/core/scic_sds_port.h create mode 100644 drivers/scsi/isci/core/scic_sds_port_configuration_agent.c create mode 100644 drivers/scsi/isci/core/scic_sds_port_configuration_agent.h create mode 100644 drivers/scsi/isci/core/scic_sds_port_registers.h create mode 100644 drivers/scsi/isci/core/scic_sds_remote_device.c create mode 100644 drivers/scsi/isci/core/scic_sds_remote_device.h create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_context.c create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_context.h create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_table.c create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_table.h create mode 100644 drivers/scsi/isci/core/scic_sds_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_smp_remote_device.c create mode 100644 drivers/scsi/isci/core/scic_sds_smp_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_smp_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_ssp_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_packet_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_packet_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_stp_pio_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_stp_remote_device.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c create mode 100644 drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.h create mode 100644 drivers/scsi/isci/core/scic_task_request.h create mode 100644 drivers/scsi/isci/core/scu_completion_codes.h create mode 100644 drivers/scsi/isci/core/scu_constants.h create mode 100644 drivers/scsi/isci/core/scu_event_codes.h create mode 100644 drivers/scsi/isci/core/scu_registers.h create mode 100644 drivers/scsi/isci/core/scu_remote_node_context.h create mode 100644 drivers/scsi/isci/core/scu_task_context.h create mode 100644 drivers/scsi/isci/core/scu_unsolicited_frame.h create mode 100644 drivers/scsi/isci/core/scu_viit_data.h
RFC PATCH 1/10 isci/core: controller
Controller state machines and hardware interface.
--- drivers/scsi/isci/core/sci_base_controller.h | 306 ++ drivers/scsi/isci/core/sci_controller.h | 98 + drivers/scsi/isci/core/sci_controller_constants.h | 215 + drivers/scsi/isci/core/scic_controller.h | 495 +++ drivers/scsi/isci/core/scic_sds_controller.c | 3804 ++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_controller.h | 722 ++++ .../scsi/isci/core/scic_sds_controller_registers.h | 463 ++ 7 files changed, 6103 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/sci_base_controller.h create mode 100644 drivers/scsi/isci/core/sci_controller.h create mode 100644 drivers/scsi/isci/core/sci_controller_constants.h create mode 100644 drivers/scsi/isci/core/scic_controller.h create mode 100644 drivers/scsi/isci/core/scic_sds_controller.c create mode 100644 drivers/scsi/isci/core/scic_sds_controller.h create mode 100644 drivers/scsi/isci/core/scic_sds_controller_registers.h
drivers/scsi/isci/core/sci_base_controller.h new file +306 -0
@@ -0,0 +1,306 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _SCI_BASE_CONTROLLER_H_ +#define _SCI_BASE_CONTROLLER_H_ + +#include "intel_sas.h" +#include "sci_controller_constants.h" +#include "sci_base_state.h" +#include "sci_base_memory_descriptor_list.h" +#include "sci_base_state_machine.h" +#include "sci_object.h" + +struct sci_base_memory_descriptor_list ; + +/** +* enum sci_base_controller_states - This enumeration depicts all the states +* for the common controller state machine. +* +* +*/ +enum sci_base_controller_states { +/** +* Simply the initial state for the base controller state machine. +*/ +SCI_BASE_CONTROLLER_STATE_INITIAL =0 , + +/** +* This state indicates that the controller is reset. The memory for +* the controller is in it's initial state, but the controller requires +* initialization. +* This state is entered from the INITIAL state. +* This state is entered from the RESETTING state. +*/ +SCI_BASE_CONTROLLER_STATE_RESET , + +/** +* This state is typically an action state that indicates the controller +* is in the process of initialization. In this state no new IO operations +* are permitted. +* This state is entered from the RESET state. +*/ +SCI_BASE_CONTROLLER_STATE_INITIALIZING , + +/** +* This state indicates that the controller has been successfully +* initialized. In this state no new IO operations are permitted. +* This state is entered from the INITIALIZING state. +*/ +SCI_BASE_CONTROLLER_STATE_INITIALIZED , + +/** +* This state indicates the the controller is in the process of becoming +* ready (i.e. starting). In this state no new IO operations are permitted. +* This state is entered from the INITIALIZED state. +*/ +SCI_BASE_CONTROLLER_STATE_STARTING , + +/** +* This state indicates the controller is now ready. Thus, the user +* is able to perform IO operations on the controller. +* This state is entered from the STARTING state. +*/ +SCI_BASE_CONTROLLER_STATE_READY , + +/** +* This state is typically an action state that indicates the controller +* is in the process of resetting. Thus, the user is unable to perform +* IO operations on the controller. A reset is considered destructive in +* most cases. +* This state is entered from the READY state. +* This state is entered from the FAILED state. +* This state is entered from the STOPPED state. +*/ +SCI_BASE_CONTROLLER_STATE_RESETTING , + +/** +* This state indicates that the controller is in the process of stopping. +* In this state no new IO operations are permitted, but existing IO +* operations are allowed to complete. +* This state is entered from the READY state. +*/ +SCI_BASE_CONTROLLER_STATE_STOPPING , + +/** +* This state indicates that the controller has successfully been stopped. +* In this state no new IO operations are permitted. +* This state is entered from the STOPPING state. +*/ +SCI_BASE_CONTROLLER_STATE_STOPPED , + +/** +* This state indicates that the controller could not successfully be +* initialized. In this state no new IO operations are permitted. +* This state is entered from the INITIALIZING state. +* This state is entered from the STARTING state. +* This state is entered from the STOPPING state. +* This state is entered from the RESETTING state. +*/ +SCI_BASE_CONTROLLER_STATE_FAILED , + +SCI_BASE_CONTROLLER_MAX_STATES + +}; + +/** +* struct sci_base_controller - The base controller object abstracts the fields +* common to all SCI controller objects. +* +* +*/ +struct sci_base_controller { +/** +* The field specifies that the parent object for the base controller +* is the base object itself. +*/ +struct sci_base_object parent; + +/** +* This field points to the memory descriptor list associated with this +* controller. The MDL indicates the memory requirements necessary for +* this controller object. +*/ +struct sci_base_memory_descriptor_list mdl; + +/** +* This field contains the information for the base controller state +* machine. +*/ +struct sci_base_state_machine state_machine; +}; + +/* Forward declarations */ +struct sci_base_remote_device ; +struct sci_base_request ; + +typedef enum sci_status +(*sci_base_controller_handler_t )(struct sci_base_controller *); + +typedef enum sci_status +(*sci_base_controller_timed_handler_t )(struct sci_base_controller *,u32 ); + +typedef enum sci_status +(*sci_base_controller_request_handler_t )(struct sci_base_controller *, +struct sci_base_remote_device *, +struct sci_base_request *); + +typedef enum sci_status +(*sci_base_controller_start_request_handler_t )(struct sci_base_controller *, +struct sci_base_remote_device *, +struct sci_base_request *,u16 ); + +/** +* struct sci_base_controller_state_handler - This structure contains all of +* the state handler methods common to base controller state machines. +* Handler methods provide the ability to change the behavior for user +* requests or transitions depending on the state the machine is in. +* +* +*/ +struct sci_base_controller_state_handler { +/** +* The start_handler specifies the method invoked when a user attempts to +* start a controller. +*/ +sci_base_controller_timed_handler_t start; + +/** +* The stop_handler specifies the method invoked when a user attempts to +* stop a controller. +*/ +sci_base_controller_timed_handler_t stop; + +/** +* The reset_handler specifies the method invoked when a user attempts to +* reset a controller. +*/ +sci_base_controller_handler_t reset; + +/** +* The initialize_handler specifies the method invoked when a user +* attempts to initialize a controller. +*/ +sci_base_controller_handler_t initialize; + +/** +* The start_io_handler specifies the method invoked when a user +* attempts to start an IO request for a controller. +*/ +sci_base_controller_start_request_handler_t start_io; + +/** +* The complete_io_handler specifies the method invoked when a user +* attempts to complete an IO request for a controller. +*/ +sci_base_controller_request_handler_t complete_io; + +/** +* The continue_io_handler specifies the method invoked when a user +* attempts to continue an IO request for a controller. +*/ +sci_base_controller_request_handler_t continue_io; + +/** +* The start_task_handler specifies the method invoked when a user +* attempts to start a task management request for a controller. +*/ +sci_base_controller_start_request_handler_t start_task; + +/** +* The complete_task_handler specifies the method invoked when a user +* attempts to complete a task management request for a controller. +*/ +sci_base_controller_request_handler_t complete_task; + +}; + +/** +* sci_base_controller_construct() - Construct the base controller +* @this_controller: This parameter specifies the base controller to be +* constructed. +* @state_table: This parameter specifies the table of state definitions to be +* utilized for the controller state machine. +* @mde_array: This parameter specifies the array of memory descriptor entries +* to be managed by this list. +* @mde_array_length: This parameter specifies the size of the array of entries. +* @next_mdl: This parameter specifies a subsequent MDL object to be managed by +* this MDL object. +* @oem_parameters: This parameter specifies the original equipment +* manufacturer parameters to be utilized by this controller object. +* +*/ +static inline void sci_base_controller_construct ( +struct sci_base_controller *scic_base, +const struct sci_base_state *state_table, +struct sci_physical_memory_descriptor *mdes, +u32 mde_count, +struct sci_base_memory_descriptor_list *next_mdl) +{ + scic_base->parent.private =NULL ; + +sci_base_state_machine_construct ( + &scic_base->state_machine, + &scic_base->parent, + state_table, +SCI_BASE_CONTROLLER_STATE_INITIAL + ); + +sci_base_mdl_construct (&scic_base->mdl, mdes, mde_count, next_mdl); + +sci_base_state_machine_start (&scic_base->state_machine); +} + +#endif /* _SCI_BASE_CONTROLLER_H_ */
drivers/scsi/isci/core/sci_controller.h new file +98 -0
98 lines not on this page · raw message
drivers/scsi/isci/core/sci_controller_constants.h new file +215 -0
215 lines not on this page · raw message
drivers/scsi/isci/core/scic_controller.h new file +495 -0
495 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_controller.c new file +3804 -0
1,886 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_controller.h new file +722 -0
722 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_controller_registers.h new file +463 -0
463 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH 2/10 isci/core: phy
In reply to Dan WilliamsPhy state machines and hardware interface.
--- drivers/scsi/isci/core/sci_base_phy.h | 200 ++ drivers/scsi/isci/core/scic_phy.h | 305 +++ drivers/scsi/isci/core/scic_sds_phy.c | 2726 +++++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_phy.h | 476 ++++ drivers/scsi/isci/core/scic_sds_phy_registers.h | 248 ++ 5 files changed, 3955 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/sci_base_phy.h create mode 100644 drivers/scsi/isci/core/scic_phy.h create mode 100644 drivers/scsi/isci/core/scic_sds_phy.c create mode 100644 drivers/scsi/isci/core/scic_sds_phy.h create mode 100644 drivers/scsi/isci/core/scic_sds_phy_registers.h
drivers/scsi/isci/core/sci_base_phy.h new file +200 -0
@@ -0,0 +1,200 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _SCI_BASE_PHY_H_ +#define _SCI_BASE_PHY_H_ + +/** +* This file contains all of the structures, constants, and methods common to +* all phy object definitions. +* +* +*/ + +#include "sci_base_state_machine.h" + +/** +* enum sci_base_phy_states - This enumeration depicts the standard states +* common to all phy state machine implementations. +* +* +*/ +enum sci_base_phy_states { +/** +* Simply the initial state for the base domain state machine. +*/ +SCI_BASE_PHY_STATE_INITIAL , + +/** +* This state indicates that the phy has successfully been stopped. +* In this state no new IO operations are permitted on this phy. +* This state is entered from the INITIAL state. +* This state is entered from the STARTING state. +* This state is entered from the READY state. +* This state is entered from the RESETTING state. +*/ +SCI_BASE_PHY_STATE_STOPPED , + +/** +* This state indicates that the phy is in the process of becomming +* ready. In this state no new IO operations are permitted on this phy. +* This state is entered from the STOPPED state. +* This state is entered from the READY state. +* This state is entered from the RESETTING state. +*/ +SCI_BASE_PHY_STATE_STARTING , + +/** +* This state indicates the the phy is now ready. Thus, the user +* is able to perform IO operations utilizing this phy as long as it +* is currently part of a valid port. +* This state is entered from the STARTING state. +*/ +SCI_BASE_PHY_STATE_READY , + +/** +* This state indicates that the phy is in the process of being reset. +* In this state no new IO operations are permitted on this phy. +* This state is entered from the READY state. +*/ +SCI_BASE_PHY_STATE_RESETTING , + +/** +* Simply the final state for the base phy state machine. +*/ +SCI_BASE_PHY_STATE_FINAL , +}; + +/** +* struct sci_base_phy - This structure defines all of the fields common to PHY +* objects. +* +* +*/ +struct sci_base_phy { +/** +* This field depicts the parent object (struct sci_base_object) for the phy. +*/ +struct sci_base_object parent; + +/** +* This field contains the information for the base phy state machine. +*/ +struct sci_base_state_machine state_machine; +}; + +typedef enum sci_status (*sci_base_phy_handler_t )(struct sci_base_phy *); + +/** +* struct sci_base_phy_state_handler - This structure contains all of the state +* handler methods common to base phy state machines. Handler methods +* provide the ability to change the behavior for user requests or +* transitions depending on the state the machine is in. +* +* +*/ +struct sci_base_phy_state_handler { +/** +* The start_handler specifies the method invoked when there is an +* attempt to start a phy. +*/ +sci_base_phy_handler_t start_handler; + +/** +* The stop_handler specifies the method invoked when there is an +* attempt to stop a phy. +*/ +sci_base_phy_handler_t stop_handler; + +/** +* The reset_handler specifies the method invoked when there is an +* attempt to reset a phy. +*/ +sci_base_phy_handler_t reset_handler; + +/** +* The destruct_handler specifies the method invoked when attempting to +* destruct a phy. +*/ +sci_base_phy_handler_t destruct_handler; + +}; + +/** +* sci_base_phy_construct() - Construct the base phy +* @this_phy: This parameter specifies the base phy to be constructed. +* @state_table: This parameter specifies the table of state definitions to be +* utilized for the phy state machine. +* +*/ +static inline void sci_base_phy_construct ( +struct sci_base_phy *base_phy, +const struct sci_base_state *state_table) +{ + base_phy->parent.private =NULL ; +sci_base_state_machine_construct ( + &base_phy->state_machine, + &base_phy->parent, + state_table, +SCI_BASE_PHY_STATE_INITIAL + ); + +sci_base_state_machine_start ( + &base_phy->state_machine + ); +} + + +#endif /* _SCI_BASE_PHY_H_ */
drivers/scsi/isci/core/scic_phy.h new file +305 -0
305 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_phy.c new file +2726 -0
2,495 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_phy.h new file +476 -0
476 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_phy_registers.h new file +248 -0
248 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH 3/10 isci/core: port
In reply to Dan WilliamsPort state machines and port configuration agent.
--- drivers/scsi/isci/core/sci_base_port.h | 203 + drivers/scsi/isci/core/scic_port.h | 195 + drivers/scsi/isci/core/scic_sds_port.c | 2915 ++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_port.h | 499 +++ .../isci/core/scic_sds_port_configuration_agent.c | 863 ++++++ .../isci/core/scic_sds_port_configuration_agent.h | 108 + drivers/scsi/isci/core/scic_sds_port_registers.h | 147 + 7 files changed, 4930 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/sci_base_port.h create mode 100644 drivers/scsi/isci/core/scic_port.h create mode 100644 drivers/scsi/isci/core/scic_sds_port.c create mode 100644 drivers/scsi/isci/core/scic_sds_port.h create mode 100644 drivers/scsi/isci/core/scic_sds_port_configuration_agent.c create mode 100644 drivers/scsi/isci/core/scic_sds_port_configuration_agent.h create mode 100644 drivers/scsi/isci/core/scic_sds_port_registers.h
drivers/scsi/isci/core/sci_base_port.h new file +203 -0
@@ -0,0 +1,203 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _SCI_BASE_PORT_H_ +#define _SCI_BASE_PORT_H_ + +#include "sci_base_state_machine.h" +#include "sci_object.h" + +/** +* enum sci_base_port_states - This enumeration depicts all the states for the +* common port state machine. +* +* +*/ +enum sci_base_port_states { +/** +* This state indicates that the port has successfully been stopped. +* In this state no new IO operations are permitted. +* This state is entered from the STOPPING state. +*/ +SCI_BASE_PORT_STATE_STOPPED , + +/** +* This state indicates that the port is in the process of stopping. +* In this state no new IO operations are permitted, but existing IO +* operations are allowed to complete. +* This state is entered from the READY state. +*/ +SCI_BASE_PORT_STATE_STOPPING , + +/** +* This state indicates the port is now ready. Thus, the user is +* able to perform IO operations on this port. +* This state is entered from the STARTING state. +*/ +SCI_BASE_PORT_STATE_READY , + +/** +* This state indicates the port is in the process of performing a hard +* reset. Thus, the user is unable to perform IO operations on this +* port. +* This state is entered from the READY state. +*/ +SCI_BASE_PORT_STATE_RESETTING , + +/** +* This state indicates the port has failed a reset request. This state +* is entered when a port reset request times out. +* This state is entered from the RESETTING state. +*/ +SCI_BASE_PORT_STATE_FAILED , + +SCI_BASE_PORT_MAX_STATES + +}; + +/** +* struct sci_base_port - The base port object abstracts the fields common to +* all SCI port objects. +* +* +*/ +struct sci_base_port { +/** +* The field specifies that the parent object for the base controller +* is the base object itself. +*/ +struct sci_base_object parent; + +/** +* This field contains the information for the base port state machine. +*/ +struct sci_base_state_machine state_machine; +}; + +struct sci_base_phy ; + +typedef enum sci_status (*SCI_BASE_PORT_HANDLER_T )( +struct sci_base_port * + ); + +typedef enum sci_status (*SCI_BASE_PORT_PHY_HANDLER_T )( +struct sci_base_port *, +struct sci_base_phy * + ); + +typedef enum sci_status (*SCI_BASE_PORT_RESET_HANDLER_T )( +struct sci_base_port *, +u32 timeout + ); + +/** +* struct sci_base_port_state_handler - This structure contains all of the +* state handler methods common to base port state machines. Handler +* methods provide the ability to change the behavior for user requests or +* transitions depending on the state the machine is in. +* +* +*/ +struct sci_base_port_state_handler { +/** +* The start_handler specifies the method invoked when a user attempts to +* start a port. +*/ +SCI_BASE_PORT_HANDLER_T start_handler; + +/** +* The stop_handler specifies the method invoked when a user attempts to +* stop a port. +*/ +SCI_BASE_PORT_HANDLER_T stop_handler; + +/** +* The destruct_handler specifies the method invoked when attempting to +* destruct a port. +*/ +SCI_BASE_PORT_HANDLER_T destruct_handler; + +/** +* The reset_handler specifies the method invoked when a user attempts to +* hard reset a port. +*/ +SCI_BASE_PORT_RESET_HANDLER_T reset_handler; + +/** +* The add_phy_handler specifies the method invoked when a user attempts to +* add another phy into the port. +*/ +SCI_BASE_PORT_PHY_HANDLER_T add_phy_handler; + +/** +* The remove_phy_handler specifies the method invoked when a user +* attempts to remove a phy from the port. +*/ +SCI_BASE_PORT_PHY_HANDLER_T remove_phy_handler; + +}; + +/** +* sci_base_port_construct() - Construct the base port object +* @this_port: This parameter specifies the base port to be constructed. +* @state_table: This parameter specifies the table of state definitions to be +* utilized for the domain state machine. +* +*/ +void sci_base_port_construct ( +struct sci_base_port *this_port, +const struct sci_base_state *state_table); + +#endif /* _SCI_BASE_PORT_H_ */
drivers/scsi/isci/core/scic_port.h new file +195 -0
195 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_port.c new file +2915 -0
2,602 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_port.h new file +499 -0
499 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_port_configuration_agent.c new file +863 -0
863 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_port_configuration_agent.h new file +108 -0
108 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_port_registers.h new file +147 -0
147 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH 4/10 isci/core: remote device
In reply to Dan WilliamsSoftware representation of SSP, SMP, STP and direct attached SATA devices.
--- drivers/scsi/isci/core/sci_base_remote_device.h | 274 +++ drivers/scsi/isci/core/scic_remote_device.h | 294 +++ drivers/scsi/isci/core/scic_sds_remote_device.c | 2079 ++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_remote_device.h | 570 +++++ .../scsi/isci/core/scic_sds_smp_remote_device.c | 325 +++ .../scsi/isci/core/scic_sds_stp_remote_device.c | 908 +++++++++ 6 files changed, 4450 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/sci_base_remote_device.h create mode 100644 drivers/scsi/isci/core/scic_remote_device.h create mode 100644 drivers/scsi/isci/core/scic_sds_remote_device.c create mode 100644 drivers/scsi/isci/core/scic_sds_remote_device.h create mode 100644 drivers/scsi/isci/core/scic_sds_smp_remote_device.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_remote_device.c
drivers/scsi/isci/core/sci_base_remote_device.h new file +274 -0
@@ -0,0 +1,274 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _SCI_BASE_REMOTE_DEVICE_H_ +#define _SCI_BASE_REMOTE_DEVICE_H_ + +/** +* This file contains all of the structures, constants, and methods common to +* all remote device object definitions. +* +* +*/ + +#include "sci_base_state_machine.h" + +struct sci_base_request ; + +/** +* enum sci_base_remote_device_states - This enumeration depicts all the states +* for the common remote device state machine. +* +* +*/ +enum sci_base_remote_device_states { +/** +* Simply the initial state for the base remote device state machine. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_INITIAL , + +/** +* This state indicates that the remote device has successfully been +* stopped. In this state no new IO operations are permitted. +* This state is entered from the INITIAL state. +* This state is entered from the STOPPING state. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_STOPPED , + +/** +* This state indicates the the remote device is in the process of +* becoming ready (i.e. starting). In this state no new IO operations +* are permitted. +* This state is entered from the STOPPED state. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_STARTING , + +/** +* This state indicates the remote device is now ready. Thus, the user +* is able to perform IO operations on the remote device. +* This state is entered from the STARTING state. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_READY , + +/** +* This state indicates that the remote device is in the process of +* stopping. In this state no new IO operations are permitted, but +* existing IO operations are allowed to complete. +* This state is entered from the READY state. +* This state is entered from the FAILED state. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_STOPPING , + +/** +* This state indicates that the remote device has failed. +* In this state no new IO operations are permitted. +* This state is entered from the INITIALIZING state. +* This state is entered from the READY state. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_FAILED , + +/** +* This state indicates the device is being reset. +* In this state no new IO operations are permitted. +* This state is entered from the READY state. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_RESETTING , + +/** +* Simply the final state for the base remote device state machine. +*/ +SCI_BASE_REMOTE_DEVICE_STATE_FINAL , +}; + +/** +* struct sci_base_remote_device - The base remote device object abstracts the +* fields common to all SCI remote device objects. +* +* +*/ +struct sci_base_remote_device { +/** +* The field specifies that the parent object for the base remote +* device is the base object itself. +*/ +struct sci_base_object parent; + +/** +* This field contains the information for the base remote device state +* machine. +*/ +struct sci_base_state_machine state_machine; +}; + + +typedef enum sci_status (*sci_base_remote_device_handler_t )( +struct sci_base_remote_device * + ); + +typedef enum sci_status (*sci_base_remote_device_request_handler_t )( +struct sci_base_remote_device *, +struct sci_base_request * + ); + +typedef enum sci_status (*sci_base_remote_device_high_priority_request_complete_handler_t )( +struct sci_base_remote_device *, +struct sci_base_request *, +void *, +enum sci_io_status + ); + +/** +* struct sci_base_remote_device_state_handler - This structure contains all of +* the state handler methods common to base remote device state machines. +* Handler methods provide the ability to change the behavior for user +* requests or transitions depending on the state the machine is in. +* +* +*/ +struct sci_base_remote_device_state_handler { +/** +* The start_handler specifies the method invoked when a user attempts to +* start a remote device. +*/ +sci_base_remote_device_handler_t start_handler; + +/** +* The stop_handler specifies the method invoked when a user attempts to +* stop a remote device. +*/ +sci_base_remote_device_handler_t stop_handler; + +/** +* The fail_handler specifies the method invoked when a remote device +* failure has occurred. A failure may be due to an inability to +* initialize/configure the device. +*/ +sci_base_remote_device_handler_t fail_handler; + +/** +* The destruct_handler specifies the method invoked when attempting to +* destruct a remote device. +*/ +sci_base_remote_device_handler_t destruct_handler; + +/** +* The reset handler specifies the method invloked when requesting to reset a +* remote device. +*/ +sci_base_remote_device_handler_t reset_handler; + +/** +* The reset complete handler specifies the method invloked when reporting +* that a reset has completed to the remote device. +*/ +sci_base_remote_device_handler_t reset_complete_handler; + +/** +* The start_io_handler specifies the method invoked when a user +* attempts to start an IO request for a remote device. +*/ +sci_base_remote_device_request_handler_t start_io_handler; + +/** +* The complete_io_handler specifies the method invoked when a user +* attempts to complete an IO request for a remote device. +*/ +sci_base_remote_device_request_handler_t complete_io_handler; + +/** +* The continue_io_handler specifies the method invoked when a user +* attempts to continue an IO request for a remote device. +*/ +sci_base_remote_device_request_handler_t continue_io_handler; + +/** +* The start_task_handler specifies the method invoked when a user +* attempts to start a task management request for a remote device. +*/ +sci_base_remote_device_request_handler_t start_task_handler; + +/** +* The complete_task_handler specifies the method invoked when a user +* attempts to complete a task management request for a remote device. +*/ +sci_base_remote_device_request_handler_t complete_task_handler; + +}; + +/** +* sci_base_remote_device_construct() - Construct the base remote device +* @this_remote_device: This parameter specifies the base remote device to be +* constructed. +* @state_table: This parameter specifies the table of state definitions to be +* utilized for the remote device state machine. +* +*/ +static inline void sci_base_remote_device_construct ( +struct sci_base_remote_device *base_dev, +const struct sci_base_state *state_table) +{ + base_dev->parent.private =NULL ; +sci_base_state_machine_construct ( + &base_dev->state_machine, + &base_dev->parent, + state_table, +SCI_BASE_REMOTE_DEVICE_STATE_INITIAL + ); + +sci_base_state_machine_start ( + &base_dev->state_machine + ); +} +#endif /* _SCI_BASE_REMOTE_DEVICE_H_ */
drivers/scsi/isci/core/scic_remote_device.h new file +294 -0
294 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_remote_device.c new file +2079 -0
2,079 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_remote_device.h new file +570 -0
353 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_smp_remote_device.c new file +325 -0
325 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_stp_remote_device.c new file +908 -0
908 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH 5/10 isci/core: remote node context
In reply to Dan WilliamsA remote node context is a descriptor that represents an end device. An SSP device consumes 1 descriptor while an STP target consumes 3. There are 256 remote node context descriptor that can be active at any given point in time.
--- .../scsi/isci/core/scic_sds_remote_node_context.c | 1247 ++++++++++++++++++++ .../scsi/isci/core/scic_sds_remote_node_context.h | 323 +++++ .../scsi/isci/core/scic_sds_remote_node_table.c | 600 ++++++++++ .../scsi/isci/core/scic_sds_remote_node_table.h | 195 +++ drivers/scsi/isci/core/scu_remote_node_context.h | 229 ++++ 5 files changed, 2594 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_context.c create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_context.h create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_table.c create mode 100644 drivers/scsi/isci/core/scic_sds_remote_node_table.h create mode 100644 drivers/scsi/isci/core/scu_remote_node_context.h
drivers/scsi/isci/core/scic_sds_remote_node_context.c new file +1247 -0
@@ -0,0 +1,1247 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "sci_base_state_machine.h" +#include "scic_remote_device.h" +#include "scic_sds_controller.h" +#include "scic_sds_port.h" +#include "scic_sds_remote_device.h" +#include "scic_sds_remote_node_context.h" +#include "sci_environment.h" +#include "sci_util.h" +#include "scu_event_codes.h" +#include "scu_task_context.h" + +void scic_sds_remote_node_context_construct ( +struct scic_sds_remote_device *device, +struct scic_sds_remote_node_context *rnc, +u16 remote_node_index) +{ +memset (rnc,0 ,sizeof (struct scic_sds_remote_node_context )); + + rnc->remote_node_index = remote_node_index; + rnc->device = device; + rnc->destination_state =SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED ; + +sci_base_state_machine_construct ( + &rnc->state_machine, + &rnc->parent, + scic_sds_remote_node_context_state_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE + ); + +sci_base_state_machine_start (&rnc->state_machine); +} + +/** +* +* @this_rnc: The RNC for which the is posted request is being made. +* +* This method will return true if the RNC is not in the initial state. In all +* other states the RNC is considered active and this will return true. The +* destroy request of the state machine drives the RNC back to the initial +* state. If the state machine changes then this routine will also have to be +* changed. bool true if the state machine is not in the initial state false if +* the state machine is in the initial state +*/ + +/** +* +* @this_rnc: The state of the remote node context object to check. +* +* This method will return true if the remote node context is in a READY state +* otherwise it will return false bool true if the remote node context is in +* the ready state. false if the remote node context is not in the ready state. +*/ +bool scic_sds_remote_node_context_is_ready ( +struct scic_sds_remote_node_context *this_rnc) +{ +u32 current_state =sci_base_state_machine_get_state (&this_rnc->state_machine); + +if (current_state ==SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE ) { +return true; + } + +return false; +} + +/** +* +* @this_device: The remote device to use to construct the RNC buffer. +* @rnc: The buffer into which the remote device data will be copied. +* +* This method will construct the RNC buffer for this remote device object. none +*/ +void scic_sds_remote_node_context_construct_buffer ( +struct scic_sds_remote_node_context *this_rnc) +{ +union scu_remote_node_context *rnc; +struct scic_sds_controller *the_controller; + + the_controller =scic_sds_remote_device_get_controller (this_rnc->device); + + rnc =scic_sds_controller_get_remote_node_context_buffer ( + the_controller, this_rnc->remote_node_index); + +memset ( + rnc, +0x00 , +sizeof (union scu_remote_node_context ) + *scic_sds_remote_device_node_count (this_rnc->device) + ); + + rnc->ssp.remote_node_index = this_rnc->remote_node_index; + rnc->ssp.remote_node_port_width = this_rnc->device->device_port_width; + rnc->ssp.logical_port_index = +scic_sds_remote_device_get_port_index (this_rnc->device); + + rnc->ssp.remote_sas_address_hi =SCIC_SWAP_DWORD (this_rnc->device->device_address.high); + rnc->ssp.remote_sas_address_lo =SCIC_SWAP_DWORD (this_rnc->device->device_address.low); + + rnc->ssp.nexus_loss_timer_enable = true; + rnc->ssp.check_bit = false; + rnc->ssp.is_valid = false; + rnc->ssp.is_remote_node_context = true; + rnc->ssp.function_number =0 ; + + rnc->ssp.arbitration_wait_time =0 ; + + +if ( + this_rnc->device->target_protocols.u.bits.attached_sata_device + || this_rnc->device->target_protocols.u.bits.attached_stp_target + ) { + rnc->ssp.connection_occupancy_timeout = + the_controller->user_parameters.sds1.stp_max_occupancy_timeout; + rnc->ssp.connection_inactivity_timeout = + the_controller->user_parameters.sds1.stp_inactivity_timeout; + }else { + rnc->ssp.connection_occupancy_timeout = + the_controller->user_parameters.sds1.ssp_max_occupancy_timeout; + rnc->ssp.connection_inactivity_timeout = + the_controller->user_parameters.sds1.ssp_inactivity_timeout; + } + + rnc->ssp.initial_arbitration_wait_time =0 ; + +/* Open Address Frame Parameters */ + rnc->ssp.oaf_connection_rate = this_rnc->device->connection_rate; + rnc->ssp.oaf_features =0 ; + rnc->ssp.oaf_source_zone_group =0 ; + rnc->ssp.oaf_more_compatibility_features =0 ; +} + +/** +* +* @this_rnc: +* @the_callback: +* @callback_parameter: +* +* This method will setup the remote node context object so it will transition +* to its ready state. If the remote node context is already setup to +* transition to its final state then this function does nothing. none +*/ +static void scic_sds_remote_node_context_setup_to_resume ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +if (this_rnc->destination_state !=SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL ) { + this_rnc->destination_state =SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY ; + this_rnc->user_callback = the_callback; + this_rnc->user_cookie = callback_parameter; + } +} + +/** +* +* @this_rnc: +* @the_callback: +* @callback_parameter: +* +* This method will setup the remote node context object so it will transistion +* to its final state. none +*/ +static void scic_sds_remote_node_context_setup_to_destory ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ + this_rnc->destination_state =SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL ; + this_rnc->user_callback = the_callback; + this_rnc->user_cookie = callback_parameter; +} + +/** +* +* @this_rnc: +* @the_callback: +* +* This method will continue to resume a remote node context. This is used in +* the states where a resume is requested while a resume is in progress. +*/ +static enum sci_status scic_sds_remote_node_context_continue_to_resume_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +if (this_rnc->destination_state ==SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY ) { + this_rnc->user_callback = the_callback; + this_rnc->user_cookie = callback_parameter; + +return SCI_SUCCESS ; + } + +return SCI_FAILURE_INVALID_STATE ; +} + +/* --------------------------------------------------------------------------- */ + +static enum sci_status scic_sds_remote_node_context_default_destruct_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to stop while " +"in unexpected state %d\n" , + __func__, + this_rnc, +sci_base_state_machine_get_state (&this_rnc->state_machine)); + +/* +* We have decided that the destruct request on the remote node context can not fail +* since it is either in the initial/destroyed state or is can be destroyed. */ +return SCI_SUCCESS ; +} + +static enum sci_status scic_sds_remote_node_context_default_suspend_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 suspend_type, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to suspend " +"while in wrong state %d\n" , + __func__, + this_rnc, +sci_base_state_machine_get_state (&this_rnc->state_machine)); + +return SCI_FAILURE_INVALID_STATE ; +} + +static enum sci_status scic_sds_remote_node_context_default_resume_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to resume " +"while in wrong state %d\n" , + __func__, + this_rnc, +sci_base_state_machine_get_state (&this_rnc->state_machine)); + +return SCI_FAILURE_INVALID_STATE ; +} + +static enum sci_status scic_sds_remote_node_context_default_start_io_handler ( +struct scic_sds_remote_node_context *this_rnc, +struct scic_sds_request *the_request) +{ +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to start io " +"0x%p while in wrong state %d\n" , + __func__, + this_rnc, + the_request, +sci_base_state_machine_get_state (&this_rnc->state_machine)); + +return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED ; +} + +static enum sci_status scic_sds_remote_node_context_default_start_task_handler ( +struct scic_sds_remote_node_context *this_rnc, +struct scic_sds_request *the_request) +{ +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to start " +"task 0x%p while in wrong state %d\n" , + __func__, + this_rnc, + the_request, +sci_base_state_machine_get_state (&this_rnc->state_machine)); + +return SCI_FAILURE ; +} + +static enum sci_status scic_sds_remote_node_context_default_event_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 event_code) +{ +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to process " +"event 0x%x while in wrong state %d\n" , + __func__, + this_rnc, + event_code, +sci_base_state_machine_get_state (&this_rnc->state_machine)); + +return SCI_FAILURE_INVALID_STATE ; +} + +/** +* +* @this_rnc: The rnc for which the task request is targeted. +* @the_request: The request which is going to be started. +* +* This method determines if the task request can be started by the SCU +* hardware. When the RNC is in the ready state any task can be started. +* enum sci_status SCI_SUCCESS +*/ +static enum sci_status scic_sds_remote_node_context_success_start_task_handler ( +struct scic_sds_remote_node_context *this_rnc, +struct scic_sds_request *the_request) +{ +return SCI_SUCCESS ; +} + +/** +* +* @this_rnc: +* @the_callback: +* @callback_parameter: +* +* This method handles destruct calls from the various state handlers. The +* remote node context can be requested to destroy from any state. If there was +* a user callback it is always replaced with the request to destroy user +* callback. enum sci_status +*/ +static enum sci_status scic_sds_remote_node_context_general_destruct_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +scic_sds_remote_node_context_setup_to_destory ( + this_rnc, the_callback, callback_parameter + ); + +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE + ); + +return SCI_SUCCESS ; +} + +/* --------------------------------------------------------------------------- */ + +static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +if (this_rnc->remote_node_index !=SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX ) { +scic_sds_remote_node_context_setup_to_resume ( + this_rnc, the_callback, callback_parameter + ); + +scic_sds_remote_node_context_construct_buffer (this_rnc); + +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE + ); + +return SCI_SUCCESS ; + } + +return SCI_FAILURE_INVALID_STATE ; +} + +/* --------------------------------------------------------------------------- */ + +static enum sci_status scic_sds_remote_node_context_posting_state_event_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 event_code) +{ +enum sci_status status; + +switch (scu_get_event_code (event_code)) { +case SCU_EVENT_POST_RNC_COMPLETE : + status =SCI_SUCCESS ; + +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE + ); +break ; + +default : + status =SCI_FAILURE ; +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to " +"process unexpected event 0x%x while in posting " +"state\n" , + __func__, + this_rnc, + event_code); +break ; + } + +return status; +} + +/* --------------------------------------------------------------------------- */ + +static enum sci_status scic_sds_remote_node_context_invalidating_state_destruct_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +scic_sds_remote_node_context_setup_to_destory ( + this_rnc, the_callback, callback_parameter + ); + +return SCI_SUCCESS ; +} + +static enum sci_status scic_sds_remote_node_context_invalidating_state_event_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 event_code) +{ +enum sci_status status; + +if (scu_get_event_code (event_code) ==SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE ) { + status =SCI_SUCCESS ; + +if (this_rnc->destination_state ==SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL ) { +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE + ); + }else { +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE + ); + } + }else { +switch (scu_get_event_type (event_code)) { +case SCU_EVENT_TYPE_RNC_SUSPEND_TX : +case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX : +/* +* We really dont care if the hardware is going to suspend +* the device since it's being invalidated anyway */ +dev_dbg (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p was " +"suspeneded by hardware while being " +"invalidated.\n" , + __func__, + this_rnc); + status =SCI_SUCCESS ; +break ; + +default : +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p " +"requested to process event 0x%x while " +"in state %d.\n" , + __func__, + this_rnc, + event_code, +sci_base_state_machine_get_state ( + &this_rnc->state_machine)); + status =SCI_FAILURE ; +break ; + } + } + +return status; +} + +/* --------------------------------------------------------------------------- */ + + +static enum sci_status scic_sds_remote_node_context_resuming_state_event_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 event_code) +{ +enum sci_status status; + +if (scu_get_event_code (event_code) ==SCU_EVENT_POST_RCN_RELEASE ) { + status =SCI_SUCCESS ; + +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE + ); + }else { +switch (scu_get_event_type (event_code)) { +case SCU_EVENT_TYPE_RNC_SUSPEND_TX : +case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX : +/* +* We really dont care if the hardware is going to suspend +* the device since it's being resumed anyway */ +dev_dbg (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p was " +"suspeneded by hardware while being resumed.\n" , + __func__, + this_rnc); + status =SCI_SUCCESS ; +break ; + +default : +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested " +"to process event 0x%x while in state %d.\n" , + __func__, + this_rnc, + event_code, +sci_base_state_machine_get_state ( + &this_rnc->state_machine)); + status =SCI_FAILURE ; +break ; + } + } + +return status; +} + +/* --------------------------------------------------------------------------- */ + +/** +* +* @this_rnc: The remote node context object being suspended. +* @the_callback: The callback when the suspension is complete. +* @callback_parameter: The parameter that is to be passed into the callback. +* +* This method will handle the suspend requests from the ready state. +* SCI_SUCCESS +*/ +static enum sci_status scic_sds_remote_node_context_ready_state_suspend_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 suspend_type, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ + this_rnc->user_callback = the_callback; + this_rnc->user_cookie = callback_parameter; + this_rnc->suspension_code = suspend_type; + +if (suspend_type ==SCI_SOFTWARE_SUSPENSION ) { +scic_sds_remote_device_post_request ( + this_rnc->device, +SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX + ); + } + +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE + ); + +return SCI_SUCCESS ; +} + +/** +* +* @this_rnc: The rnc for which the io request is targeted. +* @the_request: The request which is going to be started. +* +* This method determines if the io request can be started by the SCU hardware. +* When the RNC is in the ready state any io request can be started. enum sci_status +* SCI_SUCCESS +*/ +static enum sci_status scic_sds_remote_node_context_ready_state_start_io_handler ( +struct scic_sds_remote_node_context *this_rnc, +struct scic_sds_request *the_request) +{ +return SCI_SUCCESS ; +} + + +static enum sci_status scic_sds_remote_node_context_ready_state_event_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 event_code) +{ +enum sci_status status; + +switch (scu_get_event_type (event_code)) { +case SCU_EVENT_TL_RNC_SUSPEND_TX : +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE + ); + + this_rnc->suspension_code =scu_get_event_specifier (event_code); + status =SCI_SUCCESS ; +break ; + +case SCU_EVENT_TL_RNC_SUSPEND_TX_RX : +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE + ); + + this_rnc->suspension_code =scu_get_event_specifier (event_code); + status =SCI_SUCCESS ; +break ; + +default : +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to " +"process event 0x%x while in state %d.\n" , + __func__, + this_rnc, + event_code, +sci_base_state_machine_get_state ( + &this_rnc->state_machine)); + + status =SCI_FAILURE ; +break ; + } + +return status; +} + +/* --------------------------------------------------------------------------- */ + +static enum sci_status scic_sds_remote_node_context_tx_suspended_state_resume_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +enum sci_status status; +struct smp_discover_response_protocols protocols; + +scic_sds_remote_node_context_setup_to_resume ( + this_rnc, the_callback, callback_parameter + ); + +/* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */ + +scic_remote_device_get_protocols (this_rnc->device, &protocols); + +if ( + (protocols.u.bits.attached_ssp_target ==1 ) + || (protocols.u.bits.attached_smp_target ==1 ) + ) { +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE + ); + + status =SCI_SUCCESS ; + }else if (protocols.u.bits.attached_stp_target ==1 ) { +if (this_rnc->device->is_direct_attached) { +/* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */ +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE + ); + }else { +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE + ); + } + + status =SCI_SUCCESS ; + }else { + status =SCI_FAILURE ; + } + +return status; +} + +/** +* +* @this_rnc: The remote node context which is to receive the task request. +* @the_request: The task request to be transmitted to to the remote target +* device. +* +* This method will report a success or failure attempt to start a new task +* request to the hardware. Since all task requests are sent on the high +* priority queue they can be sent when the RCN is in a TX suspend state. +* enum sci_status SCI_SUCCESS +*/ +static enum sci_status scic_sds_remote_node_context_suspended_start_task_handler ( +struct scic_sds_remote_node_context *this_rnc, +struct scic_sds_request *the_request) +{ +scic_sds_remote_node_context_resume (this_rnc,NULL ,NULL ); + +return SCI_SUCCESS ; +} + +/* --------------------------------------------------------------------------- */ + +static enum sci_status scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +scic_sds_remote_node_context_setup_to_resume ( + this_rnc, the_callback, callback_parameter + ); + +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE + ); + +return SCI_FAILURE_INVALID_STATE ; +} + +/* --------------------------------------------------------------------------- */ + +/** +* +* +* +*/ +static enum sci_status scic_sds_remote_node_context_await_suspension_state_resume_handler ( +struct scic_sds_remote_node_context *this_rnc, +scics_sds_remote_node_context_callback the_callback, +void *callback_parameter) +{ +scic_sds_remote_node_context_setup_to_resume ( + this_rnc, the_callback, callback_parameter + ); + +return SCI_SUCCESS ; +} + +/** +* +* @this_rnc: The remote node context which is to receive the task request. +* @the_request: The task request to be transmitted to to the remote target +* device. +* +* This method will report a success or failure attempt to start a new task +* request to the hardware. Since all task requests are sent on the high +* priority queue they can be sent when the RCN is in a TX suspend state. +* enum sci_status SCI_SUCCESS +*/ +static enum sci_status scic_sds_remote_node_context_await_suspension_state_start_task_handler ( +struct scic_sds_remote_node_context *this_rnc, +struct scic_sds_request *the_request) +{ +return SCI_SUCCESS ; +} + +static enum sci_status scic_sds_remote_node_context_await_suspension_state_event_handler ( +struct scic_sds_remote_node_context *this_rnc, +u32 event_code) +{ +enum sci_status status; + +switch (scu_get_event_type (event_code)) { +case SCU_EVENT_TL_RNC_SUSPEND_TX : +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE + ); + + this_rnc->suspension_code =scu_get_event_specifier (event_code); + status =SCI_SUCCESS ; +break ; + +case SCU_EVENT_TL_RNC_SUSPEND_TX_RX : +sci_base_state_machine_change_state ( + &this_rnc->state_machine, +SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE + ); + + this_rnc->suspension_code =scu_get_event_specifier (event_code); + status =SCI_SUCCESS ; +break ; + +default : +dev_warn (scirdev_to_dev (this_rnc->device), +"%s: SCIC Remote Node Context 0x%p requested to " +"process event 0x%x while in state %d.\n" , + __func__, + this_rnc, + event_code, +sci_base_state_machine_get_state ( + &this_rnc->state_machine)); + + status =SCI_FAILURE ; +break ; + } + +return status; +} + +/* --------------------------------------------------------------------------- */ + +struct scic_sds_remote_node_context_handlers +scic_sds_remote_node_context_state_handler_table[ +SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES ] = +{ +/* SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE */ + { + scic_sds_remote_node_context_default_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_initial_state_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_default_start_task_handler, + scic_sds_remote_node_context_default_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE */ + { + scic_sds_remote_node_context_general_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_continue_to_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_default_start_task_handler, + scic_sds_remote_node_context_posting_state_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE */ + { + scic_sds_remote_node_context_invalidating_state_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_continue_to_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_default_start_task_handler, + scic_sds_remote_node_context_invalidating_state_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE */ + { + scic_sds_remote_node_context_general_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_continue_to_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_success_start_task_handler, + scic_sds_remote_node_context_resuming_state_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE */ + { + scic_sds_remote_node_context_general_destruct_handler, + scic_sds_remote_node_context_ready_state_suspend_handler, + scic_sds_remote_node_context_default_resume_handler, + scic_sds_remote_node_context_ready_state_start_io_handler, + scic_sds_remote_node_context_success_start_task_handler, + scic_sds_remote_node_context_ready_state_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE */ + { + scic_sds_remote_node_context_general_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_tx_suspended_state_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_suspended_start_task_handler, + scic_sds_remote_node_context_default_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE */ + { + scic_sds_remote_node_context_general_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_suspended_start_task_handler, + scic_sds_remote_node_context_default_event_handler + }, +/* SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE */ + { + scic_sds_remote_node_context_general_destruct_handler, + scic_sds_remote_node_context_default_suspend_handler, + scic_sds_remote_node_context_await_suspension_state_resume_handler, + scic_sds_remote_node_context_default_start_io_handler, + scic_sds_remote_node_context_await_suspension_state_start_task_handler, + scic_sds_remote_node_context_await_suspension_state_event_handler + } +}; + +/* +* ***************************************************************************** +* * REMOTE NODE CONTEXT PRIVATE METHODS +* ***************************************************************************** */ + +/** +* +* +* This method just calls the user callback function and then resets the +* callback. +*/ +static void scic_sds_remote_node_context_notify_user ( +struct scic_sds_remote_node_context *rnc) +{ +if (rnc->user_callback !=NULL ) { + (*rnc->user_callback)(rnc->user_cookie); + + rnc->user_callback =NULL ; + rnc->user_cookie =NULL ; + } +} + +/** +* +* +* This method will continue the remote node context state machine by +* requesting to resume the remote node context state machine from its current +* state. +*/ +static void scic_sds_remote_node_context_continue_state_transitions ( +struct scic_sds_remote_node_context *rnc) +{ +if (rnc->destination_state ==SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY ) { + rnc->state_handlers->resume_handler ( + rnc, rnc->user_callback, rnc->user_cookie + ); + } +} + +/** +* +* @this_rnc: The remote node context object that is to be validated. +* +* This method will mark the rnc buffer as being valid and post the request to +* the hardware. none +*/ +static void scic_sds_remote_node_context_validate_context_buffer ( +struct scic_sds_remote_node_context *this_rnc) +{ +union scu_remote_node_context *rnc_buffer; + + rnc_buffer =scic_sds_controller_get_remote_node_context_buffer ( +scic_sds_remote_device_get_controller (this_rnc->device), + this_rnc->remote_node_index + ); + + rnc_buffer->ssp.is_valid = true; + +if ( + !this_rnc->device->is_direct_attached + && this_rnc->device->target_protocols.u.bits.attached_stp_target + ) { +scic_sds_remote_device_post_request ( + this_rnc->device, +SCU_CONTEXT_COMMAND_POST_RNC_96 + ); + }else { +scic_sds_remote_device_post_request ( + this_rnc->device, +SCU_CONTEXT_COMMAND_POST_RNC_32 + ); + +if (this_rnc->device->is_direct_attached) { +scic_sds_port_setup_transports ( + this_rnc->device->owning_port, + this_rnc->remote_node_index + ); + } + } +} + +/** +* +* @this_rnc: The remote node context object that is to be invalidated. +* +* This method will update the RNC buffer and post the invalidate request. none +*/ +static void scic_sds_remote_node_context_invalidate_context_buffer ( +struct scic_sds_remote_node_context *this_rnc) +{ +union scu_remote_node_context *rnc_buffer; + + rnc_buffer =scic_sds_controller_get_remote_node_context_buffer ( +scic_sds_remote_device_get_controller (this_rnc->device), + this_rnc->remote_node_index + ); + + rnc_buffer->ssp.is_valid = false; + +scic_sds_remote_device_post_request ( + this_rnc->device, +SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE + ); +} + +/* +* ***************************************************************************** +* * REMOTE NODE CONTEXT STATE ENTER AND EXIT METHODS +* ***************************************************************************** */ + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_initial_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE + ); + +/* +* Check to see if we have gotten back to the initial state because someone +* requested to destroy the remote node context object. */ +if ( + rnc->state_machine.previous_state_id + ==SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE + ) { + rnc->destination_state =SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED ; + +scic_sds_remote_node_context_notify_user (rnc); + } +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_posting_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *this_rnc; + + this_rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + this_rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE + ); + +scic_sds_remote_node_context_validate_context_buffer (this_rnc); +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_invalidating_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE + ); + +scic_sds_remote_node_context_invalidate_context_buffer (rnc); +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_resuming_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; +struct smp_discover_response_protocols protocols; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE + ); + +/* +* For direct attached SATA devices we need to clear the TLCR +* NCQ to TCi tag mapping on the phy and in cases where we +* resume because of a target reset we also need to update +* the STPTLDARNI register with the RNi of the device +*/ +scic_remote_device_get_protocols (rnc->device, &protocols); + +if ((protocols.u.bits.attached_stp_target ==1 ) && + (rnc->device->is_direct_attached)) { +scic_sds_port_setup_transports ( + rnc->device->owning_port, rnc->remote_node_index); + } + +scic_sds_remote_device_post_request ( + rnc->device, +SCU_CONTEXT_COMMAND_POST_RNC_RESUME + ); +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_ready_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE + ); + + rnc->destination_state =SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED ; + +if (rnc->user_callback !=NULL ) { +scic_sds_remote_node_context_notify_user (rnc); + } +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_tx_suspended_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE + ); + +scic_sds_remote_node_context_continue_state_transitions (rnc); +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_tx_rx_suspended_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE + ); + +scic_sds_remote_node_context_continue_state_transitions (rnc); +} + +/** +* +* +* +*/ +static void scic_sds_remote_node_context_await_suspension_state_enter ( +struct sci_base_object *object) +{ +struct scic_sds_remote_node_context *rnc; + + rnc = (struct scic_sds_remote_node_context *)object; + +SET_STATE_HANDLER ( + rnc, + scic_sds_remote_node_context_state_handler_table, +SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE + ); +} + +/* --------------------------------------------------------------------------- */ + +const struct sci_base_state scic_sds_remote_node_context_state_table[] = { + [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE ] = { + .enter_state = scic_sds_remote_node_context_initial_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE ] = { + .enter_state = scic_sds_remote_node_context_posting_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE ] = { + .enter_state = scic_sds_remote_node_context_invalidating_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE ] = { + .enter_state = scic_sds_remote_node_context_resuming_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE ] = { + .enter_state = scic_sds_remote_node_context_ready_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE ] = { + .enter_state = scic_sds_remote_node_context_tx_suspended_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE ] = { + .enter_state = scic_sds_remote_node_context_tx_rx_suspended_state_enter, + }, + [SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE ] = { + .enter_state = scic_sds_remote_node_context_await_suspension_state_enter, + }, +}; +
drivers/scsi/isci/core/scic_sds_remote_node_context.h new file +323 -0
323 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_remote_node_table.c new file +600 -0
600 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_remote_node_table.h new file +195 -0
195 lines not on this page · raw message
drivers/scsi/isci/core/scu_remote_node_context.h new file +229 -0
229 lines not on this page · raw message
RFC PATCH 6/10 isci/core: stp
In reply to Dan Williamsstp request support and state machines. pio and exceptions handled in software, fpdma and udma handled in hardware.
--- .../scsi/isci/core/scic_sds_stp_packet_request.c | 834 +++++++++ .../scsi/isci/core/scic_sds_stp_packet_request.h | 153 ++ drivers/scsi/isci/core/scic_sds_stp_pio_request.h | 116 + drivers/scsi/isci/core/scic_sds_stp_request.c | 1941 ++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_stp_request.h | 221 ++ 5 files changed, 3265 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/scic_sds_stp_packet_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_packet_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_stp_pio_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_stp_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_stp_request.h
drivers/scsi/isci/core/scic_sds_stp_packet_request.c new file +834 -0
@@ -0,0 +1,834 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#if !defined(DISABLE_ATAPI ) + +#include "intel_ata.h" +#include "intel_sas.h" +#include "intel_sata.h" +#include "intel_sat.h" +#include "sati_translator_sequence.h" +#include "sci_base_state.h" +#include "scic_controller.h" +#include "scic_remote_device.h" +#include "scic_sds_controller.h" +#include "scic_sds_remote_device.h" +#include "scic_sds_request.h" +#include "scic_sds_stp_packet_request.h" +#include "scic_user_callback.h" +#include "sci_util.h" +#include "scu_completion_codes.h" +#include "scu_task_context.h" + + +/** +* This method will fill in the SCU Task Context for a PACKET fis. And +* construct the request STARTED sub-state machine for Packet Protocol IO. +* @this_request: This parameter specifies the stp packet request object being +* constructed. +* +*/ +enum sci_status scic_sds_stp_packet_request_construct ( +struct scic_sds_request *this_request) +{ +struct sata_fis_reg_h2d *h2d_fis = +scic_stp_io_request_get_h2d_reg_address ( + this_request + ); + +/* +* Work around, we currently only support PACKET DMA protocol, so we +* need to make change to Packet Fis features field. */ + h2d_fis->features = h2d_fis->features |ATA_PACKET_FEATURE_DMA ; + +scic_sds_stp_non_ncq_request_construct (this_request); + +/* Build the Packet Fis task context structure */ +scu_stp_raw_request_construct_task_context ( + (struct scic_sds_stp_request *)this_request, + this_request->task_context_buffer + ); + +sci_base_state_machine_construct ( + &this_request->started_substate_machine, + &this_request->parent.parent, + scic_sds_stp_packet_request_started_substate_table, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE + ); + +return SCI_SUCCESS ; +} + + +/** +* This method will fill in the SCU Task Context for a Packet request command +* phase in PACKET DMA DATA (IN/OUT) type. The following important settings +* are utilized: -# task_type == SCU_TASK_TYPE_PACKET_DMA. This simply +* indicates that a normal request type (i.e. non-raw frame) is being +* utilized to perform task management. -# control_frame == 1. This ensures +* that the proper endianess is set so that the bytes are transmitted in the +* right order for a smp request frame. +* @this_request: This parameter specifies the smp request object being +* constructed. +* @task_context: The task_context to be reconstruct for packet request command +* phase. +* +*/ +void scu_stp_packet_request_command_phase_construct_task_context ( +struct scic_sds_request *this_request, +struct scu_task_context *task_context) +{ +void *atapi_cdb; +u32 atapi_cdb_length; +struct scic_sds_stp_request *stp_request = (struct scic_sds_stp_request *)this_request; + +/* +* reference: SSTL 1.13.4.2 +* task_type, sata_direction */ +if (scic_cb_io_request_get_data_direction (this_request->user_request) + ==SCI_IO_REQUEST_DATA_OUT ) { + task_context->task_type =SCU_TASK_TYPE_PACKET_DMA_OUT ; + task_context->sata_direction =0 ; + }else {/* todo: for NO_DATA command, we need to send out raw frame. */ + task_context->task_type =SCU_TASK_TYPE_PACKET_DMA_IN ; + task_context->sata_direction =1 ; + } + +/* sata header */ +memset (&(task_context->type.stp),0 ,sizeof (struct STP_TASK_CONTEXT )); + task_context->type.stp.fis_type =SATA_FIS_TYPE_DATA ; + +/* +* Copy in the command IU with CDB so that the commandIU address doesn't +* change. */ +memset (this_request->command_buffer,0 ,sizeof (struct sata_fis_reg_h2d )); + + atapi_cdb = +scic_cb_stp_packet_io_request_get_cdb_address (this_request->user_request); + + atapi_cdb_length = +scic_cb_stp_packet_io_request_get_cdb_length (this_request->user_request); + +memcpy (((u8 *)this_request->command_buffer +sizeof (u32)), atapi_cdb, atapi_cdb_length); + + atapi_cdb_length = +max (atapi_cdb_length, stp_request->type.packet.device_preferred_cdb_length); + + task_context->ssp_command_iu_length = + ((atapi_cdb_length %4 ) ==0 ) ? + (atapi_cdb_length /4 ) : ((atapi_cdb_length /4 ) +1 ); + +/* task phase is set to TX_CMD */ + task_context->task_phase =0x1 ; + +/* retry counter */ + task_context->stp_retry_count =0 ; + +if (scic_cb_request_is_initial_construction (this_request->user_request)) { +/* data transfer size. */ + task_context->transfer_length_bytes = +scic_cb_io_request_get_transfer_length (this_request->user_request); + +/* setup sgl */ +scic_sds_request_build_sgl (this_request); + }else { +/* data transfer size, need to be 4 bytes aligned. */ + task_context->transfer_length_bytes = (SCSI_FIXED_SENSE_DATA_BASE_LENGTH +2 ); + +scic_sds_stp_packet_internal_request_sense_build_sgl (this_request); + } +} + +/** +* This method will fill in the SCU Task Context for a DATA fis containing CDB +* in Raw Frame type. The TC for previous Packet fis was already there, we +* only need to change the H2D fis content. +* @this_request: This parameter specifies the smp request object being +* constructed. +* @task_context: The task_context to be reconstruct for packet request command +* phase. +* +*/ +void scu_stp_packet_request_command_phase_reconstruct_raw_frame_task_context ( +struct scic_sds_request *this_request, +struct scu_task_context *task_context) +{ +void *atapi_cdb = +scic_cb_stp_packet_io_request_get_cdb_address (this_request->user_request); + +u32 atapi_cdb_length = +scic_cb_stp_packet_io_request_get_cdb_length (this_request->user_request); + +memset (this_request->command_buffer,0 ,sizeof (struct sata_fis_reg_h2d )); +memcpy (((u8 *)this_request->command_buffer +sizeof (u32)), atapi_cdb, atapi_cdb_length); + +memset (&(task_context->type.stp),0 ,sizeof (struct STP_TASK_CONTEXT )); + task_context->type.stp.fis_type =SATA_FIS_TYPE_DATA ; + +/* +* Note the data send out has to be 4 bytes aligned. Or else out hardware will +* patch non-zero bytes and cause the target device unhappy. */ + task_context->transfer_length_bytes =12 ; +} + + +/* +* *@brief This methods decode the D2H status FIS and retrieve the sense data, +* then pass the sense data to user request. +* +***@param[in] this_request The request receive D2H status FIS. +***@param[in] status_fis The D2H status fis to be processed. +* +*/ +enum sci_status scic_sds_stp_packet_request_process_status_fis ( +struct scic_sds_request *this_request, +struct sata_fis_reg_d2h *status_fis) +{ +enum sci_status status =SCI_SUCCESS ; + +/* TODO: Process the error status fis, retrieve sense data. */ +if (status_fis->status &ATA_STATUS_REG_ERROR_BIT ) + status =SCI_FAILURE_IO_RESPONSE_VALID ; + +return status; +} + +/* +* *@brief This methods builds sgl for internal REQUEST SENSE stp packet +* command using this request response buffer, only one sge is +* needed. +* +***@param[in] this_request The request receive request sense data. +* +*/ +void scic_sds_stp_packet_internal_request_sense_build_sgl ( +struct scic_sds_request *sds_request) +{ +void *sge; +struct scu_sgl_element_pair *scu_sgl_list =NULL ; +struct scu_task_context *task_context; +dma_addr_t dma_addr; + +struct sci_ssp_response_iu *rsp_iu = + (struct sci_ssp_response_iu *)sds_request->response_buffer; + + sge = (void *)&rsp_iu->data[0 ]; + + task_context = + (struct scu_task_context *)sds_request->task_context_buffer; + scu_sgl_list = &task_context->sgl_pair_ab; + + dma_addr =scic_io_request_get_dma_addr (sds_request, sge); + + scu_sgl_list->A.address_upper =upper_32_bits (dma_addr); + scu_sgl_list->A.address_lower =lower_32_bits (dma_addr); + scu_sgl_list->A.length = task_context->transfer_length_bytes; + scu_sgl_list->A.address_modifier =0 ; + +SCU_SGL_ZERO (scu_sgl_list->B); +} + +/** +* This method processes the completions transport layer (TL) status to +* determine if the Packet FIS was sent successfully. If the Packet FIS was +* sent successfully, then the state for the Packet request transits to +* waiting for a PIO SETUP frame. +* @this_request: This parameter specifies the request for which the TC +* completion was received. +* @completion_code: This parameter indicates the completion status information +* for the TC. +* +* Indicate if the tc completion handler was successful. SCI_SUCCESS currently +* this method always returns success. +*/ +enum sci_status scic_sds_stp_packet_request_packet_phase_await_tc_completion_tc_completion_handler ( +struct scic_sds_request *this_request, +u32 completion_code) +{ +enum sci_status status =SCI_SUCCESS ; + +switch (SCU_GET_COMPLETION_TL_STATUS (completion_code)) { +case SCU_MAKE_COMPLETION_STATUS (SCU_TASK_DONE_GOOD ): +scic_sds_request_set_status ( + this_request,SCU_TASK_DONE_GOOD ,SCI_SUCCESS + ); + +sci_base_state_machine_change_state ( + &this_request->started_substate_machine, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_PIO_SETUP_SUBSTATE + ); +break ; + +default : +/* +* All other completion status cause the IO to be complete. If a NAK +* was received, then it is up to the user to retry the request. */ +scic_sds_request_set_status ( + this_request, +SCU_NORMALIZE_COMPLETION_STATUS (completion_code), +SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR + ); + +sci_base_state_machine_change_state ( + &this_request->parent.state_machine, +SCI_BASE_REQUEST_STATE_COMPLETED + ); +break ; + } + +return status; +} + + +/** +* This method processes an unsolicited frame while the Packet request is +* waiting for a PIO SETUP FIS. It will release the unsolicited frame, and +* transition the request to the COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE +* state. +* @this_request: This parameter specifies the request for which the +* unsolicited frame was received. +* @frame_index: This parameter indicates the unsolicited frame index that +* should contain the response. +* +* This method returns an indication of whether the pio setup frame was handled +* successfully or not. SCI_SUCCESS Currently this value is always returned and +* indicates successful processing of the TC response. +*/ +enum sci_status scic_sds_stp_packet_request_packet_phase_await_pio_setup_frame_handler ( +struct scic_sds_request *request, +u32 frame_index) +{ +enum sci_status status; +struct sata_fis_header *frame_header; +u32 *frame_buffer; +struct scic_sds_stp_request *this_request; + + this_request = (struct scic_sds_stp_request *)request; + + status =scic_sds_unsolicited_frame_control_get_header ( + &(this_request->parent.owning_controller->uf_control), + frame_index, + (void **)&frame_header + ); + +if (status ==SCI_SUCCESS ) { +BUG_ON (frame_header->fis_type !=SATA_FIS_TYPE_PIO_SETUP ); + +/* +* Get from the frame buffer the PIO Setup Data, although we don't need +* any info from this pio setup fis. */ +scic_sds_unsolicited_frame_control_get_buffer ( + &(this_request->parent.owning_controller->uf_control), + frame_index, + (void **)&frame_buffer + ); + +/* +* Get the data from the PIO Setup +* The SCU Hardware returns first word in the frame_header and the rest +* of the data is in the frame buffer so we need to back up one dword */ + this_request->type.packet.device_preferred_cdb_length = + (u16)((struct sata_fis_pio_setup *)(&frame_buffer[-1 ]))->transfter_count; + +/* Frame has been decoded return it to the controller */ +scic_sds_controller_release_frame ( + this_request->parent.owning_controller, frame_index + ); + +sci_base_state_machine_change_state ( + &this_request->parent.started_substate_machine, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE + ); + }else +dev_err (scic_to_dev (request->owning_controller), +"%s: SCIC IO Request 0x%p could not get frame header " +"for frame index %d, status %x\n" , + __func__, this_request, frame_index, status); + +return status; +} + + +/** +* This method processes the completions transport layer (TL) status to +* determine if the PACKET command data FIS was sent successfully. If +* successfully, then the state for the packet request transits to COMPLETE +* state. If not successfuly, the request transits to +* COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE. +* @this_request: This parameter specifies the request for which the TC +* completion was received. +* @completion_code: This parameter indicates the completion status information +* for the TC. +* +* Indicate if the tc completion handler was successful. SCI_SUCCESS currently +* this method always returns success. +*/ +enum sci_status scic_sds_stp_packet_request_command_phase_await_tc_completion_tc_completion_handler ( +struct scic_sds_request *this_request, +u32 completion_code) +{ +enum sci_status status =SCI_SUCCESS ; +u8 sat_packet_protocol = +scic_cb_request_get_sat_protocol (this_request->user_request); + +switch (SCU_GET_COMPLETION_TL_STATUS (completion_code)) { +case (SCU_TASK_DONE_GOOD <<SCU_COMPLETION_TL_STATUS_SHIFT ): +scic_sds_request_set_status ( + this_request,SCU_TASK_DONE_GOOD ,SCI_SUCCESS + ); + +if (sat_packet_protocol ==SAT_PROTOCOL_PACKET_DMA_DATA_IN + || sat_packet_protocol ==SAT_PROTOCOL_PACKET_DMA_DATA_OUT + ) +sci_base_state_machine_change_state ( + &this_request->parent.state_machine, +SCI_BASE_REQUEST_STATE_COMPLETED + ); +else +sci_base_state_machine_change_state ( + &this_request->started_substate_machine, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE + ); +break ; + +case (SCU_TASK_DONE_UNEXP_FIS <<SCU_COMPLETION_TL_STATUS_SHIFT ): +if (scic_io_request_get_number_of_bytes_transferred (this_request) < +scic_cb_io_request_get_transfer_length (this_request->user_request)) { +scic_sds_request_set_status ( + this_request,SCU_TASK_DONE_GOOD ,SCI_SUCCESS_IO_DONE_EARLY + ); + +sci_base_state_machine_change_state ( + &this_request->parent.state_machine, +SCI_BASE_REQUEST_STATE_COMPLETED + ); + + status = this_request->sci_status; + } +break ; + +case (SCU_TASK_DONE_EXCESS_DATA <<SCU_COMPLETION_TL_STATUS_SHIFT ): +/* In this case, there is no UF coming after. compelte the IO now. */ +scic_sds_request_set_status ( + this_request,SCU_TASK_DONE_GOOD ,SCI_SUCCESS + ); + +sci_base_state_machine_change_state ( + &this_request->parent.state_machine, +SCI_BASE_REQUEST_STATE_COMPLETED + ); + +break ; + +default : +if (this_request->sci_status !=SCI_SUCCESS ) {/* The io status was set already. This means an UF for the status +* fis was received already. +*/ + +/* +* A device suspension event is expected, we need to have the device +* coming out of suspension, then complete the IO. */ +sci_base_state_machine_change_state ( + &this_request->started_substate_machine, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMPLETION_DELAY_SUBSTATE + ); + +/* change the device state to ATAPI_ERROR. */ +sci_base_state_machine_change_state ( + &this_request->target_device->ready_substate_machine, +SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR + ); + + status = this_request->sci_status; + }else {/* If receiving any non-sucess TC status, no UF received yet, then an UF for +* the status fis is coming after. +*/ +scic_sds_request_set_status ( + this_request, +SCU_TASK_DONE_CHECK_RESPONSE , +SCI_FAILURE_IO_RESPONSE_VALID + ); + +sci_base_state_machine_change_state ( + &this_request->started_substate_machine, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE + ); + } +break ; + } + +return status; +} + + +/** +* This method processes an unsolicited frame. +* @this_request: This parameter specifies the request for which the +* unsolicited frame was received. +* @frame_index: This parameter indicates the unsolicited frame index that +* should contain the response. +* +* This method returns an indication of whether the UF frame was handled +* successfully or not. SCI_SUCCESS Currently this value is always returned and +* indicates successful processing of the TC response. +*/ +enum sci_status scic_sds_stp_packet_request_command_phase_common_frame_handler ( +struct scic_sds_request *request, +u32 frame_index) +{ +enum sci_status status; +struct sata_fis_header *frame_header; +u32 *frame_buffer; +struct scic_sds_stp_request *this_request; + + this_request = (struct scic_sds_stp_request *)request; + + status =scic_sds_unsolicited_frame_control_get_header ( + &(this_request->parent.owning_controller->uf_control), + frame_index, + (void **)&frame_header + ); + +if (status ==SCI_SUCCESS ) { +BUG_ON (frame_header->fis_type !=SATA_FIS_TYPE_REGD2H ); + +/* +* Get from the frame buffer the PIO Setup Data, although we don't need +* any info from this pio setup fis. */ +scic_sds_unsolicited_frame_control_get_buffer ( + &(this_request->parent.owning_controller->uf_control), + frame_index, + (void **)&frame_buffer + ); + +scic_sds_controller_copy_sata_response ( + &this_request->d2h_reg_fis, (u32 *)frame_header, frame_buffer + ); + +/* Frame has been decoded return it to the controller */ +scic_sds_controller_release_frame ( + this_request->parent.owning_controller, frame_index + ); + } + +return status; +} + +/** +* This method processes an unsolicited frame while the packet request is +* expecting TC completion. It will process the FIS and construct sense data. +* @this_request: This parameter specifies the request for which the +* unsolicited frame was received. +* @frame_index: This parameter indicates the unsolicited frame index that +* should contain the response. +* +* This method returns an indication of whether the UF frame was handled +* successfully or not. SCI_SUCCESS Currently this value is always returned and +* indicates successful processing of the TC response. +*/ +enum sci_status scic_sds_stp_packet_request_command_phase_await_tc_completion_frame_handler ( +struct scic_sds_request *request, +u32 frame_index) +{ +struct scic_sds_stp_request *this_request = (struct scic_sds_stp_request *)request; + +enum sci_status status = +scic_sds_stp_packet_request_command_phase_common_frame_handler ( + request, frame_index); + +if (status ==SCI_SUCCESS ) { +/* The command has completed with error status from target device. */ + status =scic_sds_stp_packet_request_process_status_fis ( + request, &this_request->d2h_reg_fis); + +if (status !=SCI_SUCCESS ) { +scic_sds_request_set_status ( + &this_request->parent, +SCU_TASK_DONE_CHECK_RESPONSE , + status + ); + }else +scic_sds_request_set_status ( + &this_request->parent,SCU_TASK_DONE_GOOD ,SCI_SUCCESS + ); + } + +return status; +} + + +/** +* This method processes an unsolicited frame while the packet request is +* expecting TC completion. It will process the FIS and construct sense data. +* @this_request: This parameter specifies the request for which the +* unsolicited frame was received. +* @frame_index: This parameter indicates the unsolicited frame index that +* should contain the response. +* +* This method returns an indication of whether the UF frame was handled +* successfully or not. SCI_SUCCESS Currently this value is always returned and +* indicates successful processing of the TC response. +*/ +enum sci_status scic_sds_stp_packet_request_command_phase_await_d2h_fis_frame_handler ( +struct scic_sds_request *request, +u32 frame_index) +{ +enum sci_status status = +scic_sds_stp_packet_request_command_phase_common_frame_handler ( + request, frame_index); + +struct scic_sds_stp_request *this_request = (struct scic_sds_stp_request *)request; + +if (status ==SCI_SUCCESS ) { +/* The command has completed with error status from target device. */ + status =scic_sds_stp_packet_request_process_status_fis ( + request, &this_request->d2h_reg_fis); + +if (status !=SCI_SUCCESS ) { +scic_sds_request_set_status ( + request, +SCU_TASK_DONE_CHECK_RESPONSE , + status + ); + }else +scic_sds_request_set_status ( + request,SCU_TASK_DONE_GOOD ,SCI_SUCCESS + ); + +/* +* Always complete the NON_DATA command right away, no need to delay completion +* even an error status fis came from target device. */ +sci_base_state_machine_change_state ( + &request->parent.state_machine, +SCI_BASE_REQUEST_STATE_COMPLETED + ); + } + +return status; +} + +enum sci_status scic_sds_stp_packet_request_started_completion_delay_complete_handler ( +struct sci_base_request *request) +{ +struct scic_sds_request *this_request = (struct scic_sds_request *)request; + +sci_base_state_machine_change_state ( + &this_request->parent.state_machine, +SCI_BASE_REQUEST_STATE_COMPLETED + ); + +return this_request->sci_status; +} + +/* --------------------------------------------------------------------------- */ + +const struct scic_sds_io_request_state_handler scic_sds_stp_packet_request_started_substate_handler_table[] = { + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE ] = { + .parent.start_handler = scic_sds_request_default_start_handler, + .parent.abort_handler = scic_sds_request_started_state_abort_handler, + .parent.complete_handler = scic_sds_request_default_complete_handler, + .parent.destruct_handler = scic_sds_request_default_destruct_handler + .tc_completion_handler = scic_sds_stp_packet_request_packet_phase_await_tc_completion_tc_completion_handler, + .event_handler = scic_sds_request_default_event_handler, + .frame_handler = scic_sds_request_default_frame_handler + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_PIO_SETUP_SUBSTATE ] = { + .parent.start_handler = scic_sds_request_default_start_handler, + .parent.abort_handler = scic_sds_request_started_state_abort_handler, + .parent.complete_handler = scic_sds_request_default_complete_handler, + .parent.destruct_handler = scic_sds_request_default_destruct_handler + .tc_completion_handler = scic_sds_request_default_tc_completion_handler, + .event_handler = scic_sds_request_default_event_handler, + .frame_handler = scic_sds_stp_packet_request_packet_phase_await_pio_setup_frame_handler + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE ] = { + .parent.start_handler = scic_sds_request_default_start_handler, + .parent.abort_handler = scic_sds_request_started_state_abort_handler, + .parent.complete_handler = scic_sds_request_default_complete_handler, + .parent.destruct_handler = scic_sds_request_default_destruct_handler + .tc_completion_handler = scic_sds_stp_packet_request_command_phase_await_tc_completion_tc_completion_handler, + .event_handler = scic_sds_request_default_event_handler, + .frame_handler = scic_sds_stp_packet_request_command_phase_await_tc_completion_frame_handler + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE ] = { + .parent.start_handler = scic_sds_request_default_start_handler, + .parent.abort_handler = scic_sds_request_started_state_abort_handler, + .parent.complete_handler = scic_sds_request_default_complete_handler, + .parent.destruct_handler = scic_sds_request_default_destruct_handler + .tc_completion_handler = scic_sds_request_default_tc_completion_handler, + .event_handler = scic_sds_request_default_event_handler, + .frame_handler = scic_sds_stp_packet_request_command_phase_await_d2h_fis_frame_handler + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMPLETION_DELAY_SUBSTATE ] = { + .parent.start_handler = scic_sds_request_default_start_handler, + .parent.abort_handler = scic_sds_request_started_state_abort_handler, + .parent.complete_handler = scic_sds_stp_packet_request_started_completion_delay_complete_handler, + .parent.destruct_handler = scic_sds_request_default_destruct_handler + .tc_completion_handler = scic_sds_request_default_tc_completion_handler, + .event_handler = scic_sds_request_default_event_handler, + .frame_handler = scic_sds_request_default_frame_handler + }, +}; + +void scic_sds_stp_packet_request_started_packet_phase_await_tc_completion_enter ( +struct sci_base_object *object) +{ +struct scic_sds_request *this_request = (struct scic_sds_request *)object; + +SET_STATE_HANDLER ( + this_request, + scic_sds_stp_packet_request_started_substate_handler_table, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE + ); + +scic_sds_remote_device_set_working_request ( + this_request->target_device, this_request + ); +} + +void scic_sds_stp_packet_request_started_packet_phase_await_pio_setup_enter ( +struct sci_base_object *object) +{ +struct scic_sds_request *this_request = (struct scic_sds_request *)object; + +SET_STATE_HANDLER ( + this_request, + scic_sds_stp_packet_request_started_substate_handler_table, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_PIO_SETUP_SUBSTATE + ); +} + +void scic_sds_stp_packet_request_started_command_phase_await_tc_completion_enter ( +struct sci_base_object *object) +{ +struct scic_sds_request *this_request = (struct scic_sds_request *)object; +u8 sat_packet_protocol = +scic_cb_request_get_sat_protocol (this_request->user_request); + +struct scu_task_context *task_context; +enum sci_status status; + +/* +* Recycle the TC and reconstruct it for sending out data fis containing +* CDB. */ + task_context =scic_sds_controller_get_task_context_buffer ( + this_request->owning_controller, this_request->io_tag); + +if (sat_packet_protocol ==SAT_PROTOCOL_PACKET_NON_DATA ) +scu_stp_packet_request_command_phase_reconstruct_raw_frame_task_context ( + this_request, task_context); +else +scu_stp_packet_request_command_phase_construct_task_context ( + this_request, task_context); + +/* send the new TC out. */ + status = this_request->owning_controller->state_handlers->parent.continue_io_handler ( + &this_request->owning_controller->parent, + &this_request->target_device->parent, + &this_request->parent + ); + +if (status ==SCI_SUCCESS ) +SET_STATE_HANDLER ( + this_request, + scic_sds_stp_packet_request_started_substate_handler_table, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE + ); +} + +void scic_sds_stp_packet_request_started_command_phase_await_d2h_fis_enter ( +struct sci_base_object *object) +{ +struct scic_sds_request *this_request = (struct scic_sds_request *)object; + +SET_STATE_HANDLER ( + this_request, + scic_sds_stp_packet_request_started_substate_handler_table, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE + ); +} + +void scic_sds_stp_packet_request_started_completion_delay_enter ( +struct sci_base_object *object) +{ +struct scic_sds_request *this_request = (struct scic_sds_request *)object; + +SET_STATE_HANDLER ( + this_request, + scic_sds_stp_packet_request_started_substate_handler_table, +SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMPLETION_DELAY_SUBSTATE + ); +} + + +/* --------------------------------------------------------------------------- */ +const struct sci_base_state scic_sds_stp_packet_request_started_substate_table[] = { + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE ] = { + .enter_state = scic_sds_stp_packet_request_started_packet_phase_await_tc_completion_enter, + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_PIO_SETUP_SUBSTATE ] = { + .enter_state = scic_sds_stp_packet_request_started_packet_phase_await_pio_setup_enter, + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE ] = { + .enter_state = scic_sds_stp_packet_request_started_command_phase_await_tc_completion_enter, + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE ] = { + .enter_state = scic_sds_stp_packet_request_started_command_phase_await_d2h_fis_enter, + }, + [SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMPLETION_DELAY_SUBSTATE ] = { + .enter_state scic_sds_stp_packet_request_started_completion_delay_enter, + } +}; + +#endif /* !defined(DISABLE_ATAPI) */
drivers/scsi/isci/core/scic_sds_stp_packet_request.h new file +153 -0
153 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_stp_pio_request.h new file +116 -0
116 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_stp_request.c new file +1941 -0
1,897 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_stp_request.h new file +221 -0
221 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH 7/10 isci/core: request (general, ssp and smp)
In reply to Dan WilliamsGeneral request state machines as well as the sub-state machines for ssp (hardware accelerated) and smp operation (not accelerated).
--- drivers/scsi/isci/core/sci_base_request.h | 195 ++ drivers/scsi/isci/core/scic_io_request.h | 511 ++++++ drivers/scsi/isci/core/scic_sds_request.c | 2174 +++++++++++++++++++++++++ drivers/scsi/isci/core/scic_sds_request.h | 469 +++++ drivers/scsi/isci/core/scic_sds_smp_request.c | 669 ++++++++ drivers/scsi/isci/core/scic_sds_smp_request.h | 69 + drivers/scsi/isci/core/scic_sds_ssp_request.c | 268 +++ drivers/scsi/isci/core/scic_task_request.h | 147 ++ 8 files changed, 4502 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/sci_base_request.h create mode 100644 drivers/scsi/isci/core/scic_io_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_smp_request.c create mode 100644 drivers/scsi/isci/core/scic_sds_smp_request.h create mode 100644 drivers/scsi/isci/core/scic_sds_ssp_request.c create mode 100644 drivers/scsi/isci/core/scic_task_request.h
drivers/scsi/isci/core/sci_base_request.h new file +195 -0
@@ -0,0 +1,195 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _SCI_BASE_REQUST_H_ +#define _SCI_BASE_REQUST_H_ + +/** +* This file contains all of the constants, types, and method declarations for +* the SCI base IO and task request objects. +* +* +*/ + +#include "sci_base_state_machine.h" + +/** +* enum sci_base_request_states - This enumeration depicts all the states for +* the common request state machine. +* +* +*/ +enum sci_base_request_states { +/** +* Simply the initial state for the base request state machine. +*/ +SCI_BASE_REQUEST_STATE_INITIAL , + +/** +* This state indicates that the request has been constructed. This state +* is entered from the INITIAL state. +*/ +SCI_BASE_REQUEST_STATE_CONSTRUCTED , + +/** +* This state indicates that the request has been started. This state is +* entered from the CONSTRUCTED state. +*/ +SCI_BASE_REQUEST_STATE_STARTED , + +/** +* This state indicates that the request has completed. +* This state is entered from the STARTED state. This state is entered from +* the ABORTING state. +*/ +SCI_BASE_REQUEST_STATE_COMPLETED , + +/** +* This state indicates that the request is in the process of being +* terminated/aborted. +* This state is entered from the CONSTRUCTED state. +* This state is entered from the STARTED state. +*/ +SCI_BASE_REQUEST_STATE_ABORTING , + +/** +* Simply the final state for the base request state machine. +*/ +SCI_BASE_REQUEST_STATE_FINAL , +}; + +/** +* struct sci_base_request - The base request object abstracts the fields +* common to all SCI IO and task request objects. +* +* +*/ +struct sci_base_request { +/** +* The field specifies that the parent object for the base request is the +* base object itself. +*/ +struct sci_base_object parent; + +/** +* This field contains the information for the base request state machine. +*/ +struct sci_base_state_machine state_machine; +}; + +typedef enum sci_status (*SCI_BASE_REQUEST_HANDLER_T )( +struct sci_base_request *this_request + ); + +/** +* struct sci_base_request_state_handler - This structure contains all of the +* state handler methods common to base IO and task request state machines. +* Handler methods provide the ability to change the behavior for user +* requests or transitions depending on the state the machine is in. +* +* +*/ +struct sci_base_request_state_handler { +/** +* The start_handler specifies the method invoked when a user attempts to +* start a request. +*/ +SCI_BASE_REQUEST_HANDLER_T start_handler; + +/** +* The abort_handler specifies the method invoked when a user attempts to +* abort a request. +*/ +SCI_BASE_REQUEST_HANDLER_T abort_handler; + +/** +* The complete_handler specifies the method invoked when a user attempts to +* complete a request. +*/ +SCI_BASE_REQUEST_HANDLER_T complete_handler; + +/** +* The destruct_handler specifies the method invoked when a user attempts to +* destruct a request. +*/ +SCI_BASE_REQUEST_HANDLER_T destruct_handler; + +}; + +/** +* sci_base_request_construct() - Construct the base request. +* @this_request: This parameter specifies the base request to be constructed. +* @state_table: This parameter specifies the table of state definitions to be +* utilized for the request state machine. +* +*/ +static inline void sci_base_request_construct ( +struct sci_base_request *base_req, +const struct sci_base_state *my_state_table) +{ + base_req->parent.private =NULL ; +sci_base_state_machine_construct ( + &base_req->state_machine, + &base_req->parent, + my_state_table, +SCI_BASE_REQUEST_STATE_INITIAL + ); + +sci_base_state_machine_start ( + &base_req->state_machine + ); +} + +#endif /* _SCI_BASE_REQUST_H_ */
drivers/scsi/isci/core/scic_io_request.h new file +511 -0
511 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_request.c new file +2174 -0
2,174 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_request.h new file +469 -0
120 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_smp_request.c new file +669 -0
669 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_smp_request.h new file +69 -0
69 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_ssp_request.c new file +268 -0
268 lines not on this page · raw message
drivers/scsi/isci/core/scic_task_request.h new file +147 -0
147 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
RFC PATCH 8/10 isci/core: unsolicited frame handling and registers
In reply to Dan WilliamsThe hardware kicks unaccelerated / unknown traffic to an unsolicited frame queue for handling in software.
--- .../isci/core/scic_sds_unsolicited_frame_control.c | 383 ++++ .../isci/core/scic_sds_unsolicited_frame_control.h | 286 +++ drivers/scsi/isci/core/scu_registers.h | 1830 ++++++++++++++++++++ drivers/scsi/isci/core/scu_unsolicited_frame.h | 117 + 4 files changed, 2616 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c create mode 100644 drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.h create mode 100644 drivers/scsi/isci/core/scu_registers.h create mode 100644 drivers/scsi/isci/core/scu_unsolicited_frame.h
drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.c new file +383 -0
@@ -0,0 +1,383 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +* This file contains the implementation of the +* struct scic_sds_unsolicited_frame_control object and it's public, protected, and +* private methods. +* +* +*/ + +#include "scic_sds_unsolicited_frame_control.h" +#include "scu_registers.h" +#include "scic_sds_controller.h" +#include "sci_util.h" +#include "sci_environment.h" + +/** +* The UF buffer address table size must be programmed to a power of 2. Find +* the first power of 2 that is equal to or greater then the number of +* unsolicited frame buffers to be utilized. +* @uf_control: This parameter specifies the UF control object for which to +* update the address table count. +* +*/ +void scic_sds_unsolicited_frame_control_set_address_table_count ( +struct scic_sds_unsolicited_frame_control *uf_control) +{ + uf_control->address_table.count =SCU_MIN_UF_TABLE_ENTRIES ; +while ( + (uf_control->address_table.count < uf_control->buffers.count) + && (uf_control->address_table.count <SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES ) + ) { + uf_control->address_table.count <<=1 ; + } +} + +/** +* This method will program the unsolicited frames (UFs) into the UF address +* table and construct the UF frame structure being modeled in the core. It +* will handle the case where some of the UFs are not being used and thus +* should have entries programmed to zero in the address table. +* @uf_control: This parameter specifies the unsolicted frame control object +* for which to construct the unsolicited frames objects. +* @uf_buffer_phys_address: This parameter specifies the physical address for +* the first unsolicited frame buffer. +* @uf_buffer_virt_address: This parameter specifies the virtual address for +* the first unsolicited frame buffer. +* @unused_uf_header_entries: This parameter specifies the number of unused UF +* headers. This value can be non-zero when there are a non-power of 2 +* number of unsolicited frames being supported. +* @used_uf_header_entries: This parameter specifies the number of actually +* utilized UF headers. +* +*/ +static void scic_sds_unsolicited_frame_control_construct_frames ( +struct scic_sds_unsolicited_frame_control *uf_control, +dma_addr_t uf_buffer_phys_address, +void *uf_buffer_virt_address, +u32 unused_uf_header_entries, +u32 used_uf_header_entries) +{ +u32 index; +struct scic_sds_unsolicited_frame *uf; + +/* +* Program the unused buffers into the UF address table and the +* controller's array of UFs. +*/ +for (index =0 ; index < unused_uf_header_entries; index++) { + uf = &uf_control->buffers.array[index]; + +sci_cb_make_physical_address ( + uf_control->address_table.array[index],0 ,0 + ); + uf->buffer =NULL ; + uf->header = &uf_control->headers.array[index]; + uf->state =UNSOLICITED_FRAME_EMPTY ; + } + +/* +* Program the actual used UF buffers into the UF address table and +* the controller's array of UFs. +*/ +for (index = unused_uf_header_entries; + index < unused_uf_header_entries + used_uf_header_entries; + index++) { + uf = &uf_control->buffers.array[index]; + + uf_control->address_table.array[index] = uf_buffer_phys_address; + + uf->buffer = uf_buffer_virt_address; + uf->header = &uf_control->headers.array[index]; + uf->state =UNSOLICITED_FRAME_EMPTY ; + +/* +* Increment the address of the physical and virtual memory +* pointers. Everything is aligned on 1k boundary with an +* increment of 1k. +*/ + uf_buffer_virt_address +=SCU_UNSOLICITED_FRAME_BUFFER_SIZE ; + uf_buffer_phys_address +=SCU_UNSOLICITED_FRAME_BUFFER_SIZE ; + } +} + +/** +* This method constructs the various members of the unsolicted frame control +* object (buffers, headers, address, table, etc). +* @uf_control: This parameter specifies the unsolicited frame control object +* to construct. +* @mde: This parameter specifies the memory descriptor from which to derive +* all of the address information needed to get the unsolicited frame +* functionality working. +* @controller: This parameter specifies the controller object associated with +* the uf_control being constructed. +* +*/ +void scic_sds_unsolicited_frame_control_construct ( +struct scic_sds_unsolicited_frame_control *uf_control, +struct sci_physical_memory_descriptor *mde, +struct scic_sds_controller *controller) +{ +u32 unused_uf_header_entries; +u32 used_uf_header_entries; +u32 used_uf_buffer_bytes; +u32 unused_uf_header_bytes; +u32 used_uf_header_bytes; +dma_addr_t uf_buffer_phys_address; +void *uf_buffer_virt_address; + +/* +* Prepare all of the memory sizes for the UF headers, UF address +* table, and UF buffers themselves. */ + used_uf_buffer_bytes = uf_control->buffers.count + *SCU_UNSOLICITED_FRAME_BUFFER_SIZE ; + unused_uf_header_entries = uf_control->address_table.count + - uf_control->buffers.count; + used_uf_header_entries = uf_control->buffers.count; + unused_uf_header_bytes = unused_uf_header_entries + *sizeof (struct scu_unsolicited_frame_header ); + used_uf_header_bytes = used_uf_header_entries + *sizeof (struct scu_unsolicited_frame_header ); + +/* +* The Unsolicited Frame buffers are set at the start of the UF +* memory descriptor entry. The headers and address table will be +* placed after the buffers. +*/ + uf_buffer_phys_address = mde->physical_address; + uf_buffer_virt_address = mde->virtual_address; + +/* +* Program the location of the UF header table into the SCU. +* Notes: +* - The address must align on a 64-byte boundary. Guaranteed to be +* on 64-byte boundary already 1KB boundary for unsolicited frames. +* - Program unused header entries to overlap with the last +* unsolicited frame. The silicon will never DMA to these unused +* headers, since we program the UF address table pointers to +* NULL. +*/ + uf_control->headers.physical_address = + uf_buffer_phys_address + + used_uf_buffer_bytes - + unused_uf_header_bytes; + + uf_control->headers.array = + uf_buffer_virt_address + + used_uf_buffer_bytes - + unused_uf_header_bytes; + +/* +* Program the location of the UF address table into the SCU. +* Notes: +* - The address must align on a 64-bit boundary. Guaranteed to be on 64 +* byte boundary already due to above programming headers being on a +* 64-bit boundary and headers are on a 64-bytes in size. +*/ + uf_control->address_table.physical_address = + uf_buffer_phys_address + + used_uf_buffer_bytes + + used_uf_header_bytes; + + uf_control->address_table.array = + uf_buffer_virt_address + + used_uf_buffer_bytes + + used_uf_header_bytes; + + uf_control->get =0 ; + +/* +* UF buffer requirements are: +* - The last entry in the UF queue is not NULL. +* - There is a power of 2 number of entries (NULL or not-NULL) +* programmed into the queue. +* - Aligned on a 1KB boundary. */ + +/* +* If the user provided less then the maximum amount of memory, +* then be sure that we programm the first entries in the UF +* address table to NULL. */ +scic_sds_unsolicited_frame_control_construct_frames ( + uf_control, + uf_buffer_phys_address, + mde->virtual_address, + unused_uf_header_entries, + used_uf_header_entries + ); +} + +/** +* This method returns the frame header for the specified frame index. +* @uf_control: +* @frame_index: +* @frame_header: +* +* enum sci_status +*/ +enum sci_status scic_sds_unsolicited_frame_control_get_header ( +struct scic_sds_unsolicited_frame_control *uf_control, +u32 frame_index, +void **frame_header) +{ +if (frame_index < uf_control->address_table.count) { +/* +* Skip the first word in the frame since this is a controll word used +* by the hardware. */ + *frame_header = &uf_control->buffers.array[frame_index].header->data; + +return SCI_SUCCESS ; + } + +return SCI_FAILURE_INVALID_PARAMETER_VALUE ; +} + +/** +* This method returns the frame buffer for the specified frame index. +* @uf_control: +* @frame_index: +* @frame_buffer: +* +* enum sci_status +*/ +enum sci_status scic_sds_unsolicited_frame_control_get_buffer ( +struct scic_sds_unsolicited_frame_control *uf_control, +u32 frame_index, +void **frame_buffer) +{ +if (frame_index < uf_control->address_table.count) { + *frame_buffer = uf_control->buffers.array[frame_index].buffer; + +return SCI_SUCCESS ; + } + +return SCI_FAILURE_INVALID_PARAMETER_VALUE ; +} + +/** +* This method releases the frame once this is done the frame is available for +* re-use by the hardware. The data contained in the frame header and frame +* buffer is no longer valid. +* @uf_control: This parameter specifies the UF control object +* @frame_index: This parameter specifies the frame index to attempt to release. +* +* This method returns an indication to the caller as to whether the +* unsolicited frame get pointer should be updated. true This value indicates +* the unsolicited frame get pointer should be updated (i.e. write +* SCU_UFQGP_WRITE). false This value indicates the get pointer should not be +* updated. +*/ +bool scic_sds_unsolicited_frame_control_release_frame ( +struct scic_sds_unsolicited_frame_control *uf_control, +u32 frame_index) +{ +u32 frame_get; +u32 frame_cycle; + + frame_get = uf_control->get & (uf_control->address_table.count -1 ); + frame_cycle = uf_control->get & uf_control->address_table.count; + +/* +* In the event there are NULL entries in the UF table, we need to +* advance the get pointer in order to find out if this frame should +* be released (i.e. update the get pointer). */ +while (((lower_32_bits (uf_control->address_table.array[frame_get]) + ==0 ) && + (upper_32_bits (uf_control->address_table.array[frame_get]) + ==0 )) && + (frame_get < uf_control->address_table.count)) + frame_get++; + +/* +* The table has a NULL entry as it's last element. This is +* illegal. */ +BUG_ON (frame_get >= uf_control->address_table.count); + +if (frame_index < uf_control->address_table.count) { + uf_control->buffers.array[frame_index].state =UNSOLICITED_FRAME_RELEASED ; + +/* +* The frame index is equal to the current get pointer so we +* can now free up all of the frame entries that */ +if (frame_get == frame_index) { +while ( + uf_control->buffers.array[frame_get].state + ==UNSOLICITED_FRAME_RELEASED + ) { + uf_control->buffers.array[frame_get].state =UNSOLICITED_FRAME_EMPTY ; + +INCREMENT_QUEUE_GET ( + frame_get, + frame_cycle, + uf_control->address_table.count -1 , + uf_control->address_table.count + ); + } + + uf_control->get = + (SCU_UFQGP_GEN_BIT (ENABLE_BIT ) | frame_cycle | frame_get); + +return true; + }else { +/* +* Frames remain in use until we advance the get pointer +* so there is nothing we can do here */ + } + } + +return false; +} +
drivers/scsi/isci/core/scic_sds_unsolicited_frame_control.h new file +286 -0
286 lines not on this page · raw message
drivers/scsi/isci/core/scu_registers.h new file +1830 -0
1,830 lines not on this page · raw message
drivers/scsi/isci/core/scu_unsolicited_frame.h new file +117 -0
117 lines not on this page · raw message
RFC PATCH 9/10 isci/core: base state machine and memory descriptors
In reply to Dan WilliamsGeneric state machine implementation, and the memory descriptor interface for the lldd to pass buffers to the core.
--- .../isci/core/sci_base_memory_descriptor_list.c | 159 +++ .../isci/core/sci_base_memory_descriptor_list.h | 153 +++ drivers/scsi/isci/core/sci_base_state.h | 90 ++ drivers/scsi/isci/core/sci_base_state_machine.c | 182 ++++ drivers/scsi/isci/core/sci_base_state_machine.h | 141 +++ .../scsi/isci/core/sci_memory_descriptor_list.h | 168 ++++ drivers/scsi/isci/core/sci_object.h | 98 ++ drivers/scsi/isci/core/scu_completion_codes.h | 283 ++++++ drivers/scsi/isci/core/scu_constants.h | 151 +++ drivers/scsi/isci/core/scu_event_codes.h | 336 +++++++ drivers/scsi/isci/core/scu_task_context.h | 942 ++++++++++++++++++++ drivers/scsi/isci/core/scu_viit_data.h | 178 ++++ 12 files changed, 2881 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/sci_base_memory_descriptor_list.c create mode 100644 drivers/scsi/isci/core/sci_base_memory_descriptor_list.h create mode 100644 drivers/scsi/isci/core/sci_base_state.h create mode 100644 drivers/scsi/isci/core/sci_base_state_machine.c create mode 100644 drivers/scsi/isci/core/sci_base_state_machine.h create mode 100644 drivers/scsi/isci/core/sci_memory_descriptor_list.h create mode 100644 drivers/scsi/isci/core/sci_object.h create mode 100644 drivers/scsi/isci/core/scu_completion_codes.h create mode 100644 drivers/scsi/isci/core/scu_constants.h create mode 100644 drivers/scsi/isci/core/scu_event_codes.h create mode 100644 drivers/scsi/isci/core/scu_task_context.h create mode 100644 drivers/scsi/isci/core/scu_viit_data.h
drivers/scsi/isci/core/sci_base_memory_descriptor_list.c new file +159 -0
@@ -0,0 +1,159 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +* This file contains the base implementation for the memory descriptor list. +* This is currently comprised of MDL iterator methods. +* +* +*/ + +#include "sci_environment.h" +#include "sci_base_memory_descriptor_list.h" + +/* +* ****************************************************************************** +* * P U B L I C M E T H O D S +* ****************************************************************************** */ + +void sci_mdl_first_entry ( +struct sci_base_memory_descriptor_list *base_mdl) +{ + base_mdl->next_index =0 ; + +/* +* If this MDL is managing another MDL, then recursively rewind that MDL +* object as well. */ +if (base_mdl->next_mdl !=NULL ) +sci_mdl_first_entry (base_mdl->next_mdl); +} + + +void sci_mdl_next_entry ( +struct sci_base_memory_descriptor_list *base_mdl) +{ +/* +* If there is at least one more entry left in the array, then change +* the next pointer to it. */ +if (base_mdl->next_index < base_mdl->length) + base_mdl->next_index++; +else if (base_mdl->next_index == base_mdl->length) { +/* +* This MDL has exhausted it's set of entries. If this MDL is managing +* another MDL, then start iterating through that MDL. */ +if (base_mdl->next_mdl !=NULL ) +sci_mdl_next_entry (base_mdl->next_mdl); + } +} + + +struct sci_physical_memory_descriptor *sci_mdl_get_current_entry ( +struct sci_base_memory_descriptor_list *base_mdl) +{ +if (base_mdl->next_index < base_mdl->length) +return &base_mdl->mde_array[base_mdl->next_index]; +else if (base_mdl->next_index == base_mdl->length) { +/* +* This MDL has exhausted it's set of entries. If this MDL is managing +* another MDL, then return it's current entry. */ +if (base_mdl->next_mdl !=NULL ) +return sci_mdl_get_current_entry (base_mdl->next_mdl); + } + +return NULL ; +} + +/* +* ****************************************************************************** +* * P R O T E C T E D M E T H O D S +* ****************************************************************************** */ + +void sci_base_mdl_construct ( +struct sci_base_memory_descriptor_list *mdl, +struct sci_physical_memory_descriptor *mde_array, +u32 mde_array_length, +struct sci_base_memory_descriptor_list *next_mdl) +{ + mdl->length = mde_array_length; + mdl->mde_array = mde_array; + mdl->next_index =0 ; + mdl->next_mdl = next_mdl; +} + +/* --------------------------------------------------------------------------- */ + +bool sci_base_mde_is_valid ( +struct sci_physical_memory_descriptor *mde, +u32 alignment, +u32 size, +u16 attributes) +{ +/* Only need the lower 32 bits to ensure alignment is met. */ +u32 physical_address =lower_32_bits (mde->physical_address); + +if ( + ((((unsigned long )mde->virtual_address) & (alignment -1 )) !=0 ) + || ((physical_address & (alignment -1 )) !=0 ) + || (mde->constant_memory_alignment != alignment) + || (mde->constant_memory_size != size) + || (mde->virtual_address ==NULL ) + || (mde->constant_memory_attributes != attributes) + ) { +return false; + } + +return true; +} +
drivers/scsi/isci/core/sci_base_memory_descriptor_list.h new file +153 -0
153 lines not on this page · raw message
drivers/scsi/isci/core/sci_base_state.h new file +90 -0
90 lines not on this page · raw message
drivers/scsi/isci/core/sci_base_state_machine.c new file +182 -0
182 lines not on this page · raw message
drivers/scsi/isci/core/sci_base_state_machine.h new file +141 -0
141 lines not on this page · raw message
drivers/scsi/isci/core/sci_memory_descriptor_list.h new file +168 -0
168 lines not on this page · raw message
drivers/scsi/isci/core/sci_object.h new file +98 -0
98 lines not on this page · raw message
drivers/scsi/isci/core/scu_completion_codes.h new file +283 -0
283 lines not on this page · raw message
drivers/scsi/isci/core/scu_constants.h new file +151 -0
151 lines not on this page · raw message
drivers/scsi/isci/core/scu_event_codes.h new file +336 -0
336 lines not on this page · raw message
drivers/scsi/isci/core/scu_task_context.h new file +942 -0
942 lines not on this page · raw message
drivers/scsi/isci/core/scu_viit_data.h new file +178 -0
178 lines not on this page · raw message
RFC PATCH 10/10 isci/core: common definitions and utility functions
In reply to Dan WilliamsMany of these want to be deleted in favor of the in-kernel equivalent.
--- drivers/scsi/isci/core/intel_ata.h | 554 ++++++++++++ drivers/scsi/isci/core/intel_sas.h | 948 +++++++++++++++++++++ drivers/scsi/isci/core/intel_sat.h | 95 ++ drivers/scsi/isci/core/intel_sata.h | 280 ++++++ drivers/scsi/isci/core/intel_scsi.h | 474 +++++++++++ drivers/scsi/isci/core/sati_device.h | 156 +++ drivers/scsi/isci/core/sati_translator_sequence.h | 304 +++++++ drivers/scsi/isci/core/sati_types.h | 145 +++ drivers/scsi/isci/core/sci_pool.h | 199 ++++ drivers/scsi/isci/core/sci_status.h | 409 +++++++++ drivers/scsi/isci/core/sci_util.c | 101 ++ drivers/scsi/isci/core/sci_util.h | 108 ++ drivers/scsi/isci/core/scic_config_parameters.h | 346 ++++++++ drivers/scsi/isci/core/scic_sds_pci.h | 94 ++ 14 files changed, 4213 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/isci/core/intel_ata.h create mode 100644 drivers/scsi/isci/core/intel_sas.h create mode 100644 drivers/scsi/isci/core/intel_sat.h create mode 100644 drivers/scsi/isci/core/intel_sata.h create mode 100644 drivers/scsi/isci/core/intel_scsi.h create mode 100644 drivers/scsi/isci/core/sati_device.h create mode 100644 drivers/scsi/isci/core/sati_translator_sequence.h create mode 100644 drivers/scsi/isci/core/sati_types.h create mode 100644 drivers/scsi/isci/core/sci_pool.h create mode 100644 drivers/scsi/isci/core/sci_status.h create mode 100644 drivers/scsi/isci/core/sci_util.c create mode 100644 drivers/scsi/isci/core/sci_util.h create mode 100644 drivers/scsi/isci/core/scic_config_parameters.h create mode 100644 drivers/scsi/isci/core/scic_sds_pci.h
drivers/scsi/isci/core/intel_ata.h new file +554 -0
@@ -0,0 +1,554 @@ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* BSD LICENSE +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** +* This file defines all of the ATA related constants, enumerations, and types. +* Please note that this file does not necessarily contain an exhaustive +* list of all constants, commands, sub-commands, etc. +* +* +*/ + +#ifndef _ATA_H_ +#define _ATA_H_ + +#include <linux/types.h> + +/** +* +* +* ATA_COMMAND_CODES These constants depict the various ATA command codes +* defined in the ATA/ATAPI specification. +*/ +#define ATA_IDENTIFY_DEVICE 0xEC +#define ATA_CHECK_POWER_MODE 0xE5 +#define ATA_STANDBY 0xE2 +#define ATA_STANDBY_IMMED 0xE0 +#define ATA_IDLE_IMMED 0xE1 +#define ATA_IDLE 0xE3 +#define ATA_FLUSH_CACHE 0xE7 +#define ATA_FLUSH_CACHE_EXT 0xEA +#define ATA_READ_DMA_EXT 0x25 +#define ATA_READ_DMA 0xC8 +#define ATA_READ_SECTORS_EXT 0x24 +#define ATA_READ_SECTORS 0x20 +#define ATA_WRITE_DMA_EXT 0x35 +#define ATA_WRITE_DMA 0xCA +#define ATA_WRITE_SECTORS_EXT 0x34 +#define ATA_WRITE_SECTORS 0x30 +#define ATA_WRITE_UNCORRECTABLE 0x45 +#define ATA_READ_VERIFY_SECTORS 0x40 +#define ATA_READ_VERIFY_SECTORS_EXT 0x42 +#define ATA_READ_BUFFER 0xE4 +#define ATA_WRITE_BUFFER 0xE8 +#define ATA_EXECUTE_DEVICE_DIAG 0x90 +#define ATA_SET_FEATURES 0xEF +#define ATA_SMART 0xB0 +#define ATA_PACKET_IDENTIFY 0xA1 +#define ATA_PACKET 0xA0 +#define ATA_READ_FPDMA 0x60 +#define ATA_WRITE_FPDMA 0x61 +#define ATA_READ_LOG_EXT 0x2F +#define ATA_NOP 0x00 +#define ATA_DEVICE_RESET 0x08 +#define ATA_MEDIA_EJECT 0xED + +/** +* +* +* ATA_SMART_SUB_COMMAND_CODES These constants define the ATA SMART command +* sub-codes that can be executed. +*/ +#define ATA_SMART_SUB_CMD_ENABLE 0xD8 +#define ATA_SMART_SUB_CMD_DISABLE 0xD9 +#define ATA_SMART_SUB_CMD_RETURN_STATUS 0xDA +#define ATA_SMART_SUB_CMD_READ_LOG 0xD5 + +/** +* +* +* ATA_SET_FEATURES_SUB_COMMAND_CODES These constants define the ATA SET +* FEATURES command sub-codes that can be executed. +*/ +#define ATA_SET_FEATURES_SUB_CMD_ENABLE_CACHE 0x02 +#define ATA_SET_FEATURES_SUB_CMD_DISABLE_CACHE 0x82 +#define ATA_SET_FEATURES_SUB_CMD_DISABLE_READ_AHEAD 0x55 +#define ATA_SET_FEATURES_SUB_CMD_ENABLE_READ_AHEAD 0xAA +#define ATA_SET_FEATURES_SUB_CMD_SET_TRANSFER_MODE 0x3 + +/** +* +* +* ATA_READ_LOG_EXT_PAGE_CODES This is a list of log page codes available for +* use. +*/ +#define ATA_LOG_PAGE_NCQ_ERROR 0x10 +#define ATA_LOG_PAGE_SMART_SELF_TEST 0x06 +#define ATA_LOG_PAGE_EXTENDED_SMART_SELF_TEST 0x07 + +/** +* +* +* ATA_LOG_PAGE_NCQ_ERROR_CONSTANTS These constants define standard values for +* use when requesting the NCQ error log page. +*/ +#define ATA_LOG_PAGE_NCQ_ERROR_SECTOR 0 +#define ATA_LOG_PAGE_NCQ_ERROR_SECTOR_COUNT 1 + +/** +* +* +* ATA_STATUS_REGISTER_BITS The following are status register bit definitions +* per ATA/ATAPI-7. +*/ +#define ATA_STATUS_REG_BSY_BIT 0x80 +#define ATA_STATUS_REG_DEVICE_FAULT_BIT 0x20 +#define ATA_STATUS_REG_ERROR_BIT 0x01 + +/** +* +* +* ATA_ERROR_REGISTER_BITS The following are error register bit definitions per +* ATA/ATAPI-7. +*/ +#define ATA_ERROR_REG_NO_MEDIA_BIT 0x02 +#define ATA_ERROR_REG_ABORT_BIT 0x04 +#define ATA_ERROR_REG_MEDIA_CHANGE_REQUEST_BIT 0x08 +#define ATA_ERROR_REG_ID_NOT_FOUND_BIT 0x10 +#define ATA_ERROR_REG_MEDIA_CHANGE_BIT 0x20 +#define ATA_ERROR_REG_UNCORRECTABLE_BIT 0x40 +#define ATA_ERROR_REG_WRITE_PROTECTED_BIT 0x40 +#define ATA_ERROR_REG_ICRC_BIT 0x80 + +/** +* +* +* ATA_CONTROL_REGISTER_BITS The following are control register bit definitions +* per ATA/ATAPI-7 +*/ +#define ATA_CONTROL_REG_INTERRUPT_ENABLE_BIT 0x02 +#define ATA_CONTROL_REG_SOFT_RESET_BIT 0x04 +#define ATA_CONTROL_REG_HIGH_ORDER_BYTE_BIT 0x80 + +/** +* +* +* ATA_DEVICE_HEAD_REGISTER_BITS The following are device/head register bit +* definitions per ATA/ATAPI-7. +*/ +#define ATA_DEV_HEAD_REG_LBA_MODE_ENABLE 0x40 +#define ATA_DEV_HEAD_REG_FUA_ENABLE 0x80 + +/** +* +* +* ATA_IDENTIFY_DEVICE_FIELD_LENGTHS The following constants define the number +* of bytes contained in various fields found in the IDENTIFY DEVICE data +* structure. +*/ +#define ATA_IDENTIFY_SERIAL_NUMBER_LEN 20 +#define ATA_IDENTIFY_MODEL_NUMBER_LEN 40 +#define ATA_IDENTIFY_FW_REVISION_LEN 8 +#define ATA_IDENTIFY_48_LBA_LEN 8 +#define ATA_IDENTIFY_MEDIA_SERIAL_NUMBER_LEN 30 +#define ATA_IDENTIFY_WWN_LEN 8 + +/** +* +* +* ATA_IDENTIFY_DEVICE_FIELD_MASKS The following constants define bit masks +* utilized to determine if a feature is supported/enabled or if a bit is +* simply set inside of the IDENTIFY DEVICE data structre. +*/ +#define ATA_IDENTIFY_REMOVABLE_MEDIA_ENABLE 0x0080 +#define ATA_IDENTIFY_CAPABILITIES1_NORMAL_DMA_ENABLE 0x0100 +#define ATA_IDENTIFY_CAPABILITIES1_STANDBY_ENABLE 0x2000 +#define ATA_IDENTIFY_COMMAND_SET_SUPPORTED0_SMART_ENABLE 0x0001 +#define ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE 0x0400 +#define ATA_IDENTIFY_COMMAND_SET_WWN_SUPPORT_ENABLE 0x0100 +#define ATA_IDENTIFY_COMMAND_SET_ENABLED0_SMART_ENABLE 0x0001 +#define ATA_IDENTIFY_SATA_CAPABILITIES_NCQ_ENABLE 0x0100 +#define ATA_IDENTIFY_NCQ_QUEUE_DEPTH_ENABLE 0x001F +#define ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE 0x0100 +#define ATA_IDENTIFY_LOGICAL_SECTOR_PER_PHYSICAL_SECTOR_MASK 0x000F +#define ATA_IDENTIFY_LOGICAL_SECTOR_PER_PHYSICAL_SECTOR_ENABLE 0x2000 +#define ATA_IDENTIFY_WRITE_UNCORRECTABLE_SUPPORT 0x0004 +#define ATA_IDENTIFY_COMMAND_SET_SMART_SELF_TEST_SUPPORTED 0x0002 + +/** +* +* +* ATAPI_IDENTIFY_DEVICE_FIELD_MASKS These constants define the various bit +* definitions for the fields in the PACKET IDENTIFY DEVICE data structure. +*/ +#define ATAPI_IDENTIFY_16BYTE_CMD_PCKT_ENABLE 0x01 + +/** +* +* +* ATA_PACKET_FEATURE_BITS These constants define the various bit definitions +* for the ATA PACKET feature register. +*/ +#define ATA_PACKET_FEATURE_DMA 0x01 +#define ATA_PACKET_FEATURE_OVL 0x02 +#define ATA_PACKET_FEATURE_DMADIR 0x04 + +/** +* +* +* ATA_Device_Power_Mode_Values These constants define the power mode values +* returned by ATA_Check_Power_Mode +*/ +#define ATA_STANDBY_POWER_MODE 0x00 +#define ATA_IDLE_POWER_MODE 0x80 +#define ATA_ACTIVE_POWER_MODE 0xFF + +/** +* +* +* ATA_WRITE_UNCORRECTIABLE feature field values These constants define the +* Write Uncorrectable feature values used with the SATI translation. +*/ +#define ATA_WRITE_UNCORRECTABLE_PSUEDO 0x55 +#define ATA_WRITE_UNCORRECTABLE_FLAGGED 0xAA + + + +/** +* struct ATA_IDENTIFY_DEVICE - This structure depicts the ATA IDENTIFY DEVICE +* data format. +* +* +*/ +struct ata_identify_device_data { +u16 general_config_bits;/* word 00 */ +u16 obsolete0;/* word 01 (num cylinders) */ +u16 vendor_specific_config_bits;/* word 02 */ +u16 obsolete1;/* word 03 (num heads) */ +u16 retired1[2 ];/* words 04-05 */ +u16 obsolete2;/* word 06 (sectors / track) */ +u16 reserved_for_compact_flash1[2 ];/* words 07-08 */ +u16 retired0;/* word 09 */ +u8 serial_number[ATA_IDENTIFY_SERIAL_NUMBER_LEN ];/* word 10-19 */ +u16 retired2[2 ];/* words 20-21 */ +u16 obsolete4;/* word 22 */ +u8 firmware_revision[ATA_IDENTIFY_FW_REVISION_LEN ];/* words 23-26 */ +u8 model_number[ATA_IDENTIFY_MODEL_NUMBER_LEN ];/* words 27-46 */ +u16 max_sectors_per_multiple;/* word 47 */ +u16 reserved0;/* word 48 */ +u16 capabilities1;/* word 49 */ +u16 capabilities2;/* word 50 */ +u16 obsolete5[2 ];/* words 51-52 */ +u16 validity_bits;/* word 53 */ +u16 obsolete6[5 ];/* +* words 54-58 Used to be: +* current cylinders, +* current heads, +* current sectors/Track, +* current capacity */ +u16 current_max_sectors_per_multiple;/* word 59 */ +u8 total_num_sectors[4 ];/* words 60-61 */ +u16 obsolete7;/* word 62 */ +u16 multi_word_dma_mode;/* word 63 */ +u16 pio_modes_supported;/* word 64 */ +u16 min_multiword_dma_transfer_cycle;/* word 65 */ +u16 rec_min_multiword_dma_transfer_cycle;/* word 66 */ +u16 min_pio_transfer_no_flow_ctrl;/* word 67 */ +u16 min_pio_transfer_with_flow_ctrl;/* word 68 */ +u16 reserved1[2 ];/* words 69-70 */ +u16 reserved2[4 ];/* words 71-74 */ +u16 queue_depth;/* word 75 */ +u16 serial_ata_capabilities;/* word 76 */ +u16 serial_ata_reserved;/* word 77 */ +u16 serial_ata_features_supported;/* word 78 */ +u16 serial_ata_features_enabled;/* word 79 */ +u16 major_version_number;/* word 80 */ +u16 minor_version_number;/* word 81 */ +u16 command_set_supported0;/* word 82 */ +u16 command_set_supported1;/* word 83 */ +u16 command_set_supported_extention;/* word 84 */ +u16 command_set_enabled0;/* word 85 */ +u16 command_set_enabled1;/* word 86 */ +u16 command_set_default;/* word 87 */ +u16 ultra_dma_mode;/* word 88 */ +u16 security_erase_completion_time;/* word 89 */ +u16 enhanced_security_erase_time;/* word 90 */ +u16 current_power_mgmt_value;/* word 91 */ +u16 master_password_revision;/* word 92 */ +u16 hardware_reset_result;/* word 93 */ +u16 current_acoustic_management_value;/* word 94 */ +u16 stream_min_request_size;/* word 95 */ +u16 stream_transfer_time;/* word 96 */ +u16 stream_access_latency;/* word 97 */ +u16 stream_performance_granularity[2 ];/* words 98-99 */ +u8 max_48bit_lba[ATA_IDENTIFY_48_LBA_LEN ];/* words 100-103 */ +u16 streaming_transfer_time;/* word 104 */ +u16 reserved3;/* word 105 */ +u16 physical_logical_sector_info;/* word 106 */ +u16 acoustic_test_interseek_delay;/* word 107 */ +u8 world_wide_name[ATA_IDENTIFY_WWN_LEN ];/* words 108-111 */ +u8 reserved_for_wwn_extention[ATA_IDENTIFY_WWN_LEN ];/* words 112-115 */ +u16 reserved4;/* word 116 */ +u8 words_per_logical_sector[4 ];/* words 117-118 */ +u16 command_set_supported2;/* word 119 */ +u16 reserved5[7 ];/* words 120-126 */ +u16 removable_media_status;/* word 127 */ +u16 security_status;/* word 128 */ +u16 vendor_specific1[31 ];/* words 129-159 */ +u16 cfa_power_mode1;/* word 160 */ +u16 reserved_for_compact_flash2[7 ];/* words 161-167 */ +u16 device_nominal_form_factor;/* word 168 */ +u16 reserved_for_compact_flash3[7 ];/* words 169-175 */ +u16 current_media_serial_number[ATA_IDENTIFY_MEDIA_SERIAL_NUMBER_LEN ];/* words 176-205 */ +u16 reserved6[3 ];/* words 206-208 */ +u16 logical_sector_alignment;/* words 209 */ +u16 reserved7[7 ];/* words 210-216 */ +u16 nominal_media_rotation_rate;/* word 217 */ +u16 reserved8[37 ];/* words 218-254 */ +u16 integrity_word;/* word 255 */ + +}; + +#define ATA_IDENTIFY_DEVICE_GET_OFFSET (field_name) \ + ((unsigned long)&(((struct ata_identify_device_data *)0)->field_name)) +#define ATA_IDENTIFY_DEVICE_WCE_ENABLE 0x20 +#define ATA_IDENTIFY_DEVICE_RA_ENABLE 0x40 + +/** +* struct ATAPI_IDENTIFY_PACKET_DATA - The following structure depicts the +* ATA-ATAPI 7 version of the IDENTIFY PACKET DEVICE data structure. +* +* +*/ +struct atapi_identify_packet_device { +u16 generalConfigBits;/* word 00 */ +u16 reserved0;/* word 01 (num cylinders) */ +u16 uniqueConfigBits;/* word 02 */ +u16 reserved1[7 ];/* words 03 - 09 */ +u8 serialNumber[ATA_IDENTIFY_SERIAL_NUMBER_LEN ];/* word 10-19 */ +u16 reserved2[3 ];/* words 20-22 */ +u8 firmwareRevision[ATA_IDENTIFY_FW_REVISION_LEN ];/* words 23-26 */ +u8 modelNumber[ATA_IDENTIFY_MODEL_NUMBER_LEN ];/* words 27-46 */ +u16 reserved4[2 ];/* words 47-48 */ +u16 capabilities1;/* word 49 */ +u16 capabilities2;/* word 50 */ +u16 obsolete0[2 ];/* words 51-52 */ +u16 validityBits;/* word 53 */ +u16 reserved[8 ];/* words 54-61 */ + +u16 DMADIRBitRequired;/* word 62, page2 */ +u16 multiWordDmaMode;/* word 63 */ +u16 pioModesSupported;/* word 64 */ +u16 minMultiwordDmaTransferCycle;/* word 65 */ +u16 recMinMultiwordDmaTransferCycle;/* word 66 */ +u16 minPioTransferNoFlowCtrl;/* word 67 */ +u16 minPioTransferWithFlowCtrl;/* word 68 */ +u16 reserved6[2 ];/* words 69-70 */ +u16 nsFromPACKETReceiptToBusRelease;/* word 71 */ +u16 nsFromSERVICEReceiptToBSYreset;/* wore 72 */ +u16 reserved7[2 ];/* words 73-74 */ +u16 queueDepth;/* word 75 */ +u16 serialAtaCapabilities;/* word 76 */ +u16 serialAtaReserved;/* word 77 */ +u16 serialAtaFeaturesSupported;/* word 78 */ +u16 serialAtaFeaturesEnabled;/* word 79 */ + +u16 majorVersionNumber;/* word 80, page3 */ +u16 minorVersionNumber;/* word 81 */ +u16 commandSetSupported0;/* word 82 */ +u16 commandSetSupported1;/* word 83 */ + +u16 commandSetSupportedExtention;/* word 84, page4 */ +u16 commandSetEnabled0;/* word 85 */ +u16 commandSetEnabled1;/* word 86 */ +u16 commandSetDefault;/* word 87 */ + +u16 ultraDmaMode;/* word 88, page5 */ +u16 reserved8[4 ];/* words 89 - 92 */ + +u16 hardwareResetResult;/* word 93, page6 */ +u16 currentAcousticManagementValue;/* word 94 */ +u16 reserved9[30 ];/* words 95-124 */ +u16 ATAPIByteCount0Behavior;/* word 125 */ +u16 obsolete1;/* word 126 */ +u16 removableMediaStatus;/* word 127, */ + +u16 securityStatus;/* word 128, page7 */ +u16 vendorSpecific1[31 ];/* words 129-159 */ +u16 reservedForCompactFlash[16 ];/* words 160-175 */ +u16 reserved10[79 ];/* words 176-254 */ +u16 integrityWord;/* word 255 */ +}; + +/** +* struct ata_extended_smart_self_test_log - The following structure depicts +* the ATA-8 version of the Extended SMART self test log page descriptor +* entry. +* +* +*/ +union ata_descriptor_entry { +struct DESCRIPTOR_ENTRY { +u8 lba_field; +u8 status_byte; +u8 time_stamp_low; +u8 time_stamp_high; +u8 checkpoint_byte; +u8 failing_lba_low; +u8 failing_lba_mid; +u8 failing_lba_high; +u8 failing_lba_low_ext; +u8 failing_lba_mid_ext; +u8 failing_lba_high_ext; + +u8 vendor_specific1; +u8 vendor_specific2; +u8 vendor_specific3; +u8 vendor_specific4; +u8 vendor_specific5; +u8 vendor_specific6; +u8 vendor_specific7; +u8 vendor_specific8; +u8 vendor_specific9; +u8 vendor_specific10; +u8 vendor_specific11; +u8 vendor_specific12; +u8 vendor_specific13; +u8 vendor_specific14; +u8 vendor_specific15; + } DESCRIPTOR_ENTRY; + +u8 descriptor_entry[26 ]; + +}; + +/** +* struct ata_extended_smart_self_test_log - The following structure depicts +* the ATA-8 version of the SMART self test log page descriptor entry. +* +* +*/ +union ata_smart_descriptor_entry { +struct SMART_DESCRIPTOR_ENTRY { +u8 lba_field; +u8 status_byte; +u8 time_stamp_low; +u8 time_stamp_high; +u8 checkpoint_byte; +u8 failing_lba_low; +u8 failing_lba_mid; +u8 failing_lba_high; +u8 failing_lba_low_ext; + +u8 vendor_specific1; +u8 vendor_specific2; +u8 vendor_specific3; +u8 vendor_specific4; +u8 vendor_specific5; +u8 vendor_specific6; +u8 vendor_specific7; +u8 vendor_specific8; +u8 vendor_specific9; +u8 vendor_specific10; +u8 vendor_specific11; +u8 vendor_specific12; +u8 vendor_specific13; +u8 vendor_specific14; +u8 vendor_specific15; + } SMART_DESCRIPTOR_ENTRY; + +u8 smart_descriptor_entry[24 ]; + +}; + +/** +* struct ata_extended_smart_self_test_log - The following structure depicts +* the ATA-8 version of the Extended SMART self test log page. +* +* +*/ +struct ata_extended_smart_self_test_log { +u8 self_test_log_data_structure_revision_number;/* byte 0 */ +u8 reserved0;/* byte 1 */ +u8 self_test_descriptor_index[2 ];/* byte 2-3 */ + +union ata_descriptor_entry descriptor_entrys[19 ];/* bytes 4-497 */ + +u8 vendor_specific[2 ];/* byte 498-499 */ +u8 reserved1[11 ];/* byte 500-510 */ +u8 data_structure_checksum;/* byte 511 */ + +}; + +/** +* struct ata_extended_smart_self_test_log - The following structure depicts +* the ATA-8 version of the SMART self test log page. +* +* +*/ +struct ata_smart_self_test_log { +u8 self_test_log_data_structure_revision_number[2 ];/* bytes 0-1 */ + +union ata_smart_descriptor_entry descriptor_entrys[21 ];/* bytes 2-505 */ + +u8 vendor_specific[2 ];/* byte 506-507 */ +u8 self_test_index;/* byte 508 */ +u8 reserved1[2 ];/* byte 509-510 */ +u8 data_structure_checksum;/* byte 511 */ + +}; + +#endif /* _ATA_H_ */ +
drivers/scsi/isci/core/intel_sas.h new file +948 -0
948 lines not on this page · raw message
drivers/scsi/isci/core/intel_sat.h new file +95 -0
95 lines not on this page · raw message
drivers/scsi/isci/core/intel_sata.h new file +280 -0
280 lines not on this page · raw message
drivers/scsi/isci/core/intel_scsi.h new file +474 -0
474 lines not on this page · raw message
drivers/scsi/isci/core/sati_device.h new file +156 -0
156 lines not on this page · raw message
drivers/scsi/isci/core/sati_translator_sequence.h new file +304 -0
304 lines not on this page · raw message
drivers/scsi/isci/core/sati_types.h new file +145 -0
145 lines not on this page · raw message
drivers/scsi/isci/core/sci_pool.h new file +199 -0
44 lines not on this page · raw message
drivers/scsi/isci/core/sci_status.h new file +409 -0
409 lines not on this page · raw message
drivers/scsi/isci/core/sci_util.c new file +101 -0
101 lines not on this page · raw message
drivers/scsi/isci/core/sci_util.h new file +108 -0
108 lines not on this page · raw message
drivers/scsi/isci/core/scic_config_parameters.h new file +346 -0
346 lines not on this page · raw message
drivers/scsi/isci/core/scic_sds_pci.h new file +94 -0
94 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [RFC PATCH 10/10] isci/core: common definitions and utility functions
drivers/scsi/isci/core/sci_util.h line 73
Quoted 12 lines
drivers/scsi/isci/core/sci_util.h new file +12
-0+/** +* SCIC_SWAP_DWORD() - +* +* Normal byte swap macro +*/ +#define SCIC_SWAP_DWORD (x) \ + (\ + (((x) >> 24) & 0x000000FF) \ + | (((x) >> 8) & 0x0000FF00) \ + | (((x) << 8) & 0x00FF0000) \ + | (((x) << 24) & 0xFF000000) \ + )
Duplicates the kernel byte sewap macros. Even worse it's doing an unconditional swap instead of a conditional one if the platform is big endian. While we're at it this driver seems to lack any kind of endiness awareness, but that's probably to be expected coming from intel. Isn't the new chipset generation supposed to support ia64 as well, which is capable of running in big endian mode?
Quoted 23 lines · Dan Williams
The full driver and history is available in git:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.gitmasterThe libsas-pending branch contains proposed libsas fixes (pending acceptance into scsi-misc):
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.gitlibsas-pendingThe x86-pending branch contains a proposed api for mapping bios roms so the driver can retrieve configuration parameters (pending acceptance into -tip):
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.gitx86-pending--
Dan for the isci driver team[1]: http://marc.info/?l=linux-scsi&m=129703780424729&w=2
---
Quoted 11 lines
Dan Williams (10):
isci/core: controller
isci/core: phy
isci/core: port
isci/core: remote device
isci/core: remote node context
isci/core: stp
isci/core: request (general, ssp and smp) isci/core: unsolicited frame handling and registers isci/core: base state machine and memory descriptors isci/core: common definitions and utility functions
Let's get this driver into staging for 2.6.39, if it isn't going to hit the merge window for 2.6.39.
It would lame for such [presumably] high volume hardware to be in neither the main kernel, nor staging, at 2.6.39 release time.
Jeff
Quoted 5 lines · Jeff Garzik
Let's get this driver into staging for 2.6.39, if it isn't going to hit the merge window for 2.6.39.
It would lame for such [presumably] high volume hardware to be in neither the main kernel, nor staging, at 2.6.39 release time.
What's the point of staging? That just causes tons of poinless churn. Linus has made it clear that normal high volume hardware drivers can go in after the merge window. So let's just polish it for another few weeks and then put it in where it belongs.
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Jeff Garzik
Let's get this driver into staging for 2.6.39, if it isn't going to hit the merge window for 2.6.39.
It would lame for such [presumably] high volume hardware to be in neither the main kernel, nor staging, at 2.6.39 release time.
What's the point of staging? That just causes tons of poinless churn. Linus has made it clear that normal high volume hardware drivers can go in after the merge window. So let's just polish it for another few weeks and then put it in where it belongs.
That's fine... if that really happens.
It seemed like this was turning into another driver that would get held outside the kernel until it's "perfect." If that is the case, Linus has also made it clear we should get drivers for high volume, shipping hardware into the kernel, even if its staging, if the alternative is to deny users the driver.
Jeff
Quoted 15 lines · Jeff Garzik
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Jeff Garzik
Let's get this driver into staging for 2.6.39, if it isn't going to hit the merge window for 2.6.39.
Quoted 7 lines
Quoted 2 lines
It would lame for such [presumably] high volume hardware to be in neither the main kernel, nor staging, at 2.6.39 release time.
What's the point of staging? That just causes tons of poinless churn. Linus has made it clear that normal high volume hardware drivers can go in after the merge window. So let's just polish it for another few weeks and then put it in where it belongs.
Quoted 8 lines
That's fine... if that really happens.
It seemed like this was turning into another driver that would get held outside the kernel until it's "perfect." If that is the case, Linus has also made it clear we should get drivers for high volume, shipping hardware into the kernel, even if its staging, if the alternative is to deny users the driver.
Whether it is drivers/staging/ or drivers/scsi/ having a few more weeks to at least allow for a SCSI focused review (and the resulting cleanups / fixes) before merging is the important point.
Staging does not seem to be the location for high volume cleanups after the merge window closes:
$ git diff --stat -M v2.6.38-rc1..v2.6.38 drivers/staging/ 50 files changed, 832 insertions(+), 476 deletions(-)
...though there is a precedent for taking large staging drivers post merge window (commit 9d200153: Staging: add MSM framebuffer driver).
This looks like a way forward. Barring objections I would also go ahead and get the current git tree into -next just to flush out any build / integration issues. If we (community) end up deciding the driver should still go to staging I can just do a late "git mv drivers/scsi/isci drivers/staging/" prior to sending the pull request to Greg.
--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Dan Williams
Whether it is
drivers/staging/ordrivers/scsi/having a few more weeks to at least allow for a SCSI focused review (and the resulting cleanups / fixes) before merging is the important point.
Oh, agreed. Not trying to rush past that part. And there's still plenty of work that wants doing.
I just don't want to get stuck behind the "wall of perfection," either. :)
Jeff
Quoted 4 lines · Dan Williams
As first introduced in "[RFC PATCH 0/6] isci: initial driver release (part1: intro and lldd) " [1], the isci driver is split into an lldd layer that interfaces with libsas and a core layer that interfaces with the hardware. Quoting from the original introduction:
I just looked at it and that architecture is a complete fucking mess.
You absolutely have to fix it before it can be merged. Gems like duplicating all wire level constants and structures for SCSI, SAS and ATA in your own headers is simply not acceptable. I'm not sure where you got the idea this could be remotely acceptable.
Also the source layout is a real mess, almost comparably to the broacade FC driver - there really is no point in having a header for barely more than a structure or inline.
Also care to explain the design rationale for all these specific semi-statemachines? To my untrained eye they really looks like pointless obsfucation, but maybe there's a good reason that should be explained in long comments.
And please don't make the code like ACPICA, macro names like SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT or SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE just need to go.
Also please get rid of ALL UPPERCASE SCREAMING NAMES for structures.
FYI:
u32 connection_inactivity_timeout:16;
is a really dumb idea. Please take the crackpipe away from whatever idiot came up with junk like that and use the proper right sized integer types. Also for sub-byte field please absolutely avoid bitfields. Their layout is unportable, and properly locking them is a nightmare. Just define a flags field and use bit operations on them.
On Fri, Mar 18, 2011 at 8:56 AM, Christoph Hellwig <[email protected]> wrote:
[..]
Quoted 3 lines
You absolutely have to fix it before it can be merged. Gems like duplicating all wire level constants and structures for SCSI, SAS and ATA in your own headers is simply not acceptable.
Hence the comment "Many of these want to be deleted in favor of the in-kernel equivalent." in "[RFC PATCH 10/10] isci/core: common definitions and utility functions' [1].
Quoted 1 line
I'm not sure where you got the idea this could be remotely acceptable.
Never did. We're reworking the driver that was handed to us.
To date fixing bugs in the current code (things like removing phys_to_virt and virt_to_phys in favor of proper dma-api and kmap usage) has delayed this rework... still plan to fix it.
Quoted 3 lines
Also the source layout is a real mess, almost comparably to the broacade FC driver - there really is no point in having a header for barely more than a structure or inline.
Agreed. We consolidated the c files, now need to go back and do the same for the headers. There is also a namespacecheck driven cleanup that needs to happen as well.
Quoted 4 lines
Also care to explain the design rationale for all these specific semi-statemachines? To my untrained eye they really looks like pointless obsfucation, but maybe there's a good reason that should be explained in long comments.
They model asynchronous hardware / protocol states and are loosely analogous to the ata_sff_hsm implementation in libata in terms of
needing to handle transport layer details of sata, smp, and ssp. The
hardware is focused on accelerating the fast paths and let's software handle many slow path conditions, for example ata pio requests require driver interaction to progress the request through several states at a per frame level. We'll put together some better documentation but there are a lot of conditions and states that software is required to handle and the state machines keep these organized.
There have been some patches to make them more readable (8e131f53, ba647271, 03355704), but this work has not been completed across all the state machines. I will say I think the controller state machine is one that could be eventually factored out / absorbed into the lldd because there are no asynchronous hardware-event driven controller state transitions.
Quoted 4 lines
And please don't make the code like ACPICA, macro names like
SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORTorSCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATEjust need to go.
Ok.
Quoted 1 line
Also please get rid of ALL UPPERCASE SCREAMING NAMES for structures.
Unfortunately, the automated scripts we developed at the beginning of the cleanup effort only caught definitions of the form:
typedef struct UPPERCASE_STRUCT { } UPPERCASE_STRUCT_T;
...and missed ones of the form:
struct UPPERCASE_STRUCT { };
...so we need to manually handle these stragglers.
Quoted 9 lines
FYI:
u32 connection_inactivity_timeout:16;
is a really dumb idea. Please take the crackpipe away from whatever idiot came up with junk like that and use the proper right sized integer types. Also for sub-byte field please absolutely avoid bitfields. Their layout is unportable, and properly locking them is a nightmare. Just define a flags field and use bit operations on them.
Yeah. it does not make sense to define bitfields for things that are correctly aligned base types.
--
Dan
[1]: http://marc.info/?l=linux-scsi&m=129975444506569&w=2
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Btw, the naming scheme in the driver seems utterly confusing, with prefixed split between isci_, sci_ and scic_, where a lot of the latter also have a second sds_ or controller_ prefix. Especially the use of controller_ in a lot of the nomenclature seems very confusing to me. Is there a scheme behind all this?
Quoted 6 lines · Christoph Hellwig
Btw, the naming scheme in the driver seems utterly confusing, with prefixed split between
isci_,sci_andscic_, where a lot of the latter also have a secondsds_orcontroller_prefix. Especially the use ofcontroller_in a lot of the nomenclature seems very confusing to me. Is there a scheme behind all this?
Yes, it needs to be documented, but there is some method behind the confusion.
The expectation is that the lldd need not understand core internals outside of a set of interface functions. Any functions prefixed scic_sds_ are meant to only be called by other core routines. We have broken that rule in places where it added unnecessary indirection, like the isr handlers and phy enable/disable interface (should probably go back and make those consistent before the final merge).
Core data-structure definitions are also hidden from the lldd. All it has access to are the forward declared structure types.
Any functions prefixed with isci_ belong to the lldd, and to remove indirection we are teaching the core to call lldd routines and native Linux routines directly (the bulk of the upstream cleanup effort is covered by this theme).
During this effort it was found that local variable instances had inconsistent, sometimes overly verbose (contributing to 80 column collisions), and sometimes ambiguous names so we are using the following scheme going forward and converting routines in the course of doing other cleanups.
object | lldd instance | core instance ------------------|---------------|--------------- controller / host | ihost | scic task / request | ireq | sci_req, stp_req, ssp_req, smp_req sas device | idev | sci_dev sas phy | iphy | sci_phy sas port | iport | sci_port
Quoted 2 lines · Dan Williams
The expectation is that the lldd need not understand core internals outside of a set of interface functions.
I think you need to get rid of that stupid core/wrapper split ASAP, as it's the root of a lot of the crap in this driver. Removing all the stupid indirections and duplicate structures it causes will make the driver a lot smaller, and actually look like a normal Linux driver and thus actually maintainable.
Quoted 9 lines · Christoph Hellwig
Quoted 2 lines · Dan Williams
The expectation is that the lldd need not understand core internals outside of a set of interface functions.
I think you need to get rid of that stupid core/wrapper split ASAP, as it's the root of a lot of the crap in this driver. Removing all the stupid indirections and duplicate structures it causes will make the driver a lot smaller, and actually look like a normal Linux driver and thus actually maintainable.
I think we were already on this path, but now just need to formally acknowledge and accelerate in this direction. Let me outline where I think we are and a rough outline of how to get to the removal of the wrapper.
1/ Complete the removal of all OS agnostic indirections in the core. We have done quite a bit here to call kernel and lldd facilities directly, but still need to get rid of intel_{sas|sata|scsi}.h and duplicated utilities before this step is complete.
2/ Make the core data structures member position independent (so we can start adding / removing fields at will). That means getting rid of unnecessary casting (already started), the base_ structures (you started this) and the _{get|set}_association macros.
3/ Unify the data structures so they have the same lifetimes. Where the lldd has a member that duplicates a core member teach it to use the core version. Quick example isci_phy.aif and scic_sds_phy.sas.identify_address_frame_buffer.
4/ Remove the lldd/core data structure distinction.
Probably missing some sub-steps between three and four, but that is the general idea.
--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Dan Williams
I think we were already on this path, but now just need to formally acknowledge and accelerate in this direction. Let me outline where I think we are and a rough outline of how to get to the removal of the wrapper.
1/ Complete the removal of all OS agnostic indirections in the core. We have done quite a bit here to call kernel and lldd facilities directly, but still need to get rid of intel_{sas|sata|scsi}.h and duplicated utilities before this step is complete.
2/ Make the core data structures member position independent (so we can start adding / removing fields at will). That means getting rid of unnecessary casting (already started), the
base_structures (you started this) and the _{get|set}_association macros.3/ Unify the data structures so they have the same lifetimes. Where the lldd has a member that duplicates a core member teach it to use the core version. Quick example isci_phy.aif and scic_sds_phy.sas.identify_address_frame_buffer.
Quoted 4 lines
4/ Remove the lldd/core data structure distinction.
Probably missing some sub-steps between three and four, but that is the general idea.
Yes, that's about the required stepts. In general I'd try to do as much as possible of the data structures before the procedural part, as that's the design that really matters.