LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Nicholas Richardson <richardsonnick@google.com>
To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org
Cc: nrrichar@ncsu.edu, promanov@google.com, arunkaly@google.com,
	Nick Richardson <richardsonnick@google.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Yejune Deng <yejune.deng@gmail.com>, Leesoo Ahn <dev@ooseel.net>,
	Ye Bin <yebin10@huawei.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] pktgen: Remove fill_imix_distribution() CONFIG_XFRM dependency
Date: Wed, 18 Aug 2021 01:31:26 +0000	[thread overview]
Message-ID: <20210818013129.1147350-1-richardsonnick@google.com> (raw)

From: Nick Richardson <richardsonnick@google.com>

Currently, the declaration of fill_imix_distribution() is dependent
on CONFIG_XFRM. This is incorrect.

Move fill_imix_distribution() declaration out of #ifndef CONFIG_XFRM
block.

Signed-off-by: Nick Richardson <richardsonnick@google.com>
---
 net/core/pktgen.c | 53 +++++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 94008536a9d6..9e5a3249373c 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2601,6 +2601,32 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 	pkt_dev->flows[flow].count++;
 }
 
+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;
+	}
+}
 
 #ifdef CONFIG_XFRM
 static u32 pktgen_dst_metrics[RTAX_MAX + 1] = {
@@ -2662,33 +2688,6 @@ 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)
 {
-- 
2.33.0.rc1.237.g0d66db33f3-goog


             reply	other threads:[~2021-08-18  1:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  1:31 Nicholas Richardson [this message]
2021-08-18 10:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210818013129.1147350-1-richardsonnick@google.com \
    --to=richardsonnick@google.com \
    --cc=arunkaly@google.com \
    --cc=davem@davemloft.net \
    --cc=dev@ooseel.net \
    --cc=gustavoars@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nrrichar@ncsu.edu \
    --cc=promanov@google.com \
    --cc=yebin10@huawei.com \
    --cc=yejune.deng@gmail.com \
    --subject='Re: [PATCH] pktgen: Remove fill_imix_distribution() CONFIG_XFRM dependency' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).