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) {
770 "%s: Operation not supported, rc:%s\n",
771 tf_dir_2_str(parms->dir),
776 sparms.dir = parms->dir;
777 sparms.type = parms->tcam_tbl_type;
778 sparms.idx = parms->idx;
779 sparms.key = parms->key;
780 sparms.mask = parms->mask;
781 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
782 sparms.result = parms->result;
783 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
785 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
788 "%s: TCAM set failed, rc:%s\n",
789 tf_dir_2_str(parms->dir),
798 tf_get_tcam_entry(struct tf *tfp __rte_unused,
799 struct tf_get_tcam_entry_parms *parms __rte_unused)
801 TF_CHECK_PARMS2(tfp, parms);
806 tf_free_tcam_entry(struct tf *tfp,
807 struct tf_free_tcam_entry_parms *parms)
810 struct tf_session *tfs;
811 struct tf_dev_info *dev;
812 struct tf_tcam_free_parms fparms;
814 TF_CHECK_PARMS2(tfp, parms);
816 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
818 /* Retrieve the session information */
819 rc = tf_session_get_session(tfp, &tfs);
822 "%s: Failed to lookup session, rc:%s\n",
823 tf_dir_2_str(parms->dir),
828 /* Retrieve the device information */
829 rc = tf_session_get_device(tfs, &dev);
832 "%s: Failed to lookup device, rc:%s\n",
833 tf_dir_2_str(parms->dir),
838 if (dev->ops->tf_dev_free_tcam == NULL) {
841 "%s: Operation not supported, rc:%s\n",
842 tf_dir_2_str(parms->dir),
847 fparms.dir = parms->dir;
848 fparms.type = parms->tcam_tbl_type;
849 fparms.idx = parms->idx;
850 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
853 "%s: TCAM free failed, rc:%s\n",
854 tf_dir_2_str(parms->dir),
863 tf_alloc_tbl_entry(struct tf *tfp,
864 struct tf_alloc_tbl_entry_parms *parms)
867 struct tf_session *tfs;
868 struct tf_dev_info *dev;
869 struct tf_tbl_alloc_parms aparms;
872 TF_CHECK_PARMS2(tfp, parms);
874 /* Can't do static initialization due to UT enum check */
875 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_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 aparms.dir = parms->dir;
898 aparms.type = parms->type;
900 aparms.tbl_scope_id = parms->tbl_scope_id;
902 if (parms->type == TF_TBL_TYPE_EXT) {
903 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
906 "%s: Operation not supported, rc:%s\n",
907 tf_dir_2_str(parms->dir),
912 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
915 "%s: External table allocation failed, rc:%s\n",
916 tf_dir_2_str(parms->dir),
922 if (dev->ops->tf_dev_alloc_tbl == NULL) {
925 "%s: Operation not supported, rc:%s\n",
926 tf_dir_2_str(parms->dir),
931 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
934 "%s: Table allocation failed, rc:%s\n",
935 tf_dir_2_str(parms->dir),
947 tf_search_tbl_entry(struct tf *tfp,
948 struct tf_search_tbl_entry_parms *parms)
951 struct tf_session *tfs;
952 struct tf_dev_info *dev;
953 struct tf_tbl_alloc_search_parms sparms;
955 TF_CHECK_PARMS2(tfp, parms);
957 /* Retrieve the session information */
958 rc = tf_session_get_session(tfp, &tfs);
961 "%s: Failed to lookup session, rc:%s\n",
962 tf_dir_2_str(parms->dir),
967 /* Retrieve the device information */
968 rc = tf_session_get_device(tfs, &dev);
971 "%s: Failed to lookup device, rc:%s\n",
972 tf_dir_2_str(parms->dir),
977 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
980 "%s: Operation not supported, rc:%s\n",
981 tf_dir_2_str(parms->dir),
986 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
987 sparms.dir = parms->dir;
988 sparms.type = parms->type;
989 sparms.result = parms->result;
990 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
991 sparms.alloc = parms->alloc;
992 sparms.tbl_scope_id = parms->tbl_scope_id;
993 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
996 "%s: TBL allocation failed, rc:%s\n",
997 tf_dir_2_str(parms->dir),
1002 /* Return the outputs from the search */
1003 parms->hit = sparms.hit;
1004 parms->search_status = sparms.search_status;
1005 parms->ref_cnt = sparms.ref_cnt;
1006 parms->idx = sparms.idx;
1012 tf_free_tbl_entry(struct tf *tfp,
1013 struct tf_free_tbl_entry_parms *parms)
1016 struct tf_session *tfs;
1017 struct tf_dev_info *dev;
1018 struct tf_tbl_free_parms fparms;
1020 TF_CHECK_PARMS2(tfp, parms);
1022 /* Can't do static initialization due to UT enum check */
1023 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1025 /* Retrieve the session information */
1026 rc = tf_session_get_session(tfp, &tfs);
1029 "%s: Failed to lookup session, rc:%s\n",
1030 tf_dir_2_str(parms->dir),
1035 /* Retrieve the device information */
1036 rc = tf_session_get_device(tfs, &dev);
1039 "%s: Failed to lookup device, rc:%s\n",
1040 tf_dir_2_str(parms->dir),
1045 fparms.dir = parms->dir;
1046 fparms.type = parms->type;
1047 fparms.idx = parms->idx;
1048 fparms.tbl_scope_id = parms->tbl_scope_id;
1050 if (parms->type == TF_TBL_TYPE_EXT) {
1051 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1054 "%s: Operation not supported, rc:%s\n",
1055 tf_dir_2_str(parms->dir),
1060 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1063 "%s: Table free failed, rc:%s\n",
1064 tf_dir_2_str(parms->dir),
1069 if (dev->ops->tf_dev_free_tbl == NULL) {
1072 "%s: Operation not supported, rc:%s\n",
1073 tf_dir_2_str(parms->dir),
1078 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1081 "%s: Table free failed, rc:%s\n",
1082 tf_dir_2_str(parms->dir),
1092 tf_set_tbl_entry(struct tf *tfp,
1093 struct tf_set_tbl_entry_parms *parms)
1096 struct tf_session *tfs;
1097 struct tf_dev_info *dev;
1098 struct tf_tbl_set_parms sparms;
1100 TF_CHECK_PARMS3(tfp, parms, parms->data);
1102 /* Can't do static initialization due to UT enum check */
1103 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1105 /* Retrieve the session information */
1106 rc = tf_session_get_session(tfp, &tfs);
1109 "%s: Failed to lookup session, rc:%s\n",
1110 tf_dir_2_str(parms->dir),
1115 /* Retrieve the device information */
1116 rc = tf_session_get_device(tfs, &dev);
1119 "%s: Failed to lookup device, rc:%s\n",
1120 tf_dir_2_str(parms->dir),
1125 sparms.dir = parms->dir;
1126 sparms.type = parms->type;
1127 sparms.data = parms->data;
1128 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1129 sparms.idx = parms->idx;
1130 sparms.tbl_scope_id = parms->tbl_scope_id;
1132 if (parms->type == TF_TBL_TYPE_EXT) {
1133 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1136 "%s: Operation not supported, rc:%s\n",
1137 tf_dir_2_str(parms->dir),
1142 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1145 "%s: Table set failed, rc:%s\n",
1146 tf_dir_2_str(parms->dir),
1151 if (dev->ops->tf_dev_set_tbl == NULL) {
1154 "%s: Operation not supported, rc:%s\n",
1155 tf_dir_2_str(parms->dir),
1160 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1163 "%s: Table set failed, rc:%s\n",
1164 tf_dir_2_str(parms->dir),
1174 tf_get_tbl_entry(struct tf *tfp,
1175 struct tf_get_tbl_entry_parms *parms)
1178 struct tf_session *tfs;
1179 struct tf_dev_info *dev;
1180 struct tf_tbl_get_parms gparms;
1182 TF_CHECK_PARMS3(tfp, parms, parms->data);
1184 /* Can't do static initialization due to UT enum check */
1185 memset(&gparms, 0, sizeof(struct tf_tbl_get_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_get_tbl == NULL) {
1210 "%s: Operation not supported, rc:%s\n",
1211 tf_dir_2_str(parms->dir),
1216 gparms.dir = parms->dir;
1217 gparms.type = parms->type;
1218 gparms.data = parms->data;
1219 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1220 gparms.idx = parms->idx;
1221 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1224 "%s: Table get failed, rc:%s\n",
1225 tf_dir_2_str(parms->dir),
1234 tf_bulk_get_tbl_entry(struct tf *tfp,
1235 struct tf_bulk_get_tbl_entry_parms *parms)
1238 struct tf_session *tfs;
1239 struct tf_dev_info *dev;
1240 struct tf_tbl_get_bulk_parms bparms;
1242 TF_CHECK_PARMS2(tfp, parms);
1244 /* Can't do static initialization due to UT enum check */
1245 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1247 /* Retrieve the session information */
1248 rc = tf_session_get_session(tfp, &tfs);
1251 "%s: Failed to lookup session, rc:%s\n",
1252 tf_dir_2_str(parms->dir),
1257 /* Retrieve the device information */
1258 rc = tf_session_get_device(tfs, &dev);
1261 "%s: Failed to lookup device, rc:%s\n",
1262 tf_dir_2_str(parms->dir),
1267 if (parms->type == TF_TBL_TYPE_EXT) {
1268 /* Not supported, yet */
1271 "%s, External table type not supported, rc:%s\n",
1272 tf_dir_2_str(parms->dir),
1278 /* Internal table type processing */
1280 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1283 "%s: Operation not supported, rc:%s\n",
1284 tf_dir_2_str(parms->dir),
1289 bparms.dir = parms->dir;
1290 bparms.type = parms->type;
1291 bparms.starting_idx = parms->starting_idx;
1292 bparms.num_entries = parms->num_entries;
1293 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1294 bparms.physical_mem_addr = parms->physical_mem_addr;
1295 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1298 "%s: Table get bulk failed, rc:%s\n",
1299 tf_dir_2_str(parms->dir),
1308 tf_alloc_tbl_scope(struct tf *tfp,
1309 struct tf_alloc_tbl_scope_parms *parms)
1311 struct tf_session *tfs;
1312 struct tf_dev_info *dev;
1315 TF_CHECK_PARMS2(tfp, parms);
1317 /* Retrieve the session information */
1318 rc = tf_session_get_session(tfp, &tfs);
1321 "Failed to lookup session, rc:%s\n",
1326 /* Retrieve the device information */
1327 rc = tf_session_get_device(tfs, &dev);
1330 "Failed to lookup device, rc:%s\n",
1335 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1336 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1339 "Alloc table scope not supported by device\n");
1346 tf_map_tbl_scope(struct tf *tfp,
1347 struct tf_map_tbl_scope_parms *parms)
1349 struct tf_session *tfs;
1350 struct tf_dev_info *dev;
1353 TF_CHECK_PARMS2(tfp, parms);
1355 /* Retrieve the session information */
1356 rc = tf_session_get_session(tfp, &tfs);
1359 "Failed to lookup session, rc:%s\n",
1364 /* Retrieve the device information */
1365 rc = tf_session_get_device(tfs, &dev);
1368 "Failed to lookup device, rc:%s\n",
1373 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1374 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1377 "Map table scope not supported by device\n");
1385 tf_free_tbl_scope(struct tf *tfp,
1386 struct tf_free_tbl_scope_parms *parms)
1388 struct tf_session *tfs;
1389 struct tf_dev_info *dev;
1392 TF_CHECK_PARMS2(tfp, parms);
1394 /* Retrieve the session information */
1395 rc = tf_session_get_session(tfp, &tfs);
1398 "Failed to lookup session, rc:%s\n",
1403 /* Retrieve the device information */
1404 rc = tf_session_get_device(tfs, &dev);
1407 "Failed to lookup device, rc:%s\n",
1412 if (dev->ops->tf_dev_free_tbl_scope) {
1413 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1416 "Free table scope not supported by device\n");
1424 tf_set_if_tbl_entry(struct tf *tfp,
1425 struct tf_set_if_tbl_entry_parms *parms)
1428 struct tf_session *tfs;
1429 struct tf_dev_info *dev;
1430 struct tf_if_tbl_set_parms sparms = { 0 };
1432 TF_CHECK_PARMS2(tfp, parms);
1434 /* Retrieve the session information */
1435 rc = tf_session_get_session(tfp, &tfs);
1438 "%s: Failed to lookup session, rc:%s\n",
1439 tf_dir_2_str(parms->dir),
1444 /* Retrieve the device information */
1445 rc = tf_session_get_device(tfs, &dev);
1448 "%s: Failed to lookup device, rc:%s\n",
1449 tf_dir_2_str(parms->dir),
1454 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1457 "%s: Operation not supported, rc:%s\n",
1458 tf_dir_2_str(parms->dir),
1463 sparms.dir = parms->dir;
1464 sparms.type = parms->type;
1465 sparms.idx = parms->idx;
1466 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1467 sparms.data = parms->data;
1469 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1472 "%s: If_tbl set failed, rc:%s\n",
1473 tf_dir_2_str(parms->dir),
1482 tf_get_if_tbl_entry(struct tf *tfp,
1483 struct tf_get_if_tbl_entry_parms *parms)
1486 struct tf_session *tfs;
1487 struct tf_dev_info *dev;
1488 struct tf_if_tbl_get_parms gparms = { 0 };
1490 TF_CHECK_PARMS2(tfp, parms);
1492 /* Retrieve the session information */
1493 rc = tf_session_get_session(tfp, &tfs);
1496 "%s: Failed to lookup session, rc:%s\n",
1497 tf_dir_2_str(parms->dir),
1502 /* Retrieve the device information */
1503 rc = tf_session_get_device(tfs, &dev);
1506 "%s: Failed to lookup device, rc:%s\n",
1507 tf_dir_2_str(parms->dir),
1512 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1515 "%s: Operation not supported, rc:%s\n",
1516 tf_dir_2_str(parms->dir),
1521 gparms.dir = parms->dir;
1522 gparms.type = parms->type;
1523 gparms.idx = parms->idx;
1524 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1525 gparms.data = parms->data;
1527 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1530 "%s: If_tbl get failed, rc:%s\n",
1531 tf_dir_2_str(parms->dir),