1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_session.h"
14 #include "tf_global_cfg.h"
20 #include "tf_common.h"
24 tf_open_session(struct tf *tfp,
25 struct tf_open_session_parms *parms)
28 unsigned int domain, bus, slot, device;
29 struct tf_session_open_session_parms oparms;
31 TF_CHECK_PARMS2(tfp, parms);
33 /* Filter out any non-supported device types on the Core
34 * side. It is assumed that the Firmware will be supported if
35 * firmware open session succeeds.
37 if (parms->device_type != TF_DEVICE_TYPE_WH) {
39 "Unsupported device type %d\n",
44 /* Verify control channel and build the beginning of session_id */
45 rc = sscanf(parms->ctrl_chan_name,
52 /* PCI Domain not provided (optional in DPDK), thus we
53 * force domain to 0 and recheck.
57 /* Check parsing of bus/slot/device */
58 rc = sscanf(parms->ctrl_chan_name,
65 "Failed to scan device ctrl_chan_name\n");
70 parms->session_id.internal.domain = domain;
71 parms->session_id.internal.bus = bus;
72 parms->session_id.internal.device = device;
73 oparms.open_cfg = parms;
75 /* Session vs session client is decided in
76 * tf_session_open_session()
78 rc = tf_session_open_session(tfp, &oparms);
79 /* Logging handled by tf_session_open_session */
84 "domain:%d, bus:%d, device:%d\n",
85 parms->session_id.internal.domain,
86 parms->session_id.internal.bus,
87 parms->session_id.internal.device);
93 tf_attach_session(struct tf *tfp,
94 struct tf_attach_session_parms *parms)
97 unsigned int domain, bus, slot, device;
98 struct tf_session_attach_session_parms aparms;
100 TF_CHECK_PARMS2(tfp, parms);
102 /* Verify control channel */
103 rc = sscanf(parms->ctrl_chan_name,
111 "Failed to scan device ctrl_chan_name\n");
115 /* Verify 'attach' channel */
116 rc = sscanf(parms->attach_chan_name,
124 "Failed to scan device attach_chan_name\n");
128 /* Prepare return value of session_id, using ctrl_chan_name
129 * device values as it becomes the session id.
131 parms->session_id.internal.domain = domain;
132 parms->session_id.internal.bus = bus;
133 parms->session_id.internal.device = device;
134 aparms.attach_cfg = parms;
135 rc = tf_session_attach_session(tfp,
137 /* Logging handled by dev_bind */
142 "Attached to session, session_id:%d\n",
143 parms->session_id.id);
146 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
147 parms->session_id.internal.domain,
148 parms->session_id.internal.bus,
149 parms->session_id.internal.device,
150 parms->session_id.internal.fw_session_id);
156 tf_close_session(struct tf *tfp)
159 struct tf_session_close_session_parms cparms = { 0 };
160 union tf_session_id session_id = { 0 };
163 TF_CHECK_PARMS1(tfp);
165 cparms.ref_count = &ref_count;
166 cparms.session_id = &session_id;
167 /* Session vs session client is decided in
168 * tf_session_close_session()
170 rc = tf_session_close_session(tfp,
172 /* Logging handled by tf_session_close_session */
177 "domain:%d, bus:%d, device:%d\n",
178 cparms.session_id->internal.domain,
179 cparms.session_id->internal.bus,
180 cparms.session_id->internal.device);
185 /** insert EM hash entry API
191 int tf_insert_em_entry(struct tf *tfp,
192 struct tf_insert_em_entry_parms *parms)
194 struct tf_session *tfs;
195 struct tf_dev_info *dev;
198 TF_CHECK_PARMS2(tfp, parms);
200 /* Retrieve the session information */
201 rc = tf_session_get_session(tfp, &tfs);
204 "%s: Failed to lookup session, rc:%s\n",
205 tf_dir_2_str(parms->dir),
210 /* Retrieve the device information */
211 rc = tf_session_get_device(tfs, &dev);
214 "%s: Failed to lookup device, rc:%s\n",
215 tf_dir_2_str(parms->dir),
220 if (parms->mem == TF_MEM_EXTERNAL &&
221 dev->ops->tf_dev_insert_ext_em_entry != NULL)
222 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
223 else if (parms->mem == TF_MEM_INTERNAL &&
224 dev->ops->tf_dev_insert_int_em_entry != NULL)
225 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
231 "%s: EM insert failed, rc:%s\n",
232 tf_dir_2_str(parms->dir),
240 /** Delete EM hash entry API
246 int tf_delete_em_entry(struct tf *tfp,
247 struct tf_delete_em_entry_parms *parms)
249 struct tf_session *tfs;
250 struct tf_dev_info *dev;
253 TF_CHECK_PARMS2(tfp, parms);
255 /* Retrieve the session information */
256 rc = tf_session_get_session(tfp, &tfs);
259 "%s: Failed to lookup session, rc:%s\n",
260 tf_dir_2_str(parms->dir),
265 /* Retrieve the device information */
266 rc = tf_session_get_device(tfs, &dev);
269 "%s: Failed to lookup device, rc:%s\n",
270 tf_dir_2_str(parms->dir),
275 if (parms->mem == TF_MEM_EXTERNAL)
276 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
277 else if (parms->mem == TF_MEM_INTERNAL)
278 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
284 "%s: EM delete failed, rc:%s\n",
285 tf_dir_2_str(parms->dir),
293 /** Get global configuration API
299 int tf_get_global_cfg(struct tf *tfp,
300 struct tf_global_cfg_parms *parms)
303 struct tf_session *tfs;
304 struct tf_dev_info *dev;
305 struct tf_dev_global_cfg_parms gparms = { 0 };
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 gparms.dir = parms->dir;
345 gparms.type = parms->type;
346 gparms.offset = parms->offset;
347 gparms.config = parms->config;
348 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
349 rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
352 "%s: Global Cfg get failed, rc:%s\n",
353 tf_dir_2_str(parms->dir),
361 /** Set global configuration API
367 int tf_set_global_cfg(struct tf *tfp,
368 struct tf_global_cfg_parms *parms)
371 struct tf_session *tfs;
372 struct tf_dev_info *dev;
373 struct tf_dev_global_cfg_parms gparms = { 0 };
375 TF_CHECK_PARMS2(tfp, parms);
377 /* Retrieve the session information */
378 rc = tf_session_get_session(tfp, &tfs);
381 "%s: Failed to lookup session, rc:%s\n",
382 tf_dir_2_str(parms->dir),
387 /* Retrieve the device information */
388 rc = tf_session_get_device(tfs, &dev);
391 "%s: Failed to lookup device, rc:%s\n",
392 tf_dir_2_str(parms->dir),
397 if (parms->config == NULL ||
398 parms->config_sz_in_bytes == 0) {
399 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
403 if (dev->ops->tf_dev_set_global_cfg == NULL) {
406 "%s: Operation not supported, rc:%s\n",
407 tf_dir_2_str(parms->dir),
412 gparms.dir = parms->dir;
413 gparms.type = parms->type;
414 gparms.offset = parms->offset;
415 gparms.config = parms->config;
416 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
417 rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
420 "%s: Global Cfg set failed, rc:%s\n",
421 tf_dir_2_str(parms->dir),
430 tf_alloc_identifier(struct tf *tfp,
431 struct tf_alloc_identifier_parms *parms)
434 struct tf_session *tfs;
435 struct tf_dev_info *dev;
436 struct tf_ident_alloc_parms aparms;
439 TF_CHECK_PARMS2(tfp, parms);
441 /* Can't do static initialization due to UT enum check */
442 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
444 /* Retrieve the session information */
445 rc = tf_session_get_session(tfp, &tfs);
448 "%s: Failed to lookup session, rc:%s\n",
449 tf_dir_2_str(parms->dir),
454 /* Retrieve the device information */
455 rc = tf_session_get_device(tfs, &dev);
458 "%s: Failed to lookup device, rc:%s\n",
459 tf_dir_2_str(parms->dir),
464 if (dev->ops->tf_dev_alloc_ident == NULL) {
467 "%s: Operation not supported, rc:%s\n",
468 tf_dir_2_str(parms->dir),
473 aparms.dir = parms->dir;
474 aparms.type = parms->ident_type;
476 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
479 "%s: Identifier allocation failed, rc:%s\n",
480 tf_dir_2_str(parms->dir),
491 tf_free_identifier(struct tf *tfp,
492 struct tf_free_identifier_parms *parms)
495 struct tf_session *tfs;
496 struct tf_dev_info *dev;
497 struct tf_ident_free_parms fparms;
499 TF_CHECK_PARMS2(tfp, parms);
501 /* Can't do static initialization due to UT enum check */
502 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
504 /* Retrieve the session information */
505 rc = tf_session_get_session(tfp, &tfs);
508 "%s: Failed to lookup session, rc:%s\n",
509 tf_dir_2_str(parms->dir),
514 /* Retrieve the device information */
515 rc = tf_session_get_device(tfs, &dev);
518 "%s: Failed to lookup device, rc:%s\n",
519 tf_dir_2_str(parms->dir),
524 if (dev->ops->tf_dev_free_ident == NULL) {
527 "%s: Operation not supported, rc:%s\n",
528 tf_dir_2_str(parms->dir),
533 fparms.dir = parms->dir;
534 fparms.type = parms->ident_type;
535 fparms.id = parms->id;
536 fparms.ref_cnt = &parms->ref_cnt;
537 rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
540 "%s: Identifier free failed, rc:%s\n",
541 tf_dir_2_str(parms->dir),
550 tf_search_identifier(struct tf *tfp,
551 struct tf_search_identifier_parms *parms)
554 struct tf_session *tfs;
555 struct tf_dev_info *dev;
556 struct tf_ident_search_parms sparms;
558 TF_CHECK_PARMS2(tfp, parms);
560 /* Can't do static initialization due to UT enum check */
561 memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
563 /* Retrieve the session information */
564 rc = tf_session_get_session(tfp, &tfs);
567 "%s: Failed to lookup session, rc:%s\n",
568 tf_dir_2_str(parms->dir),
573 /* Retrieve the device information */
574 rc = tf_session_get_device(tfs, &dev);
577 "%s: Failed to lookup device, rc:%s\n",
578 tf_dir_2_str(parms->dir),
583 if (dev->ops->tf_dev_search_ident == NULL) {
586 "%s: Operation not supported, rc:%s\n",
587 tf_dir_2_str(parms->dir),
592 sparms.dir = parms->dir;
593 sparms.type = parms->ident_type;
594 sparms.search_id = parms->search_id;
595 sparms.hit = &parms->hit;
596 sparms.ref_cnt = &parms->ref_cnt;
597 rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
600 "%s: Identifier search failed, rc:%s\n",
601 tf_dir_2_str(parms->dir),
610 tf_search_tcam_entry(struct tf *tfp,
611 struct tf_search_tcam_entry_parms *parms)
614 struct tf_session *tfs;
615 struct tf_dev_info *dev;
616 struct tf_tcam_alloc_search_parms sparms;
618 TF_CHECK_PARMS2(tfp, parms);
620 memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
622 /* Retrieve the session information */
623 rc = tf_session_get_session(tfp, &tfs);
626 "%s: Failed to lookup session, rc:%s\n",
627 tf_dir_2_str(parms->dir),
632 /* Retrieve the device information */
633 rc = tf_session_get_device(tfs, &dev);
636 "%s: Failed to lookup device, rc:%s\n",
637 tf_dir_2_str(parms->dir),
642 if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
645 "%s: Operation not supported, rc:%s\n",
646 tf_dir_2_str(parms->dir),
651 sparms.dir = parms->dir;
652 sparms.type = parms->tcam_tbl_type;
653 sparms.key = parms->key;
654 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
655 sparms.mask = parms->mask;
656 sparms.priority = parms->priority;
657 sparms.alloc = parms->alloc;
659 /* Result is an in/out and so no need to copy during outputs */
660 sparms.result = parms->result;
662 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
664 rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
667 "%s: TCAM allocation failed, rc:%s\n",
668 tf_dir_2_str(parms->dir),
673 /* Copy the outputs */
674 parms->hit = sparms.hit;
675 parms->search_status = sparms.search_status;
676 parms->ref_cnt = sparms.ref_cnt;
677 parms->idx = sparms.idx;
683 tf_alloc_tcam_entry(struct tf *tfp,
684 struct tf_alloc_tcam_entry_parms *parms)
687 struct tf_session *tfs;
688 struct tf_dev_info *dev;
689 struct tf_tcam_alloc_parms aparms;
691 TF_CHECK_PARMS2(tfp, parms);
693 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
695 /* Retrieve the session information */
696 rc = tf_session_get_session(tfp, &tfs);
699 "%s: Failed to lookup session, rc:%s\n",
700 tf_dir_2_str(parms->dir),
705 /* Retrieve the device information */
706 rc = tf_session_get_device(tfs, &dev);
709 "%s: Failed to lookup device, rc:%s\n",
710 tf_dir_2_str(parms->dir),
715 if (dev->ops->tf_dev_alloc_tcam == NULL) {
718 "%s: Operation not supported, rc:%s\n",
719 tf_dir_2_str(parms->dir),
724 aparms.dir = parms->dir;
725 aparms.type = parms->tcam_tbl_type;
726 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
727 aparms.priority = parms->priority;
728 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
731 "%s: TCAM allocation failed, rc:%s\n",
732 tf_dir_2_str(parms->dir),
737 parms->idx = aparms.idx;
743 tf_set_tcam_entry(struct tf *tfp,
744 struct tf_set_tcam_entry_parms *parms)
747 struct tf_session *tfs;
748 struct tf_dev_info *dev;
749 struct tf_tcam_set_parms sparms;
751 TF_CHECK_PARMS2(tfp, parms);
753 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
756 /* Retrieve the session information */
757 rc = tf_session_get_session(tfp, &tfs);
760 "%s: Failed to lookup session, rc:%s\n",
761 tf_dir_2_str(parms->dir),
766 /* Retrieve the device information */
767 rc = tf_session_get_device(tfs, &dev);
770 "%s: Failed to lookup device, rc:%s\n",
771 tf_dir_2_str(parms->dir),
776 if (dev->ops->tf_dev_set_tcam == 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 = TF_BITS2BYTES_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 __rte_unused)
810 TF_CHECK_PARMS2(tfp, parms);
815 tf_free_tcam_entry(struct tf *tfp,
816 struct tf_free_tcam_entry_parms *parms)
819 struct tf_session *tfs;
820 struct tf_dev_info *dev;
821 struct tf_tcam_free_parms fparms;
823 TF_CHECK_PARMS2(tfp, parms);
825 memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
827 /* Retrieve the session information */
828 rc = tf_session_get_session(tfp, &tfs);
831 "%s: Failed to lookup session, rc:%s\n",
832 tf_dir_2_str(parms->dir),
837 /* Retrieve the device information */
838 rc = tf_session_get_device(tfs, &dev);
841 "%s: Failed to lookup device, rc:%s\n",
842 tf_dir_2_str(parms->dir),
847 if (dev->ops->tf_dev_free_tcam == NULL) {
850 "%s: Operation not supported, rc:%s\n",
851 tf_dir_2_str(parms->dir),
856 fparms.dir = parms->dir;
857 fparms.type = parms->tcam_tbl_type;
858 fparms.idx = parms->idx;
859 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
862 "%s: TCAM free failed, rc:%s\n",
863 tf_dir_2_str(parms->dir),
872 tf_alloc_tbl_entry(struct tf *tfp,
873 struct tf_alloc_tbl_entry_parms *parms)
876 struct tf_session *tfs;
877 struct tf_dev_info *dev;
878 struct tf_tbl_alloc_parms aparms;
881 TF_CHECK_PARMS2(tfp, parms);
883 /* Can't do static initialization due to UT enum check */
884 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
886 /* Retrieve the session information */
887 rc = tf_session_get_session(tfp, &tfs);
890 "%s: Failed to lookup session, rc:%s\n",
891 tf_dir_2_str(parms->dir),
896 /* Retrieve the device information */
897 rc = tf_session_get_device(tfs, &dev);
900 "%s: Failed to lookup device, rc:%s\n",
901 tf_dir_2_str(parms->dir),
906 aparms.dir = parms->dir;
907 aparms.type = parms->type;
909 aparms.tbl_scope_id = parms->tbl_scope_id;
911 if (parms->type == TF_TBL_TYPE_EXT) {
912 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
915 "%s: Operation not supported, rc:%s\n",
916 tf_dir_2_str(parms->dir),
921 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
924 "%s: External table allocation failed, rc:%s\n",
925 tf_dir_2_str(parms->dir),
931 if (dev->ops->tf_dev_alloc_tbl == NULL) {
934 "%s: Operation not supported, rc:%s\n",
935 tf_dir_2_str(parms->dir),
940 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
943 "%s: Table allocation failed, rc:%s\n",
944 tf_dir_2_str(parms->dir),
956 tf_search_tbl_entry(struct tf *tfp,
957 struct tf_search_tbl_entry_parms *parms)
960 struct tf_session *tfs;
961 struct tf_dev_info *dev;
962 struct tf_tbl_alloc_search_parms sparms;
964 TF_CHECK_PARMS2(tfp, parms);
966 /* Retrieve the session information */
967 rc = tf_session_get_session(tfp, &tfs);
970 "%s: Failed to lookup session, rc:%s\n",
971 tf_dir_2_str(parms->dir),
976 /* Retrieve the device information */
977 rc = tf_session_get_device(tfs, &dev);
980 "%s: Failed to lookup device, rc:%s\n",
981 tf_dir_2_str(parms->dir),
986 if (dev->ops->tf_dev_alloc_search_tbl == NULL) {
989 "%s: Operation not supported, rc:%s\n",
990 tf_dir_2_str(parms->dir),
995 memset(&sparms, 0, sizeof(struct tf_tbl_alloc_search_parms));
996 sparms.dir = parms->dir;
997 sparms.type = parms->type;
998 sparms.result = parms->result;
999 sparms.result_sz_in_bytes = parms->result_sz_in_bytes;
1000 sparms.alloc = parms->alloc;
1001 sparms.tbl_scope_id = parms->tbl_scope_id;
1002 rc = dev->ops->tf_dev_alloc_search_tbl(tfp, &sparms);
1005 "%s: TBL allocation failed, rc:%s\n",
1006 tf_dir_2_str(parms->dir),
1011 /* Return the outputs from the search */
1012 parms->hit = sparms.hit;
1013 parms->search_status = sparms.search_status;
1014 parms->ref_cnt = sparms.ref_cnt;
1015 parms->idx = sparms.idx;
1021 tf_free_tbl_entry(struct tf *tfp,
1022 struct tf_free_tbl_entry_parms *parms)
1025 struct tf_session *tfs;
1026 struct tf_dev_info *dev;
1027 struct tf_tbl_free_parms fparms;
1029 TF_CHECK_PARMS2(tfp, parms);
1031 /* Can't do static initialization due to UT enum check */
1032 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
1034 /* Retrieve the session information */
1035 rc = tf_session_get_session(tfp, &tfs);
1038 "%s: Failed to lookup session, rc:%s\n",
1039 tf_dir_2_str(parms->dir),
1044 /* Retrieve the device information */
1045 rc = tf_session_get_device(tfs, &dev);
1048 "%s: Failed to lookup device, rc:%s\n",
1049 tf_dir_2_str(parms->dir),
1054 fparms.dir = parms->dir;
1055 fparms.type = parms->type;
1056 fparms.idx = parms->idx;
1057 fparms.tbl_scope_id = parms->tbl_scope_id;
1059 if (parms->type == TF_TBL_TYPE_EXT) {
1060 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
1063 "%s: Operation not supported, rc:%s\n",
1064 tf_dir_2_str(parms->dir),
1069 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
1072 "%s: Table free failed, rc:%s\n",
1073 tf_dir_2_str(parms->dir),
1078 if (dev->ops->tf_dev_free_tbl == NULL) {
1081 "%s: Operation not supported, rc:%s\n",
1082 tf_dir_2_str(parms->dir),
1087 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
1090 "%s: Table free failed, rc:%s\n",
1091 tf_dir_2_str(parms->dir),
1101 tf_set_tbl_entry(struct tf *tfp,
1102 struct tf_set_tbl_entry_parms *parms)
1105 struct tf_session *tfs;
1106 struct tf_dev_info *dev;
1107 struct tf_tbl_set_parms sparms;
1109 TF_CHECK_PARMS3(tfp, parms, parms->data);
1111 /* Can't do static initialization due to UT enum check */
1112 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
1114 /* Retrieve the session information */
1115 rc = tf_session_get_session(tfp, &tfs);
1118 "%s: Failed to lookup session, rc:%s\n",
1119 tf_dir_2_str(parms->dir),
1124 /* Retrieve the device information */
1125 rc = tf_session_get_device(tfs, &dev);
1128 "%s: Failed to lookup device, rc:%s\n",
1129 tf_dir_2_str(parms->dir),
1134 sparms.dir = parms->dir;
1135 sparms.type = parms->type;
1136 sparms.data = parms->data;
1137 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1138 sparms.idx = parms->idx;
1139 sparms.tbl_scope_id = parms->tbl_scope_id;
1141 if (parms->type == TF_TBL_TYPE_EXT) {
1142 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
1145 "%s: Operation not supported, rc:%s\n",
1146 tf_dir_2_str(parms->dir),
1151 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
1154 "%s: Table set failed, rc:%s\n",
1155 tf_dir_2_str(parms->dir),
1160 if (dev->ops->tf_dev_set_tbl == NULL) {
1163 "%s: Operation not supported, rc:%s\n",
1164 tf_dir_2_str(parms->dir),
1169 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
1172 "%s: Table set failed, rc:%s\n",
1173 tf_dir_2_str(parms->dir),
1183 tf_get_tbl_entry(struct tf *tfp,
1184 struct tf_get_tbl_entry_parms *parms)
1187 struct tf_session *tfs;
1188 struct tf_dev_info *dev;
1189 struct tf_tbl_get_parms gparms;
1191 TF_CHECK_PARMS3(tfp, parms, parms->data);
1193 /* Can't do static initialization due to UT enum check */
1194 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
1196 /* Retrieve the session information */
1197 rc = tf_session_get_session(tfp, &tfs);
1200 "%s: Failed to lookup session, rc:%s\n",
1201 tf_dir_2_str(parms->dir),
1206 /* Retrieve the device information */
1207 rc = tf_session_get_device(tfs, &dev);
1210 "%s: Failed to lookup device, rc:%s\n",
1211 tf_dir_2_str(parms->dir),
1216 if (dev->ops->tf_dev_get_tbl == NULL) {
1219 "%s: Operation not supported, rc:%s\n",
1220 tf_dir_2_str(parms->dir),
1225 gparms.dir = parms->dir;
1226 gparms.type = parms->type;
1227 gparms.data = parms->data;
1228 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1229 gparms.idx = parms->idx;
1230 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1233 "%s: Table get failed, rc:%s\n",
1234 tf_dir_2_str(parms->dir),
1243 tf_bulk_get_tbl_entry(struct tf *tfp,
1244 struct tf_bulk_get_tbl_entry_parms *parms)
1247 struct tf_session *tfs;
1248 struct tf_dev_info *dev;
1249 struct tf_tbl_get_bulk_parms bparms;
1251 TF_CHECK_PARMS2(tfp, parms);
1253 /* Can't do static initialization due to UT enum check */
1254 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1256 /* Retrieve the session information */
1257 rc = tf_session_get_session(tfp, &tfs);
1260 "%s: Failed to lookup session, rc:%s\n",
1261 tf_dir_2_str(parms->dir),
1266 /* Retrieve the device information */
1267 rc = tf_session_get_device(tfs, &dev);
1270 "%s: Failed to lookup device, rc:%s\n",
1271 tf_dir_2_str(parms->dir),
1276 if (parms->type == TF_TBL_TYPE_EXT) {
1277 /* Not supported, yet */
1280 "%s, External table type not supported, rc:%s\n",
1281 tf_dir_2_str(parms->dir),
1287 /* Internal table type processing */
1289 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1292 "%s: Operation not supported, rc:%s\n",
1293 tf_dir_2_str(parms->dir),
1298 bparms.dir = parms->dir;
1299 bparms.type = parms->type;
1300 bparms.starting_idx = parms->starting_idx;
1301 bparms.num_entries = parms->num_entries;
1302 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1303 bparms.physical_mem_addr = parms->physical_mem_addr;
1304 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1307 "%s: Table get bulk failed, rc:%s\n",
1308 tf_dir_2_str(parms->dir),
1317 tf_alloc_tbl_scope(struct tf *tfp,
1318 struct tf_alloc_tbl_scope_parms *parms)
1320 struct tf_session *tfs;
1321 struct tf_dev_info *dev;
1324 TF_CHECK_PARMS2(tfp, parms);
1326 /* Retrieve the session information */
1327 rc = tf_session_get_session(tfp, &tfs);
1330 "Failed to lookup session, rc:%s\n",
1335 /* Retrieve the device information */
1336 rc = tf_session_get_device(tfs, &dev);
1339 "Failed to lookup device, rc:%s\n",
1344 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1345 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1348 "Alloc table scope not supported by device\n");
1356 tf_free_tbl_scope(struct tf *tfp,
1357 struct tf_free_tbl_scope_parms *parms)
1359 struct tf_session *tfs;
1360 struct tf_dev_info *dev;
1363 TF_CHECK_PARMS2(tfp, parms);
1365 /* Retrieve the session information */
1366 rc = tf_session_get_session(tfp, &tfs);
1369 "Failed to lookup session, rc:%s\n",
1374 /* Retrieve the device information */
1375 rc = tf_session_get_device(tfs, &dev);
1378 "Failed to lookup device, rc:%s\n",
1383 if (dev->ops->tf_dev_free_tbl_scope) {
1384 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1387 "Free table scope not supported by device\n");
1395 tf_set_if_tbl_entry(struct tf *tfp,
1396 struct tf_set_if_tbl_entry_parms *parms)
1399 struct tf_session *tfs;
1400 struct tf_dev_info *dev;
1401 struct tf_if_tbl_set_parms sparms = { 0 };
1403 TF_CHECK_PARMS2(tfp, parms);
1405 /* Retrieve the session information */
1406 rc = tf_session_get_session(tfp, &tfs);
1409 "%s: Failed to lookup session, rc:%s\n",
1410 tf_dir_2_str(parms->dir),
1415 /* Retrieve the device information */
1416 rc = tf_session_get_device(tfs, &dev);
1419 "%s: Failed to lookup device, rc:%s\n",
1420 tf_dir_2_str(parms->dir),
1425 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1428 "%s: Operation not supported, rc:%s\n",
1429 tf_dir_2_str(parms->dir),
1434 sparms.dir = parms->dir;
1435 sparms.type = parms->type;
1436 sparms.idx = parms->idx;
1437 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1438 sparms.data = parms->data;
1440 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1443 "%s: If_tbl set failed, rc:%s\n",
1444 tf_dir_2_str(parms->dir),
1453 tf_get_if_tbl_entry(struct tf *tfp,
1454 struct tf_get_if_tbl_entry_parms *parms)
1457 struct tf_session *tfs;
1458 struct tf_dev_info *dev;
1459 struct tf_if_tbl_get_parms gparms = { 0 };
1461 TF_CHECK_PARMS2(tfp, parms);
1463 /* Retrieve the session information */
1464 rc = tf_session_get_session(tfp, &tfs);
1467 "%s: Failed to lookup session, rc:%s\n",
1468 tf_dir_2_str(parms->dir),
1473 /* Retrieve the device information */
1474 rc = tf_session_get_device(tfs, &dev);
1477 "%s: Failed to lookup device, rc:%s\n",
1478 tf_dir_2_str(parms->dir),
1483 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1486 "%s: Operation not supported, rc:%s\n",
1487 tf_dir_2_str(parms->dir),
1492 gparms.dir = parms->dir;
1493 gparms.type = parms->type;
1494 gparms.idx = parms->idx;
1495 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1496 gparms.data = parms->data;
1498 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1501 "%s: If_tbl get failed, rc:%s\n",
1502 tf_dir_2_str(parms->dir),