qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v2 7/8] pc-bios/s390-ccw: Add virtio-net dri


From: Cornelia Huck
Subject: Re: [Qemu-devel] [RFC PATCH v2 7/8] pc-bios/s390-ccw: Add virtio-net driver code
Date: Mon, 10 Jul 2017 13:38:00 +0200

On Mon, 10 Jul 2017 13:23:07 +0200
Thomas Huth <address@hidden> wrote:

> On 07.07.2017 14:37, Cornelia Huck wrote:
> > On Fri,  7 Jul 2017 12:27:03 +0200
> > Thomas Huth <address@hidden> wrote:
> >   
> >> The driver provides the recv() and send() functions which will
> >> be required by SLOF's libnet code for receiving and sending
> >> packets.  
> [...]
> >> +int virtio_net_init(void *mac_addr)
> >> +{
> >> +    VDev *vdev = virtio_get_device();
> >> +    VRing *rxvq = &vdev->vrings[VQ_RX];
> >> +    void *buf;
> >> +    int i;
> >> +
> >> +    virtio_setup_ccw(vdev);
> >> +
> >> +    memcpy(mac_addr, vdev->config.net.mac, ETH_ALEN);  
> > 
> > The mac address in the config space is only valid if the mac feature
> > flag has been negotiated (although the field always exists).  
> 
> QEMU seems to always set it ... but yes, let's better negotiate
> VIRTIO_NET_F_MAC here.

Ah, feature negotiation in the bios, nice :)

> 
> >> +
> >> +    for (i = 0; i < 64; i++) {
> >> +        buf = malloc(ETH_MTU_SIZE + sizeof(VirtioNetHdr));
> >> +        IPL_assert(buf != NULL, "Can not allocate memory for receive 
> >> buffers");
> >> +        vring_send_buf(rxvq, buf, ETH_MTU_SIZE + sizeof(VirtioNetHdr),
> >> +                       VRING_DESC_F_WRITE);
> >> +    }
> >> +    vring_notify(rxvq);
> >> +
> >> +    return 0;
> >> +}
> >> +
> >> +int send(int fd, const void *buf, int len, int flags)
> >> +{
> >> +    VirtioNetHdr tx_hdr;
> >> +    VDev *vdev = virtio_get_device();
> >> +    VRing *txvq = &vdev->vrings[VQ_TX];
> >> +
> >> +    /* Set up header - we do not use anything special, so simply clear it 
> >> */
> >> +    memset(&tx_hdr, 0, sizeof(tx_hdr));
> >> +
> >> +    vring_send_buf(txvq, &tx_hdr, sizeof(tx_hdr), VRING_DESC_F_NEXT);
> >> +    vring_send_buf(txvq, (void *)buf, len, VRING_HIDDEN_IS_CHAIN);
> >> +    while (!vr_poll(txvq)) {
> >> +        yield();
> >> +    }
> >> +    if (drain_irqs(txvq->schid)) {
> >> +        puts("send: drain irqs failed");
> >> +        return -1;  
> > 
> > Does the caller try again later? drain_irqs() errors may be transient.  
> 
> Yes, the TFTP code retries to send packets after a certain amount of
> time (since the packets could also be lost in the network somewhere).

Sounds good. (Not that I expect many errors in drain_irqs()...)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]