Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932356AbbLXMkm (ORCPT ); Thu, 24 Dec 2015 07:40:42 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:55755 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932221AbbLXMki (ORCPT ); Thu, 24 Dec 2015 07:40:38 -0500 x-originating-ip: 72.167.245.219 From: Dexuan Cui To: gregkh@linuxfoundation.org, davem@davemloft.net, stephen@networkplumber.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, driverdev-devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, kys@microsoft.com Cc: pebolle@tiscali.nl, stefanha@redhat.com, vkuznets@redhat.com, dan.carpenter@oracle.com Subject: [PATCH V5 7/9] Drivers: hv: vmbus: add a mechanism to pass hvsock events to the hvsock driver Date: Thu, 24 Dec 2015 06:14:51 -0800 Message-Id: <1450966491-13276-1-git-send-email-decui@microsoft.com> X-Mailer: git-send-email 1.7.4.1 X-CMAE-Envelope: MS4wfEmZj3mM+1/0LjYuX4RLG2MmaOXWZALlDaq2b6/UpcUqdrorpdd8Ig7Cviu529NOA2UKSwUtZKQRMPfLwI0RySoLODwoeBNMZgg0LKViyvlL+Ej3ylCC WqYryGEm6TGNdFF6Oq8OWX3UkKJ7YrMMP3LR33gL0FSoR/E6zDX0qe/y+h3pOWn9KMDvLswPS7jqNiUh0Am6LWSycHoGyG0Ki9cdXotvULkutf1P/fVTspOv Z098XpE96rGJpOINQKG1uNxpBrImSFGfTcZb2QYIrf+NtLZp2f1U9t44Ik+LN5s2O+kppFfvdSBaxzEtjV4R4khR3GuTtyVo5fUd+w0s9/NvVxZ1nL0LPEdD LaFW6dBhItGNANFXqkhnKbpHkjmaWmpTFRCzvZ1MPjf8EafRa3i3QlaV2G2S9uXRvGAJgWO40EkAZTUjS6XvVYS7ZCrWZujdsBPbpMHZiHkJfJbpPrwRN71I 54EmKTEEVdDug6Pmlz5E+zqktkV3MlX0pWib6mK+NCTLKO4e0FWchnvwgA5nY1sYnzkqCyR8cN2WK4Vx1m+nrDFIbAgIQpIcAF0HsF2nlzLL6QHCJwprk6ca clZVHEGLZR7tvozIRBZLf5L0fd/fA3GLBwSot4Vo+Hp1Kg== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3079 Lines: 92 For now only 1 event is defined: HVSOCK_RESCIND_CHANNEL. We'll have more events in the future. Signed-off-by: Dexuan Cui --- drivers/hv/channel_mgmt.c | 18 ++++++++++++++++++ include/linux/hyperv.h | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 4611b50..87fc7d2 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -608,6 +608,16 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) spin_unlock_irqrestore(&channel->lock, flags); if (channel->device_obj) { + if (is_hvsock_channel(channel) && + channel->hvsock_event_callback) { + channel->hvsock_event_callback(channel, + HVSOCK_RESCIND_CHANNEL); + /* + * We can't invoke vmbus_device_unregister() + * until the socket fd is closed. + */ + return; + } /* * We will have to unregister this device from the * driver core. @@ -977,3 +987,11 @@ bool vmbus_are_subchannels_present(struct vmbus_channel *primary) return ret; } EXPORT_SYMBOL_GPL(vmbus_are_subchannels_present); + +void vmbus_set_hvsock_event_callback(struct vmbus_channel *channel, + void (*hvsock_event_callback)(struct vmbus_channel *, + enum hvsock_event)) +{ + channel->hvsock_event_callback = hvsock_event_callback; +} +EXPORT_SYMBOL_GPL(vmbus_set_hvsock_event_callback); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index b4cc44c..7e507bb 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -645,6 +645,12 @@ enum hv_signal_policy { HV_SIGNAL_POLICY_EXPLICIT, }; +/* hvsock related definitions */ +enum hvsock_event { + /* The host application is close()-ing the connection */ + HVSOCK_RESCIND_CHANNEL, +}; + struct vmbus_channel { /* Unique channel id */ int id; @@ -740,6 +746,13 @@ struct vmbus_channel { void (*sc_creation_callback)(struct vmbus_channel *new_sc); /* + * hvsock event callback. + * For now only 1 event is defined: HVSOCK_RESCIND_CHANNEL. + */ + void (*hvsock_event_callback)(struct vmbus_channel *channel, + enum hvsock_event event); + + /* * The spinlock to protect the structure. It is being used to protect * test-and-set access to various attributes of the structure as well * as all sc_list operations. @@ -825,6 +838,10 @@ int vmbus_request_offers(void); void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel, void (*sc_cr_cb)(struct vmbus_channel *new_sc)); +void vmbus_set_hvsock_event_callback(struct vmbus_channel *channel, + void (*hvsock_event_callback)(struct vmbus_channel *, + enum hvsock_event)); + /* * Retrieve the (sub) channel on which to send an outgoing request. * When a primary channel has multiple sub-channels, we choose a -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/