1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
7 #define SNIC_DFLT_SG_DESC_CNT 32 /* Default descriptors for sgl */
8 #define SNIC_MAX_SG_DESC_CNT 60 /* Max descriptor for sgl */
9 #define SNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */
11 /* SG descriptor for snic */
18 struct snic_dflt_sgl
{
19 struct snic_sg_desc sg_desc
[SNIC_DFLT_SG_DESC_CNT
];
23 struct snic_sg_desc sg_desc
[SNIC_MAX_SG_DESC_CNT
];
26 enum snic_req_cache_type
{
27 SNIC_REQ_CACHE_DFLT_SGL
= 0, /* cache with default size sgl */
28 SNIC_REQ_CACHE_MAX_SGL
, /* cache with max size sgl */
29 SNIC_REQ_TM_CACHE
, /* cache for task mgmt reqs contains
30 snic_host_req objects only*/
31 SNIC_REQ_MAX_CACHES
/* number of sgl caches */
34 /* Per IO internal state */
35 struct snic_internal_io_state
{
39 u32 abts_status
; /* Abort completion status */
40 u32 lr_status
; /* device reset completion status */
43 /* IO state machine */
44 enum snic_ioreq_state
{
45 SNIC_IOREQ_NOT_INITED
= 0,
47 SNIC_IOREQ_ABTS_PENDING
,
48 SNIC_IOREQ_ABTS_COMPLETE
,
49 SNIC_IOREQ_LR_PENDING
,
50 SNIC_IOREQ_LR_COMPLETE
,
58 * snic_req_info : Contains info about IO, one per scsi command.
59 * Notes: Make sure that the structure is aligned to 16 B
60 * this helps in easy access to snic_req_info from snic_host_req
62 struct snic_req_info
{
63 struct list_head list
;
64 struct snic_host_req
*req
;
65 u64 start_time
; /* start time in jiffies */
66 u16 rq_pool_type
; /* noticion of request pool type */
67 u16 req_len
; /* buf len passing to fw (req + sgl)*/
71 u8 io_cmpl
:1; /* sets to 1 when fw completes IO */
73 struct scsi_cmnd
*sc
; /* Associated scsi cmd */
74 struct snic
*snic
; /* Associated snic */
75 ulong sge_va
; /* Pointer to Resp Buffer */
78 struct snic_host_req
*abort_req
;
79 struct completion
*abts_done
;
81 struct snic_host_req
*dr_req
;
82 struct completion
*dr_done
;
86 #define rqi_to_req(rqi) \
87 ((struct snic_host_req *) (((struct snic_req_info *)rqi)->req))
89 #define req_to_rqi(req) \
90 ((struct snic_req_info *) (((struct snic_host_req *)req)->hdr.init_ctx))
92 #define req_to_sgl(req) \
93 ((struct snic_sg_desc *) (((struct snic_host_req *)req)+1))
95 struct snic_req_info
*
96 snic_req_init(struct snic
*, int sg_cnt
);
97 void snic_req_free(struct snic
*, struct snic_req_info
*);
98 void snic_calc_io_process_time(struct snic
*, struct snic_req_info
*);
99 void snic_pci_unmap_rsp_buf(struct snic
*, struct snic_req_info
*);
100 struct snic_host_req
*
101 snic_abort_req_init(struct snic
*, struct snic_req_info
*);
102 struct snic_host_req
*
103 snic_dr_req_init(struct snic
*, struct snic_req_info
*);
104 #endif /* _SNIC_IO_H */