/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <malloc.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <sched.h>
#include <rsmapi.h>
#include <rsmlib_in.h>
/* lint -w2 */
extern rsm_node_id_t rsm_local_nodeid;
extern int loopback_getv(rsm_scat_gath_t *);
extern int loopback_putv(rsm_scat_gath_t *);
};
static int
"__rsm_import_connect: enter\n"));
"__rsm_import_connect: exit\n"));
return (RSM_SUCCESS);
}
static int
"__rsm_import_disconnect: enter\n"));
"__rsm_import_disconnect: exit\n"));
return (RSM_SUCCESS);
}
/*
* XXX: one day we ought to rewrite this stuff based on 64byte atomic access.
* We can have a new ops vector that makes that assumption.
*/
static int
{
uint_t i = 0;
int e;
"__rsm_import_get8x8: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_import_get8x8: exit\n"));
return (RSM_SUCCESS);
}
static int
{
/* LINTED */
uint_t i = 0;
int e;
"__rsm_import_get16x16: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_import_get16x16: exit\n"));
return (RSM_SUCCESS);
}
static int
{
/* LINTED */
uint_t i = 0;
int e;
"__rsm_import_get32x32: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_import_get32x32: exit\n"));
return (RSM_SUCCESS);
}
static int
{
/* LINTED */
uint_t i = 0;
int e;
"__rsm_import_get64x64: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_import_get64x64: exit\n"));
return (RSM_SUCCESS);
}
/*
* import side memory segment operations (write access functions):
*/
/*
* XXX: Each one of the following cases ought to be a separate function loaded
* into a segment access ops vector. We determine the correct function at
* segment connect time. When a new controller is register, we can decode
* it's direct_access_size attribute and load the correct function. For
* loop back we need to create a special ops vector that bypasses all of
* this stuff.
*
* XXX: We need to create a special interrupt queue for the library to handle
* partial writes in the remote process.
*/
static int
{
uint_t i = 0;
int e;
"__rsm_put8x8: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_put8x8: exit\n"));
return (RSM_SUCCESS);
}
static int
{
/* LINTED */
uint_t i = 0;
int e;
"__rsm_put16x16: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_put16x16: exit\n"));
return (RSM_SUCCESS);
}
static int
{
/* LINTED */
uint_t i = 0;
int e;
"__rsm_put32x32: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_put32x32: exit\n"));
return (RSM_SUCCESS);
}
static int
{
/* LINTED */
uint_t i = 0;
int e;
"__rsm_put64x64: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
for (i = 0; i < rep_cnt; i++) {
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_put64x64: exit\n"));
return (RSM_SUCCESS);
}
static int
{
int e;
"__rsm_get: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_get: exit\n"));
return (RSM_SUCCESS);
}
static int
{
int e, i;
"__rsm_getv: enter\n"));
/*
* Use loopback for single node operations.
* replace local handles with virtual addresses
*/
/*
* To use the loopback optimization map the segment
* here implicitly.
*/
im_seg_hndl->rsmseg_fd, 0);
if (va == MAP_FAILED) {
"implicit map failed:%d\n", errno));
return (RSMERR_BAD_MEM_ALIGNMENT);
return (RSMERR_BAD_LENGTH);
return (RSMERR_INSUFFICIENT_RESOURCES);
else
return (errno);
}
im_seg_hndl->rsmseg_mapoffset = 0;
}
else
for (i = 0; i < sg_io->io_request_count; i++) {
/* Get the surrogate export segment handle */
seg_hndl = (rsmseg_handle_t *)
}
l_iovec++;
}
e = loopback_getv(sg_io);
"__rsm_getv: exit\n"));
return (e);
}
/* for the Kernel Agent, replace local handles with segment ids */
else
for (i = 0; i < sg_io->io_request_count; i++) {
}
ka_iovec++;
}
if (e < 0) {
" RSM_IOCTL_GETV failed\n"));
return (errno);
}
"__rsm_getv: exit\n"));
return (RSM_SUCCESS);
}
static int
{
int e;
"__rsm_put: enter\n"));
if (e != RSM_SUCCESS) {
return (e);
}
}
length);
if (e != RSM_SUCCESS) {
return (e);
}
}
"__rsm_put: exit\n"));
return (RSM_SUCCESS);
}
static int
{
int e, i;
"__rsm_putv: enter\n"));
/*
* Use loopback for single node operations.
* replace local handles with virtual addresses
*/
/*
* To use the loopback optimization map the segment
* here implicitly.
*/
im_seg_hndl->rsmseg_fd, 0);
if (va == MAP_FAILED) {
"implicit map failed:%d\n", errno));
return (RSMERR_BAD_MEM_ALIGNMENT);
return (RSMERR_BAD_LENGTH);
return (RSMERR_INSUFFICIENT_RESOURCES);
else
return (errno);
}
im_seg_hndl->rsmseg_mapoffset = 0;
}
else
for (i = 0; i < sg_io->io_request_count; i++) {
/* Get the surrogate export segment handle */
seg_hndl = (rsmseg_handle_t *)
}
l_iovec++;
}
e = loopback_putv(sg_io);
"__rsm_putv: exit\n"));
return (e);
}
/* for the Kernel Agent, replace local handles with segment ids */
else
for (i = 0; i < sg_io->io_request_count; i++) {
}
ka_iovec++;
}
if (e < 0) {
" RSM_IOCTL_PUTV failed\n"));
return (errno);
}
"__rsm_putv: exit\n"));
return (RSM_SUCCESS);
}
/*
* import side memory segment operations (barriers):
*/
static int
{
""
"__rsm_memseg_import_init_barrier: enter\n"));
if (!seg) {
"invalid segment handle\n"));
return (RSMERR_BAD_SEG_HNDL);
}
if (!bar) {
"invalid barrier handle\n"));
return (RSMERR_BAD_BARRIER_PTR);
}
/* XXX: fix later. We only support span-of-node barriers */
"not enough memory\n"));
return (RSMERR_INSUFFICIENT_MEM);
}
"__rsm_memseg_import_init_barrier: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_memseg_import_open_barrier: enter\n"));
if (!bar) {
"invalid barrier pointer\n"));
return (RSMERR_BAD_BARRIER_PTR);
}
"uninitialized barrier\n"));
return (RSMERR_BARRIER_UNINITIALIZED);
}
/* lint -save -e718 -e746 */
RSM_IOCTL_BAR_OPEN, &msg) < 0) {
" RSM_IOCTL_BAR_OPEN failed\n"));
/* lint -restore */
return (RSMERR_BARRIER_OPEN_FAILED);
}
"__rsm_memseg_import_open_barrier: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_memseg_import_order_barrier: enter\n"));
if (!bar) {
"invalid barrier\n"));
return (RSMERR_BAD_BARRIER_PTR);
}
"uninitialized barrier\n"));
return (RSMERR_BARRIER_UNINITIALIZED);
}
"RSM_IOCTL_BAR_ORDER failed\n"));
return (RSMERR_BARRIER_FAILURE);
}
"__rsm_memseg_import_order_barrier: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_memseg_import_close_barrier: enter\n"));
if (!bar) {
"invalid barrier\n"));
return (RSMERR_BAD_BARRIER_PTR);
}
"uninitialized barrier\n"));
return (RSMERR_BARRIER_UNINITIALIZED);
}
" RSM_IOCTL_BAR_CLOSE failed\n"));
return (RSMERR_BARRIER_FAILURE);
}
"__rsm_memseg_import_close_barrier: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_memseg_import_destroy_barrier: enter\n"));
if (!bar) {
"invalid barrier\n"));
return (RSMERR_BAD_BARRIER_PTR);
}
"__rsm_memseg_import_destroy_barrier: exit\n"));
return (RSM_SUCCESS);
}
/* lint -w1 */
static int
{
"__rsm_memseg_import_get_mode: enter\n"));
"__rsm_memseg_import_get_mode: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_memseg_import_set_mode: enter\n"));
"__rsm_memseg_import_set_mode: exit\n"));
return (RSM_SUCCESS);
}
static int
{
int e;
"__rsm_create_memory_handle: enter\n"));
/*
* create a surrogate segment (local memory will be locked down).
*/
if (e != RSM_SUCCESS) {
"export create failed\n"));
return (e);
}
/*
* Publish the segment to the local node only. If the segment
* length is very large then don't publish to the adapter driver
* because that will consume too much DVMA space - this is indicated
* to the Kernel Agent using null permissions. DVMA binding will
* be done when the RDMA is set up.
*/
if (len > RSM_MAX_HANDLE_DVMA)
acl[0].ae_permission = 0;
else
if (e != RSM_SUCCESS) {
"export publish failed\n"));
return (e);
}
/* Use the surrogate seghandle as the local memory handle */
"__rsm_create_memory_handle: exit\n"));
return (e);
}
static int
{
"__rsm_free_memory_handle: enter\n"));
"__rsm_free_memory_handle: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_get_lib_attr: enter\n"));
*libattrp = &_rsm_genlib_attr;
"__rsm_get_lib_attr: exit\n"));
return (RSM_SUCCESS);
}
static int
{
"__rsm_closedevice: enter\n"));
"__rsm_closedevice: exit\n"));
return (RSM_SUCCESS);
}
void
{
"__rsmdefault_setops: enter\n"));
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
/* XXX: Need to support barrier functions */
}
}
}
}
}
}
}
}
}
"__rsmdefault_setops: exit\n"));
}