#include <linux/highmem.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/random.h>
#include <linux/mlx5/driver.h>
#include <linux/mlx5/eq.h>
#include <linux/debugfs.h>
#include "mlx5_core.h"
#include "lib/eq.h"
#include "lib/tout.h"
#define CREATE_TRACE_POINTS
#include "diag/cmd_tracepoint.h"
struct mlx5_ifc_mbox_out_bits { … };
struct mlx5_ifc_mbox_in_bits { … };
enum { … };
enum { … };
enum { … };
static u16 in_to_opcode(void *in)
{ … }
static bool mlx5_cmd_is_throttle_opcode(u16 op)
{ … }
static struct mlx5_cmd_work_ent *
cmd_alloc_ent(struct mlx5_cmd *cmd, struct mlx5_cmd_msg *in,
struct mlx5_cmd_msg *out, void *uout, int uout_size,
mlx5_cmd_cbk_t cbk, void *context, int page_queue)
{ … }
static void cmd_free_ent(struct mlx5_cmd_work_ent *ent)
{ … }
static u8 alloc_token(struct mlx5_cmd *cmd)
{ … }
static int cmd_alloc_index(struct mlx5_cmd *cmd, struct mlx5_cmd_work_ent *ent)
{ … }
static void cmd_free_index(struct mlx5_cmd *cmd, int idx)
{ … }
static void cmd_ent_get(struct mlx5_cmd_work_ent *ent)
{ … }
static void cmd_ent_put(struct mlx5_cmd_work_ent *ent)
{ … }
static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx)
{ … }
static int mlx5_calc_cmd_blocks(struct mlx5_cmd_msg *msg)
{ … }
static u8 xor8_buf(void *buf, size_t offset, int len)
{ … }
static int verify_block_sig(struct mlx5_cmd_prot_block *block)
{ … }
static void calc_block_sig(struct mlx5_cmd_prot_block *block)
{ … }
static void calc_chain_sig(struct mlx5_cmd_msg *msg)
{ … }
static void set_signature(struct mlx5_cmd_work_ent *ent, int csum)
{ … }
static void poll_timeout(struct mlx5_cmd_work_ent *ent)
{ … }
static int verify_signature(struct mlx5_cmd_work_ent *ent)
{ … }
static void dump_buf(void *buf, int size, int data_only, int offset, int idx)
{ … }
static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
u32 *synd, u8 *status)
{ … }
const char *mlx5_command_str(int command)
{ … }
static const char *cmd_status_str(u8 status)
{ … }
static int cmd_status_to_err(u8 status)
{ … }
void mlx5_cmd_out_err(struct mlx5_core_dev *dev, u16 opcode, u16 op_mod, void *out)
{ … }
EXPORT_SYMBOL(…);
static void cmd_status_print(struct mlx5_core_dev *dev, void *in, void *out)
{ … }
int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *out)
{ … }
EXPORT_SYMBOL(…);
static void dump_command(struct mlx5_core_dev *dev,
struct mlx5_cmd_work_ent *ent, int input)
{ … }
static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced);
static void cb_timeout_handler(struct work_struct *work)
{ … }
static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg);
static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
struct mlx5_cmd_msg *msg);
static bool opcode_allowed(struct mlx5_cmd *cmd, u16 opcode)
{ … }
bool mlx5_cmd_is_down(struct mlx5_core_dev *dev)
{ … }
static void cmd_work_handler(struct work_struct *work)
{ … }
static int deliv_status_to_err(u8 status)
{ … }
static const char *deliv_status_to_str(u8 status)
{ … }
enum { … };
static void wait_func_handle_exec_timeout(struct mlx5_core_dev *dev,
struct mlx5_cmd_work_ent *ent)
{ … }
static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent)
{ … }
static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
struct mlx5_cmd_msg *out, void *uout, int uout_size,
mlx5_cmd_cbk_t callback,
void *context, int page_queue,
u8 token, bool force_polling)
{ … }
static ssize_t dbg_write(struct file *filp, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static const struct file_operations fops = …;
static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size,
u8 token)
{ … }
static int mlx5_copy_from_msg(void *to, struct mlx5_cmd_msg *from, int size)
{ … }
static struct mlx5_cmd_mailbox *alloc_cmd_box(struct mlx5_core_dev *dev,
gfp_t flags)
{ … }
static void free_cmd_box(struct mlx5_core_dev *dev,
struct mlx5_cmd_mailbox *mailbox)
{ … }
static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev,
gfp_t flags, int size,
u8 token)
{ … }
static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
struct mlx5_cmd_msg *msg)
{ … }
static ssize_t data_write(struct file *filp, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
loff_t *pos)
{ … }
static const struct file_operations dfops = …;
static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count,
loff_t *pos)
{ … }
static ssize_t outlen_write(struct file *filp, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static const struct file_operations olfops = …;
static void set_wqname(struct mlx5_core_dev *dev)
{ … }
static void clean_debug_files(struct mlx5_core_dev *dev)
{ … }
static void create_debugfs_files(struct mlx5_core_dev *dev)
{ … }
void mlx5_cmd_allowed_opcode(struct mlx5_core_dev *dev, u16 opcode)
{ … }
static void mlx5_cmd_change_mod(struct mlx5_core_dev *dev, int mode)
{ … }
static int cmd_comp_notifier(struct notifier_block *nb,
unsigned long type, void *data)
{ … }
void mlx5_cmd_use_events(struct mlx5_core_dev *dev)
{ … }
void mlx5_cmd_use_polling(struct mlx5_core_dev *dev)
{ … }
static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg)
{ … }
static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool forced)
{ … }
static void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev)
{ … }
void mlx5_cmd_flush(struct mlx5_core_dev *dev)
{ … }
static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size,
gfp_t gfp)
{ … }
static int is_manage_pages(void *in)
{ … }
static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
int out_size, mlx5_cmd_cbk_t callback, void *context,
bool force_polling)
{ … }
static void mlx5_cmd_err_trace(struct mlx5_core_dev *dev, u16 opcode, u16 op_mod, void *out)
{ … }
static void cmd_status_log(struct mlx5_core_dev *dev, u16 opcode, u8 status,
u32 syndrome, int err)
{ … }
static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, u16 op_mod, void *out)
{ … }
int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size)
{ … }
EXPORT_SYMBOL(…);
int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
int out_size)
{ … }
EXPORT_SYMBOL(…);
int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
void *out, int out_size)
{ … }
EXPORT_SYMBOL(…);
void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev,
struct mlx5_async_ctx *ctx)
{ … }
EXPORT_SYMBOL(…);
void mlx5_cmd_cleanup_async_ctx(struct mlx5_async_ctx *ctx)
{ … }
EXPORT_SYMBOL(…);
static void mlx5_cmd_exec_cb_handler(int status, void *_work)
{ … }
int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
void *out, int out_size, mlx5_async_cbk_t callback,
struct mlx5_async_work *work)
{ … }
EXPORT_SYMBOL(…);
int mlx5_cmd_allow_other_vhca_access(struct mlx5_core_dev *dev,
struct mlx5_cmd_allow_other_vhca_access_attr *attr)
{ … }
int mlx5_cmd_alias_obj_create(struct mlx5_core_dev *dev,
struct mlx5_cmd_alias_obj_create_attr *alias_attr,
u32 *obj_id)
{ … }
int mlx5_cmd_alias_obj_destroy(struct mlx5_core_dev *dev, u32 obj_id,
u16 obj_type)
{ … }
static void destroy_msg_cache(struct mlx5_core_dev *dev)
{ … }
static unsigned cmd_cache_num_ent[MLX5_NUM_COMMAND_CACHES] = …;
static unsigned cmd_cache_ent_size[MLX5_NUM_COMMAND_CACHES] = …;
static void create_msg_cache(struct mlx5_core_dev *dev)
{ … }
static int alloc_cmd_page(struct mlx5_core_dev *dev, struct mlx5_cmd *cmd)
{ … }
static void free_cmd_page(struct mlx5_core_dev *dev, struct mlx5_cmd *cmd)
{ … }
static u16 cmdif_rev(struct mlx5_core_dev *dev)
{ … }
int mlx5_cmd_init(struct mlx5_core_dev *dev)
{ … }
void mlx5_cmd_cleanup(struct mlx5_core_dev *dev)
{ … }
int mlx5_cmd_enable(struct mlx5_core_dev *dev)
{ … }
void mlx5_cmd_disable(struct mlx5_core_dev *dev)
{ … }
void mlx5_cmd_set_state(struct mlx5_core_dev *dev,
enum mlx5_cmdif_state cmdif_state)
{ … }