Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH v3] prism54: isl_38xx: Replace 'struct timeval'
From: Johannes Berg @ 2016-04-17 12:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: y2038, netdev, linux-wireless, Tina Ruchandani, linux-kernel
In-Reply-To: <5521267.mr5HLCdTY6@wuerfel>

On Sun, 2016-04-17 at 01:34 +0200, Arnd Bergmann wrote:
> On Wednesday 13 April 2016 10:38:26 Johannes Berg wrote:
> > 
> > > 
> > > The patch was build-tested / debugged by removing the
> > > "if VERBOSE > SHOW_ERROR_MESSAGES" guards.
> > Stands to reason that we should just remove the (more or less) dead
> > code, since I don't think anyone really ever touches this driver
> > any
> > more or will ever again ...
> Do you mean removing all DEBUG() statements from the driver, or
> removing the entire driver?
> 

We tried removing the driver once, since p54 supposedly drives the same
hardware, but some people had certain use cases that didn't work there,
apparently.

I was thinking more restrictively of just the stuff that can't even be
built without modifying the sources - like the "#if VERBOSE" thing.

johannes
_______________________________________________
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038

^ permalink raw reply

* Re: FlameGraph of mlx4 early drop with order-0 pages
From: Mel Gorman @ 2016-04-17 13:23 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: linux-mm, netdev@vger.kernel.org, Brenden Blanco, tom,
	alexei.starovoitov, ogerlitz, daniel, eric.dumazet, ecree,
	john.fastabend, tgraf, johannes, eranlinuxmellanox
In-Reply-To: <20160415214034.6ffae9ee@redhat.com>

On Fri, Apr 15, 2016 at 09:40:34PM +0200, Jesper Dangaard Brouer wrote:
> Hi Mel,
> 
> I did an experiment that you might find interesting.  Using Brenden's
> early drop with eBPF in the mxl4 driver.  I changed the mlx4 driver to
> use order-0 pages.  It usually use order-3 pages to amortize the cost
> of calling the page allocator (which is problematic for other reasons,
> like memory pin-down, latency spikes and multi CPU scalability)
> 
> With this change I could do around 12Mpps (Mill packet per sec) drops,
> usually does 14.5Mpps (limited due to a HW setup/limit, with idle cycles). 
> 
> Looking at the perf report as a FlameGraph, the page allocator clearly
> show up as the bottleneck: 
> 

Yeah, it's very obvious there. You didn't say if this had the optimisations
included or not but it doesn't really matter. Even halving the cost would
still be a lot.

FWIW, the latest series included an optimisation around the debugging
check. I also have an extreme patch that creates a special fast path for
order-0 pages only when there is plenty of free memory. It halved the
cost of the allocation side even on top of the current optimisations. I'm
not super-happy with it though as it duplicates some code and it requires
node-lru to be merged. Right now, node-lru is colliding very badly with
what's in mmotm so there is legwork required.

I also prototyped something that caches high-order pages on the per-cpu
lists on the flight over. It is at the "it builds so it must be ok"
stage. It's at the horrible hack and the accounting is quesionable but
something like it may be justified for SLUB even if network drivers move
away from high-order pages.

> Signing off, heading for the plane soon... see you at MM-summit!

Indeed and we'll slap some sort of plan together. If there is a slot free,
we might spend 15-30 minutes on it. Failing that, we'll grab a table
somewhere. We'll see how far we can get before considering a page-recycle
layer that preserves cache coherent state.

-- 
Mel Gorman
SUSE Labs

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

* [RFC PATCH] net: ipv4: add l3 and l4 multipath algorithms
From: Nikolay Aleksandrov @ 2016-04-17 14:29 UTC (permalink / raw)
  To: netdev
  Cc: tom, roopa, dsa, gospo, pch, davem, eric.dumazet,
	Nikolay Aleksandrov

Hi all,
I've been looking into adding both l3 and l4 multipath algorithms which
are consistent in both forwarded and locally originated traffic.
This attempt removes the old multipath code, and trades performance for
unifying both locally originated and forwarded traffic cases.
There's one case that is much faster though - for the forwarded case if the
l4 hash is already present we'll shortcircuit and use that.
We would like to see/implement the following items:
 1. Unified and consistent multipath for local and forwarded traffic
 2. Choice between different multipath algorithms
 3. IPv4 and IPv6 symmetry (as much as we can)
 4. Use of precomputed hash where possible

The first two points and partially the fourth are implemented by this
patch. Currently we can only be certain if the hash is L4, thus we can only
use skb->hash in the L4 hash case, the L3 hash is always computed.
Later we might revisit fib_multipath_hash and change it to accept enum
pkt_hash_types based on the precomputed hash that is passed.
Unfortunately I have to remove the special ICMP handling for now, I don't
mind adding the same workaround for IPv6 though, I'm not sure which is
preferred. This patch changes the IPv4 L4 hash to be computed only over
{src/dst IP, src/dst port, protocol}.

About the third point if a change like this is acceptable, I'll post the
respective IPv6 change which will make it symmetric in the way the hash
is derived.

And about the fourth point, I have a quick and dirty patch that passes
the socket txhash (currently randomly generated) for connected sockets down
to the multipath selection algorithm. It uses a 4 byte hole in flowi_common
to pass it down, but it's far from ready so I will not be submitting it with
this change.

The hash over flow_keys directly was chosen to avoid one zeroing and a few
initializations since if I were to use a flowi hash function it'd boil down
to flow_keys again, but I'd have to zero and initialize a fake flowi4 struct
as well. If this is not desired, I don't mind reverting to using the flowi4
version.

What do you think ?

Thanks,
 Nik

Note: if you'd like to minimize the performance hit for L3, I can simply
use the jhash_2words directly, but that would violate point 3.
---
 drivers/net/vrf.c              |  2 +-
 include/net/ip_fib.h           | 16 ++++----
 include/net/route.h            |  5 +--
 include/uapi/linux/rtnetlink.h | 10 ++++-
 net/ipv4/fib_frontend.c        |  8 ++++
 net/ipv4/fib_semantics.c       | 23 +++++++-----
 net/ipv4/icmp.c                | 19 +---------
 net/ipv4/route.c               | 83 +++++++++++++++++++++---------------------
 8 files changed, 82 insertions(+), 84 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 9a9fabb900c1..3ab7a62edb23 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -768,7 +768,7 @@ static int vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4)
 		if (res.type == RTN_LOCAL)
 			fl4->saddr = res.fi->fib_prefsrc ? : fl4->daddr;
 		else
-			fib_select_path(net, &res, fl4, -1);
+			fib_select_path(net, &res, fl4);
 	}
 
 	fl4->flowi4_flags = flags;
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 4079fc18ffe4..0ddcc028e520 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -37,6 +37,7 @@ struct fib_config {
 	u32			fc_flags;
 	u32			fc_priority;
 	__be32			fc_prefsrc;
+	u32			fc_mp_alg;
 	struct nlattr		*fc_mx;
 	struct rtnexthop	*fc_mp;
 	int			fc_mx_len;
@@ -120,6 +121,7 @@ struct fib_info {
 	int			fib_nhs;
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	int			fib_weight;
+	u32			fib_mp_alg;
 #endif
 	struct rcu_head		rcu;
 	struct fib_nh		fib_nh[0];
@@ -322,17 +324,13 @@ int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force);
 int fib_sync_down_addr(struct net *net, __be32 local);
 int fib_sync_up(struct net_device *dev, unsigned int nh_flags);
 
-extern u32 fib_multipath_secret __read_mostly;
-
-static inline int fib_multipath_hash(__be32 saddr, __be32 daddr)
-{
-	return jhash_2words((__force u32)saddr, (__force u32)daddr,
-			    fib_multipath_secret) >> 1;
-}
-
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4,
+		       const struct sk_buff *skb);
+#endif
 void fib_select_multipath(struct fib_result *res, int hash);
 void fib_select_path(struct net *net, struct fib_result *res,
-		     struct flowi4 *fl4, int mp_hash);
+		     struct flowi4 *fl4);
 
 /* Exported by fib_trie.c */
 void fib_trie_init(void);
diff --git a/include/net/route.h b/include/net/route.h
index f4b11eee1754..2146964bdf6d 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -114,13 +114,12 @@ struct in_device;
 int ip_rt_init(void);
 void rt_cache_flush(struct net *net);
 void rt_flush_dev(struct net_device *dev);
-struct rtable *__ip_route_output_key_hash(struct net *, struct flowi4 *flp,
-					  int mp_hash);
+struct rtable *__ip_route_output_key_hash(struct net *, struct flowi4 *flp);
 
 static inline struct rtable *__ip_route_output_key(struct net *net,
 						   struct flowi4 *flp)
 {
-	return __ip_route_output_key_hash(net, flp, -1);
+	return __ip_route_output_key_hash(net, flp);
 }
 
 struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 6be7fabf94a8..5d76194557d9 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -272,6 +272,14 @@ enum rt_scope_t {
 #define RTM_F_PREFIX		0x800	/* Prefix addresses		*/
 #define RTM_F_LOOKUP_TABLE	0x1000	/* set rtm_table to FIB lookup result */
 
+/* Multipath algorithms */
+enum rt_mp_alg_t {
+	RT_MP_ALG_L3_HASH,
+	RT_MP_ALG_L4_HASH,
+	__RT_MP_ALG_MAX
+};
+#define RT_MP_ALG_MAX (__RT_MP_ALG_MAX - 1)
+
 /* Reserved table identifiers */
 
 enum rt_class_t {
@@ -302,7 +310,7 @@ enum rtattr_type_t {
 	RTA_FLOW,
 	RTA_CACHEINFO,
 	RTA_SESSION, /* no longer used */
-	RTA_MP_ALGO, /* no longer used */
+	RTA_MP_ALGO,
 	RTA_TABLE,
 	RTA_MARK,
 	RTA_MFC_STATS,
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 8a9246deccfe..0aecfec8f7a6 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -624,6 +624,7 @@ const struct nla_policy rtm_ipv4_policy[RTA_MAX + 1] = {
 	[RTA_PREFSRC]		= { .type = NLA_U32 },
 	[RTA_METRICS]		= { .type = NLA_NESTED },
 	[RTA_MULTIPATH]		= { .len = sizeof(struct rtnexthop) },
+	[RTA_MP_ALGO]		= { .type = NLA_U32 },
 	[RTA_FLOW]		= { .type = NLA_U32 },
 	[RTA_ENCAP_TYPE]	= { .type = NLA_U16 },
 	[RTA_ENCAP]		= { .type = NLA_NESTED },
@@ -686,6 +687,13 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
 			cfg->fc_mp = nla_data(attr);
 			cfg->fc_mp_len = nla_len(attr);
 			break;
+		case RTA_MP_ALGO:
+			cfg->fc_mp_alg = nla_get_u32(attr);
+			if (cfg->fc_mp_alg > RT_MP_ALG_MAX) {
+				err = -EINVAL;
+				goto errout;
+			}
+			break;
 		case RTA_FLOW:
 			cfg->fc_flow = nla_get_u32(attr);
 			break;
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index ab64d9f2eef9..8af436352ec4 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -57,7 +57,6 @@ static unsigned int fib_info_cnt;
 static struct hlist_head fib_info_devhash[DEVINDEX_HASHSIZE];
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
-u32 fib_multipath_secret __read_mostly;
 
 #define for_nexthops(fi) {						\
 	int nhsel; const struct fib_nh *nh;				\
@@ -257,6 +256,11 @@ static inline int nh_comp(const struct fib_info *fi, const struct fib_info *ofi)
 {
 	const struct fib_nh *onh = ofi->fib_nh;
 
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+	if (fi->fib_mp_alg != ofi->fib_mp_alg)
+		return -1;
+#endif
+
 	for_nexthops(fi) {
 		if (nh->nh_oif != onh->nh_oif ||
 		    nh->nh_gw  != onh->nh_gw ||
@@ -575,9 +579,6 @@ static void fib_rebalance(struct fib_info *fi)
 
 		atomic_set(&nexthop_nh->nh_upper_bound, upper_bound);
 	} endfor_nexthops(fi);
-
-	net_get_random_once(&fib_multipath_secret,
-			    sizeof(fib_multipath_secret));
 }
 
 static inline void fib_add_weight(struct fib_info *fi,
@@ -1064,6 +1065,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
 
 	if (cfg->fc_mp) {
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
+		fi->fib_mp_alg = cfg->fc_mp_alg;
 		err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg);
 		if (err != 0)
 			goto failure;
@@ -1277,6 +1279,9 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
 		struct rtnexthop *rtnh;
 		struct nlattr *mp;
 
+		if (nla_put_u32(skb, RTA_MP_ALGO, fi->fib_mp_alg))
+			goto nla_put_failure;
+
 		mp = nla_nest_start(skb, RTA_MULTIPATH);
 		if (!mp)
 			goto nla_put_failure;
@@ -1602,16 +1607,14 @@ void fib_select_multipath(struct fib_result *res, int hash)
 #endif
 
 void fib_select_path(struct net *net, struct fib_result *res,
-		     struct flowi4 *fl4, int mp_hash)
+		     struct flowi4 *fl4)
 {
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	if (res->fi->fib_nhs > 1 && fl4->flowi4_oif == 0) {
-		if (mp_hash < 0)
-			mp_hash = get_hash_from_flowi4(fl4) >> 1;
+		int h = fib_multipath_hash(res->fi, fl4, NULL);
 
-		fib_select_multipath(res, mp_hash);
-	}
-	else
+		fib_select_multipath(res, h);
+	} else
 #endif
 	if (!res->prefixlen &&
 	    res->table->tb_num_default > 1 &&
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 6333489771ed..51a4db5f22ad 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -440,22 +440,6 @@ out_unlock:
 	icmp_xmit_unlock(sk);
 }
 
-#ifdef CONFIG_IP_ROUTE_MULTIPATH
-
-/* Source and destination is swapped. See ip_multipath_icmp_hash */
-static int icmp_multipath_hash_skb(const struct sk_buff *skb)
-{
-	const struct iphdr *iph = ip_hdr(skb);
-
-	return fib_multipath_hash(iph->daddr, iph->saddr);
-}
-
-#else
-
-#define icmp_multipath_hash_skb(skb) (-1)
-
-#endif
-
 static struct rtable *icmp_route_lookup(struct net *net,
 					struct flowi4 *fl4,
 					struct sk_buff *skb_in,
@@ -480,8 +464,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
 	fl4->flowi4_oif = l3mdev_master_ifindex(skb_in->dev);
 
 	security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
-	rt = __ip_route_output_key_hash(net, fl4,
-					icmp_multipath_hash_skb(skb_in));
+	rt = __ip_route_output_key_hash(net, fl4);
 	if (IS_ERR(rt))
 		return rt;
 
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 02c62299d717..fba9de1f02d9 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1692,45 +1692,49 @@ out:
 }
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
-
-/* To make ICMP packets follow the right flow, the multipath hash is
- * calculated from the inner IP addresses in reverse order.
- */
-static int ip_multipath_icmp_hash(struct sk_buff *skb)
+int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4,
+		       const struct sk_buff *skb)
 {
-	const struct iphdr *outer_iph = ip_hdr(skb);
-	struct icmphdr _icmph;
-	const struct icmphdr *icmph;
-	struct iphdr _inner_iph;
-	const struct iphdr *inner_iph;
-
-	if (unlikely((outer_iph->frag_off & htons(IP_OFFSET)) != 0))
-		goto standard_hash;
+	struct flow_keys hash_keys;
+	u32 mhash;
 
-	icmph = skb_header_pointer(skb, outer_iph->ihl * 4, sizeof(_icmph),
-				   &_icmph);
-	if (!icmph)
-		goto standard_hash;
-
-	if (icmph->type != ICMP_DEST_UNREACH &&
-	    icmph->type != ICMP_REDIRECT &&
-	    icmph->type != ICMP_TIME_EXCEEDED &&
-	    icmph->type != ICMP_PARAMETERPROB) {
-		goto standard_hash;
+	switch (fi->fib_mp_alg) {
+	case RT_MP_ALG_L3_HASH:
+		memset(&hash_keys, 0, sizeof(hash_keys));
+		hash_keys.addrs.v4addrs.src = fl4->saddr;
+		hash_keys.addrs.v4addrs.dst = fl4->daddr;
+		break;
+	case RT_MP_ALG_L4_HASH:
+		/* skb is currently provided only when forwarding */
+		if (skb) {
+			unsigned int flag = FLOW_DISSECTOR_F_STOP_AT_ENCAP;
+			struct flow_keys keys;
+
+			/* short-circuit if we already have L4 hash present */
+			if (skb->l4_hash)
+				return skb_get_hash_raw(skb) >> 1;
+			memset(&hash_keys, 0, sizeof(hash_keys));
+			skb_flow_dissect_flow_keys(skb, &keys, flag);
+			hash_keys.addrs.v4addrs.src = keys.addrs.v4addrs.src;
+			hash_keys.addrs.v4addrs.dst = keys.addrs.v4addrs.dst;
+			hash_keys.ports.src = keys.ports.src;
+			hash_keys.ports.dst = keys.ports.dst;
+			hash_keys.basic.ip_proto = keys.basic.ip_proto;
+		} else {
+			memset(&hash_keys, 0, sizeof(hash_keys));
+			hash_keys.addrs.v4addrs.src = fl4->saddr;
+			hash_keys.addrs.v4addrs.dst = fl4->daddr;
+			hash_keys.ports.src = fl4->fl4_sport;
+			hash_keys.ports.dst = fl4->fl4_dport;
+			hash_keys.basic.ip_proto = fl4->flowi4_proto;
+		}
+		break;
 	}
+	mhash = flow_hash_from_keys(&hash_keys);
 
-	inner_iph = skb_header_pointer(skb,
-				       outer_iph->ihl * 4 + sizeof(_icmph),
-				       sizeof(_inner_iph), &_inner_iph);
-	if (!inner_iph)
-		goto standard_hash;
-
-	return fib_multipath_hash(inner_iph->daddr, inner_iph->saddr);
-
-standard_hash:
-	return fib_multipath_hash(outer_iph->saddr, outer_iph->daddr);
+	return mhash >> 1;
 }
-
+EXPORT_SYMBOL_GPL(fib_multipath_hash);
 #endif /* CONFIG_IP_ROUTE_MULTIPATH */
 
 static int ip_mkroute_input(struct sk_buff *skb,
@@ -1741,12 +1745,8 @@ static int ip_mkroute_input(struct sk_buff *skb,
 {
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 	if (res->fi && res->fi->fib_nhs > 1) {
-		int h;
+		int h = fib_multipath_hash(res->fi, fl4, skb);
 
-		if (unlikely(ip_hdr(skb)->protocol == IPPROTO_ICMP))
-			h = ip_multipath_icmp_hash(skb);
-		else
-			h = fib_multipath_hash(saddr, daddr);
 		fib_select_multipath(res, h);
 	}
 #endif
@@ -2125,8 +2125,7 @@ add:
  * Major route resolver routine.
  */
 
-struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
-					  int mp_hash)
+struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4)
 {
 	struct net_device *dev_out = NULL;
 	__u8 tos = RT_FL_TOS(fl4);
@@ -2289,7 +2288,7 @@ struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
 		goto make_route;
 	}
 
-	fib_select_path(net, &res, fl4, mp_hash);
+	fib_select_path(net, &res, fl4);
 
 	dev_out = FIB_RES_DEV(res);
 	fl4->flowi4_oif = dev_out->ifindex;
-- 
2.4.11

^ permalink raw reply related

* Re: [PATCH net-next v3 2/8] net: dsa: mv88e6xxx: drop revision probing
From: Andrew Lunn @ 2016-04-17 15:24 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <1460846505-20305-3-git-send-email-vivien.didelot@savoirfairelinux.com>

On Sat, Apr 16, 2016 at 06:41:39PM -0400, Vivien Didelot wrote:
> There is no point in having a special case for the revision when probing
> a switch model. The code gets cluttered with unnecessary defines, and
> leads to errors when code such as mv88e6131_setup compares
> PORT_SWITCH_ID_6131_B2 to ps->id which masks the revision.
> 
> Drop every revision definition, and lookup only the product number.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks
	Andrew

> ---
>  drivers/net/dsa/mv88e6123.c |  6 ------
>  drivers/net/dsa/mv88e6131.c |  2 --
>  drivers/net/dsa/mv88e6352.c |  6 ------
>  drivers/net/dsa/mv88e6xxx.c | 14 +-------------
>  drivers/net/dsa/mv88e6xxx.h | 15 ---------------
>  5 files changed, 1 insertion(+), 42 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
> index 88a812d..00c1121 100644
> --- a/drivers/net/dsa/mv88e6123.c
> +++ b/drivers/net/dsa/mv88e6123.c
> @@ -19,14 +19,8 @@
>  
>  static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
>  	{ PORT_SWITCH_ID_6123, "Marvell 88E6123" },
> -	{ PORT_SWITCH_ID_6123_A1, "Marvell 88E6123 (A1)" },
> -	{ PORT_SWITCH_ID_6123_A2, "Marvell 88E6123 (A2)" },
>  	{ PORT_SWITCH_ID_6161, "Marvell 88E6161" },
> -	{ PORT_SWITCH_ID_6161_A1, "Marvell 88E6161 (A1)" },
> -	{ PORT_SWITCH_ID_6161_A2, "Marvell 88E6161 (A2)" },
>  	{ PORT_SWITCH_ID_6165, "Marvell 88E6165" },
> -	{ PORT_SWITCH_ID_6165_A1, "Marvell 88E6165 (A1)" },
> -	{ PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" },
>  };
>  
>  static char *mv88e6123_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
> index 6b2bcb0..df534da 100644
> --- a/drivers/net/dsa/mv88e6131.c
> +++ b/drivers/net/dsa/mv88e6131.c
> @@ -21,7 +21,6 @@ static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
>  	{ PORT_SWITCH_ID_6085, "Marvell 88E6085" },
>  	{ PORT_SWITCH_ID_6095, "Marvell 88E6095/88E6095F" },
>  	{ PORT_SWITCH_ID_6131, "Marvell 88E6131" },
> -	{ PORT_SWITCH_ID_6131_B2, "Marvell 88E6131 (B2)" },
>  	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
>  };
>  
> @@ -109,7 +108,6 @@ static int mv88e6131_setup(struct dsa_switch *ds)
>  		ps->num_ports = 11;
>  		break;
>  	case PORT_SWITCH_ID_6131:
> -	case PORT_SWITCH_ID_6131_B2:
>  		ps->num_ports = 8;
>  		break;
>  	default:
> diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
> index dbd920e..30fc5f6 100644
> --- a/drivers/net/dsa/mv88e6352.c
> +++ b/drivers/net/dsa/mv88e6352.c
> @@ -27,14 +27,8 @@ static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
>  	{ PORT_SWITCH_ID_6176, "Marvell 88E6176" },
>  	{ PORT_SWITCH_ID_6240, "Marvell 88E6240" },
>  	{ PORT_SWITCH_ID_6320, "Marvell 88E6320" },
> -	{ PORT_SWITCH_ID_6320_A1, "Marvell 88E6320 (A1)" },
> -	{ PORT_SWITCH_ID_6320_A2, "Marvell 88e6320 (A2)" },
>  	{ PORT_SWITCH_ID_6321, "Marvell 88E6321" },
> -	{ PORT_SWITCH_ID_6321_A1, "Marvell 88E6321 (A1)" },
> -	{ PORT_SWITCH_ID_6321_A2, "Marvell 88e6321 (A2)" },
>  	{ PORT_SWITCH_ID_6352, "Marvell 88E6352" },
> -	{ PORT_SWITCH_ID_6352_A0, "Marvell 88E6352 (A0)" },
> -	{ PORT_SWITCH_ID_6352_A1, "Marvell 88E6352 (A1)" },
>  };
>  
>  static char *mv88e6352_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 9985a0c..b63e985 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -3081,22 +3081,10 @@ static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
>  	if (ret < 0)
>  		return NULL;
>  
> -	/* Look up the exact switch ID */
>  	for (i = 0; i < num; ++i)
> -		if (table[i].id == ret)
> +		if (table[i].id == (ret & 0xfff0))
>  			return table[i].name;
>  
> -	/* Look up only the product number */
> -	for (i = 0; i < num; ++i) {
> -		if (table[i].id == (ret & PORT_SWITCH_ID_PROD_NUM_MASK)) {
> -			dev_warn(&bus->dev,
> -				 "unknown revision %d, using base switch 0x%x\n",
> -				 ret & PORT_SWITCH_ID_REV_MASK,
> -				 ret & PORT_SWITCH_ID_PROD_NUM_MASK);
> -			return table[i].name;
> -		}
> -	}
> -
>  	return NULL;
>  }
>  
> diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
> index 5d27dec..9242aea 100644
> --- a/drivers/net/dsa/mv88e6xxx.h
> +++ b/drivers/net/dsa/mv88e6xxx.h
> @@ -68,8 +68,6 @@
>  #define PORT_PCS_CTRL_UNFORCED		0x03
>  #define PORT_PAUSE_CTRL		0x02
>  #define PORT_SWITCH_ID		0x03
> -#define PORT_SWITCH_ID_PROD_NUM_MASK	0xfff0
> -#define PORT_SWITCH_ID_REV_MASK		0x000f
>  #define PORT_SWITCH_ID_6031	0x0310
>  #define PORT_SWITCH_ID_6035	0x0350
>  #define PORT_SWITCH_ID_6046	0x0480
> @@ -84,18 +82,11 @@
>  #define PORT_SWITCH_ID_6121	0x1040
>  #define PORT_SWITCH_ID_6122	0x1050
>  #define PORT_SWITCH_ID_6123	0x1210
> -#define PORT_SWITCH_ID_6123_A1	0x1212
> -#define PORT_SWITCH_ID_6123_A2	0x1213
>  #define PORT_SWITCH_ID_6131	0x1060
> -#define PORT_SWITCH_ID_6131_B2	0x1066
>  #define PORT_SWITCH_ID_6152	0x1a40
>  #define PORT_SWITCH_ID_6155	0x1a50
>  #define PORT_SWITCH_ID_6161	0x1610
> -#define PORT_SWITCH_ID_6161_A1	0x1612
> -#define PORT_SWITCH_ID_6161_A2	0x1613
>  #define PORT_SWITCH_ID_6165	0x1650
> -#define PORT_SWITCH_ID_6165_A1	0x1652
> -#define PORT_SWITCH_ID_6165_A2	0x1653
>  #define PORT_SWITCH_ID_6171	0x1710
>  #define PORT_SWITCH_ID_6172	0x1720
>  #define PORT_SWITCH_ID_6175	0x1750
> @@ -104,16 +95,10 @@
>  #define PORT_SWITCH_ID_6185	0x1a70
>  #define PORT_SWITCH_ID_6240	0x2400
>  #define PORT_SWITCH_ID_6320	0x1150
> -#define PORT_SWITCH_ID_6320_A1	0x1151
> -#define PORT_SWITCH_ID_6320_A2	0x1152
>  #define PORT_SWITCH_ID_6321	0x3100
> -#define PORT_SWITCH_ID_6321_A1	0x3101
> -#define PORT_SWITCH_ID_6321_A2	0x3102
>  #define PORT_SWITCH_ID_6350	0x3710
>  #define PORT_SWITCH_ID_6351	0x3750
>  #define PORT_SWITCH_ID_6352	0x3520
> -#define PORT_SWITCH_ID_6352_A0	0x3521
> -#define PORT_SWITCH_ID_6352_A1	0x3522
>  #define PORT_CONTROL		0x04
>  #define PORT_CONTROL_USE_CORE_TAG	BIT(15)
>  #define PORT_CONTROL_DROP_ON_LOCK	BIT(14)
> -- 
> 2.8.0
> 

^ permalink raw reply

* Re: [PATCH net-next v3 3/8] net: dsa: mv88e6xxx: read switch ID in probe
From: Andrew Lunn @ 2016-04-17 15:26 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <1460846505-20305-4-git-send-email-vivien.didelot@savoirfairelinux.com>

On Sat, Apr 16, 2016 at 06:41:40PM -0400, Vivien Didelot wrote:
> Read the switch ID only once, at probe time, to avoid multiple read
> accesses and MII bus checking.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks
	Andrew

> ---
>  drivers/net/dsa/mv88e6xxx.c | 54 +++++++++++++++++++++++++--------------------
>  1 file changed, 30 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index b63e985..af5ae70 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -2667,8 +2667,6 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
>  	ps->ds = ds;
>  	mutex_init(&ps->smi_mutex);
>  
> -	ps->id = REG_READ(REG_PORT(0), PORT_SWITCH_ID) & 0xfff0;
> -
>  	INIT_WORK(&ps->bridge_work, mv88e6xxx_bridge_work);
>  
>  	return 0;
> @@ -3068,21 +3066,14 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
>  }
>  #endif /* CONFIG_NET_DSA_HWMON */
>  
> -static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
> +static char *mv88e6xxx_lookup_name(unsigned int id,
>  				   const struct mv88e6xxx_switch_id *table,
>  				   unsigned int num)
>  {
> -	int i, ret;
> -
> -	if (!bus)
> -		return NULL;
> -
> -	ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
> -	if (ret < 0)
> -		return NULL;
> +	int i;
>  
>  	for (i = 0; i < num; ++i)
> -		if (table[i].id == (ret & 0xfff0))
> +		if (table[i].id == (id & 0xfff0))
>  			return table[i].name;
>  
>  	return NULL;
> @@ -3094,23 +3085,38 @@ char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  			  unsigned int num)
>  {
>  	struct mv88e6xxx_priv_state *ps;
> -	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
> +	struct mii_bus *bus;
> +	int id, prod_num, rev;
>  	char *name;
>  
> +	bus = dsa_host_dev_to_mii_bus(host_dev);
>  	if (!bus)
>  		return NULL;
>  
> -	name = mv88e6xxx_lookup_name(bus, sw_addr, table, num);
> -	if (name) {
> -		ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
> -		if (!ps)
> -			return NULL;
> -		*priv = ps;
> -		ps->bus = dsa_host_dev_to_mii_bus(host_dev);
> -		if (!ps->bus)
> -			return NULL;
> -		ps->sw_addr = sw_addr;
> -	}
> +	id = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
> +	if (id < 0)
> +		return NULL;
> +
> +	prod_num = (id & 0xfff0) >> 4;
> +	rev = id & 0x000f;
> +
> +	name = mv88e6xxx_lookup_name(id, table, num);
> +	if (!name)
> +		return NULL;
> +
> +	ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
> +	if (!ps)
> +		return NULL;
> +
> +	ps->bus = bus;
> +	ps->sw_addr = sw_addr;
> +	ps->id = id & 0xfff0;
> +
> +	*priv = ps;
> +
> +	dev_info(&ps->bus->dev, "switch 0x%x probed: %s, revision %u\n",
> +		 prod_num, name, rev);
> +
>  	return name;
>  }
>  
> -- 
> 2.8.0
> 

^ permalink raw reply

* Re: [PATCH net-next v3 4/8] net: dsa: mv88e6xxx: add switch info
From: Andrew Lunn @ 2016-04-17 15:35 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <1460846505-20305-5-git-send-email-vivien.didelot@savoirfairelinux.com>

> @@ -3100,16 +3100,19 @@ char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  	prod_num = (id & 0xfff0) >> 4;
>  	rev = id & 0x000f;
>  
> -	name = mv88e6xxx_lookup_name(id, table, num);
> -	if (!name)
> +	info = mv88e6xxx_lookup_info(prod_num, table, num);
> +	if (!info)
>  		return NULL;
>  
> +	name = (char *) info->name;
> +

Hi Vivien

Casting off the const is not so nice. How about adding in another
patch to change the API to return a const char *.

      Andrew

^ permalink raw reply

* Re: [PATCH net-next v3 4/8] net: dsa: mv88e6xxx: add switch info
From: Vivien Didelot @ 2016-04-17 16:37 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <20160417153541.GC907@lunn.ch>

Hi Andrew,

Andrew Lunn <andrew@lunn.ch> writes:

>> @@ -3100,16 +3100,19 @@ char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>>  	prod_num = (id & 0xfff0) >> 4;
>>  	rev = id & 0x000f;
>>  
>> -	name = mv88e6xxx_lookup_name(id, table, num);
>> -	if (!name)
>> +	info = mv88e6xxx_lookup_info(prod_num, table, num);
>> +	if (!info)
>>  		return NULL;
>>  
>> +	name = (char *) info->name;
>> +
>
> Hi Vivien
>
> Casting off the const is not so nice. How about adding in another
> patch to change the API to return a const char *.

OK.

Thanks,
Vivien

^ permalink raw reply

* bpf: use-after-free in array_map_alloc
From: Sasha Levin @ 2016-04-17 16:58 UTC (permalink / raw)
  To: ast; +Cc: netdev@vger.kernel.org, LKML

Hi all,

I've hit the following while fuzzing with syzkaller inside a KVM tools guest
running the latest -next kernel:

[ 2590.845375] ==================================================================

[ 2590.845445] BUG: KASAN: use-after-free in pcpu_extend_area_map+0x8a/0x130 at addr ffff88035452a3cc

[ 2590.845457] Read of size 4 by task syz-executor/31307

[ 2590.845464] =============================================================================

[ 2590.845476] BUG kmalloc-128 (Tainted: G        W      ): kasan: bad access detected

[ 2590.845479] -----------------------------------------------------------------------------

[ 2590.845479]

[ 2590.845485] Disabling lock debugging due to kernel taint

[ 2590.845496] INFO: Allocated in 0xbbbbbbbbbbbbbbbb age=18446609615465671625 cpu=0 pid=0

[ 2590.845504] 	pcpu_mem_zalloc+0x7e/0xc0

[ 2590.845521] 	___slab_alloc+0x7af/0x870

[ 2590.845528] 	__slab_alloc.isra.22+0xf4/0x130

[ 2590.845535] 	__kmalloc+0x1fe/0x340

[ 2590.845543] 	pcpu_mem_zalloc+0x7e/0xc0

[ 2590.845551] 	pcpu_create_chunk+0x79/0x600

[ 2590.845558] 	pcpu_alloc+0x5d4/0xe10

[ 2590.845567] 	__alloc_percpu_gfp+0x27/0x30

[ 2590.845582] 	array_map_alloc+0x595/0x710

[ 2590.845590] 	SyS_bpf+0x336/0xba0

[ 2590.845605] 	do_syscall_64+0x2a6/0x4a0

[ 2590.845639] 	return_from_SYSCALL_64+0x0/0x6a

[ 2590.845647] INFO: Freed in 0x10022ebb3 age=18446628393062689737 cpu=0 pid=0

[ 2590.845653] 	kvfree+0x45/0x50

[ 2590.845660] 	__slab_free+0x6a/0x2f0

[ 2590.845665] 	kfree+0x22c/0x270

[ 2590.845671] 	kvfree+0x45/0x50

[ 2590.845680] 	pcpu_balance_workfn+0x11a1/0x1280

[ 2590.845693] 	process_one_work+0x973/0x10b0

[ 2590.845700] 	worker_thread+0xcfd/0x1160

[ 2590.845708] 	kthread+0x2e7/0x300

[ 2590.845716] 	ret_from_fork+0x22/0x40

[ 2590.845724] INFO: Slab 0xffffea000d514a00 objects=35 used=33 fp=0xffff88035452b740 flags=0x2fffff80004080

[ 2590.845730] INFO: Object 0xffff88035452a3a0 @offset=9120 fp=0xbbbbbbbbbbbbbbbb

[ 2590.845730]

[ 2590.845743] Redzone ffff88035452a398: 00 00 00 00 00 00 00 00                          ........

[ 2590.845751] Object ffff88035452a3a0: bb bb bb bb bb bb bb bb 00 00 00 00 00 00 00 00  ................

[ 2590.845758] Object ffff88035452a3b0: b0 7b 17 3f 03 88 ff ff 00 00 08 00 00 00 08 00  .{.?............

[ 2590.845765] Object ffff88035452a3c0: 00 00 e0 f9 ff e8 ff ff 01 00 00 00 10 00 00 00  ................

[ 2590.845775] Object ffff88035452a3d0: 18 83 2c 3f 03 88 ff ff e0 ff ff ff 0f 00 00 00  ..,?............

[ 2590.845783] Object ffff88035452a3e0: e0 a3 52 54 03 88 ff ff e0 a3 52 54 03 88 ff ff  ..RT......RT....

[ 2590.845790] Object ffff88035452a3f0: 90 96 6b 9f ff ff ff ff e8 a7 13 3f 03 88 ff ff  ..k........?....

[ 2590.845797] Object ffff88035452a400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

[ 2590.845804] Object ffff88035452a410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

[ 2590.845811] Redzone ffff88035452a420: 00 00 00 00 00 00 00 00                          ........

[ 2590.845818] Padding ffff88035452a558: b5 eb 22 00 01 00 00 00                          ..".....

[ 2590.845833] CPU: 0 PID: 31307 Comm: syz-executor Tainted: G    B   W       4.6.0-rc3-next-20160412-sasha-00023-g0b02d6d-dirty #2998

[ 2590.845851]  0000000000000000 00000000a66f8039 ffff880354f8fa60 ffffffffa0fc9d01

[ 2590.845861]  ffffffff00000000 fffffbfff57ad2a0 0000000041b58ab3 ffffffffab65eee0

[ 2590.845870]  ffffffffa0fc9b88 00000000a66f8039 ffff88035e9d4000 ffffffffab67cede

[ 2590.845872] Call Trace:

[ 2590.845903] dump_stack (lib/dump_stack.c:53)
[ 2590.845939] print_trailer (mm/slub.c:668)
[ 2590.845948] object_err (mm/slub.c:675)
[ 2590.845958] kasan_report_error (mm/kasan/report.c:180 mm/kasan/report.c:276)
[ 2590.846007] __asan_report_load4_noabort (mm/kasan/report.c:318)
[ 2590.846028] pcpu_extend_area_map (mm/percpu.c:445)
[ 2590.846038] pcpu_alloc (mm/percpu.c:940)
[ 2590.846128] __alloc_percpu_gfp (mm/percpu.c:1068)
[ 2590.846140] array_map_alloc (kernel/bpf/arraymap.c:36 kernel/bpf/arraymap.c:99)
[ 2590.846150] SyS_bpf (kernel/bpf/syscall.c:35 kernel/bpf/syscall.c:183 kernel/bpf/syscall.c:830 kernel/bpf/syscall.c:787)
[ 2590.846203] do_syscall_64 (arch/x86/entry/common.c:350)
[ 2590.846214] entry_SYSCALL64_slow_path (arch/x86/entry/entry_64.S:251)
[ 2590.846217] Memory state around the buggy address:

[ 2590.846224]  ffff88035452a280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

[ 2590.846230]  ffff88035452a300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

[ 2590.846237] >ffff88035452a380: fc fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb

[ 2590.846240]                                               ^

[ 2590.846247]  ffff88035452a400: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc

[ 2590.846253]  ffff88035452a480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

[ 2590.846256] ==================================================================

^ permalink raw reply

* [PATCH net-next v4 0/9] net: dsa: mv88e6xxx: factorize switch info
From: Vivien Didelot @ 2016-04-17 17:23 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot

This patchset factorizes the mv88e6xxx code by sharing a new extendable
info structure to store static data such as switch family, product
number, number of ports, number of databases and the name.

The next step is to add a "flags" bitmap member to the info structure in
order to simplify the shared code with a feature-based logic instead of
checking their family/ID.

This is a step forward having a single mv88e6xxx driver supporting many
similar devices, like any usual Linux driver.

Changes v3 -> v4:
  - constify probed name in DSA
  - rebase patchset above conflicting commit 48ace4e

Changes v2 -> v3:
  - update commit messages and add Andrew's tags
  - keep the info lookup code in a separated function
  - split the single switch ID reading in probe in a new commit

Changes v1 -> v2:
  - define PORT_SWITCH_ID_PROD_NUM_* values
  - use plain struct mv88e6xxx_info
  - remove non used yet ps->rev

Vivien Didelot (9):
  net: dsa: constify probed name
  net: dsa: mv88e6xxx: drop double ds assignment
  net: dsa: mv88e6xxx: drop revision probing
  net: dsa: mv88e6xxx: read switch ID in probe
  net: dsa: mv88e6xxx: add switch info
  net: dsa: mv88e6xxx: add family to info
  net: dsa: mv88e6xxx: add number of ports to info
  net: dsa: mv88e6xxx: add number of db to info
  net: dsa: mv88e6xxx: remove switch ID from ps

 drivers/net/dsa/bcm_sf2.c   |   6 +-
 drivers/net/dsa/mv88e6060.c |  10 +--
 drivers/net/dsa/mv88e6123.c |  51 +++++------
 drivers/net/dsa/mv88e6131.c |  59 ++++++------
 drivers/net/dsa/mv88e6171.c |  42 ++++++---
 drivers/net/dsa/mv88e6352.c |  61 ++++++++-----
 drivers/net/dsa/mv88e6xxx.c | 215 ++++++++++++++------------------------------
 drivers/net/dsa/mv88e6xxx.h |  97 +++++++++-----------
 include/net/dsa.h           |   5 +-
 net/dsa/dsa.c               |   6 +-
 10 files changed, 247 insertions(+), 305 deletions(-)

-- 
2.8.0

^ permalink raw reply

* [PATCH net-next v4 1/9] net: dsa: constify probed name
From: Vivien Didelot @ 2016-04-17 17:23 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Change the dsa_switch_driver.probe function to return a const char *.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/bcm_sf2.c   |  6 +++---
 drivers/net/dsa/mv88e6060.c | 10 +++++-----
 drivers/net/dsa/mv88e6123.c |  6 +++---
 drivers/net/dsa/mv88e6131.c |  6 +++---
 drivers/net/dsa/mv88e6171.c |  6 +++---
 drivers/net/dsa/mv88e6352.c |  6 +++---
 drivers/net/dsa/mv88e6xxx.c | 17 +++++++++--------
 drivers/net/dsa/mv88e6xxx.h |  8 ++++----
 include/net/dsa.h           |  5 +++--
 net/dsa/dsa.c               |  6 +++---
 10 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 7a5f0ef..448deb5 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -135,9 +135,9 @@ static int bcm_sf2_sw_get_sset_count(struct dsa_switch *ds)
 	return BCM_SF2_STATS_SIZE;
 }
 
-static char *bcm_sf2_sw_drv_probe(struct device *dsa_dev,
-				  struct device *host_dev,
-				  int sw_addr, void **_priv)
+static const char *bcm_sf2_sw_drv_probe(struct device *dsa_dev,
+					struct device *host_dev, int sw_addr,
+					void **_priv)
 {
 	struct bcm_sf2_priv *priv;
 
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 92cebab..e36b408 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -51,7 +51,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
 			return __ret;				\
 	})
 
-static char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
+static const char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
 {
 	int ret;
 
@@ -69,13 +69,13 @@ static char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
 	return NULL;
 }
 
-static char *mv88e6060_drv_probe(struct device *dsa_dev,
-				 struct device *host_dev,
-				 int sw_addr, void **_priv)
+static const char *mv88e6060_drv_probe(struct device *dsa_dev,
+				       struct device *host_dev, int sw_addr,
+				       void **_priv)
 {
 	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
 	struct mv88e6060_priv *priv;
-	char *name;
+	const char *name;
 
 	name = mv88e6060_get_name(bus, sw_addr);
 	if (name) {
diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 140e44e..9701c0f 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -29,9 +29,9 @@ static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
 	{ PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" },
 };
 
-static char *mv88e6123_drv_probe(struct device *dsa_dev,
-				 struct device *host_dev,
-				 int sw_addr, void **priv)
+static const char *mv88e6123_drv_probe(struct device *dsa_dev,
+				       struct device *host_dev, int sw_addr,
+				       void **priv)
 {
 	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
 				   mv88e6123_table,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 34d297b..fa3a354 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -25,9 +25,9 @@ static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
 	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
 };
 
-static char *mv88e6131_drv_probe(struct device *dsa_dev,
-				 struct device *host_dev,
-				 int sw_addr, void **priv)
+static const char *mv88e6131_drv_probe(struct device *dsa_dev,
+				       struct device *host_dev, int sw_addr,
+				       void **priv)
 {
 	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
 				   mv88e6131_table,
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index b7af2b78..8d86c9e 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -24,9 +24,9 @@ static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
 	{ PORT_SWITCH_ID_6351, "Marvell 88E6351" },
 };
 
-static char *mv88e6171_drv_probe(struct device *dsa_dev,
-				 struct device *host_dev,
-				 int sw_addr, void **priv)
+static const char *mv88e6171_drv_probe(struct device *dsa_dev,
+				       struct device *host_dev, int sw_addr,
+				       void **priv)
 {
 	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
 				   mv88e6171_table,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index e8cb03f..c7fa69c 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -37,9 +37,9 @@ static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
 	{ PORT_SWITCH_ID_6352_A1, "Marvell 88E6352 (A1)" },
 };
 
-static char *mv88e6352_drv_probe(struct device *dsa_dev,
-				 struct device *host_dev,
-				 int sw_addr, void **priv)
+static const char *mv88e6352_drv_probe(struct device *dsa_dev,
+				       struct device *host_dev, int sw_addr,
+				       void **priv)
 {
 	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
 				   mv88e6352_table,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index b018f20..25d7fec 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3173,9 +3173,10 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
 }
 #endif /* CONFIG_NET_DSA_HWMON */
 
-static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
-				   const struct mv88e6xxx_switch_id *table,
-				   unsigned int num)
+static const char *
+mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
+		      const struct mv88e6xxx_switch_id *table,
+		      unsigned int num)
 {
 	int i, ret;
 
@@ -3205,14 +3206,14 @@ static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
 	return NULL;
 }
 
-char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
-			  int sw_addr, void **priv,
-			  const struct mv88e6xxx_switch_id *table,
-			  unsigned int num)
+const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
+				int sw_addr, void **priv,
+				const struct mv88e6xxx_switch_id *table,
+				unsigned int num)
 {
 	struct mv88e6xxx_priv_state *ps;
 	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
-	char *name;
+	const char *name;
 
 	if (!bus)
 		return NULL;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 0debb9f..5eb6013 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -462,10 +462,10 @@ struct mv88e6xxx_hw_stat {
 };
 
 int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
-char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
-			  int sw_addr, void **priv,
-			  const struct mv88e6xxx_switch_id *table,
-			  unsigned int num);
+const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
+				int sw_addr, void **priv,
+				const struct mv88e6xxx_switch_id *table,
+				unsigned int num);
 
 int mv88e6xxx_setup_ports(struct dsa_switch *ds);
 int mv88e6xxx_setup_common(struct dsa_switch *ds);
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 689ebd3..c4bc42b 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -217,8 +217,9 @@ struct dsa_switch_driver {
 	/*
 	 * Probing and setup.
 	 */
-	char	*(*probe)(struct device *dsa_dev, struct device *host_dev,
-			  int sw_addr, void **priv);
+	const char	*(*probe)(struct device *dsa_dev,
+				  struct device *host_dev, int sw_addr,
+				  void **priv);
 	int	(*setup)(struct dsa_switch *ds);
 	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 60ea9848..efa612f 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -52,11 +52,11 @@ EXPORT_SYMBOL_GPL(unregister_switch_driver);
 
 static struct dsa_switch_driver *
 dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
-		 char **_name, void **priv)
+		 const char **_name, void **priv)
 {
 	struct dsa_switch_driver *ret;
 	struct list_head *list;
-	char *name;
+	const char *name;
 
 	ret = NULL;
 	name = NULL;
@@ -383,7 +383,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
 	struct dsa_switch_driver *drv;
 	struct dsa_switch *ds;
 	int ret;
-	char *name;
+	const char *name;
 	void *priv;
 
 	/*
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 2/9] net: dsa: mv88e6xxx: drop double ds assignment
From: Vivien Didelot @ 2016-04-17 17:23 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Every driver assigns ps->ds even though it gets assigned in the shared
mv88e6xxx_setup_common function. Kill redundancy.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6123.c | 2 --
 drivers/net/dsa/mv88e6131.c | 2 --
 drivers/net/dsa/mv88e6171.c | 2 --
 drivers/net/dsa/mv88e6352.c | 2 --
 4 files changed, 8 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 9701c0f..85537eb 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -79,8 +79,6 @@ static int mv88e6123_setup(struct dsa_switch *ds)
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
-	ps->ds = ds;
-
 	ret = mv88e6xxx_setup_common(ds);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index fa3a354..4117c9b 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -101,8 +101,6 @@ static int mv88e6131_setup(struct dsa_switch *ds)
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
-	ps->ds = ds;
-
 	ret = mv88e6xxx_setup_common(ds);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 8d86c9e..ae32875 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -76,8 +76,6 @@ static int mv88e6171_setup(struct dsa_switch *ds)
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
-	ps->ds = ds;
-
 	ret = mv88e6xxx_setup_common(ds);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index c7fa69c..10c36ab 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -87,8 +87,6 @@ static int mv88e6352_setup(struct dsa_switch *ds)
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
-	ps->ds = ds;
-
 	ret = mv88e6xxx_setup_common(ds);
 	if (ret < 0)
 		return ret;
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 5/9] net: dsa: mv88e6xxx: add switch info
From: Vivien Didelot @ 2016-04-17 17:23 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Add a new switch info structure which is meant to store switch models
static information, such as product number, name, number of ports,
number of databases, etc.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6123.c | 15 +++++++++++----
 drivers/net/dsa/mv88e6131.c | 19 ++++++++++++++-----
 drivers/net/dsa/mv88e6171.c | 19 ++++++++++++++-----
 drivers/net/dsa/mv88e6352.c | 27 ++++++++++++++++++++-------
 drivers/net/dsa/mv88e6xxx.c | 18 +++++++++++-------
 drivers/net/dsa/mv88e6xxx.h | 27 +++++++++++++++++++++++----
 6 files changed, 93 insertions(+), 32 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index d6921ba..62dffcf 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -17,10 +17,17 @@
 #include <net/dsa.h>
 #include "mv88e6xxx.h"
 
-static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
-	{ PORT_SWITCH_ID_6123, "Marvell 88E6123" },
-	{ PORT_SWITCH_ID_6161, "Marvell 88E6161" },
-	{ PORT_SWITCH_ID_6165, "Marvell 88E6165" },
+static const struct mv88e6xxx_info mv88e6123_table[] = {
+	{
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
+		.name = "Marvell 88E6123",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
+		.name = "Marvell 88E6161",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
+		.name = "Marvell 88E6165",
+	}
 };
 
 static const char *mv88e6123_drv_probe(struct device *dsa_dev,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 8dc1365..0056715 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -17,11 +17,20 @@
 #include <net/dsa.h>
 #include "mv88e6xxx.h"
 
-static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
-	{ PORT_SWITCH_ID_6085, "Marvell 88E6085" },
-	{ PORT_SWITCH_ID_6095, "Marvell 88E6095/88E6095F" },
-	{ PORT_SWITCH_ID_6131, "Marvell 88E6131" },
-	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
+static const struct mv88e6xxx_info mv88e6131_table[] = {
+	{
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
+		.name = "Marvell 88E6095/88E6095F",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
+		.name = "Marvell 88E6085",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
+		.name = "Marvell 88E6131",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
+		.name = "Marvell 88E6185",
+	}
 };
 
 static const char *mv88e6131_drv_probe(struct device *dsa_dev,
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index ae32875..ea14ab2 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -17,11 +17,20 @@
 #include <net/dsa.h>
 #include "mv88e6xxx.h"
 
-static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
-	{ PORT_SWITCH_ID_6171, "Marvell 88E6171" },
-	{ PORT_SWITCH_ID_6175, "Marvell 88E6175" },
-	{ PORT_SWITCH_ID_6350, "Marvell 88E6350" },
-	{ PORT_SWITCH_ID_6351, "Marvell 88E6351" },
+static const struct mv88e6xxx_info mv88e6171_table[] = {
+	{
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
+		.name = "Marvell 88E6171",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
+		.name = "Marvell 88E6175",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
+		.name = "Marvell 88E6350",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
+		.name = "Marvell 88E6351",
+	}
 };
 
 static const char *mv88e6171_drv_probe(struct device *dsa_dev,
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 34f92b1..2f72606 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -22,13 +22,26 @@
 #include <net/dsa.h>
 #include "mv88e6xxx.h"
 
-static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
-	{ PORT_SWITCH_ID_6172, "Marvell 88E6172" },
-	{ PORT_SWITCH_ID_6176, "Marvell 88E6176" },
-	{ PORT_SWITCH_ID_6240, "Marvell 88E6240" },
-	{ PORT_SWITCH_ID_6320, "Marvell 88E6320" },
-	{ PORT_SWITCH_ID_6321, "Marvell 88E6321" },
-	{ PORT_SWITCH_ID_6352, "Marvell 88E6352" },
+static const struct mv88e6xxx_info mv88e6352_table[] = {
+	{
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
+		.name = "Marvell 88E6320",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
+		.name = "Marvell 88E6321",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
+		.name = "Marvell 88E6172",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
+		.name = "Marvell 88E6176",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
+		.name = "Marvell 88E6240",
+	}, {
+		.prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
+		.name = "Marvell 88E6352",
+	}
 };
 
 static const char *mv88e6352_drv_probe(struct device *dsa_dev,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 49f085a..5fb21e0 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3169,24 +3169,25 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
 }
 #endif /* CONFIG_NET_DSA_HWMON */
 
-static const char *
-mv88e6xxx_lookup_name(unsigned int id, const struct mv88e6xxx_switch_id *table,
+static const struct mv88e6xxx_info *
+mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table,
 		      unsigned int num)
 {
 	int i;
 
 	for (i = 0; i < num; ++i)
-		if (table[i].id == (id & 0xfff0))
-			return table[i].name;
+		if (table[i].prod_num == prod_num)
+			return &table[i];
 
 	return NULL;
 }
 
 const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
 				int sw_addr, void **priv,
-				const struct mv88e6xxx_switch_id *table,
+				const struct mv88e6xxx_info *table,
 				unsigned int num)
 {
+	const struct mv88e6xxx_info *info;
 	struct mv88e6xxx_priv_state *ps;
 	struct mii_bus *bus;
 	const char *name;
@@ -3203,16 +3204,19 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
 	prod_num = (id & 0xfff0) >> 4;
 	rev = id & 0x000f;
 
-	name = mv88e6xxx_lookup_name(id, table, num);
-	if (!name)
+	info = mv88e6xxx_lookup_info(prod_num, table, num);
+	if (!info)
 		return NULL;
 
+	name = info->name;
+
 	ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
 	if (!ps)
 		return NULL;
 
 	ps->bus = bus;
 	ps->sw_addr = sw_addr;
+	ps->info = info;
 	ps->id = id & 0xfff0;
 
 	*priv = ps;
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 6513450..b87f574 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -68,6 +68,23 @@
 #define PORT_PCS_CTRL_UNFORCED		0x03
 #define PORT_PAUSE_CTRL		0x02
 #define PORT_SWITCH_ID		0x03
+#define PORT_SWITCH_ID_PROD_NUM_6085	0x04a
+#define PORT_SWITCH_ID_PROD_NUM_6095	0x095
+#define PORT_SWITCH_ID_PROD_NUM_6131	0x106
+#define PORT_SWITCH_ID_PROD_NUM_6320	0x115
+#define PORT_SWITCH_ID_PROD_NUM_6123	0x121
+#define PORT_SWITCH_ID_PROD_NUM_6161	0x161
+#define PORT_SWITCH_ID_PROD_NUM_6165	0x165
+#define PORT_SWITCH_ID_PROD_NUM_6171	0x171
+#define PORT_SWITCH_ID_PROD_NUM_6172	0x172
+#define PORT_SWITCH_ID_PROD_NUM_6175	0x175
+#define PORT_SWITCH_ID_PROD_NUM_6176	0x176
+#define PORT_SWITCH_ID_PROD_NUM_6185	0x1a7
+#define PORT_SWITCH_ID_PROD_NUM_6240	0x240
+#define PORT_SWITCH_ID_PROD_NUM_6321	0x310
+#define PORT_SWITCH_ID_PROD_NUM_6352	0x352
+#define PORT_SWITCH_ID_PROD_NUM_6350	0x371
+#define PORT_SWITCH_ID_PROD_NUM_6351	0x375
 #define PORT_SWITCH_ID_6031	0x0310
 #define PORT_SWITCH_ID_6035	0x0350
 #define PORT_SWITCH_ID_6046	0x0480
@@ -352,9 +369,9 @@
 
 #define MV88E6XXX_N_FID		4096
 
-struct mv88e6xxx_switch_id {
-	u16 id;
-	char *name;
+struct mv88e6xxx_info {
+	u16 prod_num;
+	const char *name;
 };
 
 struct mv88e6xxx_atu_entry {
@@ -382,6 +399,8 @@ struct mv88e6xxx_priv_port {
 };
 
 struct mv88e6xxx_priv_state {
+	const struct mv88e6xxx_info *info;
+
 	/* The dsa_switch this private structure is related to */
 	struct dsa_switch *ds;
 
@@ -449,7 +468,7 @@ struct mv88e6xxx_hw_stat {
 int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
 const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
 				int sw_addr, void **priv,
-				const struct mv88e6xxx_switch_id *table,
+				const struct mv88e6xxx_info *table,
 				unsigned int num);
 
 int mv88e6xxx_setup_ports(struct dsa_switch *ds);
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 7/9] net: dsa: mv88e6xxx: add number of ports to info
From: Vivien Didelot @ 2016-04-17 17:24 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Drop the ps->num_ports variable in favor of a new member of the info
structure. This removes the need to assign it at setup time.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6123.c | 16 +++-------------
 drivers/net/dsa/mv88e6131.c | 22 +++++-----------------
 drivers/net/dsa/mv88e6171.c |  7 ++++---
 drivers/net/dsa/mv88e6352.c |  8 ++++++--
 drivers/net/dsa/mv88e6xxx.c | 38 +++++++++++++++++++-------------------
 drivers/net/dsa/mv88e6xxx.h |  3 +--
 6 files changed, 38 insertions(+), 56 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 776e6ef..0bf43bb 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -22,14 +22,17 @@ static const struct mv88e6xxx_info mv88e6123_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
 		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6123",
+		.num_ports = 3,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
 		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6161",
+		.num_ports = 6,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
 		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6165",
+		.num_ports = 6,
 	}
 };
 
@@ -80,25 +83,12 @@ static int mv88e6123_setup_global(struct dsa_switch *ds)
 
 static int mv88e6123_setup(struct dsa_switch *ds)
 {
-	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
 	ret = mv88e6xxx_setup_common(ds);
 	if (ret < 0)
 		return ret;
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6123:
-		ps->num_ports = 3;
-		break;
-	case PORT_SWITCH_ID_6161:
-	case PORT_SWITCH_ID_6165:
-		ps->num_ports = 6;
-		break;
-	default:
-		return -ENODEV;
-	}
-
 	ret = mv88e6xxx_switch_reset(ds, false);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 1986651..c01bbb1 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -22,18 +22,22 @@ static const struct mv88e6xxx_info mv88e6131_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
 		.family = MV88E6XXX_FAMILY_6095,
 		.name = "Marvell 88E6095/88E6095F",
+		.num_ports = 11,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
 		.family = MV88E6XXX_FAMILY_6097,
 		.name = "Marvell 88E6085",
+		.num_ports = 10,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
 		.family = MV88E6XXX_FAMILY_6185,
 		.name = "Marvell 88E6131",
+		.num_ports = 8,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
 		.family = MV88E6XXX_FAMILY_6185,
 		.name = "Marvell 88E6185",
+		.num_ports = 10,
 	}
 };
 
