usb: device_next: usbd_cdc_ncm: correct net_if_carrier use#104379
Conversation
net_if_carrier is to be used independently of the administrative state (start and stop of the ethernet_api). This way we are able to detect a "reconnect" of the USB cable, unfortunatly we can't detect a disconnection on it's own, but we can detect a reconnection and thus trigger the carrier state change. And therefore we can trigger the DHCP client to get a new IP address. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
|
|
This pull request has been marked as stale because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 7 days. Note, that you can always re-open a closed pull request at any time. |
|
This pull request has been marked as stale because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 7 days. Note, that you can always re-open a closed pull request at any time. |
There was a problem hiding this comment.
I'm not super familiar with CDC NCM.
I just had a few questions to make sure things are as intended.
AFAIU, this PR gives the final decision of making the interface up or down to the host, rather than to the application.
Or maybe one step further than this: after this change, an interface is up when both Zephyr and the host enabled it?
Thank you for the changes.
| LOG_INF("Connection status sent"); | ||
| net_if_carrier_on(data->iface); |
There was a problem hiding this comment.
The log says "sent", should net_if_carrier_on() be placed before?
There was a problem hiding this comment.
Should there also be a atomic_set_bit(&data->state, CDC_NCM_IFACE_UP); like cdc_ncm_iface_start() is doing?
|
|
||
| static void usbd_cdc_ncm_enable(struct usbd_class_data *const c_data) | ||
| { | ||
| LOG_INF("Enabled %s", c_data->name); |
There was a problem hiding this comment.
Should there be a matching net_if_carrier_on()?
I think not needed: it up to the host to re-enable it.



net_if_carrier is to be used independently of the
administrative state (start and stop of the ethernet_api).
This way we are able to detect a "reconnect" of the USB cable, unfortunatly we can't detect a disconnection on it's own, but we can detect a reconnection and thus trigger the carrier state change. And therefore we can trigger the DHCP client to get a new IP address.
Split from #100809