Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH iproute2 net 0/8] tc/act_pedit: Support offset relative to conventional header
From: Stephen Hemminger @ 2017-05-01 16:26 UTC (permalink / raw)
  To: Amir Vadai; +Cc: netdev, Or Gerlitz, Jamal Hadi Salim
In-Reply-To: <20170423125356.1298-1-amir@vadai.me>

On Sun, 23 Apr 2017 15:53:48 +0300
Amir Vadai <amir@vadai.me> wrote:

> Hi Stephen,
> 
> This patchset extends pedit to support modifying a field in an offset relative
> to the conventional network headers (kenrel support was added [1] in 4.11 rc1).
> Without the extended pedit, user could specify fields in TCP and ICMP headers,
> but the kernel code was using an offset relative to the begining of the IP
> header. This will break if IP header length is greater than the minimal value
> of 20, or if L3 is not IPv4.
> 
> It also introduces support in manipulating ETH, TCP, UDP and IP.ttl fields and
> a new command to increase/decrease the value of a field (current use case is IP.ttl).
> 
> Since there might be deployments already using pedit, special consideration was
> taken, not to break those scripts - only by specifying the special keyword
> 'ex', the extended capabilities are available, thus there should be no impact
> on existing scripts.
> Also, the new code can live together with rules added by the old code. It
> supports both the old netlink and the new one.
> 
> This patchset is against the master and not net-next as the functionality was
> added in 4.11
> 
> Thanks,
> Amir
> 
> [1] - 71d0ed7079df ("net/act_pedit: Support using offset relative to the
>                      conventional network headers")
> 
> Amir Vadai (7):
>   tc/pedit: Fix a typo in pedit usage message
>   tc/pedit: Extend pedit to specify offset relative to mac/transport
>     headers
>   tc/pedit: Introduce 'add' operation
>   tc/pedit: p_ip: introduce editing ttl header
>   tc/pedit: Support fields bigger than 32 bits
>   tc/pedit: p_eth: ETH header editor
>   tc/pedit: p_tcp: introduce pedit tcp support
> 
> Or Gerlitz (1):
>   tc/pedit: p_udp: introduce pedit udp support
> 
>  man/man8/tc-pedit.8 | 126 +++++++++++++++++++++--
>  tc/Makefile         |   1 +
>  tc/m_pedit.c        | 290 ++++++++++++++++++++++++++++++++++++++++++++++------
>  tc/m_pedit.h        |  44 ++++++--
>  tc/p_eth.c          |  72 +++++++++++++
>  tc/p_icmp.c         |   3 +-
>  tc/p_ip.c           |  21 +++-
>  tc/p_tcp.c          |  40 +++++++-
>  tc/p_udp.c          |  30 +++++-
>  9 files changed, 572 insertions(+), 55 deletions(-)
>  create mode 100644 tc/p_eth.c
> 

Applied. Then I cleaned up long lines

^ permalink raw reply

* Re: [PATCH iproute2 net-next v2] bpf: add support for generic xdp
From: Stephen Hemminger @ 2017-05-01 16:29 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: alexei.starovoitov, davem, netdev
In-Reply-To: <e2ca217f7b95b4dd0b5fa8650e8fcf783de73967.1493386943.git.daniel@iogearbox.net>

On Fri, 28 Apr 2017 15:44:29 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:

> Follow-up to commit c7272ca72009 ("bpf: add initial support for
> attaching xdp progs") to also support generic XDP. This adds an
> indicator for loaded generic XDP programs when programs are loaded
> as shown in c7272ca72009, but the driver still lacks native XDP
> support.
> 
>   # ip link
>   [...]
>   3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc [...]
>       link/ether 0c:c4:7a:03:f9:25 brd ff:ff:ff:ff:ff:ff
>   [...]
> 
> In case the driver does support native XDP, but the user wants
> to load the program as generic XDP (e.g. for testing purposes),
> then this can be done with the same semantics as in c7272ca72009,
> but with 'xdpgeneric' instead of 'xdp' command for loading:
> 
>   # ip -force link set dev eno1 xdpgeneric obj xdp.o
> 
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Applied, thanks for remembering to update man page.
Does bash-completion need update?

^ permalink raw reply

* Re: [PATCH iproute2 net-next] ip xfrm: Add xfrm state crypto offload
From: Stephen Hemminger @ 2017-05-01 16:31 UTC (permalink / raw)
  To: ilant; +Cc: Steffen Klassert, netdev, Boris Pismenny
In-Reply-To: <20170430141602.30995-1-ilant@mellanox.com>

On Sun, 30 Apr 2017 17:16:02 +0300
<ilant@mellanox.com> wrote:

> From: Boris Pismenny <borisp@mellanox.com>
> 
> syntax:
> ip xfrm state .... offload dev <if-name> dir <in or out>
> 
> Example to add inbound offload:
>   ip xfrm state .... offload dev mlx0 dir in
> Example to add outbound offload:
>   ip xfrm state .... offload dev mlx0 dir out
> 
> Signed-off-by: Boris Pismenny <borisp@mellanox.com>
> Signed-off-by: Ilan Tayari <ilant@mellanox.com>


Applied to net-next

^ permalink raw reply

* net/smc and the RDMA core
From: Christoph Hellwig @ 2017-05-01 16:33 UTC (permalink / raw)
  To: Ursula Braun, David S. Miller
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA

Hi Ursual, hi netdev reviewers,

how did the smc protocol manage to get merged without any review 
on linux-rdma at all?  As the results it seems it's very substandard
in terms of RDMA API usage, e.g. it neither uses the proper CQ API
nor the RDMA R/W API, and other will probably find additional issues
as well.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* 13067 netdev
From: kelley @ 2017-05-01 16:37 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: 26336675947658.zip --]
[-- Type: application/zip, Size: 4203 bytes --]

^ permalink raw reply

* [PATCH 1/1] IB/mlx5: Add port_xmit_wait to counter registers read
From: Tim Wright @ 2017-05-01 16:30 UTC (permalink / raw)
  To: matanb, leonro, dledford, sean.hefty, hal.rosenstock, saeedm
  Cc: Tim Wright, linux-rdma, netdev

Add port_xmit_wait to the error counters read by mlx5_ib_process_mad to
ensure sysfs port counter provides correct value for PortXmitWait.
Otherwise the sysfs port_xmit_wait file always contains zero.

The previous MAD_IFC implementation populated this counter, but it was
removed during the migration to PPCNT for error counters (32-bit only).

Signed-off-by: Tim Wright <tim@binbash.co.uk>
---
 drivers/infiniband/hw/mlx5/mad.c | 2 ++
 include/linux/mlx5/mlx5_ifc.h    | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c
index 8dacb49..f1b56de6 100644
--- a/drivers/infiniband/hw/mlx5/mad.c
+++ b/drivers/infiniband/hw/mlx5/mad.c
@@ -187,6 +187,8 @@ static void pma_cnt_assign(struct ib_pma_portcounters *pma_cnt,
 			     port_xmit_discards);
 	MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_xmit_constraint_errors,
 			     port_xmit_constraint_errors);
+	MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_xmit_wait,
+			     port_xmit_wait);
 	MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_rcv_constraint_errors,
 			     port_rcv_constraint_errors);
 	MLX5_ASSIGN_PMA_CNTR(pma_cnt->link_overrun_errors,
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 8382426..e641bc3 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1452,7 +1452,9 @@ struct mlx5_ifc_ib_port_cntrs_grp_data_layout_bits {
 
 	u8         vl_15_dropped[0x10];
 
-	u8	   reserved_at_a0[0xa0];
+	u8	   reserved_at_a0[0x80];
+
+	u8         port_xmit_wait[0x20];
 };
 
 struct mlx5_ifc_eth_per_traffic_grp_data_layout_bits {
-- 
1.8.3.1

^ permalink raw reply related

* Re: [PATCH net-next 00/18] net: dsa: mv88e6xxx: 802.1s and 88E6390 VTU
From: Vivien Didelot @ 2017-05-01 16:36 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew
In-Reply-To: <20170501.122618.1787371573631638101.davem@davemloft.net>

Hi David,

David Miller <davem@davemloft.net> writes:

> Once I set the state to "changes requested", that's basically permanent.
>
> Please simply resubmit your patch series, ACKs added if necessary.

OK good to know, I respin this series in a few minutes.

Thanks,

        Vivien

^ permalink raw reply

* Re: [PATCH net-next 00/18] net: dsa: mv88e6xxx: 802.1s and 88E6390 VTU
From: Vivien Didelot @ 2017-05-01 17:16 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: David Miller, netdev, linux-kernel, kernel, f.fainelli
In-Reply-To: <20170501162552.GH1285@lunn.ch>

Andrew,

Andrew Lunn <andrew@lunn.ch> writes:

> I actually pointed out a typo in one of the change log message. And i
> requested some additional comments.

I can respin this patch series to correct the nitpicks on 8/18 but, what
I want most is a Tested-by tag. As you have this hardware, can you give
it a try?

Note that 17/18 is missing your Reviewed-by as agreed.

        Vivien

^ permalink raw reply

* Re: [PATCH v4 binutils] Add BPF support to binutils...
From: Aaron Conole @ 2017-05-01 17:22 UTC (permalink / raw)
  To: David Miller; +Cc: ast, daniel, netdev, xdp-newbies
In-Reply-To: <20170430.120750.651845251226226775.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 871 bytes --]

David Miller <davem@davemloft.net> writes:

> This is mainly a synchronization point, I still need to look
> more deeply into Alexei's -g issue.
>
> New in this version from v3:
>  - Remove tailcall from opcode table
>  - Rearrange relocations so that numbers match with LLVM ones
>  - Emit relocs properly so that dwarf2 debug info tests pass
>  - Handle negative load/store offsets properly, add tests
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---

Latest results from x86-64 and aarch64:

Both are little endian.  The only difference is for x86-64, I'm off of
commit 750eaa47f10f ("x86: Check plt_got before using .plt.got") and
for aarch64 I'm off of ee7e95efb981 ("merge_gnu_build_notes reloc
deletion").  I don't think that should matter.

I've also got a small incremental to fix some trailing whitespace, and
s/SPARC/BPF/ in one file, attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: incremental patch for git apply --]
[-- Type: text/x-patch, Size: 3060 bytes --]

diff --git a/bfd/elf64-bpf.c b/bfd/elf64-bpf.c
index a42f768..b04fdfb 100644
--- a/bfd/elf64-bpf.c
+++ b/bfd/elf64-bpf.c
@@ -39,7 +39,7 @@ _bfd_bpf_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     {
     case BFD_RELOC_NONE:
       return &_bfd_bpf_elf_howto_table[R_BPF_NONE];
-     
+
     case BFD_RELOC_BPF_WDISP16:
       return &_bfd_bpf_elf_howto_table[R_BPF_WDISP16];
 
diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c
index 36393b7..d78f06f 100644
--- a/gas/config/tc-bpf.c
+++ b/gas/config/tc-bpf.c
@@ -1,4 +1,4 @@
-/* tc-bpf.c -- Assemble for the SPARC
+/* tc-bpf.c -- Assemble for BPF
    Copyright (C) 2017 Free Software Foundation, Inc.
    This file is part of GAS, the GNU Assembler.
 
@@ -153,7 +153,7 @@ output_insn (struct bpf_it *theinsn)
   valueT opc = theinsn->opcode;
   char *toP = frag_more (theinsn->imm64 ? 16 : 8);
   char code, regs;
-  
+
   code = opc >> (64 - 8);
   regs = opc >> (64 - (8 + 8));
 
@@ -317,7 +317,7 @@ md_assemble (char *str ATTRIBUTE_UNUSED)
 		      if (c != '0' || mask != 1)
 			goto error;
 		      mask = 10;
-		    }			  
+		    }
 		  the_insn.opcode |= (mask << 52);
 		  continue;
 		}
@@ -337,7 +337,7 @@ md_assemble (char *str ATTRIBUTE_UNUSED)
 		      if (c != '0' || mask != 1)
 			goto error;
 		      mask = 10;
-		    }			  
+		    }
 		  the_insn.opcode |= (mask << 48);
 		  continue;
 		}
diff --git a/gas/testsuite/gas/bpf/bpf.exp b/gas/testsuite/gas/bpf/bpf.exp
index 363fd2c..5a8d54c 100644
--- a/gas/testsuite/gas/bpf/bpf.exp
+++ b/gas/testsuite/gas/bpf/bpf.exp
@@ -4,15 +4,15 @@
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 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.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
 # BPF assembler testsuite
 
diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c
index 6629f73..9cca3bc 100644
--- a/gdb/bpf-tdep.c
+++ b/gdb/bpf-tdep.c
@@ -192,7 +192,7 @@ bpf_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
-  
+
   tdep->xxx = 0;
 
   set_gdbarch_num_regs (gdbarch, BPF_NUM_REGS);
diff --git a/opcodes/bpf-dis.c b/opcodes/bpf-dis.c
index 39656bf..e15acc1 100644
--- a/opcodes/bpf-dis.c
+++ b/opcodes/bpf-dis.c
@@ -79,7 +79,7 @@ print_insn_bpf (bfd_vma memaddr, disassemble_info *info)
     {
       getword = bfd_getl32;
       gethalf = bfd_getl16;
-    }  
+    }
 
   code = buffer[0];
   dest = (buffer[1] & 0xf0) >> 4;
-- 
2.9.3


[-- Attachment #3: Type: text/plain, Size: 376 bytes --]


x86-64:
  Running /home/aconole/git/binutils-gdb/gas/testsuite/gas/bpf/bpf.exp ...
  FAIL: jump
  FAIL: call
  FAIL: imm64a
  Running /home/aconole/git/binutils-gdb/gas/testsuite/gas/cfi/cfi.exp ...

aarch64 (pine64 board):
  Running /root/aarch64/git/binutils-gdb/gas/testsuite/gas/bpf/bpf.exp ...
  Running /root/aarch64/git/binutils-gdb/gas/testsuite/gas/cfi/cfi.exp ...


^ permalink raw reply related

* Re: net/smc and the RDMA core
From: Bart Van Assche @ 2017-05-01 17:29 UTC (permalink / raw)
  To: hch@lst.de, davem@davemloft.net, ubraun@linux.vnet.ibm.com
  Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org
In-Reply-To: <20170501163311.GA22209@lst.de>

On Mon, 2017-05-01 at 18:33 +0200, Christoph Hellwig wrote:
> Hi Ursual, hi netdev reviewers,
> 
> how did the smc protocol manage to get merged without any review 
> on linux-rdma at all?  As the results it seems it's very substandard
> in terms of RDMA API usage, e.g. it neither uses the proper CQ API
> nor the RDMA R/W API, and other will probably find additional issues
> as well.

Hello Dave and Ursula,

It seems very rude to me to have merged the SMC protocol driver without
having involved the linux-rdma community. Anyway, I have the following
questions for Dave and Ursula:
* Since the Linux kernel is standards based: where can we find the standard
  that defines the SMC wire protocol? If this protocol has not been
  standardized yet: in what file (other than *.[ch]) in the Linux kernel
  tree has this protocol been documented?
* What are the differences between the SMC protocol, the SDP protocol and
  the rsockets protocol? How do existing implementations for these protocols
  compare to each other from a performance point of view? If no performance
  comparison between these protocols is available, shouldn't the performance
  of these protocols have been compared with each other before a review of
  the SMC driver even started?
* What are the reasons why the SDP driver was never accepted upstream? Do
  the arguments why SDP was not accepted upstream also apply to the SMC
  driver (SDP = Sockets Direct Protocol)?
* Since SMC has to be selected by specifying AF_SMC, how are users expected
  to specify whether AF_INET, AF_INET6 or yet another address family should
  be used to set up a connection between SMC
endpoints?
* Is the SMC driver limited to RoCE? Are you aware that the rsockets library
  supports multiple transport layers (RoCE, IB and iWARP)?
* Since functionality that is similar what the SMC driver provides already
  exists in user space (rsockets), why has this functionality been
  reimplemented as a kernel driver (SMC)?

Bart.

^ permalink raw reply

* [ANNOUNCE] iproute2 4.11
From: Stephen Hemminger @ 2017-05-01 17:32 UTC (permalink / raw)
  To: netdev, linux-kernel

Update to iproute2 utility to support new features in Linux 4.11.
Most of the changes are related to recent work for hardware offload
and flow classification in tc.

Also the usual array of small manual and documentaton updates.

Source:
  https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.11.0.tar.gz

Repository:
  git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git

Report problems (or enhancements) to the netdev@vger.kernel.org mailing list.

---
Alexander Alemayhu (2):
      man: add examples to ip.8
      man: fix man page warnings

Amir Vadai (7):
      tc/pedit: Fix a typo in pedit usage message
      tc/pedit: Extend pedit to specify offset relative to mac/transport headers
      tc/pedit: Introduce 'add' operation
      tc/pedit: p_ip: introduce editing ttl header
      tc/pedit: Support fields bigger than 32 bits
      tc/pedit: p_eth: ETH header editor
      tc/pedit: p_tcp: introduce pedit tcp support

Craig Gallek (1):
      gre6: fix copy/paste bugs in GREv6 attribute manipulation

Daniel Borkmann (2):
      {f,m}_bpf: dump tag over insns
      bpf: test for valid type in bpf_get_work_dir

David Ahern (3):
      ip: Add support for MPLS netconf
      ip route: Add missing space between nexthop and via for mpls multipath routes
      ip vrf: Add command name next to pid

Davide Caratti (1):
      tc: m_csum: add support for SCTP checksum

Hangbin Liu (7):
      iplink: bridge: add support for IFLA_BR_FDB_FLUSH
      iplink: bridge: add support for IFLA_BR_VLAN_STATS_ENABLED
      iplink: bridge: add support for IFLA_BR_MCAST_STATS_ENABLED
      iplink: bridge: add support for IFLA_BR_MCAST_IGMP_VERSION
      iplink: bridge: add support for IFLA_BR_MCAST_MLD_VERSION
      iplink: bridge_slave: add support for IFLA_BRPORT_FLUSH
      man: ip-link.8: Document bridge_slave fdb_flush option

Jamal Hadi Salim (1):
      actions: Add support for user cookies

Jiri Kosina (1):
      iproute2: tc: introduce build dependency on libnetlink

Jiri Pirko (1):
      devlink: use DEVLINK_CMD_ESWITCH_* instead of DEVLINK_CMD_ESWITCH_MODE_*

Michal Kubeček (1):
      routel: fix infinite loop in line parser

Nikolay Aleksandrov (4):
      ipmroute: add support for RTNH_F_UNRESOLVED
      iplink: add support for xstats subcommand
      iplink: bridge: add support for displaying xstats
      iplink: bridge_slave: add support for displaying xstats

Or Gerlitz (1):
      tc/pedit: p_udp: introduce pedit udp support

Paul Blakey (2):
      tc: flower: support matching flags
      tc: flower: Refactor matching flags to be more user friendly

Petr Vorel (1):
      color: use "light" colors for dark background

Phil Sutter (7):
      man: ss.8: Add missing protocols to description of -A
      ip: link: bond: Fix whitespace in help text
      ip: link: macvlan: Add newline to help output
      ip: link: Unify link type help functions a bit
      ip: link: Add missing link type help texts
      man: ip-link: Specify min/max values for bridge slave priority and cost
      man: ip-rule.8: Further clarify how to interpret priority value

Robert Shearman (2):
      iplink: add support for afstats subcommand
      man: Fix formatting of vrf parameter of ip-link show command

Roi Dayan (2):
      tc: flower: Fix parsing ip address
      devlink: Add json and pretty options to help and man

Roman Mashak (1):
      tc: print skbedit action when dumping actions.

Sabrina Dubroca (1):
      man: ip-link.8: document bridge options

Simon Horman (9):
      tc: flower: document that *_ip parameters take a PREFIX as an argument.
      tc: flower: Allow *_mac options to accept a mask
      tc: flower: Update dest UDP port documentation
      tc: flower: Support matching ARP
      tc: flower: use correct type when calling flower_icmp_attr_type
      tc: flower: Update documentation to indicate ARP takes IPv4 prefixes
      tc: flower: provide generic masked u8 parser helper
      tc: flower: provide generic masked u8 print helper
      tc: flower: support masked ICMP code and type match

Stephen Hemminger (24):
      minor kernel header update
      kernel headers update
      add more uapi header files
      include: remove unused header
      update kernel headers from 4.10 net-next
      update kernel headers from net-next
      tcp: header file update
      update headers from bridge tunnel metadata
      tc: add missing sample file
      update headers from net-next
      add missing iplink_xstats.c
      update headers from net-next
      Update headers based on 4.11 merge window
      netlink route attribute cleanup
      xfrm: remove unnecessary casts
      tc: use rta_getattr_u32
      bpf: remove unnecessary cast
      pie: remove always false condition
      update headers from 4.11-rc2
      update headers from 4.11-rc3
      netem: fix out of bounds access in maketable
      iplink: whitespace cleanup
      pedit: fix whitespace
      v4.11.0

Timothy Redaelli (1):
      ip-route: Prevent some other double spaces in output

Vincent Bernat (1):
      vxlan: use preferred address family when neither group or remote is specified

Yotam Gigi (8):
      tc: Add support for the sample tc action
      tc: man: Add man entry for the tc-sample action
      tc: man: matchall: Update examples to include sample
      tc: bash-completion: Add the _from variant to _tc_one* funcs
      tc: bash-completion: Prepare action autocomplete to support several actions
      tc: bash-completion: Make the *_KIND variables global
      tc: bash-completion: Add support for filter actions
      tc: bash-completion: Add support for matchall

Zhang Shengju (1):
      iplink: add support for IFLA_CARRIER attribute

^ permalink raw reply

* Re: [PATCH iproute2 net-next v2] bpf: add support for generic xdp
From: Daniel Borkmann @ 2017-05-01 17:33 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: alexei.starovoitov, davem, netdev, quentin.monnet
In-Reply-To: <20170501092915.5c19395c@xeon-e3>

[ +Quentin ]

On 05/01/2017 06:29 PM, Stephen Hemminger wrote:
> On Fri, 28 Apr 2017 15:44:29 +0200
> Daniel Borkmann <daniel@iogearbox.net> wrote:
>
>> Follow-up to commit c7272ca72009 ("bpf: add initial support for
>> attaching xdp progs") to also support generic XDP. This adds an
>> indicator for loaded generic XDP programs when programs are loaded
>> as shown in c7272ca72009, but the driver still lacks native XDP
>> support.
>>
>>    # ip link
>>    [...]
>>    3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc [...]
>>        link/ether 0c:c4:7a:03:f9:25 brd ff:ff:ff:ff:ff:ff
>>    [...]
>>
>> In case the driver does support native XDP, but the user wants
>> to load the program as generic XDP (e.g. for testing purposes),
>> then this can be done with the same semantics as in c7272ca72009,
>> but with 'xdpgeneric' instead of 'xdp' command for loading:
>>
>>    # ip -force link set dev eno1 xdpgeneric obj xdp.o
>>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>
> Applied, thanks for remembering to update man page.

No problem, thanks!

> Does bash-completion need update?

Yeah, so far there's only a bash completion for the tc tool
in the tree, but nothing else. Is there anything in the works
for covering other tools, Quentin?

Thanks again,
Daniel

^ permalink raw reply

* Re: [PATCH v4 binutils] Add BPF support to binutils...
From: David Miller @ 2017-05-01 17:42 UTC (permalink / raw)
  To: aconole; +Cc: ast, daniel, netdev, xdp-newbies
In-Reply-To: <f7ttw541ohz.fsf@redhat.com>

From: Aaron Conole <aconole@bytheb.org>
Date: Mon, 01 May 2017 13:22:00 -0400

> Latest results from x86-64 and aarch64:

I'll see if I can reproduce here...

> I've also got a small incremental to fix some trailing whitespace, and
> s/SPARC/BPF/ in one file, attached.

Applied, thanks!

^ permalink raw reply

* Re: [PATCH] switchdev: documentation: fix whitespace issues
From: Ivan Vecera @ 2017-05-01 17:50 UTC (permalink / raw)
  To: Sylvain Lemieux, jiri; +Cc: netdev
In-Reply-To: <20170501150201.18959-1-slemieux.tyco@gmail.com>

On 1.5.2017 17:02, Sylvain Lemieux wrote:
> From: Liam Beguin <lbeguin@tycoint.com>
> 
> Figure 1 is full of whitespaces; fix it
> 
> Signed-off-by: Liam Beguin <lbeguin@tycoint.com>
> Signed-off-by: Sylvain Lemieux <slemieux@tycoint.com>
> ---
>  Documentation/networking/switchdev.txt | 70 +++++++++++++++++-----------------
>  1 file changed, 35 insertions(+), 35 deletions(-)
> 
> diff --git a/Documentation/networking/switchdev.txt b/Documentation/networking/switchdev.txt
> index 2bbac05ab9e2..3e7b946dea27 100644
> --- a/Documentation/networking/switchdev.txt
> +++ b/Documentation/networking/switchdev.txt
> @@ -13,43 +13,43 @@ an example setup using a data-center-class switch ASIC chip.  Other setups
>  with SR-IOV or soft switches, such as OVS, are possible.
>  
>  
> -                             User-space tools                                 
> -                                                                              
> -       user space                   |                                         
> -      +-------------------------------------------------------------------+   
> -       kernel                       | Netlink                                 
> -                                    |                                         
> -                     +--------------+-------------------------------+         
> -                     |         Network stack                        |         
> -                     |           (Linux)                            |         
> -                     |                                              |         
> -                     +----------------------------------------------+         
> -                                                                              
> +                             User-space tools
> +
> +       user space                   |
> +      +-------------------------------------------------------------------+
> +       kernel                       | Netlink
> +                                    |
> +                     +--------------+-------------------------------+
> +                     |         Network stack                        |
> +                     |           (Linux)                            |
> +                     |                                              |
> +                     +----------------------------------------------+
> +
>                             sw1p2     sw1p4     sw1p6
> -                      sw1p1  +  sw1p3  +  sw1p5  +          eth1             
> -                        +    |    +    |    +    |            +               
> -                        |    |    |    |    |    |            |               
> -                     +--+----+----+----+-+--+----+---+  +-----+-----+         
> -                     |         Switch driver         |  |    mgmt   |         
> -                     |        (this document)        |  |   driver  |         
> -                     |                               |  |           |         
> -                     +--------------+----------------+  +-----------+         
> -                                    |                                         
> -       kernel                       | HW bus (eg PCI)                         
> -      +-------------------------------------------------------------------+   
> -       hardware                     |                                         
> -                     +--------------+---+------------+                        
> -                     |         Switch device (sw1)   |                        
> -                     |  +----+                       +--------+               
> -                     |  |    v offloaded data path   | mgmt port              
> -                     |  |    |                       |                        
> -                     +--|----|----+----+----+----+---+                        
> -                        |    |    |    |    |    |                            
> -                        +    +    +    +    +    +                            
> +                      sw1p1  +  sw1p3  +  sw1p5  +          eth1
> +                        +    |    +    |    +    |            +
> +                        |    |    |    |    |    |            |
> +                     +--+----+----+----+-+--+----+---+  +-----+-----+
> +                     |         Switch driver         |  |    mgmt   |
> +                     |        (this document)        |  |   driver  |
> +                     |                               |  |           |
> +                     +--------------+----------------+  +-----------+
> +                                    |
> +       kernel                       | HW bus (eg PCI)
> +      +-------------------------------------------------------------------+
> +       hardware                     |
> +                     +--------------+---+------------+
> +                     |         Switch device (sw1)   |
> +                     |  +----+                       +--------+
> +                     |  |    v offloaded data path   | mgmt port
> +                     |  |    |                       |
> +                     +--|----|----+----+----+----+---+
> +                        |    |    |    |    |    |
> +                        +    +    +    +    +    +
>                         p1   p2   p3   p4   p5   p6
> -                                       
> -                             front-panel ports                                
> -                                                                              
> +
> +                             front-panel ports
> +
>  
>                                      Fig 1.
>  
> 

Acked-by: Ivan Vecera <ivecera@redhat.com>

^ permalink raw reply

* Re: [PATCH v4 binutils] Add BPF support to binutils...
From: David Miller @ 2017-05-01 17:52 UTC (permalink / raw)
  To: aconole; +Cc: ast, daniel, netdev, xdp-newbies
In-Reply-To: <f7ttw541ohz.fsf@redhat.com>

From: Aaron Conole <aconole@bytheb.org>
Date: Mon, 01 May 2017 13:22:00 -0400

> x86-64:
>   Running /home/aconole/git/binutils-gdb/gas/testsuite/gas/bpf/bpf.exp ...
>   FAIL: jump
>   FAIL: call
>   FAIL: imm64a
>   Running /home/aconole/git/binutils-gdb/gas/testsuite/gas/cfi/cfi.exp ...

I cannot reproduce this, can you show what it says in the:

	/home/aconole/git/binutils-gdb/gas/testsuite/gas.log

file near the "FAIL" cases?

^ permalink raw reply

* Re: [PATCH] switchdev: documentation: fix whitespace issues
From: David Miller @ 2017-05-01 17:53 UTC (permalink / raw)
  To: slemieux.tyco; +Cc: jiri, ivecera, netdev
In-Reply-To: <20170501150201.18959-1-slemieux.tyco@gmail.com>

From: Sylvain Lemieux <slemieux.tyco@gmail.com>
Date: Mon,  1 May 2017 11:02:01 -0400

> From: Liam Beguin <lbeguin@tycoint.com>
> 
> Figure 1 is full of whitespaces; fix it
> 
> Signed-off-by: Liam Beguin <lbeguin@tycoint.com>
> Signed-off-by: Sylvain Lemieux <slemieux@tycoint.com>

Applied.

^ permalink raw reply

* RE: net/smc and the RDMA core
From: Parav Pandit @ 2017-05-01 17:55 UTC (permalink / raw)
  To: Bart Van Assche, hch-jcswGhMUV9g@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	ubraun-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <1493659776.2665.7.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>

Hi Bart, Ursula, Dave,

I am particularly concerned about SMC as address family.
It should not be treated as address family, but rather an additional protocol similar for socket type SOCK_STREAM.
While doing performance benchmarking last month and while porting few database application,

I encountered a major hurdle where user space library heavily depend on AF_INET and AF_INET6 family through get_addrinfo and other friend functions.
Adding or treating AF_SMC as AF_INET just doesn't sound right.

Most user space code doesn't care for the protocol field, but do handle domain field.

I personally believe it's not too late to modify SMC to drop expose AF_SMC and have it exposed through new protocol that can be exposed through socket() API.

Parav

> -----Original Message-----
> From: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-rdma-
> owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org] On Behalf Of Bart Van Assche
> Sent: Monday, May 1, 2017 12:30 PM
> To: hch-jcswGhMUV9g@public.gmane.org; davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org; ubraun-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Subject: Re: net/smc and the RDMA core
> 
> On Mon, 2017-05-01 at 18:33 +0200, Christoph Hellwig wrote:
> > Hi Ursual, hi netdev reviewers,
> >
> > how did the smc protocol manage to get merged without any review on
> > linux-rdma at all?  As the results it seems it's very substandard in
> > terms of RDMA API usage, e.g. it neither uses the proper CQ API nor
> > the RDMA R/W API, and other will probably find additional issues as
> > well.
> 
> Hello Dave and Ursula,
> 
> It seems very rude to me to have merged the SMC protocol driver without
> having involved the linux-rdma community. Anyway, I have the following
> questions for Dave and Ursula:
> * Since the Linux kernel is standards based: where can we find the standard
>   that defines the SMC wire protocol? If this protocol has not been
>   standardized yet: in what file (other than *.[ch]) in the Linux kernel
>   tree has this protocol been documented?
> * What are the differences between the SMC protocol, the SDP protocol and
>   the rsockets protocol? How do existing implementations for these protocols
>   compare to each other from a performance point of view? If no performance
>   comparison between these protocols is available, shouldn't the performance
>   of these protocols have been compared with each other before a review of
>   the SMC driver even started?
> * What are the reasons why the SDP driver was never accepted upstream? Do
>   the arguments why SDP was not accepted upstream also apply to the SMC
>   driver (SDP = Sockets Direct Protocol)?
> * Since SMC has to be selected by specifying AF_SMC, how are users expected
>   to specify whether AF_INET, AF_INET6 or yet another address family should
>   be used to set up a connection between SMC endpoints?
> * Is the SMC driver limited to RoCE? Are you aware that the rsockets library
>   supports multiple transport layers (RoCE, IB and iWARP)?
> * Since functionality that is similar what the SMC driver provides already
>   exists in user space (rsockets), why has this functionality been
>   reimplemented as a kernel driver (SMC)?
> 
> Bart.--
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body
> of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH net-next v2 00/18] net: dsa: mv88e6xxx: 802.1s and 88E6390 VTU
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot

This patch series adds support for the VLAN Table Unit (a.k.a. the VTU)
to the 88E6390 family of Marvell Ethernet switch chips. The plumbing for
the per VLAN Spanning Tree support is added as a side effect of the
necessary refactoring.

The patchset is split up so that no duplication of code is introduced.
With this patchset applied, the mv88e6xxx driver has 2 new function
pointers for the VTU GetNext and VTU Load/Purge operations (with 3
implementations), both handling programmation of 802.1q and 802.1s.

On a ZII Rev C board (featuring 2 88E6390X chips) with all ports bridged
together, we obtain the following hardware VLAN configuration:

    # cat /sys/class/net/br0/bridge/vlan_filtering 
    1
    # cat /sys/class/net/br0/bridge/default_pvid
    42
    # bridge vlan add dev lan3 vid 666
    # bridge vlan show
    port    vlan ids
    lan1     42 PVID Egress Untagged

    lan1     42 PVID Egress Untagged

    lan2     42 PVID Egress Untagged

    lan2     42 PVID Egress Untagged

    lan3     42 PVID Egress Untagged
             666

    lan3     42 PVID Egress Untagged
             666

    lan4     42 PVID Egress Untagged

    lan4     42 PVID Egress Untagged

    lan5     42 PVID Egress Untagged

    lan5     42 PVID Egress Untagged

    lan6     42 PVID Egress Untagged

    lan6     42 PVID Egress Untagged

    lan7     42 PVID Egress Untagged

    lan7     42 PVID Egress Untagged

    lan8     42 PVID Egress Untagged

    lan8     42 PVID Egress Untagged

    br0      42 PVID Egress Untagged

Below are the technical details for the different implementations.

All switch families have up to 3 dedicated VTU Data registers used to
program 802.1q and 802.1s, both using 2-bit values.

On 88E6185 and 88E6352 families, port membership and state are adjacent,
while the 88E6390 family share the same bits:

    Bits        88E6185/88E6352         88E6390
    -----       -----------------       --------------------------
    0-1         Port 0 membership       Port 0 membership or state
    2-3         Port 0 state            Port 1 membership or state
    4-5         Port 1 membership       Port 2 membership or state
    6-7         Port 1 state            Port 3 membership or state
    8-9         Port 2 membership       Port 4 membership or state
    10-11       Port 2 state            Port 5 membership or state
    ...         ...                     ...

The 88E6185 family programs all ports membership and state in a single
VTU GetNext or Load/Purge operation.

The 88E6352 family introduced an indirect Spanning Tree Unit table
(a.k.a. STU) which requires additional STU GetNext and Load/Purge
operations to read and write the ports state bits.

The 88E6390 family also has an STU and requires data bits to be accessed
before and after every single VTU or STU operation.

Finally, the 88E6390 family introduced a 13th bit for the VLAN ID, which
must be taken care of regardless the VTU operating mode. This means that
iterating over the VTU now starts or ends with value 8191, not 4095.

Patch 1 adds a max_vid field to the chip info structure.
Patch 2 adds 802.1q and 802.1s data to the generic VTU entry structure.
Patches 3 to 10 move helpers to a dedicated file (later made static).
Patches 11 and 12 abstract handling of the STU behind VTU operations.
Patches 13 and 14 add the new function pointers for VTU operations.
Patches 15 and 18 polish the VTU code and add VTU support for 88E6390.

Changes in v2:
  - add Reviewed-by tags
  - fix comments in 8/18

Vivien Didelot (18):
  net: dsa: mv88e6xxx: add max VID to info
  net: dsa: mv88e6xxx: split VTU entry data member
  net: dsa: mv88e6xxx: move VTU Operation accessors
  net: dsa: mv88e6xxx: move VTU flush
  net: dsa: mv88e6xxx: move VTU FID accessors
  net: dsa: mv88e6xxx: move VTU SID accessors
  net: dsa: mv88e6xxx: move VTU VID accessors
  net: dsa: mv88e6xxx: move generic VTU GetNext
  net: dsa: mv88e6xxx: move VTU Data accessors
  net: dsa: mv88e6xxx: move STU GetNext operation
  net: dsa: mv88e6xxx: get STU entry on VTU GetNext
  net: dsa: mv88e6xxx: load STU entry with VTU entry
  net: dsa: mv88e6xxx: add VTU GetNext operation
  net: dsa: mv88e6xxx: add VTU Load/Purge operation
  net: dsa: mv88e6xxx: make VTU helpers static
  net: dsa: mv88e6xxx: simplify VTU entry getter
  net: dsa: mv88e6xxx: support the VTU Page bit
  net: dsa: mv88e6xxx: add VTU support for 88E6390

 drivers/net/dsa/mv88e6xxx/Makefile      |   1 +
 drivers/net/dsa/mv88e6xxx/chip.c        | 568 +++++++++-----------------------
 drivers/net/dsa/mv88e6xxx/global1.h     |  14 +
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 511 ++++++++++++++++++++++++++++
 drivers/net/dsa/mv88e6xxx/mv88e6xxx.h   |  31 +-
 5 files changed, 690 insertions(+), 435 deletions(-)
 create mode 100644 drivers/net/dsa/mv88e6xxx/global1_vtu.c

-- 
2.12.2

^ permalink raw reply

* [PATCH net-next v2 02/18] net: dsa: mv88e6xxx: split VTU entry data member
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

VLAN aware Marvell chips can program 802.1Q VLAN membership as well as
802.1s per VLAN Spanning Tree state using the same 3 VTU Data registers.

Some chips such as 88E6185 use different Data registers offsets for
ports state and membership, and program them in a single operation.

Other chips such as 88E6352 use the same register layout but program
them in distinct operations (an indirect table is used for 802.1s.)

Newer chips such as 88E6390 use the same offsets for both state and
membership in distinct operations, thus require multiple data accesses.

To correctly abstract this, split the "data" structure member of
mv88e6xxx_vtu_entry in two "state" and "member" members, before adding
VTU support for newer chips.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c      | 21 +++++++++++----------
 drivers/net/dsa/mv88e6xxx/mv88e6xxx.h |  3 ++-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index e45ddf3e90e8..f025d3c22dba 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1312,7 +1312,7 @@ static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_chip *chip,
 		unsigned int shift = (i % 4) * 4 + nibble_offset;
 		u16 reg = regs[i / 4];
 
-		entry->data[i] = (reg >> shift) & GLOBAL_VTU_STU_DATA_MASK;
+		entry->state[i] = (reg >> shift) & GLOBAL_VTU_STU_DATA_MASK;
 	}
 
 	return 0;
@@ -1339,7 +1339,7 @@ static int _mv88e6xxx_vtu_stu_data_write(struct mv88e6xxx_chip *chip,
 
 	for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
 		unsigned int shift = (i % 4) * 4 + nibble_offset;
-		u8 data = entry->data[i];
+		u8 data = entry->state[i];
 
 		regs[i / 4] |= (data & GLOBAL_VTU_STU_DATA_MASK) << shift;
 	}
@@ -1461,7 +1461,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
 		if (!next.valid)
 			break;
 
-		if (next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
+		if (next.member[port] == GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
 			continue;
 
 		/* reinit and dump this VLAN obj */
@@ -1469,7 +1469,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
 		vlan->vid_end = next.vid;
 		vlan->flags = 0;
 
-		if (next.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED)
+		if (next.member[port] == GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED)
 			vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
 
 		if (next.vid == pvid)
@@ -1669,7 +1669,8 @@ static int _mv88e6xxx_vtu_new(struct mv88e6xxx_chip *chip, u16 vid,
 
 	/* exclude all ports except the CPU and DSA ports */
 	for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
-		vlan.data[i] = dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i)
+		vlan.member[i] = dsa_is_cpu_port(ds, i) ||
+			dsa_is_dsa_port(ds, i)
 			? GLOBAL_VTU_DATA_MEMBER_TAG_UNMODIFIED
 			: GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
 
@@ -1765,7 +1766,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 			if (!ds->ports[port].netdev)
 				continue;
 
-			if (vlan.data[i] ==
+			if (vlan.member[i] ==
 			    GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
 				continue;
 
@@ -1844,7 +1845,7 @@ static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
 	if (err)
 		return err;
 
-	vlan.data[port] = untagged ?
+	vlan.member[port] = untagged ?
 		GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED :
 		GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED;
 
@@ -1890,10 +1891,10 @@ static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
 		return err;
 
 	/* Tell switchdev if this VLAN is handled in software */
-	if (vlan.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
+	if (vlan.member[port] == GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
 		return -EOPNOTSUPP;
 
-	vlan.data[port] = GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
+	vlan.member[port] = GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
 
 	/* keep the VLAN unless all ports are excluded */
 	vlan.valid = false;
@@ -1901,7 +1902,7 @@ static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
 		if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i))
 			continue;
 
-		if (vlan.data[i] != GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
+		if (vlan.member[i] != GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
 			vlan.valid = true;
 			break;
 		}
diff --git a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
index 5695ca206620..8638892a7e18 100644
--- a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
@@ -704,7 +704,8 @@ struct mv88e6xxx_vtu_entry {
 	u16	fid;
 	u8	sid;
 	bool	valid;
-	u8	data[DSA_MAX_PORTS];
+	u8	member[DSA_MAX_PORTS];
+	u8	state[DSA_MAX_PORTS];
 };
 
 struct mv88e6xxx_bus_ops;
-- 
2.12.2

^ permalink raw reply related

* [PATCH net-next v2 03/18] net: dsa: mv88e6xxx: move VTU Operation accessors
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

Move the helper functions to access the Global 1 VTU Operation register
to a new global1_vtu.c file, and get rid of the old underscore prefix
naming convention. This file will be extended will all VTU/STU related
code.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/Makefile      |  1 +
 drivers/net/dsa/mv88e6xxx/chip.c        | 39 +++++++++------------------------
 drivers/net/dsa/mv88e6xxx/global1.h     |  3 +++
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 33 ++++++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 29 deletions(-)
 create mode 100644 drivers/net/dsa/mv88e6xxx/global1_vtu.c

diff --git a/drivers/net/dsa/mv88e6xxx/Makefile b/drivers/net/dsa/mv88e6xxx/Makefile
index 31d37a90cec7..6edd869c8d6f 100644
--- a/drivers/net/dsa/mv88e6xxx/Makefile
+++ b/drivers/net/dsa/mv88e6xxx/Makefile
@@ -2,5 +2,6 @@ obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
 mv88e6xxx-objs := chip.o
 mv88e6xxx-objs += global1.o
 mv88e6xxx-objs += global1_atu.o
+mv88e6xxx-objs += global1_vtu.o
 mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_GLOBAL2) += global2.o
 mv88e6xxx-objs += port.o
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index f025d3c22dba..bf0350432337 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2008 Marvell Semiconductor
  *
- * Copyright (c) 2015 CMC Electronics, Inc.
- *	Added support for VLAN Table Unit operations
- *
  * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
  *
  * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
@@ -1266,31 +1263,15 @@ static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
 		netdev_err(ds->ports[port].netdev, "failed to flush ATU\n");
 }
 
-static int _mv88e6xxx_vtu_wait(struct mv88e6xxx_chip *chip)
-{
-	return mv88e6xxx_g1_wait(chip, GLOBAL_VTU_OP, GLOBAL_VTU_OP_BUSY);
-}
-
-static int _mv88e6xxx_vtu_cmd(struct mv88e6xxx_chip *chip, u16 op)
-{
-	int err;
-
-	err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_OP, op);
-	if (err)
-		return err;
-
-	return _mv88e6xxx_vtu_wait(chip);
-}
-
 static int _mv88e6xxx_vtu_stu_flush(struct mv88e6xxx_chip *chip)
 {
 	int ret;
 
-	ret = _mv88e6xxx_vtu_wait(chip);
+	ret = mv88e6xxx_g1_vtu_op_wait(chip);
 	if (ret < 0)
 		return ret;
 
-	return _mv88e6xxx_vtu_cmd(chip, GLOBAL_VTU_OP_FLUSH_ALL);
+	return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
 }
 
 static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_chip *chip,
@@ -1380,11 +1361,11 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
 	u16 val;
 	int err;
 
-	err = _mv88e6xxx_vtu_wait(chip);
+	err = mv88e6xxx_g1_vtu_op_wait(chip);
 	if (err)
 		return err;
 
-	err = _mv88e6xxx_vtu_cmd(chip, GLOBAL_VTU_OP_VTU_GET_NEXT);
+	err = mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_VTU_GET_NEXT);
 	if (err)
 		return err;
 
@@ -1493,7 +1474,7 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 	u16 reg = 0;
 	int err;
 
-	err = _mv88e6xxx_vtu_wait(chip);
+	err = mv88e6xxx_g1_vtu_op_wait(chip);
 	if (err)
 		return err;
 
@@ -1532,7 +1513,7 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 	if (err)
 		return err;
 
-	return _mv88e6xxx_vtu_cmd(chip, op);
+	return mv88e6xxx_g1_vtu_op(chip, op);
 }
 
 static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
@@ -1542,7 +1523,7 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
 	u16 val;
 	int err;
 
-	err = _mv88e6xxx_vtu_wait(chip);
+	err = mv88e6xxx_g1_vtu_op_wait(chip);
 	if (err)
 		return err;
 
@@ -1551,7 +1532,7 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
 	if (err)
 		return err;
 
-	err = _mv88e6xxx_vtu_cmd(chip, GLOBAL_VTU_OP_STU_GET_NEXT);
+	err = mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_STU_GET_NEXT);
 	if (err)
 		return err;
 
@@ -1583,7 +1564,7 @@ static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
 	u16 reg = 0;
 	int err;
 
-	err = _mv88e6xxx_vtu_wait(chip);
+	err = mv88e6xxx_g1_vtu_op_wait(chip);
 	if (err)
 		return err;
 
@@ -1606,7 +1587,7 @@ static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
 	if (err)
 		return err;
 
-	return _mv88e6xxx_vtu_cmd(chip, GLOBAL_VTU_OP_STU_LOAD_PURGE);
+	return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_STU_LOAD_PURGE);
 }
 
 static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index e30cbe480d5b..c153d07d2065 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -50,4 +50,7 @@ int mv88e6xxx_g1_atu_flush(struct mv88e6xxx_chip *chip, u16 fid, bool all);
 int mv88e6xxx_g1_atu_remove(struct mv88e6xxx_chip *chip, u16 fid, int port,
 			    bool all);
 
+int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
+int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
+
 #endif /* _MV88E6XXX_GLOBAL1_H */
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
new file mode 100644
index 000000000000..20dfdcbda238
--- /dev/null
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -0,0 +1,33 @@
+/*
+ * Marvell 88E6xxx VLAN [Spanning Tree] Translation Unit (VTU [STU]) support
+ *
+ * Copyright (c) 2008 Marvell Semiconductor
+ * Copyright (c) 2015 CMC Electronics, Inc.
+ * Copyright (c) 2017 Savoir-faire Linux, Inc.
+ *
+ * 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.
+ */
+
+#include "mv88e6xxx.h"
+#include "global1.h"
+
+/* Offset 0x05: VTU Operation Register */
+
+int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip)
+{
+	return mv88e6xxx_g1_wait(chip, GLOBAL_VTU_OP, GLOBAL_VTU_OP_BUSY);
+}
+
+int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op)
+{
+	int err;
+
+	err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_OP, op);
+	if (err)
+		return err;
+
+	return mv88e6xxx_g1_vtu_op_wait(chip);
+}
-- 
2.12.2