@@ -110,7 +114,6 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
 
 static int mv88e6131_setup(struct dsa_switch *ds)
 {
-	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
 	ret = mv88e6xxx_setup_common(ds);
@@ -119,21 +122,6 @@ static int mv88e6131_setup(struct dsa_switch *ds)
 
 	mv88e6xxx_ppu_state_init(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6085:
-	case PORT_SWITCH_ID_6185:
-		ps->num_ports = 10;
-		break;
-	case PORT_SWITCH_ID_6095:
-		ps->num_ports = 11;
-		break;
-	case PORT_SWITCH_ID_6131:
-		ps->num_ports = 8;
-		break;
-	default:
-		return -ENODEV;
-	}
-
 	ret = mv88e6xxx_switch_reset(ds, false);
 	if (ret < 0)
 		return ret;
@@ -149,7 +137,7 @@ static int mv88e6131_port_to_phy_addr(struct dsa_switch *ds, int port)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	if (port >= 0 && port < ps->num_ports)
+	if (port >= 0 && port < ps->info->num_ports)
 		return port;
 
 	return -EINVAL;
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 9a3b1e1..172824f 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -22,18 +22,22 @@ static const struct mv88e6xxx_info mv88e6171_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6171",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6175",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6350",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6351",
+		.num_ports = 7,
 	}
 };
 
