-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usb: device_next: add CDC ECM class implementation #54448
usb: device_next: add CDC ECM class implementation #54448
Conversation
4d00db9
to
35666b8
Compare
*/ | ||
#define CDC_ECM_IMAC_BASE 4 | ||
|
||
#define CDC_ECM_IFACE_UP 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think enum fits the purpose here better than defines.
int ret; | ||
|
||
if (!atomic_test_bit(&data->state, CDC_ECM_CLASS_ENABLED)) { | ||
return -EPERM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ENODEV
better reflects the error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENODEV is confusing because there is a device but it can not be used yet, I would like to use EACCES and align it with 562d799#r1126070376
} | ||
|
||
if (atomic_test_bit(&data->state, CDC_ECM_CLASS_SUSPENDED)) { | ||
LOG_INF("USB support is suspended (FIXME)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"USB device" is suspended, not "USB support"
if (!atomic_test_bit(&data->state, CDC_ECM_CLASS_ENABLED) || | ||
!atomic_test_bit(&data->state, CDC_ECM_IFACE_UP)) { | ||
LOG_INF("Configuration is not enabled or interface not ready"); | ||
return -EACCES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ENODEV
is more appropriate here.
#define USBD_CDC_ECM_DT_DEVICE_DEFINE(n) \ | ||
CDC_ECM_DEFINE_DESCRIPTOR(n); \ | ||
USBD_DESC_STRING_DEFINE(mac_desc_nd_##n, \ | ||
DT_INST_PROP_OR(n, mac_address, "00005E005301"),\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If MAC address is changed to require property this hardcoded fallback will no longer be necessary.
Add bindings for CDC ECM virtual ethernet controller. Signed-off-by: Johann Fischer <[email protected]>
Add CDC Ethernet Control Model class implementation for the new experimental USB device support based on the existing implementation subsys/usb/device/class/netusb/function_ecm.c. The implementation forms virtual ethernet connection between USB host and USB device and requires two corresponding MAC addresses, one for the virtual interface on the device side, and other for the host which is described by a string descriptor. With upcoming changes it should also possible to use a real ethernet controller as media access on the device side. CDC ECM implementation supports multiple instances which are specified using DT. The number of instances is limited by the number of endpoints on the controller, two to three should usually be possible. Signed-off-by: Johann Fischer <[email protected]>
Add DT and Kconfig overlay for new experimental CDC ECM implementation. USB device support configuration and initialization can be done through shell by following commands: uart:~$ usbd config add 1 uart:~$ usbd class add cdc_ecm_0 1 uart:~$ usbd defaults uart:~$ usbd init uart:~$ usbd enable Signed-off-by: Johann Fischer <[email protected]>
35666b8
to
8dc282c
Compare
Add CDC Ethernet Control Model class implementation for the
new experimental USB device support based on the existing
implementation subsys/usb/device/class/netusb/function_ecm.c.
The implementation forms virtual ethernet connection between
USB host and USB device and requires two corresponding MAC
addresses, one for the virtual interface on the device side,
and other for the host which is described by a string descriptor.
CDC ECM implementation supports multiple instances which are
specified using DT. The number of instances is limited by the
number of endpoints on the controller, two to three should usually
be possible.