linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.de>
To: Stephanie Wallick <stephanie.s.wallick@intel.com>
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, devel@driverdev.osuosl.org,
	"Sean O. Stalley" <sean.stalley@intel.com>
Subject: Re: [V2 PATCH 02/10] added media agnostic (MA) USB HCD roothubs
Date: Wed, 12 Nov 2014 09:35:42 +0100	[thread overview]
Message-ID: <1415781342.1761.10.camel@linux-0dmf.site> (raw)
In-Reply-To: <1415671781-11351-2-git-send-email-stephanie.s.wallick@intel.com>

On Mon, 2014-11-10 at 18:09 -0800, Stephanie Wallick wrote:
> This is where we implement USB 2.0 and 3.0 roothubs. From the host's
> perspective, hub state is set and tracked just like any other USB roothub.
> Likewise, requests to the roothub appear to be handled like any other wired
> USB request.
> 
> Signed-off-by: Sean O. Stalley <sean.stalley@intel.com>
> Signed-off-by: Stephanie Wallick <stephanie.s.wallick@intel.com>
> ---
>  drivers/staging/mausb/drivers/mausb_hub.c | 849 ++++++++++++++++++++++++++++++
>  drivers/staging/mausb/drivers/mausb_hub.h | 128 +++++
>  2 files changed, 977 insertions(+)
>  create mode 100644 drivers/staging/mausb/drivers/mausb_hub.c
>  create mode 100644 drivers/staging/mausb/drivers/mausb_hub.h
> 
> diff --git a/drivers/staging/mausb/drivers/mausb_hub.c b/drivers/staging/mausb/drivers/mausb_hub.c
> new file mode 100644
> index 0000000..63c0fe4
> --- /dev/null
> +++ b/drivers/staging/mausb/drivers/mausb_hub.c

> +/**
> + * Returns true if the given is the superspeed HCD. Note: The primary HCD is
> + * High Speed and the shared HCD is SuperSpeed.
> + */

Why in that order?

> +bool mausb_is_ss_hcd(struct usb_hcd *hcd)
> +{
> +	if (usb_hcd_is_primary_hcd(hcd))
> +		return false;
> +	else
> +		return true;
> +}



