[dpdk-dev] net/i40e: fix missing Port Representor data-path callbacks

Message ID 20180509150005.2531-1-remy.horton@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Helin Zhang
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Remy Horton May 9, 2018, 3 p.m. UTC
  This patch adds Rx and Tx burst functions to the i40e Port
Representors, so that the implementation within this PMD
can be tested using applications such as testpmd which
require data-path functionality.

Fixes: e0cb96204b71 ("net/i40e: add support for representor ports")

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 drivers/net/i40e/i40e_vf_representor.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
  

Comments

Mohammad Abdul Awal May 11, 2018, 10:48 a.m. UTC | #1
On 09/05/2018 16:00, Remy Horton wrote:
> This patch adds Rx and Tx burst functions to the i40e Port
> Representors, so that the implementation within this PMD
> can be tested using applications such as testpmd which
> require data-path functionality.
>
> Fixes: e0cb96204b71 ("net/i40e: add support for representor ports")
>
> Signed-off-by: Remy Horton <remy.horton@intel.com>
> ---
>   drivers/net/i40e/i40e_vf_representor.c | 27 ++++++++++++++++++++++++---
>   1 file changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c
> index 96b3787..e205019 100644
> --- a/drivers/net/i40e/i40e_vf_representor.c
> +++ b/drivers/net/i40e/i40e_vf_representor.c
> @@ -337,6 +337,25 @@ struct eth_dev_ops i40e_representor_dev_ops = {
>   
>   };
>   
> +static uint16_t
> +i40e_vf_representor_rx_burst(__rte_unused void *rx_queue,
> +	__rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
> +{
> +	return 0;
> +}
> +
> +static uint16_t
> +i40e_vf_representor_tx_burst(__rte_unused void *tx_queue,
> +	struct rte_mbuf **tx_pkts,
> +	uint16_t nb_pkts)
> +{
> +	uint16_t idx_pkt;
> +
> +	for (idx_pkt = 0; idx_pkt < nb_pkts; idx_pkt++)
> +		rte_pktmbuf_free(tx_pkts[idx_pkt]);
We should not free them in the driver silently whereas the application 
will think that it has been sent successfully.
Please use the same rule for rx_burst, and return 0.
> +	return nb_pkts;
> +}
> +
>   int
>   i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
>   {
> @@ -365,9 +384,11 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
>   	/* Set representor device ops */
>   	ethdev->dev_ops = &i40e_representor_dev_ops;
>   
> -	/* No data-path so no RX/TX functions */
> -	ethdev->rx_pkt_burst = NULL;
> -	ethdev->tx_pkt_burst = NULL;
> +	/* No data-path, but need stub Rx/Tx functions to avoid crash
> +	 * when testing with the likes of testpmd.
> +	 */
> +	ethdev->rx_pkt_burst = i40e_vf_representor_rx_burst;
> +	ethdev->tx_pkt_burst = i40e_vf_representor_tx_burst;
>   
>   	vf = &pf->vfs[representor->vf_id];
>
  
Remy Horton May 11, 2018, 12:28 p.m. UTC | #2
This patchset adds Rx and Tx burst functions to the ixgbe and i40e Port
Representors, so that the implementation within these PMDd can be tested
using applications such as testpmd which require data-path functionality.

Changes in v2:
* Combine patches into one patchset
* Tx burst changed from silently consuming packets to No-Op

Remy Horton (2):
  net/i40e: fix missing Port Representor data-path
  net/ixgbe: fix missing Port Representor data-path

 drivers/net/i40e/i40e_vf_representor.c   | 22 +++++++++++++++++++---
 drivers/net/ixgbe/ixgbe_vf_representor.c | 22 +++++++++++++++++++---
 2 files changed, 38 insertions(+), 6 deletions(-)
  
Remy Horton May 11, 2018, 12:29 p.m. UTC | #3
On 11/05/2018 11:48, Mohammad Abdul Awal wrote:
[..]
>> +static uint16_t
>> +i40e_vf_representor_tx_burst(__rte_unused void *tx_queue,
>> +    struct rte_mbuf **tx_pkts,
>> +    uint16_t nb_pkts)
>> +{
>> +    uint16_t idx_pkt;
>> +
>> +    for (idx_pkt = 0; idx_pkt < nb_pkts; idx_pkt++)
>> +        rte_pktmbuf_free(tx_pkts[idx_pkt]);
> We should not free them in the driver silently whereas the application
> will think that it has been sent successfully.
> Please use the same rule for rx_burst, and return 0.

Ok, v2 coming.

I'll also combine this and the ixgbe patch into the same patchset.
  

Patch

diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c
index 96b3787..e205019 100644
--- a/drivers/net/i40e/i40e_vf_representor.c
+++ b/drivers/net/i40e/i40e_vf_representor.c
@@ -337,6 +337,25 @@  struct eth_dev_ops i40e_representor_dev_ops = {
 
 };
 
+static uint16_t
+i40e_vf_representor_rx_burst(__rte_unused void *rx_queue,
+	__rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
+static uint16_t
+i40e_vf_representor_tx_burst(__rte_unused void *tx_queue,
+	struct rte_mbuf **tx_pkts,
+	uint16_t nb_pkts)
+{
+	uint16_t idx_pkt;
+
+	for (idx_pkt = 0; idx_pkt < nb_pkts; idx_pkt++)
+		rte_pktmbuf_free(tx_pkts[idx_pkt]);
+	return nb_pkts;
+}
+
 int
 i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
 {
@@ -365,9 +384,11 @@  i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
 	/* Set representor device ops */
 	ethdev->dev_ops = &i40e_representor_dev_ops;
 
-	/* No data-path so no RX/TX functions */
-	ethdev->rx_pkt_burst = NULL;
-	ethdev->tx_pkt_burst = NULL;
+	/* No data-path, but need stub Rx/Tx functions to avoid crash
+	 * when testing with the likes of testpmd.
+	 */
+	ethdev->rx_pkt_burst = i40e_vf_representor_rx_burst;
+	ethdev->tx_pkt_burst = i40e_vf_representor_tx_burst;
 
 	vf = &pf->vfs[representor->vf_id];