]>
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)) |
5881569b AV |
1531 | eiter->a.sup_speed = __constant_cpu_to_be32( |
1532 | FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB| | |
1533 | FDMI_PORT_SPEED_4GB); | |
cca5335c | 1534 | else if (IS_QLA23XX(ha)) |
5881569b AV |
1535 | eiter->a.sup_speed =__constant_cpu_to_be32( |
1536 | FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB); | |
cca5335c | 1537 | else |
5881569b AV |
1538 | eiter->a.sup_speed = __constant_cpu_to_be32( |
1539 | FDMI_PORT_SPEED_1GB); | |
cca5335c AV |
1540 | size += 4 + 4; |
1541 | ||
1542 | DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, | |
1543 | eiter->a.sup_speed)); | |
1544 | ||
1545 | /* Current speed. */ | |
1546 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1547 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); | |
1548 | eiter->len = __constant_cpu_to_be16(4 + 4); | |
1549 | switch (ha->link_data_rate) { | |
5881569b AV |
1550 | case PORT_SPEED_1GB: |
1551 | eiter->a.cur_speed = | |
1552 | __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB); | |
cca5335c | 1553 | break; |
5881569b AV |
1554 | case PORT_SPEED_2GB: |
1555 | eiter->a.cur_speed = | |
1556 | __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB); | |
cca5335c | 1557 | break; |
5881569b AV |
1558 | case PORT_SPEED_4GB: |
1559 | eiter->a.cur_speed = | |
1560 | __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB); | |
1561 | break; | |
1562 | default: | |
1563 | eiter->a.cur_speed = | |
1564 | __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN); | |
cca5335c AV |
1565 | break; |
1566 | } | |
1567 | size += 4 + 4; | |
1568 | ||
1569 | DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no, | |
1570 | eiter->a.cur_speed)); | |
1571 | ||
1572 | /* Max frame size. */ | |
1573 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1574 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); | |
1575 | eiter->len = __constant_cpu_to_be16(4 + 4); | |
e428924c | 1576 | max_frame_size = IS_FWI2_CAPABLE(ha) ? |
cca5335c AV |
1577 | (uint32_t) icb24->frame_payload_size: |
1578 | (uint32_t) ha->init_cb->frame_payload_size; | |
1579 | eiter->a.max_frame_size = cpu_to_be32(max_frame_size); | |
1580 | size += 4 + 4; | |
1581 | ||
1582 | DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no, | |
1583 | eiter->a.max_frame_size)); | |
1584 | ||
1585 | /* OS device name. */ | |
1586 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1587 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); | |
1588 | sprintf(eiter->a.os_dev_name, "/proc/scsi/qla2xxx/%ld", ha->host_no); | |
1589 | alen = strlen(eiter->a.os_dev_name); | |
1590 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1591 | eiter->len = cpu_to_be16(4 + alen); | |
1592 | size += 4 + alen; | |
1593 | ||
1594 | DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no, | |
1595 | eiter->a.os_dev_name)); | |
1596 | ||
a740a3f0 AV |
1597 | /* Hostname. */ |
1598 | if (strlen(fc_host_system_hostname(ha->host))) { | |
1599 | eiter = (struct ct_fdmi_port_attr *) (entries + size); | |
1600 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME); | |
1601 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), | |
1602 | "%s", fc_host_system_hostname(ha->host)); | |
1603 | alen = strlen(eiter->a.host_name); | |
1604 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; | |
1605 | eiter->len = cpu_to_be16(4 + alen); | |
1606 | size += 4 + alen; | |
1607 | ||
1608 | DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__, | |
1609 | ha->host_no, eiter->a.host_name)); | |
1610 | } | |
1611 | ||
cca5335c AV |
1612 | /* Update MS request size. */ |
1613 | qla2x00_update_ms_fdmi_iocb(ha, size + 16); | |
1614 | ||
1615 | DEBUG13(printk("%s(%ld): RPA portname=" | |
1616 | "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, | |
1617 | ha->host_no, ct_req->req.rpa.port_name[0], | |
1618 | ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], | |
1619 | ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], | |
1620 | ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], | |
1621 | ct_req->req.rpa.port_name[7], size)); | |
1622 | DEBUG13(qla2x00_dump_buffer(entries, size)); | |
1623 | ||
1624 | /* Execute MS IOCB */ | |
1625 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1626 | sizeof(ms_iocb_entry_t)); | |
1627 | if (rval != QLA_SUCCESS) { | |
1628 | /*EMPTY*/ | |
1629 | DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n", | |
1630 | ha->host_no, rval)); | |
1631 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") != | |
1632 | QLA_SUCCESS) { | |
1633 | rval = QLA_FUNCTION_FAILED; | |
1634 | } else { | |
1635 | DEBUG2(printk("scsi(%ld): RPA exiting normally.\n", | |
1636 | ha->host_no)); | |
1637 | } | |
1638 | ||
1639 | return rval; | |
1640 | } | |
1641 | ||
1642 | /** | |
1643 | * qla2x00_fdmi_register() - | |
1644 | * @ha: HA context | |
1645 | * | |
1646 | * Returns 0 on success. | |
1647 | */ | |
1648 | int | |
1649 | qla2x00_fdmi_register(scsi_qla_host_t *ha) | |
1650 | { | |
1651 | int rval; | |
1652 | ||
1653 | rval = qla2x00_mgmt_svr_login(ha); | |
1654 | if (rval) | |
1655 | return rval; | |
1656 | ||
1657 | rval = qla2x00_fdmi_rhba(ha); | |
1658 | if (rval) { | |
1659 | if (rval != QLA_ALREADY_REGISTERED) | |
1660 | return rval; | |
1661 | ||
1662 | rval = qla2x00_fdmi_dhba(ha); | |
1663 | if (rval) | |
1664 | return rval; | |
1665 | ||
1666 | rval = qla2x00_fdmi_rhba(ha); | |
1667 | if (rval) | |
1668 | return rval; | |
1669 | } | |
1670 | rval = qla2x00_fdmi_rpa(ha); | |
1671 | ||
1672 | return rval; | |
1673 | } | |
d8b45213 AV |
1674 | |
1675 | /** | |
1676 | * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query. | |
1677 | * @ha: HA context | |
1678 | * @list: switch info entries to populate | |
1679 | * | |
1680 | * Returns 0 on success. | |
1681 | */ | |
1682 | int | |
1683 | qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list) | |
1684 | { | |
1685 | int rval; | |
1686 | uint16_t i; | |
1687 | ||
1688 | ms_iocb_entry_t *ms_pkt; | |
1689 | struct ct_sns_req *ct_req; | |
1690 | struct ct_sns_rsp *ct_rsp; | |
1691 | ||
c76f2c01 | 1692 | if (!IS_IIDMA_CAPABLE(ha)) |
d8b45213 AV |
1693 | return QLA_FUNCTION_FAILED; |
1694 | ||
1695 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
1696 | /* Issue GFPN_ID */ | |
1697 | memset(list[i].fabric_port_name, 0, WWN_SIZE); | |
1698 | ||
1699 | /* Prepare common MS IOCB */ | |
71ea9949 | 1700 | ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GFPN_ID_REQ_SIZE, |
d8b45213 AV |
1701 | GFPN_ID_RSP_SIZE); |
1702 | ||
1703 | /* Prepare CT request */ | |
1704 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD, | |
1705 | GFPN_ID_RSP_SIZE); | |
1706 | ct_rsp = &ha->ct_sns->p.rsp; | |
1707 | ||
1708 | /* Prepare CT arguments -- port_id */ | |
1709 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; | |
1710 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; | |
1711 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; | |
1712 | ||
1713 | /* Execute MS IOCB */ | |
1714 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1715 | sizeof(ms_iocb_entry_t)); | |
1716 | if (rval != QLA_SUCCESS) { | |
1717 | /*EMPTY*/ | |
1718 | DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB " | |
1719 | "failed (%d).\n", ha->host_no, rval)); | |
1720 | } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, | |
1721 | "GFPN_ID") != QLA_SUCCESS) { | |
1722 | rval = QLA_FUNCTION_FAILED; | |
1723 | } else { | |
1724 | /* Save fabric portname */ | |
1725 | memcpy(list[i].fabric_port_name, | |
1726 | ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE); | |
1727 | } | |
1728 | ||
1729 | /* Last device exit. */ | |
1730 | if (list[i].d_id.b.rsvd_1 != 0) | |
1731 | break; | |
1732 | } | |
1733 | ||
1734 | return (rval); | |
1735 | } | |
1736 | ||
1737 | static inline void * | |
1738 | qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *ha, uint32_t req_size, | |
1739 | uint32_t rsp_size) | |
1740 | { | |
1741 | struct ct_entry_24xx *ct_pkt; | |
1742 | ||
1743 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; | |
1744 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); | |
1745 | ||
1746 | ct_pkt->entry_type = CT_IOCB_TYPE; | |
1747 | ct_pkt->entry_count = 1; | |
1748 | ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id); | |
1749 | ct_pkt->timeout = __constant_cpu_to_le16(59); | |
1750 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); | |
1751 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); | |
1752 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); | |
1753 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); | |
1754 | ||
1755 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1756 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1757 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; | |
1758 | ||
1759 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); | |
1760 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); | |
1761 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; | |
2c3dfe3f | 1762 | ct_pkt->vp_index = ha->vp_idx; |
d8b45213 AV |
1763 | |
1764 | return ct_pkt; | |
1765 | } | |
1766 | ||
1767 | ||
1768 | static inline struct ct_sns_req * | |
1769 | qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd, | |
1770 | uint16_t rsp_size) | |
1771 | { | |
1772 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); | |
1773 | ||
1774 | ct_req->header.revision = 0x01; | |
1775 | ct_req->header.gs_type = 0xFA; | |
1776 | ct_req->header.gs_subtype = 0x01; | |
1777 | ct_req->command = cpu_to_be16(cmd); | |
1778 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); | |
1779 | ||
1780 | return ct_req; | |
1781 | } | |
1782 | ||
1783 | /** | |
1784 | * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query. | |
1785 | * @ha: HA context | |
1786 | * @list: switch info entries to populate | |
1787 | * | |
1788 | * Returns 0 on success. | |
1789 | */ | |
1790 | int | |
1791 | qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list) | |
1792 | { | |
1793 | int rval; | |
1794 | uint16_t i; | |
1795 | ||
1796 | ms_iocb_entry_t *ms_pkt; | |
1797 | struct ct_sns_req *ct_req; | |
1798 | struct ct_sns_rsp *ct_rsp; | |
1799 | ||
c76f2c01 | 1800 | if (!IS_IIDMA_CAPABLE(ha)) |
d8b45213 | 1801 | return QLA_FUNCTION_FAILED; |
4346b149 AV |
1802 | if (!ha->flags.gpsc_supported) |
1803 | return QLA_FUNCTION_FAILED; | |
d8b45213 AV |
1804 | |
1805 | rval = qla2x00_mgmt_svr_login(ha); | |
1806 | if (rval) | |
1807 | return rval; | |
1808 | ||
1809 | for (i = 0; i < MAX_FIBRE_DEVICES; i++) { | |
1810 | /* Issue GFPN_ID */ | |
1811 | list[i].fp_speeds = list[i].fp_speed = 0; | |
1812 | ||
1813 | /* Prepare common MS IOCB */ | |
1814 | ms_pkt = qla24xx_prep_ms_fm_iocb(ha, GPSC_REQ_SIZE, | |
1815 | GPSC_RSP_SIZE); | |
1816 | ||
1817 | /* Prepare CT request */ | |
1818 | ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req, | |
1819 | GPSC_CMD, GPSC_RSP_SIZE); | |
1820 | ct_rsp = &ha->ct_sns->p.rsp; | |
1821 | ||
1822 | /* Prepare CT arguments -- port_name */ | |
1823 | memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name, | |
1824 | WWN_SIZE); | |
1825 | ||
1826 | /* Execute MS IOCB */ | |
1827 | rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, | |
1828 | sizeof(ms_iocb_entry_t)); | |
1829 | if (rval != QLA_SUCCESS) { | |
1830 | /*EMPTY*/ | |
1831 | DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB " | |
1832 | "failed (%d).\n", ha->host_no, rval)); | |
4346b149 AV |
1833 | } else if ((rval = qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, |
1834 | "GPSC")) != QLA_SUCCESS) { | |
1835 | /* FM command unsupported? */ | |
1836 | if (rval == QLA_INVALID_COMMAND && | |
1837 | ct_rsp->header.reason_code == | |
1838 | CT_REASON_INVALID_COMMAND_CODE) { | |
1839 | DEBUG2(printk("scsi(%ld): GPSC command " | |
1840 | "unsupported, disabling query...\n", | |
1841 | ha->host_no)); | |
1842 | ha->flags.gpsc_supported = 0; | |
1843 | rval = QLA_FUNCTION_FAILED; | |
1844 | break; | |
1845 | } | |
d8b45213 AV |
1846 | rval = QLA_FUNCTION_FAILED; |
1847 | } else { | |
1848 | /* Save portname */ | |
1849 | list[i].fp_speeds = ct_rsp->rsp.gpsc.speeds; | |
1850 | list[i].fp_speed = ct_rsp->rsp.gpsc.speed; | |
1851 | ||
1852 | DEBUG2_3(printk("scsi(%ld): GPSC ext entry - " | |
1853 | "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x " | |
1854 | "speed=%04x.\n", ha->host_no, | |
1855 | list[i].fabric_port_name[0], | |
1856 | list[i].fabric_port_name[1], | |
1857 | list[i].fabric_port_name[2], | |
1858 | list[i].fabric_port_name[3], | |
1859 | list[i].fabric_port_name[4], | |
1860 | list[i].fabric_port_name[5], | |
1861 | list[i].fabric_port_name[6], | |
1862 | list[i].fabric_port_name[7], | |
1863 | be16_to_cpu(list[i].fp_speeds), | |
1864 | be16_to_cpu(list[i].fp_speed))); | |
1865 | } | |
1866 | ||
1867 | /* Last device exit. */ | |
1868 | if (list[i].d_id.b.rsvd_1 != 0) | |
1869 | break; | |
1870 | } | |
1871 | ||
1872 | return (rval); | |
1873 | } |