Skip to content

Commit

Permalink
RDMA/CMA: Add rdma_port_space to UAPI
Browse files Browse the repository at this point in the history
Since the rdma_port_space enum is being passed between user and kernel for
user cm_id setup, we need it in a UAPI header.  So add it to
rdma_user_cm.h.

This also fixes the cm_id restrack changes which pass up the port space
value via the RDMA_NLDEV_ATTR_RES_PS attribute.

Fixes: 0031398 ("RDMA/nldev: provide detailed CM_ID information")
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Steve Wise authored and Jason Gunthorpe committed Mar 29, 2018
1 parent 1b90d30 commit 2253fc0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
32 changes: 17 additions & 15 deletions drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static struct cma_pernet *cma_pernet(struct net *net)
return net_generic(net, cma_pernet_id);
}

static struct idr *cma_pernet_idr(struct net *net, enum rdma_port_space ps)
static struct idr *cma_pernet_idr(struct net *net, enum rdma_ucm_port_space ps)
{
struct cma_pernet *pernet = cma_pernet(net);

Expand Down Expand Up @@ -204,7 +204,7 @@ struct cma_device {
};

struct rdma_bind_list {
enum rdma_port_space ps;
enum rdma_ucm_port_space ps;
struct hlist_head owners;
unsigned short port;
};
Expand All @@ -217,7 +217,7 @@ struct class_port_info_context {
u8 port_num;
};

static int cma_ps_alloc(struct net *net, enum rdma_port_space ps,
static int cma_ps_alloc(struct net *net, enum rdma_ucm_port_space ps,
struct rdma_bind_list *bind_list, int snum)
{
struct idr *idr = cma_pernet_idr(net, ps);
Expand All @@ -226,14 +226,15 @@ static int cma_ps_alloc(struct net *net, enum rdma_port_space ps,
}

static struct rdma_bind_list *cma_ps_find(struct net *net,
enum rdma_port_space ps, int snum)
enum rdma_ucm_port_space ps, int snum)
{
struct idr *idr = cma_pernet_idr(net, ps);

return idr_find(idr, snum);
}

static void cma_ps_remove(struct net *net, enum rdma_port_space ps, int snum)
static void cma_ps_remove(struct net *net, enum rdma_ucm_port_space ps,
int snum)
{
struct idr *idr = cma_pernet_idr(net, ps);

Expand Down Expand Up @@ -742,7 +743,7 @@ static void cma_deref_id(struct rdma_id_private *id_priv)

struct rdma_cm_id *__rdma_create_id(struct net *net,
rdma_cm_event_handler event_handler,
void *context, enum rdma_port_space ps,
void *context, enum rdma_ucm_port_space ps,
enum ib_qp_type qp_type, const char *caller)
{
struct rdma_id_private *id_priv;
Expand Down Expand Up @@ -1366,7 +1367,7 @@ static struct net_device *cma_get_net_dev(struct ib_cm_event *ib_event,
return net_dev;
}

static enum rdma_port_space rdma_ps_from_service_id(__be64 service_id)
static enum rdma_ucm_port_space rdma_ps_from_service_id(__be64 service_id)
{
return (be64_to_cpu(service_id) >> 16) & 0xffff;
}
Expand Down Expand Up @@ -2994,7 +2995,7 @@ static void cma_bind_port(struct rdma_bind_list *bind_list,
hlist_add_head(&id_priv->node, &bind_list->owners);
}

static int cma_alloc_port(enum rdma_port_space ps,
static int cma_alloc_port(enum rdma_ucm_port_space ps,
struct rdma_id_private *id_priv, unsigned short snum)
{
struct rdma_bind_list *bind_list;
Expand Down Expand Up @@ -3057,7 +3058,7 @@ static int cma_port_is_unique(struct rdma_bind_list *bind_list,
return 0;
}

static int cma_alloc_any_port(enum rdma_port_space ps,
static int cma_alloc_any_port(enum rdma_ucm_port_space ps,
struct rdma_id_private *id_priv)
{
static unsigned int last_used_port;
Expand Down Expand Up @@ -3135,7 +3136,7 @@ static int cma_check_port(struct rdma_bind_list *bind_list,
return 0;
}

static int cma_use_port(enum rdma_port_space ps,
static int cma_use_port(enum rdma_ucm_port_space ps,
struct rdma_id_private *id_priv)
{
struct rdma_bind_list *bind_list;
Expand Down Expand Up @@ -3169,8 +3170,8 @@ static int cma_bind_listen(struct rdma_id_private *id_priv)
return ret;
}

static enum rdma_port_space cma_select_inet_ps(
struct rdma_id_private *id_priv)
static enum rdma_ucm_port_space
cma_select_inet_ps(struct rdma_id_private *id_priv)
{
switch (id_priv->id.ps) {
case RDMA_PS_TCP:
Expand All @@ -3184,9 +3185,10 @@ static enum rdma_port_space cma_select_inet_ps(
}
}

static enum rdma_port_space cma_select_ib_ps(struct rdma_id_private *id_priv)
static enum rdma_ucm_port_space
cma_select_ib_ps(struct rdma_id_private *id_priv)
{
enum rdma_port_space ps = 0;
enum rdma_ucm_port_space ps = 0;
struct sockaddr_ib *sib;
u64 sid_ps, mask, sid;

Expand Down Expand Up @@ -3217,7 +3219,7 @@ static enum rdma_port_space cma_select_ib_ps(struct rdma_id_private *id_priv)

static int cma_get_port(struct rdma_id_private *id_priv)
{
enum rdma_port_space ps;
enum rdma_ucm_port_space ps;
int ret;

if (cma_family(id_priv) != AF_IB)
Expand Down
17 changes: 6 additions & 11 deletions include/rdma/rdma_cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <linux/in6.h>
#include <rdma/ib_addr.h>
#include <rdma/ib_sa.h>
#include <uapi/rdma/rdma_user_cm.h>

/*
* Upon receiving a device removal event, users must destroy the associated
Expand All @@ -64,13 +65,6 @@ enum rdma_cm_event_type {

const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event);

enum rdma_port_space {
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
Expand Down Expand Up @@ -151,15 +145,16 @@ struct rdma_cm_id {
struct ib_qp *qp;
rdma_cm_event_handler event_handler;
struct rdma_route route;
enum rdma_port_space ps;
enum rdma_ucm_port_space ps;
enum ib_qp_type qp_type;
u8 port_num;
};

struct rdma_cm_id *__rdma_create_id(struct net *net,
rdma_cm_event_handler event_handler,
void *context, enum rdma_port_space ps,
enum ib_qp_type qp_type, const char *caller);
rdma_cm_event_handler event_handler,
void *context, enum rdma_ucm_port_space ps,
enum ib_qp_type qp_type,
const char *caller);

/**
* rdma_create_id - Create an RDMA identifier.
Expand Down
10 changes: 9 additions & 1 deletion include/uapi/rdma/rdma_user_cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ enum {
RDMA_USER_CM_CMD_JOIN_MCAST
};

/* See IBTA Annex A11, servies ID bytes 4 & 5 */
enum rdma_ucm_port_space {
RDMA_PS_IPOIB = 0x0002,
RDMA_PS_IB = 0x013F,
RDMA_PS_TCP = 0x0106,
RDMA_PS_UDP = 0x0111,
};

/*
* command ABI structures.
*/
Expand All @@ -82,7 +90,7 @@ struct rdma_ucm_cmd_hdr {
struct rdma_ucm_create_id {
__aligned_u64 uid;
__aligned_u64 response;
__u16 ps;
__u16 ps; /* use enum rdma_ucm_port_space */
__u8 qp_type;
__u8 reserved[5];
};
Expand Down

0 comments on commit 2253fc0

Please sign in to comment.