From patchwork Thu Feb 29 17:31:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 137511 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C89843C3F; Thu, 29 Feb 2024 18:32:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 063EF42F6B; Thu, 29 Feb 2024 18:32:08 +0100 (CET) Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by mails.dpdk.org (Postfix) with ESMTP id 0436142E2A for ; Thu, 29 Feb 2024 18:32:06 +0100 (CET) Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-7c403dbf3adso62484639f.1 for ; Thu, 29 Feb 2024 09:32:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709227925; x=1709832725; darn=dpdk.org; 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=qiIChBbEfOJEfkcvKPQt0vsbsiYdobAfFLkr/kwzjxQ=; b=yL7ofXhhCYqG9/UX0fXDC5qLglJq1lIIuybo70b1zgsP8RvI4gZAzSUKx3x335PN1i F02PdV1SZJEI6tA4pTsAkYa8jAXPE3e6ed6pDXr+Nf1KTFtCixYXQcbVknL+Gz4CIats h861sIxacAq+LJXxFXTV+JMnVaCAof0eOkrOEH7YP29qcPusgZDWSOG3mkZI/DzEHL0q bL9OPHnwqbnHcO+UvjoG/P2bibAAAqoAmXcxeC+N9FVZdv4F2G6ieLNkFYLTNssdOe4w 3CcP7UM1rYFv2jW7ZgW9AnQ869FUkDkDvFCVxbmbZ9rqG14u7MRVe0eSKv6Y+/nFBGcV AwaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709227925; x=1709832725; 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=qiIChBbEfOJEfkcvKPQt0vsbsiYdobAfFLkr/kwzjxQ=; b=JTI9iuPIyBKXHA+gu7eMegxzWNNQqQGl12VIbF+kGmwnoCBr5Fh0IyZ/7bSUwhyII/ Taz2Wz6JpIatNkAF9G/Gg9XpDkYRVFY8oaTH/23euT47pqqWuB0YzNvfxiiE20QYv8uX BYCGK6eZrmNifhfarsCblQnda6o511BRdP6x2PUk6hSdh2CgWXzzaAP/EqafMknsYVWO 1m88yCwFQfYMEs3svf5pYwPgEn/5RzEHhT6l/OktjDYEytyVLd1k53r5xnezfWyxUjof YL3wyDe/hfidbZRAz/vrYciWUBXNH6723G/i4SzAr089No5qeZxUzz442+Zn9gu0WsXA 75Aw== X-Gm-Message-State: AOJu0YzlXhIRWA8c/raHoLeTIq8soee+vQqndwyVcboX1fSoox1U68bm aa1Be6tcvxGKXqP4cqqEbyr8mcdvQB0vSYRLZ3OKxSRSVYPxXwmtGu8dRCRVY8dtp2JSkNa7Ad7 6 X-Google-Smtp-Source: AGHT+IFefMc7hX6BZlpvTa1vZv0GH5jVq0PmnOUdQCEnYWfifUV4T9LUY8wjvgGMNwZHY8/nLG50TA== X-Received: by 2002:a92:c944:0:b0:363:d9eb:c2de with SMTP id i4-20020a92c944000000b00363d9ebc2demr3103141ilq.6.1709227925405; Thu, 29 Feb 2024 09:32:05 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id r31-20020a63fc5f000000b005dc3fc53f19sm1584846pgk.7.2024.02.29.09.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:32:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Thomas Monjalon Subject: [PATCH 1/3] MAINTAINERS: add maintainer for TAP device Date: Thu, 29 Feb 2024 09:31:06 -0800 Message-ID: <20240229173154.121491-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229173154.121491-1-stephen@networkplumber.org> References: <20240229173154.121491-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Add myself as maintainer for TAP device. Signed-off-by: Stephen Hemminger Acked-by: Ferruh Yigit --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 962c359cdd85..e0959992d998 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1021,6 +1021,7 @@ F: doc/guides/nics/pcap_ring.rst F: doc/guides/nics/features/pcap.ini Tap PMD +M: Stephen Hemminger F: drivers/net/tap/ F: doc/guides/nics/tap.rst F: doc/guides/nics/features/tap.ini From patchwork Thu Feb 29 17:31:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 137512 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 430AF43C3F; Thu, 29 Feb 2024 18:32:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D1CF42F8B; Thu, 29 Feb 2024 18:32:09 +0100 (CET) Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by mails.dpdk.org (Postfix) with ESMTP id 798CE42F76 for ; Thu, 29 Feb 2024 18:32:07 +0100 (CET) Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-7c7db34d162so44873139f.2 for ; Thu, 29 Feb 2024 09:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709227927; x=1709832727; darn=dpdk.org; 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=FUQximORum8BhjyMMC3ErcEcgBw2b5paXd1ZD/Z8r0U=; b=HypURsZgRnP0Lo0Vskvzk6kceoN476EFsiAVdopxShRRniKE/xLMEQmyp4bdmZ2Axv 6ir7vo9SETN2SDApVwoyNhTYGhVk3COr/NG/Fyq9Rcq8RKyYeyToUUcjT8euUg5vUozx dkfgPmOyoZ3iJMRegaQ5lMoV59iC0GOa0l85nvz+wDLvBmtYgXSFKzF4syKeHRZo63sN +CEc2v63Uz/LtXSMLjxoG5H8/Gcnz1ro3gUZH0i0rPAr5w/FCbKpjEyaAPT/p8Qrm61j OdBy2vHxzBgyhuHvLpaeN3ml861tTj3cOwMdo/u964oBiIK49qrxnXiI8H+ZLctJ52ZY reMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709227927; x=1709832727; 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=FUQximORum8BhjyMMC3ErcEcgBw2b5paXd1ZD/Z8r0U=; b=r05+0t+f7IX+ZxhBEFPXAiItGq+Rs3/mbXgU9mkkFjieccVjotlaq46e4GynfKWPTl OmjC7CehWhaEkNJbVhlSntkLx25DWwQ9biftG8l4DVpvf3TylJeY/J7ZoXJtPlhpG3qm 6+qhbsBlJboc3+2MIVTIWjuA4MFOLaaDqgavsKN0v4QF3u2MbI6jfjv82bRMKaEZAx/Q pZOgFw0PkUtM7eVD/w/0qgRM6iXvnsPkE3ABAX+a8W1O9XWNTl/T78Ao0qd7v3cchvwP 37KbdV5UxD4yD1izNZ7tzWvTQKu5yEjH736ylOaWHSrRUD3iBVsH1qxQ/aAyodsnCv1x 2fAw== X-Gm-Message-State: AOJu0YxpAu5hLyYehKCeKy244P1FVp9WkUpqfUGSTkgyD554lI9RIieH ykvscaMT1MjW06RM9OmWLqysMHtw/Ojr/mWrEDNQD3bkFYT231nPEDEOMxDSa2HXgTedNK0AANs v X-Google-Smtp-Source: AGHT+IHigGPwYXFq5fM6SSdb3GYNnb/cBr9P4qNcBcqilkkeWa/HZs+AohOBsElnB/MXAuQZruJpYg== X-Received: by 2002:a05:6e02:1041:b0:365:5dbd:aa34 with SMTP id p1-20020a056e02104100b003655dbdaa34mr2703498ilj.12.1709227926774; Thu, 29 Feb 2024 09:32:06 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id r31-20020a63fc5f000000b005dc3fc53f19sm1584846pgk.7.2024.02.29.09.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:32:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Pascal Mazon , Ophir Munk , Olga Shern , Keith Wiles Subject: [PATCH 2/3] net/tap: do not overwrite rte_flow errors Date: Thu, 29 Feb 2024 09:31:07 -0800 Message-ID: <20240229173154.121491-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229173154.121491-1-stephen@networkplumber.org> References: <20240229173154.121491-1-stephen@networkplumber.org> MIME-Version: 1.0 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 All flow errors were ending up being reported as not supported, even when the error path was previously setting a valid and better error message. Example, asking for a non-existent queue in flow. Before: testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:01 \ / end actions queue index 12 / end port_flow_complain(): Caught PMD error type 16 (specific action): cause: 0x7fffc46c1e18, action not supported: Operation not supported After: testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:01 \ / end actions queue index 12 / end port_flow_complain(): Caught PMD error type 16 (specific action): cause: 0x7fffa54e1d88, queue index out of range: Numerical result out of range Fixes: f46900d03823 ("net/tap: fix flow and port commands") Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions") Signed-off-by: Stephen Hemminger --- drivers/net/tap/tap_flow.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index ed4d42f92f9f..5b0fee906493 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1082,8 +1082,11 @@ priv_flow_process(struct pmd_internals *pmd, } /* use flower filter type */ tap_nlattr_add(&flow->msg.nh, TCA_KIND, sizeof("flower"), "flower"); - if (tap_nlattr_nested_start(&flow->msg, TCA_OPTIONS) < 0) - goto exit_item_not_supported; + if (tap_nlattr_nested_start(&flow->msg, TCA_OPTIONS) < 0) { + rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ACTION, + actions, "could not allocated netlink msg"); + goto exit_return_error; + } } for (; items->type != RTE_FLOW_ITEM_TYPE_END; ++items) { const struct tap_flow_items *token = NULL; @@ -1199,9 +1202,12 @@ priv_flow_process(struct pmd_internals *pmd, if (action) goto exit_action_not_supported; action = 1; - if (!queue || - (queue->index > pmd->dev->data->nb_rx_queues - 1)) - goto exit_action_not_supported; + if (queue->index >= pmd->dev->data->nb_rx_queues) { + rte_flow_error_set(error, ERANGE, + RTE_FLOW_ERROR_TYPE_ACTION, actions, + "queue index out of range"); + goto exit_return_error; + } if (flow) { struct action_data adata = { .id = "skbedit", @@ -1227,7 +1233,7 @@ priv_flow_process(struct pmd_internals *pmd, if (!pmd->rss_enabled) { err = rss_enable(pmd, attr, error); if (err) - goto exit_action_not_supported; + goto exit_return_error; } if (flow) err = rss_add_actions(flow, pmd, rss, error); @@ -1235,7 +1241,7 @@ priv_flow_process(struct pmd_internals *pmd, goto exit_action_not_supported; } if (err) - goto exit_action_not_supported; + goto exit_return_error; } /* When fate is unknown, drop traffic. */ if (!action) { @@ -1258,6 +1264,7 @@ priv_flow_process(struct pmd_internals *pmd, exit_action_not_supported: rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, "action not supported"); +exit_return_error: return -rte_errno; } From patchwork Thu Feb 29 17:31:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 137513 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20A4543C3F; Thu, 29 Feb 2024 18:32:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E9CE42F91; Thu, 29 Feb 2024 18:32:10 +0100 (CET) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by mails.dpdk.org (Postfix) with ESMTP id C711542F85 for ; Thu, 29 Feb 2024 18:32:08 +0100 (CET) Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5d8b887bb0cso962794a12.2 for ; Thu, 29 Feb 2024 09:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709227928; x=1709832728; darn=dpdk.org; 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=+AeF2SCiSz//fc0HRFr/2OIbFohjhgN6psQREKMfvKU=; b=de/EO9/YC6N0oSHTJ9QEtsMErV4tPQrdZqg/XyFYJIYY/AO7AlRNlSTu5dkO2ewn/r AiNBZznAFzT9EMEAC+8/GRlzALMtAIkuZ9jXnnjk3fUr6Keyre61djswbIwopB/HbL+q RYqKrC2v4kcxySJV4AzOlKJM+X79/yxdZ2QZvQSyrrQJKIjaDzWjy20CYe2L3RuwOAK4 FAKL6xjPBPjUU/3gIN+zs/os28w+HN1iVvryJS2rWg7dC2avd3MsqB/gcVWwQVUYNmxq ZsLxliFb4lQsmv7FS8tZb0zmhsnOQBLzQtdm8s37wMJ3Id60bxnXpz4T2L7x22akEV11 lTiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709227928; x=1709832728; 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=+AeF2SCiSz//fc0HRFr/2OIbFohjhgN6psQREKMfvKU=; b=P0iSLkjVAc72pjjiRz5Pmy8g4+BrH4I3MMkUXKzRCOdW0HgDRa7eksClEEMLiki48T KL3IEUSx43WZtELNFJKR5UOb5qFTJkGZnWByylaFyoXGxhp23fsLkHhuaefsNci9jhJc kjBLbfLntfCLTra/ubowz8AmPRTKagm8bdtXEXoGG53lLZiSWpoE2axHQ1md2zhFVTDJ Tt1BnlUaNSE85GJkF54uIJqy2C1I5/aPG26wPnh0fs2u3naibc398iqJ4wQ/Y3f6Qtq9 Xmo3E70s985hTzwbmSvLLSHevAxLAzGg014ipgy/9NhT4SNfFTqEl06oDdPBugWMEbVN +JFg== X-Gm-Message-State: AOJu0YxZv3wnTgcNZnAfoeHBhh9/a6Xl0DCSDegeTC4aQZrIyLKkn1Wa UcVShMGUdUeBUFP51KtxpAB2ztFvIfKDChAscoaQLA/Ih3+VZye5lLOxoAIXjknUm+7/6ef0vWn 0 X-Google-Smtp-Source: AGHT+IHTEbBrLI6NPYPA+Oj+PVTXSjwOfpK43mw+8LWX4o+5DOigr9dpq9ILfE6G8nXHTlJWpmfAFQ== X-Received: by 2002:a05:6a00:3d43:b0:6e5:3abd:33bd with SMTP id lp3-20020a056a003d4300b006e53abd33bdmr3616230pfb.34.1709227927900; Thu, 29 Feb 2024 09:32:07 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id r31-20020a63fc5f000000b005dc3fc53f19sm1584846pgk.7.2024.02.29.09.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:32:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olga Shern , Keith Wiles , Pascal Mazon , Kevin Traynor , Ferruh Yigit Subject: [PATCH 3/3] net/tap: compute TC handle correctly Date: Thu, 29 Feb 2024 09:31:08 -0800 Message-ID: <20240229173154.121491-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229173154.121491-1-stephen@networkplumber.org> References: <20240229173154.121491-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The code to take a flow pointer and make a TC handle was incorrect and would always generate the same handle. This is because it was hashing the address of the union on the stack (which is invariant) rather than the contents of the union. The following testpmd case would cause an error: testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:01 \ / end actions queue index 2 / end Flow rule #0 created testpmd> flow create 0 ingress pattern eth src is 06:05:04:03:02:02 \ / end actions queue index 3 / end tap_nl_dump_ext_ack(): Filter already exists tap_flow_create(): Kernel refused TC filter rule creation (17): File exists port_flow_complain(): Caught PMD error type 2 (flow rule (handle)): overlapping rules or Kernel too old for flower support: File exists This fix does it in a more robust manner using size independent code. It also initializes the hash seed so the same hash won't show up every time and risk potential leakage of address to other places. Bugzilla ID: 1382 Fixes: de96fe68ae95 ("net/tap: add basic flow API patterns and actions") Fixes: a625ab89df11 ("net/tap: fix build with GCC 11") Signed-off-by: Stephen Hemminger --- drivers/net/tap/tap_flow.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 5b0fee906493..94f9b99cdaa6 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1297,9 +1298,7 @@ tap_flow_validate(struct rte_eth_dev *dev, * In those rules, the handle (uint32_t) is the part that would identify * specifically each rule. * - * On 32-bit architectures, the handle can simply be the flow's pointer address. - * On 64-bit architectures, we rely on jhash(flow) to find a (sufficiently) - * unique handle. + * Use jhash of the flow poitner to make a unique handle. * * @param[in, out] flow * The flow that needs its handle set. @@ -1309,16 +1308,18 @@ tap_flow_set_handle(struct rte_flow *flow) { union { struct rte_flow *flow; - const void *key; - } tmp; - uint32_t handle = 0; + uint32_t words[sizeof(flow) / sizeof(uint32_t)]; + } tmp = { + .flow = flow, + }; + uint32_t handle; + static uint64_t hash_seed; - tmp.flow = flow; + if (hash_seed == 0) + hash_seed = rte_rand(); + + handle = rte_jhash_32b(tmp.words, sizeof(flow) / sizeof(uint32_t), hash_seed); - if (sizeof(flow) > 4) - handle = rte_jhash(tmp.key, sizeof(flow), 1); - else - handle = (uintptr_t)flow; /* must be at least 1 to avoid letting the kernel choose one for us */ if (!handle) handle = 1;