Commit 4b33981a authored by Dan Williams's avatar Dan Williams

isci: unify phy data structures

Make scic_sds_phy a member of isci_phy and merge their lifetimes which
means removing the phy table from scic_sds_controller in favor of the
one at that isci_host level.
Reported-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent a98a7426
......@@ -673,6 +673,7 @@ static void scic_sds_controller_phy_timer_stop(struct scic_sds_controller *scic)
*/
static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *scic)
{
struct isci_host *ihost = scic_to_ihost(scic);
struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
struct scic_sds_phy *sci_phy;
enum sci_status status;
......@@ -688,7 +689,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
u8 index;
for (index = 0; index < SCI_MAX_PHYS; index++) {
sci_phy = &scic->phy_table[index];
sci_phy = &ihost->phys[index].sci;
state = sci_phy->state_machine.current_state_id;
if (!scic_sds_phy_get_port(sci_phy))
......@@ -719,7 +720,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
scic_sds_controller_phy_timer_stop(scic);
}
} else {
sci_phy = &scic->phy_table[scic->next_phy_to_start];
sci_phy = &ihost->phys[scic->next_phy_to_start].sci;
if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
if (scic_sds_phy_get_port(sci_phy) == NULL) {
......@@ -748,7 +749,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
"to stop phy %d because of status "
"%d.\n",
__func__,
scic->phy_table[scic->next_phy_to_start].phy_index,
ihost->phys[scic->next_phy_to_start].sci.phy_index,
status);
}
......@@ -792,23 +793,22 @@ static enum sci_status scic_sds_controller_stop_phys(struct scic_sds_controller
u32 index;
enum sci_status status;
enum sci_status phy_status;
struct isci_host *ihost = scic_to_ihost(scic);
status = SCI_SUCCESS;
for (index = 0; index < SCI_MAX_PHYS; index++) {
phy_status = scic_sds_phy_stop(&scic->phy_table[index]);
phy_status = scic_sds_phy_stop(&ihost->phys[index].sci);
if (
(phy_status != SCI_SUCCESS)
&& (phy_status != SCI_FAILURE_INVALID_STATE)
) {
if (phy_status != SCI_SUCCESS &&
phy_status != SCI_FAILURE_INVALID_STATE) {
status = SCI_FAILURE;
dev_warn(scic_to_dev(scic),
"%s: Controller stop operation failed to stop "
"phy %d because of status %d.\n",
__func__,
scic->phy_table[index].phy_index, phy_status);
ihost->phys[index].sci.phy_index, phy_status);
}
}
......@@ -1069,21 +1069,13 @@ static void scic_sds_controller_sdma_completion(
}
}
/**
*
* @scic:
* @completion_entry:
*
* This method processes an unsolicited frame message. This is called from
* within the controller completion handler. none
*/
static void scic_sds_controller_unsolicited_frame(
struct scic_sds_controller *scic,
u32 completion_entry)
static void scic_sds_controller_unsolicited_frame(struct scic_sds_controller *scic,
u32 completion_entry)
{
u32 index;
u32 frame_index;
struct isci_host *ihost = scic_to_ihost(scic);
struct scu_unsolicited_frame_header *frame_header;
struct scic_sds_phy *phy;
struct scic_sds_remote_device *device;
......@@ -1092,10 +1084,8 @@ static void scic_sds_controller_unsolicited_frame(
frame_index = SCU_GET_FRAME_INDEX(completion_entry);
frame_header
= scic->uf_control.buffers.array[frame_index].header;
scic->uf_control.buffers.array[frame_index].state
= UNSOLICITED_FRAME_IN_USE;
frame_header = scic->uf_control.buffers.array[frame_index].header;
scic->uf_control.buffers.array[frame_index].state = UNSOLICITED_FRAME_IN_USE;
if (SCU_GET_FRAME_ERROR(completion_entry)) {
/*
......@@ -1108,10 +1098,8 @@ static void scic_sds_controller_unsolicited_frame(
if (frame_header->is_address_frame) {
index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
phy = &scic->phy_table[index];
if (phy != NULL) {
result = scic_sds_phy_frame_handler(phy, frame_index);
}
phy = &ihost->phys[index].sci;
result = scic_sds_phy_frame_handler(phy, frame_index);
} else {
index = SCU_GET_COMPLETION_INDEX(completion_entry);
......@@ -1122,7 +1110,7 @@ static void scic_sds_controller_unsolicited_frame(
* device that has not yet been created. In either case forwared
* the frame to the PE and let it take care of the frame data. */
index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
phy = &scic->phy_table[index];
phy = &ihost->phys[index].sci;
result = scic_sds_phy_frame_handler(phy, frame_index);
} else {
if (index < scic->remote_node_entries)
......@@ -1144,21 +1132,14 @@ static void scic_sds_controller_unsolicited_frame(
}
}
/**
* This method processes an event completion entry. This is called from within
* the controller completion handler.
* @scic:
* @completion_entry:
*
*/
static void scic_sds_controller_event_completion(
struct scic_sds_controller *scic,
u32 completion_entry)
static void scic_sds_controller_event_completion(struct scic_sds_controller *scic,
u32 completion_entry)
{
u32 index;
struct isci_host *ihost = scic_to_ihost(scic);
struct scic_sds_request *io_request;
struct scic_sds_remote_device *device;
struct scic_sds_phy *phy;
u32 index;
index = SCU_GET_COMPLETION_INDEX(completion_entry);
......@@ -1237,7 +1218,7 @@ static void scic_sds_controller_event_completion(
* we get the event notification. This is a type 4 event. */
case SCU_EVENT_TYPE_OSSP_EVENT:
index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
phy = &scic->phy_table[index];
phy = &ihost->phys[index].sci;
scic_sds_phy_event_handler(phy, completion_entry);
break;
......@@ -2154,38 +2135,6 @@ enum sci_task_status scic_controller_start_task(
return status;
}
/**
* scic_controller_get_phy_handle() - This method simply provides the user with
* a unique handle for a given SAS/SATA phy index/identifier.
* @controller: This parameter represents the handle to the controller object
* from which to retrieve a phy (SAS or SATA) handle.
* @phy_index: This parameter specifies the phy index in the controller for
* which to retrieve the phy handle. 0 <= phy_index < maximum number of phys.
* @phy_handle: This parameter specifies the retrieved phy handle to be
* provided to the caller.
*
* Indicate if the retrieval of the phy handle was successful. SCI_SUCCESS This
* value is returned if the retrieval was successful. SCI_FAILURE_INVALID_PHY
* This value is returned if the supplied phy id is not in the supported range.
*/
enum sci_status scic_controller_get_phy_handle(
struct scic_sds_controller *scic,
u8 phy_index,
struct scic_sds_phy **phy_handle)
{
if (phy_index < ARRAY_SIZE(scic->phy_table)) {
*phy_handle = &scic->phy_table[phy_index];
return SCI_SUCCESS;
}
dev_err(scic_to_dev(scic),
"%s: Controller:0x%p PhyId:0x%x invalid phy index\n",
__func__, scic, phy_index);
return SCI_FAILURE_INVALID_PHY;
}
/**
* scic_controller_allocate_io_tag() - This method will allocate a tag from the
* pool of free IO tags. Direct allocation of IO tags by the SCI Core user
......@@ -2724,7 +2673,7 @@ enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
(result == SCI_SUCCESS) && (index < SCI_MAX_PHYS);
index++) {
result = scic_sds_phy_initialize(
&scic->phy_table[index],
&ihost->phys[index].sci,
&scic->scu_registers->peg0.pe[index].tl,
&scic->scu_registers->peg0.pe[index].ll);
}
......@@ -2979,6 +2928,7 @@ enum sci_status scic_controller_construct(struct scic_sds_controller *scic,
void __iomem *scu_base,
void __iomem *smu_base)
{
struct isci_host *ihost = scic_to_ihost(scic);
u8 i;
sci_base_state_machine_construct(&scic->state_machine,
......@@ -3000,7 +2950,7 @@ enum sci_status scic_controller_construct(struct scic_sds_controller *scic,
/* Construct the phys for this controller */
for (i = 0; i < SCI_MAX_PHYS; i++) {
/* Add all the PHYs to the dummy port */
scic_sds_phy_construct(&scic->phy_table[i],
scic_sds_phy_construct(&ihost->phys[i].sci,
&scic->port_table[SCI_MAX_PORTS], i);
}
......
......@@ -167,12 +167,6 @@ struct scic_sds_controller {
*/
struct scic_sds_port port_table[SCI_MAX_PORTS + 1];
/**
* This field is the array of phy objects that are controlled by this
* controller object.
*/
struct scic_sds_phy phy_table[SCI_MAX_PHYS];
/**
* This field is the array of device objects that are currently constructed
* for this controller object. This table is used as a fast lookup of device
......
......@@ -436,7 +436,7 @@ void scic_sds_phy_get_attached_sas_address(struct scic_sds_phy *sci_phy,
struct sci_sas_address *sas_address)
{
struct sas_identify_frame *iaf;
struct isci_phy *iphy = sci_phy->iphy;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
iaf = &iphy->frame_rcvd.iaf;
memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE);
......@@ -1099,7 +1099,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler
enum sci_status result;
u32 *frame_words;
struct sas_identify_frame iaf;
struct isci_phy *iphy = sci_phy->iphy;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
result = scic_sds_unsolicited_frame_control_get_header(
&(scic_sds_phy_get_controller(sci_phy)->uf_control),
......@@ -1164,7 +1164,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle
enum sci_status result;
struct dev_to_host_fis *frame_header;
u32 *fis_frame_data;
struct isci_phy *iphy = sci_phy->iphy;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
result = scic_sds_unsolicited_frame_control_get_header(
&(scic_sds_phy_get_controller(sci_phy)->uf_control),
......
......@@ -217,7 +217,6 @@ enum scic_sds_phy_protocol {
SCIC_SDS_MAX_PHY_PROTOCOLS
};
struct isci_phy;
/**
* struct scic_sds_phy - This structure contains or references all of the data
* necessary to represent the core phy object and SCU harware protocol
......@@ -226,11 +225,6 @@ struct isci_phy;
*
*/
struct scic_sds_phy {
/**
* This field depicts the peer object for the phy.
*/
struct isci_phy *iphy;
/**
* This field contains the information for the base phy state machine.
*/
......
......@@ -645,7 +645,7 @@ void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
struct isci_port *iport = sci_port->iport;
struct isci_host *ihost = scic_to_ihost(scic);
struct isci_phy *iphy = sci_phy->iphy;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
sci_port->active_phy_mask &= ~(1 << sci_phy->phy_index);
......
......@@ -63,61 +63,35 @@ struct scic_sds_phy;
extern enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy);
extern enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy);
/**
* isci_phy_init() - This function is called by the probe function to
* initialize the phy objects. This func assumes that the isci_port objects
* associated with the SCU have been initialized.
* @isci_phy: This parameter specifies the isci_phy object to initialize
* @isci_host: This parameter specifies the parent SCU host object for this
* isci_phy
* @index: This parameter specifies which SCU phy associates with this
* isci_phy. Generally, SCU phy 0 relates isci_phy 0, etc.
*
*/
void isci_phy_init(
struct isci_phy *phy,
struct isci_host *isci_host,
int index)
void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index)
{
struct scic_sds_phy *scic_phy;
union scic_oem_parameters oem;
enum sci_status status = SCI_SUCCESS;
u64 sas_addr;
/*--------------- SCU_Phy Initialization Stuff -----------------------*/
status = scic_controller_get_phy_handle(&isci_host->sci, index, &scic_phy);
if (status == SCI_SUCCESS) {
phy->sci_phy_handle = scic_phy;
scic_phy->iphy = phy;
} else
dev_err(&isci_host->pdev->dev,
"failed scic_controller_get_phy_handle\n");
scic_oem_parameters_get(&isci_host->sci, &oem);
sas_addr = oem.sds1.phys[index].sas_address.high;
sas_addr <<= 32;
sas_addr |= oem.sds1.phys[index].sas_address.low;
swab64s(&sas_addr);
memcpy(phy->sas_addr, &sas_addr, sizeof(sas_addr));
phy->isci_port = NULL;
phy->sas_phy.enabled = 0;
phy->sas_phy.id = index;
phy->sas_phy.sas_addr = &phy->sas_addr[0];
phy->sas_phy.frame_rcvd = (u8 *)&phy->frame_rcvd;
phy->sas_phy.ha = &isci_host->sas_ha;
phy->sas_phy.lldd_phy = phy;
phy->sas_phy.enabled = 1;
phy->sas_phy.class = SAS;
phy->sas_phy.iproto = SAS_PROTOCOL_ALL;
phy->sas_phy.tproto = 0;
phy->sas_phy.type = PHY_TYPE_PHYSICAL;
phy->sas_phy.role = PHY_ROLE_INITIATOR;
phy->sas_phy.oob_mode = OOB_NOT_CONNECTED;
phy->sas_phy.linkrate = SAS_LINK_RATE_UNKNOWN;
memset((u8 *)&phy->frame_rcvd, 0, sizeof(phy->frame_rcvd));
u64 sci_sas_addr;
__be64 sas_addr;
scic_oem_parameters_get(&ihost->sci, &oem);
sci_sas_addr = oem.sds1.phys[index].sas_address.high;
sci_sas_addr <<= 32;
sci_sas_addr |= oem.sds1.phys[index].sas_address.low;
sas_addr = cpu_to_be64(sci_sas_addr);
memcpy(iphy->sas_addr, &sas_addr, sizeof(sas_addr));
iphy->isci_port = NULL;
iphy->sas_phy.enabled = 0;
iphy->sas_phy.id = index;
iphy->sas_phy.sas_addr = &iphy->sas_addr[0];
iphy->sas_phy.frame_rcvd = (u8 *)&iphy->frame_rcvd;
iphy->sas_phy.ha = &ihost->sas_ha;
iphy->sas_phy.lldd_phy = iphy;
iphy->sas_phy.enabled = 1;
iphy->sas_phy.class = SAS;
iphy->sas_phy.iproto = SAS_PROTOCOL_ALL;
iphy->sas_phy.tproto = 0;
iphy->sas_phy.type = PHY_TYPE_PHYSICAL;
iphy->sas_phy.role = PHY_ROLE_INITIATOR;
iphy->sas_phy.oob_mode = OOB_NOT_CONNECTED;
iphy->sas_phy.linkrate = SAS_LINK_RATE_UNKNOWN;
memset(&iphy->frame_rcvd, 0, sizeof(iphy->frame_rcvd));
}
......@@ -147,14 +121,14 @@ int isci_phy_control(struct asd_sas_phy *sas_phy,
switch (func) {
case PHY_FUNC_DISABLE:
spin_lock_irqsave(&ihost->scic_lock, flags);
scic_sds_phy_stop(iphy->sci_phy_handle);
scic_sds_phy_stop(&iphy->sci);
spin_unlock_irqrestore(&ihost->scic_lock, flags);
break;
case PHY_FUNC_LINK_RESET:
spin_lock_irqsave(&ihost->scic_lock, flags);
scic_sds_phy_stop(iphy->sci_phy_handle);
scic_sds_phy_start(iphy->sci_phy_handle);
scic_sds_phy_stop(&iphy->sci);
scic_sds_phy_start(&iphy->sci);
spin_unlock_irqrestore(&ihost->scic_lock, flags);
break;
......
......@@ -54,24 +54,17 @@
*/
#if !defined(_ISCI_PHY_H_)
#ifndef _ISCI_PHY_H_
#define _ISCI_PHY_H_
#include "port.h"
#include "host.h"
#include <scsi/sas.h>
#include <scsi/libsas.h>
/**
* struct isci_phy - This class implements the ISCI specific representation of
* the phy object.
*
*
*/
#include "scic_sds_phy.h"
#include "port.h"
#include "host.h"
struct isci_phy {
struct scic_sds_phy *sci_phy_handle;
struct scic_sds_phy sci;
struct asd_sas_phy sas_phy;
struct isci_port *isci_port;
u8 sas_addr[SAS_ADDR_SIZE];
......@@ -82,17 +75,21 @@ struct isci_phy {
} frame_rcvd;
};
#define to_isci_phy(p) \
container_of(p, struct isci_phy, sas_phy);
static inline struct isci_phy *to_isci_phy(struct asd_sas_phy *sas_phy)
{
struct isci_phy *iphy = container_of(sas_phy, typeof(*iphy), sas_phy);
return iphy;
}
static inline struct isci_phy *sci_phy_to_iphy(struct scic_sds_phy *sci_phy)
{
struct isci_phy *iphy = container_of(sci_phy, typeof(*iphy), sci);
void isci_phy_init(
struct isci_phy *phy,
struct isci_host *isci_host,
int index);
return iphy;
}
int isci_phy_control(
struct asd_sas_phy *phy,
enum phy_func func,
void *buf);
void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index);
int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf);
#endif /* !defined(_ISCI_PHY_H_) */
......@@ -120,44 +120,26 @@ static void isci_port_change_state(
spin_unlock_irqrestore(&isci_port->state_lock, flags);
}
void isci_port_bc_change_received(
struct isci_host *isci_host,
struct scic_sds_port *port,
struct scic_sds_phy *phy)
void isci_port_bc_change_received(struct isci_host *ihost,
struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
{
struct isci_phy *isci_phy = phy->iphy;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
dev_dbg(&isci_host->pdev->dev,
"%s: isci_phy = %p, sas_phy = %p\n",
__func__,
isci_phy,
&isci_phy->sas_phy);
isci_host->sas_ha.notify_port_event(
&isci_phy->sas_phy,
PORTE_BROADCAST_RCVD
);
dev_dbg(&ihost->pdev->dev, "%s: iphy = %p, sas_phy = %p\n",
__func__, iphy, &iphy->sas_phy);
scic_port_enable_broadcast_change_notification(port);
ihost->sas_ha.notify_port_event(&iphy->sas_phy, PORTE_BROADCAST_RCVD);
scic_port_enable_broadcast_change_notification(sci_port);
}
/**
* isci_port_link_up() - This function is called by the sci core when a link
* becomes active. the identify address frame is retrieved from the core and
* a notify port event is sent to libsas.
* @isci_host: This parameter specifies the isci host object.
* @port: This parameter specifies the sci port with the active link.
* @phy: This parameter specifies the sci phy with the active link.
*
*/
void isci_port_link_up(
struct isci_host *isci_host,
struct scic_sds_port *port,
struct scic_sds_phy *phy)
void isci_port_link_up(struct isci_host *isci_host,
struct scic_sds_port *port,
struct scic_sds_phy *phy)
{
unsigned long flags;
struct scic_port_properties properties;
struct isci_phy *isci_phy = phy->iphy;
struct isci_phy *isci_phy = sci_phy_to_iphy(phy);
struct isci_port *isci_port = port->iport;
unsigned long success = true;
......
......@@ -67,7 +67,7 @@ static inline struct device *scic_to_dev(struct scic_sds_controller *scic)
static inline struct device *sciphy_to_dev(struct scic_sds_phy *sci_phy)
{
struct isci_phy *iphy = sci_phy->iphy;
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
if (!iphy || !iphy->isci_port || !iphy->isci_port->isci_host)
return NULL;
......
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