From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:51:54 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 D96A9D19E4B; Thu, 23 Mar 2017 06:51:54 +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 9BDC91B03; Thu, 23 Mar 2017 06:51:54 +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 v2N6prX7058395; Thu, 23 Mar 2017 06:51:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6prbA058393; Thu, 23 Mar 2017 06:51:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230651.v2N6prbA058393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:51:53 +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: r315825 - stable/11/sys/dev/mpt 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: Thu, 23 Mar 2017 06:51:55 -0000 Author: mav Date: Thu Mar 23 06:51:53 2017 New Revision: 315825 URL: https://svnweb.freebsd.org/changeset/base/315825 Log: MFC r315004: Add PIM_EXTLUNS support to mpt(4). Target mode is still limited to 256 LUNs due to the way driver is written, but initiator can now use full 8 byte LUN space. Modified: stable/11/sys/dev/mpt/mpt_cam.c stable/11/sys/dev/mpt/mpt_debug.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:50:46 2017 (r315824) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:51:53 2017 (r315825) @@ -133,7 +133,7 @@ static void mpt_recovery_thread(void *ar static void mpt_recover_commands(struct mpt_softc *mpt); static int mpt_scsi_send_tmf(struct mpt_softc *, u_int, u_int, u_int, - u_int, u_int, u_int, int); + target_id_t, lun_id_t, u_int, int); static void mpt_fc_post_els(struct mpt_softc *mpt, request_t *, int); static void mpt_post_target_command(struct mpt_softc *, request_t *, int); @@ -2133,13 +2133,7 @@ mpt_start(struct cam_sim *sim, union ccb /* Which physical device to do the I/O on */ mpt_req->TargetID = tgt; - /* We assume a single level LUN type */ - if (ccb->ccb_h.target_lun >= MPT_MAX_LUNS) { - mpt_req->LUN[0] = 0x40 | ((ccb->ccb_h.target_lun >> 8) & 0x3f); - mpt_req->LUN[1] = ccb->ccb_h.target_lun & 0xff; - } else { - mpt_req->LUN[1] = ccb->ccb_h.target_lun; - } + be64enc(mpt_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun)); /* Set the direction of the transfer */ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { @@ -3585,7 +3579,8 @@ mpt_action(struct cam_sim *sim, union cc */ cpi->protocol = PROTO_SCSI; if (mpt->is_fc) { - cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; + cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 100000; cpi->hba_inquiry = PI_TAG_ABLE; cpi->transport = XPORT_FC; @@ -3597,14 +3592,16 @@ mpt_action(struct cam_sim *sim, union cc cpi->xport_specific.fc.bitrate = 100000 * mpt->mpt_fcport_speed; } else if (mpt->is_sas) { - cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; + cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 300000; cpi->hba_inquiry = PI_TAG_ABLE; cpi->transport = XPORT_SAS; cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC2; } else { - cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED; + cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 3300; cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; cpi->transport = XPORT_SPI; @@ -3913,7 +3910,8 @@ mpt_recovery_thread(void *arg) static int mpt_scsi_send_tmf(struct mpt_softc *mpt, u_int type, u_int flags, - u_int channel, u_int target, u_int lun, u_int abort_ctx, int sleep_ok) + u_int channel, target_id_t target, lun_id_t lun, u_int abort_ctx, + int sleep_ok) { MSG_SCSI_TASK_MGMT *tmf_req; int error; @@ -3941,12 +3939,7 @@ mpt_scsi_send_tmf(struct mpt_softc *mpt, tmf_req->MsgFlags = flags; tmf_req->MsgContext = htole32(mpt->tmf_req->index | scsi_tmf_handler_id); - if (lun > MPT_MAX_LUNS) { - tmf_req->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); - tmf_req->LUN[1] = lun & 0xff; - } else { - tmf_req->LUN[1] = lun; - } + be64enc(tmf_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); tmf_req->TaskMsgContext = abort_ctx; mpt_lprt(mpt, MPT_PRT_DEBUG, @@ -4413,13 +4406,7 @@ mpt_target_start_io(struct mpt_softc *mp ta->Function = MPI_FUNCTION_TARGET_ASSIST; ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); ta->ReplyWord = htole32(tgt->reply_desc); - if (csio->ccb_h.target_lun > MPT_MAX_LUNS) { - ta->LUN[0] = - 0x40 | ((csio->ccb_h.target_lun >> 8) & 0x3f); - ta->LUN[1] = csio->ccb_h.target_lun & 0xff; - } else { - ta->LUN[1] = csio->ccb_h.target_lun; - } + be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(csio->ccb_h.target_lun)); ta->RelativeOffset = tgt->bytes_xfered; ta->DataLength = ccb->csio.dxfer_len; @@ -4485,7 +4472,7 @@ mpt_target_start_io(struct mpt_softc *mp static void mpt_scsi_tgt_local(struct mpt_softc *mpt, request_t *cmd_req, - uint32_t lun, int send, uint8_t *data, size_t length) + lun_id_t lun, int send, uint8_t *data, size_t length) { mpt_tgt_state_t *tgt; PTR_MSG_TARGET_ASSIST_REQUEST ta; @@ -4525,12 +4512,7 @@ mpt_scsi_tgt_local(struct mpt_softc *mpt ta->Function = MPI_FUNCTION_TARGET_ASSIST; ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); ta->ReplyWord = htole32(tgt->reply_desc); - if (lun > MPT_MAX_LUNS) { - ta->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); - ta->LUN[1] = lun & 0xff; - } else { - ta->LUN[1] = lun; - } + be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); ta->RelativeOffset = 0; ta->DataLength = length; @@ -4958,21 +4940,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, itag = sp->Tag; } - /* - * Generate a simple lun - */ - switch (lunptr[0] & 0xc0) { - case 0x40: - lun = ((lunptr[0] & 0x3f) << 8) | lunptr[1]; - break; - case 0: - lun = lunptr[1]; - break; - default: - mpt_lprt(mpt, MPT_PRT_ERROR, "cannot handle this type lun\n"); - lun = 0xffff; - break; - } + lun = CAM_EXTLUN_BYTE_SWIZZLE(be64dec(lunptr)); /* * Deal with non-enabled or bad luns here. Modified: stable/11/sys/dev/mpt/mpt_debug.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_debug.c Thu Mar 23 06:50:46 2017 (r315824) +++ stable/11/sys/dev/mpt/mpt_debug.c Thu Mar 23 06:51:53 2017 (r315825) @@ -536,7 +536,7 @@ mpt_print_scsi_io_request(MSG_SCSI_IO_RE printf("\tBus: %d\n", msg->Bus); printf("\tTargetID %d\n", msg->TargetID); printf("\tSenseBufferLength %d\n", msg->SenseBufferLength); - printf("\tLUN: 0x%0x\n", msg->LUN[1]); + printf("\tLUN: 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tControl 0x%08x ", msg->Control); #define MPI_PRINT_FIELD(x) \ case MPI_SCSIIO_CONTROL_ ## x : \ @@ -585,7 +585,7 @@ mpt_print_scsi_tmf_request(MSG_SCSI_TASK { mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tTaskType %s\n", mpt_scsi_tm_type(msg->TaskType)); printf("\tTaskMsgContext 0x%08x\n", msg->TaskMsgContext); } @@ -600,7 +600,7 @@ mpt_print_scsi_target_assist_request(PTR printf("\tTargetAssist 0x%02x\n", msg->TargetAssistFlags); printf("\tQueueTag 0x%04x\n", msg->QueueTag); printf("\tReplyWord 0x%08x\n", msg->ReplyWord); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tRelativeOff 0x%08x\n", msg->RelativeOffset); printf("\tDataLength 0x%08x\n", msg->DataLength); mpt_dump_sgl(msg->SGL, 0); @@ -616,7 +616,7 @@ mpt_print_scsi_target_status_send_reques printf("\tStatusFlags 0x%02x\n", msg->StatusFlags); printf("\tQueueTag 0x%04x\n", msg->QueueTag); printf("\tReplyWord 0x%08x\n", msg->ReplyWord); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); x.u.Simple = msg->StatusDataSGE; mpt_dump_sgl(&x, 0); }