1225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier/* 2225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 3225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 5225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * 6225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * This software is available to you under a choice of one of two 7225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * licenses. You may choose to be licensed under the terms of the GNU 8225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * General Public License (GPL) Version 2, available from the file 9225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * COPYING in the main directory of this source tree, or the 10225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * OpenIB.org BSD license below: 11225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * 12225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * Redistribution and use in source and binary forms, with or 13225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * without modification, are permitted provided that the following 14225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * conditions are met: 15225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * 16225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * - Redistributions of source code must retain the above 17225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * copyright notice, this list of conditions and the following 18225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * disclaimer. 19225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * 20225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * - Redistributions in binary form must reproduce the above 21225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * copyright notice, this list of conditions and the following 22225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * disclaimer in the documentation and/or other materials 23225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * provided with the distribution. 24225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * 25225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * SOFTWARE. 33225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier */ 34225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 355a0e3ad6af8660be21ca98a971cd00f331318c05Tejun Heo#include <linux/slab.h> 365a0e3ad6af8660be21ca98a971cd00f331318c05Tejun Heo 37225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier#include "mlx4.h" 38225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier#include "fw.h" 39225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 40225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreierenum { 41225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_QP, 42225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_RDMARC, 43225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_ALTC, 44225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_AUXC, 45225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_SRQ, 46225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_CQ, 47225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_EQ, 48225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_DMPT, 49225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_CMPT, 50225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_MTT, 51225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_MCG, 52225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier MLX4_RES_NUM 53225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier}; 54225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 55225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreierstatic const char *res_name[] = { 56225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_QP] = "QP", 57225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_RDMARC] = "RDMARC", 58225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_ALTC] = "ALTC", 59225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_AUXC] = "AUXC", 60225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_SRQ] = "SRQ", 61225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_CQ] = "CQ", 62225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_EQ] = "EQ", 63225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_DMPT] = "DMPT", 64225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_CMPT] = "CMPT", 65225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_MTT] = "MTT", 66225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier [MLX4_RES_MCG] = "MCG", 67225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier}; 68225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 69225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreieru64 mlx4_make_profile(struct mlx4_dev *dev, 70225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_profile *request, 71225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_dev_cap *dev_cap, 72225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_init_hca_param *init_hca) 73225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier{ 74225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_priv *priv = mlx4_priv(dev); 75225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_resource { 76225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier u64 size; 77225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier u64 start; 78225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier int type; 79225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier int num; 80225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier int log_num; 81225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier }; 82225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 83225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier u64 total_size = 0; 84225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_resource *profile; 85225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier struct mlx4_resource tmp; 86225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier int i, j; 87225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 88baeb2ffab4e67bb9174e6166e070a9a8ec94b0f6Joe Perches profile = kcalloc(MLX4_RES_NUM, sizeof(*profile), GFP_KERNEL); 89225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier if (!profile) 90225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier return -ENOMEM; 91225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 92225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_QP].size = dev_cap->qpc_entry_sz; 93225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_RDMARC].size = dev_cap->rdmarc_entry_sz; 94225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_ALTC].size = dev_cap->altc_entry_sz; 95225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_AUXC].size = dev_cap->aux_entry_sz; 96225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_SRQ].size = dev_cap->srq_entry_sz; 97225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_CQ].size = dev_cap->cqc_entry_sz; 98225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_EQ].size = dev_cap->eqc_entry_sz; 99225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_DMPT].size = dev_cap->dmpt_entry_sz; 100225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_CMPT].size = dev_cap->cmpt_entry_sz; 1012b8fb2867ca2736a715a88067fd0ec2904777cbeMarcel Apfelbaum profile[MLX4_RES_MTT].size = dev_cap->mtt_entry_sz; 1020ec2c0f86d31ab36547307f133b0016006bdc6b5Eugenia Emantayev profile[MLX4_RES_MCG].size = mlx4_get_mgm_entry_size(dev); 103225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 104225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_QP].num = request->num_qp; 105225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_RDMARC].num = request->num_qp * request->rdmarc_per_qp; 106225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_ALTC].num = request->num_qp; 107225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_AUXC].num = request->num_qp; 108225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_SRQ].num = request->num_srq; 109225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_CQ].num = request->num_cq; 1100b7ca5a928e2271bbc225e9e1ac1f22e9fbee54fYevgeny Petrilin profile[MLX4_RES_EQ].num = min_t(unsigned, dev_cap->max_eqs, MAX_MSIX); 111225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_DMPT].num = request->num_mpt; 112225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_CMPT].num = MLX4_NUM_CMPTS; 1139fd7a1e147bd41fb999a58da8a8826b9f3415384Marcel Apfelbaum profile[MLX4_RES_MTT].num = request->num_mtt * (1 << log_mtts_per_seg); 114225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[MLX4_RES_MCG].num = request->num_mcg; 115225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 116225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier for (i = 0; i < MLX4_RES_NUM; ++i) { 117225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[i].type = i; 118225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[i].num = roundup_pow_of_two(profile[i].num); 119225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[i].log_num = ilog2(profile[i].num); 120225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[i].size *= profile[i].num; 121225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[i].size = max(profile[i].size, (u64) PAGE_SIZE); 122225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 123225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 124225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier /* 125225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * Sort the resources in decreasing order of size. Since they 126225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * all have sizes that are powers of 2, we'll be able to keep 127225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * resources aligned to their size and pack them without gaps 128225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * using the sorted order. 129225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier */ 130225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier for (i = MLX4_RES_NUM; i > 0; --i) 131225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier for (j = 1; j < i; ++j) { 132225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier if (profile[j].size > profile[j - 1].size) { 133225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier tmp = profile[j]; 134225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[j] = profile[j - 1]; 135225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[j - 1] = tmp; 136225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 137225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 138225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 139225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier for (i = 0; i < MLX4_RES_NUM; ++i) { 140225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier if (profile[i].size) { 141225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier profile[i].start = total_size; 142225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier total_size += profile[i].size; 143225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 144225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 145225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier if (total_size > dev_cap->max_icm_sz) { 146225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier mlx4_err(dev, "Profile requires 0x%llx bytes; " 147225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier "won't fit in 0x%llx bytes of context memory.\n", 148225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier (unsigned long long) total_size, 149225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier (unsigned long long) dev_cap->max_icm_sz); 150225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier kfree(profile); 151225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier return -ENOMEM; 152225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 153225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 154225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier if (profile[i].size) 155225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier mlx4_dbg(dev, " profile[%2d] (%6s): 2^%02d entries @ 0x%10llx, " 156225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier "size 0x%10llx\n", 157225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier i, res_name[profile[i].type], profile[i].log_num, 158225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier (unsigned long long) profile[i].start, 159225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier (unsigned long long) profile[i].size); 160225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 161225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 162225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier mlx4_dbg(dev, "HCA context memory: reserving %d KB\n", 163225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier (int) (total_size >> 10)); 164225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 165225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier for (i = 0; i < MLX4_RES_NUM; ++i) { 166225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier switch (profile[i].type) { 167225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_QP: 168225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_qps = profile[i].num; 169225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->qpc_base = profile[i].start; 170225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_num_qps = profile[i].log_num; 171225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 172225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_RDMARC: 173225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier for (priv->qp_table.rdmarc_shift = 0; 174225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier request->num_qp << priv->qp_table.rdmarc_shift < profile[i].num; 175225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier ++priv->qp_table.rdmarc_shift) 176225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier ; /* nothing */ 177225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.max_qp_dest_rdma = 1 << priv->qp_table.rdmarc_shift; 178225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier priv->qp_table.rdmarc_base = (u32) profile[i].start; 179225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->rdmarc_base = profile[i].start; 180225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_rd_per_qp = priv->qp_table.rdmarc_shift; 181225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 182225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_ALTC: 183225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->altc_base = profile[i].start; 184225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 185225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_AUXC: 186225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->auxc_base = profile[i].start; 187225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 188225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_SRQ: 189225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_srqs = profile[i].num; 190225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->srqc_base = profile[i].start; 191225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_num_srqs = profile[i].log_num; 192225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 193225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_CQ: 194225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_cqs = profile[i].num; 195225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->cqc_base = profile[i].start; 196225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_num_cqs = profile[i].log_num; 197225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 198225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_EQ: 199225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_eqs = profile[i].num; 200225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->eqc_base = profile[i].start; 201225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_num_eqs = profile[i].log_num; 202225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 203225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_DMPT: 204225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_mpts = profile[i].num; 205225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier priv->mr_table.mpt_base = profile[i].start; 206225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->dmpt_base = profile[i].start; 207225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_mpt_sz = profile[i].log_num; 208225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 209225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_CMPT: 210225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->cmpt_base = profile[i].start; 211225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 212225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_MTT: 2132b8fb2867ca2736a715a88067fd0ec2904777cbeMarcel Apfelbaum dev->caps.num_mtts = profile[i].num; 214225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier priv->mr_table.mtt_base = profile[i].start; 215225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->mtt_base = profile[i].start; 216225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 217225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier case MLX4_RES_MCG: 218225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_mgms = profile[i].num >> 1; 219225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_amgms = profile[i].num >> 1; 220225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->mc_base = profile[i].start; 2210ec2c0f86d31ab36547307f133b0016006bdc6b5Eugenia Emantayev init_hca->log_mc_entry_sz = 2220ec2c0f86d31ab36547307f133b0016006bdc6b5Eugenia Emantayev ilog2(mlx4_get_mgm_entry_size(dev)); 223225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_mc_table_sz = profile[i].log_num; 224225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier init_hca->log_mc_hash_sz = profile[i].log_num - 1; 225225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 226225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier default: 227225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier break; 228225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 229225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier } 230225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 231225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier /* 232225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * PDs don't take any HCA memory, but we assign them as part 233225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier * of the HCA profile anyway. 234225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier */ 235225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier dev->caps.num_pds = MLX4_NUM_PDS; 236225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier 237225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier kfree(profile); 238225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier return total_size; 239225c7b1feef1b41170f7037a5b10a65cd8a42c54Roland Dreier} 240