isp_library.c (288709) | isp_library.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 * --- 21 unchanged lines hidden (view full) --- 30 */ 31#ifdef __NetBSD__ 32#include <sys/cdefs.h> 33__KERNEL_RCSID(0, "$NetBSD$"); 34#include <dev/ic/isp_netbsd.h> 35#endif 36#ifdef __FreeBSD__ 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2009 by Matthew Jacob 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 21 unchanged lines hidden (view full) --- 30 */ 31#ifdef __NetBSD__ 32#include <sys/cdefs.h> 33__KERNEL_RCSID(0, "$NetBSD$"); 34#include <dev/ic/isp_netbsd.h> 35#endif 36#ifdef __FreeBSD__ 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp_library.c 288709 2015-10-05 08:16:10Z mav $"); | 38__FBSDID("$FreeBSD: stable/10/sys/dev/isp/isp_library.c 288714 2015-10-05 08:31:48Z mav $"); |
39#include <dev/isp/isp_freebsd.h> 40#endif 41#ifdef __OpenBSD__ 42#include <dev/ic/isp_openbsd.h> 43#endif 44#ifdef __linux__ 45#include "isp_linux.h" 46#endif --- 359 unchanged lines hidden (view full) --- 406 return (-1); 407 } 408 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD) { 409 isp_prt(isp, ISP_LOG_SANCFG, "isp_fc_runstate: f/w not ready for channel %d", chan); 410 return (-1); 411 } 412 } 413 | 39#include <dev/isp/isp_freebsd.h> 40#endif 41#ifdef __OpenBSD__ 42#include <dev/ic/isp_openbsd.h> 43#endif 44#ifdef __linux__ 45#include "isp_linux.h" 46#endif --- 359 unchanged lines hidden (view full) --- 406 return (-1); 407 } 408 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD) { 409 isp_prt(isp, ISP_LOG_SANCFG, "isp_fc_runstate: f/w not ready for channel %d", chan); 410 return (-1); 411 } 412 } 413 |
414 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) { 415 return (0); 416 } 417 | |
418 if (isp_control(isp, ISPCTL_SCAN_LOOP, chan) != 0) { 419 isp_prt(isp, ISP_LOG_SANCFG, "isp_fc_runstate: scan loop fails on channel %d", chan); 420 return (LOOP_PDB_RCVD); 421 } 422 if (isp_control(isp, ISPCTL_SCAN_FABRIC, chan) != 0) { 423 isp_prt(isp, ISP_LOG_SANCFG, "isp_fc_runstate: scan fabric fails on channel %d", chan); 424 return (LOOP_LSCAN_DONE); 425 } --- 13 unchanged lines hidden (view full) --- 439 */ 440void 441isp_dump_portdb(ispsoftc_t *isp, int chan) 442{ 443 fcparam *fcp = FCPARAM(isp, chan); 444 int i; 445 446 for (i = 0; i < MAX_FC_TARG; i++) { | 414 if (isp_control(isp, ISPCTL_SCAN_LOOP, chan) != 0) { 415 isp_prt(isp, ISP_LOG_SANCFG, "isp_fc_runstate: scan loop fails on channel %d", chan); 416 return (LOOP_PDB_RCVD); 417 } 418 if (isp_control(isp, ISPCTL_SCAN_FABRIC, chan) != 0) { 419 isp_prt(isp, ISP_LOG_SANCFG, "isp_fc_runstate: scan fabric fails on channel %d", chan); 420 return (LOOP_LSCAN_DONE); 421 } --- 13 unchanged lines hidden (view full) --- 435 */ 436void 437isp_dump_portdb(ispsoftc_t *isp, int chan) 438{ 439 fcparam *fcp = FCPARAM(isp, chan); 440 int i; 441 442 for (i = 0; i < MAX_FC_TARG; i++) { |
447 char mb[4], buf1[64], buf2[64]; | 443 char buf1[64], buf2[64]; |
448 const char *dbs[8] = { 449 "NIL ", 450 "PROB", 451 "DEAD", 452 "CHGD", 453 "NEW ", 454 "PVLD", 455 "ZOMB", 456 "VLD " 457 }; 458 fcportdb_t *lp = &fcp->portdb[i]; 459 | 444 const char *dbs[8] = { 445 "NIL ", 446 "PROB", 447 "DEAD", 448 "CHGD", 449 "NEW ", 450 "PVLD", 451 "ZOMB", 452 "VLD " 453 }; 454 fcportdb_t *lp = &fcp->portdb[i]; 455 |
460 if (lp->state == FC_PORTDB_STATE_NIL && lp->target_mode == 0) { | 456 if (lp->state == FC_PORTDB_STATE_NIL) { |
461 continue; 462 } | 457 continue; 458 } |
463 if (lp->dev_map_idx) { 464 ISP_SNPRINTF(mb, sizeof (mb), "%3d", ((int) lp->dev_map_idx) - 1); 465 } else { 466 ISP_SNPRINTF(mb, sizeof (mb), "---"); 467 } | |
468 isp_gen_role_str(buf1, sizeof (buf1), lp->prli_word3); 469 isp_gen_role_str(buf2, sizeof (buf2), lp->new_prli_word3); | 459 isp_gen_role_str(buf1, sizeof (buf1), lp->prli_word3); 460 isp_gen_role_str(buf2, sizeof (buf2), lp->new_prli_word3); |
470 isp_prt(isp, ISP_LOGALL, "Chan %d [%d]: hdl 0x%x %s al%d tgt %s %s 0x%06x =>%s 0x%06x; WWNN 0x%08x%08x WWPN 0x%08x%08x", 471 chan, i, lp->handle, dbs[lp->state], lp->autologin, mb, buf1, lp->portid, buf2, lp->new_portid, | 461 isp_prt(isp, ISP_LOGALL, "Chan %d [%d]: hdl 0x%x %s al%d %s 0x%06x =>%s 0x%06x; WWNN 0x%08x%08x WWPN 0x%08x%08x", 462 chan, i, lp->handle, dbs[lp->state], lp->autologin, buf1, lp->portid, buf2, lp->new_portid, |
472 (uint32_t) (lp->node_wwn >> 32), (uint32_t) (lp->node_wwn), (uint32_t) (lp->port_wwn >> 32), (uint32_t) (lp->port_wwn)); 473 } 474} 475 476void 477isp_gen_role_str(char *buf, size_t len, uint16_t p3) 478{ 479 int nd = 0; --- 118 unchanged lines hidden (view full) --- 598{ 599 fcparam *fcp = FCPARAM(isp, chan); 600 601 if (chan >= isp->isp_nchan) { 602 isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan); 603 return (ENXIO); 604 } 605 if (chan == 0) { | 463 (uint32_t) (lp->node_wwn >> 32), (uint32_t) (lp->node_wwn), (uint32_t) (lp->port_wwn >> 32), (uint32_t) (lp->port_wwn)); 464 } 465} 466 467void 468isp_gen_role_str(char *buf, size_t len, uint16_t p3) 469{ 470 int nd = 0; --- 118 unchanged lines hidden (view full) --- 589{ 590 fcparam *fcp = FCPARAM(isp, chan); 591 592 if (chan >= isp->isp_nchan) { 593 isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan); 594 return (ENXIO); 595 } 596 if (chan == 0) { |
606 isp_clear_commands(isp); 607 isp_reset(isp, 0); 608 if (isp->isp_state != ISP_RESETSTATE) { 609 isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__); 610 return (EIO); 611 } | |
612 fcp->role = new_role; | 597 fcp->role = new_role; |
613 isp_init(isp); 614 if (isp->isp_state != ISP_INITSTATE) { 615 isp_prt(isp, ISP_LOGERR, "%s: cannot init card", __func__); 616 return (EIO); 617 } 618 isp->isp_state = ISP_RUNSTATE; 619 return (0); | 598 return (isp_reinit(isp, 0)); |
620 } else if (ISP_CAP_MULTI_ID(isp)) { 621 mbreg_t mbs; 622 vp_modify_t *vp; 623 uint8_t qe[QENTRY_LEN], *scp; 624 625 ISP_MEMZERO(qe, QENTRY_LEN); 626 if (FC_SCRATCH_ACQUIRE(isp, chan)) { 627 return (EBUSY); --- 1714 unchanged lines hidden (view full) --- 2342 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle); 2343 } else { 2344 isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].handle = ISP_HANDLE_FREE; 2345 isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].cmd = isp->isp_tgtfree; 2346 isp->isp_tgtfree = &isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)]; 2347 } 2348} 2349 | 599 } else if (ISP_CAP_MULTI_ID(isp)) { 600 mbreg_t mbs; 601 vp_modify_t *vp; 602 uint8_t qe[QENTRY_LEN], *scp; 603 604 ISP_MEMZERO(qe, QENTRY_LEN); 605 if (FC_SCRATCH_ACQUIRE(isp, chan)) { 606 return (EBUSY); --- 1714 unchanged lines hidden (view full) --- 2321 isp_prt(isp, ISP_LOGERR, "%s: bad handle 0x%x", __func__, handle); 2322 } else { 2323 isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].handle = ISP_HANDLE_FREE; 2324 isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)].cmd = isp->isp_tgtfree; 2325 isp->isp_tgtfree = &isp->isp_tgtlist[(handle & ISP_HANDLE_CMD_MASK)]; 2326 } 2327} 2328 |
2329#endif 2330 |
|
2350/* | 2331/* |
2351 * Find target mode entries | 2332 * Find port database entries |
2352 */ 2353int 2354isp_find_pdb_by_wwn(ispsoftc_t *isp, int chan, uint64_t wwn, fcportdb_t **lptr) 2355{ 2356 fcparam *fcp; 2357 int i; 2358 2359 if (chan >= isp->isp_nchan) 2360 return (0); 2361 fcp = FCPARAM(isp, chan); | 2333 */ 2334int 2335isp_find_pdb_by_wwn(ispsoftc_t *isp, int chan, uint64_t wwn, fcportdb_t **lptr) 2336{ 2337 fcparam *fcp; 2338 int i; 2339 2340 if (chan >= isp->isp_nchan) 2341 return (0); 2342 fcp = FCPARAM(isp, chan); |
2362 for (i = MAX_FC_TARG - 1; i >= 0; i--) { | 2343 for (i = 0; i < MAX_FC_TARG; i++) { |
2363 fcportdb_t *lp = &fcp->portdb[i]; 2364 | 2344 fcportdb_t *lp = &fcp->portdb[i]; 2345 |
2365 if (lp->target_mode == 0) | 2346 if (lp->state == FC_PORTDB_STATE_NIL) |
2366 continue; 2367 if (lp->port_wwn == wwn) { 2368 *lptr = lp; 2369 return (1); 2370 } 2371 } 2372 return (0); 2373} 2374 | 2347 continue; 2348 if (lp->port_wwn == wwn) { 2349 *lptr = lp; 2350 return (1); 2351 } 2352 } 2353 return (0); 2354} 2355 |
2356#ifdef ISP_TARGET_MODE 2357 |
|
2375int | 2358int |
2376isp_find_pdb_by_loopid(ispsoftc_t *isp, int chan, uint32_t loopid, fcportdb_t **lptr) | 2359isp_find_pdb_by_handle(ispsoftc_t *isp, int chan, uint32_t handle, fcportdb_t **lptr) |
2377{ 2378 fcparam *fcp; 2379 int i; 2380 2381 if (chan >= isp->isp_nchan) 2382 return (0); 2383 fcp = FCPARAM(isp, chan); | 2360{ 2361 fcparam *fcp; 2362 int i; 2363 2364 if (chan >= isp->isp_nchan) 2365 return (0); 2366 fcp = FCPARAM(isp, chan); |
2384 if ((i = fcp->isp_tgt_map[loopid]) > 0) { 2385 *lptr = &fcp->portdb[i - 1]; 2386 return (1); | 2367 for (i = 0; i < MAX_FC_TARG; i++) { 2368 fcportdb_t *lp = &fcp->portdb[i]; 2369 2370 if (lp->state == FC_PORTDB_STATE_NIL) 2371 continue; 2372 if (lp->handle == handle) { 2373 *lptr = lp; 2374 return (1); 2375 } |
2387 } 2388 return (0); 2389} 2390 2391int 2392isp_find_pdb_by_sid(ispsoftc_t *isp, int chan, uint32_t sid, fcportdb_t **lptr) 2393{ 2394 fcparam *fcp; 2395 int i; 2396 2397 if (chan >= isp->isp_nchan) 2398 return (0); 2399 fcp = FCPARAM(isp, chan); | 2376 } 2377 return (0); 2378} 2379 2380int 2381isp_find_pdb_by_sid(ispsoftc_t *isp, int chan, uint32_t sid, fcportdb_t **lptr) 2382{ 2383 fcparam *fcp; 2384 int i; 2385 2386 if (chan >= isp->isp_nchan) 2387 return (0); 2388 fcp = FCPARAM(isp, chan); |
2400 for (i = MAX_FC_TARG - 1; i >= 0; i--) { | 2389 for (i = 0; i < MAX_FC_TARG; i++) { |
2401 fcportdb_t *lp = &fcp->portdb[i]; 2402 | 2390 fcportdb_t *lp = &fcp->portdb[i]; 2391 |
2403 if (lp->target_mode == 0) | 2392 if (lp->state == FC_PORTDB_STATE_NIL) |
2404 continue; 2405 if (lp->portid == sid) { 2406 *lptr = lp; 2407 return (1); 2408 } 2409 } 2410 return (0); 2411} --- 20 unchanged lines hidden (view full) --- 2432 * Add an initiator device to the port database 2433 */ 2434void 2435isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint32_t s_id, uint16_t prli_params) 2436{ 2437 char buf[64]; 2438 fcparam *fcp; 2439 fcportdb_t *lp; | 2393 continue; 2394 if (lp->portid == sid) { 2395 *lptr = lp; 2396 return (1); 2397 } 2398 } 2399 return (0); 2400} --- 20 unchanged lines hidden (view full) --- 2421 * Add an initiator device to the port database 2422 */ 2423void 2424isp_add_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint32_t s_id, uint16_t prli_params) 2425{ 2426 char buf[64]; 2427 fcparam *fcp; 2428 fcportdb_t *lp; |
2440 isp_notify_t nt; 2441 int i, something, take, taken; | 2429 int i, change; |
2442 2443 fcp = FCPARAM(isp, chan); 2444 if (nphdl >= MAX_NPORT_HANDLE) { | 2430 2431 fcp = FCPARAM(isp, chan); 2432 if (nphdl >= MAX_NPORT_HANDLE) { |
2445 isp_prt(isp, ISP_LOGWARN, "Chan %d IID 0x%016llx " 2446 "N-Port handle 0x%04x Port ID 0x%06x -- bad handle", 2447 chan, (unsigned long long) ini, nphdl, s_id); | 2433 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, "Chan %d WWPN 0x%016llx " 2434 "PortID 0x%06x handle 0x%x -- bad handle", 2435 chan, (unsigned long long) ini, s_id, nphdl); |
2448 return; 2449 } 2450 2451 /* 2452 * If valid record for requested handle already exists, update it 2453 * with new parameters. Some cases of update can be suspicious, 2454 * so log them verbosely and dump the whole port database. 2455 */ | 2436 return; 2437 } 2438 2439 /* 2440 * If valid record for requested handle already exists, update it 2441 * with new parameters. Some cases of update can be suspicious, 2442 * so log them verbosely and dump the whole port database. 2443 */ |
2456 if ((i = fcp->isp_tgt_map[nphdl]) > 0) { 2457 take = taken = i - 1; 2458 lp = &fcp->portdb[taken]; 2459 something = 0; | 2444 if ((VALID_INI(ini) && isp_find_pdb_by_wwn(isp, chan, ini, &lp)) || 2445 (s_id != PORT_NONE && isp_find_pdb_by_sid(isp, chan, s_id, &lp))) { 2446 change = 0; 2447 lp->new_portid = lp->portid; 2448 lp->new_prli_word3 = lp->prli_word3; |
2460 if (s_id != PORT_NONE && lp->portid != s_id) { 2461 if (lp->portid == PORT_NONE) { 2462 isp_prt(isp, ISP_LOGTINFO, | 2449 if (s_id != PORT_NONE && lp->portid != s_id) { 2450 if (lp->portid == PORT_NONE) { 2451 isp_prt(isp, ISP_LOGTINFO, |
2463 "Chan %d IID 0x%016llx N-port handle 0x%04x " 2464 "gets Port ID 0x%06x", | 2452 "Chan %d WWPN 0x%016llx handle 0x%x " 2453 "gets PortID 0x%06x", |
2465 chan, (unsigned long long) lp->port_wwn, 2466 nphdl, s_id); 2467 } else { 2468 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, | 2454 chan, (unsigned long long) lp->port_wwn, 2455 nphdl, s_id); 2456 } else { 2457 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, |
2469 "Chan %d IID 0x%016llx N-port handle 0x%04x " 2470 "changes Port ID 0x%06x to 0x%06x", | 2458 "Chan %d WWPN 0x%016llx handle 0x%x " 2459 "changes PortID 0x%06x to 0x%06x", |
2471 chan, (unsigned long long) lp->port_wwn, 2472 nphdl, lp->portid, s_id); 2473 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2474 isp_dump_portdb(isp, chan); 2475 } | 2460 chan, (unsigned long long) lp->port_wwn, 2461 nphdl, lp->portid, s_id); 2462 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2463 isp_dump_portdb(isp, chan); 2464 } |
2476 lp->portid = s_id; 2477 something++; | 2465 lp->new_portid = s_id; 2466 change++; |
2478 } 2479 if (VALID_INI(ini) && lp->port_wwn != ini) { 2480 if (!VALID_INI(lp->port_wwn)) { 2481 isp_prt(isp, ISP_LOGTINFO, | 2467 } 2468 if (VALID_INI(ini) && lp->port_wwn != ini) { 2469 if (!VALID_INI(lp->port_wwn)) { 2470 isp_prt(isp, ISP_LOGTINFO, |
2482 "Chan %d N-port handle 0x%04x Port ID " 2483 "0x%06x gets WWN 0x%016llxx", 2484 chan, nphdl, lp->portid, | 2471 "Chan %d PortID 0x%06x handle 0x%x " 2472 "gets WWN 0x%016llxx", 2473 chan, lp->portid, nphdl, |
2485 (unsigned long long) ini); 2486 } else if (lp->port_wwn != ini) { 2487 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, | 2474 (unsigned long long) ini); 2475 } else if (lp->port_wwn != ini) { 2476 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, |
2488 "Chan %d N-port handle 0x%04x Port ID " 2489 "0x%06x changes WWN 0x%016llx to 0x%016llx", 2490 chan, nphdl, lp->portid, | 2477 "Chan %d PortID 0x%06x handle 0x%x " 2478 "changes WWN 0x%016llx to 0x%016llx", 2479 chan, lp->portid, nphdl, |
2491 (unsigned long long) lp->port_wwn, 2492 (unsigned long long) ini); 2493 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2494 isp_dump_portdb(isp, chan); 2495 } 2496 lp->port_wwn = ini; | 2480 (unsigned long long) lp->port_wwn, 2481 (unsigned long long) ini); 2482 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2483 isp_dump_portdb(isp, chan); 2484 } 2485 lp->port_wwn = ini; |
2497 something++; | 2486 change++; |
2498 } | 2487 } |
2499 if (lp->prli_word3 != prli_params) { 2500 lp->prli_word3 = prli_params; 2501 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3); | 2488 if (prli_params != 0 && lp->prli_word3 != prli_params) { 2489 isp_gen_role_str(buf, sizeof (buf), prli_params); |
2502 isp_prt(isp, ISP_LOGTINFO|ISP_LOGCONFIG, | 2490 isp_prt(isp, ISP_LOGTINFO|ISP_LOGCONFIG, |
2503 "Chan %d IID 0x%016llx N-Port Handle 0x%04x " 2504 "Port ID 0x%06x changes PRLI Word 3 %s", | 2491 "Chan %d WWPN 0x%016llx PortID 0x%06x " 2492 "handle 0x%x changes PRLI Word 3 %s", |
2505 chan, (unsigned long long) lp->port_wwn, | 2493 chan, (unsigned long long) lp->port_wwn, |
2506 lp->handle, lp->portid, buf); 2507 something++; | 2494 lp->portid, lp->handle, buf); 2495 lp->new_prli_word3 = prli_params; 2496 change++; |
2508 } | 2497 } |
2509 if (!something) { 2510 isp_prt(isp, ISP_LOGTINFO, 2511 "Chan %d IID 0x%016llx N-Port Handle 0x%04x " 2512 "Port ID 0x%06x reentered", | 2498 if (lp->handle != nphdl) { 2499 isp_prt(isp, ISP_LOGTINFO|ISP_LOGCONFIG, 2500 "Chan %d WWPN 0x%016llx PortID 0x%06x " 2501 "changes handle 0x%x to 0x%x", |
2513 chan, (unsigned long long) lp->port_wwn, | 2502 chan, (unsigned long long) lp->port_wwn, |
2514 lp->handle, lp->portid); | 2503 lp->portid, lp->handle, nphdl); 2504 lp->handle = nphdl; 2505 change++; |
2515 } | 2506 } |
2516 } else 2517 take = taken = -1; 2518 2519 /* 2520 * Search for records colliding on handler, Port ID or WWN. 2521 * Remove any found collisions, logging suspicious cases of 2522 * still valid records. 2523 */ 2524 for (i = 0; i < MAX_FC_TARG; i++) { 2525 lp = &fcp->portdb[i]; 2526 if (lp->target_mode == 0 || i == take) 2527 continue; 2528 if (lp->handle != nphdl && lp->portid != s_id && 2529 lp->port_wwn != ini) 2530 continue; 2531 if (lp->state == FC_PORTDB_STATE_VALID) { 2532 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, 2533 "Chan %d IID 0x%016llx N-Port Handle 0x%04x " 2534 "Port ID 0x%06x is conflicting", | 2507 lp->state = FC_PORTDB_STATE_VALID; 2508 if (change) { 2509 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp); 2510 lp->portid = lp->new_portid; 2511 lp->prli_word3 = lp->new_prli_word3; 2512 lp->new_prli_word3 = 0; 2513 lp->new_portid = 0; 2514 } else { 2515 isp_prt(isp, ISP_LOGTINFO, 2516 "Chan %d WWPN 0x%016llx PortID 0x%06x " 2517 "handle 0x%x reentered", |
2535 chan, (unsigned long long) lp->port_wwn, | 2518 chan, (unsigned long long) lp->port_wwn, |
2536 lp->handle, lp->portid); 2537 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2538 isp_dump_portdb(isp, chan); 2539 isp_del_wwn_entry(isp, chan, 2540 lp->port_wwn, lp->handle, lp->portid); | 2519 lp->portid, lp->handle); 2520 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp); |
2541 } | 2521 } |
2542 ISP_MEMZERO(lp, sizeof (fcportdb_t)); 2543 take = i; | 2522 return; |
2544 } 2545 | 2523 } 2524 |
2546 /* If valid record already exists -- we are done. */ 2547 if (taken >= 0) 2548 return; 2549 | |
2550 /* Search for room to insert new record. */ | 2525 /* Search for room to insert new record. */ |
2551 if (take < 0) { 2552 for (i = MAX_FC_TARG - 1; i >= 0; i--) { 2553 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) { 2554 take = i; 2555 break; 2556 } 2557 } | 2526 for (i = 0; i < MAX_FC_TARG; i++) { 2527 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) 2528 break; |
2558 } | 2529 } |
2559 if (take < 0) { | 2530 if (i >= MAX_FC_TARG) { |
2560 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, | 2531 isp_prt(isp, ISP_LOGTINFO|ISP_LOGWARN, |
2561 "Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x " | 2532 "Chan %d WWPN 0x%016llx PortID 0x%06x handle 0x%x " |
2562 "-- no room in port database", | 2533 "-- no room in port database", |
2563 chan, (unsigned long long) ini, nphdl, s_id); | 2534 chan, (unsigned long long) ini, s_id, nphdl); |
2564 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2565 isp_dump_portdb(isp, chan); 2566 return; 2567 } 2568 2569 /* Insert new record and mark it valid. */ | 2535 if (isp->isp_dblev & (ISP_LOGTINFO|ISP_LOGWARN)) 2536 isp_dump_portdb(isp, chan); 2537 return; 2538 } 2539 2540 /* Insert new record and mark it valid. */ |
2570 lp = &fcp->portdb[take]; | 2541 lp = &fcp->portdb[i]; |
2571 ISP_MEMZERO(lp, sizeof (fcportdb_t)); | 2542 ISP_MEMZERO(lp, sizeof (fcportdb_t)); |
2572 lp->target_mode = 1; | |
2573 lp->handle = nphdl; 2574 lp->portid = s_id; 2575 lp->port_wwn = ini; | 2543 lp->handle = nphdl; 2544 lp->portid = s_id; 2545 lp->port_wwn = ini; |
2576 lp->prli_word3 = prli_params; | 2546 lp->prli_word3 = (prli_params != 0) ? prli_params : PRLI_WD3_INITIATOR_FUNCTION; |
2577 lp->state = FC_PORTDB_STATE_VALID; | 2547 lp->state = FC_PORTDB_STATE_VALID; |
2578 fcp->isp_tgt_map[nphdl] = take + 1; | |
2579 2580 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3); | 2548 2549 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3); |
2581 isp_prt(isp, ISP_LOGTINFO, "Chan %d IID 0x%016llx N-Port Handle 0x%04x" 2582 " Port ID 0x%06x vtgt %d %s added", chan, 2583 (unsigned long long) ini, nphdl, s_id, take, buf); | 2550 isp_prt(isp, ISP_LOGTINFO, "Chan %d WWPN 0x%016llx " 2551 "PortID 0x%06x handle 0x%x vtgt %d %s added", chan, 2552 (unsigned long long) ini, s_id, nphdl, i, buf); |
2584 | 2553 |
2585 /* Notify above levels about new initiator arrival. */ 2586 ISP_MEMZERO(&nt, sizeof (nt)); 2587 nt.nt_hba = isp; 2588 nt.nt_wwn = ini; 2589 nt.nt_tgt = FCPARAM(isp, chan)->isp_wwpn; 2590 nt.nt_sid = s_id; 2591 nt.nt_did = FCPARAM(isp, chan)->isp_portid; 2592 nt.nt_nphdl = nphdl; 2593 nt.nt_channel = chan; 2594 nt.nt_ncode = NT_ARRIVED; 2595 isp_async(isp, ISPASYNC_TARGET_NOTIFY, &nt); | 2554 /* Notify above levels about new port arrival. */ 2555 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp); |
2596} 2597 2598/* 2599 * Remove a target device to the port database 2600 */ 2601void 2602isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint32_t s_id) 2603{ 2604 fcparam *fcp; | 2556} 2557 2558/* 2559 * Remove a target device to the port database 2560 */ 2561void 2562isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t ini, uint16_t nphdl, uint32_t s_id) 2563{ 2564 fcparam *fcp; |
2605 isp_notify_t nt; | |
2606 fcportdb_t *lp; 2607 2608 if (nphdl >= MAX_NPORT_HANDLE) { | 2565 fcportdb_t *lp; 2566 2567 if (nphdl >= MAX_NPORT_HANDLE) { |
2609 isp_prt(isp, ISP_LOGWARN, "Chan %d IID 0x%016llx bad N-Port handle 0x%04x Port ID 0x%06x", 2610 chan, (unsigned long long) ini, nphdl, s_id); | 2568 isp_prt(isp, ISP_LOGWARN, "Chan %d WWPN 0x%016llx PortID 0x%06x bad handle 0x%x", 2569 chan, (unsigned long long) ini, s_id, nphdl); |
2611 return; 2612 } 2613 2614 fcp = FCPARAM(isp, chan); | 2570 return; 2571 } 2572 2573 fcp = FCPARAM(isp, chan); |
2615 if (fcp->isp_tgt_map[nphdl] == 0) { 2616 lp = NULL; 2617 } else { 2618 lp = &fcp->portdb[fcp->isp_tgt_map[nphdl] - 1]; 2619 if (lp->target_mode == 0) { 2620 lp = NULL; 2621 } 2622 } 2623 if (lp == NULL) { 2624 isp_prt(isp, ISP_LOGWARN, "Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x cannot be found to be deleted", 2625 chan, (unsigned long long) ini, nphdl, s_id); | 2574 if (isp_find_pdb_by_handle(isp, chan, nphdl, &lp) == 0) { 2575 isp_prt(isp, ISP_LOGWARN, "Chan %d WWPN 0x%016llx PortID 0x%06x handle 0x%x cannot be found to be deleted", 2576 chan, (unsigned long long) ini, s_id, nphdl); |
2626 isp_dump_portdb(isp, chan); 2627 return; 2628 } | 2577 isp_dump_portdb(isp, chan); 2578 return; 2579 } |
2629 isp_prt(isp, ISP_LOGTINFO, "Chan %d IID 0x%016llx N-Port Handle 0x%04x Port ID 0x%06x vtgt %d deleted", 2630 chan, (unsigned long long) lp->port_wwn, nphdl, lp->portid, fcp->isp_tgt_map[nphdl] - 1); 2631 fcp->isp_tgt_map[nphdl] = 0; 2632 lp->state = FC_PORTDB_STATE_DEAD; | 2580 isp_prt(isp, ISP_LOGTINFO, "Chan %d WWPN 0x%016llx PortID 0x%06x handle 0x%x vtgt %d deleted", 2581 chan, (unsigned long long) lp->port_wwn, lp->portid, nphdl, FC_PORTDB_TGT(isp, chan, lp)); 2582 lp->state = FC_PORTDB_STATE_NIL; |
2633 | 2583 |
2634 ISP_MEMZERO(&nt, sizeof (nt)); 2635 nt.nt_hba = isp; 2636 nt.nt_wwn = lp->port_wwn; 2637 nt.nt_tgt = FCPARAM(isp, chan)->isp_wwpn; 2638 nt.nt_sid = lp->portid; 2639 nt.nt_did = FCPARAM(isp, chan)->isp_portid; 2640 nt.nt_nphdl = nphdl; 2641 nt.nt_channel = chan; 2642 nt.nt_ncode = NT_DEPARTED; 2643 isp_async(isp, ISPASYNC_TARGET_NOTIFY, &nt); | 2584 /* Notify above levels about gone port. */ 2585 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp); |
2644} 2645 2646void 2647isp_del_all_wwn_entries(ispsoftc_t *isp, int chan) 2648{ 2649 fcparam *fcp; 2650 int i; 2651 --- 14 unchanged lines hidden (view full) --- 2666 if (chan > isp->isp_nchan) { 2667 return; 2668 } 2669 2670 fcp = FCPARAM(isp, chan); 2671 if (fcp == NULL) { 2672 return; 2673 } | 2586} 2587 2588void 2589isp_del_all_wwn_entries(ispsoftc_t *isp, int chan) 2590{ 2591 fcparam *fcp; 2592 int i; 2593 --- 14 unchanged lines hidden (view full) --- 2608 if (chan > isp->isp_nchan) { 2609 return; 2610 } 2611 2612 fcp = FCPARAM(isp, chan); 2613 if (fcp == NULL) { 2614 return; 2615 } |
2674 for (i = 0; i < MAX_NPORT_HANDLE; i++) { 2675 if (fcp->isp_tgt_map[i]) { 2676 fcportdb_t *lp = &fcp->portdb[fcp->isp_tgt_map[i] - 1]; | 2616 for (i = 0; i < MAX_FC_TARG; i++) { 2617 fcportdb_t *lp = &fcp->portdb[i]; 2618 2619 if (lp->state != FC_PORTDB_STATE_NIL) |
2677 isp_del_wwn_entry(isp, chan, lp->port_wwn, lp->handle, lp->portid); | 2620 isp_del_wwn_entry(isp, chan, lp->port_wwn, lp->handle, lp->portid); |
2678 } | |
2679 } 2680} 2681 2682void 2683isp_del_wwn_entries(ispsoftc_t *isp, isp_notify_t *mp) 2684{ 2685 fcportdb_t *lp; 2686 --- 10 unchanged lines hidden (view full) --- 2697 2698 /* 2699 * We have an entry which is only partially identified. 2700 * 2701 * It's only known by WWN, N-Port handle, or Port ID. 2702 * We need to find the actual entry so we can delete it. 2703 */ 2704 if (mp->nt_nphdl != NIL_HANDLE) { | 2621 } 2622} 2623 2624void 2625isp_del_wwn_entries(ispsoftc_t *isp, isp_notify_t *mp) 2626{ 2627 fcportdb_t *lp; 2628 --- 10 unchanged lines hidden (view full) --- 2639 2640 /* 2641 * We have an entry which is only partially identified. 2642 * 2643 * It's only known by WWN, N-Port handle, or Port ID. 2644 * We need to find the actual entry so we can delete it. 2645 */ 2646 if (mp->nt_nphdl != NIL_HANDLE) { |
2705 if (isp_find_pdb_by_loopid(isp, mp->nt_channel, mp->nt_nphdl, &lp)) { | 2647 if (isp_find_pdb_by_handle(isp, mp->nt_channel, mp->nt_nphdl, &lp)) { |
2706 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid); 2707 return; 2708 } 2709 } 2710 if (mp->nt_wwn != INI_ANY) { 2711 if (isp_find_pdb_by_wwn(isp, mp->nt_channel, mp->nt_wwn, &lp)) { 2712 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid); 2713 return; 2714 } 2715 } 2716 if (mp->nt_sid != PORT_ANY && mp->nt_sid != PORT_NONE) { 2717 if (isp_find_pdb_by_sid(isp, mp->nt_channel, mp->nt_sid, &lp)) { 2718 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid); 2719 return; 2720 } 2721 } | 2648 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid); 2649 return; 2650 } 2651 } 2652 if (mp->nt_wwn != INI_ANY) { 2653 if (isp_find_pdb_by_wwn(isp, mp->nt_channel, mp->nt_wwn, &lp)) { 2654 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid); 2655 return; 2656 } 2657 } 2658 if (mp->nt_sid != PORT_ANY && mp->nt_sid != PORT_NONE) { 2659 if (isp_find_pdb_by_sid(isp, mp->nt_channel, mp->nt_sid, &lp)) { 2660 isp_del_wwn_entry(isp, mp->nt_channel, lp->port_wwn, lp->handle, lp->portid); 2661 return; 2662 } 2663 } |
2722 isp_prt(isp, ISP_LOGWARN, "Chan %d unable to find entry to delete N-port handle 0x%04x initiator WWN 0x%016llx Port ID 0x%06x", 2723 mp->nt_channel, mp->nt_nphdl, (unsigned long long) mp->nt_wwn, mp->nt_sid); | 2664 isp_prt(isp, ISP_LOGWARN, "Chan %d unable to find entry to delete WWPN 0x%016jx PortID 0x%06x handle 0x%x", 2665 mp->nt_channel, mp->nt_wwn, mp->nt_sid, mp->nt_nphdl); |
2724} 2725 2726void 2727isp_put_atio(ispsoftc_t *isp, at_entry_t *src, at_entry_t *dst) 2728{ 2729 int i; 2730 isp_put_hdr(isp, &src->at_header, &dst->at_header); 2731 ISP_IOXPUT_16(isp, src->at_reserved, &dst->at_reserved); --- 1197 unchanged lines hidden --- | 2666} 2667 2668void 2669isp_put_atio(ispsoftc_t *isp, at_entry_t *src, at_entry_t *dst) 2670{ 2671 int i; 2672 isp_put_hdr(isp, &src->at_header, &dst->at_header); 2673 ISP_IOXPUT_16(isp, src->at_reserved, &dst->at_reserved); --- 1197 unchanged lines hidden --- |