]> Git Repo - qemu.git/commitdiff
net/cadence_gem: Fix small packet FCS stripping
authorPeter Crosthwaite <[email protected]>
Wed, 4 Dec 2013 06:00:17 +0000 (22:00 -0800)
committerPeter Maydell <[email protected]>
Tue, 10 Dec 2013 13:28:50 +0000 (13:28 +0000)
The minimum packet size is 64, however this is before FCS stripping
occurs. So when FCS stripping the minimum packet size is 60. Fix.

Reported-by: Deepika Dhamija <[email protected]>
Signed-off-by: Peter Crosthwaite <[email protected]>
Message-id: 8aac5bd737f9cf48b87f32943d7eb5939061e546.1386136219[email protected]
Signed-off-by: Peter Maydell <[email protected]>
hw/net/cadence_gem.c

index 2afafdfb2b19e69b60d0a0f8be54ea595470a8b9..1619507e553159a8ff3f8bcbdd41e477ede7375d 100644 (file)
@@ -687,6 +687,14 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
                  GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL;
     bytes_to_copy = size;
 
+    /* Pad to minimum length. Assume FCS field is stripped, logic
+     * below will increment it to the real minimum of 64 when
+     * not FCS stripping
+     */
+    if (size < 60) {
+        size = 60;
+    }
+
     /* Strip of FCS field ? (usually yes) */
     if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) {
         rxbuf_ptr = (void *)buf;
@@ -713,11 +721,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         size += 4;
     }
 
-    /* Pad to minimum length */
-    if (size < 64) {
-        size = 64;
-    }
-
     DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size);
 
     while (bytes_to_copy) {
This page took 0.028878 seconds and 4 git commands to generate.