Skip to content

Commit a11e254

Browse files
Vikas ChaudharyJames Bottomley
authored andcommitted
[SCSI] scsi_transport_iscsi: added support for host event
Added support to post kernel host event to application using netlink interface. Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 46801ba commit a11e254

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,37 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
14761476
}
14771477
EXPORT_SYMBOL_GPL(iscsi_conn_login_event);
14781478

1479+
void iscsi_post_host_event(uint32_t host_no, struct iscsi_transport *transport,
1480+
enum iscsi_host_event_code code, uint32_t data_size,
1481+
uint8_t *data)
1482+
{
1483+
struct nlmsghdr *nlh;
1484+
struct sk_buff *skb;
1485+
struct iscsi_uevent *ev;
1486+
int len = NLMSG_SPACE(sizeof(*ev) + data_size);
1487+
1488+
skb = alloc_skb(len, GFP_KERNEL);
1489+
if (!skb) {
1490+
printk(KERN_ERR "gracefully ignored host event (%d):%d OOM\n",
1491+
host_no, code);
1492+
return;
1493+
}
1494+
1495+
nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
1496+
ev = NLMSG_DATA(nlh);
1497+
ev->transport_handle = iscsi_handle(transport);
1498+
ev->type = ISCSI_KEVENT_HOST_EVENT;
1499+
ev->r.host_event.host_no = host_no;
1500+
ev->r.host_event.code = code;
1501+
ev->r.host_event.data_size = data_size;
1502+
1503+
if (data_size)
1504+
memcpy((char *)ev + sizeof(*ev), data, data_size);
1505+
1506+
iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_KERNEL);
1507+
}
1508+
EXPORT_SYMBOL_GPL(iscsi_post_host_event);
1509+
14791510
static int
14801511
iscsi_if_send_reply(uint32_t group, int seq, int type, int done, int multi,
14811512
void *payload, int size)

include/scsi/iscsi_if.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ enum iscsi_uevent_e {
7272
ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
7373
ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
7474
ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9,
75+
ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10,
7576
};
7677

7778
enum iscsi_tgt_dscvr {
@@ -80,6 +81,13 @@ enum iscsi_tgt_dscvr {
8081
ISCSI_TGT_DSCVR_SLP = 3,
8182
};
8283

84+
enum iscsi_host_event_code {
85+
ISCSI_EVENT_LINKUP = 1,
86+
ISCSI_EVENT_LINKDOWN,
87+
/* must always be last */
88+
ISCSI_EVENT_MAX,
89+
};
90+
8391
struct iscsi_uevent {
8492
uint32_t type; /* k/u events type */
8593
uint32_t iferror; /* carries interface or resource errors */
@@ -222,6 +230,11 @@ struct iscsi_uevent {
222230
struct msg_notify_if_down {
223231
uint32_t host_no;
224232
} notify_if_down;
233+
struct msg_host_event {
234+
uint32_t host_no;
235+
uint32_t data_size;
236+
enum iscsi_host_event_code code;
237+
} host_event;
225238
} r;
226239
} __attribute__ ((aligned (sizeof(uint64_t))));
227240

include/scsi/scsi_transport_iscsi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ extern int iscsi_offload_mesg(struct Scsi_Host *shost,
166166
struct iscsi_transport *transport, uint32_t type,
167167
char *data, uint16_t data_size);
168168

169+
extern void iscsi_post_host_event(uint32_t host_no,
170+
struct iscsi_transport *transport,
171+
enum iscsi_host_event_code code,
172+
uint32_t data_size,
173+
uint8_t *data);
174+
169175
struct iscsi_cls_conn {
170176
struct list_head conn_list; /* item in connlist */
171177
void *dd_data; /* LLD private data */

0 commit comments

Comments
 (0)