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;
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_THOR &&
39 parms->device_type != TF_DEVICE_TYPE_SR) {
41 "Unsupported device type %d\n",
46 /* Verify control channel and build the beginning of session_id */
47 rc = sscanf(parms->ctrl_chan_name,
54 /* PCI Domain not provided (optional in DPDK), thus we
55 * force domain to 0 and recheck.
59 /* Check parsing of bus/slot/device */
60 rc = sscanf(parms->ctrl_chan_name,
67 "Failed to scan device ctrl_chan_name\n");
72 parms->session_id.internal.domain = domain;
73 parms->session_id.internal.bus = bus;
74 parms->session_id.internal.device = device;
75 oparms.open_cfg = parms;
77 /* Session vs session client is decided in
78 * tf_session_open_session()
80 rc = tf_session_open_session(tfp, &oparms);
81 /* Logging handled by tf_session_open_session */
86 "domain:%d, bus:%d, device:%u\n",
87 parms->session_id.internal.domain,
88 parms->session_id.internal.bus,
89 parms->session_id.internal.device);
95 tf_attach_session(struct tf *tfp,
96 struct tf_attach_session_parms *parms)
99 unsigned int domain, bus, slot, device;
100 struct tf_session_attach_session_parms aparms;
102 TF_CHECK_PARMS2(tfp, parms);
104 /* Verify control channel */
105 rc = sscanf(parms->ctrl_chan_name,
113 "Failed to scan device ctrl_chan_name\n");
117 /* Verify 'attach' channel */
118 rc = sscanf(parms->attach_chan_name,
126 "Failed to scan device attach_chan_name\n");
130 /* Prepare return value of session_id, using ctrl_chan_name
131 * device values as it becomes the session id.
133 parms->session_id.internal.domain = domain;
134 parms->session_id.internal.bus = bus;
135 parms->session_id.internal.device = device;
136 aparms.attach_cfg = parms;
137 rc = tf_session_attach_session(tfp,
139 /* Logging handled by dev_bind */
144 "Attached to session, session_id:%d\n",
145 parms->session_id.id);
148 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
149 parms->session_id.internal.domain,
150 parms->session_id.internal.bus,
151 parms->session_id.internal.device,
152 parms->session_id.internal.fw_session_id);
158 tf_close_session(struct tf *tfp)
161 struct tf_session_close_session_parms cparms = { 0 };
162 union tf_session_id session_id = { 0 };
165 TF_CHECK_PARMS1(tfp);
167 cparms.ref_count = &ref_count;
168 cparms.session_id = &session_id;
169 /* Session vs session client is decided in
170 * tf_session_close_session()
172 rc = tf_session_close_session(tfp,
174 /* Logging handled by tf_session_close_session */
179 "domain:%d, bus:%d, device:%d\n",
180 cparms.session_id->internal.domain,
181 cparms.session_id->internal.bus,
182 cparms.session_id->internal.device);
187 /** insert EM hash entry API
193 int tf_insert_em_entry(struct tf *tfp,
194 struct tf_insert_em_entry_parms *parms)
196 struct tf_session *tfs;
197 struct tf_dev_info *dev;
200 TF_CHECK_PARMS2(tfp, parms);
202 /* Retrieve the session information */
203 rc = tf_session_get_session(tfp, &tfs);
206 "%s: Failed to lookup session, rc:%s\n",
207 tf_dir_2_str(parms->dir),
212 /* Retrieve the device information */
213 rc = tf_session_get_device(tfs, &dev);
216 "%s: Failed to lookup device, rc:%s\n",
217 tf_dir_2_str(parms->dir),
222 if (parms->mem == TF_MEM_EXTERNAL &&
223 dev->ops->tf_dev_insert_ext_em_entry != NULL)
224 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
225 else if (parms->mem == TF_MEM_INTERNAL &&
226 dev->ops->tf_dev_insert_int_em_entry != NULL)
227 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
233 "%s: EM insert failed, rc:%s\n",
234 tf_dir_2_str(parms->dir),
242 /** Delete EM hash entry API
248 int tf_delete_em_entry(struct tf *tfp,
249 struct tf_delete_em_entry_parms *parms)
251 struct tf_session *tfs;
252 struct tf_dev_info *dev;
254 unsigned int flag = 0;
256 TF_CHECK_PARMS2(tfp, parms);
258 /* Retrieve the session information */
259 rc = tf_session_get_session(tfp, &tfs);
262 "%s: Failed to lookup session, rc:%s\n",
263 tf_dir_2_str(parms->dir),
268 /* Retrieve the device information */
269 rc = tf_session_get_device(tfs, &dev);
272 "%s: Failed to lookup device, rc:%s\n",
273 tf_dir_2_str(parms->dir),
278 TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
279 if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
280 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
282 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
286 "%s: EM delete failed, rc:%s\n",
287 tf_dir_2_str(parms->dir),
295 /** Get global configuration API
301 int tf_get_global_cfg(struct tf *tfp,
302 struct tf_global_cfg_parms *parms)
305 struct tf_session *tfs;
306 struct tf_dev_info *dev;
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 rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
348 "%s: Global Cfg get failed, rc:%s\n",
349 tf_dir_2_str(parms->dir),
357 /** Set global configuration API
363 int tf_set_global_cfg(struct tf *tfp,
364 struct tf_global_cfg_parms *parms)
367 struct tf_session *tfs;
368 struct tf_dev_info *dev;
370 TF_CHECK_PARMS2(tfp, parms);
372 /* Retrieve the session information */
373 rc = tf_session_get_session(tfp, &tfs);
376 "%s: Failed to lookup session, rc:%s\n",
377 tf_dir_2_str(parms->dir),
382 /* Retrieve the device information */
383 rc = tf_session_get_device(tfs, &dev);
386 "%s: Failed to lookup device, rc:%s\n",
387 tf_dir_2_str(parms->dir),
392 if (parms->config == NULL ||
393 parms->config_sz_in_bytes == 0) {
394 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
398 if (dev->ops->tf_dev_set_global_cfg == NULL) {
401 "%s: Operation not supported, rc:%s\n",
402 tf_dir_2_str(parms->dir),
407 rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
410 "%s: Global Cfg set failed, rc:%s\n",
411 tf_dir_2_str(parms->dir),
420 tf_alloc_identifier(struct tf *tfp,
421 struct tf_alloc_identifier_parms *parms)
424 struct tf_session *tfs;
425 struct tf_dev_info *dev;
426 struct tf_ident_alloc_parms aparms;
429 TF_CHECK_PARMS2(tfp, parms);
431 /* Can't do static initialization due to UT enum check */
432 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
434 /* Retrieve the session information */
435 rc = tf_session_get_session(tfp, &tfs);
438 "%s: Failed to lookup session, rc:%s\n",
439 tf_dir_2_str(parms->dir),
444 /* Retrieve the device information */
445 rc = tf_session_get_device(tfs, &dev);
448 "%s: Failed to lookup device, rc:%s\n",
449 tf_dir_2_str(parms->dir),
454 if (dev->ops->tf_dev_alloc_ident == NULL) {
457 "%s: Operation not supported, rc:%s\n",
458 tf_dir_2_str(parms->dir),
463 aparms.dir = parms->dir;
464 aparms.type = parms->ident_type;
466 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
469 "%s: Identifier allocation failed, rc:%s\n",
470 tf_dir_2_str(parms->dir),
481 tf_free_identifier(struct tf *tfp,
482 struct tf_free_identifier_parms *parms)
485 struct tf_session *tfs;
486 struct tf_dev_info *dev;
487 struct tf_ident_free_parms fparms;
489 TF_CHECK_PARMS2(tfp, parms);
491 /* Can't do static initialization due to UT enum check */
492 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
494 /* Retrieve the session information */
495 rc = tf_session_get_session(tfp, &tfs);
498 "%s: Failed to lookup session, rc:%s\n",
499 tf_dir_2_str(parms->dir),
504 /* Retrieve the device information */
505 rc = tf_session_get_device(tfs, &dev);
508 "%s: Failed to lookup device, rc:%s\n",
509 tf_dir_2_str(parms->dir),
514 if (dev->ops->tf_dev_free_ident == NULL) {
517 "%s: Operation not supported, rc:%s\n",
518 tf_dir_2_str(parms->dir),
523 fparms.dir = parms->dir;
524 fparms.type = parms->ident_type;
525 fparms.id = parms->id;
526 fparms.ref_cnt = &parms->ref_cnt;
527 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
530 "%s: Identifier free failed, rc:%s\n",
531 tf_dir_2_str(parms->dir),
540 tf_search_identifier(struct tf *tfp,
541 struct tf_search_identifier_parms *parms)
544 struct tf_session *tfs;
545 struct tf_dev_info *dev;
546 struct tf_ident_search_parms sparms;
548 TF_CHECK_PARMS2(tfp, parms);
550 /* Can't do static initialization due to UT enum check */
551 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
553 /* Retrieve the session information */
554 rc = tf_session_get_session(tfp, &tfs);
557 "%s: Failed to lookup session, rc:%s\n",
558 tf_dir_2_str(parms->dir),
563 /* Retrieve the device information */
564 rc = tf_session_get_device(tfs, &dev);
567 "%s: Failed to lookup device, rc:%s\n",
568 tf_dir_2_str(parms->dir),
573 if (dev->ops->tf_dev_search_ident == NULL) {
576 "%s: Operation not supported, rc:%s\n",
577 tf_dir_2_str(parms->dir),
582 sparms.dir = parms->dir;
583 sparms.type = parms->ident_type;
584 sparms.search_id = parms->search_id;
585 sparms.hit = &parms->hit;
586 sparms.ref_cnt = &parms->ref_cnt;
587 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
590 "%s: Identifier search failed, rc:%s\n",
591 tf_dir_2_str(parms->dir),
600 tf_search_tcam_entry(struct tf *tfp,
601 struct tf_search_tcam_entry_parms *parms)
604 struct tf_session *tfs;
605 struct tf_dev_info *dev;
606 struct tf_tcam_alloc_search_parms sparms;
608 TF_CHECK_PARMS2(tfp, parms);
610 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
612 /* Retrieve the session information */
613 rc = tf_session_get_session(tfp, &tfs);
616 "%s: Failed to lookup session, rc:%s\n",
617 tf_dir_2_str(parms->dir),
622 /* Retrieve the device information */
623 rc = tf_session_get_device(tfs, &dev);
626 "%s: Failed to lookup device, rc:%s\n",
627 tf_dir_2_str(parms->dir),
632 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
635 "%s: Operation not supported, rc:%s\n",
636 tf_dir_2_str(parms->dir),
641 sparms.dir = parms->dir;
642 sparms.type = parms->tcam_tbl_type;
643 sparms.key = parms->key;
644 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
645 sparms.mask = parms->mask;
646 sparms.priority = parms->priority;
647 sparms.alloc = parms->alloc;
649 /* Result is an in/out and so no need to copy during outputs */
650 sparms.result = parms->result;
652 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
654 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
657 "%s: TCAM allocation failed, rc:%s\n",
658 tf_dir_2_str(parms->dir),
663 /* Copy the outputs */
664 parms->hit = sparms.hit;
665 parms->search_status = sparms.search_status;
666 parms->ref_cnt = sparms.ref_cnt;
667 parms->idx = sparms.idx;
673 tf_alloc_tcam_entry(struct tf *tfp,
674 struct tf_alloc_tcam_entry_parms *parms)
677 struct tf_session *tfs;
678 struct tf_dev_info *dev;
679 struct tf_tcam_alloc_parms aparms;
681 TF_CHECK_PARMS2(tfp, parms);
683 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
685 /* Retrieve the session information */
686 rc = tf_session_get_session(tfp, &tfs);
689 "%s: Failed to lookup session, rc:%s\n",
690 tf_dir_2_str(parms->dir),
695 /* Retrieve the device information */
696 rc = tf_session_get_device(tfs, &dev);
699 "%s: Failed to lookup device, rc:%s\n",
700 tf_dir_2_str(parms->dir),
705 if (dev->ops->tf_dev_alloc_tcam == NULL) {
708 "%s: Operation not supported, rc:%s\n",
709 tf_dir_2_str(parms->dir),
714 aparms.dir = parms->dir;
715 aparms.type = parms->tcam_tbl_type;
716 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
717 aparms.priority = parms->priority;
718 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
721 "%s: TCAM allocation failed, rc:%s\n",
722 tf_dir_2_str(parms->dir),
727 parms->idx = aparms.idx;
733 tf_set_tcam_entry(struct tf *tfp,
734 struct tf_set_tcam_entry_parms *parms)
737 struct tf_session *tfs;
738 struct tf_dev_info *dev;
739 struct tf_tcam_set_parms sparms;
741 TF_CHECK_PARMS2(tfp, parms);
743 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
746 /* Retrieve the session information */
747 rc = tf_session_get_session(tfp, &tfs);
750 "%s: Failed to lookup session, rc:%s\n",
751 tf_dir_2_str(parms->dir),
756 /* Retrieve the device information */
757 rc = tf_session_get_device(tfs, &dev);
760 "%s: Failed to lookup device, rc:%s\n",
761 tf_dir_2_str(parms->dir),
766 if (dev->ops->tf_dev_set_tcam == NULL ||
767 dev->ops->tf_dev_word_align == NULL) {
770 "%s: Operation not supported, rc:%s\n",
771 tf_dir_2_str(parms->dir),
776 sparms.dir = parms->dir;
777 sparms.type = parms->tcam_tbl_type;
778 sparms.idx = parms->idx;
779 sparms.key = parms->key;
780 sparms.mask = parms->mask;
781 sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
782 sparms.result = parms->result;
783 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
785 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
788 "%s: TCAM set failed, rc:%s\n",
789 tf_dir_2_str(parms->dir),
798 tf_get_tcam_entry(struct tf *tfp __rte_unused,
799 struct tf_get_tcam_entry_parms *parms)
802 struct tf_session *tfs;
803 struct tf_dev_info *dev;
804 struct tf_tcam_get_parms gparms;
806 TF_CHECK_PARMS2(tfp, parms);
808 memset(&gparms, 0, sizeof(struct tf_tcam_get_parms));
811 /* Retrieve the session information */
812 rc = tf_session_get_session(tfp, &tfs);
815 "%s: Failed to lookup session, rc:%s\n",
816 tf_dir_2_str(parms->dir),
821 /* Retrieve the device information */
822 rc = tf_session_get_device(tfs, &dev);
825 "%s: Failed to lookup device, rc:%s\n",
826 tf_dir_2_str(parms->dir),
831 if (dev->ops->tf_dev_get_tcam == NULL) {
834 "%s: Operation not supported, rc:%s\n",
835 tf_dir_2_str(parms->dir),
840 gparms.dir = parms->dir;
841 gparms.type = parms->tcam_tbl_type;
842 gparms.idx = parms->idx;
843 gparms.key = parms->key;
844 gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
845 gparms.mask = parms->mask;
846 gparms.result = parms->result;
847 gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
849 rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
852 "%s: TCAM get failed, rc:%s\n",
853 tf_dir_2_str(parms->dir),
857 parms->key_sz_in_bits = gparms.key_size * 8;
858 parms->result_sz_in_bits = gparms.result_size * 8;
864 tf_free_tcam_entry(struct tf *tfp,
865 struct tf_free_tcam_entry_parms *parms)
868 struct tf_session *tfs;
869 struct tf_dev_info *dev;
870 struct tf_tcam_free_parms fparms;
872 TF_CHECK_PARMS2(tfp, parms);
874 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
876 /* Retrieve the session information */
877 rc = tf_session_get_session(tfp, &tfs);
880 "%s: Failed to lookup session, rc:%s\n",
881 tf_dir_2_str(parms->dir),
886 /* Retrieve the device information */
887 rc = tf_session_get_device(tfs, &dev);
890 "%s: Failed to lookup device, rc:%s\n",
891 tf_dir_2_str(parms->dir),
896 if (dev->ops->tf_dev_free_tcam == NULL) {
899 "%s: Operation not supported, rc:%s\n",
900 tf_dir_2_str(parms->dir),
905 fparms.dir = parms->dir;
906 fparms.type = parms->tcam_tbl_type;
907 fparms.idx = parms->idx;
908 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
911 "%s: TCAM free failed, rc:%s\n",
912 tf_dir_2_str(parms->dir),
920 #ifdef TF_TCAM_SHARED
922 tf_move_tcam_shared_entries(struct tf *tfp,
923 struct tf_move_tcam_shared_entries_parms *parms)
926 struct tf_session *tfs;
927 struct tf_dev_info *dev;
929 TF_CHECK_PARMS2(tfp, parms);
931 /* Retrieve the session information */
932 rc = tf_session_get_session(tfp, &tfs);
935 "%s: Failed to lookup session, rc:%s\n",
936 tf_dir_2_str(parms->dir),
941 /* Retrieve the device information */
942 rc = tf_session_get_device(tfs, &dev);
945 "%s: Failed to lookup device, rc:%s\n",
946 tf_dir_2_str(parms->dir),
951 if (dev->ops->tf_dev_move_tcam == NULL) {
954 "%s: Operation not supported, rc:%s\n",
955 tf_dir_2_str(parms->dir),
960 rc = dev->ops->tf_dev_move_tcam(tfp, parms);
963 "%s: TCAM shared entries move failed, rc:%s\n",
964 tf_dir_2_str(parms->dir),
973 tf_clear_tcam_shared_entries(struct tf *tfp,
974 struct tf_clear_tcam_shared_entries_parms *parms)
977 struct tf_session *tfs;
978 struct tf_dev_info *dev;
980 TF_CHECK_PARMS2(tfp, parms);
982 /* Retrieve the session information */
983 rc = tf_session_get_session(tfp, &tfs);
986 "%s: Failed to lookup session, rc:%s\n",
987 tf_dir_2_str(parms->dir),
992 /* Retrieve the device information */
993 rc = tf_session_get_device(tfs, &dev);
996 "%s: Failed to lookup device, rc:%s\n",
997 tf_dir_2_str(parms->dir),
1002 if (dev->ops->tf_dev_clear_tcam == NULL) {
1005 "%s: Operation not supported, rc:%s\n",
1006 tf_dir_2_str(parms->dir),
1011 rc = dev->ops->tf_dev_clear_tcam(tfp, parms);
1014 "%s: TCAM shared entries clear failed, rc:%s\n",
1015 tf_dir_2_str(parms->dir),
1022 #endif /* TF_TCAM_SHARED */
1025 tf_alloc_tbl_entry(struct tf *tfp,
1026 struct tf_alloc_tbl_entry_parms *parms)
1029 struct tf_session *tfs;
1030 struct tf_dev_info *dev;
1031 struct tf_tbl_alloc_parms aparms;
1034 TF_CHECK_PARMS2(tfp, parms);
1036 /* Can't do static initialization due to UT enum check */
1037 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
1039 /* Retrieve the session information */
1040 rc = tf_session_get_session(tfp, &tfs);
1043 "%s: Failed to lookup session, rc:%s\n",
1044 tf_dir_2_str(parms->dir),
1049 /* Retrieve the device information */
1050 rc = tf_session_get_device(tfs, &dev);
1053 "%s: Failed to lookup device, rc:%s\n",
1054 tf_dir_2_str(parms->dir),
1059 aparms.dir = parms->dir;
1060 aparms.type = parms->type;
1062 aparms.tbl_scope_id = parms->tbl_scope_id;
1064 if (parms->type == TF_TBL_TYPE_EXT) {
1065 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
1068 "%s: Operation not supported, rc:%s\n",
1069 tf_dir_2_str(parms->dir),
1074 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
1077 "%s: External table allocation failed, rc:%s\n",
1078 tf_dir_2_str(parms->dir),
1084 if (dev->ops->tf_dev_alloc_tbl == NULL) {
1087 "%s: Operation not supported, rc:%s\n",
1088 tf_dir_2_str(parms->dir),
1093 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
1096 "%s: Table allocation failed, rc:%s\n",
1097 tf_dir_2_str(parms->dir),
1109 tf_search_tbl_entry(struct tf *tfp,
1110 struct tf_search_tbl_entry_parms *parms)
1113 struct tf_session *tfs;
1114 struct tf_dev_info *dev;
1115 struct tf_tbl_alloc_search_parms sparms;
1117 TF_CHECK_PARMS2(tfp, parms);
1119 /* Retrieve the session information */
1120 rc = tf_session_get_session(tfp, &tfs);
1123 "%s: Failed to lookup session, rc:%s\n",
1124 tf_dir_2_str(parms->dir),
1129 /* Retrieve the device information */
1130 rc = tf_session_get_device(tfs, &dev);
1133 "%s: Failed to lookup device, rc:%s\n",
1134 tf_dir_2_str(parms->dir),
1139 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
1142 "%s: Operation not supported, rc:%s\n",
1143 tf_dir_2_str(parms->dir),
1148 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
1149 sparms.dir = parms->dir;
1150 sparms.type = parms->type;
1151 sparms.result = parms->result;
1152 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
1153 sparms.alloc = parms->alloc;
1154 sparms.tbl_scope_id = parms->tbl_scope_id;
1155 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
1158 "%s: TBL allocation failed, rc:%s\n",
1159 tf_dir_2_str(parms->dir),
1164 /* Return the outputs from the search */
1165 parms->hit = sparms.hit;
1166 parms->search_status = sparms.search_status;
1167 parms->ref_cnt = sparms.ref_cnt;
1168 parms->idx = sparms.idx;
1174 tf_free_tbl_entry(struct tf *tfp,
1175 struct tf_free_tbl_entry_parms *parms)
1178 struct tf_session *tfs;
1179 struct tf_dev_info *dev;
1180 struct tf_tbl_free_parms fparms;
1182 TF_CHECK_PARMS2(tfp, parms);
1184 /* Can't do static initialization due to UT enum check */
1185 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1187 /* Retrieve the session information */
1188 rc = tf_session_get_session(tfp, &tfs);
1191 "%s: Failed to lookup session, rc:%s\n",
1192 tf_dir_2_str(parms->dir),
1197 /* Retrieve the device information */
1198 rc = tf_session_get_device(tfs, &dev);
1201 "%s: Failed to lookup device, rc:%s\n",
1202 tf_dir_2_str(parms->dir),
1207 fparms.dir = parms->dir;
1208 fparms.type = parms->type;
1209 fparms.idx = parms->idx;
1210 fparms.tbl_scope_id = parms->tbl_scope_id;
1212 if (parms->type == TF_TBL_TYPE_EXT) {
1213 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1216 "%s: Operation not supported, rc:%s\n",
1217 tf_dir_2_str(parms->dir),
1222 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1225 "%s: Table free failed, rc:%s\n",
1226 tf_dir_2_str(parms->dir),
1231 if (dev->ops->tf_dev_free_tbl == NULL) {
1234 "%s: Operation not supported, rc:%s\n",
1235 tf_dir_2_str(parms->dir),
1240 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1243 "%s: Table free failed, rc:%s\n",
1244 tf_dir_2_str(parms->dir),
1254 tf_set_tbl_entry(struct tf *tfp,
1255 struct tf_set_tbl_entry_parms *parms)
1258 struct tf_session *tfs;
1259 struct tf_dev_info *dev;
1260 struct tf_tbl_set_parms sparms;
1262 TF_CHECK_PARMS3(tfp, parms, parms->data);
1264 /* Can't do static initialization due to UT enum check */
1265 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1267 /* Retrieve the session information */
1268 rc = tf_session_get_session(tfp, &tfs);
1271 "%s: Failed to lookup session, rc:%s\n",
1272 tf_dir_2_str(parms->dir),
1277 /* Retrieve the device information */
1278 rc = tf_session_get_device(tfs, &dev);
1281 "%s: Failed to lookup device, rc:%s\n",
1282 tf_dir_2_str(parms->dir),
1287 sparms.dir = parms->dir;
1288 sparms.type = parms->type;
1289 sparms.data = parms->data;
1290 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1291 sparms.idx = parms->idx;
1292 sparms.tbl_scope_id = parms->tbl_scope_id;
1294 if (parms->type == TF_TBL_TYPE_EXT) {
1295 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1298 "%s: Operation not supported, rc:%s\n",
1299 tf_dir_2_str(parms->dir),
1304 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1307 "%s: Table set failed, rc:%s\n",
1308 tf_dir_2_str(parms->dir),
1313 if (dev->ops->tf_dev_set_tbl == NULL) {
1316 "%s: Operation not supported, rc:%s\n",
1317 tf_dir_2_str(parms->dir),
1322 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1325 "%s: Table set failed, rc:%s\n",
1326 tf_dir_2_str(parms->dir),
1336 tf_get_tbl_entry(struct tf *tfp,
1337 struct tf_get_tbl_entry_parms *parms)
1340 struct tf_session *tfs;
1341 struct tf_dev_info *dev;
1342 struct tf_tbl_get_parms gparms;
1344 TF_CHECK_PARMS3(tfp, parms, parms->data);
1346 /* Can't do static initialization due to UT enum check */
1347 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1349 /* Retrieve the session information */
1350 rc = tf_session_get_session(tfp, &tfs);
1353 "%s: Failed to lookup session, rc:%s\n",
1354 tf_dir_2_str(parms->dir),
1359 /* Retrieve the device information */
1360 rc = tf_session_get_device(tfs, &dev);
1363 "%s: Failed to lookup device, rc:%s\n",
1364 tf_dir_2_str(parms->dir),
1369 if (dev->ops->tf_dev_get_tbl == NULL) {
1372 "%s: Operation not supported, rc:%s\n",
1373 tf_dir_2_str(parms->dir),
1378 gparms.dir = parms->dir;
1379 gparms.type = parms->type;
1380 gparms.data = parms->data;
1381 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1382 gparms.idx = parms->idx;
1383 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1386 "%s: Table get failed, rc:%s\n",
1387 tf_dir_2_str(parms->dir),
1396 tf_bulk_get_tbl_entry(struct tf *tfp,
1397 struct tf_bulk_get_tbl_entry_parms *parms)
1400 struct tf_session *tfs;
1401 struct tf_dev_info *dev;
1402 struct tf_tbl_get_bulk_parms bparms;
1404 TF_CHECK_PARMS2(tfp, parms);
1406 /* Can't do static initialization due to UT enum check */
1407 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1409 /* Retrieve the session information */
1410 rc = tf_session_get_session(tfp, &tfs);
1413 "%s: Failed to lookup session, rc:%s\n",
1414 tf_dir_2_str(parms->dir),
1419 /* Retrieve the device information */
1420 rc = tf_session_get_device(tfs, &dev);
1423 "%s: Failed to lookup device, rc:%s\n",
1424 tf_dir_2_str(parms->dir),
1429 if (parms->type == TF_TBL_TYPE_EXT) {
1430 /* Not supported, yet */
1433 "%s, External table type not supported, rc:%s\n",
1434 tf_dir_2_str(parms->dir),
1440 /* Internal table type processing */
1442 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1445 "%s: Operation not supported, rc:%s\n",
1446 tf_dir_2_str(parms->dir),
1451 bparms.dir = parms->dir;
1452 bparms.type = parms->type;
1453 bparms.starting_idx = parms->starting_idx;
1454 bparms.num_entries = parms->num_entries;
1455 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1456 bparms.physical_mem_addr = parms->physical_mem_addr;
1457 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1460 "%s: Table get bulk failed, rc:%s\n",
1461 tf_dir_2_str(parms->dir),
1469 int tf_get_shared_tbl_increment(struct tf *tfp,
1470 struct tf_get_shared_tbl_increment_parms *parms)
1473 struct tf_session *tfs;
1474 struct tf_dev_info *dev;
1476 TF_CHECK_PARMS2(tfp, parms);
1478 /* Retrieve the session information */
1479 rc = tf_session_get_session(tfp, &tfs);
1482 "%s: Failed to lookup session, rc:%s\n",
1483 tf_dir_2_str(parms->dir),
1488 /* Retrieve the device information */
1489 rc = tf_session_get_device(tfs, &dev);
1492 "%s: Failed to lookup device, rc:%s\n",
1493 tf_dir_2_str(parms->dir),
1498 /* Internal table type processing */
1500 if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) {
1503 "%s: Operation not supported, rc:%s\n",
1504 tf_dir_2_str(parms->dir),
1509 rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms);
1512 "%s: Get table increment not supported, rc:%s\n",
1513 tf_dir_2_str(parms->dir),
1522 tf_alloc_tbl_scope(struct tf *tfp,
1523 struct tf_alloc_tbl_scope_parms *parms)
1525 struct tf_session *tfs;
1526 struct tf_dev_info *dev;
1529 TF_CHECK_PARMS2(tfp, parms);
1531 /* Retrieve the session information */
1532 rc = tf_session_get_session(tfp, &tfs);
1535 "Failed to lookup session, rc:%s\n",
1540 /* Retrieve the device information */
1541 rc = tf_session_get_device(tfs, &dev);
1544 "Failed to lookup device, rc:%s\n",
1549 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1550 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1553 "Alloc table scope not supported by device\n");
1560 tf_map_tbl_scope(struct tf *tfp,
1561 struct tf_map_tbl_scope_parms *parms)
1563 struct tf_session *tfs;
1564 struct tf_dev_info *dev;
1567 TF_CHECK_PARMS2(tfp, parms);
1569 /* Retrieve the session information */
1570 rc = tf_session_get_session(tfp, &tfs);
1573 "Failed to lookup session, rc:%s\n",
1578 /* Retrieve the device information */
1579 rc = tf_session_get_device(tfs, &dev);
1582 "Failed to lookup device, rc:%s\n",
1587 if (dev->ops->tf_dev_map_tbl_scope != NULL) {
1588 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
1591 "Map table scope not supported by device\n");
1599 tf_free_tbl_scope(struct tf *tfp,
1600 struct tf_free_tbl_scope_parms *parms)
1602 struct tf_session *tfs;
1603 struct tf_dev_info *dev;
1606 TF_CHECK_PARMS2(tfp, parms);
1608 /* Retrieve the session information */
1609 rc = tf_session_get_session(tfp, &tfs);
1612 "Failed to lookup session, rc:%s\n",
1617 /* Retrieve the device information */
1618 rc = tf_session_get_device(tfs, &dev);
1621 "Failed to lookup device, rc:%s\n",
1626 if (dev->ops->tf_dev_free_tbl_scope) {
1627 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1630 "Free table scope not supported by device\n");
1638 tf_set_if_tbl_entry(struct tf *tfp,
1639 struct tf_set_if_tbl_entry_parms *parms)
1642 struct tf_session *tfs;
1643 struct tf_dev_info *dev;
1644 struct tf_if_tbl_set_parms sparms = { 0 };
1646 TF_CHECK_PARMS2(tfp, parms);
1648 /* Retrieve the session information */
1649 rc = tf_session_get_session(tfp, &tfs);
1652 "%s: Failed to lookup session, rc:%s\n",
1653 tf_dir_2_str(parms->dir),
1658 /* Retrieve the device information */
1659 rc = tf_session_get_device(tfs, &dev);
1662 "%s: Failed to lookup device, rc:%s\n",
1663 tf_dir_2_str(parms->dir),
1668 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1671 "%s: Operation not supported, rc:%s\n",
1672 tf_dir_2_str(parms->dir),
1677 sparms.dir = parms->dir;
1678 sparms.type = parms->type;
1679 sparms.idx = parms->idx;
1680 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1681 sparms.data = parms->data;
1683 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1686 "%s: If_tbl set failed, rc:%s\n",
1687 tf_dir_2_str(parms->dir),
1696 tf_get_if_tbl_entry(struct tf *tfp,
1697 struct tf_get_if_tbl_entry_parms *parms)
1700 struct tf_session *tfs;
1701 struct tf_dev_info *dev;
1702 struct tf_if_tbl_get_parms gparms = { 0 };
1704 TF_CHECK_PARMS2(tfp, parms);
1706 /* Retrieve the session information */
1707 rc = tf_session_get_session(tfp, &tfs);
1710 "%s: Failed to lookup session, rc:%s\n",
1711 tf_dir_2_str(parms->dir),
1716 /* Retrieve the device information */
1717 rc = tf_session_get_device(tfs, &dev);
1720 "%s: Failed to lookup device, rc:%s\n",
1721 tf_dir_2_str(parms->dir),
1726 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1729 "%s: Operation not supported, rc:%s\n",
1730 tf_dir_2_str(parms->dir),
1735 gparms.dir = parms->dir;
1736 gparms.type = parms->type;
1737 gparms.idx = parms->idx;
1738 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1739 gparms.data = parms->data;
1741 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1744 "%s: If_tbl get failed, rc:%s\n",
1745 tf_dir_2_str(parms->dir),
1753 int tf_get_session_info(struct tf *tfp,
1754 struct tf_get_session_info_parms *parms)
1757 struct tf_session *tfs;
1758 struct tf_dev_info *dev;
1760 TF_CHECK_PARMS2(tfp, parms);
1762 /* Retrieve the session information */
1763 rc = tf_session_get_session(tfp, &tfs);
1766 "Failed to lookup session, rc:%s\n",
1771 /* Retrieve the device information */
1772 rc = tf_session_get_device(tfs, &dev);
1775 "Failed to lookup device, rc:%s\n",
1780 TF_CHECK_PARMS2(tfp, parms);
1782 if (dev->ops->tf_dev_get_ident_resc_info == NULL) {
1785 "Operation not supported, rc:%s\n",
1790 rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident);
1793 "Ident get resc info failed, rc:%s\n",
1797 if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
1800 "Operation not supported, rc:%s\n",
1805 rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl);
1808 "Tbl get resc info failed, rc:%s\n",
1812 if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
1815 "Operation not supported, rc:%s\n",
1820 rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam);
1823 "TCAM get resc info failed, rc:%s\n",
1827 if (dev->ops->tf_dev_get_em_resc_info == NULL) {
1830 "Operation not supported, rc:%s\n",
1835 rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em);
1838 "EM get resc info failed, rc:%s\n",