2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2014 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
8 #include "qla_target.h"
9 #include <linux/utsname.h>
11 static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *);
12 static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *);
13 static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *);
14 static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *);
15 static int qla2x00_sns_rft_id(scsi_qla_host_t *);
16 static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
19 * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
21 * @req_size: request size in bytes
22 * @rsp_size: response size in bytes
24 * Returns a pointer to the @ha's ms_iocb.
27 qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
29 struct qla_hw_data *ha = vha->hw;
30 ms_iocb_entry_t *ms_pkt;
33 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
35 ms_pkt->entry_type = MS_IOCB_TYPE;
36 ms_pkt->entry_count = 1;
37 SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER);
38 ms_pkt->control_flags = cpu_to_le16(CF_READ | CF_HEAD_TAG);
39 ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
40 ms_pkt->cmd_dsd_count = cpu_to_le16(1);
41 ms_pkt->total_dsd_count = cpu_to_le16(2);
42 ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
43 ms_pkt->req_bytecount = cpu_to_le32(req_size);
45 ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
46 ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
47 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
49 ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
50 ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
51 ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
53 vha->qla_stats.control_requests++;
59 * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
61 * @req_size: request size in bytes
62 * @rsp_size: response size in bytes
64 * Returns a pointer to the @ha's ms_iocb.
67 qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
69 struct qla_hw_data *ha = vha->hw;
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 = cpu_to_le16(NPH_SNS);
78 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
79 ct_pkt->cmd_dsd_count = cpu_to_le16(1);
80 ct_pkt->rsp_dsd_count = cpu_to_le16(1);
81 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
82 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
84 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
85 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
86 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
88 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
89 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
90 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
91 ct_pkt->vp_index = vha->vp_idx;
93 vha->qla_stats.control_requests++;
99 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
100 * @ct_req: CT request buffer
102 * @rsp_size: response size in bytes
104 * Returns a pointer to the intitialized @ct_req.
106 static inline struct ct_sns_req *
107 qla2x00_prep_ct_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t rsp_size)
109 memset(p, 0, sizeof(struct ct_sns_pkt));
111 p->p.req.header.revision = 0x01;
112 p->p.req.header.gs_type = 0xFC;
113 p->p.req.header.gs_subtype = 0x02;
114 p->p.req.command = cpu_to_be16(cmd);
115 p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
121 qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt,
122 struct ct_sns_rsp *ct_rsp, const char *routine)
125 uint16_t comp_status;
126 struct qla_hw_data *ha = vha->hw;
128 rval = QLA_FUNCTION_FAILED;
129 if (ms_pkt->entry_status != 0) {
130 ql_dbg(ql_dbg_disc, vha, 0x2031,
131 "%s failed, error status (%x) on port_id: %02x%02x%02x.\n",
132 routine, ms_pkt->entry_status, vha->d_id.b.domain,
133 vha->d_id.b.area, vha->d_id.b.al_pa);
135 if (IS_FWI2_CAPABLE(ha))
136 comp_status = le16_to_cpu(
137 ((struct ct_entry_24xx *)ms_pkt)->comp_status);
139 comp_status = le16_to_cpu(ms_pkt->status);
140 switch (comp_status) {
142 case CS_DATA_UNDERRUN:
143 case CS_DATA_OVERRUN: /* Overrun? */
144 if (ct_rsp->header.response !=
145 cpu_to_be16(CT_ACCEPT_RESPONSE)) {
146 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2077,
147 "%s failed rejected request on port_id: %02x%02x%02x Compeltion status 0x%x, response 0x%x\n",
148 routine, vha->d_id.b.domain,
149 vha->d_id.b.area, vha->d_id.b.al_pa,
150 comp_status, ct_rsp->header.response);
151 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha,
152 0x2078, (uint8_t *)&ct_rsp->header,
153 sizeof(struct ct_rsp_hdr));
154 rval = QLA_INVALID_COMMAND;
159 ql_dbg(ql_dbg_disc, vha, 0x2033,
160 "%s failed, completion status (%x) on port_id: "
161 "%02x%02x%02x.\n", routine, comp_status,
162 vha->d_id.b.domain, vha->d_id.b.area,
171 * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
173 * @fcport: fcport entry to updated
175 * Returns 0 on success.
178 qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
182 ms_iocb_entry_t *ms_pkt;
183 struct ct_sns_req *ct_req;
184 struct ct_sns_rsp *ct_rsp;
185 struct qla_hw_data *ha = vha->hw;
187 if (IS_QLA2100(ha) || IS_QLA2200(ha))
188 return qla2x00_sns_ga_nxt(vha, fcport);
191 /* Prepare common MS IOCB */
192 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GA_NXT_REQ_SIZE,
195 /* Prepare CT request */
196 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GA_NXT_CMD,
198 ct_rsp = &ha->ct_sns->p.rsp;
200 /* Prepare CT arguments -- port_id */
201 ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
202 ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
203 ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
205 /* Execute MS IOCB */
206 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
207 sizeof(ms_iocb_entry_t));
208 if (rval != QLA_SUCCESS) {
210 ql_dbg(ql_dbg_disc, vha, 0x2062,
211 "GA_NXT issue IOCB failed (%d).\n", rval);
212 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GA_NXT") !=
214 rval = QLA_FUNCTION_FAILED;
216 /* Populate fc_port_t entry. */
217 fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0];
218 fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1];
219 fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2];
221 memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name,
223 memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name,
226 fcport->fc4_type = (ct_rsp->rsp.ga_nxt.fc4_types[2] & BIT_0) ?
227 FC4_TYPE_FCP_SCSI : FC4_TYPE_OTHER;
229 if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE &&
230 ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE)
231 fcport->d_id.b.domain = 0xf0;
233 ql_dbg(ql_dbg_disc, vha, 0x2063,
234 "GA_NXT entry - nn %8phN pn %8phN "
235 "port_id=%02x%02x%02x.\n",
236 fcport->node_name, fcport->port_name,
237 fcport->d_id.b.domain, fcport->d_id.b.area,
238 fcport->d_id.b.al_pa);
245 qla2x00_gid_pt_rsp_size(scsi_qla_host_t *vha)
247 return vha->hw->max_fibre_devices * 4 + 16;
251 * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
253 * @list: switch info entries to populate
255 * NOTE: Non-Nx_Ports are not requested.
257 * Returns 0 on success.
260 qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
265 ms_iocb_entry_t *ms_pkt;
266 struct ct_sns_req *ct_req;
267 struct ct_sns_rsp *ct_rsp;
269 struct ct_sns_gid_pt_data *gid_data;
270 struct qla_hw_data *ha = vha->hw;
271 uint16_t gid_pt_rsp_size;
273 if (IS_QLA2100(ha) || IS_QLA2200(ha))
274 return qla2x00_sns_gid_pt(vha, list);
277 gid_pt_rsp_size = qla2x00_gid_pt_rsp_size(vha);
279 /* Prepare common MS IOCB */
280 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GID_PT_REQ_SIZE,
283 /* Prepare CT request */
284 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GID_PT_CMD, gid_pt_rsp_size);
285 ct_rsp = &ha->ct_sns->p.rsp;
287 /* Prepare CT arguments -- port_type */
288 ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
290 /* Execute MS IOCB */
291 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
292 sizeof(ms_iocb_entry_t));
293 if (rval != QLA_SUCCESS) {
295 ql_dbg(ql_dbg_disc, vha, 0x2055,
296 "GID_PT issue IOCB failed (%d).\n", rval);
297 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GID_PT") !=
299 rval = QLA_FUNCTION_FAILED;
301 /* Set port IDs in switch info list. */
302 for (i = 0; i < ha->max_fibre_devices; i++) {
303 gid_data = &ct_rsp->rsp.gid_pt.entries[i];
304 list[i].d_id.b.domain = gid_data->port_id[0];
305 list[i].d_id.b.area = gid_data->port_id[1];
306 list[i].d_id.b.al_pa = gid_data->port_id[2];
307 memset(list[i].fabric_port_name, 0, WWN_SIZE);
308 list[i].fp_speed = PORT_SPEED_UNKNOWN;
311 if (gid_data->control_byte & BIT_7) {
312 list[i].d_id.b.rsvd_1 = gid_data->control_byte;
318 * If we've used all available slots, then the switch is
319 * reporting back more devices than we can handle with this
320 * single call. Return a failed status, and let GA_NXT handle
323 if (i == ha->max_fibre_devices)
324 rval = QLA_FUNCTION_FAILED;
331 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
333 * @list: switch info entries to populate
335 * Returns 0 on success.
338 qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
340 int rval = QLA_SUCCESS;
343 ms_iocb_entry_t *ms_pkt;
344 struct ct_sns_req *ct_req;
345 struct ct_sns_rsp *ct_rsp;
346 struct qla_hw_data *ha = vha->hw;
348 if (IS_QLA2100(ha) || IS_QLA2200(ha))
349 return qla2x00_sns_gpn_id(vha, list);
351 for (i = 0; i < ha->max_fibre_devices; i++) {
353 /* Prepare common MS IOCB */
354 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GPN_ID_REQ_SIZE,
357 /* Prepare CT request */
358 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GPN_ID_CMD,
360 ct_rsp = &ha->ct_sns->p.rsp;
362 /* Prepare CT arguments -- port_id */
363 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
364 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
365 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
367 /* Execute MS IOCB */
368 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
369 sizeof(ms_iocb_entry_t));
370 if (rval != QLA_SUCCESS) {
372 ql_dbg(ql_dbg_disc, vha, 0x2056,
373 "GPN_ID issue IOCB failed (%d).\n", rval);
375 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
376 "GPN_ID") != QLA_SUCCESS) {
377 rval = QLA_FUNCTION_FAILED;
381 memcpy(list[i].port_name,
382 ct_rsp->rsp.gpn_id.port_name, WWN_SIZE);
385 /* Last device exit. */
386 if (list[i].d_id.b.rsvd_1 != 0)
394 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
396 * @list: switch info entries to populate
398 * Returns 0 on success.
401 qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
403 int rval = QLA_SUCCESS;
405 struct qla_hw_data *ha = vha->hw;
406 ms_iocb_entry_t *ms_pkt;
407 struct ct_sns_req *ct_req;
408 struct ct_sns_rsp *ct_rsp;
410 if (IS_QLA2100(ha) || IS_QLA2200(ha))
411 return qla2x00_sns_gnn_id(vha, list);
413 for (i = 0; i < ha->max_fibre_devices; i++) {
415 /* Prepare common MS IOCB */
416 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GNN_ID_REQ_SIZE,
419 /* Prepare CT request */
420 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GNN_ID_CMD,
422 ct_rsp = &ha->ct_sns->p.rsp;
424 /* Prepare CT arguments -- port_id */
425 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
426 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
427 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
429 /* Execute MS IOCB */
430 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
431 sizeof(ms_iocb_entry_t));
432 if (rval != QLA_SUCCESS) {
434 ql_dbg(ql_dbg_disc, vha, 0x2057,
435 "GNN_ID issue IOCB failed (%d).\n", rval);
437 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
438 "GNN_ID") != QLA_SUCCESS) {
439 rval = QLA_FUNCTION_FAILED;
443 memcpy(list[i].node_name,
444 ct_rsp->rsp.gnn_id.node_name, WWN_SIZE);
446 ql_dbg(ql_dbg_disc, vha, 0x2058,
447 "GID_PT entry - nn %8phN pn %8phN "
448 "portid=%02x%02x%02x.\n",
449 list[i].node_name, list[i].port_name,
450 list[i].d_id.b.domain, list[i].d_id.b.area,
451 list[i].d_id.b.al_pa);
454 /* Last device exit. */
455 if (list[i].d_id.b.rsvd_1 != 0)
463 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
466 * Returns 0 on success.
469 qla2x00_rft_id(scsi_qla_host_t *vha)
472 struct qla_hw_data *ha = vha->hw;
473 ms_iocb_entry_t *ms_pkt;
474 struct ct_sns_req *ct_req;
475 struct ct_sns_rsp *ct_rsp;
477 if (IS_QLA2100(ha) || IS_QLA2200(ha))
478 return qla2x00_sns_rft_id(vha);
481 /* Prepare common MS IOCB */
482 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFT_ID_REQ_SIZE,
485 /* Prepare CT request */
486 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFT_ID_CMD,
488 ct_rsp = &ha->ct_sns->p.rsp;
490 /* Prepare CT arguments -- port_id, FC-4 types */
491 ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain;
492 ct_req->req.rft_id.port_id[1] = vha->d_id.b.area;
493 ct_req->req.rft_id.port_id[2] = vha->d_id.b.al_pa;
495 ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
497 /* Execute MS IOCB */
498 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
499 sizeof(ms_iocb_entry_t));
500 if (rval != QLA_SUCCESS) {
502 ql_dbg(ql_dbg_disc, vha, 0x2043,
503 "RFT_ID issue IOCB failed (%d).\n", rval);
504 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFT_ID") !=
506 rval = QLA_FUNCTION_FAILED;
508 ql_dbg(ql_dbg_disc, vha, 0x2044,
509 "RFT_ID exiting normally.\n");
516 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
519 * Returns 0 on success.
522 qla2x00_rff_id(scsi_qla_host_t *vha)
525 struct qla_hw_data *ha = vha->hw;
526 ms_iocb_entry_t *ms_pkt;
527 struct ct_sns_req *ct_req;
528 struct ct_sns_rsp *ct_rsp;
530 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
531 ql_dbg(ql_dbg_disc, vha, 0x2046,
532 "RFF_ID call not supported on ISP2100/ISP2200.\n");
533 return (QLA_SUCCESS);
537 /* Prepare common MS IOCB */
538 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFF_ID_REQ_SIZE,
541 /* Prepare CT request */
542 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFF_ID_CMD,
544 ct_rsp = &ha->ct_sns->p.rsp;
546 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
547 ct_req->req.rff_id.port_id[0] = vha->d_id.b.domain;
548 ct_req->req.rff_id.port_id[1] = vha->d_id.b.area;
549 ct_req->req.rff_id.port_id[2] = vha->d_id.b.al_pa;
551 qlt_rff_id(vha, ct_req);
553 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
555 /* Execute MS IOCB */
556 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
557 sizeof(ms_iocb_entry_t));
558 if (rval != QLA_SUCCESS) {
560 ql_dbg(ql_dbg_disc, vha, 0x2047,
561 "RFF_ID issue IOCB failed (%d).\n", rval);
562 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFF_ID") !=
564 rval = QLA_FUNCTION_FAILED;
566 ql_dbg(ql_dbg_disc, vha, 0x2048,
567 "RFF_ID exiting normally.\n");
574 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
577 * Returns 0 on success.
580 qla2x00_rnn_id(scsi_qla_host_t *vha)
583 struct qla_hw_data *ha = vha->hw;
584 ms_iocb_entry_t *ms_pkt;
585 struct ct_sns_req *ct_req;
586 struct ct_sns_rsp *ct_rsp;
588 if (IS_QLA2100(ha) || IS_QLA2200(ha))
589 return qla2x00_sns_rnn_id(vha);
592 /* Prepare common MS IOCB */
593 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RNN_ID_REQ_SIZE,
596 /* Prepare CT request */
597 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RNN_ID_CMD, RNN_ID_RSP_SIZE);
598 ct_rsp = &ha->ct_sns->p.rsp;
600 /* Prepare CT arguments -- port_id, node_name */
601 ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain;
602 ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area;
603 ct_req->req.rnn_id.port_id[2] = vha->d_id.b.al_pa;
605 memcpy(ct_req->req.rnn_id.node_name, vha->node_name, WWN_SIZE);
607 /* Execute MS IOCB */
608 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
609 sizeof(ms_iocb_entry_t));
610 if (rval != QLA_SUCCESS) {
612 ql_dbg(ql_dbg_disc, vha, 0x204d,
613 "RNN_ID issue IOCB failed (%d).\n", rval);
614 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RNN_ID") !=
616 rval = QLA_FUNCTION_FAILED;
618 ql_dbg(ql_dbg_disc, vha, 0x204e,
619 "RNN_ID exiting normally.\n");
626 qla2x00_get_sym_node_name(scsi_qla_host_t *vha, uint8_t *snn, size_t size)
628 struct qla_hw_data *ha = vha->hw;
631 snprintf(snn, size, "%s FW:v%s DVR:v%s", ha->model_number,
632 ha->mr.fw_version, qla2x00_version_str);
635 "%s FW:v%d.%02d.%02d DVR:v%s", ha->model_number,
636 ha->fw_major_version, ha->fw_minor_version,
637 ha->fw_subminor_version, qla2x00_version_str);
641 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
644 * Returns 0 on success.
647 qla2x00_rsnn_nn(scsi_qla_host_t *vha)
650 struct qla_hw_data *ha = vha->hw;
651 ms_iocb_entry_t *ms_pkt;
652 struct ct_sns_req *ct_req;
653 struct ct_sns_rsp *ct_rsp;
655 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
656 ql_dbg(ql_dbg_disc, vha, 0x2050,
657 "RSNN_ID call unsupported on ISP2100/ISP2200.\n");
658 return (QLA_SUCCESS);
662 /* Prepare common MS IOCB */
663 /* Request size adjusted after CT preparation */
664 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE);
666 /* Prepare CT request */
667 ct_req = qla2x00_prep_ct_req(ha->ct_sns, RSNN_NN_CMD,
669 ct_rsp = &ha->ct_sns->p.rsp;
671 /* Prepare CT arguments -- node_name, symbolic node_name, size */
672 memcpy(ct_req->req.rsnn_nn.node_name, vha->node_name, WWN_SIZE);
674 /* Prepare the Symbolic Node Name */
675 qla2x00_get_sym_node_name(vha, ct_req->req.rsnn_nn.sym_node_name,
676 sizeof(ct_req->req.rsnn_nn.sym_node_name));
678 /* Calculate SNN length */
679 ct_req->req.rsnn_nn.name_len =
680 (uint8_t)strlen(ct_req->req.rsnn_nn.sym_node_name);
682 /* Update MS IOCB request */
683 ms_pkt->req_bytecount =
684 cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len);
685 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
687 /* Execute MS IOCB */
688 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
689 sizeof(ms_iocb_entry_t));
690 if (rval != QLA_SUCCESS) {
692 ql_dbg(ql_dbg_disc, vha, 0x2051,
693 "RSNN_NN issue IOCB failed (%d).\n", rval);
694 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RSNN_NN") !=
696 rval = QLA_FUNCTION_FAILED;
698 ql_dbg(ql_dbg_disc, vha, 0x2052,
699 "RSNN_NN exiting normally.\n");
706 * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
709 * @scmd_len: Subcommand length
710 * @data_size: response size in bytes
712 * Returns a pointer to the @ha's sns_cmd.
714 static inline struct sns_cmd_pkt *
715 qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len,
719 struct sns_cmd_pkt *sns_cmd;
720 struct qla_hw_data *ha = vha->hw;
722 sns_cmd = ha->sns_cmd;
723 memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
724 wc = data_size / 2; /* Size in 16bit words. */
725 sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc);
726 sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma));
727 sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma));
728 sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len);
729 sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd);
730 wc = (data_size - 16) / 4; /* Size in 32bit words. */
731 sns_cmd->p.cmd.size = cpu_to_le16(wc);
733 vha->qla_stats.control_requests++;
739 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
741 * @fcport: fcport entry to updated
743 * This command uses the old Exectute SNS Command mailbox routine.
745 * Returns 0 on success.
748 qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
750 int rval = QLA_SUCCESS;
751 struct qla_hw_data *ha = vha->hw;
752 struct sns_cmd_pkt *sns_cmd;
755 /* Prepare SNS command request. */
756 sns_cmd = qla2x00_prep_sns_cmd(vha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
757 GA_NXT_SNS_DATA_SIZE);
759 /* Prepare SNS command arguments -- port_id. */
760 sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa;
761 sns_cmd->p.cmd.param[1] = fcport->d_id.b.area;
762 sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
764 /* Execute SNS command. */
765 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
766 sizeof(struct sns_cmd_pkt));
767 if (rval != QLA_SUCCESS) {
769 ql_dbg(ql_dbg_disc, vha, 0x205f,
770 "GA_NXT Send SNS failed (%d).\n", rval);
771 } else if (sns_cmd->p.gan_data[8] != 0x80 ||
772 sns_cmd->p.gan_data[9] != 0x02) {
773 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2084,
774 "GA_NXT failed, rejected request ga_nxt_rsp:\n");
775 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2074,
776 sns_cmd->p.gan_data, 16);
777 rval = QLA_FUNCTION_FAILED;
779 /* Populate fc_port_t entry. */
780 fcport->d_id.b.domain = sns_cmd->p.gan_data[17];
781 fcport->d_id.b.area = sns_cmd->p.gan_data[18];
782 fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19];
784 memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE);
785 memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE);
787 if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE &&
788 sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE)
789 fcport->d_id.b.domain = 0xf0;
791 ql_dbg(ql_dbg_disc, vha, 0x2061,
792 "GA_NXT entry - nn %8phN pn %8phN "
793 "port_id=%02x%02x%02x.\n",
794 fcport->node_name, fcport->port_name,
795 fcport->d_id.b.domain, fcport->d_id.b.area,
796 fcport->d_id.b.al_pa);
803 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
805 * @list: switch info entries to populate
807 * This command uses the old Exectute SNS Command mailbox routine.
809 * NOTE: Non-Nx_Ports are not requested.
811 * Returns 0 on success.
814 qla2x00_sns_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
817 struct qla_hw_data *ha = vha->hw;
820 struct sns_cmd_pkt *sns_cmd;
821 uint16_t gid_pt_sns_data_size;
823 gid_pt_sns_data_size = qla2x00_gid_pt_rsp_size(vha);
826 /* Prepare SNS command request. */
827 sns_cmd = qla2x00_prep_sns_cmd(vha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
828 gid_pt_sns_data_size);
830 /* Prepare SNS command arguments -- port_type. */
831 sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
833 /* Execute SNS command. */
834 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
835 sizeof(struct sns_cmd_pkt));
836 if (rval != QLA_SUCCESS) {
838 ql_dbg(ql_dbg_disc, vha, 0x206d,
839 "GID_PT Send SNS failed (%d).\n", rval);
840 } else if (sns_cmd->p.gid_data[8] != 0x80 ||
841 sns_cmd->p.gid_data[9] != 0x02) {
842 ql_dbg(ql_dbg_disc, vha, 0x202f,
843 "GID_PT failed, rejected request, gid_rsp:\n");
844 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2081,
845 sns_cmd->p.gid_data, 16);
846 rval = QLA_FUNCTION_FAILED;
848 /* Set port IDs in switch info list. */
849 for (i = 0; i < ha->max_fibre_devices; i++) {
850 entry = &sns_cmd->p.gid_data[(i * 4) + 16];
851 list[i].d_id.b.domain = entry[1];
852 list[i].d_id.b.area = entry[2];
853 list[i].d_id.b.al_pa = entry[3];
856 if (entry[0] & BIT_7) {
857 list[i].d_id.b.rsvd_1 = entry[0];
863 * If we've used all available slots, then the switch is
864 * reporting back more devices that we can handle with this
865 * single call. Return a failed status, and let GA_NXT handle
868 if (i == ha->max_fibre_devices)
869 rval = QLA_FUNCTION_FAILED;
876 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
878 * @list: switch info entries to populate
880 * This command uses the old Exectute SNS Command mailbox routine.
882 * Returns 0 on success.
885 qla2x00_sns_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
887 int rval = QLA_SUCCESS;
888 struct qla_hw_data *ha = vha->hw;
890 struct sns_cmd_pkt *sns_cmd;
892 for (i = 0; i < ha->max_fibre_devices; i++) {
894 /* Prepare SNS command request. */
895 sns_cmd = qla2x00_prep_sns_cmd(vha, GPN_ID_CMD,
896 GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
898 /* Prepare SNS command arguments -- port_id. */
899 sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
900 sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
901 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
903 /* Execute SNS command. */
904 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
905 GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
906 if (rval != QLA_SUCCESS) {
908 ql_dbg(ql_dbg_disc, vha, 0x2032,
909 "GPN_ID Send SNS failed (%d).\n", rval);
910 } else if (sns_cmd->p.gpn_data[8] != 0x80 ||
911 sns_cmd->p.gpn_data[9] != 0x02) {
912 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x207e,
913 "GPN_ID failed, rejected request, gpn_rsp:\n");
914 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207f,
915 sns_cmd->p.gpn_data, 16);
916 rval = QLA_FUNCTION_FAILED;
919 memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16],
923 /* Last device exit. */
924 if (list[i].d_id.b.rsvd_1 != 0)
932 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
934 * @list: switch info entries to populate
936 * This command uses the old Exectute SNS Command mailbox routine.
938 * Returns 0 on success.
941 qla2x00_sns_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
943 int rval = QLA_SUCCESS;
944 struct qla_hw_data *ha = vha->hw;
946 struct sns_cmd_pkt *sns_cmd;
948 for (i = 0; i < ha->max_fibre_devices; i++) {
950 /* Prepare SNS command request. */
951 sns_cmd = qla2x00_prep_sns_cmd(vha, GNN_ID_CMD,
952 GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
954 /* Prepare SNS command arguments -- port_id. */
955 sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
956 sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
957 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
959 /* Execute SNS command. */
960 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
961 GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
962 if (rval != QLA_SUCCESS) {
964 ql_dbg(ql_dbg_disc, vha, 0x203f,
965 "GNN_ID Send SNS failed (%d).\n", rval);
966 } else if (sns_cmd->p.gnn_data[8] != 0x80 ||
967 sns_cmd->p.gnn_data[9] != 0x02) {
968 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2082,
969 "GNN_ID failed, rejected request, gnn_rsp:\n");
970 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207a,
971 sns_cmd->p.gnn_data, 16);
972 rval = QLA_FUNCTION_FAILED;
975 memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16],
978 ql_dbg(ql_dbg_disc, vha, 0x206e,
979 "GID_PT entry - nn %8phN pn %8phN "
980 "port_id=%02x%02x%02x.\n",
981 list[i].node_name, list[i].port_name,
982 list[i].d_id.b.domain, list[i].d_id.b.area,
983 list[i].d_id.b.al_pa);
986 /* Last device exit. */
987 if (list[i].d_id.b.rsvd_1 != 0)
995 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
998 * This command uses the old Exectute SNS Command mailbox routine.
1000 * Returns 0 on success.
1003 qla2x00_sns_rft_id(scsi_qla_host_t *vha)
1006 struct qla_hw_data *ha = vha->hw;
1007 struct sns_cmd_pkt *sns_cmd;
1010 /* Prepare SNS command request. */
1011 sns_cmd = qla2x00_prep_sns_cmd(vha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
1012 RFT_ID_SNS_DATA_SIZE);
1014 /* Prepare SNS command arguments -- port_id, FC-4 types */
1015 sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
1016 sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
1017 sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
1019 sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */
1021 /* Execute SNS command. */
1022 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
1023 sizeof(struct sns_cmd_pkt));
1024 if (rval != QLA_SUCCESS) {
1026 ql_dbg(ql_dbg_disc, vha, 0x2060,
1027 "RFT_ID Send SNS failed (%d).\n", rval);
1028 } else if (sns_cmd->p.rft_data[8] != 0x80 ||
1029 sns_cmd->p.rft_data[9] != 0x02) {
1030 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2083,
1031 "RFT_ID failed, rejected request rft_rsp:\n");
1032 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2080,
1033 sns_cmd->p.rft_data, 16);
1034 rval = QLA_FUNCTION_FAILED;
1036 ql_dbg(ql_dbg_disc, vha, 0x2073,
1037 "RFT_ID exiting normally.\n");
1044 * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
1048 * This command uses the old Exectute SNS Command mailbox routine.
1050 * Returns 0 on success.
1053 qla2x00_sns_rnn_id(scsi_qla_host_t *vha)
1056 struct qla_hw_data *ha = vha->hw;
1057 struct sns_cmd_pkt *sns_cmd;
1060 /* Prepare SNS command request. */
1061 sns_cmd = qla2x00_prep_sns_cmd(vha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
1062 RNN_ID_SNS_DATA_SIZE);
1064 /* Prepare SNS command arguments -- port_id, nodename. */
1065 sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
1066 sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
1067 sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
1069 sns_cmd->p.cmd.param[4] = vha->node_name[7];
1070 sns_cmd->p.cmd.param[5] = vha->node_name[6];
1071 sns_cmd->p.cmd.param[6] = vha->node_name[5];
1072 sns_cmd->p.cmd.param[7] = vha->node_name[4];
1073 sns_cmd->p.cmd.param[8] = vha->node_name[3];
1074 sns_cmd->p.cmd.param[9] = vha->node_name[2];
1075 sns_cmd->p.cmd.param[10] = vha->node_name[1];
1076 sns_cmd->p.cmd.param[11] = vha->node_name[0];
1078 /* Execute SNS command. */
1079 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
1080 sizeof(struct sns_cmd_pkt));
1081 if (rval != QLA_SUCCESS) {
1083 ql_dbg(ql_dbg_disc, vha, 0x204a,
1084 "RNN_ID Send SNS failed (%d).\n", rval);
1085 } else if (sns_cmd->p.rnn_data[8] != 0x80 ||
1086 sns_cmd->p.rnn_data[9] != 0x02) {
1087 ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x207b,
1088 "RNN_ID failed, rejected request, rnn_rsp:\n");
1089 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207c,
1090 sns_cmd->p.rnn_data, 16);
1091 rval = QLA_FUNCTION_FAILED;
1093 ql_dbg(ql_dbg_disc, vha, 0x204c,
1094 "RNN_ID exiting normally.\n");
1101 * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
1104 * Returns 0 on success.
1107 qla2x00_mgmt_svr_login(scsi_qla_host_t *vha)
1110 uint16_t mb[MAILBOX_REGISTER_COUNT];
1111 struct qla_hw_data *ha = vha->hw;
1113 if (vha->flags.management_server_logged_in)
1116 rval = ha->isp_ops->fabric_login(vha, vha->mgmt_svr_loop_id, 0xff, 0xff,
1118 if (rval != QLA_SUCCESS || mb[0] != MBS_COMMAND_COMPLETE) {
1119 if (rval == QLA_MEMORY_ALLOC_FAILED)
1120 ql_dbg(ql_dbg_disc, vha, 0x2085,
1121 "Failed management_server login: loopid=%x "
1122 "rval=%d\n", vha->mgmt_svr_loop_id, rval);
1124 ql_dbg(ql_dbg_disc, vha, 0x2024,
1125 "Failed management_server login: loopid=%x "
1126 "mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x.\n",
1127 vha->mgmt_svr_loop_id, mb[0], mb[1], mb[2], mb[6],
1129 ret = QLA_FUNCTION_FAILED;
1131 vha->flags.management_server_logged_in = 1;
1137 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1139 * @req_size: request size in bytes
1140 * @rsp_size: response size in bytes
1142 * Returns a pointer to the @ha's ms_iocb.
1145 qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
1148 ms_iocb_entry_t *ms_pkt;
1149 struct qla_hw_data *ha = vha->hw;
1150 ms_pkt = ha->ms_iocb;
1151 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
1153 ms_pkt->entry_type = MS_IOCB_TYPE;
1154 ms_pkt->entry_count = 1;
1155 SET_TARGET_ID(ha, ms_pkt->loop_id, vha->mgmt_svr_loop_id);
1156 ms_pkt->control_flags = cpu_to_le16(CF_READ | CF_HEAD_TAG);
1157 ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
1158 ms_pkt->cmd_dsd_count = cpu_to_le16(1);
1159 ms_pkt->total_dsd_count = cpu_to_le16(2);
1160 ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
1161 ms_pkt->req_bytecount = cpu_to_le32(req_size);
1163 ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1164 ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1165 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
1167 ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1168 ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1169 ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
1175 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1177 * @req_size: request size in bytes
1178 * @rsp_size: response size in bytes
1180 * Returns a pointer to the @ha's ms_iocb.
1183 qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
1186 struct ct_entry_24xx *ct_pkt;
1187 struct qla_hw_data *ha = vha->hw;
1189 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1190 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
1192 ct_pkt->entry_type = CT_IOCB_TYPE;
1193 ct_pkt->entry_count = 1;
1194 ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
1195 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
1196 ct_pkt->cmd_dsd_count = cpu_to_le16(1);
1197 ct_pkt->rsp_dsd_count = cpu_to_le16(1);
1198 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
1199 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1201 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1202 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1203 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1205 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1206 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1207 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
1208 ct_pkt->vp_index = vha->vp_idx;
1213 static inline ms_iocb_entry_t *
1214 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size)
1216 struct qla_hw_data *ha = vha->hw;
1217 ms_iocb_entry_t *ms_pkt = ha->ms_iocb;
1218 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1220 if (IS_FWI2_CAPABLE(ha)) {
1221 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1222 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1224 ms_pkt->req_bytecount = cpu_to_le32(req_size);
1225 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
1232 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1233 * @ct_req: CT request buffer
1235 * @rsp_size: response size in bytes
1237 * Returns a pointer to the intitialized @ct_req.
1239 static inline struct ct_sns_req *
1240 qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t cmd,
1243 memset(p, 0, sizeof(struct ct_sns_pkt));
1245 p->p.req.header.revision = 0x01;
1246 p->p.req.header.gs_type = 0xFA;
1247 p->p.req.header.gs_subtype = 0x10;
1248 p->p.req.command = cpu_to_be16(cmd);
1249 p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
1255 * qla2x00_fdmi_rhba() -
1258 * Returns 0 on success.
1261 qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
1266 ms_iocb_entry_t *ms_pkt;
1267 struct ct_sns_req *ct_req;
1268 struct ct_sns_rsp *ct_rsp;
1270 struct ct_fdmi_hba_attr *eiter;
1271 struct qla_hw_data *ha = vha->hw;
1274 /* Prepare common MS IOCB */
1275 /* Request size adjusted after CT preparation */
1276 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE);
1278 /* Prepare CT request */
1279 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RHBA_CMD, RHBA_RSP_SIZE);
1280 ct_rsp = &ha->ct_sns->p.rsp;
1282 /* Prepare FDMI command arguments -- attribute block, attributes. */
1283 memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE);
1284 ct_req->req.rhba.entry_count = cpu_to_be32(1);
1285 memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE);
1286 size = 2 * WWN_SIZE + 4 + 4;
1289 ct_req->req.rhba.attrs.count =
1290 cpu_to_be32(FDMI_HBA_ATTR_COUNT);
1291 entries = ct_req->req.rhba.hba_identifier;
1294 eiter = entries + size;
1295 eiter->type = cpu_to_be16(FDMI_HBA_NODE_NAME);
1296 eiter->len = cpu_to_be16(4 + WWN_SIZE);
1297 memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE);
1298 size += 4 + WWN_SIZE;
1300 ql_dbg(ql_dbg_disc, vha, 0x2025,
1301 "NodeName = %8phN.\n", eiter->a.node_name);
1304 eiter = entries + size;
1305 eiter->type = cpu_to_be16(FDMI_HBA_MANUFACTURER);
1306 alen = strlen(QLA2XXX_MANUFACTURER);
1307 snprintf(eiter->a.manufacturer, sizeof(eiter->a.manufacturer),
1308 "%s", "QLogic Corporation");
1309 alen += 4 - (alen & 3);
1310 eiter->len = cpu_to_be16(4 + alen);
1313 ql_dbg(ql_dbg_disc, vha, 0x2026,
1314 "Manufacturer = %s.\n", eiter->a.manufacturer);
1316 /* Serial number. */
1317 eiter = entries + size;
1318 eiter->type = cpu_to_be16(FDMI_HBA_SERIAL_NUMBER);
1319 if (IS_FWI2_CAPABLE(ha))
1320 qla2xxx_get_vpd_field(vha, "SN", eiter->a.serial_num,
1321 sizeof(eiter->a.serial_num));
1323 sn = ((ha->serial0 & 0x1f) << 16) |
1324 (ha->serial2 << 8) | ha->serial1;
1325 snprintf(eiter->a.serial_num, sizeof(eiter->a.serial_num),
1326 "%c%05d", 'A' + sn / 100000, sn % 100000);
1328 alen = strlen(eiter->a.serial_num);
1329 alen += 4 - (alen & 3);
1330 eiter->len = cpu_to_be16(4 + alen);
1333 ql_dbg(ql_dbg_disc, vha, 0x2027,
1334 "Serial no. = %s.\n", eiter->a.serial_num);
1337 eiter = entries + size;
1338 eiter->type = cpu_to_be16(FDMI_HBA_MODEL);
1339 snprintf(eiter->a.model, sizeof(eiter->a.model),
1340 "%s", ha->model_number);
1341 alen = strlen(eiter->a.model);
1342 alen += 4 - (alen & 3);
1343 eiter->len = cpu_to_be16(4 + alen);
1346 ql_dbg(ql_dbg_disc, vha, 0x2028,
1347 "Model Name = %s.\n", eiter->a.model);
1349 /* Model description. */
1350 eiter = entries + size;
1351 eiter->type = cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
1352 snprintf(eiter->a.model_desc, sizeof(eiter->a.model_desc),
1353 "%s", ha->model_desc);
1354 alen = strlen(eiter->a.model_desc);
1355 alen += 4 - (alen & 3);
1356 eiter->len = cpu_to_be16(4 + alen);
1359 ql_dbg(ql_dbg_disc, vha, 0x2029,
1360 "Model Desc = %s.\n", eiter->a.model_desc);
1362 /* Hardware version. */
1363 eiter = entries + size;
1364 eiter->type = cpu_to_be16(FDMI_HBA_HARDWARE_VERSION);
1365 if (!IS_FWI2_CAPABLE(ha)) {
1366 snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version),
1367 "HW:%s", ha->adapter_id);
1368 } else if (qla2xxx_get_vpd_field(vha, "MN", eiter->a.hw_version,
1369 sizeof(eiter->a.hw_version))) {
1371 } else if (qla2xxx_get_vpd_field(vha, "EC", eiter->a.hw_version,
1372 sizeof(eiter->a.hw_version))) {
1375 snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version),
1376 "HW:%s", ha->adapter_id);
1378 alen = strlen(eiter->a.hw_version);
1379 alen += 4 - (alen & 3);
1380 eiter->len = cpu_to_be16(4 + alen);
1383 ql_dbg(ql_dbg_disc, vha, 0x202a,
1384 "Hardware ver = %s.\n", eiter->a.hw_version);
1386 /* Driver version. */
1387 eiter = entries + size;
1388 eiter->type = cpu_to_be16(FDMI_HBA_DRIVER_VERSION);
1389 snprintf(eiter->a.driver_version, sizeof(eiter->a.driver_version),
1390 "%s", qla2x00_version_str);
1391 alen = strlen(eiter->a.driver_version);
1392 alen += 4 - (alen & 3);
1393 eiter->len = cpu_to_be16(4 + alen);
1396 ql_dbg(ql_dbg_disc, vha, 0x202b,
1397 "Driver ver = %s.\n", eiter->a.driver_version);
1399 /* Option ROM version. */
1400 eiter = entries + size;
1401 eiter->type = cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION);
1402 snprintf(eiter->a.orom_version, sizeof(eiter->a.orom_version),
1403 "%d.%02d", ha->bios_revision[1], ha->bios_revision[0]);
1404 alen = strlen(eiter->a.orom_version);
1405 alen += 4 - (alen & 3);
1406 eiter->len = cpu_to_be16(4 + alen);
1409 ql_dbg(ql_dbg_disc, vha , 0x202c,
1410 "Optrom vers = %s.\n", eiter->a.orom_version);
1412 /* Firmware version */
1413 eiter = entries + size;
1414 eiter->type = cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
1415 ha->isp_ops->fw_version_str(vha, eiter->a.fw_version,
1416 sizeof(eiter->a.fw_version));
1417 alen = strlen(eiter->a.fw_version);
1418 alen += 4 - (alen & 3);
1419 eiter->len = cpu_to_be16(4 + alen);
1422 ql_dbg(ql_dbg_disc, vha, 0x202d,
1423 "Firmware vers = %s.\n", eiter->a.fw_version);
1425 /* Update MS request size. */
1426 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
1428 ql_dbg(ql_dbg_disc, vha, 0x202e,
1429 "RHBA identifier = %8phN size=%d.\n",
1430 ct_req->req.rhba.hba_identifier, size);
1431 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2076,
1434 /* Execute MS IOCB */
1435 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1436 sizeof(ms_iocb_entry_t));
1437 if (rval != QLA_SUCCESS) {
1439 ql_dbg(ql_dbg_disc, vha, 0x2030,
1440 "RHBA issue IOCB failed (%d).\n", rval);
1441 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") !=
1443 rval = QLA_FUNCTION_FAILED;
1444 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
1445 ct_rsp->header.explanation_code ==
1446 CT_EXPL_ALREADY_REGISTERED) {
1447 ql_dbg(ql_dbg_disc, vha, 0x2034,
1448 "HBA already registered.\n");
1449 rval = QLA_ALREADY_REGISTERED;
1451 ql_dbg(ql_dbg_disc, vha, 0x20ad,
1452 "RHBA FDMI registration failed, CT Reason code: 0x%x, CT Explanation 0x%x\n",
1453 ct_rsp->header.reason_code,
1454 ct_rsp->header.explanation_code);
1457 ql_dbg(ql_dbg_disc, vha, 0x2035,
1458 "RHBA exiting normally.\n");
1465 * qla2x00_fdmi_rpa() -
1468 * Returns 0 on success.
1471 qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
1475 struct qla_hw_data *ha = vha->hw;
1476 ms_iocb_entry_t *ms_pkt;
1477 struct ct_sns_req *ct_req;
1478 struct ct_sns_rsp *ct_rsp;
1480 struct ct_fdmi_port_attr *eiter;
1481 struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb;
1482 struct new_utsname *p_sysid = NULL;
1485 /* Prepare common MS IOCB */
1486 /* Request size adjusted after CT preparation */
1487 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE);
1489 /* Prepare CT request */
1490 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RPA_CMD,
1492 ct_rsp = &ha->ct_sns->p.rsp;
1494 /* Prepare FDMI command arguments -- attribute block, attributes. */
1495 memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE);
1496 size = WWN_SIZE + 4;
1499 ct_req->req.rpa.attrs.count = cpu_to_be32(FDMI_PORT_ATTR_COUNT);
1500 entries = ct_req->req.rpa.port_name;
1503 eiter = entries + size;
1504 eiter->type = cpu_to_be16(FDMI_PORT_FC4_TYPES);
1505 eiter->len = cpu_to_be16(4 + 32);
1506 eiter->a.fc4_types[2] = 0x01;
1509 ql_dbg(ql_dbg_disc, vha, 0x2039,
1510 "FC4_TYPES=%02x %02x.\n",
1511 eiter->a.fc4_types[2],
1512 eiter->a.fc4_types[1]);
1514 /* Supported speed. */
1515 eiter = entries + size;
1516 eiter->type = cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
1517 eiter->len = cpu_to_be16(4 + 4);
1518 if (IS_CNA_CAPABLE(ha))
1519 eiter->a.sup_speed = cpu_to_be32(
1520 FDMI_PORT_SPEED_10GB);
1521 else if (IS_QLA27XX(ha))
1522 eiter->a.sup_speed = cpu_to_be32(
1523 FDMI_PORT_SPEED_32GB|
1524 FDMI_PORT_SPEED_16GB|
1525 FDMI_PORT_SPEED_8GB);
1526 else if (IS_QLA2031(ha))
1527 eiter->a.sup_speed = cpu_to_be32(
1528 FDMI_PORT_SPEED_16GB|
1529 FDMI_PORT_SPEED_8GB|
1530 FDMI_PORT_SPEED_4GB);
1531 else if (IS_QLA25XX(ha))
1532 eiter->a.sup_speed = cpu_to_be32(
1533 FDMI_PORT_SPEED_8GB|
1534 FDMI_PORT_SPEED_4GB|
1535 FDMI_PORT_SPEED_2GB|
1536 FDMI_PORT_SPEED_1GB);
1537 else if (IS_QLA24XX_TYPE(ha))
1538 eiter->a.sup_speed = cpu_to_be32(
1539 FDMI_PORT_SPEED_4GB|
1540 FDMI_PORT_SPEED_2GB|
1541 FDMI_PORT_SPEED_1GB);
1542 else if (IS_QLA23XX(ha))
1543 eiter->a.sup_speed = cpu_to_be32(
1544 FDMI_PORT_SPEED_2GB|
1545 FDMI_PORT_SPEED_1GB);
1547 eiter->a.sup_speed = cpu_to_be32(
1548 FDMI_PORT_SPEED_1GB);
1551 ql_dbg(ql_dbg_disc, vha, 0x203a,
1552 "Supported_Speed=%x.\n", eiter->a.sup_speed);
1554 /* Current speed. */
1555 eiter = entries + size;
1556 eiter->type = cpu_to_be16(FDMI_PORT_CURRENT_SPEED);
1557 eiter->len = cpu_to_be16(4 + 4);
1558 switch (ha->link_data_rate) {
1559 case PORT_SPEED_1GB:
1560 eiter->a.cur_speed =
1561 cpu_to_be32(FDMI_PORT_SPEED_1GB);
1563 case PORT_SPEED_2GB:
1564 eiter->a.cur_speed =
1565 cpu_to_be32(FDMI_PORT_SPEED_2GB);
1567 case PORT_SPEED_4GB:
1568 eiter->a.cur_speed =
1569 cpu_to_be32(FDMI_PORT_SPEED_4GB);
1571 case PORT_SPEED_8GB:
1572 eiter->a.cur_speed =
1573 cpu_to_be32(FDMI_PORT_SPEED_8GB);
1575 case PORT_SPEED_10GB:
1576 eiter->a.cur_speed =
1577 cpu_to_be32(FDMI_PORT_SPEED_10GB);
1579 case PORT_SPEED_16GB:
1580 eiter->a.cur_speed =
1581 cpu_to_be32(FDMI_PORT_SPEED_16GB);
1583 case PORT_SPEED_32GB:
1584 eiter->a.cur_speed =
1585 cpu_to_be32(FDMI_PORT_SPEED_32GB);
1588 eiter->a.cur_speed =
1589 cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN);
1594 ql_dbg(ql_dbg_disc, vha, 0x203b,
1595 "Current_Speed=%x.\n", eiter->a.cur_speed);
1597 /* Max frame size. */
1598 eiter = entries + size;
1599 eiter->type = cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
1600 eiter->len = cpu_to_be16(4 + 4);
1601 eiter->a.max_frame_size = IS_FWI2_CAPABLE(ha) ?
1602 le16_to_cpu(icb24->frame_payload_size) :
1603 le16_to_cpu(ha->init_cb->frame_payload_size);
1604 eiter->a.max_frame_size = cpu_to_be32(eiter->a.max_frame_size);
1607 ql_dbg(ql_dbg_disc, vha, 0x203c,
1608 "Max_Frame_Size=%x.\n", eiter->a.max_frame_size);
1610 /* OS device name. */
1611 eiter = entries + size;
1612 eiter->type = cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
1613 snprintf(eiter->a.os_dev_name, sizeof(eiter->a.os_dev_name),
1614 "%s:host%lu", QLA2XXX_DRIVER_NAME, vha->host_no);
1615 alen = strlen(eiter->a.os_dev_name);
1616 alen += 4 - (alen & 3);
1617 eiter->len = cpu_to_be16(4 + alen);
1620 ql_dbg(ql_dbg_disc, vha, 0x204b,
1621 "OS_Device_Name=%s.\n", eiter->a.os_dev_name);
1624 eiter = entries + size;
1625 eiter->type = cpu_to_be16(FDMI_PORT_HOST_NAME);
1626 p_sysid = utsname();
1628 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
1629 "%s", p_sysid->nodename);
1631 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
1632 "%s", fc_host_system_hostname(vha->host));
1634 alen = strlen(eiter->a.host_name);
1635 alen += 4 - (alen & 3);
1636 eiter->len = cpu_to_be16(4 + alen);
1639 ql_dbg(ql_dbg_disc, vha, 0x203d, "HostName=%s.\n", eiter->a.host_name);
1641 /* Update MS request size. */
1642 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
1644 ql_dbg(ql_dbg_disc, vha, 0x203e,
1645 "RPA portname %016llx, size = %d.\n",
1646 wwn_to_u64(ct_req->req.rpa.port_name), size);
1647 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2079,
1650 /* Execute MS IOCB */
1651 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1652 sizeof(ms_iocb_entry_t));
1653 if (rval != QLA_SUCCESS) {
1655 ql_dbg(ql_dbg_disc, vha, 0x2040,
1656 "RPA issue IOCB failed (%d).\n", rval);
1657 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") !=
1659 rval = QLA_FUNCTION_FAILED;
1660 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
1661 ct_rsp->header.explanation_code ==
1662 CT_EXPL_ALREADY_REGISTERED) {
1663 ql_dbg(ql_dbg_disc, vha, 0x20cd,
1664 "RPA already registered.\n");
1665 rval = QLA_ALREADY_REGISTERED;
1669 ql_dbg(ql_dbg_disc, vha, 0x2041,
1670 "RPA exiting normally.\n");
1677 * qla2x00_fdmiv2_rhba() -
1680 * Returns 0 on success.
1683 qla2x00_fdmiv2_rhba(scsi_qla_host_t *vha)
1687 ms_iocb_entry_t *ms_pkt;
1688 struct ct_sns_req *ct_req;
1689 struct ct_sns_rsp *ct_rsp;
1691 struct ct_fdmiv2_hba_attr *eiter;
1692 struct qla_hw_data *ha = vha->hw;
1693 struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb;
1694 struct new_utsname *p_sysid = NULL;
1697 /* Prepare common MS IOCB */
1698 /* Request size adjusted after CT preparation */
1699 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE);
1701 /* Prepare CT request */
1702 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RHBA_CMD,
1704 ct_rsp = &ha->ct_sns->p.rsp;
1706 /* Prepare FDMI command arguments -- attribute block, attributes. */
1707 memcpy(ct_req->req.rhba2.hba_identifier, vha->port_name, WWN_SIZE);
1708 ct_req->req.rhba2.entry_count = cpu_to_be32(1);
1709 memcpy(ct_req->req.rhba2.port_name, vha->port_name, WWN_SIZE);
1710 size = 2 * WWN_SIZE + 4 + 4;
1713 ct_req->req.rhba2.attrs.count = cpu_to_be32(FDMIV2_HBA_ATTR_COUNT);
1714 entries = ct_req->req.rhba2.hba_identifier;
1717 eiter = entries + size;
1718 eiter->type = cpu_to_be16(FDMI_HBA_NODE_NAME);
1719 eiter->len = cpu_to_be16(4 + WWN_SIZE);
1720 memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE);
1721 size += 4 + WWN_SIZE;
1723 ql_dbg(ql_dbg_disc, vha, 0x207d,
1724 "NodeName = %016llx.\n", wwn_to_u64(eiter->a.node_name));
1727 eiter = entries + size;
1728 eiter->type = cpu_to_be16(FDMI_HBA_MANUFACTURER);
1729 snprintf(eiter->a.manufacturer, sizeof(eiter->a.manufacturer),
1730 "%s", "QLogic Corporation");
1731 eiter->a.manufacturer[strlen("QLogic Corporation")] = '\0';
1732 alen = strlen(eiter->a.manufacturer);
1733 alen += 4 - (alen & 3);
1734 eiter->len = cpu_to_be16(4 + alen);
1737 ql_dbg(ql_dbg_disc, vha, 0x20a5,
1738 "Manufacturer = %s.\n", eiter->a.manufacturer);
1740 /* Serial number. */
1741 eiter = entries + size;
1742 eiter->type = cpu_to_be16(FDMI_HBA_SERIAL_NUMBER);
1743 if (IS_FWI2_CAPABLE(ha))
1744 qla2xxx_get_vpd_field(vha, "SN", eiter->a.serial_num,
1745 sizeof(eiter->a.serial_num));
1747 sn = ((ha->serial0 & 0x1f) << 16) |
1748 (ha->serial2 << 8) | ha->serial1;
1749 snprintf(eiter->a.serial_num, sizeof(eiter->a.serial_num),
1750 "%c%05d", 'A' + sn / 100000, sn % 100000);
1752 alen = strlen(eiter->a.serial_num);
1753 alen += 4 - (alen & 3);
1754 eiter->len = cpu_to_be16(4 + alen);
1757 ql_dbg(ql_dbg_disc, vha, 0x20a6,
1758 "Serial no. = %s.\n", eiter->a.serial_num);
1761 eiter = entries + size;
1762 eiter->type = cpu_to_be16(FDMI_HBA_MODEL);
1763 snprintf(eiter->a.model, sizeof(eiter->a.model),
1764 "%s", ha->model_number);
1765 alen = strlen(eiter->a.model);
1766 alen += 4 - (alen & 3);
1767 eiter->len = cpu_to_be16(4 + alen);
1770 ql_dbg(ql_dbg_disc, vha, 0x20a7,
1771 "Model Name = %s.\n", eiter->a.model);
1773 /* Model description. */
1774 eiter = entries + size;
1775 eiter->type = cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
1776 snprintf(eiter->a.model_desc, sizeof(eiter->a.model_desc),
1777 "%s", ha->model_desc);
1778 alen = strlen(eiter->a.model_desc);
1779 alen += 4 - (alen & 3);
1780 eiter->len = cpu_to_be16(4 + alen);
1783 ql_dbg(ql_dbg_disc, vha, 0x20a8,
1784 "Model Desc = %s.\n", eiter->a.model_desc);
1786 /* Hardware version. */
1787 eiter = entries + size;
1788 eiter->type = cpu_to_be16(FDMI_HBA_HARDWARE_VERSION);
1789 if (!IS_FWI2_CAPABLE(ha)) {
1790 snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version),
1791 "HW:%s", ha->adapter_id);
1792 } else if (qla2xxx_get_vpd_field(vha, "MN", eiter->a.hw_version,
1793 sizeof(eiter->a.hw_version))) {
1795 } else if (qla2xxx_get_vpd_field(vha, "EC", eiter->a.hw_version,
1796 sizeof(eiter->a.hw_version))) {
1799 snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version),
1800 "HW:%s", ha->adapter_id);
1802 alen = strlen(eiter->a.hw_version);
1803 alen += 4 - (alen & 3);
1804 eiter->len = cpu_to_be16(4 + alen);
1807 ql_dbg(ql_dbg_disc, vha, 0x20a9,
1808 "Hardware ver = %s.\n", eiter->a.hw_version);
1810 /* Driver version. */
1811 eiter = entries + size;
1812 eiter->type = cpu_to_be16(FDMI_HBA_DRIVER_VERSION);
1813 snprintf(eiter->a.driver_version, sizeof(eiter->a.driver_version),
1814 "%s", qla2x00_version_str);
1815 alen = strlen(eiter->a.driver_version);
1816 alen += 4 - (alen & 3);
1817 eiter->len = cpu_to_be16(4 + alen);
1820 ql_dbg(ql_dbg_disc, vha, 0x20aa,
1821 "Driver ver = %s.\n", eiter->a.driver_version);
1823 /* Option ROM version. */
1824 eiter = entries + size;
1825 eiter->type = cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION);
1826 snprintf(eiter->a.orom_version, sizeof(eiter->a.orom_version),
1827 "%d.%02d", ha->bios_revision[1], ha->bios_revision[0]);
1828 alen = strlen(eiter->a.orom_version);
1829 alen += 4 - (alen & 3);
1830 eiter->len = cpu_to_be16(4 + alen);
1833 ql_dbg(ql_dbg_disc, vha , 0x20ab,
1834 "Optrom version = %d.%02d.\n", eiter->a.orom_version[1],
1835 eiter->a.orom_version[0]);
1837 /* Firmware version */
1838 eiter = entries + size;
1839 eiter->type = cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
1840 ha->isp_ops->fw_version_str(vha, eiter->a.fw_version,
1841 sizeof(eiter->a.fw_version));
1842 alen = strlen(eiter->a.fw_version);
1843 alen += 4 - (alen & 3);
1844 eiter->len = cpu_to_be16(4 + alen);
1847 ql_dbg(ql_dbg_disc, vha, 0x20ac,
1848 "Firmware vers = %s.\n", eiter->a.fw_version);
1850 /* OS Name and Version */
1851 eiter = entries + size;
1852 eiter->type = cpu_to_be16(FDMI_HBA_OS_NAME_AND_VERSION);
1853 p_sysid = utsname();
1855 snprintf(eiter->a.os_version, sizeof(eiter->a.os_version),
1857 p_sysid->sysname, p_sysid->release, p_sysid->version);
1859 snprintf(eiter->a.os_version, sizeof(eiter->a.os_version),
1860 "%s %s", "Linux", fc_host_system_hostname(vha->host));
1862 alen = strlen(eiter->a.os_version);
1863 alen += 4 - (alen & 3);
1864 eiter->len = cpu_to_be16(4 + alen);
1867 ql_dbg(ql_dbg_disc, vha, 0x20ae,
1868 "OS Name and Version = %s.\n", eiter->a.os_version);
1870 /* MAX CT Payload Length */
1871 eiter = entries + size;
1872 eiter->type = cpu_to_be16(FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH);
1873 eiter->a.max_ct_len = IS_FWI2_CAPABLE(ha) ?
1874 le16_to_cpu(icb24->frame_payload_size) :
1875 le16_to_cpu(ha->init_cb->frame_payload_size);
1876 eiter->a.max_ct_len = cpu_to_be32(eiter->a.max_ct_len);
1877 eiter->len = cpu_to_be16(4 + 4);
1880 ql_dbg(ql_dbg_disc, vha, 0x20af,
1881 "CT Payload Length = 0x%x.\n", eiter->a.max_ct_len);
1883 /* Node Sybolic Name */
1884 eiter = entries + size;
1885 eiter->type = cpu_to_be16(FDMI_HBA_NODE_SYMBOLIC_NAME);
1886 qla2x00_get_sym_node_name(vha, eiter->a.sym_name,
1887 sizeof(eiter->a.sym_name));
1888 alen = strlen(eiter->a.sym_name);
1889 alen += 4 - (alen & 3);
1890 eiter->len = cpu_to_be16(4 + alen);
1893 ql_dbg(ql_dbg_disc, vha, 0x20b0,
1894 "Symbolic Name = %s.\n", eiter->a.sym_name);
1897 eiter = entries + size;
1898 eiter->type = cpu_to_be16(FDMI_HBA_VENDOR_ID);
1899 eiter->a.vendor_id = cpu_to_be32(0x1077);
1900 eiter->len = cpu_to_be16(4 + 4);
1903 ql_dbg(ql_dbg_disc, vha, 0x20b1,
1904 "Vendor Id = %x.\n", eiter->a.vendor_id);
1907 eiter = entries + size;
1908 eiter->type = cpu_to_be16(FDMI_HBA_NUM_PORTS);
1909 eiter->a.num_ports = cpu_to_be32(1);
1910 eiter->len = cpu_to_be16(4 + 4);
1913 ql_dbg(ql_dbg_disc, vha, 0x20b2,
1914 "Port Num = %x.\n", eiter->a.num_ports);
1917 eiter = entries + size;
1918 eiter->type = cpu_to_be16(FDMI_HBA_FABRIC_NAME);
1919 memcpy(eiter->a.fabric_name, vha->fabric_node_name, WWN_SIZE);
1920 eiter->len = cpu_to_be16(4 + WWN_SIZE);
1921 size += 4 + WWN_SIZE;
1923 ql_dbg(ql_dbg_disc, vha, 0x20b3,
1924 "Fabric Name = %016llx.\n", wwn_to_u64(eiter->a.fabric_name));
1927 eiter = entries + size;
1928 eiter->type = cpu_to_be16(FDMI_HBA_BOOT_BIOS_NAME);
1929 snprintf(eiter->a.bios_name, sizeof(eiter->a.bios_name),
1930 "BIOS %d.%02d", ha->bios_revision[1], ha->bios_revision[0]);
1931 alen = strlen(eiter->a.bios_name);
1932 alen += 4 - (alen & 3);
1933 eiter->len = cpu_to_be16(4 + alen);
1936 ql_dbg(ql_dbg_disc, vha, 0x20b4,
1937 "BIOS Name = %s\n", eiter->a.bios_name);
1939 /* Vendor Identifier */
1940 eiter = entries + size;
1941 eiter->type = cpu_to_be16(FDMI_HBA_TYPE_VENDOR_IDENTIFIER);
1942 snprintf(eiter->a.vendor_indentifer, sizeof(eiter->a.vendor_indentifer),
1944 alen = strlen(eiter->a.vendor_indentifer);
1945 alen += 4 - (alen & 3);
1946 eiter->len = cpu_to_be16(4 + alen);
1949 ql_dbg(ql_dbg_disc, vha, 0x20b1,
1950 "Vendor Identifier = %s.\n", eiter->a.vendor_indentifer);
1952 /* Update MS request size. */
1953 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
1955 ql_dbg(ql_dbg_disc, vha, 0x20b5,
1956 "RHBA identifier = %016llx.\n",
1957 wwn_to_u64(ct_req->req.rhba2.hba_identifier));
1958 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x20b6,
1961 /* Execute MS IOCB */
1962 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
1963 sizeof(ms_iocb_entry_t));
1964 if (rval != QLA_SUCCESS) {
1966 ql_dbg(ql_dbg_disc, vha, 0x20b7,
1967 "RHBA issue IOCB failed (%d).\n", rval);
1968 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") !=
1970 rval = QLA_FUNCTION_FAILED;
1972 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
1973 ct_rsp->header.explanation_code ==
1974 CT_EXPL_ALREADY_REGISTERED) {
1975 ql_dbg(ql_dbg_disc, vha, 0x20b8,
1976 "HBA already registered.\n");
1977 rval = QLA_ALREADY_REGISTERED;
1979 ql_dbg(ql_dbg_disc, vha, 0x2016,
1980 "RHBA FDMI v2 failed, CT Reason code: 0x%x, CT Explanation 0x%x\n",
1981 ct_rsp->header.reason_code,
1982 ct_rsp->header.explanation_code);
1985 ql_dbg(ql_dbg_disc, vha, 0x20b9,
1986 "RHBA FDMI V2 exiting normally.\n");
1993 * qla2x00_fdmi_dhba() -
1996 * Returns 0 on success.
1999 qla2x00_fdmi_dhba(scsi_qla_host_t *vha)
2002 struct qla_hw_data *ha = vha->hw;
2003 ms_iocb_entry_t *ms_pkt;
2004 struct ct_sns_req *ct_req;
2005 struct ct_sns_rsp *ct_rsp;
2008 /* Prepare common MS IOCB */
2009 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, DHBA_REQ_SIZE,
2012 /* Prepare CT request */
2013 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, DHBA_CMD, DHBA_RSP_SIZE);
2014 ct_rsp = &ha->ct_sns->p.rsp;
2016 /* Prepare FDMI command arguments -- portname. */
2017 memcpy(ct_req->req.dhba.port_name, vha->port_name, WWN_SIZE);
2019 ql_dbg(ql_dbg_disc, vha, 0x2036,
2020 "DHBA portname = %8phN.\n", ct_req->req.dhba.port_name);
2022 /* Execute MS IOCB */
2023 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
2024 sizeof(ms_iocb_entry_t));
2025 if (rval != QLA_SUCCESS) {
2027 ql_dbg(ql_dbg_disc, vha, 0x2037,
2028 "DHBA issue IOCB failed (%d).\n", rval);
2029 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "DHBA") !=
2031 rval = QLA_FUNCTION_FAILED;
2033 ql_dbg(ql_dbg_disc, vha, 0x2038,
2034 "DHBA exiting normally.\n");
2041 * qla2x00_fdmiv2_rpa() -
2044 * Returns 0 on success.
2047 qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha)
2051 struct qla_hw_data *ha = vha->hw;
2052 ms_iocb_entry_t *ms_pkt;
2053 struct ct_sns_req *ct_req;
2054 struct ct_sns_rsp *ct_rsp;
2056 struct ct_fdmiv2_port_attr *eiter;
2057 struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb;
2058 struct new_utsname *p_sysid = NULL;
2061 /* Prepare common MS IOCB */
2062 /* Request size adjusted after CT preparation */
2063 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE);
2065 /* Prepare CT request */
2066 ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RPA_CMD, RPA_RSP_SIZE);
2067 ct_rsp = &ha->ct_sns->p.rsp;
2069 /* Prepare FDMI command arguments -- attribute block, attributes. */
2070 memcpy(ct_req->req.rpa2.port_name, vha->port_name, WWN_SIZE);
2071 size = WWN_SIZE + 4;
2074 ct_req->req.rpa2.attrs.count = cpu_to_be32(FDMIV2_PORT_ATTR_COUNT);
2075 entries = ct_req->req.rpa2.port_name;
2078 eiter = entries + size;
2079 eiter->type = cpu_to_be16(FDMI_PORT_FC4_TYPES);
2080 eiter->len = cpu_to_be16(4 + 32);
2081 eiter->a.fc4_types[2] = 0x01;
2084 ql_dbg(ql_dbg_disc, vha, 0x20ba,
2085 "FC4_TYPES=%02x %02x.\n",
2086 eiter->a.fc4_types[2],
2087 eiter->a.fc4_types[1]);
2089 /* Supported speed. */
2090 eiter = entries + size;
2091 eiter->type = cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
2092 eiter->len = cpu_to_be16(4 + 4);
2093 if (IS_CNA_CAPABLE(ha))
2094 eiter->a.sup_speed = cpu_to_be32(
2095 FDMI_PORT_SPEED_10GB);
2096 else if (IS_QLA27XX(ha))
2097 eiter->a.sup_speed = cpu_to_be32(
2098 FDMI_PORT_SPEED_32GB|
2099 FDMI_PORT_SPEED_16GB|
2100 FDMI_PORT_SPEED_8GB);
2101 else if (IS_QLA2031(ha))
2102 eiter->a.sup_speed = cpu_to_be32(
2103 FDMI_PORT_SPEED_16GB|
2104 FDMI_PORT_SPEED_8GB|
2105 FDMI_PORT_SPEED_4GB);
2106 else if (IS_QLA25XX(ha))
2107 eiter->a.sup_speed = cpu_to_be32(
2108 FDMI_PORT_SPEED_8GB|
2109 FDMI_PORT_SPEED_4GB|
2110 FDMI_PORT_SPEED_2GB|
2111 FDMI_PORT_SPEED_1GB);
2112 else if (IS_QLA24XX_TYPE(ha))
2113 eiter->a.sup_speed = cpu_to_be32(
2114 FDMI_PORT_SPEED_4GB|
2115 FDMI_PORT_SPEED_2GB|
2116 FDMI_PORT_SPEED_1GB);
2117 else if (IS_QLA23XX(ha))
2118 eiter->a.sup_speed = cpu_to_be32(
2119 FDMI_PORT_SPEED_2GB|
2120 FDMI_PORT_SPEED_1GB);
2122 eiter->a.sup_speed = cpu_to_be32(
2123 FDMI_PORT_SPEED_1GB);
2126 ql_dbg(ql_dbg_disc, vha, 0x20bb,
2127 "Supported Port Speed = %x.\n", eiter->a.sup_speed);
2129 /* Current speed. */
2130 eiter = entries + size;
2131 eiter->type = cpu_to_be16(FDMI_PORT_CURRENT_SPEED);
2132 eiter->len = cpu_to_be16(4 + 4);
2133 switch (ha->link_data_rate) {
2134 case PORT_SPEED_1GB:
2135 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_1GB);
2137 case PORT_SPEED_2GB:
2138 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_2GB);
2140 case PORT_SPEED_4GB:
2141 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_4GB);
2143 case PORT_SPEED_8GB:
2144 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_8GB);
2146 case PORT_SPEED_10GB:
2147 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_10GB);
2149 case PORT_SPEED_16GB:
2150 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_16GB);
2152 case PORT_SPEED_32GB:
2153 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_32GB);
2156 eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN);
2161 ql_dbg(ql_dbg_disc, vha, 0x20bc,
2162 "Current_Speed = %x.\n", eiter->a.cur_speed);
2164 /* Max frame size. */
2165 eiter = entries + size;
2166 eiter->type = cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
2167 eiter->len = cpu_to_be16(4 + 4);
2168 eiter->a.max_frame_size = IS_FWI2_CAPABLE(ha) ?
2169 le16_to_cpu(icb24->frame_payload_size):
2170 le16_to_cpu(ha->init_cb->frame_payload_size);
2171 eiter->a.max_frame_size = cpu_to_be32(eiter->a.max_frame_size);
2174 ql_dbg(ql_dbg_disc, vha, 0x20bc,
2175 "Max_Frame_Size = %x.\n", eiter->a.max_frame_size);
2177 /* OS device name. */
2178 eiter = entries + size;
2179 eiter->type = cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
2180 alen = strlen(QLA2XXX_DRIVER_NAME);
2181 snprintf(eiter->a.os_dev_name, sizeof(eiter->a.os_dev_name),
2182 "%s:host%lu", QLA2XXX_DRIVER_NAME, vha->host_no);
2183 alen += 4 - (alen & 3);
2184 eiter->len = cpu_to_be16(4 + alen);
2187 ql_dbg(ql_dbg_disc, vha, 0x20be,
2188 "OS_Device_Name = %s.\n", eiter->a.os_dev_name);
2191 eiter = entries + size;
2192 eiter->type = cpu_to_be16(FDMI_PORT_HOST_NAME);
2193 p_sysid = utsname();
2195 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
2196 "%s", p_sysid->nodename);
2198 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
2199 "%s", fc_host_system_hostname(vha->host));
2201 alen = strlen(eiter->a.host_name);
2202 alen += 4 - (alen & 3);
2203 eiter->len = cpu_to_be16(4 + alen);
2206 ql_dbg(ql_dbg_disc, vha, 0x203d,
2207 "HostName=%s.\n", eiter->a.host_name);
2210 eiter = entries + size;
2211 eiter->type = cpu_to_be16(FDMI_PORT_NODE_NAME);
2212 memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE);
2213 eiter->len = cpu_to_be16(4 + WWN_SIZE);
2214 size += 4 + WWN_SIZE;
2216 ql_dbg(ql_dbg_disc, vha, 0x20c0,
2217 "Node Name = %016llx.\n", wwn_to_u64(eiter->a.node_name));
2220 eiter = entries + size;
2221 eiter->type = cpu_to_be16(FDMI_PORT_NAME);
2222 memcpy(eiter->a.port_name, vha->port_name, WWN_SIZE);
2223 eiter->len = cpu_to_be16(4 + WWN_SIZE);
2224 size += 4 + WWN_SIZE;
2226 ql_dbg(ql_dbg_disc, vha, 0x20c1,
2227 "Port Name = %016llx.\n", wwn_to_u64(eiter->a.port_name));
2229 /* Port Symbolic Name */
2230 eiter = entries + size;
2231 eiter->type = cpu_to_be16(FDMI_PORT_SYM_NAME);
2232 qla2x00_get_sym_node_name(vha, eiter->a.port_sym_name,
2233 sizeof(eiter->a.port_sym_name));
2234 alen = strlen(eiter->a.port_sym_name);
2235 alen += 4 - (alen & 3);
2236 eiter->len = cpu_to_be16(4 + alen);
2239 ql_dbg(ql_dbg_disc, vha, 0x20c2,
2240 "port symbolic name = %s\n", eiter->a.port_sym_name);
2243 eiter = entries + size;
2244 eiter->type = cpu_to_be16(FDMI_PORT_TYPE);
2245 eiter->a.port_type = cpu_to_be32(NS_NX_PORT_TYPE);
2246 eiter->len = cpu_to_be16(4 + 4);
2249 ql_dbg(ql_dbg_disc, vha, 0x20c3,
2250 "Port Type = %x.\n", eiter->a.port_type);
2252 /* Class of Service */
2253 eiter = entries + size;
2254 eiter->type = cpu_to_be16(FDMI_PORT_SUPP_COS);
2255 eiter->a.port_supported_cos = cpu_to_be32(FC_CLASS_3);
2256 eiter->len = cpu_to_be16(4 + 4);
2259 ql_dbg(ql_dbg_disc, vha, 0x20c4,
2260 "Supported COS = %08x\n", eiter->a.port_supported_cos);
2262 /* Port Fabric Name */
2263 eiter = entries + size;
2264 eiter->type = cpu_to_be16(FDMI_PORT_FABRIC_NAME);
2265 memcpy(eiter->a.fabric_name, vha->fabric_node_name, WWN_SIZE);
2266 eiter->len = cpu_to_be16(4 + WWN_SIZE);
2267 size += 4 + WWN_SIZE;
2269 ql_dbg(ql_dbg_disc, vha, 0x20c5,
2270 "Fabric Name = %016llx.\n", wwn_to_u64(eiter->a.fabric_name));
2273 eiter = entries + size;
2274 eiter->type = cpu_to_be16(FDMI_PORT_FC4_TYPE);
2275 eiter->a.port_fc4_type[0] = 0;
2276 eiter->a.port_fc4_type[1] = 0;
2277 eiter->a.port_fc4_type[2] = 1;
2278 eiter->a.port_fc4_type[3] = 0;
2279 eiter->len = cpu_to_be16(4 + 32);
2282 ql_dbg(ql_dbg_disc, vha, 0x20c6,
2283 "Port Active FC4 Type = %02x %02x.\n",
2284 eiter->a.port_fc4_type[2], eiter->a.port_fc4_type[1]);
2287 eiter = entries + size;
2288 eiter->type = cpu_to_be16(FDMI_PORT_STATE);
2289 eiter->a.port_state = cpu_to_be32(1);
2290 eiter->len = cpu_to_be16(4 + 4);
2293 ql_dbg(ql_dbg_disc, vha, 0x20c7,
2294 "Port State = %x.\n", eiter->a.port_state);
2296 /* Number of Ports */
2297 eiter = entries + size;
2298 eiter->type = cpu_to_be16(FDMI_PORT_COUNT);
2299 eiter->a.num_ports = cpu_to_be32(1);
2300 eiter->len = cpu_to_be16(4 + 4);
2303 ql_dbg(ql_dbg_disc, vha, 0x20c8,
2304 "Number of ports = %x.\n", eiter->a.num_ports);
2307 eiter = entries + size;
2308 eiter->type = cpu_to_be16(FDMI_PORT_ID);
2309 eiter->a.port_id = cpu_to_be32(vha->d_id.b24);
2310 eiter->len = cpu_to_be16(4 + 4);
2313 ql_dbg(ql_dbg_disc, vha, 0x20c8,
2314 "Port Id = %x.\n", eiter->a.port_id);
2316 /* Update MS request size. */
2317 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
2319 ql_dbg(ql_dbg_disc, vha, 0x203e,
2320 "RPA portname= %8phN size=%d.\n", ct_req->req.rpa.port_name, size);
2321 ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x20ca,
2324 /* Execute MS IOCB */
2325 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
2326 sizeof(ms_iocb_entry_t));
2327 if (rval != QLA_SUCCESS) {
2329 ql_dbg(ql_dbg_disc, vha, 0x20cb,
2330 "RPA FDMI v2 issue IOCB failed (%d).\n", rval);
2331 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") !=
2333 rval = QLA_FUNCTION_FAILED;
2334 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
2335 ct_rsp->header.explanation_code ==
2336 CT_EXPL_ALREADY_REGISTERED) {
2337 ql_dbg(ql_dbg_disc, vha, 0x20ce,
2338 "RPA FDMI v2 already registered\n");
2339 rval = QLA_ALREADY_REGISTERED;
2341 ql_dbg(ql_dbg_disc, vha, 0x2020,
2342 "RPA FDMI v2 failed, CT Reason code: 0x%x, CT Explanation 0x%x\n",
2343 ct_rsp->header.reason_code,
2344 ct_rsp->header.explanation_code);
2347 ql_dbg(ql_dbg_disc, vha, 0x20cc,
2348 "RPA FDMI V2 exiting normally.\n");
2355 * qla2x00_fdmi_register() -
2358 * Returns 0 on success.
2361 qla2x00_fdmi_register(scsi_qla_host_t *vha)
2363 int rval = QLA_FUNCTION_FAILED;
2364 struct qla_hw_data *ha = vha->hw;
2366 if (IS_QLA2100(ha) || IS_QLA2200(ha) ||
2368 return QLA_FUNCTION_FAILED;
2370 rval = qla2x00_mgmt_svr_login(vha);
2374 rval = qla2x00_fdmiv2_rhba(vha);
2376 if (rval != QLA_ALREADY_REGISTERED)
2379 rval = qla2x00_fdmi_dhba(vha);
2383 rval = qla2x00_fdmiv2_rhba(vha);
2387 rval = qla2x00_fdmiv2_rpa(vha);
2394 rval = qla2x00_fdmi_rhba(vha);
2396 if (rval != QLA_ALREADY_REGISTERED)
2399 rval = qla2x00_fdmi_dhba(vha);
2403 rval = qla2x00_fdmi_rhba(vha);
2407 rval = qla2x00_fdmi_rpa(vha);
2413 * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
2415 * @list: switch info entries to populate
2417 * Returns 0 on success.
2420 qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list)
2422 int rval = QLA_SUCCESS;
2424 struct qla_hw_data *ha = vha->hw;
2425 ms_iocb_entry_t *ms_pkt;
2426 struct ct_sns_req *ct_req;
2427 struct ct_sns_rsp *ct_rsp;
2429 if (!IS_IIDMA_CAPABLE(ha))
2430 return QLA_FUNCTION_FAILED;
2432 for (i = 0; i < ha->max_fibre_devices; i++) {
2434 /* Prepare common MS IOCB */
2435 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFPN_ID_REQ_SIZE,
2438 /* Prepare CT request */
2439 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFPN_ID_CMD,
2441 ct_rsp = &ha->ct_sns->p.rsp;
2443 /* Prepare CT arguments -- port_id */
2444 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
2445 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
2446 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
2448 /* Execute MS IOCB */
2449 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
2450 sizeof(ms_iocb_entry_t));
2451 if (rval != QLA_SUCCESS) {
2453 ql_dbg(ql_dbg_disc, vha, 0x2023,
2454 "GFPN_ID issue IOCB failed (%d).\n", rval);
2456 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
2457 "GFPN_ID") != QLA_SUCCESS) {
2458 rval = QLA_FUNCTION_FAILED;
2461 /* Save fabric portname */
2462 memcpy(list[i].fabric_port_name,
2463 ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE);
2466 /* Last device exit. */
2467 if (list[i].d_id.b.rsvd_1 != 0)
2474 static inline void *
2475 qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size,
2478 struct ct_entry_24xx *ct_pkt;
2479 struct qla_hw_data *ha = vha->hw;
2480 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
2481 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
2483 ct_pkt->entry_type = CT_IOCB_TYPE;
2484 ct_pkt->entry_count = 1;
2485 ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
2486 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
2487 ct_pkt->cmd_dsd_count = cpu_to_le16(1);
2488 ct_pkt->rsp_dsd_count = cpu_to_le16(1);
2489 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
2490 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
2492 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
2493 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
2494 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
2496 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
2497 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
2498 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
2499 ct_pkt->vp_index = vha->vp_idx;
2505 static inline struct ct_sns_req *
2506 qla24xx_prep_ct_fm_req(struct ct_sns_pkt *p, uint16_t cmd,
2509 memset(p, 0, sizeof(struct ct_sns_pkt));
2511 p->p.req.header.revision = 0x01;
2512 p->p.req.header.gs_type = 0xFA;
2513 p->p.req.header.gs_subtype = 0x01;
2514 p->p.req.command = cpu_to_be16(cmd);
2515 p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
2521 * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
2523 * @list: switch info entries to populate
2525 * Returns 0 on success.
2528 qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list)
2532 struct qla_hw_data *ha = vha->hw;
2533 ms_iocb_entry_t *ms_pkt;
2534 struct ct_sns_req *ct_req;
2535 struct ct_sns_rsp *ct_rsp;
2537 if (!IS_IIDMA_CAPABLE(ha))
2538 return QLA_FUNCTION_FAILED;
2539 if (!ha->flags.gpsc_supported)
2540 return QLA_FUNCTION_FAILED;
2542 rval = qla2x00_mgmt_svr_login(vha);
2546 for (i = 0; i < ha->max_fibre_devices; i++) {
2548 /* Prepare common MS IOCB */
2549 ms_pkt = qla24xx_prep_ms_fm_iocb(vha, GPSC_REQ_SIZE,
2552 /* Prepare CT request */
2553 ct_req = qla24xx_prep_ct_fm_req(ha->ct_sns, GPSC_CMD,
2555 ct_rsp = &ha->ct_sns->p.rsp;
2557 /* Prepare CT arguments -- port_name */
2558 memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name,
2561 /* Execute MS IOCB */
2562 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
2563 sizeof(ms_iocb_entry_t));
2564 if (rval != QLA_SUCCESS) {
2566 ql_dbg(ql_dbg_disc, vha, 0x2059,
2567 "GPSC issue IOCB failed (%d).\n", rval);
2568 } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
2569 "GPSC")) != QLA_SUCCESS) {
2570 /* FM command unsupported? */
2571 if (rval == QLA_INVALID_COMMAND &&
2572 (ct_rsp->header.reason_code ==
2573 CT_REASON_INVALID_COMMAND_CODE ||
2574 ct_rsp->header.reason_code ==
2575 CT_REASON_COMMAND_UNSUPPORTED)) {
2576 ql_dbg(ql_dbg_disc, vha, 0x205a,
2577 "GPSC command unsupported, disabling "
2579 ha->flags.gpsc_supported = 0;
2580 rval = QLA_FUNCTION_FAILED;
2583 rval = QLA_FUNCTION_FAILED;
2585 /* Save port-speed */
2586 switch (be16_to_cpu(ct_rsp->rsp.gpsc.speed)) {
2588 list[i].fp_speed = PORT_SPEED_1GB;
2591 list[i].fp_speed = PORT_SPEED_2GB;
2594 list[i].fp_speed = PORT_SPEED_4GB;
2597 list[i].fp_speed = PORT_SPEED_10GB;
2600 list[i].fp_speed = PORT_SPEED_8GB;
2603 list[i].fp_speed = PORT_SPEED_16GB;
2606 list[i].fp_speed = PORT_SPEED_32GB;
2610 ql_dbg(ql_dbg_disc, vha, 0x205b,
2611 "GPSC ext entry - fpn "
2612 "%8phN speeds=%04x speed=%04x.\n",
2613 list[i].fabric_port_name,
2614 be16_to_cpu(ct_rsp->rsp.gpsc.speeds),
2615 be16_to_cpu(ct_rsp->rsp.gpsc.speed));
2618 /* Last device exit. */
2619 if (list[i].d_id.b.rsvd_1 != 0)
2627 * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query.
2630 * @list: switch info entries to populate
2634 qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list)
2639 ms_iocb_entry_t *ms_pkt;
2640 struct ct_sns_req *ct_req;
2641 struct ct_sns_rsp *ct_rsp;
2642 struct qla_hw_data *ha = vha->hw;
2643 uint8_t fcp_scsi_features = 0;
2645 for (i = 0; i < ha->max_fibre_devices; i++) {
2646 /* Set default FC4 Type as UNKNOWN so the default is to
2647 * Process this port */
2648 list[i].fc4_type = FC4_TYPE_UNKNOWN;
2650 /* Do not attempt GFF_ID if we are not FWI_2 capable */
2651 if (!IS_FWI2_CAPABLE(ha))
2654 /* Prepare common MS IOCB */
2655 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFF_ID_REQ_SIZE,
2658 /* Prepare CT request */
2659 ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFF_ID_CMD,
2661 ct_rsp = &ha->ct_sns->p.rsp;
2663 /* Prepare CT arguments -- port_id */
2664 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
2665 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
2666 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
2668 /* Execute MS IOCB */
2669 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
2670 sizeof(ms_iocb_entry_t));
2672 if (rval != QLA_SUCCESS) {
2673 ql_dbg(ql_dbg_disc, vha, 0x205c,
2674 "GFF_ID issue IOCB failed (%d).\n", rval);
2675 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
2676 "GFF_ID") != QLA_SUCCESS) {
2677 ql_dbg(ql_dbg_disc, vha, 0x205d,
2678 "GFF_ID IOCB status had a failure status code.\n");
2681 ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
2682 fcp_scsi_features &= 0x0f;
2684 if (fcp_scsi_features)
2685 list[i].fc4_type = FC4_TYPE_FCP_SCSI;
2687 list[i].fc4_type = FC4_TYPE_OTHER;
2690 /* Last device exit. */
2691 if (list[i].d_id.b.rsvd_1 != 0)