1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 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 &&
38 parms->device_type != TF_DEVICE_TYPE_THOR &&
39 parms->device_type != TF_DEVICE_TYPE_SR) {
41 "Unsupported device type %d\n",
46 /* Verify control channel and build the beginning of session_id */
47 rc = sscanf(parms->ctrl_chan_name,
54 /* PCI Domain not provided (optional in DPDK), thus we
55 * force domain to 0 and recheck.
59 /* Check parsing of bus/slot/device */
60 rc = sscanf(parms->ctrl_chan_name,
67 "Failed to scan device ctrl_chan_name\n");
72 parms->session_id.internal.domain = domain;
73 parms->session_id.internal.bus = bus;
74 parms->session_id.internal.device = device;
75 oparms.open_cfg = parms;
77 /* Session vs session client is decided in
78 * tf_session_open_session()
80 rc = tf_session_open_session(tfp, &oparms);
81 /* Logging handled by tf_session_open_session */
86 "domain:%d, bus:%d, device:%u\n",
87 parms->session_id.internal.domain,
88 parms->session_id.internal.bus,
89 parms->session_id.internal.device);
95 tf_attach_session(struct tf *tfp,
96 struct tf_attach_session_parms *parms)
99 unsigned int domain, bus, slot, device;
100 struct tf_session_attach_session_parms aparms;
102 TF_CHECK_PARMS2(tfp, parms);
104 /* Verify control channel */
105 rc = sscanf(parms->ctrl_chan_name,
113 "Failed to scan device ctrl_chan_name\n");
117 /* Verify 'attach' channel */
118 rc = sscanf(parms->attach_chan_name,
126 "Failed to scan device attach_chan_name\n");
130 /* Prepare return value of session_id, using ctrl_chan_name
131 * device values as it becomes the session id.
133 parms->session_id.internal.domain = domain;
134 parms->session_id.internal.bus = bus;
135 parms->session_id.internal.device = device;
136 aparms.attach_cfg = parms;
137 rc = tf_session_attach_session(tfp,
139 /* Logging handled by dev_bind */
144 "Attached to session, session_id:%d\n",
145 parms->session_id.id);
148 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
149 parms->session_id.internal.domain,
150 parms->session_id.internal.bus,
151 parms->session_id.internal.device,
152 parms->session_id.internal.fw_session_id);
158 tf_close_session(struct tf *tfp)
161 struct tf_session_close_session_parms cparms = { 0 };
162 union tf_session_id session_id = { 0 };
165 TF_CHECK_PARMS1(tfp);
167 cparms.ref_count = &ref_count;
168 cparms.session_id = &session_id;
169 /* Session vs session client is decided in
170 * tf_session_close_session()
172 rc = tf_session_close_session(tfp,
174 /* Logging handled by tf_session_close_session */
179 "domain:%d, bus:%d, device:%d\n",
180 cparms.session_id->internal.domain,
181 cparms.session_id->internal.bus,
182 cparms.session_id->internal.device);
187 /** insert EM hash entry API
193 int tf_insert_em_entry(struct tf *tfp,
194 struct tf_insert_em_entry_parms *parms)
196 struct tf_session *tfs;
197 struct tf_dev_info *dev;
200 TF_CHECK_PARMS2(tfp, parms);
202 /* Retrieve the session information */
203 rc = tf_session_get_session(tfp, &tfs);
206 "%s: Failed to lookup session, rc:%s\n",
207 tf_dir_2_str(parms->dir),
212 /* Retrieve the device information */
213 rc = tf_session_get_device(tfs, &dev);
216 "%s: Failed to lookup device, rc:%s\n",
217 tf_dir_2_str(parms->dir),
222 if (parms->mem == TF_MEM_EXTERNAL &&
223 dev->ops->tf_dev_insert_ext_em_entry != NULL)
224 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
225 else if (parms->mem == TF_MEM_INTERNAL &&
226 dev->ops->tf_dev_insert_int_em_entry != NULL)
227 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
233 "%s: EM insert failed, rc:%s\n",
234 tf_dir_2_str(parms->dir),
242 /** Delete EM hash entry API
248 int tf_delete_em_entry(struct tf *tfp,
249 struct tf_delete_em_entry_parms *parms)
251 struct tf_session *tfs;
252 struct tf_dev_info *dev;
255 TF_CHECK_PARMS2(tfp, parms);
257 /* Retrieve the session information */
258 rc = tf_session_get_session(tfp, &tfs);
261 "%s: Failed to lookup session, rc:%s\n",
262 tf_dir_2_str(parms->dir),
267 /* Retrieve the device information */
268 rc = tf_session_get_device(tfs, &dev);
271 "%s: Failed to lookup device, rc:%s\n",
272 tf_dir_2_str(parms->dir),
277 if (parms->mem == TF_MEM_EXTERNAL)
278 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
279 else if (parms->mem == TF_MEM_INTERNAL)
280 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
286 "%s: EM delete failed, rc:%s\n",
287 tf_dir_2_str(parms->dir),
295 /** Get global configuration API
301 int tf_get_global_cfg(struct tf *tfp,
302 struct tf_global_cfg_parms *parms)
305 struct tf_session *tfs;
306 struct tf_dev_info *dev;
308 TF_CHECK_PARMS2(tfp, parms);
310 /* Retrieve the session information */
311 rc = tf_session_get_session(tfp, &tfs);
314 "%s: Failed to lookup session, rc:%s\n",
315 tf_dir_2_str(parms->dir),
320 /* Retrieve the device information */
321 rc = tf_session_get_device(tfs, &dev);
324 "%s: Failed to lookup device, rc:%s\n",
325 tf_dir_2_str(parms->dir),
330 if (parms->config == NULL ||
331 parms->config_sz_in_bytes == 0) {
332 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
336 if (dev->ops->tf_dev_get_global_cfg == NULL) {
339 "%s: Operation not supported, rc:%s\n",
340 tf_dir_2_str(parms->dir),
345 rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
348 "%s: Global Cfg get failed, rc:%s\n",
349 tf_dir_2_str(parms->dir),
357 /** Set global configuration API
363 int tf_set_global_cfg(struct tf *tfp,
364 struct tf_global_cfg_parms *parms)
367 struct tf_session *tfs;
368 struct tf_dev_info *dev;
370 TF_CHECK_PARMS2(tfp, parms);
372 /* Retrieve the session information */
373 rc = tf_session_get_session(tfp, &tfs);
376 "%s: Failed to lookup session, rc:%s\n",
377 tf_dir_2_str(parms->dir),
382 /* Retrieve the device information */
383 rc = tf_session_get_device(tfs, &dev);
386 "%s: Failed to lookup device, rc:%s\n",
387 tf_dir_2_str(parms->dir),
392 if (parms->config == NULL ||
393 parms->config_sz_in_bytes == 0) {
394 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
398 if (dev->ops->tf_dev_set_global_cfg == NULL) {
401 "%s: Operation not supported, rc:%s\n",
402 tf_dir_2_str(parms->dir),
407 rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
410 "%s: Global Cfg set failed, rc:%s\n",
411 tf_dir_2_str(parms->dir),
420 tf_alloc_identifier(struct tf *tfp,
421 struct tf_alloc_identifier_parms *parms)
424 struct tf_session *tfs;
425 struct tf_dev_info *dev;
426 struct tf_ident_alloc_parms aparms;
429 TF_CHECK_PARMS2(tfp, parms);
431 /* Can't do static initialization due to UT enum check */
432 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
434 /* Retrieve the session information */
435 rc = tf_session_get_session(tfp, &tfs);
438 "%s: Failed to lookup session, rc:%s\n",
439 tf_dir_2_str(parms->dir),
444 /* Retrieve the device information */
445 rc = tf_session_get_device(tfs, &dev);
448 "%s: Failed to lookup device, rc:%s\n",
449 tf_dir_2_str(parms->dir),
454 if (dev->ops->tf_dev_alloc_ident == NULL) {
457 "%s: Operation not supported, rc:%s\n",
458 tf_dir_2_str(parms->dir),
463 aparms.dir = parms->dir;
464 aparms.type = parms->ident_type;
466 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
469 "%s: Identifier allocation failed, rc:%s\n",
470 tf_dir_2_str(parms->dir),
481 tf_free_identifier(struct tf *tfp,
482 struct tf_free_identifier_parms *parms)
485 struct tf_session *tfs;
486 struct tf_dev_info *dev;
487 struct tf_ident_free_parms fparms;
489 TF_CHECK_PARMS2(tfp, parms);
491 /* Can't do static initialization due to UT enum check */
492 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
494 /* Retrieve the session information */
495 rc = tf_session_get_session(tfp, &tfs);
498 "%s: Failed to lookup session, rc:%s\n",
499 tf_dir_2_str(parms->dir),
504 /* Retrieve the device information */
505 rc = tf_session_get_device(tfs, &dev);
508 "%s: Failed to lookup device, rc:%s\n",
509 tf_dir_2_str(parms->dir),
514 if (dev->ops->tf_dev_free_ident == NULL) {
517 "%s: Operation not supported, rc:%s\n",
518 tf_dir_2_str(parms->dir),
523 fparms.dir = parms->dir;
524 fparms.type = parms->ident_type;
525 fparms.id = parms->id;
526 fparms.ref_cnt = &parms->ref_cnt;
527 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
530 "%s: Identifier free failed, rc:%s\n",
531 tf_dir_2_str(parms->dir),
540 tf_search_identifier(struct tf *tfp,
541 struct tf_search_identifier_parms *parms)
544 struct tf_session *tfs;
545 struct tf_dev_info *dev;
546 struct tf_ident_search_parms sparms;
548 TF_CHECK_PARMS2(tfp, parms);
550 /* Can't do static initialization due to UT enum check */
551 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
553 /* Retrieve the session information */
554 rc = tf_session_get_session(tfp, &tfs);
557 "%s: Failed to lookup session, rc:%s\n",
558 tf_dir_2_str(parms->dir),
563 /* Retrieve the device information */
564 rc = tf_session_get_device(tfs, &dev);
567 "%s: Failed to lookup device, rc:%s\n",
568 tf_dir_2_str(parms->dir),
573 if (dev->ops->tf_dev_search_ident == NULL) {
576 "%s: Operation not supported, rc:%s\n",
577 tf_dir_2_str(parms->dir),
582 sparms.dir = parms->dir;
583 sparms.type = parms->ident_type;
584 sparms.search_id = parms->search_id;
585 sparms.hit = &parms->hit;
586 sparms.ref_cnt = &parms->ref_cnt;
587 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
590 "%s: Identifier search failed, rc:%s\n",
591 tf_dir_2_str(parms->dir),
600 tf_search_tcam_entry(struct tf *tfp,
601 struct tf_search_tcam_entry_parms *parms)
604 struct tf_session *tfs;
605 struct tf_dev_info *dev;
606 struct tf_tcam_alloc_search_parms sparms;
608 TF_CHECK_PARMS2(tfp, parms);
610 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
612 /* Retrieve the session information */
613 rc = tf_session_get_session(tfp, &tfs);
616 "%s: Failed to lookup session, rc:%s\n",
617 tf_dir_2_str(parms->dir),
622 /* Retrieve the device information */
623 rc = tf_session_get_device(tfs, &dev);
626 "%s: Failed to lookup device, rc:%s\n",
627 tf_dir_2_str(parms->dir),
632 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
635 "%s: Operation not supported, rc:%s\n",
636 tf_dir_2_str(parms->dir),
641 sparms.dir = parms->dir;
642 sparms.type = parms->tcam_tbl_type;
643 sparms.key = parms->key;
644 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
645 sparms.mask = parms->mask;
646 sparms.priority = parms->priority;
647 sparms.alloc = parms->alloc;
649 /* Result is an in/out and so no need to copy during outputs */
650 sparms.result = parms->result;
652 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
654 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
657 "%s: TCAM allocation failed, rc:%s\n",
658 tf_dir_2_str(parms->dir),
663 /* Copy the outputs */
664 parms->hit = sparms.hit;
665 parms->search_status = sparms.search_status;
666 parms->ref_cnt = sparms.ref_cnt;
667 parms->idx = sparms.idx;
673 tf_alloc_tcam_entry(struct tf *tfp,
674 struct tf_alloc_tcam_entry_parms *parms)
677 struct tf_session *tfs;
678 struct tf_dev_info *dev;
679 struct tf_tcam_alloc_parms aparms;
681 TF_CHECK_PARMS2(tfp, parms);
683 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
685 /* Retrieve the session information */
686 rc = tf_session_get_session(tfp, &tfs);
689 "%s: Failed to lookup session, rc:%s\n",
690 tf_dir_2_str(parms->dir),
695 /* Retrieve the device information */
696 rc = tf_session_get_device(tfs, &dev);
699 "%s: Failed to lookup device, rc:%s\n",
700 tf_dir_2_str(parms->dir),
705 if (dev->ops->tf_dev_alloc_tcam == NULL) {
708 "%s: Operation not supported, rc:%s\n",
709 tf_dir_2_str(parms->dir),
714 aparms.dir = parms->dir;
715 aparms.type = parms->tcam_tbl_type;
716 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
717 aparms.priority = parms->priority;
718 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
721 "%s: TCAM allocation failed, rc:%s\n",
722 tf_dir_2_str(parms->dir),
727 parms->idx = aparms.idx;
733 tf_set_tcam_entry(struct tf *tfp,
734 struct tf_set_tcam_entry_parms *parms)
737 struct tf_session *tfs;
738 struct tf_dev_info *dev;
739 struct tf_tcam_set_parms sparms;
741 TF_CHECK_PARMS2(tfp, parms);
743 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
746 /* Retrieve the session information */
747 rc = tf_session_get_session(tfp, &tfs);
750 "%s: Failed to lookup session, rc:%s\n",
751 tf_dir_2_str(parms->dir),
756 /* Retrieve the device information */
757 rc = tf_session_get_device(tfs, &dev);
760 "%s: Failed to lookup device, rc:%s\n",
761 tf_dir_2_str(parms->dir),
766 if (dev->ops->tf_dev_set_tcam == NULL) {
769 "%s: Operation not supported, rc:%s\n",
770 tf_dir_2_str(parms->dir),
775 sparms.dir = parms->dir;
776 sparms.type = parms->tcam_tbl_type;
777 sparms.idx = parms->idx;
778 sparms.key = parms->key;
779 sparms.mask = parms->mask;
780 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
781 sparms.result = parms->result;
782 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
784 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
787 "%s: TCAM set failed, rc:%s\n",
788 tf_dir_2_str(parms->dir),
797 tf_get_tcam_entry(struct tf *tfp __rte_unused,
798 struct tf_get_tcam_entry_parms *parms __rte_unused)
800 TF_CHECK_PARMS2(tfp, parms);
805 tf_free_tcam_entry(struct tf *tfp,
806 struct tf_free_tcam_entry_parms *parms)
809 struct tf_session *tfs;
810 struct tf_dev_info *dev;
811 struct tf_tcam_free_parms fparms;
813 TF_CHECK_PARMS2(tfp, parms);
815 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
817 /* Retrieve the session information */
818 rc = tf_session_get_session(tfp, &tfs);
821 "%s: Failed to lookup session, rc:%s\n",
822 tf_dir_2_str(parms->dir),
827 /* Retrieve the device information */
828 rc = tf_session_get_device(tfs, &dev);
831 "%s: Failed to lookup device, rc:%s\n",
832 tf_dir_2_str(parms->dir),
837 if (dev->ops->tf_dev_free_tcam == NULL) {
840 "%s: Operation not supported, rc:%s\n",
841 tf_dir_2_str(parms->dir),
846 fparms.dir = parms->dir;
847 fparms.type = parms->tcam_tbl_type;
848 fparms.idx = parms->idx;
849 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
852 "%s: TCAM free failed, rc:%s\n",
853 tf_dir_2_str(parms->dir),
862 tf_alloc_tbl_entry(struct tf *tfp,
863 struct tf_alloc_tbl_entry_parms *parms)
866 struct tf_session *tfs;
867 struct tf_dev_info *dev;
868 struct tf_tbl_alloc_parms aparms;
871 TF_CHECK_PARMS2(tfp, parms);
873 /* Can't do static initialization due to UT enum check */
874 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
876 /* Retrieve the session information */
877 rc = tf_session_get_session(tfp, &tfs);
880 "%s: Failed to lookup session, rc:%s\n",
881 tf_dir_2_str(parms->dir),
886 /* Retrieve the device information */
887 rc = tf_session_get_device(tfs, &dev);
890 "%s: Failed to lookup device, rc:%s\n",
891 tf_dir_2_str(parms->dir),
896 aparms.dir = parms->dir;
897 aparms.type = parms->type;
899 aparms.tbl_scope_id = parms->tbl_scope_id;
901 if (parms->type == TF_TBL_TYPE_EXT) {
902 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
905 "%s: Operation not supported, rc:%s\n",
906 tf_dir_2_str(parms->dir),
911 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
914 "%s: External table allocation failed, rc:%s\n",
915 tf_dir_2_str(parms->dir),
921 if (dev->ops->tf_dev_alloc_tbl == NULL) {
924 "%s: Operation not supported, rc:%s\n",
925 tf_dir_2_str(parms->dir),
930 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
933 "%s: Table allocation failed, rc:%s\n",
934 tf_dir_2_str(parms->dir),
946 tf_search_tbl_entry(struct tf *tfp,
947 struct tf_search_tbl_entry_parms *parms)
950 struct tf_session *tfs;
951 struct tf_dev_info *dev;
952 struct tf_tbl_alloc_search_parms sparms;
954 TF_CHECK_PARMS2(tfp, parms);
956 /* Retrieve the session information */
957 rc = tf_session_get_session(tfp, &tfs);
960 "%s: Failed to lookup session, rc:%s\n",
961 tf_dir_2_str(parms->dir),
966 /* Retrieve the device information */
967 rc = tf_session_get_device(tfs, &dev);
970 "%s: Failed to lookup device, rc:%s\n",
971 tf_dir_2_str(parms->dir),
976 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
979 "%s: Operation not supported, rc:%s\n",
980 tf_dir_2_str(parms->dir),
985 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
986 sparms.dir = parms->dir;
987 sparms.type = parms->type;
988 sparms.result = parms->result;
989 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
990 sparms.alloc = parms->alloc;
991 sparms.tbl_scope_id = parms->tbl_scope_id;
992 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
995 "%s: TBL allocation failed, rc:%s\n",
996 tf_dir_2_str(parms->dir),
1001 /* Return the outputs from the search */
1002 parms->hit = sparms.hit;
1003 parms->search_status = sparms.search_status;
1004 parms->ref_cnt = sparms.ref_cnt;
1005 parms->idx = sparms.idx;
1011 tf_free_tbl_entry(struct tf *tfp,
1012 struct tf_free_tbl_entry_parms *parms)
1015 struct tf_session *tfs;
1016 struct tf_dev_info *dev;
1017 struct tf_tbl_free_parms fparms;
1019 TF_CHECK_PARMS2(tfp, parms);
1021 /* Can't do static initialization due to UT enum check */
1022 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1024 /* Retrieve the session information */
1025 rc = tf_session_get_session(tfp, &tfs);
1028 "%s: Failed to lookup session, rc:%s\n",
1029 tf_dir_2_str(parms->dir),
1034 /* Retrieve the device information */
1035 rc = tf_session_get_device(tfs, &dev);
1038 "%s: Failed to lookup device, rc:%s\n",
1039 tf_dir_2_str(parms->dir),
1044 fparms.dir = parms->dir;
1045 fparms.type = parms->type;
1046 fparms.idx = parms->idx;
1047 fparms.tbl_scope_id = parms->tbl_scope_id;
1049 if (parms->type == TF_TBL_TYPE_EXT) {
1050 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1053 "%s: Operation not supported, rc:%s\n",
1054 tf_dir_2_str(parms->dir),
1059 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1062 "%s: Table free failed, rc:%s\n",
1063 tf_dir_2_str(parms->dir),
1068 if (dev->ops->tf_dev_free_tbl == NULL) {
1071 "%s: Operation not supported, rc:%s\n",
1072 tf_dir_2_str(parms->dir),
1077 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1080 "%s: Table free failed, rc:%s\n",
1081 tf_dir_2_str(parms->dir),
1091 tf_set_tbl_entry(struct tf *tfp,
1092 struct tf_set_tbl_entry_parms *parms)
1095 struct tf_session *tfs;
1096 struct tf_dev_info *dev;
1097 struct tf_tbl_set_parms sparms;
1099 TF_CHECK_PARMS3(tfp, parms, parms->data);
1101 /* Can't do static initialization due to UT enum check */
1102 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1104 /* Retrieve the session information */
1105 rc = tf_session_get_session(tfp, &tfs);
1108 "%s: Failed to lookup session, rc:%s\n",
1109 tf_dir_2_str(parms->dir),
1114 /* Retrieve the device information */
1115 rc = tf_session_get_device(tfs, &dev);
1118 "%s: Failed to lookup device, rc:%s\n",
1119 tf_dir_2_str(parms->dir),
1124 sparms.dir = parms->dir;
1125 sparms.type = parms->type;
1126 sparms.data = parms->data;
1127 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1128 sparms.idx = parms->idx;
1129 sparms.tbl_scope_id = parms->tbl_scope_id;
1131 if (parms->type == TF_TBL_TYPE_EXT) {
1132 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1135 "%s: Operation not supported, rc:%s\n",
1136 tf_dir_2_str(parms->dir),
1141 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1144 "%s: Table set failed, rc:%s\n",
1145 tf_dir_2_str(parms->dir),
1150 if (dev->ops->tf_dev_set_tbl == NULL) {
1153 "%s: Operation not supported, rc:%s\n",
1154 tf_dir_2_str(parms->dir),
1159 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1162 "%s: Table set failed, rc:%s\n",
1163 tf_dir_2_str(parms->dir),
1173 tf_get_tbl_entry(struct tf *tfp,
1174 struct tf_get_tbl_entry_parms *parms)
1177 struct tf_session *tfs;
1178 struct tf_dev_info *dev;
1179 struct tf_tbl_get_parms gparms;
1181 TF_CHECK_PARMS3(tfp, parms, parms->data);
1183 /* Can't do static initialization due to UT enum check */
1184 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1186 /* Retrieve the session information */
1187 rc = tf_session_get_session(tfp, &tfs);
1190 "%s: Failed to lookup session, rc:%s\n",
1191 tf_dir_2_str(parms->dir),
1196 /* Retrieve the device information */
1197 rc = tf_session_get_device(tfs, &dev);
1200 "%s: Failed to lookup device, rc:%s\n",
1201 tf_dir_2_str(parms->dir),
1206 if (dev->ops->tf_dev_get_tbl == NULL) {
1209 "%s: Operation not supported, rc:%s\n",
1210 tf_dir_2_str(parms->dir),
1215 gparms.dir = parms->dir;
1216 gparms.type = parms->type;
1217 gparms.data = parms->data;
1218 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1219 gparms.idx = parms->idx;
1220 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1223 "%s: Table get failed, rc:%s\n",
1224 tf_dir_2_str(parms->dir),
1233 tf_bulk_get_tbl_entry(struct tf *tfp,
1234 struct tf_bulk_get_tbl_entry_parms *parms)
1237 struct tf_session *tfs;
1238 struct tf_dev_info *dev;
1239 struct tf_tbl_get_bulk_parms bparms;
1241 TF_CHECK_PARMS2(tfp, parms);
1243 /* Can't do static initialization due to UT enum check */
1244 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1246 /* Retrieve the session information */
1247 rc = tf_session_get_session(tfp, &tfs);
1250 "%s: Failed to lookup session, rc:%s\n",
1251 tf_dir_2_str(parms->dir),
1256 /* Retrieve the device information */
1257 rc = tf_session_get_device(tfs, &dev);
1260 "%s: Failed to lookup device, rc:%s\n",
1261 tf_dir_2_str(parms->dir),
1266 if (parms->type == TF_TBL_TYPE_EXT) {
1267 /* Not supported, yet */
1270 "%s, External table type not supported, rc:%s\n",
1271 tf_dir_2_str(parms->dir),
1277 /* Internal table type processing */
1279 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1282 "%s: Operation not supported, rc:%s\n",
1283 tf_dir_2_str(parms->dir),
1288 bparms.dir = parms->dir;
1289 bparms.type = parms->type;
1290 bparms.starting_idx = parms->starting_idx;
1291 bparms.num_entries = parms->num_entries;
1292 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1293 bparms.physical_mem_addr = parms->physical_mem_addr;
1294 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1297 "%s: Table get bulk failed, rc:%s\n",
1298 tf_dir_2_str(parms->dir),
1307 tf_alloc_tbl_scope(struct tf *tfp,
1308 struct tf_alloc_tbl_scope_parms *parms)
1310 struct tf_session *tfs;
1311 struct tf_dev_info *dev;
1314 TF_CHECK_PARMS2(tfp, parms);
1316 /* Retrieve the session information */
1317 rc = tf_session_get_session(tfp, &tfs);
1320 "Failed to lookup session, rc:%s\n",
1325 /* Retrieve the device information */
1326 rc = tf_session_get_device(tfs, &dev);
1329 "Failed to lookup device, rc:%s\n",
1334 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1335 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1338 "Alloc table scope not supported by device\n");
1345 tf_map_tbl_scope(struct tf *tfp,
1346 struct tf_map_tbl_scope_parms *parms)
1348 struct tf_session *tfs;
1349 struct tf_dev_info *dev;
1352 TF_CHECK_PARMS2(tfp, parms);
1354 /* Retrieve the session information */
1355 rc = tf_session_get_session(tfp, &tfs);
1358 "Failed to lookup session, rc:%s\n",
1363 /* Retrieve the device information */
1364 rc = tf_session_get_device(tfs, &dev);
1367 "Failed to lookup device, rc:%s\n",
1372 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1373 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1376 "Map table scope not supported by device\n");
1384 tf_free_tbl_scope(struct tf *tfp,
1385 struct tf_free_tbl_scope_parms *parms)
1387 struct tf_session *tfs;
1388 struct tf_dev_info *dev;
1391 TF_CHECK_PARMS2(tfp, parms);
1393 /* Retrieve the session information */
1394 rc = tf_session_get_session(tfp, &tfs);
1397 "Failed to lookup session, rc:%s\n",
1402 /* Retrieve the device information */
1403 rc = tf_session_get_device(tfs, &dev);
1406 "Failed to lookup device, rc:%s\n",
1411 if (dev->ops->tf_dev_free_tbl_scope) {
1412 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1415 "Free table scope not supported by device\n");
1423 tf_set_if_tbl_entry(struct tf *tfp,
1424 struct tf_set_if_tbl_entry_parms *parms)
1427 struct tf_session *tfs;
1428 struct tf_dev_info *dev;
1429 struct tf_if_tbl_set_parms sparms = { 0 };
1431 TF_CHECK_PARMS2(tfp, parms);
1433 /* Retrieve the session information */
1434 rc = tf_session_get_session(tfp, &tfs);
1437 "%s: Failed to lookup session, rc:%s\n",
1438 tf_dir_2_str(parms->dir),
1443 /* Retrieve the device information */
1444 rc = tf_session_get_device(tfs, &dev);
1447 "%s: Failed to lookup device, rc:%s\n",
1448 tf_dir_2_str(parms->dir),
1453 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1456 "%s: Operation not supported, rc:%s\n",
1457 tf_dir_2_str(parms->dir),
1462 sparms.dir = parms->dir;
1463 sparms.type = parms->type;
1464 sparms.idx = parms->idx;
1465 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1466 sparms.data = parms->data;
1468 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1471 "%s: If_tbl set failed, rc:%s\n",
1472 tf_dir_2_str(parms->dir),
1481 tf_get_if_tbl_entry(struct tf *tfp,
1482 struct tf_get_if_tbl_entry_parms *parms)
1485 struct tf_session *tfs;
1486 struct tf_dev_info *dev;
1487 struct tf_if_tbl_get_parms gparms = { 0 };
1489 TF_CHECK_PARMS2(tfp, parms);
1491 /* Retrieve the session information */
1492 rc = tf_session_get_session(tfp, &tfs);
1495 "%s: Failed to lookup session, rc:%s\n",
1496 tf_dir_2_str(parms->dir),
1501 /* Retrieve the device information */
1502 rc = tf_session_get_device(tfs, &dev);
1505 "%s: Failed to lookup device, rc:%s\n",
1506 tf_dir_2_str(parms->dir),
1511 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1514 "%s: Operation not supported, rc:%s\n",
1515 tf_dir_2_str(parms->dir),
1520 gparms.dir = parms->dir;
1521 gparms.type = parms->type;
1522 gparms.idx = parms->idx;
1523 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1524 gparms.data = parms->data;
1526 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1529 "%s: If_tbl get failed, rc:%s\n",
1530 tf_dir_2_str(parms->dir),