Re: Understanding how USB transmission works

2020-03-03 Thread Hans Petter Selasky

On 2020-03-03 04:42, Farhan Khan wrote:

Thank you so much for your prompt response! I understand that you are the one 
who wrote the USB stack? If so, I am honored.
Can you please clarify a few points you made?

In the beginning you call the start method

Within rum(4), would that be rum_start()? If not, which function is that?


rum_start() later on calls usbd_transfer_start() which actually starts 
the USB part.



then you can submit the USB transfer

Would that function be usbd_transfer_submit(9)?


Yes.

--HPS
___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: Understanding how USB transmission works

2020-03-02 Thread Farhan Khan
On Mon, Mar 2, 2020, at 4:48 PM, Hans Petter Selasky wrote:
> On 2020-03-02 22:19, Farhan Khan wrote:
> > Hi all,
> > 
> > I am trying to understand how FreeBSD's usb transfers work compared to 
> > OpenBSD by using the rum(4) driver. I am a little confused how the FreeBSD 
> > side works.
> 
> In FreeBSD USB transfers are a statemachine. In the beginning you call 
> the start method, and that invokes the statemachine callback in the 
> SETUP state. There you setup all parameters, buffers, lengths etc. and 
> then you can submit the USB transfer, which invoke the host controller 
> drivers routines, which actually lay out the required DMA descriptors 
> for data transfer. When the USB transfer is completed the statemachine 
> callback is invoked again and you can choose what to do.
> 
> --HPS
> 

Thank you so much for your prompt response! I understand that you are the one 
who wrote the USB stack? If so, I am honored.
Can you please clarify a few points you made?
> In the beginning you call the start method
Within rum(4), would that be rum_start()? If not, which function is that?

> then you can submit the USB transfer
Would that function be usbd_transfer_submit(9)?

Thanks again!
--
Farhan Khan
PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE

___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: Understanding how USB transmission works

2020-03-02 Thread Hans Petter Selasky

On 2020-03-02 22:19, Farhan Khan wrote:

Hi all,

I am trying to understand how FreeBSD's usb transfers work compared to OpenBSD 
by using the rum(4) driver. I am a little confused how the FreeBSD side works.


In FreeBSD USB transfers are a statemachine. In the beginning you call 
the start method, and that invokes the statemachine callback in the 
SETUP state. There you setup all parameters, buffers, lengths etc. and 
then you can submit the USB transfer, which invoke the host controller 
drivers routines, which actually lay out the required DMA descriptors 
for data transfer. When the USB transfer is completed the statemachine 
callback is invoked again and you can choose what to do.


--HPS



On the OpenBSD side, it seems that after allocating the pipes, you use 
usbd_setup_xfer and usbd_transfer(). As an example, look at OpenBSD's 
/usr/src/sys/dev/usb/if_rum.c, starting on line 2027-2029, I believe that 
corresponds to FreeBSD's /usr/src/sys/dev/usb/wlan/if_rum.c, line 2607 
(rum_setup_tx_list) which goes to 807. In this function, I see that it adds 
rum_tx_data (tx_data[i] to the end of tx_free. However, how does it actually 
send the data? I believe this occurs in the callback functions, specifically 
with the usbd_transfer_submit function, but I am not certain how that is 
triggered, especially when it is triggered by the driver, such as in a send 
function.





Please assist.
Thank you!

Links below to make it easy to follow:
OpenBSD:
https://github.com/openbsd/src/blob/2e342c845e9966c26657b08851237fc18e7b5ff5/sys/dev/usb/if_rum.c#L2024

FreeBSD:
1. 
https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L2607
2. 
https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L807

--
Farhan Khan
PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE

___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"



___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: Understanding how USB transmission works

2020-03-02 Thread Ian Lepore
On Mon, 2020-03-02 at 16:19 -0500, Farhan Khan wrote:
> Hi all,
> 
> I am trying to understand how FreeBSD's usb transfers work compared
> to OpenBSD by using the rum(4) driver. I am a little confused how the
> FreeBSD side works.
> 
> On the OpenBSD side, it seems that after allocating the pipes, you
> use usbd_setup_xfer and usbd_transfer(). As an example, look at
> OpenBSD's /usr/src/sys/dev/usb/if_rum.c, starting on line 2027-2029,
> I believe that corresponds to FreeBSD's
> /usr/src/sys/dev/usb/wlan/if_rum.c, line 2607 (rum_setup_tx_list)
> which goes to 807. In this function, I see that it adds rum_tx_data
> (tx_data[i] to the end of tx_free. However, how does it actually send
> the data? I believe this occurs in the callback functions,
> specifically with the usbd_transfer_submit function, but I am not
> certain how that is triggered, especially when it is triggered by the
> driver, such as in a send function.
> 
> Please assist.
> Thank you!
> 
> Links below to make it easy to follow:
> OpenBSD:
> https://github.com/openbsd/src/blob/2e342c845e9966c26657b08851237fc18e7b5ff5/sys/dev/usb/if_rum.c#L2024
> 
> FreeBSD:
> 1. 
> https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L2607
> 2. 
> https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L807
> 

I think you're probably looking for:

https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L1623

Note that I don't know anything about the if_rum driver in general, I
just know to look for occurrances of usbd_transfer_start().

-- Ian



___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Understanding how USB transmission works

2020-03-02 Thread Farhan Khan
Hi all,

I am trying to understand how FreeBSD's usb transfers work compared to OpenBSD 
by using the rum(4) driver. I am a little confused how the FreeBSD side works.

On the OpenBSD side, it seems that after allocating the pipes, you use 
usbd_setup_xfer and usbd_transfer(). As an example, look at OpenBSD's 
/usr/src/sys/dev/usb/if_rum.c, starting on line 2027-2029, I believe that 
corresponds to FreeBSD's /usr/src/sys/dev/usb/wlan/if_rum.c, line 2607 
(rum_setup_tx_list) which goes to 807. In this function, I see that it adds 
rum_tx_data (tx_data[i] to the end of tx_free. However, how does it actually 
send the data? I believe this occurs in the callback functions, specifically 
with the usbd_transfer_submit function, but I am not certain how that is 
triggered, especially when it is triggered by the driver, such as in a send 
function.

Please assist.
Thank you!

Links below to make it easy to follow:
OpenBSD:
https://github.com/openbsd/src/blob/2e342c845e9966c26657b08851237fc18e7b5ff5/sys/dev/usb/if_rum.c#L2024

FreeBSD:
1. 
https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L2607
2. 
https://github.com/freebsd/freebsd/blob/499b2b565264824f2139ebcb5d1c97404a17e7e6/sys/dev/usb/wlan/if_rum.c#L807

--
Farhan Khan
PGP Fingerprint: 1312 89CE 663E 1EB2 179C 1C83 C41D 2281 F8DA C0DE

___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"