From owner-freebsd-scsi@FreeBSD.ORG Fri Oct 12 22:32:05 2012 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 78677502 for ; Fri, 12 Oct 2012 22:32:05 +0000 (UTC) (envelope-from ken@kdm.org) Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81]) by mx1.freebsd.org (Postfix) with ESMTP id 23DEA8FC18 for ; Fri, 12 Oct 2012 22:32:04 +0000 (UTC) Received: from nargothrond.kdm.org (localhost [127.0.0.1]) by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id q9CMW3IR069155; Fri, 12 Oct 2012 16:32:03 -0600 (MDT) (envelope-from ken@nargothrond.kdm.org) Received: (from ken@localhost) by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id q9CMW3Sr069154; Fri, 12 Oct 2012 16:32:03 -0600 (MDT) (envelope-from ken) Date: Fri, 12 Oct 2012 16:32:03 -0600 From: "Kenneth D. Merry" To: Jack Subject: Re: passstart() and immediate CCBs Message-ID: <20121012223203.GA68975@nargothrond.kdm.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2i Cc: freebsd-scsi@freebsd.org X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2012 22:32:05 -0000 On Thu, Oct 11, 2012 at 12:13:27 +0530, Jack wrote: > Hello all, > > I was going through cam subsystem source(FreeBSD RELEASE 9 ), > and tried understanding how it works. > One thing I got stuck is, when exactly is passtart() invoked in case of > immediate CCBs. For non-immediate CCBs, it is quite clear to me. > > In case of scsi pass driver(scsi_pass.c), xpt_schedule() is invoked by > cam_periph_getccb(), and cam_periph_ioctl(). > But not in case of immediate CCBs. In case of immediate CCBs, > xpt_alloc_ccb_nowait() is invoked and then xpt_setup_ccb(). > > Is it that in case of immediate CCBs, passstart() is never invoked? That is correct. passstart() is only used for non-immediate CCBs. > If it is true then, how does the thread awakens(which is slept by calling > cam_periph_ccbwait() inside cam_periph_runccb() ) when HBA driver > serves interrupt, and passdone() is invoked. The thread never sleeps in the immediate case (because the status is changed to something other than CAM_REQ_INPROG), and the done routine isn't called. Immediate CCBs are complete when xpt_action() returns, so no callback is needed. > There seems no code inside passdone(), to wakeup the thread, the > only code being inside PASS_CCB_WAITING case is not valid > for immediate CCBs, as passstart() is never invoked so it didn't > set ccb type to PASS_CCB_WAITING. > > Do immediate and immediate CCBs have any implications on > cam priority assignment specified in CCB header? Immediate CCBs never go down to the hardware. The priority mechanism is used to help determine who gets queue slots, and those are only needed for queued CCBs. > It seems that concept of which queues are in existence in cam subsystem > is not clear to me. > ie beginning from cam_periph_runccb(), how passdone() is invoked, > how passstart() is invoked if it is, and which queues are involved, > especially in case of immediate CCBs. > > > As far as I can get, there are at least 2 queues: > one is maintained by SCSI HBA driver for I/O requests, the other is queue > of CCBs maintained per cam peripheral( ie struct cam_peripheral) ?? or > cam device (ie struct cam_ed) ?? at transport layer. There is a queue per HBA, based on how many commands the HBA can handle, and a queue per device (struct cam_ed), based on how many commands a particular device can handle. Ken -- Kenneth Merry ken@FreeBSD.ORG