^ permalink raw reply related

* [PATCH net-next v2 04/18] net: dsa: mv88e6xxx: move VTU flush
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

Move the VTU flush operation to global1_vtu.c and call it from a
mv88e6xxx_vtu_setup helper, similarly to the ATU and PVT setup.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c        | 28 ++++++++++++----------------
 drivers/net/dsa/mv88e6xxx/global1.h     |  1 +
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 13 +++++++++++++
 3 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index bf0350432337..d244c2283138 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1263,17 +1263,6 @@ static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
 		netdev_err(ds->ports[port].netdev, "failed to flush ATU\n");
 }
 
-static int _mv88e6xxx_vtu_stu_flush(struct mv88e6xxx_chip *chip)
-{
-	int ret;
-
-	ret = mv88e6xxx_g1_vtu_op_wait(chip);
-	if (ret < 0)
-		return ret;
-
-	return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
-}
-
 static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_chip *chip,
 					struct mv88e6xxx_vtu_entry *entry,
 					unsigned int nibble_offset)
@@ -1412,6 +1401,14 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
 	return 0;
 }
 
+static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
+{
+	if (!chip->info->max_vid)
+		return 0;
+
+	return mv88e6xxx_g1_vtu_flush(chip);
+}
+
 static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
 				    struct switchdev_obj_port_vlan *vlan,
 				    int (*cb)(struct switchdev_obj *obj))
@@ -2599,11 +2596,6 @@ static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
 	if (err)
 		return err;
 
-	/* Clear all the VTU and STU entries */
-	err = _mv88e6xxx_vtu_stu_flush(chip);
-	if (err < 0)
-		return err;
-
 	/* Configure the IP ToS mapping registers. */
 	err = mv88e6xxx_g1_write(chip, GLOBAL_IP_PRI_0, 0x0000);
 	if (err)
@@ -2684,6 +2676,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
 			goto unlock;
 	}
 
+	err = mv88e6xxx_vtu_setup(chip);
+	if (err)
+		goto unlock;
+
 	err = mv88e6xxx_pvt_setup(chip);
 	if (err)
 		goto unlock;
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index c153d07d2065..ed40e5557bbc 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -52,5 +52,6 @@ int mv88e6xxx_g1_atu_remove(struct mv88e6xxx_chip *chip, u16 fid, int port,
 
 int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
+int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
 
 #endif /* _MV88E6XXX_GLOBAL1_H */
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 20dfdcbda238..c41ca28da084 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -31,3 +31,16 @@ int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op)
 
 	return mv88e6xxx_g1_vtu_op_wait(chip);
 }
+
+/* VLAN Translation Unit Operations */
+
+int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip)
+{
+	int err;
+
+	err = mv88e6xxx_g1_vtu_op_wait(chip);
+	if (err)
+		return err;
+
+	return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
+}
-- 
2.12.2

^ permalink raw reply related

* [PATCH net-next v2 05/18] net: dsa: mv88e6xxx: move VTU FID accessors
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

