Skip to contentSkip to conversation

vDPA/ifcvf: assign nr_vring to the MSI vector of config_intr by default

PATCH In review Zhu Lingshan 2 participants 4 messages Apr 8, 2022 – Apr 15, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vDPA/ifcvf: assign nr_vring to the MSI vector of config_intr by default

This commit assign struct ifcvf_hw.nr_vring to the MSIX vector of the config interrupt by default in ifcvf_request_config_irq(). ifcvf_hw.nr_vring is the most likely and the ideal case for the device config interrupt handling, means every virtqueue has an individual MSIX vector(0 ~ nr_vring - 1), and the config interrupt has its own MSIX vector(number nr_vring).

This change can also make GCC W = 2 happy, silence the "uninitialized" warning.

---
 drivers/vdpa/ifcvf/ifcvf_main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +4 -4
index 4366320fb68d..b500fb941dab 100644
@@ -290,13 +290,13 @@ static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter)
 	struct ifcvf_hw *vf = &adapter->vf;
 	int config_vector, ret;
 
+	/* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */
+	config_vector = vf->nr_vring;
+
+	/* re-use the vqs vector */
 	if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
 		return 0;
 
-	if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
-		/* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */
-		config_vector = vf->nr_vring;
-
 	if (vf->msix_vector_status ==  MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
 		/* vector 0 for vqs and 1 for config interrupt */
 		config_vector = 1;
Signature · 1 line
2.31.1
#1 lore raw
Quoted 21 lines · Zhu Lingshan

This commit assign struct ifcvf_hw.nr_vring to the MSIX vector of the config interrupt by default in ifcvf_request_config_irq(). ifcvf_hw.nr_vring is the most likely and the ideal case for the device config interrupt handling, means every virtqueue has an individual MSIX vector(0 ~ nr_vring - 1), and the config interrupt has its own MSIX vector(number nr_vring).

This change can also make GCC W = 2 happy, silence the "uninitialized" warning.

---
  drivers/vdpa/ifcvf/ifcvf_main.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +0 -0
index 4366320fb68d..b500fb941dab 100644

drivers/vdpa/ifcvf/ifcvf_main.c static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter) · line 293

Quoted 4 lines
drivers/vdpa/ifcvf/ifcvf_main.c +1 -0
@@ -290,13 +290,13 @@ static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter)
  	struct ifcvf_hw *vf = &adapter->vf;
  	int config_vector, ret;
 
+	/* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */

The comment is right before this patch, but probably wrong for MSIX_VECTOR_DEV_SHARED.

drivers/vdpa/ifcvf/ifcvf_main.c static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter) · line 302

Quoted 13 lines
drivers/vdpa/ifcvf/ifcvf_main.c +3 -4
+	config_vector = vf->nr_vring;
+
+	/* re-use the vqs vector */
  	if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
  		return 0;
 
-	if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
-		/* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */
-		config_vector = vf->nr_vring;
-
  	if (vf->msix_vector_status ==  MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
  		/* vector 0 for vqs and 1 for config interrupt */
  		config_vector = 1;

Actually, I prefer to use if ... else ... here.

Thanks

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#2 lore raw
Quoted 18 lines · Jason Wang
Quoted 16 lines · Zhu Lingshan

This commit assign struct ifcvf_hw.nr_vring to the MSIX vector of the config interrupt by default in ifcvf_request_config_irq(). ifcvf_hw.nr_vring is the most likely and the ideal case for the device config interrupt handling, means every virtqueue has an individual MSIX vector(0 ~ nr_vring - 1), and the config interrupt has its own MSIX vector(number nr_vring).

This change can also make GCC W = 2 happy, silence the "uninitialized" warning.

---
  drivers/vdpa/ifcvf/ifcvf_main.c | 8 ++++----

  1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 12 lines
Quoted 9 lines
drivers/vdpa/ifcvf/ifcvf_main.c +0 -0
index 4366320fb68d..b500fb941dab 100644
@@ -290,13 +290,13 @@ static int ifcvf_request_config_irq(struct 
 ifcvf_adapter *adapter)
       struct ifcvf_hw *vf = &adapter->vf;
       int config_vector, ret;

  +    /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */

The comment is right before this patch, but probably wrong for MSIX_VECTOR_DEV_SHARED.

This comment is for the case when every vq and config interrupt has its own vector, how
about a better comment "The ideal the default case, vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt"

Quoted 18 lines
Quoted 15 lines

+    config_vector = vf->nr_vring;
+
+    /* re-use the vqs vector */
      if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED) return 0;
  -    if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG) -        /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */
-        config_vector = vf->nr_vring;
-
      if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG) /* vector 0 for vqs and 1 for config interrupt */ config_vector = 1;

Actually, I prefer to use if ... else ... here.

IMHO, if else may lead to mistakes.

The code:
        /* The ideal the default case, vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt */ config_vector = vf->nr_vring;

        /* re-use the vqs vector */
        if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED) return 0;

        if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG) /* vector 0 for vqs and 1 for config interrupt */ config_vector = 1;

here by default config_vector = vf->nr_vring;
If msix_vector_status == MSIX_VECTOR_DEV_SHARED, it will reuse the dev shared vector, means using the vector(value 0) for data-vqs. If msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG, it will use vector=1(vector 0 for data-vqs).

If we use if...else, it will be:

        /* re-use the vqs vector */
        if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED) return 0;
        else
                config_vector = 1;

This looks like config_vector can only be 0(re-used vector for the data-vqs, which is 0) or 1. It shadows the ideal and default case config_vector = vf->nr_vring

Thanks,
Zhu Lingshan

Quoted 4 lines

Thanks

#3 lore raw
Quoted 38 lines · Lingshan
Quoted 19 lines · Jason Wang
Quoted 17 lines · Zhu Lingshan

This commit assign struct ifcvf_hw.nr_vring to the MSIX vector of the config interrupt by default in ifcvf_request_config_irq(). ifcvf_hw.nr_vring is the most likely and the ideal case for the device config interrupt handling, means every virtqueue has an individual MSIX vector(0 ~ nr_vring - 1), and the config interrupt has
its own MSIX vector(number nr_vring).

This change can also make GCC W = 2 happy, silence the "uninitialized" warning.

---
  drivers/vdpa/ifcvf/ifcvf_main.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 15 lines
Quoted 11 lines
drivers/vdpa/ifcvf/ifcvf_main.c +0 -0
index 4366320fb68d..b500fb941dab 100644
@@ -290,13 +290,13 @@ static int ifcvf_request_config_irq(struct
 ifcvf_adapter *adapter)
      struct ifcvf_hw *vf = &adapter->vf;
      int config_vector, ret;
  +    /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector

for config interrupt */

The comment is right before this patch, but probably wrong for MSIX_VECTOR_DEV_SHARED.

Quoted 4 lines

This comment is for the case when every vq and config interrupt has its own vector, how
about a better comment "The ideal the default case, vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector for config interrupt"

Actually, I suggest to remove the comment since the code can explain itself.

Quoted 48 lines
Quoted 18 lines
Quoted 10 lines
drivers/vdpa/ifcvf/ifcvf_main.c +3 -1
+    config_vector = vf->nr_vring;
+
+    /* re-use the vqs vector */
      if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
          return 0;
  -    if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
-        /* vector 0 ~ vf->nr_vring for vqs, num vf->nr_vring vector

for config interrupt */

drivers/vdpa/ifcvf/ifcvf_main.c static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter) · line 302

Quoted 5 lines
drivers/vdpa/ifcvf/ifcvf_main.c +0 -2
-        config_vector = vf->nr_vring;
-
      if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
          /* vector 0 for vqs and 1 for config interrupt */
          config_vector = 1;

Actually, I prefer to use if ... else ... here.

IMHO, if else may lead to mistakes.

The code:

         /* The ideal the default case, vector 0 ~ vf->nr_vring for vqs,
num vf->nr_vring vector for config interrupt */
         config_vector = vf->nr_vring;

         /* re-use the vqs vector */
         if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
                 return 0;

         if (vf->msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG)
                 /* vector 0 for vqs and 1 for config interrupt */
                 config_vector = 1;

here by default config_vector = vf->nr_vring;
If msix_vector_status == MSIX_VECTOR_DEV_SHARED, it will reuse the dev shared vector, means using the vector(value 0) for data-vqs. If msix_vector_status == MSIX_VECTOR_SHARED_VQ_AND_CONFIG, it will use vector=1(vector 0 for data-vqs).

If we use if...else, it will be:

         /* re-use the vqs vector */
         if (vf->msix_vector_status == MSIX_VECTOR_DEV_SHARED)
                 return 0;
         else
                 config_vector = 1;
Quoted 3 lines

This looks like config_vector can only be 0(re-used vector for the data-vqs, which is 0) or 1. It shadows the ideal and default case config_vector = vf->nr_vring

I meant something like

if (DEV_SHARED)

    return 0;
else if  (SHARED_VQ_AND_CONFIG)
    config_vector = 1
else if (PER_VQ_AND_CONFIG)
    config_vector = vf->nr_vring
else
    return -EINVAL;

or using a switch here.

(We get the warning because there's no way for the checker to know that msix_vector_status must be DEV_SHARED, SHARED_VQ_AND_CONFIG and PER_VQ_AND_CONFIG).

Thanks

Quoted 9 lines

Thanks,
Zhu Lingshan

Quoted 4 lines

Thanks

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization