Date: Sun, 2 Jul 2017 14:59:42 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320574 - head/sys/dev/isp Message-ID: <201707021459.v62ExgV4053436@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sun Jul 2 14:59:41 2017 New Revision: 320574 URL: https://svnweb.freebsd.org/changeset/base/320574 Log: Slightly unify SNS requests for post- and pre-24xx. Modified: head/sys/dev/isp/isp.c head/sys/dev/isp/ispmbox.h Modified: head/sys/dev/isp/isp.c ============================================================================== --- head/sys/dev/isp/isp.c Sun Jul 2 11:48:07 2017 (r320573) +++ head/sys/dev/isp/isp.c Sun Jul 2 14:59:41 2017 (r320574) @@ -117,13 +117,11 @@ static uint64_t isp_get_wwn(ispsoftc_t *, int, int, in static int isp_fclink_test(ispsoftc_t *, int, int); static int isp_pdb_sync(ispsoftc_t *, int); static int isp_scan_loop(ispsoftc_t *, int); -static int isp_gid_ft_sns(ispsoftc_t *, int); -static int isp_gid_ft_ct_passthru(ispsoftc_t *, int); +static int isp_gid_ft(ispsoftc_t *, int); static int isp_scan_fabric(ispsoftc_t *, int); static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *); static int isp_send_change_request(ispsoftc_t *, int); static int isp_register_fc4_type(ispsoftc_t *, int); -static int isp_register_fc4_type_24xx(ispsoftc_t *, int); static int isp_register_fc4_features_24xx(ispsoftc_t *, int); static int isp_register_port_name_24xx(ispsoftc_t *, int); static int isp_register_node_name_24xx(ispsoftc_t *, int); @@ -3042,7 +3040,7 @@ isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay if (IS_24XX(isp)) { fcp->isp_fabric_params = mbs.param[7]; fcp->isp_sns_hdl = NPH_SNS_ID; - r = isp_register_fc4_type_24xx(isp, chan); + r = isp_register_fc4_type(isp, chan); if (fcp->isp_loopstate < LOOP_TESTING_LINK) goto abort; if (r != 0) @@ -3417,40 +3415,17 @@ abort: #define NGENT ((GIDLEN - 16) >> 2) static int -isp_gid_ft_sns(ispsoftc_t *isp, int chan) +isp_ct_sns(ispsoftc_t *isp, int chan, uint32_t cmd_bcnt, uint32_t rsp_bcnt) { - union { - sns_gid_ft_req_t _x; - uint8_t _y[SNS_GID_FT_REQ_SIZE]; - } un; fcparam *fcp = FCPARAM(isp, chan); - sns_gid_ft_req_t *rq = &un._x; - uint8_t *scp = fcp->isp_scratch; mbreg_t mbs; - isp_prt(isp, ISP_LOGDEBUG0, "Chan %d requesting GID_FT via SNS", chan); - if (FC_SCRATCH_ACQUIRE(isp, chan)) { - isp_prt(isp, ISP_LOGERR, sacq); - return (-1); - } + if (isp->isp_dblev & ISP_LOGDEBUG1) + isp_print_bytes(isp, "CT SNS request", cmd_bcnt, fcp->isp_scratch); + MEMORYBARRIER(isp, SYNC_SFORDEV, 0, cmd_bcnt, chan); - ISP_MEMZERO(rq, SNS_GID_FT_REQ_SIZE); - rq->snscb_rblen = GIDLEN >> 1; - rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma); - rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma); - rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma); - rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma); - rq->snscb_sblen = 6; - rq->snscb_cmd = SNS_GID_FT; - rq->snscb_mword_div_2 = NGENT; - rq->snscb_fc4_type = FC4_SCSI; - - isp_put_gid_ft_request(isp, rq, (sns_gid_ft_req_t *)scp); - MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE, chan); - MBSINIT(&mbs, MBOX_SEND_SNS, MBLOGALL, 10000000); - mbs.param[0] = MBOX_SEND_SNS; - mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1; + mbs.param[1] = cmd_bcnt >> 1; mbs.param[2] = DMA_WD1(fcp->isp_scdma); mbs.param[3] = DMA_WD0(fcp->isp_scdma); mbs.param[6] = DMA_WD3(fcp->isp_scdma); @@ -3463,12 +3438,10 @@ isp_gid_ft_sns(ispsoftc_t *isp, int chan) return (-1); } } - MEMORYBARRIER(isp, SYNC_SFORCPU, 0, GIDLEN, chan); + + MEMORYBARRIER(isp, SYNC_SFORCPU, 0, rsp_bcnt, chan); if (isp->isp_dblev & ISP_LOGDEBUG1) - isp_print_bytes(isp, "CT response", GIDLEN, scp); - isp_get_gid_ft_response(isp, (sns_gid_ft_rsp_t *)scp, - (sns_gid_ft_rsp_t *)fcp->isp_scanscratch, NGENT); - FC_SCRATCH_RELEASE(isp, chan); + isp_print_bytes(isp, "CT response", rsp_bcnt, fcp->isp_scratch); return (0); } @@ -3480,6 +3453,9 @@ isp_ct_passthru(ispsoftc_t *isp, int chan, uint32_t cm void *reqp; uint8_t resp[QENTRY_LEN]; + if (isp->isp_dblev & ISP_LOGDEBUG1) + isp_print_bytes(isp, "CT request", cmd_bcnt, fcp->isp_scratch); + /* * Build a Passthrough IOCB in memory. */ @@ -3538,47 +3514,63 @@ isp_ct_passthru(ispsoftc_t *isp, int chan, uint32_t cm return (-1); } + if (isp->isp_dblev & ISP_LOGDEBUG1) + isp_print_bytes(isp, "CT response", rsp_bcnt, fcp->isp_scratch); + return (0); } static int -isp_gid_ft_ct_passthru(ispsoftc_t *isp, int chan) +isp_gid_ft(ispsoftc_t *isp, int chan) { fcparam *fcp = FCPARAM(isp, chan); ct_hdr_t ct; + sns_gid_ft_req_t rq; uint32_t *rp; uint8_t *scp = fcp->isp_scratch; - isp_prt(isp, ISP_LOGDEBUG0, "Chan %d requesting GID_FT via CT", chan); + isp_prt(isp, ISP_LOGDEBUG0, "Chan %d requesting GID_FT", chan); if (FC_SCRATCH_ACQUIRE(isp, chan)) { isp_prt(isp, ISP_LOGERR, sacq); return (-1); } - /* - * Build the CT header and command in memory. - */ - ISP_MEMZERO(&ct, sizeof (ct)); - ct.ct_revision = CT_REVISION; - ct.ct_fcs_type = CT_FC_TYPE_FC; - ct.ct_fcs_subtype = CT_FC_SUBTYPE_NS; - ct.ct_cmd_resp = SNS_GID_FT; - ct.ct_bcnt_resid = (GIDLEN - 16) >> 2; - isp_put_ct_hdr(isp, &ct, (ct_hdr_t *)scp); - rp = (uint32_t *) &scp[sizeof(ct)]; - ISP_IOZPUT_32(isp, FC4_SCSI, rp); - if (isp->isp_dblev & ISP_LOGDEBUG1) { - isp_print_bytes(isp, "CT request", - sizeof(ct) + sizeof(uint32_t), scp); - } + if (IS_24XX(isp)) { + /* Build the CT command and execute via pass-through. */ + ISP_MEMZERO(&ct, sizeof (ct)); + ct.ct_revision = CT_REVISION; + ct.ct_fcs_type = CT_FC_TYPE_FC; + ct.ct_fcs_subtype = CT_FC_SUBTYPE_NS; + ct.ct_cmd_resp = SNS_GID_FT; + ct.ct_bcnt_resid = (GIDLEN - 16) >> 2; + isp_put_ct_hdr(isp, &ct, (ct_hdr_t *)scp); + rp = (uint32_t *) &scp[sizeof(ct)]; + ISP_IOZPUT_32(isp, FC4_SCSI, rp); - if (isp_ct_passthru(isp, chan, sizeof(ct) + sizeof(uint32_t), GIDLEN)) { - FC_SCRATCH_RELEASE(isp, chan); - return (-1); + if (isp_ct_passthru(isp, chan, sizeof(ct) + sizeof(uint32_t), GIDLEN)) { + FC_SCRATCH_RELEASE(isp, chan); + return (-1); + } + } else { + /* Build the SNS request and execute via firmware. */ + ISP_MEMZERO(&rq, SNS_GID_FT_REQ_SIZE); + rq.snscb_rblen = GIDLEN >> 1; + rq.snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma); + rq.snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma); + rq.snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma); + rq.snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma); + rq.snscb_sblen = 6; + rq.snscb_cmd = SNS_GID_FT; + rq.snscb_mword_div_2 = NGENT; + rq.snscb_fc4_type = FC4_SCSI; + isp_put_gid_ft_request(isp, &rq, (sns_gid_ft_req_t *)scp); + + if (isp_ct_sns(isp, chan, sizeof(rq), NGENT)) { + FC_SCRATCH_RELEASE(isp, chan); + return (-1); + } } - if (isp->isp_dblev & ISP_LOGDEBUG1) - isp_print_bytes(isp, "CT response", GIDLEN, scp); isp_get_gid_ft_response(isp, (sns_gid_ft_rsp_t *)scp, (sns_gid_ft_rsp_t *)fcp->isp_scanscratch, NGENT); FC_SCRATCH_RELEASE(isp, chan); @@ -3635,10 +3627,7 @@ fail: } /* Get list of port IDs from SNS. */ - if (IS_24XX(isp)) - r = isp_gid_ft_ct_passthru(isp, chan); - else - r = isp_gid_ft_sns(isp, chan); + r = isp_gid_ft(isp, chan); if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) goto abort; if (r > 0) { @@ -3918,50 +3907,10 @@ static int isp_register_fc4_type(ispsoftc_t *isp, int chan) { fcparam *fcp = FCPARAM(isp, chan); + rft_id_t rp; + ct_hdr_t *ct = &rp.rftid_hdr; uint8_t local[SNS_RFT_ID_REQ_SIZE]; sns_screq_t *reqp = (sns_screq_t *) local; - mbreg_t mbs; - - ISP_MEMZERO((void *) reqp, SNS_RFT_ID_REQ_SIZE); - reqp->snscb_rblen = SNS_RFT_ID_RESP_SIZE >> 1; - reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100); - reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100); - reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100); - reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100); - reqp->snscb_sblen = 22; - reqp->snscb_data[0] = SNS_RFT_ID; - reqp->snscb_data[4] = fcp->isp_portid & 0xffff; - reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff; - reqp->snscb_data[6] = (1 << FC4_SCSI); - if (FC_SCRATCH_ACQUIRE(isp, chan)) { - isp_prt(isp, ISP_LOGERR, sacq); - return (-1); - } - isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch); - MBSINIT(&mbs, MBOX_SEND_SNS, MBLOGALL, 1000000); - mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1; - mbs.param[2] = DMA_WD1(fcp->isp_scdma); - mbs.param[3] = DMA_WD0(fcp->isp_scdma); - mbs.param[6] = DMA_WD3(fcp->isp_scdma); - mbs.param[7] = DMA_WD2(fcp->isp_scdma); - MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_RFT_ID_REQ_SIZE, chan); - isp_mboxcmd(isp, &mbs); - FC_SCRATCH_RELEASE(isp, chan); - if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { - return (0); - } else { - isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", - chan, mbs.param[0]); - return (-1); - } -} - -static int -isp_register_fc4_type_24xx(ispsoftc_t *isp, int chan) -{ - fcparam *fcp = FCPARAM(isp, chan); - ct_hdr_t *ct; - rft_id_t rp; uint8_t *scp = fcp->isp_scratch; if (FC_SCRATCH_ACQUIRE(isp, chan)) { @@ -3969,27 +3918,43 @@ isp_register_fc4_type_24xx(ispsoftc_t *isp, int chan) return (-1); } - /* - * Build the CT header and command in memory. - */ - ISP_MEMZERO(&rp, sizeof(rp)); - ct = &rp.rftid_hdr; - ct->ct_revision = CT_REVISION; - ct->ct_fcs_type = CT_FC_TYPE_FC; - ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS; - ct->ct_cmd_resp = SNS_RFT_ID; - ct->ct_bcnt_resid = (sizeof (rft_id_t) - sizeof (ct_hdr_t)) >> 2; - rp.rftid_portid[0] = fcp->isp_portid >> 16; - rp.rftid_portid[1] = fcp->isp_portid >> 8; - rp.rftid_portid[2] = fcp->isp_portid; - rp.rftid_fc4types[FC4_SCSI >> 5] = 1 << (FC4_SCSI & 0x1f); - isp_put_rft_id(isp, &rp, (rft_id_t *)scp); - if (isp->isp_dblev & ISP_LOGDEBUG1) - isp_print_bytes(isp, "CT request", sizeof(rft_id_t), scp); + if (IS_24XX(isp)) { + /* Build the CT command and execute via pass-through. */ + ISP_MEMZERO(&rp, sizeof(rp)); + ct->ct_revision = CT_REVISION; + ct->ct_fcs_type = CT_FC_TYPE_FC; + ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS; + ct->ct_cmd_resp = SNS_RFT_ID; + ct->ct_bcnt_resid = (sizeof (rft_id_t) - sizeof (ct_hdr_t)) >> 2; + rp.rftid_portid[0] = fcp->isp_portid >> 16; + rp.rftid_portid[1] = fcp->isp_portid >> 8; + rp.rftid_portid[2] = fcp->isp_portid; + rp.rftid_fc4types[FC4_SCSI >> 5] = 1 << (FC4_SCSI & 0x1f); + isp_put_rft_id(isp, &rp, (rft_id_t *)scp); - if (isp_ct_passthru(isp, chan, sizeof(rft_id_t), sizeof(ct_hdr_t))) { - FC_SCRATCH_RELEASE(isp, chan); - return (-1); + if (isp_ct_passthru(isp, chan, sizeof(rft_id_t), sizeof(ct_hdr_t))) { + FC_SCRATCH_RELEASE(isp, chan); + return (-1); + } + } else { + /* Build the SNS request and execute via firmware. */ + ISP_MEMZERO((void *) reqp, SNS_RFT_ID_REQ_SIZE); + reqp->snscb_rblen = sizeof (ct_hdr_t) >> 1; + reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma); + reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma); + reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma); + reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma); + reqp->snscb_sblen = 22; + reqp->snscb_data[0] = SNS_RFT_ID; + reqp->snscb_data[4] = fcp->isp_portid & 0xffff; + reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff; + reqp->snscb_data[6] = (1 << FC4_SCSI); + isp_put_sns_request(isp, reqp, (sns_screq_t *)scp); + + if (isp_ct_sns(isp, chan, SNS_RFT_ID_REQ_SIZE, sizeof(ct_hdr_t))) { + FC_SCRATCH_RELEASE(isp, chan); + return (-1); + } } isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct); @@ -4105,8 +4070,6 @@ isp_register_port_name_24xx(ispsoftc_t *isp, int chan) len += rp.rspnid_length; ct->ct_bcnt_resid = (len - sizeof(ct_hdr_t)) >> 2; isp_put_rspn_id(isp, &rp, (rspn_id_t *)scp); - if (isp->isp_dblev & ISP_LOGDEBUG1) - isp_print_bytes(isp, "CT request", len, scp); if (isp_ct_passthru(isp, chan, len, sizeof(ct_hdr_t))) { FC_SCRATCH_RELEASE(isp, chan); @@ -4163,8 +4126,6 @@ isp_register_node_name_24xx(ispsoftc_t *isp, int chan) len += rp.rsnnnn_length; ct->ct_bcnt_resid = (len - sizeof(ct_hdr_t)) >> 2; isp_put_rsnn_nn(isp, &rp, (rsnn_nn_t *)scp); - if (isp->isp_dblev & ISP_LOGDEBUG1) - isp_print_bytes(isp, "CT request", len, scp); if (isp_ct_passthru(isp, chan, len, sizeof(ct_hdr_t))) { FC_SCRATCH_RELEASE(isp, chan); Modified: head/sys/dev/isp/ispmbox.h ============================================================================== --- head/sys/dev/isp/ispmbox.h Sun Jul 2 11:48:07 2017 (r320573) +++ head/sys/dev/isp/ispmbox.h Sun Jul 2 14:59:41 2017 (r320574) @@ -1553,6 +1553,7 @@ typedef struct { #define SNS_GNN_ID 0x113 #define SNS_GFF_ID 0x11F #define SNS_GID_FT 0x171 +#define SNS_GID_PT 0x1A1 #define SNS_RFT_ID 0x217 #define SNS_RSPN_ID 0x218 #define SNS_RFF_ID 0x21F @@ -1667,7 +1668,6 @@ typedef struct { } snscb_ports[1]; } sns_gid_ft_rsp_t; #define SNS_GID_FT_RESP_SIZE(x) ((sizeof (sns_gid_ft_rsp_t)) + ((x - 1) << 2)) -#define SNS_RFT_ID_RESP_SIZE (sizeof (ct_hdr_t)) /* * Other Misc Structures
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707021459.v62ExgV4053436>