-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Expose len8_dlc
field of can_frame
struct.
#3357
Conversation
r? @JohnTitor (rustbot has picked a reviewer for you, use r? to override) |
len8_dlc
field of can_frame
struct.
@bors r+ |
Expose `len8_dlc` field of `can_frame` struct. The `can_frame` struct on Linux has a `len8_dlc` field which can be used to stuff a few extra bits in the `dlc` field of the actual CAN frame on the wire (only allowed when the data length itself is 8, and if the hardware CAN controller allows it). However, that field is not currently exposed. This PR exposes it as `pub len8_dlc: u8` so we can get those extra 2.8 bits from our CAN frames 😅 It would have been nice to name the current `can_dlc` field as `len`, instead of the old deprecated name, but I guess that ship has sailed. Upstream documentation: https://www.kernel.org/doc/html/latest/networking/can.html#how-to-use-socketcan > ```c > struct can_frame { > canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ > union { > /* CAN frame payload length in byte (0 .. CAN_MAX_DLEN) > * was previously named can_dlc so we need to carry that > * name for legacy support > */ > __u8 len; > __u8 can_dlc; /* deprecated */ > }; > __u8 __pad; /* padding */ > __u8 __res0; /* reserved / padding */ > __u8 len8_dlc; /* optional DLC for 8 byte payload length (9 .. 15) */ > __u8 data[8] __attribute__((aligned(8))); > }; > ``` > > Remark: The len element contains the payload length in bytes and should be used instead of can_dlc. The deprecated can_dlc was misleadingly named as it always contained the plain payload length in bytes and not the so called 'data length code' (DLC). > > To pass the raw DLC from/to a Classical CAN network device the len8_dlc element can contain values 9 .. 15 when the len element is 8 (the real payload length for all DLC values greater or equal to 8).
💔 Test failed - checks-actions |
I don't see any reason for the failure. Is it correct to assume that this was an unrelated CI failure? :o |
85dbb12
to
1f88773
Compare
The failure is related. I think mips doesn't have it or our musl header is too old. |
Oh, sorry, the link just pointed to a job running "exit 1" and I didn't notice the other red check. |
Note that the What would be a good way forward for me to unblock this? Find a different linux mips distro with a newer kernel? /edit: This openwrt release would fit the bill: https://downloads.openwrt.org/releases/23.05.0-rc4/targets/bcm47xx/generic/openwrt-sdk-23.05.0-rc4-bcm47xx-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz |
Hmm, updating to https://downloads.openwrt.org/releases/23.05.0-rc4/targets/bcm47xx/generic/openwrt-sdk-23.05.0-rc4-bcm47xx-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz breaks other tests, atleast if I locally run I guess I need to figure out why first :( |
☔ The latest upstream changes (presumably #3429) made this pull request unmergeable. Please resolve the merge conflicts. |
@de-vri-es any chance you could update this? MIPS dropped to tier3 so if that was the cause of failure here, it shouldn't be a problem anymore. |
68c9234
to
dba870b
Compare
Re-applied the changes to current |
CI now fails because the kernel headers for the musl tests are taken from https://github.com/sabotage-linux/kernel-headers which is based on linux 4.19, but this field was introduced in linux 5.11 (released in february 2021). |
Could you just update skip_field in libc-test/build.rs and leave a |
f1e04fc
to
987fd8d
Compare
Done, and rebased again! @rustbot ready |
Huh.. I don't see my changes to |
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.
Thanks!
@@ -1583,7 +1583,7 @@ s_no_extra_traits! { | |||
pub can_dlc: u8, |
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.
While you're here, mind adding a comment // FIXME(1.0): this field was renamed to `can_len`
based on the docs?
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.
Sure!
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.
Added!
Indeed :) since #3921 musl is on 6.6 I left one quick unrelated request since you're updating the struct, should be ready in either case. |
987fd8d
to
cf2028b
Compare
Nice :)
Added the comment to |
Oops thanks for the name correction. LGTM! |
Head branch was pushed to by a user without write access
cf2028b
to
48bdb18
Compare
Had to force-push again, I had a typo in |
(backport <rust-lang#3357>) (cherry picked from commit 48bdb18)
@tgross35: Thanks for the reviews! |
The
can_frame
struct on Linux has alen8_dlc
field which can be used to stuff a few extra bits in thedlc
field of the actual CAN frame on the wire (only allowed when the data length itself is 8, and if the hardware CAN controller allows it).However, that field is not currently exposed. This PR exposes it as
pub len8_dlc: u8
so we can get those extra 2.8 bits from our CAN frames 😅It would have been nice to name the current
can_dlc
field aslen
, instead of the old deprecated name, but I guess that ship has sailed.Upstream documentation: https://www.kernel.org/doc/html/latest/networking/can.html#how-to-use-socketcan