Re: [PATCH] Convert BUG_ON to WARN_ON in bond_options.c

2017-06-22 Thread Bjørn Mork
Jay Vosburgh  writes:
> Michael J Dilmore  wrote:
>
>>if (WARN_ON(!new_active_slave) {
>>netdev_dbg("Can't add new active slave - pointer null");
>>return ERROR_CODE
>>}
>
>   In general, yes, but in this case, the condition should be
> impossible to hit, so BUG_ON seems appropriate.

If it really is impossible then you should simply remove the test. No
need to test for the impossible, is there?


Bjørn


Re: [PATCH] Convert BUG_ON to WARN_ON in bond_options.c

2017-06-22 Thread Michal Kubecek
On Thu, Jun 22, 2017 at 12:04:54AM +0100, Michael J Dilmore wrote:
> 
> Is it worth at least wrapping BUG_ON in an unlikely macro then?

See BUG_ON() definition:

#ifndef HAVE_ARCH_BUG_ON
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
#endif

where HAVE_ARCH_BUG_ON is defined only on powerpc and mips. It makes
good sense, you don't want to BUG_ON() on a condition unless it's
extremely unlikely. (Except for debugging purpose but even then you
don't really care about fine optimization when you are going to oops.)

Michal Kubecek



Re: [RFC PATCH net-next 1/3] ethtool: Add link down reason callback

2017-06-22 Thread Gal Pressman

>> +enum {
>> +ETHTOOL_LINK_VENDOR_SPECIFIC = -1, /* Vendor specific issue provided in 
>> vendor_reason */
>> +ETHTOOL_LINK_NO_ISSUE, /* No issue observed with link */
>> +ETHTOOL_LINK_REASON_UNKNOWN, /* Unknown reason */
> I think OTHER would be better that UNKNOWN. 

Fine with me.
>> +ETHTOOL_LINK_NETDEV_CARRIER_DOWN, /* Netdev carrier is down */
>> +ETHTOOL_LINK_ADMIN_DOWN, /* Admin down */
> These two are interesting. We have that information already. Why do we
> want it again?

My goal is to gather all link issue reasons in one place.
I don't want the user to gather pieces of other reports just to get a sense of 
what's wrong.
>> +ETHTOOL_LINK_AN_FAILED, /* Auto negotiation failed */
>> +ETHTOOL_LINK_TRAINING_FAILED, /* Link training failed */
>> +ETHTOOL_LINK_RMT_FAULT, /* Remote fault indication */
>> +ETHTOOL_LINK_BAD_SIGNAL_INTEGRITY, /* Bad signal integrity */
>> +ETHTOOL_LINK_CABLE_MISMATCH, /* Cable protocol mismatch */
>> +ETHTOOL_LINK_INTERNAL_ERR, /* Internal error */
> How does an internet error differ from an UNKNOWN?

Internal error means I know what happened but I can't tell you, your vendor 
support might be
able to provide a better analysis.
Unknown means that the driver doesn't have any useful information that can help 
in this case.
>> +ETHTOOL_LINK_CABLE_UNPLUGGED, /* Cable unplugged */
>> +ETHTOOL_LINK_UNSUPP_MODULE, /* Unsupported module */
>> +ETHTOOL_LINK_I2C_BUS_ERR, /* I2C bus error */
> Which I2C bus? What about MDIO BUS errors?

The I2C bus that's connected to this module (interface).
We can add another reason for MDIO BUS errors or merge to one BUS error reason.
>> +ETHTOOL_LINK_UNSUPP_EEPROM, /* Unsupported EEPROM */
> Which EEPROM?

Module EEPROM.
>> +ETHTOOL_LINK_OVERTEMP, /* Over temperature */
>> +ETHTOOL_LINK_PWR_BUDGET_EXC, /* Power budget exceeded */
>> +ETHTOOL_LINK_MODULE_ADMIN_DOWN, /* Module admin down */
> It seems like these last 6 are all SFP issues? How about putting SFP
> into the name?

Might be a QSFP issue for example, we can put module in the name though.
>
>  Andrew



Re: [RFC PATCH net-next 3/3] net/mlx5e: Expose link down reason to ethtool

2017-06-22 Thread Gal Pressman

>> +if (!netif_running(netdev)) {
>> +ldr->reason = ETHTOOL_LINK_NETDEV_CARRIER_DOWN;
>> +return 0;
>> +}
> This is generic, will work for any interface. The same is true for
> ADMIN_DOWN. Either it is not required at all, since the information is
> available via other means, or it should be in the core.

I agree, will move it to the core.

>
> Andrew



[PATCH NET 2/2] net: hns: Use phy_driver to setup Phy loopback

2017-06-22 Thread Lin Yun Sheng
Use function set_loopback in phy_driver to setup phy loopback
when doing ethtool self test.

Signed-off-by: Lin Yun Sheng 
---
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 64 
 1 file changed, 10 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index e95795b..660b51e 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -259,66 +259,22 @@ static int hns_nic_set_link_ksettings(struct net_device 
*net_dev,
 
 static int hns_nic_config_phy_loopback(struct phy_device *phy_dev, u8 en)
 {
-#define COPPER_CONTROL_REG 0
-#define PHY_POWER_DOWN BIT(11)
-#define PHY_LOOP_BACK BIT(14)
-   u16 val = 0;
 
-   if (phy_dev->is_c45) /* c45 branch adding for XGE PHY */
+   if (phy_dev->is_c45 || !phy_dev->drv)
+   return -ENOTSUPP;
+
+   if (!phy_dev->drv->resume || !phy_dev->drv->suspend ||
+   !phy_dev->drv->set_loopback)
return -ENOTSUPP;
 
if (en) {
-   /* speed : 1000M */
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 2);
-   phy_write(phy_dev, 21, 0x1046);
-
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 0);
-   /* Force Master */
-   phy_write(phy_dev, 9, 0x1F00);
-
-   /* Soft-reset */
-   phy_write(phy_dev, 0, 0x9140);
-   /* If autoneg disabled,two soft-reset operations */
-   phy_write(phy_dev, 0, 0x9140);
-
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 0xFA);
-
-   /* Default is 0x0400 */
-   phy_write(phy_dev, 1, 0x418);
-
-   /* Force 1000M Link, Default is 0x0200 */
-   phy_write(phy_dev, 7, 0x20C);
-
-   /* Powerup Fiber */
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 1);
-   val = phy_read(phy_dev, COPPER_CONTROL_REG);
-   val &= ~PHY_POWER_DOWN;
-   phy_write(phy_dev, COPPER_CONTROL_REG, val);
-
-   /* Enable Phy Loopback */
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 0);
-   val = phy_read(phy_dev, COPPER_CONTROL_REG);
-   val |= PHY_LOOP_BACK;
-   val &= ~PHY_POWER_DOWN;
-   phy_write(phy_dev, COPPER_CONTROL_REG, val);
+   phy_dev->drv->resume(phy_dev);
+   phy_dev->drv->set_loopback(phy_dev, 1);
} else {
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 0xFA);
-   phy_write(phy_dev, 1, 0x400);
-   phy_write(phy_dev, 7, 0x200);
-
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 1);
-   val = phy_read(phy_dev, COPPER_CONTROL_REG);
-   val |= PHY_POWER_DOWN;
-   phy_write(phy_dev, COPPER_CONTROL_REG, val);
-
-   phy_write(phy_dev, HNS_PHY_PAGE_REG, 0);
-   phy_write(phy_dev, 9, 0xF00);
-
-   val = phy_read(phy_dev, COPPER_CONTROL_REG);
-   val &= ~PHY_LOOP_BACK;
-   val |= PHY_POWER_DOWN;
-   phy_write(phy_dev, COPPER_CONTROL_REG, val);
+   phy_dev->drv->set_loopback(phy_dev, 0);
+   phy_dev->drv->suspend(phy_dev);
}
+
return 0;
 }
 
-- 
1.9.1



[PATCH v5 1/5] stmmac: pci: Make stmmac_pci_info structure constant

2017-06-22 Thread Jan Kiszka
From: Jan Kiszka 

By removing the PCI device reference from the structure and passing it
as parameters to the interested functions, we can make quark_pci_info
const.

Signed-off-by: Jan Kiszka 
Reviewed-by: Andy Shevchenko 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 22f910795be4..0efe42659a37 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -38,17 +38,17 @@ struct stmmac_pci_dmi_data {
 };
 
 struct stmmac_pci_info {
-   struct pci_dev *pdev;
-   int (*setup)(struct plat_stmmacenet_data *plat,
-struct stmmac_pci_info *info);
+   int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
+const struct stmmac_pci_info *info);
struct stmmac_pci_dmi_data *dmi;
 };
 
-static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
+static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
+   const struct stmmac_pci_info *info)
 {
const char *name = dmi_get_system_info(DMI_BOARD_NAME);
const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
-   unsigned int func = PCI_FUNC(info->pdev->devfn);
+   unsigned int func = PCI_FUNC(pdev->devfn);
struct stmmac_pci_dmi_data *dmi;
 
/*
@@ -114,10 +114,10 @@ static void stmmac_default_data(struct 
plat_stmmacenet_data *plat)
/* TODO: AXI */
 }
 
-static int quark_default_data(struct plat_stmmacenet_data *plat,
- struct stmmac_pci_info *info)
+static int quark_default_data(struct pci_dev *pdev,
+ struct plat_stmmacenet_data *plat,
+ const struct stmmac_pci_info *info)
 {
-   struct pci_dev *pdev = info->pdev;
int ret;
 
/* Set common default data first */
@@ -127,7 +127,7 @@ static int quark_default_data(struct plat_stmmacenet_data 
*plat,
 * Refuse to load the driver and register net device if MAC controller
 * does not connect to any PHY interface.
 */
-   ret = stmmac_pci_find_phy_addr(info);
+   ret = stmmac_pci_find_phy_addr(pdev, info);
if (ret < 0)
return ret;
 
@@ -175,7 +175,7 @@ static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
{}
 };
 
-static struct stmmac_pci_info quark_pci_info = {
+static const struct stmmac_pci_info quark_pci_info = {
.setup = quark_default_data,
.dmi = quark_pci_dmi_data,
 };
@@ -237,9 +237,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
pci_set_master(pdev);
 
if (info) {
-   info->pdev = pdev;
if (info->setup) {
-   ret = info->setup(plat, info);
+   ret = info->setup(pdev, plat, info);
if (ret)
return ret;
}
-- 
2.12.3



[PATCH v5 5/5] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

2017-06-22 Thread Jan Kiszka
From: Jan Kiszka 

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

Signed-off-by: Jan Kiszka 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 97 
 1 file changed, 64 insertions(+), 33 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index a6e10d3ced5c..8d375e51a526 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -30,36 +30,39 @@
  * negative value of the address means that MAC controller is not connected
  * with PHY.
  */
-struct stmmac_pci_dmi_data {
-   const char *name;
-   const char *asset_tag;
+struct stmmac_pci_func_data {
unsigned int func;
int phy_addr;
 };
 
+struct stmmac_pci_dmi_data {
+   const struct stmmac_pci_func_data *func;
+   size_t nfuncs;
+};
+
 struct stmmac_pci_info {
int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
 };
 
 static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
-   struct stmmac_pci_dmi_data *dmi_data)
+   const struct dmi_system_id *dmi_list)
 {
-   const char *name = dmi_get_system_info(DMI_BOARD_NAME);
-   const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
-   unsigned int func = PCI_FUNC(pdev->devfn);
-   struct stmmac_pci_dmi_data *dmi;
-
-   if (!name)
+   const struct stmmac_pci_func_data *func_data;
+   const struct stmmac_pci_dmi_data *dmi_data;
+   const struct dmi_system_id *dmi_id;
+   int func = PCI_FUNC(pdev->devfn);
+   size_t n;
+
+   dmi_id = dmi_first_match(dmi_list);
+   if (!dmi_id)
return -ENODEV;
 
-   for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
-   if (!strcmp(dmi->name, name) && dmi->func == func) {
-   /* If asset tag is provided, match on it as well. */
-   if (dmi->asset_tag && strcmp(dmi->asset_tag, asset_tag))
-   continue;
-   return dmi->phy_addr;
-   }
-   }
+   dmi_data = dmi_id->driver_data;
+   func_data = dmi_data->func;
+
+   for (n = 0; n < dmi_data->nfuncs; n++, func_data++)
+   if (func_data->func == func)
+   return func_data->phy_addr;
 
return -ENODEV;
 }
@@ -115,34 +118,62 @@ static const struct stmmac_pci_info stmmac_pci_info = {
.setup = stmmac_default_data,
 };
 
-static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+static const struct stmmac_pci_func_data galileo_stmmac_func_data[] = {
{
-   .name = "Galileo",
.func = 6,
.phy_addr = 1,
},
+};
+
+static const struct stmmac_pci_dmi_data galileo_stmmac_dmi_data = {
+   .func = galileo_stmmac_func_data,
+   .nfuncs = ARRAY_SIZE(galileo_stmmac_func_data),
+};
+
+static const struct stmmac_pci_func_data iot2040_stmmac_func_data[] = {
{
-   .name = "GalileoGen2",
.func = 6,
.phy_addr = 1,
},
{
-   .name = "SIMATIC IOT2000",
-   .asset_tag = "6ES7647-0AA00-0YA2",
-   .func = 6,
+   .func = 7,
.phy_addr = 1,
},
+};
+
+static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data = {
+   .func = iot2040_stmmac_func_data,
+   .nfuncs = ARRAY_SIZE(iot2040_stmmac_func_data),
+};
+
+static const struct dmi_system_id quark_pci_dmi[] = {
{
-   .name = "SIMATIC IOT2000",
-   .asset_tag = "6ES7647-0AA00-1YA2",
-   .func = 6,
-   .phy_addr = 1,
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_NAME, "Galileo"),
+   },
+   .driver_data = (void *)_stmmac_dmi_data,
},
{
-   .name = "SIMATIC IOT2000",
-   .asset_tag = "6ES7647-0AA00-1YA2",
-   .func = 7,
-   .phy_addr = 1,
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"),
+   },
+   .driver_data = (void *)_stmmac_dmi_data,
+   },
+   {
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+   DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+   "6ES7647-0AA00-0YA2"),
+   },
+   .driver_data = (void *)_stmmac_dmi_data,
+   },
+   {
+   .matches = {
+   DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+   DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+   "6ES7647-0AA00-1YA2"),
+   },
+   .driver_data = 

[PATCH v5 4/5] stmmac: pci: Select quark_pci_dmi_data from quark_default_data

2017-06-22 Thread Jan Kiszka
From: Jan Kiszka 

No need to carry this reference in stmmac_pci_info - the Quark-specific
setup handler knows that it needs to use the Quark-specific DMI table.
This also allows to drop the stmmac_pci_info reference from the setup
handler parameter list.

Signed-off-by: Jan Kiszka 
Reviewed-by: Andy Shevchenko 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 83 +++-
 1 file changed, 39 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index f44ae49eb11c..a6e10d3ced5c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -38,13 +38,11 @@ struct stmmac_pci_dmi_data {
 };
 
 struct stmmac_pci_info {
-   int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
-const struct stmmac_pci_info *info);
-   struct stmmac_pci_dmi_data *dmi;
+   int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
 };
 
 static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
-   const struct stmmac_pci_info *info)
+   struct stmmac_pci_dmi_data *dmi_data)
 {
const char *name = dmi_get_system_info(DMI_BOARD_NAME);
const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
@@ -54,7 +52,7 @@ static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
if (!name)
return -ENODEV;
 
-   for (dmi = info->dmi; dmi->name && *dmi->name; dmi++) {
+   for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
if (!strcmp(dmi->name, name) && dmi->func == func) {
/* If asset tag is provided, match on it as well. */
if (dmi->asset_tag && strcmp(dmi->asset_tag, asset_tag))
@@ -97,8 +95,7 @@ static void common_default_data(struct plat_stmmacenet_data 
*plat)
 }
 
 static int stmmac_default_data(struct pci_dev *pdev,
-  struct plat_stmmacenet_data *plat,
-  const struct stmmac_pci_info *info)
+  struct plat_stmmacenet_data *plat)
 {
/* Set common default data first */
common_default_data(plat);
@@ -118,9 +115,40 @@ static const struct stmmac_pci_info stmmac_pci_info = {
.setup = stmmac_default_data,
 };
 
+static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+   {
+   .name = "Galileo",
+   .func = 6,
+   .phy_addr = 1,
+   },
+   {
+   .name = "GalileoGen2",
+   .func = 6,
+   .phy_addr = 1,
+   },
+   {
+   .name = "SIMATIC IOT2000",
+   .asset_tag = "6ES7647-0AA00-0YA2",
+   .func = 6,
+   .phy_addr = 1,
+   },
+   {
+   .name = "SIMATIC IOT2000",
+   .asset_tag = "6ES7647-0AA00-1YA2",
+   .func = 6,
+   .phy_addr = 1,
+   },
+   {
+   .name = "SIMATIC IOT2000",
+   .asset_tag = "6ES7647-0AA00-1YA2",
+   .func = 7,
+   .phy_addr = 1,
+   },
+   {}
+};
+
 static int quark_default_data(struct pci_dev *pdev,
- struct plat_stmmacenet_data *plat,
- const struct stmmac_pci_info *info)
+ struct plat_stmmacenet_data *plat)
 {
int ret;
 
@@ -131,7 +159,7 @@ static int quark_default_data(struct pci_dev *pdev,
 * Refuse to load the driver and register net device if MAC controller
 * does not connect to any PHY interface.
 */
-   ret = stmmac_pci_find_phy_addr(pdev, info);
+   ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
if (ret < 0) {
/* Return error to the caller on DMI enabled boards. */
if (dmi_get_system_info(DMI_BOARD_NAME))
@@ -157,41 +185,8 @@ static int quark_default_data(struct pci_dev *pdev,
return 0;
 }
 
-static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
-   {
-   .name = "Galileo",
-   .func = 6,
-   .phy_addr = 1,
-   },
-   {
-   .name = "GalileoGen2",
-   .func = 6,
-   .phy_addr = 1,
-   },
-   {
-   .name = "SIMATIC IOT2000",
-   .asset_tag = "6ES7647-0AA00-0YA2",
-   .func = 6,
-   .phy_addr = 1,
-   },
-   {
-   .name = "SIMATIC IOT2000",
-   .asset_tag = "6ES7647-0AA00-1YA2",
-   .func = 6,
-   .phy_addr = 1,
-   },
-   {
-   .name = "SIMATIC IOT2000",
-   .asset_tag = "6ES7647-0AA00-1YA2",
-   .func = 7,
-   .phy_addr = 1,
-   },
- 

[PATCH v5 0/5] stmmac: pci: Refactor DMI probing

2017-06-22 Thread Jan Kiszka
Some cleanups of the way we probe DMI platforms in the driver. Reduces
a bit of open-coding and makes the logic easier reusable for any
potential DMI platform != Quark.

Tested on IOT2000 and Galileo Gen2.

Changes in v5:
 - fixed a remaining issue in patch 5
 - dropped patch 6 for now

Jan

Jan Kiszka (5):
  stmmac: pci: Make stmmac_pci_info structure constant
  stmmac: pci: Use stmmac_pci_info for all devices
  stmmac: pci: Make stmmac_pci_find_phy_addr truly generic
  stmmac: pci: Select quark_pci_dmi_data from quark_default_data
  stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 203 ++-
 1 file changed, 122 insertions(+), 81 deletions(-)

-- 
2.12.3



[PATCH v5 3/5] stmmac: pci: Make stmmac_pci_find_phy_addr truly generic

2017-06-22 Thread Jan Kiszka
From: Jan Kiszka 

Move the special case for the early Galileo firmware into
quark_default_setup. This allows to use stmmac_pci_find_phy_addr for
non-quark cases.

Signed-off-by: Jan Kiszka 
Reviewed-by: Andy Shevchenko 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index d3d74e526e17..f44ae49eb11c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -51,12 +51,8 @@ static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
unsigned int func = PCI_FUNC(pdev->devfn);
struct stmmac_pci_dmi_data *dmi;
 
-   /*
-* Galileo boards with old firmware don't support DMI. We always return
-* 1 here, so at least first found MAC controller would be probed.
-*/
if (!name)
-   return 1;
+   return -ENODEV;
 
for (dmi = info->dmi; dmi->name && *dmi->name; dmi++) {
if (!strcmp(dmi->name, name) && dmi->func == func) {
@@ -136,8 +132,18 @@ static int quark_default_data(struct pci_dev *pdev,
 * does not connect to any PHY interface.
 */
ret = stmmac_pci_find_phy_addr(pdev, info);
-   if (ret < 0)
-   return ret;
+   if (ret < 0) {
+   /* Return error to the caller on DMI enabled boards. */
+   if (dmi_get_system_info(DMI_BOARD_NAME))
+   return ret;
+
+   /*
+* Galileo boards with old firmware don't support DMI. We always
+* use 1 here as PHY address, so at least the first found MAC
+* controller would be probed.
+*/
+   ret = 1;
+   }
 
plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
plat->phy_addr = ret;
-- 
2.12.3



Re: [PATCH] netxen: Fix a sleep-in-atomic bug in netxen_nic_pci_mem_access_direct

2017-06-22 Thread Dan Carpenter
We should probably add a might_sleep() to ioremap() to prevent these
bugs in the future.

This bug is eight years old.  You can report it, but it's going to hard
to get anyone to fix it.  I sometimes ignore ancient bugs.  On the other
hand, netxen is fairly well supported so it doesn't hurt to try.

I try to report bugs as soon as they are introduced.  I report it to
the author and CC the relevant list.  If people don't respond to my
email after a month then I complain again.

regards,
dan carpenter



Re: [PATCH][net-next] qtnfmac: fix uninitialized return code in ret

2017-06-22 Thread Sergey Matyukevich
> Not related to your patch but qtnf_map_bar() should be changed not to
> return NULL.  When functions return both NULL and error pointers the
> NULL is supposed to be a special type of success return.  Here it is
> just a fail return where we forgot to set the error code to
> ERR_PTR(-ENOMEM).

Thanks for reporting! FWIW it is not a bug, all the checks of pci maps
are in place. Though having both ERR_PTR and NULL in return indeed
looks confusing. We will add a fix in the upcoming cleanup series.

Regards,
Sergey


[PATCH net v2 2/2] esp6_offload: Fix IP6CB(skb)->nhoff for ESP GRO

2017-06-22 Thread yossiku
From: Yossi Kuperman 

IP6CB(skb)->nhoff is the offset of the nexthdr field in an IPv6
header, unless there are extension headers present, in which case
nhoff points to the nexthdr field of the last extension header.

In non-GRO code path, nhoff is set by ipv6_rcv before any XFRM code
is executed. Conversely, in GRO code path (when esp6_offload is loaded),
nhoff is not set. The following functions fail to read the correct value
and eventually the packet is dropped:

xfrm6_transport_finish
xfrm6_tunnel_input
xfrm6_rcv_tnl

Set nhoff to the proper offset of nexthdr in esp6_gro_receive.

Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
Signed-off-by: Yossi Kuperman 
---
 net/ipv6/esp6_offload.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c
index d950d43..f02f131 100644
--- a/net/ipv6/esp6_offload.c
+++ b/net/ipv6/esp6_offload.c
@@ -30,6 +30,25 @@
 #include 
 #include 
 
+static __u16 esp6_nexthdr_esp_offset(struct ipv6hdr *ipv6_hdr, int nhlen)
+{
+   int off = sizeof(struct ipv6hdr);
+   struct ipv6_opt_hdr *exthdr;
+
+   if (likely(ipv6_hdr->nexthdr == NEXTHDR_ESP))
+   return offsetof(struct ipv6hdr, nexthdr);
+
+   while (off < nhlen) {
+   exthdr = (void *)ipv6_hdr + off;
+   if (exthdr->nexthdr == NEXTHDR_ESP)
+   return off;
+
+   off += ipv6_optlen(exthdr);
+   }
+
+   return 0;
+}
+
 static struct sk_buff **esp6_gro_receive(struct sk_buff **head,
 struct sk_buff *skb)
 {
@@ -38,6 +57,7 @@ static struct sk_buff **esp6_gro_receive(struct sk_buff 
**head,
struct xfrm_state *x;
__be32 seq;
__be32 spi;
+   int nhoff;
int err;
 
skb_pull(skb, offset);
@@ -72,6 +92,11 @@ static struct sk_buff **esp6_gro_receive(struct sk_buff 
**head,
 
xo->flags |= XFRM_GRO;
 
+   nhoff = esp6_nexthdr_esp_offset(ipv6_hdr(skb), offset);
+   if (!nhoff)
+   goto out;
+
+   IP6CB(skb)->nhoff = nhoff;
XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL;
XFRM_SPI_SKB_CB(skb)->family = AF_INET6;
XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr);
-- 
2.8.1



[PATCH net v2 1/2] xfrm6: Fix IPv6 payload_len in xfrm6_transport_finish

2017-06-22 Thread yossiku
From: Yossi Kuperman 

IPv6 payload length indicates the size of the payload, including any
extension headers.

In xfrm6_transport_finish, ipv6_hdr(skb)->payload_len is set to the
payload size only, regardless of the presence of any extension headers.
After ESP GRO transport mode decapsulation, ipv6_rcv trims the packet
according to the wrong payload_len, thus corrupting the packet.

Set payload_len to account for extension headers as well.

Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
Signed-off-by: Yossi Kuperman 
---
v1 -> v2:
- Fix the "Fixes" tag
---
 net/ipv6/xfrm6_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index 08a807b..3ef5d91 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -43,8 +43,8 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)
return 1;
 #endif
 
-   ipv6_hdr(skb)->payload_len = htons(skb->len);
__skb_push(skb, skb->data - skb_network_header(skb));
+   ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
 
if (xo && (xo->flags & XFRM_GRO)) {
skb_mac_header_rebuild(skb);
-- 
2.8.1



[PATCH v5 2/5] stmmac: pci: Use stmmac_pci_info for all devices

2017-06-22 Thread Jan Kiszka
From: Jan Kiszka 

Make stmmac_default_data compatible with stmmac_pci_info.setup and use
an info structure for all devices. This allows to make the probing more
regular.

Signed-off-by: Jan Kiszka 
Reviewed-by: Andy Shevchenko 
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 0efe42659a37..d3d74e526e17 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -100,7 +100,9 @@ static void common_default_data(struct plat_stmmacenet_data 
*plat)
plat->rx_queues_cfg[0].pkt_route = 0x0;
 }
 
-static void stmmac_default_data(struct plat_stmmacenet_data *plat)
+static int stmmac_default_data(struct pci_dev *pdev,
+  struct plat_stmmacenet_data *plat,
+  const struct stmmac_pci_info *info)
 {
/* Set common default data first */
common_default_data(plat);
@@ -112,8 +114,14 @@ static void stmmac_default_data(struct 
plat_stmmacenet_data *plat)
plat->dma_cfg->pbl = 32;
plat->dma_cfg->pblx8 = true;
/* TODO: AXI */
+
+   return 0;
 }
 
+static const struct stmmac_pci_info stmmac_pci_info = {
+   .setup = stmmac_default_data,
+};
+
 static int quark_default_data(struct pci_dev *pdev,
  struct plat_stmmacenet_data *plat,
  const struct stmmac_pci_info *info)
@@ -236,14 +244,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 
pci_set_master(pdev);
 
-   if (info) {
-   if (info->setup) {
-   ret = info->setup(pdev, plat, info);
-   if (ret)
-   return ret;
-   }
-   } else
-   stmmac_default_data(plat);
+   ret = info->setup(pdev, plat, info);
+   if (ret)
+   return ret;
 
pci_enable_msi(pdev);
 
@@ -269,14 +272,21 @@ static void stmmac_pci_remove(struct pci_dev *pdev)
 
 static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_suspend, stmmac_resume);
 
-#define STMMAC_VENDOR_ID 0x700
+/* synthetic ID, no official vendor */
+#define PCI_VENDOR_ID_STMMAC 0x700
+
 #define STMMAC_QUARK_ID  0x0937
 #define STMMAC_DEVICE_ID 0x1108
 
+#define STMMAC_DEVICE(vendor_id, dev_id, info) {   \
+   PCI_VDEVICE(vendor_id, dev_id), \
+   .driver_data = (kernel_ulong_t)\
+   }
+
 static const struct pci_device_id stmmac_id_table[] = {
-   {PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)},
-   {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)},
-   {PCI_VDEVICE(INTEL, STMMAC_QUARK_ID), (kernel_ulong_t)_pci_info},
+   STMMAC_DEVICE(STMMAC, STMMAC_DEVICE_ID, stmmac_pci_info),
+   STMMAC_DEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_MAC, stmmac_pci_info),
+   STMMAC_DEVICE(INTEL, STMMAC_QUARK_ID, quark_pci_info),
{}
 };
 
-- 
2.12.3



Re: [Intel-wired-lan] [PATCH] net: intel: e1000e: add check on e1e_wphy() return value

2017-06-22 Thread Neftin, Sasha

On 21/06/2017 22:52, Gustavo A. R. Silva wrote:

Hi Ethan,

Quoting Ethan Zhao :


Gustavo,

   The return value of ret_val seems used to check if the access to 
PHY/NVM

got its semaphore,  generally speaking, it is needed for every PHY
access of this driver.

Reviewed-by: Ethan Zhao 



Thank you very much for the clarification.


On Wed, Jun 21, 2017 at 5:22 AM, Gustavo A. R. Silva
 wrote:

Check return value from call to e1e_wphy(). This value is being
checked during previous calls to function e1e_wphy() and it seems
a check was missing here.

Addresses-Coverity-ID: 1226905
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c 
b/drivers/net/ethernet/intel/e1000e/ich8lan.c

index 68ea8b4..d6d4ed7 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -2437,6 +2437,8 @@ static s32 
e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)

if (hw->phy.revision < 2) {
e1000e_phy_sw_reset(hw);
ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
+   if (ret_val)
+   return ret_val;
}
}

--
2.5.0



--
Gustavo A. R. Silva





___
Intel-wired-lan mailing list
intel-wired-...@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


We will accept this patch.



Re: [PATCH net 1/2] xfrm6: Fix IPv6 payload_len in xfrm6_transport_finish

2017-06-22 Thread Steffen Klassert
On Wed, Jun 21, 2017 at 08:38:13PM +, Yossi Kuperman wrote:
> 
> The bug is there nonetheless, it just doesn't seem to affect anything.
> I guess no one was looking inside the IP header thereafter.  
> 
> Should I use this instead: 7785bba299a8 ("esp: Add a software GRO codepath")?

Yes, please do this. The Fixes tag tells which stable kernels need
this patch. If we did not have problems before we added GRO, then
there is no need to backport it any further.

Thanks!


[PATCH NET 1/2] net: phy: Add phy loopback support in net phy framework

2017-06-22 Thread Lin Yun Sheng
This patch add set_loopback in phy_driver, which is used by Mac
driver to enable or disable a phy. it also add a generic
genphy_loopback function, which use BMCR loopback bit to enable
or disable a phy.

Signed-off-by: Lin Yun Sheng 
---
 drivers/net/phy/marvell.c|  1 +
 drivers/net/phy/phy_device.c | 23 +++
 include/linux/phy.h  |  2 ++
 3 files changed, 26 insertions(+)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 57297ba..01a1586 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -2094,6 +2094,7 @@ static int m88e1510_probe(struct phy_device *phydev)
.get_sset_count = marvell_get_sset_count,
.get_strings = marvell_get_strings,
.get_stats = marvell_get_stats,
+   .set_loopback = genphy_loopback,
},
{
.phy_id = MARVELL_PHY_ID_88E1540,
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 1219eea..13b36fa 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1628,6 +1628,27 @@ static int gen10g_resume(struct phy_device *phydev)
return 0;
 }
 
+int genphy_loopback(struct phy_device *phydev, bool enable)
+{
+   int value;
+
+   if (enable) {
+   value = phy_read(phydev, MII_BMCR);
+   phy_write(phydev, MII_BMCR, value | BMCR_LOOPBACK);
+   } else {
+   value = phy_read(phydev, MII_BMCR);
+   phy_write(phydev, MII_BMCR, value & ~BMCR_LOOPBACK);
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(genphy_loopback);
+
+static int gen10g_loopback(struct phy_device *phydev, bool enable)
+{
+   return 0;
+}
+
 static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
 {
/* The default values for phydev->supported are provided by the PHY
@@ -1874,6 +1895,7 @@ void phy_drivers_unregister(struct phy_driver *drv, int n)
.read_status= genphy_read_status,
.suspend= genphy_suspend,
.resume = genphy_resume,
+   .set_loopback   = genphy_loopback,
 }, {
.phy_id = 0x,
.phy_id_mask= 0x,
@@ -1885,6 +1907,7 @@ void phy_drivers_unregister(struct phy_driver *drv, int n)
.read_status= gen10g_read_status,
.suspend= gen10g_suspend,
.resume = gen10g_resume,
+   .set_loopback   = gen10g_loopback,
 } };
 
 static int __init phy_init(void)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index e76e4ad..9362e22 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -639,6 +639,7 @@ struct phy_driver {
int (*set_tunable)(struct phy_device *dev,
struct ethtool_tunable *tuna,
const void *data);
+   int (*set_loopback)(struct phy_device *dev, bool enable);
 };
 #define to_phy_driver(d) container_of(to_mdio_common_driver(d),
\
  struct phy_driver, mdiodrv)
@@ -825,6 +826,7 @@ void phy_attached_print(struct phy_device *phydev, const 
char *fmt, ...)
 int genphy_read_status(struct phy_device *phydev);
 int genphy_suspend(struct phy_device *phydev);
 int genphy_resume(struct phy_device *phydev);
+int genphy_loopback(struct phy_device *phydev, bool enable);
 int genphy_soft_reset(struct phy_device *phydev);
 static inline int genphy_no_soft_reset(struct phy_device *phydev)
 {
-- 
1.9.1



[PATCH NET 0/2] Add loopback support in phy_driver and hns ethtool fix

2017-06-22 Thread Lin Yun Sheng
This Patch Set add set_loopback in phy_driver and use it to setup loopback
when doing ethtool phy self_test.

Lin Yun Sheng (2):
  net: phy: Add phy loopback support in net phy framework
  net: hns: Use phy_driver to setup Phy loopback

 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 64 
 drivers/net/phy/marvell.c|  1 +
 drivers/net/phy/phy_device.c | 23 +
 include/linux/phy.h  |  2 +
 4 files changed, 36 insertions(+), 54 deletions(-)

-- 
1.9.1



Re: [RFC PATCH net-next 3/3] net/mlx5e: Expose link down reason to ethtool

2017-06-22 Thread Gal Pressman

> Is my reading correct that in case the reason is not in the
> pddr2ethtool_table opaque binary data will be passed from the firmware
> to user space?  Is there any particular reason to allow for this?  If
> it's just for the rare scenario where a new error code needs to be
> added perhaps it would be enough to dump the FW-provided message to the
> logs?

No binary data is passed in this patch, the monitor_opcode is simply a vendor 
specific
16 bit id that is used when the reason  is not generic enough to have it's own 
enum.


Re: [PATCH] netxen: Fix a sleep-in-atomic bug in netxen_nic_pci_mem_access_direct

2017-06-22 Thread Jia-Ju Bai

On 2017/6/22 14:08, Dan Carpenter wrote:

We should probably add a might_sleep() to ioremap() to prevent these
bugs in the future.

I think it is right to do this.
And it will be very useful to summarize common kernel interface 
functions which may sleep into a list. When writing a new driver, the 
developer can refer to this list to reduce or avoid sleep-in-atomic bugs.




This bug is eight years old.  You can report it, but it's going to hard
to get anyone to fix it.  I sometimes ignore ancient bugs.  On the other
hand, netxen is fairly well supported so it doesn't hurt to try.

I try to report bugs as soon as they are introduced.  I report it to
the author and CC the relevant list.  If people don't respond to my
email after a month then I complain again.

regards,
dan carpenter



Thanks for your helpful advice.

Thanks,
Jia-Ju Bai



Re: [PATCH net v2 2/2] esp6_offload: Fix IP6CB(skb)->nhoff for ESP GRO

2017-06-22 Thread Steffen Klassert
On Thu, Jun 22, 2017 at 11:37:11AM +0300, yoss...@mellanox.com wrote:
> From: Yossi Kuperman 
> 
> IP6CB(skb)->nhoff is the offset of the nexthdr field in an IPv6
> header, unless there are extension headers present, in which case
> nhoff points to the nexthdr field of the last extension header.
> 
> In non-GRO code path, nhoff is set by ipv6_rcv before any XFRM code
> is executed. Conversely, in GRO code path (when esp6_offload is loaded),
> nhoff is not set. The following functions fail to read the correct value
> and eventually the packet is dropped:
> 
> xfrm6_transport_finish
> xfrm6_tunnel_input
> xfrm6_rcv_tnl
> 
> Set nhoff to the proper offset of nexthdr in esp6_gro_receive.
> 
> Fixes: 7785bba299a8 ("esp: Add a software GRO codepath")
> Signed-off-by: Yossi Kuperman 

Both patches applied, thanks for your work Yossi!


EMAIL ALERT

2017-06-22 Thread IT Department
Please be advised that we will be performing a scheduled email maintenance 
within the next 24hrs, during this maintenance you will be require to
update your email account via link http://www.beam.to/9687

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



Re: [RFC PATCH net-next 0/3] ethtool: Add link down reason reporting

2017-06-22 Thread Gal Pressman
> Ethtool doesn't work well as a monitoring/event interface.
> Maybe this would be better as extended information with the  netlink UP/DOW 
> event.

This API is not meant for monitoring events.
The main use case here is a new interface that's down and won't go up for some 
reason.
Nothing will magically change until someone fixes the issue, logging the reason 
as an event on
netdev creation seems less convenient to me.


Re: [RFC PATCH net-next 1/3] ethtool: Add link down reason callback

2017-06-22 Thread Gal Pressman

>> +ETHTOOL_LINK_PWR_BUDGET_EXC, /* Power budget exceeded */
>> +ETHTOOL_LINK_MODULE_ADMIN_DOWN, /* Module admin down */
>> +
>> +ETHTOOL_LINK_REASONS_COUNT
>> +};
> Any enumerated list is going to get changed too often.
> Could the API just return a string?

The motivation for the enumerated list is to make this API as generic as 
possible and compatible
with all ethernet drivers.

Returning a string is a good idea, maybe change the vendor specific opcode to a 
string?


[PATCH net] sfc: Fix MCDI command size for filter operations

2017-06-22 Thread Martin Habets
The 8000 series adapters uses catch-all filters for encapsulated traffic
to support filtering VXLAN, NVGRE and GENEVE traffic.
This new filter functionality requires a longer MCDI command.
This patch increases the size of buffers on stack that were missed, which
fixes a kernel panic from the stack protector.

Fixes: 9b41080125176 ("sfc: insert catch-all filters for encapsulated traffic")
Signed-off-by: Martin Habets 
Acked-by: Edward Cree 
Acked-by: Bert Kenward bkenw...@solarflare.com
---
 drivers/net/ethernet/sfc/ef10.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 78efb2822b86..a8089667fc5b 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -4172,7 +4172,7 @@ static s32 efx_ef10_filter_insert(struct efx_nic *efx,
 * recipients
 */
if (is_mc_recip) {
-   MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_IN_LEN);
+   MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_EXT_IN_LEN);
unsigned int depth, i;
 
memset(inbuf, 0, sizeof(inbuf));
@@ -4320,7 +4320,7 @@ static int efx_ef10_filter_remove_internal(struct efx_nic 
*efx,
efx_ef10_filter_set_entry(table, filter_idx, NULL, 0);
} else {
efx_mcdi_display_error(efx, MC_CMD_FILTER_OP,
-  MC_CMD_FILTER_OP_IN_LEN,
+  MC_CMD_FILTER_OP_EXT_IN_LEN,
   NULL, 0, rc);
}
}
@@ -4453,7 +4453,7 @@ static s32 efx_ef10_filter_rfs_insert(struct efx_nic *efx,
  struct efx_filter_spec *spec)
 {
struct efx_ef10_filter_table *table = efx->filter_state;
-   MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_IN_LEN);
+   MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_EXT_IN_LEN);
struct efx_filter_spec *saved_spec;
unsigned int hash, i, depth = 1;
bool replacing = false;
@@ -4940,7 +4940,7 @@ static void efx_ef10_filter_table_restore(struct efx_nic 
*efx)
 static void efx_ef10_filter_table_remove(struct efx_nic *efx)
 {
struct efx_ef10_filter_table *table = efx->filter_state;
-   MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_IN_LEN);
+   MCDI_DECLARE_BUF(inbuf, MC_CMD_FILTER_OP_EXT_IN_LEN);
struct efx_filter_spec *spec;
unsigned int filter_idx;
int rc;


Re: [Patch net] ipv6: avoid unregistering inet6_dev for loopback

2017-06-22 Thread Andrey Konovalov
On Wed, Jun 21, 2017 at 11:34 PM, Cong Wang  wrote:
> The per netns loopback_dev->ip6_ptr is unregistered and set to
> NULL when its mtu is set to smaller than IPV6_MIN_MTU, this
> leads to that we could set rt->rt6i_idev NULL after a
> rt6_uncached_list_flush_dev() and then crash after another
> call.
>
> In this case we should just bring its inet6_dev down, rather
> than unregistering it, at least prior to commit 176c39af29bc
> ("netns: fix addrconf_ifdown kernel panic") we always
> override the case for loopback.
>
> Thanks a lot to Andrey for finding a reliable reproducer.

Thanks! This fixes the bug for me.

Tested-by: Andrey Konovalov 

>
> Fixes: 176c39af29bc ("netns: fix addrconf_ifdown kernel panic")
> Reported-by: Andrey Konovalov 
> Cc: Andrey Konovalov 
> Cc: Daniel Lezcano 
> Cc: David Ahern 
> Signed-off-by: Cong Wang 
> ---
>  net/ipv6/addrconf.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 686c923..1d2dbac 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -3369,6 +3369,7 @@ static int addrconf_notify(struct notifier_block *this, 
> unsigned long event,
> struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> struct netdev_notifier_changeupper_info *info;
> struct inet6_dev *idev = __in6_dev_get(dev);
> +   struct net *net = dev_net(dev);
> int run_pending = 0;
> int err;
>
> @@ -3384,7 +3385,7 @@ static int addrconf_notify(struct notifier_block *this, 
> unsigned long event,
> case NETDEV_CHANGEMTU:
> /* if MTU under IPV6_MIN_MTU stop IPv6 on this interface. */
> if (dev->mtu < IPV6_MIN_MTU) {
> -   addrconf_ifdown(dev, 1);
> +   addrconf_ifdown(dev, dev != net->loopback_dev);
> break;
> }
>
> @@ -3500,7 +3501,7 @@ static int addrconf_notify(struct notifier_block *this, 
> unsigned long event,
>  * IPV6_MIN_MTU stop IPv6 on this interface.
>  */
> if (dev->mtu < IPV6_MIN_MTU)
> -   addrconf_ifdown(dev, 1);
> +   addrconf_ifdown(dev, dev != 
> net->loopback_dev);
> }
> break;
>
> --
> 2.5.5
>


[PATCH v6 3/3] net/cxgb4: Use new PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag

2017-06-22 Thread Ding Tianhong
From: Casey Leedom 

cxgb4 Ethernet driver now queries PCIe configuration space to determine
if it can send TLPs to it with the Relaxed Ordering Attribute set.

Signed-off-by: Casey Leedom 
Signed-off-by: Ding Tianhong 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 17 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c|  5 +++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index e88c180..478f25a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -521,6 +521,7 @@ enum { /* adapter flags */
USING_SOFT_PARAMS  = (1 << 6),
MASTER_PF  = (1 << 7),
FW_OFLD_CONN   = (1 << 9),
+   ROOT_NO_RELAXED_ORDERING = (1 << 10),
 };
 
 enum {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index ea1bfcf..0c4a6e9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4735,6 +4735,23 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
adapter->msg_enable = DFLT_MSG_ENABLE;
memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
 
+   /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
+* Ingress Packet Data to Free List Buffers in order to allow for
+* chipset performance optimizations between the Root Complex and
+* Memory Controllers.  (Messages to the associated Ingress Queue
+* notifying new Packet Placement in the Free Lists Buffers will be
+* send without the Relaxed Ordering Attribute thus guaranteeing that
+* all preceding PCIe Transaction Layer Packets will be processed
+* first.)  But some Root Complexes have various issues with Upstream
+* Transaction Layer Packets with the Relaxed Ordering Attribute set.
+* The PCIe devices which under the Root Complexes will be cleared the
+* Relaxed Ordering bit in the configuration space, So we check our
+* PCIe configuration space to see if it's flagged with advice against
+* using Relaxed Ordering.
+*/
+   if (!pcie_relaxed_ordering_supported(pdev))
+   adapter->flags |= ROOT_NO_RELAXED_ORDERING;
+
spin_lock_init(>stats_lock);
spin_lock_init(>tid_release_lock);
spin_lock_init(>win0_lock);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index f05f0d4..ac229a3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2571,6 +2571,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
struct fw_iq_cmd c;
struct sge *s = >sge;
struct port_info *pi = netdev_priv(dev);
+   int relaxed = !(adap->flags & ROOT_NO_RELAXED_ORDERING);
 
/* Size needs to be multiple of 16, including status entry. */
iq->size = roundup(iq->size, 16);
@@ -2624,8 +2625,8 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
 
flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc);
c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F |
-FW_IQ_CMD_FL0FETCHRO_F |
-FW_IQ_CMD_FL0DATARO_F |
+FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
+FW_IQ_CMD_FL0DATARO_V(relaxed) |
 FW_IQ_CMD_FL0PADEN_F);
if (cong >= 0)
c.iqns_to_fl0congen |=
-- 
1.9.0




[PATCH v6 1/3] PCI: Add new PCIe Fabric End Node flag, PCI_DEV_FLAGS_NO_RELAXED_ORDERING

2017-06-22 Thread Ding Tianhong
From: Casey Leedom 

The new flag PCI_DEV_FLAGS_NO_RELAXED_ORDERING indicates that the Relaxed
Ordering Attribute should not be used on Transaction Layer Packets destined
for the PCIe End Node so flagged.  Initially flagged this way are Intel
E5-26xx Root Complex Ports which suffer from a Flow Control Credit
Performance Problem and AMD A1100 ARM ("SEATTLE") Root Complex Ports which
don't obey PCIe 3.0 ordering rules which can lead to Data Corruption.

Signed-off-by: Casey Leedom 
Signed-off-by: Ding Tianhong 
---
 drivers/pci/quirks.c | 38 ++
 include/linux/pci.h  |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 085fb78..58bdd23 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3999,6 +3999,44 @@ static void quirk_tw686x_class(struct pci_dev *pdev)
  quirk_tw686x_class);
 
 /*
+ * Some devices have problems with Transaction Layer Packets with the Relaxed
+ * Ordering Attribute set.  Such devices should mark themselves and other
+ * Device Drivers should check before sending TLPs with RO set.
+ */
+static void quirk_relaxedordering_disable(struct pci_dev *dev)
+{
+   dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING;
+}
+
+/*
+ * Intel E5-26xx Root Complex has a Flow Control Credit issue which can
+ * cause performance problems with Upstream Transaction Layer Packets with
+ * Relaxed Ordering set.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+
+/*
+ * The AMD ARM A1100 (AKA "SEATTLE") SoC has a bug in its PCIe Root Complex
+ * where Upstream Transaction Layer Packets with the Relaxed Ordering
+ * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering
+ * set.  This is a violation of the PCIe 3.0 Transaction Ordering Rules
+ * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0
+ * November 10, 2010).  As a result, on this platform we can't use Relaxed
+ * Ordering for Upstream TLPs.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, 
PCI_CLASS_NOT_DEFINED, 8,
+ quirk_relaxedordering_disable);
+
+/*
  * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same
  * values for the Attribute as were supplied in the header of the
  * corresponding Request, except as explicitly allowed when IDO is used."
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8039f9f..ce77690 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -188,6 +188,8 @@ enum pci_dev_flags {
 * the direct_complete optimization.
 */
PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11),
+   /* Don't use Relaxed Ordering for TLPs directed at this device */
+   PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 12),
 };
 
 enum pci_irq_reroute_variant {
-- 
1.9.0




[PATCH net-next 4/4] esp6: Fix RX checksum after header pull

2017-06-22 Thread ilant
From: Yossi Kuperman 

Both ip6_input_finish (non-GRO) and esp6_gro_receive (GRO) strip
the IPv6 header without adjusting skb->csum accordingly. As a
result CHECKSUM_COMPLETE breaks and "hw csum failure" is written
to the kernel log by netdev_rx_csum_fault (dev.c).

Fix skb->csum by substracting the checksum value of the pulled IPv6
header using a call to skb_postpull_rcsum.

This affects both transport and tunnel modes.

Note that the fix occurs far from the place that the header was
pulled. This is based on existing code, see:
ipv6_srh_rcv() in exthdrs.c and rawv6_rcv() in raw.c

Signed-off-by: Yossi Kuperman 
---
 net/ipv6/esp6.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index f872bb16cc9d..3fed3947acf9 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -500,6 +500,8 @@ int esp6_input_done2(struct sk_buff *skb, int err)
 
trimlen = alen + padlen + 2;
if (skb->ip_summed == CHECKSUM_COMPLETE) {
+   skb_postpull_rcsum(skb, skb_network_header(skb),
+  skb_network_header_len(skb));
csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
skb->csum = csum_block_sub(skb->csum, csumdiff,
   skb->len - trimlen);
-- 
2.11.0



[PATCH net-next 0/4] CHECKSUM_COMPLETE in IPSec

2017-06-22 Thread ilant
From: Ilan Tayari 

This patchset adds support for RX checksum offload in IPSec.

When crypto is performed in the host, the checksum needs to
be recalculated over all the payload.

However, when crypto is performed in the NIC, the NIC may
provide useful CHECKSUM_COMPLETE value, which then only needs
to be updated to account for decapsulation.

Note: This patchset is on top of the recent two IPv6 xfrm
patches which were submitted to 'net'.

Ilan Tayari (2):
  esp4: Support RX checksum with crypto offload
  esp6: Support RX checksum with crypto offload

Yossi Kuperman (2):
  xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push
  esp6: Fix RX checksum after header pull

 net/ipv4/esp4.c | 13 +++--
 net/ipv4/esp4_offload.c |  4 +++-
 net/ipv6/esp6.c | 15 +--
 net/ipv6/esp6_offload.c |  4 +++-
 net/ipv6/xfrm6_input.c  |  4 +++-
 5 files changed, 33 insertions(+), 7 deletions(-)

-- 
2.11.0



Re: [RFC PATCH net-next 0/3] ethtool: Add link down reason reporting

2017-06-22 Thread Gal Pressman

> Any particular reason for implementing this ABI in ethtool rather than
> via some netlink-based interface?  Devlink naturally comes to mind,
> given that cabling problems are not really related to the L2 and netdev
> shouldn't be required for diagnostics..

ethtool is already used for reporting and handling of link related stuff 
through get/set_link_ksettings.
How is reporting the link modes/port type/speed/etc different from this?
This feature is only an extension of the already existent "link detected" field.

Implementing this ABI in devlink is a good idea, but it shouldn't be instead of 
ethtool but in addition to ethtool.
Many users already use ethtool for this kind of info, we can tell them to use 
devlink to check why their link is down,
but I think it's nicer to have it all in one place.


[PATCH v6 2/3] PCI: Enable PCIe Relaxed Ordering if supported

2017-06-22 Thread Ding Tianhong
The PCIe Device Control Register use the bit 4 to indicate that
whether the device is permitted to enable relaxed ordering or not.
But relaxed ordering is not safe for some platform which could only
use strong write ordering, so devices are allowed (but not required)
to enable relaxed ordering bit by default.

If a PCIe device didn't enable the relaxed ordering attribute default,
we should not do anything in the PCIe configuration, otherwise we
should check if any of the devices above us do not support relaxed
ordering by the PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag, then base on
the result if we get a return that indicate that the relaxed ordering
is not supported we should update our device to disable relaxed ordering
in configuration space. If the device above us doesn't exist or isn't
the PCIe device, we shouldn't do anything and skip updating relaxed ordering
because we are probably running in a guest machine.

Signed-off-by: Ding Tianhong 
---
 drivers/pci/pci.c   | 29 +
 drivers/pci/probe.c | 37 +
 include/linux/pci.h |  2 ++
 3 files changed, 68 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 563901c..c773e0d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4879,6 +4879,35 @@ int pcie_set_mps(struct pci_dev *dev, int mps)
 EXPORT_SYMBOL(pcie_set_mps);
 
 /**
+ * pcie_clear_relaxed_ordering - clear PCI Express relaxed ordering bit
+ * @dev: PCI device to query
+ *
+ * If possible clear relaxed ordering
+ */
+int pcie_clear_relaxed_ordering(struct pci_dev *dev)
+{
+   return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
+ PCI_EXP_DEVCTL_RELAX_EN);
+}
+EXPORT_SYMBOL(pcie_clear_relaxed_ordering);
+
+/**
+ * pcie_relaxed_ordering_supported - Probe for PCIe relexed ordering support
+ * @dev: PCI device to query
+ *
+ * Returns true if the device support relaxed ordering attribute.
+ */
+bool pcie_relaxed_ordering_supported(struct pci_dev *dev)
+{
+   u16 v;
+
+   pcie_capability_read_word(dev, PCI_EXP_DEVCTL, );
+
+   return !!(v & PCI_EXP_DEVCTL_RELAX_EN);
+}
+EXPORT_SYMBOL(pcie_relaxed_ordering_supported);
+
+/**
  * pcie_get_minimum_link - determine minimum link settings of a PCI device
  * @dev: PCI device to query
  * @speed: storage for minimum speed
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 19c8950..2615299 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1701,6 +1701,42 @@ static void pci_configure_extended_tags(struct pci_dev 
*dev)
 PCI_EXP_DEVCTL_EXT_TAG);
 }
 
+/**
+ * pci_dev_should_disable_relaxed_ordering - check if the PCI device
+ * should disable the relaxed ordering attribute.
+ * @dev: PCI device
+ *
+ * Return true if any of the PCI devices above us do not support
+ * relaxed ordering.
+ */
+static bool pci_dev_should_disable_relaxed_ordering(struct pci_dev *dev)
+{
+   while (dev) {
+   if (dev->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING)
+   return true;
+
+   dev = dev->bus->self;
+   }
+
+   return false;
+}
+
+static void pci_configure_relaxed_ordering(struct pci_dev *dev)
+{
+   /* We should not alter the relaxed ordering bit for the VF */
+   if (dev->is_virtfn)
+   return;
+
+   /* If the releaxed ordering enable bit is not set, do nothing. */
+   if (!pcie_relaxed_ordering_supported(dev))
+   return;
+
+   if (pci_dev_should_disable_relaxed_ordering(dev)) {
+   pcie_clear_relaxed_ordering(dev);
+   dev_info(>dev, "Disable Relaxed Ordering\n");
+   }
+}
+
 static void pci_configure_device(struct pci_dev *dev)
 {
struct hotplug_params hpp;
@@ -1708,6 +1744,7 @@ static void pci_configure_device(struct pci_dev *dev)
 
pci_configure_mps(dev);
pci_configure_extended_tags(dev);
+   pci_configure_relaxed_ordering(dev);
 
memset(, 0, sizeof(hpp));
ret = pci_get_hp_params(dev, );
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ce77690..f5f200f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1110,6 +1110,8 @@ int __pci_enable_wake(struct pci_dev *dev, pci_power_t 
state,
 void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
+int pcie_clear_relaxed_ordering(struct pci_dev *dev);
+bool pcie_relaxed_ordering_supported(struct pci_dev *dev);
 
 static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
  bool enable)
-- 
1.9.0




[PATCH v6 0/3] Add new PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag

2017-06-22 Thread Ding Tianhong
Some devices have problems with Transaction Layer Packets with the Relaxed
Ordering Attribute set.  This patch set adds a new PCIe Device Flag,
PCI_DEV_FLAGS_NO_RELAXED_ORDERING, a set of PCI Quirks to catch some known
devices with Relaxed Ordering issues, and a use of this new flag by the
cxgb4 driver to avoid using Relaxed Ordering with problematic Root Complex
Ports.

It's been years since I've submitted kernel.org patches, I appolgise for the
almost certain submission errors.

v2: Alexander point out that the v1 was only a part of the whole solution,
some platform which has some issues could use the new flag to indicate
that it is not safe to enable relaxed ordering attribute, then we need
to clear the relaxed ordering enable bits in the PCI configuration when
initializing the device. So add a new second patch to modify the PCI
initialization code to clear the relaxed ordering enable bit in the
event that the root complex doesn't want relaxed ordering enabled.

The third patch was base on the v1's second patch and only be changed
to query the relaxed ordering enable bit in the PCI configuration space
to allow the Chelsio NIC to send TLPs with the relaxed ordering attributes
set.

This version didn't plan to drop the defines for Intel Drivers to use the
new checking way to enable relaxed ordering because it is not the hardest
part of the moment, we could fix it in next patchset when this patches
reach the goal.  

v3: Redesigned the logic for pci_configure_relaxed_ordering when configuration,
If a PCIe device didn't enable the relaxed ordering attribute default,
we should not do anything in the PCIe configuration, otherwise we
should check if any of the devices above us do not support relaxed
ordering by the PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag, then base on
the result if we get a return that indicate that the relaxed ordering
is not supported we should update our device to disable relaxed ordering
in configuration space. If the device above us doesn't exist or isn't
the PCIe device, we shouldn't do anything and skip updating relaxed ordering
because we are probably running in a guest.

v4: Rename the functions pcie_get_relaxed_ordering and 
pcie_disable_relaxed_ordering
according John's suggestion, and modify the description, use the true/false
as the return value.

We shouldn't enable relaxed ordering attribute by the setting in the root
complex configuration space for PCIe device, so fix it for cxgb4.

Fix some format issues.

v5: Removed the unnecessary code for some function which only return the bool
value, and add the check for VF device.

Make this patch set base on 4.12-rc5.

v6: Fix the logic error in the need to enable the relaxed ordering attribute 
for cxgb4.
 
Casey Leedom (2):
  PCI: Add new PCIe Fabric End Node flag,
PCI_DEV_FLAGS_NO_RELAXED_ORDERING
  net/cxgb4: Use new PCI_DEV_FLAGS_NO_RELAXED_ORDERING flag

Ding Tianhong (1):
  PCI: Enable PCIe Relaxed Ordering if supported

 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 17 ++
 drivers/net/ethernet/chelsio/cxgb4/sge.c|  5 +--
 drivers/pci/pci.c   | 32 +++
 drivers/pci/probe.c | 41 +
 drivers/pci/quirks.c| 38 +++
 include/linux/pci.h |  4 +++
 7 files changed, 136 insertions(+), 2 deletions(-)

-- 
1.9.0




[PATCH net-next 3/4] xfrm6: Fix CHECKSUM_COMPLETE after IPv6 header push

2017-06-22 Thread ilant
From: Yossi Kuperman 

xfrm6_transport_finish rebuilds the IPv6 header based on the
original one and pushes it back without fixing skb->csum.
Therefore, CHECKSUM_COMPLETE is no longer valid and the packet
gets dropped.

Fix skb->csum by calling skb_postpush_rcsum.

Note: A valid IPv4 header has checksum 0, unlike IPv6. Thus,
the change is not needed in the sibling xfrm4_transport_finish
function.

Signed-off-by: Yossi Kuperman 
---
 net/ipv6/xfrm6_input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index 3ef5d913e7a3..f95943a13abc 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -34,6 +34,7 @@ EXPORT_SYMBOL(xfrm6_rcv_spi);
 int xfrm6_transport_finish(struct sk_buff *skb, int async)
 {
struct xfrm_offload *xo = xfrm_offload(skb);
+   int nhlen = skb->data - skb_network_header(skb);
 
skb_network_header(skb)[IP6CB(skb)->nhoff] =
XFRM_MODE_SKB_CB(skb)->protocol;
@@ -43,8 +44,9 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)
return 1;
 #endif
 
-   __skb_push(skb, skb->data - skb_network_header(skb));
+   __skb_push(skb, nhlen);
ipv6_hdr(skb)->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
+   skb_postpush_rcsum(skb, skb_network_header(skb), nhlen);
 
if (xo && (xo->flags & XFRM_GRO)) {
skb_mac_header_rebuild(skb);
-- 
2.11.0



[PATCH net-next 2/4] esp6: Support RX checksum with crypto offload

2017-06-22 Thread ilant
From: Ilan Tayari 

Keep the device's reported ip_summed indication in case crypto
was offloaded by the device. Subtract the csum values of the
stripped parts (esp header+iv, esp trailer+auth_data) to keep
value correct.

Note: CHECKSUM_COMPLETE should be indicated only if skb->csum
has the post-decryption offload csum value.

Signed-off-by: Ariel Levkovich 
Signed-off-by: Ilan Tayari 
---
 net/ipv6/esp6.c | 13 +++--
 net/ipv6/esp6_offload.c |  4 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index d8b40ff4b2e6..f872bb16cc9d 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -475,7 +475,8 @@ int esp6_input_done2(struct sk_buff *skb, int err)
int hlen = sizeof(struct ip_esp_hdr) + crypto_aead_ivsize(aead);
int elen = skb->len - hlen;
int hdr_len = skb_network_header_len(skb);
-   int padlen;
+   int padlen, trimlen;
+   __wsum csumdiff;
u8 nexthdr[2];
 
if (!xo || (xo && !(xo->flags & CRYPTO_DONE)))
@@ -497,7 +498,15 @@ int esp6_input_done2(struct sk_buff *skb, int err)
 
/* ... check padding bits here. Silly. :-) */
 
-   pskb_trim(skb, skb->len - alen - padlen - 2);
+   trimlen = alen + padlen + 2;
+   if (skb->ip_summed == CHECKSUM_COMPLETE) {
+   csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
+   skb->csum = csum_block_sub(skb->csum, csumdiff,
+  skb->len - trimlen);
+   skb_postpull_rcsum(skb, skb->data, hlen);
+   }
+
+   pskb_trim(skb, skb->len - trimlen);
__skb_pull(skb, hlen);
if (x->props.mode == XFRM_MODE_TUNNEL)
skb_reset_transport_header(skb);
diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c
index f02f131f6435..eec3add177fe 100644
--- a/net/ipv6/esp6_offload.c
+++ b/net/ipv6/esp6_offload.c
@@ -209,11 +209,13 @@ static struct sk_buff *esp6_gso_segment(struct sk_buff 
*skb,
 static int esp6_input_tail(struct xfrm_state *x, struct sk_buff *skb)
 {
struct crypto_aead *aead = x->data;
+   struct xfrm_offload *xo = xfrm_offload(skb);
 
if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + 
crypto_aead_ivsize(aead)))
return -EINVAL;
 
-   skb->ip_summed = CHECKSUM_NONE;
+   if (!(xo->flags & CRYPTO_DONE))
+   skb->ip_summed = CHECKSUM_NONE;
 
return esp6_input_done2(skb, 0);
 }
-- 
2.11.0



[PATCH net-next 1/4] esp4: Support RX checksum with crypto offload

2017-06-22 Thread ilant
From: Ilan Tayari 

Keep the device's reported ip_summed indication in case crypto
was offloaded by the device. Subtract the csum values of the
stripped parts (esp header+iv, esp trailer+auth_data) to keep
value correct.

Note: CHECKSUM_COMPLETE should be indicated only if skb->csum
has the post-decryption offload csum value.

Signed-off-by: Ariel Levkovich 
Signed-off-by: Ilan Tayari 
---
 net/ipv4/esp4.c | 13 +++--
 net/ipv4/esp4_offload.c |  4 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 1f18b4650253..2eab0992b127 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -510,7 +510,8 @@ int esp_input_done2(struct sk_buff *skb, int err)
int elen = skb->len - hlen;
int ihl;
u8 nexthdr[2];
-   int padlen;
+   int padlen, trimlen;
+   __wsum csumdiff;
 
if (!xo || (xo && !(xo->flags & CRYPTO_DONE)))
kfree(ESP_SKB_CB(skb)->tmp);
@@ -568,7 +569,15 @@ int esp_input_done2(struct sk_buff *skb, int err)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
 
-   pskb_trim(skb, skb->len - alen - padlen - 2);
+   trimlen = alen + padlen + 2;
+   if (skb->ip_summed == CHECKSUM_COMPLETE) {
+   csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0);
+   skb->csum = csum_block_sub(skb->csum, csumdiff,
+  skb->len - trimlen);
+   skb_postpull_rcsum(skb, skb->data, hlen);
+   }
+
+   pskb_trim(skb, skb->len - trimlen);
__skb_pull(skb, hlen);
if (x->props.mode == XFRM_MODE_TUNNEL)
skb_reset_transport_header(skb);
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c
index e0666016a764..05831dea00f4 100644
--- a/net/ipv4/esp4_offload.c
+++ b/net/ipv4/esp4_offload.c
@@ -182,11 +182,13 @@ static struct sk_buff *esp4_gso_segment(struct sk_buff 
*skb,
 static int esp_input_tail(struct xfrm_state *x, struct sk_buff *skb)
 {
struct crypto_aead *aead = x->data;
+   struct xfrm_offload *xo = xfrm_offload(skb);
 
if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + 
crypto_aead_ivsize(aead)))
return -EINVAL;
 
-   skb->ip_summed = CHECKSUM_NONE;
+   if (!(xo->flags & CRYPTO_DONE))
+   skb->ip_summed = CHECKSUM_NONE;
 
return esp_input_done2(skb, 0);
 }
-- 
2.11.0



[PATCH net-next 0/3] net: mvpp2: misc improvements

2017-06-22 Thread Thomas Petazzoni
David,

Here are a few patches making various small improvements/refactoring
in the mvpp2 driver. They are based on today's net-next.

Thanks!

Thomas

Thomas Petazzoni (3):
  net: mvpp2: add comments about smp_processor_id() usage
  net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function
  net: mvpp2: remove mvpp2_pool_refill()

 drivers/net/ethernet/marvell/mvpp2.c | 58 
 1 file changed, 32 insertions(+), 26 deletions(-)

-- 
2.9.4



[PATCH net-next 3/3] net: mvpp2: remove mvpp2_pool_refill()

2017-06-22 Thread Thomas Petazzoni
When all a function does is calling another function with the exact same
arguments, in the exact same order, you know it's time to remove said
function. Which is exactly what this commit does.

Signed-off-by: Thomas Petazzoni 
---
 drivers/net/ethernet/marvell/mvpp2.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index aad763c..48d21c1 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3953,14 +3953,6 @@ static inline void mvpp2_bm_pool_put(struct mvpp2_port 
*port, int pool,
put_cpu();
 }
 
-/* Refill BM pool */
-static void mvpp2_pool_refill(struct mvpp2_port *port, int pool,
- dma_addr_t dma_addr,
- phys_addr_t phys_addr)
-{
-   mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
-}
-
 /* Allocate buffers for the pool */
 static int mvpp2_bm_bufs_add(struct mvpp2_port *port,
 struct mvpp2_bm_pool *bm_pool, int buf_num)
@@ -5015,7 +5007,7 @@ static void mvpp2_rxq_drop_pkts(struct mvpp2_port *port,
pool = (status & MVPP2_RXD_BM_POOL_ID_MASK) >>
MVPP2_RXD_BM_POOL_ID_OFFS;
 
-   mvpp2_pool_refill(port, pool,
+   mvpp2_bm_pool_put(port, pool,
  mvpp2_rxdesc_dma_addr_get(port, rx_desc),
  mvpp2_rxdesc_cookie_get(port, rx_desc));
}
@@ -5469,7 +5461,7 @@ static int mvpp2_rx_refill(struct mvpp2_port *port,
if (!buf)
return -ENOMEM;
 
-   mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
+   mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
 
return 0;
 }
@@ -5553,7 +5545,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo,
dev->stats.rx_errors++;
mvpp2_rx_error(port, rx_desc);
/* Return the buffer to the pool */
-   mvpp2_pool_refill(port, pool, dma_addr, phys_addr);
+   mvpp2_bm_pool_put(port, pool, dma_addr, phys_addr);
continue;
}
 
-- 
2.9.4



[PATCH net-next 1/3] net: mvpp2: add comments about smp_processor_id() usage

2017-06-22 Thread Thomas Petazzoni
A previous commit modified a number of smp_processor_id() used in
migration-enabled contexts into get_cpu/put_cpu sections. However, a few
smp_processor_id() calls remain in the driver, and this commit adds
comments explaining why they can be kept.

Signed-off-by: Thomas Petazzoni 
---
 drivers/net/ethernet/marvell/mvpp2.c | 33 +
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index ca4b55c..4b3bf37 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -4162,7 +4162,10 @@ static inline void mvpp2_interrupts_disable(struct 
mvpp2_port *port)
MVPP2_ISR_DISABLE_INTERRUPT(cpu_mask));
 }
 
-/* Mask the current CPU's Rx/Tx interrupts */
+/* Mask the current CPU's Rx/Tx interrupts
+ * Called by on_each_cpu(), guaranteed to run with migration disabled,
+ * using smp_processor_id() is OK.
+ */
 static void mvpp2_interrupts_mask(void *arg)
 {
struct mvpp2_port *port = arg;
@@ -4171,7 +4174,10 @@ static void mvpp2_interrupts_mask(void *arg)
   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
 }
 
-/* Unmask the current CPU's Rx/Tx interrupts */
+/* Unmask the current CPU's Rx/Tx interrupts.
+ * Called by on_each_cpu(), guaranteed to run with migration disabled,
+ * using smp_processor_id() is OK.
+ */
 static void mvpp2_interrupts_unmask(void *arg)
 {
struct mvpp2_port *port = arg;
@@ -4554,7 +4560,11 @@ mvpp2_txq_next_desc_get(struct mvpp2_tx_queue *txq)
return txq->descs + tx_desc;
 }
 
-/* Update HW with number of aggregated Tx descriptors to be sent */
+/* Update HW with number of aggregated Tx descriptors to be sent
+ *
+ * Called only from mvpp2_tx(), so migration is disabled, using
+ * smp_processor_id() is OK.
+ */
 static void mvpp2_aggr_txq_pend_desc_add(struct mvpp2_port *port, int pending)
 {
/* aggregated access - relevant TXQ number is written in TX desc */
@@ -4565,6 +4575,9 @@ static void mvpp2_aggr_txq_pend_desc_add(struct 
mvpp2_port *port, int pending)
 
 /* Check if there are enough free descriptors in aggregated txq.
  * If not, update the number of occupied descriptors and repeat the check.
+ *
+ * Called only from mvpp2_tx(), so migration is disabled, using
+ * smp_processor_id() is OK.
  */
 static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv,
 struct mvpp2_tx_queue *aggr_txq, int num)
@@ -4583,7 +4596,12 @@ static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv,
return 0;
 }
 
-/* Reserved Tx descriptors allocation request */
+/* Reserved Tx descriptors allocation request
+ *
+ * Called only from mvpp2_txq_reserved_desc_num_proc(), itself called
+ * only by mvpp2_tx(), so migration is disabled, using
+ * smp_processor_id() is OK.
+ */
 static int mvpp2_txq_alloc_reserved_desc(struct mvpp2 *priv,
 struct mvpp2_tx_queue *txq, int num)
 {
@@ -4687,6 +4705,10 @@ static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto,
 /* Get number of sent descriptors and decrement counter.
  * The number of sent descriptors is returned.
  * Per-CPU access
+ *
+ * Called only from mvpp2_txq_done(), called from mvpp2_tx()
+ * (migration disabled) and from the TX completion tasklet (migration
+ * disabled) so using smp_processor_id() is OK.
  */
 static inline int mvpp2_txq_sent_desc_proc(struct mvpp2_port *port,
   struct mvpp2_tx_queue *txq)
@@ -4701,6 +4723,9 @@ static inline int mvpp2_txq_sent_desc_proc(struct 
mvpp2_port *port,
MVPP2_TRANSMITTED_COUNT_OFFSET;
 }
 
+/* Called through on_each_cpu(), so runs on all CPUs, with migration
+ * disabled, therefore using smp_processor_id() is OK.
+ */
 static void mvpp2_txq_sent_counter_clear(void *arg)
 {
struct mvpp2_port *port = arg;
-- 
2.9.4



[PATCH net-next 2/3] net: mvpp2: remove unused mvpp2_bm_cookie_pool_set() function

2017-06-22 Thread Thomas Petazzoni
This function is not used in the driver, remove it.

Signed-off-by: Thomas Petazzoni 
---
 drivers/net/ethernet/marvell/mvpp2.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 4b3bf37..aad763c 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3917,17 +3917,6 @@ static void *mvpp2_buf_alloc(struct mvpp2_port *port,
return data;
 }
 
-/* Set pool number in a BM cookie */
-static inline u32 mvpp2_bm_cookie_pool_set(u32 cookie, int pool)
-{
-   u32 bm;
-
-   bm = cookie & ~(0xFF << MVPP2_BM_COOKIE_POOL_OFFS);
-   bm |= ((pool & 0xFF) << MVPP2_BM_COOKIE_POOL_OFFS);
-
-   return bm;
-}
-
 /* Release buffer to BM */
 static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool,
 dma_addr_t buf_dma_addr,
-- 
2.9.4



[PATCH net-next] udp/v6: prefetch rmem_alloc in udp6_queue_rcv_skb()

2017-06-22 Thread Paolo Abeni
very similar to commit dd99e425be23 ("udp: prefetch
rmem_alloc in udp_queue_rcv_skb()"), this allows saving a cache
miss when the BH is bottle-neck for UDP over ipv6 packet
processing, e.g. for small packets when a single RX NIC ingress
queue is in use.

Performances under flood when multiple NIC RX queues used are
unaffected, but when a single NIC rx queue is in use, this
gives ~8% performance improvement.

Signed-off-by: Paolo Abeni 
---
 net/ipv6/udp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 2b33847..d1d7288 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -630,6 +630,7 @@ static int udpv6_queue_rcv_skb(struct sock *sk, struct 
sk_buff *skb)
}
}
 
+   prefetch(>sk_rmem_alloc);
if (rcu_access_pointer(sk->sk_filter) &&
udp_lib_checksum_complete(skb))
goto csum_error;
-- 
2.9.4



[PATCH rdma-next V1 04/19] RDMA/netlink: Rename and remove redundant parameter from ibnl_multicast

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

The pointer to netlink header was not used in the ibnl_multicast
function, so let's remove it and simplify the function
signature.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/addr.c | 2 +-
 drivers/infiniband/core/iwpm_msg.c | 2 +-
 drivers/infiniband/core/netlink.c  | 5 ++---
 drivers/infiniband/core/sa_query.c | 2 +-
 include/rdma/rdma_netlink.h| 4 +---
 5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 134d8394fca5..ebd0242bab3d 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -185,7 +185,7 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,
 
/* Repair the nlmsg header length */
nlmsg_end(skb, nlh);
-   ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, GFP_KERNEL);
+   rdma_nl_multicast(skb, RDMA_NL_GROUP_LS, GFP_KERNEL);
 
/* Make the request retry, so when we get the response from userspace
 * we will have something.
diff --git a/drivers/infiniband/core/iwpm_msg.c 
b/drivers/infiniband/core/iwpm_msg.c
index 8f84557d04e3..561f312ea35a 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -103,7 +103,7 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 
nl_client)
pr_debug("%s: Multicasting a nlmsg (dev = %s ifname = %s iwpm = %s)\n",
__func__, pm_msg->dev_name, pm_msg->if_name, iwpm_ulib_name);
 
-   ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_IWPM, GFP_KERNEL);
+   ret = rdma_nl_multicast(skb, RDMA_NL_GROUP_IWPM, GFP_KERNEL);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
iwpm_user_pid = IWPM_PID_UNAVAILABLE;
diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index cd29311078b5..89a6219b6ec8 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -247,12 +247,11 @@ int rdma_nl_unicast(struct sk_buff *skb, u32 pid)
 }
 EXPORT_SYMBOL(rdma_nl_unicast);
 
-int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-   unsigned int group, gfp_t flags)
+int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags)
 {
return nlmsg_multicast(nls, skb, 0, group, flags);
 }
-EXPORT_SYMBOL(ibnl_multicast);
+EXPORT_SYMBOL(rdma_nl_multicast);
 
 int __init rdma_nl_init(void)
 {
diff --git a/drivers/infiniband/core/sa_query.c 
b/drivers/infiniband/core/sa_query.c
index 6e39a763b220..d890600f1e2d 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -862,7 +862,7 @@ static int ib_nl_send_msg(struct ib_sa_query *query, gfp_t 
gfp_mask)
/* Repair the nlmsg header length */
nlmsg_end(skb, nlh);
 
-   ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, gfp_mask);
+   ret = rdma_nl_multicast(skb, RDMA_NL_GROUP_LS, gfp_mask);
if (!ret)
ret = len;
else
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 9779cd5520d7..145283896417 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -67,13 +67,11 @@ int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
 /**
  * Send the supplied skb to a netlink group.
  * @skb: The netlink skb
- * @nlh: Header of the netlink message to send
  * @group: Netlink group ID
  * @flags: allocation flags
  * Returns 0 on success or a negative error code.
  */
-int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-   unsigned int group, gfp_t flags);
+int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
 
 /**
  * Check if there are any listeners to the netlink group
-- 
2.13.1



[PATCH rdma-next V1 03/19] RDMA/netlink: Rename and remove redundant parameter from ibnl_unicast

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

Netlink message header is not needed for unicast reply, hence remove it.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/iwpm_msg.c  | 6 +++---
 drivers/infiniband/core/iwpm_util.c | 4 ++--
 drivers/infiniband/core/netlink.c   | 5 ++---
 include/rdma/rdma_netlink.h | 4 +---
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/core/iwpm_msg.c 
b/drivers/infiniband/core/iwpm_msg.c
index 1fab707b1f68..8f84557d04e3 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -172,7 +172,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 
nl_client)
goto add_mapping_error;
nlmsg_request->req_buffer = pm_msg;
 
-   ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+   ret = rdma_nl_unicast(skb, iwpm_user_pid);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
iwpm_user_pid = IWPM_PID_UNDEFINED;
@@ -248,7 +248,7 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, 
u8 nl_client)
goto query_mapping_error;
nlmsg_request->req_buffer = pm_msg;
 
-   ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+   ret = rdma_nl_unicast(skb, iwpm_user_pid);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
err_str = "Unable to send a nlmsg";
@@ -308,7 +308,7 @@ int iwpm_remove_mapping(struct sockaddr_storage 
*local_addr, u8 nl_client)
if (ret)
goto remove_mapping_error;
 
-   ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+   ret = rdma_nl_unicast(skb, iwpm_user_pid);
if (ret) {
skb = NULL; /* skb is freed in the netlink send-op handling */
iwpm_user_pid = IWPM_PID_UNDEFINED;
diff --git a/drivers/infiniband/core/iwpm_util.c 
b/drivers/infiniband/core/iwpm_util.c
index c46442ac71a2..c81c55942626 100644
--- a/drivers/infiniband/core/iwpm_util.c
+++ b/drivers/infiniband/core/iwpm_util.c
@@ -597,7 +597,7 @@ static int send_mapinfo_num(u32 mapping_num, u8 nl_client, 
int iwpm_pid)
_num, IWPM_NLA_MAPINFO_SEND_NUM);
if (ret)
goto mapinfo_num_error;
-   ret = ibnl_unicast(skb, nlh, iwpm_pid);
+   ret = rdma_nl_unicast(skb, iwpm_pid);
if (ret) {
skb = NULL;
err_str = "Unable to send a nlmsg";
@@ -626,7 +626,7 @@ static int send_nlmsg_done(struct sk_buff *skb, u8 
nl_client, int iwpm_pid)
return -ENOMEM;
}
nlh->nlmsg_type = NLMSG_DONE;
-   ret = ibnl_unicast(skb, (struct nlmsghdr *)skb->data, iwpm_pid);
+   ret = rdma_nl_unicast(skb, iwpm_pid);
if (ret)
pr_warn("%s Unable to send a nlmsg\n", __func__);
return ret;
diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 96057e722123..cd29311078b5 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -241,12 +241,11 @@ static void rdma_nl_rcv(struct sk_buff *skb)
mutex_unlock(_nl_mutex);
 }
 
-int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-   __u32 pid)
+int rdma_nl_unicast(struct sk_buff *skb, u32 pid)
 {
return nlmsg_unicast(nls, skb, pid);
 }
-EXPORT_SYMBOL(ibnl_unicast);
+EXPORT_SYMBOL(rdma_nl_unicast);
 
 int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
unsigned int group, gfp_t flags)
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 6932b7acd3a6..9779cd5520d7 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -59,12 +59,10 @@ int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
 /**
  * Send the supplied skb to a specific userspace PID.
  * @skb: The netlink skb
- * @nlh: Header of the netlink message to send
  * @pid: Userspace netlink process ID
  * Returns 0 on success or a negative error code.
  */
-int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-   __u32 pid);
+int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
 
 /**
  * Send the supplied skb to a netlink group.
-- 
2.13.1



[PATCH rdma-next V1 02/19] RDMA/netlink: Simplify the put_msg and put_attr

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

Reuse standard macros to cancel the netlink message
in case of error.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/netlink.c | 31 +--
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index f0d482009c69..96057e722123 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -126,36 +126,23 @@ EXPORT_SYMBOL(rdma_nl_unregister);
 void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
   int len, int client, int op, int flags)
 {
-   unsigned char *prev_tail;
-
-   prev_tail = skb_tail_pointer(skb);
-   *nlh = nlmsg_put(skb, 0, seq, RDMA_NL_GET_TYPE(client, op),
-len, flags);
-   if (!*nlh)
-   goto out_nlmsg_trim;
-   (*nlh)->nlmsg_len = skb_tail_pointer(skb) - prev_tail;
+   *nlh = nlmsg_put(skb, 0, seq, RDMA_NL_GET_TYPE(client, op), len, flags);
+   if (!*nlh) {
+   nlmsg_cancel(skb, *nlh);
+   return NULL;
+   }
return nlmsg_data(*nlh);
-
-out_nlmsg_trim:
-   nlmsg_trim(skb, prev_tail);
-   return NULL;
 }
 EXPORT_SYMBOL(ibnl_put_msg);
 
 int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
  int len, void *data, int type)
 {
-   unsigned char *prev_tail;
-
-   prev_tail = skb_tail_pointer(skb);
-   if (nla_put(skb, type, len, data))
-   goto nla_put_failure;
-   nlh->nlmsg_len += skb_tail_pointer(skb) - prev_tail;
+   if (nla_put(skb, type, len, data)) {
+   nlmsg_cancel(skb, nlh);
+   return -EMSGSIZE;
+   }
return 0;
-
-nla_put_failure:
-   nlmsg_trim(skb, prev_tail - nlh->nlmsg_len);
-   return -EMSGSIZE;
 }
 EXPORT_SYMBOL(ibnl_put_attr);
 
-- 
2.13.1



[PATCH rdma-next V1 01/19] RDMA/netlink: Add flag to consolidate common handing

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

Add ability to provide flags to control RDMA netlink callbacks
and convert addr.c and sa_query.c to be first users of such
infrastructure. It allows to move their CAP_NET_ADMIN checks
into netlink core.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/addr.c |  3 +--
 drivers/infiniband/core/device.c   | 12 +---
 drivers/infiniband/core/netlink.c  |  4 
 drivers/infiniband/core/sa_query.c |  6 ++
 include/rdma/rdma_netlink.h|  6 ++
 5 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 02971e239a18..134d8394fca5 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -134,8 +134,7 @@ int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
 
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
-   !(NETLINK_CB(skb).sk) ||
-   !netlink_capable(skb, CAP_NET_ADMIN))
+   !(NETLINK_CB(skb).sk))
return -EPERM;
 
if (ib_nl_is_good_ip_resp(nlh))
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 5c70ea49d5ad..2001dabd1444 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1010,11 +1010,17 @@ EXPORT_SYMBOL(ib_get_net_dev_by_params);
 
 static const struct ibnl_client_cbs ibnl_ls_cb_table[] = {
[RDMA_NL_LS_OP_RESOLVE] = {
-   .dump = ib_nl_handle_resolve_resp},
+   .dump = ib_nl_handle_resolve_resp,
+   .flags = RDMA_NL_ADMIN_PERM,
+   },
[RDMA_NL_LS_OP_SET_TIMEOUT] = {
-   .dump = ib_nl_handle_set_timeout},
+   .dump = ib_nl_handle_set_timeout,
+   .flags = RDMA_NL_ADMIN_PERM,
+   },
[RDMA_NL_LS_OP_IP_RESOLVE] = {
-   .dump = ib_nl_handle_ip_res_resp},
+   .dump = ib_nl_handle_ip_res_resp,
+   .flags = RDMA_NL_ADMIN_PERM,
+   },
 };
 
 static int __init ib_core_init(void)
diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 4fa6746a62b1..f0d482009c69 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -171,6 +171,10 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct 
nlmsghdr *nlh,
if (!is_nl_valid(index, op))
return -EINVAL;
 
+   if ((rdma_nl_types[index].cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
+   !netlink_capable(skb, CAP_NET_ADMIN))
+   return -EPERM;
+
/*
 * For response or local service set_timeout request,
 * there is no need to use netlink_dump_start.
diff --git a/drivers/infiniband/core/sa_query.c 
b/drivers/infiniband/core/sa_query.c
index e335b09c022e..6e39a763b220 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -1034,8 +1034,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
int ret;
 
if (!(nlh->nlmsg_flags & NLM_F_REQUEST) ||
-   !(NETLINK_CB(skb).sk) ||
-   !netlink_capable(skb, CAP_NET_ADMIN))
+   !(NETLINK_CB(skb).sk))
return -EPERM;
 
ret = nla_parse(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
@@ -1110,8 +1109,7 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb,
int ret;
 
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
-   !(NETLINK_CB(skb).sk) ||
-   !netlink_capable(skb, CAP_NET_ADMIN))
+   !(NETLINK_CB(skb).sk))
return -EPERM;
 
spin_lock_irqsave(_nl_request_lock, flags);
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 761517105a36..6932b7acd3a6 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -7,6 +7,12 @@
 
 struct ibnl_client_cbs {
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
+   u8 flags;
+};
+
+enum rdma_nl_flags {
+   /* Require CAP_NET_ADMIN */
+   RDMA_NL_ADMIN_PERM  = 1 << 0,
 };
 
 int rdma_nl_init(void);
-- 
2.13.1



[PATCH rdma-next V1 00/19] RDMA Netlink Device Client

2017-06-22 Thread Leon Romanovsky
Hi All,

This is second version of the RDMA netlink patch set.

The following patch set is an implementation of NLDEV - RDMA netlink
device client. It is based on the already sent patch [1] and patch set [2].

This client is needed to properly integrate coming RDMAtool [3]
into iproute2 package which is based on netlink.

The following patch set can be logically divided into four parts:
 * Cleanup of RDMA netlink interface to handle dumpit/doit callbacks.
 * Implementation of static ib_device index to allow future renaming support 
for IB devices.
 * NLDEV initial implementation
 * Exposing device and capability masks via this interface

The supplementary user space part will follow later on.

Chagelog:
v0->v1:
 * Added Steve's Reviewed-by tags for all patches except patch #8, because it 
was completely rewritten.
 * Implemented static indexes for ib_device in patch #8 and dropped preview 
version which
   translated device name to corresponding ib_device.
 * Fixed language in commit messages as was pointed by Steve.
 * Rename TODO to be FIXME in patch #11.

Thanks

[1] "Revert "IB/core: Add flow control to the portmapper netlink calls""
 https://patchwork.kernel.org/patch/9752865/

[2] [PATCH rdma-next V2 0/5] Refactor RDMA netlink infrastructure
https://www.spinics.net/lists/linux-rdma/msg50945.html

[3] [RFC iproute2 0/8] RDMA tool
https://www.spinics.net/lists/linux-rdma/msg49575.html

Available in the "topic/rdma-netlink-v1" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git

Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/rdma-netlink-v1

CC: Chien Tin Tung 
CC: Steve Wise 
CC: Stephen Hemminger 
CC: Jason Gunthorpe 
CC: Jiri Pirko 
CC: Ariel Almog 
CC: Linux RDMA 
CC: Linux Netdev 


*** BLURB HERE ***

Leon Romanovsky (19):
  RDMA/netlink: Add flag to consolidate common handing
  RDMA/netlink: Simplify the put_msg and put_attr
  RDMA/netlink: Rename and remove redundant parameter from ibnl_unicast
  RDMA/netlink: Rename and remove redundant parameter from
ibnl_multicast
  RDMA/netlink: Simplify and rename ibnl_chk_listeners
  RDMA/netlink: Rename netlink callback struct
  RDMA/core: Add iterator over ib_devices
  RDMA/core: Add and expose static device index
  RDMA/netlink: Add and implement doit netlink callback
  RDMA/netlink: Reduce indirection access to cb_table
  RDMA/netlink: Convert LS to doit callback
  RDMA/netlink: Update copyright
  RDMA/netlink: Add netlink device definitions to UAPI
  RDMA/netlink: Add nldev initialization flows
  RDMA/netlink: Implement nldev device dumpit calback
  RDMA/netlink: Add nldev device doit implementation
  RDMA/netlink: Add nldev port dumpit implementation
  RDMA/netlink: Implement nldev port doit callback
  RDMA/netlink: Expose device and port capability masks

 drivers/infiniband/core/Makefile|   4 +-
 drivers/infiniband/core/addr.c  |  12 +-
 drivers/infiniband/core/cma.c   |   2 +-
 drivers/infiniband/core/core_priv.h |  21 ++-
 drivers/infiniband/core/device.c|  78 ++-
 drivers/infiniband/core/iwcm.c  |   2 +-
 drivers/infiniband/core/iwpm_msg.c  |   8 +-
 drivers/infiniband/core/iwpm_util.c |   4 +-
 drivers/infiniband/core/netlink.c   |  98 ++---
 drivers/infiniband/core/nldev.c | 271 
 drivers/infiniband/core/sa_query.c  |  18 ++-
 include/rdma/ib_verbs.h |   2 +
 include/rdma/rdma_netlink.h |  22 +--
 include/uapi/rdma/rdma_netlink.h|  44 +-
 14 files changed, 489 insertions(+), 97 deletions(-)
 create mode 100644 drivers/infiniband/core/nldev.c

--
2.13.1



[PATCH rdma-next V1 08/19] RDMA/core: Add and expose static device index

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

This patch adds static device index in similar fashion to
already available in netdev world (struct net->ifindex).

In downstream patches, the RDMA nelink will use this idx-to-ib_device
conversion, so as part of this commit, we are exposing the translation
function to be visible for IB/core users.

Signed-off-by: Leon Romanovsky 
---
 drivers/infiniband/core/core_priv.h |  4 
 drivers/infiniband/core/device.c| 37 -
 include/rdma/ib_verbs.h |  2 ++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/core_priv.h 
b/drivers/infiniband/core/core_priv.h
index 4a150c4be175..291cae284771 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -184,4 +184,8 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
 int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
 struct netlink_callback *cb);
 
+struct ib_device *__ib_device_get_by_index(u32 ifindex);
+/* RDMA device netlink */
+void nldev_init(void);
+void nldev_exit(void);
 #endif /* _CORE_PRIV_H */
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 7a799fc90348..7ff65d766d86 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -124,6 +124,17 @@ static int ib_device_check_mandatory(struct ib_device 
*device)
return 0;
 }
 
+struct ib_device *__ib_device_get_by_index(u32 index)
+{
+   struct ib_device *device;
+
+   list_for_each_entry(device, _list, core_list)
+   if (device->index == index)
+   return device;
+
+   return NULL;
+}
+
 static struct ib_device *__ib_device_get_by_name(const char *name)
 {
struct ib_device *device;
@@ -135,7 +146,6 @@ static struct ib_device *__ib_device_get_by_name(const char 
*name)
return NULL;
 }
 
-
 static int alloc_name(char *name)
 {
unsigned long *inuse;
@@ -326,6 +336,30 @@ void ib_get_device_fw_str(struct ib_device *dev, char 
*str, size_t str_len)
 EXPORT_SYMBOL(ib_get_device_fw_str);
 
 /**
+ * __dev_new_index -   allocate an device index
+ *
+ * Returns a suitable unique value for a new device interface
+ * number.  It assumes that there are less than 2^32-1 ib devices
+ * will be present in the system.
+ */
+static u32 __dev_new_index(void)
+{
+   /*
+* The device index to allow stable naming.
+* Similar to struct net -> ifindex.
+*/
+   static u32 index;
+
+   for (;;) {
+   if (!(++index))
+   index = 1;
+
+   if (!__ib_device_get_by_index(index))
+   return index;
+   }
+}
+
+/**
  * ib_register_device - Register an IB device with IB core
  * @device:Device to register
  *
@@ -417,6 +451,7 @@ int ib_register_device(struct ib_device *device,
if (client->add && !add_client_context(device, client))
client->add(device);
 
+   device->index = __dev_new_index();
down_write(_rwsem);
list_add_tail(>core_list, _list);
up_write(_rwsem);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index ba8314ec5768..b73120727d60 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2237,6 +2237,8 @@ struct ib_device {
struct rdmacg_device cg_device;
 #endif
 
+   u32  index;
+
/**
 * The following mandatory functions are used only at device
 * registration.  Keep functions such as these at the end of this
-- 
2.13.1



[PATCH rdma-next V1 16/19] RDMA/netlink: Add nldev device doit implementation

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

Provide ability to query specific device.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/nldev.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 4b8b0f5d5344..666940f2b49a 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -53,6 +53,45 @@ static int fill_dev_info(struct sk_buff *msg, struct 
ib_device *device)
return 0;
 }
 
+static int nldev_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
+ struct netlink_ext_ack *extack)
+{
+   struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
+   struct ib_device *device;
+   struct sk_buff *msg;
+   u32 index;
+   int err;
+
+   err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
+ nldev_policy, extack);
+   if (err || !tb[RDMA_NLDEV_ATTR_DEV_INDEX])
+   return -EINVAL;
+
+   index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
+
+   device = __ib_device_get_by_index(index);
+   if (!device)
+   return -EINVAL;
+
+   msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+   if (!msg)
+   return -ENOMEM;
+
+   nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
+   RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET),
+   0, 0);
+
+   err = fill_dev_info(msg, device);
+   if (err) {
+   nlmsg_free(msg);
+   return err;
+   }
+
+   nlmsg_end(msg, nlh);
+
+   return rdma_nl_unicast(msg, NETLINK_CB(skb).portid);
+}
+
 static int _nldev_get_dumpit(struct ib_device *device,
 struct sk_buff *skb,
 struct netlink_callback *cb,
@@ -92,6 +131,7 @@ static int nldev_get_dumpit(struct sk_buff *skb, struct 
netlink_callback *cb)
 
 static const struct rdma_nl_cbs nldev_cb_table[] = {
[RDMA_NLDEV_CMD_GET] = {
+   .doit = nldev_get_doit,
.dump = nldev_get_dumpit,
},
 };
-- 
2.13.1



[PATCH rdma-next V1 12/19] RDMA/netlink: Update copyright

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

Add Mellanox to the copyright header.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 103af358ce4e..58b7ec213c59 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2017 Mellanox Technologies Inc.  All rights reserved.
  * Copyright (c) 2010 Voltaire Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
-- 
2.13.1



[PATCH rdma-next V1 13/19] RDMA/netlink: Add netlink device definitions to UAPI

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

Introduce new defines to rdma_netlink.h, so the RDMA configuration tool
will be able to communicate with RDMA subsystem by using the shared defines.

The addition of new client (NLDEV) revealed the fact that we exposed by
mistake the RDMA_NL_I40IW define which is not backed by any RDMA netlink
by now and it won't be exposed in the future too. So this patch reuses
the value and deletes the old defines.

The NLDEV operates with objects. The struct ib_device has two straightforward
objects: device itself and ports of that device.

This brings us to propose the following commands to work on those objects:
 * RDMA_NLDEV_CMD_{GET,SET,NEW,DEL} - works on ib_device itself
 * RDMA_NLDEV_CMD_PORT_{GET,SET,NEW,DEL} - works on ports of specific ib_device

Those commands receive/return the device index (RDMA_NLDEV_ATTR_DEV_INDEX)
and port index (RDMA_NLDEV_ATTR_PORT_INDEX). For device object accesses,
the RDMA_NLDEV_ATTR_PORT_INDEX will return the maximum number of ports
for specific ib_device and for port access the actual port index.

The port index starts from 1 to follow RDMA/core internal semantics and
the sysfs exposed knobs.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/netlink.c |  2 +-
 include/uapi/rdma/rdma_netlink.h  | 39 ++-
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 58b7ec213c59..9b6b9b84f856 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -60,7 +60,7 @@ static bool is_nl_msg_valid(unsigned int type, unsigned int 
op)
  RDMA_NL_IWPM_NUM_OPS,
  0,
  RDMA_NL_LS_NUM_OPS,
- 0 };
+ RDMA_NLDEV_NUM_OPS };
 
/*
 * This BUILD_BUG_ON is intended to catch addition of new
diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h
index 02fe8390c18f..1d064fedfa9a 100644
--- a/include/uapi/rdma/rdma_netlink.h
+++ b/include/uapi/rdma/rdma_netlink.h
@@ -8,7 +8,7 @@ enum {
RDMA_NL_IWCM,
RDMA_NL_RSVD,
RDMA_NL_LS, /* RDMA Local Services */
-   RDMA_NL_I40IW,
+   RDMA_NL_NLDEV,  /* RDMA device interface */
RDMA_NL_NUM_CLIENTS
 };
 
@@ -222,4 +222,41 @@ struct rdma_nla_ls_gid {
__u8gid[16];
 };
 
+enum rdma_nldev_command {
+   RDMA_NLDEV_CMD_UNSPEC,
+
+   RDMA_NLDEV_CMD_GET, /* can dump */
+   RDMA_NLDEV_CMD_SET,
+   RDMA_NLDEV_CMD_NEW,
+   RDMA_NLDEV_CMD_DEL,
+
+   RDMA_NLDEV_CMD_PORT_GET, /* can dump */
+   RDMA_NLDEV_CMD_PORT_SET,
+   RDMA_NLDEV_CMD_PORT_NEW,
+   RDMA_NLDEV_CMD_PORT_DEL,
+
+   RDMA_NLDEV_NUM_OPS
+};
+
+enum rdma_nldev_attr {
+   /* don't change the order or add anything between, this is ABI! */
+   RDMA_NLDEV_ATTR_UNSPEC,
+
+   /* Identifier for ib_device */
+   RDMA_NLDEV_ATTR_DEV_INDEX,  /* u32 */
+
+   RDMA_NLDEV_ATTR_DEV_NAME,   /* string */
+   /*
+* Device index together with port index are identifiers
+* for port/link properties.
+*
+* For RDMA_NLDEV_CMD_GET comamnd, port index will return number
+* of available ports in ib_device, while for port specific operations,
+* it will be real port index as it appears in sysfs. Port index follows
+* sysfs notation and starts from 1 for the first port.
+*/
+   RDMA_NLDEV_ATTR_PORT_INDEX, /* u32 */
+
+   RDMA_NLDEV_ATTR_MAX
+};
 #endif /* _UAPI_RDMA_NETLINK_H */
-- 
2.13.1



[PATCH rdma-next V1 09/19] RDMA/netlink: Add and implement doit netlink callback

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

The .doit callback is used by netlink core to differentiate
between get and set operations. Common convention is to use
that call for command operations like (SET, ADD, e.t.c.) and/or
access without NLF_M_DUMP flag.

This commit adds proper declaration and implementation
to RDMA netlink.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/netlink.c | 19 ++-
 include/rdma/rdma_netlink.h   |  2 ++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 14b64e4d1e06..34f529cc9776 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -75,9 +75,13 @@ static bool is_nl_msg_valid(unsigned int type, unsigned int 
op)
 
 static bool is_nl_valid(unsigned int type, unsigned int op)
 {
-   if (!is_nl_msg_valid(type, op) ||
-   !rdma_nl_types[type].cb_table ||
-   !rdma_nl_types[type].cb_table[op].dump)
+   const struct rdma_nl_cbs *cb_table;
+
+   if (!is_nl_msg_valid(type, op))
+   return false;
+
+   cb_table = rdma_nl_types[type].cb_table;
+   if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit))
return false;
return true;
 }
@@ -152,6 +156,7 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct 
nlmsghdr *nlh,
unsigned int op = RDMA_NL_GET_OP(type);
struct netlink_callback cb = {};
struct netlink_dump_control c = {};
+   int ret;
 
if (!is_nl_valid(index, op))
return -EINVAL;
@@ -170,10 +175,14 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct 
nlmsghdr *nlh,
cb.nlh = nlh;
cb.dump = rdma_nl_types[index].cb_table[op].dump;
return cb.dump(skb, );
+   } else {
+   c.dump = rdma_nl_types[index].cb_table[op].dump;
+   return netlink_dump_start(nls, skb, nlh, );
}
+   if (rdma_nl_types[index].cb_table[op].doit)
+   ret = rdma_nl_types[index].cb_table[op].doit(skb, nlh, extack);
+   return ret;
 
-   c.dump = rdma_nl_types[index].cb_table[op].dump;
-   return netlink_dump_start(nls, skb, nlh, );
 }
 
 /*
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 8feeb899e2b2..d6a481880f41 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -6,6 +6,8 @@
 #include 
 
 struct rdma_nl_cbs {
+   int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh,
+   struct netlink_ext_ack *extack);
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
u8 flags;
 };
-- 
2.13.1



[PATCH rdma-next V1 06/19] RDMA/netlink: Rename netlink callback struct

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

The RDMA netlink client infrastructure was removed and made
obsolete the old name (ibnl_client_cbs). This patch renames
to the more appropriate name (rdma_nl_cbs).

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/cma.c | 2 +-
 drivers/infiniband/core/device.c  | 2 +-
 drivers/infiniband/core/iwcm.c| 2 +-
 drivers/infiniband/core/netlink.c | 4 ++--
 include/rdma/rdma_netlink.h   | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index a4013b0908e2..2af30a19b926 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4477,7 +4477,7 @@ static int cma_get_id_stats(struct sk_buff *skb, struct 
netlink_callback *cb)
return skb->len;
 }
 
-static const struct ibnl_client_cbs cma_cb_table[] = {
+static const struct rdma_nl_cbs cma_cb_table[] = {
[RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats},
 };
 
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 2001dabd1444..5326dcc6ede7 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -1008,7 +1008,7 @@ struct net_device *ib_get_net_dev_by_params(struct 
ib_device *dev,
 }
 EXPORT_SYMBOL(ib_get_net_dev_by_params);
 
-static const struct ibnl_client_cbs ibnl_ls_cb_table[] = {
+static const struct rdma_nl_cbs ibnl_ls_cb_table[] = {
[RDMA_NL_LS_OP_RESOLVE] = {
.dump = ib_nl_handle_resolve_resp,
.flags = RDMA_NL_ADMIN_PERM,
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 8599271d8be6..452a3115e3e6 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -80,7 +80,7 @@ const char *__attribute_const__ iwcm_reject_msg(int reason)
 }
 EXPORT_SYMBOL(iwcm_reject_msg);
 
-static struct ibnl_client_cbs iwcm_nl_cb_table[] = {
+static struct rdma_nl_cbs iwcm_nl_cb_table[] = {
[RDMA_NL_IWPM_REG_PID] = {.dump = iwpm_register_pid_cb},
[RDMA_NL_IWPM_ADD_MAPPING] = {.dump = iwpm_add_mapping_cb},
[RDMA_NL_IWPM_QUERY_MAPPING] = {.dump = iwpm_add_and_query_mapping_cb},
diff --git a/drivers/infiniband/core/netlink.c 
b/drivers/infiniband/core/netlink.c
index 1022ce6628ae..14b64e4d1e06 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -43,7 +43,7 @@
 static DEFINE_MUTEX(rdma_nl_mutex);
 static struct sock *nls;
 static struct {
-   const struct ibnl_client_cbs   *cb_table;
+   const struct rdma_nl_cbs   *cb_table;
 } rdma_nl_types[RDMA_NL_NUM_CLIENTS];
 
 int rdma_nl_chk_listeners(unsigned int group)
@@ -83,7 +83,7 @@ static bool is_nl_valid(unsigned int type, unsigned int op)
 }
 
 void rdma_nl_register(unsigned int index,
- const struct ibnl_client_cbs cb_table[])
+ const struct rdma_nl_cbs cb_table[])
 {
mutex_lock(_nl_mutex);
if (!is_nl_msg_valid(index, 0)) {
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index b39e030b3a64..8feeb899e2b2 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -5,7 +5,7 @@
 #include 
 #include 
 
-struct ibnl_client_cbs {
+struct rdma_nl_cbs {
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
u8 flags;
 };
@@ -24,7 +24,7 @@ void rdma_nl_exit(void);
  * @cb_table: A table for op->callback
  */
 void rdma_nl_register(unsigned int index,
- const struct ibnl_client_cbs cb_table[]);
+ const struct rdma_nl_cbs cb_table[]);
 
 /**
  * Remove a client from IB netlink.
-- 
2.13.1



[PATCH rdma-next V1 15/19] RDMA/netlink: Implement nldev device dumpit calback

2017-06-22 Thread Leon Romanovsky
From: Leon Romanovsky 

This patch adds the ability to return all available devices
together with their properties.

Signed-off-by: Leon Romanovsky 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/nldev.c | 64 -
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 1d1e4f214874..4b8b0f5d5344 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -30,13 +30,75 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include 
 #include 
 
 #include "core_priv.h"
 
+static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
+   [RDMA_NLDEV_ATTR_DEV_INDEX] = { .type = NLA_U32 },
+   [RDMA_NLDEV_ATTR_DEV_NAME]  = { .type = NLA_NUL_STRING,
+   .len = IB_DEVICE_NAME_MAX - 1},
+   [RDMA_NLDEV_ATTR_PORT_INDEX]= { .type = NLA_U32 },
+};
+
+static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
+{
+   if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index))
+   return -EMSGSIZE;
+   if (nla_put_string(msg, RDMA_NLDEV_ATTR_DEV_NAME, device->name))
+   return -EMSGSIZE;
+   if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, rdma_end_port(device)))
+   return -EMSGSIZE;
+   return 0;
+}
+
+static int _nldev_get_dumpit(struct ib_device *device,
+struct sk_buff *skb,
+struct netlink_callback *cb,
+unsigned int idx)
+{
+   int start = cb->args[0];
+   struct nlmsghdr *nlh;
+
+   if (idx < start)
+   return 0;
+
+   nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
+   RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET),
+   0, NLM_F_MULTI);
+
+   if (fill_dev_info(skb, device)) {
+   nlmsg_cancel(skb, nlh);
+   goto out;
+   }
+
+   nlmsg_end(skb, nlh);
+
+   idx++;
+
+out:   cb->args[0] = idx;
+   return skb->len;
+}
+
+static int nldev_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
+{
+   /*
+* There is no need to take lock, because
+* we are relying on ib_core's lists_rwsem
+*/
+   return ib_enum_all_devs(_nldev_get_dumpit, skb, cb);
+}
+
+static const struct rdma_nl_cbs nldev_cb_table[] = {
+   [RDMA_NLDEV_CMD_GET] = {
+   .dump = nldev_get_dumpit,
+   },
+};
+
 void __init nldev_init(void)
 {
-   rdma_nl_register(RDMA_NL_NLDEV, NULL);
+   rdma_nl_register(RDMA_NL_NLDEV, nldev_cb_table);
 }
 
 void __exit nldev_exit(void)
-- 
2.13.1



Re: [PATCH net-next v2 00/12] nfp: add flower app with representors

2017-06-22 Thread Or Gerlitz
On Wed, Jun 21, 2017 at 10:40 PM, David Miller  wrote:
>
> Simon it looks like Or has some more questions about how these
> representers will work and operate.
>
> So I'm going to mark this series as "deferred" in patchwork while
> you two sort out that conversation.


Hi Dave,

Jakub and Simon provided answers for the questions on the general
architecture of the framework, how things are configured and how it
will work for more use-cases, seems very well done.

FWIW, I posted now two point comments on V2, I guess we can continue the review
from there, but this is on much more concrete matters.

Or.


Re: [PATCH] liquidio: stop using huge static buffer, save 4096k in .data

2017-06-22 Thread David Miller
From: Denys Vlasenko 
Date: Mon, 19 Jun 2017 21:50:52 +0200

> Only compile-tested - I don't have the hardware.
> 
> From code inspection, octeon_pci_write_core_mem() appears to be safe wrt
> unaligned source. In any case, u8 fbuf[] was not guaranteed to be aligned
> anyway.
> 
> Signed-off-by: Denys Vlasenko 

Applied to net-next, thanks.


Re: [PATCH v2] net/mlx5e: Use device ID defines

2017-06-22 Thread David Miller
From: Myron Stowe 
Date: Tue, 20 Jun 2017 11:21:26 -0600

> Use Mellanox device ID definitions in the driver's mlx5 ID table so tools
> such as 'grep' and 'cscope' can be used to help find correlated material
> (such as INTx Masking quirks: d76d2fe05fd PCI: Convert Mellanox broken
> INTx quirks to be for listed devices only).
> 
> No functional change intended.
> 
> Signed-off-by: Myron Stowe 

Applied to net-next, thanks.


Re: [Patch net] ipv6: only call ip6_route_dev_notify() once for NETDEV_UNREGISTER

2017-06-22 Thread David Miller
From: Cong Wang 
Date: Tue, 20 Jun 2017 11:42:27 -0700

> In commit 242d3a49a2a1 ("ipv6: reorder ip6_route_dev_notifier after 
> ipv6_dev_notf")
> I assumed NETDEV_REGISTER and NETDEV_UNREGISTER are paired,
> unfortunately, as reported by jeffy, netdev_wait_allrefs()
> could rebroadcast NETDEV_UNREGISTER event until all refs are
> gone.
> 
> We have to add an additional check to avoid this corner case.
> For netdev_wait_allrefs() dev->reg_state is NETREG_UNREGISTERED,
> for dev_change_net_namespace(), dev->reg_state is
> NETREG_REGISTERED. So check for dev->reg_state != NETREG_UNREGISTERED.
> 
> Fixes: 242d3a49a2a1 ("ipv6: reorder ip6_route_dev_notifier after 
> ipv6_dev_notf")
> Reported-by: jeffy 
> Cc: David Ahern 
> Signed-off-by: Cong Wang 

Applied.


Re: [PATCH v2] net/phy: micrel: configure intterupts after autoneg workaround

2017-06-22 Thread David Miller
From: Zach Brown 
Date: Tue, 20 Jun 2017 12:48:11 -0500

> The commit ("net/phy: micrel: Add workaround for bad autoneg") fixes an
> autoneg failure case by resetting the hardware. This turns off
> intterupts. Things will work themselves out if the phy polls, as it will
> figure out it's state during a poll. However if the phy uses only
> intterupts, the phy will stall, since interrupts are off. This patch
> fixes the issue by calling config_intr after resetting the phy.
> 
> Fixes: d2fd719bcb0e ("net/phy: micrel: Add workaround for bad autoneg ")
> Signed-off-by: Zach Brown 

Applied and queued up for -stable.


Re: [PATCH] net: phy: smsc: fix buffer overflow in memcpy

2017-06-22 Thread David Miller
From: Arnd Bergmann 
Date: Tue, 20 Jun 2017 22:40:46 +0200

> The memcpy annotation triggers for a fixed-length buffer copy:
> 
> In file included from /git/arm-soc/arch/arm64/include/asm/processor.h:30:0,
>  from /git/arm-soc/arch/arm64/include/asm/spinlock.h:21,
>  from /git/arm-soc/include/linux/spinlock.h:87,
>  from /git/arm-soc/include/linux/seqlock.h:35,
>  from /git/arm-soc/include/linux/time.h:5,
>  from /git/arm-soc/include/linux/stat.h:21,
>  from /git/arm-soc/include/linux/module.h:10,
>  from /git/arm-soc/drivers/net/phy/smsc.c:20:
> In function 'memcpy',
> inlined from 'smsc_get_strings' at 
> /git/arm-soc/drivers/net/phy/smsc.c:166:3:
> /git/arm-soc/include/linux/string.h:309:4: error: call to '__read_overflow2' 
> declared with attribute error: detected read beyond size of object passed as 
> 2nd parameter
> 
> Using strncpy instead of memcpy should do the right thing here.
> 
> Fixes: 030a89028db0 ("net: phy: smsc: Implement PHY statistics")
> Signed-off-by: Arnd Bergmann 

APplied to net-next, thanks Arnd.


Re: [PATCH net-next] Add a tcp_filter hook before handle ack packet

2017-06-22 Thread David Miller
From: Chenbo Feng 
Date: Tue, 20 Jun 2017 19:06:40 -0700

> From: Chenbo Feng 
> 
> Currently in both ipv4 and ipv6 code path, the ack packet received when
> sk at TCP_NEW_SYN_RECV state is not filtered by socket filter or cgroup
> filter since it is handled from tcp_child_process and never reaches the
> tcp_filter inside tcp_v4_rcv or tcp_v6_rcv. Adding a tcp_filter hooks
> here can make sure all the ingress tcp packet can be correctly filtered.
> 
> Signed-off-by: Chenbo Feng 

Applied, thanks.


Re: [PATCH] drivers: net: cpsw-common: Fix reading of mac address for am43 SoCs

2017-06-22 Thread David Miller
From: Lokesh Vutla 
Date: Wed, 21 Jun 2017 14:12:04 +0530

> cpsw driver tries to get macid for am43xx SoCs using the compatible
> ti,am4372. But not all variants of am43x uses this complatible like
> epos evm uses ti,am438x. So use a generic compatible ti,am43 to get
> macid for all am43 based platforms.
> 
> Reviewed-by: Dave Gerlach 
> Signed-off-by: Lokesh Vutla 

Applied.


Re: veth: Be more robust on network device creation when no attributes

2017-06-22 Thread David Miller
From: Serhey Popovych 
Date: Wed, 21 Jun 2017 12:12:24 +0300

> There are number of problems with configuration peer
> network device in absence of IFLA_VETH_PEER attributes
> where attributes for main network device shared with
> peer.
> 
> First it is not feasible to configure both network
> devices with same MAC address since this makes
> communication in such configuration problematic.
> 
> This case can be reproduced with following sequence:
> 
>   # ip link add address 02:11:22:33:44:55 type veth
>   # ip li sh
>   ...
>   26: veth0@veth1:  mtu 1500 qdisc \
>   noop state DOWN mode DEFAULT qlen 1000
>   link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
>   27: veth1@veth0:  mtu 1500 qdisc \
>   noop state DOWN mode DEFAULT qlen 1000
>   link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
> 
> Second it is not possible to register both main and
> peer network devices with same name, that happens
> when name for main interface is given with IFLA_IFNAME
> and same attribute reused for peer.
> 
> This case can be reproduced with following sequence:
> 
>   # ip link add dev veth1a type veth
>   RTNETLINK answers: File exists
> 
> To fix both of the cases check if corresponding netlink
> attributes are taken from peer_tb when valid or
> name based on rtnl ops kind and random address is used.
> 
> Signed-off-by: Serhey Popovych 

Applied.


Re: [PATCH net] xen-netback: correctly schedule rate-limited queues

2017-06-22 Thread David Miller
From: Wei Liu 
Date: Wed, 21 Jun 2017 10:21:22 +0100

> Add a flag to indicate if a queue is rate-limited. Test the flag in
> NAPI poll handler and avoid rescheduling the queue if true, otherwise
> we risk locking up the host. The rescheduling will be done in the
> timer callback function.
> 
> Reported-by: Jean-Louis Dupond 
> Signed-off-by: Wei Liu 
> Tested-by: Jean-Louis Dupond 

Applied.


Re: [PATCH] of: update ePAPR references to point to Devicetree Specification

2017-06-22 Thread Rob Herring
On Mon, Jun 19, 2017 at 03:23:41AM -0700, Frank Rowand wrote:
> On 06/18/17 07:05, Rob Herring wrote:
> > On Tue, Jun 13, 2017 at 07:49:04PM -0700, frowand.l...@gmail.com wrote:
> >> From: Frank Rowand 
> >>
> >> The Devicetree Specification has superseded the ePAPR as the
> >> base specification for bindings.  Update files in Documentation
> >> to reference the new document.
> >>
> >> Some files are not updated because there is no hypervisor chapter
> >> in the Devicetree Specification:
> >>Documentation/devicetree/bindings/powerpc/fsl/msi-pic.txt
> >>Documenation/virtual/kvm/api.txt
> >>Documenation/virtual/kvm/ppc-pv.txt

> >> diff --git a/Documentation/devicetree/bindings/powerpc/fsl/cpus.txt 
> >> b/Documentation/devicetree/bindings/powerpc/fsl/cpus.txt
> >> index f8cd2397aa04..d63ab1dec16d 100644
> >> --- a/Documentation/devicetree/bindings/powerpc/fsl/cpus.txt
> >> +++ b/Documentation/devicetree/bindings/powerpc/fsl/cpus.txt
> >> @@ -3,10 +3,10 @@ Power Architecture CPU Binding
> >>  Copyright 2013 Freescale Semiconductor Inc.
> >>  
> >>  Power Architecture CPUs in Freescale SOCs are represented in device trees 
> >> as
> >> -per the definition in ePAPR.
> >> +per the definition in the Devicetree Specification.
> > 
> > Are we sure we didn't remove any PPC specifics that apply here?
> 
> I don't see any.
> 
> Table 3.7.1 "General Properties of CPU nodes" was slightly
> re-ordered, but the same properties are listed in both documents.
> 
> I don't think that the boot requirements removal impacts this
> file.
> 
> Am I missing something?

No, I just wanted to make sure. So I guess there's just that one minor 
thing to drop.

Rob


Re: [PATCH V2 net 0/4] macvlan: Fix some issues with changing mac addresses

2017-06-22 Thread David Miller
From: Vladislav Yasevich 
Date: Wed, 21 Jun 2017 07:59:15 -0400

> There are some issues in macvlan wrt to changing it's mac address.
> * An error is returned in the specified address is the same as an already
>   assigned address.
> * In passthru mode, the mac address of the macvlan device doesn't change.
> * After changing the mac address of a passthru macvlan and then removing it,
>   the mac address of the physical device remains changed.
> 
> This patch series attempts to resolve these issues.
> 
> V2: Address a small issue in p4 where we save the address from the lowerdev
> (from girish.moodalb...@oracle.com)

Series applied, thanks.


[PATCH] net: stmmac: make some functions static

2017-06-22 Thread Colin King
From: Colin Ian King 

The functions dwmac4_dma_init_rx_chan, dwmac4_dma_init_tx_chan and
dwmac4_dma_init_channel do not need to be in global scope, so them
static.

Cleans up sparse warnings:
"symbol 'dwmac4_dma_init_rx_chan' was not declared. Should it be static?"
"symbol 'dwmac4_dma_init_tx_chan' was not declared. Should it be static?"
"symbol 'dwmac4_dma_init_channel' was not declared. Should it be static?"

Signed-off-by: Colin Ian King 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index eec8463057fd..e84831e1b63b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -71,9 +71,9 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct 
stmmac_axi *axi)
writel(value, ioaddr + DMA_SYS_BUS_MODE);
 }
 
-void dwmac4_dma_init_rx_chan(void __iomem *ioaddr,
-struct stmmac_dma_cfg *dma_cfg,
-u32 dma_rx_phy, u32 chan)
+static void dwmac4_dma_init_rx_chan(void __iomem *ioaddr,
+   struct stmmac_dma_cfg *dma_cfg,
+   u32 dma_rx_phy, u32 chan)
 {
u32 value;
u32 rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;
@@ -85,9 +85,9 @@ void dwmac4_dma_init_rx_chan(void __iomem *ioaddr,
writel(dma_rx_phy, ioaddr + DMA_CHAN_RX_BASE_ADDR(chan));
 }
 
-void dwmac4_dma_init_tx_chan(void __iomem *ioaddr,
-struct stmmac_dma_cfg *dma_cfg,
-u32 dma_tx_phy, u32 chan)
+static void dwmac4_dma_init_tx_chan(void __iomem *ioaddr,
+   struct stmmac_dma_cfg *dma_cfg,
+   u32 dma_tx_phy, u32 chan)
 {
u32 value;
u32 txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;
@@ -99,8 +99,8 @@ void dwmac4_dma_init_tx_chan(void __iomem *ioaddr,
writel(dma_tx_phy, ioaddr + DMA_CHAN_TX_BASE_ADDR(chan));
 }
 
-void dwmac4_dma_init_channel(void __iomem *ioaddr,
-struct stmmac_dma_cfg *dma_cfg, u32 chan)
+static void dwmac4_dma_init_channel(void __iomem *ioaddr,
+   struct stmmac_dma_cfg *dma_cfg, u32 chan)
 {
u32 value;
 
-- 
2.11.0



Re: [PATCH net-next v3 03/13] sock: add MSG_ZEROCOPY

2017-06-22 Thread David Miller
From: Willem de Bruijn 
Date: Wed, 21 Jun 2017 17:18:06 -0400

> +struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size)
> +{
> + struct sk_buff *skb;
> + struct ubuf_info *uarg;

Reverse christmas tree.

> +void sock_zerocopy_callback(struct ubuf_info *uarg, bool success)
> +{
> + struct sock_exterr_skb *serr;
> + struct sk_buff *skb = skb_from_uarg(uarg);
> + struct sock *sk = skb->sk;
> + u16 id = uarg->desc;

Likewise.


[PATCH v3 08/11] brcmsmac: make some local variables 'static const' to reduce stack size

2017-06-22 Thread Arnd Bergmann
With KASAN and a couple of other patches applied, this driver is one
of the few remaining ones that actually use more than 2048 bytes of
kernel stack:

broadcom/brcm80211/brcmsmac/phy/phy_n.c: In function 
'wlc_phy_workarounds_nphy_gainctrl':
broadcom/brcm80211/brcmsmac/phy/phy_n.c:16065:1: warning: the frame size of 
3264 bytes is larger than 2048 bytes [-Wframe-larger-than=]
broadcom/brcm80211/brcmsmac/phy/phy_n.c: In function 'wlc_phy_workarounds_nphy':
broadcom/brcm80211/brcmsmac/phy/phy_n.c:17138:1: warning: the frame size of 
2864 bytes is larger than 2048 bytes [-Wframe-larger-than=]

Here, I'm reducing the stack size by marking as many local variables as
'static const' as I can without changing the actual code.

Acked-by: Arend van Spriel 
Signed-off-by: Arnd Bergmann 
---
 .../broadcom/brcm80211/brcmsmac/phy/phy_n.c| 197 ++---
 1 file changed, 97 insertions(+), 100 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
index b3aab2fe96eb..ef685465f80a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
@@ -14764,8 +14764,8 @@ static void 
wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi)
 }
 
 static void
-wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys,
-  u8 len)
+wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, const u8 *events,
+  const u8 *dlys, u8 len)
 {
u32 t1_offset, t2_offset;
u8 ctr;
@@ -15240,16 +15240,16 @@ static void 
wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi)
 static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
 {
u16 currband;
-   s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };
-   s8 *lna1_gain_db = NULL;
-   s8 *lna1_gain_db_2 = NULL;
-   s8 *lna2_gain_db = NULL;
-   s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 };
-   s8 *tia_gain_db;
-   s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };
-   s8 *tia_gainbits;
-   u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };
-   u16 *rfseq_init_gain;
+   static const s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };
+   const s8 *lna1_gain_db = NULL;
+   const s8 *lna1_gain_db_2 = NULL;
+   const s8 *lna2_gain_db = NULL;
+   static const s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 
};
+   const s8 *tia_gain_db;
+   static const s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };
+   const s8 *tia_gainbits;
+   static const u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };
+   const u16 *rfseq_init_gain;
u16 init_gaincode;
u16 clip1hi_gaincode;
u16 clip1md_gaincode = 0;
@@ -15310,10 +15310,9 @@ static void 
wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
 
if ((freq <= 5080) || (freq == 5825)) {
 
-   s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 };
-   s8 lna1A_gain_db_2_rev7[] = {
-   11, 17, 22, 25};
-   s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
+   static const s8 lna1A_gain_db_rev7[] = { 11, 
16, 20, 24 };
+   static const s8 lna1A_gain_db_2_rev7[] = { 11, 
17, 22, 25};
+   static const s8 lna2A_gain_db_rev7[] = { -1, 6, 
10, 14 };
 
crsminu_th = 0x3e;
lna1_gain_db = lna1A_gain_db_rev7;
@@ -15321,10 +15320,9 @@ static void 
wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
lna2_gain_db = lna2A_gain_db_rev7;
} else if ((freq >= 5500) && (freq <= 5700)) {
 
-   s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 };
-   s8 lna1A_gain_db_2_rev7[] = {
-   12, 18, 22, 26};
-   s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
+   static const s8 lna1A_gain_db_rev7[] = { 11, 
17, 21, 25 };
+   static const s8 lna1A_gain_db_2_rev7[] = { 12, 
18, 22, 26};
+   static const s8 lna2A_gain_db_rev7[] = { 1, 8, 
12, 16 };
 
crsminu_th = 0x45;
clip1md_gaincode_B = 0x14;
@@ -15335,10 +15333,9 @@ static void 
wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
lna2_gain_db = lna2A_gain_db_rev7;
} else {
 
-   s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 };
-   s8 

[PATCH v3 03/11] rocker: mark rocker_tlv_put_* functions as noinline_if_stackbloat

2017-06-22 Thread Arnd Bergmann
Inlining these functions creates lots of stack variables when KASAN is
enabled, leading to this warning about potential stack overflow:

drivers/net/ethernet/rocker/rocker_ofdpa.c: In function 
'ofdpa_cmd_flow_tbl_add':
drivers/net/ethernet/rocker/rocker_ofdpa.c:621:1: error: the frame size of 2752 
bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

This marks all of them noinline_if_stackbloat, which solves the problem by
keeping the redzone inside of the separate stack frames.

Signed-off-by: Arnd Bergmann 
---
 drivers/net/ethernet/rocker/rocker_tlv.h | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker_tlv.h 
b/drivers/net/ethernet/rocker/rocker_tlv.h
index a63ef82e7c72..8970a414eb5b 100644
--- a/drivers/net/ethernet/rocker/rocker_tlv.h
+++ b/drivers/net/ethernet/rocker/rocker_tlv.h
@@ -139,38 +139,38 @@ rocker_tlv_start(struct rocker_desc_info *desc_info)
 int rocker_tlv_put(struct rocker_desc_info *desc_info,
   int attrtype, int attrlen, const void *data);
 
-static inline int rocker_tlv_put_u8(struct rocker_desc_info *desc_info,
-   int attrtype, u8 value)
+static noinline_if_stackbloat int
+rocker_tlv_put_u8(struct rocker_desc_info *desc_info, int attrtype, u8 value)
 {
return rocker_tlv_put(desc_info, attrtype, sizeof(u8), );
 }
 
-static inline int rocker_tlv_put_u16(struct rocker_desc_info *desc_info,
-int attrtype, u16 value)
+static noinline_if_stackbloat int
+rocker_tlv_put_u16(struct rocker_desc_info *desc_info, int attrtype, u16 value)
 {
return rocker_tlv_put(desc_info, attrtype, sizeof(u16), );
 }
 
-static inline int rocker_tlv_put_be16(struct rocker_desc_info *desc_info,
- int attrtype, __be16 value)
+static noinline_if_stackbloat int
+rocker_tlv_put_be16(struct rocker_desc_info *desc_info, int attrtype, __be16 
value)
 {
return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), );
 }
 
-static inline int rocker_tlv_put_u32(struct rocker_desc_info *desc_info,
-int attrtype, u32 value)
+static noinline_if_stackbloat int
+rocker_tlv_put_u32(struct rocker_desc_info *desc_info, int attrtype, u32 value)
 {
return rocker_tlv_put(desc_info, attrtype, sizeof(u32), );
 }
 
-static inline int rocker_tlv_put_be32(struct rocker_desc_info *desc_info,
- int attrtype, __be32 value)
+static noinline_if_stackbloat int
+rocker_tlv_put_be32(struct rocker_desc_info *desc_info, int attrtype, __be32 
value)
 {
return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), );
 }
 
-static inline int rocker_tlv_put_u64(struct rocker_desc_info *desc_info,
-int attrtype, u64 value)
+static noinline_if_stackbloat int
+rocker_tlv_put_u64(struct rocker_desc_info *desc_info, int attrtype, u64 value)
 {
return rocker_tlv_put(desc_info, attrtype, sizeof(u64), );
 }
-- 
2.9.0



[PATCH v3 06/11] r820t: mark register functions as noinline_if_stackbloat

2017-06-22 Thread Arnd Bergmann
With KASAN, we get an overly long stack frame due to inlining
the register access function:

drivers/media/tuners/r820t.c: In function 'generic_set_freq.isra.7':
drivers/media/tuners/r820t.c:1334:1: error: the frame size of 2880 bytes is 
larger than 2048 bytes [-Werror=frame-larger-than=]

An earlier patch I tried used an open-coded r820t_write_reg()
implementation that may have been more efficent, while this
version simply adds the annotation, which has a lower risk for
regressions.

Signed-off-by: Arnd Bergmann 
---
 drivers/media/tuners/r820t.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index ba80376a3b86..a26d0eb64555 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -396,7 +396,7 @@ static int r820t_write(struct r820t_priv *priv, u8 reg, 
const u8 *val,
return 0;
 }
 
-static int r820t_write_reg(struct r820t_priv *priv, u8 reg, u8 val)
+static noinline_if_stackbloat int r820t_write_reg(struct r820t_priv *priv, u8 
reg, u8 val)
 {
return r820t_write(priv, reg, , 1);
 }
@@ -411,7 +411,7 @@ static int r820t_read_cache_reg(struct r820t_priv *priv, 
int reg)
return -EINVAL;
 }
 
-static int r820t_write_reg_mask(struct r820t_priv *priv, u8 reg, u8 val,
+static noinline_if_stackbloat int r820t_write_reg_mask(struct r820t_priv 
*priv, u8 reg, u8 val,
u8 bit_mask)
 {
int rc = r820t_read_cache_reg(priv, reg);
-- 
2.9.0



Re: [Patch net] ipv6: avoid unregistering inet6_dev for loopback

2017-06-22 Thread David Miller
From: Cong Wang 
Date: Wed, 21 Jun 2017 14:34:58 -0700

> The per netns loopback_dev->ip6_ptr is unregistered and set to
> NULL when its mtu is set to smaller than IPV6_MIN_MTU, this
> leads to that we could set rt->rt6i_idev NULL after a
> rt6_uncached_list_flush_dev() and then crash after another
> call.
> 
> In this case we should just bring its inet6_dev down, rather
> than unregistering it, at least prior to commit 176c39af29bc
> ("netns: fix addrconf_ifdown kernel panic") we always
> override the case for loopback.
> 
> Thanks a lot to Andrey for finding a reliable reproducer.
> 
> Fixes: 176c39af29bc ("netns: fix addrconf_ifdown kernel panic")
> Reported-by: Andrey Konovalov 
> Cc: Andrey Konovalov 
> Cc: Daniel Lezcano 
> Cc: David Ahern 
> Signed-off-by: Cong Wang 

Applied and queued up for -stable.


Re: [PATCH net-next] udp/v6: prefetch rmem_alloc in udp6_queue_rcv_skb()

2017-06-22 Thread Paolo Abeni
On Thu, 2017-06-22 at 13:44 -0400, David Miller wrote:
> From: Paolo Abeni 
> Date: Thu, 22 Jun 2017 15:01:22 +0200
> 
> > very similar to commit dd99e425be23 ("udp: prefetch
> > rmem_alloc in udp_queue_rcv_skb()"), this allows saving a cache
> > miss when the BH is bottle-neck for UDP over ipv6 packet
> > processing, e.g. for small packets when a single RX NIC ingress
> > queue is in use.
> > 
> > Performances under flood when multiple NIC RX queues used are
> > unaffected, but when a single NIC rx queue is in use, this
> > gives ~8% performance improvement.
> > 
> > Signed-off-by: Paolo Abeni 
> 
> Applied but please look into that DNS lookup regression which was
> reported today.

Sure! I'm on it right now.

Cheers,

Paolo


Re: [PATCH v2 net] udpv6: reset daddr and dport in sk if connect() fails

2017-06-22 Thread Maciej Żenczykowski
So this is clearly an improvement over the current state of things.

However, I think there is still a very slight race condition in the
error case, since I imagine udp early demux might find the socket
while ip6_datagram_dst_update() is running.

It's possible that inet_dport assignment could simply be postponed
until after the ip6_datagram_dst_update() call.

Another possibility would be to make the early demux code only capable
of finding TCP_ESTABLISHED sockets.

That said, I'm not sure what the right call would be.


Re: DNS (?) not working on G5 (64-bit powerpc) (was [net-next,v3,3/3] udp: try to avoid 2 cache miss on dequeue)

2017-06-22 Thread Paolo Abeni
On Thu, 2017-06-22 at 23:06 +1000, Michael Ellerman wrote:
> Paolo wrote:
> > when udp_recvmsg() is executed, on x86_64 and other archs, most skb
> > fields are on cold cachelines.
> > If the skb are linear and the kernel don't need to compute the udp
> > csum, only a handful of skb fields are required by udp_recvmsg().
> > Since we already use skb->dev_scratch to cache hot data, and
> > there are 32 bits unused on 64 bit archs, use such field to cache
> > as much data as we can, and try to prefetch on dequeue the relevant
> > fields that are left out.
> > 
> > This can save up to 2 cache miss per packet.
> > 
> > v1 -> v2:
> >   - changed udp_dev_scratch fields types to u{32,16} variant,
> > replaced bitfiled with bool
> > 
> > Signed-off-by: Paolo Abeni 
> > Acked-by: Eric Dumazet 
> > ---
> >  net/ipv4/udp.c | 114 
> > +++--
> >  1 file changed, 103 insertions(+), 11 deletions(-)
> 
> This appears to break wget on one of my machines.
> 
> Networking in general is working, I'm able to SSH in, but then I can't
> do a wget.
> 
> eg:
> 
> $ wget google.com
> --2017-06-22 22:45:39--  http://google.com/
> Resolving proxy.pmdw.com (proxy.pmdw.com)... failed: Temporary failure in 
> name resolution.
> wget: unable to resolve host address ‘proxy.pmdw.com’
> 
> $ host proxy.pmdw.com
> proxy.pmdw.com is an alias for raven.pmdw.com.
> raven.pmdw.com has address 10.1.2.3
> 
> $ wget google.com
> --2017-06-22 22:52:08--  http://google.com/
> Resolving proxy.pmdw.com (proxy.pmdw.com)... failed: Temporary failure in 
> name resolution.
> wget: unable to resolve host address ‘proxy.pmdw.com’
> 
> Maybe host is using TCP but the man page says it doesn't?
> 
> 
> Everything is OK if I boot back to the previous commit 0a463c78d25b
> ("udp: avoid a cache miss on dequeue"):
> 
> $ wget google.com
> --2017-06-22 23:00:01--  http://google.com/
> Resolving proxy.pmdw.com (proxy.pmdw.com)... 10.1.2.3
> Connecting to proxy.pmdw.com (proxy.pmdw.com)|10.1.2.3|:3128... connected.
> Proxy request sent, awaiting response... 302 Found
> Location: http://www.google.com.au/?gfe_rd=cr=Ub9LWbPbLujDXrH1uPgE 
> [following]
> --2017-06-22 23:00:01--  
> http://www.google.com.au/?gfe_rd=cr=Ub9LWbPbLujDXrH1uPgE
> Reusing existing connection to proxy.pmdw.com:3128.
> Proxy request sent, awaiting response... 200 OK
> Length: unspecified [text/html]
> Saving to: ‘index.html’
> 
> index.html  [ <=>   ] 
>  11.37K  --.-KB/sin 0.001s  
> 
> 2017-06-22 23:00:01 (22.0 MB/s) - ‘index.html’ saved [11640]
> 
> $ uname -a
> Linux 4.12.0-rc4-gcc6-00988-g0a463c7 #88 SMP Thu Jun 22 22:55:12 AEST 2017 
> ppc64 GNU/Linux
> 
> 
> Haven't had time to debug any further. Any ideas?

Thank you for this report.

Can you please specify features of the relevant NIC ? (ethtool -k
) 

I'll try to replicate the issue as soon I'll get hands on suitable HW,
meanwhile can you please try to trace the system behavior with perf?

Something like:

perf probe -a __udp_enqueue_schedule_skb
perf probe -a udp_recvmsg
perf probe -a udpv6_recvmsg
perf record -e probe:__udp_enqueue_schedule_skb -e probe:udp_recvmsg -e 
probe:udpv6_recvmsg -ag wget google.com
perf report --stdio

Thanks,

Paolo


[PATCH v3 02/11] netlink: mark nla_put_{u8,u16,u32} noinline_if_stackbloat

2017-06-22 Thread Arnd Bergmann
When CONFIG_KASAN is enabled, the "--param asan-stack=1" causes rather large
stack frames in some functions. This goes unnoticed normally because
CONFIG_FRAME_WARN is disabled with CONFIG_KASAN by default as of commit
3f181b4d8652 ("lib/Kconfig.debug: disable -Wframe-larger-than warnings with
KASAN=y").

The kernelci.org build bot however has the warning enabled and that led
me to investigate it a little further, as every build produces these warnings:

net/wireless/nl80211.c:4389:1: warning: the frame size of 2240 bytes is larger 
than 2048 bytes [-Wframe-larger-than=]
net/wireless/nl80211.c:1895:1: warning: the frame size of 3776 bytes is larger 
than 2048 bytes [-Wframe-larger-than=]
net/wireless/nl80211.c:1410:1: warning: the frame size of 2208 bytes is larger 
than 2048 bytes [-Wframe-larger-than=]
net/bridge/br_netlink.c:1282:1: warning: the frame size of 2544 bytes is larger 
than 2048 bytes [-Wframe-larger-than=]

With the new noinline_if_stackbloat annotation, we can avoid the problem
when KASAN is enabled but not change anything otherwise.

Cc: Andrey Ryabinin 
Cc: Alexander Potapenko 
Cc: Dmitry Vyukov 
Cc: kasan-...@googlegroups.com
Signed-off-by: Arnd Bergmann 
---
 include/net/netlink.h | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/include/net/netlink.h b/include/net/netlink.h
index 01709172b3d3..24b4badd6eaf 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -766,7 +766,7 @@ static inline int nla_parse_nested(struct nlattr *tb[], int 
maxtype,
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value)
+static noinline_if_stackbloat int nla_put_u8(struct sk_buff *skb, int 
attrtype, u8 value)
 {
return nla_put(skb, attrtype, sizeof(u8), );
 }
@@ -777,7 +777,7 @@ static inline int nla_put_u8(struct sk_buff *skb, int 
attrtype, u8 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value)
+static noinline_if_stackbloat int nla_put_u16(struct sk_buff *skb, int 
attrtype, u16 value)
 {
return nla_put(skb, attrtype, sizeof(u16), );
 }
@@ -788,7 +788,7 @@ static inline int nla_put_u16(struct sk_buff *skb, int 
attrtype, u16 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)
+static noinline_if_stackbloat int nla_put_be16(struct sk_buff *skb, int 
attrtype, __be16 value)
 {
return nla_put(skb, attrtype, sizeof(__be16), );
 }
@@ -799,7 +799,7 @@ static inline int nla_put_be16(struct sk_buff *skb, int 
attrtype, __be16 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 
value)
+static noinline_if_stackbloat int nla_put_net16(struct sk_buff *skb, int 
attrtype, __be16 value)
 {
return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, value);
 }
@@ -810,7 +810,7 @@ static inline int nla_put_net16(struct sk_buff *skb, int 
attrtype, __be16 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value)
+static noinline_if_stackbloat int nla_put_le16(struct sk_buff *skb, int 
attrtype, __le16 value)
 {
return nla_put(skb, attrtype, sizeof(__le16), );
 }
@@ -821,7 +821,7 @@ static inline int nla_put_le16(struct sk_buff *skb, int 
attrtype, __le16 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value)
+static noinline_if_stackbloat int nla_put_u32(struct sk_buff *skb, int 
attrtype, u32 value)
 {
return nla_put(skb, attrtype, sizeof(u32), );
 }
@@ -832,7 +832,7 @@ static inline int nla_put_u32(struct sk_buff *skb, int 
attrtype, u32 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)
+static noinline_if_stackbloat int nla_put_be32(struct sk_buff *skb, int 
attrtype, __be32 value)
 {
return nla_put(skb, attrtype, sizeof(__be32), );
 }
@@ -843,7 +843,7 @@ static inline int nla_put_be32(struct sk_buff *skb, int 
attrtype, __be32 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 
value)
+static noinline_if_stackbloat int nla_put_net32(struct sk_buff *skb, int 
attrtype, __be32 value)
 {
return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, value);
 }
@@ -854,7 +854,7 @@ static inline int nla_put_net32(struct sk_buff *skb, int 
attrtype, __be32 value)
  * @attrtype: attribute type
  * @value: numeric value
  */
-static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 

[PATCH v3 04/11] mtd: cfi: reduce stack size with KASAN

2017-06-22 Thread Arnd Bergmann
When CONFIG_KASAN is used, we consume a lot of extra stack space:

drivers/mtd/chips/cfi_cmdset_0020.c: In function 'do_write_buffer':
drivers/mtd/chips/cfi_cmdset_0020.c:603:1: error: the frame size of 2184 bytes 
is larger than 1536 bytes [-Werror=frame-larger-than=]
drivers/mtd/chips/cfi_cmdset_0020.c: In function 'cfi_staa_erase_varsize':
drivers/mtd/chips/cfi_cmdset_0020.c:972:1: error: the frame size of 1936 bytes 
is larger than 1536 bytes [-Werror=frame-larger-than=]
drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer':
drivers/mtd/chips/cfi_cmdset_0001.c:1841:1: error: the frame size of 1776 bytes 
is larger than 1536 bytes [-Werror=frame-larger-than=]

This marks some functions as noinline_if_stackbloat to keep reduce the
overall stack size.

Signed-off-by: Arnd Bergmann 
---
 drivers/mtd/chips/cfi_cmdset_0020.c | 8 
 include/linux/mtd/map.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c 
b/drivers/mtd/chips/cfi_cmdset_0020.c
index 7d342965f392..5eee5e883f55 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -244,7 +244,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
 }
 
 
-static inline int do_read_onechip(struct map_info *map, struct flchip *chip, 
loff_t adr, size_t len, u_char *buf)
+static noinline_if_stackbloat int do_read_onechip(struct map_info *map, struct 
flchip *chip, loff_t adr, size_t len, u_char *buf)
 {
map_word status, status_OK;
unsigned long timeo;
@@ -728,7 +728,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec 
*vecs,
 }
 
 
-static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, 
unsigned long adr)
+static noinline_if_stackbloat int do_erase_oneblock(struct map_info *map, 
struct flchip *chip, unsigned long adr)
 {
struct cfi_private *cfi = map->fldrv_priv;
map_word status, status_OK;
@@ -1029,7 +1029,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
}
 }
 
-static inline int do_lock_oneblock(struct map_info *map, struct flchip *chip, 
unsigned long adr)
+static noinline_if_stackbloat int do_lock_oneblock(struct map_info *map, 
struct flchip *chip, unsigned long adr)
 {
struct cfi_private *cfi = map->fldrv_priv;
map_word status, status_OK;
@@ -1175,7 +1175,7 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t 
ofs, uint64_t len)
}
return 0;
 }
-static inline int do_unlock_oneblock(struct map_info *map, struct flchip 
*chip, unsigned long adr)
+static noinline_if_stackbloat int do_unlock_oneblock(struct map_info *map, 
struct flchip *chip, unsigned long adr)
 {
struct cfi_private *cfi = map->fldrv_priv;
map_word status, status_OK;
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index 3aa56e3104bb..29db74314db8 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -316,7 +316,7 @@ static inline map_word map_word_or(struct map_info *map, 
map_word val1, map_word
return r;
 }
 
-static inline int map_word_andequal(struct map_info *map, map_word val1, 
map_word val2, map_word val3)
+static noinline_if_stackbloat int map_word_andequal(struct map_info *map, 
map_word val1, map_word val2, map_word val3)
 {
int i;
 
@@ -328,7 +328,7 @@ static inline int map_word_andequal(struct map_info *map, 
map_word val1, map_wor
return 1;
 }
 
-static inline int map_word_bitsset(struct map_info *map, map_word val1, 
map_word val2)
+static noinline_if_stackbloat int map_word_bitsset(struct map_info *map, 
map_word val1, map_word val2)
 {
int i;
 
@@ -362,7 +362,7 @@ static inline map_word map_word_load(struct map_info *map, 
const void *ptr)
return r;
 }
 
-static inline map_word map_word_load_partial(struct map_info *map, map_word 
orig, const unsigned char *buf, int start, int len)
+static noinline_if_stackbloat map_word map_word_load_partial(struct map_info 
*map, map_word orig, const unsigned char *buf, int start, int len)
 {
int i;
 
@@ -392,7 +392,7 @@ static inline map_word map_word_load_partial(struct 
map_info *map, map_word orig
 #define MAP_FF_LIMIT 8
 #endif
 
-static inline map_word map_word_ff(struct map_info *map)
+static noinline_if_stackbloat map_word map_word_ff(struct map_info *map)
 {
map_word r;
int i;
-- 
2.9.0



Re: [PATCH net] udp: ipv6: reset daddr and dport in sk if connect() fails

2017-06-22 Thread David Miller
From: Wei Wang 
Date: Wed, 21 Jun 2017 14:36:31 -0700

> + memset(>sk_v6_daddr, 0 sizeof(sk->sk_v6_daddr);

Tell me how that compiles.


[PATCH v2] of: update ePAPR references to point to Devicetree Specification

2017-06-22 Thread frowand . list
From: Frank Rowand 

The Devicetree Specification has superseded the ePAPR as the
base specification for bindings.  Update files in Documentation
to reference the new document.

First reference to ePAPR in Documentation/devicetree/bindings/arm/cci.txt
is generic, remove it.

Some files are not updated because there is no hypervisor chapter
in the Devicetree Specification:
   Documentation/devicetree/bindings/powerpc/fsl/msi-pic.txt
   Documenation/virtual/kvm/api.txt
   Documenation/virtual/kvm/ppc-pv.txt

Signed-off-by: Frank Rowand 
---

changes from v1:
   - remove boilerplat ePAPR reference from cci.txt

 Documentation/devicetree/bindings/arm/cci.txt | 15 ---
 Documentation/devicetree/bindings/arm/cpus.txt| 13 +++--
 Documentation/devicetree/bindings/arm/idle-states.txt |  4 ++--
 Documentation/devicetree/bindings/arm/l2c2x0.txt  |  4 ++--
 Documentation/devicetree/bindings/arm/topology.txt|  4 ++--
 Documentation/devicetree/bindings/bus/simple-pm-bus.txt   |  2 +-
 Documentation/devicetree/bindings/chosen.txt  |  3 ++-
 Documentation/devicetree/bindings/common-properties.txt   |  2 +-
 Documentation/devicetree/bindings/crypto/fsl-sec4.txt |  4 ++--
 Documentation/devicetree/bindings/crypto/fsl-sec6.txt |  4 ++--
 .../devicetree/bindings/interrupt-controller/open-pic.txt |  5 ++---
 Documentation/devicetree/bindings/net/ethernet.txt|  9 ++---
 Documentation/devicetree/bindings/powerpc/fsl/cpus.txt|  6 +++---
 Documentation/devicetree/bindings/powerpc/fsl/l2cache.txt |  2 +-
 .../devicetree/bindings/powerpc/fsl/srio-rmu.txt  |  4 ++--
 Documentation/devicetree/bindings/powerpc/fsl/srio.txt|  3 ++-
 Documentation/devicetree/booting-without-of.txt   |  2 +-
 Documentation/devicetree/usage-model.txt  |  2 +-
 Documentation/xtensa/mmu.txt  |  6 +++---
 19 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/cci.txt 
b/Documentation/devicetree/bindings/arm/cci.txt
index 0f2153e8fa7e..9600761f2d5b 100644
--- a/Documentation/devicetree/bindings/arm/cci.txt
+++ b/Documentation/devicetree/bindings/arm/cci.txt
@@ -11,13 +11,6 @@ clusters, through memory mapped interface, with a global 
control register
 space and multiple sets of interface control registers, one per slave
 interface.
 
-Bindings for the CCI node follow the ePAPR standard, available from:
-
-www.power.org/documentation/epapr-version-1-1/
-
-with the addition of the bindings described in this document which are
-specific to ARM.
-
 * CCI interconnect node
 
Description: Describes a CCI cache coherent Interconnect component
@@ -50,10 +43,10 @@ specific to ARM.
as a tuple of cells, containing child address,
parent address and the size of the region in the
child address space.
-   Definition: A standard property. Follow rules in the ePAPR for
-   hierarchical bus addressing. CCI interfaces
-   addresses refer to the parent node addressing
-   scheme to declare their register bases.
+   Definition: A standard property. Follow rules in the Devicetree
+   Specification for hierarchical bus addressing. CCI
+   interfaces addresses refer to the parent node
+   addressing scheme to declare their register bases.
 
CCI interconnect node can define the following child nodes:
 
diff --git a/Documentation/devicetree/bindings/arm/cpus.txt 
b/Documentation/devicetree/bindings/arm/cpus.txt
index 1030f5f50207..283c520a2224 100644
--- a/Documentation/devicetree/bindings/arm/cpus.txt
+++ b/Documentation/devicetree/bindings/arm/cpus.txt
@@ -6,9 +6,9 @@ The device tree allows to describe the layout of CPUs in a 
system through
 the "cpus" node, which in turn contains a number of subnodes (ie "cpu")
 defining properties for every cpu.
 
-Bindings for CPU nodes follow the ePAPR v1.1 standard, available from:
+Bindings for CPU nodes follow the Devicetree Specification, available from:
 
-https://www.power.org/documentation/epapr-version-1-1/
+https://www.devicetree.org/specifications/
 
 with updates for 32-bit and 64-bit ARM systems provided in this document.
 
@@ -16,8 +16,8 @@ with updates for 32-bit and 64-bit ARM systems provided in 
this document.
 Convention used in this document
 
 
-This document follows the conventions described in the ePAPR v1.1, with
-the addition:
+This document follows the conventions described in the Devicetree
+Specification, with the addition:
 
 - square brackets define bitfields, eg reg[7:0] value of the bitfield in
   the reg property contained in bits 7 down to 0
@@ -26,8 +26,9 @@ the 

[next-queue PATCH] i40evf: remove unnecessary __packed

2017-06-22 Thread Tushar Dave
This is similar to 'commit 9588397d24eec ("i40e: remove unnecessary
__packed")' to avoid unaligned access.

Signed-off-by: Tushar Dave 
---
 drivers/net/ethernet/intel/i40evf/i40e_osdep.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40evf/i40e_osdep.h 
b/drivers/net/ethernet/intel/i40evf/i40e_osdep.h
index 5e314fd..a907377 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_osdep.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_osdep.h
@@ -54,7 +54,7 @@ struct i40e_dma_mem {
void *va;
dma_addr_t pa;
u32 size;
-} __packed;
+};
 
 #define i40e_allocate_dma_mem(h, m, unused, s, a) \
i40evf_allocate_dma_mem_d(h, m, s, a)
@@ -63,7 +63,7 @@ struct i40e_dma_mem {
 struct i40e_virt_mem {
void *va;
u32 size;
-} __packed;
+};
 #define i40e_allocate_virt_mem(h, m, s) i40evf_allocate_virt_mem_d(h, m, s)
 #define i40e_free_virt_mem(h, m) i40evf_free_virt_mem_d(h, m)
 
-- 
1.9.1



Re: [Patch net] ipv6: avoid unregistering inet6_dev for loopback

2017-06-22 Thread David Miller
From: Cong Wang 
Date: Wed, 21 Jun 2017 14:34:58 -0700

> The per netns loopback_dev->ip6_ptr is unregistered and set to
> NULL when its mtu is set to smaller than IPV6_MIN_MTU, this
> leads to that we could set rt->rt6i_idev NULL after a
> rt6_uncached_list_flush_dev() and then crash after another
> call.
> 
> In this case we should just bring its inet6_dev down, rather
> than unregistering it, at least prior to commit 176c39af29bc
> ("netns: fix addrconf_ifdown kernel panic") we always
> override the case for loopback.
> 
> Thanks a lot to Andrey for finding a reliable reproducer.
> 
> Fixes: 176c39af29bc ("netns: fix addrconf_ifdown kernel panic")
> Reported-by: Andrey Konovalov 
> Cc: Andrey Konovalov 
> Cc: Daniel Lezcano 
> Cc: David Ahern 
> Signed-off-by: Cong Wang 

Applied, thanks.


Re: [PATCH net] udp: ipv6: reset daddr and dport in sk if connect() fails

2017-06-22 Thread Wei Wang
On Thu, Jun 22, 2017 at 10:25 AM, David Miller  wrote:
> From: Wei Wang 
> Date: Wed, 21 Jun 2017 14:36:31 -0700
>
>> + memset(>sk_v6_daddr, 0 sizeof(sk->sk_v6_daddr);
>
> Tell me how that compiles.

Really sorry about that. I ported over the change manually from
another branch and made the stupid mistake...
Will send out v2 shortly.


Re: [oss-drivers] Re: [PATCH net-next 00/12] nfp: add flower app with representors

2017-06-22 Thread Simon Horman
On Thu, Jun 22, 2017 at 05:39:09PM +0300, Or Gerlitz wrote:
> On Wed, Jun 21, 2017 at 12:32 PM, Simon Horman
>  wrote:
> 
> > This patchset is in two parts.
> >
> > The first 9 patches add code to allow representors to be instantiated
> > etc... The remaining patches provide the beginning of a flower app which
> > makes use of this infrastructure. So I think there is a clear separation
> > between representor code, in .../nfp/ and app code that uses representors,
> > in this case .../nfp/flower/.
> 
> indeed, got it.
> 
> > I could have supplied a test app to demonstrate using representors - and
> > that is really what the flower app is as of this patchset. But I chose to
> > name it flower as it we have follow-up work to make the app actually
> > offload flower and at that point that will be come its dominant feature.
> 
> As you stated, the separation is there. If got you right, it will be possible 
> to
> use representors in non flower apps, and probably also possible to have
> the flower app used in a non-SRIOV environment, just fine.

Yes, that is correct.


[PATCH v3 09/11] brcmsmac: split up wlc_phy_workarounds_nphy

2017-06-22 Thread Arnd Bergmann
The stack consumption in this driver is still relatively high, with one
remaining warning if the warning level is lowered to 1536 bytes:

drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c:17135:1: error: 
the frame size of 1880 bytes is larger than 1536 bytes 
[-Werror=frame-larger-than=]

The affected function is actually a collection of three separate 
implementations,
and each of them is fairly large by itself. Splitting them up is done easily
and improves readability at the same time.

I'm leaving the original indentation to make the review easier.

Acked-by: Arend van Spriel 
Signed-off-by: Arnd Bergmann 
---
 .../broadcom/brcm80211/brcmsmac/phy/phy_n.c| 178 -
 1 file changed, 104 insertions(+), 74 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
index ef685465f80a..ed409a80f3d2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
@@ -16061,52 +16061,8 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct 
brcms_phy *pi)
}
 }
 
-static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
+static void wlc_phy_workarounds_nphy_rev7(struct brcms_phy *pi)
 {
-   static const u8 rfseq_rx2tx_events[] = {
-   NPHY_RFSEQ_CMD_NOP,
-   NPHY_RFSEQ_CMD_RXG_FBW,
-   NPHY_RFSEQ_CMD_TR_SWITCH,
-   NPHY_RFSEQ_CMD_CLR_HIQ_DIS,
-   NPHY_RFSEQ_CMD_RXPD_TXPD,
-   NPHY_RFSEQ_CMD_TX_GAIN,
-   NPHY_RFSEQ_CMD_EXT_PA
-   };
-   u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 };
-   static const u8 rfseq_tx2rx_events[] = {
-   NPHY_RFSEQ_CMD_NOP,
-   NPHY_RFSEQ_CMD_EXT_PA,
-   NPHY_RFSEQ_CMD_TX_GAIN,
-   NPHY_RFSEQ_CMD_RXPD_TXPD,
-   NPHY_RFSEQ_CMD_TR_SWITCH,
-   NPHY_RFSEQ_CMD_RXG_FBW,
-   NPHY_RFSEQ_CMD_CLR_HIQ_DIS
-   };
-   static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 };
-   static const u8 rfseq_tx2rx_events_rev3[] = {
-   NPHY_REV3_RFSEQ_CMD_EXT_PA,
-   NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
-   NPHY_REV3_RFSEQ_CMD_TX_GAIN,
-   NPHY_REV3_RFSEQ_CMD_RXPD_TXPD,
-   NPHY_REV3_RFSEQ_CMD_TR_SWITCH,
-   NPHY_REV3_RFSEQ_CMD_RXG_FBW,
-   NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS,
-   NPHY_REV3_RFSEQ_CMD_END
-   };
-   static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 };
-   u8 rfseq_rx2tx_events_rev3[] = {
-   NPHY_REV3_RFSEQ_CMD_NOP,
-   NPHY_REV3_RFSEQ_CMD_RXG_FBW,
-   NPHY_REV3_RFSEQ_CMD_TR_SWITCH,
-   NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS,
-   NPHY_REV3_RFSEQ_CMD_RXPD_TXPD,
-   NPHY_REV3_RFSEQ_CMD_TX_GAIN,
-   NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
-   NPHY_REV3_RFSEQ_CMD_EXT_PA,
-   NPHY_REV3_RFSEQ_CMD_END
-   };
-   u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 };
-
static const u8 rfseq_rx2tx_events_rev3_ipa[] = {
NPHY_REV3_RFSEQ_CMD_NOP,
NPHY_REV3_RFSEQ_CMD_RXG_FBW,
@@ -16120,29 +16076,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy 
*pi)
};
static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 
1, 1 };
static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f };
-
-   s16 alpha0, alpha1, alpha2;
-   s16 beta0, beta1, beta2;
-   u32 leg_data_weights, ht_data_weights, nss1_data_weights,
-   stbc_data_weights;
+   u32 leg_data_weights;
u8 chan_freq_range = 0;
static const u16 dac_control = 0x0002;
u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 };
u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 };
-   u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 };
-   u16 aux_adc_vmid_rev3[] = { 0xa2, 0xb4, 0xb4, 0x89 };
-   u16 *aux_adc_vmid;
u16 aux_adc_gain_rev7[] = { 0x02, 0x02, 0x02, 0x02 };
-   u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 };
-   u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 };
-   u16 *aux_adc_gain;
-   static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 };
-   static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 };
s32 min_nvar_val = 0x18d;
s32 min_nvar_offset_6mbps = 20;
u8 pdetrange;
-   u8 triso;
-   u16 regval;
u16 afectrl_adc_ctrl1_rev7 = 0x20;
u16 afectrl_adc_ctrl2_rev7 = 0x0;
u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77;
@@ -16171,17 +16113,6 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy 
*pi)
u16 freq;
int coreNum;
 
-   if (CHSPEC_IS5G(pi->radio_chanspec))
-   

Re: [PATCH v5 0/5] stmmac: pci: Refactor DMI probing

2017-06-22 Thread David Miller
From: Jan Kiszka 
Date: Thu, 22 Jun 2017 08:17:56 +0200

> Some cleanups of the way we probe DMI platforms in the driver. Reduces
> a bit of open-coding and makes the logic easier reusable for any
> potential DMI platform != Quark.
> 
> Tested on IOT2000 and Galileo Gen2.
> 
> Changes in v5:
>  - fixed a remaining issue in patch 5
>  - dropped patch 6 for now

Series applied to net-next.

Any chance the DMI table can be marked const as well?


Re: [PATCH net] udp: ipv6: reset daddr and dport in sk if connect() fails

2017-06-22 Thread kbuild test robot
Hi Wei,

[auto build test ERROR on net/master]

url:
https://github.com/0day-ci/linux/commits/Wei-Wang/udp-ipv6-reset-daddr-and-dport-in-sk-if-connect-fails/20170623-011149
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha 

All error/warnings (new ones prefixed by >>):

   net//ipv6/datagram.c: In function '__ip6_datagram_connect':
   net//ipv6/datagram.c:257:30: error: expected ')' before 'sizeof'
  memset(>sk_v6_daddr, 0 sizeof(sk->sk_v6_daddr);
 ^~
   In file included from include/linux/string.h:18:0,
from include/linux/bitmap.h:8,
from include/linux/cpumask.h:11,
from include/linux/interrupt.h:9,
from net//ipv6/datagram.c:18:
>> arch/alpha/include/asm/string.h:45:16: error: too few arguments to function 
>> '__memset'
#define memset __memset
   ^
>> net//ipv6/datagram.c:257:3: note: in expansion of macro 'memset'
  memset(>sk_v6_daddr, 0 sizeof(sk->sk_v6_daddr);
  ^~
   arch/alpha/include/asm/string.h:32:21: note: declared here
extern inline void *__memset(void *s, int c, size_t n)
^~~~
   net//ipv6/datagram.c:260:2: error: expected ';' before '}' token
 }
 ^
--
   net/ipv6/datagram.c: In function '__ip6_datagram_connect':
   net/ipv6/datagram.c:257:30: error: expected ')' before 'sizeof'
  memset(>sk_v6_daddr, 0 sizeof(sk->sk_v6_daddr);
 ^~
   In file included from include/linux/string.h:18:0,
from include/linux/bitmap.h:8,
from include/linux/cpumask.h:11,
from include/linux/interrupt.h:9,
from net/ipv6/datagram.c:18:
>> arch/alpha/include/asm/string.h:45:16: error: too few arguments to function 
>> '__memset'
#define memset __memset
   ^
   net/ipv6/datagram.c:257:3: note: in expansion of macro 'memset'
  memset(>sk_v6_daddr, 0 sizeof(sk->sk_v6_daddr);
  ^~
   arch/alpha/include/asm/string.h:32:21: note: declared here
extern inline void *__memset(void *s, int c, size_t n)
^~~~
   net/ipv6/datagram.c:260:2: error: expected ';' before '}' token
 }
 ^

vim +/__memset +45 arch/alpha/include/asm/string.h

a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  29  /* 
For gcc 3.x, we cannot have the inline function named "memset" because
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  30 
the __builtin_memset will attempt to resolve to the inline as well,
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  31 
leading to a "sorry" about unimplemented recursive inlining.  */
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  32  
extern inline void *__memset(void *s, int c, size_t n)
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  33  {
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  34   
if (__builtin_constant_p(c)) {
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  35   
if (__builtin_constant_p(n)) {
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  36   
return __builtin_memset(s, c, n);
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  37   
} else {
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  38   
unsigned long c8 = (c & 0xff) * 0x0101010101010101UL;
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  39   
return __constant_c_memset(s, c8, n);
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  40   
}
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  41   
}
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  42   
return ___memset(s, c, n);
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  43  }
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11  44  
a47e5bb5 arch/alpha/include/asm/string.h Richard Henderson 2013-07-11 @45  
#define memset __memset
^1da177e include/asm-alpha/string.h  Linus Torvalds2005-04-16  46  
^1da177e include/asm-alpha/string.h  Linus Torvalds2005-04-16  47  
#define __HAVE_ARCH_STRCPY
^1da177e include/asm-alpha/string.h  Linus Torvalds2005-04-16  48  
extern char * strcpy(char *,const char *);
^1da177e include/asm-alpha/string.h  Linus Torvalds2005-04-16  49  
#define __HAVE_ARCH_STRNCPY
^1da177e include/asm-alpha/string.h  

[PATCH v2 net] udpv6: reset daddr and dport in sk if connect() fails

2017-06-22 Thread Wei Wang
From: Wei Wang 

In __ip6_datagram_connect(), reset sk->sk_v6_daddr and inet->dport if
error occurs so that udp_v6_early_demux() won't consider this socket
as a valid candidate for early demux.

v2: fix compilation error

Signed-off-by: Wei Wang 
Acked-by: Maciej Żenczykowski 
---
 net/ipv6/datagram.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index e011122ebd43..5c786f5ab961 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -250,8 +250,14 @@ int __ip6_datagram_connect(struct sock *sk, struct 
sockaddr *uaddr,
 */
 
err = ip6_datagram_dst_update(sk, true);
-   if (err)
+   if (err) {
+   /* Reset daddr and dport so that udp_v6_early_demux()
+* fails to find this socket
+*/
+   memset(>sk_v6_daddr, 0, sizeof(sk->sk_v6_daddr));
+   inet->inet_dport = 0;
goto out;
+   }
 
sk->sk_state = TCP_ESTABLISHED;
sk_set_txhash(sk);
-- 
2.13.1.611.g7e3b11ae1-goog



Re: [PATCH] dt-bindings: gpmc: Correct location of generic gpmc binding

2017-06-22 Thread Boris Brezillon
On Wed, 21 Jun 2017 08:14:54 -0400
Tom Rini  wrote:

> The binding bus/ti-gpmc.txt has been moved to
> memory-controllers/omap-gpmc.txt.  Update all references to this in
> order to make reading and understanding a given binding easier.
> 
> Cc: David Woodhouse 
> Cc: Brian Norris 
> Cc:Boris Brezillon 
> Cc: Marek Vasut 
> Cc: Richard Weinberger 
> Cc: Cyrille Pitchen 
> Cc: Rob Herring 
> Cc: Mark Rutland 
> Signed-off-by: Tom Rini 

Applied.

Thanks,

Boris

> ---
>  Documentation/devicetree/bindings/mtd/gpmc-nand.txt| 2 +-
>  Documentation/devicetree/bindings/mtd/gpmc-nor.txt | 4 ++--
>  Documentation/devicetree/bindings/mtd/gpmc-onenand.txt | 2 +-
>  Documentation/devicetree/bindings/net/gpmc-eth.txt | 4 ++--
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt 
> b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
> index 174f68c26c1b..dd559045593d 100644
> --- a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
> @@ -5,7 +5,7 @@ the GPMC controller with a name of "nand".
>  
>  All timing relevant properties as well as generic gpmc child properties are
>  explained in a separate documents - please refer to
> -Documentation/devicetree/bindings/bus/ti-gpmc.txt
> +Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
>  
>  For NAND specific properties such as ECC modes or bus width, please refer to
>  Documentation/devicetree/bindings/mtd/nand.txt
> diff --git a/Documentation/devicetree/bindings/mtd/gpmc-nor.txt 
> b/Documentation/devicetree/bindings/mtd/gpmc-nor.txt
> index 4828c17bb784..131d3a74d0bd 100644
> --- a/Documentation/devicetree/bindings/mtd/gpmc-nor.txt
> +++ b/Documentation/devicetree/bindings/mtd/gpmc-nor.txt
> @@ -5,7 +5,7 @@ child nodes of the GPMC controller with a name of "nor".
>  
>  All timing relevant properties as well as generic GPMC child properties are
>  explained in a separate documents. Please refer to
> -Documentation/devicetree/bindings/bus/ti-gpmc.txt
> +Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
>  
>  Required properties:
>  - bank-width:Width of NOR flash in bytes. GPMC supports 
> 8-bit and
> @@ -28,7 +28,7 @@ Required properties:
>  
>  Optional properties:
>  - gpmc,XXX   Additional GPMC timings and settings parameters. See
> - Documentation/devicetree/bindings/bus/ti-gpmc.txt
> + 
> Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
>  
>  Optional properties for partition table parsing:
>  - #address-cells: should be set to 1
> diff --git a/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt 
> b/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt
> index 5d8fa527c496..b6e8bfd024f4 100644
> --- a/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt
> +++ b/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt
> @@ -5,7 +5,7 @@ the GPMC controller with a name of "onenand".
>  
>  All timing relevant properties as well as generic gpmc child properties are
>  explained in a separate documents - please refer to
> -Documentation/devicetree/bindings/bus/ti-gpmc.txt
> +Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
>  
>  Required properties:
>  
> diff --git a/Documentation/devicetree/bindings/net/gpmc-eth.txt 
> b/Documentation/devicetree/bindings/net/gpmc-eth.txt
> index ace4a64b3695..f7da3d73ca1b 100644
> --- a/Documentation/devicetree/bindings/net/gpmc-eth.txt
> +++ b/Documentation/devicetree/bindings/net/gpmc-eth.txt
> @@ -9,7 +9,7 @@ the GPMC controller with an "ethernet" name.
>  
>  All timing relevant properties as well as generic GPMC child properties are
>  explained in a separate documents. Please refer to
> -Documentation/devicetree/bindings/bus/ti-gpmc.txt
> +Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
>  
>  For the properties relevant to the ethernet controller connected to the GPMC
>  refer to the binding documentation of the device. For example, the 
> documentation
> @@ -43,7 +43,7 @@ Required properties:
>  
>  Optional properties:
>  - gpmc,XXX   Additional GPMC timings and settings parameters. See
> - Documentation/devicetree/bindings/bus/ti-gpmc.txt
> + 
> Documentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
>  
>  Example:
>  



[PATCH] rsi: add in missing RSI_FSM_STATES into array fsm_state

2017-06-22 Thread Colin King
From: Colin Ian King 

Two recent commits added new RSI_FSM_STATES (namely FSM_FW_NOT_LOADED
and FSM_COMMON_DEV_PARAMS_SENT) and the corresponding table fsm_state
was not updated to match. This can lead to an array overrun when
accessing the latter two states in fsm_state. Fix this by adding in
the missing states.

Detected by CoverityScan, CID#1398379 ("Illegal address computation")

Fixes: 9920322ccd8e04 ("rsi: add tx frame for common device configuration")
Fixes: 015e367494c1d5 ("rsi: Register interrupt handler before firmware load")

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/rsi/rsi_91x_debugfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/rsi/rsi_91x_debugfs.c 
b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
index 828a042f903f..4c0a493bd44e 100644
--- a/drivers/net/wireless/rsi/rsi_91x_debugfs.c
+++ b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
@@ -125,7 +125,9 @@ static int rsi_stats_read(struct seq_file *seq, void *data)
struct rsi_common *common = seq->private;
 
unsigned char fsm_state[][32] = {
+   "FSM_FW_NOT_LOADED",
"FSM_CARD_NOT_READY",
+   "FSM_COMMON_DEV_PARAMS_SENT",
"FSM_BOOT_PARAMS_SENT",
"FSM_EEPROM_READ_MAC_ADDR",
"FSM_RESET_MAC_SENT",
-- 
2.11.0



Re: [PATCH net-next v3 06/13] sock: MSG_ZEROCOPY notification coalescing

2017-06-22 Thread David Miller
From: Willem de Bruijn 
Date: Wed, 21 Jun 2017 17:18:09 -0400

> +static bool skb_zerocopy_notify_extend(struct sk_buff *skb, u32 lo, u16 len)
> +{
> + struct sock_exterr_skb *serr = SKB_EXT_ERR(skb);
> + u64 sum_len;
> + u32 old_lo, old_hi;

Reverse christmas tree.

>  void sock_zerocopy_callback(struct ubuf_info *uarg, bool success)
>  {
>   struct sock_exterr_skb *serr;
> - struct sk_buff *skb = skb_from_uarg(uarg);
> + struct sk_buff *tail, *skb = skb_from_uarg(uarg);
>   struct sock *sk = skb->sk;
> - u16 id = uarg->desc;
> + struct sk_buff_head *q = >sk_error_queue;
> + unsigned long flags;
> + u32 lo, hi;
> + u16 len;

Likewise.


Re: [PATCH] netvsc: don't access netdev->num_rx_queues directly

2017-06-22 Thread David Miller
From: Arnd Bergmann 
Date: Thu, 22 Jun 2017 00:16:37 +0200

> This structure member is hidden behind CONFIG_SYSFS, and we
> get a build error when that is disabled:
> 
> drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_channels':
> drivers/net/hyperv/netvsc_drv.c:754:49: error: 'struct net_device' has no 
> member named 'num_rx_queues'; did you mean 'num_tx_queues'?
> drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_rxfh':
> drivers/net/hyperv/netvsc_drv.c:1181:25: error: 'struct net_device' has no 
> member named 'num_rx_queues'; did you mean 'num_tx_queues'?
> 
> As the value is only set once to the argument of alloc_netdev_mq(),
> we can compare against that constant directly.
> 
> Fixes: ff4a44199012 ("netvsc: allow get/set of RSS indirection table")
> Fixes: 2b01888d1b45 ("netvsc: allow more flexible setting of number of 
> channels")
> Signed-off-by: Arnd Bergmann 

Applied and queued up for -stable, thank you.


[PATCH 3/3] net: qcom/emac: add support for emulation systems

2017-06-22 Thread Timur Tabi
On emulation systems, the EMAC's internal PHY ("SGMII") is not present,
but is not needed for network functionality.  So just display a warning
message and ignore the SGMII.

Tested-by: Philip Elcan 
Tested-by: Adam Wallis 
Signed-off-by: Timur Tabi 
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c 
b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index 18c184e..29ba37a 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -297,6 +297,14 @@ static int emac_sgmii_acpi_match(struct device *dev, void 
*data)
{}
 };
 
+/* Dummy function for systems without an internal PHY. This avoids having
+ * to check for NULL pointers before calling the functions.
+ */
+static int emac_sgmii_dummy(struct emac_adapter *adpt)
+{
+   return 0;
+}
+
 int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
 {
struct platform_device *sgmii_pdev = NULL;
@@ -311,8 +319,19 @@ int emac_sgmii_config(struct platform_device *pdev, struct 
emac_adapter *adpt)
emac_sgmii_acpi_match);
 
if (!dev) {
-   dev_err(>dev, "cannot find internal phy node\n");
-   return -ENODEV;
+   dev_warn(>dev, "cannot find internal phy node\n");
+   /* There is typically no internal PHY on emulation
+* systems, so if we can't find the node, assume
+* we are on an emulation system and stub-out
+* support for the internal PHY.  These systems only
+* use ACPI.
+*/
+   phy->open = emac_sgmii_dummy;
+   phy->close = emac_sgmii_dummy;
+   phy->link_up = emac_sgmii_dummy;
+   phy->link_down = emac_sgmii_dummy;
+
+   return 0;
}
 
sgmii_pdev = to_platform_device(dev);
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



[PATCH 1/3] net: qcom/emac: add shutdown function

2017-06-22 Thread Timur Tabi
The shutdown function halts all DMA and interrupts, so that all
operations are discontinued when the system shuts down, e.g. via
kexec or a forced reboot.

Tested-by: Tyler Baicar 
Signed-off-by: Timur Tabi 
---
 drivers/net/ethernet/qualcomm/emac/emac.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c 
b/drivers/net/ethernet/qualcomm/emac/emac.c
index 98a326f..77c5c92 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -762,6 +762,19 @@ static int emac_remove(struct platform_device *pdev)
return 0;
 }
 
+static void emac_shutdown(struct platform_device *pdev)
+{
+   struct net_device *netdev = dev_get_drvdata(>dev);
+   struct emac_adapter *adpt = netdev_priv(netdev);
+   struct emac_sgmii *sgmii = >phy;
+
+   /* Closing the SGMII turns off its interrupts */
+   sgmii->close(adpt);
+
+   /* Resetting the MAC turns off all DMA and its interrupts */
+   emac_mac_reset(adpt);
+}
+
 static struct platform_driver emac_platform_driver = {
.probe  = emac_probe,
.remove = emac_remove,
@@ -770,6 +783,7 @@ static int emac_remove(struct platform_device *pdev)
.of_match_table = emac_dt_match,
.acpi_match_table = ACPI_PTR(emac_acpi_match),
},
+   .shutdown = emac_shutdown,
 };
 
 module_platform_driver(emac_platform_driver);
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



[PATCH 2/3] net: qcom/emac: do not reset the EMAC during initialization

2017-06-22 Thread Timur Tabi
It doesn't make sense to reset the EMAC in the middle of initializing
it during the probe.

Tested-by: Richard Ruigrok 
Signed-off-by: Timur Tabi 
---
 drivers/net/ethernet/qualcomm/emac/emac.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c 
b/drivers/net/ethernet/qualcomm/emac/emac.c
index 77c5c92..746d94e 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -683,8 +683,6 @@ static int emac_probe(struct platform_device *pdev)
goto err_undo_mdiobus;
}
 
-   emac_mac_reset(adpt);
-
/* set hw features */
netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM |
NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_RX |
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



[PATCH 0/3] net: qcom/emac: various minor improvements

2017-06-22 Thread Timur Tabi
A collection of minor fixes and features to the Qualcomm Technologies
EMAC network driver.

Timur Tabi (3):
  net: qcom/emac: add shutdown function
  net: qcom/emac: do not reset the EMAC during initialization
  net: qcom/emac: add support for emulation systems

 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 23 +--
 drivers/net/ethernet/qualcomm/emac/emac.c   | 16 ++--
 2 files changed, 35 insertions(+), 4 deletions(-)

-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



[PATCH v3 05/11] dvb-frontends: reduce stack size in i2c access

2017-06-22 Thread Arnd Bergmann
A typical code fragment was copied across many dvb-frontend
drivers and causes large stack frames when built with
-fsanitize-address-use-after-scope, e.g.

drivers/media/dvb-frontends/cxd2841er.c:3225:1: error: the frame size of 3992 
bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/cxd2841er.c:3404:1: error: the frame size of 3136 
bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/stv0367.c:3143:1: error: the frame size of 4016 
bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 
bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/stv090x.c:4248:1: error: the frame size of 4872 
bytes is larger than 3072 bytes [-Werror=frame-larger-than=]

By marking the register access functions as noinline_if_stackbloat,
we can completely avoid this problem.

Signed-off-by: Arnd Bergmann 
---
 drivers/media/dvb-frontends/ascot2e.c   |  3 ++-
 drivers/media/dvb-frontends/cxd2841er.c |  4 ++--
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 14 +++---
 drivers/media/dvb-frontends/helene.c|  4 ++--
 drivers/media/dvb-frontends/horus3a.c   |  2 +-
 drivers/media/dvb-frontends/itd1000.c   |  2 +-
 drivers/media/dvb-frontends/mt312.c |  2 +-
 drivers/media/dvb-frontends/si2165.c| 14 +++---
 drivers/media/dvb-frontends/stb0899_drv.c   |  2 +-
 drivers/media/dvb-frontends/stb6100.c   |  2 +-
 drivers/media/dvb-frontends/stv0367.c   |  2 +-
 drivers/media/dvb-frontends/stv090x.c   |  2 +-
 drivers/media/dvb-frontends/stv6110.c   |  2 +-
 drivers/media/dvb-frontends/stv6110x.c  |  2 +-
 drivers/media/dvb-frontends/tda8083.c   |  2 +-
 drivers/media/dvb-frontends/zl10039.c   |  2 +-
 16 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/media/dvb-frontends/ascot2e.c 
b/drivers/media/dvb-frontends/ascot2e.c
index 0ee0df53b91b..da1d1fc03c5e 100644
--- a/drivers/media/dvb-frontends/ascot2e.c
+++ b/drivers/media/dvb-frontends/ascot2e.c
@@ -153,7 +153,8 @@ static int ascot2e_write_regs(struct ascot2e_priv *priv,
return 0;
 }
 
-static int ascot2e_write_reg(struct ascot2e_priv *priv, u8 reg, u8 val)
+static noinline_if_stackbloat int ascot2e_write_reg(struct ascot2e_priv *priv,
+   u8 reg, u8 val)
 {
return ascot2e_write_regs(priv, reg, , 1);
 }
diff --git a/drivers/media/dvb-frontends/cxd2841er.c 
b/drivers/media/dvb-frontends/cxd2841er.c
index ce37dc2e89c7..6b851a948ce0 100644
--- a/drivers/media/dvb-frontends/cxd2841er.c
+++ b/drivers/media/dvb-frontends/cxd2841er.c
@@ -258,7 +258,7 @@ static int cxd2841er_write_regs(struct cxd2841er_priv *priv,
return 0;
 }
 
-static int cxd2841er_write_reg(struct cxd2841er_priv *priv,
+static noinline_if_stackbloat int cxd2841er_write_reg(struct cxd2841er_priv 
*priv,
   u8 addr, u8 reg, u8 val)
 {
return cxd2841er_write_regs(priv, addr, reg, , 1);
@@ -306,7 +306,7 @@ static int cxd2841er_read_regs(struct cxd2841er_priv *priv,
return 0;
 }
 
-static int cxd2841er_read_reg(struct cxd2841er_priv *priv,
+static noinline_if_stackbloat int cxd2841er_read_reg(struct cxd2841er_priv 
*priv,
  u8 addr, u8 reg, u8 *val)
 {
return cxd2841er_read_regs(priv, addr, reg, val, 1);
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c 
b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 14040c915dbb..ec5b13ca630b 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -1516,7 +1516,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr 
*dev_addr,
 *
 **/
 
-static int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr,
+static noinline_if_stackbloat int drxdap_fasi_read_reg16(struct 
i2c_device_addr *dev_addr,
 u32 addr,
 u16 *data, u32 flags)
 {
@@ -1549,7 +1549,7 @@ static int drxdap_fasi_read_reg16(struct i2c_device_addr 
*dev_addr,
 *
 **/
 
-static int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr,
+static noinline_if_stackbloat int drxdap_fasi_read_reg32(struct 
i2c_device_addr *dev_addr,
 u32 addr,
 u32 *data, u32 flags)
 {
@@ -1722,7 +1722,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr 
*dev_addr,
 *
 **/
 
-static int drxdap_fasi_write_reg16(struct i2c_device_addr *dev_addr,
+static noinline_if_stackbloat int drxdap_fasi_write_reg16(struct 
i2c_device_addr *dev_addr,
  u32 addr,
  u16 data, u32 flags)
 {
@@ -1795,7 +1795,7 @@ static 

[PATCH v3 00/11] bring back stack frame warning with KASAN

2017-06-22 Thread Arnd Bergmann
This is a new version of patches I originally submitted back in
March [1], this time reducing the size of the series even further.

This minimal set of patches only makes sure that we do get
frame size warnings in allmodconfig for x86_64 and arm64 again,
even with KASAN enabled.

The changes this time are reduced to:

- I'm introducing "noinline_if_stackbloat" and use it in a number
  of places that suffer from inline functions with local variables
  - netlink, as used in various parts of the kernel
  - a number of drivers/media drivers
  - a handful of wireless network drivers
- a rework for the brcmsmac driver
- -fsanitize-address-use-after-scope is moved to a separate
  CONFIG_KASAN_EXTRA option that increases the warning limit
- CONFIG_KASAN_EXTRA is disabled with CONFIG_COMPILE_TEST,
  improving compile speed and disabling code that leads to
  valid warnings on gcc-7.0.1
- kmemcheck conflicts with CONFIG_KASAN_EXTRA

Compared to the version 1, I no longer have patches
to fix all the CONFIG_KASAN_EXTRA warnings:

- READ_ONCE/WRITE_ONCE cause problems in lots of code
- typecheck() causes huge problems in a few places
- many more uses of noinline_if_stackbloat

And compared to version 2, I have rewritten the vt-keyboard
patch based on feedback, and made KMEMCHECK mutually exclusive
with KASAN (rather than KASAN_EXTRA), everything else remains
unchanged.

This series lets us add back a stack frame warning for the regular
2048 bytes without CONFIG_KASAN_EXTRA. I set the warning limit with
KASAN_EXTRA to 3072, since I have an additional set of patches
to address all files that surpass that limit. We can debate whether
we want to apply those as a follow-up, or instead remove the option
entirely.

Another follow-up series I have reduces the warning limit with
KASAN to 1536, and without KASAN to 1280 for 64-bit architectures.

I hope that Andrew can pick up the entire series for mmotm, and
we can eventually backport most of it to stable kernels and
address the warnings that kernelci still reports for this problem [2].

 Arnd

[1] https://lkml.org/lkml/2017/3/2/508
[2] https://kernelci.org/build/id/593f89a659b51463306b958d/logs/

Arnd Bergmann (11):
  compiler: introduce noinline_if_stackbloat annotation
  netlink: mark nla_put_{u8,u16,u32} noinline_if_stackbloat
  rocker: mark rocker_tlv_put_* functions as noinline_if_stackbloat
  mtd: cfi: reduce stack size with KASAN
  dvb-frontends: reduce stack size in i2c access
  r820t: mark register functions as noinline_if_stackbloat
  tty: improve tty_insert_flip_char() fast path
  brcmsmac: make some local variables 'static const' to reduce stack
size
  brcmsmac: split up wlc_phy_workarounds_nphy
  brcmsmac: reindent split functions
  kasan: rework Kconfig settings

 drivers/media/dvb-frontends/ascot2e.c  |3 +-
 drivers/media/dvb-frontends/cxd2841er.c|4 +-
 drivers/media/dvb-frontends/drx39xyj/drxj.c|   14 +-
 drivers/media/dvb-frontends/helene.c   |4 +-
 drivers/media/dvb-frontends/horus3a.c  |2 +-
 drivers/media/dvb-frontends/itd1000.c  |2 +-
 drivers/media/dvb-frontends/mt312.c|2 +-
 drivers/media/dvb-frontends/si2165.c   |   14 +-
 drivers/media/dvb-frontends/stb0899_drv.c  |2 +-
 drivers/media/dvb-frontends/stb6100.c  |2 +-
 drivers/media/dvb-frontends/stv0367.c  |2 +-
 drivers/media/dvb-frontends/stv090x.c  |2 +-
 drivers/media/dvb-frontends/stv6110.c  |2 +-
 drivers/media/dvb-frontends/stv6110x.c |2 +-
 drivers/media/dvb-frontends/tda8083.c  |2 +-
 drivers/media/dvb-frontends/zl10039.c  |2 +-
 drivers/media/tuners/r820t.c   |4 +-
 drivers/mtd/chips/cfi_cmdset_0020.c|8 +-
 drivers/net/ethernet/rocker/rocker_tlv.h   |   24 +-
 .../broadcom/brcm80211/brcmsmac/phy/phy_n.c| 1856 ++--
 drivers/tty/tty_buffer.c   |   24 +
 include/linux/compiler.h   |   11 +
 include/linux/mtd/map.h|8 +-
 include/linux/tty_flip.h   |3 +-
 include/net/netlink.h  |   36 +-
 lib/Kconfig.debug  |4 +-
 lib/Kconfig.kasan  |   11 +-
 lib/Kconfig.kmemcheck  |1 +
 scripts/Makefile.kasan |3 +
 29 files changed, 1009 insertions(+), 1045 deletions(-)

-- 
2.9.0



Re: [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info

2017-06-22 Thread David Miller
From: Haiyang Zhang 
Date: Wed, 21 Jun 2017 16:40:46 -0700

> From: Haiyang Zhang 
> 
> We simply use rndis_device->link_state in the netdev_dbg. The variable,
> link_state from struct netvsc_device_info, is not used anywhere else.
> 
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: Stephen Hemminger 

Applied.


Re: [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off

2017-06-22 Thread David Miller
From: Haiyang Zhang 
Date: Wed, 21 Jun 2017 16:40:47 -0700

> From: Haiyang Zhang 
> 
> When the VF NIC is opened, the synthetic NIC's carrier state is set to
> off. This tells the host to transitions data path to the VF device. But
> if startup script or user manipulates the admin state of the netvsc
> device directly for example:
> # ifconfig eth0 down
>   # ifconfig eth0 up
> Then the carrier state of the synthetic NIC would be on, even though the
> data path was still over the VF NIC. This patch sets the carrier state
> of synthetic NIC with consideration of the related VF state.
> 
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: Stephen Hemminger 

Applied.


Re: [PATCH net] sfc: Fix MCDI command size for filter operations

2017-06-22 Thread David Miller
From: Martin Habets 
Date: Thu, 22 Jun 2017 10:50:41 +0100

> The 8000 series adapters uses catch-all filters for encapsulated traffic
> to support filtering VXLAN, NVGRE and GENEVE traffic.
> This new filter functionality requires a longer MCDI command.
> This patch increases the size of buffers on stack that were missed, which
> fixes a kernel panic from the stack protector.
> 
> Fixes: 9b41080125176 ("sfc: insert catch-all filters for encapsulated 
> traffic")
> Signed-off-by: Martin Habets 
> Acked-by: Edward Cree 
> Acked-by: Bert Kenward bkenw...@solarflare.com

Applied and queued up for -stable.


  1   2   >