-
Notifications
You must be signed in to change notification settings - Fork 7.3k
usb: device_next: Simple NCM driver for usb-next #72310
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) 2024 Hardy Griech | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
description: USB CDC NCM virtual Ethernet controller | ||
|
||
compatible: "zephyr,cdc-ncm-ethernet" | ||
|
||
include: ethernet-controller.yaml | ||
|
||
properties: | ||
remote-mac-address: | ||
type: string | ||
required: true | ||
description: | | ||
Remote MAC address of the virtual Ethernet connection. | ||
Should not be the same as local-mac-address property. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,13 @@ | |
#define ACM_SUBCLASS 0x02 | ||
#define ECM_SUBCLASS 0x06 | ||
#define EEM_SUBCLASS 0x0c | ||
#define NCM_SUBCLASS 0x0d | ||
|
||
/** Communications Class Protocol Codes */ | ||
#define AT_CMD_V250_PROTOCOL 0x01 | ||
#define EEM_PROTOCOL 0x07 | ||
#define ACM_VENDOR_PROTOCOL 0xFF | ||
#define NCM_DATA_PROTOCOL 1 | ||
|
||
/** | ||
* @brief Data Class Interface Codes | ||
|
@@ -50,6 +52,7 @@ | |
#define ACM_FUNC_DESC 0x02 | ||
#define UNION_FUNC_DESC 0x06 | ||
#define ETHERNET_FUNC_DESC 0x0F | ||
#define ETHERNET_FUNC_DESC_NCM 0x1a | ||
|
||
/** | ||
* @brief PSTN Subclass Specific Requests | ||
|
@@ -199,7 +202,7 @@ struct cdc_acm_notification { | |
} __packed; | ||
|
||
/** Ethernet Networking Functional Descriptor */ | ||
struct cdc_ecm_descriptor { | ||
struct cdc_eth_functional_descriptor { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think you should rename it here or at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... but |
||
uint8_t bFunctionLength; | ||
uint8_t bDescriptorType; | ||
uint8_t bDescriptorSubtype; | ||
|
@@ -210,4 +213,12 @@ struct cdc_ecm_descriptor { | |
uint8_t bNumberPowerFilters; | ||
} __packed; | ||
|
||
struct cdc_ncm_functional_descriptor { | ||
uint8_t bFunctionLength; | ||
uint8_t bDescriptorType; | ||
uint8_t bDescriptorSubtype; | ||
uint16_t bcdNcmVersion; | ||
uint8_t bmNetworkCapabilities; | ||
} __packed; | ||
|
||
#endif /* ZEPHYR_INCLUDE_USB_CLASS_USB_CDC_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# USB Device Settings | ||
CONFIG_USB_DEVICE_STACK=y | ||
|
||
CONFIG_NET_PKT_RX_COUNT=14 | ||
CONFIG_NET_PKT_TX_COUNT=14 | ||
CONFIG_NET_BUF_RX_COUNT=28 | ||
CONFIG_NET_BUF_TX_COUNT=28 | ||
CONFIG_NET_BUF_DATA_SIZE=1500 | ||
|
||
Comment on lines
+4
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This configuration overlay is not used if sample is build for the new USB device support. Stray changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to rethink why I have done this ;-) |
||
# Select USB Configurations | ||
CONFIG_USB_DEVICE_NETWORK_ECM=y | ||
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CONFIG_USB_DEVICE_STACK_NEXT=y | ||
|
||
# next-ncm does not work well with the static-size buffers | ||
CONFIG_NET_PKT_BUF_RX_DATA_POOL_SIZE=10000 | ||
CONFIG_NET_PKT_BUF_TX_DATA_POOL_SIZE=10000 | ||
CONFIG_NET_BUF_VARIABLE_DATA_SIZE=y | ||
|
||
CONFIG_LOG=y | ||
CONFIG_USBD_LOG_LEVEL_WRN=y | ||
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y | ||
Comment on lines
+1
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move sample changes to a separate commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done that |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright (c) 2024 Hardy Griech | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/ { | ||
cdc_ncm_eth0: cdc_ncm_eth0 { | ||
compatible = "zephyr,cdc-ncm-ethernet"; | ||
Check failure on line 9 in samples/net/zperf/usbd_next_ncm.overlay
|
||
remote-mac-address = "00005E005301"; | ||
Check failure on line 10 in samples/net/zperf/usbd_next_ncm.overlay
|
||
}; | ||
}; | ||
Comment on lines
+7
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please indent with tabs, always. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2024 Hardy Griech | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config USBD_CDC_NCM_CLASS | ||
bool "USB CDC NCM implementation [EXPERIMENTAL]" | ||
default y | ||
depends on NET_L2_ETHERNET | ||
depends on DT_HAS_ZEPHYR_CDC_NCM_ETHERNET_ENABLED | ||
help | ||
USB CDC Network Control Model (NCM) implementation" | ||
|
||
if USBD_CDC_NCM_CLASS | ||
module = USBD_CDC_NCM | ||
module-str = usbd cdc_ncm | ||
default-count = 1 | ||
source "subsys/logging/Kconfig.template.log_config" | ||
rsource "Kconfig.template.instances_count" | ||
endif |
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.
Please move changes in doc/connectivity/usb/device_next/usb_device.rst to a separate commit, it would also make it easier for you to rebase.
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.
ok... I have created three branches and soon two more PRs will appear here. New code stays in this PR.
Concerning review procedure: who is resolving conversations? You? Me?
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.
One branch (one PR) with N commits is the preferred way.
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.
gosh... what have I done!? Misunderstood Johanns point completely. Will go back.
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.
what commit comments do you expect in this case?
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 by commit comments you mean the commit messages, then each commit message should describe what the individual commit does. Do not reuse the title for all of the commits, make each of them point to the respective part. For example the commit changing sample should start its commit title with
samples: net: zperf:
.Things like "This PR contains the actual driver." do not belong in commit message.