5baec95bc1c2b258a53124bf447974b4d9a3bf7f
[dpdk.git] / drivers / common / cnxk / roc_platform.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #include "roc_api.h"
6
7 int
8 roc_plt_init(void)
9 {
10         const struct rte_memzone *mz;
11
12         mz = rte_memzone_lookup(PLT_MODEL_MZ_NAME);
13         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
14                 if (mz == NULL) {
15                         mz = rte_memzone_reserve(PLT_MODEL_MZ_NAME,
16                                                  sizeof(struct roc_model),
17                                                  SOCKET_ID_ANY, 0);
18                         if (mz == NULL) {
19                                 plt_err("Failed to reserve mem for roc_model");
20                                 return -ENOMEM;
21                         }
22                         roc_model_init(mz->addr);
23                 }
24         } else {
25                 if (mz == NULL) {
26                         plt_err("Failed to lookup mem for roc_model");
27                         return -ENOMEM;
28                 }
29                 roc_model = mz->addr;
30         }
31
32         return 0;
33 }