2 * Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 #define SNIC_DFLT_SG_DESC_CNT 32 /* Default descriptors for sgl */
22 #define SNIC_MAX_SG_DESC_CNT 60 /* Max descriptor for sgl */
23 #define SNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */
25 /* SG descriptor for snic */
32 struct snic_dflt_sgl
{
33 struct snic_sg_desc sg_desc
[SNIC_DFLT_SG_DESC_CNT
];
37 struct snic_sg_desc sg_desc
[SNIC_MAX_SG_DESC_CNT
];
40 enum snic_req_cache_type
{
41 SNIC_REQ_CACHE_DFLT_SGL
= 0, /* cache with default size sgl */
42 SNIC_REQ_CACHE_MAX_SGL
, /* cache with max size sgl */
43 SNIC_REQ_TM_CACHE
, /* cache for task mgmt reqs contains
44 snic_host_req objects only*/
45 SNIC_REQ_MAX_CACHES
/* number of sgl caches */
48 /* Per IO internal state */
49 struct snic_internal_io_state
{
53 u32 abts_status
; /* Abort completion status */
54 u32 lr_status
; /* device reset completion status */
57 /* IO state machine */
58 enum snic_ioreq_state
{
59 SNIC_IOREQ_NOT_INITED
= 0,
61 SNIC_IOREQ_ABTS_PENDING
,
62 SNIC_IOREQ_ABTS_COMPLETE
,
63 SNIC_IOREQ_LR_PENDING
,
64 SNIC_IOREQ_LR_COMPLETE
,
72 * snic_req_info : Contains info about IO, one per scsi command.
73 * Notes: Make sure that the structure is aligned to 16 B
74 * this helps in easy access to snic_req_info from snic_host_req
76 struct snic_req_info
{
77 struct list_head list
;
78 struct snic_host_req
*req
;
79 u64 start_time
; /* start time in jiffies */
80 u16 rq_pool_type
; /* noticion of request pool type */
81 u16 req_len
; /* buf len passing to fw (req + sgl)*/
85 u8 io_cmpl
:1; /* sets to 1 when fw completes IO */
87 struct scsi_cmnd
*sc
; /* Associated scsi cmd */
88 struct snic
*snic
; /* Associated snic */
89 ulong sge_va
; /* Pointer to Resp Buffer */
92 struct snic_host_req
*abort_req
;
93 struct completion
*abts_done
;
95 struct snic_host_req
*dr_req
;
96 struct completion
*dr_done
;
100 #define rqi_to_req(rqi) \
101 ((struct snic_host_req *) (((struct snic_req_info *)rqi)->req))
103 #define req_to_rqi(req) \
104 ((struct snic_req_info *) (((struct snic_host_req *)req)->hdr.init_ctx))
106 #define req_to_sgl(req) \
107 ((struct snic_sg_desc *) (((struct snic_host_req *)req)+1))
109 struct snic_req_info
*
110 snic_req_init(struct snic
*, int sg_cnt
);
111 void snic_req_free(struct snic
*, struct snic_req_info
*);
112 void snic_calc_io_process_time(struct snic
*, struct snic_req_info
*);
113 void snic_pci_unmap_rsp_buf(struct snic
*, struct snic_req_info
*);
114 struct snic_host_req
*
115 snic_abort_req_init(struct snic
*, struct snic_req_info
*);
116 struct snic_host_req
*
117 snic_dr_req_init(struct snic
*, struct snic_req_info
*);
118 #endif /* _SNIC_IO_H */