From: Roland Dreier <roland@topspin.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH][19/26] IB/mthca: mem-free CQ operations
Date: Thu, 3 Mar 2005 15:20:28 -0800 [thread overview]
Message-ID: <2005331520.VEavoMG964z0bUT1@topspin.com> (raw)
In-Reply-To: <2005331520.xvxJqi7Nfv5UdZpQ@topspin.com>
Add support for CQ data path operations (request notification, update
consumer index) in mem-free mode.
Signed-off-by: Roland Dreier <roland@topspin.com>
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_cq.c 2005-03-03 14:13:00.312829664 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_cq.c 2005-03-03 14:13:01.214633912 -0800
@@ -136,11 +136,15 @@
#define MTHCA_CQ_ENTRY_OWNER_SW (0 << 7)
#define MTHCA_CQ_ENTRY_OWNER_HW (1 << 7)
-#define MTHCA_CQ_DB_INC_CI (1 << 24)
-#define MTHCA_CQ_DB_REQ_NOT (2 << 24)
-#define MTHCA_CQ_DB_REQ_NOT_SOL (3 << 24)
-#define MTHCA_CQ_DB_SET_CI (4 << 24)
-#define MTHCA_CQ_DB_REQ_NOT_MULT (5 << 24)
+#define MTHCA_TAVOR_CQ_DB_INC_CI (1 << 24)
+#define MTHCA_TAVOR_CQ_DB_REQ_NOT (2 << 24)
+#define MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL (3 << 24)
+#define MTHCA_TAVOR_CQ_DB_SET_CI (4 << 24)
+#define MTHCA_TAVOR_CQ_DB_REQ_NOT_MULT (5 << 24)
+
+#define MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL (1 << 24)
+#define MTHCA_ARBEL_CQ_DB_REQ_NOT (2 << 24)
+#define MTHCA_ARBEL_CQ_DB_REQ_NOT_MULT (3 << 24)
static inline struct mthca_cqe *get_cqe(struct mthca_cq *cq, int entry)
{
@@ -159,7 +163,7 @@
static inline struct mthca_cqe *next_cqe_sw(struct mthca_cq *cq)
{
- return cqe_sw(cq, cq->cons_index);
+ return cqe_sw(cq, cq->cons_index & cq->ibcq.cqe);
}
static inline void set_cqe_hw(struct mthca_cqe *cqe)
@@ -167,17 +171,26 @@
cqe->owner = MTHCA_CQ_ENTRY_OWNER_HW;
}
-static inline void inc_cons_index(struct mthca_dev *dev, struct mthca_cq *cq,
- int nent)
+/*
+ * incr is ignored in native Arbel (mem-free) mode, so cq->cons_index
+ * should be correct before calling update_cons_index().
+ */
+static inline void update_cons_index(struct mthca_dev *dev, struct mthca_cq *cq,
+ int incr)
{
u32 doorbell[2];
- doorbell[0] = cpu_to_be32(MTHCA_CQ_DB_INC_CI | cq->cqn);
- doorbell[1] = cpu_to_be32(nent - 1);
+ if (dev->hca_type == ARBEL_NATIVE) {
+ *cq->set_ci_db = cpu_to_be32(cq->cons_index);
+ wmb();
+ } else {
+ doorbell[0] = cpu_to_be32(MTHCA_TAVOR_CQ_DB_INC_CI | cq->cqn);
+ doorbell[1] = cpu_to_be32(incr - 1);
- mthca_write64(doorbell,
- dev->kar + MTHCA_CQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ mthca_write64(doorbell,
+ dev->kar + MTHCA_CQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ }
}
void mthca_cq_event(struct mthca_dev *dev, u32 cqn)
@@ -191,6 +204,8 @@
return;
}
+ ++cq->arm_sn;
+
cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
}
@@ -247,8 +262,8 @@
if (nfreed) {
wmb();
- inc_cons_index(dev, cq, nfreed);
- cq->cons_index = (cq->cons_index + nfreed) & cq->ibcq.cqe;
+ cq->cons_index += nfreed;
+ update_cons_index(dev, cq, nfreed);
}
spin_unlock_irq(&cq->lock);
@@ -341,7 +356,7 @@
break;
}
- err = mthca_free_err_wqe(qp, is_send, wqe_index, &dbd, &new_wqe);
+ err = mthca_free_err_wqe(dev, qp, is_send, wqe_index, &dbd, &new_wqe);
if (err)
return err;
@@ -411,7 +426,7 @@
if (*cur_qp) {
if (*freed) {
wmb();
- inc_cons_index(dev, cq, *freed);
+ update_cons_index(dev, cq, *freed);
*freed = 0;
}
spin_unlock(&(*cur_qp)->lock);
@@ -505,7 +520,7 @@
if (likely(free_cqe)) {
set_cqe_hw(cqe);
++(*freed);
- cq->cons_index = (cq->cons_index + 1) & cq->ibcq.cqe;
+ ++cq->cons_index;
}
return err;
@@ -533,7 +548,7 @@
if (freed) {
wmb();
- inc_cons_index(dev, cq, freed);
+ update_cons_index(dev, cq, freed);
}
if (qp)
@@ -544,20 +559,57 @@
return err == 0 || err == -EAGAIN ? npolled : err;
}
-void mthca_arm_cq(struct mthca_dev *dev, struct mthca_cq *cq,
- int solicited)
+int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify)
{
u32 doorbell[2];
- doorbell[0] = cpu_to_be32((solicited ?
- MTHCA_CQ_DB_REQ_NOT_SOL :
- MTHCA_CQ_DB_REQ_NOT) |
- cq->cqn);
+ doorbell[0] = cpu_to_be32((notify == IB_CQ_SOLICITED ?
+ MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL :
+ MTHCA_TAVOR_CQ_DB_REQ_NOT) |
+ to_mcq(cq)->cqn);
doorbell[1] = 0xffffffff;
mthca_write64(doorbell,
- dev->kar + MTHCA_CQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ to_mdev(cq->device)->kar + MTHCA_CQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&to_mdev(cq->device)->doorbell_lock));
+
+ return 0;
+}
+
+int mthca_arbel_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
+{
+ struct mthca_cq *cq = to_mcq(ibcq);
+ u32 doorbell[2];
+ u32 sn;
+ u32 ci;
+
+ sn = cq->arm_sn & 3;
+ ci = cpu_to_be32(cq->cons_index);
+
+ doorbell[0] = ci;
+ doorbell[1] = cpu_to_be32((cq->cqn << 8) | (2 << 5) | (sn << 3) |
+ (notify == IB_CQ_SOLICITED ? 1 : 2));
+
+ mthca_write_db_rec(doorbell, cq->arm_db);
+
+ /*
+ * Make sure that the doorbell record in host memory is
+ * written before ringing the doorbell via PCI MMIO.
+ */
+ wmb();
+
+ doorbell[0] = cpu_to_be32((sn << 28) |
+ (notify == IB_CQ_SOLICITED ?
+ MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL :
+ MTHCA_ARBEL_CQ_DB_REQ_NOT) |
+ cq->cqn);
+ doorbell[1] = ci;
+
+ mthca_write64(doorbell,
+ to_mdev(ibcq->device)->kar + MTHCA_CQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&to_mdev(ibcq->device)->doorbell_lock));
+
+ return 0;
}
static void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq *cq)
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_dev.h 2005-03-03 14:12:59.077097900 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_dev.h 2005-03-03 14:13:01.213634129 -0800
@@ -368,8 +368,8 @@
int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
struct ib_wc *entry);
-void mthca_arm_cq(struct mthca_dev *dev, struct mthca_cq *cq,
- int solicited);
+int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify);
+int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify);
int mthca_init_cq(struct mthca_dev *dev, int nent,
struct mthca_cq *cq);
void mthca_free_cq(struct mthca_dev *dev,
@@ -384,7 +384,7 @@
struct ib_send_wr **bad_wr);
int mthca_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr);
-int mthca_free_err_wqe(struct mthca_qp *qp, int is_send,
+int mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
int index, int *dbd, u32 *new_wqe);
int mthca_alloc_qp(struct mthca_dev *dev,
struct mthca_pd *pd,
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_provider.c 2005-03-03 14:12:59.925913650 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_provider.c 2005-03-03 14:13:01.213634129 -0800
@@ -421,13 +421,6 @@
return 0;
}
-static int mthca_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify notify)
-{
- mthca_arm_cq(to_mdev(cq->device), to_mcq(cq),
- notify == IB_CQ_SOLICITED);
- return 0;
-}
-
static inline u32 convert_access(int acc)
{
return (acc & IB_ACCESS_REMOTE_ATOMIC ? MTHCA_MPT_FLAG_ATOMIC : 0) |
@@ -625,7 +618,6 @@
dev->ib_dev.create_cq = mthca_create_cq;
dev->ib_dev.destroy_cq = mthca_destroy_cq;
dev->ib_dev.poll_cq = mthca_poll_cq;
- dev->ib_dev.req_notify_cq = mthca_req_notify_cq;
dev->ib_dev.get_dma_mr = mthca_get_dma_mr;
dev->ib_dev.reg_phys_mr = mthca_reg_phys_mr;
dev->ib_dev.dereg_mr = mthca_dereg_mr;
@@ -633,6 +625,11 @@
dev->ib_dev.detach_mcast = mthca_multicast_detach;
dev->ib_dev.process_mad = mthca_process_mad;
+ if (dev->hca_type == ARBEL_NATIVE)
+ dev->ib_dev.req_notify_cq = mthca_arbel_arm_cq;
+ else
+ dev->ib_dev.req_notify_cq = mthca_tavor_arm_cq;
+
init_MUTEX(&dev->cap_mask_mutex);
ret = ib_register_device(&dev->ib_dev);
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_provider.h 2005-03-03 14:13:00.312829664 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_provider.h 2005-03-03 14:13:01.213634129 -0800
@@ -141,7 +141,7 @@
spinlock_t lock;
atomic_t refcount;
int cqn;
- int cons_index;
+ u32 cons_index;
int is_direct;
/* Next fields are Arbel only */
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_qp.c 2005-03-03 14:12:56.155732030 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_qp.c 2005-03-03 14:13:01.215633695 -0800
@@ -1551,7 +1551,7 @@
return err;
}
-int mthca_free_err_wqe(struct mthca_qp *qp, int is_send,
+int mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
int index, int *dbd, u32 *new_wqe)
{
struct mthca_next_seg *next;
@@ -1561,7 +1561,10 @@
else
next = get_recv_wqe(qp, index);
- *dbd = !!(next->ee_nds & cpu_to_be32(MTHCA_NEXT_DBD));
+ if (dev->hca_type == ARBEL_NATIVE)
+ *dbd = 1;
+ else
+ *dbd = !!(next->ee_nds & cpu_to_be32(MTHCA_NEXT_DBD));
if (next->ee_nds & cpu_to_be32(0x3f))
*new_wqe = (next->nda_op & cpu_to_be32(~0x3f)) |
(next->ee_nds & cpu_to_be32(0x3f));
next prev parent reply other threads:[~2005-03-03 23:45 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-03 23:20 [PATCH][0/26] InfiniBand merge Roland Dreier
2005-03-03 23:20 ` [PATCH][1/26] IB: fix ib_find_cached_gid() port numbering Roland Dreier
2005-03-03 23:20 ` [PATCH][2/26] IB/mthca: CQ minor tweaks Roland Dreier
2005-03-03 23:20 ` [PATCH][3/26] IB/mthca: improve CQ locking part 1 Roland Dreier
2005-03-03 23:20 ` [PATCH][4/26] IB/mthca: improve CQ locking part 2 Roland Dreier
2005-03-03 23:20 ` [PATCH][5/26] IB/mthca: CQ cleanups Roland Dreier
2005-03-03 23:20 ` [PATCH][6/26] IB: remove unsignaled receives Roland Dreier
2005-03-03 23:20 ` [PATCH][7/26] IB/mthca: map registers for mem-free mode Roland Dreier
2005-03-03 23:20 ` [PATCH][8/26] IB/mthca: add UAR allocation Roland Dreier
2005-03-03 23:20 ` [PATCH][9/26] IB/mthca: dynamic context memory mapping for mem-free mode Roland Dreier
2005-03-03 23:20 ` [PATCH][10/26] IB/mthca: mem-free memory region support Roland Dreier
2005-03-03 23:20 ` [PATCH][11/26] IB/mthca: mem-free EQ initialization Roland Dreier
2005-03-03 23:20 ` [PATCH][12/26] IB/mthca: mem-free interrupt handling Roland Dreier
2005-03-03 23:20 ` [PATCH][13/26] IB/mthca: tweak firmware command debug messages Roland Dreier
2005-03-03 23:20 ` [PATCH][14/26] IB/mthca: tweak MAP_ICM_page firmware command Roland Dreier
2005-03-03 23:20 ` [PATCH][15/26] IB/mthca: mem-free doorbell record allocation Roland Dreier
2005-03-03 23:20 ` [PATCH][16/26] IB/mthca: mem-free doorbell record writing Roland Dreier
2005-03-03 23:20 ` [PATCH][17/26] IB/mthca: refactor CQ buffer allocate/free Roland Dreier
2005-03-03 23:20 ` [PATCH][18/26] IB/mthca: mem-free CQ initialization Roland Dreier
2005-03-03 23:20 ` Roland Dreier [this message]
2005-03-03 23:20 ` [PATCH][20/26] IB/mthca: mem-free QP initialization Roland Dreier
2005-03-03 23:20 ` [PATCH][21/26] IB/mthca: mem-free address vectors Roland Dreier
2005-03-03 23:20 ` [PATCH][22/26] IB/mthca: mem-free work request posting Roland Dreier
2005-03-03 23:20 ` [PATCH][23/26] IB/mthca: mem-free multicast table Roland Dreier
2005-03-03 23:20 ` [PATCH][24/26] IB/mthca: QP locking optimization Roland Dreier
2005-03-03 23:20 ` [PATCH][25/26] IB/mthca: implement query of device caps Roland Dreier
2005-03-03 23:20 ` [PATCH][26/26] IB: MAD cancel callbacks from thread Roland Dreier
2005-03-04 0:07 ` Jeff Garzik
2005-03-04 0:30 ` Roland Dreier
2005-03-04 0:34 ` [openib-general] Re: [PATCH][26/26] IB: MAD cancel callbacks fromthread Sean Hefty
2005-03-04 0:43 ` Roland Dreier
2005-03-04 1:01 ` Andrew Morton
2005-03-04 1:07 ` Andrew Morton
2005-03-04 1:22 ` Andrew Morton
2006-03-13 15:43 ` [PATCH 5/6 v2] IB: IP address based RDMA connection manager Roland Dreier
2006-03-13 17:11 ` Sean Hefty
2006-03-13 17:26 ` Roland Dreier
2005-03-04 0:04 ` [PATCH][16/26] IB/mthca: mem-free doorbell record writing Jeff Garzik
2005-03-04 0:33 ` Roland Dreier
2005-03-04 0:41 ` Jeff Garzik
2005-03-04 0:50 ` Roland Dreier
2005-03-04 0:35 ` [PATCH][3/26] IB/mthca: improve CQ locking part 1 Jeff Garzik
2005-03-04 0:40 ` Roland Dreier
2005-03-04 0:58 ` Greg KH
2005-03-04 1:02 ` Roland Dreier
2005-03-04 16:33 ` Greg KH
2005-03-04 16:43 ` Roland Dreier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2005331520.VEavoMG964z0bUT1@topspin.com \
--to=roland@topspin.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®