Re: [PATCH 2/3] ARM: dts: stm32f429: Add Ethernet support

2016-03-02 Thread Alexandre Torgue
Hi Maxime,

2016-03-01 18:24 GMT+01:00 Maxime Coquelin :
> Hi Alex,
>
> I have made a handful of changes on your patch, let me know if this is
> ok for you.
> If ok, it will be part of the PR I'll send tomorrow.

I agree with modifications.

Regards

alex

>
> On 02/29/2016 05:29 PM, Alexandre TORGUE wrote:
>>
>> Add Ethernet support (Synopsys MAC IP 3.50a) on stm32f429 SOC.
>>
>> Signed-off-by: Alexandre TORGUE 
>>
>> diff --git a/arch/arm/boot/dts/stm32f429.dtsi
>> b/arch/arm/boot/dts/stm32f429.dtsi
>> index bb7a736..af0367c 100644
>> --- a/arch/arm/boot/dts/stm32f429.dtsi
>> +++ b/arch/arm/boot/dts/stm32f429.dtsi
>> @@ -283,6 +283,26 @@
>> bias-disable;
>> };
>> };
>> +
>> +   ethernet0_mii: mii@0 {
>> +   mii {
>> +   slew-rate = <2>;
>
> I moved slew-rate property below the pinmux one for consistency with other
> pin configs in the file.
>>
>> +   pinmux =
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ,
>> +
>> ;
>> +   };
>> +   };
>> };
>> rcc: rcc@40023810 {
>> @@ -323,6 +343,21 @@
>> st,mem2mem;
>> };
>>   + ethernet0: dwmac@40028000 {
>> +   compatible = "st,stm32-dwmac", "snps,dwmac-3.50a";
>> +   status = "disabled";
>
> I moved status property at the end of the node for consistency
>>
>> +   reg = <0x40028000 0x8000>;
>> +   reg-names = "stmmaceth";
>> +   interrupts = <0 61 0>, <0 62 0>;
>
> #interrupt-cells is set to 1 in the nvic node, meaning that a single cell is
> expected here:
>
> interrupts = <61>, <62>;
>
>> +   interrupt-names = "macirq", "eth_wake_irq";
>> +   clock-names = "stmmaceth", "tx-clk", "rx-clk";
>> +   clocks = <&rcc 0 25>, <&rcc 0 26>, <&rcc 0 27>;
>> +   st,syscon = <&syscfg 0x4>;
>> +   snps,pbl = <8>;
>> +   snps,mixed-burst;
>> +   dma-ranges;
>> +   };
>> +
>> rng: rng@50060800 {
>> compatible = "st,stm32-rng";
>> reg = <0x50060800 0x400>;
>
>
> Regards,
> Maxime
>
>


RE: [PATCH] can: rcar_canfd: Add Renesas R-Car CAN FD driver

2016-03-02 Thread Ramesh Shanmugasundaram
Hi Marc,

Thanks for the review.

> On 03/01/2016 10:34 AM, Ramesh Shanmugasundaram wrote:
> > This patch adds support for the CAN FD controller found in Renesas
> > R-Car SoCs. The controller operates in CAN FD mode by default. Two
> > test modes are available and can be enabled by the
> > "rcar_canfd.testmode" module parameter. Refer to Documentation/kernel-
> parameters.txt.
> 
> Is the channel loopback mode configurable per channel? If so, please
> remove the module parameter and make use of CAN_CTRLMODE_LOOPBACK to
> configure it.

The loopback setting is not truly a per channel attribute. It requires touching 
Rx rules which can be done only when the controller's global state is reset 
(during probe). CAN_CTRLMODE_LOOPBACK config option is possible only through 
.ndo_open of that channel but the global controller state needs to be 
operational by this time. As it is a global attribute & for the above reason, I 
choose the module option.

> 
> > CAN FD mode supports both Classical CAN & CAN FD frame formats. The
> > controller supports ISO 11898-1:2015 CAN FD format only.
> >
> > This controller supports two channels and the driver can enable either
> > or both of the channels.
> >
> > Driver uses Rx FIFOs (one per channel) for reception & Common FIFOs
> > (one per channel) for transmission. Rx filter rules are configured to
> > the minimum (one per channel) and it accepts Standard, Extended, Data
> > & Remote Frame combinations.
> 
> I see no locking for the tx-path.
 
I am not sure why locking is needed in tx-path? 
However, looking at it again, I should move the incrementing of head after the 
"sts" handing to be apt. What do you think?

Thanks,
Ramesh


RE: [PATCH] can: rcar_canfd: Add Renesas R-Car CAN FD driver

2016-03-02 Thread Ramesh Shanmugasundaram
Hi Oliver,

Thanks for the review.

> On 03/01/2016 10:34 AM, Ramesh Shanmugasundaram wrote:
> > This patch adds support for the CAN FD controller found in Renesas
> > R-Car SoCs. The controller operates in CAN FD mode by default. Two
> > test modes are available and can be enabled by the
> > "rcar_canfd.testmode" module parameter. Refer to Documentation/kernel-
> parameters.txt.
> 
> (..)
> 
> > +#ifdef CONFIG_DEBUG_FS
> > +#include 
> > +
> > +static int rcar_canfd_showregs(struct seq_file *s, void *data) {
> > +   struct rcar_canfd_channel *priv = s->private;
> > +   u32 ch = priv->channel;
> > +   u32 rf = ch + RCANFD_RFFIFO_IDX;
> > +   u32 cf = RCANFD_CFFIFO_IDX;
> > +   u32 val, offset, i;
> > +
> > +   if (testmode)
> > +   seq_printf(s, "RCANFD : testmode = %d\n", testmode);
> > +   seq_printf(s, "RCANFD register dump: channel %u\n", ch);
> > +   seq_printf(s, "%-40s: %x\n", "g: cfg",
> > +  rcar_canfd_read(priv, RCANFD_GCFG));
> 
> Why do you think you would need this kind of register dumps in debugfs?
> 
> This could be interesting for development purposes - but in production
> drivers this is pretty unusual and needless.

I thought it would be useful when we add more features to the driver (e.g. 
Gateway mode).
 
> 
> I would sugest to remove either the testmode (already suggested by Marc)
> and this register dump stuff.

OK. I'll remove both.

Thanks,
Ramesh


Re: net/sctp: sock memory leak

2016-03-02 Thread Dmitry Vyukov
On Fri, Jan 15, 2016 at 8:11 PM, Dmitry Vyukov  wrote:
> On Fri, Jan 15, 2016 at 7:46 PM, Marcelo Ricardo Leitner
>  wrote:
>> On Wed, Dec 30, 2015 at 09:42:27PM +0100, Dmitry Vyukov wrote:
>>> Hello,
>>>
>>> The following program leads to a leak of two sock objects:
>> ...
>>>
>>> On commit 8513342170278468bac126640a5d2d12ffbff106 (Dec 28).
>>
>> I'm afraid I cannot reproduce this one?
>> I enabled dynprintk at sctp_destroy_sock and it does print twice when I
>> run this test app.
>> Also added debugs to check association lifetime, and then it was
>> destroyed. Same for endpoint.
>>
>> Checking with trace-cmd, both calls to sctp_close() resulted in
>> sctp_destroy_sock() being called.
>>
>> As for sock_hold/put, they are matched too.
>>
>> Ideas? Log is below for double checking
>
>
> Hummm... I can reproduce it pretty reliably.
>
> [  197.459024] kmemleak: 11 new suspected memory leaks (see
> /sys/kernel/debug/kmemleak)
> [  307.494874] kmemleak: 409 new suspected memory leaks (see
> /sys/kernel/debug/kmemleak)
> [  549.784022] kmemleak: 125 new suspected memory leaks (see
> /sys/kernel/debug/kmemleak)
>
> I double checked via /proc/slabinfo:
>
> SCTPv6  4373   4420   2368   138 : tunables00
>   0 : slabdata340340  0
>
> SCTPv6 starts with almost 0, but grows infinitely while I run the
> program in a loop.
>
> Here is my SCTP related configs:
>
> CONFIG_IP_SCTP=y
> CONFIG_NET_SCTPPROBE=y
> CONFIG_SCTP_DBG_OBJCNT=y
> # CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5 is not set
> # CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1 is not set
> CONFIG_SCTP_DEFAULT_COOKIE_HMAC_NONE=y
> # CONFIG_SCTP_COOKIE_HMAC_MD5 is not set
> # CONFIG_SCTP_COOKIE_HMAC_SHA1 is not set
>
> I am on commit 67990608c8b95d2b8ccc29932376ae73d5818727 and I don't
> seem to have any sctp-related changes on top.


Still happens on 4.5-rc6.

Marcelo, try to apply my config (if yours differs), run the program in
a parallel loop and check /proc/slabinfo (or kmemleak).


Re: [PATCH 1/2] net: ethernet: renesas: ravb_main: don't open code of_device_get_match_data()

2016-03-02 Thread Geert Uytterhoeven
On Tue, Mar 1, 2016 at 5:37 PM, Wolfram Sang  wrote:
> From: Wolfram Sang 
>
> This change will also make Coverity happy by avoiding a theoretical NULL
> pointer dereference; yet another reason is to use the above helper function
> to tighten the code and make it more readable.
>
> Signed-off-by: Wolfram Sang 

Acked-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH net-next] sh_eth, ravb: Use ARCH_RENESAS

2016-03-02 Thread Geert Uytterhoeven
On Wed, Mar 2, 2016 at 2:28 AM, Simon Horman  wrote:
> Make use of ARCH_RENESAS in place of ARCH_SHMOBILE.
>
> This is part of an ongoing process to migrate from ARCH_SHMOBILE to
> ARCH_RENESAS the motivation for which being that RENESAS seems to be a more
> appropriate name than SHMOBILE for the majority of Renesas ARM based SoCs.
>
> Signed-off-by: Simon Horman 

Acked-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] can: rcar_canfd: Add Renesas R-Car CAN FD driver

2016-03-02 Thread Marc Kleine-Budde
On 03/02/2016 09:41 AM, Ramesh Shanmugasundaram wrote:
>> Is the channel loopback mode configurable per channel? If so, please
>> remove the module parameter and make use of CAN_CTRLMODE_LOOPBACK to
>> configure it.
> 
> The loopback setting is not truly a per channel attribute. It
> requires touching Rx rules which can be done only when the
> controller's global state is reset (during probe).
> CAN_CTRLMODE_LOOPBACK config option is possible only through
> .ndo_open of that channel but the global controller state needs to be
> operational by this time. As it is a global attribute & for the above
> reason, I choose the module option.

I see, ok then.

>>> CAN FD mode supports both Classical CAN & CAN FD frame formats. The
>>> controller supports ISO 11898-1:2015 CAN FD format only.
>>>
>>> This controller supports two channels and the driver can enable either
>>> or both of the channels.
>>>
>>> Driver uses Rx FIFOs (one per channel) for reception & Common FIFOs
>>> (one per channel) for transmission. Rx filter rules are configured to
>>> the minimum (one per channel) and it accepts Standard, Extended, Data
>>> & Remote Frame combinations.
>>
>> I see no locking for the tx-path.
>  
> I am not sure why locking is needed in tx-path? 

If the tx-path is shared between both channels you need locking as the
networking subsystem may send one frame to each controller at the same time.

> However, looking at it again, I should move the incrementing of head
> after the "sts" handing to be apt. What do you think?

With one producer (one SW instance) and one consumer (the HW) you can
write lockless code (if the HW allows it), but with two producers it's
not possible.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH] net: mellanox: add DEVLINK dependencies

2016-03-02 Thread Arnd Bergmann
The new NET_DEVLINK infrastructure can be a loadable module, but the drivers
using it might be built-in, which causes link errors like:

drivers/net/built-in.o: In function `mlx4_load_one':
:(.text+0x2fbfda): undefined reference to `devlink_port_register'
:(.text+0x2fc084): undefined reference to `devlink_port_unregister'
drivers/net/built-in.o: In function `mlxsw_sx_port_remove':
:(.text+0x33a03a): undefined reference to `devlink_port_type_clear'
:(.text+0x33a04e): undefined reference to `devlink_port_unregister'

There are multiple ways to avoid this:

a) add 'depends on NET_DEVLINK || !NET_DEVLINK' dependencies
   for each user
b) use 'select NET_DEVLINK' from each driver that uses it
   and hide the symbol in Kconfig.
c) make NET_DEVLINK a 'bool' option so we don't have to
   list it as a dependency, and rely on the APIs to be
   stubbed out when it is disabled
d) use IS_REACHABLE() rather than IS_ENABLED() to check for
   NET_DEVLINK in include/net/devlink.h

This implements a variation of approach a) by adding an
intermediate symbol that drivers can depend on, and changes
the three drivers using it.

Signed-off-by: Arnd Bergmann 
Fixes: 09d4d087cd48 ("mlx4: Implement devlink interface")
Fixes: c4745500e988 ("mlxsw: Implement devlink interface")
---
 drivers/infiniband/hw/mlx4/Kconfig  | 1 +
 drivers/net/ethernet/mellanox/mlx4/Kconfig  | 1 +
 drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 +
 net/Kconfig | 9 +
 4 files changed, 12 insertions(+)

diff --git a/drivers/infiniband/hw/mlx4/Kconfig 
b/drivers/infiniband/hw/mlx4/Kconfig
index fc01deac1d3c..db4aa13ebae0 100644
--- a/drivers/infiniband/hw/mlx4/Kconfig
+++ b/drivers/infiniband/hw/mlx4/Kconfig
@@ -1,6 +1,7 @@
 config MLX4_INFINIBAND
tristate "Mellanox ConnectX HCA support"
depends on NETDEVICES && ETHERNET && PCI && INET
+   depends on MAY_USE_DEVLINK
select NET_VENDOR_MELLANOX
select MLX4_CORE
---help---
diff --git a/drivers/net/ethernet/mellanox/mlx4/Kconfig 
b/drivers/net/ethernet/mellanox/mlx4/Kconfig
index 1486ce902a56..9ca3734ebb6b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx4/Kconfig
@@ -4,6 +4,7 @@
 
 config MLX4_EN
tristate "Mellanox Technologies 1/10/40Gbit Ethernet support"
+   depends on MAY_USE_DEVLINK
depends on PCI
select MLX4_CORE
select PTP_1588_CLOCK
diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig 
b/drivers/net/ethernet/mellanox/mlxsw/Kconfig
index ce26adcb4988..2ad7f67854d5 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig
@@ -4,6 +4,7 @@
 
 config MLXSW_CORE
tristate "Mellanox Technologies Switch ASICs support"
+   depends on MAY_USE_DEVLINK
---help---
  This driver supports Mellanox Technologies Switch ASICs family.
 
diff --git a/net/Kconfig b/net/Kconfig
index 6c9cfb0d7639..2760825e53fa 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -403,6 +403,15 @@ config NET_DEVLINK
  infrastructure to support access to physical chip-wide config and
  monitoring.
 
+config MAY_USE_DEVLINK
+   tristate
+   default m if NET_DEVLINK=m
+   default y if NET_DEVLINK=y || NET_DEVLINK=n
+   help
+ Drivers using the devlink infrastructure should have a dependency
+ on MAY_USE_DEVLINK to ensure they do not cause link errors when
+ devlink is a loadable module and the driver using it is built-in.
+
 endif   # if NET
 
 # Used by archs to tell that they support BPF_JIT
-- 
2.7.0



RE: [PATCH] can: rcar_canfd: Add Renesas R-Car CAN FD driver

2016-03-02 Thread Ramesh Shanmugasundaram
Hi Marc,

> On 03/02/2016 09:41 AM, Ramesh Shanmugasundaram wrote:
> >> Is the channel loopback mode configurable per channel? If so, please
> >> remove the module parameter and make use of CAN_CTRLMODE_LOOPBACK to
> >> configure it.
> >
> > The loopback setting is not truly a per channel attribute. It requires
> > touching Rx rules which can be done only when the controller's global
> > state is reset (during probe).
> > CAN_CTRLMODE_LOOPBACK config option is possible only through .ndo_open
> > of that channel but the global controller state needs to be
> > operational by this time. As it is a global attribute & for the above
> > reason, I choose the module option.
> 
> I see, ok then.
> 
> >>> CAN FD mode supports both Classical CAN & CAN FD frame formats. The
> >>> controller supports ISO 11898-1:2015 CAN FD format only.
> >>>
> >>> This controller supports two channels and the driver can enable
> >>> either or both of the channels.
> >>>
> >>> Driver uses Rx FIFOs (one per channel) for reception & Common FIFOs
> >>> (one per channel) for transmission. Rx filter rules are configured
> >>> to the minimum (one per channel) and it accepts Standard, Extended,
> >>> Data & Remote Frame combinations.
> >>
> >> I see no locking for the tx-path.
> >
> > I am not sure why locking is needed in tx-path?
> 
> If the tx-path is shared between both channels you need locking as the
> networking subsystem may send one frame to each controller at the same
> time.

Yes. Tx completion interrupt is shared by both channels but the Tx FIFO, echo 
skbs, head, tail are maintained on a per channel basis. 
Yes, net subsystem can send one frame to each channel at the same time and the 
tx completion interrupt handler will traverse each channel & update per channel 
context accordingly.

> > However, looking at it again, I should move the incrementing of head
> > after the "sts" handing to be apt. What do you think?
> 
> With one producer (one SW instance) and one consumer (the HW) you can
> write lockless code (if the HW allows it), but with two producers it's not
> possible.

For a channel represented as netdev, there is still one producer (one SW 
instance) isn't it? net acquires lock before calling xmit. The consumer is tx 
completion interrupt handler which updates per channel attributes only.

Sorry if I am annoying. I have tested this with two channels transmitting & 
receiving at the same time and it works fine. If I am missing lock, I would 
like to understand it thoroughly before making the change.

Thanks for the help,
Ramesh.


Re: [PATCH] net: mellanox: add DEVLINK dependencies

2016-03-02 Thread Jiri Pirko
Wed, Mar 02, 2016 at 10:40:54AM CET, a...@arndb.de wrote:
>The new NET_DEVLINK infrastructure can be a loadable module, but the drivers
>using it might be built-in, which causes link errors like:
>
>drivers/net/built-in.o: In function `mlx4_load_one':
>:(.text+0x2fbfda): undefined reference to `devlink_port_register'
>:(.text+0x2fc084): undefined reference to `devlink_port_unregister'
>drivers/net/built-in.o: In function `mlxsw_sx_port_remove':
>:(.text+0x33a03a): undefined reference to `devlink_port_type_clear'
>:(.text+0x33a04e): undefined reference to `devlink_port_unregister'
>
>There are multiple ways to avoid this:
>
>a) add 'depends on NET_DEVLINK || !NET_DEVLINK' dependencies
>   for each user
>b) use 'select NET_DEVLINK' from each driver that uses it
>   and hide the symbol in Kconfig.
>c) make NET_DEVLINK a 'bool' option so we don't have to
>   list it as a dependency, and rely on the APIs to be
>   stubbed out when it is disabled
>d) use IS_REACHABLE() rather than IS_ENABLED() to check for
>   NET_DEVLINK in include/net/devlink.h
>
>This implements a variation of approach a) by adding an
>intermediate symbol that drivers can depend on, and changes
>the three drivers using it.

Approach a) looks like the best. Thanks for taking care of this.

>
>Signed-off-by: Arnd Bergmann 

Acked-by: Jiri Pirko 


[patch] net: moxa: fix an error code

2016-03-02 Thread Dan Carpenter
We accidentally return IS_ERR(priv->base) which is 1 instead of
PTR_ERR(priv->base) which is the error code.

Fixes: 6c821bd9edc9 ('net: Add MOXA ART SoCs ethernet driver')
Signed-off-by: Dan Carpenter 

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 00cfd95..3e67f45 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -474,9 +474,9 @@ static int moxart_mac_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ndev->base_addr = res->start;
priv->base = devm_ioremap_resource(p_dev, res);
-   ret = IS_ERR(priv->base);
-   if (ret) {
+   if (IS_ERR(priv->base)) {
dev_err(p_dev, "devm_ioremap_resource failed\n");
+   ret = PTR_ERR(priv->base);
goto init_fail;
}
 


Re: [PATCH] can: rcar_canfd: Add Renesas R-Car CAN FD driver

2016-03-02 Thread Marc Kleine-Budde
On 03/02/2016 11:08 AM, Ramesh Shanmugasundaram wrote:
 I see no locking for the tx-path.
>>>
>>> I am not sure why locking is needed in tx-path?
>>
>> If the tx-path is shared between both channels you need locking as the
>> networking subsystem may send one frame to each controller at the same
>> time.
> 
> Yes. Tx completion interrupt is shared by both channels but the Tx
> FIFO, echo skbs, head, tail are maintained on a per channel basis. 
> Yes, net subsystem can send one frame to each channel at the same
> time and the tx completion interrupt handler will traverse each
> channel & update per channel context accordingly.

Ok. Which instruction starts the transmit? Please add a comment to the
code. You stop the tx_queue after this, so your code is racy, as the
interrupt might happen in between.

>>> However, looking at it again, I should move the incrementing of head
>>> after the "sts" handing to be apt. What do you think?
>>
>> With one producer (one SW instance) and one consumer (the HW) you can
>> write lockless code (if the HW allows it), but with two producers it's not
>> possible.
> 
> For a channel represented as netdev, there is still one producer (one
> SW instance) isn't it? net acquires lock before calling xmit. The
> consumer is tx completion interrupt handler which updates per channel
> attributes only.

Ok - I haven't looked at the code in depth yet. Now it's clear, that
just the tx interrupt is shared.

> Sorry if I am annoying. I have tested this with two channels
> transmitting & receiving at the same time and it works fine. If I am
> missing lock, I would like to understand it thoroughly before making
> the change.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 3/4] net: can: ifi: Fix RX and TX ID mask

2016-03-02 Thread Marek Vasut
On 03/02/2016 07:10 AM, Oliver Hartkopp wrote:
> Hi Marek,
> 
> On 03/01/2016 10:23 PM, Marek Vasut wrote:
>> On 03/01/2016 06:49 PM, Oliver Hartkopp wrote:
> 
> 
 -#define IFI_CANFD_RXFIFO_ID_ID_STD_MASK   0x3ff
 +#define IFI_CANFD_RXFIFO_ID_ID_STD_MASK   0x7ff
  #define IFI_CANFD_RXFIFO_ID_ID_XTD_MASK   0x1fff
>>>
>>> You should use the CAN_SFF_MASK and CAN_EFF_MASK in your code instead of
>>> defining you private IFI_CANFD_RXFIFO_ID_ID_?TD_MASK definitions.
>>>
>>> You won't have trapped into this problem then :-)
>>
>> These are register bitfield definitions, so should I really ?
>>
>> My OCD kicks in and tells me it'd be odd and inconsistent with the rest
>> of the bitfields, but if you prefer it that way, I'll just send an
>> updated patch.
>>
> 
> Your bit mask is masking the CAN ID out of a given variable.
> That's what CAN_SFF_MASK and CAN_EFF_MASK is made for.
> 
> So at least it should be:
> 
> #define IFI_CANFD_RXFIFO_ID_ID_STD_MASK   CAN_SFF_MASK
> #define IFI_CANFD_RXFIFO_ID_ID_XTD_MASK   CAN_EFF_MASK

This is good, I will do this. Thanks!

> Btw. These defines are _never_ referenced in ifi_canfd.c so they should be
> removed anyway.

The documentation for this core is not available, so if you don't mind,
I'd like to keep those.

-- 
Best regards,
Marek Vasut


Re: [PATCH 2/4] net: can: ifi: Fix TX DLC configuration

2016-03-02 Thread Marek Vasut
On 03/02/2016 07:12 AM, Oliver Hartkopp wrote:
> 
> 
> On 03/01/2016 10:27 PM, Marek Vasut wrote:
>> On 03/01/2016 07:11 PM, Oliver Hartkopp wrote:
>>
>> Hi!
>>
>>> On 02/29/2016 08:59 PM, Marek Vasut wrote:
 The TX DLC, the transmission length information, was not written
 into the transmit configuration register. When using the CAN core
 with different CAN controller, the receiving CAN controller will
 receive only the ID part of the CAN frame, but no data at all.

 This patch adds the TX DLC into the register to fix this issue.

 Signed-off-by: Marek Vasut 
 Cc: Marc Kleine-Budde 
 Cc: Mark Rutland 
 Cc: Oliver Hartkopp 
 Cc: Wolfgang Grandegger 
 ---
  drivers/net/can/ifi_canfd/ifi_canfd.c | 5 +
  1 file changed, 5 insertions(+)

 diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
 b/drivers/net/can/ifi_canfd/ifi_canfd.c
 index 72f5205..82a33bd 100644
 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c
 +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
 @@ -774,10 +774,15 @@ static netdev_tx_t ifi_canfd_start_xmit(struct 
 sk_buff *skb,
  
if (priv->can.ctrlmode & (CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO)) {
if (can_is_canfd_skb(skb)) {
 +  txdlc |= can_len2dlc(cf->len);
txdlc |= IFI_CANFD_TXFIFO_DLC_EDL;
if (cf->flags & CANFD_BRS)
txdlc |= IFI_CANFD_TXFIFO_DLC_BRS;
 +  } else {
 +  txdlc |= cf->len;
}
 +  } else {
 +  txdlc |= cf->len;
}
>>>
>>> Please use
>>>
>>> txdlc |= can_len2dlc(cf->len);
>>>
>>> by default (it works for CAN and CAN FD).
>>>
>>> So that it looks more like:
>>>
>>> txdlc |= can_len2dlc(cf->len);
>>
>> Roger.
>>
>>> if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) {
>>> txdlc |= IFI_CANFD_TXFIFO_DLC_EDL;
>>> if (cf->flags & CANFD_BRS)
>>> txdlc |= IFI_CANFD_TXFIFO_DLC_BRS;
>>> }
>>>
>>> Testing against CAN_CTRLMODE_FD_NON_ISO is wrong!
>>> This configuration bit is just for the protocol on the wire and is no
>>> distinction for CAN / CAN FD.
>>
>> So CAN_CTRLMODE_FD is always set if the system operates in CAN/FD mode.
> 
> Not the 'system' but this specific CAN netdevice.

Ooops, of course, sorry.

>> And in addition to that, if the system operates in CAN/FD BOSCH mode,
>> the CAN_CTRLMODE_FD_NON_ISO is set. Do I understand it correctly ?
> 
> Yep! ('the CAN netdev')

Thanks for the clarification!

-- 
Best regards,
Marek Vasut


[PATCH V2 2/4] net: can: ifi: Fix TX DLC configuration

2016-03-02 Thread Marek Vasut
The TX DLC, the transmission length information, was not written
into the transmit configuration register. When using the CAN core
with different CAN controller, the receiving CAN controller will
receive only the ID part of the CAN frame, but no data at all.

This patch adds the TX DLC into the register to fix this issue.

Signed-off-by: Marek Vasut 
Cc: Marc Kleine-Budde 
Cc: Mark Rutland 
Cc: Oliver Hartkopp 
Cc: Wolfgang Grandegger 
---
V2: - Use can_len2dlc() unconditionally to sanitize DLC in the TX path
- The CAN_CTRLMODE_CANFD_NON_ISO can only ever be set if the
  CANFD_CTRLMODE_CANFD is set. Use only the later for checking
  if the core transmits in CANFD mode.
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 72f5205..4bbc7d9 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -772,12 +772,11 @@ static netdev_tx_t ifi_canfd_start_xmit(struct sk_buff 
*skb,
txid = cf->can_id & CAN_SFF_MASK;
}
 
-   if (priv->can.ctrlmode & (CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO)) {
-   if (can_is_canfd_skb(skb)) {
-   txdlc |= IFI_CANFD_TXFIFO_DLC_EDL;
-   if (cf->flags & CANFD_BRS)
-   txdlc |= IFI_CANFD_TXFIFO_DLC_BRS;
-   }
+   txdlc |= can_len2dlc(cf->len);
+   if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) {
+   txdlc |= IFI_CANFD_TXFIFO_DLC_EDL;
+   if (cf->flags & CANFD_BRS)
+   txdlc |= IFI_CANFD_TXFIFO_DLC_BRS;
}
 
if (cf->can_id & CAN_RTR_FLAG)
-- 
2.7.0



[PATCH V2 0/4] Synchronise IFI CANFD driver with real world

2016-03-02 Thread Marek Vasut
Thus far, this driver was only tested on a hardware synthesised in
the warm and safe insides of an FPGA, only against another IFI CANFD
core. The real hardware arrived now and I tested the IFI CANFD driver
against different, harsh, real-world CAN controller.

This uncovered a few bugs, so here are the fixes for those.

Marek Vasut (4):
  net: can: ifi: Fix clock generator configuration
  net: can: ifi: Fix TX DLC configuration
  net: can: ifi: Fix RX and TX ID mask
  net: can: ifi: Add obscure bit swap for EFF frame IDs

 drivers/net/can/ifi_canfd/ifi_canfd.c | 93 ++-
 1 file changed, 60 insertions(+), 33 deletions(-)

V2: Address comments in the ML

-- 
2.7.0



[PATCH 4/4] net: can: ifi: Add obscure bit swap for EFF frame IDs

2016-03-02 Thread Marek Vasut
In case of CAN2.0 EFF frame, the controller handles frame IDs in a
rather bizzare way. The ID is split into an extended part, IDX[28:11]
and standard part, ID[10:0]. In the TX path, the core first sends the
top 11 bits of the IDX, followed by ID and finally the rest of IDX.
In the RX path, the core stores the ID the LSbit part of IDX field,
followed by the LSbit parts of real IDX. The MSbit parts of IDX are
stored in ID field of the register.

This patch implements the necessary bit shuffling to mitigate this
obscure behavior. In case two of these controllers are connected
together, the RX and TX bit swapping nullifies itself and the issue
does not manifest. The issue only manifests when talking to another
different CAN controller.

Signed-off-by: Marek Vasut 
Cc: Marc Kleine-Budde 
Cc: Mark Rutland 
Cc: Oliver Hartkopp 
Cc: Wolfgang Grandegger 
---
V2: Rebase on top of patch 3/4, no change to the patch
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 238dd02..a55f080 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -136,7 +136,11 @@
 #define IFI_CANFD_RXFIFO_ID0x6c
 #define IFI_CANFD_RXFIFO_ID_ID_OFFSET  0
 #define IFI_CANFD_RXFIFO_ID_ID_STD_MASKCAN_SFF_MASK
+#define IFI_CANFD_RXFIFO_ID_ID_STD_OFFSET  0
+#define IFI_CANFD_RXFIFO_ID_ID_STD_WIDTH   10
 #define IFI_CANFD_RXFIFO_ID_ID_XTD_MASKCAN_EFF_MASK
+#define IFI_CANFD_RXFIFO_ID_ID_XTD_OFFSET  11
+#define IFI_CANFD_RXFIFO_ID_ID_XTD_WIDTH   18
 #define IFI_CANFD_RXFIFO_ID_IDEBIT(29)
 
 #define IFI_CANFD_RXFIFO_DATA  0x70/* 0x70..0xac */
@@ -157,7 +161,11 @@
 #define IFI_CANFD_TXFIFO_ID0xbc
 #define IFI_CANFD_TXFIFO_ID_ID_OFFSET  0
 #define IFI_CANFD_TXFIFO_ID_ID_STD_MASKCAN_SFF_MASK
+#define IFI_CANFD_TXFIFO_ID_ID_STD_OFFSET  0
+#define IFI_CANFD_TXFIFO_ID_ID_STD_WIDTH   10
 #define IFI_CANFD_TXFIFO_ID_ID_XTD_MASKCAN_EFF_MASK
+#define IFI_CANFD_TXFIFO_ID_ID_XTD_OFFSET  11
+#define IFI_CANFD_TXFIFO_ID_ID_XTD_WIDTH   18
 #define IFI_CANFD_TXFIFO_ID_IDEBIT(29)
 
 #define IFI_CANFD_TXFIFO_DATA  0xc0/* 0xb0..0xfc */
@@ -229,10 +237,20 @@ static void ifi_canfd_read_fifo(struct net_device *ndev)
 
rxid = readl(priv->base + IFI_CANFD_RXFIFO_ID);
id = (rxid >> IFI_CANFD_RXFIFO_ID_ID_OFFSET);
-   if (id & IFI_CANFD_RXFIFO_ID_IDE)
+   if (id & IFI_CANFD_RXFIFO_ID_IDE) {
id &= IFI_CANFD_RXFIFO_ID_ID_XTD_MASK;
-   else
+   /*
+* In case the Extended ID frame is received, the standard
+* and extended part of the ID are swapped in the register,
+* so swap them back to obtain the correct ID.
+*/
+   id = (id >> IFI_CANFD_RXFIFO_ID_ID_XTD_OFFSET) |
+((id & IFI_CANFD_RXFIFO_ID_ID_STD_MASK) <<
+  IFI_CANFD_RXFIFO_ID_ID_XTD_WIDTH);
+   id |= CAN_EFF_FLAG;
+   } else {
id &= IFI_CANFD_RXFIFO_ID_ID_STD_MASK;
+   }
cf->can_id = id;
 
if (rxdlc & IFI_CANFD_RXFIFO_DLC_ESI) {
@@ -767,6 +785,15 @@ static netdev_tx_t ifi_canfd_start_xmit(struct sk_buff 
*skb,
 
if (cf->can_id & CAN_EFF_FLAG) {
txid = cf->can_id & CAN_EFF_MASK;
+   /*
+* In case the Extended ID frame is transmitted, the
+* standard and extended part of the ID are swapped
+* in the register, so swap them back to send the
+* correct ID.
+*/
+   txid = (txid >> IFI_CANFD_TXFIFO_ID_ID_XTD_WIDTH) |
+  ((txid & IFI_CANFD_TXFIFO_ID_ID_XTD_MASK) <<
+IFI_CANFD_TXFIFO_ID_ID_XTD_OFFSET);
txid |= IFI_CANFD_TXFIFO_ID_IDE;
} else {
txid = cf->can_id & CAN_SFF_MASK;
-- 
2.7.0



[PATCH 3/4] net: can: ifi: Fix RX and TX ID mask

2016-03-02 Thread Marek Vasut
The RX and TX ID mask for CAN2.0 is 11 bits wide. This patch fixes
the incorrect mask, which caused the CAN IDs to miss the MSBit both
on receive and transmit.

Signed-off-by: Marek Vasut 
Cc: Marc Kleine-Budde 
Cc: Mark Rutland 
Cc: Oliver Hartkopp 
Cc: Wolfgang Grandegger 
---
V2: Use CAN_SFF_MASK instead of plain bitfield
Use CAN_EFF_MASK for the extended frame format
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 4bbc7d9..238dd02 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -135,8 +135,8 @@
 
 #define IFI_CANFD_RXFIFO_ID0x6c
 #define IFI_CANFD_RXFIFO_ID_ID_OFFSET  0
-#define IFI_CANFD_RXFIFO_ID_ID_STD_MASK0x3ff
-#define IFI_CANFD_RXFIFO_ID_ID_XTD_MASK0x1fff
+#define IFI_CANFD_RXFIFO_ID_ID_STD_MASKCAN_SFF_MASK
+#define IFI_CANFD_RXFIFO_ID_ID_XTD_MASKCAN_EFF_MASK
 #define IFI_CANFD_RXFIFO_ID_IDEBIT(29)
 
 #define IFI_CANFD_RXFIFO_DATA  0x70/* 0x70..0xac */
@@ -156,8 +156,8 @@
 
 #define IFI_CANFD_TXFIFO_ID0xbc
 #define IFI_CANFD_TXFIFO_ID_ID_OFFSET  0
-#define IFI_CANFD_TXFIFO_ID_ID_STD_MASK0x3ff
-#define IFI_CANFD_TXFIFO_ID_ID_XTD_MASK0x1fff
+#define IFI_CANFD_TXFIFO_ID_ID_STD_MASKCAN_SFF_MASK
+#define IFI_CANFD_TXFIFO_ID_ID_XTD_MASKCAN_EFF_MASK
 #define IFI_CANFD_TXFIFO_ID_IDEBIT(29)
 
 #define IFI_CANFD_TXFIFO_DATA  0xc0/* 0xb0..0xfc */
-- 
2.7.0



[PATCH 1/4] net: can: ifi: Fix clock generator configuration

2016-03-02 Thread Marek Vasut
The clock generation does not match reality when using the CAN IP
core outside of the FPGA design. This patch fixes the computation
of values which are programmed into the clock generator registers.

First, there are some off-by-one errors which manifest themselves
only when communicating with different controller, so those are
fixed.

Second, the bits in the clock generator registers have different
meaning depending on whether the core is in ISO CANFD mode or any
of the other modes (BOSCH CANFD or CAN2.0). Detect the ISO CANFD
mode and fix handling of this special case of clock configuration.

Finally, the CAN clock speed is in CANCLOCK register, not SYSCLOCK
register, so fix this as well.

Signed-off-by: Marek Vasut 
Cc: Marc Kleine-Budde 
Cc: Mark Rutland 
Cc: Oliver Hartkopp 
Cc: Wolfgang Grandegger 
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 43 ++-
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c 
b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 639868b..72f5205 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -514,25 +514,25 @@ static irqreturn_t ifi_canfd_isr(int irq, void *dev_id)
 
 static const struct can_bittiming_const ifi_canfd_bittiming_const = {
.name   = KBUILD_MODNAME,
-   .tseg1_min  = 2,/* Time segment 1 = prop_seg + phase_seg1 */
+   .tseg1_min  = 1,/* Time segment 1 = prop_seg + phase_seg1 */
.tseg1_max  = 64,
-   .tseg2_min  = 1,/* Time segment 2 = phase_seg2 */
-   .tseg2_max  = 16,
+   .tseg2_min  = 2,/* Time segment 2 = phase_seg2 */
+   .tseg2_max  = 64,
.sjw_max= 16,
-   .brp_min= 1,
-   .brp_max= 1024,
+   .brp_min= 2,
+   .brp_max= 256,
.brp_inc= 1,
 };
 
 static const struct can_bittiming_const ifi_canfd_data_bittiming_const = {
.name   = KBUILD_MODNAME,
-   .tseg1_min  = 2,/* Time segment 1 = prop_seg + phase_seg1 */
-   .tseg1_max  = 16,
-   .tseg2_min  = 1,/* Time segment 2 = phase_seg2 */
-   .tseg2_max  = 8,
-   .sjw_max= 4,
-   .brp_min= 1,
-   .brp_max= 32,
+   .tseg1_min  = 1,/* Time segment 1 = prop_seg + phase_seg1 */
+   .tseg1_max  = 64,
+   .tseg2_min  = 2,/* Time segment 2 = phase_seg2 */
+   .tseg2_max  = 64,
+   .sjw_max= 16,
+   .brp_min= 2,
+   .brp_max= 256,
.brp_inc= 1,
 };
 
@@ -545,32 +545,33 @@ static void ifi_canfd_set_bittiming(struct net_device 
*ndev)
u32 noniso_arg = 0;
u32 time_off;
 
-   if (priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) {
+   if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
+   time_off = IFI_CANFD_TIME_SJW_OFF_ISO;
+   } else {
noniso_arg = IFI_CANFD_TIME_SET_TIMEB_BOSCH |
 IFI_CANFD_TIME_SET_TIMEA_BOSCH |
 IFI_CANFD_TIME_SET_PRESC_BOSCH |
 IFI_CANFD_TIME_SET_SJW_BOSCH;
time_off = IFI_CANFD_TIME_SJW_OFF_BOSCH;
-   } else {
-   time_off = IFI_CANFD_TIME_SJW_OFF_ISO;
}
 
/* Configure bit timing */
-   brp = bt->brp - 1;
+   brp = bt->brp - 2;
sjw = bt->sjw - 1;
tseg1 = bt->prop_seg + bt->phase_seg1 - 1;
-   tseg2 = bt->phase_seg2 - 1;
+   tseg2 = bt->phase_seg2 - 2;
writel((tseg2 << IFI_CANFD_TIME_TIMEB_OFF) |
   (tseg1 << IFI_CANFD_TIME_TIMEA_OFF) |
   (brp << IFI_CANFD_TIME_PRESCALE_OFF) |
-  (sjw << time_off),
+  (sjw << time_off) |
+  noniso_arg,
   priv->base + IFI_CANFD_TIME);
 
/* Configure data bit timing */
-   brp = dbt->brp - 1;
+   brp = dbt->brp - 2;
sjw = dbt->sjw - 1;
tseg1 = dbt->prop_seg + dbt->phase_seg1 - 1;
-   tseg2 = dbt->phase_seg2 - 1;
+   tseg2 = dbt->phase_seg2 - 2;
writel((tseg2 << IFI_CANFD_TIME_TIMEB_OFF) |
   (tseg1 << IFI_CANFD_TIME_TIMEA_OFF) |
   (brp << IFI_CANFD_TIME_PRESCALE_OFF) |
@@ -847,7 +848,7 @@ static int ifi_canfd_plat_probe(struct platform_device 
*pdev)
 
priv->can.state = CAN_STATE_STOPPED;
 
-   priv->can.clock.freq = readl(addr + IFI_CANFD_SYSCLOCK);
+   priv->can.clock.freq = readl(addr + IFI_CANFD_CANCLOCK);
 
priv->can.bittiming_const   = &ifi_canfd_bittiming_const;
priv->can.data_bittiming_const  = &ifi_canfd_data_bittiming_const;
-- 
2.7.0



Re: [PATCH v2] ethtool: check size of user memory before copying strings and stats

2016-03-02 Thread Ben Hutchings
On Wed, 2016-03-02 at 01:11 +, Keller, Jacob E wrote:
> On Wed, 2016-03-02 at 00:12 +, Ben Hutchings wrote:
> > NAK, ethtool is not the only consumer of the ethtool API.  How many
> > times do I have to repeat myself?
> > 
> > Ben.
> > 
> 
> Ok, so essentially forcing drivers to require static sets for the
> various stats/strings/etc?

No, you can define a new and better statistics API.  There are many
limitations of the current API that could be addressed at the same
time, e.g. lack of units, lack of hierarchy in naming, lack of
distinction between counters and other statistics.

Ben.

> :(
> 
> Will have patches to cleanup fm10k for this then.
> 
> Regards,
> Jake
-- 
Ben Hutchings
Tomorrow will be cancelled due to lack of interest.


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


Re: [patch] net: moxa: fix an error code

2016-03-02 Thread Arnd Bergmann
On Wednesday 02 March 2016 13:11:10 Dan Carpenter wrote:
> We accidentally return IS_ERR(priv->base) which is 1 instead of
> PTR_ERR(priv->base) which is the error code.
> 
> Fixes: 6c821bd9edc9 ('net: Add MOXA ART SoCs ethernet driver')
> Signed-off-by: Dan Carpenter 

Acked-by: Arnd Bergmann 

nice catch!

> diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
> b/drivers/net/ethernet/moxa/moxart_ether.c
> index 00cfd95..3e67f45 100644
> --- a/drivers/net/ethernet/moxa/moxart_ether.c
> +++ b/drivers/net/ethernet/moxa/moxart_ether.c
> @@ -474,9 +474,9 @@ static int moxart_mac_probe(struct platform_device *pdev)
>   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   ndev->base_addr = res->start;
>   priv->base = devm_ioremap_resource(p_dev, res);
> - ret = IS_ERR(priv->base);
> - if (ret) {
> + if (IS_ERR(priv->base)) {
>   dev_err(p_dev, "devm_ioremap_resource failed\n");
> + ret = PTR_ERR(priv->base);
>   goto init_fail;
>   }

Did you find more of these?

it doesn't matter much either way, but if you do multiple such patches,
I'd suggest using a single PTR_ERR_OR_ZERO() instead of IS_ERR()+PTR_ERR().

I have found a couple of drivers in which that leads to better object
code, and avoids a warning about a possibly uninitialized variable
when the function gets inlined into another one (which won't happen
for this driver).

Arnd


Re: [net-next][PATCH v2 01/13] RDS: Drop stale iWARP RDMA transport

2016-03-02 Thread Or Gerlitz
On Mon, Feb 29, 2016 at 2:26 AM, santosh.shilim...@oracle.com
 wrote:
> On 2/28/16 11:51 AM, Or Gerlitz wrote:
>> On Sun, Feb 28, 2016 at 4:19 AM, Santosh Shilimkar 
>>  wrote:

>>> Signed-off-by: Santosh Shilimkar 
>>> Signed-off-by: Santosh Shilimkar 

>> Hi, just wondered if there's any special reason that all this series
>> carries double S.O.B signature line with your name appearing twice on
>> two different email addresses?

> Nothing special. I sign of all my patches with k.org id and have to
> keep Oracle id as well being a payed Oracle employee. ;-)

so the kernel logs are carrying forever either 64 or 55 bytes with
your 2nd signature
which are sort of not a must...

Or.


[PATCH] MAINTAINERS: add maintainer entry for FREESCALE FEC ethernet driver

2016-03-02 Thread Fugang Duan
Add a maintainer entry for FREESCALE FEC ethernet driver and add myself
as a maintainer.

Signed-off-by: Fugang Duan 
---
 MAINTAINERS | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0499f9e..4d4b18f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4552,6 +4552,15 @@ S:   Maintained
 F: drivers/net/ethernet/freescale/fs_enet/
 F: include/linux/fs_enet_pd.h
 
+FREESCALE IMX / MXC FEC DRIVER
+M: Fugang Duan 
+L: netdev@vger.kernel.org
+S: Maintained
+F: drivers/net/ethernet/freescale/fec_main.c
+F: drivers/net/ethernet/freescale/fec_ptp.c
+F: drivers/net/ethernet/freescale/fec.h
+F: Documentation/devicetree/bindings/net/fsl-fec.txt
+
 FREESCALE QUICC ENGINE LIBRARY
 L: linuxppc-...@lists.ozlabs.org
 S: Orphan
-- 
1.9.1



[PATCH] be2net: don't enable multicast flag in be_enable_if_filters() routine

2016-03-02 Thread Sathya Perla
From: Venkat Duvvuru 

When the interface is opened (in be_open()) the routine
be_enable_if_filters() must be called to switch on the basic filtering
capabilities of an interface that are not changed at run-time.
These include the flags UNTAGGED, BROADCAST and PASS_L3L4_ERRORS.
Other flags such as MULTICAST and PROMISC must be enabled later by
be_set_rx_mode() based on the state in the netdev/adapter struct.

be_enable_if_filters() routine is wrongly trying to enable MULTICAST flag
without checking the current adapter state. This can cause the RX_FILTER
cmds to the FW to fail.  This patch fixes this problem by only enabling
the basic filtering flags in be_enable_if_filters().

The VF must be able to issue RX_FILTER cmd with any filter flag, as long
as the PF allowed those flags (if_cap_flags) in the iface it provisioned
for the VF. This rule is applicable even when the VF doesn't have the
FILTMGMT privilege. There is a bug in BE3 FW that wrongly fails RX_FILTER
multicast programming cmds on VFs that don't have FILTMGMT privilege.
This patch also helps in insulating the VF driver from be_open failures due
to the FW bug. A fix for the BE3 FW issue will be available in
versions >= 11.0.283.0 and 10.6.334.0

Reported-by: Ivan Vecera 
Signed-off-by: Venkat Duvvuru 
Signed-off-by: Sathya Perla 
---
 drivers/net/ethernet/emulex/benet/be_cmds.h |  9 ++---
 drivers/net/ethernet/emulex/benet/be_main.c | 16 +---
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 241819b..6d9a8d7 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -622,10 +622,13 @@ enum be_if_flags {
 BE_IF_FLAGS_VLAN_PROMISCUOUS |\
 BE_IF_FLAGS_MCAST_PROMISCUOUS)
 
-#define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\
-   BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED)
+#define BE_IF_FILT_FLAGS_BASIC (BE_IF_FLAGS_BROADCAST | \
+   BE_IF_FLAGS_PASS_L3L4_ERRORS | \
+   BE_IF_FLAGS_UNTAGGED)
 
-#define BE_IF_ALL_FILT_FLAGS   (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS)
+#define BE_IF_ALL_FILT_FLAGS   (BE_IF_FILT_FLAGS_BASIC | \
+BE_IF_FLAGS_MULTICAST | \
+BE_IF_FLAGS_ALL_PROMISCUOUS)
 
 /* An RX interface is an object with one or more MAC addresses and
  * filtering capabilities. */
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index f99de36..db81e3d 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -125,6 +125,11 @@ static const char * const ue_status_hi_desc[] = {
"Unknown"
 };
 
+#define BE_VF_IF_EN_FLAGS  (BE_IF_FLAGS_UNTAGGED | \
+BE_IF_FLAGS_BROADCAST | \
+BE_IF_FLAGS_MULTICAST | \
+BE_IF_FLAGS_PASS_L3L4_ERRORS)
+
 static void be_queue_free(struct be_adapter *adapter, struct be_queue_info *q)
 {
struct be_dma_mem *mem = &q->dma_mem;
@@ -3537,7 +3542,7 @@ static int be_enable_if_filters(struct be_adapter 
*adapter)
 {
int status;
 
-   status = be_cmd_rx_filter(adapter, BE_IF_EN_FLAGS, ON);
+   status = be_cmd_rx_filter(adapter, BE_IF_FILT_FLAGS_BASIC, ON);
if (status)
return status;
 
@@ -3857,8 +3862,7 @@ static int be_vfs_if_create(struct be_adapter *adapter)
int status;
 
/* If a FW profile exists, then cap_flags are updated */
-   cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
-   BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
+   cap_flags = BE_VF_IF_EN_FLAGS;
 
for_all_vfs(adapter, vf_cfg, vf) {
if (!BE3_chip(adapter)) {
@@ -3874,10 +3878,8 @@ static int be_vfs_if_create(struct be_adapter *adapter)
}
}
 
-   en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED |
-   BE_IF_FLAGS_BROADCAST |
-   BE_IF_FLAGS_MULTICAST |
-   BE_IF_FLAGS_PASS_L3L4_ERRORS);
+   /* PF should enable IF flags during proxy if_create call */
+   en_flags = cap_flags & BE_VF_IF_EN_FLAGS;
status = be_cmd_if_create(adapter, cap_flags, en_flags,
  &vf_cfg->if_handle, vf + 1);
if (status)
-- 
2.4.1



RE: [PATCH] MAINTAINERS: add maintainer entry for FREESCALE FEC ethernet driver

2016-03-02 Thread Fugang Duan
From: Fugang Duan  Sent: Wednesday, March 02, 2016 5:25 PM
> To: da...@davemloft.net
> Cc: netdev@vger.kernel.org; Fugang Duan 
> Subject: [PATCH] MAINTAINERS: add maintainer entry for FREESCALE FEC
> ethernet driver
> 
> Add a maintainer entry for FREESCALE FEC ethernet driver and add myself as a
> maintainer.
> 
> Signed-off-by: Fugang Duan 
> ---

Hi David,

Recently, there have many fec Ethernet driver patches sent out review, to avoid 
introducing impact on fec driver stable for all i.MX platforms, I request to 
add myself as the driver maintainer for helping patch review.
Current the driver supports FEC and ENET controllers, support HW PTP for 
i.MX25/i.MX50/i.MX51/i.MX53/i.MX6x/i.MX7x/i.MX8x...There have some feature 
extensions in later chips. 
It is more convenient for us to test reviewing patches.

Regards,
Andy

>  MAINTAINERS | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0499f9e..4d4b18f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -4552,6 +4552,15 @@ S: Maintained
>  F:   drivers/net/ethernet/freescale/fs_enet/
>  F:   include/linux/fs_enet_pd.h
> 
> +FREESCALE IMX / MXC FEC DRIVER
> +M:   Fugang Duan 
> +L:   netdev@vger.kernel.org
> +S:   Maintained
> +F:   drivers/net/ethernet/freescale/fec_main.c
> +F:   drivers/net/ethernet/freescale/fec_ptp.c
> +F:   drivers/net/ethernet/freescale/fec.h
> +F:   Documentation/devicetree/bindings/net/fsl-fec.txt
> +
>  FREESCALE QUICC ENGINE LIBRARY
>  L:   linuxppc-...@lists.ozlabs.org
>  S:   Orphan
> --
> 1.9.1


Re: [PATCH net-next 1/8] net/flower: Introduce hardware offload support

2016-03-02 Thread Or Gerlitz
On Tue, Mar 1, 2016 at 7:01 PM, Jiri Pirko  wrote:
> Tue, Mar 01, 2016 at 05:49:27PM CET, a...@vadai.me wrote:
>>On Tue, Mar 01, 2016 at 03:47:19PM +0100, Jiri Pirko wrote:
>>> Tue, Mar 01, 2016 at 03:24:43PM CET, a...@vadai.me wrote:
>>> >This patch is based on a patch made by John Fastabend.

>>> >It adds support for offloading cls_flower.
>>> >A filter that is offloaded successfully by hardware, will not be added to
>>> >the hashtable and won't be processed by software.

>>> That is wrong. User should explicitly specify to not include rule into sw
>>> by SKIP_KERNEL flag (does not exist now, with John's recent patch we'll
>>> have only SKIP_HW). Please add that in this patchset.

>> Why? If a rule is offloaded, why would the user want to reprocess it by 
>> software?

>> If the user use SKIP_HW, it will be processed by SW. Else, the user
>> would want it to be processed by HW or fallback to SW. I don't
>> understand in which case the user would like to have it done twice.

> For example if you turn on the offloading by unsetting NETIF_F_HW_TC.
> Or if someone inserts skbs into rx path directly, for example pktgen.
> We need SKIP_KERNEL to be set by user, not implicit.

As discussed in netdev, we want to have three modes for TC offloads

1. SW only
2. HW only (and err if can't)
3. HW and if not supported fallback to SW

Now, from your reply, I understand we want a fourth mode

4. Both (HW and SW)

Do we agree that these four policies/modes make sense?

So you want #4 to be the default? can you elaborate why? note that for
the HW marking
case a "both" mode will be very inefficient, also for actions like
vlan push/pop, encap/decap, etc
the result will be just wrong... I don't think this should be the default.

Or.


[iproute PATCH 1/3] tc: pedit: Fix layered op parsing

2016-03-02 Thread Phil Sutter
After lookup of the layered op submodule, pedit would pass argv and argc
including the layered op identifier at first position which confused the
submodule parser. Fix this by calling NEXT_ARG() before calling the
parse_peopt() callback.

Signed-off-by: Phil Sutter 
---
 tc/m_pedit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 4fdd189d7d9c6..455e4ffd4b2bb 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -421,6 +421,7 @@ parse_munge(int *argc_p, char ***argv_p,struct tc_pedit_sel 
*sel)
p = get_pedit_kind(k);
if (NULL == p)
goto bad_val;
+   NEXT_ARG();
res = p->parse_peopt(&argc, &argv, sel,&tkey);
if (res < 0) {
fprintf(stderr,"bad pedit parsing\n");
-- 
2.7.2



[iproute PATCH 3/3] tc: pedit: Fix retain value for ihl adjustments

2016-03-02 Thread Phil Sutter
Since the IP Header Length field is just half a byte, adjust retain to
only match these bits so the Version field is not overwritten by
accident.

The whole concept is actually broken due to dependency on endianness
which pedit ignores.

Signed-off-by: Phil Sutter 
---
 tc/p_ip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/p_ip.c b/tc/p_ip.c
index 08fdbaa41fbf4..10e4bebc71d94 100644
--- a/tc/p_ip.c
+++ b/tc/p_ip.c
@@ -58,7 +58,7 @@ parse_ip(int *argc_p, char ***argv_p,struct tc_pedit_sel 
*sel,struct tc_pedit_ke
if (strcmp(*argv, "ihl") == 0) {
NEXT_ARG();
tkey->off = 0;
-   res = parse_cmd(&argc, &argv, 1, TU32,RU8,sel,tkey);
+   res = parse_cmd(&argc, &argv, 1, TU32,0x0f,sel,tkey);
goto done;
}
if (strcmp(*argv, "protocol") == 0) {
-- 
2.7.2



[iproute PATCH 2/3] tc: pedit: Fix parse_cmd()

2016-03-02 Thread Phil Sutter
This was horribly broken:
* pack_key8() and pack_key16() ...
  * missed to invert retain value when applying it to the mask,
  * did not sanitize val by ANDing it with retain,
  * and ignored the mask which is necessary for 'invert' command.
* pack_key16() did not convert mask to network byte order.
* Changing the retain value for 'invert' or 'retain' operation seems
  just plain wrong.
* While here, also got rid of unnecessary offset sanitization in
  pack_key32().
* Simplify code a bit by always assigning the local mask variable to
  tkey->mask before calling any of the pack_key*() variants.

Signed-off-by: Phil Sutter 
---
 tc/m_pedit.c | 23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 455e4ffd4b2bb..a314f482cd9c0 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -152,8 +152,6 @@ pack_key32(__u32 retain,struct tc_pedit_sel *sel,struct 
tc_pedit_key *tkey)
 
tkey->val = htonl(tkey->val & retain);
tkey->mask = htonl(tkey->mask | ~retain);
-   /* jamal remove this - it is not necessary given the if check above */
-   tkey->off &= ~3;
return pack_key(sel,tkey);
 }
 
@@ -176,11 +174,8 @@ pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct 
tc_pedit_key *tkey)
}
 
stride = 8 * ind;
-   tkey->val = htons(tkey->val);
-   tkey->val <<= stride;
-   tkey->mask <<= stride;
-   retain <<= stride;
-   tkey->mask = retain|m[ind];
+   tkey->val = htons(tkey->val & retain) << stride;
+   tkey->mask = (htons(tkey->mask | ~retain) << stride) | m[ind];
 
tkey->off &= ~3;
 
@@ -204,10 +199,8 @@ pack_key8(__u32 retain,struct tc_pedit_sel *sel,struct 
tc_pedit_key *tkey)
ind = tkey->off & 3;
 
stride = 8 * ind;
-   tkey->val <<= stride;
-   tkey->mask <<= stride;
-   retain <<= stride;
-   tkey->mask = retain|m[ind];
+   tkey->val = (tkey->val & retain) << stride;
+   tkey->mask = ((tkey->mask | ~retain) << stride) | m[ind];
 
tkey->off &= ~3;
 
@@ -268,13 +261,13 @@ parse_cmd(int *argc_p, char ***argv_p, __u32 len, int 
type,__u32 retain,struct t
o = 0x;
 
if (matches(*argv, "invert") == 0) {
-   retain = val = mask = o;
+   val = mask = o;
} else if (matches(*argv, "set") == 0) {
NEXT_ARG();
if (parse_val(&argc, &argv, &val, type))
return -1;
} else if (matches(*argv, "preserve") == 0) {
-   retain = mask = o;
+   retain = 0;
} else {
if (matches(*argv, "clear") != 0)
return -1;
@@ -290,19 +283,17 @@ parse_cmd(int *argc_p, char ***argv_p, __u32 len, int 
type,__u32 retain,struct t
}
 
tkey->val = val;
+   tkey->mask = mask;
 
if (len == 1) {
-   tkey->mask = 0xFF;
res = pack_key8(retain,sel,tkey);
goto done;
}
if (len == 2) {
-   tkey->mask = mask;
res = pack_key16(retain,sel,tkey);
goto done;
}
if (len == 4) {
-   tkey->mask = mask;
res = pack_key32(retain,sel,tkey);
goto done;
}
-- 
2.7.2



Re: [patch] net: moxa: fix an error code

2016-03-02 Thread Dan Carpenter
On Wed, Mar 02, 2016 at 11:52:29AM +0100, Arnd Bergmann wrote:
> Did you find more of these?
> 
> it doesn't matter much either way, but if you do multiple such patches,

One or two.  I already sent the fixes.  I think it was applied.

> I'd suggest using a single PTR_ERR_OR_ZERO() instead of IS_ERR()+PTR_ERR().
> 
> I have found a couple of drivers in which that leads to better object
> code, and avoids a warning about a possibly uninitialized variable
> when the function gets inlined into another one (which won't happen
> for this driver).

Huh?  I sent one where I could have done that but I deliberately didn't
because I wanted the uninitialized warning if I made a mistake.  It
sounds like you're working around a GCC bug...

regards,
dan carpenter


[iproute PATCH 0/3] tc: pedit fixes

2016-03-02 Thread Phil Sutter
While implementing an implementation example for a pedit man page, I
noticed several issues with the current code. The following patch
series addreses them.

In order to validate my changes, I implemented a simple unit tester.
It requires the following hack:

--8<-
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -513,6 +513,12 @@ parse_pedit(struct action_util *a, int *argc_p, char 
***argv_p, int tca_id, stru
}
}
 
+   fprintf(stderr, "mask=0x%x\n", sel.keys[0].mask);
+   fprintf(stderr, "val=0x%x\n", sel.keys[0].val);
+   fprintf(stderr, "off=0x%x\n", sel.keys[0].off);
+   fprintf(stderr, "at=0x%x\n", sel.keys[0].at);
+   fprintf(stderr, "offmask=0x%x\n", sel.keys[0].offmask);
+   fprintf(stderr, "shift=0x%x\n", sel.keys[0].shift);
tail = NLMSG_TAIL(n);
addattr_l(n, MAX_MSG, tca_id, NULL, 0);
addattr_l(n, MAX_MSG, TCA_PEDIT_PARMS,&sel, 
sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_pedit_key));
--8<-

With this in place, the following simple shell script can be used to
check generated permutation values:

--8<-
#!/bin/bash

run_tc() {
echo "testing $@"
eval "$(./tc/tc filter add dev bla123 parent root u32 \
match u32 0 0 action pedit munge $@ 2>&1 | \
grep -e '^\(mask\|val\|off\|at\|offmask\|shift\)=')"
}

prove() { # (oval, check, ooff)
local oval=$1
local check=$2
local ooff=$3
[[ $ooff -eq $off ]] || {
echo "Wrong offset ($off instead of $ooff)"
#exit 1
}
[[ $(((oval & mask) ^ val)) -eq $check ]] || {
echo "failed for $oval, should be $check but is 0x$(echo "obase 
= 16; $(((oval & mask) ^ val))" | bc)"
echo "mask=$mask"
echo "val=$val"
echo "off=$off"
echo "at=$at"
echo "offmask=$offmask"
echo "shift=$shift"
#exit 1
}
}

run_tc ip df set 0
prove 0x 0xffbf 4
prove 0x0040 0x 4
prove 0xffbf 0xffbf 4
prove 0x 0x 4

run_tc ip df set 0x40
prove 0x 0x 4
prove 0x0040 0x0040 4
prove 0xffbf 0x 4
prove 0x 0x0040 4

run_tc ip df preserve
prove 0x 0x 4
prove 0x0040 0x0040 4
prove 0xffbf 0xffbf 4
prove 0x 0x 4

run_tc ip df invert
prove 0x 0xffbf 4
prove 0x0040 0x 4
prove 0xffbf 0x 4
prove 0x 0x0040 4

run_tc ip mf set 0x20
prove 0xf2ff 0xf2ff 4
prove 0x00203000 0x00203000 4
prove 0xfadf 0xfaff 4
prove 0x 0x0020 4

run_tc ip ihl set 0x04
prove 0x 0xfff4 0
prove 0x0005 0x0004 0
prove 0xfff0 0xfff4 0
prove 0x 0x0004 0

run_tc ip tos set 0
prove 0x 0x00ff 0
prove 0x2300 0x 0
prove 0x00ff 0x00ff 0
prove 0x 0x 0

run_tc ip tos set 17
prove 0x 0x11ff 0
prove 0x2300 0x1100 0
prove 0x00ff 0x11ff 0
prove 0x 0x1100 0

run_tc ip tos invert
prove 0x 0x00ff 0
prove 0x2300 0xDC00 0
prove 0x00ff 0x 0
prove 0x 0xff00 0

run_tc ip tos preserve
prove 0x 0x 0
prove 0x2300 0x2300 0
prove 0x00ff 0x00ff 0
prove 0x 0x 0

run_tc ip tos clear
prove 0x 0x00ff 0
prove 0x2300 0x 0
prove 0x00ff 0x00ff 0
prove 0x 0x 0

run_tc ip dport set 0
prove 0x 0x 20
prove 0x1234 0x 20
prove 0x 0x 20
prove 0x 0x 20

run_tc ip dport set 27374
prove 0xf22f 0xee6af22f 20
prove 0x12340010 0xee6a0010 20
prove 0xee6aff0f 0xee6aff0f 20
prove 0xee6a 0xee6a 20

run_tc ip dport invert
prove 0x 0x 20
prove 0x1234 0xEDCB 20
prove 0x 0x 20

run_tc ip dport preserve
prove 0x 0x 20
prove 0x1234 0x1234 20
prove 0xee6a 0xee6a 20
prove 0xee6a 0xee6a 20

run_tc ip dport clear
prove 0x3fff 0x3fff 20
prove 0x12340030 0x0030 20
prove 0xee6af1ff 0xf1ff 20
prove 0x 0x 20


run_tc ip src set 0.0.0.0
prove 0x3fff 0x 12
prove 0x12340030 0x 12
prove 0xee6af1ff 0x 12
prove 0x 0x 12

run_tc ip src set 1.2.3.4
prove 0x3fff 0x01020304 12
prove 0x12340030 0x01020304 12
prove 0xee6af1ff 0x01020304 12
prove 0x 0x01020304 12

run_tc ip src clear
prove 0x3fff 0x 12
prove 0x12340030 0x 12
prove 0xee6af1ff 0x 12
prove 0x 0x 12

run_tc ip src preserve
prove 0x3fff 0x3fff 12
prove 0x12340030 0x12340030 12
prove 0xee6af

Re: [patch] net: moxa: fix an error code

2016-03-02 Thread Arnd Bergmann
On Wednesday 02 March 2016 14:21:29 Dan Carpenter wrote:
> On Wed, Mar 02, 2016 at 11:52:29AM +0100, Arnd Bergmann wrote:
> > Did you find more of these?
> > 
> > it doesn't matter much either way, but if you do multiple such patches,
> 
> One or two.  I already sent the fixes.  I think it was applied.
> 
> > I'd suggest using a single PTR_ERR_OR_ZERO() instead of IS_ERR()+PTR_ERR().
> > 
> > I have found a couple of drivers in which that leads to better object
> > code, and avoids a warning about a possibly uninitialized variable
> > when the function gets inlined into another one (which won't happen
> > for this driver).
> 
> Huh?  I sent one where I could have done that but I deliberately didn't
> because I wanted the uninitialized warning if I made a mistake.  It
> sounds like you're working around a GCC bug...

The uninitialized warning here is about a type mismatch preventing
gcc from noticing that two conditions are the same, I'm not sure
if this is a bug in gcc, or required by the C standard.

I don't think there is a way in which you would hide a correct
warning about an uninitialized warning.

Have a look at
https://git.kernel.org/cgit/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=07cfdc3071432a07713e4d007c2811e0224490b0

in which get_leaf_nr() uses the IS_ERR()/PTR_ERR() combo to return
an error from a pointer, or return success when the pointer was set,
followed by a warning about the use of the pointer in another
function. My original patch avoided the warning by using IS_ERR_VALUE()
in the caller, but in retrospect, IS_ERR_OR_ZERO() would have been
a nicer solution:

@@ -783,12 +783,15 @@ static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
   u64 *leaf_out)
 {
__be64 *hash;
+   int error;
 
hash = gfs2_dir_get_hash_table(dip);
-   if (IS_ERR(hash))
-   return PTR_ERR(hash);
-   *leaf_out = be64_to_cpu(*(hash + index));
-   return 0;
+   error = PTR_ERR_OR_ZERO(hash);
+
+   if (!error)
+   *leaf_out = be64_to_cpu(*(hash + index));
+
+   return error;
 }

and I've used that elsewhere now when I ran into this kind of
false positive warning.

Arnd


Re: [patch] net: moxa: fix an error code

2016-03-02 Thread Dan Carpenter
On Wed, Mar 02, 2016 at 12:36:05PM +0100, Arnd Bergmann wrote:
> The uninitialized warning here is about a type mismatch preventing
> gcc from noticing that two conditions are the same, I'm not sure
> if this is a bug in gcc, or required by the C standard.

I wouldn't call it a bug, because everyone has to make trade offs
between how fast the program runs and how accurate it is.  And trade
offs between how ambitious your warnings are vs how many false positives
you can tolerate.

Anyway, I feel like we should just work around GCC on a case by case
basis instead of always using PTR_ERR_OR_ZERO().  The next version of
GCC will fix some false positives and introduce new ones...  Next time
using PTR_ERR_OR_ZERO() could cause warnings instead of fixing them.

Smatch works in a different way and it parse the code correctly.  But
Smatch is slow and sometimes runs out of memory and gives up trying to
parse large functions.  Smatch sees the two returns and tries to figure
out the implications of each (uninitialized vs initialized).  If you
change the code to:

error = PTR_ERR_OR_ZERO(hash);

if (!error)
*leaf_out = be64_to_cpu(*(hash + index));

return error;

then Smatch still breaks that up into two separate returns which imply
initialized vs uninitialized.

regards,
dan carpenter



Re: [patch] net: moxa: fix an error code

2016-03-02 Thread Arnd Bergmann
On Wednesday 02 March 2016 15:15:26 Dan Carpenter wrote:
> On Wed, Mar 02, 2016 at 12:36:05PM +0100, Arnd Bergmann wrote:
> > The uninitialized warning here is about a type mismatch preventing
> > gcc from noticing that two conditions are the same, I'm not sure
> > if this is a bug in gcc, or required by the C standard.
> 
> I wouldn't call it a bug, because everyone has to make trade offs
> between how fast the program runs and how accurate it is.  And trade
> offs between how ambitious your warnings are vs how many false positives
> you can tolerate.
> 
> Anyway, I feel like we should just work around GCC on a case by case
> basis instead of always using PTR_ERR_OR_ZERO().  The next version of
> GCC will fix some false positives and introduce new ones...  Next time
> using PTR_ERR_OR_ZERO() could cause warnings instead of fixing them.

It depends on whether we think the PTR_ERR_OR_ZERO() actually makes
the code more readable too. I've actually come to like it now,
the main downside being that it looks a lot like IS_ERR_OR_NULL()
which is very bad style and should be avoided at all cost. ;-)

I can also see how PTR_ERR_OR_ZERO() is easier for the compiler
to understand than IS_ERR()+PTR_ERR() and can't think of a case
where it would result in worse object code or extra (false
positive) warnings.

> Smatch works in a different way and it parse the code correctly.  But
> Smatch is slow and sometimes runs out of memory and gives up trying to
> parse large functions.  Smatch sees the two returns and tries to figure
> out the implications of each (uninitialized vs initialized).  If you
> change the code to:
> 
> error = PTR_ERR_OR_ZERO(hash);
> 
> if (!error)
> *leaf_out = be64_to_cpu(*(hash + index));
> 
> return error;
> 
> then Smatch still breaks that up into two separate returns which imply
> initialized vs uninitialized.

Right, so it does the right thing, and it presumably understands
that 'if (error)' is the same as 'if (error < 0)' and
'if (IS_ERR_VALUE(error)', right? I think that is where gcc
gets it wrong.

Arnd


[PATCH net 1/7] bnx2x: fix crash on big-endian when adding VLAN

2016-03-02 Thread Michal Schmidt
bnx2x crashes during the initialization of the 8021q module on ppc64.
The bug is a missing conversion from le32 in
bnx2x_handle_classification_eqe() when obtaining the cid value from
struct eth_event_data.

The fields in struct eth_event_data should all be declared as
little-endian and conversions added where missing.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h   |  6 +++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 13 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c |  9 -
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 27aa080..90a4dba 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -5207,9 +5207,9 @@ struct e2_integ_data {
  * set mac event data
  */
 struct eth_event_data {
-   u32 echo;
-   u32 reserved0;
-   u32 reserved1;
+   __le32 echo;
+   __le32 reserved0;
+   __le32 reserved1;
 };
 
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 6c4e3a6..b707ba8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -5280,14 +5280,14 @@ static void bnx2x_handle_classification_eqe(struct 
bnx2x *bp,
 {
unsigned long ramrod_flags = 0;
int rc = 0;
-   u32 cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
+   u32 echo = le32_to_cpu(elem->message.data.eth_event.echo);
+   u32 cid = echo & BNX2X_SWCID_MASK;
struct bnx2x_vlan_mac_obj *vlan_mac_obj;
 
/* Always push next commands out, don't wait here */
__set_bit(RAMROD_CONT, &ramrod_flags);
 
-   switch (le32_to_cpu((__force __le32)elem->message.data.eth_event.echo)
-   >> BNX2X_SWCID_SHIFT) {
+   switch (echo >> BNX2X_SWCID_SHIFT) {
case BNX2X_FILTER_MAC_PENDING:
DP(BNX2X_MSG_SP, "Got SETUP_MAC completions\n");
if (CNIC_LOADED(bp) && (cid == BNX2X_ISCSI_ETH_CID(bp)))
@@ -5308,8 +5308,7 @@ static void bnx2x_handle_classification_eqe(struct bnx2x 
*bp,
bnx2x_handle_mcast_eqe(bp);
return;
default:
-   BNX2X_ERR("Unsupported classification command: %d\n",
- elem->message.data.eth_event.echo);
+   BNX2X_ERR("Unsupported classification command: 0x%x\n", echo);
return;
}
 
@@ -5596,10 +5595,8 @@ static void bnx2x_eq_int(struct bnx2x *bp)
  BNX2X_STATE_OPENING_WAIT4_PORT):
case (EVENT_RING_OPCODE_RSS_UPDATE_RULES |
  BNX2X_STATE_CLOSING_WAIT4_HALT):
-   cid = elem->message.data.eth_event.echo &
-   BNX2X_SWCID_MASK;
DP(BNX2X_MSG_SP, "got RSS_UPDATE ramrod. CID %d\n",
-  cid);
+  SW_CID(elem->message.data.eth_event.echo));
rss_raw->clear_pending(rss_raw);
break;
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 9d02734..55fcc21 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -1672,11 +1672,12 @@ void bnx2x_vf_handle_classification_eqe(struct bnx2x 
*bp,
 {
unsigned long ramrod_flags = 0;
int rc = 0;
+   u32 echo = le32_to_cpu(elem->message.data.eth_event.echo);
 
/* Always push next commands out, don't wait here */
set_bit(RAMROD_CONT, &ramrod_flags);
 
-   switch (elem->message.data.eth_event.echo >> BNX2X_SWCID_SHIFT) {
+   switch (echo >> BNX2X_SWCID_SHIFT) {
case BNX2X_FILTER_MAC_PENDING:
rc = vfq->mac_obj.complete(bp, &vfq->mac_obj, elem,
   &ramrod_flags);
@@ -1686,8 +1687,7 @@ void bnx2x_vf_handle_classification_eqe(struct bnx2x *bp,
&ramrod_flags);
break;
default:
-   BNX2X_ERR("Unsupported classification command: %d\n",
- elem->message.data.eth_event.echo);
+   BNX2X_ERR("Unsupported classification command: 0x%x\n", echo);
return;
}
if (rc < 0)
@@ -1755,8 +1755,7 @@ int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union 
event_ring_elem *elem)
case EVENT_RING_OPCODE_MULTICAST_RULES:
case EVENT_RING_OPCODE_FILTERS_RULES:
case EVENT_RING_OPCODE_RSS_UPDATE_RULES:
-   cid = (elem->message.data.eth_event.echo &
-  BNX2X_SWCID_MASK);
+   cid = SW_CID(elem->message.data.eth_event.echo);
DP(BNX2X_MSG_IOV, "checking 

[PATCH net 0/7] bnx2x: endianness fixes

2016-03-02 Thread Michal Schmidt
Hello,
this fixes a VLAN crash and some SRIOV bugs in bnx2x observed on ppc64.

Michal Schmidt (7):
  bnx2x: fix crash on big-endian when adding VLAN
  bnx2x: fix sending VF->PF messages on big-endian
  bnx2x: fix receive of VF->PF mailbox messages by the PF on big-endian
  bnx2x: access cfc_del_event only if the opcode is CFC_DEL
  bnx2x: define fields of struct cfc_del_event_data as little-endian
  bnx2x: define event data reserved fields as little-endian
  bnx2x: fix indentation in bnx2x_sp_task()

 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h   | 36 ++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 22 +++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 12 
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c  |  4 +--
 4 files changed, 32 insertions(+), 42 deletions(-)

-- 
2.5.0



[PATCH net 2/7] bnx2x: fix sending VF->PF messages on big-endian

2016-03-02 Thread Michal Schmidt
When a VF is sending a message to the PF, it needs to trigger the PF
to tell it the message is ready.
The trigger did not work on ppc64. No interrupt appeared in the PF.

The bug is due to confusion about the layout of struct trigger_vf_zone.
In bnx2x_send_msg2pf() the trigger is written using writeb(), not
writel(), so the attempt to define the struct with a reversed layout on
big-endian is counter-productive.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 90a4dba..47b13ed 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -5114,15 +5114,9 @@ struct vf_pf_channel_zone_trigger {
  * zone that triggers the in-bound interrupt
  */
 struct trigger_vf_zone {
-#if defined(__BIG_ENDIAN)
-   u16 reserved1;
-   u8 reserved0;
-   struct vf_pf_channel_zone_trigger vf_pf_channel;
-#elif defined(__LITTLE_ENDIAN)
struct vf_pf_channel_zone_trigger vf_pf_channel;
u8 reserved0;
u16 reserved1;
-#endif
u32 reserved2;
 };
 
-- 
2.5.0



[PATCH net 6/7] bnx2x: define event data reserved fields as little-endian

2016-03-02 Thread Michal Schmidt
For consistency with other event data structs and to lessen
the chance of a mistake should one of the reserved fields become
used in the future, define the reserved fields as little-endian.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index a24909a..91874d2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -5224,9 +5224,9 @@ struct vf_pf_event_data {
 struct vf_flr_event_data {
u8 vf_id;
u8 reserved0;
-   u16 reserved1;
-   u32 reserved2;
-   u32 reserved3;
+   __le16 reserved1;
+   __le32 reserved2;
+   __le32 reserved3;
 };
 
 /*
@@ -5235,9 +5235,9 @@ struct vf_flr_event_data {
 struct malicious_vf_event_data {
u8 vf_id;
u8 err_id;
-   u16 reserved1;
-   u32 reserved2;
-   u32 reserved3;
+   __le16 reserved1;
+   __le32 reserved2;
+   __le32 reserved3;
 };
 
 /*
-- 
2.5.0



[PATCH net 3/7] bnx2x: fix receive of VF->PF mailbox messages by the PF on big-endian

2016-03-02 Thread Michal Schmidt
On ppc64 the PF did not receive messages from VFs correctly.

Fields of struct vf_pf_event_data are little-endian.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h  | 6 +++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 6 --
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 47b13ed..1058591 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -5213,9 +5213,9 @@ struct eth_event_data {
 struct vf_pf_event_data {
u8 vf_id;
u8 reserved0;
-   u16 reserved1;
-   u32 msg_addr_lo;
-   u32 msg_addr_hi;
+   __le16 reserved1;
+   __le32 msg_addr_lo;
+   __le32 msg_addr_hi;
 };
 
 /*
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 1374e53..bfae300 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -2187,8 +2187,10 @@ void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
 
/* Update VFDB with current message and schedule its handling */
mutex_lock(&BP_VFDB(bp)->event_mutex);
-   BP_VF_MBX(bp, vf_idx)->vf_addr_hi = vfpf_event->msg_addr_hi;
-   BP_VF_MBX(bp, vf_idx)->vf_addr_lo = vfpf_event->msg_addr_lo;
+   BP_VF_MBX(bp, vf_idx)->vf_addr_hi =
+   le32_to_cpu(vfpf_event->msg_addr_hi);
+   BP_VF_MBX(bp, vf_idx)->vf_addr_lo =
+   le32_to_cpu(vfpf_event->msg_addr_lo);
BP_VFDB(bp)->event_occur |= (1ULL << vf_idx);
mutex_unlock(&BP_VFDB(bp)->event_mutex);
 
-- 
2.5.0



[PATCH net 7/7] bnx2x: fix indentation in bnx2x_sp_task()

2016-03-02 Thread Michal Schmidt
Fix a case of misleading code indentation.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 9f5716a..2bf9c87 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -5682,7 +5682,7 @@ static void bnx2x_sp_task(struct work_struct *work)
if (status & BNX2X_DEF_SB_IDX) {
struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp);
 
-   if (FCOE_INIT(bp) &&
+   if (FCOE_INIT(bp) &&
(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
/* Prevent local bottom-halves from running as
 * we are going to change the local NAPI list.
-- 
2.5.0



[PATCH net 4/7] bnx2x: access cfc_del_event only if the opcode is CFC_DEL

2016-03-02 Thread Michal Schmidt
It's not really a bug, but it was odd that bnx2x_eq_int() read the
message data as if it were a cfc_del_event regardless of the event type.
It's cleaner to access only the appropriate member of union event_data
after checking the event opcode.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b707ba8..0e0bcbd 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -5477,9 +5477,6 @@ static void bnx2x_eq_int(struct bnx2x *bp)
goto next_spqe;
}
 
-   /* elem CID originates from FW; actually LE */
-   cid = SW_CID((__force __le32)
-elem->message.data.cfc_del_event.cid);
opcode = elem->message.opcode;
 
/* handle eq element */
@@ -5502,6 +5499,11 @@ static void bnx2x_eq_int(struct bnx2x *bp)
 * we may want to verify here that the bp state is
 * HALTING
 */
+
+   /* elem CID originates from FW; actually LE */
+   cid = SW_CID((__force __le32)
+elem->message.data.cfc_del_event.cid);
+
DP(BNX2X_MSG_SP,
   "got delete ramrod for MULTI[%d]\n", cid);
 
-- 
2.5.0



[PATCH net 5/7] bnx2x: define fields of struct cfc_del_event_data as little-endian

2016-03-02 Thread Michal Schmidt
There were no missing endianness conversions in this case, but the
fields of struct cfc_del_event_data should be defined as little-endian
to get rid of the ugly (__force __le32) casts.

Signed-off-by: Michal Schmidt 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h   | 6 +++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 3 +--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 1058591..a24909a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -4896,9 +4896,9 @@ struct c2s_pri_trans_table_entry {
  * cfc delete event data
  */
 struct cfc_del_event_data {
-   u32 cid;
-   u32 reserved0;
-   u32 reserved1;
+   __le32 cid;
+   __le32 reserved0;
+   __le32 reserved1;
 };
 
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0e0bcbd..9f5716a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -5501,8 +5501,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
 */
 
/* elem CID originates from FW; actually LE */
-   cid = SW_CID((__force __le32)
-elem->message.data.cfc_del_event.cid);
+   cid = SW_CID(elem->message.data.cfc_del_event.cid);
 
DP(BNX2X_MSG_SP,
   "got delete ramrod for MULTI[%d]\n", cid);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 55fcc21..632daff 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -1747,8 +1747,7 @@ int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union 
event_ring_elem *elem)
 
switch (opcode) {
case EVENT_RING_OPCODE_CFC_DEL:
-   cid = SW_CID((__force __le32)
-elem->message.data.cfc_del_event.cid);
+   cid = SW_CID(elem->message.data.cfc_del_event.cid);
DP(BNX2X_MSG_IOV, "checking cfc-del comp cid=%d\n", cid);
break;
case EVENT_RING_OPCODE_CLASSIFICATION_RULES:
-- 
2.5.0



Re: [PATCH net-next 1/8] net/flower: Introduce hardware offload support

2016-03-02 Thread Jiri Pirko
Wed, Mar 02, 2016 at 12:14:39PM CET, gerlitz...@gmail.com wrote:
>On Tue, Mar 1, 2016 at 7:01 PM, Jiri Pirko  wrote:
>> Tue, Mar 01, 2016 at 05:49:27PM CET, a...@vadai.me wrote:
>>>On Tue, Mar 01, 2016 at 03:47:19PM +0100, Jiri Pirko wrote:
 Tue, Mar 01, 2016 at 03:24:43PM CET, a...@vadai.me wrote:
 >This patch is based on a patch made by John Fastabend.
>
 >It adds support for offloading cls_flower.
 >A filter that is offloaded successfully by hardware, will not be added to
 >the hashtable and won't be processed by software.
>
 That is wrong. User should explicitly specify to not include rule into sw
 by SKIP_KERNEL flag (does not exist now, with John's recent patch we'll
 have only SKIP_HW). Please add that in this patchset.
>
>>> Why? If a rule is offloaded, why would the user want to reprocess it by 
>>> software?
>
>>> If the user use SKIP_HW, it will be processed by SW. Else, the user
>>> would want it to be processed by HW or fallback to SW. I don't
>>> understand in which case the user would like to have it done twice.
>
>> For example if you turn on the offloading by unsetting NETIF_F_HW_TC.
>> Or if someone inserts skbs into rx path directly, for example pktgen.
>> We need SKIP_KERNEL to be set by user, not implicit.
>
>As discussed in netdev, we want to have three modes for TC offloads
>
>1. SW only
>2. HW only (and err if can't)
>3. HW and if not supported fallback to SW
>
>Now, from your reply, I understand we want a fourth mode
>
>4. Both (HW and SW)

I would perhaps do it a litte bit differently:
NO FLAG (default)- insert into kernel and HW now:
if NETIF_F_HW_TC is off (default)
-> push to kernel only (current behaviour)
if NETIF_F_HW_TC is on AND push to HW fails
-> return error
SKIP_HW - flag to tell kernel not to insert into HW
SKIP_SW - flag to tell kernel not to insert into kernel

to achieve hw only, user has to turn on the NETIF_F_HW_TC and
pass SKIP_SW flag.


>
>Do we agree that these four policies/modes make sense?
>
>So you want #4 to be the default? can you elaborate why? note that for
>the HW marking
>case a "both" mode will be very inefficient, also for actions like
>vlan push/pop, encap/decap, etc

Well when you push/pop vlan of encap/decap tunnel header in hw, you won't
match the packet in kernel again. Most likely. But anyway, if you turn
on NETIF_F_HW_TC you know what you are doing and you adjust the
included rules (flags) accordingly.


>the result will be just wrong... I don't think this should be the default.
>
>Or.


pull-request: mac80211 2016-03-02

2016-03-02 Thread Johannes Berg
Hi Dave,

Here are a few more fixes for the current cycle; the MAINTAINERS patch
isn't really a fix for the tree, but helps the kbuild robot and clearly
can't be causing any regressions :)

Let me know if there's any problem.

Thanks,
johannes



The following changes since commit b86071528f3261ab592fad5b9b1a02aea3dcabf3:

  cfg80211: stop critical protocol session upon disconnect event (2016-02-23 
10:41:24 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211.git 
tags/mac80211-for-davem-2016-03-02

for you to fetch changes up to 2af8c4dc2e9c7038aefe9a822aa1df62e2b106b7:

  mac80211_hwsim: treat as part of mac80211 for MAINTAINERS (2016-03-02 
14:16:48 +0100)


Here are a few more fixes for the current cycle:
 * check GCMP encryption vs. fragmentation properly; we'd found
   this problem quite a while ago but waited for the 802.11 spec
   to be updated
 * fix RTS/CTS logic in minstrel_ht
 * fix RX of certain public action frames in AP mode
 * add mac80211_hwsim to MAC80211 in MAINTAINERS, this helps
   the kbuild robot pick up the right tree for it


Felix Fietkau (1):
  mac80211: minstrel_ht: fix a logic error in RTS/CTS handling

Johannes Berg (2):
  mac80211: check PN correctly for GCMP-encrypted fragmented MPDUs
  mac80211_hwsim: treat as part of mac80211 for MAINTAINERS

Jouni Malinen (1):
  mac80211: Fix Public Action frame RX in AP mode

 MAINTAINERS|  1 +
 net/mac80211/ieee80211_i.h |  2 +-
 net/mac80211/rc80211_minstrel_ht.c |  2 +-
 net/mac80211/rx.c  | 37 -
 4 files changed, 31 insertions(+), 11 deletions(-)


[PATCH] batman-adv: clarify CFG80211 dependency

2016-03-02 Thread Arnd Bergmann
The driver calls cfg80211_get_station, which may be part of a
module, so we must not enable BATMAN_ADV_BATMAN_V if
BATMAN_ADV=y and CFG80211=m:

net/built-in.o: In function `batadv_v_elp_get_throughput':
(text+0x5c62c): undefined reference to `cfg80211_get_station'

This clarifies the dependency to cover all combinations.

Signed-off-by: Arnd Bergmann 
Fixes: c833484e5f38 ("batman-adv: ELP - compute the metric based on the 
estimated throughput")
---
 net/batman-adv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index e651dc927bfd..f66930ee3c0b 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -17,7 +17,7 @@ config BATMAN_ADV
 
 config BATMAN_ADV_BATMAN_V
bool "B.A.T.M.A.N. V protocol (experimental)"
-   depends on BATMAN_ADV && CFG80211
+   depends on BATMAN_ADV && CFG80211=y || (CFG80211=m && BATMAN_ADV=m)
default n
help
  This option enables the B.A.T.M.A.N. V protocol, the successor
-- 
2.7.0



Re: [PATCH] wan: lmc: Switch to using managed resources

2016-03-02 Thread Amitoj Kaur Chawla
On Wed, Mar 2, 2016 at 3:51 AM, David Miller  wrote:
> From: Amitoj Kaur Chawla 
> Date: Sat, 27 Feb 2016 22:34:16 +0530
>
>> @@ -835,23 +835,20 @@ static int lmc_init_one(struct pci_dev *pdev, const 
>> struct pci_device_id *ent)
>>   err = pci_request_regions(pdev, "lmc");
>>   if (err) {
>>   printk(KERN_ERR "lmc: pci_request_region failed\n");
>> - goto err_req_io;
>> + return err;
>>   }
>>
>>   /*
>>* Allocate our own device structure
>>*/
>> - sc = kzalloc(sizeof(lmc_softc_t), GFP_KERNEL);
>> - if (!sc) {
>> - err = -ENOMEM;
>> - goto err_kzalloc;
>
> You can't get rid of the error paths from here on out, because you still need 
> to
> release the PCI regions obtained from pci_request_regions() above.
>
> To be quite honest, unless you are fixing real bugs, managed resource
> converstions are more likely to add bugs than do anything truly
> useful.
>
> I strongly consider you just drop this change.

Hi David,

I checked pcim_enable_device() before sending the patch, it has a call
to pcim_release() which does disabling of the PCI device and the
releasing of PCI regions obtained from pci_request_regions so there is
no need for pci_release_regions or pci_disable_device anymore.

Specifically, pcim_release contains the following code:

for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
  if (this->region_mask & (1 << i))
pci_release_region(dev, i);

Also, commit id add243d5bc371eef66f81c9da4fd4b55a18dad23 is a similar
change that further made me believe that the change is a correct one.

However, if you think I am wrong somewhere and I understood things
incorrectly, please correct me.

Thanks,
Amitoj


Re: RFC: blueprint for proxy PHY module

2016-03-02 Thread Tomas Hlavacek

Hi Andrew!

On Thu, Feb 25, 2016 at 4:31 PM, Andrew Lunn  wrote:

 Question is how to connect the userspace? I think that corresponding
 file in /sys would do the job, but I am not sure whether it is the
 proper way of doing that. (?)


A historian might be able to help you. Going back to the days of
10MBps Ethernet, cards used to have a few different ports, AUI, BNC
and TP. The kernel probably supports configuring which to use,
probably via ethtool. Your use case is not that different, so you can
probably reuse it.


Extending the ethtool ops in the driver (namely mvneta) seems to be 
possible and it seems that I could add more phy_dev pointers to the 
private data of the driver and switch among them quite easily. But it 
would be driver specific hack and I believe this problem is more 
general.


Perhaps I can pass some common PHY switch command from the driver to 
the prospective phy-proxy module. I'll come back to this question when 
I haveproof-of-concept code.


Btw. thanks for the pointer to the phylink patchset.

Tomas



Re: [PATCH] batman-adv: clarify CFG80211 dependency

2016-03-02 Thread Antonio Quartulli
On Wed, Mar 02, 2016 at 02:54:35PM +0100, Arnd Bergmann wrote:
> The driver calls cfg80211_get_station, which may be part of a
> module, so we must not enable BATMAN_ADV_BATMAN_V if
> BATMAN_ADV=y and CFG80211=m:
> 
> net/built-in.o: In function `batadv_v_elp_get_throughput':
> (text+0x5c62c): undefined reference to `cfg80211_get_station'
> 
> This clarifies the dependency to cover all combinations.
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: c833484e5f38 ("batman-adv: ELP - compute the metric based on the 
> estimated throughput")

Acked-by: Antonio Quartulli 

Thanks a lot Arnd!

David, could you please merge this change in net-next directly ?

Regards,

-- 
Antonio Quartulli


signature.asc
Description: Digital signature


Re: net_sched: dsmark: use qdisc_dequeue_peeked()

2016-03-02 Thread Sergei Shtylyov

Hello.

On 3/2/2016 7:10 AM, Kyeong Yoo wrote:


This fix is for dsmark similar to 3557619f0f6f7496ed453d4825e24958ab1884e0,


   scripts/checkpatch.pl now enforces certain commit citing format, yours 
doesn't match it.



and makes use of qdisc_dequeue_peeked() instead of direct dequeue() call.

First time, wrr peeks dsmark, which will then peek into sfq.
sfq dequeues an skb and it's stored in sch->gso_skb.
Next time, wrr tries to dequeue from dsmark, which will call sfq dequeue
directly. This results skipping the previously peeked skb.

So changed dsmark dequeue to call qdisc_dequeue_peeked() instead to use
peeked skb if exists.

Also replaced dsmark peek to use qdisc_peek_dequeued() which works correctly
if previously peeked skb still exists.

Signed-off-by: Kyeong Yoo 


[...]

MBR, Sergei



RE: [PATCH net-next V2 01/16] net: fec: only check queue 0 if RXF_0/TXF_0 interrupt is set

2016-03-02 Thread Fugang Duan
From: Troy Kisky  Sent: Thursday, February 25, 
2016 8:37 AM
> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
> johan...@sipsolutions.net; stillcompil...@gmail.com;
> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
> 
> Subject: [PATCH net-next V2 01/16] net: fec: only check queue 0 if
> RXF_0/TXF_0 interrupt is set
> 
> Before queue 0 was always checked if any queue caused an interrupt.
> It is better to just mark queue 0 if queue 0 has caused an interrupt.
> 
> Signed-off-by: Troy Kisky 
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index bad0ba2..dbac975 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1534,14 +1534,14 @@ fec_enet_collect_events(struct fec_enet_private
> *fep, uint int_events)
>   if (int_events == 0)
>   return false;
> 
> - if (int_events & FEC_ENET_RXF)
> + if (int_events & FEC_ENET_RXF_0)
>   fep->work_rx |= (1 << 2);
>   if (int_events & FEC_ENET_RXF_1)
>   fep->work_rx |= (1 << 0);
>   if (int_events & FEC_ENET_RXF_2)
>   fep->work_rx |= (1 << 1);
> 
> - if (int_events & FEC_ENET_TXF)
> + if (int_events & FEC_ENET_TXF_0)
>   fep->work_tx |= (1 << 2);
>   if (int_events & FEC_ENET_TXF_1)
>   fep->work_tx |= (1 << 0);
> --
> 2.5.0

Acked-by: Fugang Duan 


RE: [PATCH net-next V2 02/16] net: fec: pass rxq to fec_enet_rx_queue instead of queue_id

2016-03-02 Thread Fugang Duan
From: Troy Kisky  Sent: Thursday, February 25, 
2016 8:37 AM
> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
> johan...@sipsolutions.net; stillcompil...@gmail.com;
> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
> 
> Subject: [PATCH net-next V2 02/16] net: fec: pass rxq to fec_enet_rx_queue
> instead of queue_id
> 
> The queue_id is the qid member of struct bufdesc_prop.
> 
> Signed-off-by: Troy Kisky 
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 13 +
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index dbac975..9619b9e 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1328,11 +1328,9 @@ static bool fec_enet_copybreak(struct net_device
> *ndev, struct sk_buff **skb,
>   * not been given to the system, we just set the empty indicator,
>   * effectively tossing the packet.
>   */
> -static int
> -fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
> +static int fec_rxq(struct net_device *ndev, struct fec_enet_private *fep,
> +struct fec_enet_priv_rx_q *rxq, int budget)
>  {
> - struct fec_enet_private *fep = netdev_priv(ndev);
> - struct fec_enet_priv_rx_q *rxq;
>   struct bufdesc *bdp;
>   unsigned short status;
>   struct  sk_buff *skb_new = NULL;
> @@ -1350,8 +1348,6 @@ fec_enet_rx_queue(struct net_device *ndev, int
> budget, u16 queue_id)  #ifdef CONFIG_M532x
>   flush_cache_all();
>  #endif
> - queue_id = FEC_ENET_GET_QUQUE(queue_id);
> - rxq = fep->rx_queue[queue_id];
> 
>   /* First, grab all of the stats for the incoming packet.
>* These get messed up if we get called due to a busy condition.
> @@ -1519,11 +1515,12 @@ fec_enet_rx(struct net_device *ndev, int budget)
>   int pkt_received = 0;
>   u16 queue_id;
>   struct fec_enet_private *fep = netdev_priv(ndev);
> + struct fec_enet_priv_rx_q *rxq;
> 
>   for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS)
> {
>   clear_bit(queue_id, &fep->work_rx);
> - pkt_received += fec_enet_rx_queue(ndev,
> - budget - pkt_received, queue_id);
> + rxq = fep->rx_queue[FEC_ENET_GET_QUQUE(queue_id)];
> + pkt_received += fec_rxq(ndev, fep, rxq, budget -
> pkt_received);
>   }
>   return pkt_received;
>  }
> --
> 2.5.0

This is one clean up patch that you introduce struct bufdesc_prop.

Acked-by: Fugang Duan 


Re: [PATCH] MAINTAINERS: add maintainer entry for FREESCALE FEC ethernet driver

2016-03-02 Thread Zhi Li
On Wed, Mar 2, 2016 at 3:38 AM, Fugang Duan  wrote:
> From: Fugang Duan  Sent: Wednesday, March 02, 2016 5:25 
> PM
>> To: da...@davemloft.net
>> Cc: netdev@vger.kernel.org; Fugang Duan 
>> Subject: [PATCH] MAINTAINERS: add maintainer entry for FREESCALE FEC
>> ethernet driver
>>
>> Add a maintainer entry for FREESCALE FEC ethernet driver and add myself as a
>> maintainer.
>>
>> Signed-off-by: Fugang Duan 

Acked-by: Frank Li 

>> ---
>
> Hi David,
>
> Recently, there have many fec Ethernet driver patches sent out review, to 
> avoid introducing impact on fec driver stable for all i.MX platforms, I 
> request to add myself as the driver maintainer for helping patch review.
> Current the driver supports FEC and ENET controllers, support HW PTP for 
> i.MX25/i.MX50/i.MX51/i.MX53/i.MX6x/i.MX7x/i.MX8x...There have some 
> feature extensions in later chips.
> It is more convenient for us to test reviewing patches.
>
> Regards,
> Andy
>
>>  MAINTAINERS | 9 +
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 0499f9e..4d4b18f 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -4552,6 +4552,15 @@ S: Maintained
>>  F:   drivers/net/ethernet/freescale/fs_enet/
>>  F:   include/linux/fs_enet_pd.h
>>
>> +FREESCALE IMX / MXC FEC DRIVER
>> +M:   Fugang Duan 
>> +L:   netdev@vger.kernel.org
>> +S:   Maintained
>> +F:   drivers/net/ethernet/freescale/fec_main.c
>> +F:   drivers/net/ethernet/freescale/fec_ptp.c
>> +F:   drivers/net/ethernet/freescale/fec.h
>> +F:   Documentation/devicetree/bindings/net/fsl-fec.txt
>> +
>>  FREESCALE QUICC ENGINE LIBRARY
>>  L:   linuxppc-...@lists.ozlabs.org
>>  S:   Orphan
>> --
>> 1.9.1


[PATCH 1/2] rhashtable: accept GFP flags in rhashtable_walk_init

2016-03-02 Thread Bob Copeland
In certain cases, the 802.11 mesh pathtable code wants to
iterate over all of the entries in the forwarding table from
the receive path, which is inside an RCU read-side critical
section.  Enable walks inside atomic sections by allowing
GFP_ATOMIC allocations for the walker state.

Change all existing callsites to pass in GFP_KERNEL.

Cc: Thomas Graf 
Cc: netdev@vger.kernel.org
Acked-by: Thomas Graf 
Signed-off-by: Bob Copeland 
---
(-RFC, +Thomas's Ack)

 include/linux/rhashtable.h | 3 ++-
 lib/rhashtable.c   | 6 --
 net/ipv6/ila/ila_xlat.c| 3 ++-
 net/netfilter/nft_hash.c   | 4 ++--
 net/netlink/af_netlink.c   | 3 ++-
 net/sctp/proc.c| 3 ++-
 6 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index 63bd7601b6de..3eef0802a0cd 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -346,7 +346,8 @@ struct bucket_table *rhashtable_insert_slow(struct 
rhashtable *ht,
struct bucket_table *old_tbl);
 int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl);
 
-int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter);
+int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter,
+gfp_t gfp);
 void rhashtable_walk_exit(struct rhashtable_iter *iter);
 int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU);
 void *rhashtable_walk_next(struct rhashtable_iter *iter);
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index cc808707d1cf..5d845ffd7982 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -487,6 +487,7 @@ EXPORT_SYMBOL_GPL(rhashtable_insert_slow);
  * rhashtable_walk_init - Initialise an iterator
  * @ht:Table to walk over
  * @iter:  Hash table Iterator
+ * @gfp:   GFP flags for allocations
  *
  * This function prepares a hash table walk.
  *
@@ -504,14 +505,15 @@ EXPORT_SYMBOL_GPL(rhashtable_insert_slow);
  * You must call rhashtable_walk_exit if this function returns
  * successfully.
  */
-int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter)
+int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter,
+gfp_t gfp)
 {
iter->ht = ht;
iter->p = NULL;
iter->slot = 0;
iter->skip = 0;
 
-   iter->walker = kmalloc(sizeof(*iter->walker), GFP_KERNEL);
+   iter->walker = kmalloc(sizeof(*iter->walker), gfp);
if (!iter->walker)
return -ENOMEM;
 
diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
index 295ca29a23c3..0b03533453e4 100644
--- a/net/ipv6/ila/ila_xlat.c
+++ b/net/ipv6/ila/ila_xlat.c
@@ -501,7 +501,8 @@ static int ila_nl_dump_start(struct netlink_callback *cb)
struct ila_net *ilan = net_generic(net, ila_net_id);
struct ila_dump_iter *iter = (struct ila_dump_iter *)cb->args;
 
-   return rhashtable_walk_init(&ilan->rhash_table, &iter->rhiter);
+   return rhashtable_walk_init(&ilan->rhash_table, &iter->rhiter,
+   GFP_KERNEL);
 }
 
 static int ila_nl_dump_done(struct netlink_callback *cb)
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index 3f9d45d3d9b7..6fa016564f90 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -192,7 +192,7 @@ static void nft_hash_walk(const struct nft_ctx *ctx, const 
struct nft_set *set,
u8 genmask = nft_genmask_cur(read_pnet(&set->pnet));
int err;
 
-   err = rhashtable_walk_init(&priv->ht, &hti);
+   err = rhashtable_walk_init(&priv->ht, &hti, GFP_KERNEL);
iter->err = err;
if (err)
return;
@@ -248,7 +248,7 @@ static void nft_hash_gc(struct work_struct *work)
priv = container_of(work, struct nft_hash, gc_work.work);
set  = nft_set_container_of(priv);
 
-   err = rhashtable_walk_init(&priv->ht, &hti);
+   err = rhashtable_walk_init(&priv->ht, &hti, GFP_KERNEL);
if (err)
goto schedule;
 
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index c8416792cce0..6e0cbdeb21d3 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2335,7 +2335,8 @@ static int netlink_walk_start(struct nl_seq_iter *iter)
 {
int err;
 
-   err = rhashtable_walk_init(&nl_table[iter->link].hash, &iter->hti);
+   err = rhashtable_walk_init(&nl_table[iter->link].hash, &iter->hti,
+  GFP_KERNEL);
if (err) {
iter->link = MAX_LINKS;
return err;
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index cfc3c7101a38..c5991e5e5daf 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -319,7 +319,8 @@ static int sctp_transport_walk_start(struct seq_file *seq)
struct sctp_ht_iter *iter = seq->private;
int err;
 
-   err = rhashtable_walk_init(&sctp_transport_hashtable

[PATCH 2/2] mac80211: mesh: convert path table to rhashtable

2016-03-02 Thread Bob Copeland
In the time since the mesh path table was implemented as an
RCU-traversable, dynamically growing hash table, a generic RCU
hashtable implementation was added to the kernel.

Switch the mesh path table over to rhashtable to remove some code
and also gain some features like automatic shrinking.

Cc: Thomas Graf 
Cc: netdev@vger.kernel.org
Signed-off-by: Bob Copeland 
---
 net/mac80211/ieee80211_i.h  |  11 +-
 net/mac80211/mesh.c |   6 -
 net/mac80211/mesh.h |  31 +-
 net/mac80211/mesh_pathtbl.c | 786 ++--
 4 files changed, 259 insertions(+), 575 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index db7f0dbebc4b..c8945e2d8a86 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -697,17 +697,10 @@ struct ieee80211_if_mesh {
/* offset from skb->data while building IE */
int meshconf_offset;
 
-   struct mesh_table __rcu *mesh_paths;
-   struct mesh_table __rcu *mpp_paths; /* Store paths for MPP&MAP */
+   struct mesh_table *mesh_paths;
+   struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */
int mesh_paths_generation;
int mpp_paths_generation;
-
-   /* Protects assignment of the mesh_paths/mpp_paths table
-* pointer for resize against reading it for add/delete
-* of individual paths.  Pure readers (lookups) just use
-* RCU.
-*/
-   rwlock_t pathtbl_resize_lock;
 };
 
 #ifdef CONFIG_MAC80211_MESH
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index c92af2a7714d..a216c439b6f2 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1347,12 +1347,6 @@ void ieee80211_mesh_work(struct ieee80211_sub_if_data 
*sdata)
   ifmsh->last_preq + 
msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))
mesh_path_start_discovery(sdata);
 
-   if (test_and_clear_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags))
-   mesh_mpath_table_grow(sdata);
-
-   if (test_and_clear_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags))
-   mesh_mpp_table_grow(sdata);
-
if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
ieee80211_mesh_housekeeping(sdata);
 
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index f3cc3917e048..cc6854db156e 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -51,10 +51,6 @@ enum mesh_path_flags {
  *
  *
  * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
- * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs
- * to grow.
- * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to
- * grow
  * @MESH_WORK_ROOT: the mesh root station needs to send a frame
  * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to 
other
  * mesh nodes
@@ -62,8 +58,6 @@ enum mesh_path_flags {
  */
 enum mesh_deferred_task_flags {
MESH_WORK_HOUSEKEEPING,
-   MESH_WORK_GROW_MPATH_TABLE,
-   MESH_WORK_GROW_MPP_TABLE,
MESH_WORK_ROOT,
MESH_WORK_DRIFT_ADJUST,
MESH_WORK_MBSS_CHANGED,
@@ -105,6 +99,7 @@ enum mesh_deferred_task_flags {
 struct mesh_path {
u8 dst[ETH_ALEN];
u8 mpp[ETH_ALEN];   /* used for MPP or MAP */
+   struct rhash_head rhash;
struct hlist_node gate_list;
struct ieee80211_sub_if_data *sdata;
struct sta_info __rcu *next_hop;
@@ -129,34 +124,17 @@ struct mesh_path {
 /**
  * struct mesh_table
  *
- * @hash_buckets: array of hash buckets of the table
- * @hashwlock: array of locks to protect write operations, one per bucket
- * @hash_mask: 2^size_order - 1, used to compute hash idx
- * @hash_rnd: random value used for hash computations
  * @entries: number of entries in the table
- * @free_node: function to free nodes of the table
- * @copy_node: function to copy nodes of the table
- * @size_order: determines size of the table, there will be 2^size_order hash
- * buckets
  * @known_gates: list of known mesh gates and their mpaths by the station. The
  * gate's mpath may or may not be resolved and active.
- *
- * rcu_head: RCU head to free the table
+ * @rhash: the rhashtable containing struct mesh_paths, keyed by dest addr
  */
 struct mesh_table {
-   /* Number of buckets will be 2^N */
-   struct hlist_head *hash_buckets;
-   spinlock_t *hashwlock;  /* One per bucket, for add/del */
-   unsigned int hash_mask; /* (2^size_order) - 1 */
-   __u32 hash_rnd; /* Used for hash generation */
atomic_t entries;   /* Up to MAX_MESH_NEIGHBOURS */
-   void (*free_node) (struct hlist_node *p, bool free_leafs);
-   int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
-   int size_order;
struct hlist_head *known_gates;
spinlock_t gates_lock;
 
-   struct rcu_head rcu_head;
+   struct rhashtable rhead;
 };
 
 /* R

RE: [PATCH net 0/7] bnx2x: endianness fixes

2016-03-02 Thread Ariel Elior
> -Original Message-
> From: Michal Schmidt [mailto:mschm...@redhat.com]
> Sent: Wednesday, March 02, 2016 2:47 PM
> To: netdev 
> Cc: Yuval Mintz ; Ariel Elior 
> Subject: [PATCH net 0/7] bnx2x: endianness fixes
> 
> Hello,
> this fixes a VLAN crash and some SRIOV bugs in bnx2x observed on ppc64.
> 
> Michal Schmidt (7):
>   bnx2x: fix crash on big-endian when adding VLAN
>   bnx2x: fix sending VF->PF messages on big-endian
>   bnx2x: fix receive of VF->PF mailbox messages by the PF on big-endian
>   bnx2x: access cfc_del_event only if the opcode is CFC_DEL
>   bnx2x: define fields of struct cfc_del_event_data as little-endian
>   bnx2x: define event data reserved fields as little-endian
>   bnx2x: fix indentation in bnx2x_sp_task()
> 
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h   | 36 
> ++-
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 22 +++---
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 12 
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c  |  4 +--
>  4 files changed, 32 insertions(+), 42 deletions(-)
> 
> --
> 2.5.0
Hi Michal,
Thanks for making these changes!
Acked-By: Ariel Elior 


[PATCH] net: sh_eth: avoid NULL pointer dereference in ring setup

2016-03-02 Thread Wolfram Sang
From: Wolfram Sang 

When allocating an skb fails, rxdesc is still NULL (or the previous ring
index on further iterations of the loop). However, this pointer is
dereferenced after the loop. So, make sure rxdesc is updated immediately
at the beginning of the loop.

Reported-by: coverity (CID 1056464)
Signed-off-by: Wolfram Sang 
---
 drivers/net/ethernet/renesas/sh_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c 
b/drivers/net/ethernet/renesas/sh_eth.c
index a2767336b7c545..d5f13d54099734 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1120,6 +1120,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
 
/* build Rx ring buffer */
for (i = 0; i < mdp->num_rx_ring; i++) {
+   rxdesc = &mdp->rx_ring[i];
/* skb */
mdp->rx_skbuff[i] = NULL;
skb = netdev_alloc_skb(ndev, skbuff_size);
@@ -1128,7 +1129,6 @@ static void sh_eth_ring_format(struct net_device *ndev)
sh_eth_set_receive_align(skb);
 
/* RX descriptor */
-   rxdesc = &mdp->rx_ring[i];
/* The size of the buffer is a multiple of 32 bytes. */
buf_len = ALIGN(mdp->rx_buf_sz, 32);
rxdesc->len = cpu_to_le32(buf_len << 16);
-- 
2.7.0



RE: [PATCH net-next V2 04/16] net: fec: reduce interrupts

2016-03-02 Thread Fugang Duan
From: Troy Kisky  Sent: Thursday, February 25, 
2016 8:37 AM
> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
> johan...@sipsolutions.net; stillcompil...@gmail.com;
> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
> 
> Subject: [PATCH net-next V2 04/16] net: fec: reduce interrupts
> 
> By clearing the NAPI interrupts in the NAPI routine and not in the interrupt
> handler, we can reduce the number of interrupts. We also don't need any
> status variables as the registers are still valid.
> 
> Also, notice that if budget pkts are received, the next call to 
> fec_enet_rx_napi
> will now continue to receive the previously pending packets.
> 
> Signed-off-by: Troy Kisky 
> ---
>  drivers/net/ethernet/freescale/fec.h  |   6 +-
>  drivers/net/ethernet/freescale/fec_main.c | 127 
> --
>  2 files changed, 50 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec.h
> b/drivers/net/ethernet/freescale/fec.h
> index 195122e..001200b 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -505,11 +505,7 @@ struct fec_enet_private {
> 
>   unsigned int total_tx_ring_size;
>   unsigned int total_rx_ring_size;
> -
> - unsigned long work_tx;
> - unsigned long work_rx;
> - unsigned long work_ts;
> - unsigned long work_mdio;
> + uintevents;
> 
>   struct  platform_device *pdev;
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index c517194..4a218b9 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -70,8 +70,6 @@ static void fec_enet_itr_coal_init(struct net_device
> *ndev);
> 
>  #define DRIVER_NAME  "fec"
> 
> -#define FEC_ENET_GET_QUQUE(_x) ((_x == 0) ? 1 : ((_x == 1) ? 2 : 0))
> -
>  /* Pause frame feild and FIFO threshold */
>  #define FEC_ENET_FCE (1 << 5)
>  #define FEC_ENET_RSEM_V  0x84
> @@ -1257,21 +1255,6 @@ static void fec_txq(struct net_device *ndev, struct
> fec_enet_private *fep,
>   writel(0, txq->bd.reg_desc_active);
>  }
> 
> -static void
> -fec_enet_tx(struct net_device *ndev)
> -{
> - struct fec_enet_private *fep = netdev_priv(ndev);
> - struct fec_enet_priv_tx_q *txq;
> - u16 queue_id;
> - /* First process class A queue, then Class B and Best Effort queue */
> - for_each_set_bit(queue_id, &fep->work_tx, FEC_ENET_MAX_TX_QS)
> {
> - clear_bit(queue_id, &fep->work_tx);
> - txq = fep->tx_queue[FEC_ENET_GET_QUQUE(queue_id)];
> - fec_txq(ndev, fep, txq);
> - }
> - return;
> -}
> -
>  static int
>  fec_enet_new_rxbdp(struct net_device *ndev, struct bufdesc *bdp, struct
> sk_buff *skb)  { @@ -1504,92 +1487,80 @@ rx_processing_done:
>   return pkt_received;
>  }
> 
> -static int
> -fec_enet_rx(struct net_device *ndev, int budget) -{
> - int pkt_received = 0;
> - u16 queue_id;
> - struct fec_enet_private *fep = netdev_priv(ndev);
> - struct fec_enet_priv_rx_q *rxq;
> -
> - for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS)
> {
> - clear_bit(queue_id, &fep->work_rx);
> - rxq = fep->rx_queue[FEC_ENET_GET_QUQUE(queue_id)];
> - pkt_received += fec_rxq(ndev, fep, rxq, budget -
> pkt_received);
> - }
> - return pkt_received;
> -}
> -
> -static bool
> -fec_enet_collect_events(struct fec_enet_private *fep, uint int_events) -{
> - if (int_events == 0)
> - return false;
> -
> - if (int_events & FEC_ENET_RXF_0)
> - fep->work_rx |= (1 << 2);
> - if (int_events & FEC_ENET_RXF_1)
> - fep->work_rx |= (1 << 0);
> - if (int_events & FEC_ENET_RXF_2)
> - fep->work_rx |= (1 << 1);
> -
> - if (int_events & FEC_ENET_TXF_0)
> - fep->work_tx |= (1 << 2);
> - if (int_events & FEC_ENET_TXF_1)
> - fep->work_tx |= (1 << 0);
> - if (int_events & FEC_ENET_TXF_2)
> - fep->work_tx |= (1 << 1);
> -
> - return true;
> -}
> -
>  static irqreturn_t
>  fec_enet_interrupt(int irq, void *dev_id)  {
>   struct net_device *ndev = dev_id;
>   struct fec_enet_private *fep = netdev_priv(ndev);
> - uint int_events;
> - irqreturn_t ret = IRQ_NONE;
> + uint eir = readl(fep->hwp + FEC_IEVENT);
> + uint int_events = eir & readl(fep->hwp + FEC_IMASK);
> 
> - int_events = readl(fep->hwp + FEC_IEVENT);
> - writel(int_events, fep->hwp + FEC_IEVENT);
> - fec_enet_collect_events(fep, int_events);
> -
> - if ((fep->work_tx || fep->work_rx) && fep->link) {
> - ret = IRQ_HANDLED;
> + if (!int_events)
> + return IRQ_NONE;
> 
> + 

[PATCH net 0/3] Mellanox 10/40G mlx4 driver fixes for 4.5-rc6

2016-03-02 Thread Or Gerlitz
Hi Dave,

This series contains two fixes for the SRIOV HW LAG that was 
introduced in 4.5-rc1 and one fix that allows to revoke the 
administrative MAC that was assigned to VF through the PF.

The VF mac fix needs to go for stable too.

Or.


Jack Morgenstein (2):
  net/mlx4_core: Fix lockdep warning in handling of mac/vlan tables
  net/mlx4_core: Allow resetting VF admin mac to zero

Moni Shoua (1):
  net/mlx4_core: Check the correct limitation on VFs for HA mode

 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |  2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c  | 14 +++---
 drivers/net/ethernet/mellanox/mlx4/port.c  | 20 ++--
 3 files changed, 22 insertions(+), 14 deletions(-)

-- 
2.3.7



[PATCH net 1/3] net/mlx4_core: Fix lockdep warning in handling of mac/vlan tables

2016-03-02 Thread Or Gerlitz
From: Jack Morgenstein 

In the mac and vlan register/unregister/replace functions, the driver locks
the mac table mutex (or vlan table mutex) on both ports.

We move to use mutex_lock_nested() to prevent warnings, such as the one below.

[ 101.828445] =
[ 101.834820] [ INFO: possible recursive locking detected ]
[ 101.841199] 4.5.0-rc2+  #49 Not tainted
[ 101.850251] -
[ 101.856621] modprobe/3054 is trying to acquire lock:
[ 101.862514] (&table->mutex#2){+.+.+.}, at: [] 
__mlx4_register_mac+0x87e/0xa90 [mlx4_core]
[ 101.874598]
[ 101.874598] but task is already holding lock:
[ 101.881703] (&table->mutex#2){+.+.+.}, at: [] 
__mlx4_register_mac+0x860/0xa90 [mlx4_core]
[ 101.893776]
[ 101.893776] other info that might help us debug this:
[ 101.901658] Possible unsafe locking scenario:
[ 101.901658]
[ 101.908859] CPU0
[ 101.911923] 
[ 101.914985] lock(&table->mutex#2);
[ 101.919595] lock(&table->mutex#2);
[ 101.924199]
[ 101.924199] * DEADLOCK *
[ 101.924199]
[ 101.931643] May be due to missing lock nesting notation

Fixes: 5f61385d2ebc ('net/mlx4_core: Keep VLAN/MAC tables mirrored in multifunc 
HA mode')
Signed-off-by: Jack Morgenstein 
Suggested-by: Doron Tsur 
---
 drivers/net/ethernet/mellanox/mlx4/port.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c 
b/drivers/net/ethernet/mellanox/mlx4/port.c
index 787b7bb..211c650 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -193,10 +193,10 @@ int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, 
u64 mac)
if (need_mf_bond) {
if (port == 1) {
mutex_lock(&table->mutex);
-   mutex_lock(&dup_table->mutex);
+   mutex_lock_nested(&dup_table->mutex, 
SINGLE_DEPTH_NESTING);
} else {
mutex_lock(&dup_table->mutex);
-   mutex_lock(&table->mutex);
+   mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
}
} else {
mutex_lock(&table->mutex);
@@ -389,10 +389,10 @@ void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, 
u64 mac)
if (dup) {
if (port == 1) {
mutex_lock(&table->mutex);
-   mutex_lock(&dup_table->mutex);
+   mutex_lock_nested(&dup_table->mutex, 
SINGLE_DEPTH_NESTING);
} else {
mutex_lock(&dup_table->mutex);
-   mutex_lock(&table->mutex);
+   mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
}
} else {
mutex_lock(&table->mutex);
@@ -479,10 +479,10 @@ int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int 
qpn, u64 new_mac)
if (dup) {
if (port == 1) {
mutex_lock(&table->mutex);
-   mutex_lock(&dup_table->mutex);
+   mutex_lock_nested(&dup_table->mutex, 
SINGLE_DEPTH_NESTING);
} else {
mutex_lock(&dup_table->mutex);
-   mutex_lock(&table->mutex);
+   mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
}
} else {
mutex_lock(&table->mutex);
@@ -588,10 +588,10 @@ int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, 
u16 vlan,
if (need_mf_bond) {
if (port == 1) {
mutex_lock(&table->mutex);
-   mutex_lock(&dup_table->mutex);
+   mutex_lock_nested(&dup_table->mutex, 
SINGLE_DEPTH_NESTING);
} else {
mutex_lock(&dup_table->mutex);
-   mutex_lock(&table->mutex);
+   mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
}
} else {
mutex_lock(&table->mutex);
@@ -764,10 +764,10 @@ void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 
port, u16 vlan)
if (dup) {
if (port == 1) {
mutex_lock(&table->mutex);
-   mutex_lock(&dup_table->mutex);
+   mutex_lock_nested(&dup_table->mutex, 
SINGLE_DEPTH_NESTING);
} else {
mutex_lock(&dup_table->mutex);
-   mutex_lock(&table->mutex);
+   mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
}
} else {
mutex_lock(&table->mutex);
-- 
2.3.7



[PATCH net 3/3] net/mlx4_core: Allow resetting VF admin mac to zero

2016-03-02 Thread Or Gerlitz
From: Jack Morgenstein 

The VF administrative mac addresses (stored in the PF driver) are
initialized to zero when the PF driver starts up.

These addresses may be modified in the PF driver through ndo calls
initiated by iproute2 or libvirt.

While we allow the PF/host to change the VF admin mac address from zero
to a valid unicast mac, we do not allow restoring the VF admin mac to
zero. We currently only allow changing this mac to a different unicast mac.

This leads to problems when libvirt scripts are used to deal with
VF mac addresses, and libvirt attempts to revoke the mac so this
host will not use it anymore.

Fix this by allowing resetting a VF administrative MAC back to zero.

Fixes: 8f7ba3ca12f6 ('net/mlx4: Add set VF mac address support')
Signed-off-by: Jack Morgenstein 
Reported-by: Moshe Levi 
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c 
b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index f191a16..21e2c09 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2245,7 +2245,7 @@ static int mlx4_en_set_vf_mac(struct net_device *dev, int 
queue, u8 *mac)
struct mlx4_en_dev *mdev = en_priv->mdev;
u64 mac_u64 = mlx4_mac_to_u64(mac);
 
-   if (!is_valid_ether_addr(mac))
+   if (is_multicast_ether_addr(mac))
return -EINVAL;
 
return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac_u64);
-- 
2.3.7



Re: net/bluetooth: workqueue destruction WARNING in hci_unregister_dev

2016-03-02 Thread Tejun Heo
Hello, Jiri.

On Fri, Feb 19, 2016 at 01:10:00PM +0100, Jiri Slaby wrote:
> > 1. didn't help, the problem persists. So I haven't applied the patch from 2.
> 
> FWIW I dumped more info about the wq:
> wq->name='hci0' pwq=8800390d7600 wq->dfl_pwq=8800390d5200
> pwq->refcnt=2 pwq->nr_active=0 delayed_works: 

Can you please print out the same info for all pwq's during shutdown?
It looks like we're leaking pwq refcnt but I can't spot a place where
that could happen on an empty pwq.

Thanks.

-- 
tejun


Re: [PATCH net-next 6/8] net/mlx5e: Introduce tc offload support

2016-03-02 Thread Amir Vadai
On Tue, Mar 01, 2016 at 09:13:25AM -0800, John Fastabend wrote:
> On 16-03-01 09:00 AM, Amir Vadai wrote:
> > On Tue, Mar 01, 2016 at 03:52:08PM +0100, Jiri Pirko wrote:
> >> Tue, Mar 01, 2016 at 03:24:48PM CET, a...@vadai.me wrote:
> >>> Extend ndo_setup_tc() to support ingress tc offloading. Will be used by
> >>> later patches to offload tc flower filter.
> >>>
> >>> Feature is off by default and could be enabled by issuing:
> >>> # ethtool  -K eth0 hw-tc-offload on
> >>>
> >>> Offloads flow table is dynamically created when first filter is
> >>> added.
> >>> Rules are saved in a hash table that is maintained by the consumer (for
> >>> example - the flower offload in the next patch).
> >>> When last filter is removed and no filters exist in the hash table, the
> >>> offload flow table is destroyed.
> >>
> >>  
> >>
> >>> @@ -1880,6 +1883,17 @@ static int mlx5e_setup_tc(struct net_device 
> >>> *netdev, u8 tc)
> >>> static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle,
> >>> __be16 proto, struct tc_to_netdev *tc)
> >>> {
> >>> + struct mlx5e_priv *priv = netdev_priv(dev);
> >>> +
> >>> + if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
> >>> + goto mqprio;
> >>> +
> >>> + switch (tc->type) {
> >>> + default:
> >>> + return -EINVAL;
> >>
> >> -EOPNOTSUPP would be better here perhaps?
> >>
> >>
> >>> + }
> >>> +
> >>> +mqprio:
> >>>   if (handle != TC_H_ROOT || tc->type != TC_SETUP_MQPRIO)
> >>>   return -EINVAL;
> >>>
> >>> @@ -1963,6 +1977,13 @@ static int mlx5e_set_features(struct net_device 
> >>> *netdev,
> >>>   mlx5e_disable_vlan_filter(priv);
> >>>   }
> >>>
> >>> + if ((changes & NETIF_F_HW_TC) && !(features & NETIF_F_HW_TC) &&
> >>> + mlx5e_tc_num_filters(priv)) {
> >>> + netdev_err(netdev,
> >>> +"Active offloaded tc filters, can't turn 
> >>> hw_tc_offload off\n");
> >>> + return -EINVAL;
> >>
> >> This should not fail I believe. Just disable it in hw. I would even toss
> >> away the rules if necessary.
> > It depends on the answer regarding your comment on the previous patch.
> > If we have the rule in both SW and HW, and remove it from the HW it is
> > ok (although, currently I don't understand why would anyone want in both
> > places).
> > If the rule is processed by HW only - turning off this flag, will
> > disable the offloaded rules - it might be misleading, so I prefered not
> > to allow it and print a message.
> 
> When we get the HW only mode we will need to also flush the hardware
> representation in software as well as the hardware state.

Yep, I do think that just failing the operation is the best appraoch.
Will make the design simpler, and from the user point of view, less
surprises.

Jiri?


RE: [PATCH net-next V2 03/16] net: fec: pass txq to fec_enet_tx_queue instead of queue_id

2016-03-02 Thread Fugang Duan
From: Troy Kisky   Sent: Thursday, February 25, 
2016 8:37 AM
> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
> johan...@sipsolutions.net; stillcompil...@gmail.com;
> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
> 
> Subject: [PATCH net-next V2 03/16] net: fec: pass txq to fec_enet_tx_queue
> instead of queue_id
> 
> queue_id is the qid member of struct bufdesc_prop.
> 
> Signed-off-by: Troy Kisky 
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 17 ++---
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index 9619b9e..c517194 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1156,25 +1156,18 @@ fec_enet_hwtstamp(struct fec_enet_private *fep,
> unsigned ts,
>   hwtstamps->hwtstamp = ns_to_ktime(ns);  }
> 
> -static void
> -fec_enet_tx_queue(struct net_device *ndev, u16 queue_id)
> +static void fec_txq(struct net_device *ndev, struct fec_enet_private *fep,
> + struct fec_enet_priv_tx_q *txq)
>  {
> - struct  fec_enet_private *fep;
>   struct bufdesc *bdp;
>   unsigned short status;
>   struct  sk_buff *skb;
> - struct fec_enet_priv_tx_q *txq;
>   struct netdev_queue *nq;
>   int index = 0;
>   int entries_free;
> 
> - fep = netdev_priv(ndev);
> -
> - queue_id = FEC_ENET_GET_QUQUE(queue_id);
> -
> - txq = fep->tx_queue[queue_id];
>   /* get next bdp of dirty_tx */
> - nq = netdev_get_tx_queue(ndev, queue_id);
> + nq = netdev_get_tx_queue(ndev, txq->bd.qid);
>   bdp = txq->dirty_tx;
> 
>   /* get next bdp of dirty_tx */
> @@ -1268,11 +1261,13 @@ static void
>  fec_enet_tx(struct net_device *ndev)
>  {
>   struct fec_enet_private *fep = netdev_priv(ndev);
> + struct fec_enet_priv_tx_q *txq;
>   u16 queue_id;
>   /* First process class A queue, then Class B and Best Effort queue */
>   for_each_set_bit(queue_id, &fep->work_tx, FEC_ENET_MAX_TX_QS)
> {
>   clear_bit(queue_id, &fep->work_tx);
> - fec_enet_tx_queue(ndev, queue_id);
> + txq = fep->tx_queue[FEC_ENET_GET_QUQUE(queue_id)];
> + fec_txq(ndev, fep, txq);
>   }
>   return;
>  }
> --
> 2.5.0

The patch should merge with patch#1.


[PATCH net 2/3] net/mlx4_core: Check the correct limitation on VFs for HA mode

2016-03-02 Thread Or Gerlitz
From: Moni Shoua 

The limit of 63 is only for virtual functions while the actual enforcement
was for VFs plus physical functions, fix that.

Fixes: e57968a10bc1 ('net/mlx4_core: Support the HA mode for SRIOV VFs too')
Signed-off-by: Moni Shoua 
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 2cc3c62..f8674ae 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1256,6 +1256,7 @@ err_set_port:
 static int mlx4_mf_bond(struct mlx4_dev *dev)
 {
int err = 0;
+   int nvfs;
struct mlx4_slaves_pport slaves_port1;
struct mlx4_slaves_pport slaves_port2;
DECLARE_BITMAP(slaves_port_1_2, MLX4_MFUNC_MAX);
@@ -1272,11 +1273,18 @@ static int mlx4_mf_bond(struct mlx4_dev *dev)
return -EINVAL;
}
 
+   /* number of virtual functions is number of total functions minus one
+* physical function for each port.
+*/
+   nvfs = bitmap_weight(slaves_port1.slaves, dev->persist->num_vfs + 1) +
+   bitmap_weight(slaves_port2.slaves, dev->persist->num_vfs + 1) - 
2;
+
/* limit on maximum allowed VFs */
-   if ((bitmap_weight(slaves_port1.slaves, dev->persist->num_vfs + 1) +
-   bitmap_weight(slaves_port2.slaves, dev->persist->num_vfs + 1)) >
-   MAX_MF_BOND_ALLOWED_SLAVES)
+   if (nvfs > MAX_MF_BOND_ALLOWED_SLAVES) {
+   mlx4_warn(dev, "HA mode is not supported for %d VFs (max %d are 
allowed)\n",
+ nvfs, MAX_MF_BOND_ALLOWED_SLAVES);
return -EINVAL;
+   }
 
if (dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED) {
mlx4_warn(dev, "HA mode unsupported for NON DMFS steering\n");
-- 
2.3.7



[iproute PATCH] ifstat, nstat: fix daemon mode

2016-03-02 Thread Phil Sutter
Since the relevant code (and it's bugs) is identical in both files, fix
them in one go. This patch fixes multiple issues:

* Using 'int' for the 'tdiff' variable does not suffice on 64bit
  systems, the assigned initial time difference makes it wrap and
  contain a negative value afterwards. Instead use the more appropriate
  'time_t' type.

* As far as I understood the code, poll() is supposed to time out just
  at the right time to trigger update_db() in the configured interval.
  Therefore it's timeout must be set to the desired interval *minus* the
  time that has already passed since then.

* With the last change to the algorithm in place, it does not make sense
  to call update_db() before returning data to the connected client.
  Actually, it never does otherwise we could skip the periodic updates
  in the first place.

Signed-off-by: Phil Sutter 
---
 misc/ifstat.c | 9 +++--
 misc/nstat.c  | 9 +++--
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/misc/ifstat.c b/misc/ifstat.c
index ac5c29c89184a..694d9839d2bd0 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -589,7 +589,7 @@ static void server_loop(int fd)
 
for (;;) {
int status;
-   int tdiff;
+   time_t tdiff;
struct timeval now;
 
gettimeofday(&now, NULL);
@@ -600,7 +600,7 @@ static void server_loop(int fd)
tdiff = 0;
}
 
-   if (poll(&p, 1, tdiff + scan_interval) > 0
+   if (poll(&p, 1, scan_interval - tdiff) > 0
&& (p.revents&POLLIN)) {
int clnt = accept(fd, NULL, NULL);
if (clnt >= 0) {
@@ -613,11 +613,8 @@ static void server_loop(int fd)
close(clnt);
} else {
FILE *fp = fdopen(clnt, "w");
-   if (fp) {
-   if (tdiff > 0)
-   update_db(tdiff);
+   if (fp)
dump_raw_db(fp, 0);
-   }
exit(0);
}
}
diff --git a/misc/nstat.c b/misc/nstat.c
index 99705286d279c..22b27eba7c8f6 100644
--- a/misc/nstat.c
+++ b/misc/nstat.c
@@ -433,7 +433,7 @@ static void server_loop(int fd)
 
for (;;) {
int status;
-   int tdiff;
+   time_t tdiff;
struct timeval now;
gettimeofday(&now, NULL);
tdiff = T_DIFF(now, snaptime);
@@ -442,7 +442,7 @@ static void server_loop(int fd)
snaptime = now;
tdiff = 0;
}
-   if (poll(&p, 1, tdiff + scan_interval) > 0
+   if (poll(&p, 1, scan_interval - tdiff) > 0
&& (p.revents&POLLIN)) {
int clnt = accept(fd, NULL, NULL);
if (clnt >= 0) {
@@ -455,11 +455,8 @@ static void server_loop(int fd)
close(clnt);
} else {
FILE *fp = fdopen(clnt, "w");
-   if (fp) {
-   if (tdiff > 0)
-   update_db(tdiff);
+   if (fp)
dump_kern_db(fp, 0);
-   }
exit(0);
}
}
-- 
2.7.2



Re: [PATCH net-next 6/8] net/mlx5e: Introduce tc offload support

2016-03-02 Thread Jiri Pirko
Wed, Mar 02, 2016 at 04:53:37PM CET, a...@vadai.me wrote:
>On Tue, Mar 01, 2016 at 09:13:25AM -0800, John Fastabend wrote:
>> On 16-03-01 09:00 AM, Amir Vadai wrote:
>> > On Tue, Mar 01, 2016 at 03:52:08PM +0100, Jiri Pirko wrote:
>> >> Tue, Mar 01, 2016 at 03:24:48PM CET, a...@vadai.me wrote:
>> >>> Extend ndo_setup_tc() to support ingress tc offloading. Will be used by
>> >>> later patches to offload tc flower filter.
>> >>>
>> >>> Feature is off by default and could be enabled by issuing:
>> >>> # ethtool  -K eth0 hw-tc-offload on
>> >>>
>> >>> Offloads flow table is dynamically created when first filter is
>> >>> added.
>> >>> Rules are saved in a hash table that is maintained by the consumer (for
>> >>> example - the flower offload in the next patch).
>> >>> When last filter is removed and no filters exist in the hash table, the
>> >>> offload flow table is destroyed.
>> >>
>> >> 
>> >>   
>> >>> @@ -1880,6 +1883,17 @@ static int mlx5e_setup_tc(struct net_device 
>> >>> *netdev, u8 tc)
>> >>> static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle,
>> >>>__be16 proto, struct tc_to_netdev *tc)
>> >>> {
>> >>> +struct mlx5e_priv *priv = netdev_priv(dev);
>> >>> +
>> >>> +if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
>> >>> +goto mqprio;
>> >>> +
>> >>> +switch (tc->type) {
>> >>> +default:
>> >>> +return -EINVAL;
>> >>
>> >> -EOPNOTSUPP would be better here perhaps?
>> >>
>> >>
>> >>> +}
>> >>> +
>> >>> +mqprio:
>> >>>  if (handle != TC_H_ROOT || tc->type != TC_SETUP_MQPRIO)
>> >>>  return -EINVAL;
>> >>>
>> >>> @@ -1963,6 +1977,13 @@ static int mlx5e_set_features(struct net_device 
>> >>> *netdev,
>> >>>  mlx5e_disable_vlan_filter(priv);
>> >>>  }
>> >>>
>> >>> +if ((changes & NETIF_F_HW_TC) && !(features & NETIF_F_HW_TC) &&
>> >>> +mlx5e_tc_num_filters(priv)) {
>> >>> +netdev_err(netdev,
>> >>> +   "Active offloaded tc filters, can't turn 
>> >>> hw_tc_offload off\n");
>> >>> +return -EINVAL;
>> >>
>> >> This should not fail I believe. Just disable it in hw. I would even toss
>> >> away the rules if necessary.
>> > It depends on the answer regarding your comment on the previous patch.
>> > If we have the rule in both SW and HW, and remove it from the HW it is
>> > ok (although, currently I don't understand why would anyone want in both
>> > places).
>> > If the rule is processed by HW only - turning off this flag, will
>> > disable the offloaded rules - it might be misleading, so I prefered not
>> > to allow it and print a message.
>> 
>> When we get the HW only mode we will need to also flush the hardware
>> representation in software as well as the hardware state.
>
>Yep, I do think that just failing the operation is the best appraoch.
>Will make the design simpler, and from the user point of view, less
>surprises.
>
>Jiri?

I don't feel it is ok, but at the same time, it is probably the best
solution for now. Other solutions would be too complicated.


[PATCH 00/14] drivers: use __maybe_unused to hide pm functions

2016-03-02 Thread Arnd Bergmann
I found many variations of the bug in these device drivers (and some
USB drivers I already send patches for in a separate series).

In each case, the power management operations structure conditionally
references suspend/resume functions, but the functions are hidden
in an incorrect #ifdef or not hidden at all.

We could try to correct the #ifdefs, but it seems easier to just
mark those functions as __maybe_unused, which has the same effect
but provides better compile-time test coverage and (subjectively)
looks a bit nicer.

I have a patch series that avoids all warnings in ARM randconfig
builds, and I have verified that all these patches fix a warning that
is still present in today's linux-next, and that they do not
introduce new warnings in any configuration I found.

Note that all these drivers are ARM specific, so I assume that
all portable drivers got fixed already when someone rand into
the problem on x86.

There are no dependencies between the patches, so I'd appreciate
subsystem maintainers to put them directly into their git trees.

Arnd

Arnd Bergmann (14):
  pinctrl: at91: use __maybe_unused to hide pm functions
  irqchip: st: use __maybe_unused to hide st_irq_syscfg_resume
  power: ipaq-micro-battery: use __maybe_unused to hide pm functions
  power: pm2301-charger: use __maybe_unused to hide pm functions
  mfd: ipaq-micro: use __maybe_unused to hide pm functions
  dma: sirf: use __maybe_unused to hide pm functions
  hw_random: exynos: use __maybe_unused to hide pm functions
  scsi: mvumi: use __maybe_unused to hide pm functions
  amd-xgbe: use __maybe_unused to hide pm functions
  wireless: cw1200: use __maybe_unused to hide pm functions_
  input: spear-keyboard: use __maybe_unused to hide pm functions
  keyboard: snvs-pwrkey: use __maybe_unused to hide pm functions
  [media] omap3isp: use IS_ENABLED() to hide pm functions
  ASoC: rockchip: use __maybe_unused to hide st_irq_syscfg_resume

 drivers/char/hw_random/exynos-rng.c | 10 --
 drivers/dma/sirf-dma.c  | 10 --
 drivers/input/keyboard/snvs_pwrkey.c|  4 ++--
 drivers/input/keyboard/spear-keyboard.c |  6 ++
 drivers/irqchip/irq-st.c|  2 +-
 drivers/media/platform/omap3isp/isp.c   | 13 +
 drivers/mfd/ipaq-micro.c|  2 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c   |  6 ++
 drivers/net/wireless/st/cw1200/cw1200_spi.c |  9 ++---
 drivers/net/wireless/st/cw1200/pm.h |  9 +++--
 drivers/pinctrl/pinctrl-at91-pio4.c |  4 ++--
 drivers/power/ipaq_micro_battery.c  |  4 ++--
 drivers/power/pm2301_charger.c  | 22 ++
 drivers/scsi/mvumi.c|  4 ++--
 sound/soc/rockchip/rockchip_spdif.c |  4 ++--
 15 files changed, 40 insertions(+), 69 deletions(-)

-- 
2.7.0
Cc: herb...@gondor.apana.org.au
Cc: k.kozlow...@samsung.com
Cc: dan.j.willi...@intel.com
Cc: vinod.k...@intel.com
Cc: bao...@kernel.org
Cc: dmitry.torok...@gmail.com
Cc: t...@linutronix.de
Cc: ja...@lakedaemon.net
Cc: marc.zyng...@arm.com
Cc: laurent.pinch...@ideasonboard.com
Cc: mche...@osg.samsung.com
Cc: lee.jo...@linaro.org
Cc: kv...@codeaurora.org
Cc: ludovic.desroc...@atmel.com
Cc: linus.wall...@linaro.org
Cc: s...@kernel.org
Cc: dbarysh...@gmail.com
Cc: jbottom...@odin.com
Cc: martin.peter...@oracle.com
Cc: broo...@kernel.org
Cc: linux-cry...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-samsung-...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: dmaeng...@vger.kernel.org
Cc: linux-in...@vger.kernel.org
Cc: linux-me...@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-wirel...@vger.kernel.org
Cc: linux-g...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: linux-s...@vger.kernel.org
Cc: alsa-de...@alsa-project.org
Cc: linux-rockc...@lists.infradead.org


[PATCH 09/14] amd-xgbe: use __maybe_unused to hide pm functions

2016-03-02 Thread Arnd Bergmann
The amd-xgbe ethernet driver hides its suspend/resume functions
in #ifdef CONFIG_PM, but uses SIMPLE_DEV_PM_OPS() to make the
reference conditional on CONFIG_PM_SLEEP, which results in a
warning when PM_SLEEP is not set but PM is:

drivers/net/ethernet/amd/xgbe/xgbe-main.c:833:12: warning: 'xgbe_suspend' 
defined but not used [-Wunused-function]
drivers/net/ethernet/amd/xgbe/xgbe-main.c:853:12: warning: 'xgbe_resume' 
defined but not used [-Wunused-function]

This removes the incorrect #ifdef and instead uses a __maybe_unused
annotation to let the compiler know it can silently drop
the function definition.

Signed-off-by: Arnd Bergmann 
---
 drivers/net/ethernet/amd/xgbe/xgbe-main.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 3eee3201b58f..a86f32106639 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -829,8 +829,7 @@ static int xgbe_remove(struct platform_device *pdev)
return 0;
 }
 
-#ifdef CONFIG_PM
-static int xgbe_suspend(struct device *dev)
+static int __maybe_unused xgbe_suspend(struct device *dev)
 {
struct net_device *netdev = dev_get_drvdata(dev);
struct xgbe_prv_data *pdata = netdev_priv(netdev);
@@ -850,7 +849,7 @@ static int xgbe_suspend(struct device *dev)
return ret;
 }
 
-static int xgbe_resume(struct device *dev)
+static int __maybe_unused xgbe_resume(struct device *dev)
 {
struct net_device *netdev = dev_get_drvdata(dev);
struct xgbe_prv_data *pdata = netdev_priv(netdev);
@@ -868,7 +867,6 @@ static int xgbe_resume(struct device *dev)
 
return ret;
 }
-#endif /* CONFIG_PM */
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id xgbe_acpi_match[] = {
-- 
2.7.0



[PATCH 10/14] wireless: cw1200: use __maybe_unused to hide pm functions_

2016-03-02 Thread Arnd Bergmann
The cw1200 uses #ifdef to check for CONFIG_PM, but then
uses SIMPLE_DEV_PM_OPS, which leaves the references out when
CONFIG_PM_SLEEP is not defined, so we get a warning with
PM=y && PM_SLEEP=n:

drivers/net/wireless/st/cw1200/cw1200_spi.c:450:12: error: 'cw1200_spi_suspend' 
defined but not used [-Werror=unused-function]

This removes the incorrect #ifdef and instead uses a __maybe_unused
annotation to let the compiler know it can silently drop
the function definition.

For the DEV_PM_OPS definition, we can use an IS_ENABLED() check
to avoid defining the structure when CONFIG_PM is not set without
the #ifdef.

Signed-off-by: Arnd Bergmann 
---
 drivers/net/wireless/st/cw1200/cw1200_spi.c | 9 ++---
 drivers/net/wireless/st/cw1200/pm.h | 9 +++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/cw1200_spi.c 
b/drivers/net/wireless/st/cw1200/cw1200_spi.c
index a740083634d8..63f95e9c2992 100644
--- a/drivers/net/wireless/st/cw1200/cw1200_spi.c
+++ b/drivers/net/wireless/st/cw1200/cw1200_spi.c
@@ -446,8 +446,7 @@ static int cw1200_spi_disconnect(struct spi_device *func)
return 0;
 }
 
-#ifdef CONFIG_PM
-static int cw1200_spi_suspend(struct device *dev)
+static int __maybe_unused cw1200_spi_suspend(struct device *dev)
 {
struct hwbus_priv *self = spi_get_drvdata(to_spi_device(dev));
 
@@ -460,16 +459,12 @@ static int cw1200_spi_suspend(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(cw1200_pm_ops, cw1200_spi_suspend, NULL);
 
-#endif
-
 static struct spi_driver spi_driver = {
.probe  = cw1200_spi_probe,
.remove = cw1200_spi_disconnect,
.driver = {
.name   = "cw1200_wlan_spi",
-#ifdef CONFIG_PM
-   .pm = &cw1200_pm_ops,
-#endif
+   .pm = IS_ENABLED(CONFIG_PM) ? &cw1200_pm_ops : NULL,
},
 };
 
diff --git a/drivers/net/wireless/st/cw1200/pm.h 
b/drivers/net/wireless/st/cw1200/pm.h
index 3ed90ff22bb8..534548470ebc 100644
--- a/drivers/net/wireless/st/cw1200/pm.h
+++ b/drivers/net/wireless/st/cw1200/pm.h
@@ -31,13 +31,18 @@ int cw1200_pm_init(struct cw1200_pm_state *pm,
 void cw1200_pm_deinit(struct cw1200_pm_state *pm);
 int cw1200_wow_suspend(struct ieee80211_hw *hw,
   struct cfg80211_wowlan *wowlan);
-int cw1200_wow_resume(struct ieee80211_hw *hw);
 int cw1200_can_suspend(struct cw1200_common *priv);
+int cw1200_wow_resume(struct ieee80211_hw *hw);
 void cw1200_pm_stay_awake(struct cw1200_pm_state *pm,
  unsigned long tmo);
 #else
 static inline void cw1200_pm_stay_awake(struct cw1200_pm_state *pm,
-   unsigned long tmo) {
+   unsigned long tmo)
+{
+}
+static inline int cw1200_can_suspend(struct cw1200_common *priv)
+{
+   return 0;
 }
 #endif
 #endif
-- 
2.7.0



Re: [PATCH net-next V2 04/16] net: fec: reduce interrupts

2016-03-02 Thread Troy Kisky
On 3/2/2016 8:13 AM, Fugang Duan wrote:
> From: Troy Kisky  Sent: Thursday, February 
> 25, 2016 8:37 AM
>> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
>> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
>> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
>> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
>> johan...@sipsolutions.net; stillcompil...@gmail.com;
>> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
>> 
>> Subject: [PATCH net-next V2 04/16] net: fec: reduce interrupts
>>
>> By clearing the NAPI interrupts in the NAPI routine and not in the interrupt
>> handler, we can reduce the number of interrupts. We also don't need any
>> status variables as the registers are still valid.
>>
>> Also, notice that if budget pkts are received, the next call to 
>> fec_enet_rx_napi
>> will now continue to receive the previously pending packets.
>>
>> Signed-off-by: Troy Kisky 
>> ---
>>  drivers/net/ethernet/freescale/fec.h  |   6 +-
>>  drivers/net/ethernet/freescale/fec_main.c | 127 
>> --
>>  2 files changed, 50 insertions(+), 83 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/freescale/fec.h
>> b/drivers/net/ethernet/freescale/fec.h
>> index 195122e..001200b 100644
>> --- a/drivers/net/ethernet/freescale/fec.h
>> +++ b/drivers/net/ethernet/freescale/fec.h
>> @@ -505,11 +505,7 @@ struct fec_enet_private {
>>
>>  unsigned int total_tx_ring_size;
>>  unsigned int total_rx_ring_size;
>> -
>> -unsigned long work_tx;
>> -unsigned long work_rx;
>> -unsigned long work_ts;
>> -unsigned long work_mdio;
>> +uintevents;
>>
>>  struct  platform_device *pdev;
>>
>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>> b/drivers/net/ethernet/freescale/fec_main.c
>> index c517194..4a218b9 100644
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -70,8 +70,6 @@ static void fec_enet_itr_coal_init(struct net_device
>> *ndev);
>>
>>  #define DRIVER_NAME "fec"
>>
>> -#define FEC_ENET_GET_QUQUE(_x) ((_x == 0) ? 1 : ((_x == 1) ? 2 : 0))
>> -
>>  /* Pause frame feild and FIFO threshold */
>>  #define FEC_ENET_FCE(1 << 5)
>>  #define FEC_ENET_RSEM_V 0x84
>> @@ -1257,21 +1255,6 @@ static void fec_txq(struct net_device *ndev, struct
>> fec_enet_private *fep,
>>  writel(0, txq->bd.reg_desc_active);
>>  }
>>
>> -static void
>> -fec_enet_tx(struct net_device *ndev)
>> -{
>> -struct fec_enet_private *fep = netdev_priv(ndev);
>> -struct fec_enet_priv_tx_q *txq;
>> -u16 queue_id;
>> -/* First process class A queue, then Class B and Best Effort queue */
>> -for_each_set_bit(queue_id, &fep->work_tx, FEC_ENET_MAX_TX_QS)
>> {
>> -clear_bit(queue_id, &fep->work_tx);
>> -txq = fep->tx_queue[FEC_ENET_GET_QUQUE(queue_id)];
>> -fec_txq(ndev, fep, txq);
>> -}
>> -return;
>> -}
>> -
>>  static int
>>  fec_enet_new_rxbdp(struct net_device *ndev, struct bufdesc *bdp, struct
>> sk_buff *skb)  { @@ -1504,92 +1487,80 @@ rx_processing_done:
>>  return pkt_received;
>>  }
>>
>> -static int
>> -fec_enet_rx(struct net_device *ndev, int budget) -{
>> -int pkt_received = 0;
>> -u16 queue_id;
>> -struct fec_enet_private *fep = netdev_priv(ndev);
>> -struct fec_enet_priv_rx_q *rxq;
>> -
>> -for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS)
>> {
>> -clear_bit(queue_id, &fep->work_rx);
>> -rxq = fep->rx_queue[FEC_ENET_GET_QUQUE(queue_id)];
>> -pkt_received += fec_rxq(ndev, fep, rxq, budget -
>> pkt_received);
>> -}
>> -return pkt_received;
>> -}
>> -
>> -static bool
>> -fec_enet_collect_events(struct fec_enet_private *fep, uint int_events) -{
>> -if (int_events == 0)
>> -return false;
>> -
>> -if (int_events & FEC_ENET_RXF_0)
>> -fep->work_rx |= (1 << 2);
>> -if (int_events & FEC_ENET_RXF_1)
>> -fep->work_rx |= (1 << 0);
>> -if (int_events & FEC_ENET_RXF_2)
>> -fep->work_rx |= (1 << 1);
>> -
>> -if (int_events & FEC_ENET_TXF_0)
>> -fep->work_tx |= (1 << 2);
>> -if (int_events & FEC_ENET_TXF_1)
>> -fep->work_tx |= (1 << 0);
>> -if (int_events & FEC_ENET_TXF_2)
>> -fep->work_tx |= (1 << 1);
>> -
>> -return true;
>> -}
>> -
>>  static irqreturn_t
>>  fec_enet_interrupt(int irq, void *dev_id)  {
>>  struct net_device *ndev = dev_id;
>>  struct fec_enet_private *fep = netdev_priv(ndev);
>> -uint int_events;
>> -irqreturn_t ret = IRQ_NONE;
>> +uint eir = readl(fep->hwp + FEC_IEVENT);
>> +uint int_events = eir & readl(fep->hwp + FEC_IMASK);
>>
>> -int_events = readl(fep->hwp + FEC_IEVENT);
>> -writel(int_events, fep->hwp + FEC_IEVENT);
>> -fec_enet_collect_events(fep, int_events);
>> -
>> -if ((fep->work_tx || fep->work_r

Re: [PATCH net-next V2 03/16] net: fec: pass txq to fec_enet_tx_queue instead of queue_id

2016-03-02 Thread Troy Kisky
On 3/2/2016 8:16 AM, Fugang Duan wrote:
> From: Troy Kisky   Sent: Thursday, February 
> 25, 2016 8:37 AM
>> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
>> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
>> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
>> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
>> johan...@sipsolutions.net; stillcompil...@gmail.com;
>> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
>> 
>> Subject: [PATCH net-next V2 03/16] net: fec: pass txq to fec_enet_tx_queue
>> instead of queue_id
>>
>> queue_id is the qid member of struct bufdesc_prop.
>>
>> Signed-off-by: Troy Kisky 
>> ---
>>  drivers/net/ethernet/freescale/fec_main.c | 17 ++---
>>  1 file changed, 6 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>> b/drivers/net/ethernet/freescale/fec_main.c
>> index 9619b9e..c517194 100644
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -1156,25 +1156,18 @@ fec_enet_hwtstamp(struct fec_enet_private *fep,
>> unsigned ts,
>>  hwtstamps->hwtstamp = ns_to_ktime(ns);  }
>>
>> -static void
>> -fec_enet_tx_queue(struct net_device *ndev, u16 queue_id)
>> +static void fec_txq(struct net_device *ndev, struct fec_enet_private *fep,
>> +struct fec_enet_priv_tx_q *txq)
>>  {
>> -struct  fec_enet_private *fep;
>>  struct bufdesc *bdp;
>>  unsigned short status;
>>  struct  sk_buff *skb;
>> -struct fec_enet_priv_tx_q *txq;
>>  struct netdev_queue *nq;
>>  int index = 0;
>>  int entries_free;
>>
>> -fep = netdev_priv(ndev);
>> -
>> -queue_id = FEC_ENET_GET_QUQUE(queue_id);
>> -
>> -txq = fep->tx_queue[queue_id];
>>  /* get next bdp of dirty_tx */
>> -nq = netdev_get_tx_queue(ndev, queue_id);
>> +nq = netdev_get_tx_queue(ndev, txq->bd.qid);
>>  bdp = txq->dirty_tx;
>>
>>  /* get next bdp of dirty_tx */
>> @@ -1268,11 +1261,13 @@ static void
>>  fec_enet_tx(struct net_device *ndev)
>>  {
>>  struct fec_enet_private *fep = netdev_priv(ndev);
>> +struct fec_enet_priv_tx_q *txq;
>>  u16 queue_id;
>>  /* First process class A queue, then Class B and Best Effort queue */
>>  for_each_set_bit(queue_id, &fep->work_tx, FEC_ENET_MAX_TX_QS)
>> {
>>  clear_bit(queue_id, &fep->work_tx);
>> -fec_enet_tx_queue(ndev, queue_id);
>> +txq = fep->tx_queue[FEC_ENET_GET_QUQUE(queue_id)];
>> +fec_txq(ndev, fep, txq);
>>  }
>>  return;
>>  }
>> --
>> 2.5.0
> 
> The patch should merge with patch#1.
> 


Why ?  That would only hide the change in patch #1.



[PATCH net-next] net: sched: use pfifo_fast for non real queues

2016-03-02 Thread Eric Dumazet
Some devices declare a high number of TX queues, then set a much
lower real_num_tx_queues

This cause setups using fq_codel, sfq or fq as the default qdisc to consume
more memory than really needed.

Signed-off-by: Eric Dumazet 
---
 include/net/sch_generic.h | 6 ++
 net/sched/sch_generic.c   | 1 +
 net/sched/sch_mq.c| 2 +-
 net/sched/sch_mqprio.c| 3 ++-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index e5bba897d206..46e55f0202a6 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -345,6 +345,12 @@ extern struct Qdisc_ops pfifo_fast_ops;
 extern struct Qdisc_ops mq_qdisc_ops;
 extern struct Qdisc_ops noqueue_qdisc_ops;
 extern const struct Qdisc_ops *default_qdisc_ops;
+static inline const struct Qdisc_ops *
+get_default_qdisc_ops(const struct net_device *dev, int ntx)
+{
+   return ntx < dev->real_num_tx_queues ?
+   default_qdisc_ops : &pfifo_fast_ops;
+}
 
 struct Qdisc_class_common {
u32 classid;
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 16bc83b2842a..f18c35024207 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -567,6 +567,7 @@ struct Qdisc_ops pfifo_fast_ops __read_mostly = {
.dump   =   pfifo_fast_dump,
.owner  =   THIS_MODULE,
 };
+EXPORT_SYMBOL(pfifo_fast_ops);
 
 static struct lock_class_key qdisc_tx_busylock;
 
diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c
index 3e82f047caaf..56a77b878eb3 100644
--- a/net/sched/sch_mq.c
+++ b/net/sched/sch_mq.c
@@ -57,7 +57,7 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt)
 
for (ntx = 0; ntx < dev->num_tx_queues; ntx++) {
dev_queue = netdev_get_tx_queue(dev, ntx);
-   qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
+   qdisc = qdisc_create_dflt(dev_queue, get_default_qdisc_ops(dev, 
ntx),
  TC_H_MAKE(TC_H_MAJ(sch->handle),
TC_H_MIN(ntx + 1)));
if (qdisc == NULL)
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 02ffb3fbbc20..b8002ce3d010 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -125,7 +125,8 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr 
*opt)
 
for (i = 0; i < dev->num_tx_queues; i++) {
dev_queue = netdev_get_tx_queue(dev, i);
-   qdisc = qdisc_create_dflt(dev_queue, default_qdisc_ops,
+   qdisc = qdisc_create_dflt(dev_queue,
+ get_default_qdisc_ops(dev, i),
  TC_H_MAKE(TC_H_MAJ(sch->handle),
TC_H_MIN(i + 1)));
if (qdisc == NULL) {
-- 
2.7.0.rc3.207.g0ac5344



Re: [PATCH net-next 1/8] net/flower: Introduce hardware offload support

2016-03-02 Thread John Fastabend
On 16-03-02 05:22 AM, Jiri Pirko wrote:
> Wed, Mar 02, 2016 at 12:14:39PM CET, gerlitz...@gmail.com wrote:
>> On Tue, Mar 1, 2016 at 7:01 PM, Jiri Pirko  wrote:
>>> Tue, Mar 01, 2016 at 05:49:27PM CET, a...@vadai.me wrote:
 On Tue, Mar 01, 2016 at 03:47:19PM +0100, Jiri Pirko wrote:
> Tue, Mar 01, 2016 at 03:24:43PM CET, a...@vadai.me wrote:
>> This patch is based on a patch made by John Fastabend.
>>
>> It adds support for offloading cls_flower.
>> A filter that is offloaded successfully by hardware, will not be added to
>> the hashtable and won't be processed by software.
>>
> That is wrong. User should explicitly specify to not include rule into sw
> by SKIP_KERNEL flag (does not exist now, with John's recent patch we'll
> have only SKIP_HW). Please add that in this patchset.
>>
 Why? If a rule is offloaded, why would the user want to reprocess it by 
 software?
>>
 If the user use SKIP_HW, it will be processed by SW. Else, the user
 would want it to be processed by HW or fallback to SW. I don't
 understand in which case the user would like to have it done twice.
>>
>>> For example if you turn on the offloading by unsetting NETIF_F_HW_TC.
>>> Or if someone inserts skbs into rx path directly, for example pktgen.
>>> We need SKIP_KERNEL to be set by user, not implicit.
>>
>> As discussed in netdev, we want to have three modes for TC offloads
>>
>> 1. SW only
>> 2. HW only (and err if can't)
>> 3. HW and if not supported fallback to SW
>>
>> Now, from your reply, I understand we want a fourth mode
>>
>> 4. Both (HW and SW)
> 
> I would perhaps do it a litte bit differently:
> NO FLAG (default)- insert into kernel and HW now:
>   if NETIF_F_HW_TC is off (default)
>   -> push to kernel only (current behaviour)
>   if NETIF_F_HW_TC is on AND push to HW fails
>   -> return error
> SKIP_HW - flag to tell kernel not to insert into HW
> SKIP_SW - flag to tell kernel not to insert into kernel
> 
> to achieve hw only, user has to turn on the NETIF_F_HW_TC and
> pass SKIP_SW flag.
> 

The modes Jiri describes here is exactly how I planned to build
this. And at the moment the only one we are missing is SKIP_HW
which I'm reworking now and should have in a few days.

To resolve the error handling if the rule is SKIP_HW or NO_FLAG
an error will be thrown if it can not be applied to software.
Notice if an error happens on the software insert with NO_FLAG then
the hardware insert is not attempted either. With SKIP_SW I will
throw an error if the hardware insert fails because there is
no software fallback in this mode.

The only mode I haven't looked at doing is

3. HW and if not supported fallback to SW

I'm not sure I have a use case for it at the moment. It is sufficient
for me to just do a SKIP_SW command followed by a SKIP_HW command
if needed. I guess someone else could implement it if they really need
it.

> 
>>
>> Do we agree that these four policies/modes make sense?
>>
>> So you want #4 to be the default? can you elaborate why? note that for
>> the HW marking
>> case a "both" mode will be very inefficient, also for actions like
>> vlan push/pop, encap/decap, etc
> 
> Well when you push/pop vlan of encap/decap tunnel header in hw, you won't
> match the packet in kernel again. Most likely. But anyway, if you turn
> on NETIF_F_HW_TC you know what you are doing and you adjust the
> included rules (flags) accordingly.
> 
> 
>> the result will be just wrong... I don't think this should be the default.
>>
>> Or.



Re: [PATCH net-next 1/8] net/flower: Introduce hardware offload support

2016-03-02 Thread Jiri Pirko
Wed, Mar 02, 2016 at 05:22:48PM CET, john.fastab...@gmail.com wrote:
>On 16-03-02 05:22 AM, Jiri Pirko wrote:
>> Wed, Mar 02, 2016 at 12:14:39PM CET, gerlitz...@gmail.com wrote:
>>> On Tue, Mar 1, 2016 at 7:01 PM, Jiri Pirko  wrote:
 Tue, Mar 01, 2016 at 05:49:27PM CET, a...@vadai.me wrote:
> On Tue, Mar 01, 2016 at 03:47:19PM +0100, Jiri Pirko wrote:
>> Tue, Mar 01, 2016 at 03:24:43PM CET, a...@vadai.me wrote:
>>> This patch is based on a patch made by John Fastabend.
>>>
>>> It adds support for offloading cls_flower.
>>> A filter that is offloaded successfully by hardware, will not be added 
>>> to
>>> the hashtable and won't be processed by software.
>>>
>> That is wrong. User should explicitly specify to not include rule into sw
>> by SKIP_KERNEL flag (does not exist now, with John's recent patch we'll
>> have only SKIP_HW). Please add that in this patchset.
>>>
> Why? If a rule is offloaded, why would the user want to reprocess it by 
> software?
>>>
> If the user use SKIP_HW, it will be processed by SW. Else, the user
> would want it to be processed by HW or fallback to SW. I don't
> understand in which case the user would like to have it done twice.
>>>
 For example if you turn on the offloading by unsetting NETIF_F_HW_TC.
 Or if someone inserts skbs into rx path directly, for example pktgen.
 We need SKIP_KERNEL to be set by user, not implicit.
>>>
>>> As discussed in netdev, we want to have three modes for TC offloads
>>>
>>> 1. SW only
>>> 2. HW only (and err if can't)
>>> 3. HW and if not supported fallback to SW
>>>
>>> Now, from your reply, I understand we want a fourth mode
>>>
>>> 4. Both (HW and SW)
>> 
>> I would perhaps do it a litte bit differently:
>> NO FLAG (default)- insert into kernel and HW now:
>>  if NETIF_F_HW_TC is off (default)
>>  -> push to kernel only (current behaviour)
>>  if NETIF_F_HW_TC is on AND push to HW fails
>>  -> return error
>> SKIP_HW - flag to tell kernel not to insert into HW
>> SKIP_SW - flag to tell kernel not to insert into kernel
>> 
>> to achieve hw only, user has to turn on the NETIF_F_HW_TC and
>> pass SKIP_SW flag.
>> 
>
>The modes Jiri describes here is exactly how I planned to build
>this. And at the moment the only one we are missing is SKIP_HW
>which I'm reworking now and should have in a few days.
>
>To resolve the error handling if the rule is SKIP_HW or NO_FLAG
>an error will be thrown if it can not be applied to software.
>Notice if an error happens on the software insert with NO_FLAG then
>the hardware insert is not attempted either. With SKIP_SW I will
>throw an error if the hardware insert fails because there is
>no software fallback in this mode.
>
>The only mode I haven't looked at doing is
>
>   3. HW and if not supported fallback to SW
>
>I'm not sure I have a use case for it at the moment. It is sufficient
>for me to just do a SKIP_SW command followed by a SKIP_HW command
>if needed. I guess someone else could implement it if they really need
>it.

I'd let user to resolve this as you described.


RE: [PATCH net 0/3] r8169:issues fix.

2016-03-02 Thread Hau
> I don't agree with changes #1 and #2.
> 
> If you are going to go to a model where every single configuration operation
> is recorded in software and performed at resume time, then really do it and
> fix it in the whole driver.  As currently coded you are leaving lots of known
> bugs in the driver.
> 
> #2 is even a worse situation.  If you are going to handle things this way you
> must sync the counters when the suspend happens, so that the statistics get
> call receives up to date values.

Thanks for your advice. I will send #3 patch first. Then modify #1 and #2 patch 
and resend these two patches.

 --Please consider the environment before printing this e-mail.


[PATCH net-next] ipv4: properly apply change to ignore_routes_on_linkdown to all interfaces

2016-03-02 Thread Andy Gospodarek
Any change to sysctl net.ipv4.conf.all.ignore_routes_with_linkdown does
not result in a change to all interfaces on the system.  This means that
any devices initialized before sysctl settings are applied on boot do
not see a change if the sysctl setting is different than what the stack
has as a default ('0' in this case).

This patch changes the net.ipv4.conf.all.ignore_routes_with_linkdown
setting to match what is done for forwarding for ipv4 and for
ignore_routes_with_linkdown for ipv6.  The current behavior was not
intentional and had I recognized this corner-case before posting I would
have done this with the first series.

Fixes: 0eeb075fad73 ("net: ipv4 sysctl option to ignore routes when nexthop 
link is down")
Signed-off-by: Andy Gospodarek 
---
Generic infrastructure could be added to do this for all values, but I'm
hesitant to do this since historically users are probably depending on
the exiting behavior (whether intentional or not) for the more widely
used sysctls.

 net/ipv4/devinet.c | 77 --
 1 file changed, 75 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8c3df2c..d247e41 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2030,6 +2030,36 @@ static void inet_forward_change(struct net *net)
}
 }
 
+/* called with RTNL locked */
+static void inet_ignore_routes_change(struct net *net)
+{
+   struct net_device *dev;
+   int on = IPV4_DEVCONF_ALL(net, IGNORE_ROUTES_WITH_LINKDOWN);
+
+   IPV4_DEVCONF_DFLT(net, IGNORE_ROUTES_WITH_LINKDOWN) = on;
+   inet_netconf_notify_devconf(net, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   NETCONFA_IFINDEX_ALL,
+   net->ipv4.devconf_all);
+   inet_netconf_notify_devconf(net, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   NETCONFA_IFINDEX_DEFAULT,
+   net->ipv4.devconf_dflt);
+
+   for_each_netdev(net, dev) {
+   struct in_device *in_dev;
+
+   rcu_read_lock();
+   in_dev = __in_dev_get_rcu(dev);
+   if (in_dev) {
+   IN_DEV_CONF_SET(in_dev,
+   IGNORE_ROUTES_WITH_LINKDOWN, on);
+   inet_netconf_notify_devconf(net,
+   
NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   dev->ifindex, &in_dev->cnf);
+   }
+   rcu_read_unlock();
+   }
+}
+
 static int devinet_conf_ifindex(struct net *net, struct ipv4_devconf *cnf)
 {
if (cnf == net->ipv4.devconf_dflt)
@@ -2147,6 +2177,48 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, 
int write,
return ret;
 }
 
+static int devinet_sysctl_ignore_routes(struct ctl_table *ctl, int write,
+   void __user *buffer,
+   size_t *lenp, loff_t *ppos)
+{
+   int *valp = ctl->data;
+   int val = *valp;
+   loff_t pos = *ppos;
+   int ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
+
+   if (write && *valp != val) {
+   struct net *net = ctl->extra2;
+
+   if (valp != &IPV4_DEVCONF_DFLT(net, 
IGNORE_ROUTES_WITH_LINKDOWN)) {
+   if (!rtnl_trylock()) {
+   /* Restore the original values before 
restarting */
+   *valp = val;
+   *ppos = pos;
+   return restart_syscall();
+   }
+   if (valp == &IPV4_DEVCONF_ALL(net, 
IGNORE_ROUTES_WITH_LINKDOWN)) {
+   inet_ignore_routes_change(net);
+   } else {
+   struct ipv4_devconf *cnf = ctl->extra1;
+   struct in_device *idev =
+   container_of(cnf, struct in_device, 
cnf);
+   inet_netconf_notify_devconf(net,
+   
NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   idev->dev->ifindex,
+   cnf);
+   }
+   rtnl_unlock();
+   rt_cache_flush(net);
+   } else
+   inet_netconf_notify_devconf(net,
+   
NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   NETCONFA_IFINDEX_DEFAULT,
+   net->ipv4.devconf_dflt);
+   }
+
+   return ret;
+}
+
 #define DEVINET_SYSCTL_ENTRY(attr, name, mval, proc) \
{ \
.procname   = name, \
@@ -2205,8 +2277,9 

Re: [PATCH net-next V2 04/16] net: fec: reduce interrupts

2016-03-02 Thread Zhi Li
On Wed, Mar 2, 2016 at 10:12 AM, Troy Kisky
 wrote:
> it is going to be delayed for a very long time.
> Should it be moved to the napi routine?

No!

irq can generate.  Compared irq enable is not controlled by EIMR, but TCSR.

Original code is correct.

best regards
Frank Li


Re: [PATCH] net: sh_eth: avoid NULL pointer dereference in ring setup

2016-03-02 Thread Sergei Shtylyov

Hello.

On 03/02/2016 06:26 PM, Wolfram Sang wrote:


From: Wolfram Sang 

When allocating an skb fails, rxdesc is still NULL (or the previous ring
index on further iterations of the loop). However, this pointer is
dereferenced after the loop.


   This is intended. What we seem to actually need is a NULL check before 
that dereference.



So, make sure rxdesc is updated immediately
at the beginning of the loop.


   No, this seems wrong. We don't want an unfilled descriptor to be marked as 
last, we still need the previous one marked as last. Actually, 'rxdesc' 
shouldn't be "advanced" even before the second *break* as it is now.



Reported-by: coverity (CID 1056464)
Signed-off-by: Wolfram Sang 


   Will you respin or should I?

MBR, Sergei



Re: [PATCH net-next V2 04/16] net: fec: reduce interrupts

2016-03-02 Thread Zhi Li
On Wed, Mar 2, 2016 at 10:12 AM, Troy Kisky
 wrote:
> On 3/2/2016 8:13 AM, Fugang Duan wrote:
>> From: Troy Kisky  Sent: Thursday, February 
>> 25, 2016 8:37 AM
>>> To: netdev@vger.kernel.org; da...@davemloft.net; b38...@freescale.com
>>> Cc: fabio.este...@freescale.com; l.st...@pengutronix.de; and...@lunn.ch;
>>> trem...@gmail.com; li...@arm.linux.org.uk; linux-arm-
>>> ker...@lists.infradead.org; l...@boundarydevices.com; shawn...@kernel.org;
>>> johan...@sipsolutions.net; stillcompil...@gmail.com;
>>> sergei.shtyl...@cogentembedded.com; a...@arndb.de; Troy Kisky
>>> 
>>> Subject: [PATCH net-next V2 04/16] net: fec: reduce interrupts
>>>
>>> By clearing the NAPI interrupts in the NAPI routine and not in the interrupt
>>> handler, we can reduce the number of interrupts. We also don't need any
>>> status variables as the registers are still valid.
>>>
>>> Also, notice that if budget pkts are received, the next call to 
>>> fec_enet_rx_napi
>>> will now continue to receive the previously pending packets.
>>>
>>> Signed-off-by: Troy Kisky 
>>> ---
>>>  drivers/net/ethernet/freescale/fec.h  |   6 +-
>>>  drivers/net/ethernet/freescale/fec_main.c | 127 
>>> 
>>> --
>>>  2 files changed, 50 insertions(+), 83 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/freescale/fec.h
>>> b/drivers/net/ethernet/freescale/fec.h
>>> index 195122e..001200b 100644
>>> --- a/drivers/net/ethernet/freescale/fec.h
>>> +++ b/drivers/net/ethernet/freescale/fec.h
>>> @@ -505,11 +505,7 @@ struct fec_enet_private {
>>>
>>>  unsigned int total_tx_ring_size;
>>>  unsigned int total_rx_ring_size;
>>> -
>>> -unsigned long work_tx;
>>> -unsigned long work_rx;
>>> -unsigned long work_ts;
>>> -unsigned long work_mdio;
>>> +uintevents;
>>>
>>>  struct  platform_device *pdev;
>>>
>>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>>> b/drivers/net/ethernet/freescale/fec_main.c
>>> index c517194..4a218b9 100644
>>> --- a/drivers/net/ethernet/freescale/fec_main.c
>>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>>> @@ -70,8 +70,6 @@ static void fec_enet_itr_coal_init(struct net_device
>>> *ndev);
>>>
>>>  #define DRIVER_NAME "fec"
>>>
>>> -#define FEC_ENET_GET_QUQUE(_x) ((_x == 0) ? 1 : ((_x == 1) ? 2 : 0))
>>> -
>>>  /* Pause frame feild and FIFO threshold */
>>>  #define FEC_ENET_FCE(1 << 5)
>>>  #define FEC_ENET_RSEM_V 0x84
>>> @@ -1257,21 +1255,6 @@ static void fec_txq(struct net_device *ndev, struct
>>> fec_enet_private *fep,
>>>  writel(0, txq->bd.reg_desc_active);
>>>  }
>>>
>>> -static void
>>> -fec_enet_tx(struct net_device *ndev)
>>> -{
>>> -struct fec_enet_private *fep = netdev_priv(ndev);
>>> -struct fec_enet_priv_tx_q *txq;
>>> -u16 queue_id;
>>> -/* First process class A queue, then Class B and Best Effort queue */
>>> -for_each_set_bit(queue_id, &fep->work_tx, FEC_ENET_MAX_TX_QS)
>>> {
>>> -clear_bit(queue_id, &fep->work_tx);
>>> -txq = fep->tx_queue[FEC_ENET_GET_QUQUE(queue_id)];
>>> -fec_txq(ndev, fep, txq);
>>> -}
>>> -return;
>>> -}
>>> -
>>>  static int
>>>  fec_enet_new_rxbdp(struct net_device *ndev, struct bufdesc *bdp, struct
>>> sk_buff *skb)  { @@ -1504,92 +1487,80 @@ rx_processing_done:
>>>  return pkt_received;
>>>  }
>>>
>>> -static int
>>> -fec_enet_rx(struct net_device *ndev, int budget) -{
>>> -int pkt_received = 0;
>>> -u16 queue_id;
>>> -struct fec_enet_private *fep = netdev_priv(ndev);
>>> -struct fec_enet_priv_rx_q *rxq;
>>> -
>>> -for_each_set_bit(queue_id, &fep->work_rx, FEC_ENET_MAX_RX_QS)
>>> {
>>> -clear_bit(queue_id, &fep->work_rx);
>>> -rxq = fep->rx_queue[FEC_ENET_GET_QUQUE(queue_id)];
>>> -pkt_received += fec_rxq(ndev, fep, rxq, budget -
>>> pkt_received);
>>> -}
>>> -return pkt_received;
>>> -}
>>> -
>>> -static bool
>>> -fec_enet_collect_events(struct fec_enet_private *fep, uint int_events) -{
>>> -if (int_events == 0)
>>> -return false;
>>> -
>>> -if (int_events & FEC_ENET_RXF_0)
>>> -fep->work_rx |= (1 << 2);
>>> -if (int_events & FEC_ENET_RXF_1)
>>> -fep->work_rx |= (1 << 0);
>>> -if (int_events & FEC_ENET_RXF_2)
>>> -fep->work_rx |= (1 << 1);
>>> -
>>> -if (int_events & FEC_ENET_TXF_0)
>>> -fep->work_tx |= (1 << 2);
>>> -if (int_events & FEC_ENET_TXF_1)
>>> -fep->work_tx |= (1 << 0);
>>> -if (int_events & FEC_ENET_TXF_2)
>>> -fep->work_tx |= (1 << 1);
>>> -
>>> -return true;
>>> -}
>>> -
>>>  static irqreturn_t
>>>  fec_enet_interrupt(int irq, void *dev_id)  {
>>>  struct net_device *ndev = dev_id;
>>>  struct fec_enet_private *fep = netdev_priv(ndev);
>>> -uint int_events;
>>> -irqreturn_t ret = IRQ_NONE;
>>> +uint eir = readl(fep->hwp + FEC_IEVENT);
>>> +uint int_events = eir & readl(fep->hwp + FEC_IMASK);
>>>
>>> 

Re: [PATCH for-next 01/10] net/core: Add support for configuring VF GUIDs

2016-03-02 Thread Doug Ledford
On 3/1/2016 4:08 PM, Or Gerlitz wrote:
> On Tue, Mar 1, 2016 at 8:25 PM, Jason Gunthorpe
>  wrote:
>> On Tue, Mar 01, 2016 at 07:49:51PM +0200, Eli Cohen wrote:
>>> On Tue, Mar 01, 2016 at 10:37:51AM -0700, Jason Gunthorpe wrote:
> + return handle_infiniband_guid(dev, &ivt, IFLA_VF_IB_PORT_GUID);

 But is this emulation really necessary? It seems dangerous and
 continues the bad practice of assuming IFLA_VF_MAC is fixed to 6 bytes
 in size, and is not just LLADDR bytes. I'd rather see mac sets fail on
 IB.

>>> struct ifla_vf_mac  already defines mac as 32 bytes but the idea here
>>> is that applications that configure six byte Ethernet MACs to VFs will
>>> continue to work without any change.
>>
>> In my view it is incorrect for an application to try and set a 6 byte
>> mac on an *infiniband* interface, the kernel should refuse to do it.
> 
> As Eli wrote, there's a well defined way to extend MAC to GUID. With
> that in hand, the idea here is to allow staged/evolved support for IB
> Virtualization using un-touched provisioning systems which assign VMs
> with 6-byte MACs

Exactly *what* provisioning system tries to set the VF_MAC on an IPoIB
interface and expects it to set the GUID of an underlying IB device?

> along with the fully IB aware solution where the
> upper level does provision IB GUIDs.

There has never been upstream support for this MAC->GUID stuff you refer
to.  I'm not convinced we should add it now versus just doing things
right, period.




signature.asc
Description: OpenPGP digital signature


[PATCH net v2] r8169: Enable RX_MULTI_EN for RTL_GIGA_MAC_VER_41~48

2016-03-02 Thread Chunhao Lin
For RTL8168G/RTL8168H/RTL8411B/RTL8107E, enable this flag to eliminate
message "AMD-Vi: Event logged [IO_PAGE_FAULT device=01:00.0 domain=0x0002
address=0x3000 flags=0x0050] in dmesg.

Signed-off-by: Chunhao Lin 
---
 drivers/net/ethernet/realtek/r8169.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c 
b/drivers/net/ethernet/realtek/r8169.c
index 4caeacb..dd2cf37 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -4933,8 +4933,6 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
break;
case RTL_GIGA_MAC_VER_40:
-   RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | 
RX_EARLY_OFF);
-   break;
case RTL_GIGA_MAC_VER_41:
case RTL_GIGA_MAC_VER_42:
case RTL_GIGA_MAC_VER_43:
@@ -4943,8 +4941,6 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
case RTL_GIGA_MAC_VER_46:
case RTL_GIGA_MAC_VER_47:
case RTL_GIGA_MAC_VER_48:
-   RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF);
-   break;
case RTL_GIGA_MAC_VER_49:
case RTL_GIGA_MAC_VER_50:
case RTL_GIGA_MAC_VER_51:
-- 
1.9.1



skb_under_panic in ip_tunnel_xmit

2016-03-02 Thread Francesco Ruggeri
I can consistently get this  panic on 4.4.1 as well as 3.18.

[ 2076.264975] gre: GRE over IPv4 demultiplexor driver
[ 2076.269326] ip_gre: GRE over IPv4 tunneling driver
[ 2076.274464] conntrack: generic helper won't handle protocol 47. Please 
consider loading the specific helper module.
[ 2088.868553] skbuff: skb_under_panic: text:814c03f2 len:108 put:20 
head:8800a5f6c400 data:8800a5f6c3f8 tail:0x64 end:0xc0 dev:t3
[ 2088.869755] [ cut here ]
[ 2088.870179] kernel BUG at net/core/skbuff.c:102!
[ 2088.870599] invalid opcode:  [#1] SMP 
[ 2088.871024] Modules linked in: ip_gre ip_tunnel gre dummy iptable_filter 
rfcomm bnep macvlan snd_seq_midi snd_seq_midi_event btusb btrtl btbcm btintel 
sg bluetooth joydev snd_ens1371 snd_ac97_codec ac97_bus coretemp hwmon snd_seq 
snd_pcm snd_timer snd_rawmidi snd_seq_device snd ppdev soundcore 
ip6table_filter ip6_tables bonding gameport serio_raw pcspkr battery kvm 
parport_pc nfsd auth_rpcgss oid_registry parport irqbypass ac irda crc_ccitt 
fuse nfs_acl lockd xt_multiport acpi_cpufreq tpm_tis tpm iptable_nat shpchp 
grace nf_conntrack_ipv4 nf_defrag_ipv4 i2c_piix4 nf_nat_ipv4 ip_tables nf_nat 
nf_conntrack x_tables tun 8021q uinput vmwgfx crc32c_intel drm_kms_helper 
syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ehci_pci drm aesni_intel 
aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd i2c_core
[ 2088.875474]  sr_mod mptspi mptscsih ehci_hcd mptbase scsi_transport_spi 
e1000 uhci_hcd cdrom sunrpc dm_mirror dm_region_hash dm_log dm_mod autofs4
[ 2088.876737] CPU: 1 PID: 6420 Comm: ping Not tainted 
4.4.1-2980094.AroraKernelnextfruggeri.2.fc18.x86_64 #1
[ 2088.878039] Hardware name: VMware, Inc. VMware Virtual Platform/440BX 
Desktop Reference Platform, BIOS 6.00 07/02/2012
[ 2088.879521] task: 880035ea ti: 8800b0ff8000 task.ti: 
8800b0ff8000
[ 2088.880285] RIP: 0010:[]  [] 
skb_panic+0x66/0x68
[ 2088.881214] RSP: 0018:8800b0ffb728  EFLAGS: 00010292
[ 2088.881945] RAX: 0083 RBX: 8800b51b6c00 RCX: 
[ 2088.882692] RDX: 88013ae2f101 RSI: 88013ae2cae8 RDI: 88013ae2cae8
[ 2088.883424] RBP: 8800b0ffb748 R08:  R09: 
[ 2088.884110] R10:  R11: 88013621f3e0 R12: 0054
[ 2088.884846] R13: 81a9fe40 R14:  R15: 03030303
[ 2088.885535] FS:  7f24b4a24740() GS:88013ae2() 
knlGS:
[ 2088.886270] CS:  0010 DS:  ES:  CR0: 80050033
[ 2088.887014] CR2: 7f9d6fb26000 CR3: aae66000 CR4: 001406e0
[ 2088.887817] Stack:
[ 2088.888582]  8800a5f6c3f8 0064 00c0 
880138fac000
[ 2088.889378]  8800b0ffb758 8143b640 8800b0ffb7c8 
814c03f2
[ 2088.890188]  8840 0040 8800 
002f
[ 2088.891011] Call Trace:
[ 2088.892073]  [] skb_push+0x3b/0x3c
[ 2088.893156]  [] iptunnel_xmit+0xad/0x145
[ 2088.894033]  [] ip_tunnel_xmit+0x673/0x790 [ip_tunnel]
[ 2088.894884]  [] __gre_xmit+0x76/0x7f [ip_gre]
[ 2088.895700]  [] ipgre_xmit+0xd3/0xef [ip_gre]
[ 2088.896573]  [] dev_hard_start_xmit+0x226/0x2fc
[ 2088.897387]  [] __dev_queue_xmit+0x333/0x425
[ 2088.898183]  [] dev_queue_xmit+0x10/0x12
[ 2088.898996]  [] neigh_direct_output+0x11/0x13
[ 2088.899793]  [] ip_finish_output2+0x233/0x293
[ 2088.900582]  [] ? dst_mtu+0xb/0xd
[ 2088.901283]  [] ip_finish_output+0x146/0x159
[ 2088.901990]  [] ? ip_generic_getfrag+0x5c/0x98
[ 2088.902658]  [] ip_output+0x5f/0x91
[ 2088.903306]  [] ? ip_finish_output2+0x293/0x293
[ 2088.903964]  [] ? __ip_local_out+0x73/0x7c
[ 2088.904625]  [] ? dst_mtu+0xd/0xd
[ 2088.905222]  [] dst_output+0xf/0x11
[ 2088.905820]  [] ip_local_out+0x31/0x3a
[ 2088.906378]  [] ip_send_skb+0x1a/0x3f
[ 2088.906938]  [] ip_push_pending_frames+0x33/0x3b
[ 2088.907465]  [] raw_sendmsg+0x794/0x8ea
[ 2088.907981]  [] ? __skb_recv_datagram+0x201/0x487
[ 2088.908548]  [] ? skb_recv_datagram+0x32/0x34
[ 2088.909050]  [] ? raw_recvmsg+0x68/0x159
[ 2088.909705]  [] ? rw_copy_check_uvector+0x6e/0x109
[ 2088.910247]  [] inet_sendmsg+0x3c/0x65
[ 2088.910775]  [] sock_sendmsg_nosec+0x12/0x1d
[ 2088.911279]  [] sock_sendmsg+0x29/0x2e
[ 2088.911764]  [] ___sys_sendmsg+0x1a6/0x23f
[ 2088.912349]  [] ? ldsem_up_read+0x1b/0x30
[ 2088.912820]  [] ? tty_ldisc_deref+0x16/0x18
[ 2088.913299]  [] ? tty_write+0x207/0x222
[ 2088.913743]  [] ? n_tty_receive_buf+0x13/0x13
[ 2088.914244]  [] ? __fget_light+0x2c/0x4d
[ 2088.914671]  [] __sys_sendmsg+0x42/0x60
[ 2088.915126]  [] SyS_sendmsg+0x12/0x1e
[ 2088.915534]  [] entry_SYSCALL_64_fastpath+0x12/0x71
[ 2088.915947] Code: 00 00 48 89 44 24 10 8b 87 c8 00 00 00 48 89 44 24 08 48 
8b 87 d8 00 00 00 48 c7 c7 29 ba 85 81 48 89 04 24 31 c0 e8 d4 4e bd ff <0f> 0b 
0f 1f 44 00 00 55 48 89 e5 41 54 4c 8d a7 a8 01 00 00 53 
[ 2088.917397] RIP  [] skb_panic+0x66/0x68
[ 2088.917914]  RSP 

I use this script, wh

Re: [PATCH] net: sh_eth: avoid NULL pointer dereference in ring setup

2016-03-02 Thread Wolfram Sang
> >Reported-by: coverity (CID 1056464)
> >Signed-off-by: Wolfram Sang 
> 
>Will you respin or should I?

Please go ahead. You have more knowledge about this driver, so you will
be faster.

Reported-by: Wolfram Sang 



signature.asc
Description: PGP signature


RE: [PATCH] fsl/fman: remove dTSEC-A003 Errata workaround

2016-03-02 Thread Igal Liberman
> -Original Message-
> From: Scott Wood [mailto:scott.w...@nxp.com]
> Sent: Tuesday, March 01, 2016 1:31 AM
> To: igal.liber...@freescale.com; netdev@vger.kernel.org
> Cc: scottw...@freescale.com; madalin.bu...@freescale.com
> Subject: Re: [PATCH] fsl/fman: remove dTSEC-A003 Errata workaround
> 
> On 02/29/2016 09:17 AM, igal.liber...@freescale.com wrote:
> > From: Igal Liberman 
> >
> > Errata dTSEC-A003 was fixed in P4080 rev 3.0.
> > Prior revisions are not supported, so the workaround can be removed.
> >
> > Signed-off-by: Igal Liberman 
> 
> Since when do we not support p4080 rev 2?
> 

Hi Scott,
According to the following link, only rev 3 part numbers are "Active". Rev 2 
part numbers are either "Not recommended for New Design" or "No Longer 
Manufactured".
http://www.nxp.com/products/microcontrollers-and-processors/power-architecture-processors/qoriq-power-architecture-processors/qoriq-p4080-p4040-p4081-multicore-communications-processors:P4080?fpsp=1&tab=Package_Quality_Tab

In addition,
P4080 rev 2 was removed in SDK 1.5 (2013). This can be seen here (requires 
registration):
https://freescale.sdlproducts.com/LiveContent/web/pub.xql?c=t&action=home&pub=QorIQ_SDK_1.9&lang=en-US#addHistory=true&filename=GUID-21A68B1F-4CD4-4959-9175-406D8FCD9A7A.xml&docid=GUID-21A68B1F-4CD4-4959-9175-406D8FCD9A7A&inner_id=&tid=&query=&scope=&resource=&toc=false&eventType=lcContent.loadDocGUID-21A68B1F-4CD4-4959-9175-406D8FCD9A7A
Click on "Supported Targets" and scroll down to P4080.
 
Igal

> -Scott



Re: [PATCH iproute2 v2] iplink: Support VF Trust

2016-03-02 Thread Stephen Hemminger
On Fri, 26 Feb 2016 02:40:18 +
Hiroshi Shimamoto  wrote:

> From: Hiroshi Shimamoto 
> 
> Add IFLA_VF_TRUST message to trust the VF.
> PF can accept some privileged operation from the trusted VF.
> For example, ixgbe PF doesn't allow to enable VF promiscuous mode until
> the VF is trusted because it may hurt performance.
> 
> To trust VF.
>  # ip link set dev eth0 vf 1 trust on
> 
> To untrust VF.
>  # ip link set dev eth0 vf 1 trust off
> 
> Signed-off-by: Hiroshi Shimamoto 

Applied.


Re: [PATCH iproute2 net-next] bridge: mdb: add user-space support for extended attributes

2016-03-02 Thread Stephen Hemminger
On Mon, 22 Feb 2016 15:00:21 +0100
Nikolay Aleksandrov  wrote:

> From: Nikolay Aleksandrov 
> 
> Recently support was added to the kernel to be able to add more per-mdb
> entry attributes via standard netlink attributes of type MDBA_MDB_EATTR_.
> This patch adds support to iproute2 to parse and output these
> attributes. The first exported attribute is the mdb "timer" value which
> is shown only when the "-d" iproute2 arg is used.
> 
> Example:
> $ bridge -d mdb show
> dev br0 port eth1 grp 239.0.0.11 permanent   0.00
> dev br0 port eth2 grp 239.0.0.11 permanent   0.00
> dev br0 port eth1 grp 239.0.0.10 temp 244.38
> dev br0 port eth1 grp 239.0.0.1 temp 245.41
> dev br0 port eth1 grp 239.0.0.5 temp 246.43
> dev br0 port eth2 grp 239.0.0.5 temp 248.48
> dev br0 port eth1 grp 239.0.0.2 temp 245.41
> 
> Signed-off-by: Nikolay Aleksandrov 

Applied.



Re: [iproute PATCH] ipl2tp: Print help even on systems without l2tp support

2016-03-02 Thread Stephen Hemminger
On Wed, 24 Feb 2016 09:12:47 +0100
Phil Sutter  wrote:

> Signed-off-by: Phil Sutter 

Applied


Re: [iproute PATCH 03/20] iplink: fix help text syntax

2016-03-02 Thread Stephen Hemminger
On Wed, 24 Feb 2016 09:21:16 +0100
Phil Sutter  wrote:

> Get rid of extraneous closing brackets and while here, merge the double
> netns parameter.
> 
> Signed-off-by: Phil Sutter 

Patch does not apply to current git.

Applying: iplink: fix help text syntax
error: patch failed: ip/iplink.c:70
error: ip/iplink.c: patch does not apply


Please rebase and resend the whole patch series with v2


Re: [PATCH] net: sh_eth: avoid NULL pointer dereference in ring setup

2016-03-02 Thread Sergei Shtylyov

On 03/02/2016 08:11 PM, Wolfram Sang wrote:


Reported-by: coverity (CID 1056464)
Signed-off-by: Wolfram Sang 


Will you respin or should I?


Please go ahead. You have more knowledge about this driver, so you will
be faster.


   Not necessarily -- I have other bug to chase right now. :-)


Reported-by: Wolfram Sang 


   Thanks for reporting, anyway.

MBR, Sergei



Re: [iproute PATCH 3/3] tc: pedit: Fix retain value for ihl adjustments

2016-03-02 Thread Stephen Hemminger
On Wed, 2 Mar 2016 11:20:31 +
Phil Sutter  wrote:

> + res = parse_cmd(&argc, &argv, 1, TU32,0x0f,sel,tkey);
>   goto done;
Please add whitespace after ,


Re: [net-next,v7] net: ipv6: Make address flushing on ifdown optional

2016-03-02 Thread Andrey Wagin
Hi David,

We execute CRIU test on linux-next. On the current linux-next kernel
they hangs on creating a network namespace.

The kernel log contains many massages like this:
[ 1036.122108] unregister_netdevice: waiting for lo to become free.
Usage count = 2
[ 1046.165156] unregister_netdevice: waiting for lo to become free.
Usage count = 2
[ 1056.210287] unregister_netdevice: waiting for lo to become free.
Usage count = 2

I tried to revert this patch and the bug disappeared.

Here is a set of commands to reproduce this bug:

[root@linux-next-test linux-next]# uname -a
Linux linux-next-test 4.5.0-rc6-next-20160301+ #3 SMP Wed Mar 2
17:32:18 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@linux-next-test ~]# unshare -n
[root@linux-next-test ~]# ip link set up dev lo
[root@linux-next-test ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN
group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
[root@linux-next-test ~]# logout
[root@linux-next-test ~]# unshare -n



^Z
...

Thanks,
Andrew


Re: skb_under_panic in ip_tunnel_xmit

2016-03-02 Thread Eric Dumazet
On mer., 2016-03-02 at 09:11 -0800, Francesco Ruggeri wrote:
> I can consistently get this  panic on 4.4.1 as well as 3.18.
> 
> [ 2076.264975] gre: GRE over IPv4 demultiplexor driver
> [ 2076.269326] ip_gre: GRE over IPv4 tunneling driver
> [ 2076.274464] conntrack: generic helper won't handle protocol 47. Please 
> consider loading the specific helper module.
> [ 2088.868553] skbuff: skb_under_panic: text:814c03f2 len:108 put:20 
> head:8800a5f6c400 data:8800a5f6c3f8 tail:0x64 end:0xc0 dev:t3
> [ 2088.869755] [ cut here ]
> [ 2088.870179] kernel BUG at net/core/skbuff.c:102!
> [ 2088.870599] invalid opcode:  [#1] SMP 
> [ 2088.871024] Modules linked in: ip_gre ip_tunnel gre dummy iptable_filter 
> rfcomm bnep macvlan snd_seq_midi snd_seq_midi_event btusb btrtl btbcm btintel 
> sg bluetooth joydev snd_ens1371 snd_ac97_codec ac97_bus coretemp hwmon 
> snd_seq snd_pcm snd_timer snd_rawmidi snd_seq_device snd ppdev soundcore 
> ip6table_filter ip6_tables bonding gameport serio_raw pcspkr battery kvm 
> parport_pc nfsd auth_rpcgss oid_registry parport irqbypass ac irda crc_ccitt 
> fuse nfs_acl lockd xt_multiport acpi_cpufreq tpm_tis tpm iptable_nat shpchp 
> grace nf_conntrack_ipv4 nf_defrag_ipv4 i2c_piix4 nf_nat_ipv4 ip_tables nf_nat 
> nf_conntrack x_tables tun 8021q uinput vmwgfx crc32c_intel drm_kms_helper 
> syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ehci_pci drm aesni_intel 
> aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd i2c_core
> [ 2088.875474]  sr_mod mptspi mptscsih ehci_hcd mptbase scsi_transport_spi 
> e1000 uhci_hcd cdrom sunrpc dm_mirror dm_region_hash dm_log dm_mod autofs4
> [ 2088.876737] CPU: 1 PID: 6420 Comm: ping Not tainted 
> 4.4.1-2980094.AroraKernelnextfruggeri.2.fc18.x86_64 #1
> [ 2088.878039] Hardware name: VMware, Inc. VMware Virtual Platform/440BX 
> Desktop Reference Platform, BIOS 6.00 07/02/2012
> [ 2088.879521] task: 880035ea ti: 8800b0ff8000 task.ti: 
> 8800b0ff8000
> [ 2088.880285] RIP: 0010:[]  [] 
> skb_panic+0x66/0x68
> [ 2088.881214] RSP: 0018:8800b0ffb728  EFLAGS: 00010292
> [ 2088.881945] RAX: 0083 RBX: 8800b51b6c00 RCX: 
> 
> [ 2088.882692] RDX: 88013ae2f101 RSI: 88013ae2cae8 RDI: 
> 88013ae2cae8
> [ 2088.883424] RBP: 8800b0ffb748 R08:  R09: 
> 
> [ 2088.884110] R10:  R11: 88013621f3e0 R12: 
> 0054
> [ 2088.884846] R13: 81a9fe40 R14:  R15: 
> 03030303
> [ 2088.885535] FS:  7f24b4a24740() GS:88013ae2() 
> knlGS:
> [ 2088.886270] CS:  0010 DS:  ES:  CR0: 80050033
> [ 2088.887014] CR2: 7f9d6fb26000 CR3: aae66000 CR4: 
> 001406e0
> [ 2088.887817] Stack:
> [ 2088.888582]  8800a5f6c3f8 0064 00c0 
> 880138fac000
> [ 2088.889378]  8800b0ffb758 8143b640 8800b0ffb7c8 
> 814c03f2
> [ 2088.890188]  8840 0040 8800 
> 002f
> [ 2088.891011] Call Trace:
> [ 2088.892073]  [] skb_push+0x3b/0x3c
> [ 2088.893156]  [] iptunnel_xmit+0xad/0x145
> [ 2088.894033]  [] ip_tunnel_xmit+0x673/0x790 [ip_tunnel]
> [ 2088.894884]  [] __gre_xmit+0x76/0x7f [ip_gre]
> [ 2088.895700]  [] ipgre_xmit+0xd3/0xef [ip_gre]
> [ 2088.896573]  [] dev_hard_start_xmit+0x226/0x2fc
> [ 2088.897387]  [] __dev_queue_xmit+0x333/0x425
> [ 2088.898183]  [] dev_queue_xmit+0x10/0x12
> [ 2088.898996]  [] neigh_direct_output+0x11/0x13
> [ 2088.899793]  [] ip_finish_output2+0x233/0x293
> [ 2088.900582]  [] ? dst_mtu+0xb/0xd
> [ 2088.901283]  [] ip_finish_output+0x146/0x159
> [ 2088.901990]  [] ? ip_generic_getfrag+0x5c/0x98
> [ 2088.902658]  [] ip_output+0x5f/0x91
> [ 2088.903306]  [] ? ip_finish_output2+0x293/0x293
> [ 2088.903964]  [] ? __ip_local_out+0x73/0x7c
> [ 2088.904625]  [] ? dst_mtu+0xd/0xd
> [ 2088.905222]  [] dst_output+0xf/0x11
> [ 2088.905820]  [] ip_local_out+0x31/0x3a
> [ 2088.906378]  [] ip_send_skb+0x1a/0x3f
> [ 2088.906938]  [] ip_push_pending_frames+0x33/0x3b
> [ 2088.907465]  [] raw_sendmsg+0x794/0x8ea
> [ 2088.907981]  [] ? __skb_recv_datagram+0x201/0x487
> [ 2088.908548]  [] ? skb_recv_datagram+0x32/0x34
> [ 2088.909050]  [] ? raw_recvmsg+0x68/0x159
> [ 2088.909705]  [] ? rw_copy_check_uvector+0x6e/0x109
> [ 2088.910247]  [] inet_sendmsg+0x3c/0x65
> [ 2088.910775]  [] sock_sendmsg_nosec+0x12/0x1d
> [ 2088.911279]  [] sock_sendmsg+0x29/0x2e
> [ 2088.911764]  [] ___sys_sendmsg+0x1a6/0x23f
> [ 2088.912349]  [] ? ldsem_up_read+0x1b/0x30
> [ 2088.912820]  [] ? tty_ldisc_deref+0x16/0x18
> [ 2088.913299]  [] ? tty_write+0x207/0x222
> [ 2088.913743]  [] ? n_tty_receive_buf+0x13/0x13
> [ 2088.914244]  [] ? __fget_light+0x2c/0x4d
> [ 2088.914671]  [] __sys_sendmsg+0x42/0x60
> [ 2088.915126]  [] SyS_sendmsg+0x12/0x1e
> [ 2088.915534]  [] entry_SYSCALL_64_fastpath+0x12/0x71
> [ 2088.915947] Code: 00 00 48 89 44 24 10 8b 87

Re: [PATCH/RFC v6 net-next] ravb: Add dma queue interrupt support

2016-03-02 Thread Yoshihiro Kaneko
2016-03-01 5:30 GMT+09:00 Sergei Shtylyov :
> Hello.
>
>
> On 02/28/2016 06:41 PM, Yoshihiro Kaneko wrote:
>
>> From: Kazuya Mizuguchi 
>>
>> This patch supports the following interrupts.
>>
>> - One interrupt for multiple (timestamp, error, gPTP)
>> - One interrupt for emac
>> - Four interrupts for dma queue (best effort rx/tx, network control rx/tx)
>>
>> This patch improve efficiency of the interrupt handler by adding the
>> interrupt handler corresponding to each interrupt source described
>> above. Additionally, it reduces the number of times of the access to
>> EthernetAVB IF.
>> Also this patch prevent this driver depends on the whim of a boot loader.
>>
>> [ykaneko0...@gmail.com: define bit names of registers]
>> [ykaneko0...@gmail.com: add comment for gen3 only registers]
>> [ykaneko0...@gmail.com: fix coding style]
>> [ykaneko0...@gmail.com: update changelog]
>> [ykaneko0...@gmail.com: gen3: fix initialization of interrupts]
>> [ykaneko0...@gmail.com: gen3: fix clearing interrupts]
>> [ykaneko0...@gmail.com: gen3: add helper function for request_irq()]
>> [ykaneko0...@gmail.com: gen3: remove IRQF_SHARED flag for request_irq()]
>> [ykaneko0...@gmail.com: revert ravb_close() and ravb_ptp_stop()]
>> [ykaneko0...@gmail.com: avoid calling free_irq() to non-hooked interrupts]
>> [ykaneko0...@gmail.com: make NC/BE interrupt handler a function]
>> [ykaneko0...@gmail.com: make timestamp interrupt handler a function]
>> [ykaneko0...@gmail.com: timestamp interrupt is handled in multiple
>>   interrupt handler instead of dma queue interrupt handler]
>> Signed-off-by: Kazuya Mizuguchi 
>> Signed-off-by: Yoshihiro Kaneko 
>
>
>OK, you are very close now! Just a few comments...
>
> [...]
>>
>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
>> b/drivers/net/ethernet/renesas/ravb_main.c
>> index c936682..22ef65d 100644
>> --- a/drivers/net/ethernet/renesas/ravb_main.c
>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
>
> [...]
>>
>> @@ -697,6 +726,47 @@ static void ravb_error_interrupt(struct net_device
>> *ndev)
>> }
>>   }
>>
>> +static bool ravb_queue_interrupt(struct net_device *ndev, int q,
>> +u32 ris0, u32 *ric0, u32 tis, u32 *tic)
>> +{
>> +   struct ravb_private *priv = netdev_priv(ndev);
>> +
>
>
>Perhaps it makes sense to read the RI[CS]0/TI[CS] here instead of passing
> them (by reference)?

OK, I will do.

>
> [...]
>
>> @@ -714,42 +784,21 @@ static irqreturn_t ravb_interrupt(int irq, void
>> *dev_id)
>> u32 ric0 = ravb_read(ndev, RIC0);
>> u32 tis  = ravb_read(ndev, TIS);
>> u32 tic  = ravb_read(ndev, TIC);
>> -   int q;
>>
>> /* Timestamp updated */
>> -   if (tis & TIS_TFUF) {
>> -   ravb_write(ndev, ~TIS_TFUF, TIS);
>> -   ravb_get_tx_tstamp(ndev);
>> +   if (ravb_timestamp_interrupt(ndev, tis))
>> result = IRQ_HANDLED;
>> -   }
>>
>> /* Network control and best effort queue RX/TX */
>> -   for (q = RAVB_NC; q >= RAVB_BE; q--) {
>> -   if (((ris0 & ric0) & BIT(q)) ||
>> -   ((tis  & tic)  & BIT(q))) {
>> -   if (napi_schedule_prep(&priv->napi[q])) {
>> -   /* Mask RX and TX interrupts */
>> -   ric0 &= ~BIT(q);
>> -   tic &= ~BIT(q);
>> -   ravb_write(ndev, ric0, RIC0);
>> -   ravb_write(ndev, tic, TIC);
>> -   __napi_schedule(&priv->napi[q]);
>> -   } else {
>> -   netdev_warn(ndev,
>> -   "ignoring interrupt,
>> rx status 0x%08x, rx mask 0x%08x,\n",
>> -   ris0, ric0);
>> -   netdev_warn(ndev,
>> -   "
>> tx status 0x%08x, tx mask 0x%08x.\n",
>> -   tis, tic);
>> -   }
>> -   result = IRQ_HANDLED;
>> -   }
>> -   }
>> +   if (ravb_queue_interrupt(ndev, RAVB_NC, ris0, &ric0, tis,
>> &tic))
>> +   result = IRQ_HANDLED;
>> +   if (ravb_queue_interrupt(ndev, RAVB_BE, ris0, &ric0, tis,
>> &tic))
>> +   result = IRQ_HANDLED;
>
>
>Hmm, perhaps unrolling wasn't such a great idea... we can't use || here
> as it would be short-circuited. :-(
>
> [...]
>>
>> +static irqreturn_t ravb_rx_tx_interrupt(int irq, void *dev_id, int
>> ravb_queue)
>
>
>Please, please shorten this 'ravb_queue'...

I will fix it.

>Also, would 

Re: [PATCH net-next] ipv4: properly apply change to ignore_routes_on_linkdown to all interfaces

2016-03-02 Thread David Ahern

On 3/2/16 8:43 AM, Andy Gospodarek wrote:


+/* called with RTNL locked */
+static void inet_ignore_routes_change(struct net *net)
+{
+   struct net_device *dev;
+   int on = IPV4_DEVCONF_ALL(net, IGNORE_ROUTES_WITH_LINKDOWN);
+
+   IPV4_DEVCONF_DFLT(net, IGNORE_ROUTES_WITH_LINKDOWN) = on;
+   inet_netconf_notify_devconf(net, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   NETCONFA_IFINDEX_ALL,
+   net->ipv4.devconf_all);
+   inet_netconf_notify_devconf(net, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   NETCONFA_IFINDEX_DEFAULT,
+   net->ipv4.devconf_dflt);
+
+   for_each_netdev(net, dev) {
+   struct in_device *in_dev;
+
+   rcu_read_lock();
+   in_dev = __in_dev_get_rcu(dev);
+   if (in_dev) {
+   IN_DEV_CONF_SET(in_dev,
+   IGNORE_ROUTES_WITH_LINKDOWN, on);
+   inet_netconf_notify_devconf(net,
+   
NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
+   dev->ifindex, &in_dev->cnf);
+   }
+   rcu_read_unlock();
+   }
+}
+


This seems wrong -- changing the 'all' and 'default' settings for a 
sysctl should not require walking the interface list.


[iproute PATCH v2 09/20] man: ip-link.8: minor font fix

2016-03-02 Thread Phil Sutter
We commonly use bold font for terminals and italic for non-terminals.

Signed-off-by: Phil Sutter 
---
 man/man8/ip-link.8.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 221831e52bc9a..2376f1653a8f2 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -49,7 +49,7 @@ ip-link \- network device configuration
 .RB "[ " numrxqueues
 .IR QUEUE_COUNT " ]"
 .br
-.BR type " TYPE"
+.BI type " TYPE"
 .RI "[ " ARGS " ]"
 
 .ti -8
-- 
2.7.2



[iproute PATCH v2 16/20] man: ip-tunnel.8: Document missing 6rd action

2016-03-02 Thread Phil Sutter
Also drop the non-terminal 'TIME' description as it is not referenced
anywhere.

Signed-off-by: Phil Sutter 
---
 man/man8/ip-tunnel.8 | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/man/man8/ip-tunnel.8 b/man/man8/ip-tunnel.8
index 8b746cb0f52b8..4938c7405ce85 100644
--- a/man/man8/ip-tunnel.8
+++ b/man/man8/ip-tunnel.8
@@ -11,7 +11,7 @@ ip-tunnel - tunnel configuration
 .ti -8
 .BR "ip "
 .RI "[ " OPTIONS " ]"
-.BR "tunnel" " { " add " | " change " | " del " | " show " | " prl " }"
+.BR "tunnel" " { " add " | " change " | " del " | " show " | " prl " | " 6rd " 
}"
 .RI "[ " NAME " ]"
 .br
 .RB "[ " mode
@@ -42,6 +42,12 @@ ip-tunnel - tunnel configuration
 .B prl-delete
 .IR ADDR " ]"
 .br
+.RB "[ " 6rd-prefix
+.IR ADDR " ] ["
+.B 6rd-relay_prefix
+.IR ADDR " ] [
+.BR 6rd-reset " ]"
+.br
 .RB "[ [" no "]" pmtudisc " ]"
 .RB "[ " dev
 .IR PHYS_DEV " ]"
@@ -75,9 +81,6 @@ ip-tunnel - tunnel configuration
 .ti -8
 .IR KEY " := { " DOTTED_QUAD " | " NUMBER " }"
 
-.ti -8
-.IR TIME " := " NUMBER "[s|ms]"
-
 .SH DESCRIPTION
 .B tunnel
 objects are tunnels, encapsulating packets in IP packets and then
-- 
2.7.2



[iproute PATCH v2 00/20] Sync man pages and help texts

2016-03-02 Thread Phil Sutter
This patch series aims at improving consistency of builtin help texts and
related man pages (synopsis section at least). It was created by
comparing the two and fixing up whatever occurred to be broken.

Changes since v1:
- rebased onto current master
- resolved merge conflict in ip-link.8.in due to added 'trust' option

Phil Sutter (20):
  ip: align help text with manpage
  ipaddrlabel: Improve help text precision
  iplink: fix help text syntax
  ipneigh: add missing proxy keyword to help text
  ipntable: Fix typo in help text
  iproute: TYPE keyword is not optional, fix help text accordingly
  iprule: add missing nat keyword to help text
  man: ip-address.8: Minor syntax fixes
  man: ip-link.8: minor font fix
  man: ip-link.8: Fix and improve synopsis
  man: ip-neighbour: Fix for missing NUD_STATE description
  man: ip-netns.8: Clarify synopsis a bit
  man: ip-ntable.8: Review synopsis section
  man: ip-rule.8: Review synopsis section
  man: ip-token.8: Review synopsis section
  man: ip-tunnel.8: Document missing 6rd action
  man: ip-xfrm.8: Document missing parameters
  man: ip.8: Add missing flags and token subcommand description
  man: ip-l2tp.8: Fix BNF syntax
  man: ip-*.8: drop any reference to generic ip options

 ip/ip.c  |   2 +-
 ip/ipaddrlabel.c |   3 +-
 ip/iplink.c  |   9 ++--
 ip/ipneigh.c |   2 +-
 ip/ipntable.c|   2 +-
 ip/iproute.c |   6 +--
 ip/iprule.c  |   1 +
 man/man8/ip-address.8.in |   8 ++--
 man/man8/ip-addrlabel.8  |  14 +-
 man/man8/ip-l2tp.8   |  24 --
 man/man8/ip-link.8.in| 117 +++
 man/man8/ip-monitor.8|   4 +-
 man/man8/ip-mroute.8 |   2 +-
 man/man8/ip-neighbour.8  |  11 +++--
 man/man8/ip-netns.8  |   4 +-
 man/man8/ip-ntable.8 |  39 +---
 man/man8/ip-rule.8   |  19 +---
 man/man8/ip-token.8  |  12 ++---
 man/man8/ip-tunnel.8 |  11 +++--
 man/man8/ip-xfrm.8   |  11 +
 man/man8/ip.8|  29 +++-
 21 files changed, 183 insertions(+), 147 deletions(-)

-- 
2.7.2



[iproute PATCH v2 11/20] man: ip-neighbour: Fix for missing NUD_STATE description

2016-03-02 Thread Phil Sutter
Signed-off-by: Phil Sutter 
---
 man/man8/ip-neighbour.8 | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/man/man8/ip-neighbour.8 b/man/man8/ip-neighbour.8
index c9b0256e12207..19c6d9d8bf605 100644
--- a/man/man8/ip-neighbour.8
+++ b/man/man8/ip-neighbour.8
@@ -18,7 +18,9 @@ ip-neighbour \- neighbour/arp tables management.
 .IR ADDR " [ "
 .B  lladdr
 .IR LLADDR " ] [ "
-.BR nud " { " permanent " | " noarp " | " stale " | " reachable " } ] | " proxy
+.B nud
+.IR STATE " ] |"
+.B proxy
 .IR ADDR " } [ "
 .B  dev
 .IR DEV " ]"
@@ -31,6 +33,9 @@ ip-neighbour \- neighbour/arp tables management.
 .B  nud
 .IR STATE " ]"
 
+.ti -8
+.IR STATE " := {"
+.BR permanent " | " noarp " | " stale " | " reachable " }"
 
 .SH DESCRIPTION
 The
@@ -75,7 +80,7 @@ can also be
 .BR "null" .
 
 .TP
-.BI nud " NUD_STATE"
+.BI nud " STATE"
 the state of the neighbour entry.
 .B nud
 is an abbreviation for 'Neighbour Unreachability Detection'.
@@ -147,7 +152,7 @@ list neighbour proxies.
 only list neighbours which are not currently in use.
 
 .TP
-.BI nud " NUD_STATE"
+.BI nud " STATE"
 only list neighbour entries in this state.
 .I NUD_STATE
 takes values listed below or the special value
-- 
2.7.2



[iproute PATCH v2 20/20] man: ip-*.8: drop any reference to generic ip options

2016-03-02 Thread Phil Sutter
Listing generic 'ip' options in subcommand man pages is redundant and
error-prone, as they won't be kept in sync anyway. Since many other man
pages don't list them either, drop references to them in the remaining
ones.

Signed-off-by: Phil Sutter 
---
 man/man8/ip-addrlabel.8 | 14 +-
 man/man8/ip-link.8.in   | 15 +--
 man/man8/ip-monitor.8   |  4 +---
 man/man8/ip-mroute.8|  2 +-
 4 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/man/man8/ip-addrlabel.8 b/man/man8/ip-addrlabel.8
index 51ef5727a0db1..233d6067ab407 100644
--- a/man/man8/ip-addrlabel.8
+++ b/man/man8/ip-addrlabel.8
@@ -6,21 +6,9 @@ ip-addrlabel \- protocol address label management
 .ad l
 .in +8
 .ti -8
-.B ip
-.RI "[ " OPTIONS " ]"
-.B addrlabel
+.B ip addrlabel
 .RI " { " COMMAND " | "
 .BR help " }"
-.sp
-
-.ti -8
-.IR OPTIONS " := { "
-\fB\-V\fR[\fIersion\fR] |
-\fB\-s\fR[\fItatistics\fR] |
-\fB\-r\fR[\fIesolve\fR] |
-\fB\-f\fR[\fIamily\fR] {
-.BR inet " | " inet6 " | " ipx " | " dnet " | " link " } | "
-\fB\-o\fR[\fIneline\fR] }
 
 .ti -8
 .BR "ip addrlabel" " { " add " | " del " } " prefix
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index e402fdd033165..c6a9c862dfda2 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -6,25 +6,12 @@ ip-link \- network device configuration
 .ad l
 .in +8
 .ti -8
-.B ip
-.RI "[ " OPTIONS " ]"
-.B link
+.B ip link
 .RI  " { " COMMAND " | "
 .BR help " }"
 .sp
 
 .ti -8
-.IR OPTIONS " := { "
-\fB\-V\fR[\fIersion\fR] |
-\fB\-h\fR[\fIuman-readable\fR] |
-\fB\-s\fR[\fItatistics\fR] |
-\fB\-r\fR[\fIesolve\fR] |
-\fB\-f\fR[\fIamily\fR] {
-.BR inet " | " inet6 " | " ipx " | " dnet " | " link " } | "
-\fB\-o\fR[\fIneline\fR] |
-\fB\-br\fR[\fIief\fR] }
-
-.ti -8
 .BI "ip link add"
 .RB "[ " link
 .IR DEVICE " ]"
diff --git a/man/man8/ip-monitor.8 b/man/man8/ip-monitor.8
index d2bd381a8c32e..86f8f9885fefe 100644
--- a/man/man8/ip-monitor.8
+++ b/man/man8/ip-monitor.8
@@ -6,9 +6,7 @@ ip-monitor, rtmon \- state monitoring
 .ad l
 .in +8
 .ti -8
-.BR "ip " " [ "
-.IR ip-OPTIONS " ]"
-.BR  "monitor" " [ " all " |"
+.BR "ip monitor" " [ " all " |"
 .IR OBJECT-LIST " ] ["
 .BI file " FILENAME "
 ] [
diff --git a/man/man8/ip-mroute.8 b/man/man8/ip-mroute.8
index e89b6b2d2cc56..b64e30d33d412 100644
--- a/man/man8/ip-mroute.8
+++ b/man/man8/ip-mroute.8
@@ -6,7 +6,7 @@ ip-mroute \- multicast routing cache management
 .ad l
 .in +8
 .ti -8
-.BR "ip " " [ ip-OPTIONS ] " "mroute show" " [ [ "
+.BR "ip mroute show" " [ [ "
 .BR " to " " ] "
 .IR PREFIX " ] [ "
 .B  from
-- 
2.7.2



[iproute PATCH v2 01/20] ip: align help text with manpage

2016-03-02 Thread Phil Sutter
Although the ip command accepts both "neighbor" and "neighbour" as
subcommand, I assume it's sufficient to list it in help text as just
"neigh" like ip.8 does.

Signed-off-by: Phil Sutter 
---
 ip/ip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ip.c b/ip/ip.c
index eea00b822088e..123f18133a2e5 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -49,7 +49,7 @@ static void usage(void)
fprintf(stderr,
 "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
 "   ip [ -force ] -batch filename\n"
-"where  OBJECT := { link | address | addrlabel | route | rule | neighbor | 
ntable |\n"
+"where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable 
|\n"
 "   tunnel | tuntap | maddress | mroute | mrule | monitor | 
xfrm |\n"
 "   netns | l2tp | fou | tcp_metrics | token | netconf }\n"
 "   OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
-- 
2.7.2



  1   2   3   >