Commit c5e039be authored by Kashyap, Desai's avatar Kashyap, Desai Committed by James Bottomley

[SCSI] mpt2sas: Driver will use sas address instead of handle as a lookup

The device driver was not handling updating device handles in all cases
across diag resets. To fix this issue, the driver is converted to using sas
address instead of handle as a lookup reference to the parent expander or
sas_host. Also, for both expanders and sas host, the phy handle will be one
unique handle. In the sas host case, the phy handle can be different for
every phy, so the change is to set the handle to the handle of the first
phy; every phy will be one single sas address(phy 0) instead of a different
sas address for every phy(previous implementation). So making one consistent
sas address for all the direct attachedports to the sas host, will make it
better user experience when using udev /dev/disk/by-path dev nodes
Signed-off-by: default avatarKashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: default avatarEric Moore <Eric.moore@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 8d5eb435
...@@ -278,7 +278,7 @@ struct _internal_cmd { ...@@ -278,7 +278,7 @@ struct _internal_cmd {
* @sas_address: device sas address * @sas_address: device sas address
* @device_name: retrieved from the SAS IDENTIFY frame. * @device_name: retrieved from the SAS IDENTIFY frame.
* @handle: device handle * @handle: device handle
* @parent_handle: handle to parent device * @sas_address_parent: sas address of parent expander or sas host
* @enclosure_handle: enclosure handle * @enclosure_handle: enclosure handle
* @enclosure_logical_id: enclosure logical identifier * @enclosure_logical_id: enclosure logical identifier
* @volume_handle: volume handle (valid when hidden raid member) * @volume_handle: volume handle (valid when hidden raid member)
...@@ -296,7 +296,7 @@ struct _sas_device { ...@@ -296,7 +296,7 @@ struct _sas_device {
u64 sas_address; u64 sas_address;
u64 device_name; u64 device_name;
u16 handle; u16 handle;
u16 parent_handle; u64 sas_address_parent;
u16 enclosure_handle; u16 enclosure_handle;
u64 enclosure_logical_id; u64 enclosure_logical_id;
u16 volume_handle; u16 volume_handle;
...@@ -352,8 +352,6 @@ struct _boot_device { ...@@ -352,8 +352,6 @@ struct _boot_device {
/** /**
* struct _sas_port - wide/narrow sas port information * struct _sas_port - wide/narrow sas port information
* @port_list: list of ports belonging to expander * @port_list: list of ports belonging to expander
* @handle: device handle for this port
* @sas_address: sas address of this port
* @num_phys: number of phys belonging to this port * @num_phys: number of phys belonging to this port
* @remote_identify: attached device identification * @remote_identify: attached device identification
* @rphy: sas transport rphy object * @rphy: sas transport rphy object
...@@ -362,8 +360,6 @@ struct _boot_device { ...@@ -362,8 +360,6 @@ struct _boot_device {
*/ */
struct _sas_port { struct _sas_port {
struct list_head port_list; struct list_head port_list;
u16 handle;
u64 sas_address;
u8 num_phys; u8 num_phys;
struct sas_identify remote_identify; struct sas_identify remote_identify;
struct sas_rphy *rphy; struct sas_rphy *rphy;
...@@ -398,7 +394,7 @@ struct _sas_phy { ...@@ -398,7 +394,7 @@ struct _sas_phy {
* @num_phys: number phys belonging to this sas_host/expander * @num_phys: number phys belonging to this sas_host/expander
* @sas_address: sas address of this sas_host/expander * @sas_address: sas address of this sas_host/expander
* @handle: handle for this sas_host/expander * @handle: handle for this sas_host/expander
* @parent_handle: parent handle * @sas_address_parent: sas address of parent expander or sas host
* @enclosure_handle: handle for this a member of an enclosure * @enclosure_handle: handle for this a member of an enclosure
* @device_info: bitwise defining capabilities of this sas_host/expander * @device_info: bitwise defining capabilities of this sas_host/expander
* @responding: used in _scsih_expander_device_mark_responding * @responding: used in _scsih_expander_device_mark_responding
...@@ -411,7 +407,7 @@ struct _sas_node { ...@@ -411,7 +407,7 @@ struct _sas_node {
u8 num_phys; u8 num_phys;
u64 sas_address; u64 sas_address;
u16 handle; u16 handle;
u16 parent_handle; u64 sas_address_parent;
u16 enclosure_handle; u16 enclosure_handle;
u64 enclosure_logical_id; u64 enclosure_logical_id;
u8 responding; u8 responding;
...@@ -890,15 +886,15 @@ void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc, ...@@ -890,15 +886,15 @@ void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
u32 reply); u32 reply);
struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
u16 handle, u16 parent_handle); u16 handle, u64 sas_address);
void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
u16 parent_handle); u64 sas_address_parent);
int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
*mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev); *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
*mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev); *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle, void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
u16 attached_handle, u8 phy_number, u8 link_rate); u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
extern struct sas_function_template mpt2sas_transport_functions; extern struct sas_function_template mpt2sas_transport_functions;
extern struct scsi_transport_template *mpt2sas_transport_template; extern struct scsi_transport_template *mpt2sas_transport_template;
extern int scsi_internal_device_block(struct scsi_device *sdev); extern int scsi_internal_device_block(struct scsi_device *sdev);
......
This diff is collapsed.
...@@ -59,24 +59,23 @@ ...@@ -59,24 +59,23 @@
#include "mpt2sas_base.h" #include "mpt2sas_base.h"
/** /**
* _transport_sas_node_find_by_handle - sas node search * _transport_sas_node_find_by_sas_address - sas node search
* @ioc: per adapter object * @ioc: per adapter object
* @handle: expander or hba handle (assigned by firmware) * @sas_address: sas address of expander or sas host
* Context: Calling function should acquire ioc->sas_node_lock. * Context: Calling function should acquire ioc->sas_node_lock.
* *
* Search for either hba phys or expander device based on handle, then returns * Search for either hba phys or expander device based on handle, then returns
* the sas_node object. * the sas_node object.
*/ */
static struct _sas_node * static struct _sas_node *
_transport_sas_node_find_by_handle(struct MPT2SAS_ADAPTER *ioc, u16 handle) _transport_sas_node_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc,
u64 sas_address)
{ {
int i; if (ioc->sas_hba.sas_address == sas_address)
for (i = 0; i < ioc->sas_hba.num_phys; i++)
if (ioc->sas_hba.phy[i].handle == handle)
return &ioc->sas_hba; return &ioc->sas_hba;
else
return mpt2sas_scsih_expander_find_by_handle(ioc, handle); return mpt2sas_scsih_expander_find_by_sas_address(ioc,
sas_address);
} }
/** /**
...@@ -469,7 +468,7 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc, ...@@ -469,7 +468,7 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
* mpt2sas_transport_port_add - insert port to the list * mpt2sas_transport_port_add - insert port to the list
* @ioc: per adapter object * @ioc: per adapter object
* @handle: handle of attached device * @handle: handle of attached device
* @parent_handle: parent handle(either hba or expander) * @sas_address: sas address of parent expander or sas host
* Context: This function will acquire ioc->sas_node_lock. * Context: This function will acquire ioc->sas_node_lock.
* *
* Adding new port object to the sas_node->sas_port_list. * Adding new port object to the sas_node->sas_port_list.
...@@ -478,7 +477,7 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc, ...@@ -478,7 +477,7 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
*/ */
struct _sas_port * struct _sas_port *
mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle, mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle,
u16 parent_handle) u64 sas_address)
{ {
struct _sas_phy *mpt2sas_phy, *next; struct _sas_phy *mpt2sas_phy, *next;
struct _sas_port *mpt2sas_port; struct _sas_port *mpt2sas_port;
...@@ -488,9 +487,6 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle, ...@@ -488,9 +487,6 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle,
int i; int i;
struct sas_port *port; struct sas_port *port;
if (!parent_handle)
return NULL;
mpt2sas_port = kzalloc(sizeof(struct _sas_port), mpt2sas_port = kzalloc(sizeof(struct _sas_port),
GFP_KERNEL); GFP_KERNEL);
if (!mpt2sas_port) { if (!mpt2sas_port) {
...@@ -502,17 +498,16 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle, ...@@ -502,17 +498,16 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle,
INIT_LIST_HEAD(&mpt2sas_port->port_list); INIT_LIST_HEAD(&mpt2sas_port->port_list);
INIT_LIST_HEAD(&mpt2sas_port->phy_list); INIT_LIST_HEAD(&mpt2sas_port->phy_list);
spin_lock_irqsave(&ioc->sas_node_lock, flags); spin_lock_irqsave(&ioc->sas_node_lock, flags);
sas_node = _transport_sas_node_find_by_handle(ioc, parent_handle); sas_node = _transport_sas_node_find_by_sas_address(ioc, sas_address);
spin_unlock_irqrestore(&ioc->sas_node_lock, flags); spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (!sas_node) { if (!sas_node) {
printk(MPT2SAS_ERR_FMT "%s: Could not find parent(0x%04x)!\n", printk(MPT2SAS_ERR_FMT "%s: Could not find "
ioc->name, __func__, parent_handle); "parent sas_address(0x%016llx)!\n", ioc->name,
__func__, (unsigned long long)sas_address);
goto out_fail; goto out_fail;
} }
mpt2sas_port->handle = parent_handle;
mpt2sas_port->sas_address = sas_node->sas_address;
if ((_transport_set_identify(ioc, handle, if ((_transport_set_identify(ioc, handle,
&mpt2sas_port->remote_identify))) { &mpt2sas_port->remote_identify))) {
printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
...@@ -604,7 +599,7 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle, ...@@ -604,7 +599,7 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle,
* mpt2sas_transport_port_remove - remove port from the list * mpt2sas_transport_port_remove - remove port from the list
* @ioc: per adapter object * @ioc: per adapter object
* @sas_address: sas address of attached device * @sas_address: sas address of attached device
* @parent_handle: handle to the upstream parent(either hba or expander) * @sas_address_parent: sas address of parent expander or sas host
* Context: This function will acquire ioc->sas_node_lock. * Context: This function will acquire ioc->sas_node_lock.
* *
* Removing object and freeing associated memory from the * Removing object and freeing associated memory from the
...@@ -614,7 +609,7 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle, ...@@ -614,7 +609,7 @@ mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, u16 handle,
*/ */
void void
mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
u16 parent_handle) u64 sas_address_parent)
{ {
int i; int i;
unsigned long flags; unsigned long flags;
...@@ -624,7 +619,8 @@ mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, ...@@ -624,7 +619,8 @@ mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
struct _sas_phy *mpt2sas_phy, *next_phy; struct _sas_phy *mpt2sas_phy, *next_phy;
spin_lock_irqsave(&ioc->sas_node_lock, flags); spin_lock_irqsave(&ioc->sas_node_lock, flags);
sas_node = _transport_sas_node_find_by_handle(ioc, parent_handle); sas_node = _transport_sas_node_find_by_sas_address(ioc,
sas_address_parent);
spin_unlock_irqrestore(&ioc->sas_node_lock, flags); spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (!sas_node) if (!sas_node)
return; return;
...@@ -650,8 +646,7 @@ mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, ...@@ -650,8 +646,7 @@ mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
&mpt2sas_port->phy_list, port_siblings) { &mpt2sas_port->phy_list, port_siblings) {
if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) if ((ioc->logging_level & MPT_DEBUG_TRANSPORT))
dev_printk(KERN_INFO, &mpt2sas_port->port->dev, dev_printk(KERN_INFO, &mpt2sas_port->port->dev,
"remove: parent_handle(0x%04x), " "remove: sas_addr(0x%016llx), phy(%d)\n",
"sas_addr(0x%016llx), phy(%d)\n", parent_handle,
(unsigned long long) (unsigned long long)
mpt2sas_port->remote_identify.sas_address, mpt2sas_port->remote_identify.sas_address,
mpt2sas_phy->phy_id); mpt2sas_phy->phy_id);
...@@ -799,8 +794,8 @@ mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy ...@@ -799,8 +794,8 @@ mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
/** /**
* mpt2sas_transport_update_links - refreshing phy link changes * mpt2sas_transport_update_links - refreshing phy link changes
* @ioc: per adapter object * @ioc: per adapter object
* @handle: handle to sas_host or expander * @sas_address: sas address of parent expander or sas host
* @attached_handle: attached device handle * @handle: attached device handle
* @phy_numberv: phy number * @phy_numberv: phy number
* @link_rate: new link rate * @link_rate: new link rate
* *
...@@ -808,28 +803,25 @@ mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy ...@@ -808,28 +803,25 @@ mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
*/ */
void void
mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
u16 handle, u16 attached_handle, u8 phy_number, u8 link_rate) u64 sas_address, u16 handle, u8 phy_number, u8 link_rate)
{ {
unsigned long flags; unsigned long flags;
struct _sas_node *sas_node; struct _sas_node *sas_node;
struct _sas_phy *mpt2sas_phy; struct _sas_phy *mpt2sas_phy;
if (ioc->shost_recovery) { if (ioc->shost_recovery)
printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n",
__func__, ioc->name);
return; return;
}
spin_lock_irqsave(&ioc->sas_node_lock, flags); spin_lock_irqsave(&ioc->sas_node_lock, flags);
sas_node = _transport_sas_node_find_by_handle(ioc, handle); sas_node = _transport_sas_node_find_by_sas_address(ioc, sas_address);
spin_unlock_irqrestore(&ioc->sas_node_lock, flags); spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (!sas_node) if (!sas_node)
return; return;
mpt2sas_phy = &sas_node->phy[phy_number]; mpt2sas_phy = &sas_node->phy[phy_number];
mpt2sas_phy->attached_handle = attached_handle; mpt2sas_phy->attached_handle = handle;
if (attached_handle && (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5)) if (handle && (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5))
_transport_set_identify(ioc, mpt2sas_phy->attached_handle, _transport_set_identify(ioc, handle,
&mpt2sas_phy->remote_identify); &mpt2sas_phy->remote_identify);
else else
memset(&mpt2sas_phy->remote_identify, 0 , sizeof(struct memset(&mpt2sas_phy->remote_identify, 0 , sizeof(struct
...@@ -841,13 +833,11 @@ mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, ...@@ -841,13 +833,11 @@ mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) if ((ioc->logging_level & MPT_DEBUG_TRANSPORT))
dev_printk(KERN_INFO, &mpt2sas_phy->phy->dev, dev_printk(KERN_INFO, &mpt2sas_phy->phy->dev,
"refresh: handle(0x%04x), sas_addr(0x%016llx),\n" "refresh: parent sas_addr(0x%016llx),\n"
"\tlink_rate(0x%02x), phy(%d)\n" "\tlink_rate(0x%02x), phy(%d)\n"
"\tattached_handle(0x%04x), sas_addr(0x%016llx)\n", "\tattached_handle(0x%04x), sas_addr(0x%016llx)\n",
handle, (unsigned long long) (unsigned long long)sas_address,
mpt2sas_phy->identify.sas_address, link_rate, link_rate, phy_number, handle, (unsigned long long)
phy_number, attached_handle,
(unsigned long long)
mpt2sas_phy->remote_identify.sas_address); mpt2sas_phy->remote_identify.sas_address);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment