Signed-off-by: Tom Duffy <[EMAIL PROTECTED]>

Index: linux-kernel-srq/dat-provider/dapl_srq.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq.c    (revision 0)
+++ linux-kernel-srq/dat-provider/dapl_srq.c    (revision 0)
@@ -0,0 +1,500 @@
+/*
+ * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
+ *
+ * This Software is licensed under one of the following licenses:
+ *
+ * 1) under the terms of the "Common Public License 1.0" a copy of which is
+ *    available from the Open Source Initiative, see
+ *    http://www.opensource.org/licenses/cpl.php.
+ *
+ * 2) under the terms of the "The BSD License" a copy of which is
+ *    available from the Open Source Initiative, see
+ *    http://www.opensource.org/licenses/bsd-license.php.
+ *
+ * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
+ *    copy of which is available from the Open Source Initiative, see
+ *    http://www.opensource.org/licenses/gpl-license.php.
+ *
+ * Licensee has the right to choose one of the above licenses.
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice and one of the license notices.
+ *
+ * Redistributions in binary form must reproduce both the above copyright
+ * notice, one of the license notices in the documentation
+ * and/or other materials provided with the distribution.
+ */
+
+/*
+ * $Id$
+ */
+
+#include "dapl.h"
+#include "dapl_ia_util.h"
+#include "dapl_openib_util.h"
+#include "dapl_cookie.h"
+
+/*
+ * dapl_srq_dealloc
+ *
+ * Free the passed in SRQ structure.
+ *
+ * Input:
+ *     SRQ pointer
+ *
+ * Output:
+ *     none
+ *
+ * Returns:
+ *     none
+ *
+ */
+static void dapl_srq_dealloc(struct dapl_srq *srq_ptr)
+{
+       dapl_os_assert(srq_ptr->header.magic == DAPL_MAGIC_SRQ);
+
+       /* reset magic to prevent reuse */
+       srq_ptr->header.magic = DAPL_MAGIC_INVALID;
+       dapl_ia_unlink_srq(srq_ptr->header.owner_ia, srq_ptr);
+       dapl_cb_free(&srq_ptr->recv_buffer);
+       /* no need to destroy srq_ptr->header.lock */
+
+       kfree(srq_ptr);
+}
+
+/*
+ * dapl_srq_alloc
+ *
+ * alloc and initialize an SRQ struct
+ *
+ * Input:
+ *     IA INFO struct ptr
+ *     SRQ ATTR ptr
+ *
+ * Output:
+ *     none
+ *
+ * Returns:
+ *     pointer to srq
+ *
+ */
+static struct dapl_srq *dapl_srq_alloc(struct dapl_ia *ia_ptr,
+                                      const struct dat_srq_attr *srq_attr)
+{
+       struct dapl_srq *srq_ptr;
+
+       /* Allocate SRQ */
+       srq_ptr = kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
+       if (!srq_ptr)
+               goto bail;
+
+       /* zero the structure */
+       memset(srq_ptr, 0, sizeof *srq_ptr);
+
+       /*
+        * initialize the header
+        */
+       srq_ptr->header.provider = ia_ptr->header.provider;
+       srq_ptr->header.magic = DAPL_MAGIC_SRQ;
+       srq_ptr->header.handle_type = DAT_HANDLE_TYPE_SRQ;
+       srq_ptr->header.owner_ia = ia_ptr;
+       srq_ptr->header.user_context.as_64 = 0;
+       srq_ptr->header.user_context.as_ptr = NULL;
+       atomic_set(&srq_ptr->srq_ref_count, 0);
+
+       dapl_llist_init_entry(&srq_ptr->header.ia_list_entry);
+       spin_lock_init(&srq_ptr->header.lock);
+
+       /*
+        * Initialize the body. 
+        * XXX Assume srq_attrs is required
+        */
+       srq_ptr->param.max_recv_dtos = srq_attr->max_recv_dtos;
+       srq_ptr->param.max_recv_iov = srq_attr->max_recv_iov;
+       srq_ptr->param.low_watermark = srq_attr->low_watermark;
+
+       /* Get a cookie buffer to track outstanding recvs */
+       if (DAT_SUCCESS != dapl_cb_create(&srq_ptr->recv_buffer,
+                                        (struct dapl_ep *)srq_ptr,
+                                         srq_ptr->param.max_recv_dtos)) {
+               dapl_srq_dealloc(srq_ptr);
+               srq_ptr = NULL;
+               goto bail;
+       }
+
+bail:
+       return srq_ptr;
+}
+
+/*
+ * dapl_srq_create
+ *
+ * Create an instance of a Shared Receive Queue that is provided to the
+ * consumer at srq_handle.
+ *
+ * Input:
+ *     ia_handle
+ *     pz_handle
+ *     srq_attr
+ *
+ * Output:
+ *     srq_handle
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INSUFFICIENT_RESOURCES
+ *     DAT_INVALID_HANDLE
+ *     DAT_INVALID_PARAMETER
+ *     ?DAT_INVALID_ATTRIBUTE??
+ *     DAT_MODEL_NOT_SUPPORTED
+ */
+u32 dapl_srq_create(DAT_IA_HANDLE ia_handle, DAT_PZ_HANDLE pz_handle,
+                   struct dat_srq_attr *srq_attr, DAT_SRQ_HANDLE *srq_handle)
+{
+       struct dapl_ia *ia_ptr;
+       struct dapl_srq *srq_ptr;
+       u32 status = DAT_SUCCESS;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_srq_create (%p, %p, %p, %p)\n",
+                    ia_handle, pz_handle, srq_attr, srq_handle);
+
+       ia_ptr = (struct dapl_ia *)ia_handle;
+
+       /*
+        * Verify parameters
+        */
+       if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+               goto bail;
+       }
+
+       /*
+        * Verify non-required parameters.
+        * N.B. Assumption: any parameter that can be
+        *      modified by dat_ep_modify() is not strictly
+        *      required when the EP is created
+        */
+       if (pz_handle != NULL && DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+               goto bail;
+       }
+
+       if (srq_handle == NULL) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+               goto bail;
+       }
+       if ((unsigned long)srq_attr & 3) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+               goto bail;
+       }
+
+       /* Allocate SRQ */
+       srq_ptr = dapl_srq_alloc(ia_ptr, srq_attr);
+       if (srq_ptr == NULL) {
+               status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+                                  DAT_RESOURCE_MEMORY);
+               goto bail;
+       }
+
+       srq_ptr->param.ia_handle = (DAT_IA_HANDLE) ia_ptr;
+       srq_ptr->param.srq_state = DAT_SRQ_STATE_OPERATIONAL;
+       srq_ptr->param.pz_handle = pz_handle;
+
+       /*
+        * XXX Allocate provider resource here!!!
+        */
+       /* XXX */ status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+       /* XXX */ dapl_srq_dealloc(srq_ptr);
+       /* XXX */ goto bail;
+
+       /* Link it onto the IA */
+       dapl_ia_link_srq(ia_ptr, srq_ptr);
+
+       *srq_handle = srq_ptr;
+
+bail:
+       return status;
+}
+
+/*
+ * dapl_srq_free
+ *
+ * Destroy an instance of an SRQ
+ *
+ * Input:
+ *     srq_handle
+ *
+ * Output:
+ *     none
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INVALID_PARAMETER
+ *     DAT_INVALID_STATE
+ */
+u32 dapl_srq_free(DAT_SRQ_HANDLE srq_handle)
+{
+       struct dapl_srq *srq_ptr;
+       struct dapl_ia *ia_ptr;
+       struct dat_srq_param *param;
+       u32 status = DAT_SUCCESS;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_free (%p)\n", srq_handle);
+
+       srq_ptr = (struct dapl_srq *)srq_handle;
+       param = &srq_ptr->param;
+
+       /*
+        * Verify parameter & state
+        */
+       if (DAPL_BAD_HANDLE(srq_ptr, DAPL_MAGIC_SRQ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+               goto bail;
+       }
+
+       if (atomic_read(&srq_ptr->srq_ref_count) != 0) {
+               /*
+                * The DAPL 1.2 spec says to return DAT_SRQ_IN_USE, which does
+                * not exist. Have filed the following as an eratta.
+                */
+               status = DAT_ERROR(DAT_INVALID_STATE,
+                                  DAT_INVALID_STATE_SRQ_IN_USE);
+               goto bail;
+       }
+
+       ia_ptr = srq_ptr->header.owner_ia;
+
+       /*
+        * Do verification of parameters and the state change atomically.
+        */
+       spin_lock_irqsave(&srq_ptr->header.lock, srq_ptr->header.flags);
+
+       /* Remove the SRQ from the IA */
+       dapl_ia_unlink_srq(ia_ptr, srq_ptr);
+
+       spin_unlock_irqrestore(&srq_ptr->header.lock, srq_ptr->header.flags);
+
+       /*
+        * Finish tearing everything down.
+        */
+
+       /*
+        * Take care of the transport resource
+        */
+
+       /* XXX Put provider code here!!! */
+
+       /* Free the resource */
+       dapl_srq_dealloc(srq_ptr);
+
+bail:
+       return status;
+
+}
+
+/*
+ * dapl_srq_post_recv
+ *
+ * Post a receive buffer that can be used by any incoming
+ * message by any connected EP using the SRQ. Request to receive data
+ * over a connection of any ep handle into local_iov
+ *
+ * Input:
+ *     srq_handle
+ *     num_segments
+ *     local_iov
+ *     user_cookie
+ *
+ * Output:
+ *     None.
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INSUFFICIENT_RESOURCES
+ *     DAT_INVALID_PARAMETER
+ *     DAT_INVALID_HANDLE
+ *     DAT_INVALID_STATE
+ *     DAT_PROTECTION_VIOLATION
+ *     DAT_PROVILEGES_VIOLATION
+ */
+u32 dapl_srq_post_recv(DAT_SRQ_HANDLE srq_handle, int num_segments,
+                      struct dat_lmr_triplet *local_iov,
+                      DAT_DTO_COOKIE user_cookie)
+{
+       struct dapl_srq *srq_ptr;
+       struct dapl_cookie *cookie;
+       u32 status;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_srq_post_recv (%p, %d, %p, %P)\n",
+                    srq_handle, num_segments, local_iov, user_cookie.as_64);
+
+       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+               goto bail;
+       }
+
+       srq_ptr = (struct dapl_srq *)srq_handle;
+
+       /*
+        * Synchronization ok since this buffer is only used for receive
+        * requests, which aren't allowed to race with each other. The
+        * app must syncronize access to the SRQ.
+        */
+       status = dapl_dto_cookie_alloc(&srq_ptr->recv_buffer,
+                                      DAPL_DTO_TYPE_RECV,
+                                      user_cookie, &cookie);
+       if (DAT_SUCCESS != status)
+               goto bail;
+
+       /*
+        * Take reference before posting to avoid race conditions with
+        * completions
+        */
+       atomic_inc(&srq_ptr->recv_count);
+
+       /*
+        * Invoke provider specific routine to post DTO
+        */
+       /* XXX Put code here XXX */
+       /* XXX */ status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+
+       if (status != DAT_SUCCESS) {
+               atomic_dec(&srq_ptr->recv_count);
+               dapl_cookie_dealloc(&srq_ptr->recv_buffer, cookie);
+       }
+
+bail:
+       return status;
+}
+
+u32 dapl_srq_query(DAT_SRQ_HANDLE srq_handle, struct dat_srq_param *srq_param)
+{
+       struct dapl_srq *srq_ptr;
+       u32 status = DAT_SUCCESS;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_srq_query (%p, %x, %p)\n",
+                    srq_handle, srq_param);
+
+       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+               goto bail;
+       }
+       if (srq_param == NULL) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+               goto bail;
+       }
+
+       srq_ptr = (struct dapl_srq *)srq_handle;
+
+       /*
+        * XXX Need to calculate available_dto_count and outstanding_dto_count
+        */
+       srq_ptr->param.available_dto_count = DAT_VALUE_UNKNOWN;
+       srq_ptr->param.outstanding_dto_count = DAT_VALUE_UNKNOWN;
+
+       *srq_param = srq_ptr->param;
+
+bail:
+       return status;
+}
+
+/*
+ * dapl_srq_resize
+ *
+ * Modify the size fo the event queue of a Shared Recieve Queue
+ *
+ * Input:
+ *     srq_handle
+ *     srq_max_recv_dto
+ *
+ * Output:
+ *     none
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INVALID_HANDLE
+ *     DAT_INVALID_PARAMETER
+ *     DAT_INSUFFICIENT_RESOURCES
+ *     DAT_INVALID_STATE
+ */
+
+u32 dapl_srq_resize(DAT_SRQ_HANDLE srq_handle, int srq_max_recv_dto)
+{
+       struct dapl_ia *ia_ptr;
+       struct dapl_srq *srq_ptr;
+       u32 status = DAT_SUCCESS;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_resize (%p, %d)\n",
+                    srq_handle, srq_max_recv_dto);
+
+       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+               goto bail;
+       }
+
+       srq_ptr = (struct dapl_srq *)srq_handle;
+       ia_ptr = srq_ptr->header.owner_ia;
+
+       /*
+        * Check for nonsense requests per the spec
+        */
+       if (srq_max_recv_dto <= srq_ptr->param.low_watermark) {
+               status = DAT_ERROR(DAT_INVALID_STATE, DAT_NO_SUBTYPE);
+               goto bail;
+       }
+
+       /* XXX Put implementation here XXX */
+
+       /* XXX */ status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+
+bail:
+       return status;
+}
+
+/*
+ * dapl_srq_set_lw
+ *
+ * DAPL Requirements Version 1.2, 6.5.4
+ *
+ * Set the low water mark for an SRQ and arm the SRQ to generate an
+ * event if it is reached.
+ *
+ * Input:
+ *     srq_handle
+ *     srq_max_recv_dto
+ *
+ * Output:
+ *     none
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INVALID_HANDLE
+ *     DAT_INVALID_PARAMETER
+ *     DAT_MODEL_NOT_SUPPORTED
+ */
+
+u32 dapl_srq_set_lw(DAT_SRQ_HANDLE srq_handle, int low_watermark)
+{
+       struct dapl_srq *srq_ptr;
+       u32 status = DAT_SUCCESS;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_set_lw (%p, %d)\n",
+                    srq_handle, low_watermark);
+
+       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+               goto bail;
+       }
+
+       srq_ptr = (struct dapl_srq *)srq_handle;
+
+       /* XXX Put implementation here XXX */
+
+       /* XXX */ status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+
+bail:
+       return status;
+}
Index: linux-kernel-srq/dat-provider/dapl_srq_resize.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_resize.c     (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_resize.c     (working copy)
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_srq_util.h"
-#include "dapl_openib_util.h"
-
-/*
- * dapl_srq_resize
- *
- * Modify the size fo the event queue of a Shared Recieve Queue
- *
- * Input:
- *     srq_handle
- *     srq_max_recv_dto
- *
- * Output:
- *     none
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INVALID_HANDLE
- *     DAT_INVALID_PARAMETER
- *     DAT_INSUFFICIENT_RESOURCES
- *     DAT_INVALID_STATE
- */
-
-u32 dapl_srq_resize(DAT_SRQ_HANDLE srq_handle, int srq_max_recv_dto)
-{
-       struct dapl_ia *ia_ptr;
-       struct dapl_srq *srq_ptr;
-       u32 dat_status = DAT_SUCCESS;
-
-       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_resize (%p, %d)\n",
-                    srq_handle, srq_max_recv_dto);
-
-       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-               goto bail;
-       }
-
-       srq_ptr = (struct dapl_srq *)srq_handle;
-       ia_ptr = srq_ptr->header.owner_ia;
-
-       /*
-        * Check for nonsense requests per the spec
-        */
-       if (srq_max_recv_dto <= srq_ptr->param.low_watermark) {
-               dat_status = DAT_ERROR(DAT_INVALID_STATE, DAT_NO_SUBTYPE);
-               goto bail;
-       }
-
-       /* XXX Put implementation here XXX */
-
-       /* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-
-      bail:
-       return dat_status;
-}
Index: linux-kernel-srq/dat-provider/dapl_srq_create.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_create.c     (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_create.c     (working copy)
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_ia_util.h"
-#include "dapl_srq_util.h"
-#include "dapl_openib_util.h"
-
-/*
- * dapl_srq_create
- *
- * Create an instance of a Shared Receive Queue that is provided to the
- * consumer at srq_handle.
- *
- * Input:
- *     ia_handle
- *     pz_handle
- *     srq_attr
- *
- * Output:
- *     srq_handle
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INSUFFICIENT_RESOURCES
- *     DAT_INVALID_HANDLE
- *     DAT_INVALID_PARAMETER
- *     ?DAT_INVALID_ATTRIBUTE??
- *     DAT_MODEL_NOT_SUPPORTED
- */
-u32 dapl_srq_create(DAT_IA_HANDLE ia_handle, DAT_PZ_HANDLE pz_handle,
-                   struct dat_srq_attr *srq_attr, DAT_SRQ_HANDLE *srq_handle)
-{
-       struct dapl_ia *ia_ptr;
-       struct dapl_srq *srq_ptr;
-       u32 dat_status = DAT_SUCCESS;
-
-       dapl_dbg_log(DAPL_DBG_TYPE_API,
-                    "dapl_srq_create (%p, %p, %p, %p)\n",
-                    ia_handle, pz_handle, srq_attr, srq_handle);
-
-       ia_ptr = (struct dapl_ia *)ia_handle;
-
-       /*
-        * Verify parameters
-        */
-       if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-               goto bail;
-       }
-
-       /*
-        * Verify non-required parameters.
-        * N.B. Assumption: any parameter that can be
-        *      modified by dat_ep_modify() is not strictly
-        *      required when the EP is created
-        */
-       if (pz_handle != NULL && DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-               goto bail;
-       }
-
-       if (srq_handle == NULL) {
-               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-               goto bail;
-       }
-       if ((unsigned long)srq_attr & 3) {
-               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-               goto bail;
-       }
-
-       /* Allocate SRQ */
-       srq_ptr = dapl_srq_alloc(ia_ptr, srq_attr);
-       if (srq_ptr == NULL) {
-               dat_status =
-                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-               goto bail;
-       }
-
-       srq_ptr->param.ia_handle = (DAT_IA_HANDLE) ia_ptr;
-       srq_ptr->param.srq_state = DAT_SRQ_STATE_OPERATIONAL;
-       srq_ptr->param.pz_handle = pz_handle;
-
-       /*
-        * XXX Allocate provider resource here!!!
-        */
-       /* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-       /* XXX */ dapl_srq_dealloc(srq_ptr);
-       /* XXX */ goto bail;
-
-       /* Link it onto the IA */
-       dapl_ia_link_srq(ia_ptr, srq_ptr);
-
-       *srq_handle = srq_ptr;
-
-      bail:
-       return dat_status;
-}
Index: linux-kernel-srq/dat-provider/dapl_srq_query.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_query.c      (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_query.c      (working copy)
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-
-u32 dapl_srq_query(DAT_SRQ_HANDLE srq_handle, struct dat_srq_param *srq_param)
-{
-       struct dapl_srq *srq_ptr;
-       u32 dat_status = DAT_SUCCESS;
-
-       dapl_dbg_log(DAPL_DBG_TYPE_API,
-                    "dapl_srq_query (%p, %x, %p)\n",
-                    srq_handle, srq_param);
-
-       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-               goto bail;
-       }
-       if (srq_param == NULL) {
-               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-               goto bail;
-       }
-
-       srq_ptr = (struct dapl_srq *)srq_handle;
-
-       /*
-        * XXX Need to calculate available_dto_count and outstanding_dto_count
-        */
-       srq_ptr->param.available_dto_count = DAT_VALUE_UNKNOWN;
-       srq_ptr->param.outstanding_dto_count = DAT_VALUE_UNKNOWN;
-
-       *srq_param = srq_ptr->param;
-
-      bail:
-       return dat_status;
-}
Index: linux-kernel-srq/dat-provider/Makefile
===================================================================
--- linux-kernel-srq/dat-provider/Makefile      (revision 2489)
+++ linux-kernel-srq/dat-provider/Makefile      (working copy)
@@ -82,13 +82,7 @@ PROVIDER_MODULES := \
         dapl_rsp_query                 \
         dapl_set_consumer_context      \
         dapl_sp_util                   \
-        dapl_srq_create                \
-        dapl_srq_free                  \
-        dapl_srq_post_recv             \
-        dapl_srq_query                 \
-        dapl_srq_resize                \
-        dapl_srq_set_lw                \
-        dapl_srq_util                  \
+        dapl_srq                       \
         dapl_timer_util                \
        dapl_util
 
Index: linux-kernel-srq/dat-provider/dapl_srq_util.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_util.c       (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_util.c       (working copy)
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl_srq_util.h"
-#include "dapl_ia_util.h"
-#include "dapl_cookie.h"
-
-/*
- * dapl_srq_alloc
- *
- * alloc and initialize an SRQ struct
- *
- * Input:
- *     IA INFO struct ptr
- *     SRQ ATTR ptr
- *
- * Output:
- *     none
- *
- * Returns:
- *     pointer to srq
- *
- */
-struct dapl_srq *dapl_srq_alloc(struct dapl_ia *ia_ptr,
-                               const struct dat_srq_attr *srq_attr)
-{
-       struct dapl_srq *srq_ptr;
-
-       /* Allocate SRQ */
-       srq_ptr = kmalloc(sizeof *srq_ptr, GFP_ATOMIC);
-       if (!srq_ptr)
-               goto bail;
-
-       /* zero the structure */
-       memset(srq_ptr, 0, sizeof *srq_ptr);
-
-       /*
-        * initialize the header
-        */
-       srq_ptr->header.provider = ia_ptr->header.provider;
-       srq_ptr->header.magic = DAPL_MAGIC_SRQ;
-       srq_ptr->header.handle_type = DAT_HANDLE_TYPE_SRQ;
-       srq_ptr->header.owner_ia = ia_ptr;
-       srq_ptr->header.user_context.as_64 = 0;
-       srq_ptr->header.user_context.as_ptr = NULL;
-       atomic_set(&srq_ptr->srq_ref_count, 0);
-
-       dapl_llist_init_entry(&srq_ptr->header.ia_list_entry);
-       spin_lock_init(&srq_ptr->header.lock);
-
-       /*
-        * Initialize the body. 
-        * XXX Assume srq_attrs is required
-        */
-       srq_ptr->param.max_recv_dtos = srq_attr->max_recv_dtos;
-       srq_ptr->param.max_recv_iov = srq_attr->max_recv_iov;
-       srq_ptr->param.low_watermark = srq_attr->low_watermark;
-
-       /* Get a cookie buffer to track outstanding recvs */
-       if (DAT_SUCCESS != dapl_cb_create(&srq_ptr->recv_buffer,
-                                        (struct dapl_ep *)srq_ptr,
-                                         srq_ptr->param.max_recv_dtos)) {
-               dapl_srq_dealloc(srq_ptr);
-               srq_ptr = NULL;
-               goto bail;
-       }
-
-bail:
-       return srq_ptr;
-}
-
-/*
- * dapl_srq_dealloc
- *
- * Free the passed in SRQ structure.
- *
- * Input:
- *     SRQ pointer
- *
- * Output:
- *     none
- *
- * Returns:
- *     none
- *
- */
-void dapl_srq_dealloc(struct dapl_srq *srq_ptr)
-{
-       dapl_os_assert(srq_ptr->header.magic == DAPL_MAGIC_SRQ);
-
-       /* reset magic to prevent reuse */
-       srq_ptr->header.magic = DAPL_MAGIC_INVALID;
-       dapl_ia_unlink_srq(srq_ptr->header.owner_ia, srq_ptr);
-       dapl_cb_free(&srq_ptr->recv_buffer);
-       /* no need to destroy srq_ptr->header.lock */
-
-       kfree(srq_ptr);
-}
Index: linux-kernel-srq/dat-provider/dapl_srq_util.h
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_util.h       (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_util.h       (working copy)
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/**********************************************************************
- * 
- * HEADER: dapl_srq_util.h
- *
- * PURPOSE: Utility defs & routines for the SRQ data structure
- *
- * $Id$
- **********************************************************************/
-
-#ifndef DAPL_SRQ_UTIL_H
-#define DAPL_SRQ_UTIL_H
-
-#include "dapl.h"
-
-extern struct dapl_srq *dapl_srq_alloc(struct dapl_ia *ia,
-                                      const struct dat_srq_attr *srq_attr);
-
-extern void dapl_srq_dealloc(struct dapl_srq *srq_ptr);
-
-#endif /* DAPL_SRQ_UTIL_H */
Index: linux-kernel-srq/dat-provider/dapl_srq_set_lw.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_set_lw.c     (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_set_lw.c     (working copy)
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_srq_util.h"
-#include "dapl_openib_util.h"
-
-/*
- * dapl_srq_set_lw
- *
- * DAPL Requirements Version 1.2, 6.5.4
- *
- * Set the low water mark for an SRQ and arm the SRQ to generate an
- * event if it is reached.
- *
- * Input:
- *     srq_handle
- *     srq_max_recv_dto
- *
- * Output:
- *     none
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INVALID_HANDLE
- *     DAT_INVALID_PARAMETER
- *     DAT_MODEL_NOT_SUPPORTED
- */
-
-u32 dapl_srq_set_lw(DAT_SRQ_HANDLE srq_handle, int low_watermark)
-{
-       struct dapl_srq *srq_ptr;
-       u32 dat_status = DAT_SUCCESS;
-
-       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_set_lw (%p, %d)\n",
-                    srq_handle, low_watermark);
-
-       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-               goto bail;
-       }
-
-       srq_ptr = (struct dapl_srq *)srq_handle;
-
-       /* XXX Put implementation here XXX */
-
-       /* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-
-      bail:
-       return dat_status;
-}
Index: linux-kernel-srq/dat-provider/dapl_srq_post_recv.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_post_recv.c  (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_post_recv.c  (working copy)
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_cookie.h"
-#include "dapl_openib_util.h"
-
-/*
- * dapl_srq_post_recv
- *
- * Post a receive buffer that can be used by any incoming
- * message by any connected EP using the SRQ. Request to receive data
- * over a connection of any ep handle into local_iov
- *
- * Input:
- *     srq_handle
- *     num_segments
- *     local_iov
- *     user_cookie
- *
- * Output:
- *     None.
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INSUFFICIENT_RESOURCES
- *     DAT_INVALID_PARAMETER
- *     DAT_INVALID_HANDLE
- *     DAT_INVALID_STATE
- *     DAT_PROTECTION_VIOLATION
- *     DAT_PROVILEGES_VIOLATION
- */
-u32 dapl_srq_post_recv(DAT_SRQ_HANDLE srq_handle, int num_segments,
-                      struct dat_lmr_triplet *local_iov,
-                      DAT_DTO_COOKIE user_cookie)
-{
-       struct dapl_srq *srq_ptr;
-       struct dapl_cookie *cookie;
-       u32 dat_status;
-
-       dapl_dbg_log(DAPL_DBG_TYPE_API,
-                    "dapl_srq_post_recv (%p, %d, %p, %P)\n",
-                    srq_handle, num_segments, local_iov, user_cookie.as_64);
-
-       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-               goto bail;
-       }
-
-       srq_ptr = (struct dapl_srq *)srq_handle;
-
-       /*
-        * Synchronization ok since this buffer is only used for receive
-        * requests, which aren't allowed to race with each other. The
-        * app must syncronize access to the SRQ.
-        */
-       dat_status = dapl_dto_cookie_alloc(&srq_ptr->recv_buffer,
-                                          DAPL_DTO_TYPE_RECV,
-                                          user_cookie, &cookie);
-       if (DAT_SUCCESS != dat_status) {
-               goto bail;
-       }
-
-       /*
-        * Take reference before posting to avoid race conditions with
-        * completions
-        */
-       atomic_inc(&srq_ptr->recv_count);
-
-       /*
-        * Invoke provider specific routine to post DTO
-        */
-       /* XXX Put code here XXX */
-       /* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-
-       if (dat_status != DAT_SUCCESS) {
-               atomic_dec(&srq_ptr->recv_count);
-               dapl_cookie_dealloc(&srq_ptr->recv_buffer, cookie);
-       }
-
-      bail:
-       return dat_status;
-}
Index: linux-kernel-srq/dat-provider/dapl_srq_free.c
===================================================================
--- linux-kernel-srq/dat-provider/dapl_srq_free.c       (revision 2489)
+++ linux-kernel-srq/dat-provider/dapl_srq_free.c       (working copy)
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_ia_util.h"
-#include "dapl_srq_util.h"
-#include "dapl_openib_util.h"
-
-/*
- * dapl_srq_free
- *
- * Destroy an instance of an SRQ
- *
- * Input:
- *     srq_handle
- *
- * Output:
- *     none
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INVALID_PARAMETER
- *     DAT_INVALID_STATE
- */
-u32 dapl_srq_free(DAT_SRQ_HANDLE srq_handle)
-{
-       struct dapl_srq *srq_ptr;
-       struct dapl_ia *ia_ptr;
-       struct dat_srq_param *param;
-       u32 dat_status = DAT_SUCCESS;
-
-       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_free (%p)\n", srq_handle);
-
-       srq_ptr = (struct dapl_srq *)srq_handle;
-       param = &srq_ptr->param;
-
-       /*
-        * Verify parameter & state
-        */
-       if (DAPL_BAD_HANDLE(srq_ptr, DAPL_MAGIC_SRQ)) {
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-               goto bail;
-       }
-
-       if (atomic_read(&srq_ptr->srq_ref_count) != 0) {
-               /*
-                * The DAPL 1.2 spec says to return DAT_SRQ_IN_USE, which does
-                * not exist. Have filed the following as an eratta.
-                */
-               dat_status =
-                   DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_SRQ_IN_USE);
-               goto bail;
-       }
-
-       ia_ptr = srq_ptr->header.owner_ia;
-
-       /*
-        * Do verification of parameters and the state change atomically.
-        */
-       spin_lock_irqsave(&srq_ptr->header.lock, srq_ptr->header.flags);
-
-       /* Remove the SRQ from the IA */
-       dapl_ia_unlink_srq(ia_ptr, srq_ptr);
-
-       spin_unlock_irqrestore(&srq_ptr->header.lock, srq_ptr->header.flags);
-
-       /*
-        * Finish tearing everything down.
-        */
-
-       /*
-        * Take care of the transport resource
-        */
-
-       /* XXX Put provider code here!!! */
-
-       /* Free the resource */
-       dapl_srq_dealloc(srq_ptr);
-
-      bail:
-       return dat_status;
-
-}
Index: linux-kernel-srq/patches/alt_dat_provider_makefile
===================================================================
--- linux-kernel-srq/patches/alt_dat_provider_makefile  (revision 2489)
+++ linux-kernel-srq/patches/alt_dat_provider_makefile  (working copy)
@@ -76,13 +76,7 @@ PROVIDER_MODULES := \
         dapl_rsp_query                 \
         dapl_set_consumer_context      \
         dapl_sp_util                   \
-        dapl_srq_create                \
-        dapl_srq_free                  \
-        dapl_srq_post_recv             \
-        dapl_srq_query                 \
-        dapl_srq_resize                \
-        dapl_srq_set_lw                \
-        dapl_srq_util                  \
+        dapl_srq                       \
         dapl_timer_util                \
        dapl_util
 

_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to