* [PATCH 1/2] libsas: Provide a transport-level facility to request SAS addrs
@ 2007-10-09 0:39 Darrick J. Wong
0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2007-10-09 0:39 UTC (permalink / raw)
To: linux-scsi, linux-kernel; +Cc: Alexis Bruemmer
Use the request_firmware() interface to get a SAS address from userspace.
This way, there's no debate as to who or how an address gets generated;
it's up to the administrator to provide one if the driver can't find one
on its own.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
drivers/scsi/libsas/sas_scsi_host.c | 41 +++++++++++++++++++++++++++++++++++
include/scsi/libsas.h | 3 +++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 7663841..0fa0296 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -24,6 +24,8 @@
*/
#include <linux/kthread.h>
+#include <linux/firmware.h>
+#include <linux/ctype.h>
#include "sas_internal.h"
@@ -1047,6 +1049,45 @@ void sas_target_destroy(struct scsi_target *starget)
return;
}
+static void sas_parse_addr(u8 *sas_addr, const char *p)
+{
+ int i;
+ for (i = 0; i < SAS_ADDR_SIZE; i++) {
+ u8 h, l;
+ if (!*p)
+ break;
+ h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
+ p++;
+ l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
+ p++;
+ sas_addr[i] = (h<<4) | l;
+ }
+}
+
+#define SAS_STRING_ADDR_SIZE 16
+
+int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
+{
+ int res;
+ const struct firmware *fw;
+
+ res = request_firmware(&fw, "sas_addr", &shost->shost_gendev);
+ if (res)
+ return res;
+
+ if (fw->size < SAS_STRING_ADDR_SIZE) {
+ res = -ENODEV;
+ goto out;
+ }
+
+ sas_parse_addr(addr, fw->data);
+
+out:
+ release_firmware(fw);
+ return res;
+}
+EXPORT_SYMBOL_GPL(sas_request_addr);
+
EXPORT_SYMBOL_GPL(sas_queuecommand);
EXPORT_SYMBOL_GPL(sas_target_alloc);
EXPORT_SYMBOL_GPL(sas_slave_configure);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 8dda2d6..58aa2aa 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -676,4 +676,7 @@ extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg);
extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
struct request *req);
+
+int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
+
#endif /* _SASLIB_H_ */
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/2] libsas: Provide a transport-level facility to request SAS addrs
@ 2008-02-19 18:49 Darrick J. Wong
2008-02-19 19:50 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2008-02-19 18:49 UTC (permalink / raw)
To: linux-scsi, Alexis Bruemmer
Provide a facility to use the request_firmware() interface to get a SAS
address from userspace. This can be used by SAS LLDDs that cannot
obtain the address from the host adapter.
Resend of 8 Oct. 2007 patch, now based off 2.6.25-rc2 + scsi_misc.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
drivers/scsi/libsas/sas_scsi_host.c | 41 +++++++++++++++++++++++++++++++++++
include/scsi/libsas.h | 2 ++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index f869fba..583d249 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -24,6 +24,8 @@
*/
#include <linux/kthread.h>
+#include <linux/firmware.h>
+#include <linux/ctype.h>
#include "sas_internal.h"
@@ -1050,6 +1052,45 @@ void sas_target_destroy(struct scsi_target *starget)
return;
}
+static void sas_parse_addr(u8 *sas_addr, const char *p)
+{
+ int i;
+ for (i = 0; i < SAS_ADDR_SIZE; i++) {
+ u8 h, l;
+ if (!*p)
+ break;
+ h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
+ p++;
+ l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
+ p++;
+ sas_addr[i] = (h<<4) | l;
+ }
+}
+
+#define SAS_STRING_ADDR_SIZE 16
+
+int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
+{
+ int res;
+ const struct firmware *fw;
+
+ res = request_firmware(&fw, "sas_addr", &shost->shost_gendev);
+ if (res)
+ return res;
+
+ if (fw->size < SAS_STRING_ADDR_SIZE) {
+ res = -ENODEV;
+ goto out;
+ }
+
+ sas_parse_addr(addr, fw->data);
+
+out:
+ release_firmware(fw);
+ return res;
+}
+EXPORT_SYMBOL_GPL(sas_request_addr);
+
EXPORT_SYMBOL_GPL(sas_queuecommand);
EXPORT_SYMBOL_GPL(sas_target_alloc);
EXPORT_SYMBOL_GPL(sas_slave_configure);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 3ffd6b5..5f183de 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -676,4 +676,6 @@ extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
struct ssp_response_iu *iu);
+int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
+
#endif /* _SASLIB_H_ */
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] libsas: Provide a transport-level facility to request SAS addrs
2008-02-19 18:49 [PATCH 1/2] libsas: Provide a transport-level facility to request SAS addrs Darrick J. Wong
@ 2008-02-19 19:50 ` Jeff Garzik
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2008-02-19 19:50 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-scsi, Alexis Bruemmer
Darrick J. Wong wrote:
> Provide a facility to use the request_firmware() interface to get a SAS
> address from userspace. This can be used by SAS LLDDs that cannot
> obtain the address from the host adapter.
>
> Resend of 8 Oct. 2007 patch, now based off 2.6.25-rc2 + scsi_misc.
>
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
> ---
>
> drivers/scsi/libsas/sas_scsi_host.c | 41 +++++++++++++++++++++++++++++++++++
> include/scsi/libsas.h | 2 ++
> 2 files changed, 43 insertions(+), 0 deletions(-)
ACK patches 1-2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-19 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-19 18:49 [PATCH 1/2] libsas: Provide a transport-level facility to request SAS addrs Darrick J. Wong
2008-02-19 19:50 ` Jeff Garzik
-- strict thread matches above, loose matches on Subject: below --
2007-10-09 0:39 Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).