Commit 90c8014c authored by Nathan Fontenot's avatar Nathan Fontenot Committed by David S. Miller

ibmvnic: Replace is_closed with state field

Replace the is_closed flag in the ibmvnic adapter strcut with a
more comprehensive state field that tracks the current state of
the driver.
Signed-off-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfc32f29
...@@ -669,7 +669,9 @@ static int ibmvnic_open(struct net_device *netdev) ...@@ -669,7 +669,9 @@ static int ibmvnic_open(struct net_device *netdev)
struct ibmvnic_adapter *adapter = netdev_priv(netdev); struct ibmvnic_adapter *adapter = netdev_priv(netdev);
int i, rc; int i, rc;
if (adapter->is_closed) { adapter->state = VNIC_OPENING;
if (adapter->state == VNIC_CLOSED) {
rc = ibmvnic_init(adapter); rc = ibmvnic_init(adapter);
if (rc) if (rc)
return rc; return rc;
...@@ -704,7 +706,7 @@ static int ibmvnic_open(struct net_device *netdev) ...@@ -704,7 +706,7 @@ static int ibmvnic_open(struct net_device *netdev)
release_resources(adapter); release_resources(adapter);
} else { } else {
netif_tx_start_all_queues(netdev); netif_tx_start_all_queues(netdev);
adapter->is_closed = false; adapter->state = VNIC_OPEN;
} }
return rc; return rc;
...@@ -733,7 +735,7 @@ static int ibmvnic_close(struct net_device *netdev) ...@@ -733,7 +735,7 @@ static int ibmvnic_close(struct net_device *netdev)
int rc = 0; int rc = 0;
int i; int i;
adapter->closing = true; adapter->state = VNIC_CLOSING;
disable_sub_crqs(adapter); disable_sub_crqs(adapter);
if (adapter->napi) { if (adapter->napi) {
...@@ -748,8 +750,7 @@ static int ibmvnic_close(struct net_device *netdev) ...@@ -748,8 +750,7 @@ static int ibmvnic_close(struct net_device *netdev)
release_resources(adapter); release_resources(adapter);
adapter->is_closed = true; adapter->state = VNIC_CLOSED;
adapter->closing = false;
return rc; return rc;
} }
...@@ -1860,7 +1861,8 @@ static int pending_scrq(struct ibmvnic_adapter *adapter, ...@@ -1860,7 +1861,8 @@ static int pending_scrq(struct ibmvnic_adapter *adapter,
{ {
union sub_crq *entry = &scrq->msgs[scrq->cur]; union sub_crq *entry = &scrq->msgs[scrq->cur];
if (entry->generic.first & IBMVNIC_CRQ_CMD_RSP || adapter->closing) if (entry->generic.first & IBMVNIC_CRQ_CMD_RSP ||
adapter->state == VNIC_CLOSING)
return 1; return 1;
else else
return 0; return 0;
...@@ -3353,6 +3355,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) ...@@ -3353,6 +3355,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
return -ENOMEM; return -ENOMEM;
adapter = netdev_priv(netdev); adapter = netdev_priv(netdev);
adapter->state = VNIC_PROBING;
dev_set_drvdata(&dev->dev, netdev); dev_set_drvdata(&dev->dev, netdev);
adapter->vdev = dev; adapter->vdev = dev;
adapter->netdev = netdev; adapter->netdev = netdev;
...@@ -3380,7 +3383,6 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) ...@@ -3380,7 +3383,6 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
} }
netdev->mtu = adapter->req_mtu - ETH_HLEN; netdev->mtu = adapter->req_mtu - ETH_HLEN;
adapter->is_closed = false;
rc = register_netdev(netdev); rc = register_netdev(netdev);
if (rc) { if (rc) {
...@@ -3390,6 +3392,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) ...@@ -3390,6 +3392,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
} }
dev_info(&dev->dev, "ibmvnic registered\n"); dev_info(&dev->dev, "ibmvnic registered\n");
adapter->state = VNIC_PROBED;
return 0; return 0;
} }
...@@ -3398,12 +3401,15 @@ static int ibmvnic_remove(struct vio_dev *dev) ...@@ -3398,12 +3401,15 @@ static int ibmvnic_remove(struct vio_dev *dev)
struct net_device *netdev = dev_get_drvdata(&dev->dev); struct net_device *netdev = dev_get_drvdata(&dev->dev);
struct ibmvnic_adapter *adapter = netdev_priv(netdev); struct ibmvnic_adapter *adapter = netdev_priv(netdev);
adapter->state = VNIC_REMOVING;
unregister_netdev(netdev); unregister_netdev(netdev);
release_resources(adapter); release_resources(adapter);
release_sub_crqs(adapter); release_sub_crqs(adapter);
release_crq_queue(adapter); release_crq_queue(adapter);
adapter->state = VNIC_REMOVED;
free_netdev(netdev); free_netdev(netdev);
dev_set_drvdata(&dev->dev, NULL); dev_set_drvdata(&dev->dev, NULL);
......
...@@ -913,6 +913,15 @@ struct ibmvnic_error_buff { ...@@ -913,6 +913,15 @@ struct ibmvnic_error_buff {
__be32 error_id; __be32 error_id;
}; };
enum vnic_state {VNIC_PROBING = 1,
VNIC_PROBED,
VNIC_OPENING,
VNIC_OPEN,
VNIC_CLOSING,
VNIC_CLOSED,
VNIC_REMOVING,
VNIC_REMOVED};
struct ibmvnic_adapter { struct ibmvnic_adapter {
struct vio_dev *vdev; struct vio_dev *vdev;
struct net_device *netdev; struct net_device *netdev;
...@@ -962,7 +971,6 @@ struct ibmvnic_adapter { ...@@ -962,7 +971,6 @@ struct ibmvnic_adapter {
u64 promisc; u64 promisc;
struct ibmvnic_tx_pool *tx_pool; struct ibmvnic_tx_pool *tx_pool;
bool closing;
struct completion init_done; struct completion init_done;
int init_done_rc; int init_done_rc;
...@@ -1011,5 +1019,5 @@ struct ibmvnic_adapter { ...@@ -1011,5 +1019,5 @@ struct ibmvnic_adapter {
struct work_struct ibmvnic_xport; struct work_struct ibmvnic_xport;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
bool failover; bool failover;
bool is_closed; enum vnic_state state;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment