From owner-freebsd-scsi Fri Sep 6 09:44:11 1996 Return-Path: owner-freebsd-scsi Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id JAA11034 for freebsd-scsi-outgoing; Fri, 6 Sep 1996 09:44:11 -0700 (PDT) Received: from freefall.freebsd.org (localhost.cdrom.com [127.0.0.1]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id JAA10983; Fri, 6 Sep 1996 09:44:04 -0700 (PDT) Message-Id: <199609061644.JAA10983@freefall.freebsd.org> To: current, scsi Subject: New SCSI code on the "SCSI" branch Date: Fri, 06 Sep 1996 09:44:04 -0700 From: "Justin T. Gibbs" Sender: owner-freebsd-scsi@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk As you may have seen from the commit mail last night, I placed all of my work so far on the SCSI system onto the "SCSI" branch to allow for controlled testing and to incourage other developers to help out in the effort (hint, hint, 8-). Below I've included the relavent portion of sys/scsi/README that lists what I've done. If you have the CVS tree, you can try/work-on this code by using the following cvs command: cd /usr/src/sys cvs update -P -d -r SCSI scsi dev/aic7xxx i386/scsi i386/isa/bt5xx-445.c \ i386/isa/aha1542.c i386/isa/aic6360.c i386/isa/ncr5380.c \ i386/isa/seagate.c i386/isa/ultra14f.c i386/isa/wd7000.c \ i386/eisa/aic7770.c i386/eisa/aha1742.c i386/eisa/bt74x.c \ pci/ncr.c pci/ncrreg.h conf/files Do NOT do this: cd /usr/src/sys cvs update -P -d -r SCSI -f While the above command appears to do what you want, it adds a sticky tag of "TSCSI" on every file in the tree even if that tag is not in its corresponding RCS file. CVS will complain bitterly if you try to do ceratin opertions with your tree like this (say a cvs status or commit). Here's the README: ------Thu Sep 5 23:27:18 PDT 1996----- gibbs@FreeBSD.org 1) Made a first pass over the data structures: There is still lots of work to be done on the current set of data structures. My main changes were to remove obsolete fields, separate adapter reated information into a separate "adapter_link", and to create the scsi_queue structure. 2) Renamed flags and data structure members to lessen the differences with Open/NetBSD: There are lots of gratuitous and some not so gratuitous differences between the two camps SCSI code. I hope to bring the code bases closer together over the next month so that we can easily share controller drivers. 3) Changed how transfers are queued, started, and completed: The original scsi system has had a long standing problem with how queued transactions are handled. The root of the problem comes from the policy of deferring the reservation of controller resources until way down in the controller scsi_cmd routine where we may not have a process context and thus cannot always sleep. With these patches, the scsi system relies almost entirely on queue management instead of sleeping to handle its resources. More specifically, I've introduced a new data structure, the scsi_queue, that relates devices that share common controller resources. A scsi_queue has "openings" as do the individual scsi_links. A scsi_link is on the scsi_queue's run queue only when it has spare openings and work to do. When running a scsi_queue, the scsi_links are handled in round-robin fashion with each link allowed to send a single transaction per round. Before a transaction is dequeued, controller resources are obtained through adapter->get_cdb and attached to the scsi_xfer structure. get_cdb and free_cdb are two entry points provided by the controller drivers that encapsulate controller resource management. They should never be called directly by the controller driver (the wd7000 driver is the only current exception to this rule). Transaction ordering is also maintained by locking the scsi_link off the run queue until the controller drivers completes queueing the command. This strategy should yield greater performance since a freed controller resource can start any scsi_link attached to that device instead of only attempting to start pending transactions on the device that just completed a transaction. The round-robin scheme also ensures resource fairness when devices with multiple openings compete for a small number of resources. The scheduling algorithm should be changed to support real-time priorities. The scsi_queue structure is an opaque type to the controller drivers to make this easier to accomplish. 4) Centralized error handling and "done" processing: The scsi_cmd entry point now returns void. The controller drivers now exclusively use scsi_done() along with a properly set scsi_xfer->error to report errors. This removes superflous code paths and duplicated code. 5) Commands are built directly in the scsi_xfer structure instead of on the stack: The original design forced each and every command structure to be copied into the scsi_xfer by the scsi_scsi_cmd routine. The scsi_xfer is now obtained up front and the command built directly into the scsi_xfer->cmd_store. The members of the scsi_xfer structure are filled in directly via an inline function, scsi_prepare_xs, instead of stuffing all of them on the stack to simply be assigned into the scsi_xfer by scsi_scsi_cmd. scsi_scsi_cmd has also been replaced by scsi_schedule_xs(). 6) Converted individual controller resource management to use the queue(3) macros. Many of the drivers performed complicated list manipulations that were simplified by using the queue macros. The generic scsi layer's queue managment is also queue(3) based. 7) Removed error detection and reporting from the xxstart routines: The goal here is to make the xxstart routines as small and efficient as possible. Error detection occurs in the strategy routine or in the sense handlers. If an error is detected that may affect queued transactions, the new driver entry point clean_queue() is called to synchronously remove any entries that would have been gradually drained by the start routines in the past. 8) Added the complete driver entry point: The complete entry point is called as the last operation on a scsi_xfer before it is freed. This is the place where device usage statistic hooks should be added. In NetBSD, they have overloaded the scsi_done routine by adding an additional argument to serve this purpose which I think is the wrong approach. Currently all disk type drivers have a complete routine using the old dk_* stat stuff. Eventually I'd like to bring in NetBSD's disk status code which is much cleaner and provides more information. 9) Removed the async driver entry point: This entry point has never been used. 10) Brough in Jason Thorpe's ch driver. I haven't added the quirk entries for the supported changers yet, but we should probably invert the meaning of our quirks (probe multiple luns by default) first. 11) Set the lun in the second byte of CDBs. This was brought up on the NetBSD lists and the lack of setting it is probably the main reason for our code probing multiple luns on so many devices. The SCSI-II spec allows for the lun to be set although it is "optional". 12) Removed the need for a static scsi_link prototype and dummy scsi_device entry in each controller driver. 13) Added tagged queueing support to the generic SCSI code and modified the aic7xxx driver to use it. We now honor the B_ORDERED buffer flag and convert sync writes to async/ordered writes if the target device does tagged queueing. 14) Added proper, timeout based, retries for the XS_BUSY case. We don't retry until either the timeout expires or the target successfully completes a command. This should also be done for the QUEUE FULL condition, but that is NYI. 15) Brought in NetBSD's scsi_message.h file and converted the generic scsi scsi layer and the aic7xxx driver to use its constants instead of home grown ones. -- Justin T. Gibbs =========================================== FreeBSD: Turning PCs into workstations ===========================================