[Coin] IPv6 Switch ML @ IETF 105 Hackathon

<hemant@mnkcg.com> Sun, 21 July 2019 10:13 UTC

Return-Path: <hemant@mnkcg.com>
X-Original-To: coin@ietfa.amsl.com
Delivered-To: coin@ietfa.amsl.com
Received: from localhost (localhost []) by ietfa.amsl.com (Postfix) with ESMTP id 3DDAC120058 for <coin@ietfa.amsl.com>; Sun, 21 Jul 2019 03:13:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([]) by localhost (ietfa.amsl.com []) (amavisd-new, port 10024) with ESMTP id OwfVyLG4Kvwn for <coin@ietfa.amsl.com>; Sun, 21 Jul 2019 03:13:42 -0700 (PDT)
Received: from web033.dnchosting.com (web033.dnchosting.com []) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0685D12004A for <coin@irtf.org>; Sun, 21 Jul 2019 03:13:41 -0700 (PDT)
Received: from c-98-229-163-41.hsd1.ma.comcast.net ([]:51257 helo=hemantPC) by web033.dnchosting.com with esmtpsa (TLSv1.2:AES128-SHA256:128) (Exim 4.92) (envelope-from <hemant@mnkcg.com>) id 1hp8qT-00DL1p-7L for coin@irtf.org; Sun, 21 Jul 2019 05:13:39 -0500
Reply-To: <hemant@mnkcg.com>
From: <hemant@mnkcg.com>
To: <coin@irtf.org>
Date: Sun, 21 Jul 2019 06:13:50 -0400
Organization: MNK Consulting
Message-ID: <014401d53fac$febb9a10$fc32ce30$@mnkcg.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_NextPart_000_0145_01D53F8B.77ABCED0"
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AdU/p+5FTt5w/ONNTVKaMU9nPqOgRA==
Content-Language: en-us
X-OutGoing-Spam-Status: No, score=-0.2
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - web033.dnchosting.com
X-AntiAbuse: Original Domain - irtf.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - mnkcg.com
X-Get-Message-Sender-Via: web033.dnchosting.com: authenticated_id: hemant@mnkcg.com
X-Authenticated-Sender: web033.dnchosting.com: hemant@mnkcg.com
X-From-Rewrite: unmodified, already matched
Archived-At: <https://mailarchive.ietf.org/arch/msg/coin/0ywn5VdEO7GI4xFohrZrebtXZPI>
Subject: [Coin] IPv6 Switch ML @ IETF 105 Hackathon
X-BeenThere: coin@irtf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "COIN: Computing in the Network" <coin.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/coin>, <mailto:coin-request@irtf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/coin/>
List-Post: <mailto:coin@irtf.org>
List-Help: <mailto:coin-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/coin>, <mailto:coin-request@irtf.org?subject=subscribe>
X-List-Received-Date: Sun, 21 Jul 2019 10:13:44 -0000

I ran into interesting issues writing Algorithm 1 from
https://arxiv.org/pdf/1903.06701.pdf  at the hackathon yesterday.  It would
be good for any author of the paper to chime in.


First, I have read several research papers using P4 which publish P4 or
pseudo P4 code in the paper.  The switch ML paper does not.  It would have
been good to publish the code because P4 is jumping through hoops
implementing Algorithm 1 for switch with bmv2 simulator.  I used
public-domain p4lang/p4c and its bmv2 simple_switch simulation to test P4
code at the hackathon.


I used a P4 header stack (array) to represent the vector.  P4 has no for
loops, so how does one add elements of the vector? There is the one way.
You can have one action that adds 1 header, another that adds 2, another
that adds 3, etc., and choose between them at run time via a table lookup.
Even with a vector with 20-50 elements, writing such P4 code manually is
risky.  One has to write a Python script to generate such code.  The paper
did not think of it, but an alternative exists.  With every element in the
vector, use a new 1-byte field.  The field has values 0 or 1.  1 represents
bos (bottom of stack) like what MPLS uses.  The last element has bos set to
1.  Then, one has a termination condition in the P4 parser to terminate
recursive parsing of vector.  As the parser is recursing through the vector,
add the vector elements and save sum in metadata.  I didn't use a bit for
bos because the p4c bmv2 model accepts a header on byte boundary.  I plan to
add such details to my draft in the next revision:


The same p4c bmv2 model, also, does not accept an index into array if the
index is a run-time value.  The p4-16 specification allows run-time index.
Algorithm 1  in the paper uses p.idx which is a run-time value.  Again, one
has to use P4 tables.  Include the run-time variable index as a table search
key, which selects between several different actions that are identical,
except for the constant array index values they use.  This gets crazy with
128 or 512 indices in the paper.  Again, one would have to generate P4 code
to avoid mistakes cut-and-pasting code.  For 128 indices with some bit
shifting, maybe we reduces indices to 32.   If the Barefoot Tofino asic
allows run-time index into array, then it's better to use Tofino simulator
rather than bmv2 simulator.


I am not working in the hackathon today.  I have personal matters to take
care of on Sunday.