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 3545FA00C5; Tue, 26 Jul 2022 23:36:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C48D340F19; Tue, 26 Jul 2022 23:36:53 +0200 (CEST) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by mails.dpdk.org (Postfix) with ESMTP id 1132740E25 for ; Tue, 26 Jul 2022 23:36:52 +0200 (CEST) Received: by mail-ej1-f52.google.com with SMTP id va17so28453185ejb.0 for ; Tue, 26 Jul 2022 14:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MvkvhCe7/dzkxWCxtZztV93bf1c+CHOSidF0+15IJiE=; b=IB/zk012EHlmBys3fiUo31uj8+CVhbqnG47WnfCo/dT5+Di+rjN5Bh7zgB5Fi7gg+2 srrYSTVtNm7732m6+fDA8tLzrpT0dFF8rG8fSOgu+wV3KjBERDm57bzvtk3VwDnlBljN vs4awlJk5ds3M4aQZDTZO70pdq//oBrzokwNJ6W/o9X7N+PAnPyTP/ohQf41b6ABzGQj YrTieDRCWiLX6aQVCInHZHSofDQq4aFZKXMDoSSEVG9Oio+afESKaJIQND1EKibivtBV yzL6RgWcGrbpI/GGRc66uozATImKw4BlIjstuTNiB96M1aGgf3h2rIuSh2a1oHWl+l89 Lbvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MvkvhCe7/dzkxWCxtZztV93bf1c+CHOSidF0+15IJiE=; b=n/a8PkOkcGTOBin7zIJ/YdcHcpm9QhQ73/DhSaB+PzVujApCDpto0PraX+LxOD12sQ RZgSxR1zIh7JqhRCyH8NxVJHO0PcMH6fKZRiPiQgRIRyZA+Z1AnIHQ3ldDSk4fbHK3IB QLVvY5KYljTmVJuKNTRL6gu+cWYULO/rp4c6S7mq6q/LdXxeHa+WKht5sRMj0cclC12g 9h4PsgpSa9/6DBQd5NFtSTes+zikESzPj/K+z10ZrzVvArVM/Q9nJnmhU9tCGRbIRRlX NF5dQ8bGYyO3uPj8ExSzzcfWR3BF/wIPTzPI/bP86X9dyRdB9+4UReWTxuX1F5CLhSAz JOpg== X-Gm-Message-State: AJIora8bv+QdVnL97JahDK8f2WA71U5qhDAGeMHau8euZAdLy6MO20SK oMJ2SsOanbbHrY4e2GmiB37f0Rkaj4QpuA== X-Google-Smtp-Source: AGRyM1ufRucrvY2t+pMtKGPuFp55MSl40sUXP30YgFzZjjUpvmQqRP2s4I+ONsJJTqfO8RAMKIDq9A== X-Received: by 2002:a17:907:6890:b0:72e:dc8f:ad42 with SMTP id qy16-20020a170907689000b0072edc8fad42mr14856569ejc.683.1658871412140; Tue, 26 Jul 2022 14:36:52 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id kv11-20020a17090778cb00b0072eddc468absm6886471ejc.134.2022.07.26.14.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 14:36:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC] pcapng: record received RSS hash in pcap file Date: Tue, 26 Jul 2022 14:36:19 -0700 Message-Id: <20220726213618.142173-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 There is an option for recording RSS hash with packets in the pcapng standard. This implements this for all received packets. There is a corner case that can not be addressed with current DPDK API's. If using rte_flow() and some hardware it is possible to write a flow rule that uses another hash function like XOR. But there is no API that records this, or provides the algorithm info on a per-packet basis. The current version of wireshark does not display the recorded hash option. But if we build it they will come. Signed-off-by: Stephen Hemminger --- lib/pcapng/rte_pcapng.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 06ad712bd1eb..f7df3ddd64e8 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -453,9 +454,10 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, struct pcapng_enhance_packet_block *epb; uint32_t orig_len, data_len, padding, flags; struct pcapng_option *opt; - const uint16_t optlen = pcapng_optlen(sizeof(flags)) + pcapng_optlen(sizeof(queue)); + uint16_t optlen; struct rte_mbuf *mc; uint64_t ns; + bool rss_hash; #ifdef RTE_LIBRTE_ETHDEV_DEBUG RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, NULL); @@ -488,6 +490,10 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, goto fail; } + /* record HASH on incoming packets */ + rss_hash = (direction == RTE_PCAPNG_DIRECTION_IN && + (md->ol_flags & RTE_MBUF_F_RX_RSS_HASH)); + /* pad the packet to 32 bit boundary */ data_len = rte_pktmbuf_data_len(mc); padding = RTE_ALIGN(data_len, sizeof(uint32_t)) - data_len; @@ -499,6 +505,11 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, memset(tail, 0, padding); } + optlen = pcapng_optlen(sizeof(flags)); + optlen += pcapng_optlen(sizeof(queue)); + if (rss_hash) + optlen += pcapng_optlen(sizeof(uint8_t) + sizeof(uint32_t)); + /* reserve trailing options and block length */ opt = (struct pcapng_option *) rte_pktmbuf_append(mc, optlen + sizeof(uint32_t)); @@ -522,6 +533,20 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, opt = pcapng_add_option(opt, PCAPNG_EPB_QUEUE, &queue, sizeof(queue)); + if (rss_hash) { + uint8_t hash_opt[5]; + + /* The algorithm could be something else if + * using rte_flow_action_rss; but the current API does not + * have a way for ethdev to report this on a per-packet basis. + */ + hash_opt[0] = PCAPNG_HASH_TOEPLITZ; + + memcpy(&hash_opt[1], &md->hash.rss, sizeof(uint32_t)); + opt = pcapng_add_option(opt, PCAPNG_EPB_HASH, + &hash_opt, sizeof(hash_opt)); + } + /* Note: END_OPT necessary here. Wireshark doesn't do it. */ /* Add PCAPNG packet header */ -- 2.35.1