* [next-next PATCH 6/7] fib_trie: Move fib_find_alias to file where it is used
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
The function fib_find_alias is only accessed by functions in fib_trie.c as
such it makes sense to relocate it and cast it as static so that the
compiler can take advantage of optimizations it can do to it as a local
function.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/fib_lookup.h | 1 -
net/ipv4/fib_semantics.c | 18 ------------------
net/ipv4/fib_trie.c | 20 ++++++++++++++++++++
3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h
index 1e4f660..825981b 100644
--- a/net/ipv4/fib_lookup.h
+++ b/net/ipv4/fib_lookup.h
@@ -32,7 +32,6 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, u32 tb_id,
unsigned int);
void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, int dst_len,
u32 tb_id, const struct nl_info *info, unsigned int nlm_flags);
-struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio);
static inline void fib_result_assign(struct fib_result *res,
struct fib_info *fi)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 265cb72..1e2090e 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -411,24 +411,6 @@ errout:
rtnl_set_sk_err(info->nl_net, RTNLGRP_IPV4_ROUTE, err);
}
-/* Return the first fib alias matching TOS with
- * priority less than or equal to PRIO.
- */
-struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
-{
- if (fah) {
- struct fib_alias *fa;
- list_for_each_entry(fa, fah, fa_list) {
- if (fa->fa_tos > tos)
- continue;
- if (fa->fa_info->fib_priority >= prio ||
- fa->fa_tos < tos)
- return fa;
- }
- }
- return NULL;
-}
-
static int fib_detect_death(struct fib_info *fi, int order,
struct fib_info **last_resort, int *last_idx,
int dflt)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 90654bb..7f34226 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -998,6 +998,26 @@ static struct tnode *fib_find_node(struct trie *t, u32 key)
return n;
}
+/* Return the first fib alias matching TOS with
+ * priority less than or equal to PRIO.
+ */
+static struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
+{
+ struct fib_alias *fa;
+
+ if (!fah)
+ return NULL;
+
+ list_for_each_entry(fa, fah, fa_list) {
+ if (fa->fa_tos > tos)
+ continue;
+ if (fa->fa_info->fib_priority >= prio || fa->fa_tos < tos)
+ return fa;
+ }
+
+ return NULL;
+}
+
static void trie_rebalance(struct trie *t, struct tnode *tn)
{
struct tnode *tp;
^ permalink raw reply related
* [next-next PATCH 5/7] fib_trie: Use empty_children instead of counting empty nodes in stats collection
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
It doesn't make much sense to count the pointers ourselves when
empty_children already has a count for the number of NULL pointers stored
in the tnode. As such save ourselves the cycles and just use
empty_children.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/fib_trie.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f874e18..90654bb 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1954,16 +1954,10 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
hlist_for_each_entry_rcu(li, &n->list, hlist)
++s->prefixes;
} else {
- unsigned long i;
-
s->tnodes++;
if (n->bits < MAX_STAT_DEPTH)
s->nodesizes[n->bits]++;
-
- for (i = tnode_child_length(n); i--;) {
- if (!rcu_access_pointer(n->child[i]))
- s->nullpointers++;
- }
+ s->nullpointers += n->empty_children;
}
}
rcu_read_unlock();
^ permalink raw reply related
* [next-next PATCH 4/7] fib_trie: Add collapse() and should_collapse() to resize
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
This patch really does two things.
First it pulls the logic for determining if we should collapse one node out
of the tree and the actual code doing the collapse into a separate pair of
functions. This helps to make the changes to these areas more readable.
Second it encodes the upper 32b of the empty_children value onto the
full_children value in the case of bits == KEYLENGTH. By doing this we are
able to handle the case of a 32b node where empty_children would appear to
be 0 when it was actually 1ul << 32.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/fib_trie.c | 100 +++++++++++++++++++++++++++++++++------------------
1 file changed, 65 insertions(+), 35 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 80892f5..f874e18 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -83,7 +83,8 @@
#define MAX_STAT_DEPTH 32
-#define KEYLENGTH (8*sizeof(t_key))
+#define KEYLENGTH (8*sizeof(t_key))
+#define KEY_MAX ((t_key)~0)
typedef unsigned int t_key;
@@ -102,8 +103,8 @@ struct tnode {
union {
/* The fields in this struct are valid if bits > 0 (TNODE) */
struct {
- unsigned int full_children; /* KEYLENGTH bits needed */
- unsigned int empty_children; /* KEYLENGTH bits needed */
+ t_key empty_children; /* KEYLENGTH bits needed */
+ t_key full_children; /* KEYLENGTH bits needed */
struct tnode __rcu *child[0];
};
/* This list pointer if valid if bits == 0 (LEAF) */
@@ -302,6 +303,16 @@ static struct tnode *tnode_alloc(size_t size)
return vzalloc(size);
}
+static inline void empty_child_inc(struct tnode *n)
+{
+ ++n->empty_children ? : ++n->full_children;
+}
+
+static inline void empty_child_dec(struct tnode *n)
+{
+ n->empty_children-- ? : n->full_children--;
+}
+
static struct tnode *leaf_new(t_key key)
{
struct tnode *l = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL);
@@ -335,7 +346,7 @@ static struct leaf_info *leaf_info_new(int plen)
static struct tnode *tnode_new(t_key key, int pos, int bits)
{
- size_t sz = offsetof(struct tnode, child[1 << bits]);
+ size_t sz = offsetof(struct tnode, child[1ul << bits]);
struct tnode *tn = tnode_alloc(sz);
unsigned int shift = pos + bits;
@@ -348,8 +359,10 @@ static struct tnode *tnode_new(t_key key, int pos, int bits)
tn->pos = pos;
tn->bits = bits;
tn->key = (shift < KEYLENGTH) ? (key >> shift) << shift : 0;
- tn->full_children = 0;
- tn->empty_children = 1<<bits;
+ if (bits == KEYLENGTH)
+ tn->full_children = 1;
+ else
+ tn->empty_children = 1ul << bits;
}
pr_debug("AT %p s=%zu %zu\n", tn, sizeof(struct tnode),
@@ -375,11 +388,11 @@ static void put_child(struct tnode *tn, unsigned long i, struct tnode *n)
BUG_ON(i >= tnode_child_length(tn));
- /* update emptyChildren */
+ /* update emptyChildren, overflow into fullChildren */
if (n == NULL && chi != NULL)
- tn->empty_children++;
- else if (n != NULL && chi == NULL)
- tn->empty_children--;
+ empty_child_inc(tn);
+ if (n != NULL && chi == NULL)
+ empty_child_dec(tn);
/* update fullChildren */
wasfull = tnode_full(tn, chi);
@@ -630,6 +643,24 @@ static int halve(struct trie *t, struct tnode *oldtnode)
return 0;
}
+static void collapse(struct trie *t, struct tnode *oldtnode)
+{
+ struct tnode *n, *tp;
+ unsigned long i;
+
+ /* scan the tnode looking for that one child that might still exist */
+ for (n = NULL, i = tnode_child_length(oldtnode); !n && i;)
+ n = tnode_get_child(oldtnode, --i);
+
+ /* compress one level */
+ tp = node_parent(oldtnode);
+ put_child_root(tp, t, oldtnode->key, n);
+ node_set_parent(n, tp);
+
+ /* drop dead node */
+ node_free(oldtnode);
+}
+
static unsigned char update_suffix(struct tnode *tn)
{
unsigned char slen = tn->pos;
@@ -729,10 +760,12 @@ static bool should_inflate(const struct tnode *tp, const struct tnode *tn)
/* Keep root node larger */
threshold *= tp ? inflate_threshold : inflate_threshold_root;
- used += tn->full_children;
used -= tn->empty_children;
+ used += tn->full_children;
- return tn->pos && ((50 * used) >= threshold);
+ /* if bits == KEYLENGTH then pos = 0, and will fail below */
+
+ return (used > 1) && tn->pos && ((50 * used) >= threshold);
}
static bool should_halve(const struct tnode *tp, const struct tnode *tn)
@@ -744,13 +777,29 @@ static bool should_halve(const struct tnode *tp, const struct tnode *tn)
threshold *= tp ? halve_threshold : halve_threshold_root;
used -= tn->empty_children;
- return (tn->bits > 1) && ((100 * used) < threshold);
+ /* if bits == KEYLENGTH then used = 100% on wrap, and will fail below */
+
+ return (used > 1) && (tn->bits > 1) && ((100 * used) < threshold);
+}
+
+static bool should_collapse(const struct tnode *tn)
+{
+ unsigned long used = tnode_child_length(tn);
+
+ used -= tn->empty_children;
+
+ /* account for bits == KEYLENGTH case */
+ if ((tn->bits == KEYLENGTH) && tn->full_children)
+ used -= KEY_MAX;
+
+ /* One child or none, time to drop us from the trie */
+ return used < 2;
}
#define MAX_WORK 10
static void resize(struct trie *t, struct tnode *tn)
{
- struct tnode *tp = node_parent(tn), *n = NULL;
+ struct tnode *tp = node_parent(tn);
struct tnode __rcu **cptr;
int max_work = MAX_WORK;
@@ -764,14 +813,6 @@ static void resize(struct trie *t, struct tnode *tn)
cptr = tp ? &tp->child[get_index(tn->key, tp)] : &t->trie;
BUG_ON(tn != rtnl_dereference(*cptr));
- /* No children */
- if (tn->empty_children > (tnode_child_length(tn) - 1))
- goto no_children;
-
- /* One child */
- if (tn->empty_children == (tnode_child_length(tn) - 1))
- goto one_child;
-
/* Double as long as the resulting node has a number of
* nonempty nodes that are above the threshold.
*/
@@ -807,19 +848,8 @@ static void resize(struct trie *t, struct tnode *tn)
}
/* Only one child remains */
- if (tn->empty_children == (tnode_child_length(tn) - 1)) {
- unsigned long i;
-one_child:
- for (i = tnode_child_length(tn); !n && i;)
- n = tnode_get_child(tn, --i);
-no_children:
- /* compress one level */
- put_child_root(tp, t, tn->key, n);
- node_set_parent(n, tp);
-
- /* drop dead node */
- tnode_free_init(tn);
- tnode_free(tn);
+ if (should_collapse(tn)) {
+ collapse(t, tn);
return;
}
^ permalink raw reply related
* [next-next PATCH 3/7] fib_trie: Fall back to slen update on inflate/halve failure
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
This change corrects an issue where if inflate or halve fails we were
exiting the resize function without at least updating the slen for the
node. To correct this I have moved the update of max_size into the while
loop so that it is only decremented on a successful call to either inflate
or halve.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/fib_trie.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 7e90317..80892f5 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -752,7 +752,7 @@ static void resize(struct trie *t, struct tnode *tn)
{
struct tnode *tp = node_parent(tn), *n = NULL;
struct tnode __rcu **cptr;
- int max_work;
+ int max_work = MAX_WORK;
pr_debug("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
tn, inflate_threshold, halve_threshold);
@@ -775,8 +775,7 @@ static void resize(struct trie *t, struct tnode *tn)
/* Double as long as the resulting node has a number of
* nonempty nodes that are above the threshold.
*/
- max_work = MAX_WORK;
- while (should_inflate(tp, tn) && max_work--) {
+ while (should_inflate(tp, tn) && max_work) {
if (inflate(t, tn)) {
#ifdef CONFIG_IP_FIB_TRIE_STATS
this_cpu_inc(t->stats->resize_node_skipped);
@@ -784,6 +783,7 @@ static void resize(struct trie *t, struct tnode *tn)
break;
}
+ max_work--;
tn = rtnl_dereference(*cptr);
}
@@ -794,8 +794,7 @@ static void resize(struct trie *t, struct tnode *tn)
/* Halve as long as the number of empty children in this
* node is above threshold.
*/
- max_work = MAX_WORK;
- while (should_halve(tp, tn) && max_work--) {
+ while (should_halve(tp, tn) && max_work) {
if (halve(t, tn)) {
#ifdef CONFIG_IP_FIB_TRIE_STATS
this_cpu_inc(t->stats->resize_node_skipped);
@@ -803,6 +802,7 @@ static void resize(struct trie *t, struct tnode *tn)
break;
}
+ max_work--;
tn = rtnl_dereference(*cptr);
}
^ permalink raw reply related
* [next-next PATCH 2/7] fib_trie: Fix RCU bug and merge similar bits of inflate/halve
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
This patch addresses two issues.
The first issue is the fact that I believe I had the RCU freeing sequence
slightly out of order. As a result we could get into an issue if a caller
went into a child of a child of the new node, then backtraced into the to be
freed parent, and then attempted to access a child of a child that may have
been consumed in a resize of one of the new nodes children. To resolve this I
have moved the resize after we have freed the oldtnode. The only side effect
of this is that we will now be calling resize on more nodes in the case of
inflate due to the fact that we don't have a good way to test to see if a
full_tnode on the new node was there before or after the allocation. This
should have minimal impact however since the node should already be
correctly size so it is just the cost of calling should_inflate that we
will be taking on the node which is only a couple of cycles.
The second issue is the fact that inflate and halve were essentially doing
the same thing after the new node was added to the trie replacing the old
one. As such it wasn't really necessary to keep the code in both functions
so I have split it out into two other functions, called replace and
update_children.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/fib_trie.c | 157 ++++++++++++++++++++++++---------------------------
1 file changed, 73 insertions(+), 84 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index dea2f80..7e90317 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -396,8 +396,30 @@ static void put_child(struct tnode *tn, unsigned long i, struct tnode *n)
rcu_assign_pointer(tn->child[i], n);
}
-static void put_child_root(struct tnode *tp, struct trie *t,
- t_key key, struct tnode *n)
+static void update_children(struct tnode *tn)
+{
+ unsigned long i;
+
+ /* update all of the child parent pointers */
+ for (i = tnode_child_length(tn); i;) {
+ struct tnode *inode = tnode_get_child(tn, --i);
+
+ if (!inode)
+ continue;
+
+ /* Either update the children of a tnode that
+ * already belongs to us or update the child
+ * to point to ourselves.
+ */
+ if (node_parent(inode) == tn)
+ update_children(inode);
+ else
+ node_set_parent(inode, tn);
+ }
+}
+
+static inline void put_child_root(struct tnode *tp, struct trie *t,
+ t_key key, struct tnode *n)
{
if (tp)
put_child(tp, get_index(key, tp), n);
@@ -434,10 +456,35 @@ static void tnode_free(struct tnode *tn)
}
}
+static void replace(struct trie *t, struct tnode *oldtnode, struct tnode *tn)
+{
+ struct tnode *tp = node_parent(oldtnode);
+ unsigned long i;
+
+ /* setup the parent pointer out of and back into this node */
+ NODE_INIT_PARENT(tn, tp);
+ put_child_root(tp, t, tn->key, tn);
+
+ /* update all of the child parent pointers */
+ update_children(tn);
+
+ /* all pointers should be clean so we are done */
+ tnode_free(oldtnode);
+
+ /* resize children now that oldtnode is freed */
+ for (i = tnode_child_length(tn); i;) {
+ struct tnode *inode = tnode_get_child(tn, --i);
+
+ /* resize child node */
+ if (tnode_full(tn, inode))
+ resize(t, inode);
+ }
+}
+
static int inflate(struct trie *t, struct tnode *oldtnode)
{
- struct tnode *inode, *node0, *node1, *tn, *tp;
- unsigned long i, j, k;
+ struct tnode *tn;
+ unsigned long i;
t_key m;
pr_debug("In inflate\n");
@@ -446,13 +493,18 @@ static int inflate(struct trie *t, struct tnode *oldtnode)
if (!tn)
return -ENOMEM;
+ /* prepare oldtnode to be freed */
+ tnode_free_init(oldtnode);
+
/* Assemble all of the pointers in our cluster, in this case that
* represents all of the pointers out of our allocated nodes that
* point to existing tnodes and the links between our allocated
* nodes.
*/
for (i = tnode_child_length(oldtnode), m = 1u << tn->pos; i;) {
- inode = tnode_get_child(oldtnode, --i);
+ struct tnode *inode = tnode_get_child(oldtnode, --i);
+ struct tnode *node0, *node1;
+ unsigned long j, k;
/* An empty child */
if (inode == NULL)
@@ -464,6 +516,9 @@ static int inflate(struct trie *t, struct tnode *oldtnode)
continue;
}
+ /* drop the node in the old tnode free list */
+ tnode_free_append(oldtnode, inode);
+
/* An internal node with two children */
if (inode->bits == 1) {
put_child(tn, 2 * i + 1, tnode_get_child(inode, 1));
@@ -488,9 +543,9 @@ static int inflate(struct trie *t, struct tnode *oldtnode)
node1 = tnode_new(inode->key | m, inode->pos, inode->bits - 1);
if (!node1)
goto nomem;
- tnode_free_append(tn, node1);
+ node0 = tnode_new(inode->key, inode->pos, inode->bits - 1);
- node0 = tnode_new(inode->key & ~m, inode->pos, inode->bits - 1);
+ tnode_free_append(tn, node1);
if (!node0)
goto nomem;
tnode_free_append(tn, node0);
@@ -512,53 +567,9 @@ static int inflate(struct trie *t, struct tnode *oldtnode)
put_child(tn, 2 * i, node0);
}
- /* setup the parent pointer into and out of this node */
- tp = node_parent(oldtnode);
- NODE_INIT_PARENT(tn, tp);
- put_child_root(tp, t, tn->key, tn);
-
- /* prepare oldtnode to be freed */
- tnode_free_init(oldtnode);
-
- /* update all child nodes parent pointers to route to us */
- for (i = tnode_child_length(oldtnode); i;) {
- inode = tnode_get_child(oldtnode, --i);
-
- /* A leaf or an internal node with skipped bits */
- if (!tnode_full(oldtnode, inode)) {
- node_set_parent(inode, tn);
- continue;
- }
-
- /* drop the node in the old tnode free list */
- tnode_free_append(oldtnode, inode);
-
- /* fetch new nodes */
- node1 = tnode_get_child(tn, 2 * i + 1);
- node0 = tnode_get_child(tn, 2 * i);
+ /* setup the parent pointers into and out of this node */
+ replace(t, oldtnode, tn);
- /* bits == 1 then node0 and node1 represent inode's children */
- if (inode->bits == 1) {
- node_set_parent(node1, tn);
- node_set_parent(node0, tn);
- continue;
- }
-
- /* update parent pointers in child node's children */
- for (k = tnode_child_length(inode), j = k / 2; j;) {
- node_set_parent(tnode_get_child(inode, --k), node1);
- node_set_parent(tnode_get_child(inode, --j), node0);
- node_set_parent(tnode_get_child(inode, --k), node1);
- node_set_parent(tnode_get_child(inode, --j), node0);
- }
-
- /* resize child nodes */
- resize(t, node1);
- resize(t, node0);
- }
-
- /* we completed without error, prepare to free old node */
- tnode_free(oldtnode);
return 0;
nomem:
/* all pointers should be clean so we are done */
@@ -568,7 +579,7 @@ nomem:
static int halve(struct trie *t, struct tnode *oldtnode)
{
- struct tnode *tn, *tp, *inode, *node0, *node1;
+ struct tnode *tn;
unsigned long i;
pr_debug("In halve\n");
@@ -577,14 +588,18 @@ static int halve(struct trie *t, struct tnode *oldtnode)
if (!tn)
return -ENOMEM;
+ /* prepare oldtnode to be freed */
+ tnode_free_init(oldtnode);
+
/* Assemble all of the pointers in our cluster, in this case that
* represents all of the pointers out of our allocated nodes that
* point to existing tnodes and the links between our allocated
* nodes.
*/
for (i = tnode_child_length(oldtnode); i;) {
- node1 = tnode_get_child(oldtnode, --i);
- node0 = tnode_get_child(oldtnode, --i);
+ struct tnode *node1 = tnode_get_child(oldtnode, --i);
+ struct tnode *node0 = tnode_get_child(oldtnode, --i);
+ struct tnode *inode;
/* At least one of the children is empty */
if (!node1 || !node0) {
@@ -609,34 +624,8 @@ static int halve(struct trie *t, struct tnode *oldtnode)
put_child(tn, i / 2, inode);
}
- /* setup the parent pointer out of and back into this node */
- tp = node_parent(oldtnode);
- NODE_INIT_PARENT(tn, tp);
- put_child_root(tp, t, tn->key, tn);
-
- /* prepare oldtnode to be freed */
- tnode_free_init(oldtnode);
-
- /* update all of the child parent pointers */
- for (i = tnode_child_length(tn); i;) {
- inode = tnode_get_child(tn, --i);
-
- /* only new tnodes will be considered "full" nodes */
- if (!tnode_full(tn, inode)) {
- node_set_parent(inode, tn);
- continue;
- }
-
- /* Two nonempty children */
- node_set_parent(tnode_get_child(inode, 1), inode);
- node_set_parent(tnode_get_child(inode, 0), inode);
-
- /* resize child node */
- resize(t, inode);
- }
-
- /* all pointers should be clean so we are done */
- tnode_free(oldtnode);
+ /* setup the parent pointers into and out of this node */
+ replace(t, oldtnode, tn);
return 0;
}
^ permalink raw reply related
* [next-next PATCH 1/7] fib_trie: Use index & (~0ul << n->bits) instead of index >> n->bits
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
In-Reply-To: <20150122234652.5779.44251.stgit@ahduyck-vm-fedora20>
In doing performance testing and analysis of the changes I recently found
that by shifting the index I had created an unnecessary dependency.
I have updated the code so that we instead shift a mask by bits and then
just test against that as that should save us about 2 CPU cycles since we
can generate the mask while the key and pos are being processed.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/fib_trie.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 281e5e0..dea2f80 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -961,12 +961,12 @@ static struct tnode *fib_find_node(struct trie *t, u32 key)
* prefix plus zeros for the bits in the cindex. The index
* is the difference between the key and this value. From
* this we can actually derive several pieces of data.
- * if !(index >> bits)
- * we know the value is cindex
- * else
+ * if (index & (~0ul << bits))
* we have a mismatch in skip bits and failed
+ * else
+ * we know the value is cindex
*/
- if (index >> n->bits)
+ if (index & (~0ul << n->bits))
return NULL;
/* we have found a leaf. Prefixes have already been compared */
@@ -1301,12 +1301,12 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
* prefix plus zeros for the "bits" in the prefix. The index
* is the difference between the key and this value. From
* this we can actually derive several pieces of data.
- * if !(index >> bits)
- * we know the value is child index
- * else
+ * if (index & (~0ul << bits))
* we have a mismatch in skip bits and failed
+ * else
+ * we know the value is cindex
*/
- if (index >> n->bits)
+ if (index & (~0ul << n->bits))
break;
/* we have found a leaf. Prefixes have already been compared */
^ permalink raw reply related
* [next-next PATCH 0/7] Fixes and improvements for recent fib_trie updates
From: Alexander Duyck @ 2015-01-22 23:51 UTC (permalink / raw)
To: netdev; +Cc: davem
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.
---
Alexander Duyck (7):
fib_trie: Use index & (~0ul << n->bits) instead of index >> n->bits
fib_trie: Fix RCU bug and merge similar bits of inflate/halve
fib_trie: Fall back to slen update on inflate/halve failure
fib_trie: Add collapse() and should_collapse() to resize
fib_trie: Use empty_children instead of counting empty nodes in stats collection
fib_trie: Move fib_find_alias to file where it is used
fib_trie: Various clean-ups for handling slen
net/ipv4/fib_lookup.h | 1
net/ipv4/fib_semantics.c | 18 --
net/ipv4/fib_trie.c | 354 ++++++++++++++++++++++++++--------------------
3 files changed, 198 insertions(+), 175 deletions(-)
--
^ permalink raw reply
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Dean Gehnert @ 2015-01-22 23:09 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Ezequiel Garcia, netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <20150122230622.GA14472@n2100.arm.linux.org.uk>
On 01/22/2015 03:06 PM, Russell King - ARM Linux wrote:
> On Thu, Jan 22, 2015 at 09:49:10PM +0000, Russell King - ARM Linux wrote:
>> On Thu, Jan 22, 2015 at 01:27:31PM -0800, Dean Gehnert wrote:
>>> Can you can try the SOCAT test on your Dove platform and see if that passes
>>> the non-cache line aligned test case? I think what the SOCAT test does is
>>> take the NFS "variable" out of the equation. My theory is that if there is a
>>> DMA corruption, then hard telling what kinds of problems will occur. It
>>> might be the payload of a file is corrupted, or if the NFS structures are
>>> corrupted, it could manifest itself as a problem in the NFS code.
>> Anyway, I'm running the test now, but I had to change the socat line to:
>>
>> # socat -b$(((1024*10)+1)) -u open:ExpectData.in TCP:192.168.1.212:4000
>>
>> The receiving end is getting:
>>
>> 4a4727232209b85badc1ca25ed4df222 -
>> 4a4727232209b85badc1ca25ed4df222 -
>> 4a4727232209b85badc1ca25ed4df222 -
>> 4a4727232209b85badc1ca25ed4df222 -
>> 4a4727232209b85badc1ca25ed4df222 -
>> ...
> It's been running for about an hour now with no sign of any problem.
>
It should show the problem in the 1st or 2nd iteration and then continue
after that... I don't think your Dove shows the problem.
^ permalink raw reply
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Dean Gehnert @ 2015-01-22 23:08 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Ezequiel Garcia, netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <20150122214910.GD26493@n2100.arm.linux.org.uk>
On 01/22/2015 01:49 PM, Russell King - ARM Linux wrote:
> On Thu, Jan 22, 2015 at 01:27:31PM -0800, Dean Gehnert wrote:
>> On 01/22/2015 01:09 PM, Russell King - ARM Linux wrote:
>>> On Thu, Jan 22, 2015 at 10:41:00AM -0800, Dean Gehnert wrote:
>>>> FYI, I found a way to reproduce the mv643xx_eth transmit corruption without
>>>> using a network filesystem by using SOCAT (should also be able to use NETCAT
>>>> or NC) and I have a bit more information about the corruption that looks
>>>> like it is somehow related to the cache line size.
>>> That's not quite what I'm seeing. What I'm seeing with NFS is that the
>>> machine is basically unusable. I have the etna_viv source in a NFS
>>> share (it's shared amongst not only the Dove box but also my collection
>>> of iMX6 based hardware.)
>>>
>>> I'm fairly fully IPv6 enabled here, which includes NFS.
>>>
>>> On the Dove, if I try to build this without any fixes, and then try to
>>> build the etna_viv sources, it will take the machine out to the extent
>>> that I have to reboot it - either the machine will freeze solidly, or
>>> the kernel will oops in the DMA API functions, in a path which was
>>> called from an interrupt handler. That takes out the entire machine
>>> because we miss acknowleding the interrupt.
>> I am wondering if there is a possibility of the root cause of this being in
>> the arch DMA layer... From my testing with SOCAT and different cache line
>> alignments, I am seeing Ethernet 4 byte transmit corruptions. My fear is
>> this may not be restricted to the Ethernet transmit and maybe the root cause
>> is a DMA / cache issue... I have no way to prove that theory. Your DMA API
>> oops is a bit concerning that maybe there is some corruption going on during
>> DMA operation.
> We're careful in the arch code to do the best we can in all cases; that's
> not to say that drivers aren't buggy (in that, they don't respect the DMA
> API rules) but what I can say is that the ARM arch code gets it right.
Agreed. I have not seen problems like this before on other ARM
implementations.
>
> Provided the ethernet driver maps the DMA buffer with DMA_TO_DEVICE prior
> to the transfer being initiated, transfers _from_ the Marvell platform(s)
> should be fine.
>
> Provided the ethernet driver maps the DMA buffer with DMA_FROM_DEVICE
> prior to handing it to the device, and then does not write to any cache
> line associated with that DMA buffer before the ethernet driver has
> completed, and then unmaps it with DMA_FROM_DEVICE, then again,
> everything should be fine.
>
> (The detail above "does not write to any cache line associated with
> the DMA buffer" is subtle; what it means is that if the DMA buffer is
> not aligned to a cache line, then nothing must write to the cache lines
> which overlap the buffer, otherwise data corruption will occur.)
I wonder if that is a clue for me to chase... The cache line should be
completely flushed to hardware before the DMA operation is started. The
DMA mapping routines should be making sure all the buffers associated
with the DMA operation are locked down and flushed before completing the
DMA map operation. However, if there is other code that was modifying
the DMA buffers after the lock down and before the DMA has completed and
the buffers have been un-mapped, that would be bad.
>
>> Can you can try the SOCAT test on your Dove platform and see if that passes
>> the non-cache line aligned test case? I think what the SOCAT test does is
>> take the NFS "variable" out of the equation. My theory is that if there is a
>> DMA corruption, then hard telling what kinds of problems will occur. It
>> might be the payload of a file is corrupted, or if the NFS structures are
>> corrupted, it could manifest itself as a problem in the NFS code.
> This is one of the problems of having the TCP/UDP checksums offloaded to
> the adapter - if the data is cocked up at the DMA stage, these checksums
> won't detect it.
I am going to noodle a bit for a way that I could check if the buffer
has changed between the DMA map and un-map calls... I might be able to
add some code to checksum the buffer between those calls. If the
checksum changes. that would indicate that someone is changing the buffer.
>
> Anyway, I'm running the test now, but I had to change the socat line to:
>
> # socat -b$(((1024*10)+1)) -u open:ExpectData.in TCP:192.168.1.212:4000
>
> The receiving end is getting:
>
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> ...
>
> and I'm up to over 24 of these without any problem being visible - how
> long does it take to show?
It should show up in the 1st or 2nd and all following iterations. For
smaller files it seems to work for a while, but with the 256MB file, it
stresses the system enough that is about guaranteed to occur. It looks
like the Dove is working correctly. You have TSO enabled, large buffer,
etc, so your results look good.
Refresh my memory... What version of Marvell Armada is the Dove? I was
thinking the Dove was later than the Kirkwood and Armada 300 and was
maybe an early Armada 370 or ???...
>
> For reference, the features on my Dove box are:
>
> Features for eth0:
> rx-checksumming: on
> tx-checksumming: on
> tx-checksum-ipv4: on
> tx-checksum-ip-generic: off [fixed]
> tx-checksum-ipv6: off [fixed]
> tx-checksum-fcoe-crc: off [fixed]
> tx-checksum-sctp: off [fixed]
> scatter-gather: on
> tx-scatter-gather: on
> tx-scatter-gather-fraglist: off [fixed]
> tcp-segmentation-offload: on
> tx-tcp-segmentation: on
> tx-tcp-ecn-segmentation: off [fixed]
> tx-tcp6-segmentation: off [fixed]
> udp-fragmentation-offload: off [fixed]
> generic-segmentation-offload: on
> generic-receive-offload: on
> large-receive-offload: off [fixed]
> rx-vlan-offload: off [fixed]
> tx-vlan-offload: off [fixed]
> ntuple-filters: off [fixed]
> receive-hashing: off [fixed]
> highdma: off [fixed]
> rx-vlan-filter: off [fixed]
> vlan-challenged: off [fixed]
> tx-lockless: off [fixed]
> netns-local: off [fixed]
> tx-gso-robust: off [fixed]
> tx-fcoe-segmentation: off [fixed]
> tx-gre-segmentation: off [fixed]
> tx-ipip-segmentation: off [fixed]
> tx-sit-segmentation: off [fixed]
> tx-udp_tnl-segmentation: off [fixed]
> tx-mpls-segmentation: off [fixed]
> fcoe-mtu: off [fixed]
> tx-nocache-copy: off
> loopback: off [fixed]
> rx-fcs: off [fixed]
> rx-all: off [fixed]
> tx-vlan-stag-hw-insert: off [fixed]
> rx-vlan-stag-hw-parse: off [fixed]
> rx-vlan-stag-filter: off [fixed]
> l2-fwd-offload: off [fixed]
> busy-poll: off [fixed]
>
>
^ permalink raw reply
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Russell King - ARM Linux @ 2015-01-22 23:06 UTC (permalink / raw)
To: Dean Gehnert; +Cc: Ezequiel Garcia, netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <20150122214910.GD26493@n2100.arm.linux.org.uk>
On Thu, Jan 22, 2015 at 09:49:10PM +0000, Russell King - ARM Linux wrote:
> On Thu, Jan 22, 2015 at 01:27:31PM -0800, Dean Gehnert wrote:
> > Can you can try the SOCAT test on your Dove platform and see if that passes
> > the non-cache line aligned test case? I think what the SOCAT test does is
> > take the NFS "variable" out of the equation. My theory is that if there is a
> > DMA corruption, then hard telling what kinds of problems will occur. It
> > might be the payload of a file is corrupted, or if the NFS structures are
> > corrupted, it could manifest itself as a problem in the NFS code.
>
> Anyway, I'm running the test now, but I had to change the socat line to:
>
> # socat -b$(((1024*10)+1)) -u open:ExpectData.in TCP:192.168.1.212:4000
>
> The receiving end is getting:
>
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> 4a4727232209b85badc1ca25ed4df222 -
> ...
It's been running for about an hour now with no sign of any problem.
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply
* [PATCH] ethernet: fm10k: Actually drop 4 bits
From: Rasmus Villemoes @ 2015-01-22 22:53 UTC (permalink / raw)
To: Alexander Duyck, Jeff Kirsher
Cc: Rasmus Villemoes, e1000-devel, netdev, linux-kernel
The comment explains the intention, but vid has type u16. Before the
inner shift, it is promoted to int, which has plenty of space for all
vid's bits, so nothing is dropped. Use a simple mask instead.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
index 275423d4f777..b1c57d0166a9 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
@@ -335,7 +335,7 @@ static s32 fm10k_update_xc_addr_pf(struct fm10k_hw *hw, u16 glort,
return FM10K_ERR_PARAM;
/* drop upper 4 bits of VLAN ID */
- vid = (vid << 4) >> 4;
+ vid &= 0x0fff;
/* record fields */
mac_update.mac_lower = cpu_to_le32(((u32)mac[2] << 24) |
--
2.1.3
^ permalink raw reply related
* Re: [PATCH] drivers: net: xgene: fix: Out of order descriptor bytes read
From: Eric Dumazet @ 2015-01-22 22:50 UTC (permalink / raw)
To: Iyappan Subramanian
Cc: davem, netdev, linux-kernel, linux-arm-kernel, mlangsdo, patches,
Keyur Chudgar
In-Reply-To: <1421957007-720-1-git-send-email-isubramanian@apm.com>
On Thu, 2015-01-22 at 12:03 -0800, Iyappan Subramanian wrote:
> This patch fixes the following kernel crash,
>
> WARNING: CPU: 2 PID: 0 at net/ipv4/tcp_input.c:3079 tcp_clean_rtx_queue+0x658/0x80c()
> Call trace:
>
> Software writes poison data into the descriptor bytes[15:8] and upon
> receiving the interrupt, if those bytes are overwritten by the hardware with
> the valid data, software also reads bytes[7:0] and executes receive/tx
> completion logic.
>
> If the CPU executes the above two reads in out of order fashion, then the
> bytes[7:0] will have older data and causing the kernel panic. We have to
> force the order of the reads and thus this patch introduces read memory
> barrier between these reads.
>
> Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
> Signed-off-by: Keyur Chudgar <kchudgar@apm.com>
> Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
> ---
> drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> index 83a5028..3622cdb 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> @@ -369,6 +369,8 @@ static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring,
> if (unlikely(xgene_enet_is_desc_slot_empty(raw_desc)))
> break;
>
> + /* read fpqnum field after dataaddr field */
> + smp_rmb();
> if (is_rx_desc(raw_desc))
> ret = xgene_enet_rx_frame(ring, raw_desc);
> else
Reading your changelog, it looks like you need a plain rmb() here.
^ permalink raw reply
* Re: [ovs-dev] [PATCH] net: openvswitch: Support masked set actions.
From: Pravin Shelar @ 2015-01-22 22:41 UTC (permalink / raw)
To: Jarno Rajahalme; +Cc: netdev, dev@openvswitch.org
In-Reply-To: <1418170225-9328-1-git-send-email-jrajahalme@nicira.com>
On Tue, Dec 9, 2014 at 4:10 PM, Jarno Rajahalme <jrajahalme@nicira.com> wrote:
> OVS userspace already probes the openvswitch kernel module for
> OVS_ACTION_ATTR_SET_MASKED support. This patch adds the kernel module
> implementation of masked set actions.
>
> The existing set action sets many fields at once. When only a subset
> of the IP header fields, for example, should be modified, all the IP
> fields need to be exact matched so that the other field values can be
> copied to the set action. A masked set action allows modification of
> an arbitrary subset of the supported header bits without requiring the
> rest to be matched.
>
> Masked set action is now supported for all writeable key types, except
> for the tunnel key. The set tunnel action is an exception as any
> input tunnel info is cleared before action processing starts, so there
> is no tunnel info to mask.
>
> The kernel module converts all (non-tunnel) set actions to masked set
> actions. This makes action processing more uniform, and results in
> less branching and duplicating the action processing code. When
> returning actions to userspace, the fully masked set actions are
> converted back to normal set actions. We use a kernel internal action
> code to be able to tell the userspace provided and converted masked
> set actions apart.
>
> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
> ---
checkpatch few gave few warnings. otherwise looks good.
^ permalink raw reply
* Re: net_test_tools: add ipv6 support for kbench_mod
From: Shaohua Li @ 2015-01-22 22:12 UTC (permalink / raw)
To: David Miller; +Cc: netdev, kafai
In-Reply-To: <20150115.180839.2081269036058084221.davem@davemloft.net>
On Thu, Jan 15, 2015 at 06:08:39PM -0500, David Miller wrote:
> From: Shaohua Li <shli@fb.com>
> Date: Thu, 15 Jan 2015 13:17:37 -0800
>
> > On Wed, Jan 14, 2015 at 01:35:40AM -0500, David Miller wrote:
> >> From: Shaohua Li <shli@fb.com>
> >> Date: Tue, 13 Jan 2015 21:45:48 -0800
> >>
> >> > This patch adds ipv6 support for kbench_mod test module
> >>
> >> This doesn't even link because ip6_route_input is not an
> >> exported symbol.
> >>
> >> So you either didn't test this, or it depends upon custom
> >> kernel changes which you didn't mention.
> >>
> >> Either way I can't apply this, sorry
> >
> > Yes, we need export the sysmbol for the test. Can we export the symbol?
> > or I can delete the route input test, which one do you prefer?
>
> There is no justification upstream to export that symbol since
> there are no modular users in-tree.
Hi,
I changed it to do the ip6_route_input test optionally. If the test is
required, somebody should change the kernel to export it and define
HAVE_IP6_ROUTE_INPUT in the test module. I thought this is fine for a
test module. How do you think?
Thanks,
Shaohua
This patch adds ipv6 support for kbench_mod test module. Since
ip6_route_input() isn't exported, it can only be tested with
HAVE_IP6_ROUTE_INPUT defined (ofcourse, changing kernel to export it)
diff --git a/kbench_mod.c b/kbench_mod.c
index fc3765c..9f5dccc 100644
--- a/kbench_mod.c
+++ b/kbench_mod.c
@@ -3,9 +3,11 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/inet.h>
+#include <linux/in6.h>
#include <net/route.h>
#include <net/ip_fib.h>
+#include <net/ip6_route.h>
#include <linux/timex.h>
@@ -66,9 +68,13 @@ extern int ip_route_output_cycles_7;
static int flow_oif = DEFAULT_OIF;
static int flow_iif = DEFAULT_IIF;
static u32 flow_mark = DEFAULT_MARK;
-static u32 flow_dst_ip_addr = DEFAULT_DST_IP_ADDR;
-static u32 flow_src_ip_addr = DEFAULT_SRC_IP_ADDR;
+static u32 ip4_flow_dst_ip_addr = DEFAULT_DST_IP_ADDR;
+static u32 ip4_flow_src_ip_addr = DEFAULT_SRC_IP_ADDR;
+static struct in6_addr ip6_flow_dst_ip_addr;
+static struct in6_addr ip6_flow_src_ip_addr;
static int flow_tos = DEFAULT_TOS;
+static int ip6_bench;
+module_param(ip6_bench, int, 0);
static char dst_string[64];
static char src_string[64];
@@ -76,12 +82,29 @@ static char src_string[64];
module_param_string(dst, dst_string, sizeof(dst_string), 0);
module_param_string(src, src_string, sizeof(src_string), 0);
-static void __init flow_setup(void)
+static int __init flow_setup(void)
{
+ if (ip6_bench) {
+ if (dst_string[0] &&
+ !in6_pton(dst_string, -1, ip6_flow_dst_ip_addr.s6_addr, -1, NULL)) {
+ pr_info("cannot parse \"%s\"\n", dst_string);
+ return -1;
+ }
+
+ if (src_string[0] &&
+ !in6_pton(src_string, -1, ip6_flow_src_ip_addr.s6_addr, -1, NULL)) {
+ pr_info("cannot parse \"%s\"\n", src_string);
+ return -1;
+ }
+
+ return 0;
+ }
+
if (dst_string[0])
- flow_dst_ip_addr = in_aton(dst_string);
+ ip4_flow_dst_ip_addr = in_aton(dst_string);
if (src_string[0])
- flow_src_ip_addr = in_aton(src_string);
+ ip4_flow_src_ip_addr = in_aton(src_string);
+ return 0;
}
module_param_named(oif, flow_oif, int, 0);
@@ -92,15 +115,70 @@ module_param_named(tos, flow_tos, int, 0);
static int warmup_count = DEFAULT_WARMUP_COUNT;
module_param_named(count, warmup_count, int, 0);
-static void flow_init(struct flowi4 *fl4)
+#define flow_init(fl, gen) \
+do { \
+ memset((fl), 0, sizeof(*(fl))); \
+ (fl)->flowi##gen##_oif = flow_oif; \
+ (fl)->flowi##gen##_iif = flow_iif; \
+ (fl)->flowi##gen##_mark = flow_mark; \
+ (fl)->flowi##gen##_tos = flow_tos; \
+ (fl)->daddr = ip##gen##_flow_dst_ip_addr; \
+ (fl)->saddr = ip##gen##_flow_src_ip_addr; \
+} while (0)
+
+#define flow_init_ip6(fl) \
+do { \
+ flow_init(fl, 6); \
+ (fl)->flowi6_proto = IPPROTO_ICMPV6; \
+} while(0)
+
+static int skb_init_ip6(struct sk_buff *skb)
{
- memset(fl4, 0, sizeof(*fl4));
- fl4->flowi4_oif = flow_oif;
- fl4->flowi4_iif = flow_iif;
- fl4->flowi4_mark = flow_mark;
- fl4->flowi4_tos = flow_tos;
- fl4->daddr = flow_dst_ip_addr;
- fl4->saddr = flow_src_ip_addr;
+ struct ipv6hdr *hdr;
+ struct net_device *dev;
+
+ skb_reset_mac_header(skb);
+ skb_reset_network_header(skb);
+ skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr));
+ hdr = ipv6_hdr(skb);
+
+ hdr->priority = 0;
+ hdr->version = 6;
+ memset(hdr->flow_lbl, 0, sizeof(hdr->flow_lbl));
+ hdr->payload_len = htons(sizeof(struct icmp6hdr));
+ hdr->nexthdr = IPPROTO_ICMPV6;
+ hdr->saddr = ip6_flow_src_ip_addr;
+ hdr->daddr = ip6_flow_dst_ip_addr;
+
+ dev = __dev_get_by_index(&init_net, flow_iif);
+ if (dev == NULL) {
+ pr_info("Input device does not exist\n");
+ return -ENODEV;
+ }
+ skb->protocol = htons(ETH_P_IPV6);
+ skb->dev = dev;
+ skb->mark = flow_mark;
+ return 0;
+}
+
+static int skb_init_ip4(struct sk_buff *skb)
+{
+ struct net_device *dev;
+
+ skb_reset_mac_header(skb);
+ skb_reset_network_header(skb);
+ ip_hdr(skb)->protocol = IPPROTO_ICMP;
+ skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
+
+ dev = __dev_get_by_index(&init_net, flow_iif);
+ if (dev == NULL) {
+ pr_info("Input device does not exist\n");
+ return -ENODEV;
+ }
+ skb->protocol = htons(ETH_P_IP);
+ skb->dev = dev;
+ skb->mark = flow_mark;
+ return 0;
}
static struct rtable *route_output(struct net *net, struct flowi4 *fl4)
@@ -108,7 +186,7 @@ static struct rtable *route_output(struct net *net, struct flowi4 *fl4)
return ip_route_output_key(net, fl4);
}
-static void do_full_output_lookup_bench(void)
+static void do_full_output_lookup_bench_ip4(void)
{
unsigned long long t1, t2, tdiff;
struct rtable *rt;
@@ -118,7 +196,7 @@ static void do_full_output_lookup_bench(void)
rt = NULL;
for (i = 0; i < warmup_count; i++) {
- flow_init(&fl4);
+ flow_init(&fl4, 4);
rt = route_output(&init_net, &fl4);
if (IS_ERR(rt))
@@ -140,7 +218,7 @@ static void do_full_output_lookup_bench(void)
ip_route_output_cycles_7 = 0;
#endif
- flow_init(&fl4);
+ flow_init(&fl4, 4);
t1 = get_tick();
rt = route_output(&init_net, &fl4);
@@ -161,35 +239,73 @@ static void do_full_output_lookup_bench(void)
#endif
}
+static void do_full_output_lookup_bench_ip6(void)
+{
+ unsigned long long t1, t2, tdiff;
+ struct rt6_info *rt;
+ struct flowi6 fl6;
+ int i;
+
+ rt = NULL;
+
+ for (i = 0; i < warmup_count; i++) {
+ flow_init_ip6(&fl6);
+
+ rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl6);
+ if (IS_ERR(rt))
+ break;
+ ip6_rt_put(rt);
+ }
+ if (IS_ERR(rt)) {
+ pr_info("ip6_route_output: err=%ld\n", PTR_ERR(rt));
+ return;
+ }
+
+ flow_init_ip6(&fl6);
+
+ t1 = get_tick();
+ rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl6);
+ t2 = get_tick();
+ if (!IS_ERR(rt))
+ ip6_rt_put(rt);
+
+ tdiff = t2 - t1;
+ pr_info("ip6_route_output tdiff: %llu\n", tdiff);
+}
+
static void do_full_input_lookup_bench(void)
{
unsigned long long t1, t2, tdiff;
- struct net_device *dev;
struct sk_buff *skb;
+ struct rt6_info *rt;
int err, i;
+#ifndef HAVE_IP6_ROUTE_INPUT
+#define ip6_route_input(s)
+ if (ip6_bench)
+ return;
+#endif
skb = alloc_skb(4096, GFP_KERNEL);
if (!skb) {
pr_info("Cannot alloc SKB for test\n");
return;
}
- skb_reset_mac_header(skb);
- skb_reset_network_header(skb);
- ip_hdr(skb)->protocol = IPPROTO_ICMP;
- skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
-
- dev = __dev_get_by_index(&init_net, flow_iif);
- if (dev == NULL) {
- pr_info("Input device does not exist\n");
+ if (ip6_bench)
+ err = skb_init_ip6(skb);
+ else
+ err = skb_init_ip4(skb);
+ if (err)
goto out_free;
- }
- skb->protocol = htons(ETH_P_IP);
- skb->dev = dev;
- skb->mark = flow_mark;
+
local_bh_disable();
err = 0;
for (i = 0; i < warmup_count; i++) {
- err = ip_route_input(skb, flow_dst_ip_addr, flow_src_ip_addr, flow_tos, dev);
+ if (ip6_bench) {
+ ip6_route_input(skb);
+ rt = (struct rt6_info *)skb_dst(skb);
+ err = (!rt || rt == init_net.ipv6.ip6_null_entry);
+ } else
+ err = ip_route_input(skb, ip4_flow_dst_ip_addr, ip4_flow_src_ip_addr, flow_tos, skb->dev);
if (err)
break;
skb_dst_drop(skb);
@@ -203,7 +319,12 @@ static void do_full_input_lookup_bench(void)
local_bh_disable();
t1 = get_tick();
- err = ip_route_input(skb, flow_dst_ip_addr, flow_src_ip_addr, flow_tos, dev);
+ if (ip6_bench) {
+ ip6_route_input(skb);
+ rt = (struct rt6_info *)skb_dst(skb);
+ err = (!rt || rt == init_net.ipv6.ip6_null_entry);
+ } else
+ err = ip_route_input(skb, ip4_flow_dst_ip_addr, ip4_flow_src_ip_addr, flow_tos, skb->dev);
t2 = get_tick();
local_bh_enable();
@@ -215,7 +336,10 @@ static void do_full_input_lookup_bench(void)
skb_dst_drop(skb);
tdiff = t2 - t1;
- pr_info("ip_route_input tdiff: %llu\n", tdiff);
+ if (ip6_bench)
+ pr_info("ip6_route_input tdiff: %llu\n", tdiff);
+ else
+ pr_info("ip_route_input tdiff: %llu\n", tdiff);
out_free:
kfree_skb(skb);
@@ -223,9 +347,12 @@ static void do_full_input_lookup_bench(void)
static void do_full_lookup_bench(void)
{
- if (!flow_iif)
- do_full_output_lookup_bench();
- else
+ if (!flow_iif) {
+ if (ip6_bench)
+ do_full_output_lookup_bench_ip6();
+ else
+ do_full_output_lookup_bench_ip4();
+ } else
do_full_input_lookup_bench();
}
@@ -240,7 +367,7 @@ static void do_full_lookup_prealloc_bench(void)
err = 0;
for (i = 0; i < warmup_count; i++) {
- flow_init(&fl4);
+ flow_init(&fl4, 4);
rt = ip_route_output_flow_prealloc(&init_net, &fl4, NULL, &rt_stack.dst);
if (IS_ERR(rt)) {
@@ -264,7 +391,7 @@ static void do_full_lookup_prealloc_bench(void)
ip_route_output_cycles_7 = 0;
#endif
- flow_init(&fl4);
+ flow_init(&fl4, 4);
t1 = get_tick();
rt = ip_route_output_flow_prealloc(&init_net, &fl4, NULL, &rt_stack.dst);
@@ -295,7 +422,7 @@ static void do_fib_lookup_bench(void)
struct flowi4 fl4;
int err, i;
- flow_init(&fl4);
+ flow_init(&fl4, 4);
for (i = 0; i < warmup_count; i++) {
struct fib_table *table;
@@ -398,7 +525,7 @@ static void do_new_lookup_bench(void)
struct flowi fl;
int err, i;
- flow_init(&fl);
+ flow_init(&fl, 4);
for (i = 0; i < warmup_count; i++) {
err = new_output_lookup(&fl, &rt);
@@ -428,6 +555,8 @@ static void do_bench(void)
do_full_lookup_bench();
do_full_lookup_bench();
+ if (ip6_bench)
+ return;
#ifdef IP_ROUTE_HAVE_PREALLOC
do_full_lookup_prealloc_bench();
do_full_lookup_prealloc_bench();
@@ -452,10 +581,19 @@ static int __init kbench_init(void)
{
flow_setup();
- pr_info("flow [IIF(%d),OIF(%d),MARK(0x%08x),D(%pI4),S(%pI4),TOS(0x%02x)]\n",
- flow_iif, flow_oif, flow_mark,
- &flow_dst_ip_addr,
- &flow_src_ip_addr, flow_tos);
+ if (!ip6_bench) {
+ pr_info("flow [IIF(%d),OIF(%d),MARK(0x%08x),D(%pI4),S(%pI4),TOS(0x%02x)]\n",
+ flow_iif, flow_oif, flow_mark,
+ &ip4_flow_dst_ip_addr,
+ &ip4_flow_src_ip_addr, flow_tos);
+ } else {
+ pr_info("flow [IIF(%d),OIF(%d),MARK(0x%08x),D(%pI6),"
+ "S(%pI6),TOS(0x%02x)]\n",
+ flow_iif, flow_oif, flow_mark,
+ &ip6_flow_dst_ip_addr,
+ &ip6_flow_src_ip_addr,
+ flow_tos);
+ }
#if defined(CONFIG_X86)
if (!cpu_has_tsc) {
^ permalink raw reply related
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Russell King - ARM Linux @ 2015-01-22 21:49 UTC (permalink / raw)
To: Dean Gehnert; +Cc: Ezequiel Garcia, netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <54C16B43.5040504@tpi.com>
On Thu, Jan 22, 2015 at 01:27:31PM -0800, Dean Gehnert wrote:
> On 01/22/2015 01:09 PM, Russell King - ARM Linux wrote:
> >On Thu, Jan 22, 2015 at 10:41:00AM -0800, Dean Gehnert wrote:
> >>FYI, I found a way to reproduce the mv643xx_eth transmit corruption without
> >>using a network filesystem by using SOCAT (should also be able to use NETCAT
> >>or NC) and I have a bit more information about the corruption that looks
> >>like it is somehow related to the cache line size.
> >That's not quite what I'm seeing. What I'm seeing with NFS is that the
> >machine is basically unusable. I have the etna_viv source in a NFS
> >share (it's shared amongst not only the Dove box but also my collection
> >of iMX6 based hardware.)
> >
> >I'm fairly fully IPv6 enabled here, which includes NFS.
> >
> >On the Dove, if I try to build this without any fixes, and then try to
> >build the etna_viv sources, it will take the machine out to the extent
> >that I have to reboot it - either the machine will freeze solidly, or
> >the kernel will oops in the DMA API functions, in a path which was
> >called from an interrupt handler. That takes out the entire machine
> >because we miss acknowleding the interrupt.
>
> I am wondering if there is a possibility of the root cause of this being in
> the arch DMA layer... From my testing with SOCAT and different cache line
> alignments, I am seeing Ethernet 4 byte transmit corruptions. My fear is
> this may not be restricted to the Ethernet transmit and maybe the root cause
> is a DMA / cache issue... I have no way to prove that theory. Your DMA API
> oops is a bit concerning that maybe there is some corruption going on during
> DMA operation.
We're careful in the arch code to do the best we can in all cases; that's
not to say that drivers aren't buggy (in that, they don't respect the DMA
API rules) but what I can say is that the ARM arch code gets it right.
Provided the ethernet driver maps the DMA buffer with DMA_TO_DEVICE prior
to the transfer being initiated, transfers _from_ the Marvell platform(s)
should be fine.
Provided the ethernet driver maps the DMA buffer with DMA_FROM_DEVICE
prior to handing it to the device, and then does not write to any cache
line associated with that DMA buffer before the ethernet driver has
completed, and then unmaps it with DMA_FROM_DEVICE, then again,
everything should be fine.
(The detail above "does not write to any cache line associated with
the DMA buffer" is subtle; what it means is that if the DMA buffer is
not aligned to a cache line, then nothing must write to the cache lines
which overlap the buffer, otherwise data corruption will occur.)
> Can you can try the SOCAT test on your Dove platform and see if that passes
> the non-cache line aligned test case? I think what the SOCAT test does is
> take the NFS "variable" out of the equation. My theory is that if there is a
> DMA corruption, then hard telling what kinds of problems will occur. It
> might be the payload of a file is corrupted, or if the NFS structures are
> corrupted, it could manifest itself as a problem in the NFS code.
This is one of the problems of having the TCP/UDP checksums offloaded to
the adapter - if the data is cocked up at the DMA stage, these checksums
won't detect it.
Anyway, I'm running the test now, but I had to change the socat line to:
# socat -b$(((1024*10)+1)) -u open:ExpectData.in TCP:192.168.1.212:4000
The receiving end is getting:
4a4727232209b85badc1ca25ed4df222 -
4a4727232209b85badc1ca25ed4df222 -
4a4727232209b85badc1ca25ed4df222 -
4a4727232209b85badc1ca25ed4df222 -
4a4727232209b85badc1ca25ed4df222 -
...
and I'm up to over 24 of these without any problem being visible - how
long does it take to show?
For reference, the features on my Dove box are:
Features for eth0:
rx-checksumming: on
tx-checksumming: on
tx-checksum-ipv4: on
tx-checksum-ip-generic: off [fixed]
tx-checksum-ipv6: off [fixed]
tx-checksum-fcoe-crc: off [fixed]
tx-checksum-sctp: off [fixed]
scatter-gather: on
tx-scatter-gather: on
tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
tx-tcp-segmentation: on
tx-tcp-ecn-segmentation: off [fixed]
tx-tcp6-segmentation: off [fixed]
udp-fragmentation-offload: off [fixed]
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: off [fixed]
tx-vlan-offload: off [fixed]
ntuple-filters: off [fixed]
receive-hashing: off [fixed]
highdma: off [fixed]
rx-vlan-filter: off [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: off [fixed]
tx-ipip-segmentation: off [fixed]
tx-sit-segmentation: off [fixed]
tx-udp_tnl-segmentation: off [fixed]
tx-mpls-segmentation: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: off
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off [fixed]
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: off [fixed]
rx-vlan-stag-filter: off [fixed]
l2-fwd-offload: off [fixed]
busy-poll: off [fixed]
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply
* [PATCH v1] cxgb3: re-use native hex2bin()
From: Andy Shevchenko @ 2015-01-22 21:37 UTC (permalink / raw)
To: netdev, Santosh Raspatur; +Cc: Andy Shevchenko
Call hex2bin() library function instead of doing conversion here.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index c74a898..184a8d5 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -727,9 +727,9 @@ static int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
p->xauicfg[1] = simple_strtoul(vpd.xaui1cfg_data, NULL, 16);
}
- for (i = 0; i < 6; i++)
- p->eth_base[i] = hex_to_bin(vpd.na_data[2 * i]) * 16 +
- hex_to_bin(vpd.na_data[2 * i + 1]);
+ ret = hex2bin(p->eth_base, vpd.na_data, 6);
+ if (ret < 0)
+ return -EINVAL;
return 0;
}
--
1.8.3.101.g727a46b
^ permalink raw reply related
* RE: [E1000-devel] [PATCH 1/2] if_link: Add VF multicast promiscuous mode control
From: Skidmore, Donald C @ 2015-01-22 21:34 UTC (permalink / raw)
To: Bjørn Mork
Cc: David Laight, Hiroshi Shimamoto,
e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org,
Choi, Sy Jong, linux-kernel@vger.kernel.org, Hayato Momma
In-Reply-To: <87bnlqpq6v.fsf@nemi.mork.no>
> -----Original Message-----
> From: Bjørn Mork [mailto:bjorn@mork.no]
> Sent: Thursday, January 22, 2015 11:32 AM
> To: Skidmore, Donald C
> Cc: David Laight; Hiroshi Shimamoto; e1000-devel@lists.sourceforge.net;
> netdev@vger.kernel.org; Choi, Sy Jong; linux-kernel@vger.kernel.org;
> Hayato Momma
> Subject: Re: [E1000-devel] [PATCH 1/2] if_link: Add VF multicast promiscuous
> mode control
>
> "Skidmore, Donald C" <donald.c.skidmore@intel.com> writes:
>
> > My hang up is more related to: without the nob to enable it (off by
> > default) we are letting one VF dictate policy for all the other VFs
> > and the PF. If one VF needs to be in promiscuous multicast so is
> > everyone else. Their stacks now needs to deal with all the extra
> > multicast packets. As you point out this might not be a direct
> > concern for isolation in that the VM could have 'chosen' to join any
> > Multicast group and seen this traffic. My concern over isolation is
> > one VF has chosen that all the other VM now have to see this multicast
> > traffic.
>
> Apologies if this question is stupid, but I just have to ask about stuff I don't
> understand...
>
> Looking at the proposed implementation, the promiscous multicast flag
> seems to be a per-VF flag:
>
> +int ixgbe_ndo_set_vf_mc_promisc(struct net_device *netdev, int vf, bool
> +setting) {
> + struct ixgbe_adapter *adapter = netdev_priv(netdev);
> + struct ixgbe_hw *hw = &adapter->hw;
> + u32 vmolr;
> +
> + if (vf >= adapter->num_vfs)
> + return -EINVAL;
> +
> + adapter->vfinfo[vf].mc_promisc_enabled = setting;
> +
> + vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
> + if (setting) {
> + e_info(drv, "VF %u: enabling multicast promiscuous\n", vf);
> + vmolr |= IXGBE_VMOLR_MPE;
> + } else {
> + e_info(drv, "VF %u: disabling multicast promiscuous\n", vf);
> + vmolr &= ~IXGBE_VMOLR_MPE;
> + }
> +
> + IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
> +
> + return 0;
> +}
> +
>
> I haven't read the data sheet, but I took a quick look at the excellent high
> level driver docs:
> http://www.intel.com/content/dam/doc/design-guide/82599-sr-iov-driver-
> companion-guide.pdf
>
> It mentions "Multicast Promiscuous Enable" in its "Thoughts for
> Customization" section:
>
> 7.1 Multicast Promiscuous Enable
>
> The controller has provisions to allow each VF to be put into Multicast
> Promiscuous mode. The Intel reference driver does not configure this
> option .
>
> The capability can be enabled/disabled by manipulating the MPE field (bit
> 28) of the PF VF L2 Control Register (PFVML2FLT – 0x0F000)
>
> and showing a section from the data sheet describing the "PF VM L2 Control
> Register - PFVML2FLT[n] (0x0F000 + 4 * n, n=0...63; RW)"
>
> To me it looks like enabling Promiscuos Multicast for a VF won't affect any
> other VF at all. Is this really not the case?
>
>
>
> Bjørn
Clearly not a dumb question at all and I'm glad you mentioned that. :) I was going off the assumption, been awhile since I read the patch, that the patch was using FCTRL.MPE or MANC.MCST_PASS_L2 which would turn multicast promiscuous on for everyone. Since the patch is using PFVML2FLT.MPE this lessens my concern over effect on the entire system.
That said I still would prefer having a way to override this behavior on the PF, although I admit my argument is weaker. I'm still concerned about a VF changing the behavior of the PF without any way to prevent it. This might be one part philosophical (PF sets policy not the VF) but this still could have a noticeable effect on the overall system. If any other VFs (or the PF) are receiving MC packets these will have to be replicated which will be a performance hit. When we use the MC hash this is limited vs. when anyone is in MC promiscuous every MC packet used by another pool would be replicated. I could imagine in some environments (i.e. public clouds) where you don't trust what is running in your VM you might what to block this from happening.
In some ways it is almost the mirror image of the issue you brought up:
Adding a new hook for this seems over-complicated to me. And it still
doesn't solve the real problems that
a) the user has to know about this limit, and
b) manually configure the feature
My reverse argument might be that if this happens automatically. It might take the VM provider a long time to realize performance has taken a hit because some VM asked to join 31 multicast groups and entered MC promiscuous. Then only to find that they have no way to block such behavior.
Maybe I wouldn't as concerned if the patch author could provide some performance results to show this won't have as a negative effect as I'm afraid it might?
-Don Skidmore <donald.c.skidmore@intel.com>
^ permalink raw reply
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Dean Gehnert @ 2015-01-22 21:27 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Ezequiel Garcia, netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <20150122210951.GC26493@n2100.arm.linux.org.uk>
On 01/22/2015 01:09 PM, Russell King - ARM Linux wrote:
> On Thu, Jan 22, 2015 at 10:41:00AM -0800, Dean Gehnert wrote:
>> FYI, I found a way to reproduce the mv643xx_eth transmit corruption without
>> using a network filesystem by using SOCAT (should also be able to use NETCAT
>> or NC) and I have a bit more information about the corruption that looks
>> like it is somehow related to the cache line size.
> That's not quite what I'm seeing. What I'm seeing with NFS is that the
> machine is basically unusable. I have the etna_viv source in a NFS
> share (it's shared amongst not only the Dove box but also my collection
> of iMX6 based hardware.)
>
> I'm fairly fully IPv6 enabled here, which includes NFS.
>
> On the Dove, if I try to build this without any fixes, and then try to
> build the etna_viv sources, it will take the machine out to the extent
> that I have to reboot it - either the machine will freeze solidly, or
> the kernel will oops in the DMA API functions, in a path which was
> called from an interrupt handler. That takes out the entire machine
> because we miss acknowleding the interrupt.
I am wondering if there is a possibility of the root cause of this being
in the arch DMA layer... From my testing with SOCAT and different cache
line alignments, I am seeing Ethernet 4 byte transmit corruptions. My
fear is this may not be restricted to the Ethernet transmit and maybe
the root cause is a DMA / cache issue... I have no way to prove that
theory. Your DMA API oops is a bit concerning that maybe there is some
corruption going on during DMA operation.
>
> Either way, it's effectively a power cycle as there's no reset button on
> the machine.
>
> I have yet to see any sign of data corruption.
>
Can you can try the SOCAT test on your Dove platform and see if that
passes the non-cache line aligned test case? I think what the SOCAT test
does is take the NFS "variable" out of the equation. My theory is that
if there is a DMA corruption, then hard telling what kinds of problems
will occur. It might be the payload of a file is corrupted, or if the
NFS structures are corrupted, it could manifest itself as a problem in
the NFS code.
^ permalink raw reply
* [PATCH v1] usbnet: re-use native hex2bin()
From: Andy Shevchenko @ 2015-01-22 21:27 UTC (permalink / raw)
To: Oliver Neukum, netdev; +Cc: Andy Shevchenko
Call hex2bin() library function, instead of doing conversion here.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/net/usb/usbnet.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3a6770a..449835f 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -160,20 +160,19 @@ EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
{
- int tmp, i;
+ int tmp = -1, ret;
unsigned char buf [13];
- tmp = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
- if (tmp != 12) {
+ ret = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
+ if (ret == 12)
+ tmp = hex2bin(dev->net->dev_addr, buf, 6);
+ if (tmp < 0) {
dev_dbg(&dev->udev->dev,
"bad MAC string %d fetch, %d\n", iMACAddress, tmp);
- if (tmp >= 0)
- tmp = -EINVAL;
- return tmp;
+ if (ret >= 0)
+ ret = -EINVAL;
+ return ret;
}
- for (i = tmp = 0; i < 6; i++, tmp += 2)
- dev->net->dev_addr [i] =
- (hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
return 0;
}
EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
--
1.8.3.101.g727a46b
^ permalink raw reply related
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Russell King - ARM Linux @ 2015-01-22 21:09 UTC (permalink / raw)
To: Dean Gehnert; +Cc: Ezequiel Garcia, netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <54C1443C.80909@tpi.com>
On Thu, Jan 22, 2015 at 10:41:00AM -0800, Dean Gehnert wrote:
> FYI, I found a way to reproduce the mv643xx_eth transmit corruption without
> using a network filesystem by using SOCAT (should also be able to use NETCAT
> or NC) and I have a bit more information about the corruption that looks
> like it is somehow related to the cache line size.
That's not quite what I'm seeing. What I'm seeing with NFS is that the
machine is basically unusable. I have the etna_viv source in a NFS
share (it's shared amongst not only the Dove box but also my collection
of iMX6 based hardware.)
I'm fairly fully IPv6 enabled here, which includes NFS.
On the Dove, if I try to build this without any fixes, and then try to
build the etna_viv sources, it will take the machine out to the extent
that I have to reboot it - either the machine will freeze solidly, or
the kernel will oops in the DMA API functions, in a path which was
called from an interrupt handler. That takes out the entire machine
because we miss acknowleding the interrupt.
Either way, it's effectively a power cycle as there's no reset button on
the machine.
I have yet to see any sign of data corruption.
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply
* Re: [PATCH] brcmfmac: avoid duplicated suspend/resume operation
From: Arend van Spriel @ 2015-01-22 20:58 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Kalle Valo, Fu, Zhonghui, brudley-dY08KVG/lbpWk0Htik3J/w,
Franky Lin, meuleman-dY08KVG/lbpWk0Htik3J/w,
linville-2XuSBdqkA4R54TAoqtyWWQ, pieterpg-dY08KVG/lbpWk0Htik3J/w,
hdegoede-H+wXaHxf7aLQT0dZR+AlfA, wens-jdAy2FN1RRM,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/w,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <54C1012F.1020400-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
On 01/22/15 14:54, Sergei Shtylyov wrote:
> Hello.
>
> On 1/22/2015 4:49 PM, Kalle Valo wrote:
>
>>> >From 04d3fa673897ca4ccbea6c76836d0092dba2484a Mon Sep 17 00:00:00 2001
>>> From: Zhonghui Fu <zhonghui.fu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>>> Date: Tue, 20 Jan 2015 11:14:13 +0800
>>> Subject: [PATCH] brcmfmac: avoid duplicated suspend/resume operation
>
>>> WiFi chip has 2 SDIO functions, and PM core will trigger
>>> twice suspend/resume operations for one WiFi chip to do
>>> the same things. This patch avoid this case.
>
>>> Acked-by: Arend van Spriel <arend-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
>>> Acked-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
>>> Acked-by: Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
>>> Signed-off-by: Zhonghui Fu <zhonghui.fu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>
>> I don't remember giving Acked-by to this (or for matter to anything for
>> a long time). What about Sergei or Arend?
>
> I haven't ACK'ed this patch either.
I did ACK the initial patch and felt it still valid for this 'V2' patch.
Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] drivers: net: xgene: fix: Out of order descriptor bytes read
From: Iyappan Subramanian @ 2015-01-22 20:03 UTC (permalink / raw)
To: davem, netdev
Cc: linux-kernel, linux-arm-kernel, mlangsdo, patches,
Iyappan Subramanian, Keyur Chudgar
This patch fixes the following kernel crash,
WARNING: CPU: 2 PID: 0 at net/ipv4/tcp_input.c:3079 tcp_clean_rtx_queue+0x658/0x80c()
Call trace:
[<fffffe0000096b7c>] dump_backtrace+0x0/0x184
[<fffffe0000096d10>] show_stack+0x10/0x1c
[<fffffe0000685ea0>] dump_stack+0x74/0x98
[<fffffe00000b44e0>] warn_slowpath_common+0x88/0xb0
[<fffffe00000b461c>] warn_slowpath_null+0x14/0x20
[<fffffe00005b5c1c>] tcp_clean_rtx_queue+0x654/0x80c
[<fffffe00005b6228>] tcp_ack+0x454/0x688
[<fffffe00005b6ca8>] tcp_rcv_established+0x4a4/0x62c
[<fffffe00005bf4b4>] tcp_v4_do_rcv+0x16c/0x350
[<fffffe00005c225c>] tcp_v4_rcv+0x8e8/0x904
[<fffffe000059d470>] ip_local_deliver_finish+0x100/0x26c
[<fffffe000059dad8>] ip_local_deliver+0xac/0xc4
[<fffffe000059d6c4>] ip_rcv_finish+0xe8/0x328
[<fffffe000059dd3c>] ip_rcv+0x24c/0x38c
[<fffffe0000563950>] __netif_receive_skb_core+0x29c/0x7c8
[<fffffe0000563ea4>] __netif_receive_skb+0x28/0x7c
[<fffffe0000563f54>] netif_receive_skb_internal+0x5c/0xe0
[<fffffe0000564810>] napi_gro_receive+0xb4/0x110
[<fffffe0000482a2c>] xgene_enet_process_ring+0x144/0x338
[<fffffe0000482d18>] xgene_enet_napi+0x1c/0x50
[<fffffe0000565454>] net_rx_action+0x154/0x228
[<fffffe00000b804c>] __do_softirq+0x110/0x28c
[<fffffe00000b8424>] irq_exit+0x8c/0xc0
[<fffffe0000093898>] handle_IRQ+0x44/0xa8
[<fffffe000009032c>] gic_handle_irq+0x38/0x7c
[...]
Software writes poison data into the descriptor bytes[15:8] and upon
receiving the interrupt, if those bytes are overwritten by the hardware with
the valid data, software also reads bytes[7:0] and executes receive/tx
completion logic.
If the CPU executes the above two reads in out of order fashion, then the
bytes[7:0] will have older data and causing the kernel panic. We have to
force the order of the reads and thus this patch introduces read memory
barrier between these reads.
Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
Signed-off-by: Keyur Chudgar <kchudgar@apm.com>
Tested-by: Mark Langsdorf <mlangsdo@redhat.com>
---
drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 83a5028..3622cdb 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -369,6 +369,8 @@ static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring,
if (unlikely(xgene_enet_is_desc_slot_empty(raw_desc)))
break;
+ /* read fpqnum field after dataaddr field */
+ smp_rmb();
if (is_rx_desc(raw_desc))
ret = xgene_enet_rx_frame(ring, raw_desc);
else
--
1.9.1
^ permalink raw reply related
* Re: [PATCH net v2] ipv4: try to cache dst_entries which would cause a redirect
From: Julian Anastasov @ 2015-01-22 19:57 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev, Marcelo Leitner, Florian Westphal
In-Reply-To: <1421930098.14431.8.camel@stressinduktion.org>
Hello,
On Thu, 22 Jan 2015, Hannes Frederic Sowa wrote:
> I would try to not introduce this complexity. I am currently researching
> if this change does improve things:
>
> do_cache = res->fi && !itag;
> - if (out_dev == in_dev && err && IN_DEV_TX_REDIRECTS(out_dev) &&
> - (IN_DEV_SHARED_MEDIA(out_dev) ||
> - inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res)))) {
> - flags |= RTCF_DOREDIRECT;
> - do_cache = false;
> + if (skb->protocol == htons(ETH_P_IP)) {
> + if (out_dev == in_dev && err && IN_DEV_TX_REDIRECTS(out_dev) &&
> + skb->protocol == htons(ETH_P_IP) &&
Above is duplicate. Or better to remove first
and to keep this second check if flag is not cleared below...
> + (IN_DEV_SHARED_MEDIA(out_dev) ||
> + inet_addr_onlink(out_dev, saddr, FIB_RES_GW(*res))))
> + IPCB(skb)->flags |= IPSKB_DOREDIRECT;
> + else if (IPCB(skb)->flags & IPSKB_DOREDIRECT)
> + IPCB(skb)->flags &= ~IPSKB_DOREDIRECT;
It seems we do not need to clear the flag for
ip_options_rcv_srr purposes because ip_route_input is called
only if initial rt_type is RTN_LOCAL, so the flag should be
unset. ip_mkroute_input/__mkroute_input is called only for
forwarding.
In ip_options_rcv_srr we have RTN_LOCAL ... [RTN_LOCAL]
and may be final RTN_UNICAST. The flag can be set and used
only for RTN_UNICAST and that is the final ip_route_input
called there. Lets keep it just with the 2nd ETH_P_IP check?
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply
* Re: [E1000-devel] [PATCH 1/2] if_link: Add VF multicast promiscuous mode control
From: Bjørn Mork @ 2015-01-22 19:31 UTC (permalink / raw)
To: Skidmore, Donald C
Cc: David Laight, Hiroshi Shimamoto,
e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org,
Choi, Sy Jong, linux-kernel@vger.kernel.org, Hayato Momma
In-Reply-To: <F6FB0E698C9B3143BDF729DF222866469129BFFD@ORSMSX110.amr.corp.intel.com>
"Skidmore, Donald C" <donald.c.skidmore@intel.com> writes:
> My hang up is more related to: without the nob to enable it (off by
> default) we are letting one VF dictate policy for all the other VFs
> and the PF. If one VF needs to be in promiscuous multicast so is
> everyone else. Their stacks now needs to deal with all the extra
> multicast packets. As you point out this might not be a direct
> concern for isolation in that the VM could have 'chosen' to join any
> Multicast group and seen this traffic. My concern over isolation is
> one VF has chosen that all the other VM now have to see this multicast
> traffic.
Apologies if this question is stupid, but I just have to ask about stuff
I don't understand...
Looking at the proposed implementation, the promiscous multicast flag
seems to be a per-VF flag:
+int ixgbe_ndo_set_vf_mc_promisc(struct net_device *netdev, int vf, bool setting)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+ struct ixgbe_hw *hw = &adapter->hw;
+ u32 vmolr;
+
+ if (vf >= adapter->num_vfs)
+ return -EINVAL;
+
+ adapter->vfinfo[vf].mc_promisc_enabled = setting;
+
+ vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
+ if (setting) {
+ e_info(drv, "VF %u: enabling multicast promiscuous\n", vf);
+ vmolr |= IXGBE_VMOLR_MPE;
+ } else {
+ e_info(drv, "VF %u: disabling multicast promiscuous\n", vf);
+ vmolr &= ~IXGBE_VMOLR_MPE;
+ }
+
+ IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
+
+ return 0;
+}
+
I haven't read the data sheet, but I took a quick look at the excellent
high level driver docs:
http://www.intel.com/content/dam/doc/design-guide/82599-sr-iov-driver-companion-guide.pdf
It mentions "Multicast Promiscuous Enable" in its "Thoughts for
Customization" section:
7.1 Multicast Promiscuous Enable
The controller has provisions to allow each VF to be put into Multicast
Promiscuous mode. The Intel reference driver does not configure this
option .
The capability can be enabled/disabled by manipulating the MPE field
(bit 28) of the PF VF L2 Control Register (PFVML2FLT – 0x0F000)
and showing a section from the data sheet describing the
"PF VM L2 Control Register - PFVML2FLT[n] (0x0F000 + 4 * n, n=0...63; RW)"
To me it looks like enabling Promiscuos Multicast for a VF won't affect
any other VF at all. Is this really not the case?
Bjørn
^ permalink raw reply
* Re: [PATCH net 0/2] net: marvell: Fix highmem support on non-TSO path
From: Dean Gehnert @ 2015-01-22 18:41 UTC (permalink / raw)
To: Russell King - ARM Linux, Ezequiel Garcia
Cc: netdev, David Miller, B38611, fabio.estevam
In-Reply-To: <20150121150159.GS26493@n2100.arm.linux.org.uk>
On 01/21/2015 07:01 AM, Russell King - ARM Linux wrote:
> On Wed, Jan 21, 2015 at 09:54:08AM -0300, Ezequiel Garcia wrote:
>> These two commits are fixes to the issue reported by Russell King on
>> mv643xx_eth. Namely, the introduction of a regression by commit 69ad0dd7af22
>> which removed the support for highmem skb fragments. The guilty commit
>> introduced the assumption of fragment's payload being located in lowmem pages.
> I do wonder whether 69ad0dd7af22 is the real culpret, or whether there is
> some other change in the netdev layer that we're missing. That commit is
> in 3.16, but from what I remember, 3.17 works fine, it's 3.18 which fails.
>
>> A similar pattern can be found in the original mvneta driver (in fact, the
>> regression was introduced by copy-pasting the mvneta code).
>>
>> These fixes are for the non-TSO egress path in mvneta and mv643xx_eth drivers.
>> The TSO path needs a more intrusive change, as the TSO API needs to be fixed
>> (e.g. to make it work in skb fragments, instead of pointers to data).
>>
>> Russell, as I'm still unable to reproduce this, do you think you can
>> give it a spin over there?
> Sure - I think the only one I can test is mv643xx_eth, I don't think I
> have any device which supports mv_neta.
>
> The test scenario is for a NFS mount (the Marvell device as the NFS
> client) over IPv6.
>
> Initial testing looks good, I'll let it run for a while with various
> builds on the NFS share (which iirc was one of the triggering
> workloads).
>
> Thanks.
>
FYI, I found a way to reproduce the mv643xx_eth transmit corruption
without using a network filesystem by using SOCAT (should also be able
to use NETCAT or NC) and I have a bit more information about the
corruption that looks like it is somehow related to the cache line size.
1) Create a "large" input file with known data on the target (saved to
RAM disk or other storage):
% php -r 'for ($x = 0; $x < 0x2000000; $x++) { printf("%08X\n",
$x); }' > ExpectData.in
or
% perl -e 'for ($x = 0; $x < 0x2000000; $x++) { printf("%08X\n",
$x); }' > ExpectData.in
% md5sum ExpectData.in
4a4727232209b85badc1ca25ed4df222 ExpectData.in
2) Start SOCAT on the host system to perform Ethernet receive MD5
checksum of the data:
% socat -s -u TCP4-LISTEN:4000,fork,reuseaddr EXEC:md5sum
3) Enable TSO on the target:
% ethtool -K eth0 tso on
4) Send the data file from the target to the host using SOCAT with a
non-cache aligned block size:
% socat -b$(((1024*10)+1)) -u ExpectData.in TCP:192.168.1.212:4000
5) The SOCAT running on the host system will report the MD5 checksum. If
the MD5 is correct, it should be 4a4727232209b85badc1ca25ed4df222.
What I am seeing is every now and then, there are 32-bits (4 bytes) of
data in the transmit Ethernet stream that are corrupted. If I change the
SOCAT block size to something that is Armada 300 (Kirkwood) cache line
aligned (ie. -b$(((1024*10)+0)) or -b$(((1024*10)+8))), it works just
fine... If you want to capture the actual file and look at it, you can
use SOCAT:
% socat -u TCP4-LISTEN:4000,fork,reuseaddr OPEN:ActualData.in,creat
and since the data file is text, it is really easy to see the corruption
(diff ExpectData.in ActualData.in | less).
I can disable TSO (ethtool -K eth0 tso off) and re-run the tests and the
corruption does not occur.
I will give Ezequiel's latest patches a test a today and let you know if
they change the behavior.
Dean
^ 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