2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 static inline struct ct_sns_req *
10 qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t);
12 static inline struct sns_cmd_pkt *
13 qla2x00_prep_sns_cmd(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t);
15 static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *);
16 static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *);
17 static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *);
18 static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *);
19 static int qla2x00_sns_rft_id(scsi_qla_host_t *);
20 static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
23 * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
25 * @req_size: request size in bytes
26 * @rsp_size: response size in bytes
28 * Returns a pointer to the @ha's ms_iocb.
31 qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
33 ms_iocb_entry_t *ms_pkt;
36 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
38 ms_pkt->entry_type = MS_IOCB_TYPE;
39 ms_pkt->entry_count = 1;
40 SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER);
41 ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
42 ms_pkt->timeout = __constant_cpu_to_le16(25);
43 ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
44 ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
45 ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
46 ms_pkt->req_bytecount = cpu_to_le32(req_size);
48 ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
49 ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
50 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
52 ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
53 ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
54 ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
60 * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
62 * @req_size: request size in bytes
63 * @rsp_size: response size in bytes
65 * Returns a pointer to the @ha's ms_iocb.
68 qla24xx_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
70 struct ct_entry_24xx *ct_pkt;
72 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
73 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
75 ct_pkt->entry_type = CT_IOCB_TYPE;
76 ct_pkt->entry_count = 1;
77 ct_pkt->nport_handle = __constant_cpu_to_le16(NPH_SNS);
78 ct_pkt->timeout = __constant_cpu_to_le16(25);
79 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
80 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
81 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
82 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
84 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
85 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
86 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
88 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
89 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
90 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
96 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
97 * @ct_req: CT request buffer
99 * @rsp_size: response size in bytes
101 * Returns a pointer to the intitialized @ct_req.
103 static inline struct ct_sns_req *
104 qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
106 memset(ct_req, 0, sizeof(struct ct_sns_pkt));
108 ct_req->header.revision = 0x01;
109 ct_req->header.gs_type = 0xFC;
110 ct_req->header.gs_subtype = 0x02;
111 ct_req->command = cpu_to_be16(cmd);
112 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
118 qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt,
119 struct ct_sns_rsp *ct_rsp, const char *routine)
122 uint16_t comp_status;
124 rval = QLA_FUNCTION_FAILED;
125 if (ms_pkt->entry_status != 0) {
126 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n",
127 ha->host_no, routine, ms_pkt->entry_status));
129 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
131 ((struct ct_entry_24xx *)ms_pkt)->comp_status;
133 comp_status = le16_to_cpu(ms_pkt->status);
134 switch (comp_status) {
136 case CS_DATA_UNDERRUN:
137 case CS_DATA_OVERRUN: /* Overrun? */
138 if (ct_rsp->header.response !=
139 __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
140 DEBUG2_3(printk("scsi(%ld): %s failed, "
141 "rejected request:\n", ha->host_no,
143 DEBUG2_3(qla2x00_dump_buffer(
144 (uint8_t *)&ct_rsp->header,
145 sizeof(struct ct_rsp_hdr)));
150 DEBUG2_3(printk("scsi(%ld): %s failed, completion "
151 "status (%x).\n", ha->host_no, routine,
160 * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
162 * @fcport: fcport entry to updated
164 * Returns 0 on success.
167 qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
171 ms_iocb_entry_t *ms_pkt;
172 struct ct_sns_req *ct_req;
173 struct ct_sns_rsp *ct_rsp;
175 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
176 return (qla2x00_sns_ga_nxt(ha, fcport));
180 /* Prepare common MS IOCB */
181 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_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(ha, 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",
200 } else if (qla2x00_chk_ms_status(ha, 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 *ha, 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;
259 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
260 return (qla2x00_sns_gid_pt(ha, list));
266 /* Prepare common MS IOCB */
267 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE);
269 /* Prepare CT request */
270 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
272 ct_rsp = &ha->ct_sns->p.rsp;
274 /* Prepare CT arguments -- port_type */
275 ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
277 /* Execute MS IOCB */
278 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
279 sizeof(ms_iocb_entry_t));
280 if (rval != QLA_SUCCESS) {
282 DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
284 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GID_PT") !=
286 rval = QLA_FUNCTION_FAILED;
288 /* Set port IDs in switch info list. */
289 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
290 gid_data = &ct_rsp->rsp.gid_pt.entries[i];
291 list[i].d_id.b.domain = gid_data->port_id[0];
292 list[i].d_id.b.area = gid_data->port_id[1];
293 list[i].d_id.b.al_pa = gid_data->port_id[2];
296 if (gid_data->control_byte & BIT_7) {
297 list[i].d_id.b.rsvd_1 = gid_data->control_byte;
303 * If we've used all available slots, then the switch is
304 * reporting back more devices than we can handle with this
305 * single call. Return a failed status, and let GA_NXT handle
308 if (i == MAX_FIBRE_DEVICES)
309 rval = QLA_FUNCTION_FAILED;
316 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
318 * @list: switch info entries to populate
320 * Returns 0 on success.
323 qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
328 ms_iocb_entry_t *ms_pkt;
329 struct ct_sns_req *ct_req;
330 struct ct_sns_rsp *ct_rsp;
332 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
333 return (qla2x00_sns_gpn_id(ha, list));
336 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
338 /* Prepare common MS IOCB */
339 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GPN_ID_REQ_SIZE,
342 /* Prepare CT request */
343 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD,
345 ct_rsp = &ha->ct_sns->p.rsp;
347 /* Prepare CT arguments -- port_id */
348 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
349 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
350 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
352 /* Execute MS IOCB */
353 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
354 sizeof(ms_iocb_entry_t));
355 if (rval != QLA_SUCCESS) {
357 DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
358 "(%d).\n", ha->host_no, rval));
359 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp,
360 "GPN_ID") != QLA_SUCCESS) {
361 rval = QLA_FUNCTION_FAILED;
364 memcpy(list[i].port_name,
365 ct_rsp->rsp.gpn_id.port_name, WWN_SIZE);
368 /* Last device exit. */
369 if (list[i].d_id.b.rsvd_1 != 0)
377 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
379 * @list: switch info entries to populate
381 * Returns 0 on success.
384 qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
389 ms_iocb_entry_t *ms_pkt;
390 struct ct_sns_req *ct_req;
391 struct ct_sns_rsp *ct_rsp;
393 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
394 return (qla2x00_sns_gnn_id(ha, list));
397 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
399 /* Prepare common MS IOCB */
400 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GNN_ID_REQ_SIZE,
403 /* Prepare CT request */
404 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD,
406 ct_rsp = &ha->ct_sns->p.rsp;
408 /* Prepare CT arguments -- port_id */
409 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
410 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
411 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
413 /* Execute MS IOCB */
414 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
415 sizeof(ms_iocb_entry_t));
416 if (rval != QLA_SUCCESS) {
418 DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
419 "(%d).\n", ha->host_no, rval));
420 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp,
421 "GNN_ID") != QLA_SUCCESS) {
422 rval = QLA_FUNCTION_FAILED;
425 memcpy(list[i].node_name,
426 ct_rsp->rsp.gnn_id.node_name, WWN_SIZE);
428 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
429 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
430 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
431 "portid=%02x%02x%02x.\n",
433 list[i].node_name[0], list[i].node_name[1],
434 list[i].node_name[2], list[i].node_name[3],
435 list[i].node_name[4], list[i].node_name[5],
436 list[i].node_name[6], list[i].node_name[7],
437 list[i].port_name[0], list[i].port_name[1],
438 list[i].port_name[2], list[i].port_name[3],
439 list[i].port_name[4], list[i].port_name[5],
440 list[i].port_name[6], list[i].port_name[7],
441 list[i].d_id.b.domain, list[i].d_id.b.area,
442 list[i].d_id.b.al_pa));
445 /* Last device exit. */
446 if (list[i].d_id.b.rsvd_1 != 0)
454 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
457 * Returns 0 on success.
460 qla2x00_rft_id(scsi_qla_host_t *ha)
464 ms_iocb_entry_t *ms_pkt;
465 struct ct_sns_req *ct_req;
466 struct ct_sns_rsp *ct_rsp;
468 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
469 return (qla2x00_sns_rft_id(ha));
473 /* Prepare common MS IOCB */
474 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE);
476 /* Prepare CT request */
477 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
479 ct_rsp = &ha->ct_sns->p.rsp;
481 /* Prepare CT arguments -- port_id, FC-4 types */
482 ct_req->req.rft_id.port_id[0] = ha->d_id.b.domain;
483 ct_req->req.rft_id.port_id[1] = ha->d_id.b.area;
484 ct_req->req.rft_id.port_id[2] = ha->d_id.b.al_pa;
486 ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
488 /* Execute MS IOCB */
489 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
490 sizeof(ms_iocb_entry_t));
491 if (rval != QLA_SUCCESS) {
493 DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
495 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFT_ID") !=
497 rval = QLA_FUNCTION_FAILED;
499 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
507 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
510 * Returns 0 on success.
513 qla2x00_rff_id(scsi_qla_host_t *ha)
517 ms_iocb_entry_t *ms_pkt;
518 struct ct_sns_req *ct_req;
519 struct ct_sns_rsp *ct_rsp;
521 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
522 DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
523 "ISP2100/ISP2200.\n", ha->host_no));
524 return (QLA_SUCCESS);
528 /* Prepare common MS IOCB */
529 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE);
531 /* Prepare CT request */
532 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
534 ct_rsp = &ha->ct_sns->p.rsp;
536 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
537 ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain;
538 ct_req->req.rff_id.port_id[1] = ha->d_id.b.area;
539 ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa;
541 ct_req->req.rff_id.fc4_feature = BIT_1;
542 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
544 /* Execute MS IOCB */
545 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
546 sizeof(ms_iocb_entry_t));
547 if (rval != QLA_SUCCESS) {
549 DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
551 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFF_ID") !=
553 rval = QLA_FUNCTION_FAILED;
555 DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
563 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
566 * Returns 0 on success.
569 qla2x00_rnn_id(scsi_qla_host_t *ha)
573 ms_iocb_entry_t *ms_pkt;
574 struct ct_sns_req *ct_req;
575 struct ct_sns_rsp *ct_rsp;
577 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
578 return (qla2x00_sns_rnn_id(ha));
582 /* Prepare common MS IOCB */
583 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE);
585 /* Prepare CT request */
586 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
588 ct_rsp = &ha->ct_sns->p.rsp;
590 /* Prepare CT arguments -- port_id, node_name */
591 ct_req->req.rnn_id.port_id[0] = ha->d_id.b.domain;
592 ct_req->req.rnn_id.port_id[1] = ha->d_id.b.area;
593 ct_req->req.rnn_id.port_id[2] = ha->d_id.b.al_pa;
595 memcpy(ct_req->req.rnn_id.node_name, ha->node_name, WWN_SIZE);
597 /* Execute MS IOCB */
598 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
599 sizeof(ms_iocb_entry_t));
600 if (rval != QLA_SUCCESS) {
602 DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
604 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RNN_ID") !=
606 rval = QLA_FUNCTION_FAILED;
608 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
616 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
619 * Returns 0 on success.
622 qla2x00_rsnn_nn(scsi_qla_host_t *ha)
628 ms_iocb_entry_t *ms_pkt;
629 struct ct_sns_req *ct_req;
630 struct ct_sns_rsp *ct_rsp;
632 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
633 DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
634 "ISP2100/ISP2200.\n", ha->host_no));
635 return (QLA_SUCCESS);
639 /* Prepare common MS IOCB */
640 /* Request size adjusted after CT preparation */
641 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE);
643 /* Prepare CT request */
644 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
646 ct_rsp = &ha->ct_sns->p.rsp;
648 /* Prepare CT arguments -- node_name, symbolic node_name, size */
649 memcpy(ct_req->req.rsnn_nn.node_name, ha->node_name, WWN_SIZE);
651 /* Prepare the Symbolic Node Name */
653 snn = ct_req->req.rsnn_nn.sym_node_name;
654 strcpy(snn, ha->model_number);
655 /* Firmware version */
656 strcat(snn, " FW:v");
657 sprintf(version, "%d.%02d.%02d", ha->fw_major_version,
658 ha->fw_minor_version, ha->fw_subminor_version);
659 strcat(snn, version);
661 strcat(snn, " DVR:v");
662 strcat(snn, qla2x00_version_str);
664 /* Calculate SNN length */
665 ct_req->req.rsnn_nn.name_len = (uint8_t)strlen(snn);
667 /* Update MS IOCB request */
668 ms_pkt->req_bytecount =
669 cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len);
670 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
672 /* Execute MS IOCB */
673 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
674 sizeof(ms_iocb_entry_t));
675 if (rval != QLA_SUCCESS) {
677 DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
679 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RSNN_NN") !=
681 rval = QLA_FUNCTION_FAILED;
683 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 *ha, uint16_t cmd, uint16_t scmd_len,
705 struct sns_cmd_pkt *sns_cmd;
707 sns_cmd = ha->sns_cmd;
708 memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
709 wc = data_size / 2; /* Size in 16bit words. */
710 sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc);
711 sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma));
712 sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma));
713 sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len);
714 sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd);
715 wc = (data_size - 16) / 4; /* Size in 32bit words. */
716 sns_cmd->p.cmd.size = cpu_to_le16(wc);
722 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
724 * @fcport: fcport entry to updated
726 * This command uses the old Exectute SNS Command mailbox routine.
728 * Returns 0 on success.
731 qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
735 struct sns_cmd_pkt *sns_cmd;
738 /* Prepare SNS command request. */
739 sns_cmd = qla2x00_prep_sns_cmd(ha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
740 GA_NXT_SNS_DATA_SIZE);
742 /* Prepare SNS command arguments -- port_id. */
743 sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa;
744 sns_cmd->p.cmd.param[1] = fcport->d_id.b.area;
745 sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
747 /* Execute SNS command. */
748 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
749 sizeof(struct sns_cmd_pkt));
750 if (rval != QLA_SUCCESS) {
752 DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
754 } else if (sns_cmd->p.gan_data[8] != 0x80 ||
755 sns_cmd->p.gan_data[9] != 0x02) {
756 DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
757 "ga_nxt_rsp:\n", ha->host_no));
758 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16));
759 rval = QLA_FUNCTION_FAILED;
761 /* Populate fc_port_t entry. */
762 fcport->d_id.b.domain = sns_cmd->p.gan_data[17];
763 fcport->d_id.b.area = sns_cmd->p.gan_data[18];
764 fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19];
766 memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE);
767 memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE);
769 if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE &&
770 sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE)
771 fcport->d_id.b.domain = 0xf0;
773 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
774 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
775 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
776 "portid=%02x%02x%02x.\n",
778 fcport->node_name[0], fcport->node_name[1],
779 fcport->node_name[2], fcport->node_name[3],
780 fcport->node_name[4], fcport->node_name[5],
781 fcport->node_name[6], fcport->node_name[7],
782 fcport->port_name[0], fcport->port_name[1],
783 fcport->port_name[2], fcport->port_name[3],
784 fcport->port_name[4], fcport->port_name[5],
785 fcport->port_name[6], fcport->port_name[7],
786 fcport->d_id.b.domain, fcport->d_id.b.area,
787 fcport->d_id.b.al_pa));
794 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
796 * @list: switch info entries to populate
798 * This command uses the old Exectute SNS Command mailbox routine.
800 * NOTE: Non-Nx_Ports are not requested.
802 * Returns 0 on success.
805 qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
811 struct sns_cmd_pkt *sns_cmd;
814 /* Prepare SNS command request. */
815 sns_cmd = qla2x00_prep_sns_cmd(ha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
816 GID_PT_SNS_DATA_SIZE);
818 /* Prepare SNS command arguments -- port_type. */
819 sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
821 /* Execute SNS command. */
822 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
823 sizeof(struct sns_cmd_pkt));
824 if (rval != QLA_SUCCESS) {
826 DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
828 } else if (sns_cmd->p.gid_data[8] != 0x80 ||
829 sns_cmd->p.gid_data[9] != 0x02) {
830 DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
831 "gid_rsp:\n", ha->host_no));
832 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16));
833 rval = QLA_FUNCTION_FAILED;
835 /* Set port IDs in switch info list. */
836 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
837 entry = &sns_cmd->p.gid_data[(i * 4) + 16];
838 list[i].d_id.b.domain = entry[1];
839 list[i].d_id.b.area = entry[2];
840 list[i].d_id.b.al_pa = entry[3];
843 if (entry[0] & BIT_7) {
844 list[i].d_id.b.rsvd_1 = entry[0];
850 * If we've used all available slots, then the switch is
851 * reporting back more devices that we can handle with this
852 * single call. Return a failed status, and let GA_NXT handle
855 if (i == MAX_FIBRE_DEVICES)
856 rval = QLA_FUNCTION_FAILED;
863 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
865 * @list: switch info entries to populate
867 * This command uses the old Exectute SNS Command mailbox routine.
869 * Returns 0 on success.
872 qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
877 struct sns_cmd_pkt *sns_cmd;
879 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
881 /* Prepare SNS command request. */
882 sns_cmd = qla2x00_prep_sns_cmd(ha, GPN_ID_CMD,
883 GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
885 /* Prepare SNS command arguments -- port_id. */
886 sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
887 sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
888 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
890 /* Execute SNS command. */
891 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma,
892 GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
893 if (rval != QLA_SUCCESS) {
895 DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
896 "(%d).\n", ha->host_no, rval));
897 } else if (sns_cmd->p.gpn_data[8] != 0x80 ||
898 sns_cmd->p.gpn_data[9] != 0x02) {
899 DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
900 "request, gpn_rsp:\n", ha->host_no));
901 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16));
902 rval = QLA_FUNCTION_FAILED;
905 memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16],
909 /* Last device exit. */
910 if (list[i].d_id.b.rsvd_1 != 0)
918 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
920 * @list: switch info entries to populate
922 * This command uses the old Exectute SNS Command mailbox routine.
924 * Returns 0 on success.
927 qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
932 struct sns_cmd_pkt *sns_cmd;
934 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
936 /* Prepare SNS command request. */
937 sns_cmd = qla2x00_prep_sns_cmd(ha, GNN_ID_CMD,
938 GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
940 /* Prepare SNS command arguments -- port_id. */
941 sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
942 sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
943 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
945 /* Execute SNS command. */
946 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma,
947 GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
948 if (rval != QLA_SUCCESS) {
950 DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
951 "(%d).\n", ha->host_no, rval));
952 } else if (sns_cmd->p.gnn_data[8] != 0x80 ||
953 sns_cmd->p.gnn_data[9] != 0x02) {
954 DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
955 "request, gnn_rsp:\n", ha->host_no));
956 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16));
957 rval = QLA_FUNCTION_FAILED;
960 memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16],
963 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
964 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
965 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
966 "portid=%02x%02x%02x.\n",
968 list[i].node_name[0], list[i].node_name[1],
969 list[i].node_name[2], list[i].node_name[3],
970 list[i].node_name[4], list[i].node_name[5],
971 list[i].node_name[6], list[i].node_name[7],
972 list[i].port_name[0], list[i].port_name[1],
973 list[i].port_name[2], list[i].port_name[3],
974 list[i].port_name[4], list[i].port_name[5],
975 list[i].port_name[6], list[i].port_name[7],
976 list[i].d_id.b.domain, list[i].d_id.b.area,
977 list[i].d_id.b.al_pa));
980 /* Last device exit. */
981 if (list[i].d_id.b.rsvd_1 != 0)
989 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
992 * This command uses the old Exectute SNS Command mailbox routine.
994 * Returns 0 on success.
997 qla2x00_sns_rft_id(scsi_qla_host_t *ha)
1001 struct sns_cmd_pkt *sns_cmd;
1004 /* Prepare SNS command request. */
1005 sns_cmd = qla2x00_prep_sns_cmd(ha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
1006 RFT_ID_SNS_DATA_SIZE);
1008 /* Prepare SNS command arguments -- port_id, FC-4 types */
1009 sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
1010 sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
1011 sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
1013 sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */
1015 /* Execute SNS command. */
1016 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
1017 sizeof(struct sns_cmd_pkt));
1018 if (rval != QLA_SUCCESS) {
1020 DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
1021 ha->host_no, rval));
1022 } else if (sns_cmd->p.rft_data[8] != 0x80 ||
1023 sns_cmd->p.rft_data[9] != 0x02) {
1024 DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
1025 "rft_rsp:\n", ha->host_no));
1026 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16));
1027 rval = QLA_FUNCTION_FAILED;
1029 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
1037 * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
1041 * This command uses the old Exectute SNS Command mailbox routine.
1043 * Returns 0 on success.
1046 qla2x00_sns_rnn_id(scsi_qla_host_t *ha)
1050 struct sns_cmd_pkt *sns_cmd;
1053 /* Prepare SNS command request. */
1054 sns_cmd = qla2x00_prep_sns_cmd(ha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
1055 RNN_ID_SNS_DATA_SIZE);
1057 /* Prepare SNS command arguments -- port_id, nodename. */
1058 sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
1059 sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
1060 sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
1062 sns_cmd->p.cmd.param[4] = ha->node_name[7];
1063 sns_cmd->p.cmd.param[5] = ha->node_name[6];
1064 sns_cmd->p.cmd.param[6] = ha->node_name[5];
1065 sns_cmd->p.cmd.param[7] = ha->node_name[4];
1066 sns_cmd->p.cmd.param[8] = ha->node_name[3];
1067 sns_cmd->p.cmd.param[9] = ha->node_name[2];
1068 sns_cmd->p.cmd.param[10] = ha->node_name[1];
1069 sns_cmd->p.cmd.param[11] = ha->node_name[0];
1071 /* Execute SNS command. */
1072 rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
1073 sizeof(struct sns_cmd_pkt));
1074 if (rval != QLA_SUCCESS) {
1076 DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
1077 ha->host_no, rval));
1078 } else if (sns_cmd->p.rnn_data[8] != 0x80 ||
1079 sns_cmd->p.rnn_data[9] != 0x02) {
1080 DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
1081 "rnn_rsp:\n", ha->host_no));
1082 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16));
1083 rval = QLA_FUNCTION_FAILED;
1085 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
1093 * qla2x00_mgmt_svr_login() - Login to fabric Managment Service.
1096 * Returns 0 on success.
1099 qla2x00_mgmt_svr_login(scsi_qla_host_t *ha)
1102 uint16_t mb[MAILBOX_REGISTER_COUNT];
1105 if (ha->flags.management_server_logged_in)
1108 ha->isp_ops.fabric_login(ha, ha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa,
1110 if (mb[0] != MBS_COMMAND_COMPLETE) {
1111 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
1112 "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
1113 __func__, ha->host_no, ha->mgmt_svr_loop_id, mb[0], mb[1],
1114 mb[2], mb[6], mb[7]));
1115 ret = QLA_FUNCTION_FAILED;
1117 ha->flags.management_server_logged_in = 1;
1123 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1125 * @req_size: request size in bytes
1126 * @rsp_size: response size in bytes
1128 * Returns a pointer to the @ha's ms_iocb.
1131 qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size,
1134 ms_iocb_entry_t *ms_pkt;
1136 ms_pkt = ha->ms_iocb;
1137 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
1139 ms_pkt->entry_type = MS_IOCB_TYPE;
1140 ms_pkt->entry_count = 1;
1141 SET_TARGET_ID(ha, ms_pkt->loop_id, ha->mgmt_svr_loop_id);
1142 ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
1143 ms_pkt->timeout = __constant_cpu_to_le16(59);
1144 ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1145 ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
1146 ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
1147 ms_pkt->req_bytecount = cpu_to_le32(req_size);
1149 ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1150 ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1151 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
1153 ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1154 ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1155 ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
1161 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1163 * @req_size: request size in bytes
1164 * @rsp_size: response size in bytes
1166 * Returns a pointer to the @ha's ms_iocb.
1169 qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size,
1172 struct ct_entry_24xx *ct_pkt;
1174 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1175 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
1177 ct_pkt->entry_type = CT_IOCB_TYPE;
1178 ct_pkt->entry_count = 1;
1179 ct_pkt->nport_handle = cpu_to_le16(ha->mgmt_svr_loop_id);
1180 ct_pkt->timeout = __constant_cpu_to_le16(59);
1181 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1182 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
1183 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
1184 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1186 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1187 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1188 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1190 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1191 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1192 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
1197 static inline ms_iocb_entry_t *
1198 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size)
1200 ms_iocb_entry_t *ms_pkt = ha->ms_iocb;
1201 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1203 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
1204 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1205 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1207 ms_pkt->req_bytecount = cpu_to_le32(req_size);
1208 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
1215 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1216 * @ct_req: CT request buffer
1218 * @rsp_size: response size in bytes
1220 * Returns a pointer to the intitialized @ct_req.
1222 static inline struct ct_sns_req *
1223 qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd,
1226 memset(ct_req, 0, sizeof(struct ct_sns_pkt));
1228 ct_req->header.revision = 0x01;
1229 ct_req->header.gs_type = 0xFA;
1230 ct_req->header.gs_subtype = 0x10;
1231 ct_req->command = cpu_to_be16(cmd);
1232 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
1238 * qla2x00_fdmi_rhba() -
1241 * Returns 0 on success.
1244 qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1249 ms_iocb_entry_t *ms_pkt;
1250 struct ct_sns_req *ct_req;
1251 struct ct_sns_rsp *ct_rsp;
1253 struct ct_fdmi_hba_attr *eiter;
1256 /* Prepare common MS IOCB */
1257 /* Request size adjusted after CT preparation */
1258 ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE);
1260 /* Prepare CT request */
1261 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD,
1263 ct_rsp = &ha->ct_sns->p.rsp;
1265 /* Prepare FDMI command arguments -- attribute block, attributes. */
1266 memcpy(ct_req->req.rhba.hba_identifier, ha->port_name, WWN_SIZE);
1267 ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1);
1268 memcpy(ct_req->req.rhba.port_name, ha->port_name, WWN_SIZE);
1269 size = 2 * WWN_SIZE + 4 + 4;
1272 ct_req->req.rhba.attrs.count =
1273 __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT);
1274 entries = ct_req->req.rhba.hba_identifier;
1277 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1278 eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME);
1279 eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE);
1280 memcpy(eiter->a.node_name, ha->node_name, WWN_SIZE);
1281 size += 4 + WWN_SIZE;
1283 DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n",
1284 __func__, ha->host_no,
1285 eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2],
1286 eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5],
1287 eiter->a.node_name[6], eiter->a.node_name[7]));
1290 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1291 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER);
1292 strcpy(eiter->a.manufacturer, "QLogic Corporation");
1293 alen = strlen(eiter->a.manufacturer);
1294 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1295 eiter->len = cpu_to_be16(4 + alen);
1298 DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, ha->host_no,
1299 eiter->a.manufacturer));
1301 /* Serial number. */
1302 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1303 eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER);
1304 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
1305 sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000);
1306 alen = strlen(eiter->a.serial_num);
1307 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1308 eiter->len = cpu_to_be16(4 + alen);
1311 DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, ha->host_no,
1312 eiter->a.serial_num));
1315 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1316 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL);
1317 strcpy(eiter->a.model, ha->model_number);
1318 alen = strlen(eiter->a.model);
1319 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1320 eiter->len = cpu_to_be16(4 + alen);
1323 DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, ha->host_no,
1326 /* Model description. */
1327 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1328 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
1330 strncpy(eiter->a.model_desc, ha->model_desc, 80);
1331 alen = strlen(eiter->a.model_desc);
1332 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1333 eiter->len = cpu_to_be16(4 + alen);
1336 DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, ha->host_no,
1337 eiter->a.model_desc));
1339 /* Hardware version. */
1340 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1341 eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION);
1342 strcpy(eiter->a.hw_version, ha->adapter_id);
1343 alen = strlen(eiter->a.hw_version);
1344 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1345 eiter->len = cpu_to_be16(4 + alen);
1348 DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, ha->host_no,
1349 eiter->a.hw_version));
1351 /* Driver version. */
1352 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1353 eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION);
1354 strcpy(eiter->a.driver_version, qla2x00_version_str);
1355 alen = strlen(eiter->a.driver_version);
1356 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1357 eiter->len = cpu_to_be16(4 + alen);
1360 DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, ha->host_no,
1361 eiter->a.driver_version));
1363 /* Option ROM version. */
1364 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1365 eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION);
1366 strcpy(eiter->a.orom_version, "0.00");
1367 alen = strlen(eiter->a.orom_version);
1368 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1369 eiter->len = cpu_to_be16(4 + alen);
1372 DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, ha->host_no,
1373 eiter->a.orom_version));
1375 /* Firmware version */
1376 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1377 eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
1378 ha->isp_ops.fw_version_str(ha, eiter->a.fw_version);
1379 alen = strlen(eiter->a.fw_version);
1380 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1381 eiter->len = cpu_to_be16(4 + alen);
1384 DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, ha->host_no,
1385 eiter->a.fw_version));
1387 /* Update MS request size. */
1388 qla2x00_update_ms_fdmi_iocb(ha, size + 16);
1390 DEBUG13(printk("%s(%ld): RHBA identifier="
1391 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
1392 ha->host_no, ct_req->req.rhba.hba_identifier[0],
1393 ct_req->req.rhba.hba_identifier[1],
1394 ct_req->req.rhba.hba_identifier[2],
1395 ct_req->req.rhba.hba_identifier[3],
1396 ct_req->req.rhba.hba_identifier[4],
1397 ct_req->req.rhba.hba_identifier[5],
1398 ct_req->req.rhba.hba_identifier[6],
1399 ct_req->req.rhba.hba_identifier[7], size));
1400 DEBUG13(qla2x00_dump_buffer(entries, size));
1402 /* Execute MS IOCB */
1403 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
1404 sizeof(ms_iocb_entry_t));
1405 if (rval != QLA_SUCCESS) {
1407 DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n",
1408 ha->host_no, rval));
1409 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RHBA") !=
1411 rval = QLA_FUNCTION_FAILED;
1412 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
1413 ct_rsp->header.explanation_code ==
1414 CT_EXPL_ALREADY_REGISTERED) {
1415 DEBUG2_13(printk("%s(%ld): HBA already registered.\n",
1416 __func__, ha->host_no));
1417 rval = QLA_ALREADY_REGISTERED;
1420 DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n",
1428 * qla2x00_fdmi_dhba() -
1431 * Returns 0 on success.
1434 qla2x00_fdmi_dhba(scsi_qla_host_t *ha)
1438 ms_iocb_entry_t *ms_pkt;
1439 struct ct_sns_req *ct_req;
1440 struct ct_sns_rsp *ct_rsp;
1443 /* Prepare common MS IOCB */
1444 ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE,
1447 /* Prepare CT request */
1448 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD,
1450 ct_rsp = &ha->ct_sns->p.rsp;
1452 /* Prepare FDMI command arguments -- portname. */
1453 memcpy(ct_req->req.dhba.port_name, ha->port_name, WWN_SIZE);
1455 DEBUG13(printk("%s(%ld): DHBA portname="
1456 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no,
1457 ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1],
1458 ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3],
1459 ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5],
1460 ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7]));
1462 /* Execute MS IOCB */
1463 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
1464 sizeof(ms_iocb_entry_t));
1465 if (rval != QLA_SUCCESS) {
1467 DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n",
1468 ha->host_no, rval));
1469 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "DHBA") !=
1471 rval = QLA_FUNCTION_FAILED;
1473 DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n",
1481 * qla2x00_fdmi_rpa() -
1484 * Returns 0 on success.
1487 qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1490 uint32_t size, max_frame_size;
1492 ms_iocb_entry_t *ms_pkt;
1493 struct ct_sns_req *ct_req;
1494 struct ct_sns_rsp *ct_rsp;
1496 struct ct_fdmi_port_attr *eiter;
1497 struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb;
1500 /* Prepare common MS IOCB */
1501 /* Request size adjusted after CT preparation */
1502 ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE);
1504 /* Prepare CT request */
1505 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD,
1507 ct_rsp = &ha->ct_sns->p.rsp;
1509 /* Prepare FDMI command arguments -- attribute block, attributes. */
1510 memcpy(ct_req->req.rpa.port_name, ha->port_name, WWN_SIZE);
1511 size = WWN_SIZE + 4;
1514 ct_req->req.rpa.attrs.count =
1515 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT);
1516 entries = ct_req->req.rpa.port_name;
1519 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1520 eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES);
1521 eiter->len = __constant_cpu_to_be16(4 + 32);
1522 eiter->a.fc4_types[2] = 0x01;
1525 DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__, ha->host_no,
1526 eiter->a.fc4_types[2], 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_QLA24XX(ha) || IS_QLA54XX(ha))
1533 eiter->a.sup_speed = __constant_cpu_to_be32(4);
1534 else if (IS_QLA23XX(ha))
1535 eiter->a.sup_speed = __constant_cpu_to_be32(2);
1537 eiter->a.sup_speed = __constant_cpu_to_be32(1);
1540 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no,
1541 eiter->a.sup_speed));
1543 /* Current speed. */
1544 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1545 eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED);
1546 eiter->len = __constant_cpu_to_be16(4 + 4);
1547 switch (ha->link_data_rate) {
1549 eiter->a.cur_speed = __constant_cpu_to_be32(1);
1552 eiter->a.cur_speed = __constant_cpu_to_be32(2);
1555 eiter->a.cur_speed = __constant_cpu_to_be32(4);
1560 DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no,
1561 eiter->a.cur_speed));
1563 /* Max frame size. */
1564 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1565 eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
1566 eiter->len = __constant_cpu_to_be16(4 + 4);
1567 max_frame_size = IS_QLA24XX(ha) || IS_QLA54XX(ha) ?
1568 (uint32_t) icb24->frame_payload_size:
1569 (uint32_t) ha->init_cb->frame_payload_size;
1570 eiter->a.max_frame_size = cpu_to_be32(max_frame_size);
1573 DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no,
1574 eiter->a.max_frame_size));
1576 /* OS device name. */
1577 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1578 eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
1579 sprintf(eiter->a.os_dev_name, "/proc/scsi/qla2xxx/%ld", ha->host_no);
1580 alen = strlen(eiter->a.os_dev_name);
1581 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1582 eiter->len = cpu_to_be16(4 + alen);
1585 DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no,
1586 eiter->a.os_dev_name));
1588 /* Update MS request size. */
1589 qla2x00_update_ms_fdmi_iocb(ha, size + 16);
1591 DEBUG13(printk("%s(%ld): RPA portname="
1592 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
1593 ha->host_no, ct_req->req.rpa.port_name[0],
1594 ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2],
1595 ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4],
1596 ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6],
1597 ct_req->req.rpa.port_name[7], size));
1598 DEBUG13(qla2x00_dump_buffer(entries, size));
1600 /* Execute MS IOCB */
1601 rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
1602 sizeof(ms_iocb_entry_t));
1603 if (rval != QLA_SUCCESS) {
1605 DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n",
1606 ha->host_no, rval));
1607 } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") !=
1609 rval = QLA_FUNCTION_FAILED;
1611 DEBUG2(printk("scsi(%ld): RPA exiting normally.\n",
1619 * qla2x00_fdmi_register() -
1622 * Returns 0 on success.
1625 qla2x00_fdmi_register(scsi_qla_host_t *ha)
1629 rval = qla2x00_mgmt_svr_login(ha);
1633 rval = qla2x00_fdmi_rhba(ha);
1635 if (rval != QLA_ALREADY_REGISTERED)
1638 rval = qla2x00_fdmi_dhba(ha);
1642 rval = qla2x00_fdmi_rhba(ha);
1646 rval = qla2x00_fdmi_rpa(ha);