[v2,1/3] net/virtio: register/unregister intr handler on start/stop
diff mbox series

Message ID 20180919125757.17938-1-bluca@debian.org
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • [v2,1/3] net/virtio: register/unregister intr handler on start/stop
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Luca Boccassi Sept. 19, 2018, 12:57 p.m. UTC
Register and unregister the virtio interrupt handler when the device is
started and stopped. This allows a virtio device to be hotplugged or
unplugged.

Fixes: c1f86306a026 ("virtio: add new driver")
Cc: stable@dpdk.org

Signed-off-by: Brian Russell <brussell@brocade.com>
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
 drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

Comments

Luca Boccassi Sept. 27, 2018, 8:40 a.m. UTC | #1
On Wed, 2018-09-19 at 13:57 +0100, Luca Boccassi wrote:
> Register and unregister the virtio interrupt handler when the device
> is
> started and stopped. This allows a virtio device to be hotplugged or
> unplugged.
> 
> Fixes: c1f86306a026 ("virtio: add new driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Brian Russell <brussell@brocade.com>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index b81df0a99f..adc6a30a32 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1679,11 +1679,6 @@ eth_virtio_dev_init(struct rte_eth_dev
> *eth_dev)
>  	if (ret < 0)
>  		goto out;
>  
> -	/* Setup interrupt callback  */
> -	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
> -		rte_intr_callback_register(eth_dev->intr_handle,
> -			virtio_interrupt_handler, eth_dev);
> -
>  	return 0;
>  
>  out:
> @@ -1709,11 +1704,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev
> *eth_dev)
>  	rte_free(eth_dev->data->mac_addrs);
>  	eth_dev->data->mac_addrs = NULL;
>  
> -	/* reset interrupt callback  */
> -	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
> -		rte_intr_callback_unregister(eth_dev->intr_handle,
> -						virtio_interrupt_han
> dler,
> -						eth_dev);
>  	if (eth_dev->device)
>  		rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
>  
> @@ -1972,6 +1962,12 @@ virtio_dev_start(struct rte_eth_dev *dev)
>  	    dev->data->dev_conf.intr_conf.rxq) {
>  		virtio_intr_disable(dev);
>  
> +		/* Setup interrupt callback  */
> +		if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
> +			rte_intr_callback_register(dev->intr_handle,
> +						   virtio_interrupt_
> handler,
> +						   dev);
> +
>  		if (virtio_intr_enable(dev) < 0) {
>  			PMD_DRV_LOG(ERR, "interrupt enable failed");
>  			return -EIO;
> @@ -2081,9 +2077,17 @@ virtio_dev_stop(struct rte_eth_dev *dev)
>  	PMD_INIT_LOG(DEBUG, "stop");
>  
>  	rte_spinlock_lock(&hw->state_lock);
> -	if (intr_conf->lsc || intr_conf->rxq)
> +	if (intr_conf->lsc || intr_conf->rxq) {
>  		virtio_intr_disable(dev);
>  
> +		/* Reset interrupt callback  */
> +		if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
> +			rte_intr_callback_unregister(dev-
> >intr_handle,
> +						     virtio_interrup
> t_handler,
> +						     dev);
> +		}
> +	}
> +
>  	hw->started = 0;
>  	memset(&link, 0, sizeof(link));
>  	rte_eth_linkstatus_set(dev, &link);

Hi, any chance the virtio and eal patches in this series could get a
review? Thanks!
Maxime Coquelin Sept. 27, 2018, 10:51 a.m. UTC | #2
On 09/27/2018 10:40 AM, Luca Boccassi wrote:
> On Wed, 2018-09-19 at 13:57 +0100, Luca Boccassi wrote:
>> Register and unregister the virtio interrupt handler when the device
>> is
>> started and stopped. This allows a virtio device to be hotplugged or
>> unplugged.
>>
>> Fixes: c1f86306a026 ("virtio: add new driver")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Brian Russell <brussell@brocade.com>
>> Signed-off-by: Luca Boccassi <bluca@debian.org>
>> ---
>>   drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++-----------
>>   1 file changed, 15 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/net/virtio/virtio_ethdev.c
>> b/drivers/net/virtio/virtio_ethdev.c
>> index b81df0a99f..adc6a30a32 100644
>> --- a/drivers/net/virtio/virtio_ethdev.c
>> +++ b/drivers/net/virtio/virtio_ethdev.c
>> @@ -1679,11 +1679,6 @@ eth_virtio_dev_init(struct rte_eth_dev
>> *eth_dev)
>>   	if (ret < 0)
>>   		goto out;
>>   
>> -	/* Setup interrupt callback  */
>> -	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
>> -		rte_intr_callback_register(eth_dev->intr_handle,
>> -			virtio_interrupt_handler, eth_dev);
>> -
>>   	return 0;
>>   
>>   out:
>> @@ -1709,11 +1704,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev
>> *eth_dev)
>>   	rte_free(eth_dev->data->mac_addrs);
>>   	eth_dev->data->mac_addrs = NULL;
>>   
>> -	/* reset interrupt callback  */
>> -	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
>> -		rte_intr_callback_unregister(eth_dev->intr_handle,
>> -						virtio_interrupt_han
>> dler,
>> -						eth_dev);
>>   	if (eth_dev->device)
>>   		rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
>>   
>> @@ -1972,6 +1962,12 @@ virtio_dev_start(struct rte_eth_dev *dev)
>>   	    dev->data->dev_conf.intr_conf.rxq) {
>>   		virtio_intr_disable(dev);
>>   
>> +		/* Setup interrupt callback  */
>> +		if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
>> +			rte_intr_callback_register(dev->intr_handle,
>> +						   virtio_interrupt_
>> handler,
>> +						   dev);
>> +
>>   		if (virtio_intr_enable(dev) < 0) {
>>   			PMD_DRV_LOG(ERR, "interrupt enable failed");
>>   			return -EIO;
>> @@ -2081,9 +2077,17 @@ virtio_dev_stop(struct rte_eth_dev *dev)
>>   	PMD_INIT_LOG(DEBUG, "stop");
>>   
>>   	rte_spinlock_lock(&hw->state_lock);
>> -	if (intr_conf->lsc || intr_conf->rxq)
>> +	if (intr_conf->lsc || intr_conf->rxq) {
>>   		virtio_intr_disable(dev);
>>   
>> +		/* Reset interrupt callback  */
>> +		if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
>> +			rte_intr_callback_unregister(dev-
>>> intr_handle,
>> +						     virtio_interrup
>> t_handler,
>> +						     dev);
>> +		}
>> +	}
>> +
>>   	hw->started = 0;
>>   	memset(&link, 0, sizeof(link));
>>   	rte_eth_linkstatus_set(dev, &link);
> 
> Hi, any chance the virtio and eal patches in this series could get a
> review? Thanks!
> 

Hi,

Sorry, I missed it because not delegated to me in patchwork.
Looking at it now!

Regards,
Maxime
Maxime Coquelin Sept. 27, 2018, 11:14 a.m. UTC | #3
On 09/19/2018 02:57 PM, Luca Boccassi wrote:
> Register and unregister the virtio interrupt handler when the device is
> started and stopped. This allows a virtio device to be hotplugged or
> unplugged.
> 
> Fixes: c1f86306a026 ("virtio: add new driver")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Brian Russell <brussell@brocade.com>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
>   drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++-----------
>   1 file changed, 15 insertions(+), 11 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

Patch
diff mbox series

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b81df0a99f..adc6a30a32 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1679,11 +1679,6 @@  eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		goto out;
 
-	/* Setup interrupt callback  */
-	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-		rte_intr_callback_register(eth_dev->intr_handle,
-			virtio_interrupt_handler, eth_dev);
-
 	return 0;
 
 out:
@@ -1709,11 +1704,6 @@  eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 
-	/* reset interrupt callback  */
-	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-		rte_intr_callback_unregister(eth_dev->intr_handle,
-						virtio_interrupt_handler,
-						eth_dev);
 	if (eth_dev->device)
 		rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
 
@@ -1972,6 +1962,12 @@  virtio_dev_start(struct rte_eth_dev *dev)
 	    dev->data->dev_conf.intr_conf.rxq) {
 		virtio_intr_disable(dev);
 
+		/* Setup interrupt callback  */
+		if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+			rte_intr_callback_register(dev->intr_handle,
+						   virtio_interrupt_handler,
+						   dev);
+
 		if (virtio_intr_enable(dev) < 0) {
 			PMD_DRV_LOG(ERR, "interrupt enable failed");
 			return -EIO;
@@ -2081,9 +2077,17 @@  virtio_dev_stop(struct rte_eth_dev *dev)
 	PMD_INIT_LOG(DEBUG, "stop");
 
 	rte_spinlock_lock(&hw->state_lock);
-	if (intr_conf->lsc || intr_conf->rxq)
+	if (intr_conf->lsc || intr_conf->rxq) {
 		virtio_intr_disable(dev);
 
+		/* Reset interrupt callback  */
+		if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
+			rte_intr_callback_unregister(dev->intr_handle,
+						     virtio_interrupt_handler,
+						     dev);
+		}
+	}
+
 	hw->started = 0;
 	memset(&link, 0, sizeof(link));
 	rte_eth_linkstatus_set(dev, &link);