aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bnx2fc
diff options
context:
space:
mode:
authorBhanu Prakash Gollapudi <bprakash@broadcom.com>2011-08-04 20:38:41 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-08-27 10:35:33 -0400
commit9be17fc43e0121e966049a323ad38a35626525c1 (patch)
treea95ba5a7ce9e24186ee19a4decf6bc644e291741 /drivers/scsi/bnx2fc
parent776cebcac6fad2f638c0ab16e2111a84c1c85d84 (diff)
[SCSI] bnx2fc: Reorganize cleanup code between interface_cleanup and if_destory
Move interface specific cleanup functionality to from bnx2fc_if_destroy to bnx2fc_interface_cleanup. Do not access interface/hba in bnx2fc_if_destroy as by the time this function is called interface may already be destroyed. This patch is in preparation to handle NETDEV_UNREGISTER on a vlan device. Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bnx2fc')
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 407a9b841d4..673c97c31b9 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -1384,16 +1384,10 @@ free_blport:
1384 1384
1385static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface) 1385static void bnx2fc_interface_cleanup(struct bnx2fc_interface *interface)
1386{ 1386{
1387 /* Dont listen for Ethernet packets anymore */ 1387 struct fc_lport *lport = interface->ctlr.lp;
1388 __dev_remove_pack(&interface->fcoe_packet_type);
1389 __dev_remove_pack(&interface->fip_packet_type);
1390 synchronize_net();
1391}
1392
1393static void bnx2fc_if_destroy(struct fc_lport *lport, struct bnx2fc_hba *hba)
1394{
1395 struct fcoe_port *port = lport_priv(lport); 1388 struct fcoe_port *port = lport_priv(lport);
1396 struct bnx2fc_lport *blport, *tmp; 1389 struct bnx2fc_lport *blport, *tmp;
1390 struct bnx2fc_hba *hba = interface->hba;
1397 1391
1398 /* Stop the transmit retry timer */ 1392 /* Stop the transmit retry timer */
1399 del_timer_sync(&port->timer); 1393 del_timer_sync(&port->timer);
@@ -1401,6 +1395,24 @@ static void bnx2fc_if_destroy(struct fc_lport *lport, struct bnx2fc_hba *hba)
1401 /* Free existing transmit skbs */ 1395 /* Free existing transmit skbs */
1402 fcoe_clean_pending_queue(lport); 1396 fcoe_clean_pending_queue(lport);
1403 1397
1398 /* Dont listen for Ethernet packets anymore */
1399 __dev_remove_pack(&interface->fcoe_packet_type);
1400 __dev_remove_pack(&interface->fip_packet_type);
1401 synchronize_net();
1402
1403 spin_lock_bh(&hba->hba_lock);
1404 list_for_each_entry_safe(blport, tmp, &hba->vports, list) {
1405 if (blport->lport == lport) {
1406 list_del(&blport->list);
1407 kfree(blport);
1408 }
1409 }
1410 spin_unlock_bh(&hba->hba_lock);
1411}
1412
1413static void bnx2fc_if_destroy(struct fc_lport *lport)
1414{
1415
1404 /* Free queued packets for the receive thread */ 1416 /* Free queued packets for the receive thread */
1405 bnx2fc_clean_rx_queue(lport); 1417 bnx2fc_clean_rx_queue(lport);
1406 1418
@@ -1417,15 +1429,6 @@ static void bnx2fc_if_destroy(struct fc_lport *lport, struct bnx2fc_hba *hba)
1417 /* Free memory used by statistical counters */ 1429 /* Free memory used by statistical counters */
1418 fc_lport_free_stats(lport); 1430 fc_lport_free_stats(lport);
1419 1431
1420 spin_lock_bh(&hba->hba_lock);
1421 list_for_each_entry_safe(blport, tmp, &hba->vports, list) {
1422 if (blport->lport == lport) {
1423 list_del(&blport->list);
1424 kfree(blport);
1425 }
1426 }
1427 spin_unlock_bh(&hba->hba_lock);
1428
1429 /* Release Scsi_Host */ 1432 /* Release Scsi_Host */
1430 scsi_host_put(lport->host); 1433 scsi_host_put(lport->host);
1431} 1434}
@@ -1443,7 +1446,6 @@ static void bnx2fc_if_destroy(struct fc_lport *lport, struct bnx2fc_hba *hba)
1443static int bnx2fc_destroy(struct net_device *netdev) 1446static int bnx2fc_destroy(struct net_device *netdev)
1444{ 1447{
1445 struct bnx2fc_interface *interface = NULL; 1448 struct bnx2fc_interface *interface = NULL;
1446 struct bnx2fc_hba *hba;
1447 struct fc_lport *lport; 1449 struct fc_lport *lport;
1448 int rc = 0; 1450 int rc = 0;
1449 1451
@@ -1457,7 +1459,6 @@ static int bnx2fc_destroy(struct net_device *netdev)
1457 goto netdev_err; 1459 goto netdev_err;
1458 } 1460 }
1459 1461
1460 hba = interface->hba;
1461 1462
1462 bnx2fc_interface_cleanup(interface); 1463 bnx2fc_interface_cleanup(interface);
1463 lport = interface->ctlr.lp; 1464 lport = interface->ctlr.lp;
@@ -1465,7 +1466,7 @@ static int bnx2fc_destroy(struct net_device *netdev)
1465 list_del(&interface->list); 1466 list_del(&interface->list);
1466 destroy_workqueue(interface->timer_work_queue); 1467 destroy_workqueue(interface->timer_work_queue);
1467 bnx2fc_interface_put(interface); 1468 bnx2fc_interface_put(interface);
1468 bnx2fc_if_destroy(lport, hba); 1469 bnx2fc_if_destroy(lport);
1469 1470
1470netdev_err: 1471netdev_err:
1471 mutex_unlock(&bnx2fc_dev_lock); 1472 mutex_unlock(&bnx2fc_dev_lock);
@@ -1478,19 +1479,17 @@ static void bnx2fc_destroy_work(struct work_struct *work)
1478 struct fcoe_port *port; 1479 struct fcoe_port *port;
1479 struct fc_lport *lport; 1480 struct fc_lport *lport;
1480 struct bnx2fc_interface *interface; 1481 struct bnx2fc_interface *interface;
1481 struct bnx2fc_hba *hba;
1482 1482
1483 port = container_of(work, struct fcoe_port, destroy_work); 1483 port = container_of(work, struct fcoe_port, destroy_work);
1484 lport = port->lport; 1484 lport = port->lport;
1485 interface = port->priv; 1485 interface = port->priv;
1486 hba = interface->hba;
1487 1486
1488 BNX2FC_HBA_DBG(lport, "Entered bnx2fc_destroy_work\n"); 1487 BNX2FC_HBA_DBG(lport, "Entered bnx2fc_destroy_work\n");
1489 1488
1490 bnx2fc_port_shutdown(lport); 1489 bnx2fc_port_shutdown(lport);
1491 rtnl_lock(); 1490 rtnl_lock();
1492 mutex_lock(&bnx2fc_dev_lock); 1491 mutex_lock(&bnx2fc_dev_lock);
1493 bnx2fc_if_destroy(lport, hba); 1492 bnx2fc_if_destroy(lport);
1494 mutex_unlock(&bnx2fc_dev_lock); 1493 mutex_unlock(&bnx2fc_dev_lock);
1495 rtnl_unlock(); 1494 rtnl_unlock();
1496} 1495}
@@ -2063,7 +2062,7 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev)
2063 list_del(&interface->list); 2062 list_del(&interface->list);
2064 lport = interface->ctlr.lp; 2063 lport = interface->ctlr.lp;
2065 bnx2fc_interface_put(interface); 2064 bnx2fc_interface_put(interface);
2066 bnx2fc_if_destroy(lport, hba); 2065 bnx2fc_if_destroy(lport);
2067 } 2066 }
2068 } 2067 }
2069 mutex_unlock(&bnx2fc_dev_lock); 2068 mutex_unlock(&bnx2fc_dev_lock);