Skip to content

Commit

Permalink
IB/RXE: Add ib_rxe.h uapi file for shared objects
Browse files Browse the repository at this point in the history
Add ib_rxe.h uapi file to hold all the shared objects between user space
and kernel space.

Fixes: #36
issue: none

Change-Id: I9f78cb9506159a623d21087d4cb567295302f45e
Signed-off-by: Kamal Heib <[email protected]>
  • Loading branch information
Kamal Heib committed Jul 29, 2015
1 parent 0c21a45 commit e1ed702
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 68 deletions.
18 changes: 9 additions & 9 deletions drivers/infiniband/hw/rxe/rxe_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,
/* Fall through (IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE
* doesn't have an AETH) */
case IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE:
if (wqe->ibwr.opcode != IB_WR_RDMA_READ &&
wqe->ibwr.opcode != IB_WR_RDMA_READ_WITH_INV) {
if (wqe->wr.opcode != IB_WR_RDMA_READ &&
wqe->wr.opcode != IB_WR_RDMA_READ_WITH_INV) {
/* TODO check spec. retry/discard ? */
return COMPST_ERROR;
}
Expand All @@ -284,8 +284,8 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,
if ((syn & AETH_TYPE_MASK) != AETH_ACK)
return COMPST_ERROR;

if (wqe->ibwr.opcode != IB_WR_ATOMIC_CMP_AND_SWP &&
wqe->ibwr.opcode != IB_WR_ATOMIC_FETCH_AND_ADD)
if (wqe->wr.opcode != IB_WR_ATOMIC_CMP_AND_SWP &&
wqe->wr.opcode != IB_WR_ATOMIC_FETCH_AND_ADD)
/* TODO check spec. retry/discard ? */
return COMPST_ERROR;
reset_retry_counters(qp);
Expand Down Expand Up @@ -392,17 +392,17 @@ static void make_send_cqe(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
if (!qp->is_user) {
struct ib_wc *wc = &cqe->ibwc;

wc->wr_id = wqe->ibwr.wr_id;
wc->wr_id = wqe->wr.wr_id;
wc->status = wqe->status;
wc->opcode = wr_to_wc_opcode(wqe->ibwr.opcode);
wc->opcode = wr_to_wc_opcode(wqe->wr.opcode);
wc->byte_len = wqe->dma.length;
wc->qp = &qp->ibqp;
} else {
struct ib_uverbs_wc *uwc = &cqe->uibwc;

uwc->wr_id = wqe->ibwr.wr_id;
uwc->wr_id = wqe->wr.wr_id;
uwc->status = wqe->status;
uwc->opcode = wr_to_wc_opcode(wqe->ibwr.opcode);
uwc->opcode = wr_to_wc_opcode(wqe->wr.opcode);
uwc->byte_len = wqe->dma.length;
uwc->qp_num = qp->ibqp.qp_num;
}
Expand All @@ -413,7 +413,7 @@ static void do_complete(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
struct rxe_cqe cqe;

if ((qp->sq_sig_type == IB_SIGNAL_ALL_WR) ||
(wqe->ibwr.send_flags & IB_SEND_SIGNALED) ||
(wqe->wr.send_flags & IB_SEND_SIGNALED) ||
(qp->req.state == QP_STATE_ERROR)) {
make_send_cqe(qp, wqe, &cqe);
rxe_cq_post(qp->scq, &cqe, 0);
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/hw/rxe/rxe_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ int copy_data(
u32 *crcp)
{
int bytes;
struct ib_sge *sge = &dma->sge[dma->cur_sge];
struct rxe_sge *sge = &dma->sge[dma->cur_sge];
int offset = dma->sge_offset;
int resid = dma->resid;
struct rxe_mem *mem = NULL;
Expand Down Expand Up @@ -640,7 +640,7 @@ int copy_data(

int advance_dma_data(struct rxe_dma_info *dma, unsigned int length)
{
struct ib_sge *sge = &dma->sge[dma->cur_sge];
struct rxe_sge *sge = &dma->sge[dma->cur_sge];
int offset = dma->sge_offset;
int resid = dma->resid;

Expand Down
20 changes: 10 additions & 10 deletions drivers/infiniband/hw/rxe/rxe_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ static inline void retry_first_write_send(struct rxe_qp *qp,
qp->mtu : wqe->dma.resid;

qp->req.opcode = next_opcode(qp, wqe,
wqe->ibwr.opcode);
wqe->wr.opcode);

if (wqe->ibwr.send_flags & IB_SEND_INLINE) {
if (wqe->wr.send_flags & IB_SEND_INLINE) {
wqe->dma.resid -= to_send;
wqe->dma.sge_offset += to_send;
} else {
Expand Down Expand Up @@ -83,7 +83,7 @@ static void req_retry(struct rxe_qp *qp)
wqe_index != producer_index(qp->sq.queue);
wqe_index = next_index(qp->sq.queue, wqe_index)) {
wqe = addr_from_index(qp->sq.queue, wqe_index);
mask = wr_opcode_mask(wqe->ibwr.opcode, qp);
mask = wr_opcode_mask(wqe->wr.opcode, qp);

if (wqe->state == wqe_state_posted)
break;
Expand All @@ -92,8 +92,8 @@ static void req_retry(struct rxe_qp *qp)
continue;

wqe->iova = (mask & WR_ATOMIC_MASK) ?
wqe->ibwr.wr.atomic.remote_addr :
wqe->ibwr.wr.rdma.remote_addr;
wqe->wr.wr.atomic.remote_addr :
wqe->wr.wr.rdma.remote_addr;

if (!first || (mask & WR_READ_MASK) == 0) {
wqe->dma.resid = wqe->dma.length;
Expand Down Expand Up @@ -174,13 +174,13 @@ static struct rxe_send_wqe *req_next_wqe(struct rxe_qp *qp)
(wqe->state != wqe_state_processing)))
return NULL;

if (unlikely((wqe->ibwr.send_flags & IB_SEND_FENCE) &&
if (unlikely((wqe->wr.send_flags & IB_SEND_FENCE) &&
(qp->req.wqe_index != consumer_index(qp->sq.queue)))) {
qp->req.wait_fence = 1;
return NULL;
}

wqe->mask = wr_opcode_mask(wqe->ibwr.opcode, qp);
wqe->mask = wr_opcode_mask(wqe->wr.opcode, qp);
return wqe;
}

Expand Down Expand Up @@ -378,7 +378,7 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp,
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
struct rxe_port *port = &rxe->port[qp->attr.port_num - 1];
struct sk_buff *skb;
struct ib_send_wr *ibwr = &wqe->ibwr;
struct rxe_send_wr *ibwr = &wqe->wr;
struct rxe_av *av;
int pad = (-payload) & 0x3;
int paylen;
Expand Down Expand Up @@ -485,7 +485,7 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
crc = rxe_icrc_hdr(pkt, skb);

if (pkt->mask & RXE_WRITE_OR_SEND) {
if (wqe->ibwr.send_flags & IB_SEND_INLINE) {
if (wqe->wr.send_flags & IB_SEND_INLINE) {
u8 *tmp = &wqe->dma.inline_data[wqe->dma.sge_offset];

crc = crc32_le(crc, tmp, payload);
Expand Down Expand Up @@ -600,7 +600,7 @@ int rxe_requester(void *arg)
goto exit;
}

opcode = next_opcode(qp, wqe, wqe->ibwr.opcode);
opcode = next_opcode(qp, wqe, wqe->wr.opcode);
if (unlikely(opcode < 0)) {
wqe->status = IB_WC_LOC_QP_OP_ERR;
/* TODO most be more to do here ?? */
Expand Down
52 changes: 51 additions & 1 deletion drivers/infiniband/hw/rxe/rxe_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,56 @@ static int validate_send_wr(struct rxe_qp *qp, struct ib_send_wr *ibwr,
return -EINVAL;
}

static void init_send_wr(struct rxe_qp *qp, struct rxe_send_wr *wr,
struct ib_send_wr *ibwr)
{
wr->wr_id = ibwr->wr_id;
wr->num_sge = ibwr->num_sge;
wr->opcode = ibwr->opcode;
wr->send_flags = ibwr->send_flags;

if (qp_type(qp) == IB_QPT_UD ||
qp_type(qp) == IB_QPT_SMI ||
qp_type(qp) == IB_QPT_GSI) {
wr->wr.ud.remote_qpn = ibwr->wr.ud.remote_qpn;
wr->wr.ud.pkey_index = ibwr->wr.ud.pkey_index;
wr->wr.ud.remote_qkey = ibwr->wr.ud.remote_qkey;
if (wr->opcode == IB_WR_SEND_WITH_IMM)
wr->ex.imm_data = ibwr->ex.imm_data;
} else {
switch (wr->opcode) {
case IB_WR_RDMA_WRITE_WITH_IMM:
wr->ex.imm_data = ibwr->ex.imm_data;
case IB_WR_RDMA_READ:
case IB_WR_RDMA_WRITE:
wr->wr.rdma.remote_addr =
ibwr->wr.rdma.remote_addr;
wr->wr.rdma.rkey =
ibwr->wr.rdma.rkey;
break;
case IB_WR_SEND_WITH_IMM:
wr->ex.imm_data =
ibwr->ex.imm_data;
break;
case IB_WR_SEND_WITH_INV:
wr->ex.invalidate_rkey =
ibwr->ex.invalidate_rkey;
break;
case IB_WR_ATOMIC_CMP_AND_SWP:
case IB_WR_ATOMIC_FETCH_AND_ADD:
wr->wr.atomic.remote_addr =
ibwr->wr.atomic.remote_addr;
wr->wr.atomic.compare_add =
ibwr->wr.atomic.compare_add;
wr->wr.atomic.swap = ibwr->wr.atomic.swap;
wr->wr.atomic.rkey = ibwr->wr.atomic.rkey;
break;
default:
break;
}
}
}

static int init_send_wqe(struct rxe_qp *qp, struct ib_send_wr *ibwr,
unsigned int mask, unsigned int length,
struct rxe_send_wqe *wqe)
Expand All @@ -594,7 +644,7 @@ static int init_send_wqe(struct rxe_qp *qp, struct ib_send_wr *ibwr,
int i;
u8 *p;

memcpy(&wqe->ibwr, ibwr, sizeof(wqe->ibwr));
init_send_wr(qp, &wqe->wr, ibwr);

if (qp_type(qp) == IB_QPT_UD ||
qp_type(qp) == IB_QPT_SMI ||
Expand Down
47 changes: 1 addition & 46 deletions drivers/infiniband/hw/rxe/rxe_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define RXE_VERBS_H

#include <linux/interrupt.h>
#include <rdma/ib_rxe.h>
#include "rxe_pool.h"
#include "rxe_task.h"

Expand Down Expand Up @@ -67,17 +68,6 @@ struct rxe_pd {
struct ib_pd ibpd;
};

struct rxe_av {
u8 port_num;
u8 network_type;
struct ib_global_route grh;
union {
struct sockaddr _sockaddr;
struct sockaddr_in _sockaddr_in;
struct sockaddr_in6 _sockaddr_in6;
} sgid_addr, dgid_addr;
};

struct rxe_ah {
struct rxe_pool_entry pelem;
struct ib_ah ibah;
Expand All @@ -103,18 +93,6 @@ struct rxe_cq {
struct tasklet_struct comp_task;
};

struct rxe_dma_info {
__u32 length;
__u32 resid;
__u32 cur_sge;
__u32 num_sge;
__u32 sge_offset;
union {
u8 inline_data[0];
struct ib_sge sge[0];
};
};

enum wqe_state {
wqe_state_posted,
wqe_state_processing,
Expand All @@ -123,29 +101,6 @@ enum wqe_state {
wqe_state_error,
};

/* must match corresponding data structure in librxe */
struct rxe_send_wqe {
struct ib_send_wr ibwr;
struct rxe_av av; /* UD only */
u32 status;
u32 state;
u64 iova;
u32 mask;
u32 first_psn;
u32 last_psn;
u32 ack_length;
u32 ssn;
u32 has_rd_atomic;
struct rxe_dma_info dma; /* must go last */
};

struct rxe_recv_wqe {
__u64 wr_id;
__u32 num_sge;
__u32 padding;
struct rxe_dma_info dma;
};

struct rxe_sq {
int max_wr;
int max_sge;
Expand Down
1 change: 1 addition & 0 deletions include/uapi/rdma/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ header-y += ib_user_sa.h
header-y += ib_user_verbs.h
header-y += rdma_netlink.h
header-y += rdma_user_cm.h
header-y += ib_rxe.h
Loading

0 comments on commit e1ed702

Please sign in to comment.