@@ -86,15 +90,12 @@ static int mv88e6171_setup_global(struct dsa_switch *ds)
 
 static int mv88e6171_setup(struct dsa_switch *ds)
 {
-	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	int ret;
 
 	ret = mv88e6xxx_setup_common(ds);
 	if (ret < 0)
 		return ret;
 
-	ps->num_ports = 7;
-
 	ret = mv88e6xxx_switch_reset(ds, true);
 	if (ret < 0)
 		return ret;
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index bae62eb..12b9a7b 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -27,26 +27,32 @@ static const struct mv88e6xxx_info mv88e6352_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
 		.family = MV88E6XXX_FAMILY_6320,
 		.name = "Marvell 88E6320",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
 		.family = MV88E6XXX_FAMILY_6320,
 		.name = "Marvell 88E6321",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6172",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6176",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6240",
+		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6352",
+		.num_ports = 7,
 	}
 };
 
@@ -104,8 +110,6 @@ static int mv88e6352_setup(struct dsa_switch *ds)
 	if (ret < 0)
 		return ret;
 
-	ps->num_ports = 7;
-
 	mutex_init(&ps->eeprom_mutex);
 
 	ret = mv88e6xxx_switch_reset(ds, true);
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 8f8a1cf..c952d91 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -551,7 +551,7 @@ void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
 		reg |= PORT_PCS_CTRL_DUPLEX_FULL;
 
 	if ((mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds)) &&
-	    (port >= ps->num_ports - 2)) {
+	    (port >= ps->info->num_ports - 2)) {
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
 			reg |= PORT_PCS_CTRL_RGMII_DELAY_RXCLK;
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
@@ -1132,7 +1132,7 @@ static int _mv88e6xxx_port_based_vlan_map(struct dsa_switch *ds, int port)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 	struct net_device *bridge = ps->ports[port].bridge_dev;
-	const u16 mask = (1 << ps->num_ports) - 1;
+	const u16 mask = (1 << ps->info->num_ports) - 1;
 	u16 output_ports = 0;
 	int reg;
 	int i;
@@ -1141,7 +1141,7 @@ static int _mv88e6xxx_port_based_vlan_map(struct dsa_switch *ds, int port)
 	if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) {
 		output_ports = mask;
 	} else {
-		for (i = 0; i < ps->num_ports; ++i) {
+		for (i = 0; i < ps->info->num_ports; ++i) {
 			/* allow sending frames to every group member */
 			if (bridge && ps->ports[i].bridge_dev == bridge)
 				output_ports |= BIT(i);
@@ -1282,7 +1282,7 @@ static int _mv88e6xxx_vtu_stu_data_read(struct dsa_switch *ds,
 		regs[i] = ret;
 	}
 
-	for (i = 0; i < ps->num_ports; ++i) {
+	for (i = 0; i < ps->info->num_ports; ++i) {
 		unsigned int shift = (i % 4) * 4 + nibble_offset;
 		u16 reg = regs[i / 4];
 
@@ -1301,7 +1301,7 @@ static int _mv88e6xxx_vtu_stu_data_write(struct dsa_switch *ds,
 	int i;
 	int ret;
 
-	for (i = 0; i < ps->num_ports; ++i) {
+	for (i = 0; i < ps->info->num_ports; ++i) {
 		unsigned int shift = (i % 4) * 4 + nibble_offset;
 		u8 data = entry->data[i];
 
@@ -1633,7 +1633,7 @@ static int _mv88e6xxx_fid_new(struct dsa_switch *ds, u16 *fid)
 	bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
 
 	/* Set every FID bit used by the (un)bridged ports */
-	for (i = 0; i < ps->num_ports; ++i) {
+	for (i = 0; i < ps->info->num_ports; ++i) {
 		err = _mv88e6xxx_port_fid_get(ds, i, fid);
 		if (err)
 			return err;
@@ -1683,7 +1683,7 @@ static int _mv88e6xxx_vtu_new(struct dsa_switch *ds, u16 vid,
 		return err;
 
 	/* exclude all ports except the CPU and DSA ports */
-	for (i = 0; i < ps->num_ports; ++i)
+	for (i = 0; i < ps->info->num_ports; ++i)
 		vlan.data[i] = dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i)
 			? GLOBAL_VTU_DATA_MEMBER_TAG_UNMODIFIED
 			: GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
@@ -1772,7 +1772,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 		if (vlan.vid > vid_end)
 			break;
 
-		for (i = 0; i < ps->num_ports; ++i) {
+		for (i = 0; i < ps->info->num_ports; ++i) {
 			if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
 				continue;
 
@@ -1921,7 +1921,7 @@ static int _mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
 
 	/* keep the VLAN unless all ports are excluded */
 	vlan.valid = false;
-	for (i = 0; i < ps->num_ports; ++i) {
+	for (i = 0; i < ps->info->num_ports; ++i) {
 		if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i))
 			continue;
 
@@ -2230,11 +2230,11 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
 	mutex_lock(&ps->smi_mutex);
 
 	/* Get or create the bridge FID and assign it to the port */
-	for (i = 0; i < ps->num_ports; ++i)
+	for (i = 0; i < ps->info->num_ports; ++i)
 		if (ps->ports[i].bridge_dev == bridge)
 			break;
 
-	if (i < ps->num_ports)
+	if (i < ps->info->num_ports)
 		err = _mv88e6xxx_port_fid_get(ds, i, &fid);
 	else
 		err = _mv88e6xxx_fid_new(ds, &fid);
@@ -2248,7 +2248,7 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
 	/* Assign the bridge and remap each port's VLANTable */
 	ps->ports[port].bridge_dev = bridge;
 
-	for (i = 0; i < ps->num_ports; ++i) {
+	for (i = 0; i < ps->info->num_ports; ++i) {
 		if (ps->ports[i].bridge_dev == bridge) {
 			err = _mv88e6xxx_port_based_vlan_map(ds, i);
 			if (err)
@@ -2279,7 +2279,7 @@ void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
 	/* Unassign the bridge and remap each port's VLANTable */
 	ps->ports[port].bridge_dev = NULL;
 
-	for (i = 0; i < ps->num_ports; ++i)
+	for (i = 0; i < ps->info->num_ports; ++i)
 		if (i == port || ps->ports[i].bridge_dev == bridge)
 			if (_mv88e6xxx_port_based_vlan_map(ds, i))
 				netdev_warn(ds->ports[i], "failed to remap\n");
@@ -2298,7 +2298,7 @@ static void mv88e6xxx_bridge_work(struct work_struct *work)
 
 	mutex_lock(&ps->smi_mutex);
 
-	for (port = 0; port < ps->num_ports; ++port)
+	for (port = 0; port < ps->info->num_ports; ++port)
 		if (test_and_clear_bit(port, ps->port_state_update_mask) &&
 		    _mv88e6xxx_port_state(ds, port, ps->ports[port].state))
 			netdev_warn(ds->ports[port], "failed to update state to %s\n",
@@ -2630,7 +2630,7 @@ int mv88e6xxx_setup_ports(struct dsa_switch *ds)
 	int ret;
 	int i;
 
-	for (i = 0; i < ps->num_ports; i++) {
+	for (i = 0; i < ps->info->num_ports; i++) {
 		ret = mv88e6xxx_setup_port(ds, i);
 		if (ret < 0)
 			return ret;
@@ -2737,7 +2737,7 @@ int mv88e6xxx_setup_global(struct dsa_switch *ds)
 		err = _mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_TRUNK_MASK,
 					   0x8000 |
 					   (i << GLOBAL2_TRUNK_MASK_NUM_SHIFT) |
-					   ((1 << ps->num_ports) - 1));
+					   ((1 << ps->info->num_ports) - 1));
 		if (err)
 			goto unlock;
 	}
@@ -2790,7 +2790,7 @@ int mv88e6xxx_setup_global(struct dsa_switch *ds)
 		 * ingress rate limit registers to their initial
 		 * state.
 		 */
-		for (i = 0; i < ps->num_ports; i++) {
+		for (i = 0; i < ps->info->num_ports; i++) {
 			err = _mv88e6xxx_reg_write(ds, REG_GLOBAL2,
 						   GLOBAL2_INGRESS_OP,
 						   0x9000 | (i << 8));
@@ -2835,7 +2835,7 @@ int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active)
 	mutex_lock(&ps->smi_mutex);
 
 	/* Set all ports to the disabled state. */
-	for (i = 0; i < ps->num_ports; i++) {
+	for (i = 0; i < ps->info->num_ports; i++) {
 		ret = _mv88e6xxx_reg_read(ds, REG_PORT(i), PORT_CONTROL);
 		if (ret < 0)
 			goto unlock;
@@ -2918,7 +2918,7 @@ static int mv88e6xxx_port_to_phy_addr(struct dsa_switch *ds, int port)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	if (port >= 0 && port < ps->num_ports)
+	if (port >= 0 && port < ps->info->num_ports)
 		return port;
 	return -EINVAL;
 }
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index b4eec9a..801486a 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -385,6 +385,7 @@ struct mv88e6xxx_info {
 	enum mv88e6xxx_family family;
 	u16 prod_num;
 	const char *name;
+	unsigned int num_ports;
 };
 
 struct mv88e6xxx_atu_entry {
@@ -456,8 +457,6 @@ struct mv88e6xxx_priv_state {
 	struct mutex eeprom_mutex;
 
 	int		id; /* switch product id */
-	int		num_ports;	/* number of switch ports */
-
 	struct mv88e6xxx_priv_port	ports[DSA_MAX_PORTS];
 
 	DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS);
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 8/9] net: dsa: mv88e6xxx: add number of db to info
From: Vivien Didelot @ 2016-04-17 17:24 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Add the number of databases to the info structure.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6123.c |  3 +++
 drivers/net/dsa/mv88e6131.c |  4 ++++
 drivers/net/dsa/mv88e6171.c |  4 ++++
 drivers/net/dsa/mv88e6352.c |  6 ++++++
 drivers/net/dsa/mv88e6xxx.c | 19 +------------------
 drivers/net/dsa/mv88e6xxx.h |  1 +
 6 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 0bf43bb..534ebc8 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -22,16 +22,19 @@ static const struct mv88e6xxx_info mv88e6123_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
 		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6123",
+		.num_databases = 4096,
 		.num_ports = 3,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
 		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6161",
+		.num_databases = 4096,
 		.num_ports = 6,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
 		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6165",
+		.num_databases = 4096,
 		.num_ports = 6,
 	}
 };
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index c01bbb1..c3eb9a8 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -22,21 +22,25 @@ static const struct mv88e6xxx_info mv88e6131_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
 		.family = MV88E6XXX_FAMILY_6095,
 		.name = "Marvell 88E6095/88E6095F",
+		.num_databases = 256,
 		.num_ports = 11,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
 		.family = MV88E6XXX_FAMILY_6097,
 		.name = "Marvell 88E6085",
+		.num_databases = 4096,
 		.num_ports = 10,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
 		.family = MV88E6XXX_FAMILY_6185,
 		.name = "Marvell 88E6131",
+		.num_databases = 256,
 		.num_ports = 8,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
 		.family = MV88E6XXX_FAMILY_6185,
 		.name = "Marvell 88E6185",
+		.num_databases = 256,
 		.num_ports = 10,
 	}
 };
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 172824f..841ffe1 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -22,21 +22,25 @@ static const struct mv88e6xxx_info mv88e6171_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6171",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6175",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6350",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
 		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6351",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}
 };
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 12b9a7b..4afc24d 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -27,31 +27,37 @@ static const struct mv88e6xxx_info mv88e6352_table[] = {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
 		.family = MV88E6XXX_FAMILY_6320,
 		.name = "Marvell 88E6320",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
 		.family = MV88E6XXX_FAMILY_6320,
 		.name = "Marvell 88E6321",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6172",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6176",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6240",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
 		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6352",
+		.num_databases = 4096,
 		.num_ports = 7,
 	}
 };
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index c952d91..67b1dd1 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -458,24 +458,7 @@ static unsigned int mv88e6xxx_num_databases(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	/* The following devices have 4-bit identifiers for 16 databases */
-	if (ps->id == PORT_SWITCH_ID_6061)
-		return 16;
-
-	/* The following devices have 6-bit identifiers for 64 databases */
-	if (ps->id == PORT_SWITCH_ID_6065)
-		return 64;
-
-	/* The following devices have 8-bit identifiers for 256 databases */
-	if (mv88e6xxx_6095_family(ds) || mv88e6xxx_6185_family(ds))
-		return 256;
-
-	/* The following devices have 12-bit identifiers for 4096 databases */
-	if (mv88e6xxx_6097_family(ds) || mv88e6xxx_6165_family(ds) ||
-	    mv88e6xxx_6351_family(ds) || mv88e6xxx_6352_family(ds))
-		return 4096;
-
-	return 0;
+	return ps->info->num_databases;
 }
 
 static bool mv88e6xxx_has_fid_reg(struct dsa_switch *ds)
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 801486a..8eeafff 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -385,6 +385,7 @@ struct mv88e6xxx_info {
 	enum mv88e6xxx_family family;
 	u16 prod_num;
 	const char *name;
+	unsigned int num_databases;
 	unsigned int num_ports;
 };
 
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 9/9] net: dsa: mv88e6xxx: remove switch ID from ps
From: Vivien Didelot @ 2016-04-17 17:24 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

ps->id is not needed anymore, so remove it as well as the related
defined values.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx.c |  1 -
 drivers/net/dsa/mv88e6xxx.h | 32 --------------------------------
 2 files changed, 33 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 67b1dd1..1dd525d 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3145,7 +3145,6 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
 	ps->bus = bus;
 	ps->sw_addr = sw_addr;
 	ps->info = info;
-	ps->id = id & 0xfff0;
 
 	*priv = ps;
 
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 8eeafff..0dbe2d1 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -85,37 +85,6 @@
 #define PORT_SWITCH_ID_PROD_NUM_6352	0x352
 #define PORT_SWITCH_ID_PROD_NUM_6350	0x371
 #define PORT_SWITCH_ID_PROD_NUM_6351	0x375
-#define PORT_SWITCH_ID_6031	0x0310
-#define PORT_SWITCH_ID_6035	0x0350
-#define PORT_SWITCH_ID_6046	0x0480
-#define PORT_SWITCH_ID_6061	0x0610
-#define PORT_SWITCH_ID_6065	0x0650
-#define PORT_SWITCH_ID_6085	0x04a0
-#define PORT_SWITCH_ID_6092	0x0970
-#define PORT_SWITCH_ID_6095	0x0950
-#define PORT_SWITCH_ID_6096	0x0980
-#define PORT_SWITCH_ID_6097	0x0990
-#define PORT_SWITCH_ID_6108	0x1070
-#define PORT_SWITCH_ID_6121	0x1040
-#define PORT_SWITCH_ID_6122	0x1050
-#define PORT_SWITCH_ID_6123	0x1210
-#define PORT_SWITCH_ID_6131	0x1060
-#define PORT_SWITCH_ID_6152	0x1a40
-#define PORT_SWITCH_ID_6155	0x1a50
-#define PORT_SWITCH_ID_6161	0x1610
-#define PORT_SWITCH_ID_6165	0x1650
-#define PORT_SWITCH_ID_6171	0x1710
-#define PORT_SWITCH_ID_6172	0x1720
-#define PORT_SWITCH_ID_6175	0x1750
-#define PORT_SWITCH_ID_6176	0x1760
-#define PORT_SWITCH_ID_6182	0x1a60
-#define PORT_SWITCH_ID_6185	0x1a70
-#define PORT_SWITCH_ID_6240	0x2400
-#define PORT_SWITCH_ID_6320	0x1150
-#define PORT_SWITCH_ID_6321	0x3100
-#define PORT_SWITCH_ID_6350	0x3710
-#define PORT_SWITCH_ID_6351	0x3750
-#define PORT_SWITCH_ID_6352	0x3520
 #define PORT_CONTROL		0x04
 #define PORT_CONTROL_USE_CORE_TAG	BIT(15)
 #define PORT_CONTROL_DROP_ON_LOCK	BIT(14)
@@ -457,7 +426,6 @@ struct mv88e6xxx_priv_state {
 	 */
 	struct mutex eeprom_mutex;
 
-	int		id; /* switch product id */
 	struct mv88e6xxx_priv_port	ports[DSA_MAX_PORTS];
 
 	DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS);
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 3/9] net: dsa: mv88e6xxx: drop revision probing
From: Vivien Didelot @ 2016-04-17 17:23 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

There is no point in having a special case for the revision when probing
a switch model. The code gets cluttered with unnecessary defines, and
leads to errors when code such as mv88e6131_setup compares
PORT_SWITCH_ID_6131_B2 to ps->id which masks the revision.

Drop every revision definition, and lookup only the product number.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6123.c |  6 ------
 drivers/net/dsa/mv88e6131.c |  2 --
 drivers/net/dsa/mv88e6352.c |  6 ------
 drivers/net/dsa/mv88e6xxx.c | 14 +-------------
 drivers/net/dsa/mv88e6xxx.h | 15 ---------------
 5 files changed, 1 insertion(+), 42 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 85537eb..d6921ba 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -19,14 +19,8 @@
 
 static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
 	{ PORT_SWITCH_ID_6123, "Marvell 88E6123" },
-	{ PORT_SWITCH_ID_6123_A1, "Marvell 88E6123 (A1)" },
-	{ PORT_SWITCH_ID_6123_A2, "Marvell 88E6123 (A2)" },
 	{ PORT_SWITCH_ID_6161, "Marvell 88E6161" },
-	{ PORT_SWITCH_ID_6161_A1, "Marvell 88E6161 (A1)" },
-	{ PORT_SWITCH_ID_6161_A2, "Marvell 88E6161 (A2)" },
 	{ PORT_SWITCH_ID_6165, "Marvell 88E6165" },
-	{ PORT_SWITCH_ID_6165_A1, "Marvell 88E6165 (A1)" },
-	{ PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" },
 };
 
 static const char *mv88e6123_drv_probe(struct device *dsa_dev,
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 4117c9b..8dc1365 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -21,7 +21,6 @@ static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
 	{ PORT_SWITCH_ID_6085, "Marvell 88E6085" },
 	{ PORT_SWITCH_ID_6095, "Marvell 88E6095/88E6095F" },
 	{ PORT_SWITCH_ID_6131, "Marvell 88E6131" },
-	{ PORT_SWITCH_ID_6131_B2, "Marvell 88E6131 (B2)" },
 	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
 };
 
@@ -116,7 +115,6 @@ static int mv88e6131_setup(struct dsa_switch *ds)
 		ps->num_ports = 11;
 		break;
 	case PORT_SWITCH_ID_6131:
-	case PORT_SWITCH_ID_6131_B2:
 		ps->num_ports = 8;
 		break;
 	default:
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 10c36ab..34f92b1 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -27,14 +27,8 @@ static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
 	{ PORT_SWITCH_ID_6176, "Marvell 88E6176" },
 	{ PORT_SWITCH_ID_6240, "Marvell 88E6240" },
 	{ PORT_SWITCH_ID_6320, "Marvell 88E6320" },
-	{ PORT_SWITCH_ID_6320_A1, "Marvell 88E6320 (A1)" },
-	{ PORT_SWITCH_ID_6320_A2, "Marvell 88e6320 (A2)" },
 	{ PORT_SWITCH_ID_6321, "Marvell 88E6321" },
-	{ PORT_SWITCH_ID_6321_A1, "Marvell 88E6321 (A1)" },
-	{ PORT_SWITCH_ID_6321_A2, "Marvell 88e6321 (A2)" },
 	{ PORT_SWITCH_ID_6352, "Marvell 88E6352" },
-	{ PORT_SWITCH_ID_6352_A0, "Marvell 88E6352 (A0)" },
-	{ PORT_SWITCH_ID_6352_A1, "Marvell 88E6352 (A1)" },
 };
 
 static const char *mv88e6352_drv_probe(struct device *dsa_dev,
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 25d7fec..469d8a3 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -3187,22 +3187,10 @@ mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
 	if (ret < 0)
 		return NULL;
 
-	/* Look up the exact switch ID */
 	for (i = 0; i < num; ++i)
-		if (table[i].id == ret)
+		if (table[i].id == (ret & 0xfff0))
 			return table[i].name;
 
-	/* Look up only the product number */
-	for (i = 0; i < num; ++i) {
-		if (table[i].id == (ret & PORT_SWITCH_ID_PROD_NUM_MASK)) {
-			dev_warn(&bus->dev,
-				 "unknown revision %d, using base switch 0x%x\n",
-				 ret & PORT_SWITCH_ID_REV_MASK,
-				 ret & PORT_SWITCH_ID_PROD_NUM_MASK);
-			return table[i].name;
-		}
-	}
-
 	return NULL;
 }
 
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 5eb6013..6513450 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -68,8 +68,6 @@
 #define PORT_PCS_CTRL_UNFORCED		0x03
 #define PORT_PAUSE_CTRL		0x02
 #define PORT_SWITCH_ID		0x03
-#define PORT_SWITCH_ID_PROD_NUM_MASK	0xfff0
-#define PORT_SWITCH_ID_REV_MASK		0x000f
 #define PORT_SWITCH_ID_6031	0x0310
 #define PORT_SWITCH_ID_6035	0x0350
 #define PORT_SWITCH_ID_6046	0x0480
@@ -84,18 +82,11 @@
 #define PORT_SWITCH_ID_6121	0x1040
 #define PORT_SWITCH_ID_6122	0x1050
 #define PORT_SWITCH_ID_6123	0x1210
-#define PORT_SWITCH_ID_6123_A1	0x1212
-#define PORT_SWITCH_ID_6123_A2	0x1213
 #define PORT_SWITCH_ID_6131	0x1060
-#define PORT_SWITCH_ID_6131_B2	0x1066
 #define PORT_SWITCH_ID_6152	0x1a40
 #define PORT_SWITCH_ID_6155	0x1a50
 #define PORT_SWITCH_ID_6161	0x1610
-#define PORT_SWITCH_ID_6161_A1	0x1612
-#define PORT_SWITCH_ID_6161_A2	0x1613
 #define PORT_SWITCH_ID_6165	0x1650
-#define PORT_SWITCH_ID_6165_A1	0x1652
-#define PORT_SWITCH_ID_6165_A2	0x1653
 #define PORT_SWITCH_ID_6171	0x1710
 #define PORT_SWITCH_ID_6172	0x1720
 #define PORT_SWITCH_ID_6175	0x1750
@@ -104,16 +95,10 @@
 #define PORT_SWITCH_ID_6185	0x1a70
 #define PORT_SWITCH_ID_6240	0x2400
 #define PORT_SWITCH_ID_6320	0x1150
-#define PORT_SWITCH_ID_6320_A1	0x1151
-#define PORT_SWITCH_ID_6320_A2	0x1152
 #define PORT_SWITCH_ID_6321	0x3100
-#define PORT_SWITCH_ID_6321_A1	0x3101
-#define PORT_SWITCH_ID_6321_A2	0x3102
 #define PORT_SWITCH_ID_6350	0x3710
 #define PORT_SWITCH_ID_6351	0x3750
 #define PORT_SWITCH_ID_6352	0x3520
-#define PORT_SWITCH_ID_6352_A0	0x3521
-#define PORT_SWITCH_ID_6352_A1	0x3522
 #define PORT_CONTROL		0x04
 #define PORT_CONTROL_USE_CORE_TAG	BIT(15)
 #define PORT_CONTROL_DROP_ON_LOCK	BIT(14)
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 4/9] net: dsa: mv88e6xxx: read switch ID in probe
From: Vivien Didelot @ 2016-04-17 17:23 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Read the switch ID only once, at probe time, to avoid multiple read
accesses and MII bus checking.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx.c | 57 ++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 469d8a3..49f085a 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -2700,10 +2700,6 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
 	ps->ds = ds;
 	mutex_init(&ps->smi_mutex);
 
-	ps->id = mv88e6xxx_reg_read(ds, REG_PORT(0), PORT_SWITCH_ID) & 0xfff0;
-	if (ps->id < 0)
-		return ps->id;
-
 	INIT_WORK(&ps->bridge_work, mv88e6xxx_bridge_work);
 
 	return 0;
@@ -3174,21 +3170,13 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
 #endif /* CONFIG_NET_DSA_HWMON */
 
 static const char *
-mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
-		      const struct mv88e6xxx_switch_id *table,
+mv88e6xxx_lookup_name(unsigned int id, const struct mv88e6xxx_switch_id *table,
 		      unsigned int num)
 {
-	int i, ret;
-
-	if (!bus)
-		return NULL;
-
-	ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
-	if (ret < 0)
-		return NULL;
+	int i;
 
 	for (i = 0; i < num; ++i)
-		if (table[i].id == (ret & 0xfff0))
+		if (table[i].id == (id & 0xfff0))
 			return table[i].name;
 
 	return NULL;
@@ -3200,23 +3188,38 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
 				unsigned int num)
 {
 	struct mv88e6xxx_priv_state *ps;
-	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
+	struct mii_bus *bus;
 	const char *name;
+	int id, prod_num, rev;
 
+	bus = dsa_host_dev_to_mii_bus(host_dev);
 	if (!bus)
 		return NULL;
 
-	name = mv88e6xxx_lookup_name(bus, sw_addr, table, num);
-	if (name) {
-		ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
-		if (!ps)
-			return NULL;
-		*priv = ps;
-		ps->bus = dsa_host_dev_to_mii_bus(host_dev);
-		if (!ps->bus)
-			return NULL;
-		ps->sw_addr = sw_addr;
-	}
+	id = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
+	if (id < 0)
+		return NULL;
+
+	prod_num = (id & 0xfff0) >> 4;
+	rev = id & 0x000f;
+
+	name = mv88e6xxx_lookup_name(id, table, num);
+	if (!name)
+		return NULL;
+
+	ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
+	if (!ps)
+		return NULL;
+
+	ps->bus = bus;
+	ps->sw_addr = sw_addr;
+	ps->id = id & 0xfff0;
+
+	*priv = ps;
+
+	dev_info(&ps->bus->dev, "switch 0x%x probed: %s, revision %u\n",
+		 prod_num, name, rev);
+
 	return name;
 }
 
-- 
2.8.0

^ permalink raw reply related

* [PATCH net-next v4 6/9] net: dsa: mv88e6xxx: add family to info
From: Vivien Didelot @ 2016-04-17 17:24 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <1460913843-7459-1-git-send-email-vivien.didelot@savoirfairelinux.com>

Add an mv88e6xxx_family enum to the info structure for better family
indentification.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6123.c |  3 ++
 drivers/net/dsa/mv88e6131.c |  4 +++
 drivers/net/dsa/mv88e6171.c |  4 +++
 drivers/net/dsa/mv88e6352.c |  6 ++++
 drivers/net/dsa/mv88e6xxx.c | 71 +++++----------------------------------------
 drivers/net/dsa/mv88e6xxx.h | 13 +++++++++
 6 files changed, 38 insertions(+), 63 deletions(-)

diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
index 62dffcf..776e6ef 100644
--- a/drivers/net/dsa/mv88e6123.c
+++ b/drivers/net/dsa/mv88e6123.c
@@ -20,12 +20,15 @@
 static const struct mv88e6xxx_info mv88e6123_table[] = {
 	{
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
+		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6123",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
+		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6161",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
+		.family = MV88E6XXX_FAMILY_6165,
 		.name = "Marvell 88E6165",
 	}
 };
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index 0056715..1986651 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -20,15 +20,19 @@
 static const struct mv88e6xxx_info mv88e6131_table[] = {
 	{
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
+		.family = MV88E6XXX_FAMILY_6095,
 		.name = "Marvell 88E6095/88E6095F",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
+		.family = MV88E6XXX_FAMILY_6097,
 		.name = "Marvell 88E6085",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
+		.family = MV88E6XXX_FAMILY_6185,
 		.name = "Marvell 88E6131",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
+		.family = MV88E6XXX_FAMILY_6185,
 		.name = "Marvell 88E6185",
 	}
 };
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index ea14ab2..9a3b1e1 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -20,15 +20,19 @@
 static const struct mv88e6xxx_info mv88e6171_table[] = {
 	{
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
+		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6171",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
+		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6175",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
+		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6350",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
+		.family = MV88E6XXX_FAMILY_6351,
 		.name = "Marvell 88E6351",
 	}
 };
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 2f72606..bae62eb 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -25,21 +25,27 @@
 static const struct mv88e6xxx_info mv88e6352_table[] = {
 	{
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
+		.family = MV88E6XXX_FAMILY_6320,
 		.name = "Marvell 88E6320",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
+		.family = MV88E6XXX_FAMILY_6320,
 		.name = "Marvell 88E6321",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
+		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6172",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
+		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6176",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
+		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6240",
 	}, {
 		.prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
+		.family = MV88E6XXX_FAMILY_6352,
 		.name = "Marvell 88E6352",
 	}
 };
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index 5fb21e0..8f8a1cf 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -402,111 +402,56 @@ static bool mv88e6xxx_6065_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6031:
-	case PORT_SWITCH_ID_6061:
-	case PORT_SWITCH_ID_6035:
-	case PORT_SWITCH_ID_6065:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6065;
 }
 
 static bool mv88e6xxx_6095_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6092:
-	case PORT_SWITCH_ID_6095:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6095;
 }
 
 static bool mv88e6xxx_6097_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6046:
-	case PORT_SWITCH_ID_6085:
-	case PORT_SWITCH_ID_6096:
-	case PORT_SWITCH_ID_6097:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6097;
 }
 
 static bool mv88e6xxx_6165_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6123:
-	case PORT_SWITCH_ID_6161:
-	case PORT_SWITCH_ID_6165:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6165;
 }
 
 static bool mv88e6xxx_6185_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6121:
-	case PORT_SWITCH_ID_6122:
-	case PORT_SWITCH_ID_6152:
-	case PORT_SWITCH_ID_6155:
-	case PORT_SWITCH_ID_6182:
-	case PORT_SWITCH_ID_6185:
-	case PORT_SWITCH_ID_6108:
-	case PORT_SWITCH_ID_6131:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6185;
 }
 
 static bool mv88e6xxx_6320_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6320:
-	case PORT_SWITCH_ID_6321:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6320;
 }
 
 static bool mv88e6xxx_6351_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6171:
-	case PORT_SWITCH_ID_6175:
-	case PORT_SWITCH_ID_6350:
-	case PORT_SWITCH_ID_6351:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6351;
 }
 
 static bool mv88e6xxx_6352_family(struct dsa_switch *ds)
 {
 	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
 
-	switch (ps->id) {
-	case PORT_SWITCH_ID_6172:
-	case PORT_SWITCH_ID_6176:
-	case PORT_SWITCH_ID_6240:
-	case PORT_SWITCH_ID_6352:
-		return true;
-	}
-	return false;
+	return ps->info->family == MV88E6XXX_FAMILY_6352;
 }
 
 static unsigned int mv88e6xxx_num_databases(struct dsa_switch *ds)
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index b87f574..b4eec9a 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -369,7 +369,20 @@
 
 #define MV88E6XXX_N_FID		4096
 
