Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
fa90c54f AV |
2 | * QLogic Fibre Channel HBA Driver |
3 | * Copyright (c) 2003-2005 QLogic Corporation | |
1da177e4 | 4 | * |
fa90c54f | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
1da177e4 LT |
6 | */ |
7 | #include "qla_def.h" | |
8 | ||
1da177e4 LT |
9 | static inline struct ct_sns_req * |
10 | qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t); | |
11 | ||
12 | static inline struct sns_cmd_pkt * | |
13 | qla2x00_prep_sns_cmd(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t); | |
14 | ||
15 | static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *); | |
16 | static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *); | |
17 | static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *); | |
18 | static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *); | |
19 | static int qla2x00_sns_rft_id(scsi_qla_host_t *); | |
20 | static int qla2x00_sns_rnn_id(scsi_qla_host_t *); | |
21 | ||
22 | /** | |
8c958a99 | 23 | * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query. |
1da177e4 LT |
24 | * @ha: HA context |
25 | * @req_size: request size in bytes | |
26 | * @rsp_size: response size in bytes | |
27 | * | |
28 | * Returns a pointer to the @ha's ms_iocb. | |
29 | */ | |
8c958a99 | 30 | void * |
1da177e4 LT |
31 | qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size) |
32 | { | |
33 | ms_iocb_entry_t *ms_pkt; | |
34 | ||
35 | ms_pkt = ha->ms_iocb; | |
36 | memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); | |
37 | ||
38 | ms_pkt->entry_type = MS_IOCB_TYPE; | |
39 | ms_pkt->entry_count = 1; | |
40 | SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER); | |
41 | ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG); | |
42 | ms_pkt->timeout = __constant_cpu_to_le16(25); | |
43 | ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); | |
44 | ms_pkt->total_dsd_count = __constant_cpu_to_le16(2); | |
45 | ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); | |
46 | ms_pkt->req_bytecount = cpu_to_le32(req_size); | |
47 | ||
48 | ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
49 | ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
50 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; | |
51 | ||
52 | ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
53 | ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
54 | ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; | |
55 | ||
56 | return (ms_pkt); | |
57 | } | |
58 | ||
8c958a99 AV |
59 | /** |
60 | * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query. | |
61 | * @ha: HA context | |
62 | * @req_size: request size in bytes | |
63 | * @rsp_size: response size in bytes | |
64 | * | |
65 | * Returns a pointer to the @ha's ms_iocb. | |
66 | */ | |
67 | void * | |
68 | qla24xx_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size) | |
69 | { | |
70 | struct ct_entry_24xx *ct_pkt; | |
71 | ||
72 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; | |
73 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); | |
74 | ||
75 | ct_pkt->entry_type = CT_IOCB_TYPE; | |
76 | ct_pkt->entry_count = 1; | |
77 | ct_pkt->nport_handle = __constant_cpu_to_le16(NPH_SNS); | |
78 | ct_pkt->timeout = __constant_cpu_to_le16(25); | |
79 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); | |
80 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); | |
81 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); | |
82 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); | |
83 | ||
84 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
85 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
86 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; | |
87 | ||
88 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
89 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
90 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; | |
2c3dfe3f | 91 | ct_pkt->vp_index = ha->vp_idx; |
8c958a99 AV |
92 | |
93 | return (ct_pkt); | |
94 | } | |
95 | ||
1da177e4 LT |
96 | /** |
97 | * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. | |
98 | * @ct_req: CT request buffer | |
99 | * @cmd: GS command | |
100 | * @rsp_size: response size in bytes | |
101 | * | |
102 | * Returns a pointer to the intitialized @ct_req. | |
103 | */ | |
104 | static inline struct ct_sns_req * | |
105 | qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size) | |
106 | { | |
107 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); | |
108 | ||
109 | ct_req->header.revision = 0x01; | |
110 | ct_req->header.gs_type = 0xFC; | |
111 | ct_req->header.gs_subtype = 0x02; | |
112 | ct_req->command = cpu_to_be16(cmd); | |
113 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); | |
114 | ||
115 | return (ct_req); | |
116 | } | |
117 | ||
8c958a99 AV |
118 | static int |
119 | qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt, | |
120 | struct ct_sns_rsp *ct_rsp, const char *routine) | |
121 | { | |
122 | int rval; | |
123 | uint16_t comp_status; | |
124 | ||
125 | rval = QLA_FUNCTION_FAILED; | |
126 | if (ms_pkt->entry_status != 0) { | |
127 | DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n", | |
128 | ha->host_no, routine, ms_pkt->entry_status)); | |
129 | } else { | |
e428924c | 130 | if (IS_FWI2_CAPABLE(ha)) |
cdfc82ad AV |
131 | comp_status = le16_to_cpu( |
132 | ((struct ct_entry_24xx *)ms_pkt)->comp_status); | |
8c958a99 AV |
133 | else |
134 | comp_status = le16_to_cpu(ms_pkt->status); | |
135 | switch (comp_status) { | |
136 | case CS_COMPLETE: | |
137 | case CS_DATA_UNDERRUN: | |
138 | case CS_DATA_OVERRUN: /* Overrun? */ | |
139 | if (ct_rsp->header.response != | |
140 | __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { | |
141 | DEBUG2_3(printk("scsi(%ld): %s failed, " | |
142 | "rejected request:\n", ha->host_no, | |
143 | routine)); | |
144 | DEBUG2_3(qla2x00_dump_buffer( | |
145 | (uint8_t *)&ct_rsp->header, | |
146 | sizeof(struct ct_rsp_hdr))); | |
4346b149 | 147 | rval = QLA_INVALID_COMMAND; |
8c958a99 AV |
148 | } else |
149 | rval = QLA_SUCCESS; | |
150 | break; | |
151 | default: | |
152 | DEBUG2_3(printk("scsi(%ld): %s failed, completion " | |
153 | "status (%x).\n", ha->host_no, routine, | |
154 | comp_status)); | |
155 | break; | |
156 | } | |
157 | } | |
158 | return rval; | |
159 | } | |
1da177e4 LT |
160 | |
161 | /** | |
162 | * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command. | |
163 | * @ha: HA context | |
164 | * @fcport: fcport entry to updated | |
165 | * | |
166 | * Returns 0 on success. | |
167 | */ | |
168 | int | |
169 | qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) | |
170 | { | |
171 | int rval; | |
172 | ||
173 | ms_iocb_entry_t *ms_pkt; | |
174 | struct ct_sns_req *ct_req; | |
175 | struct ct_sns_rsp *ct_rsp; | |
176 | ||
177 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
178 | return (qla2x00_sns_ga_nxt(ha, fcport)); | |
179 | } | |
180 | ||
181 | /* Issue GA_NXT */ | |
182 | /* Prepare common MS IOCB */ | |
8c958a99 | 183 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE); |
1da177e4 LT |
184 | |
185 | /* Prepare CT request */ | |
186 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, | |
187 | GA_NXT_RSP_SIZE); | |
188 | ct_rsp = &ha->ct_sns->p.rsp; | |
189 | ||
190 | /* Prepare CT arguments -- port_id */ | |
191 | ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain; | |
192 | ct_req->req.port_id.port_id[1] = fcport->d_id.b.area; | |
193 | ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa; | |
194 | ||
195 | /* Execute MS IOCB */ | |
196 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
197 | sizeof(ms_iocb_entry_t)); | |
198 | if (rval != QLA_SUCCESS) { | |
199 | /*EMPTY*/ | |
200 | DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n", | |
201 | ha->host_no, rval)); | |
8c958a99 AV |
202 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GA_NXT") != |
203 | QLA_SUCCESS) { | |
1da177e4 LT |
204 | rval = QLA_FUNCTION_FAILED; |
205 | } else { | |
206 | /* Populate fc_port_t entry. */ | |
207 | fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0]; | |
208 | fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1]; | |
209 | fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2]; | |
210 | ||
211 | memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name, | |
212 | WWN_SIZE); | |
213 | memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name, | |
214 | WWN_SIZE); | |
215 | ||
216 | if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE && | |
217 | ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE) | |
218 | fcport->d_id.b.domain = 0xf0; | |
219 | ||
220 | DEBUG2_3(printk("scsi(%ld): GA_NXT entry - " | |
221 | "nn %02x%02x%02x%02x%02x%02x%02x%02x " | |
222 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " | |
223 | "portid=%02x%02x%02x.\n", | |
224 | ha->host_no, | |
225 | fcport->node_name[0], fcport->node_name[1], | |
226 | fcport->node_name[2], fcport->node_name[3], | |
227 | fcport->node_name[4], fcport->node_name[5], | |
228 | fcport->node_name[6], fcport->node_name[7], | |
229 | fcport->port_name[0], fcport->port_name[1], | |
230 | fcport->port_name[2], fcport->port_name[3], | |
231 | fcport->port_name[4], fcport->port_name[5], | |
232 | fcport->port_name[6], fcport->port_name[7], | |
233 | fcport->d_id.b.domain, fcport->d_id.b.area, | |
234 | fcport->d_id.b.al_pa)); | |
235 | } | |
236 | ||
237 | return (rval); | |
238 | } | |
239 | ||
240 | /** | |
241 | * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command. | |
242 | * @ha: HA context | |
243 | * @list: switch info entries to populate | |
244 | * | |
245 | * NOTE: Non-Nx_Ports are not requested. | |
246 | * | |
247 | * Returns 0 on success. | |
248 | */ | |
249 | int | |
250 | qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) | |
251 | { | |
252 | int rval; | |
253 | uint16_t i; | |
254 | ||
255 | ms_iocb_entry_t *ms_pkt; | |
256 | struct ct_sns_req *ct_req; | |
257 | struct ct_sns_rsp *ct_rsp; | |
258 | ||
259 | struct ct_sns_gid_pt_data *gid_data; | |
260 | ||
261 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
262 | return (qla2x00_sns_gid_pt(ha, list)); | |
263 | } | |
264 | ||
265 | gid_data = NULL; | |
266 | ||
267 | /* Issue GID_PT */ | |
268 | /* Prepare common MS IOCB */ | |
8c958a99 | 269 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE); |
1da177e4 LT |
270 | |
271 | /* Prepare CT request */ | |
272 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, | |
273 | GID_PT_RSP_SIZE); | |
274 | ct_rsp = &ha->ct_sns->p.rsp; | |
275 | ||
276 | /* Prepare CT arguments -- port_type */ | |
277 | ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE; | |
278 | ||
279 | /* Execute MS IOCB */ | |
280 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
281 | sizeof(ms_iocb_entry_t)); | |
282 | if (rval != QLA_SUCCESS) { | |
283 | /*EMPTY*/ | |
284 | DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n", | |
285 | ha->host_no, rval)); | |
8c958a99 AV |
286 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GID_PT") != |
287 | QLA_SUCCESS) { | |
1da177e4 LT |
288 | rval = QLA_FUNCTION_FAILED; |
289 | } else { | |
290 | /* Set port IDs in switch info list. */ | |
291 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
292 | gid_data = &ct_rsp->rsp.gid_pt.entries[i]; | |
293 | list[i].d_id.b.domain = gid_data->port_id[0]; | |
294 | list[i].d_id.b.area = gid_data->port_id[1]; | |
295 | list[i].d_id.b.al_pa = gid_data->port_id[2]; | |
296 | ||
297 | /* Last one exit. */ | |
298 | if (gid_data->control_byte & BIT_7) { | |
299 | list[i].d_id.b.rsvd_1 = gid_data->control_byte; | |
300 | break; | |
301 | } | |
302 | } | |
303 | ||
304 | /* | |
305 | * If we've used all available slots, then the switch is | |
306 | * reporting back more devices than we can handle with this | |
307 | * single call. Return a failed status, and let GA_NXT handle | |
308 | * the overload. | |
309 | */ | |
fa2a1ce5 | 310 | if (i == MAX_FIBRE_DEVICES) |
1da177e4 LT |
311 | rval = QLA_FUNCTION_FAILED; |
312 | } | |
313 | ||
314 | return (rval); | |
315 | } | |
316 | ||
317 | /** | |
318 | * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query. | |
319 | * @ha: HA context | |
320 | * @list: switch info entries to populate | |
321 | * | |
322 | * Returns 0 on success. | |
323 | */ | |
324 | int | |
325 | qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) | |
326 | { | |
327 | int rval; | |
328 | uint16_t i; | |
329 | ||
330 | ms_iocb_entry_t *ms_pkt; | |
331 | struct ct_sns_req *ct_req; | |
332 | struct ct_sns_rsp *ct_rsp; | |
333 | ||
334 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
335 | return (qla2x00_sns_gpn_id(ha, list)); | |
336 | } | |
337 | ||
338 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
339 | /* Issue GPN_ID */ | |
340 | /* Prepare common MS IOCB */ | |
8c958a99 | 341 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GPN_ID_REQ_SIZE, |
1da177e4 LT |
342 | GPN_ID_RSP_SIZE); |
343 | ||
344 | /* Prepare CT request */ | |
345 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, | |
346 | GPN_ID_RSP_SIZE); | |
347 | ct_rsp = &ha->ct_sns->p.rsp; | |
348 | ||
349 | /* Prepare CT arguments -- port_id */ | |
350 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; | |
351 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; | |
352 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; | |
353 | ||
354 | /* Execute MS IOCB */ | |
355 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
356 | sizeof(ms_iocb_entry_t)); | |
357 | if (rval != QLA_SUCCESS) { | |
358 | /*EMPTY*/ | |
359 | DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed " | |
360 | "(%d).\n", ha->host_no, rval)); | |
8c958a99 AV |
361 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, |
362 | "GPN_ID") != QLA_SUCCESS) { | |
1da177e4 LT |
363 | rval = QLA_FUNCTION_FAILED; |
364 | } else { | |
365 | /* Save portname */ | |
366 | memcpy(list[i].port_name, | |
367 | ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); | |
368 | } | |
369 | ||
370 | /* Last device exit. */ | |
371 | if (list[i].d_id.b.rsvd_1 != 0) | |
372 | break; | |
373 | } | |
374 | ||
375 | return (rval); | |
376 | } | |
377 | ||
378 | /** | |
379 | * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query. | |
380 | * @ha: HA context | |
381 | * @list: switch info entries to populate | |
382 | * | |
383 | * Returns 0 on success. | |
384 | */ | |
385 | int | |
386 | qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list) | |
387 | { | |
388 | int rval; | |
389 | uint16_t i; | |
390 | ||
391 | ms_iocb_entry_t *ms_pkt; | |
392 | struct ct_sns_req *ct_req; | |
393 | struct ct_sns_rsp *ct_rsp; | |
394 | ||
395 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
396 | return (qla2x00_sns_gnn_id(ha, list)); | |
397 | } | |
398 | ||
399 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
400 | /* Issue GNN_ID */ | |
401 | /* Prepare common MS IOCB */ | |
8c958a99 | 402 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GNN_ID_REQ_SIZE, |
1da177e4 LT |
403 | GNN_ID_RSP_SIZE); |
404 | ||
405 | /* Prepare CT request */ | |
406 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD, | |
407 | GNN_ID_RSP_SIZE); | |
408 | ct_rsp = &ha->ct_sns->p.rsp; | |
409 | ||
410 | /* Prepare CT arguments -- port_id */ | |
411 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; | |
412 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; | |
413 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; | |
414 | ||
415 | /* Execute MS IOCB */ | |
416 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
417 | sizeof(ms_iocb_entry_t)); | |
418 | if (rval != QLA_SUCCESS) { | |
419 | /*EMPTY*/ | |
420 | DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed " | |
421 | "(%d).\n", ha->host_no, rval)); | |
8c958a99 AV |
422 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, |
423 | "GNN_ID") != QLA_SUCCESS) { | |
1da177e4 LT |
424 | rval = QLA_FUNCTION_FAILED; |
425 | } else { | |
426 | /* Save nodename */ | |
427 | memcpy(list[i].node_name, | |
428 | ct_rsp->rsp.gnn_id.node_name, WWN_SIZE); | |
429 | ||
430 | DEBUG2_3(printk("scsi(%ld): GID_PT entry - " | |
431 | "nn %02x%02x%02x%02x%02x%02x%02x%02x " | |
432 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " | |
433 | "portid=%02x%02x%02x.\n", | |
434 | ha->host_no, | |
435 | list[i].node_name[0], list[i].node_name[1], | |
436 | list[i].node_name[2], list[i].node_name[3], | |
437 | list[i].node_name[4], list[i].node_name[5], | |
438 | list[i].node_name[6], list[i].node_name[7], | |
439 | list[i].port_name[0], list[i].port_name[1], | |
440 | list[i].port_name[2], list[i].port_name[3], | |
441 | list[i].port_name[4], list[i].port_name[5], | |
442 | list[i].port_name[6], list[i].port_name[7], | |
443 | list[i].d_id.b.domain, list[i].d_id.b.area, | |
444 | list[i].d_id.b.al_pa)); | |
445 | } | |
446 | ||
447 | /* Last device exit. */ | |
448 | if (list[i].d_id.b.rsvd_1 != 0) | |
449 | break; | |
450 | } | |
451 | ||
452 | return (rval); | |
453 | } | |
454 | ||
455 | /** | |
456 | * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA. | |
457 | * @ha: HA context | |
458 | * | |
459 | * Returns 0 on success. | |
460 | */ | |
461 | int | |
462 | qla2x00_rft_id(scsi_qla_host_t *ha) | |
463 | { | |
464 | int rval; | |
465 | ||
466 | ms_iocb_entry_t *ms_pkt; | |
467 | struct ct_sns_req *ct_req; | |
468 | struct ct_sns_rsp *ct_rsp; | |
469 | ||
470 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
471 | return (qla2x00_sns_rft_id(ha)); | |
472 | } | |
473 | ||
474 | /* Issue RFT_ID */ | |
475 | /* Prepare common MS IOCB */ | |
8c958a99 | 476 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE); |
1da177e4 LT |
477 | |
478 | /* Prepare CT request */ | |
479 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD, | |
480 | RFT_ID_RSP_SIZE); | |
481 | ct_rsp = &ha->ct_sns->p.rsp; | |
482 | ||
483 | /* Prepare CT arguments -- port_id, FC-4 types */ | |
484 | ct_req->req.rft_id.port_id[0] = ha->d_id.b.domain; | |
485 | ct_req->req.rft_id.port_id[1] = ha->d_id.b.area; | |
486 | ct_req->req.rft_id.port_id[2] = ha->d_id.b.al_pa; | |
487 | ||
488 | ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */ | |
489 | ||
490 | /* Execute MS IOCB */ | |
491 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
492 | sizeof(ms_iocb_entry_t)); | |
493 | if (rval != QLA_SUCCESS) { | |
494 | /*EMPTY*/ | |
495 | DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n", | |
496 | ha->host_no, rval)); | |
8c958a99 AV |
497 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFT_ID") != |
498 | QLA_SUCCESS) { | |
1da177e4 LT |
499 | rval = QLA_FUNCTION_FAILED; |
500 | } else { | |
501 | DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n", | |
502 | ha->host_no)); | |
503 | } | |
504 | ||
505 | return (rval); | |
506 | } | |
507 | ||
508 | /** | |
509 | * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA. | |
510 | * @ha: HA context | |
511 | * | |
512 | * Returns 0 on success. | |
513 | */ | |
514 | int | |
515 | qla2x00_rff_id(scsi_qla_host_t *ha) | |
516 | { | |
517 | int rval; | |
518 | ||
519 | ms_iocb_entry_t *ms_pkt; | |
520 | struct ct_sns_req *ct_req; | |
521 | struct ct_sns_rsp *ct_rsp; | |
522 | ||
523 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
524 | DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on " | |
525 | "ISP2100/ISP2200.\n", ha->host_no)); | |
526 | return (QLA_SUCCESS); | |
527 | } | |
528 | ||
529 | /* Issue RFF_ID */ | |
530 | /* Prepare common MS IOCB */ | |
8c958a99 | 531 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE); |
1da177e4 LT |
532 | |
533 | /* Prepare CT request */ | |
534 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, | |
535 | RFF_ID_RSP_SIZE); | |
536 | ct_rsp = &ha->ct_sns->p.rsp; | |
537 | ||
538 | /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ | |
539 | ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain; | |
540 | ct_req->req.rff_id.port_id[1] = ha->d_id.b.area; | |
541 | ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa; | |
542 | ||
9403688e | 543 | ct_req->req.rff_id.fc4_feature = BIT_1; |
1da177e4 LT |
544 | ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ |
545 | ||
546 | /* Execute MS IOCB */ | |
547 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
548 | sizeof(ms_iocb_entry_t)); | |
549 | if (rval != QLA_SUCCESS) { | |
550 | /*EMPTY*/ | |
551 | DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n", | |
552 | ha->host_no, rval)); | |
8c958a99 AV |
553 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFF_ID") != |
554 | QLA_SUCCESS) { | |
1da177e4 LT |
555 | rval = QLA_FUNCTION_FAILED; |
556 | } else { | |
557 | DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n", | |
558 | ha->host_no)); | |
559 | } | |
560 | ||
561 | return (rval); | |
562 | } | |
563 | ||
564 | /** | |
565 | * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. | |
566 | * @ha: HA context | |
567 | * | |
568 | * Returns 0 on success. | |
569 | */ | |
570 | int | |
571 | qla2x00_rnn_id(scsi_qla_host_t *ha) | |
572 | { | |
573 | int rval; | |
574 | ||
575 | ms_iocb_entry_t *ms_pkt; | |
576 | struct ct_sns_req *ct_req; | |
577 | struct ct_sns_rsp *ct_rsp; | |
578 | ||
579 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
580 | return (qla2x00_sns_rnn_id(ha)); | |
581 | } | |
582 | ||
583 | /* Issue RNN_ID */ | |
584 | /* Prepare common MS IOCB */ | |
8c958a99 | 585 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE); |
1da177e4 LT |
586 | |
587 | /* Prepare CT request */ | |
588 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, | |
589 | RNN_ID_RSP_SIZE); | |
590 | ct_rsp = &ha->ct_sns->p.rsp; | |
591 | ||
592 | /* Prepare CT arguments -- port_id, node_name */ | |
593 | ct_req->req.rnn_id.port_id[0] = ha->d_id.b.domain; | |
594 | ct_req->req.rnn_id.port_id[1] = ha->d_id.b.area; | |
595 | ct_req->req.rnn_id.port_id[2] = ha->d_id.b.al_pa; | |
596 | ||
8c958a99 | 597 | memcpy(ct_req->req.rnn_id.node_name, ha->node_name, WWN_SIZE); |
1da177e4 LT |
598 | |
599 | /* Execute MS IOCB */ | |
600 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
601 | sizeof(ms_iocb_entry_t)); | |
602 | if (rval != QLA_SUCCESS) { | |
603 | /*EMPTY*/ | |
604 | DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n", | |
605 | ha->host_no, rval)); | |
8c958a99 AV |
606 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RNN_ID") != |
607 | QLA_SUCCESS) { | |
1da177e4 LT |
608 | rval = QLA_FUNCTION_FAILED; |
609 | } else { | |
610 | DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n", | |
611 | ha->host_no)); | |
612 | } | |
613 | ||
614 | return (rval); | |
615 | } | |
616 | ||
1620f7c2 AV |
617 | void |
618 | qla2x00_get_sym_node_name(scsi_qla_host_t *ha, uint8_t *snn) | |
619 | { | |
620 | sprintf(snn, "%s FW:v%d.%02d.%02d DVR:v%s",ha->model_number, | |
621 | ha->fw_major_version, ha->fw_minor_version, | |
622 | ha->fw_subminor_version, qla2x00_version_str); | |
623 | } | |
624 | ||
1da177e4 LT |
625 | /** |
626 | * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA. | |
627 | * @ha: HA context | |
628 | * | |
629 | * Returns 0 on success. | |
630 | */ | |
631 | int | |
632 | qla2x00_rsnn_nn(scsi_qla_host_t *ha) | |
633 | { | |
634 | int rval; | |
1da177e4 LT |
635 | ms_iocb_entry_t *ms_pkt; |
636 | struct ct_sns_req *ct_req; | |
637 | struct ct_sns_rsp *ct_rsp; | |
638 | ||
639 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
640 | DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on " | |
641 | "ISP2100/ISP2200.\n", ha->host_no)); | |
642 | return (QLA_SUCCESS); | |
643 | } | |
644 | ||
645 | /* Issue RSNN_NN */ | |
646 | /* Prepare common MS IOCB */ | |
647 | /* Request size adjusted after CT preparation */ | |
8c958a99 | 648 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE); |
1da177e4 LT |
649 | |
650 | /* Prepare CT request */ | |
651 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, | |
652 | RSNN_NN_RSP_SIZE); | |
653 | ct_rsp = &ha->ct_sns->p.rsp; | |
654 | ||
655 | /* Prepare CT arguments -- node_name, symbolic node_name, size */ | |
8c958a99 | 656 | memcpy(ct_req->req.rsnn_nn.node_name, ha->node_name, WWN_SIZE); |
fa2a1ce5 | 657 | |
1da177e4 | 658 | /* Prepare the Symbolic Node Name */ |
1620f7c2 | 659 | qla2x00_get_sym_node_name(ha, ct_req->req.rsnn_nn.sym_node_name); |
1da177e4 LT |
660 | |
661 | /* Calculate SNN length */ | |
1620f7c2 AV |
662 | ct_req->req.rsnn_nn.name_len = |
663 | (uint8_t)strlen(ct_req->req.rsnn_nn.sym_node_name); | |
1da177e4 LT |
664 | |
665 | /* Update MS IOCB request */ | |
666 | ms_pkt->req_bytecount = | |
667 | cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len); | |
668 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; | |
669 | ||
670 | /* Execute MS IOCB */ | |
671 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
672 | sizeof(ms_iocb_entry_t)); | |
673 | if (rval != QLA_SUCCESS) { | |
674 | /*EMPTY*/ | |
675 | DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n", | |
676 | ha->host_no, rval)); | |
8c958a99 AV |
677 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RSNN_NN") != |
678 | QLA_SUCCESS) { | |
1da177e4 LT |
679 | rval = QLA_FUNCTION_FAILED; |
680 | } else { | |
681 | DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n", | |
682 | ha->host_no)); | |
683 | } | |
684 | ||
685 | return (rval); | |
686 | } | |
687 | ||
1da177e4 LT |
688 | /** |
689 | * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query. | |
690 | * @ha: HA context | |
691 | * @cmd: GS command | |
692 | * @scmd_len: Subcommand length | |
693 | * @data_size: response size in bytes | |
694 | * | |
695 | * Returns a pointer to the @ha's sns_cmd. | |
696 | */ | |
697 | static inline struct sns_cmd_pkt * | |
698 | qla2x00_prep_sns_cmd(scsi_qla_host_t *ha, uint16_t cmd, uint16_t scmd_len, | |
699 | uint16_t data_size) | |
700 | { | |
701 | uint16_t wc; | |
702 | struct sns_cmd_pkt *sns_cmd; | |
703 | ||
704 | sns_cmd = ha->sns_cmd; | |
705 | memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt)); | |
706 | wc = data_size / 2; /* Size in 16bit words. */ | |
707 | sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc); | |
708 | sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma)); | |
709 | sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma)); | |
710 | sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len); | |
711 | sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd); | |
712 | wc = (data_size - 16) / 4; /* Size in 32bit words. */ | |
713 | sns_cmd->p.cmd.size = cpu_to_le16(wc); | |
714 | ||
715 | return (sns_cmd); | |
716 | } | |
717 | ||
718 | /** | |
719 | * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command. | |
720 | * @ha: HA context | |
721 | * @fcport: fcport entry to updated | |
722 | * | |
723 | * This command uses the old Exectute SNS Command mailbox routine. | |
724 | * | |
725 | * Returns 0 on success. | |
726 | */ | |
727 | static int | |
728 | qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) | |
729 | { | |
730 | int rval; | |
731 | ||
732 | struct sns_cmd_pkt *sns_cmd; | |
733 | ||
734 | /* Issue GA_NXT. */ | |
735 | /* Prepare SNS command request. */ | |
736 | sns_cmd = qla2x00_prep_sns_cmd(ha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN, | |
737 | GA_NXT_SNS_DATA_SIZE); | |
738 | ||
739 | /* Prepare SNS command arguments -- port_id. */ | |
740 | sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa; | |
741 | sns_cmd->p.cmd.param[1] = fcport->d_id.b.area; | |
742 | sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain; | |
743 | ||
744 | /* Execute SNS command. */ | |
745 | rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2, | |
746 | sizeof(struct sns_cmd_pkt)); | |
747 | if (rval != QLA_SUCCESS) { | |
748 | /*EMPTY*/ | |
749 | DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n", | |
750 | ha->host_no, rval)); | |
751 | } else if (sns_cmd->p.gan_data[8] != 0x80 || | |
752 | sns_cmd->p.gan_data[9] != 0x02) { | |
753 | DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, " | |
754 | "ga_nxt_rsp:\n", ha->host_no)); | |
755 | DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16)); | |
756 | rval = QLA_FUNCTION_FAILED; | |
757 | } else { | |
758 | /* Populate fc_port_t entry. */ | |
759 | fcport->d_id.b.domain = sns_cmd->p.gan_data[17]; | |
760 | fcport->d_id.b.area = sns_cmd->p.gan_data[18]; | |
761 | fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19]; | |
762 | ||
763 | memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE); | |
764 | memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE); | |
765 | ||
766 | if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE && | |
767 | sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE) | |
768 | fcport->d_id.b.domain = 0xf0; | |
769 | ||
770 | DEBUG2_3(printk("scsi(%ld): GA_NXT entry - " | |
771 | "nn %02x%02x%02x%02x%02x%02x%02x%02x " | |
772 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " | |
773 | "portid=%02x%02x%02x.\n", | |
774 | ha->host_no, | |
775 | fcport->node_name[0], fcport->node_name[1], | |
776 | fcport->node_name[2], fcport->node_name[3], | |
777 | fcport->node_name[4], fcport->node_name[5], | |
778 | fcport->node_name[6], fcport->node_name[7], | |
779 | fcport->port_name[0], fcport->port_name[1], | |
780 | fcport->port_name[2], fcport->port_name[3], | |
781 | fcport->port_name[4], fcport->port_name[5], | |
782 | fcport->port_name[6], fcport->port_name[7], | |
783 | fcport->d_id.b.domain, fcport->d_id.b.area, | |
784 | fcport->d_id.b.al_pa)); | |
785 | } | |
786 | ||
787 | return (rval); | |
788 | } | |
789 | ||
790 | /** | |
791 | * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command. | |
792 | * @ha: HA context | |
793 | * @list: switch info entries to populate | |
794 | * | |
795 | * This command uses the old Exectute SNS Command mailbox routine. | |
796 | * | |
797 | * NOTE: Non-Nx_Ports are not requested. | |
798 | * | |
799 | * Returns 0 on success. | |
800 | */ | |
801 | static int | |
802 | qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) | |
803 | { | |
804 | int rval; | |
805 | ||
806 | uint16_t i; | |
807 | uint8_t *entry; | |
808 | struct sns_cmd_pkt *sns_cmd; | |
809 | ||
810 | /* Issue GID_PT. */ | |
811 | /* Prepare SNS command request. */ | |
812 | sns_cmd = qla2x00_prep_sns_cmd(ha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN, | |
813 | GID_PT_SNS_DATA_SIZE); | |
814 | ||
815 | /* Prepare SNS command arguments -- port_type. */ | |
816 | sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE; | |
817 | ||
818 | /* Execute SNS command. */ | |
819 | rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2, | |
820 | sizeof(struct sns_cmd_pkt)); | |
821 | if (rval != QLA_SUCCESS) { | |
822 | /*EMPTY*/ | |
823 | DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n", | |
824 | ha->host_no, rval)); | |
825 | } else if (sns_cmd->p.gid_data[8] != 0x80 || | |
826 | sns_cmd->p.gid_data[9] != 0x02) { | |
827 | DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, " | |
828 | "gid_rsp:\n", ha->host_no)); | |
829 | DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16)); | |
830 | rval = QLA_FUNCTION_FAILED; | |
831 | } else { | |
832 | /* Set port IDs in switch info list. */ | |
833 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
834 | entry = &sns_cmd->p.gid_data[(i * 4) + 16]; | |
835 | list[i].d_id.b.domain = entry[1]; | |
836 | list[i].d_id.b.area = entry[2]; | |
837 | list[i].d_id.b.al_pa = entry[3]; | |
838 | ||
839 | /* Last one exit. */ | |
840 | if (entry[0] & BIT_7) { | |
841 | list[i].d_id.b.rsvd_1 = entry[0]; | |
842 | break; | |
843 | } | |
844 | } | |
845 | ||
846 | /* | |
847 | * If we've used all available slots, then the switch is | |
848 | * reporting back more devices that we can handle with this | |
849 | * single call. Return a failed status, and let GA_NXT handle | |
850 | * the overload. | |
851 | */ | |
fa2a1ce5 | 852 | if (i == MAX_FIBRE_DEVICES) |
1da177e4 LT |
853 | rval = QLA_FUNCTION_FAILED; |
854 | } | |
855 | ||
856 | return (rval); | |
857 | } | |
858 | ||
859 | /** | |
860 | * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query. | |
861 | * @ha: HA context | |
862 | * @list: switch info entries to populate | |
863 | * | |
864 | * This command uses the old Exectute SNS Command mailbox routine. | |
865 | * | |
866 | * Returns 0 on success. | |
867 | */ | |
868 | static int | |
869 | qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) | |
870 | { | |
871 | int rval; | |
872 | ||
873 | uint16_t i; | |
874 | struct sns_cmd_pkt *sns_cmd; | |
875 | ||
876 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
877 | /* Issue GPN_ID */ | |
878 | /* Prepare SNS command request. */ | |
879 | sns_cmd = qla2x00_prep_sns_cmd(ha, GPN_ID_CMD, | |
880 | GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE); | |
881 | ||
882 | /* Prepare SNS command arguments -- port_id. */ | |
883 | sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; | |
884 | sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; | |
885 | sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; | |
886 | ||
887 | /* Execute SNS command. */ | |
888 | rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, | |
889 | GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); | |
890 | if (rval != QLA_SUCCESS) { | |
891 | /*EMPTY*/ | |
892 | DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed " | |
893 | "(%d).\n", ha->host_no, rval)); | |
894 | } else if (sns_cmd->p.gpn_data[8] != 0x80 || | |
895 | sns_cmd->p.gpn_data[9] != 0x02) { | |
896 | DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected " | |
897 | "request, gpn_rsp:\n", ha->host_no)); | |
898 | DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16)); | |
899 | rval = QLA_FUNCTION_FAILED; | |
900 | } else { | |
901 | /* Save portname */ | |
902 | memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16], | |
903 | WWN_SIZE); | |
904 | } | |
905 | ||
906 | /* Last device exit. */ | |
907 | if (list[i].d_id.b.rsvd_1 != 0) | |
908 | break; | |
909 | } | |
910 | ||
911 | return (rval); | |
912 | } | |
913 | ||
914 | /** | |
915 | * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query. | |
916 | * @ha: HA context | |
917 | * @list: switch info entries to populate | |
918 | * | |
919 | * This command uses the old Exectute SNS Command mailbox routine. | |
920 | * | |
921 | * Returns 0 on success. | |
922 | */ | |
923 | static int | |
924 | qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list) | |
925 | { | |
926 | int rval; | |
927 | ||
928 | uint16_t i; | |
929 | struct sns_cmd_pkt *sns_cmd; | |
930 | ||
931 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
932 | /* Issue GNN_ID */ | |
933 | /* Prepare SNS command request. */ | |
934 | sns_cmd = qla2x00_prep_sns_cmd(ha, GNN_ID_CMD, | |
935 | GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE); | |
936 | ||
937 | /* Prepare SNS command arguments -- port_id. */ | |
938 | sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; | |
939 | sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; | |
940 | sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; | |
941 | ||
942 | /* Execute SNS command. */ | |
943 | rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, | |
944 | GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); | |
945 | if (rval != QLA_SUCCESS) { | |
946 | /*EMPTY*/ | |
947 | DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed " | |
948 | "(%d).\n", ha->host_no, rval)); | |
949 | } else if (sns_cmd->p.gnn_data[8] != 0x80 || | |
950 | sns_cmd->p.gnn_data[9] != 0x02) { | |
951 | DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected " | |
952 | "request, gnn_rsp:\n", ha->host_no)); | |
953 | DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16)); | |
954 | rval = QLA_FUNCTION_FAILED; | |
955 | } else { | |
956 | /* Save nodename */ | |
957 | memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16], | |
958 | WWN_SIZE); | |
959 | ||
960 | DEBUG2_3(printk("scsi(%ld): GID_PT entry - " | |
961 | "nn %02x%02x%02x%02x%02x%02x%02x%02x " | |
962 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " | |
963 | "portid=%02x%02x%02x.\n", | |
964 | ha->host_no, | |
965 | list[i].node_name[0], list[i].node_name[1], | |
966 | list[i].node_name[2], list[i].node_name[3], | |
967 | list[i].node_name[4], list[i].node_name[5], | |
968 | list[i].node_name[6], list[i].node_name[7], | |
969 | list[i].port_name[0], list[i].port_name[1], | |
970 | list[i].port_name[2], list[i].port_name[3], | |
971 | list[i].port_name[4], list[i].port_name[5], | |
972 | list[i].port_name[6], list[i].port_name[7], | |
973 | list[i].d_id.b.domain, list[i].d_id.b.area, | |
974 | list[i].d_id.b.al_pa)); | |
975 | } | |
976 | ||
977 | /* Last device exit. */ | |
978 | if (list[i].d_id.b.rsvd_1 != 0) | |
979 | break; | |
980 | } | |
981 | ||
982 | return (rval); | |
983 | } | |
984 | ||
985 | /** | |
986 | * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA. | |
987 | * @ha: HA context | |
988 | * | |
989 | * This command uses the old Exectute SNS Command mailbox routine. | |
990 | * | |
991 | * Returns 0 on success. | |
992 | */ | |
993 | static int | |
994 | qla2x00_sns_rft_id(scsi_qla_host_t *ha) | |
995 | { | |
996 | int rval; | |
997 | ||
998 | struct sns_cmd_pkt *sns_cmd; | |
999 | ||
1000 | /* Issue RFT_ID. */ | |
1001 | /* Prepare SNS command request. */ | |
1002 | sns_cmd = qla2x00_prep_sns_cmd(ha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN, | |
1003 | RFT_ID_SNS_DATA_SIZE); | |
1004 | ||
1005 | /* Prepare SNS command arguments -- port_id, FC-4 types */ | |
1006 | sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa; | |
1007 | sns_cmd->p.cmd.param[1] = ha->d_id.b.area; | |
1008 | sns_cmd->p.cmd.param[2] = ha->d_id.b.domain; | |
1009 | ||
1010 | sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */ | |
1011 | ||
1012 | /* Execute SNS command. */ | |
1013 | rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2, | |
1014 | sizeof(struct sns_cmd_pkt)); | |
1015 | if (rval != QLA_SUCCESS) { | |
1016 | /*EMPTY*/ | |
1017 | DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n", | |
1018 | ha->host_no, rval)); | |
1019 | } else if (sns_cmd->p.rft_data[8] != 0x80 || | |
1020 | sns_cmd->p.rft_data[9] != 0x02) { | |
1021 | DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, " | |
1022 | "rft_rsp:\n", ha->host_no)); | |
1023 | DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16)); | |
1024 | rval = QLA_FUNCTION_FAILED; | |
1025 | } else { | |
1026 | DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n", | |
1027 | ha->host_no)); | |
1028 | } | |
1029 | ||
1030 | return (rval); | |
1031 | } | |
1032 | ||
1033 | /** | |
1034 | * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. | |
1035 | * HBA. | |
1036 | * @ha: HA context | |
1037 | * | |
1038 | * This command uses the old Exectute SNS Command mailbox routine. | |
1039 | * | |
1040 | * Returns 0 on success. | |
1041 | */ | |
1042 | static int | |
1043 | qla2x00_sns_rnn_id(scsi_qla_host_t *ha) | |
1044 | { | |
1045 | int rval; | |
1046 | ||
1047 | struct sns_cmd_pkt *sns_cmd; | |
1048 | ||
1049 | /* Issue RNN_ID. */ | |
1050 | /* Prepare SNS command request. */ | |
1051 | sns_cmd = qla2x00_prep_sns_cmd(ha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN, | |
1052 | RNN_ID_SNS_DATA_SIZE); | |
1053 | ||
1054 | /* Prepare SNS command arguments -- port_id, nodename. */ | |
1055 | sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa; | |
1056 | sns_cmd->p.cmd.param[1] = ha->d_id.b.area; | |
1057 | sns_cmd->p.cmd.param[2] = ha->d_id.b.domain; | |
1058 | ||
8c958a99 AV |
1059 | sns_cmd->p.cmd.param[4] = ha->node_name[7]; |
1060 | sns_cmd->p.cmd.param[5] = ha->node_name[6]; | |
1061 | sns_cmd->p.cmd.param[6] = ha->node_name[5]; | |
1062 | sns_cmd->p.cmd.param[7] = ha->node_name[4]; | |
1063 | sns_cmd->p.cmd.param[8] = ha->node_name[3]; | |
1064 | sns_cmd->p.cmd.param[9] = ha->node_name[2]; | |
1065 | sns_cmd->p.cmd.param[10] = ha->node_name[1]; | |
1066 | sns_cmd->p.cmd.param[11] = ha->node_name[0]; | |
1da177e4 LT |
1067 | |
1068 | /* Execute SNS command. */ | |
1069 | rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2, | |
1070 | sizeof(struct sns_cmd_pkt)); | |
1071 | if (rval != QLA_SUCCESS) { | |
1072 | /*EMPTY*/ | |
1073 | DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n", | |
1074 | ha->host_no, rval)); | |
1075 | } else if (sns_cmd->p.rnn_data[8] != 0x80 || | |
1076 | sns_cmd->p.rnn_data[9] != 0x02) { | |
1077 | DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, " | |
1078 | "rnn_rsp:\n", ha->host_no)); | |
1079 | DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16)); | |
1080 | rval = QLA_FUNCTION_FAILED; | |
1081 | } else { | |
1082 | DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n", | |
1083 | ha->host_no)); | |
1084 | } | |
1085 | ||
1086 | return (rval); | |
1087 | } | |
cca5335c AV |
1088 | |
1089 | /** | |
1090 | * qla2x00_mgmt_svr_login() - Login to fabric Managment Service. | |
1091 | * @ha: HA context | |
1092 | * | |
1093 | * Returns 0 on success. | |
1094 | */ | |
1095 | static int | |
1096 | qla2x00_mgmt_svr_login(scsi_qla_host_t *ha) | |
1097 | { | |
1098 | int ret; | |
1099 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | |
1100 | ||
1101 | ret = QLA_SUCCESS; | |
1102 | if (ha->flags.management_server_logged_in) | |
1103 | return ret; | |
1104 | ||
1105 | ha->isp_ops.fabric_login(ha, ha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa, | |
1106 | mb, BIT_1); | |
1107 | if (mb[0] != MBS_COMMAND_COMPLETE) { | |
1108 | DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: " | |
1109 | "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n", | |
1110 | __func__, ha->host_no, ha->mgmt_svr_loop_id, mb[0], mb[1], | |
1111 | mb[2], mb[6], mb[7])); | |
1112 | ret = QLA_FUNCTION_FAILED; | |
1113 | } else | |
1114 | ha->flags.management_server_logged_in = 1; | |
1115 | ||
1116 | return ret; | |
1117 | } | |
1118 | ||
1119 | /** | |
1120 | * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. | |
1121 | * @ha: HA context | |
1122 | * @req_size: request size in bytes | |
1123 | * @rsp_size: response size in bytes | |
1124 | * | |
1125 | * Returns a pointer to the @ha's ms_iocb. | |
1126 | */ | |
1127 | void * | |
1128 | qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size, | |
1129 | uint32_t rsp_size) | |
1130 | { | |
1131 | ms_iocb_entry_t *ms_pkt; | |
1132 | ||
1133 | ms_pkt = ha->ms_iocb; | |
1134 | memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); | |
1135 | ||
1136 | ms_pkt->entry_type = MS_IOCB_TYPE; | |
1137 | ms_pkt->entry_count = 1; | |
1138 | SET_TARGET_ID(ha, ms_pkt->loop_id, ha->mgmt_svr_loop_id); | |
1139 | ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG); | |
1140 | ms_pkt->timeout = __constant_cpu_to_le16(59); | |
1141 | ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); | |
1142 | ms_pkt->total_dsd_count = __constant_cpu_to_le16(2); | |
1143 | ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); | |
1144 | ms_pkt->req_bytecount = cpu_to_le32(req_size); | |
1145 | ||
1146 | ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1147 | ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1148 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; | |
1149 | ||
1150 | ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1151 | ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1152 | ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; | |
1153 | ||
1154 | return ms_pkt; | |
1155 | } | |
1156 | ||
1157 | /** | |
1158 | * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. | |
1159 | * @ha: HA context | |
1160 | * @req_size: request size in bytes | |
1161 | * @rsp_size: response size in bytes | |
1162 | * | |
1163 | * Returns a pointer to the @ha's ms_iocb. | |
1164 | */ | |
1165 | void * | |
1166 | qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size, | |
1167 | uint32_t rsp_size) | |
1168 | { | |
1169 | struct ct_entry_24xx *ct_pkt; | |
1170 | ||
1171 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; | |
1172 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); | |
1173 | ||
1174 | ct_pkt->entry_type = CT_IOCB_TYPE; | |
1175 | ct_pkt->entry_count = 1; | |
1176 | ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id); | |
1177 | ct_pkt->timeout = __constant_cpu_to_le16(59); | |
1178 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); | |
1179 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); | |
1180 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); | |
1181 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); | |
1182 | ||
1183 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1184 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1185 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; | |
1186 | ||
1187 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1188 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1189 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; | |
2c3dfe3f | 1190 | ct_pkt->vp_index = ha->vp_idx; |
cca5335c AV |
1191 | |
1192 | return ct_pkt; | |
1193 | } | |
1194 | ||
1195 | static inline ms_iocb_entry_t * | |
1196 | qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size) | |
1197 | { | |
1198 | ms_iocb_entry_t *ms_pkt = ha->ms_iocb; | |
1199 | struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; | |
1200 | ||
e428924c | 1201 | if (IS_FWI2_CAPABLE(ha)) { |
cca5335c AV |
1202 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
1203 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; | |
1204 | } else { | |
1205 | ms_pkt->req_bytecount = cpu_to_le32(req_size); | |
1206 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; | |
1207 | } | |
1208 | ||
1209 | return ms_pkt; | |
1210 | } | |
1211 | ||
1212 | /** | |
1213 | * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. | |
1214 | * @ct_req: CT request buffer | |
1215 | * @cmd: GS command | |
1216 | * @rsp_size: response size in bytes | |
1217 | * | |
1218 | * Returns a pointer to the intitialized @ct_req. | |
1219 | */ | |
1220 | static inline struct ct_sns_req * | |
1221 | qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd, | |
1222 | uint16_t rsp_size) | |
1223 | { | |
1224 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); | |
1225 | ||
1226 | ct_req->header.revision = 0x01; | |
1227 | ct_req->header.gs_type = 0xFA; | |
1228 | ct_req->header.gs_subtype = 0x10; | |
1229 | ct_req->command = cpu_to_be16(cmd); | |
1230 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); | |
1231 | ||
1232 | return ct_req; | |
1233 | } | |
1234 | ||
1235 | /** | |
1236 | * qla2x00_fdmi_rhba() - | |
1237 | * @ha: HA context | |
1238 | * | |
1239 | * Returns 0 on success. | |
1240 | */ | |
1241 | static int | |
1242 | qla2x00_fdmi_rhba(scsi_qla_host_t *ha) | |
1243 | { | |
1244 | int rval, alen; | |
1245 | uint32_t size, sn; | |
1246 | ||
1247 | ms_iocb_entry_t *ms_pkt; | |
1248 | struct ct_sns_req *ct_req; | |
1249 | struct ct_sns_rsp *ct_rsp; | |
1250 | uint8_t *entries; | |
1251 | struct ct_fdmi_hba_attr *eiter; | |
1252 | ||
1253 | /* Issue RHBA */ | |
1254 | /* Prepare common MS IOCB */ | |
1255 | /* Request size adjusted after CT preparation */ | |
1256 | ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE); | |
1257 | ||
1258 | /* Prepare CT request */ | |
1259 | ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, | |
1260 | RHBA_RSP_SIZE); | |
1261 | ct_rsp = &ha->ct_sns->p.rsp; | |
1262 | ||
1263 | /* Prepare FDMI command arguments -- attribute block, attributes. */ | |
1264 | memcpy(ct_req->req.rhba.hba_identifier, ha->port_name, WWN_SIZE); | |
1265 | ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); | |
1266 | memcpy(ct_req->req.rhba.port_name, ha->port_name, WWN_SIZE); | |
1267 | size = 2 * WWN_SIZE + 4 + 4; | |
1268 | ||
1269 | /* Attributes */ | |
1270 | ct_req->req.rhba.attrs.count = | |
1271 | __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); | |
1272 | entries = ct_req->req.rhba.hba_identifier; | |
1273 | ||
1274 | /* Nodename. */ | |
1275 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1276 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); | |
1277 | eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); | |
1278 | memcpy(eiter->a.node_name, ha->node_name, WWN_SIZE); | |
1279 | size += 4 + WWN_SIZE; | |
1280 | ||
1281 | DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n", | |
1282 | __func__, ha->host_no, | |
1283 | eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], | |
1284 | eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], | |
1285 | eiter->a.node_name[6], eiter->a.node_name[7])); | |
1286 | ||
1287 | /* Manufacturer. */ | |
1288 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1289 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); | |
1290 | strcpy(eiter->a.manufacturer, "QLogic Corporation"); | |
1291 | alen = strlen(eiter->a.manufacturer); | |
1292 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1293 | eiter->len = cpu_to_be16(4 + alen); | |
1294 | size += 4 + alen; | |
1295 | ||
1296 | DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, ha->host_no, | |
1297 | eiter->a.manufacturer)); | |
1298 | ||
1299 | /* Serial number. */ | |
1300 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1301 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); | |
1302 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; | |
1303 | sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); | |
1304 | alen = strlen(eiter->a.serial_num); | |
1305 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1306 | eiter->len = cpu_to_be16(4 + alen); | |
1307 | size += 4 + alen; | |
1308 | ||
1309 | DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, ha->host_no, | |
1310 | eiter->a.serial_num)); | |
1311 | ||
1312 | /* Model name. */ | |
1313 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1314 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); | |
1315 | strcpy(eiter->a.model, ha->model_number); | |
1316 | alen = strlen(eiter->a.model); | |
1317 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1318 | eiter->len = cpu_to_be16(4 + alen); | |
1319 | size += 4 + alen; | |
1320 | ||
1321 | DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, ha->host_no, | |
1322 | eiter->a.model)); | |
1323 | ||
1324 | /* Model description. */ | |
1325 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1326 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); | |
1327 | if (ha->model_desc) | |
1328 | strncpy(eiter->a.model_desc, ha->model_desc, 80); | |
1329 | alen = strlen(eiter->a.model_desc); | |
1330 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1331 | eiter->len = cpu_to_be16(4 + alen); | |
1332 | size += 4 + alen; | |
1333 | ||
1334 | DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, ha->host_no, | |
1335 | eiter->a.model_desc)); | |
1336 | ||
1337 | /* Hardware version. */ | |
1338 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1339 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); | |
1340 | strcpy(eiter->a.hw_version, ha->adapter_id); | |
1341 | alen = strlen(eiter->a.hw_version); | |
1342 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1343 | eiter->len = cpu_to_be16(4 + alen); | |
1344 | size += 4 + alen; | |
1345 | ||
1346 | DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, ha->host_no, | |
1347 | eiter->a.hw_version)); | |
1348 | ||
1349 | /* Driver version. */ | |
1350 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1351 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION); | |
1352 | strcpy(eiter->a.driver_version, qla2x00_version_str); | |
1353 | alen = strlen(eiter->a.driver_version); | |
1354 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1355 | eiter->len = cpu_to_be16(4 + alen); | |
1356 | size += 4 + alen; | |
1357 | ||
1358 | DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, ha->host_no, | |
1359 | eiter->a.driver_version)); | |
1360 | ||
1361 | /* Option ROM version. */ | |
1362 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1363 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); | |
1364 | strcpy(eiter->a.orom_version, "0.00"); | |
1365 | alen = strlen(eiter->a.orom_version); | |
1366 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1367 | eiter->len = cpu_to_be16(4 + alen); | |
1368 | size += 4 + alen; | |
1369 | ||
1370 | DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, ha->host_no, | |
1371 | eiter->a.orom_version)); | |
1372 | ||
1373 | /* Firmware version */ | |
1374 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); | |
1375 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); | |
1376 | ha->isp_ops.fw_version_str(ha, eiter->a.fw_version); | |
1377 | alen = strlen(eiter->a.fw_version); | |
1378 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1379 | eiter->len = cpu_to_be16(4 + alen); | |
1380 | size += 4 + alen; | |
1381 | ||
1382 | DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, ha->host_no, | |
1383 | eiter->a.fw_version)); | |
1384 | ||
1385 | /* Update MS request size. */ | |
1386 | qla2x00_update_ms_fdmi_iocb(ha, size + 16); | |
1387 | ||
1388 | DEBUG13(printk("%s(%ld): RHBA identifier=" | |
1389 | "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, | |
1390 | ha->host_no, ct_req->req.rhba.hba_identifier[0], | |
1391 | ct_req->req.rhba.hba_identifier[1], | |
1392 | ct_req->req.rhba.hba_identifier[2], | |
1393 | ct_req->req.rhba.hba_identifier[3], | |
1394 | ct_req->req.rhba.hba_identifier[4], | |
1395 | ct_req->req.rhba.hba_identifier[5], | |
1396 | ct_req->req.rhba.hba_identifier[6], | |
1397 | ct_req->req.rhba.hba_identifier[7], size)); | |
1398 | DEBUG13(qla2x00_dump_buffer(entries, size)); | |
1399 | ||
1400 | /* Execute MS IOCB */ | |
1401 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1402 | sizeof(ms_iocb_entry_t)); | |
1403 | if (rval != QLA_SUCCESS) { | |
1404 | /*EMPTY*/ | |
1405 | DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n", | |
1406 | ha->host_no, rval)); | |
1407 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RHBA") != | |
1408 | QLA_SUCCESS) { | |
1409 | rval = QLA_FUNCTION_FAILED; | |
1410 | if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && | |
1411 | ct_rsp->header.explanation_code == | |
1412 | CT_EXPL_ALREADY_REGISTERED) { | |
1413 | DEBUG2_13(printk("%s(%ld): HBA already registered.\n", | |
1414 | __func__, ha->host_no)); | |
1415 | rval = QLA_ALREADY_REGISTERED; | |
1416 | } | |
1417 | } else { | |
1418 | DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n", | |
1419 | ha->host_no)); | |
1420 | } | |
1421 | ||
1422 | return rval; | |
1423 | } | |
1424 | ||
1425 | /** | |
1426 | * qla2x00_fdmi_dhba() - | |
1427 | * @ha: HA context | |
1428 | * | |
1429 | * Returns 0 on success. | |
1430 | */ | |
1431 | static int | |
1432 | qla2x00_fdmi_dhba(scsi_qla_host_t *ha) | |
1433 | { | |
1434 | int rval; | |
1435 | ||
1436 | ms_iocb_entry_t *ms_pkt; | |
1437 | struct ct_sns_req *ct_req; | |
1438 | struct ct_sns_rsp *ct_rsp; | |
1439 | ||
1440 | /* Issue RPA */ | |
1441 | /* Prepare common MS IOCB */ | |
1442 | ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE, | |
1443 | DHBA_RSP_SIZE); | |
1444 | ||
1445 | /* Prepare CT request */ | |
1446 | ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD, | |
1447 | DHBA_RSP_SIZE); | |
1448 | ct_rsp = &ha->ct_sns->p.rsp; | |
1449 | ||
1450 | /* Prepare FDMI command arguments -- portname. */ | |
1451 | memcpy(ct_req->req.dhba.port_name, ha->port_name, WWN_SIZE); | |
1452 | ||
1453 | DEBUG13(printk("%s(%ld): DHBA portname=" | |
1454 | "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no, | |
1455 | ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1], | |
1456 | ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3], | |
1457 | ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5], | |
1458 | ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7])); | |
1459 | ||
1460 | /* Execute MS IOCB */ | |
1461 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1462 | sizeof(ms_iocb_entry_t)); | |
1463 | if (rval != QLA_SUCCESS) { | |
1464 | /*EMPTY*/ | |
1465 | DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n", | |
1466 | ha->host_no, rval)); | |
1467 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "DHBA") != | |
1468 | QLA_SUCCESS) { | |
1469 | rval = QLA_FUNCTION_FAILED; | |
1470 | } else { | |
1471 | DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n", | |
1472 | ha->host_no)); | |
1473 | } | |
1474 | ||
1475 | return rval; | |
1476 | } | |
1477 | ||
1478 | /** | |
1479 | * qla2x00_fdmi_rpa() - | |
1480 | * @ha: HA context | |
1481 | * | |
1482 | * Returns 0 on success. | |
1483 | */ | |
1484 | static int | |
1485 | qla2x00_fdmi_rpa(scsi_qla_host_t *ha) | |
1486 | { | |
1487 | int rval, alen; | |
1488 | uint32_t size, max_frame_size; | |
1489 | ||
1490 | ms_iocb_entry_t *ms_pkt; | |
1491 | struct ct_sns_req *ct_req; | |
1492 | struct ct_sns_rsp *ct_rsp; | |
1493 | uint8_t *entries; | |
1494 | struct ct_fdmi_port_attr *eiter; | |
1495 | struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; | |
1496 | ||
1497 | /* Issue RPA */ | |
1498 | /* Prepare common MS IOCB */ | |
1499 | /* Request size adjusted after CT preparation */ | |
1500 | ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE); | |
1501 | ||
1502 | /* Prepare CT request */ | |
1503 | ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, | |
1504 | RPA_RSP_SIZE); | |
1505 | ct_rsp = &ha->ct_sns->p.rsp; | |
1506 | ||
1507 | /* Prepare FDMI command arguments -- attribute block, attributes. */ | |
1508 | memcpy(ct_req->req.rpa.port_name, ha->port_name, WWN_SIZE); | |
1509 | size = WWN_SIZE + 4; | |
1510 | ||
1511 | /* Attributes */ | |
1512 | ct_req->req.rpa.attrs.count = | |
1513 | __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); | |
1514 | entries = ct_req->req.rpa.port_name; | |
1515 | ||
1516 | /* FC4 types. */ | |
1517 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1518 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES); | |
1519 | eiter->len = __constant_cpu_to_be16(4 + 32); | |
1520 | eiter->a.fc4_types[2] = 0x01; | |
1521 | size += 4 + 32; | |
1522 | ||
1523 | DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__, ha->host_no, | |
1524 | eiter->a.fc4_types[2], eiter->a.fc4_types[1])); | |
1525 | ||
1526 | /* Supported speed. */ | |
1527 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1528 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); | |
1529 | eiter->len = __constant_cpu_to_be16(4 + 4); | |
044cc6c8 | 1530 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) |
c0eb8755 | 1531 | eiter->a.sup_speed = __constant_cpu_to_be32(4); |
cca5335c AV |
1532 | else if (IS_QLA23XX(ha)) |
1533 | eiter->a.sup_speed = __constant_cpu_to_be32(2); | |
1534 | else | |
1535 | eiter->a.sup_speed = __constant_cpu_to_be32(1); | |
1536 | size += 4 + 4; | |
1537 | ||
1538 | DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, | |
1539 | eiter->a.sup_speed)); | |
1540 | ||
1541 | /* Current speed. */ | |
1542 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1543 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); | |
1544 | eiter->len = __constant_cpu_to_be16(4 + 4); | |
1545 | switch (ha->link_data_rate) { | |
1546 | case 0: | |
1547 | eiter->a.cur_speed = __constant_cpu_to_be32(1); | |
1548 | break; | |
1549 | case 1: | |
1550 | eiter->a.cur_speed = __constant_cpu_to_be32(2); | |
1551 | break; | |
1552 | case 3: | |
cca5335c AV |
1553 | eiter->a.cur_speed = __constant_cpu_to_be32(4); |
1554 | break; | |
1555 | } | |
1556 | size += 4 + 4; | |
1557 | ||
1558 | DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no, | |
1559 | eiter->a.cur_speed)); | |
1560 | ||
1561 | /* Max frame size. */ | |
1562 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1563 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); | |
1564 | eiter->len = __constant_cpu_to_be16(4 + 4); | |
e428924c | 1565 | max_frame_size = IS_FWI2_CAPABLE(ha) ? |
cca5335c AV |
1566 | (uint32_t) icb24->frame_payload_size: |
1567 | (uint32_t) ha->init_cb->frame_payload_size; | |
1568 | eiter->a.max_frame_size = cpu_to_be32(max_frame_size); | |
1569 | size += 4 + 4; | |
1570 | ||
1571 | DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no, | |
1572 | eiter->a.max_frame_size)); | |
1573 | ||
1574 | /* OS device name. */ | |
1575 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1576 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); | |
1577 | sprintf(eiter->a.os_dev_name, "/proc/scsi/qla2xxx/%ld", ha->host_no); | |
1578 | alen = strlen(eiter->a.os_dev_name); | |
1579 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1580 | eiter->len = cpu_to_be16(4 + alen); | |
1581 | size += 4 + alen; | |
1582 | ||
1583 | DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no, | |
1584 | eiter->a.os_dev_name)); | |
1585 | ||
a740a3f0 AV |
1586 | /* Hostname. */ |
1587 | if (strlen(fc_host_system_hostname(ha->host))) { | |
1588 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1589 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME); | |
1590 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), | |
1591 | "%s", fc_host_system_hostname(ha->host)); | |
1592 | alen = strlen(eiter->a.host_name); | |
1593 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1594 | eiter->len = cpu_to_be16(4 + alen); | |
1595 | size += 4 + alen; | |
1596 | ||
1597 | DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__, | |
1598 | ha->host_no, eiter->a.host_name)); | |
1599 | } | |
1600 | ||
cca5335c AV |
1601 | /* Update MS request size. */ |
1602 | qla2x00_update_ms_fdmi_iocb(ha, size + 16); | |
1603 | ||
1604 | DEBUG13(printk("%s(%ld): RPA portname=" | |
1605 | "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, | |
1606 | ha->host_no, ct_req->req.rpa.port_name[0], | |
1607 | ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], | |
1608 | ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], | |
1609 | ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], | |
1610 | ct_req->req.rpa.port_name[7], size)); | |
1611 | DEBUG13(qla2x00_dump_buffer(entries, size)); | |
1612 | ||
1613 | /* Execute MS IOCB */ | |
1614 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1615 | sizeof(ms_iocb_entry_t)); | |
1616 | if (rval != QLA_SUCCESS) { | |
1617 | /*EMPTY*/ | |
1618 | DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n", | |
1619 | ha->host_no, rval)); | |
1620 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") != | |
1621 | QLA_SUCCESS) { | |
1622 | rval = QLA_FUNCTION_FAILED; | |
1623 | } else { | |
1624 | DEBUG2(printk("scsi(%ld): RPA exiting normally.\n", | |
1625 | ha->host_no)); | |
1626 | } | |
1627 | ||
1628 | return rval; | |
1629 | } | |
1630 | ||
1631 | /** | |
1632 | * qla2x00_fdmi_register() - | |
1633 | * @ha: HA context | |
1634 | * | |
1635 | * Returns 0 on success. | |
1636 | */ | |
1637 | int | |
1638 | qla2x00_fdmi_register(scsi_qla_host_t *ha) | |
1639 | { | |
1640 | int rval; | |
1641 | ||
1642 | rval = qla2x00_mgmt_svr_login(ha); | |
1643 | if (rval) | |
1644 | return rval; | |
1645 | ||
1646 | rval = qla2x00_fdmi_rhba(ha); | |
1647 | if (rval) { | |
1648 | if (rval != QLA_ALREADY_REGISTERED) | |
1649 | return rval; | |
1650 | ||
1651 | rval = qla2x00_fdmi_dhba(ha); | |
1652 | if (rval) | |
1653 | return rval; | |
1654 | ||
1655 | rval = qla2x00_fdmi_rhba(ha); | |
1656 | if (rval) | |
1657 | return rval; | |
1658 | } | |
1659 | rval = qla2x00_fdmi_rpa(ha); | |
1660 | ||
1661 | return rval; | |
1662 | } | |
d8b45213 AV |
1663 | |
1664 | /** | |
1665 | * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query. | |
1666 | * @ha: HA context | |
1667 | * @list: switch info entries to populate | |
1668 | * | |
1669 | * Returns 0 on success. | |
1670 | */ | |
1671 | int | |
1672 | qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list) | |
1673 | { | |
1674 | int rval; | |
1675 | uint16_t i; | |
1676 | ||
1677 | ms_iocb_entry_t *ms_pkt; | |
1678 | struct ct_sns_req *ct_req; | |
1679 | struct ct_sns_rsp *ct_rsp; | |
1680 | ||
e428924c | 1681 | if (!IS_FWI2_CAPABLE(ha)) |
d8b45213 AV |
1682 | return QLA_FUNCTION_FAILED; |
1683 | ||
1684 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
1685 | /* Issue GFPN_ID */ | |
1686 | memset(list[i].fabric_port_name, 0, WWN_SIZE); | |
1687 | ||
1688 | /* Prepare common MS IOCB */ | |
71ea9949 | 1689 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GFPN_ID_REQ_SIZE, |
d8b45213 AV |
1690 | GFPN_ID_RSP_SIZE); |
1691 | ||
1692 | /* Prepare CT request */ | |
1693 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD, | |
1694 | GFPN_ID_RSP_SIZE); | |
1695 | ct_rsp = &ha->ct_sns->p.rsp; | |
1696 | ||
1697 | /* Prepare CT arguments -- port_id */ | |
1698 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; | |
1699 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; | |
1700 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; | |
1701 | ||
1702 | /* Execute MS IOCB */ | |
1703 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1704 | sizeof(ms_iocb_entry_t)); | |
1705 | if (rval != QLA_SUCCESS) { | |
1706 | /*EMPTY*/ | |
1707 | DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB " | |
1708 | "failed (%d).\n", ha->host_no, rval)); | |
1709 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, | |
1710 | "GFPN_ID") != QLA_SUCCESS) { | |
1711 | rval = QLA_FUNCTION_FAILED; | |
1712 | } else { | |
1713 | /* Save fabric portname */ | |
1714 | memcpy(list[i].fabric_port_name, | |
1715 | ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE); | |
1716 | } | |
1717 | ||
1718 | /* Last device exit. */ | |
1719 | if (list[i].d_id.b.rsvd_1 != 0) | |
1720 | break; | |
1721 | } | |
1722 | ||
1723 | return (rval); | |
1724 | } | |
1725 | ||
1726 | static inline void * | |
1727 | qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *ha, uint32_t req_size, | |
1728 | uint32_t rsp_size) | |
1729 | { | |
1730 | struct ct_entry_24xx *ct_pkt; | |
1731 | ||
1732 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; | |
1733 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); | |
1734 | ||
1735 | ct_pkt->entry_type = CT_IOCB_TYPE; | |
1736 | ct_pkt->entry_count = 1; | |
1737 | ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id); | |
1738 | ct_pkt->timeout = __constant_cpu_to_le16(59); | |
1739 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); | |
1740 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); | |
1741 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); | |
1742 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); | |
1743 | ||
1744 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1745 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1746 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; | |
1747 | ||
1748 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1749 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1750 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; | |
2c3dfe3f | 1751 | ct_pkt->vp_index = ha->vp_idx; |
d8b45213 AV |
1752 | |
1753 | return ct_pkt; | |
1754 | } | |
1755 | ||
1756 | ||
1757 | static inline struct ct_sns_req * | |
1758 | qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd, | |
1759 | uint16_t rsp_size) | |
1760 | { | |
1761 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); | |
1762 | ||
1763 | ct_req->header.revision = 0x01; | |
1764 | ct_req->header.gs_type = 0xFA; | |
1765 | ct_req->header.gs_subtype = 0x01; | |
1766 | ct_req->command = cpu_to_be16(cmd); | |
1767 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); | |
1768 | ||
1769 | return ct_req; | |
1770 | } | |
1771 | ||
1772 | /** | |
1773 | * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query. | |
1774 | * @ha: HA context | |
1775 | * @list: switch info entries to populate | |
1776 | * | |
1777 | * Returns 0 on success. | |
1778 | */ | |
1779 | int | |
1780 | qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list) | |
1781 | { | |
1782 | int rval; | |
1783 | uint16_t i; | |
1784 | ||
1785 | ms_iocb_entry_t *ms_pkt; | |
1786 | struct ct_sns_req *ct_req; | |
1787 | struct ct_sns_rsp *ct_rsp; | |
1788 | ||
e428924c | 1789 | if (!IS_FWI2_CAPABLE(ha)) |
d8b45213 | 1790 | return QLA_FUNCTION_FAILED; |
4346b149 AV |
1791 | if (!ha->flags.gpsc_supported) |
1792 | return QLA_FUNCTION_FAILED; | |
d8b45213 AV |
1793 | |
1794 | rval = qla2x00_mgmt_svr_login(ha); | |
1795 | if (rval) | |
1796 | return rval; | |
1797 | ||
1798 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
1799 | /* Issue GFPN_ID */ | |
1800 | list[i].fp_speeds = list[i].fp_speed = 0; | |
1801 | ||
1802 | /* Prepare common MS IOCB */ | |
1803 | ms_pkt = qla24xx_prep_ms_fm_iocb(ha, GPSC_REQ_SIZE, | |
1804 | GPSC_RSP_SIZE); | |
1805 | ||
1806 | /* Prepare CT request */ | |
1807 | ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req, | |
1808 | GPSC_CMD, GPSC_RSP_SIZE); | |
1809 | ct_rsp = &ha->ct_sns->p.rsp; | |
1810 | ||
1811 | /* Prepare CT arguments -- port_name */ | |
1812 | memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name, | |
1813 | WWN_SIZE); | |
1814 | ||
1815 | /* Execute MS IOCB */ | |
1816 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1817 | sizeof(ms_iocb_entry_t)); | |
1818 | if (rval != QLA_SUCCESS) { | |
1819 | /*EMPTY*/ | |
1820 | DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB " | |
1821 | "failed (%d).\n", ha->host_no, rval)); | |
4346b149 AV |
1822 | } else if ((rval = qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, |
1823 | "GPSC")) != QLA_SUCCESS) { | |
1824 | /* FM command unsupported? */ | |
1825 | if (rval == QLA_INVALID_COMMAND && | |
1826 | ct_rsp->header.reason_code == | |
1827 | CT_REASON_INVALID_COMMAND_CODE) { | |
1828 | DEBUG2(printk("scsi(%ld): GPSC command " | |
1829 | "unsupported, disabling query...\n", | |
1830 | ha->host_no)); | |
1831 | ha->flags.gpsc_supported = 0; | |
1832 | rval = QLA_FUNCTION_FAILED; | |
1833 | break; | |
1834 | } | |
d8b45213 AV |
1835 | rval = QLA_FUNCTION_FAILED; |
1836 | } else { | |
1837 | /* Save portname */ | |
1838 | list[i].fp_speeds = ct_rsp->rsp.gpsc.speeds; | |
1839 | list[i].fp_speed = ct_rsp->rsp.gpsc.speed; | |
1840 | ||
1841 | DEBUG2_3(printk("scsi(%ld): GPSC ext entry - " | |
1842 | "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x " | |
1843 | "speed=%04x.\n", ha->host_no, | |
1844 | list[i].fabric_port_name[0], | |
1845 | list[i].fabric_port_name[1], | |
1846 | list[i].fabric_port_name[2], | |
1847 | list[i].fabric_port_name[3], | |
1848 | list[i].fabric_port_name[4], | |
1849 | list[i].fabric_port_name[5], | |
1850 | list[i].fabric_port_name[6], | |
1851 | list[i].fabric_port_name[7], | |
1852 | be16_to_cpu(list[i].fp_speeds), | |
1853 | be16_to_cpu(list[i].fp_speed))); | |
1854 | } | |
1855 | ||
1856 | /* Last device exit. */ | |
1857 | if (list[i].d_id.b.rsvd_1 != 0) | |
1858 | break; | |
1859 | } | |
1860 | ||
1861 | return (rval); | |
1862 | } |