From: Bogdan Pricope <bogdan.pric...@linaro.org>

Update odp_generator example application to use L3/L4 checksum
validation status functions.

Signed-off-by: Bogdan Pricope <bogdan.pric...@linaro.org>
---
/** Email created from pull request 269 (bogdanPricope:api_next_csum_status_pr)
 ** https://github.com/Linaro/odp/pull/269
 ** Patch: https://github.com/Linaro/odp/pull/269.patch
 ** Base sha: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: 31b12178be4753494e806513020d7706600c8382
 **/
 example/generator/odp_generator.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index 771bd1a2e..912fe7e9e 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -784,15 +784,13 @@ static void print_pkts(int thr, odp_packet_t pkt_tbl[], 
unsigned len)
 static int gen_recv_thread(void *arg)
 {
        int thr;
-       thread_args_t *thr_args;
        odp_packet_t pkts[MAX_RX_BURST], pkt;
        odp_event_t events[MAX_RX_BURST];
        int pkt_cnt, ev_cnt, i;
-       interface_t *itfs, *itf;
+       odp_packet_chksum_status_t csum_status;
 
+       (void)arg;
        thr = odp_thread_id();
-       thr_args = (thread_args_t *)arg;
-       itfs = thr_args->rx.ifs;
 
        printf("  [%02i] created mode: RECEIVE\n", thr);
        odp_barrier_wait(&barrier);
@@ -811,21 +809,14 @@ static int gen_recv_thread(void *arg)
                        continue;
                for (i = 0, pkt_cnt = 0; i < ev_cnt; i++) {
                        pkt = odp_packet_from_event(events[i]);
-                       itf = &itfs[odp_pktio_index(odp_packet_input(pkt))];
 
-                       if (odp_packet_has_ipv4(pkt)) {
-                               if (itf->config.pktin.bit.ipv4_chksum) {
-                                       if (odp_packet_has_l3_error(pkt))
-                                               printf("HW detected L3 
error\n");
-                               }
-                       }
+                       csum_status = odp_packet_l3_chksum_status(pkt);
+                       if (csum_status == ODP_PACKET_CHKSUM_BAD)
+                               printf("L3 checksum error detected.\n");
 
-                       if (odp_packet_has_udp(pkt)) {
-                               if (itf->config.pktin.bit.udp_chksum) {
-                                       if (odp_packet_has_l4_error(pkt))
-                                               printf("HW detected L4 
error\n");
-                               }
-                       }
+                       csum_status = odp_packet_l4_chksum_status(pkt);
+                       if (csum_status == ODP_PACKET_CHKSUM_BAD)
+                               printf("L4 checksum error detected.\n");
 
                        /* Drop packets with errors */
                        if (odp_unlikely(odp_packet_has_error(pkt))) {

Reply via email to