From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 6B46F45E48;
	Fri, 13 Dec 2024 02:52:11 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 01F7640263;
	Fri, 13 Dec 2024 02:52:11 +0100 (CET)
Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com
 [209.85.215.180])
 by mails.dpdk.org (Postfix) with ESMTP id 1A22C4003C
 for <dev@dpdk.org>; Fri, 13 Dec 2024 02:52:10 +0100 (CET)
Received: by mail-pg1-f180.google.com with SMTP id
 41be03b00d2f7-7fd17f231a7so771228a12.0
 for <dev@dpdk.org>; Thu, 12 Dec 2024 17:52:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1734054729;
 x=1734659529; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=AJqi+r4IXv6bSKPESikzKyM1FyNLYXuX05y8CJLiIBo=;
 b=urj3Weq9o8mj8jcipVUQdURyP1ev9w23aRo9qnCKh5rC9x1AMmCpF7wWrk84cuwd0o
 miKYdudFmm4fPxfCwKtMtxMRrN0CESSloTRycCL+UnPF4NNXezEGztD39azYz9z8haAy
 i01pNABLITUrMqMSKK8E3k9iPUF0bKZS1z3Fesei/Fch8tdgo5hYnZQlOBD/zOufIRrY
 9DpwELoBDrpCAiq8QklNCf+eyv6QpSqY2zIQuuLgOS/hNhyZxvP2JVhfPK86ltZwsQcF
 yXE/i6NpeHVQyA277zdaNs/m5hh8ey2YscfoPy1Zt6B6KLpkfNs9WCZI4AJkCHoxeJFm
 9Keg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734054729; x=1734659529;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=AJqi+r4IXv6bSKPESikzKyM1FyNLYXuX05y8CJLiIBo=;
 b=nTOx9OOsGc+Xw4DoQ0odFQXbif6yr52ZmHJnQLUTZZ8uTJM8IFxesCOe4S2eTGVm33
 /SLRihnmAH/dEmUOOEABFS6NJaqRl31OCLqQd/NAolPo7pd2pI/FDZbVZozuENQnClOc
 0uXYJHAkOiqu7Wv12/8609V/uRLLpts0ZJOQBHiE30tf/T68VprPS2PatvhX5oQLQDl0
 r9+VJOI79z5CIfcrTHN2mRcbJPmeVvT3HSpKhy9Oq0EUYq4LGVoOLRHKjPe/DRRmUJSD
 0mgpeqsRuH+KPsueGxD4H0IWpbnMKm0JT0iGzaWeWUUp6yvdTQ0ajgOhRFkGAOvyxwq4
 ljwA==
X-Gm-Message-State: AOJu0YwZQ6VcDYFPkEH3UyQ3mc7CPqlgN2+LMly3Ii3mHEIXsF71FY1a
 NPLqRwQkGge0T7Xr4mMey0Kezus0rJRkBcUEzUr6S2qwN9/z2v8sWVcpomvhOg2OSpbu+Qrb9Sl
 V
X-Gm-Gg: ASbGncsSSKlxQwojjlADwd76Y0tja+C0kBuOUu9oQYBNiWXa/YlWryMQsfhS5h5whrT
 2GphRkn9WuyHx2W4HOqT45ipbA1V9/nVp8SBrjaZaZNeHl5kJ7Bzpyf7cizAvSrORA4c1GWsypE
 49VnpBasiPXEFMp/Y31Gbc0L0xJbYnAsoIyldERYDDCrZeHkE4EEkqSzsyLUf7wz+01VUvo4gTq
 ELiviDtp3NjTAWhzeHmtjub9ndlqsVS/vxSU1LVp5JwX52YrOdRmmPgwftF9ZuYQw/pdUy5NR1t
 AZQiX1fiZuDZd1Mcyzx+nr55GiZMK9TEQg==
X-Google-Smtp-Source: AGHT+IGo0iY+zPx3pcPVktAkwy5E/m3qND3SnqDaKO7lAV/RxAWv5heyEs46W49umNNe9ahGsPgS3g==
X-Received: by 2002:a17:90b:3891:b0:2ee:f19b:86e5 with SMTP id
 98e67ed59e1d1-2f28fb6d11fmr1493671a91.14.1734054728856; 
 Thu, 12 Dec 2024 17:52:08 -0800 (PST)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-2f142de33basm2011122a91.23.2024.12.12.17.52.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 12 Dec 2024 17:52:08 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, stable@dpdk.org,
 Chas Williams <chas3@att.com>, "Min Hu (Connor)" <humin29@huawei.com>,
 Chengwen Feng <fengchengwen@huawei.com>,
 Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH] test/bonding: fix active backup rx test
