Commit f685c195 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB: Make ib_init_ah_from_mcmember set sgid_attr

This is really just a CM support function, normally a multicast address
does not have a specific SGID - but the RDMA CM usage model does restrict
things to the netdevice the CM id is bound to, at least for roce case.

Store the selected table entry in the sgid_attr for everything else to
use.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent b7403217
......@@ -3988,6 +3988,8 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
ret = id_priv->id.event_handler(&id_priv->id, &event);
rdma_destroy_ah_attr(&event.param.ud.ah_attr);
if (ret) {
cma_exch(id_priv, RDMA_CM_DESTROYING);
mutex_unlock(&id_priv->handler_mutex);
......
......@@ -716,14 +716,28 @@ int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
}
EXPORT_SYMBOL(ib_sa_get_mcmember_rec);
/**
* ib_init_ah_from_mcmember - Initialize AH attribute from multicast
* member record and gid of the device.
* @device: RDMA device
* @port_num: Port of the rdma device to consider
* @ndev: Optional netdevice, applicable only for RoCE
* @gid_type: GID type to consider
* @ah_attr: AH attribute to fillup on successful completion
*
* ib_init_ah_from_mcmember() initializes AH attribute based on multicast
* member record and other device properties. On success the caller is
* responsible to call rdma_destroy_ah_attr on the ah_attr. Returns 0 on
* success or appropriate error code.
*
*/
int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
struct ib_sa_mcmember_rec *rec,
struct net_device *ndev,
enum ib_gid_type gid_type,
struct rdma_ah_attr *ah_attr)
{
int ret;
u16 gid_index;
const struct ib_gid_attr *sgid_attr;
/* GID table is not based on the netdevice for IB link layer,
* so ignore ndev during search.
......@@ -733,26 +747,22 @@ int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
else if (!rdma_protocol_roce(device, port_num))
return -EINVAL;
ret = ib_find_cached_gid_by_port(device, &rec->port_gid,
gid_type, port_num,
ndev,
&gid_index);
if (ret)
return ret;
sgid_attr = rdma_find_gid_by_port(device, &rec->port_gid,
gid_type, port_num, ndev);
if (IS_ERR(sgid_attr))
return PTR_ERR(sgid_attr);
memset(ah_attr, 0, sizeof *ah_attr);
memset(ah_attr, 0, sizeof(*ah_attr));
ah_attr->type = rdma_ah_find_type(device, port_num);
rdma_ah_set_dlid(ah_attr, be16_to_cpu(rec->mlid));
rdma_ah_set_sl(ah_attr, rec->sl);
rdma_ah_set_port_num(ah_attr, port_num);
rdma_ah_set_static_rate(ah_attr, rec->rate);
rdma_ah_set_grh(ah_attr, &rec->mgid,
be32_to_cpu(rec->flow_label),
(u8)gid_index,
rec->hop_limit,
rec->traffic_class);
rdma_move_grh_sgid_attr(ah_attr, &rec->mgid,
be32_to_cpu(rec->flow_label),
rec->hop_limit, rec->traffic_class,
sgid_attr);
return 0;
}
EXPORT_SYMBOL(ib_init_ah_from_mcmember);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment