1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */
3 * Copyright (C) 2018 Netronome Systems, Inc.
5 * This software is dual licensed under the GNU General License Version 2,
6 * June 1991 as shown in the file COPYING in the top-level directory of this
7 * source tree or the BSD 2-Clause License provided below. You have the
8 * option to license this software under the complete terms of either license.
10 * The BSD 2-Clause License:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * 1. Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * 2. Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 #include <linux/types.h>
40 #define NFP_MBOX_SYM_NAME "_abi_nfd_pf%u_mbox"
41 #define NFP_MBOX_SYM_MIN_SIZE 16 /* When no data needed */
43 #define NFP_MBOX_CMD 0x00
44 #define NFP_MBOX_RET 0x04
45 #define NFP_MBOX_DATA_LEN 0x08
46 #define NFP_MBOX_RESERVED 0x0c
47 #define NFP_MBOX_DATA 0x10
50 * enum nfp_mbox_cmd - PF mailbox commands
52 * @NFP_MBOX_NO_CMD: null command
53 * Used to indicate previous command has finished.
55 * @NFP_MBOX_POOL_GET: get shared buffer pool info/config
56 * Input - struct nfp_shared_buf_pool_id
57 * Output - struct nfp_shared_buf_pool_info_get
59 * @NFP_MBOX_POOL_SET: set shared buffer pool info/config
60 * Input - struct nfp_shared_buf_pool_info_set
63 * @NFP_MBOX_PCIE_ABM_ENABLE: enable PCIe-side advanced buffer management
64 * Enable advanced buffer management of the PCIe block. If ABM is disabled
65 * PCIe block maintains a very short queue of buffers and does tail drop.
66 * ABM allows more advanced buffering and priority control.
70 * @NFP_MBOX_PCIE_ABM_DISABLE: disable PCIe-side advanced buffer management
75 NFP_MBOX_NO_CMD = 0x00,
77 NFP_MBOX_POOL_GET = 0x01,
78 NFP_MBOX_POOL_SET = 0x02,
80 NFP_MBOX_PCIE_ABM_ENABLE = 0x03,
81 NFP_MBOX_PCIE_ABM_DISABLE = 0x04,
84 #define NFP_SHARED_BUF_COUNT_SYM_NAME "_abi_nfd_pf%u_sb_cnt"
85 #define NFP_SHARED_BUF_TABLE_SYM_NAME "_abi_nfd_pf%u_sb_tbl"
88 * struct nfp_shared_buf - NFP shared buffer description
89 * @id: numerical user-visible id of the shared buffer
90 * @size: size in bytes of the buffer
91 * @ingress_pools_count: number of ingress pools
92 * @egress_pools_count: number of egress pools
93 * @ingress_tc_count: number of ingress trafic classes
94 * @egress_tc_count: number of egress trafic classes
95 * @pool_size_unit: pool size may be in credits, each credit is
96 * @pool_size_unit bytes
98 struct nfp_shared_buf {
101 __le16 ingress_pools_count;
102 __le16 egress_pools_count;
103 __le16 ingress_tc_count;
104 __le16 egress_tc_count;
106 __le32 pool_size_unit;
110 * struct nfp_shared_buf_pool_id - shared buffer pool identification
111 * @shared_buf: shared buffer id
114 struct nfp_shared_buf_pool_id {
120 * struct nfp_shared_buf_pool_info_get - struct devlink_sb_pool_info mirror
121 * @pool_type: one of enum devlink_sb_pool_type
122 * @size: pool size in units of SB's @pool_size_unit
123 * @threshold_type: one of enum devlink_sb_threshold_type
125 struct nfp_shared_buf_pool_info_get {
128 __le32 threshold_type;
132 * struct nfp_shared_buf_pool_info_set - packed args of sb_pool_set
133 * @id: pool identification info
134 * @size: pool size in units of SB's @pool_size_unit
135 * @threshold_type: one of enum devlink_sb_threshold_type
137 struct nfp_shared_buf_pool_info_set {
138 struct nfp_shared_buf_pool_id id;
140 __le32 threshold_type;