+enum mv88e6xxx_family {
+	MV88E6XXX_FAMILY_NONE,
+	MV88E6XXX_FAMILY_6065,	/* 6031 6035 6061 6065 */
+	MV88E6XXX_FAMILY_6095,	/* 6092 6095 */
+	MV88E6XXX_FAMILY_6097,	/* 6046 6085 6096 6097 */
+	MV88E6XXX_FAMILY_6165,	/* 6123 6161 6165 */
+	MV88E6XXX_FAMILY_6185,	/* 6108 6121 6122 6131 6152 6155 6182 6185 */
+	MV88E6XXX_FAMILY_6320,	/* 6320 6321 */
+	MV88E6XXX_FAMILY_6351,	/* 6171 6175 6350 6351 */
+	MV88E6XXX_FAMILY_6352,	/* 6172 6176 6240 6352 */
+};
+
 struct mv88e6xxx_info {
+	enum mv88e6xxx_family family;
 	u16 prod_num;
 	const char *name;
 };
-- 
2.8.0

^ permalink raw reply related

* Re: FlameGraph of mlx4 early drop with order-0 pages
From: Jesper Dangaard Brouer @ 2016-04-17 17:24 UTC (permalink / raw)
  To: Mel Gorman
  Cc: linux-mm, netdev@vger.kernel.org, Brenden Blanco, tom,
	alexei.starovoitov, ogerlitz, daniel, eric.dumazet, ecree,
	john.fastabend, tgraf, johannes, brouer
