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
, struct ct_arg
*arg
)
29 struct qla_hw_data
*ha
= vha
->hw
;
30 ms_iocb_entry_t
*ms_pkt
;
32 ms_pkt
= (ms_iocb_entry_t
*)arg
->iocb
;
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(arg
->rsp_size
);
43 ms_pkt
->req_bytecount
= cpu_to_le32(arg
->req_size
);
45 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(arg
->req_dma
));
46 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(arg
->req_dma
));
47 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
49 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(arg
->rsp_dma
));
50 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(arg
->rsp_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
, struct ct_arg
*arg
)
69 struct qla_hw_data
*ha
= vha
->hw
;
70 struct ct_entry_24xx
*ct_pkt
;
72 ct_pkt
= (struct ct_entry_24xx
*)arg
->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(arg
->nport_handle
);
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(arg
->rsp_size
);
82 ct_pkt
->cmd_byte_count
= cpu_to_le32(arg
->req_size
);
84 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(arg
->req_dma
));
85 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(arg
->req_dma
));
86 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
88 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(arg
->rsp_dma
));
89 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(arg
->rsp_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
;
188 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
189 return qla2x00_sns_ga_nxt(vha
, fcport
);
191 arg
.iocb
= ha
->ms_iocb
;
192 arg
.req_dma
= ha
->ct_sns_dma
;
193 arg
.rsp_dma
= ha
->ct_sns_dma
;
194 arg
.req_size
= GA_NXT_REQ_SIZE
;
195 arg
.rsp_size
= GA_NXT_RSP_SIZE
;
196 arg
.nport_handle
= NPH_SNS
;
199 /* Prepare common MS IOCB */
200 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
202 /* Prepare CT request */
203 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GA_NXT_CMD
,
205 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
207 /* Prepare CT arguments -- port_id */
208 ct_req
->req
.port_id
.port_id
[0] = fcport
->d_id
.b
.domain
;
209 ct_req
->req
.port_id
.port_id
[1] = fcport
->d_id
.b
.area
;
210 ct_req
->req
.port_id
.port_id
[2] = fcport
->d_id
.b
.al_pa
;
212 /* Execute MS IOCB */
213 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
214 sizeof(ms_iocb_entry_t
));
215 if (rval
!= QLA_SUCCESS
) {
217 ql_dbg(ql_dbg_disc
, vha
, 0x2062,
218 "GA_NXT issue IOCB failed (%d).\n", rval
);
219 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "GA_NXT") !=
221 rval
= QLA_FUNCTION_FAILED
;
223 /* Populate fc_port_t entry. */
224 fcport
->d_id
.b
.domain
= ct_rsp
->rsp
.ga_nxt
.port_id
[0];
225 fcport
->d_id
.b
.area
= ct_rsp
->rsp
.ga_nxt
.port_id
[1];
226 fcport
->d_id
.b
.al_pa
= ct_rsp
->rsp
.ga_nxt
.port_id
[2];
228 memcpy(fcport
->node_name
, ct_rsp
->rsp
.ga_nxt
.node_name
,
230 memcpy(fcport
->port_name
, ct_rsp
->rsp
.ga_nxt
.port_name
,
233 fcport
->fc4_type
= (ct_rsp
->rsp
.ga_nxt
.fc4_types
[2] & BIT_0
) ?
234 FC4_TYPE_FCP_SCSI
: FC4_TYPE_OTHER
;
236 if (ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_N_PORT_TYPE
&&
237 ct_rsp
->rsp
.ga_nxt
.port_type
!= NS_NL_PORT_TYPE
)
238 fcport
->d_id
.b
.domain
= 0xf0;
240 ql_dbg(ql_dbg_disc
, vha
, 0x2063,
241 "GA_NXT entry - nn %8phN pn %8phN "
242 "port_id=%02x%02x%02x.\n",
243 fcport
->node_name
, fcport
->port_name
,
244 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
245 fcport
->d_id
.b
.al_pa
);
252 qla2x00_gid_pt_rsp_size(scsi_qla_host_t
*vha
)
254 return vha
->hw
->max_fibre_devices
* 4 + 16;
258 * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
260 * @list: switch info entries to populate
262 * NOTE: Non-Nx_Ports are not requested.
264 * Returns 0 on success.
267 qla2x00_gid_pt(scsi_qla_host_t
*vha
, sw_info_t
*list
)
272 ms_iocb_entry_t
*ms_pkt
;
273 struct ct_sns_req
*ct_req
;
274 struct ct_sns_rsp
*ct_rsp
;
276 struct ct_sns_gid_pt_data
*gid_data
;
277 struct qla_hw_data
*ha
= vha
->hw
;
278 uint16_t gid_pt_rsp_size
;
281 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
282 return qla2x00_sns_gid_pt(vha
, list
);
285 gid_pt_rsp_size
= qla2x00_gid_pt_rsp_size(vha
);
287 arg
.iocb
= ha
->ms_iocb
;
288 arg
.req_dma
= ha
->ct_sns_dma
;
289 arg
.rsp_dma
= ha
->ct_sns_dma
;
290 arg
.req_size
= GID_PT_REQ_SIZE
;
291 arg
.rsp_size
= gid_pt_rsp_size
;
292 arg
.nport_handle
= NPH_SNS
;
295 /* Prepare common MS IOCB */
296 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
298 /* Prepare CT request */
299 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GID_PT_CMD
, gid_pt_rsp_size
);
300 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
302 /* Prepare CT arguments -- port_type */
303 ct_req
->req
.gid_pt
.port_type
= NS_NX_PORT_TYPE
;
305 /* Execute MS IOCB */
306 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
307 sizeof(ms_iocb_entry_t
));
308 if (rval
!= QLA_SUCCESS
) {
310 ql_dbg(ql_dbg_disc
, vha
, 0x2055,
311 "GID_PT issue IOCB failed (%d).\n", rval
);
312 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "GID_PT") !=
314 rval
= QLA_FUNCTION_FAILED
;
316 /* Set port IDs in switch info list. */
317 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
318 gid_data
= &ct_rsp
->rsp
.gid_pt
.entries
[i
];
319 list
[i
].d_id
.b
.domain
= gid_data
->port_id
[0];
320 list
[i
].d_id
.b
.area
= gid_data
->port_id
[1];
321 list
[i
].d_id
.b
.al_pa
= gid_data
->port_id
[2];
322 memset(list
[i
].fabric_port_name
, 0, WWN_SIZE
);
323 list
[i
].fp_speed
= PORT_SPEED_UNKNOWN
;
326 if (gid_data
->control_byte
& BIT_7
) {
327 list
[i
].d_id
.b
.rsvd_1
= gid_data
->control_byte
;
333 * If we've used all available slots, then the switch is
334 * reporting back more devices than we can handle with this
335 * single call. Return a failed status, and let GA_NXT handle
338 if (i
== ha
->max_fibre_devices
)
339 rval
= QLA_FUNCTION_FAILED
;
346 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
348 * @list: switch info entries to populate
350 * Returns 0 on success.
353 qla2x00_gpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
355 int rval
= QLA_SUCCESS
;
358 ms_iocb_entry_t
*ms_pkt
;
359 struct ct_sns_req
*ct_req
;
360 struct ct_sns_rsp
*ct_rsp
;
361 struct qla_hw_data
*ha
= vha
->hw
;
364 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
365 return qla2x00_sns_gpn_id(vha
, list
);
367 arg
.iocb
= ha
->ms_iocb
;
368 arg
.req_dma
= ha
->ct_sns_dma
;
369 arg
.rsp_dma
= ha
->ct_sns_dma
;
370 arg
.req_size
= GPN_ID_REQ_SIZE
;
371 arg
.rsp_size
= GPN_ID_RSP_SIZE
;
372 arg
.nport_handle
= NPH_SNS
;
374 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
376 /* Prepare common MS IOCB */
377 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
379 /* Prepare CT request */
380 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GPN_ID_CMD
,
382 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
384 /* Prepare CT arguments -- port_id */
385 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
386 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
387 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
389 /* Execute MS IOCB */
390 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
391 sizeof(ms_iocb_entry_t
));
392 if (rval
!= QLA_SUCCESS
) {
394 ql_dbg(ql_dbg_disc
, vha
, 0x2056,
395 "GPN_ID issue IOCB failed (%d).\n", rval
);
397 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
398 "GPN_ID") != QLA_SUCCESS
) {
399 rval
= QLA_FUNCTION_FAILED
;
403 memcpy(list
[i
].port_name
,
404 ct_rsp
->rsp
.gpn_id
.port_name
, WWN_SIZE
);
407 /* Last device exit. */
408 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
416 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
418 * @list: switch info entries to populate
420 * Returns 0 on success.
423 qla2x00_gnn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
425 int rval
= QLA_SUCCESS
;
427 struct qla_hw_data
*ha
= vha
->hw
;
428 ms_iocb_entry_t
*ms_pkt
;
429 struct ct_sns_req
*ct_req
;
430 struct ct_sns_rsp
*ct_rsp
;
433 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
434 return qla2x00_sns_gnn_id(vha
, list
);
436 arg
.iocb
= ha
->ms_iocb
;
437 arg
.req_dma
= ha
->ct_sns_dma
;
438 arg
.rsp_dma
= ha
->ct_sns_dma
;
439 arg
.req_size
= GNN_ID_REQ_SIZE
;
440 arg
.rsp_size
= GNN_ID_RSP_SIZE
;
441 arg
.nport_handle
= NPH_SNS
;
443 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
445 /* Prepare common MS IOCB */
446 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
448 /* Prepare CT request */
449 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GNN_ID_CMD
,
451 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
453 /* Prepare CT arguments -- port_id */
454 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
455 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
456 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
458 /* Execute MS IOCB */
459 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
460 sizeof(ms_iocb_entry_t
));
461 if (rval
!= QLA_SUCCESS
) {
463 ql_dbg(ql_dbg_disc
, vha
, 0x2057,
464 "GNN_ID issue IOCB failed (%d).\n", rval
);
466 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
467 "GNN_ID") != QLA_SUCCESS
) {
468 rval
= QLA_FUNCTION_FAILED
;
472 memcpy(list
[i
].node_name
,
473 ct_rsp
->rsp
.gnn_id
.node_name
, WWN_SIZE
);
475 ql_dbg(ql_dbg_disc
, vha
, 0x2058,
476 "GID_PT entry - nn %8phN pn %8phN "
477 "portid=%02x%02x%02x.\n",
478 list
[i
].node_name
, list
[i
].port_name
,
479 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
480 list
[i
].d_id
.b
.al_pa
);
483 /* Last device exit. */
484 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
492 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
495 * Returns 0 on success.
498 qla2x00_rft_id(scsi_qla_host_t
*vha
)
501 struct qla_hw_data
*ha
= vha
->hw
;
502 ms_iocb_entry_t
*ms_pkt
;
503 struct ct_sns_req
*ct_req
;
504 struct ct_sns_rsp
*ct_rsp
;
507 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
508 return qla2x00_sns_rft_id(vha
);
510 arg
.iocb
= ha
->ms_iocb
;
511 arg
.req_dma
= ha
->ct_sns_dma
;
512 arg
.rsp_dma
= ha
->ct_sns_dma
;
513 arg
.req_size
= RFT_ID_REQ_SIZE
;
514 arg
.rsp_size
= RFT_ID_RSP_SIZE
;
515 arg
.nport_handle
= NPH_SNS
;
518 /* Prepare common MS IOCB */
519 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
521 /* Prepare CT request */
522 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RFT_ID_CMD
,
524 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
526 /* Prepare CT arguments -- port_id, FC-4 types */
527 ct_req
->req
.rft_id
.port_id
[0] = vha
->d_id
.b
.domain
;
528 ct_req
->req
.rft_id
.port_id
[1] = vha
->d_id
.b
.area
;
529 ct_req
->req
.rft_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
531 ct_req
->req
.rft_id
.fc4_types
[2] = 0x01; /* FCP-3 */
533 /* Execute MS IOCB */
534 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
535 sizeof(ms_iocb_entry_t
));
536 if (rval
!= QLA_SUCCESS
) {
538 ql_dbg(ql_dbg_disc
, vha
, 0x2043,
539 "RFT_ID issue IOCB failed (%d).\n", rval
);
540 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RFT_ID") !=
542 rval
= QLA_FUNCTION_FAILED
;
544 ql_dbg(ql_dbg_disc
, vha
, 0x2044,
545 "RFT_ID exiting normally.\n");
552 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
555 * Returns 0 on success.
558 qla2x00_rff_id(scsi_qla_host_t
*vha
)
561 struct qla_hw_data
*ha
= vha
->hw
;
562 ms_iocb_entry_t
*ms_pkt
;
563 struct ct_sns_req
*ct_req
;
564 struct ct_sns_rsp
*ct_rsp
;
567 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
568 ql_dbg(ql_dbg_disc
, vha
, 0x2046,
569 "RFF_ID call not supported on ISP2100/ISP2200.\n");
570 return (QLA_SUCCESS
);
573 arg
.iocb
= ha
->ms_iocb
;
574 arg
.req_dma
= ha
->ct_sns_dma
;
575 arg
.rsp_dma
= ha
->ct_sns_dma
;
576 arg
.req_size
= RFF_ID_REQ_SIZE
;
577 arg
.rsp_size
= RFF_ID_RSP_SIZE
;
578 arg
.nport_handle
= NPH_SNS
;
581 /* Prepare common MS IOCB */
582 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
584 /* Prepare CT request */
585 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RFF_ID_CMD
,
587 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
589 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
590 ct_req
->req
.rff_id
.port_id
[0] = vha
->d_id
.b
.domain
;
591 ct_req
->req
.rff_id
.port_id
[1] = vha
->d_id
.b
.area
;
592 ct_req
->req
.rff_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
594 qlt_rff_id(vha
, ct_req
);
596 ct_req
->req
.rff_id
.fc4_type
= 0x08; /* SCSI - FCP */
598 /* Execute MS IOCB */
599 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
600 sizeof(ms_iocb_entry_t
));
601 if (rval
!= QLA_SUCCESS
) {
603 ql_dbg(ql_dbg_disc
, vha
, 0x2047,
604 "RFF_ID issue IOCB failed (%d).\n", rval
);
605 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RFF_ID") !=
607 rval
= QLA_FUNCTION_FAILED
;
609 ql_dbg(ql_dbg_disc
, vha
, 0x2048,
610 "RFF_ID exiting normally.\n");
617 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
620 * Returns 0 on success.
623 qla2x00_rnn_id(scsi_qla_host_t
*vha
)
626 struct qla_hw_data
*ha
= vha
->hw
;
627 ms_iocb_entry_t
*ms_pkt
;
628 struct ct_sns_req
*ct_req
;
629 struct ct_sns_rsp
*ct_rsp
;
632 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
633 return qla2x00_sns_rnn_id(vha
);
635 arg
.iocb
= ha
->ms_iocb
;
636 arg
.req_dma
= ha
->ct_sns_dma
;
637 arg
.rsp_dma
= ha
->ct_sns_dma
;
638 arg
.req_size
= RNN_ID_REQ_SIZE
;
639 arg
.rsp_size
= RNN_ID_RSP_SIZE
;
640 arg
.nport_handle
= NPH_SNS
;
643 /* Prepare common MS IOCB */
644 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
646 /* Prepare CT request */
647 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RNN_ID_CMD
, RNN_ID_RSP_SIZE
);
648 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
650 /* Prepare CT arguments -- port_id, node_name */
651 ct_req
->req
.rnn_id
.port_id
[0] = vha
->d_id
.b
.domain
;
652 ct_req
->req
.rnn_id
.port_id
[1] = vha
->d_id
.b
.area
;
653 ct_req
->req
.rnn_id
.port_id
[2] = vha
->d_id
.b
.al_pa
;
655 memcpy(ct_req
->req
.rnn_id
.node_name
, vha
->node_name
, WWN_SIZE
);
657 /* Execute MS IOCB */
658 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
659 sizeof(ms_iocb_entry_t
));
660 if (rval
!= QLA_SUCCESS
) {
662 ql_dbg(ql_dbg_disc
, vha
, 0x204d,
663 "RNN_ID issue IOCB failed (%d).\n", rval
);
664 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RNN_ID") !=
666 rval
= QLA_FUNCTION_FAILED
;
668 ql_dbg(ql_dbg_disc
, vha
, 0x204e,
669 "RNN_ID exiting normally.\n");
676 qla2x00_get_sym_node_name(scsi_qla_host_t
*vha
, uint8_t *snn
, size_t size
)
678 struct qla_hw_data
*ha
= vha
->hw
;
681 snprintf(snn
, size
, "%s FW:v%s DVR:v%s", ha
->model_number
,
682 ha
->mr
.fw_version
, qla2x00_version_str
);
685 "%s FW:v%d.%02d.%02d DVR:v%s", ha
->model_number
,
686 ha
->fw_major_version
, ha
->fw_minor_version
,
687 ha
->fw_subminor_version
, qla2x00_version_str
);
691 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
694 * Returns 0 on success.
697 qla2x00_rsnn_nn(scsi_qla_host_t
*vha
)
700 struct qla_hw_data
*ha
= vha
->hw
;
701 ms_iocb_entry_t
*ms_pkt
;
702 struct ct_sns_req
*ct_req
;
703 struct ct_sns_rsp
*ct_rsp
;
706 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
707 ql_dbg(ql_dbg_disc
, vha
, 0x2050,
708 "RSNN_ID call unsupported on ISP2100/ISP2200.\n");
709 return (QLA_SUCCESS
);
712 arg
.iocb
= ha
->ms_iocb
;
713 arg
.req_dma
= ha
->ct_sns_dma
;
714 arg
.rsp_dma
= ha
->ct_sns_dma
;
716 arg
.rsp_size
= RSNN_NN_RSP_SIZE
;
717 arg
.nport_handle
= NPH_SNS
;
720 /* Prepare common MS IOCB */
721 /* Request size adjusted after CT preparation */
722 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
724 /* Prepare CT request */
725 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, RSNN_NN_CMD
,
727 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
729 /* Prepare CT arguments -- node_name, symbolic node_name, size */
730 memcpy(ct_req
->req
.rsnn_nn
.node_name
, vha
->node_name
, WWN_SIZE
);
732 /* Prepare the Symbolic Node Name */
733 qla2x00_get_sym_node_name(vha
, ct_req
->req
.rsnn_nn
.sym_node_name
,
734 sizeof(ct_req
->req
.rsnn_nn
.sym_node_name
));
736 /* Calculate SNN length */
737 ct_req
->req
.rsnn_nn
.name_len
=
738 (uint8_t)strlen(ct_req
->req
.rsnn_nn
.sym_node_name
);
740 /* Update MS IOCB request */
741 ms_pkt
->req_bytecount
=
742 cpu_to_le32(24 + 1 + ct_req
->req
.rsnn_nn
.name_len
);
743 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
745 /* Execute MS IOCB */
746 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
747 sizeof(ms_iocb_entry_t
));
748 if (rval
!= QLA_SUCCESS
) {
750 ql_dbg(ql_dbg_disc
, vha
, 0x2051,
751 "RSNN_NN issue IOCB failed (%d).\n", rval
);
752 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RSNN_NN") !=
754 rval
= QLA_FUNCTION_FAILED
;
756 ql_dbg(ql_dbg_disc
, vha
, 0x2052,
757 "RSNN_NN exiting normally.\n");
764 * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
767 * @scmd_len: Subcommand length
768 * @data_size: response size in bytes
770 * Returns a pointer to the @ha's sns_cmd.
772 static inline struct sns_cmd_pkt
*
773 qla2x00_prep_sns_cmd(scsi_qla_host_t
*vha
, uint16_t cmd
, uint16_t scmd_len
,
777 struct sns_cmd_pkt
*sns_cmd
;
778 struct qla_hw_data
*ha
= vha
->hw
;
780 sns_cmd
= ha
->sns_cmd
;
781 memset(sns_cmd
, 0, sizeof(struct sns_cmd_pkt
));
782 wc
= data_size
/ 2; /* Size in 16bit words. */
783 sns_cmd
->p
.cmd
.buffer_length
= cpu_to_le16(wc
);
784 sns_cmd
->p
.cmd
.buffer_address
[0] = cpu_to_le32(LSD(ha
->sns_cmd_dma
));
785 sns_cmd
->p
.cmd
.buffer_address
[1] = cpu_to_le32(MSD(ha
->sns_cmd_dma
));
786 sns_cmd
->p
.cmd
.subcommand_length
= cpu_to_le16(scmd_len
);
787 sns_cmd
->p
.cmd
.subcommand
= cpu_to_le16(cmd
);
788 wc
= (data_size
- 16) / 4; /* Size in 32bit words. */
789 sns_cmd
->p
.cmd
.size
= cpu_to_le16(wc
);
791 vha
->qla_stats
.control_requests
++;
797 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
799 * @fcport: fcport entry to updated
801 * This command uses the old Exectute SNS Command mailbox routine.
803 * Returns 0 on success.
806 qla2x00_sns_ga_nxt(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
808 int rval
= QLA_SUCCESS
;
809 struct qla_hw_data
*ha
= vha
->hw
;
810 struct sns_cmd_pkt
*sns_cmd
;
813 /* Prepare SNS command request. */
814 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GA_NXT_CMD
, GA_NXT_SNS_SCMD_LEN
,
815 GA_NXT_SNS_DATA_SIZE
);
817 /* Prepare SNS command arguments -- port_id. */
818 sns_cmd
->p
.cmd
.param
[0] = fcport
->d_id
.b
.al_pa
;
819 sns_cmd
->p
.cmd
.param
[1] = fcport
->d_id
.b
.area
;
820 sns_cmd
->p
.cmd
.param
[2] = fcport
->d_id
.b
.domain
;
822 /* Execute SNS command. */
823 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, GA_NXT_SNS_CMD_SIZE
/ 2,
824 sizeof(struct sns_cmd_pkt
));
825 if (rval
!= QLA_SUCCESS
) {
827 ql_dbg(ql_dbg_disc
, vha
, 0x205f,
828 "GA_NXT Send SNS failed (%d).\n", rval
);
829 } else if (sns_cmd
->p
.gan_data
[8] != 0x80 ||
830 sns_cmd
->p
.gan_data
[9] != 0x02) {
831 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2084,
832 "GA_NXT failed, rejected request ga_nxt_rsp:\n");
833 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2074,
834 sns_cmd
->p
.gan_data
, 16);
835 rval
= QLA_FUNCTION_FAILED
;
837 /* Populate fc_port_t entry. */
838 fcport
->d_id
.b
.domain
= sns_cmd
->p
.gan_data
[17];
839 fcport
->d_id
.b
.area
= sns_cmd
->p
.gan_data
[18];
840 fcport
->d_id
.b
.al_pa
= sns_cmd
->p
.gan_data
[19];
842 memcpy(fcport
->node_name
, &sns_cmd
->p
.gan_data
[284], WWN_SIZE
);
843 memcpy(fcport
->port_name
, &sns_cmd
->p
.gan_data
[20], WWN_SIZE
);
845 if (sns_cmd
->p
.gan_data
[16] != NS_N_PORT_TYPE
&&
846 sns_cmd
->p
.gan_data
[16] != NS_NL_PORT_TYPE
)
847 fcport
->d_id
.b
.domain
= 0xf0;
849 ql_dbg(ql_dbg_disc
, vha
, 0x2061,
850 "GA_NXT entry - nn %8phN pn %8phN "
851 "port_id=%02x%02x%02x.\n",
852 fcport
->node_name
, fcport
->port_name
,
853 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
854 fcport
->d_id
.b
.al_pa
);
861 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
863 * @list: switch info entries to populate
865 * This command uses the old Exectute SNS Command mailbox routine.
867 * NOTE: Non-Nx_Ports are not requested.
869 * Returns 0 on success.
872 qla2x00_sns_gid_pt(scsi_qla_host_t
*vha
, sw_info_t
*list
)
875 struct qla_hw_data
*ha
= vha
->hw
;
878 struct sns_cmd_pkt
*sns_cmd
;
879 uint16_t gid_pt_sns_data_size
;
881 gid_pt_sns_data_size
= qla2x00_gid_pt_rsp_size(vha
);
884 /* Prepare SNS command request. */
885 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GID_PT_CMD
, GID_PT_SNS_SCMD_LEN
,
886 gid_pt_sns_data_size
);
888 /* Prepare SNS command arguments -- port_type. */
889 sns_cmd
->p
.cmd
.param
[0] = NS_NX_PORT_TYPE
;
891 /* Execute SNS command. */
892 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, GID_PT_SNS_CMD_SIZE
/ 2,
893 sizeof(struct sns_cmd_pkt
));
894 if (rval
!= QLA_SUCCESS
) {
896 ql_dbg(ql_dbg_disc
, vha
, 0x206d,
897 "GID_PT Send SNS failed (%d).\n", rval
);
898 } else if (sns_cmd
->p
.gid_data
[8] != 0x80 ||
899 sns_cmd
->p
.gid_data
[9] != 0x02) {
900 ql_dbg(ql_dbg_disc
, vha
, 0x202f,
901 "GID_PT failed, rejected request, gid_rsp:\n");
902 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2081,
903 sns_cmd
->p
.gid_data
, 16);
904 rval
= QLA_FUNCTION_FAILED
;
906 /* Set port IDs in switch info list. */
907 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
908 entry
= &sns_cmd
->p
.gid_data
[(i
* 4) + 16];
909 list
[i
].d_id
.b
.domain
= entry
[1];
910 list
[i
].d_id
.b
.area
= entry
[2];
911 list
[i
].d_id
.b
.al_pa
= entry
[3];
914 if (entry
[0] & BIT_7
) {
915 list
[i
].d_id
.b
.rsvd_1
= entry
[0];
921 * If we've used all available slots, then the switch is
922 * reporting back more devices that we can handle with this
923 * single call. Return a failed status, and let GA_NXT handle
926 if (i
== ha
->max_fibre_devices
)
927 rval
= QLA_FUNCTION_FAILED
;
934 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
936 * @list: switch info entries to populate
938 * This command uses the old Exectute SNS Command mailbox routine.
940 * Returns 0 on success.
943 qla2x00_sns_gpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
945 int rval
= QLA_SUCCESS
;
946 struct qla_hw_data
*ha
= vha
->hw
;
948 struct sns_cmd_pkt
*sns_cmd
;
950 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
952 /* Prepare SNS command request. */
953 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GPN_ID_CMD
,
954 GPN_ID_SNS_SCMD_LEN
, GPN_ID_SNS_DATA_SIZE
);
956 /* Prepare SNS command arguments -- port_id. */
957 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
958 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
959 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
961 /* Execute SNS command. */
962 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
,
963 GPN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
964 if (rval
!= QLA_SUCCESS
) {
966 ql_dbg(ql_dbg_disc
, vha
, 0x2032,
967 "GPN_ID Send SNS failed (%d).\n", rval
);
968 } else if (sns_cmd
->p
.gpn_data
[8] != 0x80 ||
969 sns_cmd
->p
.gpn_data
[9] != 0x02) {
970 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207e,
971 "GPN_ID failed, rejected request, gpn_rsp:\n");
972 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207f,
973 sns_cmd
->p
.gpn_data
, 16);
974 rval
= QLA_FUNCTION_FAILED
;
977 memcpy(list
[i
].port_name
, &sns_cmd
->p
.gpn_data
[16],
981 /* Last device exit. */
982 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
990 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
992 * @list: switch info entries to populate
994 * This command uses the old Exectute SNS Command mailbox routine.
996 * Returns 0 on success.
999 qla2x00_sns_gnn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
1001 int rval
= QLA_SUCCESS
;
1002 struct qla_hw_data
*ha
= vha
->hw
;
1004 struct sns_cmd_pkt
*sns_cmd
;
1006 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
1008 /* Prepare SNS command request. */
1009 sns_cmd
= qla2x00_prep_sns_cmd(vha
, GNN_ID_CMD
,
1010 GNN_ID_SNS_SCMD_LEN
, GNN_ID_SNS_DATA_SIZE
);
1012 /* Prepare SNS command arguments -- port_id. */
1013 sns_cmd
->p
.cmd
.param
[0] = list
[i
].d_id
.b
.al_pa
;
1014 sns_cmd
->p
.cmd
.param
[1] = list
[i
].d_id
.b
.area
;
1015 sns_cmd
->p
.cmd
.param
[2] = list
[i
].d_id
.b
.domain
;
1017 /* Execute SNS command. */
1018 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
,
1019 GNN_ID_SNS_CMD_SIZE
/ 2, sizeof(struct sns_cmd_pkt
));
1020 if (rval
!= QLA_SUCCESS
) {
1022 ql_dbg(ql_dbg_disc
, vha
, 0x203f,
1023 "GNN_ID Send SNS failed (%d).\n", rval
);
1024 } else if (sns_cmd
->p
.gnn_data
[8] != 0x80 ||
1025 sns_cmd
->p
.gnn_data
[9] != 0x02) {
1026 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2082,
1027 "GNN_ID failed, rejected request, gnn_rsp:\n");
1028 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207a,
1029 sns_cmd
->p
.gnn_data
, 16);
1030 rval
= QLA_FUNCTION_FAILED
;
1033 memcpy(list
[i
].node_name
, &sns_cmd
->p
.gnn_data
[16],
1036 ql_dbg(ql_dbg_disc
, vha
, 0x206e,
1037 "GID_PT entry - nn %8phN pn %8phN "
1038 "port_id=%02x%02x%02x.\n",
1039 list
[i
].node_name
, list
[i
].port_name
,
1040 list
[i
].d_id
.b
.domain
, list
[i
].d_id
.b
.area
,
1041 list
[i
].d_id
.b
.al_pa
);
1044 /* Last device exit. */
1045 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
1053 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
1056 * This command uses the old Exectute SNS Command mailbox routine.
1058 * Returns 0 on success.
1061 qla2x00_sns_rft_id(scsi_qla_host_t
*vha
)
1064 struct qla_hw_data
*ha
= vha
->hw
;
1065 struct sns_cmd_pkt
*sns_cmd
;
1068 /* Prepare SNS command request. */
1069 sns_cmd
= qla2x00_prep_sns_cmd(vha
, RFT_ID_CMD
, RFT_ID_SNS_SCMD_LEN
,
1070 RFT_ID_SNS_DATA_SIZE
);
1072 /* Prepare SNS command arguments -- port_id, FC-4 types */
1073 sns_cmd
->p
.cmd
.param
[0] = vha
->d_id
.b
.al_pa
;
1074 sns_cmd
->p
.cmd
.param
[1] = vha
->d_id
.b
.area
;
1075 sns_cmd
->p
.cmd
.param
[2] = vha
->d_id
.b
.domain
;
1077 sns_cmd
->p
.cmd
.param
[5] = 0x01; /* FCP-3 */
1079 /* Execute SNS command. */
1080 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, RFT_ID_SNS_CMD_SIZE
/ 2,
1081 sizeof(struct sns_cmd_pkt
));
1082 if (rval
!= QLA_SUCCESS
) {
1084 ql_dbg(ql_dbg_disc
, vha
, 0x2060,
1085 "RFT_ID Send SNS failed (%d).\n", rval
);
1086 } else if (sns_cmd
->p
.rft_data
[8] != 0x80 ||
1087 sns_cmd
->p
.rft_data
[9] != 0x02) {
1088 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2083,
1089 "RFT_ID failed, rejected request rft_rsp:\n");
1090 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2080,
1091 sns_cmd
->p
.rft_data
, 16);
1092 rval
= QLA_FUNCTION_FAILED
;
1094 ql_dbg(ql_dbg_disc
, vha
, 0x2073,
1095 "RFT_ID exiting normally.\n");
1102 * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
1106 * This command uses the old Exectute SNS Command mailbox routine.
1108 * Returns 0 on success.
1111 qla2x00_sns_rnn_id(scsi_qla_host_t
*vha
)
1114 struct qla_hw_data
*ha
= vha
->hw
;
1115 struct sns_cmd_pkt
*sns_cmd
;
1118 /* Prepare SNS command request. */
1119 sns_cmd
= qla2x00_prep_sns_cmd(vha
, RNN_ID_CMD
, RNN_ID_SNS_SCMD_LEN
,
1120 RNN_ID_SNS_DATA_SIZE
);
1122 /* Prepare SNS command arguments -- port_id, nodename. */
1123 sns_cmd
->p
.cmd
.param
[0] = vha
->d_id
.b
.al_pa
;
1124 sns_cmd
->p
.cmd
.param
[1] = vha
->d_id
.b
.area
;
1125 sns_cmd
->p
.cmd
.param
[2] = vha
->d_id
.b
.domain
;
1127 sns_cmd
->p
.cmd
.param
[4] = vha
->node_name
[7];
1128 sns_cmd
->p
.cmd
.param
[5] = vha
->node_name
[6];
1129 sns_cmd
->p
.cmd
.param
[6] = vha
->node_name
[5];
1130 sns_cmd
->p
.cmd
.param
[7] = vha
->node_name
[4];
1131 sns_cmd
->p
.cmd
.param
[8] = vha
->node_name
[3];
1132 sns_cmd
->p
.cmd
.param
[9] = vha
->node_name
[2];
1133 sns_cmd
->p
.cmd
.param
[10] = vha
->node_name
[1];
1134 sns_cmd
->p
.cmd
.param
[11] = vha
->node_name
[0];
1136 /* Execute SNS command. */
1137 rval
= qla2x00_send_sns(vha
, ha
->sns_cmd_dma
, RNN_ID_SNS_CMD_SIZE
/ 2,
1138 sizeof(struct sns_cmd_pkt
));
1139 if (rval
!= QLA_SUCCESS
) {
1141 ql_dbg(ql_dbg_disc
, vha
, 0x204a,
1142 "RNN_ID Send SNS failed (%d).\n", rval
);
1143 } else if (sns_cmd
->p
.rnn_data
[8] != 0x80 ||
1144 sns_cmd
->p
.rnn_data
[9] != 0x02) {
1145 ql_dbg(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207b,
1146 "RNN_ID failed, rejected request, rnn_rsp:\n");
1147 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x207c,
1148 sns_cmd
->p
.rnn_data
, 16);
1149 rval
= QLA_FUNCTION_FAILED
;
1151 ql_dbg(ql_dbg_disc
, vha
, 0x204c,
1152 "RNN_ID exiting normally.\n");
1159 * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
1162 * Returns 0 on success.
1165 qla2x00_mgmt_svr_login(scsi_qla_host_t
*vha
)
1168 uint16_t mb
[MAILBOX_REGISTER_COUNT
];
1169 struct qla_hw_data
*ha
= vha
->hw
;
1171 if (vha
->flags
.management_server_logged_in
)
1174 rval
= ha
->isp_ops
->fabric_login(vha
, vha
->mgmt_svr_loop_id
, 0xff, 0xff,
1176 if (rval
!= QLA_SUCCESS
|| mb
[0] != MBS_COMMAND_COMPLETE
) {
1177 if (rval
== QLA_MEMORY_ALLOC_FAILED
)
1178 ql_dbg(ql_dbg_disc
, vha
, 0x2085,
1179 "Failed management_server login: loopid=%x "
1180 "rval=%d\n", vha
->mgmt_svr_loop_id
, rval
);
1182 ql_dbg(ql_dbg_disc
, vha
, 0x2024,
1183 "Failed management_server login: loopid=%x "
1184 "mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x.\n",
1185 vha
->mgmt_svr_loop_id
, mb
[0], mb
[1], mb
[2], mb
[6],
1187 ret
= QLA_FUNCTION_FAILED
;
1189 vha
->flags
.management_server_logged_in
= 1;
1195 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1197 * @req_size: request size in bytes
1198 * @rsp_size: response size in bytes
1200 * Returns a pointer to the @ha's ms_iocb.
1203 qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1206 ms_iocb_entry_t
*ms_pkt
;
1207 struct qla_hw_data
*ha
= vha
->hw
;
1208 ms_pkt
= ha
->ms_iocb
;
1209 memset(ms_pkt
, 0, sizeof(ms_iocb_entry_t
));
1211 ms_pkt
->entry_type
= MS_IOCB_TYPE
;
1212 ms_pkt
->entry_count
= 1;
1213 SET_TARGET_ID(ha
, ms_pkt
->loop_id
, vha
->mgmt_svr_loop_id
);
1214 ms_pkt
->control_flags
= cpu_to_le16(CF_READ
| CF_HEAD_TAG
);
1215 ms_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1216 ms_pkt
->cmd_dsd_count
= cpu_to_le16(1);
1217 ms_pkt
->total_dsd_count
= cpu_to_le16(2);
1218 ms_pkt
->rsp_bytecount
= cpu_to_le32(rsp_size
);
1219 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1221 ms_pkt
->dseg_req_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1222 ms_pkt
->dseg_req_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1223 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1225 ms_pkt
->dseg_rsp_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1226 ms_pkt
->dseg_rsp_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1227 ms_pkt
->dseg_rsp_length
= ms_pkt
->rsp_bytecount
;
1233 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1235 * @req_size: request size in bytes
1236 * @rsp_size: response size in bytes
1238 * Returns a pointer to the @ha's ms_iocb.
1241 qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
,
1244 struct ct_entry_24xx
*ct_pkt
;
1245 struct qla_hw_data
*ha
= vha
->hw
;
1247 ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1248 memset(ct_pkt
, 0, sizeof(struct ct_entry_24xx
));
1250 ct_pkt
->entry_type
= CT_IOCB_TYPE
;
1251 ct_pkt
->entry_count
= 1;
1252 ct_pkt
->nport_handle
= cpu_to_le16(vha
->mgmt_svr_loop_id
);
1253 ct_pkt
->timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
1254 ct_pkt
->cmd_dsd_count
= cpu_to_le16(1);
1255 ct_pkt
->rsp_dsd_count
= cpu_to_le16(1);
1256 ct_pkt
->rsp_byte_count
= cpu_to_le32(rsp_size
);
1257 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1259 ct_pkt
->dseg_0_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1260 ct_pkt
->dseg_0_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1261 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1263 ct_pkt
->dseg_1_address
[0] = cpu_to_le32(LSD(ha
->ct_sns_dma
));
1264 ct_pkt
->dseg_1_address
[1] = cpu_to_le32(MSD(ha
->ct_sns_dma
));
1265 ct_pkt
->dseg_1_len
= ct_pkt
->rsp_byte_count
;
1266 ct_pkt
->vp_index
= vha
->vp_idx
;
1271 static inline ms_iocb_entry_t
*
1272 qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t
*vha
, uint32_t req_size
)
1274 struct qla_hw_data
*ha
= vha
->hw
;
1275 ms_iocb_entry_t
*ms_pkt
= ha
->ms_iocb
;
1276 struct ct_entry_24xx
*ct_pkt
= (struct ct_entry_24xx
*)ha
->ms_iocb
;
1278 if (IS_FWI2_CAPABLE(ha
)) {
1279 ct_pkt
->cmd_byte_count
= cpu_to_le32(req_size
);
1280 ct_pkt
->dseg_0_len
= ct_pkt
->cmd_byte_count
;
1282 ms_pkt
->req_bytecount
= cpu_to_le32(req_size
);
1283 ms_pkt
->dseg_req_length
= ms_pkt
->req_bytecount
;
1290 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1291 * @ct_req: CT request buffer
1293 * @rsp_size: response size in bytes
1295 * Returns a pointer to the intitialized @ct_req.
1297 static inline struct ct_sns_req
*
1298 qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt
*p
, uint16_t cmd
,
1301 memset(p
, 0, sizeof(struct ct_sns_pkt
));
1303 p
->p
.req
.header
.revision
= 0x01;
1304 p
->p
.req
.header
.gs_type
= 0xFA;
1305 p
->p
.req
.header
.gs_subtype
= 0x10;
1306 p
->p
.req
.command
= cpu_to_be16(cmd
);
1307 p
->p
.req
.max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
1313 * qla2x00_fdmi_rhba() -
1316 * Returns 0 on success.
1319 qla2x00_fdmi_rhba(scsi_qla_host_t
*vha
)
1324 ms_iocb_entry_t
*ms_pkt
;
1325 struct ct_sns_req
*ct_req
;
1326 struct ct_sns_rsp
*ct_rsp
;
1328 struct ct_fdmi_hba_attr
*eiter
;
1329 struct qla_hw_data
*ha
= vha
->hw
;
1332 /* Prepare common MS IOCB */
1333 /* Request size adjusted after CT preparation */
1334 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 0, RHBA_RSP_SIZE
);
1336 /* Prepare CT request */
1337 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, RHBA_CMD
, RHBA_RSP_SIZE
);
1338 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1340 /* Prepare FDMI command arguments -- attribute block, attributes. */
1341 memcpy(ct_req
->req
.rhba
.hba_identifier
, vha
->port_name
, WWN_SIZE
);
1342 ct_req
->req
.rhba
.entry_count
= cpu_to_be32(1);
1343 memcpy(ct_req
->req
.rhba
.port_name
, vha
->port_name
, WWN_SIZE
);
1344 size
= 2 * WWN_SIZE
+ 4 + 4;
1347 ct_req
->req
.rhba
.attrs
.count
=
1348 cpu_to_be32(FDMI_HBA_ATTR_COUNT
);
1349 entries
= ct_req
->req
.rhba
.hba_identifier
;
1352 eiter
= entries
+ size
;
1353 eiter
->type
= cpu_to_be16(FDMI_HBA_NODE_NAME
);
1354 eiter
->len
= cpu_to_be16(4 + WWN_SIZE
);
1355 memcpy(eiter
->a
.node_name
, vha
->node_name
, WWN_SIZE
);
1356 size
+= 4 + WWN_SIZE
;
1358 ql_dbg(ql_dbg_disc
, vha
, 0x2025,
1359 "NodeName = %8phN.\n", eiter
->a
.node_name
);
1362 eiter
= entries
+ size
;
1363 eiter
->type
= cpu_to_be16(FDMI_HBA_MANUFACTURER
);
1364 alen
= strlen(QLA2XXX_MANUFACTURER
);
1365 snprintf(eiter
->a
.manufacturer
, sizeof(eiter
->a
.manufacturer
),
1366 "%s", "QLogic Corporation");
1367 alen
+= 4 - (alen
& 3);
1368 eiter
->len
= cpu_to_be16(4 + alen
);
1371 ql_dbg(ql_dbg_disc
, vha
, 0x2026,
1372 "Manufacturer = %s.\n", eiter
->a
.manufacturer
);
1374 /* Serial number. */
1375 eiter
= entries
+ size
;
1376 eiter
->type
= cpu_to_be16(FDMI_HBA_SERIAL_NUMBER
);
1377 if (IS_FWI2_CAPABLE(ha
))
1378 qla2xxx_get_vpd_field(vha
, "SN", eiter
->a
.serial_num
,
1379 sizeof(eiter
->a
.serial_num
));
1381 sn
= ((ha
->serial0
& 0x1f) << 16) |
1382 (ha
->serial2
<< 8) | ha
->serial1
;
1383 snprintf(eiter
->a
.serial_num
, sizeof(eiter
->a
.serial_num
),
1384 "%c%05d", 'A' + sn
/ 100000, sn
% 100000);
1386 alen
= strlen(eiter
->a
.serial_num
);
1387 alen
+= 4 - (alen
& 3);
1388 eiter
->len
= cpu_to_be16(4 + alen
);
1391 ql_dbg(ql_dbg_disc
, vha
, 0x2027,
1392 "Serial no. = %s.\n", eiter
->a
.serial_num
);
1395 eiter
= entries
+ size
;
1396 eiter
->type
= cpu_to_be16(FDMI_HBA_MODEL
);
1397 snprintf(eiter
->a
.model
, sizeof(eiter
->a
.model
),
1398 "%s", ha
->model_number
);
1399 alen
= strlen(eiter
->a
.model
);
1400 alen
+= 4 - (alen
& 3);
1401 eiter
->len
= cpu_to_be16(4 + alen
);
1404 ql_dbg(ql_dbg_disc
, vha
, 0x2028,
1405 "Model Name = %s.\n", eiter
->a
.model
);
1407 /* Model description. */
1408 eiter
= entries
+ size
;
1409 eiter
->type
= cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION
);
1410 snprintf(eiter
->a
.model_desc
, sizeof(eiter
->a
.model_desc
),
1411 "%s", ha
->model_desc
);
1412 alen
= strlen(eiter
->a
.model_desc
);
1413 alen
+= 4 - (alen
& 3);
1414 eiter
->len
= cpu_to_be16(4 + alen
);
1417 ql_dbg(ql_dbg_disc
, vha
, 0x2029,
1418 "Model Desc = %s.\n", eiter
->a
.model_desc
);
1420 /* Hardware version. */
1421 eiter
= entries
+ size
;
1422 eiter
->type
= cpu_to_be16(FDMI_HBA_HARDWARE_VERSION
);
1423 if (!IS_FWI2_CAPABLE(ha
)) {
1424 snprintf(eiter
->a
.hw_version
, sizeof(eiter
->a
.hw_version
),
1425 "HW:%s", ha
->adapter_id
);
1426 } else if (qla2xxx_get_vpd_field(vha
, "MN", eiter
->a
.hw_version
,
1427 sizeof(eiter
->a
.hw_version
))) {
1429 } else if (qla2xxx_get_vpd_field(vha
, "EC", eiter
->a
.hw_version
,
1430 sizeof(eiter
->a
.hw_version
))) {
1433 snprintf(eiter
->a
.hw_version
, sizeof(eiter
->a
.hw_version
),
1434 "HW:%s", ha
->adapter_id
);
1436 alen
= strlen(eiter
->a
.hw_version
);
1437 alen
+= 4 - (alen
& 3);
1438 eiter
->len
= cpu_to_be16(4 + alen
);
1441 ql_dbg(ql_dbg_disc
, vha
, 0x202a,
1442 "Hardware ver = %s.\n", eiter
->a
.hw_version
);
1444 /* Driver version. */
1445 eiter
= entries
+ size
;
1446 eiter
->type
= cpu_to_be16(FDMI_HBA_DRIVER_VERSION
);
1447 snprintf(eiter
->a
.driver_version
, sizeof(eiter
->a
.driver_version
),
1448 "%s", qla2x00_version_str
);
1449 alen
= strlen(eiter
->a
.driver_version
);
1450 alen
+= 4 - (alen
& 3);
1451 eiter
->len
= cpu_to_be16(4 + alen
);
1454 ql_dbg(ql_dbg_disc
, vha
, 0x202b,
1455 "Driver ver = %s.\n", eiter
->a
.driver_version
);
1457 /* Option ROM version. */
1458 eiter
= entries
+ size
;
1459 eiter
->type
= cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION
);
1460 snprintf(eiter
->a
.orom_version
, sizeof(eiter
->a
.orom_version
),
1461 "%d.%02d", ha
->bios_revision
[1], ha
->bios_revision
[0]);
1462 alen
= strlen(eiter
->a
.orom_version
);
1463 alen
+= 4 - (alen
& 3);
1464 eiter
->len
= cpu_to_be16(4 + alen
);
1467 ql_dbg(ql_dbg_disc
, vha
, 0x202c,
1468 "Optrom vers = %s.\n", eiter
->a
.orom_version
);
1470 /* Firmware version */
1471 eiter
= entries
+ size
;
1472 eiter
->type
= cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION
);
1473 ha
->isp_ops
->fw_version_str(vha
, eiter
->a
.fw_version
,
1474 sizeof(eiter
->a
.fw_version
));
1475 alen
= strlen(eiter
->a
.fw_version
);
1476 alen
+= 4 - (alen
& 3);
1477 eiter
->len
= cpu_to_be16(4 + alen
);
1480 ql_dbg(ql_dbg_disc
, vha
, 0x202d,
1481 "Firmware vers = %s.\n", eiter
->a
.fw_version
);
1483 /* Update MS request size. */
1484 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
1486 ql_dbg(ql_dbg_disc
, vha
, 0x202e,
1487 "RHBA identifier = %8phN size=%d.\n",
1488 ct_req
->req
.rhba
.hba_identifier
, size
);
1489 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2076,
1492 /* Execute MS IOCB */
1493 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1494 sizeof(ms_iocb_entry_t
));
1495 if (rval
!= QLA_SUCCESS
) {
1497 ql_dbg(ql_dbg_disc
, vha
, 0x2030,
1498 "RHBA issue IOCB failed (%d).\n", rval
);
1499 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RHBA") !=
1501 rval
= QLA_FUNCTION_FAILED
;
1502 if (ct_rsp
->header
.reason_code
== CT_REASON_CANNOT_PERFORM
&&
1503 ct_rsp
->header
.explanation_code
==
1504 CT_EXPL_ALREADY_REGISTERED
) {
1505 ql_dbg(ql_dbg_disc
, vha
, 0x2034,
1506 "HBA already registered.\n");
1507 rval
= QLA_ALREADY_REGISTERED
;
1509 ql_dbg(ql_dbg_disc
, vha
, 0x20ad,
1510 "RHBA FDMI registration failed, CT Reason code: 0x%x, CT Explanation 0x%x\n",
1511 ct_rsp
->header
.reason_code
,
1512 ct_rsp
->header
.explanation_code
);
1515 ql_dbg(ql_dbg_disc
, vha
, 0x2035,
1516 "RHBA exiting normally.\n");
1523 * qla2x00_fdmi_rpa() -
1526 * Returns 0 on success.
1529 qla2x00_fdmi_rpa(scsi_qla_host_t
*vha
)
1533 struct qla_hw_data
*ha
= vha
->hw
;
1534 ms_iocb_entry_t
*ms_pkt
;
1535 struct ct_sns_req
*ct_req
;
1536 struct ct_sns_rsp
*ct_rsp
;
1538 struct ct_fdmi_port_attr
*eiter
;
1539 struct init_cb_24xx
*icb24
= (struct init_cb_24xx
*)ha
->init_cb
;
1540 struct new_utsname
*p_sysid
= NULL
;
1543 /* Prepare common MS IOCB */
1544 /* Request size adjusted after CT preparation */
1545 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 0, RPA_RSP_SIZE
);
1547 /* Prepare CT request */
1548 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, RPA_CMD
,
1550 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1552 /* Prepare FDMI command arguments -- attribute block, attributes. */
1553 memcpy(ct_req
->req
.rpa
.port_name
, vha
->port_name
, WWN_SIZE
);
1554 size
= WWN_SIZE
+ 4;
1557 ct_req
->req
.rpa
.attrs
.count
= cpu_to_be32(FDMI_PORT_ATTR_COUNT
);
1558 entries
= ct_req
->req
.rpa
.port_name
;
1561 eiter
= entries
+ size
;
1562 eiter
->type
= cpu_to_be16(FDMI_PORT_FC4_TYPES
);
1563 eiter
->len
= cpu_to_be16(4 + 32);
1564 eiter
->a
.fc4_types
[2] = 0x01;
1567 ql_dbg(ql_dbg_disc
, vha
, 0x2039,
1568 "FC4_TYPES=%02x %02x.\n",
1569 eiter
->a
.fc4_types
[2],
1570 eiter
->a
.fc4_types
[1]);
1572 /* Supported speed. */
1573 eiter
= entries
+ size
;
1574 eiter
->type
= cpu_to_be16(FDMI_PORT_SUPPORT_SPEED
);
1575 eiter
->len
= cpu_to_be16(4 + 4);
1576 if (IS_CNA_CAPABLE(ha
))
1577 eiter
->a
.sup_speed
= cpu_to_be32(
1578 FDMI_PORT_SPEED_10GB
);
1579 else if (IS_QLA27XX(ha
))
1580 eiter
->a
.sup_speed
= cpu_to_be32(
1581 FDMI_PORT_SPEED_32GB
|
1582 FDMI_PORT_SPEED_16GB
|
1583 FDMI_PORT_SPEED_8GB
);
1584 else if (IS_QLA2031(ha
))
1585 eiter
->a
.sup_speed
= cpu_to_be32(
1586 FDMI_PORT_SPEED_16GB
|
1587 FDMI_PORT_SPEED_8GB
|
1588 FDMI_PORT_SPEED_4GB
);
1589 else if (IS_QLA25XX(ha
))
1590 eiter
->a
.sup_speed
= cpu_to_be32(
1591 FDMI_PORT_SPEED_8GB
|
1592 FDMI_PORT_SPEED_4GB
|
1593 FDMI_PORT_SPEED_2GB
|
1594 FDMI_PORT_SPEED_1GB
);
1595 else if (IS_QLA24XX_TYPE(ha
))
1596 eiter
->a
.sup_speed
= cpu_to_be32(
1597 FDMI_PORT_SPEED_4GB
|
1598 FDMI_PORT_SPEED_2GB
|
1599 FDMI_PORT_SPEED_1GB
);
1600 else if (IS_QLA23XX(ha
))
1601 eiter
->a
.sup_speed
= cpu_to_be32(
1602 FDMI_PORT_SPEED_2GB
|
1603 FDMI_PORT_SPEED_1GB
);
1605 eiter
->a
.sup_speed
= cpu_to_be32(
1606 FDMI_PORT_SPEED_1GB
);
1609 ql_dbg(ql_dbg_disc
, vha
, 0x203a,
1610 "Supported_Speed=%x.\n", eiter
->a
.sup_speed
);
1612 /* Current speed. */
1613 eiter
= entries
+ size
;
1614 eiter
->type
= cpu_to_be16(FDMI_PORT_CURRENT_SPEED
);
1615 eiter
->len
= cpu_to_be16(4 + 4);
1616 switch (ha
->link_data_rate
) {
1617 case PORT_SPEED_1GB
:
1618 eiter
->a
.cur_speed
=
1619 cpu_to_be32(FDMI_PORT_SPEED_1GB
);
1621 case PORT_SPEED_2GB
:
1622 eiter
->a
.cur_speed
=
1623 cpu_to_be32(FDMI_PORT_SPEED_2GB
);
1625 case PORT_SPEED_4GB
:
1626 eiter
->a
.cur_speed
=
1627 cpu_to_be32(FDMI_PORT_SPEED_4GB
);
1629 case PORT_SPEED_8GB
:
1630 eiter
->a
.cur_speed
=
1631 cpu_to_be32(FDMI_PORT_SPEED_8GB
);
1633 case PORT_SPEED_10GB
:
1634 eiter
->a
.cur_speed
=
1635 cpu_to_be32(FDMI_PORT_SPEED_10GB
);
1637 case PORT_SPEED_16GB
:
1638 eiter
->a
.cur_speed
=
1639 cpu_to_be32(FDMI_PORT_SPEED_16GB
);
1641 case PORT_SPEED_32GB
:
1642 eiter
->a
.cur_speed
=
1643 cpu_to_be32(FDMI_PORT_SPEED_32GB
);
1646 eiter
->a
.cur_speed
=
1647 cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN
);
1652 ql_dbg(ql_dbg_disc
, vha
, 0x203b,
1653 "Current_Speed=%x.\n", eiter
->a
.cur_speed
);
1655 /* Max frame size. */
1656 eiter
= entries
+ size
;
1657 eiter
->type
= cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE
);
1658 eiter
->len
= cpu_to_be16(4 + 4);
1659 eiter
->a
.max_frame_size
= IS_FWI2_CAPABLE(ha
) ?
1660 le16_to_cpu(icb24
->frame_payload_size
) :
1661 le16_to_cpu(ha
->init_cb
->frame_payload_size
);
1662 eiter
->a
.max_frame_size
= cpu_to_be32(eiter
->a
.max_frame_size
);
1665 ql_dbg(ql_dbg_disc
, vha
, 0x203c,
1666 "Max_Frame_Size=%x.\n", eiter
->a
.max_frame_size
);
1668 /* OS device name. */
1669 eiter
= entries
+ size
;
1670 eiter
->type
= cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME
);
1671 snprintf(eiter
->a
.os_dev_name
, sizeof(eiter
->a
.os_dev_name
),
1672 "%s:host%lu", QLA2XXX_DRIVER_NAME
, vha
->host_no
);
1673 alen
= strlen(eiter
->a
.os_dev_name
);
1674 alen
+= 4 - (alen
& 3);
1675 eiter
->len
= cpu_to_be16(4 + alen
);
1678 ql_dbg(ql_dbg_disc
, vha
, 0x204b,
1679 "OS_Device_Name=%s.\n", eiter
->a
.os_dev_name
);
1682 eiter
= entries
+ size
;
1683 eiter
->type
= cpu_to_be16(FDMI_PORT_HOST_NAME
);
1684 p_sysid
= utsname();
1686 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
1687 "%s", p_sysid
->nodename
);
1689 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
1690 "%s", fc_host_system_hostname(vha
->host
));
1692 alen
= strlen(eiter
->a
.host_name
);
1693 alen
+= 4 - (alen
& 3);
1694 eiter
->len
= cpu_to_be16(4 + alen
);
1697 ql_dbg(ql_dbg_disc
, vha
, 0x203d, "HostName=%s.\n", eiter
->a
.host_name
);
1699 /* Update MS request size. */
1700 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
1702 ql_dbg(ql_dbg_disc
, vha
, 0x203e,
1703 "RPA portname %016llx, size = %d.\n",
1704 wwn_to_u64(ct_req
->req
.rpa
.port_name
), size
);
1705 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x2079,
1708 /* Execute MS IOCB */
1709 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
1710 sizeof(ms_iocb_entry_t
));
1711 if (rval
!= QLA_SUCCESS
) {
1713 ql_dbg(ql_dbg_disc
, vha
, 0x2040,
1714 "RPA issue IOCB failed (%d).\n", rval
);
1715 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RPA") !=
1717 rval
= QLA_FUNCTION_FAILED
;
1718 if (ct_rsp
->header
.reason_code
== CT_REASON_CANNOT_PERFORM
&&
1719 ct_rsp
->header
.explanation_code
==
1720 CT_EXPL_ALREADY_REGISTERED
) {
1721 ql_dbg(ql_dbg_disc
, vha
, 0x20cd,
1722 "RPA already registered.\n");
1723 rval
= QLA_ALREADY_REGISTERED
;
1727 ql_dbg(ql_dbg_disc
, vha
, 0x2041,
1728 "RPA exiting normally.\n");
1735 * qla2x00_fdmiv2_rhba() -
1738 * Returns 0 on success.
1741 qla2x00_fdmiv2_rhba(scsi_qla_host_t
*vha
)
1745 ms_iocb_entry_t
*ms_pkt
;
1746 struct ct_sns_req
*ct_req
;
1747 struct ct_sns_rsp
*ct_rsp
;
1749 struct ct_fdmiv2_hba_attr
*eiter
;
1750 struct qla_hw_data
*ha
= vha
->hw
;
1751 struct init_cb_24xx
*icb24
= (struct init_cb_24xx
*)ha
->init_cb
;
1752 struct new_utsname
*p_sysid
= NULL
;
1755 /* Prepare common MS IOCB */
1756 /* Request size adjusted after CT preparation */
1757 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 0, RHBA_RSP_SIZE
);
1759 /* Prepare CT request */
1760 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, RHBA_CMD
,
1762 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
1764 /* Prepare FDMI command arguments -- attribute block, attributes. */
1765 memcpy(ct_req
->req
.rhba2
.hba_identifier
, vha
->port_name
, WWN_SIZE
);
1766 ct_req
->req
.rhba2
.entry_count
= cpu_to_be32(1);
1767 memcpy(ct_req
->req
.rhba2
.port_name
, vha
->port_name
, WWN_SIZE
);
1768 size
= 2 * WWN_SIZE
+ 4 + 4;
1771 ct_req
->req
.rhba2
.attrs
.count
= cpu_to_be32(FDMIV2_HBA_ATTR_COUNT
);
1772 entries
= ct_req
->req
.rhba2
.hba_identifier
;
1775 eiter
= entries
+ size
;
1776 eiter
->type
= cpu_to_be16(FDMI_HBA_NODE_NAME
);
1777 eiter
->len
= cpu_to_be16(4 + WWN_SIZE
);
1778 memcpy(eiter
->a
.node_name
, vha
->node_name
, WWN_SIZE
);
1779 size
+= 4 + WWN_SIZE
;
1781 ql_dbg(ql_dbg_disc
, vha
, 0x207d,
1782 "NodeName = %016llx.\n", wwn_to_u64(eiter
->a
.node_name
));
1785 eiter
= entries
+ size
;
1786 eiter
->type
= cpu_to_be16(FDMI_HBA_MANUFACTURER
);
1787 snprintf(eiter
->a
.manufacturer
, sizeof(eiter
->a
.manufacturer
),
1788 "%s", "QLogic Corporation");
1789 eiter
->a
.manufacturer
[strlen("QLogic Corporation")] = '\0';
1790 alen
= strlen(eiter
->a
.manufacturer
);
1791 alen
+= 4 - (alen
& 3);
1792 eiter
->len
= cpu_to_be16(4 + alen
);
1795 ql_dbg(ql_dbg_disc
, vha
, 0x20a5,
1796 "Manufacturer = %s.\n", eiter
->a
.manufacturer
);
1798 /* Serial number. */
1799 eiter
= entries
+ size
;
1800 eiter
->type
= cpu_to_be16(FDMI_HBA_SERIAL_NUMBER
);
1801 if (IS_FWI2_CAPABLE(ha
))
1802 qla2xxx_get_vpd_field(vha
, "SN", eiter
->a
.serial_num
,
1803 sizeof(eiter
->a
.serial_num
));
1805 sn
= ((ha
->serial0
& 0x1f) << 16) |
1806 (ha
->serial2
<< 8) | ha
->serial1
;
1807 snprintf(eiter
->a
.serial_num
, sizeof(eiter
->a
.serial_num
),
1808 "%c%05d", 'A' + sn
/ 100000, sn
% 100000);
1810 alen
= strlen(eiter
->a
.serial_num
);
1811 alen
+= 4 - (alen
& 3);
1812 eiter
->len
= cpu_to_be16(4 + alen
);
1815 ql_dbg(ql_dbg_disc
, vha
, 0x20a6,
1816 "Serial no. = %s.\n", eiter
->a
.serial_num
);
1819 eiter
= entries
+ size
;
1820 eiter
->type
= cpu_to_be16(FDMI_HBA_MODEL
);
1821 snprintf(eiter
->a
.model
, sizeof(eiter
->a
.model
),
1822 "%s", ha
->model_number
);
1823 alen
= strlen(eiter
->a
.model
);
1824 alen
+= 4 - (alen
& 3);
1825 eiter
->len
= cpu_to_be16(4 + alen
);
1828 ql_dbg(ql_dbg_disc
, vha
, 0x20a7,
1829 "Model Name = %s.\n", eiter
->a
.model
);
1831 /* Model description. */
1832 eiter
= entries
+ size
;
1833 eiter
->type
= cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION
);
1834 snprintf(eiter
->a
.model_desc
, sizeof(eiter
->a
.model_desc
),
1835 "%s", ha
->model_desc
);
1836 alen
= strlen(eiter
->a
.model_desc
);
1837 alen
+= 4 - (alen
& 3);
1838 eiter
->len
= cpu_to_be16(4 + alen
);
1841 ql_dbg(ql_dbg_disc
, vha
, 0x20a8,
1842 "Model Desc = %s.\n", eiter
->a
.model_desc
);
1844 /* Hardware version. */
1845 eiter
= entries
+ size
;
1846 eiter
->type
= cpu_to_be16(FDMI_HBA_HARDWARE_VERSION
);
1847 if (!IS_FWI2_CAPABLE(ha
)) {
1848 snprintf(eiter
->a
.hw_version
, sizeof(eiter
->a
.hw_version
),
1849 "HW:%s", ha
->adapter_id
);
1850 } else if (qla2xxx_get_vpd_field(vha
, "MN", eiter
->a
.hw_version
,
1851 sizeof(eiter
->a
.hw_version
))) {
1853 } else if (qla2xxx_get_vpd_field(vha
, "EC", eiter
->a
.hw_version
,
1854 sizeof(eiter
->a
.hw_version
))) {
1857 snprintf(eiter
->a
.hw_version
, sizeof(eiter
->a
.hw_version
),
1858 "HW:%s", ha
->adapter_id
);
1860 alen
= strlen(eiter
->a
.hw_version
);
1861 alen
+= 4 - (alen
& 3);
1862 eiter
->len
= cpu_to_be16(4 + alen
);
1865 ql_dbg(ql_dbg_disc
, vha
, 0x20a9,
1866 "Hardware ver = %s.\n", eiter
->a
.hw_version
);
1868 /* Driver version. */
1869 eiter
= entries
+ size
;
1870 eiter
->type
= cpu_to_be16(FDMI_HBA_DRIVER_VERSION
);
1871 snprintf(eiter
->a
.driver_version
, sizeof(eiter
->a
.driver_version
),
1872 "%s", qla2x00_version_str
);
1873 alen
= strlen(eiter
->a
.driver_version
);
1874 alen
+= 4 - (alen
& 3);
1875 eiter
->len
= cpu_to_be16(4 + alen
);
1878 ql_dbg(ql_dbg_disc
, vha
, 0x20aa,
1879 "Driver ver = %s.\n", eiter
->a
.driver_version
);
1881 /* Option ROM version. */
1882 eiter
= entries
+ size
;
1883 eiter
->type
= cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION
);
1884 snprintf(eiter
->a
.orom_version
, sizeof(eiter
->a
.orom_version
),
1885 "%d.%02d", ha
->bios_revision
[1], ha
->bios_revision
[0]);
1886 alen
= strlen(eiter
->a
.orom_version
);
1887 alen
+= 4 - (alen
& 3);
1888 eiter
->len
= cpu_to_be16(4 + alen
);
1891 ql_dbg(ql_dbg_disc
, vha
, 0x20ab,
1892 "Optrom version = %d.%02d.\n", eiter
->a
.orom_version
[1],
1893 eiter
->a
.orom_version
[0]);
1895 /* Firmware version */
1896 eiter
= entries
+ size
;
1897 eiter
->type
= cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION
);
1898 ha
->isp_ops
->fw_version_str(vha
, eiter
->a
.fw_version
,
1899 sizeof(eiter
->a
.fw_version
));
1900 alen
= strlen(eiter
->a
.fw_version
);
1901 alen
+= 4 - (alen
& 3);
1902 eiter
->len
= cpu_to_be16(4 + alen
);
1905 ql_dbg(ql_dbg_disc
, vha
, 0x20ac,
1906 "Firmware vers = %s.\n", eiter
->a
.fw_version
);
1908 /* OS Name and Version */
1909 eiter
= entries
+ size
;
1910 eiter
->type
= cpu_to_be16(FDMI_HBA_OS_NAME_AND_VERSION
);
1911 p_sysid
= utsname();
1913 snprintf(eiter
->a
.os_version
, sizeof(eiter
->a
.os_version
),
1915 p_sysid
->sysname
, p_sysid
->release
, p_sysid
->version
);
1917 snprintf(eiter
->a
.os_version
, sizeof(eiter
->a
.os_version
),
1918 "%s %s", "Linux", fc_host_system_hostname(vha
->host
));
1920 alen
= strlen(eiter
->a
.os_version
);
1921 alen
+= 4 - (alen
& 3);
1922 eiter
->len
= cpu_to_be16(4 + alen
);
1925 ql_dbg(ql_dbg_disc
, vha
, 0x20ae,
1926 "OS Name and Version = %s.\n", eiter
->a
.os_version
);
1928 /* MAX CT Payload Length */
1929 eiter
= entries
+ size
;
1930 eiter
->type
= cpu_to_be16(FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH
);
1931 eiter
->a
.max_ct_len
= IS_FWI2_CAPABLE(ha
) ?
1932 le16_to_cpu(icb24
->frame_payload_size
) :
1933 le16_to_cpu(ha
->init_cb
->frame_payload_size
);
1934 eiter
->a
.max_ct_len
= cpu_to_be32(eiter
->a
.max_ct_len
);
1935 eiter
->len
= cpu_to_be16(4 + 4);
1938 ql_dbg(ql_dbg_disc
, vha
, 0x20af,
1939 "CT Payload Length = 0x%x.\n", eiter
->a
.max_ct_len
);
1941 /* Node Sybolic Name */
1942 eiter
= entries
+ size
;
1943 eiter
->type
= cpu_to_be16(FDMI_HBA_NODE_SYMBOLIC_NAME
);
1944 qla2x00_get_sym_node_name(vha
, eiter
->a
.sym_name
,
1945 sizeof(eiter
->a
.sym_name
));
1946 alen
= strlen(eiter
->a
.sym_name
);
1947 alen
+= 4 - (alen
& 3);
1948 eiter
->len
= cpu_to_be16(4 + alen
);
1951 ql_dbg(ql_dbg_disc
, vha
, 0x20b0,
1952 "Symbolic Name = %s.\n", eiter
->a
.sym_name
);
1955 eiter
= entries
+ size
;
1956 eiter
->type
= cpu_to_be16(FDMI_HBA_VENDOR_ID
);
1957 eiter
->a
.vendor_id
= cpu_to_be32(0x1077);
1958 eiter
->len
= cpu_to_be16(4 + 4);
1961 ql_dbg(ql_dbg_disc
, vha
, 0x20b1,
1962 "Vendor Id = %x.\n", eiter
->a
.vendor_id
);
1965 eiter
= entries
+ size
;
1966 eiter
->type
= cpu_to_be16(FDMI_HBA_NUM_PORTS
);
1967 eiter
->a
.num_ports
= cpu_to_be32(1);
1968 eiter
->len
= cpu_to_be16(4 + 4);
1971 ql_dbg(ql_dbg_disc
, vha
, 0x20b2,
1972 "Port Num = %x.\n", eiter
->a
.num_ports
);
1975 eiter
= entries
+ size
;
1976 eiter
->type
= cpu_to_be16(FDMI_HBA_FABRIC_NAME
);
1977 memcpy(eiter
->a
.fabric_name
, vha
->fabric_node_name
, WWN_SIZE
);
1978 eiter
->len
= cpu_to_be16(4 + WWN_SIZE
);
1979 size
+= 4 + WWN_SIZE
;
1981 ql_dbg(ql_dbg_disc
, vha
, 0x20b3,
1982 "Fabric Name = %016llx.\n", wwn_to_u64(eiter
->a
.fabric_name
));
1985 eiter
= entries
+ size
;
1986 eiter
->type
= cpu_to_be16(FDMI_HBA_BOOT_BIOS_NAME
);
1987 snprintf(eiter
->a
.bios_name
, sizeof(eiter
->a
.bios_name
),
1988 "BIOS %d.%02d", ha
->bios_revision
[1], ha
->bios_revision
[0]);
1989 alen
= strlen(eiter
->a
.bios_name
);
1990 alen
+= 4 - (alen
& 3);
1991 eiter
->len
= cpu_to_be16(4 + alen
);
1994 ql_dbg(ql_dbg_disc
, vha
, 0x20b4,
1995 "BIOS Name = %s\n", eiter
->a
.bios_name
);
1997 /* Vendor Identifier */
1998 eiter
= entries
+ size
;
1999 eiter
->type
= cpu_to_be16(FDMI_HBA_TYPE_VENDOR_IDENTIFIER
);
2000 snprintf(eiter
->a
.vendor_identifier
, sizeof(eiter
->a
.vendor_identifier
),
2002 alen
= strlen(eiter
->a
.vendor_identifier
);
2003 alen
+= 4 - (alen
& 3);
2004 eiter
->len
= cpu_to_be16(4 + alen
);
2007 ql_dbg(ql_dbg_disc
, vha
, 0x20b1,
2008 "Vendor Identifier = %s.\n", eiter
->a
.vendor_identifier
);
2010 /* Update MS request size. */
2011 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
2013 ql_dbg(ql_dbg_disc
, vha
, 0x20b5,
2014 "RHBA identifier = %016llx.\n",
2015 wwn_to_u64(ct_req
->req
.rhba2
.hba_identifier
));
2016 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x20b6,
2019 /* Execute MS IOCB */
2020 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
2021 sizeof(ms_iocb_entry_t
));
2022 if (rval
!= QLA_SUCCESS
) {
2024 ql_dbg(ql_dbg_disc
, vha
, 0x20b7,
2025 "RHBA issue IOCB failed (%d).\n", rval
);
2026 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RHBA") !=
2028 rval
= QLA_FUNCTION_FAILED
;
2030 if (ct_rsp
->header
.reason_code
== CT_REASON_CANNOT_PERFORM
&&
2031 ct_rsp
->header
.explanation_code
==
2032 CT_EXPL_ALREADY_REGISTERED
) {
2033 ql_dbg(ql_dbg_disc
, vha
, 0x20b8,
2034 "HBA already registered.\n");
2035 rval
= QLA_ALREADY_REGISTERED
;
2037 ql_dbg(ql_dbg_disc
, vha
, 0x2016,
2038 "RHBA FDMI v2 failed, CT Reason code: 0x%x, CT Explanation 0x%x\n",
2039 ct_rsp
->header
.reason_code
,
2040 ct_rsp
->header
.explanation_code
);
2043 ql_dbg(ql_dbg_disc
, vha
, 0x20b9,
2044 "RHBA FDMI V2 exiting normally.\n");
2051 * qla2x00_fdmi_dhba() -
2054 * Returns 0 on success.
2057 qla2x00_fdmi_dhba(scsi_qla_host_t
*vha
)
2060 struct qla_hw_data
*ha
= vha
->hw
;
2061 ms_iocb_entry_t
*ms_pkt
;
2062 struct ct_sns_req
*ct_req
;
2063 struct ct_sns_rsp
*ct_rsp
;
2066 /* Prepare common MS IOCB */
2067 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, DHBA_REQ_SIZE
,
2070 /* Prepare CT request */
2071 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, DHBA_CMD
, DHBA_RSP_SIZE
);
2072 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
2074 /* Prepare FDMI command arguments -- portname. */
2075 memcpy(ct_req
->req
.dhba
.port_name
, vha
->port_name
, WWN_SIZE
);
2077 ql_dbg(ql_dbg_disc
, vha
, 0x2036,
2078 "DHBA portname = %8phN.\n", ct_req
->req
.dhba
.port_name
);
2080 /* Execute MS IOCB */
2081 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
2082 sizeof(ms_iocb_entry_t
));
2083 if (rval
!= QLA_SUCCESS
) {
2085 ql_dbg(ql_dbg_disc
, vha
, 0x2037,
2086 "DHBA issue IOCB failed (%d).\n", rval
);
2087 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "DHBA") !=
2089 rval
= QLA_FUNCTION_FAILED
;
2091 ql_dbg(ql_dbg_disc
, vha
, 0x2038,
2092 "DHBA exiting normally.\n");
2099 * qla2x00_fdmiv2_rpa() -
2102 * Returns 0 on success.
2105 qla2x00_fdmiv2_rpa(scsi_qla_host_t
*vha
)
2109 struct qla_hw_data
*ha
= vha
->hw
;
2110 ms_iocb_entry_t
*ms_pkt
;
2111 struct ct_sns_req
*ct_req
;
2112 struct ct_sns_rsp
*ct_rsp
;
2114 struct ct_fdmiv2_port_attr
*eiter
;
2115 struct init_cb_24xx
*icb24
= (struct init_cb_24xx
*)ha
->init_cb
;
2116 struct new_utsname
*p_sysid
= NULL
;
2119 /* Prepare common MS IOCB */
2120 /* Request size adjusted after CT preparation */
2121 ms_pkt
= ha
->isp_ops
->prep_ms_fdmi_iocb(vha
, 0, RPA_RSP_SIZE
);
2123 /* Prepare CT request */
2124 ct_req
= qla2x00_prep_ct_fdmi_req(ha
->ct_sns
, RPA_CMD
, RPA_RSP_SIZE
);
2125 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
2127 /* Prepare FDMI command arguments -- attribute block, attributes. */
2128 memcpy(ct_req
->req
.rpa2
.port_name
, vha
->port_name
, WWN_SIZE
);
2129 size
= WWN_SIZE
+ 4;
2132 ct_req
->req
.rpa2
.attrs
.count
= cpu_to_be32(FDMIV2_PORT_ATTR_COUNT
);
2133 entries
= ct_req
->req
.rpa2
.port_name
;
2136 eiter
= entries
+ size
;
2137 eiter
->type
= cpu_to_be16(FDMI_PORT_FC4_TYPES
);
2138 eiter
->len
= cpu_to_be16(4 + 32);
2139 eiter
->a
.fc4_types
[2] = 0x01;
2142 ql_dbg(ql_dbg_disc
, vha
, 0x20ba,
2143 "FC4_TYPES=%02x %02x.\n",
2144 eiter
->a
.fc4_types
[2],
2145 eiter
->a
.fc4_types
[1]);
2147 /* Supported speed. */
2148 eiter
= entries
+ size
;
2149 eiter
->type
= cpu_to_be16(FDMI_PORT_SUPPORT_SPEED
);
2150 eiter
->len
= cpu_to_be16(4 + 4);
2151 if (IS_CNA_CAPABLE(ha
))
2152 eiter
->a
.sup_speed
= cpu_to_be32(
2153 FDMI_PORT_SPEED_10GB
);
2154 else if (IS_QLA27XX(ha
))
2155 eiter
->a
.sup_speed
= cpu_to_be32(
2156 FDMI_PORT_SPEED_32GB
|
2157 FDMI_PORT_SPEED_16GB
|
2158 FDMI_PORT_SPEED_8GB
);
2159 else if (IS_QLA2031(ha
))
2160 eiter
->a
.sup_speed
= cpu_to_be32(
2161 FDMI_PORT_SPEED_16GB
|
2162 FDMI_PORT_SPEED_8GB
|
2163 FDMI_PORT_SPEED_4GB
);
2164 else if (IS_QLA25XX(ha
))
2165 eiter
->a
.sup_speed
= cpu_to_be32(
2166 FDMI_PORT_SPEED_8GB
|
2167 FDMI_PORT_SPEED_4GB
|
2168 FDMI_PORT_SPEED_2GB
|
2169 FDMI_PORT_SPEED_1GB
);
2170 else if (IS_QLA24XX_TYPE(ha
))
2171 eiter
->a
.sup_speed
= cpu_to_be32(
2172 FDMI_PORT_SPEED_4GB
|
2173 FDMI_PORT_SPEED_2GB
|
2174 FDMI_PORT_SPEED_1GB
);
2175 else if (IS_QLA23XX(ha
))
2176 eiter
->a
.sup_speed
= cpu_to_be32(
2177 FDMI_PORT_SPEED_2GB
|
2178 FDMI_PORT_SPEED_1GB
);
2180 eiter
->a
.sup_speed
= cpu_to_be32(
2181 FDMI_PORT_SPEED_1GB
);
2184 ql_dbg(ql_dbg_disc
, vha
, 0x20bb,
2185 "Supported Port Speed = %x.\n", eiter
->a
.sup_speed
);
2187 /* Current speed. */
2188 eiter
= entries
+ size
;
2189 eiter
->type
= cpu_to_be16(FDMI_PORT_CURRENT_SPEED
);
2190 eiter
->len
= cpu_to_be16(4 + 4);
2191 switch (ha
->link_data_rate
) {
2192 case PORT_SPEED_1GB
:
2193 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_1GB
);
2195 case PORT_SPEED_2GB
:
2196 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_2GB
);
2198 case PORT_SPEED_4GB
:
2199 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_4GB
);
2201 case PORT_SPEED_8GB
:
2202 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_8GB
);
2204 case PORT_SPEED_10GB
:
2205 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_10GB
);
2207 case PORT_SPEED_16GB
:
2208 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_16GB
);
2210 case PORT_SPEED_32GB
:
2211 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_32GB
);
2214 eiter
->a
.cur_speed
= cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN
);
2219 ql_dbg(ql_dbg_disc
, vha
, 0x20bc,
2220 "Current_Speed = %x.\n", eiter
->a
.cur_speed
);
2222 /* Max frame size. */
2223 eiter
= entries
+ size
;
2224 eiter
->type
= cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE
);
2225 eiter
->len
= cpu_to_be16(4 + 4);
2226 eiter
->a
.max_frame_size
= IS_FWI2_CAPABLE(ha
) ?
2227 le16_to_cpu(icb24
->frame_payload_size
):
2228 le16_to_cpu(ha
->init_cb
->frame_payload_size
);
2229 eiter
->a
.max_frame_size
= cpu_to_be32(eiter
->a
.max_frame_size
);
2232 ql_dbg(ql_dbg_disc
, vha
, 0x20bc,
2233 "Max_Frame_Size = %x.\n", eiter
->a
.max_frame_size
);
2235 /* OS device name. */
2236 eiter
= entries
+ size
;
2237 eiter
->type
= cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME
);
2238 alen
= strlen(QLA2XXX_DRIVER_NAME
);
2239 snprintf(eiter
->a
.os_dev_name
, sizeof(eiter
->a
.os_dev_name
),
2240 "%s:host%lu", QLA2XXX_DRIVER_NAME
, vha
->host_no
);
2241 alen
+= 4 - (alen
& 3);
2242 eiter
->len
= cpu_to_be16(4 + alen
);
2245 ql_dbg(ql_dbg_disc
, vha
, 0x20be,
2246 "OS_Device_Name = %s.\n", eiter
->a
.os_dev_name
);
2249 eiter
= entries
+ size
;
2250 eiter
->type
= cpu_to_be16(FDMI_PORT_HOST_NAME
);
2251 p_sysid
= utsname();
2253 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
2254 "%s", p_sysid
->nodename
);
2256 snprintf(eiter
->a
.host_name
, sizeof(eiter
->a
.host_name
),
2257 "%s", fc_host_system_hostname(vha
->host
));
2259 alen
= strlen(eiter
->a
.host_name
);
2260 alen
+= 4 - (alen
& 3);
2261 eiter
->len
= cpu_to_be16(4 + alen
);
2264 ql_dbg(ql_dbg_disc
, vha
, 0x203d,
2265 "HostName=%s.\n", eiter
->a
.host_name
);
2268 eiter
= entries
+ size
;
2269 eiter
->type
= cpu_to_be16(FDMI_PORT_NODE_NAME
);
2270 memcpy(eiter
->a
.node_name
, vha
->node_name
, WWN_SIZE
);
2271 eiter
->len
= cpu_to_be16(4 + WWN_SIZE
);
2272 size
+= 4 + WWN_SIZE
;
2274 ql_dbg(ql_dbg_disc
, vha
, 0x20c0,
2275 "Node Name = %016llx.\n", wwn_to_u64(eiter
->a
.node_name
));
2278 eiter
= entries
+ size
;
2279 eiter
->type
= cpu_to_be16(FDMI_PORT_NAME
);
2280 memcpy(eiter
->a
.port_name
, vha
->port_name
, WWN_SIZE
);
2281 eiter
->len
= cpu_to_be16(4 + WWN_SIZE
);
2282 size
+= 4 + WWN_SIZE
;
2284 ql_dbg(ql_dbg_disc
, vha
, 0x20c1,
2285 "Port Name = %016llx.\n", wwn_to_u64(eiter
->a
.port_name
));
2287 /* Port Symbolic Name */
2288 eiter
= entries
+ size
;
2289 eiter
->type
= cpu_to_be16(FDMI_PORT_SYM_NAME
);
2290 qla2x00_get_sym_node_name(vha
, eiter
->a
.port_sym_name
,
2291 sizeof(eiter
->a
.port_sym_name
));
2292 alen
= strlen(eiter
->a
.port_sym_name
);
2293 alen
+= 4 - (alen
& 3);
2294 eiter
->len
= cpu_to_be16(4 + alen
);
2297 ql_dbg(ql_dbg_disc
, vha
, 0x20c2,
2298 "port symbolic name = %s\n", eiter
->a
.port_sym_name
);
2301 eiter
= entries
+ size
;
2302 eiter
->type
= cpu_to_be16(FDMI_PORT_TYPE
);
2303 eiter
->a
.port_type
= cpu_to_be32(NS_NX_PORT_TYPE
);
2304 eiter
->len
= cpu_to_be16(4 + 4);
2307 ql_dbg(ql_dbg_disc
, vha
, 0x20c3,
2308 "Port Type = %x.\n", eiter
->a
.port_type
);
2310 /* Class of Service */
2311 eiter
= entries
+ size
;
2312 eiter
->type
= cpu_to_be16(FDMI_PORT_SUPP_COS
);
2313 eiter
->a
.port_supported_cos
= cpu_to_be32(FC_CLASS_3
);
2314 eiter
->len
= cpu_to_be16(4 + 4);
2317 ql_dbg(ql_dbg_disc
, vha
, 0x20c4,
2318 "Supported COS = %08x\n", eiter
->a
.port_supported_cos
);
2320 /* Port Fabric Name */
2321 eiter
= entries
+ size
;
2322 eiter
->type
= cpu_to_be16(FDMI_PORT_FABRIC_NAME
);
2323 memcpy(eiter
->a
.fabric_name
, vha
->fabric_node_name
, WWN_SIZE
);
2324 eiter
->len
= cpu_to_be16(4 + WWN_SIZE
);
2325 size
+= 4 + WWN_SIZE
;
2327 ql_dbg(ql_dbg_disc
, vha
, 0x20c5,
2328 "Fabric Name = %016llx.\n", wwn_to_u64(eiter
->a
.fabric_name
));
2331 eiter
= entries
+ size
;
2332 eiter
->type
= cpu_to_be16(FDMI_PORT_FC4_TYPE
);
2333 eiter
->a
.port_fc4_type
[0] = 0;
2334 eiter
->a
.port_fc4_type
[1] = 0;
2335 eiter
->a
.port_fc4_type
[2] = 1;
2336 eiter
->a
.port_fc4_type
[3] = 0;
2337 eiter
->len
= cpu_to_be16(4 + 32);
2340 ql_dbg(ql_dbg_disc
, vha
, 0x20c6,
2341 "Port Active FC4 Type = %02x %02x.\n",
2342 eiter
->a
.port_fc4_type
[2], eiter
->a
.port_fc4_type
[1]);
2345 eiter
= entries
+ size
;
2346 eiter
->type
= cpu_to_be16(FDMI_PORT_STATE
);
2347 eiter
->a
.port_state
= cpu_to_be32(1);
2348 eiter
->len
= cpu_to_be16(4 + 4);
2351 ql_dbg(ql_dbg_disc
, vha
, 0x20c7,
2352 "Port State = %x.\n", eiter
->a
.port_state
);
2354 /* Number of Ports */
2355 eiter
= entries
+ size
;
2356 eiter
->type
= cpu_to_be16(FDMI_PORT_COUNT
);
2357 eiter
->a
.num_ports
= cpu_to_be32(1);
2358 eiter
->len
= cpu_to_be16(4 + 4);
2361 ql_dbg(ql_dbg_disc
, vha
, 0x20c8,
2362 "Number of ports = %x.\n", eiter
->a
.num_ports
);
2365 eiter
= entries
+ size
;
2366 eiter
->type
= cpu_to_be16(FDMI_PORT_ID
);
2367 eiter
->a
.port_id
= cpu_to_be32(vha
->d_id
.b24
);
2368 eiter
->len
= cpu_to_be16(4 + 4);
2371 ql_dbg(ql_dbg_disc
, vha
, 0x20c8,
2372 "Port Id = %x.\n", eiter
->a
.port_id
);
2374 /* Update MS request size. */
2375 qla2x00_update_ms_fdmi_iocb(vha
, size
+ 16);
2377 ql_dbg(ql_dbg_disc
, vha
, 0x203e,
2378 "RPA portname= %8phN size=%d.\n", ct_req
->req
.rpa
.port_name
, size
);
2379 ql_dump_buffer(ql_dbg_disc
+ ql_dbg_buffer
, vha
, 0x20ca,
2382 /* Execute MS IOCB */
2383 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
2384 sizeof(ms_iocb_entry_t
));
2385 if (rval
!= QLA_SUCCESS
) {
2387 ql_dbg(ql_dbg_disc
, vha
, 0x20cb,
2388 "RPA FDMI v2 issue IOCB failed (%d).\n", rval
);
2389 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
, "RPA") !=
2391 rval
= QLA_FUNCTION_FAILED
;
2392 if (ct_rsp
->header
.reason_code
== CT_REASON_CANNOT_PERFORM
&&
2393 ct_rsp
->header
.explanation_code
==
2394 CT_EXPL_ALREADY_REGISTERED
) {
2395 ql_dbg(ql_dbg_disc
, vha
, 0x20ce,
2396 "RPA FDMI v2 already registered\n");
2397 rval
= QLA_ALREADY_REGISTERED
;
2399 ql_dbg(ql_dbg_disc
, vha
, 0x2020,
2400 "RPA FDMI v2 failed, CT Reason code: 0x%x, CT Explanation 0x%x\n",
2401 ct_rsp
->header
.reason_code
,
2402 ct_rsp
->header
.explanation_code
);
2405 ql_dbg(ql_dbg_disc
, vha
, 0x20cc,
2406 "RPA FDMI V2 exiting normally.\n");
2413 * qla2x00_fdmi_register() -
2416 * Returns 0 on success.
2419 qla2x00_fdmi_register(scsi_qla_host_t
*vha
)
2421 int rval
= QLA_FUNCTION_FAILED
;
2422 struct qla_hw_data
*ha
= vha
->hw
;
2424 if (IS_QLA2100(ha
) || IS_QLA2200(ha
) ||
2426 return QLA_FUNCTION_FAILED
;
2428 rval
= qla2x00_mgmt_svr_login(vha
);
2432 rval
= qla2x00_fdmiv2_rhba(vha
);
2434 if (rval
!= QLA_ALREADY_REGISTERED
)
2437 rval
= qla2x00_fdmi_dhba(vha
);
2441 rval
= qla2x00_fdmiv2_rhba(vha
);
2445 rval
= qla2x00_fdmiv2_rpa(vha
);
2452 rval
= qla2x00_fdmi_rhba(vha
);
2454 if (rval
!= QLA_ALREADY_REGISTERED
)
2457 rval
= qla2x00_fdmi_dhba(vha
);
2461 rval
= qla2x00_fdmi_rhba(vha
);
2465 rval
= qla2x00_fdmi_rpa(vha
);
2471 * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
2473 * @list: switch info entries to populate
2475 * Returns 0 on success.
2478 qla2x00_gfpn_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
2480 int rval
= QLA_SUCCESS
;
2482 struct qla_hw_data
*ha
= vha
->hw
;
2483 ms_iocb_entry_t
*ms_pkt
;
2484 struct ct_sns_req
*ct_req
;
2485 struct ct_sns_rsp
*ct_rsp
;
2488 if (!IS_IIDMA_CAPABLE(ha
))
2489 return QLA_FUNCTION_FAILED
;
2491 arg
.iocb
= ha
->ms_iocb
;
2492 arg
.req_dma
= ha
->ct_sns_dma
;
2493 arg
.rsp_dma
= ha
->ct_sns_dma
;
2494 arg
.req_size
= GFPN_ID_REQ_SIZE
;
2495 arg
.rsp_size
= GFPN_ID_RSP_SIZE
;
2496 arg
.nport_handle
= NPH_SNS
;
2498 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
2500 /* Prepare common MS IOCB */
2501 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
2503 /* Prepare CT request */
2504 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GFPN_ID_CMD
,
2506 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
2508 /* Prepare CT arguments -- port_id */
2509 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
2510 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
2511 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
2513 /* Execute MS IOCB */
2514 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
2515 sizeof(ms_iocb_entry_t
));
2516 if (rval
!= QLA_SUCCESS
) {
2518 ql_dbg(ql_dbg_disc
, vha
, 0x2023,
2519 "GFPN_ID issue IOCB failed (%d).\n", rval
);
2521 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
2522 "GFPN_ID") != QLA_SUCCESS
) {
2523 rval
= QLA_FUNCTION_FAILED
;
2526 /* Save fabric portname */
2527 memcpy(list
[i
].fabric_port_name
,
2528 ct_rsp
->rsp
.gfpn_id
.port_name
, WWN_SIZE
);
2531 /* Last device exit. */
2532 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
2540 static inline struct ct_sns_req
*
2541 qla24xx_prep_ct_fm_req(struct ct_sns_pkt
*p
, uint16_t cmd
,
2544 memset(p
, 0, sizeof(struct ct_sns_pkt
));
2546 p
->p
.req
.header
.revision
= 0x01;
2547 p
->p
.req
.header
.gs_type
= 0xFA;
2548 p
->p
.req
.header
.gs_subtype
= 0x01;
2549 p
->p
.req
.command
= cpu_to_be16(cmd
);
2550 p
->p
.req
.max_rsp_size
= cpu_to_be16((rsp_size
- 16) / 4);
2556 * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
2558 * @list: switch info entries to populate
2560 * Returns 0 on success.
2563 qla2x00_gpsc(scsi_qla_host_t
*vha
, sw_info_t
*list
)
2567 struct qla_hw_data
*ha
= vha
->hw
;
2568 ms_iocb_entry_t
*ms_pkt
;
2569 struct ct_sns_req
*ct_req
;
2570 struct ct_sns_rsp
*ct_rsp
;
2573 if (!IS_IIDMA_CAPABLE(ha
))
2574 return QLA_FUNCTION_FAILED
;
2575 if (!ha
->flags
.gpsc_supported
)
2576 return QLA_FUNCTION_FAILED
;
2578 rval
= qla2x00_mgmt_svr_login(vha
);
2582 arg
.iocb
= ha
->ms_iocb
;
2583 arg
.req_dma
= ha
->ct_sns_dma
;
2584 arg
.rsp_dma
= ha
->ct_sns_dma
;
2585 arg
.req_size
= GPSC_REQ_SIZE
;
2586 arg
.rsp_size
= GPSC_RSP_SIZE
;
2587 arg
.nport_handle
= vha
->mgmt_svr_loop_id
;
2589 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
2591 /* Prepare common MS IOCB */
2592 ms_pkt
= qla24xx_prep_ms_iocb(vha
, &arg
);
2594 /* Prepare CT request */
2595 ct_req
= qla24xx_prep_ct_fm_req(ha
->ct_sns
, GPSC_CMD
,
2597 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
2599 /* Prepare CT arguments -- port_name */
2600 memcpy(ct_req
->req
.gpsc
.port_name
, list
[i
].fabric_port_name
,
2603 /* Execute MS IOCB */
2604 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
2605 sizeof(ms_iocb_entry_t
));
2606 if (rval
!= QLA_SUCCESS
) {
2608 ql_dbg(ql_dbg_disc
, vha
, 0x2059,
2609 "GPSC issue IOCB failed (%d).\n", rval
);
2610 } else if ((rval
= qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
2611 "GPSC")) != QLA_SUCCESS
) {
2612 /* FM command unsupported? */
2613 if (rval
== QLA_INVALID_COMMAND
&&
2614 (ct_rsp
->header
.reason_code
==
2615 CT_REASON_INVALID_COMMAND_CODE
||
2616 ct_rsp
->header
.reason_code
==
2617 CT_REASON_COMMAND_UNSUPPORTED
)) {
2618 ql_dbg(ql_dbg_disc
, vha
, 0x205a,
2619 "GPSC command unsupported, disabling "
2621 ha
->flags
.gpsc_supported
= 0;
2622 rval
= QLA_FUNCTION_FAILED
;
2625 rval
= QLA_FUNCTION_FAILED
;
2627 /* Save port-speed */
2628 switch (be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)) {
2630 list
[i
].fp_speed
= PORT_SPEED_1GB
;
2633 list
[i
].fp_speed
= PORT_SPEED_2GB
;
2636 list
[i
].fp_speed
= PORT_SPEED_4GB
;
2639 list
[i
].fp_speed
= PORT_SPEED_10GB
;
2642 list
[i
].fp_speed
= PORT_SPEED_8GB
;
2645 list
[i
].fp_speed
= PORT_SPEED_16GB
;
2648 list
[i
].fp_speed
= PORT_SPEED_32GB
;
2652 ql_dbg(ql_dbg_disc
, vha
, 0x205b,
2653 "GPSC ext entry - fpn "
2654 "%8phN speeds=%04x speed=%04x.\n",
2655 list
[i
].fabric_port_name
,
2656 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speeds
),
2657 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
));
2660 /* Last device exit. */
2661 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
2669 * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query.
2672 * @list: switch info entries to populate
2676 qla2x00_gff_id(scsi_qla_host_t
*vha
, sw_info_t
*list
)
2681 ms_iocb_entry_t
*ms_pkt
;
2682 struct ct_sns_req
*ct_req
;
2683 struct ct_sns_rsp
*ct_rsp
;
2684 struct qla_hw_data
*ha
= vha
->hw
;
2685 uint8_t fcp_scsi_features
= 0;
2688 for (i
= 0; i
< ha
->max_fibre_devices
; i
++) {
2689 /* Set default FC4 Type as UNKNOWN so the default is to
2690 * Process this port */
2691 list
[i
].fc4_type
= FC4_TYPE_UNKNOWN
;
2693 /* Do not attempt GFF_ID if we are not FWI_2 capable */
2694 if (!IS_FWI2_CAPABLE(ha
))
2697 arg
.iocb
= ha
->ms_iocb
;
2698 arg
.req_dma
= ha
->ct_sns_dma
;
2699 arg
.rsp_dma
= ha
->ct_sns_dma
;
2700 arg
.req_size
= GFF_ID_REQ_SIZE
;
2701 arg
.rsp_size
= GFF_ID_RSP_SIZE
;
2702 arg
.nport_handle
= NPH_SNS
;
2704 /* Prepare common MS IOCB */
2705 ms_pkt
= ha
->isp_ops
->prep_ms_iocb(vha
, &arg
);
2707 /* Prepare CT request */
2708 ct_req
= qla2x00_prep_ct_req(ha
->ct_sns
, GFF_ID_CMD
,
2710 ct_rsp
= &ha
->ct_sns
->p
.rsp
;
2712 /* Prepare CT arguments -- port_id */
2713 ct_req
->req
.port_id
.port_id
[0] = list
[i
].d_id
.b
.domain
;
2714 ct_req
->req
.port_id
.port_id
[1] = list
[i
].d_id
.b
.area
;
2715 ct_req
->req
.port_id
.port_id
[2] = list
[i
].d_id
.b
.al_pa
;
2717 /* Execute MS IOCB */
2718 rval
= qla2x00_issue_iocb(vha
, ha
->ms_iocb
, ha
->ms_iocb_dma
,
2719 sizeof(ms_iocb_entry_t
));
2721 if (rval
!= QLA_SUCCESS
) {
2722 ql_dbg(ql_dbg_disc
, vha
, 0x205c,
2723 "GFF_ID issue IOCB failed (%d).\n", rval
);
2724 } else if (qla2x00_chk_ms_status(vha
, ms_pkt
, ct_rsp
,
2725 "GFF_ID") != QLA_SUCCESS
) {
2726 ql_dbg(ql_dbg_disc
, vha
, 0x205d,
2727 "GFF_ID IOCB status had a failure status code.\n");
2730 ct_rsp
->rsp
.gff_id
.fc4_features
[GFF_FCP_SCSI_OFFSET
];
2731 fcp_scsi_features
&= 0x0f;
2733 if (fcp_scsi_features
)
2734 list
[i
].fc4_type
= FC4_TYPE_FCP_SCSI
;
2736 list
[i
].fc4_type
= FC4_TYPE_OTHER
;
2739 /* Last device exit. */
2740 if (list
[i
].d_id
.b
.rsvd_1
!= 0)
2745 /* GID_PN completion processing. */
2746 void qla24xx_handle_gidpn_event(scsi_qla_host_t
*vha
, struct event_arg
*ea
)
2748 fc_port_t
*fcport
= ea
->fcport
;
2750 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2751 "%s %8phC login state %d \n",
2752 __func__
, fcport
->port_name
, fcport
->fw_login_state
);
2754 if (ea
->sp
->gen2
!= fcport
->login_gen
) {
2755 /* PLOGI/PRLI/LOGO came in while cmd was out.*/
2756 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2757 "%s %8phC generation changed rscn %d|%d login %d|%d \n",
2758 __func__
, fcport
->port_name
, fcport
->last_rscn_gen
,
2759 fcport
->rscn_gen
, fcport
->last_login_gen
, fcport
->login_gen
);
2764 if (ea
->sp
->gen1
== fcport
->rscn_gen
) {
2765 fcport
->scan_state
= QLA_FCPORT_FOUND
;
2766 fcport
->flags
|= FCF_FABRIC_DEVICE
;
2768 if (fcport
->d_id
.b24
== ea
->id
.b24
) {
2769 /* cable plugged into the same place */
2770 switch (vha
->host
->active_mode
) {
2772 /* NOOP. let the other guy login to us.*/
2774 case MODE_INITIATOR
:
2777 if (atomic_read(&fcport
->state
) ==
2780 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2781 "%s %d %8phC post gnl\n",
2782 __func__
, __LINE__
, fcport
->port_name
);
2783 qla24xx_post_gnl_work(vha
, fcport
);
2786 } else { /* fcport->d_id.b24 != ea->id.b24 */
2787 fcport
->d_id
.b24
= ea
->id
.b24
;
2788 if (fcport
->deleted
== QLA_SESS_DELETED
) {
2789 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2790 "%s %d %8phC post del sess\n",
2791 __func__
, __LINE__
, fcport
->port_name
);
2792 qlt_schedule_sess_for_deletion_lock(fcport
);
2795 } else { /* ea->sp->gen1 != fcport->rscn_gen */
2796 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2797 "%s %d %8phC post gidpn\n",
2798 __func__
, __LINE__
, fcport
->port_name
);
2799 /* rscn came in while cmd was out */
2800 qla24xx_post_gidpn_work(vha
, fcport
);
2802 } else { /* ea->rc */
2804 if (ea
->sp
->gen1
== fcport
->rscn_gen
) {
2805 if (ea
->sp
->gen2
== fcport
->login_gen
) {
2806 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2807 "%s %d %8phC post del sess\n", __func__
,
2808 __LINE__
, fcport
->port_name
);
2809 qlt_schedule_sess_for_deletion_lock(fcport
);
2811 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2812 "%s %d %8phC login\n", __func__
, __LINE__
,
2814 qla24xx_fcport_handle_login(vha
, fcport
);
2817 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2818 "%s %d %8phC post gidpn\n", __func__
, __LINE__
,
2820 qla24xx_post_gidpn_work(vha
, fcport
);
2825 static void qla2x00_async_gidpn_sp_done(void *s
, int res
)
2828 struct scsi_qla_host
*vha
= sp
->vha
;
2829 fc_port_t
*fcport
= sp
->fcport
;
2830 u8
*id
= fcport
->ct_desc
.ct_sns
->p
.rsp
.rsp
.gid_pn
.port_id
;
2831 struct event_arg ea
;
2833 fcport
->flags
&= ~FCF_ASYNC_SENT
;
2835 memset(&ea
, 0, sizeof(ea
));
2837 ea
.id
.b
.domain
= id
[0];
2838 ea
.id
.b
.area
= id
[1];
2839 ea
.id
.b
.al_pa
= id
[2];
2842 ea
.event
= FCME_GIDPN_DONE
;
2844 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2845 "Async done-%s res %x, WWPN %8phC ID %3phC \n",
2846 sp
->name
, res
, fcport
->port_name
, id
);
2848 qla2x00_fcport_event_handler(vha
, &ea
);
2853 int qla24xx_async_gidpn(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
2855 int rval
= QLA_FUNCTION_FAILED
;
2856 struct ct_sns_req
*ct_req
;
2859 if (!vha
->flags
.online
)
2862 fcport
->flags
|= FCF_ASYNC_SENT
;
2863 fcport
->disc_state
= DSC_GID_PN
;
2864 fcport
->scan_state
= QLA_FCPORT_SCAN
;
2865 sp
= qla2x00_get_sp(vha
, fcport
, GFP_ATOMIC
);
2869 sp
->type
= SRB_CT_PTHRU_CMD
;
2871 sp
->gen1
= fcport
->rscn_gen
;
2872 sp
->gen2
= fcport
->login_gen
;
2874 qla2x00_init_timer(sp
, qla2x00_get_async_timeout(vha
) + 2);
2876 /* CT_IU preamble */
2877 ct_req
= qla2x00_prep_ct_req(fcport
->ct_desc
.ct_sns
, GID_PN_CMD
,
2881 memcpy(ct_req
->req
.gid_pn
.port_name
, fcport
->port_name
,
2884 /* req & rsp use the same buffer */
2885 sp
->u
.iocb_cmd
.u
.ctarg
.req
= fcport
->ct_desc
.ct_sns
;
2886 sp
->u
.iocb_cmd
.u
.ctarg
.req_dma
= fcport
->ct_desc
.ct_sns_dma
;
2887 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
= fcport
->ct_desc
.ct_sns
;
2888 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_dma
= fcport
->ct_desc
.ct_sns_dma
;
2889 sp
->u
.iocb_cmd
.u
.ctarg
.req_size
= GID_PN_REQ_SIZE
;
2890 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_size
= GID_PN_RSP_SIZE
;
2891 sp
->u
.iocb_cmd
.u
.ctarg
.nport_handle
= NPH_SNS
;
2893 sp
->u
.iocb_cmd
.timeout
= qla2x00_async_iocb_timeout
;
2894 sp
->done
= qla2x00_async_gidpn_sp_done
;
2896 rval
= qla2x00_start_sp(sp
);
2897 if (rval
!= QLA_SUCCESS
)
2900 ql_dbg(ql_dbg_disc
, vha
, 0x206f,
2901 "Async-%s - %8phC hdl=%x loopid=%x portid %02x%02x%02x.\n",
2902 sp
->name
, fcport
->port_name
,
2903 sp
->handle
, fcport
->loop_id
, fcport
->d_id
.b
.domain
,
2904 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
2910 fcport
->flags
&= ~FCF_ASYNC_SENT
;
2914 int qla24xx_post_gidpn_work(struct scsi_qla_host
*vha
, fc_port_t
*fcport
)
2916 struct qla_work_evt
*e
;
2919 ls
= atomic_read(&vha
->loop_state
);
2920 if (((ls
!= LOOP_READY
) && (ls
!= LOOP_UP
)) ||
2921 test_bit(UNLOADING
, &vha
->dpc_flags
))
2924 e
= qla2x00_alloc_work(vha
, QLA_EVT_GIDPN
);
2926 return QLA_FUNCTION_FAILED
;
2928 e
->u
.fcport
.fcport
= fcport
;
2929 return qla2x00_post_work(vha
, e
);
2932 int qla24xx_post_gpsc_work(struct scsi_qla_host
*vha
, fc_port_t
*fcport
)
2934 struct qla_work_evt
*e
;
2936 e
= qla2x00_alloc_work(vha
, QLA_EVT_GPSC
);
2938 return QLA_FUNCTION_FAILED
;
2940 e
->u
.fcport
.fcport
= fcport
;
2941 return qla2x00_post_work(vha
, e
);
2944 static void qla24xx_async_gpsc_sp_done(void *s
, int res
)
2947 struct scsi_qla_host
*vha
= sp
->vha
;
2948 struct qla_hw_data
*ha
= vha
->hw
;
2949 fc_port_t
*fcport
= sp
->fcport
;
2950 struct ct_sns_rsp
*ct_rsp
;
2951 struct event_arg ea
;
2953 ct_rsp
= &fcport
->ct_desc
.ct_sns
->p
.rsp
;
2955 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
2956 "Async done-%s res %x, WWPN %8phC \n",
2957 sp
->name
, res
, fcport
->port_name
);
2959 fcport
->flags
&= ~FCF_ASYNC_SENT
;
2961 if (res
== (DID_ERROR
<< 16)) {
2962 /* entry status error */
2965 if ((ct_rsp
->header
.reason_code
==
2966 CT_REASON_INVALID_COMMAND_CODE
) ||
2967 (ct_rsp
->header
.reason_code
==
2968 CT_REASON_COMMAND_UNSUPPORTED
)) {
2969 ql_dbg(ql_dbg_disc
, vha
, 0x205a,
2970 "GPSC command unsupported, disabling "
2972 ha
->flags
.gpsc_supported
= 0;
2976 switch (be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
)) {
2978 fcport
->fp_speed
= PORT_SPEED_1GB
;
2981 fcport
->fp_speed
= PORT_SPEED_2GB
;
2984 fcport
->fp_speed
= PORT_SPEED_4GB
;
2987 fcport
->fp_speed
= PORT_SPEED_10GB
;
2990 fcport
->fp_speed
= PORT_SPEED_8GB
;
2993 fcport
->fp_speed
= PORT_SPEED_16GB
;
2996 fcport
->fp_speed
= PORT_SPEED_32GB
;
3000 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
3001 "Async-%s OUT WWPN %8phC speeds=%04x speed=%04x.\n",
3003 fcport
->fabric_port_name
,
3004 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speeds
),
3005 be16_to_cpu(ct_rsp
->rsp
.gpsc
.speed
));
3008 memset(&ea
, 0, sizeof(ea
));
3009 ea
.event
= FCME_GPSC_DONE
;
3012 qla2x00_fcport_event_handler(vha
, &ea
);
3017 int qla24xx_async_gpsc(scsi_qla_host_t
*vha
, fc_port_t
*fcport
)
3019 int rval
= QLA_FUNCTION_FAILED
;
3020 struct ct_sns_req
*ct_req
;
3023 if (!vha
->flags
.online
)
3026 fcport
->flags
|= FCF_ASYNC_SENT
;
3027 sp
= qla2x00_get_sp(vha
, fcport
, GFP_KERNEL
);
3031 sp
->type
= SRB_CT_PTHRU_CMD
;
3033 sp
->gen1
= fcport
->rscn_gen
;
3034 sp
->gen2
= fcport
->login_gen
;
3036 qla2x00_init_timer(sp
, qla2x00_get_async_timeout(vha
) + 2);
3038 /* CT_IU preamble */
3039 ct_req
= qla24xx_prep_ct_fm_req(fcport
->ct_desc
.ct_sns
, GPSC_CMD
,
3043 memcpy(ct_req
->req
.gpsc
.port_name
, fcport
->port_name
,
3046 sp
->u
.iocb_cmd
.u
.ctarg
.req
= fcport
->ct_desc
.ct_sns
;
3047 sp
->u
.iocb_cmd
.u
.ctarg
.req_dma
= fcport
->ct_desc
.ct_sns_dma
;
3048 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
= fcport
->ct_desc
.ct_sns
;
3049 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_dma
= fcport
->ct_desc
.ct_sns_dma
;
3050 sp
->u
.iocb_cmd
.u
.ctarg
.req_size
= GPSC_REQ_SIZE
;
3051 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_size
= GPSC_RSP_SIZE
;
3052 sp
->u
.iocb_cmd
.u
.ctarg
.nport_handle
= vha
->mgmt_svr_loop_id
;
3054 sp
->u
.iocb_cmd
.timeout
= qla2x00_async_iocb_timeout
;
3055 sp
->done
= qla24xx_async_gpsc_sp_done
;
3057 rval
= qla2x00_start_sp(sp
);
3058 if (rval
!= QLA_SUCCESS
)
3061 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
3062 "Async-%s %8phC hdl=%x loopid=%x portid=%02x%02x%02x.\n",
3063 sp
->name
, fcport
->port_name
, sp
->handle
,
3064 fcport
->loop_id
, fcport
->d_id
.b
.domain
,
3065 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
3071 fcport
->flags
&= ~FCF_ASYNC_SENT
;
3075 int qla24xx_post_gpnid_work(struct scsi_qla_host
*vha
, port_id_t
*id
)
3077 struct qla_work_evt
*e
;
3079 if (test_bit(UNLOADING
, &vha
->dpc_flags
))
3082 e
= qla2x00_alloc_work(vha
, QLA_EVT_GPNID
);
3084 return QLA_FUNCTION_FAILED
;
3086 e
->u
.gpnid
.id
= *id
;
3087 return qla2x00_post_work(vha
, e
);
3090 void qla24xx_async_gpnid_done(scsi_qla_host_t
*vha
, srb_t
*sp
)
3092 if (sp
->u
.iocb_cmd
.u
.ctarg
.req
) {
3093 dma_free_coherent(&vha
->hw
->pdev
->dev
,
3094 sizeof(struct ct_sns_pkt
),
3095 sp
->u
.iocb_cmd
.u
.ctarg
.req
,
3096 sp
->u
.iocb_cmd
.u
.ctarg
.req_dma
);
3097 sp
->u
.iocb_cmd
.u
.ctarg
.req
= NULL
;
3099 if (sp
->u
.iocb_cmd
.u
.ctarg
.rsp
) {
3100 dma_free_coherent(&vha
->hw
->pdev
->dev
,
3101 sizeof(struct ct_sns_pkt
),
3102 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
,
3103 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_dma
);
3104 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
= NULL
;
3110 void qla24xx_handle_gpnid_event(scsi_qla_host_t
*vha
, struct event_arg
*ea
)
3113 unsigned long flags
;
3115 spin_lock_irqsave(&vha
->hw
->tgt
.sess_lock
, flags
);
3116 fcport
= qla2x00_find_fcport_by_wwpn(vha
, ea
->port_name
, 1);
3117 spin_unlock_irqrestore(&vha
->hw
->tgt
.sess_lock
, flags
);
3120 /* cable moved. just plugged in */
3121 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
3122 "%s %d %8phC post del sess\n",
3123 __func__
, __LINE__
, fcport
->port_name
);
3126 fcport
->d_id
= ea
->id
;
3127 fcport
->scan_state
= QLA_FCPORT_FOUND
;
3128 fcport
->flags
|= FCF_FABRIC_DEVICE
;
3130 qlt_schedule_sess_for_deletion_lock(fcport
);
3132 /* create new fcport */
3133 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
3134 "%s %d %8phC post new sess\n",
3135 __func__
, __LINE__
, ea
->port_name
);
3137 qla24xx_post_newsess_work(vha
, &ea
->id
, ea
->port_name
, NULL
);
3141 static void qla2x00_async_gpnid_sp_done(void *s
, int res
)
3144 struct scsi_qla_host
*vha
= sp
->vha
;
3145 struct ct_sns_req
*ct_req
=
3146 (struct ct_sns_req
*)sp
->u
.iocb_cmd
.u
.ctarg
.req
;
3147 struct ct_sns_rsp
*ct_rsp
=
3148 (struct ct_sns_rsp
*)sp
->u
.iocb_cmd
.u
.ctarg
.rsp
;
3149 struct event_arg ea
;
3150 struct qla_work_evt
*e
;
3152 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
3153 "Async done-%s res %x ID %3phC. %8phC\n",
3154 sp
->name
, res
, ct_req
->req
.port_id
.port_id
,
3155 ct_rsp
->rsp
.gpn_id
.port_name
);
3157 memset(&ea
, 0, sizeof(ea
));
3158 memcpy(ea
.port_name
, ct_rsp
->rsp
.gpn_id
.port_name
, WWN_SIZE
);
3160 ea
.id
.b
.domain
= ct_req
->req
.port_id
.port_id
[0];
3161 ea
.id
.b
.area
= ct_req
->req
.port_id
.port_id
[1];
3162 ea
.id
.b
.al_pa
= ct_req
->req
.port_id
.port_id
[2];
3164 ea
.event
= FCME_GPNID_DONE
;
3166 qla2x00_fcport_event_handler(vha
, &ea
);
3168 e
= qla2x00_alloc_work(vha
, QLA_EVT_GPNID_DONE
);
3170 /* please ignore kernel warning. otherwise, we have mem leak. */
3171 if (sp
->u
.iocb_cmd
.u
.ctarg
.req
) {
3172 dma_free_coherent(&vha
->hw
->pdev
->dev
,
3173 sizeof(struct ct_sns_pkt
),
3174 sp
->u
.iocb_cmd
.u
.ctarg
.req
,
3175 sp
->u
.iocb_cmd
.u
.ctarg
.req_dma
);
3176 sp
->u
.iocb_cmd
.u
.ctarg
.req
= NULL
;
3178 if (sp
->u
.iocb_cmd
.u
.ctarg
.rsp
) {
3179 dma_free_coherent(&vha
->hw
->pdev
->dev
,
3180 sizeof(struct ct_sns_pkt
),
3181 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
,
3182 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_dma
);
3183 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
= NULL
;
3191 qla2x00_post_work(vha
, e
);
3194 /* Get WWPN with Nport ID. */
3195 int qla24xx_async_gpnid(scsi_qla_host_t
*vha
, port_id_t
*id
)
3197 int rval
= QLA_FUNCTION_FAILED
;
3198 struct ct_sns_req
*ct_req
;
3200 struct ct_sns_pkt
*ct_sns
;
3202 if (!vha
->flags
.online
)
3205 sp
= qla2x00_get_sp(vha
, NULL
, GFP_KERNEL
);
3209 sp
->type
= SRB_CT_PTHRU_CMD
;
3211 qla2x00_init_timer(sp
, qla2x00_get_async_timeout(vha
) + 2);
3213 sp
->u
.iocb_cmd
.u
.ctarg
.req
= dma_alloc_coherent(&vha
->hw
->pdev
->dev
,
3214 sizeof(struct ct_sns_pkt
), &sp
->u
.iocb_cmd
.u
.ctarg
.req_dma
,
3216 if (!sp
->u
.iocb_cmd
.u
.ctarg
.req
) {
3217 ql_log(ql_log_warn
, vha
, 0xffff,
3218 "Failed to allocate ct_sns request.\n");
3222 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
= dma_alloc_coherent(&vha
->hw
->pdev
->dev
,
3223 sizeof(struct ct_sns_pkt
), &sp
->u
.iocb_cmd
.u
.ctarg
.rsp_dma
,
3225 if (!sp
->u
.iocb_cmd
.u
.ctarg
.rsp
) {
3226 ql_log(ql_log_warn
, vha
, 0xffff,
3227 "Failed to allocate ct_sns request.\n");
3231 ct_sns
= (struct ct_sns_pkt
*)sp
->u
.iocb_cmd
.u
.ctarg
.rsp
;
3232 memset(ct_sns
, 0, sizeof(*ct_sns
));
3234 ct_sns
= (struct ct_sns_pkt
*)sp
->u
.iocb_cmd
.u
.ctarg
.req
;
3235 /* CT_IU preamble */
3236 ct_req
= qla2x00_prep_ct_req(ct_sns
, GPN_ID_CMD
, GPN_ID_RSP_SIZE
);
3239 ct_req
->req
.port_id
.port_id
[0] = id
->b
.domain
;
3240 ct_req
->req
.port_id
.port_id
[1] = id
->b
.area
;
3241 ct_req
->req
.port_id
.port_id
[2] = id
->b
.al_pa
;
3243 sp
->u
.iocb_cmd
.u
.ctarg
.req_size
= GPN_ID_REQ_SIZE
;
3244 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_size
= GPN_ID_RSP_SIZE
;
3245 sp
->u
.iocb_cmd
.u
.ctarg
.nport_handle
= NPH_SNS
;
3247 sp
->u
.iocb_cmd
.timeout
= qla2x00_async_iocb_timeout
;
3248 sp
->done
= qla2x00_async_gpnid_sp_done
;
3250 rval
= qla2x00_start_sp(sp
);
3251 if (rval
!= QLA_SUCCESS
)
3254 ql_dbg(ql_dbg_disc
, vha
, 0xffff,
3255 "Async-%s hdl=%x ID %3phC.\n", sp
->name
,
3256 sp
->handle
, ct_req
->req
.port_id
.port_id
);
3260 if (sp
->u
.iocb_cmd
.u
.ctarg
.req
) {
3261 dma_free_coherent(&vha
->hw
->pdev
->dev
,
3262 sizeof(struct ct_sns_pkt
),
3263 sp
->u
.iocb_cmd
.u
.ctarg
.req
,
3264 sp
->u
.iocb_cmd
.u
.ctarg
.req_dma
);
3265 sp
->u
.iocb_cmd
.u
.ctarg
.req
= NULL
;
3267 if (sp
->u
.iocb_cmd
.u
.ctarg
.rsp
) {
3268 dma_free_coherent(&vha
->hw
->pdev
->dev
,
3269 sizeof(struct ct_sns_pkt
),
3270 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
,
3271 sp
->u
.iocb_cmd
.u
.ctarg
.rsp_dma
);
3272 sp
->u
.iocb_cmd
.u
.ctarg
.rsp
= NULL
;