and the bytes we push through vscsi(4).
-/* $OpenBSD: iscsid.c,v 1.11 2014/04/20 12:22:16 claudio Exp $ */
+/* $OpenBSD: iscsid.c,v 1.12 2014/04/20 22:18:04 claudio Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
log_verbose(*valp);
control_compose(ch, CTRL_SUCCESS, NULL, 0);
break;
+ case CTRL_VSCSI_STATS:
+ control_compose(ch, CTRL_VSCSI_STATS, vscsi_stats(),
+ sizeof(struct vscsi_stats));
+ break;
default:
log_warnx("unknown control message type %d", cmh->type);
control_compose(ch, CTRL_FAILURE, NULL, 0);
-/* $OpenBSD: iscsid.h,v 1.10 2014/04/07 19:55:46 claudio Exp $ */
+/* $OpenBSD: iscsid.h,v 1.11 2014/04/20 22:18:04 claudio Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
#define CTRL_INITIATOR_CONFIG 4
#define CTRL_SESSION_CONFIG 5
#define CTRL_LOG_VERBOSE 6
+#define CTRL_VSCSI_STATS 7
TAILQ_HEAD(session_head, session);
#define KVP_KEY_ALLOCED 0x01
#define KVP_VALUE_ALLOCED 0x02
+struct vscsi_stats {
+ u_int64_t bytes_rd;
+ u_int64_t bytes_wr;
+ u_int64_t cnt_read;
+ u_int64_t cnt_write;
+ u_int64_t cnt_i2t;
+ u_int64_t cnt_i2t_dir[3];
+ u_int64_t cnt_t2i;
+ u_int64_t cnt_t2i_status[3];
+ u_int32_t cnt_probe;
+ u_int32_t cnt_detach;
+};
+
extern const struct session_params iscsi_sess_defaults;
extern const struct connection_params iscsi_conn_defaults;
extern struct session_params initiator_sess_defaults;
void vscsi_data(unsigned long, int, void *, size_t);
void vscsi_status(int, int, void *, size_t);
void vscsi_event(unsigned long, u_int, u_int);
+struct vscsi_stats *vscsi_stats(void);
-/* $OpenBSD: vscsi.c,v 1.9 2014/04/19 18:31:33 claudio Exp $ */
+/* $OpenBSD: vscsi.c,v 1.10 2014/04/20 22:18:04 claudio Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
*/
#include <sys/types.h>
+#include <sys/param.h> /* for nitems */
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include "log.h"
struct vscsi {
- struct event ev;
- int fd;
+ struct event ev;
+ int fd;
+ struct vscsi_stats stats;
} v;
struct scsi_task {
if (ioctl(v.fd, VSCSI_I2T, &i2t) == -1)
fatal("vscsi_dispatch");
+ v.stats.cnt_i2t++;
+ if (i2t.direction < (int)nitems(v.stats.cnt_i2t_dir))
+ v.stats.cnt_i2t_dir[i2t.direction]++;
+
s = initiator_t2s(i2t.target);
if (s == NULL)
fatalx("vscsi_dispatch: unknown target");
session_task_issue(s, &t->task);
}
+/* read / write data to vscsi */
void
vscsi_data(unsigned long req, int tag, void *buf, size_t len)
{
struct vscsi_ioc_data data;
+ if (req == VSCSI_DATA_READ) {
+ v.stats.cnt_read++;
+ v.stats.bytes_rd += len;
+ } else if (req == VSCSI_DATA_WRITE) {
+ v.stats.cnt_write++;
+ v.stats.bytes_wr += len;
+ }
data.tag = tag;
data.data = buf;
data.datalen = len;
{
struct vscsi_ioc_t2i t2i;
+ v.stats.cnt_t2i++;
+ if (status < (int)nitems(v.stats.cnt_t2i_status))
+ v.stats.cnt_t2i_status[status]++;
+
bzero(&t2i, sizeof(t2i));
t2i.tag = tag;
t2i.status = status;
{
struct vscsi_ioc_devevent devev;
+ if (req == VSCSI_REQPROBE)
+ v.stats.cnt_probe++;
+ else if (req == VSCSI_REQDETACH)
+ v.stats.cnt_detach++;
+
devev.target = target;
devev.lun = lun;
}
conn_task_issue(c, &t->task);
}
+
+struct vscsi_stats *
+vscsi_stats(void)
+{
+ return &v.stats;
+}