Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  linux/drivers/acorn/scsi/queue.h: queue handling
0004  *
0005  *  Copyright (C) 1997 Russell King
0006  */
0007 #ifndef QUEUE_H
0008 #define QUEUE_H
0009 
0010 typedef struct {
0011     struct list_head head;
0012     struct list_head free;
0013     spinlock_t queue_lock;
0014     void *alloc;            /* start of allocated mem */
0015 } Queue_t;
0016 
0017 /*
0018  * Function: void queue_initialise (Queue_t *queue)
0019  * Purpose : initialise a queue
0020  * Params  : queue - queue to initialise
0021  */
0022 extern int queue_initialise (Queue_t *queue);
0023 
0024 /*
0025  * Function: void queue_free (Queue_t *queue)
0026  * Purpose : free a queue
0027  * Params  : queue - queue to free
0028  */
0029 extern void queue_free (Queue_t *queue);
0030 
0031 /*
0032  * Function: struct scsi_cmnd *queue_remove (queue)
0033  * Purpose : removes first SCSI command from a queue
0034  * Params  : queue   - queue to remove command from
0035  * Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available
0036  */
0037 extern struct scsi_cmnd *queue_remove (Queue_t *queue);
0038 
0039 /*
0040  * Function: struct scsi_cmnd *queue_remove_exclude_ref (queue, exclude)
0041  * Purpose : remove a SCSI command from a queue
0042  * Params  : queue   - queue to remove command from
0043  *       exclude - array of busy LUNs
0044  * Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available
0045  */
0046 extern struct scsi_cmnd *queue_remove_exclude(Queue_t *queue,
0047                           unsigned long *exclude);
0048 
0049 #define queue_add_cmd_ordered(queue,SCpnt) \
0050     __queue_add(queue,SCpnt,(SCpnt)->cmnd[0] == REQUEST_SENSE)
0051 #define queue_add_cmd_tail(queue,SCpnt) \
0052     __queue_add(queue,SCpnt,0)
0053 /*
0054  * Function: int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
0055  * Purpose : Add a new command onto a queue
0056  * Params  : queue - destination queue
0057  *       SCpnt - command to add
0058  *       head  - add command to head of queue
0059  * Returns : 0 on error, !0 on success
0060  */
0061 extern int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head);
0062 
0063 /*
0064  * Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
0065  * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
0066  * Params  : queue  - queue to remove command from
0067  *       target - target that we want
0068  *       lun    - lun on device
0069  *       tag    - tag on device
0070  * Returns : struct scsi_cmnd if successful, or NULL if no command satisfies requirements
0071  */
0072 extern struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target,
0073                         int lun, int tag);
0074 
0075 /*
0076  * Function: queue_remove_all_target(queue, target)
0077  * Purpose : remove all SCSI commands from the queue for a specified target
0078  * Params  : queue  - queue to remove command from
0079  *           target - target device id
0080  * Returns : nothing
0081  */
0082 extern void queue_remove_all_target(Queue_t *queue, int target);
0083 
0084 /*
0085  * Function: int queue_probetgtlun (queue, target, lun)
0086  * Purpose : check to see if we have a command in the queue for the specified
0087  *       target/lun.
0088  * Params  : queue  - queue to look in
0089  *       target - target we want to probe
0090  *       lun    - lun on target
0091  * Returns : 0 if not found, != 0 if found
0092  */
0093 extern int queue_probetgtlun (Queue_t *queue, int target, int lun);
0094 
0095 /*
0096  * Function: int queue_remove_cmd (Queue_t *queue, struct scsi_cmnd *SCpnt)
0097  * Purpose : remove a specific command from the queues
0098  * Params  : queue - queue to look in
0099  *       SCpnt - command to find
0100  * Returns : 0 if not found
0101  */
0102 int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt);
0103 
0104 #endif /* QUEUE_H */