net/i40e: remove redundant code in free queues.
PATCH 1/1 net/i40e: remove redundant code in free queues.
Before this patch, there are two functions that will clear RX/TX queues
number: rte_eth_dev_close() and i40e_dev_free_queues().
This patch remove redundant code in i40e_dev_free_queues().
--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -2
@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])
@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC
Signature · 1 line
2.17.1
Quoted 10 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Monday, December 10, 2018 9:32 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>
Cc: Yan, Zhirun <[email protected]>
Subject: [PATCH v1] net/i40e: remove redundant code in free queues.
Quoted 2 lines
Before this patch, there are two functions that will clear RX/TX queues
number:rte_eth_dev_close()andi40e_dev_free_queues().
I agree with what the patch changed, but the commit log is not comprehensive.I40e_dev_free_queues is not only in the path of rte_eth_dev_close but also rte_eth_dev_reset.
So
For rte_eth_dev_close, its redundant because of duplication.
For rte_eth_dev_reset its redundant because of not necessary, since following dev_configure is required after dev_reset and it will be updated correctly.
Quoted 31 lines
This patch remove redundant code in
i40e_dev_free_queues().Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)drivers/net/i40e/i40e_rxtx.c index renamed from drivers/net/i40e/i40e_rxtx.c +0
-0
e1152ff0e..cc953ad58100644drivers/net/i40e/i40e_rxtx.c +0
-3@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC --2.17.1
Quoted 21 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 20:36
To: Yan, Zhirun <[email protected]>; [email protected]; Wang, Haiyue <[email protected]>
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 11 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Monday, December 10, 2018 9:32 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>
Cc: Yan, Zhirun <[email protected]>
Subject: [PATCH v1] net/i40e: remove redundant code in free queues.Before this patch, there are two functions that will clear RX/TX queues
number:rte_eth_dev_close()andi40e_dev_free_queues().
Quoted 8 lines
I agree with what the patch changed, but the commit log is not comprehensive.
I40e_dev_free_queuesis not only in the path ofrte_eth_dev_closebut alsorte_eth_dev_reset.
So
Forrte_eth_dev_close, its redundant because of duplication.
Forrte_eth_dev_resetits redundant because of not necessary, since followingdev_configureis required afterdev_resetand it will be updated correctly.
How about this commit message ?
net/i40e: queue management data set is out of the API scope.
Function i40e_dev_free_queues is used to free specific i40e queue entries, but should not be used to set the upper level queue management data in 'struct rte_eth_dev_data', such as ' nb_rx/tx_queues ', which are maintained by 'rte_eth_dev_rx/tx_queue_config'.
Quoted 32 lines
Quoted 32 lines
This patch remove redundant code in
i40e_dev_free_queues().Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_rxtx.cindexe1152ff0e..cc953ad58100644drivers/net/i40e/i40e_rxtx.c +0
-3@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC --2.17.1
Quoted 41 lines
-----Original Message-----
From: Wang, Haiyue
Sent: Monday, December 10, 2018 8:47 PM
To: Zhang, Qi Z <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 17 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 20:36
To: Yan, Zhirun <[email protected]>; [email protected]; Wang, Haiyue <[email protected]>
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 8 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Monday, December 10, 2018 9:32 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>
Cc: Yan, Zhirun <[email protected]>
Subject: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 5 lines
Quoted 3 lines
Before this patch, there are two functions that will clear RX/TX queues
number:rte_eth_dev_close()andi40e_dev_free_queues().I agree with what the patch changed, but the commit log is not
comprehensive.
Quoted 6 lines
I40e_dev_free_queuesis not only in the path ofrte_eth_dev_closebut alsorte_eth_dev_reset.
So
Forrte_eth_dev_close, its redundant because of duplication. Forrte_eth_dev_resetits redundant because of not necessary, since followingdev_configureis required afterdev_resetand it will be updatedcorrectly.
Quoted 1 line
Quoted 8 lines
How about this commit message ?
net/i40e: queue management data set is out of the API scope.
Function
i40e_dev_free_queuesis used to free specific i40e queue entries, but should not be used to set the upper level queue management data in 'structrte_eth_dev_data', such as ' nb_rx/tx_queues ', which are maintained by 'rte_eth_dev_rx/tx_queue_config'.
Ideally it should be what you described , but if you look at exist code in different PMD nb_rx/tx_queues is modified anywhere.
so I'm not very sure if nb_rx/tx_queues should only be modified in rte_ethdev_rx/tx_queue_config is the original design, and I don't have confidence those cleanup is always correct, that's why I will prefer an explanation that prove this code clean is correct. I think your comment is much fit for a patch set that do all the cleanup.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
This patch remove redundant code in
i40e_dev_free_queues().Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_rxtx.cindexe1152ff0e..cc953ad58100644drivers/net/i40e/i40e_rxtx.c +0
-3@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC --2.17.1
Quoted 58 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 22:08
To: Wang, Haiyue <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 40 lines
-----Original Message-----
From: Wang, Haiyue
Sent: Monday, December 10, 2018 8:47 PM
To: Zhang, Qi Z <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 17 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 20:36
To: Yan, Zhirun <[email protected]>; [email protected]; Wang, Haiyue <[email protected]>
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 8 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Monday, December 10, 2018 9:32 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>
Cc: Yan, Zhirun <[email protected]>
Subject: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 5 lines
Quoted 3 lines
Before this patch, there are two functions that will clear RX/TX queues
number:rte_eth_dev_close()andi40e_dev_free_queues().I agree with what the patch changed, but the commit log is not
comprehensive.
Quoted 7 lines
I40e_dev_free_queuesis not only in the path ofrte_eth_dev_closebut alsorte_eth_dev_reset.
So
Forrte_eth_dev_close, its redundant because of duplication. Forrte_eth_dev_resetits redundant because of not necessary, since followingdev_configureis required afterdev_resetand it will be updatedcorrectly.
Quoted 1 line
Quoted 8 lines
How about this commit message ?
net/i40e: queue management data set is out of the API scope.
Function
i40e_dev_free_queuesis used to free specific i40e queue entries, but should not be used to set the upper level queue management data in 'structrte_eth_dev_data', such as ' nb_rx/tx_queues ', which are maintained by 'rte_eth_dev_rx/tx_queue_config'.
Quoted 8 lines
Ideally it should be what you described , but if you look at exist code in different PMD nb_rx/tx_queues is modified anywhere.
so I'm not very sure if nb_rx/tx_queues should only be modified in rte_ethdev_rx/tx_queue_config is the original design, and I don't have confidence those cleanup is always correct, that's why I will prefer an explanation that prove this code clean is correct. I think your comment is much fit for a patch set that do all the cleanup.
I searched the " dev->data->nb_rx_queues = 0 ", 10 PMDs drivers write like this, and these functions nearly look like the same, like *copy*. :)
Well, from the feature ' VIRTCHNL_OP_REQUEST_QUEUES ', it will cause the VF PMD internally reset after the application like testpmd calls the ' rte_eth_dev_configure ' API. The internal reset has to free the internal resource firstly, which will call free functions such as ' i40e_dev_free_queues ', if this function reset the upper level parameters like nb_rx/tx_queues from ' rte_eth_dev_configure ', then this standard API will be changed to be more ugly, like:
' rte_eth_dev_configure '
--> diag = (*dev->dev_ops->dev_configure)(dev);
the PMD's dev_configure needs to be changed the new return value, such as 1 to
tell the ' rte_eth_dev_configure ' reconfigures the nb_rx/tx_queues again, such as
diag = (*dev->dev_ops->dev_configure)(dev);
if (diag == 1) {
rte_eth_dev_rx_queue_config(dev, nb_rx_q);
rte_eth_dev_tx_queue_config(dev, nb_tx_q);
} else if (diag != 0) {
RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
port_id, diag);
rte_eth_dev_rx_queue_config(dev, 0);
rte_eth_dev_tx_queue_config(dev, 0);
return eth_err(port_id, diag);
}This makes VIRTCHNL_OP_REQUEST_QUEUES work, but patch will be 100% rejected. Finally, we found that it we made i40e a good PMD boy, then all will be happy. This is the long history.
And if ' nb_rx/tx_queues ' stands for the number of TX/RX queues array entries, we'd better make code looks clean, like an OOP programming: let the rte_eth_xxx API handle its data.
struct rte_eth_dev_data {
char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
void **rx_queues; /**< Array of pointers to RX queues. */ void **tx_queues; /**< Array of pointers to TX queues. */ uint16_t nb_rx_queues; /**< Number of RX queues. */ uint16_t nb_tx_queues; /**< Number of TX queues. */
And the API 'void rte_eth_dev_close(uint16_t port_id)' will make things clean:
/* old behaviour: only free queue arrays */ dev->data->nb_rx_queues = 0; rte_free(dev->data->rx_queues); dev->data->rx_queues = NULL; dev->data->nb_tx_queues = 0; rte_free(dev->data->tx_queues); dev->data->tx_queues = NULL;
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
This patch remove redundant code in
i40e_dev_free_queues().Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)(quoted diff) +0
-0
b/drivers/net/i40e/i40e_rxtx.cindexe1152ff0e..cc953ad58100644drivers/net/i40e/i40e_rxtx.c +0
-3@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC --2.17.1
Quoted 76 lines
-----Original Message-----
From: Wang, Haiyue
Sent: Tuesday, December 11, 2018 1:00 AM
To: Zhang, Qi Z <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 57 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 22:08
To: Wang, Haiyue <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 48 lines
-----Original Message-----
From: Wang, Haiyue
Sent: Monday, December 10, 2018 8:47 PM
To: Zhang, Qi Z <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 17 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 20:36
To: Yan, Zhirun <[email protected]>; [email protected]; Wang, Haiyue <[email protected]>
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 8 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Monday, December 10, 2018 9:32 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>
Cc: Yan, Zhirun <[email protected]>
Subject: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 5 lines
Quoted 3 lines
Before this patch, there are two functions that will clear RX/TX queues
number:rte_eth_dev_close()andi40e_dev_free_queues().I agree with what the patch changed, but the commit log is not
comprehensive.
Quoted 7 lines
I40e_dev_free_queuesis not only in the path ofrte_eth_dev_closebut alsorte_eth_dev_reset.
So
Forrte_eth_dev_close, its redundant because of duplication. Forrte_eth_dev_resetits redundant because of not necessary, since followingdev_configureis required afterdev_resetand it will be updatedcorrectly.
Quoted 1 line
How about this commit message ?
net/i40e: queue management data set is out of the API scope.
Function
i40e_dev_free_queuesis used to free specific i40e queue entries, but should not be used to set the upper level queue management data in 'structrte_eth_dev_data', such as ' nb_rx/tx_queues ', which are maintained by'rte_eth_dev_rx/tx_queue_config'.
Quoted 9 lines
Ideally it should be what you described , but if you look at exist code in different PMD nb_rx/tx_queues is modified anywhere. so I'm not very sure if nb_rx/tx_queues should only be modified in rte_ethdev_rx/tx_queue_config is the original design, and I don't have confidence those cleanup is always correct, that's why I will prefer an explanation that prove this code clean is correct. I think your comment is much fit for a patch set that do all the cleanup.
Quoted 2 lines
I searched the "
dev->data->nb_rx_queues= 0 ", 10 PMDs drivers write like this, and these functions nearly look like the same, like *copy*. :)
that's not all the case, if you just search "nb_rx_queues = " you will get more cases that nb_rx_queues is modified by PMD directly. We should make sure all of them can be cleanup with that way before have our statement, but this is beyond this patch's scope.
Quoted 8 lines
Well, from the feature '
VIRTCHNL_OP_REQUEST_QUEUES', it will cause the VF PMD internally reset after the application like testpmd calls the 'rte_eth_dev_configure' API.
The internal reset has to free the internal resource firstly, which will call free functions such as 'i40e_dev_free_queues', if this function reset the upper level parameters like nb_rx/tx_queues from 'rte_eth_dev_configure', then this standard API will be changed to be more ugly, like:
Yes, that's why I also recommend Zhirun to merge this change to the patch for VIRTCHNL_OP_REQUEST_QUEUES as another option. But as an independent patch, I think current comments should be OK, because the context here is we have no idea about VIRTCHNL_OP_REQUEST_QUEUES yet.
Again, the words in your comment
".... but should not be used to set the upper level queue management data in 'struct rte_eth_dev_data', such as 'nb_rx/tx_queues ', which are maintained by 'rte_eth_dev_rx/tx_queue_config" I think it is a good design, but I'm not sure if this is considered at original because it is broken everywhere with current implementations.
So from my view, you are introducing a new design and should be covered in a separate patch set which focus on it, but this is not current patch's purpose.
Quoted 79 lines
'
rte_eth_dev_configure'
--> diag = (*dev->dev_ops->dev_configure)(dev);
the PMD'sdev_configureneeds to be changed the new return value,
such as 1 to
tell the 'rte_eth_dev_configure' reconfigures the nb_rx/tx_queues
again, such asdiag = (*dev->dev_ops->dev_configure)(dev); if (diag == 1) { rte_eth_dev_rx_queue_config(dev, nb_rx_q); rte_eth_dev_tx_queue_config(dev, nb_tx_q); } else if (diag != 0) { RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n", port_id, diag); rte_eth_dev_rx_queue_config(dev, 0); rte_eth_dev_tx_queue_config(dev, 0); return eth_err(port_id, diag); }This makes
VIRTCHNL_OP_REQUEST_QUEUESwork, but patch will be 100% rejected.
Finally, we found that it we made i40e a good PMD boy, then all will be happy. This is the long history.And if ' nb_rx/tx_queues ' stands for the number of TX/RX queues array entries, we'd better make code looks clean, like an OOP programming: let the
rte_eth_xxxAPI handle its data.struct
rte_eth_dev_data{
char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */void **rx_queues; /**< Array of pointers to RX queues. */ void **tx_queues; /**< Array of pointers to TX queues. */
uint16_tnb_rx_queues; /**< Number of RX queues. */uint16_tnb_tx_queues; /**< Number of TX queues. */And the API 'void
rte_eth_dev_close(uint16_t port_id)' will make things clean:/* old behaviour: only free queue arrays */ dev->data->nb_rx_queues = 0; rte_free(dev->data->rx_queues); dev->data->rx_queues = NULL; dev->data->nb_tx_queues = 0; rte_free(dev->data->tx_queues); dev->data->tx_queues = NULL;Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
This patch remove redundant code in
i40e_dev_free_queues().Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/i40e/i40e_rxtx.c i40e_dev_free_queues(struct rte_eth_dev
Quoted 6 lines
(quoted diff) +0
-0
b/drivers/net/i40e/i40e_rxtx.cindexe1152ff0e..cc953ad58100644drivers/net/i40e/i40e_rxtx.c +0
-0@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev*dev)
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/net/i40e/i40e_rxtx.c +0
-1i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { if (!dev->data->tx_queues[i]) @@ -2761,7 +2760,6 @@
i40e_dev_free_queues(struct rte_eth_dev *dev)drivers/net/i40e/i40e_rxtx.c +0
-2i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC --2.17.1
Quoted 83 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Tuesday, December 11, 2018 09:22
To: Wang, Haiyue <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 74 lines
-----Original Message-----
From: Wang, Haiyue
Sent: Tuesday, December 11, 2018 1:00 AM
To: Zhang, Qi Z <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 57 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 22:08
To: Wang, Haiyue <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 48 lines
-----Original Message-----
From: Wang, Haiyue
Sent: Monday, December 10, 2018 8:47 PM
To: Zhang, Qi Z <[email protected]>; Yan, Zhirun <[email protected]>; [email protected]
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 17 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Monday, December 10, 2018 20:36
To: Yan, Zhirun <[email protected]>; [email protected]; Wang, Haiyue <[email protected]>
Subject: RE: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 8 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Monday, December 10, 2018 9:32 PM
To: [email protected]; Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>
Cc: Yan, Zhirun <[email protected]>
Subject: [PATCH v1] net/i40e: remove redundant code in free queues.Quoted 5 lines
Quoted 3 lines
Before this patch, there are two functions that will clear RX/TX queues
number:rte_eth_dev_close()andi40e_dev_free_queues().I agree with what the patch changed, but the commit log is not
comprehensive.
Quoted 7 lines
I40e_dev_free_queuesis not only in the path ofrte_eth_dev_closebut alsorte_eth_dev_reset.
So
Forrte_eth_dev_close, its redundant because of duplication. Forrte_eth_dev_resetits redundant because of not necessary, since followingdev_configureis required afterdev_resetand it will be updatedcorrectly.
Quoted 1 line
How about this commit message ?
net/i40e: queue management data set is out of the API scope.
Function
i40e_dev_free_queuesis used to free specific i40e queue entries, but should not be used to set the upper level queue management data in 'structrte_eth_dev_data', such as ' nb_rx/tx_queues ', which are maintained by'rte_eth_dev_rx/tx_queue_config'.
Quoted 9 lines
Ideally it should be what you described , but if you look at exist code in different PMD nb_rx/tx_queues is modified anywhere. so I'm not very sure if nb_rx/tx_queues should only be modified in rte_ethdev_rx/tx_queue_config is the original design, and I don't have confidence those cleanup is always correct, that's why I will prefer an explanation that prove this code clean is correct. I think your comment is much fit for a patch set that do all the cleanup.
Quoted 9 lines
Quoted 3 lines
I searched the "
dev->data->nb_rx_queues= 0 ", 10 PMDs drivers write like this, and these functions nearly look like the same, like *copy*. :)that's not all the case, if you just search "
nb_rx_queues= " you will get more cases thatnb_rx_queuesis modified by PMD directly.
We should make sure all of them can be cleanup with that way before have our statement, but this is beyond this patch's scope.
I studied again, yes! I took two PMDs (pcap, ring) to understand more:drivers/net/pcap/rte_eth_pcap.c:961: data->nb_rx_queues = (uint16_t)nb_rx_queues;drivers/net/ring/rte_eth_ring.c:319: data->nb_rx_queues = (uint16_t)nb_rx_queues;
I found that they used internal queue management data, such as : struct pmd_internals --> struct ring_queue rx_ring_queues[RTE_PMD_RING_MAX_RX_RINGS]; then the eth_ops API rx/tx_queue_release have empty functions, like:
static voideth_queue_release(void *q __rte_unused) { ; }
It seems that the queue data management design is flexible, just let the PMD handles them carefully, and matches the rte_eth_xxx API's behavior.
Quoted 106 lines
Quoted 8 lines
Well, from the feature '
VIRTCHNL_OP_REQUEST_QUEUES', it will cause the VF PMD internally reset after the application like testpmd calls the 'rte_eth_dev_configure' API.
The internal reset has to free the internal resource firstly, which will call free functions such as 'i40e_dev_free_queues', if this function reset the upper level parameters like nb_rx/tx_queues from 'rte_eth_dev_configure', then this standard API will be changed to be moreugly, like:
Yes, that's why I also recommend Zhirun to merge this change to the patch for
VIRTCHNL_OP_REQUEST_QUEUESas another option.
But as an independent patch, I think current comments should be OK, because the context here is we have no idea aboutVIRTCHNL_OP_REQUEST_QUEUESyet.Again, the words in your comment
".... but should not be used to set the upper level queue management data in 'structrte_eth_dev_data', such as 'nb_rx/tx_queues ', which are maintained by 'rte_eth_dev_rx/tx_queue_config"
I think it is a good design, but I'm not sure if this is considered at original because it is broken everywhere with current implementations.So from my view, you are introducing a new design and should be covered in a separate patch set which focus on it, but this is not current patch's purpose.
Quoted 79 lines
'
rte_eth_dev_configure'
--> diag = (*dev->dev_ops->dev_configure)(dev);
the PMD'sdev_configureneeds to be changed the new return
value, such as 1 to
tell the 'rte_eth_dev_configure' reconfigures the
nb_rx/tx_queues again, such asdiag = (*dev->dev_ops->dev_configure)(dev); if (diag == 1) { rte_eth_dev_rx_queue_config(dev, nb_rx_q); rte_eth_dev_tx_queue_config(dev, nb_tx_q); } else if (diag != 0) { RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n", port_id, diag); rte_eth_dev_rx_queue_config(dev, 0); rte_eth_dev_tx_queue_config(dev, 0); return eth_err(port_id, diag); }This makes
VIRTCHNL_OP_REQUEST_QUEUESwork, but patch will be 100% rejected.
Finally, we found that it we made i40e a good PMD boy, then all will be happy. This is the long history.And if ' nb_rx/tx_queues ' stands for the number of TX/RX queues array entries, we'd better make code looks clean, like an OOP programming:
let therte_eth_xxxAPI handle its data.struct
rte_eth_dev_data{
char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */void **rx_queues; /**< Array of pointers to RX queues. */ void **tx_queues; /**< Array of pointers to TX queues. */
uint16_tnb_rx_queues; /**< Number of RX queues. */uint16_tnb_tx_queues; /**< Number of TX queues. */And the API 'void
rte_eth_dev_close(uint16_t port_id)' will make things clean:/* old behaviour: only free queue arrays */ dev->data->nb_rx_queues = 0; rte_free(dev->data->rx_queues); dev->data->rx_queues = NULL; dev->data->nb_tx_queues = 0; rte_free(dev->data->tx_queues); dev->data->tx_queues = NULL;Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
This patch remove redundant code in
i40e_dev_free_queues().Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/i40e/i40e_rxtx.c i40e_dev_free_queues(struct rte_eth_dev
Quoted 6 lines
(quoted diff) +0
-0
b/drivers/net/i40e/i40e_rxtx.cindexe1152ff0e..cc953ad58100644drivers/net/i40e/i40e_rxtx.c +0
-0@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev*dev)
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/net/i40e/i40e_rxtx.c +0
-1i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) { if (!dev->data->tx_queues[i]) @@ -2761,7 +2760,6 @@
i40e_dev_free_queues(struct rte_eth_dev *dev)drivers/net/i40e/i40e_rxtx.c +0
-2i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC --2.17.1
PATCH v2 1/1 net/i40e: remove redundant code
In reply to Zhirun YanBefore this patch, there are two functions will call i40e_dev_free_queues to free queues. For rte_eth_dev_close(), its redundant because of duplication. For rte_eth_dev_reset() its redundant because of not necessary, since following dev_configure is required after dev_reset and it will be updated correctly.
This patch removes redundant code in i40e_dev_free_queues().
--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -2
@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])
@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC
Signature · 1 line
2.17.1
PATCH v2 1/1 net/i40e: remove redundant code
In reply to Zhirun YanBefore this patch, there are two functions will call i40e_dev_free_queues to free queues. For rte_eth_dev_close(), its redundant because of duplication. For rte_eth_dev_reset() its redundant because of not necessary, since following dev_configure is required after dev_reset and it will be updated correctly.
This patch removes redundant code in i40e_dev_free_queues().
--- drivers/net/i40e/i40e_rxtx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -2
@@ -2753,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_rx_queue_release (dev->data->rx_queues[i]); dev->data->rx_queues[i] =NULL ; } - dev->data->nb_rx_queues =0 ;for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (!dev->data->tx_queues[i])
@@ -2761,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)i40e_dev_tx_queue_release (dev->data->tx_queues[i]); dev->data->tx_queues[i] =NULL ; } - dev->data->nb_tx_queues =0 ; }#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC
Signature · 1 line
2.17.1
Re: [PATCH v2] net/i40e: remove redundant code
Quoted 14 lines
-----Original Message-----
From: Yan, Zhirun
Sent: Thursday, December 13, 2018 8:49 PM
To: [email protected]; Zhang, Qi Z <[email protected]>
Cc: Yan, Zhirun <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [PATCH v2] net/i40e: remove redundant codeBefore this patch, there are two functions will call
i40e_dev_free_queuesto free queues. Forrte_eth_dev_close(), its redundant because of duplication. Forrte_eth_dev_reset()its redundant because of not necessary, since followingdev_configureis required afterdev_resetand it will be updated correctly.
Quoted 6 lines
This patch removes redundant code in
i40e_dev_free_queues().Fixes 6b4537128394 ("i40e: free queue memory when closing")Signed-off-by Zhirun Yan <[email protected]>Signed-off-by Haiyue Wang <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi