net: macb: sparse warning fixes
Subsystems (3)
These are 3 hopefully easy patches for fixing sparse errors due to endian-ness warnings. There are still some left, but there are not as easy as they mix host and network fields together.
For example, gem_prog_cmp_regs() has two u32 variables that it does bitfield manipulation on for the tcp ports and these are __be16 into u32, so not sure how these are meant to be changed. I've also no hardware to test on, so even if these did get changed then I can't check if it is working pre/post change.
Also gem_writel and gem_writel_n, it is not clear if both of these are meant to be host order or not.
Ben Dooks (3):
net: macb: check constant to define and fix __be32 warnings
net: macb: add port constant to fix __be16 warnings
net: macb: fix __be32 warnings in debug code
drivers/net/ethernet/cadence/macb_main.c | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/3 net: macb: check constant to define and fix __be32 warnings
The checks on ipv4 addresses in the filtering code check against a constant of 0xFFFFFFFF, so replace it with MACB_IPV4_MASK and then make sure it is of __be32 type to avoid the following sparse warnigns:
drivers/net/ethernet/cadence/macb_main.c:3448:39: warning: restricted __be32 degrades to integer drivers/net/ethernet/cadence/macb_main.c:3453:39: warning: restricted __be32 degrades to integer drivers/net/ethernet/cadence/macb_main.c:3483:20: warning: restricted __be32 degrades to integer drivers/net/ethernet/cadence/macb_main.c:3497:20: warning: restricted __be32 degrades to integer
--- drivers/net/ethernet/cadence/macb_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +6 -4
@@ -3418,6 +3418,8 @@ static int macb_get_ts_info(struct net_device *netdev,return ethtool_op_get_ts_info (netdev, info); } +#define MACB_IPV4_MASK htonl(0xFFFFFFFF) +static void gem_enable_flow_filters (struct macb *bp,bool enable) {struct net_device *netdev = bp->dev;
@@ -3445,12 +3447,12 @@ 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 ==MACB_IPV4_MASK )) 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 ==MACB_IPV4_MASK )) t2_scr =GEM_BFINS (CMPBEN ,1 , t2_scr);else t2_scr =GEM_BFINS (CMPBEN ,0 , t2_scr);
@@ -3480,7 +3482,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 ==MACB_IPV4_MASK ) {/* 1st compare reg - IP source address */ w0 =0 ; w1 =0 ;
@@ -3494,7 +3496,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 ==MACB_IPV4_MASK ) {/* 2nd compare reg - IP destination address */ w0 =0 ; w1 =0 ;
Signature · 1 line
2.40.1
Re: [PATCH 1/3] net: macb: check constant to define and fix __be32 warnings
Quoted 20 lines · Ben Dooks
The checks on ipv4 addresses in the filtering code check against a constant of
0xFFFFFFFF, so replace it withMACB_IPV4_MASKand then make sure it is of__be32type to avoid the following sparse warnigns:
drivers/net/ethernet/cadence/macb_main.c:3448:39: warning: restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3453:39: warning: restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3483:20: warning: restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3497:20: warning: restricted__be32degrades to integerSigned-off-by Ben Dooks <[email protected]>--- drivers/net/ethernet/cadence/macb_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/net/ethernet/cadence/macb_main.c +0
-0
drivers/net/ethernet/cadence/macb_main.c static int macb_get_ts_info(struct net_device *netdev, · line 3422
Quoted 5 lines
drivers/net/ethernet/cadence/macb_main.c +2
-0@@ -3418,6 +3418,8 @@ static int macb_get_ts_info(struct net_device *netdev,return ethtool_op_get_ts_info (netdev, info); } +#define MACB_IPV4_MASK htonl(0xFFFFFFFF) +
Hi Ben,
according to a recent thread, it seems that the preferred approach might be ~(__le32)0.
Re: [PATCH 1/3] net: macb: check constant to define and fix __be32 warnings
Quoted 30 lines · Simon Horman
Quoted 20 lines · Ben Dooks
The checks on ipv4 addresses in the filtering code check against a constant of
0xFFFFFFFF, so replace it withMACB_IPV4_MASKand then make sure it is of__be32type to avoid the following sparse warnigns:
drivers/net/ethernet/cadence/macb_main.c:3448:39: warning: restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3453:39: warning: restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3483:20: warning: restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3497:20: warning: restricted__be32degrades to integerSigned-off-by Ben Dooks <[email protected]>--- drivers/net/ethernet/cadence/macb_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/net/ethernet/cadence/macb_main.c +0
-0drivers/net/ethernet/cadence/macb_main.c static int macb_get_ts_info(struct net_device · line 3423
Quoted 6 lines
drivers/net/ethernet/cadence/macb_main.c +2
-0@@ -3418,6 +3418,8 @@ static int macb_get_ts_info(struct net_device *netdev, return ethtool_op_get_ts_info(netdev, info); } +#define MACB_IPV4_MASK htonl(0xFFFFFFFF) +Hi Ben,
Quoted 4 lines
according to a recent thread, it seems that the preferred approach might be ~(__le32)0.
Out of interest, should we keep the define then or simply go through changing all the places where change is needed?
Signature · 1 line
Ben
Re: [PATCH 1/3] net: macb: check constant to define and fix __be32 warnings
Quoted 42 lines · Ben Dooks
Quoted 39 lines · Simon Horman
Quoted 25 lines · Ben Dooks
The checks on ipv4 addresses in the filtering code check against a constant of
0xFFFFFFFF, so replace it withMACB_IPV4_MASKand then make sure it is of__be32type to avoid the following sparse warnigns:
drivers/net/ethernet/cadence/macb_main.c:3448:39: warning:
restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3453:39: warning:
restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3483:20: warning:
restricted__be32degrades to integerdrivers/net/ethernet/cadence/macb_main.c:3497:20: warning:
restricted__be32degrades to integerSigned-off-by Ben Dooks <[email protected]>--- drivers/net/ethernet/cadence/macb_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/net/ethernet/cadence/macb_main.c +0
-0drivers/net/ethernet/cadence/macb_main.c static int macb_get_ts_info(struct net_device · line 3423
Quoted 6 lines
drivers/net/ethernet/cadence/macb_main.c +2
-0@@ -3418,6 +3418,8 @@ static int macb_get_ts_info(struct net_device *netdev, return ethtool_op_get_ts_info(netdev, info); } +#define MACB_IPV4_MASK htonl(0xFFFFFFFF) +Hi Ben,
according to a recent thread, it seems that the preferred approach might be
~(__le32)0.
Quoted 5 lines
Quoted 1 line
Out of interest, should we keep the define then or simply go through changing
all the places where change is needed?
My personal opinion is that a #define is a nice way to go here.
PATCH 2/3 net: macb: add port constant to fix __be16 warnings
In reply to Ben DooksAdd a constant MACB_PORT_MASK to use instead of 0xffff when checking against ipv4 address port numbers. This allows the use of the __be16 constant and silences the following sparse warnings:
drivers/net/ethernet/cadence/macb_main.c:3458:40: warning: restricted __be16 degrades to integer drivers/net/ethernet/cadence/macb_main.c:3458:69: warning: restricted __be16 degrades to integer drivers/net/ethernet/cadence/macb_main.c:3511:21: warning: restricted __be16 degrades to integer drivers/net/ethernet/cadence/macb_main.c:3511:50: warning: restricted __be16 degrades to integer
--- drivers/net/ethernet/cadence/macb_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +4 -3
@@ -3419,6 +3419,7 @@ static int macb_get_ts_info(struct net_device *netdev, }#define MACB_IPV4_MASK htonl(0xFFFFFFFF) +#define MACB_PORT_MASK htons(0xFFFF)static void gem_enable_flow_filters (struct macb *bp,bool enable) {
@@ -3457,7 +3458,7 @@ static void gem_enable_flow_filters(struct macb *bp, bool enable)else t2_scr =GEM_BFINS (CMPBEN ,0 , t2_scr); -if (enable && ((tp4sp_m->psrc ==0xFFFF ) || (tp4sp_m->pdst ==0xFFFF ))) +if (enable && ((tp4sp_m->psrc ==MACB_PORT_MASK ) || (tp4sp_m->pdst ==MACB_PORT_MASK ))) t2_scr =GEM_BFINS (CMPCEN ,1 , t2_scr);else t2_scr =GEM_BFINS (CMPCEN ,0 , t2_scr);
@@ -3510,7 +3511,7 @@ 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 ==MACB_PORT_MASK ) || (tp4sp_m->pdst ==MACB_PORT_MASK )) {/* 3rd compare reg - source port, destination port */ w0 =0 ; w1 =0 ;
@@ -3524,7 +3525,7 @@ static void gem_prog_cmp_regs(struct macb *bp, struct ethtool_rx_flow_spec *fs)/* 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 */ +if (tp4sp_m->psrc ==MACB_PORT_MASK ) {/* src port */ w0 =GEM_BFINS (T2CMP , tp4sp_v->psrc, w0); w1 =GEM_BFINS (T2OFST ,IPHDR_SRCPORT_OFFSET , w1); }else {/* dst port */
Signature · 1 line
2.40.1
PATCH 3/3 net: macb: fix __be32 warnings in debug code
In reply to Ben DooksThe netdev_dbg() calls in gem_add_flow_filter() and gem_del_flow_filter() call ntohl() on the ipv4 addresses, which will put them into the host order but not the right type (returns a __be32, not an u32 as would be expected).
Chaning the htonl() to nthol() should still do the right conversion, return the correct u32 type and should not change any functional to remove the following sparse warnings:
drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted __be32 [usertype] ip4srcdrivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted __be32 [usertype] ip4dstdrivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted __be32
ddrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted __be32 [usertype] ip4srcdrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted __be32 [usertype] ip4dstdrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32 drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted __be32
--- drivers/net/ethernet/cadence/macb_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +4 -4
@@ -3568,8 +3568,8 @@ static int gem_add_flow_filter(struct net_device *netdev,netdev_dbg (netdev,"Adding flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n" , fs->flow_type, (int )fs->ring_cookie, fs->location, -htonl (fs->h_u.tcp_ip4_spec.ip4src), -htonl (fs->h_u.tcp_ip4_spec.ip4dst), +ntohl (fs->h_u.tcp_ip4_spec.ip4src), +ntohl (fs->h_u.tcp_ip4_spec.ip4dst),be16_to_cpu (fs->h_u.tcp_ip4_spec.psrc),be16_to_cpu (fs->h_u.tcp_ip4_spec.pdst));
@@ -3622,8 +3622,8 @@ static int gem_del_flow_filter(struct net_device *netdev,netdev_dbg (netdev,"Deleting flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n" , fs->flow_type, (int )fs->ring_cookie, fs->location, -htonl (fs->h_u.tcp_ip4_spec.ip4src), -htonl (fs->h_u.tcp_ip4_spec.ip4dst), +ntohl (fs->h_u.tcp_ip4_spec.ip4src), +ntohl (fs->h_u.tcp_ip4_spec.ip4dst),be16_to_cpu (fs->h_u.tcp_ip4_spec.psrc),be16_to_cpu (fs->h_u.tcp_ip4_spec.pdst));
Signature · 1 line
2.40.1
Re: [PATCH 3/3] net: macb: fix __be32 warnings in debug code
Quoted 38 lines · Ben Dooks
The
netdev_dbg()calls ingem_add_flow_filter()andgem_del_flow_filter()callntohl()on the ipv4 addresses, which will put them into the host order but not the right type (returns a__be32, not an u32 as would be expected).Chaning the
htonl()tonthol()should still do the right conversion, return the correct u32 type and should not change any functional to remove the following sparse warnings:
drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted__be32[usertype] ip4srcdrivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted__be32[usertype] ip4dstdrivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32
ddrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted__be32[usertype] ip4srcdrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted__be32[usertype] ip4dstdrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32
Quoted 1 line
Signed-off-by Ben Dooks <[email protected]>
Hi Ben,
this code-change looks good to me, but I have a few minor nits for your consideration.
1. Please specify the target tree, in this case net-next, for patch sets for Networking code.
Subject: [PATCH net-next ...] ...
2. It might be nicer to write '.../macb_main.c' or similar, rather tha nthe full path, in the patch description.
3. checkpatch --codespell says: 'Chaning' -> 'Chaining'
Quoted 34 lines
--- drivers/net/ethernet/cadence/macb_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/cadence/macb_main.c +4
-4@@ -3568,8 +3568,8 @@ static int gem_add_flow_filter(struct net_device *netdev,netdev_dbg (netdev,"Adding flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n" , fs->flow_type, (int )fs->ring_cookie, fs->location, -htonl (fs->h_u.tcp_ip4_spec.ip4src), -htonl (fs->h_u.tcp_ip4_spec.ip4dst), +ntohl (fs->h_u.tcp_ip4_spec.ip4src), +ntohl (fs->h_u.tcp_ip4_spec.ip4dst),be16_to_cpu (fs->h_u.tcp_ip4_spec.psrc),be16_to_cpu (fs->h_u.tcp_ip4_spec.pdst));@@ -3622,8 +3622,8 @@ static int gem_del_flow_filter(struct net_device *netdev,netdev_dbg (netdev,"Deleting flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n" , fs->flow_type, (int )fs->ring_cookie, fs->location, -htonl (fs->h_u.tcp_ip4_spec.ip4src), -htonl (fs->h_u.tcp_ip4_spec.ip4dst), +ntohl (fs->h_u.tcp_ip4_spec.ip4src), +ntohl (fs->h_u.tcp_ip4_spec.ip4dst),be16_to_cpu (fs->h_u.tcp_ip4_spec.psrc),be16_to_cpu (fs->h_u.tcp_ip4_spec.pdst));Signature · 1 line
2.40.1
Re: [PATCH 3/3] net: macb: fix __be32 warnings in debug code
Quoted 43 lines · Simon Horman
Quoted 38 lines · Ben Dooks
The
netdev_dbg()calls ingem_add_flow_filter()andgem_del_flow_filter()callntohl()on the ipv4 addresses, which will put them into the host order but not the right type (returns a__be32, not an u32 as would be expected).Chaning the
htonl()tonthol()should still do the right conversion, return the correct u32 type and should not change any functional to remove the following sparse warnings:
drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted__be32[usertype] ip4srcdrivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3568:9: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3568:9: got restricted__be32[usertype] ip4dstdrivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3568:9: warning: cast from restricted__be32
ddrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted__be32[usertype] ip4srcdrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: incorrect type in argument 1 (different base types)drivers/net/ethernet/cadence/macb_main.c:3622:25: expected unsigned int [usertype] valdrivers/net/ethernet/cadence/macb_main.c:3622:25: got restricted__be32[usertype] ip4dstdrivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32drivers/net/ethernet/cadence/macb_main.c:3622:25: warning: cast from restricted__be32Quoted 1 line
Signed-off-by Ben Dooks <[email protected]>Hi Ben,
Quoted 7 lines
this code-change looks good to me, but I have a few minor nits for your consideration.
1. Please specify the target tree, in this case net-next, for patch sets for Networking code.
Subject: [PATCH net-next ...] ...
Ah, was using net, but I assume net-next is probably ok
Quoted 4 lines
2. It might be nicer to write '
.../macb_main.c' or similar, rather tha nthe full path, in the patch description.3. checkpatch --codespell says: 'Chaning' -> 'Chaining'
Ok, thank you. I didn't know about that.
Since there's another patch that needs work I'll re-send this early next week with the fixes in.
Quoted 38 lines
Quoted 38 lines
--- drivers/net/ethernet/cadence/macb_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/cadence/macb_main.c +2
-2@@ -3568,8 +3568,8 @@ static int gem_add_flow_filter(struct net_device *netdev, netdev_dbg(netdev, "Adding flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n", fs->flow_type, (int)fs->ring_cookie, fs->location, - htonl(fs->h_u.tcp_ip4_spec.ip4src), - htonl(fs->h_u.tcp_ip4_spec.ip4dst), + ntohl(fs->h_u.tcp_ip4_spec.ip4src), + ntohl(fs->h_u.tcp_ip4_spec.ip4dst), be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),drivers/net/ethernet/cadence/macb_main.c +2
-2be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));@@ -3622,8 +3622,8 @@ static int gem_del_flow_filter(struct net_device *netdev, netdev_dbg(netdev, "Deleting flow filter entry,type=%u,queue=%u,loc=%u,src=%08X,dst=%08X,ps=%u,pd=%u\n", fs->flow_type, (int)fs->ring_cookie, fs->location, - htonl(fs->h_u.tcp_ip4_spec.ip4src), - htonl(fs->h_u.tcp_ip4_spec.ip4dst), + ntohl(fs->h_u.tcp_ip4_spec.ip4src), + ntohl(fs->h_u.tcp_ip4_spec.ip4dst), be16_to_cpu(fs->h_u.tcp_ip4_spec.psrc),
be16_to_cpu(fs->h_u.tcp_ip4_spec.pdst));--
2.40.1
Re: [PATCH 3/3] net: macb: fix __be32 warnings in debug code
Quoted 4 lines · Ben Dooks
Quoted 1 line · Simon Horman
On Thu, Jun 22, 2023 at 02:05:07PM +0100, Ben Dooks wrote:
...
Quoted 11 lines
Quoted 9 lines
Hi Ben,
this code-change looks good to me, but I have a few minor nits for your consideration.
1. Please specify the target tree, in this case net-next, for patch sets for Networking code.
Subject: [PATCH net-next ...] ...Ah, was using net, but I assume net-next is probably ok
I think net-next is best for this kind of change.
FWIIW, this series did apply there.
Quoted 6 lines
Quoted 4 lines
2. It might be nicer to write '
.../macb_main.c' or similar, rather tha nthe full path, in the patch description.3. checkpatch --codespell says: 'Chaning' -> 'Chaining'
Ok, thank you. I didn't know about that.
It is quite handy :)
Quoted 3 lines
Since there's another patch that needs work I'll re-send this early next week
with the fixes in.
I think a repost of the series is a good plan.
Please note that when v6.4 is released, which may well be over the weekend, then net-next will be closed until after rc1 is released - approximately two weeks. If it is closed then you'll need to wait until it reopens before posting v2.
Hi Ben,
Quoted 9 lines · Ben Dooks
These are 3 hopefully easy patches for fixing sparse errors due to endian-ness warnings. There are still some left, but there are not as easy as they mix host and network fields together.
For example,
gem_prog_cmp_regs()has two u32 variables that it does bitfield manipulation on for the tcp ports and these are__be16into u32, so not sure how these are meant to be changed. I've also no hardware to test on, so even if these did get changed then I can't check if it is working pre/post change.
Do you know if there could be any impact on performance (even if limited)?
Best regards,
Nicolas
Quoted 10 lines
Also
gem_writelandgem_writel_n, it is not clear if both of these are meant to be host order or not.Ben Dooks (3):
net: macb: check constant to define and fix__be32warnings
net: macb: add port constant to fix__be16warnings
net: macb: fix__be32warnings in debug codedrivers/net/ethernet/cadence/macb_main.c | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
Signature · 1 line
Nicolas Ferre
Quoted 7 lines · Nicolas Ferre
Hi Ben,
Quoted 4 lines · Ben Dooks
These are 3 hopefully easy patches for fixing sparse errors due to endian-ness warnings. There are still some left, but there are not as easy as they mix host and network fields together.
Quoted 7 lines
Quoted 5 lines
For example,
gem_prog_cmp_regs()has two u32 variables that it does bitfield manipulation on for the tcp ports and these are__be16into u32, so not sure how these are meant to be changed. I've also no hardware to test on, so even if these did get changed then I can't check if it is working pre/post change.Do you know if there could be any impact on performance (even if limited)?
Hi Nicolas
This is inside a netdev_dbg(). So 99% of the time it is compiled out. The other 1% of the time, your 115200 baud serial port is probably the bottleneck, not an endianness swap.
Andrew
Quoted 16 lines · Andrew Lunn
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 13 lines · Nicolas Ferre
Hi Ben,
Quoted 9 lines · Ben Dooks
These are 3 hopefully easy patches for fixing sparse errors due to endian-ness warnings. There are still some left, but there are not as easy as they mix host and network fields together.
For example,
gem_prog_cmp_regs()has two u32 variables that it does bitfield manipulation on for the tcp ports and these are__be16into u32, so not sure how these are meant to be changed. I've also no hardware to test on, so even if these did get changed then I can't check if it is working pre/post change.
Quoted 7 lines
Quoted 1 line
Do you know if there could be any impact on performance (even if limited)?
Hi Nicolas
This is inside a
netdev_dbg(). So 99% of the time it is compiled out. The other 1% of the time, your 115200 baud serial port is probably the bottleneck, not an endianness swap.
Yeah, sure thing: I was not talking about the 3/3 patch where, yes, indeed it doesn't have an importance.
Others in gem_enable_flow_filters() and gem_prog_cmp_regs() look like they are away from hot path anyway, so here again probably no impact.
Regards,
Nicolas
Signature · 1 line
Nicolas Ferre
Quoted 7 lines · Nicolas Ferre
Hi Ben,
Quoted 4 lines · Ben Dooks
These are 3 hopefully easy patches for fixing sparse errors due to endian-ness warnings. There are still some left, but there are not as easy as they mix host and network fields together.
Quoted 7 lines
Quoted 5 lines
For example,
gem_prog_cmp_regs()has two u32 variables that it does bitfield manipulation on for the tcp ports and these are__be16into u32, so not sure how these are meant to be changed. I've also no hardware to test on, so even if these did get changed then I can't check if it is working pre/post change.Do you know if there could be any impact on performance (even if limited)?
There shouldn't be, these are either constants so should be compile time sorted or they are just using the swap code the wrong way round... same values, just the wrong endian markers going in/out.
The only device with a macb I've got is an unmatched, so don't even know if I can test any of this.
The filter code I would like to get some feedback on, as I didn't want to do any modifications without being able to test.
Quoted 14 lines
Best regards,
NicolasQuoted 10 lines
Also
gem_writelandgem_writel_n, it is not clear if both of these are meant to be host order or not.Ben Dooks (3):
net: macb: check constant to define and fix__be32warnings
net: macb: add port constant to fix__be16warnings
net: macb: fix__be32warnings in debug code
drivers/net/ethernet/cadence/macb_main.c| 25 +++++++++++++-----------1 file changed, 14 insertions(+), 11 deletions(-)
Signature · 4 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html