Re: [issue] usbip: vhci-hcd: Device unable to get work after reset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Shuah,

For me, I want to let the remote control software passing some virtual device (e.g. ethernet device) to the remote computer.

More specifically, the remote computer is connected to a private network, and the local computer is connected to the Internet. And the local can only connect to the remote computer using RDP/SPICE protocols, some other softwares such as vmware client, or even remote management cards.

All these protocols or softwares support USB redirection. So I can create a virtual ethernet device with usbip, let them redirect the USB ethernet device to the remote computer, and enable NAT forward.

Then I am able to access the private network with local computer.


Currently, I am writing a user-space program. It runs usbip protocol, and can be connected and attached to the vhci.

But the USB redirection will always reset the USB device before it passing the device to the remote computer.

And now, this "reset" results the device be disabled and never be enabled again. So the redirection fails.


In addition to this, I think usbip is a great module to allow the user emulate some other devices and passing them to the remote computer easily. For example, the virtual serial port can be emulated in user-space, and communicate with the remote computer over SPICE. And then, I can get the console output from the remote computer or send console command to it.


Thanks,

Zhai Zhaoxuan


On 12/12/19 12:00 AM, Shuah Khan wrote:
On 12/10/19 4:43 AM, Zhai Zhaoxuan wrote:
Hi,

I am trying to implement a virtual USB device using usbip. But I get a trouble.


Can you give me more details on why you are planning to add virtual USB
to usbip? How does it work with conjunction with the usbip server side?

When a running port on vhci_hcd is resetted (by setting USB_PORT_FEAT_RESET), it will never be enabled again.

The kernel version is 5.5.0-rc1-00012-g6794862a16ef.
In the source file drivers/usb/usbip/vhci_hcd.c:

  565         case USB_PORT_FEAT_RESET:
...
  572             /* if it's already enabled, disable */
  573             if (hcd->speed == HCD_USB3) {
  574                 vhci_hcd->port_status[rhport] = 0;
  575                 vhci_hcd->port_status[rhport] =
  576                     (USB_SS_PORT_STAT_POWER |
  577                      USB_PORT_STAT_CONNECTION |
  578                      USB_PORT_STAT_RESET);
  579             } else if (vhci_hcd->port_status[rhport] & USB_PORT_STAT_ENABLE) {   580                 vhci_hcd->port_status[rhport] &= ~(USB_PORT_STAT_ENABLE
  581                     | USB_PORT_STAT_LOW_SPEED
  582                     | USB_PORT_STAT_HIGH_SPEED);
  583             }
  584

The USB_PORT_STAT_ENABLE is cleard. And it should be set later.
But, the GetPortStatus only set the USB_PORT_STAT_ENABLE for not-assigned ports.

  430     case GetPortStatus:
...
  456             if (vhci_hcd->vdev[rhport].ud.status ==
  457                 VDEV_ST_NOTASSIGNED) {
  458                 usbip_dbg_vhci_rh(
  459                     " enable rhport %d (status %u)\n",
  460                     rhport,
  461                     vhci_hcd->vdev[rhport].ud.status);
  462                 vhci_hcd->port_status[rhport] |=
  463                     USB_PORT_STAT_ENABLE;
  464             }

The used port (status == VDEV_ST_USED) will be disabled after USB_PORT_FEAT_RESET, and unable to be enabled again.

Should VDEV_ST_USED be added to line 457?
And if it shouldn't, how can I enable a port after USB_PORT_FEAT_RESET?



I would like to see server and client side patches and a use-case for
adding virtual device.

thanks,
-- Shuah





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux