1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, v.1, (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2014-2017 Cavium, Inc. 24 * The contents of this file are subject to the terms of the Common Development 25 * and Distribution License, v.1, (the "License"). 26 27 * You may not use this file except in compliance with the License. 28 29 * You can obtain a copy of the License at available 30 * at http://opensource.org/licenses/CDDL-1.0 31 32 * See the License for the specific language governing permissions and 33 * limitations under the License. 34 */ 35 36 #ifndef __STORAGE_COMMON__ 37 #define __STORAGE_COMMON__ 38 /*********************/ 39 /* SCSI CONSTANTS */ 40 /*********************/ 41 42 43 #define NUM_OF_CMDQS_CQS (NUM_OF_GLOBAL_QUEUES / 2) 44 // Each Resource ID is one-one-valued mapped by the driver to a BDQ Resource ID (for instance per port) 45 #define BDQ_NUM_RESOURCES (4) 46 47 // ID 0 : RQ, ID 1 : IMMEDIATE_DATA: 48 #define BDQ_ID_RQ (0) 49 #define BDQ_ID_IMM_DATA (1) 50 #define BDQ_NUM_IDS (2) 51 52 #define SCSI_NUM_SGES_SLOW_SGL_THR 8 53 54 #define BDQ_MAX_EXTERNAL_RING_SIZE (1<<15) 55 56 57 58 59 /* 60 * SCSI buffer descriptor 61 */ 62 struct scsi_bd 63 { 64 struct regpair address /* Physical Address of buffer */; 65 struct regpair opaque /* Driver Metadata (preferably Virtual Address of buffer) */; 66 }; 67 68 69 /* 70 * Scsi Drv BDQ struct 71 */ 72 struct scsi_bdq_ram_drv_data 73 { 74 __le16 external_producer /* BDQ External Producer; updated by driver when it loads BDs to External Ring */; 75 __le16 reserved0[3]; 76 }; 77 78 79 /* 80 * SCSI SGE entry 81 */ 82 struct scsi_sge 83 { 84 struct regpair sge_addr /* SGE address */; 85 __le32 sge_len /* SGE length */; 86 __le32 reserved; 87 }; 88 89 /* 90 * Cached SGEs section 91 */ 92 struct scsi_cached_sges 93 { 94 struct scsi_sge sge[4] /* Cached SGEs section */; 95 }; 96 97 98 /* 99 * Scsi Drv CMDQ struct 100 */ 101 struct scsi_drv_cmdq 102 { 103 __le16 cmdq_cons /* CMDQ consumer - updated by driver when CMDQ is consumed */; 104 __le16 reserved0; 105 __le32 reserved1; 106 }; 107 108 109 /* 110 * Common SCSI init params passed by driver to FW in function init ramrod 111 */ 112 struct scsi_init_func_params 113 { 114 __le16 num_tasks /* Number of tasks in global task list */; 115 u8 log_page_size /* log of page size value */; 116 u8 debug_mode /* Use iscsi_debug_mode enum */; 117 u8 reserved2[12]; 118 }; 119 120 121 /* 122 * SCSI RQ/CQ/CMDQ firmware function init parameters 123 */ 124 struct scsi_init_func_queues 125 { 126 struct regpair glbl_q_params_addr /* Global Qs (CQ/RQ/CMDQ) params host address */; 127 __le16 rq_buffer_size /* The buffer size of RQ BDQ */; 128 __le16 cq_num_entries /* CQ num entries */; 129 __le16 cmdq_num_entries /* CMDQ num entries */; 130 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 */; 131 u8 q_validity; 132 #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_MASK 0x1 133 #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_SHIFT 0 134 #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_MASK 0x1 135 #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_SHIFT 1 136 #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_MASK 0x1 137 #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_SHIFT 2 138 #define SCSI_INIT_FUNC_QUEUES_RESERVED_VALID_MASK 0x1F 139 #define SCSI_INIT_FUNC_QUEUES_RESERVED_VALID_SHIFT 3 140 u8 num_queues /* Number of continuous global queues used */; 141 u8 queue_relative_offset /* offset of continuous global queues used */; 142 u8 cq_sb_pi /* Protocol Index of CQ in status block (CQ consumer) */; 143 u8 cmdq_sb_pi /* Protocol Index of CMDQ in status block (CMDQ consumer) */; 144 __le16 cq_cmdq_sb_num_arr[NUM_OF_CMDQS_CQS] /* CQ/CMDQ status block number array */; 145 __le16 reserved0 /* reserved */; 146 u8 bdq_pbl_num_entries[BDQ_NUM_IDS] /* Per BDQ ID, the PBL page size (number of entries in PBL) */; 147 struct regpair bdq_pbl_base_address[BDQ_NUM_IDS] /* Per BDQ ID, the PBL page Base Address */; 148 __le16 bdq_xoff_threshold[BDQ_NUM_IDS] /* BDQ XOFF threshold - when number of entries will be below that TH, it will send XOFF */; 149 __le16 bdq_xon_threshold[BDQ_NUM_IDS] /* BDQ XON threshold - when number of entries will be above that TH, it will send XON */; 150 __le16 cmdq_xoff_threshold /* CMDQ XOFF threshold - when number of entries will be below that TH, it will send XOFF */; 151 __le16 cmdq_xon_threshold /* CMDQ XON threshold - when number of entries will be above that TH, it will send XON */; 152 __le32 reserved1 /* reserved */; 153 }; 154 155 156 /* 157 * Scsi Drv BDQ Data struct (2 BDQ IDs: 0 - RQ, 1 - Immediate Data) 158 */ 159 struct scsi_ram_per_bdq_resource_drv_data 160 { 161 struct scsi_bdq_ram_drv_data drv_data_per_bdq_id[BDQ_NUM_IDS] /* External ring data */; 162 }; 163 164 165 166 /* 167 * SCSI SGL types 168 */ 169 enum scsi_sgl_mode 170 { 171 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 */, 172 SCSI_FAST_SGL /* Fast SGL: Less than SCSI_NUM_SGES_SLOW_SGL_THR SGEs or all middle SGEs are at least a page size */, 173 MAX_SCSI_SGL_MODE 174 }; 175 176 177 /* 178 * SCSI SGL parameters 179 */ 180 struct scsi_sgl_params 181 { 182 struct regpair sgl_addr /* SGL base address */; 183 __le32 sgl_total_length /* SGL total legnth (bytes) */; 184 __le32 sge_offset /* Offset in SGE (bytes) */; 185 __le16 sgl_num_sges /* Number of SGLs sges */; 186 u8 sgl_index /* SGL index */; 187 u8 reserved; 188 }; 189 190 191 /* 192 * SCSI terminate connection params 193 */ 194 struct scsi_terminate_extra_params 195 { 196 __le16 unsolicited_cq_count /* Counts number of CQ placements done due to arrival of unsolicited packets on this connection */; 197 __le16 cmdq_count /* Counts number of CMDQ placements on this connection */; 198 u8 reserved[4]; 199 }; 200 201 #endif /* __STORAGE_COMMON__ */ 202