Date: Thu, 12 Dec 2024 17:51:58 -0800
Message-ID: <20241213015158.10174-1-stephen@networkplumber.org>
X-Mailer: git-send-email 2.45.2
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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

The test had incorrect assumptions about how active backup
should work. When in active backup mode, the secondary (not primary)
ports should be ignored. The test was always broken since initially
written but earlier bug was masking the part of the test which
tested non-primary ports.

Bugzilla ID: 1589
Fixes: 112ce3917674 ("test/bonding: fix loop on members")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_link_bonding.c | 68 +++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 35 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index b752a5ecbf..512e79365f 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -2246,49 +2246,47 @@ test_activebackup_rx_burst(void)
 		virtual_ethdev_add_mbufs_to_rx_queue(test_params->member_port_ids[i],
 				&gen_pkt_burst[0], burst_size);
 
+		/* Expect burst if this was the active port, zero otherwise */
+		unsigned int rx_expect = (test_params->member_port_ids[i] == primary_port) ? burst_size : 0;
+
 		/* Call rx burst on bonding device */
-		TEST_ASSERT_EQUAL(rte_eth_rx_burst(test_params->bonding_port_id, 0,
-				&rx_pkt_burst[0], MAX_PKT_BURST), burst_size,
-				"rte_eth_rx_burst failed");
+		unsigned int rx_count = rte_eth_rx_burst(test_params->bonding_port_id, 0,
+							 &rx_pkt_burst[0], MAX_PKT_BURST);
+		TEST_ASSERT_EQUAL(rx_count, rx_expect,
+				  "rte_eth_rx_burst (%u) not as expected (%u)",
+				  rx_count, rx_expect);
 
-		if (test_params->member_port_ids[i] == primary_port) {
-			/* Verify bonding device rx count */
-			rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
-			TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
-					"Bonding Port (%d) ipackets value (%u) not as expected (%d)",
+		/* Verify bonding device rx count */
+		rte_eth_stats_get(test_params->bonding_port_id, &port_stats);
+		TEST_ASSERT_EQUAL(port_stats.ipackets, rx_expect,
+				  "Bonding Port (%d) ipackets value (%u) not as expected (%u)",
 					test_params->bonding_port_id,
-					(unsigned int)port_stats.ipackets, burst_size);
+				  (unsigned int)port_stats.ipackets, rx_expect);
 
-			/* Verify bonding member devices rx count */
-			for (j = 0; j < test_params->bonding_member_count; j++) {
-				rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
-				if (i == j) {
-					TEST_ASSERT_EQUAL(port_stats.ipackets, (uint64_t)burst_size,
-							"Member Port (%d) ipackets value (%u) not as "
-							"expected (%d)",
-							test_params->member_port_ids[i],
-							(unsigned int)port_stats.ipackets,
-							burst_size);
-				} else {
-					TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
-							"Member Port (%d) ipackets value (%u) not as "
-							"expected (%d)\n",
-							test_params->member_port_ids[i],
-							(unsigned int)port_stats.ipackets, 0);
-				}
-			}
-		} else {
-			for (j = 0; j < test_params->bonding_member_count; j++) {
-				rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
+		for (j = 0; j < test_params->bonding_member_count; j++) {
+			rte_eth_stats_get(test_params->member_port_ids[j], &port_stats);
+			if (i == j) {
+				TEST_ASSERT_EQUAL(port_stats.ipackets, rx_expect,
+					  "Member Port (%d) ipackets (%u) not as expected (%d)",
+					  test_params->member_port_ids[i],
+					  (unsigned int)port_stats.ipackets, rx_expect);
+
+				/* reset member device stats */
+				rte_eth_stats_reset(test_params->member_port_ids[j]);
+			} else {
 				TEST_ASSERT_EQUAL(port_stats.ipackets, 0,
-						"Member Port (%d) ipackets value (%u) not as expected "
-						"(%d)", test_params->member_port_ids[i],
-						(unsigned int)port_stats.ipackets, 0);
+					  "Member Port (%d) ipackets (%u) not as expected (%d)",
+					  test_params->member_port_ids[i],
+					  (unsigned int)port_stats.ipackets, 0);
 			}
 		}
 
-		/* free mbufs */
-		rte_pktmbuf_free_bulk(rx_pkt_burst, burst_size);
+		/* extract packets queued to inactive member */
+		if (rx_count == 0)
+			rx_count = rte_eth_rx_burst(test_params->member_port_ids[i], 0,
+						    rx_pkt_burst, MAX_PKT_BURST);
+		if (rx_count > 0)
+			rte_pktmbuf_free_bulk(rx_pkt_burst, rx_count);
 
 		/* reset bonding device stats */
 		rte_eth_stats_reset(test_params->bonding_port_id);
-- 
2.45.2