Commit 396b3ced authored by Stefan Mätje's avatar Stefan Mätje Committed by Marc Kleine-Budde

can: drivers: add len8_dlc support for esd_usb2 CAN adapter

Support the Classical CAN raw DLC functionality to send and receive DLC values
from 9 .. 15 for the Classical CAN capable CAN network driver esd_usb that
supports the esd CAN-USB/2 and CAN-USB/Micro devices:

- esd_usb2
Signed-off-by: default avatarStefan Mätje <stefan.maetje@esd.eu>
Tested-by: default avatarStefan Mätje <stefan.maetje@esd.eu>
Link: https://lore.kernel.org/r/20201116184430.25462-2-stefan.maetje@esd.eu
[mkl: rewrapped some long lines]
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 4c01fc87
......@@ -183,7 +183,7 @@ struct esd_usb2_net_priv;
struct esd_tx_urb_context {
struct esd_usb2_net_priv *priv;
u32 echo_index;
int dlc;
int len; /* CAN payload length */
};
struct esd_usb2 {
......@@ -321,7 +321,8 @@ static void esd_usb2_rx_can_msg(struct esd_usb2_net_priv *priv,
}
cf->can_id = id & ESD_IDMASK;
cf->len = can_cc_dlc2len(msg->msg.rx.dlc & ~ESD_RTR);
can_frame_set_cc_len(cf, msg->msg.rx.dlc & ~ESD_RTR,
priv->can.ctrlmode);
if (id & ESD_EXTID)
cf->can_id |= CAN_EFF_FLAG;
......@@ -355,7 +356,7 @@ static void esd_usb2_tx_done_msg(struct esd_usb2_net_priv *priv,
if (!msg->msg.txdone.status) {
stats->tx_packets++;
stats->tx_bytes += context->dlc;
stats->tx_bytes += context->len;
can_get_echo_skb(netdev, context->echo_index);
} else {
stats->tx_errors++;
......@@ -737,7 +738,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
msg->msg.hdr.len = 3; /* minimal length */
msg->msg.hdr.cmd = CMD_CAN_TX;
msg->msg.tx.net = priv->index;
msg->msg.tx.dlc = cf->len;
msg->msg.tx.dlc = can_get_cc_dlc(cf, priv->can.ctrlmode);
msg->msg.tx.id = cpu_to_le32(cf->can_id & CAN_ERR_MASK);
if (cf->can_id & CAN_RTR_FLAG)
......@@ -769,7 +770,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
context->priv = priv;
context->echo_index = i;
context->dlc = cf->len;
context->len = cf->len;
/* hnd must not be 0 - MSB is stripped in txdone handling */
msg->msg.tx.hnd = 0x80000000 | i; /* returned in TX done message */
......@@ -988,7 +989,8 @@ static int esd_usb2_probe_one_net(struct usb_interface *intf, int index)
priv->index = index;
priv->can.state = CAN_STATE_STOPPED;
priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY;
priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_CC_LEN8_DLC;
if (le16_to_cpu(dev->udev->descriptor.idProduct) ==
USB_CANUSBM_PRODUCT_ID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment