2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#include "dapl.h"
2N/A#include "dapl_mr_util.h"
2N/A#include <dapl_tavor_ibtf_impl.h>
2N/A
2N/ADAT_RETURN
2N/Adapls_ib_lmr_sync_rdma_common(
2N/A IN DAT_IA_HANDLE ia_handle,
2N/A IN const DAT_LMR_TRIPLET *lmr_triplet,
2N/A IN DAT_VLEN num_segments,
2N/A IN uint32_t op_type)
2N/A{
2N/A DAPL_IA *ia_ptr;
2N/A DAPL_LMR *lmr;
2N/A DAT_RETURN dat_status;
2N/A dapl_mr_sync_t args;
2N/A int i, j;
2N/A int retval;
2N/A
2N/A if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
2N/A return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
2N/A }
2N/A
2N/A ia_ptr = (DAPL_IA *)ia_handle;
2N/A args.mrs_flags = op_type;
2N/A
2N/A for (i = 0, j = 0; i < num_segments; i++) {
2N/A dat_status = dapls_hash_search(
2N/A ia_ptr->hca_ptr->lmr_hash_table,
2N/A lmr_triplet[i].lmr_context, (DAPL_HASH_DATA *)&lmr);
2N/A
2N/A if (dat_status != DAT_SUCCESS) {
2N/A return (DAT_ERROR(DAT_INVALID_PARAMETER,
2N/A DAT_INVALID_ARG2));
2N/A }
2N/A
2N/A dat_status = dapl_mr_bounds_check(
2N/A dapl_mr_get_address(lmr->param.region_desc,
2N/A lmr->param.mem_type),
2N/A lmr->param.length,
2N/A lmr_triplet[i].virtual_address,
2N/A lmr_triplet[i].segment_length);
2N/A if (dat_status != DAT_TRUE) {
2N/A return (DAT_ERROR(DAT_INVALID_PARAMETER,
2N/A DAT_INVALID_ARG2));
2N/A }
2N/A args.mrs_vec[j].mrsv_hkey = lmr->mr_handle->mr_hkey;
2N/A args.mrs_vec[j].mrsv_va = lmr_triplet[i].virtual_address;
2N/A args.mrs_vec[j].mrsv_len = lmr_triplet[i].segment_length;
2N/A j = j + 1;
2N/A args.mrs_numseg = j;
2N/A if (j == DAPL_MR_PER_SYNC) {
2N/A j = 0;
2N/A retval = ioctl(ia_ptr->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_MR_SYNC, &args);
2N/A
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_lmr_sync: failed %s, retval %d\n",
2N/A strerror(errno), retval);
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A }
2N/A }
2N/A
2N/A if (j != 0) {
2N/A retval = ioctl(ia_ptr->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_MR_SYNC, &args);
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_lmr_sync: failed %s, retval %d\n",
2N/A strerror(errno), retval);
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A }
2N/A return (DAT_SUCCESS);
2N/A}