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 &&
38 parms->device_type != TF_DEVICE_TYPE_SR) {
40 "Unsupported device type %d\n",
45 /* Verify control channel and build the beginning of session_id */
46 rc = sscanf(parms->ctrl_chan_name,
53 /* PCI Domain not provided (optional in DPDK), thus we
54 * force domain to 0 and recheck.
58 /* Check parsing of bus/slot/device */
59 rc = sscanf(parms->ctrl_chan_name,
66 "Failed to scan device ctrl_chan_name\n");
71 parms->session_id.internal.domain = domain;
72 parms->session_id.internal.bus = bus;
73 parms->session_id.internal.device = device;
74 oparms.open_cfg = parms;
76 /* Session vs session client is decided in
77 * tf_session_open_session()
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_search_tbl_entry(struct tf *tfp,
958 struct tf_search_tbl_entry_parms *parms)
961 struct tf_session *tfs;
962 struct tf_dev_info *dev;
963 struct tf_tbl_alloc_search_parms sparms;
965 TF_CHECK_PARMS2(tfp, parms);
967 /* Retrieve the session information */
968 rc = tf_session_get_session(tfp, &tfs);
971 "%s: Failed to lookup session, rc:%s\n",
972 tf_dir_2_str(parms->dir),
977 /* Retrieve the device information */
978 rc = tf_session_get_device(tfs, &dev);
981 "%s: Failed to lookup device, rc:%s\n",
982 tf_dir_2_str(parms->dir),
987 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
990 "%s: Operation not supported, rc:%s\n",
991 tf_dir_2_str(parms->dir),
996 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
997 sparms.dir = parms->dir;
998 sparms.type = parms->type;
999 sparms.result = parms->result;
1000 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
1001 sparms.alloc = parms->alloc;
1002 sparms.tbl_scope_id = parms->tbl_scope_id;
1003 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
1006 "%s: TBL allocation failed, rc:%s\n",
1007 tf_dir_2_str(parms->dir),
1012 /* Return the outputs from the search */
1013 parms->hit = sparms.hit;
1014 parms->search_status = sparms.search_status;
1015 parms->ref_cnt = sparms.ref_cnt;
1016 parms->idx = sparms.idx;
1022 tf_free_tbl_entry(struct tf *tfp,
1023 struct tf_free_tbl_entry_parms *parms)
1026 struct tf_session *tfs;
1027 struct tf_dev_info *dev;
1028 struct tf_tbl_free_parms fparms;
1030 TF_CHECK_PARMS2(tfp, parms);
1032 /* Can't do static initialization due to UT enum check */
1033 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1035 /* Retrieve the session information */
1036 rc = tf_session_get_session(tfp, &tfs);
1039 "%s: Failed to lookup session, rc:%s\n",
1040 tf_dir_2_str(parms->dir),
1045 /* Retrieve the device information */
1046 rc = tf_session_get_device(tfs, &dev);
1049 "%s: Failed to lookup device, rc:%s\n",
1050 tf_dir_2_str(parms->dir),
1055 fparms.dir = parms->dir;
1056 fparms.type = parms->type;
1057 fparms.idx = parms->idx;
1058 fparms.tbl_scope_id = parms->tbl_scope_id;
1060 if (parms->type == TF_TBL_TYPE_EXT) {
1061 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1064 "%s: Operation not supported, rc:%s\n",
1065 tf_dir_2_str(parms->dir),
1070 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1073 "%s: Table free failed, rc:%s\n",
1074 tf_dir_2_str(parms->dir),
1079 if (dev->ops->tf_dev_free_tbl == NULL) {
1082 "%s: Operation not supported, rc:%s\n",
1083 tf_dir_2_str(parms->dir),
1088 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1091 "%s: Table free failed, rc:%s\n",
1092 tf_dir_2_str(parms->dir),
1102 tf_set_tbl_entry(struct tf *tfp,
1103 struct tf_set_tbl_entry_parms *parms)
1106 struct tf_session *tfs;
1107 struct tf_dev_info *dev;
1108 struct tf_tbl_set_parms sparms;
1110 TF_CHECK_PARMS3(tfp, parms, parms->data);
1112 /* Can't do static initialization due to UT enum check */
1113 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1115 /* Retrieve the session information */
1116 rc = tf_session_get_session(tfp, &tfs);
1119 "%s: Failed to lookup session, rc:%s\n",
1120 tf_dir_2_str(parms->dir),
1125 /* Retrieve the device information */
1126 rc = tf_session_get_device(tfs, &dev);
1129 "%s: Failed to lookup device, rc:%s\n",
1130 tf_dir_2_str(parms->dir),
1135 sparms.dir = parms->dir;
1136 sparms.type = parms->type;
1137 sparms.data = parms->data;
1138 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1139 sparms.idx = parms->idx;
1140 sparms.tbl_scope_id = parms->tbl_scope_id;
1142 if (parms->type == TF_TBL_TYPE_EXT) {
1143 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1146 "%s: Operation not supported, rc:%s\n",
1147 tf_dir_2_str(parms->dir),
1152 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1155 "%s: Table set failed, rc:%s\n",
1156 tf_dir_2_str(parms->dir),
1161 if (dev->ops->tf_dev_set_tbl == NULL) {
1164 "%s: Operation not supported, rc:%s\n",
1165 tf_dir_2_str(parms->dir),
1170 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1173 "%s: Table set failed, rc:%s\n",
1174 tf_dir_2_str(parms->dir),
1184 tf_get_tbl_entry(struct tf *tfp,
1185 struct tf_get_tbl_entry_parms *parms)
1188 struct tf_session *tfs;
1189 struct tf_dev_info *dev;
1190 struct tf_tbl_get_parms gparms;
1192 TF_CHECK_PARMS3(tfp, parms, parms->data);
1194 /* Can't do static initialization due to UT enum check */
1195 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1197 /* Retrieve the session information */
1198 rc = tf_session_get_session(tfp, &tfs);
1201 "%s: Failed to lookup session, rc:%s\n",
1202 tf_dir_2_str(parms->dir),
1207 /* Retrieve the device information */
1208 rc = tf_session_get_device(tfs, &dev);
1211 "%s: Failed to lookup device, rc:%s\n",
1212 tf_dir_2_str(parms->dir),
1217 if (dev->ops->tf_dev_get_tbl == NULL) {
1220 "%s: Operation not supported, rc:%s\n",
1221 tf_dir_2_str(parms->dir),
1226 gparms.dir = parms->dir;
1227 gparms.type = parms->type;
1228 gparms.data = parms->data;
1229 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1230 gparms.idx = parms->idx;
1231 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1234 "%s: Table get failed, rc:%s\n",
1235 tf_dir_2_str(parms->dir),
1244 tf_bulk_get_tbl_entry(struct tf *tfp,
1245 struct tf_bulk_get_tbl_entry_parms *parms)
1248 struct tf_session *tfs;
1249 struct tf_dev_info *dev;
1250 struct tf_tbl_get_bulk_parms bparms;
1252 TF_CHECK_PARMS2(tfp, parms);
1254 /* Can't do static initialization due to UT enum check */
1255 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1257 /* Retrieve the session information */
1258 rc = tf_session_get_session(tfp, &tfs);
1261 "%s: Failed to lookup session, rc:%s\n",
1262 tf_dir_2_str(parms->dir),
1267 /* Retrieve the device information */
1268 rc = tf_session_get_device(tfs, &dev);
1271 "%s: Failed to lookup device, rc:%s\n",
1272 tf_dir_2_str(parms->dir),
1277 if (parms->type == TF_TBL_TYPE_EXT) {
1278 /* Not supported, yet */
1281 "%s, External table type not supported, rc:%s\n",
1282 tf_dir_2_str(parms->dir),
1288 /* Internal table type processing */
1290 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1293 "%s: Operation not supported, rc:%s\n",
1294 tf_dir_2_str(parms->dir),
1299 bparms.dir = parms->dir;
1300 bparms.type = parms->type;
1301 bparms.starting_idx = parms->starting_idx;
1302 bparms.num_entries = parms->num_entries;
1303 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1304 bparms.physical_mem_addr = parms->physical_mem_addr;
1305 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1308 "%s: Table get bulk failed, rc:%s\n",
1309 tf_dir_2_str(parms->dir),
1318 tf_alloc_tbl_scope(struct tf *tfp,
1319 struct tf_alloc_tbl_scope_parms *parms)
1321 struct tf_session *tfs;
1322 struct tf_dev_info *dev;
1325 TF_CHECK_PARMS2(tfp, parms);
1327 /* Retrieve the session information */
1328 rc = tf_session_get_session(tfp, &tfs);
1331 "Failed to lookup session, rc:%s\n",
1336 /* Retrieve the device information */
1337 rc = tf_session_get_device(tfs, &dev);
1340 "Failed to lookup device, rc:%s\n",
1345 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1346 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1349 "Alloc table scope not supported by device\n");
1357 tf_free_tbl_scope(struct tf *tfp,
1358 struct tf_free_tbl_scope_parms *parms)
1360 struct tf_session *tfs;
1361 struct tf_dev_info *dev;
1364 TF_CHECK_PARMS2(tfp, parms);
1366 /* Retrieve the session information */
1367 rc = tf_session_get_session(tfp, &tfs);
1370 "Failed to lookup session, rc:%s\n",
1375 /* Retrieve the device information */
1376 rc = tf_session_get_device(tfs, &dev);
1379 "Failed to lookup device, rc:%s\n",
1384 if (dev->ops->tf_dev_free_tbl_scope) {
1385 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1388 "Free table scope not supported by device\n");
1396 tf_set_if_tbl_entry(struct tf *tfp,
1397 struct tf_set_if_tbl_entry_parms *parms)
1400 struct tf_session *tfs;
1401 struct tf_dev_info *dev;
1402 struct tf_if_tbl_set_parms sparms = { 0 };
1404 TF_CHECK_PARMS2(tfp, parms);
1406 /* Retrieve the session information */
1407 rc = tf_session_get_session(tfp, &tfs);
1410 "%s: Failed to lookup session, rc:%s\n",
1411 tf_dir_2_str(parms->dir),
1416 /* Retrieve the device information */
1417 rc = tf_session_get_device(tfs, &dev);
1420 "%s: Failed to lookup device, rc:%s\n",
1421 tf_dir_2_str(parms->dir),
1426 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1429 "%s: Operation not supported, rc:%s\n",
1430 tf_dir_2_str(parms->dir),
1435 sparms.dir = parms->dir;
1436 sparms.type = parms->type;
1437 sparms.idx = parms->idx;
1438 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1439 sparms.data = parms->data;
1441 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1444 "%s: If_tbl set failed, rc:%s\n",
1445 tf_dir_2_str(parms->dir),
1454 tf_get_if_tbl_entry(struct tf *tfp,
1455 struct tf_get_if_tbl_entry_parms *parms)
1458 struct tf_session *tfs;
1459 struct tf_dev_info *dev;
1460 struct tf_if_tbl_get_parms gparms = { 0 };
1462 TF_CHECK_PARMS2(tfp, parms);
1464 /* Retrieve the session information */
1465 rc = tf_session_get_session(tfp, &tfs);
1468 "%s: Failed to lookup session, rc:%s\n",
1469 tf_dir_2_str(parms->dir),
1474 /* Retrieve the device information */
1475 rc = tf_session_get_device(tfs, &dev);
1478 "%s: Failed to lookup device, rc:%s\n",
1479 tf_dir_2_str(parms->dir),
1484 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1487 "%s: Operation not supported, rc:%s\n",
1488 tf_dir_2_str(parms->dir),
1493 gparms.dir = parms->dir;
1494 gparms.type = parms->type;
1495 gparms.idx = parms->idx;
1496 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1497 gparms.data = parms->data;
1499 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1502 "%s: If_tbl get failed, rc:%s\n",
1503 tf_dir_2_str(parms->dir),