diff --git a/modules/mqnic/mqnic.h b/modules/mqnic/mqnic.h index f7e331ede..dddd853c6 100644 --- a/modules/mqnic/mqnic.h +++ b/modules/mqnic/mqnic.h @@ -73,6 +73,8 @@ struct mqnic_dev { u8 __iomem *hw_addr; u8 __iomem *phc_hw_addr; + struct mutex state_lock; + u8 base_mac[ETH_ALEN]; char name[16]; diff --git a/modules/mqnic/mqnic_main.c b/modules/mqnic/mqnic_main.c index cb204a44d..4dd472b56 100644 --- a/modules/mqnic/mqnic_main.c +++ b/modules/mqnic/mqnic_main.c @@ -313,6 +313,8 @@ static int mqnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_save_state(pdev); + mutex_init(&mqnic->state_lock); + // probe complete return 0; diff --git a/modules/mqnic/mqnic_netdev.c b/modules/mqnic/mqnic_netdev.c index 7643f6066..2b6cb4cd0 100644 --- a/modules/mqnic/mqnic_netdev.c +++ b/modules/mqnic/mqnic_netdev.c @@ -33,7 +33,7 @@ either expressed or implied, of The Regents of the University of California. #include "mqnic.h" -static int mqnic_open(struct net_device *ndev) +static int mqnic_start_port(struct net_device *ndev) { struct mqnic_priv *priv = netdev_priv(ndev); struct mqnic_dev *mdev = priv->mdev; @@ -102,7 +102,7 @@ static int mqnic_open(struct net_device *ndev) return 0; } -static int mqnic_close(struct net_device *ndev) +static int mqnic_stop_port(struct net_device *ndev) { struct mqnic_priv *priv = netdev_priv(ndev); struct mqnic_dev *mdev = priv->mdev; @@ -183,6 +183,44 @@ static int mqnic_close(struct net_device *ndev) return 0; } +static int mqnic_open(struct net_device *ndev) +{ + struct mqnic_priv *priv = netdev_priv(ndev); + struct mqnic_dev *mdev = priv->mdev; + int ret = 0; + + mutex_lock(&mdev->state_lock); + + ret = mqnic_start_port(ndev); + + if (ret) + { + dev_err(&mdev->pdev->dev, "Failed to start port: %d", priv->port); + } + + mutex_unlock(&mdev->state_lock); + return ret; +} + +static int mqnic_close(struct net_device *ndev) +{ + struct mqnic_priv *priv = netdev_priv(ndev); + struct mqnic_dev *mdev = priv->mdev; + int ret = 0; + + mutex_lock(&mdev->state_lock); + + ret = mqnic_stop_port(ndev); + + if (ret) + { + dev_err(&mdev->pdev->dev, "Failed to stop port: %d", priv->port); + } + + mutex_unlock(&mdev->state_lock); + return ret; +} + void mqnic_update_stats(struct net_device *ndev) { struct mqnic_priv *priv = netdev_priv(ndev);