1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015-2017  QLogic Corporation
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and /or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef __STORAGE_COMMON__
34 #define __STORAGE_COMMON__
35 
36 #define NUM_OF_CMDQS_CQS (NUM_OF_GLOBAL_QUEUES / 2)
37 #define BDQ_NUM_RESOURCES (4)
38 
39 #define BDQ_ID_RQ                        (0)
40 #define BDQ_ID_IMM_DATA          (1)
41 #define BDQ_NUM_IDS          (2)
42 
43 #define SCSI_NUM_SGES_SLOW_SGL_THR      8
44 
45 #define BDQ_MAX_EXTERNAL_RING_SIZE (1 << 15)
46 
47 struct scsi_bd {
48 	struct regpair address;
49 	struct regpair opaque;
50 };
51 
52 struct scsi_bdq_ram_drv_data {
53 	__le16 external_producer;
54 	__le16 reserved0[3];
55 };
56 
57 struct scsi_sge {
58 	struct regpair sge_addr;
59 	__le32 sge_len;
60 	__le32 reserved;
61 };
62 
63 struct scsi_cached_sges {
64 	struct scsi_sge sge[4];
65 };
66 
67 struct scsi_drv_cmdq {
68 	__le16 cmdq_cons;
69 	__le16 reserved0;
70 	__le32 reserved1;
71 };
72 
73 struct scsi_init_func_params {
74 	__le16 num_tasks;
75 	u8 log_page_size;
76 	u8 debug_mode;
77 	u8 reserved2[12];
78 };
79 
80 struct scsi_init_func_queues {
81 	struct regpair glbl_q_params_addr;
82 	__le16 rq_buffer_size;
83 	__le16 cq_num_entries;
84 	__le16 cmdq_num_entries;
85 	u8 bdq_resource_id;
86 	u8 q_validity;
87 #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_MASK        0x1
88 #define SCSI_INIT_FUNC_QUEUES_RQ_VALID_SHIFT       0
89 #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_MASK  0x1
90 #define SCSI_INIT_FUNC_QUEUES_IMM_DATA_VALID_SHIFT 1
91 #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_MASK       0x1
92 #define SCSI_INIT_FUNC_QUEUES_CMD_VALID_SHIFT      2
93 #define SCSI_INIT_FUNC_QUEUES_RESERVED_VALID_MASK  0x1F
94 #define SCSI_INIT_FUNC_QUEUES_RESERVED_VALID_SHIFT 3
95 	u8 num_queues;
96 	u8 queue_relative_offset;
97 	u8 cq_sb_pi;
98 	u8 cmdq_sb_pi;
99 	__le16 cq_cmdq_sb_num_arr[NUM_OF_CMDQS_CQS];
100 	__le16 reserved0;
101 	u8 bdq_pbl_num_entries[BDQ_NUM_IDS];
102 	struct regpair bdq_pbl_base_address[BDQ_NUM_IDS];
103 	__le16 bdq_xoff_threshold[BDQ_NUM_IDS];
104 	__le16 bdq_xon_threshold[BDQ_NUM_IDS];
105 	__le16 cmdq_xoff_threshold;
106 	__le16 cmdq_xon_threshold;
107 	__le32 reserved1;
108 };
109 
110 struct scsi_ram_per_bdq_resource_drv_data {
111 	struct scsi_bdq_ram_drv_data drv_data_per_bdq_id[BDQ_NUM_IDS];
112 };
113 
114 enum scsi_sgl_mode {
115 	SCSI_TX_SLOW_SGL,
116 	SCSI_FAST_SGL,
117 	MAX_SCSI_SGL_MODE
118 };
119 
120 struct scsi_sgl_params {
121 	struct regpair sgl_addr;
122 	__le32 sgl_total_length;
123 	__le32 sge_offset;
124 	__le16 sgl_num_sges;
125 	u8 sgl_index;
126 	u8 reserved;
127 };
128 
129 struct scsi_terminate_extra_params {
130 	__le16 unsolicited_cq_count;
131 	__le16 cmdq_count;
132 	u8 reserved[4];
133 };
134 
135 #endif /* __STORAGE_COMMON__ */
136