public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com,
	konrad.wilk@oracle.com, david.vrabel@citrix.com,
	boris.ostrovsky@oracle.com, linux-usb@vger.kernel.org
Subject: Re: [Patch V2 1/3] usb: Add Xen pvUSB protocol description
Date: Mon, 15 Jun 2015 06:04:52 +0200	[thread overview]
Message-ID: <557E4EE4.4020504@suse.com> (raw)
In-Reply-To: <20150612162327.GD15911@kroah.com>

On 06/12/2015 06:23 PM, Greg KH wrote:
> On Fri, Jun 12, 2015 at 04:09:59PM +0200, Juergen Gross wrote:
>> +enum usb_spec_version {
>> +	USB_VER_UNKNOWN = 0,
>> +	USB_VER_USB11,
>> +	USB_VER_USB20,
>> +	USB_VER_USB30,	/* not supported yet */
>> +};
>> +
>
> You are defining a bunch of things in this .h file that start with
> "usb" yet are not part of the USB core at all, but rather are xen
> specific.  Please don't polute the namespace with such things.

Okay.

>
>> +/*
>> + *  USB pipe in usbif_request
>> + *
>> + *  - port number:	bits 0-4
>> + *				(USB_MAXCHILDREN is 31)
>> + *
>> + *  - operation flag:	bit 5
>> + *				(0 = submit urb,
>> + *				 1 = unlink urb)
>> + *
>> + *  - direction:	bit 7
>> + *				(0 = Host-to-Device [Out]
>> + *				 1 = Device-to-Host [In])
>> + *
>> + *  - device address:	bits 8-14
>> + *
>> + *  - endpoint:		bits 15-18
>> + *
>> + *  - pipe type:	bits 30-31
>> + *				(00 = isochronous, 01 = interrupt,
>> + *				 10 = control, 11 = bulk)
>> + */
>> +
>> +#define USBIF_PIPE_PORT_MASK	0x0000001f
>> +#define USBIF_PIPE_UNLINK	0x00000020
>> +#define USBIF_PIPE_DIR		0x00000080
>> +#define USBIF_PIPE_DEV_MASK	0x0000007f
>> +#define USBIF_PIPE_DEV_SHIFT	8
>> +#define USBIF_PIPE_EP_MASK	0x0000000f
>> +#define USBIF_PIPE_EP_SHIFT	15
>> +#define USBIF_PIPE_TYPE_MASK	0x00000003
>> +#define USBIF_PIPE_TYPE_SHIFT	30
>> +#define USBIF_PIPE_TYPE_ISOC	0
>> +#define USBIF_PIPE_TYPE_INT	1
>> +#define USBIF_PIPE_TYPE_CTRL	2
>> +#define USBIF_PIPE_TYPE_BULK	3
>
> Why can't you just use the defines we have for this already?

This interface is a stable ABI to be used outside of Linux by other
Xen guests as well. As long as those Linux internal definitions are
not guaranteed to remain unchanged forever, I'd rather have my own
defines.

>
>> +
>> +#define usbif_pipeportnum(pipe)			((pipe) & USBIF_PIPE_PORT_MASK)
>> +#define usbif_setportnum_pipe(pipe, portnum)	((pipe) | (portnum))
>> +
>> +#define usbif_pipeunlink(pipe)			((pipe) & USBIF_PIPE_UNLINK)
>> +#define usbif_pipesubmit(pipe)			(!usbif_pipeunlink(pipe))
>> +#define usbif_setunlink_pipe(pipe)		((pipe) | USBIF_PIPE_UNLINK)
>> +
>> +#define usbif_pipein(pipe)			((pipe) & USBIF_PIPE_DIR)
>> +#define usbif_pipeout(pipe)			(!usbif_pipein(pipe))
>> +
>> +#define usbif_pipedevice(pipe)			\
>> +		(((pipe) >> USBIF_PIPE_DEV_SHIFT) & USBIF_PIPE_DEV_MASK)
>> +
>> +#define usbif_pipeendpoint(pipe)		\
>> +		(((pipe) >> USBIF_PIPE_EP_SHIFT) & USBIF_PIPE_EP_MASK)
>> +
>> +#define usbif_pipetype(pipe)			\
>> +		(((pipe) >> USBIF_PIPE_TYPE_SHIFT) & USBIF_PIPE_TYPE_MASK)
>> +#define usbif_pipeisoc(pipe)	(usbif_pipetype(pipe) == USBIF_PIPE_TYPE_ISOC)
>> +#define usbif_pipeint(pipe)	(usbif_pipetype(pipe) == USBIF_PIPE_TYPE_INT)
>> +#define usbif_pipectrl(pipe)	(usbif_pipetype(pipe) == USBIF_PIPE_TYPE_CTRL)
>> +#define usbif_pipebulk(pipe)	(usbif_pipetype(pipe) == USBIF_PIPE_TYPE_BULK)
>
>
> Same for all of these?

Correct. :-)

>
>> +
>> +#define USBIF_MAX_SEGMENTS_PER_REQUEST (16)
>> +#define USBIF_MAX_PORTNR	31
>
> Why does userspace have to know this?

Not userspace, but Xen guests. The number of segments per request and
the maximum port number are part of the interface between frontend and
backend, so they are defined here.

>
>> +
>> +/*
>> + * RING for transferring urbs.
>> + */
>> +struct usbif_request_segment {
>> +	grant_ref_t gref;
>> +	uint16_t offset;
>> +	uint16_t length;
>> +};
>
> Please use proper kernel types for things that go outside of the kernel
> (__u16 and the like).  There is no "uint16_t" as a valid type in the
> kernel, sorry.  Well, ok, we have it, just because it snuck in somehow,
> but it should be removed one of these days...

Okay.

>
>> +struct usbif_urb_request {
>
> Again, very generic structure name for a xen specific thing :(

I'll change all names to use "xenusb_" instead of "usbif_" as prefix.


Juergen

  reply	other threads:[~2015-06-15  4:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 14:09 [Patch V2 0/3] xen, usb: support pvUSB frontend driver Juergen Gross
2015-06-12 14:09 ` [Patch V2 1/3] usb: Add Xen pvUSB protocol description Juergen Gross
2015-06-12 16:23   ` Greg KH
2015-06-15  4:04     ` Juergen Gross [this message]
2015-06-12 14:10 ` [Patch V2 2/3] usb: Introduce Xen pvUSB frontend Juergen Gross
2015-06-12 16:20   ` Greg KH
2015-06-12 16:33     ` [Xen-devel] " David Vrabel
2015-06-12 18:06       ` Greg KH
2015-06-15  4:36     ` Juergen Gross
2015-06-12 14:10 ` [Patch V2 3/3] xen: add Xen pvUSB maintainer Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=557E4EE4.4020504@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox