linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: add ability to allocate CANFD frame in skb data
@ 2014-01-15  8:50 Stephane Grosjean
  2014-01-15 12:58 ` Marc Kleine-Budde
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Stephane Grosjean @ 2014-01-15  8:50 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: linux-can, Stephane Grosjean

This patch adds the ability of allocating a CANFD frame data structure in the
skb data area.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>

---
 drivers/net/can/dev.c   | 24 ++++++++++++++++++++++++
 include/linux/can/dev.h |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 13a9098..cb584ea 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -521,6 +521,30 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
 }
 EXPORT_SYMBOL_GPL(alloc_can_skb);
 
+struct sk_buff *alloc_canfd_skb(struct net_device *dev,
+				struct canfd_frame **cfd)
+{
+	struct sk_buff *skb;
+
+	skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) +
+			       sizeof(struct canfd_frame));
+	if (unlikely(!skb))
+		return NULL;
+
+	skb->protocol = htons(ETH_P_CANFD);
+	skb->pkt_type = PACKET_BROADCAST;
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+	can_skb_reserve(skb);
+	can_skb_prv(skb)->ifindex = dev->ifindex;
+
+	*cfd = (struct canfd_frame *)skb_put(skb, sizeof(struct canfd_frame));
+	memset(*cfd, 0, sizeof(struct canfd_frame));
+
+	return skb;
+}
+EXPORT_SYMBOL_GPL(alloc_canfd_skb);
+
 struct sk_buff *alloc_can_err_skb(struct net_device *dev, struct can_frame **cf)
 {
 	struct sk_buff *skb;
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index fb0ab65..dc5f902 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -124,6 +124,8 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
 void can_free_echo_skb(struct net_device *dev, unsigned int idx);
 
 struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf);
+struct sk_buff *alloc_canfd_skb(struct net_device *dev,
+				struct canfd_frame **cfd);
 struct sk_buff *alloc_can_err_skb(struct net_device *dev,
 				  struct can_frame **cf);
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] can: add ability to allocate CANFD frame in skb data
  2014-01-15  8:50 [PATCH] can: add ability to allocate CANFD frame in skb data Stephane Grosjean
@ 2014-01-15 12:58 ` Marc Kleine-Budde
  2014-01-15 13:13   ` Stephane Grosjean
  2014-01-15 17:35 ` Oliver Hartkopp
  2014-01-16 16:35 ` Marc Kleine-Budde
  2 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-01-15 12:58 UTC (permalink / raw)
  To: Stephane Grosjean, Oliver Hartkopp; +Cc: linux-can

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

On 01/15/2014 09:50 AM, Stephane Grosjean wrote:
> This patch adds the ability of allocating a CANFD frame data structure in the
> skb data area.

Do you have real CANFD hardware?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] can: add ability to allocate CANFD frame in skb data
  2014-01-15 12:58 ` Marc Kleine-Budde
@ 2014-01-15 13:13   ` Stephane Grosjean
  0 siblings, 0 replies; 5+ messages in thread
From: Stephane Grosjean @ 2014-01-15 13:13 UTC (permalink / raw)
  To: Marc Kleine-Budde, Oliver Hartkopp; +Cc: linux-can

Hi Marc,

Yes we (PEAK-System) have got onereal CANFD hardware.

Stephane

Le 15/01/2014 13:58, Marc Kleine-Budde a écrit :
> On 01/15/2014 09:50 AM, Stephane Grosjean wrote:
>> This patch adds the ability of allocating a CANFD frame data structure in the
>> skb data area.
> Do you have real CANFD hardware?
>
> Marc
>

--
PEAK-System Technik GmbH, Otto-Roehm-Strasse 69, D-64293 Darmstadt 
Geschaeftsleitung: A.Gach/U.Wilhelm,St.Nr.:007/241/13586 FA Darmstadt 
HRB-9183 Darmstadt, Ust.IdNr.:DE 202220078, WEE-Reg.-Nr.: DE39305391 
Tel.+49 (0)6151-817320 / Fax:+49 (0)6151-817329, info@peak-system.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] can: add ability to allocate CANFD frame in skb data
  2014-01-15  8:50 [PATCH] can: add ability to allocate CANFD frame in skb data Stephane Grosjean
  2014-01-15 12:58 ` Marc Kleine-Budde
@ 2014-01-15 17:35 ` Oliver Hartkopp
  2014-01-16 16:35 ` Marc Kleine-Budde
  2 siblings, 0 replies; 5+ messages in thread
From: Oliver Hartkopp @ 2014-01-15 17:35 UTC (permalink / raw)
  To: Stephane Grosjean; +Cc: linux-can

Hi Stephane,

thanks for starting the first steps here.

On 15.01.2014 09:50, Stephane Grosjean wrote:
> This patch adds the ability of allocating a CANFD frame data structure in the
> skb data area.
> 
> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
> 

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] can: add ability to allocate CANFD frame in skb data
  2014-01-15  8:50 [PATCH] can: add ability to allocate CANFD frame in skb data Stephane Grosjean
  2014-01-15 12:58 ` Marc Kleine-Budde
  2014-01-15 17:35 ` Oliver Hartkopp
@ 2014-01-16 16:35 ` Marc Kleine-Budde
  2 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2014-01-16 16:35 UTC (permalink / raw)
  To: Stephane Grosjean, Oliver Hartkopp; +Cc: linux-can

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

On 01/15/2014 09:50 AM, Stephane Grosjean wrote:
> This patch adds the ability of allocating a CANFD frame data structure in the
> skb data area.
> 
> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
> 
> ---
>  drivers/net/can/dev.c   | 24 ++++++++++++++++++++++++
>  include/linux/can/dev.h |  2 ++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 13a9098..cb584ea 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -521,6 +521,30 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
>  }
>  EXPORT_SYMBOL_GPL(alloc_can_skb);
>  
> +struct sk_buff *alloc_canfd_skb(struct net_device *dev,
> +				struct canfd_frame **cfd)

Originally "cf" stands for _c_an _f_rame, but cfd for for CAN-FD frames
ist nice, too :)

applied to can-next
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-16 16:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15  8:50 [PATCH] can: add ability to allocate CANFD frame in skb data Stephane Grosjean
2014-01-15 12:58 ` Marc Kleine-Budde
2014-01-15 13:13   ` Stephane Grosjean
2014-01-15 17:35 ` Oliver Hartkopp
2014-01-16 16:35 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).