Skip to content

Commit 61e62e2

Browse files
Krishna GudipatiJames Bottomley
authored andcommitted
[SCSI] bfa: Driver and BSG enhancements.
- Added a new module parameter max_xfer_size to set the max_sectors in the scsi_host template. - Added logic to handle request_irq() failure so that msix vector resource is de-allocated immediately when failure happens. - BSG enhancements to collect vHBA releated info and port log. - Removed the workaround of incrementing the module refcnt on bsg request. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 3350d98 commit 61e62e2

6 files changed

Lines changed: 100 additions & 34 deletions

File tree

‎drivers/scsi/bfa/bfa_defs_svc.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,19 @@ struct bfa_itnim_ioprofile_s {
10421042
struct bfa_itnim_latency_s io_latency;
10431043
};
10441044

1045+
/*
1046+
* vHBA port attribute values.
1047+
*/
1048+
struct bfa_vhba_attr_s {
1049+
wwn_t nwwn; /* node wwn */
1050+
wwn_t pwwn; /* port wwn */
1051+
u32 pid; /* port ID */
1052+
bfa_boolean_t io_profile; /* get it from fcpim mod */
1053+
bfa_boolean_t plog_enabled; /* portlog is enabled */
1054+
u16 path_tov;
1055+
u8 rsvd[2];
1056+
};
1057+
10451058
/*
10461059
* FC physical port statistics.
10471060
*/

‎drivers/scsi/bfa/bfad.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int fdmi_enable = BFA_TRUE;
5656
int pcie_max_read_reqsz;
5757
int bfa_debugfs_enable = 1;
5858
int msix_disable_cb = 0, msix_disable_ct = 0;
59+
int max_xfer_size = BFAD_MAX_SECTORS >> 1;
5960

6061
/* Firmware releated */
6162
u32 bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size;
@@ -144,6 +145,9 @@ MODULE_PARM_DESC(pcie_max_read_reqsz, "PCIe max read request size, default=0 "
144145
module_param(bfa_debugfs_enable, int, S_IRUGO | S_IWUSR);
145146
MODULE_PARM_DESC(bfa_debugfs_enable, "Enables debugfs feature, default=1,"
146147
" Range[false:0|true:1]");
148+
module_param(max_xfer_size, int, S_IRUGO | S_IWUSR);
149+
MODULE_PARM_DESC(max_xfer_size, "default=32MB,"
150+
" Range[64k|128k|256k|512k|1024k|2048k]");
147151

148152
static void
149153
bfad_sm_uninit(struct bfad_s *bfad, enum bfad_sm_event event);
@@ -1015,6 +1019,12 @@ bfad_start_ops(struct bfad_s *bfad) {
10151019
struct bfad_vport_s *vport, *vport_new;
10161020
struct bfa_fcs_driver_info_s driver_info;
10171021

1022+
/* Limit min/max. xfer size to [64k-32MB] */
1023+
if (max_xfer_size < BFAD_MIN_SECTORS >> 1)
1024+
max_xfer_size = BFAD_MIN_SECTORS >> 1;
1025+
if (max_xfer_size > BFAD_MAX_SECTORS >> 1)
1026+
max_xfer_size = BFAD_MAX_SECTORS >> 1;
1027+
10181028
/* Fill the driver_info info to fcs*/
10191029
memset(&driver_info, 0, sizeof(driver_info));
10201030
strncpy(driver_info.version, BFAD_DRIVER_VERSION,
@@ -1231,6 +1241,9 @@ bfad_install_msix_handler(struct bfad_s *bfad)
12311241
free_irq(bfad->msix_tab[j].msix.vector,
12321242
&bfad->msix_tab[j]);
12331243

1244+
bfad->bfad_flags &= ~BFAD_MSIX_ON;
1245+
pci_disable_msix(bfad->pcidev);
1246+
12341247
return 1;
12351248
}
12361249
}
@@ -1306,6 +1319,7 @@ bfad_setup_intr(struct bfad_s *bfad)
13061319
/* Enable interrupt handler failed */
13071320
return 1;
13081321
}
1322+
bfad->bfad_flags |= BFAD_INTX_ON;
13091323

13101324
return error;
13111325
}
@@ -1322,7 +1336,7 @@ bfad_remove_intr(struct bfad_s *bfad)
13221336

13231337
pci_disable_msix(bfad->pcidev);
13241338
bfad->bfad_flags &= ~BFAD_MSIX_ON;
1325-
} else {
1339+
} else if (bfad->bfad_flags & BFAD_INTX_ON) {
13261340
free_irq(bfad->pcidev->irq, bfad);
13271341
}
13281342
}

‎drivers/scsi/bfa/bfad_bsg.c‎

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,6 @@
2222

2323
BFA_TRC_FILE(LDRV, BSG);
2424

25-
/* bfad_im_bsg_get_kobject - increment the bfa refcnt */
26-
static void
27-
bfad_im_bsg_get_kobject(struct fc_bsg_job *job)
28-
{
29-
struct Scsi_Host *shost = job->shost;
30-
unsigned long flags;
31-
32-
spin_lock_irqsave(shost->host_lock, flags);
33-
__module_get(shost->dma_dev->driver->owner);
34-
spin_unlock_irqrestore(shost->host_lock, flags);
35-
}
36-
37-
/* bfad_im_bsg_put_kobject - decrement the bfa refcnt */
38-
static void
39-
bfad_im_bsg_put_kobject(struct fc_bsg_job *job)
40-
{
41-
struct Scsi_Host *shost = job->shost;
42-
unsigned long flags;
43-
44-
spin_lock_irqsave(shost->host_lock, flags);
45-
module_put(shost->dma_dev->driver->owner);
46-
spin_unlock_irqrestore(shost->host_lock, flags);
47-
}
48-
4925
int
5026
bfad_iocmd_ioc_enable(struct bfad_s *bfad, void *cmd)
5127
{
@@ -1467,6 +1443,25 @@ bfad_iocmd_phy_read(struct bfad_s *bfad, void *cmd, unsigned int payload_len)
14671443
return 0;
14681444
}
14691445

1446+
int
1447+
bfad_iocmd_vhba_query(struct bfad_s *bfad, void *cmd)
1448+
{
1449+
struct bfa_bsg_vhba_attr_s *iocmd =
1450+
(struct bfa_bsg_vhba_attr_s *)cmd;
1451+
struct bfa_vhba_attr_s *attr = &iocmd->attr;
1452+
unsigned long flags;
1453+
1454+
spin_lock_irqsave(&bfad->bfad_lock, flags);
1455+
attr->pwwn = bfad->bfa.ioc.attr->pwwn;
1456+
attr->nwwn = bfad->bfa.ioc.attr->nwwn;
1457+
attr->plog_enabled = (bfa_boolean_t)bfad->bfa.plog->plog_enabled;
1458+
attr->io_profile = bfa_fcpim_get_io_profile(&bfad->bfa);
1459+
attr->path_tov = bfa_fcpim_path_tov_get(&bfad->bfa);
1460+
iocmd->status = BFA_STATUS_OK;
1461+
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1462+
return 0;
1463+
}
1464+
14701465
int
14711466
bfad_iocmd_phy_update(struct bfad_s *bfad, void *cmd, unsigned int payload_len)
14721467
{
@@ -1497,6 +1492,25 @@ bfad_iocmd_phy_update(struct bfad_s *bfad, void *cmd, unsigned int payload_len)
14971492
return 0;
14981493
}
14991494

1495+
int
1496+
bfad_iocmd_porglog_get(struct bfad_s *bfad, void *cmd)
1497+
{
1498+
struct bfa_bsg_debug_s *iocmd = (struct bfa_bsg_debug_s *)cmd;
1499+
void *iocmd_bufptr;
1500+
1501+
if (iocmd->bufsz < sizeof(struct bfa_plog_s)) {
1502+
bfa_trc(bfad, sizeof(struct bfa_plog_s));
1503+
iocmd->status = BFA_STATUS_EINVAL;
1504+
goto out;
1505+
}
1506+
1507+
iocmd->status = BFA_STATUS_OK;
1508+
iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_debug_s);
1509+
memcpy(iocmd_bufptr, (u8 *) &bfad->plog_buf, sizeof(struct bfa_plog_s));
1510+
out:
1511+
return 0;
1512+
}
1513+
15001514
static int
15011515
bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
15021516
unsigned int payload_len)
@@ -1682,6 +1696,12 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
16821696
case IOCMD_PHY_READ_FW:
16831697
rc = bfad_iocmd_phy_read(bfad, iocmd, payload_len);
16841698
break;
1699+
case IOCMD_VHBA_QUERY:
1700+
rc = bfad_iocmd_vhba_query(bfad, iocmd);
1701+
break;
1702+
case IOCMD_DEBUG_PORTLOG:
1703+
rc = bfad_iocmd_porglog_get(bfad, iocmd);
1704+
break;
16851705
default:
16861706
rc = EINVAL;
16871707
break;
@@ -2111,9 +2131,6 @@ bfad_im_bsg_request(struct fc_bsg_job *job)
21112131
{
21122132
uint32_t rc = BFA_STATUS_OK;
21132133

2114-
/* Increment the bfa module refcnt - if bsg request is in service */
2115-
bfad_im_bsg_get_kobject(job);
2116-
21172134
switch (job->request->msgcode) {
21182135
case FC_BSG_HST_VENDOR:
21192136
/* Process BSG HST Vendor requests */
@@ -2132,9 +2149,6 @@ bfad_im_bsg_request(struct fc_bsg_job *job)
21322149
break;
21332150
}
21342151

2135-
/* Decrement the bfa module refcnt - on completion of bsg request */
2136-
bfad_im_bsg_put_kobject(job);
2137-
21382152
return rc;
21392153
}
21402154

‎drivers/scsi/bfa/bfad_bsg.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ enum {
8484
IOCMD_PHY_GET_STATS,
8585
IOCMD_PHY_UPDATE_FW,
8686
IOCMD_PHY_READ_FW,
87+
IOCMD_VHBA_QUERY,
88+
IOCMD_DEBUG_PORTLOG,
8789
};
8890

8991
struct bfa_bsg_gen_s {
@@ -459,13 +461,30 @@ struct bfa_bsg_phy_s {
459461
u64 buf_ptr;
460462
};
461463

464+
struct bfa_bsg_debug_s {
465+
bfa_status_t status;
466+
u16 bfad_num;
467+
u16 rsvd;
468+
u32 bufsz;
469+
int inst_no;
470+
u64 buf_ptr;
471+
u64 offset;
472+
};
473+
462474
struct bfa_bsg_phy_stats_s {
463475
bfa_status_t status;
464476
u16 bfad_num;
465477
u16 instance;
466478
struct bfa_phy_stats_s stats;
467479
};
468480

481+
struct bfa_bsg_vhba_attr_s {
482+
bfa_status_t status;
483+
u16 bfad_num;
484+
u16 pcifn_id;
485+
struct bfa_vhba_attr_s attr;
486+
};
487+
469488
struct bfa_bsg_fcpt_s {
470489
bfa_status_t status;
471490
u16 vf_id;

‎drivers/scsi/bfa/bfad_drv.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
#define BFAD_HAL_INIT_FAIL 0x00000100
8181
#define BFAD_FC4_PROBE_DONE 0x00000200
8282
#define BFAD_PORT_DELETE 0x00000001
83-
83+
#define BFAD_INTX_ON 0x00000400
8484
/*
8585
* BFAD related definition
8686
*/
@@ -93,6 +93,8 @@
9393
*/
9494
#define BFAD_LUN_QUEUE_DEPTH 32
9595
#define BFAD_IO_MAX_SGE SG_ALL
96+
#define BFAD_MIN_SECTORS 128 /* 64k */
97+
#define BFAD_MAX_SECTORS 0xFFFF /* 32 MB */
9698

9799
#define bfad_isr_t irq_handler_t
98100

@@ -343,6 +345,7 @@ extern int msix_disable_ct;
343345
extern int fdmi_enable;
344346
extern int supported_fc4s;
345347
extern int pcie_max_read_reqsz;
348+
extern int max_xfer_size;
346349
extern int bfa_debugfs_enable;
347350
extern struct mutex bfad_mutex;
348351

‎drivers/scsi/bfa/bfad_im.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,9 @@ bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad)
700700
else
701701
sht = &bfad_im_vport_template;
702702

703+
if (max_xfer_size != BFAD_MAX_SECTORS >> 1)
704+
sht->max_sectors = max_xfer_size << 1;
705+
703706
sht->sg_tablesize = bfad->cfg_data.io_max_sge;
704707

705708
return scsi_host_alloc(sht, sizeof(unsigned long));
@@ -777,7 +780,7 @@ struct scsi_host_template bfad_im_scsi_host_template = {
777780
.cmd_per_lun = 3,
778781
.use_clustering = ENABLE_CLUSTERING,
779782
.shost_attrs = bfad_im_host_attrs,
780-
.max_sectors = 0xFFFF,
783+
.max_sectors = BFAD_MAX_SECTORS,
781784
.vendor_id = BFA_PCI_VENDOR_ID_BROCADE,
782785
};
783786

@@ -799,7 +802,7 @@ struct scsi_host_template bfad_im_vport_template = {
799802
.cmd_per_lun = 3,
800803
.use_clustering = ENABLE_CLUSTERING,
801804
.shost_attrs = bfad_im_vport_attrs,
802-
.max_sectors = 0xFFFF,
805+
.max_sectors = BFAD_MAX_SECTORS,
803806
};
804807

805808
bfa_status_t

0 commit comments

Comments
 (0)