From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A40C445E82; Thu, 12 Dec 2024 09:05:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6EE82402DE; Thu, 12 Dec 2024 09:05:11 +0100 (CET) Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by mails.dpdk.org (Postfix) with ESMTP id 470D240269 for ; Thu, 12 Dec 2024 09:05:10 +0100 (CET) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a9f1d76dab1so56634566b.0 for ; Thu, 12 Dec 2024 00:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733990710; x=1734595510; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JvwKH4jdglNCfE18FxGYum71TikRC7x60ynvsIFagG4=; b=Nl5lo9c92cgp9/a3vGVMcOESQgnI/P2FDx5ei7DSX17Go35UEGHhNz/XlvMz0/A5Sh VOV8uWEryL8sxGSlUeo1AF/8WENcGERepwsM5g1ThLmXq0aUouHy0uGGwLJACfaAehbu z65QZguF7sRBcnHf2Q2/IBgVhJgrcsIl+DaeSK1k2TkQHpO/lkwgpVGbE+y4yDhVXwjC 9xHRrP01crnQ+OUIteTy3Q5+SiQh4b8CmobjmIWSMsncsIVSMnk4Vw253G09l4GG25mH 0J9WP4Ea0ku2kBN8SbDlqiQjqW3FjphugOxMqRvTzIyGJA4InLY1M/wICxYEON4MV4WB zsYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733990710; x=1734595510; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JvwKH4jdglNCfE18FxGYum71TikRC7x60ynvsIFagG4=; b=VoCvwrNzYzID5qcM0SZatovFOHo44jsZV7QW7UQZeg00hbrSm6XCMaAhYzlRm0QIPF RFAHj4atwWUHpmiLDNTgHRKjnxFExPUOPrMK+wcG7Xzltw+fuIeRrLnShNS2oXJ2LdRE REaSDKYTKEDAKcNoj1cGbHtH8XZKVk58ihQ/hjpCe74Ab7y7LlA2FlK7nWhoJrbpIG3n ESHPI58JAWS4zrM3JMW20iFJ6P2lMmCoWkVHlrMMolibtQnMWd9eCfl3USv+0AhT1nrA r+NfOskJeSuZw8e7lM9QkFvXr/xreyAvf06cdHia4hecEl0hkmD9jjdKVf4a0WlcAIo0 QKpg== X-Forwarded-Encrypted: i=1; AJvYcCUQCzJi+Xo0e2rbXBTXSAQII61HF45xlNPC3AwlJhp5P/jfrUv5J3mAgmW+rkBwoUzt4Rc=@dpdk.org X-Gm-Message-State: AOJu0Yx43OLQpZxcBNIOx089mGNuPezgbG+VhJDWjW7GlwhCufHhr1lK rVq1wobYwod72W1sNJOxR7j5+ofsA2c8p3D6GQJhig08untwSYPR X-Gm-Gg: ASbGncsDSQU7ljb5sSSqbeqclzwswGSrpHHPEncvZSHbPJnLdQ0BcGdackvQBfJuv5i Mki5hwCCsP0DIaZFrbJcj9ictVLBCuM+tFVv+gt5FNgbQgrHBg/XPJqH9Cqf1OfY0Yru5JoS/e+ ofN3QZq9TpZvhpUZW9TvAkAT4IosEJYKXm5opfh4vRNhVxQ5GlGdkPCNGZ0TThwfN8nMDnBmsIx 0sSShUvifxGkhXJyA3TqOJ47HSkmThxxkvniqKUaJU/kasvGJKmRqjxTwmsONXoKLEVjB1K/wWj JrwzPKYu7LqWTze/FkYiiQy7RP0lSGzxMZhjEg== X-Google-Smtp-Source: AGHT+IF/h+HHrLMwcpl6/deIW9JIoOufkjoRGjiQhltiqdC5Yrfr7xOnTrWzyUOrwgfeTSMm24442Q== X-Received: by 2002:a17:906:23e1:b0:aa6:96c4:ad62 with SMTP id a640c23a62f3a-aa6b13f164bmr528872966b.58.1733990709554; Thu, 12 Dec 2024 00:05:09 -0800 (PST) Received: from tucornea-pc-virtualbox.buh.is.keysight.com ([213.249.122.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa66fd738d4sm694898366b.177.2024.12.12.00.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 00:05:08 -0800 (PST) From: Tudor Cornea To: linville@tuxdriver.com Cc: ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, dev@dpdk.org, Tudor Cornea Subject: [PATCH] net/af_packet: allow disabling packet fanout Date: Thu, 12 Dec 2024 10:04:42 +0200 Message-Id: <20241212080442.1628366-1-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This allows us to control whether the PMD will attempt to use the PACKET_FANOUT socket option, and allows the binary compiled against newer kernel headers to run on an older kernel, which lacks support for it. Signed-off-by: Tudor Cornea --- doc/guides/nics/af_packet.rst | 4 ++- drivers/net/af_packet/rte_eth_af_packet.c | 32 ++++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst index a343d3a961..42837031de 100644 --- a/doc/guides/nics/af_packet.rst +++ b/doc/guides/nics/af_packet.rst @@ -25,6 +25,8 @@ Some of these, in turn, will be used to configure the PACKET_MMAP settings. * ``qpairs`` - number of Rx and Tx queues (optional, default 1); * ``qdisc_bypass`` - set PACKET_QDISC_BYPASS option in AF_PACKET (optional, disabled by default); +* ``packet_fanout`` - set PACKET_FANOUT option in AF_PACKET (optional, + enabled by default); * ``blocksz`` - PACKET_MMAP block size (optional, default 4096); * ``framesz`` - PACKET_MMAP frame size (optional, default 2048B; Note: multiple of 16B); @@ -64,7 +66,7 @@ framecnt=512): .. code-block:: console - --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=0 + --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=0,packet_fanout=0 Features and Limitations ------------------------ diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index ceb8d9356a..521dbef317 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -36,6 +36,7 @@ #define ETH_AF_PACKET_FRAMESIZE_ARG "framesz" #define ETH_AF_PACKET_FRAMECOUNT_ARG "framecnt" #define ETH_AF_PACKET_QDISC_BYPASS_ARG "qdisc_bypass" +#define ETH_AF_PACKET_PACKET_FANOUT_ARG "packet_fanout" #define DFLT_FRAME_SIZE (1 << 11) #define DFLT_FRAME_COUNT (1 << 9) @@ -96,6 +97,7 @@ static const char *valid_arguments[] = { ETH_AF_PACKET_FRAMESIZE_ARG, ETH_AF_PACKET_FRAMECOUNT_ARG, ETH_AF_PACKET_QDISC_BYPASS_ARG, + ETH_AF_PACKET_PACKET_FANOUT_ARG, NULL }; @@ -709,6 +711,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, unsigned int framesize, unsigned int framecnt, unsigned int qdisc_bypass, + unsigned int packet_fanout, struct pmd_internals **internals, struct rte_eth_dev **eth_dev, struct rte_kvargs *kvlist) @@ -926,14 +929,17 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, goto error; } + if (packet_fanout) { #if defined(PACKET_FANOUT) - rc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT, - &fanout_arg, sizeof(fanout_arg)); - if (rc == -1) { - PMD_LOG_ERRNO(ERR, - "%s: could not set PACKET_FANOUT on AF_PACKET socket for %s", - name, pair->value); - goto error; + rc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT, + &fanout_arg, sizeof(fanout_arg)); + if (rc == -1) { + PMD_LOG_ERRNO(ERR, + "%s: could not set PACKET_FANOUT " + "on AF_PACKET socket for %s", + name, pair->value); + goto error; + } } #endif } @@ -1003,6 +1009,7 @@ rte_eth_from_packet(struct rte_vdev_device *dev, unsigned int framecount = DFLT_FRAME_COUNT; unsigned int qpairs = 1; unsigned int qdisc_bypass = 1; + unsigned int packet_fanout = 1; /* do some parameter checking */ if (*sockfd < 0) @@ -1065,6 +1072,16 @@ rte_eth_from_packet(struct rte_vdev_device *dev, } continue; } + if (strstr(pair->key, ETH_AF_PACKET_PACKET_FANOUT_ARG) != NULL) { + packet_fanout = atoi(pair->value); + if (packet_fanout > 1) { + PMD_LOG(ERR, + "%s: invalid packet fanout value", + name); + return -1; + } + continue; + } } if (framesize > blocksize) { @@ -1091,6 +1108,7 @@ rte_eth_from_packet(struct rte_vdev_device *dev, blocksize, blockcount, framesize, framecount, qdisc_bypass, + packet_fanout, &internals, ð_dev, kvlist) < 0) return -1; -- 2.34.1