[SCSI] bnx2i: register given device with cnic if shost != NULL in ep_connect()
authorAnil Veerabhadrappa <anilgv@broadcom.com>
Thu, 9 Jul 2009 01:21:01 +0000 (18:21 -0700)
committerJames Bottomley <James.Bottomley@suse.de>
Sat, 22 Aug 2009 22:51:54 +0000 (17:51 -0500)
When using iface, bnx2i was unable to offload further connections after all
active sessions are logged out. bnx2i will unregister the device from cnic
when the last connection is torn down. Next call to ep_connect() will fail
because the device is not registered. This issue is not seen if shost == NULL
is passed to ep_connect() call because in that case bnx2i will registers all
known devices with cnic before doing a route look-up.  When shost != NULL,
bnx2i knows the device on which to offload the connection and has to register
this device before attempting to offload the connection

Signed-off-by: Anil Veerabhadrappa <anilgv@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Reviewed-by Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/bnx2i/bnx2i_init.c
drivers/scsi/bnx2i/bnx2i_iscsi.c

index fd78540ffc95f063c06a790145b5ad04412c809b..0c4210d48ee8a7d8932e0b1431c9ea4fb4c5b973 100644 (file)
@@ -185,14 +185,17 @@ void bnx2i_stop(void *handle)
  */
 void bnx2i_register_device(struct bnx2i_hba *hba)
 {
+       int rc;
+
        if (test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state) ||
            test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
                return;
        }
 
-       hba->cnic->register_device(hba->cnic, CNIC_ULP_ISCSI, hba);
+       rc = hba->cnic->register_device(hba->cnic, CNIC_ULP_ISCSI, hba);
 
-       set_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
+       if (!rc)
+               set_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
 }
 
 
index f7412196f2f8967579518fa7c85e82c72b3950b5..98148f3f3c63b63e0218937f011a2a48553ceabe 100644 (file)
@@ -1653,15 +1653,18 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
        struct iscsi_endpoint *ep;
        int rc = 0;
 
-       if (shost)
+       if (shost) {
                /* driver is given scsi host to work with */
                hba = iscsi_host_priv(shost);
-       else
+               /* Register the device with cnic if not already done so */
+               bnx2i_register_device(hba);
+       } else
                /*
                 * check if the given destination can be reached through
                 * a iscsi capable NetXtreme2 device
                 */
                hba = bnx2i_check_route(dst_addr);
+
        if (!hba) {
                rc = -ENOMEM;
                goto check_busy;