* [issue] usbip: vhci-hcd: Device unable to get work after reset
@ 2019-12-10 11:43 Zhai Zhaoxuan
2019-12-11 16:00 ` Shuah Khan
0 siblings, 1 reply; 7+ messages in thread
From: Zhai Zhaoxuan @ 2019-12-10 11:43 UTC (permalink / raw)
To: Valentina Manea, Shuah Khan, Shuah Khan; +Cc: linux-usb
Hi,
I am trying to implement a virtual USB device using usbip. But I get a trouble.
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?
Thanks,
Zhai Zhaoxuan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [issue] usbip: vhci-hcd: Device unable to get work after reset
2019-12-10 11:43 [issue] usbip: vhci-hcd: Device unable to get work after reset Zhai Zhaoxuan
@ 2019-12-11 16:00 ` Shuah Khan
2019-12-12 3:23 ` Zhai Zhaoxuan
[not found] ` <3e97b00c-ca87-0085-3f8e-6e85fd9b6c30@gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Shuah Khan @ 2019-12-11 16:00 UTC (permalink / raw)
To: Zhai Zhaoxuan, Valentina Manea, Shuah Khan; +Cc: linux-usb, Shuah Khan
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [issue] usbip: vhci-hcd: Device unable to get work after reset
2019-12-11 16:00 ` Shuah Khan
@ 2019-12-12 3:23 ` Zhai Zhaoxuan
[not found] ` <3e97b00c-ca87-0085-3f8e-6e85fd9b6c30@gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: Zhai Zhaoxuan @ 2019-12-12 3:23 UTC (permalink / raw)
To: Shuah Khan, Valentina Manea, Shuah Khan; +Cc: linux-usb
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
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [issue] usbip: vhci-hcd: Device unable to get work after reset
[not found] ` <3e97b00c-ca87-0085-3f8e-6e85fd9b6c30@gmail.com>
@ 2019-12-12 22:33 ` Shuah Khan
2019-12-13 3:01 ` Zhai Zhaoxuan
0 siblings, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2019-12-12 22:33 UTC (permalink / raw)
To: Zhai Zhaoxuan, Valentina Manea, Shuah Khan
Cc: linux-usb, skh >> Shuah Khan
Hi Zhai,
On 12/11/19 8:19 PM, Zhai Zhaoxuan wrote:
> 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.
Does USB redirection support virtual devices? My understanding
it is usually a physical device connected to the local system.
So I can
> create a virtual ethernet device with usbip,
How are you creating the virtual device?
let them
Who is them here?
redirect the USB
> ethernet device to the remote computer, and enable NAT forward.
>
Is this virtual device is exported by USBIP host driver on your local
machine?
> 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.
Why do you need to write a user-space program and what does it do?
Where does this vhci run? On the local system? I still don't fully
follow the use-case.
>
> But the USB redirection will always reset the USB device before it
> passing the device to the remote computer.
>
Does USB redirection support virtual devices?
> 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,
-- Shuah
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [issue] usbip: vhci-hcd: Device unable to get work after reset
2019-12-12 22:33 ` Shuah Khan
@ 2019-12-13 3:01 ` Zhai Zhaoxuan
2020-01-01 11:50 ` Zhai Zhaoxuan
0 siblings, 1 reply; 7+ messages in thread
From: Zhai Zhaoxuan @ 2019-12-13 3:01 UTC (permalink / raw)
To: Shuah Khan, Valentina Manea, Shuah Khan; +Cc: linux-usb
Hi Shuah,
On 12/13/19 6:33 AM, Shuah Khan wrote:
> Hi Zhai,
>
> On 12/11/19 8:19 PM, Zhai Zhaoxuan wrote:
>> 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.
>
> Does USB redirection support virtual devices? My understanding
> it is usually a physical device connected to the local system.
Yes. At least "spicy" (a SPICE protocol client program) allows users
choose virtual devices in the list.
But "spicy" is unable to reset devices. "spicy" redirection fails with
the error: "Could not redirect [Device Product Name] at 6-2: error
resetting device: LIBUSB_ERROR_NOT_FOUND".
>
> So I can
>> create a virtual ethernet device with usbip,
>
> How are you creating the virtual device?
usbip creates a virtual device and attach the device to the vhci.
It just like local usbip client connected to a virtual remote system.
And the virtual remote system has a usb ethernet card.
But in my use case, the virtual remote system is emulated by the
user-space program.
>
> let them
>
> Who is them here?
> redirect the USB
"them" indicates SPICE/RDP protocols, remote control softwares (e.g
vmware client), and remote management cards, etc.
They are protocols or programs which allows the user passing a local USB
device to the remote system.
Let's call them "AGENT".
>> ethernet device to the remote computer, and enable NAT forward.
>>
>
> Is this virtual device is exported by USBIP host driver on your local
> machine?
Yes, you are correct!
>
>> 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.
>
> Why do you need to write a user-space program and what does it do?
> Where does this vhci run? On the local system? I still don't fully
> follow the use-case.
The vhci runs on local system.
The user-space program transfers the data from vhci to the network
subsystem. I plans use TAP device to communicate with the network subsystem.
If the USB redirection sucessed, the full chain will be:
remote kernel network subsystem <--> remote USB bus <--> AGENT <-->
local vhci <--> local user-space program <--> local TAP device <-->
local kernel network subsystem
>
>>
>> But the USB redirection will always reset the USB device before it
>> passing the device to the remote computer.
>>
> Does USB redirection support virtual devices?
Yes. The virtual devices are USB devices. The remote agents does not
filter out the virtual devices.
>
>> 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,
> -- Shuah
Thanks,
Zhai Zhaoxuan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [issue] usbip: vhci-hcd: Device unable to get work after reset
2019-12-13 3:01 ` Zhai Zhaoxuan
@ 2020-01-01 11:50 ` Zhai Zhaoxuan
2020-01-01 23:17 ` Shuah Khan
0 siblings, 1 reply; 7+ messages in thread
From: Zhai Zhaoxuan @ 2020-01-01 11:50 UTC (permalink / raw)
To: Shuah Khan, Valentina Manea, Shuah Khan; +Cc: linux-usb
Hi Shuah,
It has been almost 3 weeks since the last email.
Can you confirm if this is a bug or a feature?
I am still looking forward to your reply. And hope this issue can be
resolved.
Thanks,
Zhai Zhaoxuan
On 12/13/19 11:01 AM, Zhai Zhaoxuan wrote:
> Hi Shuah,
>
> On 12/13/19 6:33 AM, Shuah Khan wrote:
>> Hi Zhai,
>>
>> On 12/11/19 8:19 PM, Zhai Zhaoxuan wrote:
>>> 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.
>>
>> Does USB redirection support virtual devices? My understanding
>> it is usually a physical device connected to the local system.
>
> Yes. At least "spicy" (a SPICE protocol client program) allows users
> choose virtual devices in the list.
>
> But "spicy" is unable to reset devices. "spicy" redirection fails with
> the error: "Could not redirect [Device Product Name] at 6-2: error
> resetting device: LIBUSB_ERROR_NOT_FOUND".
>
>>
>> So I can
>>> create a virtual ethernet device with usbip,
>>
>> How are you creating the virtual device?
>
> usbip creates a virtual device and attach the device to the vhci.
>
> It just like local usbip client connected to a virtual remote system.
> And the virtual remote system has a usb ethernet card.
>
> But in my use case, the virtual remote system is emulated by the
> user-space program.
>
>
>>
>> let them
>>
>> Who is them here?
>> redirect the USB
>
> "them" indicates SPICE/RDP protocols, remote control softwares (e.g
> vmware client), and remote management cards, etc.
>
> They are protocols or programs which allows the user passing a local
> USB device to the remote system.
>
> Let's call them "AGENT".
>
>
>>> ethernet device to the remote computer, and enable NAT forward.
>>>
>>
>> Is this virtual device is exported by USBIP host driver on your local
>> machine?
>
> Yes, you are correct!
>
>
>>
>>> 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.
>>
>> Why do you need to write a user-space program and what does it do?
>> Where does this vhci run? On the local system? I still don't fully
>> follow the use-case.
> The vhci runs on local system.
>
> The user-space program transfers the data from vhci to the network
> subsystem. I plans use TAP device to communicate with the network
> subsystem.
>
> If the USB redirection sucessed, the full chain will be:
>
> remote kernel network subsystem <--> remote USB bus <--> AGENT <-->
> local vhci <--> local user-space program <--> local TAP device <-->
> local kernel network subsystem
>
>
>>
>>>
>>> But the USB redirection will always reset the USB device before it
>>> passing the device to the remote computer.
>>>
>> Does USB redirection support virtual devices?
> Yes. The virtual devices are USB devices. The remote agents does not
> filter out the virtual devices.
>>
>>> 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,
>> -- Shuah
>
> Thanks,
> Zhai Zhaoxuan
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [issue] usbip: vhci-hcd: Device unable to get work after reset
2020-01-01 11:50 ` Zhai Zhaoxuan
@ 2020-01-01 23:17 ` Shuah Khan
0 siblings, 0 replies; 7+ messages in thread
From: Shuah Khan @ 2020-01-01 23:17 UTC (permalink / raw)
To: Zhai Zhaoxuan, Valentina Manea, Shuah Khan; +Cc: linux-usb, Shuah Khan
Hi Zhai Zhaoxuan,
On 1/1/20 4:50 AM, Zhai Zhaoxuan wrote:
> Hi Shuah,
>
>
> It has been almost 3 weeks since the last email.
December got away from em with holidays and vacation time.
Sorry for the delay.
>
> Can you confirm if this is a bug or a feature?
>
>
The behavior you are seeing is specific to how your use-case.
> I am trying to implement a virtual USB device using usbip. But I get a trouble.
>
> 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?
Right.There is no need to clear VDEV_ST_USED because the port is still
used, and reset is sent to the usbip_host. VDEV_ST_NOTASSIGNED indicates
that the port is in used state with no usb addresses assigned.
I am not sure what is happening in your environment. It would be useful
to see dmesg from the usbip server and client in you environment.
I would be very interested to see if you can reproduce this problem
outside the USB Redirect scenario.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-01-01 23:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 11:43 [issue] usbip: vhci-hcd: Device unable to get work after reset Zhai Zhaoxuan
2019-12-11 16:00 ` Shuah Khan
2019-12-12 3:23 ` Zhai Zhaoxuan
[not found] ` <3e97b00c-ca87-0085-3f8e-6e85fd9b6c30@gmail.com>
2019-12-12 22:33 ` Shuah Khan
2019-12-13 3:01 ` Zhai Zhaoxuan
2020-01-01 11:50 ` Zhai Zhaoxuan
2020-01-01 23:17 ` Shuah Khan
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).