-
-/**
- * scic_controller_allocate_io_tag() - This method will allocate a tag from the
- * pool of free IO tags. Direct allocation of IO tags by the SCI Core user
- * is optional. The scic_controller_start_io() method will allocate an IO
- * tag if this method is not utilized and the tag is not supplied to the IO
- * construct routine. Direct allocation of IO tags may provide additional
- * performance improvements in environments capable of supporting this usage
- * model. Additionally, direct allocation of IO tags also provides
- * additional flexibility to the SCI Core user. Specifically, the user may
- * retain IO tags across the lives of multiple IO requests.
- * @controller: the handle to the controller object for which to allocate the
- * tag.
- *
- * IO tags are a protected resource. It is incumbent upon the SCI Core user to
- * ensure that each of the methods that may allocate or free available IO tags
- * are handled in a mutually exclusive manner. This method is one of said
- * methods requiring proper critical code section protection (e.g. semaphore,
- * spin-lock, etc.). An unsigned integer representing an available IO tag.
- * SCI_CONTROLLER_INVALID_IO_TAG This value is returned if there are no
- * currently available tags to be allocated. All return other values indicate a
- * legitimate tag.
- */
-u16 scic_controller_allocate_io_tag(struct scic_sds_controller *scic)
-{
- struct isci_host *ihost = scic_to_ihost(scic);
-
- if (isci_tci_space(ihost)) {
- u16 tci = isci_tci_alloc(ihost);
- u8 seq = scic->io_request_sequence[tci];
-
- return ISCI_TAG(seq, tci);
- }
-
- return SCI_CONTROLLER_INVALID_IO_TAG;
-}
-
-/**
- * scic_controller_free_io_tag() - This method will free an IO tag to the pool
- * of free IO tags. This method provides the SCI Core user more flexibility
- * with regards to IO tags. The user may desire to keep an IO tag after an
- * IO request has completed, because they plan on re-using the tag for a
- * subsequent IO request. This method is only legal if the tag was
- * allocated via scic_controller_allocate_io_tag().
- * @controller: This parameter specifies the handle to the controller object
- * for which to free/return the tag.
- * @io_tag: This parameter represents the tag to be freed to the pool of
- * available tags.
- *
- * - IO tags are a protected resource. It is incumbent upon the SCI Core user
- * to ensure that each of the methods that may allocate or free available IO
- * tags are handled in a mutually exclusive manner. This method is one of said
- * methods requiring proper critical code section protection (e.g. semaphore,
- * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
- * Core user, using the scic_controller_allocate_io_tag() method, then it is
- * the responsibility of the caller to invoke this method to free the tag. This
- * method returns an indication of whether the tag was successfully put back
- * (freed) to the pool of available tags. SCI_SUCCESS This return value
- * indicates the tag was successfully placed into the pool of available IO
- * tags. SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied tag
- * is not a valid IO tag value.
- */
-enum sci_status scic_controller_free_io_tag(struct scic_sds_controller *scic,
- u16 io_tag)
-{
- struct isci_host *ihost = scic_to_ihost(scic);
- 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 (seq == scic->io_request_sequence[tci]) {
- scic->io_request_sequence[tci] = (seq+1) & (SCI_MAX_SEQ-1);
-
- isci_tci_free(ihost, ISCI_TAG_TCI(io_tag));
-
- return SCI_SUCCESS;
- }
- return SCI_FAILURE_INVALID_IO_TAG;
-}