1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved. 24 */ 25 26 /* 27 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31 /* 32 * 33 * MODULE: dapl_ep_post_recv.c 34 * 35 * PURPOSE: Endpoint management 36 * Description: Interfaces in this file are completely described in 37 * the DAPL 1.1 API, Chapter 6, section 5 38 * 39 * $Id: dapl_ep_post_recv.c,v 1.17 2003/07/30 18:13:37 hobie16 Exp $ 40 */ 41 42 #include "dapl.h" 43 #include "dapl_cookie.h" 44 #include "dapl_adapter_util.h" 45 46 /* 47 * dapl_ep_post_recv 48 * 49 * DAPL Requirements Version xxx, 6.5.11 50 * 51 * Request to receive data over the connection of ep handle into 52 * local_iov 53 * 54 * Input: 55 * ep_handle 56 * num_segments 57 * local_iov 58 * user_cookie 59 * completion_flags 60 * 61 * Output: 62 * None. 63 * 64 * Returns: 65 * DAT_SUCCESS 66 * DAT_INSUFFICIENT_RESOURCES 67 * DAT_INVALID_PARAMETER 68 * DAT_INVALID_STATE 69 * DAT_PROTECTION_VIOLATION 70 * DAT_PROVILEGES_VIOLATION 71 */ 72 DAT_RETURN 73 dapl_ep_post_recv( 74 IN DAT_EP_HANDLE ep_handle, 75 IN DAT_COUNT num_segments, 76 IN DAT_LMR_TRIPLET *local_iov, 77 IN DAT_DTO_COOKIE user_cookie, 78 IN DAT_COMPLETION_FLAGS completion_flags) 79 { 80 DAPL_EP *ep_ptr; 81 DAPL_COOKIE *cookie; 82 DAT_RETURN dat_status; 83 84 dapl_dbg_log(DAPL_DBG_TYPE_API, 85 "dapl_ep_post_recv (%p, %d, %p, %P, %x)\n", 86 ep_handle, 87 num_segments, 88 local_iov, 89 user_cookie.as_64, 90 completion_flags); 91 92 if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP)) { 93 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 94 DAT_INVALID_HANDLE_EP); 95 goto bail; 96 } 97 98 ep_ptr = (DAPL_EP *) ep_handle; 99 100 /* dat_ep_post_recv is not supported on EPs with SRQ */ 101 if (ep_ptr->srq_attached) { 102 dat_status = DAT_ERROR(DAT_INVALID_STATE, 0); 103 goto bail; 104 } 105 106 /* 107 * Synchronization ok since this buffer is only used for receive 108 * requests, which aren't allowed to race with each other. 109 */ 110 dat_status = dapls_dto_cookie_alloc(&ep_ptr->recv_buffer, 111 DAPL_DTO_TYPE_RECV, 112 user_cookie, 113 &cookie); 114 if (DAT_SUCCESS != dat_status) { 115 goto bail; 116 } 117 118 /* 119 * Invoke provider specific routine to post DTO 120 */ 121 if (num_segments != 1 || 122 completion_flags != DAT_COMPLETION_DEFAULT_FLAG) 123 dat_status = dapls_ib_post_recv(ep_ptr, cookie, num_segments, 124 local_iov, completion_flags); 125 else 126 dat_status = dapls_ib_post_recv_one(ep_ptr, cookie, local_iov); 127 128 if (dat_status != DAT_SUCCESS) { 129 dapls_cookie_dealloc(&ep_ptr->recv_buffer, cookie); 130 } else { 131 dapl_os_atomic_inc(&ep_ptr->recv_count); 132 } 133 134 bail: 135 dapl_dbg_log(DAPL_DBG_TYPE_RTN, 136 "dapl_ep_post_recv () returns 0x%x\n", dat_status); 137 138 return (dat_status); 139 } 140