From owner-svn-src-stable-11@freebsd.org Fri Mar 24 07:02:53 2017 Return-Path: Delivered-To: svn-src-stable-11@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 3FC7ED1BB8D; Fri, 24 Mar 2017 07:02:53 +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 F11BD116B; Fri, 24 Mar 2017 07:02:52 +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 v2O72qNH057208; Fri, 24 Mar 2017 07:02:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O72q2H057207; Fri, 24 Mar 2017 07:02:52 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240702.v2O72q2H057207@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315890 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 07:02:53 -0000 Author: mav Date: Fri Mar 24 07:02:51 2017 New Revision: 315890 URL: https://svnweb.freebsd.org/changeset/base/315890 Log: MFC r315022: Request change of SIM target role only when it is different. Separate WWNs change into separate request to know what actually failed. Modified: stable/11/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:02:03 2017 (r315889) +++ stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:02:51 2017 (r315890) @@ -1503,18 +1503,14 @@ out: static void ctlfe_onoffline(void *arg, int online) { - struct ctlfe_softc *bus_softc; + struct ctlfe_softc *bus_softc = arg; union ccb *ccb; cam_status status; struct cam_path *path; - int set_wwnn; - - bus_softc = (struct ctlfe_softc *)arg; - - set_wwnn = 0; + int set_wwnn = 0; status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) { printf("%s: unable to create path!\n", __func__); return; @@ -1524,21 +1520,9 @@ ctlfe_onoffline(void *arg, int online) ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; xpt_action(ccb); - /* - * Copan WWN format: - * - * Bits 63-60: 0x5 NAA, IEEE registered name - * Bits 59-36: 0x000ED5 IEEE Company name assigned to Copan - * Bits 35-12: Copan SSN (Sequential Serial Number) - * Bits 11-8: Type of port: - * 1 == N-Port - * 2 == F-Port - * 3 == NL-Port - * Bits 7-0: 0 == Node Name, >0 == Port Number - */ + /* Check whether we should change WWNs. */ if (online != 0) { if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ - printf("%s: %s current WWNN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwnn); @@ -1571,43 +1555,59 @@ ctlfe_onoffline(void *arg, int online) false, 0, true, ccb->knob.xport_specific.fc.wwpn); } - - - if (set_wwnn != 0) { - printf("%s: %s new WWNN %#jx\n", __func__, - bus_softc->port_name, - ccb->knob.xport_specific.fc.wwnn); - printf("%s: %s new WWPN %#jx\n", __func__, - bus_softc->port_name, - ccb->knob.xport_specific.fc.wwpn); - } } else { printf("%s: %s has no valid WWNN/WWPN\n", __func__, bus_softc->port_name); + if (bus_softc->port.wwnn != 0) { + ccb->knob.xport_specific.fc.wwnn = + bus_softc->port.wwnn; + set_wwnn = 1; + } + if (bus_softc->port.wwpn != 0) { + ccb->knob.xport_specific.fc.wwpn = + bus_softc->port.wwpn; + set_wwnn = 1; + } + } + } + if (set_wwnn) { + ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; + ccb->knob.xport_specific.valid = KNOB_VALID_ADDRESS; + xpt_action(ccb); + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + printf("%s: %s (path id %d) failed set WWNs: %#x\n", + __func__, bus_softc->port_name, bus_softc->path_id, + ccb->ccb_h.status); + } else { + printf("%s: %s new WWNN %#jx\n", __func__, + bus_softc->port_name, + ccb->knob.xport_specific.fc.wwnn); + printf("%s: %s new WWPN %#jx\n", __func__, + bus_softc->port_name, + ccb->knob.xport_specific.fc.wwpn); } } - ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; - ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; - if (set_wwnn != 0) - ccb->knob.xport_specific.valid |= KNOB_VALID_ADDRESS; - - if (online != 0) - ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; - else - ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; - - xpt_action(ccb); - if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - printf("%s: SIM %s (path id %d) target %s failed with " - "status %#x\n", - __func__, bus_softc->port_name, bus_softc->path_id, - (online != 0) ? "enable" : "disable", - ccb->ccb_h.status); - } else { - printf("%s: SIM %s (path id %d) target %s succeeded\n", - __func__, bus_softc->port_name, bus_softc->path_id, - (online != 0) ? "enable" : "disable"); + /* Check whether we should change role. */ + if ((ccb->knob.xport_specific.valid & KNOB_VALID_ROLE) == 0 || + ((online != 0) ^ + ((ccb->knob.xport_specific.fc.role & KNOB_ROLE_TARGET) != 0)) != 0) { + ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; + ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; + if (online) + ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; + else + ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; + xpt_action(ccb); + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + printf("%s: %s (path id %d) failed %s target role: %#x\n", + __func__, bus_softc->port_name, bus_softc->path_id, + online ? "enable" : "disable", ccb->ccb_h.status); + } else { + printf("%s: %s (path id %d) target role %s succeeded\n", + __func__, bus_softc->port_name, bus_softc->path_id, + online ? "enable" : "disable"); + } } xpt_free_path(path);