[SCSI] Merge tag 'fcoe-02-19-13' into for-linus
authorJames Bottomley <JBottomley@Parallels.com>
Fri, 1 Mar 2013 09:09:51 +0000 (09:09 +0000)
committerJames Bottomley <JBottomley@Parallels.com>
Fri, 1 Mar 2013 09:10:08 +0000 (09:10 +0000)
FCoE Updates for 3.9

Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1  2 
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/fcoe/fcoe_ctlr.c

@@@ -22,10 -22,10 +22,10 @@@ DEFINE_PER_CPU(struct bnx2fc_percpu_s, 
  
  #define DRV_MODULE_NAME               "bnx2fc"
  #define DRV_MODULE_VERSION    BNX2FC_VERSION
 -#define DRV_MODULE_RELDATE    "Jun 04, 2012"
 +#define DRV_MODULE_RELDATE    "Dec 21, 2012"
  
  
 -static char version[] __devinitdata =
 +static char version[] =
                "Broadcom NetXtreme II FCoE Driver " DRV_MODULE_NAME \
                " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
  
@@@ -62,6 -62,10 +62,10 @@@ static int bnx2fc_destroy(struct net_de
  static int bnx2fc_enable(struct net_device *netdev);
  static int bnx2fc_disable(struct net_device *netdev);
  
+ /* fcoe_syfs control interface handlers */
+ static int bnx2fc_ctlr_alloc(struct net_device *netdev);
+ static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev);
  static void bnx2fc_recv_frame(struct sk_buff *skb);
  
  static void bnx2fc_start_disc(struct bnx2fc_interface *interface);
@@@ -89,7 -93,6 +93,6 @@@ static void bnx2fc_port_shutdown(struc
  static void bnx2fc_stop(struct bnx2fc_interface *interface);
  static int __init bnx2fc_mod_init(void);
  static void __exit bnx2fc_mod_exit(void);
- static void bnx2fc_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev);
  
  unsigned int bnx2fc_debug_level;
  module_param_named(debug_logging, bnx2fc_debug_level, int, S_IRUGO|S_IWUSR);
@@@ -107,44 -110,6 +110,6 @@@ static inline struct net_device *bnx2fc
                ((struct fcoe_port *)lport_priv(lport))->priv)->netdev;
  }
  
- /**
-  * bnx2fc_get_lesb() - Fill the FCoE Link Error Status Block
-  * @lport: the local port
-  * @fc_lesb: the link error status block
-  */
- static void bnx2fc_get_lesb(struct fc_lport *lport,
-                           struct fc_els_lesb *fc_lesb)
- {
-       struct net_device *netdev = bnx2fc_netdev(lport);
-       __fcoe_get_lesb(lport, fc_lesb, netdev);
- }
- static void bnx2fc_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev)
- {
-       struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr_dev);
-       struct net_device *netdev = bnx2fc_netdev(fip->lp);
-       struct fcoe_fc_els_lesb *fcoe_lesb;
-       struct fc_els_lesb fc_lesb;
-       __fcoe_get_lesb(fip->lp, &fc_lesb, netdev);
-       fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb);
-       ctlr_dev->lesb.lesb_link_fail =
-               ntohl(fcoe_lesb->lesb_link_fail);
-       ctlr_dev->lesb.lesb_vlink_fail =
-               ntohl(fcoe_lesb->lesb_vlink_fail);
-       ctlr_dev->lesb.lesb_miss_fka =
-               ntohl(fcoe_lesb->lesb_miss_fka);
-       ctlr_dev->lesb.lesb_symb_err =
-               ntohl(fcoe_lesb->lesb_symb_err);
-       ctlr_dev->lesb.lesb_err_block =
-               ntohl(fcoe_lesb->lesb_err_block);
-       ctlr_dev->lesb.lesb_fcs_error =
-               ntohl(fcoe_lesb->lesb_fcs_error);
- }
- EXPORT_SYMBOL(bnx2fc_ctlr_get_lesb);
  static void bnx2fc_fcf_get_vlan_id(struct fcoe_fcf_device *fcf_dev)
  {
        struct fcoe_ctlr_device *ctlr_dev =
@@@ -687,16 -652,11 +652,16 @@@ static struct fc_host_statistics *bnx2f
                BNX2FC_HBA_DBG(lport, "FW stat req timed out\n");
                return bnx2fc_stats;
        }
 -      bnx2fc_stats->invalid_crc_count += fw_stats->rx_stat2.fc_crc_cnt;
 -      bnx2fc_stats->tx_frames += fw_stats->tx_stat.fcoe_tx_pkt_cnt;
 -      bnx2fc_stats->tx_words += (fw_stats->tx_stat.fcoe_tx_byte_cnt) / 4;
 -      bnx2fc_stats->rx_frames += fw_stats->rx_stat0.fcoe_rx_pkt_cnt;
 -      bnx2fc_stats->rx_words += (fw_stats->rx_stat0.fcoe_rx_byte_cnt) / 4;
 +      BNX2FC_STATS(hba, rx_stat2, fc_crc_cnt);
 +      bnx2fc_stats->invalid_crc_count += hba->bfw_stats.fc_crc_cnt;
 +      BNX2FC_STATS(hba, tx_stat, fcoe_tx_pkt_cnt);
 +      bnx2fc_stats->tx_frames += hba->bfw_stats.fcoe_tx_pkt_cnt;
 +      BNX2FC_STATS(hba, tx_stat, fcoe_tx_byte_cnt);
 +      bnx2fc_stats->tx_words += ((hba->bfw_stats.fcoe_tx_byte_cnt) / 4);
 +      BNX2FC_STATS(hba, rx_stat0, fcoe_rx_pkt_cnt);
 +      bnx2fc_stats->rx_frames += hba->bfw_stats.fcoe_rx_pkt_cnt;
 +      BNX2FC_STATS(hba, rx_stat0, fcoe_rx_byte_cnt);
 +      bnx2fc_stats->rx_words += ((hba->bfw_stats.fcoe_rx_byte_cnt) / 4);
  
        bnx2fc_stats->dumped_frames = 0;
        bnx2fc_stats->lip_count = 0;
        bnx2fc_stats->loss_of_signal_count = 0;
        bnx2fc_stats->prim_seq_protocol_err_count = 0;
  
 +      memcpy(&hba->prev_stats, hba->stats_buffer,
 +             sizeof(struct fcoe_statistics_params));
        return bnx2fc_stats;
  }
  
@@@ -741,35 -699,6 +706,6 @@@ static int bnx2fc_shost_config(struct f
        return 0;
  }
  
- static void bnx2fc_link_speed_update(struct fc_lport *lport)
- {
-       struct fcoe_port *port = lport_priv(lport);
-       struct bnx2fc_interface *interface = port->priv;
-       struct net_device *netdev = interface->netdev;
-       struct ethtool_cmd ecmd;
-       if (!__ethtool_get_settings(netdev, &ecmd)) {
-               lport->link_supported_speeds &=
-                       ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
-               if (ecmd.supported & (SUPPORTED_1000baseT_Half |
-                                     SUPPORTED_1000baseT_Full))
-                       lport->link_supported_speeds |= FC_PORTSPEED_1GBIT;
-               if (ecmd.supported & SUPPORTED_10000baseT_Full)
-                       lport->link_supported_speeds |= FC_PORTSPEED_10GBIT;
-               switch (ethtool_cmd_speed(&ecmd)) {
-               case SPEED_1000:
-                       lport->link_speed = FC_PORTSPEED_1GBIT;
-                       break;
-               case SPEED_2500:
-                       lport->link_speed = FC_PORTSPEED_2GBIT;
-                       break;
-               case SPEED_10000:
-                       lport->link_speed = FC_PORTSPEED_10GBIT;
-                       break;
-               }
-       }
- }
  static int bnx2fc_link_ok(struct fc_lport *lport)
  {
        struct fcoe_port *port = lport_priv(lport);
@@@ -827,7 -756,7 +763,7 @@@ static int bnx2fc_net_config(struct fc_
        port->fcoe_pending_queue_active = 0;
        setup_timer(&port->timer, fcoe_queue_timer, (unsigned long) lport);
  
-       bnx2fc_link_speed_update(lport);
+       fcoe_link_speed_update(lport);
  
        if (!lport->vport) {
                if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
@@@ -871,6 -800,7 +807,7 @@@ static void bnx2fc_indicate_netevent(vo
                                     u16 vlan_id)
  {
        struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context;
+       struct fcoe_ctlr_device *cdev;
        struct fc_lport *lport;
        struct fc_lport *vport;
        struct bnx2fc_interface *interface, *tmp;
                BNX2FC_HBA_DBG(lport, "netevent handler - event=%s %ld\n",
                                interface->netdev->name, event);
  
-               bnx2fc_link_speed_update(lport);
+               fcoe_link_speed_update(lport);
+               cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
  
                if (link_possible && !bnx2fc_link_ok(lport)) {
-                       /* Reset max recv frame size to default */
-                       fc_set_mfs(lport, BNX2FC_MFS);
-                       /*
-                        * ctlr link up will only be handled during
-                        * enable to avoid sending discovery solicitation
-                        * on a stale vlan
-                        */
-                       if (interface->enabled)
-                               fcoe_ctlr_link_up(ctlr);
+                       switch (cdev->enabled) {
+                       case FCOE_CTLR_DISABLED:
+                               pr_info("Link up while interface is disabled.\n");
+                               break;
+                       case FCOE_CTLR_ENABLED:
+                       case FCOE_CTLR_UNUSED:
+                               /* Reset max recv frame size to default */
+                               fc_set_mfs(lport, BNX2FC_MFS);
+                               /*
+                                * ctlr link up will only be handled during
+                                * enable to avoid sending discovery
+                                * solicitation on a stale vlan
+                                */
+                               if (interface->enabled)
+                                       fcoe_ctlr_link_up(ctlr);
+                       };
                } else if (fcoe_ctlr_link_down(ctlr)) {
-                       mutex_lock(&lport->lp_mutex);
-                       list_for_each_entry(vport, &lport->vports, list)
-                               fc_host_port_type(vport->host) =
-                                                       FC_PORTTYPE_UNKNOWN;
-                       mutex_unlock(&lport->lp_mutex);
-                       fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN;
-                       per_cpu_ptr(lport->stats,
-                                   get_cpu())->LinkFailureCount++;
-                       put_cpu();
-                       fcoe_clean_pending_queue(lport);
-                       wait_for_upload = 1;
+                       switch (cdev->enabled) {
+                       case FCOE_CTLR_DISABLED:
+                               pr_info("Link down while interface is disabled.\n");
+                               break;
+                       case FCOE_CTLR_ENABLED:
+                       case FCOE_CTLR_UNUSED:
+                               mutex_lock(&lport->lp_mutex);
+                               list_for_each_entry(vport, &lport->vports, list)
+                                       fc_host_port_type(vport->host) =
+                                       FC_PORTTYPE_UNKNOWN;
+                               mutex_unlock(&lport->lp_mutex);
+                               fc_host_port_type(lport->host) =
+                                       FC_PORTTYPE_UNKNOWN;
+                               per_cpu_ptr(lport->stats,
+                                           get_cpu())->LinkFailureCount++;
+                               put_cpu();
+                               fcoe_clean_pending_queue(lport);
+                               wait_for_upload = 1;
+                       };
                }
        }
        mutex_unlock(&bnx2fc_dev_lock);
@@@ -1484,6 -1431,7 +1438,7 @@@ static struct fc_lport *bnx2fc_if_creat
        port = lport_priv(lport);
        port->lport = lport;
        port->priv = interface;
+       port->get_netdev = bnx2fc_netdev;
        INIT_WORK(&port->destroy_work, bnx2fc_destroy_work);
  
        /* Configure fcoe_port */
@@@ -2003,7 -1951,9 +1958,9 @@@ static void bnx2fc_ulp_init(struct cnic
                set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
  }
  
+ /**
+  * Deperecated: Use bnx2fc_enabled()
+  */
  static int bnx2fc_disable(struct net_device *netdev)
  {
        struct bnx2fc_interface *interface;
        return rc;
  }
  
+ /**
+  * Deprecated: Use bnx2fc_enabled()
+  */
  static int bnx2fc_enable(struct net_device *netdev)
  {
        struct bnx2fc_interface *interface;
  }
  
  /**
-  * bnx2fc_create - Create bnx2fc FCoE interface
+  * bnx2fc_ctlr_enabled() - Enable or disable an FCoE Controller
+  * @cdev: The FCoE Controller that is being enabled or disabled
+  *
+  * fcoe_sysfs will ensure that the state of 'enabled' has
+  * changed, so no checking is necessary here. This routine simply
+  * calls fcoe_enable or fcoe_disable, both of which are deprecated.
+  * When those routines are removed the functionality can be merged
+  * here.
+  */
+ static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device *cdev)
+ {
+       struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(cdev);
+       struct fc_lport *lport = ctlr->lp;
+       struct net_device *netdev = bnx2fc_netdev(lport);
+       switch (cdev->enabled) {
+       case FCOE_CTLR_ENABLED:
+               return bnx2fc_enable(netdev);
+       case FCOE_CTLR_DISABLED:
+               return bnx2fc_disable(netdev);
+       case FCOE_CTLR_UNUSED:
+       default:
+               return -ENOTSUPP;
+       };
+ }
+ enum bnx2fc_create_link_state {
+       BNX2FC_CREATE_LINK_DOWN,
+       BNX2FC_CREATE_LINK_UP,
+ };
+ /**
+  * _bnx2fc_create() - Create bnx2fc FCoE interface
+  * @netdev  :   The net_device object the Ethernet interface to create on
+  * @fip_mode:   The FIP mode for this creation
+  * @link_state: The ctlr link state on creation
   *
-  * @buffer: The name of Ethernet interface to create on
-  * @kp:     The associated kernel param
+  * Called from either the libfcoe 'create' module parameter
+  * via fcoe_create or from fcoe_syfs's ctlr_create file.
   *
-  * Called from sysfs.
+  * libfcoe's 'create' module parameter is deprecated so some
+  * consolidation of code can be done when that interface is
+  * removed.
   *
   * Returns: 0 for success
   */
- static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
+ static int _bnx2fc_create(struct net_device *netdev,
+                         enum fip_state fip_mode,
+                         enum bnx2fc_create_link_state link_state)
  {
+       struct fcoe_ctlr_device *cdev;
        struct fcoe_ctlr *ctlr;
        struct bnx2fc_interface *interface;
        struct bnx2fc_hba *hba;
        /* Make this master N_port */
        ctlr->lp = lport;
  
-       if (!bnx2fc_link_ok(lport)) {
+       cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
+       if (link_state == BNX2FC_CREATE_LINK_UP)
+               cdev->enabled = FCOE_CTLR_ENABLED;
+       else
+               cdev->enabled = FCOE_CTLR_DISABLED;
+       if (link_state == BNX2FC_CREATE_LINK_UP &&
+           !bnx2fc_link_ok(lport)) {
                fcoe_ctlr_link_up(ctlr);
                fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT;
                set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
  
        BNX2FC_HBA_DBG(lport, "create: START DISC\n");
        bnx2fc_start_disc(interface);
-       interface->enabled = true;
+       if (link_state == BNX2FC_CREATE_LINK_UP)
+               interface->enabled = true;
        /*
         * Release from kref_init in bnx2fc_interface_setup, on success
         * lport should be holding a reference taken in bnx2fc_if_create
@@@ -2194,6 -2197,37 +2204,37 @@@ mod_err
  }
  
  /**
+  * bnx2fc_create() - Create a bnx2fc interface
+  * @netdev  : The net_device object the Ethernet interface to create on
+  * @fip_mode: The FIP mode for this creation
+  *
+  * Called from fcoe transport
+  *
+  * Returns: 0 for success
+  */
+ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode)
+ {
+       return _bnx2fc_create(netdev, fip_mode, BNX2FC_CREATE_LINK_UP);
+ }
+ /**
+  * bnx2fc_ctlr_alloc() - Allocate a bnx2fc interface from fcoe_sysfs
+  * @netdev: The net_device to be used by the allocated FCoE Controller
+  *
+  * This routine is called from fcoe_sysfs. It will start the fcoe_ctlr
+  * in a link_down state. The allows the user an opportunity to configure
+  * the FCoE Controller from sysfs before enabling the FCoE Controller.
+  *
+  * Creating in with this routine starts the FCoE Controller in Fabric
+  * mode. The user can change to VN2VN or another mode before enabling.
+  */
+ static int bnx2fc_ctlr_alloc(struct net_device *netdev)
+ {
+       return _bnx2fc_create(netdev, FIP_MODE_FABRIC,
+                             BNX2FC_CREATE_LINK_DOWN);
+ }
+ /**
   * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
   *
   * @cnic:     Pointer to cnic device instance
@@@ -2318,6 -2352,7 +2359,7 @@@ static struct fcoe_transport bnx2fc_tra
        .name = {"bnx2fc"},
        .attached = false,
        .list = LIST_HEAD_INIT(bnx2fc_transport.list),
+       .alloc = bnx2fc_ctlr_alloc,
        .match = bnx2fc_match,
        .create = bnx2fc_create,
        .destroy = bnx2fc_destroy,
@@@ -2562,13 -2597,13 +2604,13 @@@ module_init(bnx2fc_mod_init)
  module_exit(bnx2fc_mod_exit);
  
  static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = {
-       .get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode,
-       .get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb,
-       .get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb,
-       .get_fcoe_ctlr_miss_fka = bnx2fc_ctlr_get_lesb,
-       .get_fcoe_ctlr_symb_err = bnx2fc_ctlr_get_lesb,
-       .get_fcoe_ctlr_err_block = bnx2fc_ctlr_get_lesb,
-       .get_fcoe_ctlr_fcs_error = bnx2fc_ctlr_get_lesb,
+       .set_fcoe_ctlr_enabled = bnx2fc_ctlr_enabled,
+       .get_fcoe_ctlr_link_fail = fcoe_ctlr_get_lesb,
+       .get_fcoe_ctlr_vlink_fail = fcoe_ctlr_get_lesb,
+       .get_fcoe_ctlr_miss_fka = fcoe_ctlr_get_lesb,
+       .get_fcoe_ctlr_symb_err = fcoe_ctlr_get_lesb,
+       .get_fcoe_ctlr_err_block = fcoe_ctlr_get_lesb,
+       .get_fcoe_ctlr_fcs_error = fcoe_ctlr_get_lesb,
  
        .get_fcoe_fcf_selected = fcoe_fcf_get_selected,
        .get_fcoe_fcf_vlan_id = bnx2fc_fcf_get_vlan_id,
@@@ -2667,7 -2702,7 +2709,7 @@@ static struct scsi_host_template bnx2fc
        .can_queue              = BNX2FC_CAN_QUEUE,
        .use_clustering         = ENABLE_CLUSTERING,
        .sg_tablesize           = BNX2FC_MAX_BDS_PER_CMD,
 -      .max_sectors            = 512,
 +      .max_sectors            = 1024,
  };
  
  static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
        .elsct_send             = bnx2fc_elsct_send,
        .fcp_abort_io           = bnx2fc_abort_io,
        .fcp_cleanup            = bnx2fc_cleanup,
-       .get_lesb               = bnx2fc_get_lesb,
+       .get_lesb               = fcoe_get_lesb,
        .rport_event_callback   = bnx2fc_rport_event_handler,
  };
  
@@@ -1291,8 -1291,16 +1291,16 @@@ static void fcoe_ctlr_recv_clr_vlink(st
  
        LIBFCOE_FIP_DBG(fip, "Clear Virtual Link received\n");
  
-       if (!fcf || !lport->port_id)
+       if (!fcf || !lport->port_id) {
+               /*
+                * We are yet to select best FCF, but we got CVL in the
+                * meantime. reset the ctlr and let it rediscover the FCF
+                */
+               mutex_lock(&fip->ctlr_mutex);
+               fcoe_ctlr_reset(fip);
+               mutex_unlock(&fip->ctlr_mutex);
                return;
+       }
  
        /*
         * mask of required descriptors.  Validating each one clears its bit.
@@@ -1551,15 -1559,6 +1559,6 @@@ static struct fcoe_fcf *fcoe_ctlr_selec
                                fcf->fabric_name, fcf->vfid, fcf->fcf_mac,
                                fcf->fc_map, fcoe_ctlr_mtu_valid(fcf),
                                fcf->flogi_sent, fcf->pri);
-               if (fcf->fabric_name != first->fabric_name ||
-                   fcf->vfid != first->vfid ||
-                   fcf->fc_map != first->fc_map) {
-                       LIBFCOE_FIP_DBG(fip, "Conflicting fabric, VFID, "
-                                       "or FC-MAP\n");
-                       return NULL;
-               }
-               if (fcf->flogi_sent)
-                       continue;
                if (!fcoe_ctlr_fcf_usable(fcf)) {
                        LIBFCOE_FIP_DBG(fip, "FCF for fab %16.16llx "
                                        "map %x %svalid %savailable\n",
                                        "" : "un");
                        continue;
                }
+               if (fcf->fabric_name != first->fabric_name ||
+                   fcf->vfid != first->vfid ||
+                   fcf->fc_map != first->fc_map) {
+                       LIBFCOE_FIP_DBG(fip, "Conflicting fabric, VFID, "
+                                       "or FC-MAP\n");
+                       return NULL;
+               }
+               if (fcf->flogi_sent)
+                       continue;
                if (!best || fcf->pri < best->pri || best->flogi_sent)
                        best = fcf;
        }
@@@ -2144,7 -2152,7 +2152,7 @@@ static void fcoe_ctlr_vn_restart(struc
         */
        port_id = fip->port_id;
        if (fip->probe_tries)
 -              port_id = prandom32(&fip->rnd_state) & 0xffff;
 +              port_id = prandom_u32_state(&fip->rnd_state) & 0xffff;
        else if (!port_id)
                port_id = fip->lp->wwpn & 0xffff;
        if (!port_id || port_id == 0xffff)
  static void fcoe_ctlr_vn_start(struct fcoe_ctlr *fip)
  {
        fip->probe_tries = 0;
 -      prandom32_seed(&fip->rnd_state, fip->lp->wwpn);
 +      prandom_seed_state(&fip->rnd_state, fip->lp->wwpn);
        fcoe_ctlr_vn_restart(fip);
  }
  
@@@ -2864,22 -2872,21 +2872,21 @@@ void fcoe_fcf_get_selected(struct fcoe_
  }
  EXPORT_SYMBOL(fcoe_fcf_get_selected);
  
- void fcoe_ctlr_get_fip_mode(struct fcoe_ctlr_device *ctlr_dev)
+ void fcoe_ctlr_set_fip_mode(struct fcoe_ctlr_device *ctlr_dev)
  {
        struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
  
        mutex_lock(&ctlr->ctlr_mutex);
-       switch (ctlr->mode) {
-       case FIP_MODE_FABRIC:
-               ctlr_dev->mode = FIP_CONN_TYPE_FABRIC;
-               break;
-       case FIP_MODE_VN2VN:
-               ctlr_dev->mode = FIP_CONN_TYPE_VN2VN;
+       switch (ctlr_dev->mode) {
+       case FIP_CONN_TYPE_VN2VN:
+               ctlr->mode = FIP_MODE_VN2VN;
                break;
+       case FIP_CONN_TYPE_FABRIC:
        default:
-               ctlr_dev->mode = FIP_CONN_TYPE_UNKNOWN;
+               ctlr->mode = FIP_MODE_FABRIC;
                break;
        }
        mutex_unlock(&ctlr->ctlr_mutex);
  }
- EXPORT_SYMBOL(fcoe_ctlr_get_fip_mode);
+ EXPORT_SYMBOL(fcoe_ctlr_set_fip_mode);