Add helpers to access the VTU FID register in the global1_vtu.c file.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c        |  7 ++-----
 drivers/net/dsa/mv88e6xxx/global1.h     |  4 ++++
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 25 +++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index d244c2283138..0452543a2463 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1371,11 +1371,9 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
 			return err;
 
 		if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_G1_VTU_FID)) {
-			err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_FID, &val);
+			err = mv88e6xxx_g1_vtu_fid_read(chip, &next);
 			if (err)
 				return err;
-
-			next.fid = val & GLOBAL_VTU_FID_MASK;
 		} else if (mv88e6xxx_num_databases(chip) == 256) {
 			/* VTU DBNum[7:4] are located in VTU Operation 11:8, and
 			 * VTU DBNum[3:0] are located in VTU Operation 3:0
@@ -1491,8 +1489,7 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 	}
 
 	if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_G1_VTU_FID)) {
-		reg = entry->fid & GLOBAL_VTU_FID_MASK;
-		err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_FID, reg);
+		err = mv88e6xxx_g1_vtu_fid_write(chip, entry);
 		if (err)
 			return err;
 	} else if (mv88e6xxx_num_databases(chip) == 256) {
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index ed40e5557bbc..353de283362f 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -50,6 +50,10 @@ int mv88e6xxx_g1_atu_flush(struct mv88e6xxx_chip *chip, u16 fid, bool all);
 int mv88e6xxx_g1_atu_remove(struct mv88e6xxx_chip *chip, u16 fid, int port,
 			    bool all);
 
+int mv88e6xxx_g1_vtu_fid_read(struct mv88e6xxx_chip *chip,
+			      struct mv88e6xxx_vtu_entry *entry);
+int mv88e6xxx_g1_vtu_fid_write(struct mv88e6xxx_chip *chip,
+			       struct mv88e6xxx_vtu_entry *entry);
 int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
 int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index c41ca28da084..81d6f9f3c84a 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -14,6 +14,31 @@
 #include "mv88e6xxx.h"
 #include "global1.h"
 
+/* Offset 0x02: VTU FID Register */
+
+int mv88e6xxx_g1_vtu_fid_read(struct mv88e6xxx_chip *chip,
+			      struct mv88e6xxx_vtu_entry *entry)
+{
+	u16 val;
+	int err;
+
+	err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_FID, &val);
+	if (err)
+		return err;
+
+	entry->fid = val & GLOBAL_VTU_FID_MASK;
+
+	return 0;
+}
+
+int mv88e6xxx_g1_vtu_fid_write(struct mv88e6xxx_chip *chip,
+			       struct mv88e6xxx_vtu_entry *entry)
+{
+	u16 val = entry->fid & GLOBAL_VTU_FID_MASK;
+
+	return mv88e6xxx_g1_write(chip, GLOBAL_VTU_FID, val);
+}
+
 /* Offset 0x05: VTU Operation Register */
 
 int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip)
-- 
2.12.2

^ permalink raw reply related

* [PATCH net-next v2 07/18] net: dsa: mv88e6xxx: move VTU VID accessors
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

Add helpers to access the VTU VID register in the global1_vtu.c file.

At the same time, move mv88e6xxx_g1_vtu_vid_write at the beginning of
_mv88e6xxx_vtu_loadpurge, which adds no functional changes but makes
future patches simpler.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c        | 57 +++++++++++++--------------------
 drivers/net/dsa/mv88e6xxx/global1.h     |  4 +++
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 29 +++++++++++++++++
 3 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index ec621879439d..dce490e78347 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1337,12 +1337,6 @@ static int mv88e6xxx_stu_data_write(struct mv88e6xxx_chip *chip,
 	return _mv88e6xxx_vtu_stu_data_write(chip, entry, 2);
 }
 
-static int _mv88e6xxx_vtu_vid_write(struct mv88e6xxx_chip *chip, u16 vid)
-{
-	return mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID,
-				  vid & GLOBAL_VTU_VID_MASK);
-}
-
 static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
 				  struct mv88e6xxx_vtu_entry *entry)
 {
@@ -1358,13 +1352,10 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
 	if (err)
 		return err;
 
-	err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val);
+	err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
 	if (err)
 		return err;
 
-	next.vid = val & GLOBAL_VTU_VID_MASK;
-	next.valid = !!(val & GLOBAL_VTU_VID_VALID);
-
 	if (next.valid) {
 		err = mv88e6xxx_vtu_data_read(chip, &next);
 		if (err)
@@ -1410,7 +1401,9 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
 				    int (*cb)(struct switchdev_obj *obj))
 {
 	struct mv88e6xxx_chip *chip = ds->priv;
-	struct mv88e6xxx_vtu_entry next;
+	struct mv88e6xxx_vtu_entry next = {
+		.vid = chip->info->max_vid,
+	};
 	u16 pvid;
 	int err;
 
@@ -1423,7 +1416,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
 	if (err)
 		goto unlock;
 
-	err = _mv88e6xxx_vtu_vid_write(chip, GLOBAL_VTU_VID_MASK);
+	err = mv88e6xxx_g1_vtu_vid_write(chip, &next);
 	if (err)
 		goto unlock;
 
@@ -1464,13 +1457,16 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 				    struct mv88e6xxx_vtu_entry *entry)
 {
 	u16 op = GLOBAL_VTU_OP_VTU_LOAD_PURGE;
-	u16 reg = 0;
 	int err;
 
 	err = mv88e6xxx_g1_vtu_op_wait(chip);
 	if (err)
 		return err;
 
+	err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
+	if (err)
+		return err;
+
 	if (!entry->valid)
 		goto loadpurge;
 
@@ -1496,14 +1492,7 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
 		op |= (entry->fid & 0xf0) << 8;
 		op |= entry->fid & 0xf;
 	}
-
-	reg = GLOBAL_VTU_VID_VALID;
 loadpurge:
-	reg |= entry->vid & GLOBAL_VTU_VID_MASK;
-	err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, reg);
-	if (err)
-		return err;
-
 	return mv88e6xxx_g1_vtu_op(chip, op);
 }
 
@@ -1513,7 +1502,6 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
 	struct mv88e6xxx_vtu_entry next = {
 		.sid = sid,
 	};
-	u16 val;
 	int err;
 
 	err = mv88e6xxx_g1_vtu_op_wait(chip);
@@ -1532,12 +1520,10 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
 	if (err)
 		return err;
 
-	err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val);
+	err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
 	if (err)
 		return err;
 
-	next.valid = !!(val & GLOBAL_VTU_VID_VALID);
-
 	if (next.valid) {
 		err = mv88e6xxx_stu_data_read(chip, &next);
 		if (err)
@@ -1551,7 +1537,6 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
 static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
 				    struct mv88e6xxx_vtu_entry *entry)
 {
-	u16 reg = 0;
 	int err;
 
 	err = mv88e6xxx_g1_vtu_op_wait(chip);
@@ -1565,10 +1550,8 @@ static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
 	err = mv88e6xxx_stu_data_write(chip, entry);
 	if (err)
 		return err;
-
-	reg = GLOBAL_VTU_VID_VALID;
 loadpurge:
-	err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, reg);
+	err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
 	if (err)
 		return err;
 
@@ -1582,7 +1565,9 @@ static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
 static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
 {
 	DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
-	struct mv88e6xxx_vtu_entry vlan;
+	struct mv88e6xxx_vtu_entry vlan = {
+		.vid = chip->info->max_vid,
+	};
 	int i, err;
 
 	bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
@@ -1597,7 +1582,7 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
 	}
 
 	/* Set every FID bit used by the VLAN entries */
-	err = _mv88e6xxx_vtu_vid_write(chip, GLOBAL_VTU_VID_MASK);
+	err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
 	if (err)
 		return err;
 
@@ -1681,7 +1666,9 @@ static int _mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
 	if (!vid)
 		return -EINVAL;
 
-	err = _mv88e6xxx_vtu_vid_write(chip, vid - 1);
+	entry->vid = vid - 1;
+	entry->valid = false;
+	err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
 	if (err)
 		return err;
 
