Re: [v4] Fix to avoid IS_ERR_VALUE and IS_ERR abuses on 64bit systems.

2016-08-01 Thread Arnd Bergmann
On Sunday, July 31, 2016 4:48:44 PM CEST Arvind Yadav wrote:
> IS_ERR_VALUE() assumes that parameter is an unsigned long.
> It can not be used to check if 'unsigned int' is passed insted.
> Which tends to reflect an error.
> 
> In 64bit architectures sizeof (int) == 4 && sizeof (long) == 8.
> IS_ERR_VALUE(x) is ((x) >= (unsigned long)-4095).
> 
> IS_ERR_VALUE() of 'unsigned int' is always false because the 32bit
> value is zero extended to 64 bits.
> 
> Value of (unsigned int)-4095 is always less than value of
> (unsigned long)-4095.
> 
> Now We are taking only first 32 bit for error checking rest of the 32 bit
> we ignore such that we get appropriate comparison on 64bit system as well.

This is completely wrong: if you have a valid 64-bit pointer like
0x1234ff00, this will be interpreted as an error now.

> First 32bit of Value of (unsigned int)-4095 and (unsigned long)-4095 will
> be equal.
> 
> Signed-off-by: Arvind Yadav 
> ---
>  include/linux/err.h | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/err.h b/include/linux/err.h
> index 1e35588..c2a2789 100644
> --- a/include/linux/err.h
> +++ b/include/linux/err.h
> @@ -18,7 +18,17 @@
>  
>  #ifndef __ASSEMBLY__
>  
> -#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned 
> long)-MAX_ERRNO)
> +#define IS_ERR_VALUE(x) unlikely(is_error_check(x))
> +
> +static inline int is_error_check(unsigned long error)

Please leave the existing macro alone. I think you were looking for
something specific to the return code of qe_muram_alloc() function,
so please add a helper in that subsystem if you need it, not in
the generic header files.

Arnd


[PATCH v2 02/15] ethernet: apm: xgene: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 2f5638f..fb23408 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -758,6 +758,7 @@ static int xgene_enet_phy_connect(struct net_device *ndev)
 
phy_dev = of_phy_connect(ndev, phy_np, &xgene_enet_adjust_link,
 0, pdata->phy_mode);
+   of_node_put(phy_np);
if (!phy_dev) {
netdev_err(ndev, "Could not connect to PHY\n");
return -ENODEV;
-- 
1.9.1



[PATCH v2 08/15] ethernet: marvell: mvneta: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/marvell/mvneta.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index f92018b..d41c28d 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4118,6 +4118,7 @@ static int mvneta_probe(struct platform_device *pdev)
pp->bm_priv = NULL;
}
}
+   of_node_put(bm_node);
 
err = mvneta_init(&pdev->dev, pp);
if (err < 0)
-- 
1.9.1



[PATCH v2 01/15] ethernet: altera: add missing of_node_put

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle (or of_node_get) has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/altera/altera_tse_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c 
b/drivers/net/ethernet/altera/altera_tse_main.c
index 49025e9..bda31f3 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -815,6 +815,7 @@ static int init_phy(struct net_device *dev)
phydev = of_phy_connect(dev, phynode,
&altera_tse_adjust_link, 0, priv->phy_iface);
}
+   of_node_put(phynode);
 
if (!phydev) {
netdev_err(dev, "Could not find the PHY\n");
-- 
1.9.1



[PATCH v2 06/15] ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 3fb87e2..5c8afe1 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -795,6 +795,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
mac_cb->mac_id, np->name);
}
+   of_node_put(np);
 
return 0;
}
@@ -812,10 +813,12 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
mac_cb->mac_id, np->name);
}
+   of_node_put(np);
 
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(to_of_node(mac_cb->fw_port),
-"serdes-syscon", 0));
+   np = of_parse_phandle(to_of_node(mac_cb->fw_port),
+   "serdes-syscon", 0);
+   syscon = syscon_node_to_regmap(np);
+   of_node_put(np);
if (IS_ERR_OR_NULL(syscon)) {
dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
return -EINVAL;
-- 
1.9.1



[PATCH v2 04/15] ethernet: aurora: nb8800: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/aurora/nb8800.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/aurora/nb8800.c 
b/drivers/net/ethernet/aurora/nb8800.c
index 0d4ea92..b047fd6 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -1504,6 +1504,7 @@ static int nb8800_probe(struct platform_device *pdev)
 err_free_dma:
nb8800_dma_free(dev);
 err_free_bus:
+   of_node_put(priv->phy_node);
mdiobus_unregister(bus);
 err_disable_clk:
clk_disable_unprepare(priv->clk);
@@ -1519,6 +1520,7 @@ static int nb8800_remove(struct platform_device *pdev)
struct nb8800_priv *priv = netdev_priv(ndev);
 
unregister_netdev(ndev);
+   of_node_put(priv->phy_node);
 
mdiobus_unregister(priv->mii_bus);
 
-- 
1.9.1



[PATCH v2 00/15] add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
Hi David,

This patch set fixes missing of_node_put issue at ethernet driver.
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

The compilation test has passed by using allmodconfig for drivers/net/ethernet.

Thanks.

Changes for v2:
- If the device node is local variable, it can be put in the same function.
- If the device node will be used the whole driver life cycle,
  it should be put (call of_node_put) at driver's remove. 
  Patch [4, 5, 9, 14, 15/15]
- Fix the issue that the node still be used at error patch [6/15]
- Add acked for patch [11,12/15]

Peter Chen (15):
  ethernet: altera: add missing of_node_put
  ethernet: apm: xgene: add missing of_node_put after calling
of_parse_phandle
  ethernet: arc: emac_main: add missing of_node_put after calling
of_parse_phandle
  ethernet: aurora: nb8800: add missing of_node_put after calling
of_parse_phandle
  ethernet: cavium: octeon: add missing of_node_put after calling
of_parse_phandle
  ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after
calling of_parse_phandle
  ethernet: hisilicon: hns: hns_dsaf_main: add missing of_node_put after
calling of_parse_phandle
  ethernet: marvell: mvneta: add missing of_node_put after calling
of_parse_phandle
  ethernet: marvell: mvpp2: add missing of_node_put after calling
of_parse_phandle
  ethernet: marvell: pxa168_eth: add missing of_node_put after calling
of_parse_phandle
  ethernet: renesas: ravb_main: add missing of_node_put after calling
of_parse_phandle
  ethernet: renesas: sh_eth: add missing of_node_put after calling
of_parse_phandle
  ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put
after calling of_parse_phandle
  ethernet: stmicro: stmmac: add missing of_node_put after calling
of_parse_phandle
  ethernet: ti: davinci_emac: add missing of_node_put after calling
of_parse_phandle

 drivers/net/ethernet/altera/altera_tse_main.c  |  1 +
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c |  1 +
 drivers/net/ethernet/arc/emac_main.c   | 15 ++---
 drivers/net/ethernet/aurora/nb8800.c   |  2 ++
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c   |  3 ++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  |  9 --
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |  7 +++--
 drivers/net/ethernet/marvell/mvneta.c  |  1 +
 drivers/net/ethernet/marvell/mvpp2.c   |  2 ++
 drivers/net/ethernet/marvell/pxa168_eth.c  |  1 +
 drivers/net/ethernet/renesas/ravb_main.c   |  1 +
 drivers/net/ethernet/renesas/sh_eth.c  |  1 +
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c| 36 --
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  1 +
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  7 +++--
 drivers/net/ethernet/ti/davinci_emac.c |  1 +
 16 files changed, 67 insertions(+), 22 deletions(-)

-- 
1.9.1



[PATCH v2 05/15] ethernet: cavium: octeon: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c 
b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index e8bc15b..4ab404f 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -1513,6 +1513,7 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
return 0;
 
 err:
+   of_node_put(p->phy_np);
free_netdev(netdev);
return result;
 }
@@ -1520,8 +1521,10 @@ err:
 static int octeon_mgmt_remove(struct platform_device *pdev)
 {
struct net_device *netdev = platform_get_drvdata(pdev);
+   struct octeon_mgmt *p = netdev_priv(netdev);
 
unregister_netdev(netdev);
+   of_node_put(p->phy_np);
free_netdev(netdev);
return 0;
 }
-- 
1.9.1



[PATCH v2 11/15] ethernet: renesas: ravb_main: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
Acked-by: Sergei Shtylyov 
---
 drivers/net/ethernet/renesas/ravb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 8377d02..1e1cc0f 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1005,6 +1005,7 @@ static int ravb_phy_init(struct net_device *ndev)
}
phydev = of_phy_connect(ndev, pn, ravb_adjust_link, 0,
priv->phy_interface);
+   of_node_put(pn);
if (!phydev) {
netdev_err(ndev, "failed to connect PHY\n");
return -ENOENT;
-- 
1.9.1



[PATCH v2 14/15] ethernet: stmicro: stmmac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

This commit fixes both local (in stmmac_axi_setup) and global
(plat->phy_node) device_node for this issue, and using the
correct device node when tries to put node at stmmac_probe_config_dt
for error path.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c23ccab..4c8c60a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3397,6 +3397,7 @@ int stmmac_dvr_remove(struct device *dev)
stmmac_set_mac(priv->ioaddr, false);
netif_carrier_off(ndev);
unregister_netdev(ndev);
+   of_node_put(priv->plat->phy_node);
if (priv->stmmac_rst)
reset_control_assert(priv->stmmac_rst);
clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f7dfc0a..756bb54 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
return NULL;
 
axi = kzalloc(sizeof(*axi), GFP_KERNEL);
-   if (!axi)
+   if (!axi) {
+   of_node_put(np);
return ERR_PTR(-ENOMEM);
+   }
 
axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
@@ -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+   of_node_put(np);
 
return axi;
 }
@@ -302,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const 
char **mac)
dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
   GFP_KERNEL);
if (!dma_cfg) {
-   of_node_put(np);
+   of_node_put(plat->phy_node);
return ERR_PTR(-ENOMEM);
}
plat->dma_cfg = dma_cfg;
-- 
1.9.1



[PATCH v2 13/15] ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c| 36 --
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index edd20c3..bec6963 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -135,7 +135,9 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
 
np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0);
if (np_splitter) {
-   if (of_address_to_resource(np_splitter, 0, &res_splitter)) {
+   ret = of_address_to_resource(np_splitter, 0, &res_splitter);
+   of_node_put(np_splitter);
+   if (ret) {
dev_info(dev, "Missing emac splitter address\n");
return -EINVAL;
}
@@ -159,14 +161,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: missing emac splitter 
address\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->splitter_base =
devm_ioremap_resource(dev, &res_splitter);
 
-   if (IS_ERR(dwmac->splitter_base))
-   return PTR_ERR(dwmac->splitter_base);
+   if (IS_ERR(dwmac->splitter_base)) {
+   ret = PTR_ERR(dwmac->splitter_base);
+   goto err_node_put;
+   }
}
 
index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -178,14 +183,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: failed mapping adapter\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->pcs.sgmii_adapter_base =
devm_ioremap_resource(dev, &res_sgmii_adapter);
 
-   if (IS_ERR(dwmac->pcs.sgmii_adapter_base))
-   return PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+   if (IS_ERR(dwmac->pcs.sgmii_adapter_base)) {
+   ret = PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+   goto err_node_put;
+   }
}
 
index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -197,22 +205,30 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: failed mapping tse control 
port\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->pcs.tse_pcs_base =
devm_ioremap_resource(dev, &res_tse_pcs);
 
-   if (IS_ERR(dwmac->pcs.tse_pcs_base))
-   return PTR_ERR(dwmac->pcs.tse_pcs_base);
+   if (IS_ERR(dwmac->pcs.tse_pcs_base)) {
+   ret = PTR_ERR(dwmac->pcs.tse_pcs_base);
+   goto err_node_put;
+   }
}
}
dwmac->reg_offset = reg_offset;
dwmac->reg_shift = reg_shift;
dwmac->sys_mgr_base_addr = sys_mgr_base_addr;
dwmac->dev = dev;
+   of_node_put(np_sgmii_adapter);
 
return 0;
+
+err_node_put:
+   of_node_put(np_sgmii_adapter);
+   return ret;
 }
 
 static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
-- 
1.9.1



[PATCH v2 12/15] ethernet: renesas: sh_eth: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
Acked-by: Sergei Shtylyov 
---
 drivers/net/ethernet/renesas/sh_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c 
b/drivers/net/ethernet/renesas/sh_eth.c
index 7bd910c..799d58d 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1780,6 +1780,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
sh_eth_adjust_link, 0,
mdp->phy_interface);
 
+   of_node_put(pn);
if (!phydev)
phydev = ERR_PTR(-ENOENT);
} else {
-- 
1.9.1



[PATCH v2 09/15] ethernet: marvell: mvpp2: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 0b04717..60227a3 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6234,6 +6234,7 @@ err_free_stats:
 err_free_irq:
irq_dispose_mapping(port->irq);
 err_free_netdev:
+   of_node_put(phy_node);
free_netdev(dev);
return err;
 }
@@ -6244,6 +6245,7 @@ static void mvpp2_port_remove(struct mvpp2_port *port)
int i;
 
unregister_netdev(port->dev);
+   of_node_put(port->phy_node);
free_percpu(port->pcpu);
free_percpu(port->stats);
for (i = 0; i < txq_number; i++)
-- 
1.9.1



[PATCH v2 10/15] ethernet: marvell: pxa168_eth: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c 
b/drivers/net/ethernet/marvell/pxa168_eth.c
index aeeb2e7..5d5000c 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1506,6 +1506,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
}
of_property_read_u32(np, "reg", &pep->phy_addr);
pep->phy_intf = of_get_phy_mode(pdev->dev.of_node);
+   of_node_put(np);
}
 
/* Hardware supports only 3 ports */
-- 
1.9.1



[PATCH v2 15/15] ethernet: ti: davinci_emac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/ti/davinci_emac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c 
b/drivers/net/ethernet/ti/davinci_emac.c
index c6c5465..45ab9d4 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -2060,6 +2060,7 @@ static int davinci_emac_remove(struct platform_device 
*pdev)
cpdma_ctlr_destroy(priv->dma);
 
unregister_netdev(ndev);
+   of_node_put(priv->phy_node);
pm_runtime_disable(&pdev->dev);
free_netdev(ndev);
 
-- 
1.9.1



[RFC PATCH 1/2] net: macb: Correct CAPS mask

2016-08-01 Thread Harini Katakam
USRIO and JUMBO CAPS have the same mask.
Fix the same.

Signed-off-by: Harini Katakam 
---
 drivers/net/ethernet/cadence/macb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index 36893d8..b6fcf10 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -403,11 +403,11 @@
 #define MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII0x0004
 #define MACB_CAPS_NO_GIGABIT_HALF  0x0008
 #define MACB_CAPS_USRIO_DISABLED   0x0010
+#define MACB_CAPS_JUMBO0x0020
 #define MACB_CAPS_FIFO_MODE0x1000
 #define MACB_CAPS_GIGABIT_MODE_AVAILABLE   0x2000
 #define MACB_CAPS_SG_DISABLED  0x4000
 #define MACB_CAPS_MACB_IS_GEM  0x8000
-#define MACB_CAPS_JUMBO0x0010
 
 /* Bit manipulation macros */
 #define MACB_BIT(name) \
-- 
2.7.4



[PATCH v2 03/15] ethernet: arc: emac_main: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/arc/emac_main.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac_main.c 
b/drivers/net/ethernet/arc/emac_main.c
index 586beda..4bff0f3 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -749,14 +749,16 @@ int arc_emac_probe(struct net_device *ndev, int interface)
err = of_address_to_resource(dev->of_node, 0, &res_regs);
if (err) {
dev_err(dev, "failed to retrieve registers base from device 
tree\n");
-   return -ENODEV;
+   err = -ENODEV;
+   goto out_put_node;
}
 
/* Get IRQ from device tree */
irq = irq_of_parse_and_map(dev->of_node, 0);
if (!irq) {
dev_err(dev, "failed to retrieve  value from device 
tree\n");
-   return -ENODEV;
+   err = -ENODEV;
+   goto out_put_node;
}
 
ndev->netdev_ops = &arc_emac_netdev_ops;
@@ -778,7 +780,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
err = clk_prepare_enable(priv->clk);
if (err) {
dev_err(dev, "failed to enable clock\n");
-   return err;
+   goto out_put_node;
}
 
clock_frequency = clk_get_rate(priv->clk);
@@ -787,7 +789,8 @@ int arc_emac_probe(struct net_device *ndev, int interface)
if (of_property_read_u32(dev->of_node, "clock-frequency",
 &clock_frequency)) {
dev_err(dev, "failed to retrieve  from 
device tree\n");
-   return -EINVAL;
+   err = -EINVAL;
+   goto out_put_node;
}
}
 
@@ -867,6 +870,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
goto out_netif_api;
}
 
+   of_node_put(phy_node);
return 0;
 
 out_netif_api:
@@ -877,6 +881,9 @@ out_mdio:
 out_clken:
if (priv->clk)
clk_disable_unprepare(priv->clk);
+out_put_node:
+   of_node_put(phy_node);
+
return err;
 }
 EXPORT_SYMBOL_GPL(arc_emac_probe);
-- 
1.9.1



[PATCH v2 07/15] ethernet: hisilicon: hns: hns_dsaf_main: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 2ef4277..afb5daa 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -51,7 +51,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
const char *mode_str;
struct regmap *syscon;
struct resource *res;
-   struct device_node *np = dsaf_dev->dev->of_node;
+   struct device_node *np = dsaf_dev->dev->of_node, *np_temp;
struct platform_device *pdev = to_platform_device(dsaf_dev->dev);
 
if (dev_of_node(dsaf_dev->dev)) {
@@ -102,8 +102,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
dsaf_dev->dsaf_tc_mode = HRD_DSAF_4TC_MODE;
 
if (dev_of_node(dsaf_dev->dev)) {
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(np, "subctrl-syscon", 0));
+   np_temp = of_parse_phandle(np, "subctrl-syscon", 0);
+   syscon = syscon_node_to_regmap(np_temp);
+   of_node_put(np_temp);
if (IS_ERR_OR_NULL(syscon)) {
res = platform_get_resource(pdev, IORESOURCE_MEM,
res_idx++);
-- 
1.9.1



Re: [PATCH 1/1] rps: Inspect PPTP encapsulated by GRE to get flow hash

2016-08-01 Thread Feng Gao
Hi Philp & Tom,

Thanks your advice.
I have send the update patch some days ago.

The link is http://www.spinics.net/lists/netdev/msg388083.html.
Could you help review it please?

Best Regards
Feng

On Thu, Jul 28, 2016 at 8:46 AM, Philp Prindeville
 wrote:
> Inline...
>
>
>
> On 07/27/2016 06:04 PM, Tom Herbert wrote:
>>
>> On Wed, Jul 27, 2016 at 4:42 PM,   wrote:
>>>
>>> From: Gao Feng 
>>>
>>> The PPTP is encapsulated by GRE header with that GRE_VERSION bits
>>> must contain one. But current GRE RPS needs the GRE_VERSION must be
>>> zero. So RPS does not work for PPTP traffic.
>>>
>>> In my test environment, there are four MIPS cores, and all traffic
>>> are passed through by PPTP. As a result, only one core is 100% busy
>>> while other three cores are very idle. After this patch, the usage
>>> of four cores are balanced well.
>>>
>>> Signed-off-by: Gao Feng 
>>> ---
>>>   v1: Initial patch
>>>
>>>   include/uapi/linux/if_tunnel.h |   5 +-
>>>   net/core/flow_dissector.c  | 138
>>> ++---
>>>   2 files changed, 92 insertions(+), 51 deletions(-)
>>>
>>> diff --git a/include/uapi/linux/if_tunnel.h
>>> b/include/uapi/linux/if_tunnel.h
>>> index 1046f55..dda4e4b 100644
>>> --- a/include/uapi/linux/if_tunnel.h
>>> +++ b/include/uapi/linux/if_tunnel.h
>>> @@ -24,9 +24,12 @@
>>>   #define GRE_SEQ__cpu_to_be16(0x1000)
>>>   #define GRE_STRICT __cpu_to_be16(0x0800)
>>>   #define GRE_REC__cpu_to_be16(0x0700)
>>> -#define GRE_FLAGS  __cpu_to_be16(0x00F8)
>>> +#define GRE_ACK__cpu_to_be16(0x0080)
>>> +#define GRE_FLAGS  __cpu_to_be16(0x0078)
>>>   #define GRE_VERSION__cpu_to_be16(0x0007)
>>>
>>> +#define GRE_PROTO_PPP  __cpu_to_be16(0x880b)
>>> +
>>>   struct ip_tunnel_parm {
>>>  charname[IFNAMSIZ];
>>>  int link;
>>> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
>>> index 61ad43f..d95e060 100644
>>> --- a/net/core/flow_dissector.c
>>> +++ b/net/core/flow_dissector.c
>>> @@ -346,63 +346,101 @@ ip_proto_again:
>>>  hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr),
>>> data, hlen, &_hdr);
>>>  if (!hdr)
>>>  goto out_bad;
>>> -   /*
>>> -* Only look inside GRE if version zero and no
>>> -* routing
>>> -*/
>>> -   if (hdr->flags & (GRE_VERSION | GRE_ROUTING))
>>> -   break;
>>>
>>> -   proto = hdr->proto;
>>> -   nhoff += 4;
>>> -   if (hdr->flags & GRE_CSUM)
>>> +   /*
>>> +   * Only look inside GRE if version zero and no
>>> +   * routing
>>
>> This comment is no longer true, GRE version 1 is being handled.
>>
>>> +   */
>>> +   if (!(hdr->flags & (GRE_VERSION | GRE_ROUTING))) {
>>> +   proto = hdr->proto;
>>>  nhoff += 4;
>>> -   if (hdr->flags & GRE_KEY) {
>>> -   const __be32 *keyid;
>>> -   __be32 _keyid;
>>> +   if (hdr->flags & GRE_CSUM)
>>> +   nhoff += 4;
>>> +   if (hdr->flags & GRE_KEY) {
>>> +   const __be32 *keyid;
>>> +   __be32 _keyid;
>>> +
>>> +   keyid = __skb_header_pointer(skb, nhoff,
>>> sizeof(_keyid),
>>> +data, hlen,
>>> &_keyid);
>>> +
>>> +   if (!keyid)
>>> +   goto out_bad;
>>> +
>>> +   if (dissector_uses_key(flow_dissector,
>>> +
>>> FLOW_DISSECTOR_KEY_GRE_KEYID)) {
>>> +   key_keyid =
>>> skb_flow_dissector_target(flow_dissector,
>>> +
>>> FLOW_DISSECTOR_KEY_GRE_KEYID,
>>> +
>>> target_container);
>>> +   key_keyid->keyid = *keyid;
>>> +   }
>>> +   nhoff += 4;
>>> +   }
>>> +   if (hdr->flags & GRE_SEQ)
>>> +   nhoff += 4;
>>> +   if (proto == htons(ETH_P_TEB)) {
>>> +   const struct ethhdr *eth;
>>> +   struct ethhdr _eth;
>>> +
>>> +   eth = __skb_header_pointer(skb, nhoff,
>>> +  sizeof(_eth),
>>> +  data, hlen,
>>> &_eth);
>>> +   if (!eth)
>>> +   goto out_bad;
>>> +   proto = eth->h_proto;
>>> +   nhoff += sizeof(*eth);
>>> +
>>> +  

[RFC PATCH 2/2] net: macb: Add 64 bit addressing support for GEM

2016-08-01 Thread Harini Katakam
This patch adds support for 64 bit addressing and BDs.
-> Enable 64 bit addressing in DMACFG register.
-> Set DMA mask when design config register shows support for 64 bit addr.
-> Add new BD words for higher address when 64 bit DMA support is present.
-> Add and update TBQPH and RBQPH for MSB of BD pointers.
-> Change extraction and updation of buffer addresses to use
64 bit address.
-> In gem_rx extract address in one place insted of two and use a
separate flag for RXUSED.

Signed-off-by: Harini Katakam 
---
 drivers/net/ethernet/cadence/macb.c | 62 ++---
 drivers/net/ethernet/cadence/macb.h | 10 ++
 2 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 89c0cfa..6b797e3 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -541,6 +541,14 @@ static void macb_tx_unmap(struct macb *bp, struct 
macb_tx_skb *tx_skb)
}
 }
 
+static inline void macb_set_addr(struct macb_dma_desc *desc, dma_addr_t addr)
+{
+   desc->addr = (u32)addr;
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+   desc->addrh = (u32)(addr >> 32);
+#endif
+}
+
 static void macb_tx_error_task(struct work_struct *work)
 {
struct macb_queue   *queue = container_of(work, struct macb_queue,
@@ -621,14 +629,17 @@ static void macb_tx_error_task(struct work_struct *work)
 
/* Set end of TX queue */
desc = macb_tx_desc(queue, 0);
-   desc->addr = 0;
+   macb_set_addr(desc, 0);
desc->ctrl = MACB_BIT(TX_USED);
 
/* Make descriptor updates visible to hardware */
wmb();
 
/* Reinitialize the TX desc queue */
-   queue_writel(queue, TBQP, queue->tx_ring_dma);
+   queue_writel(queue, TBQP, (u32)(queue->tx_ring_dma));
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+   queue_writel(queue, TBQPH, (u32)(queue->tx_ring_dma >> 32));
+#endif
/* Make TX ring reflect state of hardware */
queue->tx_head = 0;
queue->tx_tail = 0;
@@ -750,7 +761,7 @@ static void gem_rx_refill(struct macb *bp)
 
if (entry == RX_RING_SIZE - 1)
paddr |= MACB_BIT(RX_WRAP);
-   bp->rx_ring[entry].addr = paddr;
+   macb_set_addr(&(bp->rx_ring[entry]), paddr);
bp->rx_ring[entry].ctrl = 0;
 
/* properly align Ethernet header */
@@ -798,7 +809,9 @@ static int gem_rx(struct macb *bp, int budget)
int count = 0;
 
while (count < budget) {
-   u32 addr, ctrl;
+   u32 ctrl;
+   dma_addr_t addr;
+   bool rxused;
 
entry = macb_rx_ring_wrap(bp->rx_tail);
desc = &bp->rx_ring[entry];
@@ -806,10 +819,14 @@ static int gem_rx(struct macb *bp, int budget)
/* Make hw descriptor updates visible to CPU */
rmb();
 
-   addr = desc->addr;
+   rxused = (desc->addr & MACB_BIT(RX_USED)) ? true : false;
+   addr = MACB_BF(RX_WADDR, MACB_BFEXT(RX_WADDR, desc->addr));
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+   addr |= ((u64)(desc->addrh) << 32);
+#endif
ctrl = desc->ctrl;
 
-   if (!(addr & MACB_BIT(RX_USED)))
+   if (!rxused)
break;
 
bp->rx_tail++;
@@ -835,7 +852,6 @@ static int gem_rx(struct macb *bp, int budget)
netdev_vdbg(bp->dev, "gem_rx %u (len %u)\n", entry, len);
 
skb_put(skb, len);
-   addr = MACB_BF(RX_WADDR, MACB_BFEXT(RX_WADDR, addr));
dma_unmap_single(&bp->pdev->dev, addr,
 bp->rx_buffer_size, DMA_FROM_DEVICE);
 
@@ -1299,7 +1315,7 @@ static unsigned int macb_tx_map(struct macb *bp,
ctrl |= MACB_BIT(TX_WRAP);
 
/* Set TX buffer descriptor */
-   desc->addr = tx_skb->mapping;
+   macb_set_addr(desc, tx_skb->mapping);
/* desc->addr must be visible to hardware before clearing
 * 'TX_USED' bit in desc->ctrl.
 */
@@ -1422,6 +1438,9 @@ static void gem_free_rx_buffers(struct macb *bp)
 
desc = &bp->rx_ring[i];
addr = MACB_BF(RX_WADDR, MACB_BFEXT(RX_WADDR, desc->addr));
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+   addr |= ((u64)(desc->addrh) << 32);
+#endif
dma_unmap_single(&bp->pdev->dev, addr, bp->rx_buffer_size,
 DMA_FROM_DEVICE);
dev_kfree_skb_any(skb);
@@ -1547,7 +1566,7 @@ static void gem_init_rings(struct macb *bp)
 
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
for (i = 0; i < TX_RING_SIZE; i++) {
-   queue->tx_ring[i].addr = 0;
+   macb_set_add

Re: [PATCH v2 14/15] ethernet: stmicro: stmmac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Alexandre Torgue

Hi,

On 08/01/2016 09:02 AM, Peter Chen wrote:

of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

This commit fixes both local (in stmmac_axi_setup) and global
(plat->phy_node) device_node for this issue, and using the
correct device node when tries to put node at stmmac_probe_config_dt
for error path.

Signed-off-by: Peter Chen 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c23ccab..4c8c60a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3397,6 +3397,7 @@ int stmmac_dvr_remove(struct device *dev)
stmmac_set_mac(priv->ioaddr, false);
netif_carrier_off(ndev);
unregister_netdev(ndev);
+   of_node_put(priv->plat->phy_node);
if (priv->stmmac_rst)
reset_control_assert(priv->stmmac_rst);
clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f7dfc0a..756bb54 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
return NULL;

axi = kzalloc(sizeof(*axi), GFP_KERNEL);
-   if (!axi)
+   if (!axi) {
+   of_node_put(np);
return ERR_PTR(-ENOMEM);
+   }

axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
@@ -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+   of_node_put(np);

return axi;
 }
@@ -302,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const 
char **mac)
dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
   GFP_KERNEL);
if (!dma_cfg) {
-   of_node_put(np);
+   of_node_put(plat->phy_node);
return ERR_PTR(-ENOMEM);
}
plat->dma_cfg = dma_cfg;



You can add my:

Acked-by: Alexandre Torgue 

Regards

Alex



Re: [PATCH v2 15/15] ethernet: ti: davinci_emac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Mugunthan V N
+omap ML

On Monday 01 August 2016 12:32 PM, Peter Chen wrote:
> of_node_put needs to be called when the device node which is got
> from of_parse_phandle has finished using.
> 
> Signed-off-by: Peter Chen 

Reviewed-by: Mugunthan V N 

Regards
Mugunthan V N


Re: [PATCH v2 1/3] mac80211: mesh: flush stations before beacons are stopped

2016-08-01 Thread Johannes Berg
On Wed, 2016-07-13 at 14:44 +0300, Yaniv Machani wrote:
> From: Maital Hahn 
> 
> Some drivers (e.g. wl18xx) expect that the last stage in the
> de-initialization process will be stopping the beacons, similar to AP
> flow.
> Update ieee80211_stop_mesh() flow accordingly.
> As peers can be removed dynamically, this would not impact other
> drivers.
> 
Ah, I see now that you did :)

johannes


Re: [PATCH 1/4] mac80211: mesh: flush stations before beacons are stopped

2016-08-01 Thread Johannes Berg
On Wed, 2016-07-13 at 10:11 +, Machani, Yaniv wrote:
> On Wed, Jun 29, 2016 at 10:14:19, Johannes Berg wrote:
> > Cc: Hahn, Maital
> > Subject: Re: [PATCH 1/4] mac80211: mesh: flush stations before
> > beacons 
> > are stopped
> > 
> > On Tue, 2016-06-28 at 14:13 +0300, Yaniv Machani wrote:
> > > From: Maital Hahn 
> > > 
> > > Some drivers (e.g. wl18xx) expect that the last stage in the 
> > > de-initialization process will be stopping the beacons, similar
> > > to ap.
> > > Update ieee80211_stop_mesh() flow accordingly.
> > > 
> > How well have you tested that with other drivers?
> > 
> 
> Sorry for the delayed response (I've been out) and thanks for your
> comments,
> I have tested it with RT3572 as well, and didn't see any issue.
> I'll update the comment to reflect that.
> 

I'm actually reasonably sure that it *must* work, similiar to the AP
mode change, since it's always valid to remove stations while the the
mesh beacon is still active.

I hoped you'd actually figure out that line of reasoning and put it
into the commit message :)

johannes


Re: [PATCH v4] net: sched: convert qdisc linked list to hashtable

2016-08-01 Thread Jiri Kosina
On Sun, 31 Jul 2016, Fengguang Wu wrote:

> Jiri, I just double checked and find no similar errors related to
> qdisc_list_add(). The parent commit 95556a8838 ("dccp: avoid deadlock
> in dccp_v4_ctl_send_reset") builds fine without error.

You are right, I realized my mistake afterwards. This is fixed in v5 of 
the patch.

Thanks,

-- 
Jiri Kosina
SUSE Labs



[PATCH v6] net: sched: convert qdisc linked list to hashtable

2016-08-01 Thread Jiri Kosina
From: Jiri Kosina 
 
Convert the per-device linked list into a hashtable. The primary 
motivation for this change is that currently, we're not tracking all the 
qdiscs in hierarchy (e.g. excluding default qdiscs), as the lookup 
performed over the linked list by qdisc_match_from_root() is rather 
expensive.

The ultimate goal is to get rid of hidden qdiscs completely, which will 
bring much more determinism in user experience.

As we're adding hashtable.h include into generic netdevice.h, we have to 
make sure HASH_SIZE macro is now non-conflicting with local definitions.

Reviewed-by: Cong Wang 
Signed-off-by: Jiri Kosina 
---

v1 -> v2: fix up RCU hastable usage wrt. rtnl
  fix compilation of .c files which define their own
  HASH_SIZE that now oncflicts with the one from
  hashtable.h (newly included via netdevice.h)

v2 -> v3: resolve HASH_SIZE identifier conflicts in a cleaner way
  fix up the number of hash bucket bits (4 bits for 16 buckets)

v3 -> v4: put the hastable into struct netdevice only if 
  CONFIG_NET_SCHED has been enabled

v4 -> v5: fix !CONFIG_NET_SCHED build (reported by Fengguang Wu)
  add Cong Wang's reviewed-by

v5 -> v6: build fix for davinci_emac driver that got symbol conflict 
  due to hashtable.h include, reported by 0day bot

 drivers/net/ethernet/ti/davinci_emac.c | 14 +++---
 include/linux/netdevice.h  |  4 
 include/net/pkt_sched.h|  4 ++--
 include/net/sch_generic.h  |  2 +-
 net/core/dev.c |  3 +++
 net/ipv6/ip6_gre.c | 12 ++--
 net/ipv6/ip6_tunnel.c  | 10 +-
 net/ipv6/ip6_vti.c | 10 +-
 net/ipv6/sit.c | 10 +-
 net/sched/sch_api.c| 23 +--
 net/sched/sch_generic.c|  8 +---
 net/sched/sch_mq.c |  2 +-
 net/sched/sch_mqprio.c |  2 +-
 13 files changed, 58 insertions(+), 46 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c 
b/drivers/net/ethernet/ti/davinci_emac.c
index f56d66e..91ca2b2 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -726,14 +726,14 @@ static u32 hash_get(u8 *addr)
 }
 
 /**
- * hash_add - Hash function to add mac addr from hash table
+ * emac_hash_add - Hash function to add mac addr from hash table
  * @priv: The DaVinci EMAC private adapter structure
  * @mac_addr: mac address to delete from hash table
  *
  * Adds mac address to the internal hash table
  *
  */
-static int hash_add(struct emac_priv *priv, u8 *mac_addr)
+static int emac_hash_add(struct emac_priv *priv, u8 *mac_addr)
 {
struct device *emac_dev = &priv->ndev->dev;
u32 rc = 0;
@@ -742,7 +742,7 @@ static int hash_add(struct emac_priv *priv, u8 *mac_addr)
 
if (hash_value >= EMAC_NUM_MULTICAST_BITS) {
if (netif_msg_drv(priv)) {
-   dev_err(emac_dev, "DaVinci EMAC: hash_add(): Invalid "\
+   dev_err(emac_dev, "DaVinci EMAC: emac_hash_add(): 
Invalid "\
"Hash %08x, should not be greater than %08x",
hash_value, (EMAC_NUM_MULTICAST_BITS - 1));
}
@@ -768,14 +768,14 @@ static int hash_add(struct emac_priv *priv, u8 *mac_addr)
 }
 
 /**
- * hash_del - Hash function to delete mac addr from hash table
+ * emac_hash_del - Hash function to delete mac addr from hash table
  * @priv: The DaVinci EMAC private adapter structure
  * @mac_addr: mac address to delete from hash table
  *
  * Removes mac address from the internal hash table
  *
  */
-static int hash_del(struct emac_priv *priv, u8 *mac_addr)
+static int emac_hash_del(struct emac_priv *priv, u8 *mac_addr)
 {
u32 hash_value;
u32 hash_bit;
@@ -825,10 +825,10 @@ static void emac_add_mcast(struct emac_priv *priv, u32 
action, u8 *mac_addr)
 
switch (action) {
case EMAC_MULTICAST_ADD:
-   update = hash_add(priv, mac_addr);
+   update = emac_hash_add(priv, mac_addr);
break;
case EMAC_MULTICAST_DEL:
-   update = hash_del(priv, mac_addr);
+   update = emac_hash_del(priv, mac_addr);
break;
case EMAC_ALL_MULTI_SET:
update = 1;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f45929c..17c6499 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct netpoll_info;
 struct device;
@@ -1778,6 +1779,9 @@ struct net_device {
unsigned intnum_tx_queues;
unsigned intreal_num_tx_queues;
struct Qdisc*qdisc;
+#ifdef CONFIG_NET_SCHED
+   DECLARE_HASHTABLE  

RE: [PATCH 1/1] mwifiex: key_material_v2 remove superfluous condition

2016-08-01 Thread Amitkumar Karwar
> From: Heinrich Schuchardt [mailto:xypron.g...@gmx.de]
> Sent: Sunday, July 31, 2016 5:41 PM
> To: Amitkumar Karwar; Nishant Sarmukadam; Kalle Valo
> Cc: linux-wirel...@vger.kernel.org; netdev@vger.kernel.org; linux-
> ker...@vger.kernel.org; Heinrich Schuchardt
> Subject: [PATCH 1/1] mwifiex: key_material_v2 remove superfluous
> condition
> 
> We are using mac as source address in a memcpy.
> In the lines below we can assume mac is not NULL.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 11 +++
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> index 128add8..0d4f9fe 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> @@ -706,15 +706,10 @@ mwifiex_cmd_802_11_key_material_v2(struct
> mwifiex_private *priv,
>   (priv->wep_key_curr_index & KEY_INDEX_MASK))
>   key_info |= KEY_DEFAULT;
>   } else {
> - if (mac) {
> - if (is_broadcast_ether_addr(mac))
> - key_info |= KEY_MCAST;
> - else
> - key_info |= KEY_UNICAST |
> - KEY_DEFAULT;
> - } else {
> + if (is_broadcast_ether_addr(mac))
>   key_info |= KEY_MCAST;
> - }
> + else
> + key_info |= KEY_UNICAST | KEY_DEFAULT;
>   }
>   }
>   km->key_param_set.key_info = cpu_to_le16(key_info);
> --
> 2.8.1

Looks ok to me.

Acked-by: Amitkumar Karwar 

Regards,
Amitkumar


RE: [PATCH 1/1] mwifiex: remove superfluous condition

2016-08-01 Thread Amitkumar Karwar
> From: Heinrich Schuchardt [mailto:xypron.g...@gmx.de]
> Sent: Sunday, July 31, 2016 4:09 PM
> To: Amitkumar Karwar; Nishant Sarmukadam; Kalle Valo
> Cc: linux-wirel...@vger.kernel.org; netdev@vger.kernel.org; linux-
> ker...@vger.kernel.org; Heinrich Schuchardt
> Subject: [PATCH 1/1] mwifiex: remove superfluous condition
> 
> for_each_property_of_node is only executed if the property prop is not
> NULL.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> index 7897037..128add8 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
> @@ -1482,7 +1482,7 @@ int mwifiex_dnld_dt_cfgdata(struct mwifiex_private
> *priv,
>   continue;
> 
>   /* property header is 6 bytes, data must fit in cmd buffer
> */
> - if (prop && prop->value && prop->length > 6 &&
> + if (prop->value && prop->length > 6 &&
>   prop->length <= MWIFIEX_SIZE_OF_CMD_BUFFER - S_DS_GEN) {
>   ret = mwifiex_send_cmd(priv, HostCmd_CMD_CFG_DATA,
>  HostCmd_ACT_GEN_SET, 0,

Thanks. The patch looks fine to me.

Acked-by: Amitkumar Karwar 

Regards,
Amitkumar


Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-08-01 Thread Johannes Berg
On Fri, 2016-07-22 at 14:26 +0900, Masashi Honma wrote:
> On 2016年07月14日 05:07, Yaniv Machani wrote:
> > +
> > +   /* if channel width is 20MHz - configure HT capab
> > accordingly*/
> > +   if (sdata->vif.bss_conf.chandef.width ==
> > NL80211_CHAN_WIDTH_20) {
> > +   cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
> > +   cap &= ~IEEE80211_HT_CAP_DSSSCCK40;
> > +   }
> 
> I have tested this part of your patch and this works for me.
> 
> Previouly, "Supported Channel Width Set bit" in HT Capabilities
> element was 1 even though disable_ht40=1 existed in
> wpa_supplicant.conf. After appllication of patch, the bit was 0.
> 

But why is that behaviour *correct*? We still support 40 MHz bandwidth
things, we just don't use them if we disable HT40.

johannes


Re: [PATCH 2/2] nvme-rdma: Add handling for connecting to IPv6 targets

2016-08-01 Thread Christoph Hellwig
Hi Roland,

On Sun, Jul 31, 2016 at 12:27:40AM -0700, Roland Dreier wrote:
> From: Roland Dreier 
> 
> If a target address does not parse as IPv4, try parsing it as IPv6
> (including handling '%' suffixes for link-local addresses).

The code below looks fine to me, but is there any chance to add it to
net/ as a generic helper?  It's a little sad this sort of code would
have to live in each driver trying to parse IP addresses.

> Signed-off-by: Roland Dreier 
> ---
>  drivers/nvme/host/rdma.c | 55 
> ++--
>  1 file changed, 44 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index b96b88369871..dd4aa54cd709 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
> @@ -138,6 +138,7 @@ struct nvme_rdma_ctrl {
>   union {
>   struct sockaddr addr;
>   struct sockaddr_in addr_in;
> + struct sockaddr_in6 addr_in6;
>   };
>  
>   struct nvme_ctrlctrl;
> @@ -1847,19 +1848,51 @@ out_free_io_queues:
>   return ret;
>  }
>  
> -static int nvme_rdma_parse_ipaddr(struct sockaddr_in *in_addr, char *p)
> +static int nvme_rdma_parse_ipaddr(struct sockaddr *addr, char *p)
>  {
> - u8 *addr = (u8 *)&in_addr->sin_addr.s_addr;
>   size_t buflen = strlen(p);
>  
> - /* XXX: handle IPv6 addresses */
> + if (buflen <= INET_ADDRSTRLEN) {
> + struct sockaddr_in *addr4 = (struct sockaddr_in *) addr;
> + if (in4_pton(p, buflen, (u8 *) &addr4->sin_addr.s_addr,
> +  '\0', NULL) > 0) {
> + addr4->sin_family = AF_INET;
> + return 0;
> + }
> + }
>  
> - if (buflen > INET_ADDRSTRLEN)
> - return -EINVAL;
> - if (in4_pton(p, buflen, addr, '\0', NULL) == 0)
> - return -EINVAL;
> - in_addr->sin_family = AF_INET;
> - return 0;
> + if (buflen <= INET6_ADDRSTRLEN) {
> + struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
> + const char *scope_delim;
> +
> + if (in6_pton(p, buflen, (u8 *) &addr6->sin6_addr.s6_addr,
> +  '%', &scope_delim) == 0)
> + return -EINVAL;
> + addr6->sin6_family = AF_INET6;
> +
> + if (ipv6_addr_type(&addr6->sin6_addr) & IPV6_ADDR_LINKLOCAL &&
> + p + buflen != scope_delim && *scope_delim == '%') {
> + char scope_id[16];
> + size_t scope_len = min_t(size_t, sizeof scope_id,
> +  p + buflen - scope_delim - 1);
> + struct net_device *dev;
> +
> + memcpy(scope_id, scope_delim + 1, scope_len);
> + scope_id[scope_len] = '\0';
> +
> + /* XXX: what network namespace should we use? */
> + dev = dev_get_by_name(&init_net, scope_id);
> + if (dev) {
> + addr6->sin6_scope_id = dev->ifindex;
> + dev_put(dev);
> + } else if (kstrtouint(scope_id, 0, 
> &addr6->sin6_scope_id))
> + return -EINVAL;
> + }
> +
> + return 0;
> + }
> +
> + return -EINVAL;
>  }
>  
>  static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
> @@ -1875,7 +1908,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct 
> device *dev,
>   ctrl->ctrl.opts = opts;
>   INIT_LIST_HEAD(&ctrl->list);
>  
> - ret = nvme_rdma_parse_ipaddr(&ctrl->addr_in, opts->traddr);
> + ret = nvme_rdma_parse_ipaddr(&ctrl->addr, opts->traddr);
>   if (ret) {
>   pr_err("malformed IP address passed: %s\n", opts->traddr);
>   goto out_free_ctrl;
> @@ -1949,7 +1982,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct 
> device *dev,
>   changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
>   WARN_ON_ONCE(!changed);
>  
> - dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISp\n",
> + dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISpcs\n",
>   ctrl->ctrl.opts->subsysnqn, &ctrl->addr);
>  
>   kref_get(&ctrl->ctrl.kref);
> -- 
> 2.7.4
---end quoted text---


RE: [PATCH 14/15] ethernet: stmicro: stmmac: stmmac_platform: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
 
>
>>Hi,
>>
>>On 07/27/2016 04:20 AM, Peter Chen wrote:
>>> of_node_put needs to be called when the device node which is got from
>>> of_parse_phandle has finished using.
>>>
>>> Signed-off-by: Peter Chen 
>>> ---
>>>   drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 -
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> index f7dfc0a..8d88782 100644
>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> @@ -113,8 +113,10 @@ static struct stmmac_axi
>>> *stmmac_axi_setup(struct
>>platform_device *pdev)
>>> return NULL;
>>>
>>> axi = kzalloc(sizeof(*axi), GFP_KERNEL);
>>> -   if (!axi)
>>> +   if (!axi) {
>>> +   of_node_put(np);
>>> return ERR_PTR(-ENOMEM);
>>> +   }
>>>
>>> axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
>>> axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm"); @@
>>> -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct
>>platform_device *pdev)
>>> of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
>>> of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
>>> of_property_read_u32_array(np, "snps,blen", axi->axi_blen,
>>> AXI_BLEN);
>>> +   of_node_put(np);
>>>
>>> return axi;
>>>   }
>>>
>>
>>I agree with the modification inside stmmac_axi. I just have a question
>>about np =
>>pdev->dev.of_node inside stmmac_probe_config_dt (same file).
>>We could add a "of_node_put(np)" just before "return plat" ?
>>
>
>Yes, you remind me there is still one node need to be put (should be 
>plat->phy_node),
>except for changing node name at error path, how about calling 
>of_node_put(plat-
>>phy_node) at stmmac_release after phy is disconnected?
>

Since the plat->phy_node will be used during the whole life cycle, I put it at
stmmac_dvr_remove at my v2 patch set.

Best regards,
Peter


Re: [PATCH net] sctp: change to use TCP_CLOSE_WAIT as SCTP_SS_CLOSING

2016-08-01 Thread marcelo . leitner
On Sat, Jul 30, 2016 at 10:08:03PM -0700, David Miller wrote:
> From: Marcelo Ricardo Leitner 
> Date: Sat, 30 Jul 2016 10:25:35 -0300
> 
> > On Sat, Jul 30, 2016 at 08:00:45PM +0800, Xin Long wrote:
> >> Prior to this patch, sctp defined TCP_CLOSING as SCTP_SS_CLOSING.
> >> TCP_CLOSING is such a special sk state in TCP that inet common codes
> >> even exclude it.
> >> 
> >> For instance, inet_accept thinks the accept sk's state never be
> >> TCP_CLOSING, or it will give a WARN_ON. TCP works well with that
> >> while SCTP may trigger the call trace, as CLOSING state in SCTP
> >> has different meaning from TCP.
> >> 
> >> This fix is to change to use TCP_CLOSE_WAIT as SCTP_SS_CLOSING,
> >> instead of TCP_CLOSING. Some side-effects could be expected,
> >> regardless of not being used before. inet_accept will accept it
> >> now.
> >> 
> >> I did all the func_tests in lksctp-tools and ran sctp codnomicon
> >> fuzzer tests against this patch, no regression or failure found.
> >> 
> >> Signed-off-by: Xin Long 
> > 
> > I don't think this is -net material. It's a one line change but a core
> > one.
> > Dave please consider it for net-next instead.
> > Though, Xin you may need to re-post later..
> > 
> > Acked-by: Marcelo Ricardo Leitner 
> 
> But, the commit log message says that inet_accept() will generate
> a WARN_ON() call trace without this change.  That makes it sound
> like it's 'net' material to me.
> 

That's right, it will fix a WARN_ON(). I just feel that this change is
too intrusive for -net. But if you think it's okay, okay then.

  Marcelo


[PATCH v6 4/8] thunderbolt: Communication with the ICM (firmware)

2016-08-01 Thread Amir Levy
Firmware-based (a.k.a ICM - Intel Connection Manager) controller is
used for establishing and maintaining the Thunderbolt Networking
connection. We need to be able to communicate with it.

Signed-off-by: Amir Levy 
---
 drivers/thunderbolt/Makefile  |1 +
 drivers/thunderbolt/icm/Makefile  |   28 +
 drivers/thunderbolt/icm/icm_nhi.c | 1324 +
 drivers/thunderbolt/icm/icm_nhi.h |   93 +++
 drivers/thunderbolt/icm/net.h |  227 +++
 5 files changed, 1673 insertions(+)
 create mode 100644 drivers/thunderbolt/icm/Makefile
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.h
 create mode 100644 drivers/thunderbolt/icm/net.h

diff --git a/drivers/thunderbolt/Makefile b/drivers/thunderbolt/Makefile
index 7a85bd1..b6aa6a3 100644
--- a/drivers/thunderbolt/Makefile
+++ b/drivers/thunderbolt/Makefile
@@ -1,3 +1,4 @@
 obj-${CONFIG_THUNDERBOLT_APPLE} := thunderbolt.o
 thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o 
eeprom.o
 
+obj-${CONFIG_THUNDERBOLT_ICM} += icm/
diff --git a/drivers/thunderbolt/icm/Makefile b/drivers/thunderbolt/icm/Makefile
new file mode 100644
index 000..3adfc35
--- /dev/null
+++ b/drivers/thunderbolt/icm/Makefile
@@ -0,0 +1,28 @@
+
+#
+# Intel Thunderbolt(TM) driver
+# Copyright(c) 2014 - 2016 Intel Corporation.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms and conditions of the GNU General Public License,
+# version 2, as published by the Free Software Foundation.
+#
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program.  If not, see .
+#
+# The full GNU General Public License is included in this distribution in
+# the file called "COPYING".
+#
+# Contact Information:
+# Intel Thunderbolt Mailing List 
+# Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+#
+
+
+obj-${CONFIG_THUNDERBOLT_ICM} += thunderbolt-icm.o
+thunderbolt-icm-objs := icm_nhi.o
diff --git a/drivers/thunderbolt/icm/icm_nhi.c 
b/drivers/thunderbolt/icm/icm_nhi.c
new file mode 100644
index 000..bcb5c1b
--- /dev/null
+++ b/drivers/thunderbolt/icm/icm_nhi.c
@@ -0,0 +1,1324 @@
+/***
+ *
+ * Intel Thunderbolt(TM) driver
+ * Copyright(c) 2014 - 2016 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see .
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ *
+ * Contact Information:
+ * Intel Thunderbolt Mailing List 
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ 
**/
+
+#include 
+#include 
+#include 
+#include 
+#include "icm_nhi.h"
+#include "net.h"
+
+#define NHI_GENL_VERSION 1
+#define NHI_GENL_NAME DRV_NAME
+
+#define DEVICE_DATA(num_ports, dma_port, nvm_ver_offset, nvm_auth_on_boot,\
+   support_full_e2e) \
+   ((num_ports) | ((dma_port) << 4) | ((nvm_ver_offset) << 10) | \
+((nvm_auth_on_boot) << 22) | ((support_full_e2e) << 23))
+#define DEVICE_DATA_NUM_PORTS(device_data) ((device_data) & 0xf)
+#define DEVICE_DATA_DMA_PORT(device_data) (((device_data) >> 4) & 0x3f)
+#define DEVICE_DATA_NVM_VER_OFFSET(device_data) (((device_data) >> 10) & 0xfff)
+#define DEVICE_DATA_NVM_AUTH_ON_BOOT(device_data) (((device_data) >> 22) & 0x1)
+#define DEVICE_DATA_SUPPORT_FULL_E2E(device_data) (((device_data) >> 23) & 0x1)
+
+#define USEC_TO_256_NSECS(usec) DIV_ROUND_UP((usec) * NSEC_PER_USEC, 256)
+
+/* NHI genetlink commands */
+enum {
+   NHI_CMD_UNSPEC,
+   NHI_CMD_SUBSCRIBE,
+   NHI_CMD_UNSUBSCRIBE,
+   NHI_CMD_QUERY_INFORMATION,
+   NHI_CMD_MSG_TO_ICM,
+   NHI_CMD_MSG_FROM_ICM,
+   NHI_CMD_MAILBOX,
+   NHI_CMD_APPROVE_TBT_NETWORKING,
+   NHI_CMD_ICM_IN_SAFE_MODE,
+   __NHI_CMD_MAX,
+};
+#define

[PATCH v6 0/8] thunderbolt: Introducing Thunderbolt(TM) networking

2016-08-01 Thread Amir Levy
This is version 6 of Thunderbolt(TM) driver for non-Apple hardware.

Changes since v5:
 - Removed the padding of short packets in receive
 - Replaced RW semaphore with mutex
 - Cleanup

These patches were pushed to GitHub where they can be reviewed more
comfortably with green/red highlighting:
https://github.com/01org/thunderbolt-software-kernel-tree

Daemon code:
https://github.com/01org/thunderbolt-software-daemon

For reference, here's a link to version 5:
[v5]:   https://lkml.org/lkml/2016/7/28/85

Amir Levy (8):
  thunderbolt: Macro rename
  thunderbolt: Updating the register definitions
  thunderbolt: Kconfig for Thunderbolt(TM) networking
  thunderbolt: Communication with the ICM (firmware)
  thunderbolt: Networking state machine
  thunderbolt: Networking transmit and receive
  thunderbolt: Networking doc
  thunderbolt: Adding maintainer entry

 Documentation/00-INDEX   |2 +
 Documentation/thunderbolt-networking.txt |  135 ++
 MAINTAINERS  |8 +-
 drivers/thunderbolt/Kconfig  |   25 +-
 drivers/thunderbolt/Makefile |3 +-
 drivers/thunderbolt/icm/Makefile |   28 +
 drivers/thunderbolt/icm/icm_nhi.c| 1622 +
 drivers/thunderbolt/icm/icm_nhi.h|   93 ++
 drivers/thunderbolt/icm/net.c| 2264 ++
 drivers/thunderbolt/icm/net.h|  297 
 drivers/thunderbolt/nhi_regs.h   |  115 +-
 11 files changed, 4583 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/thunderbolt-networking.txt
 create mode 100644 drivers/thunderbolt/icm/Makefile
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.h
 create mode 100644 drivers/thunderbolt/icm/net.c
 create mode 100644 drivers/thunderbolt/icm/net.h

-- 
2.7.4



[PATCH v6 7/8] thunderbolt: Networking doc

2016-08-01 Thread Amir Levy
Adding Thunderbolt(TM) networking documentation.

Signed-off-by: Amir Levy 
---
 Documentation/00-INDEX   |   2 +
 Documentation/thunderbolt-networking.txt | 135 +++
 2 files changed, 137 insertions(+)
 create mode 100644 Documentation/thunderbolt-networking.txt

diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index cb9a6c6..80a6706 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -439,6 +439,8 @@ this_cpu_ops.txt
- List rationale behind and the way to use this_cpu operations.
 thermal/
- directory with information on managing thermal issues (CPU/temp)
+thunderbolt-networking.txt
+   - Thunderbolt(TM) Networking driver description.
 trace/
- directory with info on tracing technologies within linux
 unaligned-memory-access.txt
diff --git a/Documentation/thunderbolt-networking.txt 
b/Documentation/thunderbolt-networking.txt
new file mode 100644
index 000..e112313
--- /dev/null
+++ b/Documentation/thunderbolt-networking.txt
@@ -0,0 +1,135 @@
+Intel Thunderbolt(TM) Linux driver
+==
+
+Copyright(c) 2013 - 2016 Intel Corporation.
+
+Contact Information:
+Intel Thunderbolt mailing list 
+Edited by Michael Jamet 
+
+Overview
+
+
+Thunderbolt(TM) Networking mode is introduced with this driver.
+This kernel code creates an ethernet device utilized in computer to computer
+communication over a Thunderbolt cable.
+This driver has been added on the top of the existing thunderbolt driver
+for systems with firwmare (FW) based Thunderbolt controllers supporting
+Thunderbolt Networking.
+
+Files
+=
+
+- icm_nhi.c/h: These files allow communication with the FW (a.k.a ICM) based 
controller.
+   In addition, they create an interface for netlink communication 
with
+   a user space daemon.
+
+- net.c/net.h: These files implement the 'eth' interface for the 
Thunderbolt(TM)
+   networking.
+
+Interface to user space
+===
+
+The interface to the user space module is implemented through a Generic 
Netlink.
+In order to be accessed by the user space module, both kernel and user space
+modules have to register with the same GENL_NAME. In our case, this is
+simply "thunderbolt".
+The registration is done at driver initialization time for all instances of
+the Thunderbolt controllers.
+The communication is then carried through pre-defined Thunderbolt messages.
+Each specific message has a callback function that is called when
+the related message is received.
+
+The messages are defined as follows:
+* NHI_CMD_UNSPEC: Not used.
+* NHI_CMD_SUBSCRIBE: Subscription request from daemon to driver to open the
+  communication channel.
+* NHI_CMD_UNSUBSCRIBE: Request from daemon to driver to unsubscribe
+  to close communication channel.
+* NHI_CMD_QUERY_INFORMATION: Request information from the driver such as
+  driver version, FW version offset, number of ports in the controller
+  and DMA port.
+* NHI_CMD_MSG_TO_ICM: Message from user space module to FW.
+* NHI_CMD_MSG_FROM_ICM: Response from FW to user space module.
+* NHI_CMD_MAILBOX: Message that uses mailbox mechanism such as FW policy
+  changes or disconnect path.
+* NHI_CMD_APPROVE_TBT_NETWORKING: Request from user space
+  module to FW to establish path.
+* NHI_CMD_ICM_IN_SAFE_MODE: Indication that the FW has entered safe mode.
+
+Communication with ICM (Firmware)
+=
+
+The communication with ICM is principally achieved through
+a DMA mechanism on Ring 0.
+The driver allocates a shared memory that is physically mapped onto
+the DMA physical space at Ring 0.
+
+Interrupts
+==
+
+Thunderbolt relies on MSI-X interrupts.
+The MSI-X vector is allocated as follows:
+ICM
+ - Tx: MSI-X vector index 0
+ - Rx: MSI-X vector index 1
+
+Port 0
+ - Tx: MSI-X vector index 2
+ - Rx: MSI-X vector index 3
+
+Port 1
+ - Tx: MSI-X vector index 4
+ - Rx: MSI-X vector index 5
+
+ICM interrupts are used for communication with ICM only.
+Port 0 and Port 1 interrupts are used for Thunderbolt Networking
+communications.
+In case MSI-X is not available, the driver requests to enable MSI only.
+
+Mutexes, semaphores and spinlocks
+=
+
+The driver should be able to operate in an environment where hardware
+is asynchronously accessed by multiple entities such as netlink,
+multiple controllers etc.
+
+* send_sem: This semaphore enforces unique sender (one sender at a time)
+  to avoid wrong impairing with responses. FW may process one message
+  at the time.
+* d0_exit_send_mutex: This mutex protects D0 exit (D3) situation
+  to avoid continuing to send messages to FW.
+* d0_exit_mailbox_mutex: This mutex protects D0 exit (D3) situation to
+  avoid continuing to send commands to mailbox.
+* mailbox_mutex: This mutex enforces unique sender (one sender at a time)
+  for the mailbox command.
+  A mutex is sufficien

[PATCH v6 6/8] thunderbolt: Networking transmit and receive

2016-08-01 Thread Amir Levy
Handling the transmission to second peer and receiving from it.
This includes communication with upper layer, the network stack
and configuration of Thunderbolt(TM) HW.

Signed-off-by: Amir Levy 
---
 drivers/thunderbolt/icm/icm_nhi.c |   15 +
 drivers/thunderbolt/icm/net.c | 1471 +
 2 files changed, 1486 insertions(+)

diff --git a/drivers/thunderbolt/icm/icm_nhi.c 
b/drivers/thunderbolt/icm/icm_nhi.c
index b083f21c..e17adc5 100644
--- a/drivers/thunderbolt/icm/icm_nhi.c
+++ b/drivers/thunderbolt/icm/icm_nhi.c
@@ -1036,6 +1036,7 @@ static irqreturn_t nhi_msi(int __always_unused irq, void 
*data)
 {
struct tbt_nhi_ctxt *nhi_ctxt = data;
u32 isr0, isr1, imr0, imr1;
+   int i;
 
/* clear on read */
isr0 = ioread32(nhi_ctxt->iobase + REG_RING_NOTIFY_BASE);
@@ -1058,6 +1059,20 @@ static irqreturn_t nhi_msi(int __always_unused irq, void 
*data)
 
spin_unlock(&nhi_ctxt->lock);
 
+   for (i = 0; i < nhi_ctxt->num_ports; ++i) {
+   struct net_device *net_dev =
+   nhi_ctxt->net_devices[i].net_dev;
+   if (net_dev) {
+   u8 path = PATH_FROM_PORT(nhi_ctxt->num_paths, i);
+
+   if (isr0 & REG_RING_INT_RX_PROCESSED(
+   path, nhi_ctxt->num_paths))
+   tbt_net_rx_msi(net_dev);
+   if (isr0 & REG_RING_INT_TX_PROCESSED(path))
+   tbt_net_tx_msi(net_dev);
+   }
+   }
+
if (isr0 & REG_RING_INT_RX_PROCESSED(TBT_ICM_RING_NUM,
 nhi_ctxt->num_paths))
schedule_work(&nhi_ctxt->icm_msgs_work);
diff --git a/drivers/thunderbolt/icm/net.c b/drivers/thunderbolt/icm/net.c
index e11da23..7ce8930 100644
--- a/drivers/thunderbolt/icm/net.c
+++ b/drivers/thunderbolt/icm/net.c
@@ -134,6 +134,17 @@ struct approve_inter_domain_connection_cmd {
 
 };
 
+struct tbt_frame_header {
+   /* size of the data with the frame */
+   __le32 frame_size;
+   /* running index on the frames */
+   __le16 frame_index;
+   /* ID of the frame to match frames to specific packet */
+   __le16 frame_id;
+   /* how many frames assembles a full packet */
+   __le32 frame_count;
+};
+
 enum neg_event {
RECEIVE_LOGOUT = NUM_MEDIUM_STATUSES,
RECEIVE_LOGIN_RESPONSE,
@@ -141,15 +152,81 @@ enum neg_event {
NUM_NEG_EVENTS
 };
 
+enum frame_status {
+   GOOD_FRAME,
+   GOOD_AS_FIRST_FRAME,
+   GOOD_AS_FIRST_MULTICAST_FRAME,
+   FRAME_NOT_READY,
+   FRAME_ERROR,
+};
+
+enum packet_filter {
+   /* all multicast MAC addresses */
+   PACKET_TYPE_ALL_MULTICAST,
+   /* all types of MAC addresses: multicast, unicast and broadcast */
+   PACKET_TYPE_PROMISCUOUS,
+   /* all unicast MAC addresses */
+   PACKET_TYPE_UNICAST_PROMISCUOUS,
+};
+
 enum disconnect_path_stage {
STAGE_1 = BIT(0),
STAGE_2 = BIT(1)
 };
 
+struct tbt_net_stats {
+   u64 tx_packets;
+   u64 tx_bytes;
+   u64 tx_errors;
+   u64 rx_packets;
+   u64 rx_bytes;
+   u64 rx_length_errors;
+   u64 rx_over_errors;
+   u64 rx_crc_errors;
+   u64 rx_missed_errors;
+   u64 multicast;
+};
+
+static const char tbt_net_gstrings_stats[][ETH_GSTRING_LEN] = {
+   "tx_packets",
+   "tx_bytes",
+   "tx_errors",
+   "rx_packets",
+   "rx_bytes",
+   "rx_length_errors",
+   "rx_over_errors",
+   "rx_crc_errors",
+   "rx_missed_errors",
+   "multicast",
+};
+
+struct tbt_buffer {
+   dma_addr_t dma;
+   union {
+   struct tbt_frame_header *hdr;
+   struct page *page;
+   };
+   u32 page_offset;
+};
+
+struct tbt_desc_ring {
+   /* pointer to the descriptor ring memory */
+   struct tbt_buf_desc *desc;
+   /* physical address of the descriptor ring */
+   dma_addr_t dma;
+   /* array of buffer structs */
+   struct tbt_buffer *buffers;
+   /* last descriptor that was associated with a buffer */
+   u16 last_allocated;
+   /* next descriptor to check for DD status bit */
+   u16 next_to_clean;
+};
+
 /**
 *  struct tbt_port - the basic tbt_port structure
 *  @tbt_nhi_ctxt:  context of the nhi controller.
 *  @net_dev:   networking device object.
+*  @napi:  network API
 *  @login_retry_work:  work queue for sending login requests.
 *  @login_response_work:   work queue for sending login responses.
 *  @work_struct logout_work:   work queue for sending logout requests.
@@ -165,6 +242,11 @@ enum disconnect_path_stage {
 *  @login_retry_count: counts number of login retries sent.
 *  @local_depth:   depth of the remote peer in the chain.
 *  @transmit_path: routing parameter for the icm.
+*  @tx_ring:   

[PATCH v6 2/8] thunderbolt: Updating the register definitions

2016-08-01 Thread Amir Levy
Adding more Thunderbolt(TM) register definitions
and some helper macros.

Signed-off-by: Amir Levy 
---
 drivers/thunderbolt/nhi_regs.h | 109 +
 1 file changed, 109 insertions(+)

diff --git a/drivers/thunderbolt/nhi_regs.h b/drivers/thunderbolt/nhi_regs.h
index 75cf069..b8e961f 100644
--- a/drivers/thunderbolt/nhi_regs.h
+++ b/drivers/thunderbolt/nhi_regs.h
@@ -9,6 +9,11 @@
 
 #include 
 
+#define NHI_MMIO_BAR 0
+
+#define TBT_RING_MIN_NUM_BUFFERS   2
+#define TBT_RING_MAX_FRAME_SIZE(4 * 1024)
+
 enum ring_flags {
RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
@@ -39,6 +44,33 @@ struct ring_desc {
u32 time; /* write zero */
 } __packed;
 
+/**
+ * struct tbt_buf_desc - TX/RX ring buffer descriptor.
+ * This is same as struct ring_desc, but without the use of bitfields and
+ * with explicit endianity.
+ */
+struct tbt_buf_desc {
+   __le64 phys;
+   __le32 attributes;
+   __le32 time;
+};
+
+#define DESC_ATTR_LEN_SHIFT0
+#define DESC_ATTR_LEN_MASK GENMASK(11, DESC_ATTR_LEN_SHIFT)
+#define DESC_ATTR_EOF_SHIFT12
+#define DESC_ATTR_EOF_MASK GENMASK(15, DESC_ATTR_EOF_SHIFT)
+#define DESC_ATTR_SOF_SHIFT16
+#define DESC_ATTR_SOF_MASK GENMASK(19, DESC_ATTR_SOF_SHIFT)
+#define DESC_ATTR_TX_ISOCH_DMA_EN  BIT(20) /* TX */
+#define DESC_ATTR_RX_CRC_ERR   BIT(20) /* RX after use */
+#define DESC_ATTR_DESC_DONEBIT(21)
+#define DESC_ATTR_REQ_STS  BIT(22) /* TX and RX before use */
+#define DESC_ATTR_RX_BUF_OVRN_ERR  BIT(22) /* RX after use */
+#define DESC_ATTR_INT_EN   BIT(23)
+#define DESC_ATTR_OFFSET_SHIFT 24
+#define DESC_ATTR_OFFSET_MASK  GENMASK(31, DESC_ATTR_OFFSET_SHIFT)
+
+
 /* NHI registers in bar 0 */
 
 /*
@@ -60,6 +92,30 @@ struct ring_desc {
  */
 #define REG_RX_RING_BASE   0x08000
 
+#define REG_RING_STEP  16
+#define REG_RING_PHYS_LO_OFFSET0
+#define REG_RING_PHYS_HI_OFFSET4
+#define REG_RING_CONS_PROD_OFFSET  8   /* cons - RO, prod - RW */
+#define REG_RING_CONS_SHIFT0
+#define REG_RING_CONS_MASK GENMASK(15, REG_RING_CONS_SHIFT)
+#define REG_RING_PROD_SHIFT16
+#define REG_RING_PROD_MASK GENMASK(31, REG_RING_PROD_SHIFT)
+#define REG_RING_SIZE_OFFSET   12
+#define REG_RING_SIZE_SHIFT0
+#define REG_RING_SIZE_MASK GENMASK(15, REG_RING_SIZE_SHIFT)
+#define REG_RING_BUF_SIZE_SHIFT16
+#define REG_RING_BUF_SIZE_MASK GENMASK(27, REG_RING_BUF_SIZE_SHIFT)
+
+#define TBT_RING_CONS_PROD_REG(iobase, ringbase, ringnumber) \
+ ((iobase) + (ringbase) + \
+ ((ringnumber) * REG_RING_STEP) + \
+ REG_RING_CONS_PROD_OFFSET)
+
+#define TBT_REG_RING_PROD_EXTRACT(val) (((val) & REG_RING_PROD_MASK) >> \
+  REG_RING_PROD_SHIFT)
+
+#define TBT_REG_RING_CONS_EXTRACT(val) (((val) & REG_RING_CONS_MASK) >> \
+  REG_RING_CONS_SHIFT)
 /*
  * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  * 00: enum_ring_flags
@@ -77,6 +133,19 @@ struct ring_desc {
  * ..: unknown
  */
 #define REG_RX_OPTIONS_BASE0x29800
+#define REG_RX_OPTS_TX_E2E_HOP_ID_SHIFT12
+#define REG_RX_OPTS_TX_E2E_HOP_ID_MASK \
+   GENMASK(22, REG_RX_OPTS_TX_E2E_HOP_ID_SHIFT)
+#define REG_RX_OPTS_MASK_OFFSET4
+#define REG_RX_OPTS_MASK_EOF_SHIFT 0
+#define REG_RX_OPTS_MASK_EOF_MASK  GENMASK(15, REG_RX_OPTS_MASK_EOF_SHIFT)
+#define REG_RX_OPTS_MASK_SOF_SHIFT 16
+#define REG_RX_OPTS_MASK_SOF_MASK  GENMASK(31, REG_RX_OPTS_MASK_SOF_SHIFT)
+
+#define REG_OPTS_STEP  32
+#define REG_OPTS_E2E_ENBIT(28)
+#define REG_OPTS_RAW   BIT(30)
+#define REG_OPTS_VALID BIT(31)
 
 /*
  * three bitfields: tx, rx, rx overflow
@@ -86,6 +155,7 @@ struct ring_desc {
  */
 #define REG_RING_NOTIFY_BASE   0x37800
 #define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32)
+#define REG_RING_NOTIFY_STEP   4
 
 /*
  * two bitfields: rx, tx
@@ -94,8 +164,47 @@ struct ring_desc {
  */
 #define REG_RING_INTERRUPT_BASE0x38200
 #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32)
+#define REG_RING_INT_TX_PROCESSED(ring_num)BIT(ring_num)
+#define REG_RING_INT_RX_PROCESSED(ring_num, num_paths) BIT((ring_num) + \
+   (num_paths))
+#define RING_INT_DISABLE(base, val) iowrite32( \
+   ioread32((base) + REG_RING_INTERRUPT_BASE) & ~(val), \
+   (base) + REG_RING_INTERRUPT_BASE)
+#define RING_INT_ENABLE(base, val) iowrite32( \
+  

[PATCH v6 5/8] thunderbolt: Networking state machine

2016-08-01 Thread Amir Levy
Negotiation states that a peer goes through in order to establish
the communication with the second peer.
This includes communication with upper layer and additional
infrastructure support to communicate with the second peer through ICM.

Signed-off-by: Amir Levy 
---
 drivers/thunderbolt/icm/Makefile  |   2 +-
 drivers/thunderbolt/icm/icm_nhi.c | 303 ++-
 drivers/thunderbolt/icm/net.c | 793 ++
 drivers/thunderbolt/icm/net.h |  70 
 4 files changed, 1157 insertions(+), 11 deletions(-)
 create mode 100644 drivers/thunderbolt/icm/net.c

diff --git a/drivers/thunderbolt/icm/Makefile b/drivers/thunderbolt/icm/Makefile
index 3adfc35..624ee31 100644
--- a/drivers/thunderbolt/icm/Makefile
+++ b/drivers/thunderbolt/icm/Makefile
@@ -25,4 +25,4 @@
 

 
 obj-${CONFIG_THUNDERBOLT_ICM} += thunderbolt-icm.o
-thunderbolt-icm-objs := icm_nhi.o
+thunderbolt-icm-objs := icm_nhi.o net.o
diff --git a/drivers/thunderbolt/icm/icm_nhi.c 
b/drivers/thunderbolt/icm/icm_nhi.c
index bcb5c1b..b083f21c 100644
--- a/drivers/thunderbolt/icm/icm_nhi.c
+++ b/drivers/thunderbolt/icm/icm_nhi.c
@@ -74,6 +74,12 @@ static const struct nla_policy nhi_genl_policy[NHI_ATTR_MAX 
+ 1] = {
.len = TBT_ICM_RING_MAX_FRAME_SIZE },
[NHI_ATTR_MSG_FROM_ICM] = { .type = NLA_BINARY,
.len = TBT_ICM_RING_MAX_FRAME_SIZE },
+   [NHI_ATTR_LOCAL_ROUTE_STRING]   = {.len = sizeof(struct route_string)},
+   [NHI_ATTR_LOCAL_UUID]   = { .len = sizeof(uuid_be) },
+   [NHI_ATTR_REMOTE_UUID]  = { .len = sizeof(uuid_be) },
+   [NHI_ATTR_LOCAL_DEPTH]  = { .type = NLA_U8, },
+   [NHI_ATTR_ENABLE_FULL_E2E]  = { .type = NLA_FLAG, },
+   [NHI_ATTR_MATCH_FRAME_ID]   = { .type = NLA_FLAG, },
 };
 
 /* NHI genetlink family */
@@ -522,6 +528,29 @@ int nhi_mailbox(struct tbt_nhi_ctxt *nhi_ctxt, u32 cmd, 
u32 data, bool deinit)
return 0;
 }
 
+static inline bool nhi_is_path_disconnected(u32 cmd, u8 num_ports)
+{
+   return (cmd >= DISCONNECT_PORT_A_INTER_DOMAIN_PATH &&
+   cmd < (DISCONNECT_PORT_A_INTER_DOMAIN_PATH + num_ports));
+}
+
+static int nhi_mailbox_disconn_path(struct tbt_nhi_ctxt *nhi_ctxt, u32 cmd)
+   __releases(&controllers_list_mutex)
+{
+   struct port_net_dev *port;
+   u32 port_num = cmd - DISCONNECT_PORT_A_INTER_DOMAIN_PATH;
+
+   port = &(nhi_ctxt->net_devices[port_num]);
+   mutex_lock(&port->state_mutex);
+
+   mutex_unlock(&controllers_list_mutex);
+   port->medium_sts = MEDIUM_READY_FOR_APPROVAL;
+   if (port->net_dev)
+   negotiation_events(port->net_dev, MEDIUM_DISCONNECTED);
+   mutex_unlock(&port->state_mutex);
+   return  0;
+}
+
 static int nhi_mailbox_generic(struct tbt_nhi_ctxt *nhi_ctxt, u32 mb_cmd)
__releases(&controllers_list_mutex)
 {
@@ -571,13 +600,94 @@ static int nhi_genl_mailbox(__always_unused struct 
sk_buff *u_skb,
return -ERESTART;
 
nhi_ctxt = nhi_search_ctxt(*(u32 *)info->userhdr);
-   if (nhi_ctxt && !nhi_ctxt->d0_exit)
-   return nhi_mailbox_generic(nhi_ctxt, mb_cmd);
+   if (nhi_ctxt && !nhi_ctxt->d0_exit) {
+
+   /* rwsem is released later by the below functions */
+   if (nhi_is_path_disconnected(cmd, nhi_ctxt->num_ports))
+   return nhi_mailbox_disconn_path(nhi_ctxt, cmd);
+   else
+   return nhi_mailbox_generic(nhi_ctxt, mb_cmd);
+
+   }
 
mutex_unlock(&controllers_list_mutex);
return -ENODEV;
 }
 
+static int nhi_genl_approve_networking(__always_unused struct sk_buff *u_skb,
+  struct genl_info *info)
+{
+   struct tbt_nhi_ctxt *nhi_ctxt;
+   struct route_string *route_str;
+   int res = -ENODEV;
+   u8 port_num;
+
+   if (!info || !info->userhdr || !info->attrs ||
+   !info->attrs[NHI_ATTR_LOCAL_ROUTE_STRING] ||
+   !info->attrs[NHI_ATTR_LOCAL_UUID] ||
+   !info->attrs[NHI_ATTR_REMOTE_UUID] ||
+   !info->attrs[NHI_ATTR_LOCAL_DEPTH])
+   return -EINVAL;
+
+   /*
+* route_str is an unique topological address
+* used for approving remote controller
+*/
+   route_str = nla_data(info->attrs[NHI_ATTR_LOCAL_ROUTE_STRING]);
+   /* extracts the port we're connected to */
+   port_num = PORT_NUM_FROM_LINK(L0_PORT_NUM(route_str->lo));
+
+   if (mutex_lock_interruptible(&controllers_list_mutex))
+   return -ERESTART;
+
+   nhi_ctxt = nhi_search_ctxt(*(u32 *)info->userhdr);
+   if (nhi_ctxt && !nhi_ctxt->d0_exit) {
+   struct port_net_dev *port;
+
+   if (port_num >= nhi_ctxt->num_ports) {
+   res = -EINVAL;
+  

[PATCH v6 3/8] thunderbolt: Kconfig for Thunderbolt(TM) networking

2016-08-01 Thread Amir Levy
Updating the Kconfig Thunderbolt(TM) description.

Signed-off-by: Amir Levy 
---
 drivers/thunderbolt/Kconfig  | 25 +
 drivers/thunderbolt/Makefile |  2 +-
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/thunderbolt/Kconfig b/drivers/thunderbolt/Kconfig
index c121acc..d34b0f5 100644
--- a/drivers/thunderbolt/Kconfig
+++ b/drivers/thunderbolt/Kconfig
@@ -1,13 +1,30 @@
-menuconfig THUNDERBOLT
-   tristate "Thunderbolt support for Apple devices"
+config THUNDERBOLT
+   tristate "Thunderbolt(TM) support"
depends on PCI
select CRC32
help
- Cactus Ridge Thunderbolt Controller driver
+ Thunderbolt(TM) Controller driver
+
+if THUNDERBOLT
+
+config THUNDERBOLT_APPLE
+   tristate "Apple hardware support"
+   help
  This driver is required if you want to hotplug Thunderbolt devices on
  Apple hardware.
 
  Device chaining is currently not supported.
 
- To compile this driver a module, choose M here. The module will be
+ To compile this driver as a module, choose M here. The module will be
  called thunderbolt.
+
+config THUNDERBOLT_ICM
+   tristate "Thunderbolt(TM) Networking"
+   help
+ This driver is required if you want Thunderbolt(TM) Networking on
+ non-Apple hardware.
+
+ To compile this driver as a module, choose M here. The module will be
+ called thunderbolt_icm.
+
+endif
diff --git a/drivers/thunderbolt/Makefile b/drivers/thunderbolt/Makefile
index 5d1053c..7a85bd1 100644
--- a/drivers/thunderbolt/Makefile
+++ b/drivers/thunderbolt/Makefile
@@ -1,3 +1,3 @@
-obj-${CONFIG_THUNDERBOLT} := thunderbolt.o
+obj-${CONFIG_THUNDERBOLT_APPLE} := thunderbolt.o
 thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o 
eeprom.o
 
-- 
2.7.4



[PATCH v6 1/8] thunderbolt: Macro rename

2016-08-01 Thread Amir Levy
This first patch updates the registers file to
reflect that it isn't only for Cactus Ridge.
No functional change intended.

Signed-off-by: Amir Levy 
---
 drivers/thunderbolt/nhi_regs.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/nhi_regs.h b/drivers/thunderbolt/nhi_regs.h
index 86b996c..75cf069 100644
--- a/drivers/thunderbolt/nhi_regs.h
+++ b/drivers/thunderbolt/nhi_regs.h
@@ -1,11 +1,11 @@
 /*
- * Thunderbolt Cactus Ridge driver - NHI registers
+ * Thunderbolt driver - NHI registers
  *
  * Copyright (c) 2014 Andreas Noever 
  */
 
-#ifndef DSL3510_REGS_H_
-#define DSL3510_REGS_H_
+#ifndef NHI_REGS_H_
+#define NHI_REGS_H_
 
 #include 
 
-- 
2.7.4



[PATCH v6 8/8] thunderbolt: Adding maintainer entry

2016-08-01 Thread Amir Levy
Add Amir Levy as maintainer for Thunderbolt(TM) ICM driver

Signed-off-by: Amir Levy 
---
 MAINTAINERS | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 72f7703..2b6d635 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10193,7 +10193,13 @@ F: include/uapi/linux/stm.h
 THUNDERBOLT DRIVER
 M: Andreas Noever 
 S: Maintained
-F: drivers/thunderbolt/
+F: drivers/thunderbolt/*
+
+THUNDERBOLT ICM DRIVER
+M: Amir Levy 
+S: Maintained
+F: drivers/thunderbolt/icm/
+F: Documentation/thunderbolt-networking.txt
 
 TI BQ27XXX POWER SUPPLY DRIVER
 R: Andrew F. Davis 
-- 
2.7.4



Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-08-01 Thread Masashi Honma

On 2016年08月01日 19:03, Johannes Berg wrote:


But why is that behaviour *correct*? We still support 40 MHz bandwidth
things, we just don't use them if we disable HT40.


I could not fully understand your concern...

Do you mean we have 2 bugs about disabling HT40 ?

1) bits in HT capabilities IE
2) HT40 still enabled even if it was disabled by wpa_supplicant or 
hostapd with disable_ht40


And do you mean 1) and 2) should be fixed at one time ?
Indeed, currently on the view point of opposite peer, HT40 was enabled 
even though it was disabled because both 1) and 2) are wrong.

But if only 1) was fixed, this causes unmatch.

Now I do not recognize bug 2).
Do you have any information about 2) ?


Re: [PATCH RESEND nf] netfilter: avoid a race between nf_register_hook() and cleanup_net()

2016-08-01 Thread Pablo Neira Ayuso
On Sat, Jul 30, 2016 at 08:24:37AM -0500, Eric W. Biederman wrote:
> Michal Kubecek  writes:
> 
> > There is a race condition between nf_{,un}register_hook() and
> > cleanup_net() which can either trigger WARN check or cause a memory
> > leak. The scenario is like this (2a and 2b are alternatives):
> >
> > 1.  cleanup_net() removes one or more struct net from net_namespace_list
> > 2a. nf_register_hook() adds per-netns hooks to all netns (but not those
> > removed in step 1) and adds the hook to global nf_hook_list
> > 2b. nf_unregister_hook() deletes per-netns hooks from all netns (but not
> > those removed in step 1) and removes the hook from nf_hook_list
> > 3.  cleanup_net() calls pernet subsystem exit functions for netns being
> > removed; one of them is netfilter_net_exit() which (among others)
> > calls nf_unregister_net_hook() to unregister per-netns hooks for all
> > hooks in nf_hook_list.
> >
> > In case (a), per-netns hooks are never added as the namespace was
> > already invisible to for_each_net() in step 2a but an attempt to remove
> > them in step 3 (the hook is already in nf_hook_list) triggers a WARN
> > check in nf_unregister_net_hook() (no real harm done, however). In case
> > (b), the per-netns hook is removed neither in step 2b (netns is already
> > invisible to for_each_net()) nor in step 3 (the hook is already removed
> > from nf_hook_list), causing a memory leak.
> >
> > Prevent the race by protecting the for_each_net() loop in
> > nf_{,un}register_hook() (also) by net_mutex. There is already a
> > precendens for this in rtnl_link_unregister() which addresses similar
> > race.
> 
> So this analysis of a problem appears to be spot on.
> 
> Reviewed-by: "Eric W. Biederman" 
> 
> 
> I really really want there to be a better way to do this, but it is
> really not ok for a hook to continue it's life past
> nf_unregister_net_hook as after that point the code may be removed
> from the kernel (sigh).
> 
> Although keeping with the precedent and minimizing net_mutex
> we could remove the WARN and keep nf_register_hook as it is.
> But that sounds entirely too clever for a fix that will
> probably be backported.
> 
> But that sounds entirely too clever for a fix that likely needs to be
> backported.

Please, propagate up to the caller to register and unregister the
hooks from init_net and exit_net instead as I suggested time ago.

I understand that this is not as small as this patch, and that this
will require a bit more boiler plate code in iptable_*.c and nftables
itself, but we'll avoid the dependencies with both rtnl_lock and
net_lock.

Thanks.


e1000e: PHY cann't be initialized correctly on some I218 controllers

2016-08-01 Thread Denis Turischev
There is an error "e1000e: probe of :00:19.0 failed with error -3"
that can be observed after power-on on some I218 controllers.
Hardware reset and re-initialization fixes the issue.

Signed-off-by: Denis Turischev 

diff -Nru linux-4.7.orig/drivers/net/ethernet/intel/e1000e/ich8lan.c 
linux-4.7/drivers/net/ethernet/intel/e1000e/ich8lan.c
--- linux-4.7.orig/drivers/net/ethernet/intel/e1000e/ich8lan.c  2016-07-24 
22:23:50.0 +0300
+++ linux-4.7/drivers/net/ethernet/intel/e1000e/ich8lan.c   2016-08-01 
13:59:08.046563095 +0300
@@ -155,6 +155,7 @@
 static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force);
 static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
 static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state);
+static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw);
 
 static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
 {
@@ -459,8 +460,12 @@
phy->id = e1000_phy_unknown;
 
ret_val = e1000_init_phy_workarounds_pchlan(hw);
-   if (ret_val)
-   return ret_val;
+   if (ret_val) {
+   e1000_reset_hw_ich8lan(hw);
+   ret_val = e1000_init_phy_workarounds_pchlan(hw);
+   if (ret_val)
+   return ret_val;
+   }
 
if (phy->id == e1000_phy_unknown)
switch (hw->mac.type) {


Re: [PATCH 1/3] sctp: Export struct sctp_info to userspace

2016-08-01 Thread Phil Sutter
Hi Stephen,

On Sun, Jul 31, 2016 at 02:18:24PM -0700, Stephen Hemminger wrote:
> On Fri, 29 Jul 2016 18:59:38 +0200
> Phil Sutter  wrote:
> 
> > This is required to correctly interpret INET_DIAG_INFO messages exported
> > by sctp_diag module.
> > 
> > Signed-off-by: Phil Sutter 
> 
> You need to add sctp.h to include/linux/Kbuild to get it exported correctly

Thanks for the heads-up! Luckily it is in there already.

Cheers, Phil


[PATCH net] qed: Fail driver load in 100g MSI mode.

2016-08-01 Thread Sudarsana Reddy Kalluru
100g support is not available in MSI mode. Failing the driver load in this 
scenario.

Please consider applying this to `net'.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 1f13abb..c7dc34b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -659,8 +659,13 @@ static int qed_slowpath_setup_int(struct qed_dev *cdev,
struct qed_sb_cnt_info sb_cnt_info;
int rc;
int i;
-   memset(&cdev->int_params, 0, sizeof(struct qed_int_params));
 
+   if ((int_mode == QED_INT_MODE_MSI) && (cdev->num_hwfns > 1)) {
+   DP_NOTICE(cdev, "MSI mode is not supported for CMT devices\n");
+   return -EINVAL;
+   }
+
+   memset(&cdev->int_params, 0, sizeof(struct qed_int_params));
cdev->int_params.in.int_mode = int_mode;
for_each_hwfn(cdev, i) {
memset(&sb_cnt_info, 0, sizeof(sb_cnt_info));
-- 
1.8.3.1



RE: [PATCH net-next 2/3] bna: change type of bna_id to atomic_t

2016-08-01 Thread David Laight
From: Ivan Vecera
> Sent: 29 July 2016 18:53
> Change type of bna_id to atomic_t. The bnad_list_mutex is used to prevent
> a race when bna_id is incremented. After the change the mutex can be
> removed in the next step.
...
> -static u32 bna_id;
> +static atomic_t bna_id;
...
>   bnad_lock_init(bnad);
>   bnad_add_to_list(bnad);
> + bnad->id = atomic_inc_return(&bna_id) - 1;
...

Is the 'id' expected to be unique?
Looks like they get reallocated after 2^32 allocates.

David




Re: [PATCH net-next 2/3] bna: change type of bna_id to atomic_t

2016-08-01 Thread Ivan Vecera

On 1.8.2016 16:20, David Laight wrote:

From: Ivan Vecera

Sent: 29 July 2016 18:53
Change type of bna_id to atomic_t. The bnad_list_mutex is used to prevent
a race when bna_id is incremented. After the change the mutex can be
removed in the next step.

...

-static u32 bna_id;
+static atomic_t bna_id;

...

bnad_lock_init(bnad);
bnad_add_to_list(bnad);
+   bnad->id = atomic_inc_return(&bna_id) - 1;

...

Is the 'id' expected to be unique?
Looks like they get reallocated after 2^32 allocates.

David


I have just converted it to atomic type to eliminate mutex. The id is 
only used as parameter 'instance' for bfa_nw_flash_{update,read}_part(). 
There is no documentation in source code regarding this so this is a 
question to Qlogic.


Ivan


Re: [PATCH] net/mlx5_core/pagealloc: Remove deprecated create_singlethread_workqueue

2016-08-01 Thread Tejun Heo
Hello, Leon.

On Sun, Jul 31, 2016 at 09:35:13AM +0300, Leon Romanovsky wrote:
> > The conversion uses WQ_MEM_RECLAIM, which is standard for all
> > workqueues which can stall packet processing if stalled.  The
> > requirement comes from nfs or block devices over network.
> 
> The title stays "remove deprecated create_singlethread_workqueue" and if
> we put aside the word "deprecated", the code moves from ordered
> workqueue to unordered workqueue and changes max_active count which
> isn't expressed in commit message.

Maybe it was too compressed but the description says

"The workqueue has a single work item. Hence, alloc_workqueue() is
 used instead of alloc_ordered_workqueue() since ordering is
 unnecessary when there's only one work item."

There's only one work item so whether the workqueue is ordered and its
concurrency level don't make any difference.  The reason why people
used to use create_singlethread_workqueue() in these situations was
because per-cpu workqueues used to be very expensive which isn't true
anymore.

> For reclaim paths, I want to be extra caution and want to see
> justification for doing that along with understanding if it is tested or
> not.

WQ_MEM_RECLAIM maintains the behavior of the existing code and the
requirement comes from network interfaces being used for nfs and
transport for block devices and is universial to everything in network
layer.  The only test we can do here is removing it and pushing it
really hard and see whether we can actually trigger deadlock, which it
will under the right circumstances which may or may not be easy to
replicate in test environments.  I don't see many merits in doing this
especially when the behavior doesn't change from the existing code.

> Right now, I'm feeling that I'm participating in soapie where one sends
> patch for every line, waits and sends the same patch for another file.
> It is worth to send one patch set and let us to test it all in once.

Yeah, I guess it can be a bit annoying.  Bhaktipriya, can you please
group patches for meallnox?

Thanks.

-- 
tejun


Re: [PATCH v2] bpf: silence warnings when building kernel/bpf/core.c with W=1

2016-08-01 Thread Alexei Starovoitov
On Mon, Aug 01, 2016 at 01:18:43AM -0400, valdis.kletni...@vt.edu wrote:
> On Sun, 31 Jul 2016 21:42:22 -0700, Alexei Starovoitov said:
> 
> > and at least 2 other such patches for other files...
> > Is there a single warning where -Woverride-init was useful?
> > May be worth disabling this warning for the whole build?
> 
> There's a few other cases that *aren't* the "define the array to zero
> and then build the entries from a list" form.
> 
> In particular, there's still 3 odd complaints:
> 
> drivers/ata/ahci.c:
> drivers/ata/ahci.h:393:16: warning: initialized field overwritten 
> [-Woverride-in
> it]
>   .can_queue  = AHCI_MAX_CMDS - 1,
> 
> drivers/block/drbd/drbd_main.c:
> drivers/block/drbd/drbd_main.c:3767:22: warning: initialized field 
> overwritten [
> -Woverride-init]
>[P_RETRY_WRITE]  = "retry_write",
> 
> arch/x86/kernel/cpu/common.c:
> ./arch/x86/include/asm/page_64_types.h:22:21: warning: initialized field 
> overwri
> tten [-Woverride-init]
>  #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
> 
> The point of these patches is to make -Woverride-init *useful* - you'll never
> spot 3 warnings in a flood of over 9,000 understood-and-ignored warnings.
> 
> Get rid of the 9,000 understood-and-ignored warnings, and then things that
> probably *should* be looked at can be noticed.

I don't think it makes sense to play kernel whack-a-warning in a hope that
particular warning will find something useful.
Please show few cases where it actually found a real issue, otherwise
just disable it for all.




Re: [PATCH] bpf: fix size of copy_to_user in percpu map.

2016-08-01 Thread Alexei Starovoitov
On Sun, Jul 31, 2016 at 08:25:12AM -0700, William Tu wrote:
> >> >>num_possible_cpu == 64
> >> >>num_online_cpu == 2 == sysconf(_SC_NPROCESSORS_CONF)
> > ...
> >> >> To fix it, I could either
> >> >> 1). declare values array based on num_possible_cpu in test_map.c,
> >> >>long values[64];
> >> >> or 2) in kernel, only copying 8*2 = 16 byte from kernel to user.
> > ...
> >> Since percpu array adds variable length of data passing between kernel
> >> and userspace, I wonder if we should add a 'value_len' field in 'union
> >> bpf_attr' so kernel knows how much data to copy to user?
> >
> > I think the first step is to figure out why num_possible is 64,
> > since it hurts all per-cpu allocations. If it is a widespread issue,
> > it hurts a lot of VMs.
> > Hopefully it's not the case, since in my kvm setup num_possible==num_online
> > qemu version 2.4.0
> > booting with -enable-kvm -smp N
> >
> Thanks. I'm using VMware Fusion with 2 vcpu, running Fedora 23.
> 
> I tried on my another physical machine (Xeon E3), indeed
> "num_possible==num_online". In fact, num_online shouldn't be an issue.
> As long as num_possible == sysconf(SC_NPROCESSORS_CONF), then kernel
> and user are consistent about the size of data copied.
> 
> Diving into more details:
> when calling sysconf(_SC_NPROCESSORS_CONF), strace shows that it does
> "open("/sys/devices/system/cpu",
> O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
> And in my /sys/devices/system/cpu, I have cpu0 and cpu1,
> kernel_max = 63
> possible = 0-63
> present = 0-1

glibc is doing
ls -d /sys/devices/system/cpu/cpu*
http://osxr.org:8080/glibc/source/sysdeps/unix/sysv/linux/getsysstats.c?v=glibc-2.14#0180
And /sys/devices/system/cpu/possible shows 0-63 while only two dirs 'cpu0' and 
'cpu1'
are there?!
If my understanding of cpu_dev_register_generic() in drivers/base/cpu.c 
is correct the number of 'cpu*' dirs should be equal to possible_cpu.
Could you please debug why is that the case, because then it's probably
a bug on the kernel side.
I think it's correct for glibc to rely on the number of 'cpu*' dirs.
Did you boot with possible_cpus=64 command line arg by any chance?

> So sysconf simply reads these entries configured by kernel. Looking at
> kernel code, "arch/x86/configs/x86_64_defconfig" sets
> CONFIG_NR_CPUS=64, and later on set_cpu_possible() is called at
> arch/x86/kernel/smpboot.c, which parses the ACPI multiprocessor table
> and configured new value. Based on these observations, I think
> different hypervisor may have different ways of emulating ACPI
> processor table or BIOS implementation thus these values differ.

What behavior do you see in ESX ?
btw, rhel7 ships with nr_cpus=5120 and ubuntu default is 256,
so this lack of acpi in vmware fusion will lead to possible_cpu=5120,
a lot of pain in per-cpu allocator and linux VMs will not be happy.
I think vmware has to be fixed first regardless of what we find
out about 'cpu*' vs /sys/devices/system/cpu/possible



Re: [PATCH] net: thunderx: correct bound check in nic_config_loopback

2016-08-01 Thread Levin, Alexander
On 07/31/2016 12:41 PM, Sunil Kovvuri wrote:
> Thanks for finding.
> A much better fix would be,
> 
> -   if (lbk->vf_id > MAX_LMAC)
> +   if (lbk->vf_id >= nic->num_vf_en)
> return -1;
> 
> where 'num_vf_en' reflects the exact number of physical interfaces or
> LMACs on the system.

Right. I see quite a few more places that compare to MAX_LMAC vs
num_vf_en. What was the reasoning behind it then?


Thanks,
Sasha


Re: [PATCH] bpf: fix size of copy_to_user in percpu map.

2016-08-01 Thread William Tu
>> And in my /sys/devices/system/cpu, I have cpu0 and cpu1,
>> kernel_max = 63
>> possible = 0-63
>> present = 0-1
>
> glibc is doing
> ls -d /sys/devices/system/cpu/cpu*
> http://osxr.org:8080/glibc/source/sysdeps/unix/sysv/linux/getsysstats.c?v=glibc-2.14#0180
> And /sys/devices/system/cpu/possible shows 0-63 while only two dirs 'cpu0' 
> and 'cpu1'
> are there?!

yes, that's right.
I only have cpu0 and cpu1 directories, while 'possible' shows 0-63.

> If my understanding of cpu_dev_register_generic() in drivers/base/cpu.c
> is correct the number of 'cpu*' dirs should be equal to possible_cpu.
> Could you please debug why is that the case, because then it's probably
> a bug on the kernel side.

Thanks, I will do it.

> I think it's correct for glibc to rely on the number of 'cpu*' dirs.
> Did you boot with possible_cpus=64 command line arg by any chance?
>
No.

>> So sysconf simply reads these entries configured by kernel. Looking at
>> kernel code, "arch/x86/configs/x86_64_defconfig" sets
>> CONFIG_NR_CPUS=64, and later on set_cpu_possible() is called at
>> arch/x86/kernel/smpboot.c, which parses the ACPI multiprocessor table
>> and configured new value. Based on these observations, I think
>> different hypervisor may have different ways of emulating ACPI
>> processor table or BIOS implementation thus these values differ.
>
> What behavior do you see in ESX ?
> btw, rhel7 ships with nr_cpus=5120 and ubuntu default is 256,
> so this lack of acpi in vmware fusion will lead to possible_cpu=5120,
> a lot of pain in per-cpu allocator and linux VMs will not be happy.
> I think vmware has to be fixed first regardless of what we find
> out about 'cpu*' vs /sys/devices/system/cpu/possible
>

Thanks, I will debug it and update when I have more info.
Regards,
William


Re: [PATCH 1/1] net: s2io: simplify logical constraint

2016-08-01 Thread Jon Mason
On Sun, Jul 31, 2016 at 5:53 AM, Heinrich Schuchardt  wrote:
> (!A || (A && B)) is equivalent to (!A || B)

Seems logical to me.

Acked-by: Jon Mason 

> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/net/ethernet/neterion/s2io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/neterion/s2io.c 
> b/drivers/net/ethernet/neterion/s2io.c
> index 2874dff..eaa37c0 100644
> --- a/drivers/net/ethernet/neterion/s2io.c
> +++ b/drivers/net/ethernet/neterion/s2io.c
> @@ -7412,7 +7412,7 @@ static int rx_osm_handler(struct ring_info *ring_data, 
> struct RxD_t * rxdp)
>
> if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) &&
> ((!ring_data->lro) ||
> -(ring_data->lro && (!(rxdp->Control_1 & RXD_FRAME_IP_FRAG &&
> +(!(rxdp->Control_1 & RXD_FRAME_IP_FRAG))) &&
> (dev->features & NETIF_F_RXCSUM)) {
> l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1);
> l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1);
> --
> 2.8.1
>


[PATCH net-next v2 0/3] strp: Stream parser for messages

2016-08-01 Thread Tom Herbert
This patch set introduces a utility for parsing application layer
protocol messages in a TCP stream. This is a generalization of the
mechanism implemented of Kernel Connection Multiplexor.

This patch set adapts KCM to use the strparser. We expect that kTLS
can use this mechanism also. RDS would probably be another candidate
to use a common stream parsing mechanism.

The API includes a context structure, a set of callbacks, utility
functions, and a data ready function. The callbacks include
a parse_msg function that is called to perform parsing (e.g.
BPF parsing in case of KCM), and a rcv_msg function that is called
when a full message has been completed.

For strparser we specify the return codes from the parser to allow
the backend to indicate that control of the socket should be
transferred back to userspace to handle some exceptions in the
stream: The return values are:

  >0 : indicates length of successfully parsed message
   0  : indicates more data must be received to parse the message
   -ESTRPIPE : current message should not be processed by the
  kernel, return control of the socket to userspace which
  can proceed to read the messages itself
   other < 0 : Error is parsing, give control back to userspace
  assuming that synchronization is lost and the stream
  is unrecoverable (application expected to close TCP socket)

There is one issue I haven't been able to fully resolve. If parse_msg
returns ESTRPIPE (wants control back to userspace) the parser may
already have consumed some bytes of the message. There is no way to
put bytes back into the TCP receive queue and tcp_read_sock does not
allow an easy way to peek messages. In lieu of a better solution, we
return ENODATA on the socket to indicate that the data stream is
unrecoverable (application needs to close socket). This condition
should only happen if an application layer message header is split
across two skbuffs and parsing just the first skbuff wasn't sufficient
to determine the that transfer to userspace is needed.

This patch set contains:

  - strparser implementation
  - changes to kcm to use strparser
  - strparser.txt documentation

v2:
  - Add copyright notice to C files
  - Remove GPL module license from strparser.c
  - Add report of rxpause

Tested:
  - Ran a KCM thrash test for 24 hours. No behavioral or performance
differences observed.


Tom Herbert (3):
  strparser: Stream parser for messages
  kcm: Use stream parser
  strparser: Documentation

 Documentation/networking/strparser.txt | 147 ++
 include/net/kcm.h  |  37 +--
 include/net/strparser.h| 147 ++
 net/Kconfig|   1 +
 net/Makefile   |   1 +
 net/ipv6/ila/ila_common.c  |   1 -
 net/kcm/Kconfig|   1 +
 net/kcm/kcmproc.c  |  44 ++-
 net/kcm/kcmsock.c  | 464 +-
 net/strparser/Kconfig  |   4 +
 net/strparser/Makefile |   1 +
 net/strparser/strparser.c  | 500 +
 12 files changed, 916 insertions(+), 432 deletions(-)
 create mode 100644 Documentation/networking/strparser.txt
 create mode 100644 include/net/strparser.h
 create mode 100644 net/strparser/Kconfig
 create mode 100644 net/strparser/Makefile
 create mode 100644 net/strparser/strparser.c

-- 
2.8.0.rc2



[PATCH net-next v2 3/3] strparser: Documentation

2016-08-01 Thread Tom Herbert
Signed-off-by: Tom Herbert 
---
 Documentation/networking/strparser.txt | 147 +
 1 file changed, 147 insertions(+)
 create mode 100644 Documentation/networking/strparser.txt

diff --git a/Documentation/networking/strparser.txt 
b/Documentation/networking/strparser.txt
new file mode 100644
index 000..abfef72
--- /dev/null
+++ b/Documentation/networking/strparser.txt
@@ -0,0 +1,147 @@
+Stream Parser
+-
+
+The stream parser (strparser) is a utility that parses messages of an
+application layer protocol running over a TCP connection. The stream
+parser works in conjunction with an upper layer in the kernel to provide
+kernel support for application layer messages. For instance, Kernel
+Connection Multiplexor (KCM) uses the Stream Parser to parse messages
+using a BPF program.
+
+Interface
+-
+
+The API includes a context structure, a set of callbacks, utility
+functions, and a data_ready function. The callbacks include
+a parse_msg function that is called to perform parsing (e.g.
+BPF parsing in case of KCM), and a rcv_msg function that is called
+when a full message has been completed.
+
+A stream parser can be instantiated for a TCP connection. This is done
+by:
+
+strp_init(struct strparser *strp, struct sock *csk,
+ struct strp_callbacks *cb)
+
+strp is a struct of type strparser that is allocated by the upper layer.
+csk is the TCP socket associated with the stream parser. Callbacks are
+called by the stream parser.
+
+Callbacks
+-
+
+There are four callbacks:
+
+int (*parse_msg)(struct strparser *strp, struct sk_buff *skb);
+
+parse_msg is called to determine the length of the next message
+in the stream. The upper layer must implement this function. It
+should parse the sk_buff as containing the headers for the
+next application layer messages in the stream.
+
+The skb->cb in the input skb is a struct strp_rx_msg. Only
+the offset field is relevant in parse_msg and gives the offset
+where the message starts in the skb.
+
+The return values of this function are:
+
+>0 : indicates length of successfully parsed message
+0  : indicates more data must be received to parse the message
+-ESTRPIPE : current message should not be processed by the
+  kernel, return control of the socket to userspace which
+  can proceed to read the messages itself
+other < 0 : Error is parsing, give control back to userspace
+  assuming that synchronization is lost and the stream
+  is unrecoverable (application expected to close TCP socket)
+
+In the case that an error is returned (return value is less than
+zero) the stream parser will set the error on TCP socket and wake
+it up. If parse_msg returned -ESTRPIPE and the stream parser had
+previously read some bytes for the current message, then the error
+set on the attached socket is ENODATA since the stream is
+unrecoverable in that case.
+
+void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb);
+
+rcv_msg is called when a full message has been received and
+is queued. The callee must consume the sk_buff; it can
+call strp_pause to prevent any further messages from being
+received in rcv_msg (see strp_pause below). This callback
+must be set.
+
+The skb->cb in the input skb is a struct strp_rx_msg. This
+struct contains two fields: offset and full_len. Offset is
+where the message starts in the skb, and full_len is the
+the length of the message. skb->len - offset may be greater
+then full_len since strparser does not trim the skb.
+
+int (*read_sock_done)(struct strparser *strp, int err);
+
+ read_sock_done is called when the stream parser is done reading
+ the TCP socket. The stream parser may read multiple messages
+ in a loop and this function allows cleanup to occur when existing
+ the loop. If the callback is not set (NULL in strp_init) a
+ default function is used.
+
+void (*abort_parser)(struct strparser *strp, int err);
+
+ This function is called when stream parser encounters an error
+ in parsing. The default function stops the stream parser for the
+ TCP socket and sets the error in the socket. The default function
+ can be changed by setting the callback to non-NULL in strp_init.
+
+data_ready
+--
+
+strp_tcp_data_ready is the TCP data ready function that can be used with
+the stream parser. When the upper layer attaches the TCP socket it
+can set sk_data_ready to this function (after strp_init). sk_user_data
+must be set to the stream parser structure to use this (container_of
+can be used in the other socket callbacks to get the upper layer
+structure from the stream parser structure).
+
+Functions
+-
+
+The upper layer uses strp_pause and strp_unpause to flow control the
+stream parser. This is needed for instance when the upper layer can't
+immediately process a received message and has to 

[PATCH net-next v2 1/3] strparser: Stream parser for messages

2016-08-01 Thread Tom Herbert
This patch introduces a utility for parsing application layer protocol
messages in a TCP stream. This is a generalization of the mechanism
implemented of Kernel Connection Multiplexor.

The API includes a context structure, a set of callbacks, utility
functions, and a data ready function.

A stream parser instance is defined by a strparse structure that
is bound to a TCP socket. The function to initialize the structure
is:

int strp_init(struct strparser *strp, struct sock *csk,
  struct strp_callbacks *cb);

csk is the TCP socket being bound to and cb are the parser callbacks.

A parser is bound to a TCP socket by setting data_ready function to
strp_tcp_data_ready so that all receive indications on the socket
go through the parser. This is assumes that sk_user_data is set to
the strparser structure.

There are four callbacks.
 - parse_msg is called to parse the message (returns length or error).
 - rcv_msg is called when a complete message has been received
 - read_sock_done is called when data_ready function exits
 - abort_parser is called to abort the parser

The input to parse_msg is an skbuff which contains next message under
construction. The backend processing of parse_msg will parse the
application layer protocol headers to determine the length of
the message in the stream. The possible return values are:

   >0 : indicates length of successfully parsed message
   0  : indicates more data must be received to parse the message
   -ESTRPIPE : current message should not be processed by the
  kernel, return control of the socket to userspace which
  can proceed to read the messages itself
   other < 0 : Error is parsing, give control back to userspace
  assuming that synchronzation is lost and the stream
  is unrecoverable (application expected to close TCP socket)

In the case of error return (< 0) strparse will stop the parser
and report and error to userspace. The application must deal
with the error. To handle the error the strparser is unbound
from the TCP socket. If the error indicates that the stream
TCP socket is at recoverable point (ESTRPIPE) then the application
can read the TCP socket to process the stream. Once the application
has dealt with the exceptions in the stream, it may again bind the
socket to a strparser to continue data operations.

Note that ENODATA may be returned to the application. In this case
parse_msg returned -ESTRPIPE, however strparser was unable to maintain
synchronization of the stream (i.e. some of the message in question
was already read by the parser).

strp_pause and strp_unpause are used to provide flow control. For
instance, if rcv_msg is called but the upper layer can't immediately
consume the message it can hold the message and pause strparser.

Signed-off-by: Tom Herbert 
---
 include/net/strparser.h   | 147 ++
 net/Kconfig   |   1 +
 net/Makefile  |   1 +
 net/strparser/Kconfig |   4 +
 net/strparser/Makefile|   1 +
 net/strparser/strparser.c | 500 ++
 6 files changed, 654 insertions(+)
 create mode 100644 include/net/strparser.h
 create mode 100644 net/strparser/Kconfig
 create mode 100644 net/strparser/Makefile
 create mode 100644 net/strparser/strparser.c

diff --git a/include/net/strparser.h b/include/net/strparser.h
new file mode 100644
index 000..42b964d
--- /dev/null
+++ b/include/net/strparser.h
@@ -0,0 +1,147 @@
+/*
+ * Stream Parser
+ *
+ * Copyright (c) 2016 Tom Herbert 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ */
+
+#ifndef __NET_STRPARSER_H_
+#define __NET_STRPARSER_H_
+
+#include 
+#include 
+
+#define STRP_STATS_ADD(stat, count) ((stat) += (count))
+#define STRP_STATS_INCR(stat) ((stat)++)
+
+struct strp_stats {
+   unsigned long long rx_msgs;
+   unsigned long long rx_bytes;
+   unsigned int rx_mem_fail;
+   unsigned int rx_need_more_hdr;
+   unsigned int rx_msg_too_big;
+   unsigned int rx_msg_timeouts;
+   unsigned int rx_bad_hdr_len;
+};
+
+struct strp_aggr_stats {
+   unsigned long long rx_msgs;
+   unsigned long long rx_bytes;
+   unsigned int rx_mem_fail;
+   unsigned int rx_need_more_hdr;
+   unsigned int rx_msg_too_big;
+   unsigned int rx_msg_timeouts;
+   unsigned int rx_bad_hdr_len;
+   unsigned int rx_aborts;
+   unsigned int rx_interrupted;
+   unsigned int rx_unrecov_intr;
+};
+
+struct strparser;
+
+/* Callbacks are called with lock held for the attached socket */
+struct strp_callbacks {
+   int (*parse_msg)(struct strparser *strp, struct sk_buff *skb);
+   void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb);
+   int (*read_sock_done)(struct strparser *strp, int err);
+   void (*abort_parser)(struct strparser *strp, int err);
+};
+
+struct strp_rx_msg {
+   int

[PATCH net-next v2 2/3] kcm: Use stream parser

2016-08-01 Thread Tom Herbert
Adapt KCM to use the stream parser. This mostly involves removing
the RX handling and setting up the strparser using the interface.

Signed-off-by: Tom Herbert 
---
 include/net/kcm.h |  37 +---
 net/ipv6/ila/ila_common.c |   1 -
 net/kcm/Kconfig   |   1 +
 net/kcm/kcmproc.c |  44 +++--
 net/kcm/kcmsock.c | 464 --
 5 files changed, 115 insertions(+), 432 deletions(-)

diff --git a/include/net/kcm.h b/include/net/kcm.h
index 2840b58..2a89658 100644
--- a/include/net/kcm.h
+++ b/include/net/kcm.h
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 extern unsigned int kcm_net_id;
@@ -21,16 +22,8 @@ extern unsigned int kcm_net_id;
 #define KCM_STATS_INCR(stat) ((stat)++)
 
 struct kcm_psock_stats {
-   unsigned long long rx_msgs;
-   unsigned long long rx_bytes;
unsigned long long tx_msgs;
unsigned long long tx_bytes;
-   unsigned int rx_aborts;
-   unsigned int rx_mem_fail;
-   unsigned int rx_need_more_hdr;
-   unsigned int rx_msg_too_big;
-   unsigned int rx_msg_timeouts;
-   unsigned int rx_bad_hdr_len;
unsigned long long reserved;
unsigned long long unreserved;
unsigned int tx_aborts;
@@ -64,13 +57,6 @@ struct kcm_tx_msg {
struct sk_buff *last_skb;
 };
 
-struct kcm_rx_msg {
-   int full_len;
-   int accum_len;
-   int offset;
-   int early_eaten;
-};
-
 /* Socket structure for KCM client sockets */
 struct kcm_sock {
struct sock sk;
@@ -87,6 +73,7 @@ struct kcm_sock {
struct work_struct tx_work;
struct list_head wait_psock_list;
struct sk_buff *seq_skb;
+   u32 tx_stopped : 1;
 
/* Don't use bit fields here, these are set under different locks */
bool tx_wait;
@@ -104,11 +91,11 @@ struct bpf_prog;
 /* Structure for an attached lower socket */
 struct kcm_psock {
struct sock *sk;
+   struct strparser strp;
struct kcm_mux *mux;
int index;
 
u32 tx_stopped : 1;
-   u32 rx_stopped : 1;
u32 done : 1;
u32 unattaching : 1;
 
@@ -121,18 +108,12 @@ struct kcm_psock {
struct kcm_psock_stats stats;
 
/* Receive */
-   struct sk_buff *rx_skb_head;
-   struct sk_buff **rx_skb_nextp;
-   struct sk_buff *ready_rx_msg;
struct list_head psock_ready_list;
-   struct work_struct rx_work;
-   struct delayed_work rx_delayed_work;
struct bpf_prog *bpf_prog;
struct kcm_sock *rx_kcm;
unsigned long long saved_rx_bytes;
unsigned long long saved_rx_msgs;
-   struct timer_list rx_msg_timer;
-   unsigned int rx_need_bytes;
+   struct sk_buff *ready_rx_msg;
 
/* Transmit */
struct kcm_sock *tx_kcm;
@@ -146,6 +127,7 @@ struct kcm_net {
struct mutex mutex;
struct kcm_psock_stats aggregate_psock_stats;
struct kcm_mux_stats aggregate_mux_stats;
+   struct strp_aggr_stats aggregate_strp_stats;
struct list_head mux_list;
int count;
 };
@@ -163,6 +145,7 @@ struct kcm_mux {
 
struct kcm_mux_stats stats;
struct kcm_psock_stats aggregate_psock_stats;
+   struct strp_aggr_stats aggregate_strp_stats;
 
/* Receive */
spinlock_t rx_lock cacheline_aligned_in_smp;
@@ -190,14 +173,6 @@ static inline void aggregate_psock_stats(struct 
kcm_psock_stats *stats,
/* Save psock statistics in the mux when psock is being unattached. */
 
 #define SAVE_PSOCK_STATS(_stat) (agg_stats->_stat += stats->_stat)
-   SAVE_PSOCK_STATS(rx_msgs);
-   SAVE_PSOCK_STATS(rx_bytes);
-   SAVE_PSOCK_STATS(rx_aborts);
-   SAVE_PSOCK_STATS(rx_mem_fail);
-   SAVE_PSOCK_STATS(rx_need_more_hdr);
-   SAVE_PSOCK_STATS(rx_msg_too_big);
-   SAVE_PSOCK_STATS(rx_msg_timeouts);
-   SAVE_PSOCK_STATS(rx_bad_hdr_len);
SAVE_PSOCK_STATS(tx_msgs);
SAVE_PSOCK_STATS(tx_bytes);
SAVE_PSOCK_STATS(reserved);
diff --git a/net/ipv6/ila/ila_common.c b/net/ipv6/ila/ila_common.c
index ec9efbc..aba0998 100644
--- a/net/ipv6/ila/ila_common.c
+++ b/net/ipv6/ila/ila_common.c
@@ -172,6 +172,5 @@ static void __exit ila_fini(void)
 
 module_init(ila_init);
 module_exit(ila_fini);
-MODULE_ALIAS_RTNL_LWT(ILA);
 MODULE_AUTHOR("Tom Herbert ");
 MODULE_LICENSE("GPL");
diff --git a/net/kcm/Kconfig b/net/kcm/Kconfig
index 5db94d9..87fca36 100644
--- a/net/kcm/Kconfig
+++ b/net/kcm/Kconfig
@@ -3,6 +3,7 @@ config AF_KCM
tristate "KCM sockets"
depends on INET
select BPF_SYSCALL
+   select STREAM_PARSER
---help---
  KCM (Kernel Connection Multiplexor) sockets provide a method
  for multiplexing messages of a message based application
diff --git a/net/kcm/kcmproc.c b/net/kcm/kcmproc.c
index 16c2e03..47e4453 100644
--- a/net/kcm/kcmproc.c
+++ b/net/kcm/kcmproc.c
@@ -155,8 +155,8 @@ static void kcm_format_psock(struct kcm_psock *psock, 
st

Re: [PATCH net-next 10/10] Documentation: dtb: xgene: Add rxlos GPIO mapping

2016-08-01 Thread Rob Herring
On Fri, Jul 29, 2016 at 05:34:03PM -0700, Iyappan Subramanian wrote:
> Signed-off-by: Quan Nguyen 
> Signed-off-by: Iyappan Subramanian 
> Tested-by: Fushen Chen 
> ---
>  Documentation/devicetree/bindings/net/apm-xgene-enet.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/apm-xgene-enet.txt 
> b/Documentation/devicetree/bindings/net/apm-xgene-enet.txt
> index 05f705e3..b83ae67 100644
> --- a/Documentation/devicetree/bindings/net/apm-xgene-enet.txt
> +++ b/Documentation/devicetree/bindings/net/apm-xgene-enet.txt
> @@ -24,6 +24,7 @@ Required properties for all the ethernet interfaces:
>  - clocks: Reference to the clock entry.
>  - local-mac-address: MAC address assigned to this device
>  - phy-connection-type: Interface type between ethernet device and PHY device
> +- rxlos-gpios: rxlos GPIO mapping

Needs a vendor prefix and some definition of what rxlos is. Direction 
and active state is needed as well.

Rob


[PATCH 0/1] virtio-vsock: Fix unbound rx buffer

2016-08-01 Thread ggarcia
From: Gerard Garcia 

This patch applies over VSOCK RFC v6.

Reset connection and close rx socket when the sender is ignoring our
announced available buffer. This avoids a DoS.

Gerard Garcia (1):
  Fix unbound rx buffer

 net/vmw_vsock/virtio_transport_common.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

-- 
2.9.1



[PATCH 1/1] virtio-vsock: Fix unbound rx buffer

2016-08-01 Thread ggarcia
From: Gerard Garcia 

Reset connection and close rx socket when the sender is ignoring our announced 
available buffer.

Signed-off-by: Gerard Garcia 
---
 net/vmw_vsock/virtio_transport_common.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/net/vmw_vsock/virtio_transport_common.c 
b/net/vmw_vsock/virtio_transport_common.c
index a53b3a1..3c38d43 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -773,13 +773,23 @@ virtio_transport_recv_connected(struct sock *sk,
pkt->len = le32_to_cpu(pkt->hdr.len);
pkt->off = 0;
 
-   spin_lock_bh(&vvs->rx_lock);
-   virtio_transport_inc_rx_pkt(vvs, pkt);
-   list_add_tail(&pkt->list, &vvs->rx_queue);
-   spin_unlock_bh(&vvs->rx_lock);
+   if (vvs->rx_bytes + pkt->len <= vvs->buf_size) {
+   spin_lock_bh(&vvs->rx_lock);
+   virtio_transport_inc_rx_pkt(vvs, pkt);
+   list_add_tail(&pkt->list, &vvs->rx_queue);
+   spin_unlock_bh(&vvs->rx_lock);
+
+   sk->sk_data_ready(sk);
+   return err;
+   } else {
+   /* Sender is ignoring our buf_alloc */
+   spin_unlock_bh(&vvs->rx_lock);
+
+   virtio_transport_reset(vsk, pkt);
+   virtio_transport_do_close(vsk, true);
+   break;
+   }
 
-   sk->sk_data_ready(sk);
-   return err;
case VIRTIO_VSOCK_OP_CREDIT_UPDATE:
sk->sk_write_space(sk);
break;
-- 
2.9.1



Re: [v4] Fix to avoid IS_ERR_VALUE and IS_ERR abuses on 64bit systems.

2016-08-01 Thread Scott Wood
On 08/01/2016 02:02 AM, Arnd Bergmann wrote:
> On Sunday, July 31, 2016 4:48:44 PM CEST Arvind Yadav wrote:
>> IS_ERR_VALUE() assumes that parameter is an unsigned long.
>> It can not be used to check if 'unsigned int' is passed insted.
>> Which tends to reflect an error.
>>
>> In 64bit architectures sizeof (int) == 4 && sizeof (long) == 8.
>> IS_ERR_VALUE(x) is ((x) >= (unsigned long)-4095).
>>
>> IS_ERR_VALUE() of 'unsigned int' is always false because the 32bit
>> value is zero extended to 64 bits.
>>
>> Value of (unsigned int)-4095 is always less than value of
>> (unsigned long)-4095.
>>
>> Now We are taking only first 32 bit for error checking rest of the 32 bit
>> we ignore such that we get appropriate comparison on 64bit system as well.
> 
> This is completely wrong: if you have a valid 64-bit pointer like
> 0x1234ff00, this will be interpreted as an error now.
> 
>> First 32bit of Value of (unsigned int)-4095 and (unsigned long)-4095 will
>> be equal.
>>
>> Signed-off-by: Arvind Yadav 
>> ---
>>  include/linux/err.h | 12 +++-
>>  1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/err.h b/include/linux/err.h
>> index 1e35588..c2a2789 100644
>> --- a/include/linux/err.h
>> +++ b/include/linux/err.h
>> @@ -18,7 +18,17 @@
>>  
>>  #ifndef __ASSEMBLY__
>>  
>> -#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned 
>> long)-MAX_ERRNO)
>> +#define IS_ERR_VALUE(x) unlikely(is_error_check(x))
>> +
>> +static inline int is_error_check(unsigned long error)
> 
> Please leave the existing macro alone. I think you were looking for
> something specific to the return code of qe_muram_alloc() function,
> so please add a helper in that subsystem if you need it, not in
> the generic header files.

qe_muram_alloc (a.k.a. cpm_muram_alloc) returns unsigned long.  The
problem is certain callers that store the return value in a u32.  Why
not just fix those callers to store it in unsigned long (at least until
error checking is done)?

-Scott



[vhost:vhost 14/14] drivers/vhost/vhost.c:915:30: warning: passing argument 2 of 'access_ok' makes pointer from integer without a cast

2016-08-01 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
head:   51ce50c54895044f949129e595ed9a37e4d6c13a
commit: 51ce50c54895044f949129e595ed9a37e4d6c13a [14/14] vhost: new device 
IOTLB API
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 51ce50c54895044f949129e595ed9a37e4d6c13a
# save the attached .config to linux build tree
make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

   drivers/vhost/vhost.c: In function 'umem_access_ok':
>> drivers/vhost/vhost.c:915:30: warning: passing argument 2 of 'access_ok' 
>> makes pointer from integer without a cast [-Wint-conversion]
 !access_ok(VERIFY_READ, uaddr, size))
 ^
   In file included from arch/sparc/include/asm/uaccess.h:4:0,
from include/linux/poll.h:11,
from drivers/vhost/vhost.c:21:
   arch/sparc/include/asm/uaccess_64.h:79:19: note: expected 'const void *' but 
argument is of type 'u64 {aka long long unsigned int}'
static inline int access_ok(int type, const void __user * addr, unsigned 
long size)
  ^
   drivers/vhost/vhost.c:918:31: warning: passing argument 2 of 'access_ok' 
makes pointer from integer without a cast [-Wint-conversion]
 !access_ok(VERIFY_WRITE, uaddr, size))
  ^
   In file included from arch/sparc/include/asm/uaccess.h:4:0,
from include/linux/poll.h:11,
from drivers/vhost/vhost.c:21:
   arch/sparc/include/asm/uaccess_64.h:79:19: note: expected 'const void *' but 
argument is of type 'u64 {aka long long unsigned int}'
static inline int access_ok(int type, const void __user * addr, unsigned 
long size)
  ^

vim +/access_ok +915 drivers/vhost/vhost.c

   899  struct vhost_iotlb_msg *vq_msg = &node->msg.iotlb;
   900  if (msg->iova <= vq_msg->iova &&
   901  msg->iova + msg->size - 1 > vq_msg->iova &&
   902  vq_msg->type == VHOST_IOTLB_MISS) {
   903  vhost_poll_queue(&node->vq->poll);
   904  list_del(&node->node);
   905  kfree(node);
   906  }
   907  }
   908  
   909  spin_unlock(&d->iotlb_lock);
   910  }
   911  
   912  static int umem_access_ok(u64 uaddr, u64 size, int access)
   913  {
   914  if ((access & VHOST_ACCESS_RO) &&
 > 915  !access_ok(VERIFY_READ, uaddr, size))
   916  return -EFAULT;
   917  if ((access & VHOST_ACCESS_WO) &&
   918  !access_ok(VERIFY_WRITE, uaddr, size))
   919  return -EFAULT;
   920  return 0;
   921  }
   922  
   923  int vhost_process_iotlb_msg(struct vhost_dev *dev,

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH net-next v2 0/3] strp: Stream parser for messages

2016-08-01 Thread David Miller
From: Tom Herbert 
Date: Mon, 1 Aug 2016 09:33:17 -0700

>   - Remove GPL module license from strparser.c

Why?


Re: [PATCH 1/1] net: enic: use correct type specifier

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 11:10:08 +0200

> i is defined as unsigned.
> So print it with %u.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: bna: use correct type specifier (2)

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 11:01:20 +0200

> add and val are read with
> sscanf(kern_buf, "%x:%x", &addr, &val);
> and used as arguments for bna_reg_offset_check and writel
> so they have to be unsigned.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: qlcnic: avoid superfluous assignement

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 12:07:37 +0200

> Assigning NULL to parmeter dcb has no effect outside of the
> inlined function.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: qlge: remove superfluous statement

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 12:19:28 +0200

> Variable length is not used after the deleted line.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] wan/fsl_ucc_hdlc: avoid possible NULL pointer dereference

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 13:14:23 +0200

> All assignments to components of priv should only
> occur after the check if prif is NULL.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: s2io: simplify logical constraint

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 11:53:57 +0200

> (!A || (A && B)) is equivalent to (!A || B)
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: bna: use correct type specifications

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 10:53:14 +0200

> addr and len are read with
> sscanf(kern_buf, "%x:%x", &addr, &len);
> and used as arguments for
> bna_reg_offset_check.
> 
> So they have to be unsigned.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH net-next v2 0/3] strp: Stream parser for messages

2016-08-01 Thread Tom Herbert
On Mon, Aug 1, 2016 at 1:27 PM, David Miller  wrote:
> From: Tom Herbert 
> Date: Mon, 1 Aug 2016 09:33:17 -0700
>
>>   - Remove GPL module license from strparser.c
>
> Why?

It looked more consistent with other modules. Is GPL module license
preferred then?

Tom


Re: [PATCH 1/1] qed: do not use unitialized variable

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 13:24:52 +0200

> Do not write random bytes from the kernel stack when
> calling qed_wr.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: caif: use correct format specifier

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 09:19:50 +0200

> %u is the wrong format specifier for int.
> size_t cannot be converted to int without possible
> loss of information.
> 
> So leave the result as size_t and use %zu as format specifier.
> 
> cf. Documentation/printk-formats.txt
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: amd-xgbe: use correct format specifier

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 10:07:18 +0200

> i has been defined as unsigned int.
> So use %u for output.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1 v2] dsa: b53: remove redundant if

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 13:42:33 +0200

> For pdata == null the code leaves with an error.
> There is no need to check the condition again.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: ethernet: ax88796: avoid null pointer dereference

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 09:58:44 +0200

> If platform_get_resource fails, mem2 is null.
> Do not dereference null.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH 1/1] net: bcm63xx: avoid possible null pointer dereference

2016-08-01 Thread David Miller
From: Heinrich Schuchardt 
Date: Sun, 31 Jul 2016 10:24:29 +0200

> If dev_get_platdata has failed pd is null.
> Do not dereference a null pointer.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied.


Re: [PATCH net] sctp: change to use TCP_CLOSE_WAIT as SCTP_SS_CLOSING

2016-08-01 Thread David Miller
From: Xin Long 
Date: Sat, 30 Jul 2016 20:00:45 +0800

> Prior to this patch, sctp defined TCP_CLOSING as SCTP_SS_CLOSING.
> TCP_CLOSING is such a special sk state in TCP that inet common codes
> even exclude it.
> 
> For instance, inet_accept thinks the accept sk's state never be
> TCP_CLOSING, or it will give a WARN_ON. TCP works well with that
> while SCTP may trigger the call trace, as CLOSING state in SCTP
> has different meaning from TCP.
> 
> This fix is to change to use TCP_CLOSE_WAIT as SCTP_SS_CLOSING,
> instead of TCP_CLOSING. Some side-effects could be expected,
> regardless of not being used before. inet_accept will accept it
> now.
> 
> I did all the func_tests in lksctp-tools and ran sctp codnomicon
> fuzzer tests against this patch, no regression or failure found.
> 
> Signed-off-by: Xin Long 

Applied.


Re: [PATCH net-next v2 0/3] strp: Stream parser for messages

2016-08-01 Thread David Miller
From: Tom Herbert 
Date: Mon, 1 Aug 2016 13:38:46 -0700

> On Mon, Aug 1, 2016 at 1:27 PM, David Miller  wrote:
>> From: Tom Herbert 
>> Date: Mon, 1 Aug 2016 09:33:17 -0700
>>
>>>   - Remove GPL module license from strparser.c
>>
>> Why?
> 
> It looked more consistent with other modules. Is GPL module license
> preferred then?

Yes.

Since this is a facility which is largely unique to the Linux kernel,
things linking to these symbols are almost certainly derived works.


[vhost:vhost 11/15] warning: (VOP && ..) selects VHOST_RING which has unmet direct dependencies (NETDEVICES && ..)

2016-08-01 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
head:   c4ea43c2c1779f5dde3ff5645b830c90f75ccc15
commit: efd7eb77f631e1ed3533db7725df157a379c78ef [11/15] VSOCK: Add Makefile 
and Kconfig
config: x86_64-randconfig-x005-201631 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
git checkout efd7eb77f631e1ed3533db7725df157a379c78ef
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

warning: (VOP && CAIF_VIRTIO && VHOST_NET && VHOST_SCSI && VHOST_VSOCK && 
VHOST_NET && VHOST_SCSI && VHOST_VSOCK) selects VHOST_RING which has unmet 
direct dependencies (NETDEVICES && CAIF_VIRTIO || VIRTUALIZATION)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: 4.6.3, pppoe + shaper workload, skb_panic / skb_push / ppp_start_xmit

2016-08-01 Thread Guillaume Nault
On Thu, Jul 28, 2016 at 02:28:23PM +0300, Denys Fedoryshchenko wrote:
>  [ 5449.904989] CPU: 1 PID: 6359 Comm: ip Not tainted
> 4.7.0-build-0109 #2
>  [ 5449.905255] Hardware name: Supermicro
> X10SLM+-LN4F/X10SLM+-LN4F, BIOS 3.0 04/24/2015
>  [ 5449.905712] task: 8803eef4 ti: 8803fd754000
> task.ti: 8803fd754000
>  [ 5449.906168] RIP: 0010:[]
>  [] inet_fill_ifaddr+0x5a/0x264
>  [ 5449.906710] RSP: 0018:8803fd757b98  EFLAGS: 00010286
>  [ 5449.906976] RAX: 8803ef65cb90 RBX: 8803f7d2cd00 RCX:
> 
>  [ 5449.907248] RDX: 00080002 RSI: 8803ef65cb90 RDI:
> 8803ef65cba8
>  [ 5449.907519] RBP: 8803fd757be0 R08: 0008 R09:
> 0002
>  [ 5449.907792] R10: ffa005040269f480 R11: 820a1c00 R12:
> ffa005040269f480
>  [ 5449.908067] R13: 8803ef65cb90 R14:  R15:
> 8803f7d2cd00
>  [ 5449.908339] FS:  7f660674d700()
> GS:88041fc4() knlGS:
>  [ 5449.908796] CS:  0010 DS:  ES:  CR0: 80050033
>  [ 5449.909067] CR2: 008b9018 CR3: 0003f2a11000 CR4:
> 001406e0
>  [ 5449.909339] Stack:
>  [ 5449.909598]  0163a8c0869711ac
>  0080
>  
>  0003e1d50003e1d5
> 
>  [ 5449.910329]  8800d54c0ac8
>  8803f0d9
>  0005
>  
> 
>  [ 5449.911066]  8803f7d2cd00
>  8803fd757c40
>  818a9f73
>  820a1c00
> 
>  [ 5449.911803] Call Trace:
>  [ 5449.912061]  [] inet_dump_ifaddr+0xfb/0x185
>  [ 5449.912332]  [] rtnl_dump_all+0xa9/0xc2
>  [ 5449.912601]  [] netlink_dump+0xf0/0x25c
>  [ 5449.912873]  [] netlink_recvmsg+0x1a9/0x2d3
>  [ 5449.913142]  [] sock_recvmsg+0x14/0x16
>  [ 5449.913407]  [] ___sys_recvmsg+0xea/0x1a1
>  [ 5449.913675]  [] ?
> alloc_pages_vma+0x167/0x1a0
>  [ 5449.913945]  [] ?
> page_add_new_anon_rmap+0xb4/0xbd
>  [ 5449.914212]  [] ?
> lru_cache_add_active_or_unevictable+0x31/0x9d
>  [ 5449.914664]  [] ?
> handle_mm_fault+0x632/0x112d
>  [ 5449.914940]  [] ? vma_merge+0x27e/0x2b1
>  [ 5449.915208]  [] __sys_recvmsg+0x3d/0x5e
>  [ 5449.915478]  [] ? __sys_recvmsg+0x3d/0x5e
>  [ 5449.915747]  [] SyS_recvmsg+0xd/0x17
>  [ 5449.916017]  []
> entry_SYSCALL_64_fastpath+0x17/0x93
> 
Do you still have the vmlinux file with debug symbols that generated
this panic?


Re: [PATCH v5 09/11] dtb: xgene: Add MDIO node

2016-08-01 Thread Olof Johansson
Hi,

I came across this now when looking at merge conflicts when preparing
this. I wish I had seen it sooner.

On Thu, Jul 7, 2016 at 4:02 PM, Iyappan Subramanian
 wrote:
> Added mdio node for mdio driver.  Also added phy-handle
> reference to the ethernet nodes.
>
> Removed unused mdio subnode within storm menet ethernet node.
> Removed unused clock node from storm sgenet1.
>
> Signed-off-by: Iyappan Subramanian 
> Tested-by: Fushen Chen 
> Tested-by: Toan Le 
> Tested-by: Matthias Brugger 
> ---
>  arch/arm64/boot/dts/apm/apm-mustang.dts | 12 +++
>  arch/arm64/boot/dts/apm/apm-storm.dtsi  | 36 
> -
>  2 files changed, 25 insertions(+), 23 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/apm/apm-mustang.dts 
> b/arch/arm64/boot/dts/apm/apm-mustang.dts
> index 44db32e..b7fb5d9 100644
> --- a/arch/arm64/boot/dts/apm/apm-mustang.dts
> +++ b/arch/arm64/boot/dts/apm/apm-mustang.dts
> @@ -79,3 +79,15 @@
>  &mmc0 {
> status = "ok";
>  };
> +
> +&mdio {
> +   menet0phy: phy@3 {
> +   reg = <0x3>;
> +   };
> +   sgenet0phy: phy@4 {
> +   reg = <0x4>;
> +   };
> +   sgenet1phy: phy@5 {
> +   reg = <0x5>;
> +   };
> +};
> diff --git a/arch/arm64/boot/dts/apm/apm-storm.dtsi 
> b/arch/arm64/boot/dts/apm/apm-storm.dtsi
> index 5147d76..a415b3a 100644
> --- a/arch/arm64/boot/dts/apm/apm-storm.dtsi
> +++ b/arch/arm64/boot/dts/apm/apm-storm.dtsi
> @@ -237,20 +237,11 @@
> clocks = <&socplldiv2 0>;
> reg = <0x0 0x1f21c000 0x0 0x1000>;
> reg-names = "csr-reg";
> -   csr-mask = <0x3>;
> +   csr-mask = <0xa>;
> +   enable-mask = <0xf>;
> clock-output-names = "sge0clk";
> };
>
> -   sge1clk: sge1clk@1f21c000 {
> -   compatible = "apm,xgene-device-clock";
> -   #clock-cells = <1>;
> -   clocks = <&socplldiv2 0>;
> -   reg = <0x0 0x1f21c000 0x0 0x1000>;
> -   reg-names = "csr-reg";
> -   csr-mask = <0xc>;
> -   clock-output-names = "sge1clk";
> -   };
> -
> xge0clk: xge0clk@1f61c000 {
> compatible = "apm,xgene-device-clock";
> #clock-cells = <1>;
> @@ -921,6 +912,14 @@
> clocks = <&rtcclk 0>;
> };
>
> +   mdio: mdio@0x1702 {
> +   compatible = "apm,xgene-mdio-rgmii";
> +   #address-cells = <1>;
> +   #size-cells = <0>;
> +   reg = <0x0 0x1702 0x0 0xd100>;
> +   clocks = <&menetclk 0>;
> +   };
> +
> menet: ethernet@1702 {


This new mmio node has the same unit address, and claims the same
register window as the ethernet controller.
That's doesn't seem correct?


-Olof


Re: 4.6.3, pppoe + shaper workload, skb_panic / skb_push / ppp_start_xmit

2016-08-01 Thread Guillaume Nault
On Thu, Jul 28, 2016 at 02:28:23PM +0300, Denys Fedoryshchenko wrote:
> On 2016-07-28 14:09, Guillaume Nault wrote:
> > On Tue, Jul 12, 2016 at 10:31:18AM -0700, Cong Wang wrote:
> > > On Mon, Jul 11, 2016 at 12:45 PM,   wrote:
> > > > Hi
> > > >
> > > > On latest kernel i noticed kernel panic happening 1-2 times per day. It 
> > > > is
> > > > also happening on older kernel (at least 4.5.3).
> > > >
> > > ...
> > > >  [42916.426463] Call Trace:
> > > >  [42916.426658]  
> > > >
> > > >  [42916.426719]  [] skb_push+0x36/0x37
> > > >  [42916.427111]  [] ppp_start_xmit+0x10f/0x150
> > > > [ppp_generic]
> > > >  [42916.427314]  [] dev_hard_start_xmit+0x25a/0x2d3
> > > >  [42916.427516]  [] ?
> > > > validate_xmit_skb.isra.107.part.108+0x11d/0x238
> > > >  [42916.427858]  [] sch_direct_xmit+0x89/0x1b5
> > > >  [42916.428060]  [] __qdisc_run+0x133/0x170
> > > >  [42916.428261]  [] net_tx_action+0xe3/0x148
> > > >  [42916.428462]  [] __do_softirq+0xb9/0x1a9
> > > >  [42916.428663]  [] irq_exit+0x37/0x7c
> > > >  [42916.428862]  [] smp_apic_timer_interrupt+0x3d/0x48
> > > >  [42916.429063]  [] apic_timer_interrupt+0x7c/0x90
> > > 
> > > Interesting, we call a skb_cow_head() before skb_push() in
> > > ppp_start_xmit(),
> > > I have no idea why this could happen.
> > > 
> > The skb is corrupted: head is at 8800b0bf2800 while data is at
> > ffa00500b0bf284c.
> > 
> > Figuring out how this corruption happened is going to be hard without a
> > way to reproduce the problem.
> > 
> > Denys, can you confirm you're using a vanilla kernel?
> > Also I guess the ppp devices and tc settings are handled by accel-ppp.
> > If so, can you share more info about your setup (accel-ppp.conf, radius
> > attributes, iptables...) so that I can try to reproduce it on my
> > machines?
> 
> I have slight modification from vanilla:
> 
> --- linux/net/sched/sch_htb.c 2016-06-08 01:23:53.0 +
> +++ linux-new/net/sched/sch_htb.c 2016-06-21 14:03:08.398486593 +
> @@ -1495,10 +1495,10 @@
>   cl->common.classid);
>   cl->quantum = 1000;
>   }
> - if (!hopt->quantum && cl->quantum > 20) {
> + if (!hopt->quantum && cl->quantum > 200) {
>   pr_warn("HTB: quantum of class %X is big. Consider r2q 
> change.\n",
>   cl->common.classid);
> - cl->quantum = 20;
> + cl->quantum = 200;
>   }
>   if (hopt->quantum)
>   cl->quantum = hopt->quantum;
> 
> But i guess it should not be reason of crash (it is related to another
> system,  without it i was unable to shape over 7Gbps, maybe with latest
> kernel i will not need this patch).
>
I guess such a big quantum is probably going to add some stress on HTB
because of longer dequeues. But that shouldn't make the kernel panic.
Anyway, I'm certainly not an HTB expert, so I can't comment further.
BTW, what about setting ->quantum directly and drop this patch if you
really need values this big?

> I'm trying to make reproducible conditions of crash, because right now it
> happens only on some servers in large networks (completely different ISPs,
> so i excluded possible hardware fault of specific server). It is complex
> config, i have accel-ppp, plus my own "shaping daemon" that apply several
> shapers on ppp interfaces. Wost thing it happens only on live customers, i
> am unable to reproduce same on stress tests. Also until recent kernel i
> was getting different panic messages (but all related to ppp).
> 
In the logs I commented earlier, the skb is probably corrupted before
the ppp_start_xmit() call. The PPP module hasn't done anything at this
stage, unless the packet was forwarded from another PPP interface.
In short, corruption could have happened anywhere. So we really need to
narrow down the scope or get a way to reproduce the problem.

> I think also at least one reason of crash also was fixed by "ppp: defer
> netns reference release for ppp channel" in 4.7.0 (maybe thats why i am
> getting less crashes recently).
> I tried also various kernel debug options that doesn't cause major
> performance degradation (locks checking, freed memory poisoning and etc),
> without any luck yet.
> Is it useful if i will post panics that at least
> occurs twice? (I will post below example, got recently)
Do you mean that you have many more different panics traces?


Re: [vhost:vhost 11/15] warning: (VOP && ..) selects VHOST_RING which has unmet direct dependencies (NETDEVICES && ..)

2016-08-01 Thread Michael S. Tsirkin
On Tue, Aug 02, 2016 at 04:56:54AM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
> head:   c4ea43c2c1779f5dde3ff5645b830c90f75ccc15
> commit: efd7eb77f631e1ed3533db7725df157a379c78ef [11/15] VSOCK: Add Makefile 
> and Kconfig
> config: x86_64-randconfig-x005-201631 (attached as .config)
> compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> git checkout efd7eb77f631e1ed3533db7725df157a379c78ef
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All warnings (new ones prefixed by >>):
> 
> warning: (VOP && CAIF_VIRTIO && VHOST_NET && VHOST_SCSI && VHOST_VSOCK && 
> VHOST_NET && VHOST_SCSI && VHOST_VSOCK) selects VHOST_RING which has unmet 
> direct dependencies (NETDEVICES && CAIF_VIRTIO || VIRTUALIZATION)

I don't see what is going on here.

VHOST_RING is in the same config file as VHOST_NET so it
has the same dependencies. How can one set VHOST_NET without
enabling dependencies for VHOST_RING?


> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation




[PATCH net-next v3 0/3] strp: Stream parser for messages

2016-08-01 Thread Tom Herbert
This patch set introduces a utility for parsing application layer
protocol messages in a TCP stream. This is a generalization of the
mechanism implemented of Kernel Connection Multiplexor.

This patch set adapts KCM to use the strparser. We expect that kTLS
can use this mechanism also. RDS would probably be another candidate
to use a common stream parsing mechanism.

The API includes a context structure, a set of callbacks, utility
functions, and a data ready function. The callbacks include
a parse_msg function that is called to perform parsing (e.g.
BPF parsing in case of KCM), and a rcv_msg function that is called
when a full message has been completed.

For strparser we specify the return codes from the parser to allow
the backend to indicate that control of the socket should be
transferred back to userspace to handle some exceptions in the
stream: The return values are:

  >0 : indicates length of successfully parsed message
   0  : indicates more data must be received to parse the message
   -ESTRPIPE : current message should not be processed by the
  kernel, return control of the socket to userspace which
  can proceed to read the messages itself
   other < 0 : Error is parsing, give control back to userspace
  assuming that synchronization is lost and the stream
  is unrecoverable (application expected to close TCP socket)

There is one issue I haven't been able to fully resolve. If parse_msg
returns ESTRPIPE (wants control back to userspace) the parser may
already have consumed some bytes of the message. There is no way to
put bytes back into the TCP receive queue and tcp_read_sock does not
allow an easy way to peek messages. In lieu of a better solution, we
return ENODATA on the socket to indicate that the data stream is
unrecoverable (application needs to close socket). This condition
should only happen if an application layer message header is split
across two skbuffs and parsing just the first skbuff wasn't sufficient
to determine the that transfer to userspace is needed.

This patch set contains:

  - strparser implementation
  - changes to kcm to use strparser
  - strparser.txt documentation

v2:
  - Add copyright notice to C files
  - Remove GPL module license from strparser.c
  - Add report of rxpause

v3:
  - Restore GPL module license
  - Use EXPORT_SYMBOL_GPL

Tested:
  - Ran a KCM thrash test for 24 hours. No behavioral or performance
differences observed.


Tom Herbert (3):
  strparser: Stream parser for messages
  kcm: Use stream parser
  strparser: Documentation

 Documentation/networking/strparser.txt | 147 ++
 include/net/kcm.h  |  37 +--
 include/net/strparser.h| 147 ++
 net/Kconfig|   1 +
 net/Makefile   |   1 +
 net/ipv6/ila/ila_common.c  |   1 -
 net/kcm/Kconfig|   1 +
 net/kcm/kcmproc.c  |  44 ++-
 net/kcm/kcmsock.c  | 464 +-
 net/strparser/Kconfig  |   4 +
 net/strparser/Makefile |   1 +
 net/strparser/strparser.c  | 500 +
 12 files changed, 916 insertions(+), 432 deletions(-)
 create mode 100644 Documentation/networking/strparser.txt
 create mode 100644 include/net/strparser.h
 create mode 100644 net/strparser/Kconfig
 create mode 100644 net/strparser/Makefile
 create mode 100644 net/strparser/strparser.c

-- 
2.8.0.rc2



[PATCH net-next v3 1/3] strparser: Stream parser for messages

2016-08-01 Thread Tom Herbert
This patch introduces a utility for parsing application layer protocol
messages in a TCP stream. This is a generalization of the mechanism
implemented of Kernel Connection Multiplexor.

The API includes a context structure, a set of callbacks, utility
functions, and a data ready function.

A stream parser instance is defined by a strparse structure that
is bound to a TCP socket. The function to initialize the structure
is:

int strp_init(struct strparser *strp, struct sock *csk,
  struct strp_callbacks *cb);

csk is the TCP socket being bound to and cb are the parser callbacks.

A parser is bound to a TCP socket by setting data_ready function to
strp_tcp_data_ready so that all receive indications on the socket
go through the parser. This is assumes that sk_user_data is set to
the strparser structure.

There are four callbacks.
 - parse_msg is called to parse the message (returns length or error).
 - rcv_msg is called when a complete message has been received
 - read_sock_done is called when data_ready function exits
 - abort_parser is called to abort the parser

The input to parse_msg is an skbuff which contains next message under
construction. The backend processing of parse_msg will parse the
application layer protocol headers to determine the length of
the message in the stream. The possible return values are:

   >0 : indicates length of successfully parsed message
   0  : indicates more data must be received to parse the message
   -ESTRPIPE : current message should not be processed by the
  kernel, return control of the socket to userspace which
  can proceed to read the messages itself
   other < 0 : Error is parsing, give control back to userspace
  assuming that synchronzation is lost and the stream
  is unrecoverable (application expected to close TCP socket)

In the case of error return (< 0) strparse will stop the parser
and report and error to userspace. The application must deal
with the error. To handle the error the strparser is unbound
from the TCP socket. If the error indicates that the stream
TCP socket is at recoverable point (ESTRPIPE) then the application
can read the TCP socket to process the stream. Once the application
has dealt with the exceptions in the stream, it may again bind the
socket to a strparser to continue data operations.

Note that ENODATA may be returned to the application. In this case
parse_msg returned -ESTRPIPE, however strparser was unable to maintain
synchronization of the stream (i.e. some of the message in question
was already read by the parser).

strp_pause and strp_unpause are used to provide flow control. For
instance, if rcv_msg is called but the upper layer can't immediately
consume the message it can hold the message and pause strparser.

Signed-off-by: Tom Herbert 
---
 include/net/strparser.h   | 147 ++
 net/Kconfig   |   1 +
 net/Makefile  |   1 +
 net/strparser/Kconfig |   4 +
 net/strparser/Makefile|   1 +
 net/strparser/strparser.c | 500 ++
 6 files changed, 654 insertions(+)
 create mode 100644 include/net/strparser.h
 create mode 100644 net/strparser/Kconfig
 create mode 100644 net/strparser/Makefile
 create mode 100644 net/strparser/strparser.c

diff --git a/include/net/strparser.h b/include/net/strparser.h
new file mode 100644
index 000..42b964d
--- /dev/null
+++ b/include/net/strparser.h
@@ -0,0 +1,147 @@
+/*
+ * Stream Parser
+ *
+ * Copyright (c) 2016 Tom Herbert 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ */
+
+#ifndef __NET_STRPARSER_H_
+#define __NET_STRPARSER_H_
+
+#include 
+#include 
+
+#define STRP_STATS_ADD(stat, count) ((stat) += (count))
+#define STRP_STATS_INCR(stat) ((stat)++)
+
+struct strp_stats {
+   unsigned long long rx_msgs;
+   unsigned long long rx_bytes;
+   unsigned int rx_mem_fail;
+   unsigned int rx_need_more_hdr;
+   unsigned int rx_msg_too_big;
+   unsigned int rx_msg_timeouts;
+   unsigned int rx_bad_hdr_len;
+};
+
+struct strp_aggr_stats {
+   unsigned long long rx_msgs;
+   unsigned long long rx_bytes;
+   unsigned int rx_mem_fail;
+   unsigned int rx_need_more_hdr;
+   unsigned int rx_msg_too_big;
+   unsigned int rx_msg_timeouts;
+   unsigned int rx_bad_hdr_len;
+   unsigned int rx_aborts;
+   unsigned int rx_interrupted;
+   unsigned int rx_unrecov_intr;
+};
+
+struct strparser;
+
+/* Callbacks are called with lock held for the attached socket */
+struct strp_callbacks {
+   int (*parse_msg)(struct strparser *strp, struct sk_buff *skb);
+   void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb);
+   int (*read_sock_done)(struct strparser *strp, int err);
+   void (*abort_parser)(struct strparser *strp, int err);
+};
+
+struct strp_rx_msg {
+   int

[PATCH net-next v3 2/3] kcm: Use stream parser

2016-08-01 Thread Tom Herbert
Adapt KCM to use the stream parser. This mostly involves removing
the RX handling and setting up the strparser using the interface.

Signed-off-by: Tom Herbert 
---
 include/net/kcm.h |  37 +---
 net/ipv6/ila/ila_common.c |   1 -
 net/kcm/Kconfig   |   1 +
 net/kcm/kcmproc.c |  44 +++--
 net/kcm/kcmsock.c | 464 --
 5 files changed, 115 insertions(+), 432 deletions(-)

diff --git a/include/net/kcm.h b/include/net/kcm.h
index 2840b58..2a89658 100644
--- a/include/net/kcm.h
+++ b/include/net/kcm.h
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 extern unsigned int kcm_net_id;
@@ -21,16 +22,8 @@ extern unsigned int kcm_net_id;
 #define KCM_STATS_INCR(stat) ((stat)++)
 
 struct kcm_psock_stats {
-   unsigned long long rx_msgs;
-   unsigned long long rx_bytes;
unsigned long long tx_msgs;
unsigned long long tx_bytes;
-   unsigned int rx_aborts;
-   unsigned int rx_mem_fail;
-   unsigned int rx_need_more_hdr;
-   unsigned int rx_msg_too_big;
-   unsigned int rx_msg_timeouts;
-   unsigned int rx_bad_hdr_len;
unsigned long long reserved;
unsigned long long unreserved;
unsigned int tx_aborts;
@@ -64,13 +57,6 @@ struct kcm_tx_msg {
struct sk_buff *last_skb;
 };
 
-struct kcm_rx_msg {
-   int full_len;
-   int accum_len;
-   int offset;
-   int early_eaten;
-};
-
 /* Socket structure for KCM client sockets */
 struct kcm_sock {
struct sock sk;
@@ -87,6 +73,7 @@ struct kcm_sock {
struct work_struct tx_work;
struct list_head wait_psock_list;
struct sk_buff *seq_skb;
+   u32 tx_stopped : 1;
 
/* Don't use bit fields here, these are set under different locks */
bool tx_wait;
@@ -104,11 +91,11 @@ struct bpf_prog;
 /* Structure for an attached lower socket */
 struct kcm_psock {
struct sock *sk;
+   struct strparser strp;
struct kcm_mux *mux;
int index;
 
u32 tx_stopped : 1;
-   u32 rx_stopped : 1;
u32 done : 1;
u32 unattaching : 1;
 
@@ -121,18 +108,12 @@ struct kcm_psock {
struct kcm_psock_stats stats;
 
/* Receive */
-   struct sk_buff *rx_skb_head;
-   struct sk_buff **rx_skb_nextp;
-   struct sk_buff *ready_rx_msg;
struct list_head psock_ready_list;
-   struct work_struct rx_work;
-   struct delayed_work rx_delayed_work;
struct bpf_prog *bpf_prog;
struct kcm_sock *rx_kcm;
unsigned long long saved_rx_bytes;
unsigned long long saved_rx_msgs;
-   struct timer_list rx_msg_timer;
-   unsigned int rx_need_bytes;
+   struct sk_buff *ready_rx_msg;
 
/* Transmit */
struct kcm_sock *tx_kcm;
@@ -146,6 +127,7 @@ struct kcm_net {
struct mutex mutex;
struct kcm_psock_stats aggregate_psock_stats;
struct kcm_mux_stats aggregate_mux_stats;
+   struct strp_aggr_stats aggregate_strp_stats;
struct list_head mux_list;
int count;
 };
@@ -163,6 +145,7 @@ struct kcm_mux {
 
struct kcm_mux_stats stats;
struct kcm_psock_stats aggregate_psock_stats;
+   struct strp_aggr_stats aggregate_strp_stats;
 
/* Receive */
spinlock_t rx_lock cacheline_aligned_in_smp;
@@ -190,14 +173,6 @@ static inline void aggregate_psock_stats(struct 
kcm_psock_stats *stats,
/* Save psock statistics in the mux when psock is being unattached. */
 
 #define SAVE_PSOCK_STATS(_stat) (agg_stats->_stat += stats->_stat)
-   SAVE_PSOCK_STATS(rx_msgs);
-   SAVE_PSOCK_STATS(rx_bytes);
-   SAVE_PSOCK_STATS(rx_aborts);
-   SAVE_PSOCK_STATS(rx_mem_fail);
-   SAVE_PSOCK_STATS(rx_need_more_hdr);
-   SAVE_PSOCK_STATS(rx_msg_too_big);
-   SAVE_PSOCK_STATS(rx_msg_timeouts);
-   SAVE_PSOCK_STATS(rx_bad_hdr_len);
SAVE_PSOCK_STATS(tx_msgs);
SAVE_PSOCK_STATS(tx_bytes);
SAVE_PSOCK_STATS(reserved);
diff --git a/net/ipv6/ila/ila_common.c b/net/ipv6/ila/ila_common.c
index ec9efbc..aba0998 100644
--- a/net/ipv6/ila/ila_common.c
+++ b/net/ipv6/ila/ila_common.c
@@ -172,6 +172,5 @@ static void __exit ila_fini(void)
 
 module_init(ila_init);
 module_exit(ila_fini);
-MODULE_ALIAS_RTNL_LWT(ILA);
 MODULE_AUTHOR("Tom Herbert ");
 MODULE_LICENSE("GPL");
diff --git a/net/kcm/Kconfig b/net/kcm/Kconfig
index 5db94d9..87fca36 100644
--- a/net/kcm/Kconfig
+++ b/net/kcm/Kconfig
@@ -3,6 +3,7 @@ config AF_KCM
tristate "KCM sockets"
depends on INET
select BPF_SYSCALL
+   select STREAM_PARSER
---help---
  KCM (Kernel Connection Multiplexor) sockets provide a method
  for multiplexing messages of a message based application
diff --git a/net/kcm/kcmproc.c b/net/kcm/kcmproc.c
index 16c2e03..47e4453 100644
--- a/net/kcm/kcmproc.c
+++ b/net/kcm/kcmproc.c
@@ -155,8 +155,8 @@ static void kcm_format_psock(struct kcm_psock *psock, 
st

[PATCH net-next v3 3/3] strparser: Documentation

2016-08-01 Thread Tom Herbert
Signed-off-by: Tom Herbert 
---
 Documentation/networking/strparser.txt | 147 +
 1 file changed, 147 insertions(+)
 create mode 100644 Documentation/networking/strparser.txt

diff --git a/Documentation/networking/strparser.txt 
b/Documentation/networking/strparser.txt
new file mode 100644
index 000..abfef72
--- /dev/null
+++ b/Documentation/networking/strparser.txt
@@ -0,0 +1,147 @@
+Stream Parser
+-
+
+The stream parser (strparser) is a utility that parses messages of an
+application layer protocol running over a TCP connection. The stream
+parser works in conjunction with an upper layer in the kernel to provide
+kernel support for application layer messages. For instance, Kernel
+Connection Multiplexor (KCM) uses the Stream Parser to parse messages
+using a BPF program.
+
+Interface
+-
+
+The API includes a context structure, a set of callbacks, utility
+functions, and a data_ready function. The callbacks include
+a parse_msg function that is called to perform parsing (e.g.
+BPF parsing in case of KCM), and a rcv_msg function that is called
+when a full message has been completed.
+
+A stream parser can be instantiated for a TCP connection. This is done
+by:
+
+strp_init(struct strparser *strp, struct sock *csk,
+ struct strp_callbacks *cb)
+
+strp is a struct of type strparser that is allocated by the upper layer.
+csk is the TCP socket associated with the stream parser. Callbacks are
+called by the stream parser.
+
+Callbacks
+-
+
+There are four callbacks:
+
+int (*parse_msg)(struct strparser *strp, struct sk_buff *skb);
+
+parse_msg is called to determine the length of the next message
+in the stream. The upper layer must implement this function. It
+should parse the sk_buff as containing the headers for the
+next application layer messages in the stream.
+
+The skb->cb in the input skb is a struct strp_rx_msg. Only
+the offset field is relevant in parse_msg and gives the offset
+where the message starts in the skb.
+
+The return values of this function are:
+
+>0 : indicates length of successfully parsed message
+0  : indicates more data must be received to parse the message
+-ESTRPIPE : current message should not be processed by the
+  kernel, return control of the socket to userspace which
+  can proceed to read the messages itself
+other < 0 : Error is parsing, give control back to userspace
+  assuming that synchronization is lost and the stream
+  is unrecoverable (application expected to close TCP socket)
+
+In the case that an error is returned (return value is less than
+zero) the stream parser will set the error on TCP socket and wake
+it up. If parse_msg returned -ESTRPIPE and the stream parser had
+previously read some bytes for the current message, then the error
+set on the attached socket is ENODATA since the stream is
+unrecoverable in that case.
+
+void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb);
+
+rcv_msg is called when a full message has been received and
+is queued. The callee must consume the sk_buff; it can
+call strp_pause to prevent any further messages from being
+received in rcv_msg (see strp_pause below). This callback
+must be set.
+
+The skb->cb in the input skb is a struct strp_rx_msg. This
+struct contains two fields: offset and full_len. Offset is
+where the message starts in the skb, and full_len is the
+the length of the message. skb->len - offset may be greater
+then full_len since strparser does not trim the skb.
+
+int (*read_sock_done)(struct strparser *strp, int err);
+
+ read_sock_done is called when the stream parser is done reading
+ the TCP socket. The stream parser may read multiple messages
+ in a loop and this function allows cleanup to occur when existing
+ the loop. If the callback is not set (NULL in strp_init) a
+ default function is used.
+
+void (*abort_parser)(struct strparser *strp, int err);
+
+ This function is called when stream parser encounters an error
+ in parsing. The default function stops the stream parser for the
+ TCP socket and sets the error in the socket. The default function
+ can be changed by setting the callback to non-NULL in strp_init.
+
+data_ready
+--
+
+strp_tcp_data_ready is the TCP data ready function that can be used with
+the stream parser. When the upper layer attaches the TCP socket it
+can set sk_data_ready to this function (after strp_init). sk_user_data
+must be set to the stream parser structure to use this (container_of
+can be used in the other socket callbacks to get the upper layer
+structure from the stream parser structure).
+
+Functions
+-
+
+The upper layer uses strp_pause and strp_unpause to flow control the
+stream parser. This is needed for instance when the upper layer can't
+immediately process a received message and has to 

Re: 4.6.3, pppoe + shaper workload, skb_panic / skb_push / ppp_start_xmit

2016-08-01 Thread Denys Fedoryshchenko

On 2016-08-01 23:59, Guillaume Nault wrote:

On Thu, Jul 28, 2016 at 02:28:23PM +0300, Denys Fedoryshchenko wrote:

 [ 5449.904989] CPU: 1 PID: 6359 Comm: ip Not tainted
4.7.0-build-0109 #2
 [ 5449.905255] Hardware name: Supermicro
X10SLM+-LN4F/X10SLM+-LN4F, BIOS 3.0 04/24/2015
 [ 5449.905712] task: 8803eef4 ti: 8803fd754000
task.ti: 8803fd754000
 [ 5449.906168] RIP: 0010:[]
 [] inet_fill_ifaddr+0x5a/0x264
 [ 5449.906710] RSP: 0018:8803fd757b98  EFLAGS: 00010286
 [ 5449.906976] RAX: 8803ef65cb90 RBX: 8803f7d2cd00 
RCX:


 [ 5449.907248] RDX: 00080002 RSI: 8803ef65cb90 
RDI:

8803ef65cba8
 [ 5449.907519] RBP: 8803fd757be0 R08: 0008 
R09:

0002
 [ 5449.907792] R10: ffa005040269f480 R11: 820a1c00 
R12:

ffa005040269f480
 [ 5449.908067] R13: 8803ef65cb90 R14:  
R15:

8803f7d2cd00
 [ 5449.908339] FS:  7f660674d700()
GS:88041fc4() knlGS:
 [ 5449.908796] CS:  0010 DS:  ES:  CR0: 
80050033
 [ 5449.909067] CR2: 008b9018 CR3: 0003f2a11000 
CR4:

001406e0
 [ 5449.909339] Stack:
 [ 5449.909598]  0163a8c0869711ac
 0080
 
 0003e1d50003e1d5

 [ 5449.910329]  8800d54c0ac8
 8803f0d9
 0005
 

 [ 5449.911066]  8803f7d2cd00
 8803fd757c40
 818a9f73
 820a1c00

 [ 5449.911803] Call Trace:
 [ 5449.912061]  [] 
inet_dump_ifaddr+0xfb/0x185
 [ 5449.912332]  [] 
rtnl_dump_all+0xa9/0xc2
 [ 5449.912601]  [] 
netlink_dump+0xf0/0x25c
 [ 5449.912873]  [] 
netlink_recvmsg+0x1a9/0x2d3

 [ 5449.913142]  [] sock_recvmsg+0x14/0x16
 [ 5449.913407]  [] 
___sys_recvmsg+0xea/0x1a1

 [ 5449.913675]  [] ?
alloc_pages_vma+0x167/0x1a0
 [ 5449.913945]  [] ?
page_add_new_anon_rmap+0xb4/0xbd
 [ 5449.914212]  [] ?
lru_cache_add_active_or_unevictable+0x31/0x9d
 [ 5449.914664]  [] ?
handle_mm_fault+0x632/0x112d
 [ 5449.914940]  [] ? 
vma_merge+0x27e/0x2b1
 [ 5449.915208]  [] 
__sys_recvmsg+0x3d/0x5e
 [ 5449.915478]  [] ? 
__sys_recvmsg+0x3d/0x5e

 [ 5449.915747]  [] SyS_recvmsg+0xd/0x17
 [ 5449.916017]  []
entry_SYSCALL_64_fastpath+0x17/0x93


Do you still have the vmlinux file with debug symbols that generated
this panic?


I have slightly different build now (tried to enable slightly different 
kernel options), but i had also new panic in inet_fill_ifaddr in new 
build. I will prepare tomorrow(everything at office) all files and 
provide link with sources and vmlinux, and sure new panic message on 
this build.

New panic message happened on completely different location and ISP.


[vhost:vhost 5/15] warning: (VOP && ..) selects VHOST_RING which has unmet direct dependencies (NETDEVICES && ..)

2016-08-01 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
head:   ccbb911915b99ba9ff81a1cfa4f07c98f98fff83
commit: 4d167a33a6669c309f8fcdc6cd7143de3b5445b3 [5/15] vhost: drop vringh 
dependency
config: x86_64-randconfig-x005-201631 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
git checkout 4d167a33a6669c309f8fcdc6cd7143de3b5445b3
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

warning: (VOP && CAIF_VIRTIO) selects VHOST_RING which has unmet direct 
dependencies (NETDEVICES && CAIF_VIRTIO || VIRTUALIZATION)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH -next] qed: Fix error return code in qed_resc_alloc()

2016-08-01 Thread Wei Yongjun
Fix to return error code -EINVAL instead of 0 when EQ elements is
too larger, as done elsewhere in this function.

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 1a53c04..648c814 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -509,6 +509,7 @@ int qed_resc_alloc(struct qed_dev *cdev)
DP_ERR(p_hwfn,
   "Cannot allocate 0x%x EQ elements. The maximum 
of a u16 chain is 0x%x\n",
   n_eqes, 0x);
+   rc = -EINVAL;
goto alloc_err;
}



Re: [Intel-wired-lan] [PATCH net-next v3 1/2] e1000e: factor out systim sanitization

2016-08-01 Thread Jarod Wilson
On Wed, Jul 27, 2016 at 11:01:55AM -0400, Jarod Wilson wrote:
> On Wed, Jul 27, 2016 at 02:09:13PM +, Avargil, Raanan wrote:
> >> This is prepatory work for an expanding list of adapter families that have 
> >> occasional ~10 hour clock jumps when being used for PTP. Factor out the 
> >> sanitization function and convert to using a feature (bug) flag, per 
> >> suggestion from Jesse Brandeburg.
> >> 
> >> Littering functional code with device-specific checks is much messier than 
> >> simply checking a flag, and having device-specific init set flags as 
> >> needed.
> >> There are probably a number of other cases in the e1000e code that 
> >> could/should be converted similarly.
> > 
> > Looks ok to me.
> > Adding Chris who asked what happens if we reach the max retry counter 
> > (E1000_MAX_82574_SYSTIM_REREAD)?
> > This counter is set to 50. 
> > Can you, for testing purposes, decreased this value (or even set it to 0) 
> > and see what happens?
> 
> Unfortunately, I don't have direct access to the affected hardware myself,
> so I'd have to prep a test build, hand it off to someone and play relay. I
> could do that, but it'd have some lag and possible multiple round-trips...
> Anyone inside Intel have hardware handy to test on? :p

Was tied up with other work the middle of last week, then on vacation for
a bit. There was some testing feedback provided from someone at neither
Red Hat or Intel, but I'm not sure where it leaves us right now. What
needs to happen next?

-- 
Jarod Wilson
ja...@redhat.com



Re: [PATCH 1/1] rps: Inspect PPTP encapsulated by GRE to get flow hash

2016-08-01 Thread Philp Prindeville

Inline...

Main issue in a nutshell is I don't like using "4" instead of 
"sizeof(my_32bit_header_field_here)".



On 07/28/2016 01:14 AM, f...@48lvckh6395k16k5.yundunddos.com wrote:

From: Gao Feng 

The PPTP is encapsulated by GRE header with that GRE_VERSION bits
must contain one. But current GRE RPS needs the GRE_VERSION must be
zero. So RPS does not work for PPTP traffic.

In my test environment, there are four MIPS cores, and all traffic
are passed through by PPTP. As a result, only one core is 100% busy
while other three cores are very idle. After this patch, the usage
of four cores are balanced well.

Signed-off-by: Gao Feng 
---
  v2: Update according to Tom and Philp's advice.
  1) Consolidate the codes with GRE version 0 path;
  2) Use PPP_PROTOCOL to get ppp protol;
  3) Set the FLOW_DIS_ENCAPSULATION flag;
  v1: Initial patch

  include/uapi/linux/if_tunnel.h |   5 +-
  net/core/flow_dissector.c  | 146 ++---
  2 files changed, 97 insertions(+), 54 deletions(-)

diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h
index 1046f55..dda4e4b 100644
--- a/include/uapi/linux/if_tunnel.h
+++ b/include/uapi/linux/if_tunnel.h
@@ -24,9 +24,12 @@
  #define GRE_SEQ   __cpu_to_be16(0x1000)
  #define GRE_STRICT__cpu_to_be16(0x0800)
  #define GRE_REC   __cpu_to_be16(0x0700)
-#define GRE_FLAGS  __cpu_to_be16(0x00F8)
+#define GRE_ACK__cpu_to_be16(0x0080)
+#define GRE_FLAGS  __cpu_to_be16(0x0078)
  #define GRE_VERSION   __cpu_to_be16(0x0007)
  
+#define GRE_PROTO_PPP	__cpu_to_be16(0x880b)

+
  struct ip_tunnel_parm {
charname[IFNAMSIZ];
int link;
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 61ad43f..33e957b 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -346,63 +346,103 @@ ip_proto_again:
hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, hlen, 
&_hdr);
if (!hdr)
goto out_bad;
-   /*
-* Only look inside GRE if version zero and no
-* routing
-*/
-   if (hdr->flags & (GRE_VERSION | GRE_ROUTING))
-   break;
-
-   proto = hdr->proto;
-   nhoff += 4;
-   if (hdr->flags & GRE_CSUM)
-   nhoff += 4;
-   if (hdr->flags & GRE_KEY) {
-   const __be32 *keyid;
-   __be32 _keyid;
-
-   keyid = __skb_header_pointer(skb, nhoff, sizeof(_keyid),
-data, hlen, &_keyid);
  
-			if (!keyid)

-   goto out_bad;
+   /* Only look inside GRE without routing */
+   if (!(hdr->flags & GRE_ROUTING)) {
+   proto = hdr->proto;
+
+   if (hdr->flags & GRE_VERSION) {
+   /* It should be the PPTP in GRE */
+   u8 _ppp_hdr[PPP_HDRLEN];
+   u8 *ppp_hdr;
+   int offset = 0;
+
+   /* Check the flags according to RFC 2637*/
+   if (!(proto == GRE_PROTO_PPP && (hdr->flags & GRE_KEY) 
&&
+ !(hdr->flags & (GRE_CSUM | GRE_STRICT | 
GRE_REC | GRE_FLAGS {
+   break;
+   }
+
+   /* Skip GRE header */
+   offset += 4;


Please don't use literal values.  Instead use the size of the field(s):

sizeof(struct gre_base_hdr) or offsetof(pptp_gre_header.payload_len)


+   /* Skip payload length and call id */
+   offset += 4;


sizeof(pptp_gre_header.payload_len) + sizeof(pptp_gre_header.call_id)


+
+   if (hdr->flags & GRE_SEQ)
+   offset += 4;


sizeof(pptp_gre_header.seq)


+
+   if (hdr->flags & GRE_ACK)
+   offset += 4;


sizeof(pptp_gre_header.ack)



+
+   ppp_hdr = skb_header_pointer(skb, nhoff + 
offset, sizeof(_ppp_hdr), _ppp_hdr);
+   if (!ppp_hdr)
+   goto out_bad;
+   proto = PPP_PROTOCOL(ppp_hdr);
+   if (proto == PPP_IP) {
+   nhoff += (PPP_HDRLEN + offset);
+   proto = htons(ETH_P_IP);
+   key_control->flags |= 
FLOW_DIS_ENCAPSULATION;
+   goto again;
+   } else if (proto == PPP_I

Re: [PATCH v3 3/3] mac80211: mesh: fixed HT ies in beacon template

2016-08-01 Thread Masashi Honma

On 2016年08月01日 19:03, Johannes Berg wrote:


But why is that behaviour *correct*? We still support 40 MHz bandwidth
things, we just don't use them if we disable HT40.


Or do you mean difference between "hardware capability" and "software 
capability" ?
Do you think IEEE80211_HT_CAP_SUP_WIDTH_20_40 bit should be 1 if the 
hardware capable of HT40 even though HT40 is disabled by 
wpa_supplicant/hostapd ?


I have tested with hostapd. I compared these 2 configfiles.

hostapd0.conf
ht_capab=[HT40-]
hostapd1.conf
#ht_capab=[HT40-]

The IEEE80211_HT_CAP_SUP_WIDTH_20_40 bit in beacon was below.

hostapd0.conf
IEEE80211_HT_CAP_SUP_WIDTH_20_40 = 1
hostapd1.conf
IEEE80211_HT_CAP_SUP_WIDTH_20_40 = 0

So I think the bit should be zero if disabled also for mesh peer.

Masashi Honma.


[vhost:vhost 6/17] ERROR: "vhost_work_flush" [drivers/vhost/vhost_scsi.ko] undefined!

2016-08-01 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
head:   b5311f2ee9cf07e73303ae792bdc363a91b9df0b
commit: 6190efb08c16dcd68c64b096a28f47ab33f017d7 [6/17] vhost: drop vringh 
dependency
config: x86_64-randconfig-n0-08020724 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
git checkout 6190efb08c16dcd68c64b096a28f47ab33f017d7
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "vhost_work_flush" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_dev_cleanup" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_log_access_ok" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_enable_notify" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_poll_flush" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_disable_notify" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_signal" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_dev_ioctl" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_get_vq_desc" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_work_queue" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_add_used_and_signal" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_work_init" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_vq_init_access" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_dev_init" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_dev_stop" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_vq_access_ok" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_vring_ioctl" [drivers/vhost/vhost_scsi.ko] undefined!
>> ERROR: "vhost_add_used" [drivers/vhost/vhost_scsi.ko] undefined!
   make[2]: *** [__modpost] Error 1
   make[2]: Target '_modpost' not remade because of errors.
   make[1]: *** [modules] Error 2
   make[1]: Target '_all' not remade because of errors.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH 0/2] HFSC patches

2016-08-01 Thread David Miller
From: Michal Soltys 
Date: Mon,  1 Aug 2016 01:03:57 +0200

> - first patch:
> 
> This patch syncs virtual times with fair service curve and fixes a very old
> subtle bug.
> 
> The detailed explanation is in the commit message. Additionally
> I've made an illustration to help understand the issue better:
> 
> http://imgur.com/a/N8uMC
> 
> See the example at the bottom of the commit message - Am1_3 and Am2_3 is what
> should happen with such queue setup, Am1_3real and Am2_3real is what actually
> happens due to rtsc_min() calculating minimum from corrected and uncorrected
> curves.
> 
> - second patch:
> 
> This is trivial patch that comments out one unused variable, related to 
> another
> commented out piece of code.

Don't just comment it out, if it's unused delete it entirely.


[PATCH net] openvswitch: Remove incorrect WARN_ONCE().

2016-08-01 Thread Jarno Rajahalme
ovs_ct_find_existing() issues a warning if an existing conntrack entry
classified as IP_CT_NEW is found, with the premise that this should
not happen.  However, a newly confirmed, non-expected conntrack entry
remains IP_CT_NEW as long as no reply direction traffic is seen.  This
has resulted into somewhat confusing kernel log messages.  This patch
removes this check and warning.

Fixes: 289f2253 ("openvswitch: Find existing conntrack entry after upcall.")
Suggested-by: Joe Stringer 
Signed-off-by: Jarno Rajahalme 
---
 net/openvswitch/conntrack.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index c644c78..e054a74 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -433,7 +433,6 @@ ovs_ct_find_existing(struct net *net, const struct 
nf_conntrack_zone *zone,
struct nf_conntrack_l4proto *l4proto;
struct nf_conntrack_tuple tuple;
struct nf_conntrack_tuple_hash *h;
-   enum ip_conntrack_info ctinfo;
struct nf_conn *ct;
unsigned int dataoff;
u8 protonum;
@@ -458,13 +457,8 @@ ovs_ct_find_existing(struct net *net, const struct 
nf_conntrack_zone *zone,
 
ct = nf_ct_tuplehash_to_ctrack(h);
 
-   ctinfo = ovs_ct_get_info(h);
-   if (ctinfo == IP_CT_NEW) {
-   /* This should not happen. */
-   WARN_ONCE(1, "ovs_ct_find_existing: new packet for %p\n", ct);
-   }
skb->nfct = &ct->ct_general;
-   skb->nfctinfo = ctinfo;
+   skb->nfctinfo = ovs_ct_get_info(h);
return ct;
 }
 
-- 
2.1.4



Re: [PATCH -next] qed: Fix error return code in qed_resc_alloc()

2016-08-01 Thread David Miller
From: Wei Yongjun 
Date: Tue,  2 Aug 2016 00:55:34 +

> Fix to return error code -EINVAL instead of 0 when EQ elements is
> too larger, as done elsewhere in this function.
> 
> Signed-off-by: Wei Yongjun 

Applied, thanks.


Re: [PATCH net v2] 8139too: fix system hang when there is a tx timeout event.

2016-08-01 Thread David Miller
From: Chunhao Lin 
Date: Mon, 1 Aug 2016 13:45:30 +0800

> If tx timeout event occur, kernel will call rtl8139_tx_timeout_task() to reset
> hardware. But in this function, driver does not stop tx and rx function before
> reset hardware, that will cause system hang.
> 
> In this patch, add stop tx and rx function before reset hardware.
> 
> Signed-off-by: Chunhao Lin 

Applied, thanks.


  1   2   >