15a2cc190SJeff Kirsher /* 25a2cc190SJeff Kirsher * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 35a2cc190SJeff Kirsher * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. 45a2cc190SJeff Kirsher * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 55a2cc190SJeff Kirsher * 65a2cc190SJeff Kirsher * This software is available to you under a choice of one of two 75a2cc190SJeff Kirsher * licenses. You may choose to be licensed under the terms of the GNU 85a2cc190SJeff Kirsher * General Public License (GPL) Version 2, available from the file 95a2cc190SJeff Kirsher * COPYING in the main directory of this source tree, or the 105a2cc190SJeff Kirsher * OpenIB.org BSD license below: 115a2cc190SJeff Kirsher * 125a2cc190SJeff Kirsher * Redistribution and use in source and binary forms, with or 135a2cc190SJeff Kirsher * without modification, are permitted provided that the following 145a2cc190SJeff Kirsher * conditions are met: 155a2cc190SJeff Kirsher * 165a2cc190SJeff Kirsher * - Redistributions of source code must retain the above 175a2cc190SJeff Kirsher * copyright notice, this list of conditions and the following 185a2cc190SJeff Kirsher * disclaimer. 195a2cc190SJeff Kirsher * 205a2cc190SJeff Kirsher * - Redistributions in binary form must reproduce the above 215a2cc190SJeff Kirsher * copyright notice, this list of conditions and the following 225a2cc190SJeff Kirsher * disclaimer in the documentation and/or other materials 235a2cc190SJeff Kirsher * provided with the distribution. 245a2cc190SJeff Kirsher * 255a2cc190SJeff Kirsher * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 265a2cc190SJeff Kirsher * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 275a2cc190SJeff Kirsher * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 285a2cc190SJeff Kirsher * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 295a2cc190SJeff Kirsher * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 305a2cc190SJeff Kirsher * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 315a2cc190SJeff Kirsher * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 325a2cc190SJeff Kirsher * SOFTWARE. 335a2cc190SJeff Kirsher */ 345a2cc190SJeff Kirsher 355cc914f1SMarcel Apfelbaum #include <linux/etherdevice.h> 365a2cc190SJeff Kirsher #include <linux/mlx4/cmd.h> 379d9779e7SPaul Gortmaker #include <linux/module.h> 385a2cc190SJeff Kirsher #include <linux/cache.h> 395a2cc190SJeff Kirsher 405a2cc190SJeff Kirsher #include "fw.h" 415a2cc190SJeff Kirsher #include "icm.h" 425a2cc190SJeff Kirsher 435a2cc190SJeff Kirsher enum { 445a2cc190SJeff Kirsher MLX4_COMMAND_INTERFACE_MIN_REV = 2, 455a2cc190SJeff Kirsher MLX4_COMMAND_INTERFACE_MAX_REV = 3, 465a2cc190SJeff Kirsher MLX4_COMMAND_INTERFACE_NEW_PORT_CMDS = 3, 475a2cc190SJeff Kirsher }; 485a2cc190SJeff Kirsher 495a2cc190SJeff Kirsher extern void __buggy_use_of_MLX4_GET(void); 505a2cc190SJeff Kirsher extern void __buggy_use_of_MLX4_PUT(void); 515a2cc190SJeff Kirsher 52eb939922SRusty Russell static bool enable_qos; 535a2cc190SJeff Kirsher module_param(enable_qos, bool, 0444); 545a2cc190SJeff Kirsher MODULE_PARM_DESC(enable_qos, "Enable Quality of Service support in the HCA (default: off)"); 555a2cc190SJeff Kirsher 565a2cc190SJeff Kirsher #define MLX4_GET(dest, source, offset) \ 575a2cc190SJeff Kirsher do { \ 585a2cc190SJeff Kirsher void *__p = (char *) (source) + (offset); \ 595a2cc190SJeff Kirsher switch (sizeof (dest)) { \ 605a2cc190SJeff Kirsher case 1: (dest) = *(u8 *) __p; break; \ 615a2cc190SJeff Kirsher case 2: (dest) = be16_to_cpup(__p); break; \ 625a2cc190SJeff Kirsher case 4: (dest) = be32_to_cpup(__p); break; \ 635a2cc190SJeff Kirsher case 8: (dest) = be64_to_cpup(__p); break; \ 645a2cc190SJeff Kirsher default: __buggy_use_of_MLX4_GET(); \ 655a2cc190SJeff Kirsher } \ 665a2cc190SJeff Kirsher } while (0) 675a2cc190SJeff Kirsher 685a2cc190SJeff Kirsher #define MLX4_PUT(dest, source, offset) \ 695a2cc190SJeff Kirsher do { \ 705a2cc190SJeff Kirsher void *__d = ((char *) (dest) + (offset)); \ 715a2cc190SJeff Kirsher switch (sizeof(source)) { \ 725a2cc190SJeff Kirsher case 1: *(u8 *) __d = (source); break; \ 735a2cc190SJeff Kirsher case 2: *(__be16 *) __d = cpu_to_be16(source); break; \ 745a2cc190SJeff Kirsher case 4: *(__be32 *) __d = cpu_to_be32(source); break; \ 755a2cc190SJeff Kirsher case 8: *(__be64 *) __d = cpu_to_be64(source); break; \ 765a2cc190SJeff Kirsher default: __buggy_use_of_MLX4_PUT(); \ 775a2cc190SJeff Kirsher } \ 785a2cc190SJeff Kirsher } while (0) 795a2cc190SJeff Kirsher 805a2cc190SJeff Kirsher static void dump_dev_cap_flags(struct mlx4_dev *dev, u64 flags) 815a2cc190SJeff Kirsher { 825a2cc190SJeff Kirsher static const char *fname[] = { 835a2cc190SJeff Kirsher [ 0] = "RC transport", 845a2cc190SJeff Kirsher [ 1] = "UC transport", 855a2cc190SJeff Kirsher [ 2] = "UD transport", 865a2cc190SJeff Kirsher [ 3] = "XRC transport", 875a2cc190SJeff Kirsher [ 4] = "reliable multicast", 885a2cc190SJeff Kirsher [ 5] = "FCoIB support", 895a2cc190SJeff Kirsher [ 6] = "SRQ support", 905a2cc190SJeff Kirsher [ 7] = "IPoIB checksum offload", 915a2cc190SJeff Kirsher [ 8] = "P_Key violation counter", 925a2cc190SJeff Kirsher [ 9] = "Q_Key violation counter", 935a2cc190SJeff Kirsher [10] = "VMM", 945a2cc190SJeff Kirsher [12] = "DPDP", 955a2cc190SJeff Kirsher [15] = "Big LSO headers", 965a2cc190SJeff Kirsher [16] = "MW support", 975a2cc190SJeff Kirsher [17] = "APM support", 985a2cc190SJeff Kirsher [18] = "Atomic ops support", 995a2cc190SJeff Kirsher [19] = "Raw multicast support", 1005a2cc190SJeff Kirsher [20] = "Address vector port checking support", 1015a2cc190SJeff Kirsher [21] = "UD multicast support", 1025a2cc190SJeff Kirsher [24] = "Demand paging support", 1035a2cc190SJeff Kirsher [25] = "Router support", 1045a2cc190SJeff Kirsher [30] = "IBoE support", 1055a2cc190SJeff Kirsher [32] = "Unicast loopback support", 106f3a9d1f2SYevgeny Petrilin [34] = "FCS header control", 1075a2cc190SJeff Kirsher [38] = "Wake On LAN support", 1085a2cc190SJeff Kirsher [40] = "UDP RSS support", 1095a2cc190SJeff Kirsher [41] = "Unicast VEP steering support", 1105a2cc190SJeff Kirsher [42] = "Multicast VEP steering support", 1115a2cc190SJeff Kirsher [48] = "Counters support", 11200f5ce99SJack Morgenstein [59] = "Port management change event support", 11308ff3235SOr Gerlitz [61] = "64 byte EQE support", 11408ff3235SOr Gerlitz [62] = "64 byte CQE support", 1155a2cc190SJeff Kirsher }; 1165a2cc190SJeff Kirsher int i; 1175a2cc190SJeff Kirsher 1185a2cc190SJeff Kirsher mlx4_dbg(dev, "DEV_CAP flags:\n"); 1195a2cc190SJeff Kirsher for (i = 0; i < ARRAY_SIZE(fname); ++i) 1205a2cc190SJeff Kirsher if (fname[i] && (flags & (1LL << i))) 1215a2cc190SJeff Kirsher mlx4_dbg(dev, " %s\n", fname[i]); 1225a2cc190SJeff Kirsher } 1235a2cc190SJeff Kirsher 124b3416f44SShlomo Pongratz static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags) 125b3416f44SShlomo Pongratz { 126b3416f44SShlomo Pongratz static const char * const fname[] = { 127b3416f44SShlomo Pongratz [0] = "RSS support", 128b3416f44SShlomo Pongratz [1] = "RSS Toeplitz Hash Function support", 1290ff1fb65SHadar Hen Zion [2] = "RSS XOR Hash Function support", 130*955154faSMatan Barak [3] = "Device manage flow steering support", 131*955154faSMatan Barak [4] = "Automatic mac reassignment support" 132b3416f44SShlomo Pongratz }; 133b3416f44SShlomo Pongratz int i; 134b3416f44SShlomo Pongratz 135b3416f44SShlomo Pongratz for (i = 0; i < ARRAY_SIZE(fname); ++i) 136b3416f44SShlomo Pongratz if (fname[i] && (flags & (1LL << i))) 137b3416f44SShlomo Pongratz mlx4_dbg(dev, " %s\n", fname[i]); 138b3416f44SShlomo Pongratz } 139b3416f44SShlomo Pongratz 1405a2cc190SJeff Kirsher int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg) 1415a2cc190SJeff Kirsher { 1425a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 1435a2cc190SJeff Kirsher u32 *inbox; 1445a2cc190SJeff Kirsher int err = 0; 1455a2cc190SJeff Kirsher 1465a2cc190SJeff Kirsher #define MOD_STAT_CFG_IN_SIZE 0x100 1475a2cc190SJeff Kirsher 1485a2cc190SJeff Kirsher #define MOD_STAT_CFG_PG_SZ_M_OFFSET 0x002 1495a2cc190SJeff Kirsher #define MOD_STAT_CFG_PG_SZ_OFFSET 0x003 1505a2cc190SJeff Kirsher 1515a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 1525a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 1535a2cc190SJeff Kirsher return PTR_ERR(mailbox); 1545a2cc190SJeff Kirsher inbox = mailbox->buf; 1555a2cc190SJeff Kirsher 1565a2cc190SJeff Kirsher memset(inbox, 0, MOD_STAT_CFG_IN_SIZE); 1575a2cc190SJeff Kirsher 1585a2cc190SJeff Kirsher MLX4_PUT(inbox, cfg->log_pg_sz, MOD_STAT_CFG_PG_SZ_OFFSET); 1595a2cc190SJeff Kirsher MLX4_PUT(inbox, cfg->log_pg_sz_m, MOD_STAT_CFG_PG_SZ_M_OFFSET); 1605a2cc190SJeff Kirsher 1615a2cc190SJeff Kirsher err = mlx4_cmd(dev, mailbox->dma, 0, 0, MLX4_CMD_MOD_STAT_CFG, 162f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 1635a2cc190SJeff Kirsher 1645a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 1655a2cc190SJeff Kirsher return err; 1665a2cc190SJeff Kirsher } 1675a2cc190SJeff Kirsher 1685cc914f1SMarcel Apfelbaum int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave, 1695cc914f1SMarcel Apfelbaum struct mlx4_vhcr *vhcr, 1705cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *inbox, 1715cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *outbox, 1725cc914f1SMarcel Apfelbaum struct mlx4_cmd_info *cmd) 1735cc914f1SMarcel Apfelbaum { 1745cc914f1SMarcel Apfelbaum u8 field; 1755cc914f1SMarcel Apfelbaum u32 size; 1765cc914f1SMarcel Apfelbaum int err = 0; 1775cc914f1SMarcel Apfelbaum 1785cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_FLAGS_OFFSET 0x0 1795cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_NUM_PORTS_OFFSET 0x1 1805cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_PF_BHVR_OFFSET 0x4 181105c320fSJack Morgenstein #define QUERY_FUNC_CAP_FMR_OFFSET 0x8 1825cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_QP_QUOTA_OFFSET 0x10 1835cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_CQ_QUOTA_OFFSET 0x14 1845cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET 0x18 1855cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_MPT_QUOTA_OFFSET 0x20 1865cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_MTT_QUOTA_OFFSET 0x24 1875cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_MCG_QUOTA_OFFSET 0x28 1885cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_MAX_EQ_OFFSET 0x2c 18969612b9fSRoland Dreier #define QUERY_FUNC_CAP_RESERVED_EQ_OFFSET 0x30 1905cc914f1SMarcel Apfelbaum 191105c320fSJack Morgenstein #define QUERY_FUNC_CAP_FMR_FLAG 0x80 192105c320fSJack Morgenstein #define QUERY_FUNC_CAP_FLAG_RDMA 0x40 193105c320fSJack Morgenstein #define QUERY_FUNC_CAP_FLAG_ETH 0x80 194105c320fSJack Morgenstein 195105c320fSJack Morgenstein /* when opcode modifier = 1 */ 1965cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_PHYS_PORT_OFFSET 0x3 197105c320fSJack Morgenstein #define QUERY_FUNC_CAP_RDMA_PROPS_OFFSET 0x8 1985cc914f1SMarcel Apfelbaum #define QUERY_FUNC_CAP_ETH_PROPS_OFFSET 0xc 1995cc914f1SMarcel Apfelbaum 20047605df9SJack Morgenstein #define QUERY_FUNC_CAP_QP0_TUNNEL 0x10 20147605df9SJack Morgenstein #define QUERY_FUNC_CAP_QP0_PROXY 0x14 20247605df9SJack Morgenstein #define QUERY_FUNC_CAP_QP1_TUNNEL 0x18 20347605df9SJack Morgenstein #define QUERY_FUNC_CAP_QP1_PROXY 0x1c 20447605df9SJack Morgenstein 205105c320fSJack Morgenstein #define QUERY_FUNC_CAP_ETH_PROPS_FORCE_MAC 0x40 206105c320fSJack Morgenstein #define QUERY_FUNC_CAP_ETH_PROPS_FORCE_VLAN 0x80 207105c320fSJack Morgenstein 208105c320fSJack Morgenstein #define QUERY_FUNC_CAP_RDMA_PROPS_FORCE_PHY_WQE_GID 0x80 209105c320fSJack Morgenstein 2105cc914f1SMarcel Apfelbaum if (vhcr->op_modifier == 1) { 211105c320fSJack Morgenstein field = 0; 212105c320fSJack Morgenstein /* ensure force vlan and force mac bits are not set */ 2135cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_ETH_PROPS_OFFSET); 214105c320fSJack Morgenstein /* ensure that phy_wqe_gid bit is not set */ 215105c320fSJack Morgenstein MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_RDMA_PROPS_OFFSET); 216105c320fSJack Morgenstein 21747605df9SJack Morgenstein field = vhcr->in_modifier; /* phys-port = logical-port */ 21847605df9SJack Morgenstein MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_PHYS_PORT_OFFSET); 21947605df9SJack Morgenstein 22047605df9SJack Morgenstein /* size is now the QP number */ 22147605df9SJack Morgenstein size = dev->phys_caps.base_tunnel_sqpn + 8 * slave + field - 1; 22247605df9SJack Morgenstein MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP0_TUNNEL); 22347605df9SJack Morgenstein 22447605df9SJack Morgenstein size += 2; 22547605df9SJack Morgenstein MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP1_TUNNEL); 22647605df9SJack Morgenstein 22747605df9SJack Morgenstein size = dev->phys_caps.base_proxy_sqpn + 8 * slave + field - 1; 22847605df9SJack Morgenstein MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP0_PROXY); 22947605df9SJack Morgenstein 23047605df9SJack Morgenstein size += 2; 23147605df9SJack Morgenstein MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP1_PROXY); 23247605df9SJack Morgenstein 2335cc914f1SMarcel Apfelbaum } else if (vhcr->op_modifier == 0) { 234105c320fSJack Morgenstein /* enable rdma and ethernet interfaces */ 235105c320fSJack Morgenstein field = (QUERY_FUNC_CAP_FLAG_ETH | QUERY_FUNC_CAP_FLAG_RDMA); 2365cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS_OFFSET); 2375cc914f1SMarcel Apfelbaum 2385cc914f1SMarcel Apfelbaum field = dev->caps.num_ports; 2395cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_NUM_PORTS_OFFSET); 2405cc914f1SMarcel Apfelbaum 24108ff3235SOr Gerlitz size = dev->caps.function_caps; /* set PF behaviours */ 2425cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_PF_BHVR_OFFSET); 2435cc914f1SMarcel Apfelbaum 244105c320fSJack Morgenstein field = 0; /* protected FMR support not available as yet */ 245105c320fSJack Morgenstein MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FMR_OFFSET); 246105c320fSJack Morgenstein 2475cc914f1SMarcel Apfelbaum size = dev->caps.num_qps; 2485cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_QP_QUOTA_OFFSET); 2495cc914f1SMarcel Apfelbaum 2505cc914f1SMarcel Apfelbaum size = dev->caps.num_srqs; 2515cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET); 2525cc914f1SMarcel Apfelbaum 2535cc914f1SMarcel Apfelbaum size = dev->caps.num_cqs; 2545cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET); 2555cc914f1SMarcel Apfelbaum 2565cc914f1SMarcel Apfelbaum size = dev->caps.num_eqs; 2575cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MAX_EQ_OFFSET); 2585cc914f1SMarcel Apfelbaum 2595cc914f1SMarcel Apfelbaum size = dev->caps.reserved_eqs; 2605cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET); 2615cc914f1SMarcel Apfelbaum 2625cc914f1SMarcel Apfelbaum size = dev->caps.num_mpts; 2635cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET); 2645cc914f1SMarcel Apfelbaum 2652b8fb286SMarcel Apfelbaum size = dev->caps.num_mtts; 2665cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET); 2675cc914f1SMarcel Apfelbaum 2685cc914f1SMarcel Apfelbaum size = dev->caps.num_mgms + dev->caps.num_amgms; 2695cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET); 2705cc914f1SMarcel Apfelbaum 2715cc914f1SMarcel Apfelbaum } else 2725cc914f1SMarcel Apfelbaum err = -EINVAL; 2735cc914f1SMarcel Apfelbaum 2745cc914f1SMarcel Apfelbaum return err; 2755cc914f1SMarcel Apfelbaum } 2765cc914f1SMarcel Apfelbaum 27747605df9SJack Morgenstein int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port, 27847605df9SJack Morgenstein struct mlx4_func_cap *func_cap) 2795cc914f1SMarcel Apfelbaum { 2805cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *mailbox; 2815cc914f1SMarcel Apfelbaum u32 *outbox; 28247605df9SJack Morgenstein u8 field, op_modifier; 2835cc914f1SMarcel Apfelbaum u32 size; 2845cc914f1SMarcel Apfelbaum int err = 0; 2855cc914f1SMarcel Apfelbaum 28647605df9SJack Morgenstein op_modifier = !!gen_or_port; /* 0 = general, 1 = logical port */ 2875cc914f1SMarcel Apfelbaum 2885cc914f1SMarcel Apfelbaum mailbox = mlx4_alloc_cmd_mailbox(dev); 2895cc914f1SMarcel Apfelbaum if (IS_ERR(mailbox)) 2905cc914f1SMarcel Apfelbaum return PTR_ERR(mailbox); 2915cc914f1SMarcel Apfelbaum 29247605df9SJack Morgenstein err = mlx4_cmd_box(dev, 0, mailbox->dma, gen_or_port, op_modifier, 29347605df9SJack Morgenstein MLX4_CMD_QUERY_FUNC_CAP, 2945cc914f1SMarcel Apfelbaum MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); 2955cc914f1SMarcel Apfelbaum if (err) 2965cc914f1SMarcel Apfelbaum goto out; 2975cc914f1SMarcel Apfelbaum 2985cc914f1SMarcel Apfelbaum outbox = mailbox->buf; 2995cc914f1SMarcel Apfelbaum 30047605df9SJack Morgenstein if (!op_modifier) { 3015cc914f1SMarcel Apfelbaum MLX4_GET(field, outbox, QUERY_FUNC_CAP_FLAGS_OFFSET); 302105c320fSJack Morgenstein if (!(field & (QUERY_FUNC_CAP_FLAG_ETH | QUERY_FUNC_CAP_FLAG_RDMA))) { 303105c320fSJack Morgenstein mlx4_err(dev, "The host supports neither eth nor rdma interfaces\n"); 3045cc914f1SMarcel Apfelbaum err = -EPROTONOSUPPORT; 3055cc914f1SMarcel Apfelbaum goto out; 3065cc914f1SMarcel Apfelbaum } 307105c320fSJack Morgenstein func_cap->flags = field; 3085cc914f1SMarcel Apfelbaum 3095cc914f1SMarcel Apfelbaum MLX4_GET(field, outbox, QUERY_FUNC_CAP_NUM_PORTS_OFFSET); 3105cc914f1SMarcel Apfelbaum func_cap->num_ports = field; 3115cc914f1SMarcel Apfelbaum 3125cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_PF_BHVR_OFFSET); 3135cc914f1SMarcel Apfelbaum func_cap->pf_context_behaviour = size; 3145cc914f1SMarcel Apfelbaum 3155cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP_QUOTA_OFFSET); 3165cc914f1SMarcel Apfelbaum func_cap->qp_quota = size & 0xFFFFFF; 3175cc914f1SMarcel Apfelbaum 3185cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_SRQ_QUOTA_OFFSET); 3195cc914f1SMarcel Apfelbaum func_cap->srq_quota = size & 0xFFFFFF; 3205cc914f1SMarcel Apfelbaum 3215cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET); 3225cc914f1SMarcel Apfelbaum func_cap->cq_quota = size & 0xFFFFFF; 3235cc914f1SMarcel Apfelbaum 3245cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_MAX_EQ_OFFSET); 3255cc914f1SMarcel Apfelbaum func_cap->max_eq = size & 0xFFFFFF; 3265cc914f1SMarcel Apfelbaum 3275cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET); 3285cc914f1SMarcel Apfelbaum func_cap->reserved_eq = size & 0xFFFFFF; 3295cc914f1SMarcel Apfelbaum 3305cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET); 3315cc914f1SMarcel Apfelbaum func_cap->mpt_quota = size & 0xFFFFFF; 3325cc914f1SMarcel Apfelbaum 3335cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_MTT_QUOTA_OFFSET); 3345cc914f1SMarcel Apfelbaum func_cap->mtt_quota = size & 0xFFFFFF; 3355cc914f1SMarcel Apfelbaum 3365cc914f1SMarcel Apfelbaum MLX4_GET(size, outbox, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET); 3375cc914f1SMarcel Apfelbaum func_cap->mcg_quota = size & 0xFFFFFF; 3385cc914f1SMarcel Apfelbaum goto out; 33947605df9SJack Morgenstein } 3405cc914f1SMarcel Apfelbaum 34147605df9SJack Morgenstein /* logical port query */ 34247605df9SJack Morgenstein if (gen_or_port > dev->caps.num_ports) { 34347605df9SJack Morgenstein err = -EINVAL; 34447605df9SJack Morgenstein goto out; 34547605df9SJack Morgenstein } 34647605df9SJack Morgenstein 34747605df9SJack Morgenstein if (dev->caps.port_type[gen_or_port] == MLX4_PORT_TYPE_ETH) { 3485cc914f1SMarcel Apfelbaum MLX4_GET(field, outbox, QUERY_FUNC_CAP_ETH_PROPS_OFFSET); 349105c320fSJack Morgenstein if (field & QUERY_FUNC_CAP_ETH_PROPS_FORCE_VLAN) { 3505cc914f1SMarcel Apfelbaum mlx4_err(dev, "VLAN is enforced on this port\n"); 3515cc914f1SMarcel Apfelbaum err = -EPROTONOSUPPORT; 3525cc914f1SMarcel Apfelbaum goto out; 3535cc914f1SMarcel Apfelbaum } 3545cc914f1SMarcel Apfelbaum 355105c320fSJack Morgenstein if (field & QUERY_FUNC_CAP_ETH_PROPS_FORCE_MAC) { 3565cc914f1SMarcel Apfelbaum mlx4_err(dev, "Force mac is enabled on this port\n"); 3575cc914f1SMarcel Apfelbaum err = -EPROTONOSUPPORT; 3585cc914f1SMarcel Apfelbaum goto out; 3595cc914f1SMarcel Apfelbaum } 36047605df9SJack Morgenstein } else if (dev->caps.port_type[gen_or_port] == MLX4_PORT_TYPE_IB) { 361105c320fSJack Morgenstein MLX4_GET(field, outbox, QUERY_FUNC_CAP_RDMA_PROPS_OFFSET); 362105c320fSJack Morgenstein if (field & QUERY_FUNC_CAP_RDMA_PROPS_FORCE_PHY_WQE_GID) { 363105c320fSJack Morgenstein mlx4_err(dev, "phy_wqe_gid is " 364105c320fSJack Morgenstein "enforced on this ib port\n"); 365105c320fSJack Morgenstein err = -EPROTONOSUPPORT; 366105c320fSJack Morgenstein goto out; 367105c320fSJack Morgenstein } 368105c320fSJack Morgenstein } 3695cc914f1SMarcel Apfelbaum 3705cc914f1SMarcel Apfelbaum MLX4_GET(field, outbox, QUERY_FUNC_CAP_PHYS_PORT_OFFSET); 37147605df9SJack Morgenstein func_cap->physical_port = field; 37247605df9SJack Morgenstein if (func_cap->physical_port != gen_or_port) { 37347605df9SJack Morgenstein err = -ENOSYS; 37447605df9SJack Morgenstein goto out; 3755cc914f1SMarcel Apfelbaum } 3765cc914f1SMarcel Apfelbaum 37747605df9SJack Morgenstein MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_TUNNEL); 37847605df9SJack Morgenstein func_cap->qp0_tunnel_qpn = size & 0xFFFFFF; 37947605df9SJack Morgenstein 38047605df9SJack Morgenstein MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_PROXY); 38147605df9SJack Morgenstein func_cap->qp0_proxy_qpn = size & 0xFFFFFF; 38247605df9SJack Morgenstein 38347605df9SJack Morgenstein MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP1_TUNNEL); 38447605df9SJack Morgenstein func_cap->qp1_tunnel_qpn = size & 0xFFFFFF; 38547605df9SJack Morgenstein 38647605df9SJack Morgenstein MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP1_PROXY); 38747605df9SJack Morgenstein func_cap->qp1_proxy_qpn = size & 0xFFFFFF; 38847605df9SJack Morgenstein 3895cc914f1SMarcel Apfelbaum /* All other resources are allocated by the master, but we still report 3905cc914f1SMarcel Apfelbaum * 'num' and 'reserved' capabilities as follows: 3915cc914f1SMarcel Apfelbaum * - num remains the maximum resource index 3925cc914f1SMarcel Apfelbaum * - 'num - reserved' is the total available objects of a resource, but 3935cc914f1SMarcel Apfelbaum * resource indices may be less than 'reserved' 3945cc914f1SMarcel Apfelbaum * TODO: set per-resource quotas */ 3955cc914f1SMarcel Apfelbaum 3965cc914f1SMarcel Apfelbaum out: 3975cc914f1SMarcel Apfelbaum mlx4_free_cmd_mailbox(dev, mailbox); 3985cc914f1SMarcel Apfelbaum 3995cc914f1SMarcel Apfelbaum return err; 4005cc914f1SMarcel Apfelbaum } 4015cc914f1SMarcel Apfelbaum 4025a2cc190SJeff Kirsher int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) 4035a2cc190SJeff Kirsher { 4045a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 4055a2cc190SJeff Kirsher u32 *outbox; 4065a2cc190SJeff Kirsher u8 field; 4075a2cc190SJeff Kirsher u32 field32, flags, ext_flags; 4085a2cc190SJeff Kirsher u16 size; 4095a2cc190SJeff Kirsher u16 stat_rate; 4105a2cc190SJeff Kirsher int err; 4115a2cc190SJeff Kirsher int i; 4125a2cc190SJeff Kirsher 4135a2cc190SJeff Kirsher #define QUERY_DEV_CAP_OUT_SIZE 0x100 4145a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_SRQ_SZ_OFFSET 0x10 4155a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_QP_SZ_OFFSET 0x11 4165a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_QP_OFFSET 0x12 4175a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_QP_OFFSET 0x13 4185a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_SRQ_OFFSET 0x14 4195a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_SRQ_OFFSET 0x15 4205a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_EEC_OFFSET 0x16 4215a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_EEC_OFFSET 0x17 4225a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_CQ_SZ_OFFSET 0x19 4235a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_CQ_OFFSET 0x1a 4245a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_CQ_OFFSET 0x1b 4255a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_MPT_OFFSET 0x1d 4265a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_EQ_OFFSET 0x1e 4275a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_EQ_OFFSET 0x1f 4285a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_MTT_OFFSET 0x20 4295a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_MRW_SZ_OFFSET 0x21 4305a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_MRW_OFFSET 0x22 4315a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_MTT_SEG_OFFSET 0x23 4325a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_AV_OFFSET 0x27 4335a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_REQ_QP_OFFSET 0x29 4345a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_RES_QP_OFFSET 0x2b 4355a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_GSO_OFFSET 0x2d 436b3416f44SShlomo Pongratz #define QUERY_DEV_CAP_RSS_OFFSET 0x2e 4375a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_RDMA_OFFSET 0x2f 4385a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSZ_SRQ_OFFSET 0x33 4395a2cc190SJeff Kirsher #define QUERY_DEV_CAP_ACK_DELAY_OFFSET 0x35 4405a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MTU_WIDTH_OFFSET 0x36 4415a2cc190SJeff Kirsher #define QUERY_DEV_CAP_VL_PORT_OFFSET 0x37 4425a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_MSG_SZ_OFFSET 0x38 4435a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_GID_OFFSET 0x3b 4445a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RATE_SUPPORT_OFFSET 0x3c 4455a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_PKEY_OFFSET 0x3f 4465a2cc190SJeff Kirsher #define QUERY_DEV_CAP_EXT_FLAGS_OFFSET 0x40 4475a2cc190SJeff Kirsher #define QUERY_DEV_CAP_FLAGS_OFFSET 0x44 4485a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_UAR_OFFSET 0x48 4495a2cc190SJeff Kirsher #define QUERY_DEV_CAP_UAR_SZ_OFFSET 0x49 4505a2cc190SJeff Kirsher #define QUERY_DEV_CAP_PAGE_SZ_OFFSET 0x4b 4515a2cc190SJeff Kirsher #define QUERY_DEV_CAP_BF_OFFSET 0x4c 4525a2cc190SJeff Kirsher #define QUERY_DEV_CAP_LOG_BF_REG_SZ_OFFSET 0x4d 4535a2cc190SJeff Kirsher #define QUERY_DEV_CAP_LOG_MAX_BF_REGS_PER_PAGE_OFFSET 0x4e 4545a2cc190SJeff Kirsher #define QUERY_DEV_CAP_LOG_MAX_BF_PAGES_OFFSET 0x4f 4555a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_SG_SQ_OFFSET 0x51 4565a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_DESC_SZ_SQ_OFFSET 0x52 4575a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_SG_RQ_OFFSET 0x55 4585a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_DESC_SZ_RQ_OFFSET 0x56 4595a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_QP_MCG_OFFSET 0x61 4605a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_MCG_OFFSET 0x62 4615a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_MCG_OFFSET 0x63 4625a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_PD_OFFSET 0x64 4635a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_PD_OFFSET 0x65 464f470f8d4SLinus Torvalds #define QUERY_DEV_CAP_RSVD_XRC_OFFSET 0x66 465f470f8d4SLinus Torvalds #define QUERY_DEV_CAP_MAX_XRC_OFFSET 0x67 4665a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_COUNTERS_OFFSET 0x68 4670ff1fb65SHadar Hen Zion #define QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET 0x76 4680ff1fb65SHadar Hen Zion #define QUERY_DEV_CAP_FLOW_STEERING_MAX_QP_OFFSET 0x77 4695a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RDMARC_ENTRY_SZ_OFFSET 0x80 4705a2cc190SJeff Kirsher #define QUERY_DEV_CAP_QPC_ENTRY_SZ_OFFSET 0x82 4715a2cc190SJeff Kirsher #define QUERY_DEV_CAP_AUX_ENTRY_SZ_OFFSET 0x84 4725a2cc190SJeff Kirsher #define QUERY_DEV_CAP_ALTC_ENTRY_SZ_OFFSET 0x86 4735a2cc190SJeff Kirsher #define QUERY_DEV_CAP_EQC_ENTRY_SZ_OFFSET 0x88 4745a2cc190SJeff Kirsher #define QUERY_DEV_CAP_CQC_ENTRY_SZ_OFFSET 0x8a 4755a2cc190SJeff Kirsher #define QUERY_DEV_CAP_SRQ_ENTRY_SZ_OFFSET 0x8c 4765a2cc190SJeff Kirsher #define QUERY_DEV_CAP_C_MPT_ENTRY_SZ_OFFSET 0x8e 4775a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MTT_ENTRY_SZ_OFFSET 0x90 4785a2cc190SJeff Kirsher #define QUERY_DEV_CAP_D_MPT_ENTRY_SZ_OFFSET 0x92 4795a2cc190SJeff Kirsher #define QUERY_DEV_CAP_BMME_FLAGS_OFFSET 0x94 4805a2cc190SJeff Kirsher #define QUERY_DEV_CAP_RSVD_LKEY_OFFSET 0x98 4815a2cc190SJeff Kirsher #define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0 482*955154faSMatan Barak #define QUERY_DEV_CAP_FW_REASSIGN_MAC 0x9d 4835a2cc190SJeff Kirsher 484b3416f44SShlomo Pongratz dev_cap->flags2 = 0; 4855a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 4865a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 4875a2cc190SJeff Kirsher return PTR_ERR(mailbox); 4885a2cc190SJeff Kirsher outbox = mailbox->buf; 4895a2cc190SJeff Kirsher 4905a2cc190SJeff Kirsher err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 0, MLX4_CMD_QUERY_DEV_CAP, 491401453a3SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 4925a2cc190SJeff Kirsher if (err) 4935a2cc190SJeff Kirsher goto out; 4945a2cc190SJeff Kirsher 4955a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_QP_OFFSET); 4965a2cc190SJeff Kirsher dev_cap->reserved_qps = 1 << (field & 0xf); 4975a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_QP_OFFSET); 4985a2cc190SJeff Kirsher dev_cap->max_qps = 1 << (field & 0x1f); 4995a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_SRQ_OFFSET); 5005a2cc190SJeff Kirsher dev_cap->reserved_srqs = 1 << (field >> 4); 5015a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_SRQ_OFFSET); 5025a2cc190SJeff Kirsher dev_cap->max_srqs = 1 << (field & 0x1f); 5035a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_CQ_SZ_OFFSET); 5045a2cc190SJeff Kirsher dev_cap->max_cq_sz = 1 << field; 5055a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_CQ_OFFSET); 5065a2cc190SJeff Kirsher dev_cap->reserved_cqs = 1 << (field & 0xf); 5075a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_CQ_OFFSET); 5085a2cc190SJeff Kirsher dev_cap->max_cqs = 1 << (field & 0x1f); 5095a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MPT_OFFSET); 5105a2cc190SJeff Kirsher dev_cap->max_mpts = 1 << (field & 0x3f); 5115a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_EQ_OFFSET); 5125a2cc190SJeff Kirsher dev_cap->reserved_eqs = field & 0xf; 5135a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_EQ_OFFSET); 5145a2cc190SJeff Kirsher dev_cap->max_eqs = 1 << (field & 0xf); 5155a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_MTT_OFFSET); 5165a2cc190SJeff Kirsher dev_cap->reserved_mtts = 1 << (field >> 4); 5175a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MRW_SZ_OFFSET); 5185a2cc190SJeff Kirsher dev_cap->max_mrw_sz = 1 << field; 5195a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_MRW_OFFSET); 5205a2cc190SJeff Kirsher dev_cap->reserved_mrws = 1 << (field & 0xf); 5215a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MTT_SEG_OFFSET); 5225a2cc190SJeff Kirsher dev_cap->max_mtt_seg = 1 << (field & 0x3f); 5235a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_REQ_QP_OFFSET); 5245a2cc190SJeff Kirsher dev_cap->max_requester_per_qp = 1 << (field & 0x3f); 5255a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_RES_QP_OFFSET); 5265a2cc190SJeff Kirsher dev_cap->max_responder_per_qp = 1 << (field & 0x3f); 5275a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_GSO_OFFSET); 5285a2cc190SJeff Kirsher field &= 0x1f; 5295a2cc190SJeff Kirsher if (!field) 5305a2cc190SJeff Kirsher dev_cap->max_gso_sz = 0; 5315a2cc190SJeff Kirsher else 5325a2cc190SJeff Kirsher dev_cap->max_gso_sz = 1 << field; 5335a2cc190SJeff Kirsher 534b3416f44SShlomo Pongratz MLX4_GET(field, outbox, QUERY_DEV_CAP_RSS_OFFSET); 535b3416f44SShlomo Pongratz if (field & 0x20) 536b3416f44SShlomo Pongratz dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_RSS_XOR; 537b3416f44SShlomo Pongratz if (field & 0x10) 538b3416f44SShlomo Pongratz dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_RSS_TOP; 539b3416f44SShlomo Pongratz field &= 0xf; 540b3416f44SShlomo Pongratz if (field) { 541b3416f44SShlomo Pongratz dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_RSS; 542b3416f44SShlomo Pongratz dev_cap->max_rss_tbl_sz = 1 << field; 543b3416f44SShlomo Pongratz } else 544b3416f44SShlomo Pongratz dev_cap->max_rss_tbl_sz = 0; 5455a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_RDMA_OFFSET); 5465a2cc190SJeff Kirsher dev_cap->max_rdma_global = 1 << (field & 0x3f); 5475a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_ACK_DELAY_OFFSET); 5485a2cc190SJeff Kirsher dev_cap->local_ca_ack_delay = field & 0x1f; 5495a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_VL_PORT_OFFSET); 5505a2cc190SJeff Kirsher dev_cap->num_ports = field & 0xf; 5515a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MSG_SZ_OFFSET); 5525a2cc190SJeff Kirsher dev_cap->max_msg_sz = 1 << (field & 0x1f); 5530ff1fb65SHadar Hen Zion MLX4_GET(field, outbox, QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET); 5540ff1fb65SHadar Hen Zion if (field & 0x80) 5550ff1fb65SHadar Hen Zion dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_FS_EN; 5560ff1fb65SHadar Hen Zion dev_cap->fs_log_max_ucast_qp_range_size = field & 0x1f; 5570ff1fb65SHadar Hen Zion MLX4_GET(field, outbox, QUERY_DEV_CAP_FLOW_STEERING_MAX_QP_OFFSET); 5580ff1fb65SHadar Hen Zion dev_cap->fs_max_num_qp_per_entry = field; 5595a2cc190SJeff Kirsher MLX4_GET(stat_rate, outbox, QUERY_DEV_CAP_RATE_SUPPORT_OFFSET); 5605a2cc190SJeff Kirsher dev_cap->stat_rate_support = stat_rate; 5615a2cc190SJeff Kirsher MLX4_GET(ext_flags, outbox, QUERY_DEV_CAP_EXT_FLAGS_OFFSET); 5625a2cc190SJeff Kirsher MLX4_GET(flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET); 5635a2cc190SJeff Kirsher dev_cap->flags = flags | (u64)ext_flags << 32; 5645a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_UAR_OFFSET); 5655a2cc190SJeff Kirsher dev_cap->reserved_uars = field >> 4; 5665a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_UAR_SZ_OFFSET); 5675a2cc190SJeff Kirsher dev_cap->uar_size = 1 << ((field & 0x3f) + 20); 5685a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_PAGE_SZ_OFFSET); 5695a2cc190SJeff Kirsher dev_cap->min_page_sz = 1 << field; 5705a2cc190SJeff Kirsher 5715a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_BF_OFFSET); 5725a2cc190SJeff Kirsher if (field & 0x80) { 5735a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_LOG_BF_REG_SZ_OFFSET); 5745a2cc190SJeff Kirsher dev_cap->bf_reg_size = 1 << (field & 0x1f); 5755a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_LOG_MAX_BF_REGS_PER_PAGE_OFFSET); 5765a2cc190SJeff Kirsher if ((1 << (field & 0x3f)) > (PAGE_SIZE / dev_cap->bf_reg_size)) 5775a2cc190SJeff Kirsher field = 3; 5785a2cc190SJeff Kirsher dev_cap->bf_regs_per_page = 1 << (field & 0x3f); 5795a2cc190SJeff Kirsher mlx4_dbg(dev, "BlueFlame available (reg size %d, regs/page %d)\n", 5805a2cc190SJeff Kirsher dev_cap->bf_reg_size, dev_cap->bf_regs_per_page); 5815a2cc190SJeff Kirsher } else { 5825a2cc190SJeff Kirsher dev_cap->bf_reg_size = 0; 5835a2cc190SJeff Kirsher mlx4_dbg(dev, "BlueFlame not available\n"); 5845a2cc190SJeff Kirsher } 5855a2cc190SJeff Kirsher 5865a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_SG_SQ_OFFSET); 5875a2cc190SJeff Kirsher dev_cap->max_sq_sg = field; 5885a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_MAX_DESC_SZ_SQ_OFFSET); 5895a2cc190SJeff Kirsher dev_cap->max_sq_desc_sz = size; 5905a2cc190SJeff Kirsher 5915a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_QP_MCG_OFFSET); 5925a2cc190SJeff Kirsher dev_cap->max_qp_per_mcg = 1 << field; 5935a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_MCG_OFFSET); 5945a2cc190SJeff Kirsher dev_cap->reserved_mgms = field & 0xf; 5955a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MCG_OFFSET); 5965a2cc190SJeff Kirsher dev_cap->max_mcgs = 1 << field; 5975a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_PD_OFFSET); 5985a2cc190SJeff Kirsher dev_cap->reserved_pds = field >> 4; 5995a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_PD_OFFSET); 6005a2cc190SJeff Kirsher dev_cap->max_pds = 1 << (field & 0x3f); 601f470f8d4SLinus Torvalds MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_XRC_OFFSET); 602f470f8d4SLinus Torvalds dev_cap->reserved_xrcds = field >> 4; 603426dd00dSDotan Barak MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_XRC_OFFSET); 604f470f8d4SLinus Torvalds dev_cap->max_xrcds = 1 << (field & 0x1f); 6055a2cc190SJeff Kirsher 6065a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_RDMARC_ENTRY_SZ_OFFSET); 6075a2cc190SJeff Kirsher dev_cap->rdmarc_entry_sz = size; 6085a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_QPC_ENTRY_SZ_OFFSET); 6095a2cc190SJeff Kirsher dev_cap->qpc_entry_sz = size; 6105a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_AUX_ENTRY_SZ_OFFSET); 6115a2cc190SJeff Kirsher dev_cap->aux_entry_sz = size; 6125a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_ALTC_ENTRY_SZ_OFFSET); 6135a2cc190SJeff Kirsher dev_cap->altc_entry_sz = size; 6145a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_EQC_ENTRY_SZ_OFFSET); 6155a2cc190SJeff Kirsher dev_cap->eqc_entry_sz = size; 6165a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_CQC_ENTRY_SZ_OFFSET); 6175a2cc190SJeff Kirsher dev_cap->cqc_entry_sz = size; 6185a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_SRQ_ENTRY_SZ_OFFSET); 6195a2cc190SJeff Kirsher dev_cap->srq_entry_sz = size; 6205a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_C_MPT_ENTRY_SZ_OFFSET); 6215a2cc190SJeff Kirsher dev_cap->cmpt_entry_sz = size; 6225a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_MTT_ENTRY_SZ_OFFSET); 6235a2cc190SJeff Kirsher dev_cap->mtt_entry_sz = size; 6245a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_D_MPT_ENTRY_SZ_OFFSET); 6255a2cc190SJeff Kirsher dev_cap->dmpt_entry_sz = size; 6265a2cc190SJeff Kirsher 6275a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_SRQ_SZ_OFFSET); 6285a2cc190SJeff Kirsher dev_cap->max_srq_sz = 1 << field; 6295a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_QP_SZ_OFFSET); 6305a2cc190SJeff Kirsher dev_cap->max_qp_sz = 1 << field; 6315a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_RSZ_SRQ_OFFSET); 6325a2cc190SJeff Kirsher dev_cap->resize_srq = field & 1; 6335a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_SG_RQ_OFFSET); 6345a2cc190SJeff Kirsher dev_cap->max_rq_sg = field; 6355a2cc190SJeff Kirsher MLX4_GET(size, outbox, QUERY_DEV_CAP_MAX_DESC_SZ_RQ_OFFSET); 6365a2cc190SJeff Kirsher dev_cap->max_rq_desc_sz = size; 6375a2cc190SJeff Kirsher 6385a2cc190SJeff Kirsher MLX4_GET(dev_cap->bmme_flags, outbox, 6395a2cc190SJeff Kirsher QUERY_DEV_CAP_BMME_FLAGS_OFFSET); 6405a2cc190SJeff Kirsher MLX4_GET(dev_cap->reserved_lkey, outbox, 6415a2cc190SJeff Kirsher QUERY_DEV_CAP_RSVD_LKEY_OFFSET); 642*955154faSMatan Barak MLX4_GET(field, outbox, QUERY_DEV_CAP_FW_REASSIGN_MAC); 643*955154faSMatan Barak if (field & 1<<6) 644*955154faSMatan Barak dev_cap->flags2 |= MLX4_DEV_CAP_FLAGS2_REASSIGN_MAC_EN; 6455a2cc190SJeff Kirsher MLX4_GET(dev_cap->max_icm_sz, outbox, 6465a2cc190SJeff Kirsher QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET); 6475a2cc190SJeff Kirsher if (dev_cap->flags & MLX4_DEV_CAP_FLAG_COUNTERS) 6485a2cc190SJeff Kirsher MLX4_GET(dev_cap->max_counters, outbox, 6495a2cc190SJeff Kirsher QUERY_DEV_CAP_MAX_COUNTERS_OFFSET); 6505a2cc190SJeff Kirsher 6515a2cc190SJeff Kirsher if (dev->flags & MLX4_FLAG_OLD_PORT_CMDS) { 6525a2cc190SJeff Kirsher for (i = 1; i <= dev_cap->num_ports; ++i) { 6535a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_VL_PORT_OFFSET); 6545a2cc190SJeff Kirsher dev_cap->max_vl[i] = field >> 4; 6555a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MTU_WIDTH_OFFSET); 6565a2cc190SJeff Kirsher dev_cap->ib_mtu[i] = field >> 4; 6575a2cc190SJeff Kirsher dev_cap->max_port_width[i] = field & 0xf; 6585a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_GID_OFFSET); 6595a2cc190SJeff Kirsher dev_cap->max_gids[i] = 1 << (field & 0xf); 6605a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_PKEY_OFFSET); 6615a2cc190SJeff Kirsher dev_cap->max_pkeys[i] = 1 << (field & 0xf); 6625a2cc190SJeff Kirsher } 6635a2cc190SJeff Kirsher } else { 6645a2cc190SJeff Kirsher #define QUERY_PORT_SUPPORTED_TYPE_OFFSET 0x00 6655a2cc190SJeff Kirsher #define QUERY_PORT_MTU_OFFSET 0x01 6665a2cc190SJeff Kirsher #define QUERY_PORT_ETH_MTU_OFFSET 0x02 6675a2cc190SJeff Kirsher #define QUERY_PORT_WIDTH_OFFSET 0x06 6685a2cc190SJeff Kirsher #define QUERY_PORT_MAX_GID_PKEY_OFFSET 0x07 6695a2cc190SJeff Kirsher #define QUERY_PORT_MAX_MACVLAN_OFFSET 0x0a 6705a2cc190SJeff Kirsher #define QUERY_PORT_MAX_VL_OFFSET 0x0b 6715a2cc190SJeff Kirsher #define QUERY_PORT_MAC_OFFSET 0x10 6725a2cc190SJeff Kirsher #define QUERY_PORT_TRANS_VENDOR_OFFSET 0x18 6735a2cc190SJeff Kirsher #define QUERY_PORT_WAVELENGTH_OFFSET 0x1c 6745a2cc190SJeff Kirsher #define QUERY_PORT_TRANS_CODE_OFFSET 0x20 6755a2cc190SJeff Kirsher 6765a2cc190SJeff Kirsher for (i = 1; i <= dev_cap->num_ports; ++i) { 6775a2cc190SJeff Kirsher err = mlx4_cmd_box(dev, 0, mailbox->dma, i, 0, MLX4_CMD_QUERY_PORT, 678401453a3SJack Morgenstein MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 6795a2cc190SJeff Kirsher if (err) 6805a2cc190SJeff Kirsher goto out; 6815a2cc190SJeff Kirsher 6825a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_PORT_SUPPORTED_TYPE_OFFSET); 6835a2cc190SJeff Kirsher dev_cap->supported_port_types[i] = field & 3; 6848d0fc7b6SYevgeny Petrilin dev_cap->suggested_type[i] = (field >> 3) & 1; 6858d0fc7b6SYevgeny Petrilin dev_cap->default_sense[i] = (field >> 4) & 1; 6865a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_PORT_MTU_OFFSET); 6875a2cc190SJeff Kirsher dev_cap->ib_mtu[i] = field & 0xf; 6885a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_PORT_WIDTH_OFFSET); 6895a2cc190SJeff Kirsher dev_cap->max_port_width[i] = field & 0xf; 6905a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_PORT_MAX_GID_PKEY_OFFSET); 6915a2cc190SJeff Kirsher dev_cap->max_gids[i] = 1 << (field >> 4); 6925a2cc190SJeff Kirsher dev_cap->max_pkeys[i] = 1 << (field & 0xf); 6935a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_PORT_MAX_VL_OFFSET); 6945a2cc190SJeff Kirsher dev_cap->max_vl[i] = field & 0xf; 6955a2cc190SJeff Kirsher MLX4_GET(field, outbox, QUERY_PORT_MAX_MACVLAN_OFFSET); 6965a2cc190SJeff Kirsher dev_cap->log_max_macs[i] = field & 0xf; 6975a2cc190SJeff Kirsher dev_cap->log_max_vlans[i] = field >> 4; 6985a2cc190SJeff Kirsher MLX4_GET(dev_cap->eth_mtu[i], outbox, QUERY_PORT_ETH_MTU_OFFSET); 6995a2cc190SJeff Kirsher MLX4_GET(dev_cap->def_mac[i], outbox, QUERY_PORT_MAC_OFFSET); 7005a2cc190SJeff Kirsher MLX4_GET(field32, outbox, QUERY_PORT_TRANS_VENDOR_OFFSET); 7015a2cc190SJeff Kirsher dev_cap->trans_type[i] = field32 >> 24; 7025a2cc190SJeff Kirsher dev_cap->vendor_oui[i] = field32 & 0xffffff; 7035a2cc190SJeff Kirsher MLX4_GET(dev_cap->wavelength[i], outbox, QUERY_PORT_WAVELENGTH_OFFSET); 7045a2cc190SJeff Kirsher MLX4_GET(dev_cap->trans_code[i], outbox, QUERY_PORT_TRANS_CODE_OFFSET); 7055a2cc190SJeff Kirsher } 7065a2cc190SJeff Kirsher } 7075a2cc190SJeff Kirsher 7085a2cc190SJeff Kirsher mlx4_dbg(dev, "Base MM extensions: flags %08x, rsvd L_Key %08x\n", 7095a2cc190SJeff Kirsher dev_cap->bmme_flags, dev_cap->reserved_lkey); 7105a2cc190SJeff Kirsher 7115a2cc190SJeff Kirsher /* 7125a2cc190SJeff Kirsher * Each UAR has 4 EQ doorbells; so if a UAR is reserved, then 7135a2cc190SJeff Kirsher * we can't use any EQs whose doorbell falls on that page, 7145a2cc190SJeff Kirsher * even if the EQ itself isn't reserved. 7155a2cc190SJeff Kirsher */ 7165a2cc190SJeff Kirsher dev_cap->reserved_eqs = max(dev_cap->reserved_uars * 4, 7175a2cc190SJeff Kirsher dev_cap->reserved_eqs); 7185a2cc190SJeff Kirsher 7195a2cc190SJeff Kirsher mlx4_dbg(dev, "Max ICM size %lld MB\n", 7205a2cc190SJeff Kirsher (unsigned long long) dev_cap->max_icm_sz >> 20); 7215a2cc190SJeff Kirsher mlx4_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n", 7225a2cc190SJeff Kirsher dev_cap->max_qps, dev_cap->reserved_qps, dev_cap->qpc_entry_sz); 7235a2cc190SJeff Kirsher mlx4_dbg(dev, "Max SRQs: %d, reserved SRQs: %d, entry size: %d\n", 7245a2cc190SJeff Kirsher dev_cap->max_srqs, dev_cap->reserved_srqs, dev_cap->srq_entry_sz); 7255a2cc190SJeff Kirsher mlx4_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n", 7265a2cc190SJeff Kirsher dev_cap->max_cqs, dev_cap->reserved_cqs, dev_cap->cqc_entry_sz); 7275a2cc190SJeff Kirsher mlx4_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n", 7285a2cc190SJeff Kirsher dev_cap->max_eqs, dev_cap->reserved_eqs, dev_cap->eqc_entry_sz); 7295a2cc190SJeff Kirsher mlx4_dbg(dev, "reserved MPTs: %d, reserved MTTs: %d\n", 7305a2cc190SJeff Kirsher dev_cap->reserved_mrws, dev_cap->reserved_mtts); 7315a2cc190SJeff Kirsher mlx4_dbg(dev, "Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n", 7325a2cc190SJeff Kirsher dev_cap->max_pds, dev_cap->reserved_pds, dev_cap->reserved_uars); 7335a2cc190SJeff Kirsher mlx4_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n", 7345a2cc190SJeff Kirsher dev_cap->max_pds, dev_cap->reserved_mgms); 7355a2cc190SJeff Kirsher mlx4_dbg(dev, "Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n", 7365a2cc190SJeff Kirsher dev_cap->max_cq_sz, dev_cap->max_qp_sz, dev_cap->max_srq_sz); 7375a2cc190SJeff Kirsher mlx4_dbg(dev, "Local CA ACK delay: %d, max MTU: %d, port width cap: %d\n", 7385a2cc190SJeff Kirsher dev_cap->local_ca_ack_delay, 128 << dev_cap->ib_mtu[1], 7395a2cc190SJeff Kirsher dev_cap->max_port_width[1]); 7405a2cc190SJeff Kirsher mlx4_dbg(dev, "Max SQ desc size: %d, max SQ S/G: %d\n", 7415a2cc190SJeff Kirsher dev_cap->max_sq_desc_sz, dev_cap->max_sq_sg); 7425a2cc190SJeff Kirsher mlx4_dbg(dev, "Max RQ desc size: %d, max RQ S/G: %d\n", 7435a2cc190SJeff Kirsher dev_cap->max_rq_desc_sz, dev_cap->max_rq_sg); 7445a2cc190SJeff Kirsher mlx4_dbg(dev, "Max GSO size: %d\n", dev_cap->max_gso_sz); 7455a2cc190SJeff Kirsher mlx4_dbg(dev, "Max counters: %d\n", dev_cap->max_counters); 746b3416f44SShlomo Pongratz mlx4_dbg(dev, "Max RSS Table size: %d\n", dev_cap->max_rss_tbl_sz); 7475a2cc190SJeff Kirsher 7485a2cc190SJeff Kirsher dump_dev_cap_flags(dev, dev_cap->flags); 749b3416f44SShlomo Pongratz dump_dev_cap_flags2(dev, dev_cap->flags2); 7505a2cc190SJeff Kirsher 7515a2cc190SJeff Kirsher out: 7525a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 7535a2cc190SJeff Kirsher return err; 7545a2cc190SJeff Kirsher } 7555a2cc190SJeff Kirsher 756b91cb3ebSJack Morgenstein int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave, 757b91cb3ebSJack Morgenstein struct mlx4_vhcr *vhcr, 758b91cb3ebSJack Morgenstein struct mlx4_cmd_mailbox *inbox, 759b91cb3ebSJack Morgenstein struct mlx4_cmd_mailbox *outbox, 760b91cb3ebSJack Morgenstein struct mlx4_cmd_info *cmd) 761b91cb3ebSJack Morgenstein { 7622a4fae14SJack Morgenstein u64 flags; 763b91cb3ebSJack Morgenstein int err = 0; 764b91cb3ebSJack Morgenstein u8 field; 765b91cb3ebSJack Morgenstein 766b91cb3ebSJack Morgenstein err = mlx4_cmd_box(dev, 0, outbox->dma, 0, 0, MLX4_CMD_QUERY_DEV_CAP, 767b91cb3ebSJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 768b91cb3ebSJack Morgenstein if (err) 769b91cb3ebSJack Morgenstein return err; 770b91cb3ebSJack Morgenstein 7712a4fae14SJack Morgenstein /* add port mng change event capability unconditionally to slaves */ 7722a4fae14SJack Morgenstein MLX4_GET(flags, outbox->buf, QUERY_DEV_CAP_EXT_FLAGS_OFFSET); 7732a4fae14SJack Morgenstein flags |= MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV; 7742a4fae14SJack Morgenstein MLX4_PUT(outbox->buf, flags, QUERY_DEV_CAP_EXT_FLAGS_OFFSET); 7752a4fae14SJack Morgenstein 776b91cb3ebSJack Morgenstein /* For guests, report Blueflame disabled */ 777b91cb3ebSJack Morgenstein MLX4_GET(field, outbox->buf, QUERY_DEV_CAP_BF_OFFSET); 778b91cb3ebSJack Morgenstein field &= 0x7f; 779b91cb3ebSJack Morgenstein MLX4_PUT(outbox->buf, field, QUERY_DEV_CAP_BF_OFFSET); 780b91cb3ebSJack Morgenstein 781b91cb3ebSJack Morgenstein return 0; 782b91cb3ebSJack Morgenstein } 783b91cb3ebSJack Morgenstein 7845cc914f1SMarcel Apfelbaum int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, 7855cc914f1SMarcel Apfelbaum struct mlx4_vhcr *vhcr, 7865cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *inbox, 7875cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *outbox, 7885cc914f1SMarcel Apfelbaum struct mlx4_cmd_info *cmd) 7895cc914f1SMarcel Apfelbaum { 7905cc914f1SMarcel Apfelbaum u64 def_mac; 7915cc914f1SMarcel Apfelbaum u8 port_type; 7926634961cSJack Morgenstein u16 short_field; 7935cc914f1SMarcel Apfelbaum int err; 7945cc914f1SMarcel Apfelbaum 795105c320fSJack Morgenstein #define MLX4_VF_PORT_NO_LINK_SENSE_MASK 0xE0 7966634961cSJack Morgenstein #define QUERY_PORT_CUR_MAX_PKEY_OFFSET 0x0c 7976634961cSJack Morgenstein #define QUERY_PORT_CUR_MAX_GID_OFFSET 0x0e 79895f56e7aSYevgeny Petrilin 7995cc914f1SMarcel Apfelbaum err = mlx4_cmd_box(dev, 0, outbox->dma, vhcr->in_modifier, 0, 8005cc914f1SMarcel Apfelbaum MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B, 8015cc914f1SMarcel Apfelbaum MLX4_CMD_NATIVE); 8025cc914f1SMarcel Apfelbaum 8035cc914f1SMarcel Apfelbaum if (!err && dev->caps.function != slave) { 8045cc914f1SMarcel Apfelbaum /* set slave default_mac address */ 8055cc914f1SMarcel Apfelbaum MLX4_GET(def_mac, outbox->buf, QUERY_PORT_MAC_OFFSET); 8065cc914f1SMarcel Apfelbaum def_mac += slave << 8; 8075cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, def_mac, QUERY_PORT_MAC_OFFSET); 8085cc914f1SMarcel Apfelbaum 8095cc914f1SMarcel Apfelbaum /* get port type - currently only eth is enabled */ 8105cc914f1SMarcel Apfelbaum MLX4_GET(port_type, outbox->buf, 8115cc914f1SMarcel Apfelbaum QUERY_PORT_SUPPORTED_TYPE_OFFSET); 8125cc914f1SMarcel Apfelbaum 813105c320fSJack Morgenstein /* No link sensing allowed */ 814105c320fSJack Morgenstein port_type &= MLX4_VF_PORT_NO_LINK_SENSE_MASK; 815105c320fSJack Morgenstein /* set port type to currently operating port type */ 816105c320fSJack Morgenstein port_type |= (dev->caps.port_type[vhcr->in_modifier] & 0x3); 8175cc914f1SMarcel Apfelbaum 8185cc914f1SMarcel Apfelbaum MLX4_PUT(outbox->buf, port_type, 8195cc914f1SMarcel Apfelbaum QUERY_PORT_SUPPORTED_TYPE_OFFSET); 8206634961cSJack Morgenstein 8216634961cSJack Morgenstein short_field = 1; /* slave max gids */ 8226634961cSJack Morgenstein MLX4_PUT(outbox->buf, short_field, 8236634961cSJack Morgenstein QUERY_PORT_CUR_MAX_GID_OFFSET); 8246634961cSJack Morgenstein 8256634961cSJack Morgenstein short_field = dev->caps.pkey_table_len[vhcr->in_modifier]; 8266634961cSJack Morgenstein MLX4_PUT(outbox->buf, short_field, 8276634961cSJack Morgenstein QUERY_PORT_CUR_MAX_PKEY_OFFSET); 8285cc914f1SMarcel Apfelbaum } 8295cc914f1SMarcel Apfelbaum 8305cc914f1SMarcel Apfelbaum return err; 8315cc914f1SMarcel Apfelbaum } 8325cc914f1SMarcel Apfelbaum 8336634961cSJack Morgenstein int mlx4_get_slave_pkey_gid_tbl_len(struct mlx4_dev *dev, u8 port, 8346634961cSJack Morgenstein int *gid_tbl_len, int *pkey_tbl_len) 8356634961cSJack Morgenstein { 8366634961cSJack Morgenstein struct mlx4_cmd_mailbox *mailbox; 8376634961cSJack Morgenstein u32 *outbox; 8386634961cSJack Morgenstein u16 field; 8396634961cSJack Morgenstein int err; 8406634961cSJack Morgenstein 8416634961cSJack Morgenstein mailbox = mlx4_alloc_cmd_mailbox(dev); 8426634961cSJack Morgenstein if (IS_ERR(mailbox)) 8436634961cSJack Morgenstein return PTR_ERR(mailbox); 8446634961cSJack Morgenstein 8456634961cSJack Morgenstein err = mlx4_cmd_box(dev, 0, mailbox->dma, port, 0, 8466634961cSJack Morgenstein MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B, 8476634961cSJack Morgenstein MLX4_CMD_WRAPPED); 8486634961cSJack Morgenstein if (err) 8496634961cSJack Morgenstein goto out; 8506634961cSJack Morgenstein 8516634961cSJack Morgenstein outbox = mailbox->buf; 8526634961cSJack Morgenstein 8536634961cSJack Morgenstein MLX4_GET(field, outbox, QUERY_PORT_CUR_MAX_GID_OFFSET); 8546634961cSJack Morgenstein *gid_tbl_len = field; 8556634961cSJack Morgenstein 8566634961cSJack Morgenstein MLX4_GET(field, outbox, QUERY_PORT_CUR_MAX_PKEY_OFFSET); 8576634961cSJack Morgenstein *pkey_tbl_len = field; 8586634961cSJack Morgenstein 8596634961cSJack Morgenstein out: 8606634961cSJack Morgenstein mlx4_free_cmd_mailbox(dev, mailbox); 8616634961cSJack Morgenstein return err; 8626634961cSJack Morgenstein } 8636634961cSJack Morgenstein EXPORT_SYMBOL(mlx4_get_slave_pkey_gid_tbl_len); 8646634961cSJack Morgenstein 8655a2cc190SJeff Kirsher int mlx4_map_cmd(struct mlx4_dev *dev, u16 op, struct mlx4_icm *icm, u64 virt) 8665a2cc190SJeff Kirsher { 8675a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 8685a2cc190SJeff Kirsher struct mlx4_icm_iter iter; 8695a2cc190SJeff Kirsher __be64 *pages; 8705a2cc190SJeff Kirsher int lg; 8715a2cc190SJeff Kirsher int nent = 0; 8725a2cc190SJeff Kirsher int i; 8735a2cc190SJeff Kirsher int err = 0; 8745a2cc190SJeff Kirsher int ts = 0, tc = 0; 8755a2cc190SJeff Kirsher 8765a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 8775a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 8785a2cc190SJeff Kirsher return PTR_ERR(mailbox); 8795a2cc190SJeff Kirsher memset(mailbox->buf, 0, MLX4_MAILBOX_SIZE); 8805a2cc190SJeff Kirsher pages = mailbox->buf; 8815a2cc190SJeff Kirsher 8825a2cc190SJeff Kirsher for (mlx4_icm_first(icm, &iter); 8835a2cc190SJeff Kirsher !mlx4_icm_last(&iter); 8845a2cc190SJeff Kirsher mlx4_icm_next(&iter)) { 8855a2cc190SJeff Kirsher /* 8865a2cc190SJeff Kirsher * We have to pass pages that are aligned to their 8875a2cc190SJeff Kirsher * size, so find the least significant 1 in the 8885a2cc190SJeff Kirsher * address or size and use that as our log2 size. 8895a2cc190SJeff Kirsher */ 8905a2cc190SJeff Kirsher lg = ffs(mlx4_icm_addr(&iter) | mlx4_icm_size(&iter)) - 1; 8915a2cc190SJeff Kirsher if (lg < MLX4_ICM_PAGE_SHIFT) { 8925a2cc190SJeff Kirsher mlx4_warn(dev, "Got FW area not aligned to %d (%llx/%lx).\n", 8935a2cc190SJeff Kirsher MLX4_ICM_PAGE_SIZE, 8945a2cc190SJeff Kirsher (unsigned long long) mlx4_icm_addr(&iter), 8955a2cc190SJeff Kirsher mlx4_icm_size(&iter)); 8965a2cc190SJeff Kirsher err = -EINVAL; 8975a2cc190SJeff Kirsher goto out; 8985a2cc190SJeff Kirsher } 8995a2cc190SJeff Kirsher 9005a2cc190SJeff Kirsher for (i = 0; i < mlx4_icm_size(&iter) >> lg; ++i) { 9015a2cc190SJeff Kirsher if (virt != -1) { 9025a2cc190SJeff Kirsher pages[nent * 2] = cpu_to_be64(virt); 9035a2cc190SJeff Kirsher virt += 1 << lg; 9045a2cc190SJeff Kirsher } 9055a2cc190SJeff Kirsher 9065a2cc190SJeff Kirsher pages[nent * 2 + 1] = 9075a2cc190SJeff Kirsher cpu_to_be64((mlx4_icm_addr(&iter) + (i << lg)) | 9085a2cc190SJeff Kirsher (lg - MLX4_ICM_PAGE_SHIFT)); 9095a2cc190SJeff Kirsher ts += 1 << (lg - 10); 9105a2cc190SJeff Kirsher ++tc; 9115a2cc190SJeff Kirsher 9125a2cc190SJeff Kirsher if (++nent == MLX4_MAILBOX_SIZE / 16) { 9135a2cc190SJeff Kirsher err = mlx4_cmd(dev, mailbox->dma, nent, 0, op, 914f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_B, 915f9baff50SJack Morgenstein MLX4_CMD_NATIVE); 9165a2cc190SJeff Kirsher if (err) 9175a2cc190SJeff Kirsher goto out; 9185a2cc190SJeff Kirsher nent = 0; 9195a2cc190SJeff Kirsher } 9205a2cc190SJeff Kirsher } 9215a2cc190SJeff Kirsher } 9225a2cc190SJeff Kirsher 9235a2cc190SJeff Kirsher if (nent) 924f9baff50SJack Morgenstein err = mlx4_cmd(dev, mailbox->dma, nent, 0, op, 925f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 9265a2cc190SJeff Kirsher if (err) 9275a2cc190SJeff Kirsher goto out; 9285a2cc190SJeff Kirsher 9295a2cc190SJeff Kirsher switch (op) { 9305a2cc190SJeff Kirsher case MLX4_CMD_MAP_FA: 9315a2cc190SJeff Kirsher mlx4_dbg(dev, "Mapped %d chunks/%d KB for FW.\n", tc, ts); 9325a2cc190SJeff Kirsher break; 9335a2cc190SJeff Kirsher case MLX4_CMD_MAP_ICM_AUX: 9345a2cc190SJeff Kirsher mlx4_dbg(dev, "Mapped %d chunks/%d KB for ICM aux.\n", tc, ts); 9355a2cc190SJeff Kirsher break; 9365a2cc190SJeff Kirsher case MLX4_CMD_MAP_ICM: 9375a2cc190SJeff Kirsher mlx4_dbg(dev, "Mapped %d chunks/%d KB at %llx for ICM.\n", 9385a2cc190SJeff Kirsher tc, ts, (unsigned long long) virt - (ts << 10)); 9395a2cc190SJeff Kirsher break; 9405a2cc190SJeff Kirsher } 9415a2cc190SJeff Kirsher 9425a2cc190SJeff Kirsher out: 9435a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 9445a2cc190SJeff Kirsher return err; 9455a2cc190SJeff Kirsher } 9465a2cc190SJeff Kirsher 9475a2cc190SJeff Kirsher int mlx4_MAP_FA(struct mlx4_dev *dev, struct mlx4_icm *icm) 9485a2cc190SJeff Kirsher { 9495a2cc190SJeff Kirsher return mlx4_map_cmd(dev, MLX4_CMD_MAP_FA, icm, -1); 9505a2cc190SJeff Kirsher } 9515a2cc190SJeff Kirsher 9525a2cc190SJeff Kirsher int mlx4_UNMAP_FA(struct mlx4_dev *dev) 9535a2cc190SJeff Kirsher { 954f9baff50SJack Morgenstein return mlx4_cmd(dev, 0, 0, 0, MLX4_CMD_UNMAP_FA, 955f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 9565a2cc190SJeff Kirsher } 9575a2cc190SJeff Kirsher 9585a2cc190SJeff Kirsher 9595a2cc190SJeff Kirsher int mlx4_RUN_FW(struct mlx4_dev *dev) 9605a2cc190SJeff Kirsher { 961f9baff50SJack Morgenstein return mlx4_cmd(dev, 0, 0, 0, MLX4_CMD_RUN_FW, 962f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 9635a2cc190SJeff Kirsher } 9645a2cc190SJeff Kirsher 9655a2cc190SJeff Kirsher int mlx4_QUERY_FW(struct mlx4_dev *dev) 9665a2cc190SJeff Kirsher { 9675a2cc190SJeff Kirsher struct mlx4_fw *fw = &mlx4_priv(dev)->fw; 9685a2cc190SJeff Kirsher struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; 9695a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 9705a2cc190SJeff Kirsher u32 *outbox; 9715a2cc190SJeff Kirsher int err = 0; 9725a2cc190SJeff Kirsher u64 fw_ver; 9735a2cc190SJeff Kirsher u16 cmd_if_rev; 9745a2cc190SJeff Kirsher u8 lg; 9755a2cc190SJeff Kirsher 9765a2cc190SJeff Kirsher #define QUERY_FW_OUT_SIZE 0x100 9775a2cc190SJeff Kirsher #define QUERY_FW_VER_OFFSET 0x00 9785cc914f1SMarcel Apfelbaum #define QUERY_FW_PPF_ID 0x09 9795a2cc190SJeff Kirsher #define QUERY_FW_CMD_IF_REV_OFFSET 0x0a 9805a2cc190SJeff Kirsher #define QUERY_FW_MAX_CMD_OFFSET 0x0f 9815a2cc190SJeff Kirsher #define QUERY_FW_ERR_START_OFFSET 0x30 9825a2cc190SJeff Kirsher #define QUERY_FW_ERR_SIZE_OFFSET 0x38 9835a2cc190SJeff Kirsher #define QUERY_FW_ERR_BAR_OFFSET 0x3c 9845a2cc190SJeff Kirsher 9855a2cc190SJeff Kirsher #define QUERY_FW_SIZE_OFFSET 0x00 9865a2cc190SJeff Kirsher #define QUERY_FW_CLR_INT_BASE_OFFSET 0x20 9875a2cc190SJeff Kirsher #define QUERY_FW_CLR_INT_BAR_OFFSET 0x28 9885a2cc190SJeff Kirsher 9895cc914f1SMarcel Apfelbaum #define QUERY_FW_COMM_BASE_OFFSET 0x40 9905cc914f1SMarcel Apfelbaum #define QUERY_FW_COMM_BAR_OFFSET 0x48 9915cc914f1SMarcel Apfelbaum 9925a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 9935a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 9945a2cc190SJeff Kirsher return PTR_ERR(mailbox); 9955a2cc190SJeff Kirsher outbox = mailbox->buf; 9965a2cc190SJeff Kirsher 9975a2cc190SJeff Kirsher err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 0, MLX4_CMD_QUERY_FW, 998f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 9995a2cc190SJeff Kirsher if (err) 10005a2cc190SJeff Kirsher goto out; 10015a2cc190SJeff Kirsher 10025a2cc190SJeff Kirsher MLX4_GET(fw_ver, outbox, QUERY_FW_VER_OFFSET); 10035a2cc190SJeff Kirsher /* 10045a2cc190SJeff Kirsher * FW subminor version is at more significant bits than minor 10055a2cc190SJeff Kirsher * version, so swap here. 10065a2cc190SJeff Kirsher */ 10075a2cc190SJeff Kirsher dev->caps.fw_ver = (fw_ver & 0xffff00000000ull) | 10085a2cc190SJeff Kirsher ((fw_ver & 0xffff0000ull) >> 16) | 10095a2cc190SJeff Kirsher ((fw_ver & 0x0000ffffull) << 16); 10105a2cc190SJeff Kirsher 1011752a50caSJack Morgenstein MLX4_GET(lg, outbox, QUERY_FW_PPF_ID); 1012752a50caSJack Morgenstein dev->caps.function = lg; 1013752a50caSJack Morgenstein 1014b91cb3ebSJack Morgenstein if (mlx4_is_slave(dev)) 1015b91cb3ebSJack Morgenstein goto out; 1016b91cb3ebSJack Morgenstein 10175cc914f1SMarcel Apfelbaum 10185a2cc190SJeff Kirsher MLX4_GET(cmd_if_rev, outbox, QUERY_FW_CMD_IF_REV_OFFSET); 10195a2cc190SJeff Kirsher if (cmd_if_rev < MLX4_COMMAND_INTERFACE_MIN_REV || 10205a2cc190SJeff Kirsher cmd_if_rev > MLX4_COMMAND_INTERFACE_MAX_REV) { 10215a2cc190SJeff Kirsher mlx4_err(dev, "Installed FW has unsupported " 10225a2cc190SJeff Kirsher "command interface revision %d.\n", 10235a2cc190SJeff Kirsher cmd_if_rev); 10245a2cc190SJeff Kirsher mlx4_err(dev, "(Installed FW version is %d.%d.%03d)\n", 10255a2cc190SJeff Kirsher (int) (dev->caps.fw_ver >> 32), 10265a2cc190SJeff Kirsher (int) (dev->caps.fw_ver >> 16) & 0xffff, 10275a2cc190SJeff Kirsher (int) dev->caps.fw_ver & 0xffff); 10285a2cc190SJeff Kirsher mlx4_err(dev, "This driver version supports only revisions %d to %d.\n", 10295a2cc190SJeff Kirsher MLX4_COMMAND_INTERFACE_MIN_REV, MLX4_COMMAND_INTERFACE_MAX_REV); 10305a2cc190SJeff Kirsher err = -ENODEV; 10315a2cc190SJeff Kirsher goto out; 10325a2cc190SJeff Kirsher } 10335a2cc190SJeff Kirsher 10345a2cc190SJeff Kirsher if (cmd_if_rev < MLX4_COMMAND_INTERFACE_NEW_PORT_CMDS) 10355a2cc190SJeff Kirsher dev->flags |= MLX4_FLAG_OLD_PORT_CMDS; 10365a2cc190SJeff Kirsher 10375a2cc190SJeff Kirsher MLX4_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET); 10385a2cc190SJeff Kirsher cmd->max_cmds = 1 << lg; 10395a2cc190SJeff Kirsher 10405a2cc190SJeff Kirsher mlx4_dbg(dev, "FW version %d.%d.%03d (cmd intf rev %d), max commands %d\n", 10415a2cc190SJeff Kirsher (int) (dev->caps.fw_ver >> 32), 10425a2cc190SJeff Kirsher (int) (dev->caps.fw_ver >> 16) & 0xffff, 10435a2cc190SJeff Kirsher (int) dev->caps.fw_ver & 0xffff, 10445a2cc190SJeff Kirsher cmd_if_rev, cmd->max_cmds); 10455a2cc190SJeff Kirsher 10465a2cc190SJeff Kirsher MLX4_GET(fw->catas_offset, outbox, QUERY_FW_ERR_START_OFFSET); 10475a2cc190SJeff Kirsher MLX4_GET(fw->catas_size, outbox, QUERY_FW_ERR_SIZE_OFFSET); 10485a2cc190SJeff Kirsher MLX4_GET(fw->catas_bar, outbox, QUERY_FW_ERR_BAR_OFFSET); 10495a2cc190SJeff Kirsher fw->catas_bar = (fw->catas_bar >> 6) * 2; 10505a2cc190SJeff Kirsher 10515a2cc190SJeff Kirsher mlx4_dbg(dev, "Catastrophic error buffer at 0x%llx, size 0x%x, BAR %d\n", 10525a2cc190SJeff Kirsher (unsigned long long) fw->catas_offset, fw->catas_size, fw->catas_bar); 10535a2cc190SJeff Kirsher 10545a2cc190SJeff Kirsher MLX4_GET(fw->fw_pages, outbox, QUERY_FW_SIZE_OFFSET); 10555a2cc190SJeff Kirsher MLX4_GET(fw->clr_int_base, outbox, QUERY_FW_CLR_INT_BASE_OFFSET); 10565a2cc190SJeff Kirsher MLX4_GET(fw->clr_int_bar, outbox, QUERY_FW_CLR_INT_BAR_OFFSET); 10575a2cc190SJeff Kirsher fw->clr_int_bar = (fw->clr_int_bar >> 6) * 2; 10585a2cc190SJeff Kirsher 10595cc914f1SMarcel Apfelbaum MLX4_GET(fw->comm_base, outbox, QUERY_FW_COMM_BASE_OFFSET); 10605cc914f1SMarcel Apfelbaum MLX4_GET(fw->comm_bar, outbox, QUERY_FW_COMM_BAR_OFFSET); 10615cc914f1SMarcel Apfelbaum fw->comm_bar = (fw->comm_bar >> 6) * 2; 10625cc914f1SMarcel Apfelbaum mlx4_dbg(dev, "Communication vector bar:%d offset:0x%llx\n", 10635cc914f1SMarcel Apfelbaum fw->comm_bar, fw->comm_base); 10645a2cc190SJeff Kirsher mlx4_dbg(dev, "FW size %d KB\n", fw->fw_pages >> 2); 10655a2cc190SJeff Kirsher 10665a2cc190SJeff Kirsher /* 10675a2cc190SJeff Kirsher * Round up number of system pages needed in case 10685a2cc190SJeff Kirsher * MLX4_ICM_PAGE_SIZE < PAGE_SIZE. 10695a2cc190SJeff Kirsher */ 10705a2cc190SJeff Kirsher fw->fw_pages = 10715a2cc190SJeff Kirsher ALIGN(fw->fw_pages, PAGE_SIZE / MLX4_ICM_PAGE_SIZE) >> 10725a2cc190SJeff Kirsher (PAGE_SHIFT - MLX4_ICM_PAGE_SHIFT); 10735a2cc190SJeff Kirsher 10745a2cc190SJeff Kirsher mlx4_dbg(dev, "Clear int @ %llx, BAR %d\n", 10755a2cc190SJeff Kirsher (unsigned long long) fw->clr_int_base, fw->clr_int_bar); 10765a2cc190SJeff Kirsher 10775a2cc190SJeff Kirsher out: 10785a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 10795a2cc190SJeff Kirsher return err; 10805a2cc190SJeff Kirsher } 10815a2cc190SJeff Kirsher 1082b91cb3ebSJack Morgenstein int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave, 1083b91cb3ebSJack Morgenstein struct mlx4_vhcr *vhcr, 1084b91cb3ebSJack Morgenstein struct mlx4_cmd_mailbox *inbox, 1085b91cb3ebSJack Morgenstein struct mlx4_cmd_mailbox *outbox, 1086b91cb3ebSJack Morgenstein struct mlx4_cmd_info *cmd) 1087b91cb3ebSJack Morgenstein { 1088b91cb3ebSJack Morgenstein u8 *outbuf; 1089b91cb3ebSJack Morgenstein int err; 1090b91cb3ebSJack Morgenstein 1091b91cb3ebSJack Morgenstein outbuf = outbox->buf; 1092b91cb3ebSJack Morgenstein err = mlx4_cmd_box(dev, 0, outbox->dma, 0, 0, MLX4_CMD_QUERY_FW, 1093b91cb3ebSJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 1094b91cb3ebSJack Morgenstein if (err) 1095b91cb3ebSJack Morgenstein return err; 1096b91cb3ebSJack Morgenstein 1097752a50caSJack Morgenstein /* for slaves, set pci PPF ID to invalid and zero out everything 1098752a50caSJack Morgenstein * else except FW version */ 1099b91cb3ebSJack Morgenstein outbuf[0] = outbuf[1] = 0; 1100b91cb3ebSJack Morgenstein memset(&outbuf[8], 0, QUERY_FW_OUT_SIZE - 8); 1101752a50caSJack Morgenstein outbuf[QUERY_FW_PPF_ID] = MLX4_INVALID_SLAVE_ID; 1102752a50caSJack Morgenstein 1103b91cb3ebSJack Morgenstein return 0; 1104b91cb3ebSJack Morgenstein } 1105b91cb3ebSJack Morgenstein 11065a2cc190SJeff Kirsher static void get_board_id(void *vsd, char *board_id) 11075a2cc190SJeff Kirsher { 11085a2cc190SJeff Kirsher int i; 11095a2cc190SJeff Kirsher 11105a2cc190SJeff Kirsher #define VSD_OFFSET_SIG1 0x00 11115a2cc190SJeff Kirsher #define VSD_OFFSET_SIG2 0xde 11125a2cc190SJeff Kirsher #define VSD_OFFSET_MLX_BOARD_ID 0xd0 11135a2cc190SJeff Kirsher #define VSD_OFFSET_TS_BOARD_ID 0x20 11145a2cc190SJeff Kirsher 11155a2cc190SJeff Kirsher #define VSD_SIGNATURE_TOPSPIN 0x5ad 11165a2cc190SJeff Kirsher 11175a2cc190SJeff Kirsher memset(board_id, 0, MLX4_BOARD_ID_LEN); 11185a2cc190SJeff Kirsher 11195a2cc190SJeff Kirsher if (be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN && 11205a2cc190SJeff Kirsher be16_to_cpup(vsd + VSD_OFFSET_SIG2) == VSD_SIGNATURE_TOPSPIN) { 11215a2cc190SJeff Kirsher strlcpy(board_id, vsd + VSD_OFFSET_TS_BOARD_ID, MLX4_BOARD_ID_LEN); 11225a2cc190SJeff Kirsher } else { 11235a2cc190SJeff Kirsher /* 11245a2cc190SJeff Kirsher * The board ID is a string but the firmware byte 11255a2cc190SJeff Kirsher * swaps each 4-byte word before passing it back to 11265a2cc190SJeff Kirsher * us. Therefore we need to swab it before printing. 11275a2cc190SJeff Kirsher */ 11285a2cc190SJeff Kirsher for (i = 0; i < 4; ++i) 11295a2cc190SJeff Kirsher ((u32 *) board_id)[i] = 11305a2cc190SJeff Kirsher swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4)); 11315a2cc190SJeff Kirsher } 11325a2cc190SJeff Kirsher } 11335a2cc190SJeff Kirsher 11345a2cc190SJeff Kirsher int mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter *adapter) 11355a2cc190SJeff Kirsher { 11365a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 11375a2cc190SJeff Kirsher u32 *outbox; 11385a2cc190SJeff Kirsher int err; 11395a2cc190SJeff Kirsher 11405a2cc190SJeff Kirsher #define QUERY_ADAPTER_OUT_SIZE 0x100 11415a2cc190SJeff Kirsher #define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10 11425a2cc190SJeff Kirsher #define QUERY_ADAPTER_VSD_OFFSET 0x20 11435a2cc190SJeff Kirsher 11445a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 11455a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 11465a2cc190SJeff Kirsher return PTR_ERR(mailbox); 11475a2cc190SJeff Kirsher outbox = mailbox->buf; 11485a2cc190SJeff Kirsher 11495a2cc190SJeff Kirsher err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 0, MLX4_CMD_QUERY_ADAPTER, 1150f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 11515a2cc190SJeff Kirsher if (err) 11525a2cc190SJeff Kirsher goto out; 11535a2cc190SJeff Kirsher 11545a2cc190SJeff Kirsher MLX4_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET); 11555a2cc190SJeff Kirsher 11565a2cc190SJeff Kirsher get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4, 11575a2cc190SJeff Kirsher adapter->board_id); 11585a2cc190SJeff Kirsher 11595a2cc190SJeff Kirsher out: 11605a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 11615a2cc190SJeff Kirsher return err; 11625a2cc190SJeff Kirsher } 11635a2cc190SJeff Kirsher 11645a2cc190SJeff Kirsher int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param) 11655a2cc190SJeff Kirsher { 11665a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 11675a2cc190SJeff Kirsher __be32 *inbox; 11685a2cc190SJeff Kirsher int err; 11695a2cc190SJeff Kirsher 11705a2cc190SJeff Kirsher #define INIT_HCA_IN_SIZE 0x200 11715a2cc190SJeff Kirsher #define INIT_HCA_VERSION_OFFSET 0x000 11725a2cc190SJeff Kirsher #define INIT_HCA_VERSION 2 11735a2cc190SJeff Kirsher #define INIT_HCA_CACHELINE_SZ_OFFSET 0x0e 11745a2cc190SJeff Kirsher #define INIT_HCA_FLAGS_OFFSET 0x014 11755a2cc190SJeff Kirsher #define INIT_HCA_QPC_OFFSET 0x020 11765a2cc190SJeff Kirsher #define INIT_HCA_QPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x10) 11775a2cc190SJeff Kirsher #define INIT_HCA_LOG_QP_OFFSET (INIT_HCA_QPC_OFFSET + 0x17) 11785a2cc190SJeff Kirsher #define INIT_HCA_SRQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x28) 11795a2cc190SJeff Kirsher #define INIT_HCA_LOG_SRQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x2f) 11805a2cc190SJeff Kirsher #define INIT_HCA_CQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x30) 11815a2cc190SJeff Kirsher #define INIT_HCA_LOG_CQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x37) 11825cc914f1SMarcel Apfelbaum #define INIT_HCA_EQE_CQE_OFFSETS (INIT_HCA_QPC_OFFSET + 0x38) 11835a2cc190SJeff Kirsher #define INIT_HCA_ALTC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x40) 11845a2cc190SJeff Kirsher #define INIT_HCA_AUXC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x50) 11855a2cc190SJeff Kirsher #define INIT_HCA_EQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x60) 11865a2cc190SJeff Kirsher #define INIT_HCA_LOG_EQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x67) 11875a2cc190SJeff Kirsher #define INIT_HCA_RDMARC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x70) 11885a2cc190SJeff Kirsher #define INIT_HCA_LOG_RD_OFFSET (INIT_HCA_QPC_OFFSET + 0x77) 11895a2cc190SJeff Kirsher #define INIT_HCA_MCAST_OFFSET 0x0c0 11905a2cc190SJeff Kirsher #define INIT_HCA_MC_BASE_OFFSET (INIT_HCA_MCAST_OFFSET + 0x00) 11915a2cc190SJeff Kirsher #define INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x12) 11925a2cc190SJeff Kirsher #define INIT_HCA_LOG_MC_HASH_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x16) 11935a2cc190SJeff Kirsher #define INIT_HCA_UC_STEERING_OFFSET (INIT_HCA_MCAST_OFFSET + 0x18) 11945a2cc190SJeff Kirsher #define INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b) 11950ff1fb65SHadar Hen Zion #define INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN 0x6 11960ff1fb65SHadar Hen Zion #define INIT_HCA_FS_PARAM_OFFSET 0x1d0 11970ff1fb65SHadar Hen Zion #define INIT_HCA_FS_BASE_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x00) 11980ff1fb65SHadar Hen Zion #define INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x12) 11990ff1fb65SHadar Hen Zion #define INIT_HCA_FS_LOG_TABLE_SZ_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x1b) 12000ff1fb65SHadar Hen Zion #define INIT_HCA_FS_ETH_BITS_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x21) 12010ff1fb65SHadar Hen Zion #define INIT_HCA_FS_ETH_NUM_ADDRS_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x22) 12020ff1fb65SHadar Hen Zion #define INIT_HCA_FS_IB_BITS_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x25) 12030ff1fb65SHadar Hen Zion #define INIT_HCA_FS_IB_NUM_ADDRS_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x26) 12045a2cc190SJeff Kirsher #define INIT_HCA_TPT_OFFSET 0x0f0 12055a2cc190SJeff Kirsher #define INIT_HCA_DMPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x00) 12065a2cc190SJeff Kirsher #define INIT_HCA_LOG_MPT_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x0b) 12075a2cc190SJeff Kirsher #define INIT_HCA_MTT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x10) 12085a2cc190SJeff Kirsher #define INIT_HCA_CMPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x18) 12095a2cc190SJeff Kirsher #define INIT_HCA_UAR_OFFSET 0x120 12105a2cc190SJeff Kirsher #define INIT_HCA_LOG_UAR_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0a) 12115a2cc190SJeff Kirsher #define INIT_HCA_UAR_PAGE_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0b) 12125a2cc190SJeff Kirsher 12135a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 12145a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 12155a2cc190SJeff Kirsher return PTR_ERR(mailbox); 12165a2cc190SJeff Kirsher inbox = mailbox->buf; 12175a2cc190SJeff Kirsher 12185a2cc190SJeff Kirsher memset(inbox, 0, INIT_HCA_IN_SIZE); 12195a2cc190SJeff Kirsher 12205a2cc190SJeff Kirsher *((u8 *) mailbox->buf + INIT_HCA_VERSION_OFFSET) = INIT_HCA_VERSION; 12215a2cc190SJeff Kirsher 12225a2cc190SJeff Kirsher *((u8 *) mailbox->buf + INIT_HCA_CACHELINE_SZ_OFFSET) = 12235a2cc190SJeff Kirsher (ilog2(cache_line_size()) - 4) << 5; 12245a2cc190SJeff Kirsher 12255a2cc190SJeff Kirsher #if defined(__LITTLE_ENDIAN) 12265a2cc190SJeff Kirsher *(inbox + INIT_HCA_FLAGS_OFFSET / 4) &= ~cpu_to_be32(1 << 1); 12275a2cc190SJeff Kirsher #elif defined(__BIG_ENDIAN) 12285a2cc190SJeff Kirsher *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 1); 12295a2cc190SJeff Kirsher #else 12305a2cc190SJeff Kirsher #error Host endianness not defined 12315a2cc190SJeff Kirsher #endif 12325a2cc190SJeff Kirsher /* Check port for UD address vector: */ 12335a2cc190SJeff Kirsher *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1); 12345a2cc190SJeff Kirsher 12355a2cc190SJeff Kirsher /* Enable IPoIB checksumming if we can: */ 12365a2cc190SJeff Kirsher if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM) 12375a2cc190SJeff Kirsher *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 3); 12385a2cc190SJeff Kirsher 12395a2cc190SJeff Kirsher /* Enable QoS support if module parameter set */ 12405a2cc190SJeff Kirsher if (enable_qos) 12415a2cc190SJeff Kirsher *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 2); 12425a2cc190SJeff Kirsher 12435a2cc190SJeff Kirsher /* enable counters */ 12445a2cc190SJeff Kirsher if (dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS) 12455a2cc190SJeff Kirsher *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 4); 12465a2cc190SJeff Kirsher 124708ff3235SOr Gerlitz /* CX3 is capable of extending CQEs/EQEs from 32 to 64 bytes */ 124808ff3235SOr Gerlitz if (dev->caps.flags & MLX4_DEV_CAP_FLAG_64B_EQE) { 124908ff3235SOr Gerlitz *(inbox + INIT_HCA_EQE_CQE_OFFSETS / 4) |= cpu_to_be32(1 << 29); 125008ff3235SOr Gerlitz dev->caps.eqe_size = 64; 125108ff3235SOr Gerlitz dev->caps.eqe_factor = 1; 125208ff3235SOr Gerlitz } else { 125308ff3235SOr Gerlitz dev->caps.eqe_size = 32; 125408ff3235SOr Gerlitz dev->caps.eqe_factor = 0; 125508ff3235SOr Gerlitz } 125608ff3235SOr Gerlitz 125708ff3235SOr Gerlitz if (dev->caps.flags & MLX4_DEV_CAP_FLAG_64B_CQE) { 125808ff3235SOr Gerlitz *(inbox + INIT_HCA_EQE_CQE_OFFSETS / 4) |= cpu_to_be32(1 << 30); 125908ff3235SOr Gerlitz dev->caps.cqe_size = 64; 126008ff3235SOr Gerlitz dev->caps.userspace_caps |= MLX4_USER_DEV_CAP_64B_CQE; 126108ff3235SOr Gerlitz } else { 126208ff3235SOr Gerlitz dev->caps.cqe_size = 32; 126308ff3235SOr Gerlitz } 126408ff3235SOr Gerlitz 12655a2cc190SJeff Kirsher /* QPC/EEC/CQC/EQC/RDMARC attributes */ 12665a2cc190SJeff Kirsher 12675a2cc190SJeff Kirsher MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET); 12685a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_num_qps, INIT_HCA_LOG_QP_OFFSET); 12695a2cc190SJeff Kirsher MLX4_PUT(inbox, param->srqc_base, INIT_HCA_SRQC_BASE_OFFSET); 12705a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_num_srqs, INIT_HCA_LOG_SRQ_OFFSET); 12715a2cc190SJeff Kirsher MLX4_PUT(inbox, param->cqc_base, INIT_HCA_CQC_BASE_OFFSET); 12725a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_num_cqs, INIT_HCA_LOG_CQ_OFFSET); 12735a2cc190SJeff Kirsher MLX4_PUT(inbox, param->altc_base, INIT_HCA_ALTC_BASE_OFFSET); 12745a2cc190SJeff Kirsher MLX4_PUT(inbox, param->auxc_base, INIT_HCA_AUXC_BASE_OFFSET); 12755a2cc190SJeff Kirsher MLX4_PUT(inbox, param->eqc_base, INIT_HCA_EQC_BASE_OFFSET); 12765a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_num_eqs, INIT_HCA_LOG_EQ_OFFSET); 12775a2cc190SJeff Kirsher MLX4_PUT(inbox, param->rdmarc_base, INIT_HCA_RDMARC_BASE_OFFSET); 12785a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_rd_per_qp, INIT_HCA_LOG_RD_OFFSET); 12795a2cc190SJeff Kirsher 12800ff1fb65SHadar Hen Zion /* steering attributes */ 12810ff1fb65SHadar Hen Zion if (dev->caps.steering_mode == 12820ff1fb65SHadar Hen Zion MLX4_STEERING_MODE_DEVICE_MANAGED) { 12830ff1fb65SHadar Hen Zion *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= 12840ff1fb65SHadar Hen Zion cpu_to_be32(1 << 12850ff1fb65SHadar Hen Zion INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN); 12865a2cc190SJeff Kirsher 12870ff1fb65SHadar Hen Zion MLX4_PUT(inbox, param->mc_base, INIT_HCA_FS_BASE_OFFSET); 12880ff1fb65SHadar Hen Zion MLX4_PUT(inbox, param->log_mc_entry_sz, 12890ff1fb65SHadar Hen Zion INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET); 12900ff1fb65SHadar Hen Zion MLX4_PUT(inbox, param->log_mc_table_sz, 12910ff1fb65SHadar Hen Zion INIT_HCA_FS_LOG_TABLE_SZ_OFFSET); 12920ff1fb65SHadar Hen Zion /* Enable Ethernet flow steering 12930ff1fb65SHadar Hen Zion * with udp unicast and tcp unicast 12940ff1fb65SHadar Hen Zion */ 129523537b73SHadar Hen Zion MLX4_PUT(inbox, (u8) (MLX4_FS_UDP_UC_EN | MLX4_FS_TCP_UC_EN), 12960ff1fb65SHadar Hen Zion INIT_HCA_FS_ETH_BITS_OFFSET); 12970ff1fb65SHadar Hen Zion MLX4_PUT(inbox, (u16) MLX4_FS_NUM_OF_L2_ADDR, 12980ff1fb65SHadar Hen Zion INIT_HCA_FS_ETH_NUM_ADDRS_OFFSET); 12990ff1fb65SHadar Hen Zion /* Enable IPoIB flow steering 13000ff1fb65SHadar Hen Zion * with udp unicast and tcp unicast 13010ff1fb65SHadar Hen Zion */ 130223537b73SHadar Hen Zion MLX4_PUT(inbox, (u8) (MLX4_FS_UDP_UC_EN | MLX4_FS_TCP_UC_EN), 13030ff1fb65SHadar Hen Zion INIT_HCA_FS_IB_BITS_OFFSET); 13040ff1fb65SHadar Hen Zion MLX4_PUT(inbox, (u16) MLX4_FS_NUM_OF_L2_ADDR, 13050ff1fb65SHadar Hen Zion INIT_HCA_FS_IB_NUM_ADDRS_OFFSET); 13060ff1fb65SHadar Hen Zion } else { 13075a2cc190SJeff Kirsher MLX4_PUT(inbox, param->mc_base, INIT_HCA_MC_BASE_OFFSET); 13080ff1fb65SHadar Hen Zion MLX4_PUT(inbox, param->log_mc_entry_sz, 13090ff1fb65SHadar Hen Zion INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET); 13100ff1fb65SHadar Hen Zion MLX4_PUT(inbox, param->log_mc_hash_sz, 13110ff1fb65SHadar Hen Zion INIT_HCA_LOG_MC_HASH_SZ_OFFSET); 13120ff1fb65SHadar Hen Zion MLX4_PUT(inbox, param->log_mc_table_sz, 13130ff1fb65SHadar Hen Zion INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); 1314c96d97f4SHadar Hen Zion if (dev->caps.steering_mode == MLX4_STEERING_MODE_B0) 13150ff1fb65SHadar Hen Zion MLX4_PUT(inbox, (u8) (1 << 3), 13160ff1fb65SHadar Hen Zion INIT_HCA_UC_STEERING_OFFSET); 13170ff1fb65SHadar Hen Zion } 13185a2cc190SJeff Kirsher 13195a2cc190SJeff Kirsher /* TPT attributes */ 13205a2cc190SJeff Kirsher 13215a2cc190SJeff Kirsher MLX4_PUT(inbox, param->dmpt_base, INIT_HCA_DMPT_BASE_OFFSET); 13225a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_mpt_sz, INIT_HCA_LOG_MPT_SZ_OFFSET); 13235a2cc190SJeff Kirsher MLX4_PUT(inbox, param->mtt_base, INIT_HCA_MTT_BASE_OFFSET); 13245a2cc190SJeff Kirsher MLX4_PUT(inbox, param->cmpt_base, INIT_HCA_CMPT_BASE_OFFSET); 13255a2cc190SJeff Kirsher 13265a2cc190SJeff Kirsher /* UAR attributes */ 13275a2cc190SJeff Kirsher 1328ab9c17a0SJack Morgenstein MLX4_PUT(inbox, param->uar_page_sz, INIT_HCA_UAR_PAGE_SZ_OFFSET); 13295a2cc190SJeff Kirsher MLX4_PUT(inbox, param->log_uar_sz, INIT_HCA_LOG_UAR_SZ_OFFSET); 13305a2cc190SJeff Kirsher 1331f9baff50SJack Morgenstein err = mlx4_cmd(dev, mailbox->dma, 0, 0, MLX4_CMD_INIT_HCA, 10000, 1332f9baff50SJack Morgenstein MLX4_CMD_NATIVE); 13335a2cc190SJeff Kirsher 13345a2cc190SJeff Kirsher if (err) 13355a2cc190SJeff Kirsher mlx4_err(dev, "INIT_HCA returns %d\n", err); 13365a2cc190SJeff Kirsher 13375a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 13385a2cc190SJeff Kirsher return err; 13395a2cc190SJeff Kirsher } 13405a2cc190SJeff Kirsher 1341ab9c17a0SJack Morgenstein int mlx4_QUERY_HCA(struct mlx4_dev *dev, 1342ab9c17a0SJack Morgenstein struct mlx4_init_hca_param *param) 1343ab9c17a0SJack Morgenstein { 1344ab9c17a0SJack Morgenstein struct mlx4_cmd_mailbox *mailbox; 1345ab9c17a0SJack Morgenstein __be32 *outbox; 13467b8157beSJack Morgenstein u32 dword_field; 1347ab9c17a0SJack Morgenstein int err; 134808ff3235SOr Gerlitz u8 byte_field; 1349ab9c17a0SJack Morgenstein 1350ab9c17a0SJack Morgenstein #define QUERY_HCA_GLOBAL_CAPS_OFFSET 0x04 1351ab9c17a0SJack Morgenstein 1352ab9c17a0SJack Morgenstein mailbox = mlx4_alloc_cmd_mailbox(dev); 1353ab9c17a0SJack Morgenstein if (IS_ERR(mailbox)) 1354ab9c17a0SJack Morgenstein return PTR_ERR(mailbox); 1355ab9c17a0SJack Morgenstein outbox = mailbox->buf; 1356ab9c17a0SJack Morgenstein 1357ab9c17a0SJack Morgenstein err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 0, 1358ab9c17a0SJack Morgenstein MLX4_CMD_QUERY_HCA, 1359ab9c17a0SJack Morgenstein MLX4_CMD_TIME_CLASS_B, 1360ab9c17a0SJack Morgenstein !mlx4_is_slave(dev)); 1361ab9c17a0SJack Morgenstein if (err) 1362ab9c17a0SJack Morgenstein goto out; 1363ab9c17a0SJack Morgenstein 1364ab9c17a0SJack Morgenstein MLX4_GET(param->global_caps, outbox, QUERY_HCA_GLOBAL_CAPS_OFFSET); 1365ab9c17a0SJack Morgenstein 1366ab9c17a0SJack Morgenstein /* QPC/EEC/CQC/EQC/RDMARC attributes */ 1367ab9c17a0SJack Morgenstein 1368ab9c17a0SJack Morgenstein MLX4_GET(param->qpc_base, outbox, INIT_HCA_QPC_BASE_OFFSET); 1369ab9c17a0SJack Morgenstein MLX4_GET(param->log_num_qps, outbox, INIT_HCA_LOG_QP_OFFSET); 1370ab9c17a0SJack Morgenstein MLX4_GET(param->srqc_base, outbox, INIT_HCA_SRQC_BASE_OFFSET); 1371ab9c17a0SJack Morgenstein MLX4_GET(param->log_num_srqs, outbox, INIT_HCA_LOG_SRQ_OFFSET); 1372ab9c17a0SJack Morgenstein MLX4_GET(param->cqc_base, outbox, INIT_HCA_CQC_BASE_OFFSET); 1373ab9c17a0SJack Morgenstein MLX4_GET(param->log_num_cqs, outbox, INIT_HCA_LOG_CQ_OFFSET); 1374ab9c17a0SJack Morgenstein MLX4_GET(param->altc_base, outbox, INIT_HCA_ALTC_BASE_OFFSET); 1375ab9c17a0SJack Morgenstein MLX4_GET(param->auxc_base, outbox, INIT_HCA_AUXC_BASE_OFFSET); 1376ab9c17a0SJack Morgenstein MLX4_GET(param->eqc_base, outbox, INIT_HCA_EQC_BASE_OFFSET); 1377ab9c17a0SJack Morgenstein MLX4_GET(param->log_num_eqs, outbox, INIT_HCA_LOG_EQ_OFFSET); 1378ab9c17a0SJack Morgenstein MLX4_GET(param->rdmarc_base, outbox, INIT_HCA_RDMARC_BASE_OFFSET); 1379ab9c17a0SJack Morgenstein MLX4_GET(param->log_rd_per_qp, outbox, INIT_HCA_LOG_RD_OFFSET); 1380ab9c17a0SJack Morgenstein 13817b8157beSJack Morgenstein MLX4_GET(dword_field, outbox, INIT_HCA_FLAGS_OFFSET); 13827b8157beSJack Morgenstein if (dword_field & (1 << INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN)) { 13837b8157beSJack Morgenstein param->steering_mode = MLX4_STEERING_MODE_DEVICE_MANAGED; 13847b8157beSJack Morgenstein } else { 13857b8157beSJack Morgenstein MLX4_GET(byte_field, outbox, INIT_HCA_UC_STEERING_OFFSET); 13867b8157beSJack Morgenstein if (byte_field & 0x8) 13877b8157beSJack Morgenstein param->steering_mode = MLX4_STEERING_MODE_B0; 13887b8157beSJack Morgenstein else 13897b8157beSJack Morgenstein param->steering_mode = MLX4_STEERING_MODE_A0; 13907b8157beSJack Morgenstein } 13910ff1fb65SHadar Hen Zion /* steering attributes */ 13927b8157beSJack Morgenstein if (param->steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) { 13930ff1fb65SHadar Hen Zion MLX4_GET(param->mc_base, outbox, INIT_HCA_FS_BASE_OFFSET); 13940ff1fb65SHadar Hen Zion MLX4_GET(param->log_mc_entry_sz, outbox, 13950ff1fb65SHadar Hen Zion INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET); 13960ff1fb65SHadar Hen Zion MLX4_GET(param->log_mc_table_sz, outbox, 13970ff1fb65SHadar Hen Zion INIT_HCA_FS_LOG_TABLE_SZ_OFFSET); 13980ff1fb65SHadar Hen Zion } else { 1399ab9c17a0SJack Morgenstein MLX4_GET(param->mc_base, outbox, INIT_HCA_MC_BASE_OFFSET); 1400ab9c17a0SJack Morgenstein MLX4_GET(param->log_mc_entry_sz, outbox, 1401ab9c17a0SJack Morgenstein INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET); 1402ab9c17a0SJack Morgenstein MLX4_GET(param->log_mc_hash_sz, outbox, 1403ab9c17a0SJack Morgenstein INIT_HCA_LOG_MC_HASH_SZ_OFFSET); 1404ab9c17a0SJack Morgenstein MLX4_GET(param->log_mc_table_sz, outbox, 1405ab9c17a0SJack Morgenstein INIT_HCA_LOG_MC_TABLE_SZ_OFFSET); 14060ff1fb65SHadar Hen Zion } 1407ab9c17a0SJack Morgenstein 140808ff3235SOr Gerlitz /* CX3 is capable of extending CQEs/EQEs from 32 to 64 bytes */ 140908ff3235SOr Gerlitz MLX4_GET(byte_field, outbox, INIT_HCA_EQE_CQE_OFFSETS); 141008ff3235SOr Gerlitz if (byte_field & 0x20) /* 64-bytes eqe enabled */ 141108ff3235SOr Gerlitz param->dev_cap_enabled |= MLX4_DEV_CAP_64B_EQE_ENABLED; 141208ff3235SOr Gerlitz if (byte_field & 0x40) /* 64-bytes cqe enabled */ 141308ff3235SOr Gerlitz param->dev_cap_enabled |= MLX4_DEV_CAP_64B_CQE_ENABLED; 141408ff3235SOr Gerlitz 1415ab9c17a0SJack Morgenstein /* TPT attributes */ 1416ab9c17a0SJack Morgenstein 1417ab9c17a0SJack Morgenstein MLX4_GET(param->dmpt_base, outbox, INIT_HCA_DMPT_BASE_OFFSET); 1418ab9c17a0SJack Morgenstein MLX4_GET(param->log_mpt_sz, outbox, INIT_HCA_LOG_MPT_SZ_OFFSET); 1419ab9c17a0SJack Morgenstein MLX4_GET(param->mtt_base, outbox, INIT_HCA_MTT_BASE_OFFSET); 1420ab9c17a0SJack Morgenstein MLX4_GET(param->cmpt_base, outbox, INIT_HCA_CMPT_BASE_OFFSET); 1421ab9c17a0SJack Morgenstein 1422ab9c17a0SJack Morgenstein /* UAR attributes */ 1423ab9c17a0SJack Morgenstein 1424ab9c17a0SJack Morgenstein MLX4_GET(param->uar_page_sz, outbox, INIT_HCA_UAR_PAGE_SZ_OFFSET); 1425ab9c17a0SJack Morgenstein MLX4_GET(param->log_uar_sz, outbox, INIT_HCA_LOG_UAR_SZ_OFFSET); 1426ab9c17a0SJack Morgenstein 1427ab9c17a0SJack Morgenstein out: 1428ab9c17a0SJack Morgenstein mlx4_free_cmd_mailbox(dev, mailbox); 1429ab9c17a0SJack Morgenstein 1430ab9c17a0SJack Morgenstein return err; 1431ab9c17a0SJack Morgenstein } 1432ab9c17a0SJack Morgenstein 1433980e9001SJack Morgenstein /* for IB-type ports only in SRIOV mode. Checks that both proxy QP0 1434980e9001SJack Morgenstein * and real QP0 are active, so that the paravirtualized QP0 is ready 1435980e9001SJack Morgenstein * to operate */ 1436980e9001SJack Morgenstein static int check_qp0_state(struct mlx4_dev *dev, int function, int port) 1437980e9001SJack Morgenstein { 1438980e9001SJack Morgenstein struct mlx4_priv *priv = mlx4_priv(dev); 1439980e9001SJack Morgenstein /* irrelevant if not infiniband */ 1440980e9001SJack Morgenstein if (priv->mfunc.master.qp0_state[port].proxy_qp0_active && 1441980e9001SJack Morgenstein priv->mfunc.master.qp0_state[port].qp0_active) 1442980e9001SJack Morgenstein return 1; 1443980e9001SJack Morgenstein return 0; 1444980e9001SJack Morgenstein } 1445980e9001SJack Morgenstein 14465cc914f1SMarcel Apfelbaum int mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave, 14475cc914f1SMarcel Apfelbaum struct mlx4_vhcr *vhcr, 14485cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *inbox, 14495cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *outbox, 14505cc914f1SMarcel Apfelbaum struct mlx4_cmd_info *cmd) 14515cc914f1SMarcel Apfelbaum { 14525cc914f1SMarcel Apfelbaum struct mlx4_priv *priv = mlx4_priv(dev); 14535cc914f1SMarcel Apfelbaum int port = vhcr->in_modifier; 14545cc914f1SMarcel Apfelbaum int err; 14555cc914f1SMarcel Apfelbaum 14565cc914f1SMarcel Apfelbaum if (priv->mfunc.master.slave_state[slave].init_port_mask & (1 << port)) 14575cc914f1SMarcel Apfelbaum return 0; 14585cc914f1SMarcel Apfelbaum 1459980e9001SJack Morgenstein if (dev->caps.port_mask[port] != MLX4_PORT_TYPE_IB) { 14605cc914f1SMarcel Apfelbaum /* Enable port only if it was previously disabled */ 14615cc914f1SMarcel Apfelbaum if (!priv->mfunc.master.init_port_ref[port]) { 14625cc914f1SMarcel Apfelbaum err = mlx4_cmd(dev, 0, port, 0, MLX4_CMD_INIT_PORT, 14635cc914f1SMarcel Apfelbaum MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 14645cc914f1SMarcel Apfelbaum if (err) 14655cc914f1SMarcel Apfelbaum return err; 14665cc914f1SMarcel Apfelbaum } 14678bac9edeSJack Morgenstein priv->mfunc.master.slave_state[slave].init_port_mask |= (1 << port); 1468980e9001SJack Morgenstein } else { 1469980e9001SJack Morgenstein if (slave == mlx4_master_func_num(dev)) { 1470980e9001SJack Morgenstein if (check_qp0_state(dev, slave, port) && 1471980e9001SJack Morgenstein !priv->mfunc.master.qp0_state[port].port_active) { 1472980e9001SJack Morgenstein err = mlx4_cmd(dev, 0, port, 0, MLX4_CMD_INIT_PORT, 1473980e9001SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 1474980e9001SJack Morgenstein if (err) 1475980e9001SJack Morgenstein return err; 1476980e9001SJack Morgenstein priv->mfunc.master.qp0_state[port].port_active = 1; 1477980e9001SJack Morgenstein priv->mfunc.master.slave_state[slave].init_port_mask |= (1 << port); 1478980e9001SJack Morgenstein } 1479980e9001SJack Morgenstein } else 1480980e9001SJack Morgenstein priv->mfunc.master.slave_state[slave].init_port_mask |= (1 << port); 1481980e9001SJack Morgenstein } 14825cc914f1SMarcel Apfelbaum ++priv->mfunc.master.init_port_ref[port]; 14835cc914f1SMarcel Apfelbaum return 0; 14845cc914f1SMarcel Apfelbaum } 14855cc914f1SMarcel Apfelbaum 14865a2cc190SJeff Kirsher int mlx4_INIT_PORT(struct mlx4_dev *dev, int port) 14875a2cc190SJeff Kirsher { 14885a2cc190SJeff Kirsher struct mlx4_cmd_mailbox *mailbox; 14895a2cc190SJeff Kirsher u32 *inbox; 14905a2cc190SJeff Kirsher int err; 14915a2cc190SJeff Kirsher u32 flags; 14925a2cc190SJeff Kirsher u16 field; 14935a2cc190SJeff Kirsher 14945a2cc190SJeff Kirsher if (dev->flags & MLX4_FLAG_OLD_PORT_CMDS) { 14955a2cc190SJeff Kirsher #define INIT_PORT_IN_SIZE 256 14965a2cc190SJeff Kirsher #define INIT_PORT_FLAGS_OFFSET 0x00 14975a2cc190SJeff Kirsher #define INIT_PORT_FLAG_SIG (1 << 18) 14985a2cc190SJeff Kirsher #define INIT_PORT_FLAG_NG (1 << 17) 14995a2cc190SJeff Kirsher #define INIT_PORT_FLAG_G0 (1 << 16) 15005a2cc190SJeff Kirsher #define INIT_PORT_VL_SHIFT 4 15015a2cc190SJeff Kirsher #define INIT_PORT_PORT_WIDTH_SHIFT 8 15025a2cc190SJeff Kirsher #define INIT_PORT_MTU_OFFSET 0x04 15035a2cc190SJeff Kirsher #define INIT_PORT_MAX_GID_OFFSET 0x06 15045a2cc190SJeff Kirsher #define INIT_PORT_MAX_PKEY_OFFSET 0x0a 15055a2cc190SJeff Kirsher #define INIT_PORT_GUID0_OFFSET 0x10 15065a2cc190SJeff Kirsher #define INIT_PORT_NODE_GUID_OFFSET 0x18 15075a2cc190SJeff Kirsher #define INIT_PORT_SI_GUID_OFFSET 0x20 15085a2cc190SJeff Kirsher 15095a2cc190SJeff Kirsher mailbox = mlx4_alloc_cmd_mailbox(dev); 15105a2cc190SJeff Kirsher if (IS_ERR(mailbox)) 15115a2cc190SJeff Kirsher return PTR_ERR(mailbox); 15125a2cc190SJeff Kirsher inbox = mailbox->buf; 15135a2cc190SJeff Kirsher 15145a2cc190SJeff Kirsher memset(inbox, 0, INIT_PORT_IN_SIZE); 15155a2cc190SJeff Kirsher 15165a2cc190SJeff Kirsher flags = 0; 15175a2cc190SJeff Kirsher flags |= (dev->caps.vl_cap[port] & 0xf) << INIT_PORT_VL_SHIFT; 15185a2cc190SJeff Kirsher flags |= (dev->caps.port_width_cap[port] & 0xf) << INIT_PORT_PORT_WIDTH_SHIFT; 15195a2cc190SJeff Kirsher MLX4_PUT(inbox, flags, INIT_PORT_FLAGS_OFFSET); 15205a2cc190SJeff Kirsher 15215a2cc190SJeff Kirsher field = 128 << dev->caps.ib_mtu_cap[port]; 15225a2cc190SJeff Kirsher MLX4_PUT(inbox, field, INIT_PORT_MTU_OFFSET); 15235a2cc190SJeff Kirsher field = dev->caps.gid_table_len[port]; 15245a2cc190SJeff Kirsher MLX4_PUT(inbox, field, INIT_PORT_MAX_GID_OFFSET); 15255a2cc190SJeff Kirsher field = dev->caps.pkey_table_len[port]; 15265a2cc190SJeff Kirsher MLX4_PUT(inbox, field, INIT_PORT_MAX_PKEY_OFFSET); 15275a2cc190SJeff Kirsher 15285a2cc190SJeff Kirsher err = mlx4_cmd(dev, mailbox->dma, port, 0, MLX4_CMD_INIT_PORT, 1529f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 15305a2cc190SJeff Kirsher 15315a2cc190SJeff Kirsher mlx4_free_cmd_mailbox(dev, mailbox); 15325a2cc190SJeff Kirsher } else 15335a2cc190SJeff Kirsher err = mlx4_cmd(dev, 0, port, 0, MLX4_CMD_INIT_PORT, 1534f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED); 15355a2cc190SJeff Kirsher 15365a2cc190SJeff Kirsher return err; 15375a2cc190SJeff Kirsher } 15385a2cc190SJeff Kirsher EXPORT_SYMBOL_GPL(mlx4_INIT_PORT); 15395a2cc190SJeff Kirsher 15405cc914f1SMarcel Apfelbaum int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave, 15415cc914f1SMarcel Apfelbaum struct mlx4_vhcr *vhcr, 15425cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *inbox, 15435cc914f1SMarcel Apfelbaum struct mlx4_cmd_mailbox *outbox, 15445cc914f1SMarcel Apfelbaum struct mlx4_cmd_info *cmd) 15455cc914f1SMarcel Apfelbaum { 15465cc914f1SMarcel Apfelbaum struct mlx4_priv *priv = mlx4_priv(dev); 15475cc914f1SMarcel Apfelbaum int port = vhcr->in_modifier; 15485cc914f1SMarcel Apfelbaum int err; 15495cc914f1SMarcel Apfelbaum 15505cc914f1SMarcel Apfelbaum if (!(priv->mfunc.master.slave_state[slave].init_port_mask & 15515cc914f1SMarcel Apfelbaum (1 << port))) 15525cc914f1SMarcel Apfelbaum return 0; 15535cc914f1SMarcel Apfelbaum 1554980e9001SJack Morgenstein if (dev->caps.port_mask[port] != MLX4_PORT_TYPE_IB) { 15555cc914f1SMarcel Apfelbaum if (priv->mfunc.master.init_port_ref[port] == 1) { 1556980e9001SJack Morgenstein err = mlx4_cmd(dev, 0, port, 0, MLX4_CMD_CLOSE_PORT, 1557980e9001SJack Morgenstein 1000, MLX4_CMD_NATIVE); 15585cc914f1SMarcel Apfelbaum if (err) 15595cc914f1SMarcel Apfelbaum return err; 15605cc914f1SMarcel Apfelbaum } 15615cc914f1SMarcel Apfelbaum priv->mfunc.master.slave_state[slave].init_port_mask &= ~(1 << port); 1562980e9001SJack Morgenstein } else { 1563980e9001SJack Morgenstein /* infiniband port */ 1564980e9001SJack Morgenstein if (slave == mlx4_master_func_num(dev)) { 1565980e9001SJack Morgenstein if (!priv->mfunc.master.qp0_state[port].qp0_active && 1566980e9001SJack Morgenstein priv->mfunc.master.qp0_state[port].port_active) { 1567980e9001SJack Morgenstein err = mlx4_cmd(dev, 0, port, 0, MLX4_CMD_CLOSE_PORT, 1568980e9001SJack Morgenstein 1000, MLX4_CMD_NATIVE); 1569980e9001SJack Morgenstein if (err) 1570980e9001SJack Morgenstein return err; 1571980e9001SJack Morgenstein priv->mfunc.master.slave_state[slave].init_port_mask &= ~(1 << port); 1572980e9001SJack Morgenstein priv->mfunc.master.qp0_state[port].port_active = 0; 1573980e9001SJack Morgenstein } 1574980e9001SJack Morgenstein } else 1575980e9001SJack Morgenstein priv->mfunc.master.slave_state[slave].init_port_mask &= ~(1 << port); 1576980e9001SJack Morgenstein } 15775cc914f1SMarcel Apfelbaum --priv->mfunc.master.init_port_ref[port]; 15785cc914f1SMarcel Apfelbaum return 0; 15795cc914f1SMarcel Apfelbaum } 15805cc914f1SMarcel Apfelbaum 15815a2cc190SJeff Kirsher int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port) 15825a2cc190SJeff Kirsher { 1583f9baff50SJack Morgenstein return mlx4_cmd(dev, 0, port, 0, MLX4_CMD_CLOSE_PORT, 1000, 1584f9baff50SJack Morgenstein MLX4_CMD_WRAPPED); 15855a2cc190SJeff Kirsher } 15865a2cc190SJeff Kirsher EXPORT_SYMBOL_GPL(mlx4_CLOSE_PORT); 15875a2cc190SJeff Kirsher 15885a2cc190SJeff Kirsher int mlx4_CLOSE_HCA(struct mlx4_dev *dev, int panic) 15895a2cc190SJeff Kirsher { 1590f9baff50SJack Morgenstein return mlx4_cmd(dev, 0, 0, panic, MLX4_CMD_CLOSE_HCA, 1000, 1591f9baff50SJack Morgenstein MLX4_CMD_NATIVE); 15925a2cc190SJeff Kirsher } 15935a2cc190SJeff Kirsher 15945a2cc190SJeff Kirsher int mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages) 15955a2cc190SJeff Kirsher { 15965a2cc190SJeff Kirsher int ret = mlx4_cmd_imm(dev, icm_size, aux_pages, 0, 0, 15975a2cc190SJeff Kirsher MLX4_CMD_SET_ICM_SIZE, 1598f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 15995a2cc190SJeff Kirsher if (ret) 16005a2cc190SJeff Kirsher return ret; 16015a2cc190SJeff Kirsher 16025a2cc190SJeff Kirsher /* 16035a2cc190SJeff Kirsher * Round up number of system pages needed in case 16045a2cc190SJeff Kirsher * MLX4_ICM_PAGE_SIZE < PAGE_SIZE. 16055a2cc190SJeff Kirsher */ 16065a2cc190SJeff Kirsher *aux_pages = ALIGN(*aux_pages, PAGE_SIZE / MLX4_ICM_PAGE_SIZE) >> 16075a2cc190SJeff Kirsher (PAGE_SHIFT - MLX4_ICM_PAGE_SHIFT); 16085a2cc190SJeff Kirsher 16095a2cc190SJeff Kirsher return 0; 16105a2cc190SJeff Kirsher } 16115a2cc190SJeff Kirsher 16125a2cc190SJeff Kirsher int mlx4_NOP(struct mlx4_dev *dev) 16135a2cc190SJeff Kirsher { 16145a2cc190SJeff Kirsher /* Input modifier of 0x1f means "finish as soon as possible." */ 1615f9baff50SJack Morgenstein return mlx4_cmd(dev, 0, 0x1f, 0, MLX4_CMD_NOP, 100, MLX4_CMD_NATIVE); 16165a2cc190SJeff Kirsher } 16175a2cc190SJeff Kirsher 16185a2cc190SJeff Kirsher #define MLX4_WOL_SETUP_MODE (5 << 28) 16195a2cc190SJeff Kirsher int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port) 16205a2cc190SJeff Kirsher { 16215a2cc190SJeff Kirsher u32 in_mod = MLX4_WOL_SETUP_MODE | port << 8; 16225a2cc190SJeff Kirsher 16235a2cc190SJeff Kirsher return mlx4_cmd_imm(dev, 0, config, in_mod, 0x3, 1624f9baff50SJack Morgenstein MLX4_CMD_MOD_STAT_CFG, MLX4_CMD_TIME_CLASS_A, 1625f9baff50SJack Morgenstein MLX4_CMD_NATIVE); 16265a2cc190SJeff Kirsher } 16275a2cc190SJeff Kirsher EXPORT_SYMBOL_GPL(mlx4_wol_read); 16285a2cc190SJeff Kirsher 16295a2cc190SJeff Kirsher int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port) 16305a2cc190SJeff Kirsher { 16315a2cc190SJeff Kirsher u32 in_mod = MLX4_WOL_SETUP_MODE | port << 8; 16325a2cc190SJeff Kirsher 16335a2cc190SJeff Kirsher return mlx4_cmd(dev, config, in_mod, 0x1, MLX4_CMD_MOD_STAT_CFG, 1634f9baff50SJack Morgenstein MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE); 16355a2cc190SJeff Kirsher } 16365a2cc190SJeff Kirsher EXPORT_SYMBOL_GPL(mlx4_wol_write); 1637