DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address
@ 2022-01-05 10:32 Maxime Gouin
  2022-01-05 10:32 ` [PATCH 2/2] net/nfp: remove useless range checks Maxime Gouin
  2022-01-11 14:46 ` [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Kevin Traynor
  0 siblings, 2 replies; 5+ messages in thread
From: Maxime Gouin @ 2022-01-05 10:32 UTC (permalink / raw)
  To: dev; +Cc: Maxime Gouin, Heinrich Kuhn, Alejandro Lucero, Olivier Matz

reported by code analysis tool C++test (version 10.4):

> /build/dpdk-20.11/drivers/net/nfp/nfp_net.c
> 546   Conditions "(hw->ctrl &NFP_NET_CFG_CTRL_ENABLE) &&
        !! (hw->cap &NFP_NET_CFG_C" is always evaluated to false
> 547   Condition "! (hw->cap &NFP_NET_CFG_C" is always evaluated to false

The previous "if" checks exactly the same condition. Removal of duplicate
code.

Fixes: 2fe669f4bcd2 ("net/nfp: support MAC address change")

Signed-off-by: Maxime Gouin <maxime.gouin@6wind.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/nfp/nfp_common.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index f8978e803a0f..b26770dbfbe4 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -280,10 +280,6 @@ nfp_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
 		return -EBUSY;
 	}
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) &&
-	    !(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR))
-		return -EBUSY;
-
 	/* Writing new MAC to the specific port BAR address */
 	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
-- 
2.30.2


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

* [PATCH 2/2] net/nfp: remove useless range checks
  2022-01-05 10:32 [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Maxime Gouin
@ 2022-01-05 10:32 ` Maxime Gouin
  2022-01-11 14:54   ` Kevin Traynor
  2022-01-11 14:46 ` [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Kevin Traynor
  1 sibling, 1 reply; 5+ messages in thread
From: Maxime Gouin @ 2022-01-05 10:32 UTC (permalink / raw)
  To: dev; +Cc: Maxime Gouin, Heinrich Kuhn, Alejandro Lucero, Olivier Matz

reported by code analysis tool C++test (version 10.4):

> /build/dpdk-20.11/drivers/net/nfp/nfpcore/nfp_target.h
> 375   Condition "island < 1" is always evaluated to false
> 415   Condition "island < 1" is always evaluated to false
> 547   Condition "target < 0" is always evaluated to false

All of these conditions have the same error. They call
NFP_CPP_ID_ISLAND_of or NFP_CPP_ID_TARGET_of which return a uint8_t and
put the result in "island" or "target" which are integers. These variables
can only contain values between 0 and 255.

Fixes: c7e9729da6b5 ("net/nfp: support CPP")

Signed-off-by: Maxime Gouin <maxime.gouin@6wind.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/nfp/nfpcore/nfp_target.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h
index 2884a0034f44..e8dcc9ad1eda 100644
--- a/drivers/net/nfp/nfpcore/nfp_target.h
+++ b/drivers/net/nfp/nfpcore/nfp_target.h
@@ -37,7 +37,7 @@ pushpull_width(int pp)
 static inline int
 target_rw(uint32_t cpp_id, int pp, int start, int len)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
 	if (island && (island < start || island > (start + len)))
 		return NFP_ERRNO(EINVAL);
@@ -117,7 +117,7 @@ nfp6000_nbi_ppc(uint32_t cpp_id)
 static inline int
 nfp6000_nbi(uint32_t cpp_id, uint64_t address)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 	uint64_t rel_addr = address & 0x3fFFFF;
 
 	if (island && (island < 8 || island > 9))
@@ -281,7 +281,7 @@ static inline int
 nfp6000_mu(uint32_t cpp_id, uint64_t address)
 {
 	int pp;
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
 	if (island == 0) {
 		if (address < 0x2000000000ULL)
@@ -316,7 +316,7 @@ nfp6000_mu(uint32_t cpp_id, uint64_t address)
 static inline int
 nfp6000_ila(uint32_t cpp_id)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
 	if (island && (island < 48 || island > 51))
 		return NFP_ERRNO(EINVAL);
@@ -336,7 +336,7 @@ nfp6000_ila(uint32_t cpp_id)
 static inline int
 nfp6000_pci(uint32_t cpp_id)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
 	if (island && (island < 4 || island > 7))
 		return NFP_ERRNO(EINVAL);
@@ -354,7 +354,7 @@ nfp6000_pci(uint32_t cpp_id)
 static inline int
 nfp6000_crypto(uint32_t cpp_id)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
 	if (island && (island < 12 || island > 15))
 		return NFP_ERRNO(EINVAL);
@@ -370,9 +370,9 @@ nfp6000_crypto(uint32_t cpp_id)
 static inline int
 nfp6000_cap_xpb(uint32_t cpp_id)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
-	if (island && (island < 1 || island > 63))
+	if (island > 63)
 		return NFP_ERRNO(EINVAL);
 
 	switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) {
@@ -410,9 +410,9 @@ nfp6000_cap_xpb(uint32_t cpp_id)
 static inline int
 nfp6000_cls(uint32_t cpp_id)
 {
-	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
 
-	if (island && (island < 1 || island > 63))
+	if (island > 63)
 		return NFP_ERRNO(EINVAL);
 
 	switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) {
@@ -540,11 +540,11 @@ nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address,
 	       const uint32_t *imb_table)
 {
 	int err;
-	int island = NFP_CPP_ID_ISLAND_of(cpp_island_id);
-	int target = NFP_CPP_ID_TARGET_of(cpp_island_id);
+	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_island_id);
+	uint8_t target = NFP_CPP_ID_TARGET_of(cpp_island_id);
 	uint32_t imb;
 
-	if (target < 0 || target >= 16)
+	if (target >= 16)
 		return NFP_ERRNO(EINVAL);
 
 	if (island == 0) {
-- 
2.30.2


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

* Re: [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address
  2022-01-05 10:32 [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Maxime Gouin
  2022-01-05 10:32 ` [PATCH 2/2] net/nfp: remove useless range checks Maxime Gouin
@ 2022-01-11 14:46 ` Kevin Traynor
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Traynor @ 2022-01-11 14:46 UTC (permalink / raw)
  To: Maxime Gouin, dev; +Cc: Heinrich Kuhn, Alejandro Lucero, Olivier Matz

On 05/01/2022 10:32, Maxime Gouin wrote:
> reported by code analysis tool C++test (version 10.4):
> 
>> /build/dpdk-20.11/drivers/net/nfp/nfp_net.c
>> 546   Conditions "(hw->ctrl &NFP_NET_CFG_CTRL_ENABLE) &&
>          !! (hw->cap &NFP_NET_CFG_C" is always evaluated to false
>> 547   Condition "! (hw->cap &NFP_NET_CFG_C" is always evaluated to false
> 
> The previous "if" checks exactly the same condition. Removal of duplicate
> code.
> 
> Fixes: 2fe669f4bcd2 ("net/nfp: support MAC address change")
> 

Cc: stable@dpdk.org

> Signed-off-by: Maxime Gouin <maxime.gouin@6wind.com>
> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>

Acked-by: Kevin Traynor <ktraynor@redhat.com>

> ---
>   drivers/net/nfp/nfp_common.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
> index f8978e803a0f..b26770dbfbe4 100644
> --- a/drivers/net/nfp/nfp_common.c
> +++ b/drivers/net/nfp/nfp_common.c
> @@ -280,10 +280,6 @@ nfp_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
>   		return -EBUSY;
>   	}
>   
> -	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) &&
> -	    !(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR))
> -		return -EBUSY;
> -
>   	/* Writing new MAC to the specific port BAR address */
>   	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
>   
> 


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

* Re: [PATCH 2/2] net/nfp: remove useless range checks
  2022-01-05 10:32 ` [PATCH 2/2] net/nfp: remove useless range checks Maxime Gouin
@ 2022-01-11 14:54   ` Kevin Traynor
  2022-01-21 14:39     ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Traynor @ 2022-01-11 14:54 UTC (permalink / raw)
  To: Maxime Gouin, dev; +Cc: Heinrich Kuhn, Alejandro Lucero, Olivier Matz

On 05/01/2022 10:32, Maxime Gouin wrote:
> reported by code analysis tool C++test (version 10.4):
> 
>> /build/dpdk-20.11/drivers/net/nfp/nfpcore/nfp_target.h
>> 375   Condition "island < 1" is always evaluated to false
>> 415   Condition "island < 1" is always evaluated to false
>> 547   Condition "target < 0" is always evaluated to false
> 
> All of these conditions have the same error. They call
> NFP_CPP_ID_ISLAND_of or NFP_CPP_ID_TARGET_of which return a uint8_t and
> put the result in "island" or "target" which are integers. These variables
> can only contain values between 0 and 255.
> 
> Fixes: c7e9729da6b5 ("net/nfp: support CPP")
> 

Cc: stable@dpdk.org

> Signed-off-by: Maxime Gouin <maxime.gouin@6wind.com>
> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
> ---

Acked-by: Kevin Traynor <ktraynor@redhat.com>

>   drivers/net/nfp/nfpcore/nfp_target.h | 26 +++++++++++++-------------
>   1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h
> index 2884a0034f44..e8dcc9ad1eda 100644
> --- a/drivers/net/nfp/nfpcore/nfp_target.h
> +++ b/drivers/net/nfp/nfpcore/nfp_target.h
> @@ -37,7 +37,7 @@ pushpull_width(int pp)
>   static inline int
>   target_rw(uint32_t cpp_id, int pp, int start, int len)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
>   	if (island && (island < start || island > (start + len)))
>   		return NFP_ERRNO(EINVAL);
> @@ -117,7 +117,7 @@ nfp6000_nbi_ppc(uint32_t cpp_id)
>   static inline int
>   nfp6000_nbi(uint32_t cpp_id, uint64_t address)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   	uint64_t rel_addr = address & 0x3fFFFF;
>   
>   	if (island && (island < 8 || island > 9))
> @@ -281,7 +281,7 @@ static inline int
>   nfp6000_mu(uint32_t cpp_id, uint64_t address)
>   {
>   	int pp;
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
>   	if (island == 0) {
>   		if (address < 0x2000000000ULL)
> @@ -316,7 +316,7 @@ nfp6000_mu(uint32_t cpp_id, uint64_t address)
>   static inline int
>   nfp6000_ila(uint32_t cpp_id)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
>   	if (island && (island < 48 || island > 51))
>   		return NFP_ERRNO(EINVAL);
> @@ -336,7 +336,7 @@ nfp6000_ila(uint32_t cpp_id)
>   static inline int
>   nfp6000_pci(uint32_t cpp_id)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
>   	if (island && (island < 4 || island > 7))
>   		return NFP_ERRNO(EINVAL);
> @@ -354,7 +354,7 @@ nfp6000_pci(uint32_t cpp_id)
>   static inline int
>   nfp6000_crypto(uint32_t cpp_id)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
>   	if (island && (island < 12 || island > 15))
>   		return NFP_ERRNO(EINVAL);
> @@ -370,9 +370,9 @@ nfp6000_crypto(uint32_t cpp_id)
>   static inline int
>   nfp6000_cap_xpb(uint32_t cpp_id)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
> -	if (island && (island < 1 || island > 63))
> +	if (island > 63)
>   		return NFP_ERRNO(EINVAL);
>   
>   	switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) {
> @@ -410,9 +410,9 @@ nfp6000_cap_xpb(uint32_t cpp_id)
>   static inline int
>   nfp6000_cls(uint32_t cpp_id)
>   {
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id);
>   
> -	if (island && (island < 1 || island > 63))
> +	if (island > 63)
>   		return NFP_ERRNO(EINVAL);
>   
>   	switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) {
> @@ -540,11 +540,11 @@ nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address,
>   	       const uint32_t *imb_table)
>   {
>   	int err;
> -	int island = NFP_CPP_ID_ISLAND_of(cpp_island_id);
> -	int target = NFP_CPP_ID_TARGET_of(cpp_island_id);
> +	uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_island_id);
> +	uint8_t target = NFP_CPP_ID_TARGET_of(cpp_island_id);
>   	uint32_t imb;
>   
> -	if (target < 0 || target >= 16)
> +	if (target >= 16)
>   		return NFP_ERRNO(EINVAL);
>   
>   	if (island == 0) {
> 


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

* Re: [PATCH 2/2] net/nfp: remove useless range checks
  2022-01-11 14:54   ` Kevin Traynor
@ 2022-01-21 14:39     ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2022-01-21 14:39 UTC (permalink / raw)
  To: Kevin Traynor, Maxime Gouin, dev
  Cc: Heinrich Kuhn, Alejandro Lucero, Olivier Matz

On 1/11/2022 2:54 PM, Kevin Traynor wrote:
> On 05/01/2022 10:32, Maxime Gouin wrote:
>> reported by code analysis tool C++test (version 10.4):
>>

Hi Maxime,

Can you please give some information on this tool?

Thanks,
ferruh

>>> /build/dpdk-20.11/drivers/net/nfp/nfpcore/nfp_target.h
>>> 375   Condition "island < 1" is always evaluated to false
>>> 415   Condition "island < 1" is always evaluated to false
>>> 547   Condition "target < 0" is always evaluated to false
>>
>> All of these conditions have the same error. They call
>> NFP_CPP_ID_ISLAND_of or NFP_CPP_ID_TARGET_of which return a uint8_t and
>> put the result in "island" or "target" which are integers. These variables
>> can only contain values between 0 and 255.
>>
>> Fixes: c7e9729da6b5 ("net/nfp: support CPP")
>>
> 
> Cc: stable@dpdk.org
> 
>> Signed-off-by: Maxime Gouin <maxime.gouin@6wind.com>
>> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
>> ---
> 
> Acked-by: Kevin Traynor <ktraynor@redhat.com>
> 

For series,
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Series applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2022-01-21 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 10:32 [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Maxime Gouin
2022-01-05 10:32 ` [PATCH 2/2] net/nfp: remove useless range checks Maxime Gouin
2022-01-11 14:54   ` Kevin Traynor
2022-01-21 14:39     ` Ferruh Yigit
2022-01-11 14:46 ` [PATCH 1/2] net/nfp: remove duplicated check when setting MAC address Kevin Traynor

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).