[PATCH v2 28/61] net/ixgbe: use kvargs numeric helpers
Stephen Hemminger
stephen at networkplumber.org
Tue Sep 29 18:36:31 CEST 2026
devarg_handle_int() truncates the strtoul() result into a uint16_t and
then infers overflow from the truncated value being USHRT_MAX, so a
value such as "65536" is silently accepted as zero. It also never
checked the end pointer, and read errno without clearing it first.
fiber_sdp3_no_tx_disable and pflink_fullchk are booleans, so make the
fields bool and parse them with rte_kvargs_handle_bool() straight into
the adapter, which also removes the temporary and the "== 1" dance. A
bare key now enables the option, and the usual spellings are accepted.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/net/intel/ixgbe/ixgbe_ethdev.c | 40 ++++++--------------------
drivers/net/intel/ixgbe/ixgbe_ethdev.h | 4 +--
2 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index 284df77023..e05c9a8d1f 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -353,8 +353,6 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
static int ixgbe_filter_restore(struct rte_eth_dev *dev);
static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
-static int devarg_handle_int(__rte_unused const char *key, const char *value,
- void *extra_args);
/*
* Define VF Stats MACRO for Non "cleared on read" register
@@ -989,7 +987,6 @@ ixgbe_parse_devargs(struct ixgbe_adapter *adapter,
struct rte_devargs *devargs)
{
struct rte_kvargs *kvlist;
- uint16_t sdp3_no_tx_disable;
enum rte_eth_fdir_pballoc_type pballoc;
int ret = 0;
@@ -1000,11 +997,10 @@ ixgbe_parse_devargs(struct ixgbe_adapter *adapter,
if (kvlist == NULL)
return 0;
- if (rte_kvargs_count(kvlist, IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE) == 1 &&
- rte_kvargs_process(kvlist, IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE,
- devarg_handle_int, &sdp3_no_tx_disable) == 0 &&
- sdp3_no_tx_disable == 1)
- adapter->sdp3_no_tx_disable = 1;
+ if (rte_kvargs_count(kvlist, IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE) == 1)
+ (void)rte_kvargs_process_opt(kvlist, IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE,
+ rte_kvargs_handle_bool,
+ &adapter->sdp3_no_tx_disable);
if (rte_kvargs_count(kvlist, IXGBE_DEVARG_FDIR_BUFFER_SIZE) != 0) {
if (rte_kvargs_process(kvlist, IXGBE_DEVARG_FDIR_BUFFER_SIZE,
@@ -1499,28 +1495,11 @@ generate_random_mac_addr(struct rte_ether_addr *mac_addr)
memcpy(&mac_addr->addr_bytes[3], &random, 3);
}
-static int
-devarg_handle_int(__rte_unused const char *key, const char *value,
- void *extra_args)
-{
- uint16_t *n = extra_args;
-
- if (value == NULL || extra_args == NULL)
- return -EINVAL;
-
- *n = (uint16_t)strtoul(value, NULL, 0);
- if (*n == USHRT_MAX && errno == ERANGE)
- return -1;
-
- return 0;
-}
-
static void
ixgbevf_parse_devargs(struct ixgbe_adapter *adapter,
struct rte_devargs *devargs)
{
struct rte_kvargs *kvlist;
- uint16_t pflink_fullchk;
if (devargs == NULL)
return;
@@ -1529,11 +1508,10 @@ ixgbevf_parse_devargs(struct ixgbe_adapter *adapter,
if (kvlist == NULL)
return;
- if (rte_kvargs_count(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK) == 1 &&
- rte_kvargs_process(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK,
- devarg_handle_int, &pflink_fullchk) == 0 &&
- pflink_fullchk == 1)
- adapter->pflink_fullchk = 1;
+ if (rte_kvargs_count(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK) == 1)
+ (void)rte_kvargs_process_opt(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK,
+ rte_kvargs_handle_bool,
+ &adapter->pflink_fullchk);
rte_kvargs_free(kvlist);
}
@@ -4181,7 +4159,7 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
*speed = IXGBE_LINK_SPEED_UNKNOWN;
}
- if (wait_to_complete == 0 && adapter->pflink_fullchk == 0) {
+ if (wait_to_complete == 0 && !adapter->pflink_fullchk) {
if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
mac->get_link_status = true;
else
diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.h b/drivers/net/intel/ixgbe/ixgbe_ethdev.h
index 0efef29a5d..fff9a07943 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.h
@@ -490,13 +490,13 @@ struct ixgbe_adapter {
uint8_t rss_reta_updated;
/* Used for limiting SDP3 TX_DISABLE checks */
- uint8_t sdp3_no_tx_disable;
+ bool sdp3_no_tx_disable;
uint16_t max_vfs;
/* Used for VF link sync with PF's physical and logical (by checking
* mailbox status) link status.
*/
- uint8_t pflink_fullchk;
+ bool pflink_fullchk;
uint8_t mac_ctrl_frame_fwd;
RTE_ATOMIC(bool) link_thread_running;
rte_thread_t link_thread_tid;
--
2.53.0
More information about the dev
mailing list