1cb9cadadSEd Warnicke/*
2cb9cadadSEd Warnicke * Copyright (c) 2015 Cisco and/or its affiliates.
3cb9cadadSEd Warnicke * Licensed under the Apache License, Version 2.0 (the "License");
4cb9cadadSEd Warnicke * you may not use this file except in compliance with the License.
5cb9cadadSEd Warnicke * You may obtain a copy of the License at:
6cb9cadadSEd Warnicke *
7cb9cadadSEd Warnicke *     http://www.apache.org/licenses/LICENSE-2.0
8cb9cadadSEd Warnicke *
9cb9cadadSEd Warnicke * Unless required by applicable law or agreed to in writing, software
10cb9cadadSEd Warnicke * distributed under the License is distributed on an "AS IS" BASIS,
11cb9cadadSEd Warnicke * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cb9cadadSEd Warnicke * See the License for the specific language governing permissions and
13cb9cadadSEd Warnicke * limitations under the License.
14cb9cadadSEd Warnicke */
15cb9cadadSEd Warnicke/*
16cb9cadadSEd Warnicke * pg_init.c: VLIB packet generator
17cb9cadadSEd Warnicke *
18cb9cadadSEd Warnicke * Copyright (c) 2008 Eliot Dresselhaus
19cb9cadadSEd Warnicke *
20cb9cadadSEd Warnicke * Permission is hereby granted, free of charge, to any person obtaining
21cb9cadadSEd Warnicke * a copy of this software and associated documentation files (the
22cb9cadadSEd Warnicke * "Software"), to deal in the Software without restriction, including
23cb9cadadSEd Warnicke * without limitation the rights to use, copy, modify, merge, publish,
24cb9cadadSEd Warnicke * distribute, sublicense, and/or sell copies of the Software, and to
25cb9cadadSEd Warnicke * permit persons to whom the Software is furnished to do so, subject to
26cb9cadadSEd Warnicke * the following conditions:
27cb9cadadSEd Warnicke *
28cb9cadadSEd Warnicke * The above copyright notice and this permission notice shall be
29cb9cadadSEd Warnicke * included in all copies or substantial portions of the Software.
30cb9cadadSEd Warnicke *
31cb9cadadSEd Warnicke *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32cb9cadadSEd Warnicke *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33cb9cadadSEd Warnicke *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34cb9cadadSEd Warnicke *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35cb9cadadSEd Warnicke *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36cb9cadadSEd Warnicke *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37cb9cadadSEd Warnicke *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38cb9cadadSEd Warnicke */
39cb9cadadSEd Warnicke
40cb9cadadSEd Warnicke#include <vlib/vlib.h>
41cb9cadadSEd Warnicke#include <vnet/pg/pg.h>
42cb9cadadSEd Warnicke
43cb9cadadSEd Warnicke/* Global main structure. */
44cb9cadadSEd Warnickepg_main_t pg_main;
45cb9cadadSEd Warnicke
4671e97c63SCalvinstatic clib_error_t *
4771e97c63SCalvinpg_init (vlib_main_t * vm)
48cb9cadadSEd Warnicke{
4971e97c63SCalvin  clib_error_t *error;
5071e97c63SCalvin  pg_main_t *pg = &pg_main;
513c8e1468SDave Barach  vlib_thread_main_t *vtm = vlib_get_thread_main ();
523c8e1468SDave Barach  u32 num_threads = 1 /* main thread */  + vtm->n_threads;
53cb9cadadSEd Warnicke
543d9c86e9SDamjan Marion  pg->if_index_by_if_id = hash_create (0, sizeof (uword));
55cb9cadadSEd Warnicke
56cb9cadadSEd Warnicke  if ((error = vlib_call_init_function (vm, vnet_main_init)))
57cb9cadadSEd Warnicke    goto done;
58cb9cadadSEd Warnicke
59cb9cadadSEd Warnicke  if ((error = vlib_call_init_function (vm, pg_cli_init)))
60cb9cadadSEd Warnicke    goto done;
61cb9cadadSEd Warnicke
623c8e1468SDave Barach  vec_validate (pg->replay_buffers_by_thread, num_threads);
633c8e1468SDave Barach
6471e97c63SCalvindone:
65cb9cadadSEd Warnicke  return error;
66cb9cadadSEd Warnicke}
67cb9cadadSEd Warnicke
68cb9cadadSEd WarnickeVLIB_INIT_FUNCTION (pg_init);
6971e97c63SCalvin
7071e97c63SCalvin/*
7171e97c63SCalvin * fd.io coding-style-patch-verification: ON
7271e97c63SCalvin *
7371e97c63SCalvin * Local Variables:
7471e97c63SCalvin * eval: (c-set-style "gnu")
7571e97c63SCalvin * End:
7671e97c63SCalvin */
77