2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #include <dev/mlx4/qp.h>
38 int mlx4_ib_exp_query_device(struct ib_device *ibdev,
39 struct ib_exp_device_attr *props)
41 struct ib_device_attr *base = &props->base;
42 struct mlx4_ib_dev *dev = to_mdev(ibdev);
43 int ret = mlx4_ib_query_device(ibdev, &props->base);
45 props->exp_comp_mask = IB_EXP_DEVICE_ATTR_INLINE_RECV_SZ;
46 props->inline_recv_sz = dev->dev->caps.max_rq_sg * sizeof(struct mlx4_wqe_data_seg);
47 props->device_cap_flags2 = 0;
49 /* move RSS device cap from device_cap to device_cap_flags2 */
50 if (base->device_cap_flags & IB_DEVICE_QPG) {
51 props->device_cap_flags2 |= IB_EXP_DEVICE_QPG;
52 if (base->device_cap_flags & IB_DEVICE_UD_RSS)
53 props->device_cap_flags2 |= IB_EXP_DEVICE_UD_RSS;
55 base->device_cap_flags &= ~(IB_DEVICE_QPG |
59 if (base->max_rss_tbl_sz > 0) {
60 props->max_rss_tbl_sz = base->max_rss_tbl_sz;
61 props->exp_comp_mask |= IB_EXP_DEVICE_ATTR_RSS_TBL_SZ;
63 props->max_rss_tbl_sz = 0;
64 props->exp_comp_mask &= ~IB_EXP_DEVICE_ATTR_RSS_TBL_SZ;
67 if (props->device_cap_flags2)
68 props->exp_comp_mask |= IB_EXP_DEVICE_ATTR_CAP_FLAGS2;
74 * Experimental functions
76 struct ib_qp *mlx4_ib_exp_create_qp(struct ib_pd *pd,
77 struct ib_exp_qp_init_attr *init_attr,
78 struct ib_udata *udata)
82 struct mlx4_ib_qp *mqp;
84 struct mlx4_ib_dev *dev;
86 if (init_attr->max_inl_recv && !udata)
87 return ERR_PTR(-EINVAL);
89 use_inlr = mlx4_ib_qp_has_rq((struct ib_qp_init_attr *)init_attr) &&
90 init_attr->max_inl_recv && pd;
92 rwqe_size = roundup_pow_of_two(max(1U, init_attr->cap.max_recv_sge)) *
93 sizeof(struct mlx4_wqe_data_seg);
94 if (rwqe_size < init_attr->max_inl_recv) {
95 dev = to_mdev(pd->device);
96 init_attr->max_inl_recv = min(init_attr->max_inl_recv,
97 (u32)(dev->dev->caps.max_rq_sg *
98 sizeof(struct mlx4_wqe_data_seg)));
99 init_attr->cap.max_recv_sge = roundup_pow_of_two(init_attr->max_inl_recv) /
100 sizeof(struct mlx4_wqe_data_seg);
103 init_attr->max_inl_recv = 0;
105 qp = mlx4_ib_create_qp(pd, (struct ib_qp_init_attr *)init_attr, udata);
111 mqp->max_inlr_data = 1 << mqp->rq.wqe_shift;
112 init_attr->max_inl_recv = mqp->max_inlr_data;