Skip to contentSkip to conversation

can: gw: support modification of Classical CAN DLCs

PATCH In review Oliver Hartkopp 2 participants 2 messages Nov 19, 2020

Subsystems (2)
lore
Share & tools
lore

Oliver Hartkopp

author maintainer
#0 lore raw

PATCH v2 1/1 can: gw: support modification of Classical CAN DLCs

Add support for data length code modifications for Classical CAN.

The netlink configuration interface always allowed to pass any value that fits into a byte, therefore only the modification process had to be extended to handle the raw DLC represenation of Classical CAN frames.

When a DLC value from 0 .. F is provided for Classical CAN frame modifications the 'len' value is modified as-is with the exception that potentially existing 9 .. F DLC values in the len8_dlc element are moved to the 'len' element for the modification operation by mod_retrieve_ccdlc().

After the modification the Classical CAN frame DLC information is brought back into the correct format by mod_store_ccdlc() which is filling 'len' and 'len8_dlc' accordingly.

---
v2: remove unnecessary mod_retrieve_ccdlc() for 'set' modification

---
 include/uapi/linux/can/gw.h |  4 +-
 net/can/gw.c                | 78 +++++++++++++++++++++++++++++++++----
 2 files changed, 72 insertions(+), 10 deletions(-)
include/uapi/linux/can/gw.h +2 -2
index c2190bbe21d8..e4f0957554f3 100644
@@ -96,12 +96,12 @@ enum {
 
 #define CGW_MOD_FUNCS 4 /* AND OR XOR SET */
 
 /* CAN frame elements that are affected by curr. 3 CAN frame modifications */
 #define CGW_MOD_ID	0x01
-#define CGW_MOD_DLC	0x02		/* contains the data length in bytes */
-#define CGW_MOD_LEN	CGW_MOD_DLC	/* CAN FD length representation */
+#define CGW_MOD_DLC	0x02		/* Classical CAN data length code */
+#define CGW_MOD_LEN	CGW_MOD_DLC	/* CAN FD (plain) data length */
 #define CGW_MOD_DATA	0x04
 #define CGW_MOD_FLAGS	0x08		/* CAN FD flags */
 
 #define CGW_FRAME_MODS 4 /* ID DLC/LEN DATA FLAGS */
 
net/can/gw.c +70 -8

128 lines not on this page · raw message

Signature · 1 line
2.29.2
#1 lore raw
Quoted 11 lines · Oliver Hartkopp

Add support for data length code modifications for Classical CAN.

The netlink configuration interface always allowed to pass any value that fits into a byte, therefore only the modification process had to be extended to handle the raw DLC represenation of Classical CAN frames.

When a DLC value from 0 .. F is provided for Classical CAN frame modifications the 'len' value is modified as-is with the exception that potentially existing 9 .. F DLC values in the len8_dlc element are moved to the 'len' element for the modification operation by mod_retrieve_ccdlc().

Quoted 8 lines

After the modification the Classical CAN frame DLC information is brought back into the correct format by mod_store_ccdlc() which is filling 'len' and 'len8_dlc' accordingly.

---
v2: remove unnecessary mod_retrieve_ccdlc() for 'set' modification

Added to linux-can-next/testing.

Thanks,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |