From e2a658cb0c04b0d1cbc17777e6a8fdae5627c904 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 19 Mar 2017 10:28:04 +0000 Subject: [PATCH] Move <= 23xx PDB workaround to generic code. It is chip-specific and has nothing to do with platform. MFC after: 2 weeks --- sys/dev/isp/isp_freebsd.c | 23 ++++++++--------------- sys/dev/isp/isp_target.c | 24 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index ae210cc8e2c0..abdc27691133 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -1743,22 +1743,15 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep) if (IS_2100(isp)) atiop->init_id = nphdl; else { - if ((isp_find_pdb_by_handle(isp, 0, nphdl, &lp) == 0 || - lp->state == FC_PORTDB_STATE_ZOMBIE)) { - uint64_t wwpn = - (((uint64_t) aep->at_wwpn[0]) << 48) | - (((uint64_t) aep->at_wwpn[1]) << 32) | - (((uint64_t) aep->at_wwpn[2]) << 16) | - (((uint64_t) aep->at_wwpn[3]) << 0); - isp_add_wwn_entry(isp, 0, wwpn, INI_NONE, - nphdl, PORT_ANY, 0); - if (fcp->isp_loopstate > LOOP_LTEST_DONE) - fcp->isp_loopstate = LOOP_LTEST_DONE; - isp_async(isp, ISPASYNC_CHANGE_NOTIFY, 0, - ISPASYNC_CHANGE_PDB, nphdl, 0x06, 0xff); - isp_find_pdb_by_handle(isp, 0, nphdl, &lp); + if (isp_find_pdb_by_handle(isp, 0, nphdl, &lp)) { + atiop->init_id = FC_PORTDB_TGT(isp, 0, lp); + } else { + isp_prt(isp, ISP_LOGTINFO, "%s: port %x isn't in PDB", + __func__, nphdl); + isp_dump_portdb(isp, 0); + isp_endcmd(isp, aep, NIL_HANDLE, 0, ECMD_TERMINATE, 0); + return; } - atiop->init_id = FC_PORTDB_TGT(isp, 0, lp); } atiop->cdb_len = ATIO2_CDBLEN; ISP_MEMCPY(atiop->cdb_io.cdb_bytes, aep->at_cdb, ATIO2_CDBLEN); diff --git a/sys/dev/isp/isp_target.c b/sys/dev/isp/isp_target.c index 0d7ac3145335..ac65b12314dd 100644 --- a/sys/dev/isp/isp_target.c +++ b/sys/dev/isp/isp_target.c @@ -919,6 +919,7 @@ isp_handle_abts(ispsoftc_t *isp, abts_t *abts) static void isp_handle_atio2(ispsoftc_t *isp, at2_entry_t *aep) { + fcportdb_t *lp; int lun, iid; if (ISP_CAP_SCCFW(isp)) { @@ -975,9 +976,26 @@ isp_handle_atio2(ispsoftc_t *isp, at2_entry_t *aep) break; case AT_CDB: /* Got a CDB */ - /* - * Punt to platform specific layer. - */ + + /* Make sure we have this inititor in port database. */ + if (!IS_2100(isp) && + (isp_find_pdb_by_handle(isp, 0, iid, &lp) == 0 || + lp->state == FC_PORTDB_STATE_ZOMBIE)) { + fcparam *fcp = FCPARAM(isp, 0); + uint64_t wwpn = + (((uint64_t) aep->at_wwpn[0]) << 48) | + (((uint64_t) aep->at_wwpn[1]) << 32) | + (((uint64_t) aep->at_wwpn[2]) << 16) | + (((uint64_t) aep->at_wwpn[3]) << 0); + isp_add_wwn_entry(isp, 0, wwpn, INI_NONE, + iid, PORT_ANY, 0); + if (fcp->isp_loopstate > LOOP_LTEST_DONE) + fcp->isp_loopstate = LOOP_LTEST_DONE; + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, 0, + ISPASYNC_CHANGE_PDB, iid, 0x06, 0xff); + } + + /* Punt to platform specific layer. */ isp_async(isp, ISPASYNC_TARGET_ACTION, aep); break;