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 printf("TF_OPEN, %s\n", parms->ctrl_chan_name);
79 rc = tf_session_open_session(tfp, &oparms);
80 /* Logging handled by tf_session_open_session */
85 "domain:%d, bus:%d, device:%d\n",
86 parms->session_id.internal.domain,
87 parms->session_id.internal.bus,
88 parms->session_id.internal.device);
94 tf_attach_session(struct tf *tfp,
95 struct tf_attach_session_parms *parms)
98 unsigned int domain, bus, slot, device;
99 struct tf_session_attach_session_parms aparms;
101 TF_CHECK_PARMS2(tfp, parms);
103 /* Verify control channel */
104 rc = sscanf(parms->ctrl_chan_name,
112 "Failed to scan device ctrl_chan_name\n");
116 /* Verify 'attach' channel */
117 rc = sscanf(parms->attach_chan_name,
125 "Failed to scan device attach_chan_name\n");
129 /* Prepare return value of session_id, using ctrl_chan_name
130 * device values as it becomes the session id.
132 parms->session_id.internal.domain = domain;
133 parms->session_id.internal.bus = bus;
134 parms->session_id.internal.device = device;
135 aparms.attach_cfg = parms;
136 rc = tf_session_attach_session(tfp,
138 /* Logging handled by dev_bind */
143 "Attached to session, session_id:%d\n",
144 parms->session_id.id);
147 "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
148 parms->session_id.internal.domain,
149 parms->session_id.internal.bus,
150 parms->session_id.internal.device,
151 parms->session_id.internal.fw_session_id);
157 tf_close_session(struct tf *tfp)
160 struct tf_session_close_session_parms cparms = { 0 };
161 union tf_session_id session_id = { 0 };
164 TF_CHECK_PARMS1(tfp);
166 cparms.ref_count = &ref_count;
167 cparms.session_id = &session_id;
168 /* Session vs session client is decided in
169 * tf_session_close_session()
171 rc = tf_session_close_session(tfp,
173 /* Logging handled by tf_session_close_session */
178 "domain:%d, bus:%d, device:%d\n",
179 cparms.session_id->internal.domain,
180 cparms.session_id->internal.bus,
181 cparms.session_id->internal.device);
186 /** insert EM hash entry API
192 int tf_insert_em_entry(struct tf *tfp,
193 struct tf_insert_em_entry_parms *parms)
195 struct tf_session *tfs;
196 struct tf_dev_info *dev;
199 TF_CHECK_PARMS2(tfp, parms);
201 /* Retrieve the session information */
202 rc = tf_session_get_session(tfp, &tfs);
205 "%s: Failed to lookup session, rc:%s\n",
206 tf_dir_2_str(parms->dir),
211 /* Retrieve the device information */
212 rc = tf_session_get_device(tfs, &dev);
215 "%s: Failed to lookup device, rc:%s\n",
216 tf_dir_2_str(parms->dir),
221 if (parms->mem == TF_MEM_EXTERNAL &&
222 dev->ops->tf_dev_insert_ext_em_entry != NULL)
223 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
224 else if (parms->mem == TF_MEM_INTERNAL &&
225 dev->ops->tf_dev_insert_int_em_entry != NULL)
226 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
232 "%s: EM insert failed, rc:%s\n",
233 tf_dir_2_str(parms->dir),
241 /** Delete EM hash entry API
247 int tf_delete_em_entry(struct tf *tfp,
248 struct tf_delete_em_entry_parms *parms)
250 struct tf_session *tfs;
251 struct tf_dev_info *dev;
254 TF_CHECK_PARMS2(tfp, parms);
256 /* Retrieve the session information */
257 rc = tf_session_get_session(tfp, &tfs);
260 "%s: Failed to lookup session, rc:%s\n",
261 tf_dir_2_str(parms->dir),
266 /* Retrieve the device information */
267 rc = tf_session_get_device(tfs, &dev);
270 "%s: Failed to lookup device, rc:%s\n",
271 tf_dir_2_str(parms->dir),
276 if (parms->mem == TF_MEM_EXTERNAL)
277 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
278 else if (parms->mem == TF_MEM_INTERNAL)
279 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
285 "%s: EM delete failed, rc:%s\n",
286 tf_dir_2_str(parms->dir),
294 /** Get global configuration API
300 int tf_get_global_cfg(struct tf *tfp,
301 struct tf_global_cfg_parms *parms)
304 struct tf_session *tfs;
305 struct tf_dev_info *dev;
306 struct tf_dev_global_cfg_parms gparms = { 0 };
308 TF_CHECK_PARMS2(tfp, parms);
310 /* Retrieve the session information */
311 rc = tf_session_get_session(tfp, &tfs);
314 "%s: Failed to lookup session, rc:%s\n",
315 tf_dir_2_str(parms->dir),
320 /* Retrieve the device information */
321 rc = tf_session_get_device(tfs, &dev);
324 "%s: Failed to lookup device, rc:%s\n",
325 tf_dir_2_str(parms->dir),
330 if (parms->config == NULL ||
331 parms->config_sz_in_bytes == 0) {
332 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
336 if (dev->ops->tf_dev_get_global_cfg == NULL) {
339 "%s: Operation not supported, rc:%s\n",
340 tf_dir_2_str(parms->dir),
345 gparms.dir = parms->dir;
346 gparms.type = parms->type;
347 gparms.offset = parms->offset;
348 gparms.config = parms->config;
349 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
350 rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms);
353 "%s: Global Cfg get failed, rc:%s\n",
354 tf_dir_2_str(parms->dir),
362 /** Set global configuration API
368 int tf_set_global_cfg(struct tf *tfp,
369 struct tf_global_cfg_parms *parms)
372 struct tf_session *tfs;
373 struct tf_dev_info *dev;
374 struct tf_dev_global_cfg_parms gparms = { 0 };
376 TF_CHECK_PARMS2(tfp, parms);
378 /* Retrieve the session information */
379 rc = tf_session_get_session(tfp, &tfs);
382 "%s: Failed to lookup session, rc:%s\n",
383 tf_dir_2_str(parms->dir),
388 /* Retrieve the device information */
389 rc = tf_session_get_device(tfs, &dev);
392 "%s: Failed to lookup device, rc:%s\n",
393 tf_dir_2_str(parms->dir),
398 if (parms->config == NULL ||
399 parms->config_sz_in_bytes == 0) {
400 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
404 if (dev->ops->tf_dev_set_global_cfg == NULL) {
407 "%s: Operation not supported, rc:%s\n",
408 tf_dir_2_str(parms->dir),
413 gparms.dir = parms->dir;
414 gparms.type = parms->type;
415 gparms.offset = parms->offset;
416 gparms.config = parms->config;
417 gparms.config_sz_in_bytes = parms->config_sz_in_bytes;
418 rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms);
421 "%s: Global Cfg set failed, rc:%s\n",
422 tf_dir_2_str(parms->dir),
431 tf_alloc_identifier(struct tf *tfp,
432 struct tf_alloc_identifier_parms *parms)
435 struct tf_session *tfs;
436 struct tf_dev_info *dev;
437 struct tf_ident_alloc_parms aparms;
440 TF_CHECK_PARMS2(tfp, parms);
442 /* Can't do static initialization due to UT enum check */
443 memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
445 /* Retrieve the session information */
446 rc = tf_session_get_session(tfp, &tfs);
449 "%s: Failed to lookup session, rc:%s\n",
450 tf_dir_2_str(parms->dir),
455 /* Retrieve the device information */
456 rc = tf_session_get_device(tfs, &dev);
459 "%s: Failed to lookup device, rc:%s\n",
460 tf_dir_2_str(parms->dir),
465 if (dev->ops->tf_dev_alloc_ident == NULL) {
468 "%s: Operation not supported, rc:%s\n",
469 tf_dir_2_str(parms->dir),
474 aparms.dir = parms->dir;
475 aparms.type = parms->ident_type;
477 rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
480 "%s: Identifier allocation failed, rc:%s\n",
481 tf_dir_2_str(parms->dir),
492 tf_free_identifier(struct tf *tfp,
493 struct tf_free_identifier_parms *parms)
496 struct tf_session *tfs;
497 struct tf_dev_info *dev;
498 struct tf_ident_free_parms fparms;
500 TF_CHECK_PARMS2(tfp, parms);
502 /* Can't do static initialization due to UT enum check */
503 memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
505 /* Retrieve the session information */
506 rc = tf_session_get_session(tfp, &tfs);
509 "%s: Failed to lookup session, rc:%s\n",
510 tf_dir_2_str(parms->dir),
515 /* Retrieve the device information */
516 rc = tf_session_get_device(tfs, &dev);
519 "%s: Failed to lookup device, rc:%s\n",
520 tf_dir_2_str(parms->dir),
525 if (dev->ops->tf_dev_free_ident == NULL) {
528 "%s: Operation not supported, rc:%s\n",
529 tf_dir_2_str(parms->dir),
534 fparms.dir = parms->dir;
535 fparms.type = parms->ident_type;
536 fparms.id = parms->id;
537 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_alloc_tcam_entry(struct tf *tfp,
551 struct tf_alloc_tcam_entry_parms *parms)
554 struct tf_session *tfs;
555 struct tf_dev_info *dev;
556 struct tf_tcam_alloc_parms aparms;
558 TF_CHECK_PARMS2(tfp, parms);
560 memset(&aparms, 0, sizeof(struct tf_tcam_alloc_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_alloc_tcam == NULL) {
585 "%s: Operation not supported, rc:%s\n",
586 tf_dir_2_str(parms->dir),
591 aparms.dir = parms->dir;
592 aparms.type = parms->tcam_tbl_type;
593 aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
594 aparms.priority = parms->priority;
595 rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
598 "%s: TCAM allocation failed, rc:%s\n",
599 tf_dir_2_str(parms->dir),
604 parms->idx = aparms.idx;
610 tf_set_tcam_entry(struct tf *tfp,
611 struct tf_set_tcam_entry_parms *parms)
614 struct tf_session *tfs;
615 struct tf_dev_info *dev;
616 struct tf_tcam_set_parms sparms;
618 TF_CHECK_PARMS2(tfp, parms);
620 memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
623 /* Retrieve the session information */
624 rc = tf_session_get_session(tfp, &tfs);
627 "%s: Failed to lookup session, rc:%s\n",
628 tf_dir_2_str(parms->dir),
633 /* Retrieve the device information */
634 rc = tf_session_get_device(tfs, &dev);
637 "%s: Failed to lookup device, rc:%s\n",
638 tf_dir_2_str(parms->dir),
643 if (dev->ops->tf_dev_set_tcam == NULL) {
646 "%s: Operation not supported, rc:%s\n",
647 tf_dir_2_str(parms->dir),
652 sparms.dir = parms->dir;
653 sparms.type = parms->tcam_tbl_type;
654 sparms.idx = parms->idx;
655 sparms.key = parms->key;
656 sparms.mask = parms->mask;
657 sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
658 sparms.result = parms->result;
659 sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
661 rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
664 "%s: TCAM set failed, rc:%s\n",
665 tf_dir_2_str(parms->dir),
674 tf_get_tcam_entry(struct tf *tfp __rte_unused,
675 struct tf_get_tcam_entry_parms *parms __rte_unused)
677 TF_CHECK_PARMS2(tfp, parms);
682 tf_free_tcam_entry(struct tf *tfp,
683 struct tf_free_tcam_entry_parms *parms)
686 struct tf_session *tfs;
687 struct tf_dev_info *dev;
688 struct tf_tcam_free_parms fparms;
690 TF_CHECK_PARMS2(tfp, parms);
692 memset(&fparms, 0, sizeof(struct tf_tcam_free_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_free_tcam == NULL) {
717 "%s: Operation not supported, rc:%s\n",
718 tf_dir_2_str(parms->dir),
723 fparms.dir = parms->dir;
724 fparms.type = parms->tcam_tbl_type;
725 fparms.idx = parms->idx;
726 rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
729 "%s: TCAM free failed, rc:%s\n",
730 tf_dir_2_str(parms->dir),
739 tf_alloc_tbl_entry(struct tf *tfp,
740 struct tf_alloc_tbl_entry_parms *parms)
743 struct tf_session *tfs;
744 struct tf_dev_info *dev;
745 struct tf_tbl_alloc_parms aparms;
748 TF_CHECK_PARMS2(tfp, parms);
750 /* Can't do static initialization due to UT enum check */
751 memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
753 /* Retrieve the session information */
754 rc = tf_session_get_session(tfp, &tfs);
757 "%s: Failed to lookup session, rc:%s\n",
758 tf_dir_2_str(parms->dir),
763 /* Retrieve the device information */
764 rc = tf_session_get_device(tfs, &dev);
767 "%s: Failed to lookup device, rc:%s\n",
768 tf_dir_2_str(parms->dir),
773 aparms.dir = parms->dir;
774 aparms.type = parms->type;
776 aparms.tbl_scope_id = parms->tbl_scope_id;
778 if (parms->type == TF_TBL_TYPE_EXT) {
779 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
782 "%s: Operation not supported, rc:%s\n",
783 tf_dir_2_str(parms->dir),
788 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
791 "%s: External table allocation failed, rc:%s\n",
792 tf_dir_2_str(parms->dir),
798 if (dev->ops->tf_dev_alloc_tbl == NULL) {
801 "%s: Operation not supported, rc:%s\n",
802 tf_dir_2_str(parms->dir),
807 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
810 "%s: Table allocation failed, rc:%s\n",
811 tf_dir_2_str(parms->dir),
823 tf_free_tbl_entry(struct tf *tfp,
824 struct tf_free_tbl_entry_parms *parms)
827 struct tf_session *tfs;
828 struct tf_dev_info *dev;
829 struct tf_tbl_free_parms fparms;
831 TF_CHECK_PARMS2(tfp, parms);
833 /* Can't do static initialization due to UT enum check */
834 memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
836 /* Retrieve the session information */
837 rc = tf_session_get_session(tfp, &tfs);
840 "%s: Failed to lookup session, rc:%s\n",
841 tf_dir_2_str(parms->dir),
846 /* Retrieve the device information */
847 rc = tf_session_get_device(tfs, &dev);
850 "%s: Failed to lookup device, rc:%s\n",
851 tf_dir_2_str(parms->dir),
856 fparms.dir = parms->dir;
857 fparms.type = parms->type;
858 fparms.idx = parms->idx;
859 fparms.tbl_scope_id = parms->tbl_scope_id;
861 if (parms->type == TF_TBL_TYPE_EXT) {
862 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
865 "%s: Operation not supported, rc:%s\n",
866 tf_dir_2_str(parms->dir),
871 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
874 "%s: Table free failed, rc:%s\n",
875 tf_dir_2_str(parms->dir),
880 if (dev->ops->tf_dev_free_tbl == NULL) {
883 "%s: Operation not supported, rc:%s\n",
884 tf_dir_2_str(parms->dir),
889 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
892 "%s: Table free failed, rc:%s\n",
893 tf_dir_2_str(parms->dir),
903 tf_set_tbl_entry(struct tf *tfp,
904 struct tf_set_tbl_entry_parms *parms)
907 struct tf_session *tfs;
908 struct tf_dev_info *dev;
909 struct tf_tbl_set_parms sparms;
911 TF_CHECK_PARMS3(tfp, parms, parms->data);
913 /* Can't do static initialization due to UT enum check */
914 memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
916 /* Retrieve the session information */
917 rc = tf_session_get_session(tfp, &tfs);
920 "%s: Failed to lookup session, rc:%s\n",
921 tf_dir_2_str(parms->dir),
926 /* Retrieve the device information */
927 rc = tf_session_get_device(tfs, &dev);
930 "%s: Failed to lookup device, rc:%s\n",
931 tf_dir_2_str(parms->dir),
936 sparms.dir = parms->dir;
937 sparms.type = parms->type;
938 sparms.data = parms->data;
939 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
940 sparms.idx = parms->idx;
941 sparms.tbl_scope_id = parms->tbl_scope_id;
943 if (parms->type == TF_TBL_TYPE_EXT) {
944 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
947 "%s: Operation not supported, rc:%s\n",
948 tf_dir_2_str(parms->dir),
953 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
956 "%s: Table set failed, rc:%s\n",
957 tf_dir_2_str(parms->dir),
962 if (dev->ops->tf_dev_set_tbl == NULL) {
965 "%s: Operation not supported, rc:%s\n",
966 tf_dir_2_str(parms->dir),
971 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
974 "%s: Table set failed, rc:%s\n",
975 tf_dir_2_str(parms->dir),
985 tf_get_tbl_entry(struct tf *tfp,
986 struct tf_get_tbl_entry_parms *parms)
989 struct tf_session *tfs;
990 struct tf_dev_info *dev;
991 struct tf_tbl_get_parms gparms;
993 TF_CHECK_PARMS3(tfp, parms, parms->data);
995 /* Can't do static initialization due to UT enum check */
996 memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
998 /* Retrieve the session information */
999 rc = tf_session_get_session(tfp, &tfs);
1002 "%s: Failed to lookup session, rc:%s\n",
1003 tf_dir_2_str(parms->dir),
1008 /* Retrieve the device information */
1009 rc = tf_session_get_device(tfs, &dev);
1012 "%s: Failed to lookup device, rc:%s\n",
1013 tf_dir_2_str(parms->dir),
1018 if (dev->ops->tf_dev_get_tbl == NULL) {
1021 "%s: Operation not supported, rc:%s\n",
1022 tf_dir_2_str(parms->dir),
1027 gparms.dir = parms->dir;
1028 gparms.type = parms->type;
1029 gparms.data = parms->data;
1030 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1031 gparms.idx = parms->idx;
1032 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
1035 "%s: Table get failed, rc:%s\n",
1036 tf_dir_2_str(parms->dir),
1045 tf_bulk_get_tbl_entry(struct tf *tfp,
1046 struct tf_bulk_get_tbl_entry_parms *parms)
1049 struct tf_session *tfs;
1050 struct tf_dev_info *dev;
1051 struct tf_tbl_get_bulk_parms bparms;
1053 TF_CHECK_PARMS2(tfp, parms);
1055 /* Can't do static initialization due to UT enum check */
1056 memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
1058 /* Retrieve the session information */
1059 rc = tf_session_get_session(tfp, &tfs);
1062 "%s: Failed to lookup session, rc:%s\n",
1063 tf_dir_2_str(parms->dir),
1068 /* Retrieve the device information */
1069 rc = tf_session_get_device(tfs, &dev);
1072 "%s: Failed to lookup device, rc:%s\n",
1073 tf_dir_2_str(parms->dir),
1078 if (parms->type == TF_TBL_TYPE_EXT) {
1079 /* Not supported, yet */
1082 "%s, External table type not supported, rc:%s\n",
1083 tf_dir_2_str(parms->dir),
1089 /* Internal table type processing */
1091 if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
1094 "%s: Operation not supported, rc:%s\n",
1095 tf_dir_2_str(parms->dir),
1100 bparms.dir = parms->dir;
1101 bparms.type = parms->type;
1102 bparms.starting_idx = parms->starting_idx;
1103 bparms.num_entries = parms->num_entries;
1104 bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
1105 bparms.physical_mem_addr = parms->physical_mem_addr;
1106 rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
1109 "%s: Table get bulk failed, rc:%s\n",
1110 tf_dir_2_str(parms->dir),
1119 tf_alloc_tbl_scope(struct tf *tfp,
1120 struct tf_alloc_tbl_scope_parms *parms)
1122 struct tf_session *tfs;
1123 struct tf_dev_info *dev;
1126 TF_CHECK_PARMS2(tfp, parms);
1128 /* Retrieve the session information */
1129 rc = tf_session_get_session(tfp, &tfs);
1132 "Failed to lookup session, rc:%s\n",
1137 /* Retrieve the device information */
1138 rc = tf_session_get_device(tfs, &dev);
1141 "Failed to lookup device, rc:%s\n",
1146 if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
1147 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
1150 "Alloc table scope not supported by device\n");
1158 tf_free_tbl_scope(struct tf *tfp,
1159 struct tf_free_tbl_scope_parms *parms)
1161 struct tf_session *tfs;
1162 struct tf_dev_info *dev;
1165 TF_CHECK_PARMS2(tfp, parms);
1167 /* Retrieve the session information */
1168 rc = tf_session_get_session(tfp, &tfs);
1171 "Failed to lookup session, rc:%s\n",
1176 /* Retrieve the device information */
1177 rc = tf_session_get_device(tfs, &dev);
1180 "Failed to lookup device, rc:%s\n",
1185 if (dev->ops->tf_dev_free_tbl_scope) {
1186 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
1189 "Free table scope not supported by device\n");
1197 tf_set_if_tbl_entry(struct tf *tfp,
1198 struct tf_set_if_tbl_entry_parms *parms)
1201 struct tf_session *tfs;
1202 struct tf_dev_info *dev;
1203 struct tf_if_tbl_set_parms sparms = { 0 };
1205 TF_CHECK_PARMS2(tfp, parms);
1207 /* Retrieve the session information */
1208 rc = tf_session_get_session(tfp, &tfs);
1211 "%s: Failed to lookup session, rc:%s\n",
1212 tf_dir_2_str(parms->dir),
1217 /* Retrieve the device information */
1218 rc = tf_session_get_device(tfs, &dev);
1221 "%s: Failed to lookup device, rc:%s\n",
1222 tf_dir_2_str(parms->dir),
1227 if (dev->ops->tf_dev_set_if_tbl == NULL) {
1230 "%s: Operation not supported, rc:%s\n",
1231 tf_dir_2_str(parms->dir),
1236 sparms.dir = parms->dir;
1237 sparms.type = parms->type;
1238 sparms.idx = parms->idx;
1239 sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1240 sparms.data = parms->data;
1242 rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
1245 "%s: If_tbl set failed, rc:%s\n",
1246 tf_dir_2_str(parms->dir),
1255 tf_get_if_tbl_entry(struct tf *tfp,
1256 struct tf_get_if_tbl_entry_parms *parms)
1259 struct tf_session *tfs;
1260 struct tf_dev_info *dev;
1261 struct tf_if_tbl_get_parms gparms = { 0 };
1263 TF_CHECK_PARMS2(tfp, parms);
1265 /* Retrieve the session information */
1266 rc = tf_session_get_session(tfp, &tfs);
1269 "%s: Failed to lookup session, rc:%s\n",
1270 tf_dir_2_str(parms->dir),
1275 /* Retrieve the device information */
1276 rc = tf_session_get_device(tfs, &dev);
1279 "%s: Failed to lookup device, rc:%s\n",
1280 tf_dir_2_str(parms->dir),
1285 if (dev->ops->tf_dev_get_if_tbl == NULL) {
1288 "%s: Operation not supported, rc:%s\n",
1289 tf_dir_2_str(parms->dir),
1294 gparms.dir = parms->dir;
1295 gparms.type = parms->type;
1296 gparms.idx = parms->idx;
1297 gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
1298 gparms.data = parms->data;
1300 rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
1303 "%s: If_tbl get failed, rc:%s\n",
1304 tf_dir_2_str(parms->dir),