linux/drivers/scsi/fnic/fnic_trace.c

// SPDX-License-Identifier: GPL-2.0-only
// Copyright 2012 Cisco Systems, Inc.  All rights reserved.

#include <linux/module.h>
#include <linux/mempool.h>
#include <linux/errno.h>
#include <linux/spinlock.h>
#include <linux/kallsyms.h>
#include <linux/time.h>
#include <linux/vmalloc.h>
#include "fnic_io.h"
#include "fnic.h"

unsigned int trace_max_pages;
static int fnic_max_trace_entries;

static unsigned long fnic_trace_buf_p;
static DEFINE_SPINLOCK(fnic_trace_lock);

static fnic_trace_dbg_t fnic_trace_entries;
int fnic_tracing_enabled =;

/* static char *fnic_fc_ctlr_trace_buf_p; */

static int fc_trace_max_entries;
static unsigned long fnic_fc_ctlr_trace_buf_p;
static fnic_trace_dbg_t fc_trace_entries;
int fnic_fc_tracing_enabled =;
int fnic_fc_trace_cleared =;
static DEFINE_SPINLOCK(fnic_fc_trace_lock);


/*
 * fnic_trace_get_buf - Give buffer pointer to user to fill up trace information
 *
 * Description:
 * This routine gets next available trace buffer entry location @wr_idx
 * from allocated trace buffer pages and give that memory location
 * to user to store the trace information.
 *
 * Return Value:
 * This routine returns pointer to next available trace entry
 * @fnic_buf_head for user to fill trace information.
 */
fnic_trace_data_t *fnic_trace_get_buf(void)
{}

/*
 * fnic_get_trace_data - Copy trace buffer to a memory file
 * @fnic_dbgfs_t: pointer to debugfs trace buffer
 *
 * Description:
 * This routine gathers the fnic trace debugfs data from the fnic_trace_data_t
 * buffer and dumps it to fnic_dbgfs_t. It will start at the rd_idx entry in
 * the log and process the log until the end of the buffer. Then it will gather
 * from the beginning of the log and process until the current entry @wr_idx.
 *
 * Return Value:
 * This routine returns the amount of bytes that were dumped into fnic_dbgfs_t
 */
int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
{}

/*
 * fnic_get_stats_data - Copy fnic stats buffer to a memory file
 * @fnic_dbgfs_t: pointer to debugfs fnic stats buffer
 *
 * Description:
 * This routine gathers the fnic stats debugfs data from the fnic_stats struct
 * and dumps it to stats_debug_info.
 *
 * Return Value:
 * This routine returns the amount of bytes that were dumped into
 * stats_debug_info
 */
int fnic_get_stats_data(struct stats_debug_info *debug,
			struct fnic_stats *stats)
{}

/*
 * fnic_trace_buf_init - Initialize fnic trace buffer logging facility
 *
 * Description:
 * Initialize trace buffer data structure by allocating required memory and
 * setting page_offset information for every trace entry by adding trace entry
 * length to previous page_offset value.
 */
int fnic_trace_buf_init(void)
{}

/*
 * fnic_trace_free - Free memory of fnic trace data structures.
 */
void fnic_trace_free(void)
{}

/*
 * fnic_fc_ctlr_trace_buf_init -
 * Initialize trace buffer to log fnic control frames
 * Description:
 * Initialize trace buffer data structure by allocating
 * required memory for trace data as well as for Indexes.
 * Frame size is 256 bytes and
 * memory is allocated for 1024 entries of 256 bytes.
 * Page_offset(Index) is set to the address of trace entry
 * and page_offset is initialized by adding frame size
 * to the previous page_offset entry.
 */

int fnic_fc_trace_init(void)
{}

/*
 * Fnic_fc_ctlr_trace_free - Free memory of fnic_fc_ctlr trace data structures.
 */
void fnic_fc_trace_free(void)
{}

/*
 * fnic_fc_ctlr_set_trace_data:
 *       Maintain rd & wr idx accordingly and set data
 * Passed parameters:
 *       host_no: host number associated with fnic
 *       frame_type: send_frame, rece_frame or link event
 *       fc_frame: pointer to fc_frame
 *       frame_len: Length of the fc_frame
 * Description:
 *   This routine will get next available wr_idx and
 *   copy all passed trace data to the buffer pointed by wr_idx
 *   and increment wr_idx. It will also make sure that we dont
 *   overwrite the entry which we are reading and also
 *   wrap around if we reach the maximum entries.
 * Returned Value:
 *   It will return 0 for success or -1 for failure
 */
int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
				char *frame, u32 fc_trc_frame_len)
{}

/*
 * fnic_fc_ctlr_get_trace_data: Copy trace buffer to a memory file
 * Passed parameter:
 *       @fnic_dbgfs_t: pointer to debugfs trace buffer
 *       rdata_flag: 1 => Unformatted file
 *                   0 => formatted file
 * Description:
 *       This routine will copy the trace data to memory file with
 *       proper formatting and also copy to another memory
 *       file without formatting for further processing.
 * Return Value:
 *       Number of bytes that were dumped into fnic_dbgfs_t
 */

int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag)
{}

/*
 * copy_and_format_trace_data: Copy formatted data to char * buffer
 * Passed Parameter:
 *      @fc_trace_hdr_t: pointer to trace data
 *      @fnic_dbgfs_t: pointer to debugfs trace buffer
 *      @orig_len: pointer to len
 *      rdata_flag: 0 => Formatted file, 1 => Unformatted file
 * Description:
 *      This routine will format and copy the passed trace data
 *      for formatted file or unformatted file accordingly.
 */

void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
				fnic_dbgfs_t *fnic_dbgfs_prt, int *orig_len,
				u8 rdata_flag)
{}