c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * This file contains definitions used in OFED defined user/kernel
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * interfaces. These are imported from the OFED header <linux/rds.h>. Oracle
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * elects to have and use the contents of <linux/rds.h> under and governed
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * by the OpenIB.org BSD license (see below for full license text). However,
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * the following notice accompanied the original version of this file:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright (c) 2008 Oracle. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * This software is available to you under a choice of one of two
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * licenses. You may choose to be licensed under the terms of the GNU
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * General Public License (GPL) Version 2, available from the file
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * COPYING in the main directory of this source tree, or the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * OpenIB.org BSD license below:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Redistribution and use in source and binary forms, with or
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * without modification, are permitted provided that the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * conditions are met:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - Redistributions of source code must retain the above
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * copyright notice, this list of conditions and the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * disclaimer.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - Redistributions in binary form must reproduce the above
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * copyright notice, this list of conditions and the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * disclaimer in the documentation and/or other materials
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * provided with the distribution.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * SOFTWARE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#ifndef _SYS_RDS_H
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define _SYS_RDS_H
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#ifdef __cplusplus
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otaextern "C" {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#if !(defined(__SVR4) && defined(__sun))
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#include <linux/types.h>
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#else
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#include <sys/types.h>
5d5562f583b2b6affe19bdce0b3c8b1840d667a4Eiji Ota#include <sys/socket.h>
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota/*
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota * These sparse annotated types shouldn't be in any user
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota * visible header file. We should clean this up rather
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota * than kludging around them.
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#if !(defined(__SVR4) && defined(__sun))
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#ifndef __KERNEL__
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define __be16 u_int16_t
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define __be32 u_int32_t
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define __be64 u_int64_t
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#endif
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define u_int8_t uint8_t
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define u_int16_t uint16_t
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define u_int32_t uint32_t
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define u_int64_t uint64_t
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define RDS_IB_ABI_VERSION 0x301
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define AF_RDS AF_INET_OFFLOAD
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define PF_RDS AF_INET_OFFLOAD
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define SOL_RDS 272
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * setsockopt/getsockopt for SOL_RDS
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CANCEL_SENT_TO 1
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_GET_MR 2
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_FREE_MR 3
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* deprecated: RDS_BARRIER 4 */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RECVERR 5
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CONG_MONITOR 6
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_GET_MR_FOR_DEST 7
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Control message types for SOL_RDS.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota * CMSG_RDMA_ARGS (sendmsg)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Request a RDMA transfer to/from the specified
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * memory ranges.
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota * The cmsg_data is a struct rds_rdma_args.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * RDS_CMSG_RDMA_DEST (recvmsg, sendmsg)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Kernel informs application about intended
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * source/destination of a RDMA transfer
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * RDS_CMSG_RDMA_MAP (sendmsg)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Application asks kernel to map the given
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * memory range into a IB MR, and send the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * R_Key along in an RDS extension header.
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota * The cmsg_data is a struct rds_get_mr_args,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * the same as for the GET_MR setsockopt.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * RDS_CMSG_RDMA_STATUS (recvmsg)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Returns the status of a completed RDMA operation.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CMSG_RDMA_ARGS 1
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CMSG_RDMA_DEST 2
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CMSG_RDMA_MAP 3
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CMSG_RDMA_STATUS 4
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CMSG_CONG_UPDATE 5
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_FIRST 10000
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_COUNTERS 10000
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_CONNECTIONS 10001
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* 10002 aka RDS_INFO_FLOWS is deprecated */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_SEND_MESSAGES 10003
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_RETRANS_MESSAGES 10004
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_RECV_MESSAGES 10005
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_SOCKETS 10006
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_TCP_SOCKETS 10007
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_IB_CONNECTIONS 10008
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_CONNECTION_STATS 10009
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_IWARP_CONNECTIONS 10010
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_LAST 10010
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#if defined(__SVR4) && defined(__sun)
b27516f55237249607f754e6e42e865f12456675agiristruct rds_info_arg {
b27516f55237249607f754e6e42e865f12456675agiri uint64_t lenp;
b27516f55237249607f754e6e42e865f12456675agiri uint64_t datap;
b27516f55237249607f754e6e42e865f12456675agiri};
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#endif
b27516f55237249607f754e6e42e865f12456675agiri
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef __lock_lint
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack(1)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_counter {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t name[32];
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t value;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_counter {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t name[32];
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t value;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_CONNECTION_FLAG_CONNECTED 0x04
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota#define TRANSNAMSIZ 16
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef __lock_lint
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack(1)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_connection {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t next_tx_seq;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t next_rx_seq;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t laddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t faddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t flags;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_connection {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t next_tx_seq;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t next_rx_seq;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t laddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t faddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t flags;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef __lock_lint
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack(1)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_flow {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t laddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t faddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t bytes;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t lport;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t fport;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_flow {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t laddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t faddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t bytes;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t lport;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t fport;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_MESSAGE_FLAG_ACK 0x01
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef __lock_lint
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack(1)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_message {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t seq;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t len;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t laddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t faddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t lport;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t fport;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t flags;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_message {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t seq;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t len;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t laddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t faddr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t lport;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t fport;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int8_t flags;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef __lock_lint
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack(1)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_socket {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t sndbuf;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t bound_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t connected_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t bound_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t connected_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t rcvbuf;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t inum;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_socket {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t sndbuf;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t bound_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t connected_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t bound_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t connected_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t rcvbuf;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t inum;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifndef __lock_lint
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack(1)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_tcp_socket {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t local_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t local_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t peer_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t peer_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t hdr_rem;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t data_rem;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t last_sent_nxt;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t last_expected_una;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t last_seen_una;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#pragma pack()
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#else
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_tcp_socket {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t local_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t local_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t peer_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int16_t peer_port;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t hdr_rem;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t data_rem;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t last_sent_nxt;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t last_expected_una;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t last_seen_una;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota} __attribute__((packed));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#define RDS_IB_GID_LEN 16
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_info_rdma_connection {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t src_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int32_t dst_addr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint8_t src_gid[RDS_IB_GID_LEN];
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint8_t dst_gid[RDS_IB_GID_LEN];
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_t max_send_wr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_t max_recv_wr;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_t max_send_sge;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_t rdma_mr_max;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint32_t rdma_mr_size;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota/*
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * Congestion monitoring.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * Congestion control in RDS happens at the host connection
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * level by exchanging a bitmap marking congested ports.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * By default, a process sleeping in poll() is always woken
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * up when the congestion map is updated.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * With explicit monitoring, an application can have more
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * fine-grained control.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * The application installs a 64bit mask value in the socket,
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * where each bit corresponds to a group of ports.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * When a congestion update arrives, RDS checks the set of
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * ports that are now uncongested against the list bit mask
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * installed in the socket, and if they overlap, we queue a
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * cong_notification on the socket.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota *
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * To install the congestion monitor bitmask, use RDS_CONG_MONITOR
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * with the 64bit mask.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * Congestion updates are received via RDS_CMSG_CONG_UPDATE
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * control messages.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota *
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * The correspondence between bits and ports is
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * 1 << (portnum % 64)
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CONG_MONITOR_SIZE 64
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CONG_MONITOR_BIT(port) \
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota (((unsigned int) port) % RDS_CONG_MONITOR_SIZE)
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_CONG_MONITOR_MASK(port) (1ULL << RDS_CONG_MONITOR_BIT(port))
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota/*
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * RDMA related types
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota */
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota/*
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * This encapsulates a remote memory location.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * In the current implementation, it contains the R_Key
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * of the remote memory region, and the offset into it
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * (so that the application does not have to worry about
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * alignment).
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otatypedef u_int64_t rds_rdma_cookie_t;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_iovec {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t bytes;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota};
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_get_mr_args {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota struct rds_iovec vec;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t cookie_addr;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota uint64_t flags;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota};
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_get_mr_for_dest_args {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota struct sockaddr_storage dest_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota struct rds_iovec vec;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t cookie_addr;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota uint64_t flags;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota};
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_free_mr_args {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota rds_rdma_cookie_t cookie;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t flags;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota};
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_rdma_args {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota rds_rdma_cookie_t cookie;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota struct rds_iovec remote_vec;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t local_vec_addr;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t nr_local;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t flags;
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t user_token;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota};
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Otastruct rds_rdma_notify {
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota u_int64_t user_token;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota int32_t status;
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota};
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_SUCCESS 0
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_REMOTE_ERROR 1
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_CANCELED 2
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_DROPPED 3
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_OTHER_ERROR 4
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota/*
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * Common set of flags for all RDMA related structs
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_READWRITE 0x0001
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_FENCE 0x0002 /* use FENCE for immediate send */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_INVALIDATE 0x0004 /* invalidate R_Key after freeing MR */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#ifdef __cplusplus
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota}
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#endif
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
fe817b6022080da0a98b5d2d8cd179f594d6ca5eEiji Ota#endif /* _SYS_RDS_H */