@@ -1706,7 +1693,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 					u16 vid_begin, u16 vid_end)
 {
 	struct mv88e6xxx_chip *chip = ds->priv;
-	struct mv88e6xxx_vtu_entry vlan;
+	struct mv88e6xxx_vtu_entry vlan = {
+		.vid = vid_begin - 1,
+	};
 	int i, err;
 
 	if (!vid_begin)
@@ -1714,7 +1703,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 
 	mutex_lock(&chip->reg_lock);
 
-	err = _mv88e6xxx_vtu_vid_write(chip, vid_begin - 1);
+	err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
 	if (err)
 		goto unlock;
 
@@ -2076,7 +2065,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
 		return err;
 
 	/* Dump VLANs' Filtering Information Databases */
-	err = _mv88e6xxx_vtu_vid_write(chip, vlan.vid);
+	err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
 	if (err)
 		return err;
 
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index 1bf235085215..22fe22bd82cd 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -58,6 +58,10 @@ int mv88e6xxx_g1_vtu_sid_read(struct mv88e6xxx_chip *chip,
 			      struct mv88e6xxx_vtu_entry *entry);
 int mv88e6xxx_g1_vtu_sid_write(struct mv88e6xxx_chip *chip,
 			       struct mv88e6xxx_vtu_entry *entry);
+int mv88e6xxx_g1_vtu_vid_read(struct mv88e6xxx_chip *chip,
+			      struct mv88e6xxx_vtu_entry *entry);
+int mv88e6xxx_g1_vtu_vid_write(struct mv88e6xxx_chip *chip,
+			       struct mv88e6xxx_vtu_entry *entry);
 int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
 int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 201c063d15f2..6ac3d0eeae6b 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -82,6 +82,35 @@ int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op)
 	return mv88e6xxx_g1_vtu_op_wait(chip);
 }
 
+/* Offset 0x06: VTU VID Register */
+
+int mv88e6xxx_g1_vtu_vid_read(struct mv88e6xxx_chip *chip,
+			      struct mv88e6xxx_vtu_entry *entry)
+{
+	u16 val;
+	int err;
+
+	err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val);
+	if (err)
+		return err;
+
+	entry->vid = val & 0xfff;
+	entry->valid = !!(val & GLOBAL_VTU_VID_VALID);
+
+	return 0;
+}
+
+int mv88e6xxx_g1_vtu_vid_write(struct mv88e6xxx_chip *chip,
+			       struct mv88e6xxx_vtu_entry *entry)
+{
+	u16 val = entry->vid & 0xfff;
+
+	if (entry->valid)
+		val |= GLOBAL_VTU_VID_VALID;
+
+	return mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, val);
+}
+
 /* VLAN Translation Unit Operations */
 
 int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip)
-- 
2.12.2

^ permalink raw reply related

* [PATCH net-next v2 08/18] net: dsa: mv88e6xxx: move generic VTU GetNext
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

Even though every switch model has a different way to access the VTU
Data bits, the base implementation of the VTU GetNext operation remains
the same: wait, write the first VID to iterate from, start the
operation, and read the next VID.

Move this generic implementation into global1_vtu.c and abstract the
handling of the start VID (similarly to the ATU GetNext implementation),
before introducing a new chip operation for specific chips.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c        | 31 ++-----------------------------
 drivers/net/dsa/mv88e6xxx/global1.h     |  2 ++
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 29 +++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index dce490e78347..70b420e134ce 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1340,19 +1340,11 @@ static int mv88e6xxx_stu_data_write(struct mv88e6xxx_chip *chip,
 static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
 				  struct mv88e6xxx_vtu_entry *entry)
 {
-	struct mv88e6xxx_vtu_entry next = { 0 };
+	struct mv88e6xxx_vtu_entry next = *entry;
 	u16 val;
 	int err;
 
-	err = mv88e6xxx_g1_vtu_op_wait(chip);
-	if (err)
-		return err;
-
-	err = mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_VTU_GET_NEXT);
-	if (err)
-		return err;
-
-	err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
+	err = mv88e6xxx_g1_vtu_getnext(chip, &next);
 	if (err)
 		return err;
 
@@ -1416,10 +1408,6 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
 	if (err)
 		goto unlock;
 
-	err = mv88e6xxx_g1_vtu_vid_write(chip, &next);
-	if (err)
-		goto unlock;
-
 	do {
 		err = _mv88e6xxx_vtu_getnext(chip, &next);
 		if (err)
@@ -1582,10 +1570,6 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
 	}
 
 	/* Set every FID bit used by the VLAN entries */
-	err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
-	if (err)
-		return err;
-
 	do {
 		err = _mv88e6xxx_vtu_getnext(chip, &vlan);
 		if (err)
@@ -1668,9 +1652,6 @@ static int _mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
 
 	entry->vid = vid - 1;
 	entry->valid = false;
-	err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
-	if (err)
-		return err;
 
 	err = _mv88e6xxx_vtu_getnext(chip, entry);
 	if (err)
@@ -1703,10 +1684,6 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
 
 	mutex_lock(&chip->reg_lock);
 
-	err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
-	if (err)
-		goto unlock;
-
 	do {
 		err = _mv88e6xxx_vtu_getnext(chip, &vlan);
 		if (err)
@@ -2065,10 +2042,6 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
 		return err;
 
 	/* Dump VLANs' Filtering Information Databases */
-	err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
-	if (err)
-		return err;
-
 	do {
 		err = _mv88e6xxx_vtu_getnext(chip, &vlan);
 		if (err)
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index 22fe22bd82cd..66216848fc0d 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -64,6 +64,8 @@ int mv88e6xxx_g1_vtu_vid_write(struct mv88e6xxx_chip *chip,
 			       struct mv88e6xxx_vtu_entry *entry);
 int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
+int mv88e6xxx_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
+			     struct mv88e6xxx_vtu_entry *entry);
 int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
 
 #endif /* _MV88E6XXX_GLOBAL1_H */
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 6ac3d0eeae6b..c3f55be873b3 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -113,6 +113,35 @@ int mv88e6xxx_g1_vtu_vid_write(struct mv88e6xxx_chip *chip,
 
 /* VLAN Translation Unit Operations */
 
+int mv88e6xxx_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
+			     struct mv88e6xxx_vtu_entry *entry)
+{
+	int err;
+
+	err = mv88e6xxx_g1_vtu_op_wait(chip);
+	if (err)
+		return err;
+
+	/* To get the next higher active VID, the VTU GetNext operation can be
+	 * started again without setting the VID registers since it already
+	 * contains the last VID.
+	 *
+	 * To save a few hardware accesses and abstract this to the caller,
+	 * write the VID only once, when the entry is given as invalid.
+	 */
+	if (!entry->valid) {
+		err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
+		if (err)
+			return err;
+	}
+
+	err = mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_VTU_GET_NEXT);
+	if (err)
+		return err;
+
+	return mv88e6xxx_g1_vtu_vid_read(chip, entry);
+}
+
 int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip)
 {
 	int err;
-- 
2.12.2

^ permalink raw reply related

* [PATCH net-next v2 10/18] net: dsa: mv88e6xxx: move STU GetNext operation
From: Vivien Didelot @ 2017-05-01 18:05 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
	Andrew Lunn, Vivien Didelot
In-Reply-To: <20170501180527.11756-1-vivien.didelot@savoirfairelinux.com>

Extract the generic portion of code to issue an STU GetNext operation,
which will be used in other implementations.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c        | 14 +-------------
 drivers/net/dsa/mv88e6xxx/global1.h     |  2 ++
 drivers/net/dsa/mv88e6xxx/global1_vtu.c | 20 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index b163e40bf42e..5441b05f519b 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1422,19 +1422,7 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
 	if (err)
 		return err;
 
-	err = mv88e6xxx_g1_vtu_sid_write(chip, &next);
-	if (err)
-		return err;
-
-	err = mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_STU_GET_NEXT);
-	if (err)
-		return err;
-
-	err = mv88e6xxx_g1_vtu_sid_read(chip, &next);
-	if (err)
-		return err;
-
-	err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
+	err = mv88e6xxx_g1_vtu_stu_getnext(chip, &next);
 	if (err)
 		return err;
 
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index 9644ca649838..5d276cc4262b 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -70,6 +70,8 @@ int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
 int mv88e6xxx_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry);
+int mv88e6xxx_g1_vtu_stu_getnext(struct mv88e6xxx_chip *chip,
+				 struct mv88e6xxx_vtu_entry *vtu);
 int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
 
 #endif /* _MV88E6XXX_GLOBAL1_H */
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 060c4a5a802d..cf572ba76195 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -174,6 +174,26 @@ int mv88e6185_g1_vtu_data_write(struct mv88e6xxx_chip *chip,
 
 /* VLAN Translation Unit Operations */
 
+int mv88e6xxx_g1_vtu_stu_getnext(struct mv88e6xxx_chip *chip,
+				 struct mv88e6xxx_vtu_entry *entry)
+{
+	int err;
+
+	err = mv88e6xxx_g1_vtu_sid_write(chip, entry);
+	if (err)
+		return err;
+
+	err = mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_STU_GET_NEXT);
+	if (err)
+		return err;
+
+	err = mv88e6xxx_g1_vtu_sid_read(chip, entry);
+	if (err)
+		return err;
+
+	return mv88e6xxx_g1_vtu_vid_read(chip, entry);
+}
+
 int mv88e6xxx_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry)
 {
-- 
2.12.2

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox