On Fri, 21 Aug 2026 11:26:43 +0530
Gagandeep Singh <[email protected]> wrote:

> Add enetc4_txq_wrr devarg to configure per-ring WRR weights in the
> NETC LEAF-level Tx scheduler (TBaMR register, bits [6:4]).
> 
> The NETC Tx scheduler has three levels:
>   - ROOT (port/TC): strict priority + CBS (PF/port space)
>   - MID  (SI/VSI):  WBFS shaping (PF space)
>   - LEAF (Tx BDR):  strict priority + frame-based WRR (VF/SI space)
> 
> TBaMR is in the VF own SI space, so no Linux PF involvement is
> needed for PRIO or WRR configuration.
> 
> Changes:
> - enetc_hw.h: add ENETC_TBMR_WRR_MASK, ENETC_TBMR_WRR(n) macros for
>   TBaMR bits [6:4], and ENETC_TBMR_PRIO_MASK for bits [2:0]
> - enetc.h: add txq_wrr pointer to enetc_eth_hw struct
> - enetc4_ethdev.c: add parse_txq_wrr() and wire ENETC4_TXQ_WRR devarg
>   through enetc4_get_devargs() and enetc4_dev_configure(); apply WRR
>   bits in enetc4_tx_queue_setup() and enetc4_tx_queue_start()
> 
> Usage:
>   # strict priority: ring 0 highest
>   -a 0002:00:12.0,enetc4_txq_prior="3|2|1"
> 
>   # WRR 2:4:1 on same-priority rings
>   -a 0002:00:12.0,enetc4_txq_prior="1|1|1",enetc4_txq_wrr="2|4|1"
> 
> Signed-off-by: Gagandeep Singh <[email protected]>
> Acked-by: Hemant Agrawal <[email protected]>
> ---

This is in next-net now as is, but you should fix the arg parsing
code not to use unsafe string handling functions. 

strtok() is not thread safe, use strtok_r() or other non-destructive parsing.
atoi() and atof() except garbage and don't do out of range testing and take 
negative values;
use strtoul() here instead. Probably should have a DPDK string function for this
like rte_str_to_u32() etc; might get to doing that.

Newer version of checkpatch (in python) flags this as:

### [PATCH] net/enetc4: add WRR Tx scheduler devarg for VF rings

ERROR: [FORBIDDEN_TOKEN] Using strtok(), prefer strtok_r() (non-reentrant 
static state)
#  drivers/net/enetc/enetc4_ethdev.c:76:
+               str = strtok(NULL, "|");

ERROR: [FORBIDDEN_TOKEN] Using strtok(), prefer strtok_r() (non-reentrant 
static state)
#  drivers/net/enetc/enetc4_ethdev.c:107:
+       str = strtok(input_str, "|");

WARNING: [FORBIDDEN_TOKEN] Using atoi()/atol()/atof(), prefer 
strtol()/strtoul() with errno and endptr checks
#  drivers/net/enetc/enetc4_ethdev.c:75:
+               hw->txq_prior[i++] = atoi(str) & ENETC_TBMR_PRIO_MASK;

WARNING: [FORBIDDEN_TOKEN] Using atoi()/atol()/atof(), prefer 
strtol()/strtoul() with errno and endptr checks
#  drivers/net/enetc/enetc4_ethdev.c:109:
+               w = atoi(str);

total: 2 errors, 2 warnings, 0 checks, 102 lines checked

Reply via email to