From owner-svn-src-head@FreeBSD.ORG Mon Nov 28 09:54:41 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6DD01065679; Mon, 28 Nov 2011 09:54:41 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC4408FC15; Mon, 28 Nov 2011 09:54:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAS9sfkY083777; Mon, 28 Nov 2011 09:54:41 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAS9sfs9083775; Mon, 28 Nov 2011 09:54:41 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201111280954.pAS9sfs9083775@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 28 Nov 2011 09:54:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228056 - head/sys/dev/usb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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, 28 Nov 2011 09:54:42 -0000 Author: hselasky Date: Mon Nov 28 09:54:41 2011 New Revision: 228056 URL: http://svn.freebsd.org/changeset/base/228056 Log: This commit marks the beginning of a new internal USB transfer statemachine. This work is about using a single state variable instead of multiple state bits as input for the USB statemachine to determine what to do in the various parts of the code. No APIs towards USB device drivers or USB host controller drivers will be changed. MFC after: 1 month Modified: head/sys/dev/usb/usb_transfer.h Modified: head/sys/dev/usb/usb_transfer.h ============================================================================== --- head/sys/dev/usb/usb_transfer.h Mon Nov 28 09:33:13 2011 (r228055) +++ head/sys/dev/usb/usb_transfer.h Mon Nov 28 09:54:41 2011 (r228056) @@ -28,6 +28,120 @@ #define _USB_TRANSFER_H_ /* + * Definition of internal USB transfer states: + * =========================================== + * + * The main reason there are many USB states is that we are allowed to + * cancel USB transfers, then start the USB transfer again and that + * this state transaction cannot always be done in a single atomic + * operation without blocking the calling thread. One reason for this + * is that the USB hardware sometimes needs to wait for DMA + * controllers to finish which is done asynchronously and grows the + * statemachine. + * + * When extending the following statemachine there are basically two + * things you should think about: Which states should be executed or + * modified in case of USB transfer stop and which states should be + * executed or modified in case of USB transfer start. Also respect + * the "can_cancel_immed" flag which basically tells if you can go + * directly from a wait state to the cancelling states. + */ + +enum { + /* XFER start execute state */ + + /* USB_ST_SETUP = 0 (already defined) */ + + /* XFER transferred execute state */ + + /* USB_ST_TRANSFERRED = 1 (already defined) */ + + /* XFER error execute state */ + + /* USB_ST_ERROR = 2 (already defined) */ + + /* XFER restart after error execute state */ + + USB_ST_RESTART = 8, + + /* XFER transfer idle state */ + + USB_ST_WAIT_SETUP, + + /* Other XFER execute states */ + + USB_ST_PIPE_OPEN = 16, + USB_ST_PIPE_OPEN_ERROR, + USB_ST_PIPE_OPEN_RESTART, + + USB_ST_BDMA_LOAD, + USB_ST_BDMA_LOAD_ERROR, + USB_ST_BDMA_LOAD_RESTART, + + USB_ST_IVAL_DLY, + USB_ST_IVAL_DLY_ERROR, + USB_ST_IVAL_DLY_RESTART, + + USB_ST_PIPE_STALL, + USB_ST_PIPE_STALL_ERROR, + USB_ST_PIPE_STALL_RESTART, + + USB_ST_ENTER, + USB_ST_ENTER_ERROR, + USB_ST_ENTER_RESTART, + + USB_ST_START, + USB_ST_START_ERROR, + USB_ST_START_RESTART, + + USB_ST_PIPE_CLOSE, + USB_ST_PIPE_CLOSE_ERROR, + USB_ST_PIPE_CLOSE_RESTART, + + USB_ST_BDMA_DLY, + USB_ST_BDMA_DLY_ERROR, + USB_ST_BDMA_DLY_RESTART, + + /* XFER transfer wait states */ + + USB_ST_WAIT_PIPE_OPEN = 64, + USB_ST_WAIT_PIPE_OPEN_ERROR, + USB_ST_WAIT_PIPE_OPEN_RESTART, + + USB_ST_WAIT_BDMA_LOAD, + USB_ST_WAIT_BDMA_LOAD_ERROR, + USB_ST_WAIT_BDMA_LOAD_RESTART, + + USB_ST_WAIT_IVAL_DLY, + USB_ST_WAIT_IVAL_DLY_ERROR, + USB_ST_WAIT_IVAL_DLY_RESTART, + + USB_ST_WAIT_PIPE_STALL, + USB_ST_WAIT_PIPE_STALL_ERROR, + USB_ST_WAIT_PIPE_STALL_RESTART, + + USB_ST_WAIT_ENTER, + USB_ST_WAIT_ENTER_ERROR, + USB_ST_WAIT_ENTER_RESTART, + + USB_ST_WAIT_START, + USB_ST_WAIT_START_ERROR, + USB_ST_WAIT_START_RESTART, + + USB_ST_WAIT_PIPE_CLOSE, + USB_ST_WAIT_PIPE_CLOSE_ERROR, + USB_ST_WAIT_PIPE_CLOSE_RESTART, + + USB_ST_WAIT_BDMA_DLY, + USB_ST_WAIT_BDMA_DLY_ERROR, + USB_ST_WAIT_BDMA_DLY_RESTART, + + USB_ST_WAIT_TRANSFERRED, + USB_ST_WAIT_TRANSFERRED_ERROR, + USB_ST_WAIT_TRANSFERRED_RESTART, +}; + +/* * The following structure defines the messages that is used to signal * the "done_p" USB process. */