From owner-svn-src-all@freebsd.org Fri Mar 10 19:43:47 2017 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 16A99D0614D; Fri, 10 Mar 2017 19:43:47 +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 CB6591183; Fri, 10 Mar 2017 19:43:46 +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 v2AJhj3w012145; Fri, 10 Mar 2017 19:43:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2AJhj8T012144; Fri, 10 Mar 2017 19:43:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703101943.v2AJhj8T012144@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Mar 2017 19:43:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315022 - head/sys/cam/ctl X-SVN-Group: head 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.23 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: Fri, 10 Mar 2017 19:43:47 -0000 Author: mav Date: Fri Mar 10 19:43:45 2017 New Revision: 315022 URL: https://svnweb.freebsd.org/changeset/base/315022 Log: Request change of SIM target role only when it is different. Separate WWNs change into separate request to know what actually failed. MFC after: 2 weeks Modified: head/sys/cam/ctl/scsi_ctl.c Modified: head/sys/cam/ctl/scsi_ctl.c ============================================================================== --- head/sys/cam/ctl/scsi_ctl.c Fri Mar 10 19:34:14 2017 (r315021) +++ head/sys/cam/ctl/scsi_ctl.c Fri Mar 10 19:43:45 2017 (r315022) @@ -1492,18 +1492,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; @@ -1513,21 +1509,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); @@ -1560,43 +1544,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);