net/bnxt: add SRAM manager model
[dpdk.git] / drivers / net / bnxt / tf_core / tf_tbl_sram.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2021 Broadcom
3  * All rights reserved.
4  */
5
6 /* Truflow Table APIs and supporting code */
7
8 #include <rte_common.h>
9
10 #include "tf_tbl.h"
11 #include "tf_tbl_sram.h"
12 #include "tf_sram_mgr.h"
13 #include "tf_common.h"
14 #include "tf_rm.h"
15 #include "tf_util.h"
16 #include "tf_msg.h"
17 #include "tfp.h"
18 #include "tf_session.h"
19 #include "tf_device.h"
20 #include "cfa_resource_types.h"
21
22 #define DBG_SRAM 0
23
24 /**
25  * tf_sram_tbl_get_info_parms parameter definition
26  */
27 struct tf_tbl_sram_get_info_parms {
28         /**
29          * [in] table RM database
30          */
31         void *rm_db;
32         /**
33          * [in] Receive or transmit direction
34          */
35         enum tf_dir dir;
36         /**
37          * [in] table_type
38          *
39          *  the TF index table type
40          */
41         enum tf_tbl_type tbl_type;
42         /**
43          * [out] bank
44          *
45          *  The SRAM bank associated with the type
46          */
47         enum tf_sram_bank_id bank_id;
48         /**
49          * [out] slice_size
50          *
51          *  the slice size for the indicated table type
52          */
53         enum tf_sram_slice_size slice_size;
54 };
55
56 /**
57  * Translate HCAPI type to SRAM Manager bank
58  */
59 const uint16_t tf_tbl_sram_hcapi_2_bank[CFA_RESOURCE_TYPE_P58_LAST] = {
60         [CFA_RESOURCE_TYPE_P58_SRAM_BANK_0] = TF_SRAM_BANK_ID_0,
61         [CFA_RESOURCE_TYPE_P58_SRAM_BANK_1] = TF_SRAM_BANK_ID_1,
62         [CFA_RESOURCE_TYPE_P58_SRAM_BANK_2] = TF_SRAM_BANK_ID_2,
63         [CFA_RESOURCE_TYPE_P58_SRAM_BANK_3] = TF_SRAM_BANK_ID_3
64 };
65
66 #define TF_TBL_SRAM_SLICES_MAX  \
67         (TF_SRAM_MGR_BLOCK_SZ_BYTES / TF_SRAM_MGR_MIN_SLICE_BYTES)
68 /**
69  * Translate HCAPI type to SRAM Manager bank
70  */
71 const uint8_t tf_tbl_sram_slices_2_size[TF_TBL_SRAM_SLICES_MAX + 1] = {
72         [0] = TF_SRAM_SLICE_SIZE_64B, /* if 0 slices assume 1 64B block */
73         [1] = TF_SRAM_SLICE_SIZE_64B, /* 1 slice  per 64B block */
74         [2] = TF_SRAM_SLICE_SIZE_32B, /* 2 slices per 64B block */
75         [4] = TF_SRAM_SLICE_SIZE_16B, /* 4 slices per 64B block */
76         [8] = TF_SRAM_SLICE_SIZE_8B   /* 8 slices per 64B block */
77 };
78
79 /**
80  * Get SRAM Table Information for a given index table type
81  *
82  *
83  * [in] sram_handle
84  *   Pointer to SRAM handle
85  *
86  * [in] parms
87  *   Pointer to the SRAM get info parameters
88  *
89  * Returns
90  *   - (0) if successful
91  *   - (-EINVAL) on failure
92  *
93  */
94 static int tf_tbl_sram_get_info(struct tf_tbl_sram_get_info_parms *parms)
95 {
96         int rc = 0;
97         uint16_t hcapi_type;
98         uint16_t slices;
99         struct tf_rm_get_hcapi_parms hparms;
100         struct tf_rm_get_slices_parms sparms;
101
102         hparms.rm_db = parms->rm_db;
103         hparms.subtype = parms->tbl_type;
104         hparms.hcapi_type = &hcapi_type;
105
106         rc = tf_rm_get_hcapi_type(&hparms);
107         if (rc) {
108                 TFP_DRV_LOG(ERR,
109                             "%s: Failed to get hcapi_type %s, rc:%s\n",
110                             tf_dir_2_str(parms->dir),
111                             tf_tbl_type_2_str(parms->tbl_type),
112                             strerror(-rc));
113                 return rc;
114         }
115         parms->bank_id = tf_tbl_sram_hcapi_2_bank[hcapi_type];
116
117         sparms.rm_db = parms->rm_db;
118         sparms.subtype = parms->tbl_type;
119         sparms.slices = &slices;
120
121         rc = tf_rm_get_slices(&sparms);
122         if (rc) {
123                 TFP_DRV_LOG(ERR,
124                             "%s: Failed to get slice cnt %s, rc:%s\n",
125                             tf_dir_2_str(parms->dir),
126                             tf_tbl_type_2_str(parms->tbl_type),
127                             strerror(-rc));
128                 return rc;
129         }
130         if (slices)
131                 parms->slice_size = tf_tbl_sram_slices_2_size[slices];
132
133         TFP_DRV_LOG(INFO,
134                     "(%s) bank(%s) slice_size(%s)\n",
135                     tf_tbl_type_2_str(parms->tbl_type),
136                     tf_sram_bank_2_str(parms->bank_id),
137                     tf_sram_slice_2_str(parms->slice_size));
138         return rc;
139 }
140
141 int
142 tf_tbl_sram_bind(struct tf *tfp __rte_unused)
143 {
144         int rc = 0;
145         void *sram_handle = NULL;
146
147         TF_CHECK_PARMS1(tfp);
148
149         rc = tf_sram_mgr_bind(&sram_handle);
150
151         tf_session_set_sram_db(tfp, sram_handle);
152
153         TFP_DRV_LOG(INFO,
154                     "SRAM Table - initialized\n");
155
156         return rc;
157 }
158
159 int
160 tf_tbl_sram_unbind(struct tf *tfp __rte_unused)
161 {
162         int rc = 0;
163         void *sram_handle = NULL;
164
165         TF_CHECK_PARMS1(tfp);
166
167         rc = tf_session_get_sram_db(tfp, &sram_handle);
168         if (rc) {
169                 TFP_DRV_LOG(ERR,
170                             "Failed to get sram_handle from session, rc:%s\n",
171                             strerror(-rc));
172                 return rc;
173         }
174         if (sram_handle)
175                 rc = tf_sram_mgr_unbind(sram_handle);
176
177         TFP_DRV_LOG(INFO,
178                     "SRAM Table - deinitialized\n");
179         return rc;
180 }
181
182 int
183 tf_tbl_sram_alloc(struct tf *tfp,
184                   struct tf_tbl_alloc_parms *parms)
185 {
186         int rc;
187         uint16_t idx;
188         struct tf_session *tfs;
189         struct tf_dev_info *dev;
190         struct tf_tbl_sram_get_info_parms iparms = { 0 };
191         struct tf_sram_mgr_alloc_parms aparms = { 0 };
192         struct tbl_rm_db *tbl_db;
193         void *tbl_db_ptr = NULL;
194         void *sram_handle = NULL;
195
196         TF_CHECK_PARMS2(tfp, parms);
197
198         /* Retrieve the session information */
199         rc = tf_session_get(tfp, &tfs, &dev);
200         if (rc)
201                 return rc;
202
203         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
204         if (rc) {
205                 TFP_DRV_LOG(ERR,
206                             "Failed to get tbl_db from session, rc:%s\n",
207                             strerror(-rc));
208                 return rc;
209         }
210
211         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
212
213         rc = tf_session_get_sram_db(tfp, &sram_handle);
214         if (rc) {
215                 TFP_DRV_LOG(ERR,
216                             "Failed to get sram_handle from session, rc:%s\n",
217                             strerror(-rc));
218                 return rc;
219         }
220
221         iparms.rm_db = tbl_db->tbl_db[parms->dir];
222         iparms.dir = parms->dir;
223         iparms.tbl_type = parms->type;
224
225         rc = tf_tbl_sram_get_info(&iparms);
226
227         if (rc) {
228                 TFP_DRV_LOG(ERR,
229                             "%s: Failed to get SRAM info %s\n",
230                             tf_dir_2_str(parms->dir),
231                             tf_tbl_type_2_str(parms->type));
232                 return rc;
233         }
234
235         aparms.dir = parms->dir;
236         aparms.bank_id = iparms.bank_id;
237         aparms.slice_size = iparms.slice_size;
238         aparms.sram_offset = &idx;
239         aparms.tbl_type = parms->type;
240         aparms.rm_db = tbl_db->tbl_db[parms->dir];
241
242         rc = tf_sram_mgr_alloc(sram_handle, &aparms);
243         if (rc) {
244                 TFP_DRV_LOG(ERR,
245                             "%s: Failed to allocate SRAM table:%s\n",
246                             tf_dir_2_str(parms->dir),
247                             tf_tbl_type_2_str(parms->type));
248                 return rc;
249         }
250         *parms->idx = idx;
251
252 #if (DBG_SRAM == 1)
253         {
254                 struct tf_sram_mgr_dump_parms dparms;
255
256                 dparms.dir = parms->dir;
257                 dparms.bank_id = iparms.bank_id;
258                 dparms.slice_size = iparms.slice_size;
259
260                 rc = tf_sram_mgr_dump(sram_handle, &dparms);
261         }
262 #endif
263
264         return rc;
265 }
266
267 int
268 tf_tbl_sram_free(struct tf *tfp __rte_unused,
269                  struct tf_tbl_free_parms *parms)
270 {
271         int rc;
272         struct tf_session *tfs;
273         struct tf_dev_info *dev;
274         struct tbl_rm_db *tbl_db;
275         void *tbl_db_ptr = NULL;
276         struct tf_tbl_sram_get_info_parms iparms = { 0 };
277         struct tf_sram_mgr_free_parms fparms = { 0 };
278         struct tf_sram_mgr_is_allocated_parms aparms = { 0 };
279         bool allocated = false;
280         void *sram_handle = NULL;
281
282         TF_CHECK_PARMS2(tfp, parms);
283
284         /* Retrieve the session information */
285         rc = tf_session_get(tfp, &tfs, &dev);
286         if (rc)
287                 return rc;
288
289         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
290         if (rc) {
291                 TFP_DRV_LOG(ERR,
292                             "Failed to get em_ext_db from session, rc:%s\n",
293                             strerror(-rc));
294                 return rc;
295         }
296         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
297
298         rc = tf_session_get_sram_db(tfp, &sram_handle);
299         if (rc) {
300                 TFP_DRV_LOG(ERR,
301                             "Failed to get sram_handle from session, rc:%s\n",
302                             strerror(-rc));
303                 return rc;
304         }
305
306         iparms.rm_db = tbl_db->tbl_db[parms->dir];
307         iparms.dir = parms->dir;
308         iparms.tbl_type = parms->type;
309
310         rc = tf_tbl_sram_get_info(&iparms);
311         if (rc) {
312                 TFP_DRV_LOG(ERR,
313                             "%s: Failed to get table info:%s\n",
314                             tf_dir_2_str(parms->dir),
315                             tf_tbl_type_2_str(parms->type));
316                 return rc;
317         }
318
319 #if (DBG_SRAM == 1)
320         {
321                 struct tf_sram_mgr_dump_parms dparms;
322
323                 printf("%s: %s: %s\n", tf_dir_2_str(parms->dir),
324                        tf_sram_slice_2_str(iparms.slice_size),
325                        tf_sram_bank_2_str(iparms.bank_id));
326
327                 dparms.dir = parms->dir;
328                 dparms.bank_id = iparms.bank_id;
329                 dparms.slice_size = iparms.slice_size;
330
331                 rc = tf_sram_mgr_dump(sram_handle, &dparms);
332         }
333 #endif
334
335         aparms.sram_offset = parms->idx;
336         aparms.slice_size = iparms.slice_size;
337         aparms.bank_id = iparms.bank_id;
338         aparms.dir = parms->dir;
339         aparms.is_allocated = &allocated;
340
341         rc = tf_sram_mgr_is_allocated(sram_handle, &aparms);
342         if (rc || !allocated) {
343                 TFP_DRV_LOG(ERR,
344                             "%s: Free of invalid entry:%s idx(%d):(%s)\n",
345                             tf_dir_2_str(parms->dir),
346                             tf_tbl_type_2_str(parms->type),
347                             parms->idx,
348                             strerror(-rc));
349                 rc = -ENOMEM;
350                 return rc;
351         }
352
353         fparms.rm_db = tbl_db->tbl_db[parms->dir];
354         fparms.tbl_type = parms->type;
355         fparms.sram_offset = parms->idx;
356         fparms.slice_size = iparms.slice_size;
357         fparms.bank_id = iparms.bank_id;
358         fparms.dir = parms->dir;
359 #if (STATS_CLEAR_ON_READ_SUPPORT == 0)
360         fparms.tfp = tfp;
361 #endif
362         rc = tf_sram_mgr_free(sram_handle, &fparms);
363         if (rc) {
364                 TFP_DRV_LOG(ERR,
365                             "%s: Failed to free entry:%s idx(%d)\n",
366                             tf_dir_2_str(parms->dir),
367                             tf_tbl_type_2_str(parms->type),
368                             parms->idx);
369                 return rc;
370         }
371
372
373 #if (DBG_SRAM == 1)
374         {
375                 struct tf_sram_mgr_dump_parms dparms;
376
377                 printf("%s: %s: %s\n", tf_dir_2_str(parms->dir),
378                        tf_sram_slice_2_str(iparms.slice_size),
379                        tf_sram_bank_2_str(iparms.bank_id));
380
381                 dparms.dir = parms->dir;
382                 dparms.bank_id = iparms.bank_id;
383                 dparms.slice_size = iparms.slice_size;
384
385                 rc = tf_sram_mgr_dump(sram_handle, &dparms);
386         }
387 #endif
388         return rc;
389 }
390
391 int
392 tf_tbl_sram_set(struct tf *tfp,
393                 struct tf_tbl_set_parms *parms)
394 {
395         int rc;
396         bool allocated = 0;
397         uint16_t hcapi_type;
398         struct tf_rm_get_hcapi_parms hparms = { 0 };
399         struct tf_session *tfs;
400         struct tf_dev_info *dev;
401         struct tbl_rm_db *tbl_db;
402         void *tbl_db_ptr = NULL;
403         struct tf_tbl_sram_get_info_parms iparms = { 0 };
404         struct tf_sram_mgr_is_allocated_parms aparms = { 0 };
405         void *sram_handle = NULL;
406
407
408         TF_CHECK_PARMS3(tfp, parms, parms->data);
409
410         /* Retrieve the session information */
411         rc = tf_session_get(tfp, &tfs, &dev);
412         if (rc)
413                 return rc;
414
415         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
416         if (rc) {
417                 TFP_DRV_LOG(ERR,
418                             "Failed to get em_ext_db from session, rc:%s\n",
419                             strerror(-rc));
420                 return rc;
421         }
422         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
423
424         rc = tf_session_get_sram_db(tfp, &sram_handle);
425         if (rc) {
426                 TFP_DRV_LOG(ERR,
427                             "Failed to get sram_handle from session, rc:%s\n",
428                             strerror(-rc));
429                 return rc;
430         }
431
432         iparms.rm_db = tbl_db->tbl_db[parms->dir];
433         iparms.dir = parms->dir;
434         iparms.tbl_type = parms->type;
435
436         rc = tf_tbl_sram_get_info(&iparms);
437         if (rc) {
438                 TFP_DRV_LOG(ERR,
439                             "%s: Failed to get table info:%s\n",
440                             tf_dir_2_str(parms->dir),
441                             tf_tbl_type_2_str(parms->type));
442                 return rc;
443         }
444
445         aparms.sram_offset = parms->idx;
446         aparms.slice_size = iparms.slice_size;
447         aparms.bank_id = iparms.bank_id;
448         aparms.dir = parms->dir;
449         aparms.is_allocated = &allocated;
450         rc = tf_sram_mgr_is_allocated(sram_handle, &aparms);
451         if (rc || !allocated) {
452                 TFP_DRV_LOG(ERR,
453                             "%s: Entry not allocated:%s idx(%d):(%s)\n",
454                             tf_dir_2_str(parms->dir),
455                             tf_tbl_type_2_str(parms->type),
456                             parms->idx,
457                             strerror(-rc));
458                 rc = -ENOMEM;
459                 return rc;
460         }
461
462         /* Set the entry */
463         hparms.rm_db = tbl_db->tbl_db[parms->dir];
464         hparms.subtype = parms->type;
465         hparms.hcapi_type = &hcapi_type;
466         rc = tf_rm_get_hcapi_type(&hparms);
467         if (rc) {
468                 TFP_DRV_LOG(ERR,
469                             "%s, Failed type lookup, type:%s, rc:%s\n",
470                             tf_dir_2_str(parms->dir),
471                             tf_tbl_type_2_str(parms->type),
472                             strerror(-rc));
473                 return rc;
474         }
475
476         rc = tf_msg_set_tbl_entry(tfp,
477                                   parms->dir,
478                                   hcapi_type,
479                                   parms->data_sz_in_bytes,
480                                   parms->data,
481                                   parms->idx);
482         if (rc) {
483                 TFP_DRV_LOG(ERR,
484                             "%s, Set failed, type:%s, rc:%s\n",
485                             tf_dir_2_str(parms->dir),
486                             tf_tbl_type_2_str(parms->type),
487                             strerror(-rc));
488                 return rc;
489         }
490         return rc;
491 }
492
493 int
494 tf_tbl_sram_get(struct tf *tfp,
495                 struct tf_tbl_get_parms *parms)
496 {
497         int rc;
498         uint16_t hcapi_type;
499         bool allocated = 0;
500         struct tf_rm_get_hcapi_parms hparms = { 0 };
501         struct tf_session *tfs;
502         struct tf_dev_info *dev;
503         struct tbl_rm_db *tbl_db;
504         void *tbl_db_ptr = NULL;
505         struct tf_tbl_sram_get_info_parms iparms = { 0 };
506         struct tf_sram_mgr_is_allocated_parms aparms = { 0 };
507         void *sram_handle = NULL;
508
509         TF_CHECK_PARMS3(tfp, parms, parms->data);
510
511         /* Retrieve the session information */
512         rc = tf_session_get(tfp, &tfs, &dev);
513         if (rc)
514                 return rc;
515
516         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
517         if (rc) {
518                 TFP_DRV_LOG(ERR,
519                             "Failed to get em_ext_db from session, rc:%s\n",
520                             strerror(-rc));
521                 return rc;
522         }
523         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
524
525         rc = tf_session_get_sram_db(tfp, &sram_handle);
526         if (rc) {
527                 TFP_DRV_LOG(ERR,
528                             "Failed to get sram_handle from session, rc:%s\n",
529                             strerror(-rc));
530                 return rc;
531         }
532
533         iparms.rm_db = tbl_db->tbl_db[parms->dir];
534         iparms.dir = parms->dir;
535         iparms.tbl_type = parms->type;
536
537         rc = tf_tbl_sram_get_info(&iparms);
538         if (rc) {
539                 TFP_DRV_LOG(ERR,
540                             "%s: Failed to get table info:%s\n",
541                             tf_dir_2_str(parms->dir),
542                             tf_tbl_type_2_str(parms->type));
543                 return rc;
544         }
545
546         aparms.sram_offset = parms->idx;
547         aparms.slice_size = iparms.slice_size;
548         aparms.bank_id = iparms.bank_id;
549         aparms.dir = parms->dir;
550         aparms.is_allocated = &allocated;
551
552         rc = tf_sram_mgr_is_allocated(sram_handle, &aparms);
553         if (rc || !allocated) {
554                 TFP_DRV_LOG(ERR,
555                             "%s: Entry not allocated:%s idx(%d):(%s)\n",
556                             tf_dir_2_str(parms->dir),
557                             tf_tbl_type_2_str(parms->type),
558                             parms->idx,
559                             strerror(-rc));
560                 rc = -ENOMEM;
561                 return rc;
562         }
563
564         /* Get the entry */
565         hparms.rm_db = tbl_db->tbl_db[parms->dir];
566         hparms.subtype = parms->type;
567         hparms.hcapi_type = &hcapi_type;
568         rc = tf_rm_get_hcapi_type(&hparms);
569         if (rc) {
570                 TFP_DRV_LOG(ERR,
571                             "%s, Failed type lookup, type:%s, rc:%s\n",
572                             tf_dir_2_str(parms->dir),
573                             tf_tbl_type_2_str(parms->type),
574                             strerror(-rc));
575                 return rc;
576         }
577
578         /* Get the entry */
579         rc = tf_msg_get_tbl_entry(tfp,
580                                   parms->dir,
581                                   hcapi_type,
582                                   parms->data_sz_in_bytes,
583                                   parms->data,
584                                   parms->idx);
585         if (rc) {
586                 TFP_DRV_LOG(ERR,
587                             "%s, Get failed, type:%s, rc:%s\n",
588                             tf_dir_2_str(parms->dir),
589                             tf_tbl_type_2_str(parms->type),
590                             strerror(-rc));
591                 return rc;
592         }
593         return rc;
594 }
595
596 int
597 tf_tbl_sram_bulk_get(struct tf *tfp,
598                      struct tf_tbl_get_bulk_parms *parms)
599 {
600         int rc;
601         uint16_t hcapi_type;
602         struct tf_rm_get_hcapi_parms hparms = { 0 };
603         struct tf_tbl_sram_get_info_parms iparms = { 0 };
604         struct tf_session *tfs;
605         struct tf_dev_info *dev;
606         struct tbl_rm_db *tbl_db;
607         void *tbl_db_ptr = NULL;
608         uint16_t idx;
609         struct tf_sram_mgr_is_allocated_parms aparms = { 0 };
610         bool allocated = false;
611         void *sram_handle = NULL;
612
613         TF_CHECK_PARMS2(tfp, parms);
614
615         /* Retrieve the session information */
616         rc = tf_session_get(tfp, &tfs, &dev);
617         if (rc)
618                 return rc;
619
620         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
621         if (rc) {
622                 TFP_DRV_LOG(ERR,
623                             "Failed to get em_ext_db from session, rc:%s\n",
624                             strerror(-rc));
625                 return rc;
626         }
627         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
628
629         rc = tf_session_get_sram_db(tfp, &sram_handle);
630         if (rc) {
631                 TFP_DRV_LOG(ERR,
632                             "Failed to get sram_handle from session, rc:%s\n",
633                             strerror(-rc));
634                 return rc;
635         }
636
637         iparms.rm_db = tbl_db->tbl_db[parms->dir];
638         iparms.dir = parms->dir;
639         iparms.tbl_type = parms->type;
640
641         rc = tf_tbl_sram_get_info(&iparms);
642         if (rc) {
643                 TFP_DRV_LOG(ERR,
644                             "%s: Failed to get table info:%s\n",
645                             tf_dir_2_str(parms->dir),
646                             tf_tbl_type_2_str(parms->type));
647                 return rc;
648         }
649
650         /* Validate the start offset and the end offset is allocated
651          * This API is only used for statistics.  8 Byte entry allocation
652          * is used to verify
653          */
654         aparms.sram_offset = parms->starting_idx;
655         aparms.slice_size = iparms.slice_size;
656         aparms.bank_id = iparms.bank_id;
657         aparms.dir = parms->dir;
658         aparms.is_allocated = &allocated;
659         rc = tf_sram_mgr_is_allocated(sram_handle, &aparms);
660         if (rc || !allocated) {
661                 TFP_DRV_LOG(ERR,
662                             "%s: Entry not allocated:%s starting_idx(%d):(%s)\n",
663                             tf_dir_2_str(parms->dir),
664                             tf_tbl_type_2_str(parms->type),
665                             parms->starting_idx,
666                             strerror(-rc));
667                 rc = -ENOMEM;
668                 return rc;
669         }
670         idx = parms->starting_idx + parms->num_entries - 1;
671         aparms.sram_offset = idx;
672         rc = tf_sram_mgr_is_allocated(sram_handle, &aparms);
673         if (rc || !allocated) {
674                 TFP_DRV_LOG(ERR,
675                             "%s: Entry not allocated:%s last_idx(%d):(%s)\n",
676                             tf_dir_2_str(parms->dir),
677                             tf_tbl_type_2_str(parms->type),
678                             idx,
679                             strerror(-rc));
680                 rc = -ENOMEM;
681                 return rc;
682         }
683
684         hparms.rm_db = tbl_db->tbl_db[parms->dir];
685         hparms.subtype = parms->type;
686         hparms.hcapi_type = &hcapi_type;
687         rc = tf_rm_get_hcapi_type(&hparms);
688         if (rc) {
689                 TFP_DRV_LOG(ERR,
690                             "%s, Failed type lookup, type:%s, rc:%s\n",
691                             tf_dir_2_str(parms->dir),
692                             tf_tbl_type_2_str(parms->type),
693                             strerror(-rc));
694                 return rc;
695         }
696
697         /* Get the entries */
698         rc = tf_msg_bulk_get_tbl_entry(tfp,
699                                        parms->dir,
700                                        hcapi_type,
701                                        parms->starting_idx,
702                                        parms->num_entries,
703                                        parms->entry_sz_in_bytes,
704                                        parms->physical_mem_addr);
705         if (rc) {
706                 TFP_DRV_LOG(ERR,
707                             "%s, Bulk get failed, type:%s, rc:%s\n",
708                             tf_dir_2_str(parms->dir),
709                             tf_tbl_type_2_str(parms->type),
710                             strerror(-rc));
711         }
712         return rc;
713 }