-%define ver @VERSION@
-
Name: libocrdma
-Version: 0.0.1
+Version: @VERSION@
Release: 1%{?dist}
-Summary: Emulex OneConnect SLI4 Compliant RDMA Open Fabrics Userspace Library
-
+Summary: Userspace Library for Emulex ROCEE Device.
Group: System Environment/Libraries
License: GPL/BSD
Url: http://www.openfabrics.org/
-Source: http://www.openfabrics.org/downloads/ocrdma/%{name}-%{ver}.tar.gz
+Source: http://www.openfabrics.org/downloads/ocrdma/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libibverbs-devel
%description
-libocrdma provides a device-specific userspace driver for Emulex OneConnect RDMAAdapters for use with the libibverbs library.
+libocrdma provides a device-specific userspace driver for Emulex One Command RoCE Adapters
+for use with the libibverbs library.
%package devel
Summary: Development files for the libocrdma driver
application, which may be useful for debugging.
%prep
-%setup -q -n %{name}-%{ver}
+%setup -q -n %{name}-%{version}
%build
%configure
# remove unpackaged files from the buildroot
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
+%post
+/sbin/ldconfig
+if [ -e %{_sysconfdir}/dat.conf ]; then
+ sed -e '/ofa-v2-scm-roe-ocrdma.* u2/d' < %{_sysconfdir}/dat.conf > /tmp/$$ofadapl
+ mv /tmp/$$ofadapl %{_sysconfdir}/dat.conf
+ dapl_ver=`rpm -q dapl|cut -c6-8`
+ echo ofa-v2-scm-roe-ocrdma0-1 u${dapl_ver} nonthreadsafe default libdaploscm.so.2 dapl.${dapl_ver} '"ocrdma0 1" ""' >> %{_sysconfdir}/dat.conf
+ echo ofa-v2-scm-roe-ocrdma1-1 u${dapl_ver} nonthreadsafe default libdaploscm.so.2 dapl.${dapl_ver} '"ocrdma1 1" ""' >> %{_sysconfdir}/dat.conf
+ echo ofa-v2-scm-roe-ocrdma2-1 u${dapl_ver} nonthreadsafe default libdaploscm.so.2 dapl.${dapl_ver} '"ocrdma2 1" ""' >> %{_sysconfdir}/dat.conf
+ echo ofa-v2-scm-roe-ocrdma3-1 u${dapl_ver} nonthreadsafe default libdaploscm.so.2 dapl.${dapl_ver} '"ocrdma3 1" ""' >> %{_sysconfdir}/dat.conf
+fi
+
+%postun
+/sbin/ldconfig
+if [ -e %{_sysconfdir}/dat.conf ]; then
+ sed -e '/ofa-v2-scm-roe-ocrdma.* u2/d' < %{_sysconfdir}/dat.conf > /tmp/$$ofadapl
+ mv /tmp/$$ofadapl %{_sysconfdir}/dat.conf
+fi
+
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%{_libdir}/libocrdma*.so
-%doc AUTHORS COPYING README
+# %doc AUTHORS COPYING ChangeLog README
%config %{_sysconfdir}/libibverbs.d/ocrdma.driver
%files devel
};
#define DBLY_LIST_HEAD_INIT(name) { { &(name.node), &(name.node) } , \
- PTHREAD_MUTEX_INITIALIZER }
+ PTHREAD_MUTEX_INITIALIZER }
#define DBLY_LIST_HEAD(name) \
struct ocrdma_list_head name = DBLY_LIST_HEAD_INIT(name); \
#define INIT_DBLY_LIST_HEAD(ptr) INIT_DBLY_LIST_NODE(ptr.node)
-static inline void __list_add_node(struct ocrdma_list_node *new,
+static __inline__ void __list_add_node(struct ocrdma_list_node *new,
struct ocrdma_list_node *prev,
struct ocrdma_list_node *next)
{
prev->next = new;
}
-static inline void list_add_node_tail(struct ocrdma_list_node *new,
+static __inline__ void list_add_node_tail(struct ocrdma_list_node *new,
struct ocrdma_list_head *head)
{
__list_add_node(new, head->node.prev, &head->node);
}
-static inline void __list_del_node(struct ocrdma_list_node *prev,
+static __inline__ void __list_del_node(struct ocrdma_list_node *prev,
struct ocrdma_list_node *next)
{
next->prev = prev;
prev->next = next;
}
-static inline void list_del_node(struct ocrdma_list_node *entry)
+static __inline__ void list_del_node(struct ocrdma_list_node *entry)
{
__list_del_node(entry->prev, entry->next);
entry->next = entry->prev = 0;
void *map_addr;
cq = malloc(sizeof *cq);
- if (!cq)
+ if (!cq) {
return NULL;
-
+ }
bzero(cq, sizeof *cq);
cmd.dpp_cq = dpp_cq;
status = ibv_cmd_create_cq(context, cqe, channel, comp_vector,
#ifdef DPP_CQ_SUPPORT
if (attrs->cap.max_inline_data) {
qp->dpp_cq = ocrdma_create_dpp_cq(pd->context,
- OCRDMA_CREATE_QP_REQ_DPP_CREDIT_LIMIT);
+ OCRDMA_CREATE_QP_REQ_DPP_CREDIT_LIMIT);
if (qp->dpp_cq) {
cmd.enable_dpp_cq = 1;
cmd.dpp_cq_id = qp->dpp_cq->cq_id;
qp->sq.max_sges = attrs->cap.max_send_sge;
qp->max_inline_data = attrs->cap.max_inline_data;
-
+
qp->signaled = attrs->sq_sig_all;
qp->sq.max_cnt = resp.num_wqe_allocated;
struct ibv_modify_qp cmd;
struct ocrdma_qp *qp = get_ocrdma_qp(ibqp);
int status;
+
status = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof cmd);
if ((!status) && (attr_mask & IBV_QP_STATE))
ocrdma_qp_state_machine(qp, attr->qp_state);
{
int i = idx / 32;
unsigned int mask = (1 << (idx % 32));
- if (srq->idx_bit_fields[i] & mask)
+
+ if (srq->idx_bit_fields[i] & mask) {
srq->idx_bit_fields[i] &= ~mask;
- else
+ } else {
srq->idx_bit_fields[i] |= mask;
-
+ }
}
static int ocrdma_srq_get_idx(struct ocrdma_srq *srq)
{
int row = 0;
int indx = 0;
+
for (row = 0; row < srq->bit_fields_len; row++) {
if (srq->idx_bit_fields[row]) {
indx = ffs(srq->idx_bit_fields[row]);
}
if (row == srq->bit_fields_len)
assert(0);
- return indx;
+ return indx + 1; /* Use the index from 1 */
}
static int ocrdma_dppq_credits(struct ocrdma_qp_hwq_info *q)
static inline void *ocrdma_hwq_head(struct ocrdma_qp_hwq_info *q)
{
- return q->va + (q->head * q->entry_size);
+ return (q->va + (q->head * q->entry_size));
}
static inline void *ocrdma_wq_tail(struct ocrdma_qp_hwq_info *q)
{
- return q->va + (q->tail * q->entry_size);
+ return (q->va + (q->tail * q->entry_size));
}
static inline void *ocrdma_hwq_head_from_idx(struct ocrdma_qp_hwq_info *q,
uint32_t idx)
{
- return q->va + (idx * q->entry_size);
+ return (q->va + (idx * q->entry_size));
}
static void ocrdma_hwq_inc_head(struct ocrdma_qp_hwq_info *q)
struct ocrdma_cqe *cqe)
{
int wqe_idx;
+
wqe_idx = (ocrdma_le_to_cpu(cqe->rq.buftag_qpn) >>
OCRDMA_CQE_BUFTAG_SHIFT) & qp->srq->rq.max_wqe_idx;
+
+ if (wqe_idx < 1)
+ assert(0);
+
pthread_spin_lock(&qp->srq->q_lock);
ocrdma_hwq_inc_tail(&qp->srq->rq);
- ocrdma_srq_toggle_bit(qp->srq, wqe_idx);
+ ocrdma_srq_toggle_bit(qp->srq, wqe_idx - 1);
pthread_spin_unlock(&qp->srq->q_lock);
}
pthread_spin_lock(&cq->cq_lock);
/* traverse through the CQEs in the hw CQ,
- * find the matching CQE for a given qp,
+ * find the matching CQE for a given qp,
* mark the matching one discarded=1.
* discard the cqe.
- * ring the doorbell in the poll_cq() as
+ * ring the doorbell in the poll_cq() as
* we don't complete out of order cqe.
*/
cur_getp = cq->getp;
break;
cqe = cq->va + cur_getp;
- /* if (a) no valid cqe, or (b) done reading full hw cq, or
+ /* if (a) no valid cqe, or (b) done reading full hw cq, or
* (c) qp_xq becomes empty.
* then exit
*/
/* mark cqe discarded so that it is not picked up later
* in the poll_cq().
*/
- discard_cnt += 1;
- /* discard by marking qp_id = 0 */
- cqe->cmn.qpn = 0;
if (is_cqe_for_sq(cqe)) {
wqe_idx = (ocrdma_le_to_cpu(cqe->wq.wqeidx) &
OCRDMA_CQE_WQEIDX_MASK) & qp->sq.max_wqe_idx;
else
ocrdma_hwq_inc_tail(&qp->rq);
}
+
+ discard_cnt += 1;
+ /* discard by marking qp_id = 0 */
+ cqe->cmn.qpn = 0;
skip_cqe:
cur_getp = (cur_getp + 1) % cq->max_hw_cqe;
qp = get_ocrdma_qp(ibqp);
dev = qp->dev;
id = dev->id;
- /*
+ /*
* acquire CQ lock while destroy is in progress, in order to
* protect against proessing in-flight CQEs for this QP.
*/
if (qp->sq.va)
munmap(qp->sq.va, qp->sq.len);
- /* ensure that CQEs for newly created QP (whose id may be same with
+ /* ensure that CQEs for newly created QP (whose id may be same with
* one which just getting destroyed are same), dont get
* discarded until the old CQEs are discarded.
*/
static inline uint32_t ocrdma_sglist_len(struct ibv_sge *sg_list, int num_sge)
{
uint32_t total_len = 0, i;
-
+
for (i = 0; i < num_sge; i++)
total_len += sg_list[i].length;
- return total_len;
+ return total_len;
}
static inline int ocrdma_build_inline_sges(struct ocrdma_qp *qp,
uint32_t wqe_size)
{
int i;
+ char *dpp_addr;
if (wr->send_flags & IBV_SEND_INLINE && qp->qp_type != IBV_QPT_UD) {
-
+
hdr->total_len = ocrdma_sglist_len(wr->sg_list, wr->num_sge);
if (hdr->total_len > qp->max_inline_data) {
ocrdma_err
return -EINVAL;
}
+ dpp_addr = (char *)sge;
for (i = 0; i < wr->num_sge; i++) {
- memcpy(sge,
+ memcpy(dpp_addr,
(void *)(unsigned long)wr->sg_list[i].addr,
wr->sg_list[i].length);
- sge += wr->sg_list[i].length;
+ dpp_addr += wr->sg_list[i].length;
}
wqe_size += ROUND_UP_X(hdr->total_len, OCRDMA_WQE_ALIGN_BYTES);
hdr_sz += sizeof(struct ocrdma_ewqe_ud_hdr);
if (hdr->cw & (OCRDMA_WRITE << OCRDMA_WQE_OPCODE_SHIFT))
hdr_sz += sizeof(struct ocrdma_sge);
- return hdr_sz / sizeof(uint32_t);
+ return (hdr_sz / sizeof(uint32_t));
}
static void ocrdma_build_dpp_wqe(void *va, struct ocrdma_hdr_wqe *wqe,
qp->wqe_wr_id_tbl[qp->sq.head].dpp_wqe = 1;
qp->wqe_wr_id_tbl[qp->sq.head].dpp_wqe_idx = qp->dpp_q.head;
/* if dpp cq is not enabled, we can post
- * wqe as soon as we receive and adapter
+ * wqe as soon as we receive and adapter
* takes care of flow control.
*/
if (qp->dpp_cq)
#else
wqe_idx = (ocrdma_le_to_cpu(cqe->flags_status_srcqpn)) & 0xFFFF;
#endif
+ if (wqe_idx < 1)
+ assert(0);
ibwc->wr_id = srq->rqe_wr_id_tbl[wqe_idx];
+
pthread_spin_lock(&srq->q_lock);
- ocrdma_srq_toggle_bit(srq, wqe_idx);
+ ocrdma_srq_toggle_bit(srq, wqe_idx - 1);
pthread_spin_unlock(&srq->q_lock);
+
ocrdma_hwq_inc_tail(&srq->rq);
}
ibwc->wc_flags = 0;
if (qp->qp_type == IBV_QPT_UD)
status = (ocrdma_le_to_cpu(cqe->flags_status_srcqpn) &
- OCRDMA_CQE_UD_STATUS_MASK) >> OCRDMA_CQE_UD_STATUS_SHIFT;
+ OCRDMA_CQE_UD_STATUS_MASK) >> OCRDMA_CQE_UD_STATUS_SHIFT;
else
status = (ocrdma_le_to_cpu(cqe->flags_status_srcqpn) &
OCRDMA_CQE_STATUS_MASK) >> OCRDMA_CQE_STATUS_SHIFT;
cq->armed = 1;
cq->solicited = solicited;
- /* check whether any valid cqe exist or not, if not then safe to
- * arm. If cqe is not yet consumed, then let it get consumed and then
+ /* check whether any valid cqe exist or not, if not then safe to
+ * arm. If cqe is not yet consumed, then let it get consumed and then
* we arm it to avoid 0 interrupts.
*/
if (!is_cqe_valid(cq, cqe) || cq->arm_needed) {