diff mbox series

[3/6] dp8393x: switch to use qemu_receive_packet() for loopback packet

Message ID 20210224055401.492407-4-jasowang@redhat.com
State New
Headers show
Series Detect reentrant RX casue by loopback | expand

Commit Message

Jason Wang Feb. 24, 2021, 5:53 a.m. UTC
This patch switches to use qemu_receive_packet() which can detect
reentrancy and return early.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/dp8393x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Weil Feb. 24, 2021, 6:13 a.m. UTC | #1
Am 24.02.21 um 06:53 schrieb Jason Wang:

> This patch switches to use qemu_receive_packet() which can detect
> reentrancy and return early.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>   hw/net/dp8393x.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
> index 205c0decc5..019d4fe435 100644
> --- a/hw/net/dp8393x.c
> +++ b/hw/net/dp8393x.c
> @@ -506,7 +506,7 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)
>               s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
>               if (nc->info->can_receive(nc)) {
>                   s->loopback_packet = 1;
> -                nc->info->receive(nc, s->tx_buffer, tx_len);
> +                qemu_receice_packet(nc, s->tx_buffer, tx_Len);


Did you test compilation of that code? It looks like a typo ...

Regards

Stefan W.
Philippe Mathieu-Daudé Feb. 25, 2021, 2:36 p.m. UTC | #2
On 2/24/21 7:13 AM, Stefan Weil wrote:
> Am 24.02.21 um 06:53 schrieb Jason Wang:
> 
>> This patch switches to use qemu_receive_packet() which can detect
>> reentrancy and return early.
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>>   hw/net/dp8393x.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
>> index 205c0decc5..019d4fe435 100644
>> --- a/hw/net/dp8393x.c
>> +++ b/hw/net/dp8393x.c
>> @@ -506,7 +506,7 @@ static void
>> dp8393x_do_transmit_packets(dp8393xState *s)
>>               s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
>>               if (nc->info->can_receive(nc)) {
>>                   s->loopback_packet = 1;
>> -                nc->info->receive(nc, s->tx_buffer, tx_len);
>> +                qemu_receice_packet(nc, s->tx_buffer, tx_Len);
> 
> 
> Did you test compilation of that code? It looks like a typo ...

With typo fixed:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Stefan Weil Feb. 25, 2021, 2:42 p.m. UTC | #3
Am 25.02.21 um 15:36 schrieb Philippe Mathieu-Daudé:

> On 2/24/21 7:13 AM, Stefan Weil wrote:
>> Am 24.02.21 um 06:53 schrieb Jason Wang:
>>
>>> This patch switches to use qemu_receive_packet() which can detect
>>> reentrancy and return early.
>>>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>> ---
>>>    hw/net/dp8393x.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
>>> index 205c0decc5..019d4fe435 100644
>>> --- a/hw/net/dp8393x.c
>>> +++ b/hw/net/dp8393x.c
>>> @@ -506,7 +506,7 @@ static void
>>> dp8393x_do_transmit_packets(dp8393xState *s)
>>>                s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
>>>                if (nc->info->can_receive(nc)) {
>>>                    s->loopback_packet = 1;
>>> -                nc->info->receive(nc, s->tx_buffer, tx_len);
>>> +                qemu_receice_packet(nc, s->tx_buffer, tx_Len);
>>
>> Did you test compilation of that code? It looks like a typo ...
> With typo fixed:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Plural, as I noticed later: there are two typos in the same line of 
code. The compiler will report both of them.

Stefan
Jason Wang Feb. 26, 2021, 7:04 a.m. UTC | #4
On 2021/2/25 10:42 下午, Stefan Weil wrote:
> Am 25.02.21 um 15:36 schrieb Philippe Mathieu-Daudé:
>
>> On 2/24/21 7:13 AM, Stefan Weil wrote:
>>> Am 24.02.21 um 06:53 schrieb Jason Wang:
>>>
>>>> This patch switches to use qemu_receive_packet() which can detect
>>>> reentrancy and return early.
>>>>
>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>> ---
>>>>    hw/net/dp8393x.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
>>>> index 205c0decc5..019d4fe435 100644
>>>> --- a/hw/net/dp8393x.c
>>>> +++ b/hw/net/dp8393x.c
>>>> @@ -506,7 +506,7 @@ static void
>>>> dp8393x_do_transmit_packets(dp8393xState *s)
>>>>                s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
>>>>                if (nc->info->can_receive(nc)) {
>>>>                    s->loopback_packet = 1;
>>>> -                nc->info->receive(nc, s->tx_buffer, tx_len);
>>>> +                qemu_receice_packet(nc, s->tx_buffer, tx_Len);
>>>
>>> Did you test compilation of that code? It looks like a typo ...
>> With typo fixed:
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
>
> Plural, as I noticed later: there are two typos in the same line of 
> code. The compiler will report both of them.
>
> Stefan


Yes, my bad. Will post V2.

Thanks
diff mbox series

Patch

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 205c0decc5..019d4fe435 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -506,7 +506,7 @@  static void dp8393x_do_transmit_packets(dp8393xState *s)
             s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
             if (nc->info->can_receive(nc)) {
                 s->loopback_packet = 1;
-                nc->info->receive(nc, s->tx_buffer, tx_len);
+                qemu_receice_packet(nc, s->tx_buffer, tx_Len);
             }
         } else {
             /* Transmit packet */