linux/drivers/net/can/dev/length.c

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (C) 2012, 2020 Oliver Hartkopp <[email protected]>
 */

#include <linux/can/dev.h>

/* CAN DLC to real data length conversion helpers */

static const u8 dlc2len[] =;

/* get data length from raw data length code (DLC) */
u8 can_fd_dlc2len(u8 dlc)
{}
EXPORT_SYMBOL_GPL();

static const u8 len2dlc[] =;

/* map the sanitized data length to an appropriate data length code */
u8 can_fd_len2dlc(u8 len)
{}
EXPORT_SYMBOL_GPL();

/**
 * 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.
 */
unsigned int can_skb_get_frame_len(const struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();