From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B1AAA0524; Mon, 31 May 2021 04:28:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1ADE940140; Mon, 31 May 2021 04:28:16 +0200 (CEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 8261C4003E for ; Mon, 31 May 2021 04:28:15 +0200 (CEST) Received: by mail-pj1-f46.google.com with SMTP id f3-20020a17090a4a83b02901619627235bso3619057pjh.1 for ; Sun, 30 May 2021 19:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eHtZdd/otvM44lI6cb4w9P9HXULGn0emtuZZJhLas44=; b=RJDUtf5kLe2S14sIY9X9HxZ1hXUfnY3qwqeInlJjzrxAOW78q/oPcjh+aK/pHtcFTK qVQDgigH2GRLDZdbzUay1WA7Vw572J6rsa0kJHJTDJ0PArrOvm/7ASFRMziSavPos8EA SY+3Y94IM3GWgVZedrx4Ep2PyYA28z38EAU+jJ4dRhbZepLtUavXiMXGZn/RLV1f4bg7 5p1HfKgRLwkmWT/5P8Z5M2a7qK3CkKwfKQFTYMHWFINSPgIoQoVrcjTtfBiOFy6eObU5 1UEBqsMMj8njJFUvdiyMuRmlRXGTYjIkc+pGrHKJIFeWYcPE5A2c3ihE5CP/FCCnzYz/ RmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eHtZdd/otvM44lI6cb4w9P9HXULGn0emtuZZJhLas44=; b=Pzksk6DGnsSDhWdfpVYZUCnMr37M/JtBfiHpqJzelbc132lTflg1WduBgv4B7UgUmV /7cqZ5DuKLjO9m/sHPNXAgmA3p5/o+ivlkjNL3v+un9SlJaveKCoyZxIKMsT1L7P4YCA bdMYnLIi2z4y4dTdOH0zI2LxE72mOJKwtgshGSjfaOVl3Pv+Pxry2Br/CKPjCmSx/AyX B364hgsabMRLFcsTi9QR6WlLe/yHe6mauPienY6Xe64x+T5mH1nMi5cQ9LCzo8uFe/a/ jujWY780/LLdY5De3R0X4PWhT/OZ357bl5/X4sVI03rffhEqOgLnSTOFHwdoHE/Z1DRa 16lA== X-Gm-Message-State: AOAM532bXd7yjCq50ZcO74l/sWcdLGZShu6ry2cjvnFgg/PpHe9reKIz FHxG+HIXV3j2OApRLD1shsFRpw== X-Google-Smtp-Source: ABdhPJyI58bLqe8HYOoxT+UANXtqi4tv9vZplLWTKj2A0YGqVeO54GILxTCBWVDVVSnEeb2e6GIe0Q== X-Received: by 2002:a17:902:e00e:b029:ef:5f1c:18a8 with SMTP id o14-20020a170902e00eb02900ef5f1c18a8mr18574250plo.38.1622428094547; Sun, 30 May 2021 19:28:14 -0700 (PDT) Received: from hermes.local (76-14-218-44.or.wavecable.com. [76.14.218.44]) by smtp.gmail.com with ESMTPSA id 125sm9188529pfg.52.2021.05.30.19.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 19:28:14 -0700 (PDT) Date: Sun, 30 May 2021 19:28:05 -0700 From: Stephen Hemminger To: Ori Kam Cc: Ivan Malov , "dev@dpdk.org" , NBU-Contact-Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella , Neil Horman Message-ID: <20210530192805.71f5a8ef@hermes.local> In-Reply-To: References: <20210527082504.3495-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: add support for testpmd-compliant flow rule dumping X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sun, 30 May 2021 07:27:32 +0000 Ori Kam wrote: > > > > DPDK applications (for example, OvS) or tests which use RTE flow API need to > > log created or rejected flow rules to help to recognise what goes right or > > wrong. From this standpoint, testpmd-compliant format is nice for the > > purpose because it allows to copy-paste the flow rules and debug using > > testpmd. > > > > Recognisable pattern items: > > VOID, VF, PF, PHY_PORT, PORT_ID, ETH, VLAN, IPV4, IPV6, UDP, TCP, VXLAN, > > NVGRE, GENEVE, MARK, PPPOES, PPPOED. > > > > Recognisable actions: > > VOID, JUMP, MARK, FLAG, QUEUE, DROP, COUNT, RSS, PF, VF, PHY_PORT, > > PORT_ID, OF_POP_VLAN, OF_PUSH_VLAN, OF_SET_VLAN_VID, > > OF_SET_VLAN_PCP, VXLAN_ENCAP, VXLAN_DECAP. > > > > Recognisable RSS types (action RSS): > > IPV4, FRAG_IPV4, NONFRAG_IPV4_TCP, NONFRAG_IPV4_UDP, > > NONFRAG_IPV4_OTHER, IPV6, FRAG_IPV6, NONFRAG_IPV6_TCP, > > NONFRAG_IPV6_UDP, NONFRAG_IPV6_OTHER, IPV6_EX, IPV6_TCP_EX, > > IPV6_UDP_EX, L3_SRC_ONLY, L3_DST_ONLY, L4_SRC_ONLY, L4_DST_ONLY. > > > > Unrecognised parts of the flow specification are represented by tokens > > "{unknown}" and "{unknown bits}". Interested parties are welcome to > > extend this tool to recognise more items and actions. > > > > Signed-off-by: Ivan Malov > > --- > > lib/ethdev/meson.build | 1 + > > lib/ethdev/rte_flow.h | 33 + > > lib/ethdev/rte_flow_snprint.c | 1681 > > +++++++++++++++++++++++++++++++++ > > lib/ethdev/version.map | 3 + > > 4 files changed, 1718 insertions(+) > > create mode 100644 lib/ethdev/rte_flow_snprint.c > > > > diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build index > > 0205c853df..97bba4fa1b 100644 > > --- a/lib/ethdev/meson.build > > +++ b/lib/ethdev/meson.build > > @@ -8,6 +8,7 @@ sources = files( > > 'rte_class_eth.c', > > 'rte_ethdev.c', > > 'rte_flow.c', > > + 'rte_flow_snprint.c', > > 'rte_mtr.c', > > 'rte_tm.c', > > ) > > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index > > 961a5884fe..cd5e9ef631 100644 > > --- a/lib/ethdev/rte_flow.h > > +++ b/lib/ethdev/rte_flow.h > > @@ -4288,6 +4288,39 @@ rte_flow_tunnel_item_release(uint16_t port_id, > > struct rte_flow_item *items, > > uint32_t num_of_items, > > struct rte_flow_error *error); > > + > > +/** > > + * @warning > > + * @b EXPERIMENTAL: this API may change without prior notice > > + * > > + * Dump testpmd-compliant textual representation of the flow rule. > > + * Invoke this with zero-size buffer to learn the string size and > > + * invoke this for the second time to actually dump the flow rule. > > + * The buffer size on the second invocation = the string size + 1. > > + * > > + * @param[out] buf > > + * Buffer to save the dump in, or NULL > > + * @param buf_size > > + * Buffer size, or 0 > > + * @param[out] nb_chars_total > > + * Resulting string size (excluding the terminating null byte) > > + * @param[in] attr > > + * Flow rule attributes. > > + * @param[in] pattern > > + * Pattern specification (list terminated by the END pattern item). > > + * @param[in] actions > > + * Associated actions (list terminated by the END action). > > + * > > + * @return > > + * 0 on success, a negative errno value otherwise > > + */ > > +__rte_experimental > > +int > > +rte_flow_snprint(char *buf, size_t buf_size, size_t *nb_chars_total, > > + const struct rte_flow_attr *attr, > > + const struct rte_flow_item pattern[], > > + const struct rte_flow_action actions[]); > > + The code would be clearer and simpler if you adopted the same return value as snprintf. Then lots of places could be just tail calls and the nb_chars_total would be unnecessary.