These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / scsi / bnx2fc / bnx2fc_fcoe.c
index 98d06d1..67405c6 100644 (file)
@@ -1,10 +1,10 @@
-/* bnx2fc_fcoe.c: QLogic NetXtreme II Linux FCoE offload driver.
+/* bnx2fc_fcoe.c: QLogic Linux FCoE offload driver.
  * This file contains the code that interacts with libfc, libfcoe,
  * cnic modules to create FCoE instances, send/receive non-offloaded
  * FIP/FCoE packets, listen to link events etc.
  *
- * Copyright (c) 2008 - 2013 Broadcom Corporation
- * Copyright (c) 2014, QLogic Corporation
+ * Copyright (c) 2008-2013 Broadcom Corporation
+ * Copyright (c) 2014-2015 QLogic Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,16 +23,16 @@ DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu);
 
 #define DRV_MODULE_NAME                "bnx2fc"
 #define DRV_MODULE_VERSION     BNX2FC_VERSION
-#define DRV_MODULE_RELDATE     "Dec 11, 2013"
+#define DRV_MODULE_RELDATE     "October 15, 2015"
 
 
 static char version[] =
-               "QLogic NetXtreme II FCoE Driver " DRV_MODULE_NAME \
+               "QLogic FCoE Driver " DRV_MODULE_NAME \
                " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
 
 
 MODULE_AUTHOR("Bhanu Prakash Gollapudi <bprakash@broadcom.com>");
-MODULE_DESCRIPTION("QLogic NetXtreme II BCM57710 FCoE Driver");
+MODULE_DESCRIPTION("QLogic FCoE Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_MODULE_VERSION);
 
@@ -856,7 +856,6 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event,
                return;
 
        default:
-               printk(KERN_ERR PFX "Unknown netevent %ld", event);
                return;
        }
 
@@ -2051,9 +2050,49 @@ static int bnx2fc_disable(struct net_device *netdev)
        return rc;
 }
 
+static uint bnx2fc_npiv_create_vports(struct fc_lport *lport,
+                                     struct cnic_fc_npiv_tbl *npiv_tbl)
+{
+       struct fc_vport_identifiers vpid;
+       uint i, created = 0;
+
+       if (npiv_tbl->count > MAX_NPIV_ENTRIES) {
+               BNX2FC_HBA_DBG(lport, "Exceeded count max of npiv table\n");
+               goto done;
+       }
+
+       /* Sanity check the first entry to make sure it's not 0 */
+       if (wwn_to_u64(npiv_tbl->wwnn[0]) == 0 &&
+           wwn_to_u64(npiv_tbl->wwpn[0]) == 0) {
+               BNX2FC_HBA_DBG(lport, "First NPIV table entries invalid.\n");
+               goto done;
+       }
+
+       vpid.roles = FC_PORT_ROLE_FCP_INITIATOR;
+       vpid.vport_type = FC_PORTTYPE_NPIV;
+       vpid.disable = false;
+
+       for (i = 0; i < npiv_tbl->count; i++) {
+               vpid.node_name = wwn_to_u64(npiv_tbl->wwnn[i]);
+               vpid.port_name = wwn_to_u64(npiv_tbl->wwpn[i]);
+               scnprintf(vpid.symbolic_name, sizeof(vpid.symbolic_name),
+                   "NPIV[%u]:%016llx-%016llx",
+                   created, vpid.port_name, vpid.node_name);
+               if (fc_vport_create(lport->host, 0, &vpid))
+                       created++;
+               else
+                       BNX2FC_HBA_DBG(lport, "Failed to create vport\n");
+       }
+done:
+       return created;
+}
+
 static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
 {
        struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
+       struct bnx2fc_hba *hba;
+       struct cnic_fc_npiv_tbl *npiv_tbl;
+       struct fc_lport *lport;
 
        if (interface->enabled == false) {
                if (!ctlr->lp) {
@@ -2064,6 +2103,37 @@ static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
                        interface->enabled = true;
                }
        }
+
+       /* Create static NPIV ports if any are contained in NVRAM */
+       hba = interface->hba;
+       lport = ctlr->lp;
+
+       if (!hba)
+               goto done;
+
+       if (!hba->cnic)
+               goto done;
+
+       if (!lport)
+               goto done;
+
+       if (!lport->host)
+               goto done;
+
+       if (!hba->cnic->get_fc_npiv_tbl)
+               goto done;
+
+       npiv_tbl = kzalloc(sizeof(struct cnic_fc_npiv_tbl), GFP_KERNEL);
+       if (!npiv_tbl)
+               goto done;
+
+       if (hba->cnic->get_fc_npiv_tbl(hba->cnic, npiv_tbl))
+               goto done_free;
+
+       bnx2fc_npiv_create_vports(lport, npiv_tbl);
+done_free:
+       kfree(npiv_tbl);
+done:
        return 0;
 }
 
@@ -2797,7 +2867,6 @@ static struct scsi_host_template bnx2fc_shost_template = {
        .use_clustering         = ENABLE_CLUSTERING,
        .sg_tablesize           = BNX2FC_MAX_BDS_PER_CMD,
        .max_sectors            = 1024,
-       .use_blk_tags           = 1,
        .track_queue_depth      = 1,
 };