c235976fe84e76e7693a7d9f34e506335872dc19
[dpdk.git] / drivers / net / bnxt / tf_core / tf_device_p4.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #include <rte_common.h>
7 #include <cfa_resource_types.h>
8
9 #include "tf_device.h"
10 #include "tf_identifier.h"
11 #include "tf_tbl_type.h"
12 #include "tf_tcam.h"
13
14 /**
15  * Device specific function that retrieves the MAX number of HCAPI
16  * types the device supports.
17  *
18  * [in] tfp
19  *   Pointer to TF handle
20  *
21  * [out] max_types
22  *   Pointer to the MAX number of HCAPI types supported
23  *
24  * Returns
25  *   - (0) if successful.
26  *   - (-EINVAL) on failure.
27  */
28 static int
29 tf_dev_p4_get_max_types(struct tf *tfp __rte_unused,
30                         uint16_t *max_types)
31 {
32         if (max_types == NULL)
33                 return -EINVAL;
34
35         *max_types = CFA_RESOURCE_TYPE_P4_LAST + 1;
36
37         return 0;
38 }
39
40 /**
41  * Device specific function that retrieves the WC TCAM slices the
42  * device supports.
43  *
44  * [in] tfp
45  *   Pointer to TF handle
46  *
47  * [out] slice_size
48  *   Pointer to the WC TCAM slice size
49  *
50  * [out] num_slices_per_row
51  *   Pointer to the WC TCAM row slice configuration
52  *
53  * Returns
54  *   - (0) if successful.
55  *   - (-EINVAL) on failure.
56  */
57 static int
58 tf_dev_p4_get_wc_tcam_slices(struct tf *tfp __rte_unused,
59                              uint16_t *slice_size,
60                              uint16_t *num_slices_per_row)
61 {
62 #define CFA_P4_WC_TCAM_SLICE_SIZE       12
63 #define CFA_P4_WC_TCAM_SLICES_PER_ROW    2
64
65         if (slice_size == NULL || num_slices_per_row == NULL)
66                 return -EINVAL;
67
68         *slice_size = CFA_P4_WC_TCAM_SLICE_SIZE;
69         *num_slices_per_row = CFA_P4_WC_TCAM_SLICES_PER_ROW;
70
71         return 0;
72 }
73
74 /**
75  * Truflow P4 device specific functions
76  */
77 const struct tf_dev_ops tf_dev_ops_p4 = {
78         .tf_dev_get_max_types = tf_dev_p4_get_max_types,
79         .tf_dev_get_wc_tcam_slices = tf_dev_p4_get_wc_tcam_slices,
80         .tf_dev_alloc_ident = tf_ident_alloc,
81         .tf_dev_free_ident = tf_ident_free,
82         .tf_dev_alloc_tbl = tf_tbl_alloc,
83         .tf_dev_free_tbl = tf_tbl_free,
84         .tf_dev_alloc_search_tbl = tf_tbl_alloc_search,
85         .tf_dev_set_tbl = tf_tbl_set,
86         .tf_dev_get_tbl = tf_tbl_get,
87         .tf_dev_alloc_tcam = tf_tcam_alloc,
88         .tf_dev_free_tcam = tf_tcam_free,
89         .tf_dev_alloc_search_tcam = tf_tcam_alloc_search,
90         .tf_dev_set_tcam = tf_tcam_set,
91         .tf_dev_get_tcam = tf_tcam_get,
92 };