From nobody Sat Feb 18 18:15:47 2023 X-Original-To: freebsd-stable@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PJxgr3q53z3rMyP for ; Sat, 18 Feb 2023 18:15:52 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PJxgr3G9Zz4LVZ; Sat, 18 Feb 2023 18:15:52 +0000 (UTC) (envelope-from se@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676744152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iFpHBVLysGUaPwYro0CieOC+G83CCIqOF5wMfWeN9TU=; b=RrRUALxKtNvI5TzErIxwQZ1B0ghNSB31YHs8zt6MU8cTzey06i8VYGioQC/kT5IloCIV0j uAh/s+N1EPGafj0XzmcUmpx6wPShLe+1VfXgxW7XHSqCtHqJ3T4xQFzXc9xiAmMqVFyvNJ 5vJLA0C+JQzz5syaeASN4PHNxCJivN+EXfEwKcB+Vw8lQ0r0YMSXnRH/MGogMQYemcTMz7 sDUa3/qEV/0sP1LnUJzRgi6Xdv/ORYYJvxe0pR5PLwq5tQa5pCzjLEy2vHbCDOWJVWxsVq R17Nb4yCtLFAyHYs0a4xvwGTHJczWrOSPqcapAoeVdd+ZcKI9QHO5nESijA5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676744152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iFpHBVLysGUaPwYro0CieOC+G83CCIqOF5wMfWeN9TU=; b=QI5jNVrZqvM471Mag9ZB/jPlRqbKevs1GF/K4fIdMMkeik9KlB9j+UxgSr0viKxfGZsg3O 6Z+CuolN/WuwTyZMqo9tkfBITbVho7b5FGToFCUHUg9KDWvrd1DkflAzrTVbEBMxsnhG1K zOS7Y0RfpOnbH3Jgtvs2/1LDgy8wZ/WnhGbrWyG9naxHYhYzkWThxA17SN/jl5ab6Uzpm7 qUWVm9lCsrN2CxgoKhBLQGGZk1VNW6KWviJlQSfnZrY+tmA3XQrybJqXV5EuJ3XI9h5msA 48x5BSz2R4B4rpl6DFfslzcFs1Fy26M+0nKSV7ALBx2LPtinI9mse+H6iayp8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676744152; a=rsa-sha256; cv=none; b=WVenWC98+Op6joJpGbtd/7glVC6IO2aMtKCp96mT6Riqh4K2D43HzZHEkpzSD062w4KMmp nPwRYfDBLfiDVSiNFvIg5QJJjwmDKzThILHvPS6GIaNv6Z6tbaXRHPK55E4v0dnzq5JVQ/ 9hKnNBFFJphRjCuUW1DQ2mMlXEU+CO+mKUWTPyo4E+OP+uj7wByUnzaCeoXCLHPaqP0mfa /9jQRlyuJkDJLYCuDlPbWS6t4YqB0BvVfpM6hnpEdpDtmrkhV4RgjlvjkKvXXc7cWn0j0M tgehKsqd2DGZOGPt1b5ZjFDXm06/kKJEF1uKcCkD9yfRFUb7PcsdA5aeMNxkdQ== Received: from [IPV6:2003:cd:5f2a:1000:b0f6:dc65:6c83:f8a2] (p200300cd5f2a1000b0f6dc656c83f8a2.dip0.t-ipconnect.de [IPv6:2003:cd:5f2a:1000:b0f6:dc65:6c83:f8a2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PJxgq60m2zJ19; Sat, 18 Feb 2023 18:15:51 +0000 (UTC) (envelope-from se@FreeBSD.org) Message-ID: <5828616a-3239-dd16-0a88-b280fd0687b6@FreeBSD.org> Date: Sat, 18 Feb 2023 19:15:47 +0100 List-Id: Production branch of FreeBSD source code List-Archive: https://lists.freebsd.org/archives/freebsd-stable List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-stable@freebsd.org X-BeenThere: freebsd-stable@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 From: Stefan Esser Subject: Re: sym vs ncr driver for emulated LSI 53C895A Content-Language: de-DE To: Miroslav Lachman <000.fbsd@quip.cz> Cc: freebsd-stable References: <4caf465e-4514-6dbb-1a65-8a27b9b1537e@quip.cz> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ThisMailContainsUnwantedMimeParts: N Am 15.02.23 um 20:26 schrieb Miroslav Lachman: > On 10/02/2023 22:22, Stefan Esser wrote: >> Am 09.02.23 um 20:04 schrieb Miroslav Lachman: >>> I have FreeBSD 12.4 virtual machine installed inside KVM. This machine has 2 >>> disks. One is 30GB connected as VirtIO vtbd0. There is installed system. The >>> second is 20TB iSCSI connected to KVM and should be available inside VM as >>> SCSI disk da0 but it is not. >> >> This is an emulated SCSI controller in KVM instead of a physical >> controller on a PCI bus? > > As far as I know it is emulated by KVM. I search the net and found this for > example: > https://pve.proxmox.com/wiki/Qemu/KVM_Virtual_Machines#qm_hard_disk_bus > > "the SCSI controller, designed in 1985, is commonly found on server grade > hardware, and can connect up to 14 storage devices. Proxmox VE emulates by > default a LSI 53C895A controller. The issue with this emulation is that the 53c8xx family of devices is not an "intelligent" controller that gets a command written into some register and then executes the transfer, instead it is a very simple CPU that executes a limited and domain specific command set. The early NCR 53x8xx devices did not contain any indirect address modes, you had to store the address of a calculated memory access into the next instruction to fetch from a variable address (i.e. it depended on self modifying code). And if KVM emulates the NCR 53c895 (which btw. has indirect addressing modes), then any trivial operation requires the emulation of hundreds of simple NCR instructions, at a cost of thousands or tens of thousands CPU instructions. > A SCSI controller of type VirtIO SCSI is the recommended setting if you aim for > performance and is automatically selected for newly created Linux VMs since > Proxmox VE 4.3. Linux distributions have support for this controller since > 2012, and FreeBSD since 2014." If possible use VirtIO! These "virtual" devices are implemented in a way that makes them very efficient. The parameters of a request and the data to be transfered are just transfered to the hypervisor via shared memory areas, much like a system call into the kernel. >> The device emulation may be incomplete and may therefore violate >> assumptions made in the driver. The 53c8xx devices were complex >> and the driver contains a "firmware" blob that has to be executed >> using main CPU instructions by the emulated Symbios device. This >> is extremely inefficient compared to other emulstions (it takes >> hundreds of emulated controller instructions to execute trivial >> SCSI transfers). >> >> Why can't you use the iSCSI driver to connect to an iscsi device? > > Because my VM does not have access to network where the iSCSI target is (for > security reason) But VirtIO would be offered? >> Regarding the history of the ncr and sym drivers: >> >> I'm the co-author of the ncr driver, which originally supported only >> the NCR53c810 chip. Later additions of this device family added WIDE >> SCSI support and support for faster synchronous transfers, and their >> support was added to the ncr driver. > > [..] > >> The ncr driver has been removed from later FreeBSD releases, since sym >> covers all devices (since it is an extension of the ncr driver). > > Oh, thank you for the clarification, I thought ncr is newer than sym. So > building ncr into kernel does not have any sense. No, definitely not. The NCR driver used only the initial command set, without the indirect memory access modes offered by later NCR chips. >> The sym driver attached correctly, it should work. It has been more than >> 10 years since I last used the driver and had a machine with SCSI drives. >> >> In the meantime Marius Strobl made a few changes to the driver, but I do >> not know, whether he still has access to a system with that controller. >> >> The error messages: >> >>> (probe1:sym0:0:1:0): INQUIRY. CDB: 12 00 00 00 24 00 >>> (probe1:sym0:0:1:0): CAM status: Command timeout >>> (probe1:sym0:0:1:0): Retrying command, 3 more tries remain >>> sym0:1: message c sent on bad reselection. >>> sym0:1:control msgout: 80 6. >> >> The device should execute the INQUIRY command, but not reply was received >> (the device did not reselect the controlled). Several attempts are made, >> but the retries are exausted and the device is ignored. >> >> It seems that the selection/reselection and sending of SCSI messages is >> not perfectly emulated. >> >> You may want to contact the author of the 53c895a emulation, since you'll >> need debug output from that emulation in order to understand what's wrong. > > The administrator of KVM hypervisor changed some settings on the translation > layer iSCSI / LSI emul. / VirtIO. Even if he told me I do not understand it > well but now I see the disk correctly: > > # diskinfo -v da0 > da0 >         512             # sectorsize >         23747947921408  # mediasize in bytes (22T) >         46382710784     # mediasize in sectors >         0               # stripesize >         0               # stripeoffset >         2887190         # Cylinders according to firmware. >         255             # Heads according to firmware. >         63              # Sectors according to firmware. >         QNAP iSCSI Storage      # Disk descr. >         194d2dd6-683a-42e1-9985-acd5580b119d    # Disk ident. >         vtscsi0         # Attachment >         No              # TRIM/UNMAP support >         Unknown         # Rotation rate in RPM >         Not_Zoned       # Zone Mode > > > # pciconf -l -v > > sym0@pci0:0:7:0:        class=0x010000 rev=0x00 hdr=0x00 vendor=0x1000 > device=0x0012 subvendor=0x0000 subdevice=0x1000 >     vendor     = 'Broadcom / LSI' >     device     = '53c895a' >     class      = mass storage >     subclass   = SCSI > virtio_pci2@pci0:0:8:0: class=0x010000 rev=0x00 hdr=0x00 vendor=0x1af4 > device=0x1004 subvendor=0x1af4 subdevice=0x0008 >     vendor     = 'Red Hat, Inc.' >     device     = 'Virtio SCSI' >     class      = mass storage >     subclass   = SCSI Yes, that's the device you want to use! > virtio_pci3@pci0:0:9:0: class=0x010000 rev=0x00 hdr=0x00 vendor=0x1af4 > device=0x1001 subvendor=0x1af4 subdevice=0x0002 >     vendor     = 'Red Hat, Inc.' >     device     = 'Virtio block device' >     class      = mass storage >     subclass   = SCSI > > virtio_pci0: port 0xc100-0xc17f mem > 0xfc0b5000-0xfc0b5fff, 0xfebf0000-0xfebf3fff irq 10 at device 5.0 on pci0 > vtblk0: on virtio_pci0 > vtblk0: 30720MB (62914560 512 byte sectors) > virtio_pci1: port 0xc240-0xc27f mem > 0xfebf4000-0xfebf7fff irq 10 at device 6.0 on pci0 > vtballoon0: on virtio_pci1 > sym0: <895a> port 0xc000-0xc0ff mem 0xfc0b6000-0xfc0b63ff,0xfc0b2000-0xfc0b3fff > irq 11 at device 7.0 on pci0 > sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking > virtio_pci2: port 0xc280-0xc2bf mem > 0xfc0b7000-0xfc0b7fff,0xfebf8000-0xfebfbfff irq 11 at device 8.0 on pci0 > vtscsi0: on virtio_pci2 > virtio_pci3: port 0xc180-0xc1ff mem > 0xfc0b8000-0xfc0b8fff,0xfebfc000-0xfebfffff irq 10 at device 9.0 on pci0 > vtblk1: on virtio_pci3 > vtblk1: 102400MB (209715200 512 byte sectors) > > da0 at vtscsi0 bus 0 scbus3 target 0 lun 0 > da0: Fixed Direct Access SPC-3 SCSI device > da0: Serial Number 194d2dd6-683a-42e1-9985-acd5580b119d > da0: 300.000MB/s transfers > da0: Command Queueing enabled > da0: 22647808MB (46382710784 512 byte sectors) > > So I assume the iSCSI device is now connected as VirtIO SCSI device on vtscsi0 > / virtio_pci2. Yes, "da0 at vtscsi0" is exactly what you wanted ... You can remove the sym driver from your kernel or disable it. It will only consume (some) memory, but is of no use in your VM. > The important thing is that it works! And it does not only work this way - this is the most efficient way to connect to a device offered by the hypervisor. > I greatly appreciated your insightful reply and of course your work on ncr / sym. Thanks, and I'm glad my knowledge about this long obsolete (for lack of physical PCI slots in current systems, and due to the limit of at most 40 MB/s of the fastest parallel SCSI transfer mode) was still of use ... Regards, STefan