/* map the sanitized data length to an appropriate data length code */
u8 can_fd_len2dlc(u8 len)
{ /* check for length mapping table size at build time */
BUILD_BUG_ON(ARRAY_SIZE(len2dlc) != CANFD_MAX_DLEN + 1);
if (unlikely(len > CANFD_MAX_DLEN)) return CANFD_MAX_DLC;
/** * can_skb_get_frame_len() - Calculate the CAN Frame length in bytes * of a given skb. * @skb: socket buffer of a CAN message. * * Do a rough calculation: bit stuffing is ignored and length in bits * is rounded up to a length in bytes. * * Rationale: this function is to be used for the BQL functions * (netdev_sent_queue() and netdev_completed_queue()) which expect a * value in bytes. Just using skb->len is insufficient because it will * return the constant value of CAN(FD)_MTU. Doing the bit stuffing * calculation would be too expensive in term of computing resources * for no noticeable gain. * * Remarks: The payload of CAN FD frames with BRS flag are sent at a * different bitrate. Currently, the can-utils canbusload tool does * not support CAN-FD yet and so we could not run any benchmark to * measure the impact. There might be possible improvement here. * * Return: length in bytes.
*/ unsignedint can_skb_get_frame_len(conststruct sk_buff *skb)
{ conststruct canfd_frame *cf = (conststruct canfd_frame *)skb->data;
u8 len;
if (can_is_canfd_skb(skb))
len = canfd_sanitize_len(cf->len); elseif (cf->can_id & CAN_RTR_FLAG)
len = 0; else
len = cf->len;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.