blob: 917534b9f2216c50784888d514d764e950c7a572 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Andrew Vasquezfa90c542005-10-27 11:10:08 -07002 * QLogic Fibre Channel HBA Driver
Andrew Vasquez01e58d82008-04-03 13:13:13 -07003 * Copyright (c) 2003-2008 QLogic Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Andrew Vasquezfa90c542005-10-27 11:10:08 -07005 * See LICENSE.qla2xxx for copyright and licensing details.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#include "qla_def.h"
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *);
10static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *);
11static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *);
12static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *);
13static int qla2x00_sns_rft_id(scsi_qla_host_t *);
14static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
15
16/**
Andrew Vasquez8c958a92005-07-06 10:30:47 -070017 * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * @ha: HA context
19 * @req_size: request size in bytes
20 * @rsp_size: response size in bytes
21 *
22 * Returns a pointer to the @ha's ms_iocb.
23 */
Andrew Vasquez8c958a92005-07-06 10:30:47 -070024void *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080025qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026{
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080027 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 ms_iocb_entry_t *ms_pkt;
29
30 ms_pkt = ha->ms_iocb;
31 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
32
33 ms_pkt->entry_type = MS_IOCB_TYPE;
34 ms_pkt->entry_count = 1;
35 SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER);
36 ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
Andrew Vasquez00a537b2008-02-28 14:06:11 -080037 ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
39 ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
40 ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
41 ms_pkt->req_bytecount = cpu_to_le32(req_size);
42
43 ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
44 ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
45 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
46
47 ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
48 ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
49 ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
50
51 return (ms_pkt);
52}
53
54/**
Andrew Vasquez8c958a92005-07-06 10:30:47 -070055 * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
56 * @ha: HA context
57 * @req_size: request size in bytes
58 * @rsp_size: response size in bytes
59 *
60 * Returns a pointer to the @ha's ms_iocb.
61 */
62void *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080063qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
Andrew Vasquez8c958a92005-07-06 10:30:47 -070064{
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080065 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez8c958a92005-07-06 10:30:47 -070066 struct ct_entry_24xx *ct_pkt;
67
68 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
69 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
70
71 ct_pkt->entry_type = CT_IOCB_TYPE;
72 ct_pkt->entry_count = 1;
73 ct_pkt->nport_handle = __constant_cpu_to_le16(NPH_SNS);
Andrew Vasquez00a537b2008-02-28 14:06:11 -080074 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
Andrew Vasquez8c958a92005-07-06 10:30:47 -070075 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
76 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
77 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
78 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
79
80 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
81 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
82 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
83
84 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
85 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
86 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -080087 ct_pkt->vp_index = vha->vp_idx;
Andrew Vasquez8c958a92005-07-06 10:30:47 -070088
89 return (ct_pkt);
90}
91
92/**
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
94 * @ct_req: CT request buffer
95 * @cmd: GS command
96 * @rsp_size: response size in bytes
97 *
98 * Returns a pointer to the intitialized @ct_req.
99 */
100static inline struct ct_sns_req *
101qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
102{
103 memset(ct_req, 0, sizeof(struct ct_sns_pkt));
104
105 ct_req->header.revision = 0x01;
106 ct_req->header.gs_type = 0xFC;
107 ct_req->header.gs_subtype = 0x02;
108 ct_req->command = cpu_to_be16(cmd);
109 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
110
111 return (ct_req);
112}
113
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700114static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800115qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt,
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700116 struct ct_sns_rsp *ct_rsp, const char *routine)
117{
118 int rval;
119 uint16_t comp_status;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800120 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700121
122 rval = QLA_FUNCTION_FAILED;
123 if (ms_pkt->entry_status != 0) {
124 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800125 vha->host_no, routine, ms_pkt->entry_status));
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700126 } else {
Andrew Vasqueze4289242007-07-19 15:05:56 -0700127 if (IS_FWI2_CAPABLE(ha))
Andrew Vasquezcdfc82a2006-12-13 19:20:26 -0800128 comp_status = le16_to_cpu(
129 ((struct ct_entry_24xx *)ms_pkt)->comp_status);
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700130 else
131 comp_status = le16_to_cpu(ms_pkt->status);
132 switch (comp_status) {
133 case CS_COMPLETE:
134 case CS_DATA_UNDERRUN:
135 case CS_DATA_OVERRUN: /* Overrun? */
136 if (ct_rsp->header.response !=
137 __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
138 DEBUG2_3(printk("scsi(%ld): %s failed, "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800139 "rejected request:\n", vha->host_no,
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700140 routine));
141 DEBUG2_3(qla2x00_dump_buffer(
142 (uint8_t *)&ct_rsp->header,
143 sizeof(struct ct_rsp_hdr)));
Andrew Vasquez4346b142006-12-13 19:20:28 -0800144 rval = QLA_INVALID_COMMAND;
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700145 } else
146 rval = QLA_SUCCESS;
147 break;
148 default:
149 DEBUG2_3(printk("scsi(%ld): %s failed, completion "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800150 "status (%x).\n", vha->host_no, routine,
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700151 comp_status));
152 break;
153 }
154 }
155 return rval;
156}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
158/**
159 * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
160 * @ha: HA context
161 * @fcport: fcport entry to updated
162 *
163 * Returns 0 on success.
164 */
165int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800166qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 int rval;
169
170 ms_iocb_entry_t *ms_pkt;
171 struct ct_sns_req *ct_req;
172 struct ct_sns_rsp *ct_rsp;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800173 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800175 if (IS_QLA2100(ha) || IS_QLA2200(ha))
176 return qla2x00_sns_ga_nxt(vha, fcport);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178 /* Issue GA_NXT */
179 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800180 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GA_NXT_REQ_SIZE,
Andrew Vasquezfd34f552007-07-19 15:06:00 -0700181 GA_NXT_RSP_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 /* Prepare CT request */
184 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD,
185 GA_NXT_RSP_SIZE);
186 ct_rsp = &ha->ct_sns->p.rsp;
187
188 /* Prepare CT arguments -- port_id */
189 ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
190 ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
191 ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
192
193 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800194 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 sizeof(ms_iocb_entry_t));
196 if (rval != QLA_SUCCESS) {
197 /*EMPTY*/
198 DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800199 vha->host_no, rval));
200 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GA_NXT") !=
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700201 QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 rval = QLA_FUNCTION_FAILED;
203 } else {
204 /* Populate fc_port_t entry. */
205 fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0];
206 fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1];
207 fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2];
208
209 memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name,
210 WWN_SIZE);
211 memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name,
212 WWN_SIZE);
213
214 if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE &&
215 ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE)
216 fcport->d_id.b.domain = 0xf0;
217
218 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
219 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
220 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
221 "portid=%02x%02x%02x.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800222 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 fcport->node_name[0], fcport->node_name[1],
224 fcport->node_name[2], fcport->node_name[3],
225 fcport->node_name[4], fcport->node_name[5],
226 fcport->node_name[6], fcport->node_name[7],
227 fcport->port_name[0], fcport->port_name[1],
228 fcport->port_name[2], fcport->port_name[3],
229 fcport->port_name[4], fcport->port_name[5],
230 fcport->port_name[6], fcport->port_name[7],
231 fcport->d_id.b.domain, fcport->d_id.b.area,
232 fcport->d_id.b.al_pa));
233 }
234
235 return (rval);
236}
237
238/**
239 * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
240 * @ha: HA context
241 * @list: switch info entries to populate
242 *
243 * NOTE: Non-Nx_Ports are not requested.
244 *
245 * Returns 0 on success.
246 */
247int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800248qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249{
250 int rval;
251 uint16_t i;
252
253 ms_iocb_entry_t *ms_pkt;
254 struct ct_sns_req *ct_req;
255 struct ct_sns_rsp *ct_rsp;
256
257 struct ct_sns_gid_pt_data *gid_data;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800258 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800260 if (IS_QLA2100(ha) || IS_QLA2200(ha))
261 return qla2x00_sns_gid_pt(vha, list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 gid_data = NULL;
264
265 /* Issue GID_PT */
266 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800267 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GID_PT_REQ_SIZE,
Andrew Vasquezfd34f552007-07-19 15:06:00 -0700268 GID_PT_RSP_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270 /* Prepare CT request */
271 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
272 GID_PT_RSP_SIZE);
273 ct_rsp = &ha->ct_sns->p.rsp;
274
275 /* Prepare CT arguments -- port_type */
276 ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
277
278 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800279 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 sizeof(ms_iocb_entry_t));
281 if (rval != QLA_SUCCESS) {
282 /*EMPTY*/
283 DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800284 vha->host_no, rval));
285 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GID_PT") !=
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700286 QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 rval = QLA_FUNCTION_FAILED;
288 } else {
289 /* Set port IDs in switch info list. */
290 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
291 gid_data = &ct_rsp->rsp.gid_pt.entries[i];
292 list[i].d_id.b.domain = gid_data->port_id[0];
293 list[i].d_id.b.area = gid_data->port_id[1];
294 list[i].d_id.b.al_pa = gid_data->port_id[2];
Andrew Vasqueza3cbdfa2007-08-13 10:13:18 -0700295 memset(list[i].fabric_port_name, 0, WWN_SIZE);
296 list[i].fp_speed = PORT_SPEED_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
298 /* Last one exit. */
299 if (gid_data->control_byte & BIT_7) {
300 list[i].d_id.b.rsvd_1 = gid_data->control_byte;
301 break;
302 }
303 }
304
305 /*
306 * If we've used all available slots, then the switch is
307 * reporting back more devices than we can handle with this
308 * single call. Return a failed status, and let GA_NXT handle
309 * the overload.
310 */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700311 if (i == MAX_FIBRE_DEVICES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 rval = QLA_FUNCTION_FAILED;
313 }
314
315 return (rval);
316}
317
318/**
319 * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
320 * @ha: HA context
321 * @list: switch info entries to populate
322 *
323 * Returns 0 on success.
324 */
325int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800326qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 int rval;
329 uint16_t i;
330
331 ms_iocb_entry_t *ms_pkt;
332 struct ct_sns_req *ct_req;
333 struct ct_sns_rsp *ct_rsp;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800334 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800336 if (IS_QLA2100(ha) || IS_QLA2200(ha))
337 return qla2x00_sns_gpn_id(vha, list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
340 /* Issue GPN_ID */
341 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800342 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GPN_ID_REQ_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 GPN_ID_RSP_SIZE);
344
345 /* Prepare CT request */
346 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD,
347 GPN_ID_RSP_SIZE);
348 ct_rsp = &ha->ct_sns->p.rsp;
349
350 /* Prepare CT arguments -- port_id */
351 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
352 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
353 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
354
355 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800356 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 sizeof(ms_iocb_entry_t));
358 if (rval != QLA_SUCCESS) {
359 /*EMPTY*/
360 DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800361 "(%d).\n", vha->host_no, rval));
362 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700363 "GPN_ID") != QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 rval = QLA_FUNCTION_FAILED;
365 } else {
366 /* Save portname */
367 memcpy(list[i].port_name,
368 ct_rsp->rsp.gpn_id.port_name, WWN_SIZE);
369 }
370
371 /* Last device exit. */
372 if (list[i].d_id.b.rsvd_1 != 0)
373 break;
374 }
375
376 return (rval);
377}
378
379/**
380 * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
381 * @ha: HA context
382 * @list: switch info entries to populate
383 *
384 * Returns 0 on success.
385 */
386int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800387qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
389 int rval;
390 uint16_t i;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800391 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 ms_iocb_entry_t *ms_pkt;
393 struct ct_sns_req *ct_req;
394 struct ct_sns_rsp *ct_rsp;
395
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800396 if (IS_QLA2100(ha) || IS_QLA2200(ha))
397 return qla2x00_sns_gnn_id(vha, list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
400 /* Issue GNN_ID */
401 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800402 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GNN_ID_REQ_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 GNN_ID_RSP_SIZE);
404
405 /* Prepare CT request */
406 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD,
407 GNN_ID_RSP_SIZE);
408 ct_rsp = &ha->ct_sns->p.rsp;
409
410 /* Prepare CT arguments -- port_id */
411 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
412 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
413 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
414
415 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800416 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 sizeof(ms_iocb_entry_t));
418 if (rval != QLA_SUCCESS) {
419 /*EMPTY*/
420 DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800421 "(%d).\n", vha->host_no, rval));
422 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700423 "GNN_ID") != QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 rval = QLA_FUNCTION_FAILED;
425 } else {
426 /* Save nodename */
427 memcpy(list[i].node_name,
428 ct_rsp->rsp.gnn_id.node_name, WWN_SIZE);
429
430 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
431 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
432 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
433 "portid=%02x%02x%02x.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800434 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 list[i].node_name[0], list[i].node_name[1],
436 list[i].node_name[2], list[i].node_name[3],
437 list[i].node_name[4], list[i].node_name[5],
438 list[i].node_name[6], list[i].node_name[7],
439 list[i].port_name[0], list[i].port_name[1],
440 list[i].port_name[2], list[i].port_name[3],
441 list[i].port_name[4], list[i].port_name[5],
442 list[i].port_name[6], list[i].port_name[7],
443 list[i].d_id.b.domain, list[i].d_id.b.area,
444 list[i].d_id.b.al_pa));
445 }
446
447 /* Last device exit. */
448 if (list[i].d_id.b.rsvd_1 != 0)
449 break;
450 }
451
452 return (rval);
453}
454
455/**
456 * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
457 * @ha: HA context
458 *
459 * Returns 0 on success.
460 */
461int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800462qla2x00_rft_id(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
464 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800465 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 ms_iocb_entry_t *ms_pkt;
467 struct ct_sns_req *ct_req;
468 struct ct_sns_rsp *ct_rsp;
469
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800470 if (IS_QLA2100(ha) || IS_QLA2200(ha))
471 return qla2x00_sns_rft_id(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472
473 /* Issue RFT_ID */
474 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800475 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFT_ID_REQ_SIZE,
Andrew Vasquezfd34f552007-07-19 15:06:00 -0700476 RFT_ID_RSP_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
478 /* Prepare CT request */
479 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
480 RFT_ID_RSP_SIZE);
481 ct_rsp = &ha->ct_sns->p.rsp;
482
483 /* Prepare CT arguments -- port_id, FC-4 types */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800484 ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain;
485 ct_req->req.rft_id.port_id[1] = vha->d_id.b.area;
486 ct_req->req.rft_id.port_id[2] = vha->d_id.b.al_pa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
488 ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
489
490 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800491 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 sizeof(ms_iocb_entry_t));
493 if (rval != QLA_SUCCESS) {
494 /*EMPTY*/
495 DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800496 vha->host_no, rval));
497 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFT_ID") !=
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700498 QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 rval = QLA_FUNCTION_FAILED;
500 } else {
501 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800502 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 }
504
505 return (rval);
506}
507
508/**
509 * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
510 * @ha: HA context
511 *
512 * Returns 0 on success.
513 */
514int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800515qla2x00_rff_id(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800518 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 ms_iocb_entry_t *ms_pkt;
520 struct ct_sns_req *ct_req;
521 struct ct_sns_rsp *ct_rsp;
522
523 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
524 DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800525 "ISP2100/ISP2200.\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 return (QLA_SUCCESS);
527 }
528
529 /* Issue RFF_ID */
530 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800531 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFF_ID_REQ_SIZE,
Andrew Vasquezfd34f552007-07-19 15:06:00 -0700532 RFF_ID_RSP_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
534 /* Prepare CT request */
535 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
536 RFF_ID_RSP_SIZE);
537 ct_rsp = &ha->ct_sns->p.rsp;
538
539 /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800540 ct_req->req.rff_id.port_id[0] = vha->d_id.b.domain;
541 ct_req->req.rff_id.port_id[1] = vha->d_id.b.area;
542 ct_req->req.rff_id.port_id[2] = vha->d_id.b.al_pa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
andrew.vasquez@qlogic.com94036882006-01-13 17:04:54 -0800544 ct_req->req.rff_id.fc4_feature = BIT_1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
546
547 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800548 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 sizeof(ms_iocb_entry_t));
550 if (rval != QLA_SUCCESS) {
551 /*EMPTY*/
552 DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800553 vha->host_no, rval));
554 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFF_ID") !=
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700555 QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 rval = QLA_FUNCTION_FAILED;
557 } else {
558 DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800559 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 }
561
562 return (rval);
563}
564
565/**
566 * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
567 * @ha: HA context
568 *
569 * Returns 0 on success.
570 */
571int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800572qla2x00_rnn_id(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573{
574 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800575 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 ms_iocb_entry_t *ms_pkt;
577 struct ct_sns_req *ct_req;
578 struct ct_sns_rsp *ct_rsp;
579
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800580 if (IS_QLA2100(ha) || IS_QLA2200(ha))
581 return qla2x00_sns_rnn_id(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582
583 /* Issue RNN_ID */
584 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800585 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RNN_ID_REQ_SIZE,
Andrew Vasquezfd34f552007-07-19 15:06:00 -0700586 RNN_ID_RSP_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587
588 /* Prepare CT request */
589 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
590 RNN_ID_RSP_SIZE);
591 ct_rsp = &ha->ct_sns->p.rsp;
592
593 /* Prepare CT arguments -- port_id, node_name */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800594 ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain;
595 ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area;
596 ct_req->req.rnn_id.port_id[2] = vha->d_id.b.al_pa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800598 memcpy(ct_req->req.rnn_id.node_name, vha->node_name, WWN_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599
600 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800601 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 sizeof(ms_iocb_entry_t));
603 if (rval != QLA_SUCCESS) {
604 /*EMPTY*/
605 DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800606 vha->host_no, rval));
607 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RNN_ID") !=
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700608 QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 rval = QLA_FUNCTION_FAILED;
610 } else {
611 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800612 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 }
614
615 return (rval);
616}
617
Andrew Vasquez1620f7c2006-10-02 12:00:44 -0700618void
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800619qla2x00_get_sym_node_name(scsi_qla_host_t *vha, uint8_t *snn)
Andrew Vasquez1620f7c2006-10-02 12:00:44 -0700620{
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800621 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez1620f7c2006-10-02 12:00:44 -0700622 sprintf(snn, "%s FW:v%d.%02d.%02d DVR:v%s",ha->model_number,
623 ha->fw_major_version, ha->fw_minor_version,
624 ha->fw_subminor_version, qla2x00_version_str);
625}
626
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627/**
628 * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
629 * @ha: HA context
630 *
631 * Returns 0 on success.
632 */
633int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800634qla2x00_rsnn_nn(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635{
636 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800637 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 ms_iocb_entry_t *ms_pkt;
639 struct ct_sns_req *ct_req;
640 struct ct_sns_rsp *ct_rsp;
641
642 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
643 DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800644 "ISP2100/ISP2200.\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 return (QLA_SUCCESS);
646 }
647
648 /* Issue RSNN_NN */
649 /* Prepare common MS IOCB */
650 /* Request size adjusted after CT preparation */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800651 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652
653 /* Prepare CT request */
654 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
655 RSNN_NN_RSP_SIZE);
656 ct_rsp = &ha->ct_sns->p.rsp;
657
658 /* Prepare CT arguments -- node_name, symbolic node_name, size */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800659 memcpy(ct_req->req.rsnn_nn.node_name, vha->node_name, WWN_SIZE);
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700660
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 /* Prepare the Symbolic Node Name */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800662 qla2x00_get_sym_node_name(vha, ct_req->req.rsnn_nn.sym_node_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
664 /* Calculate SNN length */
Andrew Vasquez1620f7c2006-10-02 12:00:44 -0700665 ct_req->req.rsnn_nn.name_len =
666 (uint8_t)strlen(ct_req->req.rsnn_nn.sym_node_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667
668 /* Update MS IOCB request */
669 ms_pkt->req_bytecount =
670 cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len);
671 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
672
673 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800674 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 sizeof(ms_iocb_entry_t));
676 if (rval != QLA_SUCCESS) {
677 /*EMPTY*/
678 DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800679 vha->host_no, rval));
680 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RSNN_NN") !=
Andrew Vasquez8c958a92005-07-06 10:30:47 -0700681 QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 rval = QLA_FUNCTION_FAILED;
683 } else {
684 DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800685 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 }
687
688 return (rval);
689}
690
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691/**
692 * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
693 * @ha: HA context
694 * @cmd: GS command
695 * @scmd_len: Subcommand length
696 * @data_size: response size in bytes
697 *
698 * Returns a pointer to the @ha's sns_cmd.
699 */
700static inline struct sns_cmd_pkt *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800701qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 uint16_t data_size)
703{
704 uint16_t wc;
705 struct sns_cmd_pkt *sns_cmd;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800706 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707
708 sns_cmd = ha->sns_cmd;
709 memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
710 wc = data_size / 2; /* Size in 16bit words. */
711 sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc);
712 sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma));
713 sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma));
714 sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len);
715 sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd);
716 wc = (data_size - 16) / 4; /* Size in 32bit words. */
717 sns_cmd->p.cmd.size = cpu_to_le16(wc);
718
719 return (sns_cmd);
720}
721
722/**
723 * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
724 * @ha: HA context
725 * @fcport: fcport entry to updated
726 *
727 * This command uses the old Exectute SNS Command mailbox routine.
728 *
729 * Returns 0 on success.
730 */
731static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800732qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733{
734 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800735 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 struct sns_cmd_pkt *sns_cmd;
737
738 /* Issue GA_NXT. */
739 /* Prepare SNS command request. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800740 sns_cmd = qla2x00_prep_sns_cmd(vha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 GA_NXT_SNS_DATA_SIZE);
742
743 /* Prepare SNS command arguments -- port_id. */
744 sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa;
745 sns_cmd->p.cmd.param[1] = fcport->d_id.b.area;
746 sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
747
748 /* Execute SNS command. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800749 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 sizeof(struct sns_cmd_pkt));
751 if (rval != QLA_SUCCESS) {
752 /*EMPTY*/
753 DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800754 vha->host_no, rval));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 } else if (sns_cmd->p.gan_data[8] != 0x80 ||
756 sns_cmd->p.gan_data[9] != 0x02) {
757 DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800758 "ga_nxt_rsp:\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16));
760 rval = QLA_FUNCTION_FAILED;
761 } else {
762 /* Populate fc_port_t entry. */
763 fcport->d_id.b.domain = sns_cmd->p.gan_data[17];
764 fcport->d_id.b.area = sns_cmd->p.gan_data[18];
765 fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19];
766
767 memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE);
768 memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE);
769
770 if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE &&
771 sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE)
772 fcport->d_id.b.domain = 0xf0;
773
774 DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
775 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
776 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
777 "portid=%02x%02x%02x.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800778 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 fcport->node_name[0], fcport->node_name[1],
780 fcport->node_name[2], fcport->node_name[3],
781 fcport->node_name[4], fcport->node_name[5],
782 fcport->node_name[6], fcport->node_name[7],
783 fcport->port_name[0], fcport->port_name[1],
784 fcport->port_name[2], fcport->port_name[3],
785 fcport->port_name[4], fcport->port_name[5],
786 fcport->port_name[6], fcport->port_name[7],
787 fcport->d_id.b.domain, fcport->d_id.b.area,
788 fcport->d_id.b.al_pa));
789 }
790
791 return (rval);
792}
793
794/**
795 * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
796 * @ha: HA context
797 * @list: switch info entries to populate
798 *
799 * This command uses the old Exectute SNS Command mailbox routine.
800 *
801 * NOTE: Non-Nx_Ports are not requested.
802 *
803 * Returns 0 on success.
804 */
805static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800806qla2x00_sns_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807{
808 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800809 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 uint16_t i;
811 uint8_t *entry;
812 struct sns_cmd_pkt *sns_cmd;
813
814 /* Issue GID_PT. */
815 /* Prepare SNS command request. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800816 sns_cmd = qla2x00_prep_sns_cmd(vha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 GID_PT_SNS_DATA_SIZE);
818
819 /* Prepare SNS command arguments -- port_type. */
820 sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
821
822 /* Execute SNS command. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800823 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 sizeof(struct sns_cmd_pkt));
825 if (rval != QLA_SUCCESS) {
826 /*EMPTY*/
827 DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800828 vha->host_no, rval));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 } else if (sns_cmd->p.gid_data[8] != 0x80 ||
830 sns_cmd->p.gid_data[9] != 0x02) {
831 DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800832 "gid_rsp:\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16));
834 rval = QLA_FUNCTION_FAILED;
835 } else {
836 /* Set port IDs in switch info list. */
837 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
838 entry = &sns_cmd->p.gid_data[(i * 4) + 16];
839 list[i].d_id.b.domain = entry[1];
840 list[i].d_id.b.area = entry[2];
841 list[i].d_id.b.al_pa = entry[3];
842
843 /* Last one exit. */
844 if (entry[0] & BIT_7) {
845 list[i].d_id.b.rsvd_1 = entry[0];
846 break;
847 }
848 }
849
850 /*
851 * If we've used all available slots, then the switch is
852 * reporting back more devices that we can handle with this
853 * single call. Return a failed status, and let GA_NXT handle
854 * the overload.
855 */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700856 if (i == MAX_FIBRE_DEVICES)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 rval = QLA_FUNCTION_FAILED;
858 }
859
860 return (rval);
861}
862
863/**
864 * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
865 * @ha: HA context
866 * @list: switch info entries to populate
867 *
868 * This command uses the old Exectute SNS Command mailbox routine.
869 *
870 * Returns 0 on success.
871 */
872static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800873qla2x00_sns_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874{
875 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800876 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 uint16_t i;
878 struct sns_cmd_pkt *sns_cmd;
879
880 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
881 /* Issue GPN_ID */
882 /* Prepare SNS command request. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800883 sns_cmd = qla2x00_prep_sns_cmd(vha, GPN_ID_CMD,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
885
886 /* Prepare SNS command arguments -- port_id. */
887 sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
888 sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
889 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
890
891 /* Execute SNS command. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800892 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
894 if (rval != QLA_SUCCESS) {
895 /*EMPTY*/
896 DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800897 "(%d).\n", vha->host_no, rval));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 } else if (sns_cmd->p.gpn_data[8] != 0x80 ||
899 sns_cmd->p.gpn_data[9] != 0x02) {
900 DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800901 "request, gpn_rsp:\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16));
903 rval = QLA_FUNCTION_FAILED;
904 } else {
905 /* Save portname */
906 memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16],
907 WWN_SIZE);
908 }
909
910 /* Last device exit. */
911 if (list[i].d_id.b.rsvd_1 != 0)
912 break;
913 }
914
915 return (rval);
916}
917
918/**
919 * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
920 * @ha: HA context
921 * @list: switch info entries to populate
922 *
923 * This command uses the old Exectute SNS Command mailbox routine.
924 *
925 * Returns 0 on success.
926 */
927static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800928qla2x00_sns_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929{
930 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800931 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 uint16_t i;
933 struct sns_cmd_pkt *sns_cmd;
934
935 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
936 /* Issue GNN_ID */
937 /* Prepare SNS command request. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800938 sns_cmd = qla2x00_prep_sns_cmd(vha, GNN_ID_CMD,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
940
941 /* Prepare SNS command arguments -- port_id. */
942 sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
943 sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
944 sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
945
946 /* Execute SNS command. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800947 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
949 if (rval != QLA_SUCCESS) {
950 /*EMPTY*/
951 DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800952 "(%d).\n", vha->host_no, rval));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 } else if (sns_cmd->p.gnn_data[8] != 0x80 ||
954 sns_cmd->p.gnn_data[9] != 0x02) {
955 DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800956 "request, gnn_rsp:\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16));
958 rval = QLA_FUNCTION_FAILED;
959 } else {
960 /* Save nodename */
961 memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16],
962 WWN_SIZE);
963
964 DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
965 "nn %02x%02x%02x%02x%02x%02x%02x%02x "
966 "pn %02x%02x%02x%02x%02x%02x%02x%02x "
967 "portid=%02x%02x%02x.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800968 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 list[i].node_name[0], list[i].node_name[1],
970 list[i].node_name[2], list[i].node_name[3],
971 list[i].node_name[4], list[i].node_name[5],
972 list[i].node_name[6], list[i].node_name[7],
973 list[i].port_name[0], list[i].port_name[1],
974 list[i].port_name[2], list[i].port_name[3],
975 list[i].port_name[4], list[i].port_name[5],
976 list[i].port_name[6], list[i].port_name[7],
977 list[i].d_id.b.domain, list[i].d_id.b.area,
978 list[i].d_id.b.al_pa));
979 }
980
981 /* Last device exit. */
982 if (list[i].d_id.b.rsvd_1 != 0)
983 break;
984 }
985
986 return (rval);
987}
988
989/**
990 * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
991 * @ha: HA context
992 *
993 * This command uses the old Exectute SNS Command mailbox routine.
994 *
995 * Returns 0 on success.
996 */
997static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -0800998qla2x00_sns_rft_id(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999{
1000 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001001 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 struct sns_cmd_pkt *sns_cmd;
1003
1004 /* Issue RFT_ID. */
1005 /* Prepare SNS command request. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001006 sns_cmd = qla2x00_prep_sns_cmd(vha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 RFT_ID_SNS_DATA_SIZE);
1008
1009 /* Prepare SNS command arguments -- port_id, FC-4 types */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001010 sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
1011 sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
1012 sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013
1014 sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */
1015
1016 /* Execute SNS command. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001017 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 sizeof(struct sns_cmd_pkt));
1019 if (rval != QLA_SUCCESS) {
1020 /*EMPTY*/
1021 DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001022 vha->host_no, rval));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 } else if (sns_cmd->p.rft_data[8] != 0x80 ||
1024 sns_cmd->p.rft_data[9] != 0x02) {
1025 DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001026 "rft_rsp:\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16));
1028 rval = QLA_FUNCTION_FAILED;
1029 } else {
1030 DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001031 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 }
1033
1034 return (rval);
1035}
1036
1037/**
1038 * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
1039 * HBA.
1040 * @ha: HA context
1041 *
1042 * This command uses the old Exectute SNS Command mailbox routine.
1043 *
1044 * Returns 0 on success.
1045 */
1046static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001047qla2x00_sns_rnn_id(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048{
1049 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001050 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 struct sns_cmd_pkt *sns_cmd;
1052
1053 /* Issue RNN_ID. */
1054 /* Prepare SNS command request. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001055 sns_cmd = qla2x00_prep_sns_cmd(vha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 RNN_ID_SNS_DATA_SIZE);
1057
1058 /* Prepare SNS command arguments -- port_id, nodename. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001059 sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
1060 sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
1061 sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001063 sns_cmd->p.cmd.param[4] = vha->node_name[7];
1064 sns_cmd->p.cmd.param[5] = vha->node_name[6];
1065 sns_cmd->p.cmd.param[6] = vha->node_name[5];
1066 sns_cmd->p.cmd.param[7] = vha->node_name[4];
1067 sns_cmd->p.cmd.param[8] = vha->node_name[3];
1068 sns_cmd->p.cmd.param[9] = vha->node_name[2];
1069 sns_cmd->p.cmd.param[10] = vha->node_name[1];
1070 sns_cmd->p.cmd.param[11] = vha->node_name[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071
1072 /* Execute SNS command. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001073 rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 sizeof(struct sns_cmd_pkt));
1075 if (rval != QLA_SUCCESS) {
1076 /*EMPTY*/
1077 DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001078 vha->host_no, rval));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 } else if (sns_cmd->p.rnn_data[8] != 0x80 ||
1080 sns_cmd->p.rnn_data[9] != 0x02) {
1081 DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001082 "rnn_rsp:\n", vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16));
1084 rval = QLA_FUNCTION_FAILED;
1085 } else {
1086 DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001087 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 }
1089
1090 return (rval);
1091}
Andrew Vasquezcca53352005-08-26 19:08:30 -07001092
1093/**
Joe Perchesb1c11812008-02-03 17:28:22 +02001094 * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
Andrew Vasquezcca53352005-08-26 19:08:30 -07001095 * @ha: HA context
1096 *
1097 * Returns 0 on success.
1098 */
1099static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001100qla2x00_mgmt_svr_login(scsi_qla_host_t *vha)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001101{
1102 int ret;
1103 uint16_t mb[MAILBOX_REGISTER_COUNT];
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001104 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001105 ret = QLA_SUCCESS;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001106 if (vha->flags.management_server_logged_in)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001107 return ret;
1108
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001109 ha->isp_ops->fabric_login(vha, vha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa,
Joe Carnuccioe1f91602009-04-06 22:33:46 -07001110 mb, BIT_1|BIT_0);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001111 if (mb[0] != MBS_COMMAND_COMPLETE) {
1112 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
1113 "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001114 __func__, vha->host_no, vha->mgmt_svr_loop_id, mb[0], mb[1],
Andrew Vasquezcca53352005-08-26 19:08:30 -07001115 mb[2], mb[6], mb[7]));
1116 ret = QLA_FUNCTION_FAILED;
1117 } else
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001118 vha->flags.management_server_logged_in = 1;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001119
1120 return ret;
1121}
1122
1123/**
1124 * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1125 * @ha: HA context
1126 * @req_size: request size in bytes
1127 * @rsp_size: response size in bytes
1128 *
1129 * Returns a pointer to the @ha's ms_iocb.
1130 */
1131void *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001132qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001133 uint32_t rsp_size)
1134{
1135 ms_iocb_entry_t *ms_pkt;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001136 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001137 ms_pkt = ha->ms_iocb;
1138 memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
1139
1140 ms_pkt->entry_type = MS_IOCB_TYPE;
1141 ms_pkt->entry_count = 1;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001142 SET_TARGET_ID(ha, ms_pkt->loop_id, vha->mgmt_svr_loop_id);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001143 ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
Andrew Vasquez00a537b2008-02-28 14:06:11 -08001144 ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001145 ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1146 ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
1147 ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
1148 ms_pkt->req_bytecount = cpu_to_le32(req_size);
1149
1150 ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1151 ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1152 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
1153
1154 ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1155 ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1156 ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
1157
1158 return ms_pkt;
1159}
1160
1161/**
1162 * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
1163 * @ha: HA context
1164 * @req_size: request size in bytes
1165 * @rsp_size: response size in bytes
1166 *
1167 * Returns a pointer to the @ha's ms_iocb.
1168 */
1169void *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001170qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001171 uint32_t rsp_size)
1172{
1173 struct ct_entry_24xx *ct_pkt;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001174 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001175
1176 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1177 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
1178
1179 ct_pkt->entry_type = CT_IOCB_TYPE;
1180 ct_pkt->entry_count = 1;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001181 ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
Andrew Vasquez00a537b2008-02-28 14:06:11 -08001182 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001183 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1184 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
1185 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
1186 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1187
1188 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1189 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1190 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1191
1192 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1193 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1194 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001195 ct_pkt->vp_index = vha->vp_idx;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001196
1197 return ct_pkt;
1198}
1199
1200static inline ms_iocb_entry_t *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001201qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001202{
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001203 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001204 ms_iocb_entry_t *ms_pkt = ha->ms_iocb;
1205 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1206
Andrew Vasqueze4289242007-07-19 15:05:56 -07001207 if (IS_FWI2_CAPABLE(ha)) {
Andrew Vasquezcca53352005-08-26 19:08:30 -07001208 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1209 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1210 } else {
1211 ms_pkt->req_bytecount = cpu_to_le32(req_size);
1212 ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
1213 }
1214
1215 return ms_pkt;
1216}
1217
1218/**
1219 * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
1220 * @ct_req: CT request buffer
1221 * @cmd: GS command
1222 * @rsp_size: response size in bytes
1223 *
1224 * Returns a pointer to the intitialized @ct_req.
1225 */
1226static inline struct ct_sns_req *
1227qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd,
1228 uint16_t rsp_size)
1229{
1230 memset(ct_req, 0, sizeof(struct ct_sns_pkt));
1231
1232 ct_req->header.revision = 0x01;
1233 ct_req->header.gs_type = 0xFA;
1234 ct_req->header.gs_subtype = 0x10;
1235 ct_req->command = cpu_to_be16(cmd);
1236 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
1237
1238 return ct_req;
1239}
1240
1241/**
1242 * qla2x00_fdmi_rhba() -
1243 * @ha: HA context
1244 *
1245 * Returns 0 on success.
1246 */
1247static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001248qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001249{
1250 int rval, alen;
1251 uint32_t size, sn;
1252
1253 ms_iocb_entry_t *ms_pkt;
1254 struct ct_sns_req *ct_req;
1255 struct ct_sns_rsp *ct_rsp;
1256 uint8_t *entries;
1257 struct ct_fdmi_hba_attr *eiter;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001258 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001259
1260 /* Issue RHBA */
1261 /* Prepare common MS IOCB */
1262 /* Request size adjusted after CT preparation */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001263 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001264
1265 /* Prepare CT request */
1266 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD,
1267 RHBA_RSP_SIZE);
1268 ct_rsp = &ha->ct_sns->p.rsp;
1269
1270 /* Prepare FDMI command arguments -- attribute block, attributes. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001271 memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001272 ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1);
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001273 memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001274 size = 2 * WWN_SIZE + 4 + 4;
1275
1276 /* Attributes */
1277 ct_req->req.rhba.attrs.count =
1278 __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT);
1279 entries = ct_req->req.rhba.hba_identifier;
1280
1281 /* Nodename. */
1282 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1283 eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME);
1284 eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE);
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001285 memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001286 size += 4 + WWN_SIZE;
1287
1288 DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001289 __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001290 eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2],
1291 eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5],
1292 eiter->a.node_name[6], eiter->a.node_name[7]));
1293
1294 /* Manufacturer. */
1295 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1296 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER);
1297 strcpy(eiter->a.manufacturer, "QLogic Corporation");
1298 alen = strlen(eiter->a.manufacturer);
1299 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1300 eiter->len = cpu_to_be16(4 + alen);
1301 size += 4 + alen;
1302
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001303 DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001304 eiter->a.manufacturer));
1305
1306 /* Serial number. */
1307 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1308 eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER);
1309 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
1310 sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000);
1311 alen = strlen(eiter->a.serial_num);
1312 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1313 eiter->len = cpu_to_be16(4 + alen);
1314 size += 4 + alen;
1315
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001316 DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001317 eiter->a.serial_num));
1318
1319 /* Model name. */
1320 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1321 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL);
1322 strcpy(eiter->a.model, ha->model_number);
1323 alen = strlen(eiter->a.model);
1324 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1325 eiter->len = cpu_to_be16(4 + alen);
1326 size += 4 + alen;
1327
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001328 DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001329 eiter->a.model));
1330
1331 /* Model description. */
1332 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1333 eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
1334 if (ha->model_desc)
1335 strncpy(eiter->a.model_desc, ha->model_desc, 80);
1336 alen = strlen(eiter->a.model_desc);
1337 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1338 eiter->len = cpu_to_be16(4 + alen);
1339 size += 4 + alen;
1340
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001341 DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001342 eiter->a.model_desc));
1343
1344 /* Hardware version. */
1345 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1346 eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION);
1347 strcpy(eiter->a.hw_version, ha->adapter_id);
1348 alen = strlen(eiter->a.hw_version);
1349 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1350 eiter->len = cpu_to_be16(4 + alen);
1351 size += 4 + alen;
1352
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001353 DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001354 eiter->a.hw_version));
1355
1356 /* Driver version. */
1357 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1358 eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION);
1359 strcpy(eiter->a.driver_version, qla2x00_version_str);
1360 alen = strlen(eiter->a.driver_version);
1361 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1362 eiter->len = cpu_to_be16(4 + alen);
1363 size += 4 + alen;
1364
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001365 DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001366 eiter->a.driver_version));
1367
1368 /* Option ROM version. */
1369 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1370 eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION);
1371 strcpy(eiter->a.orom_version, "0.00");
1372 alen = strlen(eiter->a.orom_version);
1373 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1374 eiter->len = cpu_to_be16(4 + alen);
1375 size += 4 + alen;
1376
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001377 DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001378 eiter->a.orom_version));
1379
1380 /* Firmware version */
1381 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1382 eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001383 ha->isp_ops->fw_version_str(vha, eiter->a.fw_version);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001384 alen = strlen(eiter->a.fw_version);
1385 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1386 eiter->len = cpu_to_be16(4 + alen);
1387 size += 4 + alen;
1388
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001389 DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001390 eiter->a.fw_version));
1391
1392 /* Update MS request size. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001393 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001394
1395 DEBUG13(printk("%s(%ld): RHBA identifier="
1396 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001397 vha->host_no, ct_req->req.rhba.hba_identifier[0],
Andrew Vasquezcca53352005-08-26 19:08:30 -07001398 ct_req->req.rhba.hba_identifier[1],
1399 ct_req->req.rhba.hba_identifier[2],
1400 ct_req->req.rhba.hba_identifier[3],
1401 ct_req->req.rhba.hba_identifier[4],
1402 ct_req->req.rhba.hba_identifier[5],
1403 ct_req->req.rhba.hba_identifier[6],
1404 ct_req->req.rhba.hba_identifier[7], size));
1405 DEBUG13(qla2x00_dump_buffer(entries, size));
1406
1407 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001408 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001409 sizeof(ms_iocb_entry_t));
1410 if (rval != QLA_SUCCESS) {
1411 /*EMPTY*/
1412 DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001413 vha->host_no, rval));
1414 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") !=
Andrew Vasquezcca53352005-08-26 19:08:30 -07001415 QLA_SUCCESS) {
1416 rval = QLA_FUNCTION_FAILED;
1417 if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
1418 ct_rsp->header.explanation_code ==
1419 CT_EXPL_ALREADY_REGISTERED) {
1420 DEBUG2_13(printk("%s(%ld): HBA already registered.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001421 __func__, vha->host_no));
Andrew Vasquezcca53352005-08-26 19:08:30 -07001422 rval = QLA_ALREADY_REGISTERED;
1423 }
1424 } else {
1425 DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001426 vha->host_no));
Andrew Vasquezcca53352005-08-26 19:08:30 -07001427 }
1428
1429 return rval;
1430}
1431
1432/**
1433 * qla2x00_fdmi_dhba() -
1434 * @ha: HA context
1435 *
1436 * Returns 0 on success.
1437 */
1438static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001439qla2x00_fdmi_dhba(scsi_qla_host_t *vha)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001440{
1441 int rval;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001442 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001443 ms_iocb_entry_t *ms_pkt;
1444 struct ct_sns_req *ct_req;
1445 struct ct_sns_rsp *ct_rsp;
1446
1447 /* Issue RPA */
1448 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001449 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, DHBA_REQ_SIZE,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001450 DHBA_RSP_SIZE);
1451
1452 /* Prepare CT request */
1453 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD,
1454 DHBA_RSP_SIZE);
1455 ct_rsp = &ha->ct_sns->p.rsp;
1456
1457 /* Prepare FDMI command arguments -- portname. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001458 memcpy(ct_req->req.dhba.port_name, vha->port_name, WWN_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001459
1460 DEBUG13(printk("%s(%ld): DHBA portname="
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001461 "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001462 ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1],
1463 ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3],
1464 ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5],
1465 ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7]));
1466
1467 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001468 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001469 sizeof(ms_iocb_entry_t));
1470 if (rval != QLA_SUCCESS) {
1471 /*EMPTY*/
1472 DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001473 vha->host_no, rval));
1474 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "DHBA") !=
Andrew Vasquezcca53352005-08-26 19:08:30 -07001475 QLA_SUCCESS) {
1476 rval = QLA_FUNCTION_FAILED;
1477 } else {
1478 DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001479 vha->host_no));
Andrew Vasquezcca53352005-08-26 19:08:30 -07001480 }
1481
1482 return rval;
1483}
1484
1485/**
1486 * qla2x00_fdmi_rpa() -
1487 * @ha: HA context
1488 *
1489 * Returns 0 on success.
1490 */
1491static int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001492qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001493{
1494 int rval, alen;
1495 uint32_t size, max_frame_size;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001496 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezcca53352005-08-26 19:08:30 -07001497 ms_iocb_entry_t *ms_pkt;
1498 struct ct_sns_req *ct_req;
1499 struct ct_sns_rsp *ct_rsp;
1500 uint8_t *entries;
1501 struct ct_fdmi_port_attr *eiter;
1502 struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb;
1503
1504 /* Issue RPA */
1505 /* Prepare common MS IOCB */
1506 /* Request size adjusted after CT preparation */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001507 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001508
1509 /* Prepare CT request */
1510 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD,
1511 RPA_RSP_SIZE);
1512 ct_rsp = &ha->ct_sns->p.rsp;
1513
1514 /* Prepare FDMI command arguments -- attribute block, attributes. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001515 memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001516 size = WWN_SIZE + 4;
1517
1518 /* Attributes */
1519 ct_req->req.rpa.attrs.count =
Andrew Vasquez8a85e172007-09-20 14:07:41 -07001520 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT - 1);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001521 entries = ct_req->req.rpa.port_name;
1522
1523 /* FC4 types. */
1524 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1525 eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES);
1526 eiter->len = __constant_cpu_to_be16(4 + 32);
1527 eiter->a.fc4_types[2] = 0x01;
1528 size += 4 + 32;
1529
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001530 DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__,
1531 vha->host_no, eiter->a.fc4_types[2],
1532 eiter->a.fc4_types[1]));
Andrew Vasquezcca53352005-08-26 19:08:30 -07001533
1534 /* Supported speed. */
1535 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1536 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
1537 eiter->len = __constant_cpu_to_be16(4 + 4);
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001538 if (IS_QLA81XX(ha))
1539 eiter->a.sup_speed = __constant_cpu_to_be32(
1540 FDMI_PORT_SPEED_10GB);
1541 else if (IS_QLA25XX(ha))
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001542 eiter->a.sup_speed = __constant_cpu_to_be32(
1543 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
1544 FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB);
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001545 else if (IS_QLA24XX_TYPE(ha))
Andrew Vasquez58815692007-07-19 15:05:58 -07001546 eiter->a.sup_speed = __constant_cpu_to_be32(
1547 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
1548 FDMI_PORT_SPEED_4GB);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001549 else if (IS_QLA23XX(ha))
Andrew Vasquez58815692007-07-19 15:05:58 -07001550 eiter->a.sup_speed =__constant_cpu_to_be32(
1551 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001552 else
Andrew Vasquez58815692007-07-19 15:05:58 -07001553 eiter->a.sup_speed = __constant_cpu_to_be32(
1554 FDMI_PORT_SPEED_1GB);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001555 size += 4 + 4;
1556
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001557 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001558 eiter->a.sup_speed));
1559
1560 /* Current speed. */
1561 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1562 eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED);
1563 eiter->len = __constant_cpu_to_be16(4 + 4);
1564 switch (ha->link_data_rate) {
Andrew Vasquez58815692007-07-19 15:05:58 -07001565 case PORT_SPEED_1GB:
1566 eiter->a.cur_speed =
1567 __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001568 break;
Andrew Vasquez58815692007-07-19 15:05:58 -07001569 case PORT_SPEED_2GB:
1570 eiter->a.cur_speed =
1571 __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001572 break;
Andrew Vasquez58815692007-07-19 15:05:58 -07001573 case PORT_SPEED_4GB:
1574 eiter->a.cur_speed =
1575 __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB);
1576 break;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001577 case PORT_SPEED_8GB:
1578 eiter->a.cur_speed =
1579 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB);
1580 break;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001581 case PORT_SPEED_10GB:
1582 eiter->a.cur_speed =
1583 __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB);
1584 break;
Andrew Vasquez58815692007-07-19 15:05:58 -07001585 default:
1586 eiter->a.cur_speed =
1587 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001588 break;
1589 }
1590 size += 4 + 4;
1591
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001592 DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001593 eiter->a.cur_speed));
1594
1595 /* Max frame size. */
1596 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1597 eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
1598 eiter->len = __constant_cpu_to_be16(4 + 4);
Andrew Vasqueze4289242007-07-19 15:05:56 -07001599 max_frame_size = IS_FWI2_CAPABLE(ha) ?
Seokmann Juc6852c42008-04-24 15:21:29 -07001600 le16_to_cpu(icb24->frame_payload_size):
1601 le16_to_cpu(ha->init_cb->frame_payload_size);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001602 eiter->a.max_frame_size = cpu_to_be32(max_frame_size);
1603 size += 4 + 4;
1604
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001605 DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001606 eiter->a.max_frame_size));
1607
1608 /* OS device name. */
1609 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1610 eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
Andrew Vasquez8a85e172007-09-20 14:07:41 -07001611 strcpy(eiter->a.os_dev_name, QLA2XXX_DRIVER_NAME);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001612 alen = strlen(eiter->a.os_dev_name);
1613 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1614 eiter->len = cpu_to_be16(4 + alen);
1615 size += 4 + alen;
1616
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001617 DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, vha->host_no,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001618 eiter->a.os_dev_name));
1619
Andrew Vasqueza740a3f2006-10-02 12:00:45 -07001620 /* Hostname. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001621 if (strlen(fc_host_system_hostname(vha->host))) {
Andrew Vasquez8a85e172007-09-20 14:07:41 -07001622 ct_req->req.rpa.attrs.count =
1623 __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT);
Andrew Vasqueza740a3f2006-10-02 12:00:45 -07001624 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1625 eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME);
1626 snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001627 "%s", fc_host_system_hostname(vha->host));
Andrew Vasqueza740a3f2006-10-02 12:00:45 -07001628 alen = strlen(eiter->a.host_name);
1629 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1630 eiter->len = cpu_to_be16(4 + alen);
1631 size += 4 + alen;
1632
1633 DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__,
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001634 vha->host_no, eiter->a.host_name));
Andrew Vasqueza740a3f2006-10-02 12:00:45 -07001635 }
1636
Andrew Vasquezcca53352005-08-26 19:08:30 -07001637 /* Update MS request size. */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001638 qla2x00_update_ms_fdmi_iocb(vha, size + 16);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001639
1640 DEBUG13(printk("%s(%ld): RPA portname="
1641 "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001642 vha->host_no, ct_req->req.rpa.port_name[0],
Andrew Vasquezcca53352005-08-26 19:08:30 -07001643 ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2],
1644 ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4],
1645 ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6],
1646 ct_req->req.rpa.port_name[7], size));
1647 DEBUG13(qla2x00_dump_buffer(entries, size));
1648
1649 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001650 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Andrew Vasquezcca53352005-08-26 19:08:30 -07001651 sizeof(ms_iocb_entry_t));
1652 if (rval != QLA_SUCCESS) {
1653 /*EMPTY*/
1654 DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001655 vha->host_no, rval));
1656 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") !=
Andrew Vasquezcca53352005-08-26 19:08:30 -07001657 QLA_SUCCESS) {
1658 rval = QLA_FUNCTION_FAILED;
1659 } else {
1660 DEBUG2(printk("scsi(%ld): RPA exiting normally.\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001661 vha->host_no));
Andrew Vasquezcca53352005-08-26 19:08:30 -07001662 }
1663
1664 return rval;
1665}
1666
1667/**
1668 * qla2x00_fdmi_register() -
1669 * @ha: HA context
1670 *
1671 * Returns 0 on success.
1672 */
1673int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001674qla2x00_fdmi_register(scsi_qla_host_t *vha)
Andrew Vasquezcca53352005-08-26 19:08:30 -07001675{
1676 int rval;
1677
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001678 rval = qla2x00_mgmt_svr_login(vha);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001679 if (rval)
1680 return rval;
1681
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001682 rval = qla2x00_fdmi_rhba(vha);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001683 if (rval) {
1684 if (rval != QLA_ALREADY_REGISTERED)
1685 return rval;
1686
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001687 rval = qla2x00_fdmi_dhba(vha);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001688 if (rval)
1689 return rval;
1690
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001691 rval = qla2x00_fdmi_rhba(vha);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001692 if (rval)
1693 return rval;
1694 }
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001695 rval = qla2x00_fdmi_rpa(vha);
Andrew Vasquezcca53352005-08-26 19:08:30 -07001696
1697 return rval;
1698}
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001699
1700/**
1701 * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
1702 * @ha: HA context
1703 * @list: switch info entries to populate
1704 *
1705 * Returns 0 on success.
1706 */
1707int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001708qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list)
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001709{
1710 int rval;
1711 uint16_t i;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001712 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001713 ms_iocb_entry_t *ms_pkt;
1714 struct ct_sns_req *ct_req;
1715 struct ct_sns_rsp *ct_rsp;
1716
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001717 if (!IS_IIDMA_CAPABLE(ha))
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001718 return QLA_FUNCTION_FAILED;
1719
1720 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
1721 /* Issue GFPN_ID */
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001722 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001723 ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFPN_ID_REQ_SIZE,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001724 GFPN_ID_RSP_SIZE);
1725
1726 /* Prepare CT request */
1727 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD,
1728 GFPN_ID_RSP_SIZE);
1729 ct_rsp = &ha->ct_sns->p.rsp;
1730
1731 /* Prepare CT arguments -- port_id */
1732 ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
1733 ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
1734 ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
1735
1736 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001737 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001738 sizeof(ms_iocb_entry_t));
1739 if (rval != QLA_SUCCESS) {
1740 /*EMPTY*/
1741 DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001742 "failed (%d).\n", vha->host_no, rval));
1743 } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001744 "GFPN_ID") != QLA_SUCCESS) {
1745 rval = QLA_FUNCTION_FAILED;
1746 } else {
1747 /* Save fabric portname */
1748 memcpy(list[i].fabric_port_name,
1749 ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE);
1750 }
1751
1752 /* Last device exit. */
1753 if (list[i].d_id.b.rsvd_1 != 0)
1754 break;
1755 }
1756
1757 return (rval);
1758}
1759
1760static inline void *
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001761qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001762 uint32_t rsp_size)
1763{
1764 struct ct_entry_24xx *ct_pkt;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001765 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001766 ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1767 memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
1768
1769 ct_pkt->entry_type = CT_IOCB_TYPE;
1770 ct_pkt->entry_count = 1;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001771 ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
Andrew Vasquez00a537b2008-02-28 14:06:11 -08001772 ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001773 ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
1774 ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
1775 ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
1776 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1777
1778 ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1779 ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1780 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1781
1782 ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
1783 ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
1784 ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001785 ct_pkt->vp_index = vha->vp_idx;
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001786
1787 return ct_pkt;
1788}
1789
1790
1791static inline struct ct_sns_req *
1792qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd,
1793 uint16_t rsp_size)
1794{
1795 memset(ct_req, 0, sizeof(struct ct_sns_pkt));
1796
1797 ct_req->header.revision = 0x01;
1798 ct_req->header.gs_type = 0xFA;
1799 ct_req->header.gs_subtype = 0x01;
1800 ct_req->command = cpu_to_be16(cmd);
1801 ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
1802
1803 return ct_req;
1804}
1805
1806/**
1807 * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
1808 * @ha: HA context
1809 * @list: switch info entries to populate
1810 *
1811 * Returns 0 on success.
1812 */
1813int
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001814qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list)
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001815{
1816 int rval;
1817 uint16_t i;
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001818 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001819 ms_iocb_entry_t *ms_pkt;
1820 struct ct_sns_req *ct_req;
1821 struct ct_sns_rsp *ct_rsp;
1822
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001823 if (!IS_IIDMA_CAPABLE(ha))
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001824 return QLA_FUNCTION_FAILED;
Andrew Vasquez4346b142006-12-13 19:20:28 -08001825 if (!ha->flags.gpsc_supported)
1826 return QLA_FUNCTION_FAILED;
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001827
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001828 rval = qla2x00_mgmt_svr_login(vha);
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001829 if (rval)
1830 return rval;
1831
1832 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
1833 /* Issue GFPN_ID */
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001834 /* Prepare common MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001835 ms_pkt = qla24xx_prep_ms_fm_iocb(vha, GPSC_REQ_SIZE,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001836 GPSC_RSP_SIZE);
1837
1838 /* Prepare CT request */
1839 ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req,
1840 GPSC_CMD, GPSC_RSP_SIZE);
1841 ct_rsp = &ha->ct_sns->p.rsp;
1842
1843 /* Prepare CT arguments -- port_name */
1844 memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name,
1845 WWN_SIZE);
1846
1847 /* Execute MS IOCB */
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001848 rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001849 sizeof(ms_iocb_entry_t));
1850 if (rval != QLA_SUCCESS) {
1851 /*EMPTY*/
1852 DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001853 "failed (%d).\n", vha->host_no, rval));
1854 } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
Andrew Vasquez4346b142006-12-13 19:20:28 -08001855 "GPSC")) != QLA_SUCCESS) {
1856 /* FM command unsupported? */
1857 if (rval == QLA_INVALID_COMMAND &&
Andrew Vasquez3fe7cfb2008-04-03 13:13:23 -07001858 (ct_rsp->header.reason_code ==
1859 CT_REASON_INVALID_COMMAND_CODE ||
1860 ct_rsp->header.reason_code ==
1861 CT_REASON_COMMAND_UNSUPPORTED)) {
Andrew Vasquez4346b142006-12-13 19:20:28 -08001862 DEBUG2(printk("scsi(%ld): GPSC command "
1863 "unsupported, disabling query...\n",
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001864 vha->host_no));
Andrew Vasquez4346b142006-12-13 19:20:28 -08001865 ha->flags.gpsc_supported = 0;
1866 rval = QLA_FUNCTION_FAILED;
1867 break;
1868 }
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001869 rval = QLA_FUNCTION_FAILED;
1870 } else {
Andrew Vasqueza3cbdfa2007-08-13 10:13:18 -07001871 /* Save port-speed */
1872 switch (be16_to_cpu(ct_rsp->rsp.gpsc.speed)) {
1873 case BIT_15:
1874 list[i].fp_speed = PORT_SPEED_1GB;
1875 break;
1876 case BIT_14:
1877 list[i].fp_speed = PORT_SPEED_2GB;
1878 break;
1879 case BIT_13:
1880 list[i].fp_speed = PORT_SPEED_4GB;
1881 break;
Andrew Vasquez9f8fdde2009-06-03 09:55:22 -07001882 case BIT_12:
1883 list[i].fp_speed = PORT_SPEED_10GB;
1884 break;
Andrew Vasqueza3cbdfa2007-08-13 10:13:18 -07001885 case BIT_11:
1886 list[i].fp_speed = PORT_SPEED_8GB;
1887 break;
1888 }
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001889
1890 DEBUG2_3(printk("scsi(%ld): GPSC ext entry - "
1891 "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x "
Anirban Chakraborty7b867cf2008-11-06 10:40:19 -08001892 "speed=%04x.\n", vha->host_no,
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001893 list[i].fabric_port_name[0],
1894 list[i].fabric_port_name[1],
1895 list[i].fabric_port_name[2],
1896 list[i].fabric_port_name[3],
1897 list[i].fabric_port_name[4],
1898 list[i].fabric_port_name[5],
1899 list[i].fabric_port_name[6],
1900 list[i].fabric_port_name[7],
Andrew Vasqueza3cbdfa2007-08-13 10:13:18 -07001901 be16_to_cpu(ct_rsp->rsp.gpsc.speeds),
1902 be16_to_cpu(ct_rsp->rsp.gpsc.speed)));
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001903 }
1904
1905 /* Last device exit. */
1906 if (list[i].d_id.b.rsvd_1 != 0)
1907 break;
1908 }
1909
1910 return (rval);
1911}