Commit fd7255f5 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] iscsi: add sysfs attrs for uspace sync up

For iscsi boot when going from initramfs to the real root we
need to stop the userpsace iscsi daemon. To later restart it
iscsid needs to be able to rebuild itself and part of that
process is matching a session running the kernel with the
iscsid representation. To do this the attached patch
adds several required iscsi values. If the LLD does not provide
them becuase, login is done in userspace, then the transport
class and userspace set ths up for the LLD.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent b5c7a12d
......@@ -3536,7 +3536,7 @@ iscsi_session_get_param(struct iscsi_cls_session *cls_session,
*value = session->ofmarker_en;
break;
default:
return ISCSI_ERR_PARAM_NOT_FOUND;
return -EINVAL;
}
return 0;
......@@ -3547,6 +3547,7 @@ iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
enum iscsi_param param, uint32_t *value)
{
struct iscsi_conn *conn = cls_conn->dd_data;
struct inet_sock *inet;
switch(param) {
case ISCSI_PARAM_MAX_RECV_DLENGTH:
......@@ -3561,13 +3562,61 @@ iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
case ISCSI_PARAM_DATADGST_EN:
*value = conn->datadgst_en;
break;
case ISCSI_PARAM_CONN_PORT:
mutex_lock(&conn->xmitmutex);
if (!conn->sock) {
mutex_unlock(&conn->xmitmutex);
return -EINVAL;
}
inet = inet_sk(conn->sock->sk);
*value = be16_to_cpu(inet->dport);
mutex_unlock(&conn->xmitmutex);
default:
return ISCSI_ERR_PARAM_NOT_FOUND;
return -EINVAL;
}
return 0;
}
static int
iscsi_conn_get_str_param(struct iscsi_cls_conn *cls_conn,
enum iscsi_param param, char *buf)
{
struct iscsi_conn *conn = cls_conn->dd_data;
struct sock *sk;
struct inet_sock *inet;
struct ipv6_pinfo *np;
int len = 0;
switch (param) {
case ISCSI_PARAM_CONN_ADDRESS:
mutex_lock(&conn->xmitmutex);
if (!conn->sock) {
mutex_unlock(&conn->xmitmutex);
return -EINVAL;
}
sk = conn->sock->sk;
if (sk->sk_family == PF_INET) {
inet = inet_sk(sk);
len = sprintf(buf, "%u.%u.%u.%u\n",
NIPQUAD(inet->daddr));
} else {
np = inet6_sk(sk);
len = sprintf(buf,
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
NIP6(np->daddr));
}
mutex_unlock(&conn->xmitmutex);
break;
default:
return -EINVAL;
}
return len;
}
static void
iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)
{
......@@ -3610,6 +3659,20 @@ static struct iscsi_transport iscsi_tcp_transport = {
.name = "tcp",
.caps = CAP_RECOVERY_L0 | CAP_MULTI_R2T | CAP_HDRDGST
| CAP_DATADGST,
.param_mask = ISCSI_MAX_RECV_DLENGTH |
ISCSI_MAX_XMIT_DLENGTH |
ISCSI_HDRDGST_EN |
ISCSI_DATADGST_EN |
ISCSI_INITIAL_R2T_EN |
ISCSI_MAX_R2T |
ISCSI_IMM_DATA_EN |
ISCSI_FIRST_BURST |
ISCSI_MAX_BURST |
ISCSI_PDU_INORDER_EN |
ISCSI_DATASEQ_INORDER_EN |
ISCSI_ERL |
ISCSI_CONN_PORT |
ISCSI_CONN_ADDRESS,
.host_template = &iscsi_sht,
.hostdata_size = sizeof(struct iscsi_session),
.conndata_size = sizeof(struct iscsi_conn),
......@@ -3622,6 +3685,7 @@ static struct iscsi_transport iscsi_tcp_transport = {
.destroy_conn = iscsi_conn_destroy,
.set_param = iscsi_conn_set_param,
.get_conn_param = iscsi_conn_get_param,
.get_conn_str_param = iscsi_conn_get_str_param,
.get_session_param = iscsi_session_get_param,
.start_conn = iscsi_conn_start,
.stop_conn = iscsi_conn_stop,
......
This diff is collapsed.
......@@ -86,7 +86,7 @@ struct iscsi_uevent {
uint32_t sid;
uint32_t cid;
uint32_t param; /* enum iscsi_param */
uint32_t value;
uint32_t len;
} set_param;
struct msg_start_conn {
uint32_t sid;
......@@ -155,22 +155,54 @@ enum iscsi_err {
* iSCSI Parameters (RFC3720)
*/
enum iscsi_param {
ISCSI_PARAM_MAX_RECV_DLENGTH = 0,
ISCSI_PARAM_MAX_XMIT_DLENGTH = 1,
ISCSI_PARAM_HDRDGST_EN = 2,
ISCSI_PARAM_DATADGST_EN = 3,
ISCSI_PARAM_INITIAL_R2T_EN = 4,
ISCSI_PARAM_MAX_R2T = 5,
ISCSI_PARAM_IMM_DATA_EN = 6,
ISCSI_PARAM_FIRST_BURST = 7,
ISCSI_PARAM_MAX_BURST = 8,
ISCSI_PARAM_PDU_INORDER_EN = 9,
ISCSI_PARAM_DATASEQ_INORDER_EN = 10,
ISCSI_PARAM_ERL = 11,
ISCSI_PARAM_IFMARKER_EN = 12,
ISCSI_PARAM_OFMARKER_EN = 13,
/* passed in using netlink set param */
ISCSI_PARAM_MAX_RECV_DLENGTH,
ISCSI_PARAM_MAX_XMIT_DLENGTH,
ISCSI_PARAM_HDRDGST_EN,
ISCSI_PARAM_DATADGST_EN,
ISCSI_PARAM_INITIAL_R2T_EN,
ISCSI_PARAM_MAX_R2T,
ISCSI_PARAM_IMM_DATA_EN,
ISCSI_PARAM_FIRST_BURST,
ISCSI_PARAM_MAX_BURST,
ISCSI_PARAM_PDU_INORDER_EN,
ISCSI_PARAM_DATASEQ_INORDER_EN,
ISCSI_PARAM_ERL,
ISCSI_PARAM_IFMARKER_EN,
ISCSI_PARAM_OFMARKER_EN,
ISCSI_PARAM_TARGET_NAME,
ISCSI_PARAM_TPGT,
ISCSI_PARAM_PERSISTENT_ADDRESS,
ISCSI_PARAM_PERSISTENT_PORT,
/* pased in through bind conn using transport_fd */
ISCSI_PARAM_CONN_PORT,
ISCSI_PARAM_CONN_ADDRESS,
/* must always be last */
ISCSI_PARAM_MAX,
};
#define ISCSI_PARAM_MAX 14
#define ISCSI_MAX_RECV_DLENGTH (1 << ISCSI_PARAM_MAX_RECV_DLENGTH)
#define ISCSI_MAX_XMIT_DLENGTH (1 << ISCSI_PARAM_MAX_XMIT_DLENGTH)
#define ISCSI_HDRDGST_EN (1 << ISCSI_PARAM_HDRDGST_EN)
#define ISCSI_DATADGST_EN (1 << ISCSI_PARAM_DATADGST_EN)
#define ISCSI_INITIAL_R2T_EN (1 << ISCSI_PARAM_INITIAL_R2T_EN)
#define ISCSI_MAX_R2T (1 << ISCSI_PARAM_MAX_R2T)
#define ISCSI_IMM_DATA_EN (1 << ISCSI_PARAM_IMM_DATA_EN)
#define ISCSI_FIRST_BURST (1 << ISCSI_PARAM_FIRST_BURST)
#define ISCSI_MAX_BURST (1 << ISCSI_PARAM_MAX_BURST)
#define ISCSI_PDU_INORDER_EN (1 << ISCSI_PARAM_PDU_INORDER_EN)
#define ISCSI_DATASEQ_INORDER_EN (1 << ISCSI_PARAM_DATASEQ_INORDER_EN)
#define ISCSI_ERL (1 << ISCSI_PARAM_ERL)
#define ISCSI_IFMARKER_EN (1 << ISCSI_PARAM_IFMARKER_EN)
#define ISCSI_OFMARKER_EN (1 << ISCSI_PARAM_OFMARKER_EN)
#define ISCSI_TARGET_NAME (1 << ISCSI_PARAM_TARGET_NAME)
#define ISCSI_TPGT (1 << ISCSI_PARAM_TPGT)
#define ISCSI_PERSISTENT_ADDRESS (1 << ISCSI_PARAM_PERSISTENT_ADDRESS)
#define ISCSI_PERSISTENT_PORT (1 << ISCSI_PARAM_PERSISTENT_PORT)
#define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT)
#define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS)
#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
......
......@@ -53,11 +53,11 @@ struct iscsi_transport {
struct module *owner;
char *name;
unsigned int caps;
/* LLD sets this to indicate what values it can export to sysfs */
unsigned int param_mask;
struct scsi_host_template *host_template;
/* LLD session/scsi_host data size */
int hostdata_size;
/* LLD iscsi_host data size */
int ihostdata_size;
/* LLD connection data size */
int conndata_size;
/* LLD session data size */
......@@ -79,10 +79,13 @@ struct iscsi_transport {
int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param,
uint32_t value);
int (*get_conn_param) (struct iscsi_cls_conn *conn,
enum iscsi_param param,
uint32_t *value);
enum iscsi_param param, uint32_t *value);
int (*get_session_param) (struct iscsi_cls_session *session,
enum iscsi_param param, uint32_t *value);
int (*get_conn_str_param) (struct iscsi_cls_conn *conn,
enum iscsi_param param, char *buf);
int (*get_session_str_param) (struct iscsi_cls_session *session,
enum iscsi_param param, char *buf);
int (*send_pdu) (struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size);
void (*get_stats) (struct iscsi_cls_conn *conn,
......@@ -107,6 +110,14 @@ struct iscsi_cls_conn {
void *dd_data; /* LLD private data */
struct iscsi_transport *transport;
uint32_t cid; /* connection id */
/* portal/group values we got during discovery */
char *persistent_address;
int persistent_port;
/* portal/group values we are currently using */
char *address;
int port;
int active; /* must be accessed with the connlock */
struct device dev; /* sysfs transport/container device */
struct mempool_zone *z_error;
......@@ -120,6 +131,11 @@ struct iscsi_cls_conn {
struct iscsi_cls_session {
struct list_head sess_list; /* item in session_list */
struct iscsi_transport *transport;
/* iSCSI values used as unique id by userspace. */
char *targetname;
int tpgt;
int sid; /* session id */
void *dd_data; /* LLD private data */
struct device dev; /* sysfs transport/container device */
......
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