> +
> +/**
> + * Called by usb core when polling for a port status change.
> + *
> + * @hcd:	USB HCD being polled.
> + * @buf:	Holds port status changes (if any).
> + *
> + * Returns zero if there is no status change, otherwise returns number of
> + * bytes in buf. When there is a status change on a port, the bit indexed
> + * at the port number + 1 (e.g. bit 2 for port 1) is set in the buffer.
> + */
> +int mausb_hub_status_data(struct usb_hcd *hcd, char *buf)
> +{
> +	int                      i;
> +	u16                      port_change = 0;
> +	u32                      status = 0;
> +	int                      ret = 1;
> +	struct mausb_hcd	 *mhcd = usb_hcd_to_mausb_hcd(hcd);
> +	struct mausb_root_hub	 *roothub = usb_hcd_to_roothub(hcd);
> +
> +	/*
> +	 * Buf should never be more that 2 bytes. USB 3.0 hubs cannot have
> +	 * more than 15 downstream ports.
> +	 */
> +	buf[0] = 0;
> +	if (MAUSB_ROOTHUB_NUM_PORTS > 7) {
> +		buf[1] = 0;
> +		ret++;
> +	}

Endianness bug.

> +
> +	for (i = 0; i < MAUSB_ROOTHUB_NUM_PORTS; i++) {
> +		port_change = roothub->port_status[i].wPortChange;
> +		if (port_change)
> +			status |= (1 << (i + 1));
> +	}
> +
> +	mausb_dbg(mhcd, "%s: hub status is 0x%x\n", __func__, status);
> +
> +	/* hcd might be suspended, resume if there is a status change */
> +	if (mhcd->disabled == 0) {
> +		if ((hcd->state == HC_STATE_SUSPENDED) && status)
> +			usb_hcd_resume_root_hub(hcd);
> +	}
> +
> +	memcpy(buf, (char *)&status, ret);
> +
> +	return status ? ret : 0;
> +}
> +
> +/**
> + * Sets the bitfields in the hub descriptor of the 2.0 root hub. Always
> + * returns zero.
> + */
> +int mausb_set_hub_descriptor(struct usb_hub_descriptor *hub_des)
> +{
> +	/* set the values to the default */
> +	hub_des->bDescLength          = sizeof(struct usb_hub_descriptor);
> +	hub_des->bDescriptorType      = USB_DT_HUB;
> +	hub_des->bNbrPorts            = MAUSB_ROOTHUB_NUM_PORTS;
> +	hub_des->wHubCharacteristics  = MAUSB_ROOTHUB_CHAR;
> +	hub_des->bPwrOn2PwrGood       = MAUSB_ROOTHUB_PWR_ON_2_PWR_GOOD;
> +	hub_des->bHubContrCurrent     = MAUSB_ROOTHUB_CONTR_CURRENT;

Is that descriptor in bus or host endianness?

> +
> +	return 0;
> +}
> +
> +/**
> + * Sets the bitfields in the hub descriptor of the 3.0 root hub. Always
> + * returns zero.

Then why return anything?

> + */
> +int mausb_set_ss_hub_descriptor(struct usb_hub_descriptor *hub_des)
> +{
> +	/* set the values to the default */
> +	hub_des->bDescLength          = sizeof(struct usb_hub_descriptor);
> +	hub_des->bDescriptorType      = USB_DT_SS_HUB;
> +	hub_des->bNbrPorts            = MAUSB_ROOTHUB_NUM_PORTS;
> +	hub_des->wHubCharacteristics  = MAUSB_ROOTHUB_CHAR;
> +	hub_des->bPwrOn2PwrGood       = MAUSB_ROOTHUB_PWR_ON_2_PWR_GOOD;
> +	hub_des->bHubContrCurrent     = MAUSB_ROOTHUB_CONTR_CURRENT;
> +
> +	/* USB3-specific parameters */
> +	hub_des->u.ss.bHubHdrDecLat   = MAUSB_ROOTHUB_HDR_DEC_LAT;
> +	hub_des->u.ss.wHubDelay       = MAUSB_ROOTHUB_DELAY;
> +	hub_des->u.ss.DeviceRemovable = MAUSB_ALL_DEV_REMOVABLE;
> +
> +	return 0;
> +}


> +/**
> + * Contains all the structures required to emulate a root hub. One instance
> + * exists per root hub.
> + */
> +struct __attribute__((__packed__)) mausb_root_hub {

Why __packed__ ?
> +
> +	/* hub parameters */
> +	struct usb_hub_descriptor descriptor;
> +	struct usb_hub_status     status;
> +
> +	/* port parameters*/
> +	struct usb_port_status    port_status[MAUSB_ROOTHUB_NUM_PORTS];
> +
> +	/* root hub state */
> +	enum   mausb_rh_state     rh_state;
> +
> +};

	HTH
		Oliver

-- 
Oliver Neukum <oneukum@suse.de>


  reply	other threads:[~2014-11-12  8:35 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <MA USB drivers>
2014-11-03 20:42 ` [PATCH 00/10] MA USB drivers cover letter Stephanie Wallick
2014-11-03 20:42   ` [PATCH 01/10] added media agnostic (MA) USB HCD driver Stephanie Wallick
2014-11-03 21:18     ` Greg KH
2014-11-03 23:47       ` steph
2014-11-03 21:21     ` Greg KH
2014-11-04  0:04       ` steph
2014-11-04  0:13         ` Greg KH
2014-11-04  0:59           ` steph
2014-11-05 20:14           ` sostalle
2014-11-05 22:08             ` Greg KH
2014-11-03 20:42   ` [PATCH 02/10] added media agnostic (MA) USB HCD roothubs Stephanie Wallick
2014-11-03 20:42   ` [PATCH 03/10] added media agnostic (MA) data structures and handling Stephanie Wallick
2014-11-03 20:42   ` [PATCH 04/10] added media agnostic (MA) USB packet handling Stephanie Wallick
2014-11-03 20:42   ` [PATCH 05/10] added media specific (MS) TCP drivers Stephanie Wallick
2014-11-04  8:48     ` Tobias Klauser
2014-11-04 18:02       ` Greg KH
2014-11-12 19:36       ` Sean O. Stalley
2014-11-03 20:42   ` [PATCH 06/10] added media agnostic (MA) UDC Stephanie Wallick
2014-11-03 20:42   ` [PATCH 07/10] added media agnostic (MA) USB management packet handling Stephanie Wallick
2014-11-03 20:42   ` [PATCH 08/10] added media agnostic (MA) USB data " Stephanie Wallick
2014-11-03 20:42   ` [PATCH 09/10] added tools for building/loading media agnostic (MA) USB drivers Stephanie Wallick
2014-11-03 20:42   ` [PATCH 10/10] added kernel build, configuration, and TODO files Stephanie Wallick
2014-11-03 21:22     ` Greg KH
2014-11-03 21:24     ` Greg KH
     [not found]       ` <54591319.c3b5440a.7374.5f85SMTPIN_ADDED_BROKEN@mx.google.com>
2014-11-04 18:02         ` Greg KH
2014-11-04  9:00   ` [PATCH 00/10] MA USB drivers cover letter Bjørn Mork
2014-11-05  1:31     ` sostalle
2014-11-11  2:09 ` [V2 PATCH 01/10] added media agnostic (MA) USB HCD driver Stephanie Wallick
2014-11-11  2:09   ` [V2 PATCH 02/10] added media agnostic (MA) USB HCD roothubs Stephanie Wallick
2014-11-12  8:35     ` Oliver Neukum [this message]
2014-11-12 19:28       ` Sean O. Stalley
2014-11-12 19:52         ` Alan Stern
2014-11-11  2:09   ` [V2 PATCH 03/10] added media agnostic (MA) data structures and handling Stephanie Wallick
2014-11-11  4:38     ` Greg KH
2014-11-11 22:42       ` Sean O. Stalley
2014-11-12  1:14         ` Greg KH
2014-11-12  2:01           ` steph
2014-11-11  2:09   ` [V2 PATCH 04/10] added media agnostic (MA) USB packet handling Stephanie Wallick
2014-11-12 14:01     ` Oliver Neukum
2014-11-11  2:09   ` [V2 PATCH 05/10] added media specific (MS) TCP drivers Stephanie Wallick
2014-11-11  4:21     ` Greg KH
2014-11-11  2:09   ` [V2 PATCH 06/10] added media agnostic (MA) UDC Stephanie Wallick
2014-11-11  2:09   ` [V2 PATCH 07/10] added media agnostic (MA) USB management packet handling Stephanie Wallick
2014-11-11  2:09   ` [V2 PATCH 08/10] added media agnostic (MA) USB data " Stephanie Wallick
2014-11-11  2:09   ` [V2 PATCH 09/10] added tools for building/loading media agnostic (MA) USB drivers Stephanie Wallick
2014-11-11  2:09   ` [V2 PATCH 10/10] added kernel build, configuration, and TODO files Stephanie Wallick
2014-11-11  4:23     ` Greg KH
2014-11-11  4:08   ` [V2 PATCH 01/10] added media agnostic (MA) USB HCD driver Greg KH
2014-11-11 15:54   ` Alan Stern
2014-11-12 21:40     ` Sean O. Stalley
2014-11-12 22:03       ` Alan Stern
2014-11-14 22:48         ` Sean O. Stalley
2014-11-15 21:29           ` Alan Stern
2014-11-12 22:58       ` Sean O. Stalley

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=1415781342.1761.10.camel@linux-0dmf.site \
    --to=oneukum@suse.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sean.stalley@intel.com \
    --cc=stephanie.s.wallick@intel.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;
as well as URLs for NNTP newsgroup(s).