In-Reply-To: <20160417132357.GB11792@techsingularity.net>

On Sun, 17 Apr 2016 14:23:57 +0100
Mel Gorman <mgorman@techsingularity.net> wrote:

> > Signing off, heading for the plane soon... see you at MM-summit!  
> 
> Indeed and we'll slap some sort of plan together. If there is a slot free,
> we might spend 15-30 minutes on it. Failing that, we'll grab a table
> somewhere. We'll see how far we can get before considering a page-recycle
> layer that preserves cache coherent state.

We have a plenum slot tomorrow between 16:00-16:30, called "Generic
Page Pool Facility".

I'm at the Marriott now. I'm wearing my Red Hat/fedora, so I should be
easy to spot... ;-)

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer

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

* Re: bpf: use-after-free in array_map_alloc
From: Alexei Starovoitov @ 2016-04-17 17:29 UTC (permalink / raw)
  To: Sasha Levin; +Cc: ast, netdev@vger.kernel.org, LKML, Tejun Heo
In-Reply-To: <5713C0AD.3020102@oracle.com>

On Sun, Apr 17, 2016 at 12:58:21PM -0400, Sasha Levin wrote:
> Hi all,
> 
> I've hit the following while fuzzing with syzkaller inside a KVM tools guest
> running the latest -next kernel:

thanks for the report. Adding Tejun...
if I read the report correctly it's not about bpf, but rather points to
the issue inside percpu logic.
First __alloc_percpu_gfp() is called, then the memory is freed with
free_percpu() which triggers async pcpu_balance_work and then
pcpu_extend_area_map is hitting use-after-free.
I guess bpf percpu array map is stressing this logic the most.
Any simpler steps to reproduce ?

> [ 2590.845375] ==================================================================
> 
> [ 2590.845445] BUG: KASAN: use-after-free in pcpu_extend_area_map+0x8a/0x130 at addr ffff88035452a3cc
> 
> [ 2590.845457] Read of size 4 by task syz-executor/31307
> 
> [ 2590.845464] =============================================================================
> 
> [ 2590.845476] BUG kmalloc-128 (Tainted: G        W      ): kasan: bad access detected
> 
> [ 2590.845479] -----------------------------------------------------------------------------
> 
> [ 2590.845479]
> 
> [ 2590.845485] Disabling lock debugging due to kernel taint
> 
> [ 2590.845496] INFO: Allocated in 0xbbbbbbbbbbbbbbbb age=18446609615465671625 cpu=0 pid=0
> 
> [ 2590.845504] 	pcpu_mem_zalloc+0x7e/0xc0
> 
> [ 2590.845521] 	___slab_alloc+0x7af/0x870
> 
> [ 2590.845528] 	__slab_alloc.isra.22+0xf4/0x130
> 
> [ 2590.845535] 	__kmalloc+0x1fe/0x340
> 
> [ 2590.845543] 	pcpu_mem_zalloc+0x7e/0xc0
> 
> [ 2590.845551] 	pcpu_create_chunk+0x79/0x600
> 
> [ 2590.845558] 	pcpu_alloc+0x5d4/0xe10
> 
> [ 2590.845567] 	__alloc_percpu_gfp+0x27/0x30
> 
> [ 2590.845582] 	array_map_alloc+0x595/0x710
> 
> [ 2590.845590] 	SyS_bpf+0x336/0xba0
> 
> [ 2590.845605] 	do_syscall_64+0x2a6/0x4a0
> 
> [ 2590.845639] 	return_from_SYSCALL_64+0x0/0x6a
> 
> [ 2590.845647] INFO: Freed in 0x10022ebb3 age=18446628393062689737 cpu=0 pid=0
> 
> [ 2590.845653] 	kvfree+0x45/0x50
> 
> [ 2590.845660] 	__slab_free+0x6a/0x2f0
> 
> [ 2590.845665] 	kfree+0x22c/0x270
> 
> [ 2590.845671] 	kvfree+0x45/0x50
> 
> [ 2590.845680] 	pcpu_balance_workfn+0x11a1/0x1280
> 
> [ 2590.845693] 	process_one_work+0x973/0x10b0
> 
> [ 2590.845700] 	worker_thread+0xcfd/0x1160
> 
> [ 2590.845708] 	kthread+0x2e7/0x300
> 
> [ 2590.845716] 	ret_from_fork+0x22/0x40
> 
> [ 2590.845724] INFO: Slab 0xffffea000d514a00 objects=35 used=33 fp=0xffff88035452b740 flags=0x2fffff80004080
> 
> [ 2590.845730] INFO: Object 0xffff88035452a3a0 @offset=9120 fp=0xbbbbbbbbbbbbbbbb
> 
> [ 2590.845730]
> 
> [ 2590.845743] Redzone ffff88035452a398: 00 00 00 00 00 00 00 00                          ........
> 
> [ 2590.845751] Object ffff88035452a3a0: bb bb bb bb bb bb bb bb 00 00 00 00 00 00 00 00  ................
> 
> [ 2590.845758] Object ffff88035452a3b0: b0 7b 17 3f 03 88 ff ff 00 00 08 00 00 00 08 00  .{.?............
> 
> [ 2590.845765] Object ffff88035452a3c0: 00 00 e0 f9 ff e8 ff ff 01 00 00 00 10 00 00 00  ................
> 
> [ 2590.845775] Object ffff88035452a3d0: 18 83 2c 3f 03 88 ff ff e0 ff ff ff 0f 00 00 00  ..,?............
> 
> [ 2590.845783] Object ffff88035452a3e0: e0 a3 52 54 03 88 ff ff e0 a3 52 54 03 88 ff ff  ..RT......RT....
> 
> [ 2590.845790] Object ffff88035452a3f0: 90 96 6b 9f ff ff ff ff e8 a7 13 3f 03 88 ff ff  ..k........?....
> 
> [ 2590.845797] Object ffff88035452a400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> 
> [ 2590.845804] Object ffff88035452a410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> 
> [ 2590.845811] Redzone ffff88035452a420: 00 00 00 00 00 00 00 00                          ........
> 
> [ 2590.845818] Padding ffff88035452a558: b5 eb 22 00 01 00 00 00                          ..".....
> 
> [ 2590.845833] CPU: 0 PID: 31307 Comm: syz-executor Tainted: G    B   W       4.6.0-rc3-next-20160412-sasha-00023-g0b02d6d-dirty #2998
> 
> [ 2590.845851]  0000000000000000 00000000a66f8039 ffff880354f8fa60 ffffffffa0fc9d01
> 
> [ 2590.845861]  ffffffff00000000 fffffbfff57ad2a0 0000000041b58ab3 ffffffffab65eee0
> 
> [ 2590.845870]  ffffffffa0fc9b88 00000000a66f8039 ffff88035e9d4000 ffffffffab67cede
> 
> [ 2590.845872] Call Trace:
> 
> [ 2590.845903] dump_stack (lib/dump_stack.c:53)
> [ 2590.845939] print_trailer (mm/slub.c:668)
> [ 2590.845948] object_err (mm/slub.c:675)
> [ 2590.845958] kasan_report_error (mm/kasan/report.c:180 mm/kasan/report.c:276)
> [ 2590.846007] __asan_report_load4_noabort (mm/kasan/report.c:318)
> [ 2590.846028] pcpu_extend_area_map (mm/percpu.c:445)
> [ 2590.846038] pcpu_alloc (mm/percpu.c:940)
> [ 2590.846128] __alloc_percpu_gfp (mm/percpu.c:1068)
> [ 2590.846140] array_map_alloc (kernel/bpf/arraymap.c:36 kernel/bpf/arraymap.c:99)
> [ 2590.846150] SyS_bpf (kernel/bpf/syscall.c:35 kernel/bpf/syscall.c:183 kernel/bpf/syscall.c:830 kernel/bpf/syscall.c:787)
> [ 2590.846203] do_syscall_64 (arch/x86/entry/common.c:350)
> [ 2590.846214] entry_SYSCALL64_slow_path (arch/x86/entry/entry_64.S:251)
> [ 2590.846217] Memory state around the buggy address:
> 
> [ 2590.846224]  ffff88035452a280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> 
> [ 2590.846230]  ffff88035452a300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> 
> [ 2590.846237] >ffff88035452a380: fc fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb
> 
> [ 2590.846240]                                               ^
> 
> [ 2590.846247]  ffff88035452a400: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
> 
> [ 2590.846253]  ffff88035452a480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> 
> [ 2590.846256] ==================================================================
> 

^ permalink raw reply

* Re: FlameGraph of mlx4 early drop with order-0 pages
From: Mel Gorman @ 2016-04-17 17:52 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: linux-mm, netdev@vger.kernel.org, Brenden Blanco, tom,
	alexei.starovoitov, ogerlitz, daniel, eric.dumazet, ecree,
	john.fastabend, tgraf, johannes
In-Reply-To: <20160417192432.70c893fc@redhat.com>

On Sun, Apr 17, 2016 at 07:24:32PM +0200, Jesper Dangaard Brouer wrote:
> On Sun, 17 Apr 2016 14:23:57 +0100
> Mel Gorman <mgorman@techsingularity.net> wrote:
> 
> > > Signing off, heading for the plane soon... see you at MM-summit!  
> > 
> > Indeed and we'll slap some sort of plan together. If there is a slot free,
> > we might spend 15-30 minutes on it. Failing that, we'll grab a table
> > somewhere. We'll see how far we can get before considering a page-recycle
> > layer that preserves cache coherent state.
> 
> We have a plenum slot tomorrow between 16:00-16:30, called "Generic
> Page Pool Facility".
> 

Yeah. We can use part of that if you like to discuss page allocator
concerns. I didn't want to accidentally hijack a session if it was going
to focus on an API for storing cache coherent pages. My focus will still
be on improving the allocator itself and what would and would not be
acceptable there.

> I'm at the Marriott now. I'm wearing my Red Hat/fedora, so I should be
> easy to spot... ;-)
> 

I'll keep an eye out!

-- 
Mel Gorman
SUSE Labs

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

* Re: [PATCH net-next v4 1/9] net: dsa: constify probed name
From: Andrew Lunn @ 2016-04-17 17:53 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <1460913843-7459-2-git-send-email-vivien.didelot@savoirfairelinux.com>

On Sun, Apr 17, 2016 at 01:23:55PM -0400, Vivien Didelot wrote:
> Change the dsa_switch_driver.probe function to return a const char *.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks
	Andrew

