Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* Copyright 2014 Cisco Systems, Inc.  All rights reserved. */
0003 
0004 #ifndef _SNIC_IO_H
0005 #define _SNIC_IO_H
0006 
0007 #define SNIC_DFLT_SG_DESC_CNT   32  /* Default descriptors for sgl */
0008 #define SNIC_MAX_SG_DESC_CNT    60  /* Max descriptor for sgl */
0009 #define SNIC_SG_DESC_ALIGN  16  /* Descriptor address alignment */
0010 
0011 /* SG descriptor for snic */
0012 struct snic_sg_desc {
0013     __le64 addr;
0014     __le32 len;
0015     u32 _resvd;
0016 };
0017 
0018 struct snic_dflt_sgl {
0019     struct snic_sg_desc sg_desc[SNIC_DFLT_SG_DESC_CNT];
0020 };
0021 
0022 struct snic_max_sgl {
0023     struct snic_sg_desc sg_desc[SNIC_MAX_SG_DESC_CNT];
0024 };
0025 
0026 enum snic_req_cache_type {
0027     SNIC_REQ_CACHE_DFLT_SGL = 0,    /* cache with default size sgl */
0028     SNIC_REQ_CACHE_MAX_SGL,     /* cache with max size sgl */
0029     SNIC_REQ_TM_CACHE,      /* cache for task mgmt reqs contains
0030                        snic_host_req objects only*/
0031     SNIC_REQ_MAX_CACHES     /* number of sgl caches */
0032 };
0033 
0034 /* Per IO internal state */
0035 struct snic_internal_io_state {
0036     char    *rqi;
0037     u64 flags;
0038     u32 state;
0039     u32 abts_status;    /* Abort completion status */
0040     u32 lr_status;  /* device reset completion status */
0041 };
0042 
0043 /* IO state machine */
0044 enum snic_ioreq_state {
0045     SNIC_IOREQ_NOT_INITED = 0,
0046     SNIC_IOREQ_PENDING,
0047     SNIC_IOREQ_ABTS_PENDING,
0048     SNIC_IOREQ_ABTS_COMPLETE,
0049     SNIC_IOREQ_LR_PENDING,
0050     SNIC_IOREQ_LR_COMPLETE,
0051     SNIC_IOREQ_COMPLETE,
0052 };
0053 
0054 struct snic;
0055 struct snic_host_req;
0056 
0057 /*
0058  * snic_req_info : Contains info about IO, one per scsi command.
0059  * Notes: Make sure that the structure is aligned to 16 B
0060  * this helps in easy access to snic_req_info from snic_host_req
0061  */
0062 struct snic_req_info {
0063     struct list_head list;
0064     struct snic_host_req *req;
0065     u64 start_time;     /* start time in jiffies */
0066     u16 rq_pool_type;       /* noticion of request pool type */
0067     u16 req_len;        /* buf len passing to fw (req + sgl)*/
0068     u32 tgt_id;
0069 
0070     u32 tm_tag;
0071     u8  io_cmpl:1;      /* sets to 1 when fw completes IO */
0072     u8  resvd[3];
0073     struct scsi_cmnd *sc;       /* Associated scsi cmd */
0074     struct snic *snic;      /* Associated snic */
0075     ulong   sge_va;         /* Pointer to Resp Buffer */
0076     u64 snsbuf_va;
0077 
0078     struct snic_host_req *abort_req;
0079     struct completion *abts_done;
0080 
0081     struct snic_host_req *dr_req;
0082     struct completion *dr_done;
0083 };
0084 
0085 
0086 #define rqi_to_req(rqi) \
0087     ((struct snic_host_req *) (((struct snic_req_info *)rqi)->req))
0088 
0089 #define req_to_rqi(req) \
0090     ((struct snic_req_info *) (((struct snic_host_req *)req)->hdr.init_ctx))
0091 
0092 #define req_to_sgl(req) \
0093     ((struct snic_sg_desc *) (((struct snic_host_req *)req)+1))
0094 
0095 struct snic_req_info *
0096 snic_req_init(struct snic *, int sg_cnt);
0097 void snic_req_free(struct snic *, struct snic_req_info *);
0098 void snic_calc_io_process_time(struct snic *, struct snic_req_info *);
0099 void snic_pci_unmap_rsp_buf(struct snic *, struct snic_req_info *);
0100 struct snic_host_req *
0101 snic_abort_req_init(struct snic *, struct snic_req_info *);
0102 struct snic_host_req *
0103 snic_dr_req_init(struct snic *, struct snic_req_info *);
0104 #endif /* _SNIC_IO_H */