linux/include/scsi/scsi_cmnd.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _SCSI_SCSI_CMND_H
#define _SCSI_SCSI_CMND_H

#include <linux/dma-mapping.h>
#include <linux/blkdev.h>
#include <linux/t10-pi.h>
#include <linux/list.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/scatterlist.h>
#include <scsi/scsi_device.h>

struct Scsi_Host;

/*
 * MAX_COMMAND_SIZE is:
 * The longest fixed-length SCSI CDB as per the SCSI standard.
 * fixed-length means: commands that their size can be determined
 * by their opcode and the CDB does not carry a length specifier, (unlike
 * the VARIABLE_LENGTH_CMD(0x7f) command). This is actually not exactly
 * true and the SCSI standard also defines extended commands and
 * vendor specific commands that can be bigger than 16 bytes. The kernel
 * will support these using the same infrastructure used for VARLEN CDB's.
 * So in effect MAX_COMMAND_SIZE means the maximum size command scsi-ml
 * supports without specifying a cmd_len by ULD's
 */
#define MAX_COMMAND_SIZE

struct scsi_data_buffer {};

/* embedded in scsi_cmnd */
struct scsi_pointer {};

/* for scmd->flags */
#define SCMD_TAGGED
#define SCMD_INITIALIZED
#define SCMD_LAST
/*
 * libata uses SCSI EH to fetch sense data for successful commands.
 * SCSI EH should not overwrite scmd->result when SCMD_FORCE_EH_SUCCESS is set.
 */
#define SCMD_FORCE_EH_SUCCESS
#define SCMD_FAIL_IF_RECOVERING
/* flags preserved across unprep / reprep */
#define SCMD_PRESERVED_FLAGS

/* for scmd->state */
#define SCMD_STATE_COMPLETE
#define SCMD_STATE_INFLIGHT

enum scsi_cmnd_submitter {} __packed;

struct scsi_cmnd {};

/* Variant of blk_mq_rq_from_pdu() that verifies the type of its argument. */
static inline struct request *scsi_cmd_to_rq(struct scsi_cmnd *scmd)
{}

/*
 * Return the driver private allocation behind the command.
 * Only works if cmd_size is set in the host template.
 */
static inline void *scsi_cmd_priv(struct scsi_cmnd *cmd)
{}

void scsi_done(struct scsi_cmnd *cmd);
void scsi_done_direct(struct scsi_cmnd *cmd);

extern void scsi_finish_command(struct scsi_cmnd *cmd);

extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
				 size_t *offset, size_t *len);
extern void scsi_kunmap_atomic_sg(void *virt);

blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd);
void scsi_free_sgtables(struct scsi_cmnd *cmd);

#ifdef CONFIG_SCSI_DMA
extern int scsi_dma_map(struct scsi_cmnd *cmd);
extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
#else /* !CONFIG_SCSI_DMA */
static inline int scsi_dma_map(struct scsi_cmnd *cmd) { return -ENOSYS; }
static inline void scsi_dma_unmap(struct scsi_cmnd *cmd) { }
#endif /* !CONFIG_SCSI_DMA */

static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd)
{}

static inline struct scatterlist *scsi_sglist(struct scsi_cmnd *cmd)
{}

static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd)
{}

static inline void scsi_set_resid(struct scsi_cmnd *cmd, unsigned int resid)
{}

static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd)
{}

#define scsi_for_each_sg(cmd, sg, nseg, __i)

static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd,
					   const void *buf, int buflen)
{}

static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd,
					 void *buf, int buflen)
{}

static inline sector_t scsi_get_sector(struct scsi_cmnd *scmd)
{}

static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
{}

static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd)
{}

/*
 * The operations below are hints that tell the controller driver how
 * to handle I/Os with DIF or similar types of protection information.
 */
enum scsi_prot_operations {};

static inline void scsi_set_prot_op(struct scsi_cmnd *scmd, unsigned char op)
{}

static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
{}

enum scsi_prot_flags {};

/*
 * The controller usually does not know anything about the target it
 * is communicating with.  However, when DIX is enabled the controller
 * must be know target type so it can verify the protection
 * information passed along with the I/O.
 */
enum scsi_prot_target_type {};

static inline void scsi_set_prot_type(struct scsi_cmnd *scmd, unsigned char type)
{}

static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd)
{}

static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd)
{}

static inline unsigned int scsi_prot_interval(struct scsi_cmnd *scmd)
{}

static inline unsigned scsi_prot_sg_count(struct scsi_cmnd *cmd)
{}

static inline struct scatterlist *scsi_prot_sglist(struct scsi_cmnd *cmd)
{}

static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
{}

#define scsi_for_each_prot_sg(cmd, sg, nseg, __i)

static inline void set_status_byte(struct scsi_cmnd *cmd, char status)
{}

static inline u8 get_status_byte(struct scsi_cmnd *cmd)
{}

static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
{}

static inline u8 get_host_byte(struct scsi_cmnd *cmd)
{}

/**
 * scsi_msg_to_host_byte() - translate message byte
 * @cmd: the SCSI command
 * @msg: the SCSI parallel message byte to translate
 *
 * Translate the SCSI parallel message byte to a matching
 * host byte setting. A message of COMMAND_COMPLETE indicates
 * a successful command execution, any other message indicate
 * an error. As the messages themselves only have a meaning
 * for the SCSI parallel protocol this function translates
 * them into a matching host byte value for SCSI EH.
 */
static inline void scsi_msg_to_host_byte(struct scsi_cmnd *cmd, u8 msg)
{}

static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
{}

extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc,
			     u8 key, u8 asc, u8 ascq);

struct request *scsi_alloc_request(struct request_queue *q, blk_opf_t opf,
				   blk_mq_req_flags_t flags);

#endif /* _SCSI_SCSI_CMND_H */