> ---
>  drivers/net/dsa/bcm_sf2.c   |  6 +++---
>  drivers/net/dsa/mv88e6060.c | 10 +++++-----
>  drivers/net/dsa/mv88e6123.c |  6 +++---
>  drivers/net/dsa/mv88e6131.c |  6 +++---
>  drivers/net/dsa/mv88e6171.c |  6 +++---
>  drivers/net/dsa/mv88e6352.c |  6 +++---
>  drivers/net/dsa/mv88e6xxx.c | 17 +++++++++--------
>  drivers/net/dsa/mv88e6xxx.h |  8 ++++----
>  include/net/dsa.h           |  5 +++--
>  net/dsa/dsa.c               |  6 +++---
>  10 files changed, 39 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 7a5f0ef..448deb5 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -135,9 +135,9 @@ static int bcm_sf2_sw_get_sset_count(struct dsa_switch *ds)
>  	return BCM_SF2_STATS_SIZE;
>  }
>  
> -static char *bcm_sf2_sw_drv_probe(struct device *dsa_dev,
> -				  struct device *host_dev,
> -				  int sw_addr, void **_priv)
> +static const char *bcm_sf2_sw_drv_probe(struct device *dsa_dev,
> +					struct device *host_dev, int sw_addr,
> +					void **_priv)
>  {
>  	struct bcm_sf2_priv *priv;
>  
> diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
> index 92cebab..e36b408 100644
> --- a/drivers/net/dsa/mv88e6060.c
> +++ b/drivers/net/dsa/mv88e6060.c
> @@ -51,7 +51,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
>  			return __ret;				\
>  	})
>  
> -static char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
> +static const char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
>  {
>  	int ret;
>  
> @@ -69,13 +69,13 @@ static char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
>  	return NULL;
>  }
>  
> -static char *mv88e6060_drv_probe(struct device *dsa_dev,
> -				 struct device *host_dev,
> -				 int sw_addr, void **_priv)
> +static const char *mv88e6060_drv_probe(struct device *dsa_dev,
> +				       struct device *host_dev, int sw_addr,
> +				       void **_priv)
>  {
>  	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
>  	struct mv88e6060_priv *priv;
> -	char *name;
> +	const char *name;
>  
>  	name = mv88e6060_get_name(bus, sw_addr);
>  	if (name) {
> diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
> index 140e44e..9701c0f 100644
> --- a/drivers/net/dsa/mv88e6123.c
> +++ b/drivers/net/dsa/mv88e6123.c
> @@ -29,9 +29,9 @@ static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
>  	{ PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" },
>  };
>  
> -static char *mv88e6123_drv_probe(struct device *dsa_dev,
> -				 struct device *host_dev,
> -				 int sw_addr, void **priv)
> +static const char *mv88e6123_drv_probe(struct device *dsa_dev,
> +				       struct device *host_dev, int sw_addr,
> +				       void **priv)
>  {
>  	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
>  				   mv88e6123_table,
> diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
> index 34d297b..fa3a354 100644
> --- a/drivers/net/dsa/mv88e6131.c
> +++ b/drivers/net/dsa/mv88e6131.c
> @@ -25,9 +25,9 @@ static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
>  	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
>  };
>  
> -static char *mv88e6131_drv_probe(struct device *dsa_dev,
> -				 struct device *host_dev,
> -				 int sw_addr, void **priv)
> +static const char *mv88e6131_drv_probe(struct device *dsa_dev,
> +				       struct device *host_dev, int sw_addr,
> +				       void **priv)
>  {
>  	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
>  				   mv88e6131_table,
> diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
> index b7af2b78..8d86c9e 100644
> --- a/drivers/net/dsa/mv88e6171.c
> +++ b/drivers/net/dsa/mv88e6171.c
> @@ -24,9 +24,9 @@ static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
>  	{ PORT_SWITCH_ID_6351, "Marvell 88E6351" },
>  };
>  
> -static char *mv88e6171_drv_probe(struct device *dsa_dev,
> -				 struct device *host_dev,
> -				 int sw_addr, void **priv)
> +static const char *mv88e6171_drv_probe(struct device *dsa_dev,
> +				       struct device *host_dev, int sw_addr,
> +				       void **priv)
>  {
>  	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
>  				   mv88e6171_table,
> diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
> index e8cb03f..c7fa69c 100644
> --- a/drivers/net/dsa/mv88e6352.c
> +++ b/drivers/net/dsa/mv88e6352.c
> @@ -37,9 +37,9 @@ static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
>  	{ PORT_SWITCH_ID_6352_A1, "Marvell 88E6352 (A1)" },
>  };
>  
> -static char *mv88e6352_drv_probe(struct device *dsa_dev,
> -				 struct device *host_dev,
> -				 int sw_addr, void **priv)
> +static const char *mv88e6352_drv_probe(struct device *dsa_dev,
> +				       struct device *host_dev, int sw_addr,
> +				       void **priv)
>  {
>  	return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
>  				   mv88e6352_table,
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index b018f20..25d7fec 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -3173,9 +3173,10 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
>  }
>  #endif /* CONFIG_NET_DSA_HWMON */
>  
> -static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
> -				   const struct mv88e6xxx_switch_id *table,
> -				   unsigned int num)
> +static const char *
> +mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
> +		      const struct mv88e6xxx_switch_id *table,
> +		      unsigned int num)
>  {
>  	int i, ret;
>  
> @@ -3205,14 +3206,14 @@ static char *mv88e6xxx_lookup_name(struct mii_bus *bus, int sw_addr,
>  	return NULL;
>  }
>  
> -char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
> -			  int sw_addr, void **priv,
> -			  const struct mv88e6xxx_switch_id *table,
> -			  unsigned int num)
> +const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
> +				int sw_addr, void **priv,
> +				const struct mv88e6xxx_switch_id *table,
> +				unsigned int num)
>  {
>  	struct mv88e6xxx_priv_state *ps;
>  	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
> -	char *name;
> +	const char *name;
>  
>  	if (!bus)
>  		return NULL;
> diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
> index 0debb9f..5eb6013 100644
> --- a/drivers/net/dsa/mv88e6xxx.h
> +++ b/drivers/net/dsa/mv88e6xxx.h
> @@ -462,10 +462,10 @@ struct mv88e6xxx_hw_stat {
>  };
>  
>  int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
> -char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
> -			  int sw_addr, void **priv,
> -			  const struct mv88e6xxx_switch_id *table,
> -			  unsigned int num);
> +const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
> +				int sw_addr, void **priv,
> +				const struct mv88e6xxx_switch_id *table,
> +				unsigned int num);
>  
>  int mv88e6xxx_setup_ports(struct dsa_switch *ds);
>  int mv88e6xxx_setup_common(struct dsa_switch *ds);
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 689ebd3..c4bc42b 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -217,8 +217,9 @@ struct dsa_switch_driver {
>  	/*
>  	 * Probing and setup.
>  	 */
> -	char	*(*probe)(struct device *dsa_dev, struct device *host_dev,
> -			  int sw_addr, void **priv);
> +	const char	*(*probe)(struct device *dsa_dev,
> +				  struct device *host_dev, int sw_addr,
> +				  void **priv);
>  	int	(*setup)(struct dsa_switch *ds);
>  	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
>  	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index 60ea9848..efa612f 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -52,11 +52,11 @@ EXPORT_SYMBOL_GPL(unregister_switch_driver);
>  
>  static struct dsa_switch_driver *
>  dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,
> -		 char **_name, void **priv)
> +		 const char **_name, void **priv)
>  {
>  	struct dsa_switch_driver *ret;
>  	struct list_head *list;
> -	char *name;
> +	const char *name;
>  
>  	ret = NULL;
>  	name = NULL;
> @@ -383,7 +383,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
>  	struct dsa_switch_driver *drv;
>  	struct dsa_switch *ds;
>  	int ret;
> -	char *name;
> +	const char *name;
>  	void *priv;
>  
>  	/*
> -- 
> 2.8.0
> 

^ permalink raw reply

* Re: [PATCH net-next v4 5/9] net: dsa: mv88e6xxx: add switch info
From: Andrew Lunn @ 2016-04-17 17:54 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli
In-Reply-To: <1460913843-7459-6-git-send-email-vivien.didelot@savoirfairelinux.com>

On Sun, Apr 17, 2016 at 01:23:59PM -0400, Vivien Didelot wrote:
> Add a new switch info structure which is meant to store switch models
> static information, such as product number, name, number of ports,
> number of databases, etc.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks
	Andrew

> ---
>  drivers/net/dsa/mv88e6123.c | 15 +++++++++++----
>  drivers/net/dsa/mv88e6131.c | 19 ++++++++++++++-----
>  drivers/net/dsa/mv88e6171.c | 19 ++++++++++++++-----
>  drivers/net/dsa/mv88e6352.c | 27 ++++++++++++++++++++-------
>  drivers/net/dsa/mv88e6xxx.c | 18 +++++++++++-------
>  drivers/net/dsa/mv88e6xxx.h | 27 +++++++++++++++++++++++----
>  6 files changed, 93 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
> index d6921ba..62dffcf 100644
> --- a/drivers/net/dsa/mv88e6123.c
> +++ b/drivers/net/dsa/mv88e6123.c
> @@ -17,10 +17,17 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
> -	{ PORT_SWITCH_ID_6123, "Marvell 88E6123" },
> -	{ PORT_SWITCH_ID_6161, "Marvell 88E6161" },
> -	{ PORT_SWITCH_ID_6165, "Marvell 88E6165" },
> +static const struct mv88e6xxx_info mv88e6123_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6123,
> +		.name = "Marvell 88E6123",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6161,
> +		.name = "Marvell 88E6161",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6165,
> +		.name = "Marvell 88E6165",
> +	}
>  };
>  
>  static const char *mv88e6123_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
> index 8dc1365..0056715 100644
> --- a/drivers/net/dsa/mv88e6131.c
> +++ b/drivers/net/dsa/mv88e6131.c
> @@ -17,11 +17,20 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
> -	{ PORT_SWITCH_ID_6085, "Marvell 88E6085" },
> -	{ PORT_SWITCH_ID_6095, "Marvell 88E6095/88E6095F" },
> -	{ PORT_SWITCH_ID_6131, "Marvell 88E6131" },
> -	{ PORT_SWITCH_ID_6185, "Marvell 88E6185" },
> +static const struct mv88e6xxx_info mv88e6131_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6095,
> +		.name = "Marvell 88E6095/88E6095F",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6085,
> +		.name = "Marvell 88E6085",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6131,
> +		.name = "Marvell 88E6131",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6185,
> +		.name = "Marvell 88E6185",
> +	}
>  };
>  
>  static const char *mv88e6131_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
> index ae32875..ea14ab2 100644
> --- a/drivers/net/dsa/mv88e6171.c
> +++ b/drivers/net/dsa/mv88e6171.c
> @@ -17,11 +17,20 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
> -	{ PORT_SWITCH_ID_6171, "Marvell 88E6171" },
> -	{ PORT_SWITCH_ID_6175, "Marvell 88E6175" },
> -	{ PORT_SWITCH_ID_6350, "Marvell 88E6350" },
> -	{ PORT_SWITCH_ID_6351, "Marvell 88E6351" },
> +static const struct mv88e6xxx_info mv88e6171_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
> +		.name = "Marvell 88E6171",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
> +		.name = "Marvell 88E6175",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
> +		.name = "Marvell 88E6350",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
> +		.name = "Marvell 88E6351",
> +	}
>  };
>  
>  static const char *mv88e6171_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
> index 34f92b1..2f72606 100644
> --- a/drivers/net/dsa/mv88e6352.c
> +++ b/drivers/net/dsa/mv88e6352.c
> @@ -22,13 +22,26 @@
>  #include <net/dsa.h>
>  #include "mv88e6xxx.h"
>  
> -static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
> -	{ PORT_SWITCH_ID_6172, "Marvell 88E6172" },
> -	{ PORT_SWITCH_ID_6176, "Marvell 88E6176" },
> -	{ PORT_SWITCH_ID_6240, "Marvell 88E6240" },
> -	{ PORT_SWITCH_ID_6320, "Marvell 88E6320" },
> -	{ PORT_SWITCH_ID_6321, "Marvell 88E6321" },
> -	{ PORT_SWITCH_ID_6352, "Marvell 88E6352" },
> +static const struct mv88e6xxx_info mv88e6352_table[] = {
> +	{
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6320,
> +		.name = "Marvell 88E6320",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6321,
> +		.name = "Marvell 88E6321",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6172,
> +		.name = "Marvell 88E6172",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6176,
> +		.name = "Marvell 88E6176",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6240,
> +		.name = "Marvell 88E6240",
> +	}, {
> +		.prod_num = PORT_SWITCH_ID_PROD_NUM_6352,
> +		.name = "Marvell 88E6352",
> +	}
>  };
>  
>  static const char *mv88e6352_drv_probe(struct device *dsa_dev,
> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
> index 49f085a..5fb21e0 100644
> --- a/drivers/net/dsa/mv88e6xxx.c
> +++ b/drivers/net/dsa/mv88e6xxx.c
> @@ -3169,24 +3169,25 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
>  }
>  #endif /* CONFIG_NET_DSA_HWMON */
>  
> -static const char *
> -mv88e6xxx_lookup_name(unsigned int id, const struct mv88e6xxx_switch_id *table,
> +static const struct mv88e6xxx_info *
> +mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table,
>  		      unsigned int num)
>  {
>  	int i;
>  
>  	for (i = 0; i < num; ++i)
> -		if (table[i].id == (id & 0xfff0))
> -			return table[i].name;
> +		if (table[i].prod_num == prod_num)
> +			return &table[i];
>  
>  	return NULL;
>  }
>  
>  const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  				int sw_addr, void **priv,
> -				const struct mv88e6xxx_switch_id *table,
> +				const struct mv88e6xxx_info *table,
>  				unsigned int num)
>  {
> +	const struct mv88e6xxx_info *info;
>  	struct mv88e6xxx_priv_state *ps;
>  	struct mii_bus *bus;
>  	const char *name;
> @@ -3203,16 +3204,19 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  	prod_num = (id & 0xfff0) >> 4;
>  	rev = id & 0x000f;
>  
> -	name = mv88e6xxx_lookup_name(id, table, num);
> -	if (!name)
> +	info = mv88e6xxx_lookup_info(prod_num, table, num);
> +	if (!info)
>  		return NULL;
>  
> +	name = info->name;
> +
>  	ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
>  	if (!ps)
>  		return NULL;
>  
>  	ps->bus = bus;
>  	ps->sw_addr = sw_addr;
> +	ps->info = info;
>  	ps->id = id & 0xfff0;
>  
>  	*priv = ps;
> diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
> index 6513450..b87f574 100644
> --- a/drivers/net/dsa/mv88e6xxx.h
> +++ b/drivers/net/dsa/mv88e6xxx.h
> @@ -68,6 +68,23 @@
>  #define PORT_PCS_CTRL_UNFORCED		0x03
>  #define PORT_PAUSE_CTRL		0x02
>  #define PORT_SWITCH_ID		0x03
> +#define PORT_SWITCH_ID_PROD_NUM_6085	0x04a
> +#define PORT_SWITCH_ID_PROD_NUM_6095	0x095
> +#define PORT_SWITCH_ID_PROD_NUM_6131	0x106
> +#define PORT_SWITCH_ID_PROD_NUM_6320	0x115
> +#define PORT_SWITCH_ID_PROD_NUM_6123	0x121
> +#define PORT_SWITCH_ID_PROD_NUM_6161	0x161
> +#define PORT_SWITCH_ID_PROD_NUM_6165	0x165
> +#define PORT_SWITCH_ID_PROD_NUM_6171	0x171
> +#define PORT_SWITCH_ID_PROD_NUM_6172	0x172
> +#define PORT_SWITCH_ID_PROD_NUM_6175	0x175
> +#define PORT_SWITCH_ID_PROD_NUM_6176	0x176
> +#define PORT_SWITCH_ID_PROD_NUM_6185	0x1a7
> +#define PORT_SWITCH_ID_PROD_NUM_6240	0x240
> +#define PORT_SWITCH_ID_PROD_NUM_6321	0x310
> +#define PORT_SWITCH_ID_PROD_NUM_6352	0x352
> +#define PORT_SWITCH_ID_PROD_NUM_6350	0x371
> +#define PORT_SWITCH_ID_PROD_NUM_6351	0x375
>  #define PORT_SWITCH_ID_6031	0x0310
>  #define PORT_SWITCH_ID_6035	0x0350
>  #define PORT_SWITCH_ID_6046	0x0480
> @@ -352,9 +369,9 @@
>  
>  #define MV88E6XXX_N_FID		4096
>  
> -struct mv88e6xxx_switch_id {
> -	u16 id;
> -	char *name;
> +struct mv88e6xxx_info {
> +	u16 prod_num;
> +	const char *name;
>  };
>  
>  struct mv88e6xxx_atu_entry {
> @@ -382,6 +399,8 @@ struct mv88e6xxx_priv_port {
>  };
>  
>  struct mv88e6xxx_priv_state {
> +	const struct mv88e6xxx_info *info;
> +
>  	/* The dsa_switch this private structure is related to */
>  	struct dsa_switch *ds;
>  
> @@ -449,7 +468,7 @@ struct mv88e6xxx_hw_stat {
>  int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active);
>  const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
>  				int sw_addr, void **priv,
> -				const struct mv88e6xxx_switch_id *table,
> +				const struct mv88e6xxx_info *table,
>  				unsigned int num);
>  
>  int mv88e6xxx_setup_ports(struct dsa_switch *ds);
> -- 
> 2.8.0
> 

^ permalink raw reply

* re:
From: Ali Saeed @ 2016-04-17 18:03 UTC (permalink / raw)




I have a project request...

^ permalink raw reply

* Re: [PATCH] net: ipv6: Do not fix up linklocal and loopback addresses
From: Mike Manning @ 2016-04-17 18:13 UTC (permalink / raw)
  To: David Ahern, netdev
In-Reply-To: <571283EA.6020307@cumulusnetworks.com>

On 04/16/2016 07:26 PM, David Ahern wrote:
> On 4/15/16 9:13 PM, Mike Manning wrote:
>> f1705ec197e7 added the option to retain user configured addresses on an
>> admin down. A comment to one of the later revisions suggested using the
>> IFA_F_PERMANENT flag rather than adding a user_managed boolean to the
>> ifaddr struct. A side effect of this change is that link local and
>> loopback addresses are also retained which is not part of the objective
>> of f1705ec197e7. Add check so that these addresses are not fixed up,
>> given that a related fix 70af921db6f8 ensures that they are not kept in
>> the first place, otherwise this incorrect fixup triggers a crash in fib6.
> 
> oops in fib6_del?
>
 
[  285.734883]  [<ffffffff8125ad15>] ? dump_stack+0x5c/0x77
[  285.734887]  [<ffffffff8105d907>] ? warn_slowpath_common+0x77/0xb0
[  285.734889]  [<ffffffff814f3e40>] ? fib6_clean_tohost+0x50/0x50
[  285.734891]  [<ffffffff814fbe3e>] ? fib6_del+0x22e/0x290
[  285.734893]  [<ffffffff814fbf22>] ? fib6_clean_node+0x82/0x120
[  285.734895]  [<ffffffff814f9a0d>] ? fib6_walk_continue+0x16d/0x1a0
[  285.734897]  [<ffffffff814f9ad4>] ? fib6_walk+0x54/0x80
[  285.734899]  [<ffffffff814f9b42>] ? fib6_clean_tree+0x42/0x50
[  285.734901]  [<ffffffff814fbea0>] ? fib6_del+0x290/0x290
[  285.734902]  [<ffffffff814f3e40>] ? fib6_clean_tohost+0x50/0x50
[  285.734904]  [<ffffffff814f9ba8>] ? __fib6_clean_all+0x58/0x90
[  285.734906]  [<ffffffff814f9326>] ? rt6_ifdown+0x36/0x1e0
[  285.734908]  [<ffffffff814fbf0f>] ? fib6_clean_node+0x6f/0x120
[  285.734911]  [<ffffffff814eeb6b>] ? addrconf_ifdown+0x3b/0x580
[  285.734913]  [<ffffffff814f9b42>] ? fib6_clean_tree+0x42/0x50
[  285.734914]  [<ffffffff814f1ea0>] ? addrconf_notify+0xf0/0xb10
[  285.734916]  [<ffffffff814f9bb0>] ? __fib6_clean_all+0x60/0x90

>> Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional")
>> Signed-off-by: Mike Manning <mmanning@brocade.com>
>> ---
> 
> for the change
> Acked-by: David Ahern <dsa@cumulusnetworks.com>
> 

^ 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