2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2008 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 static int qla2x00_sns_ga_nxt(scsi_qla_host_t
*, fc_port_t
*);
10 static int qla2x00_sns_gid_pt(scsi_qla_host_t
*, sw_info_t
*);
11 static int qla2x00_sns_gpn_id(scsi_qla_host_t
*, sw_info_t
*);
12 static int qla2x00_sns_gnn_id(scsi_qla_host_t
*, sw_info_t
*);
13 static int qla2x00_sns_rft_id(scsi_qla_host_t
*);
14 static int qla2x00_sns_rnn_id(scsi_qla_host_t
*);
17 * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
19 * @req_size: request size in bytes
20 * @rsp_size: response size in bytes
22 * Returns a pointer to the @ha's ms_iocb.
25 qla2x00_prep_ms_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
, uint32_t rsp_size
)
27 struct qla_hw_data
*ha
= vha
->hw
;
28 ms_iocb_entry_t
*ms_pkt
;
31 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
33 ms_pkt
->entry_type
= MS_IOCB_TYPE
;
34 ms_pkt
->entry_count
= 1;
35 SET_TARGET_ID(ha
, ms_pkt
->loop_id
, SIMPLE_NAME_SERVER
);
36 ms_pkt
->control_flags
= __constant_cpu_to_le16(CF_READ
| CF_HEAD_TAG
);
37 ms_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
38 ms_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
39 ms_pkt
->total_dsd_count
= __constant_cpu_to_le16(2);
40 ms_pkt
->rsp_bytecount
= cpu_to_le32(rsp_size
);
41 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
43 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
44 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
45 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
47 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
48 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
49 ms_pkt
->dseg_rsp_length
= ms_pkt
->rsp_bytecount
;
55 * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
57 * @req_size: request size in bytes
58 * @rsp_size: response size in bytes
60 * Returns a pointer to the @ha's ms_iocb.
63 qla24xx_prep_ms_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
, uint32_t rsp_size
)
65 struct qla_hw_data
*ha
= vha
->hw
;
66 struct ct_entry_24xx
*ct_pkt
;
68 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
69 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
71 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
72 ct_pkt
->entry_count
= 1;
73 ct_pkt
->nport_handle
= __constant_cpu_to_le16(NPH_SNS
);
74 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
75 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
76 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
77 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
78 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
80 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
81 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
82 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
84 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
85 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
86 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
87 ct_pkt
->vp_index
= vha
->vp_idx
;
93 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
94 * @ct_req: CT request buffer
96 * @rsp_size: response size in bytes
98 * Returns a pointer to the intitialized @ct_req.
100 static inline struct ct_sns_req
*
101 qla2x00_prep_ct_req(struct ct_sns_req
*ct_req
, uint16_t cmd
, uint16_t rsp_size
)
103 memset(ct_req
, 0, sizeof(struct ct_sns_pkt
));
105 ct_req
->header
.revision
= 0x01;
106 ct_req
->header
.gs_type
= 0xFC;
107 ct_req
->header
.gs_subtype
= 0x02;
108 ct_req
->command
= cpu_to_be16(cmd
);
109 ct_req
->max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
115 qla2x00_chk_ms_status(scsi_qla_host_t
*vha
, ms_iocb_entry_t
*ms_pkt
,
116 struct ct_sns_rsp
*ct_rsp
, const char *routine
)
119 uint16_t comp_status
;
120 struct qla_hw_data
*ha
= vha
->hw
;
122 rval
= QLA_FUNCTION_FAILED
;
123 if (ms_pkt
->entry_status
!= 0) {
124 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n",
125 vha
->host_no
, routine
, ms_pkt
->entry_status
));
127 if (IS_FWI2_CAPABLE(ha
))
128 comp_status
= le16_to_cpu(
129 ((struct ct_entry_24xx
*)ms_pkt
)->comp_status
);
131 comp_status
= le16_to_cpu(ms_pkt
->status
);
132 switch (comp_status
) {
134 case CS_DATA_UNDERRUN
:
135 case CS_DATA_OVERRUN
: /* Overrun? */
136 if (ct_rsp
->header
.response
!=
137 __constant_cpu_to_be16(CT_ACCEPT_RESPONSE
)) {
138 DEBUG2_3(printk("scsi(%ld): %s failed, "
139 "rejected request:\n", vha
->host_no
,
141 DEBUG2_3(qla2x00_dump_buffer(
142 (uint8_t *)&ct_rsp
->header
,
143 sizeof(struct ct_rsp_hdr
)));
144 rval
= QLA_INVALID_COMMAND
;
149 DEBUG2_3(printk("scsi(%ld): %s failed, completion "
150 "status (%x).\n", vha
->host_no
, routine
,
159 * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
161 * @fcport: fcport entry to updated
163 * Returns 0 on success.
166 qla2x00_ga_nxt(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
170 ms_iocb_entry_t
*ms_pkt
;
171 struct ct_sns_req
*ct_req
;
172 struct ct_sns_rsp
*ct_rsp
;
173 struct qla_hw_data
*ha
= vha
->hw
;
175 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
176 return qla2x00_sns_ga_nxt(vha
, fcport
);
179 /* Prepare common MS IOCB */
180 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GA_NXT_REQ_SIZE
,
183 /* Prepare CT request */
184 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GA_NXT_CMD
,
186 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
188 /* Prepare CT arguments -- port_id */
189 ct_req
->req
.port_id
.port_id
[0] = fcport
->d_id
.b
.domain
;
190 ct_req
->req
.port_id
.port_id
[1] = fcport
->d_id
.b
.area
;
191 ct_req
->req
.port_id
.port_id
[2] = fcport
->d_id
.b
.al_pa
;
193 /* Execute MS IOCB */
194 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
195 sizeof(ms_iocb_entry_t
));
196 if (rval
!= QLA_SUCCESS
) {
198 DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
199 vha
->host_no
, rval
));
200 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "GA_NXT") !=
202 rval
= QLA_FUNCTION_FAILED
;
204 /* Populate fc_port_t entry. */
205 fcport
->d_id
.b
.domain
= ct_rsp
->rsp
.ga_nxt
.port_id
[0];
206 fcport
->d_id
.b
.area
= ct_rsp
->rsp
.ga_nxt
.port_id
[1];
207 fcport
->d_id
.b
.al_pa
= ct_rsp
->rsp
.ga_nxt
.port_id
[2];
209 memcpy(fcport
->node_name
, ct_rsp
->rsp
.ga_nxt
.node_name
,
211 memcpy(fcport
->port_name
, ct_rsp
->rsp
.ga_nxt
.port_name
,
214 if (ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_N_PORT_TYPE
&&
215 ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_NL_PORT_TYPE
)
216 fcport
->d_id
.b
.domain
= 0xf0;
218 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
219 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
220 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
221 "portid=%02x%02x%02x.\n",
223 fcport
->node_name
[0], fcport
->node_name
[1],
224 fcport
->node_name
[2], fcport
->node_name
[3],
225 fcport
->node_name
[4], fcport
->node_name
[5],
226 fcport
->node_name
[6], fcport
->node_name
[7],
227 fcport
->port_name
[0], fcport
->port_name
[1],
228 fcport
->port_name
[2], fcport
->port_name
[3],
229 fcport
->port_name
[4], fcport
->port_name
[5],
230 fcport
->port_name
[6], fcport
->port_name
[7],
231 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
232 fcport
->d_id
.b
.al_pa
));
239 * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
241 * @list: switch info entries to populate
243 * NOTE: Non-Nx_Ports are not requested.
245 * Returns 0 on success.
248 qla2x00_gid_pt(scsi_qla_host_t
*vha
, sw_info_t
*list
)
253 ms_iocb_entry_t
*ms_pkt
;
254 struct ct_sns_req
*ct_req
;
255 struct ct_sns_rsp
*ct_rsp
;
257 struct ct_sns_gid_pt_data
*gid_data
;
258 struct qla_hw_data
*ha
= vha
->hw
;
260 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
261 return qla2x00_sns_gid_pt(vha
, list
);
266 /* Prepare common MS IOCB */
267 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GID_PT_REQ_SIZE
,
270 /* Prepare CT request */
271 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GID_PT_CMD
,
273 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
275 /* Prepare CT arguments -- port_type */
276 ct_req
->req
.gid_pt
.port_type
= NS_NX_PORT_TYPE
;
278 /* Execute MS IOCB */
279 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
280 sizeof(ms_iocb_entry_t
));
281 if (rval
!= QLA_SUCCESS
) {
283 DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
284 vha
->host_no
, rval
));
285 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "GID_PT") !=
287 rval
= QLA_FUNCTION_FAILED
;
289 /* Set port IDs in switch info list. */
290 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
291 gid_data
= &ct_rsp
->rsp
.gid_pt
.entries
[i
];
292 list
[i
].d_id
.b
.domain
= gid_data
->port_id
[0];
293 list
[i
].d_id
.b
.area
= gid_data
->port_id
[1];
294 list
[i
].d_id
.b
.al_pa
= gid_data
->port_id
[2];
295 memset(list
[i
].fabric_port_name
, 0, WWN_SIZE
);
296 list
[i
].fp_speed
= PORT_SPEED_UNKNOWN
;
299 if (gid_data
->control_byte
& BIT_7
) {
300 list
[i
].d_id
.b
.rsvd_1
= gid_data
->control_byte
;
306 * If we've used all available slots, then the switch is
307 * reporting back more devices than we can handle with this
308 * single call. Return a failed status, and let GA_NXT handle
311 if (i
== MAX_FIBRE_DEVICES
)
312 rval
= QLA_FUNCTION_FAILED
;
319 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
321 * @list: switch info entries to populate
323 * Returns 0 on success.
326 qla2x00_gpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
331 ms_iocb_entry_t
*ms_pkt
;
332 struct ct_sns_req
*ct_req
;
333 struct ct_sns_rsp
*ct_rsp
;
334 struct qla_hw_data
*ha
= vha
->hw
;
336 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
337 return qla2x00_sns_gpn_id(vha
, list
);
339 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
341 /* Prepare common MS IOCB */
342 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GPN_ID_REQ_SIZE
,
345 /* Prepare CT request */
346 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GPN_ID_CMD
,
348 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
350 /* Prepare CT arguments -- port_id */
351 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
352 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
353 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
355 /* Execute MS IOCB */
356 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
357 sizeof(ms_iocb_entry_t
));
358 if (rval
!= QLA_SUCCESS
) {
360 DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
361 "(%d).\n", vha
->host_no
, rval
));
362 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
363 "GPN_ID") != QLA_SUCCESS
) {
364 rval
= QLA_FUNCTION_FAILED
;
367 memcpy(list
[i
].port_name
,
368 ct_rsp
->rsp
.gpn_id
.port_name
, WWN_SIZE
);
371 /* Last device exit. */
372 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
380 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
382 * @list: switch info entries to populate
384 * Returns 0 on success.
387 qla2x00_gnn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
391 struct qla_hw_data
*ha
= vha
->hw
;
392 ms_iocb_entry_t
*ms_pkt
;
393 struct ct_sns_req
*ct_req
;
394 struct ct_sns_rsp
*ct_rsp
;
396 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
397 return qla2x00_sns_gnn_id(vha
, list
);
399 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
401 /* Prepare common MS IOCB */
402 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GNN_ID_REQ_SIZE
,
405 /* Prepare CT request */
406 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GNN_ID_CMD
,
408 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
410 /* Prepare CT arguments -- port_id */
411 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
412 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
413 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
415 /* Execute MS IOCB */
416 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
417 sizeof(ms_iocb_entry_t
));
418 if (rval
!= QLA_SUCCESS
) {
420 DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
421 "(%d).\n", vha
->host_no
, rval
));
422 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
423 "GNN_ID") != QLA_SUCCESS
) {
424 rval
= QLA_FUNCTION_FAILED
;
427 memcpy(list
[i
].node_name
,
428 ct_rsp
->rsp
.gnn_id
.node_name
, WWN_SIZE
);
430 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
431 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
432 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
433 "portid=%02x%02x%02x.\n",
435 list
[i
].node_name
[0], list
[i
].node_name
[1],
436 list
[i
].node_name
[2], list
[i
].node_name
[3],
437 list
[i
].node_name
[4], list
[i
].node_name
[5],
438 list
[i
].node_name
[6], list
[i
].node_name
[7],
439 list
[i
].port_name
[0], list
[i
].port_name
[1],
440 list
[i
].port_name
[2], list
[i
].port_name
[3],
441 list
[i
].port_name
[4], list
[i
].port_name
[5],
442 list
[i
].port_name
[6], list
[i
].port_name
[7],
443 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
444 list
[i
].d_id
.b
.al_pa
));
447 /* Last device exit. */
448 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
456 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
459 * Returns 0 on success.
462 qla2x00_rft_id(scsi_qla_host_t
*vha
)
465 struct qla_hw_data
*ha
= vha
->hw
;
466 ms_iocb_entry_t
*ms_pkt
;
467 struct ct_sns_req
*ct_req
;
468 struct ct_sns_rsp
*ct_rsp
;
470 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
471 return qla2x00_sns_rft_id(vha
);
474 /* Prepare common MS IOCB */
475 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, RFT_ID_REQ_SIZE
,
478 /* Prepare CT request */
479 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RFT_ID_CMD
,
481 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
483 /* Prepare CT arguments -- port_id, FC-4 types */
484 ct_req
->req
.rft_id
.port_id
[0] = vha
->d_id
.b
.domain
;
485 ct_req
->req
.rft_id
.port_id
[1] = vha
->d_id
.b
.area
;
486 ct_req
->req
.rft_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
488 ct_req
->req
.rft_id
.fc4_types
[2] = 0x01; /* FCP-3 */
490 /* Execute MS IOCB */
491 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
492 sizeof(ms_iocb_entry_t
));
493 if (rval
!= QLA_SUCCESS
) {
495 DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
496 vha
->host_no
, rval
));
497 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RFT_ID") !=
499 rval
= QLA_FUNCTION_FAILED
;
501 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
509 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
512 * Returns 0 on success.
515 qla2x00_rff_id(scsi_qla_host_t
*vha
)
518 struct qla_hw_data
*ha
= vha
->hw
;
519 ms_iocb_entry_t
*ms_pkt
;
520 struct ct_sns_req
*ct_req
;
521 struct ct_sns_rsp
*ct_rsp
;
523 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
524 DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
525 "ISP2100/ISP2200.\n", vha
->host_no
));
526 return (QLA_SUCCESS
);
530 /* Prepare common MS IOCB */
531 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, RFF_ID_REQ_SIZE
,
534 /* Prepare CT request */
535 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RFF_ID_CMD
,
537 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
539 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
540 ct_req
->req
.rff_id
.port_id
[0] = vha
->d_id
.b
.domain
;
541 ct_req
->req
.rff_id
.port_id
[1] = vha
->d_id
.b
.area
;
542 ct_req
->req
.rff_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
544 ct_req
->req
.rff_id
.fc4_feature
= BIT_1
;
545 ct_req
->req
.rff_id
.fc4_type
= 0x08; /* SCSI - FCP */
547 /* Execute MS IOCB */
548 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
549 sizeof(ms_iocb_entry_t
));
550 if (rval
!= QLA_SUCCESS
) {
552 DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
553 vha
->host_no
, rval
));
554 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RFF_ID") !=
556 rval
= QLA_FUNCTION_FAILED
;
558 DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
566 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
569 * Returns 0 on success.
572 qla2x00_rnn_id(scsi_qla_host_t
*vha
)
575 struct qla_hw_data
*ha
= vha
->hw
;
576 ms_iocb_entry_t
*ms_pkt
;
577 struct ct_sns_req
*ct_req
;
578 struct ct_sns_rsp
*ct_rsp
;
580 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
581 return qla2x00_sns_rnn_id(vha
);
584 /* Prepare common MS IOCB */
585 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, RNN_ID_REQ_SIZE
,
588 /* Prepare CT request */
589 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RNN_ID_CMD
,
591 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
593 /* Prepare CT arguments -- port_id, node_name */
594 ct_req
->req
.rnn_id
.port_id
[0] = vha
->d_id
.b
.domain
;
595 ct_req
->req
.rnn_id
.port_id
[1] = vha
->d_id
.b
.area
;
596 ct_req
->req
.rnn_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
598 memcpy(ct_req
->req
.rnn_id
.node_name
, vha
->node_name
, WWN_SIZE
);
600 /* Execute MS IOCB */
601 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
602 sizeof(ms_iocb_entry_t
));
603 if (rval
!= QLA_SUCCESS
) {
605 DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
606 vha
->host_no
, rval
));
607 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RNN_ID") !=
609 rval
= QLA_FUNCTION_FAILED
;
611 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
619 qla2x00_get_sym_node_name(scsi_qla_host_t
*vha
, uint8_t *snn
)
621 struct qla_hw_data
*ha
= vha
->hw
;
622 sprintf(snn
, "%s FW:v%d.%02d.%02d DVR:v%s",ha
->model_number
,
623 ha
->fw_major_version
, ha
->fw_minor_version
,
624 ha
->fw_subminor_version
, qla2x00_version_str
);
628 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
631 * Returns 0 on success.
634 qla2x00_rsnn_nn(scsi_qla_host_t
*vha
)
637 struct qla_hw_data
*ha
= vha
->hw
;
638 ms_iocb_entry_t
*ms_pkt
;
639 struct ct_sns_req
*ct_req
;
640 struct ct_sns_rsp
*ct_rsp
;
642 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
643 DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
644 "ISP2100/ISP2200.\n", vha
->host_no
));
645 return (QLA_SUCCESS
);
649 /* Prepare common MS IOCB */
650 /* Request size adjusted after CT preparation */
651 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, 0, RSNN_NN_RSP_SIZE
);
653 /* Prepare CT request */
654 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, RSNN_NN_CMD
,
656 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
658 /* Prepare CT arguments -- node_name, symbolic node_name, size */
659 memcpy(ct_req
->req
.rsnn_nn
.node_name
, vha
->node_name
, WWN_SIZE
);
661 /* Prepare the Symbolic Node Name */
662 qla2x00_get_sym_node_name(vha
, ct_req
->req
.rsnn_nn
.sym_node_name
);
664 /* Calculate SNN length */
665 ct_req
->req
.rsnn_nn
.name_len
=
666 (uint8_t)strlen(ct_req
->req
.rsnn_nn
.sym_node_name
);
668 /* Update MS IOCB request */
669 ms_pkt
->req_bytecount
=
670 cpu_to_le32(24 + 1 + ct_req
->req
.rsnn_nn
.name_len
);
671 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
673 /* Execute MS IOCB */
674 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
675 sizeof(ms_iocb_entry_t
));
676 if (rval
!= QLA_SUCCESS
) {
678 DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
679 vha
->host_no
, rval
));
680 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RSNN_NN") !=
682 rval
= QLA_FUNCTION_FAILED
;
684 DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
692 * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
695 * @scmd_len: Subcommand length
696 * @data_size: response size in bytes
698 * Returns a pointer to the @ha's sns_cmd.
700 static inline struct sns_cmd_pkt
*
701 qla2x00_prep_sns_cmd(scsi_qla_host_t
*vha
, uint16_t cmd
, uint16_t scmd_len
,
705 struct sns_cmd_pkt
*sns_cmd
;
706 struct qla_hw_data
*ha
= vha
->hw
;
708 sns_cmd
= ha
->sns_cmd
;
709 memset(sns_cmd
, 0, sizeof(struct sns_cmd_pkt
));
710 wc
= data_size
/ 2; /* Size in 16bit words. */
711 sns_cmd
->p
.cmd
.buffer_length
= cpu_to_le16(wc
);
712 sns_cmd
->p
.cmd
.buffer_address
[0] = cpu_to_le32(LSD(ha
->sns_cmd_dma
));
713 sns_cmd
->p
.cmd
.buffer_address
[1] = cpu_to_le32(MSD(ha
->sns_cmd_dma
));
714 sns_cmd
->p
.cmd
.subcommand_length
= cpu_to_le16(scmd_len
);
715 sns_cmd
->p
.cmd
.subcommand
= cpu_to_le16(cmd
);
716 wc
= (data_size
- 16) / 4; /* Size in 32bit words. */
717 sns_cmd
->p
.cmd
.size
= cpu_to_le16(wc
);
723 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
725 * @fcport: fcport entry to updated
727 * This command uses the old Exectute SNS Command mailbox routine.
729 * Returns 0 on success.
732 qla2x00_sns_ga_nxt(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
735 struct qla_hw_data
*ha
= vha
->hw
;
736 struct sns_cmd_pkt
*sns_cmd
;
739 /* Prepare SNS command request. */
740 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GA_NXT_CMD
, GA_NXT_SNS_SCMD_LEN
,
741 GA_NXT_SNS_DATA_SIZE
);
743 /* Prepare SNS command arguments -- port_id. */
744 sns_cmd
->p
.cmd
.param
[0] = fcport
->d_id
.b
.al_pa
;
745 sns_cmd
->p
.cmd
.param
[1] = fcport
->d_id
.b
.area
;
746 sns_cmd
->p
.cmd
.param
[2] = fcport
->d_id
.b
.domain
;
748 /* Execute SNS command. */
749 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, GA_NXT_SNS_CMD_SIZE
/ 2,
750 sizeof(struct sns_cmd_pkt
));
751 if (rval
!= QLA_SUCCESS
) {
753 DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
754 vha
->host_no
, rval
));
755 } else if (sns_cmd
->p
.gan_data
[8] != 0x80 ||
756 sns_cmd
->p
.gan_data
[9] != 0x02) {
757 DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
758 "ga_nxt_rsp:\n", vha
->host_no
));
759 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gan_data
, 16));
760 rval
= QLA_FUNCTION_FAILED
;
762 /* Populate fc_port_t entry. */
763 fcport
->d_id
.b
.domain
= sns_cmd
->p
.gan_data
[17];
764 fcport
->d_id
.b
.area
= sns_cmd
->p
.gan_data
[18];
765 fcport
->d_id
.b
.al_pa
= sns_cmd
->p
.gan_data
[19];
767 memcpy(fcport
->node_name
, &sns_cmd
->p
.gan_data
[284], WWN_SIZE
);
768 memcpy(fcport
->port_name
, &sns_cmd
->p
.gan_data
[20], WWN_SIZE
);
770 if (sns_cmd
->p
.gan_data
[16] != NS_N_PORT_TYPE
&&
771 sns_cmd
->p
.gan_data
[16] != NS_NL_PORT_TYPE
)
772 fcport
->d_id
.b
.domain
= 0xf0;
774 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
775 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
776 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
777 "portid=%02x%02x%02x.\n",
779 fcport
->node_name
[0], fcport
->node_name
[1],
780 fcport
->node_name
[2], fcport
->node_name
[3],
781 fcport
->node_name
[4], fcport
->node_name
[5],
782 fcport
->node_name
[6], fcport
->node_name
[7],
783 fcport
->port_name
[0], fcport
->port_name
[1],
784 fcport
->port_name
[2], fcport
->port_name
[3],
785 fcport
->port_name
[4], fcport
->port_name
[5],
786 fcport
->port_name
[6], fcport
->port_name
[7],
787 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
788 fcport
->d_id
.b
.al_pa
));
795 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
797 * @list: switch info entries to populate
799 * This command uses the old Exectute SNS Command mailbox routine.
801 * NOTE: Non-Nx_Ports are not requested.
803 * Returns 0 on success.
806 qla2x00_sns_gid_pt(scsi_qla_host_t
*vha
, sw_info_t
*list
)
809 struct qla_hw_data
*ha
= vha
->hw
;
812 struct sns_cmd_pkt
*sns_cmd
;
815 /* Prepare SNS command request. */
816 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GID_PT_CMD
, GID_PT_SNS_SCMD_LEN
,
817 GID_PT_SNS_DATA_SIZE
);
819 /* Prepare SNS command arguments -- port_type. */
820 sns_cmd
->p
.cmd
.param
[0] = NS_NX_PORT_TYPE
;
822 /* Execute SNS command. */
823 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, GID_PT_SNS_CMD_SIZE
/ 2,
824 sizeof(struct sns_cmd_pkt
));
825 if (rval
!= QLA_SUCCESS
) {
827 DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
828 vha
->host_no
, rval
));
829 } else if (sns_cmd
->p
.gid_data
[8] != 0x80 ||
830 sns_cmd
->p
.gid_data
[9] != 0x02) {
831 DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
832 "gid_rsp:\n", vha
->host_no
));
833 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gid_data
, 16));
834 rval
= QLA_FUNCTION_FAILED
;
836 /* Set port IDs in switch info list. */
837 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
838 entry
= &sns_cmd
->p
.gid_data
[(i
* 4) + 16];
839 list
[i
].d_id
.b
.domain
= entry
[1];
840 list
[i
].d_id
.b
.area
= entry
[2];
841 list
[i
].d_id
.b
.al_pa
= entry
[3];
844 if (entry
[0] & BIT_7
) {
845 list
[i
].d_id
.b
.rsvd_1
= entry
[0];
851 * If we've used all available slots, then the switch is
852 * reporting back more devices that we can handle with this
853 * single call. Return a failed status, and let GA_NXT handle
856 if (i
== MAX_FIBRE_DEVICES
)
857 rval
= QLA_FUNCTION_FAILED
;
864 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
866 * @list: switch info entries to populate
868 * This command uses the old Exectute SNS Command mailbox routine.
870 * Returns 0 on success.
873 qla2x00_sns_gpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
876 struct qla_hw_data
*ha
= vha
->hw
;
878 struct sns_cmd_pkt
*sns_cmd
;
880 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
882 /* Prepare SNS command request. */
883 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GPN_ID_CMD
,
884 GPN_ID_SNS_SCMD_LEN
, GPN_ID_SNS_DATA_SIZE
);
886 /* Prepare SNS command arguments -- port_id. */
887 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
888 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
889 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
891 /* Execute SNS command. */
892 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
,
893 GPN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
894 if (rval
!= QLA_SUCCESS
) {
896 DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
897 "(%d).\n", vha
->host_no
, rval
));
898 } else if (sns_cmd
->p
.gpn_data
[8] != 0x80 ||
899 sns_cmd
->p
.gpn_data
[9] != 0x02) {
900 DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
901 "request, gpn_rsp:\n", vha
->host_no
));
902 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gpn_data
, 16));
903 rval
= QLA_FUNCTION_FAILED
;
906 memcpy(list
[i
].port_name
, &sns_cmd
->p
.gpn_data
[16],
910 /* Last device exit. */
911 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
919 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
921 * @list: switch info entries to populate
923 * This command uses the old Exectute SNS Command mailbox routine.
925 * Returns 0 on success.
928 qla2x00_sns_gnn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
931 struct qla_hw_data
*ha
= vha
->hw
;
933 struct sns_cmd_pkt
*sns_cmd
;
935 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
937 /* Prepare SNS command request. */
938 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GNN_ID_CMD
,
939 GNN_ID_SNS_SCMD_LEN
, GNN_ID_SNS_DATA_SIZE
);
941 /* Prepare SNS command arguments -- port_id. */
942 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
943 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
944 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
946 /* Execute SNS command. */
947 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
,
948 GNN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
949 if (rval
!= QLA_SUCCESS
) {
951 DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
952 "(%d).\n", vha
->host_no
, rval
));
953 } else if (sns_cmd
->p
.gnn_data
[8] != 0x80 ||
954 sns_cmd
->p
.gnn_data
[9] != 0x02) {
955 DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
956 "request, gnn_rsp:\n", vha
->host_no
));
957 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.gnn_data
, 16));
958 rval
= QLA_FUNCTION_FAILED
;
961 memcpy(list
[i
].node_name
, &sns_cmd
->p
.gnn_data
[16],
964 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
965 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
966 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
967 "portid=%02x%02x%02x.\n",
969 list
[i
].node_name
[0], list
[i
].node_name
[1],
970 list
[i
].node_name
[2], list
[i
].node_name
[3],
971 list
[i
].node_name
[4], list
[i
].node_name
[5],
972 list
[i
].node_name
[6], list
[i
].node_name
[7],
973 list
[i
].port_name
[0], list
[i
].port_name
[1],
974 list
[i
].port_name
[2], list
[i
].port_name
[3],
975 list
[i
].port_name
[4], list
[i
].port_name
[5],
976 list
[i
].port_name
[6], list
[i
].port_name
[7],
977 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
978 list
[i
].d_id
.b
.al_pa
));
981 /* Last device exit. */
982 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
990 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
993 * This command uses the old Exectute SNS Command mailbox routine.
995 * Returns 0 on success.
998 qla2x00_sns_rft_id(scsi_qla_host_t
*vha
)
1001 struct qla_hw_data
*ha
= vha
->hw
;
1002 struct sns_cmd_pkt
*sns_cmd
;
1005 /* Prepare SNS command request. */
1006 sns_cmd
= qla2x00_prep_sns_cmd(vha
, RFT_ID_CMD
, RFT_ID_SNS_SCMD_LEN
,
1007 RFT_ID_SNS_DATA_SIZE
);
1009 /* Prepare SNS command arguments -- port_id, FC-4 types */
1010 sns_cmd
->p
.cmd
.param
[0] = vha
->d_id
.b
.al_pa
;
1011 sns_cmd
->p
.cmd
.param
[1] = vha
->d_id
.b
.area
;
1012 sns_cmd
->p
.cmd
.param
[2] = vha
->d_id
.b
.domain
;
1014 sns_cmd
->p
.cmd
.param
[5] = 0x01; /* FCP-3 */
1016 /* Execute SNS command. */
1017 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, RFT_ID_SNS_CMD_SIZE
/ 2,
1018 sizeof(struct sns_cmd_pkt
));
1019 if (rval
!= QLA_SUCCESS
) {
1021 DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
1022 vha
->host_no
, rval
));
1023 } else if (sns_cmd
->p
.rft_data
[8] != 0x80 ||
1024 sns_cmd
->p
.rft_data
[9] != 0x02) {
1025 DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
1026 "rft_rsp:\n", vha
->host_no
));
1027 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.rft_data
, 16));
1028 rval
= QLA_FUNCTION_FAILED
;
1030 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
1038 * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
1042 * This command uses the old Exectute SNS Command mailbox routine.
1044 * Returns 0 on success.
1047 qla2x00_sns_rnn_id(scsi_qla_host_t
*vha
)
1050 struct qla_hw_data
*ha
= vha
->hw
;
1051 struct sns_cmd_pkt
*sns_cmd
;
1054 /* Prepare SNS command request. */
1055 sns_cmd
= qla2x00_prep_sns_cmd(vha
, RNN_ID_CMD
, RNN_ID_SNS_SCMD_LEN
,
1056 RNN_ID_SNS_DATA_SIZE
);
1058 /* Prepare SNS command arguments -- port_id, nodename. */
1059 sns_cmd
->p
.cmd
.param
[0] = vha
->d_id
.b
.al_pa
;
1060 sns_cmd
->p
.cmd
.param
[1] = vha
->d_id
.b
.area
;
1061 sns_cmd
->p
.cmd
.param
[2] = vha
->d_id
.b
.domain
;
1063 sns_cmd
->p
.cmd
.param
[4] = vha
->node_name
[7];
1064 sns_cmd
->p
.cmd
.param
[5] = vha
->node_name
[6];
1065 sns_cmd
->p
.cmd
.param
[6] = vha
->node_name
[5];
1066 sns_cmd
->p
.cmd
.param
[7] = vha
->node_name
[4];
1067 sns_cmd
->p
.cmd
.param
[8] = vha
->node_name
[3];
1068 sns_cmd
->p
.cmd
.param
[9] = vha
->node_name
[2];
1069 sns_cmd
->p
.cmd
.param
[10] = vha
->node_name
[1];
1070 sns_cmd
->p
.cmd
.param
[11] = vha
->node_name
[0];
1072 /* Execute SNS command. */
1073 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, RNN_ID_SNS_CMD_SIZE
/ 2,
1074 sizeof(struct sns_cmd_pkt
));
1075 if (rval
!= QLA_SUCCESS
) {
1077 DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
1078 vha
->host_no
, rval
));
1079 } else if (sns_cmd
->p
.rnn_data
[8] != 0x80 ||
1080 sns_cmd
->p
.rnn_data
[9] != 0x02) {
1081 DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
1082 "rnn_rsp:\n", vha
->host_no
));
1083 DEBUG2_3(qla2x00_dump_buffer(sns_cmd
->p
.rnn_data
, 16));
1084 rval
= QLA_FUNCTION_FAILED
;
1086 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
1094 * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
1097 * Returns 0 on success.
1100 qla2x00_mgmt_svr_login(scsi_qla_host_t
*vha
)
1103 uint16_t mb
[MAILBOX_REGISTER_COUNT
];
1104 struct qla_hw_data
*ha
= vha
->hw
;
1106 if (vha
->flags
.management_server_logged_in
)
1109 ha
->isp_ops
->fabric_login(vha
, vha
->mgmt_svr_loop_id
, 0xff, 0xff, 0xfa,
1111 if (mb
[0] != MBS_COMMAND_COMPLETE
) {
1112 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
1113 "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
1114 __func__
, vha
->host_no
, vha
->mgmt_svr_loop_id
, mb
[0], mb
[1],
1115 mb
[2], mb
[6], mb
[7]));
1116 ret
= QLA_FUNCTION_FAILED
;
1118 vha
->flags
.management_server_logged_in
= 1;
1124 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1126 * @req_size: request size in bytes
1127 * @rsp_size: response size in bytes
1129 * Returns a pointer to the @ha's ms_iocb.
1132 qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1135 ms_iocb_entry_t
*ms_pkt
;
1136 struct qla_hw_data
*ha
= vha
->hw
;
1137 ms_pkt
= ha
->ms_iocb
;
1138 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
1140 ms_pkt
->entry_type
= MS_IOCB_TYPE
;
1141 ms_pkt
->entry_count
= 1;
1142 SET_TARGET_ID(ha
, ms_pkt
->loop_id
, vha
->mgmt_svr_loop_id
);
1143 ms_pkt
->control_flags
= __constant_cpu_to_le16(CF_READ
| CF_HEAD_TAG
);
1144 ms_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1145 ms_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1146 ms_pkt
->total_dsd_count
= __constant_cpu_to_le16(2);
1147 ms_pkt
->rsp_bytecount
= cpu_to_le32(rsp_size
);
1148 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1150 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1151 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1152 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1154 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1155 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1156 ms_pkt
->dseg_rsp_length
= ms_pkt
->rsp_bytecount
;
1162 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1164 * @req_size: request size in bytes
1165 * @rsp_size: response size in bytes
1167 * Returns a pointer to the @ha's ms_iocb.
1170 qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1173 struct ct_entry_24xx
*ct_pkt
;
1174 struct qla_hw_data
*ha
= vha
->hw
;
1176 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1177 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1179 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1180 ct_pkt
->entry_count
= 1;
1181 ct_pkt
->nport_handle
= cpu_to_le16(vha
->mgmt_svr_loop_id
);
1182 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1183 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1184 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
1185 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1186 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1188 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1189 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1190 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1192 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1193 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1194 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1195 ct_pkt
->vp_index
= vha
->vp_idx
;
1200 static inline ms_iocb_entry_t
*
1201 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
)
1203 struct qla_hw_data
*ha
= vha
->hw
;
1204 ms_iocb_entry_t
*ms_pkt
= ha
->ms_iocb
;
1205 struct ct_entry_24xx
*ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1207 if (IS_FWI2_CAPABLE(ha
)) {
1208 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1209 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1211 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1212 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1219 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1220 * @ct_req: CT request buffer
1222 * @rsp_size: response size in bytes
1224 * Returns a pointer to the intitialized @ct_req.
1226 static inline struct ct_sns_req
*
1227 qla2x00_prep_ct_fdmi_req(struct ct_sns_req
*ct_req
, uint16_t cmd
,
1230 memset(ct_req
, 0, sizeof(struct ct_sns_pkt
));
1232 ct_req
->header
.revision
= 0x01;
1233 ct_req
->header
.gs_type
= 0xFA;
1234 ct_req
->header
.gs_subtype
= 0x10;
1235 ct_req
->command
= cpu_to_be16(cmd
);
1236 ct_req
->max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1242 * qla2x00_fdmi_rhba() -
1245 * Returns 0 on success.
1248 qla2x00_fdmi_rhba(scsi_qla_host_t
*vha
)
1253 ms_iocb_entry_t
*ms_pkt
;
1254 struct ct_sns_req
*ct_req
;
1255 struct ct_sns_rsp
*ct_rsp
;
1257 struct ct_fdmi_hba_attr
*eiter
;
1258 struct qla_hw_data
*ha
= vha
->hw
;
1261 /* Prepare common MS IOCB */
1262 /* Request size adjusted after CT preparation */
1263 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 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
, vha
->port_name
, WWN_SIZE
);
1272 ct_req
->req
.rhba
.entry_count
= __constant_cpu_to_be32(1);
1273 memcpy(ct_req
->req
.rhba
.port_name
, vha
->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
, vha
->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__
, vha
->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__
, vha
->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__
, vha
->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__
, vha
->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__
, vha
->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__
, vha
->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__
, vha
->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__
, vha
->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(vha
, 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__
, vha
->host_no
,
1390 eiter
->a
.fw_version
));
1392 /* Update MS request size. */
1393 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
1395 DEBUG13(printk("%s(%ld): RHBA identifier="
1396 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__
,
1397 vha
->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(vha
, 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 vha
->host_no
, rval
));
1414 } else if (qla2x00_chk_ms_status(vha
, 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__
, vha
->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
*vha
)
1442 struct qla_hw_data
*ha
= vha
->hw
;
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(vha
, 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
, vha
->port_name
, WWN_SIZE
);
1460 DEBUG13(printk("%s(%ld): DHBA portname="
1461 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__
, vha
->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(vha
, 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 vha
->host_no
, rval
));
1474 } else if (qla2x00_chk_ms_status(vha
, 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
*vha
)
1495 uint32_t size
, max_frame_size
;
1496 struct qla_hw_data
*ha
= vha
->hw
;
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(vha
, 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
, vha
->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__
,
1531 vha
->host_no
, eiter
->a
.fc4_types
[2],
1532 eiter
->a
.fc4_types
[1]));
1534 /* Supported speed. */
1535 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1536 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED
);
1537 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1539 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1540 FDMI_PORT_SPEED_10GB
);
1541 else if (IS_QLA25XX(ha
))
1542 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1543 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
|
1544 FDMI_PORT_SPEED_4GB
|FDMI_PORT_SPEED_8GB
);
1545 else if (IS_QLA24XX_TYPE(ha
))
1546 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1547 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
|
1548 FDMI_PORT_SPEED_4GB
);
1549 else if (IS_QLA23XX(ha
))
1550 eiter
->a
.sup_speed
=__constant_cpu_to_be32(
1551 FDMI_PORT_SPEED_1GB
|FDMI_PORT_SPEED_2GB
);
1553 eiter
->a
.sup_speed
= __constant_cpu_to_be32(
1554 FDMI_PORT_SPEED_1GB
);
1557 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__
, vha
->host_no
,
1558 eiter
->a
.sup_speed
));
1560 /* Current speed. */
1561 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1562 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED
);
1563 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1564 switch (ha
->link_data_rate
) {
1565 case PORT_SPEED_1GB
:
1566 eiter
->a
.cur_speed
=
1567 __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB
);
1569 case PORT_SPEED_2GB
:
1570 eiter
->a
.cur_speed
=
1571 __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB
);
1573 case PORT_SPEED_4GB
:
1574 eiter
->a
.cur_speed
=
1575 __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB
);
1577 case PORT_SPEED_8GB
:
1578 eiter
->a
.cur_speed
=
1579 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB
);
1581 case PORT_SPEED_10GB
:
1582 eiter
->a
.cur_speed
=
1583 __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB
);
1586 eiter
->a
.cur_speed
=
1587 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN
);
1592 DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__
, vha
->host_no
,
1593 eiter
->a
.cur_speed
));
1595 /* Max frame size. */
1596 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1597 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE
);
1598 eiter
->len
= __constant_cpu_to_be16(4 + 4);
1599 max_frame_size
= IS_FWI2_CAPABLE(ha
) ?
1600 le16_to_cpu(icb24
->frame_payload_size
):
1601 le16_to_cpu(ha
->init_cb
->frame_payload_size
);
1602 eiter
->a
.max_frame_size
= cpu_to_be32(max_frame_size
);
1605 DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__
, vha
->host_no
,
1606 eiter
->a
.max_frame_size
));
1608 /* OS device name. */
1609 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1610 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME
);
1611 strcpy(eiter
->a
.os_dev_name
, QLA2XXX_DRIVER_NAME
);
1612 alen
= strlen(eiter
->a
.os_dev_name
);
1613 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1614 eiter
->len
= cpu_to_be16(4 + alen
);
1617 DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__
, vha
->host_no
,
1618 eiter
->a
.os_dev_name
));
1621 if (strlen(fc_host_system_hostname(vha
->host
))) {
1622 ct_req
->req
.rpa
.attrs
.count
=
1623 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT
);
1624 eiter
= (struct ct_fdmi_port_attr
*) (entries
+ size
);
1625 eiter
->type
= __constant_cpu_to_be16(FDMI_PORT_HOST_NAME
);
1626 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
1627 "%s", fc_host_system_hostname(vha
->host
));
1628 alen
= strlen(eiter
->a
.host_name
);
1629 alen
+= (alen
& 3) ? (4 - (alen
& 3)) : 4;
1630 eiter
->len
= cpu_to_be16(4 + alen
);
1633 DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__
,
1634 vha
->host_no
, eiter
->a
.host_name
));
1637 /* Update MS request size. */
1638 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
1640 DEBUG13(printk("%s(%ld): RPA portname="
1641 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__
,
1642 vha
->host_no
, ct_req
->req
.rpa
.port_name
[0],
1643 ct_req
->req
.rpa
.port_name
[1], ct_req
->req
.rpa
.port_name
[2],
1644 ct_req
->req
.rpa
.port_name
[3], ct_req
->req
.rpa
.port_name
[4],
1645 ct_req
->req
.rpa
.port_name
[5], ct_req
->req
.rpa
.port_name
[6],
1646 ct_req
->req
.rpa
.port_name
[7], size
));
1647 DEBUG13(qla2x00_dump_buffer(entries
, size
));
1649 /* Execute MS IOCB */
1650 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1651 sizeof(ms_iocb_entry_t
));
1652 if (rval
!= QLA_SUCCESS
) {
1654 DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n",
1655 vha
->host_no
, rval
));
1656 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RPA") !=
1658 rval
= QLA_FUNCTION_FAILED
;
1660 DEBUG2(printk("scsi(%ld): RPA exiting normally.\n",
1668 * qla2x00_fdmi_register() -
1671 * Returns 0 on success.
1674 qla2x00_fdmi_register(scsi_qla_host_t
*vha
)
1677 struct qla_hw_data
*ha
= vha
->hw
;
1679 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
1680 return QLA_FUNCTION_FAILED
;
1682 rval
= qla2x00_mgmt_svr_login(vha
);
1686 rval
= qla2x00_fdmi_rhba(vha
);
1688 if (rval
!= QLA_ALREADY_REGISTERED
)
1691 rval
= qla2x00_fdmi_dhba(vha
);
1695 rval
= qla2x00_fdmi_rhba(vha
);
1699 rval
= qla2x00_fdmi_rpa(vha
);
1705 * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
1707 * @list: switch info entries to populate
1709 * Returns 0 on success.
1712 qla2x00_gfpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
1716 struct qla_hw_data
*ha
= vha
->hw
;
1717 ms_iocb_entry_t
*ms_pkt
;
1718 struct ct_sns_req
*ct_req
;
1719 struct ct_sns_rsp
*ct_rsp
;
1721 if (!IS_IIDMA_CAPABLE(ha
))
1722 return QLA_FUNCTION_FAILED
;
1724 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
1726 /* Prepare common MS IOCB */
1727 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, GFPN_ID_REQ_SIZE
,
1730 /* Prepare CT request */
1731 ct_req
= qla2x00_prep_ct_req(&ha
->ct_sns
->p
.req
, GFPN_ID_CMD
,
1733 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1735 /* Prepare CT arguments -- port_id */
1736 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
1737 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
1738 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
1740 /* Execute MS IOCB */
1741 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1742 sizeof(ms_iocb_entry_t
));
1743 if (rval
!= QLA_SUCCESS
) {
1745 DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB "
1746 "failed (%d).\n", vha
->host_no
, rval
));
1747 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
1748 "GFPN_ID") != QLA_SUCCESS
) {
1749 rval
= QLA_FUNCTION_FAILED
;
1751 /* Save fabric portname */
1752 memcpy(list
[i
].fabric_port_name
,
1753 ct_rsp
->rsp
.gfpn_id
.port_name
, WWN_SIZE
);
1756 /* Last device exit. */
1757 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
1764 static inline void *
1765 qla24xx_prep_ms_fm_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1768 struct ct_entry_24xx
*ct_pkt
;
1769 struct qla_hw_data
*ha
= vha
->hw
;
1770 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1771 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1773 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1774 ct_pkt
->entry_count
= 1;
1775 ct_pkt
->nport_handle
= cpu_to_le16(vha
->mgmt_svr_loop_id
);
1776 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1777 ct_pkt
->cmd_dsd_count
= __constant_cpu_to_le16(1);
1778 ct_pkt
->rsp_dsd_count
= __constant_cpu_to_le16(1);
1779 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1780 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1782 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1783 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1784 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1786 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1787 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1788 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1789 ct_pkt
->vp_index
= vha
->vp_idx
;
1795 static inline struct ct_sns_req
*
1796 qla24xx_prep_ct_fm_req(struct ct_sns_req
*ct_req
, uint16_t cmd
,
1799 memset(ct_req
, 0, sizeof(struct ct_sns_pkt
));
1801 ct_req
->header
.revision
= 0x01;
1802 ct_req
->header
.gs_type
= 0xFA;
1803 ct_req
->header
.gs_subtype
= 0x01;
1804 ct_req
->command
= cpu_to_be16(cmd
);
1805 ct_req
->max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1811 * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
1813 * @list: switch info entries to populate
1815 * Returns 0 on success.
1818 qla2x00_gpsc(scsi_qla_host_t
*vha
, sw_info_t
*list
)
1822 struct qla_hw_data
*ha
= vha
->hw
;
1823 ms_iocb_entry_t
*ms_pkt
;
1824 struct ct_sns_req
*ct_req
;
1825 struct ct_sns_rsp
*ct_rsp
;
1827 if (!IS_IIDMA_CAPABLE(ha
))
1828 return QLA_FUNCTION_FAILED
;
1829 if (!ha
->flags
.gpsc_supported
)
1830 return QLA_FUNCTION_FAILED
;
1832 rval
= qla2x00_mgmt_svr_login(vha
);
1836 for (i
= 0; i
< MAX_FIBRE_DEVICES
; i
++) {
1838 /* Prepare common MS IOCB */
1839 ms_pkt
= qla24xx_prep_ms_fm_iocb(vha
, GPSC_REQ_SIZE
,
1842 /* Prepare CT request */
1843 ct_req
= qla24xx_prep_ct_fm_req(&ha
->ct_sns
->p
.req
,
1844 GPSC_CMD
, GPSC_RSP_SIZE
);
1845 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1847 /* Prepare CT arguments -- port_name */
1848 memcpy(ct_req
->req
.gpsc
.port_name
, list
[i
].fabric_port_name
,
1851 /* Execute MS IOCB */
1852 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1853 sizeof(ms_iocb_entry_t
));
1854 if (rval
!= QLA_SUCCESS
) {
1856 DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB "
1857 "failed (%d).\n", vha
->host_no
, rval
));
1858 } else if ((rval
= qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
1859 "GPSC")) != QLA_SUCCESS
) {
1860 /* FM command unsupported? */
1861 if (rval
== QLA_INVALID_COMMAND
&&
1862 (ct_rsp
->header
.reason_code
==
1863 CT_REASON_INVALID_COMMAND_CODE
||
1864 ct_rsp
->header
.reason_code
==
1865 CT_REASON_COMMAND_UNSUPPORTED
)) {
1866 DEBUG2(printk("scsi(%ld): GPSC command "
1867 "unsupported, disabling query...\n",
1869 ha
->flags
.gpsc_supported
= 0;
1870 rval
= QLA_FUNCTION_FAILED
;
1873 rval
= QLA_FUNCTION_FAILED
;
1875 /* Save port-speed */
1876 switch (be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)) {
1878 list
[i
].fp_speed
= PORT_SPEED_1GB
;
1881 list
[i
].fp_speed
= PORT_SPEED_2GB
;
1884 list
[i
].fp_speed
= PORT_SPEED_4GB
;
1887 list
[i
].fp_speed
= PORT_SPEED_10GB
;
1890 list
[i
].fp_speed
= PORT_SPEED_8GB
;
1894 DEBUG2_3(printk("scsi(%ld): GPSC ext entry - "
1895 "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x "
1896 "speed=%04x.\n", vha
->host_no
,
1897 list
[i
].fabric_port_name
[0],
1898 list
[i
].fabric_port_name
[1],
1899 list
[i
].fabric_port_name
[2],
1900 list
[i
].fabric_port_name
[3],
1901 list
[i
].fabric_port_name
[4],
1902 list
[i
].fabric_port_name
[5],
1903 list
[i
].fabric_port_name
[6],
1904 list
[i
].fabric_port_name
[7],
1905 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speeds
),
1906 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)));
1909 /* Last device exit. */
1910 if (list
[i
].d_id
.b
.rsvd_1
!= 0)