* Re: Kernel 4.13.0-rc4-next-20170811 - IP Routing / Forwarding performance vs Core/RSS number / HT on
From: Eric Dumazet @ 2017-08-15 1:07 UTC (permalink / raw)
To: Paweł Staszewski
Cc: Paolo Abeni, Jesper Dangaard Brouer,
Linux Kernel Network Developers, Alexander Duyck
In-Reply-To: <80b3bf71-dc6b-7b96-43d6-dbb3c53c5a8b@itcare.pl>
On Tue, 2017-08-15 at 02:45 +0200, Paweł Staszewski wrote:
>
> W dniu 2017-08-14 o 18:57, Paolo Abeni pisze:
> > On Mon, 2017-08-14 at 18:19 +0200, Jesper Dangaard Brouer wrote:
> >> The output (extracted below) didn't show who called 'do_raw_spin_lock',
> >> BUT it showed another interesting thing. The kernel code
> >> __dev_queue_xmit() in might create route dst-cache problem for itself(?),
> >> as it will first call skb_dst_force() and then skb_dst_drop() when the
> >> packet is transmitted on a VLAN.
> >>
> >> static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
> >> {
> >> [...]
> >> /* If device/qdisc don't need skb->dst, release it right now while
> >> * its hot in this cpu cache.
> >> */
> >> if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
> >> skb_dst_drop(skb);
> >> else
> >> skb_dst_force(skb);
> > I think that the high impact of the above code in this specific test is
> > mostly due to the following:
> >
> > - ingress packets with different RSS rx hash lands on different CPUs
> yes but isn't this normal ?
> everybody that want to ballance load over cores will try tu use as many
> as possible :)
> With some limitations ... best are 6 to 7 RSS queues - so need to use 6
> to 7 cpu cores
>
> > - but they use the same dst entry, since the destination IPs belong to
> > the same subnet
> typical for ddos - many sources one destination
Nobody hit this issue yet.
We usually change the kernel, given typical workloads.
In this case, we might need per cpu nh_rth_input
Or try to hack the IFF_XMIT_DST_RELEASE flag on the vlan netdev.
^ permalink raw reply
* Re: Kernel 4.13.0-rc4-next-20170811 - IP Routing / Forwarding performance vs Core/RSS number / HT on
From: Paweł Staszewski @ 2017-08-15 0:45 UTC (permalink / raw)
To: Paolo Abeni, Jesper Dangaard Brouer
Cc: Linux Kernel Network Developers, Alexander Duyck, Eric Dumazet
In-Reply-To: <1502729870.8411.63.camel@redhat.com>
W dniu 2017-08-14 o 18:57, Paolo Abeni pisze:
> On Mon, 2017-08-14 at 18:19 +0200, Jesper Dangaard Brouer wrote:
>> The output (extracted below) didn't show who called 'do_raw_spin_lock',
>> BUT it showed another interesting thing. The kernel code
>> __dev_queue_xmit() in might create route dst-cache problem for itself(?),
>> as it will first call skb_dst_force() and then skb_dst_drop() when the
>> packet is transmitted on a VLAN.
>>
>> static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
>> {
>> [...]
>> /* If device/qdisc don't need skb->dst, release it right now while
>> * its hot in this cpu cache.
>> */
>> if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
>> skb_dst_drop(skb);
>> else
>> skb_dst_force(skb);
> I think that the high impact of the above code in this specific test is
> mostly due to the following:
>
> - ingress packets with different RSS rx hash lands on different CPUs
yes but isn't this normal ?
everybody that want to ballance load over cores will try tu use as many
as possible :)
With some limitations ... best are 6 to 7 RSS queues - so need to use 6
to 7 cpu cores
> - but they use the same dst entry, since the destination IPs belong to
> the same subnet
typical for ddos - many sources one destination
> - the dst refcnt cacheline is contented between all the CPUs
>
> Perhaps we can inprove the situation setting the IFF_XMIT_DST_RELEASE
> flag for vlan if the underlaying device does not have (relevant)
> classifier attached? (and clearing it as needed)
>
> Paolo
>
^ permalink raw reply
* [PATCH net] tcp: fix possible deadlock in TCP stack vs BPF filter
From: Eric Dumazet @ 2017-08-15 0:44 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Chenbo Feng
From: Eric Dumazet <edumazet@google.com>
Filtering the ACK packet was not put at the right place.
At this place, we already allocated a child and put it
into accept queue.
We absolutely need to call tcp_child_process() to release
its spinlock, or we will deadlock at accept() or close() time.
Found by syzkaller team (Thanks a lot !)
Fixes: 8fac365f63c8 ("tcp: Add a tcp_filter hook before handle ack packet")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Chenbo Feng <fengc@google.com>
---
net/ipv4/tcp_ipv4.c | 4 ++--
net/ipv6/tcp_ipv6.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a20e7f03d5f7..e9252c7df809 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1722,6 +1722,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
*/
sock_hold(sk);
refcounted = true;
+ if (tcp_filter(sk, skb))
+ goto discard_and_relse;
nsk = tcp_check_req(sk, skb, req, false);
if (!nsk) {
reqsk_put(req);
@@ -1729,8 +1731,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
}
if (nsk == sk) {
reqsk_put(req);
- } else if (tcp_filter(sk, skb)) {
- goto discard_and_relse;
} else if (tcp_child_process(sk, nsk, skb)) {
tcp_v4_send_reset(nsk, skb);
goto discard_and_relse;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2521690d62d6..206210125fd7 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1456,6 +1456,8 @@ static int tcp_v6_rcv(struct sk_buff *skb)
}
sock_hold(sk);
refcounted = true;
+ if (tcp_filter(sk, skb))
+ goto discard_and_relse;
nsk = tcp_check_req(sk, skb, req, false);
if (!nsk) {
reqsk_put(req);
@@ -1464,8 +1466,6 @@ static int tcp_v6_rcv(struct sk_buff *skb)
if (nsk == sk) {
reqsk_put(req);
tcp_v6_restore_cb(skb);
- } else if (tcp_filter(sk, skb)) {
- goto discard_and_relse;
} else if (tcp_child_process(sk, nsk, skb)) {
tcp_v6_send_reset(nsk, skb);
goto discard_and_relse;
^ permalink raw reply related
* Re: Kernel 4.13.0-rc4-next-20170811 - IP Routing / Forwarding performance vs Core/RSS number / HT on
From: Paweł Staszewski @ 2017-08-15 0:38 UTC (permalink / raw)
To: Jesper Dangaard Brouer; +Cc: Linux Kernel Network Developers, Alexander Duyck
In-Reply-To: <20170814181957.5be27906@redhat.com>
W dniu 2017-08-14 o 18:19, Jesper Dangaard Brouer pisze:
> On Sun, 13 Aug 2017 18:58:58 +0200 Paweł Staszewski <pstaszewski@itcare.pl> wrote:
>
>> To show some difference below comparision vlan/no-vlan traffic
>>
>> 10Mpps forwarded traffic vith no-vlan vs 6.9Mpps with vlan
> I'm trying to reproduce in my testlab (with ixgbe). I do see, a
> performance reduction of about 10-19% when I forward out a VLAN
> interface. This is larger than I expected, but still lower than what
> you reported 30-40% slowdown.
>
> [...]
Ok mellanox afrrived (MT27700 - mlnx5 driver)
And to compare melannox with vlans and without: 33% performance
degradation (less than with ixgbe where i reach ~40% with same settings)
Mellanox without TX traffix on vlan:
ID;CPU_CORES / RSS QUEUES;PKT_SIZE;PPS_RX;BPS_RX;PPS_TX;BPS_TX
0;16;64;11089305;709715520;8871553;567779392
1;16;64;11096292;710162688;11095566;710116224
2;16;64;11095770;710129280;11096799;710195136
3;16;64;11097199;710220736;11097702;710252928
4;16;64;11080984;567081856;11079662;709098368
5;16;64;11077696;708972544;11077039;708930496
6;16;64;11082991;709311424;8864802;567347328
7;16;64;11089596;709734144;8870927;709789184
8;16;64;11094043;710018752;11095391;710105024
Mellanox with TX traffic on vlan:
ID;CPU_CORES / RSS QUEUES;PKT_SIZE;PPS_RX;BPS_RX;PPS_TX;BPS_TX
0;16;64;7369914;471674496;7370281;471697980
1;16;64;7368896;471609408;7368043;471554752
2;16;64;7367577;471524864;7367759;471536576
3;16;64;7368744;377305344;7369391;471641024
4;16;64;7366824;471476736;7364330;471237120
5;16;64;7368352;471574528;7367239;471503296
6;16;64;7367459;471517376;7367806;471539584
7;16;64;7367190;471500160;7367988;471551232
8;16;64;7368023;471553472;7368076;471556864
ethtool settings for both tests:
ifc='enp175s0f0 enp175s0f1'
for i in $ifc
do
ip link set up dev $i
ethtool -A $i autoneg off rx off tx off
ethtool -G $i rx 128 tx 256
ip link set $i txqueuelen 1000
ethtool -C $i rx-usecs 25
ethtool -L $i combined 16
ethtool -K $i gro off tso off gso off sg on l2-fwd-offload off
tx-nocache-copy off ntuple on
ethtool -N $i rx-flow-hash udp4 sdfn
done
and perf top:
PerfTop: 83650 irqs/sec kernel:99.7% exact: 0.0% [4000Hz
cycles], (all, 56 CPUs)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
14.25% [kernel] [k] dst_release
14.17% [kernel] [k] skb_dst_force
13.41% [kernel] [k] rt_cache_valid
11.47% [kernel] [k] ip_finish_output2
7.01% [kernel] [k] do_raw_spin_lock
5.07% [kernel] [k] page_frag_free
3.47% [mlx5_core] [k] mlx5e_xmit
2.88% [kernel] [k] fib_table_lookup
2.43% [mlx5_core] [k] skb_from_cqe.isra.32
1.97% [kernel] [k] virt_to_head_page
1.81% [mlx5_core] [k] mlx5e_poll_tx_cq
0.93% [kernel] [k] __dev_queue_xmit
0.87% [kernel] [k] __build_skb
0.84% [kernel] [k] ipt_do_table
0.79% [kernel] [k] ip_rcv
0.79% [kernel] [k] acpi_processor_ffh_cstate_enter
0.78% [kernel] [k] netif_skb_features
0.73% [kernel] [k] __netif_receive_skb_core
0.52% [kernel] [k] dev_hard_start_xmit
0.52% [kernel] [k] build_skb
0.51% [kernel] [k] ip_route_input_rcu
0.50% [kernel] [k] skb_unref
0.49% [kernel] [k] ip_forward
0.48% [mlx5_core] [k] mlx5_cqwq_get_cqe
0.44% [kernel] [k] udp_v4_early_demux
0.41% [kernel] [k] napi_consume_skb
0.40% [kernel] [k] __local_bh_enable_ip
0.39% [kernel] [k] ip_rcv_finish
0.39% [kernel] [k] kmem_cache_alloc
0.38% [kernel] [k] sch_direct_xmit
0.33% [kernel] [k] validate_xmit_skb
0.32% [mlx5_core] [k] mlx5e_free_rx_wqe_reuse
0.29% [kernel] [k] netdev_pick_tx
0.28% [mlx5_core] [k] mlx5e_build_rx_skb
0.27% [kernel] [k] deliver_ptype_list_skb
0.26% [kernel] [k] fib_validate_source
0.26% [mlx5_core] [k] mlx5e_napi_poll
0.26% [mlx5_core] [k] mlx5e_handle_rx_cqe
0.26% [mlx5_core] [k] mlx5e_rx_cache_get
0.25% [kernel] [k] eth_header
0.23% [kernel] [k] skb_network_protocol
0.20% [kernel] [k] nf_hook_slow
0.20% [kernel] [k] vlan_passthru_hard_header
0.20% [kernel] [k] vlan_dev_hard_start_xmit
0.19% [kernel] [k] swiotlb_map_page
0.18% [kernel] [k] compound_head
0.18% [kernel] [k] neigh_connected_output
0.18% [mlx5_core] [k] mlx5e_alloc_rx_wqe
0.18% [kernel] [k] ip_output
0.17% [kernel] [k] prefetch_freepointer.isra.70
0.17% [kernel] [k] __slab_free
0.16% [kernel] [k] eth_type_vlan
0.16% [kernel] [k] ip_finish_output
0.15% [kernel] [k] kmem_cache_free_bulk
0.14% [kernel] [k] netif_receive_skb_internal
wondering why this:
1.97% [kernel] [k] virt_to_head_page
is in top...
>>>>> perf top:
>>>>>
>>>>> PerfTop: 77835 irqs/sec kernel:99.7%
>>>>> ---------------------------------------------
>>>>>
>>>>> 16.32% [kernel] [k] skb_dst_force
>>>>> 16.30% [kernel] [k] dst_release
>>>>> 15.11% [kernel] [k] rt_cache_valid
>>>>> 12.62% [kernel] [k] ipv4_mtu
>>>> It seems a little strange that these 4 functions are on the top
> I don't see these in my test.
>
>>>>
>>>>> 5.60% [kernel] [k] do_raw_spin_lock
>>>> Why is calling/taking this lock? (Use perf call-graph recording).
>>> can be hard to paste it here:)
>>> attached file
> The attached was very big. Please don't attach so big file on mailing
> lists. Next time plase share them via e.g. pastebin. The output was a
> capture from your terminal, which made the output more difficult to
> read. Hint: You can/could use perf --stdio and place it in a file
> instead.
>
> The output (extracted below) didn't show who called 'do_raw_spin_lock',
> BUT it showed another interesting thing. The kernel code
> __dev_queue_xmit() in might create route dst-cache problem for itself(?),
> as it will first call skb_dst_force() and then skb_dst_drop() when the
> packet is transmitted on a VLAN.
>
> static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
> {
> [...]
> /* If device/qdisc don't need skb->dst, release it right now while
> * its hot in this cpu cache.
> */
> if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
> skb_dst_drop(skb);
> else
> skb_dst_force(skb);
>
>
> - -
> Best regards,
> Jesper Dangaard Brouer
> MSc.CS, Principal Kernel Engineer at Red Hat
> LinkedIn: http://www.linkedin.com/in/brouer
>
> Extracted part of attached perf output:
>
> --5.37%--ip_rcv_finish
> |
> |--4.02%--ip_forward
> | |
> | --3.92%--ip_forward_finish
> | |
> | --3.91%--ip_output
> | |
> | --3.90%--ip_finish_output
> | |
> | --3.88%--ip_finish_output2
> | |
> | --2.77%--neigh_connected_output
> | |
> | --2.74%--dev_queue_xmit
> | |
> | --2.73%--__dev_queue_xmit
> | |
> | |--1.66%--dev_hard_start_xmit
> | | |
> | | --1.64%--vlan_dev_hard_start_xmit
> | | |
> | | --1.63%--dev_queue_xmit
> | | |
> | | --1.62%--__dev_queue_xmit
> | | |
> | | |--0.99%--skb_dst_drop.isra.77
> | | | |
> | | | --0.99%--dst_release
> | | |
> | | --0.55%--sch_direct_xmit
> | |
> | --0.99%--skb_dst_force
> |
> --1.29%--ip_route_input_noref
> |
> --1.29%--ip_route_input_rcu
> |
> --1.05%--rt_cache_valid
>
^ permalink raw reply
* Re: [PATCH net-next v2] openvswitch: enable NSH support
From: Yang, Yi @ 2017-08-15 0:39 UTC (permalink / raw)
To: Eric Garver
Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
jbenc-H+wXaHxf7aLQT0dZR+AlfA
In-Reply-To: <20170814160914.GC27729@dev-rhel7>
On Tue, Aug 15, 2017 at 12:09:14AM +0800, Eric Garver wrote:
> On Thu, Aug 10, 2017 at 09:21:15PM +0800, Yi Yang wrote:
>
> Hi Yi,
>
> In general I'd like to echo Jiri's comments on the netlink attributes.
> I'd like to see the metadata separate.
>
> I have a few other comments below.
>
> Thanks.
> Eric.
>
> [..]
Thanks Eric, I'm doing this and it is almost done, there is still an
issue to fix.
> > +{
> > + return 4 * (ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> NSH_LEN_SHIFT;
>
> This is doing the multiplication before the shift. It works only because
> the shift is 0.
>
Thank you for catching this, the right one:
((ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> NSH_LEN_SHIFT) << 2
> > +static int push_nsh(struct sk_buff *skb, struct sw_flow_key *key,
> > + const struct ovs_action_push_nsh *oapn)
> > +{
> > + struct nsh_hdr *nsh;
> > + size_t length = NSH_BASE_HDR_LEN + oapn->mdlen;
> > + u8 next_proto;
> > +
> > + if (key->mac_proto == MAC_PROTO_ETHERNET) {
> > + next_proto = NSH_P_ETHERNET;
> > + } else {
> > + switch (ntohs(skb->protocol)) {
> > + case ETH_P_IP:
> > + next_proto = NSH_P_IPV4;
> > + break;
> > + case ETH_P_IPV6:
> > + next_proto = NSH_P_IPV6;
> > + break;
> > + case ETH_P_NSH:
> > + next_proto = NSH_P_NSH;
> > + break;
> > + default:
> > + return -ENOTSUPP;
> > + }
> > + }
> > +
> >
>
> I believe you need to validate that oapn->mdlen is a multiple of 4.
>
I'll add this check.
> > + switch (nsh->md_type) {
> > + case NSH_M_TYPE1:
> > + nsh->md1 = *(struct nsh_md1_ctx *)oapn->metadata;
> > + break;
> > + case NSH_M_TYPE2: {
> > + /* The MD2 metadata in oapn is already padded to 4 bytes. */
> > + size_t len = DIV_ROUND_UP(oapn->mdlen, 4) * 4;
> > +
> > + memcpy(nsh->md2, oapn->metadata, len);
>
> I don't see any validation of oapn->mdlen. Normally this happens in
> __ovs_nla_copy_actions(). It will be made easier if you add a separate
> MD attribute as Jiri has suggested.
>
Got it, will include this in next version.
^ permalink raw reply
* Re: [PATCH net-next 1/1 v3] drivers: net: rmnet: Initial implementation
From: Subash Abhinov Kasiviswanathan @ 2017-08-14 23:52 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, fengguang.wu, dcbw
In-Reply-To: <20170414090752.GA1992@nanopsycho>
>> + */
>> +void rmnet_egress_handler(struct sk_buff *skb,
>> + struct rmnet_logical_ep_conf_s *ep)
>> +{
>> + struct rmnet_phys_ep_conf_s *config;
>> + struct net_device *orig_dev;
>> + int rc;
>> +
>> + orig_dev = skb->dev;
>> + skb->dev = ep->egress_dev;
>> +
>> + config = (struct rmnet_phys_ep_conf_s *)
>> + rcu_dereference(skb->dev->rx_handler_data);
>
> This is certainly a misuse of dev->rx_handler_data. Dev private of a
> function arg to carry the pointer around.
>
Hi Jiri
Sorry for the delay in posting a new series.
I have an additional query regarding this comment.
This dev (from skb->dev->rx_handler_data) corresponds to the real_dev to
which
the rmnet devices are attached to. I had earlier setup a rx_handler on
this
real_dev netdevice in rmnet_associate_network_device(). Would it still
be
incorrect to use rx_handler_data of real_dev to have rmnet specific
config
information?
Bridge is similarly storing the bridge information on the real_dev
rx_handler_data and retrieving it through br_port_get_rcu(). I am using
that
as a reference.
^ permalink raw reply
* Re: [PATCH net] af_key: do not use GFP_KERNEL in atomic contexts
From: David Ahern @ 2017-08-14 23:07 UTC (permalink / raw)
To: Eric Dumazet, David Miller; +Cc: netdev, David Ahern
In-Reply-To: <1502731005.4936.29.camel@edumazet-glaptop3.roam.corp.google.com>
On 8/14/17 11:16 AM, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> pfkey_broadcast() might be called from non process contexts,
> we can not use GFP_KERNEL in these cases [1].
>
> This patch partially reverts commit ba51b6be38c1 ("net: Fix RCU splat in
> af_key"), only keeping the GFP_ATOMIC forcing under rcu_read_lock()
> section.
>
> [1] : syzkaller reported :
...
> Fixes: ba51b6be38c1 ("net: Fix RCU splat in af_key")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: David Ahern <dsa@cumulusnetworks.com>
> ---
> net/key/af_key.c | 48 ++++++++++++++++++++++++---------------------
> 1 file changed, 26 insertions(+), 22 deletions(-)
>
Thanks for the fix, Eric.
Acked-by: David Ahern <dsahern@gmail.com>
^ permalink raw reply
* Re: [PATCH v2] sctp: fully initialize the IPv6 address in sctp_v6_to_addr()
From: Marcelo Ricardo Leitner @ 2017-08-14 23:07 UTC (permalink / raw)
To: Alexander Potapenko
Cc: dvyukov, kcc, edumazet, lucien.xin, vyasevich, davem,
linux-kernel, linux-sctp, netdev
In-Reply-To: <20170814184304.82747-1-glider@google.com>
On Mon, Aug 14, 2017 at 08:43:04PM +0200, Alexander Potapenko wrote:
> KMSAN reported use of uninitialized sctp_addr->v4.sin_addr.s_addr and
> sctp_addr->v6.sin6_scope_id in sctp_v6_cmp_addr() (see below).
> Make sure all fields of an IPv6 address are initialized, which
> guarantees that the IPv4 fields are also initialized.
>
> ==================================================================
> BUG: KMSAN: use of uninitialized memory in sctp_v6_cmp_addr+0x8d4/0x9f0
> net/sctp/ipv6.c:517
> CPU: 2 PID: 31056 Comm: syz-executor1 Not tainted 4.11.0-rc5+ #2944
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs
> 01/01/2011
> Call Trace:
> dump_stack+0x172/0x1c0 lib/dump_stack.c:42
> is_logbuf_locked mm/kmsan/kmsan.c:59 [inline]
> kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:938
> native_save_fl arch/x86/include/asm/irqflags.h:18 [inline]
> arch_local_save_flags arch/x86/include/asm/irqflags.h:72 [inline]
> arch_local_irq_save arch/x86/include/asm/irqflags.h:113 [inline]
> __msan_warning_32+0x61/0xb0 mm/kmsan/kmsan_instr.c:467
> sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517
> sctp_v6_get_dst+0x8c7/0x1630 net/sctp/ipv6.c:290
> sctp_transport_route+0x101/0x570 net/sctp/transport.c:292
> sctp_assoc_add_peer+0x66d/0x16f0 net/sctp/associola.c:651
> sctp_sendmsg+0x35a5/0x4f90 net/sctp/socket.c:1871
> inet_sendmsg+0x498/0x670 net/ipv4/af_inet.c:762
> sock_sendmsg_nosec net/socket.c:633 [inline]
> sock_sendmsg net/socket.c:643 [inline]
> SYSC_sendto+0x608/0x710 net/socket.c:1696
> SyS_sendto+0x8a/0xb0 net/socket.c:1664
> entry_SYSCALL_64_fastpath+0x13/0x94
> RIP: 0033:0x44b479
> RSP: 002b:00007f6213f21c08 EFLAGS: 00000286 ORIG_RAX: 000000000000002c
> RAX: ffffffffffffffda RBX: 0000000020000000 RCX: 000000000044b479
> RDX: 0000000000000041 RSI: 0000000020edd000 RDI: 0000000000000006
> RBP: 00000000007080a8 R08: 0000000020b85fe4 R09: 000000000000001c
> R10: 0000000000040005 R11: 0000000000000286 R12: 00000000ffffffff
> R13: 0000000000003760 R14: 00000000006e5820 R15: 0000000000ff8000
> origin description: ----dst_saddr@sctp_v6_get_dst
> local variable created at:
> sk_fullsock include/net/sock.h:2321 [inline]
> inet6_sk include/linux/ipv6.h:309 [inline]
> sctp_v6_get_dst+0x91/0x1630 net/sctp/ipv6.c:241
> sctp_transport_route+0x101/0x570 net/sctp/transport.c:292
> ==================================================================
> BUG: KMSAN: use of uninitialized memory in sctp_v6_cmp_addr+0x8d4/0x9f0
> net/sctp/ipv6.c:517
> CPU: 2 PID: 31056 Comm: syz-executor1 Not tainted 4.11.0-rc5+ #2944
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs
> 01/01/2011
> Call Trace:
> dump_stack+0x172/0x1c0 lib/dump_stack.c:42
> is_logbuf_locked mm/kmsan/kmsan.c:59 [inline]
> kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:938
> native_save_fl arch/x86/include/asm/irqflags.h:18 [inline]
> arch_local_save_flags arch/x86/include/asm/irqflags.h:72 [inline]
> arch_local_irq_save arch/x86/include/asm/irqflags.h:113 [inline]
> __msan_warning_32+0x61/0xb0 mm/kmsan/kmsan_instr.c:467
> sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517
> sctp_v6_get_dst+0x8c7/0x1630 net/sctp/ipv6.c:290
> sctp_transport_route+0x101/0x570 net/sctp/transport.c:292
> sctp_assoc_add_peer+0x66d/0x16f0 net/sctp/associola.c:651
> sctp_sendmsg+0x35a5/0x4f90 net/sctp/socket.c:1871
> inet_sendmsg+0x498/0x670 net/ipv4/af_inet.c:762
> sock_sendmsg_nosec net/socket.c:633 [inline]
> sock_sendmsg net/socket.c:643 [inline]
> SYSC_sendto+0x608/0x710 net/socket.c:1696
> SyS_sendto+0x8a/0xb0 net/socket.c:1664
> entry_SYSCALL_64_fastpath+0x13/0x94
> RIP: 0033:0x44b479
> RSP: 002b:00007f6213f21c08 EFLAGS: 00000286 ORIG_RAX: 000000000000002c
> RAX: ffffffffffffffda RBX: 0000000020000000 RCX: 000000000044b479
> RDX: 0000000000000041 RSI: 0000000020edd000 RDI: 0000000000000006
> RBP: 00000000007080a8 R08: 0000000020b85fe4 R09: 000000000000001c
> R10: 0000000000040005 R11: 0000000000000286 R12: 00000000ffffffff
> R13: 0000000000003760 R14: 00000000006e5820 R15: 0000000000ff8000
> origin description: ----dst_saddr@sctp_v6_get_dst
> local variable created at:
> sk_fullsock include/net/sock.h:2321 [inline]
> inet6_sk include/linux/ipv6.h:309 [inline]
> sctp_v6_get_dst+0x91/0x1630 net/sctp/ipv6.c:241
> sctp_transport_route+0x101/0x570 net/sctp/transport.c:292
> ==================================================================
>
> Signed-off-by: Alexander Potapenko <glider@google.com>
> Reviewed-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> v2 is identical to v1, resending per request by Marcelo Ricardo Leitner.
> ---
> net/sctp/ipv6.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
> index 2a186b201ad2..a15d691829c6 100644
> --- a/net/sctp/ipv6.c
> +++ b/net/sctp/ipv6.c
> @@ -513,6 +513,8 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr,
> addr->sa.sa_family = AF_INET6;
> addr->v6.sin6_port = port;
> addr->v6.sin6_addr = *saddr;
> + addr->v6.sin6_flowinfo = 0;
> + addr->v6.sin6_scope_id = 0;
> }
>
> /* Compare addresses exactly.
> --
> 2.14.0.434.g98096fd7a8-goog
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH net-next 01/11] net: dsa: legacy: assign dst->applied
From: Andrew Lunn @ 2017-08-14 22:58 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-2-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:32PM -0400, Vivien Didelot wrote:
> The "applied" boolean of the dsa_switch_tree is only set in the new
> bindings. This patch sets it in the legacy code as well.
What is missing here is: Why?
I see the next patch does a WARN_ON(!applied). Why have a WARN_ON?
Andrew
^ permalink raw reply
* Re: [PATCH net-next 03/11] net: dsa: debugfs: add tree
From: Andrew Lunn @ 2017-08-14 22:52 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-4-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:34PM -0400, Vivien Didelot wrote:
> This commit adds the boiler plate to create a DSA related debug
> filesystem entry as well as a "tree" file, containing the tree index.
>
> # cat switch1/tree
> 0
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 11/11] net: dsa: debugfs: add port vlan
From: Andrew Lunn @ 2017-08-14 22:52 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-12-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:42PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "vlan" entry to query a port's hardware VLAN
> entries through the .port_vlan_dump switch operation.
>
> This is really convenient to query directly the hardware or inspect DSA
> or CPU links, since these ports are not exposed to userspace.
>
> Here are the VLAN entries for a CPU port:
>
> # cat port5/vlan
> vid 1
> vid 42 pvid
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 10/11] net: dsa: restore VLAN dump
From: Andrew Lunn @ 2017-08-14 22:51 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-11-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:41PM -0400, Vivien Didelot wrote:
> This commit defines a dsa_vlan_dump_cb_t callback, similar to the FDB
> dump callback and partly reverts commit a0b6b8c9fa3c ("net: dsa: Remove
> support for vlan dump from DSA's drivers") to restore the DSA drivers
> VLAN dump operations.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb
From: Andrew Lunn @ 2017-08-14 22:50 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-10-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:40PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "mdb" entry to query a port's hardware MDB
> entries through the .port_mdb_dump switch operation.
>
> This is really convenient to query directly the hardware or inspect DSA
> or CPU links, since these ports are not exposed to userspace.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 08/11] net: dsa: restore mdb dump
From: Andrew Lunn @ 2017-08-14 22:48 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-9-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:39PM -0400, Vivien Didelot wrote:
> The same dsa_fdb_dump_cb_t callback is used since there is no
> distinction to do between FDB and MDB entries at this layer.
>
> Implement mv88e6xxx_port_mdb_dump so that multicast addresses associated
> to a switch port can be dumped.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb
From: Andrew Lunn @ 2017-08-14 22:47 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-8-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:38PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "fdb" entry to query a port's hardware FDB
> entries through the .port_fdb_dump switch operation.
>
> This is really convenient to query directly the hardware or inspect DSA
> or CPU links, since these ports are not exposed to userspace.
>
> # cat port1/fdb
> vid 0 12:34:56:78:90:ab static unicast
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 06/11] net: dsa: debugfs: add port registers
From: Andrew Lunn @ 2017-08-14 22:46 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-7-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:37PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "regs" entry to query a port's hardware registers
> through the .get_regs_len and .get_regs_len switch operations.
>
> This is very convenient because it allows one to dump the registers of
> DSA links, which are not exposed to userspace.
>
> Here are the registers of a zii-rev-b CPU and DSA ports:
>
> # pr -mt switch0/port{5,6}/regs
> 0: 4e07 0: 4d04
> 1: 403e 1: 003d
> 2: 0000 2: 0000
> 3: 3521 3: 3521
> 4: 0533 4: 373f
> 5: 8000 5: 0000
> 6: 005f 6: 003f
> 7: 002a 7: 002a
> 8: 2080 8: 2080
> 9: 0001 9: 0001
> 10: 0000 10: 0000
> 11: 0020 11: 0000
> 12: 0000 12: 0000
> 13: 0000 13: 0000
> 14: 0000 14: 0000
> 15: 9100 15: dada
> 16: 0000 16: 0000
> 17: 0000 17: 0000
> 18: 0000 18: 0000
> 19: 0000 19: 00d8
> 20: 0000 20: 0000
> 21: 0000 21: 0000
> 22: 0022 22: 0000
> 23: 0000 23: 0000
> 24: 3210 24: 3210
> 25: 7654 25: 7654
> 26: 0000 26: 0000
> 27: 8000 27: 8000
> 28: 0000 28: 0000
> 29: 0000 29: 0000
> 30: 0000 30: 0000
> 31: 0000 31: 0000
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 05/11] net: dsa: debugfs: add port stats
From: Andrew Lunn @ 2017-08-14 22:45 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-6-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:36PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "stats" entry to query a port's hardware
> statistics through the DSA switch .get_sset_count, .get_strings and
> .get_ethtool_stats operations.
>
> This allows one to get statistics about DSA links interconnecting
> switches, which is very convenient because this kind of port is not
> exposed to userspace.
>
> Here are the stats of a zii-rev-b DSA and CPU ports:
>
> # pr -mt switch0/port{5,6}/stats
> in_good_octets : 0 in_good_octets : 13824
> in_bad_octets : 0 in_bad_octets : 0
> in_unicast : 0 in_unicast : 0
> in_broadcasts : 0 in_broadcasts : 216
> in_multicasts : 0 in_multicasts : 0
> in_pause : 0 in_pause : 0
> in_undersize : 0 in_undersize : 0
> in_fragments : 0 in_fragments : 0
> in_oversize : 0 in_oversize : 0
> in_jabber : 0 in_jabber : 0
> in_rx_error : 0 in_rx_error : 0
> in_fcs_error : 0 in_fcs_error : 0
> out_octets : 9216 out_octets : 0
> out_unicast : 0 out_unicast : 0
> out_broadcasts : 144 out_broadcasts : 0
> out_multicasts : 0 out_multicasts : 0
> out_pause : 0 out_pause : 0
> excessive : 0 excessive : 0
> collisions : 0 collisions : 0
> deferred : 0 deferred : 0
> single : 0 single : 0
> multiple : 0 multiple : 0
> out_fcs_error : 0 out_fcs_error : 0
> late : 0 late : 0
> hist_64bytes : 0 hist_64bytes : 0
> hist_65_127bytes : 0 hist_65_127bytes : 0
> hist_128_255bytes : 0 hist_128_255bytes : 0
> hist_256_511bytes : 0 hist_256_511bytes : 0
> hist_512_1023bytes : 0 hist_512_1023bytes : 0
> hist_1024_max_bytes : 0 hist_1024_max_bytes : 0
> sw_in_discards : 0 sw_in_discards : 0
> sw_in_filtered : 0 sw_in_filtered : 0
> sw_out_filtered : 0 sw_out_filtered : 216
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* Re: [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol
From: Andrew Lunn @ 2017-08-14 22:42 UTC (permalink / raw)
To: Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller, Florian Fainelli,
Egil Hjelmeland, John Crispin, Woojung Huh, Sean Wang,
Volodymyr Bendiuga, Nikita Yushchenko, Maxime Hadjinlian,
Chris Healy, Maxim Uvarov, Stefan Eichenberger, Jason Cobham,
Juergen Borleis, Tobias Waldekranz
In-Reply-To: <20170814222242.10643-5-vivien.didelot@savoirfairelinux.com>
On Mon, Aug 14, 2017 at 06:22:35PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "tag_protocol" entry to query the switch tagging
> protocol through the .get_tag_protocol operation.
>
> # cat switch1/tag_protocol
> EDSA
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
> ---
> net/dsa/debugfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 54 insertions(+)
>
> diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
> index 5607efdb924d..30a732e86161 100644
> --- a/net/dsa/debugfs.c
> +++ b/net/dsa/debugfs.c
> @@ -109,6 +109,55 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
> return 0;
> }
>
> +static int dsa_debugfs_tag_protocol_read(struct dsa_switch *ds, int id,
> + struct seq_file *seq)
> +{
> + enum dsa_tag_protocol proto;
> +
> + if (!ds->ops->get_tag_protocol)
> + return -EOPNOTSUPP;
> +
> + proto = ds->ops->get_tag_protocol(ds);
> +
> + switch (proto) {
> + case DSA_TAG_PROTO_NONE:
> + seq_puts(seq, "NONE\n");
> + break;
> + case DSA_TAG_PROTO_BRCM:
> + seq_puts(seq, "BRCM\n");
> + break;
> + case DSA_TAG_PROTO_DSA:
> + seq_puts(seq, "DSA\n");
> + break;
> + case DSA_TAG_PROTO_EDSA:
> + seq_puts(seq, "EDSA\n");
> + break;
> + case DSA_TAG_PROTO_KSZ:
> + seq_puts(seq, "KSZ\n");
> + break;
> + case DSA_TAG_PROTO_LAN9303:
> + seq_puts(seq, "LAN9303\n");
> + break;
> + case DSA_TAG_PROTO_MTK:
> + seq_puts(seq, "MTK\n");
> + break;
> + case DSA_TAG_PROTO_QCA:
> + seq_puts(seq, "QCA\n");
> + break;
> + case DSA_TAG_PROTO_TRAILER:
> + seq_puts(seq, "TRAILER\n");
> + break;
> + default:
> + return -EINVAL;
> + }
Hi Vivien
Minor nitpick. Rather than -EINVAL, how about seq_puts(seq, "Unknown - Please fix %s\n", __func__);
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
* [PATCH net-next 04/11] net: dsa: debugfs: add tag_protocol
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
Add a debug filesystem "tag_protocol" entry to query the switch tagging
protocol through the .get_tag_protocol operation.
# cat switch1/tag_protocol
EDSA
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/debugfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 5607efdb924d..30a732e86161 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -109,6 +109,55 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
return 0;
}
+static int dsa_debugfs_tag_protocol_read(struct dsa_switch *ds, int id,
+ struct seq_file *seq)
+{
+ enum dsa_tag_protocol proto;
+
+ if (!ds->ops->get_tag_protocol)
+ return -EOPNOTSUPP;
+
+ proto = ds->ops->get_tag_protocol(ds);
+
+ switch (proto) {
+ case DSA_TAG_PROTO_NONE:
+ seq_puts(seq, "NONE\n");
+ break;
+ case DSA_TAG_PROTO_BRCM:
+ seq_puts(seq, "BRCM\n");
+ break;
+ case DSA_TAG_PROTO_DSA:
+ seq_puts(seq, "DSA\n");
+ break;
+ case DSA_TAG_PROTO_EDSA:
+ seq_puts(seq, "EDSA\n");
+ break;
+ case DSA_TAG_PROTO_KSZ:
+ seq_puts(seq, "KSZ\n");
+ break;
+ case DSA_TAG_PROTO_LAN9303:
+ seq_puts(seq, "LAN9303\n");
+ break;
+ case DSA_TAG_PROTO_MTK:
+ seq_puts(seq, "MTK\n");
+ break;
+ case DSA_TAG_PROTO_QCA:
+ seq_puts(seq, "QCA\n");
+ break;
+ case DSA_TAG_PROTO_TRAILER:
+ seq_puts(seq, "TRAILER\n");
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_tag_protocol_ops = {
+ .read = dsa_debugfs_tag_protocol_read,
+};
+
static int dsa_debugfs_tree_read(struct dsa_switch *ds, int id,
struct seq_file *seq)
{
@@ -151,6 +200,11 @@ static int dsa_debugfs_create_switch(struct dsa_switch *ds)
if (IS_ERR_OR_NULL(ds->debugfs_dir))
return -EFAULT;
+ err = dsa_debugfs_create_file(ds, ds->debugfs_dir, "tag_protocol", -1,
+ &dsa_debugfs_tag_protocol_ops);
+ if (err)
+ return err;
+
err = dsa_debugfs_create_file(ds, ds->debugfs_dir, "tree", -1,
&dsa_debugfs_tree_ops);
if (err)
--
2.14.0
^ permalink raw reply related
* [PATCH net-next 11/11] net: dsa: debugfs: add port vlan
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
Add a debug filesystem "vlan" entry to query a port's hardware VLAN
entries through the .port_vlan_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Here are the VLAN entries for a CPU port:
# cat port5/vlan
vid 1
vid 42 pvid
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/debugfs.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 98c5068d20da..b00942368d29 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -286,6 +286,34 @@ static const struct dsa_debugfs_ops dsa_debugfs_tree_ops = {
.read = dsa_debugfs_tree_read,
};
+static int dsa_debugfs_vlan_dump_cb(u16 vid, bool pvid, bool untagged,
+ void *data)
+{
+ struct seq_file *seq = data;
+
+ seq_printf(seq, "vid %d", vid);
+ if (pvid)
+ seq_puts(seq, " pvid");
+ if (untagged)
+ seq_puts(seq, " untagged");
+ seq_puts(seq, "\n");
+
+ return 0;
+}
+
+static int dsa_debugfs_vlan_read(struct dsa_switch *ds, int id,
+ struct seq_file *seq)
+{
+ if (!ds->ops->port_vlan_dump)
+ return -EOPNOTSUPP;
+
+ return ds->ops->port_vlan_dump(ds, id, dsa_debugfs_vlan_dump_cb, seq);
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_vlan_ops = {
+ .read = dsa_debugfs_vlan_read,
+};
+
static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
{
struct dentry *dir;
@@ -318,6 +346,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
if (err)
return err;
+ err = dsa_debugfs_create_file(ds, dir, "vlan", port,
+ &dsa_debugfs_vlan_ops);
+ if (err)
+ return err;
+
return 0;
}
--
2.14.0
^ permalink raw reply related
* [PATCH net-next 10/11] net: dsa: restore VLAN dump
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
This commit defines a dsa_vlan_dump_cb_t callback, similar to the FDB
dump callback and partly reverts commit a0b6b8c9fa3c ("net: dsa: Remove
support for vlan dump from DSA's drivers") to restore the DSA drivers
VLAN dump operations.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/b53/b53_common.c | 41 ++++++++++++++++++++++++++++
drivers/net/dsa/b53/b53_priv.h | 2 ++
drivers/net/dsa/bcm_sf2.c | 1 +
drivers/net/dsa/dsa_loop.c | 38 ++++++++++++++++++++++++++
drivers/net/dsa/microchip/ksz_common.c | 41 ++++++++++++++++++++++++++++
drivers/net/dsa/mv88e6xxx/chip.c | 49 ++++++++++++++++++++++++++++++++++
include/net/dsa.h | 5 ++++
7 files changed, 177 insertions(+)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 274f3679f33d..be0c5fa8bd9b 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1053,6 +1053,46 @@ int b53_vlan_del(struct dsa_switch *ds, int port,
}
EXPORT_SYMBOL(b53_vlan_del);
+int b53_vlan_dump(struct dsa_switch *ds, int port, dsa_vlan_dump_cb_t *cb,
+ void *data)
+{
+ struct b53_device *dev = ds->priv;
+ u16 vid, vid_start = 0, pvid;
+ struct b53_vlan *vl;
+ bool untagged;
+ int err = 0;
+
+ if (is5325(dev) || is5365(dev))
+ vid_start = 1;
+
+ b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &pvid);
+
+ /* Use our software cache for dumps, since we do not have any HW
+ * operation returning only the used/valid VLANs
+ */
+ for (vid = vid_start; vid < dev->num_vlans; vid++) {
+ vl = &dev->vlans[vid];
+
+ if (!vl->valid)
+ continue;
+
+ if (!(vl->members & BIT(port)))
+ continue;
+
+ untagged = false;
+
+ if (vl->untag & BIT(port))
+ untagged = true;
+
+ err = cb(vid, pvid == vid, untagged, data);
+ if (err)
+ break;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(b53_vlan_dump);
+
/* Address Resolution Logic routines */
static int b53_arl_op_wait(struct b53_device *dev)
{
@@ -1503,6 +1543,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
.port_vlan_prepare = b53_vlan_prepare,
.port_vlan_add = b53_vlan_add,
.port_vlan_del = b53_vlan_del,
+ .port_vlan_dump = b53_vlan_dump,
.port_fdb_dump = b53_fdb_dump,
.port_fdb_add = b53_fdb_add,
.port_fdb_del = b53_fdb_del,
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index 01bd8cbe9a3f..2b3e59d80fdb 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -393,6 +393,8 @@ void b53_vlan_add(struct dsa_switch *ds, int port,
struct switchdev_trans *trans);
int b53_vlan_del(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_vlan *vlan);
+int b53_vlan_dump(struct dsa_switch *ds, int port, dsa_vlan_dump_cb_t *cb,
+ void *data);
int b53_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid);
int b53_fdb_del(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index bbcb4053e04e..1907b27297c3 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1021,6 +1021,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
.port_vlan_prepare = b53_vlan_prepare,
.port_vlan_add = b53_vlan_add,
.port_vlan_del = b53_vlan_del,
+ .port_vlan_dump = b53_vlan_dump,
.port_fdb_dump = b53_fdb_dump,
.port_fdb_add = b53_fdb_add,
.port_fdb_del = b53_fdb_del,
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 7819a9fe8321..0407533f725f 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -257,6 +257,43 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
return 0;
}
+static int dsa_loop_port_vlan_dump(struct dsa_switch *ds, int port,
+ dsa_vlan_dump_cb_t *cb, void *data)
+{
+ struct dsa_loop_priv *ps = ds->priv;
+ struct mii_bus *bus = ps->bus;
+ struct dsa_loop_vlan *vl;
+ u16 vid, vid_start = 0;
+ bool pvid, untagged;
+ int err = 0;
+
+ dev_dbg(ds->dev, "%s\n", __func__);
+
+ /* Just do a sleeping operation to make lockdep checks effective */
+ mdiobus_read(bus, ps->port_base + port, MII_BMSR);
+
+ for (vid = vid_start; vid < DSA_LOOP_VLANS; vid++) {
+ vl = &ps->vlans[vid];
+
+ if (!(vl->members & BIT(port)))
+ continue;
+
+ untagged = false;
+ pvid = false;
+
+ if (vl->untagged & BIT(port))
+ untagged = true;
+ if (ps->pvid == vid)
+ pvid = true;
+
+ err = cb(vid, pvid, untagged, data);
+ if (err)
+ break;
+ }
+
+ return err;
+}
+
static const struct dsa_switch_ops dsa_loop_driver = {
.get_tag_protocol = dsa_loop_get_protocol,
.setup = dsa_loop_setup,
@@ -273,6 +310,7 @@ static const struct dsa_switch_ops dsa_loop_driver = {
.port_vlan_prepare = dsa_loop_port_vlan_prepare,
.port_vlan_add = dsa_loop_port_vlan_add,
.port_vlan_del = dsa_loop_port_vlan_del,
+ .port_vlan_dump = dsa_loop_port_vlan_dump,
};
static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 56cd6d365352..52c7849acc3c 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -638,6 +638,46 @@ static int ksz_port_vlan_del(struct dsa_switch *ds, int port,
return 0;
}
+static int ksz_port_vlan_dump(struct dsa_switch *ds, int port,
+ dsa_vlan_dump_cb_t *cb, void *data)
+{
+ struct ksz_device *dev = ds->priv;
+ struct vlan_table *vlan_cache;
+ bool pvid, untagged;
+ u16 val;
+ int vid;
+ int err = 0;
+
+ mutex_lock(&dev->vlan_mutex);
+
+ /* use dev->vlan_cache due to lack of searching valid vlan entry */
+ for (vid = 0; vid < dev->num_vlans; vid++) {
+ vlan_cache = &dev->vlan_cache[vid];
+
+ if (!(vlan_cache->table[0] & VLAN_VALID))
+ continue;
+
+ untagged = false;
+ pvid = false;
+
+ if (vlan_cache->table[2] & BIT(port)) {
+ if (vlan_cache->table[1] & BIT(port))
+ untagged = true;
+ ksz_pread16(dev, port, REG_PORT_DEFAULT_VID, &val);
+ if (vid == (val & 0xFFFFF))
+ pvid = true;
+
+ err = cb(vid, pvid, untagged, data);
+ if (err)
+ break;
+ }
+ }
+
+ mutex_unlock(&dev->vlan_mutex);
+
+ return err;
+}
+
struct alu_struct {
/* entry 1 */
u8 is_static:1;
@@ -1068,6 +1108,7 @@ static const struct dsa_switch_ops ksz_switch_ops = {
.port_vlan_prepare = ksz_port_vlan_prepare,
.port_vlan_add = ksz_port_vlan_add,
.port_vlan_del = ksz_port_vlan_del,
+ .port_vlan_dump = ksz_port_vlan_dump,
.port_fdb_dump = ksz_port_fdb_dump,
.port_fdb_add = ksz_port_fdb_add,
.port_fdb_del = ksz_port_fdb_del,
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 2ad32734b6f6..dc762e85c556 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1011,6 +1011,54 @@ static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
return chip->info->ops->vtu_loadpurge(chip, entry);
}
+static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
+ dsa_vlan_dump_cb_t *cb, void *data)
+{
+ struct mv88e6xxx_chip *chip = ds->priv;
+ struct mv88e6xxx_vtu_entry next = {
+ .vid = chip->info->max_vid,
+ };
+ bool untagged;
+ u16 pvid;
+ int err;
+
+ if (!chip->info->max_vid)
+ return -EOPNOTSUPP;
+
+ mutex_lock(&chip->reg_lock);
+
+ err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
+ if (err)
+ goto unlock;
+
+ do {
+ err = mv88e6xxx_vtu_getnext(chip, &next);
+ if (err)
+ break;
+
+ if (!next.valid)
+ break;
+
+ if (next.member[port] ==
+ MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
+ continue;
+
+ untagged = false;
+ if (next.member[port] ==
+ MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED)
+ untagged = true;
+
+ err = cb(next.vid, next.vid == pvid, untagged, data);
+ if (err)
+ break;
+ } while (next.vid < chip->info->max_vid);
+
+unlock:
+ mutex_unlock(&chip->reg_lock);
+
+ return err;
+}
+
static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
{
DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
@@ -3820,6 +3868,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
.port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
.port_vlan_add = mv88e6xxx_port_vlan_add,
.port_vlan_del = mv88e6xxx_port_vlan_del,
+ .port_vlan_dump = mv88e6xxx_port_vlan_dump,
.port_fdb_add = mv88e6xxx_port_fdb_add,
.port_fdb_del = mv88e6xxx_port_fdb_del,
.port_fdb_dump = mv88e6xxx_port_fdb_dump,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 1fd419031948..317e0cd4bf70 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -291,6 +291,8 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
/* FDB (and MDB) dump callback */
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data);
+typedef int dsa_vlan_dump_cb_t(u16 vid, bool pvid, bool untagged, void *data);
+
struct dsa_switch_ops {
/*
* Legacy probing.
@@ -397,6 +399,9 @@ struct dsa_switch_ops {
struct switchdev_trans *trans);
int (*port_vlan_del)(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_vlan *vlan);
+ int (*port_vlan_dump)(struct dsa_switch *ds, int port,
+ dsa_vlan_dump_cb_t *cb, void *data);
+
/*
* Forwarding database
*/
--
2.14.0
^ permalink raw reply related
* [PATCH net-next 09/11] net: dsa: debugfs: add port mdb
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
Add a debug filesystem "mdb" entry to query a port's hardware MDB
entries through the .port_mdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/debugfs.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 8204c62dc9c1..98c5068d20da 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -140,6 +140,20 @@ static const struct dsa_debugfs_ops dsa_debugfs_fdb_ops = {
.read = dsa_debugfs_fdb_read,
};
+static int dsa_debugfs_mdb_read(struct dsa_switch *ds, int id,
+ struct seq_file *seq)
+{
+ if (!ds->ops->port_mdb_dump)
+ return -EOPNOTSUPP;
+
+ /* same callback as for FDB dump */
+ return ds->ops->port_mdb_dump(ds, id, dsa_debugfs_fdb_dump_cb, seq);
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_mdb_ops = {
+ .read = dsa_debugfs_mdb_read,
+};
+
static void dsa_debugfs_regs_read_count(struct dsa_switch *ds, int id,
struct seq_file *seq, int count)
{
@@ -289,6 +303,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
if (err)
return err;
+ err = dsa_debugfs_create_file(ds, dir, "mdb", port,
+ &dsa_debugfs_mdb_ops);
+ if (err)
+ return err;
+
err = dsa_debugfs_create_file(ds, dir, "regs", port,
&dsa_debugfs_regs_ops);
if (err)
--
2.14.0
^ permalink raw reply related
* [PATCH net-next 08/11] net: dsa: restore mdb dump
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
The same dsa_fdb_dump_cb_t callback is used since there is no
distinction to do between FDB and MDB entries at this layer.
Implement mv88e6xxx_port_mdb_dump so that multicast addresses associated
to a switch port can be dumped.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 33 +++++++++++++++++++++++++--------
include/net/dsa.h | 3 +++
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 918d8f0fe091..2ad32734b6f6 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1380,7 +1380,7 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
}
static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
- u16 fid, u16 vid, int port,
+ u16 fid, u16 vid, int port, bool mc,
dsa_fdb_dump_cb_t *cb, void *data)
{
struct mv88e6xxx_atu_entry addr;
@@ -1401,11 +1401,14 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
if (addr.trunk || (addr.portvec & BIT(port)) == 0)
continue;
- if (!is_unicast_ether_addr(addr.mac))
+ if ((is_unicast_ether_addr(addr.mac) && mc) ||
+ (is_multicast_ether_addr(addr.mac) && !mc))
continue;
- is_static = (addr.state ==
- MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
+ is_static = addr.state == mc ?
+ MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC :
+ MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC;
+
err = cb(addr.mac, vid, is_static, data);
if (err)
return err;
@@ -1415,7 +1418,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
}
static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
- dsa_fdb_dump_cb_t *cb, void *data)
+ bool mc, dsa_fdb_dump_cb_t *cb, void *data)
{
struct mv88e6xxx_vtu_entry vlan = {
.vid = chip->info->max_vid,
@@ -1428,7 +1431,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
if (err)
return err;
- err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
+ err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, mc, cb, data);
if (err)
return err;
@@ -1442,7 +1445,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
break;
err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
- cb, data);
+ mc, cb, data);
if (err)
return err;
} while (vlan.vid < chip->info->max_vid);
@@ -1457,7 +1460,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
int err;
mutex_lock(&chip->reg_lock);
- err = mv88e6xxx_port_db_dump(chip, port, cb, data);
+ err = mv88e6xxx_port_db_dump(chip, port, false, cb, data);
mutex_unlock(&chip->reg_lock);
return err;
@@ -3777,6 +3780,19 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
return err;
}
+static int mv88e6xxx_port_mdb_dump(struct dsa_switch *ds, int port,
+ dsa_fdb_dump_cb_t *cb, void *data)
+{
+ struct mv88e6xxx_chip *chip = ds->priv;
+ int err;
+
+ mutex_lock(&chip->reg_lock);
+ err = mv88e6xxx_port_db_dump(chip, port, true, cb, data);
+ mutex_unlock(&chip->reg_lock);
+
+ return err;
+}
+
static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
.probe = mv88e6xxx_drv_probe,
.get_tag_protocol = mv88e6xxx_get_tag_protocol,
@@ -3810,6 +3826,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
.port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
.port_mdb_add = mv88e6xxx_port_mdb_add,
.port_mdb_del = mv88e6xxx_port_mdb_del,
+ .port_mdb_dump = mv88e6xxx_port_mdb_dump,
.crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
.crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
};
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4ef5d38755d9..1fd419031948 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -288,6 +288,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
return ds->rtable[dst->cpu_dp->ds->index];
}
+/* FDB (and MDB) dump callback */
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data);
struct dsa_switch_ops {
@@ -417,6 +418,8 @@ struct dsa_switch_ops {
struct switchdev_trans *trans);
int (*port_mdb_del)(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb);
+ int (*port_mdb_dump)(struct dsa_switch *ds, int port,
+ dsa_fdb_dump_cb_t *cb, void *data);
/*
* RXNFC
*/
--
2.14.0
^ permalink raw reply related
* [PATCH net-next 07/11] net: dsa: debugfs: add port fdb
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
Add a debug filesystem "fdb" entry to query a port's hardware FDB
entries through the .port_fdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
# cat port1/fdb
vid 0 12:34:56:78:90:ab static unicast
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 012fcf466cc1..8204c62dc9c1 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -10,6 +10,7 @@
*/
#include <linux/debugfs.h>
+#include <linux/etherdevice.h>
#include <linux/seq_file.h>
#include "dsa_priv.h"
@@ -109,6 +110,36 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
return 0;
}
+static int dsa_debugfs_fdb_dump_cb(const unsigned char *addr, u16 vid,
+ bool is_static, void *data)
+{
+ struct seq_file *seq = data;
+ int i;
+
+ seq_printf(seq, "vid %d", vid);
+ for (i = 0; i < ETH_ALEN; i++)
+ seq_printf(seq, "%s%02x", i ? ":" : " ", addr[i]);
+ seq_printf(seq, " %s", is_static ? "static" : "dynamic");
+ seq_printf(seq, " %s", is_unicast_ether_addr(addr) ?
+ "unicast" : "multicast");
+ seq_puts(seq, "\n");
+
+ return 0;
+}
+
+static int dsa_debugfs_fdb_read(struct dsa_switch *ds, int id,
+ struct seq_file *seq)
+{
+ if (!ds->ops->port_fdb_dump)
+ return -EOPNOTSUPP;
+
+ return ds->ops->port_fdb_dump(ds, id, dsa_debugfs_fdb_dump_cb, seq);
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_fdb_ops = {
+ .read = dsa_debugfs_fdb_read,
+};
+
static void dsa_debugfs_regs_read_count(struct dsa_switch *ds, int id,
struct seq_file *seq, int count)
{
@@ -253,6 +284,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
if (IS_ERR_OR_NULL(dir))
return -EFAULT;
+ err = dsa_debugfs_create_file(ds, dir, "fdb", port,
+ &dsa_debugfs_fdb_ops);
+ if (err)
+ return err;
+
err = dsa_debugfs_create_file(ds, dir, "regs", port,
&dsa_debugfs_regs_ops);
if (err)
--
2.14.0
^ permalink raw reply related
* [PATCH net-next 06/11] net: dsa: debugfs: add port registers
From: Vivien Didelot @ 2017-08-14 22:22 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Egil Hjelmeland, John Crispin, Woojung Huh,
Sean Wang, Volodymyr Bendiuga, Nikita Yushchenko,
Maxime Hadjinlian, Chris Healy, Maxim Uvarov, Stefan Eichenberger,
Jason Cobham, Juergen Borleis, Tobias Waldekranz, Vivien Didelot
In-Reply-To: <20170814222242.10643-1-vivien.didelot@savoirfairelinux.com>
Add a debug filesystem "regs" entry to query a port's hardware registers
through the .get_regs_len and .get_regs_len switch operations.
This is very convenient because it allows one to dump the registers of
DSA links, which are not exposed to userspace.
Here are the registers of a zii-rev-b CPU and DSA ports:
# pr -mt switch0/port{5,6}/regs
0: 4e07 0: 4d04
1: 403e 1: 003d
2: 0000 2: 0000
3: 3521 3: 3521
4: 0533 4: 373f
5: 8000 5: 0000
6: 005f 6: 003f
7: 002a 7: 002a
8: 2080 8: 2080
9: 0001 9: 0001
10: 0000 10: 0000
11: 0020 11: 0000
12: 0000 12: 0000
13: 0000 13: 0000
14: 0000 14: 0000
15: 9100 15: dada
16: 0000 16: 0000
17: 0000 17: 0000
18: 0000 18: 0000
19: 0000 19: 00d8
20: 0000 20: 0000
21: 0000 21: 0000
22: 0022 22: 0000
23: 0000 23: 0000
24: 3210 24: 3210
25: 7654 25: 7654
26: 0000 26: 0000
27: 8000 27: 8000
28: 0000 28: 0000
29: 0000 29: 0000
30: 0000 30: 0000
31: 0000 31: 0000
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 5f91b4423404..012fcf466cc1 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -109,6 +109,40 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
return 0;
}
+static void dsa_debugfs_regs_read_count(struct dsa_switch *ds, int id,
+ struct seq_file *seq, int count)
+{
+ u16 data[count * ETH_GSTRING_LEN];
+ struct ethtool_regs regs;
+ int i;
+
+ ds->ops->get_regs(ds, id, ®s, data);
+
+ for (i = 0; i < count / 2; i++)
+ seq_printf(seq, "%2d: %04x\n", i, data[i]);
+}
+
+static int dsa_debugfs_regs_read(struct dsa_switch *ds, int id,
+ struct seq_file *seq)
+{
+ int count;
+
+ if (!ds->ops->get_regs_len || !ds->ops->get_regs)
+ return -EOPNOTSUPP;
+
+ count = ds->ops->get_regs_len(ds, id);
+ if (count < 0)
+ return count;
+
+ dsa_debugfs_regs_read_count(ds, id, seq, count);
+
+ return 0;
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_regs_ops = {
+ .read = dsa_debugfs_regs_read,
+};
+
static void dsa_debugfs_stats_read_count(struct dsa_switch *ds, int id,
struct seq_file *seq, int count)
{
@@ -219,6 +253,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
if (IS_ERR_OR_NULL(dir))
return -EFAULT;
+ err = dsa_debugfs_create_file(ds, dir, "regs", port,
+ &dsa_debugfs_regs_ops);
+ if (err)
+ return err;
+
err = dsa_debugfs_create_file(ds, dir, "stats", port,
&dsa_debugfs_stats_ops);
if (err)
--
2.14.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox