Re: [PATCH] crypto: caam/qi2 - Add printing dpseci fq stats using debugfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/10/2019 1:13 PM, Vakul Garg wrote:
> Add support of printing the dpseci frame queue statistics using debugfs.
> 
Please move this into a separate file, that gets compiled only if
CONFIG_DEBUG_FS=y.

Function(s) that are needed outside this file should be called unconditionally
and should have an empty version, in case CONFIG_DEBUG_FS=n.

> Signed-off-by: Vakul Garg <vakul.garg@xxxxxxx>
> ---
>  drivers/crypto/caam/caamalg_qi2.c | 95 +++++++++++++++++++++++++++++++++++++++
>  drivers/crypto/caam/caamalg_qi2.h |  3 ++
>  2 files changed, 98 insertions(+)
> 
> diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
> index 06bf32c32cbd..9414d2149b9a 100644
> --- a/drivers/crypto/caam/caamalg_qi2.c
> +++ b/drivers/crypto/caam/caamalg_qi2.c
> @@ -5009,6 +5009,87 @@ static int __cold dpaa2_dpseci_disable(struct dpaa2_caam_priv *priv)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_DEBUG_FS
> +static int dpseci_dbg_fqs_show(struct seq_file *file, void *offset)
> +{
> +	struct dpaa2_caam_priv *priv = (struct dpaa2_caam_priv *)file->private;
> +	u32 fqid, fcnt, bcnt;
> +	int i, err;
> +
> +	seq_printf(file, "FQ stats for %s:\n", dev_name(priv->dev));
> +	seq_printf(file, "%s%16s%16s\n",
> +		   "Rx-VFQID",
> +		   "Pending frames",
> +		   "Pending bytes");
> +
> +	for (i = 0; i <  priv->num_pairs; i++) {
> +		fqid = priv->rx_queue_attr[i].fqid;
> +		err = dpaa2_io_query_fq_count(NULL, fqid, &fcnt, &bcnt);
> +		if (err)
> +			continue;
> +
> +		seq_printf(file, "%5d%16u%16u\n", fqid, fcnt, bcnt);
> +	}
> +
> +	seq_printf(file, "%s%16s%16s\n",
> +		   "Tx-VFQID",
> +		   "Pending frames",
> +		   "Pending bytes");
> +
> +	for (i = 0; i <  priv->num_pairs; i++) {
> +		fqid = priv->tx_queue_attr[i].fqid;
> +		err = dpaa2_io_query_fq_count(NULL, fqid, &fcnt, &bcnt);
> +		if (err)
> +			continue;
> +
> +		seq_printf(file, "%5d%16u%16u\n", fqid, fcnt, bcnt);
> +	}
> +
> +	return 0;
> +}
> +
> +static int dpseci_dbg_fqs_open(struct inode *inode, struct file *file)
> +{
> +	int err;
> +	struct dpaa2_caam_priv *priv;
> +
> +	priv = (struct dpaa2_caam_priv *)inode->i_private;
> +
> +	err = single_open(file, dpseci_dbg_fqs_show, priv);
> +	if (err < 0)
> +		dev_err(priv->dev, "single_open() failed\n");
> +
> +	return err;
> +}
> +
> +static const struct file_operations dpseci_dbg_fq_ops = {
> +	.open = dpseci_dbg_fqs_open,
> +	.read = seq_read,
> +	.llseek = seq_lseek,
> +	.release = single_release,
> +};
> +
> +static int dpaa2_dpseci_debugfs_init(struct dpaa2_caam_priv *priv)
> +{
> +	struct dentry *res;
> +
> +	res = debugfs_create_dir(dev_name(priv->dev), NULL);
> +	if (IS_ERR_OR_NULL(res))
> +		return PTR_ERR(res);
> +
Error checking not needed.
See previous work done by GregKH to clean up debugfs-related error path.

> +	priv->dfs_root = res;
> +
> +	res = debugfs_create_file("fq_stats", 0444, res, priv,
> +				  &dpseci_dbg_fq_ops);
> +	if (IS_ERR_OR_NULL(res)) {
> +		debugfs_remove_recursive(priv->dfs_root);
> +		return PTR_ERR(res);
> +	}
> +
> +	return 0;
> +}
> +#endif
> +
>  static struct list_head hash_list;
>  
>  static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)
> @@ -5098,6 +5179,14 @@ static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)
>  		goto err_bind;
>  	}
>  
> +#ifdef CONFIG_DEBUG_FS
> +	err = dpaa2_dpseci_debugfs_init(priv);
> +	if (err) {
> +		dev_err(dev, "dpaa2_dpseci_debugfs_init() failed\n");
> +		goto err_debugfs;
> +	}
> +#endif
> +
>  	/* register crypto algorithms the device supports */
>  	for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
>  		struct caam_skcipher_alg *t_alg = driver_algs + i;
> @@ -5242,6 +5331,8 @@ static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)
>  
>  	return err;
>  
> +err_debugfs:
> +	dpaa2_dpseci_disable(priv);
>  err_bind:
>  	dpaa2_dpseci_dpio_free(priv);
>  err_dpio_setup:
> @@ -5265,6 +5356,10 @@ static int __cold dpaa2_caam_remove(struct fsl_mc_device *ls_dev)
>  	dev = &ls_dev->dev;
>  	priv = dev_get_drvdata(dev);
>  
> +#ifdef CONFIG_DEBUG_FS
> +	debugfs_remove_recursive(priv->dfs_root);
> +#endif
> +
Please get rid of the ifdeffery, debugfs_remove_recursive() should be called
unconditionally.

>  	for (i = 0; i < ARRAY_SIZE(driver_aeads); i++) {
>  		struct caam_aead_alg *t_alg = driver_aeads + i;
>  
> diff --git a/drivers/crypto/caam/caamalg_qi2.h b/drivers/crypto/caam/caamalg_qi2.h
> index 0f207b275578..74644d92f9d7 100644
> --- a/drivers/crypto/caam/caamalg_qi2.h
> +++ b/drivers/crypto/caam/caamalg_qi2.h
> @@ -64,6 +64,9 @@ struct dpaa2_caam_priv {
>  	struct iommu_domain *domain;
>  
>  	struct dpaa2_caam_priv_per_cpu __percpu *ppriv;
> +#ifdef CONFIG_DEBUG_FS
> +	struct dentry *dfs_root;
> +#endif
>  };
>  
>  /**
> 





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux