From patchwork Tue May 5 19:20:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 219852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BC47C47259 for ; Tue, 5 May 2020 19:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19320206CC for ; Tue, 5 May 2020 19:21:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ARwEP+Gm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729000AbgEETVP (ORCPT ); Tue, 5 May 2020 15:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728749AbgEETVM (ORCPT ); Tue, 5 May 2020 15:21:12 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67BAFC061A10 for ; Tue, 5 May 2020 12:21:10 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e16so4097266wra.7 for ; Tue, 05 May 2020 12:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V8VssKTGe0n+GWzx49VVHpJibdflGSIBy499NinEmyM=; b=ARwEP+Gm40kGrsT55TNRVmAUARaHmAHwKaMQaEqPBUOF4qowO7WeDlFmmDHVAZGjWb xpZYx5y0Gnv/HTelwwfAt1r3KlyBra3NwmR2rsx25YcOFvaOsUcxcS1eD8L5sD1N8pA3 0QmzdNBvvnBIXJzvb8+jF02qOlJJygtLNimbzJBzf4IRjDH05VO4PK3zxFE1oLYFNYRw I2FNdC0LuZQAg2AHEb+KYg32u2siw7vgA5hCKOga/eGwQUIZOrFXY+vJ4W1ZStIz/K+T 54+qUYKm3udJkjPQGQmaJMRIn3nFFEBv+IPq8WyJ3rsq2RWEm6NHaQGPBA29VQXRxwp6 Pixw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V8VssKTGe0n+GWzx49VVHpJibdflGSIBy499NinEmyM=; b=l3enzp2jrkLaESezESsfoHQj7txEScXSS2nuJYYrzwu70e5VUfCASAHOHJIl26ZvBa BSxKQdAJh2avNP9S6hyaBC8LOGF/miZp9oqK4g+Wj+cYEbng8/2s5LRtSpf/ovMEHz0Q M4rEr5LihQgM+6Z3pwv4CFcTiDXPdany80EJgYTyqeUcEyCpLRYgyUtFRuffXkL/Q8Wg o+SlyxHJK/xm5p8tVlRWZUHQGJOBmZsqj7eIwMAtkFTmEC7Zw0cDWA+51RqKnMRJzbns OK4tBIJjUXrH+t4R19Ptiz9arNrDZjiLxpqzheMwlTPP1g9fVOZt2l27K8tUDXa5XrGl sqsw== X-Gm-Message-State: AGi0PubBpPT9sNdlmqJGH2Su4DDQwf54iv89wDxxf7O/dCW+pM3NjyG7 ktCMJx/nR9rhk2JQtEgHtQZOtXhV X-Google-Smtp-Source: APiQypJbvoyzkvr04F2SlGjJnfXIsUTyWDCjKeWQuDKqL0AZVYdatlmQ66am60w4BIrchAny3+//SQ== X-Received: by 2002:a5d:6692:: with SMTP id l18mr5629619wru.423.1588706468888; Tue, 05 May 2020 12:21:08 -0700 (PDT) Received: from localhost.localdomain ([86.121.118.29]) by smtp.gmail.com with ESMTPSA id z16sm5090681wrl.0.2020.05.05.12.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 12:21:08 -0700 (PDT) From: Vladimir Oltean To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com, vinicius.gomes@intel.com, po.liu@nxp.com Subject: [PATCH v3 net-next 6/6] docs: net: dsa: sja1105: document intended usage of virtual links Date: Tue, 5 May 2020 22:20:57 +0300 Message-Id: <20200505192057.9086-7-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200505192057.9086-1-olteanv@gmail.com> References: <20200505192057.9086-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean Add some verbiage describing how the hardware features of the switch are exposed to users through tc-flower. Signed-off-by: Vladimir Oltean --- Changes from v2: None. Changes from v1: None. Changes from RFC: Patch is new. Documentation/networking/dsa/sja1105.rst | 116 +++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/Documentation/networking/dsa/sja1105.rst b/Documentation/networking/dsa/sja1105.rst index 64553d8d91cb..34581629dd3f 100644 --- a/Documentation/networking/dsa/sja1105.rst +++ b/Documentation/networking/dsa/sja1105.rst @@ -230,6 +230,122 @@ simultaneously on two ports. The driver checks the consistency of the schedules against this restriction and errors out when appropriate. Schedule analysis is needed to avoid this, which is outside the scope of the document. +Routing actions (redirect, trap, drop) +-------------------------------------- + +The switch is able to offload flow-based redirection of packets to a set of +destination ports specified by the user. Internally, this is implemented by +making use of Virtual Links, a TTEthernet concept. + +The driver supports 2 types of keys for Virtual Links: + +- VLAN-aware virtual links: these match on destination MAC address, VLAN ID and + VLAN PCP. +- VLAN-unaware virtual links: these match on destination MAC address only. + +The VLAN awareness state of the bridge (vlan_filtering) cannot be changed while +there are virtual link rules installed. + +Composing multiple actions inside the same rule is supported. When only routing +actions are requested, the driver creates a "non-critical" virtual link. When +the action list also contains tc-gate (more details below), the virtual link +becomes "time-critical" (draws frame buffers from a reserved memory partition, +etc). + +The 3 routing actions that are supported are "trap", "drop" and "redirect". + +Example 1: send frames received on swp2 with a DA of 42:be:24:9b:76:20 to the +CPU and to swp3. This type of key (DA only) when the port's VLAN awareness +state is off:: + + tc qdisc add dev swp2 clsact + tc filter add dev swp2 ingress flower skip_sw dst_mac 42:be:24:9b:76:20 \ + action mirred egress redirect dev swp3 \ + action trap + +Example 2: drop frames received on swp2 with a DA of 42:be:24:9b:76:20, a VID +of 100 and a PCP of 0:: + + tc filter add dev swp2 ingress protocol 802.1Q flower skip_sw \ + dst_mac 42:be:24:9b:76:20 vlan_id 100 vlan_prio 0 action drop + +Time-based ingress policing +--------------------------- + +The TTEthernet hardware abilities of the switch can be constrained to act +similarly to the Per-Stream Filtering and Policing (PSFP) clause specified in +IEEE 802.1Q-2018 (formerly 802.1Qci). This means it can be used to perform +tight timing-based admission control for up to 1024 flows (identified by a +tuple composed of destination MAC address, VLAN ID and VLAN PCP). Packets which +are received outside their expected reception window are dropped. + +This capability can be managed through the offload of the tc-gate action. As +routing actions are intrinsic to virtual links in TTEthernet (which performs +explicit routing of time-critical traffic and does not leave that in the hands +of the FDB, flooding etc), the tc-gate action may never appear alone when +asking sja1105 to offload it. One (or more) redirect or trap actions must also +follow along. + +Example: create a tc-taprio schedule that is phase-aligned with a tc-gate +schedule (the clocks must be synchronized by a 1588 application stack, which is +outside the scope of this document). No packet delivered by the sender will be +dropped. Note that the reception window is larger than the transmission window +(and much more so, in this example) to compensate for the packet propagation +delay of the link (which can be determined by the 1588 application stack). + +Receiver (sja1105):: + + tc qdisc add dev swp2 clsact + now=$(phc_ctl /dev/ptp1 get | awk '/clock time is/ {print $5}') && \ + sec=$(echo $now | awk -F. '{print $1}') && \ + base_time="$(((sec + 2) * 1000000000))" && \ + echo "base time ${base_time}" + tc filter add dev swp2 ingress flower skip_sw \ + dst_mac 42:be:24:9b:76:20 \ + action gate base-time ${base_time} \ + sched-entry OPEN 60000 -1 -1 \ + sched-entry CLOSE 40000 -1 -1 \ + action trap + +Sender:: + + now=$(phc_ctl /dev/ptp0 get | awk '/clock time is/ {print $5}') && \ + sec=$(echo $now | awk -F. '{print $1}') && \ + base_time="$(((sec + 2) * 1000000000))" && \ + echo "base time ${base_time}" + tc qdisc add dev eno0 parent root taprio \ + num_tc 8 \ + map 0 1 2 3 4 5 6 7 \ + queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \ + base-time ${base_time} \ + sched-entry S 01 50000 \ + sched-entry S 00 50000 \ + flags 2 + +The engine used to schedule the ingress gate operations is the same that the +one used for the tc-taprio offload. Therefore, the restrictions regarding the +fact that no two gate actions (either tc-gate or tc-taprio gates) may fire at +the same time (during the same 200 ns slot) still apply. + +To come in handy, it is possible to share time-triggered virtual links across +more than 1 ingress port, via flow blocks. In this case, the restriction of +firing at the same time does not apply because there is a single schedule in +the system, that of the shared virtual link:: + + tc qdisc add dev swp2 ingress_block 1 clsact + tc qdisc add dev swp3 ingress_block 1 clsact + tc filter add block 1 flower skip_sw dst_mac 42:be:24:9b:76:20 \ + action gate index 2 \ + base-time 0 \ + sched-entry OPEN 50000000 -1 -1 \ + sched-entry CLOSE 50000000 -1 -1 \ + action trap + +Hardware statistics for each flow are also available ("pkts" counts the number +of dropped frames, which is a sum of frames dropped due to timing violations, +lack of destination ports and MTU enforcement checks). Byte-level counters are +not available. + Device Tree bindings and board design =====================================