From patchwork Fri Jul 5 01:57:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13724316 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 289A1EAC5 for ; Fri, 5 Jul 2024 01:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144652; cv=none; b=H6X/EU27Z3vGx9p8F+jfg/Mf10wfd1LaS1JlTVulLwKk+1FwQKV5ZKY2Z10XfvCbvRdrACChzmzmZJdDovPPdTN8N1QwKTNPzXVehRZbRXBhGKntBRxM4J0+XB24V23/IOrA24mbIyzps5N4jsd/x/6R0oqhOZl7fiOXqsBhC8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144652; c=relaxed/simple; bh=YurwP05hBMEW7i/lb6GoYsCicxSjn9PEync7OY/BWAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CVTVw0/dEKbXcXhoGOGJyEMXJ8wrl6G/7GvElZNDsO8JKbf5MObH368F+1s/lbWdTzkUS1nIJ7BaywO4y7DDkHDAyNxjFL/c3Huf8uHc51bJDbZ8iFsNGObH36Z4zdpIqz2j7eZpPl6ORTemBPI38wfVIWyjzIW6N+O+0NlJHnk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LB9p92xu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LB9p92xu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95D3FC4AF0A; Fri, 5 Jul 2024 01:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720144652; bh=YurwP05hBMEW7i/lb6GoYsCicxSjn9PEync7OY/BWAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LB9p92xuIrzCj9agE6wcBdRXhywOnkGyRPA2sCCseK1c5u6eA2t1506637wdA2MMm 2GneathS0jWN81Ey4q210k5Hjuwf1jXCJgzNVxy3eokV/WS2uLRxin2qiyFHmOMN4Z uN67nE4iN1hLhD0LFhZWDWpEUKXZLMRar4w/qQCRhrg8e/W+wbwg+5AYjCRo6EHvEf I/sjnQP4RcApm5blJ/NrmkgCdUC9/rDTRLg4NKPMcdJF2FwOkD6vOaDgum3G7pQHlX aVf1EZFtE9wsB/DkNecbjXXAbd5VjVQ67hMjuBOGKFncR0pM0fyjvOssGqUsV7Y0EC 8+gYXVNUYDqYA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, petrm@nvidia.com, przemyslaw.kitszel@intel.com, willemdebruijn.kernel@gmail.com, ecree.xilinx@gmail.com, Jakub Kicinski Subject: [PATCH net-next 1/5] selftests: drv-net: rss_ctx: fix cleanup in the basic test Date: Thu, 4 Jul 2024 18:57:21 -0700 Message-ID: <20240705015725.680275-2-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705015725.680275-1-kuba@kernel.org> References: <20240705015725.680275-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The basic test may fail without resetting the RSS indir table. While at it reformat the doc a tiny bit. Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/hw/rss_ctx.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index 475f2a63fcd5..de2a55c0f35c 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -64,9 +64,8 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure def test_rss_key_indir(cfg): - """ - Test basics like updating the main RSS key and indirection table. - """ + """Test basics like updating the main RSS key and indirection table.""" + if len(_get_rx_cnts(cfg)) < 2: KsftSkipEx("Device has only one queue (or doesn't support queue stats)") @@ -89,6 +88,7 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure # Set the indirection table ethtool(f"-X {cfg.ifname} equal 2") + reset_indir = defer(ethtool, f"-X {cfg.ifname} default") data = get_rss(cfg) ksft_eq(0, min(data['rss-indirection-table'])) ksft_eq(1, max(data['rss-indirection-table'])) @@ -104,7 +104,7 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_eq(sum(cnts[2:]), 0, "traffic on unused queues: " + str(cnts)) # Restore, and check traffic gets spread again - ethtool(f"-X {cfg.ifname} default") + reset_indir.exec() cnts = _get_rx_cnts(cfg) GenerateTraffic(cfg).wait_pkts_and_stop(20000) From patchwork Fri Jul 5 01:57:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13724317 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B71E7134DE for ; Fri, 5 Jul 2024 01:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144652; cv=none; b=p0Z4VvY/kg49AWJPHXn1Spuhw6C+TSB2L10QsI/gQZLtxrhLr2EWirZVVGMOJkeblKQnDP1dBBRI5aQ+yu88gFf3juds2LA6tGWDSJA+HQ1CKkWavP8kLTh5zCnJktWaOIAOJv/v1uJB9YzxkV8RS0A5qjN1ICXn4wg0TgmT5eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144652; c=relaxed/simple; bh=uj/ZOAC817aZgRZn1gmoCzMHp2tttnLPKaiySG0pFio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gYNIdlT9IT8WoDzfdoYHodYbZD14/15c7SDYMEpEclBPEMEqCNJhZGubWeZICq4+R/Y9ecqTDDlp7+PwR+454HgbYV/xKbpwz+gOGeAPXQGQyIyr05klVVsDkbOWcv5n8ireU75uRsjf3+51YVUO3T8KE9Zz5CYfAsPfZLo+AZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tN4Nt+d1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tN4Nt+d1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29600C32781; Fri, 5 Jul 2024 01:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720144652; bh=uj/ZOAC817aZgRZn1gmoCzMHp2tttnLPKaiySG0pFio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tN4Nt+d1zv0NsLkQeDR6Chj+z1J13eZLW8RTmKk2PU0HoEFMDLyBjnGn1yU6F+7Xa 0+Xmb+7S89jYS6Hq8kRmQTMeaBS/GOp9XdFxky4ekal6NfrCVALqc6grXcDRPeExgY x0DIpn6YQk0+j+T7ufHGn7npperlaESCvhuAteO7oRqrqICEr3ddBoVK67U8Vy6XbH VUkOeQ4C5IGteDDJurTZc6M6wbqrDvS3jIVjNoN78NqelQ0S7+paRaWTLnxMfdw12/ +/6zaYUi74Pm8Xk6BkNZ5b830t/ZmZJxfWqTWqCB0Ca5iGgipEhERO9u5KR6j0V6Le acn0NmK8//8Pw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, petrm@nvidia.com, przemyslaw.kitszel@intel.com, willemdebruijn.kernel@gmail.com, ecree.xilinx@gmail.com, Jakub Kicinski Subject: [PATCH net-next 2/5] selftests: drv-net: rss_ctx: factor out send traffic and check Date: Thu, 4 Jul 2024 18:57:22 -0700 Message-ID: <20240705015725.680275-3-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705015725.680275-1-kuba@kernel.org> References: <20240705015725.680275-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Wrap up sending traffic and checking in which queues it landed in a helper. Signed-off-by: Jakub Kicinski --- .../selftests/drivers/net/hw/rss_ctx.py | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index de2a55c0f35c..a95842baef99 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -63,6 +63,22 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure return queue_stats +def _send_traffic_check(cfg, port, name, params): + cnts = _get_rx_cnts(cfg) + GenerateTraffic(cfg, port=port).wait_pkts_and_stop(20000) + cnts = _get_rx_cnts(cfg, prev=cnts) + + directed = sum(cnts[i] for i in params['target']) + + ksft_ge(directed, 20000, f"traffic on {name}: " + str(cnts)) + if params.get('noise'): + ksft_lt(sum(cnts[i] for i in params['noise']), directed / 2, + "traffic on other queues:" + str(cnts)) + if params.get('empty'): + ksft_eq(sum(cnts[i] for i in params['empty']), 0, + "traffic on inactive queues: " + str(cnts)) + + def test_rss_key_indir(cfg): """Test basics like updating the main RSS key and indirection table.""" @@ -170,15 +186,10 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure defer(ethtool, f"-N {cfg.ifname} delete {ntuple}") for i in range(ctx_cnt): - cnts = _get_rx_cnts(cfg) - GenerateTraffic(cfg, port=ports[i]).wait_pkts_and_stop(20000) - cnts = _get_rx_cnts(cfg, prev=cnts) - - directed = sum(cnts[2+i*2:4+i*2]) - - ksft_lt(sum(cnts[ :2]), directed / 2, "traffic on main context:" + str(cnts)) - ksft_ge(directed, 20000, f"traffic on context {i}: " + str(cnts)) - ksft_eq(sum(cnts[2:2+i*2] + cnts[4+i*2:]), 0, "traffic on other contexts: " + str(cnts)) + _send_traffic_check(cfg, ports[i], f"context {i}", + { 'target': (2+i*2, 3+i*2), + 'noise': (0, 1), + 'empty': list(range(2, 2+i*2)) + list(range(4+i*2, 2+2*ctx_cnt)) }) if requested_ctx_cnt != ctx_cnt: raise KsftSkipEx(f"Tested only {ctx_cnt} contexts, wanted {requested_ctx_cnt}") @@ -230,18 +241,19 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure def check_traffic(): for i in range(ctx_cnt): - cnts = _get_rx_cnts(cfg) - GenerateTraffic(cfg, port=ports[i]).wait_pkts_and_stop(20000) - cnts = _get_rx_cnts(cfg, prev=cnts) - if ctx[i]: - directed = sum(cnts[2+i*2:4+i*2]) - ksft_lt(sum(cnts[ :2]), directed / 2, "traffic on main context:" + str(cnts)) - ksft_ge(directed, 20000, f"traffic on context {i}: " + str(cnts)) - ksft_eq(sum(cnts[2:2+i*2] + cnts[4+i*2:]), 0, "traffic on other contexts: " + str(cnts)) + expected = { + 'target': (2+i*2, 3+i*2), + 'noise': (0, 1), + 'empty': list(range(2, 2+i*2)) + list(range(4+i*2, 2+2*ctx_cnt)) + } else: - ksft_ge(sum(cnts[ :2]), 20000, "traffic on main context:" + str(cnts)) - ksft_eq(sum(cnts[2: ]), 0, "traffic on other contexts: " + str(cnts)) + expected = { + 'target': range(2), + 'empty': range(2, 2+2*ctx_cnt) + } + + _send_traffic_check(cfg, ports[i], f"context {i}", expected) # Use queues 0 and 1 for normal traffic ethtool(f"-X {cfg.ifname} equal 2") From patchwork Fri Jul 5 01:57:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13724318 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EDE31755A for ; Fri, 5 Jul 2024 01:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144653; cv=none; b=Aj3kaZNyCupv9urplGC7EGena/DxgCnDskjGcvQ9UKu6OVFyDaBf08II8BEjMHJUw5BzmTcxY5oEAk0W+SCqUGAZ38HvS/113S1cumUwxPi+VZV4g4FKFykwi/+M4azxrAfmQkWq/rKqskbFnl8Frob+NdfLdE6mXpMMTpFW24I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144653; c=relaxed/simple; bh=eXbbCNsf+ReqjmKdPjkK+/bd3F2B/dRrYSaWfd5Ed3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ljar3b/+066WF/kGiVN9o5Jt+TYNFMLUjRqH9Dig7s/8YUp/N02S/VPop0rmUl434Np3QROyoiwvVmH5AcNlOpoYRr2bQEj4+sECi29eAVr53elgFH2cUwZbKk40+GKywTbSeiJBFsl6eLn+AAkEiu0lWZdvFncRDWOKnT1srxQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rp3UepNl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rp3UepNl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B31EFC4AF10; Fri, 5 Jul 2024 01:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720144653; bh=eXbbCNsf+ReqjmKdPjkK+/bd3F2B/dRrYSaWfd5Ed3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rp3UepNlTQxPAAdM1uRSb/fQBysCZKylrCwSdFPuXN3fedJ/IoGH9t0qT1j0EvSUr 6RnUFVOHgGGlOmhnW+FnG3JSbz/y62sLiM1xq/daoaBQ7uYTs6Zg4RuXyGz7MdFkuK ElisefIsk7ihRvBx6S4wYbQMUAmRgKGwoPkJ4ZQP5ITJ1MQsfmr4UHHojxYR1Ei0Fz RYRy/F8bLF/4jxKU0Zg7kyBMWdQ1jx727Cs6Apf//zQUE/4i7tuM4XdFYZbSbUIgZv 4Rr5ecmmgyXMgBtB/zRnHtp8mppTmvD57thd1m/E6bb7pG56piRkooQocfJr0qhRbr U5SJaRE5TzYDg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, petrm@nvidia.com, przemyslaw.kitszel@intel.com, willemdebruijn.kernel@gmail.com, ecree.xilinx@gmail.com, Jakub Kicinski Subject: [PATCH net-next 3/5] selftests: drv-net: rss_ctx: test queue changes vs user RSS config Date: Thu, 4 Jul 2024 18:57:23 -0700 Message-ID: <20240705015725.680275-4-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705015725.680275-1-kuba@kernel.org> References: <20240705015725.680275-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org By default main RSS table should change to include all queues. When user sets a specific RSS config the driver should preserve it, even when queue count changes. Driver should refuse to deactivate queues used in the user-set RSS config. Signed-off-by: Jakub Kicinski --- .../selftests/drivers/net/hw/rss_ctx.py | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index a95842baef99..fbc234d6c395 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -129,6 +129,80 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_lt(sum(cnts[:2]), sum(cnts[2:]), "traffic distributed: " + str(cnts)) +def test_rss_queue_reconfigure(cfg, main_ctx=True): + """Make sure queue changes can't override requested RSS config. + + By default main RSS table should change to include all queues. + When user sets a specific RSS config the driver should preserve it, + even when queue count changes. Driver should refuse to deactivate + queues used in the user-set RSS config. + """ + + if not main_ctx: + require_ntuple(cfg) + + # Start with 4 queues, an arbitrary known number. + try: + qcnt = len(_get_rx_cnts(cfg)) + ethtool(f"-L {cfg.ifname} combined 4") + defer(ethtool, f"-L {cfg.ifname} combined {qcnt}") + except: + raise KsftSkipEx("Not enough queues for the test or qstat not supported") + + if main_ctx: + ctx_id = 0 + ctx_ref = "" + else: + ctx_id = ethtool_create(cfg, "-X", "context new") + ctx_ref = f"context {ctx_id}" + defer(ethtool, f"-X {cfg.ifname} {ctx_ref} delete") + + # Indirection table should be distributing to all queues. + data = get_rss(cfg, context=ctx_id) + ksft_eq(0, min(data['rss-indirection-table'])) + ksft_eq(3, max(data['rss-indirection-table'])) + + # Increase queues, indirection table should be distributing to all queues. + # It's unclear whether tables of additional contexts should be reset, too. + if main_ctx: + ethtool(f"-L {cfg.ifname} combined 5") + data = get_rss(cfg) + ksft_eq(0, min(data['rss-indirection-table'])) + ksft_eq(4, max(data['rss-indirection-table'])) + ethtool(f"-L {cfg.ifname} combined 4") + + # Configure the table explicitly + port = rand_port() + ethtool(f"-X {cfg.ifname} {ctx_ref} weight 1 0 0 1") + if main_ctx: + other_key = 'empty' + defer(ethtool, f"-X {cfg.ifname} default") + else: + other_key = 'noise' + flow = f"flow-type tcp{cfg.addr_ipver} dst-port {port} context {ctx_id}" + ntuple = ethtool_create(cfg, "-N", flow) + defer(ethtool, f"-N {cfg.ifname} delete {ntuple}") + + _send_traffic_check(cfg, port, ctx_ref, { 'target': (0, 3), + other_key: (1, 2) }) + + # We should be able to increase queues, but table should be left untouched + ethtool(f"-L {cfg.ifname} combined 5") + data = get_rss(cfg, context=ctx_id) + ksft_eq({0, 3}, set(data['rss-indirection-table'])) + + _send_traffic_check(cfg, port, ctx_ref, { 'target': (0, 3), + other_key: (1, 2, 4) }) + + # Setting queue count to 3 should fail, queue 3 is used + try: + ethtool(f"-L {cfg.ifname} combined 3") + except CmdExitFailure: + pass + else: + raise Exception(f"Driver didn't prevent us from deactivating a used queue (context {ctx_id})") + + def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None): """ Test separating traffic into RSS contexts. @@ -207,6 +281,10 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure test_rss_context(cfg, 4, create_with_cfg=True) +def test_rss_context_queue_reconfigure(cfg): + test_rss_queue_reconfigure(cfg, main_ctx=False) + + def test_rss_context_out_of_order(cfg, ctx_cnt=4): """ Test separating traffic into RSS contexts. @@ -358,8 +436,9 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure with NetDrvEpEnv(__file__, nsim_test=False) as cfg: cfg.netdevnl = NetdevFamily() - ksft_run([test_rss_key_indir, + ksft_run([test_rss_key_indir, test_rss_queue_reconfigure, test_rss_context, test_rss_context4, test_rss_context32, + test_rss_context_queue_reconfigure, test_rss_context_overlap, test_rss_context_overlap2, test_rss_context_out_of_order, test_rss_context4_create_with_cfg], args=(cfg, )) From patchwork Fri Jul 5 01:57:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13724319 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 209BA18AF4 for ; Fri, 5 Jul 2024 01:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144654; cv=none; b=bUszajS7vHAFANwAcbyWg0/G3v6iqfY7MmdZP/eK0umyv5imC+Y5X7aJNAevhwbWIOJTida5qfEW4/sOBeGzMFq6vqtSqV4i2lGgSysbANEZzFe/e8AqEgLK8d+kyYInqDQgJGRWMsF3bXXWrm3bd2kXYpiJEUlNh/VvnfzSkAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144654; c=relaxed/simple; bh=hHRSFUKZHAxlpHNuibtOX065mAxD8so0S2R7I11pZ4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4YZVIG3nu62tEFKVM6w3MaXXqSyx+UTE6yGU8BU5cJI8Iz9DoldvZerMzmgONrHTprUd3PCEP3En7wmrsjWjIaicNrRvnVeDy6/RWU/BYPrzRMuh05uPIpLrO3GKj55+HaucCcH0kxZvbyR/OwuRFuR0eeISuGWNiO4liU6h5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i3o3lcT+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i3o3lcT+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4681FC4AF17; Fri, 5 Jul 2024 01:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720144653; bh=hHRSFUKZHAxlpHNuibtOX065mAxD8so0S2R7I11pZ4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i3o3lcT+WnW/ug5UEAGhLCIFLTZ6jqPR8BJ2u84uJcYmY42lU/Wlzk4alIkIkU/V7 1dXknfxVT155t4KspTZKgrAN+i/uwr7vs/jD936oB1LkqhAtB0RQXCni+5pAOapBLy oFrjljKfN+4JRTvw5JeVgTObH7KI+UoNsL4Ttjdn35TU+6mtMHor3V3JQvix7Ohc1G bn1oMdVfXrl46Y0+wRTGE84YynKrtm46r3eBY7WKuKAl+ybIrSZKF7n7RovaQZveMe sDUU3SN0lph7gGKACgkmljg6mPhNl0/fzQKHi8AAVwMQy58ipsFUDyhVnSd3XC5AO4 fJqaUmZONUHJQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, petrm@nvidia.com, przemyslaw.kitszel@intel.com, willemdebruijn.kernel@gmail.com, ecree.xilinx@gmail.com, Jakub Kicinski Subject: [PATCH net-next 4/5] selftests: drv-net: rss_ctx: check behavior of indirection table resizing Date: Thu, 4 Jul 2024 18:57:24 -0700 Message-ID: <20240705015725.680275-5-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705015725.680275-1-kuba@kernel.org> References: <20240705015725.680275-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Some workloads may want to rehash the flows in response to an imbalance. Most effective way to do that is changing the RSS key. Check that changing the key does not cause link flaps or traffic disruption. Disrupting traffic for key update is not a bug, but makes the key update unusable for rehashing under load. Signed-off-by: Jakub Kicinski --- .../selftests/drivers/net/hw/rss_ctx.py | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index fbc234d6c395..f42807e39e0d 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -5,7 +5,7 @@ import datetime import random from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ge, ksft_lt from lib.py import NetDrvEpEnv -from lib.py import NetdevFamily +from lib.py import EthtoolFamily, NetdevFamily from lib.py import KsftSkipEx from lib.py import rand_port from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure @@ -203,6 +203,39 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure raise Exception(f"Driver didn't prevent us from deactivating a used queue (context {ctx_id})") +def test_rss_resize(cfg): + """Test resizing of the RSS table. + + Some devices dynamically increase and decrease the size of the RSS + indirection table based on the number of enabled queues. + When that happens driver must maintain the balance of entries + (preferably duplicating the smaller table). + """ + + channels = cfg.ethnl.channels_get({'header': {'dev-index': cfg.ifindex}}) + ch_max = channels['combined-max'] + qcnt = channels['combined-count'] + + if ch_max < 2: + raise KsftSkipEx(f"Not enough queues for the test: {ch_max}") + + ethtool(f"-L {cfg.ifname} combined 2") + defer(ethtool, f"-L {cfg.ifname} combined {qcnt}") + + ethtool(f"-X {cfg.ifname} weight 1 7") + defer(ethtool, f"-X {cfg.ifname} default") + + ethtool(f"-L {cfg.ifname} combined {ch_max}") + data = get_rss(cfg) + ksft_eq(0, min(data['rss-indirection-table'])) + ksft_eq(1, max(data['rss-indirection-table'])) + + ksft_eq(7, + data['rss-indirection-table'].count(1) / + data['rss-indirection-table'].count(0), + f"Table imbalance after resize: {data['rss-indirection-table']}") + + def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None): """ Test separating traffic into RSS contexts. @@ -434,9 +467,11 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure def main() -> None: with NetDrvEpEnv(__file__, nsim_test=False) as cfg: + cfg.ethnl = EthtoolFamily() cfg.netdevnl = NetdevFamily() ksft_run([test_rss_key_indir, test_rss_queue_reconfigure, + test_rss_resize, test_rss_context, test_rss_context4, test_rss_context32, test_rss_context_queue_reconfigure, test_rss_context_overlap, test_rss_context_overlap2, From patchwork Fri Jul 5 01:57:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13724320 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C40B1BC4F for ; Fri, 5 Jul 2024 01:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144654; cv=none; b=tZtLipmdAQnoyqVhkE7Epm+xeTMSE/rr2j+YCM1yFbXUblO5J408WkvLVP+6PRbpSbAlnWcRL0TLK/G5q32dCguqT04xUThI9JG063jaV+iQpEYUftuWRNBLSklpc1nRWOCYMEXHF3Psoer98E1EkBR1mc3E//veNUWxWSj3k/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720144654; c=relaxed/simple; bh=SIbEuTYh7K8QI/UY5f50+6n9Ap0yERyXt1+AyA5bq7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Suwk2owS9/9g3EKZvJWs6Ub7t4pklIA6ejNKbGZOMwlp+9NtFSAQmPVLtGvkF2XeJIfqUJImmgK/+PoEboIzlvdlkHwgcxT1UFLOW2dSsL5RRLTbL0/8WAAaM5vAmZDliauMLugXJCagA/VWm2XY1ybVmvdG0XIhQ5bTdProsCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y2S7C8V5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y2S7C8V5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3726C32781; Fri, 5 Jul 2024 01:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720144654; bh=SIbEuTYh7K8QI/UY5f50+6n9Ap0yERyXt1+AyA5bq7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2S7C8V5RCbYWdT6YwyrpTcdMLAzHfT6AmwTMP4ez2zMObpJC+LseM1aj2r+UoFhl 5EbV4qadRuu6QgB5Zv1ElKaeAvHlWIDWQnx+cfkJ4T0i2GEQytXT+09uy7a2BVT9a5 QGcNLKMLo9Fig/2GH9CyQh1ryX8fptYMYILh1N/ofNl9D6Y3yZCJMiMjblu42aHtSu j59C13vIniB3q3gC+M5x+0NYt4YTB0dX56o73w9OIvOoTxtN7WX8biRYsx5/oaKGAr 1bAAG0nXPCs6kBp0O+0ndKA3/PDerDypYIIEWUEvrzRAsMVl34gYNZ4sGIclVn4Q64 KE22WNvPERmxw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, petrm@nvidia.com, przemyslaw.kitszel@intel.com, willemdebruijn.kernel@gmail.com, ecree.xilinx@gmail.com, Jakub Kicinski Subject: [PATCH net-next 5/5] selftests: drv-net: rss_ctx: test flow rehashing without impacting traffic Date: Thu, 4 Jul 2024 18:57:25 -0700 Message-ID: <20240705015725.680275-6-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705015725.680275-1-kuba@kernel.org> References: <20240705015725.680275-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Some workloads may want to rehash the flows in response to an imbalance. Most effective way to do that is changing the RSS key. Check that changing the key does not cause link flaps or traffic disruption. Disrupting traffic for key update is not incorrect, but makes the key update unusable for rehashing under load. Signed-off-by: Jakub Kicinski --- .../selftests/drivers/net/hw/rss_ctx.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index f42807e39e0d..3c47ddc509e7 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -236,6 +236,36 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure f"Table imbalance after resize: {data['rss-indirection-table']}") +def test_hitless_key_update(cfg): + """Test that flows may be rehashed without impacting traffic. + + Some workloads may want to rehash the flows in response to an imbalance. + Most effective way to do that is changing the RSS key. Check that changing + the key does not cause link flaps or traffic disruption. + + Disrupting traffic for key update is not a bug, but makes the key + update unusable for rehashing under load. + """ + data = get_rss(cfg) + key_len = len(data['rss-hash-key']) + + key = _rss_key_rand(key_len) + + tgen = GenerateTraffic(cfg) + try: + errors0, carrier0 = get_drop_err_sum(cfg) + t0 = datetime.datetime.now() + ethtool(f"-X {cfg.ifname} hkey " + _rss_key_str(key)) + t1 = datetime.datetime.now() + errors1, carrier1 = get_drop_err_sum(cfg) + finally: + tgen.wait_pkts_and_stop(5000) + + ksft_lt((t1 - t0).total_seconds(), 0.2) + ksft_eq(errors1 - errors1, 0) + ksft_eq(carrier1 - carrier0, 0) + + def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None): """ Test separating traffic into RSS contexts. @@ -471,7 +501,7 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure cfg.netdevnl = NetdevFamily() ksft_run([test_rss_key_indir, test_rss_queue_reconfigure, - test_rss_resize, + test_rss_resize, test_hitless_key_update, test_rss_context, test_rss_context4, test_rss_context32, test_rss_context_queue_reconfigure, test_rss_context_overlap, test_rss_context_overlap2,