xref: /openbmc/linux/drivers/scsi/be2iscsi/be_mgmt.h (revision f3505013)
1 /**
2  * Copyright (C) 2005 - 2016 Broadcom
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation.  The full GNU General
8  * Public License is included in this distribution in the file called COPYING.
9  *
10  * Written by: Jayamohan Kallickal (jayamohan.kallickal@broadcom.com)
11  *
12  * Contact Information:
13  * linux-drivers@broadcom.com
14  *
15  * Emulex
16  * 3333 Susan Street
17  * Costa Mesa, CA 92626
18  */
19 
20 #ifndef _BEISCSI_MGMT_
21 #define _BEISCSI_MGMT_
22 
23 #include <scsi/scsi_bsg_iscsi.h>
24 #include "be_iscsi.h"
25 #include "be_main.h"
26 
27 #define IP_ACTION_ADD	0x01
28 #define IP_ACTION_DEL	0x02
29 
30 #define IP_V6_LEN	16
31 #define IP_V4_LEN	4
32 
33 /* UE Status and Mask register */
34 #define PCICFG_UE_STATUS_LOW            0xA0
35 #define PCICFG_UE_STATUS_HIGH           0xA4
36 #define PCICFG_UE_STATUS_MASK_LOW       0xA8
37 #define PCICFG_UE_STATUS_MASK_HI        0xAC
38 
39 /**
40  * Pseudo amap definition in which each bit of the actual structure is defined
41  * as a byte: used to calculate offset/shift/mask of each field
42  */
43 struct amap_mcc_sge {
44 	u8 pa_lo[32];		/* dword 0 */
45 	u8 pa_hi[32];		/* dword 1 */
46 	u8 length[32];		/* DWORD 2 */
47 } __packed;
48 
49 /**
50  * Pseudo amap definition in which each bit of the actual structure is defined
51  * as a byte: used to calculate offset/shift/mask of each field
52  */
53 struct amap_mcc_wrb_payload {
54 	union {
55 		struct amap_mcc_sge sgl[19];
56 		u8 embedded[59 * 32];	/* DWORDS 57 to 115 */
57 	} u;
58 } __packed;
59 
60 /**
61  * Pseudo amap definition in which each bit of the actual structure is defined
62  * as a byte: used to calculate offset/shift/mask of each field
63  */
64 struct amap_mcc_wrb {
65 	u8 embedded;		/* DWORD 0 */
66 	u8 rsvd0[2];		/* DWORD 0 */
67 	u8 sge_count[5];	/* DWORD 0 */
68 	u8 rsvd1[16];		/* DWORD 0 */
69 	u8 special[8];		/* DWORD 0 */
70 	u8 payload_length[32];
71 	u8 tag[64];		/* DWORD 2 */
72 	u8 rsvd2[32];		/* DWORD 4 */
73 	struct amap_mcc_wrb_payload payload;
74 };
75 
76 struct mcc_sge {
77 	u32 pa_lo;		/* dword 0 */
78 	u32 pa_hi;		/* dword 1 */
79 	u32 length;		/* DWORD 2 */
80 } __packed;
81 
82 struct mcc_wrb_payload {
83 	union {
84 		struct mcc_sge sgl[19];
85 		u32 embedded[59];	/* DWORDS 57 to 115 */
86 	} u;
87 } __packed;
88 
89 #define MCC_WRB_EMBEDDED_MASK                0x00000001
90 
91 struct mcc_wrb {
92 	u32 dw[0];		/* DWORD 0 */
93 	u32 payload_length;
94 	u32 tag[2];		/* DWORD 2 */
95 	u32 rsvd2[1];		/* DWORD 4 */
96 	struct mcc_wrb_payload payload;
97 };
98 
99 int mgmt_open_connection(struct beiscsi_hba *phba,
100 			 struct sockaddr *dst_addr,
101 			 struct beiscsi_endpoint *beiscsi_ep,
102 			 struct be_dma_mem *nonemb_cmd);
103 
104 unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
105 				     unsigned short cid,
106 				     unsigned int upload_flag);
107 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
108 					 struct beiscsi_hba *phba,
109 					 struct bsg_job *job,
110 					 struct be_dma_mem *nonemb_cmd);
111 
112 #define BEISCSI_NO_RST_ISSUE	0
113 struct iscsi_invalidate_connection_params_in {
114 	struct be_cmd_req_hdr hdr;
115 	unsigned int session_handle;
116 	unsigned short cid;
117 	unsigned short unused;
118 	unsigned short cleanup_type;
119 	unsigned short save_cfg;
120 } __packed;
121 
122 struct iscsi_invalidate_connection_params_out {
123 	unsigned int session_handle;
124 	unsigned short cid;
125 	unsigned short unused;
126 } __packed;
127 
128 union iscsi_invalidate_connection_params {
129 	struct iscsi_invalidate_connection_params_in request;
130 	struct iscsi_invalidate_connection_params_out response;
131 } __packed;
132 
133 #define BE_INVLDT_CMD_TBL_SZ	128
134 struct invldt_cmd_tbl {
135 	unsigned short icd;
136 	unsigned short cid;
137 } __packed;
138 
139 struct invldt_cmds_params_in {
140 	struct be_cmd_req_hdr hdr;
141 	unsigned int ref_handle;
142 	unsigned int icd_count;
143 	struct invldt_cmd_tbl table[BE_INVLDT_CMD_TBL_SZ];
144 	unsigned short cleanup_type;
145 	unsigned short unused;
146 } __packed;
147 
148 struct invldt_cmds_params_out {
149 	struct be_cmd_resp_hdr hdr;
150 	unsigned int ref_handle;
151 	unsigned int icd_count;
152 	unsigned int icd_status[BE_INVLDT_CMD_TBL_SZ];
153 } __packed;
154 
155 union be_invldt_cmds_params {
156 	struct invldt_cmds_params_in request;
157 	struct invldt_cmds_params_out response;
158 } __packed;
159 
160 struct mgmt_hba_attributes {
161 	u8 flashrom_version_string[BEISCSI_VER_STRLEN];
162 	u8 manufacturer_name[BEISCSI_VER_STRLEN];
163 	u32 supported_modes;
164 	u8 seeprom_version_lo;
165 	u8 seeprom_version_hi;
166 	u8 rsvd0[2];
167 	u32 fw_cmd_data_struct_version;
168 	u32 ep_fw_data_struct_version;
169 	u8 ncsi_version_string[12];
170 	u32 default_extended_timeout;
171 	u8 controller_model_number[BEISCSI_VER_STRLEN];
172 	u8 controller_description[64];
173 	u8 controller_serial_number[BEISCSI_VER_STRLEN];
174 	u8 ip_version_string[BEISCSI_VER_STRLEN];
175 	u8 firmware_version_string[BEISCSI_VER_STRLEN];
176 	u8 bios_version_string[BEISCSI_VER_STRLEN];
177 	u8 redboot_version_string[BEISCSI_VER_STRLEN];
178 	u8 driver_version_string[BEISCSI_VER_STRLEN];
179 	u8 fw_on_flash_version_string[BEISCSI_VER_STRLEN];
180 	u32 functionalities_supported;
181 	u16 max_cdblength;
182 	u8 asic_revision;
183 	u8 generational_guid[16];
184 	u8 hba_port_count;
185 	u16 default_link_down_timeout;
186 	u8 iscsi_ver_min_max;
187 	u8 multifunction_device;
188 	u8 cache_valid;
189 	u8 hba_status;
190 	u8 max_domains_supported;
191 	u8 phy_port;
192 	u32 firmware_post_status;
193 	u32 hba_mtu[8];
194 	u8 iscsi_features;
195 	u8 asic_generation;
196 	u8 future_u8[2];
197 	u32 future_u32[3];
198 } __packed;
199 
200 struct mgmt_controller_attributes {
201 	struct mgmt_hba_attributes hba_attribs;
202 	u16 pci_vendor_id;
203 	u16 pci_device_id;
204 	u16 pci_sub_vendor_id;
205 	u16 pci_sub_system_id;
206 	u8 pci_bus_number;
207 	u8 pci_device_number;
208 	u8 pci_function_number;
209 	u8 interface_type;
210 	u64 unique_identifier;
211 	u8 netfilters;
212 	u8 rsvd0[3];
213 	u32 future_u32[4];
214 } __packed;
215 
216 struct be_mgmt_controller_attributes {
217 	struct be_cmd_req_hdr hdr;
218 	struct mgmt_controller_attributes params;
219 } __packed;
220 
221 struct be_mgmt_controller_attributes_resp {
222 	struct be_cmd_resp_hdr hdr;
223 	struct mgmt_controller_attributes params;
224 } __packed;
225 
226 struct be_bsg_vendor_cmd {
227 	struct be_cmd_req_hdr hdr;
228 	unsigned short region;
229 	unsigned short offset;
230 	unsigned short sector;
231 } __packed;
232 
233 /* configuration management */
234 
235 #define GET_MGMT_CONTROLLER_WS(phba)    (phba->pmgmt_ws)
236 
237 #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\
238 	pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
239 					bus_address.u.a32.address_lo;  \
240 	pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
241 					bus_address.u.a32.address_hi;  \
242 }
243 
244 #define BEISCSI_WRITE_FLASH 0
245 #define BEISCSI_READ_FLASH 1
246 
247 struct beiscsi_endpoint {
248 	struct beiscsi_hba *phba;
249 	struct beiscsi_sess *sess;
250 	struct beiscsi_conn *conn;
251 	struct iscsi_endpoint *openiscsi_ep;
252 	unsigned short ip_type;
253 	char dst6_addr[ISCSI_ADDRESS_BUF_LEN];
254 	unsigned long dst_addr;
255 	unsigned short ep_cid;
256 	unsigned int fw_handle;
257 	u16 dst_tcpport;
258 	u16 cid_vld;
259 };
260 
261 unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
262 				struct invldt_cmd_tbl *inv_tbl,
263 				unsigned int num_invalidate, unsigned int cid,
264 				struct be_dma_mem *nonemb_cmd);
265 
266 unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
267 					 struct beiscsi_endpoint *beiscsi_ep,
268 					 unsigned short cid,
269 					 unsigned short issue_reset,
270 					 unsigned short savecfg_flag);
271 
272 int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type);
273 
274 int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type,
275 			 u8 *ip, u8 *subnet);
276 
277 int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw);
278 
279 int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
280 		      struct be_cmd_get_def_gateway_resp *resp);
281 
282 int mgmt_get_nic_conf(struct beiscsi_hba *phba,
283 		      struct be_cmd_get_nic_conf_resp *mac);
284 
285 int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
286 			struct be_cmd_get_if_info_resp **if_info);
287 
288 unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba);
289 
290 int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
291 
292 unsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba);
293 
294 unsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba);
295 
296 unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba);
297 
298 unsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async);
299 
300 int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle);
301 
302 ssize_t beiscsi_drvr_ver_disp(struct device *dev,
303 			       struct device_attribute *attr, char *buf);
304 
305 ssize_t beiscsi_fw_ver_disp(struct device *dev,
306 			     struct device_attribute *attr, char *buf);
307 
308 ssize_t beiscsi_active_session_disp(struct device *dev,
309 				     struct device_attribute *attr, char *buf);
310 
311 ssize_t beiscsi_adap_family_disp(struct device *dev,
312 				  struct device_attribute *attr, char *buf);
313 
314 
315 ssize_t beiscsi_free_session_disp(struct device *dev,
316 				   struct device_attribute *attr, char *buf);
317 
318 ssize_t beiscsi_phys_port_disp(struct device *dev,
319 				struct device_attribute *attr, char *buf);
320 
321 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
322 			     struct wrb_handle *pwrb_handle,
323 			     struct be_mem_descriptor *mem_descr,
324 			     struct hwi_wrb_context *pwrb_context);
325 
326 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
327 			     struct wrb_handle *pwrb_handle,
328 			     struct hwi_wrb_context *pwrb_context);
329 
330 int be_cmd_modify_eq_delay(struct beiscsi_hba *phba,
331 			 struct be_set_eqd *, int num);
332 
333 int beiscsi_logout_fw_sess(struct beiscsi_hba *phba,
334 			    uint32_t fw_sess_handle);
335 
336 #endif
337