ia64/xen-unstable

changeset 17989:abd84464c09c

ioemu: e1000: fix a TSE bug

Previously, all data descriptors used TSE context descriptor. It's not
correct, per spec, data descriptor uses TSE bit to indicate whether
use TSE. Legacy data descripter never use TSE.

Signed-off-by; Anthony Xu <anthony.xu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 07 10:29:56 2008 +0100 (2008-07-07)
parents 5eaec8296a22
children 9b35ae586cb8
files tools/ioemu/hw/e1000.c
line diff
     1.1 --- a/tools/ioemu/hw/e1000.c	Sun Jul 06 20:16:24 2008 +0100
     1.2 +++ b/tools/ioemu/hw/e1000.c	Mon Jul 07 10:29:56 2008 +0100
     1.3 @@ -103,6 +103,7 @@ typedef struct E1000State_st {
     1.4          char tse;
     1.5          char ip;
     1.6          char tcp;
     1.7 +        char cptse;     //current packet tse bit
     1.8      } tx;
     1.9  
    1.10      struct {
    1.11 @@ -306,7 +307,7 @@ xmit_seg(E1000State *s)
    1.12      unsigned int frames = s->tx.tso_frames, css, sofar, n;
    1.13      struct e1000_tx *tp = &s->tx;
    1.14  
    1.15 -    if (tp->tse) {
    1.16 +    if (tp->tse && tp->cptse) {
    1.17          css = tp->ipcss;
    1.18          DBGOUT(TXSUM, "frames %d size %d ipcss %d\n",
    1.19                 frames, tp->size, css);
    1.20 @@ -380,37 +381,49 @@ process_tx_desc(E1000State *s, struct e1
    1.21              tp->tucso = tp->tucss + (tp->tcp ? 16 : 6);
    1.22          }
    1.23          return;
    1.24 -    } else if (dtype == (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D))
    1.25 +    } else if (dtype == (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D)){
    1.26 +        // data descriptor
    1.27          tp->sum_needed = le32_to_cpu(dp->upper.data) >> 8;
    1.28 +        tp->cptse = ( txd_lower & E1000_TXD_CMD_TSE ) ? 1 : 0;
    1.29 +    } else
    1.30 +        // legacy descriptor
    1.31 +        tp->cptse = 0;
    1.32  
    1.33      addr = le64_to_cpu(dp->buffer_addr);
    1.34 -    if (tp->tse) {
    1.35 +    if (tp->tse && tp->cptse) {
    1.36          hdr = tp->hdr_len;
    1.37          msh = hdr + tp->mss;
    1.38 +        do {
    1.39 +            bytes = split_size;
    1.40 +            if (tp->size + bytes > msh)
    1.41 +                bytes = msh - tp->size;
    1.42 +            cpu_physical_memory_read(addr, tp->data + tp->size, bytes);
    1.43 +            if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)
    1.44 +                memmove(tp->header, tp->data, hdr);
    1.45 +            tp->size = sz;
    1.46 +            addr += bytes;
    1.47 +            if (sz == msh) {
    1.48 +                xmit_seg(s);
    1.49 +                memmove(tp->data, tp->header, hdr);
    1.50 +                tp->size = hdr;
    1.51 +            }
    1.52 +        } while (split_size -= bytes);
    1.53 +    } else if (!tp->tse && tp->cptse) {
    1.54 +        // context descriptor TSE is not set, while data descriptor TSE is set
    1.55 +        DBGOUT(TXERR, "TCP segmentaion Error\n");
    1.56 +    } else {
    1.57 +        cpu_physical_memory_read(addr, tp->data + tp->size, split_size);
    1.58 +        tp->size += split_size;
    1.59      }
    1.60 -    do {
    1.61 -        bytes = split_size;
    1.62 -        if (tp->size + bytes > msh)
    1.63 -            bytes = msh - tp->size;
    1.64 -        cpu_physical_memory_read(addr, tp->data + tp->size, bytes);
    1.65 -        if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)
    1.66 -            memmove(tp->header, tp->data, hdr);
    1.67 -        tp->size = sz;
    1.68 -        addr += bytes;
    1.69 -        if (sz == msh) {
    1.70 -            xmit_seg(s);
    1.71 -            memmove(tp->data, tp->header, hdr);
    1.72 -            tp->size = hdr;
    1.73 -        }
    1.74 -    } while (split_size -= bytes);
    1.75  
    1.76      if (!(txd_lower & E1000_TXD_CMD_EOP))
    1.77          return;
    1.78 -    if (tp->size > hdr)
    1.79 +    if (!(tp->tse && tp->cptse && tp->size < hdr))
    1.80          xmit_seg(s);
    1.81      tp->tso_frames = 0;
    1.82      tp->sum_needed = 0;
    1.83      tp->size = 0;
    1.84 +    tp->cptse = 0;
    1.85  }
    1.86  
    1.87  static uint32_t