Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1401244rwl; Wed, 5 Apr 2023 17:02:36 -0700 (PDT) X-Google-Smtp-Source: AKy350aDrh6wWe+ILdhq7wTnhA5zQh/wOdZKdscTu7s4ENQitHVkbp6IdF3WNtfHgNNb5gjriT6z X-Received: by 2002:a17:903:181:b0:19d:6f7:70d2 with SMTP id z1-20020a170903018100b0019d06f770d2mr9477004plg.50.1680739356656; Wed, 05 Apr 2023 17:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680739356; cv=none; d=google.com; s=arc-20160816; b=KIf+NQ0LxKthC/FBV266PX9M8ojIoymSnzxDyNO+x4DEsi/IzowRnqdTP9J6FCuJKc SOuil9eyHSm0e4LBrw8h8X18rFMMsflnQkkvZ8es1wov4yon3x1iOhFzBeQhBjdhsp00 ySBZrRpOx4FzJ0m/8uHyxoZu5oELkRgUUskJsvZYu2kzz7Y1qZJO/gQ0dWozORRDVVTh t5n7oxoy/nh1lDl/iYIgm1BeniEQDg97zjpjWRuSUo3EH1++wm+ww7/BkzkLCURtmnWu 6NpB+ITWgiMybUfJf8pftPZFZ0A6XoDcSaxsXlNl5fIqe50rR0R/N6t2PtpN5VWQZl2N lR5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aiktHjl/mMcq2QHaTiXh/kaZ7IlrVAnqoR/RxQRC2zg=; b=VdjgdpqEFThvtgvvHu2AImbIcDCK4xX38YLKdYci37vmdl6ay+BY0/P217OMnov0m8 4GXa0J9rcDAJMU70y5XqBKmOYpJGT75nENeR87PuKne7uez0aGkAWMfvRwmyLJeQyPzB 0cGgEaXRZ+4xkKKmdG5FRCnrsnqVzeZdrFxSV/TUg4QE3Vs3VpAedSeSKXbdPXqJ8Iot Inl5orB5UssAlLh0xxrETvggDCbLqBGUzIthip/oU+Q07sUQ2rD0qtBOmHrfBXvG5b8u eA77V4y+InMBHUCmXQkEZ0Xsl67datCTrKwytzS+beG2pkHWTjFmGSsjsnLAkkcfyzvk KYWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dectris.com header.s=google header.b=M4qbOdZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dectris.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a636909000000b00514344f3ed5si1625767pgc.8.2023.04.05.17.02.20; Wed, 05 Apr 2023 17:02:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dectris.com header.s=google header.b=M4qbOdZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dectris.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234117AbjDEX7t (ORCPT + 99 others); Wed, 5 Apr 2023 19:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234103AbjDEX7p (ORCPT ); Wed, 5 Apr 2023 19:59:45 -0400 Received: from mail-ed1-x562.google.com (mail-ed1-x562.google.com [IPv6:2a00:1450:4864:20::562]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED74C7683 for ; Wed, 5 Apr 2023 16:59:40 -0700 (PDT) Received: by mail-ed1-x562.google.com with SMTP id eh3so145219051edb.11 for ; Wed, 05 Apr 2023 16:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dectris.com; s=google; t=1680739179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aiktHjl/mMcq2QHaTiXh/kaZ7IlrVAnqoR/RxQRC2zg=; b=M4qbOdZXV1C/wDoAtkeyblRD3pP/gVWJ2ejk/HkiM7w0jCcQ+v29RtLw8uUviwLJl1 auBRb4iOIKy8itmdG/qdpbrAKRxz64u2qESoitiubJYsYHgTftPuHS1ASwXk3vl7M4az 3IStF2usOaKTZJlThJ/IelRoZTkMFI4q2YFm8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680739179; 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=aiktHjl/mMcq2QHaTiXh/kaZ7IlrVAnqoR/RxQRC2zg=; b=qkCt93GUP6YoY2dd7KSjAAjrZoViyD5xs/rY2+PgYstAlbs8qvIv82nrwoK+P0PFma VJUwbbAOYAGxlgUoU76n3+BP4nrd71Ag9FNbYLj5YcK9VTG0j6YZuKND/y/POhqKWU3A /aWPFAARbsHMlhmWZ9I7XG+jnrTW4tIadZ58JH8P3xQVmDSXVCbZDJfDyBddAtWVyNg9 Zd14Ff8yG1qx/6EX1J66OIKsl7+4oHktTbeIL7Kc5uwezyVXKQa2wSM3HcxP6czVvBWz 1a0VEL8mpwA7mz2U/SE9XlF2coo6raek47guGFyuu0B8teYyppT/st/fjeJggYH3BrWs X8AA== X-Gm-Message-State: AAQBX9cUjwt59rf8Nz2IPlkojRi5a1DUVg7RceylQdXg3iyarmxo+ZUw 7xvulfxDTlqE2rFOfTpXvl2hC95NkcdD9VmgWfT4vy6TxAps X-Received: by 2002:a17:906:edcb:b0:930:f953:9614 with SMTP id sb11-20020a170906edcb00b00930f9539614mr5666535ejb.1.1680739178981; Wed, 05 Apr 2023 16:59:38 -0700 (PDT) Received: from fedora.dectris.local (dect-ch-bad-pfw.cyberlink.ch. [62.12.151.50]) by smtp-relay.gmail.com with ESMTPS id hd33-20020a17090796a100b00949174b747bsm8548ejc.96.2023.04.05.16.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 16:59:38 -0700 (PDT) X-Relaying-Domain: dectris.com From: Kal Conley To: Magnus Karlsson , Martin KaFai Lau , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Maciej Fijalkowski , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: Kal Conley , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 2/2] selftests: xsk: Add test UNALIGNED_INV_DESC_4K1_FRAME_SIZE Date: Thu, 6 Apr 2023 01:59:19 +0200 Message-Id: <20230405235920.7305-3-kal.conley@dectris.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230405235920.7305-1-kal.conley@dectris.com> References: <20230405235920.7305-1-kal.conley@dectris.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add unaligned descriptor test for frame size of 4001. Using an odd frame size ensures that the end of the UMEM is not near a page boundary. This allows testing descriptors that staddle the end of the UMEM but not a page. This test used to fail without the previous commit ("xsk: Add check for unaligned descriptors that overrun UMEM"). Signed-off-by: Kal Conley --- tools/testing/selftests/bpf/xskxceiver.c | 24 ++++++++++++++++++++++++ tools/testing/selftests/bpf/xskxceiver.h | 1 + 2 files changed, 25 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 1a4bdd5aa78c..5a9691e942de 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -69,6 +69,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -1876,6 +1877,29 @@ static void run_pkt_test(struct test_spec *test, enum test_mode mode, enum test_ test->ifobj_rx->umem->unaligned_mode = true; testapp_invalid_desc(test); break; + case TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME: { + u64 page_size, umem_size; + + if (!hugepages_present(test->ifobj_tx)) { + ksft_test_result_skip("No 2M huge pages present.\n"); + return; + } + test_spec_set_name(test, "UNALIGNED_INV_DESC_4K1_FRAME_SIZE"); + /* Odd frame size so the UMEM doesn't end near a page boundary. */ + test->ifobj_tx->umem->frame_size = 4001; + test->ifobj_rx->umem->frame_size = 4001; + test->ifobj_tx->umem->unaligned_mode = true; + test->ifobj_rx->umem->unaligned_mode = true; + /* This test exists to test descriptors that staddle the end of + * the UMEM but not a page. + */ + page_size = sysconf(_SC_PAGESIZE); + umem_size = test->ifobj_tx->umem->num_frames * test->ifobj_tx->umem->frame_size; + assert(umem_size % page_size > PKT_SIZE); + assert(umem_size % page_size < page_size - PKT_SIZE); + testapp_invalid_desc(test); + break; + } case TEST_TYPE_UNALIGNED: if (!testapp_unaligned(test)) return; diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/bpf/xskxceiver.h index cc24ab72f3ff..919327807a4e 100644 --- a/tools/testing/selftests/bpf/xskxceiver.h +++ b/tools/testing/selftests/bpf/xskxceiver.h @@ -78,6 +78,7 @@ enum test_type { TEST_TYPE_ALIGNED_INV_DESC, TEST_TYPE_ALIGNED_INV_DESC_2K_FRAME, TEST_TYPE_UNALIGNED_INV_DESC, + TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME, TEST_TYPE_HEADROOM, TEST_TYPE_TEARDOWN, TEST_TYPE_BIDI, -- 2.39.2