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"
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:%u\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;
307 TF_CHECK_PARMS2(tfp, parms);
309 /* Retrieve the session information */
310 rc = tf_session_get_session(tfp, &tfs);
313 "%s: Failed to lookup session, rc:%s\n",
314 tf_dir_2_str(parms->dir),
319 /* Retrieve the device information */
320 rc = tf_session_get_device(tfs, &dev);
323 "%s: Failed to lookup device, rc:%s\n",
324 tf_dir_2_str(parms->dir),
329 if (parms->config == NULL ||
330 parms->config_sz_in_bytes == 0) {
331 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
335 if (dev->ops->tf_dev_get_global_cfg == NULL) {
338 "%s: Operation not supported, rc:%s\n",
339 tf_dir_2_str(parms->dir),
344 rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
347 "%s: Global Cfg get failed, rc:%s\n",
348 tf_dir_2_str(parms->dir),
356 /** Set global configuration API
362 int tf_set_global_cfg(struct tf *tfp,
363 struct tf_global_cfg_parms *parms)
366 struct tf_session *tfs;
367 struct tf_dev_info *dev;
369 TF_CHECK_PARMS2(tfp, parms);
371 /* Retrieve the session information */
372 rc = tf_session_get_session(tfp, &tfs);
375 "%s: Failed to lookup session, rc:%s\n",
376 tf_dir_2_str(parms->dir),
381 /* Retrieve the device information */
382 rc = tf_session_get_device(tfs, &dev);
385 "%s: Failed to lookup device, rc:%s\n",
386 tf_dir_2_str(parms->dir),
391 if (parms->config == NULL ||
392 parms->config_sz_in_bytes == 0) {
393 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
397 if (dev->ops->tf_dev_set_global_cfg == NULL) {
400 "%s: Operation not supported, rc:%s\n",
401 tf_dir_2_str(parms->dir),
406 rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
409 "%s: Global Cfg set failed, rc:%s\n",
410 tf_dir_2_str(parms->dir),
419 tf_alloc_identifier(struct tf *tfp,
420 struct tf_alloc_identifier_parms *parms)
423 struct tf_session *tfs;
424 struct tf_dev_info *dev;
425 struct tf_ident_alloc_parms aparms;
428 TF_CHECK_PARMS2(tfp, parms);
430 /* Can't do static initialization due to UT enum check */
431 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
433 /* Retrieve the session information */
434 rc = tf_session_get_session(tfp, &tfs);
437 "%s: Failed to lookup session, rc:%s\n",
438 tf_dir_2_str(parms->dir),
443 /* Retrieve the device information */
444 rc = tf_session_get_device(tfs, &dev);
447 "%s: Failed to lookup device, rc:%s\n",
448 tf_dir_2_str(parms->dir),
453 if (dev->ops->tf_dev_alloc_ident == NULL) {
456 "%s: Operation not supported, rc:%s\n",
457 tf_dir_2_str(parms->dir),
462 aparms.dir = parms->dir;
463 aparms.type = parms->ident_type;
465 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
468 "%s: Identifier allocation failed, rc:%s\n",
469 tf_dir_2_str(parms->dir),
480 tf_free_identifier(struct tf *tfp,
481 struct tf_free_identifier_parms *parms)
484 struct tf_session *tfs;
485 struct tf_dev_info *dev;
486 struct tf_ident_free_parms fparms;
488 TF_CHECK_PARMS2(tfp, parms);
490 /* Can't do static initialization due to UT enum check */
491 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
493 /* Retrieve the session information */
494 rc = tf_session_get_session(tfp, &tfs);
497 "%s: Failed to lookup session, rc:%s\n",
498 tf_dir_2_str(parms->dir),
503 /* Retrieve the device information */
504 rc = tf_session_get_device(tfs, &dev);
507 "%s: Failed to lookup device, rc:%s\n",
508 tf_dir_2_str(parms->dir),
513 if (dev->ops->tf_dev_free_ident == NULL) {
516 "%s: Operation not supported, rc:%s\n",
517 tf_dir_2_str(parms->dir),
522 fparms.dir = parms->dir;
523 fparms.type = parms->ident_type;
524 fparms.id = parms->id;
525 fparms.ref_cnt = &parms->ref_cnt;
526 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
529 "%s: Identifier free failed, rc:%s\n",
530 tf_dir_2_str(parms->dir),
539 tf_search_identifier(struct tf *tfp,
540 struct tf_search_identifier_parms *parms)
543 struct tf_session *tfs;
544 struct tf_dev_info *dev;
545 struct tf_ident_search_parms sparms;
547 TF_CHECK_PARMS2(tfp, parms);
549 /* Can't do static initialization due to UT enum check */
550 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
552 /* Retrieve the session information */
553 rc = tf_session_get_session(tfp, &tfs);
556 "%s: Failed to lookup session, rc:%s\n",
557 tf_dir_2_str(parms->dir),
562 /* Retrieve the device information */
563 rc = tf_session_get_device(tfs, &dev);
566 "%s: Failed to lookup device, rc:%s\n",
567 tf_dir_2_str(parms->dir),
572 if (dev->ops->tf_dev_search_ident == NULL) {
575 "%s: Operation not supported, rc:%s\n",
576 tf_dir_2_str(parms->dir),
581 sparms.dir = parms->dir;
582 sparms.type = parms->ident_type;
583 sparms.search_id = parms->search_id;
584 sparms.hit = &parms->hit;
585 sparms.ref_cnt = &parms->ref_cnt;
586 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
589 "%s: Identifier search failed, rc:%s\n",
590 tf_dir_2_str(parms->dir),
599 tf_search_tcam_entry(struct tf *tfp,
600 struct tf_search_tcam_entry_parms *parms)
603 struct tf_session *tfs;
604 struct tf_dev_info *dev;
605 struct tf_tcam_alloc_search_parms sparms;
607 TF_CHECK_PARMS2(tfp, parms);
609 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
611 /* Retrieve the session information */
612 rc = tf_session_get_session(tfp, &tfs);
615 "%s: Failed to lookup session, rc:%s\n",
616 tf_dir_2_str(parms->dir),
621 /* Retrieve the device information */
622 rc = tf_session_get_device(tfs, &dev);
625 "%s: Failed to lookup device, rc:%s\n",
626 tf_dir_2_str(parms->dir),
631 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
634 "%s: Operation not supported, rc:%s\n",
635 tf_dir_2_str(parms->dir),
640 sparms.dir = parms->dir;
641 sparms.type = parms->tcam_tbl_type;
642 sparms.key = parms->key;
643 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
644 sparms.mask = parms->mask;
645 sparms.priority = parms->priority;
646 sparms.alloc = parms->alloc;
648 /* Result is an in/out and so no need to copy during outputs */
649 sparms.result = parms->result;
651 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
653 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
656 "%s: TCAM allocation failed, rc:%s\n",
657 tf_dir_2_str(parms->dir),
662 /* Copy the outputs */
663 parms->hit = sparms.hit;
664 parms->search_status = sparms.search_status;
665 parms->ref_cnt = sparms.ref_cnt;
666 parms->idx = sparms.idx;
672 tf_alloc_tcam_entry(struct tf *tfp,
673 struct tf_alloc_tcam_entry_parms *parms)
676 struct tf_session *tfs;
677 struct tf_dev_info *dev;
678 struct tf_tcam_alloc_parms aparms;
680 TF_CHECK_PARMS2(tfp, parms);
682 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
684 /* Retrieve the session information */
685 rc = tf_session_get_session(tfp, &tfs);
688 "%s: Failed to lookup session, rc:%s\n",
689 tf_dir_2_str(parms->dir),
694 /* Retrieve the device information */
695 rc = tf_session_get_device(tfs, &dev);
698 "%s: Failed to lookup device, rc:%s\n",
699 tf_dir_2_str(parms->dir),
704 if (dev->ops->tf_dev_alloc_tcam == NULL) {
707 "%s: Operation not supported, rc:%s\n",
708 tf_dir_2_str(parms->dir),
713 aparms.dir = parms->dir;
714 aparms.type = parms->tcam_tbl_type;
715 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
716 aparms.priority = parms->priority;
717 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
720 "%s: TCAM allocation failed, rc:%s\n",
721 tf_dir_2_str(parms->dir),
726 parms->idx = aparms.idx;
732 tf_set_tcam_entry(struct tf *tfp,
733 struct tf_set_tcam_entry_parms *parms)
736 struct tf_session *tfs;
737 struct tf_dev_info *dev;
738 struct tf_tcam_set_parms sparms;
740 TF_CHECK_PARMS2(tfp, parms);
742 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
745 /* Retrieve the session information */
746 rc = tf_session_get_session(tfp, &tfs);
749 "%s: Failed to lookup session, rc:%s\n",
750 tf_dir_2_str(parms->dir),
755 /* Retrieve the device information */
756 rc = tf_session_get_device(tfs, &dev);
759 "%s: Failed to lookup device, rc:%s\n",
760 tf_dir_2_str(parms->dir),
765 if (dev->ops->tf_dev_set_tcam == NULL) {
768 "%s: Operation not supported, rc:%s\n",
769 tf_dir_2_str(parms->dir),
774 sparms.dir = parms->dir;
775 sparms.type = parms->tcam_tbl_type;
776 sparms.idx = parms->idx;
777 sparms.key = parms->key;
778 sparms.mask = parms->mask;
779 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
780 sparms.result = parms->result;
781 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
783 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
786 "%s: TCAM set failed, rc:%s\n",
787 tf_dir_2_str(parms->dir),
796 tf_get_tcam_entry(struct tf *tfp __rte_unused,
797 struct tf_get_tcam_entry_parms *parms __rte_unused)
799 TF_CHECK_PARMS2(tfp, parms);
804 tf_free_tcam_entry(struct tf *tfp,
805 struct tf_free_tcam_entry_parms *parms)
808 struct tf_session *tfs;
809 struct tf_dev_info *dev;
810 struct tf_tcam_free_parms fparms;
812 TF_CHECK_PARMS2(tfp, parms);
814 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
816 /* Retrieve the session information */
817 rc = tf_session_get_session(tfp, &tfs);
820 "%s: Failed to lookup session, rc:%s\n",
821 tf_dir_2_str(parms->dir),
826 /* Retrieve the device information */
827 rc = tf_session_get_device(tfs, &dev);
830 "%s: Failed to lookup device, rc:%s\n",
831 tf_dir_2_str(parms->dir),
836 if (dev->ops->tf_dev_free_tcam == NULL) {
839 "%s: Operation not supported, rc:%s\n",
840 tf_dir_2_str(parms->dir),
845 fparms.dir = parms->dir;
846 fparms.type = parms->tcam_tbl_type;
847 fparms.idx = parms->idx;
848 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
851 "%s: TCAM free failed, rc:%s\n",
852 tf_dir_2_str(parms->dir),
861 tf_alloc_tbl_entry(struct tf *tfp,
862 struct tf_alloc_tbl_entry_parms *parms)
865 struct tf_session *tfs;
866 struct tf_dev_info *dev;
867 struct tf_tbl_alloc_parms aparms;
870 TF_CHECK_PARMS2(tfp, parms);
872 /* Can't do static initialization due to UT enum check */
873 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_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 aparms.dir = parms->dir;
896 aparms.type = parms->type;
898 aparms.tbl_scope_id = parms->tbl_scope_id;
900 if (parms->type == TF_TBL_TYPE_EXT) {
901 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
904 "%s: Operation not supported, rc:%s\n",
905 tf_dir_2_str(parms->dir),
910 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
913 "%s: External table allocation failed, rc:%s\n",
914 tf_dir_2_str(parms->dir),
920 if (dev->ops->tf_dev_alloc_tbl == NULL) {
923 "%s: Operation not supported, rc:%s\n",
924 tf_dir_2_str(parms->dir),
929 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
932 "%s: Table allocation failed, rc:%s\n",
933 tf_dir_2_str(parms->dir),
945 tf_search_tbl_entry(struct tf *tfp,
946 struct tf_search_tbl_entry_parms *parms)
949 struct tf_session *tfs;
950 struct tf_dev_info *dev;
951 struct tf_tbl_alloc_search_parms sparms;
953 TF_CHECK_PARMS2(tfp, parms);
955 /* Retrieve the session information */
956 rc = tf_session_get_session(tfp, &tfs);
959 "%s: Failed to lookup session, rc:%s\n",
960 tf_dir_2_str(parms->dir),
965 /* Retrieve the device information */
966 rc = tf_session_get_device(tfs, &dev);
969 "%s: Failed to lookup device, rc:%s\n",
970 tf_dir_2_str(parms->dir),
975 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
978 "%s: Operation not supported, rc:%s\n",
979 tf_dir_2_str(parms->dir),
984 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
985 sparms.dir = parms->dir;
986 sparms.type = parms->type;
987 sparms.result = parms->result;
988 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
989 sparms.alloc = parms->alloc;
990 sparms.tbl_scope_id = parms->tbl_scope_id;
991 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
994 "%s: TBL allocation failed, rc:%s\n",
995 tf_dir_2_str(parms->dir),
1000 /* Return the outputs from the search */
1001 parms->hit = sparms.hit;
1002 parms->search_status = sparms.search_status;
1003 parms->ref_cnt = sparms.ref_cnt;
1004 parms->idx = sparms.idx;
1010 tf_free_tbl_entry(struct tf *tfp,
1011 struct tf_free_tbl_entry_parms *parms)
1014 struct tf_session *tfs;
1015 struct tf_dev_info *dev;
1016 struct tf_tbl_free_parms fparms;
1018 TF_CHECK_PARMS2(tfp, parms);
1020 /* Can't do static initialization due to UT enum check */
1021 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1023 /* Retrieve the session information */
1024 rc = tf_session_get_session(tfp, &tfs);
1027 "%s: Failed to lookup session, rc:%s\n",
1028 tf_dir_2_str(parms->dir),
1033 /* Retrieve the device information */
1034 rc = tf_session_get_device(tfs, &dev);
1037 "%s: Failed to lookup device, rc:%s\n",
1038 tf_dir_2_str(parms->dir),
1043 fparms.dir = parms->dir;
1044 fparms.type = parms->type;
1045 fparms.idx = parms->idx;
1046 fparms.tbl_scope_id = parms->tbl_scope_id;
1048 if (parms->type == TF_TBL_TYPE_EXT) {
1049 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1052 "%s: Operation not supported, rc:%s\n",
1053 tf_dir_2_str(parms->dir),
1058 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1061 "%s: Table free failed, rc:%s\n",
1062 tf_dir_2_str(parms->dir),
1067 if (dev->ops->tf_dev_free_tbl == NULL) {
1070 "%s: Operation not supported, rc:%s\n",
1071 tf_dir_2_str(parms->dir),
1076 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1079 "%s: Table free failed, rc:%s\n",
1080 tf_dir_2_str(parms->dir),
1090 tf_set_tbl_entry(struct tf *tfp,
1091 struct tf_set_tbl_entry_parms *parms)
1094 struct tf_session *tfs;
1095 struct tf_dev_info *dev;
1096 struct tf_tbl_set_parms sparms;
1098 TF_CHECK_PARMS3(tfp, parms, parms->data);
1100 /* Can't do static initialization due to UT enum check */
1101 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1103 /* Retrieve the session information */
1104 rc = tf_session_get_session(tfp, &tfs);
1107 "%s: Failed to lookup session, rc:%s\n",
1108 tf_dir_2_str(parms->dir),
1113 /* Retrieve the device information */
1114 rc = tf_session_get_device(tfs, &dev);
1117 "%s: Failed to lookup device, rc:%s\n",
1118 tf_dir_2_str(parms->dir),
1123 sparms.dir = parms->dir;
1124 sparms.type = parms->type;
1125 sparms.data = parms->data;
1126 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1127 sparms.idx = parms->idx;
1128 sparms.tbl_scope_id = parms->tbl_scope_id;
1130 if (parms->type == TF_TBL_TYPE_EXT) {
1131 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1134 "%s: Operation not supported, rc:%s\n",
1135 tf_dir_2_str(parms->dir),
1140 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1143 "%s: Table set failed, rc:%s\n",
1144 tf_dir_2_str(parms->dir),
1149 if (dev->ops->tf_dev_set_tbl == NULL) {
1152 "%s: Operation not supported, rc:%s\n",
1153 tf_dir_2_str(parms->dir),
1158 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1161 "%s: Table set failed, rc:%s\n",
1162 tf_dir_2_str(parms->dir),
1172 tf_get_tbl_entry(struct tf *tfp,
1173 struct tf_get_tbl_entry_parms *parms)
1176 struct tf_session *tfs;
1177 struct tf_dev_info *dev;
1178 struct tf_tbl_get_parms gparms;
1180 TF_CHECK_PARMS3(tfp, parms, parms->data);
1182 /* Can't do static initialization due to UT enum check */
1183 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1185 /* Retrieve the session information */
1186 rc = tf_session_get_session(tfp, &tfs);
1189 "%s: Failed to lookup session, rc:%s\n",
1190 tf_dir_2_str(parms->dir),
1195 /* Retrieve the device information */
1196 rc = tf_session_get_device(tfs, &dev);
1199 "%s: Failed to lookup device, rc:%s\n",
1200 tf_dir_2_str(parms->dir),
1205 if (dev->ops->tf_dev_get_tbl == NULL) {
1208 "%s: Operation not supported, rc:%s\n",
1209 tf_dir_2_str(parms->dir),
1214 gparms.dir = parms->dir;
1215 gparms.type = parms->type;
1216 gparms.data = parms->data;
1217 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1218 gparms.idx = parms->idx;
1219 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1222 "%s: Table get failed, rc:%s\n",
1223 tf_dir_2_str(parms->dir),
1232 tf_bulk_get_tbl_entry(struct tf *tfp,
1233 struct tf_bulk_get_tbl_entry_parms *parms)
1236 struct tf_session *tfs;
1237 struct tf_dev_info *dev;
1238 struct tf_tbl_get_bulk_parms bparms;
1240 TF_CHECK_PARMS2(tfp, parms);
1242 /* Can't do static initialization due to UT enum check */
1243 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1245 /* Retrieve the session information */
1246 rc = tf_session_get_session(tfp, &tfs);
1249 "%s: Failed to lookup session, rc:%s\n",
1250 tf_dir_2_str(parms->dir),
1255 /* Retrieve the device information */
1256 rc = tf_session_get_device(tfs, &dev);
1259 "%s: Failed to lookup device, rc:%s\n",
1260 tf_dir_2_str(parms->dir),
1265 if (parms->type == TF_TBL_TYPE_EXT) {
1266 /* Not supported, yet */
1269 "%s, External table type not supported, rc:%s\n",
1270 tf_dir_2_str(parms->dir),
1276 /* Internal table type processing */
1278 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1281 "%s: Operation not supported, rc:%s\n",
1282 tf_dir_2_str(parms->dir),
1287 bparms.dir = parms->dir;
1288 bparms.type = parms->type;
1289 bparms.starting_idx = parms->starting_idx;
1290 bparms.num_entries = parms->num_entries;
1291 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1292 bparms.physical_mem_addr = parms->physical_mem_addr;
1293 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1296 "%s: Table get bulk failed, rc:%s\n",
1297 tf_dir_2_str(parms->dir),
1306 tf_alloc_tbl_scope(struct tf *tfp,
1307 struct tf_alloc_tbl_scope_parms *parms)
1309 struct tf_session *tfs;
1310 struct tf_dev_info *dev;
1313 TF_CHECK_PARMS2(tfp, parms);
1315 /* Retrieve the session information */
1316 rc = tf_session_get_session(tfp, &tfs);
1319 "Failed to lookup session, rc:%s\n",
1324 /* Retrieve the device information */
1325 rc = tf_session_get_device(tfs, &dev);
1328 "Failed to lookup device, rc:%s\n",
1333 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1334 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1337 "Alloc table scope not supported by device\n");
1344 tf_map_tbl_scope(struct tf *tfp,
1345 struct tf_map_tbl_scope_parms *parms)
1347 struct tf_session *tfs;
1348 struct tf_dev_info *dev;
1351 TF_CHECK_PARMS2(tfp, parms);
1353 /* Retrieve the session information */
1354 rc = tf_session_get_session(tfp, &tfs);
1357 "Failed to lookup session, rc:%s\n",
1362 /* Retrieve the device information */
1363 rc = tf_session_get_device(tfs, &dev);
1366 "Failed to lookup device, rc:%s\n",
1371 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1372 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1375 "Map table scope not supported by device\n");
1383 tf_free_tbl_scope(struct tf *tfp,
1384 struct tf_free_tbl_scope_parms *parms)
1386 struct tf_session *tfs;
1387 struct tf_dev_info *dev;
1390 TF_CHECK_PARMS2(tfp, parms);
1392 /* Retrieve the session information */
1393 rc = tf_session_get_session(tfp, &tfs);
1396 "Failed to lookup session, rc:%s\n",
1401 /* Retrieve the device information */
1402 rc = tf_session_get_device(tfs, &dev);
1405 "Failed to lookup device, rc:%s\n",
1410 if (dev->ops->tf_dev_free_tbl_scope) {
1411 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1414 "Free table scope not supported by device\n");
1422 tf_set_if_tbl_entry(struct tf *tfp,
1423 struct tf_set_if_tbl_entry_parms *parms)
1426 struct tf_session *tfs;
1427 struct tf_dev_info *dev;
1428 struct tf_if_tbl_set_parms sparms = { 0 };
1430 TF_CHECK_PARMS2(tfp, parms);
1432 /* Retrieve the session information */
1433 rc = tf_session_get_session(tfp, &tfs);
1436 "%s: Failed to lookup session, rc:%s\n",
1437 tf_dir_2_str(parms->dir),
1442 /* Retrieve the device information */
1443 rc = tf_session_get_device(tfs, &dev);
1446 "%s: Failed to lookup device, rc:%s\n",
1447 tf_dir_2_str(parms->dir),
1452 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1455 "%s: Operation not supported, rc:%s\n",
1456 tf_dir_2_str(parms->dir),
1461 sparms.dir = parms->dir;
1462 sparms.type = parms->type;
1463 sparms.idx = parms->idx;
1464 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1465 sparms.data = parms->data;
1467 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1470 "%s: If_tbl set failed, rc:%s\n",
1471 tf_dir_2_str(parms->dir),
1480 tf_get_if_tbl_entry(struct tf *tfp,
1481 struct tf_get_if_tbl_entry_parms *parms)
1484 struct tf_session *tfs;
1485 struct tf_dev_info *dev;
1486 struct tf_if_tbl_get_parms gparms = { 0 };
1488 TF_CHECK_PARMS2(tfp, parms);
1490 /* Retrieve the session information */
1491 rc = tf_session_get_session(tfp, &tfs);
1494 "%s: Failed to lookup session, rc:%s\n",
1495 tf_dir_2_str(parms->dir),
1500 /* Retrieve the device information */
1501 rc = tf_session_get_device(tfs, &dev);
1504 "%s: Failed to lookup device, rc:%s\n",
1505 tf_dir_2_str(parms->dir),
1510 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1513 "%s: Operation not supported, rc:%s\n",
1514 tf_dir_2_str(parms->dir),
1519 gparms.dir = parms->dir;
1520 gparms.type = parms->type;
1521 gparms.idx = parms->idx;
1522 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1523 gparms.data = parms->data;
1525 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1528 "%s: If_tbl get failed, rc:%s\n",
1529 tf_dir_2_str(parms->dir),