From: Min-Hua Chen <minhuadotchen@gmail.com>
To: Nicolas Ferre <nicolas.ferre@microchip.com>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Min-Hua Chen <minhuadotchen@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] net: macb: use correct __be32 and __be16 types
Date: Sat, 20 May 2023 06:19:39 +0800 [thread overview]
Message-ID: <20230519221942.53942-1-minhuadotchen@gmail.com> (raw)
This patch fixes the following sparse warnings. No functional changes.
Use cpu_to_be16() and cpu_to_be32() to convert constants before comparing
them with __be16 type of psrc/pdst and __be32 type of ip4src/ip4dst.
Apply be16_to_cpu() in GEM_BFINS().
Also, remove unnecessary parentheses reported by checkpatch.pl.
drivers/net/ethernet/cadence/macb_main.c:3448:39: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3453:39: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3458:40: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3458:69: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3483:20: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3497:20: sparse: warning: restricted __be32 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3511:21: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3511:50: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3517:30: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3518:30: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3525:36: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3526:38: sparse: warning: restricted __be16 degrades to integer
drivers/net/ethernet/cadence/macb_main.c:3529:38: sparse: warning: restricted __be16 degrades to integer
Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
---
drivers/net/ethernet/cadence/macb_main.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 29a1199dad14..034ec42eaf6d 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3445,17 +3445,18 @@ static void gem_enable_flow_filters(struct macb *bp, bool enable)
/* only enable fields with no masking */
tp4sp_m = &(fs->m_u.tcp_ip4_spec);
- if (enable && (tp4sp_m->ip4src == 0xFFFFFFFF))
+ if (enable && tp4sp_m->ip4src == cpu_to_be32(0xFFFFFFFF))
t2_scr = GEM_BFINS(CMPAEN, 1, t2_scr);
else
t2_scr = GEM_BFINS(CMPAEN, 0, t2_scr);
- if (enable && (tp4sp_m->ip4dst == 0xFFFFFFFF))
+ if (enable && tp4sp_m->ip4dst == cpu_to_be32(0xFFFFFFFF))
t2_scr = GEM_BFINS(CMPBEN, 1, t2_scr);
else
t2_scr = GEM_BFINS(CMPBEN, 0, t2_scr);
- if (enable && ((tp4sp_m->psrc == 0xFFFF) || (tp4sp_m->pdst == 0xFFFF)))
+ if (enable && (tp4sp_m->psrc == cpu_to_be16(0xFFFF) ||
+ tp4sp_m->pdst == cpu_to_be16(0xFFFF)))
t2_scr = GEM_BFINS(CMPCEN, 1, t2_scr);
else
t2_scr = GEM_BFINS(CMPCEN, 0, t2_scr);
@@ -3480,7 +3481,7 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
tp4sp_m = &(fs->m_u.tcp_ip4_spec);
/* ignore field if any masking set */
- if (tp4sp_m->ip4src == 0xFFFFFFFF) {
+ if (tp4sp_m->ip4src == cpu_to_be32(0xFFFFFFFF)) {
/* 1st compare reg - IP source address */
w0 = 0;
w1 = 0;
@@ -3494,7 +3495,7 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
}
/* ignore field if any masking set */
- if (tp4sp_m->ip4dst == 0xFFFFFFFF) {
+ if (tp4sp_m->ip4dst == cpu_to_be32(0xFFFFFFFF)) {
/* 2nd compare reg - IP destination address */
w0 = 0;
w1 = 0;
@@ -3508,25 +3509,26 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)
}
/* ignore both port fields if masking set in both */
- if ((tp4sp_m->psrc == 0xFFFF) || (tp4sp_m->pdst == 0xFFFF)) {
+ if (tp4sp_m->psrc == cpu_to_be16(0xFFFF) ||
+ tp4sp_m->pdst == cpu_to_be16(0xFFFF)) {
/* 3rd compare reg - source port, destination port */
w0 = 0;
w1 = 0;
w1 = GEM_BFINS(T2CMPOFST, GEM_T2COMPOFST_IPHDR, w1);
if (tp4sp_m->psrc == tp4sp_m->pdst) {
- w0 = GEM_BFINS(T2MASK, tp4sp_v->psrc, w0);
- w0 = GEM_BFINS(T2CMP, tp4sp_v->pdst, w0);
+ w0 = GEM_BFINS(T2MASK, be16_to_cpu(tp4sp_v->psrc), w0);
+ w0 = GEM_BFINS(T2CMP, be16_to_cpu(tp4sp_v->pdst), w0);
w1 = GEM_BFINS(T2DISMSK, 1, w1); /* 32-bit compare */
w1 = GEM_BFINS(T2OFST, IPHDR_SRCPORT_OFFSET, w1);
} else {
/* only one port definition */
w1 = GEM_BFINS(T2DISMSK, 0, w1); /* 16-bit compare */
w0 = GEM_BFINS(T2MASK, 0xFFFF, w0);
- if (tp4sp_m->psrc == 0xFFFF) { /* src port */
- w0 = GEM_BFINS(T2CMP, tp4sp_v->psrc, w0);
+ if (tp4sp_m->psrc == cpu_to_be16(0xFFFF)) { /* src port */
+ w0 = GEM_BFINS(T2CMP, be16_to_cpu(tp4sp_v->psrc), w0);
w1 = GEM_BFINS(T2OFST, IPHDR_SRCPORT_OFFSET, w1);
} else { /* dst port */
- w0 = GEM_BFINS(T2CMP, tp4sp_v->pdst, w0);
+ w0 = GEM_BFINS(T2CMP, be16_to_cpu(tp4sp_v->pdst), w0);
w1 = GEM_BFINS(T2OFST, IPHDR_DSTPORT_OFFSET, w1);
}
}
--
2.34.1
next reply other threads:[~2023-05-19 22:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 22:19 Min-Hua Chen [this message]
2023-05-19 22:28 ` [PATCH] net: macb: use correct __be32 and __be16 types Jakub Kicinski
2023-05-20 2:00 ` Min-Hua Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230519221942.53942-1-minhuadotchen@gmail.com \
--to=minhuadotchen@gmail.com \
--cc=claudiu.beznea@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).