linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/bnxt_re: Replace cpu_to_be64 + le64_to_cpu with swab64
@ 2025-12-10 13:15 Thorsten Blum
  2025-12-18 15:18 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-12-10 13:15 UTC (permalink / raw)
  To: Selvin Xavier, Kalesh AP, Jason Gunthorpe, Leon Romanovsky
  Cc: Thorsten Blum, linux-rdma, linux-kernel

Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify
bnxt_re_assign_pma_port_ext_counters().  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/infiniband/hw/bnxt_re/hw_counters.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/hw_counters.c b/drivers/infiniband/hw/bnxt_re/hw_counters.c
index 651cf9d0e0c7..bb1137ad84c0 100644
--- a/drivers/infiniband/hw/bnxt_re/hw_counters.c
+++ b/drivers/infiniband/hw/bnxt_re/hw_counters.c
@@ -290,19 +290,12 @@ int bnxt_re_assign_pma_port_ext_counters(struct bnxt_re_dev *rdev, struct ib_mad
 	pma_cnt_ext = (struct ib_pma_portcounters_ext *)(out_mad->data + 40);
 	if ((bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) && rdev->is_virtfn) ||
 	    !bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) {
-		pma_cnt_ext->port_xmit_data =
-			cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_bytes) / 4);
-		pma_cnt_ext->port_rcv_data =
-			cpu_to_be64(le64_to_cpu(hw_stats->rx_ucast_bytes) / 4);
-		pma_cnt_ext->port_xmit_packets =
-			cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_pkts));
-		pma_cnt_ext->port_rcv_packets =
-			cpu_to_be64(le64_to_cpu(hw_stats->rx_ucast_pkts));
-		pma_cnt_ext->port_unicast_rcv_packets =
-			cpu_to_be64(le64_to_cpu(hw_stats->rx_ucast_pkts));
-		pma_cnt_ext->port_unicast_xmit_packets =
-			cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_pkts));
-
+		pma_cnt_ext->port_xmit_data = swab64(hw_stats->tx_ucast_bytes / 4);
+		pma_cnt_ext->port_rcv_data = swab64(hw_stats->rx_ucast_bytes / 4);
+		pma_cnt_ext->port_xmit_packets = swab64(hw_stats->tx_ucast_pkts);
+		pma_cnt_ext->port_rcv_packets = swab64(hw_stats->rx_ucast_pkts);
+		pma_cnt_ext->port_unicast_rcv_packets = swab64(hw_stats->rx_ucast_pkts);
+		pma_cnt_ext->port_unicast_xmit_packets = swab64(hw_stats->tx_ucast_pkts);
 	} else {
 		pma_cnt_ext->port_rcv_packets = cpu_to_be64(estat->rx_roce_good_pkts);
 		pma_cnt_ext->port_rcv_data = cpu_to_be64(estat->rx_roce_good_bytes / 4);
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] RDMA/bnxt_re: Replace cpu_to_be64 + le64_to_cpu with swab64
  2025-12-10 13:15 [PATCH] RDMA/bnxt_re: Replace cpu_to_be64 + le64_to_cpu with swab64 Thorsten Blum
@ 2025-12-18 15:18 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2025-12-18 15:18 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Selvin Xavier, Kalesh AP, Jason Gunthorpe, linux-rdma,
	linux-kernel

On Wed, Dec 10, 2025 at 02:15:29PM +0100, Thorsten Blum wrote:
> Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify
> bnxt_re_assign_pma_port_ext_counters().  No functional changes.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/infiniband/hw/bnxt_re/hw_counters.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/bnxt_re/hw_counters.c b/drivers/infiniband/hw/bnxt_re/hw_counters.c
> index 651cf9d0e0c7..bb1137ad84c0 100644
> --- a/drivers/infiniband/hw/bnxt_re/hw_counters.c
> +++ b/drivers/infiniband/hw/bnxt_re/hw_counters.c
> @@ -290,19 +290,12 @@ int bnxt_re_assign_pma_port_ext_counters(struct bnxt_re_dev *rdev, struct ib_mad
>  	pma_cnt_ext = (struct ib_pma_portcounters_ext *)(out_mad->data + 40);
>  	if ((bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) && rdev->is_virtfn) ||
>  	    !bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) {
> -		pma_cnt_ext->port_xmit_data =
> -			cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_bytes) / 4);

> +		pma_cnt_ext->port_xmit_data = swab64(hw_stats->tx_ucast_bytes / 4);

Why do you think that the above two lines are equal?
hw_stats->tx_ucast_bytes is __le64 value and le64_to_cpu(hw_stats->tx_ucast_bytes) / 4) is not equal to
hw_stats->tx_ucast_bytes / 4.

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-18 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 13:15 [PATCH] RDMA/bnxt_re: Replace cpu_to_be64 + le64_to_cpu with swab64 Thorsten Blum
2025-12-18 15:18 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).