canbusload: Fix worst-case frame length estimation
The Tindell's method used previously is incorrect. It does not account for the fact that the stuffed bits are themselves also subject to bit stuffing. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>pull/1/head
parent
2206f92de7
commit
d6b576c012
|
|
@ -246,7 +246,7 @@ unsigned can_frame_length(struct canfd_frame *frame, enum cfl_mode mode, int mtu
|
||||||
case CFL_NO_BITSTUFFING:
|
case CFL_NO_BITSTUFFING:
|
||||||
return (eff ? 67 : 47) + frame->len * 8;
|
return (eff ? 67 : 47) + frame->len * 8;
|
||||||
case CFL_WORSTCASE:
|
case CFL_WORSTCASE:
|
||||||
return ((eff ? 389 : 269) + frame->len * 48) / 5;
|
return (eff ? 80 : 55) + frame->len * 10;
|
||||||
case CFL_EXACT:
|
case CFL_EXACT:
|
||||||
return cfl_exact((struct can_frame*)frame);
|
return cfl_exact((struct can_frame*)frame);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,23 @@
|
||||||
/**
|
/**
|
||||||
* Frame length calculation modes.
|
* Frame length calculation modes.
|
||||||
*
|
*
|
||||||
* CFL_WORSTCASE corresponds to Ken Tindells *worst* case calculation
|
* CFL_WORSTCASE corresponds to *worst* case calculation for
|
||||||
* for stuff-bits (see "Guaranteeing Message Latencies on Controller
|
* stuff-bits - see (1)-(3) in [1]. The worst case number of bits on
|
||||||
* Area Network" 1st ICC'94) the needed bits on the wire can be
|
* the wire can be calculated as:
|
||||||
* calculated as:
|
|
||||||
*
|
*
|
||||||
* (34 + 8n)/5 + 47 + 8n for SFF frames (11 bit CAN-ID) => (269 + 48n)/5
|
* (34 + 8n - 1)/4 + 34 + 8n + 13 for SFF frames (11 bit CAN-ID) => 55 + 10n
|
||||||
* (54 + 8n)/5 + 67 + 8n for EFF frames (29 bit CAN-ID) => (389 + 48n)/5
|
* (54 + 8n - 1)/4 + 54 + 8n + 13 for EFF frames (29 bit CAN-ID) => 80 + 10n
|
||||||
*
|
*
|
||||||
* while 'n' is the data length code (number of payload bytes)
|
* while 'n' is the data length code (number of payload bytes)
|
||||||
*
|
*
|
||||||
|
* [1] "Controller Area Network (CAN) schedulability analysis:
|
||||||
|
* Refuted, revisited and revised", Real-Time Syst (2007)
|
||||||
|
* 35:239-272.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
enum cfl_mode {
|
enum cfl_mode {
|
||||||
CFL_NO_BITSTUFFING, /* plain bit calculation without bitstuffing */
|
CFL_NO_BITSTUFFING, /* plain bit calculation without bitstuffing */
|
||||||
CFL_WORSTCASE, /* with bitstuffing following Tindells estimation */
|
CFL_WORSTCASE, /* worst case estimation - see above */
|
||||||
CFL_EXACT, /* exact calculation of stuffed bits based on frame
|
CFL_EXACT, /* exact calculation of stuffed bits based on frame
|
||||||
* content and CRC */
|
* content and CRC */
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue