* [Qemu-devel] [PATCH for-2.4 v2] xen: Drop net_rx_ok
@ 2015-07-28 9:25 Fam Zheng
2015-07-28 9:32 ` Wen Congyang
0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2015-07-28 9:25 UTC (permalink / raw)
To: qemu-devel
Cc: jasowang, Fam Zheng, Chen Gang, Stefan Hajnoczi,
stefano.stabellini
Let net_rx_packet() (which checks the same conditions) drops the packet
if the device is not ready. Drop net_xen_info.can_receive and update the
return value for the buffer full case.
We rely on the qemu_flush_queued_packets() in net_event() to wake up
the peer when the buffer becomes available again.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
v2:
Fix return value of net_rx_packet to keep the semantics when ring
buffer is full. [Stefan]
Update commit message accordingly.
---
hw/net/xen_nic.c | 24 +-----------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index 19ecfc4..acb7e2e 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -234,27 +234,6 @@ static void net_rx_response(struct XenNetDev *netdev,
#define NET_IP_ALIGN 2
-static int net_rx_ok(NetClientState *nc)
-{
- struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
- RING_IDX rc, rp;
-
- if (netdev->xendev.be_state != XenbusStateConnected) {
- return 0;
- }
-
- rc = netdev->rx_ring.req_cons;
- rp = netdev->rx_ring.sring->req_prod;
- xen_rmb();
-
- if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
- xen_be_printf(&netdev->xendev, 2, "%s: no rx buffers (%d/%d)\n",
- __FUNCTION__, rc, rp);
- return 0;
- }
- return 1;
-}
-
static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size)
{
struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
@@ -272,7 +251,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
- return -1;
+ return 0;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
@@ -304,7 +283,6 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
static NetClientInfo net_xen_info = {
.type = NET_CLIENT_OPTIONS_KIND_NIC,
.size = sizeof(NICState),
- .can_receive = net_rx_ok,
.receive = net_rx_packet,
};
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.4 v2] xen: Drop net_rx_ok
2015-07-28 9:25 [Qemu-devel] [PATCH for-2.4 v2] xen: Drop net_rx_ok Fam Zheng
@ 2015-07-28 9:32 ` Wen Congyang
2015-07-28 9:50 ` Fam Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Wen Congyang @ 2015-07-28 9:32 UTC (permalink / raw)
To: Fam Zheng, qemu-devel
Cc: jasowang, Chen Gang, Stefan Hajnoczi, stefano.stabellini
On 07/28/2015 05:25 PM, Fam Zheng wrote:
> Let net_rx_packet() (which checks the same conditions) drops the packet
> if the device is not ready. Drop net_xen_info.can_receive and update the
> return value for the buffer full case.
>
> We rely on the qemu_flush_queued_packets() in net_event() to wake up
> the peer when the buffer becomes available again.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
>
> ---
>
> v2:
> Fix return value of net_rx_packet to keep the semantics when ring
> buffer is full. [Stefan]
> Update commit message accordingly.
> ---
> hw/net/xen_nic.c | 24 +-----------------------
> 1 file changed, 1 insertion(+), 23 deletions(-)
>
> diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
> index 19ecfc4..acb7e2e 100644
> --- a/hw/net/xen_nic.c
> +++ b/hw/net/xen_nic.c
> @@ -234,27 +234,6 @@ static void net_rx_response(struct XenNetDev *netdev,
>
> #define NET_IP_ALIGN 2
>
> -static int net_rx_ok(NetClientState *nc)
> -{
> - struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
> - RING_IDX rc, rp;
> -
> - if (netdev->xendev.be_state != XenbusStateConnected) {
> - return 0;
> - }
> -
> - rc = netdev->rx_ring.req_cons;
> - rp = netdev->rx_ring.sring->req_prod;
> - xen_rmb();
> -
> - if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
> - xen_be_printf(&netdev->xendev, 2, "%s: no rx buffers (%d/%d)\n",
> - __FUNCTION__, rc, rp);
> - return 0;
> - }
> - return 1;
> -}
> -
> static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size)
> {
> struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
> @@ -272,7 +251,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
>
> if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
> xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
IIUC, 'return 0' means that the packet will be queued in the incoming queue. So the log should
be changed too.
Thanks
Wen Congyang
> - return -1;
> + return 0;
> }
> if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
> xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
> @@ -304,7 +283,6 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
> static NetClientInfo net_xen_info = {
> .type = NET_CLIENT_OPTIONS_KIND_NIC,
> .size = sizeof(NICState),
> - .can_receive = net_rx_ok,
> .receive = net_rx_packet,
> };
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.4 v2] xen: Drop net_rx_ok
2015-07-28 9:32 ` Wen Congyang
@ 2015-07-28 9:50 ` Fam Zheng
0 siblings, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2015-07-28 9:50 UTC (permalink / raw)
To: Wen Congyang
Cc: jasowang, stefano.stabellini, qemu-devel, Stefan Hajnoczi,
Chen Gang
On Tue, 07/28 17:32, Wen Congyang wrote:
> On 07/28/2015 05:25 PM, Fam Zheng wrote:
> > Let net_rx_packet() (which checks the same conditions) drops the packet
> > if the device is not ready. Drop net_xen_info.can_receive and update the
> > return value for the buffer full case.
> >
> > We rely on the qemu_flush_queued_packets() in net_event() to wake up
> > the peer when the buffer becomes available again.
> >
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> >
> > ---
> >
> > v2:
> > Fix return value of net_rx_packet to keep the semantics when ring
> > buffer is full. [Stefan]
> > Update commit message accordingly.
> > ---
> > hw/net/xen_nic.c | 24 +-----------------------
> > 1 file changed, 1 insertion(+), 23 deletions(-)
> >
> > diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
> > index 19ecfc4..acb7e2e 100644
> > --- a/hw/net/xen_nic.c
> > +++ b/hw/net/xen_nic.c
> > @@ -234,27 +234,6 @@ static void net_rx_response(struct XenNetDev *netdev,
> >
> > #define NET_IP_ALIGN 2
> >
> > -static int net_rx_ok(NetClientState *nc)
> > -{
> > - struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
> > - RING_IDX rc, rp;
> > -
> > - if (netdev->xendev.be_state != XenbusStateConnected) {
> > - return 0;
> > - }
> > -
> > - rc = netdev->rx_ring.req_cons;
> > - rp = netdev->rx_ring.sring->req_prod;
> > - xen_rmb();
> > -
> > - if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
> > - xen_be_printf(&netdev->xendev, 2, "%s: no rx buffers (%d/%d)\n",
> > - __FUNCTION__, rc, rp);
> > - return 0;
> > - }
> > - return 1;
> > -}
> > -
> > static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size)
> > {
> > struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
> > @@ -272,7 +251,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
> >
> > if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
> > xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
>
> IIUC, 'return 0' means that the packet will be queued in the incoming queue. So the log should
> be changed too.
You're right, will fix.
Fam
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-28 9:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 9:25 [Qemu-devel] [PATCH for-2.4 v2] xen: Drop net_rx_ok Fam Zheng
2015-07-28 9:32 ` Wen Congyang
2015-07-28 9:50 ` Fam Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).