Commit | Line | Data |
---|---|---|
dea3101e JB |
1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | |
c44ce173 | 3 | * Fibre Channel Host Bus Adapters. * |
e47c9093 | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
c44ce173 | 5 | * EMULEX and SLI are trademarks of Emulex. * |
dea3101e JB |
6 | * www.emulex.com * |
7 | * * | |
8 | * This program is free software; you can redistribute it and/or * | |
c44ce173 JSEC |
9 | * modify it under the terms of version 2 of the GNU General * |
10 | * Public License as published by the Free Software Foundation. * | |
11 | * This program is distributed in the hope that it will be useful. * | |
12 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * | |
13 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * | |
14 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * | |
15 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * | |
16 | * TO BE LEGALLY INVALID. See the GNU General Public License for * | |
17 | * more details, a copy of which can be found in the file COPYING * | |
18 | * included with this package. * | |
dea3101e JB |
19 | *******************************************************************/ |
20 | ||
21 | /* | |
09372820 | 22 | * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS |
dea3101e JB |
23 | */ |
24 | ||
25 | #include <linux/blkdev.h> | |
26 | #include <linux/pci.h> | |
27 | #include <linux/interrupt.h> | |
28 | #include <linux/utsname.h> | |
29 | ||
91886523 | 30 | #include <scsi/scsi.h> |
dea3101e JB |
31 | #include <scsi/scsi_device.h> |
32 | #include <scsi/scsi_host.h> | |
f888ba3c | 33 | #include <scsi/scsi_transport_fc.h> |
dea3101e JB |
34 | |
35 | #include "lpfc_hw.h" | |
36 | #include "lpfc_sli.h" | |
37 | #include "lpfc_disc.h" | |
38 | #include "lpfc_scsi.h" | |
39 | #include "lpfc.h" | |
40 | #include "lpfc_logmsg.h" | |
41 | #include "lpfc_crtn.h" | |
42 | #include "lpfc_version.h" | |
92d7f7b0 | 43 | #include "lpfc_vport.h" |
858c9f6c | 44 | #include "lpfc_debugfs.h" |
dea3101e JB |
45 | |
46 | #define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver | |
47 | * incapable of reporting */ | |
48 | #define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ | |
49 | #define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ | |
50 | #define HBA_PORTSPEED_4GBIT 8 /* 4 GBit/sec */ | |
51 | #define HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */ | |
52 | #define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ | |
53 | #define HBA_PORTSPEED_NOT_NEGOTIATED 5 /* Speed not established */ | |
54 | ||
55 | #define FOURBYTES 4 | |
56 | ||
57 | ||
58 | static char *lpfc_release_version = LPFC_DRIVER_VERSION; | |
59 | ||
ed957684 | 60 | static void |
9c2face6 JS |
61 | lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq, |
62 | struct lpfc_dmabuf *mp, uint32_t size) | |
ed957684 JS |
63 | { |
64 | if (!mp) { | |
9c2face6 | 65 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
97eab634 | 66 | "0146 Ignoring unsolicited CT No HBQ " |
9c2face6 JS |
67 | "status = x%x\n", |
68 | piocbq->iocb.ulpStatus); | |
ed957684 | 69 | } |
9c2face6 JS |
70 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
71 | "0145 Ignoring unsolicted CT HBQ Size:%d " | |
72 | "status = x%x\n", | |
73 | size, piocbq->iocb.ulpStatus); | |
ed957684 JS |
74 | } |
75 | ||
76 | static void | |
9c2face6 JS |
77 | lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq, |
78 | struct lpfc_dmabuf *mp, uint32_t size) | |
ed957684 | 79 | { |
9c2face6 | 80 | lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size); |
ed957684 JS |
81 | } |
82 | ||
dea3101e | 83 | void |
2e0fef85 JS |
84 | lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
85 | struct lpfc_iocbq *piocbq) | |
dea3101e | 86 | { |
92d7f7b0 | 87 | |
ed957684 | 88 | struct lpfc_dmabuf *mp = NULL; |
dea3101e | 89 | IOCB_t *icmd = &piocbq->iocb; |
ed957684 JS |
90 | int i; |
91 | struct lpfc_iocbq *iocbq; | |
92 | dma_addr_t paddr; | |
93 | uint32_t size; | |
9c2face6 JS |
94 | struct list_head head; |
95 | struct lpfc_dmabuf *bdeBuf; | |
dea3101e | 96 | |
92d7f7b0 JS |
97 | if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) { |
98 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); | |
99 | } else if ((icmd->ulpStatus == IOSTAT_LOCAL_REJECT) && | |
100 | ((icmd->un.ulpWord[4] & 0xff) == IOERR_RCV_BUFFER_WAITING)) { | |
dea3101e JB |
101 | /* Not enough posted buffers; Try posting more buffers */ |
102 | phba->fc_stat.NoRcvBuf++; | |
92d7f7b0 | 103 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
495a714c | 104 | lpfc_post_buffer(phba, pring, 2); |
dea3101e JB |
105 | return; |
106 | } | |
107 | ||
108 | /* If there are no BDEs associated with this IOCB, | |
109 | * there is nothing to do. | |
110 | */ | |
111 | if (icmd->ulpBdeCount == 0) | |
112 | return; | |
113 | ||
ed957684 | 114 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
9c2face6 JS |
115 | INIT_LIST_HEAD(&head); |
116 | list_add_tail(&head, &piocbq->list); | |
117 | list_for_each_entry(iocbq, &head, list) { | |
ed957684 | 118 | icmd = &iocbq->iocb; |
9c2face6 | 119 | if (icmd->ulpBdeCount == 0) |
ed957684 | 120 | continue; |
9c2face6 JS |
121 | bdeBuf = iocbq->context2; |
122 | iocbq->context2 = NULL; | |
ed957684 | 123 | size = icmd->un.cont64[0].tus.f.bdeSize; |
9c2face6 JS |
124 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size); |
125 | lpfc_in_buf_free(phba, bdeBuf); | |
ed957684 | 126 | if (icmd->ulpBdeCount == 2) { |
9c2face6 JS |
127 | bdeBuf = iocbq->context3; |
128 | iocbq->context3 = NULL; | |
129 | size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize; | |
130 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, | |
131 | size); | |
132 | lpfc_in_buf_free(phba, bdeBuf); | |
ed957684 | 133 | } |
dea3101e | 134 | } |
9c2face6 | 135 | list_del(&head); |
ed957684 | 136 | } else { |
d7c255b2 JS |
137 | INIT_LIST_HEAD(&head); |
138 | list_add_tail(&head, &piocbq->list); | |
139 | list_for_each_entry(iocbq, &head, list) { | |
ed957684 | 140 | icmd = &iocbq->iocb; |
9c2face6 | 141 | if (icmd->ulpBdeCount == 0) |
d7c255b2 | 142 | lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0); |
ed957684 JS |
143 | for (i = 0; i < icmd->ulpBdeCount; i++) { |
144 | paddr = getPaddr(icmd->un.cont64[i].addrHigh, | |
145 | icmd->un.cont64[i].addrLow); | |
146 | mp = lpfc_sli_ringpostbuf_get(phba, pring, | |
147 | paddr); | |
148 | size = icmd->un.cont64[i].tus.f.bdeSize; | |
d7c255b2 | 149 | lpfc_ct_unsol_buffer(phba, iocbq, mp, size); |
92d7f7b0 | 150 | lpfc_in_buf_free(phba, mp); |
ed957684 | 151 | } |
495a714c | 152 | lpfc_post_buffer(phba, pring, i); |
dea3101e | 153 | } |
d7c255b2 | 154 | list_del(&head); |
dea3101e | 155 | } |
dea3101e JB |
156 | } |
157 | ||
158 | static void | |
2e0fef85 | 159 | lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist) |
dea3101e JB |
160 | { |
161 | struct lpfc_dmabuf *mlast, *next_mlast; | |
162 | ||
163 | list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { | |
164 | lpfc_mbuf_free(phba, mlast->virt, mlast->phys); | |
165 | list_del(&mlast->list); | |
166 | kfree(mlast); | |
167 | } | |
168 | lpfc_mbuf_free(phba, mlist->virt, mlist->phys); | |
169 | kfree(mlist); | |
170 | return; | |
171 | } | |
172 | ||
173 | static struct lpfc_dmabuf * | |
2e0fef85 | 174 | lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl, |
dea3101e JB |
175 | uint32_t size, int *entries) |
176 | { | |
177 | struct lpfc_dmabuf *mlist = NULL; | |
178 | struct lpfc_dmabuf *mp; | |
179 | int cnt, i = 0; | |
180 | ||
09372820 | 181 | /* We get chunks of FCELSSIZE */ |
dea3101e JB |
182 | cnt = size > FCELSSIZE ? FCELSSIZE: size; |
183 | ||
184 | while (size) { | |
185 | /* Allocate buffer for rsp payload */ | |
186 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | |
187 | if (!mp) { | |
188 | if (mlist) | |
189 | lpfc_free_ct_rsp(phba, mlist); | |
190 | return NULL; | |
191 | } | |
192 | ||
193 | INIT_LIST_HEAD(&mp->list); | |
194 | ||
92d7f7b0 JS |
195 | if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT) || |
196 | cmdcode == be16_to_cpu(SLI_CTNS_GFF_ID)) | |
dea3101e JB |
197 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
198 | else | |
199 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); | |
200 | ||
201 | if (!mp->virt) { | |
202 | kfree(mp); | |
0b3a82d3 ES |
203 | if (mlist) |
204 | lpfc_free_ct_rsp(phba, mlist); | |
dea3101e JB |
205 | return NULL; |
206 | } | |
207 | ||
208 | /* Queue it to a linked list */ | |
209 | if (!mlist) | |
210 | mlist = mp; | |
211 | else | |
212 | list_add_tail(&mp->list, &mlist->list); | |
213 | ||
34b02dcd | 214 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; |
dea3101e | 215 | /* build buffer ptr list for IOCB */ |
92d7f7b0 JS |
216 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
217 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); | |
dea3101e JB |
218 | bpl->tus.f.bdeSize = (uint16_t) cnt; |
219 | bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
220 | bpl++; | |
221 | ||
222 | i++; | |
223 | size -= cnt; | |
224 | } | |
225 | ||
226 | *entries = i; | |
227 | return mlist; | |
228 | } | |
229 | ||
858c9f6c JS |
230 | int |
231 | lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) | |
232 | { | |
233 | struct lpfc_dmabuf *buf_ptr; | |
234 | ||
51ef4c26 JS |
235 | if (ctiocb->context_un.ndlp) { |
236 | lpfc_nlp_put(ctiocb->context_un.ndlp); | |
237 | ctiocb->context_un.ndlp = NULL; | |
238 | } | |
858c9f6c JS |
239 | if (ctiocb->context1) { |
240 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; | |
241 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); | |
242 | kfree(buf_ptr); | |
243 | ctiocb->context1 = NULL; | |
244 | } | |
245 | if (ctiocb->context2) { | |
246 | lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2); | |
247 | ctiocb->context2 = NULL; | |
248 | } | |
249 | ||
250 | if (ctiocb->context3) { | |
251 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3; | |
252 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); | |
253 | kfree(buf_ptr); | |
254 | ctiocb->context1 = NULL; | |
255 | } | |
256 | lpfc_sli_release_iocbq(phba, ctiocb); | |
257 | return 0; | |
258 | } | |
259 | ||
dea3101e | 260 | static int |
2e0fef85 | 261 | lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, |
dea3101e JB |
262 | struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp, |
263 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, | |
264 | struct lpfc_iocbq *), | |
265 | struct lpfc_nodelist *ndlp, uint32_t usr_flg, uint32_t num_entry, | |
92d7f7b0 | 266 | uint32_t tmo, uint8_t retry) |
dea3101e | 267 | { |
2e0fef85 JS |
268 | struct lpfc_hba *phba = vport->phba; |
269 | struct lpfc_sli *psli = &phba->sli; | |
dea3101e | 270 | struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING]; |
dea3101e | 271 | IOCB_t *icmd; |
0bd4ca25 | 272 | struct lpfc_iocbq *geniocb; |
92d7f7b0 | 273 | int rc; |
dea3101e JB |
274 | |
275 | /* Allocate buffer for command iocb */ | |
0bd4ca25 | 276 | geniocb = lpfc_sli_get_iocbq(phba); |
dea3101e JB |
277 | |
278 | if (geniocb == NULL) | |
279 | return 1; | |
dea3101e JB |
280 | |
281 | icmd = &geniocb->iocb; | |
282 | icmd->un.genreq64.bdl.ulpIoTag32 = 0; | |
283 | icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); | |
284 | icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); | |
34b02dcd | 285 | icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
dea3101e JB |
286 | icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof (struct ulp_bde64)); |
287 | ||
288 | if (usr_flg) | |
289 | geniocb->context3 = NULL; | |
290 | else | |
291 | geniocb->context3 = (uint8_t *) bmp; | |
292 | ||
293 | /* Save for completion so we can release these resources */ | |
294 | geniocb->context1 = (uint8_t *) inp; | |
295 | geniocb->context2 = (uint8_t *) outp; | |
e47c9093 | 296 | geniocb->context_un.ndlp = lpfc_nlp_get(ndlp); |
dea3101e JB |
297 | |
298 | /* Fill in payload, bp points to frame payload */ | |
299 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; | |
300 | ||
301 | /* Fill in rest of iocb */ | |
302 | icmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); | |
303 | icmd->un.genreq64.w5.hcsw.Dfctl = 0; | |
304 | icmd->un.genreq64.w5.hcsw.Rctl = FC_UNSOL_CTL; | |
305 | icmd->un.genreq64.w5.hcsw.Type = FC_COMMON_TRANSPORT_ULP; | |
306 | ||
c9f8735b JW |
307 | if (!tmo) { |
308 | /* FC spec states we need 3 * ratov for CT requests */ | |
309 | tmo = (3 * phba->fc_ratov); | |
310 | } | |
dea3101e JB |
311 | icmd->ulpTimeout = tmo; |
312 | icmd->ulpBdeCount = 1; | |
313 | icmd->ulpLe = 1; | |
314 | icmd->ulpClass = CLASS3; | |
315 | icmd->ulpContext = ndlp->nlp_rpi; | |
316 | ||
92d7f7b0 JS |
317 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
318 | /* For GEN_REQUEST64_CR, use the RPI */ | |
319 | icmd->ulpCt_h = 0; | |
320 | icmd->ulpCt_l = 0; | |
321 | } | |
322 | ||
dea3101e | 323 | /* Issue GEN REQ IOCB for NPORT <did> */ |
e8b62011 JS |
324 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
325 | "0119 Issue GEN REQ IOCB to NPORT x%x " | |
326 | "Data: x%x x%x\n", | |
327 | ndlp->nlp_DID, icmd->ulpIoTag, | |
328 | vport->port_state); | |
dea3101e JB |
329 | geniocb->iocb_cmpl = cmpl; |
330 | geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT; | |
2e0fef85 | 331 | geniocb->vport = vport; |
92d7f7b0 JS |
332 | geniocb->retry = retry; |
333 | rc = lpfc_sli_issue_iocb(phba, pring, geniocb, 0); | |
334 | ||
335 | if (rc == IOCB_ERROR) { | |
604a3e30 | 336 | lpfc_sli_release_iocbq(phba, geniocb); |
dea3101e JB |
337 | return 1; |
338 | } | |
dea3101e JB |
339 | |
340 | return 0; | |
341 | } | |
342 | ||
343 | static int | |
2e0fef85 | 344 | lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp, |
dea3101e JB |
345 | struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp, |
346 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, | |
347 | struct lpfc_iocbq *), | |
92d7f7b0 | 348 | uint32_t rsp_size, uint8_t retry) |
dea3101e | 349 | { |
2e0fef85 | 350 | struct lpfc_hba *phba = vport->phba; |
dea3101e JB |
351 | struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt; |
352 | struct lpfc_dmabuf *outmp; | |
353 | int cnt = 0, status; | |
354 | int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)-> | |
355 | CommandResponse.bits.CmdRsp; | |
356 | ||
357 | bpl++; /* Skip past ct request */ | |
358 | ||
359 | /* Put buffer(s) for ct rsp in bpl */ | |
360 | outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt); | |
361 | if (!outmp) | |
362 | return -ENOMEM; | |
363 | ||
2e0fef85 | 364 | status = lpfc_gen_req(vport, bmp, inmp, outmp, cmpl, ndlp, 0, |
92d7f7b0 | 365 | cnt+1, 0, retry); |
dea3101e JB |
366 | if (status) { |
367 | lpfc_free_ct_rsp(phba, outmp); | |
368 | return -ENOMEM; | |
369 | } | |
370 | return 0; | |
371 | } | |
372 | ||
549e55cd | 373 | struct lpfc_vport * |
92d7f7b0 | 374 | lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) { |
92d7f7b0 | 375 | struct lpfc_vport *vport_curr; |
549e55cd | 376 | unsigned long flags; |
92d7f7b0 | 377 | |
549e55cd | 378 | spin_lock_irqsave(&phba->hbalock, flags); |
92d7f7b0 | 379 | list_for_each_entry(vport_curr, &phba->port_list, listentry) { |
549e55cd JS |
380 | if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) { |
381 | spin_unlock_irqrestore(&phba->hbalock, flags); | |
92d7f7b0 | 382 | return vport_curr; |
549e55cd | 383 | } |
92d7f7b0 | 384 | } |
549e55cd | 385 | spin_unlock_irqrestore(&phba->hbalock, flags); |
92d7f7b0 JS |
386 | return NULL; |
387 | } | |
388 | ||
dea3101e | 389 | static int |
2e0fef85 | 390 | lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) |
dea3101e | 391 | { |
2e0fef85 | 392 | struct lpfc_hba *phba = vport->phba; |
dea3101e JB |
393 | struct lpfc_sli_ct_request *Response = |
394 | (struct lpfc_sli_ct_request *) mp->virt; | |
395 | struct lpfc_nodelist *ndlp = NULL; | |
396 | struct lpfc_dmabuf *mlast, *next_mp; | |
397 | uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType; | |
2e0fef85 | 398 | uint32_t Did, CTentry; |
dea3101e JB |
399 | int Cnt; |
400 | struct list_head head; | |
401 | ||
2e0fef85 | 402 | lpfc_set_disctmo(vport); |
92d7f7b0 | 403 | vport->num_disc_nodes = 0; |
0ff10d46 | 404 | vport->fc_ns_retry = 0; |
dea3101e | 405 | |
dea3101e JB |
406 | |
407 | list_add_tail(&head, &mp->list); | |
408 | list_for_each_entry_safe(mp, next_mp, &head, list) { | |
409 | mlast = mp; | |
410 | ||
7054a606 JS |
411 | Cnt = Size > FCELSSIZE ? FCELSSIZE : Size; |
412 | ||
dea3101e JB |
413 | Size -= Cnt; |
414 | ||
1dcb58e5 | 415 | if (!ctptr) { |
dea3101e | 416 | ctptr = (uint32_t *) mlast->virt; |
1dcb58e5 | 417 | } else |
dea3101e JB |
418 | Cnt -= 16; /* subtract length of CT header */ |
419 | ||
420 | /* Loop through entire NameServer list of DIDs */ | |
7054a606 | 421 | while (Cnt >= sizeof (uint32_t)) { |
dea3101e JB |
422 | /* Get next DID from NameServer List */ |
423 | CTentry = *ctptr++; | |
424 | Did = ((be32_to_cpu(CTentry)) & Mask_DID); | |
92d7f7b0 | 425 | |
dea3101e | 426 | ndlp = NULL; |
92d7f7b0 JS |
427 | |
428 | /* | |
429 | * Check for rscn processing or not | |
430 | * To conserve rpi's, filter out addresses for other | |
431 | * vports on the same physical HBAs. | |
432 | */ | |
433 | if ((Did != vport->fc_myDID) && | |
434 | ((lpfc_find_vport_by_did(phba, Did) == NULL) || | |
3de2a653 | 435 | vport->cfg_peer_port_login)) { |
92d7f7b0 | 436 | if ((vport->port_type != LPFC_NPIV_PORT) || |
98c9ea5c | 437 | (!(vport->ct_flags & FC_CT_RFF_ID)) || |
3de2a653 | 438 | (!vport->cfg_restrict_login)) { |
92d7f7b0 | 439 | ndlp = lpfc_setup_disc_node(vport, Did); |
58da1ffb | 440 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
858c9f6c JS |
441 | lpfc_debugfs_disc_trc(vport, |
442 | LPFC_DISC_TRC_CT, | |
443 | "Parse GID_FTrsp: " | |
444 | "did:x%x flg:x%x x%x", | |
445 | Did, ndlp->nlp_flag, | |
446 | vport->fc_flag); | |
447 | ||
e8b62011 JS |
448 | lpfc_printf_vlog(vport, |
449 | KERN_INFO, | |
92d7f7b0 | 450 | LOG_DISCOVERY, |
e8b62011 | 451 | "0238 Process " |
92d7f7b0 JS |
452 | "x%x NameServer Rsp" |
453 | "Data: x%x x%x x%x\n", | |
e8b62011 | 454 | Did, ndlp->nlp_flag, |
92d7f7b0 JS |
455 | vport->fc_flag, |
456 | vport->fc_rscn_id_cnt); | |
457 | } else { | |
858c9f6c JS |
458 | lpfc_debugfs_disc_trc(vport, |
459 | LPFC_DISC_TRC_CT, | |
460 | "Skip1 GID_FTrsp: " | |
461 | "did:x%x flg:x%x cnt:%d", | |
462 | Did, vport->fc_flag, | |
463 | vport->fc_rscn_id_cnt); | |
464 | ||
e8b62011 JS |
465 | lpfc_printf_vlog(vport, |
466 | KERN_INFO, | |
92d7f7b0 | 467 | LOG_DISCOVERY, |
e8b62011 | 468 | "0239 Skip x%x " |
92d7f7b0 JS |
469 | "NameServer Rsp Data: " |
470 | "x%x x%x\n", | |
e8b62011 | 471 | Did, vport->fc_flag, |
92d7f7b0 JS |
472 | vport->fc_rscn_id_cnt); |
473 | } | |
474 | ||
475 | } else { | |
476 | if (!(vport->fc_flag & FC_RSCN_MODE) || | |
477 | (lpfc_rscn_payload_check(vport, Did))) { | |
858c9f6c JS |
478 | lpfc_debugfs_disc_trc(vport, |
479 | LPFC_DISC_TRC_CT, | |
480 | "Query GID_FTrsp: " | |
481 | "did:x%x flg:x%x cnt:%d", | |
482 | Did, vport->fc_flag, | |
483 | vport->fc_rscn_id_cnt); | |
484 | ||
0ff10d46 JS |
485 | /* This NPortID was previously |
486 | * a FCP target, * Don't even | |
487 | * bother to send GFF_ID. | |
488 | */ | |
489 | ndlp = lpfc_findnode_did(vport, | |
490 | Did); | |
e47c9093 JS |
491 | if (ndlp && |
492 | NLP_CHK_NODE_ACT(ndlp) | |
493 | && (ndlp->nlp_type & | |
494 | NLP_FCP_TARGET)) | |
0ff10d46 JS |
495 | lpfc_setup_disc_node |
496 | (vport, Did); | |
497 | else if (lpfc_ns_cmd(vport, | |
92d7f7b0 JS |
498 | SLI_CTNS_GFF_ID, |
499 | 0, Did) == 0) | |
500 | vport->num_disc_nodes++; | |
501 | } | |
502 | else { | |
858c9f6c JS |
503 | lpfc_debugfs_disc_trc(vport, |
504 | LPFC_DISC_TRC_CT, | |
505 | "Skip2 GID_FTrsp: " | |
506 | "did:x%x flg:x%x cnt:%d", | |
507 | Did, vport->fc_flag, | |
508 | vport->fc_rscn_id_cnt); | |
509 | ||
e8b62011 JS |
510 | lpfc_printf_vlog(vport, |
511 | KERN_INFO, | |
92d7f7b0 | 512 | LOG_DISCOVERY, |
e8b62011 | 513 | "0245 Skip x%x " |
92d7f7b0 JS |
514 | "NameServer Rsp Data: " |
515 | "x%x x%x\n", | |
e8b62011 | 516 | Did, vport->fc_flag, |
92d7f7b0 JS |
517 | vport->fc_rscn_id_cnt); |
518 | } | |
519 | } | |
dea3101e | 520 | } |
dea3101e JB |
521 | if (CTentry & (be32_to_cpu(SLI_CT_LAST_ENTRY))) |
522 | goto nsout1; | |
523 | Cnt -= sizeof (uint32_t); | |
524 | } | |
525 | ctptr = NULL; | |
526 | ||
527 | } | |
528 | ||
529 | nsout1: | |
530 | list_del(&head); | |
dea3101e JB |
531 | return 0; |
532 | } | |
533 | ||
dea3101e | 534 | static void |
2e0fef85 JS |
535 | lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
536 | struct lpfc_iocbq *rspiocb) | |
dea3101e | 537 | { |
2e0fef85 | 538 | struct lpfc_vport *vport = cmdiocb->vport; |
92d7f7b0 | 539 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
dea3101e | 540 | IOCB_t *irsp; |
dea3101e | 541 | struct lpfc_dmabuf *bmp; |
dea3101e | 542 | struct lpfc_dmabuf *outp; |
dea3101e | 543 | struct lpfc_sli_ct_request *CTrsp; |
51ef4c26 | 544 | struct lpfc_nodelist *ndlp; |
58da1ffb | 545 | int rc; |
dea3101e | 546 | |
51ef4c26 JS |
547 | /* First save ndlp, before we overwrite it */ |
548 | ndlp = cmdiocb->context_un.ndlp; | |
549 | ||
dea3101e JB |
550 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
551 | cmdiocb->context_un.rsp_iocb = rspiocb; | |
552 | ||
dea3101e JB |
553 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
554 | bmp = (struct lpfc_dmabuf *) cmdiocb->context3; | |
858c9f6c JS |
555 | irsp = &rspiocb->iocb; |
556 | ||
557 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, | |
558 | "GID_FT cmpl: status:x%x/x%x rtry:%d", | |
559 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry); | |
dea3101e | 560 | |
92d7f7b0 JS |
561 | /* Don't bother processing response if vport is being torn down. */ |
562 | if (vport->load_flag & FC_UNLOADING) | |
563 | goto out; | |
564 | ||
58da1ffb | 565 | if (lpfc_els_chk_latt(vport)) { |
e8b62011 JS |
566 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
567 | "0216 Link event during NS query\n"); | |
858c9f6c JS |
568 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
569 | goto out; | |
570 | } | |
58da1ffb JS |
571 | if (lpfc_error_lost_link(irsp)) { |
572 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
573 | "0226 NS query failed due to link event\n"); | |
574 | goto out; | |
575 | } | |
858c9f6c | 576 | if (irsp->ulpStatus) { |
dea3101e | 577 | /* Check for retry */ |
2e0fef85 | 578 | if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { |
58da1ffb JS |
579 | if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT || |
580 | irsp->un.ulpWord[4] != IOERR_NO_RESOURCES) | |
858c9f6c | 581 | vport->fc_ns_retry++; |
0ff10d46 | 582 | |
58da1ffb JS |
583 | /* CT command is being retried */ |
584 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, | |
92d7f7b0 | 585 | vport->fc_ns_retry, 0); |
58da1ffb JS |
586 | if (rc == 0) |
587 | goto out; | |
92d7f7b0 | 588 | } |
92d7f7b0 | 589 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
e8b62011 JS |
590 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
591 | "0257 GID_FT Query error: 0x%x 0x%x\n", | |
592 | irsp->ulpStatus, vport->fc_ns_retry); | |
dea3101e JB |
593 | } else { |
594 | /* Good status, continue checking */ | |
595 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
596 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
597 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { | |
e8b62011 JS |
598 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
599 | "0208 NameServer Rsp Data: x%x\n", | |
600 | vport->fc_flag); | |
2e0fef85 | 601 | lpfc_ns_rsp(vport, outp, |
dea3101e JB |
602 | (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); |
603 | } else if (CTrsp->CommandResponse.bits.CmdRsp == | |
604 | be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { | |
605 | /* NameServer Rsp Error */ | |
a58cbd52 JS |
606 | if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ) |
607 | && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) { | |
e8b62011 JS |
608 | lpfc_printf_vlog(vport, KERN_INFO, |
609 | LOG_DISCOVERY, | |
610 | "0269 No NameServer Entries " | |
a58cbd52 | 611 | "Data: x%x x%x x%x x%x\n", |
a58cbd52 JS |
612 | CTrsp->CommandResponse.bits.CmdRsp, |
613 | (uint32_t) CTrsp->ReasonCode, | |
614 | (uint32_t) CTrsp->Explanation, | |
615 | vport->fc_flag); | |
616 | ||
617 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, | |
618 | "GID_FT no entry cmd:x%x rsn:x%x exp:x%x", | |
619 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, | |
620 | (uint32_t) CTrsp->ReasonCode, | |
621 | (uint32_t) CTrsp->Explanation); | |
e8b62011 JS |
622 | } else { |
623 | lpfc_printf_vlog(vport, KERN_INFO, | |
624 | LOG_DISCOVERY, | |
625 | "0240 NameServer Rsp Error " | |
dea3101e | 626 | "Data: x%x x%x x%x x%x\n", |
dea3101e JB |
627 | CTrsp->CommandResponse.bits.CmdRsp, |
628 | (uint32_t) CTrsp->ReasonCode, | |
629 | (uint32_t) CTrsp->Explanation, | |
2e0fef85 | 630 | vport->fc_flag); |
858c9f6c | 631 | |
a58cbd52 | 632 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
858c9f6c JS |
633 | "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", |
634 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, | |
635 | (uint32_t) CTrsp->ReasonCode, | |
636 | (uint32_t) CTrsp->Explanation); | |
a58cbd52 JS |
637 | } |
638 | ||
858c9f6c | 639 | |
dea3101e JB |
640 | } else { |
641 | /* NameServer Rsp Error */ | |
e8b62011 JS |
642 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
643 | "0241 NameServer Rsp Error " | |
dea3101e | 644 | "Data: x%x x%x x%x x%x\n", |
dea3101e JB |
645 | CTrsp->CommandResponse.bits.CmdRsp, |
646 | (uint32_t) CTrsp->ReasonCode, | |
647 | (uint32_t) CTrsp->Explanation, | |
2e0fef85 | 648 | vport->fc_flag); |
858c9f6c JS |
649 | |
650 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, | |
651 | "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x", | |
652 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, | |
653 | (uint32_t) CTrsp->ReasonCode, | |
654 | (uint32_t) CTrsp->Explanation); | |
dea3101e JB |
655 | } |
656 | } | |
657 | /* Link up / RSCN discovery */ | |
92d7f7b0 JS |
658 | if (vport->num_disc_nodes == 0) { |
659 | /* | |
660 | * The driver has cycled through all Nports in the RSCN payload. | |
661 | * Complete the handling by cleaning up and marking the | |
662 | * current driver state. | |
663 | */ | |
664 | if (vport->port_state >= LPFC_DISC_AUTH) { | |
665 | if (vport->fc_flag & FC_RSCN_MODE) { | |
666 | lpfc_els_flush_rscn(vport); | |
667 | spin_lock_irq(shost->host_lock); | |
668 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ | |
669 | spin_unlock_irq(shost->host_lock); | |
670 | } | |
671 | else | |
672 | lpfc_els_flush_rscn(vport); | |
673 | } | |
674 | ||
675 | lpfc_disc_start(vport); | |
676 | } | |
677 | out: | |
51ef4c26 | 678 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
858c9f6c | 679 | lpfc_ct_free_iocb(phba, cmdiocb); |
92d7f7b0 JS |
680 | return; |
681 | } | |
682 | ||
311464ec | 683 | static void |
92d7f7b0 JS |
684 | lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
685 | struct lpfc_iocbq *rspiocb) | |
686 | { | |
687 | struct lpfc_vport *vport = cmdiocb->vport; | |
688 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | |
689 | IOCB_t *irsp = &rspiocb->iocb; | |
92d7f7b0 JS |
690 | struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
691 | struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
692 | struct lpfc_sli_ct_request *CTrsp; | |
0ff10d46 | 693 | int did, rc, retry; |
92d7f7b0 JS |
694 | uint8_t fbits; |
695 | struct lpfc_nodelist *ndlp; | |
696 | ||
697 | did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId; | |
698 | did = be32_to_cpu(did); | |
699 | ||
858c9f6c JS |
700 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
701 | "GFF_ID cmpl: status:x%x/x%x did:x%x", | |
702 | irsp->ulpStatus, irsp->un.ulpWord[4], did); | |
703 | ||
92d7f7b0 JS |
704 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
705 | /* Good status, continue checking */ | |
706 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
707 | fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET]; | |
708 | ||
709 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
710 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { | |
711 | if ((fbits & FC4_FEATURE_INIT) && | |
712 | !(fbits & FC4_FEATURE_TARGET)) { | |
e8b62011 JS |
713 | lpfc_printf_vlog(vport, KERN_INFO, |
714 | LOG_DISCOVERY, | |
715 | "0270 Skip x%x GFF " | |
716 | "NameServer Rsp Data: (init) " | |
717 | "x%x x%x\n", did, fbits, | |
718 | vport->fc_rscn_id_cnt); | |
92d7f7b0 JS |
719 | goto out; |
720 | } | |
721 | } | |
722 | } | |
858c9f6c | 723 | else { |
0ff10d46 JS |
724 | /* Check for retry */ |
725 | if (cmdiocb->retry < LPFC_MAX_NS_RETRY) { | |
726 | retry = 1; | |
727 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { | |
728 | switch (irsp->un.ulpWord[4]) { | |
729 | case IOERR_NO_RESOURCES: | |
730 | /* We don't increment the retry | |
731 | * count for this case. | |
732 | */ | |
733 | break; | |
734 | case IOERR_LINK_DOWN: | |
735 | case IOERR_SLI_ABORTED: | |
736 | case IOERR_SLI_DOWN: | |
737 | retry = 0; | |
738 | break; | |
739 | default: | |
740 | cmdiocb->retry++; | |
741 | } | |
742 | } | |
743 | else | |
744 | cmdiocb->retry++; | |
745 | ||
746 | if (retry) { | |
747 | /* CT command is being retried */ | |
748 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID, | |
749 | cmdiocb->retry, did); | |
750 | if (rc == 0) { | |
751 | /* success */ | |
752 | lpfc_ct_free_iocb(phba, cmdiocb); | |
753 | return; | |
754 | } | |
755 | } | |
756 | } | |
e8b62011 JS |
757 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
758 | "0267 NameServer GFF Rsp " | |
759 | "x%x Error (%d %d) Data: x%x x%x\n", | |
760 | did, irsp->ulpStatus, irsp->un.ulpWord[4], | |
7f5f3d0d | 761 | vport->fc_flag, vport->fc_rscn_id_cnt); |
858c9f6c JS |
762 | } |
763 | ||
92d7f7b0 JS |
764 | /* This is a target port, unregistered port, or the GFF_ID failed */ |
765 | ndlp = lpfc_setup_disc_node(vport, did); | |
58da1ffb | 766 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
e8b62011 JS |
767 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
768 | "0242 Process x%x GFF " | |
769 | "NameServer Rsp Data: x%x x%x x%x\n", | |
770 | did, ndlp->nlp_flag, vport->fc_flag, | |
771 | vport->fc_rscn_id_cnt); | |
92d7f7b0 | 772 | } else { |
e8b62011 JS |
773 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
774 | "0243 Skip x%x GFF " | |
775 | "NameServer Rsp Data: x%x x%x\n", did, | |
776 | vport->fc_flag, vport->fc_rscn_id_cnt); | |
92d7f7b0 | 777 | } |
dea3101e | 778 | out: |
92d7f7b0 JS |
779 | /* Link up / RSCN discovery */ |
780 | if (vport->num_disc_nodes) | |
781 | vport->num_disc_nodes--; | |
782 | if (vport->num_disc_nodes == 0) { | |
783 | /* | |
784 | * The driver has cycled through all Nports in the RSCN payload. | |
785 | * Complete the handling by cleaning up and marking the | |
786 | * current driver state. | |
787 | */ | |
788 | if (vport->port_state >= LPFC_DISC_AUTH) { | |
789 | if (vport->fc_flag & FC_RSCN_MODE) { | |
790 | lpfc_els_flush_rscn(vport); | |
791 | spin_lock_irq(shost->host_lock); | |
792 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ | |
793 | spin_unlock_irq(shost->host_lock); | |
794 | } | |
795 | else | |
796 | lpfc_els_flush_rscn(vport); | |
797 | } | |
798 | lpfc_disc_start(vport); | |
799 | } | |
858c9f6c | 800 | lpfc_ct_free_iocb(phba, cmdiocb); |
dea3101e JB |
801 | return; |
802 | } | |
803 | ||
92d7f7b0 | 804 | |
dea3101e | 805 | static void |
7ee5d43e JS |
806 | lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
807 | struct lpfc_iocbq *rspiocb) | |
dea3101e | 808 | { |
92d7f7b0 | 809 | struct lpfc_vport *vport = cmdiocb->vport; |
dea3101e JB |
810 | struct lpfc_dmabuf *inp; |
811 | struct lpfc_dmabuf *outp; | |
812 | IOCB_t *irsp; | |
813 | struct lpfc_sli_ct_request *CTrsp; | |
51ef4c26 | 814 | struct lpfc_nodelist *ndlp; |
92d7f7b0 JS |
815 | int cmdcode, rc; |
816 | uint8_t retry; | |
858c9f6c | 817 | uint32_t latt; |
dea3101e | 818 | |
51ef4c26 JS |
819 | /* First save ndlp, before we overwrite it */ |
820 | ndlp = cmdiocb->context_un.ndlp; | |
821 | ||
dea3101e JB |
822 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
823 | cmdiocb->context_un.rsp_iocb = rspiocb; | |
824 | ||
825 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; | |
826 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
dea3101e JB |
827 | irsp = &rspiocb->iocb; |
828 | ||
92d7f7b0 JS |
829 | cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> |
830 | CommandResponse.bits.CmdRsp); | |
dea3101e JB |
831 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
832 | ||
858c9f6c JS |
833 | latt = lpfc_els_chk_latt(vport); |
834 | ||
835 | /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ | |
e8b62011 | 836 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
7ee5d43e | 837 | "0209 CT Request completes, latt %d, " |
e8b62011 JS |
838 | "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", |
839 | latt, irsp->ulpStatus, | |
840 | CTrsp->CommandResponse.bits.CmdRsp, | |
841 | cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); | |
dea3101e | 842 | |
858c9f6c JS |
843 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
844 | "CT cmd cmpl: status:x%x/x%x cmd:x%x", | |
845 | irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); | |
846 | ||
92d7f7b0 | 847 | if (irsp->ulpStatus) { |
e8b62011 JS |
848 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
849 | "0268 NS cmd %x Error (%d %d)\n", | |
850 | cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]); | |
858c9f6c | 851 | |
92d7f7b0 JS |
852 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
853 | ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || | |
854 | (irsp->un.ulpWord[4] == IOERR_SLI_ABORTED))) | |
855 | goto out; | |
856 | ||
857 | retry = cmdiocb->retry; | |
858 | if (retry >= LPFC_MAX_NS_RETRY) | |
859 | goto out; | |
860 | ||
861 | retry++; | |
e8b62011 | 862 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
d7c255b2 | 863 | "0250 Retrying NS cmd %x\n", cmdcode); |
92d7f7b0 JS |
864 | rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); |
865 | if (rc == 0) | |
866 | goto out; | |
867 | } | |
868 | ||
869 | out: | |
51ef4c26 | 870 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
858c9f6c | 871 | lpfc_ct_free_iocb(phba, cmdiocb); |
dea3101e JB |
872 | return; |
873 | } | |
874 | ||
7ee5d43e JS |
875 | static void |
876 | lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
877 | struct lpfc_iocbq *rspiocb) | |
878 | { | |
879 | IOCB_t *irsp = &rspiocb->iocb; | |
880 | struct lpfc_vport *vport = cmdiocb->vport; | |
881 | ||
98c9ea5c JS |
882 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
883 | struct lpfc_dmabuf *outp; | |
884 | struct lpfc_sli_ct_request *CTrsp; | |
885 | ||
886 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
887 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
888 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
889 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) | |
890 | vport->ct_flags |= FC_CT_RFT_ID; | |
891 | } | |
7ee5d43e JS |
892 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
893 | return; | |
894 | } | |
895 | ||
dea3101e | 896 | static void |
2e0fef85 JS |
897 | lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
898 | struct lpfc_iocbq *rspiocb) | |
dea3101e | 899 | { |
7ee5d43e JS |
900 | IOCB_t *irsp = &rspiocb->iocb; |
901 | struct lpfc_vport *vport = cmdiocb->vport; | |
902 | ||
98c9ea5c JS |
903 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
904 | struct lpfc_dmabuf *outp; | |
905 | struct lpfc_sli_ct_request *CTrsp; | |
906 | ||
907 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
908 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
909 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
910 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) | |
911 | vport->ct_flags |= FC_CT_RNN_ID; | |
912 | } | |
7ee5d43e | 913 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
dea3101e JB |
914 | return; |
915 | } | |
916 | ||
92d7f7b0 JS |
917 | static void |
918 | lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
919 | struct lpfc_iocbq *rspiocb) | |
920 | { | |
7ee5d43e JS |
921 | IOCB_t *irsp = &rspiocb->iocb; |
922 | struct lpfc_vport *vport = cmdiocb->vport; | |
923 | ||
98c9ea5c JS |
924 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
925 | struct lpfc_dmabuf *outp; | |
926 | struct lpfc_sli_ct_request *CTrsp; | |
927 | ||
928 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
929 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
930 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
931 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) | |
932 | vport->ct_flags |= FC_CT_RSPN_ID; | |
933 | } | |
7ee5d43e | 934 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
92d7f7b0 JS |
935 | return; |
936 | } | |
937 | ||
dea3101e | 938 | static void |
2e0fef85 JS |
939 | lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
940 | struct lpfc_iocbq *rspiocb) | |
dea3101e | 941 | { |
7ee5d43e JS |
942 | IOCB_t *irsp = &rspiocb->iocb; |
943 | struct lpfc_vport *vport = cmdiocb->vport; | |
944 | ||
98c9ea5c JS |
945 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
946 | struct lpfc_dmabuf *outp; | |
947 | struct lpfc_sli_ct_request *CTrsp; | |
948 | ||
949 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
950 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
951 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
952 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) | |
953 | vport->ct_flags |= FC_CT_RSNN_NN; | |
954 | } | |
7ee5d43e JS |
955 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
956 | return; | |
957 | } | |
958 | ||
959 | static void | |
960 | lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |
961 | struct lpfc_iocbq *rspiocb) | |
962 | { | |
963 | struct lpfc_vport *vport = cmdiocb->vport; | |
964 | ||
965 | /* even if it fails we will act as though it succeeded. */ | |
966 | vport->ct_flags = 0; | |
967 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); | |
dea3101e JB |
968 | return; |
969 | } | |
970 | ||
2fb9bd8b | 971 | static void |
92d7f7b0 JS |
972 | lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
973 | struct lpfc_iocbq *rspiocb) | |
2fb9bd8b | 974 | { |
92d7f7b0 JS |
975 | IOCB_t *irsp = &rspiocb->iocb; |
976 | struct lpfc_vport *vport = cmdiocb->vport; | |
977 | ||
98c9ea5c JS |
978 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
979 | struct lpfc_dmabuf *outp; | |
980 | struct lpfc_sli_ct_request *CTrsp; | |
981 | ||
982 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; | |
983 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; | |
984 | if (CTrsp->CommandResponse.bits.CmdRsp == | |
985 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) | |
986 | vport->ct_flags |= FC_CT_RFF_ID; | |
987 | } | |
7ee5d43e | 988 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
2fb9bd8b JS |
989 | return; |
990 | } | |
991 | ||
495a714c | 992 | int |
92d7f7b0 JS |
993 | lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol, |
994 | size_t size) | |
995 | { | |
996 | int n; | |
997 | uint8_t *wwn = vport->phba->wwpn; | |
998 | ||
999 | n = snprintf(symbol, size, | |
1000 | "Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", | |
1001 | wwn[0], wwn[1], wwn[2], wwn[3], | |
1002 | wwn[4], wwn[5], wwn[6], wwn[7]); | |
1003 | ||
1004 | if (vport->port_type == LPFC_PHYSICAL_PORT) | |
1005 | return n; | |
1006 | ||
1007 | if (n < size) | |
1008 | n += snprintf(symbol + n, size - n, " VPort-%d", vport->vpi); | |
1009 | ||
1010 | if (n < size && vport->vname) | |
1011 | n += snprintf(symbol + n, size - n, " VName-%s", vport->vname); | |
1012 | return n; | |
1013 | } | |
1014 | ||
1015 | int | |
1016 | lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, | |
1017 | size_t size) | |
dea3101e JB |
1018 | { |
1019 | char fwrev[16]; | |
92d7f7b0 | 1020 | int n; |
dea3101e | 1021 | |
92d7f7b0 | 1022 | lpfc_decode_firmware_rev(vport->phba, fwrev, 0); |
dea3101e | 1023 | |
92d7f7b0 JS |
1024 | n = snprintf(symbol, size, "Emulex %s FV%s DV%s", |
1025 | vport->phba->ModelName, fwrev, lpfc_release_version); | |
1026 | return n; | |
dea3101e JB |
1027 | } |
1028 | ||
1029 | /* | |
1030 | * lpfc_ns_cmd | |
1031 | * Description: | |
1032 | * Issue Cmd to NameServer | |
1033 | * SLI_CTNS_GID_FT | |
1034 | * LI_CTNS_RFT_ID | |
1035 | */ | |
1036 | int | |
92d7f7b0 JS |
1037 | lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, |
1038 | uint8_t retry, uint32_t context) | |
dea3101e | 1039 | { |
92d7f7b0 | 1040 | struct lpfc_nodelist * ndlp; |
2e0fef85 | 1041 | struct lpfc_hba *phba = vport->phba; |
dea3101e JB |
1042 | struct lpfc_dmabuf *mp, *bmp; |
1043 | struct lpfc_sli_ct_request *CtReq; | |
1044 | struct ulp_bde64 *bpl; | |
1045 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, | |
1046 | struct lpfc_iocbq *) = NULL; | |
1047 | uint32_t rsp_size = 1024; | |
92d7f7b0 | 1048 | size_t size; |
858c9f6c | 1049 | int rc = 0; |
92d7f7b0 JS |
1050 | |
1051 | ndlp = lpfc_findnode_did(vport, NameServer_DID); | |
e47c9093 JS |
1052 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) |
1053 | || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { | |
858c9f6c JS |
1054 | rc=1; |
1055 | goto ns_cmd_exit; | |
1056 | } | |
dea3101e JB |
1057 | |
1058 | /* fill in BDEs for command */ | |
1059 | /* Allocate buffer for command payload */ | |
1060 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
858c9f6c JS |
1061 | if (!mp) { |
1062 | rc=2; | |
dea3101e | 1063 | goto ns_cmd_exit; |
858c9f6c | 1064 | } |
dea3101e JB |
1065 | |
1066 | INIT_LIST_HEAD(&mp->list); | |
1067 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); | |
858c9f6c JS |
1068 | if (!mp->virt) { |
1069 | rc=3; | |
dea3101e | 1070 | goto ns_cmd_free_mp; |
858c9f6c | 1071 | } |
dea3101e JB |
1072 | |
1073 | /* Allocate buffer for Buffer ptr list */ | |
1074 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
858c9f6c JS |
1075 | if (!bmp) { |
1076 | rc=4; | |
dea3101e | 1077 | goto ns_cmd_free_mpvirt; |
858c9f6c | 1078 | } |
dea3101e JB |
1079 | |
1080 | INIT_LIST_HEAD(&bmp->list); | |
1081 | bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); | |
858c9f6c JS |
1082 | if (!bmp->virt) { |
1083 | rc=5; | |
dea3101e | 1084 | goto ns_cmd_free_bmp; |
858c9f6c | 1085 | } |
dea3101e JB |
1086 | |
1087 | /* NameServer Req */ | |
e8b62011 JS |
1088 | lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY, |
1089 | "0236 NameServer Req Data: x%x x%x x%x\n", | |
1090 | cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt); | |
dea3101e JB |
1091 | |
1092 | bpl = (struct ulp_bde64 *) bmp->virt; | |
1093 | memset(bpl, 0, sizeof(struct ulp_bde64)); | |
92d7f7b0 JS |
1094 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
1095 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); | |
dea3101e JB |
1096 | bpl->tus.f.bdeFlags = 0; |
1097 | if (cmdcode == SLI_CTNS_GID_FT) | |
1098 | bpl->tus.f.bdeSize = GID_REQUEST_SZ; | |
92d7f7b0 JS |
1099 | else if (cmdcode == SLI_CTNS_GFF_ID) |
1100 | bpl->tus.f.bdeSize = GFF_REQUEST_SZ; | |
dea3101e JB |
1101 | else if (cmdcode == SLI_CTNS_RFT_ID) |
1102 | bpl->tus.f.bdeSize = RFT_REQUEST_SZ; | |
1103 | else if (cmdcode == SLI_CTNS_RNN_ID) | |
1104 | bpl->tus.f.bdeSize = RNN_REQUEST_SZ; | |
92d7f7b0 JS |
1105 | else if (cmdcode == SLI_CTNS_RSPN_ID) |
1106 | bpl->tus.f.bdeSize = RSPN_REQUEST_SZ; | |
dea3101e JB |
1107 | else if (cmdcode == SLI_CTNS_RSNN_NN) |
1108 | bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; | |
7ee5d43e JS |
1109 | else if (cmdcode == SLI_CTNS_DA_ID) |
1110 | bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ; | |
2fb9bd8b JS |
1111 | else if (cmdcode == SLI_CTNS_RFF_ID) |
1112 | bpl->tus.f.bdeSize = RFF_REQUEST_SZ; | |
dea3101e JB |
1113 | else |
1114 | bpl->tus.f.bdeSize = 0; | |
1115 | bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
1116 | ||
1117 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; | |
1118 | memset(CtReq, 0, sizeof (struct lpfc_sli_ct_request)); | |
1119 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; | |
1120 | CtReq->RevisionId.bits.InId = 0; | |
1121 | CtReq->FsType = SLI_CT_DIRECTORY_SERVICE; | |
1122 | CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER; | |
1123 | CtReq->CommandResponse.bits.Size = 0; | |
1124 | switch (cmdcode) { | |
1125 | case SLI_CTNS_GID_FT: | |
1126 | CtReq->CommandResponse.bits.CmdRsp = | |
1127 | be16_to_cpu(SLI_CTNS_GID_FT); | |
1128 | CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; | |
92d7f7b0 | 1129 | if (vport->port_state < LPFC_NS_QRY) |
2e0fef85 JS |
1130 | vport->port_state = LPFC_NS_QRY; |
1131 | lpfc_set_disctmo(vport); | |
dea3101e JB |
1132 | cmpl = lpfc_cmpl_ct_cmd_gid_ft; |
1133 | rsp_size = FC_MAX_NS_RSP; | |
1134 | break; | |
1135 | ||
92d7f7b0 JS |
1136 | case SLI_CTNS_GFF_ID: |
1137 | CtReq->CommandResponse.bits.CmdRsp = | |
1138 | be16_to_cpu(SLI_CTNS_GFF_ID); | |
09372820 | 1139 | CtReq->un.gff.PortId = cpu_to_be32(context); |
92d7f7b0 JS |
1140 | cmpl = lpfc_cmpl_ct_cmd_gff_id; |
1141 | break; | |
1142 | ||
dea3101e | 1143 | case SLI_CTNS_RFT_ID: |
7ee5d43e | 1144 | vport->ct_flags &= ~FC_CT_RFT_ID; |
dea3101e JB |
1145 | CtReq->CommandResponse.bits.CmdRsp = |
1146 | be16_to_cpu(SLI_CTNS_RFT_ID); | |
09372820 | 1147 | CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); |
dea3101e JB |
1148 | CtReq->un.rft.fcpReg = 1; |
1149 | cmpl = lpfc_cmpl_ct_cmd_rft_id; | |
1150 | break; | |
1151 | ||
1152 | case SLI_CTNS_RNN_ID: | |
7ee5d43e | 1153 | vport->ct_flags &= ~FC_CT_RNN_ID; |
dea3101e JB |
1154 | CtReq->CommandResponse.bits.CmdRsp = |
1155 | be16_to_cpu(SLI_CTNS_RNN_ID); | |
09372820 | 1156 | CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID); |
2e0fef85 | 1157 | memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename, |
dea3101e JB |
1158 | sizeof (struct lpfc_name)); |
1159 | cmpl = lpfc_cmpl_ct_cmd_rnn_id; | |
1160 | break; | |
1161 | ||
92d7f7b0 | 1162 | case SLI_CTNS_RSPN_ID: |
7ee5d43e | 1163 | vport->ct_flags &= ~FC_CT_RSPN_ID; |
92d7f7b0 JS |
1164 | CtReq->CommandResponse.bits.CmdRsp = |
1165 | be16_to_cpu(SLI_CTNS_RSPN_ID); | |
09372820 | 1166 | CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID); |
92d7f7b0 JS |
1167 | size = sizeof(CtReq->un.rspn.symbname); |
1168 | CtReq->un.rspn.len = | |
1169 | lpfc_vport_symbolic_port_name(vport, | |
1170 | CtReq->un.rspn.symbname, size); | |
1171 | cmpl = lpfc_cmpl_ct_cmd_rspn_id; | |
1172 | break; | |
dea3101e | 1173 | case SLI_CTNS_RSNN_NN: |
7ee5d43e | 1174 | vport->ct_flags &= ~FC_CT_RSNN_NN; |
dea3101e JB |
1175 | CtReq->CommandResponse.bits.CmdRsp = |
1176 | be16_to_cpu(SLI_CTNS_RSNN_NN); | |
2e0fef85 | 1177 | memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename, |
dea3101e | 1178 | sizeof (struct lpfc_name)); |
92d7f7b0 JS |
1179 | size = sizeof(CtReq->un.rsnn.symbname); |
1180 | CtReq->un.rsnn.len = | |
1181 | lpfc_vport_symbolic_node_name(vport, | |
1182 | CtReq->un.rsnn.symbname, size); | |
dea3101e JB |
1183 | cmpl = lpfc_cmpl_ct_cmd_rsnn_nn; |
1184 | break; | |
7ee5d43e JS |
1185 | case SLI_CTNS_DA_ID: |
1186 | /* Implement DA_ID Nameserver request */ | |
1187 | CtReq->CommandResponse.bits.CmdRsp = | |
1188 | be16_to_cpu(SLI_CTNS_DA_ID); | |
09372820 | 1189 | CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID); |
7ee5d43e JS |
1190 | cmpl = lpfc_cmpl_ct_cmd_da_id; |
1191 | break; | |
92d7f7b0 | 1192 | case SLI_CTNS_RFF_ID: |
7ee5d43e | 1193 | vport->ct_flags &= ~FC_CT_RFF_ID; |
92d7f7b0 JS |
1194 | CtReq->CommandResponse.bits.CmdRsp = |
1195 | be16_to_cpu(SLI_CTNS_RFF_ID); | |
09372820 | 1196 | CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);; |
92d7f7b0 JS |
1197 | CtReq->un.rff.fbits = FC4_FEATURE_INIT; |
1198 | CtReq->un.rff.type_code = FC_FCP_DATA; | |
1199 | cmpl = lpfc_cmpl_ct_cmd_rff_id; | |
1200 | break; | |
dea3101e | 1201 | } |
e47c9093 JS |
1202 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
1203 | * to hold ndlp reference for the corresponding callback function. | |
1204 | */ | |
858c9f6c | 1205 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { |
dea3101e | 1206 | /* On success, The cmpl function will free the buffers */ |
858c9f6c JS |
1207 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
1208 | "Issue CT cmd: cmd:x%x did:x%x", | |
1209 | cmdcode, ndlp->nlp_DID, 0); | |
dea3101e | 1210 | return 0; |
858c9f6c | 1211 | } |
858c9f6c | 1212 | rc=6; |
e47c9093 JS |
1213 | |
1214 | /* Decrement ndlp reference count to release ndlp reference held | |
1215 | * for the failed command's callback function. | |
1216 | */ | |
51ef4c26 | 1217 | lpfc_nlp_put(ndlp); |
e47c9093 | 1218 | |
dea3101e JB |
1219 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
1220 | ns_cmd_free_bmp: | |
1221 | kfree(bmp); | |
1222 | ns_cmd_free_mpvirt: | |
1223 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1224 | ns_cmd_free_mp: | |
1225 | kfree(mp); | |
1226 | ns_cmd_exit: | |
e8b62011 JS |
1227 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
1228 | "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", | |
1229 | cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt); | |
dea3101e JB |
1230 | return 1; |
1231 | } | |
1232 | ||
1233 | static void | |
2e0fef85 JS |
1234 | lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
1235 | struct lpfc_iocbq * rspiocb) | |
dea3101e | 1236 | { |
dea3101e JB |
1237 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
1238 | struct lpfc_dmabuf *outp = cmdiocb->context2; | |
1239 | struct lpfc_sli_ct_request *CTrsp = outp->virt; | |
1240 | struct lpfc_sli_ct_request *CTcmd = inp->virt; | |
1241 | struct lpfc_nodelist *ndlp; | |
1242 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; | |
1243 | uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; | |
2e0fef85 | 1244 | struct lpfc_vport *vport = cmdiocb->vport; |
858c9f6c JS |
1245 | IOCB_t *irsp = &rspiocb->iocb; |
1246 | uint32_t latt; | |
1247 | ||
1248 | latt = lpfc_els_chk_latt(vport); | |
1249 | ||
1250 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, | |
1251 | "FDMI cmpl: status:x%x/x%x latt:%d", | |
1252 | irsp->ulpStatus, irsp->un.ulpWord[4], latt); | |
1253 | ||
1254 | if (latt || irsp->ulpStatus) { | |
e8b62011 JS |
1255 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
1256 | "0229 FDMI cmd %04x failed, latt = %d " | |
1257 | "ulpStatus: x%x, rid x%x\n", | |
1258 | be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, | |
1259 | irsp->un.ulpWord[4]); | |
858c9f6c JS |
1260 | lpfc_ct_free_iocb(phba, cmdiocb); |
1261 | return; | |
1262 | } | |
dea3101e | 1263 | |
2e0fef85 | 1264 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
e47c9093 JS |
1265 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
1266 | goto fail_out; | |
1267 | ||
dea3101e JB |
1268 | if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
1269 | /* FDMI rsp failed */ | |
e8b62011 JS |
1270 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
1271 | "0220 FDMI rsp failed Data: x%x\n", | |
1272 | be16_to_cpu(fdmi_cmd)); | |
dea3101e JB |
1273 | } |
1274 | ||
1275 | switch (be16_to_cpu(fdmi_cmd)) { | |
1276 | case SLI_MGMT_RHBA: | |
2e0fef85 | 1277 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA); |
dea3101e JB |
1278 | break; |
1279 | ||
1280 | case SLI_MGMT_RPA: | |
1281 | break; | |
1282 | ||
1283 | case SLI_MGMT_DHBA: | |
2e0fef85 | 1284 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT); |
dea3101e JB |
1285 | break; |
1286 | ||
1287 | case SLI_MGMT_DPRT: | |
2e0fef85 | 1288 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); |
dea3101e JB |
1289 | break; |
1290 | } | |
e47c9093 JS |
1291 | |
1292 | fail_out: | |
858c9f6c | 1293 | lpfc_ct_free_iocb(phba, cmdiocb); |
dea3101e JB |
1294 | return; |
1295 | } | |
2e0fef85 | 1296 | |
dea3101e | 1297 | int |
2e0fef85 | 1298 | lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) |
dea3101e | 1299 | { |
2e0fef85 | 1300 | struct lpfc_hba *phba = vport->phba; |
dea3101e JB |
1301 | struct lpfc_dmabuf *mp, *bmp; |
1302 | struct lpfc_sli_ct_request *CtReq; | |
1303 | struct ulp_bde64 *bpl; | |
1304 | uint32_t size; | |
1305 | REG_HBA *rh; | |
1306 | PORT_ENTRY *pe; | |
1307 | REG_PORT_ATTRIBUTE *pab; | |
1308 | ATTRIBUTE_BLOCK *ab; | |
1309 | ATTRIBUTE_ENTRY *ae; | |
1310 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, | |
1311 | struct lpfc_iocbq *); | |
1312 | ||
1313 | ||
1314 | /* fill in BDEs for command */ | |
1315 | /* Allocate buffer for command payload */ | |
1316 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
1317 | if (!mp) | |
1318 | goto fdmi_cmd_exit; | |
1319 | ||
1320 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); | |
1321 | if (!mp->virt) | |
1322 | goto fdmi_cmd_free_mp; | |
1323 | ||
1324 | /* Allocate buffer for Buffer ptr list */ | |
1325 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
1326 | if (!bmp) | |
1327 | goto fdmi_cmd_free_mpvirt; | |
1328 | ||
1329 | bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys)); | |
1330 | if (!bmp->virt) | |
1331 | goto fdmi_cmd_free_bmp; | |
1332 | ||
1333 | INIT_LIST_HEAD(&mp->list); | |
1334 | INIT_LIST_HEAD(&bmp->list); | |
1335 | ||
1336 | /* FDMI request */ | |
e8b62011 JS |
1337 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
1338 | "0218 FDMI Request Data: x%x x%x x%x\n", | |
1339 | vport->fc_flag, vport->port_state, cmdcode); | |
dea3101e JB |
1340 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
1341 | ||
1342 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); | |
1343 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; | |
1344 | CtReq->RevisionId.bits.InId = 0; | |
1345 | ||
1346 | CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; | |
1347 | CtReq->FsSubType = SLI_CT_FDMI_Subtypes; | |
1348 | size = 0; | |
1349 | ||
1350 | switch (cmdcode) { | |
1351 | case SLI_MGMT_RHBA: | |
1352 | { | |
1353 | lpfc_vpd_t *vp = &phba->vpd; | |
1354 | uint32_t i, j, incr; | |
1355 | int len; | |
1356 | ||
1357 | CtReq->CommandResponse.bits.CmdRsp = | |
1358 | be16_to_cpu(SLI_MGMT_RHBA); | |
1359 | CtReq->CommandResponse.bits.Size = 0; | |
1360 | rh = (REG_HBA *) & CtReq->un.PortID; | |
2e0fef85 | 1361 | memcpy(&rh->hi.PortName, &vport->fc_sparam.portName, |
dea3101e JB |
1362 | sizeof (struct lpfc_name)); |
1363 | /* One entry (port) per adapter */ | |
1364 | rh->rpl.EntryCnt = be32_to_cpu(1); | |
2e0fef85 | 1365 | memcpy(&rh->rpl.pe, &vport->fc_sparam.portName, |
dea3101e JB |
1366 | sizeof (struct lpfc_name)); |
1367 | ||
1368 | /* point to the HBA attribute block */ | |
1369 | size = 2 * sizeof (struct lpfc_name) + FOURBYTES; | |
1370 | ab = (ATTRIBUTE_BLOCK *) ((uint8_t *) rh + size); | |
1371 | ab->EntryCnt = 0; | |
1372 | ||
1373 | /* Point to the beginning of the first HBA attribute | |
1374 | entry */ | |
1375 | /* #1 HBA attribute entry */ | |
1376 | size += FOURBYTES; | |
1377 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1378 | ae->ad.bits.AttrType = be16_to_cpu(NODE_NAME); | |
1379 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES | |
1380 | + sizeof (struct lpfc_name)); | |
2e0fef85 | 1381 | memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName, |
dea3101e JB |
1382 | sizeof (struct lpfc_name)); |
1383 | ab->EntryCnt++; | |
1384 | size += FOURBYTES + sizeof (struct lpfc_name); | |
1385 | ||
1386 | /* #2 HBA attribute entry */ | |
1387 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1388 | ae->ad.bits.AttrType = be16_to_cpu(MANUFACTURER); | |
1389 | strcpy(ae->un.Manufacturer, "Emulex Corporation"); | |
1390 | len = strlen(ae->un.Manufacturer); | |
1391 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1392 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1393 | ab->EntryCnt++; | |
1394 | size += FOURBYTES + len; | |
1395 | ||
1396 | /* #3 HBA attribute entry */ | |
1397 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1398 | ae->ad.bits.AttrType = be16_to_cpu(SERIAL_NUMBER); | |
1399 | strcpy(ae->un.SerialNumber, phba->SerialNumber); | |
1400 | len = strlen(ae->un.SerialNumber); | |
1401 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1402 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1403 | ab->EntryCnt++; | |
1404 | size += FOURBYTES + len; | |
1405 | ||
1406 | /* #4 HBA attribute entry */ | |
1407 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1408 | ae->ad.bits.AttrType = be16_to_cpu(MODEL); | |
1409 | strcpy(ae->un.Model, phba->ModelName); | |
1410 | len = strlen(ae->un.Model); | |
1411 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1412 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1413 | ab->EntryCnt++; | |
1414 | size += FOURBYTES + len; | |
1415 | ||
1416 | /* #5 HBA attribute entry */ | |
1417 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1418 | ae->ad.bits.AttrType = be16_to_cpu(MODEL_DESCRIPTION); | |
1419 | strcpy(ae->un.ModelDescription, phba->ModelDesc); | |
1420 | len = strlen(ae->un.ModelDescription); | |
1421 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1422 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1423 | ab->EntryCnt++; | |
1424 | size += FOURBYTES + len; | |
1425 | ||
1426 | /* #6 HBA attribute entry */ | |
1427 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1428 | ae->ad.bits.AttrType = be16_to_cpu(HARDWARE_VERSION); | |
1429 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 8); | |
1430 | /* Convert JEDEC ID to ascii for hardware version */ | |
1431 | incr = vp->rev.biuRev; | |
1432 | for (i = 0; i < 8; i++) { | |
1433 | j = (incr & 0xf); | |
1434 | if (j <= 9) | |
1435 | ae->un.HardwareVersion[7 - i] = | |
1436 | (char)((uint8_t) 0x30 + | |
1437 | (uint8_t) j); | |
1438 | else | |
1439 | ae->un.HardwareVersion[7 - i] = | |
1440 | (char)((uint8_t) 0x61 + | |
1441 | (uint8_t) (j - 10)); | |
1442 | incr = (incr >> 4); | |
1443 | } | |
1444 | ab->EntryCnt++; | |
1445 | size += FOURBYTES + 8; | |
1446 | ||
1447 | /* #7 HBA attribute entry */ | |
1448 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1449 | ae->ad.bits.AttrType = be16_to_cpu(DRIVER_VERSION); | |
1450 | strcpy(ae->un.DriverVersion, lpfc_release_version); | |
1451 | len = strlen(ae->un.DriverVersion); | |
1452 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1453 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1454 | ab->EntryCnt++; | |
1455 | size += FOURBYTES + len; | |
1456 | ||
1457 | /* #8 HBA attribute entry */ | |
1458 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1459 | ae->ad.bits.AttrType = be16_to_cpu(OPTION_ROM_VERSION); | |
1460 | strcpy(ae->un.OptionROMVersion, phba->OptionROMVersion); | |
1461 | len = strlen(ae->un.OptionROMVersion); | |
1462 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1463 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1464 | ab->EntryCnt++; | |
1465 | size += FOURBYTES + len; | |
1466 | ||
1467 | /* #9 HBA attribute entry */ | |
1468 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1469 | ae->ad.bits.AttrType = be16_to_cpu(FIRMWARE_VERSION); | |
1470 | lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion, | |
1471 | 1); | |
1472 | len = strlen(ae->un.FirmwareVersion); | |
1473 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1474 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1475 | ab->EntryCnt++; | |
1476 | size += FOURBYTES + len; | |
1477 | ||
1478 | /* #10 HBA attribute entry */ | |
1479 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1480 | ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); | |
1481 | sprintf(ae->un.OsNameVersion, "%s %s %s", | |
2fb9bd8b JS |
1482 | init_utsname()->sysname, |
1483 | init_utsname()->release, | |
96b644bd | 1484 | init_utsname()->version); |
dea3101e JB |
1485 | len = strlen(ae->un.OsNameVersion); |
1486 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1487 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1488 | ab->EntryCnt++; | |
1489 | size += FOURBYTES + len; | |
1490 | ||
1491 | /* #11 HBA attribute entry */ | |
1492 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); | |
1493 | ae->ad.bits.AttrType = be16_to_cpu(MAX_CT_PAYLOAD_LEN); | |
1494 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); | |
1495 | ae->un.MaxCTPayloadLen = (65 * 4096); | |
1496 | ab->EntryCnt++; | |
1497 | size += FOURBYTES + 4; | |
1498 | ||
1499 | ab->EntryCnt = be32_to_cpu(ab->EntryCnt); | |
1500 | /* Total size */ | |
1501 | size = GID_REQUEST_SZ - 4 + size; | |
1502 | } | |
1503 | break; | |
1504 | ||
1505 | case SLI_MGMT_RPA: | |
1506 | { | |
1507 | lpfc_vpd_t *vp; | |
1508 | struct serv_parm *hsp; | |
1509 | int len; | |
1510 | ||
1511 | vp = &phba->vpd; | |
1512 | ||
1513 | CtReq->CommandResponse.bits.CmdRsp = | |
1514 | be16_to_cpu(SLI_MGMT_RPA); | |
1515 | CtReq->CommandResponse.bits.Size = 0; | |
1516 | pab = (REG_PORT_ATTRIBUTE *) & CtReq->un.PortID; | |
1517 | size = sizeof (struct lpfc_name) + FOURBYTES; | |
1518 | memcpy((uint8_t *) & pab->PortName, | |
2e0fef85 | 1519 | (uint8_t *) & vport->fc_sparam.portName, |
dea3101e JB |
1520 | sizeof (struct lpfc_name)); |
1521 | pab->ab.EntryCnt = 0; | |
1522 | ||
1523 | /* #1 Port attribute entry */ | |
1524 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); | |
1525 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_FC4_TYPES); | |
1526 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 32); | |
1527 | ae->un.SupportFC4Types[2] = 1; | |
1528 | ae->un.SupportFC4Types[7] = 1; | |
1529 | pab->ab.EntryCnt++; | |
1530 | size += FOURBYTES + 32; | |
1531 | ||
1532 | /* #2 Port attribute entry */ | |
1533 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); | |
1534 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_SPEED); | |
1535 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); | |
74b72a59 JW |
1536 | |
1537 | ae->un.SupportSpeed = 0; | |
1538 | if (phba->lmt & LMT_10Gb) | |
dea3101e | 1539 | ae->un.SupportSpeed = HBA_PORTSPEED_10GBIT; |
74b72a59 JW |
1540 | if (phba->lmt & LMT_8Gb) |
1541 | ae->un.SupportSpeed |= HBA_PORTSPEED_8GBIT; | |
1542 | if (phba->lmt & LMT_4Gb) | |
1543 | ae->un.SupportSpeed |= HBA_PORTSPEED_4GBIT; | |
1544 | if (phba->lmt & LMT_2Gb) | |
1545 | ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT; | |
1546 | if (phba->lmt & LMT_1Gb) | |
1547 | ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT; | |
1548 | ||
dea3101e JB |
1549 | pab->ab.EntryCnt++; |
1550 | size += FOURBYTES + 4; | |
1551 | ||
1552 | /* #3 Port attribute entry */ | |
1553 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); | |
1554 | ae->ad.bits.AttrType = be16_to_cpu(PORT_SPEED); | |
1555 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); | |
1556 | switch(phba->fc_linkspeed) { | |
1557 | case LA_1GHZ_LINK: | |
1558 | ae->un.PortSpeed = HBA_PORTSPEED_1GBIT; | |
1559 | break; | |
1560 | case LA_2GHZ_LINK: | |
1561 | ae->un.PortSpeed = HBA_PORTSPEED_2GBIT; | |
1562 | break; | |
1563 | case LA_4GHZ_LINK: | |
1564 | ae->un.PortSpeed = HBA_PORTSPEED_4GBIT; | |
1565 | break; | |
b87eab38 JS |
1566 | case LA_8GHZ_LINK: |
1567 | ae->un.PortSpeed = HBA_PORTSPEED_8GBIT; | |
1568 | break; | |
dea3101e JB |
1569 | default: |
1570 | ae->un.PortSpeed = | |
1571 | HBA_PORTSPEED_UNKNOWN; | |
1572 | break; | |
1573 | } | |
1574 | pab->ab.EntryCnt++; | |
1575 | size += FOURBYTES + 4; | |
1576 | ||
1577 | /* #4 Port attribute entry */ | |
1578 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); | |
1579 | ae->ad.bits.AttrType = be16_to_cpu(MAX_FRAME_SIZE); | |
1580 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); | |
2e0fef85 | 1581 | hsp = (struct serv_parm *) & vport->fc_sparam; |
dea3101e JB |
1582 | ae->un.MaxFrameSize = |
1583 | (((uint32_t) hsp->cmn. | |
1584 | bbRcvSizeMsb) << 8) | (uint32_t) hsp->cmn. | |
1585 | bbRcvSizeLsb; | |
1586 | pab->ab.EntryCnt++; | |
1587 | size += FOURBYTES + 4; | |
1588 | ||
1589 | /* #5 Port attribute entry */ | |
1590 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); | |
1591 | ae->ad.bits.AttrType = be16_to_cpu(OS_DEVICE_NAME); | |
1592 | strcpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME); | |
1593 | len = strlen((char *)ae->un.OsDeviceName); | |
1594 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1595 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); | |
1596 | pab->ab.EntryCnt++; | |
1597 | size += FOURBYTES + len; | |
1598 | ||
3de2a653 | 1599 | if (vport->cfg_fdmi_on == 2) { |
dea3101e JB |
1600 | /* #6 Port attribute entry */ |
1601 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + | |
1602 | size); | |
1603 | ae->ad.bits.AttrType = be16_to_cpu(HOST_NAME); | |
1604 | sprintf(ae->un.HostName, "%s", | |
96b644bd | 1605 | init_utsname()->nodename); |
dea3101e JB |
1606 | len = strlen(ae->un.HostName); |
1607 | len += (len & 3) ? (4 - (len & 3)) : 4; | |
1608 | ae->ad.bits.AttrLen = | |
1609 | be16_to_cpu(FOURBYTES + len); | |
1610 | pab->ab.EntryCnt++; | |
1611 | size += FOURBYTES + len; | |
1612 | } | |
1613 | ||
1614 | pab->ab.EntryCnt = be32_to_cpu(pab->ab.EntryCnt); | |
1615 | /* Total size */ | |
1616 | size = GID_REQUEST_SZ - 4 + size; | |
1617 | } | |
1618 | break; | |
1619 | ||
1620 | case SLI_MGMT_DHBA: | |
1621 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DHBA); | |
1622 | CtReq->CommandResponse.bits.Size = 0; | |
1623 | pe = (PORT_ENTRY *) & CtReq->un.PortID; | |
1624 | memcpy((uint8_t *) & pe->PortName, | |
2e0fef85 | 1625 | (uint8_t *) & vport->fc_sparam.portName, |
dea3101e JB |
1626 | sizeof (struct lpfc_name)); |
1627 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); | |
1628 | break; | |
1629 | ||
1630 | case SLI_MGMT_DPRT: | |
1631 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DPRT); | |
1632 | CtReq->CommandResponse.bits.Size = 0; | |
1633 | pe = (PORT_ENTRY *) & CtReq->un.PortID; | |
1634 | memcpy((uint8_t *) & pe->PortName, | |
2e0fef85 | 1635 | (uint8_t *) & vport->fc_sparam.portName, |
dea3101e JB |
1636 | sizeof (struct lpfc_name)); |
1637 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); | |
1638 | break; | |
1639 | } | |
1640 | ||
1641 | bpl = (struct ulp_bde64 *) bmp->virt; | |
92d7f7b0 JS |
1642 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
1643 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); | |
dea3101e JB |
1644 | bpl->tus.f.bdeFlags = 0; |
1645 | bpl->tus.f.bdeSize = size; | |
1646 | bpl->tus.w = le32_to_cpu(bpl->tus.w); | |
1647 | ||
1648 | cmpl = lpfc_cmpl_ct_cmd_fdmi; | |
1649 | ||
e47c9093 JS |
1650 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
1651 | * to hold ndlp reference for the corresponding callback function. | |
1652 | */ | |
92d7f7b0 | 1653 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) |
dea3101e JB |
1654 | return 0; |
1655 | ||
e47c9093 JS |
1656 | /* Decrement ndlp reference count to release ndlp reference held |
1657 | * for the failed command's callback function. | |
1658 | */ | |
51ef4c26 | 1659 | lpfc_nlp_put(ndlp); |
e47c9093 | 1660 | |
dea3101e JB |
1661 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
1662 | fdmi_cmd_free_bmp: | |
1663 | kfree(bmp); | |
1664 | fdmi_cmd_free_mpvirt: | |
1665 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1666 | fdmi_cmd_free_mp: | |
1667 | kfree(mp); | |
1668 | fdmi_cmd_exit: | |
1669 | /* Issue FDMI request failed */ | |
e8b62011 JS |
1670 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
1671 | "0244 Issue FDMI request failed Data: x%x\n", | |
1672 | cmdcode); | |
dea3101e JB |
1673 | return 1; |
1674 | } | |
1675 | ||
1676 | void | |
1677 | lpfc_fdmi_tmo(unsigned long ptr) | |
1678 | { | |
2e0fef85 JS |
1679 | struct lpfc_vport *vport = (struct lpfc_vport *)ptr; |
1680 | struct lpfc_hba *phba = vport->phba; | |
5e9d9b82 | 1681 | uint32_t tmo_posted; |
dea3101e JB |
1682 | unsigned long iflag; |
1683 | ||
2e0fef85 | 1684 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
5e9d9b82 JS |
1685 | tmo_posted = vport->work_port_events & WORKER_FDMI_TMO; |
1686 | if (!tmo_posted) | |
2e0fef85 | 1687 | vport->work_port_events |= WORKER_FDMI_TMO; |
5e9d9b82 | 1688 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
92d7f7b0 | 1689 | |
5e9d9b82 JS |
1690 | if (!tmo_posted) |
1691 | lpfc_worker_wake_up(phba); | |
1692 | return; | |
dea3101e JB |
1693 | } |
1694 | ||
1695 | void | |
2e0fef85 | 1696 | lpfc_fdmi_timeout_handler(struct lpfc_vport *vport) |
dea3101e JB |
1697 | { |
1698 | struct lpfc_nodelist *ndlp; | |
1699 | ||
2e0fef85 | 1700 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
e47c9093 | 1701 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
2e0fef85 JS |
1702 | if (init_utsname()->nodename[0] != '\0') |
1703 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); | |
1704 | else | |
1705 | mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60); | |
dea3101e | 1706 | } |
dea3101e JB |
1707 | return; |
1708 | } | |
1709 | ||
dea3101e | 1710 | void |
2e0fef85 | 1711 | lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag) |
dea3101e JB |
1712 | { |
1713 | struct lpfc_sli *psli = &phba->sli; | |
1714 | lpfc_vpd_t *vp = &phba->vpd; | |
1715 | uint32_t b1, b2, b3, b4, i, rev; | |
1716 | char c; | |
1717 | uint32_t *ptr, str[4]; | |
1718 | uint8_t *fwname; | |
1719 | ||
1720 | if (vp->rev.rBit) { | |
1721 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) | |
1722 | rev = vp->rev.sli2FwRev; | |
1723 | else | |
1724 | rev = vp->rev.sli1FwRev; | |
1725 | ||
1726 | b1 = (rev & 0x0000f000) >> 12; | |
1727 | b2 = (rev & 0x00000f00) >> 8; | |
1728 | b3 = (rev & 0x000000c0) >> 6; | |
1729 | b4 = (rev & 0x00000030) >> 4; | |
1730 | ||
1731 | switch (b4) { | |
1732 | case 0: | |
1733 | c = 'N'; | |
1734 | break; | |
1735 | case 1: | |
1736 | c = 'A'; | |
1737 | break; | |
1738 | case 2: | |
1739 | c = 'B'; | |
1740 | break; | |
1741 | default: | |
1742 | c = 0; | |
1743 | break; | |
1744 | } | |
1745 | b4 = (rev & 0x0000000f); | |
1746 | ||
1747 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) | |
1748 | fwname = vp->rev.sli2FwName; | |
1749 | else | |
1750 | fwname = vp->rev.sli1FwName; | |
1751 | ||
1752 | for (i = 0; i < 16; i++) | |
1753 | if (fwname[i] == 0x20) | |
1754 | fwname[i] = 0; | |
1755 | ||
1756 | ptr = (uint32_t*)fwname; | |
1757 | ||
1758 | for (i = 0; i < 3; i++) | |
1759 | str[i] = be32_to_cpu(*ptr++); | |
1760 | ||
1761 | if (c == 0) { | |
1762 | if (flag) | |
1763 | sprintf(fwrevision, "%d.%d%d (%s)", | |
1764 | b1, b2, b3, (char *)str); | |
1765 | else | |
1766 | sprintf(fwrevision, "%d.%d%d", b1, | |
1767 | b2, b3); | |
1768 | } else { | |
1769 | if (flag) | |
1770 | sprintf(fwrevision, "%d.%d%d%c%d (%s)", | |
1771 | b1, b2, b3, c, | |
1772 | b4, (char *)str); | |
1773 | else | |
1774 | sprintf(fwrevision, "%d.%d%d%c%d", | |
1775 | b1, b2, b3, c, b4); | |
1776 | } | |
1777 | } else { | |
1778 | rev = vp->rev.smFwRev; | |
1779 | ||
1780 | b1 = (rev & 0xff000000) >> 24; | |
1781 | b2 = (rev & 0x00f00000) >> 20; | |
1782 | b3 = (rev & 0x000f0000) >> 16; | |
1783 | c = (rev & 0x0000ff00) >> 8; | |
1784 | b4 = (rev & 0x000000ff); | |
1785 | ||
1786 | if (flag) | |
1787 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, | |
1788 | b2, b3, c, b4); | |
1789 | else | |
1790 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, | |
1791 | b2, b3, c, b4); | |
1792 | } | |
1793 | return; | |
1794 | } |