1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_session.h"
14 #include "tf_global_cfg.h"
20 #include "tf_common.h"
24 tf_open_session(struct tf *tfp,
25 struct tf_open_session_parms *parms)
28 unsigned int domain, bus, slot, device;
29 struct tf_session_open_session_parms oparms;
31 TF_CHECK_PARMS2(tfp, parms);
33 /* Filter out any non-supported device types on the Core
34 * side. It is assumed that the Firmware will be supported if
35 * firmware open session succeeds.
37 if (parms->device_type != TF_DEVICE_TYPE_WH) {
39 "Unsupported device type %d\n",
44 /* Verify control channel and build the beginning of session_id */
45 rc = sscanf(parms->ctrl_chan_name,
52 /* PCI Domain not provided (optional in DPDK), thus we
53 * force domain to 0 and recheck.
57 /* Check parsing of bus/slot/device */
58 rc = sscanf(parms->ctrl_chan_name,
65 "Failed to scan device ctrl_chan_name\n");
70 parms->session_id.internal.domain = domain;
71 parms->session_id.internal.bus = bus;
72 parms->session_id.internal.device = device;
73 oparms.open_cfg = parms;
75 /* Session vs session client is decided in
76 * tf_session_open_session()
78 printf("TF_OPEN, %s\n", parms->ctrl_chan_name);
79 rc = tf_session_open_session(tfp, &oparms);
80 /* Logging handled by tf_session_open_session */
85 "domain:%d, bus:%d, device:%d\n",
86 parms->session_id.internal.domain,
87 parms->session_id.internal.bus,
88 parms->session_id.internal.device);
94 tf_attach_session(struct tf *tfp,
95 struct tf_attach_session_parms *parms)
98 unsigned int domain, bus, slot, device;
99 struct tf_session_attach_session_parms aparms;
101 TF_CHECK_PARMS2(tfp, parms);
103 /* Verify control channel */
104 rc = sscanf(parms->ctrl_chan_name,
112 "Failed to scan device ctrl_chan_name\n");
116 /* Verify 'attach' channel */
117 rc = sscanf(parms->attach_chan_name,
125 "Failed to scan device attach_chan_name\n");
129 /* Prepare return value of session_id, using ctrl_chan_name
130 * device values as it becomes the session id.
132 parms->session_id.internal.domain = domain;
133 parms->session_id.internal.bus = bus;
134 parms->session_id.internal.device = device;
135 aparms.attach_cfg = parms;
136 rc = tf_session_attach_session(tfp,
138 /* Logging handled by dev_bind */
143 "Attached to session, session_id:%d\n",
144 parms->session_id.id);
147 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
148 parms->session_id.internal.domain,
149 parms->session_id.internal.bus,
150 parms->session_id.internal.device,
151 parms->session_id.internal.fw_session_id);
157 tf_close_session(struct tf *tfp)
160 struct tf_session_close_session_parms cparms = { 0 };
161 union tf_session_id session_id = { 0 };
164 TF_CHECK_PARMS1(tfp);
166 cparms.ref_count = &ref_count;
167 cparms.session_id = &session_id;
168 /* Session vs session client is decided in
169 * tf_session_close_session()
171 rc = tf_session_close_session(tfp,
173 /* Logging handled by tf_session_close_session */
178 "domain:%d, bus:%d, device:%d\n",
179 cparms.session_id->internal.domain,
180 cparms.session_id->internal.bus,
181 cparms.session_id->internal.device);
186 /** insert EM hash entry API
192 int tf_insert_em_entry(struct tf *tfp,
193 struct tf_insert_em_entry_parms *parms)
195 struct tf_session *tfs;
196 struct tf_dev_info *dev;
199 TF_CHECK_PARMS2(tfp, parms);
201 /* Retrieve the session information */
202 rc = tf_session_get_session(tfp, &tfs);
205 "%s: Failed to lookup session, rc:%s\n",
206 tf_dir_2_str(parms->dir),
211 /* Retrieve the device information */
212 rc = tf_session_get_device(tfs, &dev);
215 "%s: Failed to lookup device, rc:%s\n",
216 tf_dir_2_str(parms->dir),
221 if (parms->mem == TF_MEM_EXTERNAL &&
222 dev->ops->tf_dev_insert_ext_em_entry != NULL)
223 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
224 else if (parms->mem == TF_MEM_INTERNAL &&
225 dev->ops->tf_dev_insert_int_em_entry != NULL)
226 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
232 "%s: EM insert failed, rc:%s\n",
233 tf_dir_2_str(parms->dir),
241 /** Delete EM hash entry API
247 int tf_delete_em_entry(struct tf *tfp,
248 struct tf_delete_em_entry_parms *parms)
250 struct tf_session *tfs;
251 struct tf_dev_info *dev;
254 TF_CHECK_PARMS2(tfp, parms);
256 /* Retrieve the session information */
257 rc = tf_session_get_session(tfp, &tfs);
260 "%s: Failed to lookup session, rc:%s\n",
261 tf_dir_2_str(parms->dir),
266 /* Retrieve the device information */
267 rc = tf_session_get_device(tfs, &dev);
270 "%s: Failed to lookup device, rc:%s\n",
271 tf_dir_2_str(parms->dir),
276 if (parms->mem == TF_MEM_EXTERNAL)
277 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
278 else if (parms->mem == TF_MEM_INTERNAL)
279 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
285 "%s: EM delete failed, rc:%s\n",
286 tf_dir_2_str(parms->dir),
294 /** Get global configuration API
300 int tf_get_global_cfg(struct tf *tfp,
301 struct tf_global_cfg_parms *parms)
304 struct tf_session *tfs;
305 struct tf_dev_info *dev;
306 struct tf_dev_global_cfg_parms gparms = { 0 };
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 gparms.dir = parms->dir;
346 gparms.type = parms->type;
347 gparms.offset = parms->offset;
348 gparms.config = parms->config;
349 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
350 rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
353 "%s: Global Cfg get failed, rc:%s\n",
354 tf_dir_2_str(parms->dir),
362 /** Set global configuration API
368 int tf_set_global_cfg(struct tf *tfp,
369 struct tf_global_cfg_parms *parms)
372 struct tf_session *tfs;
373 struct tf_dev_info *dev;
374 struct tf_dev_global_cfg_parms gparms = { 0 };
376 TF_CHECK_PARMS2(tfp, parms);
378 /* Retrieve the session information */
379 rc = tf_session_get_session(tfp, &tfs);
382 "%s: Failed to lookup session, rc:%s\n",
383 tf_dir_2_str(parms->dir),
388 /* Retrieve the device information */
389 rc = tf_session_get_device(tfs, &dev);
392 "%s: Failed to lookup device, rc:%s\n",
393 tf_dir_2_str(parms->dir),
398 if (parms->config == NULL ||
399 parms->config_sz_in_bytes == 0) {
400 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
404 if (dev->ops->tf_dev_set_global_cfg == NULL) {
407 "%s: Operation not supported, rc:%s\n",
408 tf_dir_2_str(parms->dir),
413 gparms.dir = parms->dir;
414 gparms.type = parms->type;
415 gparms.offset = parms->offset;
416 gparms.config = parms->config;
417 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
418 rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
421 "%s: Global Cfg set failed, rc:%s\n",
422 tf_dir_2_str(parms->dir),
431 tf_alloc_identifier(struct tf *tfp,
432 struct tf_alloc_identifier_parms *parms)
435 struct tf_session *tfs;
436 struct tf_dev_info *dev;
437 struct tf_ident_alloc_parms aparms;
440 TF_CHECK_PARMS2(tfp, parms);
442 /* Can't do static initialization due to UT enum check */
443 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
445 /* Retrieve the session information */
446 rc = tf_session_get_session(tfp, &tfs);
449 "%s: Failed to lookup session, rc:%s\n",
450 tf_dir_2_str(parms->dir),
455 /* Retrieve the device information */
456 rc = tf_session_get_device(tfs, &dev);
459 "%s: Failed to lookup device, rc:%s\n",
460 tf_dir_2_str(parms->dir),
465 if (dev->ops->tf_dev_alloc_ident == NULL) {
468 "%s: Operation not supported, rc:%s\n",
469 tf_dir_2_str(parms->dir),
474 aparms.dir = parms->dir;
475 aparms.type = parms->ident_type;
477 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
480 "%s: Identifier allocation failed, rc:%s\n",
481 tf_dir_2_str(parms->dir),
492 tf_free_identifier(struct tf *tfp,
493 struct tf_free_identifier_parms *parms)
496 struct tf_session *tfs;
497 struct tf_dev_info *dev;
498 struct tf_ident_free_parms fparms;
500 TF_CHECK_PARMS2(tfp, parms);
502 /* Can't do static initialization due to UT enum check */
503 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
505 /* Retrieve the session information */
506 rc = tf_session_get_session(tfp, &tfs);
509 "%s: Failed to lookup session, rc:%s\n",
510 tf_dir_2_str(parms->dir),
515 /* Retrieve the device information */
516 rc = tf_session_get_device(tfs, &dev);
519 "%s: Failed to lookup device, rc:%s\n",
520 tf_dir_2_str(parms->dir),
525 if (dev->ops->tf_dev_free_ident == NULL) {
528 "%s: Operation not supported, rc:%s\n",
529 tf_dir_2_str(parms->dir),
534 fparms.dir = parms->dir;
535 fparms.type = parms->ident_type;
536 fparms.id = parms->id;
537 fparms.ref_cnt = &parms->ref_cnt;
538 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
541 "%s: Identifier free failed, rc:%s\n",
542 tf_dir_2_str(parms->dir),
551 tf_search_identifier(struct tf *tfp,
552 struct tf_search_identifier_parms *parms)
555 struct tf_session *tfs;
556 struct tf_dev_info *dev;
557 struct tf_ident_search_parms sparms;
559 TF_CHECK_PARMS2(tfp, parms);
561 /* Can't do static initialization due to UT enum check */
562 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
564 /* Retrieve the session information */
565 rc = tf_session_get_session(tfp, &tfs);
568 "%s: Failed to lookup session, rc:%s\n",
569 tf_dir_2_str(parms->dir),
574 /* Retrieve the device information */
575 rc = tf_session_get_device(tfs, &dev);
578 "%s: Failed to lookup device, rc:%s\n",
579 tf_dir_2_str(parms->dir),
584 if (dev->ops->tf_dev_search_ident == NULL) {
587 "%s: Operation not supported, rc:%s\n",
588 tf_dir_2_str(parms->dir),
593 sparms.dir = parms->dir;
594 sparms.type = parms->ident_type;
595 sparms.search_id = parms->search_id;
596 sparms.hit = &parms->hit;
597 sparms.ref_cnt = &parms->ref_cnt;
598 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
601 "%s: Identifier search failed, rc:%s\n",
602 tf_dir_2_str(parms->dir),
611 tf_search_tcam_entry(struct tf *tfp,
612 struct tf_search_tcam_entry_parms *parms)
615 struct tf_session *tfs;
616 struct tf_dev_info *dev;
617 struct tf_tcam_alloc_search_parms sparms;
619 TF_CHECK_PARMS2(tfp, parms);
621 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
623 /* Retrieve the session information */
624 rc = tf_session_get_session(tfp, &tfs);
627 "%s: Failed to lookup session, rc:%s\n",
628 tf_dir_2_str(parms->dir),
633 /* Retrieve the device information */
634 rc = tf_session_get_device(tfs, &dev);
637 "%s: Failed to lookup device, rc:%s\n",
638 tf_dir_2_str(parms->dir),
643 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
646 "%s: Operation not supported, rc:%s\n",
647 tf_dir_2_str(parms->dir),
652 sparms.dir = parms->dir;
653 sparms.type = parms->tcam_tbl_type;
654 sparms.key = parms->key;
655 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
656 sparms.mask = parms->mask;
657 sparms.priority = parms->priority;
658 sparms.alloc = parms->alloc;
660 /* Result is an in/out and so no need to copy during outputs */
661 sparms.result = parms->result;
663 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
665 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
668 "%s: TCAM allocation failed, rc:%s\n",
669 tf_dir_2_str(parms->dir),
674 /* Copy the outputs */
675 parms->hit = sparms.hit;
676 parms->search_status = sparms.search_status;
677 parms->ref_cnt = sparms.ref_cnt;
678 parms->idx = sparms.idx;
684 tf_alloc_tcam_entry(struct tf *tfp,
685 struct tf_alloc_tcam_entry_parms *parms)
688 struct tf_session *tfs;
689 struct tf_dev_info *dev;
690 struct tf_tcam_alloc_parms aparms;
692 TF_CHECK_PARMS2(tfp, parms);
694 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
696 /* Retrieve the session information */
697 rc = tf_session_get_session(tfp, &tfs);
700 "%s: Failed to lookup session, rc:%s\n",
701 tf_dir_2_str(parms->dir),
706 /* Retrieve the device information */
707 rc = tf_session_get_device(tfs, &dev);
710 "%s: Failed to lookup device, rc:%s\n",
711 tf_dir_2_str(parms->dir),
716 if (dev->ops->tf_dev_alloc_tcam == NULL) {
719 "%s: Operation not supported, rc:%s\n",
720 tf_dir_2_str(parms->dir),
725 aparms.dir = parms->dir;
726 aparms.type = parms->tcam_tbl_type;
727 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
728 aparms.priority = parms->priority;
729 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
732 "%s: TCAM allocation failed, rc:%s\n",
733 tf_dir_2_str(parms->dir),
738 parms->idx = aparms.idx;
744 tf_set_tcam_entry(struct tf *tfp,
745 struct tf_set_tcam_entry_parms *parms)
748 struct tf_session *tfs;
749 struct tf_dev_info *dev;
750 struct tf_tcam_set_parms sparms;
752 TF_CHECK_PARMS2(tfp, parms);
754 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
757 /* Retrieve the session information */
758 rc = tf_session_get_session(tfp, &tfs);
761 "%s: Failed to lookup session, rc:%s\n",
762 tf_dir_2_str(parms->dir),
767 /* Retrieve the device information */
768 rc = tf_session_get_device(tfs, &dev);
771 "%s: Failed to lookup device, rc:%s\n",
772 tf_dir_2_str(parms->dir),
777 if (dev->ops->tf_dev_set_tcam == NULL) {
780 "%s: Operation not supported, rc:%s\n",
781 tf_dir_2_str(parms->dir),
786 sparms.dir = parms->dir;
787 sparms.type = parms->tcam_tbl_type;
788 sparms.idx = parms->idx;
789 sparms.key = parms->key;
790 sparms.mask = parms->mask;
791 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
792 sparms.result = parms->result;
793 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
795 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
798 "%s: TCAM set failed, rc:%s\n",
799 tf_dir_2_str(parms->dir),
808 tf_get_tcam_entry(struct tf *tfp __rte_unused,
809 struct tf_get_tcam_entry_parms *parms __rte_unused)
811 TF_CHECK_PARMS2(tfp, parms);
816 tf_free_tcam_entry(struct tf *tfp,
817 struct tf_free_tcam_entry_parms *parms)
820 struct tf_session *tfs;
821 struct tf_dev_info *dev;
822 struct tf_tcam_free_parms fparms;
824 TF_CHECK_PARMS2(tfp, parms);
826 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
828 /* Retrieve the session information */
829 rc = tf_session_get_session(tfp, &tfs);
832 "%s: Failed to lookup session, rc:%s\n",
833 tf_dir_2_str(parms->dir),
838 /* Retrieve the device information */
839 rc = tf_session_get_device(tfs, &dev);
842 "%s: Failed to lookup device, rc:%s\n",
843 tf_dir_2_str(parms->dir),
848 if (dev->ops->tf_dev_free_tcam == NULL) {
851 "%s: Operation not supported, rc:%s\n",
852 tf_dir_2_str(parms->dir),
857 fparms.dir = parms->dir;
858 fparms.type = parms->tcam_tbl_type;
859 fparms.idx = parms->idx;
860 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
863 "%s: TCAM free failed, rc:%s\n",
864 tf_dir_2_str(parms->dir),
873 tf_alloc_tbl_entry(struct tf *tfp,
874 struct tf_alloc_tbl_entry_parms *parms)
877 struct tf_session *tfs;
878 struct tf_dev_info *dev;
879 struct tf_tbl_alloc_parms aparms;
882 TF_CHECK_PARMS2(tfp, parms);
884 /* Can't do static initialization due to UT enum check */
885 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
887 /* Retrieve the session information */
888 rc = tf_session_get_session(tfp, &tfs);
891 "%s: Failed to lookup session, rc:%s\n",
892 tf_dir_2_str(parms->dir),
897 /* Retrieve the device information */
898 rc = tf_session_get_device(tfs, &dev);
901 "%s: Failed to lookup device, rc:%s\n",
902 tf_dir_2_str(parms->dir),
907 aparms.dir = parms->dir;
908 aparms.type = parms->type;
910 aparms.tbl_scope_id = parms->tbl_scope_id;
912 if (parms->type == TF_TBL_TYPE_EXT) {
913 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
916 "%s: Operation not supported, rc:%s\n",
917 tf_dir_2_str(parms->dir),
922 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
925 "%s: External table allocation failed, rc:%s\n",
926 tf_dir_2_str(parms->dir),
932 if (dev->ops->tf_dev_alloc_tbl == NULL) {
935 "%s: Operation not supported, rc:%s\n",
936 tf_dir_2_str(parms->dir),
941 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
944 "%s: Table allocation failed, rc:%s\n",
945 tf_dir_2_str(parms->dir),
957 tf_free_tbl_entry(struct tf *tfp,
958 struct tf_free_tbl_entry_parms *parms)
961 struct tf_session *tfs;
962 struct tf_dev_info *dev;
963 struct tf_tbl_free_parms fparms;
965 TF_CHECK_PARMS2(tfp, parms);
967 /* Can't do static initialization due to UT enum check */
968 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
970 /* Retrieve the session information */
971 rc = tf_session_get_session(tfp, &tfs);
974 "%s: Failed to lookup session, rc:%s\n",
975 tf_dir_2_str(parms->dir),
980 /* Retrieve the device information */
981 rc = tf_session_get_device(tfs, &dev);
984 "%s: Failed to lookup device, rc:%s\n",
985 tf_dir_2_str(parms->dir),
990 fparms.dir = parms->dir;
991 fparms.type = parms->type;
992 fparms.idx = parms->idx;
993 fparms.tbl_scope_id = parms->tbl_scope_id;
995 if (parms->type == TF_TBL_TYPE_EXT) {
996 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
999 "%s: Operation not supported, rc:%s\n",
1000 tf_dir_2_str(parms->dir),
1005 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1008 "%s: Table free failed, rc:%s\n",
1009 tf_dir_2_str(parms->dir),
1014 if (dev->ops->tf_dev_free_tbl == NULL) {
1017 "%s: Operation not supported, rc:%s\n",
1018 tf_dir_2_str(parms->dir),
1023 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1026 "%s: Table free failed, rc:%s\n",
1027 tf_dir_2_str(parms->dir),
1037 tf_set_tbl_entry(struct tf *tfp,
1038 struct tf_set_tbl_entry_parms *parms)
1041 struct tf_session *tfs;
1042 struct tf_dev_info *dev;
1043 struct tf_tbl_set_parms sparms;
1045 TF_CHECK_PARMS3(tfp, parms, parms->data);
1047 /* Can't do static initialization due to UT enum check */
1048 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1050 /* Retrieve the session information */
1051 rc = tf_session_get_session(tfp, &tfs);
1054 "%s: Failed to lookup session, rc:%s\n",
1055 tf_dir_2_str(parms->dir),
1060 /* Retrieve the device information */
1061 rc = tf_session_get_device(tfs, &dev);
1064 "%s: Failed to lookup device, rc:%s\n",
1065 tf_dir_2_str(parms->dir),
1070 sparms.dir = parms->dir;
1071 sparms.type = parms->type;
1072 sparms.data = parms->data;
1073 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1074 sparms.idx = parms->idx;
1075 sparms.tbl_scope_id = parms->tbl_scope_id;
1077 if (parms->type == TF_TBL_TYPE_EXT) {
1078 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1081 "%s: Operation not supported, rc:%s\n",
1082 tf_dir_2_str(parms->dir),
1087 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1090 "%s: Table set failed, rc:%s\n",
1091 tf_dir_2_str(parms->dir),
1096 if (dev->ops->tf_dev_set_tbl == NULL) {
1099 "%s: Operation not supported, rc:%s\n",
1100 tf_dir_2_str(parms->dir),
1105 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1108 "%s: Table set failed, rc:%s\n",
1109 tf_dir_2_str(parms->dir),
1119 tf_get_tbl_entry(struct tf *tfp,
1120 struct tf_get_tbl_entry_parms *parms)
1123 struct tf_session *tfs;
1124 struct tf_dev_info *dev;
1125 struct tf_tbl_get_parms gparms;
1127 TF_CHECK_PARMS3(tfp, parms, parms->data);
1129 /* Can't do static initialization due to UT enum check */
1130 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1132 /* Retrieve the session information */
1133 rc = tf_session_get_session(tfp, &tfs);
1136 "%s: Failed to lookup session, rc:%s\n",
1137 tf_dir_2_str(parms->dir),
1142 /* Retrieve the device information */
1143 rc = tf_session_get_device(tfs, &dev);
1146 "%s: Failed to lookup device, rc:%s\n",
1147 tf_dir_2_str(parms->dir),
1152 if (dev->ops->tf_dev_get_tbl == NULL) {
1155 "%s: Operation not supported, rc:%s\n",
1156 tf_dir_2_str(parms->dir),
1161 gparms.dir = parms->dir;
1162 gparms.type = parms->type;
1163 gparms.data = parms->data;
1164 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1165 gparms.idx = parms->idx;
1166 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1169 "%s: Table get failed, rc:%s\n",
1170 tf_dir_2_str(parms->dir),
1179 tf_bulk_get_tbl_entry(struct tf *tfp,
1180 struct tf_bulk_get_tbl_entry_parms *parms)
1183 struct tf_session *tfs;
1184 struct tf_dev_info *dev;
1185 struct tf_tbl_get_bulk_parms bparms;
1187 TF_CHECK_PARMS2(tfp, parms);
1189 /* Can't do static initialization due to UT enum check */
1190 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1192 /* Retrieve the session information */
1193 rc = tf_session_get_session(tfp, &tfs);
1196 "%s: Failed to lookup session, rc:%s\n",
1197 tf_dir_2_str(parms->dir),
1202 /* Retrieve the device information */
1203 rc = tf_session_get_device(tfs, &dev);
1206 "%s: Failed to lookup device, rc:%s\n",
1207 tf_dir_2_str(parms->dir),
1212 if (parms->type == TF_TBL_TYPE_EXT) {
1213 /* Not supported, yet */
1216 "%s, External table type not supported, rc:%s\n",
1217 tf_dir_2_str(parms->dir),
1223 /* Internal table type processing */
1225 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1228 "%s: Operation not supported, rc:%s\n",
1229 tf_dir_2_str(parms->dir),
1234 bparms.dir = parms->dir;
1235 bparms.type = parms->type;
1236 bparms.starting_idx = parms->starting_idx;
1237 bparms.num_entries = parms->num_entries;
1238 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1239 bparms.physical_mem_addr = parms->physical_mem_addr;
1240 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1243 "%s: Table get bulk failed, rc:%s\n",
1244 tf_dir_2_str(parms->dir),
1253 tf_alloc_tbl_scope(struct tf *tfp,
1254 struct tf_alloc_tbl_scope_parms *parms)
1256 struct tf_session *tfs;
1257 struct tf_dev_info *dev;
1260 TF_CHECK_PARMS2(tfp, parms);
1262 /* Retrieve the session information */
1263 rc = tf_session_get_session(tfp, &tfs);
1266 "Failed to lookup session, rc:%s\n",
1271 /* Retrieve the device information */
1272 rc = tf_session_get_device(tfs, &dev);
1275 "Failed to lookup device, rc:%s\n",
1280 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1281 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1284 "Alloc table scope not supported by device\n");
1292 tf_free_tbl_scope(struct tf *tfp,
1293 struct tf_free_tbl_scope_parms *parms)
1295 struct tf_session *tfs;
1296 struct tf_dev_info *dev;
1299 TF_CHECK_PARMS2(tfp, parms);
1301 /* Retrieve the session information */
1302 rc = tf_session_get_session(tfp, &tfs);
1305 "Failed to lookup session, rc:%s\n",
1310 /* Retrieve the device information */
1311 rc = tf_session_get_device(tfs, &dev);
1314 "Failed to lookup device, rc:%s\n",
1319 if (dev->ops->tf_dev_free_tbl_scope) {
1320 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1323 "Free table scope not supported by device\n");
1331 tf_set_if_tbl_entry(struct tf *tfp,
1332 struct tf_set_if_tbl_entry_parms *parms)
1335 struct tf_session *tfs;
1336 struct tf_dev_info *dev;
1337 struct tf_if_tbl_set_parms sparms = { 0 };
1339 TF_CHECK_PARMS2(tfp, parms);
1341 /* Retrieve the session information */
1342 rc = tf_session_get_session(tfp, &tfs);
1345 "%s: Failed to lookup session, rc:%s\n",
1346 tf_dir_2_str(parms->dir),
1351 /* Retrieve the device information */
1352 rc = tf_session_get_device(tfs, &dev);
1355 "%s: Failed to lookup device, rc:%s\n",
1356 tf_dir_2_str(parms->dir),
1361 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1364 "%s: Operation not supported, rc:%s\n",
1365 tf_dir_2_str(parms->dir),
1370 sparms.dir = parms->dir;
1371 sparms.type = parms->type;
1372 sparms.idx = parms->idx;
1373 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1374 sparms.data = parms->data;
1376 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1379 "%s: If_tbl set failed, rc:%s\n",
1380 tf_dir_2_str(parms->dir),
1389 tf_get_if_tbl_entry(struct tf *tfp,
1390 struct tf_get_if_tbl_entry_parms *parms)
1393 struct tf_session *tfs;
1394 struct tf_dev_info *dev;
1395 struct tf_if_tbl_get_parms gparms = { 0 };
1397 TF_CHECK_PARMS2(tfp, parms);
1399 /* Retrieve the session information */
1400 rc = tf_session_get_session(tfp, &tfs);
1403 "%s: Failed to lookup session, rc:%s\n",
1404 tf_dir_2_str(parms->dir),
1409 /* Retrieve the device information */
1410 rc = tf_session_get_device(tfs, &dev);
1413 "%s: Failed to lookup device, rc:%s\n",
1414 tf_dir_2_str(parms->dir),
1419 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1422 "%s: Operation not supported, rc:%s\n",
1423 tf_dir_2_str(parms->dir),
1428 gparms.dir = parms->dir;
1429 gparms.type = parms->type;
1430 gparms.idx = parms->idx;
1431 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1432 gparms.data = parms->data;
1434 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1437 "%s: If_tbl get failed, rc:%s\n",
1438 tf_dir_2_str(parms->dir),