lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1ee392cf6a639b47cf9aa648fbc1c11393e19748.1744048182.git.kalavakunta.hari.prasad@gmail.com>
Date: Mon,  7 Apr 2025 11:19:49 -0700
From: kalavakunta.hari.prasad@...il.com
To: sam@...dozajonas.com,
	fercerpav@...il.com,
	davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	horms@...nel.org,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: npeacock@...a.com,
	akozlov@...a.com,
	Hari Kalavakunta <kalavakunta.hari.prasad@...il.com>
Subject: [PATCH net-next 2/2] net: ncsi: Fix GCPS 64-bit member variables

From: Hari Kalavakunta <kalavakunta.hari.prasad@...il.com>

Correct Get Controller Packet Statistics (GCPS) 64-bit wide member
variables, as per DSP0222 v1.0.0 and forward specs. The Driver currently
collects these stats, but they are yet to be exposed to the user.
Therefore, no user impact.

Statistics fixes:
Total Bytes Received (byte range 28..35)
Total Bytes Transmitted (byte range 36..43)
Total Unicast Packets Received (byte range 44..51)
Total Multicast Packets Received (byte range 52..59)
Total Broadcast Packets Received (byte range 60..67)
Total Unicast Packets Transmitted (byte range 68..75)
Total Multicast Packets Transmitted (byte range 76..83)
Total Broadcast Packets Transmitted (byte range 84..91)
Valid Bytes Received (byte range 204..11)

Signed-off-by: Hari Kalavakunta <kalavakunta.hari.prasad@...il.com>
---
 net/ncsi/internal.h | 21 ++++++++++-----------
 net/ncsi/ncsi-pkt.h | 27 ++++++++++++++++++---------
 net/ncsi/ncsi-rsp.c | 31 ++++++++++++++++++++-----------
 3 files changed, 48 insertions(+), 31 deletions(-)

diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index 4e0842df5234..2c260f33b55c 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -143,16 +143,15 @@ struct ncsi_channel_vlan_filter {
 };
 
 struct ncsi_channel_stats {
-	u32 hnc_cnt_hi;		/* Counter cleared            */
-	u32 hnc_cnt_lo;		/* Counter cleared            */
-	u32 hnc_rx_bytes;	/* Rx bytes                   */
-	u32 hnc_tx_bytes;	/* Tx bytes                   */
-	u32 hnc_rx_uc_pkts;	/* Rx UC packets              */
-	u32 hnc_rx_mc_pkts;     /* Rx MC packets              */
-	u32 hnc_rx_bc_pkts;	/* Rx BC packets              */
-	u32 hnc_tx_uc_pkts;	/* Tx UC packets              */
-	u32 hnc_tx_mc_pkts;	/* Tx MC packets              */
-	u32 hnc_tx_bc_pkts;	/* Tx BC packets              */
+	u64 hnc_cnt;		/* Counter cleared            */
+	u64 hnc_rx_bytes;	/* Rx bytes                   */
+	u64 hnc_tx_bytes;	/* Tx bytes                   */
+	u64 hnc_rx_uc_pkts;	/* Rx UC packets              */
+	u64 hnc_rx_mc_pkts;     /* Rx MC packets              */
+	u64 hnc_rx_bc_pkts;	/* Rx BC packets              */
+	u64 hnc_tx_uc_pkts;	/* Tx UC packets              */
+	u64 hnc_tx_mc_pkts;	/* Tx MC packets              */
+	u64 hnc_tx_bc_pkts;	/* Tx BC packets              */
 	u32 hnc_fcs_err;	/* FCS errors                 */
 	u32 hnc_align_err;	/* Alignment errors           */
 	u32 hnc_false_carrier;	/* False carrier detection    */
@@ -181,7 +180,7 @@ struct ncsi_channel_stats {
 	u32 hnc_tx_1023_frames;	/* Tx 512-1023 bytes frames   */
 	u32 hnc_tx_1522_frames;	/* Tx 1024-1522 bytes frames  */
 	u32 hnc_tx_9022_frames;	/* Tx 1523-9022 bytes frames  */
-	u32 hnc_rx_valid_bytes;	/* Rx valid bytes             */
+	u64 hnc_rx_valid_bytes;	/* Rx valid bytes             */
 	u32 hnc_rx_runt_pkts;	/* Rx error runt packets      */
 	u32 hnc_rx_jabber_pkts;	/* Rx error jabber packets    */
 	u32 ncsi_rx_cmds;	/* Rx NCSI commands           */
diff --git a/net/ncsi/ncsi-pkt.h b/net/ncsi/ncsi-pkt.h
index 6cf3baac99dd..8560e6fe20e6 100644
--- a/net/ncsi/ncsi-pkt.h
+++ b/net/ncsi/ncsi-pkt.h
@@ -254,14 +254,22 @@ struct ncsi_rsp_gcps_pkt {
 	struct ncsi_rsp_pkt_hdr rsp;               /* Response header            */
 	__be32                  cnt_hi;            /* Counter cleared            */
 	__be32                  cnt_lo;            /* Counter cleared            */
-	__be32                  rx_bytes;          /* Rx bytes                   */
-	__be32                  tx_bytes;          /* Tx bytes                   */
-	__be32                  rx_uc_pkts;        /* Rx UC packets              */
-	__be32                  rx_mc_pkts;        /* Rx MC packets              */
-	__be32                  rx_bc_pkts;        /* Rx BC packets              */
-	__be32                  tx_uc_pkts;        /* Tx UC packets              */
-	__be32                  tx_mc_pkts;        /* Tx MC packets              */
-	__be32                  tx_bc_pkts;        /* Tx BC packets              */
+	__be32                  rx_bytes_hi;       /* Rx bytes                   */
+	__be32                  rx_bytes_lo;       /* Rx bytes                   */
+	__be32                  tx_bytes_hi;       /* Tx bytes                   */
+	__be32                  tx_bytes_lo;       /* Tx bytes                   */
+	__be32                  rx_uc_pkts_hi;     /* Rx UC packets              */
+	__be32                  rx_uc_pkts_lo;     /* Rx UC packets              */
+	__be32                  rx_mc_pkts_hi;     /* Rx MC packets              */
+	__be32                  rx_mc_pkts_lo;     /* Rx MC packets              */
+	__be32                  rx_bc_pkts_hi;     /* Rx BC packets              */
+	__be32                  rx_bc_pkts_lo;     /* Rx BC packets              */
+	__be32                  tx_uc_pkts_hi;     /* Tx UC packets              */
+	__be32                  tx_uc_pkts_lo;     /* Tx UC packets              */
+	__be32                  tx_mc_pkts_hi;     /* Tx MC packets              */
+	__be32                  tx_mc_pkts_lo;     /* Tx MC packets              */
+	__be32                  tx_bc_pkts_hi;     /* Tx BC packets              */
+	__be32                  tx_bc_pkts_lo;     /* Tx BC packets              */
 	__be32                  fcs_err;           /* FCS errors                 */
 	__be32                  align_err;         /* Alignment errors           */
 	__be32                  false_carrier;     /* False carrier detection    */
@@ -290,7 +298,8 @@ struct ncsi_rsp_gcps_pkt {
 	__be32                  tx_1023_frames;    /* Tx 512-1023 bytes frames   */
 	__be32                  tx_1522_frames;    /* Tx 1024-1522 bytes frames  */
 	__be32                  tx_9022_frames;    /* Tx 1523-9022 bytes frames  */
-	__be32                  rx_valid_bytes;    /* Rx valid bytes             */
+	__be32                  rx_valid_bytes_hi; /* Rx valid bytes             */
+	__be32                  rx_valid_bytes_lo; /* Rx valid bytes             */
 	__be32                  rx_runt_pkts;      /* Rx error runt packets      */
 	__be32                  rx_jabber_pkts;    /* Rx error jabber packets    */
 	__be32                  checksum;          /* Checksum                   */
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
index 4a8ce2949fae..50a59f4c021e 100644
--- a/net/ncsi/ncsi-rsp.c
+++ b/net/ncsi/ncsi-rsp.c
@@ -926,16 +926,24 @@ static int ncsi_rsp_handler_gcps(struct ncsi_request *nr)
 
 	/* Update HNC's statistics */
 	ncs = &nc->stats;
-	ncs->hnc_cnt_hi         = ntohl(rsp->cnt_hi);
-	ncs->hnc_cnt_lo         = ntohl(rsp->cnt_lo);
-	ncs->hnc_rx_bytes       = ntohl(rsp->rx_bytes);
-	ncs->hnc_tx_bytes       = ntohl(rsp->tx_bytes);
-	ncs->hnc_rx_uc_pkts     = ntohl(rsp->rx_uc_pkts);
-	ncs->hnc_rx_mc_pkts     = ntohl(rsp->rx_mc_pkts);
-	ncs->hnc_rx_bc_pkts     = ntohl(rsp->rx_bc_pkts);
-	ncs->hnc_tx_uc_pkts     = ntohl(rsp->tx_uc_pkts);
-	ncs->hnc_tx_mc_pkts     = ntohl(rsp->tx_mc_pkts);
-	ncs->hnc_tx_bc_pkts     = ntohl(rsp->tx_bc_pkts);
+	ncs->hnc_cnt            = (u64)ntohl(rsp->cnt_hi) << 32 |
+				  (u64)ntohl(rsp->cnt_lo);
+	ncs->hnc_rx_bytes       = (u64)ntohl(rsp->rx_bytes_hi) << 32 |
+				  (u64)ntohl(rsp->rx_bytes_lo);
+	ncs->hnc_tx_bytes       = (u64)ntohl(rsp->tx_bytes_hi) << 32 |
+				  (u64)ntohl(rsp->tx_bytes_lo);
+	ncs->hnc_rx_uc_pkts     = (u64)ntohl(rsp->rx_uc_pkts_hi) << 32 |
+				  (u64)ntohl(rsp->rx_uc_pkts_lo);
+	ncs->hnc_rx_mc_pkts     = (u64)ntohl(rsp->rx_mc_pkts_hi) << 32 |
+				  (u64)ntohl(rsp->rx_mc_pkts_lo);
+	ncs->hnc_rx_bc_pkts     = (u64)ntohl(rsp->rx_bc_pkts_hi) << 32 |
+				  (u64)ntohl(rsp->rx_bc_pkts_lo);
+	ncs->hnc_tx_uc_pkts     = (u64)ntohl(rsp->tx_uc_pkts_hi) << 32 |
+				  (u64)ntohl(rsp->tx_uc_pkts_lo);
+	ncs->hnc_tx_mc_pkts     = (u64)ntohl(rsp->tx_mc_pkts_hi) << 32 |
+				  (u64)ntohl(rsp->tx_mc_pkts_lo);
+	ncs->hnc_tx_bc_pkts     = (u64)ntohl(rsp->tx_bc_pkts_hi) << 32 |
+				  (u64)ntohl(rsp->tx_bc_pkts_lo);
 	ncs->hnc_fcs_err        = ntohl(rsp->fcs_err);
 	ncs->hnc_align_err      = ntohl(rsp->align_err);
 	ncs->hnc_false_carrier  = ntohl(rsp->false_carrier);
@@ -964,7 +972,8 @@ static int ncsi_rsp_handler_gcps(struct ncsi_request *nr)
 	ncs->hnc_tx_1023_frames = ntohl(rsp->tx_1023_frames);
 	ncs->hnc_tx_1522_frames = ntohl(rsp->tx_1522_frames);
 	ncs->hnc_tx_9022_frames = ntohl(rsp->tx_9022_frames);
-	ncs->hnc_rx_valid_bytes = ntohl(rsp->rx_valid_bytes);
+	ncs->hnc_rx_valid_bytes = (u64)ntohl(rsp->rx_valid_bytes_hi) << 32 |
+				  (u64)ntohl(rsp->rx_valid_bytes_lo);
 	ncs->hnc_rx_runt_pkts   = ntohl(rsp->rx_runt_pkts);
 	ncs->hnc_rx_jabber_pkts = ntohl(rsp->rx_jabber_pkts);
 
-- 
2.47.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