[Qemu-devel] [PATCH v1 2/5] cadence_gem: Correct the multi-queue can rx logic

Alistair Francis posted 5 patches 8 years, 10 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v1 2/5] cadence_gem: Correct the multi-queue can rx logic
Posted by Alistair Francis 8 years, 10 months ago
Correct the buffer descriptor busy logic to work correctly when using
multiple queues.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---

 hw/net/cadence_gem.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 17c229d..3e37665 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -481,14 +481,18 @@ static int gem_can_receive(NetClientState *nc)
     }
 
     for (i = 0; i < s->num_priority_queues; i++) {
-        if (rx_desc_get_ownership(s->rx_desc[i]) == 1) {
-            if (s->can_rx_state != 2) {
-                s->can_rx_state = 2;
-                DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n",
-                         i, s->rx_desc_addr[i]);
-             }
-            return 0;
+        if (rx_desc_get_ownership(s->rx_desc[i]) != 1) {
+            break;
+        }
+    };
+
+    if (i == s->num_priority_queues) {
+        if (s->can_rx_state != 2) {
+            s->can_rx_state = 2;
+            DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n",
+                     i, s->rx_desc_addr[i]);
         }
+        return 0;
     }
 
     if (s->can_rx_state != 0) {
-- 
2.9.3


Re: [Qemu-devel] [PATCH v1 2/5] cadence_gem: Correct the multi-queue can rx logic
Posted by Peter Maydell 8 years, 10 months ago
On 5 April 2017 at 00:40, Alistair Francis <alistair.francis@xilinx.com> wrote:
> Correct the buffer descriptor busy logic to work correctly when using
> multiple queues.
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
>
>  hw/net/cadence_gem.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index 17c229d..3e37665 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -481,14 +481,18 @@ static int gem_can_receive(NetClientState *nc)
>      }
>
>      for (i = 0; i < s->num_priority_queues; i++) {
> -        if (rx_desc_get_ownership(s->rx_desc[i]) == 1) {
> -            if (s->can_rx_state != 2) {
> -                s->can_rx_state = 2;
> -                DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n",
> -                         i, s->rx_desc_addr[i]);
> -             }
> -            return 0;
> +        if (rx_desc_get_ownership(s->rx_desc[i]) != 1) {
> +            break;
> +        }
> +    };
> +
> +    if (i == s->num_priority_queues) {
> +        if (s->can_rx_state != 2) {
> +            s->can_rx_state = 2;
> +            DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n",
> +                     i, s->rx_desc_addr[i]);

This looks a little odd -- surely i isn't the right index to use
into rx_desc_addr[] any more now we're outside the loop and i
is always larger than the largest valid queue number? It looks
like the debug print should be rephrased somehow.

thanks
-- PMM

Re: [Qemu-devel] [PATCH v1 2/5] cadence_gem: Correct the multi-queue can rx logic
Posted by Alistair Francis 8 years, 10 months ago
On Mon, Apr 10, 2017 at 5:37 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 5 April 2017 at 00:40, Alistair Francis <alistair.francis@xilinx.com> wrote:
>> Correct the buffer descriptor busy logic to work correctly when using
>> multiple queues.
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>>
>>  hw/net/cadence_gem.c | 18 +++++++++++-------
>>  1 file changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
>> index 17c229d..3e37665 100644
>> --- a/hw/net/cadence_gem.c
>> +++ b/hw/net/cadence_gem.c
>> @@ -481,14 +481,18 @@ static int gem_can_receive(NetClientState *nc)
>>      }
>>
>>      for (i = 0; i < s->num_priority_queues; i++) {
>> -        if (rx_desc_get_ownership(s->rx_desc[i]) == 1) {
>> -            if (s->can_rx_state != 2) {
>> -                s->can_rx_state = 2;
>> -                DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n",
>> -                         i, s->rx_desc_addr[i]);
>> -             }
>> -            return 0;
>> +        if (rx_desc_get_ownership(s->rx_desc[i]) != 1) {
>> +            break;
>> +        }
>> +    };
>> +
>> +    if (i == s->num_priority_queues) {
>> +        if (s->can_rx_state != 2) {
>> +            s->can_rx_state = 2;
>> +            DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n",
>> +                     i, s->rx_desc_addr[i]);
>
> This looks a little odd -- surely i isn't the right index to use
> into rx_desc_addr[] any more now we're outside the loop and i
> is always larger than the largest valid queue number? It looks
> like the debug print should be rephrased somehow.

Yeah you are right. It means that they are all busy, we can either
iterate over all of them and print out this or just print one
statement saying that. Somehow I ended up half way between both.

I'll update it to just print that they are all busy. I don't see why
we need every address printed.

Thanks,

Alistair

>
> thanks
> -- PMM