mpt3sas: Add support for multi-port path topology
Subsystems (2)
Sreekanth Reddy
maintainercover mpt3sas: Add support for multi-port path topology
Multi-port path topology example:
Zone 1 Zone 2
|-----------------| |----------------|
| HD1 ..... HD25 | | HD26 ......HD50|
| |==================================| |
| | | | | |
| | Expander | |
| |==================================| |
| | | | | |
|-----------|-----| |----|-----------|
x8| |x8
_______|______________|_______
| HBA |
|____________________________|In this topology, zoning is enabled in such a way that drives from HD1 to HD25 are accessible only through zone1 and drives from HD26 to HD50 are accessible only through zone2. Here the first x8 connection bw HBA to Expander in zone1 will have one PortID and second x8 connection bw HBA to Expander in Zone2 will another PortID.
Problem statement:
When zoning is enabled in expander then we will have two expander instances (for a single real expander), one instance is accessible through the first x8 connection and second instance is accessible through second x8 connection from HBA. But for both the instances the SAS Address of the expander will be the same.
But in current mpt3sas driver, driver add's only one expander instance, when second expander instance's 'add' event comes then driver ignores this event assumues that it is duplicate instance as it already has a sas_expander object in it's sas_expander_list list with the same SAS Address. So in this topology users will see only 25 drives instead of 50 drives.
Current mpt3sas driver use ‘SAS Address’ as a key to uniquely identify the End devices or Expander devices, but on the multi-port path topologies (such as above topology) HBA firmware will provide multiple device entries with different Device handles for a single device.
So here driver can't use ‘SAS Address’ as a key instead driver can use ‘SAS Address’ & ‘PhysicalPort (i.e. PortID)’ number as key to uniquely identify the device.
where, PhysicalPort is a HBA port number through which the device is accessible.
Solution:
Now driver uses both 'SAS Address' & 'PhysicalPort' number as a key to uniquely identify the device object from the corresponding device list's. So, when 'add' event comes for second instance of expander, now driver can't find the sas_expander object with same 'SAS Address' & 'PhysicalPort' number (since for this second instance PhysicalPort number will be different from first instance's PhysicalPort number) from the sas_expander_list list. So the driver processes this event and will create a new sas_expander object for this expander instance and adds it sas_expander_list.
With this solution, the driver will have two sas_expander objects, one object is for the first instance of the expander, another object is for second instance of the driver. Now users will access all 50 drives from above topology.
Like device SAS Address, PhysicalPort number is readily available from below config pages,
* SAS IO Unit Page 0,
* SAS Device Page 0,
* SAS Expander Page 0,
* SAS Phy Page 0, etc
Through this patch set, the driver now manages the sas_device & sas_expander objects using 'SAS Address' & 'PhysicalPort' number as key.
Sreekanth Reddy (14):
mpt3sas: Define hba_port structure
mpt3sas: Allocate memory for hba_port objects
mpt3sas: Rearrange _scsih_mark_responding_sas_device()
mpt3sas: Update hba_port's sas_address & phy_mask
mpt3sas: Get device objects using sas_address & portID
mpt3sas: Rename transport_del_phy_from_an_existing_port
mpt3sas: Get sas_device objects using device's rphy
mpt3sas: Update hba_port objects after host reset
mpt3sas: Set valid PhysicalPort in SMPPassThrough
mpt3sas: Handling HBA vSES device
mpt3sas: Add bypass_dirty_port_flag parameter
mpt3sas: Handle vSES vphy object during HBA reset
mpt3sas: add module parameter multipath_on_hba
mpt3sas: Bump driver version to 35.101.00.00
drivers/scsi/mpt3sas/mpt3sas_base.h | 102 +- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 6 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 1237 +++++++++++++++++++--- drivers/scsi/mpt3sas/mpt3sas_transport.c | 312 +++++- 4 files changed, 1455 insertions(+), 202 deletions(-)
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 1/14 mpt3sas: Define hba_port structure
Defined a new hba_port structure with hold below variables,
- port_id : Port ID of the narrow/wide port of the HBA
- sas_address : SAS Address of the remote device that is
attached to the current HBA port
- phy_mask : HBA’s phy bits to which above SAS addressed
device is attached
- flags : this field is used to refresh this port details
during HBA reset.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 35 ++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +34 -1
@@ -420,6 +420,7 @@ struct Mpi2ManufacturingPage11_t {* @flags: MPT_TARGET_FLAGS_XXX flags * @deleted: target flaged for deletion * @tm_busy: target is busy with TM request. +* @port: hba port entry containing target's port number info * @sas_dev: The sas_device associated with this target * @pcie_dev: The pcie device associated with this target */
@@ -432,6 +433,7 @@ struct MPT3SAS_TARGET {u32 flags;u8 deleted;u8 tm_busy; +struct hba_port *port;struct _sas_device *sas_dev;struct _pcie_device *pcie_dev; };
@@ -534,6 +536,7 @@ struct _internal_cmd {* addition routine. * @chassis_slot: chassis slot * @is_chassis_slot_valid: chassis slot valid or not +* @port: hba port entry containing device's port number info */ struct _sas_device {struct list_head list;
@@ -560,6 +563,7 @@ struct _sas_device {u8 is_chassis_slot_valid;u8 connector_name[5 ];struct kref refcount; +struct hba_port *port; };static inline void sas_device_get (struct _sas_device *s)
@@ -730,6 +734,7 @@ struct _boot_device {* @remote_identify: attached device identification * @rphy: sas transport rphy object * @port: sas transport wide/narrow port object +* @hba_port: hba port entry containing port's port number info * @phy_list: _sas_phy list objects belonging to this port */ struct _sas_port {
@@ -738,6 +743,7 @@ struct _sas_port {struct sas_identify remote_identify;struct sas_rphy *rphy;struct sas_port *port; +struct hba_port *hba_port;struct list_head phy_list; };
@@ -751,6 +757,7 @@ struct _sas_port {* @handle: device handle for this phy * @attached_handle: device handle for attached device * @phy_belongs_to_port: port has been created for this phy +* @port: hba port entry containing port number info */ struct _sas_phy {struct list_head port_siblings;
@@ -761,6 +768,7 @@ struct _sas_phy {u16 handle;u16 attached_handle;u8 phy_belongs_to_port; +struct hba_port *port; };/**
@@ -776,6 +784,7 @@ struct _sas_phy {* @responding: used in _scsih_expander_device_mark_responding * @phy: a list of phys that make up this sas_host/expander * @sas_port_list: list of ports attached to this sas_host/expander +* @port: hba port entry containing node's port number info */ struct _sas_node {struct list_head list;
@@ -787,11 +796,11 @@ struct _sas_node {u16 enclosure_handle;u64 enclosure_logical_id;u8 responding; +struct hba_port *port;struct _sas_phy *phy;struct list_head sas_port_list; }; -/** * struct _enclosure_node - enclosure information * @list: list of enclosures
@@ -1009,6 +1018,27 @@ struct reply_post_struct {dma_addr_t reply_post_free_dma; }; +/** +* struct hba_port - Saves each HBA's Wide/Narrow port info +* @sas_address: sas address of this wide/narrow port's attached device +* @phy_mask: HBA PHY's belonging to this port +* @port_id: port number +* @flags: hba port flags +*/ +struct hba_port { +struct list_head list; +u64 sas_address; +u32 phy_mask; +u8 port_id; +u8 flags; +}; + +/* hba port flags */ +#define HBA_PORT_FLAG_DIRTY_PORT 0x01 +#define HBA_PORT_FLAG_NEW_PORT 0x02 + +#define MULTIPATH_DISABLED_PORT_ID 0xFF +typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS )(struct MPT3SAS_ADAPTER *ioc);/** * struct MPT3SAS_ADAPTER - per adapter struct
@@ -1191,6 +1221,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);* which ensures the syncrhonization between cli/sysfs_show path. * @atomic_desc_capable: Atomic Request Descriptor support. * @GET_MSIX_INDEX: Get the msix index of high iops queues. +* @port_table_list: list containing HBA's wide/narrow port's info */ struct MPT3SAS_ADAPTER {struct list_head list;
@@ -1483,6 +1514,8 @@ struct MPT3SAS_ADAPTER {PUT_SMID_IO_FP_HIP put_smid_hi_priority;PUT_SMID_DEFAULT put_smid_default;GET_MSIX_INDEX get_msix_index_for_smlio; + +struct list_head port_table_list; };struct mpt3sas_debugfs_buffer {
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 2/14 mpt3sas: Allocate memory for hba_port objects
In reply to Sreekanth ReddyAllocate hba_port object whenever a new HBA's wide/narrow port is identified while processing the SASIOUnitPage0's phy data and add this object to port_table_list. And deallocate these objects during driver unload.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 73 ++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +69 -4
@@ -356,6 +356,30 @@ _scsih_srch_boot_encl_slot(u64 enclosure_logical_id, u16 slot_number, SlotNumber)) ? 1 : 0; } +/** +* mpt3sas_get_port_by_id - get hba port entry corresponding to provided +* port number from port list +* @ioc: per adapter object +* @port_id: port number +* +* Search for hba port entry corresponding to provided port number, +* if available return port object otherwise return NULL. +*/ +struct hba_port * +mpt3sas_get_port_by_id (struct MPT3SAS_ADAPTER *ioc,u8 port_id) +{ +struct hba_port *port, *port_next; + +list_for_each_entry_safe (port, port_next, + &ioc->port_table_list, list) { +if (port->port_id == port_id && + !(port->flags &HBA_PORT_FLAG_DIRTY_PORT )) +return port; + } + +return NULL ; +} +/** * _scsih_is_boot_device - search for matching boot device. * @sas_address: sas address
@@ -5732,7 +5756,8 @@ _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc)Mpi2ConfigReply_t mpi_reply;Mpi2SasIOUnitPage0_t *sas_iounit_pg0 =NULL ;u16 attached_handle; -u8 link_rate; +u8 link_rate, port_id; +struct hba_port *port; dtmprintk(ioc, ioc_info(ioc, "updating handles for sas_host(0x%016llx)\n",
@@ -5756,13 +5781,28 @@ _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc)for (i =0 ; i < ioc->sas_hba.num_phys ; i++) { link_rate = sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >>4 ;if (i ==0 ) - ioc->sas_hba.handle =le16_to_cpu (sas_iounit_pg0-> - PhyData[0 ].ControllerDevHandle); + ioc->sas_hba.handle =le16_to_cpu ( + sas_iounit_pg0->PhyData[0 ].ControllerDevHandle); + port_id = sas_iounit_pg0->PhyData[i].Port; +if (!(mpt3sas_get_port_by_id (ioc, port_id))) { + port =kzalloc (sizeof (struct hba_port ),GFP_KERNEL ); +if (!port) + goto out; + + port->port_id = port_id; +ioc_info (ioc, +"hba_port entry: %p, port: %d is added to hba_port list\n" , + port, port->port_id); +if (ioc->shost_recovery) + port->flags =HBA_PORT_FLAG_NEW_PORT ; +list_add_tail (&port->list, &ioc->port_table_list); + } ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; attached_handle =le16_to_cpu (sas_iounit_pg0->PhyData[i]. AttachedDevHandle);if (attached_handle && link_rate <MPI2_SAS_NEG_LINK_RATE_1_5 ) link_rate =MPI2_SAS_NEG_LINK_RATE_1_5 ; + ioc->sas_hba.phy[i].port =mpt3sas_get_port_by_id (ioc, port_id);mpt3sas_transport_update_links (ioc, ioc->sas_hba.sas_address, attached_handle, i, link_rate); }
@@ -5789,7 +5829,8 @@ _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc)u16 ioc_status;u16 sz;u8 device_missing_delay; -u8 num_phys; +u8 num_phys, port_id; +struct hba_port *port;mpt3sas_config_get_number_hba_phys (ioc, &num_phys);if (!num_phys) {
@@ -5882,8 +5923,24 @@ _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc)if (i ==0 ) ioc->sas_hba.handle =le16_to_cpu (sas_iounit_pg0-> PhyData[0 ].ControllerDevHandle); + + port_id = sas_iounit_pg0->PhyData[i].Port; +if (!(mpt3sas_get_port_by_id (ioc, port_id))) { + port =kzalloc (sizeof (struct hba_port ),GFP_KERNEL ); +if (!port) + goto out; + + port->port_id = port_id; +ioc_info (ioc, +"hba_port entry: %p, port: %d is added to hba_port list\n" , + port, port->port_id); +list_add_tail (&port->list, + &ioc->port_table_list); + } + ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; ioc->sas_hba.phy[i].phy_id = i; + ioc->sas_hba.phy[i].port =mpt3sas_get_port_by_id (ioc, port_id);mpt3sas_transport_add_host_phy (ioc, &ioc->sas_hba.phy[i], phy_pg0, ioc->sas_hba.parent_dev); }
@@ -10136,6 +10193,7 @@ static void scsih_remove(struct pci_dev *pdev)struct workqueue_struct *wq;unsigned long flags;Mpi2ConfigReply_t mpi_reply; +struct hba_port *port, *port_next;if (_scsih_get_shost_and_ioc (pdev, &shost, &ioc))return ;
@@ -10198,6 +10256,12 @@ static void scsih_remove(struct pci_dev *pdev) mpt3sas_port->remote_identify.sas_address); } +list_for_each_entry_safe (port, port_next, + &ioc->port_table_list, list) { +list_del (&port->list); +kfree (port); + } +/* free phys attached to the sas_host */ if (ioc->sas_hba.num_phys) {kfree (ioc->sas_hba.phy);
@@ -10987,6 +11051,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)INIT_LIST_HEAD (&ioc->delayed_event_ack_list);INIT_LIST_HEAD (&ioc->delayed_tr_volume_list);INIT_LIST_HEAD (&ioc->reply_queue_list); +INIT_LIST_HEAD (&ioc->port_table_list);sprintf (ioc->name,"%s_cm%d" , ioc->driver_name, ioc->id);
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 3/14 mpt3sas: Rearrange _scsih_mark_responding_sas_device()
In reply to Sreekanth ReddyRearrange _scsih_mark_responding_sas_device function for better code management. No functional change.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 116 +++++++++++++-------------- 1 file changed, 58 insertions(+), 58 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +58 -58
@@ -8742,69 +8742,69 @@ Mpi2SasDevicePage0_t *sas_device_pg0) }spin_lock_irqsave (&ioc->sas_device_lock, flags);list_for_each_entry (sas_device, &ioc->sas_device_list, list) { -if ((sas_device->sas_address ==le64_to_cpu ( - sas_device_pg0->SASAddress)) && (sas_device->slot == -le16_to_cpu (sas_device_pg0->Slot))) { - sas_device->responding =1 ; - starget = sas_device->starget; -if (starget && starget->hostdata) { - sas_target_priv_data = starget->hostdata; - sas_target_priv_data->tm_busy =0 ; - sas_target_priv_data->deleted =0 ; - }else - sas_target_priv_data =NULL ; -if (starget) { -starget_printk (KERN_INFO , starget, -"handle(0x%04x), sas_addr(0x%016llx)\n" , -le16_to_cpu (sas_device_pg0->DevHandle), - (unsigned long long ) - sas_device->sas_address); +if (sas_device->sas_address !=le64_to_cpu ( + sas_device_pg0->SASAddress)) +continue ; +if (sas_device->slot !=le16_to_cpu (sas_device_pg0->Slot)) +continue ; + sas_device->responding =1 ; + starget = sas_device->starget; +if (starget && starget->hostdata) { + sas_target_priv_data = starget->hostdata; + sas_target_priv_data->tm_busy =0 ; + sas_target_priv_data->deleted =0 ; + }else + sas_target_priv_data =NULL ; +if (starget) { +starget_printk (KERN_INFO , starget, +"handle(0x%04x), sas_addr(0x%016llx)\n" , +le16_to_cpu (sas_device_pg0->DevHandle), + (unsigned long long ) + sas_device->sas_address); -if (sas_device->enclosure_handle !=0 ) -starget_printk (KERN_INFO , starget, -"enclosure logical id(0x%016llx)," -" slot(%d)\n" , - (unsigned long long ) - sas_device->enclosure_logical_id, - sas_device->slot); - } -if (le16_to_cpu (sas_device_pg0->Flags) & -MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID ) { - sas_device->enclosure_level = - sas_device_pg0->EnclosureLevel; -memcpy (&sas_device->connector_name[0 ], - &sas_device_pg0->ConnectorName[0 ],4 ); - }else { - sas_device->enclosure_level =0 ; - sas_device->connector_name[0 ] ='\0' ; - } +if (sas_device->enclosure_handle !=0 ) +starget_printk (KERN_INFO , starget, +"enclosure logical id(0x%016llx), slot(%d)\n" , + (unsigned long long ) + sas_device->enclosure_logical_id, + sas_device->slot); + } +if (le16_to_cpu (sas_device_pg0->Flags) & +MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID ) { + sas_device->enclosure_level = + sas_device_pg0->EnclosureLevel; +memcpy (&sas_device->connector_name[0 ], + &sas_device_pg0->ConnectorName[0 ],4 ); + }else { + sas_device->enclosure_level =0 ; + sas_device->connector_name[0 ] ='\0' ; + } - sas_device->enclosure_handle = -le16_to_cpu (sas_device_pg0->EnclosureHandle); - sas_device->is_chassis_slot_valid =0 ; -if (enclosure_dev) { - sas_device->enclosure_logical_id =le64_to_cpu ( - enclosure_dev->pg0.EnclosureLogicalID); -if (le16_to_cpu (enclosure_dev->pg0.Flags) & -MPI2_SAS_ENCLS0_FLAGS_CHASSIS_SLOT_VALID ) { - sas_device->is_chassis_slot_valid =1 ; - sas_device->chassis_slot = - enclosure_dev->pg0.ChassisSlot; - } + sas_device->enclosure_handle = +le16_to_cpu (sas_device_pg0->EnclosureHandle); + sas_device->is_chassis_slot_valid =0 ; +if (enclosure_dev) { + sas_device->enclosure_logical_id =le64_to_cpu ( + enclosure_dev->pg0.EnclosureLogicalID); +if (le16_to_cpu (enclosure_dev->pg0.Flags) & +MPI2_SAS_ENCLS0_FLAGS_CHASSIS_SLOT_VALID ) { + sas_device->is_chassis_slot_valid =1 ; + sas_device->chassis_slot = + enclosure_dev->pg0.ChassisSlot; } + } -if (sas_device->handle ==le16_to_cpu ( - sas_device_pg0->DevHandle)) - goto out; -pr_info ("\thandle changed from(0x%04x)!!!\n" , - sas_device->handle); - sas_device->handle =le16_to_cpu ( - sas_device_pg0->DevHandle); -if (sas_target_priv_data) - sas_target_priv_data->handle = -le16_to_cpu (sas_device_pg0->DevHandle); +if (sas_device->handle ==le16_to_cpu ( + sas_device_pg0->DevHandle)) goto out; - } +pr_info ("\thandle changed from(0x%04x)!!!\n" , + sas_device->handle); + sas_device->handle =le16_to_cpu ( + sas_device_pg0->DevHandle); +if (sas_target_priv_data) + sas_target_priv_data->handle = +le16_to_cpu (sas_device_pg0->DevHandle); + goto out; } out:spin_unlock_irqrestore (&ioc->sas_device_lock, flags);
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 4/14 mpt3sas: Update hba_port's sas_address & phy_mask
In reply to Sreekanth ReddyUpdate hba_port's sas_address & phy_mask fields whenever a direct expander or sas/sata target devices are added or removed.
- When any direct attached device is discovered then driver
- gets the hba_port object corresponding to device's PhysicalPort number,
- update's the hba_port's sas_address field with device's SAS Address,
- update's the hba_port's phy_mask filed with device's narrow/wide port Phy number bits.
Also,
- if any sas/sata end device (not only direct direct attached devices) is added then corresponding sas_device object's port variable is assigned with hba_port object's address who's port_id matches with device's PhysicalPort number.
- if any expander device is added then corresponding sas_expander object's port variable is assigned with hba_port object's address who's port_id matches with expander device's PhysicalPort number.
- When any direct attached device is detached then driver will delete the hba_port object's corresponding to device's PhysicalPort number.
- Whenever any HBA phy's link (of direct attached device's port) comes up then update the phy_mask field of corresponding hba_port object.
- Added a new function parameter named 'port' of type struct hba_port to below functions,
* mpt3sas_transport_port_add()
* mpt3sas_transport_port_remove()
* mpt3sas_transport_update_links()
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 7 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 81 ++++++++++++++++++------ drivers/scsi/mpt3sas/mpt3sas_transport.c | 65 +++++++++++++++++-- 3 files changed, 126 insertions(+), 27 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +4 -3
@@ -1792,16 +1792,17 @@ extern struct scsi_transport_template *mpt3sas_transport_template;u8 mpt3sas_transport_done (struct MPT3SAS_ADAPTER *ioc,u16 smid,u8 msix_index,u32 reply);struct _sas_port *mpt3sas_transport_port_add (struct MPT3SAS_ADAPTER *ioc, -u16 handle,u64 sas_address); +u16 handle,u64 sas_address,struct hba_port *port);void mpt3sas_transport_port_remove (struct MPT3SAS_ADAPTER *ioc,u64 sas_address, -u64 sas_address_parent); +u64 sas_address_parent,struct hba_port *port);int mpt3sas_transport_add_host_phy (struct MPT3SAS_ADAPTER *ioc,struct _sas_phy *mpt3sas_phy,Mpi2SasPhyPage0_t phy_pg0,struct device *parent_dev);int mpt3sas_transport_add_expander_phy (struct MPT3SAS_ADAPTER *ioc,struct _sas_phy *mpt3sas_phy,Mpi2ExpanderPage1_t expander_pg1,struct device *parent_dev);void mpt3sas_transport_update_links (struct MPT3SAS_ADAPTER *ioc, -u64 sas_address,u16 handle,u8 phy_number,u8 link_rate); +u64 sas_address,u16 handle,u8 phy_number,u8 link_rate, +struct hba_port *port);extern struct sas_function_template mpt3sas_transport_functions;extern struct scsi_transport_template *mpt3sas_transport_template;/* trigger data externs */
drivers/scsi/mpt3sas/mpt3sas_scsih.c +62 -19
292 lines not on this page · raw message
drivers/scsi/mpt3sas/mpt3sas_transport.c +60 -5
158 lines not on this page · raw message
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 5/14 mpt3sas: Get device objects using sas_address & portID
In reply to Sreekanth ReddyCurrently driver retrieve the sas_devie/sas_expander objects from corresponding object's lists using just device's SAS Address. Now driver will retrieve the objects from the corresponding objects list using device's SAS Address and PhysicalPort(or PortID) number.
where
PhysicalPort number - Port number of the HBA through which this device is accessing.
Here are the list of objects that driver retrieves based on SAS Address & PhysicalPort number,
* Retrieve sas_device object from sas_device_list using device's SAS Address & PhysicalPort number,
* Retrieve sas_expander object from sas_expander_list using expander device's SAS Address & PhysicalPort number,
Also, where ever driver is matching the objects with device's SAS Address, now, in addition to it driver has to match the device PhysicalPort number also.
Added additional function parameter named 'port' of type struct hba_port in below list of functions,
* mpt3sas_expander_remove()
* mpt3sas_device_remove_by_sas_address()
* mpt3sas_scsih_expander_find_by_sas_address()
* mpt3sas_get_sdev_by_addr()
* __mpt3sas_get_sdev_by_addr()
* _scsih_ublock_io_device()
* _transport_sas_node_find_by_sas_address()
* _transport_sanity_check()
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 16 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 175 ++++++++++++++++------- drivers/scsi/mpt3sas/mpt3sas_transport.c | 74 ++++++---- 3 files changed, 178 insertions(+), 87 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +11 -5
@@ -1652,20 +1652,26 @@ int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,void mpt3sas_scsih_set_tm_flag (struct MPT3SAS_ADAPTER *ioc,u16 handle);void mpt3sas_scsih_clear_tm_flag (struct MPT3SAS_ADAPTER *ioc,u16 handle); -void mpt3sas_expander_remove (struct MPT3SAS_ADAPTER *ioc,u64 sas_address); +void mpt3sas_expander_remove (struct MPT3SAS_ADAPTER *ioc,u64 sas_address, +struct hba_port *port);void mpt3sas_device_remove_by_sas_address (struct MPT3SAS_ADAPTER *ioc, -u64 sas_address); +u64 sas_address,struct hba_port *port);u8 mpt3sas_check_for_pending_internal_cmds (struct MPT3SAS_ADAPTER *ioc,u16 smid); +struct hba_port * +mpt3sas_get_port_by_id (struct MPT3SAS_ADAPTER *ioc,u8 port);struct _sas_node *mpt3sas_scsih_expander_find_by_handle (struct MPT3SAS_ADAPTER *ioc,u16 handle);struct _sas_node *mpt3sas_scsih_expander_find_by_sas_address ( -struct MPT3SAS_ADAPTER *ioc,u64 sas_address); +struct MPT3SAS_ADAPTER *ioc,u64 sas_address, +struct hba_port *port);struct _sas_device *mpt3sas_get_sdev_by_addr ( -struct MPT3SAS_ADAPTER *ioc,u64 sas_address); +struct MPT3SAS_ADAPTER *ioc,u64 sas_address, +struct hba_port *port);struct _sas_device *__mpt3sas_get_sdev_by_addr ( -struct MPT3SAS_ADAPTER *ioc,u64 sas_address); +struct MPT3SAS_ADAPTER *ioc,u64 sas_address, +struct hba_port *port);struct _sas_device *mpt3sas_get_sdev_by_handle (struct MPT3SAS_ADAPTER *ioc,u16 handle); struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
drivers/scsi/mpt3sas/mpt3sas_scsih.c +120 -55
462 lines not on this page · raw message
drivers/scsi/mpt3sas/mpt3sas_transport.c +47 -27
207 lines not on this page · raw message
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 6/14 mpt3sas: Rename transport_del_phy_from_an_existing_port
In reply to Sreekanth Reddy* Renamed _transport_add_phy_to_an_existing_port to mpt3sas_transport_add_phy_to_an_existing_port & _transport_del_phy_from_an_existing_port to mpt3sas_transport_del_phy_from_an_existing_port, as driver has to call these functions from outside mpt3sas_transport.c file now.
* Added extra function argument 'port' of type
struct hba_port in above renamed functions.
* Also in above functions, check for portID before adding/removing the phy from the _sas_port object. i.e. add/remove the phy from _sas_port object only if _sas_port's port object and phy's port object are the same.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 7 +++++ drivers/scsi/mpt3sas/mpt3sas_transport.c | 35 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +7 -0
@@ -1811,6 +1811,13 @@ void mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc, struct hba_port *port);extern struct sas_function_template mpt3sas_transport_functions;extern struct scsi_transport_template *mpt3sas_transport_template; +void +mpt3sas_transport_del_phy_from_an_existing_port (struct MPT3SAS_ADAPTER *ioc, +struct _sas_node *sas_node,struct _sas_phy *mpt3sas_phy); +void +mpt3sas_transport_add_phy_to_an_existing_port (struct MPT3SAS_ADAPTER *ioc, +struct _sas_node *sas_node,struct _sas_phy *mpt3sas_phy, +u64 sas_address,struct hba_port *port);/* trigger data externs */ void mpt3sas_send_trigger_data_event (struct MPT3SAS_ADAPTER *ioc,struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
drivers/scsi/mpt3sas/mpt3sas_transport.c +23 -12
@@ -503,16 +503,17 @@ _transport_add_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_port *mpt3sas_port, }/** -* _transport_add_phy_to_an_existing_port - adding new phy to existing port +* mpt3sas_transport_add_phy_to_an_existing_port - adding new phy to existing port * @ioc: per adapter object * @sas_node: sas node object (either expander or sas host) * @mpt3sas_phy: mpt3sas per phy object * @sas_address: sas address of device/expander were phy needs to be added to +* @port: hba port entry */ -static void -_transport_add_phy_to_an_existing_port (struct MPT3SAS_ADAPTER *ioc, +void +mpt3sas_transport_add_phy_to_an_existing_port (struct MPT3SAS_ADAPTER *ioc,struct _sas_node *sas_node,struct _sas_phy *mpt3sas_phy, -u64 sas_address) +u64 sas_address,struct hba_port *port) {struct _sas_port *mpt3sas_port;struct _sas_phy *phy_srch;
@@ -520,11 +521,16 @@ _transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc,if (mpt3sas_phy->phy_belongs_to_port ==1 )return ; +if (!port) +return ; +list_for_each_entry (mpt3sas_port, &sas_node->sas_port_list, port_list) {if (mpt3sas_port->remote_identify.sas_address != sas_address)continue ; +if (mpt3sas_port->hba_port != port) +continue ;list_for_each_entry (phy_srch, &mpt3sas_port->phy_list, port_siblings) {if (phy_srch == mpt3sas_phy)
@@ -537,13 +543,13 @@ _transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc, }/** -* _transport_del_phy_from_an_existing_port - delete phy from existing port +* mpt3sas_transport_del_phy_from_an_existing_port - delete phy from existing port * @ioc: per adapter object * @sas_node: sas node object (either expander or sas host) * @mpt3sas_phy: mpt3sas per phy object */ -static void -_transport_del_phy_from_an_existing_port (struct MPT3SAS_ADAPTER *ioc, +void +mpt3sas_transport_del_phy_from_an_existing_port (struct MPT3SAS_ADAPTER *ioc,struct _sas_node *sas_node,struct _sas_phy *mpt3sas_phy) {struct _sas_port *mpt3sas_port, *next;
@@ -559,7 +565,11 @@ _transport_del_phy_from_an_existing_port(struct MPT3SAS_ADAPTER *ioc,if (phy_srch != mpt3sas_phy)continue ; -if (mpt3sas_port->num_phys ==1 ) +/* +* Don't delete port during host reset, +* just delete phy. +*/ +if (mpt3sas_port->num_phys ==1 && !ioc->shost_recovery)_transport_delete_port (ioc, mpt3sas_port);else _transport_delete_phy(ioc, mpt3sas_port,
@@ -590,8 +600,8 @@ _transport_sanity_check(struct MPT3SAS_ADAPTER *ioc, struct _sas_node *sas_node,if (sas_node->phy[i].port != port)continue ;if (sas_node->phy[i].phy_belongs_to_port ==1 ) -_transport_del_phy_from_an_existing_port (ioc, sas_node, - &sas_node->phy[i]); +mpt3sas_transport_del_phy_from_an_existing_port (ioc, + sas_node, &sas_node->phy[i]); } }
@@ -1040,8 +1050,6 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,if (handle && (link_rate >=MPI2_SAS_NEG_LINK_RATE_1_5 )) {_transport_set_identify (ioc, handle, &mpt3sas_phy->remote_identify); -_transport_add_phy_to_an_existing_port (ioc, sas_node, - mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address);if (sas_node->handle <= ioc->sas_hba.num_phys) {list_for_each_entry (hba_port, &ioc->port_table_list, list) {
@@ -1051,6 +1059,9 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc, (1 << mpt3sas_phy->phy_id); } } +mpt3sas_transport_add_phy_to_an_existing_port (ioc, sas_node, + mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address, + port); }else memset (&mpt3sas_phy->remote_identify,0 ,sizeof (struct sas_identify ));
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 7/14 mpt3sas: Get sas_device objects using device's rphy
In reply to Sreekanth ReddyIn below scsi_host_template & sas_function_template callback functions, the driver won't have PhysicalPort number information to retrieve the sas_device object using SAS Address & PhysicalPort number. So, in these callback functions the device's rphy object is used to retrieve sas_device object for the device.
.target_alloc,
.get_enclosure_identifier
.get_bay_identifier
When a rphy (of type sas_rphy) object is allocated then it's address is saved in corresponding sas_device object's rphy field. so in __mpt3sas_get_sdev_by_rphy(), driver loops over all the sas_device objects from sas_device_list list to retrieve the sas_device objects who's rphy matches with provided rphy.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 5 +++ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 41 ++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_transport.c | 7 ++-- 3 files changed, 47 insertions(+), 6 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +5 -0
@@ -537,6 +537,8 @@ struct _internal_cmd {* @chassis_slot: chassis slot * @is_chassis_slot_valid: chassis slot valid or not * @port: hba port entry containing device's port number info +* @rphy: device's sas_rphy address used to identify this device structure in +* target_alloc callback function */ struct _sas_device {struct list_head list;
@@ -564,6 +566,7 @@ struct _sas_device {u8 connector_name[5 ];struct kref refcount;struct hba_port *port; +struct sas_rphy *rphy; };static inline void sas_device_get (struct _sas_device *s)
@@ -1681,6 +1684,8 @@ void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);struct _raid_device *mpt3sas_raid_device_find_by_handle (struct MPT3SAS_ADAPTER *ioc,u16 handle);void mpt3sas_scsih_change_queue_depth (struct scsi_device *sdev,int qdepth); +struct _sas_device * +__mpt3sas_get_sdev_by_rphy (struct MPT3SAS_ADAPTER *ioc,struct sas_rphy *rphy);/* config shared API */ u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
drivers/scsi/mpt3sas/mpt3sas_scsih.c +39 -2
53 lines not on this page · raw message
drivers/scsi/mpt3sas/mpt3sas_transport.c +3 -4
@@ -733,6 +733,7 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle, mpt3sas_port->port = port;if (mpt3sas_port->remote_identify.device_type ==SAS_END_DEVICE ) { rphy =sas_end_device_alloc (port); + sas_device->rphy = rphy;if (sas_node->handle <= ioc->sas_hba.num_phys) hba_port->sas_address = sas_device->sas_address; }else {
@@ -1342,8 +1343,7 @@ _transport_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)int rc;spin_lock_irqsave (&ioc->sas_device_lock, flags); - sas_device =__mpt3sas_get_sdev_by_addr (ioc, - rphy->identify.sas_address,0 ); + sas_device =__mpt3sas_get_sdev_by_rphy (ioc, rphy);if (sas_device) { *identifier = sas_device->enclosure_logical_id; rc =0 ;
@@ -1372,8 +1372,7 @@ _transport_get_bay_identifier(struct sas_rphy *rphy)int rc;spin_lock_irqsave (&ioc->sas_device_lock, flags); - sas_device =__mpt3sas_get_sdev_by_addr (ioc, - rphy->identify.sas_address,0 ); + sas_device =__mpt3sas_get_sdev_by_rphy (ioc, rphy);if (sas_device) { rc = sas_device->slot;sas_device_put (sas_device);
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 8/14 mpt3sas: Update hba_port objects after host reset
In reply to Sreekanth ReddyDuring host reset there are chances that the Port number allocated by the firmware for the attached devices may change. Also it may be possible that some HBA phy’s may go down/come up after reset. So the driver can’t just trust the HBA Port table that it has populated before host reset as valid. So it has to update the HBA Port table in such a way that it shouldn’t disturb the drives which are still accessible even after host reset.
Driver follows below algorithm to update the ‘HBA Port table’ during host reset,
I. After host reset operation and before marking the
devices as responding/non-responding, create a temporary Port table called “New Port table” by parsing each of the HBA PHY’s Phy data info read from SAS IOUnit Page0,
a. Check whether Phy’s negotiated link rate is greater
than 1.5Gbps, if not go to next Phy,
b. Get the SAS Address of the attached device,
c. Create a new entry in the ‘New Port table’ with
SAS Address field filled with attached device’s SAS Address, port number with Phy’s Port number (read from SAS IOUnit Page0) and enable bit in the ‘Phy mask’ field corresponding to current Phy number. New entry is created only if the driver won’t find any entry in the ‘New Port table’ which matches with attached device ‘SAS Address’ & ‘Port Number’. If it finds an entry with matches with attached device ‘SAS Address’ & ‘Port Number’ then the driver takes that matched entry and will enable current Phy number bit in the ‘Phy mask’ field.
d. After parsing all the HBA phy’s info, the driver will
have complete Port table info in “New Port table”.
II. Mark all the existing sas_device & sas_expander device
structures as ‘dirty’.
III. Mark each entry of the HBA Port list’s as ‘dirty’. IV. Take each entry from ‘New Port table’ one by one and check
whether the taken entry has any corresponding matched entry (which is marked as ‘dirty’) in the HBA Port table or not. While looking for a corresponding matched entry, look for matched entry in the sequence from top row to bottom row listed in below table. If you find any matched entry (according to any of the rules tabulated below) then perform the action mentioned in the ‘Action’ column in that matched rule.
===========================================================================
|Search |SAS | Phy Mask | Port | Possibilities| Action | |every |Address | or | Number | | required | |entry |matched?| subset of| matched?| | | |in below| | phy mask | | | | |sequence| | matched? | | | | =========================================================================== | 1 |matched | matched | matched | nothing |* unmark HBA port | | | | | | changed |table entry as | | | | | | |dirty | --------------------------------------------------------------------------- | 2 |matched | matched | not | port number |* Update port | | | | | matched | is changed |number in the | | | | | | |matched port table | | | | | | |entry | | | | | | |* unmask HBA port | | | | | | |table entry as | | | | | | | dirty | --------------------------------------------------------------------------- | 3.a |matched | subset of| matched |some phys |*Add these new phys| | | | phy mask | (or) |might have |to current port in | | | | matched | not |enabled which |STL | | | | | matched |are previously|* Update phy mask | | | | | (but |disabled |field in HBA's port| | | | | first | |tables's matched | | | | | look for| |entry, | | | | | matched | |*Update port number| | | | | one) | |in the matched port| | | | | | |table entry (if | | | | | | |port number is | | | | | | |changed), | | | | | | |* Unmask HBA port | | | | | | |table entry as | | | | | | |dirty | --------------------------------------------------------------------------- | 3.b |matched | subset of| matched |some phys |*Remove these phys | | | | phy mask | (or) |might have |from current port | | | | matched | not |disabled which|in STL | | | | | matched |are previously|* Update phy mask | | | | | (but |enabled |field in HBA's port| | | | | first | |tables's matched | | | | | look for| |entry, | | | | | matched | |*Update port number| | | | | one) | |in the matched port| | | | | | |table entry (if | | | | | | |port number is | | | | | | |changed), | | | | | | |* Unmask HBA port | | | | | | |table entry as | | | | | | |dirty | --------------------------------------------------------------------------- | 4 |matched | not | matched |A cable |*Remove old phys & | | | | matched | (or) |attached to an|new phys to current| | | | | not |expander is |port in STL | | | | | matched |changed to |* Update phy mask | | | | | |another HBA |field in HBA's port| | | | | |port during |tables's matched | | | | | |reset |entry, | | | | | | |*Update port number| | | | | | |in the matched port| | | | | | |table entry (if | | | | | | |port number is | | | | | | |changed), | | | | | | |* Unmask HBA port | | | | | | |table entry as | | | | | | |dirty |
---------------------------------------------------------------------------
V. Delete the hba_port objects which are still marked as dirty.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 337 +++++++++++++++++++++++++++ 1 file changed, 337 insertions(+)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +337 -0
@@ -5816,6 +5816,341 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)return 0 ; } +/** +* _scsih_get_port_table_after_reset - Construct temporary port table +* @ioc: per adapter object +* @port_table: address where port table needs to be constructed +* +* return number of HBA port entries available after reset. +*/ +static int +_scsih_get_port_table_after_reset (struct MPT3SAS_ADAPTER *ioc, +struct hba_port *port_table) +{ +u16 sz, ioc_status; +int i, j; +Mpi2ConfigReply_t mpi_reply; +Mpi2SasIOUnitPage0_t *sas_iounit_pg0 =NULL ; +u16 attached_handle; +u64 attached_sas_addr; +u8 found =0 , port_count =0 , port_id; + + sz = offsetof(Mpi2SasIOUnitPage0_t , PhyData) + (ioc->sas_hba.num_phys + *sizeof (Mpi2SasIOUnit0PhyData_t)); + sas_iounit_pg0 =kzalloc (sz,GFP_KERNEL ); +if (!sas_iounit_pg0) { +ioc_err (ioc,"failure at %s:%d/%s()!\n" , + __FILE__, __LINE__, __func__); +return port_count; + } + +if ((mpt3sas_config_get_sas_iounit_pg0 (ioc, &mpi_reply, + sas_iounit_pg0, sz)) !=0 ) + goto out; + ioc_status =le16_to_cpu (mpi_reply.IOCStatus) &MPI2_IOCSTATUS_MASK ; +if (ioc_status !=MPI2_IOCSTATUS_SUCCESS ) + goto out; +for (i =0 ; i < ioc->sas_hba.num_phys; i++) { + found =0 ; +if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >>4 ) < +MPI2_SAS_NEG_LINK_RATE_1_5 ) +continue ; + attached_handle = +le16_to_cpu (sas_iounit_pg0->PhyData[i].AttachedDevHandle); +if (_scsih_get_sas_address ( + ioc, attached_handle, &attached_sas_addr) !=0 ) { +ioc_err (ioc,"failure at %s:%d/%s()!\n" , + __FILE__, __LINE__, __func__); +continue ; + } + +for (j =0 ; j < port_count; j++) { + port_id = sas_iounit_pg0->PhyData[i].Port; +if (port_table[j].port_id == port_id && + port_table[j].sas_address == attached_sas_addr) { + port_table[j].phy_mask |= (1 << i); + found =1 ; +break ; + } + } + +if (found) +continue ; + + port_id = sas_iounit_pg0->PhyData[i].Port; + port_table[port_count].port_id = port_id; + port_table[port_count].phy_mask = (1 << i); + port_table[port_count].sas_address = attached_sas_addr; + port_count++; + } +out: +kfree (sas_iounit_pg0); +return port_count; +} + +enum hba_port_matched_codes { +MATCHED_WITH_ADDR_AND_PHYMASK =1 , +MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT , +MATCHED_WITH_ADDR_AND_SUBPHYMASK , +MATCHED_WITH_ADDR , +}; + +/** +* _scsih_look_and_get_matched_port_entry - Get matched hba port entry +* from HBA port table +* @ioc: per adapter object +* @port_entry - hba port entry from temporary port table which needs to be +* searched for matched entry in the HBA port table +* @matched_port_entry - save matched hba port entry here +* @count - count of matched entries +* +* return type of matched entry found. +*/ +static enum hba_port_matched_codes +_scsih_look_and_get_matched_port_entry (struct MPT3SAS_ADAPTER *ioc, +struct hba_port *port_entry, +struct hba_port **matched_port_entry,int *count) +{ +struct hba_port *port_table_entry, *matched_port =NULL ; +enum hba_port_matched_codes matched_code; +int lcount =0 ; + *matched_port_entry =NULL ; + +list_for_each_entry (port_table_entry, &ioc->port_table_list, list) { +if (!(port_table_entry->flags &HBA_PORT_FLAG_DIRTY_PORT )) +continue ; + +if ((port_table_entry->sas_address == port_entry->sas_address) + && (port_table_entry->phy_mask == port_entry->phy_mask)) { + matched_code =MATCHED_WITH_ADDR_AND_PHYMASK ; + matched_port = port_table_entry; +break ; + } + +if ((port_table_entry->sas_address == port_entry->sas_address) + && (port_table_entry->phy_mask & port_entry->phy_mask) + && (port_table_entry->port_id == port_entry->port_id)) { + matched_code =MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT ; + matched_port = port_table_entry; +continue ; + } + +if ((port_table_entry->sas_address == port_entry->sas_address) + && (port_table_entry->phy_mask & port_entry->phy_mask)) { +if (matched_code == +MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT ) +continue ; + matched_code =MATCHED_WITH_ADDR_AND_SUBPHYMASK ; + matched_port = port_table_entry; +continue ; + } + +if (port_table_entry->sas_address == port_entry->sas_address) { +if (matched_code == +MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT ) +continue ; +if (matched_code ==MATCHED_WITH_ADDR_AND_SUBPHYMASK ) +continue ; + matched_code =MATCHED_WITH_ADDR ; + matched_port = port_table_entry; + lcount++; + } + } + + *matched_port_entry = matched_port; +if (matched_code ==MATCHED_WITH_ADDR ) + *count = lcount; +return matched_code; +} + +/** +* _scsih_del_phy_part_of_anther_port - remove phy if it +* is a part of anther port +*@ioc: per adapter object +*@port_table: port table after reset +*@index: hba port entry index +*@port_count: number of ports available after host reset +*@offset: HBA phy bit offset +* +*/ +static void +_scsih_del_phy_part_of_anther_port (struct MPT3SAS_ADAPTER *ioc, +struct hba_port *port_table, +int index,u8 port_count,int offset) +{ +struct _sas_node *sas_node = &ioc->sas_hba; +u32 i, found =0 ; + +for (i =0 ; i < port_count; i++) { +if (i == index) +continue ; + +if (port_table[i].phy_mask & (1 << offset)) { +mpt3sas_transport_del_phy_from_an_existing_port ( + ioc, sas_node, &sas_node->phy[offset]); + found =1 ; +break ; + } + } +if (!found) + port_table[index].phy_mask |= (1 << offset); +} + +/** +* _scsih_add_or_del_phys_from_existing_port - add/remove phy to/from +* right port +*@ioc: per adapter object +*@hba_port_entry: hba port table entry +*@port_table: temporary port table +*@index: hba port entry index +*@port_count: number of ports available after host reset +* +*/ +static void +_scsih_add_or_del_phys_from_existing_port (struct MPT3SAS_ADAPTER *ioc, +struct hba_port *hba_port_entry,struct hba_port *port_table, +int index,int port_count) +{ +u32 phy_mask, offset =0 ; +struct _sas_node *sas_node = &ioc->sas_hba; + + phy_mask = hba_port_entry->phy_mask ^ port_table[index].phy_mask; + +for (offset =0 ; offset < ioc->sas_hba.num_phys; offset++) { +if (phy_mask & (1 << offset)) { +if (!(port_table[index].phy_mask & (1 << offset))) { +_scsih_del_phy_part_of_anther_port ( + ioc, port_table, index, port_count, + offset); +continue ; + } +if (sas_node->phy[offset].phy_belongs_to_port) +mpt3sas_transport_del_phy_from_an_existing_port ( + ioc, sas_node, &sas_node->phy[offset]); +mpt3sas_transport_add_phy_to_an_existing_port ( + ioc, sas_node, &sas_node->phy[offset], + hba_port_entry->sas_address, + hba_port_entry); + } + } +} + +/** +* _scsih_del_dirty_port_entries - delete dirty port entries from port list +* after host reset +*@ioc: per adapter object +* +*/ +static void +_scsih_del_dirty_port_entries (struct MPT3SAS_ADAPTER *ioc) +{ +struct hba_port *port, *port_next; + +list_for_each_entry_safe (port, port_next, + &ioc->port_table_list, list) { +if (!(port->flags &HBA_PORT_FLAG_DIRTY_PORT ) || + port->flags &HBA_PORT_FLAG_NEW_PORT ) +continue ; + +drsprintk (ioc,ioc_info (ioc, +"Deleting port table entry %p having Port: %d\t Phy_mask 0x%08x\n" , + port, port->port_id, port->phy_mask)); +list_del (&port->list); +kfree (port); + } +} + +/** +* _scsih_sas_port_refresh - Update HBA port table after host reset +* @ioc: per adapter object +*/ +static void +_scsih_sas_port_refresh (struct MPT3SAS_ADAPTER *ioc) +{ +u32 port_count =0 ; +struct hba_port *port_table; +struct hba_port *port_table_entry; +struct hba_port *port_entry =NULL ; +int i, j, count =0 , lcount =0 ; +int ret; +u64 sas_addr; + +drsprintk (ioc,ioc_info (ioc, +"updating ports for sas_host(0x%016llx)\n" , + (unsigned long long )ioc->sas_hba.sas_address)); + + port_table =kcalloc (ioc->sas_hba.num_phys, +sizeof (struct hba_port ),GFP_KERNEL ); +if (!port_table) +return ; + + port_count =_scsih_get_port_table_after_reset (ioc, port_table); +if (!port_count) +return ; + +drsprintk (ioc,ioc_info (ioc,"New Port table\n" )); +for (j =0 ; j < port_count; j++) +drsprintk (ioc,ioc_info (ioc, +"Port: %d\t Phy_mask 0x%08x\t sas_addr(0x%016llx)\n" , + port_table[j].port_id, + port_table[j].phy_mask, port_table[j].sas_address)); + +list_for_each_entry (port_table_entry, &ioc->port_table_list, list) + port_table_entry->flags |=HBA_PORT_FLAG_DIRTY_PORT ; + +drsprintk (ioc,ioc_info (ioc,"Old Port table\n" )); + port_table_entry =NULL ; +list_for_each_entry (port_table_entry, &ioc->port_table_list, list) { +drsprintk (ioc,ioc_info (ioc, +"Port: %d\t Phy_mask 0x%08x\t sas_addr(0x%016llx)\n" , + port_table_entry->port_id, + port_table_entry->phy_mask, + port_table_entry->sas_address)); + } + +for (j =0 ; j < port_count; j++) { + ret =_scsih_look_and_get_matched_port_entry (ioc, + &port_table[j], &port_entry, &count); +if (!port_entry) { +drsprintk (ioc,ioc_info (ioc, +"No Matched entry for sas_addr(0x%16llx), Port:%d\n" , + port_table[j].sas_address, + port_table[j].port_id)); +continue ; + } + +switch (ret) { +case MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT : +case MATCHED_WITH_ADDR_AND_SUBPHYMASK : +_scsih_add_or_del_phys_from_existing_port (ioc, + port_entry, port_table, j, port_count); +break ; +case MATCHED_WITH_ADDR : + sas_addr = port_table[j].sas_address; +for (i =0 ; i < port_count; i++) { +if (port_table[i].sas_address == sas_addr) + lcount++; + } + +if (count >1 || lcount >1 ) + port_entry =NULL ; +else +_scsih_add_or_del_phys_from_existing_port (ioc, + port_entry, port_table, j, port_count); + } + +if (!port_entry) +continue ; + +if (port_entry->port_id != port_table[j].port_id) + port_entry->port_id = port_table[j].port_id; + port_entry->flags &= ~HBA_PORT_FLAG_DIRTY_PORT ; + port_entry->phy_mask = port_table[j].phy_mask; + } + + port_table_entry =NULL ; +} +/** * _scsih_sas_host_refresh - refreshing sas host object contents * @ioc: per adapter object
@@ -9790,6 +10125,7 @@ mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)dtmprintk (ioc,ioc_info (ioc,"%s: MPT3_IOC_DONE_RESET\n" , __func__));if ((!ioc->is_driver_loading) && !(disable_discovery >0 && !ioc->sas_hba.num_phys)) { +_scsih_sas_port_refresh (ioc);_scsih_prep_device_scan (ioc);_scsih_create_enclosure_list_after_reset (ioc);_scsih_search_responding_sas_devices (ioc);
@@ -9837,6 +10173,7 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)ssleep (1 ); }_scsih_remove_unresponding_devices (ioc); +_scsih_del_dirty_port_entries (ioc);_scsih_scan_for_devices_after_reset (ioc);_scsih_set_nvme_max_shutdown_latency (ioc);break ;
Signature · 1 line
2.18.4
Re: [PATCH 08/14] mpt3sas: Update hba_port objects after host reset
Hi Sreekanth,
url: https://github.com/0day-ci/linux/commits/Sreekanth-Reddy/mpt3sas-Add-support-for-multi-port-path-topology/20201010-011607 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next config: s390-randconfig-m031-20201009 (attached as .config) compiler: s390-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
New smatch warnings:drivers/scsi/mpt3sas/mpt3sas_scsih.c:5940 _scsih_look_and_get_matched_port_entry() error: uninitialized symbol 'matched_code'.
Old smatch warnings:drivers/scsi/mpt3sas/mpt3sas_scsih.c:5949 _scsih_look_and_get_matched_port_entry() error: uninitialized symbol 'matched_code'. drivers/scsi/mpt3sas/mpt3sas_scsih.c:5961 _scsih_look_and_get_matched_port_entry() error: uninitialized symbol 'matched_code'. drivers/scsi/mpt3sas/mpt3sas_scsih.c:6472 _scsih_expander_add() warn: returning -1 instead of -ENOMEM is sloppy drivers/scsi/mpt3sas/mpt3sas_scsih.c:10234 _mpt3sas_fw_work() warn: inconsistent indenting
vim +/matched_code +5940 drivers/scsi/mpt3sas/mpt3sas_scsih.c
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5909 static enum hba_port_matched_codes
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5910 _scsih_look_and_get_matched_port_entry(struct MPT3SAS_ADAPTER *ioc,
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5911 struct hba_port *port_entry,
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5912 struct hba_port **matched_port_entry, int *count)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5913 {
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5914 struct hba_port *port_table_entry, *matched_port = NULL;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5915 enum hba_port_matched_codes matched_code;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^2756bd46f6fdde Sreekanth Reddy 2020-10-09 5916 int lcount = 0;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5917 *matched_port_entry = NULL;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5918
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5919 list_for_each_entry(port_table_entry, &ioc->port_table_list, list) {
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5920 if (!(port_table_entry->flags & HBA_PORT_FLAG_DIRTY_PORT))
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5921 continue;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5922
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5923 if ((port_table_entry->sas_address == port_entry->sas_address)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5924 && (port_table_entry->phy_mask == port_entry->phy_mask)) {
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5925 matched_code = MATCHED_WITH_ADDR_AND_PHYMASK;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5926 matched_port = port_table_entry;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5927 break;This is a break statement.
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5928 }
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5929
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5930 if ((port_table_entry->sas_address == port_entry->sas_address)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5931 && (port_table_entry->phy_mask & port_entry->phy_mask)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5932 && (port_table_entry->port_id == port_entry->port_id)) {This is only true if "port_table_entry->port_id == port_entry->port_id"
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5933 matched_code = MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5934 matched_port = port_table_entry;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5935 continue;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5936 }
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5937
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5938 if ((port_table_entry->sas_address == port_entry->sas_address)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5939 && (port_table_entry->phy_mask & port_entry->phy_mask)) {
2756bd46f6fdde Sreekanth Reddy 2020-10-09 @5940 if (matched_code ==
^^^^^^^^^^^^Possibly uninitialized. Smatch only complains about the first intance otherwise it would probably complain about after the loop as well.
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5941 MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5942 continue;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5943 matched_code = MATCHED_WITH_ADDR_AND_SUBPHYMASK;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5944 matched_port = port_table_entry;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5945 continue;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5946 }
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5947
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5948 if (port_table_entry->sas_address == port_entry->sas_address) {
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5949 if (matched_code ==
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5950 MATCHED_WITH_ADDR_SUBPHYMASK_AND_PORT)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5951 continue;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5952 if (matched_code == MATCHED_WITH_ADDR_AND_SUBPHYMASK)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5953 continue;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5954 matched_code = MATCHED_WITH_ADDR;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5955 matched_port = port_table_entry;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5956 lcount++;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5957 }
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5958 }
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5959
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5960 *matched_port_entry = matched_port;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5961 if (matched_code == MATCHED_WITH_ADDR)
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5962 *count = lcount;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5963 return matched_code;
2756bd46f6fdde Sreekanth Reddy 2020-10-09 5964 }---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Sreekanth Reddy
maintainerPATCH 9/14 mpt3sas: Set valid PhysicalPort in SMPPassThrough
In reply to Sreekanth ReddyCurrent driver is always setting PhysicalPort field as 0xFF for SMPPassthrough Request message. So in zoning topologies this SMPPassthrough command always operates on devices in one zone (default zone) even when user issues SMP command for other zone drives.
Now helper functions _transport_get_port_id_by_rphy() & _transport_get_port_id_by_sas_phy() are defined to get Physical Port number from sas_rphy & sas_phy respectively for SMPPassthrough request message so that SMP Passthrough request message is send to intended zone device.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 + drivers/scsi/mpt3sas/mpt3sas_scsih.c | 1 + drivers/scsi/mpt3sas/mpt3sas_transport.c | 75 ++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 6 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +2 -0
@@ -788,6 +788,7 @@ struct _sas_phy {* @phy: a list of phys that make up this sas_host/expander * @sas_port_list: list of ports attached to this sas_host/expander * @port: hba port entry containing node's port number info +* @rphy: sas_rphy object of this expander */ struct _sas_node {struct list_head list;
@@ -802,6 +803,7 @@ struct _sas_node {struct hba_port *port;struct _sas_phy *phy;struct list_head sas_port_list; +struct sas_rphy *rphy; };/**
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -0
@@ -6509,6 +6509,7 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) goto out_fail; } sas_expander->parent_dev = &mpt3sas_port->rphy->dev; + sas_expander->rphy = mpt3sas_port->rphy;for (i =0 ; i < sas_expander->num_phys ; i++) { if ((mpt3sas_config_get_expander_pg1(ioc, &mpi_reply,
drivers/scsi/mpt3sas/mpt3sas_transport.c +69 -6
135 lines not on this page · raw message
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 10/14 mpt3sas: Handling HBA vSES device
In reply to Sreekanth ReddyEach direct attached device will have a unique Port ID, but with an exception. i.e. HBA vSES may use the same Port ID of another direct attached device Port's ID. So special handling is needed for vSES.
Create a virtual_phy object when a new HBA vSES device is detected and add this virtual_phy object to vphys_list of port ID's hba_port object.
When the HBA vSES device is removed then remove the corresponding virtual_phy object from it's parent's hba_port's vphy_list and free this virtual_vphy object.
Below are variables of virtual_phy objects,
sas_address: SAS address of vSES device, phy_mask: HBA phy bit which is assigned to vSES device flag: used during host reset to refresh this virtual_phy object
In hba_port object added vphy_mask field to hold the list of HBA phy bits which are assigned to vSES devices, Also added vphy_list list to hold list of virtual_phy objects which holds the same portID of current hba_port's portID.
Also, added a hba_vphy field in _sas_phy object to determine whether this _sas_phy object belongs to vSES device or not.
- Allocate a virtual_phy object whenever a virtual phy is detected while processing the SASIOUnitPage0's phy data. And this allocated virtual_phy object to corresponding PortID''s hba_port's vphy_list.
- When a vSES device is added to the SML then initialize the corresponding virtual_phy objects's sas_address field with vSES device's SAS Address.
- Free this virtual_phy object during driver unload time and when this vSES device is removed.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 23 +++++ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 106 +++++++++++++++++++++++ drivers/scsi/mpt3sas/mpt3sas_transport.c | 80 ++++++++++++++--- 3 files changed, 198 insertions(+), 11 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +23 -0
@@ -771,6 +771,7 @@ struct _sas_phy {u16 handle;u16 attached_handle;u8 phy_belongs_to_port; +u8 hba_vphy;struct hba_port *port; };
@@ -1023,12 +1024,29 @@ struct reply_post_struct {dma_addr_t reply_post_free_dma; }; +/** +* struct virtual_phy - vSES phy structure +* sas_address: SAS Address of vSES device +* phy_mask: vSES device's phy number +* flags: flags used to manage this structure +*/ +struct virtual_phy { +struct list_head list; +u64 sas_address; +u32 phy_mask; +u8 flags; +}; + +#define MPT_VPHY_FLAG_DIRTY_PHY 0x01 +/** * struct hba_port - Saves each HBA's Wide/Narrow port info * @sas_address: sas address of this wide/narrow port's attached device * @phy_mask: HBA PHY's belonging to this port * @port_id: port number * @flags: hba port flags +* @vphys_mask : mask of vSES devices Phy number +* @vphys_list : list containing vSES device structures */ struct hba_port {struct list_head list;
@@ -1036,6 +1054,8 @@ struct hba_port {u32 phy_mask;u8 port_id;u8 flags; +u32 vphys_mask; +struct list_head vphys_list; };/* hba port flags */
@@ -1688,6 +1708,9 @@ mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);void mpt3sas_scsih_change_queue_depth (struct scsi_device *sdev,int qdepth);struct _sas_device *__mpt3sas_get_sdev_by_rphy (struct MPT3SAS_ADAPTER *ioc,struct sas_rphy *rphy); +struct virtual_phy * +mpt3sas_get_vphy_by_phy (struct MPT3SAS_ADAPTER *ioc, +struct hba_port *port,u32 phy);/* config shared API */ u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
drivers/scsi/mpt3sas/mpt3sas_scsih.c +106 -0
136 lines not on this page · raw message
drivers/scsi/mpt3sas/mpt3sas_transport.c +69 -11
115 lines not on this page · raw message
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 11/14 mpt3sas: Add bypass_dirty_port_flag parameter
In reply to Sreekanth ReddyAdded a new parameter bypass_dirty_port_flag in function mpt3sas_get_port_by_id(). When this parameter is set to one then search for matching hba port entry from port_table_list even when this hba_port entry is marked as dirty.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 3 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 63 ++++++++++++++---------- drivers/scsi/mpt3sas/mpt3sas_transport.c | 8 +-- 3 files changed, 44 insertions(+), 30 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +2 -1
@@ -1684,7 +1684,8 @@ void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,u8 mpt3sas_check_for_pending_internal_cmds (struct MPT3SAS_ADAPTER *ioc,u16 smid);struct hba_port * -mpt3sas_get_port_by_id (struct MPT3SAS_ADAPTER *ioc,u8 port); +mpt3sas_get_port_by_id (struct MPT3SAS_ADAPTER *ioc,u8 port, +u8 bypass_dirty_port_flag);struct _sas_node *mpt3sas_scsih_expander_find_by_handle (struct MPT3SAS_ADAPTER *ioc,u16 handle);
drivers/scsi/mpt3sas/mpt3sas_scsih.c +38 -25
212 lines not on this page · raw message
drivers/scsi/mpt3sas/mpt3sas_transport.c +4 -4
@@ -1414,7 +1414,7 @@ _transport_get_linkerrors(struct sas_phy *phy)spin_lock_irqsave (&ioc->sas_node_lock, flags);if (_transport_sas_node_find_by_sas_address (ioc, phy->identify.sas_address, -mpt3sas_get_port_by_id (ioc, port_id)) ==NULL ) { +mpt3sas_get_port_by_id (ioc, port_id,0 )) ==NULL ) {spin_unlock_irqrestore (&ioc->sas_node_lock, flags);return -EINVAL ; }
@@ -1703,7 +1703,7 @@ _transport_phy_reset(struct sas_phy *phy, int hard_reset)spin_lock_irqsave (&ioc->sas_node_lock, flags);if (_transport_sas_node_find_by_sas_address (ioc, phy->identify.sas_address, -mpt3sas_get_port_by_id (ioc, port_id)) ==NULL ) { +mpt3sas_get_port_by_id (ioc, port_id,0 )) ==NULL ) {spin_unlock_irqrestore (&ioc->sas_node_lock, flags);return -EINVAL ; }
@@ -1762,7 +1762,7 @@ _transport_phy_enable(struct sas_phy *phy, int enable)spin_lock_irqsave (&ioc->sas_node_lock, flags);if (_transport_sas_node_find_by_sas_address (ioc, phy->identify.sas_address, -mpt3sas_get_port_by_id (ioc, port_id)) ==NULL ) { +mpt3sas_get_port_by_id (ioc, port_id,0 )) ==NULL ) {spin_unlock_irqrestore (&ioc->sas_node_lock, flags);return -EINVAL ; }
@@ -1902,7 +1902,7 @@ _transport_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates)spin_lock_irqsave (&ioc->sas_node_lock, flags);if (_transport_sas_node_find_by_sas_address (ioc, phy->identify.sas_address, -mpt3sas_get_port_by_id (ioc, port_id)) ==NULL ) { +mpt3sas_get_port_by_id (ioc, port_id,0 )) ==NULL ) {spin_unlock_irqrestore (&ioc->sas_node_lock, flags);return -EINVAL ; }
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 12/14 mpt3sas: Handle vSES vphy object during HBA reset
In reply to Sreekanth ReddyDuring HBA reset, Port ID of vSES device may change. So, need to refresh virtual_phy objects after reset.
Each Port’s vphy_list table needs to be updated after updating the HBA port table. Follow the below algorithm to update each Port’s vphy_list table.
• Loop over each port entry from HBA port table
* Loop over each virtual phy entry from port’s vphys_list table
- Mark virtual phy entry as dirty by setting dirty bit in virtual phy entry’s flags field
• Read SASIOUnitPage0 page
• Loop over each HBA Phy’s Phy data from SASIOUnitPage0
* If phy’s remote attached device is not SES device then continue with processing next HBA Phy’s Phy data,
* Read SASPhyPage0 data for this Phy number and determine whether current phy is a virtual phy or not. If it is not a virtual phy then continue with next Phy data,
* Get the current phy’s remote attached vSES device’s SAS Address,
* Loop over each port entry from HBA port table
- If Port’s vphys_mask field is zero then continue with next Port entry,
- Loop over each virtual phy entry from Port’s vphy_list table
• If the current phy’s remote SAS Address is different from virtual phy entry’s SAS Address then continue with next virtual phy entry,
• Set bit corresponding to current phy number in virtual phy entry’s of phy_mask field,
• Get the HBA port table’s Port entry corresponding to Phy data’s ‘Port’ value,
* If there is no Port entry corresponding to Phy data’s ‘Port’ value in HBA port table then create a new port entry and add it to HBA port table.
• If this retrieved Port entry is the same as the current Port entry then don’t do anything, just clear the dirty bit from virtual phy entry’s flag field and continue with processing next HBA Phy’s Phy data.
• If this retrieved Port entry is different from the current Port entry then move the current virtual phy entry from current Port’s vphys_list to retrieved Port entry’s vphys_list.
* Clear current phy bit in current Port entry’s vphys_mask and set the current phy bit in the retrieved Port entry’s vphys_mask field.
* Clear the dirty bit from virtual phy entry’s flag field and continue with next HBA Phy’s Phy data.
• Delete the ‘virtual phy’ entries and HBA’s ‘Port table’ entries which are still marked as ‘dirty’.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 233 +++++++++++++++++++++++++++ 1 file changed, 233 insertions(+)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +233 -0
@@ -5847,6 +5847,204 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)return 0 ; } +/** +* _scsih_update_vphys_after_reset - update the Port's +* vphys_list after reset +* @ioc: per adapter object +* +* Returns nothing. +*/ +static void +_scsih_update_vphys_after_reset (struct MPT3SAS_ADAPTER *ioc) +{ +u16 sz, ioc_status; +int i; +Mpi2ConfigReply_t mpi_reply; +Mpi2SasIOUnitPage0_t *sas_iounit_pg0 =NULL ; +u16 attached_handle; +u64 attached_sas_addr; +u8 found =0 , port_id; +Mpi2SasPhyPage0_t phy_pg0; +struct hba_port *port, *port_next, *mport; +struct virtual_phy *vphy, *vphy_next; +struct _sas_device *sas_device; + +/* +* Mark all the vphys objects as dirty. +*/ +list_for_each_entry_safe (port, port_next, + &ioc->port_table_list, list) { +if (!port->vphys_mask) +continue ; +list_for_each_entry_safe (vphy, vphy_next, + &port->vphys_list, list) { + vphy->flags |=MPT_VPHY_FLAG_DIRTY_PHY ; + } + } + +/* +* Read SASIOUnitPage0 to get each HBA Phy's data. +*/ + sz = offsetof(Mpi2SasIOUnitPage0_t , PhyData) + + (ioc->sas_hba.num_phys *sizeof (Mpi2SasIOUnit0PhyData_t)); + sas_iounit_pg0 =kzalloc (sz,GFP_KERNEL ); +if (!sas_iounit_pg0) { +ioc_err (ioc,"failure at %s:%d/%s()!\n" , + __FILE__, __LINE__, __func__); +return ; + } +if ((mpt3sas_config_get_sas_iounit_pg0 (ioc, &mpi_reply, + sas_iounit_pg0, sz)) !=0 ) + goto out; + ioc_status =le16_to_cpu (mpi_reply.IOCStatus) &MPI2_IOCSTATUS_MASK ; +if (ioc_status !=MPI2_IOCSTATUS_SUCCESS ) + goto out; +/* +* Loop over each HBA Phy. +*/ +for (i =0 ; i < ioc->sas_hba.num_phys; i++) { +/* +* Check whether Phy's Negotiation Link Rate is > 1.5G or not. +*/ +if ((sas_iounit_pg0->PhyData[i].NegotiatedLinkRate >>4 ) < +MPI2_SAS_NEG_LINK_RATE_1_5 ) +continue ; +/* +* Check whether Phy is connected to SEP device or not, +* if it is SEP device then read the Phy's SASPHYPage0 data to +* determine whether Phy is a virtual Phy or not. if it is +* virtual phy then it is conformed that the attached remote +* device is a HBA's vSES device. +*/ +if (!(le32_to_cpu ( + sas_iounit_pg0->PhyData[i].ControllerPhyDeviceInfo) & +MPI2_SAS_DEVICE_INFO_SEP )) +continue ; + +if ((mpt3sas_config_get_phy_pg0 (ioc, &mpi_reply, &phy_pg0, + i))) { +ioc_err (ioc,"failure at %s:%d/%s()!\n" , + __FILE__, __LINE__, __func__); +continue ; + } + +if (!(le32_to_cpu (phy_pg0.PhyInfo) & +MPI2_SAS_PHYINFO_VIRTUAL_PHY )) +continue ; +/* +* Get the vSES device's SAS Address. +*/ + attached_handle =le16_to_cpu ( + sas_iounit_pg0->PhyData[i].AttachedDevHandle); +if (_scsih_get_sas_address (ioc, attached_handle, + &attached_sas_addr) !=0 ) { +ioc_err (ioc,"failure at %s:%d/%s()!\n" , + __FILE__, __LINE__, __func__); +continue ; + } + + found =0 ; + port = port_next =NULL ; +/* +* Loop over each virtual_phy object from +* each port's vphys_list. +*/ +list_for_each_entry_safe (port, + port_next, &ioc->port_table_list, list) { +if (!port->vphys_mask) +continue ; +list_for_each_entry_safe (vphy, vphy_next, + &port->vphys_list, list) { +/* +* Continue with next virtual_phy object +* if the object is not marked as dirty. +*/ +if (!(vphy->flags &MPT_VPHY_FLAG_DIRTY_PHY )) +continue ; + +/* +* Continue with next virtual_phy object +* if the object's SAS Address is not equals +* to current Phy's vSES device SAS Address. +*/ +if (vphy->sas_address != attached_sas_addr) +continue ; +/* +* Enable current Phy number bit in object's +* phy_mask field. +*/ +if (!(vphy->phy_mask & (1 << i))) + vphy->phy_mask = (1 << i); +/* +* Get hba_port object from hba_port table +* corresponding to current phy's Port ID. +* if there is no hba_port object corresponding +* to Phy's Port ID then create a new hba_port +* object & add to hba_port table. +*/ + port_id = sas_iounit_pg0->PhyData[i].Port; + mport =mpt3sas_get_port_by_id (ioc, port_id,1 ); +if (!mport) { + mport =kzalloc ( +sizeof (struct hba_port ),GFP_KERNEL ); +if (!mport) +break ; + mport->port_id = port_id; +ioc_info (ioc, +"%s: hba_port entry: %p, port: %d is added to hba_port list\n" , + __func__, mport, mport->port_id); +list_add_tail (&mport->list, + &ioc->port_table_list); + } +/* +* If mport & port pointers are not pointing to +* same hba_port object then it means that vSES +* device's Port ID got changed after reset and +* hence move current virtual_phy object from +* port's vphys_list to mport's vphys_list. +*/ +if (port != mport) { +if (!mport->vphys_mask) +INIT_LIST_HEAD ( + &mport->vphys_list); + mport->vphys_mask |= (1 << i); + port->vphys_mask &= ~(1 << i); +list_move (&vphy->list, + &mport->vphys_list); + sas_device =mpt3sas_get_sdev_by_addr ( + ioc, attached_sas_addr, port); +if (sas_device) + sas_device->port = mport; + } +/* +* Earlier while updating the hba_port table, +* it is determined that there is no other +* direct attached device with mport's Port ID, +* Hence mport was marked as dirty. Only vSES +* device has this Port ID, so unmark the mport +* as dirt. +*/ +if (mport->flags &HBA_PORT_FLAG_DIRTY_PORT ) { + mport->sas_address =0 ; + mport->phy_mask =0 ; + mport->flags &= + ~HBA_PORT_FLAG_DIRTY_PORT ; + } +/* +* Unmark current virtual_phy object as dirty. +*/ + vphy->flags &= ~MPT_VPHY_FLAG_DIRTY_PHY ; + found =1 ; +break ; + } +if (found) +break ; + } + } +out: +kfree (sas_iounit_pg0); +} +/** * _scsih_get_port_table_after_reset - Construct temporary port table * @ioc: per adapter object
@@ -6066,6 +6264,39 @@ _scsih_add_or_del_phys_from_existing_port(struct MPT3SAS_ADAPTER *ioc, } } +/** +* _scsih_del_dirty_vphy - delete virtual_phy objects marked as dirty. +* @ioc: per adapter object +* +* Returns nothing. +*/ +static void +_scsih_del_dirty_vphy (struct MPT3SAS_ADAPTER *ioc) +{ +struct hba_port *port, *port_next; +struct virtual_phy *vphy, *vphy_next; + +list_for_each_entry_safe (port, port_next, + &ioc->port_table_list, list) { +if (!port->vphys_mask) +continue ; +list_for_each_entry_safe (vphy, vphy_next, + &port->vphys_list, list) { +if (vphy->flags &MPT_VPHY_FLAG_DIRTY_PHY ) { +drsprintk (ioc,ioc_info (ioc, +"Deleting vphy %p entry from port id: %d\t, Phy_mask 0x%08x\n" , + vphy, port->port_id, + vphy->phy_mask)); + port->vphys_mask &= ~vphy->phy_mask; +list_del (&vphy->list); +kfree (vphy); + } + } +if (!port->vphys_mask && !port->sas_address) + port->flags |=HBA_PORT_FLAG_DIRTY_PORT ; + } +} +/** * _scsih_del_dirty_port_entries - delete dirty port entries from port list * after host reset
@@ -10246,6 +10477,7 @@ mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)if ((!ioc->is_driver_loading) && !(disable_discovery >0 && !ioc->sas_hba.num_phys)) {_scsih_sas_port_refresh (ioc); +_scsih_update_vphys_after_reset (ioc);_scsih_prep_device_scan (ioc);_scsih_create_enclosure_list_after_reset (ioc);_scsih_search_responding_sas_devices (ioc);
@@ -10293,6 +10525,7 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)ssleep (1 ); }_scsih_remove_unresponding_devices (ioc); +_scsih_del_dirty_vphy (ioc);_scsih_del_dirty_port_entries (ioc);_scsih_scan_for_devices_after_reset (ioc);_scsih_set_nvme_max_shutdown_latency (ioc);
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 13/14 mpt3sas: add module parameter multipath_on_hba
In reply to Sreekanth ReddyAdd module parameter multipath_on_hba to enable/disable the support a multi-port path topology.
By default this feature is enabled on SAS3.5 HBA device and disabled on SAS3 &SAS2.5 HBA devices.
when this module parameter is disabled then driver uses a default PhysicalPort(PortID) number i.e. 255 instead of PhysicalPort number provided by HBA firmware.
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 + drivers/scsi/mpt3sas/mpt3sas_ctl.c | 6 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 69 ++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_transport.c | 6 ++- 4 files changed, 76 insertions(+), 7 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +2 -0
@@ -1246,6 +1246,7 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);* which ensures the syncrhonization between cli/sysfs_show path. * @atomic_desc_capable: Atomic Request Descriptor support. * @GET_MSIX_INDEX: Get the msix index of high iops queues. +* @multipath_on_hba: flag to determine multipath on hba is enabled or not * @port_table_list: list containing HBA's wide/narrow port's info */ struct MPT3SAS_ADAPTER {
@@ -1540,6 +1541,7 @@ struct MPT3SAS_ADAPTER {PUT_SMID_DEFAULT put_smid_default;GET_MSIX_INDEX get_msix_index_for_smlio; +u8 multipath_on_hba;struct list_head port_table_list; };
drivers/scsi/mpt3sas/mpt3sas_ctl.c +4 -2
@@ -902,8 +902,10 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, (Mpi2SmpPassthroughRequest_t *)mpi_request;u8 *data; -/* ioc determines which port to use */ - smp_request->PhysicalPort =0xFF ; +if (!ioc->multipath_on_hba) { +/* ioc determines which port to use */ + smp_request->PhysicalPort =0xFF ; + }if (smp_request->PassthroughFlags &MPI2_SMP_PT_REQ_PT_FLAGS_IMMEDIATE ) data = (u8 *)&smp_request->SGL;
drivers/scsi/mpt3sas/mpt3sas_scsih.c +66 -3
120 lines not on this page · raw message
drivers/scsi/mpt3sas/mpt3sas_transport.c +4 -2
@@ -912,7 +912,8 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,return ; } -if (sas_node->handle <= ioc->sas_hba.num_phys) { +if (sas_node->handle <= ioc->sas_hba.num_phys && + (ioc->multipath_on_hba)) {if (port->vphys_mask) {list_for_each_entry_safe (vphy, vphy_next, &port->vphys_list, list) {
@@ -1172,7 +1173,8 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,if (handle && (link_rate >=MPI2_SAS_NEG_LINK_RATE_1_5 )) {_transport_set_identify (ioc, handle, &mpt3sas_phy->remote_identify); -if (sas_node->handle <= ioc->sas_hba.num_phys) { +if ((sas_node->handle <= ioc->sas_hba.num_phys) && + (ioc->multipath_on_hba)) {list_for_each_entry (hba_port, &ioc->port_table_list, list) { if (hba_port->sas_address == sas_address &&
Signature · 1 line
2.18.4
Sreekanth Reddy
maintainerPATCH 14/14 mpt3sas: Bump driver version to 35.101.00.00
In reply to Sreekanth ReddyBump mpt3sas driver version to 35.101.00.00
--- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.h +2 -2
@@ -76,9 +76,9 @@#define MPT3SAS_DRIVER_NAME "mpt3sas"#define MPT3SAS_AUTHOR "Avago Technologies <[email protected]>"#define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver" -#define MPT3SAS_DRIVER_VERSION "35.100.00.00" +#define MPT3SAS_DRIVER_VERSION "35.101.00.00"#define MPT3SAS_MAJOR_VERSION 35 -#define MPT3SAS_MINOR_VERSION 100 +#define MPT3SAS_MINOR_VERSION 101#define MPT3SAS_BUILD_VERSION 0#define MPT3SAS_RELEASE_VERSION 00
Signature · 1 line
2.18.4