2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2013 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
8 #include "qla_target.h"
10 static int qla2x00_sns_ga_nxt(scsi_qla_host_t
*, fc_port_t
*);
11 static int qla2x00_sns_gid_pt(scsi_qla_host_t
*, sw_info_t
*);
12 static int qla2x00_sns_gpn_id(scsi_qla_host_t
*, sw_info_t
*);
13 static int qla2x00_sns_gnn_id(scsi_qla_host_t
*, sw_info_t
*);
14 static int qla2x00_sns_rft_id(scsi_qla_host_t
*);
15 static int qla2x00_sns_rnn_id(scsi_qla_host_t
*);
18 * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
20 * @req_size: request size in bytes
21 * @rsp_size: response size in bytes
23 * Returns a pointer to the @ha's ms_iocb.
26 qla2x00_prep_ms_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
, uint32_t rsp_size
)
28 struct qla_hw_data
*ha
= vha
->hw
;
29 ms_iocb_entry_t
*ms_pkt
;
32 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
34 ms_pkt
->entry_type
= MS_IOCB_TYPE
;
35 ms_pkt
->entry_count
= 1;
36 SET_TARGET_ID(ha
, ms_pkt
->loop_id
, SIMPLE_NAME_SERVER
);
37 ms_pkt
->control_flags
= __constant_cpu_to_le16(CF_READ
| CF_HEAD_TAG
);
38 ms_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
39 ms_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
40 ms_pkt
->total_dsd_count
= __constant_cpu_to_le16(2);
41 ms_pkt
->rsp_bytecount
= cpu_to_le32(rsp_size
);
42 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
44 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
45 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
46 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
48 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
49 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
50 ms_pkt
->dseg_rsp_length
= ms_pkt
->rsp_bytecount
;
52 vha
->qla_stats
.control_requests
++;
58 * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
60 * @req_size: request size in bytes
61 * @rsp_size: response size in bytes
63 * Returns a pointer to the @ha's ms_iocb.
66 qla24xx_prep_ms_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
, uint32_t rsp_size
)
68 struct qla_hw_data
*ha
= vha
->hw
;
69 struct ct_entry_24xx
*ct_pkt
;
71 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
72 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
74 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
75 ct_pkt
->entry_count
= 1;
76 ct_pkt
->nport_handle
= __constant_cpu_to_le16(NPH_SNS
);
77 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
78 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
79 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
80 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
81 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
83 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
84 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
85 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
87 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
88 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
89 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
90 ct_pkt
->vp_index
= vha
->vp_idx
;
92 vha
->qla_stats
.control_requests
++;
98 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
99 * @ct_req: CT request buffer
101 * @rsp_size: response size in bytes
103 * Returns a pointer to the intitialized @ct_req.
105 static inline struct ct_sns_req
*
106 qla2x00_prep_ct_req(struct ct_sns_pkt
*p
, uint16_t cmd
, uint16_t rsp_size
)
108 memset(p
, 0, sizeof(struct ct_sns_pkt
));
110 p
->p
.req
.header
.revision
= 0x01;
111 p
->p
.req
.header
.gs_type
= 0xFC;
112 p
->p
.req
.header
.gs_subtype
= 0x02;
113 p
->p
.req
.command
= cpu_to_be16(cmd
);
114 p
->p
.req
.max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
120 qla2x00_chk_ms_status(scsi_qla_host_t
*vha
, ms_iocb_entry_t
*ms_pkt
,
121 struct ct_sns_rsp
*ct_rsp
, const char *routine
)
124 uint16_t comp_status
;
125 struct qla_hw_data
*ha
= vha
->hw
;
127 rval
= QLA_FUNCTION_FAILED
;
128 if (ms_pkt
->entry_status
!= 0) {
129 ql_dbg(ql_dbg_disc
, vha
, 0x2031,
130 "%s failed, error status (%x) on port_id: %02x%02x%02x.\n",
131 routine
, ms_pkt
->entry_status
, vha
->d_id
.b
.domain
,
132 vha
->d_id
.b
.area
, vha
->d_id
.b
.al_pa
);
134 if (IS_FWI2_CAPABLE(ha
))
135 comp_status
= le16_to_cpu(
136 ((struct ct_entry_24xx
*)ms_pkt
)->comp_status
);
138 comp_status
= le16_to_cpu(ms_pkt
->status
);
139 switch (comp_status
) {
141 case CS_DATA_UNDERRUN
:
142 case CS_DATA_OVERRUN
: /* Overrun? */
143 if (ct_rsp
->header
.response
!=
144 __constant_cpu_to_be16(CT_ACCEPT_RESPONSE
)) {
145 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2077,
146 "%s failed rejected request on port_id: "
147 "%02x%02x%02x.\n", routine
,
148 vha
->d_id
.b
.domain
, vha
->d_id
.b
.area
,
150 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
,
151 0x2078, (uint8_t *)&ct_rsp
->header
,
152 sizeof(struct ct_rsp_hdr
));
153 rval
= QLA_INVALID_COMMAND
;
158 ql_dbg(ql_dbg_disc
, vha
, 0x2033,
159 "%s failed, completion status (%x) on port_id: "
160 "%02x%02x%02x.\n", routine
, comp_status
,
161 vha
->d_id
.b
.domain
, vha
->d_id
.b
.area
,
170 * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
172 * @fcport: fcport entry to updated
174 * Returns 0 on success.
177 qla2x00_ga_nxt(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
181 ms_iocb_entry_t
*ms_pkt
;
182 struct ct_sns_req
*ct_req
;
183 struct ct_sns_rsp
*ct_rsp
;
184 struct qla_hw_data
*ha
= vha
->hw
;
186 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
187 return qla2x00_sns_ga_nxt(vha
, fcport
);
190 /* Prepare common MS IOCB */
191 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GA_NXT_REQ_SIZE
,
194 /* Prepare CT request */
195 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GA_NXT_CMD
,
197 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
199 /* Prepare CT arguments -- port_id */
200 ct_req
->req
.port_id
.port_id
[0] = fcport
->d_id
.b
.domain
;
201 ct_req
->req
.port_id
.port_id
[1] = fcport
->d_id
.b
.area
;
202 ct_req
->req
.port_id
.port_id
[2] = fcport
->d_id
.b
.al_pa
;
204 /* Execute MS IOCB */
205 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
206 sizeof(ms_iocb_entry_t
));
207 if (rval
!= QLA_SUCCESS
) {
209 ql_dbg(ql_dbg_disc
, vha
, 0x2062,
210 "GA_NXT issue IOCB failed (%d).\n", rval
);
211 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "GA_NXT") !=
213 rval
= QLA_FUNCTION_FAILED
;
215 /* Populate fc_port_t entry. */
216 fcport
->d_id
.b
.domain
= ct_rsp
->rsp
.ga_nxt
.port_id
[0];
217 fcport
->d_id
.b
.area
= ct_rsp
->rsp
.ga_nxt
.port_id
[1];
218 fcport
->d_id
.b
.al_pa
= ct_rsp
->rsp
.ga_nxt
.port_id
[2];
220 memcpy(fcport
->node_name
, ct_rsp
->rsp
.ga_nxt
.node_name
,
222 memcpy(fcport
->port_name
, ct_rsp
->rsp
.ga_nxt
.port_name
,
225 fcport
->fc4_type
= (ct_rsp
->rsp
.ga_nxt
.fc4_types
[2] & BIT_0
) ?
226 FC4_TYPE_FCP_SCSI
: FC4_TYPE_OTHER
;
228 if (ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_N_PORT_TYPE
&&
229 ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_NL_PORT_TYPE
)
230 fcport
->d_id
.b
.domain
= 0xf0;
232 ql_dbg(ql_dbg_disc
, vha
, 0x2063,
233 "GA_NXT entry - nn %8phN pn %8phN "
234 "port_id=%02x%02x%02x.\n",
235 fcport
->node_name
, fcport
->port_name
,
236 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
237 fcport
->d_id
.b
.al_pa
);
244 qla2x00_gid_pt_rsp_size(scsi_qla_host_t
*vha
)
246 return vha
->hw
->max_fibre_devices
* 4 + 16;
250 * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
252 * @list: switch info entries to populate
254 * NOTE: Non-Nx_Ports are not requested.
256 * Returns 0 on success.
259 qla2x00_gid_pt(scsi_qla_host_t
*vha
, sw_info_t
*list
)
264 ms_iocb_entry_t
*ms_pkt
;
265 struct ct_sns_req
*ct_req
;
266 struct ct_sns_rsp
*ct_rsp
;
268 struct ct_sns_gid_pt_data
*gid_data
;
269 struct qla_hw_data
*ha
= vha
->hw
;
270 uint16_t gid_pt_rsp_size
;
272 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
273 return qla2x00_sns_gid_pt(vha
, list
);
276 gid_pt_rsp_size
= qla2x00_gid_pt_rsp_size(vha
);
278 /* Prepare common MS IOCB */
279 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GID_PT_REQ_SIZE
,
282 /* Prepare CT request */
283 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GID_PT_CMD
, gid_pt_rsp_size
);
284 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
286 /* Prepare CT arguments -- port_type */
287 ct_req
->req
.gid_pt
.port_type
= NS_NX_PORT_TYPE
;
289 /* Execute MS IOCB */
290 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
291 sizeof(ms_iocb_entry_t
));
292 if (rval
!= QLA_SUCCESS
) {
294 ql_dbg(ql_dbg_disc
, vha
, 0x2055,
295 "GID_PT issue IOCB failed (%d).\n", rval
);
296 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "GID_PT") !=
298 rval
= QLA_FUNCTION_FAILED
;
300 /* Set port IDs in switch info list. */
301 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
302 gid_data
= &ct_rsp
->rsp
.gid_pt
.entries
[i
];
303 list
[i
].d_id
.b
.domain
= gid_data
->port_id
[0];
304 list
[i
].d_id
.b
.area
= gid_data
->port_id
[1];
305 list
[i
].d_id
.b
.al_pa
= gid_data
->port_id
[2];
306 memset(list
[i
].fabric_port_name
, 0, WWN_SIZE
);
307 list
[i
].fp_speed
= PORT_SPEED_UNKNOWN
;
310 if (gid_data
->control_byte
& BIT_7
) {
311 list
[i
].d_id
.b
.rsvd_1
= gid_data
->control_byte
;
317 * If we've used all available slots, then the switch is
318 * reporting back more devices than we can handle with this
319 * single call. Return a failed status, and let GA_NXT handle
322 if (i
== ha
->max_fibre_devices
)
323 rval
= QLA_FUNCTION_FAILED
;
330 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
332 * @list: switch info entries to populate
334 * Returns 0 on success.
337 qla2x00_gpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
339 int rval
= QLA_SUCCESS
;
342 ms_iocb_entry_t
*ms_pkt
;
343 struct ct_sns_req
*ct_req
;
344 struct ct_sns_rsp
*ct_rsp
;
345 struct qla_hw_data
*ha
= vha
->hw
;
347 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
348 return qla2x00_sns_gpn_id(vha
, list
);
350 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
352 /* Prepare common MS IOCB */
353 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GPN_ID_REQ_SIZE
,
356 /* Prepare CT request */
357 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GPN_ID_CMD
,
359 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
361 /* Prepare CT arguments -- port_id */
362 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
363 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
364 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
366 /* Execute MS IOCB */
367 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
368 sizeof(ms_iocb_entry_t
));
369 if (rval
!= QLA_SUCCESS
) {
371 ql_dbg(ql_dbg_disc
, vha
, 0x2056,
372 "GPN_ID issue IOCB failed (%d).\n", rval
);
374 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
375 "GPN_ID") != QLA_SUCCESS
) {
376 rval
= QLA_FUNCTION_FAILED
;
380 memcpy(list
[i
].port_name
,
381 ct_rsp
->rsp
.gpn_id
.port_name
, WWN_SIZE
);
384 /* Last device exit. */
385 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
393 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
395 * @list: switch info entries to populate
397 * Returns 0 on success.
400 qla2x00_gnn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
402 int rval
= QLA_SUCCESS
;
404 struct qla_hw_data
*ha
= vha
->hw
;
405 ms_iocb_entry_t
*ms_pkt
;
406 struct ct_sns_req
*ct_req
;
407 struct ct_sns_rsp
*ct_rsp
;
409 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
410 return qla2x00_sns_gnn_id(vha
, list
);
412 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
414 /* Prepare common MS IOCB */
415 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GNN_ID_REQ_SIZE
,
418 /* Prepare CT request */
419 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GNN_ID_CMD
,
421 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
423 /* Prepare CT arguments -- port_id */
424 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
425 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
426 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
428 /* Execute MS IOCB */
429 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
430 sizeof(ms_iocb_entry_t
));
431 if (rval
!= QLA_SUCCESS
) {
433 ql_dbg(ql_dbg_disc
, vha
, 0x2057,
434 "GNN_ID issue IOCB failed (%d).\n", rval
);
436 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
437 "GNN_ID") != QLA_SUCCESS
) {
438 rval
= QLA_FUNCTION_FAILED
;
442 memcpy(list
[i
].node_name
,
443 ct_rsp
->rsp
.gnn_id
.node_name
, WWN_SIZE
);
445 ql_dbg(ql_dbg_disc
, vha
, 0x2058,
446 "GID_PT entry - nn %8phN pn %8phN "
447 "portid=%02x%02x%02x.\n",
448 list
[i
].node_name
, list
[i
].port_name
,
449 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
450 list
[i
].d_id
.b
.al_pa
);
453 /* Last device exit. */
454 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
462 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
465 * Returns 0 on success.
468 qla2x00_rft_id(scsi_qla_host_t
*vha
)
471 struct qla_hw_data
*ha
= vha
->hw
;
472 ms_iocb_entry_t
*ms_pkt
;
473 struct ct_sns_req
*ct_req
;
474 struct ct_sns_rsp
*ct_rsp
;
476 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
477 return qla2x00_sns_rft_id(vha
);
480 /* Prepare common MS IOCB */
481 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, RFT_ID_REQ_SIZE
,
484 /* Prepare CT request */
485 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RFT_ID_CMD
,
487 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
489 /* Prepare CT arguments -- port_id, FC-4 types */
490 ct_req
->req
.rft_id
.port_id
[0] = vha
->d_id
.b
.domain
;
491 ct_req
->req
.rft_id
.port_id
[1] = vha
->d_id
.b
.area
;
492 ct_req
->req
.rft_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
494 ct_req
->req
.rft_id
.fc4_types
[2] = 0x01; /* FCP-3 */
496 /* Execute MS IOCB */
497 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
498 sizeof(ms_iocb_entry_t
));
499 if (rval
!= QLA_SUCCESS
) {
501 ql_dbg(ql_dbg_disc
, vha
, 0x2043,
502 "RFT_ID issue IOCB failed (%d).\n", rval
);
503 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RFT_ID") !=
505 rval
= QLA_FUNCTION_FAILED
;
507 ql_dbg(ql_dbg_disc
, vha
, 0x2044,
508 "RFT_ID exiting normally.\n");
515 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
518 * Returns 0 on success.
521 qla2x00_rff_id(scsi_qla_host_t
*vha
)
524 struct qla_hw_data
*ha
= vha
->hw
;
525 ms_iocb_entry_t
*ms_pkt
;
526 struct ct_sns_req
*ct_req
;
527 struct ct_sns_rsp
*ct_rsp
;
529 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
530 ql_dbg(ql_dbg_disc
, vha
, 0x2046,
531 "RFF_ID call not supported on ISP2100/ISP2200.\n");
532 return (QLA_SUCCESS
);
536 /* Prepare common MS IOCB */
537 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, RFF_ID_REQ_SIZE
,
540 /* Prepare CT request */
541 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RFF_ID_CMD
,
543 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
545 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
546 ct_req
->req
.rff_id
.port_id
[0] = vha
->d_id
.b
.domain
;
547 ct_req
->req
.rff_id
.port_id
[1] = vha
->d_id
.b
.area
;
548 ct_req
->req
.rff_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
550 qlt_rff_id(vha
, ct_req
);
552 ct_req
->req
.rff_id
.fc4_type
= 0x08; /* SCSI - FCP */
554 /* Execute MS IOCB */
555 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
556 sizeof(ms_iocb_entry_t
));
557 if (rval
!= QLA_SUCCESS
) {
559 ql_dbg(ql_dbg_disc
, vha
, 0x2047,
560 "RFF_ID issue IOCB failed (%d).\n", rval
);
561 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RFF_ID") !=
563 rval
= QLA_FUNCTION_FAILED
;
565 ql_dbg(ql_dbg_disc
, vha
, 0x2048,
566 "RFF_ID exiting normally.\n");
573 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
576 * Returns 0 on success.
579 qla2x00_rnn_id(scsi_qla_host_t
*vha
)
582 struct qla_hw_data
*ha
= vha
->hw
;
583 ms_iocb_entry_t
*ms_pkt
;
584 struct ct_sns_req
*ct_req
;
585 struct ct_sns_rsp
*ct_rsp
;
587 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
588 return qla2x00_sns_rnn_id(vha
);
591 /* Prepare common MS IOCB */
592 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, RNN_ID_REQ_SIZE
,
595 /* Prepare CT request */
596 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RNN_ID_CMD
, RNN_ID_RSP_SIZE
);
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] = vha
->d_id
.b
.domain
;
601 ct_req
->req
.rnn_id
.port_id
[1] = vha
->d_id
.b
.area
;
602 ct_req
->req
.rnn_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
604 memcpy(ct_req
->req
.rnn_id
.node_name
, vha
->node_name
, WWN_SIZE
);
606 /* Execute MS IOCB */
607 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
608 sizeof(ms_iocb_entry_t
));
609 if (rval
!= QLA_SUCCESS
) {
611 ql_dbg(ql_dbg_disc
, vha
, 0x204d,
612 "RNN_ID issue IOCB failed (%d).\n", rval
);
613 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RNN_ID") !=
615 rval
= QLA_FUNCTION_FAILED
;
617 ql_dbg(ql_dbg_disc
, vha
, 0x204e,
618 "RNN_ID exiting normally.\n");
625 qla2x00_get_sym_node_name(scsi_qla_host_t
*vha
, uint8_t *snn
)
627 struct qla_hw_data
*ha
= vha
->hw
;
630 sprintf(snn
, "%s FW:v%s DVR:v%s", ha
->model_number
,
631 ha
->mr
.fw_version
, qla2x00_version_str
);
633 sprintf(snn
, "%s FW:v%d.%02d.%02d DVR:v%s", ha
->model_number
,
634 ha
->fw_major_version
, ha
->fw_minor_version
,
635 ha
->fw_subminor_version
, qla2x00_version_str
);
639 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
642 * Returns 0 on success.
645 qla2x00_rsnn_nn(scsi_qla_host_t
*vha
)
648 struct qla_hw_data
*ha
= vha
->hw
;
649 ms_iocb_entry_t
*ms_pkt
;
650 struct ct_sns_req
*ct_req
;
651 struct ct_sns_rsp
*ct_rsp
;
653 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
654 ql_dbg(ql_dbg_disc
, vha
, 0x2050,
655 "RSNN_ID call unsupported on ISP2100/ISP2200.\n");
656 return (QLA_SUCCESS
);
660 /* Prepare common MS IOCB */
661 /* Request size adjusted after CT preparation */
662 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, 0, RSNN_NN_RSP_SIZE
);
664 /* Prepare CT request */
665 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RSNN_NN_CMD
,
667 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
669 /* Prepare CT arguments -- node_name, symbolic node_name, size */
670 memcpy(ct_req
->req
.rsnn_nn
.node_name
, vha
->node_name
, WWN_SIZE
);
672 /* Prepare the Symbolic Node Name */
673 qla2x00_get_sym_node_name(vha
, ct_req
->req
.rsnn_nn
.sym_node_name
);
675 /* Calculate SNN length */
676 ct_req
->req
.rsnn_nn
.name_len
=
677 (uint8_t)strlen(ct_req
->req
.rsnn_nn
.sym_node_name
);
679 /* Update MS IOCB request */
680 ms_pkt
->req_bytecount
=
681 cpu_to_le32(24 + 1 + ct_req
->req
.rsnn_nn
.name_len
);
682 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
684 /* Execute MS IOCB */
685 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
686 sizeof(ms_iocb_entry_t
));
687 if (rval
!= QLA_SUCCESS
) {
689 ql_dbg(ql_dbg_disc
, vha
, 0x2051,
690 "RSNN_NN issue IOCB failed (%d).\n", rval
);
691 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RSNN_NN") !=
693 rval
= QLA_FUNCTION_FAILED
;
695 ql_dbg(ql_dbg_disc
, vha
, 0x2052,
696 "RSNN_NN exiting normally.\n");
703 * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
706 * @scmd_len: Subcommand length
707 * @data_size: response size in bytes
709 * Returns a pointer to the @ha's sns_cmd.
711 static inline struct sns_cmd_pkt
*
712 qla2x00_prep_sns_cmd(scsi_qla_host_t
*vha
, uint16_t cmd
, uint16_t scmd_len
,
716 struct sns_cmd_pkt
*sns_cmd
;
717 struct qla_hw_data
*ha
= vha
->hw
;
719 sns_cmd
= ha
->sns_cmd
;
720 memset(sns_cmd
, 0, sizeof(struct sns_cmd_pkt
));
721 wc
= data_size
/ 2; /* Size in 16bit words. */
722 sns_cmd
->p
.cmd
.buffer_length
= cpu_to_le16(wc
);
723 sns_cmd
->p
.cmd
.buffer_address
[0] = cpu_to_le32(LSD(ha
->sns_cmd_dma
));
724 sns_cmd
->p
.cmd
.buffer_address
[1] = cpu_to_le32(MSD(ha
->sns_cmd_dma
));
725 sns_cmd
->p
.cmd
.subcommand_length
= cpu_to_le16(scmd_len
);
726 sns_cmd
->p
.cmd
.subcommand
= cpu_to_le16(cmd
);
727 wc
= (data_size
- 16) / 4; /* Size in 32bit words. */
728 sns_cmd
->p
.cmd
.size
= cpu_to_le16(wc
);
730 vha
->qla_stats
.control_requests
++;
736 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
738 * @fcport: fcport entry to updated
740 * This command uses the old Exectute SNS Command mailbox routine.
742 * Returns 0 on success.
745 qla2x00_sns_ga_nxt(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
747 int rval
= QLA_SUCCESS
;
748 struct qla_hw_data
*ha
= vha
->hw
;
749 struct sns_cmd_pkt
*sns_cmd
;
752 /* Prepare SNS command request. */
753 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GA_NXT_CMD
, GA_NXT_SNS_SCMD_LEN
,
754 GA_NXT_SNS_DATA_SIZE
);
756 /* Prepare SNS command arguments -- port_id. */
757 sns_cmd
->p
.cmd
.param
[0] = fcport
->d_id
.b
.al_pa
;
758 sns_cmd
->p
.cmd
.param
[1] = fcport
->d_id
.b
.area
;
759 sns_cmd
->p
.cmd
.param
[2] = fcport
->d_id
.b
.domain
;
761 /* Execute SNS command. */
762 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, GA_NXT_SNS_CMD_SIZE
/ 2,
763 sizeof(struct sns_cmd_pkt
));
764 if (rval
!= QLA_SUCCESS
) {
766 ql_dbg(ql_dbg_disc
, vha
, 0x205f,
767 "GA_NXT Send SNS failed (%d).\n", rval
);
768 } else if (sns_cmd
->p
.gan_data
[8] != 0x80 ||
769 sns_cmd
->p
.gan_data
[9] != 0x02) {
770 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2084,
771 "GA_NXT failed, rejected request ga_nxt_rsp:\n");
772 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2074,
773 sns_cmd
->p
.gan_data
, 16);
774 rval
= QLA_FUNCTION_FAILED
;
776 /* Populate fc_port_t entry. */
777 fcport
->d_id
.b
.domain
= sns_cmd
->p
.gan_data
[17];
778 fcport
->d_id
.b
.area
= sns_cmd
->p
.gan_data
[18];
779 fcport
->d_id
.b
.al_pa
= sns_cmd
->p
.gan_data
[19];
781 memcpy(fcport
->node_name
, &sns_cmd
->p
.gan_data
[284], WWN_SIZE
);
782 memcpy(fcport
->port_name
, &sns_cmd
->p
.gan_data
[20], WWN_SIZE
);
784 if (sns_cmd
->p
.gan_data
[16] != NS_N_PORT_TYPE
&&
785 sns_cmd
->p
.gan_data
[16] != NS_NL_PORT_TYPE
)
786 fcport
->d_id
.b
.domain
= 0xf0;
788 ql_dbg(ql_dbg_disc
, vha
, 0x2061,
789 "GA_NXT entry - nn %8phN pn %8phN "
790 "port_id=%02x%02x%02x.\n",
791 fcport
->node_name
, fcport
->port_name
,
792 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
793 fcport
->d_id
.b
.al_pa
);
800 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
802 * @list: switch info entries to populate
804 * This command uses the old Exectute SNS Command mailbox routine.
806 * NOTE: Non-Nx_Ports are not requested.
808 * Returns 0 on success.
811 qla2x00_sns_gid_pt(scsi_qla_host_t
*vha
, sw_info_t
*list
)
814 struct qla_hw_data
*ha
= vha
->hw
;
817 struct sns_cmd_pkt
*sns_cmd
;
818 uint16_t gid_pt_sns_data_size
;
820 gid_pt_sns_data_size
= qla2x00_gid_pt_rsp_size(vha
);
823 /* Prepare SNS command request. */
824 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GID_PT_CMD
, GID_PT_SNS_SCMD_LEN
,
825 gid_pt_sns_data_size
);
827 /* Prepare SNS command arguments -- port_type. */
828 sns_cmd
->p
.cmd
.param
[0] = NS_NX_PORT_TYPE
;
830 /* Execute SNS command. */
831 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, GID_PT_SNS_CMD_SIZE
/ 2,
832 sizeof(struct sns_cmd_pkt
));
833 if (rval
!= QLA_SUCCESS
) {
835 ql_dbg(ql_dbg_disc
, vha
, 0x206d,
836 "GID_PT Send SNS failed (%d).\n", rval
);
837 } else if (sns_cmd
->p
.gid_data
[8] != 0x80 ||
838 sns_cmd
->p
.gid_data
[9] != 0x02) {
839 ql_dbg(ql_dbg_disc
, vha
, 0x202f,
840 "GID_PT failed, rejected request, gid_rsp:\n");
841 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2081,
842 sns_cmd
->p
.gid_data
, 16);
843 rval
= QLA_FUNCTION_FAILED
;
845 /* Set port IDs in switch info list. */
846 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
847 entry
= &sns_cmd
->p
.gid_data
[(i
* 4) + 16];
848 list
[i
].d_id
.b
.domain
= entry
[1];
849 list
[i
].d_id
.b
.area
= entry
[2];
850 list
[i
].d_id
.b
.al_pa
= entry
[3];
853 if (entry
[0] & BIT_7
) {
854 list
[i
].d_id
.b
.rsvd_1
= entry
[0];
860 * If we've used all available slots, then the switch is
861 * reporting back more devices that we can handle with this
862 * single call. Return a failed status, and let GA_NXT handle
865 if (i
== ha
->max_fibre_devices
)
866 rval
= QLA_FUNCTION_FAILED
;
873 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
875 * @list: switch info entries to populate
877 * This command uses the old Exectute SNS Command mailbox routine.
879 * Returns 0 on success.
882 qla2x00_sns_gpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
884 int rval
= QLA_SUCCESS
;
885 struct qla_hw_data
*ha
= vha
->hw
;
887 struct sns_cmd_pkt
*sns_cmd
;
889 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
891 /* Prepare SNS command request. */
892 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GPN_ID_CMD
,
893 GPN_ID_SNS_SCMD_LEN
, GPN_ID_SNS_DATA_SIZE
);
895 /* Prepare SNS command arguments -- port_id. */
896 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
897 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
898 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
900 /* Execute SNS command. */
901 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
,
902 GPN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
903 if (rval
!= QLA_SUCCESS
) {
905 ql_dbg(ql_dbg_disc
, vha
, 0x2032,
906 "GPN_ID Send SNS failed (%d).\n", rval
);
907 } else if (sns_cmd
->p
.gpn_data
[8] != 0x80 ||
908 sns_cmd
->p
.gpn_data
[9] != 0x02) {
909 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207e,
910 "GPN_ID failed, rejected request, gpn_rsp:\n");
911 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207f,
912 sns_cmd
->p
.gpn_data
, 16);
913 rval
= QLA_FUNCTION_FAILED
;
916 memcpy(list
[i
].port_name
, &sns_cmd
->p
.gpn_data
[16],
920 /* Last device exit. */
921 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
929 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
931 * @list: switch info entries to populate
933 * This command uses the old Exectute SNS Command mailbox routine.
935 * Returns 0 on success.
938 qla2x00_sns_gnn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
940 int rval
= QLA_SUCCESS
;
941 struct qla_hw_data
*ha
= vha
->hw
;
943 struct sns_cmd_pkt
*sns_cmd
;
945 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
947 /* Prepare SNS command request. */
948 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GNN_ID_CMD
,
949 GNN_ID_SNS_SCMD_LEN
, GNN_ID_SNS_DATA_SIZE
);
951 /* Prepare SNS command arguments -- port_id. */
952 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
953 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
954 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
956 /* Execute SNS command. */
957 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
,
958 GNN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
959 if (rval
!= QLA_SUCCESS
) {
961 ql_dbg(ql_dbg_disc
, vha
, 0x203f,
962 "GNN_ID Send SNS failed (%d).\n", rval
);
963 } else if (sns_cmd
->p
.gnn_data
[8] != 0x80 ||
964 sns_cmd
->p
.gnn_data
[9] != 0x02) {
965 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2082,
966 "GNN_ID failed, rejected request, gnn_rsp:\n");
967 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207a,
968 sns_cmd
->p
.gnn_data
, 16);
969 rval
= QLA_FUNCTION_FAILED
;
972 memcpy(list
[i
].node_name
, &sns_cmd
->p
.gnn_data
[16],
975 ql_dbg(ql_dbg_disc
, vha
, 0x206e,
976 "GID_PT entry - nn %8phN pn %8phN "
977 "port_id=%02x%02x%02x.\n",
978 list
[i
].node_name
, list
[i
].port_name
,
979 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
980 list
[i
].d_id
.b
.al_pa
);
983 /* Last device exit. */
984 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
992 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
995 * This command uses the old Exectute SNS Command mailbox routine.
997 * Returns 0 on success.
1000 qla2x00_sns_rft_id(scsi_qla_host_t
*vha
)
1003 struct qla_hw_data
*ha
= vha
->hw
;
1004 struct sns_cmd_pkt
*sns_cmd
;
1007 /* Prepare SNS command request. */
1008 sns_cmd
= qla2x00_prep_sns_cmd(vha
, RFT_ID_CMD
, RFT_ID_SNS_SCMD_LEN
,
1009 RFT_ID_SNS_DATA_SIZE
);
1011 /* Prepare SNS command arguments -- port_id, FC-4 types */
1012 sns_cmd
->p
.cmd
.param
[0] = vha
->d_id
.b
.al_pa
;
1013 sns_cmd
->p
.cmd
.param
[1] = vha
->d_id
.b
.area
;
1014 sns_cmd
->p
.cmd
.param
[2] = vha
->d_id
.b
.domain
;
1016 sns_cmd
->p
.cmd
.param
[5] = 0x01; /* FCP-3 */
1018 /* Execute SNS command. */
1019 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, RFT_ID_SNS_CMD_SIZE
/ 2,
1020 sizeof(struct sns_cmd_pkt
));
1021 if (rval
!= QLA_SUCCESS
) {
1023 ql_dbg(ql_dbg_disc
, vha
, 0x2060,
1024 "RFT_ID Send SNS failed (%d).\n", rval
);
1025 } else if (sns_cmd
->p
.rft_data
[8] != 0x80 ||
1026 sns_cmd
->p
.rft_data
[9] != 0x02) {
1027 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2083,
1028 "RFT_ID failed, rejected request rft_rsp:\n");
1029 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2080,
1030 sns_cmd
->p
.rft_data
, 16);
1031 rval
= QLA_FUNCTION_FAILED
;
1033 ql_dbg(ql_dbg_disc
, vha
, 0x2073,
1034 "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
*vha
)
1053 struct qla_hw_data
*ha
= vha
->hw
;
1054 struct sns_cmd_pkt
*sns_cmd
;
1057 /* Prepare SNS command request. */
1058 sns_cmd
= qla2x00_prep_sns_cmd(vha
, 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] = vha
->d_id
.b
.al_pa
;
1063 sns_cmd
->p
.cmd
.param
[1] = vha
->d_id
.b
.area
;
1064 sns_cmd
->p
.cmd
.param
[2] = vha
->d_id
.b
.domain
;
1066 sns_cmd
->p
.cmd
.param
[4] = vha
->node_name
[7];
1067 sns_cmd
->p
.cmd
.param
[5] = vha
->node_name
[6];
1068 sns_cmd
->p
.cmd
.param
[6] = vha
->node_name
[5];
1069 sns_cmd
->p
.cmd
.param
[7] = vha
->node_name
[4];
1070 sns_cmd
->p
.cmd
.param
[8] = vha
->node_name
[3];
1071 sns_cmd
->p
.cmd
.param
[9] = vha
->node_name
[2];
1072 sns_cmd
->p
.cmd
.param
[10] = vha
->node_name
[1];
1073 sns_cmd
->p
.cmd
.param
[11] = vha
->node_name
[0];
1075 /* Execute SNS command. */
1076 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, RNN_ID_SNS_CMD_SIZE
/ 2,
1077 sizeof(struct sns_cmd_pkt
));
1078 if (rval
!= QLA_SUCCESS
) {
1080 ql_dbg(ql_dbg_disc
, vha
, 0x204a,
1081 "RNN_ID Send SNS failed (%d).\n", rval
);
1082 } else if (sns_cmd
->p
.rnn_data
[8] != 0x80 ||
1083 sns_cmd
->p
.rnn_data
[9] != 0x02) {
1084 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207b,
1085 "RNN_ID failed, rejected request, rnn_rsp:\n");
1086 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207c,
1087 sns_cmd
->p
.rnn_data
, 16);
1088 rval
= QLA_FUNCTION_FAILED
;
1090 ql_dbg(ql_dbg_disc
, vha
, 0x204c,
1091 "RNN_ID exiting normally.\n");
1098 * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
1101 * Returns 0 on success.
1104 qla2x00_mgmt_svr_login(scsi_qla_host_t
*vha
)
1107 uint16_t mb
[MAILBOX_REGISTER_COUNT
];
1108 struct qla_hw_data
*ha
= vha
->hw
;
1110 if (vha
->flags
.management_server_logged_in
)
1113 rval
= ha
->isp_ops
->fabric_login(vha
, vha
->mgmt_svr_loop_id
, 0xff, 0xff,
1115 if (rval
!= QLA_SUCCESS
|| mb
[0] != MBS_COMMAND_COMPLETE
) {
1116 if (rval
== QLA_MEMORY_ALLOC_FAILED
)
1117 ql_dbg(ql_dbg_disc
, vha
, 0x2085,
1118 "Failed management_server login: loopid=%x "
1119 "rval=%d\n", vha
->mgmt_svr_loop_id
, rval
);
1121 ql_dbg(ql_dbg_disc
, vha
, 0x2024,
1122 "Failed management_server login: loopid=%x "
1123 "mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x.\n",
1124 vha
->mgmt_svr_loop_id
, mb
[0], mb
[1], mb
[2], mb
[6],
1126 ret
= QLA_FUNCTION_FAILED
;
1128 vha
->flags
.management_server_logged_in
= 1;
1134 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1136 * @req_size: request size in bytes
1137 * @rsp_size: response size in bytes
1139 * Returns a pointer to the @ha's ms_iocb.
1142 qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1145 ms_iocb_entry_t
*ms_pkt
;
1146 struct qla_hw_data
*ha
= vha
->hw
;
1147 ms_pkt
= ha
->ms_iocb
;
1148 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
1150 ms_pkt
->entry_type
= MS_IOCB_TYPE
;
1151 ms_pkt
->entry_count
= 1;
1152 SET_TARGET_ID(ha
, ms_pkt
->loop_id
, vha
->mgmt_svr_loop_id
);
1153 ms_pkt
->control_flags
= __constant_cpu_to_le16(CF_READ
| CF_HEAD_TAG
);
1154 ms_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1155 ms_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1156 ms_pkt
->total_dsd_count
= __constant_cpu_to_le16(2);
1157 ms_pkt
->rsp_bytecount
= cpu_to_le32(rsp_size
);
1158 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1160 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1161 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1162 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1164 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1165 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1166 ms_pkt
->dseg_rsp_length
= ms_pkt
->rsp_bytecount
;
1172 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1174 * @req_size: request size in bytes
1175 * @rsp_size: response size in bytes
1177 * Returns a pointer to the @ha's ms_iocb.
1180 qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1183 struct ct_entry_24xx
*ct_pkt
;
1184 struct qla_hw_data
*ha
= vha
->hw
;
1186 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1187 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1189 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1190 ct_pkt
->entry_count
= 1;
1191 ct_pkt
->nport_handle
= cpu_to_le16(vha
->mgmt_svr_loop_id
);
1192 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1193 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1194 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
1195 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1196 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1198 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1199 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1200 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1202 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1203 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1204 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1205 ct_pkt
->vp_index
= vha
->vp_idx
;
1210 static inline ms_iocb_entry_t
*
1211 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
)
1213 struct qla_hw_data
*ha
= vha
->hw
;
1214 ms_iocb_entry_t
*ms_pkt
= ha
->ms_iocb
;
1215 struct ct_entry_24xx
*ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1217 if (IS_FWI2_CAPABLE(ha
)) {
1218 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1219 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1221 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1222 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1229 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1230 * @ct_req: CT request buffer
1232 * @rsp_size: response size in bytes
1234 * Returns a pointer to the intitialized @ct_req.
1236 static inline struct ct_sns_req
*
1237 qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt
*p
, uint16_t cmd
,
1240 memset(p
, 0, sizeof(struct ct_sns_pkt
));
1242 p
->p
.req
.header
.revision
= 0x01;
1243 p
->p
.req
.header
.gs_type
= 0xFA;
1244 p
->p
.req
.header
.gs_subtype
= 0x10;
1245 p
->p
.req
.command
= cpu_to_be16(cmd
);
1246 p
->p
.req
.max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1252 * qla2x00_fdmi_rhba() -
1255 * Returns 0 on success.
1258 qla2x00_fdmi_rhba(scsi_qla_host_t
*vha
)
1263 ms_iocb_entry_t
*ms_pkt
;
1264 struct ct_sns_req
*ct_req
;
1265 struct ct_sns_rsp
*ct_rsp
;
1267 struct ct_fdmi_hba_attr
*eiter
;
1268 struct qla_hw_data
*ha
= vha
->hw
;
1271 /* Prepare common MS IOCB */
1272 /* Request size adjusted after CT preparation */
1273 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 0, RHBA_RSP_SIZE
);
1275 /* Prepare CT request */
1276 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, RHBA_CMD
, RHBA_RSP_SIZE
);
1277 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1279 /* Prepare FDMI command arguments -- attribute block, attributes. */
1280 memcpy(ct_req
->req
.rhba
.hba_identifier
, vha
->port_name
, WWN_SIZE
);
1281 ct_req
->req
.rhba
.entry_count
= __constant_cpu_to_be32(1);
1282 memcpy(ct_req
->req
.rhba
.port_name
, vha
->port_name
, WWN_SIZE
);
1283 size
= 2 * WWN_SIZE
+ 4 + 4;
1286 ct_req
->req
.rhba
.attrs
.count
=
1287 __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT
);
1288 entries
= ct_req
->req
.rhba
.hba_identifier
;
1291 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1292 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_NODE_NAME
);
1293 eiter
->len
= __constant_cpu_to_be16(4 + WWN_SIZE
);
1294 memcpy(eiter
->a
.node_name
, vha
->node_name
, WWN_SIZE
);
1295 size
+= 4 + WWN_SIZE
;
1297 ql_dbg(ql_dbg_disc
, vha
, 0x2025,
1298 "NodeName = %8phN.\n", eiter
->a
.node_name
);
1301 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1302 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER
);
1303 alen
= strlen(QLA2XXX_MANUFACTURER
);
1304 strncpy(eiter
->a
.manufacturer
, QLA2XXX_MANUFACTURER
, alen
+ 1);
1305 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1306 eiter
->len
= cpu_to_be16(4 + alen
);
1309 ql_dbg(ql_dbg_disc
, vha
, 0x2026,
1310 "Manufacturer = %s.\n", eiter
->a
.manufacturer
);
1312 /* Serial number. */
1313 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1314 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER
);
1315 sn
= ((ha
->serial0
& 0x1f) << 16) | (ha
->serial2
<< 8) | ha
->serial1
;
1316 sprintf(eiter
->a
.serial_num
, "%c%05d", 'A' + sn
/ 100000, sn
% 100000);
1317 alen
= strlen(eiter
->a
.serial_num
);
1318 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1319 eiter
->len
= cpu_to_be16(4 + alen
);
1322 ql_dbg(ql_dbg_disc
, vha
, 0x2027,
1323 "Serial no. = %s.\n", eiter
->a
.serial_num
);
1326 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1327 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_MODEL
);
1328 strcpy(eiter
->a
.model
, ha
->model_number
);
1329 alen
= strlen(eiter
->a
.model
);
1330 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1331 eiter
->len
= cpu_to_be16(4 + alen
);
1334 ql_dbg(ql_dbg_disc
, vha
, 0x2028,
1335 "Model Name = %s.\n", eiter
->a
.model
);
1337 /* Model description. */
1338 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1339 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION
);
1340 strncpy(eiter
->a
.model_desc
, ha
->model_desc
, 80);
1341 alen
= strlen(eiter
->a
.model_desc
);
1342 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1343 eiter
->len
= cpu_to_be16(4 + alen
);
1346 ql_dbg(ql_dbg_disc
, vha
, 0x2029,
1347 "Model Desc = %s.\n", eiter
->a
.model_desc
);
1349 /* Hardware version. */
1350 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1351 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION
);
1352 strcpy(eiter
->a
.hw_version
, ha
->adapter_id
);
1353 alen
= strlen(eiter
->a
.hw_version
);
1354 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1355 eiter
->len
= cpu_to_be16(4 + alen
);
1358 ql_dbg(ql_dbg_disc
, vha
, 0x202a,
1359 "Hardware ver = %s.\n", eiter
->a
.hw_version
);
1361 /* Driver version. */
1362 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1363 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION
);
1364 strcpy(eiter
->a
.driver_version
, qla2x00_version_str
);
1365 alen
= strlen(eiter
->a
.driver_version
);
1366 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1367 eiter
->len
= cpu_to_be16(4 + alen
);
1370 ql_dbg(ql_dbg_disc
, vha
, 0x202b,
1371 "Driver ver = %s.\n", eiter
->a
.driver_version
);
1373 /* Option ROM version. */
1374 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1375 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION
);
1376 strcpy(eiter
->a
.orom_version
, "0.00");
1377 alen
= strlen(eiter
->a
.orom_version
);
1378 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1379 eiter
->len
= cpu_to_be16(4 + alen
);
1382 ql_dbg(ql_dbg_disc
, vha
, 0x202c,
1383 "Optrom vers = %s.\n", eiter
->a
.orom_version
);
1385 /* Firmware version */
1386 eiter
= (struct ct_fdmi_hba_attr
*) (entries
+ size
);
1387 eiter
->type
= __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION
);
1388 ha
->isp_ops
->fw_version_str(vha
, eiter
->a
.fw_version
);
1389 alen
= strlen(eiter
->a
.fw_version
);
1390 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1391 eiter
->len
= cpu_to_be16(4 + alen
);
1394 ql_dbg(ql_dbg_disc
, vha
, 0x202d,
1395 "Firmware vers = %s.\n", eiter
->a
.fw_version
);
1397 /* Update MS request size. */
1398 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
1400 ql_dbg(ql_dbg_disc
, vha
, 0x202e,
1401 "RHBA identifier = %8phN size=%d.\n",
1402 ct_req
->req
.rhba
.hba_identifier
, size
);
1403 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2076,
1406 /* Execute MS IOCB */
1407 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1408 sizeof(ms_iocb_entry_t
));
1409 if (rval
!= QLA_SUCCESS
) {
1411 ql_dbg(ql_dbg_disc
, vha
, 0x2030,
1412 "RHBA issue IOCB failed (%d).\n", rval
);
1413 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RHBA") !=
1415 rval
= QLA_FUNCTION_FAILED
;
1416 if (ct_rsp
->header
.reason_code
== CT_REASON_CANNOT_PERFORM
&&
1417 ct_rsp
->header
.explanation_code
==
1418 CT_EXPL_ALREADY_REGISTERED
) {
1419 ql_dbg(ql_dbg_disc
, vha
, 0x2034,
1420 "HBA already registered.\n");
1421 rval
= QLA_ALREADY_REGISTERED
;
1424 ql_dbg(ql_dbg_disc
, vha
, 0x2035,
1425 "RHBA exiting normally.\n");
1432 * qla2x00_fdmi_dhba() -
1435 * Returns 0 on success.
1438 qla2x00_fdmi_dhba(scsi_qla_host_t
*vha
)
1441 struct qla_hw_data
*ha
= vha
->hw
;
1442 ms_iocb_entry_t
*ms_pkt
;
1443 struct ct_sns_req
*ct_req
;
1444 struct ct_sns_rsp
*ct_rsp
;
1447 /* Prepare common MS IOCB */
1448 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, DHBA_REQ_SIZE
,
1451 /* Prepare CT request */
1452 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, DHBA_CMD
, DHBA_RSP_SIZE
);
1453 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1455 /* Prepare FDMI command arguments -- portname. */
1456 memcpy(ct_req
->req
.dhba
.port_name
, vha
->port_name
, WWN_SIZE
);
1458 ql_dbg(ql_dbg_disc
, vha
, 0x2036,
1459 "DHBA portname = %8phN.\n", ct_req
->req
.dhba
.port_name
);
1461 /* Execute MS IOCB */
1462 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1463 sizeof(ms_iocb_entry_t
));
1464 if (rval
!= QLA_SUCCESS
) {
1466 ql_dbg(ql_dbg_disc
, vha
, 0x2037,
1467 "DHBA issue IOCB failed (%d).\n", rval
);
1468 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "DHBA") !=
1470 rval
= QLA_FUNCTION_FAILED
;
1472 ql_dbg(ql_dbg_disc
, vha
, 0x2038,
1473 "DHBA exiting normally.\n");
1480 * qla2x00_fdmi_rpa() -
1483 * Returns 0 on success.
1486 qla2x00_fdmi_rpa(scsi_qla_host_t
*vha
)
1489 uint32_t size
, max_frame_size
;
1490 struct qla_hw_data
*ha
= vha
->hw
;
1491 ms_iocb_entry_t
*ms_pkt
;
1492 struct ct_sns_req
*ct_req
;
1493 struct ct_sns_rsp
*ct_rsp
;
1495 struct ct_fdmi_port_attr
*eiter
;
1496 struct init_cb_24xx
*icb24
= (struct init_cb_24xx
*)ha
->init_cb
;
1499 /* Prepare common MS IOCB */
1500 /* Request size adjusted after CT preparation */
1501 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 0, RPA_RSP_SIZE
);
1503 /* Prepare CT request */
1504 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, RPA_CMD
, RPA_RSP_SIZE
);
1505 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1507 /* Prepare FDMI command arguments -- attribute block, attributes. */
1508 memcpy(ct_req
->req
.rpa
.port_name
, vha
->port_name
, WWN_SIZE
);
1509 size
= WWN_SIZE
+ 4;
1512 ct_req
->req
.rpa
.attrs
.count
=
1513 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT
- 1);
1514 entries
= ct_req
->req
.rpa
.port_name
;
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;
1523 ql_dbg(ql_dbg_disc
, vha
, 0x2039,
1524 "FC4_TYPES=%02x %02x.\n",
1525 eiter
->a
.fc4_types
[2],
1526 eiter
->a
.fc4_types
[1]);
1528 /* Supported speed. */
1529 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1530 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED
);
1531 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1532 if (IS_CNA_CAPABLE(ha
))
1533 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1534 FDMI_PORT_SPEED_10GB
);
1535 else if (IS_QLA25XX(ha
))
1536 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1537 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
|
1538 FDMI_PORT_SPEED_4GB
|FDMI_PORT_SPEED_8GB
);
1539 else if (IS_QLA24XX_TYPE(ha
))
1540 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1541 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
|
1542 FDMI_PORT_SPEED_4GB
);
1543 else if (IS_QLA23XX(ha
))
1544 eiter
->a
.sup_speed
=__constant_cpu_to_be32(
1545 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
);
1547 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1548 FDMI_PORT_SPEED_1GB
);
1551 ql_dbg(ql_dbg_disc
, vha
, 0x203a,
1552 "Supported_Speed=%x.\n", eiter
->a
.sup_speed
);
1554 /* Current speed. */
1555 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1556 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED
);
1557 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1558 switch (ha
->link_data_rate
) {
1559 case PORT_SPEED_1GB
:
1560 eiter
->a
.cur_speed
=
1561 __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB
);
1563 case PORT_SPEED_2GB
:
1564 eiter
->a
.cur_speed
=
1565 __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB
);
1567 case PORT_SPEED_4GB
:
1568 eiter
->a
.cur_speed
=
1569 __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB
);
1571 case PORT_SPEED_8GB
:
1572 eiter
->a
.cur_speed
=
1573 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB
);
1575 case PORT_SPEED_10GB
:
1576 eiter
->a
.cur_speed
=
1577 __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB
);
1579 case PORT_SPEED_16GB
:
1580 eiter
->a
.cur_speed
=
1581 __constant_cpu_to_be32(FDMI_PORT_SPEED_16GB
);
1584 eiter
->a
.cur_speed
=
1585 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN
);
1590 ql_dbg(ql_dbg_disc
, vha
, 0x203b,
1591 "Current_Speed=%x.\n", eiter
->a
.cur_speed
);
1593 /* Max frame size. */
1594 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1595 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE
);
1596 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1597 max_frame_size
= IS_FWI2_CAPABLE(ha
) ?
1598 le16_to_cpu(icb24
->frame_payload_size
):
1599 le16_to_cpu(ha
->init_cb
->frame_payload_size
);
1600 eiter
->a
.max_frame_size
= cpu_to_be32(max_frame_size
);
1603 ql_dbg(ql_dbg_disc
, vha
, 0x203c,
1604 "Max_Frame_Size=%x.\n", eiter
->a
.max_frame_size
);
1606 /* OS device name. */
1607 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1608 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME
);
1609 alen
= strlen(QLA2XXX_DRIVER_NAME
);
1610 strncpy(eiter
->a
.os_dev_name
, QLA2XXX_DRIVER_NAME
, alen
+ 1);
1611 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1612 eiter
->len
= cpu_to_be16(4 + alen
);
1615 ql_dbg(ql_dbg_disc
, vha
, 0x204b,
1616 "OS_Device_Name=%s.\n", eiter
->a
.os_dev_name
);
1619 if (strlen(fc_host_system_hostname(vha
->host
))) {
1620 ct_req
->req
.rpa
.attrs
.count
=
1621 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT
);
1622 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1623 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_HOST_NAME
);
1624 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
1625 "%s", fc_host_system_hostname(vha
->host
));
1626 alen
= strlen(eiter
->a
.host_name
);
1627 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1628 eiter
->len
= cpu_to_be16(4 + alen
);
1631 ql_dbg(ql_dbg_disc
, vha
, 0x203d,
1632 "HostName=%s.\n", eiter
->a
.host_name
);
1635 /* Update MS request size. */
1636 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
1638 ql_dbg(ql_dbg_disc
, vha
, 0x203e,
1639 "RPA portname= %8phN size=%d.\n", ct_req
->req
.rpa
.port_name
, size
);
1640 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2079,
1643 /* Execute MS IOCB */
1644 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1645 sizeof(ms_iocb_entry_t
));
1646 if (rval
!= QLA_SUCCESS
) {
1648 ql_dbg(ql_dbg_disc
, vha
, 0x2040,
1649 "RPA issue IOCB failed (%d).\n", rval
);
1650 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RPA") !=
1652 rval
= QLA_FUNCTION_FAILED
;
1654 ql_dbg(ql_dbg_disc
, vha
, 0x2041,
1655 "RPA exiting nornally.\n");
1662 * qla2x00_fdmi_register() -
1665 * Returns 0 on success.
1668 qla2x00_fdmi_register(scsi_qla_host_t
*vha
)
1671 struct qla_hw_data
*ha
= vha
->hw
;
1673 if (IS_QLA2100(ha
) || IS_QLA2200(ha
) ||
1675 return QLA_FUNCTION_FAILED
;
1677 rval
= qla2x00_mgmt_svr_login(vha
);
1681 rval
= qla2x00_fdmi_rhba(vha
);
1683 if (rval
!= QLA_ALREADY_REGISTERED
)
1686 rval
= qla2x00_fdmi_dhba(vha
);
1690 rval
= qla2x00_fdmi_rhba(vha
);
1694 rval
= qla2x00_fdmi_rpa(vha
);
1700 * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
1702 * @list: switch info entries to populate
1704 * Returns 0 on success.
1707 qla2x00_gfpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
1709 int rval
= QLA_SUCCESS
;
1711 struct qla_hw_data
*ha
= vha
->hw
;
1712 ms_iocb_entry_t
*ms_pkt
;
1713 struct ct_sns_req
*ct_req
;
1714 struct ct_sns_rsp
*ct_rsp
;
1716 if (!IS_IIDMA_CAPABLE(ha
))
1717 return QLA_FUNCTION_FAILED
;
1719 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
1721 /* Prepare common MS IOCB */
1722 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GFPN_ID_REQ_SIZE
,
1725 /* Prepare CT request */
1726 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GFPN_ID_CMD
,
1728 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1730 /* Prepare CT arguments -- port_id */
1731 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
1732 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
1733 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
1735 /* Execute MS IOCB */
1736 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1737 sizeof(ms_iocb_entry_t
));
1738 if (rval
!= QLA_SUCCESS
) {
1740 ql_dbg(ql_dbg_disc
, vha
, 0x2023,
1741 "GFPN_ID issue IOCB failed (%d).\n", rval
);
1743 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
1744 "GFPN_ID") != QLA_SUCCESS
) {
1745 rval
= QLA_FUNCTION_FAILED
;
1748 /* Save fabric portname */
1749 memcpy(list
[i
].fabric_port_name
,
1750 ct_rsp
->rsp
.gfpn_id
.port_name
, WWN_SIZE
);
1753 /* Last device exit. */
1754 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
1761 static inline void *
1762 qla24xx_prep_ms_fm_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1765 struct ct_entry_24xx
*ct_pkt
;
1766 struct qla_hw_data
*ha
= vha
->hw
;
1767 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1768 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1770 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1771 ct_pkt
->entry_count
= 1;
1772 ct_pkt
->nport_handle
= cpu_to_le16(vha
->mgmt_svr_loop_id
);
1773 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1774 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1775 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
1776 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1777 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1779 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1780 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1781 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1783 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1784 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1785 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1786 ct_pkt
->vp_index
= vha
->vp_idx
;
1792 static inline struct ct_sns_req
*
1793 qla24xx_prep_ct_fm_req(struct ct_sns_pkt
*p
, uint16_t cmd
,
1796 memset(p
, 0, sizeof(struct ct_sns_pkt
));
1798 p
->p
.req
.header
.revision
= 0x01;
1799 p
->p
.req
.header
.gs_type
= 0xFA;
1800 p
->p
.req
.header
.gs_subtype
= 0x01;
1801 p
->p
.req
.command
= cpu_to_be16(cmd
);
1802 p
->p
.req
.max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1808 * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
1810 * @list: switch info entries to populate
1812 * Returns 0 on success.
1815 qla2x00_gpsc(scsi_qla_host_t
*vha
, sw_info_t
*list
)
1819 struct qla_hw_data
*ha
= vha
->hw
;
1820 ms_iocb_entry_t
*ms_pkt
;
1821 struct ct_sns_req
*ct_req
;
1822 struct ct_sns_rsp
*ct_rsp
;
1824 if (!IS_IIDMA_CAPABLE(ha
))
1825 return QLA_FUNCTION_FAILED
;
1826 if (!ha
->flags
.gpsc_supported
)
1827 return QLA_FUNCTION_FAILED
;
1829 rval
= qla2x00_mgmt_svr_login(vha
);
1833 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
1835 /* Prepare common MS IOCB */
1836 ms_pkt
= qla24xx_prep_ms_fm_iocb(vha
, GPSC_REQ_SIZE
,
1839 /* Prepare CT request */
1840 ct_req
= qla24xx_prep_ct_fm_req(ha
->ct_sns
, GPSC_CMD
,
1842 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1844 /* Prepare CT arguments -- port_name */
1845 memcpy(ct_req
->req
.gpsc
.port_name
, list
[i
].fabric_port_name
,
1848 /* Execute MS IOCB */
1849 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1850 sizeof(ms_iocb_entry_t
));
1851 if (rval
!= QLA_SUCCESS
) {
1853 ql_dbg(ql_dbg_disc
, vha
, 0x2059,
1854 "GPSC issue IOCB failed (%d).\n", rval
);
1855 } else if ((rval
= qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
1856 "GPSC")) != QLA_SUCCESS
) {
1857 /* FM command unsupported? */
1858 if (rval
== QLA_INVALID_COMMAND
&&
1859 (ct_rsp
->header
.reason_code
==
1860 CT_REASON_INVALID_COMMAND_CODE
||
1861 ct_rsp
->header
.reason_code
==
1862 CT_REASON_COMMAND_UNSUPPORTED
)) {
1863 ql_dbg(ql_dbg_disc
, vha
, 0x205a,
1864 "GPSC command unsupported, disabling "
1866 ha
->flags
.gpsc_supported
= 0;
1867 rval
= QLA_FUNCTION_FAILED
;
1870 rval
= QLA_FUNCTION_FAILED
;
1872 /* Save port-speed */
1873 switch (be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)) {
1875 list
[i
].fp_speed
= PORT_SPEED_1GB
;
1878 list
[i
].fp_speed
= PORT_SPEED_2GB
;
1881 list
[i
].fp_speed
= PORT_SPEED_4GB
;
1884 list
[i
].fp_speed
= PORT_SPEED_10GB
;
1887 list
[i
].fp_speed
= PORT_SPEED_8GB
;
1890 list
[i
].fp_speed
= PORT_SPEED_16GB
;
1894 ql_dbg(ql_dbg_disc
, vha
, 0x205b,
1895 "GPSC ext entry - fpn "
1896 "%8phN speeds=%04x speed=%04x.\n",
1897 list
[i
].fabric_port_name
,
1898 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speeds
),
1899 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
));
1902 /* Last device exit. */
1903 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
1911 * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query.
1914 * @list: switch info entries to populate
1918 qla2x00_gff_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
1923 ms_iocb_entry_t
*ms_pkt
;
1924 struct ct_sns_req
*ct_req
;
1925 struct ct_sns_rsp
*ct_rsp
;
1926 struct qla_hw_data
*ha
= vha
->hw
;
1927 uint8_t fcp_scsi_features
= 0;
1929 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
1930 /* Set default FC4 Type as UNKNOWN so the default is to
1931 * Process this port */
1932 list
[i
].fc4_type
= FC4_TYPE_UNKNOWN
;
1934 /* Do not attempt GFF_ID if we are not FWI_2 capable */
1935 if (!IS_FWI2_CAPABLE(ha
))
1938 /* Prepare common MS IOCB */
1939 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GFF_ID_REQ_SIZE
,
1942 /* Prepare CT request */
1943 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GFF_ID_CMD
,
1945 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1947 /* Prepare CT arguments -- port_id */
1948 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
1949 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
1950 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
1952 /* Execute MS IOCB */
1953 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1954 sizeof(ms_iocb_entry_t
));
1956 if (rval
!= QLA_SUCCESS
) {
1957 ql_dbg(ql_dbg_disc
, vha
, 0x205c,
1958 "GFF_ID issue IOCB failed (%d).\n", rval
);
1959 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
1960 "GFF_ID") != QLA_SUCCESS
) {
1961 ql_dbg(ql_dbg_disc
, vha
, 0x205d,
1962 "GFF_ID IOCB status had a failure status code.\n");
1965 ct_rsp
->rsp
.gff_id
.fc4_features
[GFF_FCP_SCSI_OFFSET
];
1966 fcp_scsi_features
&= 0x0f;
1968 if (fcp_scsi_features
)
1969 list
[i
].fc4_type
= FC4_TYPE_FCP_SCSI
;
1971 list
[i
].fc4_type
= FC4_TYPE_OTHER
;
1974 /* Last device exit. */
1975 if (list
[i
].d_id
.b
.rsvd_1
!= 0)