mirror of
https://github.com/torvalds/linux.git
synced 2024-11-20 11:01:38 +00:00
mlx4_core: resource tracking for HCA resources used by guests
The resource tracker is used to track usage of HCA resources by the different guests. Virtual functions (VFs) are attached to guest operating systems but resources are allocated from the same pool and are assigned to VFs. It is essential that hostile/buggy guests not be able to affect the operation of other VFs, possibly attached to other guest OSs since ConnectX firmware is not tolerant to misuse of resources. The resource tracker module associates each resource with a VF and maintains state information for the allocated object. It also defines allowed state transitions and enforces them. Relationships between resources are also referred to. For example, CQs are pointed to by QPs, so it is forbidden to destroy a CQ if a QP refers to it. ICM memory is always accessible through the primary function and hence it is allocated by the owner of the primary function. When a guest dies, an FLR is generated for all the VFs it owns and all the resources it used are freed. The tracked resource types are: QPs, CQs, SRQs, MPTs, MTTs, MACs, RES_EQs, and XRCDNs. Signed-off-by: Eli Cohen <eli@mellanox.co.il> Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
acba2420f9
commit
c82e9aa0a8
@ -1,7 +1,7 @@
|
||||
obj-$(CONFIG_MLX4_CORE) += mlx4_core.o
|
||||
|
||||
mlx4_core-y := alloc.o catas.o cmd.o cq.o eq.o fw.o icm.o intf.o main.o mcg.o \
|
||||
mr.o pd.o port.o profile.o qp.o reset.o sense.o srq.o
|
||||
mr.o pd.o port.o profile.o qp.o reset.o sense.o srq.o resource_tracker.o
|
||||
|
||||
obj-$(CONFIG_MLX4_EN) += mlx4_en.o
|
||||
|
||||
|
@ -172,12 +172,6 @@ static void mlx4_comm_cmd_post(struct mlx4_dev *dev, u8 cmd, u16 param)
|
||||
mmiowb();
|
||||
}
|
||||
|
||||
/* dummy procedure for this patch */
|
||||
int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mlx4_comm_cmd_poll(struct mlx4_dev *dev, u8 cmd, u16 param,
|
||||
unsigned long timeout)
|
||||
{
|
||||
@ -614,6 +608,403 @@ static struct mlx4_cmd_info cmd_info[] = {
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_FUNC_CAP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_FUNC_CAP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_ADAPTER,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_INIT_PORT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_INIT_PORT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_CLOSE_PORT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_CLOSE_PORT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_PORT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_PORT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_MAP_EQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_MAP_EQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SW2HW_EQ,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_SW2HW_EQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_HW_HEALTH_CHECK,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_NOP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_ALLOC_RES,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = true,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_ALLOC_RES_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_FREE_RES,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_FREE_RES_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SW2HW_MPT,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_SW2HW_MPT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_MPT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_MPT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_HW2SW_MPT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_HW2SW_MPT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_READ_MTT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_WRITE_MTT,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_WRITE_MTT_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SYNC_TPT,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_HW2SW_EQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_HW2SW_EQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_EQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_EQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SW2HW_CQ,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_SW2HW_CQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_HW2SW_CQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_HW2SW_CQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_CQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_CQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_MODIFY_CQ,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = true,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_MODIFY_CQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SW2HW_SRQ,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_SW2HW_SRQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_HW2SW_SRQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_HW2SW_SRQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_SRQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_SRQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_ARM_SRQ,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_ARM_SRQ_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_RST2INIT_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = true,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_RST2INIT_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_INIT2INIT_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_INIT2RTR_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_INIT2RTR_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_RTR2RTS_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_RTS2RTS_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SQERR2RTS_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_2ERR_QP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_RTS2SQD_QP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SQD2SQD_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SQD2RTS_QP,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_2RST_QP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_2RST_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_QP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_SUSPEND_QP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_UNSUSPEND_QP,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_GEN_QP_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_QUERY_IF_STAT,
|
||||
.has_inbox = false,
|
||||
.has_outbox = true,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QUERY_IF_STAT_wrapper
|
||||
},
|
||||
/* Native multicast commands are not available for guests */
|
||||
{
|
||||
.opcode = MLX4_CMD_QP_ATTACH,
|
||||
.has_inbox = true,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = mlx4_QP_ATTACH_wrapper
|
||||
},
|
||||
{
|
||||
.opcode = MLX4_CMD_INFORM_FLR_DONE,
|
||||
.has_inbox = false,
|
||||
.has_outbox = false,
|
||||
.out_is_imm = false,
|
||||
.encode_slave_id = false,
|
||||
.verify = NULL,
|
||||
.wrapper = NULL
|
||||
},
|
||||
};
|
||||
|
||||
static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
|
||||
@ -877,6 +1268,8 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd,
|
||||
return;
|
||||
|
||||
reset_slave:
|
||||
/* cleanup any slave resources */
|
||||
mlx4_delete_all_resources_for_slave(dev, slave);
|
||||
spin_lock(&priv->mfunc.master.slave_state_lock);
|
||||
if (!slave_state[slave].is_slave_going_down)
|
||||
slave_state[slave].last_cmd = MLX4_COMM_CMD_RESET;
|
||||
|
@ -44,27 +44,6 @@
|
||||
#include "mlx4.h"
|
||||
#include "icm.h"
|
||||
|
||||
struct mlx4_cq_context {
|
||||
__be32 flags;
|
||||
u16 reserved1[3];
|
||||
__be16 page_offset;
|
||||
__be32 logsize_usrpage;
|
||||
__be16 cq_period;
|
||||
__be16 cq_max_count;
|
||||
u8 reserved2[3];
|
||||
u8 comp_eqn;
|
||||
u8 log_page_size;
|
||||
u8 reserved3[2];
|
||||
u8 mtt_base_addr_h;
|
||||
__be32 mtt_base_addr_l;
|
||||
__be32 last_notified_index;
|
||||
__be32 solicit_producer_index;
|
||||
__be32 consumer_index;
|
||||
__be32 producer_index;
|
||||
u32 reserved4[2];
|
||||
__be64 db_rec_addr;
|
||||
};
|
||||
|
||||
#define MLX4_CQ_STATUS_OK ( 0 << 28)
|
||||
#define MLX4_CQ_STATUS_OVERFLOW ( 9 << 28)
|
||||
#define MLX4_CQ_STATUS_WRITE_FAIL (10 << 28)
|
||||
@ -189,7 +168,7 @@ int mlx4_cq_resize(struct mlx4_dev *dev, struct mlx4_cq *cq,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mlx4_cq_resize);
|
||||
|
||||
static int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn)
|
||||
int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
struct mlx4_cq_table *cq_table = &priv->cq_table;
|
||||
@ -235,7 +214,7 @@ static int mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn)
|
||||
return __mlx4_cq_alloc_icm(dev, cqn);
|
||||
}
|
||||
|
||||
static void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn)
|
||||
void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
struct mlx4_cq_table *cq_table = &priv->cq_table;
|
||||
|
@ -53,30 +53,6 @@ enum {
|
||||
MLX4_EQ_ENTRY_SIZE = 0x20
|
||||
};
|
||||
|
||||
/*
|
||||
* Must be packed because start is 64 bits but only aligned to 32 bits.
|
||||
*/
|
||||
struct mlx4_eq_context {
|
||||
__be32 flags;
|
||||
u16 reserved1[3];
|
||||
__be16 page_offset;
|
||||
u8 log_eq_size;
|
||||
u8 reserved2[4];
|
||||
u8 eq_period;
|
||||
u8 reserved3;
|
||||
u8 eq_max_count;
|
||||
u8 reserved4[3];
|
||||
u8 intr;
|
||||
u8 log_page_size;
|
||||
u8 reserved5[2];
|
||||
u8 mtt_base_addr_h;
|
||||
__be32 mtt_base_addr_l;
|
||||
u32 reserved6[2];
|
||||
__be32 consumer_index;
|
||||
__be32 producer_index;
|
||||
u32 reserved7[4];
|
||||
};
|
||||
|
||||
#define MLX4_EQ_STATUS_OK ( 0 << 28)
|
||||
#define MLX4_EQ_STATUS_WRITE_FAIL (10 << 28)
|
||||
#define MLX4_EQ_OWNER_SW ( 0 << 24)
|
||||
@ -135,19 +111,6 @@ static struct mlx4_eqe *next_slave_event_eqe(struct mlx4_slave_event_eq *slave_e
|
||||
eqe : NULL;
|
||||
}
|
||||
|
||||
/* dummies for now */
|
||||
void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave)
|
||||
{
|
||||
}
|
||||
|
||||
int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
|
||||
enum mlx4_resource type,
|
||||
int res_id, int *slave)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
/* end dummies */
|
||||
|
||||
void mlx4_gen_slave_eqe(struct work_struct *work)
|
||||
{
|
||||
struct mlx4_mfunc_master_ctx *master =
|
||||
|
@ -224,6 +224,91 @@ struct mlx4_icm_table {
|
||||
struct mlx4_icm **icm;
|
||||
};
|
||||
|
||||
/*
|
||||
* Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
|
||||
*/
|
||||
struct mlx4_mpt_entry {
|
||||
__be32 flags;
|
||||
__be32 qpn;
|
||||
__be32 key;
|
||||
__be32 pd_flags;
|
||||
__be64 start;
|
||||
__be64 length;
|
||||
__be32 lkey;
|
||||
__be32 win_cnt;
|
||||
u8 reserved1[3];
|
||||
u8 mtt_rep;
|
||||
__be64 mtt_seg;
|
||||
__be32 mtt_sz;
|
||||
__be32 entity_size;
|
||||
__be32 first_byte_offset;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Must be packed because start is 64 bits but only aligned to 32 bits.
|
||||
*/
|
||||
struct mlx4_eq_context {
|
||||
__be32 flags;
|
||||
u16 reserved1[3];
|
||||
__be16 page_offset;
|
||||
u8 log_eq_size;
|
||||
u8 reserved2[4];
|
||||
u8 eq_period;
|
||||
u8 reserved3;
|
||||
u8 eq_max_count;
|
||||
u8 reserved4[3];
|
||||
u8 intr;
|
||||
u8 log_page_size;
|
||||
u8 reserved5[2];
|
||||
u8 mtt_base_addr_h;
|
||||
__be32 mtt_base_addr_l;
|
||||
u32 reserved6[2];
|
||||
__be32 consumer_index;
|
||||
__be32 producer_index;
|
||||
u32 reserved7[4];
|
||||
};
|
||||
|
||||
struct mlx4_cq_context {
|
||||
__be32 flags;
|
||||
u16 reserved1[3];
|
||||
__be16 page_offset;
|
||||
__be32 logsize_usrpage;
|
||||
__be16 cq_period;
|
||||
__be16 cq_max_count;
|
||||
u8 reserved2[3];
|
||||
u8 comp_eqn;
|
||||
u8 log_page_size;
|
||||
u8 reserved3[2];
|
||||
u8 mtt_base_addr_h;
|
||||
__be32 mtt_base_addr_l;
|
||||
__be32 last_notified_index;
|
||||
__be32 solicit_producer_index;
|
||||
__be32 consumer_index;
|
||||
__be32 producer_index;
|
||||
u32 reserved4[2];
|
||||
__be64 db_rec_addr;
|
||||
};
|
||||
|
||||
struct mlx4_srq_context {
|
||||
__be32 state_logsize_srqn;
|
||||
u8 logstride;
|
||||
u8 reserved1;
|
||||
__be16 xrcd;
|
||||
__be32 pg_offset_cqn;
|
||||
u32 reserved2;
|
||||
u8 log_page_size;
|
||||
u8 reserved3[2];
|
||||
u8 mtt_base_addr_h;
|
||||
__be32 mtt_base_addr_l;
|
||||
__be32 pd;
|
||||
__be16 limit_watermark;
|
||||
__be16 wqe_cnt;
|
||||
u16 reserved4;
|
||||
__be16 wqe_counter;
|
||||
u32 reserved5;
|
||||
__be64 db_rec_addr;
|
||||
};
|
||||
|
||||
struct mlx4_eqe {
|
||||
u8 reserved1;
|
||||
u8 type;
|
||||
@ -657,6 +742,18 @@ void mlx4_cleanup_cq_table(struct mlx4_dev *dev);
|
||||
void mlx4_cleanup_qp_table(struct mlx4_dev *dev);
|
||||
void mlx4_cleanup_srq_table(struct mlx4_dev *dev);
|
||||
void mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
|
||||
int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn);
|
||||
void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn);
|
||||
int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn);
|
||||
void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn);
|
||||
int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn);
|
||||
void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn);
|
||||
int __mlx4_mr_reserve(struct mlx4_dev *dev);
|
||||
void __mlx4_mr_release(struct mlx4_dev *dev, u32 index);
|
||||
int __mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index);
|
||||
void __mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index);
|
||||
u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order);
|
||||
void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order);
|
||||
|
||||
int mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
|
||||
struct mlx4_vhcr *vhcr,
|
||||
@ -693,6 +790,14 @@ int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave,
|
||||
struct mlx4_cmd_mailbox *inbox,
|
||||
struct mlx4_cmd_mailbox *outbox,
|
||||
struct mlx4_cmd_info *cmd);
|
||||
int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
|
||||
int *base);
|
||||
void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
|
||||
int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
|
||||
void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
|
||||
int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
|
||||
int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
||||
int start_index, int npages, u64 *page_list);
|
||||
|
||||
void mlx4_start_catas_poll(struct mlx4_dev *dev);
|
||||
void mlx4_stop_catas_poll(struct mlx4_dev *dev);
|
||||
@ -936,6 +1041,11 @@ static inline u32 get_param_h(u64 *arg)
|
||||
return (u32)(*arg >> 32);
|
||||
}
|
||||
|
||||
static inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev)
|
||||
{
|
||||
return &mlx4_priv(dev)->mfunc.master.res_tracker.lock;
|
||||
}
|
||||
|
||||
#define NOT_MASKED_PD_BITS 17
|
||||
|
||||
#endif /* MLX4_H */
|
||||
|
@ -43,26 +43,6 @@
|
||||
#include "mlx4.h"
|
||||
#include "icm.h"
|
||||
|
||||
/*
|
||||
* Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
|
||||
*/
|
||||
struct mlx4_mpt_entry {
|
||||
__be32 flags;
|
||||
__be32 qpn;
|
||||
__be32 key;
|
||||
__be32 pd_flags;
|
||||
__be64 start;
|
||||
__be64 length;
|
||||
__be32 lkey;
|
||||
__be32 win_cnt;
|
||||
u8 reserved1[3];
|
||||
u8 mtt_rep;
|
||||
__be64 mtt_seg;
|
||||
__be32 mtt_sz;
|
||||
__be32 entity_size;
|
||||
__be32 first_byte_offset;
|
||||
} __packed;
|
||||
|
||||
#define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28)
|
||||
#define MLX4_MPT_FLAG_FREE (0x3UL << 28)
|
||||
#define MLX4_MPT_FLAG_MIO (1 << 17)
|
||||
@ -182,7 +162,7 @@ static void mlx4_buddy_cleanup(struct mlx4_buddy *buddy)
|
||||
kfree(buddy->num_free);
|
||||
}
|
||||
|
||||
static u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order)
|
||||
u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order)
|
||||
{
|
||||
struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table;
|
||||
u32 seg;
|
||||
@ -243,7 +223,7 @@ int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mlx4_mtt_init);
|
||||
|
||||
static void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg,
|
||||
void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg,
|
||||
int order)
|
||||
{
|
||||
struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table;
|
||||
@ -360,7 +340,7 @@ static int mlx4_WRITE_MTT(struct mlx4_dev *dev,
|
||||
MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
|
||||
}
|
||||
|
||||
static int __mlx4_mr_reserve(struct mlx4_dev *dev)
|
||||
int __mlx4_mr_reserve(struct mlx4_dev *dev)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
|
||||
@ -381,7 +361,7 @@ static int mlx4_mr_reserve(struct mlx4_dev *dev)
|
||||
return __mlx4_mr_reserve(dev);
|
||||
}
|
||||
|
||||
static void __mlx4_mr_release(struct mlx4_dev *dev, u32 index)
|
||||
void __mlx4_mr_release(struct mlx4_dev *dev, u32 index)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
|
||||
@ -404,7 +384,7 @@ static void mlx4_mr_release(struct mlx4_dev *dev, u32 index)
|
||||
__mlx4_mr_release(dev, index);
|
||||
}
|
||||
|
||||
static int __mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index)
|
||||
int __mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index)
|
||||
{
|
||||
struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table;
|
||||
|
||||
@ -425,7 +405,7 @@ static int mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index)
|
||||
return __mlx4_mr_alloc_icm(dev, index);
|
||||
}
|
||||
|
||||
static void __mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index)
|
||||
void __mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index)
|
||||
{
|
||||
struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table;
|
||||
|
||||
@ -595,7 +575,7 @@ static int mlx4_write_mtt_chunk(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
||||
int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
||||
int start_index, int npages, u64 *page_list)
|
||||
{
|
||||
int err = 0;
|
||||
|
@ -182,7 +182,7 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mlx4_qp_modify);
|
||||
|
||||
static int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
|
||||
int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
|
||||
int *base)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
@ -218,7 +218,7 @@ int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, int *base)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mlx4_qp_reserve_range);
|
||||
|
||||
static void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
|
||||
void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
||||
@ -248,7 +248,7 @@ void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mlx4_qp_release_range);
|
||||
|
||||
static int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn)
|
||||
int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
||||
@ -305,7 +305,7 @@ static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn)
|
||||
return __mlx4_qp_alloc_icm(dev, qpn);
|
||||
}
|
||||
|
||||
static void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
|
||||
void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
|
||||
{
|
||||
struct mlx4_priv *priv = mlx4_priv(dev);
|
||||
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
||||
|
3103
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
Normal file
3103
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -40,26 +40,6 @@
|
||||
#include "mlx4.h"
|
||||
#include "icm.h"
|
||||
|
||||
struct mlx4_srq_context {
|
||||
__be32 state_logsize_srqn;
|
||||
u8 logstride;
|
||||
u8 reserved1;
|
||||
__be16 xrcd;
|
||||
__be32 pg_offset_cqn;
|
||||
u32 reserved2;
|
||||
u8 log_page_size;
|
||||
u8 reserved3[2];
|
||||
u8 mtt_base_addr_h;
|
||||
__be32 mtt_base_addr_l;
|
||||
__be32 pd;
|
||||
__be16 limit_watermark;
|
||||
__be16 wqe_cnt;
|
||||
u16 reserved4;
|
||||
__be16 wqe_counter;
|
||||
u32 reserved5;
|
||||
__be64 db_rec_addr;
|
||||
};
|
||||
|
||||
void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
|
||||
{
|
||||
struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
|
||||
@ -113,7 +93,7 @@ static int mlx4_QUERY_SRQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
|
||||
MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
|
||||
}
|
||||
|
||||
static int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn)
|
||||
int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn)
|
||||
{
|
||||
struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
|
||||
int err;
|
||||
@ -158,7 +138,7 @@ static int mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn)
|
||||
return __mlx4_srq_alloc_icm(dev, srqn);
|
||||
}
|
||||
|
||||
static void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn)
|
||||
void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn)
|
||||
{
|
||||
struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user