From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Anatoly Burakov <anatoly.burakov@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: [PATCH] net/ixgbe: avoid private driver include in testpmd
Date: Wed, 14 Oct 2026 22:34:34 +0200 [thread overview]
Message-ID: <20261014203435.583064-1-thomas@monjalon.net> (raw)
Testpmd commands should use the driver's public API
rather than access its private structures directly.
Note: ixgbe_testpmd.c should be considered as part of testpmd.
ixgbe_testpmd.c includes ixgbe_ethdev.h only to check whether bypass
operations are available through the private adapter structure.
Rely on the public bypass API to check availability
and handle -ENOTSUP in the commands.
Remove ixgbe_ethdev.h, ethdev_driver.h
and the now unnecessary RTE_LIBRTE_IXGBE_BYPASS definition.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/net/intel/ixgbe/ixgbe_testpmd.c | 55 ++++++++++---------------
1 file changed, 21 insertions(+), 34 deletions(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_testpmd.c b/drivers/net/intel/ixgbe/ixgbe_testpmd.c
index e0d161eafe..e209093477 100644
--- a/drivers/net/intel/ixgbe/ixgbe_testpmd.c
+++ b/drivers/net/intel/ixgbe/ixgbe_testpmd.c
@@ -2,11 +2,12 @@
* Copyright(c) 2010-2016 Intel Corporation.
*/
-/* Required for ixgbe internal structures to be aligned with the driver */
-#define RTE_LIBRTE_IXGBE_BYPASS
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-#include <ethdev_driver.h>
-#include "ixgbe_ethdev.h"
+#include <rte_string_fns.h>
#include "rte_pmd_ixgbe.h"
#include <cmdline_parse_etheraddr.h>
@@ -621,20 +622,6 @@ static cmdline_parse_inst_t cmd_tc_min_bw = {
/* The NIC bypass watchdog timeout. */
uint32_t bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
-static inline bool
-check_bypass_enabled(portid_t port_id)
-{
- struct ixgbe_adapter *adapter;
-
- adapter = rte_eth_devices[port_id].data->dev_private;
- if (adapter->bps.ops.bypass_rw == NULL) {
- fprintf(stderr, "Bypass is not enabled on this port.\n");
- return false;
- }
-
- return true;
-}
-
/* Enable bypass mode */
struct cmd_config_bypass_result {
cmdline_fixed_string_t port;
@@ -704,9 +691,6 @@ cmd_set_bypass_mode_parsed(void *parsed_result,
portid_t port_id = res->port_id;
int32_t rc = -EINVAL;
- if (!check_bypass_enabled(port_id))
- return;
-
if (!strcmp(res->value, "bypass"))
bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
else if (!strcmp(res->value, "isolate"))
@@ -716,7 +700,9 @@ cmd_set_bypass_mode_parsed(void *parsed_result,
/* Set the bypass mode for the relevant port. */
rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
- if (rc != 0)
+ if (rc == -ENOTSUP)
+ fprintf(stderr, "Bypass is not enabled on this port.\n");
+ else if (rc != 0)
fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
port_id);
}
@@ -773,9 +759,6 @@ cmd_set_bypass_event_parsed(void *parsed_result,
uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
- if (!check_bypass_enabled(port_id))
- return;
-
if (!strcmp(res->event_value, "timeout"))
bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
else if (!strcmp(res->event_value, "os_on"))
@@ -803,6 +786,10 @@ cmd_set_bypass_event_parsed(void *parsed_result,
rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
bypass_timeout);
}
+ if (rc == -ENOTSUP) {
+ fprintf(stderr, "Bypass is not enabled on this port.\n");
+ return;
+ }
if (rc != 0) {
fprintf(stderr,
"Failed to set timeout value %u for port %d, errto code: %d.\n",
@@ -813,7 +800,9 @@ cmd_set_bypass_event_parsed(void *parsed_result,
/* Set the bypass event to transition to bypass mode. */
rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
bypass_mode);
- if (rc != 0)
+ if (rc == -ENOTSUP)
+ fprintf(stderr, "Bypass is not enabled on this port.\n");
+ else if (rc != 0)
fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
port_id);
}
@@ -952,11 +941,13 @@ cmd_show_bypass_config_parsed(void *parsed_result,
"power supply off",
"timeout"};
- if (!check_bypass_enabled(port_id))
- return;
-
/* Display the bypass mode.*/
- if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
+ rc = rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode);
+ if (rc == -ENOTSUP) {
+ fprintf(stderr, "Bypass is not enabled on this port.\n");
+ return;
+ }
+ if (rc != 0) {
fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
port_id);
return;
@@ -985,10 +976,6 @@ cmd_show_bypass_config_parsed(void *parsed_result,
modes[event_mode]);
}
}
- if (rc != 0)
- fprintf(stderr,
- "\tFailed to get bypass configuration for port = %d\n",
- port_id);
}
static cmdline_parse_token_string_t cmd_showbypass_config_show =
--
2.55.0
next reply other threads:[~2026-10-14 20:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 20:34 Thomas Monjalon [this message]
2026-10-15 8:53 ` [PATCH] net/ixgbe: avoid private driver include in testpmd Burakov, Anatoly
2026-10-15 9:13 ` Thomas Monjalon
2026-10-15 10:41 ` Burakov, Anatoly
2026-10-15 11:18 ` David Marchand
2026-10-15 11:21 ` Burakov, Anatoly
2026-10-15 11:50 ` Thomas Monjalon
2026-10-15 14:01 ` Burakov, Anatoly
2026-10-15 14:21 ` [PATCH v2 1/3] " Anatoly Burakov
2026-10-15 14:21 ` [PATCH v2 2/3] net/iavf: do not include private headers " Anatoly Burakov
2026-10-15 14:33 ` Bruce Richardson
2026-10-15 14:45 ` Medvedkin, Vladimir
2026-10-15 14:21 ` [PATCH v2 3/3] net/ice: " Anatoly Burakov
2026-10-15 14:36 ` Bruce Richardson
2026-10-15 14:39 ` Bruce Richardson
2026-10-15 14:52 ` Medvedkin, Vladimir
2026-10-15 15:00 ` Burakov, Anatoly
2026-10-15 15:21 ` Bruce Richardson
2026-10-15 15:29 ` Burakov, Anatoly
2026-10-15 14:44 ` [PATCH v2 1/3] net/ixgbe: avoid private driver include " Medvedkin, Vladimir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014203435.583064-1-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=vladimir.medvedkin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox