net/bnxt: add shadow and search capability to TCAM
[dpdk.git] / drivers / net / bnxt / tf_core / tf_core.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #include <stdio.h>
7
8 #include "tf_core.h"
9 #include "tf_util.h"
10 #include "tf_session.h"
11 #include "tf_tbl.h"
12 #include "tf_em.h"
13 #include "tf_rm.h"
14 #include "tf_global_cfg.h"
15 #include "tf_msg.h"
16 #include "tfp.h"
17 #include "bitalloc.h"
18 #include "bnxt.h"
19 #include "rand.h"
20 #include "tf_common.h"
21 #include "hwrm_tf.h"
22
23 int
24 tf_open_session(struct tf *tfp,
25                 struct tf_open_session_parms *parms)
26 {
27         int rc;
28         unsigned int domain, bus, slot, device;
29         struct tf_session_open_session_parms oparms;
30
31         TF_CHECK_PARMS2(tfp, parms);
32
33         /* Filter out any non-supported device types on the Core
34          * side. It is assumed that the Firmware will be supported if
35          * firmware open session succeeds.
36          */
37         if (parms->device_type != TF_DEVICE_TYPE_WH) {
38                 TFP_DRV_LOG(ERR,
39                             "Unsupported device type %d\n",
40                             parms->device_type);
41                 return -ENOTSUP;
42         }
43
44         /* Verify control channel and build the beginning of session_id */
45         rc = sscanf(parms->ctrl_chan_name,
46                     "%x:%x:%x.%d",
47                     &domain,
48                     &bus,
49                     &slot,
50                     &device);
51         if (rc != 4) {
52                 /* PCI Domain not provided (optional in DPDK), thus we
53                  * force domain to 0 and recheck.
54                  */
55                 domain = 0;
56
57                 /* Check parsing of bus/slot/device */
58                 rc = sscanf(parms->ctrl_chan_name,
59                             "%x:%x.%d",
60                             &bus,
61                             &slot,
62                             &device);
63                 if (rc != 3) {
64                         TFP_DRV_LOG(ERR,
65                             "Failed to scan device ctrl_chan_name\n");
66                         return -EINVAL;
67                 }
68         }
69
70         parms->session_id.internal.domain = domain;
71         parms->session_id.internal.bus = bus;
72         parms->session_id.internal.device = device;
73         oparms.open_cfg = parms;
74
75         /* Session vs session client is decided in
76          * tf_session_open_session()
77          */
78         printf("TF_OPEN, %s\n", parms->ctrl_chan_name);
79         rc = tf_session_open_session(tfp, &oparms);
80         /* Logging handled by tf_session_open_session */
81         if (rc)
82                 return rc;
83
84         TFP_DRV_LOG(INFO,
85                     "domain:%d, bus:%d, device:%d\n",
86                     parms->session_id.internal.domain,
87                     parms->session_id.internal.bus,
88                     parms->session_id.internal.device);
89
90         return 0;
91 }
92
93 int
94 tf_attach_session(struct tf *tfp,
95                   struct tf_attach_session_parms *parms)
96 {
97         int rc;
98         unsigned int domain, bus, slot, device;
99         struct tf_session_attach_session_parms aparms;
100
101         TF_CHECK_PARMS2(tfp, parms);
102
103         /* Verify control channel */
104         rc = sscanf(parms->ctrl_chan_name,
105                     "%x:%x:%x.%d",
106                     &domain,
107                     &bus,
108                     &slot,
109                     &device);
110         if (rc != 4) {
111                 TFP_DRV_LOG(ERR,
112                             "Failed to scan device ctrl_chan_name\n");
113                 return -EINVAL;
114         }
115
116         /* Verify 'attach' channel */
117         rc = sscanf(parms->attach_chan_name,
118                     "%x:%x:%x.%d",
119                     &domain,
120                     &bus,
121                     &slot,
122                     &device);
123         if (rc != 4) {
124                 TFP_DRV_LOG(ERR,
125                             "Failed to scan device attach_chan_name\n");
126                 return -EINVAL;
127         }
128
129         /* Prepare return value of session_id, using ctrl_chan_name
130          * device values as it becomes the session id.
131          */
132         parms->session_id.internal.domain = domain;
133         parms->session_id.internal.bus = bus;
134         parms->session_id.internal.device = device;
135         aparms.attach_cfg = parms;
136         rc = tf_session_attach_session(tfp,
137                                        &aparms);
138         /* Logging handled by dev_bind */
139         if (rc)
140                 return rc;
141
142         TFP_DRV_LOG(INFO,
143                     "Attached to session, session_id:%d\n",
144                     parms->session_id.id);
145
146         TFP_DRV_LOG(INFO,
147                     "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
148                     parms->session_id.internal.domain,
149                     parms->session_id.internal.bus,
150                     parms->session_id.internal.device,
151                     parms->session_id.internal.fw_session_id);
152
153         return rc;
154 }
155
156 int
157 tf_close_session(struct tf *tfp)
158 {
159         int rc;
160         struct tf_session_close_session_parms cparms = { 0 };
161         union tf_session_id session_id = { 0 };
162         uint8_t ref_count;
163
164         TF_CHECK_PARMS1(tfp);
165
166         cparms.ref_count = &ref_count;
167         cparms.session_id = &session_id;
168         /* Session vs session client is decided in
169          * tf_session_close_session()
170          */
171         rc = tf_session_close_session(tfp,
172                                       &cparms);
173         /* Logging handled by tf_session_close_session */
174         if (rc)
175                 return rc;
176
177         TFP_DRV_LOG(INFO,
178                     "domain:%d, bus:%d, device:%d\n",
179                     cparms.session_id->internal.domain,
180                     cparms.session_id->internal.bus,
181                     cparms.session_id->internal.device);
182
183         return rc;
184 }
185
186 /** insert EM hash entry API
187  *
188  *    returns:
189  *    0       - Success
190  *    -EINVAL - Error
191  */
192 int tf_insert_em_entry(struct tf *tfp,
193                        struct tf_insert_em_entry_parms *parms)
194 {
195         struct tf_session      *tfs;
196         struct tf_dev_info     *dev;
197         int rc;
198
199         TF_CHECK_PARMS2(tfp, parms);
200
201         /* Retrieve the session information */
202         rc = tf_session_get_session(tfp, &tfs);
203         if (rc) {
204                 TFP_DRV_LOG(ERR,
205                             "%s: Failed to lookup session, rc:%s\n",
206                             tf_dir_2_str(parms->dir),
207                             strerror(-rc));
208                 return rc;
209         }
210
211         /* Retrieve the device information */
212         rc = tf_session_get_device(tfs, &dev);
213         if (rc) {
214                 TFP_DRV_LOG(ERR,
215                             "%s: Failed to lookup device, rc:%s\n",
216                             tf_dir_2_str(parms->dir),
217                             strerror(-rc));
218                 return rc;
219         }
220
221         if (parms->mem == TF_MEM_EXTERNAL &&
222                 dev->ops->tf_dev_insert_ext_em_entry != NULL)
223                 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
224         else if (parms->mem == TF_MEM_INTERNAL &&
225                 dev->ops->tf_dev_insert_int_em_entry != NULL)
226                 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
227         else
228                 return -EINVAL;
229
230         if (rc) {
231                 TFP_DRV_LOG(ERR,
232                             "%s: EM insert failed, rc:%s\n",
233                             tf_dir_2_str(parms->dir),
234                             strerror(-rc));
235                 return rc;
236         }
237
238         return 0;
239 }
240
241 /** Delete EM hash entry API
242  *
243  *    returns:
244  *    0       - Success
245  *    -EINVAL - Error
246  */
247 int tf_delete_em_entry(struct tf *tfp,
248                        struct tf_delete_em_entry_parms *parms)
249 {
250         struct tf_session      *tfs;
251         struct tf_dev_info     *dev;
252         int rc;
253
254         TF_CHECK_PARMS2(tfp, parms);
255
256         /* Retrieve the session information */
257         rc = tf_session_get_session(tfp, &tfs);
258         if (rc) {
259                 TFP_DRV_LOG(ERR,
260                             "%s: Failed to lookup session, rc:%s\n",
261                             tf_dir_2_str(parms->dir),
262                             strerror(-rc));
263                 return rc;
264         }
265
266         /* Retrieve the device information */
267         rc = tf_session_get_device(tfs, &dev);
268         if (rc) {
269                 TFP_DRV_LOG(ERR,
270                             "%s: Failed to lookup device, rc:%s\n",
271                             tf_dir_2_str(parms->dir),
272                             strerror(-rc));
273                 return rc;
274         }
275
276         if (parms->mem == TF_MEM_EXTERNAL)
277                 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
278         else if (parms->mem == TF_MEM_INTERNAL)
279                 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
280         else
281                 return -EINVAL;
282
283         if (rc) {
284                 TFP_DRV_LOG(ERR,
285                             "%s: EM delete failed, rc:%s\n",
286                             tf_dir_2_str(parms->dir),
287                             strerror(-rc));
288                 return rc;
289         }
290
291         return rc;
292 }
293
294 /** Get global configuration API
295  *
296  *    returns:
297  *    0       - Success
298  *    -EINVAL - Error
299  */
300 int tf_get_global_cfg(struct tf *tfp,
301                       struct tf_global_cfg_parms *parms)
302 {
303         int rc = 0;
304         struct tf_session *tfs;
305         struct tf_dev_info *dev;
306         struct tf_dev_global_cfg_parms gparms = { 0 };
307
308         TF_CHECK_PARMS2(tfp, parms);
309
310         /* Retrieve the session information */
311         rc = tf_session_get_session(tfp, &tfs);
312         if (rc) {
313                 TFP_DRV_LOG(ERR,
314                             "%s: Failed to lookup session, rc:%s\n",
315                             tf_dir_2_str(parms->dir),
316                             strerror(-rc));
317                 return rc;
318         }
319
320         /* Retrieve the device information */
321         rc = tf_session_get_device(tfs, &dev);
322         if (rc) {
323                 TFP_DRV_LOG(ERR,
324                             "%s: Failed to lookup device, rc:%s\n",
325                             tf_dir_2_str(parms->dir),
326                             strerror(-rc));
327                 return rc;
328         }
329
330         if (parms->config == NULL ||
331            parms->config_sz_in_bytes == 0) {
332                 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
333                 return -EINVAL;
334         }
335
336         if (dev->ops->tf_dev_get_global_cfg == NULL) {
337                 rc = -EOPNOTSUPP;
338                 TFP_DRV_LOG(ERR,
339                             "%s: Operation not supported, rc:%s\n",
340                             tf_dir_2_str(parms->dir),
341                             strerror(-rc));
342                 return -EOPNOTSUPP;
343         }
344
345         gparms.dir = parms->dir;
346         gparms.type = parms->type;
347         gparms.offset = parms->offset;
348         gparms.config = parms->config;
349         gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
350         rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
351         if (rc) {
352                 TFP_DRV_LOG(ERR,
353                             "%s: Global Cfg get failed, rc:%s\n",
354                             tf_dir_2_str(parms->dir),
355                             strerror(-rc));
356                 return rc;
357         }
358
359         return rc;
360 }
361
362 /** Set global configuration API
363  *
364  *    returns:
365  *    0       - Success
366  *    -EINVAL - Error
367  */
368 int tf_set_global_cfg(struct tf *tfp,
369                       struct tf_global_cfg_parms *parms)
370 {
371         int rc = 0;
372         struct tf_session *tfs;
373         struct tf_dev_info *dev;
374         struct tf_dev_global_cfg_parms gparms = { 0 };
375
376         TF_CHECK_PARMS2(tfp, parms);
377
378         /* Retrieve the session information */
379         rc = tf_session_get_session(tfp, &tfs);
380         if (rc) {
381                 TFP_DRV_LOG(ERR,
382                             "%s: Failed to lookup session, rc:%s\n",
383                             tf_dir_2_str(parms->dir),
384                             strerror(-rc));
385                 return rc;
386         }
387
388         /* Retrieve the device information */
389         rc = tf_session_get_device(tfs, &dev);
390         if (rc) {
391                 TFP_DRV_LOG(ERR,
392                             "%s: Failed to lookup device, rc:%s\n",
393                             tf_dir_2_str(parms->dir),
394                             strerror(-rc));
395                 return rc;
396         }
397
398         if (parms->config == NULL ||
399            parms->config_sz_in_bytes == 0) {
400                 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
401                 return -EINVAL;
402         }
403
404         if (dev->ops->tf_dev_set_global_cfg == NULL) {
405                 rc = -EOPNOTSUPP;
406                 TFP_DRV_LOG(ERR,
407                             "%s: Operation not supported, rc:%s\n",
408                             tf_dir_2_str(parms->dir),
409                             strerror(-rc));
410                 return -EOPNOTSUPP;
411         }
412
413         gparms.dir = parms->dir;
414         gparms.type = parms->type;
415         gparms.offset = parms->offset;
416         gparms.config = parms->config;
417         gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
418         rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
419         if (rc) {
420                 TFP_DRV_LOG(ERR,
421                             "%s: Global Cfg set failed, rc:%s\n",
422                             tf_dir_2_str(parms->dir),
423                             strerror(-rc));
424                 return rc;
425         }
426
427         return rc;
428 }
429
430 int
431 tf_alloc_identifier(struct tf *tfp,
432                     struct tf_alloc_identifier_parms *parms)
433 {
434         int rc;
435         struct tf_session *tfs;
436         struct tf_dev_info *dev;
437         struct tf_ident_alloc_parms aparms;
438         uint16_t id;
439
440         TF_CHECK_PARMS2(tfp, parms);
441
442         /* Can't do static initialization due to UT enum check */
443         memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
444
445         /* Retrieve the session information */
446         rc = tf_session_get_session(tfp, &tfs);
447         if (rc) {
448                 TFP_DRV_LOG(ERR,
449                             "%s: Failed to lookup session, rc:%s\n",
450                             tf_dir_2_str(parms->dir),
451                             strerror(-rc));
452                 return rc;
453         }
454
455         /* Retrieve the device information */
456         rc = tf_session_get_device(tfs, &dev);
457         if (rc) {
458                 TFP_DRV_LOG(ERR,
459                             "%s: Failed to lookup device, rc:%s\n",
460                             tf_dir_2_str(parms->dir),
461                             strerror(-rc));
462                 return rc;
463         }
464
465         if (dev->ops->tf_dev_alloc_ident == NULL) {
466                 rc = -EOPNOTSUPP;
467                 TFP_DRV_LOG(ERR,
468                             "%s: Operation not supported, rc:%s\n",
469                             tf_dir_2_str(parms->dir),
470                             strerror(-rc));
471                 return -EOPNOTSUPP;
472         }
473
474         aparms.dir = parms->dir;
475         aparms.type = parms->ident_type;
476         aparms.id = &id;
477         rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
478         if (rc) {
479                 TFP_DRV_LOG(ERR,
480                             "%s: Identifier allocation failed, rc:%s\n",
481                             tf_dir_2_str(parms->dir),
482                             strerror(-rc));
483                 return rc;
484         }
485
486         parms->id = id;
487
488         return 0;
489 }
490
491 int
492 tf_free_identifier(struct tf *tfp,
493                    struct tf_free_identifier_parms *parms)
494 {
495         int rc;
496         struct tf_session *tfs;
497         struct tf_dev_info *dev;
498         struct tf_ident_free_parms fparms;
499
500         TF_CHECK_PARMS2(tfp, parms);
501
502         /* Can't do static initialization due to UT enum check */
503         memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
504
505         /* Retrieve the session information */
506         rc = tf_session_get_session(tfp, &tfs);
507         if (rc) {
508                 TFP_DRV_LOG(ERR,
509                             "%s: Failed to lookup session, rc:%s\n",
510                             tf_dir_2_str(parms->dir),
511                             strerror(-rc));
512                 return rc;
513         }
514
515         /* Retrieve the device information */
516         rc = tf_session_get_device(tfs, &dev);
517         if (rc) {
518                 TFP_DRV_LOG(ERR,
519                             "%s: Failed to lookup device, rc:%s\n",
520                             tf_dir_2_str(parms->dir),
521                             strerror(-rc));
522                 return rc;
523         }
524
525         if (dev->ops->tf_dev_free_ident == NULL) {
526                 rc = -EOPNOTSUPP;
527                 TFP_DRV_LOG(ERR,
528                             "%s: Operation not supported, rc:%s\n",
529                             tf_dir_2_str(parms->dir),
530                             strerror(-rc));
531                 return -EOPNOTSUPP;
532         }
533
534         fparms.dir = parms->dir;
535         fparms.type = parms->ident_type;
536         fparms.id = parms->id;
537         fparms.ref_cnt = &parms->ref_cnt;
538         rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
539         if (rc) {
540                 TFP_DRV_LOG(ERR,
541                             "%s: Identifier free failed, rc:%s\n",
542                             tf_dir_2_str(parms->dir),
543                             strerror(-rc));
544                 return rc;
545         }
546
547         return 0;
548 }
549
550 int
551 tf_search_identifier(struct tf *tfp,
552                      struct tf_search_identifier_parms *parms)
553 {
554         int rc;
555         struct tf_session *tfs;
556         struct tf_dev_info *dev;
557         struct tf_ident_search_parms sparms;
558
559         TF_CHECK_PARMS2(tfp, parms);
560
561         /* Can't do static initialization due to UT enum check */
562         memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
563
564         /* Retrieve the session information */
565         rc = tf_session_get_session(tfp, &tfs);
566         if (rc) {
567                 TFP_DRV_LOG(ERR,
568                             "%s: Failed to lookup session, rc:%s\n",
569                             tf_dir_2_str(parms->dir),
570                             strerror(-rc));
571                 return rc;
572         }
573
574         /* Retrieve the device information */
575         rc = tf_session_get_device(tfs, &dev);
576         if (rc) {
577                 TFP_DRV_LOG(ERR,
578                             "%s: Failed to lookup device, rc:%s\n",
579                             tf_dir_2_str(parms->dir),
580                             strerror(-rc));
581                 return rc;
582         }
583
584         if (dev->ops->tf_dev_search_ident == NULL) {
585                 rc = -EOPNOTSUPP;
586                 TFP_DRV_LOG(ERR,
587                             "%s: Operation not supported, rc:%s\n",
588                             tf_dir_2_str(parms->dir),
589                             strerror(-rc));
590                 return rc;
591         }
592
593         sparms.dir = parms->dir;
594         sparms.type = parms->ident_type;
595         sparms.search_id = parms->search_id;
596         sparms.hit = &parms->hit;
597         sparms.ref_cnt = &parms->ref_cnt;
598         rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
599         if (rc) {
600                 TFP_DRV_LOG(ERR,
601                             "%s: Identifier search failed, rc:%s\n",
602                             tf_dir_2_str(parms->dir),
603                             strerror(-rc));
604                 return rc;
605         }
606
607         return 0;
608 }
609
610 int
611 tf_search_tcam_entry(struct tf *tfp,
612                      struct tf_search_tcam_entry_parms *parms)
613 {
614         int rc;
615         struct tf_session *tfs;
616         struct tf_dev_info *dev;
617         struct tf_tcam_alloc_search_parms sparms;
618
619         TF_CHECK_PARMS2(tfp, parms);
620
621         memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
622
623         /* Retrieve the session information */
624         rc = tf_session_get_session(tfp, &tfs);
625         if (rc) {
626                 TFP_DRV_LOG(ERR,
627                             "%s: Failed to lookup session, rc:%s\n",
628                             tf_dir_2_str(parms->dir),
629                             strerror(-rc));
630                 return rc;
631         }
632
633         /* Retrieve the device information */
634         rc = tf_session_get_device(tfs, &dev);
635         if (rc) {
636                 TFP_DRV_LOG(ERR,
637                             "%s: Failed to lookup device, rc:%s\n",
638                             tf_dir_2_str(parms->dir),
639                             strerror(-rc));
640                 return rc;
641         }
642
643         if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
644                 rc = -EOPNOTSUPP;
645                 TFP_DRV_LOG(ERR,
646                             "%s: Operation not supported, rc:%s\n",
647                             tf_dir_2_str(parms->dir),
648                             strerror(-rc));
649                 return rc;
650         }
651
652         sparms.dir = parms->dir;
653         sparms.type = parms->tcam_tbl_type;
654         sparms.key = parms->key;
655         sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
656         sparms.mask = parms->mask;
657         sparms.priority = parms->priority;
658         sparms.alloc = parms->alloc;
659
660         /* Result is an in/out and so no need to copy during outputs */
661         sparms.result = parms->result;
662         sparms.result_size =
663                 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
664
665         rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
666         if (rc) {
667                 TFP_DRV_LOG(ERR,
668                             "%s: TCAM allocation failed, rc:%s\n",
669                             tf_dir_2_str(parms->dir),
670                             strerror(-rc));
671                 return rc;
672         }
673
674         /* Copy the outputs */
675         parms->hit = sparms.hit;
676         parms->search_status = sparms.search_status;
677         parms->ref_cnt = sparms.ref_cnt;
678         parms->idx = sparms.idx;
679
680         return 0;
681 }
682
683 int
684 tf_alloc_tcam_entry(struct tf *tfp,
685                     struct tf_alloc_tcam_entry_parms *parms)
686 {
687         int rc;
688         struct tf_session *tfs;
689         struct tf_dev_info *dev;
690         struct tf_tcam_alloc_parms aparms;
691
692         TF_CHECK_PARMS2(tfp, parms);
693
694         memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
695
696         /* Retrieve the session information */
697         rc = tf_session_get_session(tfp, &tfs);
698         if (rc) {
699                 TFP_DRV_LOG(ERR,
700                             "%s: Failed to lookup session, rc:%s\n",
701                             tf_dir_2_str(parms->dir),
702                             strerror(-rc));
703                 return rc;
704         }
705
706         /* Retrieve the device information */
707         rc = tf_session_get_device(tfs, &dev);
708         if (rc) {
709                 TFP_DRV_LOG(ERR,
710                             "%s: Failed to lookup device, rc:%s\n",
711                             tf_dir_2_str(parms->dir),
712                             strerror(-rc));
713                 return rc;
714         }
715
716         if (dev->ops->tf_dev_alloc_tcam == NULL) {
717                 rc = -EOPNOTSUPP;
718                 TFP_DRV_LOG(ERR,
719                             "%s: Operation not supported, rc:%s\n",
720                             tf_dir_2_str(parms->dir),
721                             strerror(-rc));
722                 return rc;
723         }
724
725         aparms.dir = parms->dir;
726         aparms.type = parms->tcam_tbl_type;
727         aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
728         aparms.priority = parms->priority;
729         rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
730         if (rc) {
731                 TFP_DRV_LOG(ERR,
732                             "%s: TCAM allocation failed, rc:%s\n",
733                             tf_dir_2_str(parms->dir),
734                             strerror(-rc));
735                 return rc;
736         }
737
738         parms->idx = aparms.idx;
739
740         return 0;
741 }
742
743 int
744 tf_set_tcam_entry(struct tf *tfp,
745                   struct tf_set_tcam_entry_parms *parms)
746 {
747         int rc;
748         struct tf_session *tfs;
749         struct tf_dev_info *dev;
750         struct tf_tcam_set_parms sparms;
751
752         TF_CHECK_PARMS2(tfp, parms);
753
754         memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
755
756
757         /* Retrieve the session information */
758         rc = tf_session_get_session(tfp, &tfs);
759         if (rc) {
760                 TFP_DRV_LOG(ERR,
761                             "%s: Failed to lookup session, rc:%s\n",
762                             tf_dir_2_str(parms->dir),
763                             strerror(-rc));
764                 return rc;
765         }
766
767         /* Retrieve the device information */
768         rc = tf_session_get_device(tfs, &dev);
769         if (rc) {
770                 TFP_DRV_LOG(ERR,
771                             "%s: Failed to lookup device, rc:%s\n",
772                             tf_dir_2_str(parms->dir),
773                             strerror(-rc));
774                 return rc;
775         }
776
777         if (dev->ops->tf_dev_set_tcam == NULL) {
778                 rc = -EOPNOTSUPP;
779                 TFP_DRV_LOG(ERR,
780                             "%s: Operation not supported, rc:%s\n",
781                             tf_dir_2_str(parms->dir),
782                             strerror(-rc));
783                 return rc;
784         }
785
786         sparms.dir = parms->dir;
787         sparms.type = parms->tcam_tbl_type;
788         sparms.idx = parms->idx;
789         sparms.key = parms->key;
790         sparms.mask = parms->mask;
791         sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
792         sparms.result = parms->result;
793         sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
794
795         rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
796         if (rc) {
797                 TFP_DRV_LOG(ERR,
798                             "%s: TCAM set failed, rc:%s\n",
799                             tf_dir_2_str(parms->dir),
800                             strerror(-rc));
801                 return rc;
802         }
803
804         return 0;
805 }
806
807 int
808 tf_get_tcam_entry(struct tf *tfp __rte_unused,
809                   struct tf_get_tcam_entry_parms *parms __rte_unused)
810 {
811         TF_CHECK_PARMS2(tfp, parms);
812         return -EOPNOTSUPP;
813 }
814
815 int
816 tf_free_tcam_entry(struct tf *tfp,
817                    struct tf_free_tcam_entry_parms *parms)
818 {
819         int rc;
820         struct tf_session *tfs;
821         struct tf_dev_info *dev;
822         struct tf_tcam_free_parms fparms;
823
824         TF_CHECK_PARMS2(tfp, parms);
825
826         memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
827
828         /* Retrieve the session information */
829         rc = tf_session_get_session(tfp, &tfs);
830         if (rc) {
831                 TFP_DRV_LOG(ERR,
832                             "%s: Failed to lookup session, rc:%s\n",
833                             tf_dir_2_str(parms->dir),
834                             strerror(-rc));
835                 return rc;
836         }
837
838         /* Retrieve the device information */
839         rc = tf_session_get_device(tfs, &dev);
840         if (rc) {
841                 TFP_DRV_LOG(ERR,
842                             "%s: Failed to lookup device, rc:%s\n",
843                             tf_dir_2_str(parms->dir),
844                             strerror(-rc));
845                 return rc;
846         }
847
848         if (dev->ops->tf_dev_free_tcam == NULL) {
849                 rc = -EOPNOTSUPP;
850                 TFP_DRV_LOG(ERR,
851                             "%s: Operation not supported, rc:%s\n",
852                             tf_dir_2_str(parms->dir),
853                             strerror(-rc));
854                 return rc;
855         }
856
857         fparms.dir = parms->dir;
858         fparms.type = parms->tcam_tbl_type;
859         fparms.idx = parms->idx;
860         rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
861         if (rc) {
862                 TFP_DRV_LOG(ERR,
863                             "%s: TCAM free failed, rc:%s\n",
864                             tf_dir_2_str(parms->dir),
865                             strerror(-rc));
866                 return rc;
867         }
868
869         return 0;
870 }
871
872 int
873 tf_alloc_tbl_entry(struct tf *tfp,
874                    struct tf_alloc_tbl_entry_parms *parms)
875 {
876         int rc;
877         struct tf_session *tfs;
878         struct tf_dev_info *dev;
879         struct tf_tbl_alloc_parms aparms;
880         uint32_t idx;
881
882         TF_CHECK_PARMS2(tfp, parms);
883
884         /* Can't do static initialization due to UT enum check */
885         memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
886
887         /* Retrieve the session information */
888         rc = tf_session_get_session(tfp, &tfs);
889         if (rc) {
890                 TFP_DRV_LOG(ERR,
891                             "%s: Failed to lookup session, rc:%s\n",
892                             tf_dir_2_str(parms->dir),
893                             strerror(-rc));
894                 return rc;
895         }
896
897         /* Retrieve the device information */
898         rc = tf_session_get_device(tfs, &dev);
899         if (rc) {
900                 TFP_DRV_LOG(ERR,
901                             "%s: Failed to lookup device, rc:%s\n",
902                             tf_dir_2_str(parms->dir),
903                             strerror(-rc));
904                 return rc;
905         }
906
907         aparms.dir = parms->dir;
908         aparms.type = parms->type;
909         aparms.idx = &idx;
910         aparms.tbl_scope_id = parms->tbl_scope_id;
911
912         if (parms->type == TF_TBL_TYPE_EXT) {
913                 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
914                         rc = -EOPNOTSUPP;
915                         TFP_DRV_LOG(ERR,
916                                     "%s: Operation not supported, rc:%s\n",
917                                     tf_dir_2_str(parms->dir),
918                                     strerror(-rc));
919                         return -EOPNOTSUPP;
920                 }
921
922                 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
923                 if (rc) {
924                         TFP_DRV_LOG(ERR,
925                                     "%s: External table allocation failed, rc:%s\n",
926                                     tf_dir_2_str(parms->dir),
927                                     strerror(-rc));
928                         return rc;
929                 }
930
931         } else {
932                 if (dev->ops->tf_dev_alloc_tbl == NULL) {
933                         rc = -EOPNOTSUPP;
934                         TFP_DRV_LOG(ERR,
935                                     "%s: Operation not supported, rc:%s\n",
936                                     tf_dir_2_str(parms->dir),
937                                     strerror(-rc));
938                         return -EOPNOTSUPP;
939                 }
940
941                 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
942                 if (rc) {
943                         TFP_DRV_LOG(ERR,
944                                     "%s: Table allocation failed, rc:%s\n",
945                                     tf_dir_2_str(parms->dir),
946                                     strerror(-rc));
947                         return rc;
948                 }
949         }
950
951         parms->idx = idx;
952
953         return 0;
954 }
955
956 int
957 tf_free_tbl_entry(struct tf *tfp,
958                   struct tf_free_tbl_entry_parms *parms)
959 {
960         int rc;
961         struct tf_session *tfs;
962         struct tf_dev_info *dev;
963         struct tf_tbl_free_parms fparms;
964
965         TF_CHECK_PARMS2(tfp, parms);
966
967         /* Can't do static initialization due to UT enum check */
968         memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
969
970         /* Retrieve the session information */
971         rc = tf_session_get_session(tfp, &tfs);
972         if (rc) {
973                 TFP_DRV_LOG(ERR,
974                             "%s: Failed to lookup session, rc:%s\n",
975                             tf_dir_2_str(parms->dir),
976                             strerror(-rc));
977                 return rc;
978         }
979
980         /* Retrieve the device information */
981         rc = tf_session_get_device(tfs, &dev);
982         if (rc) {
983                 TFP_DRV_LOG(ERR,
984                             "%s: Failed to lookup device, rc:%s\n",
985                             tf_dir_2_str(parms->dir),
986                             strerror(-rc));
987                 return rc;
988         }
989
990         fparms.dir = parms->dir;
991         fparms.type = parms->type;
992         fparms.idx = parms->idx;
993         fparms.tbl_scope_id = parms->tbl_scope_id;
994
995         if (parms->type == TF_TBL_TYPE_EXT) {
996                 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
997                         rc = -EOPNOTSUPP;
998                         TFP_DRV_LOG(ERR,
999                                     "%s: Operation not supported, rc:%s\n",
1000                                     tf_dir_2_str(parms->dir),
1001                                     strerror(-rc));
1002                         return -EOPNOTSUPP;
1003                 }
1004
1005                 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1006                 if (rc) {
1007                         TFP_DRV_LOG(ERR,
1008                                     "%s: Table free failed, rc:%s\n",
1009                                     tf_dir_2_str(parms->dir),
1010                                     strerror(-rc));
1011                         return rc;
1012                 }
1013         } else {
1014                 if (dev->ops->tf_dev_free_tbl == NULL) {
1015                         rc = -EOPNOTSUPP;
1016                         TFP_DRV_LOG(ERR,
1017                                     "%s: Operation not supported, rc:%s\n",
1018                                     tf_dir_2_str(parms->dir),
1019                                     strerror(-rc));
1020                         return -EOPNOTSUPP;
1021                 }
1022
1023                 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1024                 if (rc) {
1025                         TFP_DRV_LOG(ERR,
1026                                     "%s: Table free failed, rc:%s\n",
1027                                     tf_dir_2_str(parms->dir),
1028                                     strerror(-rc));
1029                         return rc;
1030                 }
1031         }
1032
1033         return 0;
1034 }
1035
1036 int
1037 tf_set_tbl_entry(struct tf *tfp,
1038                  struct tf_set_tbl_entry_parms *parms)
1039 {
1040         int rc = 0;
1041         struct tf_session *tfs;
1042         struct tf_dev_info *dev;
1043         struct tf_tbl_set_parms sparms;
1044
1045         TF_CHECK_PARMS3(tfp, parms, parms->data);
1046
1047         /* Can't do static initialization due to UT enum check */
1048         memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1049
1050         /* Retrieve the session information */
1051         rc = tf_session_get_session(tfp, &tfs);
1052         if (rc) {
1053                 TFP_DRV_LOG(ERR,
1054                             "%s: Failed to lookup session, rc:%s\n",
1055                             tf_dir_2_str(parms->dir),
1056                             strerror(-rc));
1057                 return rc;
1058         }
1059
1060         /* Retrieve the device information */
1061         rc = tf_session_get_device(tfs, &dev);
1062         if (rc) {
1063                 TFP_DRV_LOG(ERR,
1064                             "%s: Failed to lookup device, rc:%s\n",
1065                             tf_dir_2_str(parms->dir),
1066                             strerror(-rc));
1067                 return rc;
1068         }
1069
1070         sparms.dir = parms->dir;
1071         sparms.type = parms->type;
1072         sparms.data = parms->data;
1073         sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1074         sparms.idx = parms->idx;
1075         sparms.tbl_scope_id = parms->tbl_scope_id;
1076
1077         if (parms->type == TF_TBL_TYPE_EXT) {
1078                 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1079                         rc = -EOPNOTSUPP;
1080                         TFP_DRV_LOG(ERR,
1081                                     "%s: Operation not supported, rc:%s\n",
1082                                     tf_dir_2_str(parms->dir),
1083                                     strerror(-rc));
1084                         return -EOPNOTSUPP;
1085                 }
1086
1087                 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1088                 if (rc) {
1089                         TFP_DRV_LOG(ERR,
1090                                     "%s: Table set failed, rc:%s\n",
1091                                     tf_dir_2_str(parms->dir),
1092                                     strerror(-rc));
1093                         return rc;
1094                 }
1095         } else {
1096                 if (dev->ops->tf_dev_set_tbl == NULL) {
1097                         rc = -EOPNOTSUPP;
1098                         TFP_DRV_LOG(ERR,
1099                                     "%s: Operation not supported, rc:%s\n",
1100                                     tf_dir_2_str(parms->dir),
1101                                     strerror(-rc));
1102                         return -EOPNOTSUPP;
1103                 }
1104
1105                 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1106                 if (rc) {
1107                         TFP_DRV_LOG(ERR,
1108                                     "%s: Table set failed, rc:%s\n",
1109                                     tf_dir_2_str(parms->dir),
1110                                     strerror(-rc));
1111                         return rc;
1112                 }
1113         }
1114
1115         return rc;
1116 }
1117
1118 int
1119 tf_get_tbl_entry(struct tf *tfp,
1120                  struct tf_get_tbl_entry_parms *parms)
1121 {
1122         int rc = 0;
1123         struct tf_session *tfs;
1124         struct tf_dev_info *dev;
1125         struct tf_tbl_get_parms gparms;
1126
1127         TF_CHECK_PARMS3(tfp, parms, parms->data);
1128
1129         /* Can't do static initialization due to UT enum check */
1130         memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1131
1132         /* Retrieve the session information */
1133         rc = tf_session_get_session(tfp, &tfs);
1134         if (rc) {
1135                 TFP_DRV_LOG(ERR,
1136                             "%s: Failed to lookup session, rc:%s\n",
1137                             tf_dir_2_str(parms->dir),
1138                             strerror(-rc));
1139                 return rc;
1140         }
1141
1142         /* Retrieve the device information */
1143         rc = tf_session_get_device(tfs, &dev);
1144         if (rc) {
1145                 TFP_DRV_LOG(ERR,
1146                             "%s: Failed to lookup device, rc:%s\n",
1147                             tf_dir_2_str(parms->dir),
1148                             strerror(-rc));
1149                 return rc;
1150         }
1151
1152         if (dev->ops->tf_dev_get_tbl == NULL) {
1153                 rc = -EOPNOTSUPP;
1154                 TFP_DRV_LOG(ERR,
1155                             "%s: Operation not supported, rc:%s\n",
1156                             tf_dir_2_str(parms->dir),
1157                             strerror(-rc));
1158                 return -EOPNOTSUPP;
1159         }
1160
1161         gparms.dir = parms->dir;
1162         gparms.type = parms->type;
1163         gparms.data = parms->data;
1164         gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1165         gparms.idx = parms->idx;
1166         rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1167         if (rc) {
1168                 TFP_DRV_LOG(ERR,
1169                             "%s: Table get failed, rc:%s\n",
1170                             tf_dir_2_str(parms->dir),
1171                             strerror(-rc));
1172                 return rc;
1173         }
1174
1175         return rc;
1176 }
1177
1178 int
1179 tf_bulk_get_tbl_entry(struct tf *tfp,
1180                  struct tf_bulk_get_tbl_entry_parms *parms)
1181 {
1182         int rc = 0;
1183         struct tf_session *tfs;
1184         struct tf_dev_info *dev;
1185         struct tf_tbl_get_bulk_parms bparms;
1186
1187         TF_CHECK_PARMS2(tfp, parms);
1188
1189         /* Can't do static initialization due to UT enum check */
1190         memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1191
1192         /* Retrieve the session information */
1193         rc = tf_session_get_session(tfp, &tfs);
1194         if (rc) {
1195                 TFP_DRV_LOG(ERR,
1196                             "%s: Failed to lookup session, rc:%s\n",
1197                             tf_dir_2_str(parms->dir),
1198                             strerror(-rc));
1199                 return rc;
1200         }
1201
1202         /* Retrieve the device information */
1203         rc = tf_session_get_device(tfs, &dev);
1204         if (rc) {
1205                 TFP_DRV_LOG(ERR,
1206                             "%s: Failed to lookup device, rc:%s\n",
1207                             tf_dir_2_str(parms->dir),
1208                             strerror(-rc));
1209                 return rc;
1210         }
1211
1212         if (parms->type == TF_TBL_TYPE_EXT) {
1213                 /* Not supported, yet */
1214                 rc = -EOPNOTSUPP;
1215                 TFP_DRV_LOG(ERR,
1216                             "%s, External table type not supported, rc:%s\n",
1217                             tf_dir_2_str(parms->dir),
1218                             strerror(-rc));
1219
1220                 return rc;
1221         }
1222
1223         /* Internal table type processing */
1224
1225         if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1226                 rc = -EOPNOTSUPP;
1227                 TFP_DRV_LOG(ERR,
1228                             "%s: Operation not supported, rc:%s\n",
1229                             tf_dir_2_str(parms->dir),
1230                             strerror(-rc));
1231                 return -EOPNOTSUPP;
1232         }
1233
1234         bparms.dir = parms->dir;
1235         bparms.type = parms->type;
1236         bparms.starting_idx = parms->starting_idx;
1237         bparms.num_entries = parms->num_entries;
1238         bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1239         bparms.physical_mem_addr = parms->physical_mem_addr;
1240         rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1241         if (rc) {
1242                 TFP_DRV_LOG(ERR,
1243                             "%s: Table get bulk failed, rc:%s\n",
1244                             tf_dir_2_str(parms->dir),
1245                             strerror(-rc));
1246                 return rc;
1247         }
1248
1249         return rc;
1250 }
1251
1252 int
1253 tf_alloc_tbl_scope(struct tf *tfp,
1254                    struct tf_alloc_tbl_scope_parms *parms)
1255 {
1256         struct tf_session *tfs;
1257         struct tf_dev_info *dev;
1258         int rc;
1259
1260         TF_CHECK_PARMS2(tfp, parms);
1261
1262         /* Retrieve the session information */
1263         rc = tf_session_get_session(tfp, &tfs);
1264         if (rc) {
1265                 TFP_DRV_LOG(ERR,
1266                             "Failed to lookup session, rc:%s\n",
1267                             strerror(-rc));
1268                 return rc;
1269         }
1270
1271         /* Retrieve the device information */
1272         rc = tf_session_get_device(tfs, &dev);
1273         if (rc) {
1274                 TFP_DRV_LOG(ERR,
1275                             "Failed to lookup device, rc:%s\n",
1276                             strerror(-rc));
1277                 return rc;
1278         }
1279
1280         if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1281                 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1282         } else {
1283                 TFP_DRV_LOG(ERR,
1284                             "Alloc table scope not supported by device\n");
1285                 return -EINVAL;
1286         }
1287
1288         return rc;
1289 }
1290
1291 int
1292 tf_free_tbl_scope(struct tf *tfp,
1293                   struct tf_free_tbl_scope_parms *parms)
1294 {
1295         struct tf_session *tfs;
1296         struct tf_dev_info *dev;
1297         int rc;
1298
1299         TF_CHECK_PARMS2(tfp, parms);
1300
1301         /* Retrieve the session information */
1302         rc = tf_session_get_session(tfp, &tfs);
1303         if (rc) {
1304                 TFP_DRV_LOG(ERR,
1305                             "Failed to lookup session, rc:%s\n",
1306                             strerror(-rc));
1307                 return rc;
1308         }
1309
1310         /* Retrieve the device information */
1311         rc = tf_session_get_device(tfs, &dev);
1312         if (rc) {
1313                 TFP_DRV_LOG(ERR,
1314                             "Failed to lookup device, rc:%s\n",
1315                             strerror(-rc));
1316                 return rc;
1317         }
1318
1319         if (dev->ops->tf_dev_free_tbl_scope) {
1320                 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1321         } else {
1322                 TFP_DRV_LOG(ERR,
1323                             "Free table scope not supported by device\n");
1324                 return -EINVAL;
1325         }
1326
1327         return rc;
1328 }
1329
1330 int
1331 tf_set_if_tbl_entry(struct tf *tfp,
1332                     struct tf_set_if_tbl_entry_parms *parms)
1333 {
1334         int rc;
1335         struct tf_session *tfs;
1336         struct tf_dev_info *dev;
1337         struct tf_if_tbl_set_parms sparms = { 0 };
1338
1339         TF_CHECK_PARMS2(tfp, parms);
1340
1341         /* Retrieve the session information */
1342         rc = tf_session_get_session(tfp, &tfs);
1343         if (rc) {
1344                 TFP_DRV_LOG(ERR,
1345                             "%s: Failed to lookup session, rc:%s\n",
1346                             tf_dir_2_str(parms->dir),
1347                             strerror(-rc));
1348                 return rc;
1349         }
1350
1351         /* Retrieve the device information */
1352         rc = tf_session_get_device(tfs, &dev);
1353         if (rc) {
1354                 TFP_DRV_LOG(ERR,
1355                             "%s: Failed to lookup device, rc:%s\n",
1356                             tf_dir_2_str(parms->dir),
1357                             strerror(-rc));
1358                 return rc;
1359         }
1360
1361         if (dev->ops->tf_dev_set_if_tbl == NULL) {
1362                 rc = -EOPNOTSUPP;
1363                 TFP_DRV_LOG(ERR,
1364                             "%s: Operation not supported, rc:%s\n",
1365                             tf_dir_2_str(parms->dir),
1366                             strerror(-rc));
1367                 return rc;
1368         }
1369
1370         sparms.dir = parms->dir;
1371         sparms.type = parms->type;
1372         sparms.idx = parms->idx;
1373         sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1374         sparms.data = parms->data;
1375
1376         rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1377         if (rc) {
1378                 TFP_DRV_LOG(ERR,
1379                             "%s: If_tbl set failed, rc:%s\n",
1380                             tf_dir_2_str(parms->dir),
1381                             strerror(-rc));
1382                 return rc;
1383         }
1384
1385         return 0;
1386 }
1387
1388 int
1389 tf_get_if_tbl_entry(struct tf *tfp,
1390                     struct tf_get_if_tbl_entry_parms *parms)
1391 {
1392         int rc;
1393         struct tf_session *tfs;
1394         struct tf_dev_info *dev;
1395         struct tf_if_tbl_get_parms gparms = { 0 };
1396
1397         TF_CHECK_PARMS2(tfp, parms);
1398
1399         /* Retrieve the session information */
1400         rc = tf_session_get_session(tfp, &tfs);
1401         if (rc) {
1402                 TFP_DRV_LOG(ERR,
1403                             "%s: Failed to lookup session, rc:%s\n",
1404                             tf_dir_2_str(parms->dir),
1405                             strerror(-rc));
1406                 return rc;
1407         }
1408
1409         /* Retrieve the device information */
1410         rc = tf_session_get_device(tfs, &dev);
1411         if (rc) {
1412                 TFP_DRV_LOG(ERR,
1413                             "%s: Failed to lookup device, rc:%s\n",
1414                             tf_dir_2_str(parms->dir),
1415                             strerror(-rc));
1416                 return rc;
1417         }
1418
1419         if (dev->ops->tf_dev_get_if_tbl == NULL) {
1420                 rc = -EOPNOTSUPP;
1421                 TFP_DRV_LOG(ERR,
1422                             "%s: Operation not supported, rc:%s\n",
1423                             tf_dir_2_str(parms->dir),
1424                             strerror(-rc));
1425                 return rc;
1426         }
1427
1428         gparms.dir = parms->dir;
1429         gparms.type = parms->type;
1430         gparms.idx = parms->idx;
1431         gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1432         gparms.data = parms->data;
1433
1434         rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1435         if (rc) {
1436                 TFP_DRV_LOG(ERR,
1437                             "%s: If_tbl get failed, rc:%s\n",
1438                             tf_dir_2_str(parms->dir),
1439                             strerror(-rc));
1440                 return rc;
1441         }
1442
1443         return 0;
1444 }