From patchwork Thu Sep 12 17:12:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802366 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04E71BF7E5 for ; Thu, 12 Sep 2024 17:12:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161176; cv=none; b=l5/Nhe/exfbQaeUOxsIr82lryrhcqWOt7JR5fZnM+4LA597DjgoDhrwS9uGwx1BBs9w2Rh0+OutbjL8zgShiCb5lfbTpZ2dCHgr/8e+/2xAjc6lROvPQIBLVcbPEcMPwkpd/gmp9IcbkZNT0qpMTchZtq6TbPQQZq0hUtDljIGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161176; c=relaxed/simple; bh=1ogZL8GdbW2aFlDOeHVyn14P4e17DWCzWxkTJ5g/vS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GEDIuFKeDjnXsDDPbk4KAhfXyNF5idBYCuIy8MjnkjkC0SQ1qeHNIUSWIrwsCpWwvjwzQ6pYVAqFtp6uV/J5V+0neI8094M5GXt8YikjQCmbJB+jCUby9r+pazILPyCKSyDnQ7eeSaKSZkPAZBbl22E47DZdvHS5GRcJT7xe9V8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2d8b68bddeaso80060a91.1 for ; Thu, 12 Sep 2024 10:12:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161174; x=1726765974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XDfolIjQlfBt1OrhxWrwJJpwruVFBq74SW3OsEBWFjs=; b=K7v4Gq8dwSu2jbHIDw4UXnDVKdd8M5dStcCorn5JwVVzyqRygMc4GPYhfN7CiJrjDx 6n2H9YhuYPxBbGeDkvZpjaXW/xQyhizLyp1RCMmZ6LaWCbiXlJSLV23+gV0Vc7da1pUr BDK0coZXR38iDtqqEvILI2mNeIw4JDqqfMyPkDaAHXOO1WF5Ozhwfyn3Tnp/v0jitoia 9lVttKrcn4/actTC0CrTcZBiBrYweNhTkPjJ4p5T8K1gtVP606ZYo0TJ9qkelnkNF48H 0ltzUN5r9VQuRdRIk9MLHflH2uo6OFz3F7JRw/tTUbjr/NL4DcTabPmkul8zRveOe0YU JKHw== X-Gm-Message-State: AOJu0Ywevp9j7AqjXaPnnYASNPuLtxRKQnRmXCOfBGEDXT/R3meUwbnA FZdoc3T1C8IXIRCu63nhDEVI1g7tr43dzTBcqRl6Cm9exAx1odv+n8Uw X-Google-Smtp-Source: AGHT+IEDYyJbCyhLvorf67CpddF8LJ/r4AFLPItCBdEYasDil5w3rtEUadjLqky2Nxzqmbd+MNjx0w== X-Received: by 2002:a17:90a:ad92:b0:2d3:bfc3:3ef3 with SMTP id 98e67ed59e1d1-2db9ff958f7mr3872847a91.12.1726161173672; Thu, 12 Sep 2024 10:12:53 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db070b14d3sm10716048a91.6.2024.09.12.10.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:12:53 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 01/13] selftests: ncdevmem: Add a flag for the selftest Date: Thu, 12 Sep 2024 10:12:39 -0700 Message-ID: <20240912171251.937743-2-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 And rename it to 'probing'. This is gonna be used in the selftests to probe devmem functionality. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 64d6805381c5..352dba211fb0 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -523,8 +523,9 @@ void run_devmem_tests(void) int main(int argc, char *argv[]) { int is_server = 0, opt; + int probe = 0; - while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:")) != -1) { + while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:P")) != -1) { switch (opt) { case 'l': is_server = 1; @@ -550,6 +551,9 @@ int main(int argc, char *argv[]) case 'f': ifname = optarg; break; + case 'P': + probe = 1; + break; case '?': printf("unknown option: %c\n", optopt); break; @@ -561,7 +565,10 @@ int main(int argc, char *argv[]) for (; optind < argc; optind++) printf("extra arguments: %s\n", argv[optind]); - run_devmem_tests(); + if (probe) { + run_devmem_tests(); + return 0; + } if (is_server) return do_server(); From patchwork Thu Sep 12 17:12:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802367 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2F6C1BF7F5 for ; Thu, 12 Sep 2024 17:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161177; cv=none; b=lA5VqBA9YAROrcsjxwQLUYzPZOzQqJ2i5CBk6BoV/8O2DtnK5pIzKn3NhyRWBAPKQ3bbRyZ3Aj2kTGb/O+GhfzQ3xxuoKWiXHCet6TzaLBCO6PbQpb6PX1QdP/pyqHWPjsMkdfMi9MYOQubzIZI0nYuGxGqATF7vPL1TYQoo8cI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161177; c=relaxed/simple; bh=ZZwG2rA865vWgcFv5hZ893muSsVy0VO4tdc8D/RR4Xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nc+UTMoEqcr417K9+HcLK8tDzraJT+AcamNBofYiwmrYGT4EDDjgA1nEEgxuo4RUUoXT2kCyElQvVImWvJB5Wjy/LoMGON+lN9Ml1w6jC4GaNHRnHjoM9liVa3/buI78E7UlGgN+yDaOQUeqk4qOEJaqgSz1sgRwdLoxMjiC/Do= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7d916b6a73aso835929a12.1 for ; Thu, 12 Sep 2024 10:12:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161175; x=1726765975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5M2BKgPdX1r5+Ca91xOL66iD0WupjvW0MfHAuV+BcDo=; b=XRZ/3azL588g8DMeZlBNua6v0wIPak5THCZ0HIa15cSS5CW0kcfPwdGnTGMUqeHO3q 8gG1O45BH7snMIcyBm6oWGlhLXpfcHH6RnDp4fwQkbqvv/GUtYe1iDq1WI2R3L5dYyWT 9ZyX1kPK+nMGH69tWQl0/ZJUgV0elwlGE50S8/bJIp4icF1s/UYsZhdEWDXTEPBhT5KP 3VUauW6xB9VKoQUw+HU3xk12oqcF58BGXMu8i2CBPOmfKxCigv8DNkzQPvmSIgLsMqV9 74AYE5ubfgUVXbb/LuOLixoLBIyqJ9T/RNCN+6trKJXaMc3rQOxc+NvNHEayGwjQ1JD2 jqVw== X-Gm-Message-State: AOJu0YzVJLsvd50MBNFqC5VAs9P97YZmVA3+Ewde3ni5hpzvE3jWjIl/ CHPNFCZnpmP3NAfFIzhQjuE3GDSkQX3M4C7JYRDTEeKnJZJYG8Efv5I6 X-Google-Smtp-Source: AGHT+IE08q9U+FFpqWsxTPciAB/N0YS2pvsQkPY4UbhySf0mFOZyE2Tpuk71+E3CCQ+ZHBTwC3XLvA== X-Received: by 2002:a17:90a:2f23:b0:2d8:82a2:b093 with SMTP id 98e67ed59e1d1-2db9ffcaab5mr3965099a91.13.1726161174790; Thu, 12 Sep 2024 10:12:54 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadb42e6fasm13008750a91.0.2024.09.12.10.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:12:54 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 02/13] selftests: ncdevmem: Remove validation Date: Thu, 12 Sep 2024 10:12:40 -0700 Message-ID: <20240912171251.937743-3-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 ncdevmem should (see next patches) print the payload on the stdout. The validation can and should be done by the callers: $ ncdevmem -l ... > file $ sha256sum file Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 56 +++----------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 352dba211fb0..3712296d997b 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -64,24 +64,13 @@ static char *server_ip = "192.168.1.4"; static char *client_ip = "192.168.1.2"; static char *port = "5201"; -static size_t do_validation; static int start_queue = 8; static int num_queues = 8; static char *ifname = "eth1"; static unsigned int ifindex; static unsigned int dmabuf_id; -void print_bytes(void *ptr, size_t size) -{ - unsigned char *p = ptr; - int i; - - for (i = 0; i < size; i++) - printf("%02hhX ", p[i]); - printf("\n"); -} - -void print_nonzero_bytes(void *ptr, size_t size) +static void print_nonzero_bytes(void *ptr, size_t size) { unsigned char *p = ptr; unsigned int i; @@ -91,30 +80,6 @@ void print_nonzero_bytes(void *ptr, size_t size) printf("\n"); } -void validate_buffer(void *line, size_t size) -{ - static unsigned char seed = 1; - unsigned char *ptr = line; - int errors = 0; - size_t i; - - for (i = 0; i < size; i++) { - if (ptr[i] != seed) { - fprintf(stderr, - "Failed validation: expected=%u, actual=%u, index=%lu\n", - seed, ptr[i], i); - errors++; - if (errors > 20) - error(1, 0, "validation failed."); - } - seed++; - if (seed == do_validation) - seed = 0; - } - - fprintf(stdout, "Validated buffer\n"); -} - #define run_command(cmd, ...) \ ({ \ char command[256]; \ @@ -414,16 +379,10 @@ int do_server(void) sync.flags = DMA_BUF_SYNC_READ | DMA_BUF_SYNC_START; ioctl(buf, DMA_BUF_IOCTL_SYNC, &sync); - if (do_validation) - validate_buffer( - ((unsigned char *)buf_mem) + - dmabuf_cmsg->frag_offset, - dmabuf_cmsg->frag_size); - else - print_nonzero_bytes( - ((unsigned char *)buf_mem) + - dmabuf_cmsg->frag_offset, - dmabuf_cmsg->frag_size); + print_nonzero_bytes( + ((unsigned char *)buf_mem) + + dmabuf_cmsg->frag_offset, + dmabuf_cmsg->frag_size); sync.flags = DMA_BUF_SYNC_READ | DMA_BUF_SYNC_END; ioctl(buf, DMA_BUF_IOCTL_SYNC, &sync); @@ -525,7 +484,7 @@ int main(int argc, char *argv[]) int is_server = 0, opt; int probe = 0; - while ((opt = getopt(argc, argv, "ls:c:p:v:q:t:f:P")) != -1) { + while ((opt = getopt(argc, argv, "ls:c:p:q:t:f:P")) != -1) { switch (opt) { case 'l': is_server = 1; @@ -539,9 +498,6 @@ int main(int argc, char *argv[]) case 'p': port = optarg; break; - case 'v': - do_validation = atoll(optarg); - break; case 'q': num_queues = atoi(optarg); break; From patchwork Thu Sep 12 17:12:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802368 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1395C1BF800 for ; Thu, 12 Sep 2024 17:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161178; cv=none; b=rEYtoF+Ysdc3VJ70f/S7dR6rKk+LXgxUsDcXJqo7s6yftpjNTV2B7nPMsl35HMwTGm0ACe2Dz3LmEjbj5lOhk+YLUt2mv86AGau7+qT9DHNt2SlWzMAg5a4UZePrksPZgaBuotGMkvQiq5hxDkSWcQaltAb9C/BOzBBP0nTx9Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161178; c=relaxed/simple; bh=qIU/Uno9BJxJdIy//auK6K9HWLg2TXD1Haiyu7O/j+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QJ7cgs9zeexufqUefs/k+lru1a+VcD0rPdJhGX5UsM7lVABUYHDShQhT237iE+crQXAYltHsdlmZOIBIyLYXAgWNEuCipqZf88wzWy0sxKYnVfEY6fatOrdIMKCecZCoKKnT/PPEli3OefMuK+eq7GrSJa+H8OwFdJfDim8YryE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-207397d1000so18761365ad.0 for ; Thu, 12 Sep 2024 10:12:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161176; x=1726765976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sgsSTQx8vMbVv0FXXtJf2mFV9lIEgAihpXa+rCJ+4lM=; b=f1wZ9/RuOVIqB7LPGhX0dtmjNYxfh9aRX/4a9M0Vf484zxh/g1T0Qwicv48zu6ol08 JLWZ/D9OF4Lp3rif3uAJ0/QMTH0+TX9wsK9pnClGaschb2a/NFD+TaME9PwiaEyNUCQ8 Bd9ExGeE8UXno+hPgu42ptdThFmv6E8hhICOXgrLYEVlFJuuq7k8u4oH2qcPBMJOhEFq 5l9njC0wDtxnp97nyTlz5xsW5SAwoOqhaNezZjEo9GoqQRrie7BkeFIu7yebJ0LMDKq6 cfLJjo8vjTlvIW907HoxCsBVpr5QwfN5g9iPj02RcNaQgZi5yVAtmlPngixckjEiodOe qlbQ== X-Gm-Message-State: AOJu0YwH6WKM1WFv0VHVuRK571iwzRLxt2nbM1+niq4JWOcvw9fKdS3k ZBHLGVXF6l0OnFQkkvWnIXrCuaUy+Bw2LhJTd3FHQ8j9jgZb6OI7DOHv X-Google-Smtp-Source: AGHT+IFJDb6E6GVMvg/hD0flfDJZ07IsSccmeKBUlhjRvcR4i4zkhulsh6nwHsS2AsBGxUFueWzRSQ== X-Received: by 2002:a17:903:230b:b0:202:2e81:27cd with SMTP id d9443c01a7336-2074c760c12mr123968835ad.26.1726161176003; Thu, 12 Sep 2024 10:12:56 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afdc382sm16523715ad.171.2024.09.12.10.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:12:55 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 03/13] selftests: ncdevmem: Redirect all non-payload output to stderr Date: Thu, 12 Sep 2024 10:12:41 -0700 Message-ID: <20240912171251.937743-4-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 That should make it possible to do expected payload validation on the caller side. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 61 +++++++++++++------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 3712296d997b..7fb930571ff9 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -77,7 +77,6 @@ static void print_nonzero_bytes(void *ptr, size_t size) for (i = 0; i < size; i++) putchar(p[i]); - printf("\n"); } #define run_command(cmd, ...) \ @@ -85,7 +84,7 @@ static void print_nonzero_bytes(void *ptr, size_t size) char command[256]; \ memset(command, 0, sizeof(command)); \ snprintf(command, sizeof(command), cmd, ##__VA_ARGS__); \ - printf("Running: %s\n", command); \ + fprintf(stderr, "Running: %s\n", command); \ system(command); \ }) @@ -93,22 +92,22 @@ static int reset_flow_steering(void) { int ret = 0; - ret = run_command("sudo ethtool -K %s ntuple off", ifname); + ret = run_command("sudo ethtool -K %s ntuple off >&2", ifname); if (ret) return ret; - return run_command("sudo ethtool -K %s ntuple on", ifname); + return run_command("sudo ethtool -K %s ntuple on >&2", ifname); } static int configure_headersplit(bool on) { - return run_command("sudo ethtool -G %s tcp-data-split %s", ifname, + return run_command("sudo ethtool -G %s tcp-data-split %s >&2", ifname, on ? "on" : "off"); } static int configure_rss(void) { - return run_command("sudo ethtool -X %s equal %d", ifname, start_queue); + return run_command("sudo ethtool -X %s equal %d >&2", ifname, start_queue); } static int configure_channels(unsigned int rx, unsigned int tx) @@ -118,7 +117,7 @@ static int configure_channels(unsigned int rx, unsigned int tx) static int configure_flow_steering(void) { - return run_command("sudo ethtool -N %s flow-type tcp4 src-ip %s dst-ip %s src-port %s dst-port %s queue %d", + return run_command("sudo ethtool -N %s flow-type tcp4 src-ip %s dst-ip %s src-port %s dst-port %s queue %d >&2", ifname, client_ip, server_ip, port, port, start_queue); } @@ -152,7 +151,7 @@ static int bind_rx_queue(unsigned int ifindex, unsigned int dmabuf_fd, goto err_close; } - printf("got dmabuf id=%d\n", rsp->id); + fprintf(stderr, "got dmabuf id=%d\n", rsp->id); dmabuf_id = rsp->id; netdev_bind_rx_req_free(req); @@ -279,8 +278,8 @@ int do_server(void) if (ret) error(errno, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); - printf("binding to address %s:%d\n", server_ip, - ntohs(server_sin.sin_port)); + fprintf(stderr, "binding to address %s:%d\n", server_ip, + ntohs(server_sin.sin_port)); ret = bind(socket_fd, &server_sin, sizeof(server_sin)); if (ret) @@ -294,14 +293,14 @@ int do_server(void) inet_ntop(server_sin.sin_family, &server_sin.sin_addr, buffer, sizeof(buffer)); - printf("Waiting or connection on %s:%d\n", buffer, - ntohs(server_sin.sin_port)); + fprintf(stderr, "Waiting or connection on %s:%d\n", buffer, + ntohs(server_sin.sin_port)); client_fd = accept(socket_fd, &client_addr, &client_addr_len); inet_ntop(client_addr.sin_family, &client_addr.sin_addr, buffer, sizeof(buffer)); - printf("Got connection from %s:%d\n", buffer, - ntohs(client_addr.sin_port)); + fprintf(stderr, "Got connection from %s:%d\n", buffer, + ntohs(client_addr.sin_port)); while (1) { struct iovec iov = { .iov_base = iobuf, @@ -314,14 +313,13 @@ int do_server(void) ssize_t ret; is_devmem = false; - printf("\n\n"); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = ctrl_data; msg.msg_controllen = sizeof(ctrl_data); ret = recvmsg(client_fd, &msg, MSG_SOCK_DEVMEM); - printf("recvmsg ret=%ld\n", ret); + fprintf(stderr, "recvmsg ret=%ld\n", ret); if (ret < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) continue; if (ret < 0) { @@ -329,7 +327,7 @@ int do_server(void) continue; } if (ret == 0) { - printf("client exited\n"); + fprintf(stderr, "client exited\n"); goto cleanup; } @@ -338,7 +336,7 @@ int do_server(void) if (cm->cmsg_level != SOL_SOCKET || (cm->cmsg_type != SCM_DEVMEM_DMABUF && cm->cmsg_type != SCM_DEVMEM_LINEAR)) { - fprintf(stdout, "skipping non-devmem cmsg\n"); + fprintf(stderr, "skipping non-devmem cmsg\n"); continue; } @@ -349,7 +347,7 @@ int do_server(void) /* TODO: process data copied from skb's linear * buffer. */ - fprintf(stdout, + fprintf(stderr, "SCM_DEVMEM_LINEAR. dmabuf_cmsg->frag_size=%u\n", dmabuf_cmsg->frag_size); @@ -360,12 +358,13 @@ int do_server(void) token.token_count = 1; total_received += dmabuf_cmsg->frag_size; - printf("received frag_page=%llu, in_page_offset=%llu, frag_offset=%llu, frag_size=%u, token=%u, total_received=%lu, dmabuf_id=%u\n", - dmabuf_cmsg->frag_offset >> PAGE_SHIFT, - dmabuf_cmsg->frag_offset % getpagesize(), - dmabuf_cmsg->frag_offset, dmabuf_cmsg->frag_size, - dmabuf_cmsg->frag_token, total_received, - dmabuf_cmsg->dmabuf_id); + fprintf(stderr, + "received frag_page=%llu, in_page_offset=%llu, frag_offset=%llu, frag_size=%u, token=%u, total_received=%lu, dmabuf_id=%u\n", + dmabuf_cmsg->frag_offset >> PAGE_SHIFT, + dmabuf_cmsg->frag_offset % getpagesize(), + dmabuf_cmsg->frag_offset, + dmabuf_cmsg->frag_size, dmabuf_cmsg->frag_token, + total_received, dmabuf_cmsg->dmabuf_id); if (dmabuf_cmsg->dmabuf_id != dmabuf_id) error(1, 0, @@ -397,15 +396,15 @@ int do_server(void) if (!is_devmem) error(1, 0, "flow steering error\n"); - printf("total_received=%lu\n", total_received); + fprintf(stderr, "total_received=%lu\n", total_received); } - fprintf(stdout, "%s: ok\n", TEST_PREFIX); + fprintf(stderr, "%s: ok\n", TEST_PREFIX); - fprintf(stdout, "page_aligned_frags=%lu, non_page_aligned_frags=%lu\n", + fprintf(stderr, "page_aligned_frags=%lu, non_page_aligned_frags=%lu\n", page_aligned_frags, non_page_aligned_frags); - fprintf(stdout, "page_aligned_frags=%lu, non_page_aligned_frags=%lu\n", + fprintf(stderr, "page_aligned_frags=%lu, non_page_aligned_frags=%lu\n", page_aligned_frags, non_page_aligned_frags); cleanup: @@ -511,7 +510,7 @@ int main(int argc, char *argv[]) probe = 1; break; case '?': - printf("unknown option: %c\n", optopt); + fprintf(stderr, "unknown option: %c\n", optopt); break; } } @@ -519,7 +518,7 @@ int main(int argc, char *argv[]) ifindex = if_nametoindex(ifname); for (; optind < argc; optind++) - printf("extra arguments: %s\n", argv[optind]); + fprintf(stderr, "extra arguments: %s\n", argv[optind]); if (probe) { run_devmem_tests(); From patchwork Thu Sep 12 17:12:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802369 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 290421BF812 for ; Thu, 12 Sep 2024 17:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161180; cv=none; b=inCyur1Zel5gE2EyM2M1xrV4Ny9+P+jKKsUbjivpC9TJttU50PdX+C0pFlLqQLPBwjKV0B0cZXpCBJ2mxtuTvJBlfan+4X3OZCtQ8Nd7vpIQ/LUwpqdTf/forff95v9E7OgAwVxgr0VDiEOdeoukWtsb7rN7L0WoCA/FqHhT+Zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161180; c=relaxed/simple; bh=oj70vBHAgwQssZjZmBhDuAC0iCaRum9klEXJ59CT4HA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V8LE17/UukeoSZXTV5q7H2MEazuneExmKBax9Q3MNHoxYuGyCKVRSbEuh/LHVflMOCAw4lkYNASPnpo2l6tTUrgk1Y+fFvpqMuCPbCQvnvKLzgrKj2c5CQkXUWPbnmaPM4tk97iyVkiRQnNtdwZ10miQoHH5D2KQkTnB/YwFsvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7179802b8fcso81146b3a.1 for ; Thu, 12 Sep 2024 10:12:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161177; x=1726765977; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hZ69pCclpRYKjNusVNIS764L44F9OcXi+j0TNRp4I60=; b=BxeNEq4IFTh0fEBNLDG11KJM1rjWQrtMTKbdz4hIdYPvexC5mbJDY5XExPSyltbC3n qCiLMfvAn2INIZYb1hmRsYS5kLDPvNr8FG/jy0WgM4E8SL8hislJrxt6TZGZ4w5vKsH5 BmJYp8DHj3olteE2jsG0S/IDga6sCinMJrtJOFxV4JjTRi+P1FsvqgxGHaua4Wp/MQ01 5TeBDjqRa8vb7+qavqdjZDDqk9y+17/iFc2VfD9lpO/s3HA4b0wW9IcjJMWoJ1M0vD+Y lDgFC9s4LSDBcEW7YxrgoX1sM5yqjCpG3h3UNUe+wNsJa7LCDbr0ljeE4pLCunvbN23Y qDkg== X-Gm-Message-State: AOJu0YwPDubXeVvavu9Y+OMj19iWMuukBnsVEF0NRhMEdeAZJ+7o0sMQ aXnzKEkAsZht4J6J5Y7xAQBGgVBT+f2OTOszMtylLxoNPuQ08ego/Z7o X-Google-Smtp-Source: AGHT+IGGQDSGh63CcKSl+QDaUh/jdRzxj+I09BURoP9aDUe5R3yj3VAjQO0oT0fzMYpPZeFf5G7oow== X-Received: by 2002:a05:6a00:2789:b0:713:f127:ad5c with SMTP id d2e1a72fcca58-7192622c7a3mr4664917b3a.28.1726161177203; Thu, 12 Sep 2024 10:12:57 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-719090c5349sm4815674b3a.191.2024.09.12.10.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:12:56 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 04/13] selftests: ncdevmem: Separate out dmabuf provider Date: Thu, 12 Sep 2024 10:12:42 -0700 Message-ID: <20240912171251.937743-5-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 So we can plug the other ones in the future if needed. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 209 ++++++++++++++++--------- 1 file changed, 136 insertions(+), 73 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 7fb930571ff9..a20f40adfde8 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -70,6 +70,117 @@ static char *ifname = "eth1"; static unsigned int ifindex; static unsigned int dmabuf_id; +struct memory_buffer { + int fd; + size_t size; + + int devfd; + int memfd; + char *buf_mem; +}; + +struct memory_provider { + struct memory_buffer *(*alloc)(size_t size); + void (*free)(struct memory_buffer *ctx); + void (*memcpy_to_device)(struct memory_buffer *dst, size_t off, + void *src, int n); + void (*memcpy_from_device)(void *dst, struct memory_buffer *src, + size_t off, int n); +}; + +static struct memory_buffer *udmabuf_alloc(size_t size) +{ + struct udmabuf_create create; + struct memory_buffer *ctx; + int ret; + + ctx = malloc(sizeof(*ctx)); + if (!ctx) + error(1, ENOMEM, "malloc failed"); + + ctx->size = size; + + ctx->devfd = open("/dev/udmabuf", O_RDWR); + if (ctx->devfd < 0) + error(1, errno, + "%s: [skip,no-udmabuf: Unable to access DMA buffer device file]\n", + TEST_PREFIX); + + ctx->memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING); + if (ctx->memfd < 0) + error(1, errno, "%s: [skip,no-memfd]\n", TEST_PREFIX); + + ret = fcntl(ctx->memfd, F_ADD_SEALS, F_SEAL_SHRINK); + if (ret < 0) + error(1, errno, "%s: [skip,fcntl-add-seals]\n", TEST_PREFIX); + + ret = ftruncate(ctx->memfd, size); + if (ret == -1) + error(1, errno, "%s: [FAIL,memfd-truncate]\n", TEST_PREFIX); + + memset(&create, 0, sizeof(create)); + + create.memfd = ctx->memfd; + create.offset = 0; + create.size = size; + ctx->fd = ioctl(ctx->devfd, UDMABUF_CREATE, &create); + if (ctx->fd < 0) + error(1, errno, "%s: [FAIL, create udmabuf]\n", TEST_PREFIX); + + ctx->buf_mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, + ctx->fd, 0); + if (ctx->buf_mem == MAP_FAILED) + error(1, errno, "%s: [FAIL, map udmabuf]\n", TEST_PREFIX); + + return ctx; +} + +static void udmabuf_free(struct memory_buffer *ctx) +{ + munmap(ctx->buf_mem, ctx->size); + close(ctx->fd); + close(ctx->memfd); + close(ctx->devfd); + free(ctx); +} + +static void udmabuf_memcpy_to_device(struct memory_buffer *dst, size_t off, + void *src, int n) +{ + struct dma_buf_sync sync = {}; + + sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE; + ioctl(dst->fd, DMA_BUF_IOCTL_SYNC, &sync); + + memcpy(dst->buf_mem + off, src, n); + + sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE; + ioctl(dst->fd, DMA_BUF_IOCTL_SYNC, &sync); +} + +static void udmabuf_memcpy_from_device(void *dst, struct memory_buffer *src, + size_t off, int n) +{ + struct dma_buf_sync sync = {}; + + sync.flags = DMA_BUF_SYNC_START; + ioctl(src->fd, DMA_BUF_IOCTL_SYNC, &sync); + + memcpy(dst, src->buf_mem + off, n); + + sync.flags = DMA_BUF_SYNC_END; + ioctl(src->fd, DMA_BUF_IOCTL_SYNC, &sync); +} + +static struct memory_provider udmabuf_memory_provider = { + .alloc = udmabuf_alloc, + .free = udmabuf_free, + .memcpy_to_device = udmabuf_memcpy_to_device, + .memcpy_from_device = udmabuf_memcpy_from_device, +}; + +static struct memory_provider *provider = &udmabuf_memory_provider; + static void print_nonzero_bytes(void *ptr, size_t size) { unsigned char *p = ptr; @@ -166,42 +277,7 @@ static int bind_rx_queue(unsigned int ifindex, unsigned int dmabuf_fd, return -1; } -static void create_udmabuf(int *devfd, int *memfd, int *buf, size_t dmabuf_size) -{ - struct udmabuf_create create; - int ret; - - *devfd = open("/dev/udmabuf", O_RDWR); - if (*devfd < 0) { - error(70, 0, - "%s: [skip,no-udmabuf: Unable to access DMA buffer device file]\n", - TEST_PREFIX); - } - - *memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING); - if (*memfd < 0) - error(70, 0, "%s: [skip,no-memfd]\n", TEST_PREFIX); - - /* Required for udmabuf */ - ret = fcntl(*memfd, F_ADD_SEALS, F_SEAL_SHRINK); - if (ret < 0) - error(73, 0, "%s: [skip,fcntl-add-seals]\n", TEST_PREFIX); - - ret = ftruncate(*memfd, dmabuf_size); - if (ret == -1) - error(74, 0, "%s: [FAIL,memfd-truncate]\n", TEST_PREFIX); - - memset(&create, 0, sizeof(create)); - - create.memfd = *memfd; - create.offset = 0; - create.size = dmabuf_size; - *buf = ioctl(*devfd, UDMABUF_CREATE, &create); - if (*buf < 0) - error(75, 0, "%s: [FAIL, create udmabuf]\n", TEST_PREFIX); -} - -int do_server(void) +int do_server(struct memory_buffer *mem) { char ctrl_data[sizeof(int) * 20000]; struct netdev_queue_id *queues; @@ -209,23 +285,18 @@ int do_server(void) struct sockaddr_in client_addr; struct sockaddr_in server_sin; size_t page_aligned_frags = 0; - int devfd, memfd, buf, ret; size_t total_received = 0; socklen_t client_addr_len; bool is_devmem = false; - char *buf_mem = NULL; + char *tmp_mem = NULL; struct ynl_sock *ys; - size_t dmabuf_size; char iobuf[819200]; char buffer[256]; int socket_fd; int client_fd; size_t i = 0; int opt = 1; - - dmabuf_size = getpagesize() * NUM_PAGES; - - create_udmabuf(&devfd, &memfd, &buf, dmabuf_size); + int ret; if (reset_flow_steering()) error(1, 0, "Failed to reset flow steering\n"); @@ -249,13 +320,12 @@ int do_server(void) queues[i].id = start_queue + i; } - if (bind_rx_queue(ifindex, buf, queues, num_queues, &ys)) + if (bind_rx_queue(ifindex, mem->fd, queues, num_queues, &ys)) error(1, 0, "Failed to bind\n"); - buf_mem = mmap(NULL, dmabuf_size, PROT_READ | PROT_WRITE, MAP_SHARED, - buf, 0); - if (buf_mem == MAP_FAILED) - error(1, 0, "mmap()"); + tmp_mem = malloc(mem->size); + if (!tmp_mem) + error(1, ENOMEM, "malloc failed"); server_sin.sin_family = AF_INET; server_sin.sin_port = htons(atoi(port)); @@ -306,7 +376,6 @@ int do_server(void) struct iovec iov = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; struct dmabuf_cmsg *dmabuf_cmsg = NULL; - struct dma_buf_sync sync = { 0 }; struct cmsghdr *cm = NULL; struct msghdr msg = { 0 }; struct dmabuf_token token; @@ -375,16 +444,11 @@ int do_server(void) else page_aligned_frags++; - sync.flags = DMA_BUF_SYNC_READ | DMA_BUF_SYNC_START; - ioctl(buf, DMA_BUF_IOCTL_SYNC, &sync); - - print_nonzero_bytes( - ((unsigned char *)buf_mem) + - dmabuf_cmsg->frag_offset, - dmabuf_cmsg->frag_size); + provider->memcpy_from_device(tmp_mem, mem, + dmabuf_cmsg->frag_offset, + dmabuf_cmsg->frag_size); - sync.flags = DMA_BUF_SYNC_READ | DMA_BUF_SYNC_END; - ioctl(buf, DMA_BUF_IOCTL_SYNC, &sync); + print_nonzero_bytes(tmp_mem, dmabuf_cmsg->frag_size); ret = setsockopt(client_fd, SOL_SOCKET, SO_DEVMEM_DONTNEED, &token, @@ -409,12 +473,9 @@ int do_server(void) cleanup: - munmap(buf_mem, dmabuf_size); + free(tmp_mem); close(client_fd); close(socket_fd); - close(buf); - close(memfd); - close(devfd); ynl_sock_destroy(ys); return 0; @@ -423,14 +484,11 @@ int do_server(void) void run_devmem_tests(void) { struct netdev_queue_id *queues; - int devfd, memfd, buf; + struct memory_buffer *mem; struct ynl_sock *ys; - size_t dmabuf_size; size_t i = 0; - dmabuf_size = getpagesize() * NUM_PAGES; - - create_udmabuf(&devfd, &memfd, &buf, dmabuf_size); + mem = provider->alloc(getpagesize() * NUM_PAGES); /* Configure RSS to divert all traffic from our devmem queues */ if (configure_rss()) @@ -441,7 +499,7 @@ void run_devmem_tests(void) if (configure_headersplit(1)) error(1, 0, "Failed to configure header split\n"); - if (!bind_rx_queue(ifindex, buf, queues, num_queues, &ys)) + if (!bind_rx_queue(ifindex, mem->fd, queues, num_queues, &ys)) error(1, 0, "Binding empty queues array should have failed\n"); for (i = 0; i < num_queues; i++) { @@ -454,7 +512,7 @@ void run_devmem_tests(void) if (configure_headersplit(0)) error(1, 0, "Failed to configure header split\n"); - if (!bind_rx_queue(ifindex, buf, queues, num_queues, &ys)) + if (!bind_rx_queue(ifindex, mem->fd, queues, num_queues, &ys)) error(1, 0, "Configure dmabuf with header split off should have failed\n"); if (configure_headersplit(1)) @@ -467,7 +525,7 @@ void run_devmem_tests(void) queues[i].id = start_queue + i; } - if (bind_rx_queue(ifindex, buf, queues, num_queues, &ys)) + if (bind_rx_queue(ifindex, mem->fd, queues, num_queues, &ys)) error(1, 0, "Failed to bind\n"); /* Deactivating a bound queue should not be legal */ @@ -476,12 +534,16 @@ void run_devmem_tests(void) /* Closing the netlink socket does an implicit unbind */ ynl_sock_destroy(ys); + + provider->free(mem); } int main(int argc, char *argv[]) { + struct memory_buffer *mem; int is_server = 0, opt; int probe = 0; + int ret; while ((opt = getopt(argc, argv, "ls:c:p:q:t:f:P")) != -1) { switch (opt) { @@ -525,8 +587,9 @@ int main(int argc, char *argv[]) return 0; } - if (is_server) - return do_server(); + mem = provider->alloc(getpagesize() * NUM_PAGES); + ret = is_server ? do_server(mem) : 1; + provider->free(mem); - return 0; + return ret; } From patchwork Thu Sep 12 17:12:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802370 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 924801BF800 for ; Thu, 12 Sep 2024 17:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161180; cv=none; b=kECFnXfBFTjwhT2iuEF4tVLWXt9dD5pDeqWtIrCmy0k/3R7J9qvy92XYRZLjzGE1qW6t8/YTyLOe0cXsWrLM8OMU86hl09PJJ+nZA0Qx+k9cju4AV+WVAc4I/Vi0RmUs5t9ljULNnbAnRGgVUWjyrWgZyL5Wr8/HeoN1myDm4Eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161180; c=relaxed/simple; bh=/qkpkrMunVECO3NqnNNvX4ewF3vz3vycvMLZPT0TKe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pBn5OZ+TCM7uX0Cyks1GWC79M3wRO0KV/tcaL0fDCeZA9LjTVUlcsQLCPHcHP3tUHOfa/1i2z2T+TkuObg2ejR88ktRxCtIz/XvUNjeCGjKEvCmj/2kXIXxJD+4LQt20BNqKu0gLgs0xcjJT1Ayui/MVuxbSQABdxzpUm/0hefY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2068a7c9286so45595ad.1 for ; Thu, 12 Sep 2024 10:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161179; x=1726765979; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=965vafb/SxlbMCGVTQsZKXFKp1G88lIqDgorHSu9Pdg=; b=WvLVdLoyXZt6gAsPek5r3SiurJ+U6XEhJoh2ibV5mF1775KHMMFWCj/ub5AqbJfT1p y8OWGJIrH1ixQQc/IvWviCkr1la2v6Bx2cU14kKVNDVksl9KTK+Bevq8b+KlMljYCN7d hiA7omEodif0vSUFRe8YayYzF0gfIVyrlPOc4MN0XWYn18LGkbQw0PJNITStgd+KP2NQ Ls4z3JD/HDGej/WgrPJBUYEV0NJjM2if6+92PGWC4vs/G9+FJVN0bW0mSiFsi5Ifejys 4r30C4rmJdr90gx0gGraUw0UZpv7wKz+n4CBuqvBTzD2zqO3ql2fe+8PNyP92+9Oymm/ 02hQ== X-Gm-Message-State: AOJu0Yy3EXGgZ5s8gTNFyubgjtiPTy06EBoashdJt4ZNTafHvvbNQLtM OEBCqd3dmZDdwlCyUVYADmN8t7V6Up9MOPHEGIyD8C8pBPGDga73GPBD X-Google-Smtp-Source: AGHT+IHqXA8bp8O5GYZpSFLJgxGTmXj+/oBYndyPRDu9q0jERA5JRokJxge92gXvRYOEPlEJLaiCWA== X-Received: by 2002:a17:902:d4c7:b0:205:5410:5738 with SMTP id d9443c01a7336-2076e3944aamr43884675ad.27.1726161178419; Thu, 12 Sep 2024 10:12:58 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afdd41esm16485215ad.173.2024.09.12.10.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:12:58 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 05/13] selftests: ncdevmem: Unify error handling Date: Thu, 12 Sep 2024 10:12:43 -0700 Message-ID: <20240912171251.937743-6-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 There is a bunch of places where error() calls look out of place. Use the same error(1, errno, ...) pattern everywhere. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index a20f40adfde8..c0da2b2e077f 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -332,32 +332,32 @@ int do_server(struct memory_buffer *mem) ret = inet_pton(server_sin.sin_family, server_ip, &server_sin.sin_addr); if (socket < 0) - error(79, 0, "%s: [FAIL, create socket]\n", TEST_PREFIX); + error(1, 0, "%s: [FAIL, create socket]\n", TEST_PREFIX); socket_fd = socket(server_sin.sin_family, SOCK_STREAM, 0); if (socket < 0) - error(errno, errno, "%s: [FAIL, create socket]\n", TEST_PREFIX); + error(1, errno, "%s: [FAIL, create socket]\n", TEST_PREFIX); ret = setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)); if (ret) - error(errno, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); + error(1, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); ret = setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); if (ret) - error(errno, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); + error(1, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); fprintf(stderr, "binding to address %s:%d\n", server_ip, ntohs(server_sin.sin_port)); ret = bind(socket_fd, &server_sin, sizeof(server_sin)); if (ret) - error(errno, errno, "%s: [FAIL, bind]\n", TEST_PREFIX); + error(1, errno, "%s: [FAIL, bind]\n", TEST_PREFIX); ret = listen(socket_fd, 1); if (ret) - error(errno, errno, "%s: [FAIL, listen]\n", TEST_PREFIX); + error(1, errno, "%s: [FAIL, listen]\n", TEST_PREFIX); client_addr_len = sizeof(client_addr); From patchwork Thu Sep 12 17:12:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802371 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1B591BF7E8 for ; Thu, 12 Sep 2024 17:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161182; cv=none; b=hh19/TaMDC+owai4PYkCNJFFTF/q8BLAH7/xiwqdPxtEH1aVWQRqGQSrhoi04Bpl8h5IxVxNRAXxPHF+bnJra9pZNvQcqZQp+ea4DHfP6Cnpfnb07Kqpl1VOJ8mf5NveMxg3OvXCwyTxUqxiPD/BUxGc9LYVisRRtxBJkH+ozms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161182; c=relaxed/simple; bh=DVzHYsp76hzKZntoTHzwpHhzyso+ZaOXyFoTe6z5YJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pv6Z0wQzxmpIW174AVoye89xif4ENcxjhSPpLQj1zC61IVL05uOChWkfD5hxRLGSI3X3vxsJVWL9xj31/0UG/fKoa7GyypuNTdyqAC/P/XTSSHfg25mxWHXhI6MsIyDhGTdl4q+OC8uO6gUJ3BVVeN3dCmaVWQjq/kTHj4L/fY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-6e7b121be30so953630a12.1 for ; Thu, 12 Sep 2024 10:13:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161180; x=1726765980; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2GrjV5gEwYp3sQT3vkyltKULjMmlJYoJQd5AnCA8UJg=; b=MJvTJPCJO2CYNkIHM0IMJ749Zwhkjr8W9HqDcySCgoh9XrMLkbys1fRG8FMlXcz/Y6 gB1rSoJYuoBq2Gciur+OTH+WkkAmPaTBxMDkh93Qx09tW0bVEBeIolnvzKqykg+V8G+b SQpb7mdRAog1DXHQXk8oVevnSFTX4tOs6pIEvpXy7SavSSmAPzKHR8hQMP970/OUHIUI T9gdg3UZQHRrgrw/OpC5YOTW/Nf6AtykzGJjMeo13XLDDlhsItfX0/6TMbFyg3IZBmS8 yiWXX3TMYLKegCKhnWHceAAjRWwSM75Bg+KBQmwIMffmqSfWEmlnhRNnWK4IHCygTq4p ivow== X-Gm-Message-State: AOJu0Yw0+0dK6eqiA5AXh0O5bcQMhGzCPUd1EVH5JHk/hqh047SDZMeG kDudIsYGpUBBU1ghDBavs+tXarJT+xa5Yp24XxpX9gQVS6LSN5RkHm86 X-Google-Smtp-Source: AGHT+IGT019AEEyWUlzr95G+Ry5239IM9yBY+lqdvLZiabMV3fC8f3yeGSdbzYRc6DWz+Dfobysqzg== X-Received: by 2002:a05:6a21:1813:b0:1cf:6c87:89e5 with SMTP id adf61e73a8af0-1cf764c2b90mr4230693637.48.1726161179742; Thu, 12 Sep 2024 10:12:59 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db1fba4766sm1979878a12.12.2024.09.12.10.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:12:59 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 06/13] selftests: ncdevmem: Remove client_ip Date: Thu, 12 Sep 2024 10:12:44 -0700 Message-ID: <20240912171251.937743-7-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 It's used only in ntuple filter, but having dst address/port should be enough. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index c0da2b2e077f..77f6cb166ada 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -62,7 +62,6 @@ */ static char *server_ip = "192.168.1.4"; -static char *client_ip = "192.168.1.2"; static char *port = "5201"; static int start_queue = 8; static int num_queues = 8; @@ -228,8 +227,8 @@ static int configure_channels(unsigned int rx, unsigned int tx) static int configure_flow_steering(void) { - return run_command("sudo ethtool -N %s flow-type tcp4 src-ip %s dst-ip %s src-port %s dst-port %s queue %d >&2", - ifname, client_ip, server_ip, port, port, start_queue); + return run_command("sudo ethtool -N %s flow-type tcp4 dst-ip %s dst-port %s queue %d >&2", + ifname, server_ip, port, start_queue); } static int bind_rx_queue(unsigned int ifindex, unsigned int dmabuf_fd, @@ -553,9 +552,6 @@ int main(int argc, char *argv[]) case 's': server_ip = optarg; break; - case 'c': - client_ip = optarg; - break; case 'p': port = optarg; break; From patchwork Thu Sep 12 17:12:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802372 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D2561BF800 for ; Thu, 12 Sep 2024 17:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161183; cv=none; b=EDUm7qeW6MjUIXShPAVXDSWVIpxV6wtL5HREcgY61TwCHeEAAx7c/tmJLqAkk9LVO63hSzYZRIIWIUj5NfsuEtMPyGRQniO8KQAftI99uE4Ut6caaefzMVV5IH4UWbwyN9maEXfJk099L4PdRz5ASvE2+jqJlplfLBoNsIOv66U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161183; c=relaxed/simple; bh=LAzwia09eV/4sSpw5mcMv/0gaW8i6IEmagmcjr/4NzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bbbcph192O48WHnIYSLJXx8lVU/Dp3HbXrjrrJreyIwp+4F0dT9JLB+Bq4OYfVSj8wCDrkGe3SwZSEmFLG3Spp70y4ByCI47NeTuxBQktOJiTpbA4E0Px7HR3Tnwm1XjTNuQZ1jjEP1KqUkfiIA343Uf9nb1lXoWVoAu+9EDy/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2059112f0a7so8185ad.3 for ; Thu, 12 Sep 2024 10:13:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161181; x=1726765981; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tFrKSN0qGcocZdoBbERENThA5G9MGT7/eNUPdgl7EpE=; b=LmhJxAXfd3WIwajh0b3ZKA18ZTN6u6dMonEBDhx7+BFAZc2lc4jOLMvR90lXMgB1k5 CI6VHsT7KwibIKsyPxsGwINxXcV3nm9SJgLYcFQ69ESTRPf2ZJXrnYkOhbtW5K0NLkrP okBVl7QFKFCs0QaNDBUWJkp2vT8l3f2aTNP0shFrmhCR7ylYigUuAy8fCKPrx2/IGQXj 0HTEVN9WYWMQIn+B8HarkSw8MyHDTk09CedyfF87MvUxdssCcohLJynaxav2dLR12hgw 3DE/NUT02xaXaXSA1uI2dVEBjiHvhd74Wa5kRc84FdFhO5fzmdTxIt+2LI2ufAFObRZZ +Bjg== X-Gm-Message-State: AOJu0YxVx6RmG4y0YzED3xVGpCUiQAnhuyKaYQCNqb06gv9tCkJF/WZu H8v9qNfC7fktVC+JDaFy08x+hRDaOzTE7V++bkqjDePTCcV5qtXuz4Zw X-Google-Smtp-Source: AGHT+IHkkx1xCurwuETkXacyYdyxpvKtfCyPMJieuvBmVbwrKDeOfaiffEeZmZA39Nw6ytlBZPKKQw== X-Received: by 2002:a17:902:dacf:b0:205:8b84:d60c with SMTP id d9443c01a7336-2076e3998damr47573045ad.35.1726161181072; Thu, 12 Sep 2024 10:13:01 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076af47657sm16500015ad.79.2024.09.12.10.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:00 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 07/13] selftests: ncdevmem: Remove default arguments Date: Thu, 12 Sep 2024 10:12:45 -0700 Message-ID: <20240912171251.937743-8-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 To make it clear what's required and what's not. Also, some of the values don't seem like a good defaults; for example eth1. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 34 +++++++++----------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 77f6cb166ada..829a7066387a 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -42,30 +42,11 @@ #define MSG_SOCK_DEVMEM 0x2000000 #endif -/* - * tcpdevmem netcat. Works similarly to netcat but does device memory TCP - * instead of regular TCP. Uses udmabuf to mock a dmabuf provider. - * - * Usage: - * - * On server: - * ncdevmem -s -c -f eth1 -l -p 5201 -v 7 - * - * On client: - * yes $(echo -e \\x01\\x02\\x03\\x04\\x05\\x06) | \ - * tr \\n \\0 | \ - * head -c 5G | \ - * nc 5201 -p 5201 - * - * Note this is compatible with regular netcat. i.e. the sender or receiver can - * be replaced with regular netcat to test the RX or TX path in isolation. - */ - -static char *server_ip = "192.168.1.4"; -static char *port = "5201"; +static char *server_ip; +static char *port; static int start_queue = 8; static int num_queues = 8; -static char *ifname = "eth1"; +static char *ifname; static unsigned int ifindex; static unsigned int dmabuf_id; @@ -573,6 +554,15 @@ int main(int argc, char *argv[]) } } + if (!server_ip) + error(1, 0, "Missing -s argument\n"); + + if (!port) + error(1, 0, "Missing -p argument\n"); + + if (!ifname) + error(1, 0, "Missing -f argument\n"); + ifindex = if_nametoindex(ifname); for (; optind < argc; optind++) From patchwork Thu Sep 12 17:12:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802373 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A13D1BF7E8 for ; Thu, 12 Sep 2024 17:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161184; cv=none; b=jkvYVIgvQeaN2OntnIp3sooYIx30bHNBRPfcxc+2dagiRS5pK/aoisOH/3CGcXe/ufn0WmF4NEPb+8UAqU+SWBRvE+LrJi/yr4pjAMBMNEi2GyuF28crsx0XOf1MvDhFEkq57eNw13NqPnP1JxEzhuz0I3lF7StixwtyhtzGc28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161184; c=relaxed/simple; bh=IzWaiPNvZ7bQ6KBmyTsfp9Gb6J1yGwGTM4RbN18g7x0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DY2ujJ62R1EjVaXjVbQlxozKVjBju8jNBGdNcS2zGpIhdQWmGT5myXDoaO8/08DhwMQ/UL/Hc8by0wdL4+D2gvok26lFJXVkK+IDlX7HoseQ7XxUHCPL0k2XPkYbWscn87R8ELVwR5K10g53HYKYgDPGuDtBo8FxtbYcFkiq+S0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7db2e3fa438so113852a12.1 for ; Thu, 12 Sep 2024 10:13:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161182; x=1726765982; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vu7kSS7sdkITFMlpea1V2u6bxvXk4hNcHq8Tp7Juc5k=; b=sFkGYkqoaL915KEpriOS+ArPjRjT1GeIsmayq95LSVauKkXHGZCqrNjGY9zKXuDSxa XxXdbvg96KxZOGjySnAOYBB5bdcWA6x8mAsbTe+vx+ptifbxd/Jx+B5+/5oVRxiy2BNs BkVV/kH8uHJZFRKY6d7GFyxJMNt7Yp1z7E3GB9TjlwgmBpumfX+zbk2vhUFLvhSbPffR lEnwewCnEAUB0Xi4yGEM0nG4i/Etw6WtopMj2uuIWE3Aa8w+nezYODIaL93p+e7Ln26R FfCd+2cQzVkXYoGuq3FwR4FxeJfYZXDnaWeSDmgEt1S5pplXyO0a9mGwwVohKWtbrbbm wM1g== X-Gm-Message-State: AOJu0YygtekwXbIwmdUJevidLeFIRCQpT+nEIIXNgzfD3o5hdTBaeGXe J43HIIWIIuzxuHS6Xj+Fd9Rms8eRVjZCSBuBfyr6avp+ESXAH/VvIxtx X-Google-Smtp-Source: AGHT+IGwkINhU3KQ9dR3W3onRodQXRDmgK+AIiiEdzuxjpKNwfKxVHl//532RlhR/LPuP/cs3vKE2w== X-Received: by 2002:a05:6a20:b2a8:b0:1cf:3677:1c4a with SMTP id adf61e73a8af0-1cf75eb94cfmr3877393637.16.1726161182281; Thu, 12 Sep 2024 10:13:02 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db1fbb581esm2011440a12.34.2024.09.12.10.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:01 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 08/13] selftests: ncdevmem: Switch to AF_INET6 Date: Thu, 12 Sep 2024 10:12:46 -0700 Message-ID: <20240912171251.937743-9-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 Use dualstack socket to support both v4 and v6. v4-mapped-v6 address can be used to do v4. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 84 +++++++++++++++++--------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 829a7066387a..d82e550369c0 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -206,10 +206,18 @@ static int configure_channels(unsigned int rx, unsigned int tx) return run_command("sudo ethtool -L %s rx %u tx %u", ifname, rx, tx); } -static int configure_flow_steering(void) +static int configure_flow_steering(struct sockaddr_in6 *server_sin) { - return run_command("sudo ethtool -N %s flow-type tcp4 dst-ip %s dst-port %s queue %d >&2", - ifname, server_ip, port, start_queue); + const char *addr = server_ip; + const char *type = "tcp6"; + + if (IN6_IS_ADDR_V4MAPPED(&server_sin->sin6_addr)) { + type = "tcp4"; + addr = strrchr(server_ip, ':') + 1; + } + + return run_command("sudo ethtool -N %s flow-type %s dst-ip %s dst-port %s queue %d >&2", + ifname, type, addr, port, start_queue); } static int bind_rx_queue(unsigned int ifindex, unsigned int dmabuf_fd, @@ -257,13 +265,43 @@ static int bind_rx_queue(unsigned int ifindex, unsigned int dmabuf_fd, return -1; } +static int enable_reuseaddr(int fd) +{ + int opt = 1; + int ret; + + ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)); + if (ret) + return -errno; + + ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); + if (ret) + return -errno; + + return 0; +} + +static int parse_address(const char *str, int port, struct sockaddr_in6 *sin6) +{ + int ret; + + sin6->sin6_family = AF_INET6; + sin6->sin6_port = htons(port); + + ret = inet_pton(sin6->sin6_family, str, &sin6->sin6_addr); + if (ret < 0) + return -1; + + return 0; +} + int do_server(struct memory_buffer *mem) { char ctrl_data[sizeof(int) * 20000]; struct netdev_queue_id *queues; size_t non_page_aligned_frags = 0; - struct sockaddr_in client_addr; - struct sockaddr_in server_sin; + struct sockaddr_in6 client_addr; + struct sockaddr_in6 server_sin; size_t page_aligned_frags = 0; size_t total_received = 0; socklen_t client_addr_len; @@ -275,9 +313,12 @@ int do_server(struct memory_buffer *mem) int socket_fd; int client_fd; size_t i = 0; - int opt = 1; int ret; + ret = parse_address(server_ip, atoi(port), &server_sin); + if (ret < 0) + error(1, 0, "parse server address"); + if (reset_flow_steering()) error(1, 0, "Failed to reset flow steering\n"); @@ -286,7 +327,7 @@ int do_server(struct memory_buffer *mem) error(1, 0, "Failed to configure rss\n"); /* Flow steer our devmem flows to start_queue */ - if (configure_flow_steering()) + if (configure_flow_steering(&server_sin)) error(1, 0, "Failed to configure flow steering\n"); sleep(1); @@ -307,29 +348,16 @@ int do_server(struct memory_buffer *mem) if (!tmp_mem) error(1, ENOMEM, "malloc failed"); - server_sin.sin_family = AF_INET; - server_sin.sin_port = htons(atoi(port)); - - ret = inet_pton(server_sin.sin_family, server_ip, &server_sin.sin_addr); - if (socket < 0) - error(1, 0, "%s: [FAIL, create socket]\n", TEST_PREFIX); - - socket_fd = socket(server_sin.sin_family, SOCK_STREAM, 0); + socket_fd = socket(AF_INET6, SOCK_STREAM, 0); if (socket < 0) error(1, errno, "%s: [FAIL, create socket]\n", TEST_PREFIX); - ret = setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT, &opt, - sizeof(opt)); - if (ret) - error(1, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); - - ret = setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &opt, - sizeof(opt)); + ret = enable_reuseaddr(socket_fd); if (ret) - error(1, errno, "%s: [FAIL, set sock opt]\n", TEST_PREFIX); + error(1, errno, "%s: [FAIL, reuseaddr]\n", TEST_PREFIX); fprintf(stderr, "binding to address %s:%d\n", server_ip, - ntohs(server_sin.sin_port)); + ntohs(server_sin.sin6_port)); ret = bind(socket_fd, &server_sin, sizeof(server_sin)); if (ret) @@ -341,16 +369,16 @@ int do_server(struct memory_buffer *mem) client_addr_len = sizeof(client_addr); - inet_ntop(server_sin.sin_family, &server_sin.sin_addr, buffer, + inet_ntop(AF_INET6, &server_sin.sin6_addr, buffer, sizeof(buffer)); fprintf(stderr, "Waiting or connection on %s:%d\n", buffer, - ntohs(server_sin.sin_port)); + ntohs(server_sin.sin6_port)); client_fd = accept(socket_fd, &client_addr, &client_addr_len); - inet_ntop(client_addr.sin_family, &client_addr.sin_addr, buffer, + inet_ntop(AF_INET6, &client_addr.sin6_addr, buffer, sizeof(buffer)); fprintf(stderr, "Got connection from %s:%d\n", buffer, - ntohs(client_addr.sin_port)); + ntohs(client_addr.sin6_port)); while (1) { struct iovec iov = { .iov_base = iobuf, From patchwork Thu Sep 12 17:12:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802374 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 583BB1BF800 for ; Thu, 12 Sep 2024 17:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161185; cv=none; b=lUNhveeOa6KZ4w5rU0d6L+FLrZHi8fkgb4SyCh4eGo5GyYFkpxWnSMqROZ1rVDk6jk4YzT76Lpz9nv2R461HycfH6wXLkaxUx7PZ6FH0I7/A/q7dIbsCty+4m4B+qfg2GhIJ+4oWe8avL6teCvcysXl3L4iwxsSAWYcLWsx0FN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161185; c=relaxed/simple; bh=g/fEul9GHQlgUz2TVCZwXjEba74PKMBgJz25HReQzrc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PV3cms4a8uH62mUhlWnNhia65GR61MK/H4M3naw8GyL8sjZcfyD9hnMYwyJOx2wD16bSsYgCBcdXLQVMjfDjMGuKryxDe59aLDgxpuQnjHKxVeyTyQTHSPOMkdjY1mH6hhLmLpcjmxT0YWSGj0cp4Z7bxMyFPfxLGtLyABiMIVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-719232ade93so70337b3a.2 for ; Thu, 12 Sep 2024 10:13:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161183; x=1726765983; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KazCW38vm/nFLvBuxWQxw+X70PR3pmlJGzWZIJ9gKhI=; b=lxHiAngVQU3qLwHqvpfLWF5nD4BSNf0kSMnJ2UZidwnZpJrsqEka5qzW+Y5BZ3/OAu V9fcME2SvIswdIOFczDgwhJ7O2TPY7KdYR3JV4mHjw8ZfhvwQIp1X9BCSG4U4umIlvZh UJidskjrfD1lPxvFC9CBGlVgJ/68aJodHmj0GHAqB0HWKv8dEKe4C7d+Msrpkn86ZsC3 VbN1ClI2ht93hhUjVskqdfU0rvMsvQb4Gjgx+Wui4nCSKZS53FJI7ZDr3amon3y0iY4y +QWGKuvn/qE2c9WJlV5Gs6lEDb5+PB4lHGpCRITsBl2spe00/OuwNMeMVfJO7qqAOVny 8z8A== X-Gm-Message-State: AOJu0Yxzcgt4SHi0UGXcTlNkcGS6qtJIsSV44t8XUKRnThuhzBLHDxb3 T3goI7rbY9qIzUdYUpELN9J/VtM8Z6t7Px4B4pgZWVQHl8KIZgrf3eRp X-Google-Smtp-Source: AGHT+IFPcOMUPRabk7h0yAFp1VSutJ6xNk/UyTfpuZOscujZTm5f+wiWaTXxPOHCXL+/GkSBdgneaA== X-Received: by 2002:a05:6a20:d81a:b0:1cf:21c7:2aff with SMTP id adf61e73a8af0-1cf75f1bfa2mr4776167637.23.1726161183534; Thu, 12 Sep 2024 10:13:03 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db1fddd1b6sm1996417a12.74.2024.09.12.10.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:03 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 09/13] selftests: ncdevmem: Properly reset flow steering Date: Thu, 12 Sep 2024 10:12:47 -0700 Message-ID: <20240912171251.937743-10-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 ntuple off/on might be not enough to do it on all NICs. Add a bunch of shell crap to explicitly remove the rules. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index d82e550369c0..c5b4d9069a83 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -181,13 +181,12 @@ static void print_nonzero_bytes(void *ptr, size_t size) static int reset_flow_steering(void) { - int ret = 0; - - ret = run_command("sudo ethtool -K %s ntuple off >&2", ifname); - if (ret) - return ret; - - return run_command("sudo ethtool -K %s ntuple on >&2", ifname); + run_command("sudo ethtool -K %s ntuple off >&2", ifname); + run_command("sudo ethtool -K %s ntuple on >&2", ifname); + run_command( + "sudo ethtool -n %s | grep 'Filter:' | awk '{print $2}' | xargs -n1 ethtool -N %s delete >&2", + ifname, ifname); + return 0; } static int configure_headersplit(bool on) From patchwork Thu Sep 12 17:12:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802375 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B22871C0DCB for ; Thu, 12 Sep 2024 17:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161187; cv=none; b=XvVWn/js6x4ass6zGA8A/KAlD/FYlN+Tncr1Edx4dncz23yPRcdeaL+6YnKWiYJIUs5nqFD34dKvppPQmzi41Jsb0CijrLshq3vjISv7I0ODoGRQ8DudCV5pm81z9wZqvNgY3MTjw/IUTw/PRnoKUUOKEnMpnn9asgbkWTX6lKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161187; c=relaxed/simple; bh=VR+N+n1NKVC5fxaVvwepaSZO/cKUhS6JJCWTHq5LAcg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ouKZlVpB+LM95PDcsx4SXcG/ZK4ZCtpgD8Fe3ahSKfXy71TFeqEZ8ZL7lKCxQdCcdtMINOC6n2k2rZ6eexpvKYhzkYpRZopeqy3QETF1e7+6u+UlJk4QpnN8+2h1MlSvVayNBB+DCI5yq5Q4vA9cUOq2pbOeCPr6X0UPOd9w3Pg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-717911ef035so837707b3a.3 for ; Thu, 12 Sep 2024 10:13:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161185; x=1726765985; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1/C5b82XcGrHLwyLahH7loZCBq6ghcLRWWuHXkHy25Q=; b=Kqq+XauN/GLWE+gMyU3eEjbdv/pZV4B7tssxckmA2S1Zhk5FzpxkvyDJN/IbXf1wdP IFmSRuW/fgFwsZ2qAbvYyEGPgVGhz1dTsdNIW5qHt/TD7JATqEPIpLh9TR0us6dvKnL2 Fi2IgMR/BShAydb248Y+JF+yF3VC3hr9Dqa5Fh2XIhxUtI4z1qJDLJXbewH3GNHSsnPJ 37LaVVzFgjUJpfBjngexsi84RrCugHY3GmFyHuld8GMrygX+wsESSjVXmdd574YIR8z1 /iaAq10YrTl/GlG2QSBFCy/1L3klJ1V5Wl7GFwDyLrj+kaIuzq8cx6e7KeJI7Gn8y8/m 4pvw== X-Gm-Message-State: AOJu0YwfhYOe+1xnu4w3XQxCCDQIndwfcNZDjYdFGV6OBjFNzV6NzWpS dgBLVEJ+MhI8q9KMa2Qe/tNVwhUMWZAcoNn6XC1fiqOkwAhflal6FvzD X-Google-Smtp-Source: AGHT+IFhIDmYD09Q4y8zdBJ4Nslxhp6vNn82w9RaffZuPD/nqZh+NYxHvpNL35sAkH9GbK6qAEa/1w== X-Received: by 2002:a05:6a20:9287:b0:1cf:4f09:ef25 with SMTP id adf61e73a8af0-1cf75ebae28mr3954619637.13.1726161184913; Thu, 12 Sep 2024 10:13:04 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db1fddc6eesm1990004a12.59.2024.09.12.10.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:04 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 10/13] selftests: ncdevmem: Use YNL to enable TCP header split Date: Thu, 12 Sep 2024 10:12:48 -0700 Message-ID: <20240912171251.937743-11-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 In the next patch the hard-coded queue numbers are gonna be removed. So introduce some initial support for ethtool YNL and use it to enable header split. Also, tcp-data-split requires latest ethtool which is unlikely to be present in the distros right now. (ideally, we should not shell out to ethtool at all). Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/ncdevmem.c | 42 ++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 649f1fe0dc46..9c970e96ed33 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -112,7 +112,7 @@ TEST_INCLUDES := forwarding/lib.sh include ../lib.mk # YNL build -YNL_GENS := netdev +YNL_GENS := ethtool netdev include ynl.mk $(OUTPUT)/epoll_busy_poll: LDLIBS += -lcap diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index c5b4d9069a83..f5cfaafb6509 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -32,6 +32,7 @@ #include #include "netdev-user.h" +#include "ethtool-user.h" #include #define PAGE_SHIFT 12 @@ -191,8 +192,42 @@ static int reset_flow_steering(void) static int configure_headersplit(bool on) { - return run_command("sudo ethtool -G %s tcp-data-split %s >&2", ifname, - on ? "on" : "off"); + struct ethtool_rings_set_req *req; + struct ynl_error yerr; + struct ynl_sock *ys; + int ret; + + ys = ynl_sock_create(&ynl_ethtool_family, &yerr); + if (!ys) { + fprintf(stderr, "YNL: %s\n", yerr.msg); + return -1; + } + + req = ethtool_rings_set_req_alloc(); + ethtool_rings_set_req_set_header_dev_index(req, ifindex); + ethtool_rings_set_req_set_tcp_data_split(req, on ? 2 : 0); + ret = ethtool_rings_set(ys, req); + if (ret < 0) + fprintf(stderr, "YNL failed: %s\n", ys->err.msg); + ethtool_rings_set_req_free(req); + + { + struct ethtool_rings_get_req *req; + struct ethtool_rings_get_rsp *rsp; + + req = ethtool_rings_get_req_alloc(); + ethtool_rings_get_req_set_header_dev_index(req, ifindex); + rsp = ethtool_rings_get(ys, req); + ethtool_rings_get_req_free(req); + if (rsp) + fprintf(stderr, "TCP header split: %d\n", + rsp->tcp_data_split); + ethtool_rings_get_rsp_free(rsp); + } + + ynl_sock_destroy(ys); + + return ret; } static int configure_rss(void) @@ -321,6 +356,9 @@ int do_server(struct memory_buffer *mem) if (reset_flow_steering()) error(1, 0, "Failed to reset flow steering\n"); + if (configure_headersplit(1)) + error(1, 0, "Failed to enable TCP header split\n"); + /* Configure RSS to divert all traffic from our devmem queues */ if (configure_rss()) error(1, 0, "Failed to configure rss\n"); From patchwork Thu Sep 12 17:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802376 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FBF01BF7FD for ; Thu, 12 Sep 2024 17:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161188; cv=none; b=SI4GvCcNnz+Qn5jZPSMhmX7iCjQd7ESz+WMFzhfv0SXNETHrdORE3kj/3oJzlEZuKkv6eeysRNqx3FBQlGXE8qMYjehG7Dku/XfBuUuOjfE08S4UMWqJgVmD2DFF0kGDaK2UXwHV4F7xz4zc5S1iLuJmlTDB4AGtRiGXlw2A0/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161188; c=relaxed/simple; bh=OtM7OkwCkwZOGC/t9yoQNZ4wLyLXtx0Cq9BiZbwZOJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n7kSJMzwFA8HPMw9TSyCycsi2ZwN5kh1rjzw1+hsXkLyZ8neeTrchCWObLYc68YCJ1Mgn+dJn3A2DrFYBfaxltIZR02n1UcWhPwWdX6MN16jDdQcbB5aI7xXbTVYnOIixQLPGBEesxlRKHPhNO+lK6CKrUFZp1hrWnj1SpqHB8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7193010d386so88424b3a.1 for ; Thu, 12 Sep 2024 10:13:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161186; x=1726765986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g3voLT4nupCS3bzXGwt3osaY5RB07RUpOg9hQ3Gg5c8=; b=Vbx3jERr1/eFU36yHs7hYhofu/ot/xw4NGz0aHy0nAGHbza2Va+8lcp78sA2G1xoB5 cngUtw5GAn/H904jFxna8fI8tZKU+Vlju783EzW53wooix5Rp6wyqGQAHJgT+e6+GUOP YiNyWuppMZDkAVMUXuopwHTFEg7pMOGfIQ+NuUtouEPgMBBQ1CZojrcYwnCKj5Zzrcmg On2p7ocA+9tsnwr1fYlm7w+uOynITy8++4083GNMw1GM+EBle15VHeC3vNTsekQQLBrD n4WHNL8hl7eh0dAnW/Sjw+odkq/Ur5dJHqjJPsM15564bNGuYeQ8yps7l2PO0wwh5E8w uUKw== X-Gm-Message-State: AOJu0Yykac92MDk4dOJYH7ALPro4SYM/Wa/sLXx9pAo6jfBIJwnGILP0 UrG1mxVIWceuGSj4x3Kd1hRVcQlSYPS2hWL66BBNYhMsFGmv0WX0LW3Y X-Google-Smtp-Source: AGHT+IHMFUvkSQMHdh5WNOAzoCsjn7PpyrPMPADDxm1NVMVds/Bn46cPYimhlQMbBb2KR2xhmRVtpQ== X-Received: by 2002:a05:6a00:2d91:b0:717:85d4:939c with SMTP id d2e1a72fcca58-71926206257mr5707357b3a.23.1726161186348; Thu, 12 Sep 2024 10:13:06 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7190f888a78sm4623039b3a.140.2024.09.12.10.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:05 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 11/13] selftests: ncdevmem: Remove hard-coded queue numbers Date: Thu, 12 Sep 2024 10:12:49 -0700 Message-ID: <20240912171251.937743-12-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 Use single last queue of the device and probe it dynamically. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/net/ncdevmem.c | 40 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index f5cfaafb6509..3883a67d387f 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -45,8 +45,8 @@ static char *server_ip; static char *port; -static int start_queue = 8; -static int num_queues = 8; +static int start_queue = -1; +static int num_queues = 1; static char *ifname; static unsigned int ifindex; static unsigned int dmabuf_id; @@ -171,6 +171,33 @@ static void print_nonzero_bytes(void *ptr, size_t size) putchar(p[i]); } +static int rxq_num(int ifindex) +{ + struct ethtool_channels_get_req *req; + struct ethtool_channels_get_rsp *rsp; + struct ynl_error yerr; + struct ynl_sock *ys; + int num = -1; + + ys = ynl_sock_create(&ynl_ethtool_family, &yerr); + if (!ys) { + fprintf(stderr, "YNL: %s\n", yerr.msg); + return -1; + } + + req = ethtool_channels_get_req_alloc(); + ethtool_channels_get_req_set_header_dev_index(req, ifindex); + rsp = ethtool_channels_get(ys, req); + if (rsp) + num = rsp->rx_count + rsp->combined_count; + ethtool_channels_get_req_free(req); + ethtool_channels_get_rsp_free(rsp); + + ynl_sock_destroy(ys); + + return num; +} + #define run_command(cmd, ...) \ ({ \ char command[256]; \ @@ -630,6 +657,15 @@ int main(int argc, char *argv[]) ifindex = if_nametoindex(ifname); + if (start_queue < 0) { + start_queue = rxq_num(ifindex) - 1; + + if (start_queue < 0) + error(1, 0, "couldn't detect number of queues\n"); + + fprintf(stderr, "using queues %d..%d\n", start_queue, start_queue + num_queues); + } + for (; optind < argc; optind++) fprintf(stderr, "extra arguments: %s\n", argv[optind]); From patchwork Thu Sep 12 17:12:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802377 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85A0D1C0DCB for ; Thu, 12 Sep 2024 17:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161190; cv=none; b=Uedooj7tzubaO+aCbIEV0FhsEmTpWsD6zvDtgXeQBEd7Wk+DnsjO2wdHE8x41MQJMLsJ6qyhlrXa4ua5oBOe35KQjz4SyGaBoOHZhxKeXBDllUo3TBG+oJMHbHD3Tfn15KPDhsNK3c2JMoZQblN6feUVGVhQ9Rmws4AgkE2kyoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161190; c=relaxed/simple; bh=aY9IKzJ+/Z7qBD4T7/hej92PLmomDK8vSLzho7l1aoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P0Zi91qQ3Zfu0PuVtlWp/ZBuMSu9+oXTaLEvvUEPlr7f9eILzhN5YTLE0cJO1VP60xMgBAgpPZslyGMLt8/R7PBBP24g/xvdg4BmnFiWXdgtPNuXMS1oDRenIE9wx2WCxRnN/eiQPQI8iInHsgKd+073wedhpmj7/2JUiDZtQ3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-717849c0dcaso82073b3a.3 for ; Thu, 12 Sep 2024 10:13:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161187; x=1726765987; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FS3kqnfbA9PQ+xFCHu6mnQBzNhe7mokZPsZ2P0mtUkc=; b=SCitoRO7MviQbh/zc6wqSrC74/4dqyJEdJGayn6lPlNBB6w8mkuYCgV5UoEqqPIWxV W4JgqAz6j8UQXOgT3dYi1yWOR1f3358qKXSy1mffJ9UqYD9vYf7oKL9wkvJnFeoljlcT ZAotdSmM/O/bdvFM5ErmrL7pOu691zAfEvnZYRxD33rgvST5hgLlWQ308UEsO29smGan +C3R8ZZFqjlynXthNtfQjwg/dusf1ennWTNnuDqaVjaSoNHjyqh9BMlHlyOlYTs5HIPX HmeKWkO24+9FYyKloGyOfzLmoqU6cWbMOfSeRqbHybzAwpvy5PQCovi2ySlhmBwlAoZk O4TA== X-Gm-Message-State: AOJu0Yw6jZVgF2hfdokWV4uZn3iuHCYKHS90i55hvp8lvwNif4Shngsb 0YOSoID4jEjmayvswnXHVOV2ir3oDqSme0PWxwLLu99QBPXnj0qPw7HD X-Google-Smtp-Source: AGHT+IHmAzqCgD5+ALk//iwfL9YGHkZcXB/MPBCrvl//h69+geq0nnYjELIF8Kgz9dWmK6+wZW8OEA== X-Received: by 2002:a05:6a00:17a5:b0:714:228d:e9f5 with SMTP id d2e1a72fcca58-7192606354emr5451355b3a.2.1726161187499; Thu, 12 Sep 2024 10:13:07 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71909092516sm4810737b3a.136.2024.09.12.10.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:07 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 12/13] selftests: ncdevmem: Move ncdevmem under drivers/net Date: Thu, 12 Sep 2024 10:12:50 -0700 Message-ID: <20240912171251.937743-13-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 This is where all the tests that depend on the HW functionality live in and this is where the automated test is gonna be added in the next patch. Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/drivers/net/.gitignore | 1 + tools/testing/selftests/drivers/net/Makefile | 9 +++++++++ tools/testing/selftests/{ => drivers}/net/ncdevmem.c | 0 tools/testing/selftests/net/.gitignore | 1 - tools/testing/selftests/net/Makefile | 9 --------- 5 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/.gitignore rename tools/testing/selftests/{ => drivers}/net/ncdevmem.c (100%) diff --git a/tools/testing/selftests/drivers/net/.gitignore b/tools/testing/selftests/drivers/net/.gitignore new file mode 100644 index 000000000000..e9fe6ede681a --- /dev/null +++ b/tools/testing/selftests/drivers/net/.gitignore @@ -0,0 +1 @@ +ncdevmem diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/selftests/drivers/net/Makefile index 39fb97a8c1df..bb8f7374942e 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -11,4 +11,13 @@ TEST_PROGS := \ stats.py \ # end of TEST_PROGS +# YNL files, must be before "include ..lib.mk" +EXTRA_CLEAN += $(OUTPUT)/libynl.a $(OUTPUT)/ncdevmem +YNL_GEN_FILES := ncdevmem +TEST_GEN_FILES += $(YNL_GEN_FILES) + include ../../lib.mk + +# YNL build +YNL_GENS := ethtool netdev +include ../../net/ynl.mk diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/drivers/net/ncdevmem.c similarity index 100% rename from tools/testing/selftests/net/ncdevmem.c rename to tools/testing/selftests/drivers/net/ncdevmem.c diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore index 1c04c780db66..923bf098e2eb 100644 --- a/tools/testing/selftests/net/.gitignore +++ b/tools/testing/selftests/net/.gitignore @@ -17,7 +17,6 @@ ipv6_flowlabel ipv6_flowlabel_mgr log.txt msg_zerocopy -ncdevmem nettest psock_fanout psock_snd diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 9c970e96ed33..22a5d6a7c3f3 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -97,11 +97,6 @@ TEST_PROGS += fq_band_pktlimit.sh TEST_PROGS += vlan_hw_filter.sh TEST_PROGS += bpf_offload.py -# YNL files, must be before "include ..lib.mk" -EXTRA_CLEAN += $(OUTPUT)/libynl.a -YNL_GEN_FILES := ncdevmem -TEST_GEN_FILES += $(YNL_GEN_FILES) - TEST_FILES := settings TEST_FILES += in_netns.sh lib.sh net_helper.sh setup_loopback.sh setup_veth.sh @@ -111,10 +106,6 @@ TEST_INCLUDES := forwarding/lib.sh include ../lib.mk -# YNL build -YNL_GENS := ethtool netdev -include ynl.mk - $(OUTPUT)/epoll_busy_poll: LDLIBS += -lcap $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma $(OUTPUT)/tcp_mmap: LDLIBS += -lpthread -lcrypto From patchwork Thu Sep 12 17:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 13802378 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE191C172D for ; Thu, 12 Sep 2024 17:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161191; cv=none; b=QLjwnVu0H+N8Qd7Cd0YDV9WmaJT5SYnWHqQfheUUUnskuLfrnQfljawZQ0PdlLRIqGg22i7I0PZo6xMFfCjI9BZyoHMpguNl8y9oKjtcuj/GijAmDim15FP9JYZqTpM4pifHZB6uyny6JvoFPMdv858pElvV3K2rNNipPo5brSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726161191; c=relaxed/simple; bh=7oLxcbQRmn+3arYJxRSLC70a1Lo0hbIRKyGSPf/VgUY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fro2dEotCueC4B2ZaENV7mTBI5bor9jIzuw4Y4uBiUI5afCkYu3SmVFIkwzEtXHwyXpY0y62N5xBxMJXmS+BLiYCaEPtUFKx1IfDnFfwYJVPSYgZJZVkLqF+SdANT+R9MWfaLCU9pkXhgTaDhDg3ABtncxnAKH8Ps0DqLLmAFOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fomichev.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2055136b612so16841915ad.0 for ; Thu, 12 Sep 2024 10:13:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726161188; x=1726765988; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ANPrqn/poK0SEPZlBGuiyz+Mam0cf6wHjUBvoH8Fniw=; b=KHrGKncq6hOSXRw/9c7fQW6Ax0Y/i1JYvInkRXTcj8v5HZ0KeNB5ZX0JGJEHtG2Cfb 61uBIh+lsbpSNEbnscpA/uXNEOFxdQBSbevywxtnshGsbUa6umZpKK2Q8jSJQdiOlf0g tsEVXqLXD/E+0TmqC0dqME/ZxZBsQoyzyfP3IkpALJ31Nvu99OrBLCdZGVtdr8cFSZG6 oit8W/YgfGmP0PQXkpBDIjgoR2Z4BKIOxFBsS5BfdPt4Tf/WjxPBD6mejH3AbfA+PhKs mz5mO9qpv3+P5Lg1FaQc2q/IoD5wEUlXNdZzi7+mP9fjnnNjUyEfSkSAl6MGCVOrLv7W 2Qcw== X-Gm-Message-State: AOJu0YwuAS9lh5dTdKadKLHvDFRI3VWu5puBYI9iuh942Ar4PlKtB5Oq XthNBF//UWNK9xnBd9cdRAdfRQBkOEHMzw3uFqkzYqAjT5pzx61ale7Y X-Google-Smtp-Source: AGHT+IH8RmYpXkdTtqJxRAZ2QgEN1Sn3I0/njDd8I2S03Zh+KiuVzsO0UckfBl3IBbVUFsxjOaUjEQ== X-Received: by 2002:a17:902:db05:b0:206:c12d:abad with SMTP id d9443c01a7336-2076e393e31mr67584275ad.34.1726161188715; Thu, 12 Sep 2024 10:13:08 -0700 (PDT) Received: from localhost ([2601:646:9e00:f56e:123b:cea3:439a:b3e3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076af47935sm16550585ad.106.2024.09.12.10.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:13:08 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Mina Almasry Subject: [PATCH net-next 13/13] selftests: ncdevmem: Add automated test Date: Thu, 12 Sep 2024 10:12:51 -0700 Message-ID: <20240912171251.937743-14-sdf@fomichev.me> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912171251.937743-1-sdf@fomichev.me> References: <20240912171251.937743-1-sdf@fomichev.me> 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 Only RX side for now and small message to test the setup. In the future, we can extend it to TX side and to testing both sides with a couple of megs of data. make \ -C tools/testing/selftests \ TARGETS="drivers/net" \ install INSTALL_PATH=~/tmp/ksft scp ~/tmp/ksft ${HOST}: scp ~/tmp/ksft ${PEER}: cfg+="NETIF=${DEV}\n" cfg+="LOCAL_V6=${HOST_IP}\n" cfg+="REMOTE_V6=${PEER_IP}\n" cfg+="REMOTE_TYPE=ssh\n" cfg+="REMOTE_ARGS=root@${PEER}\n" echo -e "$cfg" | ssh root@${HOST} "cat > ksft/drivers/net/net.config" ssh root@${HOST} "cd ksft && ./run_kselftest.sh -t drivers/net:devmem.py" Cc: Mina Almasry Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/devmem.py | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/devmem.py diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/selftests/drivers/net/Makefile index bb8f7374942e..00da59970a76 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -5,6 +5,7 @@ TEST_INCLUDES := $(wildcard lib/py/*.py) \ ../../net/lib.sh \ TEST_PROGS := \ + devmem.py \ netcons_basic.sh \ ping.py \ queues.py \ diff --git a/tools/testing/selftests/drivers/net/devmem.py b/tools/testing/selftests/drivers/net/devmem.py new file mode 100755 index 000000000000..bbd32e0b0fe2 --- /dev/null +++ b/tools/testing/selftests/drivers/net/devmem.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import errno +from lib.py import ksft_run, ksft_exit +from lib.py import ksft_eq, KsftSkipEx +from lib.py import NetDrvEpEnv +from lib.py import bkg, cmd, rand_port, wait_port_listen +from lib.py import ksft_disruptive + + +def require_devmem(cfg): + if not hasattr(cfg, "_devmem_probed"): + port = rand_port() + probe_command = f"./ncdevmem -P -f {cfg.ifname} -s {cfg.v6} -p {port}" + cfg._devmem_supported = cmd(probe_command, fail=False, shell=True).ret == 0 + cfg._devmem_probed = True + + if not cfg._devmem_supported: + raise KsftSkipEx("Test requires devmem support") + + +@ksft_disruptive +def check_rx(cfg) -> None: + cfg.require_v6() + require_devmem(cfg) + + port = rand_port() + listen_cmd = f"./ncdevmem -l -f {cfg.ifname} -s {cfg.v6} -p {port}" + + with bkg(listen_cmd) as nc: + wait_port_listen(port) + cmd(f"echo -e \"hello\\nworld\"| nc {cfg.v6} {port}", host=cfg.remote, shell=True) + + ksft_eq(nc.stdout.strip(), "hello\nworld") + + +def main() -> None: + with NetDrvEpEnv(__file__) as cfg: + ksft_run([check_rx], + args=(cfg, )) + ksft_exit() + + +if __name__ == "__main__": + main()