From owner-svn-src-all@freebsd.org Tue May 3 07:57:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5200AB2BAEA; Tue, 3 May 2016 07:57:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 10B341292; Tue, 3 May 2016 07:57:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u437vRjL041596; Tue, 3 May 2016 07:57:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u437vQML041590; Tue, 3 May 2016 07:57:26 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201605030757.u437vQML041590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 3 May 2016 07:57:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r298962 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2016 07:57:28 -0000 Author: mav Date: Tue May 3 07:57:26 2016 New Revision: 298962 URL: https://svnweb.freebsd.org/changeset/base/298962 Log: MFC r297751: Register symbolic port/node names in FC name server. This is cosmetics that simplifies identification of new ports on FC switch. It would be good to use target name from CTL here instead of hostname, but it is not passed here through CAM now. Modified: stable/10/sys/dev/isp/isp.c stable/10/sys/dev/isp/isp_freebsd.h stable/10/sys/dev/isp/isp_library.c stable/10/sys/dev/isp/isp_library.h stable/10/sys/dev/isp/isp_stds.h stable/10/sys/dev/isp/ispmbox.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Tue May 3 07:56:42 2016 (r298961) +++ stable/10/sys/dev/isp/isp.c Tue May 3 07:57:26 2016 (r298962) @@ -126,6 +126,8 @@ static int isp_send_change_request(ispso 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); static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *); static int isp_fw_state(ispsoftc_t *, int); static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int); @@ -3073,6 +3075,8 @@ isp_fclink_test(ispsoftc_t *isp, int cha r = isp_register_fc4_type_24xx(isp, chan); if (r == 0) isp_register_fc4_features_24xx(isp, chan); + isp_register_port_name_24xx(isp, chan); + isp_register_node_name_24xx(isp, chan); } else { fcp->isp_sns_hdl = SNS_ID; r = isp_register_fc4_type(isp, chan); @@ -3577,8 +3581,6 @@ isp_gid_ft_ct_passthru(ispsoftc_t *isp, /* * Build the CT header and command in memory. - * - * Note that the CT header has to end up as Big Endian format in memory. */ ISP_MEMZERO(&ct, sizeof (ct)); ct.ct_revision = CT_REVISION; @@ -3982,8 +3984,6 @@ isp_register_fc4_type_24xx(ispsoftc_t *i /* * Build the CT header and command in memory. - * - * Note that the CT header has to end up as Big Endian format in memory. */ ISP_MEMZERO(&rp, sizeof(rp)); ct = &rp.rftid_hdr; @@ -4034,8 +4034,6 @@ isp_register_fc4_features_24xx(ispsoftc_ /* * Build the CT header and command in memory. - * - * Note that the CT header has to end up as Big Endian format in memory. */ ISP_MEMZERO(&rp, sizeof(rp)); ct = &rp.rffid_hdr; @@ -4079,6 +4077,130 @@ isp_register_fc4_features_24xx(ispsoftc_ return (0); } +static int +isp_register_port_name_24xx(ispsoftc_t *isp, int chan) +{ + fcparam *fcp = FCPARAM(isp, chan); + ct_hdr_t *ct; + rspn_id_t rp; + uint8_t *scp = fcp->isp_scratch; + int len; + + if (FC_SCRATCH_ACQUIRE(isp, chan)) { + isp_prt(isp, ISP_LOGERR, sacq); + return (-1); + } + + /* + * Build the CT header and command in memory. + */ + ISP_MEMZERO(&rp, sizeof(rp)); + ct = &rp.rspnid_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_RSPN_ID; + rp.rspnid_portid[0] = fcp->isp_portid >> 16; + rp.rspnid_portid[1] = fcp->isp_portid >> 8; + rp.rspnid_portid[2] = fcp->isp_portid; + rp.rspnid_length = 0; + len = offsetof(rspn_id_t, rspnid_name); + mtx_lock(&prison0.pr_mtx); + rp.rspnid_length += sprintf(&scp[XTXOFF + len + rp.rspnid_length], + "%s", prison0.pr_hostname[0] ? prison0.pr_hostname : "FreeBSD"); + mtx_unlock(&prison0.pr_mtx); + rp.rspnid_length += sprintf(&scp[XTXOFF + len + rp.rspnid_length], + ":%s", device_get_nameunit(isp->isp_dev)); + if (chan != 0) { + rp.rspnid_length += sprintf(&scp[XTXOFF + len + + rp.rspnid_length], "/%d", 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[XTXOFF]); + if (isp->isp_dblev & ISP_LOGDEBUG1) + isp_print_bytes(isp, "CT request", len, &scp[XTXOFF]); + + if (isp_ct_passthru(isp, chan, len, sizeof(ct_hdr_t))) { + FC_SCRATCH_RELEASE(isp, chan); + return (-1); + } + + isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct); + FC_SCRATCH_RELEASE(isp, chan); + if (ct->ct_cmd_resp == LS_RJT) { + isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, + "Chan %d Register Symbolic Port Name rejected", chan); + return (-1); + } else if (ct->ct_cmd_resp == LS_ACC) { + isp_prt(isp, ISP_LOG_SANCFG, + "Chan %d Register Symbolic Port Name accepted", chan); + } else { + isp_prt(isp, ISP_LOGWARN, + "Chan %d Register Symbolic Port Name: 0x%x", chan, ct->ct_cmd_resp); + return (-1); + } + return (0); +} + +static int +isp_register_node_name_24xx(ispsoftc_t *isp, int chan) +{ + fcparam *fcp = FCPARAM(isp, chan); + ct_hdr_t *ct; + rsnn_nn_t rp; + uint8_t *scp = fcp->isp_scratch; + int len; + + if (FC_SCRATCH_ACQUIRE(isp, chan)) { + isp_prt(isp, ISP_LOGERR, sacq); + return (-1); + } + + /* + * Build the CT header and command in memory. + */ + ISP_MEMZERO(&rp, sizeof(rp)); + ct = &rp.rsnnnn_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_RSNN_NN; + MAKE_NODE_NAME_FROM_WWN(rp.rsnnnn_nodename, fcp->isp_wwnn); + rp.rsnnnn_length = 0; + len = offsetof(rsnn_nn_t, rsnnnn_name); + mtx_lock(&prison0.pr_mtx); + rp.rsnnnn_length += sprintf(&scp[XTXOFF + len + rp.rsnnnn_length], + "%s", prison0.pr_hostname[0] ? prison0.pr_hostname : "FreeBSD"); + mtx_unlock(&prison0.pr_mtx); + len += rp.rsnnnn_length; + ct->ct_bcnt_resid = (len - sizeof(ct_hdr_t)) >> 2; + isp_put_rsnn_nn(isp, &rp, (rsnn_nn_t *)&scp[XTXOFF]); + if (isp->isp_dblev & ISP_LOGDEBUG1) + isp_print_bytes(isp, "CT request", len, &scp[XTXOFF]); + + if (isp_ct_passthru(isp, chan, len, sizeof(ct_hdr_t))) { + FC_SCRATCH_RELEASE(isp, chan); + return (-1); + } + + isp_get_ct_hdr(isp, (ct_hdr_t *) scp, ct); + FC_SCRATCH_RELEASE(isp, chan); + if (ct->ct_cmd_resp == LS_RJT) { + isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, + "Chan %d Register Symbolic Node Name rejected", chan); + return (-1); + } else if (ct->ct_cmd_resp == LS_ACC) { + isp_prt(isp, ISP_LOG_SANCFG, + "Chan %d Register Symbolic Node Name accepted", chan); + } else { + isp_prt(isp, ISP_LOGWARN, + "Chan %d Register Symbolic Node Name: 0x%x", chan, ct->ct_cmd_resp); + return (-1); + } + return (0); +} + static uint16_t isp_next_handle(ispsoftc_t *isp, uint16_t *ohp) { Modified: stable/10/sys/dev/isp/isp_freebsd.h ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.h Tue May 3 07:56:42 2016 (r298961) +++ stable/10/sys/dev/isp/isp_freebsd.h Tue May 3 07:57:26 2016 (r298962) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include Modified: stable/10/sys/dev/isp/isp_library.c ============================================================================== --- stable/10/sys/dev/isp/isp_library.c Tue May 3 07:56:42 2016 (r298961) +++ stable/10/sys/dev/isp/isp_library.c Tue May 3 07:57:26 2016 (r298962) @@ -1988,6 +1988,17 @@ isp_put_rft_id(ispsoftc_t *isp, rft_id_t } void +isp_put_rspn_id(ispsoftc_t *isp, rspn_id_t *src, rspn_id_t *dst) +{ +/* int i;*/ + isp_put_ct_hdr(isp, &src->rspnid_hdr, &dst->rspnid_hdr); + ISP_IOZPUT_8(isp, src->rspnid_reserved, &dst->rspnid_reserved); + ISP_IOZPUT_8(isp, src->rspnid_length, &dst->rspnid_length); +/* for (i = 0; i < src->rspnid_length; i++) + ISP_IOZPUT_8(isp, src->rspnid_name[i], &dst->rspnid_name[i]);*/ +} + +void isp_put_rff_id(ispsoftc_t *isp, rff_id_t *src, rff_id_t *dst) { int i; @@ -2002,6 +2013,18 @@ isp_put_rff_id(ispsoftc_t *isp, rff_id_t } void +isp_put_rsnn_nn(ispsoftc_t *isp, rsnn_nn_t *src, rsnn_nn_t *dst) +{ + int i; + isp_put_ct_hdr(isp, &src->rsnnnn_hdr, &dst->rsnnnn_hdr); + for (i = 0; i < 8; i++) + ISP_IOZPUT_8(isp, src->rsnnnn_nodename[i], &dst->rsnnnn_nodename[i]); + ISP_IOZPUT_8(isp, src->rsnnnn_length, &dst->rsnnnn_length); +/* for (i = 0; i < src->rsnnnn_length; i++) + ISP_IOZPUT_8(isp, src->rsnnnn_name[i], &dst->rsnnnn_name[i]);*/ +} + +void isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *src, ct_hdr_t *dst) { ISP_IOZGET_8(isp, &src->ct_revision, dst->ct_revision); Modified: stable/10/sys/dev/isp/isp_library.h ============================================================================== --- stable/10/sys/dev/isp/isp_library.h Tue May 3 07:56:42 2016 (r298961) +++ stable/10/sys/dev/isp/isp_library.h Tue May 3 07:57:26 2016 (r298962) @@ -144,7 +144,9 @@ void isp_get_fc_hdr(ispsoftc_t *, fc_hdr void isp_put_fc_hdr(ispsoftc_t *, fc_hdr_t *, fc_hdr_t *); void isp_get_fcp_cmnd_iu(ispsoftc_t *, fcp_cmnd_iu_t *, fcp_cmnd_iu_t *); void isp_put_rft_id(ispsoftc_t *, rft_id_t *, rft_id_t *); +void isp_put_rspn_id(ispsoftc_t *, rspn_id_t *, rspn_id_t *); void isp_put_rff_id(ispsoftc_t *, rff_id_t *, rff_id_t *); +void isp_put_rsnn_nn(ispsoftc_t *, rsnn_nn_t *, rsnn_nn_t *); void isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *); void isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *); void isp_put_fcp_rsp_iu(ispsoftc_t *isp, fcp_rsp_iu_t *, fcp_rsp_iu_t *); Modified: stable/10/sys/dev/isp/isp_stds.h ============================================================================== --- stable/10/sys/dev/isp/isp_stds.h Tue May 3 07:56:42 2016 (r298961) +++ stable/10/sys/dev/isp/isp_stds.h Tue May 3 07:57:26 2016 (r298962) @@ -139,6 +139,19 @@ typedef struct { } rft_id_t; /* + * RSPN_ID Requet CT_IU + * + * Source: INCITS 463-2010 Generic Services 6 Section 5.2.5.32 + */ +typedef struct { + ct_hdr_t rspnid_hdr; + uint8_t rspnid_reserved; + uint8_t rspnid_portid[3]; + uint8_t rspnid_length; + uint8_t rspnid_name[0]; +} rspn_id_t; + +/* * RFF_ID Requet CT_IU * * Source: INCITS 463-2010 Generic Services 6 Section 5.2.5.34 @@ -153,6 +166,18 @@ typedef struct { } rff_id_t; /* + * RSNN_NN Requet CT_IU + * + * Source: INCITS 463-2010 Generic Services 6 Section 5.2.5.35 + */ +typedef struct { + ct_hdr_t rsnnnn_hdr; + uint8_t rsnnnn_nodename[8]; + uint8_t rsnnnn_length; + uint8_t rsnnnn_name[0]; +} rsnn_nn_t; + +/* * FCP Response IU and bits of interest * Source: NCITS T10, Project 1828D, Revision 02b (aka FCP4r02b) */ Modified: stable/10/sys/dev/isp/ispmbox.h ============================================================================== --- stable/10/sys/dev/isp/ispmbox.h Tue May 3 07:56:42 2016 (r298961) +++ stable/10/sys/dev/isp/ispmbox.h Tue May 3 07:57:26 2016 (r298962) @@ -1548,7 +1548,9 @@ typedef struct { #define SNS_GFF_ID 0x11F #define SNS_GID_FT 0x171 #define SNS_RFT_ID 0x217 +#define SNS_RSPN_ID 0x218 #define SNS_RFF_ID 0x21F +#define SNS_RSNN_NN 0x239 typedef struct { uint16_t snscb_rblen; /* response buffer length (words) */ uint16_t snscb_reserved0;