All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org,
	Sven Schuetz <sven@linux.vnet.ibm.com>,
	Christof Schmitt <christof.schmitt@de.ibm.com>
Subject: [patch 6/8] zfcp: Add port_state attribute to sysfs
Date: Tue, 10 Jun 2008 18:20:59 +0200	[thread overview]
Message-ID: <20080610162517.622082000@de.ibm.com> (raw)
In-Reply-To: 20080610162053.144590000@de.ibm.com

[-- Attachment #1: port_state.diff --]
[-- Type: text/plain, Size: 2070 bytes --]

From: Sven Schuetz <sven@linux.vnet.ibm.com>

The sysfs attribute /sys/class/fc_host/hostX/port_state was not set by
zfcp so far.

Now, the appropriate members of the fc_function_template struct are
set during its initialziation. The first is a boolean to show the port
state. The second is a function pointer to the function
zfcp_get_host_port_state, which reads the port state from our adapter
status bits and calls fc_host_port_state with the approriate port
state afterwards.

Signed-off-by: Sven Schuetz <sven@linux.vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
---
 drivers/s390/scsi/zfcp_scsi.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/drivers/s390/scsi/zfcp_scsi.c	2008-06-04 14:27:47.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_scsi.c	2008-06-04 14:28:16.000000000 +0200
@@ -704,6 +704,23 @@ zfcp_reset_fc_host_stats(struct Scsi_Hos
 	}
 }
 
+static void zfcp_get_host_port_state(struct Scsi_Host *shost)
+{
+	struct zfcp_adapter *adapter =
+		(struct zfcp_adapter *)shost->hostdata[0];
+	int status = atomic_read(&adapter->status);
+
+	if ((status & ZFCP_STATUS_COMMON_RUNNING) &&
+	    !(status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED))
+		fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
+	else if (status & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)
+		fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
+	else if (status & ZFCP_STATUS_COMMON_ERP_FAILED)
+		fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
+	else
+		fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
+}
+
 static void zfcp_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
 {
 	rport->dev_loss_tmo = timeout;
@@ -726,6 +743,8 @@ struct fc_function_template zfcp_transpo
 	.get_fc_host_stats = zfcp_get_fc_host_stats,
 	.reset_fc_host_stats = zfcp_reset_fc_host_stats,
 	.set_rport_dev_loss_tmo = zfcp_set_rport_dev_loss_tmo,
+	.get_host_port_state = zfcp_get_host_port_state,
+	.show_host_port_state = 1,
 	/* no functions registered for following dynamic attributes but
 	   directly set by LLDD */
 	.show_host_port_type = 1,

-- 

  parent reply	other threads:[~2008-06-10 16:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 16:20 [patch 0/8] zfcp update Christof Schmitt
2008-06-10 16:20 ` [patch 1/8] zfcp: Move FC code to new file Christof Schmitt
2008-06-10 16:20 ` [patch 2/8] zfcp: Move CFDC " Christof Schmitt
2008-06-10 16:20 ` [patch 3/8] zfcp: Cleanup code in zfcp_ccw Christof Schmitt
2008-06-10 16:20 ` [patch 4/8] zfcp: Cleanup qdio code Christof Schmitt
2008-06-10 16:20 ` [patch 5/8] zfcp: Message cleanup Christof Schmitt
2008-06-10 16:20 ` Christof Schmitt [this message]
2008-06-10 16:21 ` [patch 7/8] zfcp: Automatically attach remote ports Christof Schmitt
2008-06-10 19:33   ` Bastian Blank
2008-06-10 19:36     ` Bastian Blank
2008-06-11  7:41       ` Swen Schillig
2008-06-10 16:21 ` [patch 8/8] zfcp: Remove sysfs attribute port_add Christof Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080610162517.622082000@de.ibm.com \
    --to=christof.schmitt@de.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sven@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.