isp.c (288712) | isp.c (288714) |
---|---|
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 * --- 33 unchanged lines hidden (view full) --- 42 */ 43#ifdef __NetBSD__ 44#include <sys/cdefs.h> 45__KERNEL_RCSID(0, "$NetBSD$"); 46#include <dev/ic/isp_netbsd.h> 47#endif 48#ifdef __FreeBSD__ 49#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 * --- 33 unchanged lines hidden (view full) --- 42 */ 43#ifdef __NetBSD__ 44#include <sys/cdefs.h> 45__KERNEL_RCSID(0, "$NetBSD$"); 46#include <dev/ic/isp_netbsd.h> 47#endif 48#ifdef __FreeBSD__ 49#include <sys/cdefs.h> |
50__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp.c 288712 2015-10-05 08:29:31Z mav $"); | 50__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp.c 288714 2015-10-05 08:31:48Z mav $"); |
51#include <dev/isp/isp_freebsd.h> 52#endif 53#ifdef __OpenBSD__ 54#include <dev/ic/isp_openbsd.h> 55#endif 56#ifdef __linux__ 57#include "isp_linux.h" 58#endif 59#ifdef __svr4__ 60#include "isp_solaris.h" 61#endif 62 63/* 64 * General defines 65 */ 66#define MBOX_DELAY_COUNT 1000000 / 100 67#define ISP_MARK_PORTDB(a, b, c) \ | 51#include <dev/isp/isp_freebsd.h> 52#endif 53#ifdef __OpenBSD__ 54#include <dev/ic/isp_openbsd.h> 55#endif 56#ifdef __linux__ 57#include "isp_linux.h" 58#endif 59#ifdef __svr4__ 60#include "isp_solaris.h" 61#endif 62 63/* 64 * General defines 65 */ 66#define MBOX_DELAY_COUNT 1000000 / 100 67#define ISP_MARK_PORTDB(a, b, c) \ |
68 isp_prt(isp, ISP_LOG_SANCFG, \ 69 "Chan %d ISP_MARK_PORTDB@LINE %d", b, __LINE__); \ 70 isp_mark_portdb(a, b, c) | 68 do { \ 69 isp_prt(isp, ISP_LOG_SANCFG, \ 70 "Chan %d ISP_MARK_PORTDB@LINE %d", (b), __LINE__); \ 71 isp_mark_portdb((a), (b), (c)); \ 72 } while (0) |
71 72/* 73 * Local static data 74 */ 75static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)"; 76static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d"; | 73 74/* 75 * Local static data 76 */ 77static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)"; 78static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d"; |
77static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x N-Port Handle %d, Connection '%s'"; | 79static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x handle 0x%x, Connection '%s'"; |
78static const char bun[] = "bad underrun (count %d, resid %d, status %s)"; 79static const char lipd[] = "Chan %d LIP destroyed %d active commands"; 80static const char sacq[] = "unable to acquire scratch area"; 81 82static const uint8_t alpa_map[] = { 83 0xef, 0xe8, 0xe4, 0xe2, 0xe1, 0xe0, 0xdc, 0xda, 84 0xd9, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xce, 85 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5, --- 2132 unchanged lines hidden (view full) --- 2218 2219 /* 2220 * Whatever happens, we're now committed to being here. 2221 */ 2222 isp->isp_state = ISP_INITSTATE; 2223} 2224 2225static void | 80static const char bun[] = "bad underrun (count %d, resid %d, status %s)"; 81static const char lipd[] = "Chan %d LIP destroyed %d active commands"; 82static const char sacq[] = "unable to acquire scratch area"; 83 84static const uint8_t alpa_map[] = { 85 0xef, 0xe8, 0xe4, 0xe2, 0xe1, 0xe0, 0xdc, 0xda, 86 0xd9, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xce, 87 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5, --- 2132 unchanged lines hidden (view full) --- 2220 2221 /* 2222 * Whatever happens, we're now committed to being here. 2223 */ 2224 isp->isp_state = ISP_INITSTATE; 2225} 2226 2227static void |
2226isp_del_all_init_entries(ispsoftc_t *isp, int chan) | 2228isp_mark_portdb(ispsoftc_t *isp, int chan, int disposition) |
2227{ 2228 fcparam *fcp = FCPARAM(isp, chan); 2229 fcportdb_t *lp; 2230 int i; 2231 | 2229{ 2230 fcparam *fcp = FCPARAM(isp, chan); 2231 fcportdb_t *lp; 2232 int i; 2233 |
2232 for (i = 0; i < MAX_FC_TARG; i++) { 2233 lp = &fcp->portdb[i]; 2234 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) 2235 continue; 2236 lp->state = FC_PORTDB_STATE_NIL; 2237 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp, 1); 2238 if (lp->autologin == 0) { 2239 (void) isp_plogx(isp, chan, lp->handle, 2240 lp->portid, 2241 PLOGX_FLG_CMD_LOGO | 2242 PLOGX_FLG_IMPLICIT | 2243 PLOGX_FLG_FREE_NPHDL, 0); 2244 } else { 2245 lp->autologin = 0; 2246 } 2247 lp->new_prli_word3 = 0; 2248 lp->new_portid = 0; 2249 } 2250} 2251 2252static void 2253isp_mark_portdb(ispsoftc_t *isp, int chan, int disposition) 2254{ 2255 fcparam *fcp = FCPARAM(isp, chan); 2256 int i; 2257 | |
2258 if (chan < 0 || chan >= isp->isp_nchan) { 2259 isp_prt(isp, ISP_LOGWARN, "isp_mark_portdb: bad channel %d", chan); 2260 return; 2261 } 2262 for (i = 0; i < MAX_FC_TARG; i++) { | 2234 if (chan < 0 || chan >= isp->isp_nchan) { 2235 isp_prt(isp, ISP_LOGWARN, "isp_mark_portdb: bad channel %d", chan); 2236 return; 2237 } 2238 for (i = 0; i < MAX_FC_TARG; i++) { |
2263 if (fcp->portdb[i].target_mode) { 2264 if (disposition < 0) { 2265 isp_prt(isp, ISP_LOGTINFO, "isp_mark_portdb: Chan %d zeroing handle 0x" "%04x port 0x%06x", chan, 2266 fcp->portdb[i].handle, fcp->portdb[i].portid); 2267 ISP_MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); | 2239 lp = &fcp->portdb[i]; 2240 switch (lp->state) { 2241 case FC_PORTDB_STATE_PROBATIONAL: 2242 case FC_PORTDB_STATE_DEAD: 2243 case FC_PORTDB_STATE_CHANGED: 2244 case FC_PORTDB_STATE_PENDING_VALID: 2245 case FC_PORTDB_STATE_VALID: 2246 if (disposition > 0) 2247 lp->state = FC_PORTDB_STATE_PROBATIONAL; 2248 else { 2249 lp->state = FC_PORTDB_STATE_NIL; 2250 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp); |
2268 } | 2251 } |
2269 continue; | 2252 break; 2253 case FC_PORTDB_STATE_ZOMBIE: 2254 break; 2255 case FC_PORTDB_STATE_NIL: 2256 case FC_PORTDB_STATE_NEW: 2257 default: 2258 ISP_MEMZERO(lp, sizeof(*lp)); 2259 lp->state = FC_PORTDB_STATE_NIL; 2260 break; |
2270 } | 2261 } |
2271 if (disposition == 0) { 2272 ISP_MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); 2273 } else { 2274 switch (fcp->portdb[i].state) { 2275 case FC_PORTDB_STATE_CHANGED: 2276 case FC_PORTDB_STATE_PENDING_VALID: 2277 case FC_PORTDB_STATE_VALID: 2278 case FC_PORTDB_STATE_PROBATIONAL: 2279 fcp->portdb[i].state = FC_PORTDB_STATE_PROBATIONAL; 2280 break; 2281 case FC_PORTDB_STATE_ZOMBIE: 2282 break; 2283 case FC_PORTDB_STATE_NIL: 2284 default: 2285 ISP_MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t)); 2286 fcp->portdb[i].state = FC_PORTDB_STATE_NIL; 2287 break; 2288 } 2289 } | |
2290 } 2291} 2292 2293/* 2294 * Perform an IOCB PLOGI or LOGO via EXECUTE IOCB A64 for 24XX cards 2295 * or via FABRIC LOGIN/FABRIC LOGOUT for other cards. 2296 */ 2297static int --- 170 unchanged lines hidden (view full) --- 2468 isp_mboxcmd(isp, &mbs); 2469 2470 switch (mbs.param[0]) { 2471 case MBOX_PORT_ID_USED: 2472 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: portid 0x%06x already logged in as %u", portid, mbs.param[1]); 2473 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); 2474 2475 case MBOX_LOOP_ID_USED: | 2262 } 2263} 2264 2265/* 2266 * Perform an IOCB PLOGI or LOGO via EXECUTE IOCB A64 for 24XX cards 2267 * or via FABRIC LOGIN/FABRIC LOGOUT for other cards. 2268 */ 2269static int --- 170 unchanged lines hidden (view full) --- 2440 isp_mboxcmd(isp, &mbs); 2441 2442 switch (mbs.param[0]) { 2443 case MBOX_PORT_ID_USED: 2444 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: portid 0x%06x already logged in as %u", portid, mbs.param[1]); 2445 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); 2446 2447 case MBOX_LOOP_ID_USED: |
2476 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: handle 0x%04x in use for port id 0x%02xXXXX", handle, mbs.param[1] & 0xff); | 2448 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: handle 0x%x in use for port id 0x%02xXXXX", handle, mbs.param[1] & 0xff); |
2477 return (MBOX_LOOP_ID_USED); 2478 2479 case MBOX_COMMAND_COMPLETE: 2480 return (0); 2481 2482 case MBOX_COMMAND_ERROR: 2483 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: error 0x%x in PLOGI to port 0x%06x", mbs.param[1], portid); 2484 return (MBOX_COMMAND_ERROR); --- 69 unchanged lines hidden (view full) --- 2554 } 2555 if (IS_24XX(isp)) { 2556 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill); 2557 pdb->handle = un.bill.pdb_handle; 2558 pdb->prli_word3 = un.bill.pdb_prli_svc3; 2559 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits); 2560 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8); 2561 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8); | 2449 return (MBOX_LOOP_ID_USED); 2450 2451 case MBOX_COMMAND_COMPLETE: 2452 return (0); 2453 2454 case MBOX_COMMAND_ERROR: 2455 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: error 0x%x in PLOGI to port 0x%06x", mbs.param[1], portid); 2456 return (MBOX_COMMAND_ERROR); --- 69 unchanged lines hidden (view full) --- 2526 } 2527 if (IS_24XX(isp)) { 2528 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill); 2529 pdb->handle = un.bill.pdb_handle; 2530 pdb->prli_word3 = un.bill.pdb_prli_svc3; 2531 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits); 2532 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8); 2533 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8); |
2562 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Port 0x%06x flags 0x%x curstate %x", chan, pdb->portid, un.bill.pdb_flags, un.bill.pdb_curstate); | 2534 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x", chan, id, pdb->portid, un.bill.pdb_flags, un.bill.pdb_curstate); |
2563 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) { 2564 mbs.param[0] = MBOX_NOT_LOGGED_IN; 2565 if (dolock) { 2566 FC_SCRATCH_RELEASE(isp, chan); 2567 } 2568 return (mbs.param[0]); 2569 } 2570 } else { --- 11 unchanged lines hidden (view full) --- 2582} 2583 2584static void 2585isp_dump_chip_portdb(ispsoftc_t *isp, int chan, int dolock) 2586{ 2587 isp_pdb_t pdb; 2588 int lim, loopid; 2589 | 2535 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) { 2536 mbs.param[0] = MBOX_NOT_LOGGED_IN; 2537 if (dolock) { 2538 FC_SCRATCH_RELEASE(isp, chan); 2539 } 2540 return (mbs.param[0]); 2541 } 2542 } else { --- 11 unchanged lines hidden (view full) --- 2554} 2555 2556static void 2557isp_dump_chip_portdb(ispsoftc_t *isp, int chan, int dolock) 2558{ 2559 isp_pdb_t pdb; 2560 int lim, loopid; 2561 |
2562 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGINFO, "Chan %d chip port dump", chan); |
|
2590 if (ISP_CAP_2KLOGIN(isp)) { 2591 lim = NPH_MAX_2K; 2592 } else { 2593 lim = NPH_MAX; 2594 } 2595 for (loopid = 0; loopid != lim; loopid++) { 2596 if (isp_getpdb(isp, chan, loopid, &pdb, dolock)) { 2597 continue; --- 385 unchanged lines hidden (view full) --- 2983 2984 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Synchronizing PDBs", chan); 2985 2986 fcp->isp_loopstate = LOOP_SYNCING_PDB; 2987 2988 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 2989 lp = &fcp->portdb[dbidx]; 2990 | 2563 if (ISP_CAP_2KLOGIN(isp)) { 2564 lim = NPH_MAX_2K; 2565 } else { 2566 lim = NPH_MAX; 2567 } 2568 for (loopid = 0; loopid != lim; loopid++) { 2569 if (isp_getpdb(isp, chan, loopid, &pdb, dolock)) { 2570 continue; --- 385 unchanged lines hidden (view full) --- 2956 2957 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Synchronizing PDBs", chan); 2958 2959 fcp->isp_loopstate = LOOP_SYNCING_PDB; 2960 2961 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 2962 lp = &fcp->portdb[dbidx]; 2963 |
2991 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) { | 2964 if (lp->state == FC_PORTDB_STATE_NIL || 2965 lp->state == FC_PORTDB_STATE_VALID) { |
2992 continue; 2993 } 2994 | 2966 continue; 2967 } 2968 |
2995 if (lp->state == FC_PORTDB_STATE_VALID) { 2996 if (dbidx != FL_ID) { 2997 isp_prt(isp, 2998 ISP_LOGERR, "portdb idx %d already valid", 2999 dbidx); 3000 } 3001 continue; 3002 } 3003 | |
3004 switch (lp->state) { 3005 case FC_PORTDB_STATE_PROBATIONAL: 3006 case FC_PORTDB_STATE_DEAD: 3007 lp->state = FC_PORTDB_STATE_NIL; | 2969 switch (lp->state) { 2970 case FC_PORTDB_STATE_PROBATIONAL: 2971 case FC_PORTDB_STATE_DEAD: 2972 lp->state = FC_PORTDB_STATE_NIL; |
3008 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp, 0); | 2973 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp); |
3009 if (lp->autologin == 0) { 3010 (void) isp_plogx(isp, chan, lp->handle, 3011 lp->portid, 3012 PLOGX_FLG_CMD_LOGO | 3013 PLOGX_FLG_IMPLICIT | 3014 PLOGX_FLG_FREE_NPHDL, 0); 3015 } else { 3016 lp->autologin = 0; --- 7 unchanged lines hidden (view full) --- 3024 break; 3025 case FC_PORTDB_STATE_NEW: 3026 lp->portid = lp->new_portid; 3027 lp->prli_word3 = lp->new_prli_word3; 3028 lp->state = FC_PORTDB_STATE_VALID; 3029 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp); 3030 lp->new_prli_word3 = 0; 3031 lp->new_portid = 0; | 2974 if (lp->autologin == 0) { 2975 (void) isp_plogx(isp, chan, lp->handle, 2976 lp->portid, 2977 PLOGX_FLG_CMD_LOGO | 2978 PLOGX_FLG_IMPLICIT | 2979 PLOGX_FLG_FREE_NPHDL, 0); 2980 } else { 2981 lp->autologin = 0; --- 7 unchanged lines hidden (view full) --- 2989 break; 2990 case FC_PORTDB_STATE_NEW: 2991 lp->portid = lp->new_portid; 2992 lp->prli_word3 = lp->new_prli_word3; 2993 lp->state = FC_PORTDB_STATE_VALID; 2994 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp); 2995 lp->new_prli_word3 = 0; 2996 lp->new_portid = 0; |
3032 lp->announced = 0; | |
3033 break; 3034 case FC_PORTDB_STATE_CHANGED: | 2997 break; 2998 case FC_PORTDB_STATE_CHANGED: |
3035/* 3036 * XXXX FIX THIS 3037 */ | |
3038 lp->state = FC_PORTDB_STATE_VALID; 3039 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp); | 2999 lp->state = FC_PORTDB_STATE_VALID; 3000 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp); |
3001 lp->portid = lp->new_portid; 3002 lp->prli_word3 = lp->new_prli_word3; |
|
3040 lp->new_prli_word3 = 0; 3041 lp->new_portid = 0; | 3003 lp->new_prli_word3 = 0; 3004 lp->new_portid = 0; |
3042 lp->announced = 0; | |
3043 break; 3044 case FC_PORTDB_STATE_PENDING_VALID: 3045 lp->portid = lp->new_portid; 3046 lp->prli_word3 = lp->new_prli_word3; 3047 lp->state = FC_PORTDB_STATE_VALID; 3048 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp); 3049 if (dbidx != FL_ID) { 3050 lp->new_prli_word3 = 0; 3051 lp->new_portid = 0; 3052 } | 3005 break; 3006 case FC_PORTDB_STATE_PENDING_VALID: 3007 lp->portid = lp->new_portid; 3008 lp->prli_word3 = lp->new_prli_word3; 3009 lp->state = FC_PORTDB_STATE_VALID; 3010 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp); 3011 if (dbidx != FL_ID) { 3012 lp->new_prli_word3 = 0; 3013 lp->new_portid = 0; 3014 } |
3053 lp->announced = 0; | |
3054 break; 3055 case FC_PORTDB_STATE_ZOMBIE: 3056 break; 3057 default: 3058 isp_prt(isp, ISP_LOGWARN, | 3015 break; 3016 case FC_PORTDB_STATE_ZOMBIE: 3017 break; 3018 default: 3019 isp_prt(isp, ISP_LOGWARN, |
3059 "isp_scan_loop: state %d for idx %d", | 3020 "isp_pdb_sync: state %d for idx %d", |
3060 lp->state, dbidx); 3061 isp_dump_portdb(isp, chan); 3062 } 3063 } 3064 3065 /* 3066 * If we get here, we've for sure seen not only a valid loop 3067 * but know what is or isn't on it, so mark this for usage --- 54 unchanged lines hidden (view full) --- 3122 fcp->isp_loopstate = LOOP_LSCAN_DONE; 3123 return (0); 3124 } 3125 3126 fcp->isp_loopstate = LOOP_SCANNING_LOOP; 3127 3128 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop 0..%d", chan, lim-1); 3129 | 3021 lp->state, dbidx); 3022 isp_dump_portdb(isp, chan); 3023 } 3024 } 3025 3026 /* 3027 * If we get here, we've for sure seen not only a valid loop 3028 * but know what is or isn't on it, so mark this for usage --- 54 unchanged lines hidden (view full) --- 3083 fcp->isp_loopstate = LOOP_LSCAN_DONE; 3084 return (0); 3085 } 3086 3087 fcp->isp_loopstate = LOOP_SCANNING_LOOP; 3088 3089 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop 0..%d", chan, lim-1); 3090 |
3130 | |
3131 /* 3132 * Run through the list and get the port database info for each one. 3133 */ 3134 for (handle = 0; handle < lim; handle++) { 3135 int r; 3136 /* 3137 * Don't scan "special" ids. 3138 */ --- 67 unchanged lines hidden (view full) --- 3206 3207 /* 3208 * Check to make sure it's still a valid entry. The 24XX seems 3209 * to return a portid but not a WWPN/WWNN or role for devices 3210 * which shift on a loop. 3211 */ 3212 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { 3213 int a, b, c; | 3091 /* 3092 * Run through the list and get the port database info for each one. 3093 */ 3094 for (handle = 0; handle < lim; handle++) { 3095 int r; 3096 /* 3097 * Don't scan "special" ids. 3098 */ --- 67 unchanged lines hidden (view full) --- 3166 3167 /* 3168 * Check to make sure it's still a valid entry. The 24XX seems 3169 * to return a portid but not a WWPN/WWNN or role for devices 3170 * which shift on a loop. 3171 */ 3172 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { 3173 int a, b, c; |
3174 isp_prt(isp, ISP_LOGWARN, 3175 "Chan %d bad pdb (WWNN %016jx, WWPN %016jx, PortID %06x, W3 0x%x, H 0x%x) @ handle 0x%x", 3176 chan, tmp.node_wwn, tmp.port_wwn, tmp.portid, tmp.prli_word3, tmp.handle, handle); |
|
3214 a = (tmp.node_wwn == 0); 3215 b = (tmp.port_wwn == 0); 3216 c = (tmp.portid == 0); 3217 if (a == 0 && b == 0) { 3218 tmp.node_wwn = 3219 isp_get_wwn(isp, chan, handle, 1); 3220 tmp.port_wwn = 3221 isp_get_wwn(isp, chan, handle, 0); 3222 if (tmp.node_wwn && tmp.port_wwn) { | 3177 a = (tmp.node_wwn == 0); 3178 b = (tmp.port_wwn == 0); 3179 c = (tmp.portid == 0); 3180 if (a == 0 && b == 0) { 3181 tmp.node_wwn = 3182 isp_get_wwn(isp, chan, handle, 1); 3183 tmp.port_wwn = 3184 isp_get_wwn(isp, chan, handle, 0); 3185 if (tmp.node_wwn && tmp.port_wwn) { |
3223 isp_prt(isp, ISP_LOGINFO, "DODGED!"); | 3186 isp_prt(isp, ISP_LOGWARN, "DODGED!"); |
3224 goto cont; 3225 } 3226 } | 3187 goto cont; 3188 } 3189 } |
3227 isp_prt(isp, ISP_LOGWARN, 3228 "Chan %d bad pdb (%1d%1d%1d) @ handle 0x%x", chan, 3229 a, b, c, handle); | |
3230 isp_dump_portdb(isp, chan); 3231 continue; 3232 } 3233 cont: 3234 3235 /* 3236 * Now search the entire port database | 3190 isp_dump_portdb(isp, chan); 3191 continue; 3192 } 3193 cont: 3194 3195 /* 3196 * Now search the entire port database |
3237 * for the same Port and Node WWN. | 3197 * for the same Port WWN. |
3238 */ | 3198 */ |
3239 for (i = 0; i < MAX_FC_TARG; i++) { 3240 lp = &fcp->portdb[i]; 3241 3242 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) { 3243 continue; 3244 } 3245 if (lp->node_wwn != tmp.node_wwn) { 3246 continue; 3247 } 3248 if (lp->port_wwn != tmp.port_wwn) { 3249 continue; 3250 } 3251 | 3199 if (isp_find_pdb_by_wwn(isp, chan, tmp.port_wwn, &lp)) { |
3252 /* 3253 * Okay- we've found a non-nil entry that matches. 3254 * Check to make sure it's probational or a zombie. 3255 */ 3256 if (lp->state != FC_PORTDB_STATE_PROBATIONAL && | 3200 /* 3201 * Okay- we've found a non-nil entry that matches. 3202 * Check to make sure it's probational or a zombie. 3203 */ 3204 if (lp->state != FC_PORTDB_STATE_PROBATIONAL && |
3257 lp->state != FC_PORTDB_STATE_ZOMBIE) { | 3205 lp->state != FC_PORTDB_STATE_ZOMBIE && 3206 lp->state != FC_PORTDB_STATE_VALID) { |
3258 isp_prt(isp, ISP_LOGERR, 3259 "Chan %d [%d] not probational/zombie (0x%x)", | 3207 isp_prt(isp, ISP_LOGERR, 3208 "Chan %d [%d] not probational/zombie (0x%x)", |
3260 chan, i, lp->state); | 3209 chan, FC_PORTDB_TGT(isp, chan, lp), lp->state); |
3261 isp_dump_portdb(isp, chan); 3262 ISP_MARK_PORTDB(isp, chan, 1); 3263 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan); 3264 return (-1); 3265 } 3266 3267 /* 3268 * Mark the device as something the f/w logs into 3269 * automatically. 3270 */ 3271 lp->autologin = 1; | 3210 isp_dump_portdb(isp, chan); 3211 ISP_MARK_PORTDB(isp, chan, 1); 3212 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan); 3213 return (-1); 3214 } 3215 3216 /* 3217 * Mark the device as something the f/w logs into 3218 * automatically. 3219 */ 3220 lp->autologin = 1; |
3221 lp->node_wwn = tmp.node_wwn; |
|
3272 3273 /* 3274 * Check to make see if really still the same 3275 * device. If it is, we mark it pending valid. 3276 */ 3277 if (lp->portid == tmp.portid && lp->handle == tmp.handle && lp->prli_word3 == tmp.prli_word3) { 3278 lp->new_portid = tmp.portid; 3279 lp->new_prli_word3 = tmp.prli_word3; 3280 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3281 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x Pending Valid", chan, tmp.portid, tmp.handle); | 3222 3223 /* 3224 * Check to make see if really still the same 3225 * device. If it is, we mark it pending valid. 3226 */ 3227 if (lp->portid == tmp.portid && lp->handle == tmp.handle && lp->prli_word3 == tmp.prli_word3) { 3228 lp->new_portid = tmp.portid; 3229 lp->new_prli_word3 = tmp.prli_word3; 3230 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3231 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x Pending Valid", chan, tmp.portid, tmp.handle); |
3282 break; | 3232 continue; |
3283 } 3284 3285 /* 3286 * We can wipe out the old handle value 3287 * here because it's no longer valid. 3288 */ 3289 lp->handle = tmp.handle; 3290 3291 /* 3292 * Claim that this has changed and let somebody else 3293 * decide what to do. 3294 */ 3295 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x changed", chan, tmp.portid, tmp.handle); 3296 lp->state = FC_PORTDB_STATE_CHANGED; 3297 lp->new_portid = tmp.portid; 3298 lp->new_prli_word3 = tmp.prli_word3; | 3233 } 3234 3235 /* 3236 * We can wipe out the old handle value 3237 * here because it's no longer valid. 3238 */ 3239 lp->handle = tmp.handle; 3240 3241 /* 3242 * Claim that this has changed and let somebody else 3243 * decide what to do. 3244 */ 3245 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x changed", chan, tmp.portid, tmp.handle); 3246 lp->state = FC_PORTDB_STATE_CHANGED; 3247 lp->new_portid = tmp.portid; 3248 lp->new_prli_word3 = tmp.prli_word3; |
3299 break; 3300 } 3301 3302 /* 3303 * Did we find and update an old entry? 3304 */ 3305 if (i < MAX_FC_TARG) { | |
3306 continue; 3307 } 3308 3309 /* 3310 * Ah. A new device entry. Find an empty slot 3311 * for it and save info for later disposition. 3312 */ 3313 for (i = 0; i < MAX_FC_TARG; i++) { | 3249 continue; 3250 } 3251 3252 /* 3253 * Ah. A new device entry. Find an empty slot 3254 * for it and save info for later disposition. 3255 */ 3256 for (i = 0; i < MAX_FC_TARG; i++) { |
3314 if (fcp->portdb[i].target_mode) { 3315 continue; 3316 } | |
3317 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) { 3318 break; 3319 } 3320 } 3321 if (i == MAX_FC_TARG) { 3322 isp_prt(isp, ISP_LOGERR, 3323 "Chan %d out of portdb entries", chan); 3324 continue; --- 409 unchanged lines hidden (view full) --- 3734 * We now search our Port Database for any 3735 * probational entries with this PortID. We don't 3736 * look for zombies here- only probational 3737 * entries (we've already logged out of zombies). 3738 */ 3739 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3740 lp = &fcp->portdb[dbidx]; 3741 | 3257 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) { 3258 break; 3259 } 3260 } 3261 if (i == MAX_FC_TARG) { 3262 isp_prt(isp, ISP_LOGERR, 3263 "Chan %d out of portdb entries", chan); 3264 continue; --- 409 unchanged lines hidden (view full) --- 3674 * We now search our Port Database for any 3675 * probational entries with this PortID. We don't 3676 * look for zombies here- only probational 3677 * entries (we've already logged out of zombies). 3678 */ 3679 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3680 lp = &fcp->portdb[dbidx]; 3681 |
3742 if (lp->state != FC_PORTDB_STATE_PROBATIONAL || lp->target_mode) { | 3682 if (lp->state != FC_PORTDB_STATE_PROBATIONAL) { |
3743 continue; 3744 } 3745 if (lp->portid == portid) { 3746 break; 3747 } 3748 } 3749 3750 /* --- 25 unchanged lines hidden (view full) --- 3776 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { 3777 FC_SCRATCH_RELEASE(isp, chan); 3778 ISP_MARK_PORTDB(isp, chan, 1); 3779 return (-1); 3780 } 3781 if (r != 0) { 3782 lp->new_portid = portid; 3783 lp->state = FC_PORTDB_STATE_DEAD; | 3683 continue; 3684 } 3685 if (lp->portid == portid) { 3686 break; 3687 } 3688 } 3689 3690 /* --- 25 unchanged lines hidden (view full) --- 3716 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) { 3717 FC_SCRATCH_RELEASE(isp, chan); 3718 ISP_MARK_PORTDB(isp, chan, 1); 3719 return (-1); 3720 } 3721 if (r != 0) { 3722 lp->new_portid = portid; 3723 lp->state = FC_PORTDB_STATE_DEAD; |
3784 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x is dead", chan, portid); | 3724 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric PortID 0x%06x handle 0x%x is dead (%d)", chan, portid, lp->handle, r); |
3785 continue; 3786 } 3787 3788 3789 /* 3790 * Check to make sure that handle, portid, WWPN and 3791 * WWNN agree. If they don't, then the association 3792 * between this PortID and the stated handle has been 3793 * broken by the firmware. 3794 */ 3795 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3796 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3797 if (pdb.handle != lp->handle || 3798 pdb.portid != portid || 3799 wwpn != lp->port_wwn || | 3725 continue; 3726 } 3727 3728 3729 /* 3730 * Check to make sure that handle, portid, WWPN and 3731 * WWNN agree. If they don't, then the association 3732 * between this PortID and the stated handle has been 3733 * broken by the firmware. 3734 */ 3735 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3736 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3737 if (pdb.handle != lp->handle || 3738 pdb.portid != portid || 3739 wwpn != lp->port_wwn || |
3800 wwnn != lp->node_wwn) { | 3740 (lp->node_wwn != 0 && wwnn != lp->node_wwn)) { |
3801 isp_prt(isp, ISP_LOG_SANCFG, 3802 fconf, chan, dbidx, pdb.handle, pdb.portid, 3803 (uint32_t) (wwnn >> 32), (uint32_t) wwnn, 3804 (uint32_t) (wwpn >> 32), (uint32_t) wwpn, 3805 lp->handle, portid, 3806 (uint32_t) (lp->node_wwn >> 32), 3807 (uint32_t) lp->node_wwn, 3808 (uint32_t) (lp->port_wwn >> 32), 3809 (uint32_t) lp->port_wwn); 3810 /* 3811 * Try to re-login to this device using a 3812 * new handle. If that fails, mark it dead. 3813 * 3814 * isp_login_device will check for handle and 3815 * portid consistency after re-login. 3816 * 3817 */ | 3741 isp_prt(isp, ISP_LOG_SANCFG, 3742 fconf, chan, dbidx, pdb.handle, pdb.portid, 3743 (uint32_t) (wwnn >> 32), (uint32_t) wwnn, 3744 (uint32_t) (wwpn >> 32), (uint32_t) wwpn, 3745 lp->handle, portid, 3746 (uint32_t) (lp->node_wwn >> 32), 3747 (uint32_t) lp->node_wwn, 3748 (uint32_t) (lp->port_wwn >> 32), 3749 (uint32_t) lp->port_wwn); 3750 /* 3751 * Try to re-login to this device using a 3752 * new handle. If that fails, mark it dead. 3753 * 3754 * isp_login_device will check for handle and 3755 * portid consistency after re-login. 3756 * 3757 */ |
3818 if (isp_login_device(isp, chan, portid, &pdb, 3819 &oldhandle)) { | 3758 if ((fcp->role & ISP_ROLE_INITIATOR) == 0 || 3759 isp_login_device(isp, chan, portid, &pdb, 3760 &oldhandle)) { |
3820 lp->new_portid = portid; 3821 lp->state = FC_PORTDB_STATE_DEAD; 3822 if (fcp->isp_loopstate != 3823 LOOP_SCANNING_FABRIC) { 3824 FC_SCRATCH_RELEASE(isp, chan); 3825 ISP_MARK_PORTDB(isp, chan, 1); 3826 return (-1); 3827 } --- 4 unchanged lines hidden (view full) --- 3832 FC_SCRATCH_RELEASE(isp, chan); 3833 ISP_MARK_PORTDB(isp, chan, 1); 3834 return (-1); 3835 } 3836 FCPARAM(isp, 0)->isp_lasthdl = oldhandle; 3837 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3838 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3839 if (wwpn != lp->port_wwn || | 3761 lp->new_portid = portid; 3762 lp->state = FC_PORTDB_STATE_DEAD; 3763 if (fcp->isp_loopstate != 3764 LOOP_SCANNING_FABRIC) { 3765 FC_SCRATCH_RELEASE(isp, chan); 3766 ISP_MARK_PORTDB(isp, chan, 1); 3767 return (-1); 3768 } --- 4 unchanged lines hidden (view full) --- 3773 FC_SCRATCH_RELEASE(isp, chan); 3774 ISP_MARK_PORTDB(isp, chan, 1); 3775 return (-1); 3776 } 3777 FCPARAM(isp, 0)->isp_lasthdl = oldhandle; 3778 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename); 3779 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname); 3780 if (wwpn != lp->port_wwn || |
3840 wwnn != lp->node_wwn) { | 3781 (lp->node_wwn != 0 && wwnn != lp->node_wwn)) { |
3841 isp_prt(isp, ISP_LOGWARN, "changed WWN" 3842 " after relogin"); 3843 lp->new_portid = portid; 3844 lp->state = FC_PORTDB_STATE_DEAD; 3845 continue; 3846 } 3847 3848 lp->handle = pdb.handle; --- 21 unchanged lines hidden (view full) --- 3870 lp->state = FC_PORTDB_STATE_CHANGED; 3871 } else { 3872 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x Now Pending Valid", chan, portid); 3873 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3874 } 3875 continue; 3876 } 3877 | 3782 isp_prt(isp, ISP_LOGWARN, "changed WWN" 3783 " after relogin"); 3784 lp->new_portid = portid; 3785 lp->state = FC_PORTDB_STATE_DEAD; 3786 continue; 3787 } 3788 3789 lp->handle = pdb.handle; --- 21 unchanged lines hidden (view full) --- 3811 lp->state = FC_PORTDB_STATE_CHANGED; 3812 } else { 3813 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x Now Pending Valid", chan, portid); 3814 lp->state = FC_PORTDB_STATE_PENDING_VALID; 3815 } 3816 continue; 3817 } 3818 |
3819 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) 3820 continue; 3821 |
|
3878 /* 3879 * Ah- a new entry. Search the database again for all non-NIL 3880 * entries to make sure we never ever make a new database entry 3881 * with the same port id. While we're at it, mark where the 3882 * last free entry was. 3883 */ 3884 3885 dbidx = MAX_FC_TARG; 3886 for (lp = fcp->portdb; lp < &fcp->portdb[MAX_FC_TARG]; lp++) { 3887 if (lp >= &fcp->portdb[FL_ID] && 3888 lp <= &fcp->portdb[SNS_ID]) { 3889 continue; 3890 } | 3822 /* 3823 * Ah- a new entry. Search the database again for all non-NIL 3824 * entries to make sure we never ever make a new database entry 3825 * with the same port id. While we're at it, mark where the 3826 * last free entry was. 3827 */ 3828 3829 dbidx = MAX_FC_TARG; 3830 for (lp = fcp->portdb; lp < &fcp->portdb[MAX_FC_TARG]; lp++) { 3831 if (lp >= &fcp->portdb[FL_ID] && 3832 lp <= &fcp->portdb[SNS_ID]) { 3833 continue; 3834 } |
3891 /* 3892 * Skip any target mode entries. 3893 */ 3894 if (lp->target_mode) { 3895 continue; 3896 } | |
3897 if (lp->state == FC_PORTDB_STATE_NIL) { 3898 if (dbidx == MAX_FC_TARG) { 3899 dbidx = lp - fcp->portdb; 3900 } 3901 continue; 3902 } 3903 if (lp->state == FC_PORTDB_STATE_ZOMBIE) { 3904 continue; --- 56 unchanged lines hidden (view full) --- 3961 * And go through the database *one* more time to make sure 3962 * that we do not make more than one entry that has the same 3963 * WWNN/WWPN duple 3964 */ 3965 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3966 if (dbidx >= FL_ID && dbidx <= SNS_ID) { 3967 continue; 3968 } | 3835 if (lp->state == FC_PORTDB_STATE_NIL) { 3836 if (dbidx == MAX_FC_TARG) { 3837 dbidx = lp - fcp->portdb; 3838 } 3839 continue; 3840 } 3841 if (lp->state == FC_PORTDB_STATE_ZOMBIE) { 3842 continue; --- 56 unchanged lines hidden (view full) --- 3899 * And go through the database *one* more time to make sure 3900 * that we do not make more than one entry that has the same 3901 * WWNN/WWPN duple 3902 */ 3903 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) { 3904 if (dbidx >= FL_ID && dbidx <= SNS_ID) { 3905 continue; 3906 } |
3969 if (fcp->portdb[dbidx].target_mode) { 3970 continue; 3971 } 3972 if (fcp->portdb[dbidx].node_wwn == wwnn && fcp->portdb[dbidx].port_wwn == wwpn) { | 3907 if ((fcp->portdb[dbidx].node_wwn == wwnn || 3908 fcp->portdb[dbidx].node_wwn == 0) && 3909 fcp->portdb[dbidx].port_wwn == wwpn) { |
3973 break; 3974 } 3975 } 3976 3977 if (dbidx == MAX_FC_TARG) { 3978 ISP_MEMZERO(lp, sizeof (fcportdb_t)); 3979 lp->handle = handle; 3980 lp->node_wwn = wwnn; --- 21 unchanged lines hidden (view full) --- 4002 * Revive it. We know that WWN and WWPN 4003 * are the same. For fabric devices, we 4004 * don't care that handle is different 4005 * as we assign that. If role or portid 4006 * are different, it maybe a changed device. 4007 */ 4008 lp = &fcp->portdb[dbidx]; 4009 lp->handle = handle; | 3910 break; 3911 } 3912 } 3913 3914 if (dbidx == MAX_FC_TARG) { 3915 ISP_MEMZERO(lp, sizeof (fcportdb_t)); 3916 lp->handle = handle; 3917 lp->node_wwn = wwnn; --- 21 unchanged lines hidden (view full) --- 3939 * Revive it. We know that WWN and WWPN 3940 * are the same. For fabric devices, we 3941 * don't care that handle is different 3942 * as we assign that. If role or portid 3943 * are different, it maybe a changed device. 3944 */ 3945 lp = &fcp->portdb[dbidx]; 3946 lp->handle = handle; |
3947 lp->node_wwn = wwnn; |
|
4010 lp->new_portid = portid; 4011 lp->new_prli_word3 = nr; 4012 if (lp->portid != portid || lp->prli_word3 != nr) { 4013 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Changed", chan, portid); 4014 lp->state = FC_PORTDB_STATE_CHANGED; 4015 } else { 4016 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Pending Valid", chan, portid); 4017 lp->state = FC_PORTDB_STATE_PENDING_VALID; --- 370 unchanged lines hidden (view full) --- 4388 */ 4389 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) { 4390 return (CMD_RQLATER); 4391 } 4392 4393 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d", target); 4394 lp = &fcp->portdb[target]; 4395 if (target < 0 || target >= MAX_FC_TARG || | 3948 lp->new_portid = portid; 3949 lp->new_prli_word3 = nr; 3950 if (lp->portid != portid || lp->prli_word3 != nr) { 3951 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Changed", chan, portid); 3952 lp->state = FC_PORTDB_STATE_CHANGED; 3953 } else { 3954 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Pending Valid", chan, portid); 3955 lp->state = FC_PORTDB_STATE_PENDING_VALID; --- 370 unchanged lines hidden (view full) --- 4326 */ 4327 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) { 4328 return (CMD_RQLATER); 4329 } 4330 4331 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d", target); 4332 lp = &fcp->portdb[target]; 4333 if (target < 0 || target >= MAX_FC_TARG || |
4396 lp->dev_map_idx == 0) { | 4334 lp->is_target == 0) { |
4397 XS_SETERR(xs, HBA_SELTIMEOUT); 4398 return (CMD_COMPLETE); 4399 } 4400 if (lp->state == FC_PORTDB_STATE_ZOMBIE) { 4401 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d target zombie", XS_CHANNEL(xs), target, XS_LUN(xs)); 4402 return (CMD_RQLATER); 4403 } 4404 if (lp->state != FC_PORTDB_STATE_VALID) { 4405 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d bad db port state 0x%x", XS_CHANNEL(xs), target, XS_LUN(xs), lp->state); 4406 XS_SETERR(xs, HBA_SELTIMEOUT); 4407 return (CMD_COMPLETE); 4408 } | 4335 XS_SETERR(xs, HBA_SELTIMEOUT); 4336 return (CMD_COMPLETE); 4337 } 4338 if (lp->state == FC_PORTDB_STATE_ZOMBIE) { 4339 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d target zombie", XS_CHANNEL(xs), target, XS_LUN(xs)); 4340 return (CMD_RQLATER); 4341 } 4342 if (lp->state != FC_PORTDB_STATE_VALID) { 4343 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d bad db port state 0x%x", XS_CHANNEL(xs), target, XS_LUN(xs), lp->state); 4344 XS_SETERR(xs, HBA_SELTIMEOUT); 4345 return (CMD_COMPLETE); 4346 } |
4409 lp->dirty = 1; | |
4410 } else { 4411 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs)); 4412 if ((sdp->role & ISP_ROLE_INITIATOR) == 0) { 4413 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d I am not an initiator", XS_CHANNEL(xs), target, XS_LUN(xs)); 4414 XS_SETERR(xs, HBA_SELTIMEOUT); 4415 return (CMD_COMPLETE); 4416 } 4417 if (sdp->update) { 4418 isp_spi_update(isp, XS_CHANNEL(xs)); 4419 } | 4347 } else { 4348 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs)); 4349 if ((sdp->role & ISP_ROLE_INITIATOR) == 0) { 4350 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d I am not an initiator", XS_CHANNEL(xs), target, XS_LUN(xs)); 4351 XS_SETERR(xs, HBA_SELTIMEOUT); 4352 return (CMD_COMPLETE); 4353 } 4354 if (sdp->update) { 4355 isp_spi_update(isp, XS_CHANNEL(xs)); 4356 } |
4357 lp = NULL; |
|
4420 } 4421 4422 start_again: 4423 4424 qep = isp_getrqentry(isp); 4425 if (qep == NULL) { 4426 isp_prt(isp, ISP_LOG_WARN1, "Request Queue Overflow"); 4427 XS_SETERR(xs, HBA_BOTCH); --- 270 unchanged lines hidden (view full) --- 4698 fcparam *fcp = FCPARAM(isp, chan); 4699 fcportdb_t *lp; 4700 4701 if (tgt < 0 || tgt >= MAX_FC_TARG) { 4702 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to reset bad target %d", chan, tgt); 4703 break; 4704 } 4705 lp = &fcp->portdb[tgt]; | 4358 } 4359 4360 start_again: 4361 4362 qep = isp_getrqentry(isp); 4363 if (qep == NULL) { 4364 isp_prt(isp, ISP_LOG_WARN1, "Request Queue Overflow"); 4365 XS_SETERR(xs, HBA_BOTCH); --- 270 unchanged lines hidden (view full) --- 4636 fcparam *fcp = FCPARAM(isp, chan); 4637 fcportdb_t *lp; 4638 4639 if (tgt < 0 || tgt >= MAX_FC_TARG) { 4640 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to reset bad target %d", chan, tgt); 4641 break; 4642 } 4643 lp = &fcp->portdb[tgt]; |
4706 if (lp->dev_map_idx == 0 || | 4644 if (lp->is_target == 0 || |
4707 lp->state != FC_PORTDB_STATE_VALID) { 4708 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt); 4709 break; 4710 } 4711 4712 tmf = (isp24xx_tmf_t *) local; 4713 ISP_MEMZERO(tmf, QENTRY_LEN); 4714 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT; --- 73 unchanged lines hidden (view full) --- 4788 fcportdb_t *lp; 4789 4790 fcp = FCPARAM(isp, chan); 4791 if (tgt < 0 || tgt >= MAX_FC_TARG) { 4792 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to abort bad target %d", chan, tgt); 4793 break; 4794 } 4795 lp = &fcp->portdb[tgt]; | 4645 lp->state != FC_PORTDB_STATE_VALID) { 4646 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt); 4647 break; 4648 } 4649 4650 tmf = (isp24xx_tmf_t *) local; 4651 ISP_MEMZERO(tmf, QENTRY_LEN); 4652 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT; --- 73 unchanged lines hidden (view full) --- 4726 fcportdb_t *lp; 4727 4728 fcp = FCPARAM(isp, chan); 4729 if (tgt < 0 || tgt >= MAX_FC_TARG) { 4730 isp_prt(isp, ISP_LOGWARN, "Chan %d trying to abort bad target %d", chan, tgt); 4731 break; 4732 } 4733 lp = &fcp->portdb[tgt]; |
4796 if (lp->dev_map_idx == 0 || | 4734 if (lp->is_target == 0 || |
4797 lp->state != FC_PORTDB_STATE_VALID) { 4798 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt); 4799 break; 4800 } 4801 isp_prt(isp, ISP_LOGALL, "Chan %d Abort Cmd for N-Port 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid); 4802 ISP_MEMZERO(ab, QENTRY_LEN); 4803 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO; 4804 ab->abrt_header.rqs_entry_count = 1; --- 194 unchanged lines hidden (view full) --- 4999 { 5000 int role, r; 5001 5002 va_start(ap, ctl); 5003 chan = va_arg(ap, int); 5004 role = va_arg(ap, int); 5005 va_end(ap); 5006 if (IS_FC(isp)) { | 4735 lp->state != FC_PORTDB_STATE_VALID) { 4736 isp_prt(isp, ISP_LOGWARN, "Chan %d abort of no longer valid target %d", chan, tgt); 4737 break; 4738 } 4739 isp_prt(isp, ISP_LOGALL, "Chan %d Abort Cmd for N-Port 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid); 4740 ISP_MEMZERO(ab, QENTRY_LEN); 4741 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO; 4742 ab->abrt_header.rqs_entry_count = 1; --- 194 unchanged lines hidden (view full) --- 4937 { 4938 int role, r; 4939 4940 va_start(ap, ctl); 4941 chan = va_arg(ap, int); 4942 role = va_arg(ap, int); 4943 va_end(ap); 4944 if (IS_FC(isp)) { |
5007#ifdef ISP_TARGET_MODE 5008 if ((role & ISP_ROLE_TARGET) == 0) 5009 isp_del_all_wwn_entries(isp, chan); 5010#endif 5011 if ((role & ISP_ROLE_INITIATOR) == 0) 5012 isp_del_all_init_entries(isp, chan); | |
5013 r = isp_fc_change_role(isp, chan, role); 5014 } else { 5015 SDPARAM(isp, chan)->role = role; 5016 r = 0; 5017 } 5018 return (r); 5019 } 5020 default: --- 2861 unchanged lines hidden (view full) --- 7882} 7883 7884/* 7885 * Re-initialize the ISP and complete all orphaned commands 7886 * with a 'botched' notice. The reset/init routines should 7887 * not disturb an already active list of commands. 7888 */ 7889 | 4945 r = isp_fc_change_role(isp, chan, role); 4946 } else { 4947 SDPARAM(isp, chan)->role = role; 4948 r = 0; 4949 } 4950 return (r); 4951 } 4952 default: --- 2861 unchanged lines hidden (view full) --- 7814} 7815 7816/* 7817 * Re-initialize the ISP and complete all orphaned commands 7818 * with a 'botched' notice. The reset/init routines should 7819 * not disturb an already active list of commands. 7820 */ 7821 |
7890void | 7822int |
7891isp_reinit(ispsoftc_t *isp, int do_load_defaults) 7892{ | 7823isp_reinit(ispsoftc_t *isp, int do_load_defaults) 7824{ |
7893 int i; | 7825 int i, res = 0; |
7894 7895 isp_reset(isp, do_load_defaults); | 7826 7827 isp_reset(isp, do_load_defaults); |
7896 | |
7897 if (isp->isp_state != ISP_RESETSTATE) { | 7828 if (isp->isp_state != ISP_RESETSTATE) { |
7829 res = EIO; |
|
7898 isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__); 7899 ISP_DISABLE_INTS(isp); 7900 goto cleanup; 7901 } 7902 7903 isp_init(isp); | 7830 isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__); 7831 ISP_DISABLE_INTS(isp); 7832 goto cleanup; 7833 } 7834 7835 isp_init(isp); |
7904 | |
7905 if (isp->isp_state == ISP_INITSTATE) { 7906 isp->isp_state = ISP_RUNSTATE; 7907 } 7908 7909 if (isp->isp_state != ISP_RUNSTATE) { | 7836 if (isp->isp_state == ISP_INITSTATE) { 7837 isp->isp_state = ISP_RUNSTATE; 7838 } 7839 7840 if (isp->isp_state != ISP_RUNSTATE) { |
7841 res = EIO; |
|
7910#ifndef ISP_TARGET_MODE 7911 isp_prt(isp, ISP_LOGWARN, "%s: not at runstate", __func__); 7912#endif 7913 ISP_DISABLE_INTS(isp); 7914 if (IS_FC(isp)) { 7915 /* 7916 * If we're in ISP_ROLE_NONE, turn off the lasers. 7917 */ 7918 if (!IS_24XX(isp)) { 7919 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); 7920 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); 7921 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS); 7922 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL); 7923 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS); 7924 } 7925 } | 7842#ifndef ISP_TARGET_MODE 7843 isp_prt(isp, ISP_LOGWARN, "%s: not at runstate", __func__); 7844#endif 7845 ISP_DISABLE_INTS(isp); 7846 if (IS_FC(isp)) { 7847 /* 7848 * If we're in ISP_ROLE_NONE, turn off the lasers. 7849 */ 7850 if (!IS_24XX(isp)) { 7851 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS); 7852 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET); 7853 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS); 7854 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL); 7855 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS); 7856 } 7857 } |
7926 } | 7858 } |
7927 7928 cleanup: | 7859 7860 cleanup: |
7929 | |
7930 isp->isp_nactive = 0; | 7861 isp->isp_nactive = 0; |
7931 | |
7932 isp_clear_commands(isp); 7933 if (IS_FC(isp)) { | 7862 isp_clear_commands(isp); 7863 if (IS_FC(isp)) { |
7934 for (i = 0; i < isp->isp_nchan; i++) { | 7864 for (i = 0; i < isp->isp_nchan; i++) |
7935 ISP_MARK_PORTDB(isp, i, -1); | 7865 ISP_MARK_PORTDB(isp, i, -1); |
7936 } | |
7937 } | 7866 } |
7867 return (res); |
|
7938} 7939 7940/* 7941 * NVRAM Routines 7942 */ 7943static int 7944isp_read_nvram(ispsoftc_t *isp, int bus) 7945{ --- 601 unchanged lines hidden --- | 7868} 7869 7870/* 7871 * NVRAM Routines 7872 */ 7873static int 7874isp_read_nvram(ispsoftc_t *isp, int bus) 7875{ --- 601 unchanged lines hidden --- |