kni: fix compile error

Message ID 20220521070642.35413-1-humin29@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series kni: fix compile error |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

humin (Q) May 21, 2022, 7:06 a.m. UTC
When kernel version change into 5.18 from 5.17, 'netif_rx_ni' is discard.
It is replaced by 'netif_rx' and this API is also supported in the
version below 5.18.

This patch fixed it.

Fixes: d89a58dfe90b ("kni: support chained mbufs")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 kernel/linux/kni/kni_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit May 23, 2022, 8:43 a.m. UTC | #1
On 5/21/2022 8:06 AM, Min Hu (Connor) wrote:
> [CAUTION: External Email]
> 
> When kernel version change into 5.18 from 5.17, 'netif_rx_ni' is discard.
> It is replaced by 'netif_rx' and this API is also supported in the
> version below 5.18.
> 
> This patch fixed it.
> 
> Fixes: d89a58dfe90b ("kni: support chained mbufs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>   kernel/linux/kni/kni_net.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index 29e5b9e21f..e19f03285e 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>                  skb->ip_summed = CHECKSUM_UNNECESSARY;
> 
>                  /* Call netif interface */
> -               netif_rx_ni(skb);
> +               netif_rx(skb);
> 

Hi Connor,

There is already a patch for this [1], can you test & ack that instead 
please?

Same for Mingli's patch [2], @Mingli, can you please test and ack the 
[1] instead?

[1] kni: update kernel API to receive packets
https://patches.dpdk.org/project/dpdk/patch/20220421085931.2429443-1-g.singh@nxp.com/
http://inbox.dpdk.org/dev/20220421085931.2429443-1-g.singh@nxp.com/


[2]
https://patches.dpdk.org/project/dpdk/patch/20220511112334.3233433-1-mingli.yu@windriver.com/

>                  /* Update statistics */
>                  dev->stats.rx_bytes += len;
> @@ -779,7 +779,7 @@ kni_net_set_mac(struct net_device *netdev, void *p)
>                  return -EADDRNOTAVAIL;
> 
>          memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
> -       memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
> +       memcpy((void *)(netdev->dev_addr), addr->sa_data, netdev->addr_len);

Why don't you use new helper functions instead? I can see not using 
helper function is causing other problem as well [3].

[3]
https://patches.dpdk.org/project/dpdk/patch/20220407082544.21282-1-humin29@huawei.com/

> 
>          ret = kni_net_process_request(netdev, &req);
> 
> --
> 2.33.0
>
  
Andrew Rybchenko May 31, 2022, 4:42 p.m. UTC | #2
On 5/21/22 10:06, Min Hu (Connor) wrote:
> When kernel version change into 5.18 from 5.17, 'netif_rx_ni' is discard.
> It is replaced by 'netif_rx' and this API is also supported in the
> version below 5.18.
> 
> This patch fixed it.
> 
> Fixes: d89a58dfe90b ("kni: support chained mbufs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>   kernel/linux/kni/kni_net.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
> index 29e5b9e21f..e19f03285e 100644
> --- a/kernel/linux/kni/kni_net.c
> +++ b/kernel/linux/kni/kni_net.c
> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>   		skb->ip_summed = CHECKSUM_UNNECESSARY;
>   
>   		/* Call netif interface */
> -		netif_rx_ni(skb);
> +		netif_rx(skb);

I think the approach in [1] is the right one. Any comments?

[1] 
https://patches.dpdk.org/project/dpdk/patch/20220525102641.20982-1-jslaby@suse.cz/

>   
>   		/* Update statistics */
>   		dev->stats.rx_bytes += len;
> @@ -779,7 +779,7 @@ kni_net_set_mac(struct net_device *netdev, void *p)
>   		return -EADDRNOTAVAIL;
>   
>   	memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
> -	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
> +	memcpy((void *)(netdev->dev_addr), addr->sa_data, netdev->addr_len);

I don't understand why the change is needed and the patch description
does not shed any light on it.

>   
>   	ret = kni_net_process_request(netdev, &req);
>
  
humin (Q) June 1, 2022, 1:52 a.m. UTC | #3
Hi, Andrew ,

在 2022/6/1 0:42, Andrew Rybchenko 写道:
> On 5/21/22 10:06, Min Hu (Connor) wrote:
>> When kernel version change into 5.18 from 5.17, 'netif_rx_ni' is discard.
>> It is replaced by 'netif_rx' and this API is also supported in the
>> version below 5.18.
>>
>> This patch fixed it.
>>
>> Fixes: d89a58dfe90b ("kni: support chained mbufs")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   kernel/linux/kni/kni_net.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
>> index 29e5b9e21f..e19f03285e 100644
>> --- a/kernel/linux/kni/kni_net.c
>> +++ b/kernel/linux/kni/kni_net.c
>> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>>           skb->ip_summed = CHECKSUM_UNNECESSARY;
>>           /* Call netif interface */
>> -        netif_rx_ni(skb);
>> +        netif_rx(skb);
> 
> I think the approach in [1] is the right one. Any comments?
> 
> [1] 
> https://patches.dpdk.org/project/dpdk/patch/20220525102641.20982-1-jslaby@suse.cz/ 
> 
> 
>>           /* Update statistics */
>>           dev->stats.rx_bytes += len;
>> @@ -779,7 +779,7 @@ kni_net_set_mac(struct net_device *netdev, void *p)
>>           return -EADDRNOTAVAIL;
>>       memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
>> -    memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
>> +    memcpy((void *)(netdev->dev_addr), addr->sa_data, netdev->addr_len);
When compile, it will report a warning, because it claims that the
parameter types must be the same.
void *memcpy(void *destin, void *source, unsigned n);

so this is what I am doing.


> 
> I don't understand why the change is needed and the patch description
> does not shed any light on it.
> 
>>       ret = kni_net_process_request(netdev, &req);
> 
> .
  
Andrew Rybchenko June 1, 2022, 8:47 a.m. UTC | #4
On 6/1/22 04:52, Min Hu (Connor) wrote:
> Hi, Andrew ,
> 
> 在 2022/6/1 0:42, Andrew Rybchenko 写道:
>> On 5/21/22 10:06, Min Hu (Connor) wrote:
>>> When kernel version change into 5.18 from 5.17, 'netif_rx_ni' is 
>>> discard.
>>> It is replaced by 'netif_rx' and this API is also supported in the
>>> version below 5.18.
>>>
>>> This patch fixed it.
>>>
>>> Fixes: d89a58dfe90b ("kni: support chained mbufs")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>> ---
>>>   kernel/linux/kni/kni_net.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
>>> index 29e5b9e21f..e19f03285e 100644
>>> --- a/kernel/linux/kni/kni_net.c
>>> +++ b/kernel/linux/kni/kni_net.c
>>> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>>>           skb->ip_summed = CHECKSUM_UNNECESSARY;
>>>           /* Call netif interface */
>>> -        netif_rx_ni(skb);
>>> +        netif_rx(skb);
>>
>> I think the approach in [1] is the right one. Any comments?
>>
>> [1] 
>> https://patches.dpdk.org/project/dpdk/patch/20220525102641.20982-1-jslaby@suse.cz/ 
>>
>>
>>>           /* Update statistics */
>>>           dev->stats.rx_bytes += len;
>>> @@ -779,7 +779,7 @@ kni_net_set_mac(struct net_device *netdev, void *p)
>>>           return -EADDRNOTAVAIL;
>>>       memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
>>> -    memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
>>> +    memcpy((void *)(netdev->dev_addr), addr->sa_data, 
>>> netdev->addr_len);
> When compile, it will report a warning, because it claims that the
> parameter types must be the same.
> void *memcpy(void *destin, void *source, unsigned n);
> 
> so this is what I am doing.

I think it is a separate story vs netif_rx_ni(). So, it should not be in
the same patch. IMHO, it is closer to [1]

[1] 
https://patches.dpdk.org/project/dpdk/patch/20220601015925.35304-1-humin29@huawei.com/

Am I missing something?

>>
>> I don't understand why the change is needed and the patch description
>> does not shed any light on it.
>>
>>>       ret = kni_net_process_request(netdev, &req);
>>
>> .
  
Ferruh Yigit June 1, 2022, 3:49 p.m. UTC | #5
On 6/1/2022 9:47 AM, Andrew Rybchenko wrote:
> On 6/1/22 04:52, Min Hu (Connor) wrote:
>> Hi, Andrew ,
>>
>> 在 2022/6/1 0:42, Andrew Rybchenko 写道:
>>> On 5/21/22 10:06, Min Hu (Connor) wrote:
>>>> When kernel version change into 5.18 from 5.17, 'netif_rx_ni' is 
>>>> discard.
>>>> It is replaced by 'netif_rx' and this API is also supported in the
>>>> version below 5.18.
>>>>
>>>> This patch fixed it.
>>>>
>>>> Fixes: d89a58dfe90b ("kni: support chained mbufs")
>>>> Cc: stable@dpdk.org
>>>>
>>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>>> ---
>>>>   kernel/linux/kni/kni_net.c | 4 ++--
>>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
>>>> index 29e5b9e21f..e19f03285e 100644
>>>> --- a/kernel/linux/kni/kni_net.c
>>>> +++ b/kernel/linux/kni/kni_net.c
>>>> @@ -441,7 +441,7 @@ kni_net_rx_normal(struct kni_dev *kni)
>>>>           skb->ip_summed = CHECKSUM_UNNECESSARY;
>>>>           /* Call netif interface */
>>>> -        netif_rx_ni(skb);
>>>> +        netif_rx(skb);
>>>
>>> I think the approach in [1] is the right one. Any comments?
>>>
>>> [1] 
>>> https://patches.dpdk.org/project/dpdk/patch/20220525102641.20982-1-jslaby@suse.cz/ 
>>>
>>>
>>>>           /* Update statistics */
>>>>           dev->stats.rx_bytes += len;
>>>> @@ -779,7 +779,7 @@ kni_net_set_mac(struct net_device *netdev, void *p)
>>>>           return -EADDRNOTAVAIL;
>>>>       memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
>>>> -    memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
>>>> +    memcpy((void *)(netdev->dev_addr), addr->sa_data, 
>>>> netdev->addr_len);
>> When compile, it will report a warning, because it claims that the
>> parameter types must be the same.
>> void *memcpy(void *destin, void *source, unsigned n);
>>
>> so this is what I am doing.
> 
> I think it is a separate story vs netif_rx_ni(). So, it should not be in
> the same patch. IMHO, it is closer to [1]
> 
> [1] 
> https://patches.dpdk.org/project/dpdk/patch/20220601015925.35304-1-humin29@huawei.com/ 
> 
> 
> Am I missing something?
> 

There are two build errors because of kernel side changes.

- netif_rx_ni(). Following patch seems correct fix with small change 
requests:
 
https://patchwork.dpdk.org/project/dpdk/patch/20220525102641.20982-1-jslaby@suse.cz/

- 'net_dev->dev_addr' being const, following patch is in correct direction:
https://patchwork.dpdk.org/project/dpdk/patch/20220601054525.7573-1-ke1x.zhang@intel.com/


>>>
>>> I don't understand why the change is needed and the patch description
>>> does not shed any light on it.
>>>
>>>>       ret = kni_net_process_request(netdev, &req);
>>>
>>> .
>
  

Patch

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 29e5b9e21f..e19f03285e 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -441,7 +441,7 @@  kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
-		netif_rx_ni(skb);
+		netif_rx(skb);
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
@@ -779,7 +779,7 @@  kni_net_set_mac(struct net_device *netdev, void *p)
 		return -EADDRNOTAVAIL;
 
 	memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
-	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+	memcpy((void *)(netdev->dev_addr), addr->sa_data, netdev->addr_len);
 
 	ret = kni_net_process_request(netdev, &req);