* Re: [PATCH net] tcp: do not rearm RTO when future data are sacked
From: Eric Dumazet @ 2013-10-24 19:58 UTC (permalink / raw)
To: Yuchung Cheng; +Cc: davem, ncardwell, edumazet, brakmo, netdev
In-Reply-To: <1382630367-21964-1-git-send-email-ycheng@google.com>
On Thu, 2013-10-24 at 08:59 -0700, Yuchung Cheng wrote:
> Patch ed08495c3 "tcp: use RTT from SACK for RTO" always re-arms RTO upon
> obtaining a RTT sample from newly sacked data.
>
> But technically RTO should only be re-armed when the data sent before
> the last (re)transmission of write queue head are (s)acked. Otherwise
> the RTO may continue to extend during loss recovery on data sent
> in the future.
>
> Note that RTTs from ACK or timestamps do not have this problem, as the RTT
> source must be from data sent before.
>
> The new RTO re-arm policy is
> 1) Always re-arm RTO if SND.UNA is advanced
> 2) Re-arm RTO if sack RTT is available, provided the sacked data was
> sent before the last time write_queue_head was sent.
>
> Signed-off-by: Larry Brakmo <brakmo@google.com>
> Signed-off-by: Yuchung Cheng <ycheng@google.com>
> ---
> net/ipv4/tcp_input.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply
* Re: [PATCH net] tcp: fix SYNACK RTT estimation in Fast Open
From: Eric Dumazet @ 2013-10-24 20:04 UTC (permalink / raw)
To: Yuchung Cheng; +Cc: davem, ncardwell, edumazet, panweiping3, netdev
In-Reply-To: <1382629465-20310-1-git-send-email-ycheng@google.com>
On Thu, 2013-10-24 at 08:44 -0700, Yuchung Cheng wrote:
> tp->lsndtime may not always be the SYNACK timestamp if a passive
> Fast Open socket sends data before handshake completes. And if the
> remote acknowledges both the data and the SYNACK, the RTT sample
> is already taken in tcp_ack(), so no need to call
> tcp_update_ack_rtt() in tcp_synack_rtt_meas() aagain.
>
> Signed-off-by: Yuchung Cheng <ycheng@google.com>
> ---
> net/ipv4/tcp_input.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index a16b01b..305cd05 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -2871,14 +2871,19 @@ static inline bool tcp_ack_update_rtt(struct sock *sk, const int flag,
> }
>
> /* Compute time elapsed between (last) SYNACK and the ACK completing 3WHS. */
> -static void tcp_synack_rtt_meas(struct sock *sk, struct request_sock *req)
> +static void tcp_synack_rtt_meas(struct sock *sk, const u32 synack_stamp)
> {
> struct tcp_sock *tp = tcp_sk(sk);
> s32 seq_rtt = -1;
>
> - if (tp->lsndtime && !tp->total_retrans)
> - seq_rtt = tcp_time_stamp - tp->lsndtime;
> - tcp_ack_update_rtt(sk, FLAG_SYN_ACKED, seq_rtt, -1);
> + if (synack_stamp && !tp->total_retrans)
> + seq_rtt = tcp_time_stamp - synack_stamp;
> +
> + /* If the ACK acks both the SYNACK and the (Fast Open'd) data packets
> + * sent in SYN_RECV, SYNACK RTT is the smooth RTT computed in tcp_ack()
> + */
> + if (!tp->srtt)
> + tcp_ack_update_rtt(sk, FLAG_SYN_ACKED, seq_rtt, -1);
> }
>
> static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
> @@ -5587,6 +5592,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
> struct request_sock *req;
> int queued = 0;
> bool acceptable;
> + u32 synack_stamp;
>
> tp->rx_opt.saw_tstamp = 0;
>
> @@ -5669,9 +5675,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
> * so release it.
> */
> if (req) {
> + synack_stamp = tcp_rsk(req)->snt_synack;
>
Alternative would have been to set here :
tp->lsndtime = tcp_rsk(req)->snt_synack;
Because it seems TCP_INFO can return quite bogus data anyway in
info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);
> tp->total_retrans = req->num_retrans;
> reqsk_fastopen_remove(sk, req, false);
> } else {
> + synack_stamp = tp->lsndtime;
> /* Make sure socket is routed, for correct metrics. */
> icsk->icsk_af_ops->rebuild_header(sk);
> tcp_init_congestion_control(sk);
> @@ -5694,7 +5702,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
> tp->snd_una = TCP_SKB_CB(skb)->ack_seq;
> tp->snd_wnd = ntohs(th->window) << tp->rx_opt.snd_wscale;
> tcp_init_wl(tp, TCP_SKB_CB(skb)->seq);
> - tcp_synack_rtt_meas(sk, req);
> + tcp_synack_rtt_meas(sk, synack_stamp);
>
> if (tp->rx_opt.tstamp_ok)
> tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply
* [PATCH net-next 0/5] trivial changes
From: Alexander Aring @ 2013-10-24 20:51 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
This patch series includes some trivial changes to prepare the 6lowpan stack
for upcomming patch-series which mainly fix fragmentation according to rfc4944
and udp handling(which is currently broken).
Alexander Aring (5):
6lowpan: remove unnecessary ret variable
6lowpan: remove unnecessary check on err >= 0
6lowpan: use netdev_alloc_skb instead dev_alloc_skb
6lowpan: remove skb->dev assignment
6lowpan: remove unecessary break
net/ieee802154/6lowpan.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
--
1.8.4.1
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
^ permalink raw reply
* [PATCH net-next 1/5] 6lowpan: remove unnecessary ret variable
From: Alexander Aring @ 2013-10-24 20:51 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1382647904-11311-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Werner Almesberger <werner-SEdMjqphH88wryQfseakQg@public.gmane.org>
---
net/ieee802154/6lowpan.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index ff41b4d..d288035 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1120,7 +1120,7 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head,
int mlen, int plen, int offset, int type)
{
struct sk_buff *frag;
- int hlen, ret;
+ int hlen;
hlen = (type == LOWPAN_DISPATCH_FRAG1) ?
LOWPAN_FRAG1_HEAD_SIZE : LOWPAN_FRAGN_HEAD_SIZE;
@@ -1145,9 +1145,7 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head,
lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data,
frag->len);
- ret = dev_queue_xmit(frag);
-
- return ret;
+ return dev_queue_xmit(frag);
}
static int
--
1.8.4.1
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
^ permalink raw reply related
* [PATCH net-next 3/5] 6lowpan: use netdev_alloc_skb instead dev_alloc_skb
From: Alexander Aring @ 2013-10-24 20:51 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1382647904-11311-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
This patch uses the netdev_alloc_skb instead dev_alloc_skb function and
drops the seperate assignment to skb->dev.
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Werner Almesberger <werner-SEdMjqphH88wryQfseakQg@public.gmane.org>
---
net/ieee802154/6lowpan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 9057f83..7510278 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1127,12 +1127,12 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head,
lowpan_raw_dump_inline(__func__, "6lowpan fragment header", head, hlen);
- frag = dev_alloc_skb(hlen + mlen + plen + IEEE802154_MFR_SIZE);
+ frag = netdev_alloc_skb(skb->dev, hlen + mlen +
+ plen + IEEE802154_MFR_SIZE);
if (!frag)
return -ENOMEM;
frag->priority = skb->priority;
- frag->dev = skb->dev;
/* copy header, MFR and payload */
memcpy(skb_put(frag, mlen), skb->data, mlen);
--
1.8.4.1
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
^ permalink raw reply related
* [PATCH net-next 4/5] 6lowpan: remove skb->dev assignment
From: Alexander Aring @ 2013-10-24 20:51 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1382647904-11311-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
This patch removes the assignment of skb->dev. We don't need it here because
we use the netdev_alloc_skb_ip_align function which already sets the
skb->dev.
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Werner Almesberger <werner-SEdMjqphH88wryQfseakQg@public.gmane.org>
---
net/ieee802154/6lowpan.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 7510278..e15b101 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -785,7 +785,6 @@ lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag)
goto skb_err;
frame->skb->priority = skb->priority;
- frame->skb->dev = skb->dev;
/* reserve headroom for uncompressed ipv6 header */
skb_reserve(frame->skb, sizeof(struct ipv6hdr));
--
1.8.4.1
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
^ permalink raw reply related
* [PATCH net-next 5/5] 6lowpan: remove unecessary break
From: Alexander Aring @ 2013-10-24 20:51 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <1382647904-11311-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Werner Almesberger <werner-SEdMjqphH88wryQfseakQg@public.gmane.org>
---
net/ieee802154/6lowpan.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index e15b101..09350f1 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -440,7 +440,6 @@ lowpan_uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
default:
pr_debug("ERROR: unknown UDP format\n");
goto err;
- break;
}
pr_debug("uncompressed UDP ports: src = %d, dst = %d\n",
--
1.8.4.1
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
^ permalink raw reply related
* [PATCH net-next 2/5] 6lowpan: remove unnecessary check on err >= 0
From: Alexander Aring @ 2013-10-24 20:51 UTC (permalink / raw)
To: alex.bluesman.smirnov
Cc: linux-zigbee-devel, werner, dbaryshkov, netdev, Alexander Aring
In-Reply-To: <1382647904-11311-1-git-send-email-alex.aring@gmail.com>
The err variable can only be zero in this case.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Reviewed-by: Werner Almesberger <werner@almesberger.net>
---
net/ieee802154/6lowpan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index d288035..9057f83 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -1179,7 +1179,7 @@ lowpan_skb_fragmentation(struct sk_buff *skb, struct net_device *dev)
head[0] &= ~LOWPAN_DISPATCH_FRAG1;
head[0] |= LOWPAN_DISPATCH_FRAGN;
- while ((payload_length - offset > 0) && (err >= 0)) {
+ while (payload_length - offset > 0) {
int len = LOWPAN_FRAG_SIZE;
head[4] = offset / 8;
--
1.8.4.1
^ permalink raw reply related
* Re: [PATCH net] netconsole: fix NULL pointer dereference
From: Francois Romieu @ 2013-10-24 20:59 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: David Miller, David.Laight, vfalico, netdev
In-Reply-To: <52696563.1060507@redhat.com>
Nikolay Aleksandrov <nikolay@redhat.com> :
> On 10/24/2013 07:56 PM, David Miller wrote:
> > From: "David Laight" <David.Laight@ACULAB.COM>
[...]
> >> Ditto - might be worth saying:
> >> /* Acquire lock to wait for any write_msg() to complete. */
> >
> > Something this subtle definitely requires a comment.
> >
> Okay, thank you all for the reviews. I will re-submit a v2 with
> the comment edited.
"edited" as in "removed" because:
1. an irq disabling spinlock loudly states what the intent is ("hey, this
netconsole stuff could be concurrently used in irq or softirq context").
2. the target_list_lock spinlock itself tells where to look for:
drivers/net/netconsole.c
[...]
/* This needs to be a spinlock because write_msg() cannot sleep */
static DEFINE_SPINLOCK(target_list_lock);
--
Ueimor
^ permalink raw reply
* You Have Been Awarded $1,000,000.00 USD
From: Qatar Foundation @ 2013-10-24 20:44 UTC (permalink / raw)
To: Recipients
Dear Beneficiary,
This is to inform you that you were among the lucky beneficiary selected to receive this donations award sum of $1,000,000.00 USD, as charity donations/aid from the Qatar Foundation held in Doha, Qatar, 24th of October 2013, to promote your business and personal Interest. Kindly get back for more details on how to claims your award via email: qatarfoundation013@xd.ae
On behalf of the foundation, we say congratulations to you.
Yours Sincerely,
Dr. Mohammad Fathy Saoud.
Reply To: qatarfoundation013@xd.ae
President of Qatar Foundation.
^ permalink raw reply
* Re: [PATCH RFC v2 0/4] MDIO bus timeout issues on Dreamplug
From: Jason Cooper @ 2013-10-24 21:25 UTC (permalink / raw)
To: Leigh Brown
Cc: linux-arm-kernel, Thomas Petazzoni, netdev, sebastian.hesselbarth
In-Reply-To: <cover.1382637156.git.leigh@solinno.co.uk>
Leigh,
Thanks for getting the bottom of this!
On Thu, Oct 24, 2013 at 07:09:30PM +0100, Leigh Brown wrote:
> Thanks to the comment from Sebastian I did some more investigation and
> discovered that almost everything about my analysis was wrong (woops).
> The patch itself wasn't too bad though.
>
> In terms of timings, I don't believe the timeout was due to the SMI bus
> taking too long to respond because when I have repeated my testing
> (this time disabling interrupts whilst waiting), I have found that the
> maximum time that my Dreamplug takes to respond was about 95us (and
> 43us on the Mirabox, which polls). So I think the root cause of the
> problem was that interrupt handler was interfering with the polling in
> some way.
>
> I have therefore amended the first patch to use usleep_range to sleep
> instead of busy wait as suggested by Sebastian, and set the timeout to
> 1ms. I've tested this on both the Dreamplug and Mirabox and have seen
> no timeouts at all.
>
> The second, third and fourth patches are pretty much the same as before.
>
> If I receive no comments who do I submit this to for inclusion?
You can can use scripts/get_maintainer.pl for this. In this case, it
spits out:
"David S. Miller" <davem@davemloft.net> (commit_signer:63/70=90%)
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (commit_signer:15/70=21%)
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> (commit_signer:10/70=14%)
Florian Fainelli <florian@openwrt.org> (commit_signer:8/70=11%)
Stephen Hemminger <stephen@networkplumber.org> (commit_signer:6/70=9%)
netdev@vger.kernel.org (open list:NETWORKING DRIVERS)
linux-kernel@vger.kernel.org (open list)
thx,
Jason.
^ permalink raw reply
* [PATCH net-next] natsemi: fix legacy printk() style
From: Drew McGowen @ 2013-10-24 21:37 UTC (permalink / raw)
To: netdev; +Cc: Drew McGowen
Fixed printk() calls to use KERN_* prefix (some were not changed because they
are continuations of a previous line).
Reviewed-by: Sarabeth Jaffe <jaffes2@rpi.edu>
Reviewed-by: Marcio Barbosa <marcio.brito.barbosa@gmail.com>
Reviewed-by: Sean Heyse <heyses@rpi.edu>
Signed-off-by: Drew McGowen <quantumdude836@gmail.com>
---
drivers/net/ethernet/natsemi/natsemi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c
index 7a5e295..cd39d8e 100644
--- a/drivers/net/ethernet/natsemi/natsemi.c
+++ b/drivers/net/ethernet/natsemi/natsemi.c
@@ -814,7 +814,7 @@ static int natsemi_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
#ifndef MODULE
static int printed_version;
if (!printed_version++)
- printk(version);
+ printk(KERN_INFO version);
#endif
i = pci_enable_device(pdev);
@@ -3360,7 +3360,7 @@ static int __init natsemi_init_mod (void)
{
/* when a module, this is printed whether or not devices are found in probe */
#ifdef MODULE
- printk(version);
+ printk(KERN_INFO version);
#endif
return pci_register_driver(&natsemi_driver);
--
1.8.1.2
^ permalink raw reply related
* [PATCH net-next] jazzsonic: printk() style fixes
From: Tom D'Alba @ 2013-10-24 21:39 UTC (permalink / raw)
To: netdev; +Cc: Tom D'Alba
From: Tom D'Alba <dalbat@rpi.edu>
Fixed printk() format by adding correct KERN_ statuses.
Reviewed-by: Nicholas Guthrie <nickg4317@gmail.com>
Reviewed-by: Sarah Williams <swilliams704@gmail.com>
Reviewed-by: Jason Lee <calccrypto@gmail.com>
Signed-off-by: Tom D'Alba <dalbat@rpi.edu>
---
drivers/net/ethernet/natsemi/jazzsonic.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c b/drivers/net/ethernet/natsemi/jazzsonic.c
index 79257f7..3a04d32 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -135,7 +135,7 @@ static int sonic_probe1(struct net_device *dev)
*/
silicon_revision = SONIC_READ(SONIC_SR);
if (sonic_debug > 1)
- printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
+ printk(KERN_INFO "SONIC Silicon Revision = 0x%04x\n",silicon_revision);
i = 0;
while (known_revisions[i] != 0xffff &&
@@ -143,13 +143,13 @@ static int sonic_probe1(struct net_device *dev)
i++;
if (known_revisions[i] == 0xffff) {
- printk("SONIC ethernet controller not found (0x%4x)\n",
+ printk(KERN_ERR "SONIC ethernet controller not found (0x%4x)\n",
silicon_revision);
goto out;
}
if (sonic_debug && version_printed++ == 0)
- printk(version);
+ printk(KERN_INFO version);
printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ",
dev_name(lp->device), dev->base_addr);
--
1.8.1.2
^ permalink raw reply related
* [PATCH net-next] ns83820: printk() cleanup
From: Luke C. Jones @ 2013-10-24 21:45 UTC (permalink / raw)
To: netdev; +Cc: Luke C. Jones
From: "Luke C. Jones" <jonesl4@rpi.edu>
In an effort to bring all printk calls up to style standards,
added log levels to printk calls.
Reviewed-by: Mike Mathis <mathim2@rpi.edu>
Reviewed-by: Jonathan Beekman <beekmj@rpi.edu>
Signed-off-by: Luke C. Jones <jonesl4@rpi.edu>
---
drivers/net/ethernet/natsemi/ns83820.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/natsemi/ns83820.c b/drivers/net/ethernet/natsemi/ns83820.c
index d3b4700..d7f849d 100644
--- a/drivers/net/ethernet/natsemi/ns83820.c
+++ b/drivers/net/ethernet/natsemi/ns83820.c
@@ -1580,7 +1580,7 @@ static void ns83820_tx_timeout(struct net_device *ndev)
{
u32 isr;
isr = readl(dev->base + ISR);
- printk("irq: %08x imr: %08x\n", isr, dev->IMR_cache);
+ printk(KERN_DEBUG "irq: %08x imr: %08x\n", isr, dev->IMR_cache);
ns83820_do_isr(ndev, isr);
}
#endif
@@ -1603,7 +1603,7 @@ static void ns83820_tx_watch(unsigned long data)
struct ns83820 *dev = PRIV(ndev);
#if defined(DEBUG)
- printk("ns83820_tx_watch: %u %u %d\n",
+ printk(KERN_DEBUG "ns83820_tx_watch: %u %u %d\n",
dev->tx_done_idx, dev->tx_free_idx, atomic_read(&dev->nr_tx_skbs)
);
#endif
@@ -2026,7 +2026,7 @@ static int ns83820_init_one(struct pci_dev *pci_dev,
goto out_free_irq;
}
- printk("%s: ns83820.c: 0x22c: %08x, subsystem: %04x:%04x\n",
+ printk(KERN_INFO "%s: ns83820.c: 0x22c: %08x, subsystem: %04x:%04x\n",
ndev->name, le32_to_cpu(readl(dev->base + 0x22c)),
pci_dev->subsystem_vendor, pci_dev->subsystem_device);
--
1.8.1.2
^ permalink raw reply related
* [PATCH net-next] macsonic: Updated printk() statement to KERN style leading argument.
From: Matt Zanchelli @ 2013-10-24 21:37 UTC (permalink / raw)
To: netdev; +Cc: Matt Zanchelli
Updated prinkt() statement in mac_sonic_probe() function to match current
convention of using KERN style leading argument.
Reviewed-by: Daniel Felizardo <danfelizardo@gmail.com>
Reviewed-by: Nicole Negedly <nnegedly@gmail.com>
Reviewed-by: Maxwell Ensley-Field <mensleyfield@gmail.com>
Signed-off-by: Matt Zanchelli <zanchm@rpi.edu>
---
drivers/net/ethernet/natsemi/macsonic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/natsemi/macsonic.c b/drivers/net/ethernet/natsemi/macsonic.c
index 346a4e0..3eca756 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -601,7 +601,7 @@ found:
if (err)
goto out;
- printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
+ printk(KERN_INFO "%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
return 0;
--
1.8.1.2
^ permalink raw reply related
* Re: [PATCH net-next] jazzsonic: printk() style fixes
From: Sergei Shtylyov @ 2013-10-24 21:50 UTC (permalink / raw)
To: Tom D'Alba, netdev; +Cc: Tom D'Alba
In-Reply-To: <1382650780-24114-1-git-send-email-tomster595@gmail.com>
Hello.
On 10/25/2013 01:39 AM, Tom D'Alba wrote:
> From: Tom D'Alba <dalbat@rpi.edu>
> Fixed printk() format by adding correct KERN_ statuses.
> Reviewed-by: Nicholas Guthrie <nickg4317@gmail.com>
> Reviewed-by: Sarah Williams <swilliams704@gmail.com>
> Reviewed-by: Jason Lee <calccrypto@gmail.com>
> Signed-off-by: Tom D'Alba <dalbat@rpi.edu>
> ---
> drivers/net/ethernet/natsemi/jazzsonic.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c b/drivers/net/ethernet/natsemi/jazzsonic.c
> index 79257f7..3a04d32 100644
> --- a/drivers/net/ethernet/natsemi/jazzsonic.c
> +++ b/drivers/net/ethernet/natsemi/jazzsonic.c
> @@ -135,7 +135,7 @@ static int sonic_probe1(struct net_device *dev)
> */
> silicon_revision = SONIC_READ(SONIC_SR);
> if (sonic_debug > 1)
> - printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
> + printk(KERN_INFO "SONIC Silicon Revision = 0x%04x\n",silicon_revision);
Please don't change the indentation.
> @@ -143,13 +143,13 @@ static int sonic_probe1(struct net_device *dev)
> i++;
>
> if (known_revisions[i] == 0xffff) {
> - printk("SONIC ethernet controller not found (0x%4x)\n",
> + printk(KERN_ERR "SONIC ethernet controller not found (0x%4x)\n",
> silicon_revision);
> goto out;
> }
>
> if (sonic_debug && version_printed++ == 0)
> - printk(version);
> + printk(KERN_INFO version);
Same here.
WBR, Sergei
^ permalink raw reply
* Re: [PATCH net-next] jazzsonic: printk() style fixes
From: Fabio Estevam @ 2013-10-24 21:54 UTC (permalink / raw)
To: Tom D'Alba; +Cc: netdev@vger.kernel.org, Tom D'Alba
In-Reply-To: <1382650780-24114-1-git-send-email-tomster595@gmail.com>
Hi Tom,
On Thu, Oct 24, 2013 at 7:39 PM, Tom D'Alba <tomster595@gmail.com> wrote:
> From: Tom D'Alba <dalbat@rpi.edu>
>
> Fixed printk() format by adding correct KERN_ statuses.
>
> Reviewed-by: Nicholas Guthrie <nickg4317@gmail.com>
> Reviewed-by: Sarah Williams <swilliams704@gmail.com>
> Reviewed-by: Jason Lee <calccrypto@gmail.com>
> Signed-off-by: Tom D'Alba <dalbat@rpi.edu>
> ---
> drivers/net/ethernet/natsemi/jazzsonic.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c b/drivers/net/ethernet/natsemi/jazzsonic.c
> index 79257f7..3a04d32 100644
> --- a/drivers/net/ethernet/natsemi/jazzsonic.c
> +++ b/drivers/net/ethernet/natsemi/jazzsonic.c
> @@ -135,7 +135,7 @@ static int sonic_probe1(struct net_device *dev)
> */
> silicon_revision = SONIC_READ(SONIC_SR);
> if (sonic_debug > 1)
> - printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
> + printk(KERN_INFO "SONIC Silicon Revision = 0x%04x\n",silicon_revision);
You could use netdev_info here instead.
>
> i = 0;
> while (known_revisions[i] != 0xffff &&
> @@ -143,13 +143,13 @@ static int sonic_probe1(struct net_device *dev)
> i++;
>
> if (known_revisions[i] == 0xffff) {
> - printk("SONIC ethernet controller not found (0x%4x)\n",
> + printk(KERN_ERR "SONIC ethernet controller not found (0x%4x)\n",
You could use netdev_err here instead.
> silicon_revision);
> goto out;
> }
>
> if (sonic_debug && version_printed++ == 0)
> - printk(version);
> + printk(KERN_INFO version);
You could use netdev_info here instead.
^ permalink raw reply
* Re: [PATCH net-next] macsonic: Updated printk() statement to KERN style leading argument.
From: Joe Perches @ 2013-10-24 22:30 UTC (permalink / raw)
To: Matt Zanchelli; +Cc: netdev
In-Reply-To: <1382650645-23973-1-git-send-email-zanchm@rpi.edu>
On Thu, 2013-10-24 at 21:37 +0000, Matt Zanchelli wrote:
> Updated prinkt() statement in mac_sonic_probe() function to match current
> convention of using KERN style leading argument.
s/prinkt/printk/
> diff --git a/drivers/net/ethernet/natsemi/macsonic.c b/drivers/net/ethernet/natsemi/macsonic.c
[]
> @@ -601,7 +601,7 @@ found:
> if (err)
> goto out;
>
> - printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
> + printk(KERN_INFO "%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
It'd be nicer to use:
netdev_info(dev, "MAC %pM IRQ %d\n", dev->dev_addr, dev->irq);
Nicer still to convert all the printks in this
file to netdev_<level> where possible.
^ permalink raw reply
* Re: [PATCH net-next] natsemi: fix legacy printk() style
From: Joe Perches @ 2013-10-24 22:33 UTC (permalink / raw)
To: Drew McGowen; +Cc: netdev
In-Reply-To: <1382650646-24009-1-git-send-email-quantumdude836@gmail.com>
On Thu, 2013-10-24 at 21:37 +0000, Drew McGowen wrote:
> Fixed printk() calls to use KERN_* prefix (some were not changed because they
> are continuations of a previous line).
[]
> diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c
[]
> @@ -814,7 +814,7 @@ static int natsemi_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
> #ifndef MODULE
> static int printed_version;
> if (!printed_version++)
> - printk(version);
> + printk(KERN_INFO version);
pr_info_once("%s\n", version);
And remove the trailing newline from version
> @@ -3360,7 +3360,7 @@ static int __init natsemi_init_mod (void)
> {
> /* when a module, this is printed whether or not devices are found in probe */
> #ifdef MODULE
> - printk(version);
> + printk(KERN_INFO version);
pr_info("%s\n", version);
Nicer to use netdev_<level> too.
^ permalink raw reply
* Re: [PATCH net-next] ns83820: printk() cleanup
From: Joe Perches @ 2013-10-24 22:38 UTC (permalink / raw)
To: Luke C. Jones; +Cc: netdev, Luke C. Jones
In-Reply-To: <1382651106-24550-1-git-send-email-Luke.Christopher.Jones@gmail.com>
On Thu, 2013-10-24 at 21:45 +0000, Luke C. Jones wrote:
> In an effort to bring all printk calls up to style standards,
> added log levels to printk calls.
[]
> diff --git a/drivers/net/ethernet/natsemi/ns83820.c b/drivers/net/ethernet/natsemi/ns83820.c
[]
> @@ -1580,7 +1580,7 @@ static void ns83820_tx_timeout(struct net_device *ndev)
> {
> u32 isr;
> isr = readl(dev->base + ISR);
> - printk("irq: %08x imr: %08x\n", isr, dev->IMR_cache);
> + printk(KERN_DEBUG "irq: %08x imr: %08x\n", isr, dev->IMR_cache);
netdev_dbg(ndev, etc...)
> @@ -1603,7 +1603,7 @@ static void ns83820_tx_watch(unsigned long data)
> struct ns83820 *dev = PRIV(ndev);
>
> #if defined(DEBUG)
> - printk("ns83820_tx_watch: %u %u %d\n",
> + printk(KERN_DEBUG "ns83820_tx_watch: %u %u %d\n",
> dev->tx_done_idx, dev->tx_free_idx, atomic_read(&dev->nr_tx_skbs)
> );
netdev_dbg()
> #endif
> @@ -2026,7 +2026,7 @@ static int ns83820_init_one(struct pci_dev *pci_dev,
> goto out_free_irq;
> }
>
> - printk("%s: ns83820.c: 0x22c: %08x, subsystem: %04x:%04x\n",
> + printk(KERN_INFO "%s: ns83820.c: 0x22c: %08x, subsystem: %04x:%04x\n",
> ndev->name, le32_to_cpu(readl(dev->base + 0x22c)),
> pci_dev->subsystem_vendor, pci_dev->subsystem_device);
>
netdev_info()
^ permalink raw reply
* Re: [PATCH] 3c59x: fix incorrect use of spin_lock_bh in interrupts
From: Francois Romieu @ 2013-10-24 22:44 UTC (permalink / raw)
To: Mikulas Patocka; +Cc: David Miller, klassert, netdev
In-Reply-To: <alpine.LRH.2.02.1310221148010.29454@file01.intranet.prod.int.rdu2.redhat.com>
Mikulas Patocka <mpatocka@redhat.com> :
> On Tue, 22 Oct 2013, David Miller wrote:
[...]
> > vortex_down() does a lot of other things which are really dangerous
> > from an interrupt handler, such as del_timer_sync().
> >
> > The real fix for this bug is to defer the vortex_error() work into
> > a workqueue, and thus process context, like every other driver does.
>
> That del_timer_sync() could be skipped - if we reset the card, we don't
> need to reinitialize the times. Do you see anything else there that
> prevents the functions vortex_down and vortex_up from being called from an
> interrupt?
Up to 1s busy wait loop in issue_and_wait.
window_{read / write} deadlock with vortex_tx_timeout.
Error recovery needs to be robust and you'd rather recover in a context
where you can be a real pig (MDIO usually is).
It is a common pattern in linux kernel ethernet drivers to reduce the irq
handler to a bare minimum and move real work to softirq (NAPI) context,
especially for rx and tx traffic, then to workqueues for rare or error
related stuff. Window locking may limit the opportunity for fast path
locks removal but the driver would -imho- still end simpler.
--
Ueimor
^ permalink raw reply
* [PATCH v2] can: add Renesas R-Car CAN driver
From: Sergei Shtylyov @ 2013-10-24 23:03 UTC (permalink / raw)
To: netdev, wg, mkl, linux-can; +Cc: linux-sh, vksavl
Add support for the CAN controller found in Renesas R-Car SoCs.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
The patch is against the 'linux-can-next.git' repo.
Changes in version 2:
- added function to clean up TX mailboxes after bus error and bus-off;
- added module parameter to enable hardware recovery from bus-off, added handler
for the bus-off recovery interrupt, and set the control register according to
the parameter value and the restart timer setting in rcar_can_start();
- changed the way CAN_ERR_CRTL_[RT]X_{PASSIVE|WARNING} flags are set to a more
realicstic one;
- replaced MBX_* macros and rcar_can_mbx_{read|write}[bl]() functions with
'struct rcar_can_mbox_regs', 'struct rcar_can_regs', and {read|write}[bl](),
replaced 'reg_base' field of 'struct rcar_can_priv' with 'struct rcar_can_regs
__iomem *regs';
- added 'ier' field to 'struct rcar_can_priv' to cache the current value of the
interrupt enable register;
- added a check for enabled interrupts on entry to rcar_can_interrupt();
- limited transmit mailbox search loop in rcar_can_interrupt();
- decoupled TX byte count increment from can_get_echo_skb() call;
- removed netif_queue_stopped() call from rcar_can_interrupt();
- added clk_prepare_enable()/clk_disable_unprepare() to ndo_{open|close}(),
do_set_bittiming(), and do_get_berr_counter() methods, removed clk_enable()
call from the probe() method and clk_disable() call from the remove() method;
- allowed rcar_can_set_bittiming() to be called when the device is closed and
remove explicit call to it from rcar_can_start();
- switched to using mailbox number priority transmit mode, and switched to the
sequential mailbox use in ndo_start_xmit() method;
- stopped reading the message control registers in ndo_start_xmit() method;
- avoided returning NETDEV_TX_BUSY from ndo_start_xmit() method;
- stopped reading data when RTR bit is set in the CAN frame;
- made 'num_pkts' variable *int* and moved its check to the *while* condition in
rcar_can_rx_poll();
- used dev_get_platdata() in the probe() method;
- enabled bus error interrupt only if CAN_CTRLMODE_BERR_REPORTING flag is set;
- started reporting CAN_CTRLMODE_BERR_REPORTING support and stopped reporting
CAN_CTRLMODE_3_SAMPLES support;
- set CAN_ERR_ACK flag on ACK error;
- switched to incrementing bus error counter only once per bus error interrupt;
- started switching to CAN sleep mode in rcar_can_stop() and stopped switching
to it in the remove() method;
- removed netdev_err() calls on allocation failure in rcar_can_error() and
rcar_can_rx_pkt();
- removed "CANi" from the register offset macro comments.
drivers/net/can/Kconfig | 9
drivers/net/can/Makefile | 1
drivers/net/can/rcar_can.c | 920 ++++++++++++++++++++++++++++++++++
include/linux/can/platform/rcar_can.h | 15
4 files changed, 945 insertions(+)
Index: linux-can-next/drivers/net/can/Kconfig
===================================================================
--- linux-can-next.orig/drivers/net/can/Kconfig
+++ linux-can-next/drivers/net/can/Kconfig
@@ -125,6 +125,15 @@ config CAN_GRCAN
endian syntheses of the cores would need some modifications on
the hardware level to work.
+config CAN_RCAR
+ tristate "Renesas R-Car CAN controller"
+ ---help---
+ Say Y here if you want to use CAN controller found on Renesas R-Car
+ SoCs.
+
+ To compile this driver as a module, choose M here: the module will
+ be called rcar_can.
+
source "drivers/net/can/mscan/Kconfig"
source "drivers/net/can/sja1000/Kconfig"
Index: linux-can-next/drivers/net/can/Makefile
===================================================================
--- linux-can-next.orig/drivers/net/can/Makefile
+++ linux-can-next/drivers/net/can/Makefile
@@ -25,5 +25,6 @@ obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ica
obj-$(CONFIG_CAN_FLEXCAN) += flexcan.o
obj-$(CONFIG_PCH_CAN) += pch_can.o
obj-$(CONFIG_CAN_GRCAN) += grcan.o
+obj-$(CONFIG_CAN_RCAR) += rcar_can.o
ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
Index: linux-can-next/drivers/net/can/rcar_can.c
===================================================================
--- /dev/null
+++ linux-can-next/drivers/net/can/rcar_can.c
@@ -0,0 +1,920 @@
+/*
+ * Renesas R-Car CAN device driver
+ *
+ * Copyright (C) 2013 Cogent Embedded, Inc. <source@cogentembedded.com>
+ * Copyright (C) 2013 Renesas Solutions Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/platform_device.h>
+#include <linux/can/led.h>
+#include <linux/can/dev.h>
+#include <linux/clk.h>
+#include <linux/can/platform/rcar_can.h>
+
+#define DRV_NAME "rcar_can"
+
+#define RCAR_CAN_MIER1 0x42C /* Mailbox Interrupt Enable Register 1 */
+#define RCAR_CAN_MKR(n) ((n) < 2 ? 0x430 + 4 * (n) : 0x400 + 4 * ((n) - 2))
+ /* Mask Register */
+#define RCAR_CAN_MKIVLR0 0x438 /* Mask Invalid Register 0 */
+#define RCAR_CAN_MIER0 0x43C /* Mailbox Interrupt Enable Register 0 */
+
+#define RCAR_CAN_MCTL(n) (0x800 + (n)) /* Message Control Register */
+#define RCAR_CAN_CTLR 0x840 /* Control Register */
+#define RCAR_CAN_STR 0x842 /* Status Register */
+#define RCAR_CAN_BCR 0x844 /* Bit Configuration Register */
+#define RCAR_CAN_CLKR 0x847 /* Clock Select Register */
+#define RCAR_CAN_EIER 0x84C /* Error Interrupt Enable Register */
+#define RCAR_CAN_EIFR 0x84D /* Err Interrupt Factor Judge Register */
+#define RCAR_CAN_RECR 0x84E /* Receive Error Count Register */
+#define RCAR_CAN_TECR 0x84F /* Transmit Error Count Register */
+#define RCAR_CAN_ECSR 0x850 /* Error Code Store Register */
+#define RCAR_CAN_MSSR 0x852 /* Mailbox Search Status Register */
+#define RCAR_CAN_MSMR 0x853 /* Mailbox Search Mode Register */
+#define RCAR_CAN_TCR 0x858 /* Test Control Register */
+#define RCAR_CAN_IER 0x860 /* Interrupt Enable Register */
+#define RCAR_CAN_ISR 0x861 /* Interrupt Status Register */
+
+/* Control Register bits */
+#define CTLR_BOM (3 << 11) /* Bus-Off Recovery Mode Bits */
+#define CTLR_BOM_ENT BIT(11) /* Entry to halt mode at bus-off entry */
+#define CTLR_SLPM BIT(10)
+#define CTLR_HALT BIT(9)
+#define CTLR_RESET BIT(8)
+#define CTLR_FORCE_RESET (3 << 8)
+#define CTLR_TPM BIT(4) /* Transmission Priority Mode Select Bit */
+#define CTLR_IDFM_MIXED BIT(2) /* Mixed ID mode */
+
+/* Message Control Register bits */
+#define MCTL_TRMREQ BIT(7)
+#define MCTL_RECREQ BIT(6)
+#define MCTL_ONESHOT BIT(4)
+#define MCTL_SENTDATA BIT(0)
+#define MCTL_NEWDATA BIT(0)
+
+#define N_RX_MKREGS 2 /* Number of mask registers */
+ /* for Rx mailboxes 0-31 */
+
+/* Bit Configuration Register settings */
+#define BCR_TSEG1(x) (((x) & 0x0f) << 28)
+#define BCR_BPR(x) (((x) & 0x3ff) << 16)
+#define BCR_SJW(x) (((x) & 0x3) << 12)
+#define BCR_TSEG2(x) (((x) & 0x07) << 8)
+
+/* Mailbox and Mask Registers bits */
+#define RCAR_CAN_IDE BIT(31)
+#define RCAR_CAN_RTR BIT(30)
+#define RCAR_CAN_SID_SHIFT 18
+
+/* Interrupt Enable Register bits */
+#define IER_ERSIE BIT(5) /* Error (ERS) Interrupt Enable Bit */
+#define IER_RXM0IE BIT(2) /* Mailbox 0 Successful Reception (RXM0) */
+ /* Interrupt Enable Bit */
+#define IER_RXM1IE BIT(1) /* Mailbox 1 Successful Reception (RXM0) */
+ /* Interrupt Enable Bit */
+#define IER_TXMIE BIT(0) /* Mailbox 32 to 63 Successful Tx */
+ /* Interrupt Enable Bit */
+
+/* Interrupt Status Register bits */
+#define ISR_ERSF BIT(5) /* Error (ERS) Interrupt Status Bit */
+#define ISR_RXM0F BIT(2) /* Mailbox 0 Successful Reception (RXM0) */
+ /* Interrupt Status Bit */
+#define ISR_RXM1F BIT(1) /* Mailbox 1 to 63 Successful Reception */
+ /* (RXM1) Interrupt Status Bit */
+#define ISR_TXMF BIT(0) /* Mailbox 32 to 63 Successful Transmission */
+ /* (TXM) Interrupt Status Bit */
+
+/* Error Interrupt Enable Register bits */
+#define EIER_BLIE BIT(7) /* Bus Lock Interrupt Enable */
+#define EIER_OLIE BIT(6) /* Overload Frame Transmit Interrupt Enable */
+#define EIER_ORIE BIT(5) /* Receive Overrun Interrupt Enable */
+#define EIER_BORIE BIT(4) /* Bus-Off Recovery Interrupt Enable */
+
+#define EIER_BOEIE BIT(3) /* Bus-Off Entry Interrupt Enable */
+#define EIER_EPIE BIT(2) /* Error Passive Interrupt Enable */
+#define EIER_EWIE BIT(1) /* Error Warning Interrupt Enable */
+#define EIER_BEIE BIT(0) /* Bus Error Interrupt Enable */
+
+/* Error Interrupt Factor Judge Register bits */
+#define EIFR_BLIF BIT(7) /* Bus Lock Detect Flag */
+#define EIFR_OLIF BIT(6) /* Overload Frame Transmission Detect Flag */
+#define EIFR_ORIF BIT(5) /* Receive Overrun Detect Flag */
+#define EIFR_BORIF BIT(4) /* Bus-Off Recovery Detect Flag */
+#define EIFR_BOEIF BIT(3) /* Bus-Off Entry Detect Flag */
+#define EIFR_EPIF BIT(2) /* Error Passive Detect Flag */
+#define EIFR_EWIF BIT(1) /* Error Warning Detect Flag */
+#define EIFR_BEIF BIT(0) /* Bus Error Detect Flag */
+
+/* Error Code Store Register bits */
+#define ECSR_EDPM BIT(7) /* Error Display Mode Select Bit */
+#define ECSR_ADEF BIT(6) /* ACK Delimiter Error Flag */
+#define ECSR_BE0F BIT(5) /* Bit Error (dominant) Flag */
+#define ECSR_BE1F BIT(4) /* Bit Error (recessive) Flag */
+#define ECSR_CEF BIT(3) /* CRC Error Flag */
+#define ECSR_AEF BIT(2) /* ACK Error Flag */
+#define ECSR_FEF BIT(1) /* Form Error Flag */
+#define ECSR_SEF BIT(0) /* Stuff Error Flag */
+
+/* Mailbox Search Status Register bits */
+#define MSSR_SEST BIT(7) /* Search Result Status Bit */
+#define MSSR_MBNST 0x3f /* Search Result Mailbox Number Status mask */
+
+/* Mailbox Search Mode Register values */
+#define MSMR_TXMB 1 /* Transmit mailbox search mode */
+#define MSMR_RXMB 0 /* Receive mailbox search mode */
+
+/* Mailbox configuration:
+ * mailbox 0 - not used
+ * mailbox 1-31 - Rx
+ * mailbox 32-63 - Tx
+ * no FIFO mailboxes
+ */
+#define N_MBX 64
+#define FIRST_TX_MB 32
+#define N_TX_MB (N_MBX - FIRST_TX_MB)
+#define RX_MBX_MASK 0xFFFFFFFE
+
+#define RCAR_CAN_NAPI_WEIGHT (FIRST_TX_MB - 1)
+
+static bool autorecovery;
+module_param(autorecovery, bool, 0644);
+MODULE_PARM_DESC(autorecovery, "Automatic hardware recovery from bus-off");
+
+/* Mailbox registers structure */
+struct rcar_can_mbox_regs {
+ u32 id; /* IDE and RTR bits, SID and EID */
+ u8 stub; /* Not used */
+ u8 dlc; /* Data Length Code - bits [0..3] */
+ u8 data[8]; /* Data Bytes */
+ u8 tsh; /* Time Stamp Higher Byte */
+ u8 tsl; /* Time Stamp Lower Byte */
+};
+
+struct rcar_can_regs {
+ struct rcar_can_mbox_regs mb[N_MBX];
+};
+
+struct rcar_can_priv {
+ struct can_priv can; /* Must be the first member! */
+ struct net_device *ndev;
+ struct napi_struct napi;
+ struct rcar_can_regs __iomem *regs;
+ struct clk *clk;
+ spinlock_t mier_lock;
+ u8 clock_select;
+ u8 ier;
+};
+
+static const struct can_bittiming_const rcar_can_bittiming_const = {
+ .name = DRV_NAME,
+ .tseg1_min = 4,
+ .tseg1_max = 16,
+ .tseg2_min = 2,
+ .tseg2_max = 8,
+ .sjw_max = 4,
+ .brp_min = 1,
+ .brp_max = 1024,
+ .brp_inc = 1,
+};
+
+static inline u32 rcar_can_readl(struct rcar_can_priv *priv, int reg)
+{
+ return readl((void __iomem *)priv->regs + reg);
+}
+
+static inline u16 rcar_can_readw(struct rcar_can_priv *priv, int reg)
+{
+ return readw((void __iomem *)priv->regs + reg);
+}
+
+static inline u8 rcar_can_readb(struct rcar_can_priv *priv, int reg)
+{
+ return readb((void __iomem *)priv->regs + reg);
+}
+
+static inline void rcar_can_writel(struct rcar_can_priv *priv, int reg, u32 val)
+{
+ writel(val, (void __iomem *)priv->regs + reg);
+}
+
+static inline void rcar_can_writew(struct rcar_can_priv *priv, int reg, u16 val)
+{
+ writew(val, (void __iomem *)priv->regs + reg);
+}
+
+static inline void rcar_can_writeb(struct rcar_can_priv *priv, int reg, u8 val)
+{
+ writeb(val, (void __iomem *)priv->regs + reg);
+}
+
+static void tx_failure_cleanup(struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ u32 mier1;
+ u8 mbx;
+
+ spin_lock(&priv->mier_lock);
+ mier1 = rcar_can_readl(priv, RCAR_CAN_MIER1);
+ for (mbx = FIRST_TX_MB; mbx < N_MBX; mbx++) {
+ if (mier1 & BIT(mbx - FIRST_TX_MB)) {
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(mbx), 0);
+ can_free_echo_skb(ndev, mbx - FIRST_TX_MB);
+ }
+ }
+ rcar_can_writel(priv, RCAR_CAN_MIER1, 0);
+ spin_unlock(&priv->mier_lock);
+}
+
+static void rcar_can_start(struct net_device *ndev);
+
+static void rcar_can_error(struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ struct net_device_stats *stats = &ndev->stats;
+ struct can_frame *cf;
+ struct sk_buff *skb;
+ u8 eifr, txerr = 0, rxerr = 0;
+
+ /* Propagate the error condition to the CAN stack */
+ skb = alloc_can_err_skb(ndev, &cf);
+ if (!skb)
+ return;
+ eifr = rcar_can_readb(priv, RCAR_CAN_EIFR);
+ if (eifr & (EIFR_EWIF | EIFR_EPIF)) {
+ cf->can_id |= CAN_ERR_CRTL;
+ txerr = rcar_can_readb(priv, RCAR_CAN_TECR);
+ rxerr = rcar_can_readb(priv, RCAR_CAN_RECR);
+ }
+ if (eifr & EIFR_BEIF) {
+ int rx_errors = 0, tx_errors = 0;
+ u8 ecsr;
+
+ if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
+ tx_failure_cleanup(ndev);
+ netdev_dbg(priv->ndev, "Bus error interrupt:\n");
+ cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
+ cf->data[2] = CAN_ERR_PROT_UNSPEC;
+
+ ecsr = rcar_can_readb(priv, RCAR_CAN_ECSR);
+ if (ecsr & ECSR_ADEF) {
+ netdev_dbg(priv->ndev, "ACK Delimiter Error\n");
+ cf->data[3] |= CAN_ERR_PROT_LOC_ACK_DEL;
+ tx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_ADEF);
+ }
+ if (ecsr & ECSR_BE0F) {
+ netdev_dbg(priv->ndev, "Bit Error (dominant)\n");
+ cf->data[2] |= CAN_ERR_PROT_BIT0;
+ tx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_BE0F);
+ }
+ if (ecsr & ECSR_BE1F) {
+ netdev_dbg(priv->ndev, "Bit Error (recessive)\n");
+ cf->data[2] |= CAN_ERR_PROT_BIT1;
+ tx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_BE1F);
+ }
+ if (ecsr & ECSR_CEF) {
+ netdev_dbg(priv->ndev, "CRC Error\n");
+ cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ;
+ rx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_CEF);
+ }
+ if (ecsr & ECSR_AEF) {
+ netdev_dbg(priv->ndev, "ACK Error\n");
+ cf->can_id |= CAN_ERR_ACK;
+ cf->data[3] |= CAN_ERR_PROT_LOC_ACK;
+ tx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_AEF);
+ }
+ if (ecsr & ECSR_FEF) {
+ netdev_dbg(priv->ndev, "Form Error\n");
+ cf->data[2] |= CAN_ERR_PROT_FORM;
+ rx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_FEF);
+ }
+ if (ecsr & ECSR_SEF) {
+ netdev_dbg(priv->ndev, "Stuff Error\n");
+ cf->data[2] |= CAN_ERR_PROT_STUFF;
+ rx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, (u8)~ECSR_SEF);
+ }
+
+ priv->can.can_stats.bus_error++;
+ ndev->stats.rx_errors += rx_errors;
+ ndev->stats.tx_errors += tx_errors;
+ rcar_can_writeb(priv, RCAR_CAN_EIFR, (u8)~EIFR_BEIF);
+ }
+ if (eifr & EIFR_EWIF) {
+ netdev_dbg(priv->ndev, "Error warning interrupt\n");
+ priv->can.state = CAN_STATE_ERROR_WARNING;
+ priv->can.can_stats.error_warning++;
+ cf->data[1] |= txerr > rxerr ? CAN_ERR_CRTL_TX_WARNING :
+ CAN_ERR_CRTL_RX_WARNING;
+ /* Clear interrupt condition */
+ rcar_can_writeb(priv, RCAR_CAN_EIFR, (u8)~EIFR_EWIF);
+ }
+ if (eifr & EIFR_EPIF) {
+ netdev_dbg(priv->ndev, "Error passive interrupt\n");
+ priv->can.state = CAN_STATE_ERROR_PASSIVE;
+ priv->can.can_stats.error_passive++;
+ cf->data[1] |= txerr > rxerr ? CAN_ERR_CRTL_TX_PASSIVE :
+ CAN_ERR_CRTL_RX_PASSIVE;
+ /* Clear interrupt condition */
+ rcar_can_writeb(priv, RCAR_CAN_EIFR, (u8)~EIFR_EPIF);
+ }
+ if (eifr & EIFR_BOEIF) {
+ netdev_dbg(priv->ndev, "Bus-off entry interrupt\n");
+ tx_failure_cleanup(ndev);
+ priv->ier = IER_ERSIE;
+ rcar_can_writeb(priv, RCAR_CAN_IER, priv->ier);
+ priv->can.state = CAN_STATE_BUS_OFF;
+ cf->can_id |= CAN_ERR_BUSOFF;
+ /* Clear interrupt condition */
+ rcar_can_writeb(priv, RCAR_CAN_EIFR, (u8)~EIFR_BOEIF);
+ can_bus_off(ndev);
+ }
+ if (eifr & EIFR_BORIF) {
+ netdev_dbg(priv->ndev, "Bus-off recovery interrupt\n");
+ priv->can.state = CAN_STATE_ERROR_ACTIVE;
+ cf->can_id |= CAN_ERR_RESTARTED;
+ rcar_can_start(priv->ndev);
+ priv->can.can_stats.restarts++;
+ netif_carrier_on(ndev);
+ netif_wake_queue(ndev);
+ }
+ if (eifr & EIFR_ORIF) {
+ netdev_dbg(priv->ndev, "Receive overrun error interrupt\n");
+ cf->can_id |= CAN_ERR_CRTL;
+ cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW;
+ ndev->stats.rx_over_errors++;
+ ndev->stats.rx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_EIFR, (u8)~EIFR_ORIF);
+ }
+ if (eifr & EIFR_OLIF) {
+ netdev_dbg(priv->ndev,
+ "Overload Frame Transmission error interrupt\n");
+ cf->can_id |= CAN_ERR_PROT;
+ cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
+ ndev->stats.rx_over_errors++;
+ ndev->stats.rx_errors++;
+ rcar_can_writeb(priv, RCAR_CAN_EIFR, (u8)~EIFR_OLIF);
+ }
+
+ netif_rx(skb);
+ stats->rx_packets++;
+ stats->rx_bytes += cf->can_dlc;
+}
+
+static irqreturn_t rcar_can_interrupt(int irq, void *dev_id)
+{
+ struct net_device *ndev = (struct net_device *)dev_id;
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ struct net_device_stats *stats = &ndev->stats;
+ u8 isr;
+
+ isr = rcar_can_readb(priv, RCAR_CAN_ISR);
+ if (!(isr & priv->ier))
+ return IRQ_NONE;
+
+ if (isr & ISR_ERSF)
+ rcar_can_error(ndev);
+
+ if (isr & ISR_TXMF) {
+ u32 ie_mask = 0;
+ int i;
+
+ /* Set Transmit Mailbox Search Mode */
+ rcar_can_writeb(priv, RCAR_CAN_MSMR, MSMR_TXMB);
+ for (i = 0; i < N_TX_MB; i++) {
+ u8 mctl, mbx;
+
+ mbx = rcar_can_readb(priv, RCAR_CAN_MSSR);
+ if (mbx & MSSR_SEST)
+ break;
+ mbx &= MSSR_MBNST;
+ stats->tx_bytes += readb(&priv->regs->mb[mbx].dlc);
+ stats->tx_packets++;
+ mctl = rcar_can_readb(priv, RCAR_CAN_MCTL(mbx));
+ /* Bits SENTDATA and TRMREQ cannot be
+ * set to 0 simultaneously
+ */
+ mctl &= ~MCTL_TRMREQ;
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(mbx), mctl);
+ mctl &= ~MCTL_SENTDATA;
+ /* Clear interrupt */
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(mbx), mctl);
+ ie_mask |= BIT(mbx - FIRST_TX_MB);
+ can_get_echo_skb(ndev, mbx - FIRST_TX_MB);
+ can_led_event(ndev, CAN_LED_EVENT_TX);
+ }
+ /* Set receive mailbox search mode */
+ rcar_can_writeb(priv, RCAR_CAN_MSMR, MSMR_RXMB);
+ /* Disable mailbox interrupt, mark mailbox as free */
+ if (ie_mask) {
+ u32 mier1;
+
+ spin_lock(&priv->mier_lock);
+ mier1 = rcar_can_readl(priv, RCAR_CAN_MIER1);
+ rcar_can_writel(priv, RCAR_CAN_MIER1, mier1 & ~ie_mask);
+ spin_unlock(&priv->mier_lock);
+ netif_wake_queue(ndev);
+ }
+ }
+ if (isr & ISR_RXM1F) {
+ if (napi_schedule_prep(&priv->napi)) {
+ /* Disable Rx interrupts */
+ priv->ier &= ~IER_RXM1IE;
+ rcar_can_writeb(priv, RCAR_CAN_IER, priv->ier);
+ __napi_schedule(&priv->napi);
+ }
+ }
+ return IRQ_HANDLED;
+}
+
+static int rcar_can_set_bittiming(struct net_device *dev)
+{
+ struct rcar_can_priv *priv = netdev_priv(dev);
+ struct can_bittiming *bt = &priv->can.bittiming;
+ u32 bcr;
+ u16 ctlr;
+ u8 clkr;
+
+ clk_prepare_enable(priv->clk);
+ /* rcar_can_set_bittiming() is called in CAN sleep mode.
+ * Can write to BCR in CAN reset mode or CAN halt mode.
+ * Cannot write to CLKR in halt mode, so go to reset mode.
+ */
+ ctlr = rcar_can_readw(priv, RCAR_CAN_CTLR);
+ ctlr &= ~CTLR_SLPM;
+ ctlr |= CTLR_FORCE_RESET;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ /* Don't overwrite CLKR with 32-bit BCR access */
+ /* CLKR has 8-bit access */
+ clkr = rcar_can_readb(priv, RCAR_CAN_CLKR);
+ bcr = BCR_TSEG1(bt->phase_seg1 + bt->prop_seg - 1) |
+ BCR_BPR(bt->brp - 1) | BCR_SJW(bt->sjw - 1) |
+ BCR_TSEG2(bt->phase_seg2 - 1);
+ rcar_can_writel(priv, RCAR_CAN_BCR, bcr);
+ rcar_can_writeb(priv, RCAR_CAN_CLKR, clkr);
+ ctlr |= CTLR_SLPM;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ clk_disable_unprepare(priv->clk);
+ return 0;
+}
+
+static void rcar_can_start(struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ u16 ctlr, n;
+
+ /* Set controller to known mode:
+ * - normal mailbox mode (no FIFO);
+ * - accept all messages (no filter).
+ * CAN is in sleep mode after MCU hardware or software reset.
+ */
+ ctlr = rcar_can_readw(priv, RCAR_CAN_CTLR);
+ ctlr &= ~CTLR_SLPM;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ /* Go to reset mode */
+ ctlr |= CTLR_FORCE_RESET;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ ctlr |= CTLR_IDFM_MIXED; /* Select mixed ID mode */
+ ctlr |= CTLR_TPM; /* Set mailbox number priority transmit mode */
+ ctlr &= ~CTLR_BOM; /* Automatic recovery */
+ /* compliant with ISO11898-1 */
+ if (!autorecovery || priv->can.restart_ms)
+ ctlr |= CTLR_BOM_ENT; /* Entry to halt mode automatically */
+ /* at bus-off */
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+
+ rcar_can_writeb(priv, RCAR_CAN_CLKR, priv->clock_select);
+
+ /* Accept all SID and EID */
+ for (n = 0; n < N_RX_MKREGS; n++)
+ rcar_can_writel(priv, RCAR_CAN_MKR(n), 0);
+ rcar_can_writel(priv, RCAR_CAN_MKIVLR0, 0);
+
+ /* Initial value of MIER1 undefined. Mark all Tx mailboxes as free. */
+ rcar_can_writel(priv, RCAR_CAN_MIER1, 0);
+
+ priv->ier = IER_TXMIE | IER_ERSIE | IER_RXM1IE;
+ rcar_can_writeb(priv, RCAR_CAN_IER, priv->ier);
+
+ /* Accumulate error codes */
+ rcar_can_writeb(priv, RCAR_CAN_ECSR, ECSR_EDPM);
+ /* Enable error interrupts */
+ rcar_can_writeb(priv, RCAR_CAN_EIER,
+ EIER_EWIE | EIER_EPIE | EIER_BOEIE |
+ (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING ?
+ EIER_BEIE : 0) | EIER_ORIE | EIER_OLIE | EIER_BORIE);
+ /* Enable interrupts for RX mailboxes */
+ rcar_can_writel(priv, RCAR_CAN_MIER0, RX_MBX_MASK);
+ priv->can.state = CAN_STATE_ERROR_ACTIVE;
+
+ /* Write to the CiMCTLj register in CAN
+ * operation mode or CAN halt mode.
+ * Configure mailboxes 0-31 as Rx mailboxes.
+ * Configure mailboxes 32-63 as Tx mailboxes.
+ */
+ /* Go to halt mode */
+ ctlr |= CTLR_HALT;
+ ctlr &= ~CTLR_RESET;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ for (n = 0; n < FIRST_TX_MB; n++) {
+ /* According to documentation we should clear MCTL
+ * register before configuring mailbox.
+ */
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(n), 0);
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(n), MCTL_RECREQ);
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(FIRST_TX_MB + n), 0);
+ }
+ /* Go to operation mode */
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr & ~CTLR_FORCE_RESET);
+}
+
+static int rcar_can_open(struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ int err;
+
+ clk_prepare_enable(priv->clk);
+ err = open_candev(ndev);
+ if (err) {
+ netdev_err(ndev, "open_candev() failed %d\n", err);
+ goto out;
+ }
+ napi_enable(&priv->napi);
+ err = request_irq(ndev->irq, rcar_can_interrupt, 0, ndev->name, ndev);
+ if (err) {
+ netdev_err(ndev, "error requesting interrupt %x\n", ndev->irq);
+ goto out_close;
+ }
+ can_led_event(ndev, CAN_LED_EVENT_OPEN);
+ rcar_can_start(ndev);
+ netif_start_queue(ndev);
+ return 0;
+out_close:
+ napi_disable(&priv->napi);
+ close_candev(ndev);
+ clk_disable_unprepare(priv->clk);
+out:
+ return err;
+}
+
+static void rcar_can_stop(struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ u16 ctlr;
+
+ /* Go to (force) reset mode */
+ ctlr = rcar_can_readw(priv, RCAR_CAN_CTLR);
+ ctlr |= CTLR_FORCE_RESET;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ rcar_can_writel(priv, RCAR_CAN_MIER0, 0);
+ rcar_can_writel(priv, RCAR_CAN_MIER1, 0);
+ rcar_can_writeb(priv, RCAR_CAN_IER, 0);
+ rcar_can_writeb(priv, RCAR_CAN_EIER, 0);
+ /* Go to sleep mode */
+ ctlr |= CTLR_SLPM;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ priv->can.state = CAN_STATE_STOPPED;
+}
+
+static int rcar_can_close(struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+
+ netif_stop_queue(ndev);
+ rcar_can_stop(ndev);
+ free_irq(ndev->irq, ndev);
+ napi_disable(&priv->napi);
+ clk_disable_unprepare(priv->clk);
+ close_candev(ndev);
+ can_led_event(ndev, CAN_LED_EVENT_STOP);
+ return 0;
+}
+
+static netdev_tx_t rcar_can_start_xmit(struct sk_buff *skb,
+ struct net_device *ndev)
+{
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ struct can_frame *cf = (struct can_frame *)skb->data;
+ u32 data, mier1, mbxno, i;
+ unsigned long flags;
+ u8 mctl = 0;
+
+ if (can_dropped_invalid_skb(ndev, skb))
+ return NETDEV_TX_OK;
+
+ spin_lock_irqsave(&priv->mier_lock, flags);
+ mier1 = rcar_can_readl(priv, RCAR_CAN_MIER1);
+ if (mier1) {
+ i = __builtin_clz(mier1);
+ mbxno = i ? N_MBX - i : FIRST_TX_MB;
+ } else {
+ mbxno = FIRST_TX_MB;
+ }
+ mier1 |= BIT(mbxno - FIRST_TX_MB);
+ rcar_can_writel(priv, RCAR_CAN_MIER1, mier1);
+ spin_unlock_irqrestore(&priv->mier_lock, flags);
+ if (unlikely(mier1 == 0xffffffff))
+ netif_stop_queue(ndev);
+
+ if (cf->can_id & CAN_EFF_FLAG) {
+ /* Extended frame format */
+ data = (cf->can_id & CAN_EFF_MASK) | RCAR_CAN_IDE;
+ } else {
+ /* Standard frame format */
+ data = (cf->can_id & CAN_SFF_MASK) << RCAR_CAN_SID_SHIFT;
+ }
+ if (cf->can_id & CAN_RTR_FLAG) {
+ /* Remote transmission request */
+ data |= RCAR_CAN_RTR;
+ }
+ writel(data, &priv->regs->mb[mbxno].id);
+
+ writeb(cf->can_dlc, &priv->regs->mb[mbxno].dlc);
+
+ for (i = 0; i < cf->can_dlc; i++)
+ writeb(cf->data[i], &priv->regs->mb[mbxno].data[i]);
+
+ can_put_echo_skb(skb, ndev, mbxno - FIRST_TX_MB);
+
+ priv->ier |= IER_TXMIE;
+ rcar_can_writeb(priv, RCAR_CAN_IER, priv->ier);
+
+ if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
+ mctl |= MCTL_ONESHOT;
+
+ /* Start TX */
+ mctl |= MCTL_TRMREQ;
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(mbxno), mctl);
+ return NETDEV_TX_OK;
+}
+
+static const struct net_device_ops rcar_can_netdev_ops = {
+ .ndo_open = rcar_can_open,
+ .ndo_stop = rcar_can_close,
+ .ndo_start_xmit = rcar_can_start_xmit,
+};
+
+static void rcar_can_rx_pkt(struct rcar_can_priv *priv, int mbx)
+{
+ struct net_device_stats *stats = &priv->ndev->stats;
+ struct can_frame *cf;
+ struct sk_buff *skb;
+ u32 data;
+ u8 dlc;
+
+ skb = alloc_can_skb(priv->ndev, &cf);
+ if (!skb) {
+ stats->rx_dropped++;
+ return;
+ }
+
+ data = readl(&priv->regs->mb[mbx].id);
+ if (data & RCAR_CAN_IDE)
+ cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG;
+ else
+ cf->can_id = (data >> RCAR_CAN_SID_SHIFT) & CAN_SFF_MASK;
+
+ dlc = readb(&priv->regs->mb[mbx].dlc);
+ cf->can_dlc = get_can_dlc(dlc);
+ if (data & RCAR_CAN_RTR) {
+ cf->can_id |= CAN_RTR_FLAG;
+ } else {
+ for (dlc = 0; dlc < cf->can_dlc; dlc++)
+ cf->data[dlc] = readb(&priv->regs->mb[mbx].data[dlc]);
+ }
+
+ can_led_event(priv->ndev, CAN_LED_EVENT_RX);
+
+ netif_receive_skb(skb);
+ stats->rx_bytes += cf->can_dlc;
+ stats->rx_packets++;
+}
+
+static int rcar_can_rx_poll(struct napi_struct *napi, int quota)
+{
+ struct rcar_can_priv *priv = container_of(napi,
+ struct rcar_can_priv, napi);
+ int num_pkts = 0;
+
+ /* Find mailbox */
+ while (num_pkts < quota) {
+ u8 mctl, mbx;
+
+ mbx = rcar_can_readb(priv, RCAR_CAN_MSSR);
+ if (mbx & MSSR_SEST)
+ break;
+ mbx &= MSSR_MBNST;
+ mctl = rcar_can_readb(priv, RCAR_CAN_MCTL(mbx));
+ /* Clear interrupt */
+ rcar_can_writeb(priv, RCAR_CAN_MCTL(mbx),
+ mctl & ~MCTL_NEWDATA);
+ rcar_can_rx_pkt(priv, mbx);
+ ++num_pkts;
+ }
+ /* All packets processed */
+ if (num_pkts < quota) {
+ napi_complete(napi);
+ priv->ier |= IER_RXM1IE;
+ rcar_can_writeb(priv, RCAR_CAN_IER, priv->ier);
+ }
+ return num_pkts;
+}
+
+static int rcar_can_do_set_mode(struct net_device *ndev, enum can_mode mode)
+{
+ switch (mode) {
+ case CAN_MODE_START:
+ rcar_can_start(ndev);
+ netif_wake_queue(ndev);
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static int rcar_can_get_berr_counter(const struct net_device *dev,
+ struct can_berr_counter *bec)
+{
+ struct rcar_can_priv *priv = netdev_priv(dev);
+
+ clk_prepare_enable(priv->clk);
+ bec->txerr = rcar_can_readb(priv, RCAR_CAN_TECR);
+ bec->rxerr = rcar_can_readb(priv, RCAR_CAN_RECR);
+ clk_disable_unprepare(priv->clk);
+ return 0;
+}
+
+static int rcar_can_probe(struct platform_device *pdev)
+{
+ struct rcar_can_platform_data *pdata;
+ struct rcar_can_priv *priv;
+ struct net_device *ndev;
+ struct resource *mem;
+ void __iomem *addr;
+ int err = -ENODEV;
+ int irq;
+
+ pdata = dev_get_platdata(&pdev->dev);
+ if (!pdata) {
+ dev_err(&pdev->dev, "No platform data provided!\n");
+ goto fail;
+ }
+
+ irq = platform_get_irq(pdev, 0);
+ if (!irq) {
+ dev_err(&pdev->dev, "No IRQ resource\n");
+ goto fail;
+ }
+
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ addr = devm_ioremap_resource(&pdev->dev, mem);
+ if (IS_ERR(addr)) {
+ err = PTR_ERR(addr);
+ goto fail;
+ }
+
+ ndev = alloc_candev(sizeof(struct rcar_can_priv), N_MBX - FIRST_TX_MB);
+ if (!ndev) {
+ dev_err(&pdev->dev, "alloc_candev failed\n");
+ err = -ENOMEM;
+ goto fail;
+ }
+
+ priv = netdev_priv(ndev);
+
+ priv->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ err = PTR_ERR(priv->clk);
+ dev_err(&pdev->dev, "cannot get clock: %d\n", err);
+ goto fail_clk;
+ }
+
+ ndev->netdev_ops = &rcar_can_netdev_ops;
+ ndev->irq = irq;
+ ndev->flags |= IFF_ECHO;
+ priv->ndev = ndev;
+ priv->regs = (struct rcar_can_regs *)addr;
+ priv->clock_select = pdata->clock_select;
+ priv->can.clock.freq = clk_get_rate(priv->clk);
+ priv->can.bittiming_const = &rcar_can_bittiming_const;
+ priv->can.do_set_bittiming = rcar_can_set_bittiming;
+ priv->can.do_set_mode = rcar_can_do_set_mode;
+ priv->can.do_get_berr_counter = rcar_can_get_berr_counter;
+ priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING |
+ CAN_CTRLMODE_ONE_SHOT;
+ platform_set_drvdata(pdev, ndev);
+ SET_NETDEV_DEV(ndev, &pdev->dev);
+ spin_lock_init(&priv->mier_lock);
+
+ netif_napi_add(ndev, &priv->napi, rcar_can_rx_poll,
+ RCAR_CAN_NAPI_WEIGHT);
+ err = register_candev(ndev);
+ if (err) {
+ dev_err(&pdev->dev, "register_candev() failed\n");
+ goto fail_candev;
+ }
+
+ devm_can_led_init(ndev);
+
+ dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n",
+ priv->regs, ndev->irq);
+
+ return 0;
+fail_candev:
+ netif_napi_del(&priv->napi);
+fail_clk:
+ free_candev(ndev);
+fail:
+ return err;
+}
+
+static int rcar_can_remove(struct platform_device *pdev)
+{
+ struct net_device *ndev = platform_get_drvdata(pdev);
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+
+ unregister_candev(ndev);
+ netif_napi_del(&priv->napi);
+ free_candev(ndev);
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int rcar_can_suspend(struct device *dev)
+{
+ struct net_device *ndev = dev_get_drvdata(dev);
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ u16 ctlr;
+
+ if (netif_running(ndev)) {
+ netif_stop_queue(ndev);
+ netif_device_detach(ndev);
+ }
+ ctlr = rcar_can_readw(priv, RCAR_CAN_CTLR);
+ ctlr |= CTLR_HALT;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ ctlr |= CTLR_SLPM;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ priv->can.state = CAN_STATE_SLEEPING;
+
+ clk_disable(priv->clk);
+ return 0;
+}
+
+static int rcar_can_resume(struct device *dev)
+{
+ struct net_device *ndev = dev_get_drvdata(dev);
+ struct rcar_can_priv *priv = netdev_priv(ndev);
+ u16 ctlr;
+
+ clk_enable(priv->clk);
+
+ ctlr = rcar_can_readw(priv, RCAR_CAN_CTLR);
+ ctlr &= ~CTLR_SLPM;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ ctlr &= ~CTLR_FORCE_RESET;
+ rcar_can_writew(priv, RCAR_CAN_CTLR, ctlr);
+ priv->can.state = CAN_STATE_ERROR_ACTIVE;
+
+ if (netif_running(ndev)) {
+ netif_device_attach(ndev);
+ netif_start_queue(ndev);
+ }
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(rcar_can_pm_ops, rcar_can_suspend, rcar_can_resume);
+
+static struct platform_driver rcar_can_driver = {
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ .pm = &rcar_can_pm_ops,
+ },
+ .probe = rcar_can_probe,
+ .remove = rcar_can_remove,
+};
+
+module_platform_driver(rcar_can_driver);
+
+MODULE_AUTHOR("Cogent Embedded, Inc.");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("CAN driver for Renesas R-Car SoC");
+MODULE_ALIAS("platform:" DRV_NAME);
Index: linux-can-next/include/linux/can/platform/rcar_can.h
===================================================================
--- /dev/null
+++ linux-can-next/include/linux/can/platform/rcar_can.h
@@ -0,0 +1,15 @@
+#ifndef _CAN_PLATFORM_RCAR_CAN_H_
+#define _CAN_PLATFORM_RCAR_CAN_H_
+
+#include <linux/types.h>
+
+/* Clock Select Register settings */
+#define CLKR_CLKEXT 3 /* Externally input clock */
+#define CLKR_CLKP2 1 /* Peripheral clock (clkp2) */
+#define CLKR_CLKP1 0 /* Peripheral clock (clkp1) */
+
+struct rcar_can_platform_data {
+ u8 clock_select; /* Clock source select */
+};
+
+#endif /* !_CAN_PLATFORM_RCAR_CAN_H_ */
^ permalink raw reply
* vxlan gso is broken by stackable gso_segment()
From: Alexei Starovoitov @ 2013-10-24 23:37 UTC (permalink / raw)
To: Eric Dumazet, Stephen Hemminger; +Cc: David S. Miller, netdev
Hi Eric, Stephen,
it seems commit 3347c960 "ipv4: gso: make inet_gso_segment() stackable"
broke vxlan gso
the way to reproduce:
start two lxc with veth and bridge between them
create vxlan dev in both containers
do iperf
this setup on net-next does ~80 Mbps and a lot of tcp retransmits.
reverting 3347c960 and d3e5e006 gets performance back to ~230 Mbps
I guess vxlan driver suppose to set encap_level ? Some other way?
Thanks
Alexei
^ permalink raw reply
* Re: vxlan gso is broken by stackable gso_segment()
From: Eric Dumazet @ 2013-10-25 0:41 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Eric Dumazet, Stephen Hemminger, David S. Miller, netdev
In-Reply-To: <CAMEtUuxRhENE+OCFgdVASyVAaLo8AOdazUZdT+YHrcEzWA8Dow@mail.gmail.com>
On Thu, 2013-10-24 at 16:37 -0700, Alexei Starovoitov wrote:
> Hi Eric, Stephen,
>
> it seems commit 3347c960 "ipv4: gso: make inet_gso_segment() stackable"
> broke vxlan gso
>
> the way to reproduce:
> start two lxc with veth and bridge between them
> create vxlan dev in both containers
> do iperf
>
> this setup on net-next does ~80 Mbps and a lot of tcp retransmits.
> reverting 3347c960 and d3e5e006 gets performance back to ~230 Mbps
>
> I guess vxlan driver suppose to set encap_level ? Some other way?
Hi Alexei
Are the GRE tunnels broken as well for you ?
In my testings, GRE was working, and it looks GRE and vxlan has quite
similar gso implementation.
Maybe you can capture some of the broken frames with tcpdump ?
^ permalink raw reply
* [PATCH 0/4] sctp: do some clean up and fix comments
From: Wang Weidong @ 2013-10-25 1:50 UTC (permalink / raw)
To: davem, nhorman, vyasevich; +Cc: dingtianhong, linux-sctp, netdev
I found: two if statements do the same work, we can merge to one;
kmem_cache_zalloc will reset the memory, no need do the work
which initialize with 0; some spelling errors, then fix them.
Wang Weidong (4):
sctp: merge two if statements to one
sctp: remove the repeat initialize with 0
sctp: fix some comments in associola.c
sctp: fix comment in chunk.c
net/sctp/associola.c | 4 ++--
net/sctp/auth.c | 12 ++++--------
net/sctp/chunk.c | 2 +-
net/sctp/sm_make_chunk.c | 29 ++++++++---------------------
4 files changed, 15 insertions(+), 32 deletions(-)
--
1.7.12
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox