diff mbox series

[v4,16/16] crypto/nx: Add sysfs interface to export NX capabilities

Message ID 35bca44c5a8af7bdffbe03b22fd82713bced8d0e.camel@linux.ibm.com (mailing list archive)
State Superseded
Headers show
Series Enable VAS and NX-GZIP support on powerVM | expand
Related show

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (258eb1f3aaa9face35e613c229c1337263491ea0)
snowpatch_ozlabs/build-ppc64le warning Build succeeded but added 40 new sparse warnings
snowpatch_ozlabs/build-ppc64be warning Build succeeded but added 40 new sparse warnings
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch warning total: 0 errors, 1 warnings, 2 checks, 61 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Haren Myneni May 21, 2021, 9:42 a.m. UTC
Changes to export the following NXGZIP capabilities through sysfs:

/sys/devices/vio/ibm,compression-v1/NxGzCaps:
min_compress_len  /*Recommended minimum compress length in bytes*/
min_decompress_len /*Recommended minimum decompress length in bytes*/
req_max_processed_len /* Maximum number of bytes processed in one
			request */

NX will return RMA_Reject if the request buffer size is greater
than req_max_processed_len.

Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 drivers/crypto/nx/nx-common-pseries.c | 43 +++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

Comments

Nicholas Piggin June 3, 2021, 4:57 a.m. UTC | #1
Excerpts from Haren Myneni's message of May 21, 2021 7:42 pm:
> 
> Changes to export the following NXGZIP capabilities through sysfs:
> 
> /sys/devices/vio/ibm,compression-v1/NxGzCaps:

Where's the horrible camel case name coming from? PowerVM?

Thanks,
Nick

> min_compress_len  /*Recommended minimum compress length in bytes*/
> min_decompress_len /*Recommended minimum decompress length in bytes*/
> req_max_processed_len /* Maximum number of bytes processed in one
> 			request */
> 
> NX will return RMA_Reject if the request buffer size is greater
> than req_max_processed_len.
> 
> Signed-off-by: Haren Myneni <haren@linux.ibm.com>
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
> ---
>  drivers/crypto/nx/nx-common-pseries.c | 43 +++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
> index 4a7278464156..121718a337fd 100644
> --- a/drivers/crypto/nx/nx-common-pseries.c
> +++ b/drivers/crypto/nx/nx-common-pseries.c
> @@ -968,6 +968,36 @@ static struct attribute_group nx842_attribute_group = {
>  	.attrs = nx842_sysfs_entries,
>  };
>  
> +#define	nxct_caps_read(_name)						\
> +static ssize_t nxct_##_name##_show(struct device *dev,			\
> +			struct device_attribute *attr, char *buf)	\
> +{									\
> +	return sprintf(buf, "%lld\n", nx_ct_caps._name);		\
> +}
> +
> +#define NXCT_ATTR_RO(_name)						\
> +	nxct_caps_read(_name);						\
> +	static struct device_attribute dev_attr_##_name = __ATTR(_name,	\
> +						0444,			\
> +						nxct_##_name##_show,	\
> +						NULL);
> +
> +NXCT_ATTR_RO(req_max_processed_len);
> +NXCT_ATTR_RO(min_compress_len);
> +NXCT_ATTR_RO(min_decompress_len);
> +
> +static struct attribute *nxct_caps_sysfs_entries[] = {
> +	&dev_attr_req_max_processed_len.attr,
> +	&dev_attr_min_compress_len.attr,
> +	&dev_attr_min_decompress_len.attr,
> +	NULL,
> +};
> +
> +static struct attribute_group nxct_caps_attr_group = {
> +	.name	=	nx_ct_caps.name,
> +	.attrs	=	nxct_caps_sysfs_entries,
> +};
> +
>  static struct nx842_driver nx842_pseries_driver = {
>  	.name =		KBUILD_MODNAME,
>  	.owner =	THIS_MODULE,
> @@ -1057,6 +1087,16 @@ static int nx842_probe(struct vio_dev *viodev,
>  		goto error;
>  	}
>  
> +	if (caps_feat) {
> +		if (sysfs_create_group(&viodev->dev.kobj,
> +					&nxct_caps_attr_group)) {
> +			dev_err(&viodev->dev,
> +				"Could not create sysfs NX capability entries\n");
> +			ret = -1;
> +			goto error;
> +		}
> +	}
> +
>  	return 0;
>  
>  error_unlock:
> @@ -1076,6 +1116,9 @@ static void nx842_remove(struct vio_dev *viodev)
>  	pr_info("Removing IBM Power 842 compression device\n");
>  	sysfs_remove_group(&viodev->dev.kobj, &nx842_attribute_group);
>  
> +	if (caps_feat)
> +		sysfs_remove_group(&viodev->dev.kobj, &nxct_caps_attr_group);
> +
>  	crypto_unregister_alg(&nx842_pseries_alg);
>  
>  	spin_lock_irqsave(&devdata_mutex, flags);
> -- 
> 2.18.2
> 
> 
>
Haren Myneni June 4, 2021, 1:02 a.m. UTC | #2
On Thu, 2021-06-03 at 14:57 +1000, Nicholas Piggin wrote:
> Excerpts from Haren Myneni's message of May 21, 2021 7:42 pm:
> > Changes to export the following NXGZIP capabilities through sysfs:
> > 
> > /sys/devices/vio/ibm,compression-v1/NxGzCaps:
> 
> Where's the horrible camel case name coming from? PowerVM?

Yes, pHyp provides the capabalities string.

Capability Description Descriptor Value Descriptor ascii Value
Overall NX Capabilities 0x4E78204361707320 “Nx Caps ”
NX GZIP Capabilities 0x4E78477A43617073 “NxGzCaps”


> 
> Thanks,
> Nick
> 
> > min_compress_len  /*Recommended minimum compress length in bytes*/
> > min_decompress_len /*Recommended minimum decompress length in
> > bytes*/
> > req_max_processed_len /* Maximum number of bytes processed in one
> > 			request */
> > 
> > NX will return RMA_Reject if the request buffer size is greater
> > than req_max_processed_len.
> > 
> > Signed-off-by: Haren Myneni <haren@linux.ibm.com>
> > Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
> > ---
> >  drivers/crypto/nx/nx-common-pseries.c | 43
> > +++++++++++++++++++++++++++
> >  1 file changed, 43 insertions(+)
> > 
> > diff --git a/drivers/crypto/nx/nx-common-pseries.c
> > b/drivers/crypto/nx/nx-common-pseries.c
> > index 4a7278464156..121718a337fd 100644
> > --- a/drivers/crypto/nx/nx-common-pseries.c
> > +++ b/drivers/crypto/nx/nx-common-pseries.c
> > @@ -968,6 +968,36 @@ static struct attribute_group
> > nx842_attribute_group = {
> >  	.attrs = nx842_sysfs_entries,
> >  };
> >  
> > +#define	nxct_caps_read(_name)					
> > 	\
> > +static ssize_t nxct_##_name##_show(struct device *dev,		
> > 	\
> > +			struct device_attribute *attr, char *buf)	\
> > +{									
> > \
> > +	return sprintf(buf, "%lld\n", nx_ct_caps._name);		\
> > +}
> > +
> > +#define NXCT_ATTR_RO(_name)					
> > 	\
> > +	nxct_caps_read(_name);						
> > \
> > +	static struct device_attribute dev_attr_##_name = __ATTR(_name,
> > 	\
> > +						0444,			
> > \
> > +						nxct_##_name##_show,	
> > \
> > +						NULL);
> > +
> > +NXCT_ATTR_RO(req_max_processed_len);
> > +NXCT_ATTR_RO(min_compress_len);
> > +NXCT_ATTR_RO(min_decompress_len);
> > +
> > +static struct attribute *nxct_caps_sysfs_entries[] = {
> > +	&dev_attr_req_max_processed_len.attr,
> > +	&dev_attr_min_compress_len.attr,
> > +	&dev_attr_min_decompress_len.attr,
> > +	NULL,
> > +};
> > +
> > +static struct attribute_group nxct_caps_attr_group = {
> > +	.name	=	nx_ct_caps.name,
> > +	.attrs	=	nxct_caps_sysfs_entries,
> > +};
> > +
> >  static struct nx842_driver nx842_pseries_driver = {
> >  	.name =		KBUILD_MODNAME,
> >  	.owner =	THIS_MODULE,
> > @@ -1057,6 +1087,16 @@ static int nx842_probe(struct vio_dev
> > *viodev,
> >  		goto error;
> >  	}
> >  
> > +	if (caps_feat) {
> > +		if (sysfs_create_group(&viodev->dev.kobj,
> > +					&nxct_caps_attr_group)) {
> > +			dev_err(&viodev->dev,
> > +				"Could not create sysfs NX capability
> > entries\n");
> > +			ret = -1;
> > +			goto error;
> > +		}
> > +	}
> > +
> >  	return 0;
> >  
> >  error_unlock:
> > @@ -1076,6 +1116,9 @@ static void nx842_remove(struct vio_dev
> > *viodev)
> >  	pr_info("Removing IBM Power 842 compression device\n");
> >  	sysfs_remove_group(&viodev->dev.kobj, &nx842_attribute_group);
> >  
> > +	if (caps_feat)
> > +		sysfs_remove_group(&viodev->dev.kobj,
> > &nxct_caps_attr_group);
> > +
> >  	crypto_unregister_alg(&nx842_pseries_alg);
> >  
> >  	spin_lock_irqsave(&devdata_mutex, flags);
> > -- 
> > 2.18.2
> > 
> > 
> >
Michael Ellerman June 4, 2021, 11:52 a.m. UTC | #3
Haren Myneni <haren@linux.ibm.com> writes:
> On Thu, 2021-06-03 at 14:57 +1000, Nicholas Piggin wrote:
>> Excerpts from Haren Myneni's message of May 21, 2021 7:42 pm:
>> > Changes to export the following NXGZIP capabilities through sysfs:
>> > 
>> > /sys/devices/vio/ibm,compression-v1/NxGzCaps:
>> 
>> Where's the horrible camel case name coming from? PowerVM?
>
> Yes, pHyp provides the capabalities string.
>
> Capability Description Descriptor Value Descriptor ascii Value
> Overall NX Capabilities 0x4E78204361707320 “Nx Caps ”
> NX GZIP Capabilities 0x4E78477A43617073 “NxGzCaps”

That doesn't mean we have to use that name in sysfs though. In fact we
couldn't use the "Nx Caps " name, because it contains spaces.

And we don't have to squeeze our name into 8 bytes, so it can be less
ugly.

Like "nx_gzip_capabilities"?

cheers
Haren Myneni June 4, 2021, 5:23 p.m. UTC | #4
On Fri, 2021-06-04 at 21:52 +1000, Michael Ellerman wrote:
> Haren Myneni <haren@linux.ibm.com> writes:
> > On Thu, 2021-06-03 at 14:57 +1000, Nicholas Piggin wrote:
> > > Excerpts from Haren Myneni's message of May 21, 2021 7:42 pm:
> > > > Changes to export the following NXGZIP capabilities through
> > > > sysfs:
> > > > 
> > > > /sys/devices/vio/ibm,compression-v1/NxGzCaps:
> > > 
> > > Where's the horrible camel case name coming from? PowerVM?
> > 
> > Yes, pHyp provides the capabalities string.
> > 
> > Capability Description Descriptor Value Descriptor ascii Value
> > Overall NX Capabilities 0x4E78204361707320 “Nx Caps ”
> > NX GZIP Capabilities 0x4E78477A43617073 “NxGzCaps”
> 
> That doesn't mean we have to use that name in sysfs though. In fact
> we
> couldn't use the "Nx Caps " name, because it contains spaces.
> 
> And we don't have to squeeze our name into 8 bytes, so it can be less
> ugly.
> 
> Like "nx_gzip_capabilities"?

Thanks for your comments. 

'NX Caps " provides the all available features in the hypervisor (only
NX GZIP caps is supported right now) and we export information for the
specific feature via sysfs.

I will change it to "nx_gzip_caps" 

Thanks
Haren

> 
> cheers
diff mbox series

Patch

diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
index 4a7278464156..121718a337fd 100644
--- a/drivers/crypto/nx/nx-common-pseries.c
+++ b/drivers/crypto/nx/nx-common-pseries.c
@@ -968,6 +968,36 @@  static struct attribute_group nx842_attribute_group = {
 	.attrs = nx842_sysfs_entries,
 };
 
+#define	nxct_caps_read(_name)						\
+static ssize_t nxct_##_name##_show(struct device *dev,			\
+			struct device_attribute *attr, char *buf)	\
+{									\
+	return sprintf(buf, "%lld\n", nx_ct_caps._name);		\
+}
+
+#define NXCT_ATTR_RO(_name)						\
+	nxct_caps_read(_name);						\
+	static struct device_attribute dev_attr_##_name = __ATTR(_name,	\
+						0444,			\
+						nxct_##_name##_show,	\
+						NULL);
+
+NXCT_ATTR_RO(req_max_processed_len);
+NXCT_ATTR_RO(min_compress_len);
+NXCT_ATTR_RO(min_decompress_len);
+
+static struct attribute *nxct_caps_sysfs_entries[] = {
+	&dev_attr_req_max_processed_len.attr,
+	&dev_attr_min_compress_len.attr,
+	&dev_attr_min_decompress_len.attr,
+	NULL,
+};
+
+static struct attribute_group nxct_caps_attr_group = {
+	.name	=	nx_ct_caps.name,
+	.attrs	=	nxct_caps_sysfs_entries,
+};
+
 static struct nx842_driver nx842_pseries_driver = {
 	.name =		KBUILD_MODNAME,
 	.owner =	THIS_MODULE,
@@ -1057,6 +1087,16 @@  static int nx842_probe(struct vio_dev *viodev,
 		goto error;
 	}
 
+	if (caps_feat) {
+		if (sysfs_create_group(&viodev->dev.kobj,
+					&nxct_caps_attr_group)) {
+			dev_err(&viodev->dev,
+				"Could not create sysfs NX capability entries\n");
+			ret = -1;
+			goto error;
+		}
+	}
+
 	return 0;
 
 error_unlock:
@@ -1076,6 +1116,9 @@  static void nx842_remove(struct vio_dev *viodev)
 	pr_info("Removing IBM Power 842 compression device\n");
 	sysfs_remove_group(&viodev->dev.kobj, &nx842_attribute_group);
 
+	if (caps_feat)
+		sysfs_remove_group(&viodev->dev.kobj, &nxct_caps_attr_group);
+
 	crypto_unregister_alg(&nx842_pseries_alg);
 
 	spin_lock_irqsave(&devdata_mutex, flags);