2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 static inline struct ct_sns_req
*
10 qla2x00_prep_ct_req(struct ct_sns_req
*, uint16_t, uint16_t);
12 static inline struct sns_cmd_pkt
*
13 qla2x00_prep_sns_cmd(scsi_qla_host_t
*, uint16_t, uint16_t, uint16_t);
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
*);
23 * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
25 * @req_size: request size in bytes
26 * @rsp_size: response size in bytes
28 * Returns a pointer to the @ha's ms_iocb.
31 qla2x00_prep_ms_iocb(scsi_qla_host_t
*ha
, uint32_t req_size
, uint32_t rsp_size
)
33 ms_iocb_entry_t
*ms_pkt
;
36 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
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
);
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
;
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
;
60 * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
62 * @req_size: request size in bytes
63 * @rsp_size: response size in bytes
65 * Returns a pointer to the @ha's ms_iocb.
68 qla24xx_prep_ms_iocb(scsi_qla_host_t
*ha
, uint32_t req_size
, uint32_t rsp_size
)
70 struct ct_entry_24xx
*ct_pkt
;
72 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
73 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
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
);
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
;
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
;
91 ct_pkt
->vp_index
= ha
->vp_idx
;
97 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
98 * @ct_req: CT request buffer
100 * @rsp_size: response size in bytes
102 * Returns a pointer to the intitialized @ct_req.
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
)
107 memset(ct_req
, 0, sizeof(struct ct_sns_pkt
));
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);
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
)
123 uint16_t comp_status
;
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
));
130 if (IS_FWI2_CAPABLE(ha
))
131 comp_status
= le16_to_cpu(
132 ((struct ct_entry_24xx
*)ms_pkt
)->comp_status
);
134 comp_status
= le16_to_cpu(ms_pkt
->status
);
135 switch (comp_status
) {
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
,
144 DEBUG2_3(qla2x00_dump_buffer(
145 (uint8_t *)&ct_rsp
->header
,
146 sizeof(struct ct_rsp_hdr
)));
147 rval
= QLA_INVALID_COMMAND
;
152 DEBUG2_3(printk("scsi(%ld): %s failed, completion "
153 "status (%x).\n", ha
->host_no
, routine
,
162 * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
164 * @fcport: fcport entry to updated
166 * Returns 0 on success.
169 qla2x00_ga_nxt(scsi_qla_host_t
*ha
, fc_port_t
*fcport
)
173 ms_iocb_entry_t
*ms_pkt
;
174 struct ct_sns_req
*ct_req
;
175 struct ct_sns_rsp
*ct_rsp
;
177 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
178 return (qla2x00_sns_ga_nxt(ha
, fcport
));
182 /* Prepare common MS IOCB */
183 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, GA_NXT_REQ_SIZE
,
186 /* Prepare CT request */
187 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GA_NXT_CMD
,
189 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
191 /* Prepare CT arguments -- port_id */
192 ct_req
->req
.port_id
.port_id
[0] = fcport
->d_id
.b
.domain
;
193 ct_req
->req
.port_id
.port_id
[1] = fcport
->d_id
.b
.area
;
194 ct_req
->req
.port_id
.port_id
[2] = fcport
->d_id
.b
.al_pa
;
196 /* Execute MS IOCB */
197 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
198 sizeof(ms_iocb_entry_t
));
199 if (rval
!= QLA_SUCCESS
) {
201 DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
203 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "GA_NXT") !=
205 rval
= QLA_FUNCTION_FAILED
;
207 /* Populate fc_port_t entry. */
208 fcport
->d_id
.b
.domain
= ct_rsp
->rsp
.ga_nxt
.port_id
[0];
209 fcport
->d_id
.b
.area
= ct_rsp
->rsp
.ga_nxt
.port_id
[1];
210 fcport
->d_id
.b
.al_pa
= ct_rsp
->rsp
.ga_nxt
.port_id
[2];
212 memcpy(fcport
->node_name
, ct_rsp
->rsp
.ga_nxt
.node_name
,
214 memcpy(fcport
->port_name
, ct_rsp
->rsp
.ga_nxt
.port_name
,
217 if (ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_N_PORT_TYPE
&&
218 ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_NL_PORT_TYPE
)
219 fcport
->d_id
.b
.domain
= 0xf0;
221 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
222 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
223 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
224 "portid=%02x%02x%02x.\n",
226 fcport
->node_name
[0], fcport
->node_name
[1],
227 fcport
->node_name
[2], fcport
->node_name
[3],
228 fcport
->node_name
[4], fcport
->node_name
[5],
229 fcport
->node_name
[6], fcport
->node_name
[7],
230 fcport
->port_name
[0], fcport
->port_name
[1],
231 fcport
->port_name
[2], fcport
->port_name
[3],
232 fcport
->port_name
[4], fcport
->port_name
[5],
233 fcport
->port_name
[6], fcport
->port_name
[7],
234 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
235 fcport
->d_id
.b
.al_pa
));
242 * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
244 * @list: switch info entries to populate
246 * NOTE: Non-Nx_Ports are not requested.
248 * Returns 0 on success.
251 qla2x00_gid_pt(scsi_qla_host_t
*ha
, sw_info_t
*list
)
256 ms_iocb_entry_t
*ms_pkt
;
257 struct ct_sns_req
*ct_req
;
258 struct ct_sns_rsp
*ct_rsp
;
260 struct ct_sns_gid_pt_data
*gid_data
;
262 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
263 return (qla2x00_sns_gid_pt(ha
, list
));
269 /* Prepare common MS IOCB */
270 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, GID_PT_REQ_SIZE
,
273 /* Prepare CT request */
274 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GID_PT_CMD
,
276 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
278 /* Prepare CT arguments -- port_type */
279 ct_req
->req
.gid_pt
.port_type
= NS_NX_PORT_TYPE
;
281 /* Execute MS IOCB */
282 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
283 sizeof(ms_iocb_entry_t
));
284 if (rval
!= QLA_SUCCESS
) {
286 DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
288 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "GID_PT") !=
290 rval
= QLA_FUNCTION_FAILED
;
292 /* Set port IDs in switch info list. */
293 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
294 gid_data
= &ct_rsp
->rsp
.gid_pt
.entries
[i
];
295 list
[i
].d_id
.b
.domain
= gid_data
->port_id
[0];
296 list
[i
].d_id
.b
.area
= gid_data
->port_id
[1];
297 list
[i
].d_id
.b
.al_pa
= gid_data
->port_id
[2];
298 memset(list
[i
].fabric_port_name
, 0, WWN_SIZE
);
299 list
[i
].fp_speed
= PORT_SPEED_UNKNOWN
;
302 if (gid_data
->control_byte
& BIT_7
) {
303 list
[i
].d_id
.b
.rsvd_1
= gid_data
->control_byte
;
309 * If we've used all available slots, then the switch is
310 * reporting back more devices than we can handle with this
311 * single call. Return a failed status, and let GA_NXT handle
314 if (i
== MAX_FIBRE_DEVICES
)
315 rval
= QLA_FUNCTION_FAILED
;
322 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
324 * @list: switch info entries to populate
326 * Returns 0 on success.
329 qla2x00_gpn_id(scsi_qla_host_t
*ha
, sw_info_t
*list
)
334 ms_iocb_entry_t
*ms_pkt
;
335 struct ct_sns_req
*ct_req
;
336 struct ct_sns_rsp
*ct_rsp
;
338 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
339 return (qla2x00_sns_gpn_id(ha
, list
));
342 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
344 /* Prepare common MS IOCB */
345 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, GPN_ID_REQ_SIZE
,
348 /* Prepare CT request */
349 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GPN_ID_CMD
,
351 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
353 /* Prepare CT arguments -- port_id */
354 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
355 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
356 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
358 /* Execute MS IOCB */
359 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
360 sizeof(ms_iocb_entry_t
));
361 if (rval
!= QLA_SUCCESS
) {
363 DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
364 "(%d).\n", ha
->host_no
, rval
));
365 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
,
366 "GPN_ID") != QLA_SUCCESS
) {
367 rval
= QLA_FUNCTION_FAILED
;
370 memcpy(list
[i
].port_name
,
371 ct_rsp
->rsp
.gpn_id
.port_name
, WWN_SIZE
);
374 /* Last device exit. */
375 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
383 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
385 * @list: switch info entries to populate
387 * Returns 0 on success.
390 qla2x00_gnn_id(scsi_qla_host_t
*ha
, sw_info_t
*list
)
395 ms_iocb_entry_t
*ms_pkt
;
396 struct ct_sns_req
*ct_req
;
397 struct ct_sns_rsp
*ct_rsp
;
399 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
400 return (qla2x00_sns_gnn_id(ha
, list
));
403 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
405 /* Prepare common MS IOCB */
406 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, GNN_ID_REQ_SIZE
,
409 /* Prepare CT request */
410 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GNN_ID_CMD
,
412 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
414 /* Prepare CT arguments -- port_id */
415 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
416 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
417 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
419 /* Execute MS IOCB */
420 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
421 sizeof(ms_iocb_entry_t
));
422 if (rval
!= QLA_SUCCESS
) {
424 DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
425 "(%d).\n", ha
->host_no
, rval
));
426 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
,
427 "GNN_ID") != QLA_SUCCESS
) {
428 rval
= QLA_FUNCTION_FAILED
;
431 memcpy(list
[i
].node_name
,
432 ct_rsp
->rsp
.gnn_id
.node_name
, WWN_SIZE
);
434 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
435 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
436 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
437 "portid=%02x%02x%02x.\n",
439 list
[i
].node_name
[0], list
[i
].node_name
[1],
440 list
[i
].node_name
[2], list
[i
].node_name
[3],
441 list
[i
].node_name
[4], list
[i
].node_name
[5],
442 list
[i
].node_name
[6], list
[i
].node_name
[7],
443 list
[i
].port_name
[0], list
[i
].port_name
[1],
444 list
[i
].port_name
[2], list
[i
].port_name
[3],
445 list
[i
].port_name
[4], list
[i
].port_name
[5],
446 list
[i
].port_name
[6], list
[i
].port_name
[7],
447 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
448 list
[i
].d_id
.b
.al_pa
));
451 /* Last device exit. */
452 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
460 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
463 * Returns 0 on success.
466 qla2x00_rft_id(scsi_qla_host_t
*ha
)
470 ms_iocb_entry_t
*ms_pkt
;
471 struct ct_sns_req
*ct_req
;
472 struct ct_sns_rsp
*ct_rsp
;
474 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
475 return (qla2x00_sns_rft_id(ha
));
479 /* Prepare common MS IOCB */
480 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, RFT_ID_REQ_SIZE
,
483 /* Prepare CT request */
484 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RFT_ID_CMD
,
486 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
488 /* Prepare CT arguments -- port_id, FC-4 types */
489 ct_req
->req
.rft_id
.port_id
[0] = ha
->d_id
.b
.domain
;
490 ct_req
->req
.rft_id
.port_id
[1] = ha
->d_id
.b
.area
;
491 ct_req
->req
.rft_id
.port_id
[2] = ha
->d_id
.b
.al_pa
;
493 ct_req
->req
.rft_id
.fc4_types
[2] = 0x01; /* FCP-3 */
495 /* Execute MS IOCB */
496 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
497 sizeof(ms_iocb_entry_t
));
498 if (rval
!= QLA_SUCCESS
) {
500 DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
502 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "RFT_ID") !=
504 rval
= QLA_FUNCTION_FAILED
;
506 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
514 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
517 * Returns 0 on success.
520 qla2x00_rff_id(scsi_qla_host_t
*ha
)
524 ms_iocb_entry_t
*ms_pkt
;
525 struct ct_sns_req
*ct_req
;
526 struct ct_sns_rsp
*ct_rsp
;
528 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
529 DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
530 "ISP2100/ISP2200.\n", ha
->host_no
));
531 return (QLA_SUCCESS
);
535 /* Prepare common MS IOCB */
536 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, RFF_ID_REQ_SIZE
,
539 /* Prepare CT request */
540 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RFF_ID_CMD
,
542 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
544 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
545 ct_req
->req
.rff_id
.port_id
[0] = ha
->d_id
.b
.domain
;
546 ct_req
->req
.rff_id
.port_id
[1] = ha
->d_id
.b
.area
;
547 ct_req
->req
.rff_id
.port_id
[2] = ha
->d_id
.b
.al_pa
;
549 ct_req
->req
.rff_id
.fc4_feature
= BIT_1
;
550 ct_req
->req
.rff_id
.fc4_type
= 0x08; /* SCSI - FCP */
552 /* Execute MS IOCB */
553 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
554 sizeof(ms_iocb_entry_t
));
555 if (rval
!= QLA_SUCCESS
) {
557 DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
559 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "RFF_ID") !=
561 rval
= QLA_FUNCTION_FAILED
;
563 DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
571 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
574 * Returns 0 on success.
577 qla2x00_rnn_id(scsi_qla_host_t
*ha
)
581 ms_iocb_entry_t
*ms_pkt
;
582 struct ct_sns_req
*ct_req
;
583 struct ct_sns_rsp
*ct_rsp
;
585 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
586 return (qla2x00_sns_rnn_id(ha
));
590 /* Prepare common MS IOCB */
591 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, RNN_ID_REQ_SIZE
,
594 /* Prepare CT request */
595 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RNN_ID_CMD
,
597 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
599 /* Prepare CT arguments -- port_id, node_name */
600 ct_req
->req
.rnn_id
.port_id
[0] = ha
->d_id
.b
.domain
;
601 ct_req
->req
.rnn_id
.port_id
[1] = ha
->d_id
.b
.area
;
602 ct_req
->req
.rnn_id
.port_id
[2] = ha
->d_id
.b
.al_pa
;
604 memcpy(ct_req
->req
.rnn_id
.node_name
, ha
->node_name
, WWN_SIZE
);
606 /* Execute MS IOCB */
607 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
608 sizeof(ms_iocb_entry_t
));
609 if (rval
!= QLA_SUCCESS
) {
611 DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
613 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "RNN_ID") !=
615 rval
= QLA_FUNCTION_FAILED
;
617 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
625 qla2x00_get_sym_node_name(scsi_qla_host_t
*ha
, uint8_t *snn
)
627 sprintf(snn
, "%s FW:v%d.%02d.%02d DVR:v%s",ha
->model_number
,
628 ha
->fw_major_version
, ha
->fw_minor_version
,
629 ha
->fw_subminor_version
, qla2x00_version_str
);
633 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
636 * Returns 0 on success.
639 qla2x00_rsnn_nn(scsi_qla_host_t
*ha
)
642 ms_iocb_entry_t
*ms_pkt
;
643 struct ct_sns_req
*ct_req
;
644 struct ct_sns_rsp
*ct_rsp
;
646 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
647 DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
648 "ISP2100/ISP2200.\n", ha
->host_no
));
649 return (QLA_SUCCESS
);
653 /* Prepare common MS IOCB */
654 /* Request size adjusted after CT preparation */
655 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, 0, RSNN_NN_RSP_SIZE
);
657 /* Prepare CT request */
658 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RSNN_NN_CMD
,
660 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
662 /* Prepare CT arguments -- node_name, symbolic node_name, size */
663 memcpy(ct_req
->req
.rsnn_nn
.node_name
, ha
->node_name
, WWN_SIZE
);
665 /* Prepare the Symbolic Node Name */
666 qla2x00_get_sym_node_name(ha
, ct_req
->req
.rsnn_nn
.sym_node_name
);
668 /* Calculate SNN length */
669 ct_req
->req
.rsnn_nn
.name_len
=
670 (uint8_t)strlen(ct_req
->req
.rsnn_nn
.sym_node_name
);
672 /* Update MS IOCB request */
673 ms_pkt
->req_bytecount
=
674 cpu_to_le32(24 + 1 + ct_req
->req
.rsnn_nn
.name_len
);
675 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
677 /* Execute MS IOCB */
678 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
679 sizeof(ms_iocb_entry_t
));
680 if (rval
!= QLA_SUCCESS
) {
682 DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
684 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "RSNN_NN") !=
686 rval
= QLA_FUNCTION_FAILED
;
688 DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
696 * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
699 * @scmd_len: Subcommand length
700 * @data_size: response size in bytes
702 * Returns a pointer to the @ha's sns_cmd.
704 static inline struct sns_cmd_pkt
*
705 qla2x00_prep_sns_cmd(scsi_qla_host_t
*ha
, uint16_t cmd
, uint16_t scmd_len
,
709 struct sns_cmd_pkt
*sns_cmd
;
711 sns_cmd
= ha
->sns_cmd
;
712 memset(sns_cmd
, 0, sizeof(struct sns_cmd_pkt
));
713 wc
= data_size
/ 2; /* Size in 16bit words. */
714 sns_cmd
->p
.cmd
.buffer_length
= cpu_to_le16(wc
);
715 sns_cmd
->p
.cmd
.buffer_address
[0] = cpu_to_le32(LSD(ha
->sns_cmd_dma
));
716 sns_cmd
->p
.cmd
.buffer_address
[1] = cpu_to_le32(MSD(ha
->sns_cmd_dma
));
717 sns_cmd
->p
.cmd
.subcommand_length
= cpu_to_le16(scmd_len
);
718 sns_cmd
->p
.cmd
.subcommand
= cpu_to_le16(cmd
);
719 wc
= (data_size
- 16) / 4; /* Size in 32bit words. */
720 sns_cmd
->p
.cmd
.size
= cpu_to_le16(wc
);
726 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
728 * @fcport: fcport entry to updated
730 * This command uses the old Exectute SNS Command mailbox routine.
732 * Returns 0 on success.
735 qla2x00_sns_ga_nxt(scsi_qla_host_t
*ha
, fc_port_t
*fcport
)
739 struct sns_cmd_pkt
*sns_cmd
;
742 /* Prepare SNS command request. */
743 sns_cmd
= qla2x00_prep_sns_cmd(ha
, GA_NXT_CMD
, GA_NXT_SNS_SCMD_LEN
,
744 GA_NXT_SNS_DATA_SIZE
);
746 /* Prepare SNS command arguments -- port_id. */
747 sns_cmd
->p
.cmd
.param
[0] = fcport
->d_id
.b
.al_pa
;
748 sns_cmd
->p
.cmd
.param
[1] = fcport
->d_id
.b
.area
;
749 sns_cmd
->p
.cmd
.param
[2] = fcport
->d_id
.b
.domain
;
751 /* Execute SNS command. */
752 rval
= qla2x00_send_sns(ha
, ha
->sns_cmd_dma
, GA_NXT_SNS_CMD_SIZE
/ 2,
753 sizeof(struct sns_cmd_pkt
));
754 if (rval
!= QLA_SUCCESS
) {
756 DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
758 } else if (sns_cmd
->p
.gan_data
[8] != 0x80 ||
759 sns_cmd
->p
.gan_data
[9] != 0x02) {
760 DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
761 "ga_nxt_rsp:\n", ha
->host_no
));
762 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gan_data
, 16));
763 rval
= QLA_FUNCTION_FAILED
;
765 /* Populate fc_port_t entry. */
766 fcport
->d_id
.b
.domain
= sns_cmd
->p
.gan_data
[17];
767 fcport
->d_id
.b
.area
= sns_cmd
->p
.gan_data
[18];
768 fcport
->d_id
.b
.al_pa
= sns_cmd
->p
.gan_data
[19];
770 memcpy(fcport
->node_name
, &sns_cmd
->p
.gan_data
[284], WWN_SIZE
);
771 memcpy(fcport
->port_name
, &sns_cmd
->p
.gan_data
[20], WWN_SIZE
);
773 if (sns_cmd
->p
.gan_data
[16] != NS_N_PORT_TYPE
&&
774 sns_cmd
->p
.gan_data
[16] != NS_NL_PORT_TYPE
)
775 fcport
->d_id
.b
.domain
= 0xf0;
777 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
778 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
779 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
780 "portid=%02x%02x%02x.\n",
782 fcport
->node_name
[0], fcport
->node_name
[1],
783 fcport
->node_name
[2], fcport
->node_name
[3],
784 fcport
->node_name
[4], fcport
->node_name
[5],
785 fcport
->node_name
[6], fcport
->node_name
[7],
786 fcport
->port_name
[0], fcport
->port_name
[1],
787 fcport
->port_name
[2], fcport
->port_name
[3],
788 fcport
->port_name
[4], fcport
->port_name
[5],
789 fcport
->port_name
[6], fcport
->port_name
[7],
790 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
791 fcport
->d_id
.b
.al_pa
));
798 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
800 * @list: switch info entries to populate
802 * This command uses the old Exectute SNS Command mailbox routine.
804 * NOTE: Non-Nx_Ports are not requested.
806 * Returns 0 on success.
809 qla2x00_sns_gid_pt(scsi_qla_host_t
*ha
, sw_info_t
*list
)
815 struct sns_cmd_pkt
*sns_cmd
;
818 /* Prepare SNS command request. */
819 sns_cmd
= qla2x00_prep_sns_cmd(ha
, GID_PT_CMD
, GID_PT_SNS_SCMD_LEN
,
820 GID_PT_SNS_DATA_SIZE
);
822 /* Prepare SNS command arguments -- port_type. */
823 sns_cmd
->p
.cmd
.param
[0] = NS_NX_PORT_TYPE
;
825 /* Execute SNS command. */
826 rval
= qla2x00_send_sns(ha
, ha
->sns_cmd_dma
, GID_PT_SNS_CMD_SIZE
/ 2,
827 sizeof(struct sns_cmd_pkt
));
828 if (rval
!= QLA_SUCCESS
) {
830 DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
832 } else if (sns_cmd
->p
.gid_data
[8] != 0x80 ||
833 sns_cmd
->p
.gid_data
[9] != 0x02) {
834 DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
835 "gid_rsp:\n", ha
->host_no
));
836 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gid_data
, 16));
837 rval
= QLA_FUNCTION_FAILED
;
839 /* Set port IDs in switch info list. */
840 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
841 entry
= &sns_cmd
->p
.gid_data
[(i
* 4) + 16];
842 list
[i
].d_id
.b
.domain
= entry
[1];
843 list
[i
].d_id
.b
.area
= entry
[2];
844 list
[i
].d_id
.b
.al_pa
= entry
[3];
847 if (entry
[0] & BIT_7
) {
848 list
[i
].d_id
.b
.rsvd_1
= entry
[0];
854 * If we've used all available slots, then the switch is
855 * reporting back more devices that we can handle with this
856 * single call. Return a failed status, and let GA_NXT handle
859 if (i
== MAX_FIBRE_DEVICES
)
860 rval
= QLA_FUNCTION_FAILED
;
867 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
869 * @list: switch info entries to populate
871 * This command uses the old Exectute SNS Command mailbox routine.
873 * Returns 0 on success.
876 qla2x00_sns_gpn_id(scsi_qla_host_t
*ha
, sw_info_t
*list
)
881 struct sns_cmd_pkt
*sns_cmd
;
883 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
885 /* Prepare SNS command request. */
886 sns_cmd
= qla2x00_prep_sns_cmd(ha
, GPN_ID_CMD
,
887 GPN_ID_SNS_SCMD_LEN
, GPN_ID_SNS_DATA_SIZE
);
889 /* Prepare SNS command arguments -- port_id. */
890 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
891 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
892 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
894 /* Execute SNS command. */
895 rval
= qla2x00_send_sns(ha
, ha
->sns_cmd_dma
,
896 GPN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
897 if (rval
!= QLA_SUCCESS
) {
899 DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
900 "(%d).\n", ha
->host_no
, rval
));
901 } else if (sns_cmd
->p
.gpn_data
[8] != 0x80 ||
902 sns_cmd
->p
.gpn_data
[9] != 0x02) {
903 DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
904 "request, gpn_rsp:\n", ha
->host_no
));
905 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gpn_data
, 16));
906 rval
= QLA_FUNCTION_FAILED
;
909 memcpy(list
[i
].port_name
, &sns_cmd
->p
.gpn_data
[16],
913 /* Last device exit. */
914 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
922 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
924 * @list: switch info entries to populate
926 * This command uses the old Exectute SNS Command mailbox routine.
928 * Returns 0 on success.
931 qla2x00_sns_gnn_id(scsi_qla_host_t
*ha
, sw_info_t
*list
)
936 struct sns_cmd_pkt
*sns_cmd
;
938 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
940 /* Prepare SNS command request. */
941 sns_cmd
= qla2x00_prep_sns_cmd(ha
, GNN_ID_CMD
,
942 GNN_ID_SNS_SCMD_LEN
, GNN_ID_SNS_DATA_SIZE
);
944 /* Prepare SNS command arguments -- port_id. */
945 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
946 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
947 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
949 /* Execute SNS command. */
950 rval
= qla2x00_send_sns(ha
, ha
->sns_cmd_dma
,
951 GNN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
952 if (rval
!= QLA_SUCCESS
) {
954 DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
955 "(%d).\n", ha
->host_no
, rval
));
956 } else if (sns_cmd
->p
.gnn_data
[8] != 0x80 ||
957 sns_cmd
->p
.gnn_data
[9] != 0x02) {
958 DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
959 "request, gnn_rsp:\n", ha
->host_no
));
960 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gnn_data
, 16));
961 rval
= QLA_FUNCTION_FAILED
;
964 memcpy(list
[i
].node_name
, &sns_cmd
->p
.gnn_data
[16],
967 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
968 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
969 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
970 "portid=%02x%02x%02x.\n",
972 list
[i
].node_name
[0], list
[i
].node_name
[1],
973 list
[i
].node_name
[2], list
[i
].node_name
[3],
974 list
[i
].node_name
[4], list
[i
].node_name
[5],
975 list
[i
].node_name
[6], list
[i
].node_name
[7],
976 list
[i
].port_name
[0], list
[i
].port_name
[1],
977 list
[i
].port_name
[2], list
[i
].port_name
[3],
978 list
[i
].port_name
[4], list
[i
].port_name
[5],
979 list
[i
].port_name
[6], list
[i
].port_name
[7],
980 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
981 list
[i
].d_id
.b
.al_pa
));
984 /* Last device exit. */
985 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
993 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
996 * This command uses the old Exectute SNS Command mailbox routine.
998 * Returns 0 on success.
1001 qla2x00_sns_rft_id(scsi_qla_host_t
*ha
)
1005 struct sns_cmd_pkt
*sns_cmd
;
1008 /* Prepare SNS command request. */
1009 sns_cmd
= qla2x00_prep_sns_cmd(ha
, RFT_ID_CMD
, RFT_ID_SNS_SCMD_LEN
,
1010 RFT_ID_SNS_DATA_SIZE
);
1012 /* Prepare SNS command arguments -- port_id, FC-4 types */
1013 sns_cmd
->p
.cmd
.param
[0] = ha
->d_id
.b
.al_pa
;
1014 sns_cmd
->p
.cmd
.param
[1] = ha
->d_id
.b
.area
;
1015 sns_cmd
->p
.cmd
.param
[2] = ha
->d_id
.b
.domain
;
1017 sns_cmd
->p
.cmd
.param
[5] = 0x01; /* FCP-3 */
1019 /* Execute SNS command. */
1020 rval
= qla2x00_send_sns(ha
, ha
->sns_cmd_dma
, RFT_ID_SNS_CMD_SIZE
/ 2,
1021 sizeof(struct sns_cmd_pkt
));
1022 if (rval
!= QLA_SUCCESS
) {
1024 DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
1025 ha
->host_no
, rval
));
1026 } else if (sns_cmd
->p
.rft_data
[8] != 0x80 ||
1027 sns_cmd
->p
.rft_data
[9] != 0x02) {
1028 DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
1029 "rft_rsp:\n", ha
->host_no
));
1030 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.rft_data
, 16));
1031 rval
= QLA_FUNCTION_FAILED
;
1033 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
1041 * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
1045 * This command uses the old Exectute SNS Command mailbox routine.
1047 * Returns 0 on success.
1050 qla2x00_sns_rnn_id(scsi_qla_host_t
*ha
)
1054 struct sns_cmd_pkt
*sns_cmd
;
1057 /* Prepare SNS command request. */
1058 sns_cmd
= qla2x00_prep_sns_cmd(ha
, RNN_ID_CMD
, RNN_ID_SNS_SCMD_LEN
,
1059 RNN_ID_SNS_DATA_SIZE
);
1061 /* Prepare SNS command arguments -- port_id, nodename. */
1062 sns_cmd
->p
.cmd
.param
[0] = ha
->d_id
.b
.al_pa
;
1063 sns_cmd
->p
.cmd
.param
[1] = ha
->d_id
.b
.area
;
1064 sns_cmd
->p
.cmd
.param
[2] = ha
->d_id
.b
.domain
;
1066 sns_cmd
->p
.cmd
.param
[4] = ha
->node_name
[7];
1067 sns_cmd
->p
.cmd
.param
[5] = ha
->node_name
[6];
1068 sns_cmd
->p
.cmd
.param
[6] = ha
->node_name
[5];
1069 sns_cmd
->p
.cmd
.param
[7] = ha
->node_name
[4];
1070 sns_cmd
->p
.cmd
.param
[8] = ha
->node_name
[3];
1071 sns_cmd
->p
.cmd
.param
[9] = ha
->node_name
[2];
1072 sns_cmd
->p
.cmd
.param
[10] = ha
->node_name
[1];
1073 sns_cmd
->p
.cmd
.param
[11] = ha
->node_name
[0];
1075 /* Execute SNS command. */
1076 rval
= qla2x00_send_sns(ha
, ha
->sns_cmd_dma
, RNN_ID_SNS_CMD_SIZE
/ 2,
1077 sizeof(struct sns_cmd_pkt
));
1078 if (rval
!= QLA_SUCCESS
) {
1080 DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
1081 ha
->host_no
, rval
));
1082 } else if (sns_cmd
->p
.rnn_data
[8] != 0x80 ||
1083 sns_cmd
->p
.rnn_data
[9] != 0x02) {
1084 DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
1085 "rnn_rsp:\n", ha
->host_no
));
1086 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.rnn_data
, 16));
1087 rval
= QLA_FUNCTION_FAILED
;
1089 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
1097 * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
1100 * Returns 0 on success.
1103 qla2x00_mgmt_svr_login(scsi_qla_host_t
*ha
)
1106 uint16_t mb
[MAILBOX_REGISTER_COUNT
];
1109 if (ha
->flags
.management_server_logged_in
)
1112 ha
->isp_ops
->fabric_login(ha
, ha
->mgmt_svr_loop_id
, 0xff, 0xff, 0xfa,
1114 if (mb
[0] != MBS_COMMAND_COMPLETE
) {
1115 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
1116 "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
1117 __func__
, ha
->host_no
, ha
->mgmt_svr_loop_id
, mb
[0], mb
[1],
1118 mb
[2], mb
[6], mb
[7]));
1119 ret
= QLA_FUNCTION_FAILED
;
1121 ha
->flags
.management_server_logged_in
= 1;
1127 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1129 * @req_size: request size in bytes
1130 * @rsp_size: response size in bytes
1132 * Returns a pointer to the @ha's ms_iocb.
1135 qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t
*ha
, uint32_t req_size
,
1138 ms_iocb_entry_t
*ms_pkt
;
1140 ms_pkt
= ha
->ms_iocb
;
1141 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
1143 ms_pkt
->entry_type
= MS_IOCB_TYPE
;
1144 ms_pkt
->entry_count
= 1;
1145 SET_TARGET_ID(ha
, ms_pkt
->loop_id
, ha
->mgmt_svr_loop_id
);
1146 ms_pkt
->control_flags
= __constant_cpu_to_le16(CF_READ
| CF_HEAD_TAG
);
1147 ms_pkt
->timeout
= __constant_cpu_to_le16(59);
1148 ms_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1149 ms_pkt
->total_dsd_count
= __constant_cpu_to_le16(2);
1150 ms_pkt
->rsp_bytecount
= cpu_to_le32(rsp_size
);
1151 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1153 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1154 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1155 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1157 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1158 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1159 ms_pkt
->dseg_rsp_length
= ms_pkt
->rsp_bytecount
;
1165 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1167 * @req_size: request size in bytes
1168 * @rsp_size: response size in bytes
1170 * Returns a pointer to the @ha's ms_iocb.
1173 qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t
*ha
, uint32_t req_size
,
1176 struct ct_entry_24xx
*ct_pkt
;
1178 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1179 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1181 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1182 ct_pkt
->entry_count
= 1;
1183 ct_pkt
->nport_handle
= cpu_to_le16(ha
->mgmt_svr_loop_id
);
1184 ct_pkt
->timeout
= __constant_cpu_to_le16(59);
1185 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1186 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
1187 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1188 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1190 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1191 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1192 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1194 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1195 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1196 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1197 ct_pkt
->vp_index
= ha
->vp_idx
;
1202 static inline ms_iocb_entry_t
*
1203 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t
*ha
, uint32_t req_size
)
1205 ms_iocb_entry_t
*ms_pkt
= ha
->ms_iocb
;
1206 struct ct_entry_24xx
*ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1208 if (IS_FWI2_CAPABLE(ha
)) {
1209 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1210 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1212 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1213 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1220 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1221 * @ct_req: CT request buffer
1223 * @rsp_size: response size in bytes
1225 * Returns a pointer to the intitialized @ct_req.
1227 static inline struct ct_sns_req
*
1228 qla2x00_prep_ct_fdmi_req(struct ct_sns_req
*ct_req
, uint16_t cmd
,
1231 memset(ct_req
, 0, sizeof(struct ct_sns_pkt
));
1233 ct_req
->header
.revision
= 0x01;
1234 ct_req
->header
.gs_type
= 0xFA;
1235 ct_req
->header
.gs_subtype
= 0x10;
1236 ct_req
->command
= cpu_to_be16(cmd
);
1237 ct_req
->max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1243 * qla2x00_fdmi_rhba() -
1246 * Returns 0 on success.
1249 qla2x00_fdmi_rhba(scsi_qla_host_t
*ha
)
1254 ms_iocb_entry_t
*ms_pkt
;
1255 struct ct_sns_req
*ct_req
;
1256 struct ct_sns_rsp
*ct_rsp
;
1258 struct ct_fdmi_hba_attr
*eiter
;
1261 /* Prepare common MS IOCB */
1262 /* Request size adjusted after CT preparation */
1263 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(ha
, 0, RHBA_RSP_SIZE
);
1265 /* Prepare CT request */
1266 ct_req
= qla2x00_prep_ct_fdmi_req(&ha
->ct_sns
->p
.req
, RHBA_CMD
,
1268 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1270 /* Prepare FDMI command arguments -- attribute block, attributes. */
1271 memcpy(ct_req
->req
.rhba
.hba_identifier
, ha
->port_name
, WWN_SIZE
);
1272 ct_req
->req
.rhba
.entry_count
= __constant_cpu_to_be32(1);
1273 memcpy(ct_req
->req
.rhba
.port_name
, ha
->port_name
, WWN_SIZE
);
1274 size
= 2 * WWN_SIZE
+ 4 + 4;
1277 ct_req
->req
.rhba
.attrs
.count
=
1278 __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT
);
1279 entries
= ct_req
->req
.rhba
.hba_identifier
;
1282 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1283 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_NODE_NAME
);
1284 eiter
->len
= __constant_cpu_to_be16(4 + WWN_SIZE
);
1285 memcpy(eiter
->a
.node_name
, ha
->node_name
, WWN_SIZE
);
1286 size
+= 4 + WWN_SIZE
;
1288 DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n",
1289 __func__
, ha
->host_no
,
1290 eiter
->a
.node_name
[0], eiter
->a
.node_name
[1], eiter
->a
.node_name
[2],
1291 eiter
->a
.node_name
[3], eiter
->a
.node_name
[4], eiter
->a
.node_name
[5],
1292 eiter
->a
.node_name
[6], eiter
->a
.node_name
[7]));
1295 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1296 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER
);
1297 strcpy(eiter
->a
.manufacturer
, "QLogic Corporation");
1298 alen
= strlen(eiter
->a
.manufacturer
);
1299 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1300 eiter
->len
= cpu_to_be16(4 + alen
);
1303 DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__
, ha
->host_no
,
1304 eiter
->a
.manufacturer
));
1306 /* Serial number. */
1307 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1308 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER
);
1309 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
1310 sprintf(eiter
->a
.serial_num
, "%c%05d", 'A' + sn
/ 100000, sn
% 100000);
1311 alen
= strlen(eiter
->a
.serial_num
);
1312 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1313 eiter
->len
= cpu_to_be16(4 + alen
);
1316 DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__
, ha
->host_no
,
1317 eiter
->a
.serial_num
));
1320 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1321 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_MODEL
);
1322 strcpy(eiter
->a
.model
, ha
->model_number
);
1323 alen
= strlen(eiter
->a
.model
);
1324 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1325 eiter
->len
= cpu_to_be16(4 + alen
);
1328 DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__
, ha
->host_no
,
1331 /* Model description. */
1332 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1333 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION
);
1335 strncpy(eiter
->a
.model_desc
, ha
->model_desc
, 80);
1336 alen
= strlen(eiter
->a
.model_desc
);
1337 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1338 eiter
->len
= cpu_to_be16(4 + alen
);
1341 DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__
, ha
->host_no
,
1342 eiter
->a
.model_desc
));
1344 /* Hardware version. */
1345 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1346 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION
);
1347 strcpy(eiter
->a
.hw_version
, ha
->adapter_id
);
1348 alen
= strlen(eiter
->a
.hw_version
);
1349 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1350 eiter
->len
= cpu_to_be16(4 + alen
);
1353 DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__
, ha
->host_no
,
1354 eiter
->a
.hw_version
));
1356 /* Driver version. */
1357 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1358 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION
);
1359 strcpy(eiter
->a
.driver_version
, qla2x00_version_str
);
1360 alen
= strlen(eiter
->a
.driver_version
);
1361 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1362 eiter
->len
= cpu_to_be16(4 + alen
);
1365 DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__
, ha
->host_no
,
1366 eiter
->a
.driver_version
));
1368 /* Option ROM version. */
1369 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1370 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION
);
1371 strcpy(eiter
->a
.orom_version
, "0.00");
1372 alen
= strlen(eiter
->a
.orom_version
);
1373 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1374 eiter
->len
= cpu_to_be16(4 + alen
);
1377 DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__
, ha
->host_no
,
1378 eiter
->a
.orom_version
));
1380 /* Firmware version */
1381 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1382 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION
);
1383 ha
->isp_ops
->fw_version_str(ha
, eiter
->a
.fw_version
);
1384 alen
= strlen(eiter
->a
.fw_version
);
1385 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1386 eiter
->len
= cpu_to_be16(4 + alen
);
1389 DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__
, ha
->host_no
,
1390 eiter
->a
.fw_version
));
1392 /* Update MS request size. */
1393 qla2x00_update_ms_fdmi_iocb(ha
, size
+ 16);
1395 DEBUG13(printk("%s(%ld): RHBA identifier="
1396 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__
,
1397 ha
->host_no
, ct_req
->req
.rhba
.hba_identifier
[0],
1398 ct_req
->req
.rhba
.hba_identifier
[1],
1399 ct_req
->req
.rhba
.hba_identifier
[2],
1400 ct_req
->req
.rhba
.hba_identifier
[3],
1401 ct_req
->req
.rhba
.hba_identifier
[4],
1402 ct_req
->req
.rhba
.hba_identifier
[5],
1403 ct_req
->req
.rhba
.hba_identifier
[6],
1404 ct_req
->req
.rhba
.hba_identifier
[7], size
));
1405 DEBUG13(qla2x00_dump_buffer(entries
, size
));
1407 /* Execute MS IOCB */
1408 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1409 sizeof(ms_iocb_entry_t
));
1410 if (rval
!= QLA_SUCCESS
) {
1412 DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n",
1413 ha
->host_no
, rval
));
1414 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "RHBA") !=
1416 rval
= QLA_FUNCTION_FAILED
;
1417 if (ct_rsp
->header
.reason_code
== CT_REASON_CANNOT_PERFORM
&&
1418 ct_rsp
->header
.explanation_code
==
1419 CT_EXPL_ALREADY_REGISTERED
) {
1420 DEBUG2_13(printk("%s(%ld): HBA already registered.\n",
1421 __func__
, ha
->host_no
));
1422 rval
= QLA_ALREADY_REGISTERED
;
1425 DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n",
1433 * qla2x00_fdmi_dhba() -
1436 * Returns 0 on success.
1439 qla2x00_fdmi_dhba(scsi_qla_host_t
*ha
)
1443 ms_iocb_entry_t
*ms_pkt
;
1444 struct ct_sns_req
*ct_req
;
1445 struct ct_sns_rsp
*ct_rsp
;
1448 /* Prepare common MS IOCB */
1449 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(ha
, DHBA_REQ_SIZE
,
1452 /* Prepare CT request */
1453 ct_req
= qla2x00_prep_ct_fdmi_req(&ha
->ct_sns
->p
.req
, DHBA_CMD
,
1455 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1457 /* Prepare FDMI command arguments -- portname. */
1458 memcpy(ct_req
->req
.dhba
.port_name
, ha
->port_name
, WWN_SIZE
);
1460 DEBUG13(printk("%s(%ld): DHBA portname="
1461 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__
, ha
->host_no
,
1462 ct_req
->req
.dhba
.port_name
[0], ct_req
->req
.dhba
.port_name
[1],
1463 ct_req
->req
.dhba
.port_name
[2], ct_req
->req
.dhba
.port_name
[3],
1464 ct_req
->req
.dhba
.port_name
[4], ct_req
->req
.dhba
.port_name
[5],
1465 ct_req
->req
.dhba
.port_name
[6], ct_req
->req
.dhba
.port_name
[7]));
1467 /* Execute MS IOCB */
1468 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1469 sizeof(ms_iocb_entry_t
));
1470 if (rval
!= QLA_SUCCESS
) {
1472 DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n",
1473 ha
->host_no
, rval
));
1474 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "DHBA") !=
1476 rval
= QLA_FUNCTION_FAILED
;
1478 DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n",
1486 * qla2x00_fdmi_rpa() -
1489 * Returns 0 on success.
1492 qla2x00_fdmi_rpa(scsi_qla_host_t
*ha
)
1495 uint32_t size
, max_frame_size
;
1497 ms_iocb_entry_t
*ms_pkt
;
1498 struct ct_sns_req
*ct_req
;
1499 struct ct_sns_rsp
*ct_rsp
;
1501 struct ct_fdmi_port_attr
*eiter
;
1502 struct init_cb_24xx
*icb24
= (struct init_cb_24xx
*)ha
->init_cb
;
1505 /* Prepare common MS IOCB */
1506 /* Request size adjusted after CT preparation */
1507 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(ha
, 0, RPA_RSP_SIZE
);
1509 /* Prepare CT request */
1510 ct_req
= qla2x00_prep_ct_fdmi_req(&ha
->ct_sns
->p
.req
, RPA_CMD
,
1512 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1514 /* Prepare FDMI command arguments -- attribute block, attributes. */
1515 memcpy(ct_req
->req
.rpa
.port_name
, ha
->port_name
, WWN_SIZE
);
1516 size
= WWN_SIZE
+ 4;
1519 ct_req
->req
.rpa
.attrs
.count
=
1520 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT
- 1);
1521 entries
= ct_req
->req
.rpa
.port_name
;
1524 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1525 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES
);
1526 eiter
->len
= __constant_cpu_to_be16(4 + 32);
1527 eiter
->a
.fc4_types
[2] = 0x01;
1530 DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__
, ha
->host_no
,
1531 eiter
->a
.fc4_types
[2], eiter
->a
.fc4_types
[1]));
1533 /* Supported speed. */
1534 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1535 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED
);
1536 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1538 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1539 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
|
1540 FDMI_PORT_SPEED_4GB
|FDMI_PORT_SPEED_8GB
);
1541 else if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
))
1542 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1543 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
|
1544 FDMI_PORT_SPEED_4GB
);
1545 else if (IS_QLA23XX(ha
))
1546 eiter
->a
.sup_speed
=__constant_cpu_to_be32(
1547 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
);
1549 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1550 FDMI_PORT_SPEED_1GB
);
1553 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__
, ha
->host_no
,
1554 eiter
->a
.sup_speed
));
1556 /* Current speed. */
1557 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1558 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED
);
1559 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1560 switch (ha
->link_data_rate
) {
1561 case PORT_SPEED_1GB
:
1562 eiter
->a
.cur_speed
=
1563 __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB
);
1565 case PORT_SPEED_2GB
:
1566 eiter
->a
.cur_speed
=
1567 __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB
);
1569 case PORT_SPEED_4GB
:
1570 eiter
->a
.cur_speed
=
1571 __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB
);
1573 case PORT_SPEED_8GB
:
1574 eiter
->a
.cur_speed
=
1575 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB
);
1578 eiter
->a
.cur_speed
=
1579 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN
);
1584 DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__
, ha
->host_no
,
1585 eiter
->a
.cur_speed
));
1587 /* Max frame size. */
1588 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1589 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE
);
1590 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1591 max_frame_size
= IS_FWI2_CAPABLE(ha
) ?
1592 (uint32_t) icb24
->frame_payload_size
:
1593 (uint32_t) ha
->init_cb
->frame_payload_size
;
1594 eiter
->a
.max_frame_size
= cpu_to_be32(max_frame_size
);
1597 DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__
, ha
->host_no
,
1598 eiter
->a
.max_frame_size
));
1600 /* OS device name. */
1601 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1602 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME
);
1603 strcpy(eiter
->a
.os_dev_name
, QLA2XXX_DRIVER_NAME
);
1604 alen
= strlen(eiter
->a
.os_dev_name
);
1605 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1606 eiter
->len
= cpu_to_be16(4 + alen
);
1609 DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__
, ha
->host_no
,
1610 eiter
->a
.os_dev_name
));
1613 if (strlen(fc_host_system_hostname(ha
->host
))) {
1614 ct_req
->req
.rpa
.attrs
.count
=
1615 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT
);
1616 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1617 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_HOST_NAME
);
1618 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
1619 "%s", fc_host_system_hostname(ha
->host
));
1620 alen
= strlen(eiter
->a
.host_name
);
1621 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1622 eiter
->len
= cpu_to_be16(4 + alen
);
1625 DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__
,
1626 ha
->host_no
, eiter
->a
.host_name
));
1629 /* Update MS request size. */
1630 qla2x00_update_ms_fdmi_iocb(ha
, size
+ 16);
1632 DEBUG13(printk("%s(%ld): RPA portname="
1633 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__
,
1634 ha
->host_no
, ct_req
->req
.rpa
.port_name
[0],
1635 ct_req
->req
.rpa
.port_name
[1], ct_req
->req
.rpa
.port_name
[2],
1636 ct_req
->req
.rpa
.port_name
[3], ct_req
->req
.rpa
.port_name
[4],
1637 ct_req
->req
.rpa
.port_name
[5], ct_req
->req
.rpa
.port_name
[6],
1638 ct_req
->req
.rpa
.port_name
[7], size
));
1639 DEBUG13(qla2x00_dump_buffer(entries
, size
));
1641 /* Execute MS IOCB */
1642 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1643 sizeof(ms_iocb_entry_t
));
1644 if (rval
!= QLA_SUCCESS
) {
1646 DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n",
1647 ha
->host_no
, rval
));
1648 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
, "RPA") !=
1650 rval
= QLA_FUNCTION_FAILED
;
1652 DEBUG2(printk("scsi(%ld): RPA exiting normally.\n",
1660 * qla2x00_fdmi_register() -
1663 * Returns 0 on success.
1666 qla2x00_fdmi_register(scsi_qla_host_t
*ha
)
1670 rval
= qla2x00_mgmt_svr_login(ha
);
1674 rval
= qla2x00_fdmi_rhba(ha
);
1676 if (rval
!= QLA_ALREADY_REGISTERED
)
1679 rval
= qla2x00_fdmi_dhba(ha
);
1683 rval
= qla2x00_fdmi_rhba(ha
);
1687 rval
= qla2x00_fdmi_rpa(ha
);
1693 * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
1695 * @list: switch info entries to populate
1697 * Returns 0 on success.
1700 qla2x00_gfpn_id(scsi_qla_host_t
*ha
, sw_info_t
*list
)
1705 ms_iocb_entry_t
*ms_pkt
;
1706 struct ct_sns_req
*ct_req
;
1707 struct ct_sns_rsp
*ct_rsp
;
1709 if (!IS_IIDMA_CAPABLE(ha
))
1710 return QLA_FUNCTION_FAILED
;
1712 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
1714 /* Prepare common MS IOCB */
1715 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(ha
, GFPN_ID_REQ_SIZE
,
1718 /* Prepare CT request */
1719 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GFPN_ID_CMD
,
1721 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1723 /* Prepare CT arguments -- port_id */
1724 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
1725 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
1726 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
1728 /* Execute MS IOCB */
1729 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1730 sizeof(ms_iocb_entry_t
));
1731 if (rval
!= QLA_SUCCESS
) {
1733 DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB "
1734 "failed (%d).\n", ha
->host_no
, rval
));
1735 } else if (qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
,
1736 "GFPN_ID") != QLA_SUCCESS
) {
1737 rval
= QLA_FUNCTION_FAILED
;
1739 /* Save fabric portname */
1740 memcpy(list
[i
].fabric_port_name
,
1741 ct_rsp
->rsp
.gfpn_id
.port_name
, WWN_SIZE
);
1744 /* Last device exit. */
1745 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
1752 static inline void *
1753 qla24xx_prep_ms_fm_iocb(scsi_qla_host_t
*ha
, uint32_t req_size
,
1756 struct ct_entry_24xx
*ct_pkt
;
1758 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1759 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1761 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1762 ct_pkt
->entry_count
= 1;
1763 ct_pkt
->nport_handle
= cpu_to_le16(ha
->mgmt_svr_loop_id
);
1764 ct_pkt
->timeout
= __constant_cpu_to_le16(59);
1765 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1766 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
1767 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1768 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1770 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1771 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1772 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1774 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1775 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1776 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1777 ct_pkt
->vp_index
= ha
->vp_idx
;
1783 static inline struct ct_sns_req
*
1784 qla24xx_prep_ct_fm_req(struct ct_sns_req
*ct_req
, uint16_t cmd
,
1787 memset(ct_req
, 0, sizeof(struct ct_sns_pkt
));
1789 ct_req
->header
.revision
= 0x01;
1790 ct_req
->header
.gs_type
= 0xFA;
1791 ct_req
->header
.gs_subtype
= 0x01;
1792 ct_req
->command
= cpu_to_be16(cmd
);
1793 ct_req
->max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1799 * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
1801 * @list: switch info entries to populate
1803 * Returns 0 on success.
1806 qla2x00_gpsc(scsi_qla_host_t
*ha
, sw_info_t
*list
)
1811 ms_iocb_entry_t
*ms_pkt
;
1812 struct ct_sns_req
*ct_req
;
1813 struct ct_sns_rsp
*ct_rsp
;
1815 if (!IS_IIDMA_CAPABLE(ha
))
1816 return QLA_FUNCTION_FAILED
;
1817 if (!ha
->flags
.gpsc_supported
)
1818 return QLA_FUNCTION_FAILED
;
1820 rval
= qla2x00_mgmt_svr_login(ha
);
1824 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
1826 /* Prepare common MS IOCB */
1827 ms_pkt
= qla24xx_prep_ms_fm_iocb(ha
, GPSC_REQ_SIZE
,
1830 /* Prepare CT request */
1831 ct_req
= qla24xx_prep_ct_fm_req(&ha
->ct_sns
->p
.req
,
1832 GPSC_CMD
, GPSC_RSP_SIZE
);
1833 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1835 /* Prepare CT arguments -- port_name */
1836 memcpy(ct_req
->req
.gpsc
.port_name
, list
[i
].fabric_port_name
,
1839 /* Execute MS IOCB */
1840 rval
= qla2x00_issue_iocb(ha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1841 sizeof(ms_iocb_entry_t
));
1842 if (rval
!= QLA_SUCCESS
) {
1844 DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB "
1845 "failed (%d).\n", ha
->host_no
, rval
));
1846 } else if ((rval
= qla2x00_chk_ms_status(ha
, ms_pkt
, ct_rsp
,
1847 "GPSC")) != QLA_SUCCESS
) {
1848 /* FM command unsupported? */
1849 if (rval
== QLA_INVALID_COMMAND
&&
1850 ct_rsp
->header
.reason_code
==
1851 CT_REASON_INVALID_COMMAND_CODE
) {
1852 DEBUG2(printk("scsi(%ld): GPSC command "
1853 "unsupported, disabling query...\n",
1855 ha
->flags
.gpsc_supported
= 0;
1856 rval
= QLA_FUNCTION_FAILED
;
1859 rval
= QLA_FUNCTION_FAILED
;
1861 /* Save port-speed */
1862 switch (be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)) {
1864 list
[i
].fp_speed
= PORT_SPEED_1GB
;
1867 list
[i
].fp_speed
= PORT_SPEED_2GB
;
1870 list
[i
].fp_speed
= PORT_SPEED_4GB
;
1873 list
[i
].fp_speed
= PORT_SPEED_8GB
;
1877 DEBUG2_3(printk("scsi(%ld): GPSC ext entry - "
1878 "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x "
1879 "speed=%04x.\n", ha
->host_no
,
1880 list
[i
].fabric_port_name
[0],
1881 list
[i
].fabric_port_name
[1],
1882 list
[i
].fabric_port_name
[2],
1883 list
[i
].fabric_port_name
[3],
1884 list
[i
].fabric_port_name
[4],
1885 list
[i
].fabric_port_name
[5],
1886 list
[i
].fabric_port_name
[6],
1887 list
[i
].fabric_port_name
[7],
1888 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speeds
),
1889 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)));
1892 /* Last device exit. */
1893 if (list
[i
].d_id
.b
.rsvd_1
!= 0)