// SPDX-License-Identifier: GPL-2.0-only // Copyright 2014 Cisco Systems, Inc. All rights reserved. #include <linux/module.h> #include <linux/errno.h> #include <linux/debugfs.h> #include "snic.h" /* * snic_debugfs_init - Initialize debugfs for snic debug logging * * Description: * When Debugfs is configured this routine sets up fnic debugfs * filesystem. If not already created. this routine will crate the * fnic directory and statistics directory for trace buffer and * stats logging */ void snic_debugfs_init(void) { … } /* * snic_debugfs_term - Tear down debugfs intrastructure * * Description: * When Debufs is configured this routine removes debugfs file system * elements that are specific to snic */ void snic_debugfs_term(void) { … } /* * snic_reset_stats_open - Open the reset_stats file */ static int snic_reset_stats_open(struct inode *inode, struct file *filp) { … } /* * snic_reset_stats_read - Read a reset_stats debugfs file * @filp: The file pointer to read from. * @ubuf: The buffer tocopy the data to. * @cnt: The number of bytes to read. * @ppos: The position in the file to start reading frm. * * Description: * This routine reads value of variable reset_stats * and stores into local @buf. It will start reading file @ppos and * copy up to @cnt of data to @ubuf from @buf. * * Returns: * This function returns the amount of data that was read. */ static ssize_t snic_reset_stats_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) { … } /* * snic_reset_stats_write - Write to reset_stats debugfs file * @filp: The file pointer to write from * @ubuf: The buffer to copy the data from. * @cnt: The number of bytes to write. * @ppos: The position in the file to start writing to. * * Description: * This routine writes data from user buffer @ubuf to buffer @buf and * resets cumulative stats of snic. * * Returns: * This function returns the amount of data that was written. */ static ssize_t snic_reset_stats_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { … } static int snic_reset_stats_release(struct inode *inode, struct file *filp) { … } /* * snic_stats_show - Formats and prints per host specific driver stats. */ static int snic_stats_show(struct seq_file *sfp, void *data) { … } DEFINE_SHOW_ATTRIBUTE(…); static const struct file_operations snic_reset_stats_fops = …; /* * snic_stats_init - Initialize stats struct and create stats file * per snic * * Description: * When debugfs is cofigured this routine sets up the stats file per snic * It will create file stats and reset_stats under statistics/host# directory * to log per snic stats */ void snic_stats_debugfs_init(struct snic *snic) { … } /* * snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats * * Description: * When Debufs is configured this routine removes debugfs file system * elements that are specific to to snic stats */ void snic_stats_debugfs_remove(struct snic *snic) { … } /* Trace Facility related API */ static void * snic_trc_seq_start(struct seq_file *sfp, loff_t *pos) { … } static void * snic_trc_seq_next(struct seq_file *sfp, void *data, loff_t *pos) { … } static void snic_trc_seq_stop(struct seq_file *sfp, void *data) { … } #define SNIC_TRC_PBLEN … static int snic_trc_seq_show(struct seq_file *sfp, void *data) { … } static const struct seq_operations snic_trc_sops = …; DEFINE_SEQ_ATTRIBUTE(…); #define TRC_ENABLE_FILE … #define TRC_FILE … /* * snic_trc_debugfs_init : creates trace/tracing_enable files for trace * under debugfs */ void snic_trc_debugfs_init(void) { … } /* * snic_trc_debugfs_term : cleans up the files created for trace under debugfs */ void snic_trc_debugfs_term(void) { … }