diff mbox series

[kvm-unit-tests,2/7] s390x: css: add callback for emnumeration

Message ID 1630059440-15586-3-git-send-email-pmorel@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Extending VIRTIO with a data transfer test | expand

Commit Message

Pierre Morel Aug. 27, 2021, 10:17 a.m. UTC
We will need to look for a device inside the channel subsystem
based upon device specificities.

Let's provide a callback for an upper layer to be called during
the enumeration of the channel subsystem.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     | 3 ++-
 lib/s390x/css_lib.c | 4 +++-
 s390x/css.c         | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

Comments

Thomas Huth Nov. 3, 2021, 7:29 a.m. UTC | #1
On 27/08/2021 12.17, Pierre Morel wrote:
> We will need to look for a device inside the channel subsystem
> based upon device specificities.
> 
> Let's provide a callback for an upper layer to be called during
> the enumeration of the channel subsystem.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>   lib/s390x/css.h     | 3 ++-
>   lib/s390x/css_lib.c | 4 +++-
>   s390x/css.c         | 2 +-
>   3 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/s390x/css.h b/lib/s390x/css.h
> index d644971f..2005f4d7 100644
> --- a/lib/s390x/css.h
> +++ b/lib/s390x/css.h
> @@ -278,7 +278,8 @@ void dump_irb(struct irb *irbp);
>   void dump_pmcw(struct pmcw *p);
>   void dump_orb(struct orb *op);
>   
> -int css_enumerate(void);
> +typedef int (enumerate_cb_t)(int);
> +int css_enumerate(enumerate_cb_t *f);
>   #define MAX_ENABLE_RETRIES      5
>   
>   #define IO_SCH_ISC      3
> diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
> index efc70576..484f9c41 100644
> --- a/lib/s390x/css_lib.c
> +++ b/lib/s390x/css_lib.c
> @@ -117,7 +117,7 @@ bool get_chsc_scsc(void)
>    * On success return the first subchannel ID found.
>    * On error return an invalid subchannel ID containing cc
>    */
> -int css_enumerate(void)
> +int css_enumerate(enumerate_cb_t *f)

I'd maybe call it "cb" instead of "f" ... but that's just my personal taste, 
I guess.

>   {
>   	struct pmcw *pmcw = &schib.pmcw;
>   	int scn_found = 0;
> @@ -153,6 +153,8 @@ int css_enumerate(void)
>   			schid = scn | SCHID_ONE;
>   		report_info("Found subchannel %08x", scn | SCHID_ONE);
>   		dev_found++;
> +		if (f)
> +			f(scn | SCHID_ONE);
>   	}
>   
>   out:
> diff --git a/s390x/css.c b/s390x/css.c
> index c340c539..b50fbc67 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -29,7 +29,7 @@ struct ccw1 *ccw;
>   
>   static void test_enumerate(void)
>   {
> -	test_device_sid = css_enumerate();
> +	test_device_sid = css_enumerate(NULL);
>   	if (test_device_sid & SCHID_ONE) {
>   		report(1, "Schid of first I/O device: 0x%08x", test_device_sid);
>   		return;
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Pierre Morel Nov. 8, 2021, 12:21 p.m. UTC | #2
On 11/3/21 08:29, Thomas Huth wrote:
> On 27/08/2021 12.17, Pierre Morel wrote:
>> We will need to look for a device inside the channel subsystem
>> based upon device specificities.
>>
>> Let's provide a callback for an upper layer to be called during
>> the enumeration of the channel subsystem.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   lib/s390x/css.h     | 3 ++-
>>   lib/s390x/css_lib.c | 4 +++-
>>   s390x/css.c         | 2 +-
>>   3 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/s390x/css.h b/lib/s390x/css.h
>> index d644971f..2005f4d7 100644
>> --- a/lib/s390x/css.h
>> +++ b/lib/s390x/css.h
>> @@ -278,7 +278,8 @@ void dump_irb(struct irb *irbp);
>>   void dump_pmcw(struct pmcw *p);
>>   void dump_orb(struct orb *op);
>> -int css_enumerate(void);
>> +typedef int (enumerate_cb_t)(int);
>> +int css_enumerate(enumerate_cb_t *f);
>>   #define MAX_ENABLE_RETRIES      5
>>   #define IO_SCH_ISC      3
>> diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
>> index efc70576..484f9c41 100644
>> --- a/lib/s390x/css_lib.c
>> +++ b/lib/s390x/css_lib.c
>> @@ -117,7 +117,7 @@ bool get_chsc_scsc(void)
>>    * On success return the first subchannel ID found.
>>    * On error return an invalid subchannel ID containing cc
>>    */
>> -int css_enumerate(void)
>> +int css_enumerate(enumerate_cb_t *f)
> 
> I'd maybe call it "cb" instead of "f" ... but that's just my personal 
> taste, I guess.

I can use cb, looks better.

> 
>>   {
>>       struct pmcw *pmcw = &schib.pmcw;
>>       int scn_found = 0;
>> @@ -153,6 +153,8 @@ int css_enumerate(void)
>>               schid = scn | SCHID_ONE;
>>           report_info("Found subchannel %08x", scn | SCHID_ONE);
>>           dev_found++;
>> +        if (f)
>> +            f(scn | SCHID_ONE);
>>       }
>>   out:
>> diff --git a/s390x/css.c b/s390x/css.c
>> index c340c539..b50fbc67 100644
>> --- a/s390x/css.c
>> +++ b/s390x/css.c
>> @@ -29,7 +29,7 @@ struct ccw1 *ccw;
>>   static void test_enumerate(void)
>>   {
>> -    test_device_sid = css_enumerate();
>> +    test_device_sid = css_enumerate(NULL);
>>       if (test_device_sid & SCHID_ONE) {
>>           report(1, "Schid of first I/O device: 0x%08x", 
>> test_device_sid);
>>           return;
>>
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 

Thanks,
Pierre
diff mbox series

Patch

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index d644971f..2005f4d7 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -278,7 +278,8 @@  void dump_irb(struct irb *irbp);
 void dump_pmcw(struct pmcw *p);
 void dump_orb(struct orb *op);
 
-int css_enumerate(void);
+typedef int (enumerate_cb_t)(int);
+int css_enumerate(enumerate_cb_t *f);
 #define MAX_ENABLE_RETRIES      5
 
 #define IO_SCH_ISC      3
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index efc70576..484f9c41 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -117,7 +117,7 @@  bool get_chsc_scsc(void)
  * On success return the first subchannel ID found.
  * On error return an invalid subchannel ID containing cc
  */
-int css_enumerate(void)
+int css_enumerate(enumerate_cb_t *f)
 {
 	struct pmcw *pmcw = &schib.pmcw;
 	int scn_found = 0;
@@ -153,6 +153,8 @@  int css_enumerate(void)
 			schid = scn | SCHID_ONE;
 		report_info("Found subchannel %08x", scn | SCHID_ONE);
 		dev_found++;
+		if (f)
+			f(scn | SCHID_ONE);
 	}
 
 out:
diff --git a/s390x/css.c b/s390x/css.c
index c340c539..b50fbc67 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -29,7 +29,7 @@  struct ccw1 *ccw;
 
 static void test_enumerate(void)
 {
-	test_device_sid = css_enumerate();
+	test_device_sid = css_enumerate(NULL);
 	if (test_device_sid & SCHID_ONE) {
 		report(1, "Schid of first I/O device: 0x%08x", test_device_sid);
 		return;