linux/drivers/net/ethernet/mellanox/mlx5/core/cmd.c

/*
 * Copyright (c) 2013-2016, Mellanox Technologies. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#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)
{}

/* Returns true for opcodes that might be triggered very frequently and throttle
 * the command interface. Limit their command slots usage.
 */
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)
{}

/*  Notes:
 *    1. Callback functions may not sleep
 *    2. page queue commands do not support asynchrous completion
 *
 * return value in case (!callback):
 *	ret < 0 : Command execution couldn't be submitted by driver
 *	ret > 0 : Command execution couldn't be performed by firmware
 *	ret == 0: Command was executed by FW, Caller must check FW outbox status.
 *
 * return value in case (callback):
 *	ret < 0 : Command execution couldn't be submitted by driver
 *	ret == 0: Command will be submitted to FW for execution
 *		  and the callback will be called for further status updates
 */
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)
{}

/*  Notes:
 *    1. Callback functions may not sleep
 *    2. Page queue commands do not support asynchrous completion
 */
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)
{}

/* preserve -EREMOTEIO for outbox.status != OK, otherwise return err as is */
static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, u16 op_mod, void *out)
{}

/**
 * mlx5_cmd_do - Executes a fw command, wait for completion.
 * Unlike mlx5_cmd_exec, this function will not translate or intercept
 * outbox.status and will return -EREMOTEIO when
 * outbox.status != MLX5_CMD_STAT_OK
 *
 * @dev: mlx5 core device
 * @in: inbox mlx5_ifc command buffer
 * @in_size: inbox buffer size
 * @out: outbox mlx5_ifc buffer
 * @out_size: outbox size
 *
 * @return:
 * -EREMOTEIO : Command executed by FW, outbox.status != MLX5_CMD_STAT_OK.
 *              Caller must check FW outbox status.
 *   0 : Command execution successful, outbox.status == MLX5_CMD_STAT_OK.
 * < 0 : Command execution couldn't be performed by firmware or driver
 */
int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size)
{}
EXPORT_SYMBOL();

/**
 * mlx5_cmd_exec - Executes a fw command, wait for completion
 *
 * @dev: mlx5 core device
 * @in: inbox mlx5_ifc command buffer
 * @in_size: inbox buffer size
 * @out: outbox mlx5_ifc buffer
 * @out_size: outbox size
 *
 * @return: 0 if no error, FW command execution was successful
 *          and outbox status is ok.
 */
int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
		  int out_size)
{}
EXPORT_SYMBOL();

/**
 * mlx5_cmd_exec_polling - Executes a fw command, poll for completion
 *	Needed for driver force teardown, when command completion EQ
 *	will not be available to complete the command
 *
 * @dev: mlx5 core device
 * @in: inbox mlx5_ifc command buffer
 * @in_size: inbox buffer size
 * @out: outbox mlx5_ifc buffer
 * @out_size: outbox size
 *
 * @return: 0 if no error, FW command execution was successful
 *          and outbox status is ok.
 */
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();

/**
 * mlx5_cmd_cleanup_async_ctx - Clean up an async_ctx
 * @ctx: The ctx to clean
 *
 * Upon return all callbacks given to mlx5_cmd_exec_cb() have been called. The
 * caller must ensure that mlx5_cmd_exec_cb() is not called during or after
 * the call mlx5_cleanup_async_ctx().
 */
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)
{}