Re: [RFC PATCH] net: macb: Add gmii2rgmii converter support

2016-06-19 Thread Florian Fainelli
On June 19, 2016 10:27:17 PM MST, Kedareswara rao Appana 
 wrote:
>This patch adds support for gmii2rgmii converter
>in the macb driver.
>
>The GMII to RGMII IP core provides the
>Reduced Gigabit Media Independent Interface
>(RGMII) between Ethernet physical media devices
>And the Gigabit Ethernet controller.
>This core can switch dynamically between the
>Three different speed modes of operation (10/100/1000 Mb/s).
>MDIO interface is used to set operating speed of Ethernet MAC.
>
>Signed-off-by: Kedareswara rao Appana 
>---
>--> Tried to include this Coverter support in the
>PHY layer but it won't fit into the PHY framework as the
>coverter won't have vaild vendor/Device id registers.
>--> The Converter has only one register (16) that need's
>to be programmed with the external phy negotiated speed.
>--> The converter won't follow the Standard MII(ieee 802.3 clause 22).
>--> Will appreciate if someone can help on adding this coverter support

With the fixed PHY emulated PHY and registering a link_update callback (see 
drivers/net/dsa/bcm_sf2.c for an example), you could read specific registers 
which indicates link parameters and update the PHY device with these. 

How exactly is this converter working?

-- 
Florian


RE: [PATCH net-next] net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)

2016-06-19 Thread Rosen, Rami
Hi all, 

A very limited review below.

+
+   /* get capabilities of particular feature */
+   ENA_ADMIN_GET_FEATURE = 8,

Instead /* get capabilities  SHOULD BE:  /* set capabilities .
+
+   /* get capabilities of particular feature */
+   ENA_ADMIN_SET_FEATURE = 9,
+
..


+int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
+{
+   struct ena_com_admin_queue *admin_queue = _dev->admin_queue;
...

You set ret=-EINVAL, but you do not use this ret as you immediately return 0 in 
the next line, which is the end of the method. Either return ret or return 
-EINVAL.
+   if (unlikely(ret)) {
+   ena_trc_err("Failed to set hash input. error: %d\n", ret);
+   ret = -EINVAL;
+   }
+
+   return 0;
+}
+



+
+/* ena_com_set_mmio_read_mode - Enable/disable the mmio reg read mechanism
+ * @ena_dev: ENA communication layer struct


Instead realess_supported: SHOULD BE: readless_supported

+ * @realess_supported: readless mode (enable/disable)
+ */
+void ena_com_set_mmio_read_mode(struct ena_com_dev *ena_dev,
+   bool readless_supported);
+



+
+/* ena_com_create_io_queue - Create io queue.
+ * @ena_dev: ENA communication layer struct

Instead ena_com_create_io_ctx SHOULD BE: @ena_com_create_io_ctx

+ * ena_com_create_io_ctx - create context structure
+ *
+ * Create the submission and the completion queues.
+ *
+ * @return - 0 on success, negative value on failure.
+ */
+int ena_com_create_io_queue(struct ena_com_dev *ena_dev,
+   struct ena_com_create_io_ctx *ctx);
+




+/* ena_com_admin_destroy - Destroy IO queue with the queue id - qid.
+ * @ena_dev: ENA communication layer struct

Missing: @qid

+ */
+void ena_com_destroy_io_queue(struct ena_com_dev *ena_dev, u16 qid);
+

Regards,
Rami Rosen
Intel Corporation


Re: [PATCH] net:ppp: replace too strict capability restriction on opening /dev/ppp

2016-06-19 Thread Andi Kleen
Shanker Wang  writes:

> This patch removes the check for CAP_NET_ADMIN in the initial namespace
> when opening /dev/open. Instead, CAP_NET_ADMIN is checked in the user
> namespace the net namespace was created so that /dev/ppp cat get opened
> in a unprivileged container.

Seems dangerous. From a quick look at the PPP ioctl there is no limit
how many PPP devices this can create. So a container having access to
this would be able to fill all kernel memory. Probably needs more
auditing and hardening first.

In general there seems to be a lot of attack surface for root
in PPP.

-Andi

-- 
a...@linux.intel.com -- Speaking for myself only


Re: [iproute PATCH 1/3] Use C99 style initializers everywhere

2016-06-19 Thread David Ahern

On 6/17/16 6:21 PM, Stephen Hemminger wrote:

I want to have the least user complaints possible.
Since the main reason people build new iproute2 utilities is to work with 
features
of newer kernels. It makes sense to keep the requirements the same. Not sure if 
kernel
still builds with gcc-3.2, has anyone tried.


That seems excessive.

Looking at the ftp sites RHEL4 started with gcc-3.4 in May 2005 -- 11 
years ago.


RHEL5 uses gcc-4.1 and it is now 9 years old.


Re: [patch net-next v4 0/4] return offloaded stats as default and expose original sw stats

2016-06-19 Thread Roopa Prabhu
On Fri, Jun 17, 2016 at 10:12 AM, Florian Fainelli  wrote:
> On 06/17/2016 08:42 AM, Jiri Pirko wrote:
>> Fri, Jun 17, 2016 at 05:35:53PM CEST, d...@cumulusnetworks.com wrote:
>>> On 6/17/16 8:54 AM, Jamal Hadi Salim wrote:
 On 16-06-17 10:05 AM, Jiri Pirko wrote:
> Fri, Jun 17, 2016 at 03:48:35PM CEST, d...@cumulusnetworks.com wrote:
>> On 6/17/16 2:24 AM, Jiri Pirko wrote:
>>>

>
> That is problematic. Existing apps depend on rtnetlink stats. But if we
> don't count offloaded forwarded packets, the apps don't see anything.
> Therefore I believe that this patchset approach is better. The existing
> apps continue to work and future apps can use newly introduces sw_stats
> to query slowpath traffic. Makes sense to me.
>

 I agree with Jiri. It is a bad idea to depend on ethtool for any of
 this stuff. Is there a way we can tag netlink stats instead
 to indicate they are hardware or software?
>>>
>>> Right, old API but the key here is that low level h/w stats are returned by 
>>> a
>>> different API.
>>>
>>> By default ip, ifconfig, snmpd, etc all continue to get traditional S/W 
>>> stats
>>> - counters as seen by the CPU.
>>
>> Yep. And I believe that for offloaded forwarding, this tools should see
>> hw counters, as they show what is going on in real.
>
> If your NIC is offloading packets today, these tools typically won't see
> these stats, but ethtool -S likely will report what is going on under
> the hood.
>
> Do we actually need to tell apart SW maintained from HW maintained
> stats, or at the end all that matters is just, as DaveM pointed out,
> getting the information, and in the case of an Ethernet switch, return
> HW stats by default and supplement with SW stats whenever we have them,
> all in the same namespace?
> --

I have also mentioned this before, the default api must provide
accumulated (hw and sw) stats...,
because this is the api that the user queries on an interface.
For advanced debugging, people do want a break down and thats what
traditionally ethtool has provided
and the new stats api should eventually include support for ethtool like stats.


Re: [PATCH net-next 0/8] tou: Transports over UDP - part I

2016-06-19 Thread David Miller
From: Tom Herbert 
Date: Fri, 17 Jun 2016 20:52:55 -0700

> For instance, TFO was put in the Linux several years ago, but it
> still hasn't been enabled in Android and only fairly recently
> enabled in iOS.

"Android decided to get locked into a really old kernel for 6+ years"
is not really a good argument, sorry.

We've already been hurt badly by the poor decisions the Android folks
have made wrt. the handling of their kernel.

Let's not make it worse by also making userland TCP stacks ubiquitous
as a side effect.

I've been assured several times that the Android situation will at
the very least improve.

And if it does improve and features do propagate more quickly, we'll
have all of this risk and gambling unnecessarily.

Let's not route around the Android problem, but rather get them to
address it properly.


Re: [patch net-next v4 0/4] return offloaded stats as default and expose original sw stats

2016-06-19 Thread Roopa Prabhu
On Fri, Jun 17, 2016 at 7:54 AM, Jamal Hadi Salim  wrote:
> On 16-06-17 10:05 AM, Jiri Pirko wrote:
>>
>> Fri, Jun 17, 2016 at 03:48:35PM CEST, d...@cumulusnetworks.com wrote:
>>>
>>> On 6/17/16 2:24 AM, Jiri Pirko wrote:


>
>>
>> That is problematic. Existing apps depend on rtnetlink stats. But if we
>> don't count offloaded forwarded packets, the apps don't see anything.
>> Therefore I believe that this patchset approach is better. The existing
>> apps continue to work and future apps can use newly introduces sw_stats
>> to query slowpath traffic. Makes sense to me.
>>
>
> I agree with Jiri. It is a bad idea to depend on ethtool for any of
> this stuff.

The concern should not be that it is an ethtool api.
In all previous discussions on this patchset and also my
stats api patches, i have indicated that we have to move all stats
in one place, so naturally, ethtool stats should move eventually to the
stats api as a new nested netlink attribute. I think i called it
IFLA_STATS_LINK_HW  (or something like that)...
and this nested attribute should provide the flexibility and extensibility
of the current ethtool stats api.


> Is there a way we can tag netlink stats instead
> to indicate they are hardware or software?
> We already have a use case with the tc where someone could get/set
> hardware and/or software.
>
> cheers,
> jamal


Re: [patch net-next v4 0/4] return offloaded stats as default and expose original sw stats

2016-06-19 Thread Roopa Prabhu
On Fri, Jun 17, 2016 at 7:05 AM, Jiri Pirko  wrote:
> Fri, Jun 17, 2016 at 03:48:35PM CEST, d...@cumulusnetworks.com wrote:
>>On 6/17/16 2:24 AM, Jiri Pirko wrote:
>>>
>>>The problem we try to handle is different, it's about offloaded
>>>forwarded packets which are not seen by kernel. Let me try to draw it :)
>>>
>>>port1   port2 (HW stats are counted here)
>>>  \  /
>>>   \/
>>>\  /
>>> --(A) ASIC --(B)--
>>>|
>>>   (C)
>>>|
>>>   CPU (SW stats are counted here)
>>>
>>>
>>>Now we have couple of flows for TX and RX (direction does not matter here):
>>>
>>>1) port1->A->ASIC->C->CPU
>>>
>>>   For this flow, HW and SW stats are equal.
>>>
>>>2) port1->A->ASIC->C->CPU->C->ASIC->B->port2
>>>
>>>   For this flow, HW and SW stats are equal.
>>>
>>>3) port1->A->ASIC->B->port2
>>>
>>>   For this flow, SW stats are 0.
>>>
>>>The purpose of this patchset is to provide facility for user to
>>>find out the difference between flows 1+2 and 3. In other words, user
>>>will be able to see the statistics for his slow-path (through kernel).
>>>
>>>Also, as a default the accumulated stats (HW) will be exposed to user
>>>so the userspace apps can react properly.
>>>
>>
>>You no longer agree with this discussion?
>>  http://comments.gmane.org/gmane.linux.network/346740
>>
>>Essentially netdevice stats show counters for packets punted to the cpu and
>>ethool -S shows h/w stats. This patch set seems to invert that.
>
> That is problematic. Existing apps depend on rtnetlink stats. But if we
> don't count offloaded forwarded packets, the apps don't see anything.
> Therefore I believe that this patchset approach is better. The existing
> apps continue to work and future apps can use newly introduces sw_stats
> to query slowpath traffic. Makes sense to me.
>

Apps only care about stats. they don't care about sw vs hardware
stats. what apps are these ?.
For debugging, I agree it would be useful, but thats why we have
always had ethtool stats which
the driver can break down and display. And in all my patches about the
new stats api, i have indicated
that we will migrate the existing ethtool stats to a new netlink
attribute in the new stats api.


Re: rcu locking issue in mpls output code?

2016-06-19 Thread David Ahern

On 6/19/16 6:45 PM, Lennert Buytenhek wrote:

diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
index fb31aa8..802956b 100644
--- a/net/mpls/mpls_iptunnel.c
+++ b/net/mpls/mpls_iptunnel.c
@@ -105,12 +105,15 @@ static int mpls_output(struct net *net, struct sock *sk, 
struct sk_buff *skb)
bos = false;
}

+   rcu_read_lock_bh();
if (rt)
err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, >rt_gateway,
 skb);
else if (rt6)
err = neigh_xmit(NEIGH_ND_TABLE, out_dev, >rt6i_gateway,
 skb);
+   rcu_read_unlock_bh();
+
if (err)
net_dbg_ratelimited("%s: packet transmission failed: %d\n",
__func__, err);



I think those need to be added to neigh_xmit in the

if (likely(index < NEIGH_NR_TABLES)) {

}

block.


linux-next: manual merge of the net-next tree with the net tree

2016-06-19 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  net/rds/tcp_listen.c

between commit:

  3bb549ae4c51 ("RDS: TCP: rds_tcp_accept_one() should transition socket from 
RESETTING to UP")

from the net tree and commit:

  0cb43965d42a ("RDS: split out connection specific state from rds_connection 
to rds_conn_path")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc net/rds/tcp_listen.c
index 245542ca4718,22d9bb15f731..
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@@ -136,9 -137,10 +137,10 @@@ int rds_tcp_accept_one(struct socket *s
goto rst_nsk;
} else {
rds_tcp_reset_callbacks(new_sock, conn);
-   conn->c_outgoing = 0;
+   conn->c_path[0].cp_outgoing = 0;
/* rds_connect_path_complete() marks RDS_CONN_UP */
-   rds_connect_path_complete(conn, RDS_CONN_RESETTING);
+   rds_connect_path_complete(>c_path[0],
 -RDS_CONN_DISCONNECTING);
++RDS_CONN_RESETTING);
}
} else {
rds_tcp_set_callbacks(new_sock, conn);


linux-next: manual merge of the net-next tree with the net tree

2016-06-19 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  net/rds/tcp_connect.c

between commit:

  5c3da57d70f1 ("net: rds: fix coding style issues")

from the net tree and commit:

  0cb43965d42a ("RDS: split out connection specific state from rds_connection 
to rds_conn_path")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc net/rds/tcp_connect.c
index f6e95d60db54,ba9ec67f4e41..
--- a/net/rds/tcp_connect.c
+++ b/net/rds/tcp_connect.c
@@@ -54,19 -55,20 +55,20 @@@ void rds_tcp_state_change(struct sock *
  
rdsdebug("sock %p state_change to %d\n", tc->t_sock, sk->sk_state);
  
 -  switch(sk->sk_state) {
 -  /* ignore connecting sockets as they make progress */
 -  case TCP_SYN_SENT:
 -  case TCP_SYN_RECV:
 -  break;
 -  case TCP_ESTABLISHED:
 -  rds_connect_path_complete(>c_path[0],
 -RDS_CONN_CONNECTING);
 -  break;
 -  case TCP_CLOSE_WAIT:
 -  case TCP_CLOSE:
 -  rds_conn_drop(conn);
 -  default:
 -  break;
 +  switch (sk->sk_state) {
 +  /* ignore connecting sockets as they make progress */
 +  case TCP_SYN_SENT:
 +  case TCP_SYN_RECV:
 +  break;
 +  case TCP_ESTABLISHED:
-   rds_connect_path_complete(conn, RDS_CONN_CONNECTING);
++  rds_connect_path_complete(>c_path[0],
++RDS_CONN_CONNECTING);
 +  break;
 +  case TCP_CLOSE_WAIT:
 +  case TCP_CLOSE:
 +  rds_conn_drop(conn);
 +  default:
 +  break;
}
  out:
read_unlock_bh(>sk_callback_lock);


linux-next: manual merge of the net-next tree with the net tree

2016-06-19 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  drivers/net/ethernet/qlogic/qed/qed_hsi.h

between commit:

  b639f197210d ("qed: Add missing port-mode")

from the net tree and commit:

  351a4dedb34c ("qed: Utilize FW 8.10.3.0")

from the net-next tree.

I fixed it up (the net-next tree version is a superset of the net tree
version) and can carry the fix as necessary. This is now fixed as far as
linux-next is concerned, but any non trivial conflicts should be mentioned
to your upstream maintainer when your tree is submitted for merging.
You may also want to consider cooperating with the maintainer of the
conflicting tree to minimise any particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell


rcu locking issue in mpls output code?

2016-06-19 Thread Lennert Buytenhek
Hi!

While trying to chase down a memory corruption issue that only occurs
when originating large amounts of MPLS tagged IP traffic, I came across
something in the MPLS output code for which I'm not entirely sure that
it's correct.

Specifically, there is the code path dst_output() -> lwtunnel_output()
-> mpls_output() -> neigh_xmit() -> ___neigh_lookup_noref(), where the
latter accesses a RCU-bh protected struct neigh_table pointer, but there
is no RCU-bh protection being arranged anywhere in this call chain.

Since this is locally generated IP traffic, we're running in process
context, and while lwtunnel_output() holds rcu_read_lock() across its
call to lwtunnel_encap_ops::output() (which is mpls_output() here),
nothing in the chain disables BHs, and in RCU-bh, the completion of a
softirq signals the end of any pending read-side critical sections,
and BHs can preempt this call chain at any time because it runs with
hardirqs and softirqs both enabled, so that would mean that neighbour
table entries can be zapped at any time even while we hold
rcu_read_lock().  I think.

The mpls_forward() path doesn't seem susceptible to the same issue,
as it runs from softirq, where rcu_read_lock() suffices, so I figured
that mpls_output() would be a good place to deal with this and that
something like the patch below would do the trick.  I can't say yet if
this makes my memory corruption issues go away, as they don't reproduce
that easily, but I'll keep testing.  Any thoughts so far?


Thanks,
Lennert



diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
index fb31aa8..802956b 100644
--- a/net/mpls/mpls_iptunnel.c
+++ b/net/mpls/mpls_iptunnel.c
@@ -105,12 +105,15 @@ static int mpls_output(struct net *net, struct sock *sk, 
struct sk_buff *skb)
bos = false;
}
 
+   rcu_read_lock_bh();
if (rt)
err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, >rt_gateway,
 skb);
else if (rt6)
err = neigh_xmit(NEIGH_ND_TABLE, out_dev, >rt6i_gateway,
 skb);
+   rcu_read_unlock_bh();
+
if (err)
net_dbg_ratelimited("%s: packet transmission failed: %d\n",
__func__, err);


Re: [PATCH 1/2] net: ethernet: bcmsysport: use phydev from struct net_device

2016-06-19 Thread David Miller
From: Philippe Reynes 
Date: Sun, 19 Jun 2016 20:39:08 +0200

> The private structure contain a pointer to phydev, but the structure
> net_device already contain such pointer. So we can remove the pointer
> phydev in the private structure, and update the driver to use the
> one contained in struct net_device.
> 
> Signed-off-by: Philippe Reynes 

Applied.


Re: [PATCH 2/2] net: ethernet: bcmsysport: use phy_ethtool_{get|set}_link_ksettings

2016-06-19 Thread David Miller
From: Philippe Reynes 
Date: Sun, 19 Jun 2016 20:39:09 +0200

> There are two generics functions phy_ethtool_{get|set}_link_ksettings,
> so we can use them instead of defining the same code in the driver.
> 
> Signed-off-by: Philippe Reynes 

Applied.


Re: [PATCH 2/2] net: ethernet: bcmsysport: use phy_ethtool_{get|set}_link_ksettings

2016-06-19 Thread Florian Fainelli
Le 19/06/2016 11:39, Philippe Reynes a écrit :
> There are two generics functions phy_ethtool_{get|set}_link_ksettings,
> so we can use them instead of defining the same code in the driver.
> 
> Signed-off-by: Philippe Reynes 

Reviewed-by: Florian Fainelli 
-- 
Florian


Re: [PATCH 1/2] net: ethernet: bcmsysport: use phydev from struct net_device

2016-06-19 Thread Florian Fainelli
Le 19/06/2016 11:39, Philippe Reynes a écrit :
> The private structure contain a pointer to phydev, but the structure
> net_device already contain such pointer. So we can remove the pointer
> phydev in the private structure, and update the driver to use the
> one contained in struct net_device.
> 
> Signed-off-by: Philippe Reynes 

Reviewed-by: Florian Fainelli 
-- 
Florian


[PATCH 2/2] net: ethernet: bgmac: use phy_ethtool_{get|set}_link_ksettings

2016-06-19 Thread Philippe Reynes
There are two generics functions phy_ethtool_{get|set}_link_ksettings,
so we can use them instead of defining the same code in the driver.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/bgmac.c |   20 ++--
 1 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
b/drivers/net/ethernet/broadcom/bgmac.c
index 90ed244..e6e74ca 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1511,22 +1511,6 @@ static void bgmac_get_ethtool_stats(struct net_device 
*dev,
}
 }
 
-static int bgmac_get_settings(struct net_device *net_dev,
- struct ethtool_cmd *cmd)
-{
-   struct bgmac *bgmac = netdev_priv(net_dev);
-
-   return phy_ethtool_gset(net_dev->phydev, cmd);
-}
-
-static int bgmac_set_settings(struct net_device *net_dev,
- struct ethtool_cmd *cmd)
-{
-   struct bgmac *bgmac = netdev_priv(net_dev);
-
-   return phy_ethtool_sset(net_dev->phydev, cmd);
-}
-
 static void bgmac_get_drvinfo(struct net_device *net_dev,
  struct ethtool_drvinfo *info)
 {
@@ -1538,9 +1522,9 @@ static const struct ethtool_ops bgmac_ethtool_ops = {
.get_strings= bgmac_get_strings,
.get_sset_count = bgmac_get_sset_count,
.get_ethtool_stats  = bgmac_get_ethtool_stats,
-   .get_settings   = bgmac_get_settings,
-   .set_settings   = bgmac_set_settings,
.get_drvinfo= bgmac_get_drvinfo,
+   .get_link_ksettings = phy_ethtool_get_link_ksettings,
+   .set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 /**
-- 
1.7.4.4



[PATCH 1/2] net: ethernet: bgmac: use phydev from struct net_device

2016-06-19 Thread Philippe Reynes
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/bgmac.c |   17 ++---
 drivers/net/ethernet/broadcom/bgmac.h |1 -
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c 
b/drivers/net/ethernet/broadcom/bgmac.c
index 0ee34cc..90ed244 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1320,7 +1320,7 @@ static int bgmac_open(struct net_device *net_dev)
}
napi_enable(>napi);
 
-   phy_start(bgmac->phy_dev);
+   phy_start(net_dev->phydev);
 
netif_carrier_on(net_dev);
return 0;
@@ -1332,7 +1332,7 @@ static int bgmac_stop(struct net_device *net_dev)
 
netif_carrier_off(net_dev);
 
-   phy_stop(bgmac->phy_dev);
+   phy_stop(net_dev->phydev);
 
napi_disable(>napi);
bgmac_chip_intrs_off(bgmac);
@@ -1370,12 +1370,10 @@ static int bgmac_set_mac_address(struct net_device 
*net_dev, void *addr)
 
 static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
 {
-   struct bgmac *bgmac = netdev_priv(net_dev);
-
if (!netif_running(net_dev))
return -EINVAL;
 
-   return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
+   return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
 }
 
 static const struct net_device_ops bgmac_netdev_ops = {
@@ -1518,7 +1516,7 @@ static int bgmac_get_settings(struct net_device *net_dev,
 {
struct bgmac *bgmac = netdev_priv(net_dev);
 
-   return phy_ethtool_gset(bgmac->phy_dev, cmd);
+   return phy_ethtool_gset(net_dev->phydev, cmd);
 }
 
 static int bgmac_set_settings(struct net_device *net_dev,
@@ -1526,7 +1524,7 @@ static int bgmac_set_settings(struct net_device *net_dev,
 {
struct bgmac *bgmac = netdev_priv(net_dev);
 
-   return phy_ethtool_sset(bgmac->phy_dev, cmd);
+   return phy_ethtool_sset(net_dev->phydev, cmd);
 }
 
 static void bgmac_get_drvinfo(struct net_device *net_dev,
@@ -1563,7 +1561,7 @@ static int bgmac_mii_write(struct mii_bus *bus, int 
mii_id, int regnum,
 static void bgmac_adjust_link(struct net_device *net_dev)
 {
struct bgmac *bgmac = netdev_priv(net_dev);
-   struct phy_device *phy_dev = bgmac->phy_dev;
+   struct phy_device *phy_dev = net_dev->phydev;
bool update = false;
 
if (phy_dev->link) {
@@ -1607,8 +1605,6 @@ static int bgmac_fixed_phy_register(struct bgmac *bgmac)
return err;
}
 
-   bgmac->phy_dev = phy_dev;
-
return err;
 }
 
@@ -1653,7 +1649,6 @@ static int bgmac_mii_register(struct bgmac *bgmac)
err = PTR_ERR(phy_dev);
goto err_unregister_bus;
}
-   bgmac->phy_dev = phy_dev;
 
return err;
 
diff --git a/drivers/net/ethernet/broadcom/bgmac.h 
b/drivers/net/ethernet/broadcom/bgmac.h
index 853d72b..99beb18 100644
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -441,7 +441,6 @@ struct bgmac {
struct net_device *net_dev;
struct napi_struct napi;
struct mii_bus *mii_bus;
-   struct phy_device *phy_dev;
 
/* DMA */
struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];
-- 
1.7.4.4



Re: [PATCH net-next 0/8] tou: Transports over UDP - part I

2016-06-19 Thread Hajime Tazaki

On Fri, 17 Jun 2016 20:52:55 -0700,
Tom Herbert wrote:
> 
> > We also now have to debug against every single userland TCP
> > implementation someone can come up with, the barrier to entry is
> > insanely low with TOU.  Maybe this sounds great to you, but to me
> > it is quite terrifying
> >
> No, it doesn't sound great, but the major problem we have is that
> Android and to some extent iOS & Windows take a long time to update
> the kernel, and it can take an _extremely_ long time if we need them
> to actively enable features that are needed by applications. For
> instance, TFO was put in the Linux several years ago, but it still
> hasn't been enabled in Android and only fairly recently enabled in
> iOS. 

This is exactly the identical motivation what LibOS (now
joined to LKL) has - to have network stack personality.
Without having additional *layers* in the protocol header,
an application can freely benefit any protocol extensions
without updating their host kernel.

the performance is far lower than TOU at this stage (we also
have netperf benchmark results) but I'm positive to improve
this.

So, I would say why not LKL ?

* LKL
https://lwn.net/Articles/662953/

-- Hajime


Re: Micrel Phy KSZ8031 clock select setting in dts

2016-06-19 Thread Oliver Graute
On 17/06/16, Sergei Shtylyov wrote:
> On 06/17/2016 04:04 PM, Oliver Graute wrote:
> 
> >I try to enable a Micrel KSZ8031 in my imx6ul board device tree. But i'am
> >struggeling with the setting for KSZPHY_RMII_REF_CLK_SEL BIT(7). In my
> >revision of this Micrel KSZ8031 Phy the Bit(7) has to be true. The 0x1f
> >register must be 0x8180.
> >
> >How can I configure this register setting into my DTS?
> >
> >I already checked Documentation/devicetree/bindings/net/micrel.txt
> >
> >but i'am not sure if this still up to date. There where some reworks
> >after git commit 86dc1342
> >
> >some other commits related to this Phy clock setting I checked
> >
> >commit 1fadee0c3
> >commit b838b4aced
> >
> >my non working device tree blob for the phy is:
> >
> > {
> > pinctrl-names = "default";
> > pinctrl-0 = <_enet1>;
> > phy-mode = "rmii";
> > rmmi-ref-clk-sel = <1>;
> > phy-handle = <>;
> > status = "okay";
> >
> > mdio {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > ethphy0: ethernet-phy@0 {
> > compatible = "micrel,ksz8031";
> > reg = <0>;
> > };
> > };
> >};
> >
> >
> >some clue how to configure this phy register setting correctly?
> 
>Tried specifying "micrel,rmii-reference-clock-select-25-mhz"
> property in the PHY node?
> 

No, I expect my RMII reference clock on 50 MHz. So I thought that
rmii-reference-clock-select-25-mhz isn't the right setting for me here.

If I manually set bit 7 in the 0x1f register to true The Phy only works
until the next ifconfig eth0 up/down cycle. After the Phy Reset Bit 7 is
false again and Phy isn't working anymore.


Best Regards,

Oliver



[PATCH 2/2] net: ethernet: bcmsysport: use phy_ethtool_{get|set}_link_ksettings

2016-06-19 Thread Philippe Reynes
There are two generics functions phy_ethtool_{get|set}_link_ksettings,
so we can use them instead of defining the same code in the driver.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/bcmsysport.c |   22 ++
 1 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c 
b/drivers/net/ethernet/broadcom/bcmsysport.c
index 9775c78..834afbb 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -96,24 +96,6 @@ static inline void tdma_port_write_desc_addr(struct 
bcm_sysport_priv *priv,
 }
 
 /* Ethtool operations */
-static int bcm_sysport_set_settings(struct net_device *dev,
-   struct ethtool_cmd *cmd)
-{
-   if (!netif_running(dev))
-   return -EINVAL;
-
-   return phy_ethtool_sset(dev->phydev, cmd);
-}
-
-static int bcm_sysport_get_settings(struct net_device *dev,
-   struct ethtool_cmd *cmd)
-{
-   if (!netif_running(dev))
-   return -EINVAL;
-
-   return phy_ethtool_gset(dev->phydev, cmd);
-}
-
 static int bcm_sysport_set_rx_csum(struct net_device *dev,
   netdev_features_t wanted)
 {
@@ -1711,8 +1693,6 @@ static int bcm_sysport_stop(struct net_device *dev)
 }
 
 static struct ethtool_ops bcm_sysport_ethtool_ops = {
-   .get_settings   = bcm_sysport_get_settings,
-   .set_settings   = bcm_sysport_set_settings,
.get_drvinfo= bcm_sysport_get_drvinfo,
.get_msglevel   = bcm_sysport_get_msglvl,
.set_msglevel   = bcm_sysport_set_msglvl,
@@ -1724,6 +1704,8 @@ static struct ethtool_ops bcm_sysport_ethtool_ops = {
.set_wol= bcm_sysport_set_wol,
.get_coalesce   = bcm_sysport_get_coalesce,
.set_coalesce   = bcm_sysport_set_coalesce,
+   .get_link_ksettings = phy_ethtool_get_link_ksettings,
+   .set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 static const struct net_device_ops bcm_sysport_netdev_ops = {
-- 
1.7.4.4



[PATCH 1/2] net: ethernet: bcmsysport: use phydev from struct net_device

2016-06-19 Thread Philippe Reynes
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/bcmsysport.c |   31 ---
 drivers/net/ethernet/broadcom/bcmsysport.h |1 -
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c 
b/drivers/net/ethernet/broadcom/bcmsysport.c
index 543bf38..9775c78 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -99,23 +99,19 @@ static inline void tdma_port_write_desc_addr(struct 
bcm_sysport_priv *priv,
 static int bcm_sysport_set_settings(struct net_device *dev,
struct ethtool_cmd *cmd)
 {
-   struct bcm_sysport_priv *priv = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
 
-   return phy_ethtool_sset(priv->phydev, cmd);
+   return phy_ethtool_sset(dev->phydev, cmd);
 }
 
 static int bcm_sysport_get_settings(struct net_device *dev,
struct ethtool_cmd *cmd)
 {
-   struct bcm_sysport_priv *priv = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
 
-   return phy_ethtool_gset(priv->phydev, cmd);
+   return phy_ethtool_gset(dev->phydev, cmd);
 }
 
 static int bcm_sysport_set_rx_csum(struct net_device *dev,
@@ -1127,7 +1123,7 @@ static void bcm_sysport_tx_timeout(struct net_device *dev)
 static void bcm_sysport_adj_link(struct net_device *dev)
 {
struct bcm_sysport_priv *priv = netdev_priv(dev);
-   struct phy_device *phydev = priv->phydev;
+   struct phy_device *phydev = dev->phydev;
unsigned int changed = 0;
u32 cmd_bits = 0, reg;
 
@@ -1182,7 +1178,7 @@ static void bcm_sysport_adj_link(struct net_device *dev)
umac_writel(priv, reg, UMAC_CMD);
}
 
-   phy_print_status(priv->phydev);
+   phy_print_status(phydev);
 }
 
 static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,
@@ -1525,7 +1521,7 @@ static void bcm_sysport_netif_start(struct net_device 
*dev)
/* Enable RX interrupt and TX ring full interrupt */
intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
 
-   phy_start(priv->phydev);
+   phy_start(dev->phydev);
 
/* Enable TX interrupts for the 32 TXQs */
intrl2_1_mask_clear(priv, 0x);
@@ -1546,6 +1542,7 @@ static void rbuf_init(struct bcm_sysport_priv *priv)
 static int bcm_sysport_open(struct net_device *dev)
 {
struct bcm_sysport_priv *priv = netdev_priv(dev);
+   struct phy_device *phydev;
unsigned int i;
int ret;
 
@@ -1570,9 +1567,9 @@ static int bcm_sysport_open(struct net_device *dev)
/* Read CRC forward */
priv->crc_fwd = !!(umac_readl(priv, UMAC_CMD) & CMD_CRC_FWD);
 
-   priv->phydev = of_phy_connect(dev, priv->phy_dn, bcm_sysport_adj_link,
-   0, priv->phy_interface);
-   if (!priv->phydev) {
+   phydev = of_phy_connect(dev, priv->phy_dn, bcm_sysport_adj_link,
+   0, priv->phy_interface);
+   if (!phydev) {
netdev_err(dev, "could not attach to PHY\n");
return -ENODEV;
}
@@ -1650,7 +1647,7 @@ out_free_tx_ring:
 out_free_irq0:
free_irq(priv->irq0, dev);
 out_phy_disconnect:
-   phy_disconnect(priv->phydev);
+   phy_disconnect(phydev);
return ret;
 }
 
@@ -1661,7 +1658,7 @@ static void bcm_sysport_netif_stop(struct net_device *dev)
/* stop all software from updating hardware */
netif_tx_stop_all_queues(dev);
napi_disable(>napi);
-   phy_stop(priv->phydev);
+   phy_stop(dev->phydev);
 
/* mask all interrupts */
intrl2_0_mask_set(priv, 0x);
@@ -1708,7 +1705,7 @@ static int bcm_sysport_stop(struct net_device *dev)
free_irq(priv->irq1, dev);
 
/* Disconnect from PHY */
-   phy_disconnect(priv->phydev);
+   phy_disconnect(dev->phydev);
 
return 0;
 }
@@ -1929,7 +1926,7 @@ static int bcm_sysport_suspend(struct device *d)
 
bcm_sysport_netif_stop(dev);
 
-   phy_suspend(priv->phydev);
+   phy_suspend(dev->phydev);
 
netif_device_detach(dev);
 
@@ -2055,7 +2052,7 @@ static int bcm_sysport_resume(struct device *d)
goto out_free_rx_ring;
}
 
-   phy_resume(priv->phydev);
+   phy_resume(dev->phydev);
 
bcm_sysport_netif_start(dev);
 
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h 
b/drivers/net/ethernet/broadcom/bcmsysport.h
index f28bf54..1c82e3d 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -670,7 

Re: [PATCH net-next 2/2] net sched actions: skbedit add support for mod-ing skb pkt_type

2016-06-19 Thread Daniel Borkmann

On 06/18/2016 05:12 PM, Jamal Hadi Salim wrote:

From: Jamal Hadi Salim 

Extremely useful for setting packet type to host so i dont
have to modify the dst mac address using pedit (which requires
that i know the mac address)

Example usage:
tc filter add dev eth0 parent : protocol ip pref 9 u32 \
match ip src 5.5.5.5/32 \
flowid 1:5 action skbedit ptype host

This will tag all packets incoming from 5.5.5.5 with type
PACKET_HOST

Signed-off-by: Jamal Hadi Salim 
---
  include/net/tc_act/tc_skbedit.h| 10 +-
  include/uapi/linux/tc_act/tc_skbedit.h |  2 ++
  net/sched/act_skbedit.c| 18 +-
  3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/include/net/tc_act/tc_skbedit.h b/include/net/tc_act/tc_skbedit.h
index b496d5a..d01a5d4 100644
--- a/include/net/tc_act/tc_skbedit.h
+++ b/include/net/tc_act/tc_skbedit.h
@@ -24,11 +24,11 @@

  struct tcf_skbedit {
struct tcf_common   common;
-   u32 flags;
-   u32 priority;
-   u32 mark;
-   u16 queue_mapping;
-   /* XXX: 16-bit pad here? */
+   u32 flags;
+   u32 priority;
+   u32 mark;
+   u16 queue_mapping;
+   u16 ptype;
  };
  #define to_skbedit(a) \
container_of(a->priv, struct tcf_skbedit, common)
diff --git a/include/uapi/linux/tc_act/tc_skbedit.h 
b/include/uapi/linux/tc_act/tc_skbedit.h
index fecb5cc..a4d00c6 100644
--- a/include/uapi/linux/tc_act/tc_skbedit.h
+++ b/include/uapi/linux/tc_act/tc_skbedit.h
@@ -27,6 +27,7 @@
  #define SKBEDIT_F_PRIORITY0x1
  #define SKBEDIT_F_QUEUE_MAPPING   0x2
  #define SKBEDIT_F_MARK0x4
+#define SKBEDIT_F_PTYPE0x8

  struct tc_skbedit {
tc_gen;
@@ -40,6 +41,7 @@ enum {
TCA_SKBEDIT_QUEUE_MAPPING,
TCA_SKBEDIT_MARK,
TCA_SKBEDIT_PAD,
+   TCA_SKBEDIT_PTYPE,
__TCA_SKBEDIT_MAX
  };
  #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1)
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index 53d1486..1c4c924 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -47,6 +47,8 @@ static int tcf_skbedit(struct sk_buff *skb, const struct 
tc_action *a,
skb_set_queue_mapping(skb, d->queue_mapping);
if (d->flags & SKBEDIT_F_MARK)
skb->mark = d->mark;
+   if (d->flags & SKBEDIT_F_PTYPE)
+   skb->pkt_type = d->ptype;

spin_unlock(>tcf_lock);
return d->tcf_action;
@@ -57,6 +59,7 @@ static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX 
+ 1] = {
[TCA_SKBEDIT_PRIORITY]  = { .len = sizeof(u32) },
[TCA_SKBEDIT_QUEUE_MAPPING] = { .len = sizeof(u16) },
[TCA_SKBEDIT_MARK]  = { .len = sizeof(u32) },
+   [TCA_SKBEDIT_PTYPE] = { .len = sizeof(u16) },
  };

  static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
@@ -68,7 +71,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr 
*nla,
struct tc_skbedit *parm;
struct tcf_skbedit *d;
u32 flags = 0, *priority = NULL, *mark = NULL;
-   u16 *queue_mapping = NULL;
+   u16 *queue_mapping = NULL, *ptype = NULL;
bool exists = false;
int ret = 0, err;

@@ -92,6 +95,13 @@ static int tcf_skbedit_init(struct net *net, struct nlattr 
*nla,
queue_mapping = nla_data(tb[TCA_SKBEDIT_QUEUE_MAPPING]);
}

+   if (tb[TCA_SKBEDIT_PTYPE] != NULL) {
+   ptype = nla_data(tb[TCA_SKBEDIT_PTYPE]);
+   if (!skb_pkt_type_ok(*ptype))
+   return -EINVAL;
+   flags |= SKBEDIT_F_PTYPE;
+   }
+
if (tb[TCA_SKBEDIT_MARK] != NULL) {
flags |= SKBEDIT_F_MARK;
mark = nla_data(tb[TCA_SKBEDIT_MARK]);
@@ -132,6 +142,8 @@ static int tcf_skbedit_init(struct net *net, struct nlattr 
*nla,
d->queue_mapping = *queue_mapping;
if (flags & SKBEDIT_F_MARK)
d->mark = *mark;
+   if (flags & SKBEDIT_F_PTYPE)
+   d->ptype = *ptype;

d->tcf_action = parm->action;

@@ -169,6 +181,10 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct 
tc_action *a,
nla_put(skb, TCA_SKBEDIT_MARK, sizeof(d->mark),
>mark))
goto nla_put_failure;
+   if ((d->flags & SKBEDIT_F_PTYPE) &&
+   nla_put(skb, TCA_SKBEDIT_PTYPE, sizeof(d->ptype),
+   >ptype))


We already have things like nla_put_u16() etc, would be good to use them here,
doesn't have to be in this set, though, but rather as follow-up since it's used
like this also for other attributes.


+   goto nla_put_failure;

tcf_tm_dump(, >tcf_tm);
if (nla_put_64bit(skb, TCA_SKBEDIT_TM, 

Re: [net-next,v3] openvswitch: Add packet len info to upcall.

2016-06-19 Thread pravin shelar
On Fri, Jun 17, 2016 at 12:52 PM, William Tu  wrote:
> The commit f2a4d086ed4c ("openvswitch: Add packet truncation support.")
> introduces packet truncation before sending to userspace upcall receiver.
> This patch passes up the skb->len before truncation so that the upcall
> receiver knows the original packet size. Potentially this will be used
> by sFlow, where OVS translates sFlow config header=N to a sample action,
> truncating packet to N byte in kernel datapath. Thus, only N bytes instead
> of full-packet size is copied from kernel to userspace, saving the
> kernel-to-userspace bandwidth.
>
> Signed-off-by: William Tu 
> Cc: Pravin Shelar 
> ---
> v2->v3:
> - remove platform specific name.
> - fix issue when receiving GSO packet
> - remove skblen in struct dp_upcall_info
> v1->v2:
> - pass skb->len to userspace instead of cutlen
> ---
>  include/uapi/linux/openvswitch.h |  2 ++
>  net/openvswitch/datapath.c   | 11 ++-
>  2 files changed, 12 insertions(+), 1 deletion(-)
>

Patch looks good, I just have one minor comment.

> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index 6739342..623fc04 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -387,7 +387,8 @@ static size_t upcall_msg_size(const struct dp_upcall_info 
> *upcall_info,
>  {
> size_t size = NLMSG_ALIGN(sizeof(struct ovs_header))
> + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */
> -   + nla_total_size(ovs_key_attr_size()); /* OVS_PACKET_ATTR_KEY 
> */
> +   + nla_total_size(ovs_key_attr_size()) /* OVS_PACKET_ATTR_KEY 
> */
> +   + nla_total_size(sizeof(unsigned int)); /* 
> OVS_PACKET_ATTR_LEN */
>
> /* OVS_PACKET_ATTR_USERDATA */
> if (upcall_info->userdata)
> @@ -514,6 +515,14 @@ static int queue_userspace_packet(struct datapath *dp, 
> struct sk_buff *skb,
> pad_packet(dp, user_skb);
> }
>
> +   /* Add OVS_PACKET_ATTR_LEN */
> +   if (nla_put_u32(user_skb, OVS_PACKET_ATTR_LEN,
> +   skb->len)) {
> +   err = -ENOBUFS;
> +   goto out;
> +   }
> +   pad_packet(dp, user_skb);
> +
We should only send packet length in case of truncated packet. This
would avoid sending this extra attribute in miss flow handling case.


Re: [PATCH net-next 1/2] net: simplify and make pkt_type_ok() available for other users

2016-06-19 Thread Daniel Borkmann

Hi Jamal,

On 06/18/2016 05:12 PM, Jamal Hadi Salim wrote:

From: Jamal Hadi Salim 

Suggested-by: Daniel Borkmann 
Signed-off-by: Jamal Hadi Salim 
---
  include/linux/skbuff.h   | 11 +++
  net/netfilter/nft_meta.c |  9 +
  2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index dc0fca7..0b794de 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -37,6 +37,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 

  /* The interface for checksum offload between the stack and networking drivers
@@ -797,6 +798,7 @@ struct sk_buff {
atomic_tusers;
  };

+


Why the extra newline here (the rest looks good)?


  #ifdef __KERNEL__
  /*
   *Handling routines are only of interest to the kernel
@@ -881,6 +883,15 @@ static inline struct rtable *skb_rtable(const struct 
sk_buff *skb)
return (struct rtable *)skb_dst(skb);
  }

+/* For mangling skb->pkt_type from user space side from applications
+ * such as nft, tc, etc, we only allow a conservative subset of
+ * possible pkt_types to be set.
+*/
+static inline bool skb_pkt_type_ok(u32 p)
+{
+   return p <= PACKET_OTHERHOST;


Just a small nit: I would probably rename 'p' into 'type'.


+}
+
  void kfree_skb(struct sk_buff *skb);
  void kfree_skb_list(struct sk_buff *segs);
  void skb_tx_error(struct sk_buff *skb);
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 16c50b0..03e5e33 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -199,13 +199,6 @@ err:
  }
  EXPORT_SYMBOL_GPL(nft_meta_get_eval);

-/* don't change or set _LOOPBACK, _USER, etc. */
-static bool pkt_type_ok(u32 p)
-{
-   return p == PACKET_HOST || p == PACKET_BROADCAST ||
-  p == PACKET_MULTICAST || p == PACKET_OTHERHOST;
-}
-
  void nft_meta_set_eval(const struct nft_expr *expr,
   struct nft_regs *regs,
   const struct nft_pktinfo *pkt)
@@ -223,7 +216,7 @@ void nft_meta_set_eval(const struct nft_expr *expr,
break;
case NFT_META_PKTTYPE:
if (skb->pkt_type != value &&
-   pkt_type_ok(value) && pkt_type_ok(skb->pkt_type))
+   skb_pkt_type_ok(value) && skb_pkt_type_ok(skb->pkt_type))
skb->pkt_type = value;
break;
case NFT_META_NFTRACE:





Re: [PATCH 2/2] net: ethernet: nb8800: use phy_ethtool_{get|set}_link_ksettings

2016-06-19 Thread David Miller
From: Philippe Reynes 
Date: Sat, 18 Jun 2016 23:16:55 +0200

> There are two generics functions phy_ethtool_{get|set}_link_ksettings,
> so we can use them instead of defining the same code in the driver.
> 
> Signed-off-by: Philippe Reynes 

Applied.


Re: [PATCH 1/2] net: ethernet: nb8800: use phydev from struct net_device

2016-06-19 Thread David Miller
From: Philippe Reynes 
Date: Sat, 18 Jun 2016 23:16:54 +0200

> The private structure contain a pointer to phydev, but the structure
> net_device already contain such pointer. So we can remove the pointer
> phydev in the private structure, and update the driver to use the
> one contained in struct net_device.
> 
> Signed-off-by: Philippe Reynes 

Applied.


Re: [PATCH] ppc: Fix BPF JIT for ABIv2

2016-06-19 Thread Naveen N. Rao
On 2016/06/17 10:00AM, Thadeu Lima de Souza Cascardo wrote:
> On Fri, Jun 17, 2016 at 10:53:21PM +1000, Michael Ellerman wrote:
> > On Tue, 2016-07-06 at 13:32:23 UTC, "Naveen N. Rao" wrote:
> > > diff --git a/arch/powerpc/net/bpf_jit_comp64.c 
> > > b/arch/powerpc/net/bpf_jit_comp64.c
> > > new file mode 100644
> > > index 000..954ff53
> > > --- /dev/null
> > > +++ b/arch/powerpc/net/bpf_jit_comp64.c
> > > @@ -0,0 +1,956 @@
> > ...
> > > +
> > > +static void bpf_jit_fill_ill_insns(void *area, unsigned int size)
> > > +{
> > > + int *p = area;
> > > +
> > > + /* Fill whole space with trap instructions */
> > > + while (p < (int *)((char *)area + size))
> > > + *p++ = BREAKPOINT_INSTRUCTION;
> > > +}
> > 
> > This breaks the build for some configs, presumably you're missing a header:
> > 
> >   arch/powerpc/net/bpf_jit_comp64.c:30:10: error: 'BREAKPOINT_INSTRUCTION' 
> > undeclared (first use in this function)
> > 
> > http://kisskb.ellerman.id.au/kisskb/buildresult/12720611/
> > 
> > cheers
> 
> Hi, Michael and Naveen.
> 
> I noticed independently that there is a problem with BPF JIT and ABIv2, and
> worked out the patch below before I noticed Naveen's patchset and the latest
> changes in ppc tree for a better way to check for ABI versions.
> 
> However, since the issue described below affect mainline and stable kernels,
> would you consider applying it before merging your two patchsets, so that we 
> can
> more easily backport the fix?

Hi Cascardo,
Given that this has been broken on ABIv2 since forever, I didn't bother 
fixing it. But, I can see why this would be a good thing to have for 
-stable and existing distros. However, while your patch below may fix 
the crash you're seeing on ppc64le, it is not sufficient -- you'll need 
changes in bpf_jit_asm.S as well.

Regards,
Naveen



Re: [PATCH net 0/5] qed*: Fixes series

2016-06-19 Thread David Miller
From: Yuval Mintz 
Date: Sun, 19 Jun 2016 15:18:10 +0300

> This series contains several small fixes to driver behavior
> [4th patch is the only one containing a 'fatal' fix, but the error
> is only theoretical for qede; if would require another protocol
> driver yet unsubmitted to reach it].

Series applied, thanks.


Re: [6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF

2016-06-19 Thread Naveen N. Rao
On 2016/06/17 10:53PM, Michael Ellerman wrote:
> On Tue, 2016-07-06 at 13:32:23 UTC, "Naveen N. Rao" wrote:
> > diff --git a/arch/powerpc/net/bpf_jit_comp64.c 
> > b/arch/powerpc/net/bpf_jit_comp64.c
> > new file mode 100644
> > index 000..954ff53
> > --- /dev/null
> > +++ b/arch/powerpc/net/bpf_jit_comp64.c
> > @@ -0,0 +1,956 @@
> ...
> > +
> > +static void bpf_jit_fill_ill_insns(void *area, unsigned int size)
> > +{
> > +   int *p = area;
> > +
> > +   /* Fill whole space with trap instructions */
> > +   while (p < (int *)((char *)area + size))
> > +   *p++ = BREAKPOINT_INSTRUCTION;
> > +}
> 
> This breaks the build for some configs, presumably you're missing a header:
> 
>   arch/powerpc/net/bpf_jit_comp64.c:30:10: error: 'BREAKPOINT_INSTRUCTION' 
> undeclared (first use in this function)
> 
> http://kisskb.ellerman.id.au/kisskb/buildresult/12720611/

Oops. Yes, I should have caught that. I need to add:

#include 

in bpf_jit_comp64.c

Can you please check if it resolves the build error?

Regards,
Naveen



[PATCH V2 RFC 1/2] brcmfmac: delete interface directly in code that sent fw request

2016-06-19 Thread Rafał Miłecki
So far when receiving event about in-firmware-interface removal our
event worker was notifying listener and afterwards it was removing Linux
interface.

First of all it was resulting in slightly unexpected order. The listener
(del_virtual_intf callback) was (usually) returning with success before
we even called unregister_netdev(ice).

Please note this couldn't be simply fixed by changing order of calls in
brcmf_fweh_handle_if_event as unregistering interface earlier could free
struct brcmf_if.

Another problem of current implementation are possible lockups. Focus on
the time slot between calling event handler and removing Linux
interface. During that time original caller may leave (unlocking rtnl
semaphore) *and* another call to the same code may be done (locking it
again). If that happens our event handler will stuck at removing Linux
interface, it won't handle another event and will block process holding
rtnl lock.

This can be simply solved by unregistering interface in a proper
callback, right after receiving confirmation event from firmware. This
only required modifying worker to don't unregister on its own if there
is someone waiting for the event.

Signed-off-by: Rafał Miłecki 
---
V2: Modification of brcmf_fweh_handle_if_event done in V1 was a wrong
idea as it could result in use-after-free regarding struct brcmf_if.
Thanks Arend for noticing that!
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 10 --
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c  |  3 +--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
index 9da7a4c..79c081f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
@@ -18,6 +18,7 @@
 #include "brcmu_wifi.h"
 #include "brcmu_utils.h"
 
+#include "cfg80211.h"
 #include "core.h"
 #include "debug.h"
 #include "tracepoint.h"
@@ -182,8 +183,13 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub 
*drvr,
 
err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
 
-   if (ifp && ifevent->action == BRCMF_E_IF_DEL)
-   brcmf_remove_interface(ifp, false);
+   if (ifp && ifevent->action == BRCMF_E_IF_DEL) {
+   bool armed = brcmf_cfg80211_vif_event_armed(drvr->config);
+
+   /* Default handling in case no-one waits for this event */
+   if (!armed)
+   brcmf_remove_interface(ifp, false);
+   }
 }
 
 /**
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
index f6241fd..66f942f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
@@ -2288,8 +2288,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct 
wireless_dev *wdev)
else
err = 0;
}
-   if (err)
-   brcmf_remove_interface(vif->ifp, true);
+   brcmf_remove_interface(vif->ifp, true);
 
brcmf_cfg80211_arm_vif_event(cfg, NULL);
if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
-- 
1.8.4.5



[PATCH V2 RFC 2/2] brcmfmac: support removing AP interfaces with "interface_remove"

2016-06-19 Thread Rafał Miłecki
New firmwares (e.g. 10.10.69.36 for BCM4366) support "interface_remove"
for removing interfaces. Try to use this method on cfg80211 request. In
case of older firmwares (e.g. 7.35.177.56 for BCM43602 as I tested) this
will just result in firmware rejecting command and this won't change any
behavior.

Signed-off-by: Rafał Miłecki 
---
V2: Add extra chcek for ndev. Thanks Arend.
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 39 +-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 502b0a0..1e411dc 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -785,12 +785,48 @@ s32 brcmf_notify_escan_complete(struct 
brcmf_cfg80211_info *cfg,
return err;
 }
 
+static int brcmf_cfg80211_del_ap_iface(struct wiphy *wiphy,
+  struct wireless_dev *wdev)
+{
+   struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+   struct net_device *ndev = wdev->netdev;
+   struct brcmf_if *ifp = netdev_priv(ndev);
+   int ret;
+   int err;
+
+   brcmf_cfg80211_arm_vif_event(cfg, ifp->vif);
+
+   err = brcmf_fil_bsscfg_data_set(ifp, "interface_remove", NULL, 0);
+   if (err) {
+   brcmf_err("interface_remove failed %d\n", err);
+   goto err_unarm;
+   }
+
+   /* wait for firmware event */
+   ret = brcmf_cfg80211_wait_vif_event(cfg, BRCMF_E_IF_DEL,
+   BRCMF_VIF_EVENT_TIMEOUT);
+   if (!ret) {
+   brcmf_err("timeout occurred\n");
+   err = -EIO;
+   goto err_unarm;
+   }
+
+   brcmf_remove_interface(ifp, true);
+
+err_unarm:
+   brcmf_cfg80211_arm_vif_event(cfg, NULL);
+   return err;
+}
+
 static
 int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
 {
struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
struct net_device *ndev = wdev->netdev;
 
+   if (ndev && ndev == cfg_to_ndev(cfg))
+   return -ENOTSUPP;
+
/* vif event pending in firmware */
if (brcmf_cfg80211_vif_event_armed(cfg))
return -EBUSY;
@@ -807,12 +843,13 @@ int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct 
wireless_dev *wdev)
switch (wdev->iftype) {
case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_STATION:
-   case NL80211_IFTYPE_AP:
case NL80211_IFTYPE_AP_VLAN:
case NL80211_IFTYPE_WDS:
case NL80211_IFTYPE_MONITOR:
case NL80211_IFTYPE_MESH_POINT:
return -EOPNOTSUPP;
+   case NL80211_IFTYPE_AP:
+   return brcmf_cfg80211_del_ap_iface(wiphy, wdev);
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_P2P_DEVICE:
-- 
1.8.4.5



Re: [very-RFC 0/8] TSN driver for the kernel

2016-06-19 Thread Takashi Sakamoto

(remove C.C. to lkml. This is not so major feature.)

On Jun 19 2916 07:45, Henrik Austad wrote:

snip

802.1Q gives you low latency through the network, but more importantly, no
dropped frames. gPTP gives you a central reference to time.


When such a long message is required, it means that we don't have enough 
premises for this discussion.


You have just interests in gPTP and transferring AVTPDUs, while no 
interests in the others such as "what the basic ideas of TSN come from" 
and "the reason that IEEE 1722 refers to IEC 61883 series which is 
originally designed for IEEE 1394 bus" and "the reason that I was 
motivated to join in this discussion even though not a netdev developer".


Here, could I ask you a question? Do you know a role of cycle start 
packet of IEEE Std 1394?


If you think it's not related to this discussion, please tell it to me. 
Then I'll drop out from this thread.



History Repeats itself.

Takashi Sakamoto


Re: [PATCH 12/15] net: davinci_mdio: document missed "ti,am4372-mdio" compat string

2016-06-19 Thread Rob Herring
On Wed, Jun 15, 2016 at 02:56:00PM +0300, Grygorii Strashko wrote:
> Document missed "ti,am4372-mdio" compat string used for TI am437x SoC
> (am4372.dtsi).
> 
> Signed-off-by: Grygorii Strashko 
> ---
>  Documentation/devicetree/bindings/net/davinci-mdio.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/davinci-mdio.txt 
> b/Documentation/devicetree/bindings/net/davinci-mdio.txt
> index 0369e25..f2bba50 100644
> --- a/Documentation/devicetree/bindings/net/davinci-mdio.txt
> +++ b/Documentation/devicetree/bindings/net/davinci-mdio.txt
> @@ -2,7 +2,8 @@ TI SoC Davinci/Keystone2 MDIO Controller Device Tree Bindings
>  ---
>  
>  Required properties:
> -- compatible : Should be "ti,davinci_mdio" or "ti,keystone_mdio"
> +- compatible : Should be "ti,davinci_mdio", "ti,keystone_mdio",
> +   "ti,am4372-mdio"

This is still an OR relationship?

It's preferred to list one per line.

>  - reg: physical base address and size of the davinci 
> mdio
> registers map
>  - bus_freq   : Mdio Bus frequency
> -- 
> 2.8.4
> 


Re: [PATCH net-next 12/18] IB/mlx5: Add kernel offload flow-tag

2016-06-19 Thread Saeed Mahameed
On Sat, Jun 18, 2016 at 2:34 AM, Eric Dumazet  wrote:
> On Fri, Jun 17, 2016 at 3:31 PM, Saeed Mahameed
>  wrote:
>>
>> Today there are some bad usages and abuse to skb->protocol where some
>> device drivers set skb->protocol = 0xff to skip the kernel TCP/IP
>> processing for the same diagnostic purposes.
>> In this series we are just trying to do the right thing.
>
> Well, your patch adds an extra test in kernel fast path, just to ease
> the life of people using kernel bypass,
> but willing to use tcpdump because they can not figure to do this in
> user space properly.
>
> Please find a way  _not_ adding a single instruction in kernel fast path.
>

Well, we can set skb->protocol = 0x.
what do you think ?


Re: [PATCH] [v5] net: emac: emac gigabit ethernet controller driver

2016-06-19 Thread Rob Herring
On Tue, Jun 14, 2016 at 05:22:35PM -0500, Timur Tabi wrote:
> Add supports for ethernet controller HW on Qualcomm Technologies, Inc. SoC.
> This driver supports the following features:
> 1) Checksum offload.
> 2) Interrupt coalescing support.
> 3) SGMII phy.
> 4) phylib interface for external phy
> 
> Based on original work by
>   Niranjana Vishwanathapura 
>   Gilad Avidov 
> 
> Signed-off-by: Timur Tabi 
> ---
> 
> v5:
>  - changed author to Timur, added MAINTAINERS entry
>  - use phylib, replacing internal phy code
>  - added support for EMAC internal SGMII v2
>  - fix ~DIS_INT warning
>  - update DT bindings, including removing unused properties
>  - removed interrupt handler for internal sgmii
>  - removed link status check handler/state (replaced with phylib)
>  - removed periodic timer handler (replaced with phylib)
>  - removed power management code (will be rewritten later)
>  - external phy is now required, not optional
>  - removed redundant EMAC_STATUS_DOWN status flag
>  - removed redundant link status and speed variables
>  - removed redundant status bits (vlan strip, promiscuous, loopback, etc)
>  - removed useless watchdog status
>  - removed command-line parameters
>  - cleaned up probe messages
>  - removed redundant params from emac_sgmii_link_init()
>  - always call netdev_completed_queue() (per review comment)
>  - fix emac_napi_rtx() (per review comment)
>  - removed max_ints loop in interrupt handler
>  - removed redundant mutex around phy read/write calls
>  - added lock for reading emac status (per review comment)
>  - generate random MAC address if it can't be read from firmware
>  - replace EMAC_DMA_ADDR_HI/LO with upper/lower_32_bits
>  - don't test return value from platform_get_resource (per review comment)
>  - use net_warn_ratelimited (per review comment)
>  - don't set the dma masks (will be set by DT or IORT code)
>  - remove unused emac_tx_tpd_ts_save()
>  - removed redundant local MTU variable
> 
> v4:
>  - add missing ipv6 header file
>  - correct compatible string
>  - fix spacing in emac_reg_write arrays
>  - drop unnecessary cell-index property
>  - remove unsupported DT properties from docs
>  - remove GPIO initialization and update docs
> 
> v3:
>  - remove most of the memory barriers by using the non xxx_relaxed() api.
>  - remove RSS and WOL support.
>  - correct comments from physical address to dma address.
>  - rearrange structs to make them packed.
>  - replace polling loops with readl_poll_timeout().
>  - remove unnecessary wrapper functions from phy layer.
>  - add blank line before return statements.
>  - set to null clocks after clk_put().
>  - use module_platform_driver() and dma_set_mask_and_coherent()
>  - replace long hex bitmasks with BIT() macro.
> 
> v2:
>  - replace hw bit fields to macros with bitwise operations.
>  - change all iterators to unsized types (int)
>  - some minor code flow improvements.
>  - change return type to void for functions which return value is never
>used.
>  - replace instance of l_relaxed() io followed by mb() with a
>readl()/writel().
> 
> 
>  .../devicetree/bindings/net/qcom-emac.txt  |   66 +
>  MAINTAINERS|6 +
>  drivers/net/ethernet/qualcomm/Kconfig  |   11 +
>  drivers/net/ethernet/qualcomm/Makefile |2 +
>  drivers/net/ethernet/qualcomm/emac/Makefile|7 +
>  drivers/net/ethernet/qualcomm/emac/emac-mac.c  | 1674 
> 
>  drivers/net/ethernet/qualcomm/emac/emac-mac.h  |  284 
>  drivers/net/ethernet/qualcomm/emac/emac-phy.c  |  211 +++
>  drivers/net/ethernet/qualcomm/emac/emac-phy.h  |   32 +
>  drivers/net/ethernet/qualcomm/emac/emac-sgmii.c|  699 
>  drivers/net/ethernet/qualcomm/emac/emac-sgmii.h|   24 +
>  drivers/net/ethernet/qualcomm/emac/emac.c  |  798 ++
>  drivers/net/ethernet/qualcomm/emac/emac.h  |  370 +
>  13 files changed, 4184 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/qcom-emac.txt
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/Makefile
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-mac.c
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-mac.h
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-phy.c
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-phy.h
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii.h
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac.c
>  create mode 100644 drivers/net/ethernet/qualcomm/emac/emac.h
> 
> diff --git a/Documentation/devicetree/bindings/net/qcom-emac.txt 
> b/Documentation/devicetree/bindings/net/qcom-emac.txt
> new file mode 100644
> index 000..e48a9b9
> --- /dev/null
> +++ 

[PATCH net 3/5] qed*: Don't reset statistics on inner reload

2016-06-19 Thread Yuval Mintz
Several user APIs can cause driver to perform an inner-reload.
Currently, doing this would cause the HW/FW statistics of the
adapter to reset, which isn't the expected behavior [statistics
should only reset on explicit unloads].

Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_l2.c | 3 ++-
 drivers/net/ethernet/qlogic/qede/qede_main.c | 7 ---
 include/linux/qed/qed_eth_if.h   | 1 +
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c 
b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index 0e8d43c..90be67e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -1745,7 +1745,8 @@ static int qed_start_vport(struct qed_dev *cdev,
   start.vport_id, start.mtu);
}
 
-   qed_reset_vport_stats(cdev);
+   if (params->clear_stats)
+   qed_reset_vport_stats(cdev);
 
return 0;
 }
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c 
b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 5733d18..f8e11f9 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -3231,7 +3231,7 @@ static int qede_stop_queues(struct qede_dev *edev)
return rc;
 }
 
-static int qede_start_queues(struct qede_dev *edev)
+static int qede_start_queues(struct qede_dev *edev, bool clear_stats)
 {
int rc, tc, i;
int vlan_removal_en = 1;
@@ -3462,6 +3462,7 @@ out:
 
 enum qede_load_mode {
QEDE_LOAD_NORMAL,
+   QEDE_LOAD_RELOAD,
 };
 
 static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
@@ -3500,7 +3501,7 @@ static int qede_load(struct qede_dev *edev, enum 
qede_load_mode mode)
goto err3;
DP_INFO(edev, "Setup IRQs succeeded\n");
 
-   rc = qede_start_queues(edev);
+   rc = qede_start_queues(edev, mode != QEDE_LOAD_RELOAD);
if (rc)
goto err4;
DP_INFO(edev, "Start VPORT, RXQ and TXQ succeeded\n");
@@ -3555,7 +3556,7 @@ void qede_reload(struct qede_dev *edev,
if (func)
func(edev, args);
 
-   qede_load(edev, QEDE_LOAD_NORMAL);
+   qede_load(edev, QEDE_LOAD_RELOAD);
 
mutex_lock(>qede_lock);
qede_config_rx_mode(edev->ndev);
diff --git a/include/linux/qed/qed_eth_if.h b/include/linux/qed/qed_eth_if.h
index 6ae8cb4..6c876a6 100644
--- a/include/linux/qed/qed_eth_if.h
+++ b/include/linux/qed/qed_eth_if.h
@@ -49,6 +49,7 @@ struct qed_start_vport_params {
bool drop_ttl0;
u8 vport_id;
u16 mtu;
+   bool clear_stats;
 };
 
 struct qed_stop_rxq_params {
-- 
1.9.3



[PATCH net 4/5] qed: Fix returning unlimited SPQ entries

2016-06-19 Thread Yuval Mintz
Driver has 2 sets of entries for handling ramrod configurations
toward firmware - a regular pre-allocated set of entires and a
possible 'unlimited' list of additional pending entries.

In most scenarios the 'unlimited' list would not be used, but
when it does the handling of the ramrod completion doesn't
properly handle the release of the entry.

Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_spq.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c 
b/drivers/net/ethernet/qlogic/qed/qed_spq.c
index acac662..67d9893 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_spq.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c
@@ -614,7 +614,9 @@ qed_spq_add_entry(struct qed_hwfn *p_hwfn,
 
*p_en2 = *p_ent;
 
-   kfree(p_ent);
+   /* EBLOCK responsible to free the allocated p_ent */
+   if (p_ent->comp_mode != QED_SPQ_MODE_EBLOCK)
+   kfree(p_ent);
 
p_ent = p_en2;
}
@@ -749,6 +751,15 @@ int qed_spq_post(struct qed_hwfn *p_hwfn,
 * Thus, after gaining the answer perform the cleanup here.
 */
rc = qed_spq_block(p_hwfn, p_ent, fw_return_code);
+
+   if (p_ent->queue == _spq->unlimited_pending) {
+   /* This is an allocated p_ent which does not need to
+* return to pool.
+*/
+   kfree(p_ent);
+   return rc;
+   }
+
if (rc)
goto spq_post_fail2;
 
@@ -844,8 +855,12 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn,
found->comp_cb.function(p_hwfn, found->comp_cb.cookie, p_data,
fw_return_code);
 
-   if (found->comp_mode != QED_SPQ_MODE_EBLOCK)
-   /* EBLOCK is responsible for freeing its own entry */
+   if ((found->comp_mode != QED_SPQ_MODE_EBLOCK) ||
+   (found->queue == _spq->unlimited_pending))
+   /* EBLOCK  is responsible for returning its own entry into the
+* free list, unless it originally added the entry into the
+* unlimited pending list.
+*/
qed_spq_return_entry(p_hwfn, found);
 
/* Attempt to post pending requests */
-- 
1.9.3



[PATCH net 5/5] qed: Add missing port-mode

2016-06-19 Thread Yuval Mintz
The 'MODULE_FIBER' value replaced several other FIBER values
in newer management firmware images, so existing code would
fail to properly reflect its mode.

Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h  | 1 +
 drivers/net/ethernet/qlogic/qed/qed_main.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index 9afc15f..e29ed5a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -3700,6 +3700,7 @@ struct public_port {
 #define MEDIA_DA_TWINAX 0x3
 #define MEDIA_BASE_T0x4
 #define MEDIA_SFP_1G_FIBER  0x5
+#define MEDIA_MODULE_FIBER  0x6
 #define MEDIA_KR0xf0
 #define MEDIA_NOT_PRESENT   0xff
 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 61cc686..c7e01b3 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -1085,6 +1085,7 @@ static int qed_get_port_type(u32 media_type)
case MEDIA_SFPP_10G_FIBER:
case MEDIA_SFP_1G_FIBER:
case MEDIA_XFP_FIBER:
+   case MEDIA_MODULE_FIBER:
case MEDIA_KR:
port_type = PORT_FIBRE;
break;
-- 
1.9.3



[PATCH net 0/5] qed*: Fixes series

2016-06-19 Thread Yuval Mintz
This series contains several small fixes to driver behavior
[4th patch is the only one containing a 'fatal' fix, but the error
is only theoretical for qede; if would require another protocol
driver yet unsubmitted to reach it].

Dave,

Please consider applying this to `net'.

Thanks,
Yuval

Yuval Mintz (5):
  qed: Correct default vlan behavior
  qed: Prevent VF from Tx-switching 'promisc'
  qed*: Don't reset statistics on inner reload
  qed: Fix returning unlimited SPQ entries
  qed: Add missing port-mode

 drivers/net/ethernet/qlogic/qed/qed_hsi.h|  1 +
 drivers/net/ethernet/qlogic/qed/qed_l2.c |  8 +++-
 drivers/net/ethernet/qlogic/qed/qed_main.c   |  1 +
 drivers/net/ethernet/qlogic/qed/qed_spq.c| 21 ++---
 drivers/net/ethernet/qlogic/qede/qede_main.c |  7 ---
 include/linux/qed/qed_eth_if.h   |  1 +
 6 files changed, 28 insertions(+), 11 deletions(-)

-- 
1.9.3



[PATCH net 2/5] qed: Prevent VF from Tx-switching 'promisc'

2016-06-19 Thread Yuval Mintz
Internal loopback in driver is based on two things - first
is the willingness of transmitter to use it [in case of VFs,
this can be forced based on VEPA/VEB] and secondly on another
vport classification configuration which should match the
packet's destination.

Current code allows non-linux VFs to configure a 'promisc'
mode on Tx, meaning all traffic sent by VF would be loopbacked
internally by firmware; This isn't considered a valid mode and
as such should be prevented by PF.

Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_l2.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c 
b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index 1aaea83..0e8d43c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -248,10 +248,6 @@ qed_sp_update_accept_mode(struct qed_hwfn *p_hwfn,
SET_FIELD(state, ETH_VPORT_TX_MODE_UCAST_DROP_ALL,
  !!(accept_filter & QED_ACCEPT_NONE));
 
-   SET_FIELD(state, ETH_VPORT_TX_MODE_UCAST_ACCEPT_ALL,
- (!!(accept_filter & QED_ACCEPT_UCAST_MATCHED) &&
-  !!(accept_filter & QED_ACCEPT_UCAST_UNMATCHED)));
-
SET_FIELD(state, ETH_VPORT_TX_MODE_MCAST_DROP_ALL,
  !!(accept_filter & QED_ACCEPT_NONE));
 
-- 
1.9.3



[PATCH net 1/5] qed: Correct default vlan behavior

2016-06-19 Thread Yuval Mintz
When no vlan filter is configured, firmware has a configurable
default on whether to pass only untagged packets or all packets
regardless of their tagging. Driver currently doesn't set this
field in the necessary ramrod, causing the default to always be
'receive all'.

Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_l2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c 
b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index 8fba87dd..1aaea83 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -72,6 +72,7 @@ int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
p_ramrod->mtu   = cpu_to_le16(p_params->mtu);
p_ramrod->inner_vlan_removal_en = p_params->remove_inner_vlan;
p_ramrod->drop_ttl0_en  = p_params->drop_ttl0;
+   p_ramrod->untagged  = p_params->only_untagged;
 
SET_FIELD(rx_mode, ETH_VPORT_RX_MODE_UCAST_DROP_ALL, 1);
SET_FIELD(rx_mode, ETH_VPORT_RX_MODE_MCAST_DROP_ALL, 1);
-- 
1.9.3



Re: [PATCH 1/2] net: ethernet: nb8800: use phydev from struct net_device

2016-06-19 Thread Måns Rullgård
Philippe Reynes  writes:

> The private structure contain a pointer to phydev, but the structure
> net_device already contain such pointer. So we can remove the pointer
> phydev in the private structure, and update the driver to use the
> one contained in struct net_device.
>
> Signed-off-by: Philippe Reynes 

Acked-by: Mans Rullgard 

> ---
>  drivers/net/ethernet/aurora/nb8800.c |   57 +
>  drivers/net/ethernet/aurora/nb8800.h |1 -
>  2 files changed, 29 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/ethernet/aurora/nb8800.c 
> b/drivers/net/ethernet/aurora/nb8800.c
> index 08a23e6..4989d31 100644
> --- a/drivers/net/ethernet/aurora/nb8800.c
> +++ b/drivers/net/ethernet/aurora/nb8800.c
> @@ -631,7 +631,7 @@ static void nb8800_mac_config(struct net_device *dev)
>  static void nb8800_pause_config(struct net_device *dev)
>  {
>   struct nb8800_priv *priv = netdev_priv(dev);
> - struct phy_device *phydev = priv->phydev;
> + struct phy_device *phydev = dev->phydev;
>   u32 rxcr;
>
>   if (priv->pause_aneg) {
> @@ -664,7 +664,7 @@ static void nb8800_pause_config(struct net_device *dev)
>  static void nb8800_link_reconfigure(struct net_device *dev)
>  {
>   struct nb8800_priv *priv = netdev_priv(dev);
> - struct phy_device *phydev = priv->phydev;
> + struct phy_device *phydev = dev->phydev;
>   int change = 0;
>
>   if (phydev->link) {
> @@ -690,7 +690,7 @@ static void nb8800_link_reconfigure(struct net_device 
> *dev)
>   }
>
>   if (change)
> - phy_print_status(priv->phydev);
> + phy_print_status(phydev);
>  }
>
>  static void nb8800_update_mac_addr(struct net_device *dev)
> @@ -935,9 +935,10 @@ static int nb8800_dma_stop(struct net_device *dev)
>  static void nb8800_pause_adv(struct net_device *dev)
>  {
>   struct nb8800_priv *priv = netdev_priv(dev);
> + struct phy_device *phydev = dev->phydev;
>   u32 adv = 0;
>
> - if (!priv->phydev)
> + if (!phydev)
>   return;
>
>   if (priv->pause_rx)
> @@ -945,13 +946,14 @@ static void nb8800_pause_adv(struct net_device *dev)
>   if (priv->pause_tx)
>   adv ^= ADVERTISED_Asym_Pause;
>
> - priv->phydev->supported |= adv;
> - priv->phydev->advertising |= adv;
> + phydev->supported |= adv;
> + phydev->advertising |= adv;
>  }
>
>  static int nb8800_open(struct net_device *dev)
>  {
>   struct nb8800_priv *priv = netdev_priv(dev);
> + struct phy_device *phydev;
>   int err;
>
>   /* clear any pending interrupts */
> @@ -969,10 +971,10 @@ static int nb8800_open(struct net_device *dev)
>   nb8800_mac_rx(dev, true);
>   nb8800_mac_tx(dev, true);
>
> - priv->phydev = of_phy_connect(dev, priv->phy_node,
> -   nb8800_link_reconfigure, 0,
> -   priv->phy_mode);
> - if (!priv->phydev)
> + phydev = of_phy_connect(dev, priv->phy_node,
> + nb8800_link_reconfigure, 0,
> + priv->phy_mode);
> + if (!phydev)
>   goto err_free_irq;
>
>   nb8800_pause_adv(dev);
> @@ -982,7 +984,7 @@ static int nb8800_open(struct net_device *dev)
>   netif_start_queue(dev);
>
>   nb8800_start_rx(dev);
> - phy_start(priv->phydev);
> + phy_start(phydev);
>
>   return 0;
>
> @@ -997,8 +999,9 @@ err_free_dma:
>  static int nb8800_stop(struct net_device *dev)
>  {
>   struct nb8800_priv *priv = netdev_priv(dev);
> + struct phy_device *phydev = dev->phydev;
>
> - phy_stop(priv->phydev);
> + phy_stop(phydev);
>
>   netif_stop_queue(dev);
>   napi_disable(>napi);
> @@ -1007,8 +1010,7 @@ static int nb8800_stop(struct net_device *dev)
>   nb8800_mac_rx(dev, false);
>   nb8800_mac_tx(dev, false);
>
> - phy_disconnect(priv->phydev);
> - priv->phydev = NULL;
> + phy_disconnect(phydev);
>
>   free_irq(dev->irq, dev);
>
> @@ -1019,9 +1021,7 @@ static int nb8800_stop(struct net_device *dev)
>
>  static int nb8800_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
>  {
> - struct nb8800_priv *priv = netdev_priv(dev);
> -
> - return phy_mii_ioctl(priv->phydev, rq, cmd);
> + return phy_mii_ioctl(dev->phydev, rq, cmd);
>  }
>
>  static const struct net_device_ops nb8800_netdev_ops = {
> @@ -1037,32 +1037,32 @@ static const struct net_device_ops nb8800_netdev_ops 
> = {
>
>  static int nb8800_get_settings(struct net_device *dev, struct ethtool_cmd 
> *cmd)
>  {
> - struct nb8800_priv *priv = netdev_priv(dev);
> + struct phy_device *phydev = dev->phydev;
>
> - if (!priv->phydev)
> + if (!phydev)
>   return -ENODEV;
>
> - return phy_ethtool_gset(priv->phydev, cmd);
> + return phy_ethtool_gset(phydev, cmd);
>  }
>
>  static int nb8800_set_settings(struct net_device *dev, struct ethtool_cmd 
> 

Re: [PATCH 2/2] net: ethernet: nb8800: use phy_ethtool_{get|set}_link_ksettings

2016-06-19 Thread Måns Rullgård
Philippe Reynes  writes:

> There are two generics functions phy_ethtool_{get|set}_link_ksettings,
> so we can use them instead of defining the same code in the driver.
>
> Signed-off-by: Philippe Reynes 

Acked-by: Mans Rullgard 

> ---
>  drivers/net/ethernet/aurora/nb8800.c |   24 ++--
>  1 files changed, 2 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ethernet/aurora/nb8800.c 
> b/drivers/net/ethernet/aurora/nb8800.c
> index 4989d31..dc2c35d 100644
> --- a/drivers/net/ethernet/aurora/nb8800.c
> +++ b/drivers/net/ethernet/aurora/nb8800.c
> @@ -1035,26 +1035,6 @@ static const struct net_device_ops nb8800_netdev_ops = 
> {
>   .ndo_validate_addr  = eth_validate_addr,
>  };
>
> -static int nb8800_get_settings(struct net_device *dev, struct ethtool_cmd 
> *cmd)
> -{
> - struct phy_device *phydev = dev->phydev;
> -
> - if (!phydev)
> - return -ENODEV;
> -
> - return phy_ethtool_gset(phydev, cmd);
> -}
> -
> -static int nb8800_set_settings(struct net_device *dev, struct ethtool_cmd 
> *cmd)
> -{
> - struct phy_device *phydev = dev->phydev;
> -
> - if (!phydev)
> - return -ENODEV;
> -
> - return phy_ethtool_sset(phydev, cmd);
> -}
> -
>  static int nb8800_nway_reset(struct net_device *dev)
>  {
>   struct phy_device *phydev = dev->phydev;
> @@ -1183,8 +1163,6 @@ static void nb8800_get_ethtool_stats(struct net_device 
> *dev,
>  }
>
>  static const struct ethtool_ops nb8800_ethtool_ops = {
> - .get_settings   = nb8800_get_settings,
> - .set_settings   = nb8800_set_settings,
>   .nway_reset = nb8800_nway_reset,
>   .get_link   = ethtool_op_get_link,
>   .get_pauseparam = nb8800_get_pauseparam,
> @@ -1192,6 +1170,8 @@ static const struct ethtool_ops nb8800_ethtool_ops = {
>   .get_sset_count = nb8800_get_sset_count,
>   .get_strings= nb8800_get_strings,
>   .get_ethtool_stats  = nb8800_get_ethtool_stats,
> + .get_link_ksettings = phy_ethtool_get_link_ksettings,
> + .set_link_ksettings = phy_ethtool_set_link_ksettings,
>  };
>
>  static int nb8800_hw_init(struct net_device *dev)
> -- 
> 1.7.4.4
>

-- 
Måns Rullgård


Re: [patch net-next v4 0/4] return offloaded stats as default and expose original sw stats

2016-06-19 Thread Jiri Pirko
Sat, Jun 18, 2016 at 03:58:56PM CEST, j...@mojatatu.com wrote:
>On 16-06-18 04:00 AM, Jiri Pirko wrote:
>>Fri, Jun 17, 2016 at 07:12:22PM CEST, f.faine...@gmail.com wrote:
>
Yep. And I believe that for offloaded forwarding, this tools should see
hw counters, as they show what is going on in real.
>>>
>>>If your NIC is offloading packets today, these tools typically won't see
>>>these stats, but ethtool -S likely will report what is going on under
>>>the hood.
>>>
>>>Do we actually need to tell apart SW maintained from HW maintained
>>>stats, or at the end all that matters is just, as DaveM pointed out,
>>>getting the information, and in the case of an Ethernet switch, return
>>>HW stats by default and supplement with SW stats whenever we have them,
>>>all in the same namespace?
>>
>
>In general it is extremely useful for debugging to be able to see them
>separately. One API to unify them (and that API being netlink) is
>the way to go. I dont know if you can ever obsolete ethtool if lots
>of other utils are using it - but would be nice.
>It is also useful to just get the sum of them - but user space can
>take care of that. David A., whatever user space tools that depended
>on ethtool should now be able to retrieve them via netlink, no?
>
>>I believe it is valuable for user to know stats for slow path
>>(non-forwarded by ASIC). Also, it's just another rtnl attr. Easy.
>>
>
>So Jiri, I see:
>IFLA_SW_STATS64 should that be: IFLA_HW_STATS_LINK_64?
>I think IFLA_STATS_LINK_64 should continue to send s/ware stats.

Well, we spent a lot of time to think about this. The problem with your
approach is that existing apps don't see "real-stats" - hw stats. For
example snmp daemon takes IFLA_STATS_LINK_64i, so it has to see HW stats
there. In order to not break existing apps, we expose HW stats as default.


Re: [PATCH] net:ppp: replace too strict capability restriction on opening /dev/ppp

2016-06-19 Thread Richard Weinberger
Am 19.06.2016 um 12:36 schrieb Shanker Wang:
> 
>> 在 2016年6月19日,12:13,Richard Weinberger  写道:
>>
>> Am 19.06.2016 um 07:21 schrieb Shanker Wang:
>>> This patch removes the check for CAP_NET_ADMIN in the initial namespace
>>> when opening /dev/open. Instead, CAP_NET_ADMIN is checked in the user
>>> namespace the net namespace was created so that /dev/ppp cat get opened
>>> in a unprivileged container.
>>>
>>> Cc: Hannes Frederic Sowa 
>>> Cc: Richard Weinberger 
>>> Cc: Guillaume Nault 
>>> Cc: Miao Wang 
>>> Signed-off-by: Miao Wang 
>>> ---
>>> drivers/net/ppp/ppp_generic.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
>>> index f572b31..4b3b2b5 100644
>>> --- a/drivers/net/ppp/ppp_generic.c
>>> +++ b/drivers/net/ppp/ppp_generic.c
>>> @@ -380,7 +380,7 @@ static int ppp_open(struct inode *inode, struct file 
>>> *file)
>>> /*
>>>  * This could (should?) be enforced by the permissions on /dev/ppp.
>>>  */
>>> -   if (!capable(CAP_NET_ADMIN))
>>> +   if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
>>> return -EPERM;
>>
>> Shouldn't this be a ns_capable(net->user_ns, …?
>> Otherwise an user can create a new user_ns followed by a new net_ns and has
>> CAP_NET_ADMIN. We need to check whether he is allowed in the user_ns of the
>> net_ns which belongs to the ppp net device which you want to open.
> You are totally right. However, I wonder how can i get the “net” struct when 
> opening /dev/ppp

I'm sure you can get it somehow via file->private_data.

Thanks,
//richard


Re: [PATCH] net:ppp: replace too strict capability restriction on opening /dev/ppp

2016-06-19 Thread Shanker Wang

> 在 2016年6月19日,12:13,Richard Weinberger  写道:
> 
> Am 19.06.2016 um 07:21 schrieb Shanker Wang:
>> This patch removes the check for CAP_NET_ADMIN in the initial namespace
>> when opening /dev/open. Instead, CAP_NET_ADMIN is checked in the user
>> namespace the net namespace was created so that /dev/ppp cat get opened
>> in a unprivileged container.
>> 
>> Cc: Hannes Frederic Sowa 
>> Cc: Richard Weinberger 
>> Cc: Guillaume Nault 
>> Cc: Miao Wang 
>> Signed-off-by: Miao Wang 
>> ---
>> drivers/net/ppp/ppp_generic.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
>> index f572b31..4b3b2b5 100644
>> --- a/drivers/net/ppp/ppp_generic.c
>> +++ b/drivers/net/ppp/ppp_generic.c
>> @@ -380,7 +380,7 @@ static int ppp_open(struct inode *inode, struct file 
>> *file)
>>  /*
>>   * This could (should?) be enforced by the permissions on /dev/ppp.
>>   */
>> -if (!capable(CAP_NET_ADMIN))
>> +if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
>>  return -EPERM;
> 
> Shouldn't this be a ns_capable(net->user_ns, …?
> Otherwise an user can create a new user_ns followed by a new net_ns and has
> CAP_NET_ADMIN. We need to check whether he is allowed in the user_ns of the
> net_ns which belongs to the ppp net device which you want to open.
You are totally right. However, I wonder how can i get the “net” struct when 
opening /dev/ppp
> 
> Thanks,
> //richard



Re: [PATCH] net:ppp: replace too strict capability restriction on opening /dev/ppp

2016-06-19 Thread Richard Weinberger
Am 19.06.2016 um 07:21 schrieb Shanker Wang:
> This patch removes the check for CAP_NET_ADMIN in the initial namespace
> when opening /dev/open. Instead, CAP_NET_ADMIN is checked in the user
> namespace the net namespace was created so that /dev/ppp cat get opened
> in a unprivileged container.
> 
> Cc: Hannes Frederic Sowa 
> Cc: Richard Weinberger 
> Cc: Guillaume Nault 
> Cc: Miao Wang 
> Signed-off-by: Miao Wang 
> ---
> drivers/net/ppp/ppp_generic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index f572b31..4b3b2b5 100644
> --- a/drivers/net/ppp/ppp_generic.c
> +++ b/drivers/net/ppp/ppp_generic.c
> @@ -380,7 +380,7 @@ static int ppp_open(struct inode *inode, struct file 
> *file)
>   /*
>* This could (should?) be enforced by the permissions on /dev/ppp.
>*/
> - if (!capable(CAP_NET_ADMIN))
> + if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
>   return -EPERM;

Shouldn't this be a ns_capable(net->user_ns, ...?
Otherwise an user can create a new user_ns followed by a new net_ns and has
CAP_NET_ADMIN. We need to check whether he is allowed in the user_ns of the
net_ns which belongs to the ppp net device which you want to open.

Thanks,
//richard


Re: [very-RFC 0/8] TSN driver for the kernel

2016-06-19 Thread Richard Cochran
On Sun, Jun 19, 2016 at 12:45:50AM +0200, Henrik Austad wrote:
> edit: this turned out to be a somewhat lengthy answer. I have tried to 
> shorten it down somewhere. it is getting late and I'm getting increasingly 
> incoherent (Richard probably knows what I'm talking about ;) so I'll stop 
> for now.

Thanks for your responses, Henrik.  I think your explanations are on spot.

> note that an adjustable sample-clock is not a *requirement* but in general 
> you'd want to avoid resampling in software.

Yes, but..

Adjusting the local clock rate to match the AVB network rate is
essential.  You must be able to *continuously* adjust the rate in
order to compensate drift.  Again, there are exactly two ways to do
it, namely in hardware (think VCO) or in software (dynamic
resampling).

What you cannot do is simply buffer the AV data and play it out
blindly at the local clock rate.

Regarding the media clock, if I understand correctly, there the talker
has two possibilities.  Either the talker samples the stream at the
gPTP rate, or the talker must tell the listeners the relationship
(phase offset and frequency ratio) between the media clock and the
gPTP time.  Please correct me if I got the wrong impression...

Thanks,
Richard


Re: PATCH 1/1] AX.25: Close socket connection on session completion

2016-06-19 Thread Thomas Osterried
> > socket. Symptom occurs in kernels >= 4.2.0
[..] 
> What changed in 4.2.x that broke this?

3.x'er kernel had also this problem; but there it happens rarely.

vy 73,
- Thomas  dl9sau