Commit 8f9d84df authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging



# gpg: Signature made Wed 26 Oct 2016 03:19:06 BST
# gpg:                using RSA key 0xEF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  colo-proxy: fix memory leak
  net: rtl8139: limit processing of ring descriptors
  net: vmxnet: initialise local tx descriptor
  e1000e: Don't zero out buffer address in rx descriptor
  net: rocker: set limit to DMA buffer size
  net: eepro100: fix memory leak in device uninit
  tap-bsd: OpenBSD uses tap(4) now
  net: pcnet: fix source formatting and indentation
  net: pcnet: check rx/tx descriptor ring length

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 991a97ac 2061c14c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1278,11 +1278,10 @@ e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc,

    struct e1000_rx_desc *d = (struct e1000_rx_desc *) desc;

    memset(d, 0, sizeof(*d));

    assert(!rss_info->enabled);

    d->length = cpu_to_le16(length);
    d->csum = 0;

    e1000e_build_rx_metadata(core, pkt, pkt != NULL,
                             rss_info,
@@ -1291,6 +1290,7 @@ e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc,
                             &d->special);
    d->errors = (uint8_t) (le32_to_cpu(status_flags) >> 24);
    d->status = (uint8_t) le32_to_cpu(status_flags);
    d->special = 0;
}

static inline void
@@ -1301,7 +1301,7 @@ e1000e_write_ext_rx_descr(E1000ECore *core, uint8_t *desc,
{
    union e1000_rx_desc_extended *d = (union e1000_rx_desc_extended *) desc;

    memset(d, 0, sizeof(*d));
    memset(&d->wb, 0, sizeof(d->wb));

    d->wb.upper.length = cpu_to_le16(length);

@@ -1325,7 +1325,7 @@ e1000e_write_ps_rx_descr(E1000ECore *core, uint8_t *desc,
    union e1000_rx_desc_packet_split *d =
        (union e1000_rx_desc_packet_split *) desc;

    memset(d, 0, sizeof(*d));
    memset(&d->wb, 0, sizeof(d->wb));

    d->wb.middle.length0 = cpu_to_le16((*written)[0]);

+1 −0
Original line number Diff line number Diff line
@@ -1843,6 +1843,7 @@ static void pci_nic_uninit(PCIDevice *pci_dev)
    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);

    vmstate_unregister(&pci_dev->qdev, s->vmstate, s);
    g_free(s->vmstate);
    eeprom93xx_free(&pci_dev->qdev, s->eeprom);
    qemu_del_nic(s->nic);
}
+70 −63
Original line number Diff line number Diff line
@@ -664,7 +664,9 @@ static inline int ladr_match(PCNetState *s, const uint8_t *buf, int size)

static inline hwaddr pcnet_rdra_addr(PCNetState *s, int idx)
{
    while (idx < 1) idx += CSR_RCVRL(s);
    while (idx < 1) {
        idx += CSR_RCVRL(s);
    }
    return s->rdra + ((CSR_RCVRL(s) - idx) * (BCR_SWSTYLE(s) ? 16 : 8));
}

@@ -672,8 +674,10 @@ static inline int64_t pcnet_get_next_poll_time(PCNetState *s, int64_t current_ti
{
    int64_t next_time = current_time +
                        (65536 - (CSR_SPND(s) ? 0 : CSR_POLL(s))) * 30;
    if (next_time <= current_time)

    if (next_time <= current_time) {
        next_time = current_time + 1;
    }
    return next_time;
}

@@ -858,12 +862,12 @@ static void pcnet_start(PCNetState *s)
    printf("pcnet_start\n");
#endif

    if (!CSR_DTX(s))
    if (!CSR_DTX(s)) {
        s->csr[0] |= 0x0010;    /* set TXON */

    if (!CSR_DRX(s))
    }
    if (!CSR_DRX(s)) {
        s->csr[0] |= 0x0020;    /* set RXON */

    }
    s->csr[0] &= ~0x0004;       /* clear STOP bit */
    s->csr[0] |= 0x0002;
    pcnet_poll_timer(s);
@@ -925,8 +929,7 @@ static void pcnet_rdte_poll(PCNetState *s)
                       crda);
            }
        } else {
            printf("pcnet: BAD RMD RDA=0x" TARGET_FMT_plx "\n",
                   crda);
            printf("pcnet: BAD RMD RDA=0x" TARGET_FMT_plx "\n", crda);
#endif
        }
    }
@@ -1168,11 +1171,12 @@ ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
#endif

            while (pktcount--) {
                if (CSR_RCVRC(s) <= 1)
                if (CSR_RCVRC(s) <= 1) {
                    CSR_RCVRC(s) = CSR_RCVRL(s);
                else
                } else {
                    CSR_RCVRC(s)--;
                }
            }

            pcnet_rdte_poll(s);

@@ -1279,18 +1283,19 @@ static void pcnet_transmit(PCNetState *s)
txdone:
        SET_FIELD(&tmd.status, TMDS, OWN, 0);
        TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));
        if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT)))
        if (!CSR_TOKINTD(s)
            || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT))) {
            s->csr[0] |= 0x0200;    /* set TINT */

        if (CSR_XMTRC(s)<=1)
        }
        if (CSR_XMTRC(s) <= 1) {
            CSR_XMTRC(s) = CSR_XMTRL(s);
        else
        } else {
            CSR_XMTRC(s)--;
        if (count--)
        }
        if (count--) {
            goto txagain;

    } else
    if (s->xmit_pos >= 0) {
        }
    } else if (s->xmit_pos >= 0) {
        struct pcnet_TMD tmd;
        TMDLOAD(&tmd, xmit_cxda);
        SET_FIELD(&tmd.misc, TMDM, BUFF, 1);
@@ -1301,10 +1306,10 @@ static void pcnet_transmit(PCNetState *s)
        s->csr[0] |= 0x0200;    /* set TINT */
        if (!CSR_DXSUFLO(s)) {
            s->csr[0] &= ~0x0010;
        } else
        if (count--)
        } else if (count--) {
            goto txagain;
        }
    }

    s->tx_busy = 0;
}
@@ -1315,13 +1320,11 @@ static void pcnet_poll(PCNetState *s)
        pcnet_rdte_poll(s);
    }

    if (CSR_TDMD(s) ||
        (CSR_TXON(s) && !CSR_DPOLL(s) && pcnet_tdte_poll(s)))
    {
    if (CSR_TDMD(s) || (CSR_TXON(s) && !CSR_DPOLL(s) && pcnet_tdte_poll(s))) {
        /* prevent recursion */
        if (s->tx_busy)
        if (s->tx_busy) {
            return;

        }
        pcnet_transmit(s);
    }
}
@@ -1340,16 +1343,17 @@ static void pcnet_poll_timer(void *opaque)

    if (!CSR_STOP(s) && !CSR_SPND(s) && !CSR_DPOLL(s)) {
        uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) * 33;
        if (!s->timer || !now)
        if (!s->timer || !now) {
            s->timer = now;
        else {
        } else {
            uint64_t t = now - s->timer + CSR_POLL(s);
            if (t > 0xffffLL) {
                pcnet_poll(s);
                CSR_POLL(s) = CSR_PINT(s);
            } else
            } else {
                CSR_POLL(s) = t;
            }
        }
        timer_mod(s->poll_timer,
            pcnet_get_next_poll_time(s,qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)));
    }
@@ -1371,21 +1375,21 @@ static void pcnet_csr_writew(PCNetState *s, uint32_t rap, uint32_t new_value)
        val = (val & 0x007f) | (s->csr[0] & 0x7f00);

        /* IFF STOP, STRT and INIT are set, clear STRT and INIT */
        if ((val&7) == 7)
        if ((val & 7) == 7) {
            val &= ~3;

        if (!CSR_STOP(s) && (val & 4))
        }
        if (!CSR_STOP(s) && (val & 4)) {
            pcnet_stop(s);

        if (!CSR_INIT(s) && (val & 1))
        }
        if (!CSR_INIT(s) && (val & 1)) {
            pcnet_init(s);

        if (!CSR_STRT(s) && (val & 2))
        }
        if (!CSR_STRT(s) && (val & 2)) {
            pcnet_start(s);

        if (CSR_TDMD(s))
        }
        if (CSR_TDMD(s)) {
            pcnet_transmit(s);

        }
        return;
    case 1:
    case 2:
@@ -1429,11 +1433,15 @@ static void pcnet_csr_writew(PCNetState *s, uint32_t rap, uint32_t new_value)
    case 47: /* POLLINT */
    case 72:
    case 74:
        break;
    case 76: /* RCVRL */
    case 78: /* XMTRL */
        val = (val > 0) ? val : 512;
        break;
    case 112:
       if (CSR_STOP(s) || CSR_SPND(s))
        if (CSR_STOP(s) || CSR_SPND(s)) {
            break;
        }
        return;
    case 3:
        break;
@@ -1651,8 +1659,7 @@ void pcnet_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
            pcnet_bcr_writew(s, s->rap, val & 0xffff);
            break;
        }
    } else
    if ((addr & 0x0f) == 0) {
    } else if ((addr & 0x0f) == 0) {
        /* switch device to dword i/o mode */
        pcnet_bcr_writew(s, BCR_BSBC, pcnet_bcr_readw(s, BCR_BSBC) | 0x0080);
#ifdef PCNET_DEBUG_IO
+1 −1
Original line number Diff line number Diff line
@@ -860,7 +860,7 @@ static void rocker_io_writel(void *opaque, hwaddr addr, uint32_t val)
        rocker_msix_irq(r, val);
        break;
    case ROCKER_TEST_DMA_SIZE:
        r->test_dma_size = val;
        r->test_dma_size = val & 0xFFFF;
        break;
    case ROCKER_TEST_DMA_ADDR + 4:
        r->test_dma_addr = ((uint64_t)val) << 32 | r->lower32;
+1 −1
Original line number Diff line number Diff line
@@ -2350,7 +2350,7 @@ static void rtl8139_cplus_transmit(RTL8139State *s)
{
    int txcount = 0;

    while (rtl8139_cplus_transmit_one(s))
    while (txcount < 64 && rtl8139_cplus_transmit_one(s))
    {
        ++txcount;
    }
Loading