emlxs_diag.c (291a2b48) emlxs_diag.c (82527734)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 7 unchanged lines hidden (view full) ---

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2009 Emulex. All rights reserved.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 7 unchanged lines hidden (view full) ---

16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2009 Emulex. All rights reserved.
24 * Use is subject to License terms.
24 * Use is subject to license terms.
25 */
26
25 */
26
27
27#include <emlxs.h>
28
29
30/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
31EMLXS_MSG_DEF(EMLXS_DIAG_C);
32
33uint32_t emlxs_diag_pattern[256] = {
34 /* Walking ones */

--- 87 unchanged lines hidden (view full) ---

122 /* Set the completed flag and wake up sleeping threads */
123 mutex_enter(&EMLXS_PKT_LOCK);
124 pkt->pkt_tran_flags |= FC_TRAN_COMPLETED;
125 cv_broadcast(&EMLXS_PKT_CV);
126 mutex_exit(&EMLXS_PKT_LOCK);
127
128 return;
129
28#include <emlxs.h>
29
30
31/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
32EMLXS_MSG_DEF(EMLXS_DIAG_C);
33
34uint32_t emlxs_diag_pattern[256] = {
35 /* Walking ones */

--- 87 unchanged lines hidden (view full) ---

123 /* Set the completed flag and wake up sleeping threads */
124 mutex_enter(&EMLXS_PKT_LOCK);
125 pkt->pkt_tran_flags |= FC_TRAN_COMPLETED;
126 cv_broadcast(&EMLXS_PKT_CV);
127 mutex_exit(&EMLXS_PKT_LOCK);
128
129 return;
130
130} /* emlxs_diag_pkt_callback() */
131} /* emlxs_diag_pkt_callback() */
131
132
133extern uint32_t
134emlxs_diag_echo_run(emlxs_port_t *port, uint32_t did, uint32_t pattern)
135{
136 emlxs_hba_t *hba = HBA;
137 uint32_t i = 0;
138 uint32_t rval = FC_SUCCESS;

--- 144 unchanged lines hidden (view full) ---

283
284done:
285
286 /* Free the echo pkt */
287 emlxs_pkt_free(pkt);
288
289 return (rval);
290
132
133
134extern uint32_t
135emlxs_diag_echo_run(emlxs_port_t *port, uint32_t did, uint32_t pattern)
136{
137 emlxs_hba_t *hba = HBA;
138 uint32_t i = 0;
139 uint32_t rval = FC_SUCCESS;

--- 144 unchanged lines hidden (view full) ---

284
285done:
286
287 /* Free the echo pkt */
288 emlxs_pkt_free(pkt);
289
290 return (rval);
291
291} /* emlxs_diag_echo_run() */
292} /* emlxs_diag_echo_run() */
292
293
294extern uint32_t
295emlxs_diag_biu_run(emlxs_hba_t *hba, uint32_t pattern)
296{
297 emlxs_port_t *port = &PPORT;
293
294
295extern uint32_t
296emlxs_diag_biu_run(emlxs_hba_t *hba, uint32_t pattern)
297{
298 emlxs_port_t *port = &PPORT;
298 MAILBOX *mb;
299 MAILBOXQ *mbq;
299 MATCHMAP *mp;
300 MATCHMAP *mp1;
301 uint32_t i;
302 uint8_t *inptr;
303 uint8_t *outptr;
304 int32_t rval = FC_SUCCESS;
305 uint32_t *lptr;
306
307 mp1 = 0;
300 MATCHMAP *mp;
301 MATCHMAP *mp1;
302 uint32_t i;
303 uint8_t *inptr;
304 uint8_t *outptr;
305 int32_t rval = FC_SUCCESS;
306 uint32_t *lptr;
307
308 mp1 = 0;
308 mb = 0;
309 mbq = 0;
309
310 /* Check if device is ready */
311 if (hba->state < FC_LINK_DOWN) {
312 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
313 "BIU: HBA not ready.");
314
315 return (FC_TRAN_BUSY);
316 }
317
318 /*
319 * Get a buffer which will be used for the mailbox command
320 */
310
311 /* Check if device is ready */
312 if (hba->state < FC_LINK_DOWN) {
313 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
314 "BIU: HBA not ready.");
315
316 return (FC_TRAN_BUSY);
317 }
318
319 /*
320 * Get a buffer which will be used for the mailbox command
321 */
321 if ((mb = (MAILBOX *) emlxs_mem_get(hba, MEM_MBOX | MEM_PRI)) == 0) {
322 if ((mbq = (MAILBOXQ *) emlxs_mem_get(hba, MEM_MBOX, 1)) == 0) {
322 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
323 "BIU: Mailbox allocation failed.");
324
325 rval = FC_NOMEM;
326 goto done;
327 }
328
329 /*
330 * Setup and issue mailbox RUN BIU DIAG command Setup test buffers
331 */
323 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
324 "BIU: Mailbox allocation failed.");
325
326 rval = FC_NOMEM;
327 goto done;
328 }
329
330 /*
331 * Setup and issue mailbox RUN BIU DIAG command Setup test buffers
332 */
332 if (((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF | MEM_PRI)) == 0) ||
333 ((mp1 = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF | MEM_PRI)) == 0)) {
333 if (((mp = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF, 1)) == 0) ||
334 ((mp1 = (MATCHMAP *) emlxs_mem_get(hba, MEM_BUF, 1)) == 0)) {
334 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
335 "BIU: Buffer allocation failed.");
336
337 rval = FC_NOMEM;
338 goto done;
339 }
340
341 if (pattern) {
342 /* Fill the transmit buffer with the pattern */
343 lptr = (uint32_t *)mp->virt;
344
345 for (i = 0; i < MEM_ELSBUF_SIZE; i += 4) {
346 *lptr++ = pattern;
347 }
348 } else {
349 /* Copy the default pattern into the trasmit buffer */
350 bcopy((caddr_t)&emlxs_diag_pattern[0], (caddr_t)mp->virt,
351 MEM_ELSBUF_SIZE);
352 }
335 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_diag_error_msg,
336 "BIU: Buffer allocation failed.");
337
338 rval = FC_NOMEM;
339 goto done;
340 }
341
342 if (pattern) {
343 /* Fill the transmit buffer with the pattern */
344 lptr = (uint32_t *)mp->virt;
345
346 for (i = 0; i < MEM_ELSBUF_SIZE; i += 4) {
347 *lptr++ = pattern;
348 }
349 } else {
350 /* Copy the default pattern into the trasmit buffer */
351 bcopy((caddr_t)&emlxs_diag_pattern[0], (caddr_t)mp->virt,
352 MEM_ELSBUF_SIZE);
353 }
353 emlxs_mpdata_sync(mp->dma_handle, 0, MEM_ELSBUF_SIZE,
354 EMLXS_MPDATA_SYNC(mp->dma_handle, 0, MEM_ELSBUF_SIZE,
354 DDI_DMA_SYNC_FORDEV);
355
356 bzero(mp1->virt, MEM_ELSBUF_SIZE);
355 DDI_DMA_SYNC_FORDEV);
356
357 bzero(mp1->virt, MEM_ELSBUF_SIZE);
357 emlxs_mpdata_sync(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
358 EMLXS_MPDATA_SYNC(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
358 DDI_DMA_SYNC_FORDEV);
359
360 /* Create the biu diag request */
359 DDI_DMA_SYNC_FORDEV);
360
361 /* Create the biu diag request */
361 (void) emlxs_mb_run_biu_diag(hba, mb, mp->phys, mp1->phys);
362 (void) emlxs_mb_run_biu_diag(hba, mbq, mp->phys, mp1->phys);
362
363
363 rval = emlxs_sli_issue_mbox_cmd(hba, mb, MBX_WAIT, 60);
364 rval = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbq, MBX_WAIT, 60);
364
365 if (rval == MBX_TIMEOUT) {
366 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_failed_msg,
367 "BUI diagnostic timed out.");
368
369 rval = EMLXS_TEST_FAILED;
370 goto done;
371 }
372
365
366 if (rval == MBX_TIMEOUT) {
367 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_failed_msg,
368 "BUI diagnostic timed out.");
369
370 rval = EMLXS_TEST_FAILED;
371 goto done;
372 }
373
373 emlxs_mpdata_sync(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
374 EMLXS_MPDATA_SYNC(mp1->dma_handle, 0, MEM_ELSBUF_SIZE,
374 DDI_DMA_SYNC_FORKERNEL);
375
376 outptr = mp->virt;
377 inptr = mp1->virt;
378
379 for (i = 0; i < MEM_ELSBUF_SIZE; i++, outptr++, inptr++) {
380 if (*outptr != *inptr) {
381 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_failed_msg,

--- 14 unchanged lines hidden (view full) ---

396done:
397
398 if (mp) {
399 (void) emlxs_mem_put(hba, MEM_BUF, (uint8_t *)mp);
400 }
401 if (mp1) {
402 (void) emlxs_mem_put(hba, MEM_BUF, (uint8_t *)mp1);
403 }
375 DDI_DMA_SYNC_FORKERNEL);
376
377 outptr = mp->virt;
378 inptr = mp1->virt;
379
380 for (i = 0; i < MEM_ELSBUF_SIZE; i++, outptr++, inptr++) {
381 if (*outptr != *inptr) {
382 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_biu_failed_msg,

--- 14 unchanged lines hidden (view full) ---

397done:
398
399 if (mp) {
400 (void) emlxs_mem_put(hba, MEM_BUF, (uint8_t *)mp);
401 }
402 if (mp1) {
403 (void) emlxs_mem_put(hba, MEM_BUF, (uint8_t *)mp1);
404 }
404 if (mb) {
405 (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mb);
405 if (mbq) {
406 (void) emlxs_mem_put(hba, MEM_MBOX, (uint8_t *)mbq);
406 }
407
408 return (rval);
409
407 }
408
409 return (rval);
410
410} /* emlxs_diag_biu_run() */
411} /* emlxs_diag_biu_run() */
411
412
413extern uint32_t
414emlxs_diag_post_run(emlxs_hba_t *hba)
415{
416 emlxs_port_t *port = &PPORT;
417 uint32_t rval = FC_SUCCESS;
418

--- 8 unchanged lines hidden (view full) ---

427 if ((rval = emlxs_offline(hba))) {
428 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_failed_msg,
429 "Unable to take adapter offline.");
430
431 rval = FC_RESETFAIL;
432 }
433
434 /* Restart the adapter */
412
413
414extern uint32_t
415emlxs_diag_post_run(emlxs_hba_t *hba)
416{
417 emlxs_port_t *port = &PPORT;
418 uint32_t rval = FC_SUCCESS;
419

--- 8 unchanged lines hidden (view full) ---

428 if ((rval = emlxs_offline(hba))) {
429 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_failed_msg,
430 "Unable to take adapter offline.");
431
432 rval = FC_RESETFAIL;
433 }
434
435 /* Restart the adapter */
435 rval = emlxs_sli_hba_reset(hba, 1, 1);
436 rval = EMLXS_SLI_HBA_RESET(hba, 1, 1, 0);
436
437 switch (rval) {
438 case 0:
439
440 (void) emlxs_online(hba);
441
442 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_complete_msg,
443 "Status good.");

--- 20 unchanged lines hidden (view full) ---

464 rval = FC_STATEC_BUSY;
465
466 break;
467
468 }
469
470 return (rval);
471
437
438 switch (rval) {
439 case 0:
440
441 (void) emlxs_online(hba);
442
443 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_post_complete_msg,
444 "Status good.");

--- 20 unchanged lines hidden (view full) ---

465 rval = FC_STATEC_BUSY;
466
467 break;
468
469 }
470
471 return (rval);
472
472} /* emlxs_diag_post_run() */
473
474
475/* ARGSUSED */
476extern uint32_t
477emlxs_core_size(emlxs_hba_t *hba)
478{
479
480 return (256);
481
482
483
484} /* emlxs_core_size() */
485
486
487/* ARGSUSED */
488extern uint32_t
489emlxs_core_dump(emlxs_hba_t *hba, char *buffer, uint32_t size)
490{
491 uint32_t i;
492
493 bzero(buffer, size);
494
495 /* Fill the buffer with dummy data */
496 for (i = 0; i < 256; i++) {
497 buffer[i] = (char)(i & 0xff);
498 }
499 return (FC_SUCCESS);
500
501
502
503} /* emlxs_core_dump() */
473} /* emlxs_diag_post_run() */