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"
21 #include "tf_ext_flow_handle.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;
33 TF_CHECK_PARMS2(tfp, parms);
35 /* Filter out any non-supported device types on the Core
36 * side. It is assumed that the Firmware will be supported if
37 * firmware open session succeeds.
39 if (parms->device_type != TF_DEVICE_TYPE_WH &&
40 parms->device_type != TF_DEVICE_TYPE_THOR &&
41 parms->device_type != TF_DEVICE_TYPE_SR) {
43 "Unsupported device type %d\n",
48 /* Verify control channel and build the beginning of session_id */
49 rc = sscanf(parms->ctrl_chan_name,
56 /* PCI Domain not provided (optional in DPDK), thus we
57 * force domain to 0 and recheck.
61 /* Check parsing of bus/slot/device */
62 rc = sscanf(parms->ctrl_chan_name,
69 "Failed to scan device ctrl_chan_name\n");
74 name_len = strlen(parms->ctrl_chan_name);
75 name = &parms->ctrl_chan_name[name_len - strlen("tf_shared")];
76 if (!strncmp(name, "tf_shared", strlen("tf_shared"))) {
77 memset(parms->ctrl_chan_name, 0, strlen(parms->ctrl_chan_name));
78 strcpy(parms->ctrl_chan_name, "tf_share");
81 parms->session_id.internal.domain = domain;
82 parms->session_id.internal.bus = bus;
83 parms->session_id.internal.device = device;
84 oparms.open_cfg = parms;
86 /* Session vs session client is decided in
87 * tf_session_open_session()
89 rc = tf_session_open_session(tfp, &oparms);
90 /* Logging handled by tf_session_open_session */
95 "domain:%d, bus:%d, device:%u\n",
96 parms->session_id.internal.domain,
97 parms->session_id.internal.bus,
98 parms->session_id.internal.device);
104 tf_attach_session(struct tf *tfp,
105 struct tf_attach_session_parms *parms)
108 unsigned int domain, bus, slot, device;
109 struct tf_session_attach_session_parms aparms;
111 TF_CHECK_PARMS2(tfp, parms);
113 /* Verify control channel */
114 rc = sscanf(parms->ctrl_chan_name,
122 "Failed to scan device ctrl_chan_name\n");
126 /* Verify 'attach' channel */
127 rc = sscanf(parms->attach_chan_name,
135 "Failed to scan device attach_chan_name\n");
139 /* Prepare return value of session_id, using ctrl_chan_name
140 * device values as it becomes the session id.
142 parms->session_id.internal.domain = domain;
143 parms->session_id.internal.bus = bus;
144 parms->session_id.internal.device = device;
145 aparms.attach_cfg = parms;
146 rc = tf_session_attach_session(tfp,
148 /* Logging handled by dev_bind */
153 "Attached to session, session_id:%d\n",
154 parms->session_id.id);
157 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
158 parms->session_id.internal.domain,
159 parms->session_id.internal.bus,
160 parms->session_id.internal.device,
161 parms->session_id.internal.fw_session_id);
167 tf_close_session(struct tf *tfp)
170 struct tf_session_close_session_parms cparms = { 0 };
171 union tf_session_id session_id = { 0 };
174 TF_CHECK_PARMS1(tfp);
176 cparms.ref_count = &ref_count;
177 cparms.session_id = &session_id;
178 /* Session vs session client is decided in
179 * tf_session_close_session()
181 rc = tf_session_close_session(tfp,
183 /* Logging handled by tf_session_close_session */
188 "domain:%d, bus:%d, device:%d\n",
189 cparms.session_id->internal.domain,
190 cparms.session_id->internal.bus,
191 cparms.session_id->internal.device);
196 /** insert EM hash entry API
202 int tf_insert_em_entry(struct tf *tfp,
203 struct tf_insert_em_entry_parms *parms)
205 struct tf_session *tfs;
206 struct tf_dev_info *dev;
209 TF_CHECK_PARMS2(tfp, parms);
211 /* Retrieve the session information */
212 rc = tf_session_get_session(tfp, &tfs);
215 "%s: Failed to lookup session, rc:%s\n",
216 tf_dir_2_str(parms->dir),
221 /* Retrieve the device information */
222 rc = tf_session_get_device(tfs, &dev);
225 "%s: Failed to lookup device, rc:%s\n",
226 tf_dir_2_str(parms->dir),
231 if (parms->mem == TF_MEM_EXTERNAL &&
232 dev->ops->tf_dev_insert_ext_em_entry != NULL)
233 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
234 else if (parms->mem == TF_MEM_INTERNAL &&
235 dev->ops->tf_dev_insert_int_em_entry != NULL)
236 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
242 "%s: EM insert failed, rc:%s\n",
243 tf_dir_2_str(parms->dir),
251 /** Delete EM hash entry API
257 int tf_delete_em_entry(struct tf *tfp,
258 struct tf_delete_em_entry_parms *parms)
260 struct tf_session *tfs;
261 struct tf_dev_info *dev;
263 unsigned int flag = 0;
265 TF_CHECK_PARMS2(tfp, parms);
267 /* Retrieve the session information */
268 rc = tf_session_get_session(tfp, &tfs);
271 "%s: Failed to lookup session, rc:%s\n",
272 tf_dir_2_str(parms->dir),
277 /* Retrieve the device information */
278 rc = tf_session_get_device(tfs, &dev);
281 "%s: Failed to lookup device, rc:%s\n",
282 tf_dir_2_str(parms->dir),
287 TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
288 if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
289 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
291 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
295 "%s: EM delete failed, rc:%s\n",
296 tf_dir_2_str(parms->dir),
304 /** Get global configuration API
310 int tf_get_global_cfg(struct tf *tfp,
311 struct tf_global_cfg_parms *parms)
314 struct tf_session *tfs;
315 struct tf_dev_info *dev;
317 TF_CHECK_PARMS2(tfp, parms);
319 /* Retrieve the session information */
320 rc = tf_session_get_session(tfp, &tfs);
323 "%s: Failed to lookup session, rc:%s\n",
324 tf_dir_2_str(parms->dir),
329 /* Retrieve the device information */
330 rc = tf_session_get_device(tfs, &dev);
333 "%s: Failed to lookup device, rc:%s\n",
334 tf_dir_2_str(parms->dir),
339 if (parms->config == NULL ||
340 parms->config_sz_in_bytes == 0) {
341 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
345 if (dev->ops->tf_dev_get_global_cfg == NULL) {
348 "%s: Operation not supported, rc:%s\n",
349 tf_dir_2_str(parms->dir),
354 rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
357 "%s: Global Cfg get failed, rc:%s\n",
358 tf_dir_2_str(parms->dir),
366 /** Set global configuration API
372 int tf_set_global_cfg(struct tf *tfp,
373 struct tf_global_cfg_parms *parms)
376 struct tf_session *tfs;
377 struct tf_dev_info *dev;
379 TF_CHECK_PARMS2(tfp, parms);
381 /* Retrieve the session information */
382 rc = tf_session_get_session(tfp, &tfs);
385 "%s: Failed to lookup session, rc:%s\n",
386 tf_dir_2_str(parms->dir),
391 /* Retrieve the device information */
392 rc = tf_session_get_device(tfs, &dev);
395 "%s: Failed to lookup device, rc:%s\n",
396 tf_dir_2_str(parms->dir),
401 if (parms->config == NULL ||
402 parms->config_sz_in_bytes == 0) {
403 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
407 if (dev->ops->tf_dev_set_global_cfg == NULL) {
410 "%s: Operation not supported, rc:%s\n",
411 tf_dir_2_str(parms->dir),
416 rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
419 "%s: Global Cfg set failed, rc:%s\n",
420 tf_dir_2_str(parms->dir),
429 tf_alloc_identifier(struct tf *tfp,
430 struct tf_alloc_identifier_parms *parms)
433 struct tf_session *tfs;
434 struct tf_dev_info *dev;
435 struct tf_ident_alloc_parms aparms;
438 TF_CHECK_PARMS2(tfp, parms);
440 /* Can't do static initialization due to UT enum check */
441 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
443 /* Retrieve the session information */
444 rc = tf_session_get_session(tfp, &tfs);
447 "%s: Failed to lookup session, rc:%s\n",
448 tf_dir_2_str(parms->dir),
453 /* Retrieve the device information */
454 rc = tf_session_get_device(tfs, &dev);
457 "%s: Failed to lookup device, rc:%s\n",
458 tf_dir_2_str(parms->dir),
463 if (dev->ops->tf_dev_alloc_ident == NULL) {
466 "%s: Operation not supported, rc:%s\n",
467 tf_dir_2_str(parms->dir),
472 aparms.dir = parms->dir;
473 aparms.type = parms->ident_type;
475 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
478 "%s: Identifier allocation failed, rc:%s\n",
479 tf_dir_2_str(parms->dir),
490 tf_free_identifier(struct tf *tfp,
491 struct tf_free_identifier_parms *parms)
494 struct tf_session *tfs;
495 struct tf_dev_info *dev;
496 struct tf_ident_free_parms fparms;
498 TF_CHECK_PARMS2(tfp, parms);
500 /* Can't do static initialization due to UT enum check */
501 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
503 /* Retrieve the session information */
504 rc = tf_session_get_session(tfp, &tfs);
507 "%s: Failed to lookup session, rc:%s\n",
508 tf_dir_2_str(parms->dir),
513 /* Retrieve the device information */
514 rc = tf_session_get_device(tfs, &dev);
517 "%s: Failed to lookup device, rc:%s\n",
518 tf_dir_2_str(parms->dir),
523 if (dev->ops->tf_dev_free_ident == NULL) {
526 "%s: Operation not supported, rc:%s\n",
527 tf_dir_2_str(parms->dir),
532 fparms.dir = parms->dir;
533 fparms.type = parms->ident_type;
534 fparms.id = parms->id;
535 fparms.ref_cnt = &parms->ref_cnt;
536 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
539 "%s: Identifier free failed, rc:%s\n",
540 tf_dir_2_str(parms->dir),
549 tf_search_identifier(struct tf *tfp,
550 struct tf_search_identifier_parms *parms)
553 struct tf_session *tfs;
554 struct tf_dev_info *dev;
555 struct tf_ident_search_parms sparms;
557 TF_CHECK_PARMS2(tfp, parms);
559 /* Can't do static initialization due to UT enum check */
560 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
562 /* Retrieve the session information */
563 rc = tf_session_get_session(tfp, &tfs);
566 "%s: Failed to lookup session, rc:%s\n",
567 tf_dir_2_str(parms->dir),
572 /* Retrieve the device information */
573 rc = tf_session_get_device(tfs, &dev);
576 "%s: Failed to lookup device, rc:%s\n",
577 tf_dir_2_str(parms->dir),
582 if (dev->ops->tf_dev_search_ident == NULL) {
585 "%s: Operation not supported, rc:%s\n",
586 tf_dir_2_str(parms->dir),
591 sparms.dir = parms->dir;
592 sparms.type = parms->ident_type;
593 sparms.search_id = parms->search_id;
594 sparms.hit = &parms->hit;
595 sparms.ref_cnt = &parms->ref_cnt;
596 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
599 "%s: Identifier search failed, rc:%s\n",
600 tf_dir_2_str(parms->dir),
609 tf_search_tcam_entry(struct tf *tfp,
610 struct tf_search_tcam_entry_parms *parms)
613 struct tf_session *tfs;
614 struct tf_dev_info *dev;
615 struct tf_tcam_alloc_search_parms sparms;
617 TF_CHECK_PARMS2(tfp, parms);
619 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
621 /* Retrieve the session information */
622 rc = tf_session_get_session(tfp, &tfs);
625 "%s: Failed to lookup session, rc:%s\n",
626 tf_dir_2_str(parms->dir),
631 /* Retrieve the device information */
632 rc = tf_session_get_device(tfs, &dev);
635 "%s: Failed to lookup device, rc:%s\n",
636 tf_dir_2_str(parms->dir),
641 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
644 "%s: Operation not supported, rc:%s\n",
645 tf_dir_2_str(parms->dir),
650 sparms.dir = parms->dir;
651 sparms.type = parms->tcam_tbl_type;
652 sparms.key = parms->key;
653 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
654 sparms.mask = parms->mask;
655 sparms.priority = parms->priority;
656 sparms.alloc = parms->alloc;
658 /* Result is an in/out and so no need to copy during outputs */
659 sparms.result = parms->result;
661 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
663 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
666 "%s: TCAM allocation failed, rc:%s\n",
667 tf_dir_2_str(parms->dir),
672 /* Copy the outputs */
673 parms->hit = sparms.hit;
674 parms->search_status = sparms.search_status;
675 parms->ref_cnt = sparms.ref_cnt;
676 parms->idx = sparms.idx;
682 tf_alloc_tcam_entry(struct tf *tfp,
683 struct tf_alloc_tcam_entry_parms *parms)
686 struct tf_session *tfs;
687 struct tf_dev_info *dev;
688 struct tf_tcam_alloc_parms aparms;
690 TF_CHECK_PARMS2(tfp, parms);
692 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
694 /* Retrieve the session information */
695 rc = tf_session_get_session(tfp, &tfs);
698 "%s: Failed to lookup session, rc:%s\n",
699 tf_dir_2_str(parms->dir),
704 /* Retrieve the device information */
705 rc = tf_session_get_device(tfs, &dev);
708 "%s: Failed to lookup device, rc:%s\n",
709 tf_dir_2_str(parms->dir),
714 if (dev->ops->tf_dev_alloc_tcam == NULL) {
717 "%s: Operation not supported, rc:%s\n",
718 tf_dir_2_str(parms->dir),
723 aparms.dir = parms->dir;
724 aparms.type = parms->tcam_tbl_type;
725 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
726 aparms.priority = parms->priority;
727 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
730 "%s: TCAM allocation failed, rc:%s\n",
731 tf_dir_2_str(parms->dir),
736 parms->idx = aparms.idx;
742 tf_set_tcam_entry(struct tf *tfp,
743 struct tf_set_tcam_entry_parms *parms)
746 struct tf_session *tfs;
747 struct tf_dev_info *dev;
748 struct tf_tcam_set_parms sparms;
750 TF_CHECK_PARMS2(tfp, parms);
752 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
755 /* Retrieve the session information */
756 rc = tf_session_get_session(tfp, &tfs);
759 "%s: Failed to lookup session, rc:%s\n",
760 tf_dir_2_str(parms->dir),
765 /* Retrieve the device information */
766 rc = tf_session_get_device(tfs, &dev);
769 "%s: Failed to lookup device, rc:%s\n",
770 tf_dir_2_str(parms->dir),
775 if (dev->ops->tf_dev_set_tcam == NULL ||
776 dev->ops->tf_dev_word_align == NULL) {
779 "%s: Operation not supported, rc:%s\n",
780 tf_dir_2_str(parms->dir),
785 sparms.dir = parms->dir;
786 sparms.type = parms->tcam_tbl_type;
787 sparms.idx = parms->idx;
788 sparms.key = parms->key;
789 sparms.mask = parms->mask;
790 sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
791 sparms.result = parms->result;
792 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
794 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
797 "%s: TCAM set failed, rc:%s\n",
798 tf_dir_2_str(parms->dir),
807 tf_get_tcam_entry(struct tf *tfp __rte_unused,
808 struct tf_get_tcam_entry_parms *parms)
811 struct tf_session *tfs;
812 struct tf_dev_info *dev;
813 struct tf_tcam_get_parms gparms;
815 TF_CHECK_PARMS2(tfp, parms);
817 memset(&gparms, 0, sizeof(struct tf_tcam_get_parms));
820 /* Retrieve the session information */
821 rc = tf_session_get_session(tfp, &tfs);
824 "%s: Failed to lookup session, rc:%s\n",
825 tf_dir_2_str(parms->dir),
830 /* Retrieve the device information */
831 rc = tf_session_get_device(tfs, &dev);
834 "%s: Failed to lookup device, rc:%s\n",
835 tf_dir_2_str(parms->dir),
840 if (dev->ops->tf_dev_get_tcam == NULL) {
843 "%s: Operation not supported, rc:%s\n",
844 tf_dir_2_str(parms->dir),
849 gparms.dir = parms->dir;
850 gparms.type = parms->tcam_tbl_type;
851 gparms.idx = parms->idx;
852 gparms.key = parms->key;
853 gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
854 gparms.mask = parms->mask;
855 gparms.result = parms->result;
856 gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
858 rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
861 "%s: TCAM get failed, rc:%s\n",
862 tf_dir_2_str(parms->dir),
866 parms->key_sz_in_bits = gparms.key_size * 8;
867 parms->result_sz_in_bits = gparms.result_size * 8;
873 tf_free_tcam_entry(struct tf *tfp,
874 struct tf_free_tcam_entry_parms *parms)
877 struct tf_session *tfs;
878 struct tf_dev_info *dev;
879 struct tf_tcam_free_parms fparms;
881 TF_CHECK_PARMS2(tfp, parms);
883 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
885 /* Retrieve the session information */
886 rc = tf_session_get_session(tfp, &tfs);
889 "%s: Failed to lookup session, rc:%s\n",
890 tf_dir_2_str(parms->dir),
895 /* Retrieve the device information */
896 rc = tf_session_get_device(tfs, &dev);
899 "%s: Failed to lookup device, rc:%s\n",
900 tf_dir_2_str(parms->dir),
905 if (dev->ops->tf_dev_free_tcam == NULL) {
908 "%s: Operation not supported, rc:%s\n",
909 tf_dir_2_str(parms->dir),
914 fparms.dir = parms->dir;
915 fparms.type = parms->tcam_tbl_type;
916 fparms.idx = parms->idx;
917 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
920 "%s: TCAM free failed, rc:%s\n",
921 tf_dir_2_str(parms->dir),
930 tf_alloc_tbl_entry(struct tf *tfp,
931 struct tf_alloc_tbl_entry_parms *parms)
934 struct tf_session *tfs;
935 struct tf_dev_info *dev;
936 struct tf_tbl_alloc_parms aparms;
939 TF_CHECK_PARMS2(tfp, parms);
941 /* Can't do static initialization due to UT enum check */
942 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
944 /* Retrieve the session information */
945 rc = tf_session_get_session(tfp, &tfs);
948 "%s: Failed to lookup session, rc:%s\n",
949 tf_dir_2_str(parms->dir),
954 /* Retrieve the device information */
955 rc = tf_session_get_device(tfs, &dev);
958 "%s: Failed to lookup device, rc:%s\n",
959 tf_dir_2_str(parms->dir),
964 aparms.dir = parms->dir;
965 aparms.type = parms->type;
967 aparms.tbl_scope_id = parms->tbl_scope_id;
969 if (parms->type == TF_TBL_TYPE_EXT) {
970 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
973 "%s: Operation not supported, rc:%s\n",
974 tf_dir_2_str(parms->dir),
979 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
982 "%s: External table allocation failed, rc:%s\n",
983 tf_dir_2_str(parms->dir),
989 if (dev->ops->tf_dev_alloc_tbl == NULL) {
992 "%s: Operation not supported, rc:%s\n",
993 tf_dir_2_str(parms->dir),
998 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
1001 "%s: Table allocation failed, rc:%s\n",
1002 tf_dir_2_str(parms->dir),
1014 tf_search_tbl_entry(struct tf *tfp,
1015 struct tf_search_tbl_entry_parms *parms)
1018 struct tf_session *tfs;
1019 struct tf_dev_info *dev;
1020 struct tf_tbl_alloc_search_parms sparms;
1022 TF_CHECK_PARMS2(tfp, parms);
1024 /* Retrieve the session information */
1025 rc = tf_session_get_session(tfp, &tfs);
1028 "%s: Failed to lookup session, rc:%s\n",
1029 tf_dir_2_str(parms->dir),
1034 /* Retrieve the device information */
1035 rc = tf_session_get_device(tfs, &dev);
1038 "%s: Failed to lookup device, rc:%s\n",
1039 tf_dir_2_str(parms->dir),
1044 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
1047 "%s: Operation not supported, rc:%s\n",
1048 tf_dir_2_str(parms->dir),
1053 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
1054 sparms.dir = parms->dir;
1055 sparms.type = parms->type;
1056 sparms.result = parms->result;
1057 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
1058 sparms.alloc = parms->alloc;
1059 sparms.tbl_scope_id = parms->tbl_scope_id;
1060 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
1063 "%s: TBL allocation failed, rc:%s\n",
1064 tf_dir_2_str(parms->dir),
1069 /* Return the outputs from the search */
1070 parms->hit = sparms.hit;
1071 parms->search_status = sparms.search_status;
1072 parms->ref_cnt = sparms.ref_cnt;
1073 parms->idx = sparms.idx;
1079 tf_free_tbl_entry(struct tf *tfp,
1080 struct tf_free_tbl_entry_parms *parms)
1083 struct tf_session *tfs;
1084 struct tf_dev_info *dev;
1085 struct tf_tbl_free_parms fparms;
1087 TF_CHECK_PARMS2(tfp, parms);
1089 /* Can't do static initialization due to UT enum check */
1090 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1092 /* Retrieve the session information */
1093 rc = tf_session_get_session(tfp, &tfs);
1096 "%s: Failed to lookup session, rc:%s\n",
1097 tf_dir_2_str(parms->dir),
1102 /* Retrieve the device information */
1103 rc = tf_session_get_device(tfs, &dev);
1106 "%s: Failed to lookup device, rc:%s\n",
1107 tf_dir_2_str(parms->dir),
1112 fparms.dir = parms->dir;
1113 fparms.type = parms->type;
1114 fparms.idx = parms->idx;
1115 fparms.tbl_scope_id = parms->tbl_scope_id;
1117 if (parms->type == TF_TBL_TYPE_EXT) {
1118 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1121 "%s: Operation not supported, rc:%s\n",
1122 tf_dir_2_str(parms->dir),
1127 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1130 "%s: Table free failed, rc:%s\n",
1131 tf_dir_2_str(parms->dir),
1136 if (dev->ops->tf_dev_free_tbl == NULL) {
1139 "%s: Operation not supported, rc:%s\n",
1140 tf_dir_2_str(parms->dir),
1145 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1148 "%s: Table free failed, rc:%s\n",
1149 tf_dir_2_str(parms->dir),
1159 tf_set_tbl_entry(struct tf *tfp,
1160 struct tf_set_tbl_entry_parms *parms)
1163 struct tf_session *tfs;
1164 struct tf_dev_info *dev;
1165 struct tf_tbl_set_parms sparms;
1167 TF_CHECK_PARMS3(tfp, parms, parms->data);
1169 /* Can't do static initialization due to UT enum check */
1170 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1172 /* Retrieve the session information */
1173 rc = tf_session_get_session(tfp, &tfs);
1176 "%s: Failed to lookup session, rc:%s\n",
1177 tf_dir_2_str(parms->dir),
1182 /* Retrieve the device information */
1183 rc = tf_session_get_device(tfs, &dev);
1186 "%s: Failed to lookup device, rc:%s\n",
1187 tf_dir_2_str(parms->dir),
1192 sparms.dir = parms->dir;
1193 sparms.type = parms->type;
1194 sparms.data = parms->data;
1195 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1196 sparms.idx = parms->idx;
1197 sparms.tbl_scope_id = parms->tbl_scope_id;
1199 if (parms->type == TF_TBL_TYPE_EXT) {
1200 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1203 "%s: Operation not supported, rc:%s\n",
1204 tf_dir_2_str(parms->dir),
1209 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1212 "%s: Table set failed, rc:%s\n",
1213 tf_dir_2_str(parms->dir),
1218 if (dev->ops->tf_dev_set_tbl == NULL) {
1221 "%s: Operation not supported, rc:%s\n",
1222 tf_dir_2_str(parms->dir),
1227 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1230 "%s: Table set failed, rc:%s\n",
1231 tf_dir_2_str(parms->dir),
1241 tf_get_tbl_entry(struct tf *tfp,
1242 struct tf_get_tbl_entry_parms *parms)
1245 struct tf_session *tfs;
1246 struct tf_dev_info *dev;
1247 struct tf_tbl_get_parms gparms;
1249 TF_CHECK_PARMS3(tfp, parms, parms->data);
1251 /* Can't do static initialization due to UT enum check */
1252 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1254 /* Retrieve the session information */
1255 rc = tf_session_get_session(tfp, &tfs);
1258 "%s: Failed to lookup session, rc:%s\n",
1259 tf_dir_2_str(parms->dir),
1264 /* Retrieve the device information */
1265 rc = tf_session_get_device(tfs, &dev);
1268 "%s: Failed to lookup device, rc:%s\n",
1269 tf_dir_2_str(parms->dir),
1274 if (dev->ops->tf_dev_get_tbl == NULL) {
1277 "%s: Operation not supported, rc:%s\n",
1278 tf_dir_2_str(parms->dir),
1283 gparms.dir = parms->dir;
1284 gparms.type = parms->type;
1285 gparms.data = parms->data;
1286 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1287 gparms.idx = parms->idx;
1288 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1291 "%s: Table get failed, rc:%s\n",
1292 tf_dir_2_str(parms->dir),
1301 tf_bulk_get_tbl_entry(struct tf *tfp,
1302 struct tf_bulk_get_tbl_entry_parms *parms)
1305 struct tf_session *tfs;
1306 struct tf_dev_info *dev;
1307 struct tf_tbl_get_bulk_parms bparms;
1309 TF_CHECK_PARMS2(tfp, parms);
1311 /* Can't do static initialization due to UT enum check */
1312 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1314 /* Retrieve the session information */
1315 rc = tf_session_get_session(tfp, &tfs);
1318 "%s: Failed to lookup session, rc:%s\n",
1319 tf_dir_2_str(parms->dir),
1324 /* Retrieve the device information */
1325 rc = tf_session_get_device(tfs, &dev);
1328 "%s: Failed to lookup device, rc:%s\n",
1329 tf_dir_2_str(parms->dir),
1334 if (parms->type == TF_TBL_TYPE_EXT) {
1335 /* Not supported, yet */
1338 "%s, External table type not supported, rc:%s\n",
1339 tf_dir_2_str(parms->dir),
1345 /* Internal table type processing */
1347 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1350 "%s: Operation not supported, rc:%s\n",
1351 tf_dir_2_str(parms->dir),
1356 bparms.dir = parms->dir;
1357 bparms.type = parms->type;
1358 bparms.starting_idx = parms->starting_idx;
1359 bparms.num_entries = parms->num_entries;
1360 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1361 bparms.physical_mem_addr = parms->physical_mem_addr;
1362 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1365 "%s: Table get bulk failed, rc:%s\n",
1366 tf_dir_2_str(parms->dir),
1375 tf_alloc_tbl_scope(struct tf *tfp,
1376 struct tf_alloc_tbl_scope_parms *parms)
1378 struct tf_session *tfs;
1379 struct tf_dev_info *dev;
1382 TF_CHECK_PARMS2(tfp, parms);
1384 /* Retrieve the session information */
1385 rc = tf_session_get_session(tfp, &tfs);
1388 "Failed to lookup session, rc:%s\n",
1393 /* Retrieve the device information */
1394 rc = tf_session_get_device(tfs, &dev);
1397 "Failed to lookup device, rc:%s\n",
1402 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1403 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1406 "Alloc table scope not supported by device\n");
1413 tf_map_tbl_scope(struct tf *tfp,
1414 struct tf_map_tbl_scope_parms *parms)
1416 struct tf_session *tfs;
1417 struct tf_dev_info *dev;
1420 TF_CHECK_PARMS2(tfp, parms);
1422 /* Retrieve the session information */
1423 rc = tf_session_get_session(tfp, &tfs);
1426 "Failed to lookup session, rc:%s\n",
1431 /* Retrieve the device information */
1432 rc = tf_session_get_device(tfs, &dev);
1435 "Failed to lookup device, rc:%s\n",
1440 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1441 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1444 "Map table scope not supported by device\n");
1452 tf_free_tbl_scope(struct tf *tfp,
1453 struct tf_free_tbl_scope_parms *parms)
1455 struct tf_session *tfs;
1456 struct tf_dev_info *dev;
1459 TF_CHECK_PARMS2(tfp, parms);
1461 /* Retrieve the session information */
1462 rc = tf_session_get_session(tfp, &tfs);
1465 "Failed to lookup session, rc:%s\n",
1470 /* Retrieve the device information */
1471 rc = tf_session_get_device(tfs, &dev);
1474 "Failed to lookup device, rc:%s\n",
1479 if (dev->ops->tf_dev_free_tbl_scope) {
1480 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1483 "Free table scope not supported by device\n");
1491 tf_set_if_tbl_entry(struct tf *tfp,
1492 struct tf_set_if_tbl_entry_parms *parms)
1495 struct tf_session *tfs;
1496 struct tf_dev_info *dev;
1497 struct tf_if_tbl_set_parms sparms = { 0 };
1499 TF_CHECK_PARMS2(tfp, parms);
1501 /* Retrieve the session information */
1502 rc = tf_session_get_session(tfp, &tfs);
1505 "%s: Failed to lookup session, rc:%s\n",
1506 tf_dir_2_str(parms->dir),
1511 /* Retrieve the device information */
1512 rc = tf_session_get_device(tfs, &dev);
1515 "%s: Failed to lookup device, rc:%s\n",
1516 tf_dir_2_str(parms->dir),
1521 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1524 "%s: Operation not supported, rc:%s\n",
1525 tf_dir_2_str(parms->dir),
1530 sparms.dir = parms->dir;
1531 sparms.type = parms->type;
1532 sparms.idx = parms->idx;
1533 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1534 sparms.data = parms->data;
1536 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1539 "%s: If_tbl set failed, rc:%s\n",
1540 tf_dir_2_str(parms->dir),
1549 tf_get_if_tbl_entry(struct tf *tfp,
1550 struct tf_get_if_tbl_entry_parms *parms)
1553 struct tf_session *tfs;
1554 struct tf_dev_info *dev;
1555 struct tf_if_tbl_get_parms gparms = { 0 };
1557 TF_CHECK_PARMS2(tfp, parms);
1559 /* Retrieve the session information */
1560 rc = tf_session_get_session(tfp, &tfs);
1563 "%s: Failed to lookup session, rc:%s\n",
1564 tf_dir_2_str(parms->dir),
1569 /* Retrieve the device information */
1570 rc = tf_session_get_device(tfs, &dev);
1573 "%s: Failed to lookup device, rc:%s\n",
1574 tf_dir_2_str(parms->dir),
1579 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1582 "%s: Operation not supported, rc:%s\n",
1583 tf_dir_2_str(parms->dir),
1588 gparms.dir = parms->dir;
1589 gparms.type = parms->type;
1590 gparms.idx = parms->idx;
1591 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1592 gparms.data = parms->data;
1594 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1597 "%s: If_tbl get failed, rc:%s\n",
1598 tf_dir_2_str(parms->dir),
1606 int tf_get_session_info(struct tf *tfp,
1607 struct tf_get_session_info_parms *parms)
1610 struct tf_session *tfs;
1611 struct tf_dev_info *dev;
1613 TF_CHECK_PARMS2(tfp, parms);
1615 /* Retrieve the session information */
1616 rc = tf_session_get_session(tfp, &tfs);
1619 "Failed to lookup session, rc:%s\n",
1624 /* Retrieve the device information */
1625 rc = tf_session_get_device(tfs, &dev);
1628 "Failed to lookup device, rc:%s\n",
1633 TF_CHECK_PARMS2(tfp, parms);
1635 if (dev->ops->tf_dev_get_ident_resc_info == NULL) {
1638 "Operation not supported, rc:%s\n",
1643 rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident);
1646 "Ident get resc info failed, rc:%s\n",
1651 if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
1654 "Operation not supported, rc:%s\n",
1659 rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl);
1662 "Tbl get resc info failed, rc:%s\n",
1667 if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
1670 "Operation not supported, rc:%s\n",
1675 rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam);
1678 "TCAM get resc info failed, rc:%s\n",
1683 if (dev->ops->tf_dev_get_em_resc_info == NULL) {
1686 "Operation not supported, rc:%s\n",
1691 rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em);
1694 "EM get resc info failed, rc:%s\n",