lkml.org 
[lkml]   [2011]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 13/40] Staging: hv: netvsc: Introduce code to properly manage outstanding sends
    Date
    Introduce code to properly manage outstanding sends.

    Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
    Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
    Signed-off-by: Abhishek Kane <v-abkane@microsoft.com>
    Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
    ---
    drivers/staging/hv/hyperv_net.h | 10 ++++++++++
    drivers/staging/hv/netvsc.c | 6 +++++-
    2 files changed, 15 insertions(+), 1 deletions(-)

    diff --git a/drivers/staging/hv/hyperv_net.h b/drivers/staging/hv/hyperv_net.h
    index 5782fea..b5bee9e 100644
    --- a/drivers/staging/hv/hyperv_net.h
    +++ b/drivers/staging/hv/hyperv_net.h
    @@ -371,6 +371,8 @@ struct netvsc_device {

    atomic_t refcnt;
    atomic_t num_outstanding_sends;
    + bool drain_notify;
    + wait_queue_head_t waiting_to_drain;
    /*
    * List of free preallocated hv_netvsc_packet to represent receive
    * packet
    @@ -1051,6 +1053,14 @@ struct rndis_filter_packet {
    #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
    #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800

    +static inline void netvsc_wait_to_drain(struct netvsc_device *dev)
    +{
    + dev->drain_notify = true;
    + wait_event(dev->waiting_to_drain,
    + atomic_read(&dev->num_outstanding_sends) == 0);
    + dev->drain_notify = false;
    +}
    +


    #endif /* _HYPERV_NET_H */
    diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
    index 551537a..bdd5c2b 100644
    --- a/drivers/staging/hv/netvsc.c
    +++ b/drivers/staging/hv/netvsc.c
    @@ -42,6 +42,8 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)

    /* Set to 2 to allow both inbound and outbound traffic */
    atomic_cmpxchg(&net_device->refcnt, 0, 2);
    + net_device->drain_notify = false;
    + init_waitqueue_head(&net_device->waiting_to_drain);

    net_device->dev = device;
    device->ext = net_device;
    @@ -483,7 +485,9 @@ static void netvsc_send_completion(struct hv_device *device,
    nvsc_packet->completion.send.send_completion(
    nvsc_packet->completion.send.send_completion_ctx);

    - atomic_dec(&net_device->num_outstanding_sends);
    + if (atomic_dec_and_test(&net_device->num_outstanding_sends) &&
    + net_device->drain_notify)
    + wake_up(&net_device->waiting_to_drain);
    } else {
    netdev_err(ndev, "Unknown send completion packet type- "
    "%d received!!\n", nvsp_packet->hdr.msg_type);
    --
    1.7.4.1


    \
     
     \ /
      Last update: 2011-06-29 16:27    [W:0.024 / U:31.364 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site