blob: 03400f3f666f2465dedbee7f24f2fec21375068a [file] [log] [blame]
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05301/**
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -07002 * Copyright (C) 2005 - 2011 Emulex
Jayamohan Kallickal6733b392009-09-05 07:36:35 +05303 * 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 *
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070010 * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com)
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053011 *
12 * Contact Information:
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070013 * linux-drivers@emulex.com
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053014 *
Jayamohan Kallickal255fa9a2011-03-25 14:23:57 -070015 * Emulex
16 * 3333 Susan Street
17 * Costa Mesa, CA 92626
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053018 */
19
20#ifndef _BEISCSI_MGMT_
21#define _BEISCSI_MGMT_
22
23#include <linux/types.h>
24#include <linux/list.h>
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -050025#include <scsi/scsi_bsg_iscsi.h>
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053026#include "be_iscsi.h"
27#include "be_main.h"
28
29/**
30 * Pseudo amap definition in which each bit of the actual structure is defined
31 * as a byte: used to calculate offset/shift/mask of each field
32 */
33struct amap_mcc_sge {
34 u8 pa_lo[32]; /* dword 0 */
35 u8 pa_hi[32]; /* dword 1 */
36 u8 length[32]; /* DWORD 2 */
37} __packed;
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 */
43struct amap_mcc_wrb_payload {
44 union {
45 struct amap_mcc_sge sgl[19];
46 u8 embedded[59 * 32]; /* DWORDS 57 to 115 */
47 } u;
48} __packed;
49
50/**
51 * Pseudo amap definition in which each bit of the actual structure is defined
52 * as a byte: used to calculate offset/shift/mask of each field
53 */
54struct amap_mcc_wrb {
55 u8 embedded; /* DWORD 0 */
56 u8 rsvd0[2]; /* DWORD 0 */
57 u8 sge_count[5]; /* DWORD 0 */
58 u8 rsvd1[16]; /* DWORD 0 */
59 u8 special[8]; /* DWORD 0 */
60 u8 payload_length[32];
61 u8 tag[64]; /* DWORD 2 */
62 u8 rsvd2[32]; /* DWORD 4 */
63 struct amap_mcc_wrb_payload payload;
64};
65
66struct mcc_sge {
67 u32 pa_lo; /* dword 0 */
68 u32 pa_hi; /* dword 1 */
69 u32 length; /* DWORD 2 */
70} __packed;
71
72struct mcc_wrb_payload {
73 union {
74 struct mcc_sge sgl[19];
75 u32 embedded[59]; /* DWORDS 57 to 115 */
76 } u;
77} __packed;
78
79#define MCC_WRB_EMBEDDED_MASK 0x00000001
80
81struct mcc_wrb {
82 u32 dw[0]; /* DWORD 0 */
83 u32 payload_length;
84 u32 tag[2]; /* DWORD 2 */
85 u32 rsvd2[1]; /* DWORD 4 */
86 struct mcc_wrb_payload payload;
87};
88
Jayamohan Kallickal03a12312010-07-22 04:17:16 +053089int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute);
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +053090int mgmt_open_connection(struct beiscsi_hba *phba,
91 struct sockaddr *dst_addr,
92 struct beiscsi_endpoint *beiscsi_ep,
93 struct be_dma_mem *nonemb_cmd);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053094
Jayamohan Kallickal03a12312010-07-22 04:17:16 +053095unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +053096 unsigned short cid,
97 unsigned int upload_flag);
Jayamohan Kallickal03a12312010-07-22 04:17:16 +053098unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
Jayamohan Kallickal41831222010-02-20 08:02:39 +053099 struct invalidate_command_table *inv_tbl,
Jayamohan Kallickal3cbb7a72010-07-22 04:27:47 +0530100 unsigned int num_invalidate, unsigned int cid,
101 struct be_dma_mem *nonemb_cmd);
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -0500102unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
103 struct beiscsi_hba *phba,
104 struct bsg_job *job,
105 struct be_dma_mem *nonemb_cmd);
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530106
107struct iscsi_invalidate_connection_params_in {
108 struct be_cmd_req_hdr hdr;
109 unsigned int session_handle;
110 unsigned short cid;
111 unsigned short unused;
112 unsigned short cleanup_type;
113 unsigned short save_cfg;
114} __packed;
115
116struct iscsi_invalidate_connection_params_out {
117 unsigned int session_handle;
118 unsigned short cid;
119 unsigned short unused;
120} __packed;
121
122union iscsi_invalidate_connection_params {
123 struct iscsi_invalidate_connection_params_in request;
124 struct iscsi_invalidate_connection_params_out response;
125} __packed;
126
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530127struct invalidate_commands_params_in {
128 struct be_cmd_req_hdr hdr;
129 unsigned int ref_handle;
130 unsigned int icd_count;
131 struct invalidate_command_table table[128];
132 unsigned short cleanup_type;
133 unsigned short unused;
134} __packed;
135
136struct invalidate_commands_params_out {
137 unsigned int ref_handle;
138 unsigned int icd_count;
139 unsigned int icd_status[128];
140} __packed;
141
142union invalidate_commands_params {
143 struct invalidate_commands_params_in request;
144 struct invalidate_commands_params_out response;
145} __packed;
146
147struct mgmt_hba_attributes {
148 u8 flashrom_version_string[32];
149 u8 manufacturer_name[32];
150 u32 supported_modes;
151 u8 seeprom_version_lo;
152 u8 seeprom_version_hi;
153 u8 rsvd0[2];
154 u32 fw_cmd_data_struct_version;
155 u32 ep_fw_data_struct_version;
156 u32 future_reserved[12];
157 u32 default_extended_timeout;
158 u8 controller_model_number[32];
159 u8 controller_description[64];
160 u8 controller_serial_number[32];
161 u8 ip_version_string[32];
162 u8 firmware_version_string[32];
163 u8 bios_version_string[32];
164 u8 redboot_version_string[32];
165 u8 driver_version_string[32];
166 u8 fw_on_flash_version_string[32];
167 u32 functionalities_supported;
168 u16 max_cdblength;
169 u8 asic_revision;
170 u8 generational_guid[16];
171 u8 hba_port_count;
172 u16 default_link_down_timeout;
173 u8 iscsi_ver_min_max;
174 u8 multifunction_device;
175 u8 cache_valid;
176 u8 hba_status;
177 u8 max_domains_supported;
178 u8 phy_port;
179 u32 firmware_post_status;
180 u32 hba_mtu[8];
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530181 u8 iscsi_features;
182 u8 future_u8[3];
183 u32 future_u32[3];
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530184} __packed;
185
186struct mgmt_controller_attributes {
187 struct mgmt_hba_attributes hba_attribs;
188 u16 pci_vendor_id;
189 u16 pci_device_id;
190 u16 pci_sub_vendor_id;
191 u16 pci_sub_system_id;
192 u8 pci_bus_number;
193 u8 pci_device_number;
194 u8 pci_function_number;
195 u8 interface_type;
196 u64 unique_identifier;
197 u8 netfilters;
198 u8 rsvd0[3];
199 u8 future_u32[4];
200} __packed;
201
202struct be_mgmt_controller_attributes {
203 struct be_cmd_req_hdr hdr;
204 struct mgmt_controller_attributes params;
205} __packed;
206
207struct be_mgmt_controller_attributes_resp {
208 struct be_cmd_resp_hdr hdr;
209 struct mgmt_controller_attributes params;
210} __packed;
211
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -0500212struct be_bsg_vendor_cmd {
213 struct be_cmd_req_hdr hdr;
214 unsigned short region;
215 unsigned short offset;
216 unsigned short sector;
217} __packed;
218
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530219/* configuration management */
220
221#define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws)
222
223/* MGMT CMD flags */
224
225#define MGMT_CMDH_FREE (1<<0)
226
227/* --- MGMT_ERROR_CODES --- */
228/* Error Codes returned in the status field of the CMD response header */
229#define MGMT_STATUS_SUCCESS 0 /* The CMD completed without errors */
230#define MGMT_STATUS_FAILED 1 /* Error status in the Status field of */
231 /* the CMD_RESPONSE_HEADER */
232
233#define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\
Jayamohan Kallickal3ec78272012-04-03 23:41:38 -0500234 pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530235 bus_address.u.a32.address_lo; \
Jayamohan Kallickal3ec78272012-04-03 23:41:38 -0500236 pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530237 bus_address.u.a32.address_hi; \
238}
239
Jayamohan Kallickalffce3e22012-04-03 23:41:50 -0500240#define BEISCSI_WRITE_FLASH 0
241#define BEISCSI_READ_FLASH 1
242
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530243struct beiscsi_endpoint {
244 struct beiscsi_hba *phba;
245 struct beiscsi_sess *sess;
246 struct beiscsi_conn *conn;
Jayamohan Kallickalc2462282010-01-05 05:05:34 +0530247 struct iscsi_endpoint *openiscsi_ep;
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530248 unsigned short ip_type;
249 char dst6_addr[ISCSI_ADDRESS_BUF_LEN];
250 unsigned long dst_addr;
251 unsigned short ep_cid;
252 unsigned int fw_handle;
253 u16 dst_tcpport;
254 u16 cid_vld;
255};
256
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530257int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530258 struct beiscsi_hba *phba);
259
Jayamohan Kallickal03a12312010-07-22 04:17:16 +0530260unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530261 struct beiscsi_endpoint *beiscsi_ep,
262 unsigned short cid,
263 unsigned short issue_reset,
264 unsigned short savecfg_flag);
Jayamohan Kallickalbfead3b2009-10-23 11:52:33 +0530265
Jayamohan Kallickal6733b392009-09-05 07:36:35 +0530266#endif