[SCSI] bfa: Add support to configure min/max bandwidth for a pcifn
authorKrishna Gudipati <kgudipat@brocade.com>
Sat, 22 Sep 2012 00:26:50 +0000 (17:26 -0700)
committerJames Bottomley <JBottomley@Parallels.com>
Sun, 7 Oct 2012 10:23:20 +0000 (11:23 +0100)
- Added support to configure minimum bandwidth for a pcifn.
- Minimum bandwith is guaranteed at per queue level.
- Added support to update pcifn bandwidth dynamically without
  a server reboot.

Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/bfa/bfa_core.c
drivers/scsi/bfa/bfa_defs.h
drivers/scsi/bfa/bfa_ioc.c
drivers/scsi/bfa/bfa_ioc.h
drivers/scsi/bfa/bfad_bsg.c
drivers/scsi/bfa/bfad_bsg.h
drivers/scsi/bfa/bfi.h

index eb296286c37e03de7da06e83eee22ea6980fe281..89ebd4459bfc037472cfa5d5b5de7901ec25d0c2 100644 (file)
@@ -838,19 +838,20 @@ void
 bfa_isr_enable(struct bfa_s *bfa)
 {
        u32 umsk;
-       int pci_func = bfa_ioc_pcifn(&bfa->ioc);
+       int port_id = bfa_ioc_portid(&bfa->ioc);
 
-       bfa_trc(bfa, pci_func);
+       bfa_trc(bfa, bfa_ioc_pcifn(&bfa->ioc));
+       bfa_trc(bfa, port_id);
 
        bfa_msix_ctrl_install(bfa);
 
        if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) {
                umsk = __HFN_INT_ERR_MASK_CT2;
-               umsk |= pci_func == 0 ?
+               umsk |= port_id == 0 ?
                        __HFN_INT_FN0_MASK_CT2 : __HFN_INT_FN1_MASK_CT2;
        } else {
                umsk = __HFN_INT_ERR_MASK;
-               umsk |= pci_func == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK;
+               umsk |= port_id == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK;
        }
 
        writel(umsk, bfa->iocfc.bfa_regs.intr_status);
index f8df2c94978659a12c8c6f0a0104cfe7d176c84b..f0b251e928bffdba6817c00716f5be58aa7f4889 100644 (file)
@@ -190,6 +190,7 @@ enum bfa_status {
        BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
        BFA_STATUS_LOOP_UNSUPP_MEZZ = 231, /* Loop topology is not supported
                                            * on mezz cards */
+       BFA_STATUS_INVALID_BW = 233,    /* Invalid bandwidth value */
        BFA_STATUS_QOS_BW_INVALID = 234,   /* Invalid QOS bandwidth
                                            * configuration */
        BFA_STATUS_DPORT_ENABLED = 235, /* D-port mode is already enabled */
@@ -749,7 +750,8 @@ struct bfa_ablk_cfg_pf_s {
        u8      rsvd[1];
        u16     num_qpairs;
        u16     num_vectors;
-       u32     bw;
+       u16     bw_min;
+       u16     bw_max;
 };
 
 struct bfa_ablk_cfg_port_s {
index 4fbff0394985313945c39de78dff598b13f66157..c697890eeca8c680d8834fcf407f826b1ac0a375 100644 (file)
@@ -3019,7 +3019,6 @@ bfa_ablk_config_swap(struct bfa_ablk_cfg_s *cfg)
        struct bfa_ablk_cfg_inst_s *cfg_inst;
        int i, j;
        u16     be16;
-       u32     be32;
 
        for (i = 0; i < BFA_ABLK_MAX; i++) {
                cfg_inst = &cfg->inst[i];
@@ -3030,8 +3029,10 @@ bfa_ablk_config_swap(struct bfa_ablk_cfg_s *cfg)
                        cfg_inst->pf_cfg[j].num_qpairs = be16_to_cpu(be16);
                        be16 = cfg_inst->pf_cfg[j].num_vectors;
                        cfg_inst->pf_cfg[j].num_vectors = be16_to_cpu(be16);
-                       be32 = cfg_inst->pf_cfg[j].bw;
-                       cfg_inst->pf_cfg[j].bw = be16_to_cpu(be32);
+                       be16 = cfg_inst->pf_cfg[j].bw_min;
+                       cfg_inst->pf_cfg[j].bw_min = be16_to_cpu(be16);
+                       be16 = cfg_inst->pf_cfg[j].bw_max;
+                       cfg_inst->pf_cfg[j].bw_max = be16_to_cpu(be16);
                }
        }
 }
@@ -3173,7 +3174,8 @@ bfa_ablk_query(struct bfa_ablk_s *ablk, struct bfa_ablk_cfg_s *ablk_cfg,
 
 bfa_status_t
 bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
-               u8 port, enum bfi_pcifn_class personality, int bw,
+               u8 port, enum bfi_pcifn_class personality,
+               u16 bw_min, u16 bw_max,
                bfa_ablk_cbfn_t cbfn, void *cbarg)
 {
        struct bfi_ablk_h2i_pf_req_s *m;
@@ -3197,7 +3199,8 @@ bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
        bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_CREATE,
                    bfa_ioc_portid(ablk->ioc));
        m->pers = cpu_to_be16((u16)personality);
-       m->bw = cpu_to_be32(bw);
+       m->bw_min = cpu_to_be16(bw_min);
+       m->bw_max = cpu_to_be16(bw_max);
        m->port = port;
        bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
 
@@ -3297,8 +3300,8 @@ bfa_ablk_port_config(struct bfa_ablk_s *ablk, int port, enum bfa_mode_s mode,
 }
 
 bfa_status_t
-bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, int bw,
-               bfa_ablk_cbfn_t cbfn, void *cbarg)
+bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, u16 bw_min,
+                  u16 bw_max, bfa_ablk_cbfn_t cbfn, void *cbarg)
 {
        struct bfi_ablk_h2i_pf_req_s *m;
 
@@ -3320,7 +3323,8 @@ bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, int bw,
        bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_UPDATE,
                bfa_ioc_portid(ablk->ioc));
        m->pcifn = (u8)pcifn;
-       m->bw = cpu_to_be32(bw);
+       m->bw_min = cpu_to_be16(bw_min);
+       m->bw_max = cpu_to_be16(bw_max);
        bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
 
        return BFA_STATUS_OK;
index 8e267246c1a5580bf2235d161892d68ab035a306..0ad221abfc8f73be80bd03d9b19eb5ef2659464e 100644 (file)
@@ -889,12 +889,12 @@ bfa_status_t bfa_ablk_port_config(struct bfa_ablk_s *ablk, int port,
                enum bfa_mode_s mode, int max_pf, int max_vf,
                bfa_ablk_cbfn_t cbfn, void *cbarg);
 bfa_status_t bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
-               u8 port, enum bfi_pcifn_class personality, int bw,
-               bfa_ablk_cbfn_t cbfn, void *cbarg);
+               u8 port, enum bfi_pcifn_class personality,
+               u16 bw_min, u16 bw_max, bfa_ablk_cbfn_t cbfn, void *cbarg);
 bfa_status_t bfa_ablk_pf_delete(struct bfa_ablk_s *ablk, int pcifn,
                bfa_ablk_cbfn_t cbfn, void *cbarg);
-bfa_status_t bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, int bw,
-               bfa_ablk_cbfn_t cbfn, void *cbarg);
+bfa_status_t bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn,
+               u16 bw_min, u16 bw_max, bfa_ablk_cbfn_t cbfn, void *cbarg);
 bfa_status_t bfa_ablk_optrom_en(struct bfa_ablk_s *ablk,
                bfa_ablk_cbfn_t cbfn, void *cbarg);
 bfa_status_t bfa_ablk_optrom_dis(struct bfa_ablk_s *ablk,
index 6e1478ae6251a7cf46923b0273bf79758037d9ef..0ab1d400ac332a5ca91701fb696ff9767a24aee5 100644 (file)
@@ -33,7 +33,7 @@ bfad_iocmd_ioc_enable(struct bfad_s *bfad, void *cmd)
        /* If IOC is not in disabled state - return */
        if (!bfa_ioc_is_disabled(&bfad->bfa.ioc)) {
                spin_unlock_irqrestore(&bfad->bfad_lock, flags);
-               iocmd->status = BFA_STATUS_IOC_FAILURE;
+               iocmd->status = BFA_STATUS_OK;
                return rc;
        }
 
@@ -54,6 +54,12 @@ bfad_iocmd_ioc_disable(struct bfad_s *bfad, void *cmd)
        unsigned long   flags;
 
        spin_lock_irqsave(&bfad->bfad_lock, flags);
+       if (bfa_ioc_is_disabled(&bfad->bfa.ioc)) {
+               spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+               iocmd->status = BFA_STATUS_OK;
+               return rc;
+       }
+
        if (bfad->disable_active) {
                spin_unlock_irqrestore(&bfad->bfad_lock, flags);
                return -EBUSY;
@@ -1191,8 +1197,8 @@ bfad_iocmd_pcifn_create(struct bfad_s *bfad, void *cmd)
        spin_lock_irqsave(&bfad->bfad_lock, flags);
        iocmd->status = bfa_ablk_pf_create(&bfad->bfa.modules.ablk,
                                &iocmd->pcifn_id, iocmd->port,
-                               iocmd->pcifn_class, iocmd->bandwidth,
-                               bfad_hcb_comp, &fcomp);
+                               iocmd->pcifn_class, iocmd->bw_min,
+                               iocmd->bw_max, bfad_hcb_comp, &fcomp);
        spin_unlock_irqrestore(&bfad->bfad_lock, flags);
        if (iocmd->status != BFA_STATUS_OK)
                goto out;
@@ -1235,8 +1241,8 @@ bfad_iocmd_pcifn_bw(struct bfad_s *bfad, void *cmd)
        init_completion(&fcomp.comp);
        spin_lock_irqsave(&bfad->bfad_lock, flags);
        iocmd->status = bfa_ablk_pf_update(&bfad->bfa.modules.ablk,
-                               iocmd->pcifn_id, iocmd->bandwidth,
-                               bfad_hcb_comp, &fcomp);
+                               iocmd->pcifn_id, iocmd->bw_min,
+                               iocmd->bw_max, bfad_hcb_comp, &fcomp);
        spin_unlock_irqrestore(&bfad->bfad_lock, flags);
        bfa_trc(bfad, iocmd->status);
        if (iocmd->status != BFA_STATUS_OK)
@@ -2122,7 +2128,7 @@ bfad_iocmd_boot_cfg(struct bfad_s *bfad, void *cmd)
        init_completion(&fcomp.comp);
        spin_lock_irqsave(&bfad->bfad_lock, flags);
        iocmd->status = bfa_flash_update_part(BFA_FLASH(&bfad->bfa),
-                       BFA_FLASH_PART_BOOT, PCI_FUNC(bfad->pcidev->devfn),
+                       BFA_FLASH_PART_BOOT, bfad->bfa.ioc.port_id,
                        &iocmd->cfg, sizeof(struct bfa_boot_cfg_s), 0,
                        bfad_hcb_comp, &fcomp);
        spin_unlock_irqrestore(&bfad->bfad_lock, flags);
@@ -2144,7 +2150,7 @@ bfad_iocmd_boot_query(struct bfad_s *bfad, void *cmd)
        init_completion(&fcomp.comp);
        spin_lock_irqsave(&bfad->bfad_lock, flags);
        iocmd->status = bfa_flash_read_part(BFA_FLASH(&bfad->bfa),
-                       BFA_FLASH_PART_BOOT, PCI_FUNC(bfad->pcidev->devfn),
+                       BFA_FLASH_PART_BOOT, bfad->bfa.ioc.port_id,
                        &iocmd->cfg, sizeof(struct bfa_boot_cfg_s), 0,
                        bfad_hcb_comp, &fcomp);
        spin_unlock_irqrestore(&bfad->bfad_lock, flags);
index 37922b96079b54e4b202e42a6aec8d8ecf428e0f..e48dcca0d7fae6b2e66e5a227d98f79cf45da89c 100644 (file)
@@ -469,7 +469,8 @@ struct bfa_bsg_pcifn_s {
        bfa_status_t            status;
        u16                     bfad_num;
        u16                     pcifn_id;
-       u32                     bandwidth;
+       u16                     bw_min;
+       u16                     bw_max;
        u8                      port;
        enum bfi_pcifn_class    pcifn_class;
        u8                      rsvd[1];
index 6f1dd9eac1d19079f99d39c4d65831cd14a54bc0..9c9861f8e6ce0fcda2c3db7fd4b3960bb2d37363 100644 (file)
@@ -690,7 +690,8 @@ struct bfi_ablk_h2i_pf_req_s {
        u8                      pcifn;
        u8                      port;
        u16                     pers;
-       u32                     bw;
+       u16                     bw_min; /* percent BW @ max speed */
+       u16                     bw_max; /* percent BW @ max speed */
 };
 
 /* BFI_ABLK_H2I_OPTROM_ENABLE, BFI_ABLK_H2I_OPTROM_DISABLE */