[PATCH 05/20] hw/net/xilinx_ethlite: Correct maximum RX buffer size

Philippe Mathieu-Daudé posted 20 patches 1 week, 4 days ago
There is a newer version of this series
[PATCH 05/20] hw/net/xilinx_ethlite: Correct maximum RX buffer size
Posted by Philippe Mathieu-Daudé 1 week, 4 days ago
The current max RX bufsize is set to 0x800. This is
invalid, since it contains the MMIO registers region.
Add the correct definition and use it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/net/xilinx_ethlite.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
index 0f59811c78..e6f6179fce 100644
--- a/hw/net/xilinx_ethlite.c
+++ b/hw/net/xilinx_ethlite.c
@@ -46,6 +46,8 @@
 #define R_RX_CTRL1    (0x1ffc / 4)
 #define R_MAX         (0x2000 / 4)
 
+#define RX_BUFSZ_MAX  0x07e0
+
 #define GIE_GIE    0x80000000
 
 #define CTRL_I     0x8
@@ -195,7 +197,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)
         return -1;
     }
 
-    if (size > (R_MAX - R_RX_BUF0 - rxbase) * 4) {
+    if (size > RX_BUFSZ_MAX) {
         trace_ethlite_pkt_size_too_big(size);
         return -1;
     }
-- 
2.45.2


Re: [PATCH 05/20] hw/net/xilinx_ethlite: Correct maximum RX buffer size
Posted by Edgar E. Iglesias 1 week, 3 days ago
On Tue, Nov 12, 2024 at 07:10:29PM +0100, Philippe Mathieu-Daudé wrote:
> The current max RX bufsize is set to 0x800. This is
> invalid, since it contains the MMIO registers region.
> Add the correct definition and use it.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>


> ---
>  hw/net/xilinx_ethlite.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
> index 0f59811c78..e6f6179fce 100644
> --- a/hw/net/xilinx_ethlite.c
> +++ b/hw/net/xilinx_ethlite.c
> @@ -46,6 +46,8 @@
>  #define R_RX_CTRL1    (0x1ffc / 4)
>  #define R_MAX         (0x2000 / 4)
>  
> +#define RX_BUFSZ_MAX  0x07e0
> +
>  #define GIE_GIE    0x80000000
>  
>  #define CTRL_I     0x8
> @@ -195,7 +197,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)
>          return -1;
>      }
>  
> -    if (size > (R_MAX - R_RX_BUF0 - rxbase) * 4) {
> +    if (size > RX_BUFSZ_MAX) {
>          trace_ethlite_pkt_size_too_big(size);
>          return -1;
>      }
> -- 
> 2.45.2
>