1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_session.h"
14 #include "tf_global_cfg.h"
20 #include "tf_common.h"
24 tf_open_session(struct tf *tfp,
25 struct tf_open_session_parms *parms)
28 unsigned int domain, bus, slot, device;
29 struct tf_session_open_session_parms oparms;
31 TF_CHECK_PARMS2(tfp, parms);
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.
37 if (parms->device_type != TF_DEVICE_TYPE_WH) {
39 "Unsupported device type %d\n",
44 /* Verify control channel and build the beginning of session_id */
45 rc = sscanf(parms->ctrl_chan_name,
53 "Failed to scan device ctrl_chan_name\n");
57 parms->session_id.internal.domain = domain;
58 parms->session_id.internal.bus = bus;
59 parms->session_id.internal.device = device;
60 oparms.open_cfg = parms;
62 /* Session vs session client is decided in
63 * tf_session_open_session()
65 printf("TF_OPEN, %s\n", parms->ctrl_chan_name);
66 rc = tf_session_open_session(tfp, &oparms);
67 /* Logging handled by tf_session_open_session */
72 "domain:%d, bus:%d, device:%d\n",
73 parms->session_id.internal.domain,
74 parms->session_id.internal.bus,
75 parms->session_id.internal.device);
81 tf_attach_session(struct tf *tfp,
82 struct tf_attach_session_parms *parms)
85 unsigned int domain, bus, slot, device;
86 struct tf_session_attach_session_parms aparms;
88 TF_CHECK_PARMS2(tfp, parms);
90 /* Verify control channel */
91 rc = sscanf(parms->ctrl_chan_name,
99 "Failed to scan device ctrl_chan_name\n");
103 /* Verify 'attach' channel */
104 rc = sscanf(parms->attach_chan_name,
112 "Failed to scan device attach_chan_name\n");
116 /* Prepare return value of session_id, using ctrl_chan_name
117 * device values as it becomes the session id.
119 parms->session_id.internal.domain = domain;
120 parms->session_id.internal.bus = bus;
121 parms->session_id.internal.device = device;
122 aparms.attach_cfg = parms;
123 rc = tf_session_attach_session(tfp,
125 /* Logging handled by dev_bind */
130 "Attached to session, session_id:%d\n",
131 parms->session_id.id);
134 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
135 parms->session_id.internal.domain,
136 parms->session_id.internal.bus,
137 parms->session_id.internal.device,
138 parms->session_id.internal.fw_session_id);
144 tf_close_session(struct tf *tfp)
147 struct tf_session_close_session_parms cparms = { 0 };
148 union tf_session_id session_id = { 0 };
151 TF_CHECK_PARMS1(tfp);
153 cparms.ref_count = &ref_count;
154 cparms.session_id = &session_id;
155 /* Session vs session client is decided in
156 * tf_session_close_session()
158 rc = tf_session_close_session(tfp,
160 /* Logging handled by tf_session_close_session */
165 "domain:%d, bus:%d, device:%d\n",
166 cparms.session_id->internal.domain,
167 cparms.session_id->internal.bus,
168 cparms.session_id->internal.device);
173 /** insert EM hash entry API
179 int tf_insert_em_entry(struct tf *tfp,
180 struct tf_insert_em_entry_parms *parms)
182 struct tf_session *tfs;
183 struct tf_dev_info *dev;
186 TF_CHECK_PARMS2(tfp, parms);
188 /* Retrieve the session information */
189 rc = tf_session_get_session(tfp, &tfs);
192 "%s: Failed to lookup session, rc:%s\n",
193 tf_dir_2_str(parms->dir),
198 /* Retrieve the device information */
199 rc = tf_session_get_device(tfs, &dev);
202 "%s: Failed to lookup device, rc:%s\n",
203 tf_dir_2_str(parms->dir),
208 if (parms->mem == TF_MEM_EXTERNAL &&
209 dev->ops->tf_dev_insert_ext_em_entry != NULL)
210 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
211 else if (parms->mem == TF_MEM_INTERNAL &&
212 dev->ops->tf_dev_insert_int_em_entry != NULL)
213 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
219 "%s: EM insert failed, rc:%s\n",
220 tf_dir_2_str(parms->dir),
228 /** Delete EM hash entry API
234 int tf_delete_em_entry(struct tf *tfp,
235 struct tf_delete_em_entry_parms *parms)
237 struct tf_session *tfs;
238 struct tf_dev_info *dev;
241 TF_CHECK_PARMS2(tfp, parms);
243 /* Retrieve the session information */
244 rc = tf_session_get_session(tfp, &tfs);
247 "%s: Failed to lookup session, rc:%s\n",
248 tf_dir_2_str(parms->dir),
253 /* Retrieve the device information */
254 rc = tf_session_get_device(tfs, &dev);
257 "%s: Failed to lookup device, rc:%s\n",
258 tf_dir_2_str(parms->dir),
263 if (parms->mem == TF_MEM_EXTERNAL)
264 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
265 else if (parms->mem == TF_MEM_INTERNAL)
266 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
272 "%s: EM delete failed, rc:%s\n",
273 tf_dir_2_str(parms->dir),
281 /** Get global configuration API
287 int tf_get_global_cfg(struct tf *tfp,
288 struct tf_global_cfg_parms *parms)
291 struct tf_session *tfs;
292 struct tf_dev_info *dev;
293 struct tf_dev_global_cfg_parms gparms = { 0 };
295 TF_CHECK_PARMS2(tfp, parms);
297 /* Retrieve the session information */
298 rc = tf_session_get_session(tfp, &tfs);
301 "%s: Failed to lookup session, rc:%s\n",
302 tf_dir_2_str(parms->dir),
307 /* Retrieve the device information */
308 rc = tf_session_get_device(tfs, &dev);
311 "%s: Failed to lookup device, rc:%s\n",
312 tf_dir_2_str(parms->dir),
317 if (parms->config == NULL ||
318 parms->config_sz_in_bytes == 0) {
319 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
323 if (dev->ops->tf_dev_get_global_cfg == NULL) {
326 "%s: Operation not supported, rc:%s\n",
327 tf_dir_2_str(parms->dir),
332 gparms.dir = parms->dir;
333 gparms.type = parms->type;
334 gparms.offset = parms->offset;
335 gparms.config = parms->config;
336 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
337 rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
340 "%s: Global Cfg get failed, rc:%s\n",
341 tf_dir_2_str(parms->dir),
349 /** Set global configuration API
355 int tf_set_global_cfg(struct tf *tfp,
356 struct tf_global_cfg_parms *parms)
359 struct tf_session *tfs;
360 struct tf_dev_info *dev;
361 struct tf_dev_global_cfg_parms gparms = { 0 };
363 TF_CHECK_PARMS2(tfp, parms);
365 /* Retrieve the session information */
366 rc = tf_session_get_session(tfp, &tfs);
369 "%s: Failed to lookup session, rc:%s\n",
370 tf_dir_2_str(parms->dir),
375 /* Retrieve the device information */
376 rc = tf_session_get_device(tfs, &dev);
379 "%s: Failed to lookup device, rc:%s\n",
380 tf_dir_2_str(parms->dir),
385 if (parms->config == NULL ||
386 parms->config_sz_in_bytes == 0) {
387 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
391 if (dev->ops->tf_dev_set_global_cfg == NULL) {
394 "%s: Operation not supported, rc:%s\n",
395 tf_dir_2_str(parms->dir),
400 gparms.dir = parms->dir;
401 gparms.type = parms->type;
402 gparms.offset = parms->offset;
403 gparms.config = parms->config;
404 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
405 rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
408 "%s: Global Cfg set failed, rc:%s\n",
409 tf_dir_2_str(parms->dir),
418 tf_alloc_identifier(struct tf *tfp,
419 struct tf_alloc_identifier_parms *parms)
422 struct tf_session *tfs;
423 struct tf_dev_info *dev;
424 struct tf_ident_alloc_parms aparms;
427 TF_CHECK_PARMS2(tfp, parms);
429 /* Can't do static initialization due to UT enum check */
430 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
432 /* Retrieve the session information */
433 rc = tf_session_get_session(tfp, &tfs);
436 "%s: Failed to lookup session, rc:%s\n",
437 tf_dir_2_str(parms->dir),
442 /* Retrieve the device information */
443 rc = tf_session_get_device(tfs, &dev);
446 "%s: Failed to lookup device, rc:%s\n",
447 tf_dir_2_str(parms->dir),
452 if (dev->ops->tf_dev_alloc_ident == NULL) {
455 "%s: Operation not supported, rc:%s\n",
456 tf_dir_2_str(parms->dir),
461 aparms.dir = parms->dir;
462 aparms.type = parms->ident_type;
464 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
467 "%s: Identifier allocation failed, rc:%s\n",
468 tf_dir_2_str(parms->dir),
479 tf_free_identifier(struct tf *tfp,
480 struct tf_free_identifier_parms *parms)
483 struct tf_session *tfs;
484 struct tf_dev_info *dev;
485 struct tf_ident_free_parms fparms;
487 TF_CHECK_PARMS2(tfp, parms);
489 /* Can't do static initialization due to UT enum check */
490 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
492 /* Retrieve the session information */
493 rc = tf_session_get_session(tfp, &tfs);
496 "%s: Failed to lookup session, rc:%s\n",
497 tf_dir_2_str(parms->dir),
502 /* Retrieve the device information */
503 rc = tf_session_get_device(tfs, &dev);
506 "%s: Failed to lookup device, rc:%s\n",
507 tf_dir_2_str(parms->dir),
512 if (dev->ops->tf_dev_free_ident == NULL) {
515 "%s: Operation not supported, rc:%s\n",
516 tf_dir_2_str(parms->dir),
521 fparms.dir = parms->dir;
522 fparms.type = parms->ident_type;
523 fparms.id = parms->id;
524 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
527 "%s: Identifier free failed, rc:%s\n",
528 tf_dir_2_str(parms->dir),
537 tf_alloc_tcam_entry(struct tf *tfp,
538 struct tf_alloc_tcam_entry_parms *parms)
541 struct tf_session *tfs;
542 struct tf_dev_info *dev;
543 struct tf_tcam_alloc_parms aparms = { 0 };
545 TF_CHECK_PARMS2(tfp, parms);
547 /* Retrieve the session information */
548 rc = tf_session_get_session(tfp, &tfs);
551 "%s: Failed to lookup session, rc:%s\n",
552 tf_dir_2_str(parms->dir),
557 /* Retrieve the device information */
558 rc = tf_session_get_device(tfs, &dev);
561 "%s: Failed to lookup device, rc:%s\n",
562 tf_dir_2_str(parms->dir),
567 if (dev->ops->tf_dev_alloc_tcam == NULL) {
570 "%s: Operation not supported, rc:%s\n",
571 tf_dir_2_str(parms->dir),
576 aparms.dir = parms->dir;
577 aparms.type = parms->tcam_tbl_type;
578 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
579 aparms.priority = parms->priority;
580 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
583 "%s: TCAM allocation failed, rc:%s\n",
584 tf_dir_2_str(parms->dir),
589 parms->idx = aparms.idx;
595 tf_set_tcam_entry(struct tf *tfp,
596 struct tf_set_tcam_entry_parms *parms)
599 struct tf_session *tfs;
600 struct tf_dev_info *dev;
601 struct tf_tcam_set_parms sparms = { 0 };
603 TF_CHECK_PARMS2(tfp, parms);
605 /* Retrieve the session information */
606 rc = tf_session_get_session(tfp, &tfs);
609 "%s: Failed to lookup session, rc:%s\n",
610 tf_dir_2_str(parms->dir),
615 /* Retrieve the device information */
616 rc = tf_session_get_device(tfs, &dev);
619 "%s: Failed to lookup device, rc:%s\n",
620 tf_dir_2_str(parms->dir),
625 if (dev->ops->tf_dev_set_tcam == NULL) {
628 "%s: Operation not supported, rc:%s\n",
629 tf_dir_2_str(parms->dir),
634 sparms.dir = parms->dir;
635 sparms.type = parms->tcam_tbl_type;
636 sparms.idx = parms->idx;
637 sparms.key = parms->key;
638 sparms.mask = parms->mask;
639 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
640 sparms.result = parms->result;
641 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
643 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
646 "%s: TCAM set failed, rc:%s\n",
647 tf_dir_2_str(parms->dir),
656 tf_get_tcam_entry(struct tf *tfp __rte_unused,
657 struct tf_get_tcam_entry_parms *parms __rte_unused)
659 TF_CHECK_PARMS2(tfp, parms);
664 tf_free_tcam_entry(struct tf *tfp,
665 struct tf_free_tcam_entry_parms *parms)
668 struct tf_session *tfs;
669 struct tf_dev_info *dev;
670 struct tf_tcam_free_parms fparms = { 0 };
672 TF_CHECK_PARMS2(tfp, parms);
674 /* Retrieve the session information */
675 rc = tf_session_get_session(tfp, &tfs);
678 "%s: Failed to lookup session, rc:%s\n",
679 tf_dir_2_str(parms->dir),
684 /* Retrieve the device information */
685 rc = tf_session_get_device(tfs, &dev);
688 "%s: Failed to lookup device, rc:%s\n",
689 tf_dir_2_str(parms->dir),
694 if (dev->ops->tf_dev_free_tcam == NULL) {
697 "%s: Operation not supported, rc:%s\n",
698 tf_dir_2_str(parms->dir),
703 fparms.dir = parms->dir;
704 fparms.type = parms->tcam_tbl_type;
705 fparms.idx = parms->idx;
706 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
709 "%s: TCAM free failed, rc:%s\n",
710 tf_dir_2_str(parms->dir),
719 tf_alloc_tbl_entry(struct tf *tfp,
720 struct tf_alloc_tbl_entry_parms *parms)
723 struct tf_session *tfs;
724 struct tf_dev_info *dev;
725 struct tf_tbl_alloc_parms aparms;
728 TF_CHECK_PARMS2(tfp, parms);
730 /* Can't do static initialization due to UT enum check */
731 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
733 /* Retrieve the session information */
734 rc = tf_session_get_session(tfp, &tfs);
737 "%s: Failed to lookup session, rc:%s\n",
738 tf_dir_2_str(parms->dir),
743 /* Retrieve the device information */
744 rc = tf_session_get_device(tfs, &dev);
747 "%s: Failed to lookup device, rc:%s\n",
748 tf_dir_2_str(parms->dir),
753 aparms.dir = parms->dir;
754 aparms.type = parms->type;
756 aparms.tbl_scope_id = parms->tbl_scope_id;
758 if (parms->type == TF_TBL_TYPE_EXT) {
759 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
762 "%s: Operation not supported, rc:%s\n",
763 tf_dir_2_str(parms->dir),
768 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
771 "%s: External table allocation failed, rc:%s\n",
772 tf_dir_2_str(parms->dir),
778 if (dev->ops->tf_dev_alloc_tbl == NULL) {
781 "%s: Operation not supported, rc:%s\n",
782 tf_dir_2_str(parms->dir),
787 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
790 "%s: Table allocation failed, rc:%s\n",
791 tf_dir_2_str(parms->dir),
803 tf_free_tbl_entry(struct tf *tfp,
804 struct tf_free_tbl_entry_parms *parms)
807 struct tf_session *tfs;
808 struct tf_dev_info *dev;
809 struct tf_tbl_free_parms fparms;
811 TF_CHECK_PARMS2(tfp, parms);
813 /* Can't do static initialization due to UT enum check */
814 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
816 /* Retrieve the session information */
817 rc = tf_session_get_session(tfp, &tfs);
820 "%s: Failed to lookup session, rc:%s\n",
821 tf_dir_2_str(parms->dir),
826 /* Retrieve the device information */
827 rc = tf_session_get_device(tfs, &dev);
830 "%s: Failed to lookup device, rc:%s\n",
831 tf_dir_2_str(parms->dir),
836 fparms.dir = parms->dir;
837 fparms.type = parms->type;
838 fparms.idx = parms->idx;
839 fparms.tbl_scope_id = parms->tbl_scope_id;
841 if (parms->type == TF_TBL_TYPE_EXT) {
842 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
845 "%s: Operation not supported, rc:%s\n",
846 tf_dir_2_str(parms->dir),
851 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
854 "%s: Table free failed, rc:%s\n",
855 tf_dir_2_str(parms->dir),
860 if (dev->ops->tf_dev_free_tbl == NULL) {
863 "%s: Operation not supported, rc:%s\n",
864 tf_dir_2_str(parms->dir),
869 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
872 "%s: Table free failed, rc:%s\n",
873 tf_dir_2_str(parms->dir),
883 tf_set_tbl_entry(struct tf *tfp,
884 struct tf_set_tbl_entry_parms *parms)
887 struct tf_session *tfs;
888 struct tf_dev_info *dev;
889 struct tf_tbl_set_parms sparms;
891 TF_CHECK_PARMS3(tfp, parms, parms->data);
893 /* Can't do static initialization due to UT enum check */
894 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
896 /* Retrieve the session information */
897 rc = tf_session_get_session(tfp, &tfs);
900 "%s: Failed to lookup session, rc:%s\n",
901 tf_dir_2_str(parms->dir),
906 /* Retrieve the device information */
907 rc = tf_session_get_device(tfs, &dev);
910 "%s: Failed to lookup device, rc:%s\n",
911 tf_dir_2_str(parms->dir),
916 sparms.dir = parms->dir;
917 sparms.type = parms->type;
918 sparms.data = parms->data;
919 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
920 sparms.idx = parms->idx;
921 sparms.tbl_scope_id = parms->tbl_scope_id;
923 if (parms->type == TF_TBL_TYPE_EXT) {
924 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
927 "%s: Operation not supported, rc:%s\n",
928 tf_dir_2_str(parms->dir),
933 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
936 "%s: Table set failed, rc:%s\n",
937 tf_dir_2_str(parms->dir),
942 if (dev->ops->tf_dev_set_tbl == NULL) {
945 "%s: Operation not supported, rc:%s\n",
946 tf_dir_2_str(parms->dir),
951 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
954 "%s: Table set failed, rc:%s\n",
955 tf_dir_2_str(parms->dir),
965 tf_get_tbl_entry(struct tf *tfp,
966 struct tf_get_tbl_entry_parms *parms)
969 struct tf_session *tfs;
970 struct tf_dev_info *dev;
971 struct tf_tbl_get_parms gparms;
973 TF_CHECK_PARMS3(tfp, parms, parms->data);
975 /* Can't do static initialization due to UT enum check */
976 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
978 /* Retrieve the session information */
979 rc = tf_session_get_session(tfp, &tfs);
982 "%s: Failed to lookup session, rc:%s\n",
983 tf_dir_2_str(parms->dir),
988 /* Retrieve the device information */
989 rc = tf_session_get_device(tfs, &dev);
992 "%s: Failed to lookup device, rc:%s\n",
993 tf_dir_2_str(parms->dir),
998 if (dev->ops->tf_dev_get_tbl == NULL) {
1001 "%s: Operation not supported, rc:%s\n",
1002 tf_dir_2_str(parms->dir),
1007 gparms.dir = parms->dir;
1008 gparms.type = parms->type;
1009 gparms.data = parms->data;
1010 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1011 gparms.idx = parms->idx;
1012 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1015 "%s: Table get failed, rc:%s\n",
1016 tf_dir_2_str(parms->dir),
1025 tf_bulk_get_tbl_entry(struct tf *tfp,
1026 struct tf_bulk_get_tbl_entry_parms *parms)
1029 struct tf_session *tfs;
1030 struct tf_dev_info *dev;
1031 struct tf_tbl_get_bulk_parms bparms;
1033 TF_CHECK_PARMS2(tfp, parms);
1035 /* Can't do static initialization due to UT enum check */
1036 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1038 /* Retrieve the session information */
1039 rc = tf_session_get_session(tfp, &tfs);
1042 "%s: Failed to lookup session, rc:%s\n",
1043 tf_dir_2_str(parms->dir),
1048 /* Retrieve the device information */
1049 rc = tf_session_get_device(tfs, &dev);
1052 "%s: Failed to lookup device, rc:%s\n",
1053 tf_dir_2_str(parms->dir),
1058 if (parms->type == TF_TBL_TYPE_EXT) {
1059 /* Not supported, yet */
1062 "%s, External table type not supported, rc:%s\n",
1063 tf_dir_2_str(parms->dir),
1069 /* Internal table type processing */
1071 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1074 "%s: Operation not supported, rc:%s\n",
1075 tf_dir_2_str(parms->dir),
1080 bparms.dir = parms->dir;
1081 bparms.type = parms->type;
1082 bparms.starting_idx = parms->starting_idx;
1083 bparms.num_entries = parms->num_entries;
1084 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1085 bparms.physical_mem_addr = parms->physical_mem_addr;
1086 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1089 "%s: Table get bulk failed, rc:%s\n",
1090 tf_dir_2_str(parms->dir),
1099 tf_alloc_tbl_scope(struct tf *tfp,
1100 struct tf_alloc_tbl_scope_parms *parms)
1102 struct tf_session *tfs;
1103 struct tf_dev_info *dev;
1106 TF_CHECK_PARMS2(tfp, parms);
1108 /* Retrieve the session information */
1109 rc = tf_session_get_session(tfp, &tfs);
1112 "Failed to lookup session, rc:%s\n",
1117 /* Retrieve the device information */
1118 rc = tf_session_get_device(tfs, &dev);
1121 "Failed to lookup device, rc:%s\n",
1126 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1127 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1130 "Alloc table scope not supported by device\n");
1138 tf_free_tbl_scope(struct tf *tfp,
1139 struct tf_free_tbl_scope_parms *parms)
1141 struct tf_session *tfs;
1142 struct tf_dev_info *dev;
1145 TF_CHECK_PARMS2(tfp, parms);
1147 /* Retrieve the session information */
1148 rc = tf_session_get_session(tfp, &tfs);
1151 "Failed to lookup session, rc:%s\n",
1156 /* Retrieve the device information */
1157 rc = tf_session_get_device(tfs, &dev);
1160 "Failed to lookup device, rc:%s\n",
1165 if (dev->ops->tf_dev_free_tbl_scope) {
1166 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1169 "Free table scope not supported by device\n");
1177 tf_set_if_tbl_entry(struct tf *tfp,
1178 struct tf_set_if_tbl_entry_parms *parms)
1181 struct tf_session *tfs;
1182 struct tf_dev_info *dev;
1183 struct tf_if_tbl_set_parms sparms = { 0 };
1185 TF_CHECK_PARMS2(tfp, parms);
1187 /* Retrieve the session information */
1188 rc = tf_session_get_session(tfp, &tfs);
1191 "%s: Failed to lookup session, rc:%s\n",
1192 tf_dir_2_str(parms->dir),
1197 /* Retrieve the device information */
1198 rc = tf_session_get_device(tfs, &dev);
1201 "%s: Failed to lookup device, rc:%s\n",
1202 tf_dir_2_str(parms->dir),
1207 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1210 "%s: Operation not supported, rc:%s\n",
1211 tf_dir_2_str(parms->dir),
1216 sparms.dir = parms->dir;
1217 sparms.type = parms->type;
1218 sparms.idx = parms->idx;
1219 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1220 sparms.data = parms->data;
1222 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1225 "%s: If_tbl set failed, rc:%s\n",
1226 tf_dir_2_str(parms->dir),
1235 tf_get_if_tbl_entry(struct tf *tfp,
1236 struct tf_get_if_tbl_entry_parms *parms)
1239 struct tf_session *tfs;
1240 struct tf_dev_info *dev;
1241 struct tf_if_tbl_get_parms gparms = { 0 };
1243 TF_CHECK_PARMS2(tfp, parms);
1245 /* Retrieve the session information */
1246 rc = tf_session_get_session(tfp, &tfs);
1249 "%s: Failed to lookup session, rc:%s\n",
1250 tf_dir_2_str(parms->dir),
1255 /* Retrieve the device information */
1256 rc = tf_session_get_device(tfs, &dev);
1259 "%s: Failed to lookup device, rc:%s\n",
1260 tf_dir_2_str(parms->dir),
1265 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1268 "%s: Operation not supported, rc:%s\n",
1269 tf_dir_2_str(parms->dir),
1274 gparms.dir = parms->dir;
1275 gparms.type = parms->type;
1276 gparms.idx = parms->idx;
1277 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1278 gparms.data = parms->data;
1280 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1283 "%s: If_tbl get failed, rc:%s\n",
1284 tf_dir_2_str(parms->dir),