Re: [PATCH rdma-core 2/2] Enforce is_global if GRH required

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 13, 2018 at 06:37:57PM +0300, Yishai Hadas wrote:
> From: Artemy Kovalyov <artemyko@xxxxxxxxxxxx>
> 
> When IBV_PORT_GRH_REQUIRED port capability flag is set, the applications
> must create all AH with GRH configured. This patch enforces the above
> requirement for providers which implement the ibv_create_ah() verb in
> user space, for others the kernel enforces that.
> 
> Signed-off-by: Artemy Kovalyov <artemyko@xxxxxxxxxxxx>
> Signed-off-by: Yishai Hadas <yishaih@xxxxxxxxxxxx>
>  providers/mlx4/verbs.c  | 4 ++++
>  providers/mlx5/mlx5.c   | 5 ++++-
>  providers/mlx5/mlx5.h   | 1 +
>  providers/mlx5/verbs.c  | 6 +++++-
>  providers/mthca/verbs.c | 8 ++++++++
>  5 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
> index 495f84e..7f0c0ab 100644
> +++ b/providers/mlx4/verbs.c
> @@ -1328,6 +1328,10 @@ struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
>  	if (query_port_cache(pd->context, attr->port_num, &port_attr))
>  		return NULL;
>  
> +	if (port_attr.port_cap_flags & IBV_PORT_GRH_REQUIRED &&
> +	    !attr->is_global)
> +		return NULL;
> +
>  	ah = malloc(sizeof *ah);
>  	if (!ah)
>  		return NULL;
> diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c
> index 5590241..5079dcd 100644
> +++ b/providers/mlx5/mlx5.c
> @@ -1176,8 +1176,11 @@ static struct verbs_context *mlx5_alloc_context(struct ibv_device *ibdev,
>  
>  	for (j = 0; j < min(MLX5_MAX_PORTS_NUM, context->num_ports); ++j) {
>  		memset(&port_attr, 0, sizeof(port_attr));
> -		if (!mlx5_query_port(&v_ctx->context, j + 1, &port_attr))
> +		if (!mlx5_query_port(&v_ctx->context, j + 1, &port_attr)) {
>  			context->cached_link_layer[j] = port_attr.link_layer;
> +			context->cached_port_flags[j] =
> +				port_attr.port_cap_flags;
> +		}
>  	}
>  
>  	return v_ctx;
> diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h
> index d3f0829..546d3a6 100644
> +++ b/providers/mlx5/mlx5.h
> @@ -269,6 +269,7 @@ struct mlx5_context {
>  	struct list_head                hugetlb_list;
>  	int				cqe_version;
>  	uint8_t				cached_link_layer[MLX5_MAX_PORTS_NUM];
> +	uint32_t			cached_port_flags[MLX5_MAX_PORTS_NUM];
>  	unsigned int			cached_device_cap_flags;
>  	enum ibv_atomic_cap		atomic_cap;
>  	struct {
> diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
> index 6ed2c35..70c6af9 100644
> +++ b/providers/mlx5/verbs.c
> @@ -2211,6 +2211,7 @@ struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
>  	__be32 tmp;
>  	uint8_t grh;
>  	int is_eth;
> +	int grh_req;

This is better as a bool..

> +		grh_req = ctx->cached_port_flags[attr->port_num - 1] &
> +			IBV_PORT_GRH_REQUIRED;

Because the only reason the above works as-is is subtle due to
IBV_PORT_GRH_REQUIRED being small enough.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux