From: Oliver Hartkopp <socketcan@hartkopp.net>
To: "Ira W. Snyder" <iws@ovro.caltech.edu>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH 1/3] can: make the echo stack keep packet information longer
Date: Mon, 09 Jul 2012 23:09:46 +0200 [thread overview]
Message-ID: <4FFB489A.1050908@hartkopp.net> (raw)
In-Reply-To: <1341863790-5645-2-git-send-email-iws@ovro.caltech.edu>
On 09.07.2012 21:56, Ira W. Snyder wrote:
> From: "Ira W. Snyder" <iws@ovro.caltech.edu>
>
> In order for the can_cmp_echo_skb() function to be able to detect
> packets received via the hardware loopback feature, all packets must be
> saved. This means we cannot drop non-loopback packets until reception
> time.
> ---
> drivers/net/can/dev.c | 41 +++++++++++++++++++++--------------------
> 1 files changed, 21 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index c5fe3a3..98e6c50 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -282,12 +282,6 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
>
> BUG_ON(idx >= priv->echo_skb_max);
>
> - /* check flag whether this packet has to be looped back */
> - if (!(dev->flags & IFF_ECHO) || skb->pkt_type != PACKET_LOOPBACK) {
> - kfree_skb(skb);
> - return;
> - }
> -
> if (!priv->echo_skb[idx]) {
> struct sock *srcsk = skb->sk;
>
> @@ -303,12 +297,6 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
>
> skb->sk = srcsk;
>
> - /* make settings for echo to reduce code in irq context */
> - skb->protocol = htons(ETH_P_CAN);
> - skb->pkt_type = PACKET_BROADCAST;
> - skb->ip_summed = CHECKSUM_UNNECESSARY;
> - skb->dev = dev;
> -
> /* save this skb for tx interrupt echo handling */
> priv->echo_skb[idx] = skb;
> } else {
> @@ -329,21 +317,34 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb);
> unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
> {
> struct can_priv *priv = netdev_priv(dev);
> + struct sk_buff *skb = priv->echo_skb[idx];
> + struct can_frame *cf;
> + u8 dlc;
>
> BUG_ON(idx >= priv->echo_skb_max);
>
> - if (priv->echo_skb[idx]) {
> - struct sk_buff *skb = priv->echo_skb[idx];
> - struct can_frame *cf = (struct can_frame *)skb->data;
> - u8 dlc = cf->can_dlc;
> + if (!skb)
> + return 0;
>
> - netif_rx(priv->echo_skb[idx]);
> - priv->echo_skb[idx] = NULL;
> + priv->echo_skb[idx] = NULL;
> + cf = (struct can_frame *)skb->data;
>
> - return dlc;
> + /* check flag whether this packet has to be looped back */
> + if (!(dev->flags & IFF_ECHO) || skb->pkt_type != PACKET_LOOPBACK) {
> + kfree_skb(skb);
> + return 0;
> }
>
> - return 0;
> + /* make settings for echo to reduce code in irq context */
This comment became pointless :-)
> + skb->protocol = htons(ETH_P_CAN);
> + skb->pkt_type = PACKET_BROADCAST;
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> + skb->dev = dev;
Hm - it's proably worth to check, if we really need to set all these values or if
skb->pkt_type = PACKET_BROADCAST;
would just be enough.
Will do so - but this is not relevant for your current patch.
> +
> + dlc = cf->can_dlc;
> + netif_rx(skb);
> +
> + return dlc;
> }
> EXPORT_SYMBOL_GPL(can_get_echo_skb);
>
Regards,
Oliver
next prev parent reply other threads:[~2012-07-09 21:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-09 19:56 [PATCH 0/3] can: janz-ican3: fix support for CAN_RAW_RECV_OWN_MSGS Ira W. Snyder
2012-07-09 19:56 ` [PATCH 1/3] can: make the echo stack keep packet information longer Ira W. Snyder
2012-07-09 21:09 ` Oliver Hartkopp [this message]
2012-07-09 19:56 ` [PATCH 2/3] can: add can_cmp_echo_skb() for echo skb comparison Ira W. Snyder
2012-07-09 19:56 ` [PATCH 3/3] can: janz-ican3: fix support for CAN_RAW_RECV_OWN_MSGS Ira W. Snyder
2012-07-09 20:57 ` Oliver Hartkopp
2012-07-09 21:16 ` Ira W. Snyder
2012-07-10 6:40 ` Wolfgang Grandegger
2012-07-09 21:05 ` [PATCH 0/3] " Oliver Hartkopp
2012-07-09 21:29 ` Ira W. Snyder
2012-07-10 6:09 ` Wolfgang Grandegger
2012-07-10 6:59 ` Wolfgang Grandegger
2012-07-10 15:22 ` Ira W. Snyder
2012-07-10 19:19 ` Oliver Hartkopp
2012-07-10 20:34 ` Wolfgang Grandegger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FFB489A.1050908@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=iws@ovro.caltech.edu \
--cc=linux-can@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.