From patchwork Mon Aug 9 17:22:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Richardson X-Patchwork-Id: 494240 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 A49C6C4338F for ; Mon, 9 Aug 2021 17:22:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 808896105A for ; Mon, 9 Aug 2021 17:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234186AbhHIRXM (ORCPT ); Mon, 9 Aug 2021 13:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbhHIRXK (ORCPT ); Mon, 9 Aug 2021 13:23:10 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44195C061796 for ; Mon, 9 Aug 2021 10:22:50 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id bo13-20020a05621414adb029035561c68664so1554763qvb.1 for ; Mon, 09 Aug 2021 10:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QwrfZsIk88oMsovuf2STnfHeCrOpCXzBnuvpUniP9TM=; b=PkfHMzJBwtBjchRZGKOSU/nApQzOUrWrOfcKhVrGk1p5Iur7Abzpxr3uUdGQo9+U4O FbHyeP5RWRLU9i4ovkJgRIVnTT1Y8VqcvhtfPglC8vl02gY9gdcajB0IjfngApwJAxph V8h2cU4xmE0bFEWUftWz1raA9S8DWp5toc3dPeRH1v0bUYd6fG1Kh9XpoJ64/yHwKQnn C73Cedv65jJOMmlHnV4HcJlI4D9uyAfcBwMgmWfKpKYq47lDBR1t8fhhDKm200p+RHdq jYTnlFOc+fpitY2lRbRTO8x0I5gRBpaV33KHouXfa4slD78l5AWc51wgKxyQy6BrIlXH XyrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QwrfZsIk88oMsovuf2STnfHeCrOpCXzBnuvpUniP9TM=; b=ZXXYqO0bosyt2p3uzrWjlaRAbej3P9xYwO8Emu1d1GyQPlPK0IYeGWVDsy9TenMLXA V+3q6r88CcvKSeG1sBvX3eo2p9GLhhS8F6yPibKQrhuMQxQUejwGxC/eyO1+wyDNbSU8 3zVQl0h/rLGKx6CYydEk4XUlWhKIPUuRqUzXDZMxlrqcIwOeSNhwwNN0/LZrvavywiUU UQszCGeJ8ujI9B+Qpyf7nY5jU7ZzzGWk2UV5AIjyfFu1VpEb8Ir6e85r14hbTEm+JNSA OqrJc1VgB9FiE9bcoqeAjs/Nw0BEOe143qd9k9mjrpWhi1p7u3L+kSegn/ynC4HcLjBP S7RA== X-Gm-Message-State: AOAM531XYGDFYCciSXR/Jg9l8iVTPpO8nYxWcupzjvstX2dQ95Jewvj2 OuOw6tPMAtLcXNzBJF3L0eE1fr0MFoEQoRyWuMFRFA== X-Google-Smtp-Source: ABdhPJyqBiB+Xe0U35ea5UVQ8j0Tl5Vzuc/Mc17NrvKHfEs2m0+b7JJHvTxfB1WYB8S1rIATC1aO3utVD4hO3bcRZuuXsg== X-Received: from mustash.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:337b]) (user=richardsonnick job=sendgmr) by 2002:a0c:d990:: with SMTP id y16mr7048149qvj.29.1628529769412; Mon, 09 Aug 2021 10:22:49 -0700 (PDT) Date: Mon, 9 Aug 2021 17:22:02 +0000 In-Reply-To: <20210809172207.3890697-1-richardsonnick@google.com> Message-Id: <20210809172207.3890697-2-richardsonnick@google.com> Mime-Version: 1.0 References: <20210809172207.3890697-1-richardsonnick@google.com> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH 1/3] pktgen: Parse internet mix (imix) input From: Nicholas Richardson To: davem@davemloft.net, kuba@kernel.org Cc: nrrichar@ncsu.edu, arunkaly@google.com, Nick Richardson , "Gustavo A. R. Silva" , Yejune Deng , Di Zhu , Ye Bin , Leesoo Ahn , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nick Richardson Adds "imix_weights" command for specifying internet mix distribution. The command is in this format: "imix_weights size_1,weight_1 size_2,weight_2 ... size_n,weight_n" where the probability that packet size_i is picked is: weight_i / (weight_1 + weight_2 + .. + weight_n) The user may provide up to 20 imix entries (size_i,weight_i) in this command. The user specified imix entries will be displayed in the "Params" section of the interface output. Values for clone_skb > 0 is not supported in IMIX mode. Summary of changes: Add flag for enabling internet mix mode. Add command (imix_weights) for internet mix input. Return -ENOTSUPP when clone_skb > 0 in IMIX mode. Display imix_weights in Params. Create data structures to store imix entries and distribution. Signed-off-by: Nick Richardson --- net/core/pktgen.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 7e258d255e90..83c83e1b5f28 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -175,6 +175,8 @@ #define IP_NAME_SZ 32 #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ #define MPLS_STACK_BOTTOM htonl(0x00000100) +/* Max number of internet mix entries that can be specified in imix_weights. */ +#define MAX_IMIX_ENTRIES 20 #define func_enter() pr_debug("entering %s\n", __func__); @@ -242,6 +244,12 @@ static char *pkt_flag_names[] = { #define VLAN_TAG_SIZE(x) ((x)->vlan_id == 0xffff ? 0 : 4) #define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4) +struct imix_pkt { + __u64 size; + __u64 weight; + __u64 count_so_far; +}; + struct flow_state { __be32 cur_daddr; int count; @@ -343,6 +351,10 @@ struct pktgen_dev { __u8 traffic_class; /* ditto for the (former) Traffic Class in IPv6 (see RFC 3260, sec. 4) */ + /* IMIX */ + unsigned int n_imix_entries; + struct imix_pkt imix_entries[MAX_IMIX_ENTRIES]; + /* MPLS */ unsigned int nr_labels; /* Depth of stack, 0 = no MPLS */ __be32 labels[MAX_MPLS_LABELS]; @@ -552,6 +564,16 @@ static int pktgen_if_show(struct seq_file *seq, void *v) (unsigned long long)pkt_dev->count, pkt_dev->min_pkt_size, pkt_dev->max_pkt_size); + if (pkt_dev->n_imix_entries > 0) { + seq_printf(seq, " imix_weights: "); + for (i = 0; i < pkt_dev->n_imix_entries; i++) { + seq_printf(seq, "%llu,%llu ", + pkt_dev->imix_entries[i].size, + pkt_dev->imix_entries[i].weight); + } + seq_printf(seq, "\n"); + } + seq_printf(seq, " frags: %d delay: %llu clone_skb: %d ifname: %s\n", pkt_dev->nfrags, (unsigned long long) pkt_dev->delay, @@ -792,6 +814,61 @@ static int strn_len(const char __user * user_buffer, unsigned int maxlen) return i; } +static ssize_t get_imix_entries(const char __user *buffer, + struct pktgen_dev *pkt_dev) +{ + /* Parses imix entries from user buffer. + * The user buffer should consist of imix entries separated by spaces + * where each entry consists of size and weight delimited by commas. + * "size1,weight_1 size2,weight_2 ... size_n,weight_n" for example. + */ + long len; + char c; + int i = 0; + const int max_digits = 10; + + pkt_dev->n_imix_entries = 0; + + do { + unsigned long size; + unsigned long weight; + + len = num_arg(&buffer[i], max_digits, &size); + if (len < 0) + return len; + i += len; + if (get_user(c, &buffer[i])) + return -EFAULT; + /* Check for comma between size_i and weight_i */ + if (c != ',') + return -EINVAL; + i++; + + if (size < 14 + 20 + 8) + size = 14 + 20 + 8; + + len = num_arg(&buffer[i], max_digits, &weight); + if (len < 0) + return len; + if (weight <= 0) + return -EINVAL; + + pkt_dev->imix_entries[pkt_dev->n_imix_entries].size = size; + pkt_dev->imix_entries[pkt_dev->n_imix_entries].weight = weight; + + i += len; + if (get_user(c, &buffer[i])) + return -EFAULT; + + i++; + pkt_dev->n_imix_entries++; + + if (pkt_dev->n_imix_entries > MAX_IMIX_ENTRIES) + return -E2BIG; + } while (c == ' '); + return i; +} + static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev) { unsigned int n = 0; @@ -960,6 +1037,18 @@ static ssize_t pktgen_if_write(struct file *file, return count; } + if (!strcmp(name, "imix_weights")) { + if (pkt_dev->clone_skb > 0) + return -ENOTSUPP; + + len = get_imix_entries(&user_buffer[i], pkt_dev); + if (len < 0) + return len; + + i += len; + return count; + } + if (!strcmp(name, "debug")) { len = num_arg(&user_buffer[i], 10, &value); if (len < 0) @@ -1082,10 +1171,16 @@ static ssize_t pktgen_if_write(struct file *file, len = num_arg(&user_buffer[i], 10, &value); if (len < 0) return len; + /* clone_skb is not supported for netif_receive xmit_mode and + * IMIX mode. + */ if ((value > 0) && ((pkt_dev->xmit_mode == M_NETIF_RECEIVE) || !(pkt_dev->odev->priv_flags & IFF_TX_SKB_SHARING))) return -ENOTSUPP; + if (value > 0 && pkt_dev->n_imix_entries > 0) + return -ENOTSUPP; + i += len; pkt_dev->clone_skb = value; From patchwork Mon Aug 9 17:22:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Richardson X-Patchwork-Id: 494857 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 95B21C4338F for ; Mon, 9 Aug 2021 17:23:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 732C561058 for ; Mon, 9 Aug 2021 17:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234319AbhHIRXW (ORCPT ); Mon, 9 Aug 2021 13:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234210AbhHIRXT (ORCPT ); Mon, 9 Aug 2021 13:23:19 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB2A5C0613D3 for ; Mon, 9 Aug 2021 10:22:58 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id f10-20020a0ccc8a0000b02903521ac3b9d7so4042938qvl.15 for ; Mon, 09 Aug 2021 10:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=zob3UxBCZJOXL7+Saz9eyr6rn9i6ZG0QqW2KutXmaCw=; b=CZfapeTkzBQt16ltomwZpYcT1FjIsPBszmbvmk6E0Fz7l1iuDe1kNfCBZFgyoSFO+A N9xZ9quGmXNLxaHteHL/h37VRrcrQQvpSpEUWVbg6vl3CKTRVDxQzLPWgg4ll1iB5wT6 k5Tj3qL3CrNL60KAeS+1MtbgmZ0bhhvWGrIms7E1hmB6m+f6neI6xkKLXgbcBRfiWimP 2FUQBI0YlBwaa3bp6K8FsvfkeVuoeXlR7gua6xkpsziIhepesjrlc5IXt/B4IsdXBMYd wDbMeN3Tm+ehCVkb0NJbKe1xcSGwcyrzun7dOroGyiBDMgb/+IC3/J4HnXZVCXVoW3lo RJBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=zob3UxBCZJOXL7+Saz9eyr6rn9i6ZG0QqW2KutXmaCw=; b=CQ0nNcW+wy5GDdAq9ce2mnXhAZI70GwTiLGVC5q4dmBuL++4WTPnpoc1k/BHDPwbK8 s3BtJApFKrP4xy2ZJ+FfdtYcLzDErxI6Mc1iOI0Tw3Dml4lcHyKNK68bA3e47Fe/hwdR xtvQooTgzmfR9crVZqt6fYtXr13CdLSYb4cH8m/Q3rrvkGnLacghi3ChQO1uF5okj1NC Ctyg0OM69reLQ363jcCWINY1saMnNfoNmzePx0/GPtV6aHnf+c8FQRT6ehedzeCpQ9en ez9k5hNWOAtAxZ15GR+ym70jlY5yeELm/xI2sn6Xhd02vpRIrRK2K/HshMWttFRaQsoO IXJQ== X-Gm-Message-State: AOAM532fhMoJsatOWOGf6LzuWJQ95ib46R5K9BLFhguIARTpxB3O/JS4 mS0luf+Mx6Y2LO8rSwmP7QqHvEyUafyrbL4YQ4jC8A== X-Google-Smtp-Source: ABdhPJxXLB/5bgROHElsTEKC1vPGaTBNAh2SbwYNIKQjRon/lN1p5FM1mh7wpJeDitwnaIhwEJoiTwxWc9Axtf5bFmKMDA== X-Received: from mustash.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:337b]) (user=richardsonnick job=sendgmr) by 2002:a05:6214:9d2:: with SMTP id dp18mr13523234qvb.46.1628529777974; Mon, 09 Aug 2021 10:22:57 -0700 (PDT) Date: Mon, 9 Aug 2021 17:22:03 +0000 In-Reply-To: <20210809172207.3890697-1-richardsonnick@google.com> Message-Id: <20210809172207.3890697-3-richardsonnick@google.com> Mime-Version: 1.0 References: <20210809172207.3890697-1-richardsonnick@google.com> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH 2/3] pktgen: Add imix distribution bins From: Nicholas Richardson To: davem@davemloft.net, kuba@kernel.org Cc: nrrichar@ncsu.edu, arunkaly@google.com, Nick Richardson , "Gustavo A. R. Silva" , Leesoo Ahn , Di Zhu , Ye Bin , Yejune Deng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nick Richardson In order to represent the distribution of imix packet sizes, a pre-computed data structure is used. It features 100 (IMIX_PRECISION) "bins". Contiguous ranges of these bins represent the respective packet size of each imix entry. This is done to avoid the overhead of selecting the correct imix packet size based on the corresponding weights. Example: imix_weights 40,7 576,4 1500,1 total_weight = 7 + 4 + 1 = 12 pkt_size 40 occurs 7/total_weight = 58% of the time pkt_size 576 occurs 4/total_weight = 33% of the time pkt_size 1500 occurs 1/total_weight = 9% of the time We generate a random number between [0-99] and select the corresponding packet size based on the specified weights. Eg. random number = 358723895 % 100 = 65 Selects the packet size corresponding to index:65 in the pre-computed imix_distribution array. An example of the pre-computed array is below: The imix_distribution will look like the following: 0 -> 0 (index of imix_entry.size == 40) 1 -> 0 (index of imix_entry.size == 40) 2 -> 0 (index of imix_entry.size == 40) [...] -> 0 (index of imix_entry.size == 40) 57 -> 0 (index of imix_entry.size == 40) 58 -> 1 (index of imix_entry.size == 576) [...] -> 1 (index of imix_entry.size == 576) 90 -> 1 (index of imix_entry.size == 576) 91 -> 2 (index of imix_entry.size == 1500) [...] -> 2 (index of imix_entry.size == 1500) 99 -> 2 (index of imix_entry.size == 1500) Create and use "bin" representation of the imix distribution. Signed-off-by: Nick Richardson --- net/core/pktgen.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 83c83e1b5f28..be46de1d6eec 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -177,6 +177,7 @@ #define MPLS_STACK_BOTTOM htonl(0x00000100) /* Max number of internet mix entries that can be specified in imix_weights. */ #define MAX_IMIX_ENTRIES 20 +#define IMIX_PRECISION 100 /* Precision of IMIX distribution */ #define func_enter() pr_debug("entering %s\n", __func__); @@ -354,6 +355,8 @@ struct pktgen_dev { /* IMIX */ unsigned int n_imix_entries; struct imix_pkt imix_entries[MAX_IMIX_ENTRIES]; + /* Maps 0-IMIX_PRECISION range to imix_entry based on probability*/ + __u8 imix_distribution[IMIX_PRECISION]; /* MPLS */ unsigned int nr_labels; /* Depth of stack, 0 = no MPLS */ @@ -483,6 +486,7 @@ static void pktgen_stop_all_threads(struct pktgen_net *pn); static void pktgen_stop(struct pktgen_thread *t); static void pktgen_clear_counters(struct pktgen_dev *pkt_dev); +static void fill_imix_distribution(struct pktgen_dev *pkt_dev); /* Module parameters, defaults. */ static int pg_count_d __read_mostly = 1000; @@ -1045,6 +1049,8 @@ static ssize_t pktgen_if_write(struct file *file, if (len < 0) return len; + fill_imix_distribution(pkt_dev); + i += len; return count; } @@ -2572,6 +2578,14 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) t = pkt_dev->min_pkt_size; } pkt_dev->cur_pkt_size = t; + } else if (pkt_dev->n_imix_entries > 0) { + struct imix_pkt *entry; + __u32 t = prandom_u32() % IMIX_PRECISION; + __u8 entry_index = pkt_dev->imix_distribution[t]; + + entry = &pkt_dev->imix_entries[entry_index]; + entry->count_so_far++; + pkt_dev->cur_pkt_size = entry->size; } set_cur_queue_map(pkt_dev); @@ -2640,6 +2654,33 @@ static void free_SAs(struct pktgen_dev *pkt_dev) } } +static void fill_imix_distribution(struct pktgen_dev *pkt_dev) +{ + int cumulative_probabilites[MAX_IMIX_ENTRIES]; + int j = 0; + __u64 cumulative_prob = 0; + __u64 total_weight = 0; + int i = 0; + + for (i = 0; i < pkt_dev->n_imix_entries; i++) + total_weight += pkt_dev->imix_entries[i].weight; + + /* Fill cumulative_probabilites with sum of normalized probabilities */ + for (i = 0; i < pkt_dev->n_imix_entries - 1; i++) { + cumulative_prob += div64_u64(pkt_dev->imix_entries[i].weight * + IMIX_PRECISION, + total_weight); + cumulative_probabilites[i] = cumulative_prob; + } + cumulative_probabilites[pkt_dev->n_imix_entries - 1] = 100; + + for (i = 0; i < IMIX_PRECISION; i++) { + if (i == cumulative_probabilites[j]) + j++; + pkt_dev->imix_distribution[i] = j; + } +} + static int process_ipsec(struct pktgen_dev *pkt_dev, struct sk_buff *skb, __be16 protocol) { From patchwork Mon Aug 9 17:22:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Richardson X-Patchwork-Id: 494239 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 E6E78C4338F for ; Mon, 9 Aug 2021 17:23:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9141601FD for ; Mon, 9 Aug 2021 17:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234323AbhHIRXa (ORCPT ); Mon, 9 Aug 2021 13:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234315AbhHIRXZ (ORCPT ); Mon, 9 Aug 2021 13:23:25 -0400 Received: from mail-vs1-xe49.google.com (mail-vs1-xe49.google.com [IPv6:2607:f8b0:4864:20::e49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08405C061798 for ; Mon, 9 Aug 2021 10:23:05 -0700 (PDT) Received: by mail-vs1-xe49.google.com with SMTP id b19-20020a67fe930000b02902bcabe3d14cso1744018vsr.12 for ; Mon, 09 Aug 2021 10:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8/jOUxt+YUrjRZL/TINLUwdfhHd+V6WjO0jwX/Usg4E=; b=GHV6a2TdKtfhsbwPqnhgRO74xhjaQwItH+Mrr+cp2L7u9JGbqujDQaYzvHp0bR+Jrl xRERdiFYLc7X0azOr01s+S4snqaH7WWq8CKnL6PxUzUAXuPAIx9WJCeJ8LX3B8hMlbfY rP6JsV0HhYuApDTX7RGqmK1C1k/p/rnhPiTvBpLVQiUHRImGGDjOMVs4SqTNYH/AK5sy 7YawBAWcU+hCUGZ6NoVspTIzigrYW/GdWB64zkDEeVsFRtIrZkU1HmRH2Td6II6rfYD+ ZgRy90rxMSc0MyIxvWFgHJ9r1kByl65BVkA0LFmaflPMEiRc1dC7uM0VU4ohsjA3GXsD +ruQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8/jOUxt+YUrjRZL/TINLUwdfhHd+V6WjO0jwX/Usg4E=; b=GojShbuRw5K/+zW1PQFgAszwhCX/o/UocVSKufBLZgY9GWAQuZxO4x+guknZJpNyv7 JE+N/fbXGrEc/dUSeHTfIPhe2OsR9WrbTyIXY8h1OFxHB6TKZ5RI0jmCcQvijS9zV8r9 wsd6byMi1/uAdH7BE/HYVsYj+YHZBBPu0utNAKpdGDn4fN7KIX0rbUqh5NhC2SEgMqCm 2ALSmmrlCMNRn+kaPXXGziTGRVvO8K7XitKpOUyA8JB6nYeBg5AaP/Itqlu9oBOMgmjU Qjc5hd6lRCJjR8GPJPtirXoxQ4M3y80Tndqm56BlY1PzfvMIyWnvEEVJPyqaJg3TopDw lOoQ== X-Gm-Message-State: AOAM532P/uN0BZgtb8u/qziGYZH5FEJ3RbHmTd4MZKBZY2YjLEQVVVNn kot1XtZiVjVPIQPN9KeqGhQjeF/F1RJC/34JZLFkvw== X-Google-Smtp-Source: ABdhPJyP+6B2j1eCMPELbbPZURKm+kELXvP9Kf87YcP9rbfEA9txxN99JVVAd6v+vwZDt2L2rb0yNcJD5AuONeefBUwv3A== X-Received: from mustash.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:337b]) (user=richardsonnick job=sendgmr) by 2002:a9f:2286:: with SMTP id 6mr17039040uan.53.1628529784146; Mon, 09 Aug 2021 10:23:04 -0700 (PDT) Date: Mon, 9 Aug 2021 17:22:04 +0000 In-Reply-To: <20210809172207.3890697-1-richardsonnick@google.com> Message-Id: <20210809172207.3890697-4-richardsonnick@google.com> Mime-Version: 1.0 References: <20210809172207.3890697-1-richardsonnick@google.com> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH 3/3] pktgen: Add output for imix results From: Nicholas Richardson To: davem@davemloft.net, kuba@kernel.org Cc: nrrichar@ncsu.edu, arunkaly@google.com, Nick Richardson , "Gustavo A. R. Silva" , Ye Bin , Leesoo Ahn , Di Zhu , Yejune Deng , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nick Richardson The bps for imix mode is calculated by: sum(imix_entry.size) / time_elapsed The actual counts of each imix_entry are displayed under the "Current:" section of the interface output in the following format: imix_size_counts: size_1,count_1 size_2,count_2 ... size_n,count_n Example (count = 200000): imix_weights: 256,1 859,3 205,2 imix_counts: 256,32082 859,99796 205,68122 Result: OK: 17992362(c17964678+d27684) usec, 200000 (859byte,0frags) 11115pps 47Mb/sec (47977140bps) errors: 0 Summary of changes: Calculate bps based on imix counters when in IMIX mode. Add output for IMIX counters. Signed-off-by: Nick Richardson --- net/core/pktgen.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index be46de1d6eec..b1705e62b10f 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -695,6 +695,18 @@ static int pktgen_if_show(struct seq_file *seq, void *v) (unsigned long long)pkt_dev->sofar, (unsigned long long)pkt_dev->errors); + if (pkt_dev->n_imix_entries > 0) { + int i; + + seq_printf(seq, " imix_size_counts: "); + for (i = 0; i < pkt_dev->n_imix_entries; i++) { + seq_printf(seq, "%llu,%llu ", + pkt_dev->imix_entries[i].size, + pkt_dev->imix_entries[i].count_so_far); + } + seq_printf(seq, "\n"); + } + seq_printf(seq, " started: %lluus stopped: %lluus idle: %lluus\n", (unsigned long long) ktime_to_us(pkt_dev->started_at), @@ -3281,7 +3293,19 @@ static void show_results(struct pktgen_dev *pkt_dev, int nr_frags) pps = div64_u64(pkt_dev->sofar * NSEC_PER_SEC, ktime_to_ns(elapsed)); - bps = pps * 8 * pkt_dev->cur_pkt_size; + if (pkt_dev->n_imix_entries > 0) { + int i; + struct imix_pkt *entry; + + bps = 0; + for (i = 0; i < pkt_dev->n_imix_entries; i++) { + entry = &pkt_dev->imix_entries[i]; + bps += entry->size * entry->count_so_far; + } + bps = div64_u64(bps * 8 * NSEC_PER_SEC, ktime_to_ns(elapsed)); + } else { + bps = pps * 8 * pkt_dev->cur_pkt_size; + } mbps = bps; do_div(mbps, 1000000);