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"
22 #include "tf_ext_flow_handle.h"
25 tf_open_session(struct tf *tfp,
26 struct tf_open_session_parms *parms)
29 unsigned int domain, bus, slot, device;
30 struct tf_session_open_session_parms oparms;
32 TF_CHECK_PARMS2(tfp, parms);
34 /* Filter out any non-supported device types on the Core
35 * side. It is assumed that the Firmware will be supported if
36 * firmware open session succeeds.
38 if (parms->device_type != TF_DEVICE_TYPE_WH &&
39 parms->device_type != TF_DEVICE_TYPE_THOR &&
40 parms->device_type != TF_DEVICE_TYPE_SR) {
42 "Unsupported device type %d\n",
47 /* Verify control channel and build the beginning of session_id */
48 rc = sscanf(parms->ctrl_chan_name,
55 /* PCI Domain not provided (optional in DPDK), thus we
56 * force domain to 0 and recheck.
60 /* Check parsing of bus/slot/device */
61 rc = sscanf(parms->ctrl_chan_name,
68 "Failed to scan device ctrl_chan_name\n");
73 parms->session_id.internal.domain = domain;
74 parms->session_id.internal.bus = bus;
75 parms->session_id.internal.device = device;
76 oparms.open_cfg = parms;
78 /* Session vs session client is decided in
79 * tf_session_open_session()
81 rc = tf_session_open_session(tfp, &oparms);
82 /* Logging handled by tf_session_open_session */
87 "domain:%d, bus:%d, device:%u\n",
88 parms->session_id.internal.domain,
89 parms->session_id.internal.bus,
90 parms->session_id.internal.device);
96 tf_attach_session(struct tf *tfp,
97 struct tf_attach_session_parms *parms)
100 unsigned int domain, bus, slot, device;
101 struct tf_session_attach_session_parms aparms;
103 TF_CHECK_PARMS2(tfp, parms);
105 /* Verify control channel */
106 rc = sscanf(parms->ctrl_chan_name,
114 "Failed to scan device ctrl_chan_name\n");
118 /* Verify 'attach' channel */
119 rc = sscanf(parms->attach_chan_name,
127 "Failed to scan device attach_chan_name\n");
131 /* Prepare return value of session_id, using ctrl_chan_name
132 * device values as it becomes the session id.
134 parms->session_id.internal.domain = domain;
135 parms->session_id.internal.bus = bus;
136 parms->session_id.internal.device = device;
137 aparms.attach_cfg = parms;
138 rc = tf_session_attach_session(tfp,
140 /* Logging handled by dev_bind */
145 "Attached to session, session_id:%d\n",
146 parms->session_id.id);
149 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
150 parms->session_id.internal.domain,
151 parms->session_id.internal.bus,
152 parms->session_id.internal.device,
153 parms->session_id.internal.fw_session_id);
159 tf_close_session(struct tf *tfp)
162 struct tf_session_close_session_parms cparms = { 0 };
163 union tf_session_id session_id = { 0 };
166 TF_CHECK_PARMS1(tfp);
168 cparms.ref_count = &ref_count;
169 cparms.session_id = &session_id;
170 /* Session vs session client is decided in
171 * tf_session_close_session()
173 rc = tf_session_close_session(tfp,
175 /* Logging handled by tf_session_close_session */
180 "domain:%d, bus:%d, device:%d\n",
181 cparms.session_id->internal.domain,
182 cparms.session_id->internal.bus,
183 cparms.session_id->internal.device);
188 /** insert EM hash entry API
194 int tf_insert_em_entry(struct tf *tfp,
195 struct tf_insert_em_entry_parms *parms)
197 struct tf_session *tfs;
198 struct tf_dev_info *dev;
201 TF_CHECK_PARMS2(tfp, parms);
203 /* Retrieve the session information */
204 rc = tf_session_get_session(tfp, &tfs);
207 "%s: Failed to lookup session, rc:%s\n",
208 tf_dir_2_str(parms->dir),
213 /* Retrieve the device information */
214 rc = tf_session_get_device(tfs, &dev);
217 "%s: Failed to lookup device, rc:%s\n",
218 tf_dir_2_str(parms->dir),
223 if (parms->mem == TF_MEM_EXTERNAL &&
224 dev->ops->tf_dev_insert_ext_em_entry != NULL)
225 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
226 else if (parms->mem == TF_MEM_INTERNAL &&
227 dev->ops->tf_dev_insert_int_em_entry != NULL)
228 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
234 "%s: EM insert failed, rc:%s\n",
235 tf_dir_2_str(parms->dir),
243 /** Delete EM hash entry API
249 int tf_delete_em_entry(struct tf *tfp,
250 struct tf_delete_em_entry_parms *parms)
252 struct tf_session *tfs;
253 struct tf_dev_info *dev;
255 unsigned int flag = 0;
257 TF_CHECK_PARMS2(tfp, parms);
259 /* Retrieve the session information */
260 rc = tf_session_get_session(tfp, &tfs);
263 "%s: Failed to lookup session, rc:%s\n",
264 tf_dir_2_str(parms->dir),
269 /* Retrieve the device information */
270 rc = tf_session_get_device(tfs, &dev);
273 "%s: Failed to lookup device, rc:%s\n",
274 tf_dir_2_str(parms->dir),
279 TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
280 if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
281 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
283 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
287 "%s: EM delete failed, rc:%s\n",
288 tf_dir_2_str(parms->dir),
296 /** Get global configuration API
302 int tf_get_global_cfg(struct tf *tfp,
303 struct tf_global_cfg_parms *parms)
306 struct tf_session *tfs;
307 struct tf_dev_info *dev;
309 TF_CHECK_PARMS2(tfp, parms);
311 /* Retrieve the session information */
312 rc = tf_session_get_session(tfp, &tfs);
315 "%s: Failed to lookup session, rc:%s\n",
316 tf_dir_2_str(parms->dir),
321 /* Retrieve the device information */
322 rc = tf_session_get_device(tfs, &dev);
325 "%s: Failed to lookup device, rc:%s\n",
326 tf_dir_2_str(parms->dir),
331 if (parms->config == NULL ||
332 parms->config_sz_in_bytes == 0) {
333 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
337 if (dev->ops->tf_dev_get_global_cfg == NULL) {
340 "%s: Operation not supported, rc:%s\n",
341 tf_dir_2_str(parms->dir),
346 rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
349 "%s: Global Cfg get failed, rc:%s\n",
350 tf_dir_2_str(parms->dir),
358 /** Set global configuration API
364 int tf_set_global_cfg(struct tf *tfp,
365 struct tf_global_cfg_parms *parms)
368 struct tf_session *tfs;
369 struct tf_dev_info *dev;
371 TF_CHECK_PARMS2(tfp, parms);
373 /* Retrieve the session information */
374 rc = tf_session_get_session(tfp, &tfs);
377 "%s: Failed to lookup session, rc:%s\n",
378 tf_dir_2_str(parms->dir),
383 /* Retrieve the device information */
384 rc = tf_session_get_device(tfs, &dev);
387 "%s: Failed to lookup device, rc:%s\n",
388 tf_dir_2_str(parms->dir),
393 if (parms->config == NULL ||
394 parms->config_sz_in_bytes == 0) {
395 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
399 if (dev->ops->tf_dev_set_global_cfg == NULL) {
402 "%s: Operation not supported, rc:%s\n",
403 tf_dir_2_str(parms->dir),
408 rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
411 "%s: Global Cfg set failed, rc:%s\n",
412 tf_dir_2_str(parms->dir),
421 tf_alloc_identifier(struct tf *tfp,
422 struct tf_alloc_identifier_parms *parms)
425 struct tf_session *tfs;
426 struct tf_dev_info *dev;
427 struct tf_ident_alloc_parms aparms;
430 TF_CHECK_PARMS2(tfp, parms);
432 /* Can't do static initialization due to UT enum check */
433 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
435 /* Retrieve the session information */
436 rc = tf_session_get_session(tfp, &tfs);
439 "%s: Failed to lookup session, rc:%s\n",
440 tf_dir_2_str(parms->dir),
445 /* Retrieve the device information */
446 rc = tf_session_get_device(tfs, &dev);
449 "%s: Failed to lookup device, rc:%s\n",
450 tf_dir_2_str(parms->dir),
455 if (dev->ops->tf_dev_alloc_ident == NULL) {
458 "%s: Operation not supported, rc:%s\n",
459 tf_dir_2_str(parms->dir),
464 aparms.dir = parms->dir;
465 aparms.type = parms->ident_type;
467 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
470 "%s: Identifier allocation failed, rc:%s\n",
471 tf_dir_2_str(parms->dir),
482 tf_free_identifier(struct tf *tfp,
483 struct tf_free_identifier_parms *parms)
486 struct tf_session *tfs;
487 struct tf_dev_info *dev;
488 struct tf_ident_free_parms fparms;
490 TF_CHECK_PARMS2(tfp, parms);
492 /* Can't do static initialization due to UT enum check */
493 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
495 /* Retrieve the session information */
496 rc = tf_session_get_session(tfp, &tfs);
499 "%s: Failed to lookup session, rc:%s\n",
500 tf_dir_2_str(parms->dir),
505 /* Retrieve the device information */
506 rc = tf_session_get_device(tfs, &dev);
509 "%s: Failed to lookup device, rc:%s\n",
510 tf_dir_2_str(parms->dir),
515 if (dev->ops->tf_dev_free_ident == NULL) {
518 "%s: Operation not supported, rc:%s\n",
519 tf_dir_2_str(parms->dir),
524 fparms.dir = parms->dir;
525 fparms.type = parms->ident_type;
526 fparms.id = parms->id;
527 fparms.ref_cnt = &parms->ref_cnt;
528 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
531 "%s: Identifier free failed, rc:%s\n",
532 tf_dir_2_str(parms->dir),
541 tf_search_identifier(struct tf *tfp,
542 struct tf_search_identifier_parms *parms)
545 struct tf_session *tfs;
546 struct tf_dev_info *dev;
547 struct tf_ident_search_parms sparms;
549 TF_CHECK_PARMS2(tfp, parms);
551 /* Can't do static initialization due to UT enum check */
552 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
554 /* Retrieve the session information */
555 rc = tf_session_get_session(tfp, &tfs);
558 "%s: Failed to lookup session, rc:%s\n",
559 tf_dir_2_str(parms->dir),
564 /* Retrieve the device information */
565 rc = tf_session_get_device(tfs, &dev);
568 "%s: Failed to lookup device, rc:%s\n",
569 tf_dir_2_str(parms->dir),
574 if (dev->ops->tf_dev_search_ident == NULL) {
577 "%s: Operation not supported, rc:%s\n",
578 tf_dir_2_str(parms->dir),
583 sparms.dir = parms->dir;
584 sparms.type = parms->ident_type;
585 sparms.search_id = parms->search_id;
586 sparms.hit = &parms->hit;
587 sparms.ref_cnt = &parms->ref_cnt;
588 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
591 "%s: Identifier search failed, rc:%s\n",
592 tf_dir_2_str(parms->dir),
601 tf_search_tcam_entry(struct tf *tfp,
602 struct tf_search_tcam_entry_parms *parms)
605 struct tf_session *tfs;
606 struct tf_dev_info *dev;
607 struct tf_tcam_alloc_search_parms sparms;
609 TF_CHECK_PARMS2(tfp, parms);
611 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
613 /* Retrieve the session information */
614 rc = tf_session_get_session(tfp, &tfs);
617 "%s: Failed to lookup session, rc:%s\n",
618 tf_dir_2_str(parms->dir),
623 /* Retrieve the device information */
624 rc = tf_session_get_device(tfs, &dev);
627 "%s: Failed to lookup device, rc:%s\n",
628 tf_dir_2_str(parms->dir),
633 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
636 "%s: Operation not supported, rc:%s\n",
637 tf_dir_2_str(parms->dir),
642 sparms.dir = parms->dir;
643 sparms.type = parms->tcam_tbl_type;
644 sparms.key = parms->key;
645 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
646 sparms.mask = parms->mask;
647 sparms.priority = parms->priority;
648 sparms.alloc = parms->alloc;
650 /* Result is an in/out and so no need to copy during outputs */
651 sparms.result = parms->result;
653 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
655 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
658 "%s: TCAM allocation failed, rc:%s\n",
659 tf_dir_2_str(parms->dir),
664 /* Copy the outputs */
665 parms->hit = sparms.hit;
666 parms->search_status = sparms.search_status;
667 parms->ref_cnt = sparms.ref_cnt;
668 parms->idx = sparms.idx;
674 tf_alloc_tcam_entry(struct tf *tfp,
675 struct tf_alloc_tcam_entry_parms *parms)
678 struct tf_session *tfs;
679 struct tf_dev_info *dev;
680 struct tf_tcam_alloc_parms aparms;
682 TF_CHECK_PARMS2(tfp, parms);
684 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
686 /* Retrieve the session information */
687 rc = tf_session_get_session(tfp, &tfs);
690 "%s: Failed to lookup session, rc:%s\n",
691 tf_dir_2_str(parms->dir),
696 /* Retrieve the device information */
697 rc = tf_session_get_device(tfs, &dev);
700 "%s: Failed to lookup device, rc:%s\n",
701 tf_dir_2_str(parms->dir),
706 if (dev->ops->tf_dev_alloc_tcam == NULL) {
709 "%s: Operation not supported, rc:%s\n",
710 tf_dir_2_str(parms->dir),
715 aparms.dir = parms->dir;
716 aparms.type = parms->tcam_tbl_type;
717 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
718 aparms.priority = parms->priority;
719 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
722 "%s: TCAM allocation failed, rc:%s\n",
723 tf_dir_2_str(parms->dir),
728 parms->idx = aparms.idx;
734 tf_set_tcam_entry(struct tf *tfp,
735 struct tf_set_tcam_entry_parms *parms)
738 struct tf_session *tfs;
739 struct tf_dev_info *dev;
740 struct tf_tcam_set_parms sparms;
742 TF_CHECK_PARMS2(tfp, parms);
744 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
747 /* Retrieve the session information */
748 rc = tf_session_get_session(tfp, &tfs);
751 "%s: Failed to lookup session, rc:%s\n",
752 tf_dir_2_str(parms->dir),
757 /* Retrieve the device information */
758 rc = tf_session_get_device(tfs, &dev);
761 "%s: Failed to lookup device, rc:%s\n",
762 tf_dir_2_str(parms->dir),
767 if (dev->ops->tf_dev_set_tcam == NULL ||
768 dev->ops->tf_dev_word_align == NULL) {
771 "%s: Operation not supported, rc:%s\n",
772 tf_dir_2_str(parms->dir),
777 sparms.dir = parms->dir;
778 sparms.type = parms->tcam_tbl_type;
779 sparms.idx = parms->idx;
780 sparms.key = parms->key;
781 sparms.mask = parms->mask;
782 sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
783 sparms.result = parms->result;
784 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
786 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
789 "%s: TCAM set failed, rc:%s\n",
790 tf_dir_2_str(parms->dir),
799 tf_get_tcam_entry(struct tf *tfp __rte_unused,
800 struct tf_get_tcam_entry_parms *parms)
803 struct tf_session *tfs;
804 struct tf_dev_info *dev;
805 struct tf_tcam_get_parms gparms;
807 TF_CHECK_PARMS2(tfp, parms);
809 memset(&gparms, 0, sizeof(struct tf_tcam_get_parms));
812 /* Retrieve the session information */
813 rc = tf_session_get_session(tfp, &tfs);
816 "%s: Failed to lookup session, rc:%s\n",
817 tf_dir_2_str(parms->dir),
822 /* Retrieve the device information */
823 rc = tf_session_get_device(tfs, &dev);
826 "%s: Failed to lookup device, rc:%s\n",
827 tf_dir_2_str(parms->dir),
832 if (dev->ops->tf_dev_get_tcam == NULL) {
835 "%s: Operation not supported, rc:%s\n",
836 tf_dir_2_str(parms->dir),
841 gparms.dir = parms->dir;
842 gparms.type = parms->tcam_tbl_type;
843 gparms.idx = parms->idx;
844 gparms.key = parms->key;
845 gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
846 gparms.mask = parms->mask;
847 gparms.result = parms->result;
848 gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
850 rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
853 "%s: TCAM get failed, rc:%s\n",
854 tf_dir_2_str(parms->dir),
858 parms->key_sz_in_bits = gparms.key_size * 8;
859 parms->result_sz_in_bits = gparms.result_size * 8;
865 tf_free_tcam_entry(struct tf *tfp,
866 struct tf_free_tcam_entry_parms *parms)
869 struct tf_session *tfs;
870 struct tf_dev_info *dev;
871 struct tf_tcam_free_parms fparms;
873 TF_CHECK_PARMS2(tfp, parms);
875 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
877 /* Retrieve the session information */
878 rc = tf_session_get_session(tfp, &tfs);
881 "%s: Failed to lookup session, rc:%s\n",
882 tf_dir_2_str(parms->dir),
887 /* Retrieve the device information */
888 rc = tf_session_get_device(tfs, &dev);
891 "%s: Failed to lookup device, rc:%s\n",
892 tf_dir_2_str(parms->dir),
897 if (dev->ops->tf_dev_free_tcam == NULL) {
900 "%s: Operation not supported, rc:%s\n",
901 tf_dir_2_str(parms->dir),
906 fparms.dir = parms->dir;
907 fparms.type = parms->tcam_tbl_type;
908 fparms.idx = parms->idx;
909 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
912 "%s: TCAM free failed, rc:%s\n",
913 tf_dir_2_str(parms->dir),
922 tf_alloc_tbl_entry(struct tf *tfp,
923 struct tf_alloc_tbl_entry_parms *parms)
926 struct tf_session *tfs;
927 struct tf_dev_info *dev;
928 struct tf_tbl_alloc_parms aparms;
931 TF_CHECK_PARMS2(tfp, parms);
933 /* Can't do static initialization due to UT enum check */
934 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
936 /* Retrieve the session information */
937 rc = tf_session_get_session(tfp, &tfs);
940 "%s: Failed to lookup session, rc:%s\n",
941 tf_dir_2_str(parms->dir),
946 /* Retrieve the device information */
947 rc = tf_session_get_device(tfs, &dev);
950 "%s: Failed to lookup device, rc:%s\n",
951 tf_dir_2_str(parms->dir),
956 aparms.dir = parms->dir;
957 aparms.type = parms->type;
959 aparms.tbl_scope_id = parms->tbl_scope_id;
961 if (parms->type == TF_TBL_TYPE_EXT) {
962 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
965 "%s: Operation not supported, rc:%s\n",
966 tf_dir_2_str(parms->dir),
971 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
974 "%s: External table allocation failed, rc:%s\n",
975 tf_dir_2_str(parms->dir),
981 if (dev->ops->tf_dev_alloc_tbl == NULL) {
984 "%s: Operation not supported, rc:%s\n",
985 tf_dir_2_str(parms->dir),
990 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
993 "%s: Table allocation failed, rc:%s\n",
994 tf_dir_2_str(parms->dir),
1006 tf_search_tbl_entry(struct tf *tfp,
1007 struct tf_search_tbl_entry_parms *parms)
1010 struct tf_session *tfs;
1011 struct tf_dev_info *dev;
1012 struct tf_tbl_alloc_search_parms sparms;
1014 TF_CHECK_PARMS2(tfp, parms);
1016 /* Retrieve the session information */
1017 rc = tf_session_get_session(tfp, &tfs);
1020 "%s: Failed to lookup session, rc:%s\n",
1021 tf_dir_2_str(parms->dir),
1026 /* Retrieve the device information */
1027 rc = tf_session_get_device(tfs, &dev);
1030 "%s: Failed to lookup device, rc:%s\n",
1031 tf_dir_2_str(parms->dir),
1036 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
1039 "%s: Operation not supported, rc:%s\n",
1040 tf_dir_2_str(parms->dir),
1045 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
1046 sparms.dir = parms->dir;
1047 sparms.type = parms->type;
1048 sparms.result = parms->result;
1049 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
1050 sparms.alloc = parms->alloc;
1051 sparms.tbl_scope_id = parms->tbl_scope_id;
1052 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
1055 "%s: TBL allocation failed, rc:%s\n",
1056 tf_dir_2_str(parms->dir),
1061 /* Return the outputs from the search */
1062 parms->hit = sparms.hit;
1063 parms->search_status = sparms.search_status;
1064 parms->ref_cnt = sparms.ref_cnt;
1065 parms->idx = sparms.idx;
1071 tf_free_tbl_entry(struct tf *tfp,
1072 struct tf_free_tbl_entry_parms *parms)
1075 struct tf_session *tfs;
1076 struct tf_dev_info *dev;
1077 struct tf_tbl_free_parms fparms;
1079 TF_CHECK_PARMS2(tfp, parms);
1081 /* Can't do static initialization due to UT enum check */
1082 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1084 /* Retrieve the session information */
1085 rc = tf_session_get_session(tfp, &tfs);
1088 "%s: Failed to lookup session, rc:%s\n",
1089 tf_dir_2_str(parms->dir),
1094 /* Retrieve the device information */
1095 rc = tf_session_get_device(tfs, &dev);
1098 "%s: Failed to lookup device, rc:%s\n",
1099 tf_dir_2_str(parms->dir),
1104 fparms.dir = parms->dir;
1105 fparms.type = parms->type;
1106 fparms.idx = parms->idx;
1107 fparms.tbl_scope_id = parms->tbl_scope_id;
1109 if (parms->type == TF_TBL_TYPE_EXT) {
1110 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1113 "%s: Operation not supported, rc:%s\n",
1114 tf_dir_2_str(parms->dir),
1119 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1122 "%s: Table free failed, rc:%s\n",
1123 tf_dir_2_str(parms->dir),
1128 if (dev->ops->tf_dev_free_tbl == NULL) {
1131 "%s: Operation not supported, rc:%s\n",
1132 tf_dir_2_str(parms->dir),
1137 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1140 "%s: Table free failed, rc:%s\n",
1141 tf_dir_2_str(parms->dir),
1151 tf_set_tbl_entry(struct tf *tfp,
1152 struct tf_set_tbl_entry_parms *parms)
1155 struct tf_session *tfs;
1156 struct tf_dev_info *dev;
1157 struct tf_tbl_set_parms sparms;
1159 TF_CHECK_PARMS3(tfp, parms, parms->data);
1161 /* Can't do static initialization due to UT enum check */
1162 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1164 /* Retrieve the session information */
1165 rc = tf_session_get_session(tfp, &tfs);
1168 "%s: Failed to lookup session, rc:%s\n",
1169 tf_dir_2_str(parms->dir),
1174 /* Retrieve the device information */
1175 rc = tf_session_get_device(tfs, &dev);
1178 "%s: Failed to lookup device, rc:%s\n",
1179 tf_dir_2_str(parms->dir),
1184 sparms.dir = parms->dir;
1185 sparms.type = parms->type;
1186 sparms.data = parms->data;
1187 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1188 sparms.idx = parms->idx;
1189 sparms.tbl_scope_id = parms->tbl_scope_id;
1191 if (parms->type == TF_TBL_TYPE_EXT) {
1192 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1195 "%s: Operation not supported, rc:%s\n",
1196 tf_dir_2_str(parms->dir),
1201 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1204 "%s: Table set failed, rc:%s\n",
1205 tf_dir_2_str(parms->dir),
1210 if (dev->ops->tf_dev_set_tbl == NULL) {
1213 "%s: Operation not supported, rc:%s\n",
1214 tf_dir_2_str(parms->dir),
1219 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1222 "%s: Table set failed, rc:%s\n",
1223 tf_dir_2_str(parms->dir),
1233 tf_get_tbl_entry(struct tf *tfp,
1234 struct tf_get_tbl_entry_parms *parms)
1237 struct tf_session *tfs;
1238 struct tf_dev_info *dev;
1239 struct tf_tbl_get_parms gparms;
1241 TF_CHECK_PARMS3(tfp, parms, parms->data);
1243 /* Can't do static initialization due to UT enum check */
1244 memset(&gparms, 0, sizeof(struct tf_tbl_get_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 (dev->ops->tf_dev_get_tbl == NULL) {
1269 "%s: Operation not supported, rc:%s\n",
1270 tf_dir_2_str(parms->dir),
1275 gparms.dir = parms->dir;
1276 gparms.type = parms->type;
1277 gparms.data = parms->data;
1278 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1279 gparms.idx = parms->idx;
1280 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1283 "%s: Table get failed, rc:%s\n",
1284 tf_dir_2_str(parms->dir),
1293 tf_bulk_get_tbl_entry(struct tf *tfp,
1294 struct tf_bulk_get_tbl_entry_parms *parms)
1297 struct tf_session *tfs;
1298 struct tf_dev_info *dev;
1299 struct tf_tbl_get_bulk_parms bparms;
1301 TF_CHECK_PARMS2(tfp, parms);
1303 /* Can't do static initialization due to UT enum check */
1304 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1306 /* Retrieve the session information */
1307 rc = tf_session_get_session(tfp, &tfs);
1310 "%s: Failed to lookup session, rc:%s\n",
1311 tf_dir_2_str(parms->dir),
1316 /* Retrieve the device information */
1317 rc = tf_session_get_device(tfs, &dev);
1320 "%s: Failed to lookup device, rc:%s\n",
1321 tf_dir_2_str(parms->dir),
1326 if (parms->type == TF_TBL_TYPE_EXT) {
1327 /* Not supported, yet */
1330 "%s, External table type not supported, rc:%s\n",
1331 tf_dir_2_str(parms->dir),
1337 /* Internal table type processing */
1339 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1342 "%s: Operation not supported, rc:%s\n",
1343 tf_dir_2_str(parms->dir),
1348 bparms.dir = parms->dir;
1349 bparms.type = parms->type;
1350 bparms.starting_idx = parms->starting_idx;
1351 bparms.num_entries = parms->num_entries;
1352 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1353 bparms.physical_mem_addr = parms->physical_mem_addr;
1354 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1357 "%s: Table get bulk failed, rc:%s\n",
1358 tf_dir_2_str(parms->dir),
1367 tf_alloc_tbl_scope(struct tf *tfp,
1368 struct tf_alloc_tbl_scope_parms *parms)
1370 struct tf_session *tfs;
1371 struct tf_dev_info *dev;
1374 TF_CHECK_PARMS2(tfp, parms);
1376 /* Retrieve the session information */
1377 rc = tf_session_get_session(tfp, &tfs);
1380 "Failed to lookup session, rc:%s\n",
1385 /* Retrieve the device information */
1386 rc = tf_session_get_device(tfs, &dev);
1389 "Failed to lookup device, rc:%s\n",
1394 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1395 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1398 "Alloc table scope not supported by device\n");
1405 tf_map_tbl_scope(struct tf *tfp,
1406 struct tf_map_tbl_scope_parms *parms)
1408 struct tf_session *tfs;
1409 struct tf_dev_info *dev;
1412 TF_CHECK_PARMS2(tfp, parms);
1414 /* Retrieve the session information */
1415 rc = tf_session_get_session(tfp, &tfs);
1418 "Failed to lookup session, rc:%s\n",
1423 /* Retrieve the device information */
1424 rc = tf_session_get_device(tfs, &dev);
1427 "Failed to lookup device, rc:%s\n",
1432 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1433 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1436 "Map table scope not supported by device\n");
1444 tf_free_tbl_scope(struct tf *tfp,
1445 struct tf_free_tbl_scope_parms *parms)
1447 struct tf_session *tfs;
1448 struct tf_dev_info *dev;
1451 TF_CHECK_PARMS2(tfp, parms);
1453 /* Retrieve the session information */
1454 rc = tf_session_get_session(tfp, &tfs);
1457 "Failed to lookup session, rc:%s\n",
1462 /* Retrieve the device information */
1463 rc = tf_session_get_device(tfs, &dev);
1466 "Failed to lookup device, rc:%s\n",
1471 if (dev->ops->tf_dev_free_tbl_scope) {
1472 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1475 "Free table scope not supported by device\n");
1483 tf_set_if_tbl_entry(struct tf *tfp,
1484 struct tf_set_if_tbl_entry_parms *parms)
1487 struct tf_session *tfs;
1488 struct tf_dev_info *dev;
1489 struct tf_if_tbl_set_parms sparms = { 0 };
1491 TF_CHECK_PARMS2(tfp, parms);
1493 /* Retrieve the session information */
1494 rc = tf_session_get_session(tfp, &tfs);
1497 "%s: Failed to lookup session, rc:%s\n",
1498 tf_dir_2_str(parms->dir),
1503 /* Retrieve the device information */
1504 rc = tf_session_get_device(tfs, &dev);
1507 "%s: Failed to lookup device, rc:%s\n",
1508 tf_dir_2_str(parms->dir),
1513 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1516 "%s: Operation not supported, rc:%s\n",
1517 tf_dir_2_str(parms->dir),
1522 sparms.dir = parms->dir;
1523 sparms.type = parms->type;
1524 sparms.idx = parms->idx;
1525 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1526 sparms.data = parms->data;
1528 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1531 "%s: If_tbl set failed, rc:%s\n",
1532 tf_dir_2_str(parms->dir),
1541 tf_get_if_tbl_entry(struct tf *tfp,
1542 struct tf_get_if_tbl_entry_parms *parms)
1545 struct tf_session *tfs;
1546 struct tf_dev_info *dev;
1547 struct tf_if_tbl_get_parms gparms = { 0 };
1549 TF_CHECK_PARMS2(tfp, parms);
1551 /* Retrieve the session information */
1552 rc = tf_session_get_session(tfp, &tfs);
1555 "%s: Failed to lookup session, rc:%s\n",
1556 tf_dir_2_str(parms->dir),
1561 /* Retrieve the device information */
1562 rc = tf_session_get_device(tfs, &dev);
1565 "%s: Failed to lookup device, rc:%s\n",
1566 tf_dir_2_str(parms->dir),
1571 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1574 "%s: Operation not supported, rc:%s\n",
1575 tf_dir_2_str(parms->dir),
1580 gparms.dir = parms->dir;
1581 gparms.type = parms->type;
1582 gparms.idx = parms->idx;
1583 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1584 gparms.data = parms->data;
1586 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1589 "%s: If_tbl get failed, rc:%s\n",
1590 tf_dir_2_str(parms->dir),