2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef __STORAGE_COMMON__
33 #define __STORAGE_COMMON__
34 /*********************/
36 /*********************/
39 #define NUM_OF_CMDQS_CQS (NUM_OF_GLOBAL_QUEUES / 2)
40 // Each Resource ID is one-one-valued mapped by the driver to a BDQ Resource ID (for instance per port)
41 #define BDQ_NUM_RESOURCES (4)
43 // ID 0 : RQ, ID 1 : IMMEDIATE_DATA:
45 #define BDQ_ID_IMM_DATA (1)
46 #define BDQ_NUM_IDS (2)
48 #define SCSI_NUM_SGES_SLOW_SGL_THR 8
50 #define BDQ_MAX_EXTERNAL_RING_SIZE (1<<15)
56 * SCSI buffer descriptor
60 struct regpair address /* Physical Address of buffer */;
61 struct regpair opaque /* Driver Metadata (preferably Virtual Address of buffer) */;
68 struct scsi_bdq_ram_drv_data
70 __le16 external_producer /* BDQ External Producer; updated by driver when it loads BDs to External Ring */;
80 struct regpair sge_addr /* SGE address */;
81 __le32 sge_len /* SGE length */;
88 struct scsi_cached_sges
90 struct scsi_sge sge[4] /* Cached SGEs section */;
95 * Scsi Drv CMDQ struct
99 __le16 cmdq_cons /* CMDQ consumer - updated by driver when CMDQ is consumed */;
106 * Common SCSI init params passed by driver to FW in function init ramrod
108 struct scsi_init_func_params
110 __le16 num_tasks /* Number of tasks in global task list */;
111 u8 log_page_size /* log of page size value */;
112 u8 debug_mode /* Use iscsi_debug_mode enum */;
118 * SCSI RQ/CQ/CMDQ firmware function init parameters
120 struct scsi_init_func_queues
122 struct regpair glbl_q_params_addr /* Global Qs (CQ/RQ/CMDQ) params host address */;
123 __le16 rq_buffer_size /* The buffer size of RQ BDQ */;
124 __le16 cq_num_entries /* CQ num entries */;
125 __le16 cmdq_num_entries /* CMDQ num entries */;
126 u8 bdq_resource_id /* Each function-init Ramrod maps its funciton ID to a BDQ function ID, each BDQ function ID contains per-BDQ-ID BDQs */;
128 #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_MASK 0x1
129 #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_SHIFT 0
130 #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_MASK 0x1
131 #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_SHIFT 1
132 #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_MASK 0x1
133 #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_SHIFT 2
134 #define SCSI_INIT_FUNC_QUEUES_RESERVED_VALID_MASK 0x1F
135 #define SCSI_INIT_FUNC_QUEUES_RESERVED_VALID_SHIFT 3
136 u8 num_queues /* Number of continuous global queues used */;
137 u8 queue_relative_offset /* offset of continuous global queues used */;
138 u8 cq_sb_pi /* Protocol Index of CQ in status block (CQ consumer) */;
139 u8 cmdq_sb_pi /* Protocol Index of CMDQ in status block (CMDQ consumer) */;
140 __le16 cq_cmdq_sb_num_arr[NUM_OF_CMDQS_CQS] /* CQ/CMDQ status block number array */;
141 __le16 reserved0 /* reserved */;
142 u8 bdq_pbl_num_entries[BDQ_NUM_IDS] /* Per BDQ ID, the PBL page size (number of entries in PBL) */;
143 struct regpair bdq_pbl_base_address[BDQ_NUM_IDS] /* Per BDQ ID, the PBL page Base Address */;
144 __le16 bdq_xoff_threshold[BDQ_NUM_IDS] /* BDQ XOFF threshold - when number of entries will be below that TH, it will send XOFF */;
145 __le16 bdq_xon_threshold[BDQ_NUM_IDS] /* BDQ XON threshold - when number of entries will be above that TH, it will send XON */;
146 __le16 cmdq_xoff_threshold /* CMDQ XOFF threshold - when number of entries will be below that TH, it will send XOFF */;
147 __le16 cmdq_xon_threshold /* CMDQ XON threshold - when number of entries will be above that TH, it will send XON */;
148 __le32 reserved1 /* reserved */;
153 * Scsi Drv BDQ Data struct (2 BDQ IDs: 0 - RQ, 1 - Immediate Data)
155 struct scsi_ram_per_bdq_resource_drv_data
157 struct scsi_bdq_ram_drv_data drv_data_per_bdq_id[BDQ_NUM_IDS] /* External ring data */;
167 SCSI_TX_SLOW_SGL /* Slow-SGL: More than SCSI_NUM_SGES_SLOW_SGL_THR SGEs and there is at least 1 middle SGE than is smaller than a page size. May be only at TX */,
168 SCSI_FAST_SGL /* Fast SGL: Less than SCSI_NUM_SGES_SLOW_SGL_THR SGEs or all middle SGEs are at least a page size */,
174 * SCSI SGL parameters
176 struct scsi_sgl_params
178 struct regpair sgl_addr /* SGL base address */;
179 __le32 sgl_total_length /* SGL total legnth (bytes) */;
180 __le32 sge_offset /* Offset in SGE (bytes) */;
181 __le16 sgl_num_sges /* Number of SGLs sges */;
182 u8 sgl_index /* SGL index */;
188 * SCSI terminate connection params
190 struct scsi_terminate_extra_params
192 __le16 unsolicited_cq_count /* Counts number of CQ placements done due to arrival of unsolicited packets on this connection */;
193 __le16 cmdq_count /* Counts number of CMDQ placements on this connection */;
197 #endif /* __STORAGE_COMMON__ */