Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

89
include/rdma/ib.h Normal file
View file

@ -0,0 +1,89 @@
/*
* Copyright (c) 2010 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(_RDMA_IB_H)
#define _RDMA_IB_H
#include <linux/types.h>
struct ib_addr {
union {
__u8 uib_addr8[16];
__be16 uib_addr16[8];
__be32 uib_addr32[4];
__be64 uib_addr64[2];
} ib_u;
#define sib_addr8 ib_u.uib_addr8
#define sib_addr16 ib_u.uib_addr16
#define sib_addr32 ib_u.uib_addr32
#define sib_addr64 ib_u.uib_addr64
#define sib_raw ib_u.uib_addr8
#define sib_subnet_prefix ib_u.uib_addr64[0]
#define sib_interface_id ib_u.uib_addr64[1]
};
static inline int ib_addr_any(const struct ib_addr *a)
{
return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0);
}
static inline int ib_addr_loopback(const struct ib_addr *a)
{
return ((a->sib_addr32[0] | a->sib_addr32[1] |
a->sib_addr32[2] | (a->sib_addr32[3] ^ htonl(1))) == 0);
}
static inline void ib_addr_set(struct ib_addr *addr,
__be32 w1, __be32 w2, __be32 w3, __be32 w4)
{
addr->sib_addr32[0] = w1;
addr->sib_addr32[1] = w2;
addr->sib_addr32[2] = w3;
addr->sib_addr32[3] = w4;
}
static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2)
{
return memcmp(a1, a2, sizeof(struct ib_addr));
}
struct sockaddr_ib {
unsigned short int sib_family; /* AF_IB */
__be16 sib_pkey;
__be32 sib_flowinfo;
struct ib_addr sib_addr;
__be64 sib_sid;
__be64 sib_sid_mask;
__u64 sib_scope_id;
};
#endif /* _RDMA_IB_H */

312
include/rdma/ib_addr.h Normal file
View file

@ -0,0 +1,312 @@
/*
* Copyright (c) 2005 Voltaire Inc. All rights reserved.
* Copyright (c) 2005 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_ADDR_H)
#define IB_ADDR_H
#include <linux/in.h>
#include <linux/in6.h>
#include <linux/if_arp.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/socket.h>
#include <linux/if_vlan.h>
#include <net/ipv6.h>
#include <net/if_inet6.h>
#include <net/ip.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_pack.h>
#include <net/ipv6.h>
struct rdma_addr_client {
atomic_t refcount;
struct completion comp;
};
/**
* rdma_addr_register_client - Register an address client.
*/
void rdma_addr_register_client(struct rdma_addr_client *client);
/**
* rdma_addr_unregister_client - Deregister an address client.
* @client: Client object to deregister.
*/
void rdma_addr_unregister_client(struct rdma_addr_client *client);
struct rdma_dev_addr {
unsigned char src_dev_addr[MAX_ADDR_LEN];
unsigned char dst_dev_addr[MAX_ADDR_LEN];
unsigned char broadcast[MAX_ADDR_LEN];
unsigned short dev_type;
int bound_dev_if;
enum rdma_transport_type transport;
};
/**
* rdma_translate_ip - Translate a local IP address to an RDMA hardware
* address.
*/
int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr,
u16 *vlan_id);
/**
* rdma_resolve_ip - Resolve source and destination IP addresses to
* RDMA hardware addresses.
* @client: Address client associated with request.
* @src_addr: An optional source address to use in the resolution. If a
* source address is not provided, a usable address will be returned via
* the callback.
* @dst_addr: The destination address to resolve.
* @addr: A reference to a data location that will receive the resolved
* addresses. The data location must remain valid until the callback has
* been invoked.
* @timeout_ms: Amount of time to wait for the address resolution to complete.
* @callback: Call invoked once address resolution has completed, timed out,
* or been canceled. A status of 0 indicates success.
* @context: User-specified context associated with the call.
*/
int rdma_resolve_ip(struct rdma_addr_client *client,
struct sockaddr *src_addr, struct sockaddr *dst_addr,
struct rdma_dev_addr *addr, int timeout_ms,
void (*callback)(int status, struct sockaddr *src_addr,
struct rdma_dev_addr *addr, void *context),
void *context);
void rdma_addr_cancel(struct rdma_dev_addr *addr);
int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
const unsigned char *dst_dev_addr);
int rdma_addr_size(struct sockaddr *addr);
int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id);
int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *smac,
u16 *vlan_id);
static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
{
return ((u16)dev_addr->broadcast[8] << 8) | (u16)dev_addr->broadcast[9];
}
static inline void ib_addr_set_pkey(struct rdma_dev_addr *dev_addr, u16 pkey)
{
dev_addr->broadcast[8] = pkey >> 8;
dev_addr->broadcast[9] = (unsigned char) pkey;
}
static inline void ib_addr_get_mgid(struct rdma_dev_addr *dev_addr,
union ib_gid *gid)
{
memcpy(gid, dev_addr->broadcast + 4, sizeof *gid);
}
static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr)
{
return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0;
}
static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)
{
return dev->priv_flags & IFF_802_1Q_VLAN ?
vlan_dev_vlan_id(dev) : 0xffff;
}
static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid)
{
switch (addr->sa_family) {
case AF_INET:
ipv6_addr_set_v4mapped(((struct sockaddr_in *)
addr)->sin_addr.s_addr,
(struct in6_addr *)gid);
break;
case AF_INET6:
memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr, 16);
break;
default:
return -EINVAL;
}
return 0;
}
/* Important - sockaddr should be a union of sockaddr_in and sockaddr_in6 */
static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid)
{
if (ipv6_addr_v4mapped((struct in6_addr *)gid)) {
struct sockaddr_in *out_in = (struct sockaddr_in *)out;
memset(out_in, 0, sizeof(*out_in));
out_in->sin_family = AF_INET;
memcpy(&out_in->sin_addr.s_addr, gid->raw + 12, 4);
} else {
struct sockaddr_in6 *out_in = (struct sockaddr_in6 *)out;
memset(out_in, 0, sizeof(*out_in));
out_in->sin6_family = AF_INET6;
memcpy(&out_in->sin6_addr.s6_addr, gid->raw, 16);
}
return 0;
}
static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
union ib_gid *gid)
{
struct net_device *dev;
struct in_device *ip4;
dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
if (dev) {
ip4 = (struct in_device *)dev->ip_ptr;
if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
(struct in6_addr *)gid);
dev_put(dev);
}
}
static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
{
if (dev_addr->transport == RDMA_TRANSPORT_IB &&
dev_addr->dev_type != ARPHRD_INFINIBAND)
iboe_addr_get_sgid(dev_addr, gid);
else
memcpy(gid, dev_addr->src_dev_addr +
rdma_addr_gid_offset(dev_addr), sizeof *gid);
}
static inline void rdma_addr_set_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
{
memcpy(dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid);
}
static inline void rdma_addr_get_dgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
{
memcpy(gid, dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof *gid);
}
static inline void rdma_addr_set_dgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
{
memcpy(dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid);
}
static inline enum ib_mtu iboe_get_mtu(int mtu)
{
/*
* reduce IB headers from effective IBoE MTU. 28 stands for
* atomic header which is the biggest possible header after BTH
*/
mtu = mtu - IB_GRH_BYTES - IB_BTH_BYTES - 28;
if (mtu >= ib_mtu_enum_to_int(IB_MTU_4096))
return IB_MTU_4096;
else if (mtu >= ib_mtu_enum_to_int(IB_MTU_2048))
return IB_MTU_2048;
else if (mtu >= ib_mtu_enum_to_int(IB_MTU_1024))
return IB_MTU_1024;
else if (mtu >= ib_mtu_enum_to_int(IB_MTU_512))
return IB_MTU_512;
else if (mtu >= ib_mtu_enum_to_int(IB_MTU_256))
return IB_MTU_256;
else
return 0;
}
static inline int iboe_get_rate(struct net_device *dev)
{
struct ethtool_cmd cmd;
u32 speed;
int err;
rtnl_lock();
err = __ethtool_get_settings(dev, &cmd);
rtnl_unlock();
if (err)
return IB_RATE_PORT_CURRENT;
speed = ethtool_cmd_speed(&cmd);
if (speed >= 40000)
return IB_RATE_40_GBPS;
else if (speed >= 30000)
return IB_RATE_30_GBPS;
else if (speed >= 20000)
return IB_RATE_20_GBPS;
else if (speed >= 10000)
return IB_RATE_10_GBPS;
else
return IB_RATE_PORT_CURRENT;
}
static inline int rdma_link_local_addr(struct in6_addr *addr)
{
if (addr->s6_addr32[0] == htonl(0xfe800000) &&
addr->s6_addr32[1] == 0)
return 1;
return 0;
}
static inline void rdma_get_ll_mac(struct in6_addr *addr, u8 *mac)
{
memcpy(mac, &addr->s6_addr[8], 3);
memcpy(mac + 3, &addr->s6_addr[13], 3);
mac[0] ^= 2;
}
static inline int rdma_is_multicast_addr(struct in6_addr *addr)
{
return addr->s6_addr[0] == 0xff;
}
static inline void rdma_get_mcast_mac(struct in6_addr *addr, u8 *mac)
{
int i;
mac[0] = 0x33;
mac[1] = 0x33;
for (i = 2; i < 6; ++i)
mac[i] = addr->s6_addr[i + 10];
}
static inline u16 rdma_get_vlan_id(union ib_gid *dgid)
{
u16 vid;
vid = dgid->raw[11] << 8 | dgid->raw[12];
return vid < 0x1000 ? vid : 0xffff;
}
static inline struct net_device *rdma_vlan_dev_real_dev(const struct net_device *dev)
{
return dev->priv_flags & IFF_802_1Q_VLAN ?
vlan_dev_real_dev(dev) : NULL;
}
#endif /* IB_ADDR_H */

132
include/rdma/ib_cache.h Normal file
View file

@ -0,0 +1,132 @@
/*
* Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef _IB_CACHE_H
#define _IB_CACHE_H
#include <rdma/ib_verbs.h>
/**
* ib_get_cached_gid - Returns a cached GID table entry
* @device: The device to query.
* @port_num: The port number of the device to query.
* @index: The index into the cached GID table to query.
* @gid: The GID value found at the specified index.
*
* ib_get_cached_gid() fetches the specified GID table entry stored in
* the local software cache.
*/
int ib_get_cached_gid(struct ib_device *device,
u8 port_num,
int index,
union ib_gid *gid);
/**
* ib_find_cached_gid - Returns the port number and GID table index where
* a specified GID value occurs.
* @device: The device to query.
* @gid: The GID value to search for.
* @port_num: The port number of the device where the GID value was found.
* @index: The index into the cached GID table where the GID was found. This
* parameter may be NULL.
*
* ib_find_cached_gid() searches for the specified GID value in
* the local software cache.
*/
int ib_find_cached_gid(struct ib_device *device,
union ib_gid *gid,
u8 *port_num,
u16 *index);
/**
* ib_get_cached_pkey - Returns a cached PKey table entry
* @device: The device to query.
* @port_num: The port number of the device to query.
* @index: The index into the cached PKey table to query.
* @pkey: The PKey value found at the specified index.
*
* ib_get_cached_pkey() fetches the specified PKey table entry stored in
* the local software cache.
*/
int ib_get_cached_pkey(struct ib_device *device_handle,
u8 port_num,
int index,
u16 *pkey);
/**
* ib_find_cached_pkey - Returns the PKey table index where a specified
* PKey value occurs.
* @device: The device to query.
* @port_num: The port number of the device to search for the PKey.
* @pkey: The PKey value to search for.
* @index: The index into the cached PKey table where the PKey was found.
*
* ib_find_cached_pkey() searches the specified PKey table in
* the local software cache.
*/
int ib_find_cached_pkey(struct ib_device *device,
u8 port_num,
u16 pkey,
u16 *index);
/**
* ib_find_exact_cached_pkey - Returns the PKey table index where a specified
* PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
* @device: The device to query.
* @port_num: The port number of the device to search for the PKey.
* @pkey: The PKey value to search for.
* @index: The index into the cached PKey table where the PKey was found.
*
* ib_find_exact_cached_pkey() searches the specified PKey table in
* the local software cache.
*/
int ib_find_exact_cached_pkey(struct ib_device *device,
u8 port_num,
u16 pkey,
u16 *index);
/**
* ib_get_cached_lmc - Returns a cached lmc table entry
* @device: The device to query.
* @port_num: The port number of the device to query.
* @lmc: The lmc value for the specified port for that device.
*
* ib_get_cached_lmc() fetches the specified lmc table entry stored in
* the local software cache.
*/
int ib_get_cached_lmc(struct ib_device *device,
u8 port_num,
u8 *lmc);
#endif /* _IB_CACHE_H */

604
include/rdma/ib_cm.h Normal file
View file

@ -0,0 +1,604 @@
/*
* Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_CM_H)
#define IB_CM_H
#include <rdma/ib_mad.h>
#include <rdma/ib_sa.h>
/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */
extern struct class cm_class;
enum ib_cm_state {
IB_CM_IDLE,
IB_CM_LISTEN,
IB_CM_REQ_SENT,
IB_CM_REQ_RCVD,
IB_CM_MRA_REQ_SENT,
IB_CM_MRA_REQ_RCVD,
IB_CM_REP_SENT,
IB_CM_REP_RCVD,
IB_CM_MRA_REP_SENT,
IB_CM_MRA_REP_RCVD,
IB_CM_ESTABLISHED,
IB_CM_DREQ_SENT,
IB_CM_DREQ_RCVD,
IB_CM_TIMEWAIT,
IB_CM_SIDR_REQ_SENT,
IB_CM_SIDR_REQ_RCVD
};
enum ib_cm_lap_state {
IB_CM_LAP_UNINIT,
IB_CM_LAP_IDLE,
IB_CM_LAP_SENT,
IB_CM_LAP_RCVD,
IB_CM_MRA_LAP_SENT,
IB_CM_MRA_LAP_RCVD,
};
enum ib_cm_event_type {
IB_CM_REQ_ERROR,
IB_CM_REQ_RECEIVED,
IB_CM_REP_ERROR,
IB_CM_REP_RECEIVED,
IB_CM_RTU_RECEIVED,
IB_CM_USER_ESTABLISHED,
IB_CM_DREQ_ERROR,
IB_CM_DREQ_RECEIVED,
IB_CM_DREP_RECEIVED,
IB_CM_TIMEWAIT_EXIT,
IB_CM_MRA_RECEIVED,
IB_CM_REJ_RECEIVED,
IB_CM_LAP_ERROR,
IB_CM_LAP_RECEIVED,
IB_CM_APR_RECEIVED,
IB_CM_SIDR_REQ_ERROR,
IB_CM_SIDR_REQ_RECEIVED,
IB_CM_SIDR_REP_RECEIVED
};
enum ib_cm_data_size {
IB_CM_REQ_PRIVATE_DATA_SIZE = 92,
IB_CM_MRA_PRIVATE_DATA_SIZE = 222,
IB_CM_REJ_PRIVATE_DATA_SIZE = 148,
IB_CM_REP_PRIVATE_DATA_SIZE = 196,
IB_CM_RTU_PRIVATE_DATA_SIZE = 224,
IB_CM_DREQ_PRIVATE_DATA_SIZE = 220,
IB_CM_DREP_PRIVATE_DATA_SIZE = 224,
IB_CM_REJ_ARI_LENGTH = 72,
IB_CM_LAP_PRIVATE_DATA_SIZE = 168,
IB_CM_APR_PRIVATE_DATA_SIZE = 148,
IB_CM_APR_INFO_LENGTH = 72,
IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
IB_CM_SIDR_REP_INFO_LENGTH = 72,
IB_CM_COMPARE_SIZE = 64
};
struct ib_cm_id;
struct ib_cm_req_event_param {
struct ib_cm_id *listen_id;
u8 port;
struct ib_sa_path_rec *primary_path;
struct ib_sa_path_rec *alternate_path;
__be64 remote_ca_guid;
u32 remote_qkey;
u32 remote_qpn;
enum ib_qp_type qp_type;
u32 starting_psn;
u8 responder_resources;
u8 initiator_depth;
unsigned int local_cm_response_timeout:5;
unsigned int flow_control:1;
unsigned int remote_cm_response_timeout:5;
unsigned int retry_count:3;
unsigned int rnr_retry_count:3;
unsigned int srq:1;
};
struct ib_cm_rep_event_param {
__be64 remote_ca_guid;
u32 remote_qkey;
u32 remote_qpn;
u32 starting_psn;
u8 responder_resources;
u8 initiator_depth;
unsigned int target_ack_delay:5;
unsigned int failover_accepted:2;
unsigned int flow_control:1;
unsigned int rnr_retry_count:3;
unsigned int srq:1;
};
enum ib_cm_rej_reason {
IB_CM_REJ_NO_QP = 1,
IB_CM_REJ_NO_EEC = 2,
IB_CM_REJ_NO_RESOURCES = 3,
IB_CM_REJ_TIMEOUT = 4,
IB_CM_REJ_UNSUPPORTED = 5,
IB_CM_REJ_INVALID_COMM_ID = 6,
IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
IB_CM_REJ_INVALID_SERVICE_ID = 8,
IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
IB_CM_REJ_STALE_CONN = 10,
IB_CM_REJ_RDC_NOT_EXIST = 11,
IB_CM_REJ_INVALID_GID = 12,
IB_CM_REJ_INVALID_LID = 13,
IB_CM_REJ_INVALID_SL = 14,
IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
IB_CM_REJ_INVALID_HOP_LIMIT = 16,
IB_CM_REJ_INVALID_PACKET_RATE = 17,
IB_CM_REJ_INVALID_ALT_GID = 18,
IB_CM_REJ_INVALID_ALT_LID = 19,
IB_CM_REJ_INVALID_ALT_SL = 20,
IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
IB_CM_REJ_PORT_CM_REDIRECT = 24,
IB_CM_REJ_PORT_REDIRECT = 25,
IB_CM_REJ_INVALID_MTU = 26,
IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
IB_CM_REJ_CONSUMER_DEFINED = 28,
IB_CM_REJ_INVALID_RNR_RETRY = 29,
IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
IB_CM_REJ_INVALID_CLASS_VERSION = 31,
IB_CM_REJ_INVALID_FLOW_LABEL = 32,
IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33
};
struct ib_cm_rej_event_param {
enum ib_cm_rej_reason reason;
void *ari;
u8 ari_length;
};
struct ib_cm_mra_event_param {
u8 service_timeout;
};
struct ib_cm_lap_event_param {
struct ib_sa_path_rec *alternate_path;
};
enum ib_cm_apr_status {
IB_CM_APR_SUCCESS,
IB_CM_APR_INVALID_COMM_ID,
IB_CM_APR_UNSUPPORTED,
IB_CM_APR_REJECT,
IB_CM_APR_REDIRECT,
IB_CM_APR_IS_CURRENT,
IB_CM_APR_INVALID_QPN_EECN,
IB_CM_APR_INVALID_LID,
IB_CM_APR_INVALID_GID,
IB_CM_APR_INVALID_FLOW_LABEL,
IB_CM_APR_INVALID_TCLASS,
IB_CM_APR_INVALID_HOP_LIMIT,
IB_CM_APR_INVALID_PACKET_RATE,
IB_CM_APR_INVALID_SL
};
struct ib_cm_apr_event_param {
enum ib_cm_apr_status ap_status;
void *apr_info;
u8 info_len;
};
struct ib_cm_sidr_req_event_param {
struct ib_cm_id *listen_id;
u8 port;
u16 pkey;
};
enum ib_cm_sidr_status {
IB_SIDR_SUCCESS,
IB_SIDR_UNSUPPORTED,
IB_SIDR_REJECT,
IB_SIDR_NO_QP,
IB_SIDR_REDIRECT,
IB_SIDR_UNSUPPORTED_VERSION
};
struct ib_cm_sidr_rep_event_param {
enum ib_cm_sidr_status status;
u32 qkey;
u32 qpn;
void *info;
u8 info_len;
};
struct ib_cm_event {
enum ib_cm_event_type event;
union {
struct ib_cm_req_event_param req_rcvd;
struct ib_cm_rep_event_param rep_rcvd;
/* No data for RTU received events. */
struct ib_cm_rej_event_param rej_rcvd;
struct ib_cm_mra_event_param mra_rcvd;
struct ib_cm_lap_event_param lap_rcvd;
struct ib_cm_apr_event_param apr_rcvd;
/* No data for DREQ/DREP received events. */
struct ib_cm_sidr_req_event_param sidr_req_rcvd;
struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
enum ib_wc_status send_status;
} param;
void *private_data;
};
#define CM_REQ_ATTR_ID cpu_to_be16(0x0010)
#define CM_MRA_ATTR_ID cpu_to_be16(0x0011)
#define CM_REJ_ATTR_ID cpu_to_be16(0x0012)
#define CM_REP_ATTR_ID cpu_to_be16(0x0013)
#define CM_RTU_ATTR_ID cpu_to_be16(0x0014)
#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015)
#define CM_DREP_ATTR_ID cpu_to_be16(0x0016)
#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017)
#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018)
#define CM_LAP_ATTR_ID cpu_to_be16(0x0019)
#define CM_APR_ATTR_ID cpu_to_be16(0x001A)
/**
* ib_cm_handler - User-defined callback to process communication events.
* @cm_id: Communication identifier associated with the reported event.
* @event: Information about the communication event.
*
* IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
* generated as a result of listen requests result in the allocation of a
* new @cm_id. The new @cm_id is returned to the user through this callback.
* Clients are responsible for destroying the new @cm_id. For peer-to-peer
* IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
* to a user's existing communication identifier.
*
* Users may not call ib_destroy_cm_id while in the context of this callback;
* however, returning a non-zero value instructs the communication manager to
* destroy the @cm_id after the callback completes.
*/
typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
struct ib_cm_event *event);
struct ib_cm_id {
ib_cm_handler cm_handler;
void *context;
struct ib_device *device;
__be64 service_id;
__be64 service_mask;
enum ib_cm_state state; /* internal CM/debug use */
enum ib_cm_lap_state lap_state; /* internal CM/debug use */
__be32 local_id;
__be32 remote_id;
u32 remote_cm_qpn; /* 1 unless redirected */
};
/**
* ib_create_cm_id - Allocate a communication identifier.
* @device: Device associated with the cm_id. All related communication will
* be associated with the specified device.
* @cm_handler: Callback invoked to notify the user of CM events.
* @context: User specified context associated with the communication
* identifier.
*
* Communication identifiers are used to track connection states, service
* ID resolution requests, and listen requests.
*/
struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
ib_cm_handler cm_handler,
void *context);
/**
* ib_destroy_cm_id - Destroy a connection identifier.
* @cm_id: Connection identifier to destroy.
*
* This call blocks until the connection identifier is destroyed.
*/
void ib_destroy_cm_id(struct ib_cm_id *cm_id);
#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL)
#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL)
#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL)
#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL)
#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL)
#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
struct ib_cm_compare_data {
u8 data[IB_CM_COMPARE_SIZE];
u8 mask[IB_CM_COMPARE_SIZE];
};
/**
* ib_cm_listen - Initiates listening on the specified service ID for
* connection and service ID resolution requests.
* @cm_id: Connection identifier associated with the listen request.
* @service_id: Service identifier matched against incoming connection
* and service ID resolution requests. The service ID should be specified
* network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
* assign a service ID to the caller.
* @service_mask: Mask applied to service ID used to listen across a
* range of service IDs. If set to 0, the service ID is matched
* exactly. This parameter is ignored if %service_id is set to
* IB_CM_ASSIGN_SERVICE_ID.
* @compare_data: This parameter is optional. It specifies data that must
* appear in the private data of a connection request for the specified
* listen request.
*/
int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
struct ib_cm_compare_data *compare_data);
struct ib_cm_req_param {
struct ib_sa_path_rec *primary_path;
struct ib_sa_path_rec *alternate_path;
__be64 service_id;
u32 qp_num;
enum ib_qp_type qp_type;
u32 starting_psn;
const void *private_data;
u8 private_data_len;
u8 peer_to_peer;
u8 responder_resources;
u8 initiator_depth;
u8 remote_cm_response_timeout;
u8 flow_control;
u8 local_cm_response_timeout;
u8 retry_count;
u8 rnr_retry_count;
u8 max_cm_retries;
u8 srq;
};
/**
* ib_send_cm_req - Sends a connection request to the remote node.
* @cm_id: Connection identifier that will be associated with the
* connection request.
* @param: Connection request information needed to establish the
* connection.
*/
int ib_send_cm_req(struct ib_cm_id *cm_id,
struct ib_cm_req_param *param);
struct ib_cm_rep_param {
u32 qp_num;
u32 starting_psn;
const void *private_data;
u8 private_data_len;
u8 responder_resources;
u8 initiator_depth;
u8 failover_accepted;
u8 flow_control;
u8 rnr_retry_count;
u8 srq;
};
/**
* ib_send_cm_rep - Sends a connection reply in response to a connection
* request.
* @cm_id: Connection identifier that will be associated with the
* connection request.
* @param: Connection reply information needed to establish the
* connection.
*/
int ib_send_cm_rep(struct ib_cm_id *cm_id,
struct ib_cm_rep_param *param);
/**
* ib_send_cm_rtu - Sends a connection ready to use message in response
* to a connection reply message.
* @cm_id: Connection identifier associated with the connection request.
* @private_data: Optional user-defined private data sent with the
* ready to use message.
* @private_data_len: Size of the private data buffer, in bytes.
*/
int ib_send_cm_rtu(struct ib_cm_id *cm_id,
const void *private_data,
u8 private_data_len);
/**
* ib_send_cm_dreq - Sends a disconnection request for an existing
* connection.
* @cm_id: Connection identifier associated with the connection being
* released.
* @private_data: Optional user-defined private data sent with the
* disconnection request message.
* @private_data_len: Size of the private data buffer, in bytes.
*/
int ib_send_cm_dreq(struct ib_cm_id *cm_id,
const void *private_data,
u8 private_data_len);
/**
* ib_send_cm_drep - Sends a disconnection reply to a disconnection request.
* @cm_id: Connection identifier associated with the connection being
* released.
* @private_data: Optional user-defined private data sent with the
* disconnection reply message.
* @private_data_len: Size of the private data buffer, in bytes.
*
* If the cm_id is in the correct state, the CM will transition the connection
* to the timewait state, even if an error occurs sending the DREP message.
*/
int ib_send_cm_drep(struct ib_cm_id *cm_id,
const void *private_data,
u8 private_data_len);
/**
* ib_cm_notify - Notifies the CM of an event reported to the consumer.
* @cm_id: Connection identifier to transition to established.
* @event: Type of event.
*
* This routine should be invoked by users to notify the CM of relevant
* communication events. Events that should be reported to the CM and
* when to report them are:
*
* IB_EVENT_COMM_EST - Used when a message is received on a connected
* QP before an RTU has been received.
* IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
* to the alternate path.
*/
int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
/**
* ib_send_cm_rej - Sends a connection rejection message to the
* remote node.
* @cm_id: Connection identifier associated with the connection being
* rejected.
* @reason: Reason for the connection request rejection.
* @ari: Optional additional rejection information.
* @ari_length: Size of the additional rejection information, in bytes.
* @private_data: Optional user-defined private data sent with the
* rejection message.
* @private_data_len: Size of the private data buffer, in bytes.
*/
int ib_send_cm_rej(struct ib_cm_id *cm_id,
enum ib_cm_rej_reason reason,
void *ari,
u8 ari_length,
const void *private_data,
u8 private_data_len);
#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */
/**
* ib_send_cm_mra - Sends a message receipt acknowledgement to a connection
* message.
* @cm_id: Connection identifier associated with the connection message.
* @service_timeout: The lower 5-bits specify the maximum time required for
* the sender to reply to the connection message. The upper 3-bits
* specify additional control flags.
* @private_data: Optional user-defined private data sent with the
* message receipt acknowledgement.
* @private_data_len: Size of the private data buffer, in bytes.
*/
int ib_send_cm_mra(struct ib_cm_id *cm_id,
u8 service_timeout,
const void *private_data,
u8 private_data_len);
/**
* ib_send_cm_lap - Sends a load alternate path request.
* @cm_id: Connection identifier associated with the load alternate path
* message.
* @alternate_path: A path record that identifies the alternate path to
* load.
* @private_data: Optional user-defined private data sent with the
* load alternate path message.
* @private_data_len: Size of the private data buffer, in bytes.
*/
int ib_send_cm_lap(struct ib_cm_id *cm_id,
struct ib_sa_path_rec *alternate_path,
const void *private_data,
u8 private_data_len);
/**
* ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
* to a specified QP state.
* @cm_id: Communication identifier associated with the QP attributes to
* initialize.
* @qp_attr: On input, specifies the desired QP state. On output, the
* mandatory and desired optional attributes will be set in order to
* modify the QP to the specified state.
* @qp_attr_mask: The QP attribute mask that may be used to transition the
* QP to the specified state.
*
* Users must set the @qp_attr->qp_state to the desired QP state. This call
* will set all required attributes for the given transition, along with
* known optional attributes. Users may override the attributes returned from
* this call before calling ib_modify_qp.
*/
int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
struct ib_qp_attr *qp_attr,
int *qp_attr_mask);
/**
* ib_send_cm_apr - Sends an alternate path response message in response to
* a load alternate path request.
* @cm_id: Connection identifier associated with the alternate path response.
* @status: Reply status sent with the alternate path response.
* @info: Optional additional information sent with the alternate path
* response.
* @info_length: Size of the additional information, in bytes.
* @private_data: Optional user-defined private data sent with the
* alternate path response message.
* @private_data_len: Size of the private data buffer, in bytes.
*/
int ib_send_cm_apr(struct ib_cm_id *cm_id,
enum ib_cm_apr_status status,
void *info,
u8 info_length,
const void *private_data,
u8 private_data_len);
struct ib_cm_sidr_req_param {
struct ib_sa_path_rec *path;
__be64 service_id;
int timeout_ms;
const void *private_data;
u8 private_data_len;
u8 max_cm_retries;
};
/**
* ib_send_cm_sidr_req - Sends a service ID resolution request to the
* remote node.
* @cm_id: Communication identifier that will be associated with the
* service ID resolution request.
* @param: Service ID resolution request information.
*/
int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
struct ib_cm_sidr_req_param *param);
struct ib_cm_sidr_rep_param {
u32 qp_num;
u32 qkey;
enum ib_cm_sidr_status status;
const void *info;
u8 info_length;
const void *private_data;
u8 private_data_len;
};
/**
* ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
* remote node.
* @cm_id: Communication identifier associated with the received service ID
* resolution request.
* @param: Service ID resolution reply information.
*/
int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
struct ib_cm_sidr_rep_param *param);
#endif /* IB_CM_H */

View file

@ -0,0 +1,93 @@
/*
* Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_FMR_POOL_H)
#define IB_FMR_POOL_H
#include <rdma/ib_verbs.h>
struct ib_fmr_pool;
/**
* struct ib_fmr_pool_param - Parameters for creating FMR pool
* @max_pages_per_fmr:Maximum number of pages per map request.
* @page_shift: Log2 of sizeof "pages" mapped by this fmr
* @access:Access flags for FMRs in pool.
* @pool_size:Number of FMRs to allocate for pool.
* @dirty_watermark:Flush is triggered when @dirty_watermark dirty
* FMRs are present.
* @flush_function:Callback called when unmapped FMRs are flushed and
* more FMRs are possibly available for mapping
* @flush_arg:Context passed to user's flush function.
* @cache:If set, FMRs may be reused after unmapping for identical map
* requests.
*/
struct ib_fmr_pool_param {
int max_pages_per_fmr;
int page_shift;
enum ib_access_flags access;
int pool_size;
int dirty_watermark;
void (*flush_function)(struct ib_fmr_pool *pool,
void *arg);
void *flush_arg;
unsigned cache:1;
};
struct ib_pool_fmr {
struct ib_fmr *fmr;
struct ib_fmr_pool *pool;
struct list_head list;
struct hlist_node cache_node;
int ref_count;
int remap_count;
u64 io_virtual_address;
int page_list_len;
u64 page_list[0];
};
struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
struct ib_fmr_pool_param *params);
void ib_destroy_fmr_pool(struct ib_fmr_pool *pool);
int ib_flush_fmr_pool(struct ib_fmr_pool *pool);
struct ib_pool_fmr *ib_fmr_pool_map_phys(struct ib_fmr_pool *pool_handle,
u64 *page_list,
int list_len,
u64 io_virtual_address);
int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr);
#endif /* IB_FMR_POOL_H */

680
include/rdma/ib_mad.h Normal file
View file

@ -0,0 +1,680 @@
/*
* Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
* Copyright (c) 2004 Infinicon Corporation. All rights reserved.
* Copyright (c) 2004 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2004-2006 Voltaire Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_MAD_H)
#define IB_MAD_H
#include <linux/list.h>
#include <rdma/ib_verbs.h>
#include <uapi/rdma/ib_user_mad.h>
/* Management base version */
#define IB_MGMT_BASE_VERSION 1
/* Management classes */
#define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01
#define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 0x81
#define IB_MGMT_CLASS_SUBN_ADM 0x03
#define IB_MGMT_CLASS_PERF_MGMT 0x04
#define IB_MGMT_CLASS_BM 0x05
#define IB_MGMT_CLASS_DEVICE_MGMT 0x06
#define IB_MGMT_CLASS_CM 0x07
#define IB_MGMT_CLASS_SNMP 0x08
#define IB_MGMT_CLASS_DEVICE_ADM 0x10
#define IB_MGMT_CLASS_BOOT_MGMT 0x11
#define IB_MGMT_CLASS_BIS 0x12
#define IB_MGMT_CLASS_CONG_MGMT 0x21
#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
#define IB_OPENIB_OUI (0x001405)
/* Management methods */
#define IB_MGMT_METHOD_GET 0x01
#define IB_MGMT_METHOD_SET 0x02
#define IB_MGMT_METHOD_GET_RESP 0x81
#define IB_MGMT_METHOD_SEND 0x03
#define IB_MGMT_METHOD_TRAP 0x05
#define IB_MGMT_METHOD_REPORT 0x06
#define IB_MGMT_METHOD_REPORT_RESP 0x86
#define IB_MGMT_METHOD_TRAP_REPRESS 0x07
#define IB_MGMT_METHOD_RESP 0x80
#define IB_BM_ATTR_MOD_RESP cpu_to_be32(1)
#define IB_MGMT_MAX_METHODS 128
/* MAD Status field bit masks */
#define IB_MGMT_MAD_STATUS_SUCCESS 0x0000
#define IB_MGMT_MAD_STATUS_BUSY 0x0001
#define IB_MGMT_MAD_STATUS_REDIRECT_REQD 0x0002
#define IB_MGMT_MAD_STATUS_BAD_VERSION 0x0004
#define IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD 0x0008
#define IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB 0x000c
#define IB_MGMT_MAD_STATUS_INVALID_ATTRIB_VALUE 0x001c
/* RMPP information */
#define IB_MGMT_RMPP_VERSION 1
#define IB_MGMT_RMPP_TYPE_DATA 1
#define IB_MGMT_RMPP_TYPE_ACK 2
#define IB_MGMT_RMPP_TYPE_STOP 3
#define IB_MGMT_RMPP_TYPE_ABORT 4
#define IB_MGMT_RMPP_FLAG_ACTIVE 1
#define IB_MGMT_RMPP_FLAG_FIRST (1<<1)
#define IB_MGMT_RMPP_FLAG_LAST (1<<2)
#define IB_MGMT_RMPP_NO_RESPTIME 0x1F
#define IB_MGMT_RMPP_STATUS_SUCCESS 0
#define IB_MGMT_RMPP_STATUS_RESX 1
#define IB_MGMT_RMPP_STATUS_ABORT_MIN 118
#define IB_MGMT_RMPP_STATUS_T2L 118
#define IB_MGMT_RMPP_STATUS_BAD_LEN 119
#define IB_MGMT_RMPP_STATUS_BAD_SEG 120
#define IB_MGMT_RMPP_STATUS_BADT 121
#define IB_MGMT_RMPP_STATUS_W2S 122
#define IB_MGMT_RMPP_STATUS_S2B 123
#define IB_MGMT_RMPP_STATUS_BAD_STATUS 124
#define IB_MGMT_RMPP_STATUS_UNV 125
#define IB_MGMT_RMPP_STATUS_TMR 126
#define IB_MGMT_RMPP_STATUS_UNSPEC 127
#define IB_MGMT_RMPP_STATUS_ABORT_MAX 127
#define IB_QP0 0
#define IB_QP1 cpu_to_be32(1)
#define IB_QP1_QKEY 0x80010000
#define IB_QP_SET_QKEY 0x80000000
#define IB_DEFAULT_PKEY_PARTIAL 0x7FFF
#define IB_DEFAULT_PKEY_FULL 0xFFFF
enum {
IB_MGMT_MAD_HDR = 24,
IB_MGMT_MAD_DATA = 232,
IB_MGMT_RMPP_HDR = 36,
IB_MGMT_RMPP_DATA = 220,
IB_MGMT_VENDOR_HDR = 40,
IB_MGMT_VENDOR_DATA = 216,
IB_MGMT_SA_HDR = 56,
IB_MGMT_SA_DATA = 200,
IB_MGMT_DEVICE_HDR = 64,
IB_MGMT_DEVICE_DATA = 192,
};
struct ib_mad_hdr {
u8 base_version;
u8 mgmt_class;
u8 class_version;
u8 method;
__be16 status;
__be16 class_specific;
__be64 tid;
__be16 attr_id;
__be16 resv;
__be32 attr_mod;
};
struct ib_rmpp_hdr {
u8 rmpp_version;
u8 rmpp_type;
u8 rmpp_rtime_flags;
u8 rmpp_status;
__be32 seg_num;
__be32 paylen_newwin;
};
typedef u64 __bitwise ib_sa_comp_mask;
#define IB_SA_COMP_MASK(n) ((__force ib_sa_comp_mask) cpu_to_be64(1ull << (n)))
/*
* ib_sa_hdr and ib_sa_mad structures must be packed because they have
* 64-bit fields that are only 32-bit aligned. 64-bit architectures will
* lay them out wrong otherwise. (And unfortunately they are sent on
* the wire so we can't change the layout)
*/
struct ib_sa_hdr {
__be64 sm_key;
__be16 attr_offset;
__be16 reserved;
ib_sa_comp_mask comp_mask;
} __attribute__ ((packed));
struct ib_mad {
struct ib_mad_hdr mad_hdr;
u8 data[IB_MGMT_MAD_DATA];
};
struct ib_rmpp_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
u8 data[IB_MGMT_RMPP_DATA];
};
struct ib_sa_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
struct ib_sa_hdr sa_hdr;
u8 data[IB_MGMT_SA_DATA];
} __attribute__ ((packed));
struct ib_vendor_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
u8 reserved;
u8 oui[3];
u8 data[IB_MGMT_VENDOR_DATA];
};
struct ib_class_port_info {
u8 base_version;
u8 class_version;
__be16 capability_mask;
u8 reserved[3];
u8 resp_time_value;
u8 redirect_gid[16];
__be32 redirect_tcslfl;
__be16 redirect_lid;
__be16 redirect_pkey;
__be32 redirect_qp;
__be32 redirect_qkey;
u8 trap_gid[16];
__be32 trap_tcslfl;
__be16 trap_lid;
__be16 trap_pkey;
__be32 trap_hlqp;
__be32 trap_qkey;
};
/**
* ib_mad_send_buf - MAD data buffer and work request for sends.
* @next: A pointer used to chain together MADs for posting.
* @mad: References an allocated MAD data buffer for MADs that do not have
* RMPP active. For MADs using RMPP, references the common and management
* class specific headers.
* @mad_agent: MAD agent that allocated the buffer.
* @ah: The address handle to use when sending the MAD.
* @context: User-controlled context fields.
* @hdr_len: Indicates the size of the data header of the MAD. This length
* includes the common MAD, RMPP, and class specific headers.
* @data_len: Indicates the total size of user-transferred data.
* @seg_count: The number of RMPP segments allocated for this send.
* @seg_size: Size of each RMPP segment.
* @timeout_ms: Time to wait for a response.
* @retries: Number of times to retry a request for a response. For MADs
* using RMPP, this applies per window. On completion, returns the number
* of retries needed to complete the transfer.
*
* Users are responsible for initializing the MAD buffer itself, with the
* exception of any RMPP header. Additional segment buffer space allocated
* beyond data_len is padding.
*/
struct ib_mad_send_buf {
struct ib_mad_send_buf *next;
void *mad;
struct ib_mad_agent *mad_agent;
struct ib_ah *ah;
void *context[2];
int hdr_len;
int data_len;
int seg_count;
int seg_size;
int timeout_ms;
int retries;
};
/**
* ib_response_mad - Returns if the specified MAD has been generated in
* response to a sent request or trap.
*/
int ib_response_mad(struct ib_mad *mad);
/**
* ib_get_rmpp_resptime - Returns the RMPP response time.
* @rmpp_hdr: An RMPP header.
*/
static inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr)
{
return rmpp_hdr->rmpp_rtime_flags >> 3;
}
/**
* ib_get_rmpp_flags - Returns the RMPP flags.
* @rmpp_hdr: An RMPP header.
*/
static inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr)
{
return rmpp_hdr->rmpp_rtime_flags & 0x7;
}
/**
* ib_set_rmpp_resptime - Sets the response time in an RMPP header.
* @rmpp_hdr: An RMPP header.
* @rtime: The response time to set.
*/
static inline void ib_set_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr, u8 rtime)
{
rmpp_hdr->rmpp_rtime_flags = ib_get_rmpp_flags(rmpp_hdr) | (rtime << 3);
}
/**
* ib_set_rmpp_flags - Sets the flags in an RMPP header.
* @rmpp_hdr: An RMPP header.
* @flags: The flags to set.
*/
static inline void ib_set_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr, u8 flags)
{
rmpp_hdr->rmpp_rtime_flags = (rmpp_hdr->rmpp_rtime_flags & 0xF8) |
(flags & 0x7);
}
struct ib_mad_agent;
struct ib_mad_send_wc;
struct ib_mad_recv_wc;
/**
* ib_mad_send_handler - callback handler for a sent MAD.
* @mad_agent: MAD agent that sent the MAD.
* @mad_send_wc: Send work completion information on the sent MAD.
*/
typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent,
struct ib_mad_send_wc *mad_send_wc);
/**
* ib_mad_snoop_handler - Callback handler for snooping sent MADs.
* @mad_agent: MAD agent that snooped the MAD.
* @send_wr: Work request information on the sent MAD.
* @mad_send_wc: Work completion information on the sent MAD. Valid
* only for snooping that occurs on a send completion.
*
* Clients snooping MADs should not modify data referenced by the @send_wr
* or @mad_send_wc.
*/
typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
struct ib_mad_send_buf *send_buf,
struct ib_mad_send_wc *mad_send_wc);
/**
* ib_mad_recv_handler - callback handler for a received MAD.
* @mad_agent: MAD agent requesting the received MAD.
* @mad_recv_wc: Received work completion information on the received MAD.
*
* MADs received in response to a send request operation will be handed to
* the user before the send operation completes. All data buffers given
* to registered agents through this routine are owned by the receiving
* client, except for snooping agents. Clients snooping MADs should not
* modify the data referenced by @mad_recv_wc.
*/
typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
struct ib_mad_recv_wc *mad_recv_wc);
/**
* ib_mad_agent - Used to track MAD registration with the access layer.
* @device: Reference to device registration is on.
* @qp: Reference to QP used for sending and receiving MADs.
* @mr: Memory region for system memory usable for DMA.
* @recv_handler: Callback handler for a received MAD.
* @send_handler: Callback handler for a sent MAD.
* @snoop_handler: Callback handler for snooped sent MADs.
* @context: User-specified context associated with this registration.
* @hi_tid: Access layer assigned transaction ID for this client.
* Unsolicited MADs sent by this client will have the upper 32-bits
* of their TID set to this value.
* @flags: registration flags
* @port_num: Port number on which QP is registered
* @rmpp_version: If set, indicates the RMPP version used by this agent.
*/
enum {
IB_MAD_USER_RMPP = IB_USER_MAD_USER_RMPP,
};
struct ib_mad_agent {
struct ib_device *device;
struct ib_qp *qp;
struct ib_mr *mr;
ib_mad_recv_handler recv_handler;
ib_mad_send_handler send_handler;
ib_mad_snoop_handler snoop_handler;
void *context;
u32 hi_tid;
u32 flags;
u8 port_num;
u8 rmpp_version;
};
/**
* ib_mad_send_wc - MAD send completion information.
* @send_buf: Send MAD data buffer associated with the send MAD request.
* @status: Completion status.
* @vendor_err: Optional vendor error information returned with a failed
* request.
*/
struct ib_mad_send_wc {
struct ib_mad_send_buf *send_buf;
enum ib_wc_status status;
u32 vendor_err;
};
/**
* ib_mad_recv_buf - received MAD buffer information.
* @list: Reference to next data buffer for a received RMPP MAD.
* @grh: References a data buffer containing the global route header.
* The data refereced by this buffer is only valid if the GRH is
* valid.
* @mad: References the start of the received MAD.
*/
struct ib_mad_recv_buf {
struct list_head list;
struct ib_grh *grh;
struct ib_mad *mad;
};
/**
* ib_mad_recv_wc - received MAD information.
* @wc: Completion information for the received data.
* @recv_buf: Specifies the location of the received data buffer(s).
* @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
* @mad_len: The length of the received MAD, without duplicated headers.
*
* For received response, the wr_id contains a pointer to the ib_mad_send_buf
* for the corresponding send request.
*/
struct ib_mad_recv_wc {
struct ib_wc *wc;
struct ib_mad_recv_buf recv_buf;
struct list_head rmpp_list;
int mad_len;
};
/**
* ib_mad_reg_req - MAD registration request
* @mgmt_class: Indicates which management class of MADs should be receive
* by the caller. This field is only required if the user wishes to
* receive unsolicited MADs, otherwise it should be 0.
* @mgmt_class_version: Indicates which version of MADs for the given
* management class to receive.
* @oui: Indicates IEEE OUI when mgmt_class is a vendor class
* in the range from 0x30 to 0x4f. Otherwise not used.
* @method_mask: The caller will receive unsolicited MADs for any method
* where @method_mask = 1.
*
*/
struct ib_mad_reg_req {
u8 mgmt_class;
u8 mgmt_class_version;
u8 oui[3];
DECLARE_BITMAP(method_mask, IB_MGMT_MAX_METHODS);
};
/**
* ib_register_mad_agent - Register to send/receive MADs.
* @device: The device to register with.
* @port_num: The port on the specified device to use.
* @qp_type: Specifies which QP to access. Must be either
* IB_QPT_SMI or IB_QPT_GSI.
* @mad_reg_req: Specifies which unsolicited MADs should be received
* by the caller. This parameter may be NULL if the caller only
* wishes to receive solicited responses.
* @rmpp_version: If set, indicates that the client will send
* and receive MADs that contain the RMPP header for the given version.
* If set to 0, indicates that RMPP is not used by this client.
* @send_handler: The completion callback routine invoked after a send
* request has completed.
* @recv_handler: The completion callback routine invoked for a received
* MAD.
* @context: User specified context associated with the registration.
* @registration_flags: Registration flags to set for this agent
*/
struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
u8 port_num,
enum ib_qp_type qp_type,
struct ib_mad_reg_req *mad_reg_req,
u8 rmpp_version,
ib_mad_send_handler send_handler,
ib_mad_recv_handler recv_handler,
void *context,
u32 registration_flags);
enum ib_mad_snoop_flags {
/*IB_MAD_SNOOP_POSTED_SENDS = 1,*/
/*IB_MAD_SNOOP_RMPP_SENDS = (1<<1),*/
IB_MAD_SNOOP_SEND_COMPLETIONS = (1<<2),
/*IB_MAD_SNOOP_RMPP_SEND_COMPLETIONS = (1<<3),*/
IB_MAD_SNOOP_RECVS = (1<<4)
/*IB_MAD_SNOOP_RMPP_RECVS = (1<<5),*/
/*IB_MAD_SNOOP_REDIRECTED_QPS = (1<<6)*/
};
/**
* ib_register_mad_snoop - Register to snoop sent and received MADs.
* @device: The device to register with.
* @port_num: The port on the specified device to use.
* @qp_type: Specifies which QP traffic to snoop. Must be either
* IB_QPT_SMI or IB_QPT_GSI.
* @mad_snoop_flags: Specifies information where snooping occurs.
* @send_handler: The callback routine invoked for a snooped send.
* @recv_handler: The callback routine invoked for a snooped receive.
* @context: User specified context associated with the registration.
*/
struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device,
u8 port_num,
enum ib_qp_type qp_type,
int mad_snoop_flags,
ib_mad_snoop_handler snoop_handler,
ib_mad_recv_handler recv_handler,
void *context);
/**
* ib_unregister_mad_agent - Unregisters a client from using MAD services.
* @mad_agent: Corresponding MAD registration request to deregister.
*
* After invoking this routine, MAD services are no longer usable by the
* client on the associated QP.
*/
int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
/**
* ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
* with the registered client.
* @send_buf: Specifies the information needed to send the MAD(s).
* @bad_send_buf: Specifies the MAD on which an error was encountered. This
* parameter is optional if only a single MAD is posted.
*
* Sent MADs are not guaranteed to complete in the order that they were posted.
*
* If the MAD requires RMPP, the data buffer should contain a single copy
* of the common MAD, RMPP, and class specific headers, followed by the class
* defined data. If the class defined data would not divide evenly into
* RMPP segments, then space must be allocated at the end of the referenced
* buffer for any required padding. To indicate the amount of class defined
* data being transferred, the paylen_newwin field in the RMPP header should
* be set to the size of the class specific header plus the amount of class
* defined data being transferred. The paylen_newwin field should be
* specified in network-byte order.
*/
int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
struct ib_mad_send_buf **bad_send_buf);
/**
* ib_free_recv_mad - Returns data buffers used to receive a MAD.
* @mad_recv_wc: Work completion information for a received MAD.
*
* Clients receiving MADs through their ib_mad_recv_handler must call this
* routine to return the work completion buffers to the access layer.
*/
void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc);
/**
* ib_cancel_mad - Cancels an outstanding send MAD operation.
* @mad_agent: Specifies the registration associated with sent MAD.
* @send_buf: Indicates the MAD to cancel.
*
* MADs will be returned to the user through the corresponding
* ib_mad_send_handler.
*/
void ib_cancel_mad(struct ib_mad_agent *mad_agent,
struct ib_mad_send_buf *send_buf);
/**
* ib_modify_mad - Modifies an outstanding send MAD operation.
* @mad_agent: Specifies the registration associated with sent MAD.
* @send_buf: Indicates the MAD to modify.
* @timeout_ms: New timeout value for sent MAD.
*
* This call will reset the timeout value for a sent MAD to the specified
* value.
*/
int ib_modify_mad(struct ib_mad_agent *mad_agent,
struct ib_mad_send_buf *send_buf, u32 timeout_ms);
/**
* ib_redirect_mad_qp - Registers a QP for MAD services.
* @qp: Reference to a QP that requires MAD services.
* @rmpp_version: If set, indicates that the client will send
* and receive MADs that contain the RMPP header for the given version.
* If set to 0, indicates that RMPP is not used by this client.
* @send_handler: The completion callback routine invoked after a send
* request has completed.
* @recv_handler: The completion callback routine invoked for a received
* MAD.
* @context: User specified context associated with the registration.
*
* Use of this call allows clients to use MAD services, such as RMPP,
* on user-owned QPs. After calling this routine, users may send
* MADs on the specified QP by calling ib_mad_post_send.
*/
struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
u8 rmpp_version,
ib_mad_send_handler send_handler,
ib_mad_recv_handler recv_handler,
void *context);
/**
* ib_process_mad_wc - Processes a work completion associated with a
* MAD sent or received on a redirected QP.
* @mad_agent: Specifies the registered MAD service using the redirected QP.
* @wc: References a work completion associated with a sent or received
* MAD segment.
*
* This routine is used to complete or continue processing on a MAD request.
* If the work completion is associated with a send operation, calling
* this routine is required to continue an RMPP transfer or to wait for a
* corresponding response, if it is a request. If the work completion is
* associated with a receive operation, calling this routine is required to
* process an inbound or outbound RMPP transfer, or to match a response MAD
* with its corresponding request.
*/
int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
struct ib_wc *wc);
/**
* ib_create_send_mad - Allocate and initialize a data buffer and work request
* for sending a MAD.
* @mad_agent: Specifies the registered MAD service to associate with the MAD.
* @remote_qpn: Specifies the QPN of the receiving node.
* @pkey_index: Specifies which PKey the MAD will be sent using. This field
* is valid only if the remote_qpn is QP 1.
* @rmpp_active: Indicates if the send will enable RMPP.
* @hdr_len: Indicates the size of the data header of the MAD. This length
* should include the common MAD header, RMPP header, plus any class
* specific header.
* @data_len: Indicates the size of any user-transferred data. The call will
* automatically adjust the allocated buffer size to account for any
* additional padding that may be necessary.
* @gfp_mask: GFP mask used for the memory allocation.
*
* This routine allocates a MAD for sending. The returned MAD send buffer
* will reference a data buffer usable for sending a MAD, along
* with an initialized work request structure. Users may modify the returned
* MAD data buffer before posting the send.
*
* The returned MAD header, class specific headers, and any padding will be
* cleared. Users are responsible for initializing the common MAD header,
* any class specific header, and MAD data area.
* If @rmpp_active is set, the RMPP header will be initialized for sending.
*/
struct ib_mad_send_buf *ib_create_send_mad(struct ib_mad_agent *mad_agent,
u32 remote_qpn, u16 pkey_index,
int rmpp_active,
int hdr_len, int data_len,
gfp_t gfp_mask);
/**
* ib_is_mad_class_rmpp - returns whether given management class
* supports RMPP.
* @mgmt_class: management class
*
* This routine returns whether the management class supports RMPP.
*/
int ib_is_mad_class_rmpp(u8 mgmt_class);
/**
* ib_get_mad_data_offset - returns the data offset for a given
* management class.
* @mgmt_class: management class
*
* This routine returns the data offset in the MAD for the management
* class requested.
*/
int ib_get_mad_data_offset(u8 mgmt_class);
/**
* ib_get_rmpp_segment - returns the data buffer for a given RMPP segment.
* @send_buf: Previously allocated send data buffer.
* @seg_num: number of segment to return
*
* This routine returns a pointer to the data buffer of an RMPP MAD.
* Users must provide synchronization to @send_buf around this call.
*/
void *ib_get_rmpp_segment(struct ib_mad_send_buf *send_buf, int seg_num);
/**
* ib_free_send_mad - Returns data buffers used to send a MAD.
* @send_buf: Previously allocated send data buffer.
*/
void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
/**
* ib_mad_kernel_rmpp_agent - Returns if the agent is performing RMPP.
* @agent: the agent in question
* @return: true if agent is performing rmpp, false otherwise.
*/
int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent);
#endif /* IB_MAD_H */

View file

@ -0,0 +1,53 @@
/*
* Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_USER_MARSHALL_H)
#define IB_USER_MARSHALL_H
#include <rdma/ib_verbs.h>
#include <rdma/ib_sa.h>
#include <rdma/ib_user_verbs.h>
#include <rdma/ib_user_sa.h>
void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
struct ib_qp_attr *src);
void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
struct ib_ah_attr *src);
void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
struct ib_sa_path_rec *src);
void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
struct ib_user_path_rec *src);
#endif /* IB_USER_MARSHALL_H */

268
include/rdma/ib_pack.h Normal file
View file

