");
> +return -EIO;
> +}
> +
> +hash_tbl_alloc();
> +
> +return 0;
> +}
> +
> +static void signal_handler(int sig, siginfo_t *siginfo, void *context)
> +{
> +static bool warned;
> +
> +/* Prevent stop if clients are connected */
> +if (server.nfds != 1) {
> +if (!warned) {
> +syslog(LOG_WARNING,
> + "Can't stop while active client exist, resend SIGINT to
> overid");
> +warned = true;
> +return;
> +}
> +}
> +
> +if (sig == SIGINT) {
> +server.run = false;
> +fini();
> +}
> +
> +exit(0);
> +}
> +
> +static int init(void)
> +{
> +int rc;
> +struct sigaction sig = {0};
> +
> +rc = init_listener();
> +if (rc) {
> +return rc;
> +}
> +
> +rc = init_umad();
> +if (rc) {
> +return rc;
> +}
> +
> +pthread_rwlock_init(&server.lock, 0);
> +
> +rc = pthread_create(&server.umad_recv_thread, NULL,
> umad_recv_thread_func,
> +NULL);
> +if (rc) {
> +syslog(LOG_ERR, "Fail to create UMAD receiver thread (%d)\n", rc);
> +return rc;
> +}
> +
> +sig.sa_sigaction = &signal_handler;
> +sig.sa_flags = SA_SIGINFO;
> +rc = sigaction(SIGINT, &sig, NULL);
> +if (rc < 0) {
> +syslog(LOG_ERR, "Fail to install SIGINT handler (%d)\n", errno);
> +return rc;
> +}
> +
> +return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +int rc;
> +
> +memset(&server, 0, sizeof(server));
> +
> +parse_args(argc, argv);
> +
> +rc = init();
> +if (rc) {
> +syslog(LOG_ERR, "Fail to initialize server (%d)\n", rc);
> +rc = -EAGAIN;
> +goto out;
> +}
> +
> +run();
> +
> +out:
> +fini();
> +
> +return rc;
> +}
> diff --git a/contrib/rdmacm-mux/rdmacm-mux.h b/contrib/rdmacm-mux/rdmacm-mux.h
> new file mode 100644
> index 00..03508d52b2
> --- /dev/null
> +++ b/contrib/rdmacm-mux/rdmacm-mux.h
> @@ -0,0 +1,56 @@
> +/*
> + * QEMU paravirtual RDMA - rdmacm-mux declarations
> + *
> + * Copyright (C) 2018 Oracle
> + * Copyright (C) 2018 Red Hat Inc
> + *
> + * Authors:
> + * Yuval Shaia
> + * Marcel Apfelbaum
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#ifndef RDMACM_MUX_H
> +#define RDMACM_MUX_H
> +
> +#include "linux/if.h"
> +#include "infiniband/verbs.h"
> +#include "infiniband/umad.h"
> +#include "rdma/rdma_user_cm.h"
> +
> +typedef enum RdmaCmMuxMsgType {
> +RDMACM_MUX_MSG_TYPE_REG = 0,
> +RDMACM_MUX_MSG_TYPE_UNREG = 1,
> +RDMACM_MUX_MSG_TYPE_MAD = 2,
> +RDMACM_MUX_MSG_TYPE_RESP = 3,
> +} RdmaCmMuxMsgType;
> +
> +typedef enum RdmaCmMuxErrCode {
> +RDMACM_MUX_ERR_CODE_OK= 0,
> +RDMACM_MUX_ERR_CODE_EINVAL= 1,
> +RDMACM_MUX_ERR_CODE_EEXIST= 2,
> +RDMACM_MUX_ERR_CODE_EACCES= 3,
> +RDMACM_MUX_ERR_CODE_ENOTFOUND = 4,
> +} RdmaCmMuxErrCode;
> +
> +typedef struct RdmaCmMuxHdr {
> +RdmaCmMuxMsgType msg_type;
> +union ibv_gid sgid;
> +RdmaCmMuxErrCode err_code;
> +} RdmaCmUHdr;
> +
> +typedef struct RdmaCmUMad {
> +struct ib_user_mad hdr;
> +char mad[RDMA_MAX_PRIVATE_DATA];
> +} RdmaCmUMad;
> +
> +typedef struct RdmaCmMuxMsg {
> +RdmaCmUHdr hdr;
> +int umad_len;
> +RdmaCmUMad umad;
> +} RdmaCmMuxMsg;
> +
> +#endif
> --
> 2.17.2
>
Reviewed-by: Shamir Rabinovitch
On Thu, Nov 08, 2018 at 06:07:57PM +0200, Yuval Shaia wrote:
> RDMA MAD kernel module (ibcm) disallow more than one MAD-agent for a
> given MAD class.
> This does not go hand-by-hand with qemu pvrdma device's requirements
> where each VM is MAD agent.
> Fix it by adding implementation of RDMA MAD m