From owner-svn-src-head@freebsd.org Mon Jun 11 02:41:42 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 35DE91013F8A; Mon, 11 Jun 2018 02:41:42 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-lf0-x22e.google.com (mail-lf0-x22e.google.com [IPv6:2a00:1450:4010:c07::22e]) (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 87A9086DE0; Mon, 11 Jun 2018 02:41:41 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-lf0-x22e.google.com with SMTP id 36-v6so28149527lfr.11; Sun, 10 Jun 2018 19:41:41 -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=Nxho1elf8rARGXGLFo0xFdhtaAPVZyf7Vah8Rjqw/VA=; b=V+X2pKDYUvDp087Oxaf9iUv7iVz3y7aKg84CYWjGuzBXh07NO3LqenEZoQyLLEGXCZ WRQrc0DnRurFoeec/HSQ6cj28I/517zJi+STTQcaZ9OhwwAcbGwUzR9j4VP4MTTsAwfb Pv/Ke7R/o/GBBMY4z8kUdx8ISTj9Zx9r+Dstb7xmqwY+Jlwzb0phk2xN+a9TLbtdz+Hd 1b7+c78QMLLa7i/AAt0ocWfyr8n5lOr/ABImgMwDTbQDAZAIsLbCxkWtyRKcIX9gP1oK RKQgs10Ew0wtzcEdXIXtktaz5hzXgb6om6AJQh8fmaC0MBYoVuy125tczVz9K1sD4AUy RKaQ== 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=Nxho1elf8rARGXGLFo0xFdhtaAPVZyf7Vah8Rjqw/VA=; b=rF1XhFh78tWWzpe81BMIrpj9oucD9nyPtwmV/rvsywPseoTcTeSHkr3R7ZLc8QS6zp Lusmp6J9nwH/5Kgpe20+VXw6x1hfiF72UdtdVth/9CDWDKbEag6PIWXFxrPPhGdAvZWP QF5Jy5V/PpyDurlhXZNI7sH3nB0lvMul3hYj99HGE7sDOR8O9bDu72FLbZD1sCyzYbpH EfeXzaWFynbbAoNiRPXiG9R0KvulGV7RPS0hUi8vfoAh7MgdxuSgfi9xwgeYDsyQhrpV XJCiUIxUwjw7E5SmKHkx7wMvKRHyJQ/s+LBRrI1eNZtdZoykq6XpOT4fyYubMZz0C15d SjCA== X-Gm-Message-State: APt69E3IhDotA/4g70YWBElu+0PXslPWBfhuiYFnrEXKtgKQCZNcdBWn gY7x2xjD1oPclISBmYKAwgSb2xGexkj7wJk/7SIm/g== X-Google-Smtp-Source: ADUXVKLI+6VQELdXdAJkUcLpEBW3rbuzaz3DxarAK56Ilfh8QdpRp72Z4ebQkNTlj7exIxwWwRZc+w1kL0yKToTe7M8= X-Received: by 2002:a2e:808e:: with SMTP id i14-v6mr6782624ljg.85.1528684899954; Sun, 10 Jun 2018 19:41:39 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:1f94:0:0:0:0:0 with HTTP; Sun, 10 Jun 2018 19:41:39 -0700 (PDT) Reply-To: araujo@freebsd.org In-Reply-To: References: <201806110209.w5B29Lni010557@repo.freebsd.org> From: Marcelo Araujo Date: Mon, 11 Jun 2018 10:41:39 +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 02:41:42 -0000 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? Best, -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)