Re: [PATCH net-next v6 2/3] Add a eBPF helper function to retrieve socket uid

2017-03-21 Thread Lorenzo Colitti
On Tue, Mar 21, 2017 at 1:08 PM, Chenbo Feng
 wrote:
> +   if (!sk || !sk_fullsock(sk))
> +   return overflowuid;
> +   kuid = sock_net_uid(sock_net(sk), sk);
> +   return from_kuid_munged(current_user_ns(), kuid);

Is current_user_ns() correct in all the contexts you'll want to run
this code from? For packets sent by userspace applications it's likely
to be correct, but what about received packets, and packets processed
by the xt_ebpf module?


Re: [PATCH 24/29] drivers: convert iblock_req.pending from atomic_t to refcount_t

2017-03-21 Thread Nicholas A. Bellinger
Hi Elena,

On Mon, 2017-03-06 at 16:21 +0200, Elena Reshetova wrote:
> refcount_t type and corresponding API should be
> used instead of atomic_t when the variable is used as
> a reference counter. This allows to avoid accidental
> refcounter overflows that might lead to use-after-free
> situations.
> 
> Signed-off-by: Elena Reshetova 
> Signed-off-by: Hans Liljestrand 
> Signed-off-by: Kees Cook 
> Signed-off-by: David Windsor 
> ---
>  drivers/target/target_core_iblock.c | 12 ++--
>  drivers/target/target_core_iblock.h |  3 ++-
>  2 files changed, 8 insertions(+), 7 deletions(-)

After reading up on this thread, it looks like various subsystem
maintainers are now picking these atomic_t -> refcount_t conversions..

That said, applied to target-pending/for-next and will plan to include
for v4.12-rc1 merge window.

Thanks!



Re: "tipc: fix socket timer deadlock" to stable?

2017-03-21 Thread Tommi Rantala

On 13.03.2017 14:18, Jon Maloy wrote:

-Original Message-
From: Tommi Rantala [mailto:tommi.t.rant...@nokia.com]

We're seeing this tipc deadlock in 4.4.y, that was fixed in the mainline commit
f1d048f24e66ba85d3dabf3d076cefa5f2b546b0 "tipc: fix socket timer
deadlock".

Could/should this patch also be included in the stable kernel trees?


I think it should. If action is required by me here (?) I will repost the 
commit for 4.4.

///jon


Hi Jon, yes, please do repost the commit. After reading through 
Documentation/networking/netdev-FAQ.txt, you probably want to send it 
with suitable subject-prefix so that the patch is not lost in the noise.



I just checked that the patch applies on top of 4.4.53, only the line numbers
are different compared to the upstream commit.


(Actually there is also a small change in the patch context.)

-Tommi


Re: [PATCH 1/3] soc: qcom: smd: Transition client drivers from smd to rpmsg

2017-03-21 Thread Marcel Holtmann
Hi Bjorn,

> By moving these client drivers to use RPMSG instead of the direct SMD
> API we can reuse them ontop of the newly added GLINK wire-protocol
> support found in the 820 and 835 Qualcomm platforms.
> 
> As the new (RPMSG-based) and old SMD implementations are mutually
> exclusive we have to change all client drivers in one commit, to make
> sure we have a working system before and after this transition.
> 
> Signed-off-by: Bjorn Andersson 
> ---
> 
> Based on v4.11-rc3 with Arnd's Kconfig dependency fixes for BT_QCOMSMD
> (https://lkml.org/lkml/2017/3/20/1038).
> 
> drivers/bluetooth/Kconfig  |  2 +-
> drivers/bluetooth/btqcomsmd.c  | 32 +--
> drivers/net/wireless/ath/wcn36xx/Kconfig   |  2 +-
> drivers/net/wireless/ath/wcn36xx/main.c|  6 ++--
> drivers/net/wireless/ath/wcn36xx/smd.c | 10 +++---
> drivers/net/wireless/ath/wcn36xx/smd.h |  6 ++--
> drivers/net/wireless/ath/wcn36xx/wcn36xx.h |  2 +-
> drivers/soc/qcom/Kconfig   |  4 +--
> drivers/soc/qcom/smd-rpm.c | 43 +
> drivers/soc/qcom/wcnss_ctrl.c  | 50 +-
> include/linux/soc/qcom/wcnss_ctrl.h| 11 ---
> net/qrtr/Kconfig   |  2 +-
> net/qrtr/smd.c | 42 -
> 13 files changed, 108 insertions(+), 104 deletions(-)

I think that it is best if Dave takes these directly then and I pull them back 
down later into our trees. Including the Kconfig fix that I will ACK as well.

Acked-by: Marcel Holtmann 

Regards

Marcel



[PATCH 3/5] netfilter: nf_tables_api: Clean up tests if NULL returned on failure

2017-03-21 Thread simran singhal
Some functions like kmalloc/kzalloc return NULL on failure. When NULL
represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/nf_tables_api.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 5e0ccfd..25a3951 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -117,7 +117,7 @@ static struct nft_trans *nft_trans_alloc_gfp(const struct 
nft_ctx *ctx,
struct nft_trans *trans;
 
trans = kzalloc(sizeof(struct nft_trans) + size, gfp);
-   if (trans == NULL)
+   if (!trans)
return NULL;
 
trans->msg_type = msg_type;
@@ -720,7 +720,7 @@ static int nf_tables_newtable(struct net *net, struct sock 
*nlsk,
 
err = -ENOMEM;
table = kzalloc(sizeof(*table), GFP_KERNEL);
-   if (table == NULL)
+   if (!table)
goto err2;
 
nla_strlcpy(table->name, name, NFT_TABLE_MAXNAMELEN);
@@ -1478,7 +1478,7 @@ static int nf_tables_newchain(struct net *net, struct 
sock *nlsk,
return err;
 
basechain = kzalloc(sizeof(*basechain), GFP_KERNEL);
-   if (basechain == NULL) {
+   if (!basechain) {
nft_chain_release_hook(&hook);
return -ENOMEM;
}
@@ -1526,7 +1526,7 @@ static int nf_tables_newchain(struct net *net, struct 
sock *nlsk,
basechain->policy = policy;
} else {
chain = kzalloc(sizeof(*chain), GFP_KERNEL);
-   if (chain == NULL)
+   if (!chain)
return -ENOMEM;
}
 
@@ -1800,7 +1800,7 @@ struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
 
err = -ENOMEM;
expr = kzalloc(info.ops->size, GFP_KERNEL);
-   if (expr == NULL)
+   if (!expr)
goto err2;
 
err = nf_tables_newexpr(ctx, &info, expr);
@@ -2214,7 +2214,7 @@ static int nf_tables_newrule(struct net *net, struct sock 
*nlsk,
 
err = -ENOMEM;
rule = kzalloc(sizeof(*rule) + size + usize, GFP_KERNEL);
-   if (rule == NULL)
+   if (!rule)
goto err1;
 
nft_activate_next(net, rule);
@@ -2810,7 +2810,7 @@ static int nf_tables_getset(struct net *net, struct sock 
*nlsk,
struct nft_ctx *ctx_dump;
 
ctx_dump = kmalloc(sizeof(*ctx_dump), GFP_KERNEL);
-   if (ctx_dump == NULL)
+   if (!ctx_dump)
return -ENOMEM;
 
*ctx_dump = ctx;
@@ -3014,7 +3014,7 @@ static int nf_tables_newset(struct net *net, struct sock 
*nlsk,
 
err = -ENOMEM;
set = kzalloc(sizeof(*set) + size + udlen, GFP_KERNEL);
-   if (set == NULL)
+   if (!set)
goto err1;
 
nla_strlcpy(name, nla[NFTA_SET_NAME], sizeof(set->name));
@@ -3543,7 +3543,7 @@ void *nft_set_elem_init(const struct nft_set *set,
void *elem;
 
elem = kzalloc(set->ops->elemsize + tmpl->len, gfp);
-   if (elem == NULL)
+   if (!elem)
return NULL;
 
ext = nft_set_elem_ext(set, elem);
@@ -3998,7 +3998,7 @@ struct nft_set_gc_batch *nft_set_gc_batch_alloc(const 
struct nft_set *set,
struct nft_set_gc_batch *gcb;
 
gcb = kzalloc(sizeof(*gcb), gfp);
-   if (gcb == NULL)
+   if (!gcb)
return gcb;
gcb->head.set = set;
return gcb;
@@ -4084,7 +4084,7 @@ static struct nft_object *nft_obj_init(const struct 
nft_object_type *type,
 
err = -ENOMEM;
obj = kzalloc(sizeof(struct nft_object) + type->size, GFP_KERNEL);
-   if (obj == NULL)
+   if (!obj)
goto err1;
 
err = type->init((const struct nlattr * const *)tb, obj);
@@ -5567,7 +5567,7 @@ static int __init nf_tables_module_init(void)
 
info = kmalloc(sizeof(struct nft_expr_info) * NFT_RULE_MAXEXPRS,
   GFP_KERNEL);
-   if (info == NULL) {
+   if (!info) {
err = -ENOMEM;
goto err1;
}
-- 
2.7.4



[PATCH 5/5] netfilter: xt_TEE: Clean up tests if NULL returned on failure

2017-03-21 Thread simran singhal
Some functions like kmalloc/kzalloc return NULL on failure. When NULL
represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/xt_TEE.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c
index 86b0580..5df3282 100644
--- a/net/netfilter/xt_TEE.c
+++ b/net/netfilter/xt_TEE.c
@@ -95,7 +95,7 @@ static int tee_tg_check(const struct xt_tgchk_param *par)
return -EINVAL;
 
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-   if (priv == NULL)
+   if (!priv)
return -ENOMEM;
 
priv->tginfo  = info;
-- 
2.7.4



[PATCH 4/5] netfilter: nfnetlink: Clean up tests if NULL returned on failure

2017-03-21 Thread simran singhal
Some functions like kmalloc/kzalloc return NULL on failure. When NULL
represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/nfnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 68eda920..c39f16c 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -232,7 +232,7 @@ static int nfnl_err_add(struct list_head *list, struct 
nlmsghdr *nlh, int err)
struct nfnl_err *nfnl_err;
 
nfnl_err = kmalloc(sizeof(struct nfnl_err), GFP_KERNEL);
-   if (nfnl_err == NULL)
+   if (!nfnl_err)
return -ENOMEM;
 
nfnl_err->nlh = nlh;
-- 
2.7.4



[PATCH 1/5] netfilter: ipvs: Clean up tests if NULL returned on failure

2017-03-21 Thread simran singhal
Some functions like kmalloc/kzalloc return NULL on failure. When NULL
represents failure, !x is commonly used.

@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal 
---
 
 --This is my contribution to the netfilter project of
   Outreachy Round 14.
 
 net/netfilter/ipvs/ip_vs_ctl.c   | 4 ++--
 net/netfilter/ipvs/ip_vs_dh.c| 2 +-
 net/netfilter/ipvs/ip_vs_lblc.c  | 2 +-
 net/netfilter/ipvs/ip_vs_lblcr.c | 4 ++--
 net/netfilter/ipvs/ip_vs_sh.c| 2 +-
 net/netfilter/ipvs/ip_vs_wrr.c   | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 5aeb0dd..efe348a 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -910,7 +910,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct 
ip_vs_dest_user_kern *udest,
}
 
dest = kzalloc(sizeof(struct ip_vs_dest), GFP_KERNEL);
-   if (dest == NULL)
+   if (!dest)
return -ENOMEM;
 
dest->stats.cpustats = alloc_percpu(struct ip_vs_cpu_stats);
@@ -1228,7 +1228,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct 
ip_vs_service_user_kern *u,
 #endif
 
svc = kzalloc(sizeof(struct ip_vs_service), GFP_KERNEL);
-   if (svc == NULL) {
+   if (!svc) {
IP_VS_DBG(1, "%s(): no memory\n", __func__);
ret = -ENOMEM;
goto out_err;
diff --git a/net/netfilter/ipvs/ip_vs_dh.c b/net/netfilter/ipvs/ip_vs_dh.c
index 75f798f..22a2535 100644
--- a/net/netfilter/ipvs/ip_vs_dh.c
+++ b/net/netfilter/ipvs/ip_vs_dh.c
@@ -159,7 +159,7 @@ static int ip_vs_dh_init_svc(struct ip_vs_service *svc)
 
/* allocate the DH table for this service */
s = kzalloc(sizeof(struct ip_vs_dh_state), GFP_KERNEL);
-   if (s == NULL)
+   if (!s)
return -ENOMEM;
 
svc->sched_data = s;
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 5824927..d7c6031 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -352,7 +352,7 @@ static int ip_vs_lblc_init_svc(struct ip_vs_service *svc)
 *Allocate the ip_vs_lblc_table for this service
 */
tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
-   if (tbl == NULL)
+   if (!tbl)
return -ENOMEM;
 
svc->sched_data = tbl;
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 703f118..b0a9e1c 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -113,7 +113,7 @@ static void ip_vs_dest_set_insert(struct ip_vs_dest_set 
*set,
}
 
e = kmalloc(sizeof(*e), GFP_ATOMIC);
-   if (e == NULL)
+   if (!e)
return;
 
ip_vs_dest_hold(dest);
@@ -515,7 +515,7 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
 *Allocate the ip_vs_lblcr_table for this service
 */
tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
-   if (tbl == NULL)
+   if (!tbl)
return -ENOMEM;
 
svc->sched_data = tbl;
diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
index 16aaac6..99f3c3e 100644
--- a/net/netfilter/ipvs/ip_vs_sh.c
+++ b/net/netfilter/ipvs/ip_vs_sh.c
@@ -235,7 +235,7 @@ static int ip_vs_sh_init_svc(struct ip_vs_service *svc)
 
/* allocate the SH table for this service */
s = kzalloc(sizeof(struct ip_vs_sh_state), GFP_KERNEL);
-   if (s == NULL)
+   if (!s)
return -ENOMEM;
 
svc->sched_data = s;
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c
index 17e6d44..0923e6c 100644
--- a/net/netfilter/ipvs/ip_vs_wrr.c
+++ b/net/netfilter/ipvs/ip_vs_wrr.c
@@ -116,7 +116,7 @@ static int ip_vs_wrr_init_svc(struct ip_vs_service *svc)
 *Allocate the mark variable for WRR scheduling
 */
mark = kmalloc(sizeof(struct ip_vs_wrr_mark), GFP_KERNEL);
-   if (mark == NULL)
+   if (!mark)
return -ENOMEM;
 
mark->cl = list_entry(&svc->destinations, struct ip_vs_dest, n_list);
-- 
2.7.4



[PATCH 2/5] netfilter: Clean up tests if NULL returned on failure

2017-03-21 Thread simran singhal
Some functions like kmalloc/kzalloc return NULL on failure. When NULL
represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@
e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/nf_conntrack_netlink.c | 2 +-
 net/netfilter/nf_conntrack_proto.c   | 2 +-
 net/netfilter/nf_nat_core.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index 6806b5e..cdcf4c1 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -779,7 +779,7 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[])
struct ctnetlink_filter *filter;
 
filter = kzalloc(sizeof(*filter), GFP_KERNEL);
-   if (filter == NULL)
+   if (!filter)
return ERR_PTR(-ENOMEM);
 
filter->mark.val = ntohl(nla_get_be32(cda[CTA_MARK]));
diff --git a/net/netfilter/nf_conntrack_proto.c 
b/net/netfilter/nf_conntrack_proto.c
index 2d6ee18..48d8354 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -358,7 +358,7 @@ int nf_ct_l4proto_register_one(struct nf_conntrack_l4proto 
*l4proto)
proto_array = kmalloc(MAX_NF_CT_PROTO *
  sizeof(struct nf_conntrack_l4proto *),
  GFP_KERNEL);
-   if (proto_array == NULL) {
+   if (!proto_array) {
ret = -ENOMEM;
goto out_unlock;
}
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 94b14c5..922bd5b 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -626,7 +626,7 @@ int nf_nat_l4proto_register(u8 l3proto, const struct 
nf_nat_l4proto *l4proto)
if (nf_nat_l4protos[l3proto] == NULL) {
l4protos = kmalloc(IPPROTO_MAX * sizeof(struct nf_nat_l4proto 
*),
   GFP_KERNEL);
-   if (l4protos == NULL) {
+   if (!l4protos) {
ret = -ENOMEM;
goto out;
}
-- 
2.7.4



[PATCH 0/5] netfilter: Clean up tests if NULL returned on failure

2017-03-21 Thread simran singhal
This patch series clean up tests if NULL returned on failure.

simran singhal (5):
  netfilter: ipvs: Clean up tests if NULL returned on failure
  netfilter: Clean up tests if NULL returned on failure
  netfilter: nf_tables_api: Clean up tests if NULL returned on failure
  netfilter: nfnetlink: Clean up tests if NULL returned on failure
  netfilter: xt_TEE: Clean up tests if NULL returned on failure

 net/netfilter/ipvs/ip_vs_ctl.c   |  4 ++--
 net/netfilter/ipvs/ip_vs_dh.c|  2 +-
 net/netfilter/ipvs/ip_vs_lblc.c  |  2 +-
 net/netfilter/ipvs/ip_vs_lblcr.c |  4 ++--
 net/netfilter/ipvs/ip_vs_sh.c|  2 +-
 net/netfilter/ipvs/ip_vs_wrr.c   |  2 +-
 net/netfilter/nf_conntrack_netlink.c |  2 +-
 net/netfilter/nf_conntrack_proto.c   |  2 +-
 net/netfilter/nf_nat_core.c  |  2 +-
 net/netfilter/nf_tables_api.c| 24 
 net/netfilter/nfnetlink.c|  2 +-
 net/netfilter/xt_TEE.c   |  2 +-
 12 files changed, 25 insertions(+), 25 deletions(-)

-- 
2.7.4



Re: [PATCH net-next] stmmac: call stmmac_init_phy from stmmac_dvr_probe

2017-03-21 Thread Niklas Cassel
On 03/20/2017 11:07 PM, Florian Fainelli wrote:
>
> (snip)
>>
>> However, it is kind of sad that drivers are so inconsistent of what goes
>> in probe and what goes in ndo_open...which is tied together with the
>> whole mess of when certain ethtool commands work or do not work.
> Well, inconsistent here is kind of big statement, what I meant to say is
> that your proposed change actually makes thing inconsistent.

What I mean is that it is about 50/50 if something e.g. phy_connect
is called from probe or from ndo_open.
This is what I think is inconsistent.

git grep -p -E "phy_connect\(|phy_connect_direct\(" drivers/net/ethernet/ | 
grep open | wc -l
12

git grep -p -E "phy_connect\(|phy_connect_direct\(" drivers/net/ethernet/ | 
grep probe | wc -l
27
even if we exclude *_mii_probe/*_mdio_probe which are done
git grep -p mii_probe drivers/net/ethernet/ | grep open | wc -l
6
git grep -p mdio_probe drivers/net/ethernet/ | grep open | wc -l
2

phy_connect done from probe:
27-6-2=19

phy_connect done from ndo_open:
12+6+2=20


>
>> Do you know of a good way to avoid the -EBUSY in 
>> stmmac_ethtool_get_link_ksettings,
>> but still keep phy_connect in ndo_open?
> Let me rephrase this: doing an ethtool operation on an interface that is
> not open is not a defined behavior which adheres to a contract with the
> kernel. ethtool operations on interfaces that are DOWN, may succeed if
> they do not involve a piece of hardware that needs to be active (e.g:
> the PHY) but there is no guarantee that a) the change is immediately
> applied, or b) that the results are consistent.
>
> The best thing to do IMHO is just silence the warning, return an error
> coed, and come back configuring the interface at a later time when it is
> guaranteed to be operational.

Thank you for your feedback. I agree with you,
silencing the warning would be the best way forward.
David, please ignore this patch.



However, since ethtool is a user interface, I think that it would
have been nice if it wasn't so driver specific regarding to if a
command works before the interface is open or not.

If the user does some ethtool operation that affects e.g. the PHY
before the interface is open, perhaps there is a way to save this
setting so it could be applied when the resource is available.

For the PHY case, net_device has a pointer to a phy_device,
register_netdev could create a dummy phy_device if
ndev->phy_device is NULL, that way changes could be saved
and applied when phy_connect replaces the dummy device
(or perhaps when phy_start() is called).
(If it isn't a dummy phy_device, changes could be applied immediately.)
This way it would not matter if phy_connect is done from probe
or from ndo_open.


Re: linux-next-20170320 break stmmac on dwmac-sunxi

2017-03-21 Thread Giuseppe CAVALLARO

+ Joao

please Joao, could you do a check if new changes have any impact on that?

peppe

On 3/20/2017 8:54 PM, Corentin Labbe wrote:

Hello

Just pushed next-20170320 to my boards and stmmac stop working on both intree 
dwmac-sunxi and my dev dwmac-sun8i.
It seems that interrupts never fire, and transmit queue timeout.
I will try to bisect this problem but perhaps other people could try to 
reproduce it.

Regards
Corentin Labbe





[PATCH net-next v2 1/5] dt-bindings: net: dsa: add Mediatek MT7530 binding

2017-03-21 Thread sean.wang
From: Sean Wang 

Add device-tree binding for Mediatek MT7530 switch.

Cc: devicet...@vger.kernel.org
Signed-off-by: Sean Wang 
---
 .../devicetree/bindings/net/dsa/mt7530.txt | 92 ++
 1 file changed, 92 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/mt7530.txt

diff --git a/Documentation/devicetree/bindings/net/dsa/mt7530.txt 
b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
new file mode 100644
index 000..a9bc27b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/dsa/mt7530.txt
@@ -0,0 +1,92 @@
+Mediatek MT7530 Ethernet switch
+
+
+Required properties:
+
+- compatible: Must be compatible = "mediatek,mt7530";
+- #address-cells: Must be 1.
+- #size-cells: Must be 0.
+- mediatek,mcm: Boolean; if defined, indicates that either MT7530 is the part
+   on multi-chip module belong to MT7623A has or the remotely standalone
+   chip as the function MT7623N reference board provided for.
+- core-supply: Phandle to the regulator node necessary for the core power.
+- io-supply: Phandle to the regulator node necessary for the I/O power.
+   See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
+   for details for the regulator setup on these boards.
+
+If the property mediatek,mcm isn't defined, following property is required
+
+- reset-gpios: Should be a gpio specifier for a reset line.
+
+Else, following properties are required
+
+- resets : Phandle pointing to the system reset controller with
+   line index for the ethsys.
+- reset-names : Should be set to "mcm".
+
+Required properties for the child nodes within ports container:
+
+- reg: Port address described must be 6 for CPU port and from 0 to 5 for
+   user ports.
+- phy-mode: String, must be either "trgmii" or "rgmii" for port labeled
+"cpu".
+
+See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
+required, optional properties and how the integrated switch subnodes must
+be specified.
+
+Example:
+
+   &mdio0 {
+   switch@0 {
+   compatible = "mediatek,mt7530";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+
+   core-supply = <&mt6323_vpa_reg>;
+   io-supply = <&mt6323_vemc3v3_reg>;
+   reset-gpios = <&pio 33 0>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+   port@0 {
+   reg = <0>;
+   label = "lan0";
+   };
+
+   port@1 {
+   reg = <1>;
+   label = "lan1";
+   };
+
+   port@2 {
+   reg = <2>;
+   label = "lan2";
+   };
+
+   port@3 {
+   reg = <3>;
+   label = "lan3";
+   };
+
+   port@4 {
+   reg = <4>;
+   label = "wan";
+   };
+
+   port@6 {
+   reg = <6>;
+   label = "cpu";
+   ethernet = <&gmac0>;
+   phy-mode = "trgmii";
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+   };
+   };
+   };
+   };
-- 
1.9.1



[PATCH net-next v2 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch

2017-03-21 Thread sean.wang
From: Sean Wang 

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on
Mediatek router platforms such as MT7623A or MT7623N platform which
includes 7-port Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY.
Among these ports, The port from 0 to 4 are the user ports connecting
with the remote devices while the port 5 and 6 are the CPU ports
connecting into Mediatek Ethernet GMAC.

For port 6, it can communicate with the CPU via Mediatek Ethernet GMAC
through either the TRGMII or RGMII which could be controlled by phy-mode
in the dt-bindings to specify which mode is preferred to use. And for
port 5, only RGMII can be specified. However, currently, only port 6 is
being supported in this DSA driver.

The driver is made with the reference to qca8k and other existing DSA
driver. The most of the essential callbacks of the DSA are already
support in the driver, including tag insert for user port distinguishing,
port control, bridge offloading, STP setup and ethtool operation to allow
DSA to model each user port into a standalone netdevice as the other DSA
driver had done.

Signed-off-by: Sean Wang 
Signed-off-by: Landen Chao 
---
 drivers/net/dsa/Kconfig  |8 +
 drivers/net/dsa/Makefile |2 +-
 drivers/net/dsa/mt7530.c | 1172 ++
 drivers/net/dsa/mt7530.h |  382 +++
 4 files changed, 1563 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/dsa/mt7530.c
 create mode 100644 drivers/net/dsa/mt7530.h

diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index 0659846..5b322b4 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -34,4 +34,12 @@ config NET_DSA_QCA8K
  This enables support for the Qualcomm Atheros QCA8K Ethernet
  switch chips.
 
+config NET_DSA_MT7530
+   tristate "Mediatek MT7530 Ethernet switch support"
+   depends on NET_DSA
+   select NET_DSA_TAG_MTK
+   ---help---
+ This enables support for the Mediatek MT7530 Ethernet switch
+ chip.
+
 endmenu
diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile
index a3c9416..8e629c1 100644
--- a/drivers/net/dsa/Makefile
+++ b/drivers/net/dsa/Makefile
@@ -2,6 +2,6 @@ obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 obj-$(CONFIG_NET_DSA_BCM_SF2)  += bcm-sf2.o
 bcm-sf2-objs   := bcm_sf2.o bcm_sf2_cfp.o
 obj-$(CONFIG_NET_DSA_QCA8K)+= qca8k.o
-
+obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o
 obj-y  += b53/
 obj-y  += mv88e6xxx/
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
new file mode 100644
index 000..99e5485
--- /dev/null
+++ b/drivers/net/dsa/mt7530.c
@@ -0,0 +1,1172 @@
+/*
+ * Mediatek MT7530 DSA Switch driver
+ * Copyright (C) 2017 Sean Wang 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mt7530.h"
+
+/* String, offset, and register size in bytes if different from 4 bytes */
+static const struct mt7530_mib_desc mt7530_mib[] = {
+   MIB_DESC(1, 0x00, "TxDrop"),
+   MIB_DESC(1, 0x04, "TxCrcErr"),
+   MIB_DESC(1, 0x08, "TxUnicast"),
+   MIB_DESC(1, 0x0c, "TxMulticast"),
+   MIB_DESC(1, 0x10, "TxBroadcast"),
+   MIB_DESC(1, 0x14, "TxCollision"),
+   MIB_DESC(1, 0x18, "TxSingleCollision"),
+   MIB_DESC(1, 0x1c, "TxMultipleCollision"),
+   MIB_DESC(1, 0x20, "TxDeferred"),
+   MIB_DESC(1, 0x24, "TxLateCollision"),
+   MIB_DESC(1, 0x28, "TxExcessiveCollistion"),
+   MIB_DESC(1, 0x2c, "TxPause"),
+   MIB_DESC(1, 0x30, "TxPktSz64"),
+   MIB_DESC(1, 0x34, "TxPktSz65To127"),
+   MIB_DESC(1, 0x38, "TxPktSz128To255"),
+   MIB_DESC(1, 0x3c, "TxPktSz256To511"),
+   MIB_DESC(1, 0x40, "TxPktSz512To1023"),
+   MIB_DESC(1, 0x44, "Tx1024ToMax"),
+   MIB_DESC(2, 0x48, "TxBytes"),
+   MIB_DESC(1, 0x60, "RxDrop"),
+   MIB_DESC(1, 0x64, "RxFiltering"),
+   MIB_DESC(1, 0x6c, "RxMulticast"),
+   MIB_DESC(1, 0x70, "RxBroadcast"),
+   MIB_DESC(1, 0x74, "RxAlignErr"),
+   MIB_DESC(1, 0x78, "RxCrcErr"),
+   MIB_DESC(1, 0x7c, "RxUnderSizeErr"),
+   MIB_DESC(1, 0x80, "RxFragErr"),
+   MIB_DESC(1, 0x84, "RxOverSzErr"),
+   MIB_DESC(1, 0x88, "RxJabberErr"),
+   MIB_DESC(1, 0x8c, "RxPause"),
+   MIB_DESC(1, 0x90, "RxPktSz64"),
+   MIB_DESC(1, 0x94, "RxPktSz65To127"),
+   MIB_DESC(1, 0x98, "RxPktSz128To255"),
+   MIB_DESC(1, 0

[PATCH net-next v2 0/5] net-next: dsa: add Mediatek MT7530 support

2017-03-21 Thread sean.wang
From: Sean Wang 

MT7530 is a 7-ports Gigabit Ethernet Switch that could be found on
Mediatek router platforms such as MT7623A or MT7623N which includes 7-port
Gigabit Ethernet MAC and 5-port Gigabit Ethernet PHY. Among these ports,
The port from 0 to 4 are the user ports connecting with the remote devices
while the port 5 and 6 are the CPU ports connecting into Mediatek Ethernet
GMAC.

The patch series integrated Mediatek MT7530 into DSA support which
includes the most of the essential callbacks such as tag insertion for
port distinguishing, port control, bridge offloading, STP setup and
ethtool operations to allow DSA to model each user port into independently
standalone netdevice as the other DSA driver had done.

Changes since v1:
- rebased into 4.11-rc1
- refined binding document including below five items 
- changed the type of mediatek,mcm into bool
- used reset controller binding for MCM reset and removed "mediatek,ethsys"
  property from binding
- reused CPU port's ethernet Phandle instead of creating new one and removed
  "mediatek,ethernet" property from binding
- aligned naming for GPIO reset with dsa/marvell.txt
- added phy-mode as required property child nodes within ports container
- handled gpio reset with devm_gpiod_* API
- refined comment words
- removed condition for CDM setting since the setup looks both fine for all 
cases
- allowed of_find_net_device_by_node() working with pointing the device node 
into
  real netdev instance
- fixed Kbuild warnings

Sean Wang (5):
  dt-bindings: net: dsa: add Mediatek MT7530 binding
  net-next: dsa: add Mediatek tag RX/TX handler
  net-next: ethernet: mediatek: add CDM able to recognize the tag for
DSA
  net-next: ethernet: mediatek: add device_node of GMAC pointing into
the netdev instance
  net-next: dsa: add dsa support for Mediatek MT7530 switch

 .../devicetree/bindings/net/dsa/mt7530.txt |   92 ++
 drivers/net/dsa/Kconfig|8 +
 drivers/net/dsa/Makefile   |2 +-
 drivers/net/dsa/mt7530.c   | 1172 
 drivers/net/dsa/mt7530.h   |  382 +++
 drivers/net/ethernet/mediatek/mtk_eth_soc.c|8 +
 drivers/net/ethernet/mediatek/mtk_eth_soc.h|4 +
 include/net/dsa.h  |1 +
 net/dsa/Kconfig|2 +
 net/dsa/Makefile   |1 +
 net/dsa/dsa.c  |3 +
 net/dsa/dsa_priv.h |3 +
 net/dsa/tag_mtk.c  |  117 ++
 13 files changed, 1794 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/mt7530.txt
 create mode 100644 drivers/net/dsa/mt7530.c
 create mode 100644 drivers/net/dsa/mt7530.h
 create mode 100644 net/dsa/tag_mtk.c

-- 
1.9.1



[PATCH net-next v2 3/5] net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA

2017-03-21 Thread sean.wang
From: Sean Wang 

The patch adds the setup for allowing CDM can recognize these packets with
carrying port-distinguishing tag. Otherwise, these tagging packets will be
handled incorrectly by CDM. The setup is working out for general untag
packets as well.

Signed-off-by: Sean Wang 
Signed-off-by: Landen Chao 
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++
 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 9e75768..c21ed99 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1846,6 +1846,12 @@ static int mtk_hw_init(struct mtk_eth *eth)
/* GE2, Force 1000M/FD, FC ON */
mtk_w32(eth, MAC_MCR_FIXED_LINK, MTK_MAC_MCR(1));
 
+   /* Indicates CDM to parse the MTK special tag from CPU
+* which also is working out for untag packets.
+*/
+   val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
+   mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
+
/* Enable RX VLan Offloading */
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
 
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 99b1c8e..996024d 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -70,6 +70,10 @@
 /* Frame Engine Interrupt Grouping Register */
 #define MTK_FE_INT_GRP 0x20
 
+/* CDMP Ingress Control Register */
+#define MTK_CDMQ_IG_CTRL   0x1400
+#define MTK_CDMQ_STAG_EN   BIT(0)
+
 /* CDMP Exgress Control Register */
 #define MTK_CDMP_EG_CTRL   0x404
 
-- 
1.9.1



[PATCH net-next v2 4/5] net-next: ethernet: mediatek: add device_node of GMAC pointing into the netdev instance

2017-03-21 Thread sean.wang
From: Sean Wang 

the patch adds the setup of the corresponding device node of GMAC into the
netdev instance which could allow other modules such as DSA to find the
instance through the node in dt-bindings using of_find_net_device_by_node()
call.

Signed-off-by: Sean Wang 
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index c21ed99..84b09a4 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2323,6 +2323,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct 
device_node *np)
eth->netdev[id]->ethtool_ops = &mtk_ethtool_ops;
 
eth->netdev[id]->irq = eth->irq[0];
+   eth->netdev[id]->dev.of_node = np;
+
return 0;
 
 free_netdev:
-- 
1.9.1



Re: mlx5e backports for v4.9 -stable

2017-03-21 Thread Saeed Mahameed
On Mon, Mar 20, 2017 at 11:32 PM, Saeed Mahameed  wrote:
>
>
> On 03/17/2017 02:06 AM, David Miller wrote:
>>
>> Commits:
>>
>> 
>> From b0d4660b4cc52e6477ca3a43435351d565dfcedc Mon Sep 17 00:00:00 2001
>> From: Tariq Toukan 
>> Date: Wed, 22 Feb 2017 17:20:14 +0200
>> Subject: [PATCH] net/mlx5e: Fix broken CQE compression initialization
>> 
>>
>> and
>>
>> 
>> From 6dc4b54e77282caf17f0ff72aa32dd296037fbc0 Mon Sep 17 00:00:00 2001
>> From: Saeed Mahameed 
>> Date: Wed, 22 Feb 2017 17:20:15 +0200
>> Subject: [PATCH] net/mlx5e: Update MPWQE stride size when modifying CQE
>>  compress state
>> 
>>
>> do not apply even closely to v4.9 while I was working on -stable backports.
>>
>> Please provide proper backports of these two patches if you want them to
>> show up in v4.9 -stable.
>>
>
> Hi Dave,
>
> thank you for trying, we will provide the patches, but I don't know what is 
> the right procedure
> to do so.
>
> is it ok to post the patches applied on top tag v4.9.16  of 
> kernel/git/stable/linux-stable.git ?
> to whom should I send them ?
>

Actually, it looks like the fixes tag is not accurate, the bug is exposed only
with the new user control of CQE compression feature which should have
took care of
those issues, 9bcc86064bb5 ("net/mlx5e: Add CQE compression user control")
and this patch was only introduced in 4.10.

No need to apply those patches into 4.9-stable.

Sorry for the inconvenience.

thanks,
Saeed.


[PATCH net-next v2 2/5] net-next: dsa: add Mediatek tag RX/TX handler

2017-03-21 Thread sean.wang
From: Sean Wang 

Add the support for the 4-bytes tag for DSA port distinguishing inserted
allowing receiving and transmitting the packet via the particular port.
The tag is being added after the source MAC address in the ethernet
header.

Signed-off-by: Sean Wang 
Signed-off-by: Landen Chao 
Reviewed-by: Andrew Lunn 
Reviewed-by: Florian Fainelli 
---
 include/net/dsa.h  |   1 +
 net/dsa/Kconfig|   2 +
 net/dsa/Makefile   |   1 +
 net/dsa/dsa.c  |   3 ++
 net/dsa/dsa_priv.h |   3 ++
 net/dsa/tag_mtk.c  | 117 +
 6 files changed, 127 insertions(+)
 create mode 100644 net/dsa/tag_mtk.c

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4e13e69..3276547 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -31,6 +31,7 @@ enum dsa_tag_protocol {
DSA_TAG_PROTO_EDSA,
DSA_TAG_PROTO_BRCM,
DSA_TAG_PROTO_QCA,
+   DSA_TAG_PROTO_MTK,
DSA_TAG_LAST,   /* MUST BE LAST */
 };
 
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 9649238..d78789b 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -31,4 +31,6 @@ config NET_DSA_TAG_TRAILER
 config NET_DSA_TAG_QCA
bool
 
+config NET_DSA_TAG_MTK
+   bool
 endif
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index 31d3437..9b1d478 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -8,3 +8,4 @@ dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
 dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
 dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
 dsa_core-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o
+dsa_core-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index b6d4f6a..617f736 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -53,6 +53,9 @@ static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff 
*skb,
 #ifdef CONFIG_NET_DSA_TAG_QCA
[DSA_TAG_PROTO_QCA] = &qca_netdev_ops,
 #endif
+#ifdef CONFIG_NET_DSA_TAG_MTK
+   [DSA_TAG_PROTO_MTK] = &mtk_netdev_ops,
+#endif
[DSA_TAG_PROTO_NONE] = &none_ops,
 };
 
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 0706a51..2a31399 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -85,4 +85,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device 
*parent,
 /* tag_qca.c */
 extern const struct dsa_device_ops qca_netdev_ops;
 
+/* tag_mtk.c */
+extern const struct dsa_device_ops mtk_netdev_ops;
+
 #endif
diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c
new file mode 100644
index 000..833a9d6
--- /dev/null
+++ b/net/dsa/tag_mtk.c
@@ -0,0 +1,117 @@
+/*
+ * Mediatek DSA Tag support
+ * Copyright (C) 2017 Landen Chao 
+ *   Sean Wang 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include 
+#include "dsa_priv.h"
+
+#define MTK_HDR_LEN4
+#define MTK_HDR_RECV_SOURCE_PORT_MASK  GENMASK(2, 0)
+#define MTK_HDR_XMIT_DP_BIT_MASK   GENMASK(5, 0)
+
+static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
+   struct net_device *dev)
+{
+   struct dsa_slave_priv *p = netdev_priv(dev);
+   u8 *mtk_tag;
+
+   if (skb_cow_head(skb, MTK_HDR_LEN) < 0)
+   goto out_free;
+
+   skb_push(skb, MTK_HDR_LEN);
+
+   memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN);
+
+   /* Build the tag after the MAC Source Address */
+   mtk_tag = skb->data + 2 * ETH_ALEN;
+   mtk_tag[0] = 0;
+   mtk_tag[1] = (1 << p->dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
+   mtk_tag[2] = 0;
+   mtk_tag[3] = 0;
+
+   return skb;
+
+out_free:
+   kfree_skb(skb);
+   return NULL;
+}
+
+static int mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
+  struct packet_type *pt, struct net_device *orig_dev)
+{
+   struct dsa_switch_tree *dst = dev->dsa_ptr;
+   struct dsa_switch *ds;
+   int port;
+   __be16 *phdr, hdr;
+
+   if (unlikely(!dst))
+   goto out_drop;
+
+   skb = skb_unshare(skb, GFP_ATOMIC);
+   if (!skb)
+   goto out;
+
+   if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
+   goto out_drop;
+
+   /* The MTK header is added by the switch between src addr
+* and ethertype at this point, skb->data points to 2 bytes
+* after src addr so header should be 2 bytes right before.
+*/
+   phdr = (__be16 *)(skb->data - 2);
+   hdr = ntohs(*phdr);
+
+   /* Remove MTK tag and recalculate checksum. */
+   skb_pull_rcsum(skb, MTK_HDR_LEN);
+
+   memmove(skb->data - ETH_HLEN,
+   skb->da

[PATCH net v1 1/1] tipc: fix nametbl deadlock at tipc_nametbl_unsubscribe

2017-03-21 Thread Parthasarathy Bhuvaragan
From: Ying Xue 

Until now, tipc_nametbl_unsubscribe() is called at subscriptions
reference count cleanup. Usually the subscriptions cleanup is
called at subscription timeout or at subscription cancel or at
subscriber delete.

We have ignored the possibility of this being called from other
locations, which causes deadlock as we try to grab the
tn->nametbl_lock while holding it already.

   CPU1: CPU2:
-- 
tipc_nametbl_publish
spin_lock_bh(&tn->nametbl_lock)
tipc_nametbl_insert_publ
tipc_nameseq_insert_publ
tipc_subscrp_report_overlap
tipc_subscrp_get
tipc_subscrp_send_event
 tipc_close_conn
 tipc_subscrb_release_cb
 tipc_subscrb_delete
 tipc_subscrp_put
tipc_subscrp_put
tipc_subscrp_kref_release
tipc_nametbl_unsubscribe
spin_lock_bh(&tn->nametbl_lock)
<>

   CPU1:  CPU2:
-- 
tipc_nametbl_stop
spin_lock_bh(&tn->nametbl_lock)
tipc_purge_publications
tipc_nameseq_remove_publ
tipc_subscrp_report_overlap
tipc_subscrp_get
tipc_subscrp_send_event
 tipc_close_conn
 tipc_subscrb_release_cb
 tipc_subscrb_delete
 tipc_subscrp_put
tipc_subscrp_put
tipc_subscrp_kref_release
tipc_nametbl_unsubscribe
spin_lock_bh(&tn->nametbl_lock)
<>

In this commit, we advance the calling of tipc_nametbl_unsubscribe()
from the refcount cleanup to the intended callers.

Fixes: d094c4d5f5c7 ("tipc: add subscription refcount to avoid invalid delete")
Reported-by: John Thompson 
Acked-by: Jon Maloy 
Signed-off-by: Ying Xue 
Signed-off-by: Parthasarathy Bhuvaragan 
---
 net/tipc/subscr.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 9d94e65d0894..271cd66e4b3b 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -141,6 +141,11 @@ void tipc_subscrp_report_overlap(struct tipc_subscription 
*sub, u32 found_lower,
 static void tipc_subscrp_timeout(unsigned long data)
 {
struct tipc_subscription *sub = (struct tipc_subscription *)data;
+   struct tipc_subscriber *subscriber = sub->subscriber;
+
+   spin_lock_bh(&subscriber->lock);
+   tipc_nametbl_unsubscribe(sub);
+   spin_unlock_bh(&subscriber->lock);
 
/* Notify subscriber of timeout */
tipc_subscrp_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper,
@@ -173,7 +178,6 @@ static void tipc_subscrp_kref_release(struct kref *kref)
struct tipc_subscriber *subscriber = sub->subscriber;
 
spin_lock_bh(&subscriber->lock);
-   tipc_nametbl_unsubscribe(sub);
list_del(&sub->subscrp_list);
atomic_dec(&tn->subscription_count);
spin_unlock_bh(&subscriber->lock);
@@ -205,6 +209,7 @@ static void tipc_subscrb_subscrp_delete(struct 
tipc_subscriber *subscriber,
if (s && memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr)))
continue;
 
+   tipc_nametbl_unsubscribe(sub);
tipc_subscrp_get(sub);
spin_unlock_bh(&subscriber->lock);
tipc_subscrp_delete(sub);
-- 
2.1.4



Re: [Bridge] [PATCH net] bridge: ebtables: fix reception of frames DNAT-ed to bridge device

2017-03-21 Thread Pablo Neira Ayuso
On Tue, Mar 21, 2017 at 01:09:47AM +0100, Linus Lüssing wrote:
> On Sun, Mar 19, 2017 at 05:55:06PM +0100, Linus Lüssing wrote:
> > On Fri, Mar 17, 2017 at 02:10:44PM +0100, Pablo Neira Ayuso wrote:
> > > Wait.
> > > 
> > > May this break local multicast listener that are bound to the bridge
> > > interface? Assuming the bridge interface got an IP address, and that
> > > there is local multicast listener.
> > > 
> > > Missing anything here?
> > 
> > Hm, for multicast packets usually the code path a few lines
> > later in br_handle_frame_finish() should be taken instead.
> > 
> > But you might be right for IP multicast packets with a unicast MAC
> > destination (due to whatever reason, for instance via DNAT'ing
> > again).
> > 
> > Will check that - thanks!
> 
> Ok, I tested DNAT'ing an IP multicast packet to the unicast MAC address
> of the bridge interface.
> 
> Both ping-ing to an IPv4 and IPv6 multicast listener on br0 worked
> and was replied to fine, both with or without changing skb->pkt_type
> from PACKET_MULTICAST to PACKET_HOST.
> ("$ ping 224.1.0.123" and "$ ping6 ff02::1:ff40:707c%in0" from a
>  network namespace, tied into the bridge via veth)
> 
> Also, a DNAT'ed PACKET_BROADCAST worked, with or without changing
> it to PACKET_HOST.
> 
> I also checked via tcpdump that the destination MAC was changed
> successfully.

Thanks for looking into this more in depth.

> So, so far I wasn't able to find any bugs with the current
> patch. But I think I like the idea of leaving the skb->pkt_type
> unaltered for PACKET_MULTICAST and PACKET_BROADCAST, seems cleaner.

Yes, and matching on skb->pkt_type would not break from netfilter.

> I'd just add an "if (skb->pkt_type == PACKET_OTHERHOST)" check
> then and resend a PATCH v2.

Thanks.


Re: [RFC PATCH] net: phy: Don't miss phy_suspend() on PHY_HALTED for PHYs with interrupts

2017-03-21 Thread Roger Quadros
On 20/03/17 18:41, Florian Fainelli wrote:
> On 03/16/2017 12:46 AM, Roger Quadros wrote:
>> On 15/03/17 17:49, Andrew Lunn wrote:
>>> On Wed, Mar 15, 2017 at 05:00:08PM +0200, Roger Quadros wrote:
 Andrew,

 On 15/03/17 16:08, Andrew Lunn wrote:
> On Wed, Mar 15, 2017 at 03:51:27PM +0200, Roger Quadros wrote:
>> Since commit 3c293f4e08b5 ("net: phy: Trigger state machine on state 
>> change and not polling.")
>> phy_suspend() doesn't get called as part of phy_stop() for PHYs using
>> interrupts because the phy state machine is never triggered after a 
>> phy_stop().
>>
>> Explicitly trigger the PHY state machine so that it can
>> see the new PHY state (HALTED) and suspend the PHY.
>>
>> Signed-off-by: Roger Quadros 
>
> Hi Roger
>
> This seems sensible. It mirrors what phy_start() does.
>
> Reviewed-by: Andrew Lunn 

 The reason for this being an RFC was the following comment just before
 where I add the phy_trigger_machine()

 /* Cannot call flush_scheduled_work() here as desired because
  * of rtnl_lock(), but PHY_HALTED shall guarantee phy_change()
  * will not reenable interrupts.
  */

 Is this comment still applicable? If yes, is it OK to call
 phy_trigger_machine() there?
>>>
>>> Humm, good question.
>>>
>>> My _guess_ would be, calling it with sync=True could
>>> deadlock. sync=False is probably safe. But lets see what Florian says.
>>
>> I agree that we should use phy_trigger_machine() with sync=False.
>>
>>>

>
> It does however lead to a follow up question. Are there other places
> phydev->state is changed and it is missing a phy_trigger_machine()?
>

 One other place I think we should add phy_trigger_machine() is 
 phy_start_aneg().
>>>
>>> Humm, that might get us into a tight loop.
>>>
>>> phy_start_aneg() kicks the phy driver to start autoneg and sets
>>> phydev->state = PHY_AN.
>>>
>>> phy_trigger_machine() triggers the state machine immediately. 
>>>
>>> In state PHY_AN, we check if aneg is done. If not, it sets needs_aneg
>>> = true. At the end of the state machine, this then calls
>>> phy_start_aneg(), and it all starts again.
>>>
>>> We are missing the 1s delay we have with polling. So for
>>> phy_start_aneg(), we might need a phy_delayed_trigger_machine(), which
>>> waits a second before doing anything?
>>
>> I think that should do the trick.
>>
>> How about this?
> 
> This sounds like a possible fix indeed, however I would like to better
> assess the impact on non interrupt driven PHYs before rolling such a change.

Is it safer if I add a check to do this only for interrupt driven PHYs?

e.g.

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 4b855f2..e0f5755 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -630,6 +630,9 @@ int phy_start_aneg(struct phy_device *phydev)
 
 out_unlock:
mutex_unlock(&phydev->lock);
+   if (!err && phy_interrupt_is_valid(phydev))
+   queue_delayed_work(system_power_efficient_wq, 
&phydev->state_queue, HZ);
+
return err;
 }
 EXPORT_SYMBOL(phy_start_aneg);
-- 
2.7.4

-- 
cheers,
-roger


Re: [net-next 05/13] i40e: rework exit flow of i40e_add_fdir_ethtool

2017-03-21 Thread Sergei Shtylyov

Hello!

On 3/21/2017 2:47 AM, Jeff Kirsher wrote:


From: Jacob Keller 

Refactor the exit flow of the i40e_add_fdir_ethtool function. Move the
input_label to the end of the function, removing the dependency on


   I don't see 'input_label' anywhere. Perhaps 'free_input' label was meant?


having a non-zero return value. Add a comment explaining why it is ok
not to free the fdir data structure, because the structure is now stored
in the fdir_filter_list.

Change-Id: I723342181d59cd0c9f3b31140c37961ba37bb242
Signed-off-by: Jacob Keller 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c 
b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 7a22b473dbdd..d16a5a6b24fc 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -2828,12 +2828,19 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
}

ret = i40e_add_del_fdir(vsi, input, true);
-free_input:
if (ret)
-   kfree(input);
-   else
-   i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
+   goto free_input;
+
+   /* Add the input filter to the fdir_input_list, possibly replacing
+* a previous filter. Do not free the input structure after adding it
+* to the list as this would cause a use-after-free bug.
+*/
+   i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);

+   return 0;
+
+free_input:
+   kfree(input);
return ret;
 }


MBR, Sergei



Re: linux-next-20170320 breaks stmmac on meson (Amlogic S905GXBB)

2017-03-21 Thread Joao Pinto

Hi Heiner and Corentin,

Às 9:58 PM de 3/20/2017, Heiner Kallweit escreveu:
> As reported by Corentin Labbe before:
> stmmac in the latest next kernel is broken also on meson8b.
> 
> The following commit seems to create the trouble:
> 6deee2221e11 "net: stmmac: prepare dma op mode config for multiple queues"
> 
> I also get queue timeout errors.

>From what you are describing it seems that the tx op mode is not being
configured by some reason and so it is not enabled.

Please check if this path is being executed:

stmmac_mtl_configuration >> stmmac_dma_operation_mode >> 
priv->hw->dma->dma_tx_mode

It must iterate by all the available channels / queues, that should be =1 since
I assume you have a single queue:

if (priv->synopsys_id >= DWMAC_CORE_4_00) {
for (chan = 0; chan < rx_channels_count; chan++)
priv->hw->dma->dma_rx_mode(priv->ioaddr, rxmode, chan,
   rxfifosz);

for (chan = 0; chan < tx_channels_count; chan++)
priv->hw->dma->dma_tx_mode(priv->ioaddr, txmode, chan);

Could you please check if RX and TX op mode are being programmed?

The rx and tx queue counters are initialized in stmmac_mtl_setup() function
(stmmac_platform.c). If they are not declared in DT they assume the default
value of 1.

> 
> Rgds, Heiner
> 

Thanks.


[PATCH net-next] net: greth: Utilize of_get_mac_address()

2017-03-21 Thread Tobias Klauser
Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address() which
looks up the MAC address using the 3 typical property names.

Signed-off-by: Tobias Klauser 
---
 drivers/net/ethernet/aeroflex/greth.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/aeroflex/greth.c 
b/drivers/net/ethernet/aeroflex/greth.c
index 9f7422ada704..d8e133ced7b8 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1454,11 +1455,10 @@ static int greth_of_probe(struct platform_device *ofdev)
break;
}
if (i == 6) {
-   const unsigned char *addr;
-   int len;
-   addr = of_get_property(ofdev->dev.of_node, "local-mac-address",
-   &len);
-   if (addr != NULL && len == 6) {
+   const u8 *addr;
+
+   addr = of_get_mac_address(ofdev->dev.of_node);
+   if (addr) {
for (i = 0; i < 6; i++)
macaddr[i] = (unsigned int) addr[i];
} else {
-- 
2.11.0




Re: [PATCH net-next 1/8] ptr_ring: introduce batch dequeuing

2017-03-21 Thread Sergei Shtylyov

Hello!

On 3/21/2017 7:04 AM, Jason Wang wrote:


Signed-off-by: Jason Wang 
---
 include/linux/ptr_ring.h | 65 
 1 file changed, 65 insertions(+)

diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 6c70444..4771ded 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -247,6 +247,22 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r)
return ptr;
 }

+static inline int __ptr_ring_consume_batched(struct ptr_ring *r,
+void **array, int n)
+{
+   void *ptr;
+   int i = 0;
+
+   while (i < n) {


   Hm, why not *for*?


+   ptr = __ptr_ring_consume(r);
+   if (!ptr)
+   break;
+   array[i++] = ptr;
+   }
+
+   return i;
+}
+
 /*
  * Note: resize (below) nests producer lock within consumer lock, so if you
  * call this in interrupt or BH context, you must disable interrupts/BH when
@@ -297,6 +313,55 @@ static inline void *ptr_ring_consume_bh(struct ptr_ring *r)

[...]

MBR, Sergei



RE: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t

2017-03-21 Thread Reshetova, Elena
> On 03/20/2017 10:37 AM, Elena Reshetova wrote:
> [...]
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index ebaeaf2..389cb8d 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -928,7 +928,7 @@ static void sk_filter_release_rcu(struct rcu_head *rcu)
> >*/
> >   static void sk_filter_release(struct sk_filter *fp)
> >   {
> > -   if (atomic_dec_and_test(&fp->refcnt))
> > +   if (refcount_dec_and_test(&fp->refcnt))
> > call_rcu(&fp->rcu, sk_filter_release_rcu);
> >   }
> >
> > @@ -943,20 +943,27 @@ void sk_filter_uncharge(struct sock *sk, struct
> sk_filter *fp)
> >   /* try to charge the socket memory if there is space available
> >* return true on success
> >*/
> > -bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
> > +bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)
> 
> And this then becomes: static bool __sk_filter_charge(...)

Ups, I guess I am getting too tired of all these patch sendings, so more and 
more mistakes slide in. 
Will try switching to smth else to get attention back in order. 

> 
> >   {
> > u32 filter_size = bpf_prog_size(fp->prog->len);
> >
> > /* same check as in sock_kmalloc() */
> > if (filter_size <= sysctl_optmem_max &&
> > atomic_read(&sk->sk_omem_alloc) + filter_size <
> sysctl_optmem_max) {
> > -   atomic_inc(&fp->refcnt);
> > atomic_add(filter_size, &sk->sk_omem_alloc);
> > return true;
> > }
> > return false;
> >   }
> 
> Since here is just all in slow-path, looks fine to me if the above
> is addressed as well in v3:
> 
> Acked-by: Daniel Borkmann 
> 
> Please make sure you add [PATCH net-next] in your subject in future
> so that it's clear which tree this goes to.

Thank you very much! Will do. 

Best Regards,
Elena.
> 
> Thanks,
> Daniel


Re: [PATCH net-stable] ipv4: keep skb->dst around in presence of IP options

2017-03-21 Thread Ben Hutchings
On Mon, 2017-03-20 at 21:23 -0700, Eric Dumazet wrote:
> From: Eric Dumazet 
> 
> Upstream commit 34b2cef20f19c87999fff3da4071e66937db9644
> ("ipv4: keep skb->dst around in presence of IP options") incorrectly
> root caused commit d826eb14ecef ("ipv4: PKTINFO doesnt need dst
> reference") as bug origin.
> 
> This patch should fix the issue for 3.2.xx stable kernels, since IPv4
> options seem to get more traction these days, after years of oblivion
> ;)
> 
> Fixes: f84af32cbca70 ("net: ip_queue_rcv_skb() helper"))
> Signed-off-by: Eric Dumazet 
> Reported-by: Anarcheuz Fritz 
> ---
> 
> This is a backport for 3.2 kernels.

Added to the queue, thanks.

Ben.

> diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
> index b3648bbef0da..a6e1eeb02267 100644
> --- a/net/ipv4/ip_sockglue.c
> +++ b/net/ipv4/ip_sockglue.c
> @@ -1009,7 +1009,8 @@ e_inval:
>   */
>  int ip_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
>  {
> - if (!(inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO))
> + if (!(inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) &&
> + !IPCB(skb)->opt.optlen)
>   skb_dst_drop(skb);
>   return sock_queue_rcv_skb(sk, skb);
>  }
> 
> 
-- 
Ben Hutchings
Power corrupts.  Absolute power is kind of neat.
   - John Lehman, Secretary of the US Navy
1981-1987



signature.asc
Description: This is a digitally signed message part


Re: [PATCH 01/11] net: usb: usbnet: add new api ethtool_{get|set}_link_ksettings

2017-03-21 Thread Oliver Neukum
Am Donnerstag, den 16.03.2017, 23:18 +0100 schrieb Philippe Reynes:
> The ethtool api {get|set}_settings is deprecated.
> We add the new api {get|set}_link_ksettings to this driver.
> 
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
> 

Unfortunately I lack hardware to test.
Phillipe and I had a patch collision. David, please take his
patch for the next merge window. It looks good and is comprehensive and
nobody has reported issues. We will never find testers for all those
drivers on this list.

Regards
Oliver



Re: [v5,net-next,1/9] net: stmmac: multiple queues dt configuration

2017-03-21 Thread Thierry Reding
On Fri, Mar 10, 2017 at 06:24:51PM +, Joao Pinto wrote:
> This patch adds the multiple queues configuration in the Device Tree.
> It was also created a set of structures to keep the RX and TX queues
> configurations to be used in the driver.
> 
> Signed-off-by: Joao Pinto 
> ---
> Changes v4->v5:
> - patch title update (stmicro replaced by stmmac)
> Changes v2->v4:
> - Just to keep up with patch-set version
> Changes v1->v2:
> - RX and TX queues child nodes had bad handle
> 
>  Documentation/devicetree/bindings/net/stmmac.txt   | 40 ++
>  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 91 
> ++
>  include/linux/stmmac.h | 30 +++
>  3 files changed, 161 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/stmmac.txt 
> b/Documentation/devicetree/bindings/net/stmmac.txt
> index d3bfc2b..4107e67 100644
> --- a/Documentation/devicetree/bindings/net/stmmac.txt
> +++ b/Documentation/devicetree/bindings/net/stmmac.txt
> @@ -72,6 +72,27 @@ Optional properties:
>   - snps,mb: mixed-burst
>   - snps,rb: rebuild INCRx Burst
>  - mdio: with compatible = "snps,dwmac-mdio", create and register mdio bus.
> +- Multiple RX Queues parameters: below the list of all the parameters to
> +  configure the multiple RX queues:
> + - snps,rx-queues-to-use: number of RX queues to be used in the driver
> + - Choose one of these RX scheduling algorithms:
> + - snps,rx-sched-sp: Strict priority
> + - snps,rx-sched-wsp: Weighted Strict priority
> + - For each RX queue
> + - Choose one of these modes:
> + - snps,dcb-algorithm: Queue to be enabled as DCB
> + - snps,avb-algorithm: Queue to be enabled as AVB
> + - snps,map-to-dma-channel: Channel to map
> +- Multiple TX Queues parameters: below the list of all the parameters to
> +  configure the multiple TX queues:
> + - snps,tx-queues-to-use: number of TX queues to be used in the driver
> + - Choose one of these TX scheduling algorithms:
> + - snps,tx-sched-wrr: Weighted Round Robin
> + - snps,tx-sched-wfq: Weighted Fair Queuing
> + - snps,tx-sched-dwrr: Deficit Weighted Round Robin
> + - snps,tx-sched-sp: Strict priority
> + - For each TX queue
> + - snps,weight: TX queue weight (if using a weighted algorithm)
>  
>  Examples:
>  
> @@ -81,6 +102,23 @@ Examples:
>   snps,blen = <256 128 64 32 0 0 0>;
>   };
>  
> + mtl_rx_setup: rx-queues-config {
> + snps,rx-queues-to-use = <1>;
> + snps,rx-sched-sp;
> + queue0 {
> + snps,dcb-algorithm;
> + snps,map-to-dma-channel = <0x0>;
> + };
> + };
> +
> + mtl_tx_setup: tx-queues-config {
> + snps,tx-queues-to-use = <1>;
> + snps,tx-sched-wrr;
> + queue0 {
> + snps,weight = <0x10>;
> + };
> + };
> +
>   gmac0: ethernet@e080 {
>   compatible = "st,spear600-gmac";
>   reg = <0xe080 0x8000>;
> @@ -104,4 +142,6 @@ Examples:
>   phy1: ethernet-phy@0 {
>   };
>   };
> + snps,mtl-rx-config = <&mtl_rx_setup>;
> + snps,mtl-tx-config = <&mtl_tx_setup>;
>   };

That's kind of an odd placement for these nodes. Wouldn't they be better
located within the controller's device tree node, rather than referenced
by phandle? Making them children of the root node leaves them completely
without context.

Thierry


signature.asc
Description: PGP signature


Re: [v5,net-next,1/9] net: stmmac: multiple queues dt configuration

2017-03-21 Thread Joao Pinto

Hi Thierry,

Às 11:32 AM de 3/21/2017, Thierry Reding escreveu:
> On Fri, Mar 10, 2017 at 06:24:51PM +, Joao Pinto wrote:
>> This patch adds the multiple queues configuration in the Device Tree.
>> It was also created a set of structures to keep the RX and TX queues
>> configurations to be used in the driver.
>>
>> Signed-off-by: Joao Pinto 
>> ---
>> Changes v4->v5:
>> - patch title update (stmicro replaced by stmmac)
>> Changes v2->v4:
>> - Just to keep up with patch-set version
>> Changes v1->v2:
>> - RX and TX queues child nodes had bad handle
>>
>>  Documentation/devicetree/bindings/net/stmmac.txt   | 40 ++
>>  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 91 
>> ++
>>  include/linux/stmmac.h | 30 +++
>>  3 files changed, 161 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/net/stmmac.txt 
>> b/Documentation/devicetree/bindings/net/stmmac.txt
>> index d3bfc2b..4107e67 100644
>> --- a/Documentation/devicetree/bindings/net/stmmac.txt
>> +++ b/Documentation/devicetree/bindings/net/stmmac.txt
>> @@ -72,6 +72,27 @@ Optional properties:
>>  - snps,mb: mixed-burst
>>  - snps,rb: rebuild INCRx Burst
>>  - mdio: with compatible = "snps,dwmac-mdio", create and register mdio bus.
>> +- Multiple RX Queues parameters: below the list of all the parameters to
>> + configure the multiple RX queues:
>> +- snps,rx-queues-to-use: number of RX queues to be used in the driver
>> +- Choose one of these RX scheduling algorithms:
>> +- snps,rx-sched-sp: Strict priority
>> +- snps,rx-sched-wsp: Weighted Strict priority
>> +- For each RX queue
>> +- Choose one of these modes:
>> +- snps,dcb-algorithm: Queue to be enabled as DCB
>> +- snps,avb-algorithm: Queue to be enabled as AVB
>> +- snps,map-to-dma-channel: Channel to map
>> +- Multiple TX Queues parameters: below the list of all the parameters to
>> + configure the multiple TX queues:
>> +- snps,tx-queues-to-use: number of TX queues to be used in the driver
>> +- Choose one of these TX scheduling algorithms:
>> +- snps,tx-sched-wrr: Weighted Round Robin
>> +- snps,tx-sched-wfq: Weighted Fair Queuing
>> +- snps,tx-sched-dwrr: Deficit Weighted Round Robin
>> +- snps,tx-sched-sp: Strict priority
>> +- For each TX queue
>> +- snps,weight: TX queue weight (if using a weighted algorithm)
>>  
>>  Examples:
>>  
>> @@ -81,6 +102,23 @@ Examples:
>>  snps,blen = <256 128 64 32 0 0 0>;
>>  };
>>  
>> +mtl_rx_setup: rx-queues-config {
>> +snps,rx-queues-to-use = <1>;
>> +snps,rx-sched-sp;
>> +queue0 {
>> +snps,dcb-algorithm;
>> +snps,map-to-dma-channel = <0x0>;
>> +};
>> +};
>> +
>> +mtl_tx_setup: tx-queues-config {
>> +snps,tx-queues-to-use = <1>;
>> +snps,tx-sched-wrr;
>> +queue0 {
>> +snps,weight = <0x10>;
>> +};
>> +};
>> +
>>  gmac0: ethernet@e080 {
>>  compatible = "st,spear600-gmac";
>>  reg = <0xe080 0x8000>;
>> @@ -104,4 +142,6 @@ Examples:
>>  phy1: ethernet-phy@0 {
>>  };
>>  };
>> +snps,mtl-rx-config = <&mtl_rx_setup>;
>> +snps,mtl-tx-config = <&mtl_tx_setup>;
>>  };
> 
> That's kind of an odd placement for these nodes. Wouldn't they be better
> located within the controller's device tree node, rather than referenced
> by phandle? Making them children of the root node leaves them completely
> without context.
> 
> Thierry
> 

I followed the same approach as "stmmac_axi_setup":
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/Documentation/devicetree/bindings/net/stmmac.txt

I personally find it cleaner and easier to read.

Thanks,
Joao




RE: "tipc: fix socket timer deadlock" to stable?

2017-03-21 Thread Jon Maloy


> -Original Message-
> From: Tommi Rantala [mailto:tommi.t.rant...@nokia.com]
> Sent: Tuesday, March 21, 2017 03:50 AM
> To: Jon Maloy ; netdev@vger.kernel.org
> Cc: David S. Miller ; GUNA ;
> Ying Xue 
> Subject: Re: "tipc: fix socket timer deadlock" to stable?
> 
> On 13.03.2017 14:18, Jon Maloy wrote:
> >> -Original Message-
> >> From: Tommi Rantala [mailto:tommi.t.rant...@nokia.com]
> >>
> >> We're seeing this tipc deadlock in 4.4.y, that was fixed in the
> >> mainline commit
> >> f1d048f24e66ba85d3dabf3d076cefa5f2b546b0 "tipc: fix socket timer
> >> deadlock".
> >>
> >> Could/should this patch also be included in the stable kernel trees?
> >
> > I think it should. If action is required by me here (?) I will repost the 
> > commit
> for 4.4.
> >
> > ///jon
> 
> Hi Jon, yes, please do repost the commit. After reading through
> Documentation/networking/netdev-FAQ.txt, you probably want to send it
> with suitable subject-prefix so that the patch is not lost in the noise.
> 
Ok. I'll do that. Just have to do proper testing first.

///jon

> >> I just checked that the patch applies on top of 4.4.53, only the line
> >> numbers are different compared to the upstream commit.
> 
> (Actually there is also a small change in the patch context.)
> 
> -Tommi


Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Thierry Reding
On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
> This patch adds the RX and TX scheduling algorithms programming.
> It introduces the multiple queues configuration function
> (stmmac_mtl_configuration) in stmmac_main.
> 
> Signed-off-by: Joao Pinto 
> ---
> Changes v4->v5:
> - patch title update (stmicro replaced by stmmac)
> Changes v3->v4:
> - Just to keep up with patch-set version
> Changes v2->v3:
> - Switch statements with a tab
> Changes v1->v2:
> - Just to keep up with patch-set version
> 
>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
> +++
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
>  4 files changed, 90 insertions(+), 3 deletions(-)

This patch breaks backwards-compatibility with DTBs that don't have an
of the multiple queue properties.

See below...

> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
> b/drivers/net/ethernet/stmicro/stmmac/common.h
> index 04d9245..5a0a781 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> @@ -455,6 +455,10 @@ struct stmmac_ops {
>   int (*rx_ipc)(struct mac_device_info *hw);
>   /* Enable RX Queues */
>   void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
> + /* Program RX Algorithms */
> + void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
> + /* Program TX Algorithms */
> + void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
>   /* Dump MAC registers */
>   void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>   /* Handle extra events on specific interrupts hw dependent */
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> index db45134..748ab6f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> @@ -161,6 +161,16 @@ enum power_event {
>  #define GMAC_HI_REG_AE   BIT(31)
>  
>  /*  MTL registers */
> +#define MTL_OPERATION_MODE   0x0c00
> +#define MTL_OPERATION_SCHALG_MASKGENMASK(6, 5)
> +#define MTL_OPERATION_SCHALG_WRR (0x0 << 5)
> +#define MTL_OPERATION_SCHALG_WFQ (0x1 << 5)
> +#define MTL_OPERATION_SCHALG_DWRR(0x2 << 5)
> +#define MTL_OPERATION_SCHALG_SP  (0x3 << 5)
> +#define MTL_OPERATION_RAABIT(2)
> +#define MTL_OPERATION_RAA_SP (0x0 << 2)
> +#define MTL_OPERATION_RAA_WSP(0x1 << 2)
> +
>  #define MTL_INT_STATUS   0x0c20
>  #define MTL_INT_Q0   BIT(0)
>  
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> index 1e79e65..f966755 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct mac_device_info 
> *hw, u32 queue)
>   writel(value, ioaddr + GMAC_RXQ_CTRL0);
>  }
>  
> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
> +   u32 rx_alg)
> +{
> + void __iomem *ioaddr = hw->pcsr;
> + u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> +
> + value &= ~MTL_OPERATION_RAA;
> + switch (rx_alg) {
> + case MTL_RX_ALGORITHM_SP:
> + value |= MTL_OPERATION_RAA_SP;
> + break;
> + case MTL_RX_ALGORITHM_WSP:
> + value |= MTL_OPERATION_RAA_WSP;
> + break;
> + default:
> + break;
> + }
> +
> + writel(value, ioaddr + MTL_OPERATION_MODE);
> +}
> +
> +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
> +   u32 tx_alg)
> +{
> + void __iomem *ioaddr = hw->pcsr;
> + u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> +
> + value &= ~MTL_OPERATION_SCHALG_MASK;
> + switch (tx_alg) {
> + case MTL_TX_ALGORITHM_WRR:
> + value |= MTL_OPERATION_SCHALG_WRR;
> + break;
> + case MTL_TX_ALGORITHM_WFQ:
> + value |= MTL_OPERATION_SCHALG_WFQ;
> + break;
> + case MTL_TX_ALGORITHM_DWRR:
> + value |= MTL_OPERATION_SCHALG_DWRR;
> + break;
> + case MTL_TX_ALGORITHM_SP:
> + value |= MTL_OPERATION_SCHALG_SP;
> + break;
> + default:
> + break;
> + }
> +}
> +
>  static void dwmac4_dump_regs(struct mac_device_info *hw, u32 *reg_space)
>  {
>   void __iomem *ioaddr = hw->pcsr;
> @@ -457,6 +503,8 @@ static const struct stmmac_ops dwmac4_ops = {
>   .core_init = dwmac4_core_init,
>   .rx_ipc = dwmac4_rx_ipc_enable,
>   .rx_queue_enable = dwmac4_rx_queue_enable,
> + .prog_mtl_rx_algorithms = dwmac4_prog_mtl_

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Joao Pinto
Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
>> This patch adds the RX and TX scheduling algorithms programming.
>> It introduces the multiple queues configuration function
>> (stmmac_mtl_configuration) in stmmac_main.
>>
>> Signed-off-by: Joao Pinto 
>> ---
>> Changes v4->v5:
>> - patch title update (stmicro replaced by stmmac)
>> Changes v3->v4:
>> - Just to keep up with patch-set version
>> Changes v2->v3:
>> - Switch statements with a tab
>> Changes v1->v2:
>> - Just to keep up with patch-set version
>>
>>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
>> +++
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
>>  4 files changed, 90 insertions(+), 3 deletions(-)
> 
> This patch breaks backwards-compatibility with DTBs that don't have an
> of the multiple queue properties.
> 
> See below...
> 
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
>> b/drivers/net/ethernet/stmicro/stmmac/common.h
>> index 04d9245..5a0a781 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
>> @@ -455,6 +455,10 @@ struct stmmac_ops {
>>  int (*rx_ipc)(struct mac_device_info *hw);
>>  /* Enable RX Queues */
>>  void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
>> +/* Program RX Algorithms */
>> +void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
>> +/* Program TX Algorithms */
>> +void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
>>  /* Dump MAC registers */
>>  void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>>  /* Handle extra events on specific interrupts hw dependent */
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> index db45134..748ab6f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> @@ -161,6 +161,16 @@ enum power_event {
>>  #define GMAC_HI_REG_AE  BIT(31)
>>  
>>  /*  MTL registers */
>> +#define MTL_OPERATION_MODE  0x0c00
>> +#define MTL_OPERATION_SCHALG_MASK   GENMASK(6, 5)
>> +#define MTL_OPERATION_SCHALG_WRR(0x0 << 5)
>> +#define MTL_OPERATION_SCHALG_WFQ(0x1 << 5)
>> +#define MTL_OPERATION_SCHALG_DWRR   (0x2 << 5)
>> +#define MTL_OPERATION_SCHALG_SP (0x3 << 5)
>> +#define MTL_OPERATION_RAA   BIT(2)
>> +#define MTL_OPERATION_RAA_SP(0x0 << 2)
>> +#define MTL_OPERATION_RAA_WSP   (0x1 << 2)
>> +
>>  #define MTL_INT_STATUS  0x0c20
>>  #define MTL_INT_Q0  BIT(0)
>>  
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> index 1e79e65..f966755 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct mac_device_info 
>> *hw, u32 queue)
>>  writel(value, ioaddr + GMAC_RXQ_CTRL0);
>>  }
>>  
>> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
>> +  u32 rx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> +value &= ~MTL_OPERATION_RAA;
>> +switch (rx_alg) {
>> +case MTL_RX_ALGORITHM_SP:
>> +value |= MTL_OPERATION_RAA_SP;
>> +break;
>> +case MTL_RX_ALGORITHM_WSP:
>> +value |= MTL_OPERATION_RAA_WSP;
>> +break;
>> +default:
>> +break;
>> +}
>> +
>> +writel(value, ioaddr + MTL_OPERATION_MODE);
>> +}
>> +
>> +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
>> +  u32 tx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> +value &= ~MTL_OPERATION_SCHALG_MASK;
>> +switch (tx_alg) {
>> +case MTL_TX_ALGORITHM_WRR:
>> +value |= MTL_OPERATION_SCHALG_WRR;
>> +break;
>> +case MTL_TX_ALGORITHM_WFQ:
>> +value |= MTL_OPERATION_SCHALG_WFQ;
>> +break;
>> +case MTL_TX_ALGORITHM_DWRR:
>> +value |= MTL_OPERATION_SCHALG_DWRR;
>> +break;
>> +case MTL_TX_ALGORITHM_SP:
>> +value |= MTL_OPERATION_SCHALG_SP;
>> +break;
>> +default:
>> +break;
>> +}
>> +}
>> +
>>  static void dwmac4_dump_regs(struct mac_device_info *hw, u32 *reg_space)
>>  {
>>  void __iomem *ioaddr = hw->pcsr;
>> @@ -457,6 +503,8 @@ static const struct stmmac_ops dwmac4_ops = {
>>  .core_init = dwmac4_core_init,
>>  .r

[PATCH net-next] net: convert sk_filter.refcnt from atomic_t to refcount_t

2017-03-21 Thread Elena Reshetova
refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.

Signed-off-by: Elena Reshetova 
Signed-off-by: Hans Liljestrand 
Signed-off-by: Kees Cook 
Signed-off-by: David Windsor 
Acked-by: Daniel Borkmann 
---
 include/linux/filter.h |  3 ++-
 net/core/filter.c  | 17 -
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 8053c38..20247e7 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -7,6 +7,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -431,7 +432,7 @@ struct bpf_prog {
 };
 
 struct sk_filter {
-   atomic_trefcnt;
+   refcount_t  refcnt;
struct rcu_head rcu;
struct bpf_prog *prog;
 };
diff --git a/net/core/filter.c b/net/core/filter.c
index ebaeaf2..c7f0ccd 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -928,7 +928,7 @@ static void sk_filter_release_rcu(struct rcu_head *rcu)
  */
 static void sk_filter_release(struct sk_filter *fp)
 {
-   if (atomic_dec_and_test(&fp->refcnt))
+   if (refcount_dec_and_test(&fp->refcnt))
call_rcu(&fp->rcu, sk_filter_release_rcu);
 }
 
@@ -943,20 +943,27 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter 
*fp)
 /* try to charge the socket memory if there is space available
  * return true on success
  */
-bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
+static bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)
 {
u32 filter_size = bpf_prog_size(fp->prog->len);
 
/* same check as in sock_kmalloc() */
if (filter_size <= sysctl_optmem_max &&
atomic_read(&sk->sk_omem_alloc) + filter_size < sysctl_optmem_max) {
-   atomic_inc(&fp->refcnt);
atomic_add(filter_size, &sk->sk_omem_alloc);
return true;
}
return false;
 }
 
+bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
+{
+   bool ret = __sk_filter_charge(sk, fp);
+   if (ret)
+   refcount_inc(&fp->refcnt);
+   return ret;
+}
+
 static struct bpf_prog *bpf_migrate_filter(struct bpf_prog *fp)
 {
struct sock_filter *old_prog;
@@ -1179,12 +1186,12 @@ static int __sk_attach_prog(struct bpf_prog *prog, 
struct sock *sk)
return -ENOMEM;
 
fp->prog = prog;
-   atomic_set(&fp->refcnt, 0);
 
-   if (!sk_filter_charge(sk, fp)) {
+   if (!__sk_filter_charge(sk, fp)) {
kfree(fp);
return -ENOMEM;
}
+   refcount_set(&fp->refcnt, 1);
 
old_fp = rcu_dereference_protected(sk->sk_filter,
   lockdep_sock_is_held(sk));
-- 
2.7.4



Re: [PATCH 1/3] soc: qcom: smd: Transition client drivers from smd to rpmsg

2017-03-21 Thread Kalle Valo
Marcel Holtmann  writes:

>> By moving these client drivers to use RPMSG instead of the direct SMD
>> API we can reuse them ontop of the newly added GLINK wire-protocol
>> support found in the 820 and 835 Qualcomm platforms.
>> 
>> As the new (RPMSG-based) and old SMD implementations are mutually
>> exclusive we have to change all client drivers in one commit, to make
>> sure we have a working system before and after this transition.
>> 
>> Signed-off-by: Bjorn Andersson 
>> ---
>> 
>> Based on v4.11-rc3 with Arnd's Kconfig dependency fixes for BT_QCOMSMD
>> (https://lkml.org/lkml/2017/3/20/1038).
>> 
>> drivers/bluetooth/Kconfig  |  2 +-
>> drivers/bluetooth/btqcomsmd.c  | 32 +--
>> drivers/net/wireless/ath/wcn36xx/Kconfig   |  2 +-
>> drivers/net/wireless/ath/wcn36xx/main.c|  6 ++--
>> drivers/net/wireless/ath/wcn36xx/smd.c | 10 +++---
>> drivers/net/wireless/ath/wcn36xx/smd.h |  6 ++--
>> drivers/net/wireless/ath/wcn36xx/wcn36xx.h |  2 +-
>> drivers/soc/qcom/Kconfig   |  4 +--
>> drivers/soc/qcom/smd-rpm.c | 43 +
>> drivers/soc/qcom/wcnss_ctrl.c  | 50 
>> +-
>> include/linux/soc/qcom/wcnss_ctrl.h| 11 ---
>> net/qrtr/Kconfig   |  2 +-
>> net/qrtr/smd.c | 42 -
>> 13 files changed, 108 insertions(+), 104 deletions(-)
>
> I think that it is best if Dave takes these directly then and I pull
> them back down later into our trees. Including the Kconfig fix that I
> will ACK as well.
>
> Acked-by: Marcel Holtmann 

Sounds good to me.

Acked-by: Kalle Valo 

-- 
Kalle Valo


Re: [v5,net-next,1/9] net: stmmac: multiple queues dt configuration

2017-03-21 Thread Thierry Reding
On Tue, Mar 21, 2017 at 11:39:24AM +, Joao Pinto wrote:
> 
> Hi Thierry,
> 
> Às 11:32 AM de 3/21/2017, Thierry Reding escreveu:
> > On Fri, Mar 10, 2017 at 06:24:51PM +, Joao Pinto wrote:
> >> This patch adds the multiple queues configuration in the Device Tree.
> >> It was also created a set of structures to keep the RX and TX queues
> >> configurations to be used in the driver.
> >>
> >> Signed-off-by: Joao Pinto 
> >> ---
> >> Changes v4->v5:
> >> - patch title update (stmicro replaced by stmmac)
> >> Changes v2->v4:
> >> - Just to keep up with patch-set version
> >> Changes v1->v2:
> >> - RX and TX queues child nodes had bad handle
> >>
> >>  Documentation/devicetree/bindings/net/stmmac.txt   | 40 ++
> >>  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 91 
> >> ++
> >>  include/linux/stmmac.h | 30 +++
> >>  3 files changed, 161 insertions(+)
> >>
> >> diff --git a/Documentation/devicetree/bindings/net/stmmac.txt 
> >> b/Documentation/devicetree/bindings/net/stmmac.txt
> >> index d3bfc2b..4107e67 100644
> >> --- a/Documentation/devicetree/bindings/net/stmmac.txt
> >> +++ b/Documentation/devicetree/bindings/net/stmmac.txt
> >> @@ -72,6 +72,27 @@ Optional properties:
> >>- snps,mb: mixed-burst
> >>- snps,rb: rebuild INCRx Burst
> >>  - mdio: with compatible = "snps,dwmac-mdio", create and register mdio bus.
> >> +- Multiple RX Queues parameters: below the list of all the parameters to
> >> +   configure the multiple RX queues:
> >> +  - snps,rx-queues-to-use: number of RX queues to be used in the driver
> >> +  - Choose one of these RX scheduling algorithms:
> >> +  - snps,rx-sched-sp: Strict priority
> >> +  - snps,rx-sched-wsp: Weighted Strict priority
> >> +  - For each RX queue
> >> +  - Choose one of these modes:
> >> +  - snps,dcb-algorithm: Queue to be enabled as DCB
> >> +  - snps,avb-algorithm: Queue to be enabled as AVB
> >> +  - snps,map-to-dma-channel: Channel to map
> >> +- Multiple TX Queues parameters: below the list of all the parameters to
> >> +   configure the multiple TX queues:
> >> +  - snps,tx-queues-to-use: number of TX queues to be used in the driver
> >> +  - Choose one of these TX scheduling algorithms:
> >> +  - snps,tx-sched-wrr: Weighted Round Robin
> >> +  - snps,tx-sched-wfq: Weighted Fair Queuing
> >> +  - snps,tx-sched-dwrr: Deficit Weighted Round Robin
> >> +  - snps,tx-sched-sp: Strict priority
> >> +  - For each TX queue
> >> +  - snps,weight: TX queue weight (if using a weighted algorithm)
> >>  
> >>  Examples:
> >>  
> >> @@ -81,6 +102,23 @@ Examples:
> >>snps,blen = <256 128 64 32 0 0 0>;
> >>};
> >>  
> >> +  mtl_rx_setup: rx-queues-config {
> >> +  snps,rx-queues-to-use = <1>;
> >> +  snps,rx-sched-sp;
> >> +  queue0 {
> >> +  snps,dcb-algorithm;
> >> +  snps,map-to-dma-channel = <0x0>;
> >> +  };
> >> +  };
> >> +
> >> +  mtl_tx_setup: tx-queues-config {
> >> +  snps,tx-queues-to-use = <1>;
> >> +  snps,tx-sched-wrr;
> >> +  queue0 {
> >> +  snps,weight = <0x10>;
> >> +  };
> >> +  };
> >> +
> >>gmac0: ethernet@e080 {
> >>compatible = "st,spear600-gmac";
> >>reg = <0xe080 0x8000>;
> >> @@ -104,4 +142,6 @@ Examples:
> >>phy1: ethernet-phy@0 {
> >>};
> >>};
> >> +  snps,mtl-rx-config = <&mtl_rx_setup>;
> >> +  snps,mtl-tx-config = <&mtl_tx_setup>;
> >>};
> > 
> > That's kind of an odd placement for these nodes. Wouldn't they be better
> > located within the controller's device tree node, rather than referenced
> > by phandle? Making them children of the root node leaves them completely
> > without context.
> > 
> > Thierry
> > 
> 
> I followed the same approach as "stmmac_axi_setup":
> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/Documentation/devicetree/bindings/net/stmmac.txt
> 
> I personally find it cleaner and easier to read.

Okay, I see. I've never really seen this done, and I suspect the device
tree maintainers would've objected to the AXI bindings, but looks like
it fell through the cracks. Given that this has been upstream for a very
long time now, it is what it is, and I suppose this is at least
consistent.

Thierry


signature.asc
Description: PGP signature


[PATCH 1/2] netfilter: ipset: Remove unnecessary cast on void pointer

2017-03-21 Thread simran singhal
The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|

- (T*)
  e
)

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14. 

 net/netfilter/ipset/ip_set_bitmap_gen.h | 4 ++--
 net/netfilter/ipset/ip_set_core.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h 
b/net/netfilter/ipset/ip_set_bitmap_gen.h
index 6f09a99..d302d98 100644
--- a/net/netfilter/ipset/ip_set_bitmap_gen.h
+++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
@@ -232,7 +232,7 @@ mtype_list(const struct ip_set *set,
if (!test_bit(id, map->members) ||
(SET_WITH_TIMEOUT(set) &&
 #ifdef IP_SET_BITMAP_STORED_TIMEOUT
-mtype_is_filled((const struct mtype_elem *)x) &&
+mtype_is_filled(x) &&
 #endif
 ip_set_timeout_expired(ext_timeout(x, set
continue;
@@ -249,7 +249,7 @@ mtype_list(const struct ip_set *set,
if (mtype_do_list(skb, map, id, set->dsize))
goto nla_put_failure;
if (ip_set_put_extensions(skb, set, x,
-   mtype_is_filled((const struct mtype_elem *)x)))
+   mtype_is_filled(x)))
goto nla_put_failure;
ipset_nest_end(skb, nested);
}
diff --git a/net/netfilter/ipset/ip_set_core.c 
b/net/netfilter/ipset/ip_set_core.c
index c296f9b..10a3694 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1915,7 +1915,7 @@ ip_set_sockfn_get(struct sock *sk, int optval, void 
__user *user, int *len)
ret = -EFAULT;
goto done;
}
-   op = (unsigned int *)data;
+   op = data;
 
if (*op < IP_SET_OP_VERSION) {
/* Check the version at the beginning of operations */
-- 
2.7.4



[PATCH 0/2] netfilter: Remove unnecessary cast on void pointer

2017-03-21 Thread simran singhal
This patch series remove unnecessary cast on void pointer.

simran singhal (2):
  netfilter: ipset: Remove unnecessary cast on void pointer
  netfilter: Remove unnecessary cast on void pointer

 net/netfilter/ipset/ip_set_bitmap_gen.h |  4 ++--
 net/netfilter/ipset/ip_set_core.c   |  2 +-
 net/netfilter/nf_conntrack_proto.c  |  2 +-
 net/netfilter/nft_set_hash.c|  2 +-
 net/netfilter/xt_hashlimit.c| 10 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.7.4



[PATCH 2/2] netfilter: Remove unnecessary cast on void pointer

2017-03-21 Thread simran singhal
The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|

- (T*)
  e
)

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14. 

 net/netfilter/nf_conntrack_proto.c |  2 +-
 net/netfilter/nft_set_hash.c   |  2 +-
 net/netfilter/xt_hashlimit.c   | 10 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto.c 
b/net/netfilter/nf_conntrack_proto.c
index 48d8354..ec665c8 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -202,7 +202,7 @@ static int kill_l3proto(struct nf_conn *i, void *data)
 static int kill_l4proto(struct nf_conn *i, void *data)
 {
struct nf_conntrack_l4proto *l4proto;
-   l4proto = (struct nf_conntrack_l4proto *)data;
+   l4proto = data;
return nf_ct_protonum(i) == l4proto->l4proto &&
   nf_ct_l3num(i) == l4proto->l3proto;
 }
diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c
index 5f65272..8ec086b 100644
--- a/net/netfilter/nft_set_hash.c
+++ b/net/netfilter/nft_set_hash.c
@@ -352,7 +352,7 @@ static int nft_hash_init(const struct nft_set *set,
 
 static void nft_hash_elem_destroy(void *ptr, void *arg)
 {
-   nft_set_elem_destroy((const struct nft_set *)arg, ptr, true);
+   nft_set_elem_destroy(arg, ptr, true);
 }
 
 static void nft_hash_destroy(const struct nft_set *set)
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 2a6dfe8..762e187 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -119,7 +119,7 @@ static int
 cfg_copy(struct hashlimit_cfg2 *to, void *from, int revision)
 {
if (revision == 1) {
-   struct hashlimit_cfg1 *cfg = (struct hashlimit_cfg1 *)from;
+   struct hashlimit_cfg1 *cfg = from;
 
to->mode = cfg->mode;
to->avg = cfg->avg;
@@ -895,7 +895,7 @@ static void *dl_seq_start(struct seq_file *s, loff_t *pos)
 static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
 {
struct xt_hashlimit_htable *htable = s->private;
-   unsigned int *bucket = (unsigned int *)v;
+   unsigned int *bucket = v;
 
*pos = ++(*bucket);
if (*pos >= htable->cfg.size) {
@@ -909,7 +909,7 @@ static void dl_seq_stop(struct seq_file *s, void *v)
__releases(htable->lock)
 {
struct xt_hashlimit_htable *htable = s->private;
-   unsigned int *bucket = (unsigned int *)v;
+   unsigned int *bucket = v;
 
if (!IS_ERR(bucket))
kfree(bucket);
@@ -980,7 +980,7 @@ static int dl_seq_real_show(struct dsthash_ent *ent, 
u_int8_t family,
 static int dl_seq_show_v1(struct seq_file *s, void *v)
 {
struct xt_hashlimit_htable *htable = s->private;
-   unsigned int *bucket = (unsigned int *)v;
+   unsigned int *bucket = v;
struct dsthash_ent *ent;
 
if (!hlist_empty(&htable->hash[*bucket])) {
@@ -994,7 +994,7 @@ static int dl_seq_show_v1(struct seq_file *s, void *v)
 static int dl_seq_show(struct seq_file *s, void *v)
 {
struct xt_hashlimit_htable *htable = s->private;
-   unsigned int *bucket = (unsigned int *)v;
+   unsigned int *bucket = v;
struct dsthash_ent *ent;
 
if (!hlist_empty(&htable->hash[*bucket])) {
-- 
2.7.4



Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Thierry Reding
On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
> Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> > On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
> >> This patch adds the RX and TX scheduling algorithms programming.
> >> It introduces the multiple queues configuration function
> >> (stmmac_mtl_configuration) in stmmac_main.
> >>
> >> Signed-off-by: Joao Pinto 
> >> ---
> >> Changes v4->v5:
> >> - patch title update (stmicro replaced by stmmac)
> >> Changes v3->v4:
> >> - Just to keep up with patch-set version
> >> Changes v2->v3:
> >> - Switch statements with a tab
> >> Changes v1->v2:
> >> - Just to keep up with patch-set version
> >>
> >>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
> >>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
> >>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
> >> +++
> >>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
> >>  4 files changed, 90 insertions(+), 3 deletions(-)
> > 
> > This patch breaks backwards-compatibility with DTBs that don't have an
> > of the multiple queue properties.
> > 
> > See below...
> > 
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
> >> b/drivers/net/ethernet/stmicro/stmmac/common.h
> >> index 04d9245..5a0a781 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> >> @@ -455,6 +455,10 @@ struct stmmac_ops {
> >>int (*rx_ipc)(struct mac_device_info *hw);
> >>/* Enable RX Queues */
> >>void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
> >> +  /* Program RX Algorithms */
> >> +  void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
> >> +  /* Program TX Algorithms */
> >> +  void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
> >>/* Dump MAC registers */
> >>void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
> >>/* Handle extra events on specific interrupts hw dependent */
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
> >> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> index db45134..748ab6f 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> @@ -161,6 +161,16 @@ enum power_event {
> >>  #define GMAC_HI_REG_AEBIT(31)
> >>  
> >>  /*  MTL registers */
> >> +#define MTL_OPERATION_MODE0x0c00
> >> +#define MTL_OPERATION_SCHALG_MASK GENMASK(6, 5)
> >> +#define MTL_OPERATION_SCHALG_WRR  (0x0 << 5)
> >> +#define MTL_OPERATION_SCHALG_WFQ  (0x1 << 5)
> >> +#define MTL_OPERATION_SCHALG_DWRR (0x2 << 5)
> >> +#define MTL_OPERATION_SCHALG_SP   (0x3 << 5)
> >> +#define MTL_OPERATION_RAA BIT(2)
> >> +#define MTL_OPERATION_RAA_SP  (0x0 << 2)
> >> +#define MTL_OPERATION_RAA_WSP (0x1 << 2)
> >> +
> >>  #define MTL_INT_STATUS0x0c20
> >>  #define MTL_INT_Q0BIT(0)
> >>  
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
> >> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> index 1e79e65..f966755 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
> >> mac_device_info *hw, u32 queue)
> >>writel(value, ioaddr + GMAC_RXQ_CTRL0);
> >>  }
> >>  
> >> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
> >> +u32 rx_alg)
> >> +{
> >> +  void __iomem *ioaddr = hw->pcsr;
> >> +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> >> +
> >> +  value &= ~MTL_OPERATION_RAA;
> >> +  switch (rx_alg) {
> >> +  case MTL_RX_ALGORITHM_SP:
> >> +  value |= MTL_OPERATION_RAA_SP;
> >> +  break;
> >> +  case MTL_RX_ALGORITHM_WSP:
> >> +  value |= MTL_OPERATION_RAA_WSP;
> >> +  break;
> >> +  default:
> >> +  break;
> >> +  }
> >> +
> >> +  writel(value, ioaddr + MTL_OPERATION_MODE);
> >> +}
> >> +
> >> +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
> >> +u32 tx_alg)
> >> +{
> >> +  void __iomem *ioaddr = hw->pcsr;
> >> +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> >> +
> >> +  value &= ~MTL_OPERATION_SCHALG_MASK;
> >> +  switch (tx_alg) {
> >> +  case MTL_TX_ALGORITHM_WRR:
> >> +  value |= MTL_OPERATION_SCHALG_WRR;
> >> +  break;
> >> +  case MTL_TX_ALGORITHM_WFQ:
> >> +  value |= MTL_OPERATION_SCHALG_WFQ;
> >> +  break;
> >> +  case MTL_TX_ALGORITHM_DWRR:
> >> +  value |= MTL_OPERATION_SCHALG_DWRR;
> >> +  break;
> >> +  case MTL_TX_ALGORITHM_SP:
> >> +  value |= MTL_OPERATION_SCHALG_SP;
> >> +  break;
> >> +  default:
> >> +  break;
> >> +  }
> >> +}
> >> +
> >>  static void dwmac4_dump_regs(s

Re: [PATCH net] sctp: declare struct sctp_stream before using it

2017-03-21 Thread Neil Horman
On Mon, Mar 20, 2017 at 10:33:57PM +0800, Xin Long wrote:
> On Mon, Mar 20, 2017 at 9:29 PM, Neil Horman  wrote:
> > On Mon, Mar 20, 2017 at 05:46:27PM +0800, Xin Long wrote:
> >> sctp_stream_free uses struct sctp_stream as a param, but struct sctp_stream
> >> is defined after it's declaration.
> >>
> >> This patch is to declare struct sctp_stream before sctp_stream_free.
> >>
> >> Fixes: a83863174a61 ("sctp: prepare asoc stream for stream reconf")
> >> Signed-off-by: Xin Long 
> >> ---
> >>  include/net/sctp/structs.h | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
> >> index 4f64519..592dece 100644
> >> --- a/include/net/sctp/structs.h
> >> +++ b/include/net/sctp/structs.h
> >> @@ -83,6 +83,7 @@ struct sctp_bind_addr;
> >>  struct sctp_ulpq;
> >>  struct sctp_ep_common;
> >>  struct crypto_shash;
> >> +struct sctp_stream;
> >>
> >>
> >>  #include 
> >> --
> >> 2.1.0
> >>
> >>
> >
> > Not sure I follow.  did we run into a compilation failure here?
> no compilation err was found, even now.
> 
> because of
> struct sctp_stream *sctp_stream_new(__u16 incnt, __u16 outcnt, gfp_t gfp);
> void sctp_stream_free(struct sctp_stream *stream);
> 
> I'm not sure why gcc did not complain, but when I moved sctp_stream_new
> below sctp_stream_free:
> void sctp_stream_free(struct sctp_stream *stream);
> struct sctp_stream *sctp_stream_new(__u16 incnt, __u16 outcnt, gfp_t gfp);
> 
> the err showed up.
> 
odd, its almost like gcc considered the return value of sctp_stream_new to be a
forward declaration of the struct.

Anywho, can't hurt to make this chagne
Acked-by: Neil Horman 

> So the better thing we should do is to declare struct sctp_stream to
> avoid this potential issue.
> 
> Besides, I'm planing to change the return value type of sctp_stream_new.
> after which, the issue will be exposed.
> 
> >
> > Neil
> >
> 


Re: [PATCH RFC 0/7] phylib MMD accessor cleanups

2017-03-21 Thread Russell King - ARM Linux
On Sun, Mar 19, 2017 at 03:30:38PM -0700, Florian Fainelli wrote:
> Le 03/19/17 à 03:59, Russell King - ARM Linux a écrit :
> > This series of patches does exactly that - we merge the functionality
> > of the indirect accesses into the clause 45 accessors, and use these
> > exclusively to access MMD registers.  Internally, the new clause
> > independent MMD accessors indirect via the PHY drivers read_mmd/write_mmd
> > methods if present, otherwise fall back to using clause 45 accesses if
> > the PHY is a clause 45 phy, or clause 22 indirect accesses if the PHY
> > is clause 22.
> 
> LGTM:
> 
> Reviewed-by: Florian Fainelli 

Thanks.  When I posted this last time around (19th Jan) I mentioned
about marking the old _indirect() accessors with __deprecated - is
that still something we want to do?

I haven't tested this against net-next yet, so I don't know if there
are any new users of the indirect accessors - going down the deprecated
route would avoid breakage, but means having to submit a patch later to
actually remove them.

How would people want this handled?

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


[PATCH 0/2] netfilter: ,netdev@vger.kernel.org

2017-03-21 Thread simran singhal
This patch series Simplify function returns by merging 
assignment and return into one command line.

simran singhal (2):
  netfilter: ipset: Compress return logic
  netfilter: ipvs: Compress return logic

 net/netfilter/ipset/ip_set_list_set.c | 5 +
 net/netfilter/ipvs/ip_vs_ftp.c| 5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

-- 
2.7.4



[PATCH 1/2] netfilter: ipset: Compress return logic

2017-03-21 Thread simran singhal
Simplify function returns by merging assignment and return into one
command line.

Signed-off-by: simran singhal 
---
 
 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/ipset/ip_set_list_set.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_list_set.c 
b/net/netfilter/ipset/ip_set_list_set.c
index 178d4eb..2fff6b5 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -453,7 +453,6 @@ static size_t
 list_set_memsize(const struct list_set *map, size_t dsize)
 {
struct set_elem *e;
-   size_t memsize;
u32 n = 0;
 
rcu_read_lock();
@@ -461,9 +460,7 @@ list_set_memsize(const struct list_set *map, size_t dsize)
n++;
rcu_read_unlock();
 
-   memsize = sizeof(*map) + n * dsize;
-
-   return memsize;
+   return (sizeof(*map) + n * dsize);
 }
 
 static int
-- 
2.7.4



[PATCH 2/2] netfilter: ipvs: Compress return logic

2017-03-21 Thread simran singhal
Simplify function returns by merging assignment and return into
one command line.

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/ipvs/ip_vs_ftp.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index d30c327..c93c937 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -482,11 +482,8 @@ static struct pernet_operations ip_vs_ftp_ops = {
 
 static int __init ip_vs_ftp_init(void)
 {
-   int rv;
-
-   rv = register_pernet_subsys(&ip_vs_ftp_ops);
/* rcu_barrier() is called by netns on error */
-   return rv;
+   return register_pernet_subsys(&ip_vs_ftp_ops);
 }
 
 /*
-- 
2.7.4



[PATCH v2 0/2] netfilter: Compress return logic

2017-03-21 Thread simran singhal
This patch series Simplify function returns by merging
assignment and return into one command line.

v2:
  -Change the subject of cover patch

simran singhal (2):
  netfilter: ipset: Compress return logic
  netfilter: ipvs: Compress return logic

 net/netfilter/ipset/ip_set_list_set.c | 5 +
 net/netfilter/ipvs/ip_vs_ftp.c| 5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

-- 
2.7.4



[PATCH v2 2/2] netfilter: ipvs: Compress return logic

2017-03-21 Thread simran singhal
Simplify function returns by merging assignment and return into
one command line.

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/ipvs/ip_vs_ftp.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index d30c327..c93c937 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -482,11 +482,8 @@ static struct pernet_operations ip_vs_ftp_ops = {
 
 static int __init ip_vs_ftp_init(void)
 {
-   int rv;
-
-   rv = register_pernet_subsys(&ip_vs_ftp_ops);
/* rcu_barrier() is called by netns on error */
-   return rv;
+   return register_pernet_subsys(&ip_vs_ftp_ops);
 }
 
 /*
-- 
2.7.4



[PATCH v2 1/2] netfilter: ipset: Compress return logic

2017-03-21 Thread simran singhal
Simplify function returns by merging assignment and return into one
command line.

Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/ipset/ip_set_list_set.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_list_set.c 
b/net/netfilter/ipset/ip_set_list_set.c
index 178d4eb..2fff6b5 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -453,7 +453,6 @@ static size_t
 list_set_memsize(const struct list_set *map, size_t dsize)
 {
struct set_elem *e;
-   size_t memsize;
u32 n = 0;
 
rcu_read_lock();
@@ -461,9 +460,7 @@ list_set_memsize(const struct list_set *map, size_t dsize)
n++;
rcu_read_unlock();
 
-   memsize = sizeof(*map) + n * dsize;
-
-   return memsize;
+   return (sizeof(*map) + n * dsize);
 }
 
 static int
-- 
2.7.4



pull-request: wireless-drivers 2017-03-21

2017-03-21 Thread Kalle Valo
Hi Dave,

few smallish fixes for 4.11. Please let me know if there are any
problems.

Kalle

The following changes since commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2:

  net: properly release sk_frag.page (2017-03-15 15:37:45 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git 
tags/wireless-drivers-for-davem-2017-03-21

for you to fetch changes up to 6be3b6cce1e225f189b68b4e84fc711d19b4277b:

  ath10k: fix incorrect wlan_mac_base in qca6174_regs (2017-03-20 17:11:31 
+0200)


wireless-drivers fixes for 4.11

iwlwifi

* fix a user reported warning in DQA

mwifiex

* fix a potential double free
* fix lost early debug logs
* fix init wakeup warning message from device framework
* add Ganapathi and Xinming as maintainers

ath10k

* fix regression with QCA6174 during resume and firmware crash


Amitkumar Karwar (1):
  MAINTAINERS: update for mwifiex driver maintainers

Brian Norris (3):
  mwifiex: pcie: don't leak DMA buffers when removing
  mwifiex: set adapter->dev before starting to use mwifiex_dbg()
  mwifiex: uninit wakeup info when removing device

Ryan Hsu (1):
  ath10k: fix incorrect wlan_mac_base in qca6174_regs

Sara Sharon (1):
  iwlwifi: mvm: cleanup pending frames in DQA mode

 MAINTAINERS   |  2 ++
 drivers/net/wireless/ath/ath10k/hw.c  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c |  5 +--
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c  | 11 +++---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c   | 41 ++-
 drivers/net/wireless/marvell/mwifiex/main.c   | 11 +++---
 drivers/net/wireless/marvell/mwifiex/pcie.c   | 38 ++---
 8 files changed, 57 insertions(+), 55 deletions(-)


[PATCH net 0/8] Mellanox mlx5 fixes 2017-03-21

2017-03-21 Thread Saeed Mahameed
Hi Dave,

This series contains some mlx5 core and ethernet driver fixes.

For -stable:
net/mlx5e: Count LRO packets correctly (for kernel >= 4.2)
net/mlx5e: Count GSO packets correctly (for kernel >= 4.2)
net/mlx5: Increase number of max QPs in default profile (for kernel >= 4.0)
net/mlx5e: Avoid supporting udp tunnel port ndo for VF reps (for kernel >= 4.10)
net/mlx5e: Use the proper UAPI values when offloading TC vlan actions (for 
kernel >= v4.9)
net/mlx5: E-Switch, Don't allow changing inline mode when flows are configured 
(for kernel >= 4.10)
net/mlx5e: Change the TC offload rule add/del code path to be per NIC or 
E-Switch (for kernel >= 4.10)
net/mlx5: Add missing entries for set/query rate limit commands (for kernel >= 
4.8)

Thanks,
Saeed.

Gal Pressman (2):
  net/mlx5e: Count GSO packets correctly
  net/mlx5e: Count LRO packets correctly

Maor Gottlieb (1):
  net/mlx5: Increase number of max QPs in default profile

Or Gerlitz (3):
  net/mlx5: Add missing entries for set/query rate limit commands
  net/mlx5e: Change the TC offload rule add/del code path to be per NIC
or E-Switch
  net/mlx5e: Use the proper UAPI values when offloading TC vlan actions

Paul Blakey (1):
  net/mlx5e: Avoid supporting udp tunnel port ndo for VF reps

Roi Dayan (1):
  net/mlx5: E-Switch, Don't allow changing inline mode when flows are
configured

 drivers/net/ethernet/mellanox/mlx5/core/cmd.c  |  4 ++
 drivers/net/ethernet/mellanox/mlx5/core/en.h   |  4 --
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |  8 +--
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c   |  2 -
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c|  4 ++
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c| 74 +++---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c|  5 +-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  |  6 ++
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 22 +++
 drivers/net/ethernet/mellanox/mlx5/core/main.c |  2 +-
 10 files changed, 94 insertions(+), 37 deletions(-)

-- 
2.11.0



[PATCH net 8/8] net/mlx5e: Count LRO packets correctly

2017-03-21 Thread Saeed Mahameed
From: Gal Pressman 

RX packets statistics ('rx_packets' counter) used to count LRO packets
as one, even though it contains multiple segments.
This patch will increment the counter by the number of segments, and
align the driver with the behavior of other drivers in the stack.

Note that no information is lost in this patch due to 'rx_lro_packets'
counter existence.

Before, ethtool showed:
$ ethtool -S ens6 | egrep "rx_packets|rx_lro_packets"
 rx_packets: 435277
 rx_lro_packets: 35847
 rx_packets_phy: 1935066

Now, we will see the more logical statistics:
$ ethtool -S ens6 | egrep "rx_packets|rx_lro_packets"
 rx_packets: 1935066
 rx_lro_packets: 35847
 rx_packets_phy: 1935066

Fixes: e586b3b0baee ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Gal Pressman 
Cc: kernel-t...@fb.com
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 3d371688fbbb..bafcb349a50c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -601,6 +601,10 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 
*cqe,
if (lro_num_seg > 1) {
mlx5e_lro_update_hdr(skb, cqe, cqe_bcnt);
skb_shinfo(skb)->gso_size = DIV_ROUND_UP(cqe_bcnt, lro_num_seg);
+   /* Subtract one since we already counted this as one
+* "regular" packet in mlx5e_complete_rx_cqe()
+*/
+   rq->stats.packets += lro_num_seg - 1;
rq->stats.lro_packets++;
rq->stats.lro_bytes += cqe_bcnt;
}
-- 
2.11.0



[PATCH net 5/8] net/mlx5e: Avoid supporting udp tunnel port ndo for VF reps

2017-03-21 Thread Saeed Mahameed
From: Paul Blakey 

This was added to allow the TC offloading code to identify offloading
encap/decap vxlan rules.

The VF reps are effectively related to the same mlx5 PCI device as the
PF. Since the kernel invokes the (say) delete ndo for each netdev, the
FW erred on multiple vxlan dst port deletes when the port was deleted
from the system.

We fix that by keeping the registration to be carried out only by the
PF. Since the PF serves as the uplink device, the VF reps will look
up a port there and realize if they are ok to offload that.

Tested:
 
 
 ip link add vxlan1 type vxlan id 44 dev ens5f0 dstport 
 ip link set vxlan1 up
 ip link del dev vxlan1

Fixes: 4a25730eb202 ('net/mlx5e: Add ndo_udp_tunnel_add to VF representors')
Signed-off-by: Paul Blakey 
Reviewed-by: Or Gerlitz 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  | 4 
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  | 2 --
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c   | 9 +++--
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h 
b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index f6a6ded204f6..dc52053128bc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -928,10 +928,6 @@ void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, 
struct mlx5e_priv *priv);
 int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
 void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device 
*netdev);
 u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
-void mlx5e_add_vxlan_port(struct net_device *netdev,
- struct udp_tunnel_info *ti);
-void mlx5e_del_vxlan_port(struct net_device *netdev,
- struct udp_tunnel_info *ti);
 
 int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev,
void *sp);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 8ef64c4db2c2..66c133757a5e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3100,8 +3100,8 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
vf_stats);
 }
 
-void mlx5e_add_vxlan_port(struct net_device *netdev,
- struct udp_tunnel_info *ti)
+static void mlx5e_add_vxlan_port(struct net_device *netdev,
+struct udp_tunnel_info *ti)
 {
struct mlx5e_priv *priv = netdev_priv(netdev);
 
@@ -3114,8 +3114,8 @@ void mlx5e_add_vxlan_port(struct net_device *netdev,
mlx5e_vxlan_queue_work(priv, ti->sa_family, be16_to_cpu(ti->port), 1);
 }
 
-void mlx5e_del_vxlan_port(struct net_device *netdev,
- struct udp_tunnel_info *ti)
+static void mlx5e_del_vxlan_port(struct net_device *netdev,
+struct udp_tunnel_info *ti)
 {
struct mlx5e_priv *priv = netdev_priv(netdev);
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 2c864574a9d5..f621373bd7a5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -393,8 +393,6 @@ static const struct net_device_ops mlx5e_netdev_ops_rep = {
.ndo_get_phys_port_name  = mlx5e_rep_get_phys_port_name,
.ndo_setup_tc= mlx5e_rep_ndo_setup_tc,
.ndo_get_stats64 = mlx5e_rep_get_stats,
-   .ndo_udp_tunnel_add  = mlx5e_add_vxlan_port,
-   .ndo_udp_tunnel_del  = mlx5e_del_vxlan_port,
.ndo_has_offload_stats   = mlx5e_has_offload_stats,
.ndo_get_offload_stats   = mlx5e_get_offload_stats,
 };
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9c13abaf3885..fade7233dac5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -267,12 +267,15 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
skb_flow_dissector_target(f->dissector,
  FLOW_DISSECTOR_KEY_ENC_PORTS,
  f->mask);
+   struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
+   struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw);
+   struct mlx5e_priv *up_priv = netdev_priv(up_dev);
 
/* Full udp dst port must be given */
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
goto vxlan_match_offload_err;
 
-   if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->dst)) &&
+   if (mlx5e_

[PATCH net 4/8] net/mlx5e: Use the proper UAPI values when offloading TC vlan actions

2017-03-21 Thread Saeed Mahameed
From: Or Gerlitz 

Currently we use the non UAPI values and we miss erring on
the modify action which is not supported, fix that.

Fixes: 8b32580df1cb ('net/mlx5e: Add TC vlan action for SRIOV offloads')
Signed-off-by: Or Gerlitz 
Reported-by: Petr Machata 
Reviewed-by: Jiri Pirko 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 2825b5665456..9c13abaf3885 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1131,14 +1131,16 @@ static int parse_tc_fdb_actions(struct mlx5e_priv 
*priv, struct tcf_exts *exts,
}
 
if (is_tcf_vlan(a)) {
-   if (tcf_vlan_action(a) == VLAN_F_POP) {
+   if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) {
attr->action |= 
MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
-   } else if (tcf_vlan_action(a) == VLAN_F_PUSH) {
+   } else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) {
if (tcf_vlan_push_proto(a) != 
htons(ETH_P_8021Q))
return -EOPNOTSUPP;
 
attr->action |= 
MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
attr->vlan = tcf_vlan_push_vid(a);
+   } else { /* action is TCA_VLAN_ACT_MODIFY */
+   return -EOPNOTSUPP;
}
continue;
}
-- 
2.11.0



[PATCH net 6/8] net/mlx5: Increase number of max QPs in default profile

2017-03-21 Thread Saeed Mahameed
From: Maor Gottlieb 

With ConnectX-4 sharing SRQs from the same space as QPs, we hit a
limit preventing some applications to allocate needed QPs amount.
Double the size to 256K.

Fixes: e126ba97dba9e ('mlx5: Add driver for Mellanox Connect-IB adapters')
Signed-off-by: Maor Gottlieb 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index e2bd600d19de..60154a175bd3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -87,7 +87,7 @@ static struct mlx5_profile profile[] = {
[2] = {
.mask   = MLX5_PROF_MASK_QP_SIZE |
  MLX5_PROF_MASK_MR_CACHE,
-   .log_max_qp = 17,
+   .log_max_qp = 18,
.mr_cache[0]= {
.size   = 500,
.limit  = 250
-- 
2.11.0



[PATCH net 7/8] net/mlx5e: Count GSO packets correctly

2017-03-21 Thread Saeed Mahameed
From: Gal Pressman 

TX packets statistics ('tx_packets' counter) used to count GSO packets
as one, even though it contains multiple segments.
This patch will increment the counter by the number of segments, and
align the driver with the behavior of other drivers in the stack.

Note that no information is lost in this patch due to 'tx_tso_packets'
counter existence.

Before, ethtool showed:
$ ethtool -S ens6 | egrep "tx_packets|tx_tso_packets"
 tx_packets: 61340
 tx_tso_packets: 60954
 tx_packets_phy: 2451115

Now, we will see the more logical statistics:
$ ethtool -S ens6 | egrep "tx_packets|tx_tso_packets"
 tx_packets: 2451115
 tx_tso_packets: 60954
 tx_packets_phy: 2451115

Fixes: e586b3b0baee ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Gal Pressman 
Cc: kernel-t...@fb.com
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index f193128bac4b..57f5e2d7ebd1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -274,15 +274,18 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, 
struct sk_buff *skb)
sq->stats.tso_bytes += skb->len - ihs;
}
 
+   sq->stats.packets += skb_shinfo(skb)->gso_segs;
num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs;
} else {
bf = sq->bf_budget &&
 !skb->xmit_more &&
 !skb_shinfo(skb)->nr_frags;
ihs = mlx5e_get_inline_hdr_size(sq, skb, bf);
+   sq->stats.packets++;
num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
}
 
+   sq->stats.bytes += num_bytes;
wi->num_bytes = num_bytes;
 
ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS;
@@ -381,8 +384,6 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, 
struct sk_buff *skb)
if (bf)
sq->bf_budget--;
 
-   sq->stats.packets++;
-   sq->stats.bytes += num_bytes;
return NETDEV_TX_OK;
 
 dma_unmap_wqe_err:
-- 
2.11.0



[PATCH net 3/8] net/mlx5: E-Switch, Don't allow changing inline mode when flows are configured

2017-03-21 Thread Saeed Mahameed
From: Roi Dayan 

Changing the eswitch inline mode can potentially cause already configured
flows not to match the policy. E.g. set policy L4, add some L4 rules,
set policy to L2 --> bad! Hence we disallow it.

Keep track of how many offloaded rules are now set and refuse
inline mode changes if this isn't zero.

Fixes: bffaa916588e ("net/mlx5: E-Switch, Add control for inline mode")
Signed-off-by: Roi Dayan 
Reviewed-by: Or Gerlitz 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  | 1 +
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 8 
 2 files changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 9227a83a97e3..ad329b1680b4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -209,6 +209,7 @@ struct mlx5_esw_offload {
struct mlx5_eswitch_rep *vport_reps;
DECLARE_HASHTABLE(encap_tbl, 8);
u8 inline_mode;
+   u64 num_flows;
 };
 
 struct mlx5_eswitch {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index bfabefe20ac0..307ec6c5fd3b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -93,6 +93,8 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
   spec, &flow_act, dest, i);
if (IS_ERR(rule))
mlx5_fc_destroy(esw->dev, counter);
+   else
+   esw->offloads.num_flows++;
 
return rule;
 }
@@ -108,6 +110,7 @@ mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
counter = mlx5_flow_rule_counter(rule);
mlx5_del_flow_rules(rule);
mlx5_fc_destroy(esw->dev, counter);
+   esw->offloads.num_flows--;
}
 }
 
@@ -922,6 +925,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink 
*devlink, u8 mode)
MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
return -EOPNOTSUPP;
 
+   if (esw->offloads.num_flows > 0) {
+   esw_warn(dev, "Can't set inline mode when flows are 
configured\n");
+   return -EOPNOTSUPP;
+   }
+
err = esw_inline_mode_from_devlink(mode, &mlx5_mode);
if (err)
goto out;
-- 
2.11.0



[PATCH net 1/8] net/mlx5: Add missing entries for set/query rate limit commands

2017-03-21 Thread Saeed Mahameed
From: Or Gerlitz 

The switch cases for the rate limit set and query commands were
missing, which could get us wrong under fw error or driver reset
flow, fix that.

Fixes: 1466cc5b23d1 ('net/mlx5: Rate limit tables support')
Signed-off-by: Or Gerlitz 
Reviewed-by: Hadar Hen Zion 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index caa837e5e2b9..a380353a78c2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -361,6 +361,8 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev 
*dev, u16 op,
case MLX5_CMD_OP_QUERY_VPORT_COUNTER:
case MLX5_CMD_OP_ALLOC_Q_COUNTER:
case MLX5_CMD_OP_QUERY_Q_COUNTER:
+   case MLX5_CMD_OP_SET_RATE_LIMIT:
+   case MLX5_CMD_OP_QUERY_RATE_LIMIT:
case MLX5_CMD_OP_ALLOC_PD:
case MLX5_CMD_OP_ALLOC_UAR:
case MLX5_CMD_OP_CONFIG_INT_MODERATION:
@@ -497,6 +499,8 @@ const char *mlx5_command_str(int command)
MLX5_COMMAND_STR_CASE(ALLOC_Q_COUNTER);
MLX5_COMMAND_STR_CASE(DEALLOC_Q_COUNTER);
MLX5_COMMAND_STR_CASE(QUERY_Q_COUNTER);
+   MLX5_COMMAND_STR_CASE(SET_RATE_LIMIT);
+   MLX5_COMMAND_STR_CASE(QUERY_RATE_LIMIT);
MLX5_COMMAND_STR_CASE(ALLOC_PD);
MLX5_COMMAND_STR_CASE(DEALLOC_PD);
MLX5_COMMAND_STR_CASE(ALLOC_UAR);
-- 
2.11.0



Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Joao Pinto
Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
>> Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
>>> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
 This patch adds the RX and TX scheduling algorithms programming.
 It introduces the multiple queues configuration function
 (stmmac_mtl_configuration) in stmmac_main.

 Signed-off-by: Joao Pinto 
 ---
 Changes v4->v5:
 - patch title update (stmicro replaced by stmmac)
 Changes v3->v4:
 - Just to keep up with patch-set version
 Changes v2->v3:
 - Switch statements with a tab
 Changes v1->v2:
 - Just to keep up with patch-set version

  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
 +++
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
  4 files changed, 90 insertions(+), 3 deletions(-)
>>>
>>> This patch breaks backwards-compatibility with DTBs that don't have an
>>> of the multiple queue properties.
>>>
>>> See below...
>>>
 diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
 b/drivers/net/ethernet/stmicro/stmmac/common.h
 index 04d9245..5a0a781 100644
 --- a/drivers/net/ethernet/stmicro/stmmac/common.h
 +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
 @@ -455,6 +455,10 @@ struct stmmac_ops {
int (*rx_ipc)(struct mac_device_info *hw);
/* Enable RX Queues */
void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
 +  /* Program RX Algorithms */
 +  void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
 +  /* Program TX Algorithms */
 +  void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
/* Dump MAC registers */
void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
/* Handle extra events on specific interrupts hw dependent */
 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
 b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
 index db45134..748ab6f 100644
 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
 @@ -161,6 +161,16 @@ enum power_event {
  #define GMAC_HI_REG_AEBIT(31)
  
  /*  MTL registers */
 +#define MTL_OPERATION_MODE0x0c00
 +#define MTL_OPERATION_SCHALG_MASK GENMASK(6, 5)
 +#define MTL_OPERATION_SCHALG_WRR  (0x0 << 5)
 +#define MTL_OPERATION_SCHALG_WFQ  (0x1 << 5)
 +#define MTL_OPERATION_SCHALG_DWRR (0x2 << 5)
 +#define MTL_OPERATION_SCHALG_SP   (0x3 << 5)
 +#define MTL_OPERATION_RAA BIT(2)
 +#define MTL_OPERATION_RAA_SP  (0x0 << 2)
 +#define MTL_OPERATION_RAA_WSP (0x1 << 2)
 +
  #define MTL_INT_STATUS0x0c20
  #define MTL_INT_Q0BIT(0)
  
 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
 b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
 index 1e79e65..f966755 100644
 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
 @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
 mac_device_info *hw, u32 queue)
writel(value, ioaddr + GMAC_RXQ_CTRL0);
  }
  
 +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
 +u32 rx_alg)
 +{
 +  void __iomem *ioaddr = hw->pcsr;
 +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
 +
 +  value &= ~MTL_OPERATION_RAA;
 +  switch (rx_alg) {
 +  case MTL_RX_ALGORITHM_SP:
 +  value |= MTL_OPERATION_RAA_SP;
 +  break;
 +  case MTL_RX_ALGORITHM_WSP:
 +  value |= MTL_OPERATION_RAA_WSP;
 +  break;
 +  default:
 +  break;
 +  }
 +
 +  writel(value, ioaddr + MTL_OPERATION_MODE);
 +}
 +
 +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
 +u32 tx_alg)
 +{
 +  void __iomem *ioaddr = hw->pcsr;
 +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
 +
 +  value &= ~MTL_OPERATION_SCHALG_MASK;
 +  switch (tx_alg) {
 +  case MTL_TX_ALGORITHM_WRR:
 +  value |= MTL_OPERATION_SCHALG_WRR;
 +  break;
 +  case MTL_TX_ALGORITHM_WFQ:
 +  value |= MTL_OPERATION_SCHALG_WFQ;
 +  break;
 +  case MTL_TX_ALGORITHM_DWRR:
 +  value |= MTL_OPERATION_SCHALG_DWRR;
 +  break;
 +  case MTL_TX_ALGORITHM_SP:
 +  value |= MTL_OPERATION_SCHALG_SP;
 +  break;
 +  default:
 +  break;
 +  }

[PATCH net 2/8] net/mlx5e: Change the TC offload rule add/del code path to be per NIC or E-Switch

2017-03-21 Thread Saeed Mahameed
From: Or Gerlitz 

Refactor the code to deal with add/del TC rules to have handler per NIC/E-switch
offloading use case, and push the latter into the e-switch code. This provides
better separation and is to be used in down-stream patch for applying a fix.

Fixes: bffaa916588e ("net/mlx5: E-Switch, Add control for inline mode")
Signed-off-by: Or Gerlitz 
Reviewed-by: Roi Dayan 
Signed-off-by: Saeed Mahameed 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c| 59 ++
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  |  5 ++
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 14 +
 3 files changed, 58 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 79481f4cf264..2825b5665456 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -133,6 +133,23 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
return rule;
 }
 
+static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
+ struct mlx5e_tc_flow *flow)
+{
+   struct mlx5_fc *counter = NULL;
+
+   if (!IS_ERR(flow->rule)) {
+   counter = mlx5_flow_rule_counter(flow->rule);
+   mlx5_del_flow_rules(flow->rule);
+   mlx5_fc_destroy(priv->mdev, counter);
+   }
+
+   if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
+   mlx5_destroy_flow_table(priv->fs.tc.t);
+   priv->fs.tc.t = NULL;
+   }
+}
+
 static struct mlx5_flow_handle *
 mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
  struct mlx5_flow_spec *spec,
@@ -149,7 +166,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
 }
 
 static void mlx5e_detach_encap(struct mlx5e_priv *priv,
-  struct mlx5e_tc_flow *flow) {
+  struct mlx5e_tc_flow *flow);
+
+static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
+ struct mlx5e_tc_flow *flow)
+{
+   struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
+
+   mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr);
+
+   mlx5_eswitch_del_vlan_action(esw, flow->attr);
+
+   if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
+   mlx5e_detach_encap(priv, flow);
+}
+
+static void mlx5e_detach_encap(struct mlx5e_priv *priv,
+  struct mlx5e_tc_flow *flow)
+{
struct list_head *next = flow->encap.next;
 
list_del(&flow->encap);
@@ -173,25 +207,10 @@ static void mlx5e_detach_encap(struct mlx5e_priv *priv,
 static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
  struct mlx5e_tc_flow *flow)
 {
-   struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
-   struct mlx5_fc *counter = NULL;
-
-   if (!IS_ERR(flow->rule)) {
-   counter = mlx5_flow_rule_counter(flow->rule);
-   mlx5_del_flow_rules(flow->rule);
-   mlx5_fc_destroy(priv->mdev, counter);
-   }
-
-   if (flow->flags & MLX5E_TC_FLOW_ESWITCH) {
-   mlx5_eswitch_del_vlan_action(esw, flow->attr);
-   if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
-   mlx5e_detach_encap(priv, flow);
-   }
-
-   if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
-   mlx5_destroy_flow_table(priv->fs.tc.t);
-   priv->fs.tc.t = NULL;
-   }
+   if (flow->flags & MLX5E_TC_FLOW_ESWITCH)
+   mlx5e_tc_del_fdb_flow(priv, flow);
+   else
+   mlx5e_tc_del_nic_flow(priv, flow);
 }
 
 static void parse_vxlan_attr(struct mlx5_flow_spec *spec,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 5b78883d5654..9227a83a97e3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -271,6 +271,11 @@ struct mlx5_flow_handle *
 mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
struct mlx5_flow_spec *spec,
struct mlx5_esw_flow_attr *attr);
+void
+mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
+   struct mlx5_flow_handle *rule,
+   struct mlx5_esw_flow_attr *attr);
+
 struct mlx5_flow_handle *
 mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 
tirn);
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c 
b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 4f5b0d47d5f3..bfabefe20ac0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -97,6 +97,20 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
return rule;
 }
 
+void
+mlx5_eswitch_del

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Joao Pinto
++Adding Corentin

Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
> On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
>> Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
>>> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
 Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
>> This patch adds the RX and TX scheduling algorithms programming.
>> It introduces the multiple queues configuration function
>> (stmmac_mtl_configuration) in stmmac_main.
>>
>> Signed-off-by: Joao Pinto 
>> ---
>> Changes v4->v5:
>> - patch title update (stmicro replaced by stmmac)
>> Changes v3->v4:
>> - Just to keep up with patch-set version
>> Changes v2->v3:
>> - Switch statements with a tab
>> Changes v1->v2:
>> - Just to keep up with patch-set version
>>
>>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
>> +++
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
>>  4 files changed, 90 insertions(+), 3 deletions(-)
>
> This patch breaks backwards-compatibility with DTBs that don't have an
> of the multiple queue properties.
>
> See below...
>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
>> b/drivers/net/ethernet/stmicro/stmmac/common.h
>> index 04d9245..5a0a781 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
>> @@ -455,6 +455,10 @@ struct stmmac_ops {
>>  int (*rx_ipc)(struct mac_device_info *hw);
>>  /* Enable RX Queues */
>>  void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
>> +/* Program RX Algorithms */
>> +void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
>> rx_alg);
>> +/* Program TX Algorithms */
>> +void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
>> tx_alg);
>>  /* Dump MAC registers */
>>  void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>>  /* Handle extra events on specific interrupts hw dependent */
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> index db45134..748ab6f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> @@ -161,6 +161,16 @@ enum power_event {
>>  #define GMAC_HI_REG_AE  BIT(31)
>>  
>>  /*  MTL registers */
>> +#define MTL_OPERATION_MODE  0x0c00
>> +#define MTL_OPERATION_SCHALG_MASK   GENMASK(6, 5)
>> +#define MTL_OPERATION_SCHALG_WRR(0x0 << 5)
>> +#define MTL_OPERATION_SCHALG_WFQ(0x1 << 5)
>> +#define MTL_OPERATION_SCHALG_DWRR   (0x2 << 5)
>> +#define MTL_OPERATION_SCHALG_SP (0x3 << 5)
>> +#define MTL_OPERATION_RAA   BIT(2)
>> +#define MTL_OPERATION_RAA_SP(0x0 << 2)
>> +#define MTL_OPERATION_RAA_WSP   (0x1 << 2)
>> +
>>  #define MTL_INT_STATUS  0x0c20
>>  #define MTL_INT_Q0  BIT(0)
>>  
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> index 1e79e65..f966755 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
>> mac_device_info *hw, u32 queue)
>>  writel(value, ioaddr + GMAC_RXQ_CTRL0);
>>  }
>>  
>> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
>> +  u32 rx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> +value &= ~MTL_OPERATION_RAA;
>> +switch (rx_alg) {
>> +case MTL_RX_ALGORITHM_SP:
>> +value |= MTL_OPERATION_RAA_SP;
>> +break;
>> +case MTL_RX_ALGORITHM_WSP:
>> +value |= MTL_OPERATION_RAA_WSP;
>> +break;
>> +default:
>> +break;
>> +}
>> +
>> +writel(value, ioaddr + MTL_OPERATION_MODE);
>> +}
>> +
>> +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
>> +  u32 tx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> 

Re: linux-next-20170320 breaks stmmac on meson (Amlogic S905GXBB)

2017-03-21 Thread Corentin Labbe
On Tue, Mar 21, 2017 at 10:13:08AM +, Joao Pinto wrote:
> 
> Hi Heiner and Corentin,
> 
> Às 9:58 PM de 3/20/2017, Heiner Kallweit escreveu:
> > As reported by Corentin Labbe before:
> > stmmac in the latest next kernel is broken also on meson8b.
> > 
> > The following commit seems to create the trouble:
> > 6deee2221e11 "net: stmmac: prepare dma op mode config for multiple queues"
> > 
> > I also get queue timeout errors.
> 
> From what you are describing it seems that the tx op mode is not being
> configured by some reason and so it is not enabled.
> 
> Please check if this path is being executed:
> 
> stmmac_mtl_configuration >> stmmac_dma_operation_mode >> 
> priv->hw->dma->dma_tx_mode
> 
> It must iterate by all the available channels / queues, that should be =1 
> since
> I assume you have a single queue:
> 
>   if (priv->synopsys_id >= DWMAC_CORE_4_00) {
>   for (chan = 0; chan < rx_channels_count; chan++)
>   priv->hw->dma->dma_rx_mode(priv->ioaddr, rxmode, chan,
>  rxfifosz);
> 
>   for (chan = 0; chan < tx_channels_count; chan++)
>   priv->hw->dma->dma_tx_mode(priv->ioaddr, txmode, chan);
> 
> Could you please check if RX and TX op mode are being programmed?
> 
> The rx and tx queue counters are initialized in stmmac_mtl_setup() function
> (stmmac_platform.c). If they are not declared in DT they assume the default
> value of 1.
> 

Since stmmac_mtl_configuration is only called with priv->synopsys_id >= 
DWMAC_CORE_4_00, all older platform never call stmmac_dma_operation_mode.

Re-adding stmmac_dma_operation_mode at its place before 
6deee2221e110f6574988120dba6cab7e7313f44 "net: stmmac: prepare dma op mode 
config for multiple queues" fix my issue.


Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Thierry Reding
On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
> Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
> > On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
> >> Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> >>> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
>  This patch adds the RX and TX scheduling algorithms programming.
>  It introduces the multiple queues configuration function
>  (stmmac_mtl_configuration) in stmmac_main.
> 
>  Signed-off-by: Joao Pinto 
>  ---
>  Changes v4->v5:
>  - patch title update (stmicro replaced by stmmac)
>  Changes v3->v4:
>  - Just to keep up with patch-set version
>  Changes v2->v3:
>  - Switch statements with a tab
>  Changes v1->v2:
>  - Just to keep up with patch-set version
> 
>   drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>   drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>   drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
>  +++
>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
>   4 files changed, 90 insertions(+), 3 deletions(-)
> >>>
> >>> This patch breaks backwards-compatibility with DTBs that don't have an
> >>> of the multiple queue properties.
> >>>
> >>> See below...
> >>>
>  diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
>  b/drivers/net/ethernet/stmicro/stmmac/common.h
>  index 04d9245..5a0a781 100644
>  --- a/drivers/net/ethernet/stmicro/stmmac/common.h
>  +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
>  @@ -455,6 +455,10 @@ struct stmmac_ops {
>   int (*rx_ipc)(struct mac_device_info *hw);
>   /* Enable RX Queues */
>   void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
>  +/* Program RX Algorithms */
>  +void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
>  rx_alg);
>  +/* Program TX Algorithms */
>  +void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
>  tx_alg);
>   /* Dump MAC registers */
>   void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>   /* Handle extra events on specific interrupts hw dependent */
>  diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
>  b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>  index db45134..748ab6f 100644
>  --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>  +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>  @@ -161,6 +161,16 @@ enum power_event {
>   #define GMAC_HI_REG_AE  BIT(31)
>   
>   /*  MTL registers */
>  +#define MTL_OPERATION_MODE  0x0c00
>  +#define MTL_OPERATION_SCHALG_MASK   GENMASK(6, 5)
>  +#define MTL_OPERATION_SCHALG_WRR(0x0 << 5)
>  +#define MTL_OPERATION_SCHALG_WFQ(0x1 << 5)
>  +#define MTL_OPERATION_SCHALG_DWRR   (0x2 << 5)
>  +#define MTL_OPERATION_SCHALG_SP (0x3 << 5)
>  +#define MTL_OPERATION_RAA   BIT(2)
>  +#define MTL_OPERATION_RAA_SP(0x0 << 2)
>  +#define MTL_OPERATION_RAA_WSP   (0x1 << 2)
>  +
>   #define MTL_INT_STATUS  0x0c20
>   #define MTL_INT_Q0  BIT(0)
>   
>  diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
>  b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>  index 1e79e65..f966755 100644
>  --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>  +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>  @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
>  mac_device_info *hw, u32 queue)
>   writel(value, ioaddr + GMAC_RXQ_CTRL0);
>   }
>   
>  +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
>  +  u32 rx_alg)
>  +{
>  +void __iomem *ioaddr = hw->pcsr;
>  +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>  +
>  +value &= ~MTL_OPERATION_RAA;
>  +switch (rx_alg) {
>  +case MTL_RX_ALGORITHM_SP:
>  +value |= MTL_OPERATION_RAA_SP;
>  +break;
>  +case MTL_RX_ALGORITHM_WSP:
>  +value |= MTL_OPERATION_RAA_WSP;
>  +break;
>  +default:
>  +break;
>  +}
>  +
>  +writel(value, ioaddr + MTL_OPERATION_MODE);
>  +}
>  +
>  +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
>  +  u32 tx_alg)
>  +{
>  +void __iomem *ioaddr = hw->pcsr;
>  +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>  +
>  +value &= ~MTL_OPERATION_SCHALG_MASK;
>  +switch (tx

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Joao Pinto
Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
> On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
>> Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
>>> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
 Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
>> This patch adds the RX and TX scheduling algorithms programming.
>> It introduces the multiple queues configuration function
>> (stmmac_mtl_configuration) in stmmac_main.
>>
>> Signed-off-by: Joao Pinto 
>> ---
>> Changes v4->v5:
>> - patch title update (stmicro replaced by stmmac)
>> Changes v3->v4:
>> - Just to keep up with patch-set version
>> Changes v2->v3:
>> - Switch statements with a tab
>> Changes v1->v2:
>> - Just to keep up with patch-set version
>>
>>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
>> +++
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
>>  4 files changed, 90 insertions(+), 3 deletions(-)
>
> This patch breaks backwards-compatibility with DTBs that don't have an
> of the multiple queue properties.
>
> See below...
>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
>> b/drivers/net/ethernet/stmicro/stmmac/common.h
>> index 04d9245..5a0a781 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
>> @@ -455,6 +455,10 @@ struct stmmac_ops {
>>  int (*rx_ipc)(struct mac_device_info *hw);
>>  /* Enable RX Queues */
>>  void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
>> +/* Program RX Algorithms */
>> +void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
>> rx_alg);
>> +/* Program TX Algorithms */
>> +void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
>> tx_alg);
>>  /* Dump MAC registers */
>>  void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>>  /* Handle extra events on specific interrupts hw dependent */
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> index db45134..748ab6f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> @@ -161,6 +161,16 @@ enum power_event {
>>  #define GMAC_HI_REG_AE  BIT(31)
>>  
>>  /*  MTL registers */
>> +#define MTL_OPERATION_MODE  0x0c00
>> +#define MTL_OPERATION_SCHALG_MASK   GENMASK(6, 5)
>> +#define MTL_OPERATION_SCHALG_WRR(0x0 << 5)
>> +#define MTL_OPERATION_SCHALG_WFQ(0x1 << 5)
>> +#define MTL_OPERATION_SCHALG_DWRR   (0x2 << 5)
>> +#define MTL_OPERATION_SCHALG_SP (0x3 << 5)
>> +#define MTL_OPERATION_RAA   BIT(2)
>> +#define MTL_OPERATION_RAA_SP(0x0 << 2)
>> +#define MTL_OPERATION_RAA_WSP   (0x1 << 2)
>> +
>>  #define MTL_INT_STATUS  0x0c20
>>  #define MTL_INT_Q0  BIT(0)
>>  
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> index 1e79e65..f966755 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
>> mac_device_info *hw, u32 queue)
>>  writel(value, ioaddr + GMAC_RXQ_CTRL0);
>>  }
>>  
>> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
>> +  u32 rx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> +value &= ~MTL_OPERATION_RAA;
>> +switch (rx_alg) {
>> +case MTL_RX_ALGORITHM_SP:
>> +value |= MTL_OPERATION_RAA_SP;
>> +break;
>> +case MTL_RX_ALGORITHM_WSP:
>> +value |= MTL_OPERATION_RAA_WSP;
>> +break;
>> +default:
>> +break;
>> +}
>> +
>> +writel(value, ioaddr + MTL_OPERATION_MODE);
>> +}
>> +
>> +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
>> +  u32 tx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> +value &= ~

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Corentin Labbe
On Tue, Mar 21, 2017 at 02:10:47PM +, Joao Pinto wrote:
> ++Adding Corentin
> 
> Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
> > On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
> >> Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
> >>> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
>  Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> > On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
> >> This patch adds the RX and TX scheduling algorithms programming.
> >> It introduces the multiple queues configuration function
> >> (stmmac_mtl_configuration) in stmmac_main.
> >>
> >> Signed-off-by: Joao Pinto 
> >> ---
> >> Changes v4->v5:
> >> - patch title update (stmicro replaced by stmmac)
> >> Changes v3->v4:
> >> - Just to keep up with patch-set version
> >> Changes v2->v3:
> >> - Switch statements with a tab
> >> Changes v1->v2:
> >> - Just to keep up with patch-set version
> >>
> >>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
> >>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
> >>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
> >> +++
> >>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
> >>  4 files changed, 90 insertions(+), 3 deletions(-)
> >
> > This patch breaks backwards-compatibility with DTBs that don't have an
> > of the multiple queue properties.
> >
> > See below...
> >
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
> >> b/drivers/net/ethernet/stmicro/stmmac/common.h
> >> index 04d9245..5a0a781 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> >> @@ -455,6 +455,10 @@ struct stmmac_ops {
> >>int (*rx_ipc)(struct mac_device_info *hw);
> >>/* Enable RX Queues */
> >>void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
> >> +  /* Program RX Algorithms */
> >> +  void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
> >> rx_alg);
> >> +  /* Program TX Algorithms */
> >> +  void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
> >> tx_alg);
> >>/* Dump MAC registers */
> >>void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
> >>/* Handle extra events on specific interrupts hw dependent */
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
> >> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> index db45134..748ab6f 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> @@ -161,6 +161,16 @@ enum power_event {
> >>  #define GMAC_HI_REG_AEBIT(31)
> >>  
> >>  /*  MTL registers */
> >> +#define MTL_OPERATION_MODE0x0c00
> >> +#define MTL_OPERATION_SCHALG_MASK GENMASK(6, 5)
> >> +#define MTL_OPERATION_SCHALG_WRR  (0x0 << 5)
> >> +#define MTL_OPERATION_SCHALG_WFQ  (0x1 << 5)
> >> +#define MTL_OPERATION_SCHALG_DWRR (0x2 << 5)
> >> +#define MTL_OPERATION_SCHALG_SP   (0x3 << 5)
> >> +#define MTL_OPERATION_RAA BIT(2)
> >> +#define MTL_OPERATION_RAA_SP  (0x0 << 2)
> >> +#define MTL_OPERATION_RAA_WSP (0x1 << 2)
> >> +
> >>  #define MTL_INT_STATUS0x0c20
> >>  #define MTL_INT_Q0BIT(0)
> >>  
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
> >> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> index 1e79e65..f966755 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
> >> mac_device_info *hw, u32 queue)
> >>writel(value, ioaddr + GMAC_RXQ_CTRL0);
> >>  }
> >>  
> >> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
> >> +u32 rx_alg)
> >> +{
> >> +  void __iomem *ioaddr = hw->pcsr;
> >> +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> >> +
> >> +  value &= ~MTL_OPERATION_RAA;
> >> +  switch (rx_alg) {
> >> +  case MTL_RX_ALGORITHM_SP:
> >> +  value |= MTL_OPERATION_RAA_SP;
> >> +  break;
> >> +  case MTL_RX_ALGORITHM_WSP:
> >> +  value |= MTL_OPERATION_RAA_WSP;
> >> +  break;
> >> +  default:
> >> +  break;
> >> +  }
> >> +
> >> +  writel(value, ioaddr + MTL_OPERATION_MODE);
> >> +}
> >> +
> >> +static void dwmac4_prog_mtl_tx_algorithms(struct 

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Joao Pinto
Às 2:23 PM de 3/21/2017, Corentin Labbe escreveu:
> On Tue, Mar 21, 2017 at 02:10:47PM +, Joao Pinto wrote:
>> ++Adding Corentin
>>
>> Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
>>> On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
 Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
>> Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
>>> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
 This patch adds the RX and TX scheduling algorithms programming.
 It introduces the multiple queues configuration function
 (stmmac_mtl_configuration) in stmmac_main.

 Signed-off-by: Joao Pinto 
 ---
 Changes v4->v5:
 - patch title update (stmicro replaced by stmmac)
 Changes v3->v4:
 - Just to keep up with patch-set version
 Changes v2->v3:
 - Switch statements with a tab
 Changes v1->v2:
 - Just to keep up with patch-set version

  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
 +++
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
  4 files changed, 90 insertions(+), 3 deletions(-)
>>>
>>> This patch breaks backwards-compatibility with DTBs that don't have an
>>> of the multiple queue properties.
>>>
>>> See below...
>>>
 diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
 b/drivers/net/ethernet/stmicro/stmmac/common.h
 index 04d9245..5a0a781 100644
 --- a/drivers/net/ethernet/stmicro/stmmac/common.h
 +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
 @@ -455,6 +455,10 @@ struct stmmac_ops {
int (*rx_ipc)(struct mac_device_info *hw);
/* Enable RX Queues */
void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
 +  /* Program RX Algorithms */
 +  void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
 rx_alg);
 +  /* Program TX Algorithms */
 +  void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
 tx_alg);
/* Dump MAC registers */
void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
/* Handle extra events on specific interrupts hw dependent */
 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
 b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
 index db45134..748ab6f 100644
 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
 @@ -161,6 +161,16 @@ enum power_event {
  #define GMAC_HI_REG_AEBIT(31)
  
  /*  MTL registers */
 +#define MTL_OPERATION_MODE0x0c00
 +#define MTL_OPERATION_SCHALG_MASK GENMASK(6, 5)
 +#define MTL_OPERATION_SCHALG_WRR  (0x0 << 5)
 +#define MTL_OPERATION_SCHALG_WFQ  (0x1 << 5)
 +#define MTL_OPERATION_SCHALG_DWRR (0x2 << 5)
 +#define MTL_OPERATION_SCHALG_SP   (0x3 << 5)
 +#define MTL_OPERATION_RAA BIT(2)
 +#define MTL_OPERATION_RAA_SP  (0x0 << 2)
 +#define MTL_OPERATION_RAA_WSP (0x1 << 2)
 +
  #define MTL_INT_STATUS0x0c20
  #define MTL_INT_Q0BIT(0)
  
 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
 b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
 index 1e79e65..f966755 100644
 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
 @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
 mac_device_info *hw, u32 queue)
writel(value, ioaddr + GMAC_RXQ_CTRL0);
  }
  
 +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
 +u32 rx_alg)
 +{
 +  void __iomem *ioaddr = hw->pcsr;
 +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
 +
 +  value &= ~MTL_OPERATION_RAA;
 +  switch (rx_alg) {
 +  case MTL_RX_ALGORITHM_SP:
 +  value |= MTL_OPERATION_RAA_SP;
 +  break;
 +  case MTL_RX_ALGORITHM_WSP:
 +  value |= MTL_OPERATION_RAA_WSP;
 +  break;
 +  default:
 +  break;
 +  }
 +
 +  writel(value, ioaddr + MTL_OPERATION_MODE);
 +}
 +
>

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Thierry Reding
On Tue, Mar 21, 2017 at 02:18:59PM +, Joao Pinto wrote:
> Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
> > On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
> >> Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
> >>> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
>  Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> > On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
> >> This patch adds the RX and TX scheduling algorithms programming.
> >> It introduces the multiple queues configuration function
> >> (stmmac_mtl_configuration) in stmmac_main.
> >>
> >> Signed-off-by: Joao Pinto 
> >> ---
> >> Changes v4->v5:
> >> - patch title update (stmicro replaced by stmmac)
> >> Changes v3->v4:
> >> - Just to keep up with patch-set version
> >> Changes v2->v3:
> >> - Switch statements with a tab
> >> Changes v1->v2:
> >> - Just to keep up with patch-set version
> >>
> >>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
> >>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
> >>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
> >> +++
> >>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
> >>  4 files changed, 90 insertions(+), 3 deletions(-)
> >
> > This patch breaks backwards-compatibility with DTBs that don't have an
> > of the multiple queue properties.
> >
> > See below...
> >
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
> >> b/drivers/net/ethernet/stmicro/stmmac/common.h
> >> index 04d9245..5a0a781 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> >> @@ -455,6 +455,10 @@ struct stmmac_ops {
> >>int (*rx_ipc)(struct mac_device_info *hw);
> >>/* Enable RX Queues */
> >>void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
> >> +  /* Program RX Algorithms */
> >> +  void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
> >> rx_alg);
> >> +  /* Program TX Algorithms */
> >> +  void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
> >> tx_alg);
> >>/* Dump MAC registers */
> >>void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
> >>/* Handle extra events on specific interrupts hw dependent */
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
> >> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> index db45134..748ab6f 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> >> @@ -161,6 +161,16 @@ enum power_event {
> >>  #define GMAC_HI_REG_AEBIT(31)
> >>  
> >>  /*  MTL registers */
> >> +#define MTL_OPERATION_MODE0x0c00
> >> +#define MTL_OPERATION_SCHALG_MASK GENMASK(6, 5)
> >> +#define MTL_OPERATION_SCHALG_WRR  (0x0 << 5)
> >> +#define MTL_OPERATION_SCHALG_WFQ  (0x1 << 5)
> >> +#define MTL_OPERATION_SCHALG_DWRR (0x2 << 5)
> >> +#define MTL_OPERATION_SCHALG_SP   (0x3 << 5)
> >> +#define MTL_OPERATION_RAA BIT(2)
> >> +#define MTL_OPERATION_RAA_SP  (0x0 << 2)
> >> +#define MTL_OPERATION_RAA_WSP (0x1 << 2)
> >> +
> >>  #define MTL_INT_STATUS0x0c20
> >>  #define MTL_INT_Q0BIT(0)
> >>  
> >> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
> >> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> index 1e79e65..f966755 100644
> >> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> >> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
> >> mac_device_info *hw, u32 queue)
> >>writel(value, ioaddr + GMAC_RXQ_CTRL0);
> >>  }
> >>  
> >> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
> >> +u32 rx_alg)
> >> +{
> >> +  void __iomem *ioaddr = hw->pcsr;
> >> +  u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> >> +
> >> +  value &= ~MTL_OPERATION_RAA;
> >> +  switch (rx_alg) {
> >> +  case MTL_RX_ALGORITHM_SP:
> >> +  value |= MTL_OPERATION_RAA_SP;
> >> +  break;
> >> +  case MTL_RX_ALGORITHM_WSP:
> >> +  value |= MTL_OPERATION_RAA_WSP;
> >> +  break;
> >> +  default:
> >> +  break;
> >> +  }
> >> +
> >> +  writel(value, ioaddr + MTL_OPERATION_MODE);
> >> +}
> >> +
> >> +static void dwmac4_prog_mtl_tx_algorithms(struct mac_device_info *hw,
> 

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Joao Pinto
Às 2:33 PM de 3/21/2017, Thierry Reding escreveu:
> On Tue, Mar 21, 2017 at 02:25:15PM +, Joao Pinto wrote:
>> Às 2:23 PM de 3/21/2017, Corentin Labbe escreveu:
>>> On Tue, Mar 21, 2017 at 02:10:47PM +, Joao Pinto wrote:
 ++Adding Corentin

 Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
> On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
>> Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
>>> On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
 Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
>> This patch adds the RX and TX scheduling algorithms programming.
>> It introduces the multiple queues configuration function
>> (stmmac_mtl_configuration) in stmmac_main.
>>
>> Signed-off-by: Joao Pinto 
>> ---
>> Changes v4->v5:
>> - patch title update (stmicro replaced by stmmac)
>> Changes v3->v4:
>> - Just to keep up with patch-set version
>> Changes v2->v3:
>> - Switch statements with a tab
>> Changes v1->v2:
>> - Just to keep up with patch-set version
>>
>>  drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
>> +++
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 
>> +--
>>  4 files changed, 90 insertions(+), 3 deletions(-)
>
> This patch breaks backwards-compatibility with DTBs that don't have an
> of the multiple queue properties.
>
> See below...
>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
>> b/drivers/net/ethernet/stmicro/stmmac/common.h
>> index 04d9245..5a0a781 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
>> @@ -455,6 +455,10 @@ struct stmmac_ops {
>>  int (*rx_ipc)(struct mac_device_info *hw);
>>  /* Enable RX Queues */
>>  void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
>> +/* Program RX Algorithms */
>> +void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
>> rx_alg);
>> +/* Program TX Algorithms */
>> +void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
>> tx_alg);
>>  /* Dump MAC registers */
>>  void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>>  /* Handle extra events on specific interrupts hw dependent */
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> index db45134..748ab6f 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>> @@ -161,6 +161,16 @@ enum power_event {
>>  #define GMAC_HI_REG_AE  BIT(31)
>>  
>>  /*  MTL registers */
>> +#define MTL_OPERATION_MODE  0x0c00
>> +#define MTL_OPERATION_SCHALG_MASK   GENMASK(6, 5)
>> +#define MTL_OPERATION_SCHALG_WRR(0x0 << 5)
>> +#define MTL_OPERATION_SCHALG_WFQ(0x1 << 5)
>> +#define MTL_OPERATION_SCHALG_DWRR   (0x2 << 5)
>> +#define MTL_OPERATION_SCHALG_SP (0x3 << 5)
>> +#define MTL_OPERATION_RAA   BIT(2)
>> +#define MTL_OPERATION_RAA_SP(0x0 << 2)
>> +#define MTL_OPERATION_RAA_WSP   (0x1 << 2)
>> +
>>  #define MTL_INT_STATUS  0x0c20
>>  #define MTL_INT_Q0  BIT(0)
>>  
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
>> b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> index 1e79e65..f966755 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>> @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
>> mac_device_info *hw, u32 queue)
>>  writel(value, ioaddr + GMAC_RXQ_CTRL0);
>>  }
>>  
>> +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info 
>> *hw,
>> +  u32 rx_alg)
>> +{
>> +void __iomem *ioaddr = hw->pcsr;
>> +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>> +
>> +value &= ~MTL_OPERATION_RAA;
>> +switch (rx_alg) {
>> +case MTL_RX_ALGORITHM_SP:
>> +value |= MTL_OPERATION_RAA_SP;
>> +break;
>> +

Re: [v5,net-next,2/9] net: stmmac: configure mtl rx and tx algorithms

2017-03-21 Thread Thierry Reding
On Tue, Mar 21, 2017 at 02:25:15PM +, Joao Pinto wrote:
> Às 2:23 PM de 3/21/2017, Corentin Labbe escreveu:
> > On Tue, Mar 21, 2017 at 02:10:47PM +, Joao Pinto wrote:
> >> ++Adding Corentin
> >>
> >> Às 2:08 PM de 3/21/2017, Thierry Reding escreveu:
> >>> On Tue, Mar 21, 2017 at 01:58:36PM +, Joao Pinto wrote:
>  Às 12:24 PM de 3/21/2017, Thierry Reding escreveu:
> > On Tue, Mar 21, 2017 at 12:02:03PM +, Joao Pinto wrote:
> >> Às 11:58 AM de 3/21/2017, Thierry Reding escreveu:
> >>> On Fri, Mar 10, 2017 at 06:24:52PM +, Joao Pinto wrote:
>  This patch adds the RX and TX scheduling algorithms programming.
>  It introduces the multiple queues configuration function
>  (stmmac_mtl_configuration) in stmmac_main.
> 
>  Signed-off-by: Joao Pinto 
>  ---
>  Changes v4->v5:
>  - patch title update (stmicro replaced by stmmac)
>  Changes v3->v4:
>  - Just to keep up with patch-set version
>  Changes v2->v3:
>  - Switch statements with a tab
>  Changes v1->v2:
>  - Just to keep up with patch-set version
> 
>   drivers/net/ethernet/stmicro/stmmac/common.h  |  4 ++
>   drivers/net/ethernet/stmicro/stmmac/dwmac4.h  | 10 +
>   drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 48 
>  +++
>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 
>  +--
>   4 files changed, 90 insertions(+), 3 deletions(-)
> >>>
> >>> This patch breaks backwards-compatibility with DTBs that don't have an
> >>> of the multiple queue properties.
> >>>
> >>> See below...
> >>>
>  diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
>  b/drivers/net/ethernet/stmicro/stmmac/common.h
>  index 04d9245..5a0a781 100644
>  --- a/drivers/net/ethernet/stmicro/stmmac/common.h
>  +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
>  @@ -455,6 +455,10 @@ struct stmmac_ops {
>   int (*rx_ipc)(struct mac_device_info *hw);
>   /* Enable RX Queues */
>   void (*rx_queue_enable)(struct mac_device_info *hw, u32 queue);
>  +/* Program RX Algorithms */
>  +void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 
>  rx_alg);
>  +/* Program TX Algorithms */
>  +void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 
>  tx_alg);
>   /* Dump MAC registers */
>   void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
>   /* Handle extra events on specific interrupts hw dependent */
>  diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
>  b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>  index db45134..748ab6f 100644
>  --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>  +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
>  @@ -161,6 +161,16 @@ enum power_event {
>   #define GMAC_HI_REG_AE  BIT(31)
>   
>   /*  MTL registers */
>  +#define MTL_OPERATION_MODE  0x0c00
>  +#define MTL_OPERATION_SCHALG_MASK   GENMASK(6, 5)
>  +#define MTL_OPERATION_SCHALG_WRR(0x0 << 5)
>  +#define MTL_OPERATION_SCHALG_WFQ(0x1 << 5)
>  +#define MTL_OPERATION_SCHALG_DWRR   (0x2 << 5)
>  +#define MTL_OPERATION_SCHALG_SP (0x3 << 5)
>  +#define MTL_OPERATION_RAA   BIT(2)
>  +#define MTL_OPERATION_RAA_SP(0x0 << 2)
>  +#define MTL_OPERATION_RAA_WSP   (0x1 << 2)
>  +
>   #define MTL_INT_STATUS  0x0c20
>   #define MTL_INT_Q0  BIT(0)
>   
>  diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
>  b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>  index 1e79e65..f966755 100644
>  --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>  +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
>  @@ -70,6 +70,52 @@ static void dwmac4_rx_queue_enable(struct 
>  mac_device_info *hw, u32 queue)
>   writel(value, ioaddr + GMAC_RXQ_CTRL0);
>   }
>   
>  +static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info 
>  *hw,
>  +  u32 rx_alg)
>  +{
>  +void __iomem *ioaddr = hw->pcsr;
>  +u32 value = readl(ioaddr + MTL_OPERATION_MODE);
>  +
>  +value &= ~MTL_OPERATION_RAA;
>  +switch (rx_alg) {
>  +case MTL_RX_ALGORITHM_SP:
>  +value |= MTL_OPERATION_RAA_SP;
>  +break;
>  +case MTL_RX_ALGORITHM_WSP:
>  +va

Re: [PATCH 06/11] net: usb: mcs7830: use new api ethtool_{get|set}_link_ksettings

2017-03-21 Thread poma
On 16.03.2017 23:18, Philippe Reynes wrote:
> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
> 
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
> 
> Signed-off-by: Philippe Reynes 
> ---
>  drivers/net/usb/mcs7830.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
> index 4f345bd..5771ff2 100644
> --- a/drivers/net/usb/mcs7830.c
> +++ b/drivers/net/usb/mcs7830.c
> @@ -464,9 +464,9 @@ static void mcs7830_get_regs(struct net_device *net, 
> struct ethtool_regs *regs,
>   .get_link   = usbnet_get_link,
>   .get_msglevel   = usbnet_get_msglevel,
>   .set_msglevel   = usbnet_set_msglevel,
> - .get_settings   = usbnet_get_settings,
> - .set_settings   = usbnet_set_settings,
>   .nway_reset = usbnet_nway_reset,
> + .get_link_ksettings = usbnet_get_link_ksettings,
> + .set_link_ksettings = usbnet_set_link_ksettings,
>  };
>  
>  static const struct net_device_ops mcs7830_netdev_ops = {
> 

$ modinfo mcs7830 usbnet mii -n
/lib/modules/4.11.0-0.rc3.git0.1.fc26.x86_64/updates/mcs7830.ko
/lib/modules/4.11.0-0.rc3.git0.1.fc26.x86_64/updates/usbnet.ko
/lib/modules/4.11.0-0.rc3.git0.1.fc26.x86_64/updates/mii.ko

$ lsmod | grep mcs7830
mcs783016384  0
usbnet 45056  1 mcs7830
mii16384  2 usbnet,mcs7830

$ nmcli -f GENERAL.DRIVER,GENERAL.STATE device show enp0s4f1u4
GENERAL.DRIVER: MOSCHIP usb-ethernet driver
GENERAL.STATE:  100 (connected)

Tested-by: poma 



Re: linux-next-20170320 break stmmac on dwmac-sunxi

2017-03-21 Thread Joao Pinto
Hi Peppe,

Às 2:39 PM de 3/21/2017, Giuseppe CAVALLARO escreveu:
> Hello Corentin
> 
> yes, bisect process is really good approach to me. Pls give us more details.
> Recently the multi DMA channel logic has been added so it could be that
> something is needed to allow your platform to manage the new code.
> Or we introduced some regression. If I have some other idea, I ping you.
> 
> Peppe
> 
> On 3/20/2017 8:54 PM, Corentin Labbe wrote:
>> Hello
>>
>> Just pushed next-20170320 to my boards and stmmac stop working on both intree
>> dwmac-sunxi and my dev dwmac-sun8i.
>> It seems that interrupts never fire, and transmit queue timeout.
>> I will try to bisect this problem but perhaps other people could try to
>> reproduce it.
>>
>> Regards
>> Corentin Labbe
>>
> 

Corentin spotted 2 bugs (dma_op_mode was only being set for core versions >=
4.00 and rx/tx default nº of queues was being set in a place that would not be
accessible if no multiqueue config is added to the DT). Thierry will send a set
of patches to improve soon.

Thanks,
Joao


Re: stmmac still supporting spear600 ?

2017-03-21 Thread Thomas Petazzoni
Hello,

On Thu, 9 Mar 2017 15:56:31 +0100, Giuseppe CAVALLARO wrote:

> On 3/9/2017 10:32 AM, Thomas Petazzoni wrote:
> 
> > OK, I'll have a look. However, I'm still confused by this DMA_RESET bit
> > that never clears, contrary to what the datasheet says. Are there some
> > erratas?  
> 
> I suggest you to take a look at the tx/rx clocks from PHY.
> You have to provide these otherwise you cannot reset the engine.

Thanks for the hint.

Further research has revealed that everything is working fine on a
platform with a Gigabit PHY connected via GMII.

However, on a different platform (which I'm using) with a 10/100 PHY
connected via MII, DMA_RESET never clears, and networking doesn't work.
The SMSC PHY LAN8700 is also supposed to be providing the clock through
its TX_CLK pin. I double checked, and both the MAC and PHY are in MII
mode, but still no luck so far.

Of course, if you have any suggestion or hint, I'm all ears :)

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


Re: [PATCH net 8/8] net/mlx5e: Count LRO packets correctly

2017-03-21 Thread Alexei Starovoitov

On 3/21/17 6:59 AM, Saeed Mahameed wrote:

From: Gal Pressman 

RX packets statistics ('rx_packets' counter) used to count LRO packets
as one, even though it contains multiple segments.
This patch will increment the counter by the number of segments, and
align the driver with the behavior of other drivers in the stack.

Note that no information is lost in this patch due to 'rx_lro_packets'
counter existence.

Before, ethtool showed:
$ ethtool -S ens6 | egrep "rx_packets|rx_lro_packets"
 rx_packets: 435277
 rx_lro_packets: 35847
 rx_packets_phy: 1935066

Now, we will see the more logical statistics:
$ ethtool -S ens6 | egrep "rx_packets|rx_lro_packets"
 rx_packets: 1935066
 rx_lro_packets: 35847
 rx_packets_phy: 1935066

Fixes: e586b3b0baee ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Gal Pressman 
Cc: kernel-t...@fb.com
Signed-off-by: Saeed Mahameed 


Acked-by: Alexei Starovoitov 




Re: [PATCH net 7/8] net/mlx5e: Count GSO packets correctly

2017-03-21 Thread Alexei Starovoitov

On 3/21/17 6:59 AM, Saeed Mahameed wrote:

From: Gal Pressman 

TX packets statistics ('tx_packets' counter) used to count GSO packets
as one, even though it contains multiple segments.
This patch will increment the counter by the number of segments, and
align the driver with the behavior of other drivers in the stack.

Note that no information is lost in this patch due to 'tx_tso_packets'
counter existence.

Before, ethtool showed:
$ ethtool -S ens6 | egrep "tx_packets|tx_tso_packets"
 tx_packets: 61340
 tx_tso_packets: 60954
 tx_packets_phy: 2451115

Now, we will see the more logical statistics:
$ ethtool -S ens6 | egrep "tx_packets|tx_tso_packets"
 tx_packets: 2451115
 tx_tso_packets: 60954
 tx_packets_phy: 2451115

Fixes: e586b3b0baee ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Gal Pressman 
Cc: kernel-t...@fb.com
Signed-off-by: Saeed Mahameed 


thank you for fixing!
Acked-by: Alexei Starovoitov 



Re: [PATCH v2 1/2] gtp: rename SGSN netlink attribute

2017-03-21 Thread Pablo Neira Ayuso
On Tue, Mar 21, 2017 at 04:04:29PM +0100, Jonas Bonn wrote:
> diff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h
> index 72a04a0..c51ebb0 100644
> --- a/include/uapi/linux/gtp.h
> +++ b/include/uapi/linux/gtp.h
> @@ -19,7 +19,7 @@ enum gtp_attrs {
>   GTPA_LINK,
>   GTPA_VERSION,
>   GTPA_TID,   /* for GTPv0 only */
> - GTPA_SGSN_ADDRESS,
> + GTPA_PEER_ADDRESS,  /* Remote GSN peer, either SGSN or GGSN */

We need here:

#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS

for backward compatibility. Anything that is exposed through uapi
cannot be changed.

>   GTPA_MS_ADDRESS,
>   GTPA_FLOW,
>   GTPA_NET_NS_FD,
> @@ -29,5 +29,6 @@ enum gtp_attrs {
>   __GTPA_MAX,
>  };
>  #define GTPA_MAX (__GTPA_MAX + 1)
> +#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */
>  
>  #endif /* _UAPI_LINUX_GTP_H_ */
> -- 
> 2.9.3
> 


Re: [PATCH v2 1/2] gtp: rename SGSN netlink attribute

2017-03-21 Thread Jonas Bonn

On 03/21/2017 04:07 PM, Pablo Neira Ayuso wrote:

On Tue, Mar 21, 2017 at 04:04:29PM +0100, Jonas Bonn wrote:

diff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h
index 72a04a0..c51ebb0 100644
--- a/include/uapi/linux/gtp.h
+++ b/include/uapi/linux/gtp.h
@@ -19,7 +19,7 @@ enum gtp_attrs {
GTPA_LINK,
GTPA_VERSION,
GTPA_TID,   /* for GTPv0 only */
-   GTPA_SGSN_ADDRESS,
+   GTPA_PEER_ADDRESS,  /* Remote GSN peer, either SGSN or GGSN */

We need here:

#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS

for backward compatibility. Anything that is exposed through uapi
cannot be changed.


Yes... look a couple of lines further down...


GTPA_MS_ADDRESS,
GTPA_FLOW,
GTPA_NET_NS_FD,
@@ -29,5 +29,6 @@ enum gtp_attrs {
__GTPA_MAX,
  };
  #define GTPA_MAX (__GTPA_MAX + 1)
+#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */


... there it is! :)

/Jonas
  
  #endif /* _UAPI_LINUX_GTP_H_ */

--
2.9.3





[PATCH 3/3] net: stmmac: Use AVB mode by default

2017-03-21 Thread Thierry Reding
From: Thierry Reding 

Prior to the recent multi-queue changes the driver would configure the
queues to use the AVB mode, but the mode then got switched to DCB. The
hardware still works fine in DCB mode, but my testing capabilities are
limited, so it's safer to revert to the prior setting anyway.

Signed-off-by: Thierry Reding 
---
 include/linux/stmmac.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index be47b859e954..8349a5c1537b 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -56,8 +56,8 @@
 #define MTL_RX_ALGORITHM_WSP   0x5
 
 /* RX/TX Queue Mode */
-#define MTL_QUEUE_DCB  0x0
-#define MTL_QUEUE_AVB  0x1
+#define MTL_QUEUE_AVB  0x0
+#define MTL_QUEUE_DCB  0x1
 
 /* The MDC clock could be set higher than the IEEE 802.3
  * specified frequency limit 0f 2.5 MHz, by programming a clock divider
-- 
2.12.0



Re: [PATCH 1/3] net: stmmac: Always enable MAC RX queues

2017-03-21 Thread Joao Pinto
Às 3:12 PM de 3/21/2017, Thierry Reding escreveu:
> From: Thierry Reding 
> 
> The MAC RX queues always need to be enabled in order to receive network
> packets. Remove the condition that this only needs to be done for multi-
> queue configurations.
> 
> Signed-off-by: Thierry Reding 
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index d3a21519e4c0..298956032098 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1943,7 +1943,7 @@ static void stmmac_mtl_configuration(struct stmmac_priv 
> *priv)
>   stmmac_rx_queue_dma_chan_map(priv);
>  
>   /* Enable MAC RX Queues */
> - if (rx_queues_count > 1 && priv->hw->mac->rx_queue_enable)
> + if (priv->hw->mac->rx_queue_enable)
>   stmmac_mac_enable_rx_queues(priv);
>  
>   /* Set the HW DMA mode and the COE */
> 

This text is from the Databook:

"In multiple Rx queues configuration, all the queues are disabled by default.
Enable the Rx queue by programming the corresponding field in this register."

So by theory, only multiple queue configured cores needs the enable operation.

>>> But came to my attention a setup that has 1 RX queue and 2 TX queues, which
enables multiple queues mechanism inside the core (even with 1 RX) and so RX
needs to be enabled. Because of that I agree with this patch.

Acked-By: Joao Pinto 


[PATCH 1/3] net: stmmac: Always enable MAC RX queues

2017-03-21 Thread Thierry Reding
From: Thierry Reding 

The MAC RX queues always need to be enabled in order to receive network
packets. Remove the condition that this only needs to be done for multi-
queue configurations.

Signed-off-by: Thierry Reding 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d3a21519e4c0..298956032098 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1943,7 +1943,7 @@ static void stmmac_mtl_configuration(struct stmmac_priv 
*priv)
stmmac_rx_queue_dma_chan_map(priv);
 
/* Enable MAC RX Queues */
-   if (rx_queues_count > 1 && priv->hw->mac->rx_queue_enable)
+   if (priv->hw->mac->rx_queue_enable)
stmmac_mac_enable_rx_queues(priv);
 
/* Set the HW DMA mode and the COE */
-- 
2.12.0



[PATCH 2/3] net: stmmac: Restore DT backwards-compatibility

2017-03-21 Thread Thierry Reding
From: Thierry Reding 

Recent changes to support multiple queues in the device tree bindings
resulted in the number of RX and TX queues to be initialized to zero for
device trees not adhering to the new bindings.

Restore backwards-compatibility with those device trees by falling back
to a single RX and TX queues each.

Signed-off-by: Thierry Reding 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 37f550ae76a5..74b0aff79b25 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -143,6 +143,13 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
struct device_node *tx_node;
u8 queue = 0;
 
+   /* For backwards-compatibility with device trees that don't have any
+* snps,mtl-rx-config or snps,mtl-tx-config properties, we fall back
+* to one RX and TX queues each.
+*/
+   plat->rx_queues_to_use = 1;
+   plat->tx_queues_to_use = 1;
+
rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0);
if (!rx_node)
return;
-- 
2.12.0



Re: [PATCH 2/3] net: stmmac: Restore DT backwards-compatibility

2017-03-21 Thread Joao Pinto
Às 3:12 PM de 3/21/2017, Thierry Reding escreveu:
> From: Thierry Reding 
> 
> Recent changes to support multiple queues in the device tree bindings
> resulted in the number of RX and TX queues to be initialized to zero for
> device trees not adhering to the new bindings.
> 
> Restore backwards-compatibility with those device trees by falling back
> to a single RX and TX queues each.
> 
> Signed-off-by: Thierry Reding 
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 37f550ae76a5..74b0aff79b25 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -143,6 +143,13 @@ static void stmmac_mtl_setup(struct platform_device 
> *pdev,
>   struct device_node *tx_node;
>   u8 queue = 0;
>  
> + /* For backwards-compatibility with device trees that don't have any
> +  * snps,mtl-rx-config or snps,mtl-tx-config properties, we fall back
> +  * to one RX and TX queues each.
> +  */
> + plat->rx_queues_to_use = 1;
> + plat->tx_queues_to_use = 1;
> +
>   rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0);
>   if (!rx_node)
>   return;
> 

Acked-By: Joao Pinto 


Re: [PATCH RFC 0/7] phylib MMD accessor cleanups

2017-03-21 Thread Andrew Lunn
> Thanks.  When I posted this last time around (19th Jan) I mentioned
> about marking the old _indirect() accessors with __deprecated - is
> that still something we want to do?
> 
> I haven't tested this against net-next yet, so I don't know if there
> are any new users of the indirect accessors - going down the deprecated
> route would avoid breakage, but means having to submit a patch later to
> actually remove them.
> 
> How would people want this handled?

Hi Russell

We can get patches into net-next very quickly. So i suggest you rebase
and resubmit and get it in. If something breaks, we add followup
patches to fix it.

Andrew


Re: [PATCH 3/3] net: stmmac: Use AVB mode by default

2017-03-21 Thread Joao Pinto
Às 3:12 PM de 3/21/2017, Thierry Reding escreveu:
> From: Thierry Reding 
> 
> Prior to the recent multi-queue changes the driver would configure the
> queues to use the AVB mode, but the mode then got switched to DCB. The
> hardware still works fine in DCB mode, but my testing capabilities are
> limited, so it's safer to revert to the prior setting anyway.
> 
> Signed-off-by: Thierry Reding 
> ---
>  include/linux/stmmac.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> index be47b859e954..8349a5c1537b 100644
> --- a/include/linux/stmmac.h
> +++ b/include/linux/stmmac.h
> @@ -56,8 +56,8 @@
>  #define MTL_RX_ALGORITHM_WSP 0x5
>  
>  /* RX/TX Queue Mode */
> -#define MTL_QUEUE_DCB0x0
> -#define MTL_QUEUE_AVB0x1
> +#define MTL_QUEUE_AVB0x0
> +#define MTL_QUEUE_DCB0x1
>  
>  /* The MDC clock could be set higher than the IEEE 802.3
>   * specified frequency limit 0f 2.5 MHz, by programming a clock divider
> 

Thierry, I don't understand this patch. It will have 0 impact.

In stmmac_platform configuration, 0 impact:

if (of_property_read_bool(q_node, "snps,dcb-algorithm"))
plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
else if (of_property_read_bool(q_node, "snps,avb-algorithm"))
plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB;
else
**  plat->rx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;

In dwmac4_core, 0 impact:

value &= GMAC_RX_QUEUE_CLEAR(queue);
if (mode == MTL_QUEUE_AVB)
value |= GMAC_RX_AV_QUEUE_ENABLE(queue);
else if (mode == MTL_QUEUE_DCB)
value |= GMAC_RX_DCB_QUEUE_ENABLE(queue);

I think you should set the default mode in (**).

Thanks.


Re: [PATCH v2 1/2] gtp: rename SGSN netlink attribute

2017-03-21 Thread Pablo Neira Ayuso
On Tue, Mar 21, 2017 at 04:10:26PM +0100, Jonas Bonn wrote:
> On 03/21/2017 04:07 PM, Pablo Neira Ayuso wrote:
> >On Tue, Mar 21, 2017 at 04:04:29PM +0100, Jonas Bonn wrote:
> >>diff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h
> >>index 72a04a0..c51ebb0 100644
> >>--- a/include/uapi/linux/gtp.h
> >>+++ b/include/uapi/linux/gtp.h
> >>@@ -19,7 +19,7 @@ enum gtp_attrs {
> >>GTPA_LINK,
> >>GTPA_VERSION,
> >>GTPA_TID,   /* for GTPv0 only */
> >>-   GTPA_SGSN_ADDRESS,
> >>+   GTPA_PEER_ADDRESS,  /* Remote GSN peer, either SGSN or GGSN */
> >We need here:
> >
> >#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS
> >
> >for backward compatibility. Anything that is exposed through uapi
> >cannot be changed.
> 
> Yes... look a couple of lines further down...
> 
> >>GTPA_MS_ADDRESS,
> >>GTPA_FLOW,
> >>GTPA_NET_NS_FD,
> >>@@ -29,5 +29,6 @@ enum gtp_attrs {
> >>__GTPA_MAX,
> >>  };
> >>  #define GTPA_MAX (__GTPA_MAX + 1)
> >>+#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */
> 
> ... there it is! :)

Oh right!

Please, move it there to the enum definition, just after the new
GTPA_PEER_ADDRESS. We usually do this in other areas of the networking
code.

You also have to resubmit indicating net-next in your patch subject,
ie.  [PATCH net-next v3 1/2] gtp: rename SGSN netlink attribute

David usually requests that you explicitly indicate the target tree in
some way.

Thanks!


[PATCH v2 1/2] gtp: rename SGSN netlink attribute

2017-03-21 Thread Jonas Bonn
This is a mostly cosmetic rename of the SGSN netlink attribute to
the GTP link.  The justification for this is that we will be making
the module support decapsulation of "downstream" SGSN packets, in
which case the netlink parameter actually refers to the upstream GGSN
peer.  Renaming the parameter makes the relationship clearer.

The legacy name is maintained as a define in the header file in order
to not break existing code.

Signed-off-by: Jonas Bonn 
---
 drivers/net/gtp.c| 22 +++---
 include/uapi/linux/gtp.h |  3 ++-
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 50349a9..3806be6 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -56,7 +56,7 @@ struct pdp_ctx {
u16 af;
 
struct in_addr  ms_addr_ip4;
-   struct in_addr  sgsn_addr_ip4;
+   struct in_addr  peer_addr_ip4;
 
atomic_ttx_seq;
struct rcu_head rcu_head;
@@ -522,17 +522,17 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct 
net_device *dev,
}
 
rt = ip4_route_output_gtp(sock_net(sk), &fl4, gtp->sock0->sk,
- pctx->sgsn_addr_ip4.s_addr);
+ pctx->peer_addr_ip4.s_addr);
if (IS_ERR(rt)) {
netdev_dbg(dev, "no route to SSGN %pI4\n",
-  &pctx->sgsn_addr_ip4.s_addr);
+  &pctx->peer_addr_ip4.s_addr);
dev->stats.tx_carrier_errors++;
goto err;
}
 
if (rt->dst.dev == dev) {
netdev_dbg(dev, "circular route to SSGN %pI4\n",
-  &pctx->sgsn_addr_ip4.s_addr);
+  &pctx->peer_addr_ip4.s_addr);
dev->stats.collisions++;
goto err_rt;
}
@@ -894,8 +894,8 @@ static void ipv4_pdp_fill(struct pdp_ctx *pctx, struct 
genl_info *info)
 {
pctx->gtp_version = nla_get_u32(info->attrs[GTPA_VERSION]);
pctx->af = AF_INET;
-   pctx->sgsn_addr_ip4.s_addr =
-   nla_get_be32(info->attrs[GTPA_SGSN_ADDRESS]);
+   pctx->peer_addr_ip4.s_addr =
+   nla_get_be32(info->attrs[GTPA_PEER_ADDRESS]);
pctx->ms_addr_ip4.s_addr =
nla_get_be32(info->attrs[GTPA_MS_ADDRESS]);
 
@@ -981,13 +981,13 @@ static int ipv4_pdp_add(struct net_device *dev, struct 
genl_info *info)
switch (pctx->gtp_version) {
case GTP_V0:
netdev_dbg(dev, "GTPv0-U: new PDP ctx id=%llx ssgn=%pI4 ms=%pI4 
(pdp=%p)\n",
-  pctx->u.v0.tid, &pctx->sgsn_addr_ip4,
+  pctx->u.v0.tid, &pctx->peer_addr_ip4,
   &pctx->ms_addr_ip4, pctx);
break;
case GTP_V1:
netdev_dbg(dev, "GTPv1-U: new PDP ctx id=%x/%x ssgn=%pI4 
ms=%pI4 (pdp=%p)\n",
   pctx->u.v1.i_tei, pctx->u.v1.o_tei,
-  &pctx->sgsn_addr_ip4, &pctx->ms_addr_ip4, pctx);
+  &pctx->peer_addr_ip4, &pctx->ms_addr_ip4, pctx);
break;
}
 
@@ -1001,7 +1001,7 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct 
genl_info *info)
 
if (!info->attrs[GTPA_VERSION] ||
!info->attrs[GTPA_LINK] ||
-   !info->attrs[GTPA_SGSN_ADDRESS] ||
+   !info->attrs[GTPA_PEER_ADDRESS] ||
!info->attrs[GTPA_MS_ADDRESS])
return -EINVAL;
 
@@ -1114,7 +1114,7 @@ static int gtp_genl_fill_info(struct sk_buff *skb, u32 
snd_portid, u32 snd_seq,
goto nlmsg_failure;
 
if (nla_put_u32(skb, GTPA_VERSION, pctx->gtp_version) ||
-   nla_put_be32(skb, GTPA_SGSN_ADDRESS, pctx->sgsn_addr_ip4.s_addr) ||
+   nla_put_be32(skb, GTPA_PEER_ADDRESS, pctx->peer_addr_ip4.s_addr) ||
nla_put_be32(skb, GTPA_MS_ADDRESS, pctx->ms_addr_ip4.s_addr))
goto nla_put_failure;
 
@@ -1267,7 +1267,7 @@ static struct nla_policy gtp_genl_policy[GTPA_MAX + 1] = {
[GTPA_LINK] = { .type = NLA_U32, },
[GTPA_VERSION]  = { .type = NLA_U32, },
[GTPA_TID]  = { .type = NLA_U64, },
-   [GTPA_SGSN_ADDRESS] = { .type = NLA_U32, },
+   [GTPA_PEER_ADDRESS] = { .type = NLA_U32, },
[GTPA_MS_ADDRESS]   = { .type = NLA_U32, },
[GTPA_FLOW] = { .type = NLA_U16, },
[GTPA_NET_NS_FD]= { .type = NLA_U32, },
diff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h
index 72a04a0..c51ebb0 100644
--- a/include/uapi/linux/gtp.h
+++ b/include/uapi/linux/gtp.h
@@ -19,7 +19,7 @@ enum gtp_attrs {
GTPA_LINK,
GTPA_VERSION,
GTPA_TID,   /* for GTPv0 only */
-   GTPA_SGSN_ADDRESS,
+   GTPA_PEER_ADDRESS,  /* Remote GSN peer, either SGSN or GGSN */
GTPA_MS_ADDRESS,
GTPA_FL

[PATCH v2 2/2] gtp: support SGSN-side tunnels

2017-03-21 Thread Jonas Bonn
The GTP-tunnel driver is explicitly GGSN-side as it searches for PDP
contexts based on the incoming packets _destination_ address.  If we
want to write an SGSN, then we want to be idenityfing PDP contexts
based on _source_ address.

This patch adds a "role" argument at GTP-link creation time to specify
whether we are on the GGSN or SGSN side of the tunnel; this flag is then
used to determine which part of the IP packet to use in determining
the PDP context.

Signed-off-by: Jonas Bonn 
---
 drivers/net/gtp.c| 41 +++--
 include/uapi/linux/if_link.h |  7 +++
 2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 3806be6..b54d1a3 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -72,6 +72,7 @@ struct gtp_dev {
struct net  *net;
struct net_device   *dev;
 
+   unsigned introle;
unsigned inthash_size;
struct hlist_head   *tid_hash;
struct hlist_head   *addr_hash;
@@ -150,8 +151,8 @@ static struct pdp_ctx *ipv4_pdp_find(struct gtp_dev *gtp, 
__be32 ms_addr)
return NULL;
 }
 
-static bool gtp_check_src_ms_ipv4(struct sk_buff *skb, struct pdp_ctx *pctx,
- unsigned int hdrlen)
+static bool gtp_check_ms_ipv4(struct sk_buff *skb, struct pdp_ctx *pctx,
+ unsigned int hdrlen, unsigned int role)
 {
struct iphdr *iph;
 
@@ -160,18 +161,22 @@ static bool gtp_check_src_ms_ipv4(struct sk_buff *skb, 
struct pdp_ctx *pctx,
 
iph = (struct iphdr *)(skb->data + hdrlen);
 
-   return iph->saddr == pctx->ms_addr_ip4.s_addr;
+   if (role == GTP_ROLE_SGSN) {
+   return iph->daddr == pctx->ms_addr_ip4.s_addr;
+   } else {
+   return iph->saddr == pctx->ms_addr_ip4.s_addr;
+   }
 }
 
-/* Check if the inner IP source address in this packet is assigned to any
+/* Check if the inner IP address in this packet is assigned to any
  * existing mobile subscriber.
  */
-static bool gtp_check_src_ms(struct sk_buff *skb, struct pdp_ctx *pctx,
-unsigned int hdrlen)
+static bool gtp_check_ms(struct sk_buff *skb, struct pdp_ctx *pctx,
+unsigned int hdrlen, unsigned int role)
 {
switch (ntohs(skb->protocol)) {
case ETH_P_IP:
-   return gtp_check_src_ms_ipv4(skb, pctx, hdrlen);
+   return gtp_check_ms_ipv4(skb, pctx, hdrlen, role);
}
return false;
 }
@@ -205,7 +210,7 @@ static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct 
sk_buff *skb,
goto out_rcu;
}
 
-   if (!gtp_check_src_ms(skb, pctx, hdrlen)) {
+   if (!gtp_check_ms(skb, pctx, hdrlen, gtp->role)) {
netdev_dbg(gtp->dev, "No PDP ctx for this MS\n");
ret = -1;
goto out_rcu;
@@ -262,7 +267,7 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct 
sk_buff *skb,
goto out_rcu;
}
 
-   if (!gtp_check_src_ms(skb, pctx, hdrlen)) {
+   if (!gtp_check_ms(skb, pctx, hdrlen, gtp->role)) {
netdev_dbg(gtp->dev, "No PDP ctx for this MS\n");
ret = -1;
goto out_rcu;
@@ -491,7 +496,11 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct 
net_device *dev,
 * Prepend PDP header with TEI/TID from PDP ctx.
 */
iph = ip_hdr(skb);
-   pctx = ipv4_pdp_find(gtp, iph->daddr);
+   if (gtp->role == GTP_ROLE_SGSN) {
+   pctx = ipv4_pdp_find(gtp, iph->saddr);
+   } else {
+   pctx = ipv4_pdp_find(gtp, iph->daddr);
+   }
if (!pctx) {
netdev_dbg(dev, "no PDP ctx found for %pI4, skip\n",
   &iph->daddr);
@@ -666,12 +675,23 @@ static int gtp_newlink(struct net *src_net, struct 
net_device *dev,
int hashsize, err, fd0, fd1;
struct gtp_dev *gtp;
struct gtp_net *gn;
+   unsigned int role;
+
+   if (data[IFLA_GTP_ROLE]) {
+   role = nla_get_u32(data[IFLA_GTP_ROLE]);
+   if (role > GTP_ROLE_SGSN)
+   return -EINVAL;
+   } else {
+   role = GTP_ROLE_GGSN;
+   }
 
if (!data[IFLA_GTP_FD0] || !data[IFLA_GTP_FD1])
return -EINVAL;
 
gtp = netdev_priv(dev);
 
+   gtp->role = role;
+
fd0 = nla_get_u32(data[IFLA_GTP_FD0]);
fd1 = nla_get_u32(data[IFLA_GTP_FD1]);
 
@@ -723,6 +743,7 @@ static const struct nla_policy gtp_policy[IFLA_GTP_MAX + 1] 
= {
[IFLA_GTP_FD0]  = { .type = NLA_U32 },
[IFLA_GTP_FD1]  = { .type = NLA_U32 },
[IFLA_GTP_PDP_HASHSIZE] = { .type = NLA_U32 },
+   [IFLA_GTP_ROLE] = { .type = NLA_U32 },
 };
 
 static int gtp_validate(struct nlattr *tb[], struct nlattr *data[])
diff 

[PATCH v3 0/2] fjes: Do not load fjes driver

2017-03-21 Thread YASUAKI ISHIMATSU
The fjes driver is used only by FUJITSU servers and almost of all
servers in the world never use it. But currently if ACPI PNP0C02
is defined in the ACPI table, the following message is always shown:

 "FUJITSU Extended Socket Network Device Driver - version 1.2
  - Copyright (c) 2015 FUJITSU LIMITED"

The message makes users confused because there is no reason that
the message is shown in other vendor servers.

To avoid the confusion, the patch adds several checks.

v3:
  - Rebase on latest net tree.
  - Add _STA method check to avoid loading fjes driver.

v2:
  - Order local variable declarations from longest to shortest line

Yasuaki Ishimatsu(2):
  fjes: Do not load fjes driver if system does not have extended socket device.
  fjes: Do not load fjes driver if extended socket device is not power on.

 drivers/net/fjes/fjes_main.c | 76 +---
 1 file changed, 71 insertions(+), 5 deletions(-)


Re: [PATCH 2/2] netfilter: ipvs: Compress return logic

2017-03-21 Thread Sergei Shtylyov

Hello!

On 03/21/2017 04:23 PM, simran singhal wrote:


Simplify function returns by merging assignment and return into
one command line.


   You mean "one statement"?


Signed-off-by: simran singhal 
---

 --This is my contribution to the netfilter project of
   Outreachy Round 14.

 net/netfilter/ipvs/ip_vs_ftp.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index d30c327..c93c937 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -482,11 +482,8 @@ static struct pernet_operations ip_vs_ftp_ops = {

 static int __init ip_vs_ftp_init(void)
 {
-   int rv;
-
-   rv = register_pernet_subsys(&ip_vs_ftp_ops);
/* rcu_barrier() is called by netns on error */
-   return rv;
+   return register_pernet_subsys(&ip_vs_ftp_ops);
 }

 /*


MBR, Sergei



[PATCH v3 2/2] fjes: Do not load fjes driver if extended socket device is not power on.

2017-03-21 Thread YASUAKI ISHIMATSU
The extended device socket cannot turn on/off while system is running.
So when system boots up and the device is not power on, the fjes driver
does not need be loaded.

To check the status of the device, the patch adds ACPI _STA method check.

Signed-off-by: Yasuaki Ishimatsu 
CC: Taku Izumi 
---
 drivers/net/fjes/fjes_main.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 7b58964..ae48c80 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -144,6 +144,24 @@ static bool is_extended_socket_device(struct acpi_device 
*device)
return true;
 }

+static int acpi_check_extended_socket_status(struct acpi_device *device)
+{
+   unsigned long long sta;
+   acpi_status status;
+
+   status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
+   if (ACPI_FAILURE(status))
+   return -ENODEV;
+
+   if (!((sta & ACPI_STA_DEVICE_PRESENT) &&
+ (sta & ACPI_STA_DEVICE_ENABLED) &&
+ (sta & ACPI_STA_DEVICE_UI) &&
+ (sta & ACPI_STA_DEVICE_FUNCTIONING)))
+   return -ENODEV;
+
+   return 0;
+}
+
 static int fjes_acpi_add(struct acpi_device *device)
 {
struct platform_device *plat_dev;
@@ -152,6 +170,9 @@ static int fjes_acpi_add(struct acpi_device *device)
if (!is_extended_socket_device(device))
return -ENODEV;

+   if (acpi_check_extended_socket_status(device))
+   return -ENODEV;
+
status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
 fjes_get_acpi_resource, fjes_resource);
if (ACPI_FAILURE(status))
@@ -1503,6 +1524,9 @@ static void fjes_watch_unshare_task(struct work_struct 
*work)
if (!is_extended_socket_device(device))
return AE_OK;

+   if (acpi_check_extended_socket_status(device))
+   return AE_OK;
+
*found = true;
return AE_CTRL_TERMINATE;
 }
-- 
1.8.3.1


On 03/21/2017 11:28 AM, YASUAKI ISHIMATSU wrote:
> The fjes driver is used only by FUJITSU servers and almost of all
> servers in the world never use it. But currently if ACPI PNP0C02
> is defined in the ACPI table, the following message is always shown:
> 
>  "FUJITSU Extended Socket Network Device Driver - version 1.2
>   - Copyright (c) 2015 FUJITSU LIMITED"
> 
> The message makes users confused because there is no reason that
> the message is shown in other vendor servers.
> 
> To avoid the confusion, the patch adds several checks.
> 
> v3:
>   - Rebase on latest net tree.
>   - Add _STA method check to avoid loading fjes driver.
> 
> v2:
>   - Order local variable declarations from longest to shortest line
> 
> Yasuaki Ishimatsu(2):
>   fjes: Do not load fjes driver if system does not have extended socket 
> device.
>   fjes: Do not load fjes driver if extended socket device is not power on.
> 
>  drivers/net/fjes/fjes_main.c | 76 
> +---
>  1 file changed, 71 insertions(+), 5 deletions(-)
> 


[PATCH v3 1/2] fjes: Do not load fjes driver if system does not have extended socket device.

2017-03-21 Thread YASUAKI ISHIMATSU
The fjes driver is used only by FUJITSU servers and almost of all
servers in the world never use it. But currently if ACPI PNP0C02
is defined in the ACPI table, the following message is always shown:

 "FUJITSU Extended Socket Network Device Driver - version 1.2
  - Copyright (c) 2015 FUJITSU LIMITED"

The message makes users confused because there is no reason that
the message is shown in other vendor servers.

To avoid the confusion, the patch adds a check that the server
has a extended socket device or not.

Signed-off-by: Yasuaki Ishimatsu 
CC: Taku Izumi 
---
v3:
- Rebase on net tree

v2:
- Order local variable declarations from longest to shortest line

 drivers/net/fjes/fjes_main.c | 52 +++-
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index c4b3c4b..7b58964 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -45,6 +45,8 @@
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);

+#define ACPI_MOTHERBOARD_RESOURCE_HID "PNP0C02"
+
 static int fjes_request_irq(struct fjes_adapter *);
 static void fjes_free_irq(struct fjes_adapter *);

@@ -78,7 +80,7 @@
 static int fjes_poll(struct napi_struct *, int);

 static const struct acpi_device_id fjes_acpi_ids[] = {
-   {"PNP0C02", 0},
+   {ACPI_MOTHERBOARD_RESOURCE_HID, 0},
{"", 0},
 };
 MODULE_DEVICE_TABLE(acpi, fjes_acpi_ids);
@@ -115,18 +117,17 @@
},
 };

-static int fjes_acpi_add(struct acpi_device *device)
+static bool is_extended_socket_device(struct acpi_device *device)
 {
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1];
-   struct platform_device *plat_dev;
union acpi_object *str;
acpi_status status;
int result;

status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer);
if (ACPI_FAILURE(status))
-   return -ENODEV;
+   return false;

str = buffer.pointer;
result = utf16s_to_utf8s((wchar_t *)str->string.pointer,
@@ -136,10 +137,21 @@ static int fjes_acpi_add(struct acpi_device *device)

if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) {
kfree(buffer.pointer);
-   return -ENODEV;
+   return false;
}
kfree(buffer.pointer);

+   return true;
+}
+
+static int fjes_acpi_add(struct acpi_device *device)
+{
+   struct platform_device *plat_dev;
+   acpi_status status;
+
+   if (!is_extended_socket_device(device))
+   return -ENODEV;
+
status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
 fjes_get_acpi_resource, fjes_resource);
if (ACPI_FAILURE(status))
@@ -1473,11 +1485,41 @@ static void fjes_watch_unshare_task(struct work_struct 
*work)
}
 }

+static acpi_status
+acpi_find_extended_socket_device(acpi_handle obj_handle, u32 level,
+void *context, void **return_value)
+{
+   struct acpi_device *device;
+   bool *found = context;
+   int result;
+
+   result = acpi_bus_get_device(obj_handle, &device);
+   if (result)
+   return AE_OK;
+
+   if (strcmp(acpi_device_hid(device), ACPI_MOTHERBOARD_RESOURCE_HID))
+   return AE_OK;
+
+   if (!is_extended_socket_device(device))
+   return AE_OK;
+
+   *found = true;
+   return AE_CTRL_TERMINATE;
+}
+
 /* fjes_init_module - Driver Registration Routine */
 static int __init fjes_init_module(void)
 {
+   bool found = false;
int result;

+   acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+   acpi_find_extended_socket_device, NULL, &found,
+   NULL);
+
+   if (!found)
+   return -ENODEV;
+
pr_info("%s - version %s - %s\n",
fjes_driver_string, fjes_driver_version, fjes_copyright);

-- 
1.8.3.1



On 03/21/2017 11:28 AM, YASUAKI ISHIMATSU wrote:
> The fjes driver is used only by FUJITSU servers and almost of all
> servers in the world never use it. But currently if ACPI PNP0C02
> is defined in the ACPI table, the following message is always shown:
> 
>  "FUJITSU Extended Socket Network Device Driver - version 1.2
>   - Copyright (c) 2015 FUJITSU LIMITED"
> 
> The message makes users confused because there is no reason that
> the message is shown in other vendor servers.
> 
> To avoid the confusion, the patch adds several checks.
> 
> v3:
>   - Rebase on latest net tree.
>   - Add _STA method check to avoid loading fjes driver.
> 
> v2:
>   - Order local variable declarations from longest to shortest line
> 
> Yasuaki Ishimatsu(2):
>   fjes: Do not load fjes driver if system does not have extended socket 
> device.
>   fjes: Do not load fjes driver if extended socket device

Re: [PATCH 1/1] gtp: support SGSN-side tunnels

2017-03-21 Thread Jonas Bonn

Hi Harald,

On 03/15/2017 05:39 PM, Harald Welte wrote:

Hi Jonas,

are you working on the review feedback that was provided back in early
February?  I think there were some comments like
* remove unrelated cosmetic change in comment
* change from FLAGS to a dedicated MODE netlink attribute
* add libgtpnl code and some usage information or even sample scripts

I would definitely like to see this move forward, particularly in order
to test the GGSN-side code.


Sorry for the delay in this.

I've sent, just now, revised patches to the kernel module.

I was going to send some libgtpnl patches but I noticed, when gathering 
these up, that you have already made most of the necessary changes on a 
new branch.  What you've got there is almost identical to what I've got.


Since you used the terminology "role" instead of "mode" in your libgtpnl 
branch, I made the corresponding change in the kernel module, too, so it 
now calls this role instead of mode.


Regards,
Jonas






Regards,
Harald





Re: linux-next-20170320 break stmmac on dwmac-sunxi

2017-03-21 Thread Giuseppe CAVALLARO

Hello Corentin

yes, bisect process is really good approach to me. Pls give us more details.
Recently the multi DMA channel logic has been added so it could be that
something is needed to allow your platform to manage the new code.
Or we introduced some regression. If I have some other idea, I ping you.

Peppe

On 3/20/2017 8:54 PM, Corentin Labbe wrote:

Hello

Just pushed next-20170320 to my boards and stmmac stop working on both intree 
dwmac-sunxi and my dev dwmac-sun8i.
It seems that interrupts never fire, and transmit queue timeout.
I will try to bisect this problem but perhaps other people could try to 
reproduce it.

Regards
Corentin Labbe





Re: [RFC PATCH] net: phy: Don't miss phy_suspend() on PHY_HALTED for PHYs with interrupts

2017-03-21 Thread Florian Fainelli
On 03/21/2017 03:09 AM, Roger Quadros wrote:
> On 20/03/17 18:41, Florian Fainelli wrote:
>> On 03/16/2017 12:46 AM, Roger Quadros wrote:
>>> On 15/03/17 17:49, Andrew Lunn wrote:
 On Wed, Mar 15, 2017 at 05:00:08PM +0200, Roger Quadros wrote:
> Andrew,
>
> On 15/03/17 16:08, Andrew Lunn wrote:
>> On Wed, Mar 15, 2017 at 03:51:27PM +0200, Roger Quadros wrote:
>>> Since commit 3c293f4e08b5 ("net: phy: Trigger state machine on state 
>>> change and not polling.")
>>> phy_suspend() doesn't get called as part of phy_stop() for PHYs using
>>> interrupts because the phy state machine is never triggered after a 
>>> phy_stop().
>>>
>>> Explicitly trigger the PHY state machine so that it can
>>> see the new PHY state (HALTED) and suspend the PHY.
>>>
>>> Signed-off-by: Roger Quadros 
>>
>> Hi Roger
>>
>> This seems sensible. It mirrors what phy_start() does.
>>
>> Reviewed-by: Andrew Lunn 
>
> The reason for this being an RFC was the following comment just before
> where I add the phy_trigger_machine()
>
> /* Cannot call flush_scheduled_work() here as desired because
>  * of rtnl_lock(), but PHY_HALTED shall guarantee phy_change()
>  * will not reenable interrupts.
>  */
>
> Is this comment still applicable? If yes, is it OK to call
> phy_trigger_machine() there?

 Humm, good question.

 My _guess_ would be, calling it with sync=True could
 deadlock. sync=False is probably safe. But lets see what Florian says.
>>>
>>> I agree that we should use phy_trigger_machine() with sync=False.
>>>

>
>>
>> It does however lead to a follow up question. Are there other places
>> phydev->state is changed and it is missing a phy_trigger_machine()?
>>
>
> One other place I think we should add phy_trigger_machine() is 
> phy_start_aneg().

 Humm, that might get us into a tight loop.

 phy_start_aneg() kicks the phy driver to start autoneg and sets
 phydev->state = PHY_AN.

 phy_trigger_machine() triggers the state machine immediately. 

 In state PHY_AN, we check if aneg is done. If not, it sets needs_aneg
 = true. At the end of the state machine, this then calls
 phy_start_aneg(), and it all starts again.

 We are missing the 1s delay we have with polling. So for
 phy_start_aneg(), we might need a phy_delayed_trigger_machine(), which
 waits a second before doing anything?
>>>
>>> I think that should do the trick.
>>>
>>> How about this?
>>
>> This sounds like a possible fix indeed, however I would like to better
>> assess the impact on non interrupt driven PHYs before rolling such a change.
> 
> Is it safer if I add a check to do this only for interrupt driven PHYs?

Yes I think this is a good solution that would not impact polled PHYs.
Can you submit a formal patch for that change?

Thanks!

> 
> e.g.
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 4b855f2..e0f5755 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -630,6 +630,9 @@ int phy_start_aneg(struct phy_device *phydev)
>  
>  out_unlock:
>   mutex_unlock(&phydev->lock);
> + if (!err && phy_interrupt_is_valid(phydev))
> + queue_delayed_work(system_power_efficient_wq, 
> &phydev->state_queue, HZ);
> +
>   return err;
>  }
>  EXPORT_SYMBOL(phy_start_aneg);
> 


-- 
Florian


[PATCH] ipv6: make sure to initialize sockc.tsflags before first use

2017-03-21 Thread Alexander Potapenko
In the case udp_sk(sk)->pending is AF_INET6, udpv6_sendmsg() would
jump to do_append_data, skipping the initialization of sockc.tsflags.
Fix the problem by moving sockc.tsflags initialization earlier.

The bug was detected with KMSAN.

Signed-off-by: Alexander Potapenko 
---
For the record, here is the KMSAN report:

==
BUG: KMSAN: use of unitialized memory
CPU: 0 PID: 1027 Comm: udpv6_sendmsg Not tainted 4.8.0-rc6+ #2041
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
  88010c17f1a8 825b5098 88010c17f0e8
  85bae870 0092 85bae550
  0092  0002
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0x238/0x290 lib/dump_stack.c:51
 [] kmsan_report+0x180/0x210 mm/kmsan/kmsan.c:1022
 [] __msan_warning+0x8a/0x100 mm/kmsan/kmsan_instr.c:431
 [< inline >] sock_tx_timestamp ./include/net/sock.h:2162
 [] __ip6_append_data+0x52e0/0x6160 net/ipv6/ip6_output.c:1336
 [] ip6_append_data+0x453/0x750 net/ipv6/ip6_output.c:1599
 [] udpv6_sendmsg+0x10f2/0x47f0 net/ipv6/udp.c:1261
 [] inet_sendmsg+0x64e/0x930 net/ipv4/af_inet.c:740
 [< inline >] sock_sendmsg_nosec net/socket.c:609
 [< inline >] sock_sendmsg net/socket.c:619
 [] ___sys_sendmsg+0xe10/0x14e0 net/socket.c:1943
 [] __sys_sendmmsg+0x4ac/0x880 net/socket.c:2033
 [] SYSC_sendmmsg+0xb8/0x130 net/socket.c:2062
 [] SyS_sendmmsg+0x95/0xc0 net/socket.c:2057
 [] do_syscall_64+0x58/0x70 arch/x86/entry/common.c:292
 [] entry_SYSCALL64_slow_path+0x25/0x25 
arch/x86/entry/entry_64.o:?
chained origin: 922009b8
 [] save_stack_trace+0x27/0x50 arch/x86/kernel/stacktrace.c:67
 [< inline >] kmsan_save_stack_with_flags mm/kmsan/kmsan.c:349
 [< inline >] kmsan_save_stack mm/kmsan/kmsan.c:364
 [] kmsan_internal_chain_origin+0x12e/0x1f0 
mm/kmsan/kmsan.c:581
 [] __msan_set_alloca_origin4+0xdc/0x160 
mm/kmsan/kmsan_instr.c:386
 [] udpv6_sendmsg+0x2e8/0x47f0 net/ipv6/udp.c:1014
 [] inet_sendmsg+0x64e/0x930 net/ipv4/af_inet.c:740
 [< inline >] sock_sendmsg_nosec net/socket.c:609
 [< inline >] sock_sendmsg net/socket.c:619
 [] ___sys_sendmsg+0xe10/0x14e0 net/socket.c:1943
 [] __sys_sendmmsg+0x4ac/0x880 net/socket.c:2033
 [] SYSC_sendmmsg+0xb8/0x130 net/socket.c:2062
 [] SyS_sendmmsg+0x95/0xc0 net/socket.c:2057
 [] do_syscall_64+0x58/0x70 arch/x86/entry/common.c:292
 [] return_from_SYSCALL_64+0x0/0x6a 
arch/x86/entry/entry_64.o:?
origin description: sockc@udpv6_sendmsg (origin=9e8009b7)
==

and the reproducer that triggers it:
==
  #define _GNU_SOURCE
  #include 
  #include 

  int main()
  {
int sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);

struct sockaddr_in6 addr;
memset(&addr, 0, sizeof(struct sockaddr_in6));
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(2);
inet_pton(AF_INET6, ":0:400::", &addr.sin6_addr);

struct msghdr msg;
memset(&msg, 0, sizeof(struct msghdr));
msg.msg_name = &addr;
msg.msg_namelen = sizeof(struct sockaddr_in6);
sendmsg(sock, &msg, MSG_DONTROUTE|MSG_MORE);

struct mmsghdr mmsg;
memset(&mmsg, 0, sizeof(struct mmsghdr));
sendmmsg(sock, &mmsg, 1, 0);
return 0;
  }
==

---
 net/ipv6/udp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4e4c401e3bc6..e28082f0a307 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1035,6 +1035,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, 
size_t len)
ipc6.hlimit = -1;
ipc6.tclass = -1;
ipc6.dontfrag = -1;
+   sockc.tsflags = sk->sk_tsflags;
 
/* destination address check */
if (sin6) {
@@ -1159,7 +1160,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, 
size_t len)
 
fl6.flowi6_mark = sk->sk_mark;
fl6.flowi6_uid = sk->sk_uid;
-   sockc.tsflags = sk->sk_tsflags;
 
if (msg->msg_controllen) {
opt = &opt_space;
-- 
2.12.1.500.gab5fba24ee-goog



Re: [PATCH net 7/8] net/mlx5e: Count GSO packets correctly

2017-03-21 Thread Eric Dumazet
On Tue, 2017-03-21 at 15:59 +0200, Saeed Mahameed wrote:
> From: Gal Pressman 
> 
> TX packets statistics ('tx_packets' counter) used to count GSO packets
> as one, even though it contains multiple segments.
> This patch will increment the counter by the number of segments, and
> align the driver with the behavior of other drivers in the stack.
> 
> Note that no information is lost in this patch due to 'tx_tso_packets'
> counter existence.

> Signed-off-by: Gal Pressman 
> Cc: kernel-t...@fb.com
> Signed-off-by: Saeed Mahameed 
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c 
> b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
> index f193128bac4b..57f5e2d7ebd1 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
> @@ -274,15 +274,18 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, 
> struct sk_buff *skb)
>   sq->stats.tso_bytes += skb->len - ihs;
>   }
>  
> + sq->stats.packets += skb_shinfo(skb)->gso_segs;
>   num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs;

This reminds me that mlx4 does not trust gso_segs yet, not sure why.


diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c 
b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 
e0c5ffb3e3a6607456e1f191b0b8c8becfc71219..3ba89bc43d74d8c023776079bcd0bbadd70fb5c6
 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -978,8 +978,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct 
net_device *dev)
 
ring->tso_packets++;
 
-   i = ((skb->len - lso_header_size) / shinfo->gso_size) +
-   !!((skb->len - lso_header_size) % shinfo->gso_size);
+   i = shinfo->gso_segs;
tx_info->nr_bytes = skb->len + (i - 1) * lso_header_size;
ring->packets += i;
} else {




Re: [PATCH] ipv6: make sure to initialize sockc.tsflags before first use

2017-03-21 Thread Soheil Hassas Yeganeh
On Tue, Mar 21, 2017 at 12:14 PM, Alexander Potapenko  wrote:
> In the case udp_sk(sk)->pending is AF_INET6, udpv6_sendmsg() would
> jump to do_append_data, skipping the initialization of sockc.tsflags.
> Fix the problem by moving sockc.tsflags initialization earlier.
>
> The bug was detected with KMSAN.

Nice catch and thanks for the fix! This is missing a "fixes"
attribution, added below.

> Signed-off-by: Alexander Potapenko 

Fixes: c14ac9451c34 ("sock: enable timestamping using control messages")
Acked-by: Soheil Hassas Yeganeh 


Re: [PATCH net-next] stmmac: call stmmac_init_phy from stmmac_dvr_probe

2017-03-21 Thread Florian Fainelli
On 03/21/2017 02:04 AM, Niklas Cassel wrote:
> On 03/20/2017 11:07 PM, Florian Fainelli wrote:
>>
>> (snip)
>>>
>>> However, it is kind of sad that drivers are so inconsistent of what goes
>>> in probe and what goes in ndo_open...which is tied together with the
>>> whole mess of when certain ethtool commands work or do not work.
>> Well, inconsistent here is kind of big statement, what I meant to say is
>> that your proposed change actually makes thing inconsistent.
> 
> What I mean is that it is about 50/50 if something e.g. phy_connect
> is called from probe or from ndo_open.
> This is what I think is inconsistent.
> 
> git grep -p -E "phy_connect\(|phy_connect_direct\(" drivers/net/ethernet/ | 
> grep open | wc -l
> 12
> 
> git grep -p -E "phy_connect\(|phy_connect_direct\(" drivers/net/ethernet/ | 
> grep probe | wc -l
> 27
> even if we exclude *_mii_probe/*_mdio_probe which are done
> git grep -p mii_probe drivers/net/ethernet/ | grep open | wc -l
> 6
> git grep -p mdio_probe drivers/net/ethernet/ | grep open | wc -l
> 2
> 
> phy_connect done from probe:
> 27-6-2=19
> 
> phy_connect done from ndo_open:
> 12+6+2=20
> 
> 
>>
>>> Do you know of a good way to avoid the -EBUSY in 
>>> stmmac_ethtool_get_link_ksettings,
>>> but still keep phy_connect in ndo_open?
>> Let me rephrase this: doing an ethtool operation on an interface that is
>> not open is not a defined behavior which adheres to a contract with the
>> kernel. ethtool operations on interfaces that are DOWN, may succeed if
>> they do not involve a piece of hardware that needs to be active (e.g:
>> the PHY) but there is no guarantee that a) the change is immediately
>> applied, or b) that the results are consistent.
>>
>> The best thing to do IMHO is just silence the warning, return an error
>> coed, and come back configuring the interface at a later time when it is
>> guaranteed to be operational.
> 
> Thank you for your feedback. I agree with you,
> silencing the warning would be the best way forward.
> David, please ignore this patch.
> 
> 
> 
> However, since ethtool is a user interface, I think that it would
> have been nice if it wasn't so driver specific regarding to if a
> command works before the interface is open or not.

On premise I agree, in practice, every HW and driver is different, and
enforcing standard behaviors is even more difficult as there are
multiple pieces of HW interconnected to each other: MAC, MDIO bus, PHY
etc. all with different power management capabilities and properties,
and different requirements, and of course, varying degrees of brokenness.

> 
> If the user does some ethtool operation that affects e.g. the PHY
> before the interface is open, perhaps there is a way to save this
> setting so it could be applied when the resource is available.

Well behaving driver will connect to the PHY as one of their final
driver's ndo_open() step, any call in between will result in phydev
being NULL which will return a proper error code and should be acted
upon by the application doing the ethtool calls (or the one doing
ioctl() calls similar to ethtool).

> 
> For the PHY case, net_device has a pointer to a phy_device,
> register_netdev could create a dummy phy_device if
> ndev->phy_device is NULL, that way changes could be saved
> and applied when phy_connect replaces the dummy device
> (or perhaps when phy_start() is called).
> (If it isn't a dummy phy_device, changes could be applied immediately.)
> This way it would not matter if phy_connect is done from probe
> or from ndo_open.
> 

I don't think there is a need for a dummy PHY device, you can do this in
your driver if you want to, but this adds a lot of complexity for little
value, and, keep in mind that before ndo_open() is complete, most
operations against your network driver can be undefined.
-- 
Florian


[PATCH net-next 0/7] Clean up PHY MMD accessors

2017-03-21 Thread Russell King - ARM Linux
This series cleans up phylib's MMD accessors, so that we have a common
way of accessing the Clause 45 register set.

The current situation is far from ideal - we have phy_(read|write)_mmd()
which accesses Clause 45 registers over Clause 45 accesses, and we have
phy_(read|write)_mmd_indirect(), which accesses Clause 45 registers via
Clause 22 register 13/14.

Generic code uses the indirect methods to access standard Clause 45
features, and when we come to add Clause 45 PHY support to phylib, we
would need to make these conditional upon the PHY type, or duplicate
these functions.

An alternative solution is to merge these accessors together, and select
the appropriate access method depending upon the 802.3 clause that the
PHY conforms with.  The result is that we have a single set of
phy_(read|write)_mmd() accessors.

For cases which require special handling, we still allow PHY drivers to
override all MMD accesses - except rather than just overriding the
indirect accesses.  This keeps existing overrides working.

Combining the two also has another beneficial side effect - we get rid
of similar functions that take arguments in different orders.  The
old direct accessors took the phy structure, devad and register number,
whereas the indirect accessors took the phy structure, register number
and devad in that order.  Care must be taken when updating future
drivers that the argument order is correct, and the function name is
not merely replaced.

This patch set is against net-next.

 drivers/net/phy/Makefile  |   2 +-
 drivers/net/phy/bcm-phy-lib.c |  12 ++---
 drivers/net/phy/dp83867.c |  25 +-
 drivers/net/phy/intel-xway.c  |  26 +-
 drivers/net/phy/micrel.c  |  13 +++--
 drivers/net/phy/microchip.c   |   5 +-
 drivers/net/phy/phy-core.c| 101 ++
 drivers/net/phy/phy.c | 110 --
 drivers/net/phy/phy_device.c  |   4 +-
 drivers/net/usb/lan78xx.c |  10 ++--
 include/linux/phy.h   |  80 +-
 11 files changed, 178 insertions(+), 210 deletions(-)

RFC->v1:
- minor update patch 2 to resolve a build error that the 0-day builder
  discovered.
- reviewed-by / acked-bys added

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


Re: [PATCH 1/3] net: stmmac: Always enable MAC RX queues

2017-03-21 Thread Thierry Reding
On Tue, Mar 21, 2017 at 03:18:20PM +, Joao Pinto wrote:
> Às 3:12 PM de 3/21/2017, Thierry Reding escreveu:
> > From: Thierry Reding 
> > 
> > The MAC RX queues always need to be enabled in order to receive network
> > packets. Remove the condition that this only needs to be done for multi-
> > queue configurations.
> > 
> > Signed-off-by: Thierry Reding 
> > ---
> >  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index d3a21519e4c0..298956032098 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -1943,7 +1943,7 @@ static void stmmac_mtl_configuration(struct 
> > stmmac_priv *priv)
> > stmmac_rx_queue_dma_chan_map(priv);
> >  
> > /* Enable MAC RX Queues */
> > -   if (rx_queues_count > 1 && priv->hw->mac->rx_queue_enable)
> > +   if (priv->hw->mac->rx_queue_enable)
> > stmmac_mac_enable_rx_queues(priv);
> >  
> > /* Set the HW DMA mode and the COE */
> > 
> 
> This text is from the Databook:
> 
> "In multiple Rx queues configuration, all the queues are disabled by default.
> Enable the Rx queue by programming the corresponding field in this register."
> 
> So by theory, only multiple queue configured cores needs the enable operation.

But that's related to multiple queues configured in the core when it was
instantiated (i.e. the capabilities). rx_queues_count reflects the
number of queues enabled in the driver, so it can be 1 even if the core
itself supports more than one queue.

In that case, we still want to enable the MAC RX queue because it will
otherwise remain disabled.

> 
> >>> But came to my attention a setup that has 1 RX queue and 2 TX queues, 
> >>> which
> enables multiple queues mechanism inside the core (even with 1 RX) and so RX
> needs to be enabled. Because of that I agree with this patch.
> 
> Acked-By: Joao Pinto 

Yeah, that case would also require this patch.

Thierry


signature.asc
Description: PGP signature


[PATCH net-next 2/7] net: phy: make phy_(read|write)_mmd() generic MMD accessors

2017-03-21 Thread Russell King
Make phy_(read|write)_mmd() generic 802.3 clause 45 register accessors
for both Clause 22 and Clause 45 PHYs, using either the direct register
reading for Clause 45, or the indirect method for Clause 22 PHYs.
Allow this behaviour to be overriden by PHY drivers where necessary.

Reviewed-by: Andrew Lunn 
Reviewed-by: Florian Fainelli 
Signed-off-by: Russell King 
---
 drivers/net/phy/phy-core.c | 33 +
 include/linux/phy.h| 24 
 2 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index b8d8276a3099..d791100afab2 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -69,11 +69,18 @@ EXPORT_SYMBOL(phy_read_mmd_indirect);
  */
 int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
 {
-   if (!phydev->is_c45)
-   return -EOPNOTSUPP;
+   if (regnum > (u16)~0 || devad > 32)
+   return -EINVAL;
 
-   return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr,
-   MII_ADDR_C45 | (devad << 16) | (regnum & 0x));
+   if (phydev->drv->read_mmd)
+   return phydev->drv->read_mmd(phydev, devad, regnum);
+
+   if (phydev->is_c45) {
+   u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0x);
+   return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, addr);
+   }
+
+   return phy_read_mmd_indirect(phydev, regnum, devad);
 }
 EXPORT_SYMBOL(phy_read_mmd);
 
@@ -125,11 +132,21 @@ EXPORT_SYMBOL(phy_write_mmd_indirect);
  */
 int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val)
 {
-   if (!phydev->is_c45)
-   return -EOPNOTSUPP;
+   if (regnum > (u16)~0 || devad > 32)
+   return -EINVAL;
+
+   if (phydev->drv->read_mmd)
+   return phydev->drv->write_mmd(phydev, devad, regnum, val);
+
+   if (phydev->is_c45) {
+   u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0x);
+
+   return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr,
+addr, val);
+   }
 
-   regnum = MII_ADDR_C45 | ((devad & 0x1f) << 16) | (regnum & 0x);
+   phy_write_mmd_indirect(phydev, regnum, devad, val);
 
-   return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, val);
+   return 0;
 }
 EXPORT_SYMBOL(phy_write_mmd);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index bcb4549b41d6..b8feeffeb64c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -587,6 +587,30 @@ struct phy_driver {
 */
void (*link_change_notify)(struct phy_device *dev);
 
+   /*
+* Phy specific driver override for reading a MMD register.
+* This function is optional for PHY specific drivers.  When
+* not provided, the default MMD read function will be used
+* by phy_read_mmd(), which will use either a direct read for
+* Clause 45 PHYs or an indirect read for Clause 22 PHYs.
+*  devnum is the MMD device number within the PHY device,
+*  regnum is the register within the selected MMD device.
+*/
+   int (*read_mmd)(struct phy_device *dev, int devnum, u16 regnum);
+
+   /*
+* Phy specific driver override for writing a MMD register.
+* This function is optional for PHY specific drivers.  When
+* not provided, the default MMD write function will be used
+* by phy_write_mmd(), which will use either a direct write for
+* Clause 45 PHYs, or an indirect write for Clause 22 PHYs.
+*  devnum is the MMD device number within the PHY device,
+*  regnum is the register within the selected MMD device.
+*  val is the value to be written.
+*/
+   int (*write_mmd)(struct phy_device *dev, int devnum, u16 regnum,
+u16 val);
+
/* A function provided by a phy specific driver to override the
 * the PHY driver framework support for reading a MMD register
 * from the PHY. If not supported, return -1. This function is
-- 
2.7.4



  1   2   3   >