[lng-odp] [ODP-DPDK] SpanningTree and block a port ?

2015-10-02 Thread Kury Nicolas
Hi


I would like to implement an application with spanning tree protocol. But can 
the application "spanningtree" stop and start a port used by another 
applications (exemple odp_generator) ?

Here a diagram:  http://s8.postimg.org/yis5flhed/spanningtree.png


For exemple, if the link #1 is down, spanningtree application enables port 0.


Thank you

Nicolas
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


Re: [lng-odp] [PATCH] validation:pktio : Fix UDP checksum computation

2015-10-02 Thread Ion Grigore
-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Maxim 
Uvarov
Sent: Wednesday, September 23, 2015 8:37 PM
To: lng-odp@lists.linaro.org
Subject: Re: [lng-odp] [PATCH] validation:pktio : Fix UDP checksum computation



On 09/21/15 08:57, ion.grig...@freescale.com wrote:
> From: Grigore Ion 
>
> The UDP checksum is computed in the CPU endianess. The returned result 
> must be converted to the BE ordering when it is used to update the UDP 
> checksum in a packet.
>
> Signed-off-by: Grigore Ion 
> ---
>   test/validation/pktio/pktio.c |2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/test/validation/pktio/pktio.c 
> b/test/validation/pktio/pktio.c index d62f18d..604ac89 100644
> --- a/test/validation/pktio/pktio.c
> +++ b/test/validation/pktio/pktio.c
> @@ -195,7 +195,7 @@ static int pktio_fixup_checksums(odp_packet_t pkt)
>   ip->chksum = 0;
>   odph_ipv4_csum_update(pkt);
>   udp->chksum = 0;
> - udp->chksum = odph_ipv4_udp_chksum(pkt);
> + udp->chksum = odp_cpu_to_be_16(odph_ipv4_udp_chksum(pkt));
>   

odph_ipv4_udp_chksum() should return checksum in right bite order. Converting 
it each time like that complicates code.

Maxim.

The chksum field is declared as uint16be_t.  In my opinion, applications 
updating the xxxbe_t fields should call the 
odp_cpu_to_be_xx function to update such fields (mapped on data in a BE 
packet).   From this point of view,
odph_ipv4_udp_chksum() returns the checksum in the CPU byte order.

The same is done in the function odph_ipv4_csum_update().

Grig

>   return 0;
>   }

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp
___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv2 2/2] example:generator : Fix UDP checksum computation

2015-10-02 Thread ion.grigore
From: Grigore Ion 

The UDP checksum is computed in the CPU endianness. The returned result
must be converted to the BE ordering when it is used to update the UDP
checksum in a packet.

Signed-off-by: Grigore Ion 
---
 v2:
 - Add PATCH version information (Maxim Uvarov)
 - Check patch with checkpatch script. (Bill Fischofer)

 example/generator/odp_generator.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index 4af82a9..443df8b 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -239,7 +239,7 @@ static odp_packet_t pack_udp_pkt(odp_pool_t pool)
udp->dst_port = 0;
udp->length = odp_cpu_to_be_16(args->appl.payload + ODPH_UDPHDR_LEN);
udp->chksum = 0;
-   udp->chksum = odph_ipv4_udp_chksum(pkt);
+   udp->chksum = odp_cpu_to_be_16(odph_ipv4_udp_chksum(pkt));
 
return pkt;
 }
-- 
1.7.3.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv2 1/2] example:generator : Fix data race condition

2015-10-02 Thread ion.grigore
From: Grigore Ion 

The counters.seq counter is used to check if the configured number of
packets was processed. There is a race condition between the counter
incrementation time and its value testing time. If code is running on
multiple CPUs it is possible the application send more packets than
expected (with number of CPUs - 1). A separate counter must be used
for the processed packets.

Signed-off-by: Grigore Ion 
---
 v2:
 - Add PATCH version information (Maxim Uvarov)
 - Check patch with checkpatch script. (Bill Fischofer)

 example/generator/odp_generator.c |   19 ++-
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index d6ec758..4af82a9 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -66,6 +66,7 @@ static struct {
odp_atomic_u64_t ip;/**< ip packets */
odp_atomic_u64_t udp;   /**< udp packets */
odp_atomic_u64_t icmp;  /**< icmp packets */
+   odp_atomic_u64_t cnt;   /**< sent packets*/
 } counters;
 
 /** * Thread specific arguments
@@ -395,6 +396,11 @@ static void *gen_send_thread(void *arg)
for (;;) {
int err;
 
+   if (args->appl.number != -1 &&
+   odp_atomic_fetch_add_u64(, 1) >=
+   (unsigned int)args->appl.number)
+   break;
+
if (args->appl.mode == APPL_MODE_UDP)
pkt = pack_udp_pkt(thr_args->pool);
else if (args->appl.mode == APPL_MODE_PING)
@@ -426,11 +432,6 @@ static void *gen_send_thread(void *arg)
   thr_args->tmo_ev);
 
}
-   if (args->appl.number != -1 &&
-   odp_atomic_load_u64()
-   >= (unsigned int)args->appl.number) {
-   break;
-   }
}
 
/* receive number of reply pks until timeout */
@@ -450,11 +451,10 @@ static void *gen_send_thread(void *arg)
 
/* print info */
if (args->appl.mode == APPL_MODE_UDP) {
-   printf("  [%02i] total send: %ju\n",
-  thr, odp_atomic_load_u64());
+   printf("  [%02i] total send: %d\n", thr, args->appl.number);
} else if (args->appl.mode == APPL_MODE_PING) {
-   printf("  [%02i] total send: %ju total receive: %ju\n",
-  thr, odp_atomic_load_u64(),
+   printf("  [%02i] total send: %d total receive: %ju\n",
+  thr, args->appl.number,
   odp_atomic_load_u64());
}
return arg;
@@ -610,6 +610,7 @@ int main(int argc, char *argv[])
odp_atomic_init_u64(, 0);
odp_atomic_init_u64(, 0);
odp_atomic_init_u64(, 0);
+   odp_atomic_init_u64(, 0);
 
/* Reserve memory for args from shared mem */
shm = odp_shm_reserve("shm_args", sizeof(args_t),
-- 
1.7.3.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv1] example:generator : Fix data race condition

2015-10-02 Thread ion.grigore
From: Grigore Ion 

The counters.seq counter is used to check if the configured number of
packets was processed. There is a race condition between the counter
incrementation time and its value testing time. If code is running on
multiple CPUs it is possible the application send more packets than
expected (with number of CPUs - 1). A separate counter must be used
for the processed packets.

Signed-off-by: Grigore Ion 
---
v1:
- Remove empty line (Maxim Uvarov)
- Add PATCH version information (Maxim Uvarov)
- Check patch with checkpatch script. (Bill Fischofer)
- Remove unnecessary parentheses

 example/generator/odp_generator.c |   19 ++-
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index e281b27..443df8b 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -66,6 +66,7 @@ static struct {
odp_atomic_u64_t ip;/**< ip packets */
odp_atomic_u64_t udp;   /**< udp packets */
odp_atomic_u64_t icmp;  /**< icmp packets */
+   odp_atomic_u64_t cnt;   /**< sent packets*/
 } counters;
 
 /** * Thread specific arguments
@@ -395,6 +396,11 @@ static void *gen_send_thread(void *arg)
for (;;) {
int err;
 
+   if (args->appl.number != -1 &&
+   odp_atomic_fetch_add_u64(, 1) >=
+   (unsigned int)args->appl.number)
+   break;
+
if (args->appl.mode == APPL_MODE_UDP)
pkt = pack_udp_pkt(thr_args->pool);
else if (args->appl.mode == APPL_MODE_PING)
@@ -426,11 +432,6 @@ static void *gen_send_thread(void *arg)
   thr_args->tmo_ev);
 
}
-   if (args->appl.number != -1 &&
-   odp_atomic_load_u64()
-   >= (unsigned int)args->appl.number) {
-   break;
-   }
}
 
/* receive number of reply pks until timeout */
@@ -450,11 +451,10 @@ static void *gen_send_thread(void *arg)
 
/* print info */
if (args->appl.mode == APPL_MODE_UDP) {
-   printf("  [%02i] total send: %ju\n",
-  thr, odp_atomic_load_u64());
+   printf("  [%02i] total send: %d\n", thr, args->appl.number);
} else if (args->appl.mode == APPL_MODE_PING) {
-   printf("  [%02i] total send: %ju total receive: %ju\n",
-  thr, odp_atomic_load_u64(),
+   printf("  [%02i] total send: %d total receive: %ju\n",
+  thr, args->appl.number,
   odp_atomic_load_u64());
}
return arg;
@@ -610,6 +610,7 @@ int main(int argc, char *argv[])
odp_atomic_init_u64(, 0);
odp_atomic_init_u64(, 0);
odp_atomic_init_u64(, 0);
+   odp_atomic_init_u64(, 0);
 
/* Reserve memory for args from shared mem */
shm = odp_shm_reserve("shm_args", sizeof(args_t),
-- 
1.7.3.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv1] validation:pktio : Fix UDP checksum computation

2015-10-02 Thread ion.grigore
From: Grigore Ion 

The UDP checksum is computed in the CPU endianness. The returned result
must be converted to the BE ordering when it is used to update the UDP
checksum in a packet.

Signed-off-by: Grigore Ion 
---
 v1:
 - Add PATCH version information (Maxim Uvarov)
 - Check patch with checkpatch script. (Bill Fischofer)

 test/validation/pktio/pktio.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index d62f18d..604ac89 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -195,7 +195,7 @@ static int pktio_fixup_checksums(odp_packet_t pkt)
ip->chksum = 0;
odph_ipv4_csum_update(pkt);
udp->chksum = 0;
-   udp->chksum = odph_ipv4_udp_chksum(pkt);
+   udp->chksum = odp_cpu_to_be_16(odph_ipv4_udp_chksum(pkt));
 
return 0;
 }
-- 
1.7.3.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp


[lng-odp] [PATCHv1] helper : Fix UDP checksum computation

2015-10-02 Thread ion.grigore
From: Grigore Ion 

This patch fixes the following problems:
- checksum computation for LE platforms
- checksum is computed in the CPU endianness. The returned result
must be converted to the BE ordering when it is used to update the
UDP checksum in a packet.
- checksum computation for packets having the UDP length not a
multiple of 2.

Signed-off-by: Grigore Ion 
---
v1: 
- Move variables declaration on top of block. (Maxim Uvarov)
- Check patch with checkpatch script.  (Maxim Uvarov) 
- L3 header presence is tested twice. (Alexandru Badicioiu)
- Remove unnecessary check for L3 header presence. (Bill Fischofer)
- Modify check of odp_packet_l4_offset() return. (Bill Fischofer)

 helper/include/odp/helper/udp.h |   55 --
 1 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/helper/include/odp/helper/udp.h b/helper/include/odp/helper/udp.h
index 06c439b..99392c5 100644
--- a/helper/include/odp/helper/udp.h
+++ b/helper/include/odp/helper/udp.h
@@ -4,7 +4,6 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-
 /**
  * @file
  *
@@ -22,7 +21,6 @@ extern "C" {
 #include 
 #include 
 
-
 /** @addtogroup odph_header ODPH HEADER
  *  @{
  */
@@ -44,46 +42,39 @@ typedef struct ODP_PACKED {
  * This function uses odp packet to calc checksum
  *
  * @param pkt  calculate chksum for pkt
- * @return  checksum value
+ * @return  checksum value in CPU endianness
  */
 static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
 {
-   uint32_t sum = 0;
-   odph_udphdr_t *udph;
-   odph_ipv4hdr_t *iph;
-   uint16_t udplen;
-   uint8_t *buf;
-
-   if (!odp_packet_l3_offset(pkt))
-   return 0;
+   odph_ipv4hdr_t  *iph;
+   odph_udphdr_t   *udph;
+   uint32_tsum;
+   uint16_tudplen, *buf;
 
-   if (!odp_packet_l4_offset(pkt))
+   if (odp_packet_l4_offset(pkt) == ODP_PACKET_OFFSET_INVALID)
return 0;
-
iph = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL);
udph = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL);
-   udplen = odp_be_to_cpu_16(udph->length);
-
-   /* 32-bit sum of all 16-bit words covered by UDP chksum */
+   /* 32-bit sum of UDP pseudo-header */
sum = (iph->src_addr & 0x) + (iph->src_addr >> 16) +
- (iph->dst_addr & 0x) + (iph->dst_addr >> 16) +
- (uint16_t)iph->proto + udplen;
-   for (buf = (uint8_t *)udph; udplen > 1; udplen -= 2) {
-   sum += ((*buf << 8) + *(buf + 1));
-   buf += 2;
-   }
-
-   /* Fold sum to 16 bits: add carrier to result */
-   while (sum >> 16)
-   sum = (sum & 0x) + (sum >> 16);
-
+   (iph->dst_addr & 0x) + (iph->dst_addr >> 16) +
+   odp_be_to_cpu_16(iph->proto) + udph->length;
+   udplen = odp_be_to_cpu_16(udph->length);
+   buf = (uint16_t *)((void *)udph);
+   /* 32-bit sum of UDP header (checksum field cleared) and UDP data */
+   for ( ; udplen > 1; udplen -= 2)
+   sum += *buf++;
+   /* Length is not a multiple of 2 bytes */
+   if (udplen)
+   sum += odp_be_to_cpu_16(*((uint8_t *)buf) << 8);
+   /* Fold sum to 16 bits */
+   sum = (sum & 0x) + (sum >> 16);
+   /* Add carrier (0/1) to result */
+   sum += (sum >> 16);
/* 1's complement */
sum = ~sum;
-
-   /* set computation result */
-   sum = (sum == 0x0) ? 0x : sum;
-
-   return sum;
+   /* Set computation result */
+   return (sum == 0x0) ? 0x : odp_be_to_cpu_16(sum);
 }
 
 /** @internal Compile time assert */
-- 
1.7.3.4

___
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp