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.mask = parms->mask;
846 gparms.result = parms->result;
848 rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
851 "%s: TCAM get failed, rc:%s\n",
852 tf_dir_2_str(parms->dir),
856 parms->key_sz_in_bits = gparms.key_size * 8;
857 parms->result_sz_in_bits = gparms.result_size * 8;
863 tf_free_tcam_entry(struct tf *tfp,
864 struct tf_free_tcam_entry_parms *parms)
867 struct tf_session *tfs;
868 struct tf_dev_info *dev;
869 struct tf_tcam_free_parms fparms;
871 TF_CHECK_PARMS2(tfp, parms);
873 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
875 /* Retrieve the session information */
876 rc = tf_session_get_session(tfp, &tfs);
879 "%s: Failed to lookup session, rc:%s\n",
880 tf_dir_2_str(parms->dir),
885 /* Retrieve the device information */
886 rc = tf_session_get_device(tfs, &dev);
889 "%s: Failed to lookup device, rc:%s\n",
890 tf_dir_2_str(parms->dir),
895 if (dev->ops->tf_dev_free_tcam == NULL) {
898 "%s: Operation not supported, rc:%s\n",
899 tf_dir_2_str(parms->dir),
904 fparms.dir = parms->dir;
905 fparms.type = parms->tcam_tbl_type;
906 fparms.idx = parms->idx;
907 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
910 "%s: TCAM free failed, rc:%s\n",
911 tf_dir_2_str(parms->dir),
920 tf_alloc_tbl_entry(struct tf *tfp,
921 struct tf_alloc_tbl_entry_parms *parms)
924 struct tf_session *tfs;
925 struct tf_dev_info *dev;
926 struct tf_tbl_alloc_parms aparms;
929 TF_CHECK_PARMS2(tfp, parms);
931 /* Can't do static initialization due to UT enum check */
932 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
934 /* Retrieve the session information */
935 rc = tf_session_get_session(tfp, &tfs);
938 "%s: Failed to lookup session, rc:%s\n",
939 tf_dir_2_str(parms->dir),
944 /* Retrieve the device information */
945 rc = tf_session_get_device(tfs, &dev);
948 "%s: Failed to lookup device, rc:%s\n",
949 tf_dir_2_str(parms->dir),
954 aparms.dir = parms->dir;
955 aparms.type = parms->type;
957 aparms.tbl_scope_id = parms->tbl_scope_id;
959 if (parms->type == TF_TBL_TYPE_EXT) {
960 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
963 "%s: Operation not supported, rc:%s\n",
964 tf_dir_2_str(parms->dir),
969 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
972 "%s: External table allocation failed, rc:%s\n",
973 tf_dir_2_str(parms->dir),
979 if (dev->ops->tf_dev_alloc_tbl == NULL) {
982 "%s: Operation not supported, rc:%s\n",
983 tf_dir_2_str(parms->dir),
988 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
991 "%s: Table allocation failed, rc:%s\n",
992 tf_dir_2_str(parms->dir),
1004 tf_search_tbl_entry(struct tf *tfp,
1005 struct tf_search_tbl_entry_parms *parms)
1008 struct tf_session *tfs;
1009 struct tf_dev_info *dev;
1010 struct tf_tbl_alloc_search_parms sparms;
1012 TF_CHECK_PARMS2(tfp, parms);
1014 /* Retrieve the session information */
1015 rc = tf_session_get_session(tfp, &tfs);
1018 "%s: Failed to lookup session, rc:%s\n",
1019 tf_dir_2_str(parms->dir),
1024 /* Retrieve the device information */
1025 rc = tf_session_get_device(tfs, &dev);
1028 "%s: Failed to lookup device, rc:%s\n",
1029 tf_dir_2_str(parms->dir),
1034 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
1037 "%s: Operation not supported, rc:%s\n",
1038 tf_dir_2_str(parms->dir),
1043 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
1044 sparms.dir = parms->dir;
1045 sparms.type = parms->type;
1046 sparms.result = parms->result;
1047 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
1048 sparms.alloc = parms->alloc;
1049 sparms.tbl_scope_id = parms->tbl_scope_id;
1050 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
1053 "%s: TBL allocation failed, rc:%s\n",
1054 tf_dir_2_str(parms->dir),
1059 /* Return the outputs from the search */
1060 parms->hit = sparms.hit;
1061 parms->search_status = sparms.search_status;
1062 parms->ref_cnt = sparms.ref_cnt;
1063 parms->idx = sparms.idx;
1069 tf_free_tbl_entry(struct tf *tfp,
1070 struct tf_free_tbl_entry_parms *parms)
1073 struct tf_session *tfs;
1074 struct tf_dev_info *dev;
1075 struct tf_tbl_free_parms fparms;
1077 TF_CHECK_PARMS2(tfp, parms);
1079 /* Can't do static initialization due to UT enum check */
1080 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1082 /* Retrieve the session information */
1083 rc = tf_session_get_session(tfp, &tfs);
1086 "%s: Failed to lookup session, rc:%s\n",
1087 tf_dir_2_str(parms->dir),
1092 /* Retrieve the device information */
1093 rc = tf_session_get_device(tfs, &dev);
1096 "%s: Failed to lookup device, rc:%s\n",
1097 tf_dir_2_str(parms->dir),
1102 fparms.dir = parms->dir;
1103 fparms.type = parms->type;
1104 fparms.idx = parms->idx;
1105 fparms.tbl_scope_id = parms->tbl_scope_id;
1107 if (parms->type == TF_TBL_TYPE_EXT) {
1108 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1111 "%s: Operation not supported, rc:%s\n",
1112 tf_dir_2_str(parms->dir),
1117 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1120 "%s: Table free failed, rc:%s\n",
1121 tf_dir_2_str(parms->dir),
1126 if (dev->ops->tf_dev_free_tbl == NULL) {
1129 "%s: Operation not supported, rc:%s\n",
1130 tf_dir_2_str(parms->dir),
1135 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1138 "%s: Table free failed, rc:%s\n",
1139 tf_dir_2_str(parms->dir),
1149 tf_set_tbl_entry(struct tf *tfp,
1150 struct tf_set_tbl_entry_parms *parms)
1153 struct tf_session *tfs;
1154 struct tf_dev_info *dev;
1155 struct tf_tbl_set_parms sparms;
1157 TF_CHECK_PARMS3(tfp, parms, parms->data);
1159 /* Can't do static initialization due to UT enum check */
1160 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1162 /* Retrieve the session information */
1163 rc = tf_session_get_session(tfp, &tfs);
1166 "%s: Failed to lookup session, rc:%s\n",
1167 tf_dir_2_str(parms->dir),
1172 /* Retrieve the device information */
1173 rc = tf_session_get_device(tfs, &dev);
1176 "%s: Failed to lookup device, rc:%s\n",
1177 tf_dir_2_str(parms->dir),
1182 sparms.dir = parms->dir;
1183 sparms.type = parms->type;
1184 sparms.data = parms->data;
1185 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1186 sparms.idx = parms->idx;
1187 sparms.tbl_scope_id = parms->tbl_scope_id;
1189 if (parms->type == TF_TBL_TYPE_EXT) {
1190 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1193 "%s: Operation not supported, rc:%s\n",
1194 tf_dir_2_str(parms->dir),
1199 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1202 "%s: Table set failed, rc:%s\n",
1203 tf_dir_2_str(parms->dir),
1208 if (dev->ops->tf_dev_set_tbl == NULL) {
1211 "%s: Operation not supported, rc:%s\n",
1212 tf_dir_2_str(parms->dir),
1217 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1220 "%s: Table set failed, rc:%s\n",
1221 tf_dir_2_str(parms->dir),
1231 tf_get_tbl_entry(struct tf *tfp,
1232 struct tf_get_tbl_entry_parms *parms)
1235 struct tf_session *tfs;
1236 struct tf_dev_info *dev;
1237 struct tf_tbl_get_parms gparms;
1239 TF_CHECK_PARMS3(tfp, parms, parms->data);
1241 /* Can't do static initialization due to UT enum check */
1242 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1244 /* Retrieve the session information */
1245 rc = tf_session_get_session(tfp, &tfs);
1248 "%s: Failed to lookup session, rc:%s\n",
1249 tf_dir_2_str(parms->dir),
1254 /* Retrieve the device information */
1255 rc = tf_session_get_device(tfs, &dev);
1258 "%s: Failed to lookup device, rc:%s\n",
1259 tf_dir_2_str(parms->dir),
1264 if (dev->ops->tf_dev_get_tbl == NULL) {
1267 "%s: Operation not supported, rc:%s\n",
1268 tf_dir_2_str(parms->dir),
1273 gparms.dir = parms->dir;
1274 gparms.type = parms->type;
1275 gparms.data = parms->data;
1276 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1277 gparms.idx = parms->idx;
1278 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1281 "%s: Table get failed, rc:%s\n",
1282 tf_dir_2_str(parms->dir),
1291 tf_bulk_get_tbl_entry(struct tf *tfp,
1292 struct tf_bulk_get_tbl_entry_parms *parms)
1295 struct tf_session *tfs;
1296 struct tf_dev_info *dev;
1297 struct tf_tbl_get_bulk_parms bparms;
1299 TF_CHECK_PARMS2(tfp, parms);
1301 /* Can't do static initialization due to UT enum check */
1302 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1304 /* Retrieve the session information */
1305 rc = tf_session_get_session(tfp, &tfs);
1308 "%s: Failed to lookup session, rc:%s\n",
1309 tf_dir_2_str(parms->dir),
1314 /* Retrieve the device information */
1315 rc = tf_session_get_device(tfs, &dev);
1318 "%s: Failed to lookup device, rc:%s\n",
1319 tf_dir_2_str(parms->dir),
1324 if (parms->type == TF_TBL_TYPE_EXT) {
1325 /* Not supported, yet */
1328 "%s, External table type not supported, rc:%s\n",
1329 tf_dir_2_str(parms->dir),
1335 /* Internal table type processing */
1337 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1340 "%s: Operation not supported, rc:%s\n",
1341 tf_dir_2_str(parms->dir),
1346 bparms.dir = parms->dir;
1347 bparms.type = parms->type;
1348 bparms.starting_idx = parms->starting_idx;
1349 bparms.num_entries = parms->num_entries;
1350 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1351 bparms.physical_mem_addr = parms->physical_mem_addr;
1352 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1355 "%s: Table get bulk failed, rc:%s\n",
1356 tf_dir_2_str(parms->dir),
1365 tf_alloc_tbl_scope(struct tf *tfp,
1366 struct tf_alloc_tbl_scope_parms *parms)
1368 struct tf_session *tfs;
1369 struct tf_dev_info *dev;
1372 TF_CHECK_PARMS2(tfp, parms);
1374 /* Retrieve the session information */
1375 rc = tf_session_get_session(tfp, &tfs);
1378 "Failed to lookup session, rc:%s\n",
1383 /* Retrieve the device information */
1384 rc = tf_session_get_device(tfs, &dev);
1387 "Failed to lookup device, rc:%s\n",
1392 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1393 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1396 "Alloc table scope not supported by device\n");
1403 tf_map_tbl_scope(struct tf *tfp,
1404 struct tf_map_tbl_scope_parms *parms)
1406 struct tf_session *tfs;
1407 struct tf_dev_info *dev;
1410 TF_CHECK_PARMS2(tfp, parms);
1412 /* Retrieve the session information */
1413 rc = tf_session_get_session(tfp, &tfs);
1416 "Failed to lookup session, rc:%s\n",
1421 /* Retrieve the device information */
1422 rc = tf_session_get_device(tfs, &dev);
1425 "Failed to lookup device, rc:%s\n",
1430 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1431 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1434 "Map table scope not supported by device\n");
1442 tf_free_tbl_scope(struct tf *tfp,
1443 struct tf_free_tbl_scope_parms *parms)
1445 struct tf_session *tfs;
1446 struct tf_dev_info *dev;
1449 TF_CHECK_PARMS2(tfp, parms);
1451 /* Retrieve the session information */
1452 rc = tf_session_get_session(tfp, &tfs);
1455 "Failed to lookup session, rc:%s\n",
1460 /* Retrieve the device information */
1461 rc = tf_session_get_device(tfs, &dev);
1464 "Failed to lookup device, rc:%s\n",
1469 if (dev->ops->tf_dev_free_tbl_scope) {
1470 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1473 "Free table scope not supported by device\n");
1481 tf_set_if_tbl_entry(struct tf *tfp,
1482 struct tf_set_if_tbl_entry_parms *parms)
1485 struct tf_session *tfs;
1486 struct tf_dev_info *dev;
1487 struct tf_if_tbl_set_parms sparms = { 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_set_if_tbl == NULL) {
1514 "%s: Operation not supported, rc:%s\n",
1515 tf_dir_2_str(parms->dir),
1520 sparms.dir = parms->dir;
1521 sparms.type = parms->type;
1522 sparms.idx = parms->idx;
1523 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1524 sparms.data = parms->data;
1526 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1529 "%s: If_tbl set failed, rc:%s\n",
1530 tf_dir_2_str(parms->dir),
1539 tf_get_if_tbl_entry(struct tf *tfp,
1540 struct tf_get_if_tbl_entry_parms *parms)
1543 struct tf_session *tfs;
1544 struct tf_dev_info *dev;
1545 struct tf_if_tbl_get_parms gparms = { 0 };
1547 TF_CHECK_PARMS2(tfp, parms);
1549 /* Retrieve the session information */
1550 rc = tf_session_get_session(tfp, &tfs);
1553 "%s: Failed to lookup session, rc:%s\n",
1554 tf_dir_2_str(parms->dir),
1559 /* Retrieve the device information */
1560 rc = tf_session_get_device(tfs, &dev);
1563 "%s: Failed to lookup device, rc:%s\n",
1564 tf_dir_2_str(parms->dir),
1569 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1572 "%s: Operation not supported, rc:%s\n",
1573 tf_dir_2_str(parms->dir),
1578 gparms.dir = parms->dir;
1579 gparms.type = parms->type;
1580 gparms.idx = parms->idx;
1581 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1582 gparms.data = parms->data;
1584 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1587 "%s: If_tbl get failed, rc:%s\n",
1588 tf_dir_2_str(parms->dir),