Deleted Added
full compact
isp_library.c (291013) isp_library.c (291080)
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

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

30 */
31#ifdef __NetBSD__
32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD$");
34#include <dev/ic/isp_netbsd.h>
35#endif
36#ifdef __FreeBSD__
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

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

30 */
31#ifdef __NetBSD__
32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD$");
34#include <dev/ic/isp_netbsd.h>
35#endif
36#ifdef __FreeBSD__
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/dev/isp/isp_library.c 291013 2015-11-18 11:14:59Z mav $");
38__FBSDID("$FreeBSD: head/sys/dev/isp/isp_library.c 291080 2015-11-19 17:43:47Z mav $");
39#include <dev/isp/isp_freebsd.h>
40#endif
41#ifdef __OpenBSD__
42#include <dev/ic/isp_openbsd.h>
43#endif
44#ifdef __linux__
45#include "isp_linux.h"
46#endif

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

560const char *
561isp_fc_toponame(fcparam *fcp)
562{
563
564 if (fcp->isp_loopstate < LOOP_LTEST_DONE) {
565 return "Unavailable";
566 }
567 switch (fcp->isp_topo) {
39#include <dev/isp/isp_freebsd.h>
40#endif
41#ifdef __OpenBSD__
42#include <dev/ic/isp_openbsd.h>
43#endif
44#ifdef __linux__
45#include "isp_linux.h"
46#endif

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

560const char *
561isp_fc_toponame(fcparam *fcp)
562{
563
564 if (fcp->isp_loopstate < LOOP_LTEST_DONE) {
565 return "Unavailable";
566 }
567 switch (fcp->isp_topo) {
568 case TOPO_NL_PORT: return "Private Loop";
569 case TOPO_FL_PORT: return "FL Port";
570 case TOPO_N_PORT: return "N-Port to N-Port";
571 case TOPO_F_PORT: return "F Port";
572 case TOPO_PTP_STUB: return "F Port (no FLOGI_ACC response)";
568 case TOPO_NL_PORT: return "Private Loop (NL_Port)";
569 case TOPO_FL_PORT: return "Public Loop (FL_Port)";
570 case TOPO_N_PORT: return "Point-to-Point (N_Port)";
571 case TOPO_F_PORT: return "Fabric (F_Port)";
572 case TOPO_PTP_STUB: return "Point-to-Point (no response)";
573 default: return "?????";
574 }
575}
576
577static int
578isp_fc_enable_vp(ispsoftc_t *isp, int chan)
579{
580 fcparam *fcp = FCPARAM(isp, chan);

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

2454}
2455
2456#endif
2457
2458/*
2459 * Find port database entries
2460 */
2461int
573 default: return "?????";
574 }
575}
576
577static int
578isp_fc_enable_vp(ispsoftc_t *isp, int chan)
579{
580 fcparam *fcp = FCPARAM(isp, chan);

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

2454}
2455
2456#endif
2457
2458/*
2459 * Find port database entries
2460 */
2461int
2462isp_find_pdb_by_wwn(ispsoftc_t *isp, int chan, uint64_t wwn, fcportdb_t **lptr)
2462isp_find_pdb_empty(ispsoftc_t *isp, int chan, fcportdb_t **lptr)
2463{
2463{
2464 fcparam *fcp;
2464 fcparam *fcp = FCPARAM(isp, chan);
2465 int i;
2466
2465 int i;
2466
2467 if (chan >= isp->isp_nchan)
2468 return (0);
2469 fcp = FCPARAM(isp, chan);
2470 for (i = 0; i < MAX_FC_TARG; i++) {
2471 fcportdb_t *lp = &fcp->portdb[i];
2472
2467 for (i = 0; i < MAX_FC_TARG; i++) {
2468 fcportdb_t *lp = &fcp->portdb[i];
2469
2470 if (lp->state == FC_PORTDB_STATE_NIL) {
2471 *lptr = lp;
2472 return (1);
2473 }
2474 }
2475 return (0);
2476}
2477
2478int
2479isp_find_pdb_by_wwpn(ispsoftc_t *isp, int chan, uint64_t wwpn, fcportdb_t **lptr)
2480{
2481 fcparam *fcp = FCPARAM(isp, chan);
2482 int i;
2483
2484 for (i = 0; i < MAX_FC_TARG; i++) {
2485 fcportdb_t *lp = &fcp->portdb[i];
2486
2473 if (lp->state == FC_PORTDB_STATE_NIL)
2474 continue;
2487 if (lp->state == FC_PORTDB_STATE_NIL)
2488 continue;
2475 if (lp->port_wwn == wwn) {
2489 if (lp->port_wwn == wwpn) {
2476 *lptr = lp;
2477 return (1);
2478 }
2479 }
2480 return (0);
2481}
2482
2490 *lptr = lp;
2491 return (1);
2492 }
2493 }
2494 return (0);
2495}
2496
2483#ifdef ISP_TARGET_MODE
2484
2485int
2497int
2486isp_find_pdb_by_handle(ispsoftc_t *isp, int chan, uint16_t handle, fcportdb_t **lptr)
2498isp_find_pdb_by_handle(ispsoftc_t *isp, int chan, uint16_t handle,
2499 fcportdb_t **lptr)
2487{
2500{
2488 fcparam *fcp;
2501 fcparam *fcp = FCPARAM(isp, chan);
2489 int i;
2490
2502 int i;
2503
2491 if (chan >= isp->isp_nchan)
2492 return (0);
2493 fcp = FCPARAM(isp, chan);
2494 for (i = 0; i < MAX_FC_TARG; i++) {
2495 fcportdb_t *lp = &fcp->portdb[i];
2496
2497 if (lp->state == FC_PORTDB_STATE_NIL)
2498 continue;
2499 if (lp->handle == handle) {
2500 *lptr = lp;
2501 return (1);
2502 }
2503 }
2504 return (0);
2505}
2506
2507int
2504 for (i = 0; i < MAX_FC_TARG; i++) {
2505 fcportdb_t *lp = &fcp->portdb[i];
2506
2507 if (lp->state == FC_PORTDB_STATE_NIL)
2508 continue;
2509 if (lp->handle == handle) {
2510 *lptr = lp;
2511 return (1);
2512 }
2513 }
2514 return (0);
2515}
2516
2517int
2508isp_find_pdb_by_sid(ispsoftc_t *isp, int chan, uint32_t sid, fcportdb_t **lptr)
2518isp_find_pdb_by_portid(ispsoftc_t *isp, int chan, uint32_t portid,
2519 fcportdb_t **lptr)
2509{
2520{
2510 fcparam *fcp;
2521 fcparam *fcp = FCPARAM(isp, chan);
2511 int i;
2512
2522 int i;
2523
2513 if (chan >= isp->isp_nchan)
2514 return (0);
2515 fcp = FCPARAM(isp, chan);
2516 for (i = 0; i < MAX_FC_TARG; i++) {
2517 fcportdb_t *lp = &fcp->portdb[i];
2518
2519 if (lp->state == FC_PORTDB_STATE_NIL)
2520 continue;
2524 for (i = 0; i < MAX_FC_TARG; i++) {
2525 fcportdb_t *lp = &fcp->portdb[i];
2526
2527 if (lp->state == FC_PORTDB_STATE_NIL)
2528 continue;
2521 if (lp->portid == sid) {
2529 if (lp->portid == portid) {
2522 *lptr = lp;
2523 return (1);
2524 }
2525 }
2526 return (0);
2527}
2528
2530 *lptr = lp;
2531 return (1);
2532 }
2533 }
2534 return (0);
2535}
2536
2537#ifdef ISP_TARGET_MODE
2529void
2530isp_find_chan_by_did(ispsoftc_t *isp, uint32_t did, uint16_t *cp)
2531{
2532 uint16_t chan;
2533
2534 *cp = ISP_NOCHAN;
2535 for (chan = 0; chan < isp->isp_nchan; chan++) {
2536 fcparam *fcp = FCPARAM(isp, chan);

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

2565 return;
2566 }
2567
2568 /*
2569 * If valid record for requested handle already exists, update it
2570 * with new parameters. Some cases of update can be suspicious,
2571 * so log them verbosely and dump the whole port database.
2572 */
2538void
2539isp_find_chan_by_did(ispsoftc_t *isp, uint32_t did, uint16_t *cp)
2540{
2541 uint16_t chan;
2542
2543 *cp = ISP_NOCHAN;
2544 for (chan = 0; chan < isp->isp_nchan; chan++) {
2545 fcparam *fcp = FCPARAM(isp, chan);

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

2574 return;
2575 }
2576
2577 /*
2578 * If valid record for requested handle already exists, update it
2579 * with new parameters. Some cases of update can be suspicious,
2580 * so log them verbosely and dump the whole port database.
2581 */
2573 if ((VALID_INI(wwpn) && isp_find_pdb_by_wwn(isp, chan, wwpn, &lp)) ||
2574 (s_id != PORT_NONE && isp_find_pdb_by_sid(isp, chan, s_id, &lp))) {
2582 if ((VALID_INI(wwpn) && isp_find_pdb_by_wwpn(isp, chan, wwpn, &lp)) ||
2583 (s_id != PORT_NONE && isp_find_pdb_by_portid(isp, chan, s_id, &lp))) {
2575 change = 0;
2576 lp->new_portid = lp->portid;
2577 lp->new_prli_word3 = lp->prli_word3;
2578 if (s_id != PORT_NONE && lp->portid != s_id) {
2579 if (lp->portid == PORT_NONE) {
2580 isp_prt(isp, ISP_LOGTINFO,
2581 "Chan %d WWPN 0x%016llx handle 0x%x "
2582 "gets PortID 0x%06x",

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

2651 lp->handle = nphdl;
2652 change++;
2653 }
2654 lp->state = FC_PORTDB_STATE_VALID;
2655 if (change) {
2656 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
2657 lp->portid = lp->new_portid;
2658 lp->prli_word3 = lp->new_prli_word3;
2584 change = 0;
2585 lp->new_portid = lp->portid;
2586 lp->new_prli_word3 = lp->prli_word3;
2587 if (s_id != PORT_NONE && lp->portid != s_id) {
2588 if (lp->portid == PORT_NONE) {
2589 isp_prt(isp, ISP_LOGTINFO,
2590 "Chan %d WWPN 0x%016llx handle 0x%x "
2591 "gets PortID 0x%06x",

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

2660 lp->handle = nphdl;
2661 change++;
2662 }
2663 lp->state = FC_PORTDB_STATE_VALID;
2664 if (change) {
2665 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
2666 lp->portid = lp->new_portid;
2667 lp->prli_word3 = lp->new_prli_word3;
2659 lp->new_prli_word3 = 0;
2660 lp->new_portid = 0;
2661 } else {
2662 isp_prt(isp, ISP_LOGTINFO,
2663 "Chan %d WWPN 0x%016llx PortID 0x%06x "
2664 "handle 0x%x reentered",
2665 chan, (unsigned long long) lp->port_wwn,
2666 lp->portid, lp->handle);
2667 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
2668 }

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

2793 */
2794 if (mp->nt_nphdl != NIL_HANDLE) {
2795 if (isp_find_pdb_by_handle(isp, mp->nt_channel, mp->nt_nphdl, &lp)) {
2796 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2797 return;
2798 }
2799 }
2800 if (mp->nt_wwn != INI_ANY) {
2668 } else {
2669 isp_prt(isp, ISP_LOGTINFO,
2670 "Chan %d WWPN 0x%016llx PortID 0x%06x "
2671 "handle 0x%x reentered",
2672 chan, (unsigned long long) lp->port_wwn,
2673 lp->portid, lp->handle);
2674 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
2675 }

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

2800 */
2801 if (mp->nt_nphdl != NIL_HANDLE) {
2802 if (isp_find_pdb_by_handle(isp, mp->nt_channel, mp->nt_nphdl, &lp)) {
2803 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2804 return;
2805 }
2806 }
2807 if (mp->nt_wwn != INI_ANY) {
2801 if (isp_find_pdb_by_wwn(isp, mp->nt_channel, mp->nt_wwn, &lp)) {
2808 if (isp_find_pdb_by_wwpn(isp, mp->nt_channel, mp->nt_wwn, &lp)) {
2802 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2803 return;
2804 }
2805 }
2806 if (mp->nt_sid != PORT_ANY && mp->nt_sid != PORT_NONE) {
2809 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2810 return;
2811 }
2812 }
2813 if (mp->nt_sid != PORT_ANY && mp->nt_sid != PORT_NONE) {
2807 if (isp_find_pdb_by_sid(isp, mp->nt_channel, mp->nt_sid, &lp)) {
2814 if (isp_find_pdb_by_portid(isp, mp->nt_channel, mp->nt_sid, &lp)) {
2808 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2809 return;
2810 }
2811 }
2812 isp_prt(isp, ISP_LOGWARN, "Chan %d unable to find entry to delete WWPN 0x%016jx PortID 0x%06x handle 0x%x",
2813 mp->nt_channel, mp->nt_wwn, mp->nt_sid, mp->nt_nphdl);
2814}
2815

--- 1203 unchanged lines hidden ---
2815 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid);
2816 return;
2817 }
2818 }
2819 isp_prt(isp, ISP_LOGWARN, "Chan %d unable to find entry to delete WWPN 0x%016jx PortID 0x%06x handle 0x%x",
2820 mp->nt_channel, mp->nt_wwn, mp->nt_sid, mp->nt_nphdl);
2821}
2822

--- 1203 unchanged lines hidden ---