@ -0,0 +1,268 @@
/*
* Copyright (c) 2004 Topspin Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef IB_PACK_H
#define IB_PACK_H
#include <rdma/ib_verbs.h>
#include <uapi/linux/if_ether.h>
enum {
IB_LRH_BYTES = 8,
IB_ETH_BYTES = 14,
IB_VLAN_BYTES = 4,
IB_GRH_BYTES = 40,
IB_BTH_BYTES = 12,
IB_DETH_BYTES = 8
};
struct ib_field {
size_t struct_offset_bytes;
size_t struct_size_bytes;
int offset_words;
int offset_bits;
int size_bits;
char *field_name;
};
#define RESERVED \
.field_name = "reserved"
/*
* This macro cleans up the definitions of constants for BTH opcodes.
* It is used to define constants such as IB_OPCODE_UD_SEND_ONLY,
* which becomes IB_OPCODE_UD + IB_OPCODE_SEND_ONLY, and this gives
* the correct value.
*
* In short, user code should use the constants defined using the
* macro rather than worrying about adding together other constants.
*/
#define IB_OPCODE(transport, op) \
IB_OPCODE_ ## transport ## _ ## op = \
IB_OPCODE_ ## transport + IB_OPCODE_ ## op
enum {
/* transport types -- just used to define real constants */
IB_OPCODE_RC = 0x00,
IB_OPCODE_UC = 0x20,
IB_OPCODE_RD = 0x40,
IB_OPCODE_UD = 0x60,
/* operations -- just used to define real constants */
IB_OPCODE_SEND_FIRST = 0x00,
IB_OPCODE_SEND_MIDDLE = 0x01,
IB_OPCODE_SEND_LAST = 0x02,
IB_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03,
IB_OPCODE_SEND_ONLY = 0x04,
IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05,
IB_OPCODE_RDMA_WRITE_FIRST = 0x06,
IB_OPCODE_RDMA_WRITE_MIDDLE = 0x07,
IB_OPCODE_RDMA_WRITE_LAST = 0x08,
IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09,
IB_OPCODE_RDMA_WRITE_ONLY = 0x0a,
IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b,
IB_OPCODE_RDMA_READ_REQUEST = 0x0c,
IB_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d,
IB_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e,
IB_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f,
IB_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10,
IB_OPCODE_ACKNOWLEDGE = 0x11,
IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12,
IB_OPCODE_COMPARE_SWAP = 0x13,
IB_OPCODE_FETCH_ADD = 0x14,
/* real constants follow -- see comment about above IB_OPCODE()
macro for more details */
/* RC */
IB_OPCODE(RC, SEND_FIRST),
IB_OPCODE(RC, SEND_MIDDLE),
IB_OPCODE(RC, SEND_LAST),
IB_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE),
IB_OPCODE(RC, SEND_ONLY),
IB_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE),
IB_OPCODE(RC, RDMA_WRITE_FIRST),
IB_OPCODE(RC, RDMA_WRITE_MIDDLE),
IB_OPCODE(RC, RDMA_WRITE_LAST),
IB_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
IB_OPCODE(RC, RDMA_WRITE_ONLY),
IB_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
IB_OPCODE(RC, RDMA_READ_REQUEST),
IB_OPCODE(RC, RDMA_READ_RESPONSE_FIRST),
IB_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE),
IB_OPCODE(RC, RDMA_READ_RESPONSE_LAST),
IB_OPCODE(RC, RDMA_READ_RESPONSE_ONLY),
IB_OPCODE(RC, ACKNOWLEDGE),
IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
IB_OPCODE(RC, COMPARE_SWAP),
IB_OPCODE(RC, FETCH_ADD),
/* UC */
IB_OPCODE(UC, SEND_FIRST),
IB_OPCODE(UC, SEND_MIDDLE),
IB_OPCODE(UC, SEND_LAST),
IB_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE),
IB_OPCODE(UC, SEND_ONLY),
IB_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE),
IB_OPCODE(UC, RDMA_WRITE_FIRST),
IB_OPCODE(UC, RDMA_WRITE_MIDDLE),
IB_OPCODE(UC, RDMA_WRITE_LAST),
IB_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
IB_OPCODE(UC, RDMA_WRITE_ONLY),
IB_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
/* RD */
IB_OPCODE(RD, SEND_FIRST),
IB_OPCODE(RD, SEND_MIDDLE),
IB_OPCODE(RD, SEND_LAST),
IB_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE),
IB_OPCODE(RD, SEND_ONLY),
IB_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE),
IB_OPCODE(RD, RDMA_WRITE_FIRST),
IB_OPCODE(RD, RDMA_WRITE_MIDDLE),
IB_OPCODE(RD, RDMA_WRITE_LAST),
IB_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE),
IB_OPCODE(RD, RDMA_WRITE_ONLY),
IB_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
IB_OPCODE(RD, RDMA_READ_REQUEST),
IB_OPCODE(RD, RDMA_READ_RESPONSE_FIRST),
IB_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE),
IB_OPCODE(RD, RDMA_READ_RESPONSE_LAST),
IB_OPCODE(RD, RDMA_READ_RESPONSE_ONLY),
IB_OPCODE(RD, ACKNOWLEDGE),
IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
IB_OPCODE(RD, COMPARE_SWAP),
IB_OPCODE(RD, FETCH_ADD),
/* UD */
IB_OPCODE(UD, SEND_ONLY),
IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
};
enum {
IB_LNH_RAW = 0,
IB_LNH_IP = 1,
IB_LNH_IBA_LOCAL = 2,
IB_LNH_IBA_GLOBAL = 3
};
struct ib_unpacked_lrh {
u8 virtual_lane;
u8 link_version;
u8 service_level;
u8 link_next_header;
__be16 destination_lid;
__be16 packet_length;
__be16 source_lid;
};
struct ib_unpacked_grh {
u8 ip_version;
u8 traffic_class;
__be32 flow_label;
__be16 payload_length;
u8 next_header;
u8 hop_limit;
union ib_gid source_gid;
union ib_gid destination_gid;
};
struct ib_unpacked_bth {
u8 opcode;
u8 solicited_event;
u8 mig_req;
u8 pad_count;
u8 transport_header_version;
__be16 pkey;
__be32 destination_qpn;
u8 ack_req;
__be32 psn;
};
struct ib_unpacked_deth {
__be32 qkey;
__be32 source_qpn;
};
struct ib_unpacked_eth {
u8 dmac_h[4];
u8 dmac_l[2];
u8 smac_h[2];
u8 smac_l[4];
__be16 type;
};
struct ib_unpacked_vlan {
__be16 tag;
__be16 type;
};
struct ib_ud_header {
int lrh_present;
struct ib_unpacked_lrh lrh;
int eth_present;
struct ib_unpacked_eth eth;
int vlan_present;
struct ib_unpacked_vlan vlan;
int grh_present;
struct ib_unpacked_grh grh;
struct ib_unpacked_bth bth;
struct ib_unpacked_deth deth;
int immediate_present;
__be32 immediate_data;
};
void ib_pack(const struct ib_field *desc,
int desc_len,
void *structure,
void *buf);
void ib_unpack(const struct ib_field *desc,
int desc_len,
void *buf,
void *structure);
void ib_ud_header_init(int payload_bytes,
int lrh_present,
int eth_present,
int vlan_present,
int grh_present,
int immediate_present,
struct ib_ud_header *header);
int ib_ud_header_pack(struct ib_ud_header *header,
void *buf);
int ib_ud_header_unpack(void *buf,
struct ib_ud_header *header);
#endif /* IB_PACK_H */

156
include/rdma/ib_pma.h Normal file
View file

@ -0,0 +1,156 @@
/*
* Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
* All rights reserved.
* Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_PMA_H)
#define IB_PMA_H
#include <rdma/ib_mad.h>
/*
* PMA class portinfo capability mask bits
*/
#define IB_PMA_CLASS_CAP_ALLPORTSELECT cpu_to_be16(1 << 8)
#define IB_PMA_CLASS_CAP_EXT_WIDTH cpu_to_be16(1 << 9)
#define IB_PMA_CLASS_CAP_XMIT_WAIT cpu_to_be16(1 << 12)
#define IB_PMA_CLASS_PORT_INFO cpu_to_be16(0x0001)
#define IB_PMA_PORT_SAMPLES_CONTROL cpu_to_be16(0x0010)
#define IB_PMA_PORT_SAMPLES_RESULT cpu_to_be16(0x0011)
#define IB_PMA_PORT_COUNTERS cpu_to_be16(0x0012)
#define IB_PMA_PORT_COUNTERS_EXT cpu_to_be16(0x001D)
#define IB_PMA_PORT_SAMPLES_RESULT_EXT cpu_to_be16(0x001E)
struct ib_pma_mad {
struct ib_mad_hdr mad_hdr;
u8 reserved[40];
u8 data[192];
} __packed;
struct ib_pma_portsamplescontrol {
u8 opcode;
u8 port_select;
u8 tick;
u8 counter_width; /* resv: 7:3, counter width: 2:0 */
__be32 counter_mask0_9; /* 2, 10 3-bit fields */
__be16 counter_mask10_14; /* 1, 5 3-bit fields */
u8 sample_mechanisms;
u8 sample_status; /* only lower 2 bits */
__be64 option_mask;
__be64 vendor_mask;
__be32 sample_start;
__be32 sample_interval;
__be16 tag;
__be16 counter_select[15];
__be32 reserved1;
__be64 samples_only_option_mask;
__be32 reserved2[28];
};
struct ib_pma_portsamplesresult {
__be16 tag;
__be16 sample_status; /* only lower 2 bits */
__be32 counter[15];
};
struct ib_pma_portsamplesresult_ext {
__be16 tag;
__be16 sample_status; /* only lower 2 bits */
__be32 extended_width; /* only upper 2 bits */
__be64 counter[15];
};
struct ib_pma_portcounters {
u8 reserved;
u8 port_select;
__be16 counter_select;
__be16 symbol_error_counter;
u8 link_error_recovery_counter;
u8 link_downed_counter;
__be16 port_rcv_errors;
__be16 port_rcv_remphys_errors;
__be16 port_rcv_switch_relay_errors;
__be16 port_xmit_discards;
u8 port_xmit_constraint_errors;
u8 port_rcv_constraint_errors;
u8 reserved1;
u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
__be16 reserved2;
__be16 vl15_dropped;
__be32 port_xmit_data;
__be32 port_rcv_data;
__be32 port_xmit_packets;
__be32 port_rcv_packets;
__be32 port_xmit_wait;
} __packed;
#define IB_PMA_SEL_SYMBOL_ERROR cpu_to_be16(0x0001)
#define IB_PMA_SEL_LINK_ERROR_RECOVERY cpu_to_be16(0x0002)
#define IB_PMA_SEL_LINK_DOWNED cpu_to_be16(0x0004)
#define IB_PMA_SEL_PORT_RCV_ERRORS cpu_to_be16(0x0008)
#define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS cpu_to_be16(0x0010)
#define IB_PMA_SEL_PORT_XMIT_DISCARDS cpu_to_be16(0x0040)
#define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS cpu_to_be16(0x0200)
#define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS cpu_to_be16(0x0400)
#define IB_PMA_SEL_PORT_VL15_DROPPED cpu_to_be16(0x0800)
#define IB_PMA_SEL_PORT_XMIT_DATA cpu_to_be16(0x1000)
#define IB_PMA_SEL_PORT_RCV_DATA cpu_to_be16(0x2000)
#define IB_PMA_SEL_PORT_XMIT_PACKETS cpu_to_be16(0x4000)
#define IB_PMA_SEL_PORT_RCV_PACKETS cpu_to_be16(0x8000)
struct ib_pma_portcounters_ext {
u8 reserved;
u8 port_select;
__be16 counter_select;
__be32 reserved1;
__be64 port_xmit_data;
__be64 port_rcv_data;
__be64 port_xmit_packets;
__be64 port_rcv_packets;
__be64 port_unicast_xmit_packets;
__be64 port_unicast_rcv_packets;
__be64 port_multicast_xmit_packets;
__be64 port_multicast_rcv_packets;
} __packed;
#define IB_PMA_SELX_PORT_XMIT_DATA cpu_to_be16(0x0001)
#define IB_PMA_SELX_PORT_RCV_DATA cpu_to_be16(0x0002)
#define IB_PMA_SELX_PORT_XMIT_PACKETS cpu_to_be16(0x0004)
#define IB_PMA_SELX_PORT_RCV_PACKETS cpu_to_be16(0x0008)
#define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS cpu_to_be16(0x0010)
#define IB_PMA_SELX_PORT_UNI_RCV_PACKETS cpu_to_be16(0x0020)
#define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS cpu_to_be16(0x0040)
#define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS cpu_to_be16(0x0080)
#endif /* IB_PMA_H */

431
include/rdma/ib_sa.h Normal file
View file

@ -0,0 +1,431 @@
/*
* Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Voltaire, Inc. All rights reserved.
* Copyright (c) 2006 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef IB_SA_H
#define IB_SA_H
#include <linux/completion.h>
#include <linux/compiler.h>
#include <linux/atomic.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_mad.h>
enum {
IB_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */
IB_SA_METHOD_GET_TABLE = 0x12,
IB_SA_METHOD_GET_TABLE_RESP = 0x92,
IB_SA_METHOD_DELETE = 0x15,
IB_SA_METHOD_DELETE_RESP = 0x95,
IB_SA_METHOD_GET_MULTI = 0x14,
IB_SA_METHOD_GET_MULTI_RESP = 0x94,
IB_SA_METHOD_GET_TRACE_TBL = 0x13
};
enum {
IB_SA_ATTR_CLASS_PORTINFO = 0x01,
IB_SA_ATTR_NOTICE = 0x02,
IB_SA_ATTR_INFORM_INFO = 0x03,
IB_SA_ATTR_NODE_REC = 0x11,
IB_SA_ATTR_PORT_INFO_REC = 0x12,
IB_SA_ATTR_SL2VL_REC = 0x13,
IB_SA_ATTR_SWITCH_REC = 0x14,
IB_SA_ATTR_LINEAR_FDB_REC = 0x15,
IB_SA_ATTR_RANDOM_FDB_REC = 0x16,
IB_SA_ATTR_MCAST_FDB_REC = 0x17,
IB_SA_ATTR_SM_INFO_REC = 0x18,
IB_SA_ATTR_LINK_REC = 0x20,
IB_SA_ATTR_GUID_INFO_REC = 0x30,
IB_SA_ATTR_SERVICE_REC = 0x31,
IB_SA_ATTR_PARTITION_REC = 0x33,
IB_SA_ATTR_PATH_REC = 0x35,
IB_SA_ATTR_VL_ARB_REC = 0x36,
IB_SA_ATTR_MC_MEMBER_REC = 0x38,
IB_SA_ATTR_TRACE_REC = 0x39,
IB_SA_ATTR_MULTI_PATH_REC = 0x3a,
IB_SA_ATTR_SERVICE_ASSOC_REC = 0x3b,
IB_SA_ATTR_INFORM_INFO_REC = 0xf3
};
enum ib_sa_selector {
IB_SA_GT = 0,
IB_SA_LT = 1,
IB_SA_EQ = 2,
/*
* The meaning of "best" depends on the attribute: for
* example, for MTU best will return the largest available
* MTU, while for packet life time, best will return the
* smallest available life time.
*/
IB_SA_BEST = 3
};
/*
* Structures for SA records are named "struct ib_sa_xxx_rec." No
* attempt is made to pack structures to match the physical layout of
* SA records in SA MADs; all packing and unpacking is handled by the
* SA query code.
*
* For a record with structure ib_sa_xxx_rec, the naming convention
* for the component mask value for field yyy is IB_SA_XXX_REC_YYY (we
* never use different abbreviations or otherwise change the spelling
* of xxx/yyy between ib_sa_xxx_rec.yyy and IB_SA_XXX_REC_YYY).
*
* Reserved rows are indicated with comments to help maintainability.
*/
#define IB_SA_PATH_REC_SERVICE_ID (IB_SA_COMP_MASK( 0) |\
IB_SA_COMP_MASK( 1))
#define IB_SA_PATH_REC_DGID IB_SA_COMP_MASK( 2)
#define IB_SA_PATH_REC_SGID IB_SA_COMP_MASK( 3)
#define IB_SA_PATH_REC_DLID IB_SA_COMP_MASK( 4)
#define IB_SA_PATH_REC_SLID IB_SA_COMP_MASK( 5)
#define IB_SA_PATH_REC_RAW_TRAFFIC IB_SA_COMP_MASK( 6)
/* reserved: 7 */
#define IB_SA_PATH_REC_FLOW_LABEL IB_SA_COMP_MASK( 8)
#define IB_SA_PATH_REC_HOP_LIMIT IB_SA_COMP_MASK( 9)
#define IB_SA_PATH_REC_TRAFFIC_CLASS IB_SA_COMP_MASK(10)
#define IB_SA_PATH_REC_REVERSIBLE IB_SA_COMP_MASK(11)
#define IB_SA_PATH_REC_NUMB_PATH IB_SA_COMP_MASK(12)
#define IB_SA_PATH_REC_PKEY IB_SA_COMP_MASK(13)
#define IB_SA_PATH_REC_QOS_CLASS IB_SA_COMP_MASK(14)
#define IB_SA_PATH_REC_SL IB_SA_COMP_MASK(15)
#define IB_SA_PATH_REC_MTU_SELECTOR IB_SA_COMP_MASK(16)
#define IB_SA_PATH_REC_MTU IB_SA_COMP_MASK(17)
#define IB_SA_PATH_REC_RATE_SELECTOR IB_SA_COMP_MASK(18)
#define IB_SA_PATH_REC_RATE IB_SA_COMP_MASK(19)
#define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20)
#define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21)
#define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22)
struct ib_sa_path_rec {
__be64 service_id;
union ib_gid dgid;
union ib_gid sgid;
__be16 dlid;
__be16 slid;
int raw_traffic;
/* reserved */
__be32 flow_label;
u8 hop_limit;
u8 traffic_class;
int reversible;
u8 numb_path;
__be16 pkey;
__be16 qos_class;
u8 sl;
u8 mtu_selector;
u8 mtu;
u8 rate_selector;
u8 rate;
u8 packet_life_time_selector;
u8 packet_life_time;
u8 preference;
u8 smac[ETH_ALEN];
u8 dmac[ETH_ALEN];
u16 vlan_id;
};
#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
#define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1)
#define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2)
#define IB_SA_MCMEMBER_REC_MLID IB_SA_COMP_MASK( 3)
#define IB_SA_MCMEMBER_REC_MTU_SELECTOR IB_SA_COMP_MASK( 4)
#define IB_SA_MCMEMBER_REC_MTU IB_SA_COMP_MASK( 5)
#define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS IB_SA_COMP_MASK( 6)
#define IB_SA_MCMEMBER_REC_PKEY IB_SA_COMP_MASK( 7)
#define IB_SA_MCMEMBER_REC_RATE_SELECTOR IB_SA_COMP_MASK( 8)
#define IB_SA_MCMEMBER_REC_RATE IB_SA_COMP_MASK( 9)
#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(10)
#define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(11)
#define IB_SA_MCMEMBER_REC_SL IB_SA_COMP_MASK(12)
#define IB_SA_MCMEMBER_REC_FLOW_LABEL IB_SA_COMP_MASK(13)
#define IB_SA_MCMEMBER_REC_HOP_LIMIT IB_SA_COMP_MASK(14)
#define IB_SA_MCMEMBER_REC_SCOPE IB_SA_COMP_MASK(15)
#define IB_SA_MCMEMBER_REC_JOIN_STATE IB_SA_COMP_MASK(16)
#define IB_SA_MCMEMBER_REC_PROXY_JOIN IB_SA_COMP_MASK(17)
struct ib_sa_mcmember_rec {
union ib_gid mgid;
union ib_gid port_gid;
__be32 qkey;
__be16 mlid;
u8 mtu_selector;
u8 mtu;
u8 traffic_class;
__be16 pkey;
u8 rate_selector;
u8 rate;
u8 packet_life_time_selector;
u8 packet_life_time;
u8 sl;
__be32 flow_label;
u8 hop_limit;
u8 scope;
u8 join_state;
int proxy_join;
};
/* Service Record Component Mask Sec 15.2.5.14 Ver 1.1 */
#define IB_SA_SERVICE_REC_SERVICE_ID IB_SA_COMP_MASK( 0)
#define IB_SA_SERVICE_REC_SERVICE_GID IB_SA_COMP_MASK( 1)
#define IB_SA_SERVICE_REC_SERVICE_PKEY IB_SA_COMP_MASK( 2)
/* reserved: 3 */
#define IB_SA_SERVICE_REC_SERVICE_LEASE IB_SA_COMP_MASK( 4)
#define IB_SA_SERVICE_REC_SERVICE_KEY IB_SA_COMP_MASK( 5)
#define IB_SA_SERVICE_REC_SERVICE_NAME IB_SA_COMP_MASK( 6)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_0 IB_SA_COMP_MASK( 7)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_1 IB_SA_COMP_MASK( 8)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_2 IB_SA_COMP_MASK( 9)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_3 IB_SA_COMP_MASK(10)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_4 IB_SA_COMP_MASK(11)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_5 IB_SA_COMP_MASK(12)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_6 IB_SA_COMP_MASK(13)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_7 IB_SA_COMP_MASK(14)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_8 IB_SA_COMP_MASK(15)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_9 IB_SA_COMP_MASK(16)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_10 IB_SA_COMP_MASK(17)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_11 IB_SA_COMP_MASK(18)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_12 IB_SA_COMP_MASK(19)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_13 IB_SA_COMP_MASK(20)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_14 IB_SA_COMP_MASK(21)
#define IB_SA_SERVICE_REC_SERVICE_DATA8_15 IB_SA_COMP_MASK(22)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_0 IB_SA_COMP_MASK(23)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_1 IB_SA_COMP_MASK(24)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_2 IB_SA_COMP_MASK(25)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_3 IB_SA_COMP_MASK(26)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_4 IB_SA_COMP_MASK(27)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_5 IB_SA_COMP_MASK(28)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_6 IB_SA_COMP_MASK(29)
#define IB_SA_SERVICE_REC_SERVICE_DATA16_7 IB_SA_COMP_MASK(30)
#define IB_SA_SERVICE_REC_SERVICE_DATA32_0 IB_SA_COMP_MASK(31)
#define IB_SA_SERVICE_REC_SERVICE_DATA32_1 IB_SA_COMP_MASK(32)
#define IB_SA_SERVICE_REC_SERVICE_DATA32_2 IB_SA_COMP_MASK(33)
#define IB_SA_SERVICE_REC_SERVICE_DATA32_3 IB_SA_COMP_MASK(34)
#define IB_SA_SERVICE_REC_SERVICE_DATA64_0 IB_SA_COMP_MASK(35)
#define IB_SA_SERVICE_REC_SERVICE_DATA64_1 IB_SA_COMP_MASK(36)
#define IB_DEFAULT_SERVICE_LEASE 0xFFFFFFFF
struct ib_sa_service_rec {
u64 id;
union ib_gid gid;
__be16 pkey;
/* reserved */
u32 lease;
u8 key[16];
u8 name[64];
u8 data8[16];
u16 data16[8];
u32 data32[4];
u64 data64[2];
};
#define IB_SA_GUIDINFO_REC_LID IB_SA_COMP_MASK(0)
#define IB_SA_GUIDINFO_REC_BLOCK_NUM IB_SA_COMP_MASK(1)
#define IB_SA_GUIDINFO_REC_RES1 IB_SA_COMP_MASK(2)
#define IB_SA_GUIDINFO_REC_RES2 IB_SA_COMP_MASK(3)
#define IB_SA_GUIDINFO_REC_GID0 IB_SA_COMP_MASK(4)
#define IB_SA_GUIDINFO_REC_GID1 IB_SA_COMP_MASK(5)
#define IB_SA_GUIDINFO_REC_GID2 IB_SA_COMP_MASK(6)
#define IB_SA_GUIDINFO_REC_GID3 IB_SA_COMP_MASK(7)
#define IB_SA_GUIDINFO_REC_GID4 IB_SA_COMP_MASK(8)
#define IB_SA_GUIDINFO_REC_GID5 IB_SA_COMP_MASK(9)
#define IB_SA_GUIDINFO_REC_GID6 IB_SA_COMP_MASK(10)
#define IB_SA_GUIDINFO_REC_GID7 IB_SA_COMP_MASK(11)
struct ib_sa_guidinfo_rec {
__be16 lid;
u8 block_num;
/* reserved */
u8 res1;
__be32 res2;
u8 guid_info_list[64];
};
struct ib_sa_client {
atomic_t users;
struct completion comp;
};
/**
* ib_sa_register_client - Register an SA client.
*/
void ib_sa_register_client(struct ib_sa_client *client);
/**
* ib_sa_unregister_client - Deregister an SA client.
* @client: Client object to deregister.
*/
void ib_sa_unregister_client(struct ib_sa_client *client);
struct ib_sa_query;
void ib_sa_cancel_query(int id, struct ib_sa_query *query);
int ib_sa_path_rec_get(struct ib_sa_client *client,
struct ib_device *device, u8 port_num,
struct ib_sa_path_rec *rec,
ib_sa_comp_mask comp_mask,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
struct ib_sa_path_rec *resp,
void *context),
void *context,
struct ib_sa_query **query);
int ib_sa_service_rec_query(struct ib_sa_client *client,
struct ib_device *device, u8 port_num,
u8 method,
struct ib_sa_service_rec *rec,
ib_sa_comp_mask comp_mask,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
struct ib_sa_service_rec *resp,
void *context),
void *context,
struct ib_sa_query **sa_query);
struct ib_sa_multicast {
struct ib_sa_mcmember_rec rec;
ib_sa_comp_mask comp_mask;
int (*callback)(int status,
struct ib_sa_multicast *multicast);
void *context;
};
/**
* ib_sa_join_multicast - Initiates a join request to the specified multicast
* group.
* @client: SA client
* @device: Device associated with the multicast group.
* @port_num: Port on the specified device to associate with the multicast
* group.
* @rec: SA multicast member record specifying group attributes.
* @comp_mask: Component mask indicating which group attributes of %rec are
* valid.
* @gfp_mask: GFP mask for memory allocations.
* @callback: User callback invoked once the join operation completes.
* @context: User specified context stored with the ib_sa_multicast structure.
*
* This call initiates a multicast join request with the SA for the specified
* multicast group. If the join operation is started successfully, it returns
* an ib_sa_multicast structure that is used to track the multicast operation.
* Users must free this structure by calling ib_free_multicast, even if the
* join operation later fails. (The callback status is non-zero.)
*
* If the join operation fails; status will be non-zero, with the following
* failures possible:
* -ETIMEDOUT: The request timed out.
* -EIO: An error occurred sending the query.
* -EINVAL: The MCMemberRecord values differed from the existing group's.
* -ENETRESET: Indicates that an fatal error has occurred on the multicast
* group, and the user must rejoin the group to continue using it.
*/
struct ib_sa_multicast *ib_sa_join_multicast(struct ib_sa_client *client,
struct ib_device *device, u8 port_num,
struct ib_sa_mcmember_rec *rec,
ib_sa_comp_mask comp_mask, gfp_t gfp_mask,
int (*callback)(int status,
struct ib_sa_multicast
*multicast),
void *context);
/**
* ib_free_multicast - Frees the multicast tracking structure, and releases
* any reference on the multicast group.
* @multicast: Multicast tracking structure allocated by ib_join_multicast.
*
* This call blocks until the multicast identifier is destroyed. It may
* not be called from within the multicast callback; however, returning a non-
* zero value from the callback will result in destroying the multicast
* tracking structure.
*/
void ib_sa_free_multicast(struct ib_sa_multicast *multicast);
/**
* ib_get_mcmember_rec - Looks up a multicast member record by its MGID and
* returns it if found.
* @device: Device associated with the multicast group.
* @port_num: Port on the specified device to associate with the multicast
* group.
* @mgid: MGID of multicast group.
* @rec: Location to copy SA multicast member record.
*/
int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
union ib_gid *mgid, struct ib_sa_mcmember_rec *rec);
/**
* ib_init_ah_from_mcmember - Initialize address handle attributes based on
* an SA multicast member record.
*/
int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
struct ib_sa_mcmember_rec *rec,
struct ib_ah_attr *ah_attr);
/**
* ib_init_ah_from_path - Initialize address handle attributes based on an SA
* path record.
*/
int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
struct ib_sa_path_rec *rec,
struct ib_ah_attr *ah_attr);
/**
* ib_sa_pack_path - Conert a path record from struct ib_sa_path_rec
* to IB MAD wire format.
*/
void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute);
/**
* ib_sa_unpack_path - Convert a path record from MAD format to struct
* ib_sa_path_rec.
*/
void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec);
/* Support GuidInfoRecord */
int ib_sa_guid_info_rec_query(struct ib_sa_client *client,
struct ib_device *device, u8 port_num,
struct ib_sa_guidinfo_rec *rec,
ib_sa_comp_mask comp_mask, u8 method,
int timeout_ms, gfp_t gfp_mask,
void (*callback)(int status,
struct ib_sa_guidinfo_rec *resp,
void *context),
void *context,
struct ib_sa_query **sa_query);
#endif /* IB_SA_H */

128
include/rdma/ib_smi.h Normal file
View file

@ -0,0 +1,128 @@
/*
* Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
* Copyright (c) 2004 Infinicon Corporation. All rights reserved.
* Copyright (c) 2004 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(IB_SMI_H)
#define IB_SMI_H
#include <rdma/ib_mad.h>
#define IB_SMP_DATA_SIZE 64
#define IB_SMP_MAX_PATH_HOPS 64
struct ib_smp {
u8 base_version;
u8 mgmt_class;
u8 class_version;
u8 method;
__be16 status;
u8 hop_ptr;
u8 hop_cnt;
__be64 tid;
__be16 attr_id;
__be16 resv;
__be32 attr_mod;
__be64 mkey;
__be16 dr_slid;
__be16 dr_dlid;
u8 reserved[28];
u8 data[IB_SMP_DATA_SIZE];
u8 initial_path[IB_SMP_MAX_PATH_HOPS];
u8 return_path[IB_SMP_MAX_PATH_HOPS];
} __attribute__ ((packed));
#define IB_SMP_DIRECTION cpu_to_be16(0x8000)
/* Subnet management attributes */
#define IB_SMP_ATTR_NOTICE cpu_to_be16(0x0002)
#define IB_SMP_ATTR_NODE_DESC cpu_to_be16(0x0010)
#define IB_SMP_ATTR_NODE_INFO cpu_to_be16(0x0011)
#define IB_SMP_ATTR_SWITCH_INFO cpu_to_be16(0x0012)
#define IB_SMP_ATTR_GUID_INFO cpu_to_be16(0x0014)
#define IB_SMP_ATTR_PORT_INFO cpu_to_be16(0x0015)
#define IB_SMP_ATTR_PKEY_TABLE cpu_to_be16(0x0016)
#define IB_SMP_ATTR_SL_TO_VL_TABLE cpu_to_be16(0x0017)
#define IB_SMP_ATTR_VL_ARB_TABLE cpu_to_be16(0x0018)
#define IB_SMP_ATTR_LINEAR_FORWARD_TABLE cpu_to_be16(0x0019)
#define IB_SMP_ATTR_RANDOM_FORWARD_TABLE cpu_to_be16(0x001A)
#define IB_SMP_ATTR_MCAST_FORWARD_TABLE cpu_to_be16(0x001B)
#define IB_SMP_ATTR_SM_INFO cpu_to_be16(0x0020)
#define IB_SMP_ATTR_VENDOR_DIAG cpu_to_be16(0x0030)
#define IB_SMP_ATTR_LED_INFO cpu_to_be16(0x0031)
#define IB_SMP_ATTR_VENDOR_MASK cpu_to_be16(0xFF00)
struct ib_port_info {
__be64 mkey;
__be64 gid_prefix;
__be16 lid;
__be16 sm_lid;
__be32 cap_mask;
__be16 diag_code;
__be16 mkey_lease_period;
u8 local_port_num;
u8 link_width_enabled;
u8 link_width_supported;
u8 link_width_active;
u8 linkspeed_portstate; /* 4 bits, 4 bits */
u8 portphysstate_linkdown; /* 4 bits, 4 bits */
u8 mkeyprot_resv_lmc; /* 2 bits, 3, 3 */
u8 linkspeedactive_enabled; /* 4 bits, 4 bits */
u8 neighbormtu_mastersmsl; /* 4 bits, 4 bits */
u8 vlcap_inittype; /* 4 bits, 4 bits */
u8 vl_high_limit;
u8 vl_arb_high_cap;
u8 vl_arb_low_cap;
u8 inittypereply_mtucap; /* 4 bits, 4 bits */
u8 vlstallcnt_hoqlife; /* 3 bits, 5 bits */
u8 operationalvl_pei_peo_fpi_fpo; /* 4 bits, 1, 1, 1, 1 */
__be16 mkey_violations;
__be16 pkey_violations;
__be16 qkey_violations;
u8 guid_cap;
u8 clientrereg_resv_subnetto; /* 1 bit, 2 bits, 5 */
u8 resv_resptimevalue; /* 3 bits, 5 bits */
u8 localphyerrors_overrunerrors; /* 4 bits, 4 bits */
__be16 max_credit_hint;
u8 resv;
u8 link_roundtrip_latency[3];
};
static inline u8
ib_get_smp_direction(struct ib_smp *smp)
{
return ((smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
}
#endif /* IB_SMI_H */

79
include/rdma/ib_umem.h Normal file
View file

@ -0,0 +1,79 @@
/*
* Copyright (c) 2007 Cisco Systems. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef IB_UMEM_H
#define IB_UMEM_H
#include <linux/list.h>
#include <linux/scatterlist.h>
#include <linux/workqueue.h>
struct ib_ucontext;
struct ib_umem {
struct ib_ucontext *context;
size_t length;
int offset;
int page_size;
int writable;
int hugetlb;
struct work_struct work;
struct pid *pid;
struct mm_struct *mm;
unsigned long diff;
struct sg_table sg_head;
int nmap;
int npages;
};
#ifdef CONFIG_INFINIBAND_USER_MEM
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
size_t size, int access, int dmasync);
void ib_umem_release(struct ib_umem *umem);
int ib_umem_page_count(struct ib_umem *umem);
#else /* CONFIG_INFINIBAND_USER_MEM */
#include <linux/err.h>
static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,
unsigned long addr, size_t size,
int access, int dmasync) {
return ERR_PTR(-EINVAL);
}
static inline void ib_umem_release(struct ib_umem *umem) { }
static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }
#endif /* CONFIG_INFINIBAND_USER_MEM */
#endif /* IB_UMEM_H */

2626
include/rdma/ib_verbs.h Normal file

File diff suppressed because it is too large Load diff

251
include/rdma/iw_cm.h Normal file
View file

@ -0,0 +1,251 @@
/*
* Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef IW_CM_H
#define IW_CM_H
#include <linux/in.h>
#include <rdma/ib_cm.h>
struct iw_cm_id;
enum iw_cm_event_type {
IW_CM_EVENT_CONNECT_REQUEST = 1, /* connect request received */
IW_CM_EVENT_CONNECT_REPLY, /* reply from active connect request */
IW_CM_EVENT_ESTABLISHED, /* passive side accept successful */
IW_CM_EVENT_DISCONNECT, /* orderly shutdown */
IW_CM_EVENT_CLOSE /* close complete */
};
struct iw_cm_event {
enum iw_cm_event_type event;
int status;
struct sockaddr_storage local_addr;
struct sockaddr_storage remote_addr;
void *private_data;
void *provider_data;
u8 private_data_len;
u8 ord;
u8 ird;
};
/**
* iw_cm_handler - Function to be called by the IW CM when delivering events
* to the client.
*
* @cm_id: The IW CM identifier associated with the event.
* @event: Pointer to the event structure.
*/
typedef int (*iw_cm_handler)(struct iw_cm_id *cm_id,
struct iw_cm_event *event);
/**
* iw_event_handler - Function called by the provider when delivering provider
* events to the IW CM. Returns either 0 indicating the event was processed
* or -errno if the event could not be processed.
*
* @cm_id: The IW CM identifier associated with the event.
* @event: Pointer to the event structure.
*/
typedef int (*iw_event_handler)(struct iw_cm_id *cm_id,
struct iw_cm_event *event);
struct iw_cm_id {
iw_cm_handler cm_handler; /* client callback function */
void *context; /* client cb context */
struct ib_device *device;
struct sockaddr_storage local_addr;
struct sockaddr_storage remote_addr;
void *provider_data; /* provider private data */
iw_event_handler event_handler; /* cb for provider
events */
/* Used by provider to add and remove refs on IW cm_id */
void (*add_ref)(struct iw_cm_id *);
void (*rem_ref)(struct iw_cm_id *);
};
struct iw_cm_conn_param {
const void *private_data;
u16 private_data_len;
u32 ord;
u32 ird;
u32 qpn;
};
struct iw_cm_verbs {
void (*add_ref)(struct ib_qp *qp);
void (*rem_ref)(struct ib_qp *qp);
struct ib_qp * (*get_qp)(struct ib_device *device,
int qpn);
int (*connect)(struct iw_cm_id *cm_id,
struct iw_cm_conn_param *conn_param);
int (*accept)(struct iw_cm_id *cm_id,
struct iw_cm_conn_param *conn_param);
int (*reject)(struct iw_cm_id *cm_id,
const void *pdata, u8 pdata_len);
int (*create_listen)(struct iw_cm_id *cm_id,
int backlog);
int (*destroy_listen)(struct iw_cm_id *cm_id);
};
/**
* iw_create_cm_id - Create an IW CM identifier.
*
* @device: The IB device on which to create the IW CM identier.
* @event_handler: User callback invoked to report events associated with the
* returned IW CM identifier.
* @context: User specified context associated with the id.
*/
struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
iw_cm_handler cm_handler, void *context);
/**
* iw_destroy_cm_id - Destroy an IW CM identifier.
*
* @cm_id: The previously created IW CM identifier to destroy.
*
* The client can assume that no events will be delivered for the CM ID after
* this function returns.
*/
void iw_destroy_cm_id(struct iw_cm_id *cm_id);
/**
* iw_cm_bind_qp - Unbind the specified IW CM identifier and QP
*
* @cm_id: The IW CM idenfier to unbind from the QP.
* @qp: The QP
*
* This is called by the provider when destroying the QP to ensure
* that any references held by the IWCM are released. It may also
* be called by the IWCM when destroying a CM_ID to that any
* references held by the provider are released.
*/
void iw_cm_unbind_qp(struct iw_cm_id *cm_id, struct ib_qp *qp);
/**
* iw_cm_get_qp - Return the ib_qp associated with a QPN
*
* @ib_device: The IB device
* @qpn: The queue pair number
*/
struct ib_qp *iw_cm_get_qp(struct ib_device *device, int qpn);
/**
* iw_cm_listen - Listen for incoming connection requests on the
* specified IW CM id.
*
* @cm_id: The IW CM identifier.
* @backlog: The maximum number of outstanding un-accepted inbound listen
* requests to queue.
*
* The source address and port number are specified in the IW CM identifier
* structure.
*/
int iw_cm_listen(struct iw_cm_id *cm_id, int backlog);
/**
* iw_cm_accept - Called to accept an incoming connect request.
*
* @cm_id: The IW CM identifier associated with the connection request.
* @iw_param: Pointer to a structure containing connection establishment
* parameters.
*
* The specified cm_id will have been provided in the event data for a
* CONNECT_REQUEST event. Subsequent events related to this connection will be
* delivered to the specified IW CM identifier prior and may occur prior to
* the return of this function. If this function returns a non-zero value, the
* client can assume that no events will be delivered to the specified IW CM
* identifier.
*/
int iw_cm_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
/**
* iw_cm_reject - Reject an incoming connection request.
*
* @cm_id: Connection identifier associated with the request.
* @private_daa: Pointer to data to deliver to the remote peer as part of the
* reject message.
* @private_data_len: The number of bytes in the private_data parameter.
*
* The client can assume that no events will be delivered to the specified IW
* CM identifier following the return of this function. The private_data
* buffer is available for reuse when this function returns.
*/
int iw_cm_reject(struct iw_cm_id *cm_id, const void *private_data,
u8 private_data_len);
/**
* iw_cm_connect - Called to request a connection to a remote peer.
*
* @cm_id: The IW CM identifier for the connection.
* @iw_param: Pointer to a structure containing connection establishment
* parameters.
*
* Events may be delivered to the specified IW CM identifier prior to the
* return of this function. If this function returns a non-zero value, the
* client can assume that no events will be delivered to the specified IW CM
* identifier.
*/
int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param);
/**
* iw_cm_disconnect - Close the specified connection.
*
* @cm_id: The IW CM identifier to close.
* @abrupt: If 0, the connection will be closed gracefully, otherwise, the
* connection will be reset.
*
* The IW CM identifier is still active until the IW_CM_EVENT_CLOSE event is
* delivered.
*/
int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt);
/**
* iw_cm_init_qp_attr - Called to initialize the attributes of the QP
* associated with a IW CM identifier.
*
* @cm_id: The IW CM identifier associated with the QP
* @qp_attr: Pointer to the QP attributes structure.
* @qp_attr_mask: Pointer to a bit vector specifying which QP attributes are
* valid.
*/
int iw_cm_init_qp_attr(struct iw_cm_id *cm_id, struct ib_qp_attr *qp_attr,
int *qp_attr_mask);
#endif /* IW_CM_H */

199
include/rdma/iw_portmap.h Normal file
View file

@ -0,0 +1,199 @@
/*
* Copyright (c) 2014 Intel Corporation. All rights reserved.
* Copyright (c) 2014 Chelsio, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef _IW_PORTMAP_H
#define _IW_PORTMAP_H
#define IWPM_ULIBNAME_SIZE 32
#define IWPM_DEVNAME_SIZE 32
#define IWPM_IFNAME_SIZE 16
#define IWPM_IPADDR_SIZE 16
enum {
IWPM_INVALID_NLMSG_ERR = 10,
IWPM_CREATE_MAPPING_ERR,
IWPM_DUPLICATE_MAPPING_ERR,
IWPM_UNKNOWN_MAPPING_ERR,
IWPM_CLIENT_DEV_INFO_ERR,
IWPM_USER_LIB_INFO_ERR,
IWPM_REMOTE_QUERY_REJECT
};
struct iwpm_dev_data {
char dev_name[IWPM_DEVNAME_SIZE];
char if_name[IWPM_IFNAME_SIZE];
};
struct iwpm_sa_data {
struct sockaddr_storage loc_addr;
struct sockaddr_storage mapped_loc_addr;
struct sockaddr_storage rem_addr;
struct sockaddr_storage mapped_rem_addr;
};
/**
* iwpm_init - Allocate resources for the iwarp port mapper
*
* Should be called when network interface goes up.
*/
int iwpm_init(u8);
/**
* iwpm_exit - Deallocate resources for the iwarp port mapper
*
* Should be called when network interface goes down.
*/
int iwpm_exit(u8);
/**
* iwpm_valid_pid - Check if the userspace iwarp port mapper pid is valid
*
* Returns true if the pid is greater than zero, otherwise returns false
*/
int iwpm_valid_pid(void);
/**
* iwpm_register_pid - Send a netlink query to userspace
* to get the iwarp port mapper pid
* @pm_msg: Contains driver info to send to the userspace port mapper
* @nl_client: The index of the netlink client
*/
int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client);
/**
* iwpm_add_mapping - Send a netlink add mapping request to
* the userspace port mapper
* @pm_msg: Contains the local ip/tcp address info to send
* @nl_client: The index of the netlink client
*
* If the request is successful, the pm_msg stores
* the port mapper response (mapped address info)
*/
int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client);
/**
* iwpm_add_and_query_mapping - Send a netlink add and query mapping request
* to the userspace port mapper
* @pm_msg: Contains the local and remote ip/tcp address info to send
* @nl_client: The index of the netlink client
*
* If the request is successful, the pm_msg stores the
* port mapper response (mapped local and remote address info)
*/
int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client);
/**
* iwpm_remove_mapping - Send a netlink remove mapping request
* to the userspace port mapper
*
* @local_addr: Local ip/tcp address to remove
* @nl_client: The index of the netlink client
*/
int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client);
/**
* iwpm_register_pid_cb - Process the port mapper response to
* iwpm_register_pid query
* @skb:
* @cb: Contains the received message (payload and netlink header)
*
* If successful, the function receives the userspace port mapper pid
* which is used in future communication with the port mapper
*/
int iwpm_register_pid_cb(struct sk_buff *, struct netlink_callback *);
/**
* iwpm_add_mapping_cb - Process the port mapper response to
* iwpm_add_mapping request
* @skb:
* @cb: Contains the received message (payload and netlink header)
*/
int iwpm_add_mapping_cb(struct sk_buff *, struct netlink_callback *);
/**
* iwpm_add_and_query_mapping_cb - Process the port mapper response to
* iwpm_add_and_query_mapping request
* @skb:
* @cb: Contains the received message (payload and netlink header)
*/
int iwpm_add_and_query_mapping_cb(struct sk_buff *, struct netlink_callback *);
/**
* iwpm_mapping_error_cb - Process port mapper notification for error
*
* @skb:
* @cb: Contains the received message (payload and netlink header)
*/
int iwpm_mapping_error_cb(struct sk_buff *, struct netlink_callback *);
/**
* iwpm_mapping_info_cb - Process a notification that the userspace
* port mapper daemon is started
* @skb:
* @cb: Contains the received message (payload and netlink header)
*
* Using the received port mapper pid, send all the local mapping
* info records to the userspace port mapper
*/
int iwpm_mapping_info_cb(struct sk_buff *, struct netlink_callback *);
/**
* iwpm_ack_mapping_info_cb - Process the port mapper ack for
* the provided local mapping info records
* @skb:
* @cb: Contains the received message (payload and netlink header)
*/
int iwpm_ack_mapping_info_cb(struct sk_buff *, struct netlink_callback *);
/**
* iwpm_create_mapinfo - Store local and mapped IPv4/IPv6 address
* info in a hash table
* @local_addr: Local ip/tcp address
* @mapped_addr: Mapped local ip/tcp address
* @nl_client: The index of the netlink client
*/
int iwpm_create_mapinfo(struct sockaddr_storage *local_addr,
struct sockaddr_storage *mapped_addr, u8 nl_client);
/**
* iwpm_remove_mapinfo - Remove local and mapped IPv4/IPv6 address
* info from the hash table
* @local_addr: Local ip/tcp address
* @mapped_addr: Mapped local ip/tcp address
*
* Returns err code if mapping info is not found in the hash table,
* otherwise returns 0
*/
int iwpm_remove_mapinfo(struct sockaddr_storage *local_addr,
struct sockaddr_storage *mapped_addr);
#endif /* _IW_PORTMAP_H */

383
include/rdma/rdma_cm.h Normal file
View file

@ -0,0 +1,383 @@
/*
* Copyright (c) 2005 Voltaire Inc. All rights reserved.
* Copyright (c) 2005 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(RDMA_CM_H)
#define RDMA_CM_H
#include <linux/socket.h>
#include <linux/in6.h>
#include <rdma/ib_addr.h>
#include <rdma/ib_sa.h>
/*
* Upon receiving a device removal event, users must destroy the associated
* RDMA identifier and release all resources allocated with the device.
*/
enum rdma_cm_event_type {
RDMA_CM_EVENT_ADDR_RESOLVED,
RDMA_CM_EVENT_ADDR_ERROR,
RDMA_CM_EVENT_ROUTE_RESOLVED,
RDMA_CM_EVENT_ROUTE_ERROR,
RDMA_CM_EVENT_CONNECT_REQUEST,
RDMA_CM_EVENT_CONNECT_RESPONSE,
RDMA_CM_EVENT_CONNECT_ERROR,
RDMA_CM_EVENT_UNREACHABLE,
RDMA_CM_EVENT_REJECTED,
RDMA_CM_EVENT_ESTABLISHED,
RDMA_CM_EVENT_DISCONNECTED,
RDMA_CM_EVENT_DEVICE_REMOVAL,
RDMA_CM_EVENT_MULTICAST_JOIN,
RDMA_CM_EVENT_MULTICAST_ERROR,
RDMA_CM_EVENT_ADDR_CHANGE,
RDMA_CM_EVENT_TIMEWAIT_EXIT
};
enum rdma_port_space {
RDMA_PS_SDP = 0x0001,
RDMA_PS_IPOIB = 0x0002,
RDMA_PS_IB = 0x013F,
RDMA_PS_TCP = 0x0106,
RDMA_PS_UDP = 0x0111,
};
#define RDMA_IB_IP_PS_MASK 0xFFFFFFFFFFFF0000ULL
#define RDMA_IB_IP_PS_TCP 0x0000000001060000ULL
#define RDMA_IB_IP_PS_UDP 0x0000000001110000ULL
#define RDMA_IB_IP_PS_IB 0x00000000013F0000ULL
struct rdma_addr {
struct sockaddr_storage src_addr;
struct sockaddr_storage dst_addr;
struct rdma_dev_addr dev_addr;
};
struct rdma_route {
struct rdma_addr addr;
struct ib_sa_path_rec *path_rec;
int num_paths;
};
struct rdma_conn_param {
const void *private_data;
u8 private_data_len;
u8 responder_resources;
u8 initiator_depth;
u8 flow_control;
u8 retry_count; /* ignored when accepting */
u8 rnr_retry_count;
/* Fields below ignored if a QP is created on the rdma_cm_id. */
u8 srq;
u32 qp_num;
u32 qkey;
};
struct rdma_ud_param {
const void *private_data;
u8 private_data_len;
struct ib_ah_attr ah_attr;
u32 qp_num;
u32 qkey;
};
struct rdma_cm_event {
enum rdma_cm_event_type event;
int status;
union {
struct rdma_conn_param conn;
struct rdma_ud_param ud;
} param;
};
enum rdma_cm_state {
RDMA_CM_IDLE,
RDMA_CM_ADDR_QUERY,
RDMA_CM_ADDR_RESOLVED,
RDMA_CM_ROUTE_QUERY,
RDMA_CM_ROUTE_RESOLVED,
RDMA_CM_CONNECT,
RDMA_CM_DISCONNECT,
RDMA_CM_ADDR_BOUND,
RDMA_CM_LISTEN,
RDMA_CM_DEVICE_REMOVAL,
RDMA_CM_DESTROYING
};
struct rdma_cm_id;
/**
* rdma_cm_event_handler - Callback used to report user events.
*
* Notes: Users may not call rdma_destroy_id from this callback to destroy
* the passed in id, or a corresponding listen id. Returning a
* non-zero value from the callback will destroy the passed in id.
*/
typedef int (*rdma_cm_event_handler)(struct rdma_cm_id *id,
struct rdma_cm_event *event);
struct rdma_cm_id {
struct ib_device *device;
void *context;
struct ib_qp *qp;
rdma_cm_event_handler event_handler;
struct rdma_route route;
enum rdma_port_space ps;
enum ib_qp_type qp_type;
u8 port_num;
};
/**
* rdma_create_id - Create an RDMA identifier.
*
* @event_handler: User callback invoked to report events associated with the
* returned rdma_id.
* @context: User specified context associated with the id.
* @ps: RDMA port space.
* @qp_type: type of queue pair associated with the id.
*/
struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
void *context, enum rdma_port_space ps,
enum ib_qp_type qp_type);
/**
* rdma_destroy_id - Destroys an RDMA identifier.
*
* @id: RDMA identifier.
*
* Note: calling this function has the effect of canceling in-flight
* asynchronous operations associated with the id.
*/
void rdma_destroy_id(struct rdma_cm_id *id);
/**
* rdma_bind_addr - Bind an RDMA identifier to a source address and
* associated RDMA device, if needed.
*
* @id: RDMA identifier.
* @addr: Local address information. Wildcard values are permitted.
*
* This associates a source address with the RDMA identifier before calling
* rdma_listen. If a specific local address is given, the RDMA identifier will
* be bound to a local RDMA device.
*/
int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
/**
* rdma_resolve_addr - Resolve destination and optional source addresses
* from IP addresses to an RDMA address. If successful, the specified
* rdma_cm_id will be bound to a local device.
*
* @id: RDMA identifier.
* @src_addr: Source address information. This parameter may be NULL.
* @dst_addr: Destination address information.
* @timeout_ms: Time to wait for resolution to complete.
*/
int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
struct sockaddr *dst_addr, int timeout_ms);
/**
* rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier
* into route information needed to establish a connection.
*
* This is called on the client side of a connection.
* Users must have first called rdma_resolve_addr to resolve a dst_addr
* into an RDMA address before calling this routine.
*/
int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);
/**
* rdma_create_qp - Allocate a QP and associate it with the specified RDMA
* identifier.
*
* QPs allocated to an rdma_cm_id will automatically be transitioned by the CMA
* through their states.
*/
int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
struct ib_qp_init_attr *qp_init_attr);
/**
* rdma_destroy_qp - Deallocate the QP associated with the specified RDMA
* identifier.
*
* Users must destroy any QP associated with an RDMA identifier before
* destroying the RDMA ID.
*/
void rdma_destroy_qp(struct rdma_cm_id *id);
/**
* rdma_init_qp_attr - Initializes the QP attributes for use in transitioning
* to a specified QP state.
* @id: Communication identifier associated with the QP attributes to
* initialize.
* @qp_attr: On input, specifies the desired QP state. On output, the
* mandatory and desired optional attributes will be set in order to
* modify the QP to the specified state.
* @qp_attr_mask: The QP attribute mask that may be used to transition the
* QP to the specified state.
*
* Users must set the @qp_attr->qp_state to the desired QP state. This call
* will set all required attributes for the given transition, along with
* known optional attributes. Users may override the attributes returned from
* this call before calling ib_modify_qp.
*
* Users that wish to have their QP automatically transitioned through its
* states can associate a QP with the rdma_cm_id by calling rdma_create_qp().
*/
int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
int *qp_attr_mask);
/**
* rdma_connect - Initiate an active connection request.
* @id: Connection identifier to connect.
* @conn_param: Connection information used for connected QPs.
*
* Users must have resolved a route for the rdma_cm_id to connect with
* by having called rdma_resolve_route before calling this routine.
*
* This call will either connect to a remote QP or obtain remote QP
* information for unconnected rdma_cm_id's. The actual operation is
* based on the rdma_cm_id's port space.
*/
int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
/**
* rdma_listen - This function is called by the passive side to
* listen for incoming connection requests.
*
* Users must have bound the rdma_cm_id to a local address by calling
* rdma_bind_addr before calling this routine.
*/
int rdma_listen(struct rdma_cm_id *id, int backlog);
/**
* rdma_accept - Called to accept a connection request or response.
* @id: Connection identifier associated with the request.
* @conn_param: Information needed to establish the connection. This must be
* provided if accepting a connection request. If accepting a connection
* response, this parameter must be NULL.
*
* Typically, this routine is only called by the listener to accept a connection
* request. It must also be called on the active side of a connection if the
* user is performing their own QP transitions.
*
* In the case of error, a reject message is sent to the remote side and the
* state of the qp associated with the id is modified to error, such that any
* previously posted receive buffers would be flushed.
*/
int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
/**
* rdma_notify - Notifies the RDMA CM of an asynchronous event that has
* occurred on the connection.
* @id: Connection identifier to transition to established.
* @event: Asynchronous event.
*
* This routine should be invoked by users to notify the CM of relevant
* communication events. Events that should be reported to the CM and
* when to report them are:
*
* IB_EVENT_COMM_EST - Used when a message is received on a connected
* QP before an RTU has been received.
*/
int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event);
/**
* rdma_reject - Called to reject a connection request or response.
*/
int rdma_reject(struct rdma_cm_id *id, const void *private_data,
u8 private_data_len);
/**
* rdma_disconnect - This function disconnects the associated QP and
* transitions it into the error state.
*/
int rdma_disconnect(struct rdma_cm_id *id);
/**
* rdma_join_multicast - Join the multicast group specified by the given
* address.
* @id: Communication identifier associated with the request.
* @addr: Multicast address identifying the group to join.
* @context: User-defined context associated with the join request, returned
* to the user through the private_data pointer in multicast events.
*/
int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
void *context);
/**
* rdma_leave_multicast - Leave the multicast group specified by the given
* address.
*/
void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
/**
* rdma_set_service_type - Set the type of service associated with a
* connection identifier.
* @id: Communication identifier to associated with service type.
* @tos: Type of service.
*
* The type of service is interpretted as a differentiated service
* field (RFC 2474). The service type should be specified before
* performing route resolution, as existing communication on the
* connection identifier may be unaffected. The type of service
* requested may not be supported by the network to all destinations.
*/
void rdma_set_service_type(struct rdma_cm_id *id, int tos);
/**
* rdma_set_reuseaddr - Allow the reuse of local addresses when binding
* the rdma_cm_id.
* @id: Communication identifier to configure.
* @reuse: Value indicating if the bound address is reusable.
*
* Reuse must be set before an address is bound to the id.
*/
int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse);
/**
* rdma_set_afonly - Specify that listens are restricted to the
* bound address family only.
* @id: Communication identifer to configure.
* @afonly: Value indicating if listens are restricted.
*
* Must be set before identifier is in the listening state.
*/
int rdma_set_afonly(struct rdma_cm_id *id, int afonly);
/**
* rdma_get_service_id - Return the IB service ID for a specified address.
* @id: Communication identifier associated with the address.
* @addr: Address for the service ID.
*/
__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr);
#endif /* RDMA_CM_H */

54
include/rdma/rdma_cm_ib.h Normal file
View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2006 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if !defined(RDMA_CM_IB_H)
#define RDMA_CM_IB_H
#include <rdma/rdma_cm.h>
/**
* rdma_set_ib_paths - Manually sets the path records used to establish a
* connection.
* @id: Connection identifier associated with the request.
* @path_rec: Reference to the path record
*
* This call permits a user to specify routing information for rdma_cm_id's
* bound to Infiniband devices. It is called on the client side of a
* connection and replaces the call to rdma_resolve_route.
*/
int rdma_set_ib_paths(struct rdma_cm_id *id,
struct ib_sa_path_rec *path_rec, int num_paths);
/* Global qkey for UDP QPs and multicast groups. */
#define RDMA_UDP_QKEY 0x01234567
#endif /* RDMA_CM_IB_H */

View file

@ -0,0 +1,80 @@
#ifndef _RDMA_NETLINK_H
#define _RDMA_NETLINK_H
#include <linux/netlink.h>
#include <uapi/rdma/rdma_netlink.h>
struct ibnl_client_cbs {
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
struct module *module;
};
int ibnl_init(void);
void ibnl_cleanup(void);
/**
* Add a a client to the list of IB netlink exporters.
* @index: Index of the added client
* @nops: Number of supported ops by the added client.
* @cb_table: A table for op->callback
*
* Returns 0 on success or a negative error code.
*/
int ibnl_add_client(int index, int nops,
const struct ibnl_client_cbs cb_table[]);
/**
* Remove a client from IB netlink.
* @index: Index of the removed IB client.
*
* Returns 0 on success or a negative error code.
*/
int ibnl_remove_client(int index);
/**
* Put a new message in a supplied skb.
* @skb: The netlink skb.
* @nlh: Pointer to put the header of the new netlink message.
* @seq: The message sequence number.
* @len: The requested message length to allocate.
* @client: Calling IB netlink client.
* @op: message content op.
* Returns the allocated buffer on success and NULL on failure.
*/
void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
int len, int client, int op, int flags);
/**
* Put a new attribute in a supplied skb.
* @skb: The netlink skb.
* @nlh: Header of the netlink message to append the attribute to.
* @len: The length of the attribute data.
* @data: The attribute data to put.
* @type: The attribute type.
* Returns the 0 and a negative error code on failure.
*/
int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
int len, void *data, int type);
/**
* Send the supplied skb to a specific userspace PID.
* @skb: The netlink skb
* @nlh: Header of the netlink message to send
* @pid: Userspace netlink process ID
* Returns 0 on success or a negative error code.
*/
int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
__u32 pid);
/**
* Send the supplied skb to a netlink group.
* @skb: The netlink skb
* @nlh: Header of the netlink message to send
* @group: Netlink group ID
* @flags: allocation flags
* Returns 0 on success or a negative error code.
*/
int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
unsigned int group, gfp_t flags);
#endif /* _RDMA_NETLINK_H */