* [PATCH net-next v3 2/2] iproute2: bridge vlan show new option to print ranges
From: roopa @ 2015-01-26 2:26 UTC (permalink / raw)
To: netdev, shemminger, vyasevic; +Cc: wkok, sfeldma
From: Roopa Prabhu <roopa@cumulusnetworks.com>
Introduce new option -c[ompressvlans] to request
vlan ranges from kernel
(pls suggest better option names if this does not look ok)
$bridge vlan show
port vlan ids
dummy0 1 PVID Egress Untagged
dummy1 1 PVID Egress Untagged
2
3
4
5
6
7
9
10
12
br0 1 PVID Egress Untagged
$bridge help
Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }
where OBJECT := { link | fdb | mdb | vlan | monitor }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |
-o[neline] | -t[imestamp] | -n[etns] name |
-c[ompressvlans] }
$bridge -c vlan show
port vlan ids
dummy0 1 PVID Egress Untagged
dummy1 1 PVID Egress Untagged
2-7
9-10
12
br0 1 PVID Egress Untagged
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
bridge/br_common.h | 1 +
bridge/bridge.c | 6 +++++-
bridge/vlan.c | 11 +++++++++--
include/linux/rtnetlink.h | 1 +
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/bridge/br_common.h b/bridge/br_common.h
index 12fce3e..169a162 100644
--- a/bridge/br_common.h
+++ b/bridge/br_common.h
@@ -16,4 +16,5 @@ extern int preferred_family;
extern int show_stats;
extern int show_details;
extern int timestamp;
+extern int compress_vlans;
extern struct rtnl_handle rth;
diff --git a/bridge/bridge.c b/bridge/bridge.c
index 5fcc552..88469ca 100644
--- a/bridge/bridge.c
+++ b/bridge/bridge.c
@@ -21,6 +21,7 @@ int resolve_hosts;
int oneline = 0;
int show_stats;
int show_details;
+int compress_vlans;
int timestamp;
char * _SL_ = NULL;
@@ -32,7 +33,8 @@ static void usage(void)
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
-" -o[neline] | -t[imestamp] | -n[etns] name }\n");
+" -o[neline] | -t[imestamp] | -n[etns] name |\n"
+" -c[ompressvlans] }\n");
exit(-1);
}
@@ -117,6 +119,8 @@ main(int argc, char **argv)
NEXT_ARG();
if (netns_switch(argv[1]))
exit(-1);
+ } else if (matches(opt, "-compressvlans") == 0) {
+ ++compress_vlans;
} else {
fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
exit(-1);
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 88992e6..9f6c84e 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -182,7 +182,12 @@ static int print_vlan(const struct sockaddr_nl *who,
continue;
vinfo = RTA_DATA(i);
- fprintf(fp, "\t %hu", vinfo->vid);
+ if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END)
+ fprintf(fp, "-%hu", vinfo->vid);
+ else
+ fprintf(fp, "\t %hu", vinfo->vid);
+ if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN)
+ continue;
if (vinfo->flags & BRIDGE_VLAN_INFO_PVID)
fprintf(fp, " PVID");
if (vinfo->flags & BRIDGE_VLAN_INFO_UNTAGGED)
@@ -218,7 +223,9 @@ static int vlan_show(int argc, char **argv)
}
if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
- RTEXT_FILTER_BRVLAN) < 0) {
+ (compress_vlans ?
+ RTEXT_FILTER_BRVLAN_COMPRESSED :
+ RTEXT_FILTER_BRVLAN)) < 0) {
perror("Cannont send dump request");
exit(1);
}
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 9aa5c2f..19eadb1 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -632,6 +632,7 @@ struct tcamsg {
/* New extended info filters for IFLA_EXT_MASK */
#define RTEXT_FILTER_VF (1 << 0)
#define RTEXT_FILTER_BRVLAN (1 << 1)
+#define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2)
/* End of information exported to user level */
--
1.7.10.4
^ permalink raw reply related
* [PATCH net-next v3 1/2] iproute2: bridge: support vlan range adds
From: roopa @ 2015-01-26 2:26 UTC (permalink / raw)
To: netdev, shemminger, vyasevic; +Cc: wkok, sfeldma
From: Roopa Prabhu <roopa@cumulusnetworks.com>
This patch adds vlan range support to bridge add command
using the newly added vinfo flags BRIDGE_VLAN_INFO_RANGE_BEGIN and
BRIDGE_VLAN_INFO_RANGE_END.
$bridge vlan show
port vlan ids
br0 1 PVID Egress Untagged
dummy0 1 PVID Egress Untagged
$bridge vlan add vid 10-15 dev dummy0
port vlan ids
br0 1 PVID Egress Untagged
dummy0 1 PVID Egress Untagged
10
11
12
13
14
15
$bridge vlan del vid 14 dev dummy0
$bridge vlan show
port vlan ids
br0 1 PVID Egress Untagged
dummy0 1 PVID Egress Untagged
10
11
12
13
15
$bridge vlan del vid 10-15 dev dummy0
$bridge vlan show
port vlan ids
br0 1 PVID Egress Untagged
dummy0 1 PVID Egress Untagged
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
---
bridge/vlan.c | 44 ++++++++++++++++++++++++++++++++++++++++----
include/linux/if_bridge.h | 2 ++
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 3bd7b0d..88992e6 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -32,6 +32,7 @@ static int vlan_modify(int cmd, int argc, char **argv)
} req;
char *d = NULL;
short vid = -1;
+ short vid_end = -1;
struct rtattr *afspec;
struct bridge_vlan_info vinfo;
unsigned short flags = 0;
@@ -49,8 +50,18 @@ static int vlan_modify(int cmd, int argc, char **argv)
NEXT_ARG();
d = *argv;
} else if (strcmp(*argv, "vid") == 0) {
+ char *p;
NEXT_ARG();
- vid = atoi(*argv);
+ p = strchr(*argv, '-');
+ if (p) {
+ *p = '\0';
+ p++;
+ vid = atoi(*argv);
+ vid_end = atoi(p);
+ vinfo.flags |= BRIDGE_VLAN_INFO_RANGE_BEGIN;
+ } else {
+ vid = atoi(*argv);
+ }
} else if (strcmp(*argv, "self") == 0) {
flags |= BRIDGE_FLAGS_SELF;
} else if (strcmp(*argv, "master") == 0) {
@@ -83,15 +94,40 @@ static int vlan_modify(int cmd, int argc, char **argv)
return -1;
}
- vinfo.vid = vid;
+ if (vinfo.flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
+ if (vid_end == -1 || vid_end >= 4096 || vid >= vid_end) {
+ fprintf(stderr, "Invalid VLAN range \"%hu-%hu\"\n",
+ vid, vid_end);
+ return -1;
+ }
+ if (vinfo.flags & BRIDGE_VLAN_INFO_PVID) {
+ fprintf(stderr,
+ "pvid cannot be configured for a vlan range\n");
+ return -1;
+ }
+ }
afspec = addattr_nest(&req.n, sizeof(req), IFLA_AF_SPEC);
if (flags)
addattr16(&req.n, sizeof(req), IFLA_BRIDGE_FLAGS, flags);
- addattr_l(&req.n, sizeof(req), IFLA_BRIDGE_VLAN_INFO, &vinfo,
- sizeof(vinfo));
+ vinfo.vid = vid;
+ if (vid_end != -1) {
+ /* send vlan range start */
+ addattr_l(&req.n, sizeof(req), IFLA_BRIDGE_VLAN_INFO, &vinfo,
+ sizeof(vinfo));
+ vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
+
+ /* Now send the vlan range end */
+ vinfo.flags |= BRIDGE_VLAN_INFO_RANGE_END;
+ vinfo.vid = vid_end;
+ addattr_l(&req.n, sizeof(req), IFLA_BRIDGE_VLAN_INFO, &vinfo,
+ sizeof(vinfo));
+ } else {
+ addattr_l(&req.n, sizeof(req), IFLA_BRIDGE_VLAN_INFO, &vinfo,
+ sizeof(vinfo));
+ }
addattr_nest_end(&req.n, afspec);
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index 19ff22a..efa10b8 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -125,6 +125,8 @@ enum {
#define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
#define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
#define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */
+#define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */
+#define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */
struct bridge_vlan_info {
__u16 flags;
--
1.7.10.4
^ permalink raw reply related
* [PATCH net-next v3 0/2] iproute2: bridge vlan range support
From: roopa @ 2015-01-26 2:26 UTC (permalink / raw)
To: netdev, shemminger, vyasevic; +Cc: wkok, sfeldma
From: Roopa Prabhu <roopa@cumulusnetworks.com>
This series adds support for vlan ranges in iproute2 bridge add
and show commands.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com>
Roopa Prabhu (2):
iproute2: bridge: support vlan range for adds
iproute2: bridge vlan show new option to print ranges
bridge/br_common.h | 1 +
bridge/bridge.c | 6 ++++-
bridge/vlan.c | 55 ++++++++++++++++++++++++++++++++++++++++-----
include/linux/if_bridge.h | 2 ++
include/linux/rtnetlink.h | 1 +
5 files changed, 58 insertions(+), 7 deletions(-)
--
1.7.10.4
^ permalink raw reply
* Re: Question on SCTP ABORT chunk is generated when the association_max_retrans is reached
From: Sun Paul @ 2015-01-26 1:27 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Michael Tuexen, Vlad Yasevich, linux-sctp, netdev, linux-kernel
In-Reply-To: <54C29B82.7090502@redhat.com>
Hi
sorry for the late reply. I am a bit confused. when side-A sends a
request to side-B, and side-B return the response, but side-A keep
re-transmit the same request to side-B, why side-B needed to send a
ABORT to side-A?
If it is used in order to reestablish the connection, shoudn't it
should be side-A to send ABORT instead?
- PS
On Sat, Jan 24, 2015 at 3:05 AM, Daniel Borkmann <dborkman@redhat.com> wrote:
> On 01/23/2015 07:36 PM, Michael Tuexen wrote:
> ...
>>
>> Yepp. It might not reach the peer or it might. If it does it helps
>> to keep the states in sync. If it doesn't it sometimes helps in
>> analysing tracefiles. In BSD, we also send it. It is not required,
>> doesn't harm and is useful in some cases...
>
>
> Ok, as the TCB is destroyed in any case, should be fine then.
>
> Thanks,
> Daniel
^ permalink raw reply
* Re: [PATCH net-next 0/2] net: phy and dsa random fixes/cleanups
From: David Miller @ 2015-01-26 0:03 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev
In-Reply-To: <1421800920-6281-1-git-send-email-f.fainelli@gmail.com>
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 20 Jan 2015 16:41:58 -0800
> These two patches were already present as part of my attempt to make
> DSA modules work properly, these are the only two "valid" patches at
> this point which should not need any further rework.
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH] net: dsa: set slave MII bus PHY mask
From: David Miller @ 2015-01-26 0:01 UTC (permalink / raw)
To: vivien.didelot; +Cc: netdev, f.fainelli, linux-kernel, kernel
In-Reply-To: <1421799212-2028-2-git-send-email-vivien.didelot@savoirfairelinux.com>
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Tue, 20 Jan 2015 19:13:32 -0500
> When registering a mdio bus, Linux assumes than every port has a PHY and tries
> to scan it. If a switch port has no PHY registered, DSA will fail to register
> the slave MII bus. To fix this, set the slave MII bus PHY mask to the switch
> PHYs mask.
>
> As an example, if we use a Marvell MV88E6352 (which is a 7-port switch with no
> registered PHYs for port 5 and port 6), with the following declared names:
>
> static struct dsa_chip_data switch_cdata = {
> [...]
> .port_names[0] = "sw0",
> .port_names[1] = "sw1",
> .port_names[2] = "sw2",
> .port_names[3] = "sw3",
> .port_names[4] = "sw4",
> .port_names[5] = "cpu",
> };
>
> DSA will fail to create the switch instance. With the PHY mask set for the
> slave MII bus, only the PHY for ports 0-4 will be scanned and the instance will
> be successfully created.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Applied.
^ permalink raw reply
* [PATCH 1/2] rhashtable: Introduce rhashtable_walk_*
From: Herbert Xu @ 2015-01-25 23:21 UTC (permalink / raw)
To: Thomas Graf, Ying Xue, davem, kaber, paulmck, netdev,
netfilter-devel
In-Reply-To: <20150125232040.GA17936@gondor.apana.org.au>
Some existing rhashtable users get too intimate with it by walking
the buckets directly. This prevents us from easily changing the
internals of rhashtable.
This patch adds the helpers rhashtable_walk_init/next/end which
will replace these custom walkers.
They are meant to be usable for both procfs seq_file walks as well
as walking by a netlink dump. The iterator structure should fit
inside a netlink dump cb structure, with at least one element to
spare.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
include/linux/rhashtable.h | 44 +++++++++++++++++++++
lib/rhashtable.c | 91 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 135 insertions(+)
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 6d7e840..b03b375 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -18,6 +18,7 @@
#ifndef _LINUX_RHASHTABLE_H
#define _LINUX_RHASHTABLE_H
+#include <linux/compiler.h>
#include <linux/list_nulls.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>
@@ -123,6 +124,22 @@ struct rhashtable {
bool being_destroyed;
};
+/**
+ * struct rhashtable_iter - Hash table iterator
+ * @ht: Table to iterate through
+ * @p: Current pointer
+ * @lock: Slot lock
+ * @slot: Current slot
+ * @skip: Number of entries to skip in slot
+ */
+struct rhashtable_iter {
+ struct rhashtable *ht;
+ struct rhash_head *p;
+ spinlock_t *lock;
+ unsigned int slot;
+ unsigned int skip;
+};
+
static inline unsigned long rht_marker(const struct rhashtable *ht, u32 hash)
{
return NULLS_MARKER(ht->p.nulls_base + hash);
@@ -178,6 +195,33 @@ bool rhashtable_lookup_compare_insert(struct rhashtable *ht,
bool (*compare)(void *, void *),
void *arg);
+/**
+ * rhashtable_walk_init - Initialise an iterator
+ * @ht: Table to walk over
+ * @iter: Hash table Iterator
+ *
+ * This function prepares a hash table walk.
+ * Note that if you restart a walk after rhashtable_walk_stop you
+ * may see the same object twice. Also, you may miss objects if
+ * there are removals in between rhashtable_walk_stop and the next
+ * call to rhashtable_walk_start.
+ *
+ * For a completely stable walk you should construct your own data
+ * structure outside the hash table.
+ */
+static inline void rhashtable_walk_init(struct rhashtable *ht,
+ struct rhashtable_iter *iter)
+{
+ iter->ht = ht;
+ iter->p = NULL;
+ iter->slot = 0;
+ iter->skip = 0;
+}
+
+int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU);
+void *rhashtable_walk_next(struct rhashtable_iter *iter);
+void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU);
+
void rhashtable_destroy(struct rhashtable *ht);
#define rht_dereference(p, ht) \
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 71c6aa1..d51fb06 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -813,6 +813,97 @@ exit:
}
EXPORT_SYMBOL_GPL(rhashtable_lookup_compare_insert);
+/**
+ * rhashtable_walk_start - Start a hash table walk
+ * @iter: Hash table iterator
+ *
+ * Start a hash table walk.
+ *
+ * Returns zero if successful. Returns -EINTR if we couldn't
+ * obtain the resize lock.
+ */
+int rhashtable_walk_start(struct rhashtable_iter *iter)
+{
+ struct rhashtable *ht = iter->ht;
+ int err;
+
+ err = mutex_lock_interruptible(&ht->mutex);
+ rcu_read_lock();
+
+ if (!err)
+ mutex_unlock(&ht->mutex);
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(rhashtable_walk_start);
+
+/**
+ * rhashtable_walk_next - Return the next object and advance the iterator
+ * @iter: Hash table iterator
+ *
+ * Note that you must call rhashtable_walk_stop when you are finished
+ * with the walk.
+ *
+ * Returns the next object or NULL when the end of the table is reached.
+ */
+void *rhashtable_walk_next(struct rhashtable_iter *iter)
+{
+ const struct bucket_table *tbl;
+ struct rhashtable *ht = iter->ht;
+ struct rhash_head *p = iter->p;
+
+ tbl = rht_dereference_rcu(ht->tbl, ht);
+
+ if (p) {
+ p = rht_dereference_bucket(p->next, tbl, iter->slot);
+ goto next;
+ }
+
+ for (; iter->slot < tbl->size; iter->slot++) {
+ int skip = iter->skip;
+
+ iter->lock = bucket_lock(tbl, iter->slot);
+ spin_lock_bh(iter->lock);
+
+ rht_for_each(p, tbl, iter->slot) {
+ if (!skip)
+ break;
+ skip--;
+ }
+
+next:
+ if (!rht_is_a_nulls(p)) {
+ iter->skip++;
+ iter->p = p;
+ return rht_obj(ht, p);
+ }
+ spin_unlock_bh(iter->lock);
+
+ iter->skip = 0;
+ }
+
+ iter->p = NULL;
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(rhashtable_walk_next);
+
+/**
+ * rhashtable_walk_stop - Finish a hash table walk
+ * @iter: Hash table iterator
+ *
+ * Finish a hash table walk.
+ */
+void rhashtable_walk_stop(struct rhashtable_iter *iter)
+{
+ if (iter->p)
+ spin_unlock_bh(iter->lock);
+
+ rcu_read_unlock();
+
+ iter->p = NULL;
+}
+EXPORT_SYMBOL_GPL(rhashtable_walk_stop);
+
static size_t rounded_hashtable_size(struct rhashtable_params *params)
{
return max(roundup_pow_of_two(params->nelem_hint * 4 / 3),
^ permalink raw reply related
* [PATCH 2/2] netlink: Use rhashtable walk iterator
From: Herbert Xu @ 2015-01-25 23:21 UTC (permalink / raw)
To: Thomas Graf, Ying Xue, davem, kaber, paulmck, netdev,
netfilter-devel
In-Reply-To: <20150125232040.GA17936@gondor.apana.org.au>
This patch gets rid of the manual rhashtable walk in netlink
which touches rhashtable internals that should not be exposed.
It does so by using the rhashtable iterator primitives.
In fact the existing code was very buggy. Some sockets weren't
shown at all while others were shown more than once.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
net/netlink/af_netlink.c | 113 +++++++++++++++++------------------------------
1 file changed, 41 insertions(+), 72 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d77b346..6f8549e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2884,99 +2884,68 @@ EXPORT_SYMBOL(nlmsg_notify);
#ifdef CONFIG_PROC_FS
struct nl_seq_iter {
struct seq_net_private p;
+ struct rhashtable_iter hti;
int link;
- int hash_idx;
};
-static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
+static int netlink_walk_start(struct nl_seq_iter *iter)
{
- struct nl_seq_iter *iter = seq->private;
- int i, j;
- struct netlink_sock *nlk;
- struct sock *s;
- loff_t off = 0;
-
- for (i = 0; i < MAX_LINKS; i++) {
- struct rhashtable *ht = &nl_table[i].hash;
- const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
-
- for (j = 0; j < tbl->size; j++) {
- struct rhash_head *node;
-
- rht_for_each_entry_rcu(nlk, node, tbl, j, node) {
- s = (struct sock *)nlk;
-
- if (sock_net(s) != seq_file_net(seq))
- continue;
- if (off == pos) {
- iter->link = i;
- iter->hash_idx = j;
- return s;
- }
- ++off;
- }
- }
- }
- return NULL;
-}
-
-static void *netlink_seq_start(struct seq_file *seq, loff_t *pos)
- __acquires(RCU)
-{
- rcu_read_lock();
- return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : SEQ_START_TOKEN;
+ rhashtable_walk_init(&nl_table[iter->link].hash, &iter->hti);
+ return rhashtable_walk_start(&iter->hti);
}
-static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+static void *__netlink_seq_next(struct seq_file *seq)
{
- struct rhashtable *ht;
- const struct bucket_table *tbl;
- struct rhash_head *node;
+ struct nl_seq_iter *iter = seq->private;
struct netlink_sock *nlk;
- struct nl_seq_iter *iter;
- struct net *net;
- int i, j;
- ++*pos;
+ do {
+ while (!(nlk = rhashtable_walk_next(&iter->hti))) {
+ int err;
- if (v == SEQ_START_TOKEN)
- return netlink_seq_socket_idx(seq, 0);
+ rhashtable_walk_stop(&iter->hti);
+ if (++iter->link >= MAX_LINKS)
+ return NULL;
- net = seq_file_net(seq);
- iter = seq->private;
- nlk = v;
+ err = netlink_walk_start(iter);
+ if (err)
+ return ERR_PTR(err);
+ }
+ } while (sock_net(&nlk->sk) != seq_file_net(seq));
- i = iter->link;
- ht = &nl_table[i].hash;
- tbl = rht_dereference_rcu(ht->tbl, ht);
- rht_for_each_entry_rcu_continue(nlk, node, nlk->node.next, tbl, iter->hash_idx, node)
- if (net_eq(sock_net((struct sock *)nlk), net))
- return nlk;
+ return nlk;
+}
- j = iter->hash_idx + 1;
+static void *netlink_seq_start(struct seq_file *seq, loff_t *posp)
+{
+ struct nl_seq_iter *iter = seq->private;
+ void *obj = SEQ_START_TOKEN;
+ loff_t pos;
+ int err;
- do {
+ iter->link = 0;
+ err = netlink_walk_start(iter);
+ if (err)
+ return ERR_PTR(err);
- for (; j < tbl->size; j++) {
- rht_for_each_entry_rcu(nlk, node, tbl, j, node) {
- if (net_eq(sock_net((struct sock *)nlk), net)) {
- iter->link = i;
- iter->hash_idx = j;
- return nlk;
- }
- }
- }
+ for (pos = *posp; pos && obj; pos--)
+ obj = __netlink_seq_next(seq);
- j = 0;
- } while (++i < MAX_LINKS);
+ return obj;
+}
- return NULL;
+static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+ ++*pos;
+ return __netlink_seq_next(seq);
}
static void netlink_seq_stop(struct seq_file *seq, void *v)
- __releases(RCU)
{
- rcu_read_unlock();
+ struct nl_seq_iter *iter = seq->private;
+
+ if (iter->link < MAX_LINKS)
+ rhashtable_walk_stop(&iter->hti);
}
^ permalink raw reply related
* [PATCH 0/2] rhashtable: Add walk iterator primitives and use them in netlink
From: Herbert Xu @ 2015-01-25 23:20 UTC (permalink / raw)
To: Thomas Graf; +Cc: Ying Xue, davem, kaber, paulmck, netdev, netfilter-devel
In-Reply-To: <20150122084924.GA4720@gondor.apana.org.au>
On Thu, Jan 22, 2015 at 07:49:24PM +1100, Herbert Xu wrote:
>
> Could you hold off for a bit? I've got some changes that touch
> this area that I'd like to push out. Basically I'm trying to
> eliminate direct access of rhashtable internals from the existing
> users.
Here are the first two patches, one to add the primitives and one
to demonstrate its use in netlink. In fact while testing this I
found that the existing netlink walking code is totally broken.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH v3 net-next] net: ipv6: Add sysctl entry to disable MTU updates from RA
From: David Miller @ 2015-01-25 22:55 UTC (permalink / raw)
To: harouth; +Cc: netdev
In-Reply-To: <1421773565-5181-1-git-send-email-harouth@codeaurora.org>
From: Harout Hedeshian <harouth@codeaurora.org>
Date: Tue, 20 Jan 2015 10:06:05 -0700
> The kernel forcefully applies MTU values received in router
> advertisements provided the new MTU is less than the current. This
> behavior is undesirable when the user space is managing the MTU. Instead
> a sysctl flag 'accept_ra_mtu' is introduced such that the user space
> can control whether or not RA provided MTU updates should be applied. The
> default behavior is unchanged; user space must explicitly set this flag
> to 0 for RA MTUs to be ignored.
>
> Signed-off-by: Harout Hedeshian <harouth@codeaurora.org>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] amd-xgbe: Let OS arch support adjust DMA mask as needed
From: David Miller @ 2015-01-25 22:54 UTC (permalink / raw)
To: thomas.lendacky; +Cc: netdev
In-Reply-To: <20150120204755.23431.37523.stgit@tlendack-t1.amdoffice.net>
From: Tom Lendacky <thomas.lendacky@amd.com>
Date: Tue, 20 Jan 2015 14:47:55 -0600
> Set the DMA mask to 64-bit and let the underlying arch support adjust
> it as appropriate based on device tree DMA ranges, etc.
>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
That's not how this works.
The interface will fail if you ask for more bits than can be
supported, so you should pass in the amount of bits you actually need
but not more.
I'm not applying this.
^ permalink raw reply
* Re: [next-next PATCH 0/7] Fixes and improvements for recent fib_trie updates
From: David Miller @ 2015-01-25 22:47 UTC (permalink / raw)
To: alexander.h.duyck; +Cc: netdev
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
From: Alexander Duyck <alexander.h.duyck@redhat.com>
Date: Thu, 22 Jan 2015 15:51:01 -0800
> While performing testing and prepping the next round of patches I found a
> few minor issues and improvements that could be made.
>
> These changes should help to reduce the overall code size and improve the
> performance slighlty as I noticed a 20ns or so improvement in my worst-case
> testing which will likely only result in a 1ns difference with a standard
> sized trie.
Looks great, series applied, thanks Alexander.
^ permalink raw reply
* Re: [PATCH V1 net-next 0/9] mlx4: Fix and enhance the device reset flow
From: David Miller @ 2015-01-25 22:46 UTC (permalink / raw)
To: ogerlitz; +Cc: netdev, matanb, amirv, talal, roland, yishaih
In-Reply-To: <1422197983-16048-1-git-send-email-ogerlitz@mellanox.com>
From: Or Gerlitz <ogerlitz@mellanox.com>
Date: Sun, 25 Jan 2015 16:59:34 +0200
> This series from Yishai Hadas fixes the device reset flow and adds SRIOV support.
Series applied, thanks.
^ permalink raw reply
* Re: [PATCH] net: Linn Ethernet Packet Sniffer driver
From: Joe Perches @ 2015-01-24 21:37 UTC (permalink / raw)
To: Stathis Voukelatos
Cc: netdev, linux-kernel, devicetree, Stathis Voukelatos, abrestic
In-Reply-To: <1422007621-13567-1-git-send-email-stathis.voukelatos@linn.co.uk>
On Fri, 2015-01-23 at 10:07 +0000, Stathis Voukelatos wrote:
> This patch adds support the Ethernet Packet Sniffer H/W module
> developed by Linn Products Ltd and found in the IMG Pistachio SoC.
> The module allows Ethernet packets to be parsed, matched against
> a user-defined pattern and timestamped. It sits between a 100M
> Ethernet MAC and PHY and is completely passive with respect to
> Ethernet frames.
[]
> include/linux/pkt_sniffer.h | 89 +++++
Why should this file be here?
Why not in the drivers/net/pkt-sniffer directory?
> diff --git a/drivers/net/pkt-sniffer/backends/ether/channel.c b/drivers/net/pkt-sniffer/backends/ether/channel.c
[]
> +static int esnf_start(struct snf_chan *dev);
Be nice to rearrange the code to avoid the forward declarations.
> +static int esnf_stop(struct snf_chan *dev);
> +static int esnf_set_pattern(struct snf_chan *dev, const u8 *pattern, int count);
> +static int esnf_num_recs_avail(struct snf_chan *dev);
> +static int esnf_max_ptn_entries(struct snf_chan *dev);
> +static int esnf_max_match_bytes(struct snf_chan *dev);
> +static int validate_pattern(
> + struct ether_snf_chan *ch,
> + const u8 *buf,
> + int count);
[]
> +static int validate_pattern(struct ether_snf_chan *ch, const u8 *buf, int count)
> +{
Maybe better as bool
> + int i, complete, max_copy_bytes;
[]
> + /* Check if the string was properly terminated
> + * and contained valid number of commands
> + */
> + if (complete) {
> + max_copy_bytes = ch->fifo_blk_words * 4;
> + if (ts)
> + max_copy_bytes -= 4;
> + if ((copy_before + copy_after) > max_copy_bytes)
> + return 0;
> + ch->ts_present = ts;
> + ch->nfb_before = copy_before;
> + ch->nfb_after = copy_after;
> + return 1;
> + } else {
> + return 0;
> + }
return complete;
[]
> +/* Interrupt thread function */
> +static irqreturn_t esnf_irq_thread(int irq, void *dev_id)
> +{
> + struct platform_device *pdev = (struct platform_device *)dev_id;
> + struct ether_snf *esnf = (struct ether_snf *)platform_get_drvdata(pdev);
> + u32 irq_status;
> +
> + if (unlikely(esnf->irq != irq))
> + return IRQ_NONE;
> +
> + irq_status = ioread32(esnf->regs + INTERRUPT_STATUS) &
> + ioread32(esnf->regs + INTERRUPT_ENABLE);
> +
> + dev_dbg(&pdev->dev, "irq: 0x%08x\n", irq_status);
> +
> + /* TX FIFO full */
> + if (unlikely(irq_status & TX_FULL_IRQ_BIT))
> + dev_notice(&pdev->dev, "TX FIFO full");
Missing terminating newlines
> +
> + /* RX FIFO full */
> + if (unlikely(irq_status & RX_FULL_IRQ_BIT))
> + dev_notice(&pdev->dev, "RX FIFO full");
> +
> + /* TX match data available */
> + if (irq_status & TX_DATA_IRQ_BIT) {
> + dev_dbg(&pdev->dev, "TX data");
> + channel_data_available(&esnf->txc);
> + }
> +
> + /* RX match data available */
> + if (irq_status & RX_DATA_IRQ_BIT) {
> + dev_dbg(&pdev->dev, "RX data");
> + channel_data_available(&esnf->rxc);
> + }
> diff --git a/drivers/net/pkt-sniffer/core/nl.c b/drivers/net/pkt-sniffer/core/nl.c
[]
> +int snf_netlink_init(int id, struct snf_chan *dev, const char *name)
> +{
[]
> + /* Allocate ops array and copy template data */
> + nl->ops = kmalloc(sizeof(snf_ops_tmpl), GFP_KERNEL);
> + if (!nl->ops) {
> + ret = -ENOMEM;
> + goto fail2;
> + }
> + memcpy(nl->ops, snf_ops_tmpl, sizeof(snf_ops_tmpl));
kmemdup
^ permalink raw reply
* Re: CONFIG_NF_CONNTRACK_PROCFS
From: Oleg @ 2015-01-25 19:44 UTC (permalink / raw)
To: netdev
In-Reply-To: <20150125112209.GD13167@breakpoint.cc>
On Sun, Jan 25, 2015 at 12:22:09PM +0100, Florian Westphal wrote:
> Oleg <lego12239@yandex.ru> wrote:
> > net/netfilter/nf_conntrack procfs file is marked as obsolete in the recent
> > kernels. What's wrong with it? Or it's simply a new fashion to replace
> > simple file interface with anything else?
>
> proc has several drawbacks vs. ctnetlink:
> - not extensible
In the what way?
Sorry, but i think that limitations isn't in proc, but in a human fantasy.
> - doesn't have ability to query for particular items
What about something like:
exec 3<>nf_conntrack; echo show tcp dport 12345 >&3; cat <&3
HERE_WE_GET_NEEDED_ENTRIES
exec 3<&-
?
> - no add/delete support
What about simple:
echo add ENTRY > nf_conntrack
echo delete ENTRY > nf_conntrack
?
> - no event notification (e.g. conntrack -E)
Florian, are you seriosly? What's wrong with simple:
cat nf_conntrack_event
?
Moreover, all things i have wrote save already existent scripts works.
May be i don't understand anything? Please correct me if so.
P.S. netlink is really cool thing, but i think we go in the wrong way.
--
Nemanov Oleg
^ permalink raw reply
* RE: [PATCH] hyperv: else branch not necessary
From: KY Srinivasan @ 2015-01-25 18:10 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: devel@linuxdriverproject.org, Haiyang Zhang,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
In-Reply-To: <1422175610-1924-1-git-send-email-der.herr@hofr.at>
> -----Original Message-----
> From: Nicholas Mc Guire [mailto:der.herr@hofr.at]
> Sent: Sunday, January 25, 2015 12:47 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; devel@linuxdriverproject.org; netdev@vger.kernel.org;
> linux-kernel@vger.kernel.org; Nicholas Mc Guire
> Subject: [PATCH] hyperv: else branch not necessary
Make the subject line clear as to what subsystem this patch is for.
K. Y
>
> As the if completes with a unconditional goto the else branch is not needed
> here.
>
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> ---
>
> All paths of execution that did not exit through the if branch will go through
> the else branch so no need for an explicit else here
>
> Patch was compile tested only for x86_64_defconfig + CONFIG_X86_VSMP=y
> CONFIG_HYPERV=m, CONFIG_HYPERV_NET=m
>
> Patch is against 3.19.0-rc5 -next-20150123
>
> drivers/net/hyperv/rndis_filter.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/hyperv/rndis_filter.c
> b/drivers/net/hyperv/rndis_filter.c
> index 7bd8387..efb84a9 100644
> --- a/drivers/net/hyperv/rndis_filter.c
> +++ b/drivers/net/hyperv/rndis_filter.c
> @@ -833,10 +833,10 @@ int rndis_filter_set_packet_filter(struct
> rndis_device *dev, u32 new_filter)
> * send completion for it.
> */
> goto exit;
> - } else {
> - set_complete = &request-
> >response_msg.msg.set_complete;
> - status = set_complete->status;
> - }
> + }
> +
> + set_complete = &request->response_msg.msg.set_complete;
> + status = set_complete->status;
>
> cleanup:
> if (request)
> --
> 1.7.10.4
^ permalink raw reply
* [PATCH v2] net: hyperv: else branch not necessary
From: Nicholas Mc Guire @ 2015-01-25 18:08 UTC (permalink / raw)
To: K. Y. Srinivasan
Cc: devel, Haiyang Zhang, Nicholas Mc Guire, linux-kernel, netdev
As the if completes with a unconditional goto the else branch
is not needed here.
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
v2: added missing subsystem string in subject line - patch unchanged
All paths of execution that did not exit through the if branch will
go through the else branch so no need for an explicit else here
Patch was compile tested only for x86_64_defconfig + CONFIG_X86_VSMP=y
CONFIG_HYPERV=m, CONFIG_HYPERV_NET=m
Patch is against 3.19.0-rc5 -next-20150123
drivers/net/hyperv/rndis_filter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 7bd8387..efb84a9 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -833,10 +833,10 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
* send completion for it.
*/
goto exit;
- } else {
- set_complete = &request->response_msg.msg.set_complete;
- status = set_complete->status;
- }
+ }
+
+ set_complete = &request->response_msg.msg.set_complete;
+ status = set_complete->status;
cleanup:
if (request)
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] net:wireless:Add proper locking for the function, b43_op_beacon_set_tim in main.c
From: Larry Finger @ 2015-01-25 16:51 UTC (permalink / raw)
To: Nicholas Krause; +Cc: netdev, linux-wireless, b43-dev, kvalo, linux-kernel
In-Reply-To: <1422169574-8451-1-git-send-email-xerofoify@gmail.com>
On 01/25/2015 01:06 AM, Nicholas Krause wrote:
> Adds proper locking for the function, b43_op_beacon_set_tim in main.c that internally calls b43_update_templates.
> Due to the function that is being called internally,b43_update_templates needing the mutex lock of the structure
> pointer wl passed it to run successfully and without issues we add the calls to mutex_lock before and mutex_unlock
> after it's call internally in b43_op_beacon_set_tim in order to allow the function,,b43_update_templates to run
> successfully and without issues related to concurrent access.
>
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> drivers/net/wireless/b43/main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
> index 47731cb..b807958 100644
> --- a/drivers/net/wireless/b43/main.c
> +++ b/drivers/net/wireless/b43/main.c
> @@ -5094,8 +5094,9 @@ static int b43_op_beacon_set_tim(struct ieee80211_hw *hw,
> {
> struct b43_wl *wl = hw_to_b43_wl(hw);
>
> - /* FIXME: add locking */
> + mutex_lock(&wl->mutex);
> b43_update_templates(wl);
> + mutex_unlock(&wl->mutex);
>
> return 0;
> }
Nicolas,
You must be an idiot for resubmitting this patch after Michael Busch clearly
told you that this patch can *never* work as we are in atomic context here! If
you are looking for patch credits, submitting one that messes with locking *that
you have never tested* will certainly get you notoriety on the Internet, but I
doubt that you want that bad a reputation!!
NACK.
Larry
^ permalink raw reply
* Re: [PATCH v3 net-next] net: ipv6: Add sysctl entry to disable MTU updates from RA
From: Harout Hedeshian @ 2015-01-25 16:28 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Vadim Kochan
In-Reply-To: <20150125072101.GA25495@angus-think.lan>
On 01/25/2015 12:21 AM, Vadim Kochan wrote:
> On Sat, Jan 24, 2015 at 11:14:32PM -0800, David Miller wrote:
>> From: Harout Hedeshian <harouth@codeaurora.org>
>> Date: Tue, 20 Jan 2015 10:06:05 -0700
>>
>>> The kernel forcefully applies MTU values received in router
>>> advertisements provided the new MTU is less than the current. This
>>> behavior is undesirable when the user space is managing the MTU.
> Instead
>>> a sysctl flag 'accept_ra_mtu' is introduced such that the user space
>>> can control whether or not RA provided MTU updates should be applied.
> The
>>> default behavior is unchanged; user space must explicitly set this
> flag
>>> to 0 for RA MTUs to be ignored.
>>>
>>> Signed-off-by: Harout Hedeshian <harouth@codeaurora.org>
>> Under what circumstances would userland ignore a router advertized
>> MTU, and are the RFCs ok with this?
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Hi,
>
> I don't know if it make sense but I had the same use case when was
> working on supporting IPv6 infrastructure for home gateway.
> One of the provider had requirements to have ability set force IPv6 MTU
> value via TR parameters and disable update it via RA.
Hi David,
We are optionally allowing the kernel shift this responsibility to the
userland. The idea would be that the kernel would ignore it, not so much
the userland. Just like Vadim, we may not want to use the MTU value
which comes from the network. Instead, we get an MTU value from the
cellular modem via configuration message, and that is the MTU we use.
In any case, none of the RFCs state that the kernel must update the MTU
and that the userland cannot. In fact, there is no mention of
kernel/user space at all in the RFC for this particular RA message. What
if someone wants to listen to these RA messages from userland and update
the MTU? Surely, that won't violate the RFC. In such a case, the kernel
is unnecessarily forcing policy on the user space.
RFC4861 section 4.6.4 defines the MTU update option (RA option 5) for RA
messages. I don't see any language where the receiver "MUST" apply this
option. It merely states that the MTU value in the RA is "The
recommended MTU for the link." The description goes on to point out why
this option can be used by the router, but does not specifically enforce
it. The only receive action specifically enforced by the RFC is that
"This option MUST be silently ignored for other Neighbor Discovery
messages."
The risk of not applying the MTU updates is that packet may get dropped
if path MTU discovery is disabled or broken on the network. HOWEVER,
anyone explicitly setting accept_ra_mtu to 0 is already taking
responsibility for enforcing the correct MTU. Since this patch by
default does not change the kernel behavior, I don't see it breaking for
users who are unaware of this option.
Thanks,
Harout
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
^ permalink raw reply
* Re: [PATCH 3/3] net: allwinner: sun4i-emac: fix emac SRAM mapping
From: Maxime Ripard @ 2015-01-25 16:25 UTC (permalink / raw)
To: Jens Kuske, Arnd Bergmann
Cc: Lee Jones, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Chen-Yu Tsai,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
In-Reply-To: <1422200959-1717-4-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2826 bytes --]
Hi Jens,
On Sun, Jan 25, 2015 at 04:49:19PM +0100, Jens Kuske wrote:
> The EMAC needs SRAM block A3_A4 being mapped to EMAC peripheral to
> work. This is done by the bootloader most of the time, but U-Boot
> Falcon Mode, for example, skips emac initialization and SRAM would
> stay mapped to the CPU.
Thanks for reviving this.
> Signed-off-by: Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/net/ethernet/allwinner/Kconfig | 1 +
> drivers/net/ethernet/allwinner/sun4i-emac.c | 18 ++++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/drivers/net/ethernet/allwinner/Kconfig b/drivers/net/ethernet/allwinner/Kconfig
> index d8d95d4..508a288 100644
> --- a/drivers/net/ethernet/allwinner/Kconfig
> +++ b/drivers/net/ethernet/allwinner/Kconfig
> @@ -28,6 +28,7 @@ config SUN4I_EMAC
> select MII
> select PHYLIB
> select MDIO_SUN4I
> + select MFD_SYSCON
> ---help---
> Support for Allwinner A10 EMAC ethernet driver.
>
> diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> index 1fcd556..86c891d 100644
> --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
> @@ -18,6 +18,8 @@
> #include <linux/gpio.h>
> #include <linux/interrupt.h>
> #include <linux/irq.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mfd/syscon/sun4i-sc.h>
> #include <linux/mii.h>
> #include <linux/module.h>
> #include <linux/netdevice.h>
> @@ -28,6 +30,7 @@
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> #include <linux/phy.h>
> +#include <linux/regmap.h>
>
> #include "sun4i-emac.h"
>
> @@ -78,6 +81,7 @@ struct emac_board_info {
>
> struct phy_device *phy_dev;
> struct device_node *phy_node;
> + struct regmap *sc;
> unsigned int link;
> unsigned int speed;
> unsigned int duplex;
> @@ -862,6 +866,18 @@ static int emac_probe(struct platform_device *pdev)
> goto out;
> }
>
> + /* Map SRAM_A3_A4 to EMAC */
> + db->sc = syscon_regmap_lookup_by_compatible(
> + "allwinner,sun4i-a10-syscon");
> + if (IS_ERR(db->sc)) {
> + dev_err(&pdev->dev, "failed to find syscon regmap\n");
> + ret = PTR_ERR(db->sc);
> + goto out;
> + }
> +
> + regmap_update_bits(db->sc, SUN4I_SC1, SUN4I_SC1_SRAM_A3_A4_MAP_MASK,
> + SUN4I_SC1_SRAM_A3_A4_MAP_EMAC);
> +
I don't think that using a syscon is the right solution here.
All this SRAM mapping thing is mutually exclusive, and will possibly
impact other drivers as well.
I think this is a more a case for a small driver in drivers/soc that
would take care of this, and make sure that client drivers don't step
on each other's toe.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH net v2] bnx2x: fix napi poll return value for repoll
From: Eric Dumazet @ 2015-01-25 16:05 UTC (permalink / raw)
To: Govindarajulu Varadarajan; +Cc: davem, netdev, ariel.elior, edumazet
In-Reply-To: <1422182363-10932-1-git-send-email-_govind@gmx.com>
On Sun, 2015-01-25 at 16:09 +0530, Govindarajulu Varadarajan wrote:
> With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi
> repoll is done only when work_done == budget. When in busy_poll is we return 0
> in napi_poll. We should return budget.
>
> Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
> ---
> v2:
> Remove unnecessary change for work_done >= budget return value.
>
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 1d1147c..e468ed3 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -3175,7 +3175,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
> }
> #endif
> if (!bnx2x_fp_lock_napi(fp))
> - return work_done;
> + return budget;
>
> for_each_cos_in_tx_queue(fp, cos)
> if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
Thanks !
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply
* [PATCH 3/3] net: allwinner: sun4i-emac: fix emac SRAM mapping
From: Jens Kuske @ 2015-01-25 15:49 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, netdev-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Chen-Yu Tsai,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Jens Kuske
In-Reply-To: <1422200959-1717-1-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
The EMAC needs SRAM block A3_A4 being mapped to EMAC peripheral to
work. This is done by the bootloader most of the time, but U-Boot
Falcon Mode, for example, skips emac initialization and SRAM would
stay mapped to the CPU.
Signed-off-by: Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/net/ethernet/allwinner/Kconfig | 1 +
drivers/net/ethernet/allwinner/sun4i-emac.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/net/ethernet/allwinner/Kconfig b/drivers/net/ethernet/allwinner/Kconfig
index d8d95d4..508a288 100644
--- a/drivers/net/ethernet/allwinner/Kconfig
+++ b/drivers/net/ethernet/allwinner/Kconfig
@@ -28,6 +28,7 @@ config SUN4I_EMAC
select MII
select PHYLIB
select MDIO_SUN4I
+ select MFD_SYSCON
---help---
Support for Allwinner A10 EMAC ethernet driver.
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 1fcd556..86c891d 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -18,6 +18,8 @@
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/sun4i-sc.h>
#include <linux/mii.h>
#include <linux/module.h>
#include <linux/netdevice.h>
@@ -28,6 +30,7 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/phy.h>
+#include <linux/regmap.h>
#include "sun4i-emac.h"
@@ -78,6 +81,7 @@ struct emac_board_info {
struct phy_device *phy_dev;
struct device_node *phy_node;
+ struct regmap *sc;
unsigned int link;
unsigned int speed;
unsigned int duplex;
@@ -862,6 +866,18 @@ static int emac_probe(struct platform_device *pdev)
goto out;
}
+ /* Map SRAM_A3_A4 to EMAC */
+ db->sc = syscon_regmap_lookup_by_compatible(
+ "allwinner,sun4i-a10-syscon");
+ if (IS_ERR(db->sc)) {
+ dev_err(&pdev->dev, "failed to find syscon regmap\n");
+ ret = PTR_ERR(db->sc);
+ goto out;
+ }
+
+ regmap_update_bits(db->sc, SUN4I_SC1, SUN4I_SC1_SRAM_A3_A4_MAP_MASK,
+ SUN4I_SC1_SRAM_A3_A4_MAP_EMAC);
+
/* Read MAC-address from DT */
mac_addr = of_get_mac_address(np);
if (mac_addr)
@@ -910,7 +926,9 @@ out:
static int emac_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
+ struct emac_board_info *db = netdev_priv(ndev);
+ regmap_update_bits(db->sc, SUN4I_SC1, SUN4I_SC1_SRAM_A3_A4_MAP_MASK, 0);
unregister_netdev(ndev);
free_netdev(ndev);
--
2.2.2
^ permalink raw reply related
* [PATCH 2/3] ARM: sunxi: Add register bit definitions for SRAM mapping syscon
From: Jens Kuske @ 2015-01-25 15:49 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, netdev-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Chen-Yu Tsai,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Jens Kuske
In-Reply-To: <1422200959-1717-1-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Signed-off-by: Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/linux/mfd/syscon/sun4i-sc.h | 42 +++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 include/linux/mfd/syscon/sun4i-sc.h
diff --git a/include/linux/mfd/syscon/sun4i-sc.h b/include/linux/mfd/syscon/sun4i-sc.h
new file mode 100644
index 0000000..fb970d9
--- /dev/null
+++ b/include/linux/mfd/syscon/sun4i-sc.h
@@ -0,0 +1,42 @@
+/**
+ * sun4i-sc.h - Allwinner sun4i system control register bit definitions
+ *
+ * Copyright (C) 2014 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __LINUX_SUN4I_SC_H
+#define __LINUX_SUN4I_SC_H
+
+#include <linux/bitops.h>
+
+/* Registers */
+#define SUN4I_SC0 0x00
+#define SUN4I_SC1 0x04
+
+/* SRAM control register 0 bits */
+#define SUN4I_SC0_SRAM_C1_MAP_VE 0x7fffffff
+
+/* SRAM control register 1 bits */
+#define SUN4I_SC1_BIST_NDMA_CTRL_SEL BIT(31)
+#define SUN4I_SC1_SRAM_C3_MAP_ISP BIT(12)
+#define SUN4I_SC1_SRAM_C2_MAP_MASK 0x0300
+#define SUN4I_SC1_SRAM_C2_MAP_AE 0x0100
+#define SUN4I_SC1_SRAM_C2_MAP_CE 0x0200
+#define SUN4I_SC1_SRAM_C2_MAP_ACE 0x0300
+#define SUN4I_SC1_SRAM_A3_A4_MAP_MASK 0x0030
+#define SUN4I_SC1_SRAM_A3_A4_MAP_EMAC 0x0010
+#define SUN4I_SC1_SRAM_D_MAP_USB0 BIT(0)
+
+#endif /* __LINUX_SUN4I_SC_H */
--
2.2.2
^ permalink raw reply related
* [PATCH 1/3] ARM: dts: sunxi: Add syscon node for controlling SRAM mapping
From: Jens Kuske @ 2015-01-25 15:49 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, netdev-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Chen-Yu Tsai,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Jens Kuske
In-Reply-To: <1422200959-1717-1-git-send-email-jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Allwinner SoCs have a system controller module that controls whether
SRAM blocks are mapped to the CPU memory or specific peripherals.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
[jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org: duplicate syscon node to sun4i and sun5i]
Signed-off-by: Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/arm/boot/dts/sun4i-a10.dtsi | 5 +++++
arch/arm/boot/dts/sun5i-a10s.dtsi | 5 +++++
arch/arm/boot/dts/sun5i-a13.dtsi | 5 +++++
arch/arm/boot/dts/sun7i-a20.dtsi | 5 +++++
4 files changed, 20 insertions(+)
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 380f914..8a90e48 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -339,6 +339,11 @@
#size-cells = <1>;
ranges;
+ syscon: syscon@01c00000 {
+ compatible = "allwinner,sun4i-a10-syscon", "syscon";
+ reg = <0x01c00000 0x8>;
+ };
+
dma: dma-controller@01c02000 {
compatible = "allwinner,sun4i-a10-dma";
reg = <0x01c02000 0x1000>;
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 531272c..21df7b4 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -300,6 +300,11 @@
#size-cells = <1>;
ranges;
+ syscon: syscon@01c00000 {
+ compatible = "allwinner,sun4i-a10-syscon", "syscon";
+ reg = <0x01c00000 0x8>;
+ };
+
dma: dma-controller@01c02000 {
compatible = "allwinner,sun4i-a10-dma";
reg = <0x01c02000 0x1000>;
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index b131068..b69b7b1 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -298,6 +298,11 @@
#size-cells = <1>;
ranges;
+ syscon: syscon@01c00000 {
+ compatible = "allwinner,sun4i-a10-syscon", "syscon";
+ reg = <0x01c00000 0x8>;
+ };
+
dma: dma-controller@01c02000 {
compatible = "allwinner,sun4i-a10-dma";
reg = <0x01c02000 0x1000>;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 82097c9..af9c7e6 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -451,6 +451,11 @@
#size-cells = <1>;
ranges;
+ syscon: syscon@01c00000 {
+ compatible = "allwinner,sun4i-a10-syscon", "syscon";
+ reg = <0x01c00000 0x8>;
+ };
+
nmi_intc: interrupt-controller@01c00030 {
compatible = "allwinner,sun7i-a20-sc-nmi";
interrupt-controller;
--
2.2.2
^ permalink raw reply related
* [PATCH 0/3] net: allwinner: sun4i-emac: add missing SRAM mapping
From: Jens Kuske @ 2015-01-25 15:49 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, netdev-u79uwXL29TY76Z2rM5mHXA
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Chen-Yu Tsai,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Jens Kuske
Hi all,
The current sun4i-emac kernel driver does not set the needed SRAM mapping.
This hasn't been noticed because normally the bootloader already did this.
But in case the bootloader skips initializing the EMAC, like in U-Boot's
Falcon Mode for example, the kernel driver has to take care of it.
Patch 1-2 add a mfd/syscon for the shared registers responsible for SRAM
mapping. These patches are taken from Chen-Yu Tsai's sunxi-musb tree [1] and
I added a copy of the device-tree nodes to sun4i and sun5i.
Patch 3 adds the code to map SRAM to EMAC using the syscon.
Regards,
Jens
[1] https://github.com/wens/linux/commits/wip/sunxi-musb
Chen-Yu Tsai (2):
ARM: dts: sunxi: Add syscon node for controlling SRAM mapping
ARM: sunxi: Add register bit definitions for SRAM mapping syscon
Jens Kuske (1):
net: allwinner: sun4i-emac: fix emac SRAM mapping
arch/arm/boot/dts/sun4i-a10.dtsi | 5 ++++
arch/arm/boot/dts/sun5i-a10s.dtsi | 5 ++++
arch/arm/boot/dts/sun5i-a13.dtsi | 5 ++++
arch/arm/boot/dts/sun7i-a20.dtsi | 5 ++++
drivers/net/ethernet/allwinner/Kconfig | 1 +
drivers/net/ethernet/allwinner/sun4i-emac.c | 18 +++++++++++++
include/linux/mfd/syscon/sun4i-sc.h | 42 +++++++++++++++++++++++++++++
7 files changed, 81 insertions(+)
create mode 100644 include/linux/mfd/syscon/sun4i-sc.h
--
2.2.2
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox