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. Marc -- 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 |
Attachment:
signature.asc
Description: PGP signature