Skip to content

Commit 1819dc8

Browse files
Mike ChristieJames Bottomley
authored andcommitted
[SCSI] iscsi_transport: export hw address
Add hw address sysfs file. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent 239a7dc commit 1819dc8

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define ISCSI_SESSION_ATTRS 11
3434
#define ISCSI_CONN_ATTRS 11
35-
#define ISCSI_HOST_ATTRS 0
35+
#define ISCSI_HOST_ATTRS 1
3636
#define ISCSI_TRANSPORT_VERSION "2.0-724"
3737

3838
struct iscsi_internal {
@@ -1197,6 +1197,25 @@ static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO, show_priv_session_##field, \
11971197
NULL)
11981198
iscsi_priv_session_attr(recovery_tmo, "%d");
11991199

1200+
/*
1201+
* iSCSI host attrs
1202+
*/
1203+
#define iscsi_host_attr_show(param) \
1204+
static ssize_t \
1205+
show_host_param_##param(struct class_device *cdev, char *buf) \
1206+
{ \
1207+
struct Scsi_Host *shost = transport_class_to_shost(cdev); \
1208+
struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \
1209+
return priv->iscsi_transport->get_host_param(shost, param, buf); \
1210+
}
1211+
1212+
#define iscsi_host_attr(field, param) \
1213+
iscsi_host_attr_show(param) \
1214+
static ISCSI_CLASS_ATTR(host, field, S_IRUGO, show_host_param_##param, \
1215+
NULL);
1216+
1217+
iscsi_host_attr(hwaddress, ISCSI_HOST_PARAM_HWADDRESS);
1218+
12001219
#define SETUP_PRIV_SESSION_RD_ATTR(field) \
12011220
do { \
12021221
priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \
@@ -1220,6 +1239,14 @@ do { \
12201239
} \
12211240
} while (0)
12221241

1242+
#define SETUP_HOST_RD_ATTR(field, param_flag) \
1243+
do { \
1244+
if (tt->host_param_mask & param_flag) { \
1245+
priv->host_attrs[count] = &class_device_attr_host_##field; \
1246+
count++; \
1247+
} \
1248+
} while (0)
1249+
12231250
static int iscsi_session_match(struct attribute_container *cont,
12241251
struct device *dev)
12251252
{
@@ -1321,9 +1348,13 @@ iscsi_register_transport(struct iscsi_transport *tt)
13211348
priv->t.host_attrs.ac.class = &iscsi_host_class.class;
13221349
priv->t.host_attrs.ac.match = iscsi_host_match;
13231350
priv->t.host_size = sizeof(struct iscsi_host);
1324-
priv->host_attrs[0] = NULL;
13251351
transport_container_register(&priv->t.host_attrs);
13261352

1353+
SETUP_HOST_RD_ATTR(hwaddress, ISCSI_HOST_HWADDRESS);
1354+
BUG_ON(count > ISCSI_HOST_ATTRS);
1355+
priv->host_attrs[count] = NULL;
1356+
count = 0;
1357+
13271358
/* connection parameters */
13281359
priv->conn_cont.ac.attrs = &priv->conn_attrs[0];
13291360
priv->conn_cont.ac.class = &iscsi_connection_class.class;

include/scsi/iscsi_if.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ enum iscsi_param {
250250
#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT)
251251
#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS)
252252

253+
/* iSCSI HBA params */
254+
enum iscsi_host_param {
255+
ISCSI_HOST_PARAM_HWADDRESS,
256+
ISCSI_HOST_PARAM_MAX,
257+
};
258+
259+
#define ISCSI_HOST_HWADDRESS (1 << ISCSI_HOST_PARAM_HWADDRESS)
260+
253261
#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
254262
#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
255263
#define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata))

include/scsi/scsi_transport_iscsi.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ struct iscsi_transport {
7979
char *name;
8080
unsigned int caps;
8181
/* LLD sets this to indicate what values it can export to sysfs */
82-
unsigned int param_mask;
82+
uint64_t param_mask;
83+
uint64_t host_param_mask;
8384
struct scsi_host_template *host_template;
8485
/* LLD connection data size */
8586
int conndata_size;
@@ -105,6 +106,8 @@ struct iscsi_transport {
105106
enum iscsi_param param, char *buf);
106107
int (*get_session_param) (struct iscsi_cls_session *session,
107108
enum iscsi_param param, char *buf);
109+
int (*get_host_param) (struct Scsi_Host *shost,
110+
enum iscsi_host_param param, char *buf);
108111
int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
109112
char *data, uint32_t data_size);
110113
void (*get_stats) (struct iscsi_cls_conn *conn,

0 commit comments

Comments
 (0)