Re: Code quality and XDP

2016-10-07 Thread Jesper Dangaard Brouer

On Sat, 8 Oct 2016 07:25:01 +0900 Tom Herbert  wrote:

> One concern raised at netdev concerning XDP is how are we going to
> maintain code quality, security, and correctness of programs being
> loaded. With kernel bypass it is not just the kernel code path that is
> being bypassed, but also the processes that hold the quality of code
> being accepted to a high bar. Our users expect that quality to be
> maintained.
> 
> I suggest that we need XDP programs to be subject to the same scrutiny
> that any other kernel netdev code is. One idea is to sign programs
> that have been accepted into the kernel. By default only signed
> programs would be allowed to be loaded, the override to allow unsigned
> programs might be a kernel config or a least a boot parameter
> (enabling the override needs to be very explicit).

Sorry, I think this "lock-down" will kill the DDoS use-case.  In the
DDoS mitigation use-case, is all about flexibility to adapt quickly to
changing attacks.  Thus, you need the ability to quickly modify your
programs to catch attack signatures.


> The acceptable XDP programs should probably be under their own
> directory. Such a directory should only contain kernel code, not
> userspace code also as is currently in samples/bpf.
>
> A nice side effect of this model is when the same XDP programs are
> being used in non-Linux environments (HW offload, other OSes, etc.)
> the process could maintain quality expections in those environments
> also.

I'm not against having some 'signed' eBPF/XDP programs.  If a XDP
programs behavior is well-defined enough, this would also open up for
HW offloading of "programs" that does the same functionality (without
looking at the eBPF code).

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer


Re: [PATCH] wan/fsl_ucc_hdlc: Fix size used in dma_free_coherent()

2016-10-07 Thread David Miller
From: Christophe JAILLET 
Date: Fri,  7 Oct 2016 22:58:47 +0200

> Size used with 'dma_alloc_coherent()' and 'dma_free_coherent()' should be
> consistent.
> Here, the size of a pointer is used in dma_alloc... and the size of the
> pointed structure is used in dma_free...
> 
> This has been spotted with coccinelle, using the following script:
> 
> @r@
> expression x0, x1, y0, y1, z0, z1, t0, t1, ret;
> @@
> 
> *   ret = dma_alloc_coherent(x0, y0, z0, t0);
> ...
> *   dma_free_coherent(x1, y1, ret, t1);
> 
> 
> @script:python@
> y0 << r.y0;
> y1 << r.y1;
> 
> @@
> if y1.find(y0) == -1:
>  print "WARNING: sizes look different:  '%s'   vs   '%s'" % (y0, y1)
> 
> 
> Signed-off-by: Christophe JAILLET 

Looks good to me, applied, thanks.


Re: [PATCH] net: macb: NULL out phydev after removing mdio bus

2016-10-07 Thread David Miller
From: Xander Huff 
Date: Fri, 7 Oct 2016 10:13:22 -0500

> From: Nathan Sullivan 
> 
> To ensure the dev->phydev pointer is not used after becoming invalid in
> mdiobus_unregister, set it to NULL. This happens when removing the macb
> driver without first taking its interface down, since unregister_netdev
> will end up calling macb_close.
> 
> Signed-off-by: Xander Huff 
> Signed-off-by: Nathan Sullivan 
> Signed-off-by: Brad Mouring 

Applied.


Re: [PATCH v2 net] xen-netback: make sure that hashes are not send to unaware frontends

2016-10-07 Thread David Miller
From: Paul Durrant 
Date: Fri, 7 Oct 2016 09:32:31 +0100

> In the case when a frontend only negotiates a single queue with xen-
> netback it is possible for a skbuff with a s/w hash to result in a
> hash extra_info segment being sent to the frontend even when no hash
> algorithm has been configured. (The ndo_select_queue() entry point makes
> sure the hash is not set if no algorithm is configured, but this entry
> point is not called when there is only a single queue). This can result
> in a frontend that is unable to handle extra_info segments being given
> such a segment, causing it to crash.
> 
> This patch fixes the problem by clearing the hash in ndo_start_xmit()
> instead, which is clearly guaranteed to be called irrespective of the
> number of queues.
> 
> Signed-off-by: Paul Durrant 

Applied, thanks.


Re: [PATCH net v2] Fixing a bug in team driver due to incorrect 'unsigned int' to 'int' conversion

2016-10-07 Thread David Miller
From: Alex Sidorenko 
Date: Fri, 07 Oct 2016 09:02:33 -0400

> Roundrobin runner of team driver uses 'unsigned int' variable to count
> the number of sent_packets. Later it is passed to a subroutine
> team_num_to_port_index(struct team *team, int num) as 'num' and when
> we reach MAXINT (2**31-1), 'num' becomes negative.
> 
> This leads to using incorrect hash-bucket for port lookup
> and as a result, packets are dropped. The fix consists of changing 
> 'int num' to 'unsigned int num'. Testing of a fixed kernel shows that
> there is no packet drop anymore.
> 
> 
> Signed-off-by: Alex Sidorenko 

Applied and queued up for -stable, thanks.


Re: [PATCH net-next] MAINTAINERS: add myself as a maintainer of xen-netback

2016-10-07 Thread David Miller
From: Paul Durrant 
Date: Fri, 7 Oct 2016 11:33:37 +0100

> Signed-off-by: Paul Durrant 

Applied.


Re: Reversion of "xen-netback: create a debugfs node for hash information"

2016-10-07 Thread David Miller
From: Paul Durrant 
Date: Fri, 7 Oct 2016 09:50:04 +

>   I notice that you have made the above reversion of commit c0c64c15
>   (debugfs node) due to a build failure, despite the failure being
>   caused by commit 0364a882 (switch to threaded irq) which was made
>   subsequently. I assume you want me to re-spin a new patch for the
>   debugfs node to fix the build problem?

Yes, that's probably what you need to do.

Thanks.


Re: [PATCH v2] ipv6 addrconf: disallow rtr_solicits < -1

2016-10-07 Thread David Miller
From: Maciej Żenczykowski 
Date: Fri,  7 Oct 2016 01:00:49 -0700

> From: Maciej Żenczykowski 
> 
> This disallows setting /proc/sys/net/ipv6/conf/*/router_solicitations
> to values below -1.
> 
> -1 continues to mean an unlimited number of retransmits.
> 
> Note: this depends on 'ipv6 addrconf: remove addrconf_sysctl_hop_limit()'
> 
> Signed-off-by: Maciej Żenczykowski 

Applied, thanks.


[PATCH net-next] sctp: remove the old ttl expires policy

2016-10-07 Thread Xin Long
The prsctp polices include ttl expires policy already, we should remove
the old ttl expires codes, and just adjust the new polices' codes to be
compatible with the old one for users.

This patch is to remove all the old expires codes, and if prsctp polices
are not set, it will still set msg's expires_at and check the expires in
sctp_check_abandoned.

Note that asoc->prsctp_enable is set by default, so users can't feel any
difference even if they use the old expires api in userspace.

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h |  1 -
 net/sctp/chunk.c   | 32 
 net/sctp/output.c  |  3 ---
 3 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 11c3bf2..61732e9 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -530,7 +530,6 @@ struct sctp_datamsg {
/* Did the messenge fail to send? */
int send_error;
u8 send_failed:1,
-  can_abandon:1,   /* can chunks from this message can be abandoned. */
   can_delay;   /* should this message be Nagle delayed */
 };
 
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 7a1cdf4..615f0dd 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -52,7 +52,6 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg)
atomic_set(>refcnt, 1);
msg->send_failed = 0;
msg->send_error = 0;
-   msg->can_abandon = 0;
msg->can_delay = 1;
msg->expires_at = 0;
INIT_LIST_HEAD(>chunks);
@@ -182,20 +181,11 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct 
sctp_association *asoc,
/* Note: Calculate this outside of the loop, so that all fragments
 * have the same expiration.
 */
-   if (sinfo->sinfo_timetolive) {
-   /* sinfo_timetolive is in milliseconds */
+   if (asoc->peer.prsctp_capable && sinfo->sinfo_timetolive &&
+   (SCTP_PR_TTL_ENABLED(sinfo->sinfo_flags) ||
+!SCTP_PR_POLICY(sinfo->sinfo_flags)))
msg->expires_at = jiffies +
msecs_to_jiffies(sinfo->sinfo_timetolive);
-   msg->can_abandon = 1;
-
-   pr_debug("%s: msg:%p expires_at:%ld jiffies:%ld\n", __func__,
-msg, msg->expires_at, jiffies);
-   }
-
-   if (asoc->peer.prsctp_capable &&
-   SCTP_PR_TTL_ENABLED(sinfo->sinfo_flags))
-   msg->expires_at =
-   jiffies + msecs_to_jiffies(sinfo->sinfo_timetolive);
 
/* This is the biggest possible DATA chunk that can fit into
 * the packet
@@ -354,18 +344,8 @@ errout:
 /* Check whether this message has expired. */
 int sctp_chunk_abandoned(struct sctp_chunk *chunk)
 {
-   if (!chunk->asoc->peer.prsctp_capable ||
-   !SCTP_PR_POLICY(chunk->sinfo.sinfo_flags)) {
-   struct sctp_datamsg *msg = chunk->msg;
-
-   if (!msg->can_abandon)
-   return 0;
-
-   if (time_after(jiffies, msg->expires_at))
-   return 1;
-
+   if (!chunk->asoc->peer.prsctp_capable)
return 0;
-   }
 
if (SCTP_PR_TTL_ENABLED(chunk->sinfo.sinfo_flags) &&
time_after(jiffies, chunk->msg->expires_at)) {
@@ -378,6 +358,10 @@ int sctp_chunk_abandoned(struct sctp_chunk *chunk)
   chunk->sent_count > chunk->sinfo.sinfo_timetolive) {
chunk->asoc->abandoned_sent[SCTP_PR_INDEX(RTX)]++;
return 1;
+   } else if (!SCTP_PR_POLICY(chunk->sinfo.sinfo_flags) &&
+  chunk->msg->expires_at &&
+  time_after(jiffies, chunk->msg->expires_at)) {
+   return 1;
}
/* PRIO policy is processed by sendmsg, not here */
 
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 2a5c189..f0af831 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -865,9 +865,6 @@ static void sctp_packet_append_data(struct sctp_packet 
*packet,
rwnd = 0;
 
asoc->peer.rwnd = rwnd;
-   /* Has been accepted for transmission. */
-   if (!asoc->peer.prsctp_capable)
-   chunk->msg->can_abandon = 0;
sctp_chunk_assign_tsn(chunk);
sctp_chunk_assign_ssn(chunk);
 }
-- 
2.1.0



[PATCH net-next] sctp: reuse sent_count to avoid retransmitted chunks for RTT measurements

2016-10-07 Thread Xin Long
Now sctp uses chunk->resent to record if a chunk is retransmitted, for
RTT measurements with retransmitted DATA chunks. chunk->sent_count was
introduced to record how many times one chunk has been sent for prsctp
RTX policy before. We actually can know if one chunk is retransmitted
by checking chunk->sent_count is greater than 1.

This patch is to remove resent from sctp_chunk and reuse sent_count
to avoid retransmitted chunks for RTT measurements.

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h | 2 +-
 net/sctp/output.c  | 3 ++-
 net/sctp/outqueue.c| 4 +---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 11c3bf2..27a933e 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -641,7 +641,6 @@ struct sctp_chunk {
 #define SCTP_NEED_FRTX 0x1
 #define SCTP_DONT_FRTX 0x2
__u16   rtt_in_progress:1,  /* This chunk used for RTT calc? */
-   resent:1,   /* Has this chunk ever been resent. */
has_tsn:1,  /* Does this chunk have a TSN yet? */
has_ssn:1,  /* Does this chunk have a SSN yet? */
singleton:1,/* Only chunk in the packet? */
@@ -656,6 +655,7 @@ struct sctp_chunk {
fast_retransmit:2;  /* Is this chunk fast retransmitted? */
 };
 
+#define sctp_chunk_retransmitted(chunk)(chunk->sent_count > 1)
 void sctp_chunk_hold(struct sctp_chunk *);
 void sctp_chunk_put(struct sctp_chunk *);
 int sctp_user_addto_chunk(struct sctp_chunk *chunk, int len,
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 2a5c189..84f66d5 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -552,7 +552,8 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t 
gfp)
 * for a given destination transport address.
 */
 
-   if (!chunk->resent && !tp->rto_pending) {
+   if (!sctp_chunk_retransmitted(chunk) &&
+   !tp->rto_pending) {
chunk->rtt_in_progress = 1;
tp->rto_pending = 1;
}
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 5825853..e540826 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -507,8 +507,6 @@ void sctp_retransmit_mark(struct sctp_outq *q,
transport->rto_pending = 0;
}
 
-   chunk->resent = 1;
-
/* Move the chunk to the retransmit queue. The chunks
 * on the retransmit queue are always kept in order.
 */
@@ -1439,7 +1437,7 @@ static void sctp_check_transmitted(struct sctp_outq *q,
 * instance).
 */
if (!tchunk->tsn_gap_acked &&
-   !tchunk->resent &&
+   !sctp_chunk_retransmitted(tchunk) &&
tchunk->rtt_in_progress) {
tchunk->rtt_in_progress = 0;
rtt = jiffies - tchunk->sent_at;
-- 
2.1.0



RE: [v12, 0/8] Fix eSDHC host version register bug

2016-10-07 Thread Y.B. Lu
Hi Uffe, Arnd and Scott,

Any comments on this latest patcheset?
Could we consider to merge it if no any other changes needed?
:)


Thanks.

Best regards,
Yangbo Lu

> -Original Message-
> From: Y.B. Lu
> Sent: Monday, September 26, 2016 11:15 AM
> To: linux-...@vger.kernel.org; ulf.hans...@linaro.org; Scott Wood; Arnd
> Bergmann
> Cc: linuxppc-...@lists.ozlabs.org; devicet...@vger.kernel.org; linux-arm-
> ker...@lists.infradead.org; linux-ker...@vger.kernel.org; linux-
> c...@vger.kernel.org; linux-...@vger.kernel.org; iommu@lists.linux-
> foundation.org; netdev@vger.kernel.org; Mark Rutland; Rob Herring;
> Russell King; Jochen Friedrich; Joerg Roedel; Claudiu Manoil; Bhupesh
> Sharma; Qiang Zhao; Kumar Gala; Santosh Shilimkar; Leo Li; X.B. Xie; M.H.
> Lian
> Subject: RE: [v12, 0/8] Fix eSDHC host version register bug
> 
> Any comments about this version patchset ?
> 
> :)
> 
> 
> > -Original Message-
> > From: Yangbo Lu [mailto:yangbo...@nxp.com]
> > Sent: Wednesday, September 21, 2016 2:57 PM
> > To: linux-...@vger.kernel.org; ulf.hans...@linaro.org; Scott Wood;
> > Arnd Bergmann
> > Cc: linuxppc-...@lists.ozlabs.org; devicet...@vger.kernel.org;
> > linux-arm- ker...@lists.infradead.org; linux-ker...@vger.kernel.org;
> > linux- c...@vger.kernel.org; linux-...@vger.kernel.org;
> > iommu@lists.linux- foundation.org; netdev@vger.kernel.org; Mark
> > Rutland; Rob Herring; Russell King; Jochen Friedrich; Joerg Roedel;
> > Claudiu Manoil; Bhupesh Sharma; Qiang Zhao; Kumar Gala; Santosh
> Shilimkar; Leo Li; X.B. Xie; M.H.
> > Lian; Y.B. Lu
> > Subject: [v12, 0/8] Fix eSDHC host version register bug
> >
> > This patchset is used to fix a host version register bug in the T4240-
> > R1.0-R2.0 eSDHC controller. To match the SoC version and revision, 10
> > previous version patchsets had tried many methods but all of them were
> > rejected by reviewers.
> > Such as
> > - dts compatible method
> > - syscon method
> > - ifdef PPC method
> > - GUTS driver getting SVR method
> > Anrd suggested a soc_device_match method in v10, and this is the only
> > available method left now. This v11 patchset introduces the
> > soc_device_match interface in soc driver.
> >
> > The first six patches of Yangbo are to add the GUTS driver. This is
> > used to register a soc device which contain soc version and revision
> > information.
> > The other two patches introduce the soc_device_match method in soc
> > driver and apply it on esdhc driver to fix this bug.
> >
> > Arnd Bergmann (1):
> >   base: soc: introduce soc_device_match() interface
> >
> > Yangbo Lu (7):
> >   dt: bindings: update Freescale DCFG compatible
> >   ARM64: dts: ls2080a: add device configuration node
> >   dt: bindings: move guts devicetree doc out of powerpc directory
> >   powerpc/fsl: move mpc85xx.h to include/linux/fsl
> >   soc: fsl: add GUTS driver for QorIQ platforms
> >   MAINTAINERS: add entry for Freescale SoC drivers
> >   mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0
> >
> >  Documentation/devicetree/bindings/arm/fsl.txt  |   6 +-
> >  .../bindings/{powerpc => soc}/fsl/guts.txt |   3 +
> >  MAINTAINERS|  11 +-
> >  arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi |   6 +
> >  arch/powerpc/kernel/cpu_setup_fsl_booke.S  |   2 +-
> >  arch/powerpc/sysdev/fsl_pci.c  |   2 +-
> >  drivers/base/Kconfig   |   1 +
> >  drivers/base/soc.c |  66 ++
> >  drivers/clk/clk-qoriq.c|   3 +-
> >  drivers/i2c/busses/i2c-mpc.c   |   2 +-
> >  drivers/iommu/fsl_pamu.c   |   3 +-
> >  drivers/mmc/host/Kconfig   |   1 +
> >  drivers/mmc/host/sdhci-of-esdhc.c  |  20 ++
> >  drivers/net/ethernet/freescale/gianfar.c   |   2 +-
> >  drivers/soc/Kconfig|   2 +-
> >  drivers/soc/fsl/Kconfig|  19 ++
> >  drivers/soc/fsl/Makefile   |   1 +
> >  drivers/soc/fsl/guts.c | 257
> > +
> >  include/linux/fsl/guts.h   | 125 ++
> >  .../asm/mpc85xx.h => include/linux/fsl/svr.h   |   4 +-
> >  include/linux/sys_soc.h|   3 +
> >  21 files changed, 478 insertions(+), 61 deletions(-)  rename
> > Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt (91%)
> > create mode 100644 drivers/soc/fsl/Kconfig  create mode 100644
> > drivers/soc/fsl/guts.c  rename arch/powerpc/include/asm/mpc85xx.h =>
> > include/linux/fsl/svr.h (97%)
> >
> > --
> > 2.1.0.27.g96db324



[PATCH] vmxnet3: avoid assumption about invalid dma_pa in vmxnet3_set_mc()

2016-10-07 Thread Alexey Khoroshilov
vmxnet3_set_mc() still assumes zero is invalid pa:
  it assumes dma_mapping_error(...,0) returns true if vmxnet3_copy_mc() fails;
  it calls dma_unmap_single() iff new_table_pa is not zero.

The patch adds an explicit variable to track status of new_table_pa.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index b5554f2ebee4..5ee059eafe9c 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2279,6 +2279,7 @@ vmxnet3_set_mc(struct net_device *netdev)
>shared->devRead.rxFilterConf;
u8 *new_table = NULL;
dma_addr_t new_table_pa = 0;
+   int new_table_pa_valid = 0;
u32 new_mode = VMXNET3_RXM_UCAST;
 
if (netdev->flags & IFF_PROMISC) {
@@ -2307,13 +2308,15 @@ vmxnet3_set_mc(struct net_device *netdev)
new_table,
sz,
PCI_DMA_TODEVICE);
+   if (!dma_mapping_error(>pdev->dev,
+  new_table_pa)) {
+   new_mode |= VMXNET3_RXM_MCAST;
+   new_table_pa_valid = 1;
+   rxConf->mfTablePA = cpu_to_le64(
+   new_table_pa);
+   }
}
-
-   if (!dma_mapping_error(>pdev->dev,
-  new_table_pa)) {
-   new_mode |= VMXNET3_RXM_MCAST;
-   rxConf->mfTablePA = cpu_to_le64(new_table_pa);
-   } else {
+   if (!new_table_pa_valid) {
netdev_info(netdev,
"failed to copy mcast list, setting 
ALL_MULTI\n");
new_mode |= VMXNET3_RXM_ALL_MULTI;
@@ -2338,7 +2341,7 @@ vmxnet3_set_mc(struct net_device *netdev)
   VMXNET3_CMD_UPDATE_MAC_FILTERS);
spin_unlock_irqrestore(>cmd_lock, flags);
 
-   if (new_table_pa)
+   if (new_table_pa_valid)
dma_unmap_single(>pdev->dev, new_table_pa,
 rxConf->mfTableLen, PCI_DMA_TODEVICE);
kfree(new_table);
-- 
2.7.4



[PATCH v3 net-next 0/2] net: centralize net_device MTU bounds checking

2016-10-07 Thread Jarod Wilson
Jarod Wilson (2):
  net: centralize net_device min/max MTU checking
  net: deprecate eth_change_mtu, remove usage

While looking into an MTU issue with sfc, I started noticing that almost
every NIC driver with an ndo_change_mtu function implemented almost
exactly the same range checks, and in many cases, that was the only
practical thing their ndo_change_mtu function was doing. Quite a few
drivers have either 68, 64, 60 or 46 as their minimum MTU value checked,
and then various sizes from 1500 to 65535 for their maximum MTU value. We
can remove a whole lot of redundant code here if we simple store min_mtu
and max_mtu in net_device, and check against those in net/core/dev.c's
dev_set_mtu().

This pair of patches looks to introduce centralized MTU range checking
infrastructure, while maintaining compatibility with all existing drivers,
and start to make use of it, converting all eth_change_mtu/ether_setup users
over to this new infra.

Assuming these pass review muster, I've got a ton of follow-on patches to
clean up MTU settings for everything in the kernel with an ndo_change_mtu.

This work is all staged in a (rebasing) git tree here:

https://github.com/jarodwilson/linux-muck

The master branch is based on net-next from Oct 7, and carries these two
patches, plus a ton of follow-on patches to eliminate MTU range checks
and change_mtu functions where possible. All patches were successfully
built across 160 various arch and config combos by the 0-day folks.
(Thanks to Andrew Lunn for the suggestion to get that going).

Jarod Wilson (2):
  net: centralize net_device min/max MTU checking
  net: deprecate eth_change_mtu, remove usage

CC: netdev@vger.kernel.org
-- 
2.10.0



[PATCH v3 net-next 2/2] net: deprecate eth_change_mtu, remove usage

2016-10-07 Thread Jarod Wilson
With centralized MTU checking, there's nothing productive done by
eth_change_mtu that isn't already done in dev_set_mtu, so mark it as
deprecated and remove all usage of it in the kernel. All callers have been
audited for calls to alloc_etherdev* or ether_setup directly, which means
they all have a valid dev->min_mtu and dev->max_mtu. Now eth_change_mtu
prints out a netdev_warn about being deprecated, for the benefit of
out-of-tree drivers that might be utilizing it.

Of note, dvb_net.c actually had dev->mtu = 4096, while using
eth_change_mtu, meaning that if you ever tried changing it's mtu, you
couldn't set it above 1500 anymore. It's now getting dev->max_mtu also set
to 4096 to remedy that.

v2: fix up lantiq_etop, missed breakage due to drive not compiling on x86

CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson 
---
 arch/m68k/emu/nfeth.c |  1 -
 drivers/isdn/hysdn/hysdn_net.c|  1 -
 drivers/media/dvb-core/dvb_net.c  |  2 +-
 drivers/net/appletalk/ipddp.c |  1 -
 drivers/net/cris/eth_v10.c|  1 -
 drivers/net/ethernet/3com/3c509.c |  1 -
 drivers/net/ethernet/3com/3c515.c |  1 -
 drivers/net/ethernet/3com/3c574_cs.c  |  1 -
 drivers/net/ethernet/3com/3c589_cs.c  |  1 -
 drivers/net/ethernet/3com/3c59x.c |  2 --
 drivers/net/ethernet/3com/typhoon.c   |  1 -
 drivers/net/ethernet/8390/8390.c  |  1 -
 drivers/net/ethernet/8390/8390p.c |  1 -
 drivers/net/ethernet/8390/ax88796.c   |  1 -
 drivers/net/ethernet/8390/axnet_cs.c  |  1 -
 drivers/net/ethernet/8390/etherh.c|  1 -
 drivers/net/ethernet/8390/hydra.c |  1 -
 drivers/net/ethernet/8390/mac8390.c   |  1 -
 drivers/net/ethernet/8390/mcf8390.c   |  1 -
 drivers/net/ethernet/8390/ne2k-pci.c  |  1 -
 drivers/net/ethernet/8390/pcnet_cs.c  |  1 -
 drivers/net/ethernet/8390/smc-ultra.c |  1 -
 drivers/net/ethernet/8390/wd.c|  1 -
 drivers/net/ethernet/8390/zorro8390.c |  1 -
 drivers/net/ethernet/adaptec/starfire.c   |  1 -
 drivers/net/ethernet/adi/bfin_mac.c   |  1 -
 drivers/net/ethernet/allwinner/sun4i-emac.c   |  1 -
 drivers/net/ethernet/amd/a2065.c  |  1 -
 drivers/net/ethernet/amd/am79c961a.c  |  1 -
 drivers/net/ethernet/amd/ariadne.c|  1 -
 drivers/net/ethernet/amd/atarilance.c |  1 -
 drivers/net/ethernet/amd/au1000_eth.c |  1 -
 drivers/net/ethernet/amd/declance.c   |  1 -
 drivers/net/ethernet/amd/hplance.c|  1 -
 drivers/net/ethernet/amd/lance.c  |  1 -
 drivers/net/ethernet/amd/mvme147.c|  1 -
 drivers/net/ethernet/amd/ni65.c   |  1 -
 drivers/net/ethernet/amd/nmclan_cs.c  |  1 -
 drivers/net/ethernet/amd/pcnet32.c|  1 -
 drivers/net/ethernet/amd/sun3lance.c  |  1 -
 drivers/net/ethernet/amd/sunlance.c   |  1 -
 drivers/net/ethernet/apm/xgene/xgene_enet_main.c  |  1 -
 drivers/net/ethernet/apple/bmac.c |  1 -
 drivers/net/ethernet/apple/mace.c |  1 -
 drivers/net/ethernet/apple/macmace.c  |  1 -
 drivers/net/ethernet/aurora/nb8800.c  |  1 -
 drivers/net/ethernet/cadence/macb.c   |  1 -
 drivers/net/ethernet/cirrus/cs89x0.c  |  1 -
 drivers/net/ethernet/cirrus/ep93xx_eth.c  |  1 -
 drivers/net/ethernet/cirrus/mac89x0.c |  1 -
 drivers/net/ethernet/davicom/dm9000.c |  1 -
 drivers/net/ethernet/dec/tulip/de2104x.c  |  1 -
 drivers/net/ethernet/dec/tulip/de4x5.c|  1 -
 drivers/net/ethernet/dec/tulip/dmfe.c |  1 -
 drivers/net/ethernet/dec/tulip/tulip_core.c   |  1 -
 drivers/net/ethernet/dec/tulip/uli526x.c  |  1 -
 drivers/net/ethernet/dec/tulip/winbond-840.c  |  1 -
 drivers/net/ethernet/dec/tulip/xircom_cb.c|  1 -
 drivers/net/ethernet/dnet.c   |  1 -
 drivers/net/ethernet/ec_bhf.c |  1 -
 drivers/net/ethernet/fealnx.c |  1 -
 drivers/net/ethernet/freescale/fec_main.c |  1 -
 drivers/net/ethernet/freescale/fec_mpc52xx.c  |  1 -
 drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c |  1 -
 drivers/net/ethernet/freescale/ucc_geth.c |  1 -
 drivers/net/ethernet/fujitsu/fmvj18x_cs.c |  1 -
 drivers/net/ethernet/hisilicon/hip04_eth.c 

[PATCH v3 net-next 1/2] net: centralize net_device min/max MTU checking

2016-10-07 Thread Jarod Wilson
While looking into an MTU issue with sfc, I started noticing that almost
every NIC driver with an ndo_change_mtu function implemented almost
exactly the same range checks, and in many cases, that was the only
practical thing their ndo_change_mtu function was doing. Quite a few
drivers have either 68, 64, 60 or 46 as their minimum MTU value checked,
and then various sizes from 1500 to 65535 for their maximum MTU value. We
can remove a whole lot of redundant code here if we simple store min_mtu
and max_mtu in net_device, and check against those in net/core/dev.c's
dev_set_mtu().

In theory, there should be zero functional change with this patch, it just
puts the infrastructure in place. Subsequent patches will attempt to start
using said infrastructure, with theoretically zero change in
functionality.

CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson 
---
v3: retain new_mtu < 0 check to prevent integral promotions,
as pointed out by Jakub Sitnicki.

 include/linux/netdevice.h |  4 
 net/core/dev.c| 13 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 136ae6bb..fbdf923 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1506,6 +1506,8 @@ enum netdev_priv_flags {
  * @if_port:   Selectable AUI, TP, ...
  * @dma:   DMA channel
  * @mtu:   Interface MTU value
+ * @min_mtu:   Interface Minimum MTU value
+ * @max_mtu:   Interface Maximum MTU value
  * @type:  Interface hardware type
  * @hard_header_len: Maximum hardware header length.
  *
@@ -1726,6 +1728,8 @@ struct net_device {
unsigned char   dma;
 
unsigned intmtu;
+   unsigned intmin_mtu;
+   unsigned intmax_mtu;
unsigned short  type;
unsigned short  hard_header_len;
 
diff --git a/net/core/dev.c b/net/core/dev.c
index f1fe26f..f376639 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6499,9 +6499,18 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
if (new_mtu == dev->mtu)
return 0;
 
-   /*  MTU must be positive.*/
-   if (new_mtu < 0)
+   /* MTU must be positive, and in range */
+   if (new_mtu < 0 || new_mtu < dev->min_mtu) {
+   net_err_ratelimited("%s: Invalid MTU %d requested, hw min %d\n",
+   dev->name, new_mtu, dev->min_mtu);
return -EINVAL;
+   }
+
+   if (dev->max_mtu > 0 && new_mtu > dev->max_mtu) {
+   net_err_ratelimited("%s: Invalid MTU %d requested, hw max %d\n",
+   dev->name, new_mtu, dev->min_mtu);
+   return -EINVAL;
+   }
 
if (!netif_device_present(dev))
return -ENODEV;
-- 
2.10.0



Re: Accelerated receive flow steering (aRFS) for UDP

2016-10-07 Thread Eric Dumazet
On Fri, 2016-10-07 at 22:55 +, Chopra, Manish wrote:
> Hello Folks,
> 
> I am experimenting aRFS with our NIC devices, and for that I have
> kernel 4.8.x installed with below config.
> 
> CONFIG_RPS=y
> CONFIG_RFS_ACCEL=y
> 
> # cat /proc/cpuinfo  | grep processor
> processor   : 0
> processor   : 1
> processor   : 2
> processor   : 3
> processor   : 4
> processor   : 5
> processor   : 6
> processor   : 7
> processor   : 8
> processor   : 9
> processor   : 10
> processor   : 11
> processor   : 12
> processor   : 13
> processor   : 14
> processor   : 15
> 
> I configured rps_sock_flow_entries  and our NIC rx queues with below
> values
> 
> echo 32768 > /proc/sys/net/core/rps_sock_flow_entries
> echo 4096 > /sys/class/net/p4p1/queues/rx-0/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-1/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-2/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-3/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-4/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-5/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-6/rps_flow_cnt
> echo 4096 > /sys/class/net/p4p1/queues/rx-7/rps_flow_cnt
> 
> echo  > /sys/class/net/p4p1/queues/rx-0/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-1/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-2/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-3/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-4/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-5/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-6/rps_cpus
> echo  > /sys/class/net/p4p1/queues/rx-7/rps_cpus
> 
> Below is IRQ affinity configuration for NIC irqs used. 
> 
> # cat /proc/irq/67/smp_affinity_list
> 8
> # cat /proc/irq/68/smp_affinity_list
> 9
> # cat /proc/irq/69/smp_affinity_list
> 10
> # cat /proc/irq/70/smp_affinity_list
> 11
> # cat /proc/irq/71/smp_affinity_list
> 12
> # cat /proc/irq/72/smp_affinity_list
> 13
> # cat /proc/irq/73/smp_affinity_list
> 14
> # cat /proc/irq/74/smp_affinity_list
> 15
> 
> Driver has required feature NETIF_F_NTUPLE set, ndo_rx_flow_steer()
> registered and I am running UDP multiple connections stream using
> netperf to the host where I am experimenting aRFS. 
> 
> # netperf -V
> Netperf version 2.7.0
> 
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 8,8 -- -m 1470 -P
> 5001,48512 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 9,9 -- -m 1470 -P
> 5001,37990 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 10,10 -- -m 1470 -P
> 5001,40302 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 11,11 -- -m 1470 -P
> 5001,39071 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 12,12 -- -m 1470 -P
> 5001,58994 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 13,13 -- -m 1470 -P
> 5001,59884 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 14,14 -- -m 1470 -P
> 5001,40282 &
> netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 15,15 -- -m 1470 -P
> 5001,56042 &
> 
> I see that our registered callback for ndo_rx_flow_steer() "NEVER"
> gets invoked for UDP packets, with TCP_STREAM I do see it gets
> invoked.
> But while running UDP_STREAM I see it gets invoked for some of TCP
> packets as netperf also uses TCP managed connections while running
> UDP_STREAM.
> 
> My initial investigation suspects that while running UDP_STREAM with
> netperf, rps_sock_flow_table doesn't get updated, as packets never
> reach to the flow of inet_recvmsg()
> where it gets updated using sock_rps_record_flow(). Which might be the
> reason it never invokes NIC's flow steering handler ?
> 
> Please note that when I run UDP stream using "iperf" - I do see that
> our registered callback function for flow steering gets invoked for
> "UDP" packets.
> I am not sure if I am missing something in configuration or something
> else which is I am unware of  ? 
> 
> I appreciate any help for this.

Make sure you use connected UDP flows


netperf -t UDP_STREAM ... -- -N -n

Otherwise, one UDP socket can be involved in millions of 4-tuples (aka
flows)





Accelerated receive flow steering (aRFS) for UDP

2016-10-07 Thread Chopra, Manish
Hello Folks,

I am experimenting aRFS with our NIC devices, and for that I have kernel 4.8.x 
installed with below config.

CONFIG_RPS=y
CONFIG_RFS_ACCEL=y

# cat /proc/cpuinfo  | grep processor
processor   : 0
processor   : 1
processor   : 2
processor   : 3
processor   : 4
processor   : 5
processor   : 6
processor   : 7
processor   : 8
processor   : 9
processor   : 10
processor   : 11
processor   : 12
processor   : 13
processor   : 14
processor   : 15

I configured rps_sock_flow_entries  and our NIC rx queues with below values

echo 32768 > /proc/sys/net/core/rps_sock_flow_entries
echo 4096 > /sys/class/net/p4p1/queues/rx-0/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-1/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-2/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-3/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-4/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-5/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-6/rps_flow_cnt
echo 4096 > /sys/class/net/p4p1/queues/rx-7/rps_flow_cnt

echo  > /sys/class/net/p4p1/queues/rx-0/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-1/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-2/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-3/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-4/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-5/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-6/rps_cpus
echo  > /sys/class/net/p4p1/queues/rx-7/rps_cpus

Below is IRQ affinity configuration for NIC irqs used. 

# cat /proc/irq/67/smp_affinity_list
8
# cat /proc/irq/68/smp_affinity_list
9
# cat /proc/irq/69/smp_affinity_list
10
# cat /proc/irq/70/smp_affinity_list
11
# cat /proc/irq/71/smp_affinity_list
12
# cat /proc/irq/72/smp_affinity_list
13
# cat /proc/irq/73/smp_affinity_list
14
# cat /proc/irq/74/smp_affinity_list
15

Driver has required feature NETIF_F_NTUPLE set, ndo_rx_flow_steer() registered 
and I am running UDP multiple connections stream using netperf to the host 
where I am experimenting aRFS. 

# netperf -V
Netperf version 2.7.0

netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 8,8 -- -m 1470 -P 5001,48512 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 9,9 -- -m 1470 -P 5001,37990 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 10,10 -- -m 1470 -P 
5001,40302 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 11,11 -- -m 1470 -P 
5001,39071 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 12,12 -- -m 1470 -P 
5001,58994 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 13,13 -- -m 1470 -P 
5001,59884 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 14,14 -- -m 1470 -P 
5001,40282 &
netperf -H 192.168.200.40 -t UDP_STREAM -l 150 -T 15,15 -- -m 1470 -P 
5001,56042 &

I see that our registered callback for ndo_rx_flow_steer() "NEVER" gets invoked 
for UDP packets, with TCP_STREAM I do see it gets invoked.
But while running UDP_STREAM I see it gets invoked for some of TCP packets as 
netperf also uses TCP managed connections while running  UDP_STREAM.

My initial investigation suspects that while running UDP_STREAM with netperf, 
rps_sock_flow_table doesn't get updated, as packets never reach to the flow of 
inet_recvmsg()
where it gets updated using sock_rps_record_flow(). Which might be the reason 
it never invokes NIC's flow steering handler ?

Please note that when I run UDP stream using "iperf" - I do see that our 
registered callback function for flow steering gets invoked for "UDP" packets.
I am not sure if I am missing something in configuration or something else 
which is I am unware of  ? 

I appreciate any help for this.

Thanks and Regards,
Manish Chopra


Code quality and XDP

2016-10-07 Thread Tom Herbert
One concern raised at netdev concerning XDP is how are we going to
maintain code quality, security, and correctness of programs being
loaded. With kernel bypass it is not just the kernel code path that is
being bypassed, but also the processes that hold the quality of code
being accepted to a high bar. Our users expect that quality to be
maintained.

I suggest that we need XDP programs to be subject to the same scrutiny
that any other kernel netdev code is. One idea is to sign programs
that have been accepted into the kernel. By default only signed
programs would be allowed to be loaded, the override to allow unsigned
programs might be a kernel config or a least a boot parameter
(enabling the override needs to be very explicit).

The acceptable XDP programs should probably be under their own
directory. Such a directory should only contain kernel code, not
userspace code also as is currently in samples/bpf.

A nice side effect of this model is when the same XDP programs are
being used in non-Linux environments (HW offload, other OSes, etc.)
the process could maintain quality expections in those environments
also.

Tom


Re: [PATCH 09/10] net: phy: Add MDIO driver for Juniper's SAM FPGA

2016-10-07 Thread Andrew Lunn
On Fri, Oct 07, 2016 at 06:18:37PM +0300, Pantelis Antoniou wrote:
> From: Georgi Vlaev 
> 
> Add driver for the MDIO IP block present in Juniper's
> SAM FPGA.
> 
> This driver supports only Clause 45 of the 802.3 spec.
> 
> Note that due to the fact that there are no drivers for
> Broadcom/Avago retimers on 10/40Ge path that are controlled
> from the MDIO interface there is a method to have direct
> access to registers via a debugfs interface.

This seems to be the wrong solution. Why not write those drivers?

Controlling stuff from user space is generally frowned up. So i expect
DaveM will NACK this patch. Please remove all the debugfs stuff.

> +static int mdio_sam_stat_wait(struct mii_bus *bus, u32 wait_mask)
> +{
> + struct mdio_sam_data *data = bus->priv;
> + unsigned long timeout;
> + u32 stat;
> +
> + timeout = jiffies + msecs_to_jiffies(MDIO_RDY_TMO);
> + do {
> + stat = ioread32(data->base + MDIO_STATUS);
> + if (stat & wait_mask)
> + return 0;
> +
> + usleep_range(50, 100);
> + } while (time_before(jiffies, timeout));
> +
> + return -EBUSY;

I've recently had to fix a loop like this in another
driver. usleep_range(50, 100) can sleep for a lot longer. If it sleeps
for MDIO_RDY_TMO you exit out with -EBUSY after a single iteration,
which is not what you want. It is better to make a fixed number of
iterations rather than a timeout.

> +}
> +
> +static int mdio_sam_read(struct mii_bus *bus, int phy_id, int regnum)
> +{
> + struct mdio_sam_data *data = bus->priv;
> + u32 command, res;
> + int ret;
> +
> + /* mdiobus_read holds the bus->mdio_lock mutex */
> +
> + if (!(regnum & MII_ADDR_C45))
> + return -ENXIO;
> +
> + ret = mdio_sam_stat_wait(bus, STAT_REG_RDY);
> + if (ret < 0)
> + return ret;
> +
> + command = regnum & 0x1f; /* regnum = (dev_id << 16) | reg */
> + command |= ((phy_id & 0x1f) << 21);
> +
> + iowrite32(command, data->base + MDIO_CMD1);
> + ioread32(data->base + MDIO_CMD1);


> + iowrite32(CMD2_READ | CMD2_ENABLE, data->base + MDIO_CMD2);
> + ioread32(data->base + MDIO_CMD2);

Why do you need to read the values back? Hardware bug?

> + iowrite32(TBL_CMD_REG_GO, data->base + MDIO_TBL_CMD);
> + ioread32(data->base + MDIO_TBL_CMD);

Although not wrong, most drivers use writel().

> +
> + usleep_range(50, 100);
> +
> + ret = mdio_sam_stat_wait(bus, (STAT_REG_DONE | STAT_REG_ERR));

Do you really need a wait before calling mdio_sam_stat_wait()? Isn't
that what it is supposed to do, wait...

> + if (ret < 0)
> + return ret;
> +
> + res = ioread32(data->base + MDIO_RESULT);
> +
> + if (res & RES_ERROR || !(res & RES_SUCCESS))
> + return -EIO;
> +
> + return (res & 0x);
> +}
> +
> +static int mdio_sam_write(struct mii_bus *bus, int phy_id, int regnum, u16 
> val)
> +{
> + struct mdio_sam_data *data = bus->priv;
> + u32 command;
> + int ret;
> +
> + /* mdiobus_write holds the bus->mdio_lock mutex */
> +
> + if (!(regnum & MII_ADDR_C45))
> + return -ENXIO;
> +
> + ret = mdio_sam_stat_wait(bus, STAT_REG_RDY);
> + if (ret < 0)
> + return ret;
> +
> + command = regnum & 0x1f; /* regnum = (dev_id << 16) | reg */
> + command |= ((phy_id & 0x1f) << 21);
> +
> + iowrite32(command, data->base + MDIO_CMD1);
> + ioread32(data->base + MDIO_CMD1);
> + iowrite32(CMD2_ENABLE | val, data->base + MDIO_CMD2);
> + ioread32(data->base + MDIO_CMD2);
> + iowrite32(TBL_CMD_REG_GO, data->base + MDIO_TBL_CMD);
> + ioread32(data->base + MDIO_TBL_CMD);
> +
> + usleep_range(50, 100);
> +
> + ret = mdio_sam_stat_wait(bus, (STAT_REG_DONE | STAT_REG_ERR));
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
> +static int mdio_sam_reset(struct mii_bus *bus)
> +{
> + struct mdio_sam_data *data = bus->priv;
> +
> + iowrite32(TBL_CMD_SOFT_RESET, data->base + MDIO_TBL_CMD);
> + ioread32(data->base + MDIO_TBL_CMD);
> + mdelay(10);
> + iowrite32(0, data->base + MDIO_TBL_CMD);
> + ioread32(data->base + MDIO_TBL_CMD);
> +
> + /* zero tables */
> + memset_io(data->base + MDIO_CMD1, 0, 0x1000);
> + memset_io(data->base + MDIO_PRI_CMD1, 0, 0x1000);

What tables?

> +
> + return 0;
> +}
> +
> +static int mdio_sam_of_register_bus(struct platform_device *pdev,
> + struct device_node *np, void __iomem *base)
> +{
> + struct mii_bus *bus;
> + struct mdio_sam_data *data;
> + u32 reg;
> + int ret;
> +
> + bus = devm_mdiobus_alloc_size(>dev, sizeof(*data));
> + if (!bus)
> + return -ENOMEM;
> +
> + /* bus offset */
> + ret = of_property_read_u32(np, "reg", );
> + if (ret)
> + return -ENODEV;
> +
> + data = bus->priv;
> + data->base = base + 

[RFC v3 2/3] phy: Encapsulate actions performed during link state changes into function phy_adjust_link

2016-10-07 Thread Zach Brown
During phy state machine state transitions some set of actions should
occur whenever the link state changes. These actions should be
encapsulated into a single function

This patch adds the phy_adjust_link function, which is called whenever
phydev->adjust_link would have been called before. Actions that should
occur whenever the phy link is adjusted can now be added to the
phy_adjust_link function.

Signed-off-by: Zach Brown 
---
 drivers/net/phy/phy.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index c6f6683..f5721db 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -893,6 +893,11 @@ void phy_start(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(phy_start);
 
+static void phy_adjust_link(struct phy_device *phydev)
+{
+   phydev->adjust_link(phydev->attached_dev);
+}
+
 /**
  * phy_state_machine - Handle the state machine
  * @work: work_struct that describes the work to be done
@@ -935,7 +940,7 @@ void phy_state_machine(struct work_struct *work)
if (!phydev->link) {
phydev->state = PHY_NOLINK;
netif_carrier_off(phydev->attached_dev);
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
break;
}
 
@@ -948,7 +953,7 @@ void phy_state_machine(struct work_struct *work)
if (err > 0) {
phydev->state = PHY_RUNNING;
netif_carrier_on(phydev->attached_dev);
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
 
} else if (0 == phydev->link_timeout--)
needs_aneg = true;
@@ -975,7 +980,7 @@ void phy_state_machine(struct work_struct *work)
}
phydev->state = PHY_RUNNING;
netif_carrier_on(phydev->attached_dev);
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
}
break;
case PHY_FORCING:
@@ -991,7 +996,7 @@ void phy_state_machine(struct work_struct *work)
needs_aneg = true;
}
 
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
break;
case PHY_RUNNING:
/* Only register a CHANGE if we are polling and link changed
@@ -1020,7 +1025,7 @@ void phy_state_machine(struct work_struct *work)
netif_carrier_off(phydev->attached_dev);
}
 
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
 
if (phy_interrupt_is_valid(phydev))
err = phy_config_interrupt(phydev,
@@ -1030,7 +1035,7 @@ void phy_state_machine(struct work_struct *work)
if (phydev->link) {
phydev->link = 0;
netif_carrier_off(phydev->attached_dev);
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
do_suspend = true;
}
break;
@@ -1054,7 +1059,7 @@ void phy_state_machine(struct work_struct *work)
} else  {
phydev->state = PHY_NOLINK;
}
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
} else {
phydev->state = PHY_AN;
phydev->link_timeout = PHY_AN_TIMEOUT;
@@ -1070,7 +1075,7 @@ void phy_state_machine(struct work_struct *work)
} else  {
phydev->state = PHY_NOLINK;
}
-   phydev->adjust_link(phydev->attached_dev);
+   phy_adjust_link(phydev);
}
break;
}
-- 
2.7.4



[RFC v3 1/3] skge: Rename LED_OFF and LED_ON in marvel skge driver to avoid conflicts with leds namespace

2016-10-07 Thread Zach Brown
Adding led support for phy causes namespace conflicts for some
phy drivers.

The marvel skge driver declared an enum for representing the states of
Link LED Register. The enum contained constant LED_OFF which conflicted
with declartation found in linux/leds.h.
LED_OFF changed to LED_REG_OFF
Also changed LED_ON to LED_REG_ON to avoid possible future conflict and
for consistency.

Signed-off-by: Zach Brown 
---
 drivers/net/ethernet/marvell/skge.c | 6 +++---
 drivers/net/ethernet/marvell/skge.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/skge.c 
b/drivers/net/ethernet/marvell/skge.c
index 7173836..783df01 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -1048,7 +1048,7 @@ static const char *skge_pause(enum pause_status status)
 static void skge_link_up(struct skge_port *skge)
 {
skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG),
-   LED_BLK_OFF|LED_SYNC_OFF|LED_ON);
+   LED_BLK_OFF|LED_SYNC_OFF|LED_REG_ON);
 
netif_carrier_on(skge->netdev);
netif_wake_queue(skge->netdev);
@@ -1062,7 +1062,7 @@ static void skge_link_up(struct skge_port *skge)
 
 static void skge_link_down(struct skge_port *skge)
 {
-   skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
+   skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_REG_OFF);
netif_carrier_off(skge->netdev);
netif_stop_queue(skge->netdev);
 
@@ -2668,7 +2668,7 @@ static int skge_down(struct net_device *dev)
if (hw->ports == 1)
free_irq(hw->pdev->irq, hw);
 
-   skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
+   skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_REG_OFF);
if (is_genesis(hw))
genesis_stop(skge);
else
diff --git a/drivers/net/ethernet/marvell/skge.h 
b/drivers/net/ethernet/marvell/skge.h
index a2eb341..3ea151f 100644
--- a/drivers/net/ethernet/marvell/skge.h
+++ b/drivers/net/ethernet/marvell/skge.h
@@ -662,8 +662,8 @@ enum {
LED_BLK_OFF = 1<<4, /* Link LED Blinking Off */
LED_SYNC_ON = 1<<3, /* Use Sync Wire to switch LED */
LED_SYNC_OFF= 1<<2, /* Disable Sync Wire Input */
-   LED_ON  = 1<<1, /* switch LED on */
-   LED_OFF = 1<<0, /* switch LED off */
+   LED_REG_ON  = 1<<1, /* switch LED on */
+   LED_REG_OFF = 1<<0, /* switch LED off */
 };
 
 /* Receive GMAC FIFO (YUKON) */
-- 
2.7.4



[PATCH 0/3] Add support for led triggers on phy link state change

2016-10-07 Thread Zach Brown
Fix skge driver that declared enum contants that conflicted with enum
constants in linux/leds.h

Create function that encapsulates actions taken during the adjust phy link step
of phy state changes.

Add support for led triggers on phy link state changes by adding
a config option. When set the config option will create a set of led triggers
for each phy device. Users can use the led triggers to represent link state
changes on the phy.

v2:
 * New patch that creates phy_adjust_link function to encapsulate actions taken
   when adjusting phy link during phy state changes
 * led trigger speed strings changed to match existing phy speed strings
 * New function that maps speeds to led triggers
 * Replace magic constants with definitions when declaring trigger name
   buffer and number of triggers.
v3:
 * Changed LED_ON to LED_REG_ON in skge driver to avoid possible future
   conflict and improve consistency.
 * Dropped rtl8712 patch that was accepted separately.

Josh Cartwright (1):
  phy,leds: add support for led triggers on phy link state change

Zach Brown (2):
  skge: Change LED_OFF to LED_REG_OFF in marvel skge driver to avoid
conflicts with leds namespace
  phy: Encapsulate actions performed during link state changes into
function phy_adjust_link

 drivers/net/ethernet/marvell/skge.c |   6 +-
 drivers/net/ethernet/marvell/skge.h |   4 +-
 drivers/net/phy/Kconfig |  13 +++-
 drivers/net/phy/Makefile|   1 +
 drivers/net/phy/phy.c   |  22 ---
 drivers/net/phy/phy_device.c|   4 ++
 drivers/net/phy/phy_led_triggers.c  | 121 
 include/linux/phy.h |   9 +++
 include/linux/phy_led_triggers.h|  52 
 9 files changed, 218 insertions(+), 14 deletions(-)
 create mode 100644 drivers/net/phy/phy_led_triggers.c
 create mode 100644 include/linux/phy_led_triggers.h

--
2.7.4



[RFC v3 3/3] phy,leds: add support for led triggers on phy link state change

2016-10-07 Thread Zach Brown
From: Josh Cartwright 

Create an option CONFIG_LED_TRIGGER_PHY (default n), which will
create a set of led triggers for each instantiated PHY device.  There is
one LED trigger per link-speed, per-phy.

This allows for a user to configure their system to allow a set of LEDs
to represent link state changes on the phy.

Signed-off-by: Josh Cartwright 
Signed-off-by: Nathan Sullivan 
Signed-off-by: Zach Brown 
---
 drivers/net/phy/Kconfig|  13 +++-
 drivers/net/phy/Makefile   |   1 +
 drivers/net/phy/phy.c  |   1 +
 drivers/net/phy/phy_device.c   |   4 ++
 drivers/net/phy/phy_led_triggers.c | 121 +
 include/linux/phy.h|   9 +++
 include/linux/phy_led_triggers.h   |  52 
 7 files changed, 200 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/phy/phy_led_triggers.c
 create mode 100644 include/linux/phy_led_triggers.h

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 5078a0d..4fd912d 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -25,6 +25,18 @@ config MDIO_BCM_IPROC
  This module provides a driver for the MDIO busses found in the
  Broadcom iProc SoC's.
 
+config LED_TRIGGER_PHY
+   bool "Support LED triggers for tracking link state"
+   depends on LEDS_TRIGGERS
+   ---help---
+ Adds support for a set of LED trigger events per-PHY.  Link
+ state change will trigger the events, for consumption by an
+ LED class driver.  There are triggers for each link speed,
+ and are of the form:
+  ::
+
+ Where speed is one of: 10Mbps, 100Mbps, 1Gbps, 2.5Gbps, or 10Gbps.
+
 config MDIO_BCM_UNIMAC
tristate "Broadcom UniMAC MDIO bus controller"
depends on HAS_IOMEM
@@ -40,7 +52,6 @@ config MDIO_BITBANG
  This module implements the MDIO bus protocol in software,
  for use by low level drivers that export the ability to
  drive the relevant pins.
-
  If in doubt, say N.
 
 config MDIO_BUS_MUX
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index e58667d..86d12cd 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -2,6 +2,7 @@
 
 libphy-y   := phy.o phy_device.o mdio_bus.o mdio_device.o
 libphy-$(CONFIG_SWPHY) += swphy.o
+libphy-$(CONFIG_LED_TRIGGER_PHY)   += phy_led_triggers.o
 
 obj-$(CONFIG_PHYLIB)   += libphy.o
 
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index f5721db..e5f9fee7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -896,6 +896,7 @@ EXPORT_SYMBOL(phy_start);
 static void phy_adjust_link(struct phy_device *phydev)
 {
phydev->adjust_link(phydev->attached_dev);
+   phy_led_trigger_change_speed(phydev);
 }
 
 /**
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e977ba9..4671c13 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,6 +58,7 @@ static void phy_mdio_device_free(struct mdio_device *mdiodev)
 
 static void phy_device_release(struct device *dev)
 {
+   phy_led_triggers_unregister(to_phy_device(dev));
kfree(to_phy_device(dev));
 }
 
@@ -345,6 +347,8 @@ struct phy_device *phy_device_create(struct mii_bus *bus, 
int addr, int phy_id,
 
dev->state = PHY_DOWN;
 
+   phy_led_triggers_register(dev);
+
mutex_init(>lock);
INIT_DELAYED_WORK(>state_queue, phy_state_machine);
INIT_WORK(>phy_queue, phy_change);
diff --git a/drivers/net/phy/phy_led_triggers.c 
b/drivers/net/phy/phy_led_triggers.c
new file mode 100644
index 000..32326d7
--- /dev/null
+++ b/drivers/net/phy/phy_led_triggers.c
@@ -0,0 +1,121 @@
+/* Copyright (C) 2016 National Instruments Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+  * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+
+static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy,
+   unsigned int speed)
+{
+   switch (speed) {
+   case SPEED_10:
+   return >phy_led_trigger[0];
+   case SPEED_100:
+   return >phy_led_trigger[1];
+   case SPEED_1000:
+   return >phy_led_trigger[2];
+   case SPEED_2500:
+   return 

Re: [PATCH] net: Reset skb to network header in neigh_hh_output

2016-10-07 Thread Eric Dumazet
On Fri, 2016-10-07 at 16:14 +0200, Abdelrhman Ahmed wrote:
> When hardware header is added without using cached one, neigh_resolve_output
> and neigh_connected_output reset skb to network header before adding it.
> When cached one is used, neigh_hh_output does not reset the skb to network
> header.
> 
> The fix is to reset skb to network header before adding cached hardware header
> to keep the behavior consistent in all cases.

What is the issue you want to fix exactly ?

Please describe the use case.

I highly suggest you take a look at commit

e1f165032c8bade3a6bdf546f8faf61fda4dd01c
("net: Fix skb_under_panic oops in neigh_resolve_output")

Otherwise, your fix is in fact adding a critical bug.




[PATCH net-next] nfnetlink_log: Use GFP_NOWARN for skb allocation

2016-10-07 Thread Calvin Owens
Since the code explicilty falls back to a smaller allocation when the
large one fails, we shouldn't complain when that happens.

Signed-off-by: Calvin Owens 
---
 net/netfilter/nfnetlink_log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index eb086a1..7435505 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -330,7 +330,7 @@ nfulnl_alloc_skb(struct net *net, u32 peer_portid, unsigned 
int inst_size,
 * message.  WARNING: has to be <= 128k due to slab restrictions */
 
n = max(inst_size, pkt_size);
-   skb = alloc_skb(n, GFP_ATOMIC);
+   skb = alloc_skb(n, GFP_ATOMIC | __GFP_NOWARN);
if (!skb) {
if (n > pkt_size) {
/* try to allocate only as much as we need for current
-- 
2.9.3



[PATCH] wan/fsl_ucc_hdlc: Fix size used in dma_free_coherent()

2016-10-07 Thread Christophe JAILLET
Size used with 'dma_alloc_coherent()' and 'dma_free_coherent()' should be
consistent.
Here, the size of a pointer is used in dma_alloc... and the size of the
pointed structure is used in dma_free...

This has been spotted with coccinelle, using the following script:

@r@
expression x0, x1, y0, y1, z0, z1, t0, t1, ret;
@@

*   ret = dma_alloc_coherent(x0, y0, z0, t0);
...
*   dma_free_coherent(x1, y1, ret, t1);


@script:python@
y0 << r.y0;
y1 << r.y1;

@@
if y1.find(y0) == -1:
 print "WARNING: sizes look different:  '%s'   vs   '%s'" % (y0, y1)


Signed-off-by: Christophe JAILLET 
---
Untested
---
 drivers/net/wan/fsl_ucc_hdlc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 5fbf83d5aa57..65647533b401 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -295,11 +295,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
qe_muram_free(priv->ucc_pram_offset);
 free_tx_bd:
dma_free_coherent(priv->dev,
- TX_BD_RING_LEN * sizeof(struct qe_bd),
+ TX_BD_RING_LEN * sizeof(struct qe_bd *),
  priv->tx_bd_base, priv->dma_tx_bd);
 free_rx_bd:
dma_free_coherent(priv->dev,
- RX_BD_RING_LEN * sizeof(struct qe_bd),
+ RX_BD_RING_LEN * sizeof(struct qe_bd *),
  priv->rx_bd_base, priv->dma_rx_bd);
 free_uccf:
ucc_fast_free(priv->uccf);
@@ -688,7 +688,7 @@ static void uhdlc_memclean(struct ucc_hdlc_private *priv)
 
if (priv->rx_bd_base) {
dma_free_coherent(priv->dev,
- RX_BD_RING_LEN * sizeof(struct qe_bd),
+ RX_BD_RING_LEN * sizeof(struct qe_bd *),
  priv->rx_bd_base, priv->dma_rx_bd);
 
priv->rx_bd_base = NULL;
@@ -697,7 +697,7 @@ static void uhdlc_memclean(struct ucc_hdlc_private *priv)
 
if (priv->tx_bd_base) {
dma_free_coherent(priv->dev,
- TX_BD_RING_LEN * sizeof(struct qe_bd),
+ TX_BD_RING_LEN * sizeof(struct qe_bd *),
  priv->tx_bd_base, priv->dma_tx_bd);
 
priv->tx_bd_base = NULL;
-- 
2.7.4



Re: [PATCH net-next v9 1/1] net: phy: Cleanup the Edge-Rate feature in Microsemi PHYs.

2016-10-07 Thread Andrew Lunn
On Fri, Oct 07, 2016 at 10:28:24AM +0200, Allan W. Nielsen wrote:
> Edge-Rate cleanup include the following:
> - Updated device tree bindings documentation for edge-rate
> - The edge-rate is now specified as a "slowdown", meaning that it is now
>   being specified as positive values instead of negative (both
>   documentation and implementation wise).
> - Only explicitly documented values for "vsc8531,vddmac" and
>   "vsc8531,edge-slowdown" are accepted by the device driver.
> - Deleting include/dt-bindings/net/mscc-phy-vsc8531.h as it was not needed.
> 
> Signed-off-by: Allan W. Nielsen 
> Signed-off-by: Raju Lakkaraju 
> ---
>  .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 49 --
>  drivers/net/phy/mscc.c | 79 
> +-
>  include/dt-bindings/net/mscc-phy-vsc8531.h | 21 --
>  3 files changed, 75 insertions(+), 74 deletions(-)
>  delete mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
> 
> diff --git a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt 
> b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
> index 99c7eb0..f552033 100644
> --- a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
> +++ b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
> @@ -6,20 +6,27 @@ Required properties:
> Documentation/devicetree/bindings/net/phy.txt
>  
>  Optional properties:
> -- vsc8531,vddmac : The vddmac in mV.
> +- vsc8531,vddmac : The vddmac in mV. Allowed values is listed
> +   in the first row of Table 1 (below).
> +   This property is only used in combination
> +   with the 'edge-slowdown' property.
> +   Default value is 3300.
>  - vsc8531,edge-slowdown  : % the edge should be slowed down relative to
> -   the fastest possible edge time. Native sign
> -   need not enter.
> +   the fastest possible edge time.
> Edge rate sets the drive strength of the MAC
> -   interface output signals.  Changing the drive
> -   strength will affect the edge rate of the output
> -   signal.  The goal of this setting is to help
> -   reduce electrical emission (EMI) by being able
> -   to reprogram drive strength and in effect slow
> -   down the edge rate if desired.  Table 1 shows the
> -   impact to the edge rate per VDDMAC supply for each
> -   drive strength setting.
> -   Ref: Table:1 - Edge rate change below.
> +   interface output signals.  Changing the
> +   drive strength will affect the edge rate of
> +   the output signal.  The goal of this setting
> +   is to help reduce electrical emission (EMI)
> +   by being able to reprogram drive strength
> +   and in effect slow down the edge rate if
> +   desired.
> +   To adjust the edge-slowdown, the 'vddmac'
> +   must be specified. Table 1 lists the
> +   supported edge-slowdown values for a given
> +   'vddmac'.
> +   Default value is 0%.
> +   Ref: Table:1 - Edge rate change (below).
>  
>  Note: see dt-bindings/net/mscc-phy-vsc8531.h for applicable values

Hi Allen

Overall, this is much better. I just have a few nitpicks.

dt-bindings/net/mscc-phy-vsc8531.h is removed by this patch. It would
be good to also remove the reference.

>  
> @@ -29,23 +36,23 @@ Table: 1 - Edge rate change
>  ||
>  | 3300 mV2500 mV 1800 mV 1500 mV |
>  |---|
> -| DefaultDeafult Default Default |
> +| 0% 0%  0%  0%  |
>  | (Fastest)  (recommended)   (recommended)   |
>  |---|
> -| -2%-3% -5% -6% |
> +| 2% 3%  5%  6%  |
>  |---|
> -| -4%-6% -9% -14%|
> +| 4% 6%  9%  14% |
>  |---|
> -| -7%-10%-16%-21%|
> +| 7% 10% 16% 21% |
>  |(recommended)   (recommended)   |
>  

Re: [PATCH net-next v3 0/6] openvswitch: make vlan handling consistent

2016-10-07 Thread Pravin Shelar
On Fri, Oct 7, 2016 at 9:07 AM, Jiri Benc  wrote:
> Always keep the first vlan tag "accelerated", i.e. in skb->vlan_tci.
>
> Unfortunately, with all the changes since v2, this patchset no longer has
> the nice deletions > insertions diffstat. I still think it's worth it, as it
> makes things more consistent overall.
>
After looking at the changes, I am not sure about the value. These
patches are making code bit complicated by processing vlan header
twice rather than once in current code.

> Patch 3 is valid on its own. Patch 6 is needed in one form or other; with
> the changes in this set, it's a simple deletion. Otherwise we'd need more
> elaborate checks.
>
As far as patch 6 is concerned I think we could do MTU checks similar
to the rest of networking stack (for example is_skb_forwardable()).
That would simplify things here.


> Jiri Benc (6):
>   openvswitch: make skb modifiable in ovs_flow_key_extract*
>   openvswitch: normalize vlan rx path
>   openvswitch: add NETIF_F_HW_VLAN_STAG_TX to internal dev
>   openvswitch: keep vlan tag accelerated on internal device
>   openvswitch: remove unreachable code in vlan parsing
>   openvswitch: fix vlan subtraction from packet length
>
>  net/openvswitch/datapath.c   |  9 ++--
>  net/openvswitch/flow.c   | 83 
> 
>  net/openvswitch/flow.h   | 14 +++---
>  net/openvswitch/vport-internal_dev.c |  9 +++-
>  net/openvswitch/vport.c  | 18 +++-
>  5 files changed, 83 insertions(+), 50 deletions(-)
>
> --
> 1.8.3.1
>


Auditor General Office

2016-10-07 Thread Mr.Malaki Ahmed
Mr.Malaki Ahmed
Auditor General Office

Attn,

I feel quite safe dealing with you in this important business. Though
this medium (Internet) has been greatly abused, I choose to reach you
through it because it still remains the fastest medium of
communication. However, this correspondence is private, and it should
be treated in strict confidence.


Firstly I will like to assure you that this transaction is 100% risk
and trouble free to both parties, In order to transfer out fifteen
million two hundred thousand dollars, (US$15.200 000 00) from our bank
 here, secondly the fund for transfers of clean origin.

The owner of the fund is a foreigner, a program leader who was
believed to have acquired the fund through his secret Crude Oil deal
with the Former IRAQ government.

The deceased died with all the members of his family in an auto
accident without a WILL. Again the amount involved isUS$15,200,000.00.

I want to transfer this money into your account as the foreign
beneficiary of the fund. I know that this letter will come to you as a
surprise as we don't know ourselves before, but be sure that it is
real and a genuine business. I contact you believing that you will not
let me down once the fund goes into your account.

Let me hear from you.


Regards
Ahmed


[PATCH v5 3/4] cfg80211: configure multicast to unicast for AP interfaces

2016-10-07 Thread Michael Braun
This add a userspace toggle to configure multicast to unicast.

Signed-off-by: Michael Braun 
---
 include/net/cfg80211.h   |  6 ++
 include/uapi/linux/nl80211.h | 10 ++
 net/wireless/nl80211.c   | 36 
 net/wireless/rdev-ops.h  | 12 
 net/wireless/trace.h | 19 +++
 5 files changed, 83 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7ce6223..7b0941d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2460,6 +2460,8 @@ struct cfg80211_qos_map {
  *
  * @set_wds_peer: set the WDS peer for a WDS interface
  *
+ * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
+ *
  * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  * functions to adjust rfkill hw state
  *
@@ -2722,6 +2724,10 @@ struct cfg80211_ops {
int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
const u8 *addr);
 
+   int (*set_multicast_to_unicast)(struct wiphy *wiphy,
+   struct net_device *dev,
+   const bool enabled);
+
void(*rfkill_poll)(struct wiphy *wiphy);
 
 #ifdef CONFIG_NL80211_TESTMODE
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 2206941..1b9e87b 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -599,6 +599,9 @@
  *
  * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS 
interface.
  *
+ * @NL80211_CMD_SET_MULTICAST_TO_UNICAST: Configure if AP interface should
+ *  perform multicast to unicast conversion (per-BSS).
+ *
  * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
  * mesh config parameters may be given.
  * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
@@ -1026,6 +1029,8 @@ enum nl80211_commands {
 
NL80211_CMD_ABORT_SCAN,
 
+   NL80211_CMD_SET_MULTICAST_TO_UNICAST,
+
/* add new commands above here */
 
/* used to define NL80211_CMD_MAX below */
@@ -1867,6 +1872,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_MESH_PEER_AID: Association ID for the mesh peer (u16). This is
  * used to pull the stored data for mesh peer in power save state.
  *
+ * @NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED: Multicast packets should be
+ *  send out as unicast to all stations.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2261,6 +2269,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_MESH_PEER_AID,
 
+   NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f02653a..57b5d70 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -409,6 +409,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {
.len = VHT_MUMIMO_GROUPS_DATA_LEN
},
[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR] = { .len = ETH_ALEN },
+   [NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED] = { .type = NLA_U8, },
 };
 
 /* policy for the key attributes */
@@ -1538,6 +1539,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
goto nla_put_failure;
}
CMD(set_wds_peer, SET_WDS_PEER);
+   CMD(set_multicast_to_unicast, SET_MULTICAST_TO_UNICAST);
if (rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) {
CMD(tdls_mgmt, TDLS_MGMT);
CMD(tdls_oper, TDLS_OPER);
@@ -2164,6 +2166,32 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, 
struct genl_info *info)
return rdev_set_wds_peer(rdev, dev, bssid);
 }
 
+static int nl80211_set_multicast_to_unicast(struct sk_buff *skb,
+   struct genl_info *info)
+{
+   struct cfg80211_registered_device *rdev = info->user_ptr[0];
+   struct net_device *dev = info->user_ptr[1];
+   struct wireless_dev *wdev = dev->ieee80211_ptr;
+   const struct nlattr *nla;
+   bool enabled;
+
+   if (!info->attrs[NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED])
+   return -EINVAL;
+
+   if (netif_running(dev))
+   return -EBUSY;
+
+   if (!rdev->ops->set_multicast_to_unicast)
+   return -EOPNOTSUPP;
+
+   if (wdev->iftype != NL80211_IFTYPE_AP)
+   return -EOPNOTSUPP;
+
+   nla = info->attrs[NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED];
+   enabled = nla_get_flag(nla);
+   return rdev_set_multicast_to_unicast(rdev, dev, enabled);
+}
+
 static int nl80211_set_wiphy(struct sk_buff *skb, struct 

[PATCH v5 2/4] mac80211: filter multicast data packets on AP / AP_VLAN

2016-10-07 Thread Michael Braun
This patch adds filtering for multicast data packets on AP_VLAN interfaces
that have no authorized station connected and changes filtering on AP
interfaces to not count stations assigned to AP_VLAN interfaces.

This saves airtime and avoids waking up other stations currently authorized
in this BSS. When using WPA, the packets dropped could not be decrypted by
any station.

The behaviour when there are no AP_VLAN interfaces is left unchanged.
When there are AP_VLAN interfaces, this patch
1. adds filtering multicast data packets sent on AP_VLAN interfaces that
   have no authorized station connected.
   No filtering happens on 4addr AP_VLAN interfaces.
2. makes filtering of multicast data packets sent on AP interfaces depend
   on the number of authorized stations in this bss not assigned to an
   AP_VLAN interface.

Therefore, a new num_mcast_sta counter is added for AP_VLAN interfaces.
The existing one for AP interfaces is altered to not track stations
assigned to an AP_VLAN interface.

The new counter is exposed in debugfs.

Signed-off-by: Michael Braun 

--
v4:
 - update description
v3:
 - reuse existing num_mcast_sta
v2:
 - use separate function to inc/dec mcast_sta counters
 - do not filter in 4addr mode
 - change description
 - change filtering on AP interface (do not count AP_VLAN sta)
 - use new counters regardless of 4addr or not
 - simplify cfg.c:change_station
 - remove no-op change in __cleanup_single_sta
---
 net/mac80211/cfg.c| 20 ++--
 net/mac80211/debugfs_netdev.c | 11 +++
 net/mac80211/ieee80211_i.h| 33 +
 net/mac80211/rx.c |  5 +++--
 net/mac80211/sta_info.c   | 10 ++
 net/mac80211/tx.c |  5 ++---
 6 files changed, 57 insertions(+), 27 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 24133f5..1edb017 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1357,9 +1357,6 @@ static int ieee80211_change_station(struct wiphy *wiphy,
goto out_err;
 
if (params->vlan && params->vlan != sta->sdata->dev) {
-   bool prev_4addr = false;
-   bool new_4addr = false;
-
vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
 
if (params->vlan->ieee80211_ptr->use_4addr) {
@@ -1369,26 +1366,21 @@ static int ieee80211_change_station(struct wiphy *wiphy,
}
 
rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
-   new_4addr = true;
__ieee80211_check_fast_rx_iface(vlansdata);
}
 
if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
-   sta->sdata->u.vlan.sta) {
+   sta->sdata->u.vlan.sta)
RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
-   prev_4addr = true;
-   }
+
+   if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
+   ieee80211_vif_dec_num_mcast(sta->sdata);
 
sta->sdata = vlansdata;
ieee80211_check_fast_xmit(sta);
 
-   if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
-   prev_4addr != new_4addr) {
-   if (new_4addr)
-   atomic_dec(>sdata->bss->num_mcast_sta);
-   else
-   atomic_inc(>sdata->bss->num_mcast_sta);
-   }
+   if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
+   ieee80211_vif_inc_num_mcast(sta->sdata);
 
ieee80211_send_layer2_update(sta);
}
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index a5ba739..ed7bff4 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -477,6 +477,7 @@ IEEE80211_IF_FILE_RW(tdls_wider_bw);
 IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
 IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC);
 IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC);
+IEEE80211_IF_FILE(num_mcast_sta_vlan, u.vlan.num_mcast_sta, ATOMIC);
 
 static ssize_t ieee80211_if_fmt_num_buffered_multicast(
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
@@ -643,6 +644,13 @@ static void add_ap_files(struct ieee80211_sub_if_data 
*sdata)
DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
 }
 
+static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
+{
+   /* add num_mcast_sta_vlan using name num_mcast_sta */
+   debugfs_create_file("num_mcast_sta", 0400, sdata->vif.debugfs_dir,
+   sdata, _mcast_sta_vlan_ops);
+}
+
 static void add_ibss_files(struct ieee80211_sub_if_data *sdata)
 {
DEBUGFS_ADD_MODE(tsf, 0600);
@@ -746,6 +754,9 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
case NL80211_IFTYPE_AP:
add_ap_files(sdata);

[PATCH v5 1/4] mac80211: remove unnecessary num_mcast_sta user

2016-10-07 Thread Michael Braun
Checking for num_mcast_sta in __ieee80211_request_smps_ap() is unnecessary,
as sta list will be empty in this case anyway, so list_for_each_entry(sta,
...) will exit immediately.

Signed-off-by: Michael Braun 
---
 net/mac80211/cfg.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 543b1d4..24133f5 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2313,13 +2313,6 @@ int __ieee80211_request_smps_ap(struct 
ieee80211_sub_if_data *sdata,
smps_mode == IEEE80211_SMPS_AUTOMATIC)
return 0;
 
-/* If no associated stations, there's no need to do anything */
-   if (!atomic_read(>u.ap.num_mcast_sta)) {
-   sdata->smps_mode = smps_mode;
-   ieee80211_queue_work(>local->hw, >recalc_smps);
-   return 0;
-   }
-
ht_dbg(sdata,
   "SMPS %d requested in AP mode, sending Action frame to %d 
stations\n",
   smps_mode, atomic_read(>u.ap.num_mcast_sta));
-- 
2.1.4



[PATCH v5 4/4] mac80211: multicast to unicast conversion

2016-10-07 Thread Michael Braun
This patch adds support for sending multicast data packets with ARP, IPv4
and IPv6 payload (possible 802.1q tagged) as 802.11 unicast frames to all
stations.

IEEE 802.11 multicast has well known issues, among them:
 1. packets are not acked and hence not retransmitted, resulting in
decreased reliablity
 2. packets are send at low rate, increasing time required on air

When used with AP_VLAN, there is another disadvantage:
 3. all stations in the BSS are woken up, regardsless of their AP_VLAN
assignment.

By doing multicast to unicast conversion, all three issus are solved.

IEEE802.11-2012 proposes directed multicast service (DMS) using A-MSDU
frames and a station initiated control protocol. It has the advantage that
the station can recover the destination multicast mac address, but it is
not backward compatible with non QOS stations and does not enable the
administrator of a BSS to force this mode of operation within a BSS.
Additionally, it would require both the ap and the station to implement
the control protocol, which is optional on both ends. Furthermore, I've
seen a few mobile phone stations locally that indicate qos support but
won't complete DHCP if their broadcasts are encapsulated as A-MSDU. Though
they work fine with this series approach.

This patch therefore does not opt to implement DMS but instead just
replicates the packet and changes the destination address. As this works
fine with ARP, IPv4 and IPv6, it is limited to these protocols and normal
802.11 multicast frames are send out for all other payload protocols.

There is a runtime toggle to enable multicast conversion in a per-bss
fashion.

When there is only a single station assigned to the AP_VLAN interface, no
packet replication will occur. 4addr mode of operation is unchanged.

This change opts for iterating all BSS stations for finding the stations
assigned to this AP/AP_VLAN interface, as there currently is no per
AP_VLAN list to iterate and multicast packets are expected to be few.
If needed, such a list could be added later.

Signed-off-by: Michael Braun 

--
v5:
  - rename bss->unicast to bss->multicast_to_unicast
  - access sdata->bss only after checking iftype
v4:
  - rename MULTICAST_TO_UNICAST to MULTICAST_TO_UNICAST
v3: fix compile error for trace.h
v2: add nl80211 toggle
rename tx_dnat to change_da
change int to bool unicast
---
 net/mac80211/cfg.c|  15 +++
 net/mac80211/debugfs_netdev.c |   3 ++
 net/mac80211/ieee80211_i.h|   1 +
 net/mac80211/tx.c | 101 ++
 4 files changed, 120 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 1edb017..1db4c3e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2242,6 +2242,20 @@ static int ieee80211_set_wds_peer(struct wiphy *wiphy, 
struct net_device *dev,
return 0;
 }
 
+static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
+ struct net_device *dev,
+ const bool enabled)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+   if (sdata->vif.type != NL80211_IFTYPE_AP)
+   return -1;
+
+   sdata->u.ap.multicast_to_unicast = enabled;
+
+   return 0;
+}
+
 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
 {
struct ieee80211_local *local = wiphy_priv(wiphy);
@@ -3400,6 +3414,7 @@ const struct cfg80211_ops mac80211_config_ops = {
.set_tx_power = ieee80211_set_tx_power,
.get_tx_power = ieee80211_get_tx_power,
.set_wds_peer = ieee80211_set_wds_peer,
+   .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
.rfkill_poll = ieee80211_rfkill_poll,
CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index ed7bff4..509c6c3 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -487,6 +487,8 @@ static ssize_t ieee80211_if_fmt_num_buffered_multicast(
 }
 IEEE80211_IF_FILE_R(num_buffered_multicast);
 
+IEEE80211_IF_FILE(multicast_to_unicast, u.ap.multicast_to_unicast, HEX);
+
 /* IBSS attributes */
 static ssize_t ieee80211_if_fmt_tsf(
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
@@ -642,6 +644,7 @@ static void add_ap_files(struct ieee80211_sub_if_data 
*sdata)
DEBUGFS_ADD(dtim_count);
DEBUGFS_ADD(num_buffered_multicast);
DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
+   DEBUGFS_ADD_MODE(multicast_to_unicast, 0600);
 }
 
 static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 70c0963..84374ed 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -293,6 +293,7 @@ struct ieee80211_if_ap {
 

[iproute2] bridge: Fix garbled json output seen if a vlan filter is specified

2016-10-07 Thread Anuradha Karuppiah
From: anuradhak 

json objects were started but not completed if the fdb vlan did not
match the specified filter vlan.

Sample output:
$ bridge -j fdb show vlan 111
[{
"mac": "44:38:39:00:69:88",
"dev": "br0",
"vlan": 111,
"master": "br0",
"state": "permanent"
}
]
$ bridge -j fdb show vlan 100
[]
$

Signed-off-by: Anuradha Karuppiah 
---
 bridge/fdb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bridge/fdb.c b/bridge/fdb.c
index c6e0379..90f4b15 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -100,11 +100,6 @@ int print_fdb(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
if (filter_index && filter_index != r->ndm_ifindex)
return 0;
 
-   if (jw_global) {
-   jsonw_pretty(jw_global, 1);
-   jsonw_start_object(jw_global);
-   }
-
parse_rtattr(tb, NDA_MAX, NDA_RTA(r),
 n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
 
@@ -114,6 +109,11 @@ int print_fdb(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
if (filter_vlan && filter_vlan != vid)
return 0;
 
+   if (jw_global) {
+   jsonw_pretty(jw_global, 1);
+   jsonw_start_object(jw_global);
+   }
+
if (n->nlmsg_type == RTM_DELNEIGH) {
if (jw_global)
jsonw_string_field(jw_global, "opCode", "deleted");
-- 
2.1.4



Re: [PATCH] net: Reset skb to network header in neigh_hh_output

2016-10-07 Thread Sergei Shtylyov

On 10/07/2016 07:27 PM, Sergei Shtylyov wrote:


When hardware header is added without using cached one, neigh_resolve_output
and neigh_connected_output reset skb to network header before adding it.
When cached one is used, neigh_hh_output does not reset the skb to network
header.

The fix is to reset skb to network header before adding cached hardware header
to keep the behavior consistent in all cases.

Signed-off-by: Abdelrhman Ahmed 
---
 include/net/neighbour.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 8b68384..4d89fc2 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -424,7 +424,7 @@ static inline struct neighbour * neigh_clone(struct
neighbour *neigh)
 static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff
*skb)
 {
unsigned long now = jiffies;
-
+


   Unraleted white-space change.


   And I thought I fixed this word... it's "unrelated" of/c. :-)




if (neigh->used != now)
neigh->used = now;
if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))

[...]


MBR, Sergei



Re: [PATCH] net: Reset skb to network header in neigh_hh_output

2016-10-07 Thread Sergei Shtylyov

Hello.

On 10/07/2016 05:14 PM, Abdelrhman Ahmed wrote:


When hardware header is added without using cached one, neigh_resolve_output
and neigh_connected_output reset skb to network header before adding it.
When cached one is used, neigh_hh_output does not reset the skb to network
header.

The fix is to reset skb to network header before adding cached hardware header
to keep the behavior consistent in all cases.

Signed-off-by: Abdelrhman Ahmed 
---
 include/net/neighbour.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 8b68384..4d89fc2 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -424,7 +424,7 @@ static inline struct neighbour * neigh_clone(struct 
neighbour *neigh)
 static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff 
*skb)
 {
unsigned long now = jiffies;
-
+


   Unraleted white-space change.


if (neigh->used != now)
neigh->used = now;
if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))

[...]

MBR, Sergei



Re: [PATCH] net: macb: NULL out phydev after removing mdio bus

2016-10-07 Thread Nicolas Ferre
Le 07/10/2016 à 17:13, Xander Huff a écrit :
> From: Nathan Sullivan 
> 
> To ensure the dev->phydev pointer is not used after becoming invalid in
> mdiobus_unregister, set it to NULL. This happens when removing the macb
> driver without first taking its interface down, since unregister_netdev
> will end up calling macb_close.
> 
> Signed-off-by: Xander Huff 
> Signed-off-by: Nathan Sullivan 
> Signed-off-by: Brad Mouring 

Acked-by: Nicolas Ferre 

> ---
>  drivers/net/ethernet/cadence/macb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.c 
> b/drivers/net/ethernet/cadence/macb.c
> index 63144bb..b32444a 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -3117,6 +3117,7 @@ static int macb_remove(struct platform_device *pdev)
>   if (dev->phydev)
>   phy_disconnect(dev->phydev);
>   mdiobus_unregister(bp->mii_bus);
> + dev->phydev = NULL;
>   mdiobus_free(bp->mii_bus);
>  
>   /* Shutdown the PHY if there is a GPIO reset */
> 


-- 
Nicolas Ferre


[PATCH net-next v3 3/6] openvswitch: add NETIF_F_HW_VLAN_STAG_TX to internal dev

2016-10-07 Thread Jiri Benc
The internal device does support 802.1AD offloading.

Signed-off-by: Jiri Benc 
---
v3: new in v3
---
 net/openvswitch/vport-internal_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/vport-internal_dev.c 
b/net/openvswitch/vport-internal_dev.c
index 95c36147a6e1..e7da29021b38 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -176,7 +176,7 @@ static void do_setup(struct net_device *netdev)
 
netdev->vlan_features = netdev->features;
netdev->hw_enc_features = netdev->features;
-   netdev->features |= NETIF_F_HW_VLAN_CTAG_TX;
+   netdev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
netdev->hw_features = netdev->features & ~NETIF_F_LLTX;
 
eth_hw_addr_random(netdev);
-- 
1.8.3.1



[PATCH net-next v3 4/6] openvswitch: keep vlan tag accelerated on internal device

2016-10-07 Thread Jiri Benc
Disallow turning off of vlan acceleration on internal ports. We need the
vlan tag to be in skb->vlan_tci; otherwise, we would pull it back in
ovs_flow_key_extract, defeating the purpose of setting the vlan acceleration
off in the first place.

Signed-off-by: Jiri Benc 
---
v3: new in v3
---
 net/openvswitch/vport-internal_dev.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/net/openvswitch/vport-internal_dev.c 
b/net/openvswitch/vport-internal_dev.c
index e7da29021b38..0531d48eb960 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -143,6 +143,12 @@ static void internal_set_rx_headroom(struct net_device 
*dev, int new_hr)
dev->needed_headroom = new_hr < 0 ? 0 : new_hr;
 }
 
+static netdev_features_t internal_fix_features(struct net_device *dev,
+  netdev_features_t features)
+{
+   return features | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
+}
+
 static const struct net_device_ops internal_dev_netdev_ops = {
.ndo_open = internal_dev_open,
.ndo_stop = internal_dev_stop,
@@ -151,6 +157,7 @@ static const struct net_device_ops internal_dev_netdev_ops 
= {
.ndo_change_mtu = internal_dev_change_mtu,
.ndo_get_stats64 = internal_get_stats,
.ndo_set_rx_headroom = internal_set_rx_headroom,
+   .ndo_fix_features = internal_fix_features,
 };
 
 static struct rtnl_link_ops internal_dev_link_ops __read_mostly = {
-- 
1.8.3.1



[PATCH net-next v3 1/6] openvswitch: make skb modifiable in ovs_flow_key_extract*

2016-10-07 Thread Jiri Benc
Allow ovs_flow_key_extract and ovs_flow_key_extract_userspace to modify the
skb. This will be used by the following patch to move vlan tag to the
vlan_tci field.

Signed-off-by: Jiri Benc 
---
v3: new in v3
---
 net/openvswitch/datapath.c |  9 ++---
 net/openvswitch/flow.c | 33 +
 net/openvswitch/flow.h | 14 --
 net/openvswitch/vport.c|  8 +++-
 4 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4d67ea856067..3469a8df3d5e 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -607,10 +607,13 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, 
struct genl_info *info)
if (IS_ERR(flow))
goto err_kfree_skb;
 
-   err = ovs_flow_key_extract_userspace(net, a[OVS_PACKET_ATTR_KEY],
-packet, >key, log);
-   if (err)
+   packet = ovs_flow_key_extract_userspace(net, a[OVS_PACKET_ATTR_KEY],
+   packet, >key, log);
+   if (IS_ERR(packet)) {
+   err = PTR_ERR(packet);
+   packet = NULL;
goto err_flow_free;
+   }
 
err = ovs_nla_copy_actions(net, a[OVS_PACKET_ATTR_ACTIONS],
   >key, , log);
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index c8c82e109c68..f358608dd33d 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -721,9 +721,12 @@ int ovs_flow_key_update(struct sk_buff *skb, struct 
sw_flow_key *key)
return key_extract(skb, key);
 }
 
-int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
-struct sk_buff *skb, struct sw_flow_key *key)
+struct sk_buff *ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
+struct sk_buff *skb,
+struct sw_flow_key *key)
 {
+   int err;
+
/* Extract metadata from packet. */
if (tun_info) {
key->tun_proto = ip_tunnel_info_af(tun_info);
@@ -753,19 +756,33 @@ int ovs_flow_key_extract(const struct ip_tunnel_info 
*tun_info,
key->ovs_flow_hash = 0;
key->recirc_id = 0;
 
-   return key_extract(skb, key);
+   err = key_extract(skb, key);
+   if (err) {
+   kfree_skb(skb);
+   return ERR_PTR(err);
+   }
+   return skb;
 }
 
-int ovs_flow_key_extract_userspace(struct net *net, const struct nlattr *attr,
-  struct sk_buff *skb,
-  struct sw_flow_key *key, bool log)
+struct sk_buff *ovs_flow_key_extract_userspace(struct net *net,
+  const struct nlattr *attr,
+  struct sk_buff *skb,
+  struct sw_flow_key *key,
+  bool log)
 {
int err;
 
/* Extract metadata from netlink attributes. */
err = ovs_nla_get_flow_metadata(net, attr, key, log);
if (err)
-   return err;
+   goto err_free;
 
-   return key_extract(skb, key);
+   err = key_extract(skb, key);
+   if (err)
+   goto err_free;
+   return skb;
+
+err_free:
+   kfree_skb(skb);
+   return ERR_PTR(err);
 }
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index ae783f5c6695..7eb251f1471f 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -224,12 +224,14 @@ void ovs_flow_stats_clear(struct sw_flow *);
 u64 ovs_flow_used_time(unsigned long flow_jiffies);
 
 int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key);
-int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
-struct sk_buff *skb,
-struct sw_flow_key *key);
+struct sk_buff *ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
+struct sk_buff *skb,
+struct sw_flow_key *key);
 /* Extract key from packet coming from userspace. */
-int ovs_flow_key_extract_userspace(struct net *net, const struct nlattr *attr,
-  struct sk_buff *skb,
-  struct sw_flow_key *key, bool log);
+struct sk_buff *ovs_flow_key_extract_userspace(struct net *net,
+  const struct nlattr *attr,
+  struct sk_buff *skb,
+  struct sw_flow_key *key,
+  bool log);
 
 #endif /* flow.h */
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 8f198437c724..8aefcb20cc58 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -455,11 

[PATCH net-next v3 2/6] openvswitch: normalize vlan rx path

2016-10-07 Thread Jiri Benc
Similarly to how the core networking stack behaves, let the first vlan tag
be always stored in skb->vlan_tci. This is already ensured in
__netif_receive_skb_core for packets that were received from the kernel and
honored by skb_vlan_push and skb_vlan_pop. There is a couple of paths where
a packet with vlan header inside the packet data can be received:

(1) Packets received from the user space.
(2) Packets received via internal device, either injected through AF_PACKET
or with vlan acceleration turned off.

In addition, there will be a third path when support for ETH_P_TEB packets
is added.

To catch all of these cases, untag the vlan frame in ovs_flow_key_extract
and ovs_flow_key_extract_userspace.

Signed-off-by: Jiri Benc 
---
v3: moved the untagging to ovs_flow_key_extract* to catch all cases
---
 net/openvswitch/flow.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index f358608dd33d..14159ac19850 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -716,6 +716,20 @@ static int key_extract(struct sk_buff *skb, struct 
sw_flow_key *key)
return 0;
 }
 
+static struct sk_buff *vlan_untag(struct sk_buff *skb)
+{
+   if (eth_type_vlan(skb->protocol)) {
+   __skb_pull(skb, ETH_HLEN);
+   skb_reset_network_header(skb);
+   skb_reset_mac_len(skb);
+   skb = skb_vlan_untag(skb);
+   if (unlikely(!skb))
+   return NULL;
+   skb_push(skb, ETH_HLEN);
+   }
+   return skb;
+}
+
 int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key)
 {
return key_extract(skb, key);
@@ -727,6 +741,10 @@ struct sk_buff *ovs_flow_key_extract(const struct 
ip_tunnel_info *tun_info,
 {
int err;
 
+   skb = vlan_untag(skb);
+   if (!skb)
+   return ERR_PTR(-ENOMEM);
+
/* Extract metadata from packet. */
if (tun_info) {
key->tun_proto = ip_tunnel_info_af(tun_info);
@@ -772,6 +790,10 @@ struct sk_buff *ovs_flow_key_extract_userspace(struct net 
*net,
 {
int err;
 
+   skb = vlan_untag(skb);
+   if (!skb)
+   return ERR_PTR(-ENOMEM);
+
/* Extract metadata from netlink attributes. */
err = ovs_nla_get_flow_metadata(net, attr, key, log);
if (err)
-- 
1.8.3.1



[PATCH net-next v3 5/6] openvswitch: remove unreachable code in vlan parsing

2016-10-07 Thread Jiri Benc
Now when the first vlan tag is always in skb->vlan_tci, drop code that
assumed it might not be the case.

This patch also removes the wrong likely() statement around
skb_vlan_tag_present introduced by 018c1dda5ff1 ("openvswitch: 802.1AD Flow
handling, actions, vlan parsing, netlink attributes"). This code is called
whenever flow key is being extracted from the packet, the packet may be as
likely vlan tagged as not.

Signed-off-by: Jiri Benc 
---
v3: unchanged
---
 net/openvswitch/flow.c | 28 
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 14159ac19850..45e384167053 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -308,9 +308,7 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
 
 /**
  * Parse vlan tag from vlan header.
- * Returns ERROR on memory error.
- * Returns 0 if it encounters a non-vlan or incomplete packet.
- * Returns 1 after successfully parsing vlan tag.
+ * Returns ERROR on memory error, 0 otherwise.
  */
 static int parse_vlan_tag(struct sk_buff *skb, struct vlan_head *key_vh)
 {
@@ -331,34 +329,24 @@ static int parse_vlan_tag(struct sk_buff *skb, struct 
vlan_head *key_vh)
key_vh->tpid = vh->tpid;
 
__skb_pull(skb, sizeof(struct vlan_head));
-   return 1;
+   return 0;
 }
 
 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key)
 {
-   int res;
-
key->eth.vlan.tci = 0;
key->eth.vlan.tpid = 0;
key->eth.cvlan.tci = 0;
key->eth.cvlan.tpid = 0;
 
-   if (likely(skb_vlan_tag_present(skb))) {
-   key->eth.vlan.tci = htons(skb->vlan_tci);
-   key->eth.vlan.tpid = skb->vlan_proto;
-   } else {
-   /* Parse outer vlan tag in the non-accelerated case. */
-   res = parse_vlan_tag(skb, >eth.vlan);
-   if (res <= 0)
-   return res;
-   }
+   if (!skb_vlan_tag_present(skb))
+   return 0;
 
-   /* Parse inner vlan tag. */
-   res = parse_vlan_tag(skb, >eth.cvlan);
-   if (res <= 0)
-   return res;
+   key->eth.vlan.tci = htons(skb->vlan_tci);
+   key->eth.vlan.tpid = skb->vlan_proto;
 
-   return 0;
+   /* Parse inner vlan tag. */
+   return parse_vlan_tag(skb, >eth.cvlan);
 }
 
 static __be16 parse_ethertype(struct sk_buff *skb)
-- 
1.8.3.1



[PATCH net-next v3 0/6] openvswitch: make vlan handling consistent

2016-10-07 Thread Jiri Benc
Always keep the first vlan tag "accelerated", i.e. in skb->vlan_tci.

Unfortunately, with all the changes since v2, this patchset no longer has
the nice deletions > insertions diffstat. I still think it's worth it, as it
makes things more consistent overall.

Patch 3 is valid on its own. Patch 6 is needed in one form or other; with
the changes in this set, it's a simple deletion. Otherwise we'd need more
elaborate checks.

Jiri Benc (6):
  openvswitch: make skb modifiable in ovs_flow_key_extract*
  openvswitch: normalize vlan rx path
  openvswitch: add NETIF_F_HW_VLAN_STAG_TX to internal dev
  openvswitch: keep vlan tag accelerated on internal device
  openvswitch: remove unreachable code in vlan parsing
  openvswitch: fix vlan subtraction from packet length

 net/openvswitch/datapath.c   |  9 ++--
 net/openvswitch/flow.c   | 83 
 net/openvswitch/flow.h   | 14 +++---
 net/openvswitch/vport-internal_dev.c |  9 +++-
 net/openvswitch/vport.c  | 18 +++-
 5 files changed, 83 insertions(+), 50 deletions(-)

-- 
1.8.3.1



[PATCH net-next v3 6/6] openvswitch: fix vlan subtraction from packet length

2016-10-07 Thread Jiri Benc
When the packet has its vlan tag in skb->vlan_tci, the length of the VLAN
header is not counted in skb->len. It doesn't make sense to subtract it.

In addition, to honor the comment below the code, the VLAN header length
should not be subtracted if there's a vlan tag in skb->vlan_tci. This leads
to the code simply subtracting the Ethernet header length.

Signed-off-by: Jiri Benc 
---
v3: unchanged
---
 net/openvswitch/vport.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 8aefcb20cc58..45370dd6a685 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -481,17 +481,13 @@ EXPORT_SYMBOL_GPL(ovs_vport_deferred_free);
 
 static unsigned int packet_length(const struct sk_buff *skb)
 {
-   unsigned int length = skb->len - ETH_HLEN;
-
-   if (skb_vlan_tagged(skb))
-   length -= VLAN_HLEN;
-
/* Don't subtract for multiple VLAN tags. Most (all?) drivers allow
 * (ETH_LEN + VLAN_HLEN) in addition to the mtu value, but almost none
 * account for 802.1ad. e.g. is_skb_forwardable().
+* Note that the first VLAN tag is always in skb->vlan_tci, thus not
+* accounted for in skb->len.
 */
-
-   return length;
+   return skb->len - ETH_HLEN;
 }
 
 void ovs_vport_send(struct vport *vport, struct sk_buff *skb)
-- 
1.8.3.1



[PATCH 08/10] mtd: flash-sam: Bindings for Juniper's SAM FPGA flash

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add binding document for Junipers Flash IP block present
in the SAM FPGA on PTX series of routers.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 .../devicetree/bindings/mtd/flash-sam.txt  | 31 ++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/flash-sam.txt

diff --git a/Documentation/devicetree/bindings/mtd/flash-sam.txt 
b/Documentation/devicetree/bindings/mtd/flash-sam.txt
new file mode 100644
index 000..bdf1d78
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/flash-sam.txt
@@ -0,0 +1,31 @@
+Flash device on a Juniper SAM FPGA
+
+These flash chips are found in the PTX series of Juniper routers.
+
+They are regular CFI compatible (Intel or AMD extended) flash chips with
+some special write protect/VPP bits that can be controlled by the machine's
+system controller.
+
+Required properties:
+- compatible : must be "jnx,flash-sam"
+
+Optional properties:
+- reg : memory address for the flash chip, note that this is not
+required since usually the device is a subdevice of the SAM MFD
+driver which fills in the register fields.
+
+For the rest of the properties, see mtd-physmap.txt.
+
+The device tree may optionally contain sub-nodes describing partitions of the
+address space. See partition.txt for more detail.
+
+Example:
+
+flash_sam {
+   compatible = "jnx,flash-sam";
+   partition@0 {
+   reg = <0x0 0x40>;
+   label = "pic0-golden";
+   read-only;
+   };
+};
-- 
1.9.1



[PATCH 04/10] i2c: i2c-sam: Add device tree bindings

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add binding document for the i2c driver of SAM FPGA.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 .../devicetree/bindings/i2c/i2c-sam-mux.txt| 20 ++
 Documentation/devicetree/bindings/i2c/i2c-sam.txt  | 44 ++
 2 files changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sam-mux.txt
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sam.txt

diff --git a/Documentation/devicetree/bindings/i2c/i2c-sam-mux.txt 
b/Documentation/devicetree/bindings/i2c/i2c-sam-mux.txt
new file mode 100644
index 000..10ddffa
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-sam-mux.txt
@@ -0,0 +1,20 @@
+Juniper's SAM FPGA I2C accelerator mux
+
+The SAM FPGA I2C mux is present only on Juniper SAM FPGA PTX series
+of routers.
+
+The definition of the i2c sam bus is located in the i2c-sam.txt document.
+
+Required properties:
+- compatible: should be "jnx,i2c-sam-mux".
+- reg: master number and mux number.
+
+Optional properties:
+- speed: If present must be either 10 or 40. No other values supported.
+
+Examples:
+
+pe1i2c: i2c-sam-mux@1,0 {
+   compatible = "jnx,i2c-sam-mux";
+   reg = <1 0>;
+};
diff --git a/Documentation/devicetree/bindings/i2c/i2c-sam.txt 
b/Documentation/devicetree/bindings/i2c/i2c-sam.txt
new file mode 100644
index 000..4830b48
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-sam.txt
@@ -0,0 +1,44 @@
+Juniper's SAM FPGA I2C accelerator
+
+The SAM FPGA accelerator is used to connect the large number of
+I2C muxes that are present on Juniper PTX series of routers.
+While it's an i2c bus, no other devices are located besides
+i2c-sam-mux devices.
+
+The definition of the i2c sam mux is located in the i2c-sam-mux.txt document.
+
+Required properties:
+- compatible: should be "jnx,i2c-sam".
+- #address-cells: should be 2.
+- #size-cells: should be 0.
+- mux-channels: number of mux channels present
+
+Optional properties:
+- reg: offset and length of the register set for the device are optional since
+  typically the register range is provided by the parent SAM MFD device.
+- master-offset: Offset of where the master register memory starts.
+  Default value is 0x8000.
+- reverse-fill: Fill the start entries of transactions in reverse order
+- priority-tables: Use the pre-programmed priority tables in the FPGA
+- i2c-options: list of options to be written to the option field in the
+  FPGA controlling things like SCL push-pull drives, hold-times, etc.
+- bus-range: start of bus master range and number of masters.
+
+Examples:
+
+i2c-sam {
+   compatible = "jnx,i2c-sam";
+   mux-channels = <2>;
+   #size-cells = <0>;
+   #address-cells = <2>;
+
+   /* PE0 */ pe0i2c: i2c-sam-mux@0,0 {
+   compatible = "jnx,i2c-sam-mux";
+   reg = <0 0>;
+   };
+
+   /* PE1 */ pe1i2c: i2c-sam-mux@1,0 {
+   compatible = "jnx,i2c-sam-mux";
+   reg = <1 0>;
+   };
+};
-- 
1.9.1



[PATCH 06/10] gpio: sam: Document bindings of SAM FPGA GPIO block

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add device tree bindings document for the GPIO driver of
Juniper's SAM FPGA.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 .../devicetree/bindings/gpio/jnx,gpio-sam.txt  | 110 +
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/jnx,gpio-sam.txt

diff --git a/Documentation/devicetree/bindings/gpio/jnx,gpio-sam.txt 
b/Documentation/devicetree/bindings/gpio/jnx,gpio-sam.txt
new file mode 100644
index 000..514c350
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/jnx,gpio-sam.txt
@@ -0,0 +1,110 @@
+Juniper SAM FPGA GPIO block
+
+The controller's registers are organized as sets of eight 32-bit
+registers with each set controlling a bank of up to 32 pins.  A single
+interrupt is shared for all of the banks handled by the controller.
+
+Required properties:
+
+- compatible:
+Must be "jnx,gpio-sam"
+
+- #gpio-cells:
+Should be <2>.  The first cell is the pin number (within the controller's
+pin space), and the second is used for the following flags:
+   bit[0]: direction (0 = out, 1 = in)
+   bit[1]: init high
+   bit[2]: active low
+   bit[3]: open drain
+   bit[4]: open drain
+
+- gpio-controller:
+Specifies that the node is a GPIO controller.
+
+Optional properties:
+
+- reg:
+This driver is part of the SAM FPGA MFD driver, so the
+address range is supplied by that driver. However you can
+override using this property.
+
+- gpio-base:
+Base of the GPIO pins of this instance. If not present use system 
allocated.
+
+- gpio-count:
+Number of GPIO pins of this instance. If not present read the number from
+the one configured in the FPGA data. Maximum number is 512.
+
+- #interrupt-cells:
+Should be <2>.  The first cell is the GPIO number, the second should 
specify
+flags.  The following subset of flags is supported:
+- bits[16,4:0] trigger type and level flags
+   bit  0: rising edge interrupt
+   bit  1: falling edge interrupt
+   bit  2: active high interrupt
+   bit  3: active low interrupt
+   bit  4: enable debounce
+   bit 16: signal is active low
+See also 
Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+
+- gpio-interrupts:
+A number of triples that define the mapping of interrupt groupsb to a 
range of
+pins. The first cell defines the interrupt group, the second is the start 
of
+the pin range and the third the number of pins in the range.
+
+- gpio-exports:
+A subnode containing the list of pins that will be exported to user-space.
+Each subnode contains:
+Required properties:
+   - pin: The gpio to be exported and the relevant flags.
+Optional properties:
+- label: The label to use for export; if not supplied use the node 
name.
+
+Example:
+
+gpio20: gpio-sam {
+   compatible = "jnx,gpio-sam";
+   gpio-controller;
+   interrupt-controller;
+   /* 1st cell: gpio pin
+* 2nd cell: flags (bit mask)
+* bit  0: rising edge interrupt
+* bit  1: falling edge interrupt
+* bit  2: active high interrupt
+* bit  3: active low interrupt
+* bit  4: enable debounce
+* bit 16: signal is active low
+*/
+   #interrupt-cells = <2>;
+   #gpio-cells = <2>;
+   gpio-count = <340>;
+   /* 1st cell: gpio interrupt status bit
+* 2nd cell: 1st pin
+* 3rd cell: # of pins
+*/
+   gpio-interrupts =
+   <0 0 32>,   /* TL / TQ */
+   <1 32 32>,  /* PIC 1 */
+   <2 32 32>,  /* PIC 1 spare */
+   <7 148 32>, /* PIC 0 */
+   <8 170 32>, /* PIC 0 spare */
+   <16 318 22>;/* FPC */
+
+   gpio-exports {
+   /*
+* flags:
+* GPIOF_DIR_IN bit 0=1
+* GPIOF_DIR_OUTbit 0=0
+* GPIOF_INIT_HIGH  bit 1=1
+*   GPIOF_INIT_HIGH is raw, not translated
+* GPIOF_ACTIVE_LOW bit 2=1
+* GPIOF_OPEN_DRAIN bit 3=1
+* GPIOF_OPEN_SOURCEbit 4=1
+* GPIOF_EXPORT bit 5=1
+* GPIOF_EXPORT_CHANGEABLE  bit 6=1
+*/
+   tl0-rst {
+   pin = < 8 0x24 >;
+   };
+   };
+};
-- 
1.9.1



[PATCH 09/10] net: phy: Add MDIO driver for Juniper's SAM FPGA

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add driver for the MDIO IP block present in Juniper's
SAM FPGA.

This driver supports only Clause 45 of the 802.3 spec.

Note that due to the fact that there are no drivers for
Broadcom/Avago retimers on 10/40Ge path that are controlled
from the MDIO interface there is a method to have direct
access to registers via a debugfs interface.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/net/phy/Kconfig|   8 +
 drivers/net/phy/Makefile   |   1 +
 drivers/net/phy/mdio-sam.c | 564 +
 3 files changed, 573 insertions(+)
 create mode 100644 drivers/net/phy/mdio-sam.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 5078a0d..7d7f265 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -122,6 +122,14 @@ config MDIO_OCTEON
  buses. It is required by the Octeon and ThunderX ethernet device
  drivers on some systems.
 
+config MDIO_SAM
+   tristate "Juniper Networks SAM FPGA MDIO controller"
+   depends on MFD_JUNIPER_SAM
+   help
+ This module provides a driver for the Juniper Network SAM FPGA MDIO
+ buses. This hardware can be found in the Gladiator PIC SAM FPGA. This
+ driver is client of the sam-core MFD driver.
+
 config MDIO_SUN4I
tristate "Allwinner sun4i MDIO interface support"
depends on ARCH_SUNXI
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index e58667d..c7631cf 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_MDIO_GPIO)   += mdio-gpio.o
 obj-$(CONFIG_MDIO_HISI_FEMAC)  += mdio-hisi-femac.o
 obj-$(CONFIG_MDIO_MOXART)  += mdio-moxart.o
 obj-$(CONFIG_MDIO_OCTEON)  += mdio-octeon.o
+obj-$(CONFIG_MDIO_SAM) += mdio-sam.o
 obj-$(CONFIG_MDIO_SUN4I)   += mdio-sun4i.o
 obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o
 obj-$(CONFIG_MDIO_XGENE)   += mdio-xgene.o
diff --git a/drivers/net/phy/mdio-sam.c b/drivers/net/phy/mdio-sam.c
new file mode 100644
index 000..73cefa1
--- /dev/null
+++ b/drivers/net/phy/mdio-sam.c
@@ -0,0 +1,564 @@
+/*
+ * Juniper Networks SAM FPGA MDIO driver.
+ *
+ * Copyright (c) 2015, Juniper Networks
+ * Author: Georgi Vlaev 
+ *
+ * The MDIO bus driver supports GPQAM, GPCAM, GPQ28 FPGAs found
+ * on Juniper's 10/40/100GE Gladiator PIC cards. Only Clause 45
+ * access is currently available natively.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef CONFIG_DEBUG_FS
+#include 
+#include 
+#include 
+#endif
+
+#define MDIO_CMD1  0x /* Command Table 1 */
+#define MDIO_CMD2  0x0800 /* Command Table 2 */
+#define MDIO_RESULT0x1000 /* Result Table (RO) */
+#define MDIO_PRI_CMD1  0x1800 /* Priority Command Table 1 */
+#define MDIO_PRI_CMD2  0x2000 /* Priority Command Table 1 */
+#define MDIO_PRI_RESULT0x2800 /* Priority Result Table (RO) */
+#define MDIO_TBL_CMD   0x3000 /* Table Command Register (WO) */
+#define MDIO_STATUS0x3008 /* Master Status (RO) */
+#define MDIO_STATUS_INT0x3010 /* Master Status Interrupt Mask (W1C) */
+
+/* MDIO_TBL_CMD */
+#define TBL_CMD_REG_ABORT  BIT(31) /* Regular Table ABORT */
+#define TBL_CMD_REG_GO BIT(30) /* Regular Table GO */
+#define TBL_CMD_PRI_ABORT  BIT(29) /* Priority Table Abort */
+#define TBL_CMD_PRI_GO BIT(28) /* Priority Table GO */
+#define TBL_CMD_SOFT_RESET BIT(27) /* Soft Reset */
+
+/* MDIO_STATUS */
+#define STAT_REG_RDY   BIT(31) /* READY for Programming Regular Table */
+#define STAT_REG_DONE  BIT(30) /* DONE SUCCESSFULLY WITH REGULAR TABLE */
+#define STAT_PRI_RDY   BIT(29) /* READY for Programming Priority Table */
+#define STAT_PRI_DONE  BIT(28) /* DONE SUCCESSFULLY WITH PRIORITY TABLE */
+#define STAT_REG_ERR   BIT(27) /* DONE WITH ERRORS for Regular Table */
+#define STAT_PRI_ERR   BIT(26) /* DONE WITH ERRORS for Priority Table */
+#define STAT_REG_PROG_ERR  BIT(25) /* Programming Err for Regular Table */
+#define STAT_PRI_PROG_ERR  BIT(24) /* Programming Err for Priority Table */
+
+/* MDIO_CMD2, MDIO_PRI_CMD2 */
+#define CMD2_ENABLEBIT(17)
+#define CMD2_READ  BIT(16)
+
+/* MDIO_RESULT, MDIO_PRI_RESULT */
+#define RES_SUCCESSBIT(17)
+#define RES_ERROR  BIT(16)
+
+#define MDIO_RDY_TMO   30 /* in msec */
+
+struct 

[PATCH 3/4] gpio: ptxpmb-ext-cpld: Add driver for Juniper's PTXPMB extended CPLD

2016-10-07 Thread Pantelis Antoniou
From: Guenter Roeck 

This IP block is present in the PTXPMB extended CPLD present on
Junipers PTX series of routers and provides SIB connector status pins
as GPIO pins for use with other drivers.

Signed-off-by: Guenter Roeck 
Signed-off-by: JawaharBalaji Thirumalaisamy 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/gpio/Kconfig|  11 +
 drivers/gpio/Makefile   |   1 +
 drivers/gpio/gpio-ptxpmb-ext-cpld.c | 430 
 3 files changed, 442 insertions(+)
 create mode 100644 drivers/gpio/gpio-ptxpmb-ext-cpld.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index c25dbe9..281029b 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -371,6 +371,17 @@ config GPIO_PTXPMB_CPLD
  This driver can also be built as a module.  If so, the module
  will be called gpio-ptxpmb-cpld.
 
+config GPIO_PTXPMB_EXT_CPLD
+   tristate "PTXPMB Extended CPLD GPIO"
+   depends on MFD_JUNIPER_EXT_CPLD
+   default y if MFD_JUNIPER_EXT_CPLD
+   help
+ This driver exports various bits on the Juniper Control Board
+ Extended CPLD as GPIO pins to userspace.
+
+ This driver can also be built as a module.  If so, the module
+ will be called gpio-ptxpmb-ext-cpld.
+
 config GPIO_PXA
bool "PXA GPIO support"
depends on ARCH_PXA || ARCH_MMP
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 6691d8c..ec890c7 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -91,6 +91,7 @@ obj-$(CONFIG_GPIO_PCH)+= gpio-pch.o
 obj-$(CONFIG_GPIO_PISOSR)  += gpio-pisosr.o
 obj-$(CONFIG_GPIO_PL061)   += gpio-pl061.o
 obj-$(CONFIG_GPIO_PTXPMB_CPLD) += gpio-ptxpmb-cpld.o
+obj-$(CONFIG_GPIO_PTXPMB_EXT_CPLD) += gpio-ptxpmb-ext-cpld.o
 obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o
 obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o
 obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o
diff --git a/drivers/gpio/gpio-ptxpmb-ext-cpld.c 
b/drivers/gpio/gpio-ptxpmb-ext-cpld.c
new file mode 100644
index 000..0152f0b
--- /dev/null
+++ b/drivers/gpio/gpio-ptxpmb-ext-cpld.c
@@ -0,0 +1,430 @@
+/*
+ * Copyright (C) 2012 Juniper networks
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define EXT_CPLD_NGPIO 32  /*  0..15: SIB presence bits*/
+   /* 16..31: SIB interrupt status */
+
+/**
+ * struct ext_cpld_gpio - GPIO private data structure.
+ * @base: PCI base address of Memory mapped I/O register.
+ * @dev: Pointer to device structure.
+ * @gpio: Data for GPIO infrastructure.
+ */
+struct ext_cpld_gpio {
+   void __iomem *base;
+   struct device *dev;
+   struct gpio_chip gpio;
+   struct mutex irq_lock;
+   struct mutex work_lock;
+   struct irq_domain *domain;
+   int irq;
+   u8 irq_type[EXT_CPLD_NGPIO];
+   u16 sib_presence_cache;
+   u16 sib_presence_irq_enabled;
+   u16 sib_irq_status_cache;
+   u16 sib_irq_enabled;
+   struct delayed_work work;
+};
+
+static int ext_cpld_gpio_get(struct gpio_chip *gpio, unsigned int nr)
+{
+   struct ext_cpld_gpio *chip = container_of(gpio,
+ struct ext_cpld_gpio, gpio);
+   struct pmb_boot_cpld_ext *cpld = chip->base;
+   u16 *addr = nr < 16 ? >sib_presence : >sib_irq_status;
+   u16 val;
+
+   val = ioread16(addr);
+   if (nr < 16)
+   chip->sib_presence_cache = val;
+   else
+   chip->sib_irq_status_cache = val;
+
+   return !!(val & (1 << (nr & 15)));
+}
+
+static int ext_cpld_gpio_direction_input(struct gpio_chip *gpio,
+unsigned int nr)
+{
+   /* all pins are input pins */
+   return 0;
+}
+
+static int ext_cpld_gpio_to_irq(struct gpio_chip *gpio, unsigned int offset)
+{
+   struct ext_cpld_gpio *chip = container_of(gpio,
+ struct ext_cpld_gpio, gpio);
+
+   return irq_create_mapping(chip->domain, offset);
+}
+
+static void ext_cpld_irq_mask(struct irq_data *data)
+{
+   struct ext_cpld_gpio *chip = irq_data_get_irq_chip_data(data);
+   struct pmb_boot_cpld_ext *cpld = chip->base;
+   u16 *addr = data->hwirq < 16 ?
+   

[PATCH] wlcore: Allow scans when in AP mode

2016-10-07 Thread Xander Huff
From: James Minor 

When in AP mode, scans can be done without changing firmware to
the multi-role firmware. Allow the interface to scan if forced
in the scan request.

Signed-off-by: James Minor 
Signed-off-by: Xander Huff 
Reviewed-by: Ben Shelton 
Reviewed-by: Jaeden Amero 
---
 drivers/net/wireless/ti/wlcore/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ti/wlcore/main.c 
b/drivers/net/wireless/ti/wlcore/main.c
index 471521a..01ca370 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -6120,6 +6120,8 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
WIPHY_FLAG_SUPPORTS_SCHED_SCAN |
WIPHY_FLAG_HAS_CHANNEL_SWITCH;
 
+   wl->hw->wiphy->features |= NL80211_FEATURE_AP_SCAN;
+
/* make sure all our channels fit in the scanned_ch bitmask */
BUILD_BUG_ON(ARRAY_SIZE(wl1271_channels) +
 ARRAY_SIZE(wl1271_channels_5ghz) >
-- 
1.9.1



[PATCH 00/10] Introduce Juniper SAM FPGA driver

2016-10-07 Thread Pantelis Antoniou
Add Juniper's SAM FPGA driver. Those FPGAs
are present in Juniper's PTX series of routers.

The MFD driver provices i2c/gpio/mtd/mdio devices.

There are full device tree binding documents for the
master mfd driver and for all slave drivers.

This patchset is against mainline as of today: v4.8-9431-g3477d16
and is dependent on the "Juniper prerequisites" and
"Juniper infrastructure" patchsets sent earlier.

Georgi Vlaev (6):
  mfd: sam: Add documentation for the SAM FPGA
  i2c: i2c-sam: Add device tree bindings
  gpio: sam: Document bindings of SAM FPGA GPIO block
  mtd: flash-sam: Bindings for Juniper's SAM FPGA flash
  net: phy: Add MDIO driver for Juniper's SAM FPGA
  net: mdio-sam: Add device tree documentation for SAM MDIO

Guenter Roeck (2):
  gpio: Introduce SAM gpio driver
  mtd: Add SAM Flash driver

Maryam Seraj (2):
  mfd: Add Juniper SAM FPGA MFD driver
  i2c: Juniper SAM I2C driver

 .../devicetree/bindings/gpio/jnx,gpio-sam.txt  | 110 +++
 .../devicetree/bindings/i2c/i2c-sam-mux.txt|  20 +
 Documentation/devicetree/bindings/i2c/i2c-sam.txt  |  44 +
 Documentation/devicetree/bindings/mfd/jnx-sam.txt  |  94 ++
 .../devicetree/bindings/mtd/flash-sam.txt  |  31 +
 Documentation/devicetree/bindings/net/mdio-sam.txt |  48 +
 drivers/gpio/Kconfig   |  11 +
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-sam.c| 707 +++
 drivers/i2c/busses/Kconfig |  11 +
 drivers/i2c/busses/Makefile|   1 +
 drivers/i2c/busses/i2c-sam.c   | 942 +++
 drivers/mfd/Kconfig|  16 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/sam-core.c | 997 +
 drivers/mtd/devices/Kconfig|  11 +
 drivers/mtd/devices/Makefile   |   1 +
 drivers/mtd/devices/sam-flash.c| 642 +
 drivers/net/phy/Kconfig|   8 +
 drivers/net/phy/Makefile   |   1 +
 drivers/net/phy/mdio-sam.c | 564 
 include/linux/mfd/sam.h|  30 +
 22 files changed, 4291 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/jnx,gpio-sam.txt
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sam-mux.txt
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sam.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/jnx-sam.txt
 create mode 100644 Documentation/devicetree/bindings/mtd/flash-sam.txt
 create mode 100644 Documentation/devicetree/bindings/net/mdio-sam.txt
 create mode 100644 drivers/gpio/gpio-sam.c
 create mode 100644 drivers/i2c/busses/i2c-sam.c
 create mode 100644 drivers/mfd/sam-core.c
 create mode 100644 drivers/mtd/devices/sam-flash.c
 create mode 100644 drivers/net/phy/mdio-sam.c
 create mode 100644 include/linux/mfd/sam.h

-- 
1.9.1



[PATCH 01/10] mfd: Add Juniper SAM FPGA MFD driver

2016-10-07 Thread Pantelis Antoniou
From: Maryam Seraj 

Add Juniper's SAM FPGA multi-function driver.

The SAM FPGAs are present on different FPC/SIB cards from the Juniper's
PTX series of routers. Depending on the card type and FPGA revision,
they include the following functional blocks:

* I2C SAM accelerator - multiple I2C masters and multiplexers
* GPIO
* Flash - hardware wrapper interface for the Altera's EPCS flashes
(used for configuration flash updates)
* MDIO - multiple MDIO masters

Signed-off-by: Maryam Seraj 
Signed-off-by: Debjit Ghosh 
Signed-off-by: Georgi Vlaev 
Signed-off-by: Guenter Roeck 
Signed-off-by: Rajat Jain 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/mfd/Kconfig |  16 +
 drivers/mfd/Makefile|   1 +
 drivers/mfd/sam-core.c  | 997 
 include/linux/mfd/sam.h |  30 ++
 4 files changed, 1044 insertions(+)
 create mode 100644 drivers/mfd/sam-core.c
 create mode 100644 include/linux/mfd/sam.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 438666a..75b46a1 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1355,6 +1355,22 @@ config MFD_JUNIPER_CPLD
  This driver can be built as a module. If built as a module it will be
  called "ptxpmb-cpld"
 
+config MFD_JUNIPER_SAM
+   tristate "Juniper SAM FPGA"
+   depends on (PTXPMB_COMMON || JNX_PTX_NGPMB)
+   default y if (PTXPMB_COMMON || JNX_PTX_NGPMB)
+   select MFD_CORE
+   select I2C_SAM
+   select GPIO_SAM
+   select MTD_SAM_FLASH
+   select MDIO_SAM
+   help
+ Select this to enable the SAM FPGA multi-function kernel driver.
+ This FPGA is used on the PTX FPC board.
+
+ This driver can be built as a module. If built as a module it will be
+ called "sam-core"
+
 config MFD_TWL4030_AUDIO
bool "TI TWL4030 Audio"
depends on TWL4030_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 62decc9..71a8ba6 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -149,6 +149,7 @@ obj-$(CONFIG_AB3100_OTP)+= ab3100-otp.o
 obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o
 obj-$(CONFIG_AB8500_GPADC) += ab8500-gpadc.o
 obj-$(CONFIG_MFD_JUNIPER_CPLD) += ptxpmb-cpld-core.o
+obj-$(CONFIG_MFD_JUNIPER_SAM)  += sam-core.o
 obj-$(CONFIG_MFD_DB8500_PRCMU) += db8500-prcmu.o
 # ab8500-core need to come after db8500-prcmu (which provides the channel)
 obj-$(CONFIG_AB8500_CORE)  += ab8500-core.o ab8500-sysctrl.o
diff --git a/drivers/mfd/sam-core.c b/drivers/mfd/sam-core.c
new file mode 100644
index 000..2ea2b1b
--- /dev/null
+++ b/drivers/mfd/sam-core.c
@@ -0,0 +1,997 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_DESC"SAM FPGA MFD core driver"
+#define DRIVER_VERSION "0.02.2"
+#define DRIVER_AUTHOR  "Maryam Seraj "
+
+#define SAM_FPGA_MODULE_NAME   "sam-mfd-core"
+#define FPGA_MEM_SIZE  0x2
+
+#define SAM_NUM_IRQ2
+#define SAM_NUM_MFD_CELLS  3
+#define SAM_NUM_RESOURCES  2
+#define SAM_NUM_RESOURCES_NOIRQ1
+
+/* Minimum SAM revisions needed for i2c irq and PMA support */
+#define SAM_REVISION_I2C_IRQ_MIN   0x0065
+#define SAM_REVISION_PMA_MIN   0x004d
+#define SAM_REVISION_MASK  0x
+#define SAM_REVISION(s)((s)->fpga_rev & 
SAM_REVISION_MASK)
+
+#define SAM_BOARD_ID_MASK  0x00ff
+#define SAM_BOARD_ID(s)((s)->board_id & 
SAM_BOARD_ID_MASK)
+#define SAM_BOARD_ID_HENDRICKS_FPC 0x00
+#define SAM_BOARD_ID_CFP4  0x00
+#define SAM_BOARD_ID_QSFPP 0x00
+#define SAM_BOARD_ID_GPCAM 0x01
+#define SAM_BOARD_ID_SANGRIA_FPC   0x03
+#define SAM_BOARD_ID_QSFPP_OLD 0x03
+#define SAM_BOARD_ID_24x10GE_PIC   0x0B
+#define SAM_BOARD_ID_GLADIATOR_3T  0x11
+#define SAM_BOARD_ID_MLC   0x21
+
+#define SAM_IMG_ID_MASK0x00ff
+#define SAM_IMG_ID_SHIFT   16
+#define SAM_IMG_ID(s)  (((s)->board_id >> SAM_IMG_ID_SHIFT) & \
+SAM_IMG_ID_MASK)
+
+#define SAM_IMG_ID_QSFPP   0x00
+#define SAM_IMG_ID_GPCAM   0x01
+#define SAM_IMG_ID_SANGRIA_FPC 0x03
+#define SAM_IMG_ID_QSFPP_OLD   0x03
+#define SAM_IMG_ID_GLADIATOR_3T0x03
+#define SAM_IMG_ID_HENDRICKS_FPC   0x05
+#define SAM_IMG_ID_24x10GE_PIC 0x0B
+#define SAM_IMG_ID_MLC 0x21
+#define SAM_IMG_ID_CFP40x22
+
+#define SANGRIA_FPC_PCIE_BUS   0x20
+
+struct sam_fpga_data {

[PATCH 02/10] mfd: sam: Add documentation for the SAM FPGA

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add DT bindings document for the SAM MFD device.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 Documentation/devicetree/bindings/mfd/jnx-sam.txt | 94 +++
 1 file changed, 94 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/jnx-sam.txt

diff --git a/Documentation/devicetree/bindings/mfd/jnx-sam.txt 
b/Documentation/devicetree/bindings/mfd/jnx-sam.txt
new file mode 100644
index 000..b4af7ea
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/jnx-sam.txt
@@ -0,0 +1,94 @@
+Device-Tree bindings for Juniper Networks SAM MFD
+
+Required properties:
+
+- compatible - Must be: "jnx,sam"
+
+Optional properties:
+
+- pma-coefficients: A set of tupples containing the configuration of the PMA.
+
+Device   Description
+--   ---
+jnx,i2c-sam: I2C mux driver
+jnx,gpio-sam   : GPIO block
+jnx,flash-sam  : MTD Flash
+jnx,mdio-sam   : MDIO interfaces
+
+All these optional nodes are described in their respective binding
+documents.
+
+Example node:
+
+pci--10-00.0 {
+   compatible = "jnx,sam";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pma-coefficients = <4 0x0>;
+
+   i2c-sam@10 {
+   compatible = "jnx,i2c-sam";
+   mux-channels = <2>;
+   master-offset = <0x1>;
+   };
+
+   gpiogpqam0: gpio-sam@10 {
+   compatible = "jnx,gpio-sam";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-count = <297>;
+   interrupt-controller;
+   /*
+   * 1st cell: gpio interrupt status bit
+   * 2nd cell: 1st pin
+   * 3rd cell: # of pins
+   */
+   gpio-interrupts =
+   <0 0 12>,   /* phy_int_monitor_en [16] */
+   <1 235 24>, /* qsfpp_fpga_int_monitor [17] */
+   <2 259 24>, /* qsfpp_fpga_modprs_monitor [18] */
+   <3 295 1>,  /* si5345_fpga_monitor [19] */
+   <4 294 1>;  /* fpc_pic_int_monitor [20] */
+   };
+
+   flash-sam@10 {
+   compatible = "jnx,flash-sam";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   reg = <0x0 0x40>;
+   label = "pic0-golden";
+   read-only;
+   };
+   partition@40 {
+   reg = <0x40 0x40>;
+   label = "pic0-user";
+   };
+   };
+
+   mdio-sam@10 {
+   compatible = "jnx,mdio-sam";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x4>;
+
+   /* mii_bus types */
+   mdio0: mdio-sam@0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x0>;
+   };
+
+   mdio1: mdio-sam@4000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x4000>;
+   };
+
+   mdio2: mdio-sam@8000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x8000>;
+   };
+   };
+};
-- 
1.9.1



Re: [PATCH] net: macb: NULL out phydev after removing mdio bus

2016-10-07 Thread Moritz Fischer
On Fri, Oct 7, 2016 at 8:13 AM, Xander Huff  wrote:
> From: Nathan Sullivan 
>
> To ensure the dev->phydev pointer is not used after becoming invalid in
> mdiobus_unregister, set it to NULL. This happens when removing the macb
> driver without first taking its interface down, since unregister_netdev
> will end up calling macb_close.
>
> Signed-off-by: Xander Huff 
> Signed-off-by: Nathan Sullivan 
> Signed-off-by: Brad Mouring 
Reviewed-by: Moritz Fischer 


[PATCH 05/10] gpio: Introduce SAM gpio driver

2016-10-07 Thread Pantelis Antoniou
From: Guenter Roeck 

The SAM GPIO IP block is present in the Juniper PTX series
of routers as part of the SAM FPGA.

Signed-off-by: Georgi Vlaev 
Signed-off-by: Guenter Roeck 
Signed-off-by: Rajat Jain 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/gpio/Kconfig|  11 +
 drivers/gpio/Makefile   |   1 +
 drivers/gpio/gpio-sam.c | 707 
 3 files changed, 719 insertions(+)
 create mode 100644 drivers/gpio/gpio-sam.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 9c91de6..c25dbe9 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -384,6 +384,17 @@ config GPIO_RCAR
help
  Say yes here to support GPIO on Renesas R-Car SoCs.
 
+config GPIO_SAM
+   tristate "SAM FPGA GPIO"
+   depends on MFD_JUNIPER_SAM
+   default y if MFD_JUNIPER_SAM
+   help
+ This driver supports the GPIO interfaces on the SAM FPGA which is
+ present on the relevant Juniper platforms.
+
+ This driver can also be built as a module.  If so, the module
+ will be called gpio-sam.
+
 config GPIO_SPEAR_SPICS
bool "ST SPEAr13xx SPI Chip Select as GPIO support"
depends on PLAT_SPEAR
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index d397ea5..6691d8c 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -96,6 +96,7 @@ obj-$(CONFIG_GPIO_RC5T583)+= gpio-rc5t583.o
 obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o
 obj-$(CONFIG_GPIO_RCAR)+= gpio-rcar.o
 obj-$(CONFIG_ARCH_SA1100)  += gpio-sa1100.o
+obj-$(CONFIG_GPIO_SAM) += gpio-sam.o
 obj-$(CONFIG_GPIO_SCH) += gpio-sch.o
 obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o
 obj-$(CONFIG_GPIO_SODAVILLE)   += gpio-sodaville.o
diff --git a/drivers/gpio/gpio-sam.c b/drivers/gpio/gpio-sam.c
new file mode 100644
index 000..5082050
--- /dev/null
+++ b/drivers/gpio/gpio-sam.c
@@ -0,0 +1,707 @@
+/*
+ * Copyright (C) 2012 - 2015 Juniper Networks
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* gpio status/configuration */
+#define SAM_GPIO_NEG_EDGE  (1 << 8)
+#define SAM_GPIO_NEG_EDGE_EN   (1 << 7)
+#define SAM_GPIO_POS_EDGE  (1 << 6)
+#define SAM_GPIO_POS_EDGE_EN   (1 << 5)
+#define SAM_GPIO_BLINK (1 << 4)
+#define SAM_GPIO_OUT   (1 << 3)
+#define SAM_GPIO_OUT_TS(1 << 2)
+#define SAM_GPIO_DEBOUNCE_EN   (1 << 1)
+#define SAM_GPIO_IN(1 << 0)
+
+#define SAM_GPIO_BASE  0x1000
+
+#define SAM_MAX_NGPIO  512
+
+#define SAM_GPIO_ADDR(addr, nr)((addr) + SAM_GPIO_BASE + (nr) * 
sizeof(u32))
+
+struct sam_gpio_irq_group {
+   int start;  /* 1st gpio pin */
+   int count;  /* # of pins in group */
+   int num_enabled;/* # of enabled interrupts */
+};
+
+/**
+ * struct sam_gpio - GPIO private data structure.
+ * @base:  PCI base address of Memory mapped I/O register.
+ * @dev:   Pointer to device structure.
+ * @gpio:  Data for GPIO infrastructure.
+ * @gpio_base: 1st gpio pin
+ * @gpio_count:# of gpio pins
+ * @irq_lock:  Lock used by interrupt subsystem
+ * @domain:Pointer to interrupt domain
+ * @irq:   Interrupt # from parent
+ * @irq_high:  Second interrupt # from parent
+ * (currently unused)
+ * @irq_group: Interrupt group descriptions
+ * (one group per interrupt bit)
+ * @irq_type:  The interrupt type for each gpio pin
+ */
+struct sam_gpio {
+   void __iomem *base;
+   struct device *dev;
+   struct gpio_chip gpio;
+   int gpio_base;
+   int gpio_count;
+   struct mutex irq_lock;
+   struct irq_domain *domain;
+   int irq;
+   int irq_high;
+   struct sam_gpio_irq_group irq_group[18];
+   u8 irq_type[SAM_MAX_NGPIO];
+   struct sam_platform_data *pdata;
+   const char **names;
+   u32 *export_flags;
+};
+#define to_sam(chip)   container_of((chip), struct sam_gpio, gpio)
+
+static void sam_gpio_bitop(struct sam_gpio *sam, unsigned int nr,
+   

[PATCH 03/10] i2c: Juniper SAM I2C driver

2016-10-07 Thread Pantelis Antoniou
From: Maryam Seraj 

Introduce SAM I2C driver for the I2C interfaces on the Juniper
SAM FPGA.

Signed-off-by: Maryam Seraj 
Signed-off-by: Debjit Ghosh 
Signed-off-by: Georgi Vlaev 
Signed-off-by: Guenter Roeck 
Signed-off-by: Rajat Jain 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/i2c/busses/Kconfig   |  11 +
 drivers/i2c/busses/Makefile  |   1 +
 drivers/i2c/busses/i2c-sam.c | 942 +++
 3 files changed, 954 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-sam.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5c3993b..eeac4b2 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -833,6 +833,17 @@ config I2C_SH7760
  This driver can also be built as a module.  If so, the module
  will be called i2c-sh7760.
 
+config I2C_SAM
+   tristate "Juniper SAM FPGA I2C Controller"
+   select I2C_MUX
+   depends on MFD_JUNIPER_SAM || MFD_JUNIPER_CBC
+   help
+ This driver supports the I2C interfaces on the Juniper SAM FPGA
+ which is present on the relevant Juniper platforms.
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-sam.
+
 config I2C_SH_MOBILE
tristate "SuperH Mobile I2C Controller"
depends on HAS_DMA
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37f2819..b99b229 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -79,6 +79,7 @@ obj-$(CONFIG_I2C_QUP) += i2c-qup.o
 obj-$(CONFIG_I2C_RIIC) += i2c-riic.o
 obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o
 obj-$(CONFIG_I2C_S3C2410)  += i2c-s3c2410.o
+obj-$(CONFIG_I2C_SAM)  += i2c-sam.o
 obj-$(CONFIG_I2C_SH7760)   += i2c-sh7760.o
 obj-$(CONFIG_I2C_SH_MOBILE)+= i2c-sh_mobile.o
 obj-$(CONFIG_I2C_SIMTEC)   += i2c-simtec.o
diff --git a/drivers/i2c/busses/i2c-sam.c b/drivers/i2c/busses/i2c-sam.c
new file mode 100644
index 000..1ec930a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-sam.c
@@ -0,0 +1,942 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SAM_DEB1(dev, fmt, args...) do { \
+   if (sam_debug >= 1) \
+   dev_err(dev, fmt, ## args); \
+   } while (0)
+#define SAM_DEB2(dev, fmt, args...) do { \
+   if (sam_debug >= 2) \
+   dev_err(dev, fmt, ## args); \
+   } while (0)
+#define SAM_DEB3(dev, fmt, args...) do { \
+   if (sam_debug >= 3) \
+   dev_err(dev, fmt, ## args); } \
+   while (0)
+
+static int sam_debug;
+
+#define DRIVER_DESC"SAM FPGA I2C Driver"
+#define DRIVER_VERSION "0.2"
+#define DRIVER_AUTHOR  "Maryam Seraj "
+
+#define SAM_FPGA_MODULE_NAME   "i2c-sam"
+
+#define SAM_I2C_MUX_MAX_CHAN   8
+
+#define SAM_I2C_DEV_ADDR_MASK  0x7f
+#define SAM_I2C_TBL_ENTRY_CMDS_NUM 2
+
+#define SAM_I2C_CMD_TABLE_SZ   256
+
+#define SAM_I2C_STS_DONE   (1 << 0)
+#define SAM_I2C_STS_PRIO_DONE  (1 << 1)
+#define SAM_I2C_STS_RUNNING(1 << 2)
+#define SAM_I2C_STS_PRIO_RUNNING   (1 << 3)
+#define SAM_I2C_STS_ERR(1 << 4)
+#define SAM_I2C_STS_PRIO_ERR   (1 << 5)
+#define SAM_I2C_STS_RDY(1 << 6)
+#define SAM_I2C_STS_TR_TIMEOUT (1 << 7)
+#define SAM_I2C_STS_CMD_TIMEOUT(1 << 8)
+#define SAM_I2C_STS_CMD_TABLE_TIMEOUT  (1 << 9)
+
+#define SAM_I2C_STS_CLEAR_MASK (SAM_I2C_STS_DONE \
+| SAM_I2C_STS_PRIO_DONE \
+| SAM_I2C_STS_TR_TIMEOUT \
+| SAM_I2C_STS_CMD_TIMEOUT \
+| SAM_I2C_STS_CMD_TABLE_TIMEOUT \
+| SAM_I2C_STS_ERR \
+| SAM_I2C_STS_PRIO_ERR)
+#define SAM_I2C_STS_CLEAR(x)   (((x) & ~0x3fb3) | SAM_I2C_STS_CLEAR_MASK)
+
+#define SAM_I2C_STS_TIMEOUT(SAM_I2C_STS_TR_TIMEOUT \
+| SAM_I2C_STS_CMD_TIMEOUT \
+| SAM_I2C_STS_CMD_TABLE_TIMEOUT)
+
+#define SAM_I2C_DONE(s)((s) & (SAM_I2C_STS_DONE | 
SAM_I2C_STS_ERR \
+   | SAM_I2C_STS_TIMEOUT))
+
+#define SAM_I2C_CTRL_RESET (1 << 0)
+#define SAM_I2C_CTRL_GO(1 << 1)
+#define SAM_I2C_CTRL_PRIO_GO   (1 << 2)
+#define SAM_I2C_CTRL_ABORT (1 << 3)
+#define SAM_I2C_CTRL_PRIO_ABORT(1 << 4)
+
+/* Priority ctrl & status bits are offset +1 from the regular 

[PATCH 07/10] mtd: Add SAM Flash driver

2016-10-07 Thread Pantelis Antoniou
From: Guenter Roeck 

Add driver for the flash block in Juniper's SAM FPGA.

This driver is used for updating the Altera's EPCS(64,256)
configuration flash devices via a Juniper defined hardware
interface.

Signed-off-by: Georgi Vlaev 
Signed-off-by: Guenter Roeck 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/mtd/devices/Kconfig |  11 +
 drivers/mtd/devices/Makefile|   1 +
 drivers/mtd/devices/sam-flash.c | 642 
 3 files changed, 654 insertions(+)
 create mode 100644 drivers/mtd/devices/sam-flash.c

diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index d4255fb..f5a9032 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -144,6 +144,17 @@ config MTD_LART
  not need any mapping/chip driver for LART. This one does it all
  for you, so go disable all of those if you enabled some of them (:
 
+config MTD_SAM_FLASH
+   tristate "Juniper SAM Flash driver"
+   depends on MFD_JUNIPER_SAM || MFD_JUNIPER_CBC
+   default y if MFD_JUNIPER_SAM
+   help
+ This enables the flash driver for the SAM FPGA which is present
+ on relevant Juniper platforms.
+
+ This driver can also be built as a module. When it is so the name of
+ the module is flash-sam.
+
 config JNX_PMB_NVRAM
tristate "Juniper FPC PMB NVRAM Driver"
depends on (PTXPMB_COMMON || JNX_PTX_NGPMB)
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index b407c5fc..7556311 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_MTD_BCM47XXSFLASH)   += bcm47xxsflash.o
 obj-$(CONFIG_MTD_ST_SPI_FSM)+= st_spi_fsm.o
 obj-$(CONFIG_MTD_POWERNV_FLASH)+= powernv_flash.o
 
+obj-$(CONFIG_MTD_SAM_FLASH)+= sam-flash.o
 obj-$(CONFIG_JNX_PMB_NVRAM) += jnx_pmb_nvram.o
 
 CFLAGS_docg3.o += -I$(src)
diff --git a/drivers/mtd/devices/sam-flash.c b/drivers/mtd/devices/sam-flash.c
new file mode 100644
index 000..5f071e6
--- /dev/null
+++ b/drivers/mtd/devices/sam-flash.c
@@ -0,0 +1,642 @@
+/*
+ * Copyright (C) 2012 Juniper networks
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define SAM_FLASH_DEBUG_ENABLED
+#undef  T5E_MAX_FLASH_READ_WAIT_TIME_FIXED
+#define SAM_FLASH_IF_READ_MAX_SIZE 32  /* 256?! */
+
+#define SAM_FLASH_BASE 0x300
+
+#define ADDR_REG(x)((x)->membase + SAM_FLASH_BASE + 0x000)
+#define COUNTER_REG(x) ((x)->membase + SAM_FLASH_BASE + 0x004)
+#define CONTROL_REG(x) ((x)->membase + SAM_FLASH_BASE + 0x008)
+#define STATUS_REG(x)  ((x)->membase + SAM_FLASH_BASE + 0x00c)
+#define WRITE_DATA_REG(x)  ((x)->membase + SAM_FLASH_BASE + 0x100)
+#define READ_DATA_REG(x)   ((x)->membase + SAM_FLASH_BASE + 0x200)
+
+static int sam_flash_if_read_max_size = SAM_FLASH_IF_READ_MAX_SIZE;
+module_param(sam_flash_if_read_max_size, int, S_IRUSR | S_IRGRP | S_IWUSR);
+MODULE_PARM_DESC(sam_flash_if_read_max_size,
+"maximum read size done by SAM flash IF");
+
+#ifdef SAM_FLASH_DEBUG_ENABLED
+
+static int sam_flash_debug;
+module_param(sam_flash_debug, int, S_IRUSR | S_IRGRP | S_IWUSR);
+MODULE_PARM_DESC(sam_flash_debug, "enable debugging information");
+
+#define SAM_FLASH_DEBUG(dev, fmt, args...) \
+   do {\
+   if (sam_flash_debug) {  \
+   dev_info(dev, fmt, ## args);\
+   }   \
+   } while (0)
+#else /* SAM_FLASH_DEBUG_ENABLED */
+#define SAM_FLASH_DEBUG(dev, fmt, args...)  {}
+#endif /* SAM_FLASH_DEBUG_ENABLED */
+
+/*
+ *  Ref: pfe/common/toolkis/flash/altera_epcs_as.h
+ */
+#define EPCS_EXT_STS_ID(sts)   ((u8)((sts >> 8) & 0xff))
+#define EPCS_EXT_STS_RDSTS(sts)((u8)((sts >> 16) & 0xff))
+#define EPCS_EXT_STS_SID(sts)  ((u8)((sts >> 24) & 0xff))
+/* EPCS Device "read status" bits */
+#define EPCS_STS_WIP_BIT   0x01
+#define EPCS_STS_WLE_BIT   0x02
+#define EPCS_STS_BP_BITS(status)   ((status >> 2) & 0x7)
+
+/*
+ *  Ref: pfe/common/toolkis/flash/altera_epcs_as.h
+ */
+#define 

[PATCH 4/4] gpio: ptxpmb-ext-cpld: Document bindings of PTXPMB extended CPLD

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add device tree bindings document for the GPIO driver of
Juniper's PTXPMB extended CPLD.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 .../bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt | 36 ++
 1 file changed, 36 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt

diff --git 
a/Documentation/devicetree/bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt 
b/Documentation/devicetree/bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt
new file mode 100644
index 000..87f01b9
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt
@@ -0,0 +1,36 @@
+Juniper PTXPMB extended CPLD GPIO block
+
+Required properties:
+
+- compatible:
+Must be "jnx,gpio-ptxpmb-ext-cpld"
+
+- #gpio-cells:
+Should be <2>.  The first cell is the pin number (within the controller's
+pin space), and the second is used for the following flags:
+   bit[0]: direction (0 = out, 1 = in)
+   bit[1]: init high
+   bit[2]: active low
+
+- gpio-controller:
+Specifies that the node is a GPIO controller.
+
+- interrupt-controller:
+Specifies that the node is an interrupt controller.
+
+Optional properties:
+
+- reg:
+Address and length of the register set for the device. Usually supplied
+by the parent MFD device.
+
+
+Example:
+
+gpio_ext_cpld: cpld-ext-gpio {
+   compatible = "jnx,gpio-ptxpmb-ext-cpld";
+   #gpio-cells = <2>;
+   #interrupt-cells = <2>;
+   gpio-controller;
+   interrupt-controller;
+};
-- 
1.9.1



[PATCH 2/4] mfd: ptxpmb-ext-cpld: Add documentation for PTXPMB extended CPLD

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add DT bindings document for the PTXPMB extended CPLD device.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 .../bindings/mfd/jnx-ptxpmb-ext-cpld.txt   | 35 ++
 1 file changed, 35 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mfd/jnx-ptxpmb-ext-cpld.txt

diff --git a/Documentation/devicetree/bindings/mfd/jnx-ptxpmb-ext-cpld.txt 
b/Documentation/devicetree/bindings/mfd/jnx-ptxpmb-ext-cpld.txt
new file mode 100644
index 000..098a548a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/jnx-ptxpmb-ext-cpld.txt
@@ -0,0 +1,35 @@
+* Device tree bindings for Juniper's PTXPMB Extended CPLD FPGA MFD driver
+
+The device supports a gpio block which is described in the
+jnx-gpio-ptxpmb-ext-cpld document.
+
+Required properties:
+
+- compatible:  "jnx,ptxpmb-ext-cpld"
+
+- reg: contains offset/length value for device state control
+   registers space.
+
+Optional properties:
+
+- interrupts:  The interrupt line(s) the /IRQ signal(s) for the device 
is
+   connected to.
+
+- interrupt-parent:The parent interrupt controller.
+
+Example:
+
+ext-cpld@1,0 {
+   compatible = "jnx,ptxpmb-ext-cpld";
+   reg = <0x1 0 0x1000>;
+   interrupt-parent = <>;
+   interrupts = <7 2>, <8 2>;
+
+   gpio_ext_cpld: cpld-ext-gpio {
+   compatible = "jnx,gpio-ptxpmb-ext-cpld";
+   #gpio-cells = <2>;
+   #interrupt-cells = <2>;
+   gpio-controller;
+   interrupt-controller;
+   };
+};
-- 
1.9.1



[PATCH 1/4] mfd: ptxpmb: Add separate driver for extended CPLD

2016-10-07 Thread Pantelis Antoniou
From: Guenter Roeck 

Extended CPLD only exists on certain boards (SPMB) and by itself requires
an MFD driver, since it supports its own interrupts and sub-devices.
It also needs to provide support for SIB hotplug. It is cleaner and easier
to maintain it as separate driver.

Signed-off-by: Georgi Vlaev 
Signed-off-by: Guenter Roeck 
Signed-off-by: JawaharBalaji Thirumalaisamy 
Signed-off-by: Tom Kavanagh 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 drivers/mfd/Kconfig |  13 +++
 drivers/mfd/Makefile|   1 +
 drivers/mfd/ptxpmb-ext-cpld-core.c  | 221 
 include/linux/mfd/ptxpmb_ext_cpld.h |  42 +++
 4 files changed, 277 insertions(+)
 create mode 100644 drivers/mfd/ptxpmb-ext-cpld-core.c
 create mode 100644 include/linux/mfd/ptxpmb_ext_cpld.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 75b46a1..7e1fa14 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1371,6 +1371,19 @@ config MFD_JUNIPER_SAM
  This driver can be built as a module. If built as a module it will be
  called "sam-core"
 
+config MFD_JUNIPER_EXT_CPLD
+   tristate "Juniper PTX PMB Extended CPLD"
+   depends on PTXPMB_COMMON
+   default y if PTXPMB_COMMON
+   select MFD_CORE
+   help
+ Select this to enable the PTX PMB Extended CPLD multi-function kernel
+ driver for the applicable Juniper platforms.
+
+ This driver can be built as a module. If built as a module it will be
+ called "ptxpmb-ext-cpld"
+
+
 config MFD_TWL4030_AUDIO
bool "TI TWL4030 Audio"
depends on TWL4030_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 71a8ba6..da94482 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -150,6 +150,7 @@ obj-$(CONFIG_AB8500_DEBUG)  += ab8500-debugfs.o
 obj-$(CONFIG_AB8500_GPADC) += ab8500-gpadc.o
 obj-$(CONFIG_MFD_JUNIPER_CPLD) += ptxpmb-cpld-core.o
 obj-$(CONFIG_MFD_JUNIPER_SAM)  += sam-core.o
+obj-$(CONFIG_MFD_JUNIPER_EXT_CPLD) += ptxpmb-ext-cpld-core.o
 obj-$(CONFIG_MFD_DB8500_PRCMU) += db8500-prcmu.o
 # ab8500-core need to come after db8500-prcmu (which provides the channel)
 obj-$(CONFIG_AB8500_CORE)  += ab8500-core.o ab8500-sysctrl.o
diff --git a/drivers/mfd/ptxpmb-ext-cpld-core.c 
b/drivers/mfd/ptxpmb-ext-cpld-core.c
new file mode 100644
index 000..a1b1793
--- /dev/null
+++ b/drivers/mfd/ptxpmb-ext-cpld-core.c
@@ -0,0 +1,221 @@
+/*
+ * Juniper PTX PMB Extended CPLD multi-function core driver
+ *
+ * Copyright (C) 2012 Juniper Networks
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct pmb_ext_cpld_core {
+   struct device   *dev;
+   struct pmb_boot_cpld_ext __iomem *cpld;
+   spinlock_t  lock;
+   int irq0, irq1;
+   wait_queue_head_t   wqh;
+};
+
+static irqreturn_t pmb_ext_cpld_core_interrupt(int irq, void *dev_data)
+{
+   struct pmb_ext_cpld_core *cpld = dev_data;
+   unsigned char __iomem *data;
+   int i;
+   u8 buffer[48];
+
+   dev_info(cpld->dev, "interrupt %d sib presence=0x%x irq status=0x%x\n",
+irq, ioread16(>cpld->sib_presence),
+ioread16(>cpld->sib_irq_status));
+
+   data = (u8 *)cpld->cpld;
+   for (i = 0; i < 48; i++)
+   buffer[i] = ioread8(data + i);
+
+   print_hex_dump(KERN_INFO, dev_name(cpld->dev), DUMP_PREFIX_OFFSET,
+  16, 4, buffer, 48, false);
+
+   spin_lock(>wqh.lock);
+
+   /* clear interrupt, wake up any handlers */
+   wake_up_locked(>wqh);
+
+   spin_unlock(>wqh.lock);
+
+   return IRQ_HANDLED;
+}
+
+static ssize_t show_sib_status(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct pmb_ext_cpld_core *cpld = dev_get_drvdata(dev);
+
+   WARN_ONCE(1,
+ "sib_status is deprecated and should no longer be used for 
presence detection\n");
+
+   return sprintf(buf, "0x%04x\n",
+  ioread16(>cpld->sib_presence));
+}
+
+static DEVICE_ATTR(sib_status, S_IRUGO, show_sib_status, 

[PATCH 0/4] Introduce Juniper PTXPMB Extended driver

2016-10-07 Thread Pantelis Antoniou
Add Juniper's PTXPMB Extended FPGA driver. Those FPGAs
are present in Juniper's PTX series of routers.

The MFD driver provices a gpio device.

There are full device tree binding documents for the
master mfd driver and for the slave driver.

This patchset is against mainline as of today: v4.8-9431-g3477d16
and is dependent on the "Juniper prerequisites" and
"Juniper infrastructure" patchsets sent earlier.

Georgi Vlaev (2):
  mfd: ptxpmb-ext-cpld: Add documentation for PTXPMB extended CPLD
  gpio: ptxpmb-ext-cpld: Document bindings of PTXPMB extended CPLD

Guenter Roeck (2):
  mfd: ptxpmb: Add separate driver for extended CPLD
  gpio: ptxpmb-ext-cpld: Add driver for Juniper's PTXPMB extended CPLD

 .../bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt |  36 ++
 .../bindings/mfd/jnx-ptxpmb-ext-cpld.txt   |  35 ++
 drivers/gpio/Kconfig   |  11 +
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-ptxpmb-ext-cpld.c| 430 +
 drivers/mfd/Kconfig|  13 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/ptxpmb-ext-cpld-core.c | 221 +++
 include/linux/mfd/ptxpmb_ext_cpld.h|  42 ++
 9 files changed, 790 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/gpio/jnx,gpio-ptxpmb-ext-cpld.txt
 create mode 100644 
Documentation/devicetree/bindings/mfd/jnx-ptxpmb-ext-cpld.txt
 create mode 100644 drivers/gpio/gpio-ptxpmb-ext-cpld.c
 create mode 100644 drivers/mfd/ptxpmb-ext-cpld-core.c
 create mode 100644 include/linux/mfd/ptxpmb_ext_cpld.h

-- 
1.9.1



[PATCH 10/10] net: mdio-sam: Add device tree documentation for SAM MDIO

2016-10-07 Thread Pantelis Antoniou
From: Georgi Vlaev 

Add device tree bindings document for the SAM MDIO block
present in Juniper's SAM FPGA.

Signed-off-by: Georgi Vlaev 
[Ported from Juniper kernel]
Signed-off-by: Pantelis Antoniou 
---
 Documentation/devicetree/bindings/net/mdio-sam.txt | 48 ++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/mdio-sam.txt

diff --git a/Documentation/devicetree/bindings/net/mdio-sam.txt 
b/Documentation/devicetree/bindings/net/mdio-sam.txt
new file mode 100644
index 000..7d354e0
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/mdio-sam.txt
@@ -0,0 +1,48 @@
+Juniper SAM FPGA MFD MDIO bus properties.
+
+Required properties:
+- compatible : "jnx,mdio-sam"
+- reg : The start offset of the MDIO bus range
+- #address-cells = <1>;
+- #size-cells = <0>;
+
+Optional properties:
+
+Required properties for child nodes:
+- #address-cells = <1>;
+- #size-cells = <0>;
+- reg : The MDIO bus offset within the MDIO range.
+
+
+Example :
+
+   sam@10 {
+   compatible = "jnx,sam";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   mdio-sam@10 {
+   compatible = "jnx,mdio-sam";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x4>;
+
+   mdio0: mdio-sam@0 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x0>;
+   };
+
+   mdio1: mdio-sam@4000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x4000>;
+   };
+
+   mdio2: mdio-sam@8000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x8000>;
+   };
+   };
+   };
-- 
1.9.1



[PATCH] net: macb: NULL out phydev after removing mdio bus

2016-10-07 Thread Xander Huff
From: Nathan Sullivan 

To ensure the dev->phydev pointer is not used after becoming invalid in
mdiobus_unregister, set it to NULL. This happens when removing the macb
driver without first taking its interface down, since unregister_netdev
will end up calling macb_close.

Signed-off-by: Xander Huff 
Signed-off-by: Nathan Sullivan 
Signed-off-by: Brad Mouring 
---
 drivers/net/ethernet/cadence/macb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 63144bb..b32444a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -3117,6 +3117,7 @@ static int macb_remove(struct platform_device *pdev)
if (dev->phydev)
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   dev->phydev = NULL;
mdiobus_free(bp->mii_bus);
 
/* Shutdown the PHY if there is a GPIO reset */
-- 
1.9.1



Re: [PATCH v4 01/10] ethernet: add sun8i-emac driver

2016-10-07 Thread Joe Perches
On Fri, 2016-10-07 at 10:25 +0200, Corentin Labbe wrote:
> This patch add support for sun8i-emac ethernet MAC hardware.
> It could be found in Allwinner H3/A83T/A64 SoCs.

trivial notes:

> diff --git a/drivers/net/ethernet/allwinner/sun8i-emac.c 
> b/drivers/net/ethernet/allwinner/sun8i-emac.c
[]
> +static const char const estats_str[][ETH_GSTRING_LEN] = {

one too many const

> +/* MAGIC value for knowing if a descriptor is available or not */
> +#define DCLEAN cpu_to_le32(BIT(16) | BIT(14) | BIT(12) | BIT(10) | BIT(9))

Aren't there #defines for these bits?

> +static void sun8i_emac_flow_ctrl(struct sun8i_emac_priv *priv, int duplex,
> +  int fc)
> +{
> + u32 flow = 0;
> +
> + flow = readl(priv->base + EMAC_RX_CTL0);
> + if (fc & EMAC_FLOW_RX)
> + flow |= BIT(16);
> + else
> + flow &= ~BIT(16);
> + writel(flow, priv->base + EMAC_RX_CTL0);
> +
> + flow = readl(priv->base + EMAC_TX_FLOW_CTL);
> + if (fc & EMAC_FLOW_TX)
> + flow |= BIT(0);
> + else
> + flow &= ~BIT(0);

more magic bits that could be #defines

> +static int sun8i_emac_rx_from_ddesc(struct net_device *ndev, int i)
> +{
> []
> + /* the checksum or length of received frame's payload is wrong*/
> + if (dstatus & BIT(0)) {
[]
> + if (dstatus & BIT(1)) {
[]
> + if ((dstatus & BIT(3))) {

etc...


HSO driver patch again [1/2]

2016-10-07 Thread Matej Kupljen
Hi,

I am using hso driver for my 3G modem (although different manufacturer
with different USB VID/PID) but I have some problems with it. It is
working fine, but if you disconnect the USB connection while the data
is transferring trough AT interface, we get a crash.

First patch
0001-Reverse-the-order-in-disconnect.patch
This patch first sets the interface to NULL and only then starts
removing the allocated resources. This is according to documentation and
it is also more similar to other drivers.

Thanks,
Matej

From: Matej Kupljen 
Date: Wed, 28 Sep 2016 18:37:23 +0200
Subject: [PATCH] Reverse the order in disconnect

When the device is disconnected, we first need to set interface
data to NULL and then do the freeing of resources to avoid race
conditions.

Signed-off-by: Matej Kupljen 
---
 drivers/net/usb/hso.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index b0df61f..16aef06 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3013,10 +3013,10 @@ exit:
 /* device removed, cleaning up */
 static void hso_disconnect(struct usb_interface *interface)
 {
- hso_free_interface(interface);
-
  /* remove reference of our private data */
  usb_set_intfdata(interface, NULL);
+
+ hso_free_interface(interface);
 }

 static void async_get_intf(struct work_struct *data)
-- 
2.7.4


HSO driver patch again [2/2]

2016-10-07 Thread Matej Kupljen
Hi,

second patch:
0002-Stop-also-serial-queue-when-device-is-unplugged.patch
Serial device was not stopped when the device got unplugged so
there are continues error messages that the URB cannot be submitted.

Thanks,
Matej

From: Matej Kupljen 
Date: Wed, 5 Oct 2016 13:08:31 +0200
Subject: [PATCH] Stop also serial queue when device is unplugged

We need to also stop serial port when the device is unplugged,
the network part is already stopped.

Signed-off-by: Matej Kupljen 
---
 drivers/net/usb/hso.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 16aef06..efd1fef 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3157,6 +3157,7 @@ static void hso_free_interface(struct
usb_interface *interface)
  mutex_lock(>parent->mutex);
  serial->parent->usb_gone = 1;
  mutex_unlock(>parent->mutex);
+ hso_stop_serial_device(serial->parent);
  cancel_work_sync(_table[i]->async_put_intf);
  cancel_work_sync(_table[i]->async_get_intf);
  hso_serial_tty_unregister(serial);
-- 
2.7.4


Re: HSO driver patch [1/2]

2016-10-07 Thread Greg KH
On Fri, Oct 07, 2016 at 04:29:42PM +0200, Matej Kupljen wrote:
> Hi,
> 
> 
> I am using hso driver for my 3G modem (although different manufacturer
> with different USB VID/PID) but I have some problems with it. It is
> working fine, but if you disconnect the USB connection while the data
> is transferring trough AT interface, we get a crash.
> 
> There are two patches:
>  1.) 0001-Reverse-the-order-in-disconnect.patch
>   This patch first sets the interface to NULL and only then starts
> removing the allocated
>   resources. This is according to documentation and it is also
> more similar to other drivers.
>  2.) 0002-Stop-also-serial-queue-when-device-is-unplugged.patch
>   Serial device was not stopped when the device got unplugged so
> there are continues error
>   messages that the URB cannot be submitted.

Again, patches can not be attached, they just need to be inline, with
the needed information.

Look at the patches on the mailing lists for plenty of examples of how
to do this.

thanks,

greg k-h


Re: HSO driver patch [2/2]

2016-10-07 Thread Matej Kupljen
Hi,

second patch..

Thanks,
Matej
From 95cfca26bbcbb021e9327c03f8edf2ed0878de75 Mon Sep 17 00:00:00 2001
From: Matej Kupljen 
Date: Wed, 5 Oct 2016 13:08:31 +0200
Subject: [PATCH] Stop also serial queue when device is unplugged

We need to also stop serial port when the device is unplugged,
the network part is already stopped.

Signed-off-by: Matej Kupljen 
---
 drivers/net/usb/hso.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 16aef06..efd1fef 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3157,6 +3157,7 @@ static void hso_free_interface(struct usb_interface *interface)
 			mutex_lock(>parent->mutex);
 			serial->parent->usb_gone = 1;
 			mutex_unlock(>parent->mutex);
+			hso_stop_serial_device(serial->parent);
 			cancel_work_sync(_table[i]->async_put_intf);
 			cancel_work_sync(_table[i]->async_get_intf);
 			hso_serial_tty_unregister(serial);
-- 
2.7.4



HSO driver patch [1/2]

2016-10-07 Thread Matej Kupljen
Hi,


I am using hso driver for my 3G modem (although different manufacturer
with different USB VID/PID) but I have some problems with it. It is
working fine, but if you disconnect the USB connection while the data
is transferring trough AT interface, we get a crash.

There are two patches:
 1.) 0001-Reverse-the-order-in-disconnect.patch
  This patch first sets the interface to NULL and only then starts
removing the allocated
  resources. This is according to documentation and it is also
more similar to other drivers.
 2.) 0002-Stop-also-serial-queue-when-device-is-unplugged.patch
  Serial device was not stopped when the device got unplugged so
there are continues error
  messages that the URB cannot be submitted.

Another problem is that we can hit the WARN macro in hso_serial_open by:
1.) Plug in the USB modem
2.) Load hso.ko module
3.) Create the /dev nodes
4.) do a less -f /dev/ttyHS2
5.) unplug the USB modem
6.) Re-plug it and back
7.) Quit previous less by pressing q
8.) start less again like in 4 and you'll get

[  198.828136] [ cut here ]
[  198.832788] WARNING: CPU: 2 PID: 1799 at include/linux/kref.h:47
kobject_get+0x9c/0xa8()
[  198.840886] Modules linked in: hso
[  198.844337] CPU: 2 PID: 1799 Comm: less Not tainted
4.1.13-00130-g126c250-dirty #5
[  198.851917] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[  198.858481] [<80017b70>] (unwind_backtrace) from [<800137d0>]
(show_stack+0x10/0x14)
[  198.866246] [<800137d0>] (show_stack) from [<8063caa0>]
(dump_stack+0x84/0xc4)
[  198.873492] [<8063caa0>] (dump_stack) from [<8002857c>]
(warn_slowpath_common+0x84/0xb4)
[  198.881597] [<8002857c>] (warn_slowpath_common) from [<80028648>]
(warn_slowpath_null+0x1c/0x24)
[  198.890398] [<80028648>] (warn_slowpath_null) from [<802533a8>]
(kobject_get+0x9c/0xa8)
[  198.898420] [<802533a8>] (kobject_get) from [<80110b90>] (cdev_get+0x2c/0x4c)
[  198.905571] [<80110b90>] (cdev_get) from [<80110eb0>]
(chrdev_open+0x2c/0x178)
[  198.912812] [<80110eb0>] (chrdev_open) from [<8010aff0>]
(do_dentry_open+0x1d8/0x2f8)
[  198.920666] [<8010aff0>] (do_dentry_open) from [<80118958>]
(do_last+0x564/0xce4)
[  198.928164] [<80118958>] (do_last) from [<8011b0fc>] (path_openat+0x80/0x5cc)
[  198.935330] [<8011b0fc>] (path_openat) from [<8011c0f8>]
(do_filp_open+0x2c/0x88)
[  198.942832] [<8011c0f8>] (do_filp_open) from [<8010c36c>]
(do_sys_open+0x108/0x1cc)
[  198.950508] [<8010c36c>] (do_sys_open) from [<80010140>]
(ret_fast_syscall+0x0/0x60)
[  198.958292] ---[ end trace d0b32f14e1047616 ]---

Thanks,
Matej
From f560b127ca9bb7c52106f0f83091e6c5e0e90b09 Mon Sep 17 00:00:00 2001
From: Matej Kupljen 
Date: Wed, 28 Sep 2016 18:37:23 +0200
Subject: [PATCH] Reverse the order in disconnect

When the device is disconnected, we first need to set interface
data to NULL and then do the freeing of resources to avoid race
conditions.

Signed-off-by: Matej Kupljen 
---
 drivers/net/usb/hso.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index b0df61f..16aef06 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3013,10 +3013,10 @@ exit:
 /* device removed, cleaning up */
 static void hso_disconnect(struct usb_interface *interface)
 {
-	hso_free_interface(interface);
-
 	/* remove reference of our private data */
 	usb_set_intfdata(interface, NULL);
+
+	hso_free_interface(interface);
 }
 
 static void async_get_intf(struct work_struct *data)
-- 
2.7.4



[PATCH] net: Reset skb to network header in neigh_hh_output

2016-10-07 Thread Abdelrhman Ahmed
When hardware header is added without using cached one, neigh_resolve_output
and neigh_connected_output reset skb to network header before adding it.
When cached one is used, neigh_hh_output does not reset the skb to network
header.

The fix is to reset skb to network header before adding cached hardware header
to keep the behavior consistent in all cases.

Signed-off-by: Abdelrhman Ahmed 
---
 include/net/neighbour.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 8b68384..4d89fc2 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -424,7 +424,7 @@ static inline struct neighbour * neigh_clone(struct 
neighbour *neigh)
 static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff 
*skb)
 {
unsigned long now = jiffies;
-   
+
if (neigh->used != now)
neigh->used = now;
if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))
@@ -451,6 +451,8 @@ static inline int neigh_hh_output(const struct hh_cache 
*hh, struct sk_buff *skb
unsigned int seq;
int hh_len;
 
+   __skb_pull(skb, skb_network_offset(skb));
+
do {
seq = read_seqbegin(>hh_lock);
hh_len = hh->hh_len;
-- 
1.9.1



Re: [RFC 0/3] Add support for led triggers on phy link state change

2016-10-07 Thread Pavel Machek
Hi!

> Some drivers that include phy.h defined LED_OFF which conflicts with
> definition in leds.h. phy led support uses leds.h so the two namespaces are no
> longer isolated.
> The first two patches fix the two net drivers that declared enum constants 
> that
> conflict with enum constants in linux/leds.h.

Perhaps led patches should be cced to led mainainters?

LED SUBSYSTEM
M:  Richard Purdie 
M:  Jacek Anaszewski 
L:  linux-l...@vger.kernel.org

Pavel


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


signature.asc
Description: Digital signature


[PATCH net 1/2] Subject: [PATCH] af_iucv: enable control sends in case of SEND_SHUTDOWN

2016-10-07 Thread Ursula Braun
If a socket program has shut down the socket for sending, it can still
receive an undetermined number of packets. The AF_IUCV protocol for
HIPER transport requires sending of a WIN flag from time to time
from the receiver to the sender, otherwise the peer cannot continue
sending. That means sending of control flags must still work, even
though the AF_IUCV socket is shutdown for sending data.
sock_alloc_send_skb() returns with error EPIPE, if socket sk_shutdown
is SEND_SHUTDOWN. Thus this patch temporarily removes the send
shutdown attribute from the socket to enable transfer of control
flags.

Signed-off-by: Ursula Braun 
---
 net/iucv/af_iucv.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 02b45a8..88d0eaa 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -453,19 +453,27 @@ static void iucv_sever_path(struct sock *sk, int 
with_user_data)
}
 }
 
-/* Send FIN through an IUCV socket for HIPER transport */
+/* Send controlling flags through an IUCV socket for HIPER transport */
 static int iucv_send_ctrl(struct sock *sk, u8 flags)
 {
int err = 0;
int blen;
struct sk_buff *skb;
+   u8 shutdown = 0;
 
blen = sizeof(struct af_iucv_trans_hdr) + ETH_HLEN;
+   if (sk->sk_shutdown & SEND_SHUTDOWN) {
+   /* controlling flags should be sent anyway */
+   shutdown = sk->sk_shutdown;
+   sk->sk_shutdown &= RCV_SHUTDOWN;
+   }
skb = sock_alloc_send_skb(sk, blen, 1, );
if (skb) {
skb_reserve(skb, blen);
err = afiucv_hs_send(NULL, sk, skb, flags);
}
+   if (shutdown)
+   sk->sk_shutdown = shutdown;
return err;
 }
 
-- 
2.8.4



[PATCH net 2/2] Subject: [PATCH] af_iucv: drop skbs rejected by filter

2016-10-07 Thread Ursula Braun
A packet filter might be installed for instance with setsockopt
SO_ATTACH_FILTER. af_iucv currently queues skbs rejected by filter
into the backlog queue. This does not make sense, since packets
rejected by filter can be dropped immediately. This patch adds
separate sk_filter return code checking, and dropping of packets
if applicable.

Signed-off-by: Ursula Braun 
Reported-by: Daniel Borkmann 
---
 net/iucv/af_iucv.c | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 88d0eaa..cfb9e5f 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1323,8 +1323,13 @@ static void iucv_process_message(struct sock *sk, struct 
sk_buff *skb,
}
 
IUCV_SKB_CB(skb)->offset = 0;
-   if (sock_queue_rcv_skb(sk, skb))
-   skb_queue_head(_sk(sk)->backlog_skb_q, skb);
+   if (sk_filter(sk, skb)) {
+   atomic_inc(>sk_drops);  /* skb rejected by filter */
+   kfree_skb(skb);
+   return;
+   }
+   if (__sock_queue_rcv_skb(sk, skb))  /* handle rcv queue full */
+   skb_queue_tail(_sk(sk)->backlog_skb_q, skb);
 }
 
 /* iucv_process_message_q() - Process outstanding IUCV messages
@@ -1438,13 +1443,13 @@ static int iucv_sock_recvmsg(struct socket *sock, 
struct msghdr *msg,
rskb = skb_dequeue(>backlog_skb_q);
while (rskb) {
IUCV_SKB_CB(rskb)->offset = 0;
-   if (sock_queue_rcv_skb(sk, rskb)) {
+   if (__sock_queue_rcv_skb(sk, rskb)) {
+   /* handle rcv queue full */
skb_queue_head(>backlog_skb_q,
rskb);
break;
-   } else {
-   rskb = skb_dequeue(>backlog_skb_q);
}
+   rskb = skb_dequeue(>backlog_skb_q);
}
if (skb_queue_empty(>backlog_skb_q)) {
if (!list_empty(>message_q.list))
@@ -2124,12 +2129,17 @@ static int afiucv_hs_callback_rx(struct sock *sk, 
struct sk_buff *skb)
skb_reset_transport_header(skb);
skb_reset_network_header(skb);
IUCV_SKB_CB(skb)->offset = 0;
+   if (sk_filter(sk, skb)) {
+   atomic_inc(>sk_drops);  /* skb rejected by filter */
+   kfree_skb(skb);
+   return NET_RX_SUCCESS;
+   }
+
spin_lock(>message_q.lock);
if (skb_queue_empty(>backlog_skb_q)) {
-   if (sock_queue_rcv_skb(sk, skb)) {
+   if (__sock_queue_rcv_skb(sk, skb))
/* handle rcv queue full */
skb_queue_tail(>backlog_skb_q, skb);
-   }
} else
skb_queue_tail(_sk(sk)->backlog_skb_q, skb);
spin_unlock(>message_q.lock);
-- 
2.8.4



[PATCH net 0/2] s390: af_iucv patches

2016-10-07 Thread Ursula Braun
Hi Dave,

here are 2 patches for the s390-only af_iucv socket family code.

Thanks, Ursula

Ursula Braun (2):
  Subject: [PATCH] af_iucv: enable control sends in case of
SEND_SHUTDOWN
  Subject: [PATCH] af_iucv: drop skbs rejected by filter

 net/iucv/af_iucv.c | 34 ++
 1 file changed, 26 insertions(+), 8 deletions(-)

-- 
2.8.4



[PATCH v4 1/4] mac80211: remove unnecessary num_mcast_sta user

2016-10-07 Thread Michael Braun
Checking for num_mcast_sta in __ieee80211_request_smps_ap() is unnecessary,
as sta list will be empty in this case anyway, so list_for_each_entry(sta,
...) will exit immediately.

Signed-off-by: Michael Braun 
---
 net/mac80211/cfg.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 543b1d4..24133f5 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2313,13 +2313,6 @@ int __ieee80211_request_smps_ap(struct 
ieee80211_sub_if_data *sdata,
smps_mode == IEEE80211_SMPS_AUTOMATIC)
return 0;
 
-/* If no associated stations, there's no need to do anything */
-   if (!atomic_read(>u.ap.num_mcast_sta)) {
-   sdata->smps_mode = smps_mode;
-   ieee80211_queue_work(>local->hw, >recalc_smps);
-   return 0;
-   }
-
ht_dbg(sdata,
   "SMPS %d requested in AP mode, sending Action frame to %d 
stations\n",
   smps_mode, atomic_read(>u.ap.num_mcast_sta));
-- 
2.1.4



[PATCH v4 4/4] mac80211: multicast to unicast conversion

2016-10-07 Thread Michael Braun
This patch adds support for sending multicast data packets with ARP, IPv4
and IPv6 payload (possible 802.1q tagged) as 802.11 unicast frames to all
stations.

IEEE 802.11 multicast has well known issues, among them:
 1. packets are not acked and hence not retransmitted, resulting in
decreased reliablity
 2. packets are send at low rate, increasing time required on air

When used with AP_VLAN, there is another disadvantage:
 3. all stations in the BSS are woken up, regardsless of their AP_VLAN
assignment.

By doing multicast to unicast conversion, all three issus are solved.

IEEE802.11-2012 proposes directed multicast service (DMS) using A-MSDU
frames and a station initiated control protocol. It has the advantage that
the station can recover the destination multicast mac address, but it is
not backward compatible with non QOS stations and does not enable the
administrator of a BSS to force this mode of operation within a BSS.
Additionally, it would require both the ap and the station to implement
the control protocol, which is optional on both ends. Furthermore, I've
seen a few mobile phone stations locally that indicate qos support but
won't complete DHCP if their broadcasts are encapsulated as A-MSDU. Though
they work fine with this series approach.

This patch therefore does not opt to implement DMS but instead just
replicates the packet and changes the destination address. As this works
fine with ARP, IPv4 and IPv6, it is limited to these protocols and normal
802.11 multicast frames are send out for all other payload protocols.

There is a runtime toggle to enable multicast conversion in a per-bss
fashion.

When there is only a single station assigned to the AP_VLAN interface, no
packet replication will occur. 4addr mode of operation is unchanged.

This change opts for iterating all BSS stations for finding the stations
assigned to this AP/AP_VLAN interface, as there currently is no per
AP_VLAN list to iterate and multicast packets are expected to be few.
If needed, such a list could be added later.

Signed-off-by: Michael Braun 

--
v4:
  - rename MULTICAST_TO_UNICAST to MULTICAST_TO_UNICAST
v3: fix compile error for trace.h
v2: add nl80211 toggle
rename tx_dnat to change_da
change int to bool unicast
---
 net/mac80211/cfg.c|  15 +++
 net/mac80211/debugfs_netdev.c |   3 ++
 net/mac80211/ieee80211_i.h|   1 +
 net/mac80211/tx.c | 101 ++
 4 files changed, 120 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 1edb017..23f711a 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2242,6 +2242,20 @@ static int ieee80211_set_wds_peer(struct wiphy *wiphy, 
struct net_device *dev,
return 0;
 }
 
+static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
+ struct net_device *dev,
+ const bool enabled)
+{
+   struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
+   if (sdata->vif.type != NL80211_IFTYPE_AP)
+   return -1;
+
+   sdata->u.ap.unicast = enabled;
+
+   return 0;
+}
+
 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
 {
struct ieee80211_local *local = wiphy_priv(wiphy);
@@ -3400,6 +3414,7 @@ const struct cfg80211_ops mac80211_config_ops = {
.set_tx_power = ieee80211_set_tx_power,
.get_tx_power = ieee80211_get_tx_power,
.set_wds_peer = ieee80211_set_wds_peer,
+   .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
.rfkill_poll = ieee80211_rfkill_poll,
CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index ed7bff4..a5554cc 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -487,6 +487,8 @@ static ssize_t ieee80211_if_fmt_num_buffered_multicast(
 }
 IEEE80211_IF_FILE_R(num_buffered_multicast);
 
+IEEE80211_IF_FILE(multicast_to_unicast, u.ap.unicast, HEX);
+
 /* IBSS attributes */
 static ssize_t ieee80211_if_fmt_tsf(
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
@@ -642,6 +644,7 @@ static void add_ap_files(struct ieee80211_sub_if_data 
*sdata)
DEBUGFS_ADD(dtim_count);
DEBUGFS_ADD(num_buffered_multicast);
DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
+   DEBUGFS_ADD_MODE(multicast_to_unicast, 0600);
 }
 
 static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 70c0963..b23bc21 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -293,6 +293,7 @@ struct ieee80211_if_ap {
 driver_smps_mode; /* smps mode request */
 
struct work_struct request_smps_work;
+   bool unicast;
 };
 
 struct ieee80211_if_wds {

[PATCH v4 3/4] cfg80211: configure multicast to unicast for AP interfaces

2016-10-07 Thread Michael Braun
This add a userspace toggle to configure multicast to unicast.

Signed-off-by: Michael Braun 
---
 include/net/cfg80211.h   |  6 ++
 include/uapi/linux/nl80211.h | 10 ++
 net/wireless/nl80211.c   | 36 
 net/wireless/rdev-ops.h  | 12 
 net/wireless/trace.h | 19 +++
 5 files changed, 83 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b550314..6ab8940 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2460,6 +2460,8 @@ struct cfg80211_qos_map {
  *
  * @set_wds_peer: set the WDS peer for a WDS interface
  *
+ * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
+ *
  * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  * functions to adjust rfkill hw state
  *
@@ -2722,6 +2724,10 @@ struct cfg80211_ops {
int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
const u8 *addr);
 
+   int (*set_multicast_to_unicast)(struct wiphy *wiphy,
+   struct net_device *dev,
+   const bool enabled);
+
void(*rfkill_poll)(struct wiphy *wiphy);
 
 #ifdef CONFIG_NL80211_TESTMODE
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 2206941..1b9e87b 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -599,6 +599,9 @@
  *
  * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS 
interface.
  *
+ * @NL80211_CMD_SET_MULTICAST_TO_UNICAST: Configure if AP interface should
+ *  perform multicast to unicast conversion (per-BSS).
+ *
  * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
  * mesh config parameters may be given.
  * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
@@ -1026,6 +1029,8 @@ enum nl80211_commands {
 
NL80211_CMD_ABORT_SCAN,
 
+   NL80211_CMD_SET_MULTICAST_TO_UNICAST,
+
/* add new commands above here */
 
/* used to define NL80211_CMD_MAX below */
@@ -1867,6 +1872,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_MESH_PEER_AID: Association ID for the mesh peer (u16). This is
  * used to pull the stored data for mesh peer in power save state.
  *
+ * @NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED: Multicast packets should be
+ *  send out as unicast to all stations.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2261,6 +2269,8 @@ enum nl80211_attrs {
 
NL80211_ATTR_MESH_PEER_AID,
 
+   NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f02653a..57b5d70 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -409,6 +409,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {
.len = VHT_MUMIMO_GROUPS_DATA_LEN
},
[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR] = { .len = ETH_ALEN },
+   [NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED] = { .type = NLA_U8, },
 };
 
 /* policy for the key attributes */
@@ -1538,6 +1539,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
goto nla_put_failure;
}
CMD(set_wds_peer, SET_WDS_PEER);
+   CMD(set_multicast_to_unicast, SET_MULTICAST_TO_UNICAST);
if (rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) {
CMD(tdls_mgmt, TDLS_MGMT);
CMD(tdls_oper, TDLS_OPER);
@@ -2164,6 +2166,32 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, 
struct genl_info *info)
return rdev_set_wds_peer(rdev, dev, bssid);
 }
 
+static int nl80211_set_multicast_to_unicast(struct sk_buff *skb,
+   struct genl_info *info)
+{
+   struct cfg80211_registered_device *rdev = info->user_ptr[0];
+   struct net_device *dev = info->user_ptr[1];
+   struct wireless_dev *wdev = dev->ieee80211_ptr;
+   const struct nlattr *nla;
+   bool enabled;
+
+   if (!info->attrs[NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED])
+   return -EINVAL;
+
+   if (netif_running(dev))
+   return -EBUSY;
+
+   if (!rdev->ops->set_multicast_to_unicast)
+   return -EOPNOTSUPP;
+
+   if (wdev->iftype != NL80211_IFTYPE_AP)
+   return -EOPNOTSUPP;
+
+   nla = info->attrs[NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED];
+   enabled = nla_get_flag(nla);
+   return rdev_set_multicast_to_unicast(rdev, dev, enabled);
+}
+
 static int nl80211_set_wiphy(struct sk_buff *skb, struct 

[PATCH v4 2/4] mac80211: filter multicast data packets on AP / AP_VLAN

2016-10-07 Thread Michael Braun
This patch adds filtering for multicast data packets on AP_VLAN interfaces
that have no authorized station connected and changes filtering on AP
interfaces to not count stations assigned to AP_VLAN interfaces.

This saves airtime and avoids waking up other stations currently authorized
in this BSS. When using WPA, the packets dropped could not be decrypted by
any station.

The behaviour when there are no AP_VLAN interfaces is left unchanged.
When there are AP_VLAN interfaces, this patch
1. adds filtering multicast data packets sent on AP_VLAN interfaces that
   have no authorized station connected.
   No filtering happens on 4addr AP_VLAN interfaces.
2. makes filtering of multicast data packets sent on AP interfaces depend
   on the number of authorized stations in this bss not assigned to an
   AP_VLAN interface.

Therefore, a new num_mcast_sta counter is added for AP_VLAN interfaces.
The existing one for AP interfaces is altered to not track stations
assigned to an AP_VLAN interface.

The new counter is exposed in debugfs.

Signed-off-by: Michael Braun 

--
v4:
 - update description
v3:
 - reuse existing num_mcast_sta
v2:
 - use separate function to inc/dec mcast_sta counters
 - do not filter in 4addr mode
 - change description
 - change filtering on AP interface (do not count AP_VLAN sta)
 - use new counters regardless of 4addr or not
 - simplify cfg.c:change_station
 - remove no-op change in __cleanup_single_sta
---
 net/mac80211/cfg.c| 20 ++--
 net/mac80211/debugfs_netdev.c | 11 +++
 net/mac80211/ieee80211_i.h| 33 +
 net/mac80211/rx.c |  5 +++--
 net/mac80211/sta_info.c   | 10 ++
 net/mac80211/tx.c |  5 ++---
 6 files changed, 57 insertions(+), 27 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 24133f5..1edb017 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1357,9 +1357,6 @@ static int ieee80211_change_station(struct wiphy *wiphy,
goto out_err;
 
if (params->vlan && params->vlan != sta->sdata->dev) {
-   bool prev_4addr = false;
-   bool new_4addr = false;
-
vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
 
if (params->vlan->ieee80211_ptr->use_4addr) {
@@ -1369,26 +1366,21 @@ static int ieee80211_change_station(struct wiphy *wiphy,
}
 
rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
-   new_4addr = true;
__ieee80211_check_fast_rx_iface(vlansdata);
}
 
if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
-   sta->sdata->u.vlan.sta) {
+   sta->sdata->u.vlan.sta)
RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
-   prev_4addr = true;
-   }
+
+   if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
+   ieee80211_vif_dec_num_mcast(sta->sdata);
 
sta->sdata = vlansdata;
ieee80211_check_fast_xmit(sta);
 
-   if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
-   prev_4addr != new_4addr) {
-   if (new_4addr)
-   atomic_dec(>sdata->bss->num_mcast_sta);
-   else
-   atomic_inc(>sdata->bss->num_mcast_sta);
-   }
+   if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
+   ieee80211_vif_inc_num_mcast(sta->sdata);
 
ieee80211_send_layer2_update(sta);
}
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index a5ba739..ed7bff4 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -477,6 +477,7 @@ IEEE80211_IF_FILE_RW(tdls_wider_bw);
 IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
 IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC);
 IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC);
+IEEE80211_IF_FILE(num_mcast_sta_vlan, u.vlan.num_mcast_sta, ATOMIC);
 
 static ssize_t ieee80211_if_fmt_num_buffered_multicast(
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
@@ -643,6 +644,13 @@ static void add_ap_files(struct ieee80211_sub_if_data 
*sdata)
DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
 }
 
+static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
+{
+   /* add num_mcast_sta_vlan using name num_mcast_sta */
+   debugfs_create_file("num_mcast_sta", 0400, sdata->vif.debugfs_dir,
+   sdata, _mcast_sta_vlan_ops);
+}
+
 static void add_ibss_files(struct ieee80211_sub_if_data *sdata)
 {
DEBUGFS_ADD_MODE(tsf, 0600);
@@ -746,6 +754,9 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
case NL80211_IFTYPE_AP:
add_ap_files(sdata);

[PATCH net v2] Fixing a bug in team driver due to incorrect 'unsigned int' to 'int' conversion

2016-10-07 Thread Alex Sidorenko
Roundrobin runner of team driver uses 'unsigned int' variable to count
the number of sent_packets. Later it is passed to a subroutine
team_num_to_port_index(struct team *team, int num) as 'num' and when
we reach MAXINT (2**31-1), 'num' becomes negative.

This leads to using incorrect hash-bucket for port lookup
and as a result, packets are dropped. The fix consists of changing 
'int num' to 'unsigned int num'. Testing of a fixed kernel shows that
there is no packet drop anymore.


Signed-off-by: Alex Sidorenko 


---
v2: fixed formatting

 include/linux/if_team.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 174f43f..c05216a 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -245,7 +245,7 @@ static inline struct team_port 
*team_get_port_by_index(struct team *team,
return NULL;
 }
 
-static inline int team_num_to_port_index(struct team *team, int num)
+static inline int team_num_to_port_index(struct team *team, unsigned int num)
 {
int en_port_count = ACCESS_ONCE(team->en_port_count);
 
-- 
2.7.4




Re: [PATCH net-next] MAINTAINERS: add myself as a maintainer of xen-netback

2016-10-07 Thread Wei Liu
On Fri, Oct 07, 2016 at 11:33:37AM +0100, Paul Durrant wrote:
> Signed-off-by: Paul Durrant 
> Cc: Wei Liu 

Acked-by: Wei Liu 

Thanks for stepping up!

> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 464437d..4491841 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13061,6 +13061,7 @@ F:arch/arm64/include/asm/xen/
>  
>  XEN NETWORK BACKEND DRIVER
>  M:   Wei Liu 
> +M:   Paul Durrant 
>  L:   xen-de...@lists.xenproject.org (moderated for non-subscribers)
>  L:   netdev@vger.kernel.org
>  S:   Supported
> -- 
> 2.1.4
> 


[PATCH net-next] MAINTAINERS: add myself as a maintainer of xen-netback

2016-10-07 Thread Paul Durrant
Signed-off-by: Paul Durrant 
Cc: Wei Liu 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 464437d..4491841 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13061,6 +13061,7 @@ F:  arch/arm64/include/asm/xen/
 
 XEN NETWORK BACKEND DRIVER
 M: Wei Liu 
+M: Paul Durrant 
 L: xen-de...@lists.xenproject.org (moderated for non-subscribers)
 L: netdev@vger.kernel.org
 S: Supported
-- 
2.1.4



Reversion of "xen-netback: create a debugfs node for hash information"

2016-10-07 Thread Paul Durrant
Dave,

  I notice that you have made the above reversion of commit c0c64c15 (debugfs 
node) due to a build failure, despite the failure being caused by commit 
0364a882 (switch to threaded irq) which was made subsequently. I assume you 
want me to re-spin a new patch for the debugfs node to fix the build problem?

  Cheers,

Paul


Re: [PATCH RFC 0/4] xfs: Transmit flow steering

2016-10-07 Thread Juerg Haefliger
As Rick states, this fixes a performance issue with the 4.4 kernel for us.

Tested-by: Juerg Haefliger 


On 09/28/2016 05:13 PM, Rick Jones wrote:
> 
> Here is a quick look at performance tests for the result of trying the
> prototype fix for the packet reordering problem with VMs sending over
> an XPS-configured NIC.  In particular, the Emulex/Avago/Broadcom
> Skyhawk.  The fix was applied to a 4.4 kernel.
> 
> Before: 3884 Mbit/s
> After: 8897 Mbit/s
> 
> That was from a VM on a node with a Skyhawk and 2 E5-2640 processors
> to baremetal E5-2640 with a BE3.  Physical MTU was 1500, the VM's
> vNIC's MTU was 1400.  Systems were HPE ProLiants in OS Control Mode
> for power management, with the "performance" frequency governor
> loaded. An OpenStack Mitaka setup with Distributed Virtual Router.
> 
> We had some other NIC types in the setup as well.  XPS was also
> enabled on the ConnectX3-Pro.  It was not enabled on the 82599ES (a
> function of the kernel being used, which had it disabled from the
> first reports of XPS negatively affecting VM traffic at the beginning
> of the year)
> 
> Average Mbit/s From NIC type To Bare Metal BE3:
> NIC Type,
>  CPU on VM HostBeforeAfter
> 
> ConnectX-3 Pro,E5-2670v39224 9271
> BE3, E5-26409016 9022
> 82599, E5-2640  9192 9003
> BCM57840, E5-2640   9213 9153
> Skyhawk, E5-26403884 8897
> 
> For completeness:
> Average Mbit/s To NIC type from Bare Metal BE3:
> NIC Type,
>  CPU on VM HostBeforeAfter
> 
> ConnectX-3 Pro,E5-2670v39322 9144
> BE3, E5-26409074 9017
> 82599, E5-2640  8670 8564
> BCM57840, E5-2640   2468 * 7979
> Skyhawk, E5-26408897 9269
> 
> * This is the Busted bnx2x NIC FW GRO implementation issue.  It was
>   not visible in the "After" because the system was setup to disable
>   the NIC FW GRO by the time it booted on the fix kernel.
> 
> Average Transactions/s Between NIC type and Bare Metal BE3:
> NIC Type,
>  CPU on VM HostBeforeAfter
> 
> ConnectX-3 Pro,E5-2670v3   12421 12612
> BE3, E5-26408178  8484
> 82599, E5-2640  8499  8549
> BCM57840, E5-2640   8544  8560
> Skyhawk, E5-26408537  8701
> 
> happy benchmarking,
> 
> Drew Balliet
> Jeurg Haefliger
> rick jones
> 
> The semi-cooked results with additional statistics:
> 
> 554M  - BE3
> 544+M - ConnectX-3 Pro
> 560M - 82599ES
> 630M - BCM57840
> 650M - Skyhawk
> 
> (substitute is simply replacing a system name with the model of NIC and CPU)
> Bulk To (South) and From (North) VM, Before:
> $ ../substitute.sh 
> vxlan_554m_control_performance_gvnr_dvr_northsouth_stream.log |
> ~/netperf2_trunk/doc/examples/parse_single_stream.py -r -5 -f 1 -f 3 -f 4 -f 
> 7 -f 8
> Field1,Field3,Field4,Field7,Field8,Min,P10,Median,Average,P90,P99,Max,Count
> North,560M,E5-2640,554FLB,E5-2640,8148.090,9048.830,9235.400,9192.868,9315.980,9338.845,9339.500,113
> North,630M,E5-2640,554FLB,E5-2640,8909.980,9113.238,9234.750,9213.140,9299.442,9336.206,9337.830,47
> North,544+M,E5-2670v3,554FLB,E5-2640,9013.740,9182.546,9229.620,9224.025,9264.036,9299.206,9301.970,99
> North,650M,E5-2640,554FLB,E5-2640,3187.680,3393.724,3796.160,3884.765,4405.096,4941.391,4956.300,129
> North,554M,E5-2640,554FLB,E5-2640,8700.930,8855.768,9026.030,9016.061,9158.846,9213.687,9226.150,135
> South,554FLB,E5-2640,560M,E5-2640,7754.350,8193.114,8718.540,8670.612,9026.436,9262.355,9285.010,113
> South,554FLB,E5-2640,630M,E5-2640,1897.660,2068.290,2514.430,2468.323,2787.162,2942.934,2957.250,53
> South,554FLB,E5-2640,544+M,E5-2670v3,9298.260,9314.432,9323.220,9322.207,9328.324,9330.704,9331.080,100
> South,554FLB,E5-2640,650M,E5-2640,8407.050,8907.136,9304.390,9206.776,9321.320,9325.347,9326.410,103
> South,554FLB,E5-2640,554M,E5-2640,7844.900,8632.530,9199.385,9074.535,9308.070,9319.224,9322.360,132
> 0 too-short lines ignored.
> 
> Bulk To (South) and From (North) VM, After:
> 
> $ ../substitute.sh 
> vxlan_554m_control_performance_gvnr_xpsfix_dvr_northsouth_stream.log |
> ~/netperf2_trunk/doc/examples/parse_single_stream.py -r -5 -f 1 -f 3 -f 4 -f 
> 7 -f 8
> Field1,Field3,Field4,Field7,Field8,Min,P10,Median,Average,P90,P99,Max,Count
> North,560M,E5-2640,554FLB,E5-2640,7576.790,8213.890,9182.870,9003.190,9295.975,9315.878,9318.160,36
> North,630M,E5-2640,554FLB,E5-2640,8811.800,8924.000,9206.660,9153.076,9306.287,9315.152,9315.790,12
> North,544+M,E5-2670v3,554FLB,E5-2640,9135.990,9228.520,9277.465,9271.875,9324.545,9339.604,9339.780,46
> North,650M,E5-2640,554FLB,E5-2640,8133.420,8483.340,8995.040,8897.779,9129.056,9165.230,9165.860,43
> 

Re: [PATCH v2 net] xen-netback: make sure that hashes are not send to unaware frontends

2016-10-07 Thread Wei Liu
On Fri, Oct 07, 2016 at 09:32:31AM +0100, Paul Durrant wrote:
> In the case when a frontend only negotiates a single queue with xen-
> netback it is possible for a skbuff with a s/w hash to result in a
> hash extra_info segment being sent to the frontend even when no hash
> algorithm has been configured. (The ndo_select_queue() entry point makes
> sure the hash is not set if no algorithm is configured, but this entry
> point is not called when there is only a single queue). This can result
> in a frontend that is unable to handle extra_info segments being given
> such a segment, causing it to crash.
> 
> This patch fixes the problem by clearing the hash in ndo_start_xmit()
> instead, which is clearly guaranteed to be called irrespective of the
> number of queues.
> 
> Signed-off-by: Paul Durrant 
> Cc: Wei Liu 

Acked-by: Wei Liu 

> ---
> 
> v2:
>  - Simplified and re-based onto re-factored net branch
> ---
>  drivers/net/xen-netback/interface.c | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/interface.c 
> b/drivers/net/xen-netback/interface.c
> index 4af532a..74dc2bf 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -149,17 +149,8 @@ static u16 xenvif_select_queue(struct net_device *dev, 
> struct sk_buff *skb,
>   struct xenvif *vif = netdev_priv(dev);
>   unsigned int size = vif->hash.size;
>  
> - if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE) {
> - u16 index = fallback(dev, skb) % dev->real_num_tx_queues;
> -
> - /* Make sure there is no hash information in the socket
> -  * buffer otherwise it would be incorrectly forwarded
> -  * to the frontend.
> -  */
> - skb_clear_hash(skb);
> -
> - return index;
> - }
> + if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE)
> + return fallback(dev, skb) % dev->real_num_tx_queues;
>  
>   xenvif_set_skb_hash(vif, skb);
>  
> @@ -208,6 +199,13 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct 
> net_device *dev)
>   cb = XENVIF_RX_CB(skb);
>   cb->expires = jiffies + vif->drain_timeout;
>  
> + /* If there is no hash algorithm configured then make sure there
> +  * is no hash information in the socket buffer otherwise it
> +  * would be incorrectly forwarded to the frontend.
> +  */
> + if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE)
> + skb_clear_hash(skb);
> +
>   xenvif_rx_queue_tail(queue, skb);
>   xenvif_kick_thread(queue);
>  
> -- 
> 2.1.4
> 


Re: Kernel 4.6.7-rt13: Intel Ethernet driver igb causes huge latencies in cyclictest

2016-10-07 Thread Koehrer Mathias (ETAS/ESW5)
Hi Mitch,
> > >
> > > Although, to be clear, it isn't the fact that there exists 8
> > > threads, it's
> > that the device is
> > > firing all 8 interrupts at the same time.  The time spent in hardirq
> > context just waking
> > > up all 8 of those threads (and the cyclictest wakeup) is enough to
> > > cause
> > your
> > > regression.
> > >
> > > netdev/igb folks-
> > >
> > > Under what conditions should it be expected that the i350 trigger
> > > all of
> > the TxRx
> > > interrupts simultaneously?  Any ideas here?
> 
> I can answer that! I wrote that code.
> 
> We trigger the interrupts once a second because MSI and MSI-X interrupts are 
> NOT
> guaranteed to be delivered. If this happens, the queues being serviced by 
> this "lost"
> interrupt are completely stuck.
> 
> The device automatically masks each interrupt vector after it fires, 
> expecting the
> ISR to re-enable the vector after processing is complete. If the interrupt is 
> lost, the
> ISR doesn't run, so the vector ends up permanently masked. At this point, any
> queues associated with that vector are stuck. The only recovery is through the
> netdev watchdog, which initiates a reset.
> 
> During development of igb, we had several platforms with chipsets that 
> routinely
> dropped MSI messages under stress. Things would be running fine and then, pow,
> all the traffic on a queue would stop.
> 
> So, I added code to fire each vector once per second. Just unmasking the 
> interrupt
> isn't enough - we need to trigger the ISR to get the queues cleaned up so the 
> device
> can work again.
> 
> Is this workaround still needed? I don't know. Modern chipsets don't break a 
> sweat
> handling gigabit-speed traffic, and they *probably* don't drop interrupts. 
> But I'd still
> rather have that insurance.
> 
> You could try to remove the write to the EICS registers in the watchdog task 
> to see if
> that takes care of your problem. But I wouldn't want to remove that code
> permanently, because we have seen lost interrupts in the past.
> 
> You also could try staggering the writes so that not all vectors fire each 
> second. But
> then you'll potentially incur a much longer delay if an interrupt does get 
> lost, which
> means you could trigger netdev watchdog events.
> 
> -Mitch

Thanks for the explanation. Now I have switched over to kernel 4.8-rt1.
This shows the very same effect.
I modified the in-kernel's igb_main.c (function igb_watchdog_task) to comment 
out
the access to the EICS registers:

--- igb_main.c.orig 2016-10-07 10:43:37.855873754 +0200
+++ igb_main.c  2016-10-07 10:31:51.451346292 +0200
@@ -4613,6 +4613,7 @@ no_wait:
}

/* Cause software interrupt to ensure Rx ring is cleaned */
+#if 0
if (adapter->flags & IGB_FLAG_HAS_MSIX) {
u32 eics = 0;

@@ -4622,6 +4623,7 @@ no_wait:
} else {
wr32(E1000_ICS, E1000_ICS_RXDMT0);
}
+#endif

igb_spoof_check(adapter);
igb_ptp_rx_hang(adapter);


The result is now slighty better, however the max latency that has been 
measured by
cyclictest is still much higher compared to the values of kernel 3.18.27-rt27.
I have now enabled all events, the execution of 
# cyclictest -a -i 105 -m -n -p 80 -t 1  -b 30 -C
delivers the following trace values


cyclicte-10062   0... 10025813402us : sys_exit: NR 230 = 0
cyclicte-10062   0... 10025813402us : sys_enter: NR 230 (1, 1, 
773ff930, 0, 0, 2bd7e12e)
cyclicte-10062   0... 10025813402us : hrtimer_init: 
hrtimer=88040a017e18 clockid=CLOCK_MONOTONIC mode=HRTIMER_MODE_ABS
cyclicte-10062   0d...1.. 10025813403us : hrtimer_start: 
hrtimer=88040a017e18 function=hrtimer_wakeup expires=10024735653388 
softexpires=10024735653388
cyclicte-10062   0d...1.. 10025813403us : write_msr: 6e0, value 20ca630b9aef
cyclicte-10062   0d...1.. 10025813403us : rcu_utilization: Start context switch
cyclicte-10062   0d...1.. 10025813403us : rcu_utilization: End context switch
cyclicte-10062   0d...2.. 10025813404us : sched_switch: prev_comm=cyclictest 
prev_pid=10062 prev_prio=19 prev_state=S ==> next_comm=kworker/0:3 
next_pid=1388 next_prio=120
cyclicte-10062   0d...2.. 10025813404us+: x86_fpu_regs_deactivated: x86/fpu: 
88040c603ec0 fpregs_active: 0 fpstate_active: 1 counter: 69 xfeatures: 2 
xcomp_bv: 0
kworker/-13880d..h... 10025813468us : irq_handler_entry: irq=48 
name=eth2-tx-0
kworker/-13880d..h... 10025813468us : irq_handler_exit: irq=48 ret=handled
kworker/-13880d..h1.. 10025813469us : sched_waking: comm=irq/48-eth2-tx- 
pid=10057 prio=49 target_cpu=000
kworker/-13880dN.h2.. 10025813469us : sched_wakeup: comm=irq/48-eth2-tx- 
pid=10057 prio=49 target_cpu=000
kworker/-13880dN.h1.. 10025813470us : irq_handler_entry: irq=47 
name=eth2-rx-0
kworker/-13880dN.h1.. 10025813470us : irq_handler_exit: irq=47 ret=handled
kworker/-13880dN.h2.. 10025813471us : sched_waking: comm=irq/47-eth2-rx- 
pid=10056 prio=49 target_cpu=000
kworker/-1388

[PATCH v2 net] xen-netback: make sure that hashes are not send to unaware frontends

2016-10-07 Thread Paul Durrant
In the case when a frontend only negotiates a single queue with xen-
netback it is possible for a skbuff with a s/w hash to result in a
hash extra_info segment being sent to the frontend even when no hash
algorithm has been configured. (The ndo_select_queue() entry point makes
sure the hash is not set if no algorithm is configured, but this entry
point is not called when there is only a single queue). This can result
in a frontend that is unable to handle extra_info segments being given
such a segment, causing it to crash.

This patch fixes the problem by clearing the hash in ndo_start_xmit()
instead, which is clearly guaranteed to be called irrespective of the
number of queues.

Signed-off-by: Paul Durrant 
Cc: Wei Liu 
---

v2:
 - Simplified and re-based onto re-factored net branch
---
 drivers/net/xen-netback/interface.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/xen-netback/interface.c 
b/drivers/net/xen-netback/interface.c
index 4af532a..74dc2bf 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -149,17 +149,8 @@ static u16 xenvif_select_queue(struct net_device *dev, 
struct sk_buff *skb,
struct xenvif *vif = netdev_priv(dev);
unsigned int size = vif->hash.size;
 
-   if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE) {
-   u16 index = fallback(dev, skb) % dev->real_num_tx_queues;
-
-   /* Make sure there is no hash information in the socket
-* buffer otherwise it would be incorrectly forwarded
-* to the frontend.
-*/
-   skb_clear_hash(skb);
-
-   return index;
-   }
+   if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE)
+   return fallback(dev, skb) % dev->real_num_tx_queues;
 
xenvif_set_skb_hash(vif, skb);
 
@@ -208,6 +199,13 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct 
net_device *dev)
cb = XENVIF_RX_CB(skb);
cb->expires = jiffies + vif->drain_timeout;
 
+   /* If there is no hash algorithm configured then make sure there
+* is no hash information in the socket buffer otherwise it
+* would be incorrectly forwarded to the frontend.
+*/
+   if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE)
+   skb_clear_hash(skb);
+
xenvif_rx_queue_tail(queue, skb);
xenvif_kick_thread(queue);
 
-- 
2.1.4



[PATCH net-next v9 0/1] net: phy: Cleanup the Edge-Rate feature in Microsemi PHYs

2016-10-07 Thread Allan W. Nielsen
Hi Andrew (and other),

Raju and I have been going through all the comments received on the edge-rate
feature, and tried to address them (once again...).

The patch is rebased to fit on top of net-next (it depends on a4cc96d1f).

Following initiatives is covered:

- Updated device tree bindings documentation for edge-rate
- The edge-rate is now specified as a "slowdown", meaning that it is now
  being specified as positive values instead of negative (both
  documentation and implementation wise).
- Only explicitly documented values for "vsc8531,vddmac" and
  "vsc8531,edge-slowdown" are accepted by the device driver.
- Deleting include/dt-bindings/net/mscc-phy-vsc8531.h as it was not needed.
- Initialize to default values when CONFIG_OF_MDIO is not defined
- Using ARRAY_SIZE when iterating through an array.

Please review.

Best regards
Allan W. Nielsen



[PATCH v4 10/10] ARM: sunxi: Enable sun8i-emac driver on multi_v7_defconfig

2016-10-07 Thread Corentin Labbe
Enable the sun8i-emac driver in the multi_v7 default configuration

Signed-off-by: Corentin Labbe 
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index 5845910..f44d633 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -229,6 +229,7 @@ CONFIG_NETDEVICES=y
 CONFIG_VIRTIO_NET=y
 CONFIG_HIX5HD2_GMAC=y
 CONFIG_SUN4I_EMAC=y
+CONFIG_SUN8I_EMAC=y
 CONFIG_MACB=y
 CONFIG_BCMGENET=m
 CONFIG_SYSTEMPORT=m
-- 
2.7.3



[PATCH v4 08/10] ARM: dts: sun8i: Enable sun8i-emac on the Orange Pi 2

2016-10-07 Thread Corentin Labbe
The sun8i-emac hardware is present on the Orange PI 2.
It uses the internal PHY.

This patch create the needed emac node.

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts 
b/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts
index f93f5d1..5608eb4 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-2.dts
@@ -54,6 +54,7 @@
 
aliases {
serial0 = 
+   ethernet0 = 
};
 
chosen {
@@ -184,3 +185,10 @@
usb1_vbus-supply = <_usb1_vbus>;
status = "okay";
 };
+
+ {
+   phy-handle = <_mii_phy>;
+   phy-mode = "mii";
+   allwinner,leds-active-low;
+   status = "okay";
+};
-- 
2.7.3



[PATCH v4 07/10] ARM: dts: sun8i: Enable sun8i-emac on the Orange PI One

2016-10-07 Thread Corentin Labbe
From: Hans de Goede 

The sun8i-emac hardware is present on the Orange PI One.
It uses the internal PHY.

This patch create the needed emac node.

Signed-off-by: Hans de Goede 
Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts 
b/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
index 0adf932..25f2455 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
@@ -54,6 +54,7 @@
 
aliases {
serial0 = 
+   ethernet0 = 
};
 
chosen {
@@ -94,6 +95,13 @@
status = "okay";
 };
 
+ {
+   phy-handle = <_mii_phy>;
+   phy-mode = "mii";
+   allwinner,leds-active-low;
+   status = "okay";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_pins_a>, <_cd_pin>;
-- 
2.7.3



[PATCH v4 06/10] ARM: dts: sun8i: Enable sun8i-emac on the Orange PI PC

2016-10-07 Thread Corentin Labbe
The sun8i-emac hardware is present on the Orange PI PC.
It uses the internal PHY.

This patch create the needed emac node.

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts 
b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
index daf50b9a6..71717cc 100644
--- a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
+++ b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
@@ -54,6 +54,7 @@
 
aliases {
serial0 = 
+   ethernet0 = 
};
 
chosen {
@@ -165,3 +166,10 @@
/* USB VBUS is always on */
status = "okay";
 };
+
+ {
+   phy-handle = <_mii_phy>;
+   phy-mode = "mii";
+   allwinner,leds-active-low;
+   status = "okay";
+};
-- 
2.7.3



[PATCH v4 04/10] ARM: dts: sun8i-h3: Add dt node for the syscon control module

2016-10-07 Thread Corentin Labbe
This patch add the dt node for the syscon register present on the
Allwinner H3.

Only two register are present in this syscon and the only one useful is
the one dedicated to EMAC clock.

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
index 8a95e36..1101d2f 100644
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
@@ -140,6 +140,11 @@
#size-cells = <1>;
ranges;
 
+   syscon: syscon@01c0 {
+   compatible = "syscon";
+   reg = <0x01c0 0x1000>;
+   };
+
dma: dma-controller@01c02000 {
compatible = "allwinner,sun8i-h3-dma";
reg = <0x01c02000 0x1000>;
-- 
2.7.3



[PATCH v4 03/10] ARM: sun8i: dt: Add DT bindings documentation for Allwinner sun8i-emac

2016-10-07 Thread Corentin Labbe
This patch adds documentation for Device-Tree bindings for the
Allwinner sun8i-emac driver.

Signed-off-by: Corentin Labbe 
---
 .../bindings/net/allwinner,sun8i-emac.txt  | 70 ++
 1 file changed, 70 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt

diff --git a/Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt 
b/Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt
new file mode 100644
index 000..92e4ef3b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt
@@ -0,0 +1,70 @@
+* Allwinner sun8i EMAC ethernet controller
+
+Required properties:
+- compatible: should be one of the following string:
+   "allwinner,sun8i-a83t-emac"
+   "allwinner,sun8i-h3-emac"
+   "allwinner,sun50i-a64-emac"
+- reg: address and length of the register for the device.
+- syscon: A phandle to the syscon of the SoC
+- interrupts: interrupt for the device
+- clocks: A phandle to the reference clock for this device
+- clock-names: should be "ahb"
+- resets: A phandle to the reset control for this device
+- reset-names: should be "ahb"
+- phy-mode: See ethernet.txt
+- phy-handle: See ethernet.txt
+- #address-cells: shall be 1
+- #size-cells: shall be 0
+
+Optional properties:
+- allwinner,tx-delay: TX clock delay chain value. Range value is 0-0x07. 
Default is 0)
+- allwinner,rx-delay: RX clock delay chain value. Range value is 0-0x1F. 
Default is 0)
+Both delay properties does not have units, there are arbitrary value.
+The TX/RX clock delay chain settings are board specific and could be found
+in vendor FEX files.
+
+Optional properties for "allwinner,sun8i-h3-emac":
+- allwinner,leds-active-low: EPHY LEDs are active low
+
+Required child node of emac:
+- mdio bus node: should be named mdio
+
+Required properties of the mdio node:
+- #address-cells: shall be 1
+- #size-cells: shall be 0
+
+The device node referenced by "phy" or "phy-handle" should be a child node
+of the mdio node. See phy.txt for the generic PHY bindings.
+
+Required properties of the phy node with "allwinner,sun8i-h3-emac":
+- clocks: an extra phandle to the reference clock for the EPHY
+- resets: an extra phandle to the reset control for the EPHY
+
+Example:
+
+emac: ethernet@01c0b000 {
+   compatible = "allwinner,sun8i-h3-emac";
+   syscon = <>;
+   reg = <0x01c0b000 0x104>;
+   interrupts = ;
+   resets = < RST_BUS_EMAC>;
+   reset-names = "ahb";
+   clocks = < CLK_BUS_EMAC>;
+   clock-names = "ahb";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   phy = <_mii_phy>;
+   phy-mode = "mii";
+   allwinner,leds-active-low;
+   mdio: mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   int_mii_phy: ethernet-phy@1 {
+   reg = <1>;
+   clocks = < CLK_BUS_EPHY>;
+   resets = < RST_BUS_EPHY>;
+   };
+   };
+};
-- 
2.7.3



[PATCH v4 09/10] ARM: sunxi: Enable sun8i-emac driver on sunxi_defconfig

2016-10-07 Thread Corentin Labbe
Enable the sun8i-emac driver in the sunxi default configuration

Signed-off-by: Corentin Labbe 
---
 arch/arm/configs/sunxi_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index 714da33..153707a 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -40,6 +40,7 @@ CONFIG_ATA=y
 CONFIG_AHCI_SUNXI=y
 CONFIG_NETDEVICES=y
 CONFIG_SUN4I_EMAC=y
+CONFIG_SUN8I_EMAC=y
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_CADENCE is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
-- 
2.7.3



[PATCH v4 01/10] ethernet: add sun8i-emac driver

2016-10-07 Thread Corentin Labbe
This patch add support for sun8i-emac ethernet MAC hardware.
It could be found in Allwinner H3/A83T/A64 SoCs.

It supports 10/100/1000 Mbit/s speed with half/full duplex.
It can use an internal PHY (MII 10/100) or an external PHY
via RGMII/RMII.

Signed-off-by: Corentin Labbe 
---
 drivers/net/ethernet/allwinner/Kconfig  |   13 +
 drivers/net/ethernet/allwinner/Makefile |1 +
 drivers/net/ethernet/allwinner/sun8i-emac.c | 2266 +++
 3 files changed, 2280 insertions(+)
 create mode 100644 drivers/net/ethernet/allwinner/sun8i-emac.c

diff --git a/drivers/net/ethernet/allwinner/Kconfig 
b/drivers/net/ethernet/allwinner/Kconfig
index 47da7e7..060569c 100644
--- a/drivers/net/ethernet/allwinner/Kconfig
+++ b/drivers/net/ethernet/allwinner/Kconfig
@@ -33,4 +33,17 @@ config SUN4I_EMAC
   To compile this driver as a module, choose M here.  The module
   will be called sun4i-emac.
 
+config SUN8I_EMAC
+   tristate "Allwinner sun8i EMAC support"
+   depends on ARCH_SUNXI || COMPILE_TEST
+   depends on OF
+   select MII
+   select PHYLIB
+---help---
+ This driver support the sun8i EMAC ethernet driver present on
+ H3/A83T/A64 Allwinner SoCs.
+
+  To compile this driver as a module, choose M here.  The module
+  will be called sun8i-emac.
+
 endif # NET_VENDOR_ALLWINNER
diff --git a/drivers/net/ethernet/allwinner/Makefile 
b/drivers/net/ethernet/allwinner/Makefile
index 03129f7..8bd1693c 100644
--- a/drivers/net/ethernet/allwinner/Makefile
+++ b/drivers/net/ethernet/allwinner/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_SUN4I_EMAC) += sun4i-emac.o
+obj-$(CONFIG_SUN8I_EMAC) += sun8i-emac.o
diff --git a/drivers/net/ethernet/allwinner/sun8i-emac.c 
b/drivers/net/ethernet/allwinner/sun8i-emac.c
new file mode 100644
index 000..aa525d7
--- /dev/null
+++ b/drivers/net/ethernet/allwinner/sun8i-emac.c
@@ -0,0 +1,2266 @@
+/*
+ * sun8i-emac driver
+ *
+ * Copyright (C) 2015-2016 Corentin LABBE 
+ *
+ * This is the driver for Allwinner Ethernet MAC found in H3/A83T/A64 SoC
+ *
+ * TODO:
+ * - MAC filtering
+ * - Jumbo frame
+ * - features rx-all (NETIF_F_RXALL_BIT)
+ * - PM runtime
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EMAC_BASIC_CTL00x00
+#define EMAC_BASIC_CTL10x04
+#define EMAC_INT_STA   0x08
+#define EMAC_INT_EN0x0C
+#define EMAC_TX_CTL0   0x10
+#define EMAC_TX_CTL1   0x14
+#define EMAC_TX_FLOW_CTL   0x1C
+#define EMAC_RX_CTL0   0x24
+#define EMAC_RX_CTL1   0x28
+#define EMAC_RX_FRM_FLT0x38
+#define EMAC_MDIO_CMD  0x48
+#define EMAC_MDIO_DATA 0x4C
+#define EMAC_TX_DMA_STA0xB0
+#define EMAC_TX_CUR_DESC   0xB4
+#define EMAC_TX_CUR_BUF0xB8
+#define EMAC_RX_DMA_STA0xC0
+
+#define MDIO_CMD_MII_BUSY  BIT(0)
+#define MDIO_CMD_MII_WRITE BIT(1)
+#define MDIO_CMD_MII_PHY_REG_ADDR_MASK GENMASK(8, 4)
+#define MDIO_CMD_MII_PHY_REG_ADDR_SHIFT4
+#define MDIO_CMD_MII_PHY_ADDR_MASK GENMASK(16, 12)
+#define MDIO_CMD_MII_PHY_ADDR_SHIFT12
+
+#define EMAC_MACADDR_HI0x50
+#define EMAC_MACADDR_LO0x54
+
+#define EMAC_RX_DESC_LIST 0x34
+#define EMAC_TX_DESC_LIST 0x20
+
+#define EMAC_RX_DO_CRC BIT(27)
+#define EMAC_RX_STRIP_FCS BIT(28)
+
+#define LE32_BIT(x) (cpu_to_le32(BIT(x)))
+
+#define EMAC_COULD_BE_USED_BY_DMA LE32_BIT(31)
+
+/* Used in RX_CTL1*/
+#define EMAC_RX_DMA_EN BIT(30)
+#define EMAC_RX_DMA_START  BIT(31)
+/* Used in TX_CTL1*/
+#define EMAC_TX_DMA_EN BIT(30)
+#define EMAC_TX_DMA_START  BIT(31)
+
+/* Used in RX_CTL0 */
+#define EMAC_RX_RECEIVER_ENBIT(31)
+/* Used in TX_CTL0 */
+#define EMAC_TX_TRANSMITTER_EN BIT(31)
+
+/* Basic CTL0 */
+#define EMAC_BCTL0_FD BIT(0)
+#define EMAC_BCTL0_SPEED_102
+#define EMAC_BCTL0_SPEED_100   3
+#define EMAC_BCTL0_SPEED_MASK  GENMASK(3, 2)
+#define EMAC_BCTL0_SPEED_SHIFT 2
+
+#define EMAC_FLOW_RX 1
+#define EMAC_FLOW_TX 2
+
+#define EMAC_TX_INTBIT(0)
+#define EMAC_TX_DMA_STOP_INT   BIT(1)
+#define EMAC_TX_BUF_UA_INT BIT(2)
+#define EMAC_TX_TIMEOUT_INTBIT(3)
+#define EMAC_TX_UNDERFLOW_INT  BIT(4)
+#define EMAC_TX_EARLY_INT  BIT(5)
+#define EMAC_RX_INTBIT(8)
+#define EMAC_RX_BUF_UA_INT BIT(9)
+#define EMAC_RX_DMA_STOP_INT   BIT(10)
+#define EMAC_RX_TIMEOUT_INTBIT(11)
+#define EMAC_RX_OVERFLOW_INT   BIT(12)
+#define EMAC_RX_EARLY_INT  BIT(13)
+#define EMAC_RGMII_STA_INT BIT(16)
+
+/* Bits used in frame RX status */
+#define EMAC_DSC_RX_FIRST  BIT(9)
+#define EMAC_DSC_RX_LAST   BIT(8)
+
+/* Bits used in frame TX ctl */
+#define EMAC_MAGIC_TX_BIT  LE32_BIT(24)
+#define EMAC_TX_DO_CRC (LE32_BIT(27) | 

[PATCH v4 05/10] ARM: dts: sun8i-h3: add sun8i-emac ethernet driver

2016-10-07 Thread Corentin Labbe
The sun8i-emac is an ethernet MAC hardware that support 10/100/1000
speed.

This patch enable the sun8i-emac on the Allwinner H3 SoC Device-tree.
The SoC H3 have an internal PHY, so optionals syscon and ephy are set.

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sun8i-h3.dtsi | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
index 1101d2f..d218154 100644
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
@@ -446,6 +446,30 @@
status = "disabled";
};
 
+   emac: ethernet@1c3 {
+   compatible = "allwinner,sun8i-h3-emac";
+   syscon = <>;
+   reg = <0x01c3 0x104>;
+   interrupts = ;
+   resets = < RST_BUS_EMAC>;
+   reset-names = "ahb";
+   clocks = < CLK_BUS_EMAC>;
+   clock-names = "ahb";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+
+   mdio: mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   int_mii_phy: ethernet-phy@1 {
+   reg = <1>;
+   clocks = < CLK_BUS_EPHY>;
+   resets = < RST_BUS_EPHY>;
+   };
+   };
+   };
+
gic: interrupt-controller@01c81000 {
compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
reg = <0x01c81000 0x1000>,
-- 
2.7.3



[PATCH v4 02/10] MAINTAINERS: Add myself as maintainer of sun8i-emac

2016-10-07 Thread Corentin Labbe
This patch add myself as maintainer of the sun8i-emac driver.

Signed-off-by: Corentin Labbe 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 40f4629..e197d82 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -582,6 +582,12 @@ S: Maintained
 F: Documentation/i2c/busses/i2c-ali1563
 F: drivers/i2c/busses/i2c-ali1563.c
 
+ALLWINNER SUN8I-EMAC ETHERNET DRIVER
+M: Corentin Labbe 
+L: netdev@vger.kernel.org
+S: Maintained
+F: drivers/net/ethernet/allwinner/sun8i-emac.c
+
 ALLWINNER SECURITY SYSTEM
 M: Corentin Labbe 
 L: linux-cry...@vger.kernel.org
-- 
2.7.3



[PATCH net-next v9 1/1] net: phy: Cleanup the Edge-Rate feature in Microsemi PHYs.

2016-10-07 Thread Allan W. Nielsen
Edge-Rate cleanup include the following:
- Updated device tree bindings documentation for edge-rate
- The edge-rate is now specified as a "slowdown", meaning that it is now
  being specified as positive values instead of negative (both
  documentation and implementation wise).
- Only explicitly documented values for "vsc8531,vddmac" and
  "vsc8531,edge-slowdown" are accepted by the device driver.
- Deleting include/dt-bindings/net/mscc-phy-vsc8531.h as it was not needed.

Signed-off-by: Allan W. Nielsen 
Signed-off-by: Raju Lakkaraju 
---
 .../devicetree/bindings/net/mscc-phy-vsc8531.txt   | 49 --
 drivers/net/phy/mscc.c | 79 +-
 include/dt-bindings/net/mscc-phy-vsc8531.h | 21 --
 3 files changed, 75 insertions(+), 74 deletions(-)
 delete mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h

diff --git a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt 
b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
index 99c7eb0..f552033 100644
--- a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
+++ b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
@@ -6,20 +6,27 @@ Required properties:
  Documentation/devicetree/bindings/net/phy.txt
 
 Optional properties:
-- vsc8531,vddmac   : The vddmac in mV.
+- vsc8531,vddmac   : The vddmac in mV. Allowed values is listed
+ in the first row of Table 1 (below).
+ This property is only used in combination
+ with the 'edge-slowdown' property.
+ Default value is 3300.
 - vsc8531,edge-slowdown: % the edge should be slowed down relative to
- the fastest possible edge time. Native sign
- need not enter.
+ the fastest possible edge time.
  Edge rate sets the drive strength of the MAC
- interface output signals.  Changing the drive
- strength will affect the edge rate of the output
- signal.  The goal of this setting is to help
- reduce electrical emission (EMI) by being able
- to reprogram drive strength and in effect slow
- down the edge rate if desired.  Table 1 shows the
- impact to the edge rate per VDDMAC supply for each
- drive strength setting.
- Ref: Table:1 - Edge rate change below.
+ interface output signals.  Changing the
+ drive strength will affect the edge rate of
+ the output signal.  The goal of this setting
+ is to help reduce electrical emission (EMI)
+ by being able to reprogram drive strength
+ and in effect slow down the edge rate if
+ desired.
+ To adjust the edge-slowdown, the 'vddmac'
+ must be specified. Table 1 lists the
+ supported edge-slowdown values for a given
+ 'vddmac'.
+ Default value is 0%.
+ Ref: Table:1 - Edge rate change (below).
 
 Note: see dt-bindings/net/mscc-phy-vsc8531.h for applicable values
 
@@ -29,23 +36,23 @@ Table: 1 - Edge rate change
 |  |
 | 3300 mV  2500 mV 1800 mV 1500 mV |
 |---|
-| Default  Deafult Default Default |
+| 0%   0%  0%  0%  |
 | (Fastest)(recommended)   (recommended)   |
 |---|
-| -2%  -3% -5% -6% |
+| 2%   3%  5%  6%  |
 |---|
-| -4%  -6% -9% -14%|
+| 4%   6%  9%  14% |
 |---|
-| -7%  -10%-16%-21%|
+| 7%   10% 16% 21% |
 |(recommended) (recommended)   |
 |---|
-| -10% -14%-23%-29%|
+| 10%  14% 23% 29% |
 |---|
-| -17% -23%-35%-42%|
+| 17%  23%

[PATCH v4 00/10] net-next: ethernet: add sun8i-emac driver

2016-10-07 Thread Corentin Labbe
Hello

This patch series add the driver for sun8i-emac which handle the Ethernet MAC
present on Allwinner H3/A83T/A64 SoCs.

It supports 10/100/1000 Mbit/s speed with half/full duplex.
It can use an internal PHY (MII 10/100) or an external PHY
via RGMII/RMII.

This patch series enable the driver only for the H3 SoC since A83T and A64
doesn't have the necessary clocks present in mainline.

This patch series enable the driver only for OrangePiPC and OrangePIOne boards
since other board with H3 use external PHY which need optional regulators
that will be supported later.

The driver have been tested on the following boards:
- H3 Orange PI PC, Orange PI Plus, BananaPI-M2+
- A64 Pine64
- A83T BananaPI-M3

I would like to thanks Chen-Yu Tsai for his help on developing this driver.

Regards

Changes since v3
- sun8i-emac require a DT mdio node
- moved sun8i_emac_power() so that no clock/reset/regulator is used
until netdev/open is called
- Removed PM patch until proper tests are done
- DT use phy-handle instead of phy
- Moved DT aliases ethernet to subnodes
- Renamed PHY nodes to [int|ext]_[r|g]mii_phy
- Moved clock/reset for internal PHY to PHY node.

Changes since v2
- Added patch to support Orange PI One
- Added a patch to enable SUN8I_EMAC in sunxi_defconfig
- Added a patch to enable pm_runtime
- The Emac clock is now used standard syscon/regmap
- Added netdev_sent_queue/netdev_completed_queue
- Added lots of documentation on working (locks, memory barrier, etc...)
- Cleaned DT bindings documentation
- Added ethernet0 aliases as suggested by Hans de Goede
- Change prefix of all DEFINE to EMAC_
- The driver is now endian safe
- Reworked the internal PHY mechanism
- Removed dma_set_mask_and_coherent(32) since it is the default for 
of_platform_driver

Changes since v1
- Implement NAPI
- Sorted and reworded all define
- Reworked ethtools stats strings
- Removed all unneeded __packked and __aligned
- Added tuning of RX/TX ring size via ethtool
- Corrected use of sk/skb naming
- Added some wmb when needed
- Moved irq claim/free to emac_open/close
- Lots of code refactoring

Corentin Labbe (9):
  ethernet: add sun8i-emac driver
  MAINTAINERS: Add myself as maintainer of sun8i-emac
  ARM: sun8i: dt: Add DT bindings documentation for Allwinner sun8i-emac
  ARM: dts: sun8i-h3: Add dt node for the syscon control module
  ARM: dts: sun8i-h3: add sun8i-emac ethernet driver
  ARM: dts: sun8i: Enable sun8i-emac on the Orange PI PC
  ARM: dts: sun8i: Enable sun8i-emac on the Orange Pi 2
  ARM: sunxi: Enable sun8i-emac driver on multi_v7_defconfig
  ARM: sunxi: Enable sun8i-emac driver on sunxi_defconfig

Hans de Goede (1):
  ARM: dts: sun8i: Enable sun8i-emac on the Orange PI One

 .../bindings/net/allwinner,sun8i-emac.txt  |   70 +
 MAINTAINERS|6 +
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts  |8 +
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts|8 +
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts |8 +
 arch/arm/boot/dts/sun8i-h3.dtsi|   29 +
 arch/arm/configs/multi_v7_defconfig|1 +
 arch/arm/configs/sunxi_defconfig   |1 +
 drivers/net/ethernet/allwinner/Kconfig |   13 +
 drivers/net/ethernet/allwinner/Makefile|1 +
 drivers/net/ethernet/allwinner/sun8i-emac.c| 2266 
 11 files changed, 2411 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt
 create mode 100644 drivers/net/ethernet/allwinner/sun8i-emac.c

-- 
2.7.3



[PATCH v2] ipv6 addrconf: disallow rtr_solicits < -1

2016-10-07 Thread Maciej Żenczykowski
From: Maciej Żenczykowski 

This disallows setting /proc/sys/net/ipv6/conf/*/router_solicitations
to values below -1.

-1 continues to mean an unlimited number of retransmits.

Note: this depends on 'ipv6 addrconf: remove addrconf_sysctl_hop_limit()'

Signed-off-by: Maciej Żenczykowski 
---
 net/ipv6/addrconf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index cbd9343751a2..d8983e15f859 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5729,6 +5729,7 @@ int addrconf_sysctl_ignore_routes_with_linkdown(struct 
ctl_table *ctl,
return ret;
 }
 
+static int minus_one = -1;
 static const int one = 1;
 static const int two_five_five = 255;
 
@@ -5789,7 +5790,8 @@ static const struct ctl_table addrconf_sysctl[] = {
.data   = _devconf.rtr_solicits,
.maxlen = sizeof(int),
.mode   = 0644,
-   .proc_handler   = proc_dointvec,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = _one,
},
{
.procname   = "router_solicitation_interval",
-- 
2.8.0.rc3.226.g39d4020



  1   2   >