X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fsvm%2Ftest_svm_fifo1.c;h=d3898a7e6514cd75271ccc6998ef0a246d5c4af9;hb=c5df8c71c;hp=63b4a9b7ba57eba59a2c5b2a8f8da7e5ef5b6543;hpb=10d8cc6bf92851fcaec4a6b4c6d3554dc1eb2386;p=vpp.git diff --git a/src/svm/test_svm_fifo1.c b/src/svm/test_svm_fifo1.c index 63b4a9b7ba5..d3898a7e651 100644 --- a/src/svm/test_svm_fifo1.c +++ b/src/svm/test_svm_fifo1.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (c) 2016-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -15,10 +15,13 @@ #include "svm_fifo_segment.h" +svm_fifo_segment_main_t segment_main; + clib_error_t * hello_world (int verbose) { svm_fifo_segment_create_args_t _a, *a = &_a; + svm_fifo_segment_main_t *sm = &segment_main; svm_fifo_segment_private_t *sp; svm_fifo_t *f; int rv; @@ -26,20 +29,17 @@ hello_world (int verbose) u8 *retrieved_data = 0; clib_error_t *error = 0; - memset (a, 0, sizeof (*a)); + clib_memset (a, 0, sizeof (*a)); a->segment_name = "fifo-test1"; a->segment_size = 256 << 10; - a->rx_fifo_size = 4096; - a->tx_fifo_size = 4096; - a->preallocated_fifo_pairs = 4; - rv = svm_fifo_segment_create (a); + rv = svm_fifo_segment_create (sm, a); if (rv) return clib_error_return (0, "svm_fifo_segment_create returned %d", rv); - sp = svm_fifo_get_segment (a->new_segment_index); + sp = svm_fifo_segment_get_segment (sm, a->new_segment_indices[0]); f = svm_fifo_segment_alloc_fifo (sp, 4096, FIFO_SEGMENT_RX_FREELIST); @@ -75,6 +75,7 @@ clib_error_t * master (int verbose) { svm_fifo_segment_create_args_t _a, *a = &_a; + svm_fifo_segment_main_t *sm = &segment_main; svm_fifo_segment_private_t *sp; svm_fifo_t *f; int rv; @@ -82,17 +83,17 @@ master (int verbose) u8 *retrieved_data = 0; int i; - memset (a, 0, sizeof (*a)); + clib_memset (a, 0, sizeof (*a)); a->segment_name = "fifo-test1"; a->segment_size = 256 << 10; - rv = svm_fifo_segment_create (a); + rv = svm_fifo_segment_create (sm, a); if (rv) return clib_error_return (0, "svm_fifo_segment_create returned %d", rv); - sp = svm_fifo_get_segment (a->new_segment_index); + sp = svm_fifo_segment_get_segment (sm, a->new_segment_indices[0]); f = svm_fifo_segment_alloc_fifo (sp, 4096, FIFO_SEGMENT_RX_FREELIST); @@ -112,23 +113,24 @@ clib_error_t * mempig (int verbose) { svm_fifo_segment_create_args_t _a, *a = &_a; + svm_fifo_segment_main_t *sm = &segment_main; svm_fifo_segment_private_t *sp; svm_fifo_t *f; svm_fifo_t **flist = 0; int rv; int i; - memset (a, 0, sizeof (*a)); + clib_memset (a, 0, sizeof (*a)); a->segment_name = "fifo-test1"; a->segment_size = 256 << 10; - rv = svm_fifo_segment_create (a); + rv = svm_fifo_segment_create (sm, a); if (rv) return clib_error_return (0, "svm_fifo_segment_create returned %d", rv); - sp = svm_fifo_get_segment (a->new_segment_index); + sp = svm_fifo_segment_get_segment (sm, a->new_segment_indices[0]); for (i = 0; i < 1000; i++) { @@ -169,6 +171,7 @@ clib_error_t * offset (int verbose) { svm_fifo_segment_create_args_t _a, *a = &_a; + svm_fifo_segment_main_t *sm = &segment_main; svm_fifo_segment_private_t *sp; svm_fifo_t *f; int rv; @@ -176,17 +179,17 @@ offset (int verbose) u32 *recovered_data = 0; int i; - memset (a, 0, sizeof (*a)); + clib_memset (a, 0, sizeof (*a)); a->segment_name = "fifo-test1"; a->segment_size = 256 << 10; - rv = svm_fifo_segment_create (a); + rv = svm_fifo_segment_create (sm, a); if (rv) return clib_error_return (0, "svm_fifo_segment_create returned %d", rv); - sp = svm_fifo_get_segment (a->new_segment_index); + sp = svm_fifo_segment_get_segment (sm, a->new_segment_indices[0]); f = svm_fifo_segment_alloc_fifo (sp, 200 << 10, FIFO_SEGMENT_RX_FREELIST); @@ -228,6 +231,7 @@ clib_error_t * slave (int verbose) { svm_fifo_segment_create_args_t _a, *a = &_a; + svm_fifo_segment_main_t *sm = &segment_main; svm_fifo_segment_private_t *sp; svm_fifo_t *f; ssvm_shared_header_t *sh; @@ -237,7 +241,7 @@ slave (int verbose) u8 *retrieved_data = 0; int i; - memset (a, 0, sizeof (*a)); + clib_memset (a, 0, sizeof (*a)); a->segment_name = "fifo-test1"; @@ -246,7 +250,7 @@ slave (int verbose) if (rv) return clib_error_return (0, "svm_fifo_segment_attach returned %d", rv); - sp = svm_fifo_get_segment (a->new_segment_index); + sp = svm_fifo_segment_get_segment (sm, a->new_segment_indices[0]); sh = sp->ssvm.sh; fsh = (svm_fifo_segment_header_t *) sh->opaque[0]; @@ -272,11 +276,12 @@ slave (int verbose) int test_ssvm_fifo1 (unformat_input_t * input) { + svm_fifo_segment_main_t *sm = &segment_main; clib_error_t *error = 0; int verbose = 0; int test_id = 0; - svm_fifo_segment_init (0x200000000ULL, 20); + svm_fifo_segment_main_init (sm, HIGH_SEGMENT_BASEVA, 20); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {