diff mbox

[v2] performance: odp_pktio_perf: use real MAC addresses while packet creation

Message ID 1438866016-19572-1-git-send-email-ivan.khoronzhuk@linaro.org
State Accepted
Commit 01f5c738c6e73bd3ad75984d293c506f952a1eff
Headers show

Commit Message

Ivan Khoronzhuk Aug. 6, 2015, 1 p.m. UTC
It's needed as pktio is not set in promisc mode.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---

Since v1:
	- initialize mac address at init, while packet creation only copy

 test/performance/odp_pktio_perf.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Stuart Haslam Aug. 6, 2015, 3:17 p.m. UTC | #1
On Thu, Aug 06, 2015 at 04:00:16PM +0300, Ivan Khoronzhuk wrote:
> It's needed as pktio is not set in promisc mode.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

Reviewed-by: Stuart Haslam <stuart.haslam@linaro.org>

> ---
> 
> Since v1:
> 	- initialize mac address at init, while packet creation only copy
> 
>  test/performance/odp_pktio_perf.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
> index 08f13b6..fcbc4ec 100644
> --- a/test/performance/odp_pktio_perf.c
> +++ b/test/performance/odp_pktio_perf.c
> @@ -123,6 +123,8 @@ typedef struct {
>  	odp_pktio_t pktio_rx;
>  	pkt_rx_stats_t rx_stats[ODP_CONFIG_MAX_THREADS];
>  	pkt_tx_stats_t tx_stats[ODP_CONFIG_MAX_THREADS];
> +	uint8_t src_mac[ODPH_ETHADDR_LEN];
> +	uint8_t dst_mac[ODPH_ETHADDR_LEN];
>  } test_globals_t;
>  
>  /* Status of max rate search */
> @@ -169,7 +171,6 @@ static odp_packet_t pktio_create_packet(void)
>  	uint32_t offset;
>  	pkt_head_t pkt_hdr;
>  	size_t payload_len;
> -	uint8_t mac[ODPH_ETHADDR_LEN] = {0};
>  
>  	payload_len = sizeof(pkt_hdr) + gbl_args->args.pkt_len;
>  
> @@ -186,8 +187,8 @@ static odp_packet_t pktio_create_packet(void)
>  	offset = 0;
>  	odp_packet_l2_offset_set(pkt, offset);
>  	eth = (odph_ethhdr_t *)buf;
> -	memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
> -	memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
> +	memcpy(eth->src.addr, gbl_args->src_mac, ODPH_ETHADDR_LEN);
> +	memcpy(eth->dst.addr, gbl_args->dst_mac, ODPH_ETHADDR_LEN);
>  	eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
>  
>  	/* IP */
> @@ -731,6 +732,11 @@ static int test_init(void)
>  	else
>  		gbl_args->pktio_rx = gbl_args->pktio_tx;
>  
> +	odp_pktio_mac_addr(gbl_args->pktio_tx, gbl_args->src_mac,
> +			   ODPH_ETHADDR_LEN);
> +	odp_pktio_mac_addr(gbl_args->pktio_rx, gbl_args->dst_mac,
> +			   ODPH_ETHADDR_LEN);
> +
>  	if (gbl_args->pktio_rx == ODP_PKTIO_INVALID ||
>  	    gbl_args->pktio_tx == ODP_PKTIO_INVALID) {
>  		LOG_ERR("failed to open pktio\n");
> -- 
> 1.9.1
>
Maxim Uvarov Aug. 7, 2015, 12:06 p.m. UTC | #2
Merged,
Maxim.

On 08/06/15 18:17, Stuart Haslam wrote:
> On Thu, Aug 06, 2015 at 04:00:16PM +0300, Ivan Khoronzhuk wrote:
>> It's needed as pktio is not set in promisc mode.
>>
>> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> Reviewed-by: Stuart Haslam <stuart.haslam@linaro.org>
>
>> ---
>>
>> Since v1:
>> 	- initialize mac address at init, while packet creation only copy
>>
>>   test/performance/odp_pktio_perf.c | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
>> index 08f13b6..fcbc4ec 100644
>> --- a/test/performance/odp_pktio_perf.c
>> +++ b/test/performance/odp_pktio_perf.c
>> @@ -123,6 +123,8 @@ typedef struct {
>>   	odp_pktio_t pktio_rx;
>>   	pkt_rx_stats_t rx_stats[ODP_CONFIG_MAX_THREADS];
>>   	pkt_tx_stats_t tx_stats[ODP_CONFIG_MAX_THREADS];
>> +	uint8_t src_mac[ODPH_ETHADDR_LEN];
>> +	uint8_t dst_mac[ODPH_ETHADDR_LEN];
>>   } test_globals_t;
>>   
>>   /* Status of max rate search */
>> @@ -169,7 +171,6 @@ static odp_packet_t pktio_create_packet(void)
>>   	uint32_t offset;
>>   	pkt_head_t pkt_hdr;
>>   	size_t payload_len;
>> -	uint8_t mac[ODPH_ETHADDR_LEN] = {0};
>>   
>>   	payload_len = sizeof(pkt_hdr) + gbl_args->args.pkt_len;
>>   
>> @@ -186,8 +187,8 @@ static odp_packet_t pktio_create_packet(void)
>>   	offset = 0;
>>   	odp_packet_l2_offset_set(pkt, offset);
>>   	eth = (odph_ethhdr_t *)buf;
>> -	memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
>> -	memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
>> +	memcpy(eth->src.addr, gbl_args->src_mac, ODPH_ETHADDR_LEN);
>> +	memcpy(eth->dst.addr, gbl_args->dst_mac, ODPH_ETHADDR_LEN);
>>   	eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
>>   
>>   	/* IP */
>> @@ -731,6 +732,11 @@ static int test_init(void)
>>   	else
>>   		gbl_args->pktio_rx = gbl_args->pktio_tx;
>>   
>> +	odp_pktio_mac_addr(gbl_args->pktio_tx, gbl_args->src_mac,
>> +			   ODPH_ETHADDR_LEN);
>> +	odp_pktio_mac_addr(gbl_args->pktio_rx, gbl_args->dst_mac,
>> +			   ODPH_ETHADDR_LEN);
>> +
>>   	if (gbl_args->pktio_rx == ODP_PKTIO_INVALID ||
>>   	    gbl_args->pktio_tx == ODP_PKTIO_INVALID) {
>>   		LOG_ERR("failed to open pktio\n");
>> -- 
>> 1.9.1
>>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 08f13b6..fcbc4ec 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -123,6 +123,8 @@  typedef struct {
 	odp_pktio_t pktio_rx;
 	pkt_rx_stats_t rx_stats[ODP_CONFIG_MAX_THREADS];
 	pkt_tx_stats_t tx_stats[ODP_CONFIG_MAX_THREADS];
+	uint8_t src_mac[ODPH_ETHADDR_LEN];
+	uint8_t dst_mac[ODPH_ETHADDR_LEN];
 } test_globals_t;
 
 /* Status of max rate search */
@@ -169,7 +171,6 @@  static odp_packet_t pktio_create_packet(void)
 	uint32_t offset;
 	pkt_head_t pkt_hdr;
 	size_t payload_len;
-	uint8_t mac[ODPH_ETHADDR_LEN] = {0};
 
 	payload_len = sizeof(pkt_hdr) + gbl_args->args.pkt_len;
 
@@ -186,8 +187,8 @@  static odp_packet_t pktio_create_packet(void)
 	offset = 0;
 	odp_packet_l2_offset_set(pkt, offset);
 	eth = (odph_ethhdr_t *)buf;
-	memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
-	memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
+	memcpy(eth->src.addr, gbl_args->src_mac, ODPH_ETHADDR_LEN);
+	memcpy(eth->dst.addr, gbl_args->dst_mac, ODPH_ETHADDR_LEN);
 	eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
 
 	/* IP */
@@ -731,6 +732,11 @@  static int test_init(void)
 	else
 		gbl_args->pktio_rx = gbl_args->pktio_tx;
 
+	odp_pktio_mac_addr(gbl_args->pktio_tx, gbl_args->src_mac,
+			   ODPH_ETHADDR_LEN);
+	odp_pktio_mac_addr(gbl_args->pktio_rx, gbl_args->dst_mac,
+			   ODPH_ETHADDR_LEN);
+
 	if (gbl_args->pktio_rx == ODP_PKTIO_INVALID ||
 	    gbl_args->pktio_tx == ODP_PKTIO_INVALID) {
 		LOG_ERR("failed to open pktio\n");