1/* SPDX-License-Identifier: GPL-2.0-only */
2/* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
3
4#ifndef _SNIC_IO_H
5#define _SNIC_IO_H
6
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 */
10
11/* SG descriptor for snic */
12struct snic_sg_desc {
13 __le64 addr;
14 __le32 len;
15 u32 _resvd;
16};
17
18struct snic_dflt_sgl {
19 struct snic_sg_desc sg_desc[SNIC_DFLT_SG_DESC_CNT];
20};
21
22struct snic_max_sgl {
23 struct snic_sg_desc sg_desc[SNIC_MAX_SG_DESC_CNT];
24};
25
26enum 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 */
32};
33
34/* Per IO internal state */
35struct snic_internal_io_state {
36 char *rqi;
37 u64 flags;
38 u32 state;
39 u32 abts_status; /* Abort completion status */
40 u32 lr_status; /* device reset completion status */
41};
42
43/* IO state machine */
44enum snic_ioreq_state {
45 SNIC_IOREQ_NOT_INITED = 0,
46 SNIC_IOREQ_PENDING,
47 SNIC_IOREQ_ABTS_PENDING,
48 SNIC_IOREQ_ABTS_COMPLETE,
49 SNIC_IOREQ_LR_PENDING,
50 SNIC_IOREQ_LR_COMPLETE,
51 SNIC_IOREQ_COMPLETE,
52};
53
54struct snic;
55struct snic_host_req;
56
57/*
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
61 */
62struct 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)*/
68 u32 tgt_id;
69
70 u32 tm_tag;
71 u8 io_cmpl:1; /* sets to 1 when fw completes IO */
72 u8 resvd[3];
73 struct scsi_cmnd *sc; /* Associated scsi cmd */
74 struct snic *snic; /* Associated snic */
75 ulong sge_va; /* Pointer to Resp Buffer */
76 u64 snsbuf_va;
77
78 struct snic_host_req *abort_req;
79 struct completion *abts_done;
80
81 struct snic_host_req *dr_req;
82 struct completion *dr_done;
83};
84
85
86#define rqi_to_req(rqi) \
87 ((struct snic_host_req *) (((struct snic_req_info *)rqi)->req))
88
89#define req_to_rqi(req) \
90 ((struct snic_req_info *) (((struct snic_host_req *)req)->hdr.init_ctx))
91
92#define req_to_sgl(req) \
93 ((struct snic_sg_desc *) (((struct snic_host_req *)req)+1))
94
95struct snic_req_info *
96snic_req_init(struct snic *, int sg_cnt);
97void snic_req_free(struct snic *, struct snic_req_info *);
98void snic_calc_io_process_time(struct snic *, struct snic_req_info *);
99void snic_pci_unmap_rsp_buf(struct snic *, struct snic_req_info *);
100struct snic_host_req *
101snic_abort_req_init(struct snic *, struct snic_req_info *);
102struct snic_host_req *
103snic_dr_req_init(struct snic *, struct snic_req_info *);
104#endif /* _SNIC_IO_H */
105

source code of linux/drivers/scsi/snic/snic_io.h