Introducing new CAN FD bittiming parameters: Transmission Delay Compensation (TDC)
v2 cover Introducing new CAN FD bittiming parameters: Transmission Delay Compensation (TDC)
At high bit rates, the propagation delay from the TX pin to the RX pin of the transceiver causes measurement errors and needs to be corrected.
To solve this issue, ISO 11898-1 introduces in section 11.3.3 "Transmitter delay compensation" (here after TDC) a SSP (Secondary Sample Point) equal to the distance, in time quanta, from the start of the bit time on the TX pin to the actual measurement on the RX pin.
This patch series implements the TDC parameters which allow the controller to calculate that SSP.
The first patch introduces the new structures, the second one saves eight bytes on struct can_priv, the third fixes some existing checkpatch warnings in preparation on the next one, the fourth one implements the netlink interface and, finally, the fifth one adds the calculation.
This is a follow-up on the RFC is sent already more than one month ago.
You might also be interested in below patch which implement those changes in iproute command line:
https://lore.kernel.org/linux-can/[email protected]/T/#t
Because this v2 introduced no changes on the netlink interface, the iproute patch will *not* be resend.
Changes from v1:
- Changed the commit message of the first patch of the serie to clarify the condition of when TDC is active.
- Changed the alignment style from tabulations to single space in drivers/net/can/dev/netlink.c
- Remove duplicated [IFLA_CAN_TERMINATION] entry in drivers/net/can/dev/netlink.c
Changes from the RFC:
- The RFC was a single e-mail with all comments in bulk, made this a proper patch series.
- Added the netlink interface.
- Rename the function can_set_tdc to can_calc_tdco (the formula is the same, everything around it was reworked).
- Other small miscellaneous changes.
TODO: the documentation will be updated after the netlink interface gets approved.
Yours sincerely,
Vincent
Vincent Mailhol (5):
can: add new CAN FD bittiming parameters: Transmitter Delay
Compensation (TDC)
can: dev: reorder struct can_priv members for better packing
can: netlink: move '=' operators back to previous line (checkpatch
fix)
can: add netlink interface for CAN-FD Transmitter Delay Compensation
(TDC)
can: bittiming: add calculation for CAN FD Transmitter Delay
Compensation (TDC)
drivers/net/can/dev/bittiming.c | 23 +++++++ drivers/net/can/dev/netlink.c | 100 ++++++++++++++++++++++++++----- include/linux/can/bittiming.h | 71 ++++++++++++++++++++++ include/linux/can/dev.h | 14 +++-- include/uapi/linux/can/netlink.h | 6 ++ 5 files changed, 194 insertions(+), 20 deletions(-)
base-commit: 1b34628ac60360ef7455c00f01dc62f82ed08d8c
Signature · 1 line
2.26.2
PATCH v2 1/5 can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
At high bit rates, the propagation delay from the TX pin to the RX pin of the transceiver causes measurement errors: the sample point on the RX pin might occur on the previous bit.
This issue is addressed in ISO 11898-1 section 11.3.3 "Transmitter delay compensation" (TDC).
This patch adds two new structures: can_tdc and can_tdc_const in order to implement this TDC.
The structures are then added to can_priv.
A controller supports TDC if an only if can_priv::tdc_const is not NULL.
TDC is active if and only if:
- fd flag is on
- can_priv::tdc.tdco is not zero.
It is the driver responsibility to check those two conditions are met.
No new controller modes are introduced (i.e. no CAN_CTRL_MODE_TDC) in order not to be redundant with above logic.
The names of the parameters are chosen to match existing CAN controllers specification. References:
- Bosch C_CAN FD8:
https://www.bosch-semiconductors.com/media/ip_modules/pdf_2/c_can_fd8/users_manual_c_can_fd8_r210_1.pdf
- Microchip CAN FD Controller Module:
http://ww1.microchip.com/downloads/en/DeviceDoc/MCP251XXFD-CAN-FD-Controller-Module-Family-Reference-Manual-20005678B.pdf
- SAM E701/S70/V70/V71 Family:
https://www.mouser.com/datasheet/2/268/60001527A-1284321.pdf
--- include/linux/can/bittiming.h | 65 +++++++++++++++++++++++++++++++++++ include/linux/can/dev.h | 3 ++ 2 files changed, 68 insertions(+)
include/linux/can/bittiming.h +65 -0
@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2020 Pengutronix, Marc Kleine-Budde <[email protected]> +* Copyright (c) 2021 Vincent Mailhol <[email protected]> */ #ifndef _CAN_BITTIMING_H
@@ -10,6 +11,70 @@#define CAN_SYNC_SEG 1 +/* +* struct can_tdc - CAN FD Transmission Delay Compensation parameters +* +* At high bit rates, the propagation delay from the TX pin to the RX +* pin of the transceiver causes measurement errors: the sample point +* on the RX pin might occur on the previous bit. +* +* To solve this issue, ISO 11898-1 introduces in section 11.3.3 +* "Transmitter delay compensation" a SSP (Secondary Sample Point) +* equal to the distance, in time quanta, from the start of the bit +* time on the TX pin to the actual measurement on the RX pin. +* +* This structure contains the parameters to calculate that SSP. +* +* @tdcv: Transmitter Delay Compensation Value. Distance, in time +* quanta, from when the bit is sent on the TX pin to when it is +* received on the RX pin of the transmitter. Possible options: +* +* O: automatic mode. The controller dynamically measure @tdcv +* for each transmited CAN FD frame. +* +* Other values: manual mode. Use the fixed provided value. +* +* @tdco: Transmitter Delay Compensation Offset. Offset value, in time +* quanta, defining the distance between the start of the bit +* reception on the RX pin of the transceiver and the SSP +* position such as SSP = @tdcv + @tdco. +* +* If @tdco is zero, then TDC is disabled and both @tdcv and +* @tdcf should be ignored. +* +* @tdcf: Transmitter Delay Compensation Filter window. Defines the +* minimum value for the SSP position in time quanta. If SSP is +* less than @tdcf, then no delay compensations occur and the +* normal sampling point is used instead. The feature is enabled +* if and only if @tdcv is set to zero (automatic mode) and @tdcf +* is configured to a value greater than @tdco. +*/ +struct can_tdc { +u32 tdcv; +u32 tdco; +u32 tdcf; +}; + +/* +* struct can_tdc_const - CAN hardware-dependent constant for +* Transmission Delay Compensation +* +* @tdcv_max: Transmitter Delay Compensation Value maximum value. +* Should be set to zero if the controller does not support +* manual mode for tdcv. +* @tdco_max: Transmitter Delay Compensation Offset maximum value. +* Should not be zero. If the controller does not support TDC, +* then the pointer to this structure should be NULL. +* @tdcf_max: Transmitter Delay Compensation Filter window maximum +* value. Should be set to zero if the controller does not +* support this feature. +*/ +struct can_tdc_const { +u32 tdcv_max; +u32 tdco_max; +u32 tdcf_max; +}; +#ifdef CONFIG_CAN_CALC_BITTIMING int can_calc_bittiming (struct net_device *dev,struct can_bittiming *bt,const struct can_bittiming_const *btc);
include/linux/can/dev.h +3 -0
@@ -42,6 +42,9 @@ struct can_priv {struct can_bittiming bittiming, data_bittiming;const struct can_bittiming_const *bittiming_const, *data_bittiming_const; +struct can_tdc tdc; +const struct can_tdc_const *tdc_const; +const u16 *termination_const;unsigned int termination_const_cnt;u16 termination;
Signature · 1 line
2.26.2
Marc Kleine-Budde
maintainerRe: [PATCH v2 1/5] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
Quoted 23 lines · Vincent Mailhol
include/linux/can/bittiming.h +11
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2020 Pengutronix, Marc Kleine-Budde <[email protected]> +* Copyright (c) 2021 Vincent Mailhol <[email protected]> */ #ifndef _CAN_BITTIMING_H@@ -10,6 +11,70 @@#define CAN_SYNC_SEG 1 +/* +* struct can_tdc - CAN FD Transmission Delay Compensation parameters +* +* At high bit rates, the propagation delay from the TX pin to the RX +* pin of the transceiver causes measurement errors: the sample point +* on the RX pin might occur on the previous bit. +* +* To solve this issue, ISO 11898-1 introduces in section 11.3.3 +* "Transmitter delay compensation" a SSP (Secondary Sample Point) +* equal to the distance, in time quanta, from the start of the bit
include/linux/can/bittiming.h line 33
Quoted 10 lines
include/linux/can/bittiming.h +10
-0+* time on the TX pin to the actual measurement on the RX pin. +* +* This structure contains the parameters to calculate that SSP. +* +* @tdcv: Transmitter Delay Compensation Value. Distance, in time +* quanta, from when the bit is sent on the TX pin to when it is +* received on the RX pin of the transmitter. Possible options: +* +* O: automatic mode. The controller dynamically measure @tdcv +* for each transmited CAN FD frame.
^^^
transmitted
Fixed while applying to linux-can-next/testing. As net-next ist still closed, there is still some time to the next pull request and I'll squash patches if needed.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 1/5] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
Quoted 35 lines · Marc Kleine-Budde
Quoted 23 lines · Vincent Mailhol
include/linux/can/bittiming.h +11
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2020 Pengutronix, Marc Kleine-Budde <[email protected]> +* Copyright (c) 2021 Vincent Mailhol <[email protected]> */ #ifndef _CAN_BITTIMING_H@@ -10,6 +11,70 @@#define CAN_SYNC_SEG 1 +/* +* struct can_tdc - CAN FD Transmission Delay Compensation parameters +* +* At high bit rates, the propagation delay from the TX pin to the RX +* pin of the transceiver causes measurement errors: the sample point +* on the RX pin might occur on the previous bit. +* +* To solve this issue, ISO 11898-1 introduces in section 11.3.3 +* "Transmitter delay compensation" a SSP (Secondary Sample Point) +* equal to the distance, in time quanta, from the start of the bit include/linux/can/bittiming.h line 33
Quoted 10 lines
include/linux/can/bittiming.h +10
-0+* time on the TX pin to the actual measurement on the RX pin. +* +* This structure contains the parameters to calculate that SSP. +* +* @tdcv: Transmitter Delay Compensation Value. Distance, in time +* quanta, from when the bit is sent on the TX pin to when it is +* received on the RX pin of the transmitter. Possible options: +* +* O: automatic mode. The controller dynamically measure @tdcv +* for each transmited CAN FD frame. ^^^
Quoted 5 lines
transmitted
Fixed while applying to linux-can-next/testing. As net-next ist still closed, there is still some time to the next pull request and I'll squash patches if needed.
Hi Marc,
Can't find this in linux-can-next/testing
https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=testing
Regards,
jimmy
Marc Kleine-Budde
maintainerRe: [PATCH v2 1/5] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
Quoted 2 lines · Jimmy Assarsson
Can't find this in linux-can-next/testing
https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=testing
Try again.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 1/5] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
Quoted 7 lines · Marc Kleine-Budde
Quoted 2 lines · Jimmy Assarsson
Can't find this in linux-can-next/testing
https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git/log/?h=testingTry again.
Marc
Thanks!
Marc Kleine-Budde
maintainerRe: [PATCH v2 1/5] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
In reply to Vincent MailholQuoted 62 lines · Vincent Mailhol
At high bit rates, the propagation delay from the TX pin to the RX pin of the transceiver causes measurement errors: the sample point on the RX pin might occur on the previous bit.
This issue is addressed in ISO 11898-1 section 11.3.3 "Transmitter delay compensation" (TDC).
This patch adds two new structures:
can_tdcandcan_tdc_constin order to implement this TDC.The structures are then added to
can_priv.A controller supports TDC if an only if
can_priv::tdc_constis not NULL.TDC is active if and only if:
- fd flag is on
-can_priv::tdc.tdcois not zero.
It is the driver responsibility to check those two conditions are met.No new controller modes are introduced (i.e. no
CAN_CTRL_MODE_TDC) in order not to be redundant with above logic.The names of the parameters are chosen to match existing CAN controllers specification. References:
- BoschC_CANFD8:
https://www.bosch-semiconductors.com/media/ip_modules/pdf_2/c_can_fd8/users_manual_c_can_fd8_r210_1.pdf
- Microchip CAN FD Controller Module:
http://ww1.microchip.com/downloads/en/DeviceDoc/MCP251XXFD-CAN-FD-Controller-Module-Family-Reference-Manual-20005678B.pdf
- SAM E701/S70/V70/V71 Family:
https://www.mouser.com/datasheet/2/268/60001527A-1284321.pdfSigned-off-by Vincent Mailhol <[email protected]>--- include/linux/can/bittiming.h | 65 +++++++++++++++++++++++++++++++++++ include/linux/can/dev.h | 3 ++ 2 files changed, 68 insertions(+)include/linux/can/bittiming.h +10
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2020 Pengutronix, Marc Kleine-Budde <[email protected]> +* Copyright (c) 2021 Vincent Mailhol <[email protected]> */ #ifndef _CAN_BITTIMING_H@@ -10,6 +11,70 @@#define CAN_SYNC_SEG 1 +/* +* struct can_tdc - CAN FD Transmission Delay Compensation parameters +* +* At high bit rates, the propagation delay from the TX pin to the RX +* pin of the transceiver causes measurement errors: the sample point +* on the RX pin might occur on the previous bit. +* +* To solve this issue, ISO 11898-1 introduces in section 11.3.3 +* "Transmitter delay compensation" a SSP (Secondary Sample Point)
include/linux/can/bittiming.h line 32
Quoted 10 lines
include/linux/can/bittiming.h +10
-0+* equal to the distance, in time quanta, from the start of the bit +* time on the TX pin to the actual measurement on the RX pin. +* +* This structure contains the parameters to calculate that SSP. +* +* @tdcv: Transmitter Delay Compensation Value. Distance, in time +* quanta, from when the bit is sent on the TX pin to when it is +* received on the RX pin of the transmitter. Possible options: +* +* O: automatic mode. The controller dynamically measure @tdcv
^
I think this is supposed to be a 0, not a O?
I'll send a patch
include/linux/can/bittiming.h line 33
Quoted 1 line
include/linux/can/bittiming.h +1
-0+* for each transmited CAN FD frame.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 1/5] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
Quoted 75 lines · Marc Kleine-Budde
Quoted 62 lines · Vincent Mailhol
At high bit rates, the propagation delay from the TX pin to the RX pin of the transceiver causes measurement errors: the sample point on the RX pin might occur on the previous bit.
This issue is addressed in ISO 11898-1 section 11.3.3 "Transmitter delay compensation" (TDC).
This patch adds two new structures:
can_tdcandcan_tdc_constin order to implement this TDC.The structures are then added to
can_priv.A controller supports TDC if an only if
can_priv::tdc_constis not NULL.TDC is active if and only if:
- fd flag is on
-can_priv::tdc.tdcois not zero.
It is the driver responsibility to check those two conditions are met.No new controller modes are introduced (i.e. no
CAN_CTRL_MODE_TDC) in order not to be redundant with above logic.The names of the parameters are chosen to match existing CAN controllers specification. References:
- BoschC_CANFD8:
https://www.bosch-semiconductors.com/media/ip_modules/pdf_2/c_can_fd8/users_manual_c_can_fd8_r210_1.pdf
- Microchip CAN FD Controller Module:
http://ww1.microchip.com/downloads/en/DeviceDoc/MCP251XXFD-CAN-FD-Controller-Module-Family-Reference-Manual-20005678B.pdf
- SAM E701/S70/V70/V71 Family:
https://www.mouser.com/datasheet/2/268/60001527A-1284321.pdfSigned-off-by Vincent Mailhol <[email protected]>--- include/linux/can/bittiming.h | 65 +++++++++++++++++++++++++++++++++++ include/linux/can/dev.h | 3 ++ 2 files changed, 68 insertions(+)include/linux/can/bittiming.h +10
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2020 Pengutronix, Marc Kleine-Budde <[email protected]> +* Copyright (c) 2021 Vincent Mailhol <[email protected]> */ #ifndef _CAN_BITTIMING_H@@ -10,6 +11,70 @@#define CAN_SYNC_SEG 1 +/* +* struct can_tdc - CAN FD Transmission Delay Compensation parameters +* +* At high bit rates, the propagation delay from the TX pin to the RX +* pin of the transceiver causes measurement errors: the sample point +* on the RX pin might occur on the previous bit. +* +* To solve this issue, ISO 11898-1 introduces in section 11.3.3 +* "Transmitter delay compensation" a SSP (Secondary Sample Point) include/linux/can/bittiming.h line 32
Quoted 10 lines
include/linux/can/bittiming.h +10
-0+* equal to the distance, in time quanta, from the start of the bit +* time on the TX pin to the actual measurement on the RX pin. +* +* This structure contains the parameters to calculate that SSP. +* +* @tdcv: Transmitter Delay Compensation Value. Distance, in time +* quanta, from when the bit is sent on the TX pin to when it is +* received on the RX pin of the transmitter. Possible options: +* +* O: automatic mode. The controller dynamically measure @tdcv ^
Quoted 2 lines
I think this is supposed to be a 0, not a O?
I'll send a patch
Absolutely. I am not sure how I did such a mistake. I was probably not fully awake as there are two other grammar issues there. I sent another patch to fix those.
Yours sincerely,
Vincent
PATCH v2 2/5 can: dev: reorder struct can_priv members for better packing
In reply to Vincent MailholSave eight bytes of holes on x86-64 architectures by reordering struct can_priv members.
Before:
$ pahole -C can_priv drivers/net/can/dev/dev.o
struct can_priv {
struct net_device * dev; /* 0 8 */
struct can_device_stats can_stats; /* 8 24 */
struct can_bittiming bittiming; /* 32 32 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct can_bittiming data_bittiming; /* 64 32 */
const struct can_bittiming_const * bittiming_const; /* 96 8 */
const struct can_bittiming_const * data_bittiming_const; /* 104 8 */
struct can_tdc tdc; /* 112 12 *//* XXX 4 bytes hole, try to pack */
/* --- cacheline 2 boundary (128 bytes) --- */
const struct can_tdc_const * tdc_const; /* 128 8 */
const u16 * termination_const; /* 136 8 */
unsigned int termination_const_cnt; /* 144 4 */
u16 termination; /* 148 2 */
/* XXX 2 bytes hole, try to pack */
const u32 * bitrate_const; /* 152 8 */
unsigned int bitrate_const_cnt; /* 160 4 */
/* XXX 4 bytes hole, try to pack */
const u32 * data_bitrate_const; /* 168 8 */
unsigned int data_bitrate_const_cnt; /* 176 4 */
u32 bitrate_max; /* 180 4 */
struct can_clock clock; /* 184 4 */
enum can_state state; /* 188 4 */
/* --- cacheline 3 boundary (192 bytes) --- */
u32 ctrlmode; /* 192 4 */
u32 ctrlmode_supported; /* 196 4 */
u32 ctrlmode_static; /* 200 4 */
int restart_ms; /* 204 4 */
struct delayed_work restart_work; /* 208 168 */
/* XXX last struct has 4 bytes of padding */
/* --- cacheline 5 boundary (320 bytes) was 56 bytes ago --- */
int (*do_set_bittiming)(struct net_device *); /* 376 8 */
/* --- cacheline 6 boundary (384 bytes) --- */
int (*do_set_data_bittiming)(struct net_device *); /* 384 8 */
int (*do_set_mode)(struct net_device *, enum can_mode); /* 392 8 */
int (*do_set_termination)(struct net_device *, u16); /* 400 8 */
int (*do_get_state)(const struct net_device *, enum can_state *); /* 408 8 */
int (*do_get_berr_counter)(const struct net_device *, struct can_berr_counter *); /* 416 8 */
unsigned int echo_skb_max; /* 424 4 */
/* XXX 4 bytes hole, try to pack */
struct sk_buff * * echo_skb; /* 432 8 */
/* size: 440, cachelines: 7, members: 31 */ /* sum members: 426, holes: 4, sum holes: 14 */ /* paddings: 1, sum paddings: 4 */
/* last cacheline: 56 bytes */
};
After:
$ pahole -C can_priv drivers/net/can/dev/dev.o
struct can_priv {
struct net_device * dev; /* 0 8 */
struct can_device_stats can_stats; /* 8 24 */
const struct can_bittiming_const * bittiming_const; /* 32 8 */
const struct can_bittiming_const * data_bittiming_const; /* 40 8 */
struct can_bittiming bittiming; /* 48 32 */
/* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
struct can_bittiming data_bittiming; /* 80 32 */
const struct can_tdc_const * tdc_const; /* 112 8 */
struct can_tdc tdc; /* 120 12 */
/* --- cacheline 2 boundary (128 bytes) was 4 bytes ago --- */
unsigned int bitrate_const_cnt; /* 132 4 */
const u32 * bitrate_const; /* 136 8 */
const u32 * data_bitrate_const; /* 144 8 */
unsigned int data_bitrate_const_cnt; /* 152 4 */
u32 bitrate_max; /* 156 4 */
struct can_clock clock; /* 160 4 */
unsigned int termination_const_cnt; /* 164 4 */
const u16 * termination_const; /* 168 8 */
u16 termination; /* 176 2 *//* XXX 2 bytes hole, try to pack */
enum can_state state; /* 180 4 */
u32 ctrlmode; /* 184 4 */
u32 ctrlmode_supported; /* 188 4 */
/* --- cacheline 3 boundary (192 bytes) --- */
u32 ctrlmode_static; /* 192 4 */
int restart_ms; /* 196 4 */
struct delayed_work restart_work; /* 200 168 */
/* XXX last struct has 4 bytes of padding */
/* --- cacheline 5 boundary (320 bytes) was 48 bytes ago --- */
int (*do_set_bittiming)(struct net_device *); /* 368 8 */
int (*do_set_data_bittiming)(struct net_device *); /* 376 8 */
/* --- cacheline 6 boundary (384 bytes) --- */
int (*do_set_mode)(struct net_device *, enum can_mode); /* 384 8 */
int (*do_set_termination)(struct net_device *, u16); /* 392 8 */
int (*do_get_state)(const struct net_device *, enum can_state *); /* 400 8 */
int (*do_get_berr_counter)(const struct net_device *, struct can_berr_counter *); /* 408 8 */
unsigned int echo_skb_max; /* 416 4 */
/* XXX 4 bytes hole, try to pack */
struct sk_buff * * echo_skb; /* 424 8 */
/* size: 432, cachelines: 7, members: 31 */ /* sum members: 426, holes: 2, sum holes: 6 */ /* paddings: 1, sum paddings: 4 */
/* last cacheline: 48 bytes */
};
--- include/linux/can/dev.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
include/linux/can/dev.h +7 -6
@@ -39,22 +39,23 @@ struct can_priv {struct net_device *dev;struct can_device_stats can_stats; -struct can_bittiming bittiming, data_bittiming;const struct can_bittiming_const *bittiming_const, *data_bittiming_const; -struct can_tdc tdc; +struct can_bittiming bittiming, data_bittiming;const struct can_tdc_const *tdc_const; +struct can_tdc tdc; -const u16 *termination_const; -unsigned int termination_const_cnt; -u16 termination; -const u32 *bitrate_const;unsigned int bitrate_const_cnt; +const u32 *bitrate_const;const u32 *data_bitrate_const;unsigned int data_bitrate_const_cnt;u32 bitrate_max;struct can_clock clock; +unsigned int termination_const_cnt; +const u16 *termination_const; +u16 termination; +enum can_state state;/* CAN controller features - see include/uapi/linux/can/netlink.h */
Signature · 1 line
2.26.2
PATCH v2 3/5 can: netlink: move '=' operators back to previous line (checkpatch fix)
In reply to Vincent MailholFix the warning triggered by having an '=' at the beginning of the line by moving it back to the previous line. Also replace all indentations with a single space so that future entries can be more easily added.
Extract of ./scripts/checkpatch.pl -f drivers/net/can/dev/netlink.c:
CHECK: Assignment operator '=' should be on the previous line
+ [IFLA_CAN_BITTIMING_CONST]
+ = { .len = sizeof(struct can_bittiming_const) },
CHECK: Assignment operator '=' should be on the previous line
+ [IFLA_CAN_DATA_BITTIMING]
+ = { .len = sizeof(struct can_bittiming) },
CHECK: Assignment operator '=' should be on the previous line
+ [IFLA_CAN_DATA_BITTIMING_CONST]
+ = { .len = sizeof(struct can_bittiming_const) },
--- drivers/net/can/dev/netlink.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/net/can/dev/netlink.c +11 -14
@@ -8,20 +8,17 @@#include <net/rtnetlink.h> static const struct nla_policy can_policy[IFLA_CAN_MAX +1 ] = { - [IFLA_CAN_STATE ] = { .type =NLA_U32 }, - [IFLA_CAN_CTRLMODE ] = { .len =sizeof (struct can_ctrlmode ) }, - [IFLA_CAN_RESTART_MS ] = { .type =NLA_U32 }, - [IFLA_CAN_RESTART ] = { .type =NLA_U32 }, - [IFLA_CAN_BITTIMING ] = { .len =sizeof (struct can_bittiming ) }, - [IFLA_CAN_BITTIMING_CONST ] - = { .len =sizeof (struct can_bittiming_const ) }, - [IFLA_CAN_CLOCK ] = { .len =sizeof (struct can_clock ) }, - [IFLA_CAN_BERR_COUNTER ] = { .len =sizeof (struct can_berr_counter ) }, - [IFLA_CAN_DATA_BITTIMING ] - = { .len =sizeof (struct can_bittiming ) }, - [IFLA_CAN_DATA_BITTIMING_CONST ] - = { .len =sizeof (struct can_bittiming_const ) }, - [IFLA_CAN_TERMINATION ] = { .type =NLA_U16 }, + [IFLA_CAN_STATE ] = { .type =NLA_U32 }, + [IFLA_CAN_CTRLMODE ] = { .len =sizeof (struct can_ctrlmode ) }, + [IFLA_CAN_RESTART_MS ] = { .type =NLA_U32 }, + [IFLA_CAN_RESTART ] = { .type =NLA_U32 }, + [IFLA_CAN_BITTIMING ] = { .len =sizeof (struct can_bittiming ) }, + [IFLA_CAN_BITTIMING_CONST ] = { .len =sizeof (struct can_bittiming_const ) }, + [IFLA_CAN_CLOCK ] = { .len =sizeof (struct can_clock ) }, + [IFLA_CAN_BERR_COUNTER ] = { .len =sizeof (struct can_berr_counter ) }, + [IFLA_CAN_DATA_BITTIMING ] = { .len =sizeof (struct can_bittiming ) }, + [IFLA_CAN_DATA_BITTIMING_CONST ] = { .len =sizeof (struct can_bittiming_const ) }, + [IFLA_CAN_TERMINATION ] = { .type =NLA_U16 }, }; static int can_validate(struct nlattr *tb[], struct nlattr *data[],
Signature · 1 line
2.26.2
PATCH v2 4/5 can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
In reply to Vincent MailholAdd the netlink interface for TDC parameters of struct can_tdc and can_tdc_const.
Contrary to the can_bittiming(_const) structures for which there is just a single IFLA_CAN(_DATA)_BITTMING(_CONST) entry per structure, here, an IFLA_CAN_TDC* entry is added for each of the TDC parameters of the newly introduced struct can_tdc and struct can_tdc_const.
For struct can_tdc, these are:
IFLA_CAN_TDCV
IFLA_CAN_TDCO
IFLA_CAN_TDCF
For struct can_tdc_const, these are:
IFLA_CAN_TDCV_MAX_CONST
IFLA_CAN_TDCO_MAX_CONST
IFLA_CAN_TDCF_MAX_CONST
This is done so that changes can be applied in the future to the structures without breaking the netlink interface.
All the new parameters are defined as u32. This arbitrary choice is done to mimic the other bittiming values with are also all of type u32. An u16 would have been sufficient to hold the TDC values.
--- drivers/net/can/dev/netlink.c | 74 +++++++++++++++++++++++++++++++- include/uapi/linux/can/netlink.h | 6 +++ 2 files changed, 79 insertions(+), 1 deletion(-)
drivers/net/can/dev/netlink.c +73 -1
@@ -19,6 +19,12 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { [IFLA_CAN_DATA_BITTIMING] = { .len = sizeof(struct can_bittiming) }, [IFLA_CAN_DATA_BITTIMING_CONST] = { .len = sizeof(struct can_bittiming_const) }, [IFLA_CAN_TERMINATION] = { .type = NLA_U16 }, + [IFLA_CAN_TDCV] = { .type = NLA_U32 }, + [IFLA_CAN_TDCV_MAX_CONST] = { .type = NLA_U32 }, + [IFLA_CAN_TDCO] = { .type = NLA_U32 }, + [IFLA_CAN_TDCO_MAX_CONST] = { .type = NLA_U32 }, + [IFLA_CAN_TDCF] = { .type = NLA_U32 }, + [IFLA_CAN_TDCF_MAX_CONST] = { .type = NLA_U32 }, }; static int can_validate(struct nlattr *tb[], struct nlattr *data[],
@@ -218,6 +224,51 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[], priv->termination = termval; } +if (data[IFLA_CAN_TDCV ]) { +u32 tdcv =nla_get_u32 (data[IFLA_CAN_TDCV ]); + +if (!priv->tdc_const || !priv->tdc_const->tdcv_max) +return -EOPNOTSUPP ; + +if (tdcv > priv->tdc_const->tdcv_max) +return -EINVAL ; + +if (dev->flags &IFF_UP ) +return -EBUSY ; + + priv->tdc.tdcv = tdcv; + } + +if (data[IFLA_CAN_TDCO ]) { +u32 tdco =nla_get_u32 (data[IFLA_CAN_TDCO ]); + +if (!priv->tdc_const || !priv->tdc_const->tdco_max) +return -EOPNOTSUPP ; + +if (tdco > priv->tdc_const->tdco_max) +return -EINVAL ; + +if (dev->flags &IFF_UP ) +return -EBUSY ; + + priv->tdc.tdco = tdco; + } + +if (data[IFLA_CAN_TDCF ]) { +u32 tdcf =nla_get_u32 (data[IFLA_CAN_TDCF ]); + +if (!priv->tdc_const || !priv->tdc_const->tdcf_max) +return -EOPNOTSUPP ; + +if (tdcf > priv->tdc_const->tdcf_max) +return -EINVAL ; + +if (dev->flags &IFF_UP ) +return -EBUSY ; + + priv->tdc.tdcf = tdcf; + } +return 0 ; }
@@ -252,6 +303,16 @@ static size_t can_get_size(const struct net_device *dev) size +=nla_total_size (sizeof (*priv->data_bitrate_const) * priv->data_bitrate_const_cnt); size +=sizeof (priv->bitrate_max);/* IFLA_CAN_BITRATE_MAX */ +if (priv->tdc.tdco) { + size +=nla_total_size (sizeof (u32));/* IFLA_CAN_TDCV */ + size +=nla_total_size (sizeof (u32));/* IFLA_CAN_TDCO */ + size +=nla_total_size (sizeof (u32));/* IFLA_CAN_TDCF */ + } +if (priv->tdc_const) { + size +=nla_total_size (sizeof (u32));/* IFLA_CAN_TDCV_MAX_CONST */ + size +=nla_total_size (sizeof (u32));/* IFLA_CAN_TDCO_MAX_CONST */ + size +=nla_total_size (sizeof (u32));/* IFLA_CAN_TDCF_MAX_CONST */ + }return size; }
@@ -313,7 +374,18 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) (nla_put (skb,IFLA_CAN_BITRATE_MAX ,sizeof (priv->bitrate_max), - &priv->bitrate_max)) + &priv->bitrate_max)) || + + (priv->tdc_const && + (nla_put_u32 (skb,IFLA_CAN_TDCV , priv->tdc.tdcv) || +nla_put_u32 (skb,IFLA_CAN_TDCO , priv->tdc.tdco) || +nla_put_u32 (skb,IFLA_CAN_TDCF , priv->tdc.tdcf) || +nla_put_u32 (skb,IFLA_CAN_TDCV_MAX_CONST , + priv->tdc_const->tdcv_max) || +nla_put_u32 (skb,IFLA_CAN_TDCO_MAX_CONST , + priv->tdc_const->tdco_max) || +nla_put_u32 (skb,IFLA_CAN_TDCF_MAX_CONST , + priv->tdc_const->tdcf_max))) ) return -EMSGSIZE;
include/uapi/linux/can/netlink.h +6 -0
@@ -134,6 +134,12 @@ enum {IFLA_CAN_BITRATE_CONST ,IFLA_CAN_DATA_BITRATE_CONST ,IFLA_CAN_BITRATE_MAX , +IFLA_CAN_TDCV , +IFLA_CAN_TDCO , +IFLA_CAN_TDCF , +IFLA_CAN_TDCV_MAX_CONST , +IFLA_CAN_TDCO_MAX_CONST , +IFLA_CAN_TDCF_MAX_CONST , __IFLA_CAN_MAX };
Signature · 1 line
2.26.2
Re: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
Quoted 6 lines · Vincent Mailhol
drivers/net/can/dev/netlink.c +0
-0
drivers/net/can/dev/netlink.c static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { · line 28
Quoted 10 lines
drivers/net/can/dev/netlink.c +6
-0@@ -19,6 +19,12 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { [IFLA_CAN_DATA_BITTIMING] = { .len = sizeof(struct can_bittiming) }, [IFLA_CAN_DATA_BITTIMING_CONST] = { .len = sizeof(struct can_bittiming_const) }, [IFLA_CAN_TERMINATION] = { .type = NLA_U16 }, + [IFLA_CAN_TDCV] = { .type = NLA_U32 }, + [IFLA_CAN_TDCV_MAX_CONST] = { .type = NLA_U32 }, + [IFLA_CAN_TDCO] = { .type = NLA_U32 }, + [IFLA_CAN_TDCO_MAX_CONST] = { .type = NLA_U32 }, + [IFLA_CAN_TDCF] = { .type = NLA_U32 }, + [IFLA_CAN_TDCF_MAX_CONST] = { .type = NLA_U32 }, };
Looking back at my patch, I just realized that the values are not ordered in a consistent way. Here, I alternate between the TDCx and the TDCx_CONST...
Quoted 8 lines
drivers/net/can/dev/netlink.c +0
-0include/uapi/linux/can/netlink.h +0
-0@@ -134,6 +134,12 @@ enum { IFLA_CAN_BITRATE_CONST,
include/uapi/linux/can/netlink.h enum { · line 144
Quoted 10 lines
include/uapi/linux/can/netlink.h +6
-0IFLA_CAN_DATA_BITRATE_CONST ,IFLA_CAN_BITRATE_MAX , +IFLA_CAN_TDCV , +IFLA_CAN_TDCO , +IFLA_CAN_TDCF , +IFLA_CAN_TDCV_MAX_CONST , +IFLA_CAN_TDCO_MAX_CONST , +IFLA_CAN_TDCF_MAX_CONST , __IFLA_CAN_MAX };
... and there, all the TDCx and the TDCx_CONST are grouped together.
Marc, because the patches are already in the linux-can-next/testing, how should I proceed to fix this? Should I resend the full patch series with the changes or can I just prepare one patch and ask you to squash it?
Yours sincerely,
Vincent
Marc Kleine-Budde
maintainerRe: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
Quoted 44 lines · Vincent MAILHOL
Quoted 6 lines · Vincent Mailhol
drivers/net/can/dev/netlink.c +0
-0drivers/net/can/dev/netlink.c static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { · line 28
Quoted 10 lines
drivers/net/can/dev/netlink.c +6
-0@@ -19,6 +19,12 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { [IFLA_CAN_DATA_BITTIMING] = { .len = sizeof(struct can_bittiming) }, [IFLA_CAN_DATA_BITTIMING_CONST] = { .len = sizeof(struct can_bittiming_const) }, [IFLA_CAN_TERMINATION] = { .type = NLA_U16 }, + [IFLA_CAN_TDCV] = { .type = NLA_U32 }, + [IFLA_CAN_TDCV_MAX_CONST] = { .type = NLA_U32 }, + [IFLA_CAN_TDCO] = { .type = NLA_U32 }, + [IFLA_CAN_TDCO_MAX_CONST] = { .type = NLA_U32 }, + [IFLA_CAN_TDCF] = { .type = NLA_U32 }, + [IFLA_CAN_TDCF_MAX_CONST] = { .type = NLA_U32 }, };Looking back at my patch, I just realized that the values are not ordered in a consistent way. Here, I alternate between the TDCx and the
TDCx_CONST...Quoted 8 lines
drivers/net/can/dev/netlink.c +0
-0include/uapi/linux/can/netlink.h +0
-0@@ -134,6 +134,12 @@ enum { IFLA_CAN_BITRATE_CONST,include/uapi/linux/can/netlink.h enum { · line 144
Quoted 10 lines
include/uapi/linux/can/netlink.h +6
-0IFLA_CAN_DATA_BITRATE_CONST ,IFLA_CAN_BITRATE_MAX , +IFLA_CAN_TDCV , +IFLA_CAN_TDCO , +IFLA_CAN_TDCF , +IFLA_CAN_TDCV_MAX_CONST , +IFLA_CAN_TDCO_MAX_CONST , +IFLA_CAN_TDCF_MAX_CONST , __IFLA_CAN_MAX };... and there, all the TDCx and the
TDCx_CONSTare grouped together.
Quoted 4 lines
Marc, because the patches are already in the linux-can-next/testing, how should I proceed to fix this? Should I resend the full patch series with the changes or can I just prepare one patch and ask you to squash it?
Please send an incremental patch and I'll squash it.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Marc Kleine-Budde
maintainerRe: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
In reply to Vincent MailholQuoted 18 lines · Vincent Mailhol
Add the netlink interface for TDC parameters of struct
can_tdcandcan_tdc_const.Contrary to the
can_bittiming(_const)structures for which there is just a single IFLA_CAN(_DATA)_BITTMING(_CONST) entry per structure, here, an IFLA_CAN_TDC* entry is added for each of the TDC parameters of the newly introduced structcan_tdcand structcan_tdc_const.For struct
can_tdc, these are:
IFLA_CAN_TDCV
IFLA_CAN_TDCO
IFLA_CAN_TDCFFor struct
can_tdc_const, these are:
IFLA_CAN_TDCV_MAX_CONST
IFLA_CAN_TDCO_MAX_CONST
IFLA_CAN_TDCF_MAX_CONST
Quoted 6 lines
This is done so that changes can be applied in the future to the structures without breaking the netlink interface.
All the new parameters are defined as u32. This arbitrary choice is done to mimic the other bittiming values with are also all of type u32. An u16 would have been sufficient to hold the TDC values.
I just had a look at the ethtool-netlink interface:
| Documentation/networking/ethtool-netlink.rst
this is much better designed than the CAN netlink interface. It was done by the pros and much later than CAN. :D So I'd like to have a similar structure for new CAN netlink stuff.
So I think I'll remove this patch for now from can-next-testing. The kernel internal interface to tdc is still OK, we can leave it as is and change it if needed. But netlink is user space and I'd like to have it properly designed.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
Quoted 30 lines · Marc Kleine-Budde
Quoted 18 lines · Vincent Mailhol
Add the netlink interface for TDC parameters of struct
can_tdcandcan_tdc_const.Contrary to the
can_bittiming(_const)structures for which there is just a single IFLA_CAN(_DATA)_BITTMING(_CONST) entry per structure, here, an IFLA_CAN_TDC* entry is added for each of the TDC parameters of the newly introduced structcan_tdcand structcan_tdc_const.For struct
can_tdc, these are:
IFLA_CAN_TDCV
IFLA_CAN_TDCO
IFLA_CAN_TDCFFor struct
can_tdc_const, these are:
IFLA_CAN_TDCV_MAX_CONST
IFLA_CAN_TDCO_MAX_CONST
IFLA_CAN_TDCF_MAX_CONSTQuoted 6 lines
This is done so that changes can be applied in the future to the structures without breaking the netlink interface.
All the new parameters are defined as u32. This arbitrary choice is done to mimic the other bittiming values with are also all of type u32. An u16 would have been sufficient to hold the TDC values.
I just had a look at the ethtool-netlink interface:
|
Documentation/networking/ethtool-netlink.rst
Quoted 8 lines
this is much better designed than the CAN netlink interface. It was done by the pros and much later than CAN. :D So I'd like to have a similar structure for new CAN netlink stuff.
So I think I'll remove this patch for now from can-next-testing. The kernel internal interface to tdc is still OK, we can leave it as is and change it if needed. But netlink is user space and I'd like to have it properly designed.
Understood. However, I will need more time to read and understand the ethtool-netlink interface. The new patch will come later, I do not know when.
Yours sincerely,
Vincent
Marc Kleine-Budde
maintainerRe: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
Quoted 8 lines · Vincent MAILHOL
Quoted 8 lines
I just had a look at the ethtool-netlink interface:
|
Documentation/networking/ethtool-netlink.rstthis is much better designed than the CAN netlink interface. It was done by the pros and much later than CAN. :D So I'd like to have a similar structure for new CAN netlink stuff.
Quoted 8 lines
Quoted 4 lines
So I think I'll remove this patch for now from can-next-testing. The kernel internal interface to tdc is still OK, we can leave it as is and change it if needed. But netlink is user space and I'd like to have it properly designed.
Understood. However, I will need more time to read and understand the ethtool-netlink interface. The new patch will come later, I do not know when.
No Problem
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
Hi Marc,
Quoted 14 lines · Marc Kleine-Budde
Quoted 13 lines · Vincent MAILHOL
Quoted 12 lines
I just had a look at the ethtool-netlink interface:
|
Documentation/networking/ethtool-netlink.rstthis is much better designed than the CAN netlink interface. It was done by the pros and much later than CAN. :D So I'd like to have a similar structure for new CAN netlink stuff.
So I think I'll remove this patch for now from can-next-testing. The kernel internal interface to tdc is still OK, we can leave it as is and change it if needed. But netlink is user space and I'd like to have it properly designed.
Quoted 5 lines
Quoted 3 lines
Understood. However, I will need more time to read and understand the ethtool-netlink interface. The new patch will come later, I do not know when.
No Problem
I started to look at Ethtool netlink, but as far as my understanding goes, this seems purely restricted to the ethtool application (i.e. not to iproute2). I double checked the latest versions of iproute2 but there isn’t a single #include <linux/ethtool_netlink.h> nor anything else related to that new API.
Please let me know if I missed the point.
Yours sincerely,
Vincent
Marc Kleine-Budde
maintainerRe: [PATCH v2 4/5] can: add netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
Quoted 23 lines · Vincent MAILHOL
Hi Marc,
Quoted 14 lines · Marc Kleine-Budde
Quoted 13 lines · Vincent MAILHOL
Quoted 12 lines
I just had a look at the ethtool-netlink interface:
|
Documentation/networking/ethtool-netlink.rstthis is much better designed than the CAN netlink interface. It was done by the pros and much later than CAN. :D So I'd like to have a similar structure for new CAN netlink stuff.
So I think I'll remove this patch for now from can-next-testing. The kernel internal interface to tdc is still OK, we can leave it as is and change it if needed. But netlink is user space and I'd like to have it properly designed.
Quoted 5 lines
Quoted 3 lines
Understood. However, I will need more time to read and understand the ethtool-netlink interface. The new patch will come later, I do not know when.
No Problem
Quoted 7 lines
I started to look at Ethtool netlink, but as far as my understanding goes, this seems purely restricted to the ethtool application (i.e. not to iproute2). I double checked the latest versions of iproute2 but there isn’t a single #include <
linux/ethtool_netlink.h> nor anything else related to that new API.Please let me know if I missed the point.
For example have a look at the RINGS_GET of ethtool-netlink.rst:
| RINGS_GET | ========= | | Gets ring sizes like ``ETHTOOL_GRINGPARAM`` ioctl request. | | Request contents: | | ==================================== ====== ========================== | ``ETHTOOL_A_RINGS_HEADER`` nested request header | ==================================== ====== ========================== | | Kernel response contents: | | ==================================== ====== ========================== | ``ETHTOOL_A_RINGS_HEADER`` nested reply header | ``ETHTOOL_A_RINGS_RX_MAX`` u32 max size of RX ring | ``ETHTOOL_A_RINGS_RX_MINI_MAX`` u32 max size of RX mini ring | ``ETHTOOL_A_RINGS_RX_JUMBO_MAX`` u32 max size of RX jumbo ring | ``ETHTOOL_A_RINGS_TX_MAX`` u32 max size of TX ring | ``ETHTOOL_A_RINGS_RX`` u32 size of RX ring | ``ETHTOOL_A_RINGS_RX_MINI`` u32 size of RX mini ring | ``ETHTOOL_A_RINGS_RX_JUMBO`` u32 size of RX jumbo ring | ``ETHTOOL_A_RINGS_TX`` u32 size of TX ring | ==================================== ====== ==========================
The response consists of a header and several nested values. This looks to me to be the netlink way to serialize a C-struct. If I understand your code correctly it was just the values without the nested header.
| RINGS_SET | ========= | | Sets ring sizes like ``ETHTOOL_SRINGPARAM`` ioctl request. | | Request contents: | | ==================================== ====== ========================== | ``ETHTOOL_A_RINGS_HEADER`` nested reply header | ``ETHTOOL_A_RINGS_RX`` u32 size of RX ring | ``ETHTOOL_A_RINGS_RX_MINI`` u32 size of RX mini ring | ``ETHTOOL_A_RINGS_RX_JUMBO`` u32 size of RX jumbo ring | ``ETHTOOL_A_RINGS_TX`` u32 size of TX ring | ==================================== ====== ========================== | | Kernel checks that requested ring sizes do not exceed limits reported by | driver. Driver may impose additional constraints and may not suspport all | attributes.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 5/5 can: bittiming: add calculation for CAN FD Transmitter Delay Compensation (TDC)
In reply to Vincent MailholThe logic for the tdco calculation is to just reuse the normal sample
point: tdco = sp. Because the sample point is expressed in tenth of percent and the tdco is expressed in time quanta, a conversion is needed.
At the end,
ssp = tdcv + tdco
= tdcv + sp.
Another popular method is to set tdco to the middle of the bit:
tdc->tdco = can_bit_time(dbt) / 2
During benchmark tests, we could not find a clear advantages for one of the two methods.
The tdco calculation is triggered each time the data_bittiming is changed so that users relying on automated calculation can use the netlink interface the exact same way without need of new parameters. For example, a command such as:
ip link set canX type can bitrate 500000 dbitrate 4000000 fd on
would trigger the calculation.
The user using CONFIG_CAN_CALC_BITTIMING who does not want automated calculation needs to manually set tdco to zero.
For example with:
ip link set canX type can tdco 0 bitrate 500000 dbitrate 4000000 fd on
(if the tdco parameter is provided in a previous command, it will be overwritten).
If tdcv is set to zero (default), it is automatically calculated by the transiver for each frame. As such, there is no code in the kernel to calculate it.
tdcf has no automated calculation functions because we could not figure out a formula for this parameter.
--- drivers/net/can/dev/bittiming.c | 23 +++++++++++++++++++++++ drivers/net/can/dev/netlink.c | 1 + include/linux/can/bittiming.h | 6 ++++++ 3 files changed, 30 insertions(+)
drivers/net/can/dev/bittiming.c +23 -0
@@ -174,6 +174,29 @@ int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, return 0; } + +void can_calc_tdco (struct net_device *dev) +{ +struct can_priv *priv =netdev_priv (dev); +const struct can_bittiming *dbt = &priv->data_bittiming; +struct can_tdc *tdc = &priv->tdc; +const struct can_tdc_const *tdc_const = priv->tdc_const; + +if (!tdc_const) +return ; + +/* As specified in ISO 11898-1 section 11.3.3 "Transmitter +* delay compensation" (TDC) is only applicable if data BRP is +* one or two. +*/ +if (dbt->brp ==1 || dbt->brp ==2 ) { +/* Reuse "normal" sample point and convert it to time quanta */ + tdc->tdco =min (can_bit_time (dbt) * dbt->sample_point /1000 , + tdc_const->tdco_max); + }else { + tdc->tdco =0 ; + } +}#endif /* CONFIG_CAN_CALC_BITTIMING */ /* Checks the validity of the specified bit-timing parameters prop_seg,
drivers/net/can/dev/netlink.c +1 -0
@@ -183,6 +183,7 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[], priv->data_bitrate_const_cnt);if (err)return err; +can_calc_tdco (dev);if (priv->bitrate_max && dbt.bitrate > priv->bitrate_max) { netdev_err(dev, "canfd data bitrate surpasses transceiver capabilities of %d bps\n",
include/linux/can/bittiming.h +6 -0
@@ -78,6 +78,8 @@ struct can_tdc_const {#ifdef CONFIG_CAN_CALC_BITTIMING int can_calc_bittiming (struct net_device *dev,struct can_bittiming *bt,const struct can_bittiming_const *btc); + +void can_calc_tdco (struct net_device *dev);#else /* !CONFIG_CAN_CALC_BITTIMING */ static inline int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
@@ -86,6 +88,10 @@ can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,netdev_err (dev,"bit-timing calculation not available\n" );return -EINVAL ; } + +static inline void can_calc_tdco (struct net_device *dev) +{ +}#endif /* CONFIG_CAN_CALC_BITTIMING */ int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,
Signature · 1 line
2.26.2