From owner-svn-src-head@freebsd.org Mon Jun 11 15:21:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BAC2100F889; Mon, 11 Jun 2018 15:21:32 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-lf0-x232.google.com (mail-lf0-x232.google.com [IPv6:2a00:1450:4010:c07::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 99F576AC0A; Mon, 11 Jun 2018 15:21:31 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-lf0-x232.google.com with SMTP id d24-v6so31123422lfa.8; Mon, 11 Jun 2018 08:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc; bh=cGcgU7Ehd3djoe1xVHpLszrcX8KRze5S2KcTCeG/56I=; b=hktI3weFLDXQUjE5EmBwo8wXqzgsoDq3eMAPJ0gB1UbdZtanct0CMXh34IQ7sFo9L+ M3Lqfn78IJFpCvjna8Nf1YyrIeVVzPmXp37heEYH7+gXbZprsK2cri1WtDG+jjhcGCEp UHgeqSh53G/h2rXI2yKfPI8YbpMg/zru8jH3ryvqhO+hxX7LqW89qoy+iCaRMHqxKm7U 1tfS+tLj9qDMe4/JG3zLZgZ+j8Y/75cVbMbg++QhvPGEIE/HNkrcPfZQ3ETJ5O9mdMqe wYNafHMYuIk0bj1Vt53rysnkJLyGiLyuSvmmCMTMzYpVeQJJ1qyWs4bkYqOfKEYTXl6L bhCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=cGcgU7Ehd3djoe1xVHpLszrcX8KRze5S2KcTCeG/56I=; b=eey/F08MvQT5SxrAkbnIw+4DSVAsGOI1zD17BpSeCdDN/tw7u6p85PbFrgRaqWjgdG 95reM7XVwS0Em/jS57AS6Ep8lltpAAHh5lR6s8M5KjJBXjJSdX3aaqZHNfej9pBgaO/v 32lVy4/0iJhcaM9apoC/p7WFgkhPYOmRoAaP+vYrGyFYZPXHPDxQlg6QSV1wGJfJcYNq wrzC/X7nAV02PHqlfbPRQeAVCVKmXxWJ8qJzQddOW0J50TXdxubbT7zezHfqzTWez1uC 1624t27+YVSGdIixV63uN/iBqhERJBcaGrfbECgKl/tfJG/QyZgNqXZp5bWnAbyviazn r6nw== X-Gm-Message-State: APt69E3wL4TYZ1DWda4qnVIa0eE1IAJ4SW9X1kyIqWeoI4k53ZxUpIt8 ydFP6TIrcYzlcYmWj2GYls2IOmE1z8Rky79FgkE= X-Google-Smtp-Source: ADUXVKKsY7bUeq0lhHkeUpXQK741jUlyxWonY2xCopTEvDgm/2RlTIrX8XvffEw3eV9EIQmFPMD0xpriI9lWJtQ/RGA= X-Received: by 2002:a2e:5047:: with SMTP id v7-v6mr12801814ljd.122.1528730489505; Mon, 11 Jun 2018 08:21:29 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:1f94:0:0:0:0:0 with HTTP; Mon, 11 Jun 2018 08:21:28 -0700 (PDT) Reply-To: araujo@freebsd.org In-Reply-To: <2b5f4141-51c8-edfa-43ad-d55d52666e7b@FreeBSD.org> References: <201806110209.w5B29Lni010557@repo.freebsd.org> <2b5f4141-51c8-edfa-43ad-d55d52666e7b@FreeBSD.org> From: Marcelo Araujo Date: Mon, 11 Jun 2018 23:21:28 +0800 Message-ID: Subject: Re: svn commit: r334940 - head/usr.sbin/bhyve To: Pedro Giffuni Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 15:21:32 -0000 2018-06-11 22:46 GMT+08:00 Pedro Giffuni : > > > On 06/10/18 21:41, Marcelo Araujo wrote: > > > > 2018-06-11 10:25 GMT+08:00 Pedro Giffuni : > >> >> >> On 10/06/2018 21:09, Marcelo Araujo wrote: >> >>> Author: araujo >>> Date: Mon Jun 11 02:09:20 2018 >>> New Revision: 334940 >>> URL: https://svnweb.freebsd.org/changeset/base/334940 >>> >>> Log: >>> - Add bhyve virtio-scsi storage backend support. >>> Example of configuration: >>> ctl.conf: >>> portal-group pg0 { >>> discovery-auth-group no-authentication >>> listen 0.0.0.0 >>> listen [::] >>> } >>> target iqn.2012-06.com.example:target0 { >>> auth-group no-authentication >>> portal-group pg0 >>> port ioctl/5/3 >>> lun 0 { >>> path /z/test.img >>> size 8G >>> } >>> lun 1 { >>> path /z/test1.img >>> size 8G >>> } >>> } >>> bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 >>> From inside guest: >>> root@:~ # zpool status test >>> pool: test >>> state: ONLINE >>> scan: none requested >>> config: >>> NAME STATE READ WRITE CKSUM >>> test ONLINE 0 0 0 >>> da0 ONLINE 0 0 0 >>> da1 ONLINE 0 0 0 >>> dmesg: >>> da0 at vtscsi0 bus 0 scbus0 target 0 lun 0 >>> da0: Fixed Direct Access SPC-5 SCSI device >>> da0: Serial Number MYSERIAL0000 >>> da0: 300.000MB/s transfers >>> da0: Command Queueing enabled >>> da0: 8192MB (16777216 512 byte sectors) >>> da1 at vtscsi0 bus 0 scbus0 target 0 lun 1 >>> da1: Fixed Direct Access SPC-5 SCSI device >>> da1: Serial Number MYSERIAL0001 >>> da1: 300.000MB/s transfers >>> da1: Command Queueing enabled >>> da1: 8192MB (16777216 512 byte sectors) >>> Discussed with: grehan >>> Reviewed by: mav >>> Obtained from: TrueOS >>> Relnotes: Yes >>> Sponsored by: iXsystems Inc. >>> Tested with: FreeBSD HEAD, Fedora 28 (Workstation) and >>> Ubuntu 18.04. >>> Differential Revision: https://reviews.freebsd.org/D15276 >>> >>> Added: >>> head/usr.sbin/bhyve/iov.c (contents, props changed) >>> head/usr.sbin/bhyve/iov.h (contents, props changed) >>> head/usr.sbin/bhyve/pci_virtio_scsi.c (contents, props changed) >>> Modified: >>> head/usr.sbin/bhyve/Makefile >>> head/usr.sbin/bhyve/bhyve.8 >>> head/usr.sbin/bhyve/virtio.h >>> >>> ... >>> >> >> Added: head/usr.sbin/bhyve/pci_virtio_scsi.c >>> ============================================================ >>> ================== >>> --- /dev/null 00:00:00 1970 (empty, because file is newly added) >>> +++ head/usr.sbin/bhyve/pci_virtio_scsi.c Mon Jun 11 02:09:20 >>> 2018 (r334940) >>> @@ -0,0 +1,718 @@ >>> +/*- >>> + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD >>> + * >>> + * Copyright (c) 2016 Jakub Klama >>> . >>> + * Copyright (c) 2018 Marcelo Araujo >>> . >>> + * All rights reserved. >>> + * >>> + * Redistribution and use in source and binary forms, with or without >>> + * modification, are permitted provided that the following conditions >>> + * are met: >>> + * 1. Redistributions of source code must retain the above copyright >>> + * notice, this list of conditions and the following disclaimer >>> + * in this position and unchanged. >>> + * 2. Redistributions in binary form must reproduce the above copyright >>> + * notice, this list of conditions and the following disclaimer in >>> the >>> + * documentation and/or other materials provided with the >>> distribution. >>> + * >>> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' >>> AND >>> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >>> PURPOSE >>> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE >>> LIABLE >>> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >>> CONSEQUENTIAL >>> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE >>> GOODS >>> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >>> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, >>> STRICT >>> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN >>> ANY WAY >>> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY >>> OF >>> + * SUCH DAMAGE. >>> + */ >>> + >>> +#include >>> +__FBSDID("$FreeBSD$"); >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "bhyverun.h" >>> +#include "pci_emul.h" >>> +#include "virtio.h" >>> +#include "iov.h" >>> + >>> +#define VTSCSI_RINGSZ 64 >>> +#define VTSCSI_REQUESTQ 1 >>> +#define VTSCSI_THR_PER_Q 16 >>> +#define VTSCSI_MAXQ (VTSCSI_REQUESTQ + 2) >>> +#define VTSCSI_MAXSEG 64 >>> + >>> +#define VTSCSI_IN_HEADER_LEN(_sc) \ >>> + (sizeof(struct pci_vtscsi_req_cmd_rd) + _sc->vss_config.cdb_size) >>> + >>> +#define VTSCSI_OUT_HEADER_LEN(_sc) \ >>> + (sizeof(struct pci_vtscsi_req_cmd_wr) + >>> _sc->vss_config.sense_size) >>> + >>> +#define VIRTIO_SCSI_MAX_CHANNEL 0 >>> +#define VIRTIO_SCSI_MAX_TARGET 0 >>> +#define VIRTIO_SCSI_MAX_LUN 16383 >>> + >>> +#define VIRTIO_SCSI_F_INOUT (1 << 0) >>> +#define VIRTIO_SCSI_F_HOTPLUG (1 << 1) >>> +#define VIRTIO_SCSI_F_CHANGE (1 << 2) >>> + >>> >> TABS missing inconsistently after #define above ... >> >> >> +static int pci_vtscsi_debug = 0; >>> +#define DPRINTF(params) if (pci_vtscsi_debug) printf params >>> +#define WPRINTF(params) printf params >>> + >>> +struct pci_vtscsi_config { >>> + uint32_t num_queues; >>> + uint32_t seg_max; >>> + uint32_t max_sectors; >>> + uint32_t cmd_per_lun; >>> + uint32_t event_info_size; >>> + uint32_t sense_size; >>> + uint32_t cdb_size; >>> + uint16_t max_channel; >>> + uint16_t max_target; >>> + uint32_t max_lun; >>> +} __attribute__((packed)); >>> + >>> +struct pci_vtscsi_queue { >>> + struct pci_vtscsi_softc * vsq_sc; >>> + struct vqueue_info * vsq_vq; >>> + int vsq_ctl_fd; >>> + pthread_mutex_t vsq_mtx; >>> + pthread_mutex_t vsq_qmtx; >>> + pthread_cond_t vsq_cv; >>> + STAILQ_HEAD(, pci_vtscsi_request) vsq_requests; >>> + LIST_HEAD(, pci_vtscsi_worker) vsq_workers; >>> +}; >>> + >>> +struct pci_vtscsi_worker { >>> + struct pci_vtscsi_queue * vsw_queue; >>> + pthread_t vsw_thread; >>> + bool vsw_exiting; >>> + LIST_ENTRY(pci_vtscsi_worker) vsw_link; >>> +}; >>> + >>> +struct pci_vtscsi_request { >>> + struct pci_vtscsi_queue * vsr_queue; >>> + struct iovec vsr_iov_in[VTSCSI_MAXSEG]; >>> + int vsr_niov_in; >>> + struct iovec vsr_iov_out[VTSCSI_MAXSEG]; >>> + int vsr_niov_out; >>> + uint32_t vsr_idx; >>> + STAILQ_ENTRY(pci_vtscsi_request) vsr_link; >>> +}; >>> + >>> +/* >>> + * Per-device softc >>> + */ >>> +struct pci_vtscsi_softc { >>> + struct virtio_softc vss_vs; >>> + struct vqueue_info vss_vq[VTSCSI_MAXQ]; >>> + struct pci_vtscsi_queue vss_queues[VTSCSI_REQUESTQ]; >>> + pthread_mutex_t vss_mtx; >>> + int vss_iid; >>> + int vss_ctl_fd; >>> + uint32_t vss_features; >>> + struct pci_vtscsi_config vss_config; >>> +}; >>> + >>> +#define VIRTIO_SCSI_T_TMF 0 >>> +#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0 >>> +#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1 >>> +#define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2 >>> +#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3 >>> +#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4 >>> +#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5 >>> +#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6 >>> +#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7 >>> + >>> +/* command-specific response values */ >>> +#define VIRTIO_SCSI_S_FUNCTION_COMPLETE 0 >>> +#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10 >>> +#define VIRTIO_SCSI_S_FUNCTION_REJECTED 11 >>> + >>> >> and here above ... >> >> >> +struct pci_vtscsi_ctrl_tmf { >>> + uint32_t type; >>> + uint32_t subtype; >>> + uint8_t lun[8]; >>> + uint64_t id; >>> + uint8_t response; >>> +} __attribute__((packed)); >>> + >>> +#define VIRTIO_SCSI_T_AN_QUERY 1 >>> +#define VIRTIO_SCSI_EVT_ASYNC_OPERATIONAL_CHANGE 2 >>> +#define VIRTIO_SCSI_EVT_ASYNC_POWER_MGMT 4 >>> +#define VIRTIO_SCSI_EVT_ASYNC_EXTERNAL_REQUEST 8 >>> +#define VIRTIO_SCSI_EVT_ASYNC_MEDIA_CHANGE 16 >>> +#define VIRTIO_SCSI_EVT_ASYNC_MULTI_HOST 32 >>> +#define VIRTIO_SCSI_EVT_ASYNC_DEVICE_BUSY 64 >>> + >>> +struct pci_vtscsi_ctrl_an { >>> + uint32_t type; >>> + uint8_t lun[8]; >>> + uint32_t event_requested; >>> + uint32_t event_actual; >>> + uint8_t response; >>> +} __attribute__((packed)); >>> + >>> +/* command-specific response values */ >>> +#define VIRTIO_SCSI_S_OK 0 >>> +#define VIRTIO_SCSI_S_OVERRUN 1 >>> +#define VIRTIO_SCSI_S_ABORTED 2 >>> +#define VIRTIO_SCSI_S_BAD_TARGET 3 >>> +#define VIRTIO_SCSI_S_RESET 4 >>> +#define VIRTIO_SCSI_S_BUSY 5 >>> +#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6 >>> +#define VIRTIO_SCSI_S_TARGET_FAILURE 7 >>> +#define VIRTIO_SCSI_S_NEXUS_FAILURE 8 >>> +#define VIRTIO_SCSI_S_FAILURE 9 >>> +#define VIRTIO_SCSI_S_INCORRECT_LUN 12 >>> + >>> +/* task_attr */ >>> +#define VIRTIO_SCSI_S_SIMPLE 0 >>> +#define VIRTIO_SCSI_S_ORDERED 1 >>> +#define VIRTIO_SCSI_S_HEAD 2 >>> +#define VIRTIO_SCSI_S_ACA 3 >>> + >>> >> And here ... >> >> Pedro. >> >> _______________________________________________ >> svn-src-head@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/svn-src-head >> To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >> > > Hi Pedro, > > I think it is the email message that messed up with it. > I did check it again, usually I use 'vi' and also I checked here: > https://svnweb.freebsd.org/base/head/usr.sbin/bhyve/pci_ > virtio_scsi.c?view=markup&pathrev=334940 > > Seems everything is correct! Am I missing something? > > > > Fixed in r334950. > I have fixed my vimrc.. Thank you! > > Pedro. > > -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)