cmd.h revision 219820
122514Sdarrenr/* 260841Sdarrenr * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. 322514Sdarrenr * 422514Sdarrenr * This software is available to you under a choice of one of two 522514Sdarrenr * licenses. You may choose to be licensed under the terms of the GNU 622514Sdarrenr * General Public License (GPL) Version 2, available from the file 722514Sdarrenr * COPYING in the main directory of this source tree, or the 822514Sdarrenr * OpenIB.org BSD license below: 960841Sdarrenr * 1022514Sdarrenr * Redistribution and use in source and binary forms, with or 1122514Sdarrenr * without modification, are permitted provided that the following 1226119Sdarrenr * conditions are met: 1326119Sdarrenr * 1426119Sdarrenr * - Redistributions of source code must retain the above 1522514Sdarrenr * copyright notice, this list of conditions and the following 1622514Sdarrenr * disclaimer. 1722514Sdarrenr * 1853024Sguido * - Redistributions in binary form must reproduce the above 1953024Sguido * copyright notice, this list of conditions and the following 2053024Sguido * disclaimer in the documentation and/or other materials 2153024Sguido * provided with the distribution. 2253024Sguido * 2353024Sguido * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2453024Sguido * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2553024Sguido * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2653024Sguido * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2753024Sguido * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2822514Sdarrenr * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2922514Sdarrenr * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3022514Sdarrenr * SOFTWARE. 3122514Sdarrenr */ 3253024Sguido 3353024Sguido#ifndef MLX4_CMD_H 3453024Sguido#define MLX4_CMD_H 3553024Sguido 3653024Sguido#include <linux/dma-mapping.h> 3753024Sguido 3853024Sguidoenum { 3953024Sguido /* initialization and general commands */ 4060841Sdarrenr MLX4_CMD_SYS_EN = 0x1, 4160841Sdarrenr MLX4_CMD_SYS_DIS = 0x2, 4260841Sdarrenr MLX4_CMD_MAP_FA = 0xfff, 4360841Sdarrenr MLX4_CMD_UNMAP_FA = 0xffe, 4422514Sdarrenr MLX4_CMD_RUN_FW = 0xff6, 4560841Sdarrenr MLX4_CMD_MOD_STAT_CFG = 0x34, 4660841Sdarrenr MLX4_CMD_QUERY_DEV_CAP = 0x3, 4760841Sdarrenr MLX4_CMD_QUERY_FW = 0x4, 4860841Sdarrenr MLX4_CMD_ENABLE_LAM = 0xff8, 4924583Sdarrenr MLX4_CMD_DISABLE_LAM = 0xff7, 5024583Sdarrenr MLX4_CMD_QUERY_DDR = 0x5, 5124583Sdarrenr MLX4_CMD_QUERY_ADAPTER = 0x6, 5224583Sdarrenr MLX4_CMD_INIT_HCA = 0x7, 5324583Sdarrenr MLX4_CMD_CLOSE_HCA = 0x8, 5424583Sdarrenr MLX4_CMD_INIT_PORT = 0x9, 5524583Sdarrenr MLX4_CMD_CLOSE_PORT = 0xa, 5622514Sdarrenr MLX4_CMD_QUERY_HCA = 0xb, 5760841Sdarrenr MLX4_CMD_QUERY_PORT = 0x43, 5860841Sdarrenr MLX4_CMD_SENSE_PORT = 0x4d, 5931183Speter MLX4_CMD_HW_HEALTH_CHECK = 0x50, 6031183Speter MLX4_CMD_SET_PORT = 0xc, 6131183Speter MLX4_CMD_SET_NODE = 0x5a, 6231183Speter MLX4_CMD_ACCESS_DDR = 0x2e, 6353024Sguido MLX4_CMD_MAP_ICM = 0xffa, 6422514Sdarrenr MLX4_CMD_UNMAP_ICM = 0xff9, 6524583Sdarrenr MLX4_CMD_MAP_ICM_AUX = 0xffc, 6624583Sdarrenr MLX4_CMD_UNMAP_ICM_AUX = 0xffb, 6753024Sguido MLX4_CMD_SET_ICM_SIZE = 0xffd, 6824583Sdarrenr 6924583Sdarrenr /* TPT commands */ 7022514Sdarrenr MLX4_CMD_SW2HW_MPT = 0xd, 7122514Sdarrenr MLX4_CMD_QUERY_MPT = 0xe, 7222514Sdarrenr MLX4_CMD_HW2SW_MPT = 0xf, 7322514Sdarrenr MLX4_CMD_READ_MTT = 0x10, 7422514Sdarrenr MLX4_CMD_WRITE_MTT = 0x11, 7522514Sdarrenr MLX4_CMD_SYNC_TPT = 0x2f, 7622514Sdarrenr 7722514Sdarrenr /* EQ commands */ 7860841Sdarrenr MLX4_CMD_MAP_EQ = 0x12, 7960841Sdarrenr MLX4_CMD_SW2HW_EQ = 0x13, 8060841Sdarrenr MLX4_CMD_HW2SW_EQ = 0x14, 8160841Sdarrenr MLX4_CMD_QUERY_EQ = 0x15, 8260841Sdarrenr 8360841Sdarrenr /* CQ commands */ 8460841Sdarrenr MLX4_CMD_SW2HW_CQ = 0x16, 8560841Sdarrenr MLX4_CMD_HW2SW_CQ = 0x17, 8660841Sdarrenr MLX4_CMD_QUERY_CQ = 0x18, 8760841Sdarrenr MLX4_CMD_MODIFY_CQ = 0x2c, 8860841Sdarrenr 8960841Sdarrenr /* SRQ commands */ 9031183Speter MLX4_CMD_SW2HW_SRQ = 0x35, 9160841Sdarrenr MLX4_CMD_HW2SW_SRQ = 0x36, 9260841Sdarrenr MLX4_CMD_QUERY_SRQ = 0x37, 9353024Sguido MLX4_CMD_ARM_SRQ = 0x40, 9431183Speter 9560841Sdarrenr /* QP/EE commands */ 9660841Sdarrenr MLX4_CMD_RST2INIT_QP = 0x19, 9760841Sdarrenr MLX4_CMD_INIT2RTR_QP = 0x1a, 9822514Sdarrenr MLX4_CMD_RTR2RTS_QP = 0x1b, 9924583Sdarrenr MLX4_CMD_RTS2RTS_QP = 0x1c, 10053024Sguido MLX4_CMD_SQERR2RTS_QP = 0x1d, 10153024Sguido MLX4_CMD_2ERR_QP = 0x1e, 10222514Sdarrenr MLX4_CMD_RTS2SQD_QP = 0x1f, 10322514Sdarrenr MLX4_CMD_SQD2SQD_QP = 0x38, 10453024Sguido MLX4_CMD_SQD2RTS_QP = 0x20, 10553024Sguido MLX4_CMD_2RST_QP = 0x21, 10622514Sdarrenr MLX4_CMD_QUERY_QP = 0x22, 10722514Sdarrenr MLX4_CMD_INIT2INIT_QP = 0x2d, 10853024Sguido MLX4_CMD_SUSPEND_QP = 0x32, 10922514Sdarrenr MLX4_CMD_UNSUSPEND_QP = 0x33, 11022514Sdarrenr /* special QP and management commands */ 11122514Sdarrenr MLX4_CMD_CONF_SPECIAL_QP = 0x23, 11222514Sdarrenr MLX4_CMD_MAD_IFC = 0x24, 11322514Sdarrenr 11422514Sdarrenr /* multicast commands */ 11526119Sdarrenr MLX4_CMD_READ_MCG = 0x25, 116 MLX4_CMD_WRITE_MCG = 0x26, 117 MLX4_CMD_MGID_HASH = 0x27, 118 119 /* miscellaneous commands */ 120 MLX4_CMD_DIAG_RPRT = 0x30, 121 MLX4_CMD_NOP = 0x31, 122 123 /* debug commands */ 124 MLX4_CMD_QUERY_DEBUG_MSG = 0x2a, 125 MLX4_CMD_SET_DEBUG_MSG = 0x2b, 126 127 /* statistics commands */ 128 MLX4_CMD_QUERY_IF_STAT = 0X54, 129 MLX4_CMD_SET_IF_STAT = 0X55, 130}; 131 132enum { 133 MLX4_CMD_TIME_CLASS_A = 10000, 134 MLX4_CMD_TIME_CLASS_B = 10000, 135 MLX4_CMD_TIME_CLASS_C = 10000, 136}; 137 138enum { 139 MLX4_MAILBOX_SIZE = 4096 140}; 141 142enum { 143 /* set port opcode modifiers */ 144 MLX4_SET_PORT_GENERAL = 0x0, 145 MLX4_SET_PORT_RQP_CALC = 0x1, 146 MLX4_SET_PORT_MAC_TABLE = 0x2, 147 MLX4_SET_PORT_VLAN_TABLE = 0x3, 148 MLX4_SET_PORT_PRIO_MAP = 0x4, 149 MLX4_SET_PORT_GID_TABLE = 0x5, 150}; 151 152struct mlx4_dev; 153 154struct mlx4_cmd_mailbox { 155 void *buf; 156 dma_addr_t dma; 157}; 158 159int __mlx4_cmd(struct mlx4_dev *dev, u64 in_param, u64 *out_param, 160 int out_is_imm, u32 in_modifier, u8 op_modifier, 161 u16 op, unsigned long timeout); 162 163/* Invoke a command with no output parameter */ 164static inline int mlx4_cmd(struct mlx4_dev *dev, u64 in_param, u32 in_modifier, 165 u8 op_modifier, u16 op, unsigned long timeout) 166{ 167 return __mlx4_cmd(dev, in_param, NULL, 0, in_modifier, 168 op_modifier, op, timeout); 169} 170 171/* Invoke a command with an output mailbox */ 172static inline int mlx4_cmd_box(struct mlx4_dev *dev, u64 in_param, u64 out_param, 173 u32 in_modifier, u8 op_modifier, u16 op, 174 unsigned long timeout) 175{ 176 return __mlx4_cmd(dev, in_param, &out_param, 0, in_modifier, 177 op_modifier, op, timeout); 178} 179 180/* 181 * Invoke a command with an immediate output parameter (and copy the 182 * output into the caller's out_param pointer after the command 183 * executes). 184 */ 185static inline int mlx4_cmd_imm(struct mlx4_dev *dev, u64 in_param, u64 *out_param, 186 u32 in_modifier, u8 op_modifier, u16 op, 187 unsigned long timeout) 188{ 189 return __mlx4_cmd(dev, in_param, out_param, 1, in_modifier, 190 op_modifier, op, timeout); 191} 192 193struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev); 194void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox); 195 196#endif /* MLX4_CMD_H */ 197