IB/core: Define 'ib' and 'roce' rdma_ah_attr types
rdma_ah_attr can now be either ib or roce allowing core components to use one type or the other and also to define attributes unique to a specific type. struct ib_ah is also initialized with the type when its first created. This ensures that calls such as modify_ah dont modify the type of the address handle attribute. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Don Hiatt <don.hiatt@intel.com> Reviewed-by: Sean Hefty <sean.hefty@intel.com> Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:

committed by
Doug Ledford

parent
d8966fcd4c
commit
44c58487d5
@@ -34,8 +34,7 @@
|
||||
|
||||
static struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,
|
||||
struct mlx5_ib_ah *ah,
|
||||
struct rdma_ah_attr *ah_attr,
|
||||
enum rdma_link_layer ll)
|
||||
struct rdma_ah_attr *ah_attr)
|
||||
{
|
||||
if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
|
||||
const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
|
||||
@@ -50,8 +49,9 @@ static struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,
|
||||
|
||||
ah->av.stat_rate_sl = (rdma_ah_get_static_rate(ah_attr) << 4);
|
||||
|
||||
if (ll == IB_LINK_LAYER_ETHERNET) {
|
||||
memcpy(ah->av.rmac, ah_attr->dmac, sizeof(ah_attr->dmac));
|
||||
if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) {
|
||||
memcpy(ah->av.rmac, ah_attr->roce.dmac,
|
||||
sizeof(ah_attr->roce.dmac));
|
||||
ah->av.udp_sport =
|
||||
mlx5_get_roce_udp_sport(dev,
|
||||
rdma_ah_get_port_num(ah_attr),
|
||||
@@ -72,16 +72,13 @@ struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
|
||||
{
|
||||
struct mlx5_ib_ah *ah;
|
||||
struct mlx5_ib_dev *dev = to_mdev(pd->device);
|
||||
enum rdma_link_layer ll;
|
||||
enum rdma_ah_attr_type ah_type = ah_attr->type;
|
||||
|
||||
ll = pd->device->get_link_layer(pd->device,
|
||||
rdma_ah_get_port_num(ah_attr));
|
||||
|
||||
if (ll == IB_LINK_LAYER_ETHERNET &&
|
||||
if ((ah_type == RDMA_AH_ATTR_TYPE_ROCE) &&
|
||||
!(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
if (ll == IB_LINK_LAYER_ETHERNET && udata) {
|
||||
if (ah_type == RDMA_AH_ATTR_TYPE_ROCE && udata) {
|
||||
int err;
|
||||
struct mlx5_ib_create_ah_resp resp = {};
|
||||
u32 min_resp_len = offsetof(typeof(resp), dmac) +
|
||||
@@ -96,7 +93,7 @@ struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
memcpy(resp.dmac, ah_attr->dmac, ETH_ALEN);
|
||||
memcpy(resp.dmac, ah_attr->roce.dmac, ETH_ALEN);
|
||||
err = ib_copy_to_udata(udata, &resp, resp.response_length);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
@@ -106,7 +103,7 @@ struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
|
||||
if (!ah)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
return create_ib_ah(dev, ah, ah_attr, ll); /* never fails */
|
||||
return create_ib_ah(dev, ah, ah_attr); /* never fails */
|
||||
}
|
||||
|
||||
int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
|
||||
@@ -115,6 +112,7 @@ int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
|
||||
u32 tmp;
|
||||
|
||||
memset(ah_attr, 0, sizeof(*ah_attr));
|
||||
ah_attr->type = ibah->type;
|
||||
|
||||
tmp = be32_to_cpu(ah->av.grh_gid_fl);
|
||||
if (tmp & (1 << 30)) {
|
||||
|
@@ -2212,7 +2212,6 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
|
||||
bool alt)
|
||||
{
|
||||
const struct ib_global_route *grh = rdma_ah_read_grh(ah);
|
||||
enum rdma_link_layer ll = rdma_port_get_link_layer(&dev->ib_dev, port);
|
||||
int err;
|
||||
enum ib_gid_type gid_type;
|
||||
u8 ah_flags = rdma_ah_get_ah_flags(ah);
|
||||
@@ -2231,14 +2230,15 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (ll == IB_LINK_LAYER_ETHERNET) {
|
||||
|
||||
if (ah->type == RDMA_AH_ATTR_TYPE_ROCE) {
|
||||
if (!(ah_flags & IB_AH_GRH))
|
||||
return -EINVAL;
|
||||
err = mlx5_get_roce_gid_type(dev, port, grh->sgid_index,
|
||||
&gid_type);
|
||||
if (err)
|
||||
return err;
|
||||
memcpy(path->rmac, ah->dmac, sizeof(ah->dmac));
|
||||
memcpy(path->rmac, ah->roce.dmac, sizeof(ah->roce.dmac));
|
||||
path->udp_sport = mlx5_get_roce_udp_sport(dev, port,
|
||||
grh->sgid_index);
|
||||
path->dci_cfi_prio_sl = (sl & 0x7) << 4;
|
||||
@@ -4259,6 +4259,7 @@ static void to_rdma_ah_attr(struct mlx5_ib_dev *ibdev,
|
||||
|
||||
memset(ah_attr, 0, sizeof(*ah_attr));
|
||||
|
||||
ah_attr->type = rdma_ah_find_type(&ibdev->ib_dev, path->port);
|
||||
rdma_ah_set_port_num(ah_attr, path->port);
|
||||
if (rdma_ah_get_port_num(ah_attr) == 0 ||
|
||||
rdma_ah_get_port_num(ah_attr) > MLX5_CAP_GEN(dev, num_ports))
|
||||
|
Reference in New Issue
Block a user