isp.c (163899) | isp.c (164272) |
---|---|
1/*- 2 * Copyright (c) 1997-2006 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 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37/* 38 * Include header file appropriate for platform we're building on. 39 */ 40#ifdef __NetBSD__ 41#include <dev/ic/isp_netbsd.h> 42#endif 43#ifdef __FreeBSD__ 44#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2006 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 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37/* 38 * Include header file appropriate for platform we're building on. 39 */ 40#ifdef __NetBSD__ 41#include <dev/ic/isp_netbsd.h> 42#endif 43#ifdef __FreeBSD__ 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 163899 2006-11-02 03:21:32Z mjacob $"); | 45__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 164272 2006-11-14 08:45:48Z mjacob $"); |
46#include <dev/isp/isp_freebsd.h> 47#endif 48#ifdef __OpenBSD__ 49#include <dev/ic/isp_openbsd.h> 50#endif 51#ifdef __linux__ 52#include "isp_linux.h" 53#endif 54#ifdef __svr4__ 55#include "isp_solaris.h" 56#endif 57 58/* 59 * General defines 60 */ 61 62#define MBOX_DELAY_COUNT 1000000 / 100 | 46#include <dev/isp/isp_freebsd.h> 47#endif 48#ifdef __OpenBSD__ 49#include <dev/ic/isp_openbsd.h> 50#endif 51#ifdef __linux__ 52#include "isp_linux.h" 53#endif 54#ifdef __svr4__ 55#include "isp_solaris.h" 56#endif 57 58/* 59 * General defines 60 */ 61 62#define MBOX_DELAY_COUNT 1000000 / 100 |
63#define ISP_MARK_PORTDB(a, b) \ 64 isp_prt(isp, ISP_LOGSANCFG, "line %d: markportdb", __LINE__); \ 65 isp_mark_portdb(a, b) |
|
63 64/* 65 * Local static data 66 */ 67static const char fconf[] = 68 "PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n" 69 " database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)"; 70static const char notresp[] = --- 33 unchanged lines hidden (view full) --- 104static void 105isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, long *); 106static void isp_fastpost_complete(ispsoftc_t *, uint16_t); 107static int isp_mbox_continue(ispsoftc_t *); 108static void isp_scsi_init(ispsoftc_t *); 109static void isp_scsi_channel_init(ispsoftc_t *, int); 110static void isp_fibre_init(ispsoftc_t *); 111static void isp_fibre_init_2400(ispsoftc_t *); | 66 67/* 68 * Local static data 69 */ 70static const char fconf[] = 71 "PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n" 72 " database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)"; 73static const char notresp[] = --- 33 unchanged lines hidden (view full) --- 107static void 108isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, long *); 109static void isp_fastpost_complete(ispsoftc_t *, uint16_t); 110static int isp_mbox_continue(ispsoftc_t *); 111static void isp_scsi_init(ispsoftc_t *); 112static void isp_scsi_channel_init(ispsoftc_t *, int); 113static void isp_fibre_init(ispsoftc_t *); 114static void isp_fibre_init_2400(ispsoftc_t *); |
112static void isp_dump_portdb(ispsoftc_t *); | |
113static void isp_mark_portdb(ispsoftc_t *, int); 114static void isp_plogx_24xx(ispsoftc_t *, uint16_t, uint32_t, int *); 115static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t); 116static void isp_port_logout(ispsoftc_t *, uint16_t, uint32_t); 117static int isp_getpdb(ispsoftc_t *, uint16_t, isp_pdb_t *, int); 118static uint64_t isp_get_portname(ispsoftc_t *, int, int); 119static int isp_fclink_test(ispsoftc_t *, int); | 115static void isp_mark_portdb(ispsoftc_t *, int); 116static void isp_plogx_24xx(ispsoftc_t *, uint16_t, uint32_t, int *); 117static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t); 118static void isp_port_logout(ispsoftc_t *, uint16_t, uint32_t); 119static int isp_getpdb(ispsoftc_t *, uint16_t, isp_pdb_t *, int); 120static uint64_t isp_get_portname(ispsoftc_t *, int, int); 121static int isp_fclink_test(ispsoftc_t *, int); |
120static const char *isp2100_fw_statename(int); | 122static const char *ispfc_fw_statename(int); |
121static int isp_pdb_sync(ispsoftc_t *); 122static int isp_scan_loop(ispsoftc_t *); 123static int isp_gid_ft_sns(ispsoftc_t *); 124static int isp_gid_ft_ct_passthru(ispsoftc_t *); 125static int isp_scan_fabric(ispsoftc_t *); 126static int isp_login_device(ispsoftc_t *, uint32_t, isp_pdb_t *, uint16_t *); 127static int isp_register_fc4_type(ispsoftc_t *); 128static int isp_register_fc4_type_24xx(ispsoftc_t *); --- 1039 unchanged lines hidden (view full) --- 1168 if (IS_DUALBUS(isp)) { 1169 isp_setdfltparm(isp, 1); 1170 } 1171 1172 if (IS_FC(isp)) { 1173 /* 1174 * Do this *before* initializing the firmware. 1175 */ | 123static int isp_pdb_sync(ispsoftc_t *); 124static int isp_scan_loop(ispsoftc_t *); 125static int isp_gid_ft_sns(ispsoftc_t *); 126static int isp_gid_ft_ct_passthru(ispsoftc_t *); 127static int isp_scan_fabric(ispsoftc_t *); 128static int isp_login_device(ispsoftc_t *, uint32_t, isp_pdb_t *, uint16_t *); 129static int isp_register_fc4_type(ispsoftc_t *); 130static int isp_register_fc4_type_24xx(ispsoftc_t *); --- 1039 unchanged lines hidden (view full) --- 1170 if (IS_DUALBUS(isp)) { 1171 isp_setdfltparm(isp, 1); 1172 } 1173 1174 if (IS_FC(isp)) { 1175 /* 1176 * Do this *before* initializing the firmware. 1177 */ |
1176 isp_mark_portdb(isp, 0); | 1178 ISP_MARK_PORTDB(isp, 0); |
1177 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 1178 FCPARAM(isp)->isp_loopstate = LOOP_NIL; 1179 1180 if (isp->isp_role != ISP_ROLE_NONE) { 1181 if (IS_24XX(isp)) { 1182 isp_fibre_init_2400(isp); 1183 } else { 1184 isp_fibre_init(isp); --- 857 unchanged lines hidden (view full) --- 2042 isp->isp_residx = 0; 2043 2044 /* 2045 * Whatever happens, we're now committed to being here. 2046 */ 2047 isp->isp_state = ISP_INITSTATE; 2048} 2049 | 1179 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 1180 FCPARAM(isp)->isp_loopstate = LOOP_NIL; 1181 1182 if (isp->isp_role != ISP_ROLE_NONE) { 1183 if (IS_24XX(isp)) { 1184 isp_fibre_init_2400(isp); 1185 } else { 1186 isp_fibre_init(isp); --- 857 unchanged lines hidden (view full) --- 2044 isp->isp_residx = 0; 2045 2046 /* 2047 * Whatever happens, we're now committed to being here. 2048 */ 2049 isp->isp_state = ISP_INITSTATE; 2050} 2051 |
2050/* 2051 * Fibre Channel Support- get the port database for the id. 2052 */ | |
2053static void | 2052static void |
2054isp_dump_portdb(ispsoftc_t *isp) 2055{ 2056 fcparam *fcp = (fcparam *) isp->isp_param; 2057 int i; 2058 2059 for (i = 0; i < MAX_FC_TARG; i++) { 2060 char mb[4]; 2061 const char *dbs[8] = { 2062 "NIL ", 2063 "PROB", 2064 "DEAD", 2065 "CHGD", 2066 "NEW ", 2067 "PVLD", 2068 "????", 2069 "VLD " 2070 }; 2071 const char *roles[4] = { 2072 " UNK", " TGT", " INI", "TINI" 2073 }; 2074 fcportdb_t *lp = &fcp->portdb[i]; 2075 2076 if (lp->state == FC_PORTDB_STATE_NIL) { 2077 continue; 2078 } 2079 if (lp->ini_map_idx) { 2080 SNPRINTF(mb, sizeof (mb), "%3d", 2081 ((int) lp->ini_map_idx) - 1); 2082 } else { 2083 SNPRINTF(mb, sizeof (mb), "---"); 2084 } 2085 isp_prt(isp, ISP_LOGALL, "%d: %s al%d tgt %s %s 0x%06x =>%s" 2086 " 0x%06x; WWNN 0x%08x%08x WWPN 0x%08x%08x", i, 2087 dbs[lp->state], lp->autologin, mb, 2088 roles[lp->roles], lp->portid, 2089 roles[lp->new_roles], lp->new_portid, 2090 (uint32_t) (lp->node_wwn >> 32), 2091 (uint32_t) (lp->node_wwn), 2092 (uint32_t) (lp->port_wwn >> 32), 2093 (uint32_t) (lp->port_wwn)); 2094 } 2095} 2096 2097static void | |
2098isp_mark_portdb(ispsoftc_t *isp, int onprobation) 2099{ 2100 fcparam *fcp = (fcparam *) isp->isp_param; 2101 int i; 2102 2103 for (i = 0; i < MAX_FC_TARG; i++) { | 2053isp_mark_portdb(ispsoftc_t *isp, int onprobation) 2054{ 2055 fcparam *fcp = (fcparam *) isp->isp_param; 2056 int i; 2057 2058 for (i = 0; i < MAX_FC_TARG; i++) { |
2104 fcp->isp_ini_map[i] = 0; | |
2105 if (onprobation == 0) { 2106 MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); 2107 } else { 2108 switch (fcp->portdb[i].state) { 2109 case FC_PORTDB_STATE_CHANGED: 2110 case FC_PORTDB_STATE_PENDING_VALID: 2111 case FC_PORTDB_STATE_VALID: 2112 case FC_PORTDB_STATE_PROBATIONAL: 2113 fcp->portdb[i].state = 2114 FC_PORTDB_STATE_PROBATIONAL; 2115 break; | 2059 if (onprobation == 0) { 2060 MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); 2061 } else { 2062 switch (fcp->portdb[i].state) { 2063 case FC_PORTDB_STATE_CHANGED: 2064 case FC_PORTDB_STATE_PENDING_VALID: 2065 case FC_PORTDB_STATE_VALID: 2066 case FC_PORTDB_STATE_PROBATIONAL: 2067 fcp->portdb[i].state = 2068 FC_PORTDB_STATE_PROBATIONAL; 2069 break; |
2070 case FC_PORTDB_STATE_ZOMBIE: 2071 break; |
|
2116 case FC_PORTDB_STATE_NIL: 2117 default: 2118 MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); 2119 fcp->portdb[i].state = 2120 FC_PORTDB_STATE_NIL; 2121 break; 2122 } 2123 } --- 38 unchanged lines hidden (view full) --- 2162 MEMZERO(&mbs, sizeof (mbs)); 2163 mbs.param[0] = MBOX_EXEC_COMMAND_IOCB_A64; 2164 mbs.param[1] = QENTRY_LEN; 2165 mbs.param[2] = DMA_WD1(FCPARAM(isp)->isp_scdma); 2166 mbs.param[3] = DMA_WD0(FCPARAM(isp)->isp_scdma); 2167 mbs.param[6] = DMA_WD3(FCPARAM(isp)->isp_scdma); 2168 mbs.param[7] = DMA_WD2(FCPARAM(isp)->isp_scdma); 2169 mbs.logval = MBLOGALL; | 2072 case FC_PORTDB_STATE_NIL: 2073 default: 2074 MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); 2075 fcp->portdb[i].state = 2076 FC_PORTDB_STATE_NIL; 2077 break; 2078 } 2079 } --- 38 unchanged lines hidden (view full) --- 2118 MEMZERO(&mbs, sizeof (mbs)); 2119 mbs.param[0] = MBOX_EXEC_COMMAND_IOCB_A64; 2120 mbs.param[1] = QENTRY_LEN; 2121 mbs.param[2] = DMA_WD1(FCPARAM(isp)->isp_scdma); 2122 mbs.param[3] = DMA_WD0(FCPARAM(isp)->isp_scdma); 2123 mbs.param[6] = DMA_WD3(FCPARAM(isp)->isp_scdma); 2124 mbs.param[7] = DMA_WD2(FCPARAM(isp)->isp_scdma); 2125 mbs.logval = MBLOGALL; |
2126 mbs.timeout = 250000; |
|
2170 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN); 2171 isp_mboxcmd(isp, &mbs); 2172 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 2173 *log_ret = mbs.param[0]; 2174 } 2175 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN); 2176 scp += QENTRY_LEN; 2177 isp_get_plogx(isp, (isp_plogx_t *) scp, plp); --- 93 unchanged lines hidden (view full) --- 2271 mbs.ibits = (1 << 10); 2272 } else { 2273 mbs.param[1] = handle << 8; 2274 } 2275 mbs.param[2] = portid >> 16; 2276 mbs.param[3] = portid; 2277 2278 mbs.logval = MBLOGNONE; | 2127 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN); 2128 isp_mboxcmd(isp, &mbs); 2129 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 2130 *log_ret = mbs.param[0]; 2131 } 2132 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN); 2133 scp += QENTRY_LEN; 2134 isp_get_plogx(isp, (isp_plogx_t *) scp, plp); --- 93 unchanged lines hidden (view full) --- 2228 mbs.ibits = (1 << 10); 2229 } else { 2230 mbs.param[1] = handle << 8; 2231 } 2232 mbs.param[2] = portid >> 16; 2233 mbs.param[3] = portid; 2234 2235 mbs.logval = MBLOGNONE; |
2236 mbs.timeout = 250000; |
|
2279 isp_mboxcmd(isp, &mbs); 2280 2281 switch (mbs.param[0]) { 2282 case MBOX_PORT_ID_USED: 2283 isp_prt(isp, ISP_LOGDEBUG0, 2284 "isp_port_login: portid 0x%06x already logged in as %u", 2285 portid, mbs.param[1]); 2286 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); --- 171 unchanged lines hidden (view full) --- 2458 uint8_t lwfs; 2459 int loopid; 2460 fcparam *fcp; 2461 fcportdb_t *lp; 2462 isp_pdb_t pdb; 2463 2464 fcp = isp->isp_param; 2465 | 2237 isp_mboxcmd(isp, &mbs); 2238 2239 switch (mbs.param[0]) { 2240 case MBOX_PORT_ID_USED: 2241 isp_prt(isp, ISP_LOGDEBUG0, 2242 "isp_port_login: portid 0x%06x already logged in as %u", 2243 portid, mbs.param[1]); 2244 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); --- 171 unchanged lines hidden (view full) --- 2416 uint8_t lwfs; 2417 int loopid; 2418 fcparam *fcp; 2419 fcportdb_t *lp; 2420 isp_pdb_t pdb; 2421 2422 fcp = isp->isp_param; 2423 |
2466 isp_prt(isp, ISP_LOGDEBUG0, "FC Link Test Entry"); 2467 isp_mark_portdb(isp, 1); | 2424 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Link Test Entry"); 2425 ISP_MARK_PORTDB(isp, 1); |
2468 2469 /* 2470 * Wait up to N microseconds for F/W to go to a ready state. 2471 */ 2472 lwfs = FW_CONFIG_WAIT; 2473 count = 0; 2474 while (count < usdelay) { 2475 uint64_t enano; 2476 uint32_t wrk; 2477 NANOTIME_T hra, hrb; 2478 2479 GET_NANOTIME(&hra); 2480 isp_fw_state(isp); 2481 if (lwfs != fcp->isp_fwstate) { | 2426 2427 /* 2428 * Wait up to N microseconds for F/W to go to a ready state. 2429 */ 2430 lwfs = FW_CONFIG_WAIT; 2431 count = 0; 2432 while (count < usdelay) { 2433 uint64_t enano; 2434 uint32_t wrk; 2435 NANOTIME_T hra, hrb; 2436 2437 GET_NANOTIME(&hra); 2438 isp_fw_state(isp); 2439 if (lwfs != fcp->isp_fwstate) { |
2482 isp_prt(isp, ISP_LOGINFO, "Firmware State <%s->%s>", 2483 isp2100_fw_statename((int)lwfs), 2484 isp2100_fw_statename((int)fcp->isp_fwstate)); | 2440 isp_prt(isp, ISP_LOGCONFIG|ISP_LOGSANCFG, 2441 "Firmware State <%s->%s>", 2442 ispfc_fw_statename((int)lwfs), 2443 ispfc_fw_statename((int)fcp->isp_fwstate)); |
2485 lwfs = fcp->isp_fwstate; 2486 } 2487 if (fcp->isp_fwstate == FW_READY) { 2488 break; 2489 } 2490 GET_NANOTIME(&hrb); 2491 2492 /* --- 35 unchanged lines hidden (view full) --- 2528 count += (wrk / 1000); 2529 } 2530 } 2531 2532 /* 2533 * If we haven't gone to 'ready' state, return. 2534 */ 2535 if (fcp->isp_fwstate != FW_READY) { | 2444 lwfs = fcp->isp_fwstate; 2445 } 2446 if (fcp->isp_fwstate == FW_READY) { 2447 break; 2448 } 2449 GET_NANOTIME(&hrb); 2450 2451 /* --- 35 unchanged lines hidden (view full) --- 2487 count += (wrk / 1000); 2488 } 2489 } 2490 2491 /* 2492 * If we haven't gone to 'ready' state, return. 2493 */ 2494 if (fcp->isp_fwstate != FW_READY) { |
2536 isp_prt(isp, ISP_LOGDEBUG0, | 2495 isp_prt(isp, ISP_LOGSANCFG, |
2537 "isp_fclink_test: not at FW_READY state"); 2538 return (-1); 2539 } 2540 2541 /* 2542 * Get our Loop ID and Port ID. 2543 */ 2544 MEMZERO(&mbs, sizeof (mbs)); --- 95 unchanged lines hidden (view full) --- 2640 fcp->isp_gbspeed = 2; 2641 } 2642 } 2643 } 2644 2645 /* 2646 * Announce ourselves, too. 2647 */ | 2496 "isp_fclink_test: not at FW_READY state"); 2497 return (-1); 2498 } 2499 2500 /* 2501 * Get our Loop ID and Port ID. 2502 */ 2503 MEMZERO(&mbs, sizeof (mbs)); --- 95 unchanged lines hidden (view full) --- 2599 fcp->isp_gbspeed = 2; 2600 } 2601 } 2602 } 2603 2604 /* 2605 * Announce ourselves, too. 2606 */ |
2648 isp_prt(isp, ISP_LOGCONFIG, topology, fcp->isp_portid, | 2607 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, topology, fcp->isp_portid, |
2649 fcp->isp_loopid, toponames[fcp->isp_topo]); | 2608 fcp->isp_loopid, toponames[fcp->isp_topo]); |
2650 isp_prt(isp, ISP_LOGCONFIG, ourwwn, | 2609 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, ourwwn, |
2651 (uint32_t) (ISP_NODEWWN(isp) >> 32), 2652 (uint32_t) ISP_NODEWWN(isp), 2653 (uint32_t) (ISP_PORTWWN(isp) >> 32), 2654 (uint32_t) ISP_PORTWWN(isp)); | 2610 (uint32_t) (ISP_NODEWWN(isp) >> 32), 2611 (uint32_t) ISP_NODEWWN(isp), 2612 (uint32_t) (ISP_PORTWWN(isp) >> 32), 2613 (uint32_t) ISP_PORTWWN(isp)); |
2655 isp_prt(isp, ISP_LOGDEBUG0, "FC Link Test Complete"); | 2614 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Link Test Complete"); |
2656 return (0); 2657} 2658 2659static const char * | 2615 return (0); 2616} 2617 2618static const char * |
2660isp2100_fw_statename(int state) | 2619ispfc_fw_statename(int state) |
2661{ 2662 switch(state) { 2663 case FW_CONFIG_WAIT: return "Config Wait"; 2664 case FW_WAIT_AL_PA: return "Waiting for AL_PA"; 2665 case FW_WAIT_LOGIN: return "Wait Login"; 2666 case FW_READY: return "Ready"; 2667 case FW_LOSS_OF_SYNC: return "Loss Of Sync"; 2668 case FW_ERROR: return "Error"; --- 62 unchanged lines hidden (view full) --- 2731 if (isp_scan_fabric(isp) != 0) { 2732 isp_prt(isp, ISP_LOGWARN, 2733 "isp_pdb_sync: isp_scan_fabric failed"); 2734 return (-1); 2735 } 2736 } 2737 } 2738 | 2620{ 2621 switch(state) { 2622 case FW_CONFIG_WAIT: return "Config Wait"; 2623 case FW_WAIT_AL_PA: return "Waiting for AL_PA"; 2624 case FW_WAIT_LOGIN: return "Wait Login"; 2625 case FW_READY: return "Ready"; 2626 case FW_LOSS_OF_SYNC: return "Loss Of Sync"; 2627 case FW_ERROR: return "Error"; --- 62 unchanged lines hidden (view full) --- 2690 if (isp_scan_fabric(isp) != 0) { 2691 isp_prt(isp, ISP_LOGWARN, 2692 "isp_pdb_sync: isp_scan_fabric failed"); 2693 return (-1); 2694 } 2695 } 2696 } 2697 |
2698 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Synchronizing PDBs"); 2699 |
|
2739 fcp->isp_loopstate = LOOP_SYNCING_PDB; 2740 2741 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 2742 lp = &fcp->portdb[dbidx]; 2743 2744 if (lp->state == FC_PORTDB_STATE_NIL) { 2745 continue; 2746 } --- 5 unchanged lines hidden (view full) --- 2752 dbidx); 2753 } 2754 continue; 2755 } 2756 2757 switch (lp->state) { 2758 case FC_PORTDB_STATE_PROBATIONAL: 2759 case FC_PORTDB_STATE_DEAD: | 2700 fcp->isp_loopstate = LOOP_SYNCING_PDB; 2701 2702 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 2703 lp = &fcp->portdb[dbidx]; 2704 2705 if (lp->state == FC_PORTDB_STATE_NIL) { 2706 continue; 2707 } --- 5 unchanged lines hidden (view full) --- 2713 dbidx); 2714 } 2715 continue; 2716 } 2717 2718 switch (lp->state) { 2719 case FC_PORTDB_STATE_PROBATIONAL: 2720 case FC_PORTDB_STATE_DEAD: |
2760 isp_async(isp, ISPASYNC_DEV_GONE, lp); 2761 if (lp->ini_map_idx) { 2762 fcp->isp_ini_map[lp->ini_map_idx-1] = 0; 2763 lp->ini_map_idx = 0; 2764 } | 2721 /* 2722 * It's up to the outer layers to clear isp_ini_map. 2723 */ |
2765 lp->state = FC_PORTDB_STATE_NIL; | 2724 lp->state = FC_PORTDB_STATE_NIL; |
2725 isp_async(isp, ISPASYNC_DEV_GONE, lp); |
|
2766 if (lp->autologin == 0) { 2767 if (IS_24XX(isp)) { 2768 int action = 2769 PLOGX_FLG_CMD_LOGO | 2770 PLOGX_FLG_IMPLICIT | 2771 PLOGX_FLG_FREE_NPHDL; 2772 FC_SCRATCH_ACQUIRE(isp); 2773 isp_plogx_24xx(isp, lp->handle, 2774 lp->portid, &action); 2775 FC_SCRATCH_RELEASE(isp); 2776 } else { 2777 isp_port_logout(isp, lp->handle, 2778 lp->portid); 2779 } 2780 } else { 2781 lp->autologin = 0; 2782 } 2783 lp->new_roles = 0; 2784 lp->new_portid = 0; | 2726 if (lp->autologin == 0) { 2727 if (IS_24XX(isp)) { 2728 int action = 2729 PLOGX_FLG_CMD_LOGO | 2730 PLOGX_FLG_IMPLICIT | 2731 PLOGX_FLG_FREE_NPHDL; 2732 FC_SCRATCH_ACQUIRE(isp); 2733 isp_plogx_24xx(isp, lp->handle, 2734 lp->portid, &action); 2735 FC_SCRATCH_RELEASE(isp); 2736 } else { 2737 isp_port_logout(isp, lp->handle, 2738 lp->portid); 2739 } 2740 } else { 2741 lp->autologin = 0; 2742 } 2743 lp->new_roles = 0; 2744 lp->new_portid = 0; |
2745 /* 2746 * Note that we might come out of this with our state 2747 * set to FC_PORTDB_STATE_ZOMBIE. 2748 */ |
|
2785 break; 2786 case FC_PORTDB_STATE_NEW: 2787 /* | 2749 break; 2750 case FC_PORTDB_STATE_NEW: 2751 /* |
2788 * If *we* have a new target dole and *it* has a target 2789 * role, assign a new target id to it. | 2752 * It's up to the outer layers to assign a virtual 2753 * target id in isp_ini_map (if any). |
2790 */ 2791 lp->portid = lp->new_portid; 2792 lp->roles = lp->new_roles; 2793 lp->state = FC_PORTDB_STATE_VALID; | 2754 */ 2755 lp->portid = lp->new_portid; 2756 lp->roles = lp->new_roles; 2757 lp->state = FC_PORTDB_STATE_VALID; |
2794 if ((isp->isp_role & ISP_ROLE_INITIATOR) && 2795 (lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT))) { 2796 int i, t = dbidx; 2797 for (i = 0; i < MAX_FC_TARG; i++) { 2798 if (i < FL_ID || i > SNS_ID) { 2799 if (fcp->isp_ini_map[t] == 0) { 2800 break; 2801 } 2802 } 2803 if (++t == MAX_FC_TARG) { 2804 t = 0; 2805 } 2806 } 2807 if (i < MAX_FC_TARG) { 2808 fcp->isp_ini_map[t] = dbidx + 1; 2809 lp->ini_map_idx = t + 1; 2810 } else { 2811 isp_prt(isp, ISP_LOGWARN, 2812 "out of target ids"); 2813 } 2814 } | |
2815 isp_async(isp, ISPASYNC_DEV_ARRIVED, lp); 2816 lp->new_roles = 0; 2817 lp->new_portid = 0; | 2758 isp_async(isp, ISPASYNC_DEV_ARRIVED, lp); 2759 lp->new_roles = 0; 2760 lp->new_portid = 0; |
2761 lp->reserved = 0; 2762 lp->new_reserved = 0; |
|
2818 break; 2819 case FC_PORTDB_STATE_CHANGED: | 2763 break; 2764 case FC_PORTDB_STATE_CHANGED: |
2820 lp->portid = lp->new_portid; 2821 lp->roles = lp->new_roles; | 2765/* 2766 * XXXX FIX THIS 2767 */ |
2822 lp->state = FC_PORTDB_STATE_VALID; | 2768 lp->state = FC_PORTDB_STATE_VALID; |
2823 if (lp->ini_map_idx) { 2824 int t = lp->ini_map_idx - 1; 2825 fcp->isp_ini_map[t] = dbidx + 1; 2826 } | |
2827 isp_async(isp, ISPASYNC_DEV_CHANGED, lp); 2828 lp->new_roles = 0; 2829 lp->new_portid = 0; | 2769 isp_async(isp, ISPASYNC_DEV_CHANGED, lp); 2770 lp->new_roles = 0; 2771 lp->new_portid = 0; |
2772 lp->reserved = 0; 2773 lp->new_reserved = 0; |
|
2830 break; 2831 case FC_PORTDB_STATE_PENDING_VALID: 2832 lp->portid = lp->new_portid; 2833 lp->roles = lp->new_roles; | 2774 break; 2775 case FC_PORTDB_STATE_PENDING_VALID: 2776 lp->portid = lp->new_portid; 2777 lp->roles = lp->new_roles; |
2834 lp->state = FC_PORTDB_STATE_VALID; | |
2835 if (lp->ini_map_idx) { 2836 int t = lp->ini_map_idx - 1; 2837 fcp->isp_ini_map[t] = dbidx + 1; 2838 } | 2778 if (lp->ini_map_idx) { 2779 int t = lp->ini_map_idx - 1; 2780 fcp->isp_ini_map[t] = dbidx + 1; 2781 } |
2782 lp->state = FC_PORTDB_STATE_VALID; |
|
2839 isp_async(isp, ISPASYNC_DEV_STAYED, lp); 2840 if (dbidx != FL_ID) { 2841 lp->new_roles = 0; 2842 lp->new_portid = 0; 2843 } | 2783 isp_async(isp, ISPASYNC_DEV_STAYED, lp); 2784 if (dbidx != FL_ID) { 2785 lp->new_roles = 0; 2786 lp->new_portid = 0; 2787 } |
2788 lp->reserved = 0; 2789 lp->new_reserved = 0; |
|
2844 break; | 2790 break; |
2791 case FC_PORTDB_STATE_ZOMBIE: 2792 break; |
|
2845 default: | 2793 default: |
2846 isp_prt(isp, ISP_LOGERR, "eh? state %d for idx %d", | 2794 isp_prt(isp, ISP_LOGWARN, 2795 "isp_scan_loop: state %d for idx %d", |
2847 lp->state, dbidx); 2848 isp_dump_portdb(isp); 2849 } 2850 } 2851 2852 /* 2853 * If we get here, we've for sure seen not only a valid loop 2854 * but know what is or isn't on it, so mark this for usage --- 9 unchanged lines hidden (view full) --- 2864 */ 2865static int 2866isp_scan_loop(ispsoftc_t *isp) 2867{ 2868 fcportdb_t *lp, tmp; 2869 fcparam *fcp = isp->isp_param; 2870 int i; 2871 isp_pdb_t pdb; | 2796 lp->state, dbidx); 2797 isp_dump_portdb(isp); 2798 } 2799 } 2800 2801 /* 2802 * If we get here, we've for sure seen not only a valid loop 2803 * but know what is or isn't on it, so mark this for usage --- 9 unchanged lines hidden (view full) --- 2813 */ 2814static int 2815isp_scan_loop(ispsoftc_t *isp) 2816{ 2817 fcportdb_t *lp, tmp; 2818 fcparam *fcp = isp->isp_param; 2819 int i; 2820 isp_pdb_t pdb; |
2872 uint16_t dbidx, lim = 0; | 2821 uint16_t handle, lim = 0; |
2873 2874 if (fcp->isp_fwstate < FW_READY || 2875 fcp->isp_loopstate < LOOP_PDB_RCVD) { 2876 return (-1); 2877 } 2878 2879 if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) { 2880 return (0); --- 20 unchanged lines hidden (view full) --- 2901 break; 2902 default: 2903 isp_prt(isp, ISP_LOGDEBUG0, "no loop topology to scan"); 2904 fcp->isp_loopstate = LOOP_LSCAN_DONE; 2905 return (0); 2906 } 2907 2908 fcp->isp_loopstate = LOOP_SCANNING_LOOP; | 2822 2823 if (fcp->isp_fwstate < FW_READY || 2824 fcp->isp_loopstate < LOOP_PDB_RCVD) { 2825 return (-1); 2826 } 2827 2828 if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) { 2829 return (0); --- 20 unchanged lines hidden (view full) --- 2850 break; 2851 default: 2852 isp_prt(isp, ISP_LOGDEBUG0, "no loop topology to scan"); 2853 fcp->isp_loopstate = LOOP_LSCAN_DONE; 2854 return (0); 2855 } 2856 2857 fcp->isp_loopstate = LOOP_SCANNING_LOOP; |
2909 isp_prt(isp, ISP_LOGDEBUG0, "scanning loop 0..%d", lim-1); | |
2910 | 2858 |
2859 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC scan loop 0..%d", lim-1); |
|
2911 | 2860 |
2861 |
|
2912 /* 2913 * Run through the list and get the port database info for each one. 2914 */ | 2862 /* 2863 * Run through the list and get the port database info for each one. 2864 */ |
2915 for (dbidx = 0; dbidx < lim; dbidx++) { | 2865 for (handle = 0; handle < lim; handle++) { |
2916 /* 2917 * But don't even try for ourselves... 2918 */ | 2866 /* 2867 * But don't even try for ourselves... 2868 */ |
2919 if (dbidx == fcp->isp_loopid) { | 2869 if (handle == fcp->isp_loopid) { |
2920 continue; 2921 } 2922 2923 /* 2924 * In older cards with older f/w GET_PORT_DATABASE has been 2925 * known to hang. This trick gets around that problem. 2926 */ 2927 if (IS_2100(isp) || IS_2200(isp)) { | 2870 continue; 2871 } 2872 2873 /* 2874 * In older cards with older f/w GET_PORT_DATABASE has been 2875 * known to hang. This trick gets around that problem. 2876 */ 2877 if (IS_2100(isp) || IS_2200(isp)) { |
2928 uint64_t node_wwn = isp_get_portname(isp, dbidx, 1); | 2878 uint64_t node_wwn = isp_get_portname(isp, handle, 1); |
2929 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { 2930 return (-1); 2931 } 2932 if (node_wwn == 0) { 2933 continue; 2934 } 2935 } 2936 2937 /* 2938 * Get the port database entity for this index. 2939 */ | 2879 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { 2880 return (-1); 2881 } 2882 if (node_wwn == 0) { 2883 continue; 2884 } 2885 } 2886 2887 /* 2888 * Get the port database entity for this index. 2889 */ |
2940 if (isp_getpdb(isp, dbidx, &pdb, 1) != 0) { | 2890 if (isp_getpdb(isp, handle, &pdb, 1) != 0) { |
2941 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { | 2891 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { |
2942 isp_mark_portdb(isp, 1); | 2892 ISP_MARK_PORTDB(isp, 1); |
2943 return (-1); 2944 } 2945 continue; 2946 } 2947 2948 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { | 2893 return (-1); 2894 } 2895 continue; 2896 } 2897 2898 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) { |
2949 isp_mark_portdb(isp, 1); | 2899 ISP_MARK_PORTDB(isp, 1); |
2950 return (-1); 2951 } 2952 2953 /* 2954 * On *very* old 2100 firmware we would end up sometimes 2955 * with the firmware returning the port database entry | 2900 return (-1); 2901 } 2902 2903 /* 2904 * On *very* old 2100 firmware we would end up sometimes 2905 * with the firmware returning the port database entry |
2956 * for something else. We used to restart locally, but 2957 * now we punt. | 2906 * for something else. We used to restart this, but 2907 * now we just punt. |
2958 */ | 2908 */ |
2959 if (IS_2100(isp) && pdb.handle != dbidx) { | 2909 if (IS_2100(isp) && pdb.handle != handle) { |
2960 isp_prt(isp, ISP_LOGWARN, 2961 "giving up on synchronizing the port database"); | 2910 isp_prt(isp, ISP_LOGWARN, 2911 "giving up on synchronizing the port database"); |
2962 isp_mark_portdb(isp, 1); | 2912 ISP_MARK_PORTDB(isp, 1); |
2963 return (-1); 2964 } 2965 2966 /* 2967 * Save the pertinent info locally. 2968 */ 2969 MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename); 2970 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname); 2971 tmp.roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; 2972 tmp.portid = pdb.portid; 2973 tmp.handle = pdb.handle; 2974 2975 /* 2976 * Check to make sure it's still a valid entry. The 24XX seems 2977 * to return a portid but not a WWPN/WWNN or role for devices 2978 * which shift on a loop. 2979 */ 2980 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { | 2913 return (-1); 2914 } 2915 2916 /* 2917 * Save the pertinent info locally. 2918 */ 2919 MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename); 2920 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname); 2921 tmp.roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; 2922 tmp.portid = pdb.portid; 2923 tmp.handle = pdb.handle; 2924 2925 /* 2926 * Check to make sure it's still a valid entry. The 24XX seems 2927 * to return a portid but not a WWPN/WWNN or role for devices 2928 * which shift on a loop. 2929 */ 2930 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { |
2981 isp_prt(isp, ISP_LOGWARN, 2982 "bad pdb entry at loop %d", dbidx); | 2931 isp_prt(isp, ISP_LOGWARN, "bad pdb @ loop %d", handle); |
2983 isp_dump_portdb(isp); 2984 continue; 2985 } 2986 2987 /* 2988 * Now search the entire port database 2989 * for the same Port and Node WWN. 2990 */ --- 6 unchanged lines hidden (view full) --- 2997 continue; 2998 } 2999 if (lp->port_wwn != tmp.port_wwn) { 3000 continue; 3001 } 3002 3003 /* 3004 * Okay- we've found a non-nil entry that matches. | 2932 isp_dump_portdb(isp); 2933 continue; 2934 } 2935 2936 /* 2937 * Now search the entire port database 2938 * for the same Port and Node WWN. 2939 */ --- 6 unchanged lines hidden (view full) --- 2946 continue; 2947 } 2948 if (lp->port_wwn != tmp.port_wwn) { 2949 continue; 2950 } 2951 2952 /* 2953 * Okay- we've found a non-nil entry that matches. |
3005 * Check to make sure it's probational. | 2954 * Check to make sure it's probational or a zombie. |
3006 */ | 2955 */ |
3007 if (lp->state != FC_PORTDB_STATE_PROBATIONAL) { | 2956 if (lp->state != FC_PORTDB_STATE_PROBATIONAL && 2957 lp->state != FC_PORTDB_STATE_ZOMBIE) { |
3008 isp_prt(isp, ISP_LOGERR, | 2958 isp_prt(isp, ISP_LOGERR, |
3009 "portdb entry %d not probational (0x%x)", | 2959 "[%d] not probational/zombie (0x%x)", |
3010 i, lp->state); 3011 isp_dump_portdb(isp); | 2960 i, lp->state); 2961 isp_dump_portdb(isp); |
3012 isp_mark_portdb(isp, 1); | 2962 ISP_MARK_PORTDB(isp, 1); |
3013 return (-1); 3014 } 3015 | 2963 return (-1); 2964 } 2965 |
2966 /* 2967 * Mark the device as something the f/w logs into 2968 * automatically. 2969 */ |
|
3016 lp->autologin = 1; | 2970 lp->autologin = 1; |
2971 |
|
3017 /* | 2972 /* |
3018 * Check to make sure it's really the same 3019 * device and update the initiator map before 3020 * we mark it as pending valid. | 2973 * Check to make see if really still the same 2974 * device. If it is, we mark it pending valid. |
3021 */ 3022 if (lp->portid == tmp.portid && 3023 lp->handle == tmp.handle && 3024 lp->roles == tmp.roles) { 3025 lp->new_portid = tmp.portid; 3026 lp->new_roles = tmp.roles; 3027 lp->state = FC_PORTDB_STATE_PENDING_VALID; | 2975 */ 2976 if (lp->portid == tmp.portid && 2977 lp->handle == tmp.handle && 2978 lp->roles == tmp.roles) { 2979 lp->new_portid = tmp.portid; 2980 lp->new_roles = tmp.roles; 2981 lp->state = FC_PORTDB_STATE_PENDING_VALID; |
2982 isp_prt(isp, ISP_LOGSANCFG, 2983 "Loop Port 0x%06x@0x%x Pending Valid", 2984 tmp.portid, tmp.handle); |
|
3028 break; 3029 } 3030 3031 /* | 2985 break; 2986 } 2987 2988 /* |
3032 * We can wipe out the old handle value here because 3033 * it's no longer valid. | 2989 * We can wipe out the old handle value 2990 * here because it's no longer valid. |
3034 */ 3035 lp->handle = tmp.handle; 3036 3037 /* 3038 * Claim that this has changed and let somebody else 3039 * decide what to do. 3040 */ | 2991 */ 2992 lp->handle = tmp.handle; 2993 2994 /* 2995 * Claim that this has changed and let somebody else 2996 * decide what to do. 2997 */ |
2998 isp_prt(isp, ISP_LOGSANCFG, 2999 "Loop Port 0x%06x@0x%x changed", 3000 tmp.portid, tmp.handle); |
|
3041 lp->state = FC_PORTDB_STATE_CHANGED; 3042 lp->new_portid = tmp.portid; 3043 lp->new_roles = tmp.roles; 3044 break; 3045 } 3046 3047 /* 3048 * Did we find and update an old entry? --- 7 unchanged lines hidden (view full) --- 3056 * for it and save info for later disposition. 3057 */ 3058 for (i = 0; i < MAX_FC_TARG; i++) { 3059 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) { 3060 break; 3061 } 3062 } 3063 if (i == MAX_FC_TARG) { | 3001 lp->state = FC_PORTDB_STATE_CHANGED; 3002 lp->new_portid = tmp.portid; 3003 lp->new_roles = tmp.roles; 3004 break; 3005 } 3006 3007 /* 3008 * Did we find and update an old entry? --- 7 unchanged lines hidden (view full) --- 3016 * for it and save info for later disposition. 3017 */ 3018 for (i = 0; i < MAX_FC_TARG; i++) { 3019 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) { 3020 break; 3021 } 3022 } 3023 if (i == MAX_FC_TARG) { |
3064 isp_prt(isp, ISP_LOGERR, 3065 "could not find slot for new entry"); | 3024 isp_prt(isp, ISP_LOGERR, "out of portdb entries"); |
3066 continue; 3067 } 3068 lp = &fcp->portdb[i]; 3069 | 3025 continue; 3026 } 3027 lp = &fcp->portdb[i]; 3028 |
3029 MEMZERO(lp, sizeof (fcportdb_t)); |
|
3070 lp->autologin = 1; 3071 lp->state = FC_PORTDB_STATE_NEW; | 3030 lp->autologin = 1; 3031 lp->state = FC_PORTDB_STATE_NEW; |
3072 lp->portid = 0; 3073 lp->roles = 0; | |
3074 lp->new_portid = tmp.portid; 3075 lp->new_roles = tmp.roles; 3076 lp->handle = tmp.handle; 3077 lp->port_wwn = tmp.port_wwn; 3078 lp->node_wwn = tmp.node_wwn; | 3032 lp->new_portid = tmp.portid; 3033 lp->new_roles = tmp.roles; 3034 lp->handle = tmp.handle; 3035 lp->port_wwn = tmp.port_wwn; 3036 lp->node_wwn = tmp.node_wwn; |
3037 isp_prt(isp, ISP_LOGSANCFG, 3038 "Loop Port 0x%06x@0x%x is New Entry", 3039 tmp.portid, tmp.handle); |
|
3079 } | 3040 } |
3080 | |
3081 fcp->isp_loopstate = LOOP_LSCAN_DONE; 3082 return (0); 3083} 3084 3085/* 3086 * Scan the fabric for devices and add them to our port database. 3087 * 3088 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows. --- 164 unchanged lines hidden (view full) --- 3253isp_scan_fabric(ispsoftc_t *isp) 3254{ 3255 fcparam *fcp = FCPARAM(isp); 3256 uint32_t portid; 3257 uint16_t handle, oldhandle; 3258 int portidx, portlim, r; 3259 sns_gid_ft_rsp_t *rs0, *rs1; 3260 | 3041 fcp->isp_loopstate = LOOP_LSCAN_DONE; 3042 return (0); 3043} 3044 3045/* 3046 * Scan the fabric for devices and add them to our port database. 3047 * 3048 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows. --- 164 unchanged lines hidden (view full) --- 3213isp_scan_fabric(ispsoftc_t *isp) 3214{ 3215 fcparam *fcp = FCPARAM(isp); 3216 uint32_t portid; 3217 uint16_t handle, oldhandle; 3218 int portidx, portlim, r; 3219 sns_gid_ft_rsp_t *rs0, *rs1; 3220 |
3261 isp_prt(isp, ISP_LOGDEBUG0, "FC Scan Fabric"); | 3221 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Scan Fabric"); |
3262 if (fcp->isp_fwstate != FW_READY || 3263 fcp->isp_loopstate < LOOP_LSCAN_DONE) { 3264 return (-1); 3265 } 3266 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) { 3267 return (0); 3268 } 3269 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) { 3270 fcp->isp_loopstate = LOOP_FSCAN_DONE; | 3222 if (fcp->isp_fwstate != FW_READY || 3223 fcp->isp_loopstate < LOOP_LSCAN_DONE) { 3224 return (-1); 3225 } 3226 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) { 3227 return (0); 3228 } 3229 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) { 3230 fcp->isp_loopstate = LOOP_FSCAN_DONE; |
3271 isp_prt(isp, ISP_LOGDEBUG0, "FC Scan Fabric Done (no fabric)"); | 3231 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3232 "FC Scan Fabric Done (no fabric)"); |
3272 return (0); 3273 } 3274 3275 FC_SCRATCH_ACQUIRE(isp); 3276 fcp->isp_loopstate = LOOP_SCANNING_FABRIC; 3277 3278 if (IS_24XX(isp)) { 3279 r = isp_gid_ft_ct_passthru(isp); --- 18 unchanged lines hidden (view full) --- 3298 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN); 3299 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF); 3300 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF); 3301 isp_get_gid_ft_response(isp, rs0, rs1, NGENT); 3302 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) { 3303 int level; 3304 if (rs1->snscb_cthdr.ct_reason == 9 && 3305 rs1->snscb_cthdr.ct_explanation == 7) { | 3233 return (0); 3234 } 3235 3236 FC_SCRATCH_ACQUIRE(isp); 3237 fcp->isp_loopstate = LOOP_SCANNING_FABRIC; 3238 3239 if (IS_24XX(isp)) { 3240 r = isp_gid_ft_ct_passthru(isp); --- 18 unchanged lines hidden (view full) --- 3259 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN); 3260 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF); 3261 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF); 3262 isp_get_gid_ft_response(isp, rs0, rs1, NGENT); 3263 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) { 3264 int level; 3265 if (rs1->snscb_cthdr.ct_reason == 9 && 3266 rs1->snscb_cthdr.ct_explanation == 7) { |
3306 level = ISP_LOGDEBUG0; | 3267 level = ISP_LOGSANCFG|ISP_LOGDEBUG0; |
3307 } else { 3308 level = ISP_LOGWARN; 3309 } 3310 isp_prt(isp, level, "Fabric Nameserver rejected GID_FT " 3311 "(Reason=0x%x Expl=0x%x)", rs1->snscb_cthdr.ct_reason, 3312 rs1->snscb_cthdr.ct_explanation); 3313 FC_SCRATCH_RELEASE(isp); 3314 fcp->isp_loopstate = LOOP_FSCAN_DONE; --- 28 unchanged lines hidden (view full) --- 3343 /* 3344 * If we're not at the last entry, our list wasn't big enough. 3345 */ 3346 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) { 3347 isp_prt(isp, ISP_LOGWARN, 3348 "fabric too big for scratch area: increase ISP2100_SCRLEN"); 3349 } 3350 portlim = portidx + 1; | 3268 } else { 3269 level = ISP_LOGWARN; 3270 } 3271 isp_prt(isp, level, "Fabric Nameserver rejected GID_FT " 3272 "(Reason=0x%x Expl=0x%x)", rs1->snscb_cthdr.ct_reason, 3273 rs1->snscb_cthdr.ct_explanation); 3274 FC_SCRATCH_RELEASE(isp); 3275 fcp->isp_loopstate = LOOP_FSCAN_DONE; --- 28 unchanged lines hidden (view full) --- 3304 /* 3305 * If we're not at the last entry, our list wasn't big enough. 3306 */ 3307 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) { 3308 isp_prt(isp, ISP_LOGWARN, 3309 "fabric too big for scratch area: increase ISP2100_SCRLEN"); 3310 } 3311 portlim = portidx + 1; |
3351 isp_prt(isp, ISP_LOGDEBUG0, "got %d ports back from name server", 3352 portlim); | 3312 isp_prt(isp, ISP_LOGSANCFG, 3313 "got %d ports back from name server", portlim); |
3353 3354 for (portidx = 0; portidx < portlim; portidx++) { 3355 int npidx; 3356 3357 portid = 3358 ((rs1->snscb_ports[portidx].portid[0]) << 16) | 3359 ((rs1->snscb_ports[portidx].portid[1]) << 8) | 3360 ((rs1->snscb_ports[portidx].portid[2])); --- 7 unchanged lines hidden (view full) --- 3368 break; 3369 } 3370 } 3371 3372 if (npidx < portlim) { 3373 rs1->snscb_ports[npidx].portid[0] = 0; 3374 rs1->snscb_ports[npidx].portid[1] = 0; 3375 rs1->snscb_ports[npidx].portid[2] = 0; | 3314 3315 for (portidx = 0; portidx < portlim; portidx++) { 3316 int npidx; 3317 3318 portid = 3319 ((rs1->snscb_ports[portidx].portid[0]) << 16) | 3320 ((rs1->snscb_ports[portidx].portid[1]) << 8) | 3321 ((rs1->snscb_ports[portidx].portid[2])); --- 7 unchanged lines hidden (view full) --- 3329 break; 3330 } 3331 } 3332 3333 if (npidx < portlim) { 3334 rs1->snscb_ports[npidx].portid[0] = 0; 3335 rs1->snscb_ports[npidx].portid[1] = 0; 3336 rs1->snscb_ports[npidx].portid[2] = 0; |
3376 isp_prt(isp, ISP_LOGDEBUG0, | 3337 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, |
3377 "removing duplicate PortID 0x%x entry from list", 3378 portid); 3379 } 3380 } 3381 3382 /* 3383 * Okay, we now have a list of Port IDs for all FC4 SCSI devices 3384 * that the Fabric Name server knows about. --- 16 unchanged lines hidden (view full) --- 3401 int dbidx, r, nr; 3402 3403 portid = 3404 ((rs1->snscb_ports[portidx].portid[0]) << 16) | 3405 ((rs1->snscb_ports[portidx].portid[1]) << 8) | 3406 ((rs1->snscb_ports[portidx].portid[2])); 3407 3408 if (portid == 0) { | 3338 "removing duplicate PortID 0x%x entry from list", 3339 portid); 3340 } 3341 } 3342 3343 /* 3344 * Okay, we now have a list of Port IDs for all FC4 SCSI devices 3345 * that the Fabric Name server knows about. --- 16 unchanged lines hidden (view full) --- 3362 int dbidx, r, nr; 3363 3364 portid = 3365 ((rs1->snscb_ports[portidx].portid[0]) << 16) | 3366 ((rs1->snscb_ports[portidx].portid[1]) << 8) | 3367 ((rs1->snscb_ports[portidx].portid[2])); 3368 3369 if (portid == 0) { |
3409 isp_prt(isp, ISP_LOGDEBUG0, | 3370 isp_prt(isp, ISP_LOGSANCFG, |
3410 "skipping null PortID at idx %d", portidx); 3411 continue; 3412 } 3413 3414 /* 3415 * Skip ourselves... 3416 */ 3417 if (portid == fcp->isp_portid) { | 3371 "skipping null PortID at idx %d", portidx); 3372 continue; 3373 } 3374 3375 /* 3376 * Skip ourselves... 3377 */ 3378 if (portid == fcp->isp_portid) { |
3418 isp_prt(isp, ISP_LOGDEBUG0, | 3379 isp_prt(isp, ISP_LOGSANCFG, |
3419 "skip ourselves @ PortID 0x%06x", portid); 3420 continue; 3421 } | 3380 "skip ourselves @ PortID 0x%06x", portid); 3381 continue; 3382 } |
3422 isp_prt(isp, ISP_LOGDEBUG0, "Fabric Port 0x%06x", portid); | 3383 isp_prt(isp, ISP_LOGSANCFG, 3384 "Checking Fabric Port 0x%06x", portid); |
3423 3424 /* 3425 * We now search our Port Database for any | 3385 3386 /* 3387 * We now search our Port Database for any |
3426 * probational entries with this PortID. | 3388 * probational entries with this PortID. We don't 3389 * look for zombies here- only probational 3390 * entries (we've already logged out of zombies). |
3427 */ 3428 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3429 lp = &fcp->portdb[dbidx]; 3430 3431 if (lp->state != FC_PORTDB_STATE_PROBATIONAL) { 3432 continue; 3433 } 3434 if (lp->portid == portid) { --- 24 unchanged lines hidden (view full) --- 3459 * database entry for somebody further along to 3460 * decide what to do (policy choice). 3461 * 3462 */ 3463 3464 r = isp_getpdb(isp, lp->handle, &pdb, 0); 3465 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { 3466 FC_SCRATCH_RELEASE(isp); | 3391 */ 3392 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3393 lp = &fcp->portdb[dbidx]; 3394 3395 if (lp->state != FC_PORTDB_STATE_PROBATIONAL) { 3396 continue; 3397 } 3398 if (lp->portid == portid) { --- 24 unchanged lines hidden (view full) --- 3423 * database entry for somebody further along to 3424 * decide what to do (policy choice). 3425 * 3426 */ 3427 3428 r = isp_getpdb(isp, lp->handle, &pdb, 0); 3429 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { 3430 FC_SCRATCH_RELEASE(isp); |
3467 isp_mark_portdb(isp, 1); | 3431 ISP_MARK_PORTDB(isp, 1); |
3468 return (-1); 3469 } 3470 if (r != 0) { 3471 lp->new_portid = portid; 3472 lp->state = FC_PORTDB_STATE_DEAD; | 3432 return (-1); 3433 } 3434 if (r != 0) { 3435 lp->new_portid = portid; 3436 lp->state = FC_PORTDB_STATE_DEAD; |
3437 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3438 "Fabric Port 0x%06x considered dead", 3439 portid); |
|
3473 continue; 3474 } 3475 3476 3477 /* 3478 * Check to make sure that handle, portid, WWPN and 3479 * WWNN agree. If they don't, then the association 3480 * between this PortID and the stated handle has been 3481 * broken by the firmware. 3482 */ 3483 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3484 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3485 if (pdb.handle != lp->handle || 3486 pdb.portid != portid || 3487 wwpn != lp->port_wwn || 3488 wwnn != lp->node_wwn) { | 3440 continue; 3441 } 3442 3443 3444 /* 3445 * Check to make sure that handle, portid, WWPN and 3446 * WWNN agree. If they don't, then the association 3447 * between this PortID and the stated handle has been 3448 * broken by the firmware. 3449 */ 3450 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3451 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3452 if (pdb.handle != lp->handle || 3453 pdb.portid != portid || 3454 wwpn != lp->port_wwn || 3455 wwnn != lp->node_wwn) { |
3489 isp_prt(isp, ISP_LOGDEBUG0, fconf, dbidx, 3490 pdb.handle, pdb.portid, | 3456 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3457 fconf, dbidx, pdb.handle, pdb.portid, |
3491 (uint32_t) (wwnn >> 32), (uint32_t) wwnn, 3492 (uint32_t) (wwpn >> 32), (uint32_t) wwpn, 3493 lp->handle, portid, 3494 (uint32_t) (lp->node_wwn >> 32), 3495 (uint32_t) lp->node_wwn, 3496 (uint32_t) (lp->port_wwn >> 32), 3497 (uint32_t) lp->port_wwn); 3498 /* --- 6 unchanged lines hidden (view full) --- 3505 */ 3506 if (isp_login_device(isp, portid, &pdb, 3507 &oldhandle)) { 3508 lp->new_portid = portid; 3509 lp->state = FC_PORTDB_STATE_DEAD; 3510 if (fcp->isp_loopstate != 3511 LOOP_SCANNING_FABRIC) { 3512 FC_SCRATCH_RELEASE(isp); | 3458 (uint32_t) (wwnn >> 32), (uint32_t) wwnn, 3459 (uint32_t) (wwpn >> 32), (uint32_t) wwpn, 3460 lp->handle, portid, 3461 (uint32_t) (lp->node_wwn >> 32), 3462 (uint32_t) lp->node_wwn, 3463 (uint32_t) (lp->port_wwn >> 32), 3464 (uint32_t) lp->port_wwn); 3465 /* --- 6 unchanged lines hidden (view full) --- 3472 */ 3473 if (isp_login_device(isp, portid, &pdb, 3474 &oldhandle)) { 3475 lp->new_portid = portid; 3476 lp->state = FC_PORTDB_STATE_DEAD; 3477 if (fcp->isp_loopstate != 3478 LOOP_SCANNING_FABRIC) { 3479 FC_SCRATCH_RELEASE(isp); |
3513 isp_mark_portdb(isp, 1); | 3480 ISP_MARK_PORTDB(isp, 1); |
3514 return (-1); 3515 } 3516 continue; 3517 } 3518 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3519 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3520 if (wwpn != lp->port_wwn || 3521 wwnn != lp->node_wwn) { --- 21 unchanged lines hidden (view full) --- 3543 * changed device and save the new port id and role 3544 * and let somebody else decide. 3545 */ 3546 3547 lp->new_portid = portid; 3548 lp->new_roles = nr; 3549 if (pdb.portid != lp->portid || nr != lp->roles || 3550 handle_changed) { | 3481 return (-1); 3482 } 3483 continue; 3484 } 3485 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3486 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3487 if (wwpn != lp->port_wwn || 3488 wwnn != lp->node_wwn) { --- 21 unchanged lines hidden (view full) --- 3510 * changed device and save the new port id and role 3511 * and let somebody else decide. 3512 */ 3513 3514 lp->new_portid = portid; 3515 lp->new_roles = nr; 3516 if (pdb.portid != lp->portid || nr != lp->roles || 3517 handle_changed) { |
3518 isp_prt(isp, ISP_LOGSANCFG, 3519 "Fabric Port 0x%06x changed", portid); |
|
3551 lp->state = FC_PORTDB_STATE_CHANGED; 3552 } else { | 3520 lp->state = FC_PORTDB_STATE_CHANGED; 3521 } else { |
3522 isp_prt(isp, ISP_LOGSANCFG, 3523 "Fabric Port 0x%06x Now Pending Valid", 3524 portid); |
|
3553 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3554 } 3555 continue; 3556 } 3557 3558 /* 3559 * Ah- a new entry. Search the database again for all non-NIL | 3525 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3526 } 3527 continue; 3528 } 3529 3530 /* 3531 * Ah- a new entry. Search the database again for all non-NIL |
3560 * entries to make sure we never ever make a database entry 3561 * with the same port id. | 3532 * entries to make sure we never ever make a new database entry 3533 * with the same port id. While we're at it, mark where the 3534 * last free entry was. |
3562 */ | 3535 */ |
3563 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3564 if (dbidx >= FL_ID && dbidx <= SNS_ID) { | 3536 3537 dbidx = MAX_FC_TARG; 3538 for (lp = fcp->portdb; lp < &fcp->portdb[MAX_FC_TARG]; lp++) { 3539 if (lp >= &fcp->portdb[FL_ID] && 3540 lp <= &fcp->portdb[SNS_ID]) { |
3565 continue; 3566 } | 3541 continue; 3542 } |
3567 if (fcp->portdb[dbidx].state == FC_PORTDB_STATE_NIL) { | 3543 if (lp->state == FC_PORTDB_STATE_NIL) { 3544 if (dbidx == MAX_FC_TARG) { 3545 dbidx = lp - fcp->portdb; 3546 } |
3568 continue; 3569 } | 3547 continue; 3548 } |
3570 if (fcp->portdb[dbidx].portid == portid) { | 3549 if (lp->state == FC_PORTDB_STATE_ZOMBIE) { 3550 continue; 3551 } 3552 if (lp->portid == portid) { |
3571 break; 3572 } 3573 } 3574 | 3553 break; 3554 } 3555 } 3556 |
3575 if (dbidx != MAX_FC_TARG) { | 3557 if (lp < &fcp->portdb[MAX_FC_TARG]) { |
3576 isp_prt(isp, ISP_LOGWARN, 3577 "PortID 0x%06x already at %d handle %d state %d", | 3558 isp_prt(isp, ISP_LOGWARN, 3559 "PortID 0x%06x already at %d handle %d state %d", |
3578 portid, dbidx, fcp->portdb[dbidx].handle, 3579 fcp->portdb[dbidx].state); | 3560 portid, dbidx, lp->handle, lp->state); |
3580 continue; 3581 } 3582 3583 /* | 3561 continue; 3562 } 3563 3564 /* |
3584 * Find an empty database entry for it. | 3565 * We should have the index of the first free entry seen. |
3585 */ | 3566 */ |
3586 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3587 if (dbidx >= FL_ID && dbidx <= SNS_ID) { 3588 continue; 3589 } 3590 if (fcp->portdb[dbidx].state == FC_PORTDB_STATE_NIL) { 3591 break; 3592 } 3593 } 3594 | |
3595 if (dbidx == MAX_FC_TARG) { 3596 isp_prt(isp, ISP_LOGERR, | 3567 if (dbidx == MAX_FC_TARG) { 3568 isp_prt(isp, ISP_LOGERR, |
3597 "port database too small to login fabric device" 3598 "- increase MAX_FC_TARG"); | 3569 "port database too small to login PortID 0x%06x" 3570 "- increase MAX_FC_TARG", portid); |
3599 continue; 3600 } 3601 3602 /* | 3571 continue; 3572 } 3573 3574 /* |
3575 * Otherwise, point to our new home. 3576 */ 3577 lp = &fcp->portdb[dbidx]; 3578 3579 /* |
|
3603 * Try to see if we are logged into this device, 3604 * and maybe log into it. 3605 * 3606 * isp_login_device will check for handle and 3607 * portid consistency after login. 3608 */ 3609 if (isp_login_device(isp, portid, &pdb, &oldhandle)) { 3610 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { 3611 FC_SCRATCH_RELEASE(isp); | 3580 * Try to see if we are logged into this device, 3581 * and maybe log into it. 3582 * 3583 * isp_login_device will check for handle and 3584 * portid consistency after login. 3585 */ 3586 if (isp_login_device(isp, portid, &pdb, &oldhandle)) { 3587 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { 3588 FC_SCRATCH_RELEASE(isp); |
3612 isp_mark_portdb(isp, 1); | 3589 ISP_MARK_PORTDB(isp, 1); |
3613 return (-1); 3614 } 3615 continue; 3616 } 3617 3618 handle = pdb.handle; 3619 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3620 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3621 nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; 3622 3623 /* 3624 * And go through the database *one* more time to make sure 3625 * that we do not make more than one entry that has the same 3626 * WWNN/WWPN duple 3627 */ | 3590 return (-1); 3591 } 3592 continue; 3593 } 3594 3595 handle = pdb.handle; 3596 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3597 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3598 nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; 3599 3600 /* 3601 * And go through the database *one* more time to make sure 3602 * that we do not make more than one entry that has the same 3603 * WWNN/WWPN duple 3604 */ |
3628 lp = &fcp->portdb[dbidx]; 3629 | |
3630 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { | 3605 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { |
3631 if (fcp->portdb[dbidx].state == FC_PORTDB_STATE_NIL) { | 3606 if (dbidx >= FL_ID && dbidx <= SNS_ID) { |
3632 continue; 3633 } | 3607 continue; 3608 } |
3634 if (dbidx >= FL_ID && dbidx <= SNS_ID) { | 3609 if (fcp->portdb[dbidx].state == FC_PORTDB_STATE_NIL) { |
3635 continue; 3636 } 3637 if (fcp->portdb[dbidx].node_wwn == wwnn && 3638 fcp->portdb[dbidx].port_wwn == wwpn) { 3639 break; 3640 } 3641 } 3642 | 3610 continue; 3611 } 3612 if (fcp->portdb[dbidx].node_wwn == wwnn && 3613 fcp->portdb[dbidx].port_wwn == wwpn) { 3614 break; 3615 } 3616 } 3617 |
3643 if (dbidx != MAX_FC_TARG) { | 3618 if (dbidx == MAX_FC_TARG) { 3619 MEMZERO(lp, sizeof (fcportdb_t)); 3620 lp->handle = handle; 3621 lp->node_wwn = wwnn; 3622 lp->port_wwn = wwpn; 3623 lp->new_portid = portid; 3624 lp->new_roles = nr; 3625 lp->state = FC_PORTDB_STATE_NEW; 3626 isp_prt(isp, ISP_LOGSANCFG, 3627 "Fabric Port 0x%06x is New Entry", portid); 3628 continue; 3629 } 3630 3631 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) { |
3644 isp_prt(isp, ISP_LOGWARN, 3645 "PortID 0x%x 0x%08x%08x/0x%08x%08x %ld already at " | 3632 isp_prt(isp, ISP_LOGWARN, 3633 "PortID 0x%x 0x%08x%08x/0x%08x%08x %ld already at " |
3646 "idx %d", portid, | 3634 "idx %d, state 0x%x", portid, |
3647 (uint32_t) (wwnn >> 32), (uint32_t) wwnn, 3648 (uint32_t) (wwpn >> 32), (uint32_t) wwpn, | 3635 (uint32_t) (wwnn >> 32), (uint32_t) wwnn, 3636 (uint32_t) (wwpn >> 32), (uint32_t) wwpn, |
3649 (long) (lp - fcp->portdb), dbidx); | 3637 (long) (lp - fcp->portdb), dbidx, 3638 fcp->portdb[dbidx].state); |
3650 continue; 3651 } 3652 | 3639 continue; 3640 } 3641 |
3642 /* 3643 * We found a zombie entry that matches us. 3644 * Revive it. We know that WWN and WWPN 3645 * are the same. For fabric devices, we 3646 * don't care that handle is different 3647 * as we assign that. If role or portid 3648 * are different, it maybe a changed device. 3649 */ 3650 lp = &fcp->portdb[dbidx]; |
|
3653 lp->handle = handle; | 3651 lp->handle = handle; |
3654 lp->ini_map_idx = 0; 3655 lp->node_wwn = wwnn; 3656 lp->port_wwn = wwpn; | |
3657 lp->new_portid = portid; 3658 lp->new_roles = nr; | 3652 lp->new_portid = portid; 3653 lp->new_roles = nr; |
3659 lp->state = FC_PORTDB_STATE_NEW; | 3654 if (lp->portid != portid || lp->roles != nr) { 3655 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3656 "Zombie Fabric Port 0x%06x Now Changed", portid); 3657 lp->state = FC_PORTDB_STATE_CHANGED; 3658 } else { 3659 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3660 "Zombie Fabric Port 0x%06x Now Pending Valid", 3661 portid); 3662 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3663 } |
3660 } 3661 | 3664 } 3665 |
3662 | |
3663 FC_SCRATCH_RELEASE(isp); 3664 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { | 3666 FC_SCRATCH_RELEASE(isp); 3667 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { |
3665 isp_mark_portdb(isp, 1); | 3668 ISP_MARK_PORTDB(isp, 1); |
3666 return (-1); 3667 } 3668 fcp->isp_loopstate = LOOP_FSCAN_DONE; | 3669 return (-1); 3670 } 3671 fcp->isp_loopstate = LOOP_FSCAN_DONE; |
3669 isp_prt(isp, ISP_LOGDEBUG0, "FC Scan Fabric Done"); | 3672 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Scan Fabric Done"); |
3670 return (0); 3671} 3672 3673/* 3674 * Find an unused handle and try and use to login to a port. 3675 */ 3676static int 3677isp_login_device(ispsoftc_t *isp, uint32_t portid, isp_pdb_t *p, uint16_t *ohp) --- 53 unchanged lines hidden (view full) --- 3731 break; 3732 } else { 3733 *ohp = handle; 3734 handle = isp_nxt_handle(isp, *ohp); 3735 } 3736 } 3737 3738 if (i == lim) { | 3673 return (0); 3674} 3675 3676/* 3677 * Find an unused handle and try and use to login to a port. 3678 */ 3679static int 3680isp_login_device(ispsoftc_t *isp, uint32_t portid, isp_pdb_t *p, uint16_t *ohp) --- 53 unchanged lines hidden (view full) --- 3734 break; 3735 } else { 3736 *ohp = handle; 3737 handle = isp_nxt_handle(isp, *ohp); 3738 } 3739 } 3740 3741 if (i == lim) { |
3739 isp_prt(isp, ISP_LOGINFO, "PLOGI 0x%06x failed", portid); | 3742 isp_prt(isp, ISP_LOGWARN, "PLOGI 0x%06x failed", portid); |
3740 return (-1); 3741 } 3742 3743 /* 3744 * If we successfully logged into it, get the PDB for it 3745 * so we can crosscheck that it is still what we think it 3746 * is and that we also have the role it plays 3747 */ --- 141 unchanged lines hidden (view full) --- 3889 pt->ctp_status); 3890 return (-1); 3891 } 3892 3893 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct); 3894 FC_SCRATCH_RELEASE(isp); 3895 3896 if (ct->ct_cmd_resp == LS_RJT) { | 3743 return (-1); 3744 } 3745 3746 /* 3747 * If we successfully logged into it, get the PDB for it 3748 * so we can crosscheck that it is still what we think it 3749 * is and that we also have the role it plays 3750 */ --- 141 unchanged lines hidden (view full) --- 3892 pt->ctp_status); 3893 return (-1); 3894 } 3895 3896 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct); 3897 FC_SCRATCH_RELEASE(isp); 3898 3899 if (ct->ct_cmd_resp == LS_RJT) { |
3897 isp_prt(isp, ISP_LOGWARN, "Register FC4 Type rejected"); | 3900 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3901 "Register FC4 Type rejected"); |
3898 return (-1); 3899 } else if (ct->ct_cmd_resp == LS_ACC) { | 3902 return (-1); 3903 } else if (ct->ct_cmd_resp == LS_ACC) { |
3900 isp_prt(isp, ISP_LOGDEBUG0, "Register FC4 Type accepted"); | 3904 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, 3905 "Register FC4 Type accepted"); |
3901 return(0); 3902 } else { 3903 isp_prt(isp, ISP_LOGWARN, | 3906 return(0); 3907 } else { 3908 isp_prt(isp, ISP_LOGWARN, |
3904 "Register FC4 Type: %x", ct->ct_cmd_resp); | 3909 "Register FC4 Type: 0x%x", ct->ct_cmd_resp); |
3905 return (-1); 3906 } 3907} 3908 3909static uint16_t 3910isp_nxt_handle(ispsoftc_t *isp, uint16_t handle) 3911{ 3912 if (handle == 0xffff) { --- 32 unchanged lines hidden (view full) --- 3945{ 3946 ispsoftc_t *isp; 3947 uint32_t nxti, optr, handle, isr; 3948 uint16_t sema, mbox; 3949 uint8_t local[QENTRY_LEN]; 3950 ispreq_t *reqp, *qep; 3951 void *cdbp; 3952 uint16_t *tptr; | 3910 return (-1); 3911 } 3912} 3913 3914static uint16_t 3915isp_nxt_handle(ispsoftc_t *isp, uint16_t handle) 3916{ 3917 if (handle == 0xffff) { --- 32 unchanged lines hidden (view full) --- 3950{ 3951 ispsoftc_t *isp; 3952 uint32_t nxti, optr, handle, isr; 3953 uint16_t sema, mbox; 3954 uint8_t local[QENTRY_LEN]; 3955 ispreq_t *reqp, *qep; 3956 void *cdbp; 3957 uint16_t *tptr; |
3953 int target, i; | 3958 int target, i, hdlidx = 0; |
3954 3955 XS_INITERR(xs); 3956 isp = XS_ISP(xs); 3957 3958 /* 3959 * Check to make sure we're supporting initiator role. 3960 */ 3961 if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) { --- 29 unchanged lines hidden (view full) --- 3991 /* 3992 * Translate the target to device handle as appropriate, checking 3993 * for correct device state as well. 3994 */ 3995 target = XS_TGT(xs); 3996 if (IS_FC(isp)) { 3997 fcparam *fcp = isp->isp_param; 3998 | 3959 3960 XS_INITERR(xs); 3961 isp = XS_ISP(xs); 3962 3963 /* 3964 * Check to make sure we're supporting initiator role. 3965 */ 3966 if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) { --- 29 unchanged lines hidden (view full) --- 3996 /* 3997 * Translate the target to device handle as appropriate, checking 3998 * for correct device state as well. 3999 */ 4000 target = XS_TGT(xs); 4001 if (IS_FC(isp)) { 4002 fcparam *fcp = isp->isp_param; 4003 |
4004 /* 4005 * Try again later. 4006 */ |
|
3999 if (fcp->isp_fwstate != FW_READY || 4000 fcp->isp_loopstate != LOOP_READY) { 4001 return (CMD_RQLATER); 4002 } 4003 4004 if (XS_TGT(xs) >= MAX_FC_TARG) { 4005 XS_SETERR(xs, HBA_SELTIMEOUT); 4006 return (CMD_COMPLETE); 4007 } 4008 | 4007 if (fcp->isp_fwstate != FW_READY || 4008 fcp->isp_loopstate != LOOP_READY) { 4009 return (CMD_RQLATER); 4010 } 4011 4012 if (XS_TGT(xs) >= MAX_FC_TARG) { 4013 XS_SETERR(xs, HBA_SELTIMEOUT); 4014 return (CMD_COMPLETE); 4015 } 4016 |
4009 i = fcp->isp_ini_map[XS_TGT(xs)]; | 4017 hdlidx = fcp->isp_ini_map[XS_TGT(xs)] - 1; |
4010 isp_prt(isp, ISP_LOGDEBUG1, "XS_TGT(xs)=%d- handle value %d", | 4018 isp_prt(isp, ISP_LOGDEBUG1, "XS_TGT(xs)=%d- handle value %d", |
4011 XS_TGT(xs), i); 4012 if (i < 1 || i >= MAX_FC_TARG) { | 4019 XS_TGT(xs), hdlidx); 4020 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) { |
4013 XS_SETERR(xs, HBA_SELTIMEOUT); 4014 return (CMD_COMPLETE); 4015 } | 4021 XS_SETERR(xs, HBA_SELTIMEOUT); 4022 return (CMD_COMPLETE); 4023 } |
4016 target = fcp->portdb[i - 1].handle; | 4024 if (fcp->portdb[hdlidx].state == FC_PORTDB_STATE_ZOMBIE) { 4025 return (CMD_RQLATER); 4026 } 4027 if (fcp->portdb[hdlidx].state != FC_PORTDB_STATE_VALID) { 4028 XS_SETERR(xs, HBA_SELTIMEOUT); 4029 return (CMD_COMPLETE); 4030 } 4031 target = fcp->portdb[hdlidx].handle; |
4017 } 4018 4019 /* 4020 * Next check to see if any HBA or Device parameters need to be updated. 4021 */ 4022 if (isp->isp_update != 0) { 4023 isp_update(isp); 4024 } --- 111 unchanged lines hidden (view full) --- 4136 4137 if (IS_SCSI(isp)) { 4138 reqp->req_target = target | (XS_CHANNEL(xs) << 7); 4139 reqp->req_lun_trn = XS_LUN(xs); 4140 reqp->req_cdblen = XS_CDBLEN(xs); 4141 } else if (IS_24XX(isp)) { 4142 fcportdb_t *lp; 4143 | 4032 } 4033 4034 /* 4035 * Next check to see if any HBA or Device parameters need to be updated. 4036 */ 4037 if (isp->isp_update != 0) { 4038 isp_update(isp); 4039 } --- 111 unchanged lines hidden (view full) --- 4151 4152 if (IS_SCSI(isp)) { 4153 reqp->req_target = target | (XS_CHANNEL(xs) << 7); 4154 reqp->req_lun_trn = XS_LUN(xs); 4155 reqp->req_cdblen = XS_CDBLEN(xs); 4156 } else if (IS_24XX(isp)) { 4157 fcportdb_t *lp; 4158 |
4144 i = FCPARAM(isp)->isp_ini_map[XS_TGT(xs)] - 1; 4145 lp = &FCPARAM(isp)->portdb[i]; 4146 | 4159 lp = &FCPARAM(isp)->portdb[hdlidx]; |
4147 ((ispreqt7_t *)reqp)->req_nphdl = target; 4148 ((ispreqt7_t *)reqp)->req_tidlo = lp->portid; 4149 ((ispreqt7_t *)reqp)->req_tidhi = lp->portid >> 16; 4150 if (XS_LUN(xs) > 256) { 4151 ((ispreqt7_t *)reqp)->req_lun[0] = XS_LUN(xs) >> 8; 4152 ((ispreqt7_t *)reqp)->req_lun[0] |= 0x40; 4153 } 4154 ((ispreqt7_t *)reqp)->req_lun[1] = XS_LUN(xs); --- 477 unchanged lines hidden (view full) --- 4632 } 4633 isp->isp_rspbsy = 1; 4634 while (optr != iptr) { 4635 uint8_t qe[QENTRY_LEN]; 4636 ispstatusreq_t *sp = (ispstatusreq_t *) qe; 4637 isphdr_t *hp; 4638 int buddaboom, etype, scsi_status, completion_status; 4639 int req_status_flags, req_state_flags; | 4160 ((ispreqt7_t *)reqp)->req_nphdl = target; 4161 ((ispreqt7_t *)reqp)->req_tidlo = lp->portid; 4162 ((ispreqt7_t *)reqp)->req_tidhi = lp->portid >> 16; 4163 if (XS_LUN(xs) > 256) { 4164 ((ispreqt7_t *)reqp)->req_lun[0] = XS_LUN(xs) >> 8; 4165 ((ispreqt7_t *)reqp)->req_lun[0] |= 0x40; 4166 } 4167 ((ispreqt7_t *)reqp)->req_lun[1] = XS_LUN(xs); --- 477 unchanged lines hidden (view full) --- 4645 } 4646 isp->isp_rspbsy = 1; 4647 while (optr != iptr) { 4648 uint8_t qe[QENTRY_LEN]; 4649 ispstatusreq_t *sp = (ispstatusreq_t *) qe; 4650 isphdr_t *hp; 4651 int buddaboom, etype, scsi_status, completion_status; 4652 int req_status_flags, req_state_flags; |
4653 uint8_t *snsp, *resp; 4654 uint32_t rlen, slen; |
|
4640 long resid; 4641 uint16_t oop; 4642 4643 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); 4644 oop = optr; 4645 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp)); 4646 nlooked++; 4647 read_again: --- 148 unchanged lines hidden (view full) --- 4796 if (req_status_flags & RQSTF_BUS_RESET) { 4797 XS_SETERR(xs, HBA_BUSRESET); 4798 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); 4799 } 4800 if (buddaboom) { 4801 XS_SETERR(xs, HBA_BOTCH); 4802 } 4803 | 4655 long resid; 4656 uint16_t oop; 4657 4658 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); 4659 oop = optr; 4660 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp)); 4661 nlooked++; 4662 read_again: --- 148 unchanged lines hidden (view full) --- 4811 if (req_status_flags & RQSTF_BUS_RESET) { 4812 XS_SETERR(xs, HBA_BUSRESET); 4813 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); 4814 } 4815 if (buddaboom) { 4816 XS_SETERR(xs, HBA_BOTCH); 4817 } 4818 |
4819 resp = NULL; 4820 rlen = 0; 4821 snsp = NULL; 4822 slen = 0; 4823 if (IS_24XX(isp) && (scsi_status & RQCS_RV) != 0) { 4824 resp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense; 4825 rlen = ((isp24xx_statusreq_t *)sp)->req_response_len; 4826 } else if (IS_FC(isp) && (scsi_status & RQCS_RV) != 0) { 4827 resp = sp->req_response; 4828 rlen = sp->req_response_len; 4829 } |
|
4804 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) { 4805 /* 4806 * Fibre Channel F/W doesn't say we got status 4807 * if there's Sense Data instead. I guess they 4808 * think it goes w/o saying. 4809 */ | 4830 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) { 4831 /* 4832 * Fibre Channel F/W doesn't say we got status 4833 * if there's Sense Data instead. I guess they 4834 * think it goes w/o saying. 4835 */ |
4810 req_state_flags |= RQSF_GOT_STATUS; | 4836 req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE; 4837 if (IS_24XX(isp)) { 4838 snsp = 4839 ((isp24xx_statusreq_t *)sp)->req_rsp_sense; 4840 snsp += rlen; 4841 slen = 4842 ((isp24xx_statusreq_t *)sp)->req_sense_len; 4843 } else { 4844 snsp = sp->req_sense_data; 4845 slen = sp->req_sense_len; 4846 } 4847 } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) { 4848 snsp = sp->req_sense_data; 4849 slen = sp->req_sense_len; |
4811 } 4812 if (req_state_flags & RQSF_GOT_STATUS) { 4813 *XS_STSP(xs) = scsi_status & 0xff; 4814 } 4815 4816 switch (etype) { 4817 case RQSTYPE_RESPONSE: | 4850 } 4851 if (req_state_flags & RQSF_GOT_STATUS) { 4852 *XS_STSP(xs) = scsi_status & 0xff; 4853 } 4854 4855 switch (etype) { 4856 case RQSTYPE_RESPONSE: |
4818 /* XXX won't work for 24xx */ | |
4819 XS_SET_STATE_STAT(isp, xs, sp); | 4857 XS_SET_STATE_STAT(isp, xs, sp); |
4858 if (resp) { 4859 isp_prt(isp, ISP_LOGWARN, 4860 "%d.%d FCP RESPONSE: 0x%x", 4861 XS_TGT(xs), XS_LUN(xs), 4862 resp[FCP_RSPNS_CODE_OFFSET]); 4863 XS_SETERR(xs, HBA_BOTCH); 4864 } |
|
4820 if (IS_24XX(isp)) { 4821 isp_parse_status_24xx(isp, 4822 (isp24xx_statusreq_t *)sp, xs, &resid); 4823 } else { 4824 isp_parse_status(isp, (void *)sp, xs, &resid); 4825 } 4826 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) && 4827 (*XS_STSP(xs) == SCSI_BUSY)) { 4828 XS_SETERR(xs, HBA_TGTBSY); 4829 } 4830 if (IS_SCSI(isp)) { 4831 XS_RESID(xs) = resid; | 4865 if (IS_24XX(isp)) { 4866 isp_parse_status_24xx(isp, 4867 (isp24xx_statusreq_t *)sp, xs, &resid); 4868 } else { 4869 isp_parse_status(isp, (void *)sp, xs, &resid); 4870 } 4871 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) && 4872 (*XS_STSP(xs) == SCSI_BUSY)) { 4873 XS_SETERR(xs, HBA_TGTBSY); 4874 } 4875 if (IS_SCSI(isp)) { 4876 XS_RESID(xs) = resid; |
4832 if ((req_state_flags & RQSF_GOT_STATUS) && 4833 (*XS_STSP(xs) == SCSI_CHECK) && 4834 (req_state_flags & RQSF_GOT_SENSE)) { 4835 XS_SAVE_SENSE(xs, sp); 4836 } | |
4837 /* 4838 * A new synchronous rate was negotiated for 4839 * this target. Mark state such that we'll go 4840 * look up that which has changed later. 4841 */ 4842 if (req_status_flags & RQSTF_NEGOTIATION) { 4843 int t = XS_TGT(xs); 4844 sdparam *sdp = isp->isp_param; --- 5 unchanged lines hidden (view full) --- 4850 } else { 4851 if (req_status_flags & RQSF_XFER_COMPLETE) { 4852 XS_RESID(xs) = 0; 4853 } else if (scsi_status & RQCS_RESID) { 4854 XS_RESID(xs) = resid; 4855 } else { 4856 XS_RESID(xs) = 0; 4857 } | 4877 /* 4878 * A new synchronous rate was negotiated for 4879 * this target. Mark state such that we'll go 4880 * look up that which has changed later. 4881 */ 4882 if (req_status_flags & RQSTF_NEGOTIATION) { 4883 int t = XS_TGT(xs); 4884 sdparam *sdp = isp->isp_param; --- 5 unchanged lines hidden (view full) --- 4890 } else { 4891 if (req_status_flags & RQSF_XFER_COMPLETE) { 4892 XS_RESID(xs) = 0; 4893 } else if (scsi_status & RQCS_RESID) { 4894 XS_RESID(xs) = resid; 4895 } else { 4896 XS_RESID(xs) = 0; 4897 } |
4858 if ((req_state_flags & RQSF_GOT_STATUS) && 4859 (*XS_STSP(xs) == SCSI_CHECK) && 4860 (scsi_status & RQCS_SV)) { 4861 XS_SAVE_SENSE(xs, sp); 4862 /* solely for the benefit of debug */ 4863 req_state_flags |= RQSF_GOT_SENSE; 4864 } | |
4865 } | 4898 } |
4899 if (snsp && slen) { 4900 XS_SAVE_SENSE(xs, snsp, slen); 4901 } |
|
4866 isp_prt(isp, ISP_LOGDEBUG2, 4867 "asked for %ld got raw resid %ld settled for %ld", 4868 (long) XS_XFRLEN(xs), resid, (long) XS_RESID(xs)); 4869 break; 4870 case RQSTYPE_REQUEST: 4871 case RQSTYPE_A64: 4872 case RQSTYPE_T2RQS: 4873 case RQSTYPE_T3RQS: --- 296 unchanged lines hidden (view full) --- 5170 break; 5171 } 5172 case ASYNC_LIP_ERROR: 5173 case ASYNC_LIP_F8: 5174 case ASYNC_LIP_OCCURRED: 5175 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5176 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; 5177 isp->isp_sendmarker = 1; | 4902 isp_prt(isp, ISP_LOGDEBUG2, 4903 "asked for %ld got raw resid %ld settled for %ld", 4904 (long) XS_XFRLEN(xs), resid, (long) XS_RESID(xs)); 4905 break; 4906 case RQSTYPE_REQUEST: 4907 case RQSTYPE_A64: 4908 case RQSTYPE_T2RQS: 4909 case RQSTYPE_T3RQS: --- 296 unchanged lines hidden (view full) --- 5206 break; 5207 } 5208 case ASYNC_LIP_ERROR: 5209 case ASYNC_LIP_F8: 5210 case ASYNC_LIP_OCCURRED: 5211 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5212 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; 5213 isp->isp_sendmarker = 1; |
5178 isp_mark_portdb(isp, 1); | 5214 ISP_MARK_PORTDB(isp, 1); |
5179 isp_async(isp, ISPASYNC_LIP, NULL); 5180#ifdef ISP_TARGET_MODE 5181 if (isp_target_async(isp, bus, mbox)) { 5182 rval = -1; 5183 } 5184#endif 5185 /* 5186 * We've had problems with data corruption occuring on --- 19 unchanged lines hidden (view full) --- 5206 } 5207 } 5208 break; 5209 5210 case ASYNC_LOOP_UP: 5211 isp->isp_sendmarker = 1; 5212 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5213 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; | 5215 isp_async(isp, ISPASYNC_LIP, NULL); 5216#ifdef ISP_TARGET_MODE 5217 if (isp_target_async(isp, bus, mbox)) { 5218 rval = -1; 5219 } 5220#endif 5221 /* 5222 * We've had problems with data corruption occuring on --- 19 unchanged lines hidden (view full) --- 5242 } 5243 } 5244 break; 5245 5246 case ASYNC_LOOP_UP: 5247 isp->isp_sendmarker = 1; 5248 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5249 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; |
5214 isp_mark_portdb(isp, 1); | 5250 ISP_MARK_PORTDB(isp, 1); |
5215 isp_async(isp, ISPASYNC_LOOP_UP, NULL); 5216#ifdef ISP_TARGET_MODE 5217 if (isp_target_async(isp, bus, mbox)) { 5218 rval = -1; 5219 } 5220#endif 5221 break; 5222 5223 case ASYNC_LOOP_DOWN: 5224 isp->isp_sendmarker = 1; 5225 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5226 FCPARAM(isp)->isp_loopstate = LOOP_NIL; | 5251 isp_async(isp, ISPASYNC_LOOP_UP, NULL); 5252#ifdef ISP_TARGET_MODE 5253 if (isp_target_async(isp, bus, mbox)) { 5254 rval = -1; 5255 } 5256#endif 5257 break; 5258 5259 case ASYNC_LOOP_DOWN: 5260 isp->isp_sendmarker = 1; 5261 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5262 FCPARAM(isp)->isp_loopstate = LOOP_NIL; |
5227 isp_mark_portdb(isp, 1); | 5263 ISP_MARK_PORTDB(isp, 1); |
5228 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); 5229#ifdef ISP_TARGET_MODE 5230 if (isp_target_async(isp, bus, mbox)) { 5231 rval = -1; 5232 } 5233#endif 5234 break; 5235 5236 case ASYNC_LOOP_RESET: 5237 isp->isp_sendmarker = 1; 5238 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5239 FCPARAM(isp)->isp_loopstate = LOOP_NIL; | 5264 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); 5265#ifdef ISP_TARGET_MODE 5266 if (isp_target_async(isp, bus, mbox)) { 5267 rval = -1; 5268 } 5269#endif 5270 break; 5271 5272 case ASYNC_LOOP_RESET: 5273 isp->isp_sendmarker = 1; 5274 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5275 FCPARAM(isp)->isp_loopstate = LOOP_NIL; |
5240 isp_mark_portdb(isp, 1); | 5276 ISP_MARK_PORTDB(isp, 1); |
5241 isp_async(isp, ISPASYNC_LOOP_RESET, NULL); 5242#ifdef ISP_TARGET_MODE 5243 if (isp_target_async(isp, bus, mbox)) { 5244 rval = -1; 5245 } 5246#endif 5247 break; 5248 5249 case ASYNC_PDB_CHANGED: 5250 isp->isp_sendmarker = 1; 5251 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; | 5277 isp_async(isp, ISPASYNC_LOOP_RESET, NULL); 5278#ifdef ISP_TARGET_MODE 5279 if (isp_target_async(isp, bus, mbox)) { 5280 rval = -1; 5281 } 5282#endif 5283 break; 5284 5285 case ASYNC_PDB_CHANGED: 5286 isp->isp_sendmarker = 1; 5287 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; |
5252 isp_mark_portdb(isp, 1); | 5288 ISP_MARK_PORTDB(isp, 1); |
5253 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_PDB); 5254 break; 5255 5256 case ASYNC_CHANGE_NOTIFY: 5257 if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) { 5258 FCPARAM(isp)->isp_loopstate = LOOP_LSCAN_DONE; 5259 } else { 5260 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; 5261 } | 5289 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_PDB); 5290 break; 5291 5292 case ASYNC_CHANGE_NOTIFY: 5293 if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) { 5294 FCPARAM(isp)->isp_loopstate = LOOP_LSCAN_DONE; 5295 } else { 5296 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; 5297 } |
5262 isp_mark_portdb(isp, 1); | 5298 ISP_MARK_PORTDB(isp, 1); |
5263 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_SNS); 5264 break; 5265 5266 case ASYNC_PTPMODE: | 5299 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_SNS); 5300 break; 5301 5302 case ASYNC_PTPMODE: |
5267 isp_mark_portdb(isp, 1); | 5303 ISP_MARK_PORTDB(isp, 1); |
5268 isp->isp_sendmarker = 1; 5269 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5270 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; 5271 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); 5272#ifdef ISP_TARGET_MODE 5273 if (isp_target_async(isp, bus, mbox)) { 5274 rval = -1; 5275 } 5276#endif 5277 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode"); 5278 break; 5279 5280 case ASYNC_CONNMODE: 5281 mbox = ISP_READ(isp, OUTMAILBOX1); | 5304 isp->isp_sendmarker = 1; 5305 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 5306 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; 5307 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); 5308#ifdef ISP_TARGET_MODE 5309 if (isp_target_async(isp, bus, mbox)) { 5310 rval = -1; 5311 } 5312#endif 5313 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode"); 5314 break; 5315 5316 case ASYNC_CONNMODE: 5317 mbox = ISP_READ(isp, OUTMAILBOX1); |
5282 isp_mark_portdb(isp, 1); | 5318 ISP_MARK_PORTDB(isp, 1); |
5283 switch (mbox) { 5284 case ISP_CONN_LOOP: 5285 isp_prt(isp, ISP_LOGINFO, 5286 "Point-to-Point -> Loop mode"); 5287 break; 5288 case ISP_CONN_PTP: 5289 isp_prt(isp, ISP_LOGINFO, 5290 "Loop -> Point-to-Point mode"); --- 475 unchanged lines hidden (view full) --- 5766 MEMZERO(&mbs, sizeof (mbs)); 5767 mbs.param[0] = MBOX_INIT_LIP; 5768 if (FCPARAM(isp)->isp_2klogin) { 5769 mbs.ibits = (1 << 10); 5770 } 5771 mbs.logval = MBLOGALL; 5772 isp_mboxcmd_qnw(isp, &mbs, 1); 5773 } | 5319 switch (mbox) { 5320 case ISP_CONN_LOOP: 5321 isp_prt(isp, ISP_LOGINFO, 5322 "Point-to-Point -> Loop mode"); 5323 break; 5324 case ISP_CONN_PTP: 5325 isp_prt(isp, ISP_LOGINFO, 5326 "Loop -> Point-to-Point mode"); --- 475 unchanged lines hidden (view full) --- 5802 MEMZERO(&mbs, sizeof (mbs)); 5803 mbs.param[0] = MBOX_INIT_LIP; 5804 if (FCPARAM(isp)->isp_2klogin) { 5805 mbs.ibits = (1 << 10); 5806 } 5807 mbs.logval = MBLOGALL; 5808 isp_mboxcmd_qnw(isp, &mbs, 1); 5809 } |
5774 5775 /* 5776 * Probably overkill. 5777 */ 5778 isp->isp_sendmarker = 1; 5779 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; 5780 isp_mark_portdb(isp, 1); 5781 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); | |
5782 if (XS_NOERR(xs)) { 5783 XS_SETERR(xs, HBA_SELTIMEOUT); 5784 } 5785 return; 5786 } 5787 case RQCS_PORT_CHANGED: 5788 isp_prt(isp, ISP_LOGWARN, 5789 "port changed for target %d", XS_TGT(xs)); --- 134 unchanged lines hidden (view full) --- 5924 MEMZERO(&mbs, sizeof (mbs)); 5925 mbs.param[0] = MBOX_INIT_LIP; 5926 if (FCPARAM(isp)->isp_2klogin) { 5927 mbs.ibits = (1 << 10); 5928 } 5929 mbs.logval = MBLOGALL; 5930 isp_mboxcmd_qnw(isp, &mbs, 1); 5931 } | 5810 if (XS_NOERR(xs)) { 5811 XS_SETERR(xs, HBA_SELTIMEOUT); 5812 } 5813 return; 5814 } 5815 case RQCS_PORT_CHANGED: 5816 isp_prt(isp, ISP_LOGWARN, 5817 "port changed for target %d", XS_TGT(xs)); --- 134 unchanged lines hidden (view full) --- 5952 MEMZERO(&mbs, sizeof (mbs)); 5953 mbs.param[0] = MBOX_INIT_LIP; 5954 if (FCPARAM(isp)->isp_2klogin) { 5955 mbs.ibits = (1 << 10); 5956 } 5957 mbs.logval = MBLOGALL; 5958 isp_mboxcmd_qnw(isp, &mbs, 1); 5959 } |
5932 5933 /* 5934 * Probably overkill. 5935 */ 5936 isp->isp_sendmarker = 1; 5937 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; 5938 isp_mark_portdb(isp, 1); 5939 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER); | |
5940 if (XS_NOERR(xs)) { 5941 XS_SETERR(xs, HBA_SELTIMEOUT); 5942 } 5943 return; 5944 } 5945 case RQCS_PORT_CHANGED: 5946 isp_prt(isp, ISP_LOGWARN, 5947 "port changed for target %d", XS_TGT(xs)); --- 1215 unchanged lines hidden (view full) --- 7163 7164void 7165isp_reinit(ispsoftc_t *isp) 7166{ 7167 XS_T *xs; 7168 uint32_t tmp; 7169 7170 if (IS_FC(isp)) { | 5960 if (XS_NOERR(xs)) { 5961 XS_SETERR(xs, HBA_SELTIMEOUT); 5962 } 5963 return; 5964 } 5965 case RQCS_PORT_CHANGED: 5966 isp_prt(isp, ISP_LOGWARN, 5967 "port changed for target %d", XS_TGT(xs)); --- 1215 unchanged lines hidden (view full) --- 7183 7184void 7185isp_reinit(ispsoftc_t *isp) 7186{ 7187 XS_T *xs; 7188 uint32_t tmp; 7189 7190 if (IS_FC(isp)) { |
7171 isp_mark_portdb(isp, 0); | 7191 ISP_MARK_PORTDB(isp, 0); |
7172 } 7173 isp_reset(isp); 7174 if (isp->isp_state != ISP_RESETSTATE) { 7175 isp_prt(isp, ISP_LOGERR, "isp_reinit cannot reset card"); 7176 } else if (isp->isp_role != ISP_ROLE_NONE) { 7177 isp_init(isp); 7178 if (isp->isp_state == ISP_INITSTATE) { 7179 isp->isp_state = ISP_RUNSTATE; --- 1055 unchanged lines hidden --- | 7192 } 7193 isp_reset(isp); 7194 if (isp->isp_state != ISP_RESETSTATE) { 7195 isp_prt(isp, ISP_LOGERR, "isp_reinit cannot reset card"); 7196 } else if (isp->isp_role != ISP_ROLE_NONE) { 7197 isp_init(isp); 7198 if (isp->isp_state == ISP_INITSTATE) { 7199 isp->isp_state = ISP_RUNSTATE; --- 1055 unchanged lines hidden --- |