Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next 5/5] 6lowpan: remove unecessary break
From: David Miller @ 2013-10-25  3:42 UTC (permalink / raw)
  To: joe
  Cc: alex.bluesman.smirnov, alex.aring, linux-zigbee-devel, werner,
	dbaryshkov, netdev
In-Reply-To: <1382672451.2068.1.camel@joe-AO722>

From: Joe Perches <joe@perches.com>
Date: Thu, 24 Oct 2013 20:40:51 -0700

> On Fri, 2013-10-25 at 07:28 +0400, Alexander Smirnov wrote:
>> > 25 окт. 2013 г., в 0:51, Alexander Aring <alex.aring@gmail.com> написал(а):
> []
>> > diff --git 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;
>> >        }
>> > 
>> 
>> It's not an unnecessary, it's let say a "good coding practice" to have a break for every case including default. 
> 
> Hello Alexanders:
> 
> Some would otherwise say it's a poor practice.

I think with a goto there at the end of the case statement, it's redundant
and stupid, and thus should be removed.

^ permalink raw reply

* Re: [PATCH net-next 5/5] 6lowpan: remove unecessary break
From: Joe Perches @ 2013-10-25  3:40 UTC (permalink / raw)
  To: Alexander Smirnov
  Cc: Alexander Aring, linux-zigbee-devel@lists.sourceforge.net,
	werner@almesberger.net, dbaryshkov@gmail.com,
	netdev@vger.kernel.org
In-Reply-To: <EFDF4460-F8D0-4721-82F1-ABC3D5F75FDA@gmail.com>

On Fri, 2013-10-25 at 07:28 +0400, Alexander Smirnov wrote:
> > 25 окт. 2013 г., в 0:51, Alexander Aring <alex.aring@gmail.com> написал(а):
[]
> > diff --git 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;
> >        }
> > 
> 
> It's not an unnecessary, it's let say a "good coding practice" to have a break for every case including default. 

Hello Alexanders:

Some would otherwise say it's a poor practice.

^ permalink raw reply

* Re: [PATCH net-next 5/5] 6lowpan: remove unecessary break
From: Alexander Smirnov @ 2013-10-25  3:28 UTC (permalink / raw)
  To: Alexander Aring
  Cc: linux-zigbee-devel@lists.sourceforge.net, werner@almesberger.net,
	dbaryshkov@gmail.com, netdev@vger.kernel.org, Alexander Aring
In-Reply-To: <1382647904-11311-6-git-send-email-alex.aring@gmail.com>


> 25 окт. 2013 г., в 0:51, Alexander Aring <alex.aring@gmail.com> написал(а):
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> Reviewed-by: Werner Almesberger <werner@almesberger.net>
> ---
> 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;
>        }
> 

It's not an unnecessary, it's let say a "good coding practice" to have a break for every case including default. 

>        pr_debug("uncompressed UDP ports: src = %d, dst = %d\n",
> -- 
> 1.8.4.1
> 

^ permalink raw reply

* Re: vxlan gso is broken by stackable gso_segment()
From: Alexei Starovoitov @ 2013-10-25  1:59 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Eric Dumazet, Stephen Hemminger, David S. Miller, netdev
In-Reply-To: <1382661707.7572.73.camel@edumazet-glaptop.roam.corp.google.com>

gre seems to be fine.
packets seem to be segmented with wrong length and being dropped.
After client iperf is finished, in few seconds I see the warning:

[  329.669685] WARNING: CPU: 3 PID: 3817 at net/core/skbuff.c:3474
skb_try_coalesce+0x3a0/0x3f0()
[  329.669688] Modules linked in: vxlan ip_tunnel veth ip6table_filter
ip6_tables ebtable_nat ebtables nf_conntrack_ipv4 nf_defrag_ipv4
xt_state nf_conntrack xt_CHECKSUM iptable_mangle ipt_REJECT xt_tcpudp
iptable_filter ip_tables x_tables bridge stp llc vhost_net macvtap
macvlan vhost kvm_intel kvm iscsi_tcp libiscsi_tcp libiscsi
scsi_transport_iscsi dm_crypt hid_generic eeepc_wmi asus_wmi
sparse_keymap mxm_wmi dm_multipath psmouse serio_raw usbhid hid
parport_pc ppdev firewire_ohci e1000e firewire_core lpc_ich crc_itu_t
binfmt_misc igb dca ptp pps_core mac_hid wmi lp parport i2o_config
i2o_block video
[  329.669746] CPU: 3 PID: 3817 Comm: iperf Not tainted 3.12.0-rc6+ #81
[  329.669748] Hardware name: System manufacturer System Product
Name/P8Z77 WS, BIOS 3007 07/26/2012
[  329.669750]  0000000000000009 ffff88082fb839d8 ffffffff8175427a
0000000000000002
[  329.669756]  0000000000000000 ffff88082fb83a18 ffffffff8105206c
ffff880808f926f8
[  329.669760]  ffff8807ef122b00 ffff8807ef122a00 0000000000000576
ffff88082fb83a94
[  329.669765] Call Trace:
[  329.669767]  <IRQ>  [<ffffffff8175427a>] dump_stack+0x55/0x76
[  329.669779]  [<ffffffff8105206c>] warn_slowpath_common+0x8c/0xc0
[  329.669783]  [<ffffffff810520ba>] warn_slowpath_null+0x1a/0x20
[  329.669787]  [<ffffffff816150f0>] skb_try_coalesce+0x3a0/0x3f0
[  329.669793]  [<ffffffff8167bce4>] tcp_try_coalesce.part.44+0x34/0xa0
[  329.669797]  [<ffffffff8167d168>] tcp_queue_rcv+0x108/0x150
[  329.669801]  [<ffffffff8167f129>] tcp_data_queue+0x299/0xd00
[  329.669806]  [<ffffffff816822f4>] tcp_rcv_established+0x2d4/0x8f0
[  329.669809]  [<ffffffff8168d8b5>] tcp_v4_do_rcv+0x295/0x520
[  329.669813]  [<ffffffff8168fb08>] tcp_v4_rcv+0x888/0xc30
[  329.669818]  [<ffffffff816651d3>] ? ip_local_deliver_finish+0x43/0x480
[  329.669823]  [<ffffffff810cae04>] ? __lock_is_held+0x54/0x80
[  329.669827]  [<ffffffff816652fb>] ip_local_deliver_finish+0x16b/0x480
[  329.669831]  [<ffffffff816651d3>] ? ip_local_deliver_finish+0x43/0x480
[  329.669836]  [<ffffffff81666018>] ip_local_deliver+0x48/0x80
[  329.669840]  [<ffffffff81665770>] ip_rcv_finish+0x160/0x770
[  329.669845]  [<ffffffff816662f8>] ip_rcv+0x2a8/0x3e0
[  329.669849]  [<ffffffff81623d13>] __netif_receive_skb_core+0xa63/0xdb0
[  329.669853]  [<ffffffff816233b8>] ? __netif_receive_skb_core+0x108/0xdb0
[  329.669858]  [<ffffffff8175d37f>] ? _raw_spin_unlock_irqrestore+0x3f/0x70
[  329.669862]  [<ffffffff8162417b>] ? process_backlog+0xab/0x180
[  329.669866]  [<ffffffff81624081>] __netif_receive_skb+0x21/0x70
[  329.669869]  [<ffffffff81624184>] process_backlog+0xb4/0x180
[  329.669873]  [<ffffffff81626d08>] ? net_rx_action+0x98/0x350
[  329.669876]  [<ffffffff81626dca>] net_rx_action+0x15a/0x350
[  329.669882]  [<ffffffff81057f97>] __do_softirq+0xf7/0x3f0
[  329.669886]  [<ffffffff8176820c>] call_softirq+0x1c/0x30
[  329.669887]  <EOI>  [<ffffffff81004bed>] do_softirq+0x8d/0xc0
[  329.669896]  [<ffffffff8160de03>] ? release_sock+0x193/0x1f0
[  329.669901]  [<ffffffff81057a5b>] local_bh_enable_ip+0xdb/0xf0
[  329.669906]  [<ffffffff8175d2e4>] _raw_spin_unlock_bh+0x44/0x50
[  329.669910]  [<ffffffff8160de03>] release_sock+0x193/0x1f0
[  329.669914]  [<ffffffff81679237>] tcp_recvmsg+0x467/0x1030
[  329.669919]  [<ffffffff816ab424>] inet_recvmsg+0x134/0x230
[  329.669923]  [<ffffffff8160a17d>] sock_recvmsg+0xad/0xe0

to reproduce do:
$ sudo brctl addbr br0
$ sudo ifconfig br0 up
$ cat foo1.conf
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.ipv4 = 10.2.3.5/24
$sudo lxc-start -n foo1 -f ./foo1.conf bash
#ip li add vxlan0 type vxlan id 42 group 239.1.1.1 dev eth0
#ip addr add 192.168.99.1/24 dev vxlan0
#ip link set up dev vxlan0
#iperf -s

similar for another lxc with different IP
$sudo lxc-start -n foo2 -f ./foo2.conf bash
#ip li add vxlan0 type vxlan id 42 group 239.1.1.1 dev eth0
#ip addr add 192.168.99.2/24 dev vxlan0
#ip link set up dev vxlan0
# iperf -c 192.168.99.1

I keep hitting it all the time.


On Thu, Oct 24, 2013 at 5:41 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 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] Documentation/networking: netdev-FAQ typo corrections
From: Randy Dunlap @ 2013-10-25  1:56 UTC (permalink / raw)
  To: netdev@vger.kernel.org, David Miller; +Cc: Paul Gortmaker

From: Randy Dunlap <rdunlap@infradead.org>

Various typo fixes to netdev-FAQ.txt:
- capitalize Linux
- hyphenate dual-word adjectives
- minor punctuation fixes

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 Documentation/networking/netdev-FAQ.txt |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

--- lnx-312-rc6.orig/Documentation/networking/netdev-FAQ.txt
+++ lnx-312-rc6/Documentation/networking/netdev-FAQ.txt
@@ -4,23 +4,23 @@ Information you need to know about netde
 
 Q: What is netdev?
 
-A: It is a mailing list for all network related linux stuff.  This includes
+A: It is a mailing list for all network-related Linux stuff.  This includes
    anything found under net/  (i.e. core code like IPv6) and drivers/net
-   (i.e. hardware specific drivers) in the linux source tree.
+   (i.e. hardware specific drivers) in the Linux source tree.
 
    Note that some subsystems (e.g. wireless drivers) which have a high volume
    of traffic have their own specific mailing lists.
 
-   The netdev list is managed (like many other linux mailing lists) through
+   The netdev list is managed (like many other Linux mailing lists) through
    VGER ( http://vger.kernel.org/ ) and archives can be found below:
 
 	http://marc.info/?l=linux-netdev
 	http://www.spinics.net/lists/netdev/
 
-   Aside from subsystems like that mentioned above, all network related linux
-   development (i.e. RFC, review, comments, etc) takes place on netdev.
+   Aside from subsystems like that mentioned above, all network-related Linux
+   development (i.e. RFC, review, comments, etc.) takes place on netdev.
 
-Q: How do the changes posted to netdev make their way into linux?
+Q: How do the changes posted to netdev make their way into Linux?
 
 A: There are always two trees (git repositories) in play.  Both are driven
    by David Miller, the main network maintainer.  There is the "net" tree,
@@ -35,7 +35,7 @@ A: There are always two trees (git repos
 Q: How often do changes from these trees make it to the mainline Linus tree?
 
 A: To understand this, you need to know a bit of background information
-   on the cadence of linux development.  Each new release starts off with
+   on the cadence of Linux development.  Each new release starts off with
    a two week "merge window" where the main maintainers feed their new
    stuff to Linus for merging into the mainline tree.  After the two weeks,
    the merge window is closed, and it is called/tagged "-rc1".  No new
@@ -46,7 +46,7 @@ A: To understand this, you need to know
    things are in a state of churn), and a week after the last vX.Y-rcN
    was done, the official "vX.Y" is released.
 
-   Relating that to netdev:  At the beginning of the 2 week merge window,
+   Relating that to netdev:  At the beginning of the 2-week merge window,
    the net-next tree will be closed - no new changes/features.  The
    accumulated new content of the past ~10 weeks will be passed onto
    mainline/Linus via a pull request for vX.Y -- at the same time,
@@ -59,12 +59,12 @@ A: To understand this, you need to know
    IMPORTANT:  Do not send new net-next content to netdev during the
    period during which net-next tree is closed.
 
-   Shortly after the two weeks have passed, (and vX.Y-rc1 is released) the
+   Shortly after the two weeks have passed (and vX.Y-rc1 is released), the
    tree for net-next reopens to collect content for the next (vX.Y+1) release.
 
    If you aren't subscribed to netdev and/or are simply unsure if net-next
    has re-opened yet, simply check the net-next git repository link above for
-   any new networking related commits.
+   any new networking-related commits.
 
    The "net" tree continues to collect fixes for the vX.Y content, and
    is fed back to Linus at regular (~weekly) intervals.  Meaning that the
@@ -217,7 +217,7 @@ A: Attention to detail.  Re-read your ow
    to why it happens, and then if necessary, explain why the fix proposed
    is the best way to get things done.   Don't mangle whitespace, and as
    is common, don't mis-indent function arguments that span multiple lines.
-   If it is your 1st patch, mail it to yourself so you can test apply
+   If it is your first patch, mail it to yourself so you can test apply
    it to an unpatched tree to confirm infrastructure didn't mangle it.
 
    Finally, go back and read Documentation/SubmittingPatches to be

^ permalink raw reply

* [PATCH 3/4] sctp: fix some comments in associola.c
From: Wang Weidong @ 2013-10-25  1:50 UTC (permalink / raw)
  To: davem, nhorman, vyasevich; +Cc: dingtianhong, linux-sctp, netdev
In-Reply-To: <1382665805-13952-1-git-send-email-wangweidong1@huawei.com>

fix some spellings

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/sctp/associola.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index cef5099..c9b91cb 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -602,7 +602,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
 
 		/* Start a T3 timer here in case it wasn't running so
 		 * that these migrated packets have a chance to get
-		 * retrnasmitted.
+		 * retransmitted.
 		 */
 		if (!timer_pending(&active->T3_rtx_timer))
 			if (!mod_timer(&active->T3_rtx_timer,
@@ -665,7 +665,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
 	/* Set the path max_retrans.  */
 	peer->pathmaxrxt = asoc->pathmaxrxt;
 
-	/* And the partial failure retrnas threshold */
+	/* And the partial failure retrans threshold */
 	peer->pf_retrans = asoc->pf_retrans;
 
 	/* Initialize the peer's SACK delay timeout based on the
-- 
1.7.12

^ permalink raw reply related

* [PATCH 2/4] sctp: remove the repeat initialize with 0
From: Wang Weidong @ 2013-10-25  1:50 UTC (permalink / raw)
  To: davem, nhorman, vyasevich; +Cc: dingtianhong, linux-sctp, netdev
In-Reply-To: <1382665805-13952-1-git-send-email-wangweidong1@huawei.com>

kmem_cache_zalloc had set the allocated memory to zero. I think no need
to initialize with 0. And move the comments to the function begin.

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/sctp/sm_make_chunk.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index d244a23..fe69032 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1297,6 +1297,13 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc)
 
 /* Turn an skb into a chunk.
  * FIXME: Eventually move the structure directly inside the skb->cb[].
+ *
+ * sctpimpguide-05.txt Section 2.8.2
+ * M1) Each time a new DATA chunk is transmitted
+ * set the 'TSN.Missing.Report' count for that TSN to 0. The
+ * 'TSN.Missing.Report' count will be used to determine missing chunks
+ * and when to fast retransmit.
+ *
  */
 struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
 			    const struct sctp_association *asoc,
@@ -1314,29 +1321,9 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
 	INIT_LIST_HEAD(&retval->list);
 	retval->skb		= skb;
 	retval->asoc		= (struct sctp_association *)asoc;
-	retval->has_tsn		= 0;
-	retval->has_ssn         = 0;
-	retval->rtt_in_progress	= 0;
-	retval->sent_at		= 0;
 	retval->singleton	= 1;
-	retval->end_of_packet	= 0;
-	retval->ecn_ce_done	= 0;
-	retval->pdiscard	= 0;
-
-	/* sctpimpguide-05.txt Section 2.8.2
-	 * M1) Each time a new DATA chunk is transmitted
-	 * set the 'TSN.Missing.Report' count for that TSN to 0. The
-	 * 'TSN.Missing.Report' count will be used to determine missing chunks
-	 * and when to fast retransmit.
-	 */
-	retval->tsn_missing_report = 0;
-	retval->tsn_gap_acked = 0;
-	retval->fast_retransmit = SCTP_CAN_FRTX;
 
-	/* If this is a fragmented message, track all fragments
-	 * of the message (for SEND_FAILED).
-	 */
-	retval->msg = NULL;
+	retval->fast_retransmit = SCTP_CAN_FRTX;
 
 	/* Polish the bead hole.  */
 	INIT_LIST_HEAD(&retval->transmitted_list);
-- 
1.7.12

^ permalink raw reply related

* [PATCH 1/4] sctp: merge two if statements to one
From: Wang Weidong @ 2013-10-25  1:50 UTC (permalink / raw)
  To: davem, nhorman, vyasevich; +Cc: dingtianhong, linux-sctp, netdev
In-Reply-To: <1382665805-13952-1-git-send-email-wangweidong1@huawei.com>

Two if statements do the same work, maybe we can merge them to
one. There is just code simplification, no functional changes.

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/sctp/auth.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 8c4fa5d..19fb0ae 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -539,18 +539,14 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc)
 	for (i = 0; i < n_elt; i++) {
 		id = ntohs(hmacs->hmac_ids[i]);
 
-		/* Check the id is in the supported range */
-		if (id > SCTP_AUTH_HMAC_ID_MAX) {
-			id = 0;
-			continue;
-		}
-
-		/* See is we support the id.  Supported IDs have name and
+		/* Check the id is in the supported range. And
+		 * see is we support the id.  Supported IDs have name and
 		 * length fields set, so that we can allocated and use
 		 * them.  We can safely just check for name, for without the
 		 * name, we can't allocate the TFM.
 		 */
-		if (!sctp_hmac_list[id].hmac_name) {
+		if (id > SCTP_AUTH_HMAC_ID_MAX ||
+			!sctp_hmac_list[id].hmac_name) {
 			id = 0;
 			continue;
 		}
-- 
1.7.12

^ permalink raw reply related

* [PATCH 4/4] sctp: fix comment in chunk.c
From: Wang Weidong @ 2013-10-25  1:50 UTC (permalink / raw)
  To: davem, nhorman, vyasevich; +Cc: dingtianhong, linux-sctp, netdev
In-Reply-To: <1382665805-13952-1-git-send-email-wangweidong1@huawei.com>

fix a spelling

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/sctp/chunk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 7bd5ed4..f2044fc 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -201,7 +201,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
 
 	max = asoc->frag_point;
 	/* If the the peer requested that we authenticate DATA chunks
-	 * we need to accound for bundling of the AUTH chunks along with
+	 * we need to account for bundling of the AUTH chunks along with
 	 * DATA.
 	 */
 	if (sctp_auth_send_cid(SCTP_CID_DATA, asoc)) {
-- 
1.7.12

^ permalink raw reply related

* [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

* 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

* 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

* [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

* 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

* 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 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] 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] 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] 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

* [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

* [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] 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] 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

* 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

* 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


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox