Update krping to the latest upstream code. Move all the FreeBSD
specific parts to krping_dev.c, which leaves the other files as close to their upstream versions as possible.
This commit is contained in:
parent
07992c1fed
commit
0082e6a570
@ -5,9 +5,10 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/ctype.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/libkern.h>
|
||||
#include <sys/types.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
/**
|
||||
@ -49,29 +50,29 @@ int krping_getopt(const char *caller, char **options,
|
||||
if (opts->has_arg & OPT_NOPARAM) {
|
||||
return opts->val;
|
||||
}
|
||||
printf("%s: the %s option requires "
|
||||
printk(KERN_INFO "%s: the %s option requires "
|
||||
"an argument\n", caller, token);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (opts->has_arg & OPT_INT) {
|
||||
char* v;
|
||||
|
||||
*value = strtoul(val, &v, 0);
|
||||
*value = simple_strtoul(val, &v, 0);
|
||||
if (!*v) {
|
||||
return opts->val;
|
||||
}
|
||||
printf("%s: invalid numeric value "
|
||||
printk(KERN_INFO "%s: invalid numeric value "
|
||||
"in %s=%s\n", caller, token, val);
|
||||
return -EDOM;
|
||||
}
|
||||
if (opts->has_arg & OPT_STRING) {
|
||||
return opts->val;
|
||||
}
|
||||
printf("%s: unexpected argument %s to the "
|
||||
printk(KERN_INFO "%s: unexpected argument %s to the "
|
||||
"%s option\n", caller, val, token);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
printf("%s: Unrecognized option %s\n", caller, token);
|
||||
printk(KERN_INFO "%s: Unrecognized option %s\n", caller, token);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,133 +1,21 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
#include <rdma/ib_verbs.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*
|
||||
* Krping header stuffs...
|
||||
*/
|
||||
|
||||
struct krping_stats {
|
||||
unsigned send_bytes;
|
||||
unsigned send_msgs;
|
||||
unsigned recv_bytes;
|
||||
unsigned recv_msgs;
|
||||
unsigned write_bytes;
|
||||
unsigned write_msgs;
|
||||
unsigned read_bytes;
|
||||
unsigned read_msgs;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* These states are used to signal events between the completion handler
|
||||
* and the main client or server thread.
|
||||
*
|
||||
* Once CONNECTED, they cycle through RDMA_READ_ADV, RDMA_WRITE_ADV,
|
||||
* and RDMA_WRITE_COMPLETE for each ping.
|
||||
*/
|
||||
enum test_state {
|
||||
IDLE = 1,
|
||||
CONNECT_REQUEST,
|
||||
ADDR_RESOLVED,
|
||||
ROUTE_RESOLVED,
|
||||
CONNECTED,
|
||||
RDMA_READ_ADV,
|
||||
RDMA_READ_COMPLETE,
|
||||
RDMA_WRITE_ADV,
|
||||
RDMA_WRITE_COMPLETE,
|
||||
ERROR,
|
||||
CLEANUP
|
||||
};
|
||||
|
||||
struct krping_rdma_info {
|
||||
uint64_t buf;
|
||||
uint32_t rkey;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/*
|
||||
* Control block struct.
|
||||
*/
|
||||
struct krping_cb {
|
||||
int server; /* 0 iff client */
|
||||
struct ib_cq *cq;
|
||||
struct ib_pd *pd;
|
||||
struct ib_qp *qp;
|
||||
struct ib_mr *dma_mr;
|
||||
int use_dmamr;
|
||||
|
||||
struct ib_recv_wr rq_wr; /* recv work request record */
|
||||
struct ib_sge recv_sgl; /* recv single SGE */
|
||||
struct krping_rdma_info recv_buf;/* malloc'd buffer */
|
||||
struct ib_mr *recv_mr;
|
||||
|
||||
struct ib_send_wr sq_wr; /* send work requrest record */
|
||||
struct ib_sge send_sgl;
|
||||
struct krping_rdma_info send_buf;/* single send buf */
|
||||
struct ib_mr *send_mr;
|
||||
|
||||
struct ib_send_wr rdma_sq_wr; /* rdma work request record */
|
||||
struct ib_sge rdma_sgl; /* rdma single SGE */
|
||||
char *rdma_buf; /* used as rdma sink */
|
||||
u64 rdma_addr;
|
||||
struct ib_mr *rdma_mr;
|
||||
|
||||
uint32_t remote_rkey; /* remote guys RKEY */
|
||||
uint64_t remote_addr; /* remote guys TO */
|
||||
uint32_t remote_len; /* remote guys LEN */
|
||||
|
||||
char *start_buf; /* rdma read src */
|
||||
u64 start_addr;
|
||||
struct ib_mr *start_mr;
|
||||
|
||||
enum test_state state; /* used for cond/signalling */
|
||||
struct mtx lock;
|
||||
struct krping_stats stats;
|
||||
|
||||
uint16_t port; /* dst port in NBO */
|
||||
struct in_addr addr; /* dst addr in NBO */
|
||||
char *addr_str; /* dst addr string */
|
||||
int verbose; /* verbose logging */
|
||||
int count; /* ping count */
|
||||
int size; /* ping data size */
|
||||
int validate; /* validate ping data */
|
||||
uint64_t memlimit; /* limit of the physical memory that
|
||||
can be registered with dma_mr mode */
|
||||
|
||||
/* CM stuff */
|
||||
struct rdma_cm_id *cm_id; /* connection on client side,*/
|
||||
/* listener on service side. */
|
||||
struct rdma_cm_id *child_cm_id; /* connection on server side */
|
||||
TAILQ_ENTRY(krping_cb) list;
|
||||
|
||||
int rlat; /* run read latency test */
|
||||
int wlat; /* run write latency test */
|
||||
int bw; /* run write bw test */
|
||||
int duplex; /* run write bw full duplex test */
|
||||
int poll; /* poll vs block in rlat */
|
||||
int txdepth;
|
||||
|
||||
unsigned long long send_bytes;
|
||||
unsigned long long send_msgs;
|
||||
unsigned long long recv_bytes;
|
||||
unsigned long long recv_msgs;
|
||||
unsigned long long write_bytes;
|
||||
unsigned long long write_msgs;
|
||||
unsigned long long read_bytes;
|
||||
unsigned long long read_msgs;
|
||||
char name[16];
|
||||
};
|
||||
|
||||
static __inline uint64_t
|
||||
get_cycles(void)
|
||||
{
|
||||
u_int32_t low, high;
|
||||
__asm __volatile("rdtsc" : "=a" (low), "=d" (high));
|
||||
return (low | ((u_int64_t)high << 32));
|
||||
}
|
||||
|
||||
#define htonll(x) htobe64((x))
|
||||
#define ntohll(x) be64toh((x))
|
||||
|
||||
typedef uint64_t cycles_t;
|
||||
|
||||
extern struct mtx krping_mutex;
|
||||
TAILQ_HEAD(krping_cb_list, krping_cb);
|
||||
extern struct krping_cb_list krping_cbs;
|
||||
|
||||
int krping_doit(char *cmd);
|
||||
int krping_doit(char *, void *);
|
||||
void krping_walk_cb_list(void (*)(struct krping_stats *, void *), void *);
|
||||
void krping_init(void);
|
||||
void krping_printf(void *, const char *, ...);
|
||||
int krping_sigpending(void);
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* This code lifted from:
|
||||
* This code lifted from:
|
||||
* Simple `echo' pseudo-device KLD
|
||||
* Murray Stokely
|
||||
* Converted to 5.X by Søren (Xride) Straarup
|
||||
*/
|
||||
|
||||
/*
|
||||
* /bin/echo "server,port=9999,addr=192.168.69.142,validate" > /dev/krping
|
||||
* /bin/echo "client,port=9999,addr=192.168.69.142,validate" > /dev/krping
|
||||
* /bin/echo "server,port=9999,addr=192.168.69.142,validate" > /dev/krping
|
||||
* /bin/echo "client,port=9999,addr=192.168.69.142,validate" > /dev/krping
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/systm.h> /* uprintf */
|
||||
#include <sys/errno.h>
|
||||
#include <sys/param.h> /* defines used in kernel.h */
|
||||
@ -21,11 +22,19 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/conf.h> /* cdevsw struct */
|
||||
#include <sys/uio.h> /* uio struct */
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include "krping.h"
|
||||
|
||||
#define BUFFERSIZE 512
|
||||
|
||||
SYSCTL_NODE(_dev, OID_AUTO, krping, CTLFLAG_RW, 0, "kernel rping module");
|
||||
|
||||
int krping_debug = 0;
|
||||
SYSCTL_INT(_dev_krping, OID_AUTO, debug, CTLFLAG_RW, &krping_debug, 0 , "");
|
||||
|
||||
/* Function prototypes */
|
||||
static d_open_t krping_open;
|
||||
static d_close_t krping_close;
|
||||
@ -47,12 +56,15 @@ typedef struct s_krping {
|
||||
int len;
|
||||
} krping_t;
|
||||
|
||||
struct stats_list_entry {
|
||||
STAILQ_ENTRY(stats_list_entry) link;
|
||||
struct krping_stats *stats;
|
||||
};
|
||||
STAILQ_HEAD(stats_list, stats_list_entry);
|
||||
|
||||
/* vars */
|
||||
static struct cdev *krping_dev;
|
||||
|
||||
#undef MODULE_VERSION
|
||||
#include <sys/module.h>
|
||||
|
||||
static int
|
||||
krping_loader(struct module *m, int what, void *arg)
|
||||
{
|
||||
@ -61,7 +73,7 @@ krping_loader(struct module *m, int what, void *arg)
|
||||
switch (what) {
|
||||
case MOD_LOAD: /* kldload */
|
||||
krping_init();
|
||||
krping_dev = make_dev(&krping_cdevsw, 0, UID_ROOT, GID_WHEEL,
|
||||
krping_dev = make_dev(&krping_cdevsw, 0, UID_ROOT, GID_WHEEL,
|
||||
0600, "krping");
|
||||
printf("Krping device loaded.\n");
|
||||
break;
|
||||
@ -73,61 +85,82 @@ krping_loader(struct module *m, int what, void *arg)
|
||||
err = EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
krping_open(struct cdev *dev, int oflags, int devtype, struct thread *p)
|
||||
{
|
||||
int err = 0;
|
||||
return err;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
krping_close(struct cdev *dev, int fflag, int devtype, struct thread *p)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
krping_copy_stats(struct krping_stats *stats, void *arg)
|
||||
{
|
||||
struct stats_list_entry *s;
|
||||
struct stats_list *list = arg;
|
||||
|
||||
s = malloc(sizeof(*s), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
if (s == NULL)
|
||||
return;
|
||||
if (stats != NULL) {
|
||||
s->stats = malloc(sizeof(*stats), M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
if (s->stats == NULL) {
|
||||
free(s, M_DEVBUF);
|
||||
return;
|
||||
}
|
||||
*s->stats = *stats;
|
||||
}
|
||||
STAILQ_INSERT_TAIL(list, s, link);
|
||||
}
|
||||
|
||||
static int
|
||||
krping_read(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
{
|
||||
struct krping_cb *cb, *cb2;
|
||||
int num=1;
|
||||
struct krping_cb_list copy_cbs;
|
||||
int num = 1;
|
||||
struct stats_list list;
|
||||
struct stats_list_entry *e;
|
||||
|
||||
STAILQ_INIT(&list);
|
||||
krping_walk_cb_list(krping_copy_stats, &list);
|
||||
|
||||
if (STAILQ_EMPTY(&list))
|
||||
return (0);
|
||||
|
||||
uprintf("krping: %4s %10s %10s %10s %10s %10s %10s %10s %10s %10s\n",
|
||||
"num", "device", "snd bytes", "snd msgs", "rcv bytes",
|
||||
"rcv msgs", "wr bytes", "wr msgs", "rd bytes", "rd msgs");
|
||||
TAILQ_INIT(©_cbs);
|
||||
"num", "device", "snd bytes", "snd msgs", "rcv bytes", "rcv msgs",
|
||||
"wr bytes", "wr msgs", "rd bytes", "rd msgs");
|
||||
|
||||
mtx_lock(&krping_mutex);
|
||||
TAILQ_FOREACH(cb, &krping_cbs, list) {
|
||||
cb2 = malloc(sizeof(*cb), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
if (!cb2)
|
||||
break;
|
||||
bcopy(cb, cb2, sizeof(*cb));
|
||||
TAILQ_INSERT_TAIL(©_cbs, cb2, list);
|
||||
}
|
||||
mtx_unlock(&krping_mutex);
|
||||
while (!STAILQ_EMPTY(&list)) {
|
||||
e = STAILQ_FIRST(&list);
|
||||
STAILQ_REMOVE_HEAD(&list, link);
|
||||
if (e->stats == NULL)
|
||||
uprintf("krping: %d listen\n", num);
|
||||
else {
|
||||
struct krping_stats *stats = e->stats;
|
||||
|
||||
while (!TAILQ_EMPTY(©_cbs)) {
|
||||
cb = TAILQ_FIRST(©_cbs);
|
||||
TAILQ_REMOVE(©_cbs, cb, list);
|
||||
if (cb->pd) {
|
||||
uprintf("krping: %4d %10s %10u %10u %10u %10u %10u %10u %10u %10u\n",
|
||||
num++, cb->name, cb->stats.send_bytes,
|
||||
cb->stats.send_msgs, cb->stats.recv_bytes,
|
||||
cb->stats.recv_msgs, cb->stats.write_bytes,
|
||||
cb->stats.write_msgs,
|
||||
cb->stats.read_bytes,
|
||||
cb->stats.read_msgs);
|
||||
} else {
|
||||
uprintf("krping: %d listen\n", num++);
|
||||
uprintf("krping: %4d %10s %10llu %10llu %10llu %10llu "
|
||||
"%10llu %10llu %10llu %10llu\n", num, stats->name,
|
||||
stats->send_bytes, stats->send_msgs,
|
||||
stats->recv_bytes, stats->recv_msgs,
|
||||
stats->write_bytes, stats->write_msgs,
|
||||
stats->read_bytes, stats->read_msgs);
|
||||
free(stats, M_DEVBUF);
|
||||
}
|
||||
free(cb, M_DEVBUF);
|
||||
num++;
|
||||
free(e, M_DEVBUF);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -171,9 +204,27 @@ krping_write(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
*cp = 0;
|
||||
krpingmsg->len = (unsigned long)(cp - krpingmsg->msg);
|
||||
uprintf("krping: write string = |%s|\n", krpingmsg->msg);
|
||||
err = krping_doit(krpingmsg->msg);
|
||||
err = krping_doit(krpingmsg->msg, curproc);
|
||||
free(krpingmsg, M_DEVBUF);
|
||||
return(err);
|
||||
}
|
||||
|
||||
DEV_MODULE(krping,krping_loader,NULL);
|
||||
void
|
||||
krping_printf(void *cookie, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vtprintf(cookie, -1, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int
|
||||
krping_sigpending(void)
|
||||
{
|
||||
|
||||
return (SIGPENDING(curthread));
|
||||
}
|
||||
|
||||
DEV_MODULE(krping, krping_loader, NULL);
|
||||
MODULE_DEPEND(krping, ibcore, 1, 1, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user