[dpdk-dev,v2] examples/flow_filtering: add Tx queues setup process

Message ID 20171227083215.112330-1-wei.zhao1@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Helin Zhang
Headers

Checks

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

Commit Message

Zhao1, Wei Dec. 27, 2017, 8:32 a.m. UTC
  This example do not has the process of set up tx queues, but
some NIC start up process will be blocked if this is no tx queue
and only rx queues. So add tx queues setup process in main code.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>

---

v2:
-add support the new tx offloads.
---
 examples/flow_filtering/main.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
  

Comments

Ori Kam Dec. 27, 2017, 11:53 a.m. UTC | #1
> -----Original Message-----
> From: Wei Zhao [mailto:wei.zhao1@intel.com]
> Sent: Wednesday, December 27, 2017 10:32 AM
> To: dev@dpdk.org
> Cc: Ori Kam <orika@mellanox.com>; Wei Zhao <wei.zhao1@intel.com>
> Subject: [PATCH v2] examples/flow_filtering: add Tx queues setup process
> 
> This example do not has the process of set up tx queues, but some NIC start
> up process will be blocked if this is no tx queue and only rx queues. So add tx
> queues setup process in main code.
> 
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> 
> ---
> 
> v2:
> -add support the new tx offloads.
> ---
>  examples/flow_filtering/main.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
> index 7d739b4..4a07b63 100644
> --- a/examples/flow_filtering/main.c
> +++ b/examples/flow_filtering/main.c
> @@ -149,7 +149,18 @@ init_port(void)
>  			/**< CRC stripped by hardware */
>  			.hw_strip_crc   = 1,
>  		},
> +		.txmode = {
> +			.offloads =
> +				DEV_TX_OFFLOAD_VLAN_INSERT |
> +				DEV_TX_OFFLOAD_IPV4_CKSUM  |
> +				DEV_TX_OFFLOAD_UDP_CKSUM   |
> +				DEV_TX_OFFLOAD_TCP_CKSUM   |
> +				DEV_TX_OFFLOAD_SCTP_CKSUM  |
> +				DEV_TX_OFFLOAD_TCP_TSO,
> +		},
>  	};
> +	struct rte_eth_txconf txq_conf;
> +	struct rte_eth_dev_info dev_info;
> 
>  	printf(":: initializing port: %d\n", port_id);
>  	ret = rte_eth_dev_configure(port_id,
> @@ -173,6 +184,21 @@ init_port(void)
>  		}
>  	}
> 
> +	rte_eth_dev_info_get(port_id, &dev_info);
> +	txq_conf = dev_info.default_txconf;
> +	txq_conf.offloads = port_conf.txmode.offloads;
> +
> +	for (i = 0; i < nr_queues; i++) {
> +		ret = rte_eth_tx_queue_setup(port_id, i, 512,
> +				rte_eth_dev_socket_id(port_id),
> +				&txq_conf);
> +		if (ret < 0) {
> +			rte_exit(EXIT_FAILURE,
> +				":: Tx queue setup failed: err=%d,
> port=%u\n",
> +				ret, port_id);
> +		}
> +	}
> +
>  	rte_eth_promiscuous_enable(port_id);
>  	ret = rte_eth_dev_start(port_id);
>  	if (ret < 0) {
> --
> 2.9.3

Acked-by: Ori Kam <orika@mellanox.com>
  
Zhao1, Wei Dec. 28, 2017, 1:54 a.m. UTC | #2
Thabk you.

> -----Original Message-----
> From: Ori Kam [mailto:orika@mellanox.com]
> Sent: Wednesday, December 27, 2017 7:53 PM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Subject: RE: [PATCH v2] examples/flow_filtering: add Tx queues setup
> process
> 
> 
> 
> > -----Original Message-----
> > From: Wei Zhao [mailto:wei.zhao1@intel.com]
> > Sent: Wednesday, December 27, 2017 10:32 AM
> > To: dev@dpdk.org
> > Cc: Ori Kam <orika@mellanox.com>; Wei Zhao <wei.zhao1@intel.com>
> > Subject: [PATCH v2] examples/flow_filtering: add Tx queues setup
> > process
> >
> > This example do not has the process of set up tx queues, but some NIC
> > start up process will be blocked if this is no tx queue and only rx
> > queues. So add tx queues setup process in main code.
> >
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> >
> > ---
> >
> > v2:
> > -add support the new tx offloads.
> > ---
> >  examples/flow_filtering/main.c | 26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> >
> > diff --git a/examples/flow_filtering/main.c
> > b/examples/flow_filtering/main.c index 7d739b4..4a07b63 100644
> > --- a/examples/flow_filtering/main.c
> > +++ b/examples/flow_filtering/main.c
> > @@ -149,7 +149,18 @@ init_port(void)
> >  			/**< CRC stripped by hardware */
> >  			.hw_strip_crc   = 1,
> >  		},
> > +		.txmode = {
> > +			.offloads =
> > +				DEV_TX_OFFLOAD_VLAN_INSERT |
> > +				DEV_TX_OFFLOAD_IPV4_CKSUM  |
> > +				DEV_TX_OFFLOAD_UDP_CKSUM   |
> > +				DEV_TX_OFFLOAD_TCP_CKSUM   |
> > +				DEV_TX_OFFLOAD_SCTP_CKSUM  |
> > +				DEV_TX_OFFLOAD_TCP_TSO,
> > +		},
> >  	};
> > +	struct rte_eth_txconf txq_conf;
> > +	struct rte_eth_dev_info dev_info;
> >
> >  	printf(":: initializing port: %d\n", port_id);
> >  	ret = rte_eth_dev_configure(port_id, @@ -173,6 +184,21 @@
> > init_port(void)
> >  		}
> >  	}
> >
> > +	rte_eth_dev_info_get(port_id, &dev_info);
> > +	txq_conf = dev_info.default_txconf;
> > +	txq_conf.offloads = port_conf.txmode.offloads;
> > +
> > +	for (i = 0; i < nr_queues; i++) {
> > +		ret = rte_eth_tx_queue_setup(port_id, i, 512,
> > +				rte_eth_dev_socket_id(port_id),
> > +				&txq_conf);
> > +		if (ret < 0) {
> > +			rte_exit(EXIT_FAILURE,
> > +				":: Tx queue setup failed: err=%d,
> > port=%u\n",
> > +				ret, port_id);
> > +		}
> > +	}
> > +
> >  	rte_eth_promiscuous_enable(port_id);
> >  	ret = rte_eth_dev_start(port_id);
> >  	if (ret < 0) {
> > --
> > 2.9.3
> 
> Acked-by: Ori Kam <orika@mellanox.com>
  
Zhang, Helin Jan. 8, 2018, 6:31 a.m. UTC | #3
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ori Kam
> Sent: Wednesday, December 27, 2017 7:53 PM
> To: Zhao1, Wei; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] examples/flow_filtering: add Tx queues
> setup process
> 
> 
> 
> > -----Original Message-----
> > From: Wei Zhao [mailto:wei.zhao1@intel.com]
> > Sent: Wednesday, December 27, 2017 10:32 AM
> > To: dev@dpdk.org
> > Cc: Ori Kam <orika@mellanox.com>; Wei Zhao <wei.zhao1@intel.com>
> > Subject: [PATCH v2] examples/flow_filtering: add Tx queues setup
> > process
> >
> > This example do not has the process of set up tx queues, but some NIC
> > start up process will be blocked if this is no tx queue and only rx
> > queues. So add tx queues setup process in main code.
> >
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> >
> > ---
> >
> > v2:
> > -add support the new tx offloads.
> > ---
> >  examples/flow_filtering/main.c | 26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> >
> > diff --git a/examples/flow_filtering/main.c
> > b/examples/flow_filtering/main.c index 7d739b4..4a07b63 100644
> > --- a/examples/flow_filtering/main.c
> > +++ b/examples/flow_filtering/main.c
> > @@ -149,7 +149,18 @@ init_port(void)
> >  			/**< CRC stripped by hardware */
> >  			.hw_strip_crc   = 1,
> >  		},
> > +		.txmode = {
> > +			.offloads =
> > +				DEV_TX_OFFLOAD_VLAN_INSERT |
> > +				DEV_TX_OFFLOAD_IPV4_CKSUM  |
> > +				DEV_TX_OFFLOAD_UDP_CKSUM   |
> > +				DEV_TX_OFFLOAD_TCP_CKSUM   |
> > +				DEV_TX_OFFLOAD_SCTP_CKSUM  |
> > +				DEV_TX_OFFLOAD_TCP_TSO,
> > +		},
> >  	};
> > +	struct rte_eth_txconf txq_conf;
> > +	struct rte_eth_dev_info dev_info;
> >
> >  	printf(":: initializing port: %d\n", port_id);
> >  	ret = rte_eth_dev_configure(port_id, @@ -173,6 +184,21 @@
> > init_port(void)
> >  		}
> >  	}
> >
> > +	rte_eth_dev_info_get(port_id, &dev_info);
> > +	txq_conf = dev_info.default_txconf;
> > +	txq_conf.offloads = port_conf.txmode.offloads;
> > +
> > +	for (i = 0; i < nr_queues; i++) {
> > +		ret = rte_eth_tx_queue_setup(port_id, i, 512,
> > +				rte_eth_dev_socket_id(port_id),
> > +				&txq_conf);
> > +		if (ret < 0) {
> > +			rte_exit(EXIT_FAILURE,
> > +				":: Tx queue setup failed: err=%d,
> > port=%u\n",
> > +				ret, port_id);
> > +		}
> > +	}
> > +
> >  	rte_eth_promiscuous_enable(port_id);
> >  	ret = rte_eth_dev_start(port_id);
> >  	if (ret < 0) {
> > --
> > 2.9.3
> 
> Acked-by: Ori Kam <orika@mellanox.com>
Applied to dpdk-next-net-intel, thanks!

/Helin
  
Ferruh Yigit Jan. 12, 2018, 12:25 p.m. UTC | #4
On 12/27/2017 8:32 AM, Wei Zhao wrote:
> This example do not has the process of set up tx queues, but
> some NIC start up process will be blocked if this is no tx queue
> and only rx queues. So add tx queues setup process in main code.
> 
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>

<...>

> @@ -149,7 +149,18 @@ init_port(void)
>  			/**< CRC stripped by hardware */
>  			.hw_strip_crc   = 1,
>  		},
> +		.txmode = {
> +			.offloads =
> +				DEV_TX_OFFLOAD_VLAN_INSERT |
> +				DEV_TX_OFFLOAD_IPV4_CKSUM  |
> +				DEV_TX_OFFLOAD_UDP_CKSUM   |
> +				DEV_TX_OFFLOAD_TCP_CKSUM   |
> +				DEV_TX_OFFLOAD_SCTP_CKSUM  |
> +				DEV_TX_OFFLOAD_TCP_TSO,
> +		},
>  	};
> +	struct rte_eth_txconf txq_conf;
> +	struct rte_eth_dev_info dev_info;
>  
>  	printf(":: initializing port: %d\n", port_id);
>  	ret = rte_eth_dev_configure(port_id,
> @@ -173,6 +184,21 @@ init_port(void)
>  		}
>  	}
>  
> +	rte_eth_dev_info_get(port_id, &dev_info);
> +	txq_conf = dev_info.default_txconf;
> +	txq_conf.offloads = port_conf.txmode.offloads;

Hi Wei, Shahaf,

When new offload method used for txmode, shouldn't ETH_TXQ_FLAGS_IGNORE set,
otherwise txq_flags assumed to have valid values, no?
  
Shahaf Shuler Jan. 16, 2018, 1:52 p.m. UTC | #5
Friday, January 12, 2018 2:25 PM, Ferruh Yigit:
> > +	rte_eth_dev_info_get(port_id, &dev_info);

> > +	txq_conf = dev_info.default_txconf;

> > +	txq_conf.offloads = port_conf.txmode.offloads;

> 

> Hi Wei, Shahaf,

> 

> When new offload method used for txmode, shouldn't

> ETH_TXQ_FLAGS_IGNORE set, otherwise txq_flags assumed to have valid

> values, no?


Yes this is correct. see other examples code already converted.
  

Patch

diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index 7d739b4..4a07b63 100644
--- a/examples/flow_filtering/main.c
+++ b/examples/flow_filtering/main.c
@@ -149,7 +149,18 @@  init_port(void)
 			/**< CRC stripped by hardware */
 			.hw_strip_crc   = 1,
 		},
+		.txmode = {
+			.offloads =
+				DEV_TX_OFFLOAD_VLAN_INSERT |
+				DEV_TX_OFFLOAD_IPV4_CKSUM  |
+				DEV_TX_OFFLOAD_UDP_CKSUM   |
+				DEV_TX_OFFLOAD_TCP_CKSUM   |
+				DEV_TX_OFFLOAD_SCTP_CKSUM  |
+				DEV_TX_OFFLOAD_TCP_TSO,
+		},
 	};
+	struct rte_eth_txconf txq_conf;
+	struct rte_eth_dev_info dev_info;
 
 	printf(":: initializing port: %d\n", port_id);
 	ret = rte_eth_dev_configure(port_id,
@@ -173,6 +184,21 @@  init_port(void)
 		}
 	}
 
+	rte_eth_dev_info_get(port_id, &dev_info);
+	txq_conf = dev_info.default_txconf;
+	txq_conf.offloads = port_conf.txmode.offloads;
+
+	for (i = 0; i < nr_queues; i++) {
+		ret = rte_eth_tx_queue_setup(port_id, i, 512,
+				rte_eth_dev_socket_id(port_id),
+				&txq_conf);
+		if (ret < 0) {
+			rte_exit(EXIT_FAILURE,
+				":: Tx queue setup failed: err=%d, port=%u\n",
+				ret, port_id);
+		}
+	}
+
 	rte_eth_promiscuous_enable(port_id);
 	ret = rte_eth_dev_start(port_id);
 	if (ret < 0) {