Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net] r8152: Fix broken RX checksums.
From: Mark Lord @ 2016-10-31 13:24 UTC (permalink / raw)
  To: Hayes Wang, David Miller
  Cc: nic_swsd, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <0835B3720019904CB8F7AA43166CEEB201047353@RTITMBSV03.realtek.com.tw>

On 16-10-31 04:14 AM, Hayes Wang wrote:
>
> Our hw engineer says only VER_01 has the issue about rx checksum.
> I need more information for checking it.

I've been doing driver work for Linux since 1991,
and learned long ago not to trust engineering specs 100%.

Get yourself a Raspberry Pi v1, set up an NFSROOT root filesystem for it,
and boot/run from that using the ethernet dongle to connect.

It should segfault like crazy when hardware RX checksums are enabled.

Definitely something wrong there, and whatever it is goes away
when RX checksums are disabled in the driver.

I have two theories as to why this happens:

1) The hardware buffer on the dongle overflows because the slow host CPU
does not empty it quickly enough.  This results in a bad checksum on the
final/truncated packet in the buffer.  The chip does not detect this.

2) Perhaps the device driver is looking at the wrong bits.

Either way, this results in data corruption and until otherwise fixed,
it is safest to just not enable RX checksums.

If it happens on a slow embedded CPU, then it can also happen on a heavily
loaded Intel/AMD CPU -- just a lot less frequently.

Cheers
-- 
Mark Lord
Real-Time Remedies Inc.
mlord@pobox.com

^ permalink raw reply

* Re: mv643xx_eth.c merge gone bad...
From: David Miller @ 2016-10-31 13:12 UTC (permalink / raw)
  To: andrew; +Cc: jgunthorpe, jarod, netdev
In-Reply-To: <20161031113349.GA8951@lunn.ch>

From: Andrew Lunn <andrew@lunn.ch>
Date: Mon, 31 Oct 2016 12:33:49 +0100

> The merge of commit 27058af401e49d88a905df000dd26f443fcfa8ce for
> mv643xx_eth.c has gone bad:

Sorry this should be fixed now.

Thanks.

^ permalink raw reply

* Re: [PATCH net-next 3/4] bpf: BPF for lightweight tunnel encapsulation
From: Thomas Graf @ 2016-10-31 12:59 UTC (permalink / raw)
  To: Tom Herbert
  Cc: David S. Miller, Alexei Starovoitov, Daniel Borkmann,
	Linux Kernel Network Developers, roopa
In-Reply-To: <CALx6S35TOQumWFu1ha9nkNNOEwq2Y2VH6oCOK6F3HZg97omQgw@mail.gmail.com>

On 10/30/16 at 06:28pm, Tom Herbert wrote:
> Right, that's why we rely on a dst cache. Any use of LWT that
> encapsulates or tunnels to a fixed destination (ILA, VXLAN, IPIP,
> etc.) would want to use the dst cache optimization to avoid the second
> lookup. The ILA LWT code used to call orig output and that worked as
> long as we could set the default router as the gateway "via". It was
> something we were able to deploy, but not a general solution.
> Integrating properly with routing gives a much better solution IMO.
> Note that David Lebrun's latest LWT Segment Routing patch does the
> second lookup with the dst cache to try to avoid it.

Noticed while implementing this: How does ILA ensure that dst_output()
is not invoked in a circular manner?

dstA->output() -> dstB->otuput() -> dstA->output() -> ...

^ permalink raw reply

* Re: [PATCH net-next V3 0/9] liquidio CN23XX VF support
From: David Miller @ 2016-10-31 12:53 UTC (permalink / raw)
  To: Raghu.Vatsavayi; +Cc: netdev
In-Reply-To: <DM3PR07MB21386FE887D71590E16ED59B81AE0@DM3PR07MB2138.namprd07.prod.outlook.com>

From: "Vatsavayi, Raghu" <Raghu.Vatsavayi@cavium.com>
Date: Mon, 31 Oct 2016 07:21:27 +0000

> So please confirm if you want us to remove these two parameters
> num_queues_per_{p,v}f. Then I can remove these module parameters and
> resubmit the patches.

Yes.

We cannot allow drivers to keep adding unique ways to configure these
things.

There has to be a generic, consistent, mechanism the user can use
to control these parameters.  Rather than a per-driver unique one.

^ permalink raw reply

* [PATCHv2 net 3/3] sctp: hold transport instead of assoc when lookup assoc in rx path
From: Xin Long @ 2016-10-31 12:32 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, Marcelo Ricardo Leitner, Vlad Yasevich, Neil Horman
In-Reply-To: <cover.1477916928.git.lucien.xin@gmail.com>

Prior to this patch, in rx path, before calling lock_sock, it needed to
hold assoc when got it by __sctp_lookup_association, in case other place
would free/put assoc.

But in __sctp_lookup_association, it lookup and hold transport, then got
assoc by transport->assoc, then hold assoc and put transport. It means
it didn't hold transport, yet it was returned and later on directly
assigned to chunk->transport.

Without the protection of sock lock, the transport may be freed/put by
other places, which would cause a use-after-free issue.

This patch is to fix this issue by holding transport instead of assoc.
As holding transport can make sure to access assoc is also safe, and
actually it looks up assoc by searching transport rhashtable, to hold
transport here makes more sense.

Note that the function will be renamed later on on another patch.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h |  2 +-
 net/sctp/input.c        | 32 ++++++++++++++++----------------
 net/sctp/ipv6.c         |  2 +-
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 87a7f42..31acc3f 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -152,7 +152,7 @@ void sctp_unhash_endpoint(struct sctp_endpoint *);
 struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *,
 			     struct sctphdr *, struct sctp_association **,
 			     struct sctp_transport **);
-void sctp_err_finish(struct sock *, struct sctp_association *);
+void sctp_err_finish(struct sock *, struct sctp_transport *);
 void sctp_icmp_frag_needed(struct sock *, struct sctp_association *,
 			   struct sctp_transport *t, __u32 pmtu);
 void sctp_icmp_redirect(struct sock *, struct sctp_transport *,
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 8e0bc58..a01a56e 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -181,9 +181,10 @@ int sctp_rcv(struct sk_buff *skb)
 	 * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
 	 */
 	if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) {
-		if (asoc) {
-			sctp_association_put(asoc);
+		if (transport) {
+			sctp_transport_put(transport);
 			asoc = NULL;
+			transport = NULL;
 		} else {
 			sctp_endpoint_put(ep);
 			ep = NULL;
@@ -269,8 +270,8 @@ int sctp_rcv(struct sk_buff *skb)
 	bh_unlock_sock(sk);
 
 	/* Release the asoc/ep ref we took in the lookup calls. */
-	if (asoc)
-		sctp_association_put(asoc);
+	if (transport)
+		sctp_transport_put(transport);
 	else
 		sctp_endpoint_put(ep);
 
@@ -283,8 +284,8 @@ int sctp_rcv(struct sk_buff *skb)
 
 discard_release:
 	/* Release the asoc/ep ref we took in the lookup calls. */
-	if (asoc)
-		sctp_association_put(asoc);
+	if (transport)
+		sctp_transport_put(transport);
 	else
 		sctp_endpoint_put(ep);
 
@@ -300,6 +301,7 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
 {
 	struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
 	struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
+	struct sctp_transport *t = chunk->transport;
 	struct sctp_ep_common *rcvr = NULL;
 	int backloged = 0;
 
@@ -351,7 +353,7 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
 done:
 	/* Release the refs we took in sctp_add_backlog */
 	if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
-		sctp_association_put(sctp_assoc(rcvr));
+		sctp_transport_put(t);
 	else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
 		sctp_endpoint_put(sctp_ep(rcvr));
 	else
@@ -363,6 +365,7 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
 static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
 {
 	struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
+	struct sctp_transport *t = chunk->transport;
 	struct sctp_ep_common *rcvr = chunk->rcvr;
 	int ret;
 
@@ -373,7 +376,7 @@ static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
 		 * from us
 		 */
 		if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
-			sctp_association_hold(sctp_assoc(rcvr));
+			sctp_transport_hold(t);
 		else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
 			sctp_endpoint_hold(sctp_ep(rcvr));
 		else
@@ -537,15 +540,15 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
 	return sk;
 
 out:
-	sctp_association_put(asoc);
+	sctp_transport_put(transport);
 	return NULL;
 }
 
 /* Common cleanup code for icmp/icmpv6 error handler. */
-void sctp_err_finish(struct sock *sk, struct sctp_association *asoc)
+void sctp_err_finish(struct sock *sk, struct sctp_transport *t)
 {
 	bh_unlock_sock(sk);
-	sctp_association_put(asoc);
+	sctp_transport_put(t);
 }
 
 /*
@@ -641,7 +644,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
 	}
 
 out_unlock:
-	sctp_err_finish(sk, asoc);
+	sctp_err_finish(sk, transport);
 }
 
 /*
@@ -952,11 +955,8 @@ static struct sctp_association *__sctp_lookup_association(
 		goto out;
 
 	asoc = t->asoc;
-	sctp_association_hold(asoc);
 	*pt = t;
 
-	sctp_transport_put(t);
-
 out:
 	return asoc;
 }
@@ -986,7 +986,7 @@ int sctp_has_association(struct net *net,
 	struct sctp_transport *transport;
 
 	if ((asoc = sctp_lookup_association(net, laddr, paddr, &transport))) {
-		sctp_association_put(asoc);
+		sctp_transport_put(transport);
 		return 1;
 	}
 
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index f473779..176af30 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -198,7 +198,7 @@ static void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	}
 
 out_unlock:
-	sctp_err_finish(sk, asoc);
+	sctp_err_finish(sk, transport);
 out:
 	if (likely(idev != NULL))
 		in6_dev_put(idev);
-- 
2.1.0

^ permalink raw reply related

* [PATCHv2 net 2/3] sctp: return back transport in __sctp_rcv_init_lookup
From: Xin Long @ 2016-10-31 12:32 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, Marcelo Ricardo Leitner, Vlad Yasevich, Neil Horman
In-Reply-To: <cover.1477916928.git.lucien.xin@gmail.com>

Prior to this patch, it used a local variable to save the transport that is
looked up by __sctp_lookup_association(), and didn't return it back. But in
sctp_rcv, it is used to initialize chunk->transport. So when hitting this,
even if it found the transport, it was still initializing chunk->transport
with null instead.

This patch is to return the transport back through transport pointer
that is from __sctp_rcv_lookup_harder().

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/input.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sctp/input.c b/net/sctp/input.c
index a2ea1d1..8e0bc58 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -1021,7 +1021,6 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,
 	struct sctphdr *sh = sctp_hdr(skb);
 	union sctp_params params;
 	sctp_init_chunk_t *init;
-	struct sctp_transport *transport;
 	struct sctp_af *af;
 
 	/*
@@ -1052,7 +1051,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,
 
 		af->from_addr_param(paddr, params.addr, sh->source, 0);
 
-		asoc = __sctp_lookup_association(net, laddr, paddr, &transport);
+		asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
 		if (asoc)
 			return asoc;
 	}
-- 
2.1.0

^ permalink raw reply related

* [PATCHv2 net 1/3] sctp: hold transport instead of assoc in sctp_diag
From: Xin Long @ 2016-10-31 12:32 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, Marcelo Ricardo Leitner, Vlad Yasevich, Neil Horman
In-Reply-To: <cover.1477916928.git.lucien.xin@gmail.com>

In sctp_transport_lookup_process(), Commit 1cceda784980 ("sctp: fix
the issue sctp_diag uses lock_sock in rcu_read_lock") moved cb() out
of rcu lock, but it put transport and hold assoc instead, and ignore
that cb() still uses transport. It may cause a use-after-free issue.

This patch is to hold transport instead of assoc there.

Fixes: 1cceda784980 ("sctp: fix the issue sctp_diag uses lock_sock in rcu_read_lock")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/socket.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9fbb6fe..71b75f9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4480,12 +4480,9 @@ int sctp_transport_lookup_process(int (*cb)(struct sctp_transport *, void *),
 	if (!transport || !sctp_transport_hold(transport))
 		goto out;
 
-	sctp_association_hold(transport->asoc);
-	sctp_transport_put(transport);
-
 	rcu_read_unlock();
 	err = cb(transport, p);
-	sctp_association_put(transport->asoc);
+	sctp_transport_put(transport);
 
 out:
 	return err;
-- 
2.1.0

^ permalink raw reply related

* [PATCHv2 net 0/3] sctp: a bunch of fixes by holding transport
From: Xin Long @ 2016-10-31 12:32 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, Marcelo Ricardo Leitner, Vlad Yasevich, Neil Horman

There are several places where it holds assoc after getting transport by
searching from transport rhashtable, it may cause use-after-free issue.

This patchset is to fix them by holding transport instead.

v1->v2:
  Fix the changelog of patch 2/3

Xin Long (3):
  sctp: hold transport instead of assoc in sctp_diag
  sctp: return back transport in __sctp_rcv_init_lookup
  sctp: hold transport instead of assoc when lookup assoc in rx path

 include/net/sctp/sctp.h |  2 +-
 net/sctp/input.c        | 35 +++++++++++++++++------------------
 net/sctp/ipv6.c         |  2 +-
 net/sctp/socket.c       |  5 +----
 4 files changed, 20 insertions(+), 24 deletions(-)

-- 
2.1.0

^ permalink raw reply

* Re: [PATCHv2 net] sctp: return back transport in __sctp_rcv_init_lookup
From: Xin Long @ 2016-10-31 12:25 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, davem, Vlad Yasevich, Neil Horman
In-Reply-To: <20161031105155.GA8514@localhost.localdomain>

On Mon, Oct 31, 2016 at 6:51 PM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Mon, Oct 31, 2016 at 12:42:35AM +0800, Xin Long wrote:
>> Prior to this patch, it used a local variable to save the transport that is
>> looked up by __sctp_lookup_association(), and didn't return it back. But in
>> sctp_rcv, it is used to initialize chunk->transport. So when hitting this,
>> even if it found the transport, it was still initializing chunk->transport
>> with null instead.
>>
>> This patch is to return the transport back through transport pointer
>> that is from __sctp_rcv_lookup_harder().
>>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ---
>
> Patch looks good now but you have to either repost the entire series
> altogether, or repost the series to remove this patch from it.
Ah, sorry, will repost the entire series altogether.

>
>   Marcelo
>

^ permalink raw reply

* [PATCH net-next 4/4] bridge: mcast: add router port on PIM hello message
From: Nikolay Aleksandrov @ 2016-10-31 12:21 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dwalton, stephen, davem, Nikolay Aleksandrov
In-Reply-To: <1477916465-20406-1-git-send-email-nikolay@cumulusnetworks.com>

When we receive a PIM Hello message on a port we can consider that it
has a multicast router attached, thus it is correct to add it to the
router list. The only catch is it shouldn't be considered for a querier.

Using Daniel's description:
leaf-11  leaf-12  leaf-13
       \   |    /
        bridge-1
         /    \
    host-11  host-12

 - all ports in bridge-1 are in a single vlan aware bridge
 - leaf-11 is the IGMP querier
 - leaf-13 is the PIM DR
 - host-11 TXes packets to 226.10.10.10
 - bridge-1 only forwards the 226.10.10.10 traffic out the port to
   leaf-11, it should also forward this traffic out the port to leaf-13

Suggested-by: Daniel Walton <dwalton@cumulusnetworks.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 net/bridge/br_multicast.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 2136e45f5277..073d54afa056 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/inetdevice.h>
+#include <linux/mroute.h>
 #include <net/ip.h>
 #if IS_ENABLED(CONFIG_IPV6)
 #include <net/ipv6.h>
@@ -1638,6 +1639,21 @@ static void br_multicast_err_count(const struct net_bridge *br,
 	u64_stats_update_end(&pstats->syncp);
 }
 
+static void br_multicast_pim(struct net_bridge *br,
+			     struct net_bridge_port *port,
+			     const struct sk_buff *skb)
+{
+	unsigned int offset = skb_transport_offset(skb);
+	struct pimhdr *pimhdr, _pimhdr;
+
+	pimhdr = skb_header_pointer(skb, offset, sizeof(_pimhdr), &_pimhdr);
+	if (!pimhdr || pim_hdr_version(pimhdr) != PIM_VERSION ||
+	    pim_hdr_type(pimhdr) != PIM_TYPE_HELLO)
+		return;
+
+	br_multicast_mark_router(br, port);
+}
+
 static int br_multicast_ipv4_rcv(struct net_bridge *br,
 				 struct net_bridge_port *port,
 				 struct sk_buff *skb,
@@ -1650,8 +1666,12 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
 	err = ip_mc_check_igmp(skb, &skb_trimmed);
 
 	if (err == -ENOMSG) {
-		if (!ipv4_is_local_multicast(ip_hdr(skb)->daddr))
+		if (!ipv4_is_local_multicast(ip_hdr(skb)->daddr)) {
 			BR_INPUT_SKB_CB(skb)->mrouters_only = 1;
+		} else if (pim_ipv4_all_pim_routers(ip_hdr(skb)->daddr)) {
+			if (ip_hdr(skb)->protocol == IPPROTO_PIM)
+				br_multicast_pim(br, port, skb);
+		}
 		return 0;
 	} else if (err < 0) {
 		br_multicast_err_count(br, port, skb->protocol);
-- 
2.1.4

^ permalink raw reply related

* [PATCH net-next 3/4] net: pim: add all RFC7761 message types
From: Nikolay Aleksandrov @ 2016-10-31 12:21 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dwalton, stephen, davem, Nikolay Aleksandrov
In-Reply-To: <1477916465-20406-1-git-send-email-nikolay@cumulusnetworks.com>

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 include/linux/pim.h | 31 ++++++++++++++++++++++++++++++-
 net/ipv4/ipmr.c     |  2 +-
 net/ipv6/ip6mr.c    |  2 +-
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/include/linux/pim.h b/include/linux/pim.h
index 1b6c0dbba94e..0e81b2778ae0 100644
--- a/include/linux/pim.h
+++ b/include/linux/pim.h
@@ -10,7 +10,36 @@
 
 /* Message types - V2 */
 #define PIM_VERSION		2
-#define PIM_REGISTER		1
+
+/* RFC7761, sec 4.9:
+ *  Type
+ *        Types for specific PIM messages.  PIM Types are:
+ *
+ *  Message Type                          Destination
+ *  ---------------------------------------------------------------------
+ *  0 = Hello                             Multicast to ALL-PIM-ROUTERS
+ *  1 = Register                          Unicast to RP
+ *  2 = Register-Stop                     Unicast to source of Register
+ *                                        packet
+ *  3 = Join/Prune                        Multicast to ALL-PIM-ROUTERS
+ *  4 = Bootstrap                         Multicast to ALL-PIM-ROUTERS
+ *  5 = Assert                            Multicast to ALL-PIM-ROUTERS
+ *  6 = Graft (used in PIM-DM only)       Unicast to RPF'(S)
+ *  7 = Graft-Ack (used in PIM-DM only)   Unicast to source of Graft
+ *                                        packet
+ *  8 = Candidate-RP-Advertisement        Unicast to Domain's BSR
+ */
+enum {
+	PIM_TYPE_HELLO,
+	PIM_TYPE_REGISTER,
+	PIM_TYPE_REGISTER_STOP,
+	PIM_TYPE_JOIN_PRUNE,
+	PIM_TYPE_BOOTSTRAP,
+	PIM_TYPE_ASSERT,
+	PIM_TYPE_GRAFT,
+	PIM_TYPE_GRAFT_ACK,
+	PIM_TYPE_CANDIDATE_RP_ADV
+};
 
 #define PIM_NULL_REGISTER	cpu_to_be32(0x40000000)
 
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 5f006e13de56..51d71a70fbbe 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -2053,7 +2053,7 @@ static int pim_rcv(struct sk_buff *skb)
 		goto drop;
 
 	pim = (struct pimreghdr *)skb_transport_header(skb);
-	if (pim->type != ((PIM_VERSION << 4) | (PIM_REGISTER)) ||
+	if (pim->type != ((PIM_VERSION << 4) | (PIM_TYPE_REGISTER)) ||
 	    (pim->flags & PIM_NULL_REGISTER) ||
 	    (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
 	     csum_fold(skb_checksum(skb, 0, skb->len, 0))))
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 7f4265b1649b..52101b37ad6e 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -636,7 +636,7 @@ static int pim6_rcv(struct sk_buff *skb)
 		goto drop;
 
 	pim = (struct pimreghdr *)skb_transport_header(skb);
-	if (pim->type != ((PIM_VERSION << 4) | PIM_REGISTER) ||
+	if (pim->type != ((PIM_VERSION << 4) | PIM_TYPE_REGISTER) ||
 	    (pim->flags & PIM_NULL_REGISTER) ||
 	    (csum_ipv6_magic(&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
 			     sizeof(*pim), IPPROTO_PIM,
-- 
2.1.4

^ permalink raw reply related

* [PATCH net-next 2/4] net: pim: add a helper to check for IPv4 all pim routers address
From: Nikolay Aleksandrov @ 2016-10-31 12:21 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dwalton, stephen, davem, Nikolay Aleksandrov
In-Reply-To: <1477916465-20406-1-git-send-email-nikolay@cumulusnetworks.com>

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 include/linux/pim.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/pim.h b/include/linux/pim.h
index 354235a2691b..1b6c0dbba94e 100644
--- a/include/linux/pim.h
+++ b/include/linux/pim.h
@@ -57,4 +57,10 @@ static inline u8 pim_hdr_type(const struct pimhdr *pimhdr)
 {
 	return pimhdr->type & 0xf;
 }
+
+/* check if the address is 224.0.0.13, RFC7761 sec 4.3.1 */
+static inline bool pim_ipv4_all_pim_routers(__be32 addr)
+{
+	return addr == htonl(0xE000000D);
+}
 #endif
-- 
2.1.4

^ permalink raw reply related

* [PATCH net-next 1/4] net: pim: add common pimhdr struct and helpers
From: Nikolay Aleksandrov @ 2016-10-31 12:21 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dwalton, stephen, davem, Nikolay Aleksandrov
In-Reply-To: <1477916465-20406-1-git-send-email-nikolay@cumulusnetworks.com>

Add the common pimhdr structure and helpers to access it, also cleanup the
format of the header file.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 include/linux/pim.h | 44 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/include/linux/pim.h b/include/linux/pim.h
index e1d756f81348..354235a2691b 100644
--- a/include/linux/pim.h
+++ b/include/linux/pim.h
@@ -1,6 +1,7 @@
 #ifndef __LINUX_PIM_H
 #define __LINUX_PIM_H
 
+#include <linux/skbuff.h>
 #include <asm/byteorder.h>
 
 /* Message types - V1 */
@@ -13,20 +14,47 @@
 
 #define PIM_NULL_REGISTER	cpu_to_be32(0x40000000)
 
-static inline bool ipmr_pimsm_enabled(void)
-{
-	return IS_BUILTIN(CONFIG_IP_PIMSM_V1) || IS_BUILTIN(CONFIG_IP_PIMSM_V2);
-}
+/* RFC7761, sec 4.9:
+ * The PIM header common to all PIM messages is:
+ *   0                   1                   2                   3
+ *   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |PIM Ver| Type  |   Reserved    |           Checksum            |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct pimhdr {
+	__u8	type;
+	__u8	reserved;
+	__be16	csum;
+};
 
 /* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
-struct pimreghdr
-{
+struct pimreghdr {
 	__u8	type;
 	__u8	reserved;
 	__be16	csum;
 	__be32	flags;
 };
 
-struct sk_buff;
-extern int pim_rcv_v1(struct sk_buff *);
+int pim_rcv_v1(struct sk_buff *skb);
+
+static inline bool ipmr_pimsm_enabled(void)
+{
+	return IS_BUILTIN(CONFIG_IP_PIMSM_V1) || IS_BUILTIN(CONFIG_IP_PIMSM_V2);
+}
+
+static inline struct pimhdr *pim_hdr(const struct sk_buff *skb)
+{
+	return (struct pimhdr *)skb_transport_header(skb);
+}
+
+static inline u8 pim_hdr_version(const struct pimhdr *pimhdr)
+{
+	return pimhdr->type >> 4;
+}
+
+static inline u8 pim_hdr_type(const struct pimhdr *pimhdr)
+{
+	return pimhdr->type & 0xf;
+}
 #endif
-- 
2.1.4

^ permalink raw reply related

* [PATCH net-next 0/4] bridge: add support for PIM hello router ports
From: Nikolay Aleksandrov @ 2016-10-31 12:21 UTC (permalink / raw)
  To: netdev; +Cc: roopa, dwalton, stephen, davem, Nikolay Aleksandrov

Hi,
The first 3 patches of this set do minor cleanups and add some helpers to
the PIM header file. Patch 4 adds a way to detect mcast router ports via
PIM hello messages, they're marked as temporary and are not considered for
querier. There's more detailed information in patch 4's commit message.

Thanks,
 Nik


Nikolay Aleksandrov (4):
  net: pim: add common pimhdr struct and helpers
  net: pim: add a helper to check for IPv4 all pim routers address
  net: pim: add all RFC7761 message types
  bridge: mcast: add router port on PIM hello message

 include/linux/pim.h       | 81 +++++++++++++++++++++++++++++++++++++++++------
 net/bridge/br_multicast.c | 22 ++++++++++++-
 net/ipv4/ipmr.c           |  2 +-
 net/ipv6/ip6mr.c          |  2 +-
 4 files changed, 95 insertions(+), 12 deletions(-)

-- 
2.1.4

^ permalink raw reply

* Re: [PATCH net-next] ipv4: fib: Replay events when registering FIB notifier
From: kbuild test robot @ 2016-10-31 11:32 UTC (permalink / raw)
  To: idosch
  Cc: kbuild-all, netdev, davem, jiri, mlxsw, roopa, nikolay, dsa, andy,
	alexander.h.duyck, vivien.didelot, f.fainelli, andrew, kuznet,
	jmorris, yoshfuji, kaber, Ido Schimmel
In-Reply-To: <1477902578-20137-1-git-send-email-idosch@idosch.org>

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

Hi Ido,

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/idosch-idosch-org/ipv4-fib-Replay-events-when-registering-FIB-notifier/20161031-163334
config: x86_64-randconfig-s4-10311807 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from arch/x86/include/asm/uaccess.h:7:0,
                    from net/ipv4/fib_trie.c:53:
   net/ipv4/fib_trie.c: In function 'register_fib_notifier':
   net/ipv4/fib_trie.c:141:16: error: 'struct netns_ipv4' has no member named 'fib_has_custom_rules'
      if (net->ipv4.fib_has_custom_rules)
                   ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> net/ipv4/fib_trie.c:141:3: note: in expansion of macro 'if'
      if (net->ipv4.fib_has_custom_rules)
      ^~
   net/ipv4/fib_trie.c:141:16: error: 'struct netns_ipv4' has no member named 'fib_has_custom_rules'
      if (net->ipv4.fib_has_custom_rules)
                   ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> net/ipv4/fib_trie.c:141:3: note: in expansion of macro 'if'
      if (net->ipv4.fib_has_custom_rules)
      ^~
   net/ipv4/fib_trie.c:141:16: error: 'struct netns_ipv4' has no member named 'fib_has_custom_rules'
      if (net->ipv4.fib_has_custom_rules)
                   ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> net/ipv4/fib_trie.c:141:3: note: in expansion of macro 'if'
      if (net->ipv4.fib_has_custom_rules)
      ^~
   net/ipv4/fib_trie.c: In function 'unregister_fib_notifier':
   net/ipv4/fib_trie.c:178:16: error: 'struct netns_ipv4' has no member named 'fib_has_custom_rules'
      if (net->ipv4.fib_has_custom_rules)
                   ^
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   net/ipv4/fib_trie.c:178:3: note: in expansion of macro 'if'
      if (net->ipv4.fib_has_custom_rules)
      ^~
   net/ipv4/fib_trie.c:178:16: error: 'struct netns_ipv4' has no member named 'fib_has_custom_rules'
      if (net->ipv4.fib_has_custom_rules)
                   ^
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   net/ipv4/fib_trie.c:178:3: note: in expansion of macro 'if'
      if (net->ipv4.fib_has_custom_rules)
      ^~
   net/ipv4/fib_trie.c:178:16: error: 'struct netns_ipv4' has no member named 'fib_has_custom_rules'
      if (net->ipv4.fib_has_custom_rules)
                   ^
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   net/ipv4/fib_trie.c:178:3: note: in expansion of macro 'if'
      if (net->ipv4.fib_has_custom_rules)
      ^~

vim +/if +141 net/ipv4/fib_trie.c

    47	 *		Paul E. McKenney <paulmck@us.ibm.com>
    48	 *		Patrick McHardy <kaber@trash.net>
    49	 */
    50	
    51	#define VERSION "0.409"
    52	
  > 53	#include <asm/uaccess.h>
    54	#include <linux/bitops.h>
    55	#include <linux/types.h>
    56	#include <linux/kernel.h>
    57	#include <linux/mm.h>
    58	#include <linux/string.h>
    59	#include <linux/socket.h>
    60	#include <linux/sockios.h>
    61	#include <linux/errno.h>
    62	#include <linux/in.h>
    63	#include <linux/inet.h>
    64	#include <linux/inetdevice.h>
    65	#include <linux/netdevice.h>
    66	#include <linux/if_arp.h>
    67	#include <linux/proc_fs.h>
    68	#include <linux/rcupdate.h>
    69	#include <linux/skbuff.h>
    70	#include <linux/netlink.h>
    71	#include <linux/init.h>
    72	#include <linux/list.h>
    73	#include <linux/slab.h>
    74	#include <linux/export.h>
    75	#include <linux/vmalloc.h>
    76	#include <linux/notifier.h>
    77	#include <net/net_namespace.h>
    78	#include <net/ip.h>
    79	#include <net/protocol.h>
    80	#include <net/route.h>
    81	#include <net/tcp.h>
    82	#include <net/sock.h>
    83	#include <net/ip_fib.h>
    84	#include <trace/events/fib.h>
    85	#include "fib_lookup.h"
    86	
    87	static BLOCKING_NOTIFIER_HEAD(fib_chain);
    88	
    89	static void fib_notify(struct net *net, struct notifier_block *nb,
    90			       enum fib_event_type event_type);
    91	
    92	static int call_fib_notifier(struct notifier_block *nb, struct net *net,
    93				     enum fib_event_type event_type,
    94				     struct fib_notifier_info *info)
    95	{
    96		info->net = net;
    97		return nb->notifier_call(nb, event_type, info);
    98	}
    99	
   100	static int call_fib_entry_notifier(struct notifier_block *nb, struct net *net,
   101					   enum fib_event_type event_type, u32 dst,
   102					   int dst_len, struct fib_info *fi,
   103					   u8 tos, u8 type, u32 tb_id, u32 nlflags)
   104	{
   105		struct fib_entry_notifier_info info = {
   106			.dst = dst,
   107			.dst_len = dst_len,
   108			.fi = fi,
   109			.tos = tos,
   110			.type = type,
   111			.tb_id = tb_id,
   112			.nlflags = nlflags,
   113		};
   114		return call_fib_notifier(nb, net, event_type, &info.info);
   115	}
   116	
   117	/**
   118	 *	register_fib_notifier - register a fib notifier block
   119	 *	@nb: notifier
   120	 *
   121	 *	Register a notifier to be called when FIB entries or rules are
   122	 *	added or removed. A negative errno code is returned on failure.
   123	 *
   124	 *	When registered, all FIB addition events are replayed to the new
   125	 *	notifier to allow the caller to have a complete view of the FIB
   126	 *	tables.
   127	 */
   128	
   129	int register_fib_notifier(struct notifier_block *nb)
   130	{
   131		struct net *net;
   132		int err;
   133	
   134		rtnl_lock();
   135		err = blocking_notifier_chain_register(&fib_chain, nb);
   136		if (err)
   137			goto unlock;
   138		for_each_net(net) {
   139			struct fib_notifier_info info;
   140	
 > 141			if (net->ipv4.fib_has_custom_rules)
   142				call_fib_notifier(nb, net, FIB_EVENT_RULE_ADD, &info);
   143			fib_notify(net, nb, FIB_EVENT_ENTRY_ADD);
   144		}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27187 bytes --]

^ permalink raw reply

* mv643xx_eth.c merge gone bad...
From: Andrew Lunn @ 2016-10-31 11:33 UTC (permalink / raw)
  To: David Miller, jgunthorpe, jarod; +Cc: netdev

Hi Dave

The merge of commit 27058af401e49d88a905df000dd26f443fcfa8ce for
mv643xx_eth.c has gone bad:

@@@ -3203,12 -3204,6 +3220,15 @@@
        dev->priv_flags |= IFF_UNICAST_FLT;
        dev->gso_max_segs = MV643XX_MAX_TSO_SEGS;
  
++<<<<<<< HEAD
 +      /* MTU range: 64 - 9500 */
 +      dev->min_mtu = 64;
 +      dev->max_mtu = 9500;
 +
 +      SET_NETDEV_DEV(dev, &pdev->dev);
 +
++=======
++>>>>>>> 2a26d99b251b8625d27aed14e97fc10707a3a81f
        if (mp->shared->win_protect)
                wrl(mp, WINDOW_PROTECT(mp->port_num), mp->shared->win_protect);
  
  Andrew

^ permalink raw reply

* Re: [PATCH v2 1/2] net: stmmac: Add OXNAS Glue Driver
From: Joachim Eastwood @ 2016-10-31 11:12 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: peppe.cavallaro, alexandre.torgue, netdev, linux-oxnas,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <20161031105442.17228-1-narmstrong@baylibre.com>

Hi Neil,

On 31 October 2016 at 11:54, Neil Armstrong <narmstrong@baylibre.com> wrote:
> Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820.
>
> Acked-by: Joachim Eastwood <manabian@gmail.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
> +static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
> +{
> +       unsigned int value;
> +       int ret;
> +
> +       /* Reset HW here before changing the glue configuration */
> +       ret = device_reset(dwmac->dev);
> +       if (ret)
> +               return ret;
> +
> +       ret = clk_prepare_enable(dwmac->clk);
> +       if (ret)
> +               return ret;
> +
> +       ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
> +       if (ret < 0)
> +               return ret;

If regmap reading fails here, the clock will be left on as probe fails.


> +
> +       /* Enable GMII_GTXCLK to follow GMII_REFCLK, required for gigabit PHY */
> +       value |= BIT(DWMAC_CKEN_GTX)            |
> +                /* Use simple mux for 25/125 Mhz clock switching */
> +                BIT(DWMAC_SIMPLE_MUX)          |
> +                /* set auto switch tx clock source */
> +                BIT(DWMAC_AUTO_TX_SOURCE)      |
> +                /* enable tx & rx vardelay */
> +                BIT(DWMAC_CKEN_TX_OUT)         |
> +                BIT(DWMAC_CKEN_TXN_OUT)        |
> +                BIT(DWMAC_CKEN_TX_IN)          |
> +                BIT(DWMAC_CKEN_RX_OUT)         |
> +                BIT(DWMAC_CKEN_RXN_OUT)        |
> +                BIT(DWMAC_CKEN_RX_IN);
> +       regmap_write(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, value);
> +
> +       /* set tx & rx vardelay */
> +       value = DWMAC_TX_VARDELAY(4)    |
> +               DWMAC_TXN_VARDELAY(2)   |
> +               DWMAC_RX_VARDELAY(10)   |
> +               DWMAC_RXN_VARDELAY(8);
> +       regmap_write(dwmac->regmap, OXNAS_DWMAC_DELAY_REGOFFSET, value);
> +
> +       return 0;
> +}


regards,
Joachim Eastwood

^ permalink raw reply

* [PATCH v2 1/2] net: stmmac: Add OXNAS Glue Driver
From: Neil Armstrong @ 2016-10-31 10:54 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: Neil Armstrong, netdev, linux-oxnas, linux-arm-kernel,
	linux-kernel
In-Reply-To: <20161031105345.16711-1-narmstrong@baylibre.com>

Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820.

Acked-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/net/ethernet/stmicro/stmmac/Kconfig       |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile      |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c | 215 ++++++++++++++++++++++
 3 files changed, 227 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c

diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 3818c5e..6e9fcc3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -69,6 +69,17 @@ config DWMAC_MESON
 	  the stmmac device driver. This driver is used for Meson6,
 	  Meson8, Meson8b and GXBB SoCs.
 
+config DWMAC_OXNAS
+	tristate "Oxford Semiconductor OXNAS dwmac support"
+	default ARCH_OXNAS
+	depends on OF && COMMON_CLK && (ARCH_OXNAS || COMPILE_TEST)
+	select MFD_SYSCON
+	help
+	  Support for Ethernet controller on Oxford Semiconductor OXNAS SoCs.
+
+	  This selects the Oxford Semiconductor OXNASSoC glue layer support for
+	  the stmmac device driver. This driver is used for OX820.
+
 config DWMAC_ROCKCHIP
 	tristate "Rockchip dwmac support"
 	default ARCH_ROCKCHIP
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 5d6ece5..8f83a86 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
 obj-$(CONFIG_DWMAC_IPQ806X)	+= dwmac-ipq806x.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o dwmac-meson8b.o
+obj-$(CONFIG_DWMAC_OXNAS)	+= dwmac-oxnas.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-altr-socfpga.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
new file mode 100644
index 0000000..de3c36a
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
@@ -0,0 +1,215 @@
+/*
+ * Oxford Semiconductor OXNAS DWMAC glue layer
+ *
+ * Copyright (C) 2016 Neil Armstrong <narmstrong@baylibre.com>
+ * Copyright (C) 2014 Daniel Golle <daniel@makrotopia.org>
+ * Copyright (C) 2013 Ma Haijun <mahaijuns@gmail.com>
+ * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+#include <linux/stmmac.h>
+
+#include "stmmac_platform.h"
+
+/* System Control regmap offsets */
+#define OXNAS_DWMAC_CTRL_REGOFFSET	0x78
+#define OXNAS_DWMAC_DELAY_REGOFFSET	0x100
+
+/* Control Register */
+#define DWMAC_CKEN_RX_IN        14
+#define DWMAC_CKEN_RXN_OUT      13
+#define DWMAC_CKEN_RX_OUT       12
+#define DWMAC_CKEN_TX_IN        10
+#define DWMAC_CKEN_TXN_OUT      9
+#define DWMAC_CKEN_TX_OUT       8
+#define DWMAC_RX_SOURCE         7
+#define DWMAC_TX_SOURCE         6
+#define DWMAC_LOW_TX_SOURCE     4
+#define DWMAC_AUTO_TX_SOURCE    3
+#define DWMAC_RGMII             2
+#define DWMAC_SIMPLE_MUX        1
+#define DWMAC_CKEN_GTX          0
+
+/* Delay register */
+#define DWMAC_TX_VARDELAY_SHIFT		0
+#define DWMAC_TXN_VARDELAY_SHIFT	8
+#define DWMAC_RX_VARDELAY_SHIFT		16
+#define DWMAC_RXN_VARDELAY_SHIFT	24
+#define DWMAC_TX_VARDELAY(d)		((d) << DWMAC_TX_VARDELAY_SHIFT)
+#define DWMAC_TXN_VARDELAY(d)		((d) << DWMAC_TXN_VARDELAY_SHIFT)
+#define DWMAC_RX_VARDELAY(d)		((d) << DWMAC_RX_VARDELAY_SHIFT)
+#define DWMAC_RXN_VARDELAY(d)		((d) << DWMAC_RXN_VARDELAY_SHIFT)
+
+struct oxnas_dwmac {
+	struct device	*dev;
+	struct clk	*clk;
+	struct regmap	*regmap;
+};
+
+static int oxnas_dwmac_init(struct oxnas_dwmac *dwmac)
+{
+	unsigned int value;
+	int ret;
+
+	/* Reset HW here before changing the glue configuration */
+	ret = device_reset(dwmac->dev);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(dwmac->clk);
+	if (ret)
+		return ret;
+
+	ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
+	if (ret < 0)
+		return ret;
+
+	/* Enable GMII_GTXCLK to follow GMII_REFCLK, required for gigabit PHY */
+	value |= BIT(DWMAC_CKEN_GTX)		|
+		 /* Use simple mux for 25/125 Mhz clock switching */
+		 BIT(DWMAC_SIMPLE_MUX)		|
+		 /* set auto switch tx clock source */
+		 BIT(DWMAC_AUTO_TX_SOURCE)	|
+		 /* enable tx & rx vardelay */
+		 BIT(DWMAC_CKEN_TX_OUT)		|
+		 BIT(DWMAC_CKEN_TXN_OUT)	|
+		 BIT(DWMAC_CKEN_TX_IN)		|
+		 BIT(DWMAC_CKEN_RX_OUT)		|
+		 BIT(DWMAC_CKEN_RXN_OUT)	|
+		 BIT(DWMAC_CKEN_RX_IN);
+	regmap_write(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, value);
+
+	/* set tx & rx vardelay */
+	value = DWMAC_TX_VARDELAY(4)	|
+		DWMAC_TXN_VARDELAY(2)	|
+		DWMAC_RX_VARDELAY(10)	|
+		DWMAC_RXN_VARDELAY(8);
+	regmap_write(dwmac->regmap, OXNAS_DWMAC_DELAY_REGOFFSET, value);
+
+	return 0;
+}
+
+static int oxnas_dwmac_probe(struct platform_device *pdev)
+{
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
+	struct device_node *sysctrl;
+	struct oxnas_dwmac *dwmac;
+	int ret;
+
+	sysctrl = of_parse_phandle(pdev->dev.of_node, "oxsemi,sys-ctrl", 0);
+	if (!sysctrl) {
+		dev_err(&pdev->dev, "failed to get sys-ctrl node\n");
+		return -EINVAL;
+	}
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
+	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
+	if (!dwmac)
+		return -ENOMEM;
+
+	dwmac->dev = &pdev->dev;
+	plat_dat->bsp_priv = dwmac;
+
+	dwmac->regmap = syscon_node_to_regmap(sysctrl);
+	if (IS_ERR(dwmac->regmap)) {
+		dev_err(&pdev->dev, "failed to have sysctrl regmap\n");
+		return PTR_ERR(dwmac->regmap);
+	}
+
+	dwmac->clk = devm_clk_get(&pdev->dev, "gmac");
+	if (IS_ERR(dwmac->clk))
+		return PTR_ERR(dwmac->clk);
+
+	ret = oxnas_dwmac_init(dwmac);
+	if (ret)
+		return ret;
+
+	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+	if (ret)
+		clk_disable_unprepare(dwmac->clk);
+
+	return ret;
+}
+
+static int oxnas_dwmac_remove(struct platform_device *pdev)
+{
+	struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
+	int ret = stmmac_dvr_remove(&pdev->dev);
+
+	clk_disable_unprepare(dwmac->clk);
+
+	return ret;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int oxnas_dwmac_suspend(struct device *dev)
+{
+	struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(dev);
+	int ret;
+
+	ret = stmmac_suspend(dev);
+	clk_disable_unprepare(dwmac->clk);
+
+	return ret;
+}
+
+static int oxnas_dwmac_resume(struct device *dev)
+{
+	struct oxnas_dwmac *dwmac = get_stmmac_bsp_priv(dev);
+	int ret;
+
+	ret = oxnas_dwmac_init(dwmac);
+	if (ret)
+		return ret;
+
+	ret = stmmac_resume(dev);
+
+	return ret;
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(oxnas_dwmac_pm_ops,
+	oxnas_dwmac_suspend, oxnas_dwmac_resume);
+
+static const struct of_device_id oxnas_dwmac_match[] = {
+	{ .compatible = "oxsemi,ox820-dwmac" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
+
+static struct platform_driver oxnas_dwmac_driver = {
+	.probe  = oxnas_dwmac_probe,
+	.remove = oxnas_dwmac_remove,
+	.driver = {
+		.name           = "oxnas-dwmac",
+		.pm		= &oxnas_dwmac_pm_ops,
+		.of_match_table = oxnas_dwmac_match,
+	},
+};
+module_platform_driver(oxnas_dwmac_driver);
+
+MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
+MODULE_DESCRIPTION("Oxford Semiconductor OXNAS DWMAC glue layer");
+MODULE_LICENSE("GPL v2");
-- 
2.7.0

^ permalink raw reply related

* [PATCH v2 2/2] dt-bindings: net: Add OXNAS DWMAC Bindings
From: Neil Armstrong @ 2016-10-31 10:53 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: Neil Armstrong, netdev, linux-oxnas, linux-arm-kernel,
	linux-kernel, devicetree
In-Reply-To: <20161031105345.16711-1-narmstrong@baylibre.com>

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 .../devicetree/bindings/net/oxnas-dwmac.txt        | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/oxnas-dwmac.txt

diff --git a/Documentation/devicetree/bindings/net/oxnas-dwmac.txt b/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
new file mode 100644
index 0000000..df0534e
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
@@ -0,0 +1,39 @@
+* Oxford Semiconductor OXNAS DWMAC Ethernet controller
+
+The device inherits all the properties of the dwmac/stmmac devices
+described in the file stmmac.txt in the current directory with the
+following changes.
+
+Required properties on all platforms:
+
+- compatible:	For the OX820 SoC, it should be :
+		- "oxsemi,ox820-dwmac" to select glue
+		- "snps,dwmac-3.512" to select IP version.
+
+- clocks: Should contain phandles to the following clocks
+- clock-names:	Should contain the following:
+		- "stmmaceth" for the host clock - see stmmac.txt
+		- "gmac" for the peripheral gate clock
+
+- oxsemi,sys-ctrl: a phandle to the system controller syscon node
+
+Example :
+
+etha: ethernet@40400000 {
+	compatible = "oxsemi,ox820-dwmac", "snps,dwmac-3.512";
+	reg = <0x40400000 0x2000>;
+	interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
+	interrupt-names = "macirq", "eth_wake_irq";
+	mac-address = [000000000000]; /* Filled in by U-Boot */
+	phy-mode = "rgmii";
+
+	clocks = <&stdclk CLK_820_ETHA>, <&gmacclk>;
+	clock-names = "gmac", "stmmaceth";
+	resets = <&reset RESET_MAC>;
+
+	/* Regmap for sys registers */
+	oxsemi,sys-ctrl = <&sys>;
+
+	status = "disabled";
+};
-- 
2.7.0

^ permalink raw reply related

* [PATCH v2 0/2] net: stmmac: Add OXNAS DWMAC Glue
From: Neil Armstrong @ 2016-10-31 10:53 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue
  Cc: Neil Armstrong, netdev, linux-oxnas, linux-arm-kernel,
	linux-kernel

This patchset add support for the Sysnopsys DWMAC Gigabit Ethernet
controller Glue layer of the Oxford Semiconductor OX820 SoC.

Changes since v1 at https://patchwork.kernel.org/patch/9388231/ :
 - Split dt-bindings in a separate patch
 - Add IP version in the dt-bindings compatible
 - Check return of clk_prepare_enable()
 - use get_stmmac_bsp_priv() helper
 - hardwire setup values in oxnas_dwmac_init()

Changes since RFC at https://patchwork.kernel.org/patch/9387257 :
 - Drop init/exit callbacks
 - Implement proper remove and PM callback
 - Call init from probe
 - Disable/Unprepare clock if stmmac probe fails

Neil Armstrong (2):
  net: stmmac: Add OXNAS Glue Driver
  dt-bindings: net: Add OXNAS DWMAC Bindings

 .../devicetree/bindings/net/oxnas-dwmac.txt        |  39 ++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |  11 ++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c  | 215 +++++++++++++++++++++
 4 files changed, 266 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/oxnas-dwmac.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c

-- 
2.7.0

^ permalink raw reply

* Re: [PATCHv2 net] sctp: return back transport in __sctp_rcv_init_lookup
From: Marcelo Ricardo Leitner @ 2016-10-31 10:51 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, davem, Vlad Yasevich, Neil Horman
In-Reply-To: <8d72a86988a2c16c74c45c52dafbf2bbbe9c3b4d.1477845755.git.lucien.xin@gmail.com>

On Mon, Oct 31, 2016 at 12:42:35AM +0800, Xin Long wrote:
> Prior to this patch, it used a local variable to save the transport that is
> looked up by __sctp_lookup_association(), and didn't return it back. But in
> sctp_rcv, it is used to initialize chunk->transport. So when hitting this,
> even if it found the transport, it was still initializing chunk->transport
> with null instead.
> 
> This patch is to return the transport back through transport pointer
> that is from __sctp_rcv_lookup_harder().
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---

Patch looks good now but you have to either repost the entire series
altogether, or repost the series to remove this patch from it.

  Marcelo

^ permalink raw reply

* Re: [bnx2] [Regression 4.8] Driver loading fails without firmware
From: Paul Menzel @ 2016-10-31 10:43 UTC (permalink / raw)
  To: Baoquan He
  Cc: Sony Chacko, Dept-HSGLinuxNICDev, netdev, David S. Miller, dyoung
In-Reply-To: <20161031100944.GE7138@x1>

Dear Baoquan,


On 10/31/16 11:09, Baoquan He wrote:

> On 10/26/16 at 12:31pm, Paul Menzel wrote:
>> Baoquan, could you please fix this regression. My suggestion is, that you
>> add the old code back, but check if the firmware has been loaded. If it
>> hasn’t, load it again.
>>
>> That way, people can update their Linux kernel, and it continues working
>> without changing the initramfs, or anything else.
>
> I checked code and this looks good to me. I can post a patch with this
> change to upstream, see what maintainers and other reviewers say.
>
> The thing is I don't understand quite well about your requirement. With
> my understanding, you just didn't add bnx2 firmware into initramfs, but
> later opening the interface can still request that firmware with "ifup
> eth-xxx" command. Is that correct? If yes, requesting firmware twice in
> probing path and opening path looks good.
>
> However I am wondering what's your exact steps to do this.
>
> What I tried to do is I execute command "dracut --add-drivers bnx2 -f
> /boot/initramfs-4.9.0-rc3+.img 4.9.0-rc3+" to build a new initramfs,
> meanwhile make sure bnx2.ko is included, then uncompressed initramfs and
> deleted bnx2 folder under lib/firmware/ of uncompressed initramfs. Then
> pack them to be /boot/initramfs-4.9.0-rc3+.img and restart. I did saw
> below failure message. But later how did you really make the bnx2
> network interface up? Could you say it more specifically?
>
> [    7.364186] bnx2: QLogic bnx2 Gigabit Ethernet Driver v2.2.6 (January 29, 2014)
> [    7.371706] ACPI: PCI Interrupt Link [LN44] enabled at IRQ 44
> [    7.378128] bnx2 0000:01:00.0: Direct firmware load for bnx2/bnx2-mips-09-6.2.1b.fw failed with error -2
> [    7.387619] bnx2: Can't load firmware file "bnx2/bnx2-mips-09-6.2.1b.fw"
> [    7.387888] bnx2: probe of 0000:01:00.0 failed with error -2
> [    7.388990] ACPI: PCI Interrupt Link [LN45] enabled at IRQ 45
> [    7.389370] bnx2 0000:01:00.1: Direct firmware load for bnx2/bnx2-mips-09-6.2.1b.fw failed with error -2
> [    7.389371] bnx2: Can't load firmware file "bnx2/bnx2-mips-09-6.2.1b.fw"
> [    7.389475] bnx2: probe of 0000:01:00.1 failed with error -2

Hopefully I understood your questions correctly, so that my answers make 
sense.

First, sorry for not saying that earlier, on our system the driver is 
built into the Linux kernel.

```
$ grep BNX2 /boot/config-4.8.4.mx64.112
# CONFIG_SCSI_BNX2_ISCSI is not set
CONFIG_BNX2=y
CONFIG_BNX2X=y
CONFIG_BNX2X_SRIOV=y
```

Second, the filesystem driver is also built into the Linux kernel.

On our system, there is a systemd service unit, which sets up the 
network device.

```
$ more /etc/systemd/system/network.service
[Unit]
Description=Network Connectivity
DefaultDependencies=no

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/mxnetctl start
ExecStart=/sbin/ip addr add XXX broadcast XXX dev net00
ExecStart=/sbin/ip link set up dev net00
ExecStop=/sbin/ip addr del XXX dev net00
StandardOutput=syslog

[Install]
WantedBy=network.target
```

During that time, the hard drive has been detected, and the filesystem 
has been mounted.


Kind regards,

Paul

^ permalink raw reply

* Re: [PATCH] net: stmmac: Add OXNAS Glue Driver
From: Neil Armstrong @ 2016-10-31 10:25 UTC (permalink / raw)
  To: Joachim Eastwood
  Cc: Rob Herring, peppe.cavallaro, alexandre.torgue, netdev,
	linux-oxnas, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree
In-Reply-To: <CAGhQ9Vxy+boEPV3pvRCAWAWh-Tie31oS0PG7F6ix5_Wf=JHxgg@mail.gmail.com>

On 10/31/2016 11:20 AM, Joachim Eastwood wrote:
> Hi Neil,
> 
> On 31 October 2016 at 10:55, Neil Armstrong <narmstrong@baylibre.com> wrote:
>> On 10/30/2016 09:41 PM, Rob Herring wrote:
>>> On Fri, Oct 21, 2016 at 10:44:45AM +0200, Neil Armstrong wrote:
>>>> Add Synopsys Designware MAC Glue layer for the Oxford Semiconductor OX820.
>>>>
>>>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>>>> ---
>>>>  .../devicetree/bindings/net/oxnas-dwmac.txt        |  44 +++++
>>>
>>> It's preferred that bindings are a separate patch.
>>
>> OK
>>
>>>
>>>>  drivers/net/ethernet/stmicro/stmmac/Kconfig        |  11 ++
>>>>  drivers/net/ethernet/stmicro/stmmac/Makefile       |   1 +
>>>>  drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c  | 219 +++++++++++++++++++++
>>>>  4 files changed, 275 insertions(+)
>>>>  create mode 100644 Documentation/devicetree/bindings/net/oxnas-dwmac.txt
>>>>  create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-oxnas.c
>>>>
>>>> Changes since RFC at https://patchwork.kernel.org/patch/9387257 :
>>>>  - Drop init/exit callbacks
>>>>  - Implement proper remove and PM callback
>>>>  - Call init from probe
>>>>  - Disable/Unprepare clock if stmmac probe fails
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/net/oxnas-dwmac.txt b/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
>>>> new file mode 100644
>>>> index 0000000..5d2696c
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
>>>> @@ -0,0 +1,44 @@
>>>> +* Oxford Semiconductor OXNAS DWMAC Ethernet controller
>>>> +
>>>> +The device inherits all the properties of the dwmac/stmmac devices
>>>> +described in the file stmmac.txt in the current directory with the
>>>> +following changes.
>>>> +
>>>> +Required properties on all platforms:
>>>> +
>>>> +- compatible:       Depending on the platform this should be one of:
>>>> +                    - "oxsemi,ox820-dwmac"
>>>> +            Additionally "snps,dwmac" and any applicable more
>>>> +            detailed version number described in net/stmmac.txt
>>>> +            should be used.
>>>
>>> You should be explicit what version applies to ox820. "snps,dwmac"
>>> should probably be deprecated IMO. There are so many variations of DW
>>> h/w.
>>
>> Well, to be honest I have absolutely no idea ! But I will try to find out...
> 
> You can see in the boot log:
> 
> From lpc18xx boot:
> [    3.242253] stmmac - user ID: 0x11, Synopsys ID: 0x36
> [    3.247653]  Ring mode enabled
> [    3.251491]  DMA HW capability register supported
> [    3.256336]  Enhanced/Alternate descriptors
> [    3.261537]  Enabled extended descriptors
> [    3.265968]  RX Checksum Offload Engine supported (type 2)
> [    3.272249]  TX Checksum insertion supported
> [    3.276874]  Wake-Up On Lan supported
> [    3.283743]  Enable RX Mitigation via HW Watchdog Timer
> [    3.326701] libphy: stmmac: probed
> 
> Synopsys ID: 0x36 and user UD: 0x11, gives us DWMAC version 3.611
> 
> 
> regards,
> Joachim Eastwood
> 
OK, thanks !

stmmac - user ID: 0x12, Synopsys ID: 0x35

Neil

^ permalink raw reply

* Re: stmmac/RTL8211F/Meson GXBB: TX throughput problems
From: André Roth @ 2016-10-31 10:25 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: Giuseppe CAVALLARO, Johnson Leung, netdev, Alexandre Torgue,
	linux-amlogic
In-Reply-To: <CAFBinCC0HiEXx5mELztH6jYfUq2f1u0Tb+pSzAvwQSu9vYydGQ@mail.gmail.com>


Hi all,
 
> on my device this results in:
> [0xc9410018] = 0x2000000
> [0xc9410030] = 0x0
> [0xc941003c] = 0x0
> [0xc9411000] = 0x1100802
> [0xc9411018] = 0x2202006
> [0xc9411028] = 0x0
> 
> maybe someone else could try the command from above on his device
> (running the original Amlogic kernel).

those registers have the same value on an original image from
hardkernel: 

Linux odroid64 3.14.65-65 #1 SMP PREEMPT Sat May 28
02:50:51 BRT 2016 aarch64 aarch64 aarch64 GNU/Linux

> please also state if ethernet is working properly on the original
> kernel (and preferably which device/board this is).

yes, the ethernet works flawless in 100 and 1000 Mbit/s on the 3.14
kernel.

I can now confirm that both 100 and 1000 Mbit/s do not work properly
on the 4.8/integ branch. the network connection is interrupted after
some outbound traffic. it can be recovered by running a ifdown/ifup
which restarts dhclient, which I think is able to somehow reset the
interface. 

Anything I can help to debug the issue further ?

Regards,

 André
 

^ permalink raw reply

* Re: [net-next PATCH RFC 04/26] arch/arm: Add option to skip sync on DMA map and unmap
From: Russell King - ARM Linux @ 2016-10-31 10:20 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: netdev, linux-kernel, linux-mm, brouer, davem
In-Reply-To: <20161024120447.16276.50401.stgit@ahduyck-blue-test.jf.intel.com>

On Mon, Oct 24, 2016 at 08:04:47AM -0400, Alexander Duyck wrote:
> The use of DMA_ATTR_SKIP_CPU_SYNC was not consistent across all of the DMA
> APIs in the arch/arm folder.  This change is meant to correct that so that
> we get consistent behavior.

I'm really not convinced that this is anywhere close to correct behaviour.

If we're DMA-ing to a buffer, and we unmap it or sync_for_cpu, then we
will want to access the DMA'd data - especially in the sync_for_cpu case,
it's pointless to call sync_for_cpu if we're not going to access the
data.

So the idea of skipping the CPU copy when DMA_ATTR_SKIP_CPU_SYNC is set
seems to be completely wrong - it means we end up reading the stale data
that was in the buffer, completely ignoring whatever was DMA'd to it.

What's the use case for DMA_ATTR_SKIP_CPU_SYNC ?

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ 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