Re: [RFC PATCH v6 5/7] can: canxl: update CAN infrastructure for CAN XL frames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 27.07.22 16:04, Marc Kleine-Budde wrote:
On 24.07.2022 09:44:00, Oliver Hartkopp wrote:
- add new ETH_P_CANXL ethernet protocol type
- update skb checks for CAN XL
- add alloc_canxl_skb() which now needs a data length parameter
- introduce init_can_skb_reserve() to reduce code duplication

Signed-off-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>
---
  drivers/net/can/dev/skb.c     | 72 ++++++++++++++++++++++++++---------
  include/linux/can/skb.h       | 23 ++++++++++-
  include/uapi/linux/if_ether.h |  1 +
  net/can/af_can.c              | 25 +++++++++++-
  4 files changed, 101 insertions(+), 20 deletions(-)

diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
index ea9ea0128c48..e9e8fcbaa7be 100644
--- a/drivers/net/can/dev/skb.c
+++ b/drivers/net/can/dev/skb.c
[...]
+struct sk_buff *alloc_canxl_skb(struct net_device *dev,
+				struct canxl_frame **cfx,
+				unsigned int data_len)
+{
+	struct sk_buff *skb;
+
+	if (data_len < CANXL_MIN_DLEN || data_len > CANXL_MAX_DLEN)
+		goto out_error;
+
+	skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) +
+			       CANXL_HDR_SIZE + data_len);
+	if (unlikely(!skb))
+		goto out_error;
+
+	skb->protocol = htons(ETH_P_CANXL);
+	init_can_skb_reserve(skb);
+	can_skb_prv(skb)->ifindex = dev->ifindex;
+
+	*cfx = skb_put_zero(skb, CANXL_HDR_SIZE + data_len);
+
+	/* set CAN XL flag and length information by default */
+	(*cfx)->flags = CANXL_XLF;
+	(*cfx)->len = data_len;
+
+	return skb;
+
+out_error:
+		*cfx = NULL;
+
+		return NULL;

Nitpick:
Indent with one tab only here.

Of course! Copy/paste from the if-statement where it originally was m(

Thanks for the review!

After these rounds I really feel better with the skb helpers which also brought some clarity to other code that needed to separate between CAN and CAN FD processing.

Best regards,
Oliver



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux