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;
545 TF_CHECK_PARMS2(tfp, parms);
547 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
549 /* Retrieve the session information */
550 rc = tf_session_get_session(tfp, &tfs);
553 "%s: Failed to lookup session, rc:%s\n",
554 tf_dir_2_str(parms->dir),
559 /* Retrieve the device information */
560 rc = tf_session_get_device(tfs, &dev);
563 "%s: Failed to lookup device, rc:%s\n",
564 tf_dir_2_str(parms->dir),
569 if (dev->ops->tf_dev_alloc_tcam == NULL) {
572 "%s: Operation not supported, rc:%s\n",
573 tf_dir_2_str(parms->dir),
578 aparms.dir = parms->dir;
579 aparms.type = parms->tcam_tbl_type;
580 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
581 aparms.priority = parms->priority;
582 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
585 "%s: TCAM allocation failed, rc:%s\n",
586 tf_dir_2_str(parms->dir),
591 parms->idx = aparms.idx;
597 tf_set_tcam_entry(struct tf *tfp,
598 struct tf_set_tcam_entry_parms *parms)
601 struct tf_session *tfs;
602 struct tf_dev_info *dev;
603 struct tf_tcam_set_parms sparms;
605 TF_CHECK_PARMS2(tfp, parms);
607 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
610 /* Retrieve the session information */
611 rc = tf_session_get_session(tfp, &tfs);
614 "%s: Failed to lookup session, rc:%s\n",
615 tf_dir_2_str(parms->dir),
620 /* Retrieve the device information */
621 rc = tf_session_get_device(tfs, &dev);
624 "%s: Failed to lookup device, rc:%s\n",
625 tf_dir_2_str(parms->dir),
630 if (dev->ops->tf_dev_set_tcam == NULL) {
633 "%s: Operation not supported, rc:%s\n",
634 tf_dir_2_str(parms->dir),
639 sparms.dir = parms->dir;
640 sparms.type = parms->tcam_tbl_type;
641 sparms.idx = parms->idx;
642 sparms.key = parms->key;
643 sparms.mask = parms->mask;
644 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
645 sparms.result = parms->result;
646 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
648 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
651 "%s: TCAM set failed, rc:%s\n",
652 tf_dir_2_str(parms->dir),
661 tf_get_tcam_entry(struct tf *tfp __rte_unused,
662 struct tf_get_tcam_entry_parms *parms __rte_unused)
664 TF_CHECK_PARMS2(tfp, parms);
669 tf_free_tcam_entry(struct tf *tfp,
670 struct tf_free_tcam_entry_parms *parms)
673 struct tf_session *tfs;
674 struct tf_dev_info *dev;
675 struct tf_tcam_free_parms fparms;
677 TF_CHECK_PARMS2(tfp, parms);
679 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
681 /* Retrieve the session information */
682 rc = tf_session_get_session(tfp, &tfs);
685 "%s: Failed to lookup session, rc:%s\n",
686 tf_dir_2_str(parms->dir),
691 /* Retrieve the device information */
692 rc = tf_session_get_device(tfs, &dev);
695 "%s: Failed to lookup device, rc:%s\n",
696 tf_dir_2_str(parms->dir),
701 if (dev->ops->tf_dev_free_tcam == NULL) {
704 "%s: Operation not supported, rc:%s\n",
705 tf_dir_2_str(parms->dir),
710 fparms.dir = parms->dir;
711 fparms.type = parms->tcam_tbl_type;
712 fparms.idx = parms->idx;
713 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
716 "%s: TCAM free failed, rc:%s\n",
717 tf_dir_2_str(parms->dir),
726 tf_alloc_tbl_entry(struct tf *tfp,
727 struct tf_alloc_tbl_entry_parms *parms)
730 struct tf_session *tfs;
731 struct tf_dev_info *dev;
732 struct tf_tbl_alloc_parms aparms;
735 TF_CHECK_PARMS2(tfp, parms);
737 /* Can't do static initialization due to UT enum check */
738 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
740 /* Retrieve the session information */
741 rc = tf_session_get_session(tfp, &tfs);
744 "%s: Failed to lookup session, rc:%s\n",
745 tf_dir_2_str(parms->dir),
750 /* Retrieve the device information */
751 rc = tf_session_get_device(tfs, &dev);
754 "%s: Failed to lookup device, rc:%s\n",
755 tf_dir_2_str(parms->dir),
760 aparms.dir = parms->dir;
761 aparms.type = parms->type;
763 aparms.tbl_scope_id = parms->tbl_scope_id;
765 if (parms->type == TF_TBL_TYPE_EXT) {
766 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
769 "%s: Operation not supported, rc:%s\n",
770 tf_dir_2_str(parms->dir),
775 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
778 "%s: External table allocation failed, rc:%s\n",
779 tf_dir_2_str(parms->dir),
785 if (dev->ops->tf_dev_alloc_tbl == NULL) {
788 "%s: Operation not supported, rc:%s\n",
789 tf_dir_2_str(parms->dir),
794 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
797 "%s: Table allocation failed, rc:%s\n",
798 tf_dir_2_str(parms->dir),
810 tf_free_tbl_entry(struct tf *tfp,
811 struct tf_free_tbl_entry_parms *parms)
814 struct tf_session *tfs;
815 struct tf_dev_info *dev;
816 struct tf_tbl_free_parms fparms;
818 TF_CHECK_PARMS2(tfp, parms);
820 /* Can't do static initialization due to UT enum check */
821 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
823 /* Retrieve the session information */
824 rc = tf_session_get_session(tfp, &tfs);
827 "%s: Failed to lookup session, rc:%s\n",
828 tf_dir_2_str(parms->dir),
833 /* Retrieve the device information */
834 rc = tf_session_get_device(tfs, &dev);
837 "%s: Failed to lookup device, rc:%s\n",
838 tf_dir_2_str(parms->dir),
843 fparms.dir = parms->dir;
844 fparms.type = parms->type;
845 fparms.idx = parms->idx;
846 fparms.tbl_scope_id = parms->tbl_scope_id;
848 if (parms->type == TF_TBL_TYPE_EXT) {
849 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
852 "%s: Operation not supported, rc:%s\n",
853 tf_dir_2_str(parms->dir),
858 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
861 "%s: Table free failed, rc:%s\n",
862 tf_dir_2_str(parms->dir),
867 if (dev->ops->tf_dev_free_tbl == NULL) {
870 "%s: Operation not supported, rc:%s\n",
871 tf_dir_2_str(parms->dir),
876 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
879 "%s: Table free failed, rc:%s\n",
880 tf_dir_2_str(parms->dir),
890 tf_set_tbl_entry(struct tf *tfp,
891 struct tf_set_tbl_entry_parms *parms)
894 struct tf_session *tfs;
895 struct tf_dev_info *dev;
896 struct tf_tbl_set_parms sparms;
898 TF_CHECK_PARMS3(tfp, parms, parms->data);
900 /* Can't do static initialization due to UT enum check */
901 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
903 /* Retrieve the session information */
904 rc = tf_session_get_session(tfp, &tfs);
907 "%s: Failed to lookup session, rc:%s\n",
908 tf_dir_2_str(parms->dir),
913 /* Retrieve the device information */
914 rc = tf_session_get_device(tfs, &dev);
917 "%s: Failed to lookup device, rc:%s\n",
918 tf_dir_2_str(parms->dir),
923 sparms.dir = parms->dir;
924 sparms.type = parms->type;
925 sparms.data = parms->data;
926 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
927 sparms.idx = parms->idx;
928 sparms.tbl_scope_id = parms->tbl_scope_id;
930 if (parms->type == TF_TBL_TYPE_EXT) {
931 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
934 "%s: Operation not supported, rc:%s\n",
935 tf_dir_2_str(parms->dir),
940 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
943 "%s: Table set failed, rc:%s\n",
944 tf_dir_2_str(parms->dir),
949 if (dev->ops->tf_dev_set_tbl == NULL) {
952 "%s: Operation not supported, rc:%s\n",
953 tf_dir_2_str(parms->dir),
958 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
961 "%s: Table set failed, rc:%s\n",
962 tf_dir_2_str(parms->dir),
972 tf_get_tbl_entry(struct tf *tfp,
973 struct tf_get_tbl_entry_parms *parms)
976 struct tf_session *tfs;
977 struct tf_dev_info *dev;
978 struct tf_tbl_get_parms gparms;
980 TF_CHECK_PARMS3(tfp, parms, parms->data);
982 /* Can't do static initialization due to UT enum check */
983 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
985 /* Retrieve the session information */
986 rc = tf_session_get_session(tfp, &tfs);
989 "%s: Failed to lookup session, rc:%s\n",
990 tf_dir_2_str(parms->dir),
995 /* Retrieve the device information */
996 rc = tf_session_get_device(tfs, &dev);
999 "%s: Failed to lookup device, rc:%s\n",
1000 tf_dir_2_str(parms->dir),
1005 if (dev->ops->tf_dev_get_tbl == NULL) {
1008 "%s: Operation not supported, rc:%s\n",
1009 tf_dir_2_str(parms->dir),
1014 gparms.dir = parms->dir;
1015 gparms.type = parms->type;
1016 gparms.data = parms->data;
1017 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1018 gparms.idx = parms->idx;
1019 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1022 "%s: Table get failed, rc:%s\n",
1023 tf_dir_2_str(parms->dir),
1032 tf_bulk_get_tbl_entry(struct tf *tfp,
1033 struct tf_bulk_get_tbl_entry_parms *parms)
1036 struct tf_session *tfs;
1037 struct tf_dev_info *dev;
1038 struct tf_tbl_get_bulk_parms bparms;
1040 TF_CHECK_PARMS2(tfp, parms);
1042 /* Can't do static initialization due to UT enum check */
1043 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1045 /* Retrieve the session information */
1046 rc = tf_session_get_session(tfp, &tfs);
1049 "%s: Failed to lookup session, rc:%s\n",
1050 tf_dir_2_str(parms->dir),
1055 /* Retrieve the device information */
1056 rc = tf_session_get_device(tfs, &dev);
1059 "%s: Failed to lookup device, rc:%s\n",
1060 tf_dir_2_str(parms->dir),
1065 if (parms->type == TF_TBL_TYPE_EXT) {
1066 /* Not supported, yet */
1069 "%s, External table type not supported, rc:%s\n",
1070 tf_dir_2_str(parms->dir),
1076 /* Internal table type processing */
1078 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1081 "%s: Operation not supported, rc:%s\n",
1082 tf_dir_2_str(parms->dir),
1087 bparms.dir = parms->dir;
1088 bparms.type = parms->type;
1089 bparms.starting_idx = parms->starting_idx;
1090 bparms.num_entries = parms->num_entries;
1091 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1092 bparms.physical_mem_addr = parms->physical_mem_addr;
1093 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1096 "%s: Table get bulk failed, rc:%s\n",
1097 tf_dir_2_str(parms->dir),
1106 tf_alloc_tbl_scope(struct tf *tfp,
1107 struct tf_alloc_tbl_scope_parms *parms)
1109 struct tf_session *tfs;
1110 struct tf_dev_info *dev;
1113 TF_CHECK_PARMS2(tfp, parms);
1115 /* Retrieve the session information */
1116 rc = tf_session_get_session(tfp, &tfs);
1119 "Failed to lookup session, rc:%s\n",
1124 /* Retrieve the device information */
1125 rc = tf_session_get_device(tfs, &dev);
1128 "Failed to lookup device, rc:%s\n",
1133 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1134 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1137 "Alloc table scope not supported by device\n");
1145 tf_free_tbl_scope(struct tf *tfp,
1146 struct tf_free_tbl_scope_parms *parms)
1148 struct tf_session *tfs;
1149 struct tf_dev_info *dev;
1152 TF_CHECK_PARMS2(tfp, parms);
1154 /* Retrieve the session information */
1155 rc = tf_session_get_session(tfp, &tfs);
1158 "Failed to lookup session, rc:%s\n",
1163 /* Retrieve the device information */
1164 rc = tf_session_get_device(tfs, &dev);
1167 "Failed to lookup device, rc:%s\n",
1172 if (dev->ops->tf_dev_free_tbl_scope) {
1173 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1176 "Free table scope not supported by device\n");
1184 tf_set_if_tbl_entry(struct tf *tfp,
1185 struct tf_set_if_tbl_entry_parms *parms)
1188 struct tf_session *tfs;
1189 struct tf_dev_info *dev;
1190 struct tf_if_tbl_set_parms sparms = { 0 };
1192 TF_CHECK_PARMS2(tfp, parms);
1194 /* Retrieve the session information */
1195 rc = tf_session_get_session(tfp, &tfs);
1198 "%s: Failed to lookup session, rc:%s\n",
1199 tf_dir_2_str(parms->dir),
1204 /* Retrieve the device information */
1205 rc = tf_session_get_device(tfs, &dev);
1208 "%s: Failed to lookup device, rc:%s\n",
1209 tf_dir_2_str(parms->dir),
1214 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1217 "%s: Operation not supported, rc:%s\n",
1218 tf_dir_2_str(parms->dir),
1223 sparms.dir = parms->dir;
1224 sparms.type = parms->type;
1225 sparms.idx = parms->idx;
1226 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1227 sparms.data = parms->data;
1229 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1232 "%s: If_tbl set failed, rc:%s\n",
1233 tf_dir_2_str(parms->dir),
1242 tf_get_if_tbl_entry(struct tf *tfp,
1243 struct tf_get_if_tbl_entry_parms *parms)
1246 struct tf_session *tfs;
1247 struct tf_dev_info *dev;
1248 struct tf_if_tbl_get_parms gparms = { 0 };
1250 TF_CHECK_PARMS2(tfp, parms);
1252 /* Retrieve the session information */
1253 rc = tf_session_get_session(tfp, &tfs);
1256 "%s: Failed to lookup session, rc:%s\n",
1257 tf_dir_2_str(parms->dir),
1262 /* Retrieve the device information */
1263 rc = tf_session_get_device(tfs, &dev);
1266 "%s: Failed to lookup device, rc:%s\n",
1267 tf_dir_2_str(parms->dir),
1272 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1275 "%s: Operation not supported, rc:%s\n",
1276 tf_dir_2_str(parms->dir),
1281 gparms.dir = parms->dir;
1282 gparms.type = parms->type;
1283 gparms.idx = parms->idx;
1284 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1285 gparms.data = parms->data;
1287 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1290 "%s: If_tbl get failed, rc:%s\n",
1291 tf_dir_2_str(parms->dir),