diff mbox series

[net-next,01/33] can: kvaser_usb: Add len8_dlc support

Message ID 20230622082658.571150-2-mkl@pengutronix.de (mailing list archive)
State Accepted
Commit 843b84640349e56ab96812cd68c19ed7021f4606
Delegated to: Netdev Maintainers
Headers show
Series [net-next,01/33] can: kvaser_usb: Add len8_dlc support | expand

Checks

Context Check Description
netdev/series_format warning Pull request is its own cover letter; Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 5 maintainers not CCed: socketcan@hartkopp.net wg@grandegger.com anssi.hannula@bitwise.fi pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: Patch version information should be after the --- line WARNING: line length of 81 exceeds 80 columns WARNING: line length of 86 exceeds 80 columns WARNING: line length of 90 exceeds 80 columns WARNING: line length of 96 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Marc Kleine-Budde June 22, 2023, 8:26 a.m. UTC
From: Carsten Schmidt <carsten.schmidt-achim@t-online.de>

Add support for the Classical CAN raw DLC functionality to send and
receive DLC values from 9 .. 15.

v1: https://lore.kernel.org/all/20230506105529.4023-1-carsten.schmidt-achim@t-online.de

Signed-off-by: Carsten Schmidt <carsten.schmidt-achim@t-online.de>
Tested-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://lore.kernel.org/r/20230516125332.82894-1-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c  |  2 +-
 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 13 +++++++++----
 drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c  |  6 +++---
 3 files changed, 13 insertions(+), 8 deletions(-)


base-commit: d49b9b07725f5dfa3344dc3eed59b8ccc0a0ddbc

Comments

patchwork-bot+netdevbpf@kernel.org June 23, 2023, 3:10 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Thu, 22 Jun 2023 10:26:26 +0200 you wrote:
> From: Carsten Schmidt <carsten.schmidt-achim@t-online.de>
> 
> Add support for the Classical CAN raw DLC functionality to send and
> receive DLC values from 9 .. 15.
> 
> v1: https://lore.kernel.org/all/20230506105529.4023-1-carsten.schmidt-achim@t-online.de
> 
> [...]

Here is the summary with links:
  - [net-next,01/33] can: kvaser_usb: Add len8_dlc support
    https://git.kernel.org/netdev/net-next/c/843b84640349
  - [net-next,02/33] can: dev: add transceiver capabilities to xilinx_can
    https://git.kernel.org/netdev/net-next/c/d7588f02e8d8
  - [net-next,03/33] can: esd_usb: Make use of existing kernel macros
    https://git.kernel.org/netdev/net-next/c/1ad549cf980c
  - [net-next,04/33] can: esd_usb: Replace initializer macros used for struct can_bittiming_const
    https://git.kernel.org/netdev/net-next/c/5a4dd8796d77
  - [net-next,05/33] can: esd_usb: Use consistent prefixes for macros
    https://git.kernel.org/netdev/net-next/c/9dc3a695da58
  - [net-next,06/33] can: esd_usb: Prefix all structures with the device name
    https://git.kernel.org/netdev/net-next/c/8ef426e1f605
  - [net-next,07/33] can: esd_usb: Replace hardcoded message length given to USB commands
    https://git.kernel.org/netdev/net-next/c/299a557651d7
  - [net-next,08/33] can: esd_usb: Don't bother the user with nonessential log message
    https://git.kernel.org/netdev/net-next/c/1336ca2d4601
  - [net-next,09/33] can: esd_usb: Make use of kernel macros BIT() and GENMASK()
    https://git.kernel.org/netdev/net-next/c/33665fdbd7ff
  - [net-next,10/33] can: esd_usb: Use consistent prefix ESD_USB_ for macros
    https://git.kernel.org/netdev/net-next/c/8a99f2ada0b8
  - [net-next,11/33] can: sja1000: Prepare the use of a threaded handler
    https://git.kernel.org/netdev/net-next/c/af7647a0b4b5
  - [net-next,12/33] can: sja1000: Prevent overrun stalls with a soft reset on Renesas SoCs
    https://git.kernel.org/netdev/net-next/c/717c6ec241b5
  - [net-next,13/33] can: rx-offload: fix coding style
    https://git.kernel.org/netdev/net-next/c/fe6027fe097a
  - [net-next,14/33] can: ti_hecc: fix coding style
    https://git.kernel.org/netdev/net-next/c/8a9d8a3c8a05
  - [net-next,15/33] can: m_can: fix coding style
    https://git.kernel.org/netdev/net-next/c/3d68f116ccdf
  - [net-next,16/33] can: length: fix description of the RRS field
    https://git.kernel.org/netdev/net-next/c/10711b11102b
  - [net-next,17/33] can: length: fix bitstuffing count
    https://git.kernel.org/netdev/net-next/c/9fde4c557f78
  - [net-next,18/33] can: length: refactor frame lengths definition to add size in bits
    (no matching commit)
  - [net-next,19/33] can: kvaser_pciefd: Remove useless write to interrupt register
    https://git.kernel.org/netdev/net-next/c/7c921556c04f
  - [net-next,20/33] can: kvaser_pciefd: Remove handler for unused KVASER_PCIEFD_PACK_TYPE_EFRAME_ACK
    https://git.kernel.org/netdev/net-next/c/76c66ddf7f89
  - [net-next,21/33] can: kvaser_pciefd: Add function to set skb hwtstamps
    https://git.kernel.org/netdev/net-next/c/2d55e9f9b442
  - [net-next,22/33] can: kvaser_pciefd: Set hardware timestamp on transmitted packets
    https://git.kernel.org/netdev/net-next/c/ec681b91befa
  - [net-next,23/33] can: kvaser_pciefd: Define unsigned constants with type suffix 'U'
    https://git.kernel.org/netdev/net-next/c/2c470dbbd32f
  - [net-next,24/33] can: uapi: move CAN_RAW_FILTER_MAX definition to raw.h
    https://git.kernel.org/netdev/net-next/c/735d86a8aaf6
  - [net-next,25/33] can: kvaser_pciefd: Remove SPI flash parameter read functionality
    https://git.kernel.org/netdev/net-next/c/c496adafee68
  - [net-next,26/33] can: kvaser_pciefd: Sort includes in alphabetic order
    https://git.kernel.org/netdev/net-next/c/1b83d0ba1c11
  - [net-next,27/33] can: kvaser_pciefd: Rename device ID defines
    https://git.kernel.org/netdev/net-next/c/488c07b441f9
  - [net-next,28/33] can: kvaser_pciefd: Change return type for kvaser_pciefd_{receive,transmit,set_tx}_irq()
    https://git.kernel.org/netdev/net-next/c/24aecf553701
  - [net-next,29/33] can: kvaser_pciefd: Sort register definitions
    https://git.kernel.org/netdev/net-next/c/69335013c451
  - [net-next,30/33] can: kvaser_pciefd: Use FIELD_{GET,PREP} and GENMASK where appropriate
    https://git.kernel.org/netdev/net-next/c/954fb21268dd
  - [net-next,31/33] can: kvaser_pciefd: Add len8_dlc support
    https://git.kernel.org/netdev/net-next/c/f07008a21364
  - [net-next,32/33] can: kvaser_pciefd: Refactor code
    https://git.kernel.org/netdev/net-next/c/f4845741e422
  - [net-next,33/33] can: kvaser_pciefd: Use TX FIFO size read from CAN controller
    https://git.kernel.org/netdev/net-next/c/6fdcd64ec34d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index 7135ec851341..71ef4db5c09f 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -816,7 +816,7 @@  static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel)
 	init_completion(&priv->stop_comp);
 	init_completion(&priv->flush_comp);
 	init_completion(&priv->get_busparams_comp);
-	priv->can.ctrlmode_supported = 0;
+	priv->can.ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC;
 
 	priv->dev = dev;
 	priv->netdev = netdev;
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index ef341c4254fc..c7ba768dfe17 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -1263,7 +1263,7 @@  static void kvaser_usb_hydra_rx_msg_std(const struct kvaser_usb *dev,
 	if (flags & KVASER_USB_HYDRA_CF_FLAG_OVERRUN)
 		kvaser_usb_can_rx_over_error(priv->netdev);
 
-	cf->len = can_cc_dlc2len(cmd->rx_can.dlc);
+	can_frame_set_cc_len((struct can_frame *)cf, cmd->rx_can.dlc, priv->can.ctrlmode);
 
 	if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) {
 		cf->can_id |= CAN_RTR_FLAG;
@@ -1342,7 +1342,7 @@  static void kvaser_usb_hydra_rx_msg_ext(const struct kvaser_usb *dev,
 		if (flags & KVASER_USB_HYDRA_CF_FLAG_ESI)
 			cf->flags |= CANFD_ESI;
 	} else {
-		cf->len = can_cc_dlc2len(dlc);
+		can_frame_set_cc_len((struct can_frame *)cf, dlc, priv->can.ctrlmode);
 	}
 
 	if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) {
@@ -1442,7 +1442,7 @@  kvaser_usb_hydra_frame_to_cmd_ext(const struct kvaser_usb_net_priv *priv,
 	struct kvaser_usb *dev = priv->dev;
 	struct kvaser_cmd_ext *cmd;
 	struct canfd_frame *cf = (struct canfd_frame *)skb->data;
-	u8 dlc = can_fd_len2dlc(cf->len);
+	u8 dlc;
 	u8 nbr_of_bytes = cf->len;
 	u32 flags;
 	u32 id;
@@ -1467,6 +1467,11 @@  kvaser_usb_hydra_frame_to_cmd_ext(const struct kvaser_usb_net_priv *priv,
 
 	cmd->len = cpu_to_le16(*cmd_len);
 
+	if (can_is_canfd_skb(skb))
+		dlc = can_fd_len2dlc(cf->len);
+	else
+		dlc = can_get_cc_dlc((struct can_frame *)cf, priv->can.ctrlmode);
+
 	cmd->tx_can.databytes = nbr_of_bytes;
 	cmd->tx_can.dlc = dlc;
 
@@ -1542,7 +1547,7 @@  kvaser_usb_hydra_frame_to_cmd_std(const struct kvaser_usb_net_priv *priv,
 		id = cf->can_id & CAN_SFF_MASK;
 	}
 
-	cmd->tx_can.dlc = cf->len;
+	cmd->tx_can.dlc = can_get_cc_dlc(cf, priv->can.ctrlmode);
 
 	flags = (cf->can_id & CAN_EFF_FLAG ?
 		 KVASER_USB_HYDRA_CF_FLAG_EXTENDED_ID : 0);
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 1c2f99ce4c6c..23bd7574b1c7 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -573,7 +573,7 @@  kvaser_usb_leaf_frame_to_cmd(const struct kvaser_usb_net_priv *priv,
 			cmd->u.tx_can.data[1] = cf->can_id & 0x3f;
 		}
 
-		cmd->u.tx_can.data[5] = cf->len;
+		cmd->u.tx_can.data[5] = can_get_cc_dlc(cf, priv->can.ctrlmode);
 		memcpy(&cmd->u.tx_can.data[6], cf->data, cf->len);
 
 		if (cf->can_id & CAN_RTR_FLAG)
@@ -1349,7 +1349,7 @@  static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,
 		else
 			cf->can_id &= CAN_SFF_MASK;
 
-		cf->len = can_cc_dlc2len(cmd->u.leaf.log_message.dlc);
+		can_frame_set_cc_len(cf, cmd->u.leaf.log_message.dlc & 0xF, priv->can.ctrlmode);
 
 		if (cmd->u.leaf.log_message.flags & MSG_FLAG_REMOTE_FRAME)
 			cf->can_id |= CAN_RTR_FLAG;
@@ -1367,7 +1367,7 @@  static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,
 			cf->can_id |= CAN_EFF_FLAG;
 		}
 
-		cf->len = can_cc_dlc2len(rx_data[5]);
+		can_frame_set_cc_len(cf, rx_data[5] & 0xF, priv->can.ctrlmode);
 
 		if (cmd->u.rx_can_header.flag & MSG_FLAG_REMOTE_FRAME)
 			cf->can_id |= CAN_RTR_FLAG;