[openib-general] Update from merging in Roland's changes...
Roland Dreier
roland at topspin.com
Tue Aug 3 22:39:47 PDT 2004
This patch (committed to my branch) syncs back up with the changes to
the CQ and MR API. Next on my list is the AH API.
- R.
Index: src/linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- src/linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c (revision 545)
+++ src/linux-kernel/infiniband/ulp/ipoib/ipoib_verbs.c (working copy)
@@ -196,7 +196,6 @@
int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
{
struct ipoib_dev_priv *priv = dev->priv;
- int entries;
priv->pd = ib_alloc_pd(priv->ca);
if (IS_ERR(priv->pd)) {
@@ -205,15 +204,15 @@
return -ENODEV;
}
- entries = IPOIB_TX_RING_SIZE + IPOIB_RX_RING_SIZE + 1;
- priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, dev, &entries);
+ priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, dev,
+ IPOIB_TX_RING_SIZE + IPOIB_RX_RING_SIZE + 1);
if (IS_ERR(priv->cq)) {
TS_REPORT_FATAL(MOD_IB_NET, "%s: failed to create CQ",
dev->name);
goto out_free_pd;
}
TS_TRACE(MOD_IB_NET, T_VERBOSE, TRACE_IB_NET_GEN,
- "%s: CQ with %d entries", dev->name, entries);
+ "%s: CQ with %d entries", dev->name, priv->cq->cqe);
if (ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP))
goto out_free_cq;
@@ -225,19 +224,19 @@
.size = (unsigned long) high_memory - PAGE_OFFSET
};
uint64_t dummy_iova = 0;
- u32 rkey;
priv->mr = ib_reg_phys_mr(priv->pd, &buffer_list,
1, /* list_len */
IB_MR_LOCAL_WRITE,
- &dummy_iova,
- &priv->lkey, &rkey);
+ &dummy_iova);
if (IS_ERR(priv->mr)) {
TS_REPORT_FATAL(MOD_IB_NET,
"%s: ib_memory_register_physical failed",
dev->name);
goto out_free_cq;
}
+
+ priv->lkey = priv->mr->lkey;
}
return 0;
Index: src/linux-kernel/infiniband/ulp/srp/srp_host.c
===================================================================
--- src/linux-kernel/infiniband/ulp/srp/srp_host.c (revision 545)
+++ src/linux-kernel/infiniband/ulp/srp/srp_host.c (working copy)
@@ -529,8 +529,6 @@
int pkt_num;
int max_num_pkts;
srp_host_hca_params_t *hca;
- int cq_entries;
- int requested_cq_entries;
int hca_index;
/* allocate twice as many packets, send and receive */
@@ -563,22 +561,19 @@
if (hca->valid == FALSE)
break;
- cq_entries = MAX_SEND_WQES;
- requested_cq_entries = cq_entries;
-
target->cqs_hndl[hca_index] = ib_create_cq(hca->ca_hndl,
- cq_send_event,
- target,
- &cq_entries);
+ cq_send_event,
+ target,
+ MAX_SEND_WQES);
if (IS_ERR(target->cqs_hndl[hca_index]) ||
- cq_entries < requested_cq_entries) {
+ target->cqs_hndl[hca_index]->cqe < MAX_SEND_WQES) {
TS_REPORT_FATAL(MOD_SRPTP,
"Send completion queue "
"creation failed: %d asked "
"for %d entries",
- cq_entries,
- requested_cq_entries);
+ target->cqs_hndl[hca_index]->cqe,
+ MAX_SEND_WQES);
target->cqs_hndl[hca_index] = NULL;
goto CQ_MR_FAIL;
}
@@ -586,16 +581,13 @@
if (ib_req_notify_cq(target->cqs_hndl[hca_index], IB_CQ_NEXT_COMP))
goto CQ_MR_FAIL;
- cq_entries = MAX_RECV_WQES;
- requested_cq_entries = cq_entries;
-
target->cqr_hndl[hca_index] = ib_create_cq(hca->ca_hndl,
cq_recv_event,
target,
- &cq_entries);
+ MAX_RECV_WQES);
if (IS_ERR(target->cqs_hndl[hca_index]) ||
- cq_entries < requested_cq_entries) {
+ target->cqr_hndl[hca_index]->cqe < MAX_RECV_WQES) {
TS_REPORT_FATAL(MOD_SRPTP,
"Recv completeion queue "
"creation failed");
@@ -616,9 +608,7 @@
1, /*list_len */
IB_MR_LOCAL_WRITE |
IB_MR_REMOTE_READ,
- &iova,
- &target->l_key[hca_index],
- &target->r_key[hca_index]);
+ &iova);
if (IS_ERR(target->srp_pkt_data_mhndl[hca_index])) {
TS_REPORT_FATAL(MOD_SRPTP,
@@ -627,6 +617,9 @@
target->srp_pkt_data_mhndl[hca_index] = NULL;
goto CQ_MR_FAIL;
}
+
+ target->l_key[hca_index] = target->srp_pkt_data_mhndl[hca_index]->lkey;
+ target->r_key[hca_index] = target->srp_pkt_data_mhndl[hca_index]->rkey;
}
srp_pkt = target->srp_pkt_hdr_area;
Index: src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c (revision 545)
+++ src/linux-kernel/infiniband/ulp/sdp/sdp_conn.c (working copy)
@@ -1064,7 +1064,7 @@
conn->send_cq = ib_create_cq(conn->ca,
sdp_cq_event_handler,
(void *)(unsigned long)conn->hashent,
- &conn->send_cq_size);
+ conn->send_cq_size);
if (IS_ERR(conn->send_cq)) {
TS_TRACE(MOD_LNX_SDP, T_TERSE, TRACE_FLOW_FATAL,
@@ -1074,6 +1074,8 @@
goto error_scq;
}
+ conn->send_cq_size = conn->send_cq->cqe;
+
result = ib_req_notify_cq(conn->send_cq, IB_CQ_NEXT_COMP);
if (0 > result) {
@@ -1088,7 +1090,7 @@
conn->recv_cq = ib_create_cq(conn->ca,
sdp_cq_event_handler,
(void *)(unsigned long)conn->hashent,
- &conn->recv_cq_size);
+ conn->recv_cq_size);
if (IS_ERR(conn->recv_cq)) {
@@ -1099,6 +1101,8 @@
goto error_rcq;
}
+ conn->recv_cq_size = conn->recv_cq->cqe;
+
result = ib_req_notify_cq(conn->recv_cq, IB_CQ_NEXT_COMP);
if (0 > result) {
@@ -1980,8 +1984,7 @@
&buffer_list,
1, /* list_len */
IB_ACCESS_LOCAL_WRITE,
- &hca->iova,
- &hca->l_key, &hca->r_key);
+ &hca->iova);
if (IS_ERR(hca->mem_h)) {
result = PTR_ERR(hca->mem_h);
TS_TRACE(MOD_LNX_SDP, T_TERSE, TRACE_FLOW_FATAL,
@@ -1989,6 +1992,10 @@
result, hca_handle, hca_count);
goto error;
}
+
+ hca->l_key = hca->mem_h->lkey;
+ hca->r_key = hca->mem_h->rkey;
+
#ifdef _TS_SDP_AIO_SUPPORT
/*
* FMR allocation
Index: src/linux-kernel/infiniband/include/ib_verbs.h
===================================================================
--- src/linux-kernel/infiniband/include/ib_verbs.h (revision 545)
+++ src/linux-kernel/infiniband/include/ib_verbs.h (working copy)
@@ -145,6 +145,8 @@
struct ib_mr {
struct ib_device *device;
struct ib_pd *pd;
+ u32 lkey;
+ u32 rkey;
atomic_t usecnt; /* count number of MWs */
};
@@ -195,9 +197,7 @@
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey);
+ u64 *iova_start);
int (*query_mr)(struct ib_mr *mr,
struct ib_mr_attr *mr_attr);
int (*dereg_mr)(struct ib_mr *mr);
@@ -207,9 +207,7 @@
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey);
+ u64 *iova_start);
ib_mw_create_func mw_create;
ib_mw_destroy_func mw_destroy;
ib_mw_bind_func mw_bind;
@@ -229,9 +227,9 @@
struct ib_cq *ib_create_cq(struct ib_device *device,
ib_comp_handler comp_handler,
- void *cq_context, int *cqe);
+ void *cq_context, int cqe);
-int ib_resize_cq(struct ib_cq *cq, int *cqe);
+int ib_resize_cq(struct ib_cq *cq, int cqe);
int ib_destroy_cq(struct ib_cq *cq);
/**
@@ -272,9 +270,7 @@
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey);
+ u64 *iova_start);
int ib_rereg_phys_mr(struct ib_mr *mr,
int mr_rereg_mask,
@@ -282,9 +278,7 @@
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey);
+ u64 *iova_start);
int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
int ib_dereg_mr(struct ib_mr *mr);
Index: src/linux-kernel/infiniband/core/core_cq.c
===================================================================
--- src/linux-kernel/infiniband/core/core_cq.c (revision 545)
+++ src/linux-kernel/infiniband/core/core_cq.c (working copy)
@@ -30,17 +30,17 @@
struct ib_cq *ib_create_cq(struct ib_device *device,
ib_comp_handler comp_handler,
- void *cq_context, int *cqe)
+ void *cq_context, int cqe)
{
struct ib_cq *cq;
- cq = device->create_cq(device, cqe);
+ cq = device->create_cq(device, &cqe);
if (!IS_ERR(cq)) {
cq->device = device;
cq->comp_handler = comp_handler;
cq->context = cq_context;
- cq->cqe = *cqe;
+ cq->cqe = cqe;
atomic_set(&cq->usecnt, 0);
}
@@ -57,10 +57,19 @@
}
EXPORT_SYMBOL(ib_destroy_cq);
-int ib_resize_cq(struct ib_cq *cq,
- int *cqe)
+int ib_resize_cq(struct ib_cq *cq,
+ int cqe)
{
- return cq->device->resize_cq ? cq->device->resize_cq(cq, cqe) : -ENOSYS;
+ int ret;
+
+ if (!cq->device->resize_cq)
+ return -ENOSYS;
+
+ ret = cq->device->resize_cq(cq, &cqe);
+ if (!ret)
+ cq->cqe = cqe;
+
+ return ret;
}
EXPORT_SYMBOL(ib_resize_cq);
Index: src/linux-kernel/infiniband/core/core_mr.c
===================================================================
--- src/linux-kernel/infiniband/core/core_mr.c (revision 545)
+++ src/linux-kernel/infiniband/core/core_mr.c (working copy)
@@ -32,14 +32,12 @@
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey)
+ u64 *iova_start)
{
struct ib_mr *mr;
mr = pd->device->reg_phys_mr(pd, phys_buf_array, num_phys_buf,
- mr_access_flags, iova_start, lkey, rkey);
+ mr_access_flags, iova_start);
if (!IS_ERR(mr)) {
mr->device = pd->device;
@@ -58,15 +56,12 @@
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey)
+ u64 *iova_start)
{
return mr->device->rereg_phys_mr ?
mr->device->rereg_phys_mr(mr, mr_rereg_mask, pd,
phys_buf_array, num_phys_buf,
- mr_access_flags, iova_start,
- lkey, rkey) :
+ mr_access_flags, iova_start) :
-ENOSYS;
}
EXPORT_SYMBOL(ib_rereg_phys_mr);
Index: src/linux-kernel/infiniband/core/mad_main.c
===================================================================
--- src/linux-kernel/infiniband/core/mad_main.c (revision 545)
+++ src/linux-kernel/infiniband/core/mad_main.c (working copy)
@@ -51,25 +51,25 @@
struct ib_mr **mr,
u32 *lkey)
{
- u32 rkey;
u64 iova = 0;
struct ib_phys_buf buffer_list = {
.addr = 0,
.size = (unsigned long) high_memory - PAGE_OFFSET
};
- *mr = ib_reg_phys_mr(pd, &buffer_list,
- 1, /* list_len */
- IB_MR_LOCAL_WRITE,
- &iova, lkey, &rkey);
- if (IS_ERR(*mr))
+ *mr = ib_reg_phys_mr(pd, &buffer_list, 1, /* list_len */
+ IB_MR_LOCAL_WRITE, &iova);
+ if (IS_ERR(*mr)) {
TS_REPORT_WARN(MOD_KERNEL_IB,
"ib_reg_phys_mr failed "
"size 0x%016" TS_U64_FMT "x, iova 0x%016" TS_U64_FMT "x"
" (return code %d)",
buffer_list.size, iova, PTR_ERR(*mr));
+ return PTR_ERR(*mr);
+ }
- return IS_ERR(*mr) ? PTR_ERR(*mr) : 0;
+ *lkey = (*mr)->lkey;
+ return 0;
}
static int ib_mad_qp_create(struct ib_device *device,
@@ -200,7 +200,7 @@
(IB_MAD_RECEIVES_PER_QP + IB_MAD_SENDS_PER_QP) * priv->num_port;
priv->cq = ib_create_cq(device, ib_mad_completion,
- device, &entries);
+ device, entries);
if (IS_ERR(priv->cq)) {
TS_REPORT_FATAL(MOD_KERNEL_IB,
"Failed to allocate CQ for %s",
Index: src/linux-kernel/infiniband/hw/mthca/mthca_provider.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_provider.c (revision 545)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_provider.c (working copy)
@@ -419,9 +419,7 @@
struct ib_phys_buf *buffer_list,
int num_phys_buf,
int acc,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey)
+ u64 *iova_start)
{
struct mthca_mr *mr;
u64 *page_list;
@@ -520,8 +518,6 @@
goto out;
}
- *lkey = *rkey = mr->key;
-
out:
kfree(page_list);
return (struct ib_mr *) mr;
Index: src/linux-kernel/infiniband/hw/mthca/mthca_provider.h
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_provider.h (revision 545)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_provider.h (working copy)
@@ -40,7 +40,6 @@
struct mthca_mr {
struct ib_mr ibmr;
- u32 key;
int order;
u32 first_seg;
};
Index: src/linux-kernel/infiniband/hw/mthca/mthca_cq.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_cq.c (revision 545)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_cq.c (working copy)
@@ -657,7 +657,7 @@
cq_context->error_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn);
cq_context->comp_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_COMP].eqn);
cq_context->pd = cpu_to_be32(dev->driver_pd.pd_num);
- cq_context->lkey = cpu_to_be32(cq->mr.key);
+ cq_context->lkey = cpu_to_be32(cq->mr.ibmr.lkey);
cq_context->cqn = cpu_to_be32(cq->cqn);
err = mthca_SW2HW_CQ(dev, cq_context, cq->cqn, &status);
Index: src/linux-kernel/infiniband/hw/mthca/mthca_eq.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_eq.c (revision 545)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_eq.c (working copy)
@@ -408,7 +408,7 @@
MTHCA_KAR_PAGE);
eq_context->pd = cpu_to_be32(dev->driver_pd.pd_num);
eq_context->intr = intr;
- eq_context->lkey = cpu_to_be32(eq->mr.key);
+ eq_context->lkey = cpu_to_be32(eq->mr.ibmr.lkey);
err = mthca_SW2HW_EQ(dev, eq_context, eq->eqn, &status);
if (err) {
Index: src/linux-kernel/infiniband/hw/mthca/mthca_av.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_av.c (revision 521)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_av.c (working copy)
@@ -77,7 +77,7 @@
av = ah->av;
}
- ah->key = pd->ntmr.key;
+ ah->key = pd->ntmr.ibmr.lkey;
memset(av, 0, MTHCA_AV_SIZE);
Index: src/linux-kernel/infiniband/hw/mthca/mthca_mr.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_mr.c (revision 545)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_mr.c (working copy)
@@ -118,14 +118,15 @@
might_sleep();
mr->order = -1;
- mr->key = mthca_alloc(&dev->mr_table.mpt_alloc);
- if (mr->key == -1)
+ mr->ibmr.lkey = mthca_alloc(&dev->mr_table.mpt_alloc);
+ if (mr->ibmr.lkey == -1)
return -ENOMEM;
+ mr->ibmr.rkey = mr->ibmr.lkey;
mailbox = kmalloc(sizeof *mpt_entry + MTHCA_CMD_MAILBOX_EXTRA,
GFP_KERNEL);
if (!mailbox) {
- mthca_free(&dev->mr_table.mpt_alloc, mr->key);
+ mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey);
return -ENOMEM;
}
mpt_entry = MAILBOX_ALIGN(mailbox);
@@ -137,7 +138,7 @@
MTHCA_MPT_FLAG_PHYSICAL |
MTHCA_MPT_FLAG_REGION);
mpt_entry->page_size = 0;
- mpt_entry->key = cpu_to_be32(mr->key);
+ mpt_entry->key = cpu_to_be32(mr->ibmr.lkey);
mpt_entry->pd = cpu_to_be32(pd);
mpt_entry->start = 0;
mpt_entry->length = ~0ULL;
@@ -146,7 +147,7 @@
sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));
err = mthca_SW2HW_MPT(dev, mpt_entry,
- mr->key & (dev->limits.num_mpts - 1),
+ mr->ibmr.lkey & (dev->limits.num_mpts - 1),
&status);
if (status) {
mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",
@@ -173,9 +174,10 @@
might_sleep();
WARN_ON(buffer_size_shift >= 32);
- mr->key = mthca_alloc(&dev->mr_table.mpt_alloc);
- if (mr->key == -1)
+ mr->ibmr.lkey = mthca_alloc(&dev->mr_table.mpt_alloc);
+ if (mr->ibmr.lkey == -1)
return -ENOMEM;
+ mr->ibmr.rkey = mr->ibmr.lkey;
for (i = dev->limits.mtt_seg_size / 8, mr->order = 0;
i < list_len;
@@ -233,7 +235,7 @@
access);
mpt_entry->page_size = cpu_to_be32(buffer_size_shift - 12);
- mpt_entry->key = cpu_to_be32(mr->key);
+ mpt_entry->key = cpu_to_be32(mr->ibmr.lkey);
mpt_entry->pd = cpu_to_be32(pd);
mpt_entry->start = cpu_to_be64(iova);
mpt_entry->length = cpu_to_be64(total_size);
@@ -243,7 +245,7 @@
mr->first_seg * dev->limits.mtt_seg_size);
if (0) {
- mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->key);
+ mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
if (i % 4 == 0)
printk("[%02x] ", i * 4);
@@ -254,7 +256,7 @@
}
err = mthca_SW2HW_MPT(dev, mpt_entry,
- mr->key & (dev->limits.num_mpts - 1),
+ mr->ibmr.lkey & (dev->limits.num_mpts - 1),
&status);
if (status) {
mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",
@@ -272,7 +274,7 @@
mthca_free_mtt(dev, mr->first_seg, mr->order);
err_out_mpt_free:
- mthca_free(&dev->mr_table.mpt_alloc, mr->key);
+ mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey);
return err;
}
@@ -284,7 +286,7 @@
might_sleep();
err = mthca_HW2SW_MPT(dev, NULL,
- mr->key & (dev->limits.num_mpts - 1),
+ mr->ibmr.lkey & (dev->limits.num_mpts - 1),
&status);
if (err)
mthca_warn(dev, "HW2SW_MPT failed (%d)\n", err);
@@ -295,7 +297,7 @@
if (mr->order >= 0)
mthca_free_mtt(dev, mr->first_seg, mr->order);
- mthca_free(&dev->mr_table.mpt_alloc, mr->key);
+ mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey);
}
int __devinit mthca_init_mr_table(struct mthca_dev *dev)
Index: src/linux-kernel/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- src/linux-kernel/infiniband/hw/mthca/mthca_qp.c (revision 545)
+++ src/linux-kernel/infiniband/hw/mthca/mthca_qp.c (working copy)
@@ -631,7 +631,7 @@
/* leave rdd as 0 */
qp_context->pd = cpu_to_be32(qp->pd->pd_num);
/* leave wqe_base as 0 (we always create an MR based at 0 for WQs) */
- qp_context->wqe_lkey = cpu_to_be32(qp->mr.key);
+ qp_context->wqe_lkey = cpu_to_be32(qp->mr.ibmr.lkey);
qp_context->params1 = cpu_to_be32((MTHCA_ACK_REQ_FREQ << 28) |
(MTHCA_FLIGHT_LIMIT << 24) |
MTHCA_QP_BIT_SRE |
@@ -1086,7 +1086,7 @@
ind * MTHCA_UD_HEADER_SIZE);
data->byte_count = cpu_to_be32(header_size);
- data->lkey = cpu_to_be32(sqp->qp.pd->ntmr.key);
+ data->lkey = cpu_to_be32(sqp->qp.pd->ntmr.ibmr.lkey);
data->addr = cpu_to_be64(sqp->header_dma +
ind * MTHCA_UD_HEADER_SIZE);
More information about the general
mailing list