Skip to content

Commit 324c122

Browse files
sreekanthbrcmmartinkpetersen
authored andcommitted
scsi: mpt3sas: Add module parameter multipath_on_hba
Add module parameter multipath_on_hba to enable/disable multi-port path topology support. By default this feature is enabled on SAS3.5 HBA device and disabled on SAS3 &SAS2.5 HBA devices. When this feature is disabled then driver uses a default PhysicalPort(PortID) number i.e. 255 instead of the PhysicalPort number provided by HBA firmware. Link: https://lore.kernel.org/r/20201027130847.9962-14-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent ffa381d commit 324c122

4 files changed

Lines changed: 76 additions & 7 deletions

File tree

‎drivers/scsi/mpt3sas/mpt3sas_base.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
12461246
* which ensures the syncrhonization between cli/sysfs_show path.
12471247
* @atomic_desc_capable: Atomic Request Descriptor support.
12481248
* @GET_MSIX_INDEX: Get the msix index of high iops queues.
1249+
* @multipath_on_hba: flag to determine multipath on hba is enabled or not
12491250
* @port_table_list: list containing HBA's wide/narrow port's info
12501251
*/
12511252
struct MPT3SAS_ADAPTER {
@@ -1540,6 +1541,7 @@ struct MPT3SAS_ADAPTER {
15401541
PUT_SMID_DEFAULT put_smid_default;
15411542
GET_MSIX_INDEX get_msix_index_for_smlio;
15421543

1544+
u8 multipath_on_hba;
15431545
struct list_head port_table_list;
15441546
};
15451547

‎drivers/scsi/mpt3sas/mpt3sas_ctl.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,10 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg,
902902
(Mpi2SmpPassthroughRequest_t *)mpi_request;
903903
u8 *data;
904904

905-
/* ioc determines which port to use */
906-
smp_request->PhysicalPort = 0xFF;
905+
if (!ioc->multipath_on_hba) {
906+
/* ioc determines which port to use */
907+
smp_request->PhysicalPort = 0xFF;
908+
}
907909
if (smp_request->PassthroughFlags &
908910
MPI2_SMP_PT_REQ_PT_FLAGS_IMMEDIATE)
909911
data = (u8 *)&smp_request->SGL;

‎drivers/scsi/mpt3sas/mpt3sas_scsih.c‎

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ module_param(enable_sdev_max_qd, bool, 0444);
159159
MODULE_PARM_DESC(enable_sdev_max_qd,
160160
"Enable sdev max qd as can_queue, def=disabled(0)");
161161

162+
static int multipath_on_hba = -1;
163+
module_param(multipath_on_hba, int, 0);
164+
MODULE_PARM_DESC(multipath_on_hba,
165+
"Multipath support to add same target device\n\t\t"
166+
"as many times as it is visible to HBA from various paths\n\t\t"
167+
"(by default:\n\t\t"
168+
"\t SAS 2.0 & SAS 3.0 HBA - This will be disabled,\n\t\t"
169+
"\t SAS 3.5 HBA - This will be enabled)");
170+
162171
/* raid transport support */
163172
static struct raid_template *mpt3sas_raid_template;
164173
static struct raid_template *mpt2sas_raid_template;
@@ -373,6 +382,14 @@ mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc,
373382
{
374383
struct hba_port *port, *port_next;
375384

385+
/*
386+
* When multipath_on_hba is disabled then
387+
* search the hba_port entry using default
388+
* port id i.e. 255
389+
*/
390+
if (!ioc->multipath_on_hba)
391+
port_id = MULTIPATH_DISABLED_PORT_ID;
392+
376393
list_for_each_entry_safe(port, port_next,
377394
&ioc->port_table_list, list) {
378395
if (port->port_id != port_id)
@@ -384,6 +401,24 @@ mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc,
384401
return port;
385402
}
386403

404+
/*
405+
* Allocate hba_port object for default port id (i.e. 255)
406+
* when multipath_on_hba is disabled for the HBA.
407+
* And add this object to port_table_list.
408+
*/
409+
if (!ioc->multipath_on_hba) {
410+
port = kzalloc(sizeof(struct hba_port), GFP_KERNEL);
411+
if (!port)
412+
return NULL;
413+
414+
port->port_id = port_id;
415+
ioc_info(ioc,
416+
"hba_port entry: %p, port: %d is added to hba_port list\n",
417+
port, port->port_id);
418+
list_add_tail(&port->list,
419+
&ioc->port_table_list);
420+
return port;
421+
}
387422
return NULL;
388423
}
389424

@@ -10014,6 +10049,7 @@ _scsih_search_responding_expanders(struct MPT3SAS_ADAPTER *ioc)
1001410049
u16 ioc_status;
1001510050
u64 sas_address;
1001610051
u16 handle;
10052+
u8 port;
1001710053

1001810054
ioc_info(ioc, "search for expanders: start\n");
1001910055

@@ -10031,10 +10067,12 @@ _scsih_search_responding_expanders(struct MPT3SAS_ADAPTER *ioc)
1003110067

1003210068
handle = le16_to_cpu(expander_pg0.DevHandle);
1003310069
sas_address = le64_to_cpu(expander_pg0.SASAddress);
10070+
port = expander_pg0.PhysicalPort;
1003410071
pr_info(
1003510072
"\texpander present: handle(0x%04x), sas_addr(0x%016llx), port:%d\n",
1003610073
handle, (unsigned long long)sas_address,
10037-
expander_pg0.PhysicalPort);
10074+
(ioc->multipath_on_hba ?
10075+
port : MULTIPATH_DISABLED_PORT_ID));
1003810076
_scsih_mark_responding_expander(ioc, &expander_pg0);
1003910077
}
1004010078

@@ -10477,8 +10515,10 @@ mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)
1047710515
dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_DONE_RESET\n", __func__));
1047810516
if ((!ioc->is_driver_loading) && !(disable_discovery > 0 &&
1047910517
!ioc->sas_hba.num_phys)) {
10480-
_scsih_sas_port_refresh(ioc);
10481-
_scsih_update_vphys_after_reset(ioc);
10518+
if (ioc->multipath_on_hba) {
10519+
_scsih_sas_port_refresh(ioc);
10520+
_scsih_update_vphys_after_reset(ioc);
10521+
}
1048210522
_scsih_prep_device_scan(ioc);
1048310523
_scsih_create_enclosure_list_after_reset(ioc);
1048410524
_scsih_search_responding_sas_devices(ioc);
@@ -11766,6 +11806,12 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1176611806
ioc->mfg_pg10_hide_flag = MFG_PAGE10_EXPOSE_ALL_DISKS;
1176711807
break;
1176811808
}
11809+
11810+
if (multipath_on_hba == -1 || multipath_on_hba == 0)
11811+
ioc->multipath_on_hba = 0;
11812+
else
11813+
ioc->multipath_on_hba = 1;
11814+
1176911815
break;
1177011816
case MPI25_VERSION:
1177111817
case MPI26_VERSION:
@@ -11827,6 +11873,23 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1182711873
ioc->combined_reply_index_count =
1182811874
MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3;
1182911875
}
11876+
11877+
switch (ioc->is_gen35_ioc) {
11878+
case 0:
11879+
if (multipath_on_hba == -1 || multipath_on_hba == 0)
11880+
ioc->multipath_on_hba = 0;
11881+
else
11882+
ioc->multipath_on_hba = 1;
11883+
break;
11884+
case 1:
11885+
if (multipath_on_hba == -1 || multipath_on_hba > 0)
11886+
ioc->multipath_on_hba = 1;
11887+
else
11888+
ioc->multipath_on_hba = 0;
11889+
default:
11890+
break;
11891+
}
11892+
1183011893
break;
1183111894
default:
1183211895
return -ENODEV;

‎drivers/scsi/mpt3sas/mpt3sas_transport.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,8 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
912912
return;
913913
}
914914

915-
if (sas_node->handle <= ioc->sas_hba.num_phys) {
915+
if (sas_node->handle <= ioc->sas_hba.num_phys &&
916+
(ioc->multipath_on_hba)) {
916917
if (port->vphys_mask) {
917918
list_for_each_entry_safe(vphy, vphy_next,
918919
&port->vphys_list, list) {
@@ -1172,7 +1173,8 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
11721173
if (handle && (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5)) {
11731174
_transport_set_identify(ioc, handle,
11741175
&mpt3sas_phy->remote_identify);
1175-
if (sas_node->handle <= ioc->sas_hba.num_phys) {
1176+
if ((sas_node->handle <= ioc->sas_hba.num_phys) &&
1177+
(ioc->multipath_on_hba)) {
11761178
list_for_each_entry(hba_port,
11771179
&ioc->port_table_list, list) {
11781180
if (hba_port->sas_address == sas_address &&

0 commit comments

Comments
 (0)