From: Marc Kleine-Budde <mkl@pengutronix.de>
To: davem@davemloft.net
Cc: Netdev@vger.kernel.org, kernel@pengutronix.de,
mkl@blackshift.org, linux-can@vger.kernel.org,
Reuben Dowle <Reuben.Dowle@navico.com>,
Reuben Dowle <reuben.dowle@navico.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 3/9] can: flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK
Date: Fri, 3 Feb 2012 01:51:52 +0100 [thread overview]
Message-ID: <1328230318-8962-4-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1328230318-8962-1-git-send-email-mkl@pengutronix.de>
From: Reuben Dowle <Reuben.Dowle@navico.com>
Currently the flexcan driver uses hardware local echo. This blindly
echos all transmitted frames to all receiving sockets, regardless what
CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK are set to.
This patch now submits transmitted frames to be echoed in the transmit
complete interrupt, preserving the reference to the sending
socket. This allows the can protocol to correctly handle the local
echo.
Further this patch moves tx_bytes statistic accounting into the tx_complete
handler.
Signed-off-by: Reuben Dowle <reuben.dowle@navico.com>
[mkl: move tx_bytes accounting into tx_complete handler; cleanups]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/flexcan.c | 17 +++++++----------
1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 7fd8089..ab0136f 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -269,7 +269,6 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
const struct flexcan_priv *priv = netdev_priv(dev);
- struct net_device_stats *stats = &dev->stats;
struct flexcan_regs __iomem *regs = priv->base;
struct can_frame *cf = (struct can_frame *)skb->data;
u32 can_id;
@@ -299,14 +298,11 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
flexcan_write(data, ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
}
+ can_put_echo_skb(skb, dev, 0);
+
flexcan_write(can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
flexcan_write(ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
- kfree_skb(skb);
-
- /* tx_packets is incremented in flexcan_irq */
- stats->tx_bytes += cf->can_dlc;
-
return NETDEV_TX_OK;
}
@@ -609,7 +605,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
/* transmission complete interrupt */
if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) {
- /* tx_bytes is incremented in flexcan_start_xmit */
+ stats->tx_bytes += can_get_echo_skb(dev, 0);
stats->tx_packets++;
flexcan_write((1 << FLEXCAN_TX_BUF_ID), ®s->iflag1);
netif_wake_queue(dev);
@@ -697,12 +693,13 @@ static int flexcan_chip_start(struct net_device *dev)
* only supervisor access
* enable warning int
* choose format C
+ * disable local echo
*
*/
reg_mcr = flexcan_read(®s->mcr);
reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT |
FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN |
- FLEXCAN_MCR_IDAM_C;
+ FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_SRX_DIS;
dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__, reg_mcr);
flexcan_write(reg_mcr, ®s->mcr);
@@ -970,7 +967,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
goto failed_map;
}
- dev = alloc_candev(sizeof(struct flexcan_priv), 0);
+ dev = alloc_candev(sizeof(struct flexcan_priv), 1);
if (!dev) {
err = -ENOMEM;
goto failed_alloc;
@@ -978,7 +975,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
dev->netdev_ops = &flexcan_netdev_ops;
dev->irq = irq;
- dev->flags |= IFF_ECHO; /* we support local echo in hardware */
+ dev->flags |= IFF_ECHO;
priv = netdev_priv(dev);
priv->can.clock.freq = clock_freq;
--
1.7.4.1
next prev parent reply other threads:[~2012-02-03 0:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-03 0:51 [PATCH 0/9] can: driver updates Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 1/9] can: ems_usb: Removed double netif_device_detach Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 2/9] can: dev: let can_get_echo_skb() return dlc of CAN frame Marc Kleine-Budde
2012-02-03 0:51 ` Marc Kleine-Budde [this message]
2012-02-03 0:51 ` [PATCH 4/9] can: ems_usb: Improved memory handling on ems_usb_start Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 5/9] can: plx_pci: add support for IXXAT PCI cards Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 6/9] can: pch_can: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 7/9] can: Kconfig: add more information about Intel EG20T PCH CAN controller Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 8/9] can: bfin_can/ti_hecc/mscan: add missing do_get_berr_counter callback Marc Kleine-Budde
2012-02-03 0:51 ` [PATCH 9/9] can: replace the dev_dbg/info/err/... with the new netdev_xxx macros Marc Kleine-Budde
2012-02-04 21:44 ` [PATCH 0/9] can: driver updates David Miller
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=1328230318-8962-4-git-send-email-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=Netdev@vger.kernel.org \
--cc=Reuben.Dowle@navico.com \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=mkl@blackshift.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 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).