u32 completion_entry)
{
u32 index;
- struct scic_sds_request *io_request;
+ struct scic_sds_request *sci_req;
index = SCU_GET_COMPLETION_INDEX(completion_entry);
- io_request = scic->io_request_table[index];
+ sci_req = scic->io_request_table[index];
/* Make sure that we really want to process this IO request */
- if (
- (io_request != NULL)
- && (io_request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG)
- && (
- scic_sds_io_tag_get_sequence(io_request->io_tag)
- == scic->io_request_sequence[index]
- )
- ) {
+ if (sci_req && sci_req->io_tag != SCI_CONTROLLER_INVALID_IO_TAG &&
+ ISCI_TAG_SEQ(sci_req->io_tag) == scic->io_request_sequence[index])
/* Yep this is a valid io request pass it along to the io request handler */
- scic_sds_io_request_tc_completion(io_request, completion_entry);
- }
+ scic_sds_io_request_tc_completion(sci_req, completion_entry);
}
static void scic_sds_controller_sdma_completion(struct scic_sds_controller *scic,
sci_req->task_context_buffer = task_context_buffer;
}
-/**
- * This method returns the task context buffer for the given io tag.
- * @scic:
- * @io_tag:
- *
- * struct scu_task_context*
- */
-struct scu_task_context *scic_sds_controller_get_task_context_buffer(
- struct scic_sds_controller *scic,
- u16 io_tag
- ) {
- u16 task_index = scic_sds_io_tag_get_index(io_tag);
+struct scu_task_context *scic_sds_controller_get_task_context_buffer(struct scic_sds_controller *scic,
+ u16 io_tag)
+{
+ u16 tci = ISCI_TAG_TCI(io_tag);
- if (task_index < scic->task_context_entries) {
- return &scic->task_context_table[task_index];
+ if (tci < scic->task_context_entries) {
+ return &scic->task_context_table[tci];
}
return NULL;
}
-struct scic_sds_request *scic_request_by_tag(struct scic_sds_controller *scic,
- u16 io_tag)
+struct scic_sds_request *scic_request_by_tag(struct scic_sds_controller *scic, u16 io_tag)
{
u16 task_index;
u16 task_sequence;
- task_index = scic_sds_io_tag_get_index(io_tag);
+ task_index = ISCI_TAG_TCI(io_tag);
- if (task_index < scic->task_context_entries) {
+ if (task_index < scic->task_context_entries) {
if (scic->io_request_table[task_index] != NULL) {
- task_sequence = scic_sds_io_tag_get_sequence(io_tag);
+ task_sequence = ISCI_TAG_SEQ(io_tag);
if (task_sequence == scic->io_request_sequence[task_index]) {
return scic->io_request_table[task_index];
* successfully started the IO request. SCI_SUCCESS if the IO request was
* successfully started. Determine the failure situations and return values.
*/
-enum sci_status scic_controller_start_io(
- struct scic_sds_controller *scic,
- struct scic_sds_remote_device *rdev,
- struct scic_sds_request *req,
- u16 io_tag)
+enum sci_status scic_controller_start_io(struct scic_sds_controller *scic,
+ struct scic_sds_remote_device *rdev,
+ struct scic_sds_request *req,
+ u16 io_tag)
{
enum sci_status status;
if (status != SCI_SUCCESS)
return status;
- scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req;
+ scic->io_request_table[ISCI_TAG_TCI(req->io_tag)] = req;
scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(req));
return SCI_SUCCESS;
}
if (status != SCI_SUCCESS)
return status;
- index = scic_sds_io_tag_get_index(request->io_tag);
+ index = ISCI_TAG_TCI(request->io_tag);
scic->io_request_table[index] = NULL;
return SCI_SUCCESS;
default:
return SCI_FAILURE_INVALID_STATE;
}
- scic->io_request_table[scic_sds_io_tag_get_index(sci_req->io_tag)] = sci_req;
+ scic->io_request_table[ISCI_TAG_TCI(sci_req->io_tag)] = sci_req;
scic_sds_controller_post_request(scic, scic_sds_request_get_post_context(sci_req));
return SCI_SUCCESS;
}
status = scic_sds_remote_device_start_task(scic, rdev, req);
switch (status) {
case SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS:
- scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req;
+ scic->io_request_table[ISCI_TAG_TCI(req->io_tag)] = req;
/*
* We will let framework know this task request started successfully,
*/
return SCI_SUCCESS;
case SCI_SUCCESS:
- scic->io_request_table[scic_sds_io_tag_get_index(req->io_tag)] = req;
+ scic->io_request_table[ISCI_TAG_TCI(req->io_tag)] = req;
scic_sds_controller_post_request(scic,
scic_sds_request_get_post_context(req));
u16 scic_controller_allocate_io_tag(struct scic_sds_controller *scic)
{
struct isci_host *ihost = scic_to_ihost(scic);
- u16 tci;
- u16 seq;
if (isci_tci_space(ihost)) {
- tci = isci_tci_alloc(ihost);
- seq = scic->io_request_sequence[tci];
+ u16 tci = isci_tci_alloc(ihost);
+ u8 seq = scic->io_request_sequence[tci];
- return scic_sds_io_tag_construct(seq, tci);
+ return ISCI_TAG(seq, tci);
}
return SCI_CONTROLLER_INVALID_IO_TAG;
u16 io_tag)
{
struct isci_host *ihost = scic_to_ihost(scic);
- u16 sequence;
- u16 index;
-
- BUG_ON(io_tag == SCI_CONTROLLER_INVALID_IO_TAG);
-
- sequence = scic_sds_io_tag_get_sequence(io_tag);
- index = scic_sds_io_tag_get_index(io_tag);
+ u16 tci = ISCI_TAG_TCI(io_tag);
+ u16 seq = ISCI_TAG_SEQ(io_tag);
/* prevent tail from passing head */
if (isci_tci_active(ihost) == 0)
return SCI_FAILURE_INVALID_IO_TAG;
- if (sequence == scic->io_request_sequence[index]) {
- scic_sds_io_sequence_increment(scic->io_request_sequence[index]);
+ if (seq == scic->io_request_sequence[tci]) {
+ scic->io_request_sequence[tci] = (seq+1) & (SCI_MAX_SEQ-1);
- isci_tci_free(ihost, index);
+ isci_tci_free(ihost, ISCI_TAG_TCI(io_tag));
return SCI_SUCCESS;
}
*/
struct scic_power_control power_control;
- /**
- * This field is the array of sequence values for the IO Tag fields. Even
- * though only 4 bits of the field is used for the sequence the sequence is 16
- * bits in size so the sequence can be bitwise or'd with the TCi to build the
- * IO Tag value.
- */
- u16 io_request_sequence[SCI_MAX_IO_REQUESTS];
+ /* sequence number per tci */
+ u8 io_request_sequence[SCI_MAX_IO_REQUESTS];
/**
* This field in the array of sequence values for the RNi. These are used
*/
#define scic_sds_controller_get_protocol_engine_group(controller) 0
-/**
- * scic_sds_io_tag_construct() -
- *
- * This macro constructs an IO tag from the sequence and index values.
- */
-#define scic_sds_io_tag_construct(sequence, task_index) \
- ((sequence) << 12 | (task_index))
-
-/**
- * scic_sds_io_tag_get_sequence() -
- *
- * This macro returns the IO sequence from the IO tag value.
- */
-#define scic_sds_io_tag_get_sequence(io_tag) \
- (((io_tag) & 0xF000) >> 12)
-
-/**
- * scic_sds_io_tag_get_index() -
- *
- * This macro returns the TCi from the io tag value
- */
-#define scic_sds_io_tag_get_index(io_tag) \
- ((io_tag) & 0x0FFF)
+/* see scic_controller_io_tag_allocate|free for how seq and tci are built */
+#define ISCI_TAG(seq, tci) (((u16) (seq)) << 12 | tci)
-/**
- * scic_sds_io_sequence_increment() -
- *
- * This is a helper macro to increment the io sequence count. We may find in
- * the future that it will be faster to store the sequence count in such a way
- * as we dont perform the shift operation to build io tag values so therefore
- * need a way to incrment them correctly
- */
-#define scic_sds_io_sequence_increment(value) \
- ((value) = (((value) + 1) & 0x000F))
+/* these are returned by the hardware, so sanitize them */
+#define ISCI_TAG_SEQ(tag) (((tag) >> 12) & (SCI_MAX_SEQ-1))
+#define ISCI_TAG_TCI(tag) ((tag) & (SCI_MAX_IO_REQUESTS-1))
/* expander attached sata devices require 3 rnc slots */
static inline int scic_sds_remote_device_node_count(struct scic_sds_remote_device *sci_dev)
#define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
#define SCI_MAX_REMOTE_DEVICES (256UL)
#define SCI_MAX_IO_REQUESTS (256UL)
+#define SCI_MAX_SEQ (16)
#define SCI_MAX_MSIX_MESSAGES (2)
#define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */
#define SCI_MAX_CONTROLLERS 2
BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_COMPLETION_QUEUE_ENTRIES);
BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES > SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES);
BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_IO_REQUESTS);
+ BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_SEQ);
}
/**
rnc->ssp.arbitration_wait_time = 0;
}
-/**
- * scic_sds_port_construct_dummy_task() - create dummy task for si workaround
- * @sci_port The logical port on which we need to create the
- * remote node context.
- * context.
- * @tci The remote node index for this remote node context.
- *
- * This routine will construct a dummy task context data structure. This
+/*
+ * construct a dummy task context data structure. This
* structure will be posted to the hardwre to work around a scheduler error
* in the hardware.
- *
*/
-static void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tci)
+static void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tag)
{
struct scu_task_context *task_context;
- task_context = scic_sds_controller_get_task_context_buffer(sci_port->owning_controller, tci);
+ task_context = scic_sds_controller_get_task_context_buffer(sci_port->owning_controller, tag);
memset(task_context, 0, sizeof(struct scu_task_context));
task_context->protocol_engine_index = 0;
task_context->logical_port_index = sci_port->physical_port_index;
task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP;
- task_context->task_index = scic_sds_io_tag_get_index(tci);
+ task_context->task_index = ISCI_TAG_TCI(tag);
task_context->valid = SCU_TASK_CONTEXT_VALID;
task_context->context_type = SCU_TASK_CONTEXT_TYPE;
SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
(scic_sds_port_get_index(target_port) <<
SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
- scic_sds_io_tag_get_index(sds_request->io_tag));
+ ISCI_TAG_TCI(sds_request->io_tag));
} else {
/*
* Build the task context now since we have already read
SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
(scic_sds_port_get_index(target_port) <<
SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
- scic_sds_io_tag_get_index(sci_req->io_tag));
+ ISCI_TAG_TCI(sci_req->io_tag));
} else {
/*
* Build the task context now since we have already read
*/
ret_val = readl(scu_reg_base +
(SCU_TASK_CONTEXT_SRAM + offsetof(struct scu_task_context, type.ssp.data_offset)) +
- ((sizeof(struct scu_task_context)) * scic_sds_io_tag_get_index(sci_req->io_tag)));
+ ((sizeof(struct scu_task_context)) * ISCI_TAG_TCI(sci_req->io_tag)));
}
return ret_val;
if (sci_req->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) {
task_context = sci_req->task_context_buffer;
- task_context->task_index = scic_sds_io_tag_get_index(sci_req->io_tag);
+ task_context->task_index = ISCI_TAG_TCI(sci_req->io_tag);
switch (task_context->protocol_type) {
case SCU_TASK_CONTEXT_PROTOCOL_SMP:
scic_sds_controller_copy_task_context(scic, sci_req);
/* Add to the post_context the io tag value */
- sci_req->post_context |= scic_sds_io_tag_get_index(sci_req->io_tag);
+ sci_req->post_context |= ISCI_TAG_TCI(sci_req->io_tag);
/* Everything is good go ahead and change state */
sci_change_state(&sci_req->sm, SCI_REQ_STARTED);
SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
(scic_sds_port_get_index(sci_port) <<
SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
- scic_sds_io_tag_get_index(sci_req->io_tag));
+ ISCI_TAG_TCI(sci_req->io_tag));
} else {
/*
* Build the task context now since we have already read