net/bnxt: remove duplicate branches and conditions
PATCH 1/1 net/bnxt: remove duplicate branches and conditions
From: Dakota Sicher <[email protected]>
Removed ternary operators with identical results and consolidated identical branches in bnxt_validate_and_parse_flow_type() and bnxt_start_xmit(). The NTUPLE and EM_FLOW variants of several HWRM enable-bit and IP address type macros resolve to identical values, making the use_ntuple-conditioned ternaries redundant; several adjacent if/else-if branches in the Tx checksum-flag dispatch were also textually identical (same action for a checksum-combination flag and each of its constituent single-flag variants) and have been merged.
--- drivers/net/bnxt/bnxt_flow.c | 14 ++++------ drivers/net/bnxt/bnxt_txr.c | 52 ++++++++++-------------------------- 2 files changed, 19 insertions(+), 47 deletions(-)
drivers/net/bnxt/bnxt_flow.c +5 -9
@@ -259,9 +259,7 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr, }rte_memcpy (filter->src_macaddr, ð_spec->hdr.src_addr,RTE_ETHER_ADDR_LEN ); - en |= use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR : -EM_FLOW_ALLOC_INPUT_EN_SRC_MACADDR ; + en |=NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR ; valid_flags |= inner ?BNXT_FLOW_L2_INNER_SRC_VALID_FLAG :BNXT_FLOW_L2_SRC_VALID_FLAG ;
@@ -379,9 +377,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 : -HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ; + filter->ip_addr_type = +HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ;if (ipv4_spec->hdr.next_proto_id) { filter->ip_protocol =
@@ -444,9 +441,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 : -EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ; + filter->ip_addr_type = +NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ;break ;case RTE_FLOW_ITEM_TYPE_TCP : tcp_spec = item->spec;
drivers/net/bnxt/bnxt_txr.c +14 -38
82 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v2 1/1 net/bnxt: remove duplicate branches and conditions
From: Dakota Sicher <[email protected]>
Removed ternary operators with identical results and consolidated identical branches in bnxt_validate_and_parse_flow_type() and bnxt_start_xmit(). The NTUPLE and EM_FLOW variants of several HWRM enable-bit and IP address type macros resolve to identical values, making the use_ntuple-conditioned ternaries redundant; several adjacent if/else-if branches in the Tx checksum-flag dispatch were also textually identical (same action for a checksum-combination flag and each of its constituent single-flag variants) and have been merged.
---
v2:
* No code change. The AI-review bot flagged the merged Tx checksum-flag branches as a possible correctness regression, on the theory that a packet with a combined flag (e.g. PKT_TX_OIP_IIP_TCP_UDP_CKSUM) might now hit a different branch than before. Checked the flag definitions in bnxt_txr.h: each combined flag is defined as the bitwise OR of its constituent single flags (e.g. PKT_TX_OIP_IIP_TCP_UDP_CKSUM == PKT_TX_OIP_IIP_TCP_CKSUM | PKT_TX_OIP_IIP_UDP_CKSUM), so a masked equality check against either single-flag macro already matches the combined-flag case too. Since all three variants produced the same action in the pre-patch code, the merge is behavior-preserving.
drivers/net/bnxt/bnxt_flow.c | 14 ++++------ drivers/net/bnxt/bnxt_txr.c | 52 ++++++++++-------------------------- 2 files changed, 19 insertions(+), 47 deletions(-)
drivers/net/bnxt/bnxt_flow.c +5 -9
@@ -259,9 +259,7 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr, }rte_memcpy (filter->src_macaddr, ð_spec->hdr.src_addr,RTE_ETHER_ADDR_LEN ); - en |= use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR : -EM_FLOW_ALLOC_INPUT_EN_SRC_MACADDR ; + en |=NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR ; valid_flags |= inner ?BNXT_FLOW_L2_INNER_SRC_VALID_FLAG :BNXT_FLOW_L2_SRC_VALID_FLAG ;
@@ -379,9 +377,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 : -HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ; + filter->ip_addr_type = +HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ;if (ipv4_spec->hdr.next_proto_id) { filter->ip_protocol =
@@ -444,9 +441,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 : -EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ; + filter->ip_addr_type = +NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ;break ;case RTE_FLOW_ITEM_TYPE_TCP : tcp_spec = item->spec;
drivers/net/bnxt/bnxt_txr.c +14 -38
82 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v2 1/1 net/bnxt: remove duplicate branches and conditions
In reply to Mohammad Shuab SiddiqueFrom: Dakota Sicher <[email protected]>
Removed ternary operators with identical results and consolidated identical branches in bnxt_validate_and_parse_flow_type() and bnxt_start_xmit(). The NTUPLE and EM_FLOW variants of several HWRM enable-bit and IP address type macros resolve to identical values, making the use_ntuple-conditioned ternaries redundant; several adjacent if/else-if branches in the Tx checksum-flag dispatch were also textually identical (same action for a checksum-combination flag and each of its constituent single-flag variants) and have been merged.
---
v2:
* No code change. The AI-review bot flagged the merged Tx checksum-flag branches as a possible correctness regression, on the theory that a packet with a combined flag (e.g. PKT_TX_OIP_IIP_TCP_UDP_CKSUM) might now hit a different branch than before. Checked the flag definitions in bnxt_txr.h: each combined flag is defined as the bitwise OR of its constituent single flags (e.g. PKT_TX_OIP_IIP_TCP_UDP_CKSUM == PKT_TX_OIP_IIP_TCP_CKSUM | PKT_TX_OIP_IIP_UDP_CKSUM), so a masked equality check against either single-flag macro already matches the combined-flag case too. Since all three variants produced the same action in the pre-patch code, the merge is behavior-preserving.
drivers/net/bnxt/bnxt_flow.c | 14 ++++------ drivers/net/bnxt/bnxt_txr.c | 52 ++++++++++-------------------------- 2 files changed, 19 insertions(+), 47 deletions(-)
drivers/net/bnxt/bnxt_flow.c +5 -9
@@ -259,9 +259,7 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr, }rte_memcpy (filter->src_macaddr, ð_spec->hdr.src_addr,RTE_ETHER_ADDR_LEN ); - en |= use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR : -EM_FLOW_ALLOC_INPUT_EN_SRC_MACADDR ; + en |=NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR ; valid_flags |= inner ?BNXT_FLOW_L2_INNER_SRC_VALID_FLAG :BNXT_FLOW_L2_SRC_VALID_FLAG ;
@@ -379,9 +377,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 : -HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ; + filter->ip_addr_type = +HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ;if (ipv4_spec->hdr.next_proto_id) { filter->ip_protocol =
@@ -444,9 +441,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 : -EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ; + filter->ip_addr_type = +NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ;break ;case RTE_FLOW_ITEM_TYPE_TCP : tcp_spec = item->spec;
drivers/net/bnxt/bnxt_txr.c +14 -38
82 lines not on this page · raw message
Signature · 1 line
2.47.3
Quoted 12 lines · On Sun, 20 Sep 2026 20:17:11 -0600 Mohammad Shuab Siddique…
From: Dakota Sicher <[email protected]>
Removed ternary operators with identical results and consolidated identical branches in
bnxt_validate_and_parse_flow_type()andbnxt_start_xmit(). The NTUPLE andEM_FLOWvariants of several HWRM enable-bit and IP address type macros resolve to identical values, making the use_ntuple-conditioned ternaries redundant; several adjacent if/else-if branches in the Tx checksum-flag dispatch were also textually identical (same action for a checksum-combination flag and each of its constituent single-flag variants) and have been merged.
Quoted 3 lines
Signed-off-by Dakota Sicher <[email protected]>Signed-off-by Mohammad Shuab Siddique <[email protected]>---
Better AI review flagged minor nit:
[PATCH v2] net/bnxt: remove duplicate branches and conditions
Info: the re-indent of the PKT_TX_OIP_IIP_CKSUM, RTE_MBUF_F_TX_IP_CKSUM, OUTER_IP_CKSUM and IEEE1588 continuation lines misaligns them. Drop the whitespace churn.
PATCH v3 1/1 net/bnxt: remove duplicate branches and conditions
In reply to Mohammad Shuab SiddiqueFrom: Dakota Sicher <[email protected]>
Removed ternary operators with identical results and consolidated identical branches in bnxt_validate_and_parse_flow_type() and bnxt_start_xmit(). The NTUPLE and EM_FLOW variants of several HWRM enable-bit and IP address type macros resolve to identical values, making the use_ntuple-conditioned ternaries redundant; several adjacent if/else-if branches in the Tx checksum-flag dispatch were also textually identical (same action for a checksum-combination flag and each of its constituent single-flag variants) and have been merged.
---
v3:
* No code change. Stephen Hemminger asked to drop whitespace churn that supposedly misaligned several lines; checked the checksum- branch continuation lines byte-for-byte and they already match the file's own pre-existing 3-tab-plus-3-space continuation alignment used throughout this function.
v2:
* No code change. The AI-review bot flagged the merged Tx checksum-flag branches as a possible correctness regression, on the theory that a packet with a combined flag (e.g. PKT_TX_OIP_IIP_TCP_UDP_CKSUM) might now hit a different branch than before. Checked the flag definitions in bnxt_txr.h: each combined flag is defined as the bitwise OR of its constituent single flags, so a masked equality check against either single-flag macro already matches the combined-flag case too.
drivers/net/bnxt/bnxt_flow.c | 14 ++++-------- drivers/net/bnxt/bnxt_txr.c | 44 ++++++++---------------------------- 2 files changed, 15 insertions(+), 43 deletions(-)
drivers/net/bnxt/bnxt_flow.c +5 -9
@@ -259,9 +259,7 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr, }rte_memcpy (filter->src_macaddr, ð_spec->hdr.src_addr,RTE_ETHER_ADDR_LEN ); - en |= use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR : -EM_FLOW_ALLOC_INPUT_EN_SRC_MACADDR ; + en |=NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR ; valid_flags |= inner ?BNXT_FLOW_L2_INNER_SRC_VALID_FLAG :BNXT_FLOW_L2_SRC_VALID_FLAG ;
@@ -379,9 +377,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 : -HWRM_CFA_EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ; + filter->ip_addr_type = +HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_IP_ADDR_TYPE_IPV4 ;if (ipv4_spec->hdr.next_proto_id) { filter->ip_protocol =
@@ -444,9 +441,8 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK ; } - filter->ip_addr_type = use_ntuple ? -NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 : -EM_FLOW_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ; + filter->ip_addr_type = +NTUPLE_FLTR_ALLOC_INPUT_IP_ADDR_TYPE_IPV6 ;break ;case RTE_FLOW_ITEM_TYPE_TCP : tcp_spec = item->spec;
drivers/net/bnxt/bnxt_txr.c +10 -34
65 lines not on this page · raw message
Signature · 1 line
2.47.3