RE: [PATCH net v2] r8169:fix "rtl_counters_cond == 1 (loop: 1000, delay: 10)" log spam.

2016-02-22 Thread Hau
> Nits:
> 
> - the tp->TxDescArray test provides the required synchronization: see
>   rtl8169_{open/close} and their pm_runtime_{get / put}.
> 
> - ioaddr is not really needed : tp->mmio_addr appears only once and it does
>   not mess the 72..80 cols limit.
> 
> - even if the device can only be automatically runtime suspended some time
>   after a link down event, you may address davem's point regarding stats
>   reliability and move rtl8169_rx_missed + rtl8169_update_counters after
>   rtl8169_net_suspend.

I will submit the new patch according to your advice.

Thanks.

Please consider the environment before printing this e-mail.


Re: [patch net-next 1/9] Introduce devlink infrastructure

2016-02-22 Thread Jiri Pirko
Mon, Feb 22, 2016 at 11:29:06PM CET, ro...@cumulusnetworks.com wrote:
>On 2/22/16, 10:31 AM, Jiri Pirko wrote:
>> From: Jiri Pirko 
>>
>> Introduce devlink infrastructure for drivers to register and expose to
>> userspace via generic Netlink interface.
>>
>> There are two basic objects defined:
>> devlink - one instance for every "parent device", for example switch ASIC
>> devlink port - one instance for every physical port of the device.
>
>Like i have expressed earlier, the only thing that bothers me here is that we 
>are creating a new devlink object for switch port when there
>is an existing netdev object.

Sometimes it is, sometimes it is not (IB). I bevelieve that there is a
need for a "handle" for a physical port, regardless what type it is.
The same instance exists all the time, even if you change the type or if
the netdev is not created yet (init phase)


>
>Is there a chance that the drivers you are targeting can still create netdevs 
>for physical ports ?
>It would make things so much more consistent and simpler to manage without a 
>cost of adding yet another interface.

So you see a problem in having devlink_port handle here? It is just an
index, very simple. But you would rather see something like:
myhost:~$ dl dev show
0: devlink0: bus pci dev :01:00.0
myhost:~$ dl port show
ens4: type eth parent devlink0
ens5: type eth parent devlink0
?

There are 2 problems with that approach:
1) It's hard to use this for IB devices, they don't necessary have
   netdev associated.
2) You have to have the netdevs created (know ifindex) in order to work
   with that from userspace. But there are usecases, for example during
   initialization that netdevs are not yet present and user needs to
   specify port for configuration (that is usecase #4 I listed in the cover
   letter)

But it is very easy to change dl userspace tool to be able to use netdev
names to specify ports when possible. Then you could do something like
for example:
myswitch:~$ sudo dl port split eth0 2


>
>The port splitter support is needed at the netdev api too (ie rtnetlink). Most 
>switchdev drivers that expose netdevs
>would benefit from a native 'ip link' way to configure port splitting. This 
>will be useful for nic drivers too.

Why would it be needed in rtnetlink too if it would be exported using
devlink? I don't get it. Sounds similar like if you would expose
wireless-specific stuff via rtnetlink in parallel to nl80211.


Re: [patch net-next 0/9] Introduce devlink interface and first drivers to use it

2016-02-22 Thread Jiri Pirko
Tue, Feb 23, 2016 at 06:12:15AM CET, go...@cumulusnetworks.com wrote:
>On Mon, Feb 22, 2016 at 07:31:55PM +0100, Jiri Pirko wrote:
>> From: Jiri Pirko 
>> 
>> There a is need for some userspace API that would allow to expose things
>> that are not directly related to any device class like net_device of
>> ib_device, but rather chip-wide/switch-ASIC-wide stuff.
>> 
>> Use cases:
>> 1) get/set of port type (Ethernet/InfiniBand)
>> 2) setting up port splitters - split port into multiple ones and squash 
>> again,
>>enables usage of splitter cable
>> 3) setting up shared buffers - shared among multiple ports within
>>one chip (work in progress)
>> 4) configuration of switch wide properties - resources division etc - This 
>> will
>>allow to pass configuration that is unacceptable to be passed as
>>a module option.
>
>I'm generally a fan of use cases #3 and #4 (as we have previously
>discussed), but I'm not sure I agree that the implementation for #2
>right now.
>
>I'm not sure I would like userspace to have control over whether or not
>a port should be split or not when the hardware can be queried to
>determine this.

I was thinking about this myself for a long time and initially it made
more sense to me the approach you are suggesting. But after lot of
thining, I saw a lot of issues, I changed my mind and now I believe that
splitter should be set by user.

when you set the splitter port, you have 2 or 4 ports created in
hardware. They looks exactly the same as unsplitted ports, they are only
wired up differently. There is a netdev created for every splitter port,
user would add it to bridge, bond, vlan, set routes, define static fdb
entry and hw would learn fdbs itself. Now when someone disconnects the
splitter cable, 2 things may happen:
1) yourway. Netdevs disappear, all configs and state info will disappear
   with it.
2) myway. Netdevs stay, only link is down. This is the same behaviour is
   if someone uplugs cable for unplitted port.

There are also similar issues before you plug the splitter cable. So it
makes sense to let user co configure this. He knows what he wants. 1)
does not look like correct behaviour to me, 2) does.





>>  myhost:~$ dl port show
>>  devlink0/1: type eth netdev ens4
> ^^^
>>  devlink0/2: type ib ibdev mlx4_0
>
>I think my only other question about this implementation is whether or
>not one would really want to have the true netdev/ibdev names mapped
>here.
>
>Would be as reasonable to simply specify the type (and there may be more
>types within ethernet that could be useful in multi-chip configurations)
>and then let normal infrastructure that exists today figure out how to
>map the names for the netdevs to the devices?

What normal infrastructure you have in mind? There is no info about
devlink port mapping to netdev/ibdev anywhere. Only here. I might be
missing something but I fail to see what's wrong with it.


Re: [net-next PATCH 0/5] net_sched: Add support for IFE action

2016-02-22 Thread Cong Wang
On Mon, Feb 22, 2016 at 5:21 AM, Jamal Hadi Salim  wrote:
> From: Jamal Hadi Salim 
>
>
> As agreed at netconf in Seville, here's the patch finally (1 year
> was just too long to wait).
> Described in netdev01 paper:
> "Distributing Linux Traffic Control Classifier-Action Subsystem"
>  Authors: Jamal Hadi Salim and Damascene M. Joachimpillai

It would be nice if you can put a paragraph summary here, I am too lazy
to read through the whole paper and the IETF drafts. ;)


[PATCH 19/20] batman-adv: Rename batadv_tt_global_entry *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/translation-table.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index de3e731542e3..7f65a8f17f52 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -247,12 +247,12 @@ static void batadv_tt_global_entry_release(struct kref 
*ref)
 }
 
 /**
- * batadv_tt_global_entry_free_ref - decrement the tt_global_entry refcounter
- *  and possibly release it
+ * batadv_tt_global_entry_put - decrement the tt_global_entry refcounter and
+ *  possibly release it
  * @tt_global_entry: tt_global_entry to be free'd
  */
 static void
-batadv_tt_global_entry_free_ref(struct batadv_tt_global_entry *tt_global_entry)
+batadv_tt_global_entry_put(struct batadv_tt_global_entry *tt_global_entry)
 {
kref_put(_global_entry->common.refcount,
 batadv_tt_global_entry_release);
@@ -278,7 +278,7 @@ int batadv_tt_global_hash_count(struct batadv_priv 
*bat_priv,
return 0;
 
count = atomic_read(_global_entry->orig_list_count);
-   batadv_tt_global_entry_free_ref(tt_global_entry);
+   batadv_tt_global_entry_put(tt_global_entry);
 
return count;
 }
@@ -561,7 +561,7 @@ static void batadv_tt_global_free(struct batadv_priv 
*bat_priv,
 
batadv_hash_remove(bat_priv->tt.global_hash, batadv_compare_tt,
   batadv_choose_tt, _global->common);
-   batadv_tt_global_entry_free_ref(tt_global);
+   batadv_tt_global_entry_put(tt_global);
 }
 
 /**
@@ -756,7 +756,7 @@ out:
if (tt_local)
batadv_tt_local_entry_put(tt_local);
if (tt_global)
-   batadv_tt_global_entry_free_ref(tt_global);
+   batadv_tt_global_entry_put(tt_global);
return ret;
 }
 
@@ -1467,7 +1467,7 @@ static bool batadv_tt_global_add(struct batadv_priv 
*bat_priv,
 
if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */
-   batadv_tt_global_entry_free_ref(tt_global_entry);
+   batadv_tt_global_entry_put(tt_global_entry);
goto out_remove;
}
} else {
@@ -1553,7 +1553,7 @@ out_remove:
 
 out:
if (tt_global_entry)
-   batadv_tt_global_entry_free_ref(tt_global_entry);
+   batadv_tt_global_entry_put(tt_global_entry);
if (tt_local_entry)
batadv_tt_local_entry_put(tt_local_entry);
return ret;
@@ -1909,7 +1909,7 @@ static void batadv_tt_global_del(struct batadv_priv 
*bat_priv,
 
 out:
if (tt_global_entry)
-   batadv_tt_global_entry_free_ref(tt_global_entry);
+   batadv_tt_global_entry_put(tt_global_entry);
if (local_entry)
batadv_tt_local_entry_put(local_entry);
 }
@@ -1965,7 +1965,7 @@ void batadv_tt_global_del_orig(struct batadv_priv 
*bat_priv,
   tt_global->common.addr,
   BATADV_PRINT_VID(vid), message);
hlist_del_rcu(_common_entry->hash_entry);
-   batadv_tt_global_entry_free_ref(tt_global);
+   batadv_tt_global_entry_put(tt_global);
}
}
spin_unlock_bh(list_lock);
@@ -2028,7 +2028,7 @@ static void batadv_tt_global_purge(struct batadv_priv 
*bat_priv)
 
hlist_del_rcu(_common->hash_entry);
 
-   batadv_tt_global_entry_free_ref(tt_global);
+   batadv_tt_global_entry_put(tt_global);
}
spin_unlock_bh(list_lock);
}
@@ -2060,7 +2060,7 @@ static void batadv_tt_global_table_free(struct 
batadv_priv *bat_priv)
tt_global = container_of(tt_common_entry,
 struct batadv_tt_global_entry,
 common);
-   batadv_tt_global_entry_free_ref(tt_global);
+   batadv_tt_global_entry_put(tt_global);
}
spin_unlock_bh(list_lock);
}
@@ -2141,7 +2141,7 @@ struct batadv_orig_node *batadv_transtable_search(struct 
batadv_priv *bat_priv,
 
 out:
if (tt_global_entry)
-   batadv_tt_global_entry_free_ref(tt_global_entry);
+   

[PATCH 15/20] batman-adv: Rename batadv_nc_node *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/network-coding.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 9180ff114a26..6105cfb0574c 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -223,11 +223,11 @@ static void batadv_nc_node_release(struct kref *ref)
 }
 
 /**
- * batadv_nc_node_free_ref - decrement the nc_node refcounter and possibly
+ * batadv_nc_node_put - decrement the nc_node refcounter and possibly
  *  release it
  * @nc_node: nc_node to be free'd
  */
-static void batadv_nc_node_free_ref(struct batadv_nc_node *nc_node)
+static void batadv_nc_node_put(struct batadv_nc_node *nc_node)
 {
kref_put(_node->refcount, batadv_nc_node_release);
 }
@@ -356,7 +356,7 @@ batadv_nc_purge_orig_nc_nodes(struct batadv_priv *bat_priv,
   "Removing nc_node %pM -> %pM\n",
   nc_node->addr, nc_node->orig_node->orig);
list_del_rcu(_node->list);
-   batadv_nc_node_free_ref(nc_node);
+   batadv_nc_node_put(nc_node);
}
spin_unlock_bh(lock);
 }
@@ -942,9 +942,9 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
 
 out:
if (in_nc_node)
-   batadv_nc_node_free_ref(in_nc_node);
+   batadv_nc_node_put(in_nc_node);
if (out_nc_node)
-   batadv_nc_node_free_ref(out_nc_node);
+   batadv_nc_node_put(out_nc_node);
 }
 
 /**
-- 
2.7.1



[PATCH 10/20] batman-adv: Rename batadv_dat_entry *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/distributed-arp-table.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 919f3445fff3..4c9b69d465a6 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -77,11 +77,11 @@ static void batadv_dat_entry_release(struct kref *ref)
 }
 
 /**
- * batadv_dat_entry_free_ref - decrement the dat_entry refcounter and possibly
+ * batadv_dat_entry_put - decrement the dat_entry refcounter and possibly
  *  release it
  * @dat_entry: dat_entry to be free'd
  */
-static void batadv_dat_entry_free_ref(struct batadv_dat_entry *dat_entry)
+static void batadv_dat_entry_put(struct batadv_dat_entry *dat_entry)
 {
kref_put(_entry->refcount, batadv_dat_entry_release);
 }
@@ -135,7 +135,7 @@ static void __batadv_dat_purge(struct batadv_priv *bat_priv,
continue;
 
hlist_del_rcu(_entry->hash_entry);
-   batadv_dat_entry_free_ref(dat_entry);
+   batadv_dat_entry_put(dat_entry);
}
spin_unlock_bh(list_lock);
}
@@ -349,7 +349,7 @@ static void batadv_dat_entry_add(struct batadv_priv 
*bat_priv, __be32 ip,
 
if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */
-   batadv_dat_entry_free_ref(dat_entry);
+   batadv_dat_entry_put(dat_entry);
goto out;
}
 
@@ -358,7 +358,7 @@ static void batadv_dat_entry_add(struct batadv_priv 
*bat_priv, __be32 ip,
 
 out:
if (dat_entry)
-   batadv_dat_entry_free_ref(dat_entry);
+   batadv_dat_entry_put(dat_entry);
 }
 
 #ifdef CONFIG_BATMAN_ADV_DEBUG
@@ -1029,7 +1029,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct 
batadv_priv *bat_priv,
}
 out:
if (dat_entry)
-   batadv_dat_entry_free_ref(dat_entry);
+   batadv_dat_entry_put(dat_entry);
return ret;
 }
 
@@ -1109,7 +1109,7 @@ bool batadv_dat_snoop_incoming_arp_request(struct 
batadv_priv *bat_priv,
}
 out:
if (dat_entry)
-   batadv_dat_entry_free_ref(dat_entry);
+   batadv_dat_entry_put(dat_entry);
if (ret)
kfree_skb(skb);
return ret;
@@ -1262,6 +1262,6 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv 
*bat_priv,
 
 out:
if (dat_entry)
-   batadv_dat_entry_free_ref(dat_entry);
+   batadv_dat_entry_put(dat_entry);
return ret;
 }
-- 
2.7.1



[PATCH v2] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Diego Viola
The JMC260 network card fails to suspend/resume because the call to
jme_start_irq() was too early, moving the call to jme_start_irq() after
the jme_reset_link() function makes it work.

Prior this change suspend/resume would fail unless /sys/power/pm_async=0
was explicitly specified.

Signed-off-by: Diego Viola 
---
 drivers/net/ethernet/jme.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index b1de7af..8adbe8f 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -3312,13 +3312,14 @@ jme_resume(struct device *dev)
jme_reset_phy_processor(jme);
jme_phy_calibration(jme);
jme_phy_setEA(jme);
-   jme_start_irq(jme);
netif_device_attach(netdev);
 
atomic_inc(>link_changing);
 
jme_reset_link(jme);
 
+   jme_start_irq(jme);
+
return 0;
 }
 
-- 
2.7.1



[PATCH 13/20] batman-adv: Rename batadv_tvlv_container *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 95aaff371966..bf8a01b8f026 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -694,11 +694,11 @@ static void batadv_tvlv_container_release(struct kref 
*ref)
 }
 
 /**
- * batadv_tvlv_container_free_ref - decrement the tvlv container refcounter and
+ * batadv_tvlv_container_put - decrement the tvlv container refcounter and
  *  possibly release it
  * @tvlv: the tvlv container to free
  */
-static void batadv_tvlv_container_free_ref(struct batadv_tvlv_container *tvlv)
+static void batadv_tvlv_container_put(struct batadv_tvlv_container *tvlv)
 {
kref_put(>refcount, batadv_tvlv_container_release);
 }
@@ -784,8 +784,8 @@ static void batadv_tvlv_container_remove(struct batadv_priv 
*bat_priv,
hlist_del(>list);
 
/* first call to decrement the counter, second call to free */
-   batadv_tvlv_container_free_ref(tvlv);
-   batadv_tvlv_container_free_ref(tvlv);
+   batadv_tvlv_container_put(tvlv);
+   batadv_tvlv_container_put(tvlv);
 }
 
 /**
-- 
2.7.1



[PATCH 14/20] batman-adv: Rename batadv_softif_vlan *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/main.c  |  2 +-
 net/batman-adv/soft-interface.c| 14 +++---
 net/batman-adv/soft-interface.h|  2 +-
 net/batman-adv/sysfs.c |  4 ++--
 net/batman-adv/translation-table.c | 20 ++--
 5 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index bf8a01b8f026..e3d7051747b0 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -1261,7 +1261,7 @@ bool batadv_vlan_ap_isola_get(struct batadv_priv 
*bat_priv, unsigned short vid)
vlan = batadv_softif_vlan_get(bat_priv, vid);
if (vlan) {
ap_isolation_enabled = atomic_read(>ap_isolation);
-   batadv_softif_vlan_free_ref(vlan);
+   batadv_softif_vlan_put(vlan);
}
 
return ap_isolation_enabled;
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index ca8fa4e28d4f..0710379491bf 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -497,11 +497,11 @@ static void batadv_softif_vlan_release(struct kref *ref)
 }
 
 /**
- * batadv_softif_vlan_free_ref - decrease the vlan object refcounter and
+ * batadv_softif_vlan_put - decrease the vlan object refcounter and
  *  possibly release it
  * @vlan: the vlan object to release
  */
-void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *vlan)
+void batadv_softif_vlan_put(struct batadv_softif_vlan *vlan)
 {
if (!vlan)
return;
@@ -552,7 +552,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, 
unsigned short vid)
 
vlan = batadv_softif_vlan_get(bat_priv, vid);
if (vlan) {
-   batadv_softif_vlan_free_ref(vlan);
+   batadv_softif_vlan_put(vlan);
return -EEXIST;
}
 
@@ -601,7 +601,7 @@ static void batadv_softif_destroy_vlan(struct batadv_priv 
*bat_priv,
   vlan->vid, "vlan interface destroyed", false);
 
batadv_sysfs_del_vlan(bat_priv, vlan);
-   batadv_softif_vlan_free_ref(vlan);
+   batadv_softif_vlan_put(vlan);
 }
 
 /**
@@ -646,7 +646,7 @@ static int batadv_interface_add_vid(struct net_device *dev, 
__be16 proto,
if (!vlan->kobj) {
ret = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan);
if (ret) {
-   batadv_softif_vlan_free_ref(vlan);
+   batadv_softif_vlan_put(vlan);
return ret;
}
}
@@ -693,7 +693,7 @@ static int batadv_interface_kill_vid(struct net_device 
*dev, __be16 proto,
batadv_softif_destroy_vlan(bat_priv, vlan);
 
/* finally free the vlan object */
-   batadv_softif_vlan_free_ref(vlan);
+   batadv_softif_vlan_put(vlan);
 
return 0;
 }
@@ -749,7 +749,7 @@ static void batadv_softif_destroy_finish(struct work_struct 
*work)
vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS);
if (vlan) {
batadv_softif_destroy_vlan(bat_priv, vlan);
-   batadv_softif_vlan_free_ref(vlan);
+   batadv_softif_vlan_put(vlan);
}
 
batadv_sysfs_del_meshif(soft_iface);
diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h
index d17cfbacf809..9ae265703d23 100644
--- a/net/batman-adv/soft-interface.h
+++ b/net/batman-adv/soft-interface.h
@@ -34,7 +34,7 @@ void batadv_softif_destroy_sysfs(struct net_device 
*soft_iface);
 int batadv_softif_is_valid(const struct net_device *net_dev);
 extern struct rtnl_link_ops batadv_link_ops;
 int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short 
vid);
-void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan);
+void batadv_softif_vlan_put(struct batadv_softif_vlan *softif_vlan);
 struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv,
  unsigned short vid);
 
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 0db7591a000f..4d70d4413e40 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -216,7 +216,7 @@ ssize_t batadv_store_vlan_##_name(struct kobject *kobj, 
\
  attr, >_name,   \
  bat_priv->soft_iface);\
\
-   batadv_softif_vlan_free_ref(vlan);  

[PATCH 11/20] batman-adv: Rename batadv_gw_node *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/gateway_client.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 37972dfda400..c59aff5ccac8 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -76,11 +76,10 @@ static void batadv_gw_node_release(struct kref *ref)
 }
 
 /**
- * batadv_gw_node_free_ref - decrement the gw_node refcounter and possibly
- *  release it
+ * batadv_gw_node_put - decrement the gw_node refcounter and possibly release 
it
  * @gw_node: gateway node to free
  */
-static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node)
+static void batadv_gw_node_put(struct batadv_gw_node *gw_node)
 {
kref_put(_node->refcount, batadv_gw_node_release);
 }
@@ -125,7 +124,7 @@ unlock:
rcu_read_unlock();
 out:
if (gw_node)
-   batadv_gw_node_free_ref(gw_node);
+   batadv_gw_node_put(gw_node);
return orig_node;
 }
 
@@ -143,7 +142,7 @@ static void batadv_gw_select(struct batadv_priv *bat_priv,
rcu_assign_pointer(bat_priv->gw.curr_gw, new_gw_node);
 
if (curr_gw_node)
-   batadv_gw_node_free_ref(curr_gw_node);
+   batadv_gw_node_put(curr_gw_node);
 
spin_unlock_bh(_priv->gw.list_lock);
 }
@@ -204,7 +203,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
((tmp_gw_factor == max_gw_factor) &&
 (tq_avg > max_tq))) {
if (curr_gw)
-   batadv_gw_node_free_ref(curr_gw);
+   batadv_gw_node_put(curr_gw);
curr_gw = gw_node;
kref_get(_gw->refcount);
}
@@ -219,7 +218,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
  */
if (tq_avg > max_tq) {
if (curr_gw)
-   batadv_gw_node_free_ref(curr_gw);
+   batadv_gw_node_put(curr_gw);
curr_gw = gw_node;
kref_get(_gw->refcount);
}
@@ -232,7 +231,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
if (tmp_gw_factor > max_gw_factor)
max_gw_factor = tmp_gw_factor;
 
-   batadv_gw_node_free_ref(gw_node);
+   batadv_gw_node_put(gw_node);
 
 next:
batadv_neigh_node_put(router);
@@ -273,7 +272,7 @@ void batadv_gw_check_client_stop(struct batadv_priv 
*bat_priv)
 */
batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL);
 
-   batadv_gw_node_free_ref(curr_gw);
+   batadv_gw_node_put(curr_gw);
 }
 
 void batadv_gw_election(struct batadv_priv *bat_priv)
@@ -348,9 +347,9 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
 
 out:
if (curr_gw)
-   batadv_gw_node_free_ref(curr_gw);
+   batadv_gw_node_put(curr_gw);
if (next_gw)
-   batadv_gw_node_free_ref(next_gw);
+   batadv_gw_node_put(next_gw);
if (router)
batadv_neigh_node_put(router);
if (router_ifinfo)
@@ -547,7 +546,7 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
spin_lock_bh(_priv->gw.list_lock);
if (!hlist_unhashed(_node->list)) {
hlist_del_init_rcu(_node->list);
-   batadv_gw_node_free_ref(gw_node);
+   batadv_gw_node_put(gw_node);
}
spin_unlock_bh(_priv->gw.list_lock);
 
@@ -556,12 +555,12 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
batadv_gw_reselect(bat_priv);
 
if (curr_gw)
-   batadv_gw_node_free_ref(curr_gw);
+   batadv_gw_node_put(curr_gw);
}
 
 out:
if (gw_node)
-   batadv_gw_node_free_ref(gw_node);
+   batadv_gw_node_put(gw_node);
 }
 
 void batadv_gw_node_delete(struct batadv_priv *bat_priv,
@@ -584,7 +583,7 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv)
hlist_for_each_entry_safe(gw_node, node_tmp,
  _priv->gw.list, list) {
hlist_del_init_rcu(_node->list);
-   

[PATCH 12/20] batman-adv: Rename batadv_tvlv_handler *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/main.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 476554b3adce..95aaff371966 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -638,12 +638,11 @@ static void batadv_tvlv_handler_release(struct kref *ref)
 }
 
 /**
- * batadv_tvlv_handler_free_ref - decrement the tvlv container refcounter and
+ * batadv_tvlv_handler_put - decrement the tvlv container refcounter and
  *  possibly release it
  * @tvlv_handler: the tvlv handler to free
  */
-static void
-batadv_tvlv_handler_free_ref(struct batadv_tvlv_handler *tvlv_handler)
+static void batadv_tvlv_handler_put(struct batadv_tvlv_handler *tvlv_handler)
 {
kref_put(_handler->refcount, batadv_tvlv_handler_release);
 }
@@ -1031,7 +1030,7 @@ int batadv_tvlv_containers_process(struct batadv_priv 
*bat_priv,
src, dst, tvlv_value,
tvlv_value_cont_len);
if (tvlv_handler)
-   batadv_tvlv_handler_free_ref(tvlv_handler);
+   batadv_tvlv_handler_put(tvlv_handler);
tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len;
tvlv_value_len -= tvlv_value_cont_len;
}
@@ -,7 +1110,7 @@ void batadv_tvlv_handler_register(struct batadv_priv 
*bat_priv,
 
tvlv_handler = batadv_tvlv_handler_get(bat_priv, type, version);
if (tvlv_handler) {
-   batadv_tvlv_handler_free_ref(tvlv_handler);
+   batadv_tvlv_handler_put(tvlv_handler);
return;
}
 
@@ -1148,11 +1147,11 @@ void batadv_tvlv_handler_unregister(struct batadv_priv 
*bat_priv,
if (!tvlv_handler)
return;
 
-   batadv_tvlv_handler_free_ref(tvlv_handler);
+   batadv_tvlv_handler_put(tvlv_handler);
spin_lock_bh(_priv->tvlv.handler_list_lock);
hlist_del_rcu(_handler->list);
spin_unlock_bh(_priv->tvlv.handler_list_lock);
-   batadv_tvlv_handler_free_ref(tvlv_handler);
+   batadv_tvlv_handler_put(tvlv_handler);
 }
 
 /**
-- 
2.7.1



[PATCH 16/20] batman-adv: Rename batadv_nc_path *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/network-coding.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 6105cfb0574c..d253bb23e2ac 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -247,11 +247,11 @@ static void batadv_nc_path_release(struct kref *ref)
 }
 
 /**
- * batadv_nc_path_free_ref - decrement the nc_path refcounter and possibly
+ * batadv_nc_path_put - decrement the nc_path refcounter and possibly
  *  release it
  * @nc_path: nc_path to be free'd
  */
-static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path)
+static void batadv_nc_path_put(struct batadv_nc_path *nc_path)
 {
kref_put(_path->refcount, batadv_nc_path_release);
 }
@@ -263,7 +263,7 @@ static void batadv_nc_path_free_ref(struct batadv_nc_path 
*nc_path)
 static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet)
 {
kfree_skb(nc_packet->skb);
-   batadv_nc_path_free_ref(nc_packet->nc_path);
+   batadv_nc_path_put(nc_packet->nc_path);
kfree(nc_packet);
 }
 
@@ -467,7 +467,7 @@ static void batadv_nc_purge_paths(struct batadv_priv 
*bat_priv,
   "Remove nc_path %pM -> %pM\n",
   nc_path->prev_hop, nc_path->next_hop);
hlist_del_rcu(_path->hash_entry);
-   batadv_nc_path_free_ref(nc_path);
+   batadv_nc_path_put(nc_path);
}
spin_unlock_bh(lock);
}
@@ -1555,7 +1555,7 @@ bool batadv_nc_skb_forward(struct sk_buff *skb,
return true;
 
 free_nc_path:
-   batadv_nc_path_free_ref(nc_path);
+   batadv_nc_path_put(nc_path);
 out:
/* Packet is not consumed */
return false;
@@ -1617,7 +1617,7 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv 
*bat_priv,
 free_skb:
kfree_skb(skb);
 free_nc_path:
-   batadv_nc_path_free_ref(nc_path);
+   batadv_nc_path_put(nc_path);
 out:
return;
 }
-- 
2.7.1



[PATCH 18/20] batman-adv: Rename batadv_tt_local_entry *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/translation-table.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 396b095c8a1d..de3e731542e3 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -219,12 +219,12 @@ static void batadv_tt_local_entry_release(struct kref 
*ref)
 }
 
 /**
- * batadv_tt_local_entry_free_ref - decrement the tt_local_entry refcounter and
+ * batadv_tt_local_entry_put - decrement the tt_local_entry refcounter and
  *  possibly release it
  * @tt_local_entry: tt_local_entry to be free'd
  */
 static void
-batadv_tt_local_entry_free_ref(struct batadv_tt_local_entry *tt_local_entry)
+batadv_tt_local_entry_put(struct batadv_tt_local_entry *tt_local_entry)
 {
kref_put(_local_entry->common.refcount,
 batadv_tt_local_entry_release);
@@ -687,7 +687,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, 
const u8 *addr,
 
if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */
-   batadv_tt_local_entry_free_ref(tt_local);
+   batadv_tt_local_entry_put(tt_local);
batadv_softif_vlan_put(vlan);
goto out;
}
@@ -754,7 +754,7 @@ out:
if (in_dev)
dev_put(in_dev);
if (tt_local)
-   batadv_tt_local_entry_free_ref(tt_local);
+   batadv_tt_local_entry_put(tt_local);
if (tt_global)
batadv_tt_global_entry_free_ref(tt_global);
return ret;
@@ -1137,7 +1137,7 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, 
const u8 *addr,
goto out;
 
/* extra call to free the local tt entry */
-   batadv_tt_local_entry_free_ref(tt_local_entry);
+   batadv_tt_local_entry_put(tt_local_entry);
 
/* decrease the reference held for this vlan */
vlan = batadv_softif_vlan_get(bat_priv, vid);
@@ -1149,7 +1149,7 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, 
const u8 *addr,
 
 out:
if (tt_local_entry)
-   batadv_tt_local_entry_free_ref(tt_local_entry);
+   batadv_tt_local_entry_put(tt_local_entry);
 
return curr_flags;
 }
@@ -1249,7 +1249,7 @@ static void batadv_tt_local_table_free(struct batadv_priv 
*bat_priv)
batadv_softif_vlan_put(vlan);
}
 
-   batadv_tt_local_entry_free_ref(tt_local);
+   batadv_tt_local_entry_put(tt_local);
}
spin_unlock_bh(list_lock);
}
@@ -1555,7 +1555,7 @@ out:
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry)
-   batadv_tt_local_entry_free_ref(tt_local_entry);
+   batadv_tt_local_entry_put(tt_local_entry);
return ret;
 }
 
@@ -1911,7 +1911,7 @@ out:
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
if (local_entry)
-   batadv_tt_local_entry_free_ref(local_entry);
+   batadv_tt_local_entry_put(local_entry);
 }
 
 /**
@@ -2143,7 +2143,7 @@ out:
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry)
-   batadv_tt_local_entry_free_ref(tt_local_entry);
+   batadv_tt_local_entry_put(tt_local_entry);
 
return orig_node;
 }
@@ -3023,7 +3023,7 @@ bool batadv_is_my_client(struct batadv_priv *bat_priv, 
const u8 *addr,
ret = true;
 out:
if (tt_local_entry)
-   batadv_tt_local_entry_free_ref(tt_local_entry);
+   batadv_tt_local_entry_put(tt_local_entry);
return ret;
 }
 
@@ -3346,7 +3346,7 @@ static void batadv_tt_local_purge_pending_clients(struct 
batadv_priv *bat_priv)
batadv_softif_vlan_put(vlan);
}
 
-   batadv_tt_local_entry_free_ref(tt_local);
+   batadv_tt_local_entry_put(tt_local);
}
spin_unlock_bh(list_lock);
}
@@ -3433,7 +3433,7 @@ out:
if (tt_global_entry)
batadv_tt_global_entry_free_ref(tt_global_entry);
if (tt_local_entry)
-   batadv_tt_local_entry_free_ref(tt_local_entry);
+   batadv_tt_local_entry_put(tt_local_entry);
return ret;
 }
 

[PATCH 17/20] batman-adv: Rename batadv_orig_node_vlan *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/originator.c|  8 
 net/batman-adv/originator.h|  2 +-
 net/batman-adv/translation-table.c | 10 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 0b1a77da2e1e..e4cbb0753e37 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -151,11 +151,11 @@ static void batadv_orig_node_vlan_release(struct kref 
*ref)
 }
 
 /**
- * batadv_orig_node_vlan_free_ref - decrement the refcounter and possibly
- *  release the originator-vlan object
+ * batadv_orig_node_vlan_put - decrement the refcounter and possibly release
+ *  the originator-vlan object
  * @orig_vlan: the originator-vlan object to release
  */
-void batadv_orig_node_vlan_free_ref(struct batadv_orig_node_vlan *orig_vlan)
+void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan)
 {
kref_put(_vlan->refcount, batadv_orig_node_vlan_release);
 }
@@ -917,7 +917,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct 
batadv_priv *bat_priv,
 * Immediately release vlan since it is not needed anymore in this
 * context
 */
-   batadv_orig_node_vlan_free_ref(vlan);
+   batadv_orig_node_vlan_put(vlan);
 
for (i = 0; i < BATADV_FRAG_BUFFER_COUNT; i++) {
INIT_HLIST_HEAD(_node->fragments[i].head);
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index 97748e84b66b..4e8b67f11051 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -83,7 +83,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
 struct batadv_orig_node_vlan *
 batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
  unsigned short vid);
-void batadv_orig_node_vlan_free_ref(struct batadv_orig_node_vlan *orig_vlan);
+void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan);
 
 /* hashfunction to choose an entry in a hash table of given size
  * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index b81f8ea3395d..396b095c8a1d 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -348,12 +348,12 @@ static void batadv_tt_global_size_mod(struct 
batadv_orig_node *orig_node,
spin_lock_bh(_node->vlan_list_lock);
if (!hlist_unhashed(>list)) {
hlist_del_init_rcu(>list);
-   batadv_orig_node_vlan_free_ref(vlan);
+   batadv_orig_node_vlan_put(vlan);
}
spin_unlock_bh(_node->vlan_list_lock);
}
 
-   batadv_orig_node_vlan_free_ref(vlan);
+   batadv_orig_node_vlan_put(vlan);
 }
 
 /**
@@ -1652,7 +1652,7 @@ batadv_tt_global_print_entry(struct batadv_priv *bat_priv,
   ((flags & BATADV_TT_CLIENT_ISOLA) ? 'I' : '.'),
   ((flags & BATADV_TT_CLIENT_TEMP) ? 'T' : '.'));
 
-   batadv_orig_node_vlan_free_ref(vlan);
+   batadv_orig_node_vlan_put(vlan);
}
 
 print_list:
@@ -1684,7 +1684,7 @@ print_list:
   ((flags & BATADV_TT_CLIENT_ISOLA) ? 'I' : '.'),
   ((flags & BATADV_TT_CLIENT_TEMP) ? 'T' : '.'));
 
-   batadv_orig_node_vlan_free_ref(vlan);
+   batadv_orig_node_vlan_put(vlan);
}
 }
 
@@ -2503,7 +2503,7 @@ static bool batadv_tt_global_check_crc(struct 
batadv_orig_node *orig_node,
return false;
 
crc = vlan->tt.crc;
-   batadv_orig_node_vlan_free_ref(vlan);
+   batadv_orig_node_vlan_put(vlan);
 
if (crc != ntohl(tt_vlan_tmp->crc))
return false;
-- 
2.7.1



[PATCH 20/20] batman-adv: Rename batadv_tt_orig_list_entry *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/translation-table.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 7f65a8f17f52..0b43e86328a5 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -397,12 +397,12 @@ static void batadv_tt_orig_list_entry_release(struct kref 
*ref)
 }
 
 /**
- * batadv_tt_orig_list_entry_free_ref - decrement the tt orig entry refcounter
- *  and possibly release it
+ * batadv_tt_orig_list_entry_put - decrement the tt orig entry refcounter and
+ *  possibly release it
  * @orig_entry: tt orig entry to be free'd
  */
 static void
-batadv_tt_orig_list_entry_free_ref(struct batadv_tt_orig_list_entry 
*orig_entry)
+batadv_tt_orig_list_entry_put(struct batadv_tt_orig_list_entry *orig_entry)
 {
kref_put(_entry->refcount, batadv_tt_orig_list_entry_release);
 }
@@ -1345,7 +1345,7 @@ batadv_tt_global_entry_has_orig(const struct 
batadv_tt_global_entry *entry,
orig_entry = batadv_tt_global_orig_entry_find(entry, orig_node);
if (orig_entry) {
found = true;
-   batadv_tt_orig_list_entry_free_ref(orig_entry);
+   batadv_tt_orig_list_entry_put(orig_entry);
}
 
return found;
@@ -1386,7 +1386,7 @@ batadv_tt_global_orig_entry_add(struct 
batadv_tt_global_entry *tt_global,
 
 out:
if (orig_entry)
-   batadv_tt_orig_list_entry_free_ref(orig_entry);
+   batadv_tt_orig_list_entry_put(orig_entry);
 }
 
 /**
@@ -1753,7 +1753,7 @@ _batadv_tt_global_del_orig_entry(struct 
batadv_tt_global_entry *tt_global_entry,
 * being part of a list
 */
hlist_del_rcu(_entry->list);
-   batadv_tt_orig_list_entry_free_ref(orig_entry);
+   batadv_tt_orig_list_entry_put(orig_entry);
 }
 
 /* deletes the orig list of a tt_global_entry */
-- 
2.7.1



[PATCH 08/20] batman-adv: Rename batadv_backbone_gw *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bridge_loop_avoidance.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index b7167cf3e907..ce2d0701fb59 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -159,12 +159,11 @@ static void batadv_backbone_gw_release(struct kref *ref)
 }
 
 /**
- * batadv_backbone_gw_free_ref - decrement the backbone gw refcounter and
- *  possibly release it
+ * batadv_backbone_gw_put - decrement the backbone gw refcounter and possibly
+ *  release it
  * @backbone_gw: backbone gateway to be free'd
  */
-static void
-batadv_backbone_gw_free_ref(struct batadv_bla_backbone_gw *backbone_gw)
+static void batadv_backbone_gw_put(struct batadv_bla_backbone_gw *backbone_gw)
 {
kref_put(_gw->refcount, batadv_backbone_gw_release);
 }
@@ -180,7 +179,7 @@ static void batadv_claim_release(struct kref *ref)
 
claim = container_of(ref, struct batadv_bla_claim, refcount);
 
-   batadv_backbone_gw_free_ref(claim->backbone_gw);
+   batadv_backbone_gw_put(claim->backbone_gw);
kfree_rcu(claim, rcu);
 }
 
@@ -524,7 +523,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv 
*bat_priv,
return;
 
backbone_gw->lasttime = jiffies;
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
 }
 
 /**
@@ -573,7 +572,7 @@ static void batadv_bla_answer_request(struct batadv_priv 
*bat_priv,
 
/* finally, send an announcement frame */
batadv_bla_send_announce(bat_priv, backbone_gw);
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
 }
 
 /**
@@ -682,7 +681,7 @@ static void batadv_bla_add_claim(struct batadv_priv 
*bat_priv,
spin_lock_bh(>backbone_gw->crc_lock);
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
spin_unlock_bh(>backbone_gw->crc_lock);
-   batadv_backbone_gw_free_ref(claim->backbone_gw);
+   batadv_backbone_gw_put(claim->backbone_gw);
}
/* set (new) backbone gw */
kref_get(_gw->refcount);
@@ -783,7 +782,7 @@ static int batadv_handle_announce(struct batadv_priv 
*bat_priv, u8 *an_addr,
}
}
 
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
return 1;
 }
 
@@ -854,7 +853,7 @@ static int batadv_handle_unclaim(struct batadv_priv 
*bat_priv,
   claim_addr, BATADV_PRINT_VID(vid), backbone_gw->orig);
 
batadv_bla_del_claim(bat_priv, claim_addr, vid);
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
return 1;
 }
 
@@ -891,7 +890,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
 
/* TODO: we could call something like tt_local_del() here. */
 
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
return 1;
 }
 
@@ -1154,7 +1153,7 @@ purge_now:
batadv_bla_del_backbone_claims(backbone_gw);
 
hlist_del_rcu(_gw->hash_entry);
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
}
spin_unlock_bh(list_lock);
}
@@ -1571,7 +1570,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
if (!backbone_gw)
return 0;
 
-   batadv_backbone_gw_free_ref(backbone_gw);
+   batadv_backbone_gw_put(backbone_gw);
return 1;
 }
 
-- 
2.7.1



[PATCH 01/20] batman-adv: remove unused BATADV_BONDING_TQ_THRESHOLD constant

2016-02-22 Thread Antonio Quartulli
BATADV_BONDING_TQ_THRESHOLD is not used anymore since the implementation
of the bat_neigh_is_similar_or_better() API function.
Such function uses the more generic BATADV_TQ_SIMILARITY_THRESHOLD
constant.

Therefore, remove definition of the unused BATADV_BONDING_TQ_THRESHOLD
constant.

Signed-off-by: Antonio Quartulli 
Signed-off-by: Marek Lindner 
---
 net/batman-adv/main.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 32dfc9e578af..8c01f54c61f3 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -100,11 +100,6 @@
  */
 #define BATADV_TQ_SIMILARITY_THRESHOLD 50
 
-/* how much worse secondary interfaces may be to be considered as bonding
- * candidates
- */
-#define BATADV_BONDING_TQ_THRESHOLD50
-
 /* should not be bigger than 512 bytes or change the size of
  * forw_packet->direct_link_flags
  */
-- 
2.7.1



[PATCH 04/20] batman-adv: Rename batadv_neigh_node *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bat_iv_ogm.c| 16 
 net/batman-adv/distributed-arp-table.c |  2 +-
 net/batman-adv/fragmentation.c |  2 +-
 net/batman-adv/gateway_client.c| 14 +++---
 net/batman-adv/icmp_socket.c   |  2 +-
 net/batman-adv/network-coding.c|  4 ++--
 net/batman-adv/originator.c| 16 
 net/batman-adv/originator.h|  2 +-
 net/batman-adv/routing.c   | 14 +++---
 net/batman-adv/send.c  |  2 +-
 net/batman-adv/translation-table.c |  6 +++---
 11 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index f01ee23e35e6..0f8742b4bfaa 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1005,7 +1005,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
tmp_neigh_node->if_incoming == if_incoming &&
kref_get_unless_zero(_neigh_node->refcount)) {
if (WARN(neigh_node, "too many matching neigh_nodes"))
-   batadv_neigh_node_free_ref(neigh_node);
+   batadv_neigh_node_put(neigh_node);
neigh_node = tmp_neigh_node;
continue;
}
@@ -1116,9 +1116,9 @@ unlock:
rcu_read_unlock();
 out:
if (neigh_node)
-   batadv_neigh_node_free_ref(neigh_node);
+   batadv_neigh_node_put(neigh_node);
if (router)
-   batadv_neigh_node_free_ref(router);
+   batadv_neigh_node_put(router);
if (neigh_ifinfo)
batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
if (router_ifinfo)
@@ -1265,7 +1265,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
 
 out:
if (neigh_node)
-   batadv_neigh_node_free_ref(neigh_node);
+   batadv_neigh_node_put(neigh_node);
return ret;
 }
 
@@ -1568,11 +1568,11 @@ out:
if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo);
if (router)
-   batadv_neigh_node_free_ref(router);
+   batadv_neigh_node_put(router);
if (router_router)
-   batadv_neigh_node_free_ref(router_router);
+   batadv_neigh_node_put(router_router);
if (orig_neigh_router)
-   batadv_neigh_node_free_ref(orig_neigh_router);
+   batadv_neigh_node_put(orig_neigh_router);
if (hardif_neigh)
batadv_hardif_neigh_free_ref(hardif_neigh);
 
@@ -1868,7 +1868,7 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv 
*bat_priv,
batman_count++;
 
 next:
-   batadv_neigh_node_free_ref(neigh_node);
+   batadv_neigh_node_put(neigh_node);
if (n_ifinfo)
batadv_neigh_ifinfo_free_ref(n_ifinfo);
}
diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 00408d6231b6..919f3445fff3 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -674,7 +674,7 @@ static bool batadv_dat_send_data(struct batadv_priv 
*bat_priv,
ret = true;
}
 free_neigh:
-   batadv_neigh_node_free_ref(neigh_node);
+   batadv_neigh_node_put(neigh_node);
 free_orig:
batadv_orig_node_put(cand[i].orig_node);
}
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index d13c5b601b67..adb9c3989add 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -387,7 +387,7 @@ out:
if (orig_node_dst)
batadv_orig_node_put(orig_node_dst);
if (neigh_node)
-   batadv_neigh_node_free_ref(neigh_node);
+   batadv_neigh_node_put(neigh_node);
return ret;
 }
 
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 7bf84c136205..ea03c056a345 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -235,7 +235,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
batadv_gw_node_free_ref(gw_node);
 
 next:
-   batadv_neigh_node_free_ref(router);
+   batadv_neigh_node_put(router);
if (router_ifinfo)

[PATCH 09/20] batman-adv: Rename batadv_claim *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bridge_loop_avoidance.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index ce2d0701fb59..0a6c8b824a00 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -184,11 +184,11 @@ static void batadv_claim_release(struct kref *ref)
 }
 
 /**
- * batadv_claim_free_ref - decrement the claim refcounter and possibly
+ * batadv_claim_put - decrement the claim refcounter and possibly
  *  release it
  * @claim: claim to be free'd
  */
-static void batadv_claim_free_ref(struct batadv_bla_claim *claim)
+static void batadv_claim_put(struct batadv_bla_claim *claim)
 {
kref_put(>refcount, batadv_claim_release);
 }
@@ -304,7 +304,7 @@ batadv_bla_del_backbone_claims(struct 
batadv_bla_backbone_gw *backbone_gw)
if (claim->backbone_gw != backbone_gw)
continue;
 
-   batadv_claim_free_ref(claim);
+   batadv_claim_put(claim);
hlist_del_rcu(>hash_entry);
}
spin_unlock_bh(list_lock);
@@ -693,7 +693,7 @@ static void batadv_bla_add_claim(struct batadv_priv 
*bat_priv,
backbone_gw->lasttime = jiffies;
 
 claim_free_ref:
-   batadv_claim_free_ref(claim);
+   batadv_claim_put(claim);
 }
 
 /**
@@ -718,14 +718,14 @@ static void batadv_bla_del_claim(struct batadv_priv 
*bat_priv,
 
batadv_hash_remove(bat_priv->bla.claim_hash, batadv_compare_claim,
   batadv_choose_claim, claim);
-   batadv_claim_free_ref(claim); /* reference from the hash is gone */
+   batadv_claim_put(claim); /* reference from the hash is gone */
 
spin_lock_bh(>backbone_gw->crc_lock);
claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
spin_unlock_bh(>backbone_gw->crc_lock);
 
/* don't need the reference from hash_find() anymore */
-   batadv_claim_free_ref(claim);
+   batadv_claim_put(claim);
 }
 
 /**
@@ -1693,7 +1693,7 @@ out:
if (primary_if)
batadv_hardif_put(primary_if);
if (claim)
-   batadv_claim_free_ref(claim);
+   batadv_claim_put(claim);
return ret;
 }
 
@@ -1782,7 +1782,7 @@ out:
if (primary_if)
batadv_hardif_put(primary_if);
if (claim)
-   batadv_claim_free_ref(claim);
+   batadv_claim_put(claim);
return ret;
 }
 
-- 
2.7.1



[PATCH 07/20] batman-adv: Rename batadv_hardif_neigh *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bat_iv_ogm.c |  2 +-
 net/batman-adv/originator.c | 10 +-
 net/batman-adv/originator.h |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index ba48fb2818fc..5651e33ca6bd 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1574,7 +1574,7 @@ out:
if (orig_neigh_router)
batadv_neigh_node_put(orig_neigh_router);
if (hardif_neigh)
-   batadv_hardif_neigh_free_ref(hardif_neigh);
+   batadv_hardif_neigh_put(hardif_neigh);
 
kfree_skb(skb_priv);
 }
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 605641536c82..0b1a77da2e1e 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -232,11 +232,11 @@ static void batadv_hardif_neigh_release(struct kref *ref)
 }
 
 /**
- * batadv_hardif_neigh_free_ref - decrement the hardif neighbors refcounter
+ * batadv_hardif_neigh_put - decrement the hardif neighbors refcounter
  *  and possibly release it
  * @hardif_neigh: hardif neigh neighbor to free
  */
-void batadv_hardif_neigh_free_ref(struct batadv_hardif_neigh_node 
*hardif_neigh)
+void batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh)
 {
kref_put(_neigh->refcount, batadv_hardif_neigh_release);
 }
@@ -266,8 +266,8 @@ static void batadv_neigh_node_release(struct kref *ref)
   neigh_node->addr);
if (hardif_neigh) {
/* batadv_hardif_neigh_get() increases refcount too */
-   batadv_hardif_neigh_free_ref(hardif_neigh);
-   batadv_hardif_neigh_free_ref(hardif_neigh);
+   batadv_hardif_neigh_put(hardif_neigh);
+   batadv_hardif_neigh_put(hardif_neigh);
}
 
if (bao->bat_neigh_free)
@@ -681,7 +681,7 @@ batadv_neigh_node_new(struct batadv_orig_node *orig_node,
 
 out:
if (hardif_neigh)
-   batadv_hardif_neigh_free_ref(hardif_neigh);
+   batadv_hardif_neigh_put(hardif_neigh);
return neigh_node;
 }
 
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index adbe7aa749a9..97748e84b66b 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -44,7 +44,7 @@ struct batadv_hardif_neigh_node *
 batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr);
 void
-batadv_hardif_neigh_free_ref(struct batadv_hardif_neigh_node *hardif_neigh);
+batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh);
 struct batadv_neigh_node *
 batadv_neigh_node_new(struct batadv_orig_node *orig_node,
  struct batadv_hard_iface *hard_iface,
-- 
2.7.1



[PATCH 05/20] batman-adv: Rename batadv_neigh_ifinfo *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bat_iv_ogm.c | 24 
 net/batman-adv/gateway_client.c | 14 +++---
 net/batman-adv/network-coding.c |  4 ++--
 net/batman-adv/originator.c |  8 
 net/batman-adv/originator.h |  2 +-
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 0f8742b4bfaa..7566cf6614f5 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1026,7 +1026,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
neigh_ifinfo->bat_iv.tq_avg = tq_avg;
spin_unlock_bh(_neigh_node->ifinfo_lock);
 
-   batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
+   batadv_neigh_ifinfo_put(neigh_ifinfo);
neigh_ifinfo = NULL;
}
 
@@ -1120,9 +1120,9 @@ out:
if (router)
batadv_neigh_node_put(router);
if (neigh_ifinfo)
-   batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
+   batadv_neigh_ifinfo_put(neigh_ifinfo);
if (router_ifinfo)
-   batadv_neigh_ifinfo_free_ref(router_ifinfo);
+   batadv_neigh_ifinfo_put(router_ifinfo);
 }
 
 /**
@@ -1192,7 +1192,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
if (neigh_ifinfo) {
neigh_rq_count = neigh_ifinfo->bat_iv.real_packet_count;
-   batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
+   batadv_neigh_ifinfo_put(neigh_ifinfo);
} else {
neigh_rq_count = 0;
}
@@ -1353,7 +1353,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
packet_count = bitmap_weight(bitmap,
 BATADV_TQ_LOCAL_WINDOW_SIZE);
neigh_ifinfo->bat_iv.real_packet_count = packet_count;
-   batadv_neigh_ifinfo_free_ref(neigh_ifinfo);
+   batadv_neigh_ifinfo_put(neigh_ifinfo);
}
rcu_read_unlock();
 
@@ -1566,7 +1566,7 @@ out_neigh:
batadv_orig_node_put(orig_neigh_node);
 out:
if (router_ifinfo)
-   batadv_neigh_ifinfo_free_ref(router_ifinfo);
+   batadv_neigh_ifinfo_put(router_ifinfo);
if (router)
batadv_neigh_node_put(router);
if (router_router)
@@ -1805,7 +1805,7 @@ batadv_iv_ogm_orig_print_neigh(struct batadv_orig_node 
*orig_node,
   neigh_node->addr,
   n_ifinfo->bat_iv.tq_avg);
 
-   batadv_neigh_ifinfo_free_ref(n_ifinfo);
+   batadv_neigh_ifinfo_put(n_ifinfo);
}
 }
 
@@ -1870,7 +1870,7 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv 
*bat_priv,
 next:
batadv_neigh_node_put(neigh_node);
if (n_ifinfo)
-   batadv_neigh_ifinfo_free_ref(n_ifinfo);
+   batadv_neigh_ifinfo_put(n_ifinfo);
}
rcu_read_unlock();
}
@@ -1964,9 +1964,9 @@ static int batadv_iv_ogm_neigh_cmp(struct 
batadv_neigh_node *neigh1,
 
 out:
if (neigh1_ifinfo)
-   batadv_neigh_ifinfo_free_ref(neigh1_ifinfo);
+   batadv_neigh_ifinfo_put(neigh1_ifinfo);
if (neigh2_ifinfo)
-   batadv_neigh_ifinfo_free_ref(neigh2_ifinfo);
+   batadv_neigh_ifinfo_put(neigh2_ifinfo);
 
return diff;
 }
@@ -2007,9 +2007,9 @@ batadv_iv_ogm_neigh_is_sob(struct batadv_neigh_node 
*neigh1,
 
 out:
if (neigh1_ifinfo)
-   batadv_neigh_ifinfo_free_ref(neigh1_ifinfo);
+   batadv_neigh_ifinfo_put(neigh1_ifinfo);
if (neigh2_ifinfo)
-   batadv_neigh_ifinfo_free_ref(neigh2_ifinfo);
+   batadv_neigh_ifinfo_put(neigh2_ifinfo);
 
return ret;
 }
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index ea03c056a345..37972dfda400 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -237,7 +237,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
 next:
batadv_neigh_node_put(router);
if (router_ifinfo)
-   batadv_neigh_ifinfo_free_ref(router_ifinfo);
+   batadv_neigh_ifinfo_put(router_ifinfo);
}
rcu_read_unlock();
 
@@ -354,7 +354,7 @@ out:
if (router)
  

[PATCH 06/20] batman-adv: Rename batadv_orig_ifinfo *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bat_iv_ogm.c |  4 ++--
 net/batman-adv/network-coding.c |  2 +-
 net/batman-adv/originator.c | 10 +-
 net/batman-adv/originator.h |  2 +-
 net/batman-adv/routing.c|  8 
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 7566cf6614f5..ba48fb2818fc 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1368,7 +1368,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
 out:
spin_unlock_bh(_node->bat_iv.ogm_cnt_lock);
batadv_orig_node_put(orig_node);
-   batadv_orig_ifinfo_free_ref(orig_ifinfo);
+   batadv_orig_ifinfo_put(orig_ifinfo);
return ret;
 }
 
@@ -1514,7 +1514,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff 
*skb, int ogm_offset,
  ogm_packet, if_incoming,
  if_outgoing, dup_status);
}
-   batadv_orig_ifinfo_free_ref(orig_ifinfo);
+   batadv_orig_ifinfo_put(orig_ifinfo);
 
/* only forward for specific interface, not for the default one. */
if (if_outgoing == BATADV_IF_DEFAULT)
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 8b367659f1ae..9180ff114a26 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -772,7 +772,7 @@ static bool batadv_can_nc_with_orig(struct batadv_priv 
*bat_priv,
 
last_ttl = orig_ifinfo->last_ttl;
last_real_seqno = orig_ifinfo->last_real_seqno;
-   batadv_orig_ifinfo_free_ref(orig_ifinfo);
+   batadv_orig_ifinfo_put(orig_ifinfo);
 
if (last_real_seqno != ntohl(ogm_packet->seqno))
return false;
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 7965fe5947fb..605641536c82 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -743,11 +743,11 @@ static void batadv_orig_ifinfo_release(struct kref *ref)
 }
 
 /**
- * batadv_orig_ifinfo_free_ref - decrement the refcounter and possibly release
+ * batadv_orig_ifinfo_put - decrement the refcounter and possibly release
  *  the orig_ifinfo
  * @orig_ifinfo: the orig_ifinfo object to release
  */
-void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo)
+void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo)
 {
kref_put(_ifinfo->refcount, batadv_orig_ifinfo_release);
 }
@@ -799,7 +799,7 @@ static void batadv_orig_node_release(struct kref *ref)
hlist_for_each_entry_safe(orig_ifinfo, node_tmp,
  _node->ifinfo_list, list) {
hlist_del_rcu(_ifinfo->list);
-   batadv_orig_ifinfo_free_ref(orig_ifinfo);
+   batadv_orig_ifinfo_put(orig_ifinfo);
}
spin_unlock_bh(_node->neigh_list_lock);
 
@@ -1012,10 +1012,10 @@ batadv_purge_orig_ifinfo(struct batadv_priv *bat_priv,
ifinfo_purged = true;
 
hlist_del_rcu(_ifinfo->list);
-   batadv_orig_ifinfo_free_ref(orig_ifinfo);
+   batadv_orig_ifinfo_put(orig_ifinfo);
if (orig_node->last_bonding_candidate == orig_ifinfo) {
orig_node->last_bonding_candidate = NULL;
-   batadv_orig_ifinfo_free_ref(orig_ifinfo);
+   batadv_orig_ifinfo_put(orig_ifinfo);
}
}
 
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index b4fe82804fc4..adbe7aa749a9 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -69,7 +69,7 @@ batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
 struct batadv_orig_ifinfo *
 batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
   struct batadv_hard_iface *if_outgoing);
-void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo);
+void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo);
 
 int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
 int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 9107f69873ea..4dd646a52f1a 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -107,7 +107,7 @@ static void _batadv_update_route(struct batadv_priv 
*bat_priv,
spin_lock_bh(_node->neigh_list_lock);
rcu_assign_pointer(orig_ifinfo->router, neigh_node);

[PATCH 03/20] batman-adv: Rename batadv_hardif *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bat_iv_ogm.c| 10 +-
 net/batman-adv/bridge_loop_avoidance.c | 18 +-
 net/batman-adv/distributed-arp-table.c |  2 +-
 net/batman-adv/fragmentation.c |  2 +-
 net/batman-adv/gateway_client.c|  2 +-
 net/batman-adv/hard-interface.c| 20 ++--
 net/batman-adv/hard-interface.h|  4 ++--
 net/batman-adv/icmp_socket.c   |  2 +-
 net/batman-adv/main.c  |  2 +-
 net/batman-adv/network-coding.c|  2 +-
 net/batman-adv/originator.c| 16 
 net/batman-adv/routing.c   |  8 
 net/batman-adv/send.c  |  8 
 net/batman-adv/soft-interface.c|  6 +++---
 net/batman-adv/sysfs.c |  8 
 net/batman-adv/translation-table.c | 10 +-
 16 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 32df38bfff25..f01ee23e35e6 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -515,7 +515,7 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet 
*forw_packet)
 
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
 }
 
 /**
@@ -617,7 +617,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet 
*new_bat_ogm_packet,
 
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
return res;
 }
 
@@ -711,9 +711,9 @@ out_nomem:
if (!own_packet)
atomic_inc(_priv->batman_queue_left);
 out_free_outgoing:
-   batadv_hardif_free_ref(if_outgoing);
+   batadv_hardif_put(if_outgoing);
 out_free_incoming:
-   batadv_hardif_free_ref(if_incoming);
+   batadv_hardif_put(if_incoming);
 }
 
 /* aggregate a new packet into the existing ogm packet */
@@ -958,7 +958,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface 
*hard_iface)
 
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
 }
 
 /**
diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index 49008d98a8aa..b7167cf3e907 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -424,7 +424,7 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, u8 *mac,
netif_rx(skb);
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
 }
 
 /**
@@ -1282,7 +1282,7 @@ void batadv_bla_status_update(struct net_device *net_dev)
 * so just call that one.
 */
batadv_bla_update_orig_address(bat_priv, primary_if, primary_if);
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
 }
 
 /**
@@ -1356,7 +1356,7 @@ static void batadv_bla_periodic_work(struct work_struct 
*work)
}
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
 
queue_delayed_work(batadv_event_workqueue, _priv->bla.work,
   msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
@@ -1395,7 +1395,7 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
if (primary_if) {
crc = crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN);
bat_priv->bla.claim_dest.group = htons(crc);
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
} else {
bat_priv->bla.claim_dest.group = 0; /* will be set later */
}
@@ -1599,7 +1599,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
bat_priv->bla.backbone_hash = NULL;
}
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
 }
 
 /**
@@ -1692,7 +1692,7 @@ handled:
 
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
if (claim)
batadv_claim_free_ref(claim);
return ret;
@@ -1781,7 +1781,7 @@ handled:
ret = 1;
 out:
if (primary_if)
-   batadv_hardif_free_ref(primary_if);
+   batadv_hardif_put(primary_if);
if (claim)
batadv_claim_free_ref(claim);
return 

[PATCH 02/20] batman-adv: Rename batadv_orig_node *_free_ref function to *_put

2016-02-22 Thread Antonio Quartulli
From: Sven Eckelmann 

The batman-adv source code is the only place in the kernel which uses the
*_free_ref naming scheme for the *_put functions. Changing it to *_put
makes it more consistent and makes it easier to understand the connection
to the *_get functions.

Signed-off-by: Sven Eckelmann 
Signed-off-by: Marek Lindner 
Signed-off-by: Antonio Quartulli 
---
 net/batman-adv/bat_iv_ogm.c| 16 
 net/batman-adv/bridge_loop_avoidance.c |  4 ++--
 net/batman-adv/distributed-arp-table.c |  4 ++--
 net/batman-adv/fragmentation.c |  2 +-
 net/batman-adv/gateway_client.c|  8 
 net/batman-adv/icmp_socket.c   |  2 +-
 net/batman-adv/main.c  |  2 +-
 net/batman-adv/network-coding.c|  4 ++--
 net/batman-adv/originator.c|  8 
 net/batman-adv/originator.h|  2 +-
 net/batman-adv/routing.c   | 18 +-
 net/batman-adv/send.c  |  2 +-
 net/batman-adv/translation-table.c | 14 +++---
 13 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index bf0e7d6f12bb..32df38bfff25 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -287,8 +287,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const 
u8 *addr)
 
 free_orig_node:
/* free twice, as batadv_orig_node_new sets refcount to 2 */
-   batadv_orig_node_free_ref(orig_node);
-   batadv_orig_node_free_ref(orig_node);
+   batadv_orig_node_put(orig_node);
+   batadv_orig_node_put(orig_node);
 
return NULL;
 }
@@ -1041,7 +1041,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
 ethhdr->h_source,
 orig_node, orig_tmp);
 
-   batadv_orig_node_free_ref(orig_tmp);
+   batadv_orig_node_put(orig_tmp);
if (!neigh_node)
goto unlock;
} else {
@@ -1306,7 +1306,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
 
orig_ifinfo = batadv_orig_ifinfo_new(orig_node, if_outgoing);
if (WARN_ON(!orig_ifinfo)) {
-   batadv_orig_node_free_ref(orig_node);
+   batadv_orig_node_put(orig_node);
return 0;
}
 
@@ -1367,7 +1367,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
 
 out:
spin_unlock_bh(_node->bat_iv.ogm_cnt_lock);
-   batadv_orig_node_free_ref(orig_node);
+   batadv_orig_node_put(orig_node);
batadv_orig_ifinfo_free_ref(orig_ifinfo);
return ret;
 }
@@ -1563,7 +1563,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff 
*skb, int ogm_offset,
 
 out_neigh:
if ((orig_neigh_node) && (!is_single_hop_neigh))
-   batadv_orig_node_free_ref(orig_neigh_node);
+   batadv_orig_node_put(orig_neigh_node);
 out:
if (router_ifinfo)
batadv_neigh_ifinfo_free_ref(router_ifinfo);
@@ -1697,7 +1697,7 @@ static void batadv_iv_ogm_process(const struct sk_buff 
*skb, int ogm_offset,
 
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
   "Drop packet: originator packet from myself (via 
neighbor)\n");
-   batadv_orig_node_free_ref(orig_neigh_node);
+   batadv_orig_node_put(orig_neigh_node);
return;
}
 
@@ -1735,7 +1735,7 @@ static void batadv_iv_ogm_process(const struct sk_buff 
*skb, int ogm_offset,
}
rcu_read_unlock();
 
-   batadv_orig_node_free_ref(orig_node);
+   batadv_orig_node_put(orig_node);
 }
 
 static int batadv_iv_ogm_receive(struct sk_buff *skb,
diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index 7781f39c174d..49008d98a8aa 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -486,7 +486,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 
*orig,
if (orig_node) {
batadv_tt_global_del_orig(bat_priv, orig_node, vid,
  "became a backbone gateway");
-   batadv_orig_node_free_ref(orig_node);
+   batadv_orig_node_put(orig_node);
}
 
if (own_backbone) {
@@ -965,7 +965,7 @@ static int batadv_check_claim_group(struct batadv_priv 
*bat_priv,
bla_dst_own->group = bla_dst->group;
}
 
-   batadv_orig_node_free_ref(orig_node);
+   batadv_orig_node_put(orig_node);
 
return 2;
 }
diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index e3261118130a..8f466e782bc7 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -547,7 +547,7 @@ static void 

pull request [net-next]: batman-adv 20160223

2016-02-22 Thread Antonio Quartulli
Hello David,

thanks for notifying me about the merge !

This is another pull request intended for net-next and it is
basically all cleanup work, mostly by Sven Eckelmann.

First the BATADV_BONDING_TQ_THRESHOLD
constant gets removed as it was defined but not used anywhere,
then all our *_free_ref functions are renamed to *_put in order
to follow the kernel naming convention.

Please pull or let me know of any problem!
Thanks a lot,
Antonio


The following changes since commit b633353115e352d3c31c12d4c61978c810f05ea1:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2016-02-23 
00:09:14 -0500)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batman-adv-for-davem

for you to fetch changes up to 7e2366c6267d4ea257c4d0deb2fcf0744749de5f:

  batman-adv: Rename batadv_tt_orig_list_entry *_free_ref function to *_put 
(2016-02-23 13:51:01 +0800)


This is a cleanup patchset: first the BATADV_BONDING_TQ_THRESHOLD
constant gets removed as it was defined but not used anywhere,
then all our *_free_ref functions are renamed to *_put in order
to follow the kernel naming convention by Sven Eckelmann.


Antonio Quartulli (1):
  batman-adv: remove unused BATADV_BONDING_TQ_THRESHOLD constant

Sven Eckelmann (19):
  batman-adv: Rename batadv_orig_node *_free_ref function to *_put
  batman-adv: Rename batadv_hardif *_free_ref function to *_put
  batman-adv: Rename batadv_neigh_node *_free_ref function to *_put
  batman-adv: Rename batadv_neigh_ifinfo *_free_ref function to *_put
  batman-adv: Rename batadv_orig_ifinfo *_free_ref function to *_put
  batman-adv: Rename batadv_hardif_neigh *_free_ref function to *_put
  batman-adv: Rename batadv_backbone_gw *_free_ref function to *_put
  batman-adv: Rename batadv_claim *_free_ref function to *_put
  batman-adv: Rename batadv_dat_entry *_free_ref function to *_put
  batman-adv: Rename batadv_gw_node *_free_ref function to *_put
  batman-adv: Rename batadv_tvlv_handler *_free_ref function to *_put
  batman-adv: Rename batadv_tvlv_container *_free_ref function to *_put
  batman-adv: Rename batadv_softif_vlan *_free_ref function to *_put
  batman-adv: Rename batadv_nc_node *_free_ref function to *_put
  batman-adv: Rename batadv_nc_path *_free_ref function to *_put
  batman-adv: Rename batadv_orig_node_vlan *_free_ref function to *_put
  batman-adv: Rename batadv_tt_local_entry *_free_ref function to *_put
  batman-adv: Rename batadv_tt_global_entry *_free_ref function to *_put
  batman-adv: Rename batadv_tt_orig_list_entry *_free_ref function to *_put

 net/batman-adv/bat_iv_ogm.c|  72 +-
 net/batman-adv/bridge_loop_avoidance.c |  63 
 net/batman-adv/distributed-arp-table.c |  24 +++---
 net/batman-adv/fragmentation.c |   6 +-
 net/batman-adv/gateway_client.c|  73 +-
 net/batman-adv/hard-interface.c|  20 ++---
 net/batman-adv/hard-interface.h|   4 +-
 net/batman-adv/icmp_socket.c   |   6 +-
 net/batman-adv/main.c  |  27 ---
 net/batman-adv/main.h  |   5 --
 net/batman-adv/network-coding.c|  38 +-
 net/batman-adv/originator.c|  76 +--
 net/batman-adv/originator.h|  12 +--
 net/batman-adv/routing.c   |  48 ++--
 net/batman-adv/send.c  |  12 +--
 net/batman-adv/soft-interface.c|  20 ++---
 net/batman-adv/soft-interface.h|   2 +-
 net/batman-adv/sysfs.c |  12 +--
 net/batman-adv/translation-table.c | 132 -
 19 files changed, 322 insertions(+), 330 deletions(-)


[PATCH net-next RFC] rtnetlink: add new RTM_GETSTATS to dump link stats

2016-02-22 Thread Roopa Prabhu
From: Roopa Prabhu 

This patch adds a new RTM_GETSTATS message to query link stats via netlink
from the kernel. RTM_NEWLINK also dumps stats today, but RTM_NEWLINK returns a
lot more than just stats and is expensive in some cases when frequent
polling for stats from userspace is a common operation.

RTM_GETSTATS is an attempt to provide a light weight netlink message
to explicity query only link stats from the kernel on an interface.
The idea is to also keep it extensible so that new kinds of stats can be
added to it in the future.

To begin with, this patch adds the following types of stats (which are
also available via RTM_NEWLINK today):

struct nla_policy ifla_stats_policy[IFLA_LINK_STATS_MAX + 1] = {
[IFLA_LINK_STATS]   = { .len = sizeof(struct rtnl_link_stats) },
[IFLA_LINK_STATS64] = { .len = sizeof(struct rtnl_link_stats64) },
[IFLA_LINK_INET6_STATS] = {. type = NLA_NESTED },
};

Like any other rtnetlink message, RTM_GETSTATS can be used to get stats of
a single interface or all interfaces with NLM_F_DUMP.

Most of the above attributes maintain their current types like 'struct
rtnl_link_stats' because there are many apps today that understand this
format. These attributes can be made nested or new nested quivalents can
be added in the future if the need arises.

Future new types of stat attributes:
- IFLA_LINK_MPLS_STATS  (nested. for mpls/mdev stats)
- IFLA_LINK_EXTENDED_STATS (nested. extended software netdev stats like bridge,
  vlan, vxlan etc)
- IFLA_LINK_EXTENDED_HW_STATS (nested. extended hardware stats which are
  available via ethtool today)

Filtering stats (if the user wanted to query just ipv6 stats ?):
a) I have a version of the patch that uses 'struct ifinfomsg->ifi_family'
as a filter from userspace. But, given that in the future we may want to
not just filter by family, I have dropped it in favor of
attribute filtering (not included in this patch but point b) below).

b) RTM_GETSTATS message to contain attributes in the request message

nlmsg_parse(nlh, IFLA_LINK_STATS_MAX, ifla_stats_policy...)

if tb[IFLA_LINK_INET6_STATS]
include ipv6 stats in the dump

if tb[IFLA_LINK_MPLS_STATS]
include mpls stats in the dump

This patch has been minimally tested with a patch to iproute2 ifstat.

Jamals original thought at netdev/netconf also had a RTM_NEWSTATS notification
that people can register to for stats updates. This patch does not include those
changes, but those can be added separately.

Suggested-by: Jamal Hadi Salim 
Signed-off-by: Roopa Prabhu 
---
 include/net/rtnetlink.h|   3 +
 include/uapi/linux/if_link.h   |  10 +++
 include/uapi/linux/rtnetlink.h |   6 ++
 net/core/rtnetlink.c   | 164 +
 net/ipv6/addrconf.c|  69 +++--
 5 files changed, 244 insertions(+), 8 deletions(-)

diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 2f87c1b..8892d21 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -131,6 +131,9 @@ struct rtnl_af_ops {
const struct nlattr *attr);
int (*set_link_af)(struct net_device *dev,
   const struct nlattr *attr);
+   size_t  (*get_link_af_stats_size)(const struct 
net_device *dev);
+   int (*fill_link_af_stats)(struct sk_buff *skb,
+ const struct net_device 
*dev);
 };
 
 void __rtnl_af_unregister(struct rtnl_af_ops *ops);
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index d452cea..3d20091 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -739,4 +739,14 @@ enum {
 
 #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
 
+/* STATS section */
+enum {
+   IFLA_LINK_STATS,
+   IFLA_LINK_STATS64,
+   IFLA_LINK_INET6_STATS,
+   __IFLA_LINK_STATS_MAX,
+};
+
+#define IFLA_LINK_STATS_MAX (__IFLA_LINK_STATS_MAX - 1)
+
 #endif /* _UAPI_LINUX_IF_LINK_H */
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index ca764b5..be41654 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -139,6 +139,12 @@ enum {
RTM_GETNSID = 90,
 #define RTM_GETNSID RTM_GETNSID
 
+   RTM_NEWSTATS = 91,
+#define RTM_NEWSTATS RTM_GETSTATS
+
+   RTM_GETSTATS = 92,
+#define RTM_GETSTATS RTM_GETSTATS
+
__RTM_MAX,
 #define RTM_MAX(((__RTM_MAX + 3) & ~3) - 1)
 };
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 62737f4..18af7a1 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3413,6 +3413,167 @@ out:
return err;
 }
 
+static int rtnl_fill_statsinfo(struct sk_buff *skb, struct net_device *dev,
+  

Re: [B.A.T.M.A.N.] pull request [net]: batman-adv 20160216

2016-02-22 Thread David Miller
From: David Miller 
Date: Tue, 23 Feb 2016 00:12:35 -0500 (EST)

> From: Antonio Quartulli 
> Date: Tue, 23 Feb 2016 13:07:50 +0800
> 
>> I know this kind of mails steal you some time, but do you have any plan
>> about merging net into net-next in the next days ?
> 
> It's what I'm working on right now.

And, done.


Re: [PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Diego Viola
On Tue, Feb 23, 2016 at 2:11 AM, Diego Viola  wrote:
> On Tue, Feb 23, 2016 at 1:42 AM, David Miller  wrote:
>> From: Diego Viola 
>> Date: Mon, 22 Feb 2016 22:58:48 -0300
>>
>>> On Mon, Feb 22, 2016 at 10:46 PM, Fabio Estevam  wrote:
 On Mon, Feb 22, 2016 at 9:32 PM, Diego Viola  wrote:
> Signed-off-by: Diego Viola 

 You should write a commit log.
>>>
>>> I thought about including the link to my bug report:
>>> https://bugzilla.kernel.org/show_bug.cgi?id=112351
>>>
>>> What else would you suggest I add to the commit message?
>>
>> The commit message is where you describe the change you are making.
>>
>> This includes exactly what you are fixing, how you are doing it, and why
>> you are doing it that way.
>>
>> Empty commit log messages are %99.9 of the time completely
>> inappropriate.
>
> David,
>
> I understand and appreciate your advice, thanks.
>
> However, please consider that I'm not a kernel developer, so I don't
> understand much or anything about how this driver works internally,
> this is why I came here to report about problem in the first place.
>
> All I can tell you for certain is that this change makes my
> suspend/resume work and it doesn't hang anymore while resuming from
> suspend.
>
> I apologize for the empty commit message and for not being able to
> explain things deeper, but Pavel Machek is the person who suggested I
> make this change in the code, so maybe he can provide some help?
>
> Diego

I will try sending a V2 patch again with a proper commit message, sorry.

Diego


[PATCH] ipv4: do not cache local route when using SO_BINDTODEVICE

2016-02-22 Thread Kouya Shimura
After v3.6, output routes are cached, however, the 'rt_iif' field of
struct rtable can not be shared by various traffics using SO_BINDTODEVICE.
It causes that traffic can not reach the local receiver which also uses 
SO_BINDTODEVICE after another traffic creates a local route cache. 

  /* sender and receiver are running on same host. */
  sender:
- socket(SOCK_DGRAM)
- setsockopt(SO_BINDTODEVICE, "eth0")
- connect(INADDR_ANY)
- send("message") -->[loopback]--+
 |
  receiver:  |
- socket(SOCK_DGRAM) |
- setsockopt(SO_BINDTODEVICE, "eth0")|
- bind(INADDR_ANY)   |
- recv()  <--+
  /* sometimes reach, sometimes not reach!!! */

Before v3.6, above traffics always reached. It seems to be a
regression. Actually the 'dhcp_release' command relies on it.

Commit 7bd86cc282a458b66c41e3f6 ("ipv4: Cache local output routes")
originated this issue. Revert it conditionally.

Signed-off-by: Kouya Shimura 
---
 net/ipv4/route.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 02c6229..4b5e024 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2285,6 +2285,8 @@ struct rtable *__ip_route_output_key_hash(struct net 
*net, struct flowi4 *fl4,
}
dev_out = net->loopback_dev;
fl4->flowi4_oif = dev_out->ifindex;
+   if (orig_oif)
+   res.fi = NULL;
flags |= RTCF_LOCAL;
goto make_route;
}
-- 
1.9.1


Re: [B.A.T.M.A.N.] pull request [net]: batman-adv 20160216

2016-02-22 Thread David Miller
From: Antonio Quartulli 
Date: Tue, 23 Feb 2016 13:07:50 +0800

> I know this kind of mails steal you some time, but do you have any plan
> about merging net into net-next in the next days ?

It's what I'm working on right now.


Re: [patch net-next 0/9] Introduce devlink interface and first drivers to use it

2016-02-22 Thread Andy Gospodarek
On Mon, Feb 22, 2016 at 07:31:55PM +0100, Jiri Pirko wrote:
> From: Jiri Pirko 
> 
> There a is need for some userspace API that would allow to expose things
> that are not directly related to any device class like net_device of
> ib_device, but rather chip-wide/switch-ASIC-wide stuff.
> 
> Use cases:
> 1) get/set of port type (Ethernet/InfiniBand)
> 2) setting up port splitters - split port into multiple ones and squash again,
>enables usage of splitter cable
> 3) setting up shared buffers - shared among multiple ports within
>one chip (work in progress)
> 4) configuration of switch wide properties - resources division etc - This 
> will
>allow to pass configuration that is unacceptable to be passed as
>a module option.

I'm generally a fan of use cases #3 and #4 (as we have previously
discussed), but I'm not sure I agree that the implementation for #2
right now.

I'm not sure I would like userspace to have control over whether or not
a port should be split or not when the hardware can be queried to
determine this.

> First patch of this set introduces a new generic Netlink based interface,
> called "devlink". It is similar to nl80211 model and it is heavily
> influenced by it, including the API definition. The devlink introduction patch
> implements use cases 1) and 2). Other 2 are in development atm and will
> be addressed by follow-ups.
> 
> It is very convenient for drivers to use devlink, as you can see in other
> patches in this set.
> 
> Counterpart for devlink is userspace tool for now called "dl". Command line
> interface and outputs are derived from "ip" tool so it should be easy
> for users to get used to it.
> 
> It is available here as a standalone tool for now:
> https://github.com/jpirko/devlink
> After this is merge in kernel, I will include the "dl" or "devlink" tool
> into iproute2 toolset.
> 
> Port type setting example:
>   myhost:~$ dl help
>   Usage: dl [ OPTIONS ] OBJECT { COMMAND | help }
>   where  OBJECT := { dev | port | monitor }
>  OPTIONS := { -v/--verbose }
> 
>   myhost:~$ dl dev help
>   Usage: dl dev show [DEV]
>   Usage: dl dev set DEV [ name NEWNAME ]
>   
>   myhost:~$ dl dev show
>   0: devlink0: bus pci dev :01:00.0
>   
>   myhost:~$ dl port help
>   Usage: dl port show [DEV/PORT_INDEX]
>   Usage: dl port set DEV/PORT_INDEX [ type { eth | ib | auto} ]
>   Usage: dl port split DEV/PORT_INDEX count
>   Usage: dl port unsplit DEV/PORT_INDEX
>   
>   myhost:~$ dl port show
>   devlink0/1: type ib ibdev mlx4_0
>   devlink0/2: type ib ibdev mlx4_0
>   
>   myhost:~$ sudo dl port set devlink0/1 type eth
>   
>   myhost:~$ dl port show
>   devlink0/1: type eth netdev ens4
 ^^^
>   devlink0/2: type ib ibdev mlx4_0

I think my only other question about this implementation is whether or
not one would really want to have the true netdev/ibdev names mapped
here.

Would be as reasonable to simply specify the type (and there may be more
types within ethernet that could be useful in multi-chip configurations)
and then let normal infrastructure that exists today figure out how to
map the names for the netdevs to the devices?

>   myhost:~$ sudo dl port set devlink0/2 type auto
>   
>   myhost:~$ dl port show
>   devlink0/1: type eth netdev ens4
>   devlink0/2: type ib(auto) ibdev mlx4_0
> 
> Port splitting example:
>   myswitch:~$ dl port
>   devlink0/1: type eth netdev eth0
>   devlink0/3: type eth netdev eth1
>   devlink0/5: type eth netdev eth2
>   ...
>   devlink0/63: type eth netdev eth31
>   
>   myswitch:~$ sudo dl port split devlink0/1 2
>   
>   myswitch:~$ dl port
>   devlink0/3: type eth netdev eth1
>   devlink0/5: type eth netdev eth2
>   ...
>   devlink0/63: type eth netdev eth31
>   devlink0/1: type eth netdev eth0 split_group 16
>   devlink0/2: type eth netdev eth32 split_group 16
>   
>   myswitch:~$ sudo dl port unsplit devlink0/1
>   
>   myswitch:~$ dl port
>   devlink0/3: type eth netdev eth1
>   devlink0/5: type eth netdev eth2
>   ...
>   devlink0/63: type eth netdev eth31
>   devlink0/1: type eth netdev eth0
> 
> Ido Schimmel (4):
>   mlxsw: spectrum: Unmap local port from module during teardown
>   mlxsw: spectrum: Store local port to module mapping during init
>   mlxsw: spectrum: Mark unused ports using NULL
>   mlxsw: spectrum: Introduce port splitting
> 
> Jiri Pirko (5):
>   Introduce devlink infrastructure
>   mlx4: Implement devlink interface
>   mlx4: Implement port type setting via devlink interface
>   mlxsw: Implement devlink interface
>   mlxsw: core: Add devlink port splitter callbacks
> 
>  MAINTAINERS|   8 +
>  drivers/infiniband/hw/mlx4/main.c  |   7 +
>  

Re: [PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Diego Viola
On Tue, Feb 23, 2016 at 1:42 AM, David Miller  wrote:
> From: Diego Viola 
> Date: Mon, 22 Feb 2016 22:58:48 -0300
>
>> On Mon, Feb 22, 2016 at 10:46 PM, Fabio Estevam  wrote:
>>> On Mon, Feb 22, 2016 at 9:32 PM, Diego Viola  wrote:
 Signed-off-by: Diego Viola 
>>>
>>> You should write a commit log.
>>
>> I thought about including the link to my bug report:
>> https://bugzilla.kernel.org/show_bug.cgi?id=112351
>>
>> What else would you suggest I add to the commit message?
>
> The commit message is where you describe the change you are making.
>
> This includes exactly what you are fixing, how you are doing it, and why
> you are doing it that way.
>
> Empty commit log messages are %99.9 of the time completely
> inappropriate.

David,

I understand and appreciate your advice, thanks.

However, please consider that I'm not a kernel developer, so I don't
understand much or anything about how this driver works internally,
this is why I came here to report about problem in the first place.

All I can tell you for certain is that this change makes my
suspend/resume work and it doesn't hang anymore while resuming from
suspend.

I apologize for the empty commit message and for not being able to
explain things deeper, but Pavel Machek is the person who suggested I
make this change in the code, so maybe he can provide some help?

Diego


Re: [B.A.T.M.A.N.] pull request [net]: batman-adv 20160216

2016-02-22 Thread Antonio Quartulli
On Sat, Feb 20, 2016 at 01:28:40PM +0800, Antonio Quartulli wrote:
> On Fri, Feb 19, 2016 at 03:37:18PM -0500, David Miller wrote:
> > And thanks for the heads up about the potential merge issues, I'll watch
> > for that.
> > 
> 
> Hi David,
> 
> actually I just realized that the patches that will create the conflict
> are not yet in net-next, but they are still pending in my queue.
> 
> At this point I will wait for you to merge net into net-next first
> (there should be no conflict at that point) and then I will rebase
> my pending patches on top of that.
> 
> 
> This should prevent you from dealing with any conflict.

Hi David,

I know this kind of mails steal you some time, but do you have any plan
about merging net into net-next in the next days ?

I have some more new changes coming, but I'd like to send them only after
the merge operation is done to avoid you to deal with some conflicts (as per
above).

Thanks !


-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: [patch net-next 6/9] mlxsw: spectrum: Unmap local port from module during teardown

2016-02-22 Thread Andy Gospodarek
On Mon, Feb 22, 2016 at 12:32:47PM -0800, John Fastabend wrote:
> On 16-02-22 10:32 AM, Jiri Pirko wrote:
> > From: Ido Schimmel 
> > 
> > When splitting a port we replace it with 2 or 4 other ports. To be able
> > to do that we need to remove the original port netdev and unmap it from
> > its module. However, we first mark it as disabled, as active ports
> > cannot be unmapped.
> > 
> > Signed-off-by: Ido Schimmel 
> > Signed-off-by: Jiri Pirko 
> > ---
> 
> Hi Jiri, Ido,
> 
> You've sort of lost me on this port splitting/unsplitting thread. What
> does this actually do? Are you just creating two netdevs and LAGing them
> in the hardware, I'm guessing not or you wouldn't have some device API
> for it and would do it using normal methods.
> 
> If its something to do with physical layout of the board itself why
> don't you trigger this based on some init time introspection or an
> interrupt if someone plugs in a port splitting cable/module (does that
> exist?).

In some implementations there are interrupts that fire when modules are
connected or removed.  Even if an interrupt doesn't fire, it would be
possible to have a timer event/workqueue in a driver that could read
QFSP VPD information periodically to note that something has changed in
the hardware and reconfigure as needed.  I actually would perfer keying
on something like that to perform a configuration change like rather
than requiring the user configure it.

Today you have to swap a 4x10GbE for a 1x40GbE module and then
performing significant software config (possibly flashing EEPROMs in the
case of some NICs) each time.  That seems too error prone as a user
could swap out a QSFP on what they think is one port on a switch and
then perform a software change on another port without realizing it.

That accidental disruption seems less tolerable than the one where there
wrong physical port was added and removed and config needs to be
applied.  Network management apps can properly solve the problem where
devices come and go accidently due to connecting the wrong QSFP, so that
seems like a less critical use-case to handle than what I described
above.




Re: [PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread David Miller
From: Diego Viola 
Date: Mon, 22 Feb 2016 22:58:48 -0300

> On Mon, Feb 22, 2016 at 10:46 PM, Fabio Estevam  wrote:
>> On Mon, Feb 22, 2016 at 9:32 PM, Diego Viola  wrote:
>>> Signed-off-by: Diego Viola 
>>
>> You should write a commit log.
> 
> I thought about including the link to my bug report:
> https://bugzilla.kernel.org/show_bug.cgi?id=112351
> 
> What else would you suggest I add to the commit message?

The commit message is where you describe the change you are making.

This includes exactly what you are fixing, how you are doing it, and why
you are doing it that way.

Empty commit log messages are %99.9 of the time completely
inappropriate.


Re: [net-next PATCH 0/2] GENEVE/VXLAN: Enable outer Tx checksum by default

2016-02-22 Thread Jesse Gross
On Sat, Feb 20, 2016 at 11:51 AM, Tom Herbert  wrote:
> On Fri, Feb 19, 2016 at 6:18 PM, Jesse Gross  wrote:
>> On Fri, Feb 19, 2016 at 4:14 PM, Tom Herbert  wrote:
>>> On Fri, Feb 19, 2016 at 4:08 PM, Jesse Gross  wrote:
 On Fri, Feb 19, 2016 at 3:10 PM, Alex Duyck  wrote:
> On Fri, Feb 19, 2016 at 1:53 PM, Jesse Gross  wrote:
>> On Fri, Feb 19, 2016 at 11:26 AM, Alexander Duyck  
>> wrote:
>>> This patch series makes it so that we enable the outer Tx checksum for 
>>> IPv4
>>> tunnels by default.  This makes the behavior consistent with how we were
>>> handling this for IPv6.  In addition I have updated the internal flags 
>>> for
>>> these tunnels so that we use a ZERO_CSUM_TX flag for IPv4 which should
>>> match up will with the ZERO_CSUM6_TX flag which was already in use for
>>> IPv6.
>>>
>>> For most network devices this should be a net gain in terms of 
>>> performance
>>> as having the outer header checksum present allows for devices to report
>>> CHECKSUM_UNNECESSARY which we can then convert to CHECKSUM_COMPLETE in 
>>> order
>>> to determine if the inner header checksum is valid.
>>>
>>> Below is some data I collected with ixgbe with an X540 that demonstrates
>>> this.  I located two PFs connected back to back in two different name
>>> spaces and then setup a pair of tunnels on each, one with checksum 
>>> enabled
>>> and one without.
>>>
>>> Recv   SendSend  Utilization
>>> Socket Socket  Message  Elapsed  Send
>>> Size   SizeSize Time Throughput  local
>>> bytes  bytes   bytessecs.10^6bits/s  % S
>>>
>>> noudpcsum:
>>>  87380  16384  1638430.00  8898.67   12.80
>>> udpcsum:
>>>  87380  16384  1638430.00  9088.47   5.69
>>>
>>> The one spot where this may cause a performance regression is if the
>>> environment contains devices that can parse the inner headers and a 
>>> device
>>> supports NETIF_F_GSO_UDP_TUNNEL but not NETIF_F_GSO_UDP_TUNNEL_CSUM.  In
>>> the case of such a device we have to fall back to using GSO to segment 
>>> the
>>> tunnel instead of TSO and as a result we may take a performance hit as 
>>> seen
>>> below with i40e.
>>
>> Do you have any numbers from 40G links? Obviously, at 10G the links
>> are basically saturated and while I can see a difference in the
>> utilization rate, I suspect that the change will be much more apparent
>> at higher speeds.
>
> Unfortunately I don't have any true 40G links to test with.  The
> closest I can get is to run PF to VF on an i40e.  Running that I have
> seen the numbers go from about 20Gb/s to 15Gb/s with almost all the
> difference being related to the fact that we are having to
> allocate/free more skbs and make more trips through the
> i40e_lan_xmit_frame function resulting in more descriptors.

 OK, I guess that is more or less in line with what I would expect off
 the top my head. There is a reasonably significant drop in the worst
 case.

>> I'm concerned about the drop in performance for devices that currently
>> support offloads (almost none of which expose
>> NETIF_F_GSO_UDP_TUNNEL_CSUM as a feature). Presumably the people that
>> care most about tunnel performance are the ones that already have
>> these NICs and will be the most impacted by the drop.
>
> The problem is being able to transmit fast is kind of pointless if the
> receiving end cannot handle it.  We hadn't gotten around to really
> getting the Rx checksum bits working until the 3.18 kernel which I
> don't suspect many people are running so at this point messing with
> the TSO bits isn't really making much of a difference.  Then on top of
> that most devices have certain limitations on how many ports they can
> handle and such.  I know the i40e is supposed to support something
> like 10 port numbers, but the fm10k and ixgbe are limited to one port
> as I recall.  So this whole thing is already really brittle as it is.
> My goal with this change is to make the behavior more consistent
> across the board.

 That's true to some degree but there are certainly plenty of cases
 where TSO makes a difference - lower CPU usage, transmitting to
 multiple receivers, people will upgrade their kernels, etc. It's
 clearly good to make things more consistent but hopefully not by
 reducing existing performance. :)

>> My hope is that we can continue to use TSO on devices that only
>> support NETIF_F_GSO_UDP_TUNNEL. The main problem is that the UDP
>> length field may vary across segments. However, in practice this is

Re: [PATCH v7 6/8] x86: tsc: Always Running Timer (ART) correlated clocksource

2016-02-22 Thread Andy Lutomirski
On Mon, Feb 22, 2016 at 6:38 PM, Christopher Hall
 wrote:
> On Thu, 18 Feb 2016 13:11:33 -0800, Andy Lutomirski  wrote:
>>>
>>> +#define X86_FEATURE_INVARIANT_TSC (7*32+4) /* Intel Invariant TSC */
>
>
> This is removed. It was basically an alias for NONSTOP_TSC and not needed.
>
>>
>>> +/*
>>> + * Convert ART to TSC given numerator/denominator found in detect_art()
>>> + */
>>> +struct system_counterval_t convert_art_to_tsc(cycle_t art)
>>> +{
>>> +   u64 tmp, res, rem;
>>> +
>>> +   rem = do_div(art, art_to_tsc_denominator);
>>> +
>>> +   res = art * art_to_tsc_numerator;
>>> +   tmp = rem * art_to_tsc_numerator;
>>> +
>>> +   do_div(tmp, art_to_tsc_denominator);
>>> +   res += tmp;
>>> +
>>> +   return (struct system_counterval_t) {.cs =
>>> art_related_clocksource,
>>> +   .cycles = res};
>>
>>
>> The SDM and the patch description both mention an offset "k".  Shouldn't
>> this code at least have a comment about how it deals with the k != 0 case?
>
>
> I don't deal with the k != 0 case. I assume that IA32 TSC adjust MSR is 0
> because it's almost always a *bad idea* to change it. I've discussed this
> with a few other developers and there is some consensus agreeing. From an
> earlier related thread Peter Zijlstra asserts that TSC adjust "had
> better" be 0.(http://lkml.iu.edu/hypermail/linux/kernel/1507.3/03734.html).

I'm having trouble finding that in the link you sent.

>
> Do we really need to accommodate BIOS's that do this?

There are three interesting cases that I can think of:

1. Crappy BIOS that sets TSC_ADJUST.  As the not-so-proud owner of a
piece of crap motherboard that actively messes with the TSC, I don't
trust BIOS.

2. Hypervisors.  What if we're running as a guest with an ART-using
NIC passed through?

3. Hypothetical improved future kernel that politely uses TSC_ADJUST
to keep the TSC from going backwards across suspend/resume.

--Andy


Re: [PATCH v7 6/8] x86: tsc: Always Running Timer (ART) correlated clocksource

2016-02-22 Thread Christopher Hall
On Thu, 18 Feb 2016 13:11:33 -0800, Andy Lutomirski   
wrote:

+#define X86_FEATURE_INVARIANT_TSC (7*32+4) /* Intel Invariant TSC */


This is removed. It was basically an alias for NONSTOP_TSC and not needed.




+/*
+ * Convert ART to TSC given numerator/denominator found in detect_art()
+ */
+struct system_counterval_t convert_art_to_tsc(cycle_t art)
+{
+   u64 tmp, res, rem;
+
+   rem = do_div(art, art_to_tsc_denominator);
+
+   res = art * art_to_tsc_numerator;
+   tmp = rem * art_to_tsc_numerator;
+
+   do_div(tmp, art_to_tsc_denominator);
+   res += tmp;
+
+   return (struct system_counterval_t) {.cs = art_related_clocksource,
+   .cycles = res};


The SDM and the patch description both mention an offset "k".  Shouldn't  
this code at least have a comment about how it deals with the k != 0  
case?


I don't deal with the k != 0 case. I assume that IA32 TSC adjust MSR is 0  
because it's almost always a *bad idea* to change it. I've discussed this  
with a few other developers and there is some consensus agreeing. From an  
earlier related thread Peter Zijlstra asserts that TSC adjust "had

better" be 0.(http://lkml.iu.edu/hypermail/linux/kernel/1507.3/03734.html).

Do we really need to accommodate BIOS's that do this?

Chris


Re: [RFC PATCH net-next 0/3] Extend macvtap with multiple qdiscs

2016-02-22 Thread Jason Wang


On 02/08/2016 11:14 AM, Vladislav Yasevich wrote:
> This is an RFC series to extend macvtap with multiple qdisc.  Right now
> multiqueue macvtap setups suffer from lock contention.  Macvtap sets
> the queue index and thus gets a default qdisc allocated to it.  Since
> it later users dev_queue_xmit() call to the macvlan type device (so that
> we can packet captures and other filtering on macvtap itself) we end up
> with qdisc lock contention since what we have is multiple file descriptors
> writing to the same qdisc.
>
> With this series, the macvtap device now becomes a true multi-queue device
> that defaults to 1 queue.  Every time the user opens the device (this is
> how multiqueue macvtap is used), we update the number of real queues for
> the device.  When the user writes to the device, we record the queue index
> associted with the file descriptor to the skb, and that ends up translating
> to the device queue index.  This is one transmit only.  Receive side
> is left alone and will prefer skb hash if available. 
>
> Macvlan through this all is left with lockless transmit path.
>
> Thanks
> -vlad

A question is do we really want a qdisc for macvtap (and other pseudo
device)? If yes, the "problem" may not be specific to macvtap. Consider
you may get contention after place a qdisc on vlan device. If not,
probably a one line patch with IFF_NO_QUEUE is sufficient?

Thanks

>
> Vladislav Yasevich (3):
>   macvtap: mutiple qdiscs support
>   macvlan: add queue selection functionality
>   macvtap: Record the rx queue based on the user tap queue
>
>  drivers/net/macvlan.c | 20 
>  drivers/net/macvtap.c | 19 +++
>  2 files changed, 39 insertions(+)
>



Re: [PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Diego Viola
On Mon, Feb 22, 2016 at 10:58 PM, Diego Viola  wrote:
> On Mon, Feb 22, 2016 at 10:46 PM, Fabio Estevam  wrote:
>> On Mon, Feb 22, 2016 at 9:32 PM, Diego Viola  wrote:
>>> Signed-off-by: Diego Viola 
>>
>> You should write a commit log.
>
> I thought about including the link to my bug report:
> https://bugzilla.kernel.org/show_bug.cgi?id=112351
>
> What else would you suggest I add to the commit message?
>
> Diego

I probably should have explained also that this patch fixes my
suspend/resume problem even when /sys/power/pm_async is set to 1,
because before that, suspend/resume only worked when pm_async was 0.

I had a chat with Guo a few minutes ago on Hangouts and he said he
will look into this problem. :)

Diego


Re: [PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Diego Viola
On Mon, Feb 22, 2016 at 10:46 PM, Fabio Estevam  wrote:
> On Mon, Feb 22, 2016 at 9:32 PM, Diego Viola  wrote:
>> Signed-off-by: Diego Viola 
>
> You should write a commit log.

I thought about including the link to my bug report:
https://bugzilla.kernel.org/show_bug.cgi?id=112351

What else would you suggest I add to the commit message?

Diego


Re: 4.4.1 skb_warn_bad_offload+0xc5/0x110

2016-02-22 Thread Wakko Warner
Please keep me in CC.

Hannes Frederic Sowa wrote:
> [full-quote for netdev]
> On 16.02.2016 01:08, Wakko Warner wrote:
> >I've been seeing the following on some of my VMs ran under qemu.  The VMs do
> >not have internet connectivity.  This happened when some files were accessed
> >via NFS to another VM (NOTE: Both VMs throw these warnings.  Both VMs are
> >running the exact same kernel).  The host is also throwing these warnings
> >and is also 4.4.1, but not the same kernel build.
> >
> >The issue appears to have gone away if I issue the following on the guests
> >and on the host (except br0 instead of eth0 on host)
> >ethtool -K eth0 gso off gro off ufo off tso off
> >
> >On the host, br0 does not have any interfaces enslaved except for the
> >interface for the VMs and also does not have an IPv4 address assigned.
> >
> >[   90.067519] [ cut here ]
> >[   90.067678] WARNING: CPU: 0 PID: 2258 at 
> >/usr/src/linux/dist/4.4.1-nobklcd/net/core/dev.c:2422 
> >skb_warn_bad_offload+0xc5/0x110()
> >[   90.067766] virtio_net: caps=(0x0804001f4a29, 0x) 
> >len=32934 data_len=32768 gso_size=1480 gso_type=2 ip_summed=0
> >[   90.067878] Modules linked in: nfsv3 nfsd auth_rpcgss oid_registry 
> >exportfs nfs lockd grace sunrpc ipv6 virtio_net virtio_balloon evdev unix
> >[   90.068206] CPU: 0 PID: 2258 Comm: kworker/0:1H Not tainted 4.4.1 #1
> >[   90.068258] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 
> >Debian-1.8.2-1 04/01/2014
> >[   90.068340] Workqueue: rpciod rpc_async_schedule [sunrpc]
> >[   90.068433]  81503288 811d455e 880276ffb9a0 
> >81041343
> >[   90.068575]  88007b85be00 880276ffb9f0 0002 
> >880276f87aac
> >[   90.068725]  88027692c000 810413b7 81503498 
> >0030
> >[   90.068846] Call Trace:
> >[   90.06]  [] ? dump_stack+0x47/0x69
> >[   90.068967]  [] ? warn_slowpath_common+0x73/0xa0
> >[   90.069068]  [] ? warn_slowpath_fmt+0x47/0x50
> >[   90.069129]  [] ? skb_warn_bad_offload+0xc5/0x110
> >[   90.069191]  [] ? __skb_gso_segment+0x71/0xc0
> >[   90.069250]  [] ? 
> >validate_xmit_skb.isra.119.part.120+0x100/0x290
> >[   90.069314]  [] ? lock_timer_base.isra.22+0x49/0x60
> >[   90.069381]  [] ? validate_xmit_skb_list+0x31/0x50
> >[   90.069440]  [] ? sch_direct_xmit+0x140/0x1e0
> >[   90.069497]  [] ? __dev_queue_xmit+0x1c8/0x490
> >[   90.069555]  [] ? ip_finish_output2+0x122/0x300
> >[   90.069613]  [] ? release_sock+0xfd/0x160
> >[   90.069671]  [] ? ip_output+0xb5/0xc0
> >[   90.069720]  [] ? ip_reply_glue_bits+0x50/0x50
> >[   90.069784]  [] ? prandom_u32+0x1b/0x30
> >[   90.069833]  [] ? ip_local_out+0x12/0x40
> >[   90.069877]  [] ? ip_send_skb+0x10/0x40
> >[   90.069922]  [] ? udp_send_skb+0x160/0x240
> >[   90.069990]  [] ? udp_push_pending_frames+0x34/0x50
> >[   90.070050]  [] ? udp_sendpage+0xe4/0x150
> >[   90.070095]  [] ? kernel_sendmsg+0x2a/0x40
> >[   90.070164]  [] ? xs_send_kvec+0x83/0x90 [sunrpc]
> >[   90.070223]  [] ? inet_sendpage+0x93/0xe0
> >[   90.070270]  [] ? xs_sendpages+0x16f/0x1b0 [sunrpc]
> >[   90.070330]  [] ? xs_udp_send_request+0x5e/0x100 
> >[sunrpc]
> >[   90.070390]  [] ? xprt_transmit+0x47/0x230 [sunrpc]
> >[   90.070449]  [] ? call_transmit+0x175/0x220 [sunrpc]
> >[   90.070508]  [] ? __rpc_execute+0x4b/0x290 [sunrpc]
> >[   90.070575]  [] ? finish_task_switch+0x83/0x1b0
> >[   90.070653]  [] ? process_one_work+0x129/0x3f0
> >[   90.070711]  [] ? worker_thread+0x42/0x490
> >[   90.070764]  [] ? process_one_work+0x3f0/0x3f0
> >[   90.070816]  [] ? kthread+0xb8/0xd0
> >[   90.070860]  [] ? kthread_worker_fn+0x100/0x100
> >[   90.070925]  [] ? ret_from_fork+0x3f/0x70
> >[   90.070974]  [] ? kthread_worker_fn+0x100/0x100
> >[   90.071035] ---[ end trace ffb4f8c2d24c1959 ]---
> >
> 
> Can you try the following patch?

I'll try it tomorrow.  I had some disk failures on this system and am in the
process of restoring it.

> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -1233,6 +1233,9 @@ ssize_t   ip_append_page(struct sock *sk,
> struct flowi4 *fl4, struct page *page,
> if (!skb)
> return -EINVAL;
> 
> +   if (skb->ip_summed != CHECKSUM_PARTIAL)
> +   return -EINVAL;
> +
> cork->length += size;
> if ((size + skb->len > mtu) &&
> (sk->sk_protocol == IPPROTO_UDP) &&
-- 
 Microsoft has beaten Volkswagen's world record.  Volkswagen only created 22
 million bugs.


Re: [PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Fabio Estevam
On Mon, Feb 22, 2016 at 9:32 PM, Diego Viola  wrote:
> Signed-off-by: Diego Viola 

You should write a commit log.


Re: [PATCH] jme: remove the jme driver as it is no longer maintained

2016-02-22 Thread Diego Viola
On Sun, Feb 21, 2016 at 2:17 PM, Diego Viola  wrote:
> On Sun, Feb 21, 2016 at 9:45 AM, One Thousand Gnomes
>  wrote:
>>> I would appreciate some hint from someone who is more experienced with 
>>> drivers.
>>
>> Start by testing
>>
>> - loading the driver as a module
>> - using the networking
>> - unloading the module (and checking it stays unloaded!)
>>
>> then suspend/resume
>>
>> If that works then you have a good starting point because you know a
>> sequence of actions that suspends properly. If it fails then it's going
>> to be rather more fun because it implies something in the hardware has
>> not been properly shut down.
>>
>> Alan
>
> Hi Alan,
>
> Thanks for your email, did you see my bug report? Because I tried all
> this already.
>
> The only workarounds I've found to work is one of these:
>
> $ rmmod jme # before suspend
>
> or
>
> $ ip link set ens34 down
>
> or
>
> $ echo 0 > /sys/power/pm_async # disable async power management
>
> Then resume works fine (I can't reproduce the hang).
>
> I'm not a C developer nor a kernel developer, I tried looking at the
> jme.c driver code but it's not clear what is broken and what needs
> fixing, so I would appreciate someone more experienced looking at the
> issue and giving me an idea or two.
>
> Thanks,
> Diego

Please disregard this patch, I feel like an idiot for sending it.

I've found a fix already and sent a patch.

Diego


[PATCH net] bpf: fix csum setting for bpf_set_tunnel_key

2016-02-22 Thread Daniel Borkmann
The fix in 35e2d1152b22 ("tunnels: Allow IPv6 UDP checksums to be correctly
controlled.") changed behavior for bpf_set_tunnel_key() when in use with
IPv6 and thus uncovered a bug that TUNNEL_CSUM needed to be set but wasn't.
As a result, the stack dropped ingress vxlan IPv6 packets, that have been
sent via eBPF through collect meta data mode due to checksum now being zero.

Since after LCO, we enable IPv4 checksum by default, so make that analogous
and only provide a flag BPF_F_ZERO_CSUM_TX for the user to turn it off in
IPv4 case.

Fixes: 35e2d1152b22 ("tunnels: Allow IPv6 UDP checksums to be correctly 
controlled.")
Fixes: c6c33454072f ("bpf: support ipv6 for bpf_skb_{set,get}_tunnel_key")
Signed-off-by: Daniel Borkmann 
Acked-by: Alexei Starovoitov 
---
 Since the tunnel key IPv6 support sits in Linus' tree, would be good to
 fix it before it goes out. The patch is small and probably not worth
 splitting into two parts, I've tested that IPv6 and IPv4 (csum on/off)
 is working fine with it. Thanks!

 include/uapi/linux/bpf.h | 3 +++
 net/core/filter.c| 6 --
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index aa6f857..5df4881 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -292,6 +292,9 @@ enum bpf_func_id {
 /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */
 #define BPF_F_TUNINFO_IPV6 (1ULL << 0)
 
+/* BPF_FUNC_skb_set_tunnel_key flags. */
+#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
+
 /* user accessible mirror of in-kernel sk_buff.
  * new fields can only be added to the end of this structure
  */
diff --git a/net/core/filter.c b/net/core/filter.c
index 94d2620..bba502f 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1752,7 +1752,7 @@ static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 
size, u64 flags, u64 r5)
u8 compat[sizeof(struct bpf_tunnel_key)];
struct ip_tunnel_info *info;
 
-   if (unlikely(flags & ~(BPF_F_TUNINFO_IPV6)))
+   if (unlikely(flags & ~(BPF_F_TUNINFO_IPV6 | BPF_F_ZERO_CSUM_TX)))
return -EINVAL;
if (unlikely(size != sizeof(struct bpf_tunnel_key))) {
switch (size) {
@@ -1776,7 +1776,7 @@ static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 
size, u64 flags, u64 r5)
info = >u.tun_info;
info->mode = IP_TUNNEL_INFO_TX;
 
-   info->key.tun_flags = TUNNEL_KEY;
+   info->key.tun_flags = TUNNEL_KEY | TUNNEL_CSUM;
info->key.tun_id = cpu_to_be64(from->tunnel_id);
info->key.tos = from->tunnel_tos;
info->key.ttl = from->tunnel_ttl;
@@ -1787,6 +1787,8 @@ static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 
size, u64 flags, u64 r5)
   sizeof(from->remote_ipv6));
} else {
info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4);
+   if (flags & BPF_F_ZERO_CSUM_TX)
+   info->key.tun_flags &= ~TUNNEL_CSUM;
}
 
return 0;
-- 
1.9.3



[PATCH][net-next][v2] bridge: allow the maximum mtu to 64k

2016-02-22 Thread roy . qing . li
From: Li RongQing 

A linux bridge always adopts the smallest MTU of the enslaved devices.
When no device are enslaved, it defaults to a MTU of 1500 and refuses to
use a larger one. This is problematic when using bridges enslaving only
virtual NICs (vnetX) like it's common with KVM guests.

Steps to reproduce the problem

1) sudo ip link add br-test0 type bridge # create an empty bridge
2) sudo ip link set br-test0 mtu 9000 # attempt to set MTU > 1500
3) ip link show dev br-test0 # confirm MTU

Here, 2) returns "RTNETLINK answers: Invalid argument". One (cumbersome)
way around this is:

4) sudo modprobe dummy
5) sudo ip link set dummy0 mtu 9000 master br-test0

Then the bridge's MTU can be changed from anywhere to 9000.

This is especially annoying for the virtualization case because the
KVM's tap driver will by default adopt the bridge's MTU on startup
making it impossible (without the workaround) to use a large MTU on the
guest VMs.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1399064

Signed-off-by: Li RongQing 
---
 net/bridge/br_if.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index c367b3e..a2ed99d 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -390,7 +390,9 @@ int br_del_bridge(struct net *net, const char *name)
return ret;
 }
 
-/* MTU of the bridge pseudo-device: ETH_DATA_LEN or the minimum of the ports */
+/* MTU of the bridge pseudo-device: the maximum IP packet size
+ * or the minimum of the ports
+ */
 int br_min_mtu(const struct net_bridge *br)
 {
const struct net_bridge_port *p;
@@ -399,7 +401,7 @@ int br_min_mtu(const struct net_bridge *br)
ASSERT_RTNL();
 
if (list_empty(>port_list))
-   mtu = ETH_DATA_LEN;
+   mtu = 64 * 1024;
else {
list_for_each_entry(p, >port_list, list) {
if (!mtu  || p->dev->mtu < mtu)
-- 
2.1.4



netfilter: warning at net/ipv4/netfilter/nf_nat_l3proto_ipv4.c:275 nf_nat_ipv4_fn

2016-02-22 Thread Sasha Levin
Hi all,

I've hit the following warning while fuzzing with trinity inside a kvmtool guest
running the latest -next kernel:

[ 3196.268106] WARNING: CPU: 3 PID: 660 at 
net/ipv4/netfilter/nf_nat_l3proto_ipv4.c:275 nf_nat_ipv4_fn+0x65d/0xab0()

[ 3196.268120] Modules linked in:

[ 3196.268142] CPU: 3 PID: 660 Comm: trinity-c95 Not tainted 
4.5.0-rc4-next-20160219-sasha-00026-g7978205-dirty #2978

[ 3196.268173]  110017065e9b 8800b832f560 a23d9a9d 
0003

[ 3196.268196]  fbfff5c2a630 41b58ab3 adb3a8f2 
a23d9905

[ 3196.268216]  a059a760 880371b25494 8800b832f958 
8800b832f960

[ 3196.268222] Call Trace:

[ 3196.268273] dump_stack (lib/dump_stack.c:53)
[ 3196.268375] warn_slowpath_common (kernel/panic.c:483)
[ 3196.268417] warn_slowpath_null (kernel/panic.c:517)
[ 3196.268435] nf_nat_ipv4_fn (net/ipv4/netfilter/nf_nat_l3proto_ipv4.c:275 
(discriminator 1))
[ 3196.268543] nf_nat_ipv4_local_fn 
(net/ipv4/netfilter/nf_nat_l3proto_ipv4.c:429)
[ 3196.268573] iptable_nat_ipv4_local_fn (net/ipv4/netfilter/iptable_nat.c:65)
[ 3196.268596] nf_iterate (net/netfilter/core.c:275)
[ 3196.268622] nf_hook_slow (net/netfilter/core.c:306)
[ 3196.268701] raw_send_hdrinc (include/linux/netfilter.h:225 
include/linux/netfilter.h:249 net/ipv4/raw.c:418)
[ 3196.268773] raw_sendmsg (net/ipv4/raw.c:640)
[ 3196.268869] inet_sendmsg (net/ipv4/af_inet.c:740)
[ 3196.268913] sock_sendmsg (net/socket.c:612 net/socket.c:621)
[ 3196.268927] SYSC_sendto (net/socket.c:1651)
[ 3196.269049] SyS_sendto (net/socket.c:1619)
[ 3196.269074] entry_SYSCALL_64_fastpath (arch/x86/entry/entry_64.S:200)


Thanks,
Sasha


Re: [PATCH][net-next] bridge: increase mtu to 9000

2016-02-22 Thread Li RongQing
On Tue, Feb 23, 2016 at 1:58 AM, Stephen Hemminger
 wrote:
>> guest VMs.
>>
>> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1399064
>>
>> Signed-off-by: Li RongQing 
>
> Your change works, but I agree with Hannes. Just allow up to 64 * 1024 like
> loopback does.  And no need for a #define for that it is only in one place.



thanks, I will change it as you suggest

-Roy


Re: Computer fails to resume from suspend unless I rmmod jme before initiating the suspend

2016-02-22 Thread Diego Viola
On Mon, Feb 22, 2016 at 4:20 PM, Pavel Machek  wrote:
> On Mon 2016-02-22 15:59:48, Diego Viola wrote:
>> On Mon, Feb 22, 2016 at 7:09 AM, Pavel Machek  wrote:
>> > Hi!
>> >
>> >>  Every time I initiate a suspend (systemctl suspend) the machine hangs
>> >>  at resume unless I unload the jme driver.
>> >
>> > It seems to have some kind of suspend/resume support. ... and it is
>> > rather complex.
>> >
>> > Maybe jme_start_irq(jme) should be moved to the end of jme_resume
>> > function?
>> >
>> >> > So I found that disabling async as in:
>> >> >
>> >> > $ echo 0 > /sys/power/pm_async
>> >> >
>> >> > Helps with my issue, I can't reproduce the hang anymore, tried
>> >> > suspend/resume almost ~15 times.
>> >> >
>> >> > Diego
>> >>
>> >> Can someone please help?
>>
>> Hi Pavel,
>>
>> This did the trick, suspend/resume is now working perfectly for me
>> (tried more than 10 times). :)
>>
>> Thank you so much, should I send a patch?
>
> Yes please.
>
> Pavel
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Sent, thank you.

Diego


[PATCH] net: jme: fix suspend/resume on JMC260

2016-02-22 Thread Diego Viola
Signed-off-by: Diego Viola 
---
 drivers/net/ethernet/jme.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index b1de7af..8adbe8f 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -3312,13 +3312,14 @@ jme_resume(struct device *dev)
jme_reset_phy_processor(jme);
jme_phy_calibration(jme);
jme_phy_setEA(jme);
-   jme_start_irq(jme);
netif_device_attach(netdev);
 
atomic_inc(>link_changing);
 
jme_reset_link(jme);
 
+   jme_start_irq(jme);
+
return 0;
 }
 
-- 
2.7.1



Re: iproute2 query

2016-02-22 Thread Marcus Furlong
On 22 February 2016 at 07:05, Stephen Hemminger
 wrote:
> On Fri, 19 Feb 2016 20:12:04 +1100
> Marcus Furlong  wrote:
>
>> Hi,
>>
>> Just wondering if the following command should work:
>>
>> # ip route add 192.168.27.27/24 dev eth0 scope link src 192.168.27.27
>> RTNETLINK answers: Invalid argument
>>
>> However, this command works:
>>
>> # ip route add 192.168.27.0/24 dev eth0 scope link src 192.168.27.27
>>
>> 192.168.27.0/24 and 192.168.27.27/24 describe the same subnet?
>>
>
> It is the kernel complaining, not ip command.
> The kernel will not accept 192.168.27.27/24 as route since it is a full
> network address, not an network prefix.

Would it be a bad idea for the ip command to validate the data, and
only submit the network bits to the kernel?

Regards,
Marcus.

-- 
Marcus Furlong


Re: [PATCH can-next 1/2] CAN: rcar: add gen[12] fallback compatibility strings

2016-02-22 Thread Simon Horman
On Mon, Feb 22, 2016 at 10:40:37AM +0100, Marc Kleine-Budde wrote:
> On 02/22/2016 04:37 AM, Rob Herring wrote:
> > On Mon, Feb 22, 2016 at 11:15:49AM +0900, Simon Horman wrote:
> >> Add fallback compatibility string for R-Car Gen 1 and Gen2 families.
> >> This is in keeping with the fallback scheme being adopted wherever
> >> appropriate for drivers for Renesas SoCs.
> >>
> >> Signed-off-by: Simon Horman 
> >> ---
> >>  Documentation/devicetree/bindings/net/can/rcar_can.txt | 4 +++-
> >>  drivers/net/can/rcar_can.c | 2 ++
> >>  2 files changed, 5 insertions(+), 1 deletion(-)
> > 
> > Acked-by: Rob Herring 
> 
> I'm not following the latest DT discussions, is there a (new) decision
> to add such "generic" compatibles? AFAIK you add the oldest device
> that's compatible with your driver to your SoC dtsi at rightmost
> compatible. You can add one that identifies your SoC's IP core in front
> of it. So there's no need to modify the driver until an IP core needs
> different handling.
> 
> In your case you'd identify the oldest SoC that implements the Gen1 IP
> core and use this instead of "renesas,can-gen1. Same for Gen2 IP core.

In the case of Renesas R-Car hardware we know that there are generations of
SoCs, e.g. Gen 1 and Gen 2, but beyond that its not clear what the
relationship between IP blocks might be. For example, I believe that
r8a7779 is older than r8a7778 but that doesn't imply that the
latter is a descendant of the former or vice versa.


Re: [PATCH can-next 1/2] CAN: rcar: add gen[12] fallback compatibility strings

2016-02-22 Thread Simon Horman
On Mon, Feb 22, 2016 at 04:40:39PM +0100, Geert Uytterhoeven wrote:
> On Mon, Feb 22, 2016 at 3:15 AM, Simon Horman
>  wrote:
> > Add fallback compatibility string for R-Car Gen 1 and Gen2 families.
> > This is in keeping with the fallback scheme being adopted wherever
> > appropriate for drivers for Renesas SoCs.
> >
> > Signed-off-by: Simon Horman 
> > ---
> >  Documentation/devicetree/bindings/net/can/rcar_can.txt | 4 +++-
> >  drivers/net/can/rcar_can.c | 2 ++
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/net/can/rcar_can.txt 
> > b/Documentation/devicetree/bindings/net/can/rcar_can.txt
> > index 002d8440bf66..036786e1f70d 100644
> > --- a/Documentation/devicetree/bindings/net/can/rcar_can.txt
> > +++ b/Documentation/devicetree/bindings/net/can/rcar_can.txt
> > @@ -6,6 +6,8 @@ Required properties:
> >   "renesas,can-r8a7779" if CAN controller is a part of R8A7779 
> > SoC.
> >   "renesas,can-r8a7790" if CAN controller is a part of R8A7790 
> > SoC.
> >   "renesas,can-r8a7791" if CAN controller is a part of R8A7791 
> > SoC.
> > + "renesas,can-gen1" for a generic R-Car Gen1 compatible device.
> > + "renesas,can-gen2" for a generic R-Car Gen2 compatible device.
> 
> "renesas,rcar-gen1-can", "renesas,rcar-gen2-can"?
> 
> (Yeah, "can" looks a lot like "rcar" ;-)

Sure, I'll update that as you suggest.

> Nothing further to say about SoC-specific vs. generic compatible values?

Sure, I'll add some text about that.

> >  - reg: physical base address and size of the R-Car CAN register map.
> >  - interrupts: interrupt specifier for the sole interrupt.
> >  - clocks: phandles and clock specifiers for 3 CAN clock inputs.
> > @@ -25,7 +27,7 @@ Example
> >  SoC common .dtsi file:
> >
> > can0: can@e6e8 {
> > -   compatible = "renesas,can-r8a7791";
> > +   compatible = "renesas,can-r8a7791", "renesas,can-gen2";
> 
> "renesas,rcar-gen2-can".
> 
> > reg = <0 0xe6e8 0 0x1000>;
> > interrupts = <0 186 IRQ_TYPE_LEVEL_HIGH>;
> > clocks = <_clks R8A7791_CLK_RCAN0>,
> > diff --git a/drivers/net/can/rcar_can.c b/drivers/net/can/rcar_can.c
> > index bc46be39549d..c70a1f795933 100644
> > --- a/drivers/net/can/rcar_can.c
> > +++ b/drivers/net/can/rcar_can.c
> > @@ -904,6 +904,8 @@ static const struct of_device_id rcar_can_of_table[] 
> > __maybe_unused = {
> > { .compatible = "renesas,can-r8a7779" },
> > { .compatible = "renesas,can-r8a7790" },
> > { .compatible = "renesas,can-r8a7791" },
> > +   { .compatible = "renesas,can-gen1" },
> > +   { .compatible = "renesas,can-gen2" },
> 
> "renesas,rcar-gen1-can"
> "renesas,rcar-gen2-can".
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH V2 net-next 2/3] lan78xx: add ethtool set & get pause functions

2016-02-22 Thread Ben Hutchings
On Mon, 2016-02-22 at 20:28 +, woojung@microchip.com wrote:
> > -Original Message-
> > From: Ben Hutchings [mailto:b...@decadent.org.uk]
> > Sent: Monday, February 22, 2016 3:05 PM
> > To: David Miller; Woojung Huh - C21699
> > Cc: netdev@vger.kernel.org
> > Subject: Re: [PATCH V2 net-next 2/3] lan78xx: add ethtool set & get pause
> > functions
> > 
> > On Mon, 2016-02-22 at 14:10 -0500, David Miller wrote:
> > > From: 
> > > Date: Mon, 22 Feb 2016 18:28:18 +
> > > 
> > > > > This is incorrect; you should always return the manual settings
> > > > > (fc_request_control flags) here.  If autonegotiation is enabled then
> > > > > your get_settings function will return the actual pause flags.
> > > > > 
> > > > What do you mean "return actual pause flags" when autoneg is enabled?
> > > > Pause flags set by (or default) advertise flag?
> > > 
> > > It means what was negotiated by autonegotiation, and is actually in use.
> > > 
> > > Otherwise, how can the user find out what was negotiated?
> > 
> > Well, actually we don't *directly* report the autonegotiation flow
> > control mode at present.  We report which pause flags were advertised
> > and what the link partner advertised, from which you can work it out.
> 
> NIC advertises pause flags via advertise register (phy reg 0x4) based on Rx & 
> Tx flags,
> and get_pauseparam() returns Rx & Tx flags set by set_pauseparm() if 
> autonegotiation is enabled?

Yes.

> > Perhaps ethtool (the utility) should explicitly show what the result
> > is.
> Ethtool -a reports Rx/Tx flags and Rx/Tx negotiated flag based on advertising 
> and lp_advertising value.

It would probably make sense to include the result of pause frame
autonegotiation in both the 'ethtool -a' and 'ethtool' (no option)
output.

Ben.

-- 
Ben Hutchings
The generation of random numbers is too important to be left to chance.
- Robert Coveyou

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


Re: [PATCH can-next 2/2] CAN: rcar: add device tree support for r8a779[234]

2016-02-22 Thread Simon Horman
On Mon, Feb 22, 2016 at 02:48:39PM +0100, Geert Uytterhoeven wrote:
> On Mon, Feb 22, 2016 at 3:15 AM, Simon Horman
>  wrote:
> > Simply document new compatibility string.
> > As a previous patch adds a generic R-Car Gen2 compatibility string
> > there appears to be no need for a driver updates.
> > By documenting this compat sting it may be used in DTSs shipped, for
> 
> string
> 
> > example as part of ROMs. It must be used in conjunction with the Gen2
> > fallback compat string. At this time there are no known differences between
> > the r8a779[234] IP blocks and that implemented by the driver for the Gen2
> > fallback compat string. Thus there is no need to update the driver as the
>   ^
> > use of the Gen2 fallback compat string will activate the correct code in
>   ^^
> 
> > the current driver while leaving the option for r8a779[234]-specific driver
> > code to be activated in an updated driver should the need arise.
> >
> > Signed-off-by: Simon Horman 
> > ---
> >  Documentation/devicetree/bindings/net/can/rcar_can.txt | 3 +++
> >  drivers/net/can/rcar_can.c | 3 +++
> >  2 files changed, 6 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/net/can/rcar_can.txt 
> > b/Documentation/devicetree/bindings/net/can/rcar_can.txt
> > index 036786e1f70d..c6fb74d7c809 100644
> > --- a/Documentation/devicetree/bindings/net/can/rcar_can.txt
> > +++ b/Documentation/devicetree/bindings/net/can/rcar_can.txt
> > @@ -6,6 +6,9 @@ Required properties:
> >   "renesas,can-r8a7779" if CAN controller is a part of R8A7779 
> > SoC.
> >   "renesas,can-r8a7790" if CAN controller is a part of R8A7790 
> > SoC.
> >   "renesas,can-r8a7791" if CAN controller is a part of R8A7791 
> > SoC.
> > + "renesas,can-r8a7792" if CAN controller is a part of R8A7792 
> > SoC.
> > + "renesas,can-r8a7793" if CAN controller is a part of R8A7793 
> > SoC.
> > + "renesas,can-r8a7794" if CAN controller is a part of R8A7794 
> > SoC.
> >   "renesas,can-gen1" for a generic R-Car Gen1 compatible device.
> >   "renesas,can-gen2" for a generic R-Car Gen2 compatible device.
> >  - reg: physical base address and size of the R-Car CAN register map.
> > diff --git a/drivers/net/can/rcar_can.c b/drivers/net/can/rcar_can.c
> > index c70a1f795933..73761a4dd1bf 100644
> > --- a/drivers/net/can/rcar_can.c
> > +++ b/drivers/net/can/rcar_can.c
> > @@ -904,6 +904,9 @@ static const struct of_device_id rcar_can_of_table[] 
> > __maybe_unused = {
> > { .compatible = "renesas,can-r8a7779" },
> > { .compatible = "renesas,can-r8a7790" },
> > { .compatible = "renesas,can-r8a7791" },
> > +   { .compatible = "renesas,can-r8a7792" },
> > +   { .compatible = "renesas,can-r8a7793" },
> > +   { .compatible = "renesas,can-r8a7794" },
> 
> So why do you update the driver?
> 
> There's no upstream DTS using "renesas,can-r8a779[234]", so
> "renesas,can-gen2" should be fine.

True. I'm not sure how that slipped in.

> > { .compatible = "renesas,can-gen1" },
> > { .compatible = "renesas,can-gen2" },
> > { }
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


[Patch net-next v2 1/2] net_sched: prepare tcf_hashinfo_destroy() for netns support

2016-02-22 Thread Cong Wang
We only release the memory of the hashtable itself, not its
entries inside. This is not a problem yet since we only call
it in module release path, and module is refcount'ed by
actions. This would be a problem after we move the per module
hinfo into per netns in the latter patch.

Cc: Jamal Hadi Salim 
Signed-off-by: Cong Wang 
---
 include/net/act_api.h |  5 -
 net/sched/act_api.c   | 32 +---
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 9d446f13..8c4e3ff 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -65,11 +65,6 @@ static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, 
unsigned int mask)
return 0;
 }
 
-static inline void tcf_hashinfo_destroy(struct tcf_hashinfo *hf)
-{
-   kfree(hf->htab);
-}
-
 /* Update lastuse only if needed, to avoid dirtying a cache line.
  * We use a temp variable to avoid fetching jiffies twice.
  */
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 06e7c4a..acafaf7 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -69,7 +69,7 @@ int __tcf_hash_release(struct tc_action *a, bool bind, bool 
strict)
if (a->ops->cleanup)
a->ops->cleanup(a, bind);
tcf_hash_destroy(a);
-   ret = 1;
+   ret = ACT_P_DELETED;
}
}
 
@@ -302,6 +302,32 @@ void tcf_hash_insert(struct tc_action *a)
 }
 EXPORT_SYMBOL(tcf_hash_insert);
 
+static void tcf_hashinfo_destroy(const struct tc_action_ops *ops)
+{
+   struct tcf_hashinfo *hinfo = ops->hinfo;
+   struct tc_action a = {
+   .ops = ops,
+   };
+   int i;
+
+   for (i = 0; i < hinfo->hmask + 1; i++) {
+   struct tcf_common *p;
+   struct hlist_node *n;
+
+   hlist_for_each_entry_safe(p, n, >htab[i], tcfc_head) {
+   int ret;
+
+   a.priv = p;
+   ret = __tcf_hash_release(, false, true);
+   if (ret == ACT_P_DELETED)
+   module_put(ops->owner);
+   else if (ret < 0)
+   return;
+   }
+   }
+   kfree(hinfo->htab);
+}
+
 static LIST_HEAD(act_base);
 static DEFINE_RWLOCK(act_mod_lock);
 
@@ -333,7 +359,7 @@ int tcf_register_action(struct tc_action_ops *act, unsigned 
int mask)
list_for_each_entry(a, _base, head) {
if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
write_unlock(_mod_lock);
-   tcf_hashinfo_destroy(act->hinfo);
+   tcf_hashinfo_destroy(act);
kfree(act->hinfo);
return -EEXIST;
}
@@ -353,7 +379,7 @@ int tcf_unregister_action(struct tc_action_ops *act)
list_for_each_entry(a, _base, head) {
if (a == act) {
list_del(>head);
-   tcf_hashinfo_destroy(act->hinfo);
+   tcf_hashinfo_destroy(act);
kfree(act->hinfo);
err = 0;
break;
-- 
2.1.0



[Patch net-next v2 0/2] net_sched: add network namespace support for tc actions

2016-02-22 Thread Cong Wang
This patchset adds network namespace support for tc actions.

v2:
* pull the first patch into net-next
* reduce code duplication by introducing more helper functions

Cong Wang (2):
  net_sched: prepare tcf_hashinfo_destroy() for netns support
  net_sched: add network namespace support for tc actions

 include/net/act_api.h|  63 --
 net/sched/act_api.c  | 137 ---
 net/sched/act_bpf.c  |  52 --
 net/sched/act_connmark.c |  54 ---
 net/sched/act_csum.c |  59 +---
 net/sched/act_gact.c |  55 ---
 net/sched/act_ipt.c  | 127 ++-
 net/sched/act_mirred.c   |  54 ---
 net/sched/act_nat.c  |  54 ---
 net/sched/act_pedit.c|  54 ---
 net/sched/act_police.c   |  52 ++
 net/sched/act_simple.c   |  55 ---
 net/sched/act_skbedit.c  |  54 ---
 net/sched/act_vlan.c |  54 ---
 14 files changed, 771 insertions(+), 153 deletions(-)

-- 
2.1.0



[Patch net-next v2 2/2] net_sched: add network namespace support for tc actions

2016-02-22 Thread Cong Wang
Currently tc actions are stored in a per-module hashtable,
therefore are visible to all network namespaces. This is
probably the last part of the tc subsystem which is not
aware of netns now. This patch makes them per-netns,
several tc action API's need to be adjusted for this.

The tc action API code is ugly due to historical reasons,
we need to refactor that code in the future.

Cc: Jamal Hadi Salim 
Signed-off-by: Cong Wang 
---
 include/net/act_api.h|  58 ++
 net/sched/act_api.c  | 113 +
 net/sched/act_bpf.c  |  52 +--
 net/sched/act_connmark.c |  54 +---
 net/sched/act_csum.c |  59 +++---
 net/sched/act_gact.c |  55 +---
 net/sched/act_ipt.c  | 127 ++-
 net/sched/act_mirred.c   |  54 +---
 net/sched/act_nat.c  |  54 +---
 net/sched/act_pedit.c|  54 +---
 net/sched/act_police.c   |  52 +++
 net/sched/act_simple.c   |  55 +---
 net/sched/act_skbedit.c  |  54 +---
 net/sched/act_vlan.c |  54 +---
 14 files changed, 746 insertions(+), 149 deletions(-)

diff --git a/include/net/act_api.h b/include/net/act_api.h
index 8c4e3ff..342be6c 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -7,6 +7,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 struct tcf_common {
struct hlist_node   tcfc_head;
@@ -87,31 +89,65 @@ struct tc_action {
__u32   type; /* for backward compat(TCA_OLD_COMPAT) */
__u32   order;
struct list_headlist;
+   struct tcf_hashinfo *hinfo;
 };
 
 struct tc_action_ops {
struct list_head head;
-   struct tcf_hashinfo *hinfo;
charkind[IFNAMSIZ];
__u32   type; /* TBD to match kind */
struct module   *owner;
int (*act)(struct sk_buff *, const struct tc_action *, struct 
tcf_result *);
int (*dump)(struct sk_buff *, struct tc_action *, int, int);
void(*cleanup)(struct tc_action *, int bind);
-   int (*lookup)(struct tc_action *, u32);
+   int (*lookup)(struct net *, struct tc_action *, u32);
int (*init)(struct net *net, struct nlattr *nla,
struct nlattr *est, struct tc_action *act, int ovr,
int bind);
-   int (*walk)(struct sk_buff *, struct netlink_callback *, int, 
struct tc_action *);
+   int (*walk)(struct net *, struct sk_buff *,
+   struct netlink_callback *, int, struct tc_action *);
+};
+
+struct tc_action_net {
+   struct tcf_hashinfo *hinfo;
+   const struct tc_action_ops *ops;
 };
 
-int tcf_hash_search(struct tc_action *a, u32 index);
-u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo);
-int tcf_hash_check(u32 index, struct tc_action *a, int bind);
-int tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a,
-   int size, int bind, bool cpustats);
+static inline
+int tc_action_net_init(struct tc_action_net *tn, const struct tc_action_ops 
*ops,
+  unsigned int mask)
+{
+   int err = 0;
+
+   tn->hinfo = kmalloc(sizeof(*tn->hinfo), GFP_KERNEL);
+   if (!tn->hinfo)
+   return -ENOMEM;
+   tn->ops = ops;
+   err = tcf_hashinfo_init(tn->hinfo, mask);
+   if (err)
+   kfree(tn->hinfo);
+   return err;
+}
+
+void tcf_hashinfo_destroy(const struct tc_action_ops *ops,
+ struct tcf_hashinfo *hinfo);
+
+static inline void tc_action_net_exit(struct tc_action_net *tn)
+{
+   tcf_hashinfo_destroy(tn->ops, tn->hinfo);
+}
+
+int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
+  struct netlink_callback *cb, int type,
+  struct tc_action *a);
+int tcf_hash_search(struct tc_action_net *tn, struct tc_action *a, u32 index);
+u32 tcf_hash_new_index(struct tc_action_net *tn);
+int tcf_hash_check(struct tc_action_net *tn, u32 index, struct tc_action *a,
+  int bind);
+int tcf_hash_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
+   struct tc_action *a, int size, int bind, bool cpustats);
 void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est);
-void tcf_hash_insert(struct tc_action *a);
+void tcf_hash_insert(struct tc_action_net *tn, struct tc_action *a);
 
 int __tcf_hash_release(struct tc_action *a, bool bind, bool strict);
 
@@ -120,8 +156,8 @@ static inline int tcf_hash_release(struct tc_action *a, 
bool bind)
return __tcf_hash_release(a, bind, false);
 }
 
-int tcf_register_action(struct tc_action_ops *a, unsigned int mask);
-int tcf_unregister_action(struct tc_action_ops *a);
+int 

Re: [Patch net-next] net_sched: add network namespace support for tc actions

2016-02-22 Thread Cong Wang
On Mon, Feb 22, 2016 at 5:42 AM, Jamal Hadi Salim  wrote:
> I did a quick look and i am struggling with it. The patch seems largish
> The issue is that we need to do this per kernel module so the code
> churn maybe unavoidable; hinfo stored in act_ops complicates things.
> Having said that:  All the pernet operations in your
> code seem to be generic, other than to accomodate for module specific
> act_ops. Is it possible to make generic pernet operations? This way
> you could do things at tcf_register_action() for all actions.
> The challenge seems to be in the xxx_net_id which appears(sorry didnt
> look closely at the namespace code) to need to be unique id per module
> and per namespace instance - otherwise i would suggest for xxx_net_id

I got some idea to reduce the duplicated code, not all but most.

> to be part of act_ops. Could we not have an #ifdef in the namespace
> core like the netfilter code does and have one level of indirection
> for everything but the namespace 0?

I believe this should be done in a separated patch if really needed.

Thanks.


Re: [PATCH net v2] r8169:fix "rtl_counters_cond == 1 (loop: 1000, delay: 10)" log spam.

2016-02-22 Thread Francois Romieu
Chunhao Lin  :
[...]
> diff --git a/drivers/net/ethernet/realtek/r8169.c 
> b/drivers/net/ethernet/realtek/r8169.c
> index 537974c..a645f8d 100644
> --- a/drivers/net/ethernet/realtek/r8169.c
> +++ b/drivers/net/ethernet/realtek/r8169.c
> @@ -7730,10 +7730,13 @@ rtl8169_get_stats64(struct net_device *dev, struct 
> rtnl_link_stats64 *stats)
>  {
>   struct rtl8169_private *tp = netdev_priv(dev);
>   void __iomem *ioaddr = tp->mmio_addr;
> + struct pci_dev *pdev = tp->pci_dev;

+   struct device *d = >pci_dev->dev;

(the patch does not use pdev alone)

[...]
> @@ -7761,7 +7764,8 @@ rtl8169_get_stats64(struct net_device *dev, struct 
> rtnl_link_stats64 *stats)
>* Fetch additonal counter values missing in stats collected by driver
>* from tally counters.
>*/
> - rtl8169_update_counters(dev);
> + if (pm_runtime_active(>dev))
> + rtl8169_update_counters(dev);

pm_runtime_active() won't change after pm_runtime_get_noresume(). You may
set a boolean active = pm_runtime_active(d) before testing netif_running().

[...]
> @@ -7842,6 +7848,12 @@ static int rtl8169_runtime_suspend(struct device 
> *device)
>   struct pci_dev *pdev = to_pci_dev(device);
>   struct net_device *dev = pci_get_drvdata(pdev);
>   struct rtl8169_private *tp = netdev_priv(dev);
> + void __iomem *ioaddr = tp->mmio_addr;
> +
> + /* Update counters before going runtime suspend */
> + if (netif_running(dev))
> + rtl8169_rx_missed(dev, ioaddr);
> + rtl8169_update_counters(dev);
>  
>   if (!tp->TxDescArray)
>   return 0;

Nits:

- the tp->TxDescArray test provides the required synchronization: see
  rtl8169_{open/close} and their pm_runtime_{get / put}.

- ioaddr is not really needed : tp->mmio_addr appears only once and it does
  not mess the 72..80 cols limit.

- even if the device can only be automatically runtime suspended some time
  after a link down event, you may address davem's point regarding stats
  reliability and move rtl8169_rx_missed + rtl8169_update_counters after
  rtl8169_net_suspend.

-- 
Ueimor


Re: net: netcp: regarding commit 899077: netcp: try to reduce type confusion in descriptors

2016-02-22 Thread Murali Karicheri
Arnd,

On 02/22/2016 05:13 PM, Arnd Bergmann wrote:
> On Monday 22 February 2016 16:48:14 Murali Karicheri wrote:
>> Arnd,
>>
>> As promised, here is what I found wrong with the commit 899077 that 
>> introduced a 
>> regression. With these changes, I am able to boot kernel without issues on 
>> K2 platforms.
> 
> Thanks so much for looking into this!
> 
>> From the commit description, it appears that you are trying to make the 
>> driver do the right
>> thing if compiled for a 64 bit systems. Is it mandatory for all kernel 
>> drivers to be
>> 64bit compliant? Similar question on supporting mixed endian in all kernel 
>> drivers.
> 
> I would generally expect all device driver code to be written as 
> architecture-independent
> as possible, for multiple reasons:
> 
> * hardware gets reused all the time, we have plenty of drivers that started 
> out on
>   big-endian powerpc32 or mips32 and are now used on 64-bit little-endian 
> arm, so
>   you should not make any assumptions
> 
> * code gets copied into other drivers, so whatever you write should be able 
> to serve
>   as an example to other developers
>

Ok. Got it.
 
>> Keystone can have SoC configured to be in big endian mode for peripherals 
>> and DSP.
> 
> I'm not entirely sure what this means

This means, ARM core can be using LE/BE and rest of the system can be 
configured through a pin
(to SOC) to operate in BE/LE. So need to take care of all mixed endian 
configuration 
properly. Refer to http://www.ti.com/lit/ds/symlink/tci6636k2h.pdf for more 
details if interested.

> 
>> so that is
>> something we need to support if there is customer interest. Wondering why do 
>> one run BE kernel
>> binary on these platforms? Any reason? I saw some reference to that in past 
>> discussion on this
>> regression issue.
> 
> The only real reason to run a big-endian ARM kernel is for compatibility with 
> user space
> that has either is known to not be portable to little-endian, or that has 
> only ever been
> used on big-endian machines and that might have unknown problems.
> 
> This is typically the case for proprietary user space network stacks of the 
> kind you
> find in commercial network infrastructure hardware, but there are a couple of 
> other
> uses in enterprise systems that have source code ported from mainframes.
> 
>> diff --git a/drivers/net/ethernet/ti/netcp_core.c 
>> b/drivers/net/ethernet/ti/netcp_core.c
>> index c61d66d..ac35161 100644
>> --- a/drivers/net/ethernet/ti/netcp_core.c
>> +++ b/drivers/net/ethernet/ti/netcp_core.c
>> @@ -167,7 +167,7 @@ static void set_pad_info(u32 pad0, u32 pad1, u32 pad2, 
>> struct knav_dma_desc *des
>>  {
>> desc->pad[0] = cpu_to_le32(pad0);
>> desc->pad[1] = cpu_to_le32(pad1);
>> -   desc->pad[2] = cpu_to_le32(pad1);
>> +   desc->pad[2] = cpu_to_le32(pad2);
>>  }
> 
> I had found this hunk earlier.
> 
>>  static void set_org_pkt_info(dma_addr_t buff, u32 buff_len,
>> @@ -870,8 +870,8 @@ static int netcp_allocate_rx_buf(struct netcp_intf 
>> *netcp, int fdq)
>> }
>> buf_len = PAGE_SIZE;
>> dma = dma_map_page(netcp->dev, page, 0, buf_len, 
>> DMA_TO_DEVICE);
>> -   pad[0] = lower_32_bits(dma);
>> -   pad[1] = upper_32_bits(dma);
>> +   pad[0] = lower_32_bits((uintptr_t)page);
>> +   pad[1] = upper_32_bits((uintptr_t)page);
>> pad[2] = 0;
>> }
> 
> And this is my stupid mistake that I failed to see.
> 
>> @@ -1194,9 +1194,9 @@ static int netcp_tx_submit_skb(struct netcp_intf 
>> *netcp,
>> }
>>  
>> set_words(, 1, >packet_info);
>> -   tmp = lower_32_bits((uintptr_t));
>> +   tmp = lower_32_bits((uintptr_t)skb);
>> set_words(, 1, >pad[0]);
>> -   tmp = upper_32_bits((uintptr_t));
>> +   tmp = upper_32_bits((uintptr_t)skb);
>> set_words(, 1, >pad[1]);
>>  
>> if (tx_pipe->flags & SWITCH_TO_PORT_IN_TAGINFO) {
> 
> And this is another one of the same sort.
> 
> Not my best patch ever obviously, but at least I understand where I went
> wrong now, and see that it was only me being sloppy in the conversion rather
> than a more fundamental misdesign.
> 

So do you plan to re-spin the patch again with the above change?

Murali

> Thanks,
> 
>   Arnd
> 


-- 
Murali Karicheri
Linux Kernel, Keystone


Re: [patch net-next 1/9] Introduce devlink infrastructure

2016-02-22 Thread roopa
On 2/22/16, 10:31 AM, Jiri Pirko wrote:
> From: Jiri Pirko 
>
> Introduce devlink infrastructure for drivers to register and expose to
> userspace via generic Netlink interface.
>
> There are two basic objects defined:
> devlink - one instance for every "parent device", for example switch ASIC
> devlink port - one instance for every physical port of the device.

Like i have expressed earlier, the only thing that bothers me here is that we 
are creating a new devlink object for switch port when there
is an existing netdev object.

Is there a chance that the drivers you are targeting can still create netdevs 
for physical ports ?
It would make things so much more consistent and simpler to manage without a 
cost of adding yet another interface.

The port splitter support is needed at the netdev api too (ie rtnetlink). Most 
switchdev drivers that expose netdevs
would benefit from a native 'ip link' way to configure port splitting. This 
will be useful for nic drivers too.

thanks,
Roopa



Re: net: netcp: regarding commit 899077: netcp: try to reduce type confusion in descriptors

2016-02-22 Thread Arnd Bergmann
On Monday 22 February 2016 16:48:14 Murali Karicheri wrote:
> Arnd,
> 
> As promised, here is what I found wrong with the commit 899077 that 
> introduced a 
> regression. With these changes, I am able to boot kernel without issues on K2 
> platforms.

Thanks so much for looking into this!

> From the commit description, it appears that you are trying to make the 
> driver do the right
> thing if compiled for a 64 bit systems. Is it mandatory for all kernel 
> drivers to be
> 64bit compliant? Similar question on supporting mixed endian in all kernel 
> drivers.

I would generally expect all device driver code to be written as 
architecture-independent
as possible, for multiple reasons:

* hardware gets reused all the time, we have plenty of drivers that started out 
on
  big-endian powerpc32 or mips32 and are now used on 64-bit little-endian arm, 
so
  you should not make any assumptions

* code gets copied into other drivers, so whatever you write should be able to 
serve
  as an example to other developers

> Keystone can have SoC configured to be in big endian mode for peripherals and 
> DSP.

I'm not entirely sure what this means

> so that is
> something we need to support if there is customer interest. Wondering why do 
> one run BE kernel
> binary on these platforms? Any reason? I saw some reference to that in past 
> discussion on this
> regression issue.

The only real reason to run a big-endian ARM kernel is for compatibility with 
user space
that has either is known to not be portable to little-endian, or that has only 
ever been
used on big-endian machines and that might have unknown problems.

This is typically the case for proprietary user space network stacks of the 
kind you
find in commercial network infrastructure hardware, but there are a couple of 
other
uses in enterprise systems that have source code ported from mainframes.

> diff --git a/drivers/net/ethernet/ti/netcp_core.c 
> b/drivers/net/ethernet/ti/netcp_core.c
> index c61d66d..ac35161 100644
> --- a/drivers/net/ethernet/ti/netcp_core.c
> +++ b/drivers/net/ethernet/ti/netcp_core.c
> @@ -167,7 +167,7 @@ static void set_pad_info(u32 pad0, u32 pad1, u32 pad2, 
> struct knav_dma_desc *des
>  {
> desc->pad[0] = cpu_to_le32(pad0);
> desc->pad[1] = cpu_to_le32(pad1);
> -   desc->pad[2] = cpu_to_le32(pad1);
> +   desc->pad[2] = cpu_to_le32(pad2);
>  }

I had found this hunk earlier.

>  static void set_org_pkt_info(dma_addr_t buff, u32 buff_len,
> @@ -870,8 +870,8 @@ static int netcp_allocate_rx_buf(struct netcp_intf 
> *netcp, int fdq)
> }
> buf_len = PAGE_SIZE;
> dma = dma_map_page(netcp->dev, page, 0, buf_len, 
> DMA_TO_DEVICE);
> -   pad[0] = lower_32_bits(dma);
> -   pad[1] = upper_32_bits(dma);
> +   pad[0] = lower_32_bits((uintptr_t)page);
> +   pad[1] = upper_32_bits((uintptr_t)page);
> pad[2] = 0;
> }

And this is my stupid mistake that I failed to see.

> @@ -1194,9 +1194,9 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
> }
>  
> set_words(, 1, >packet_info);
> -   tmp = lower_32_bits((uintptr_t));
> +   tmp = lower_32_bits((uintptr_t)skb);
> set_words(, 1, >pad[0]);
> -   tmp = upper_32_bits((uintptr_t));
> +   tmp = upper_32_bits((uintptr_t)skb);
> set_words(, 1, >pad[1]);
>  
> if (tx_pipe->flags & SWITCH_TO_PORT_IN_TAGINFO) {

And this is another one of the same sort.

Not my best patch ever obviously, but at least I understand where I went
wrong now, and see that it was only me being sloppy in the conversion rather
than a more fundamental misdesign.

Thanks,

Arnd


Re: [PATCH 1/4] net: ethernet: dwmac: add Ethernet glue logic for stm32 chip

2016-02-22 Thread Joachim Eastwood
On 22 February 2016 at 15:50, Alexandre Torgue
 wrote:
> 2016-02-13 14:48 GMT+01:00 Joachim  Eastwood :
>> On 3 February 2016 at 15:54, Alexandre TORGUE
>>  wrote:
>>> +   plat_dat->bsp_priv = dwmac;
>>> +   plat_dat->init = stm32_dwmac_init;
>>> +   plat_dat->exit = stm32_dwmac_exit;
>>
>> Instead of using these callbacks could you rather implement the PM
>> callbacks directly in this driver?
>> I don't think it should add much code and it will make it look more
>> like standard driver. This will also give you some more control and
>> flexibility in your code.
>
> I prefer to keep the code as it is. Glue layer is directly linked to
> stmmac driver and I don't want to brake the link between the glue and
> the stmmac driver.

What do you mean by break the link?

There has been numerous of patch sets to make the stmmac "glue"
drivers into more standard platform drivers.
http://marc.info/?l=linux-netdev=143159850631093=2
http://marc.info/?l=linux-netdev=143708560009851=2
http://marc.info/?l=linux-netdev=143812136600541=2

Do you see any advantage by using the init and exit hooks in your
driver instead of using the standard driver PM callbacks and remove
function?
The only "cost" I see is slightly more boilerplate code. But since you
already have init/exit functions you could easily make them into PM
resume/suspend so I doubt there would be much increase in code size.

One other thing;
Do you need to have the PHY mode setup code in the init function which
is called each time on resume?
If you could move it to probe you could drop the interface priv data
member and use plat_dat->interface as stmmac_probe_config_dt() has
already done of_get_phy_mode().


regards,
Joachim Eastwood


[PATCH net-next] bgmac: support Ethernet device on BCM47094 SoC

2016-02-22 Thread Rafał Miłecki
It needs very similar workarounds to the one on BCM4707. It was tested
on D-Link DIR-885L home router.

Signed-off-by: Rafał Miłecki 
---
It's the same patch as last time, just with a proper prefix ("net-next")
---
 drivers/net/ethernet/broadcom/bgmac.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
b/drivers/net/ethernet/broadcom/bgmac.c
index 230f8e6..99b30a9 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -30,6 +30,7 @@ static inline bool bgmac_is_bcm4707_family(struct bgmac 
*bgmac)
 {
switch (bgmac->core->bus->chipinfo.id) {
case BCMA_CHIP_ID_BCM4707:
+   case BCMA_CHIP_ID_BCM47094:
case BCMA_CHIP_ID_BCM53018:
return true;
default:
@@ -1052,8 +1053,9 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
(ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == 
BCMA_PKG_ID_BCM47188))
iost &= ~BGMAC_BCMA_IOST_ATTACHED;
 
-   /* 3GMAC: for BCM4707, only do core reset at bgmac_probe() */
-   if (ci->id != BCMA_CHIP_ID_BCM4707) {
+   /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */
+   if (ci->id != BCMA_CHIP_ID_BCM4707 &&
+   ci->id != BCMA_CHIP_ID_BCM47094) {
flags = 0;
if (iost & BGMAC_BCMA_IOST_ATTACHED) {
flags = BGMAC_BCMA_IOCTL_SW_CLKEN;
-- 
1.8.4.5



net: netcp: regarding commit 899077: netcp: try to reduce type confusion in descriptors

2016-02-22 Thread Murali Karicheri
Arnd,

As promised, here is what I found wrong with the commit 899077 that introduced 
a 
regression. With these changes, I am able to boot kernel without issues on K2 
platforms.

>From the commit description, it appears that you are trying to make the driver 
>do the right
thing if compiled for a 64 bit systems. Is it mandatory for all kernel drivers 
to be
64bit compliant? Similar question on supporting mixed endian in all kernel 
drivers.
Keystone can have SoC configured to be in big endian mode for peripherals and 
DSP. so that is
something we need to support if there is customer interest. Wondering why do 
one run BE kernel
binary on these platforms? Any reason? I saw some reference to that in past 
discussion on this
regression issue.

Murali


diff --git a/drivers/net/ethernet/ti/netcp_core.c 
b/drivers/net/ethernet/ti/netcp_core.c
index c61d66d..ac35161 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -167,7 +167,7 @@ static void set_pad_info(u32 pad0, u32 pad1, u32 pad2, 
struct knav_dma_desc *des
 {
desc->pad[0] = cpu_to_le32(pad0);
desc->pad[1] = cpu_to_le32(pad1);
-   desc->pad[2] = cpu_to_le32(pad1);
+   desc->pad[2] = cpu_to_le32(pad2);
 }
 
 static void set_org_pkt_info(dma_addr_t buff, u32 buff_len,
@@ -870,8 +870,8 @@ static int netcp_allocate_rx_buf(struct netcp_intf *netcp, 
int fdq)
}
buf_len = PAGE_SIZE;
dma = dma_map_page(netcp->dev, page, 0, buf_len, DMA_TO_DEVICE);
-   pad[0] = lower_32_bits(dma);
-   pad[1] = upper_32_bits(dma);
+   pad[0] = lower_32_bits((uintptr_t)page);
+   pad[1] = upper_32_bits((uintptr_t)page);
pad[2] = 0;
}
 
@@ -1194,9 +1194,9 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
}
 
set_words(, 1, >packet_info);
-   tmp = lower_32_bits((uintptr_t));
+   tmp = lower_32_bits((uintptr_t)skb);
set_words(, 1, >pad[0]);
-   tmp = upper_32_bits((uintptr_t));
+   tmp = upper_32_bits((uintptr_t)skb);
set_words(, 1, >pad[1]);
 
if (tx_pipe->flags & SWITCH_TO_PORT_IN_TAGINFO) {

-- 
Murali Karicheri
Linux Kernel, Keystone


Re: [patch net-next 6/9] mlxsw: spectrum: Unmap local port from module during teardown

2016-02-22 Thread Ido Schimmel
Hi John,

Mon, Feb 22, 2016 at 10:32:47PM IST, john.fastab...@gmail.com wrote:
>On 16-02-22 10:32 AM, Jiri Pirko wrote:
>> From: Ido Schimmel 
>> 
>> When splitting a port we replace it with 2 or 4 other ports. To be able
>> to do that we need to remove the original port netdev and unmap it from
>> its module. However, we first mark it as disabled, as active ports
>> cannot be unmapped.
>> 
>> Signed-off-by: Ido Schimmel 
>> Signed-off-by: Jiri Pirko 
>> ---
>
>Hi Jiri, Ido,
>
>You've sort of lost me on this port splitting/unsplitting thread. What
>does this actually do? Are you just creating two netdevs and LAGing them
>in the hardware, I'm guessing not or you wouldn't have some device API
>for it and would do it using normal methods.

Yep, it's not LAG. You basically have a mapping between a physical
module and a local port, which is represented by a port netdev.

Each module has 4 lanes, so if you connect a splitter (say a 2x) you can
map each 2 lanes to a different port and assign each a new local port.
These are completely independent from each other, but they can only give
you 50Gb/s max, as opposed to the original 100Gb/s (as it had 4 lanes
all to itself).

>
>If its something to do with physical layout of the board itself why
>don't you trigger this based on some init time introspection or an
>interrupt if someone plugs in a port splitting cable/module (does that
>exist?).

We currently don't have an event that tells us that a splitter is
connected. Also, had we created / destroyed these based on events, then
an accidental removal of the splitter would cause all the configuration
setup on these ports to disappear (say VLANs on a bridged port, unicast
flooding etc.).

Thanks.

>
>Thanks,
>John
>
>


Re: [patch net-next 6/9] mlxsw: spectrum: Unmap local port from module during teardown

2016-02-22 Thread John Fastabend
On 16-02-22 01:00 PM, Ido Schimmel wrote:
> Hi John,
> 
> Mon, Feb 22, 2016 at 10:32:47PM IST, john.fastab...@gmail.com wrote:
>> On 16-02-22 10:32 AM, Jiri Pirko wrote:
>>> From: Ido Schimmel 
>>>
>>> When splitting a port we replace it with 2 or 4 other ports. To be able
>>> to do that we need to remove the original port netdev and unmap it from
>>> its module. However, we first mark it as disabled, as active ports
>>> cannot be unmapped.
>>>
>>> Signed-off-by: Ido Schimmel 
>>> Signed-off-by: Jiri Pirko 
>>> ---
>>
>> Hi Jiri, Ido,
>>
>> You've sort of lost me on this port splitting/unsplitting thread. What
>> does this actually do? Are you just creating two netdevs and LAGing them
>> in the hardware, I'm guessing not or you wouldn't have some device API
>> for it and would do it using normal methods.
> 
> Yep, it's not LAG. You basically have a mapping between a physical
> module and a local port, which is represented by a port netdev.
> 
> Each module has 4 lanes, so if you connect a splitter (say a 2x) you can
> map each 2 lanes to a different port and assign each a new local port.
> These are completely independent from each other, but they can only give
> you 50Gb/s max, as opposed to the original 100Gb/s (as it had 4 lanes
> all to itself).
> 
>>
>> If its something to do with physical layout of the board itself why
>> don't you trigger this based on some init time introspection or an
>> interrupt if someone plugs in a port splitting cable/module (does that
>> exist?).
> 
> We currently don't have an event that tells us that a splitter is
> connected. Also, had we created / destroyed these based on events, then
> an accidental removal of the splitter would cause all the configuration
> setup on these ports to disappear (say VLANs on a bridged port, unicast
> flooding etc.).
> 

I still think this would be the better implementation. The configuration
should be saved in some daemon anyways and setup based on netdev events
so its not like it would disappear in any real system.

But seeing you don't get an interrupt or anything I guess manual
configuration is going to be the best you can do.


> Thanks.
> 
>>
>> Thanks,
>> John
>>
>>



Re: [PATCH] codel: cast the output of MS2TIME to codel_time_t

2016-02-22 Thread Emmanuel Grumbach
On Mon, Feb 22, 2016 at 9:53 PM, David Miller  wrote:
> From: Emmanuel Grumbach 
> Date: Mon, 22 Feb 2016 13:49:47 +0200
>
>> This will allow to pass the typecheck in the comparators:
>> codel_time_{after,before}
>>
>> Signed-off-by: Emmanuel Grumbach 
>
> I do not see any existing code where this would matter.  Maybe it was
> not meant to be fed directly?  And if you need to you should add the
> explicit casts yourself.

Well.. This header file is kinda special. As Eric pointed out, I
shouldn't include it since it contains huge inline functions. I only
really need small parts of it for iwlwifi and I copied those into the
driver. In iwlwifi I do need to feed MS2TIME output into the
comparators so I guess I'll do that there. I just thought it'd be nice
to feed this change back in the original implementation of the code.
If another user of the small helpers in this file comes up, it may
make sense to split this file into two header files: one that can be
included, and another one which can't. If that were to happen, I'd be
glad to have this patch in. We're not there yet.

Bottom line, I am perfectly fine if you don't apply this.

>
> I'm not applying this, sorry.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [net-next PATCH 5/5] Support to encoding decoding skb queue map on IFE action

2016-02-22 Thread John Fastabend
On 16-02-22 05:21 AM, Jamal Hadi Salim wrote:
> From: Jamal Hadi Salim 
> 
> hard code static value of 10 for qmap
> mark of 12
> prio of 13
> and hashid of 11
> 
> sudo tc filter add dev $ETH parent 1: protocol ip prio 10 \
> u32 match ip protocol 1 0xff flowid 1:2 \
> action ife encode \
> type 0xDEAD \
> use mark 12 \
> use prio 13 \
> use hashid 11 \
> use qmap 10 \
> dst 02:15:15:15:15:15
> 
> Note: as of the time of submission skbedit of queue map doesnt work
> (just in case you try to use it)
> 
> Signed-off-by: Jamal Hadi Salim 
> ---

Well the skbedit queue_mapping action does work I'm just guessing it
is not working as you expect? We probably haven't done a good job
explaining how to set it up.

If you set it on the clsact egress filter chain for example it will
map traffic to a queue if you disable XPS and get sk_tx_queue() to
return -1. This is because XPS and socket mappings have a higher
precedence in queue selection.

Anyways just tested on net-next and it works, the following
puts ip traffic with src 15.0.0.1 on hardware queue 6,

./tc/tc qdisc add dev eth4 clsact
./tc/tc filter add dev eth4 egress protocol ip \
 u32 ht 800: order 1 \
 match ip src 15.0.0.1/32 \
action skbedit queue_mapping 6

Thanks,
.John



Re: [PATCH] netcp: fix typo in netcp_setup_tc

2016-02-22 Thread David Miller
From: Arnd Bergmann 
Date: Mon, 22 Feb 2016 21:50:39 +0100

> A change to the prototype of netcp_setup_tc() missed a '*'
> character, which broke compilation of hte netcp driver:
> 
> drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_setup_tc':
> drivers/net/ethernet/ti/netcp_core.c:1839:31: error: invalid type argument of 
> '->' (have 'struct tc_to_netdev')
> drivers/net/ethernet/ti/netcp_core.c:1872:19: error: initialization from 
> incompatible pointer type [-Werror=incompatible-pointer-types]
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: 16e5cc647173 ("net: rework setup_tc ndo op to consume general tc 
> operand")

Should be fixed in my net-next tree already.

Thanks.


[PATCH] netcp: fix typo in netcp_setup_tc

2016-02-22 Thread Arnd Bergmann
A change to the prototype of netcp_setup_tc() missed a '*'
character, which broke compilation of hte netcp driver:

drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_setup_tc':
drivers/net/ethernet/ti/netcp_core.c:1839:31: error: invalid type argument of 
'->' (have 'struct tc_to_netdev')
drivers/net/ethernet/ti/netcp_core.c:1872:19: error: initialization from 
incompatible pointer type [-Werror=incompatible-pointer-types]

Signed-off-by: Arnd Bergmann 
Fixes: 16e5cc647173 ("net: rework setup_tc ndo op to consume general tc 
operand")
---
 drivers/net/ethernet/ti/netcp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/netcp_core.c 
b/drivers/net/ethernet/ti/netcp_core.c
index 132caebb401a..e74e68eabd5f 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -1829,7 +1829,7 @@ static u16 netcp_select_queue(struct net_device *dev, 
struct sk_buff *skb,
 }
 
 static int netcp_setup_tc(struct net_device *dev, u32 handle, __be16 proto,
- struct tc_to_netdev tc)
+ struct tc_to_netdev *tc)
 {
int i;
 
-- 
2.7.0



[PATCH net 5/5] ppp: protect ppp->npmode

2016-02-22 Thread Guillaume Nault
ppp->npmode is read by ppp_ioctl(), ppp_receive_nonmp_frame() and
ppp_start_xmit(). But it is only modified by ppp_ioctl().
However, the only protected access is done by ppp_receive_nonmp_frame()
which runs under ppp_recv_lock() protection.

We could protect ppp->npmode with ppp_recv_lock() in ppp_start_xmit()
too, but taking the recv lock in the xmit path would look strange. So
this patch takes the xmit lock instead and holds both locks before
writing in ppp_ioctl().

Signed-off-by: Guillaume Nault 
---
 drivers/net/ppp/ppp_generic.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 24777f4..2eb39cd 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -767,11 +767,18 @@ static long ppp_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
i = err;
if (cmd == PPPIOCGNPMODE) {
err = -EFAULT;
+
+   ppp_lock(ppp);
npi.mode = ppp->npmode[i];
+   ppp_unlock(ppp);
+
if (copy_to_user(argp, , sizeof(npi)))
break;
} else {
+   ppp_lock(ppp);
ppp->npmode[i] = npi.mode;
+   ppp_unlock(ppp);
+
/* we may be able to transmit more packets now (??) */
netif_wake_queue(ppp->dev);
}
@@ -1023,13 +1030,18 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device 
*dev)
struct ppp *ppp = netdev_priv(dev);
int npi, proto;
unsigned char *pp;
+   enum NPmode npmode;
 
npi = ethertype_to_npindex(ntohs(skb->protocol));
if (npi < 0)
goto outf;
 
+   ppp_xmit_lock(ppp);
+   npmode = ppp->npmode[npi];
+   ppp_xmit_unlock(ppp);
+
/* Drop, accept or reject the packet */
-   switch (ppp->npmode[npi]) {
+   switch (npmode) {
case NPMODE_PASS:
break;
case NPMODE_QUEUE:
-- 
2.7.0



[PATCH net 1/5] ppp: lock ppp structure before modifying mru in ppp_ioctl()

2016-02-22 Thread Guillaume Nault
PPP's Tx and Rx paths read ppp->mru under protection of ppp_xmit_lock()
and ppp_recv_lock() respectively.
Therefore ppp_ioctl() must hold the xmit and recv locks before
concurrently updating ppp->mru.

Signed-off-by: Guillaume Nault 
---
 drivers/net/ppp/ppp_generic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index fc8ad00..4d342ae 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -654,7 +654,10 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
case PPPIOCSMRU:
if (get_user(val, p))
break;
+   ppp_lock(ppp);
ppp->mru = val;
+   ppp_unlock(ppp);
+
err = 0;
break;
 
-- 
2.7.0



[PATCH net 4/5] ppp: protect access to ppp->last_{xmit,recv} in ppp_ioctl()

2016-02-22 Thread Guillaume Nault
ppp->last_xmit is witten to by ppp_send_frame() while protected by
ppp_xmit_lock().
Likewise, ppp->last_recv is written to by ppp_receive_nonmp_frame()
while protected by ppp_recv_lock().

Holding both locks is therefore necessary before ppp_ioctl() can safely
read these fields.

Signed-off-by: Guillaume Nault 
---
 drivers/net/ppp/ppp_generic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 183d89c..24777f4 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -726,8 +726,11 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
break;
 
case PPPIOCGIDLE:
+   ppp_lock(ppp);
idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
+   ppp_unlock(ppp);
+
if (copy_to_user(argp, , sizeof(idle)))
break;
err = 0;
-- 
2.7.0



[PATCH net 2/5] ppp: fix unprotected accesses to ppp->flags and ppp->n_channels

2016-02-22 Thread Guillaume Nault
Reading ppp->flags has to be done under protection of ppp_recv_lock()
or ppp_xmit_lock() (for Rx and Tx paths respectively). Therefore, both
locks have to be held before writing.

This patch adds missing locking in ppp_read(), ppp_poll() and
ppp_ioctl(). As a side effect, it fixes unprotected access to
ppp->n_channels in ppp_read() and ppp_poll(), which has the same
locking requirements as ppp->flags.

Signed-off-by: Guillaume Nault 
---
 drivers/net/ppp/ppp_generic.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 4d342ae..4af548b 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -443,9 +443,14 @@ static ssize_t ppp_read(struct file *file, char __user 
*buf,
 * network traffic (demand mode).
 */
struct ppp *ppp = PF_TO_PPP(pf);
+
+   ppp_recv_lock(ppp);
if (ppp->n_channels == 0 &&
-   (ppp->flags & SC_LOOP_TRAFFIC) == 0)
+   (ppp->flags & SC_LOOP_TRAFFIC) == 0) {
+   ppp_recv_unlock(ppp);
break;
+   }
+   ppp_recv_unlock(ppp);
}
ret = -EAGAIN;
if (file->f_flags & O_NONBLOCK)
@@ -532,9 +537,12 @@ static unsigned int ppp_poll(struct file *file, poll_table 
*wait)
else if (pf->kind == INTERFACE) {
/* see comment in ppp_read */
struct ppp *ppp = PF_TO_PPP(pf);
+
+   ppp_recv_lock(ppp);
if (ppp->n_channels == 0 &&
(ppp->flags & SC_LOOP_TRAFFIC) == 0)
mask |= POLLIN | POLLRDNORM;
+   ppp_recv_unlock(ppp);
}
 
return mask;
@@ -678,7 +686,10 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
break;
 
case PPPIOCGFLAGS:
+   ppp_lock(ppp);
val = ppp->flags | ppp->xstate | ppp->rstate;
+   ppp_unlock(ppp);
+
if (put_user(val, p))
break;
err = 0;
-- 
2.7.0



[PATCH net 0/5] ppp: fix locking issues related to ppp_ioctl()

2016-02-22 Thread Guillaume Nault
This series fixes unprotected accesses to several struct ppp fields.
Only fields used in ppp_ioctl() have been considered, though.

Locking of the xstate and rstate fields remains incomplete: although a
side effect of patch #2 provides protection in ppp_ioctl(), xstate and
rstate can still be modified without appropriate locking by
ppp_ccp_peek(). Taking the missing locks in ppp_ccp_peek() isn't
possible as this would lead to lock inversion (when protecting xstate
with ppp_xmit_lock() while ppp_ccp_peek() is called in the Rx path).

Using a workqueue to run ppp_ccp_peek() might be a solution, but this
is left for another series.

Guillaume Nault (5):
  ppp: lock ppp structure before modifying mru in ppp_ioctl()
  ppp: fix unprotected accesses to ppp->flags and ppp->n_channels
  ppp: protect ppp->debug in ppp_ioctl()
  ppp: protect access to ppp->last{xmit,recv} in ppp_ioctl()
  ppp: protect ppp->npmode

 drivers/net/ppp/ppp_generic.c | 42 +++---
 1 file changed, 39 insertions(+), 3 deletions(-)

-- 
2.7.0



[PATCH net 3/5] ppp: protect ppp->debug in ppp_ioctl()

2016-02-22 Thread Guillaume Nault
ppp->debug is read in the Tx and Rx paths while under protection of
ppp_xmit_lock() and ppp_recv_lock() respectively.
So ppp_ioctl() must hold both locks before concurrently updating it.

Signed-off-by: Guillaume Nault 
---
Locking is not strictly necessary for PPPIOCGDEBUG, because ppp->debug
can only be modified by ioctl(PPPIOCSDEBUG) which is guaranteed not to
run concurrently thanks to ppp_mutex. I've added the locking in
PPPIOCGDEBUG in order to respect the general locking semantic of
ppp->debug and to avoid relying on ppp_mutex.

 drivers/net/ppp/ppp_generic.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 4af548b..183d89c 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -708,12 +708,19 @@ static long ppp_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
case PPPIOCSDEBUG:
if (get_user(val, p))
break;
+   ppp_lock(ppp);
ppp->debug = val;
+   ppp_unlock(ppp);
+
err = 0;
break;
 
case PPPIOCGDEBUG:
-   if (put_user(ppp->debug, p))
+   ppp_lock(ppp);
+   val = ppp->debug;
+   ppp_unlock(ppp);
+
+   if (put_user(val, p))
break;
err = 0;
break;
-- 
2.7.0



Re: [patch net-next 6/9] mlxsw: spectrum: Unmap local port from module during teardown

2016-02-22 Thread John Fastabend
On 16-02-22 10:32 AM, Jiri Pirko wrote:
> From: Ido Schimmel 
> 
> When splitting a port we replace it with 2 or 4 other ports. To be able
> to do that we need to remove the original port netdev and unmap it from
> its module. However, we first mark it as disabled, as active ports
> cannot be unmapped.
> 
> Signed-off-by: Ido Schimmel 
> Signed-off-by: Jiri Pirko 
> ---

Hi Jiri, Ido,

You've sort of lost me on this port splitting/unsplitting thread. What
does this actually do? Are you just creating two netdevs and LAGing them
in the hardware, I'm guessing not or you wouldn't have some device API
for it and would do it using normal methods.

If its something to do with physical layout of the board itself why
don't you trigger this based on some init time introspection or an
interrupt if someone plugs in a port splitting cable/module (does that
exist?).

Thanks,
John




RE: [PATCH V2 net-next 2/3] lan78xx: add ethtool set & get pause functions

2016-02-22 Thread Woojung.Huh
> -Original Message-
> From: Ben Hutchings [mailto:b...@decadent.org.uk]
> Sent: Monday, February 22, 2016 3:05 PM
> To: David Miller; Woojung Huh - C21699
> Cc: netdev@vger.kernel.org
> Subject: Re: [PATCH V2 net-next 2/3] lan78xx: add ethtool set & get pause
> functions
> 
> On Mon, 2016-02-22 at 14:10 -0500, David Miller wrote:
> > From: 
> > Date: Mon, 22 Feb 2016 18:28:18 +
> >
> > >> This is incorrect; you should always return the manual settings
> > >> (fc_request_control flags) here.  If autonegotiation is enabled then
> > >> your get_settings function will return the actual pause flags.
> > >>
> > > What do you mean "return actual pause flags" when autoneg is enabled?
> > > Pause flags set by (or default) advertise flag?
> >
> > It means what was negotiated by autonegotiation, and is actually in use.
> >
> > Otherwise, how can the user find out what was negotiated?
> 
> Well, actually we don't *directly* report the autonegotiation flow
> control mode at present.  We report which pause flags were advertised
> and what the link partner advertised, from which you can work it out.

NIC advertises pause flags via advertise register (phy reg 0x4) based on Rx & 
Tx flags,
and get_pauseparam() returns Rx & Tx flags set by set_pauseparm() if 
autonegotiation is enabled?

> Perhaps ethtool (the utility) should explicitly show what the result
> is.
Ethtool -a reports Rx/Tx flags and Rx/Tx negotiated flag based on advertising 
and lp_advertising value.


Re: [PATCH][V2] rtlwifi: pass struct rtl_stats by reference as it is more efficient

2016-02-22 Thread Larry Finger

On 02/22/2016 05:35 AM, Colin King wrote:

From: Colin Ian King 

passing rtl_stats by value is inefficient; the structure is over 300
bytes in size and generally just one field (packet_report_type)
is being accessed, so the pass by value is a relatively large overhead.
This change just affects just the rx_command_packet calls.

Signed-off-by: Colin Ian King 


Looks good and tests OK with rtl8723be.

Acked-by: Larry Finger 

Thanks,

Larry


---
  drivers/net/wireless/realtek/rtlwifi/pci.c   | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c | 6 +++---
  drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.c | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8723ae/trx.h | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.c | 4 ++--
  drivers/net/wireless/realtek/rtlwifi/rtl8723be/trx.h | 2 +-
  drivers/net/wireless/realtek/rtlwifi/rtl8821ae/trx.c | 4 ++--
  drivers/net/wireless/realtek/rtlwifi/rtl8821ae/trx.h | 2 +-
  drivers/net/wireless/realtek/rtlwifi/wifi.h  | 2 +-
  12 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c 
b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 7f471bf..4153e7f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -855,7 +855,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
}
/* handle command packet here */
if (rtlpriv->cfg->ops->rx_command_packet &&
-   rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
+   rtlpriv->cfg->ops->rx_command_packet(hw, , skb)) {
dev_kfree_skb_any(skb);
goto new_trx_end;
}
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c
index 791efbe..1170106 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c
@@ -851,7 +851,7 @@ void rtl88ee_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue)
  }

  u32 rtl88ee_rx_command_packet(struct ieee80211_hw *hw,
- struct rtl_stats status,
+ const struct rtl_stats *status,
  struct sk_buff *skb)
  {
return 0;
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h
index eab5ae0..5a24d19 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h
@@ -790,7 +790,7 @@ void rtl88ee_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 
*pdesc,
 bool firstseg, bool lastseg,
 struct sk_buff *skb);
  u32 rtl88ee_rx_command_packet(struct ieee80211_hw *hw,
- struct rtl_stats status,
+ const struct rtl_stats *status,
  struct sk_buff *skb);

  #endif
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
index d39ee67..24eff8e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
@@ -1105,13 +1105,13 @@ void rtl92ee_tx_polling(struct ieee80211_hw *hw, u8 
hw_queue)
  }

  u32 rtl92ee_rx_command_packet(struct ieee80211_hw *hw,
- struct rtl_stats status,
+ const struct rtl_stats *status,
  struct sk_buff *skb)
  {
u32 result = 0;
struct rtl_priv *rtlpriv = rtl_priv(hw);

-   switch (status.packet_report_type) {
+   switch (status->packet_report_type) {
case NORMAL_RX:
result = 0;
break;
@@ -1121,7 +1121,7 @@ u32 rtl92ee_rx_command_packet(struct ieee80211_hw *hw,
break;
default:
RT_TRACE(rtlpriv, COMP_RECV, DBG_TRACE,
-"Unknown packet type %d\n", status.packet_report_type);
+"Unknown packet type %d\n", 
status->packet_report_type);
break;
}

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h
index 8f78ac9..a4c3834 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.h
@@ -857,6 +857,6 @@ void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 
*pdesc,
 bool firstseg, bool lastseg,
 

Re: [PATCH V2 net-next 2/3] lan78xx: add ethtool set & get pause functions

2016-02-22 Thread Ben Hutchings
On Mon, 2016-02-22 at 14:10 -0500, David Miller wrote:
> From: 
> Date: Mon, 22 Feb 2016 18:28:18 +
> 
> >> This is incorrect; you should always return the manual settings
> >> (fc_request_control flags) here.  If autonegotiation is enabled then
> >> your get_settings function will return the actual pause flags.
> >> 
> > What do you mean "return actual pause flags" when autoneg is enabled?
> > Pause flags set by (or default) advertise flag?
> 
> It means what was negotiated by autonegotiation, and is actually in use.
> 
> Otherwise, how can the user find out what was negotiated?

Well, actually we don't *directly* report the autonegotiation flow
control mode at present.  We report which pause flags were advertised
and what the link partner advertised, from which you can work it out.

Perhaps ethtool (the utility) should explicitly show what the result
is.

Ben.

-- 
Ben Hutchings
The generation of random numbers is too important to be left to chance.
- Robert Coveyou

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


Re: [PATCH] codel: cast the output of MS2TIME to codel_time_t

2016-02-22 Thread David Miller
From: Emmanuel Grumbach 
Date: Mon, 22 Feb 2016 13:49:47 +0200

> This will allow to pass the typecheck in the comparators:
> codel_time_{after,before}
> 
> Signed-off-by: Emmanuel Grumbach 

I do not see any existing code where this would matter.  Maybe it was
not meant to be fed directly?  And if you need to you should add the
explicit casts yourself.

I'm not applying this, sorry.



Re: [PATCHv2 00/10] RFKill airplane-mode indicator

2016-02-22 Thread João Paulo Rechi Vita
On 22 February 2016 at 12:00, Dan Williams  wrote:
> On Mon, 2016-02-22 at 11:36 -0500, João Paulo Rechi Vita wrote:
>> This series implements an airplane-mode indicator LED trigger, which
>> can be
>> used by platform drivers. The default policy have have airplane-mode
>> set when
>> all the radios known by RFKill are OFF, and unset otherwise. This
>> policy can be
>> overwritten by one single userspace application at a time using the
>> operations
>> _AIRPLANE_MODE_INDICATOR_ACQUIRE and _AIRPLANE_MODE_INDICATOR_CHANGE.
>>
> Double-check your commit messages on some of these patches; they didn't
> get updated to add INDICATOR.
>

Thanks for catching this, Dan. I've sent an updated version fixing
this problem in reply to the patch where this slept through (9/10).

--
João Paulo Rechi Vita
http://about.me/jprvita


[PATCHv3] rfkill: Userspace control for airplane mode

2016-02-22 Thread João Paulo Rechi Vita
Provide an interface for the airplane-mode indicator be controlled from
userspace. User has to first acquire the control through
RFKILL_OP_AIRPLANE_MODE_INDICATOR_ACQUIRE and keep the fd open for the
whole time it wants to be in control of the indicator. Closing the fd
restores the default policy.

To change state of the indicator, the
RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE operation is used, passing the
value on "struct rfkill_event.soft". If the caller has not acquired the
airplane-mode control beforehand, the operation fails.

Signed-off-by: João Paulo Rechi Vita 
---
 Documentation/rfkill.txt| 10 ++
 include/uapi/linux/rfkill.h |  6 ++
 net/rfkill/core.c   | 35 +--
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index b13025a..9dbe3fc 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -87,6 +87,7 @@ RFKill provides per-switch LED triggers, which can be used to 
drive LEDs
 according to the switch state (LED_FULL when blocked, LED_OFF otherwise).
 An airplane-mode indicator LED trigger is also available, which triggers
 LED_FULL when all radios known by RFKill are blocked, and LED_OFF otherwise.
+The airplane-mode indicator LED trigger policy can be overridden by userspace.
 
 
 5. Userspace support
@@ -123,5 +124,14 @@ RFKILL_TYPE
 The contents of these variables corresponds to the "name", "state" and
 "type" sysfs files explained above.
 
+Userspace can also override the default airplane-mode indicator policy through
+/dev/rfkill. Control of the airplane mode indicator has to be acquired first,
+using RFKILL_OP_AIRPLANE_MODE_INDICATOR_ACQUIRE, and is only available for one
+userspace application at a time. Closing the fd reverts the airplane-mode
+indicator back to the default kernel policy and makes it available for other
+applications to take control. Changes to the airplane-mode indicator state can
+be made using RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE, passing the new value
+in the 'soft' field of 'struct rfkill_event'.
+
 
 For further details consult Documentation/ABI/stable/sysfs-class-rfkill.
diff --git a/include/uapi/linux/rfkill.h b/include/uapi/linux/rfkill.h
index 2e00dce..36e0770 100644
--- a/include/uapi/linux/rfkill.h
+++ b/include/uapi/linux/rfkill.h
@@ -61,12 +61,18 @@ enum rfkill_type {
  * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
  * into a state, also updating the default state used for devices that
  * are hot-plugged later.
+ * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_ACQUIRE: userspace acquires control of
+ * the airplane-mode indicator.
+ * @RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE: userspace changes the
+ * airplane-mode indicator state.
  */
 enum rfkill_operation {
RFKILL_OP_ADD = 0,
RFKILL_OP_DEL,
RFKILL_OP_CHANGE,
RFKILL_OP_CHANGE_ALL,
+   RFKILL_OP_AIRPLANE_MODE_INDICATOR_ACQUIRE,
+   RFKILL_OP_AIRPLANE_MODE_INDICATOR_CHANGE,
 };
 
 /**
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 04d7fa1..8ea8b73 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -89,6 +89,7 @@ struct rfkill_data {
struct mutexmtx;
wait_queue_head_t   read_wait;
boolinput_handler;
+   boolis_apm_owner;
 };
 
 
@@ -123,7 +124,7 @@ static struct {
 } rfkill_global_states[NUM_RFKILL_TYPES];
 
 static bool rfkill_epo_lock_active;
-
+static bool rfkill_apm_owned;
 
 #ifdef CONFIG_RFKILL_LEDS
 static struct led_trigger rfkill_apm_led_trigger;
@@ -350,7 +351,8 @@ static void rfkill_update_global_state(enum rfkill_type 
type, bool blocked)
 
for (i = 0; i < NUM_RFKILL_TYPES; i++)
rfkill_global_states[i].cur = blocked;
-   rfkill_apm_led_trigger_event(blocked);
+   if (!rfkill_apm_owned)
+   rfkill_apm_led_trigger_event(blocked);
 }
 
 #ifdef CONFIG_RFKILL_INPUT
@@ -1180,9 +1182,23 @@ static ssize_t rfkill_fop_read(struct file *file, char 
__user *buf,
return ret;
 }
 
+static int rfkill_airplane_mode_release(struct rfkill_data *data)
+{
+   bool state = rfkill_global_states[RFKILL_TYPE_ALL].cur;
+
+   if (rfkill_apm_owned && data->is_apm_owner) {
+   rfkill_apm_owned = false;
+   data->is_apm_owner = false;
+   rfkill_apm_led_trigger_event(state);
+   return 0;
+   }
+   return -EACCES;
+}
+
 static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
 {
+   struct rfkill_data *data = file->private_data;
struct rfkill *rfkill;
struct rfkill_event ev;
int ret = 0;
@@ -1218,6 +1234,20 @@ static ssize_t rfkill_fop_write(struct file *file, const 
char __user *buf,
if (rfkill->idx == ev.idx && rfkill->type == ev.type)

Re: IPv6 route to gateway on fe80::1%eth0 when I have fe80::1%br0 locally

2016-02-22 Thread Marc Haber
On Mon, Feb 22, 2016 at 05:15:41PM +0100, Hannes Frederic Sowa wrote:
> On 22.02.2016 16:47, Marc Haber wrote:
> >Can you reproduce the behavior with accept_ra_from_local =0 as well?
> >Unfortunately, the debugging VM I build works fine, it's just the
> >physical host showing this behavior. This is really strange.
> 
> Same here. Debugging VM didn't show this error at all and other systems
> didn't show this symptom either (4.4.2 as well as net-next).
> 
> With which kernel did you see this behavior for the first time and what was
> the last working version?

Thanks for motivating me to investigate this further.

I have to apologize. It is not a kernel issue.

It has turned out that systemd, starting with version 229, has placed
a "Not invented here" stamp on route advertisement processing in the
kernel and has implemented its own userspace code to handle router
advertisements.

And, of course, they did it wrong.

Setting IPv6AcceptRouterAdvertisements=0 in eth0.network seems to
disable enough code that this issue does not show any more.

Sorry for the rumble, I debugged the wrong piece of software. Bugs in
Debian are filed, #815582, #815586. I don't file bugs with systemd
upstream any more since I got silenced on systemd-devel for losing my
temper.

Greetings
Marc


-- 
-
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany|  lose things."Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421


Re: Computer fails to resume from suspend unless I rmmod jme before initiating the suspend

2016-02-22 Thread Pavel Machek
On Mon 2016-02-22 15:59:48, Diego Viola wrote:
> On Mon, Feb 22, 2016 at 7:09 AM, Pavel Machek  wrote:
> > Hi!
> >
> >>  Every time I initiate a suspend (systemctl suspend) the machine hangs
> >>  at resume unless I unload the jme driver.
> >
> > It seems to have some kind of suspend/resume support. ... and it is
> > rather complex.
> >
> > Maybe jme_start_irq(jme) should be moved to the end of jme_resume
> > function?
> >
> >> > So I found that disabling async as in:
> >> >
> >> > $ echo 0 > /sys/power/pm_async
> >> >
> >> > Helps with my issue, I can't reproduce the hang anymore, tried
> >> > suspend/resume almost ~15 times.
> >> >
> >> > Diego
> >>
> >> Can someone please help?
> 
> Hi Pavel,
> 
> This did the trick, suspend/resume is now working perfectly for me
> (tried more than 10 times). :)
> 
> Thank you so much, should I send a patch?

Yes please.

Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Re: [PATCH V2 net-next 2/3] lan78xx: add ethtool set & get pause functions

2016-02-22 Thread David Miller
From: 
Date: Mon, 22 Feb 2016 18:28:18 +

>> This is incorrect; you should always return the manual settings
>> (fc_request_control flags) here.  If autonegotiation is enabled then
>> your get_settings function will return the actual pause flags.
>> 
> What do you mean "return actual pause flags" when autoneg is enabled?
> Pause flags set by (or default) advertise flag?

It means what was negotiated by autonegotiation, and is actually in use.

Otherwise, how can the user find out what was negotiated?


[PATCH net-next 0/2] be2net patches

2016-02-22 Thread Ajit Khaparde
Please consider applying to net-next

Ajit Khaparde (2):
  Patch 1: Declare some u16 fields as u32 to improve performance
  Patch 2: Fix a UE caused by passing large frames to the ASIC

 drivers/net/ethernet/emulex/benet/be.h  | 21 -
 drivers/net/ethernet/emulex/benet/be_cmds.c |  2 +-
 drivers/net/ethernet/emulex/benet/be_main.c | 27 +++
 3 files changed, 32 insertions(+), 18 deletions(-)

-- 
2.4.3



[PATCH net-next 2/2] be2net: Fix a UE caused by passing large frames to the ASIC

2016-02-22 Thread Ajit Khaparde
In QnQ configurations like Flex-10 where the VLANs are inserted by the
ASIC, on rare occasions the HW is encountering a scenario where the
final frame length ends to be greater than what the ASIC can support.

This is because when the TXULP pulls the TX WRB to check the length
of the frame to be transmitted it also adds the size of VLANs to be
inserted by the HW to the length of the frame indicated in the WRB,
which in some cases fails the range check.  This causes a UE.

Avoid this by trimming the skb length to accommodate the VLAN insertion.

Signed-off-by: Ajit Khaparde 
---
 drivers/net/ethernet/emulex/benet/be.h  |  3 +++
 drivers/net/ethernet/emulex/benet/be_main.c | 11 ++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index 756f25b..ee584c5 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -72,6 +72,9 @@
 #define BE_MAX_MTU  (BE_MAX_JUMBO_FRAME_SIZE - \
 (ETH_HLEN + ETH_FCS_LEN))
 
+/* Accommodate for QnQ configurations where VLAN insertion is enabled in HW */
+#define BE_MAX_GSO_SIZE(65535 - 2 * VLAN_HLEN)
+
 #define BE_NUM_VLANS_SUPPORTED 64
 #define BE_MAX_EQD 128u
 #defineBE_MAX_TX_FRAG_COUNT30
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 0bd64f1..17422b2 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1123,6 +1123,8 @@ static struct sk_buff *be_xmit_workarounds(struct 
be_adapter *adapter,
   struct sk_buff *skb,
   struct be_wrb_params *wrb_params)
 {
+   int err;
+
/* Lancer, SH and BE3 in SRIOV mode have a bug wherein
 * packets that are 32b or less may cause a transmit stall
 * on that port. The workaround is to pad such packets
@@ -1139,6 +1141,13 @@ static struct sk_buff *be_xmit_workarounds(struct 
be_adapter *adapter,
return NULL;
}
 
+   /* The stack can send us skbs with length greater than
+* what the HW can handle. Trim the extra bytes.
+*/
+   WARN_ON_ONCE(skb->len > BE_MAX_GSO_SIZE);
+   err = pskb_trim(skb, BE_MAX_GSO_SIZE);
+   WARN_ON(err);
+
return skb;
 }
 
@@ -4850,7 +4859,7 @@ static void be_netdev_init(struct net_device *netdev)
 
netdev->flags |= IFF_MULTICAST;
 
-   netif_set_gso_max_size(netdev, 65535 - ETH_HLEN);
+   netif_set_gso_max_size(netdev, BE_MAX_GSO_SIZE - ETH_HLEN);
 
netdev->netdev_ops = _netdev_ops;
 
-- 
2.4.3



[PATCH net-next 1/2] be2net: Declare some u16 fields as u32 to improve performance

2016-02-22 Thread Ajit Khaparde
When 16-bit integers are loaded on CPUs with high order native
register sizes, the CPU could use some extra ops before using them.
And currently some of the frequently used fields in the driver like
the producer and consumer indices of the queues are declared as u16.

This patch declares such fields as u32.  With this change we see the
64-byte packets per second numbers improve by about 4%.

Signed-off-by: Ajit Khaparde 
---
 drivers/net/ethernet/emulex/benet/be.h  | 18 +-
 drivers/net/ethernet/emulex/benet/be_cmds.c |  2 +-
 drivers/net/ethernet/emulex/benet/be_main.c | 16 +---
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index ab24f84..756f25b 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -124,27 +124,27 @@ struct be_dma_mem {
 };
 
 struct be_queue_info {
+   u32 len;
+   u32 entry_size; /* Size of an element in the queue */
+   u32 tail, head;
+   atomic_t used;  /* Number of valid elements in the queue */
+   u32 id;
struct be_dma_mem dma_mem;
-   u16 len;
-   u16 entry_size; /* Size of an element in the queue */
-   u16 id;
-   u16 tail, head;
bool created;
-   atomic_t used;  /* Number of valid elements in the queue */
 };
 
-static inline u32 MODULO(u16 val, u16 limit)
+static inline u32 MODULO(u32 val, u32 limit)
 {
BUG_ON(limit & (limit - 1));
return val & (limit - 1);
 }
 
-static inline void index_adv(u16 *index, u16 val, u16 limit)
+static inline void index_adv(u32 *index, u32 val, u32 limit)
 {
*index = MODULO((*index + val), limit);
 }
 
-static inline void index_inc(u16 *index, u16 limit)
+static inline void index_inc(u32 *index, u32 limit)
 {
*index = MODULO((*index + 1), limit);
 }
@@ -169,7 +169,7 @@ static inline void queue_head_inc(struct be_queue_info *q)
index_inc(>head, q->len);
 }
 
-static inline void index_dec(u16 *index, u16 limit)
+static inline void index_dec(u32 *index, u32 limit)
 {
*index = MODULO((*index - 1), limit);
 }
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 66fa214..22402db 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -596,7 +596,7 @@ static int be_mcc_notify_wait(struct be_adapter *adapter)
int status;
struct be_mcc_wrb *wrb;
struct be_mcc_obj *mcc_obj = >mcc_obj;
-   u16 index = mcc_obj->q.head;
+   u32 index = mcc_obj->q.head;
struct be_cmd_resp_hdr *resp;
 
index_dec(, mcc_obj->q.len);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 4624846..0bd64f1 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -849,9 +849,9 @@ static void unmap_tx_frag(struct device *dev, struct 
be_eth_wrb *wrb,
 }
 
 /* Grab a WRB header for xmit */
-static u16 be_tx_get_wrb_hdr(struct be_tx_obj *txo)
+static u32 be_tx_get_wrb_hdr(struct be_tx_obj *txo)
 {
-   u16 head = txo->q.head;
+   u32 head = txo->q.head;
 
queue_head_inc(>q);
return head;
@@ -895,7 +895,7 @@ static void be_tx_setup_wrb_frag(struct be_tx_obj *txo, 
dma_addr_t busaddr,
  * WRBs of the current packet are unmapped. Invoked to handle tx setup errors.
  */
 static void be_xmit_restore(struct be_adapter *adapter,
-   struct be_tx_obj *txo, u16 head, bool map_single,
+   struct be_tx_obj *txo, u32 head, bool map_single,
u32 copied)
 {
struct device *dev;
@@ -930,7 +930,7 @@ static u32 be_xmit_enqueue(struct be_adapter *adapter, 
struct be_tx_obj *txo,
struct device *dev = >pdev->dev;
struct be_queue_info *txq = >q;
bool map_single = false;
-   u16 head = txq->head;
+   u32 head = txq->head;
dma_addr_t busaddr;
int len;
 
@@ -1990,7 +1990,7 @@ static struct be_rx_page_info *get_rx_page_info(struct 
be_rx_obj *rxo)
struct be_adapter *adapter = rxo->adapter;
struct be_rx_page_info *rx_page_info;
struct be_queue_info *rxq = >q;
-   u16 frag_idx = rxq->tail;
+   u32 frag_idx = rxq->tail;
 
rx_page_info = >page_info_tbl[frag_idx];
BUG_ON(!rx_page_info->page);
@@ -2401,10 +2401,11 @@ static u16 be_tx_compl_process(struct be_adapter 
*adapter,
 {
struct sk_buff **sent_skbs = txo->sent_skb_list;
struct be_queue_info *txq = >q;
-   u16 frag_index, num_wrbs = 0;
struct sk_buff *skb = NULL;
bool unmap_skb_hdr = false;
struct be_eth_wrb *wrb;
+   u16 num_wrbs = 0;
+   u32 frag_index;
 
do {
if (sent_skbs[txq->tail]) {
@@ -2516,10 +2517,11 @@ static 

Re: Computer fails to resume from suspend unless I rmmod jme before initiating the suspend

2016-02-22 Thread Diego Viola
On Mon, Feb 22, 2016 at 7:09 AM, Pavel Machek  wrote:
> Hi!
>
>>  Every time I initiate a suspend (systemctl suspend) the machine hangs
>>  at resume unless I unload the jme driver.
>
> It seems to have some kind of suspend/resume support. ... and it is
> rather complex.
>
> Maybe jme_start_irq(jme) should be moved to the end of jme_resume
> function?
>
>> > So I found that disabling async as in:
>> >
>> > $ echo 0 > /sys/power/pm_async
>> >
>> > Helps with my issue, I can't reproduce the hang anymore, tried
>> > suspend/resume almost ~15 times.
>> >
>> > Diego
>>
>> Can someone please help?
>
> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Hi Pavel,

This did the trick, suspend/resume is now working perfectly for me
(tried more than 10 times). :)

Thank you so much, should I send a patch?

Diego


Re: [PATCH v7 0/8] Patchset enabling hardware based cross-timestamps for next gen Intel platforms

2016-02-22 Thread John Stultz
On Mon, Feb 22, 2016 at 10:33 AM, Christopher Hall
 wrote:
> I just sent another patchset (v8). I corrected the comment problems pointed
> out by Richard Cochran. I also changed the arch/x86 code to use "non-stop"
> TSC rather than "invariant" TSC. They are *exactly* the same thing (i.e.
> read from the same bit of the CPUID leaf). The former exists already and
> should be used instead.  Patch 6/8 is the only patch that is changed apart
> from comments.

Ok. So I see you addressed some of Andy's feedback, but did you answer
the bit about the k offset?

thanks
-john


Re: [PATCH v7 0/8] Patchset enabling hardware based cross-timestamps for next gen Intel platforms

2016-02-22 Thread Christopher Hall
On Thu, 18 Feb 2016 11:26:24 -0800, John Stultz   
wrote:

On Fri, Feb 12, 2016 at 12:25 PM, Christopher S. Hall
 wrote:

Modern Intel hardware adds an Always Running Timer (ART) that allows the
network and audio device clocks to precisely cross timestamp the device
clock with the system clock. This allows a precise correlation of the
device time and system time.


Thanks for your continued persistence here Christopher!  It is looking
pretty good.

I've queued these up for testing, and if that goes well, and don't hit
anything else in review, I'll likely try to submit all but the last
patch (unless there's an acked-by from the maintainer of that code)
through Thomas for 4.6.


Hi John,

I just sent another patchset (v8). I corrected the comment problems  
pointed out by Richard Cochran. I also changed the arch/x86 code to use  
"non-stop" TSC rather than "invariant" TSC. They are *exactly* the same  
thing (i.e. read from the same bit of the CPUID leaf). The former exists  
already and should be used instead.  Patch 6/8 is the only patch that is  
changed apart from comments.


Thanks for your help reviewing this.

Chris


[patch net-next 1/9] Introduce devlink infrastructure

2016-02-22 Thread Jiri Pirko
From: Jiri Pirko 

Introduce devlink infrastructure for drivers to register and expose to
userspace via generic Netlink interface.

There are two basic objects defined:
devlink - one instance for every "parent device", for example switch ASIC
devlink port - one instance for every physical port of the device.

This initial portion implements basic get/dump of objects to userspace.
Also, port splitter and port type setting is implemented.

Signed-off-by: Jiri Pirko 
---
 MAINTAINERS  |   8 +
 include/net/devlink.h| 156 
 include/uapi/linux/devlink.h |  73 
 net/Kconfig  |   7 +
 net/core/Makefile|   1 +
 net/core/devlink.c   | 887 +++
 6 files changed, 1132 insertions(+)
 create mode 100644 include/net/devlink.h
 create mode 100644 include/uapi/linux/devlink.h
 create mode 100644 net/core/devlink.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 355e1c8..caad3e6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3502,6 +3502,14 @@ F:   include/linux/device-mapper.h
 F: include/linux/dm-*.h
 F: include/uapi/linux/dm-*.h
 
+DEVLINK
+M: Jiri Pirko 
+L: netdev@vger.kernel.org
+S: Supported
+F: net/core/devlink.c
+F: include/net/devlink.h
+F: include/uapi/linux/devlink.h
+
 DIALOG SEMICONDUCTOR DRIVERS
 M: Support Opensource 
 W: http://www.dialog-semiconductor.com/products
diff --git a/include/net/devlink.h b/include/net/devlink.h
new file mode 100644
index 000..ad34754
--- /dev/null
+++ b/include/net/devlink.h
@@ -0,0 +1,156 @@
+/*
+ * include/net/devlink.h - Network physical device Netlink interface
+ * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2016 Jiri Pirko 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#ifndef _NET_DEVLINK_H_
+#define _NET_DEVLINK_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct devlink_ops;
+
+struct devlink {
+   struct list_head list;
+   struct list_head port_list;
+   int index;
+   const struct devlink_ops *ops;
+   struct device dev;
+   possible_net_t _net;
+   char priv[0] __aligned(NETDEV_ALIGN);
+};
+
+struct devlink_port {
+   struct list_head list;
+   struct devlink *devlink;
+   unsigned index;
+   bool registered;
+   enum devlink_port_type type;
+   enum devlink_port_type desired_type;
+   void *type_dev;
+   bool split;
+   u32 split_group;
+};
+
+struct devlink_ops {
+   size_t priv_size;
+   int (*port_type_set)(struct devlink_port *devlink_port,
+enum devlink_port_type port_type);
+   int (*port_split)(struct devlink *devlink, unsigned int port_index,
+ unsigned int count);
+   int (*port_unsplit)(struct devlink *devlink, unsigned int port_index);
+};
+
+static inline void *devlink_priv(struct devlink *devlink)
+{
+   BUG_ON(!devlink);
+   return >priv;
+}
+
+static inline struct devlink *priv_to_devlink(void *priv)
+{
+   BUG_ON(!priv);
+   return container_of(priv, struct devlink, priv);
+}
+
+static inline struct device *devlink_dev(struct devlink *devlink)
+{
+   return >dev;
+}
+
+static inline void set_devlink_dev(struct devlink *devlink, struct device *dev)
+{
+   devlink->dev.parent = dev;
+}
+
+static inline const char *devlink_name(const struct devlink *devlink)
+{
+   return dev_name(>dev);
+}
+
+struct ib_device;
+
+#if IS_ENABLED(CONFIG_NET_DEVLINK)
+
+struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
+int devlink_register(struct devlink *devlink);
+void devlink_unregister(struct devlink *devlink);
+void devlink_free(struct devlink *devlink);
+int devlink_port_register(struct devlink *devlink,
+ struct devlink_port *devlink_port,
+ unsigned int port_index);
+void devlink_port_unregister(struct devlink_port *devlink_port);
+void devlink_port_type_eth_set(struct devlink_port *devlink_port,
+  struct net_device *netdev);
+void devlink_port_type_ib_set(struct devlink_port *devlink_port,
+ struct ib_device *ibdev);
+void devlink_port_type_clear(struct devlink_port *devlink_port);
+void devlink_port_split_set(struct devlink_port *devlink_port,
+   u32 split_group);
+
+#else
+
+static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
+   size_t priv_size)
+{
+   return kzalloc(sizeof(struct devlink) + priv_size, GFP_KERNEL);
+}
+

[patch net-next 2/9] mlx4: Implement devlink interface

2016-02-22 Thread Jiri Pirko
From: Jiri Pirko 

Implement newly introduced devlink interface. Add devlink port instances
for every port and set the port types accordingly.

Signed-off-by: Jiri Pirko 
---
 drivers/infiniband/hw/mlx4/main.c  |  7 
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |  8 -
 drivers/net/ethernet/mellanox/mlx4/intf.c  |  9 ++
 drivers/net/ethernet/mellanox/mlx4/main.c  | 45 +++---
 drivers/net/ethernet/mellanox/mlx4/mlx4.h  |  2 ++
 include/linux/mlx4/driver.h|  3 ++
 6 files changed, 61 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c 
b/drivers/infiniband/hw/mlx4/main.c
index 1c7ab6c..a15a7b3 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2519,6 +2520,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
}
 
ibdev->ib_active = true;
+   mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
+   devlink_port_type_ib_set(mlx4_get_devlink_port(dev, i),
+>ib_dev);
 
if (mlx4_is_mfunc(ibdev->dev))
init_pkeys(ibdev);
@@ -2643,7 +2647,10 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void 
*ibdev_ptr)
 {
struct mlx4_ib_dev *ibdev = ibdev_ptr;
int p;
+   int i;
 
+   mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
+   devlink_port_type_clear(mlx4_get_devlink_port(dev, i));
ibdev->ib_active = false;
flush_workqueue(wq);
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 01d6a96..ab6eeb0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2033,8 +2034,11 @@ void mlx4_en_destroy_netdev(struct net_device *dev)
en_dbg(DRV, priv, "Destroying netdev on port:%d\n", priv->port);
 
/* Unregister device - this will close the port if it was up */
-   if (priv->registered)
+   if (priv->registered) {
+   devlink_port_type_clear(mlx4_get_devlink_port(mdev->dev,
+ priv->port));
unregister_netdev(dev);
+   }
 
if (priv->allocated)
mlx4_free_hwq_res(mdev->dev, >res, MLX4_EN_PAGE_SIZE);
@@ -3050,6 +3054,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
port,
}
 
priv->registered = 1;
+   devlink_port_type_eth_set(mlx4_get_devlink_port(mdev->dev, priv->port),
+ dev);
 
return 0;
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/intf.c 
b/drivers/net/ethernet/mellanox/mlx4/intf.c
index 0472941..dec77d6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/intf.c
+++ b/drivers/net/ethernet/mellanox/mlx4/intf.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mlx4.h"
 
@@ -249,3 +250,11 @@ void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum 
mlx4_protocol proto, int
return result;
 }
 EXPORT_SYMBOL_GPL(mlx4_get_protocol_dev);
+
+struct devlink_port *mlx4_get_devlink_port(struct mlx4_dev *dev, int port)
+{
+   struct mlx4_port_info *info = _priv(dev)->port[port];
+
+   return >devlink_port;
+}
+EXPORT_SYMBOL_GPL(mlx4_get_devlink_port);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index f1b6d21..a5f54a5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2847,8 +2848,13 @@ no_msi:
 
 static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
 {
+   struct devlink *devlink = priv_to_devlink(mlx4_priv(dev));
struct mlx4_port_info *info = _priv(dev)->port[port];
-   int err = 0;
+   int err;
+
+   err = devlink_port_register(devlink, >devlink_port, port);
+   if (err)
+   return err;
 
info->dev = dev;
info->port = port;
@@ -2873,6 +2879,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int 
port)
err = device_create_file(>persist->pdev->dev, >port_attr);
if (err) {
mlx4_err(dev, "Failed to create file for port %d\n", port);
+   devlink_port_unregister(>devlink_port);
info->port = -1;
}
 
@@ -3646,21 +3653,23 @@ err_disable_pdev:
 
 static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
+   struct devlink *devlink;
struct mlx4_priv *priv;
struct mlx4_dev *dev;
int ret;
 
printk_once(KERN_INFO "%s", mlx4_version);
 
-   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-   if (!priv)
+   

[patch net-next 7/9] mlxsw: spectrum: Store local port to module mapping during init

2016-02-22 Thread Jiri Pirko
From: Ido Schimmel 

The port netdevs are each associated with a different local port number
in the device. These local ports are grouped into groups of 4 (e.g.
(1-4), (5-8)) called clusters. The cluster constitutes the one of two
possible modules they can be mapped to. This mapping is board-specific
and done by the device's firmware during init.

When splitting a port by 4, the device requires us to first unmap all
the ports in the cluster and then map each to a single lane in the module
associated with the port netdev used as the handle for the operation.
This means that two port netdevs will disappear, as only 100Gb/s (4
lanes) ports can be split and we are guaranteed to have two of these
((1, 3), (5, 7) etc.) in a cluster.

When unsplit occurs we need to reinstantiate the two original 100Gb/s
ports and map each to its origianl module. Therefore, during driver init
store the initial local port to module mapping, so it can be used later
during unsplitting.

Note that a by 2 split doesn't require us to store the mapping, as we
only need to reinstantiate one port whose module is known.

Signed-off-by: Ido Schimmel 
Signed-off-by: Jiri Pirko 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 36 +++---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |  1 +
 2 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1d6f1ef..b9d963a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -305,18 +305,19 @@ mlxsw_sp_port_system_port_mapping_set(struct 
mlxsw_sp_port *mlxsw_sp_port)
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sspr), sspr_pl);
 }
 
-static int mlxsw_sp_port_module_check(struct mlxsw_sp_port *mlxsw_sp_port,
- bool *p_usable)
+static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp,
+u8 local_port, u8 *p_module,
+u8 *p_width)
 {
-   struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char pmlp_pl[MLXSW_REG_PMLP_LEN];
int err;
 
-   mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port);
+   mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
if (err)
return err;
-   *p_usable = mlxsw_reg_pmlp_width_get(pmlp_pl) ? true : false;
+   *p_module = mlxsw_reg_pmlp_module_get(pmlp_pl, 0);
+   *p_width = mlxsw_reg_pmlp_width_get(pmlp_pl);
return 0;
 }
 
@@ -1365,7 +1366,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
struct mlxsw_sp_port *mlxsw_sp_port;
struct devlink_port *devlink_port;
struct net_device *dev;
-   bool usable;
size_t bytes;
int err;
 
@@ -1417,19 +1417,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
 */
dev->hard_header_len += MLXSW_TXHDR_LEN;
 
-   err = mlxsw_sp_port_module_check(mlxsw_sp_port, );
-   if (err) {
-   dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to check 
module\n",
-   mlxsw_sp_port->local_port);
-   goto err_port_module_check;
-   }
-
-   if (!usable) {
-   dev_dbg(mlxsw_sp->bus_info->dev, "Port %d: Not usable, skipping 
initialization\n",
-   mlxsw_sp_port->local_port);
-   goto port_not_usable;
-   }
-
devlink_port = _sp_port->devlink_port;
err = devlink_port_register(devlink, devlink_port, local_port);
if (err) {
@@ -1497,8 +1484,6 @@ err_port_swid_set:
 err_port_system_port_mapping_set:
devlink_port_unregister(_sp_port->devlink_port);
 err_devlink_port_register:
-port_not_usable:
-err_port_module_check:
 err_dev_addr_init:
free_percpu(mlxsw_sp_port->pcpu_stats);
 err_alloc_stats:
@@ -1560,6 +1545,7 @@ static void mlxsw_sp_ports_remove(struct mlxsw_sp 
*mlxsw_sp)
 static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
 {
size_t alloc_size;
+   u8 module, width;
int i;
int err;
 
@@ -1569,6 +1555,13 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp 
*mlxsw_sp)
return -ENOMEM;
 
for (i = 1; i < MLXSW_PORT_MAX_PORTS; i++) {
+   err = mlxsw_sp_port_module_info_get(mlxsw_sp, i, ,
+   );
+   if (err)
+   goto err_port_module_info_get;
+   if (!width)
+   continue;
+   mlxsw_sp->port_to_module[i] = module;
err = mlxsw_sp_port_create(mlxsw_sp, i);
if (err)
goto err_port_create;
@@ -1576,6 +1569,7 @@ static int 

[patch net-next 6/9] mlxsw: spectrum: Unmap local port from module during teardown

2016-02-22 Thread Jiri Pirko
From: Ido Schimmel 

When splitting a port we replace it with 2 or 4 other ports. To be able
to do that we need to remove the original port netdev and unmap it from
its module. However, we first mark it as disabled, as active ports
cannot be unmapped.

Signed-off-by: Ido Schimmel 
Signed-off-by: Jiri Pirko 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 9d4b06c..1d6f1ef 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -320,6 +320,15 @@ static int mlxsw_sp_port_module_check(struct mlxsw_sp_port 
*mlxsw_sp_port,
return 0;
 }
 
+static int mlxsw_sp_port_module_unmap(struct mlxsw_sp *mlxsw_sp, u8 local_port)
+{
+   char pmlp_pl[MLXSW_REG_PMLP_LEN];
+
+   mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
+   mlxsw_reg_pmlp_width_set(pmlp_pl, 0);
+   return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
+}
+
 static int mlxsw_sp_port_open(struct net_device *dev)
 {
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
@@ -1531,6 +1540,8 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
devlink_port_unregister(devlink_port);
mlxsw_sp_port_vports_fini(mlxsw_sp_port);
mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
+   mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT);
+   mlxsw_sp_port_module_unmap(mlxsw_sp, mlxsw_sp_port->local_port);
free_percpu(mlxsw_sp_port->pcpu_stats);
kfree(mlxsw_sp_port->untagged_vlans);
kfree(mlxsw_sp_port->active_vlans);
-- 
2.5.0



[patch net-next 4/9] mlxsw: Implement devlink interface

2016-02-22 Thread Jiri Pirko
From: Jiri Pirko 

Implement newly introduced devlink interface. Add devlink port instances
for every port and set the port types accordingly.

Signed-off-by: Jiri Pirko 
---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 24 ++--
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 20 
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |  2 ++
 drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 20 
 4 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c 
b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 22379eb..57d9655 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core.h"
 #include "item.h"
@@ -791,6 +792,7 @@ int mlxsw_core_bus_device_register(const struct 
mlxsw_bus_info *mlxsw_bus_info,
const char *device_kind = mlxsw_bus_info->device_kind;
struct mlxsw_core *mlxsw_core;
struct mlxsw_driver *mlxsw_driver;
+   struct devlink *devlink;
size_t alloc_size;
int err;
 
@@ -798,12 +800,13 @@ int mlxsw_core_bus_device_register(const struct 
mlxsw_bus_info *mlxsw_bus_info,
if (!mlxsw_driver)
return -EINVAL;
alloc_size = sizeof(*mlxsw_core) + mlxsw_driver->priv_size;
-   mlxsw_core = kzalloc(alloc_size, GFP_KERNEL);
-   if (!mlxsw_core) {
+   devlink = devlink_alloc(NULL, alloc_size);
+   if (!devlink) {
err = -ENOMEM;
-   goto err_core_alloc;
+   goto err_devlink_alloc;
}
 
+   mlxsw_core = devlink_priv(devlink);
INIT_LIST_HEAD(_core->rx_listener_list);
INIT_LIST_HEAD(_core->event_listener_list);
mlxsw_core->driver = mlxsw_driver;
@@ -841,6 +844,11 @@ int mlxsw_core_bus_device_register(const struct 
mlxsw_bus_info *mlxsw_bus_info,
if (err)
goto err_hwmon_init;
 
+   set_devlink_dev(devlink, mlxsw_bus_info->dev);
+   err = devlink_register(devlink);
+   if (err)
+   goto err_devlink_register;
+
err = mlxsw_driver->init(mlxsw_core->driver_priv, mlxsw_core,
 mlxsw_bus_info);
if (err)
@@ -855,6 +863,8 @@ int mlxsw_core_bus_device_register(const struct 
mlxsw_bus_info *mlxsw_bus_info,
 err_debugfs_init:
mlxsw_core->driver->fini(mlxsw_core->driver_priv);
 err_driver_init:
+   devlink_unregister(devlink);
+err_devlink_register:
 err_hwmon_init:
mlxsw_emad_fini(mlxsw_core);
 err_emad_init:
@@ -864,8 +874,8 @@ err_bus_init:
 err_alloc_lag_mapping:
free_percpu(mlxsw_core->pcpu_stats);
 err_alloc_stats:
-   kfree(mlxsw_core);
-err_core_alloc:
+   devlink_free(devlink);
+err_devlink_alloc:
mlxsw_core_driver_put(device_kind);
return err;
 }
@@ -874,14 +884,16 @@ EXPORT_SYMBOL(mlxsw_core_bus_device_register);
 void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core)
 {
const char *device_kind = mlxsw_core->bus_info->device_kind;
+   struct devlink *devlink = priv_to_devlink(mlxsw_core);
 
mlxsw_core_debugfs_fini(mlxsw_core);
mlxsw_core->driver->fini(mlxsw_core->driver_priv);
+   devlink_unregister(devlink);
mlxsw_emad_fini(mlxsw_core);
mlxsw_core->bus->fini(mlxsw_core->bus_priv);
kfree(mlxsw_core->lag.mapping);
free_percpu(mlxsw_core->pcpu_stats);
-   kfree(mlxsw_core);
+   devlink_free(devlink);
mlxsw_core_driver_put(device_kind);
 }
 EXPORT_SYMBOL(mlxsw_core_bus_device_unregister);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 217856b..9d4b06c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -49,6 +49,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1351,7 +1352,9 @@ static const struct ethtool_ops mlxsw_sp_port_ethtool_ops 
= {
 
 static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
 {
+   struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
struct mlxsw_sp_port *mlxsw_sp_port;
+   struct devlink_port *devlink_port;
struct net_device *dev;
bool usable;
size_t bytes;
@@ -1360,6 +1363,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
dev = alloc_etherdev(sizeof(struct mlxsw_sp_port));
if (!dev)
return -ENOMEM;
+   SET_NETDEV_DEV(dev, devlink_dev(devlink));
mlxsw_sp_port = netdev_priv(dev);
mlxsw_sp_port->dev = dev;
mlxsw_sp_port->mlxsw_sp = mlxsw_sp;
@@ -1417,6 +1421,14 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
goto port_not_usable;
}
 
+   devlink_port = 

  1   2   3   >