1/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2/* Copyright (C) 2018 Netronome Systems, Inc. */
3
4#ifndef __NFP_ABI__
5#define __NFP_ABI__ 1
6
7#include <linux/types.h>
8
9#define NFP_MBOX_SYM_NAME		"_abi_nfd_pf%u_mbox"
10#define NFP_MBOX_SYM_MIN_SIZE		16 /* When no data needed */
11
12#define NFP_MBOX_CMD		0x00
13#define NFP_MBOX_RET		0x04
14#define NFP_MBOX_DATA_LEN	0x08
15#define NFP_MBOX_RESERVED	0x0c
16#define NFP_MBOX_DATA		0x10
17
18/**
19 * enum nfp_mbox_cmd - PF mailbox commands
20 *
21 * @NFP_MBOX_NO_CMD:	null command
22 * Used to indicate previous command has finished.
23 *
24 * @NFP_MBOX_POOL_GET:	get shared buffer pool info/config
25 * Input  - struct nfp_shared_buf_pool_id
26 * Output - struct nfp_shared_buf_pool_info_get
27 *
28 * @NFP_MBOX_POOL_SET:	set shared buffer pool info/config
29 * Input  - struct nfp_shared_buf_pool_info_set
30 * Output - None
31 *
32 * @NFP_MBOX_PCIE_ABM_ENABLE:	enable PCIe-side advanced buffer management
33 * Enable advanced buffer management of the PCIe block.  If ABM is disabled
34 * PCIe block maintains a very short queue of buffers and does tail drop.
35 * ABM allows more advanced buffering and priority control.
36 * Input  - None
37 * Output - None
38 *
39 * @NFP_MBOX_PCIE_ABM_DISABLE:	disable PCIe-side advanced buffer management
40 * Input  - None
41 * Output - None
42 */
43enum nfp_mbox_cmd {
44	NFP_MBOX_NO_CMD			= 0x00,
45
46	NFP_MBOX_POOL_GET		= 0x01,
47	NFP_MBOX_POOL_SET		= 0x02,
48
49	NFP_MBOX_PCIE_ABM_ENABLE	= 0x03,
50	NFP_MBOX_PCIE_ABM_DISABLE	= 0x04,
51};
52
53#define NFP_SHARED_BUF_COUNT_SYM_NAME	"_abi_nfd_pf%u_sb_cnt"
54#define NFP_SHARED_BUF_TABLE_SYM_NAME	"_abi_nfd_pf%u_sb_tbl"
55
56/**
57 * struct nfp_shared_buf - NFP shared buffer description
58 * @id:				numerical user-visible id of the shared buffer
59 * @size:			size in bytes of the buffer
60 * @ingress_pools_count:	number of ingress pools
61 * @egress_pools_count:		number of egress pools
62 * @ingress_tc_count:		number of ingress trafic classes
63 * @egress_tc_count:		number of egress trafic classes
64 * @pool_size_unit:		pool size may be in credits, each credit is
65 *				@pool_size_unit bytes
66 */
67struct nfp_shared_buf {
68	__le32 id;
69	__le32 size;
70	__le16 ingress_pools_count;
71	__le16 egress_pools_count;
72	__le16 ingress_tc_count;
73	__le16 egress_tc_count;
74
75	__le32 pool_size_unit;
76};
77
78/**
79 * struct nfp_shared_buf_pool_id - shared buffer pool identification
80 * @shared_buf:		shared buffer id
81 * @pool:		pool index
82 */
83struct nfp_shared_buf_pool_id {
84	__le32 shared_buf;
85	__le32 pool;
86};
87
88/**
89 * struct nfp_shared_buf_pool_info_get - struct devlink_sb_pool_info mirror
90 * @pool_type:		one of enum devlink_sb_pool_type
91 * @size:		pool size in units of SB's @pool_size_unit
92 * @threshold_type:	one of enum devlink_sb_threshold_type
93 */
94struct nfp_shared_buf_pool_info_get {
95	__le32 pool_type;
96	__le32 size;
97	__le32 threshold_type;
98};
99
100/**
101 * struct nfp_shared_buf_pool_info_set - packed args of sb_pool_set
102 * @id:			pool identification info
103 * @size:		pool size in units of SB's @pool_size_unit
104 * @threshold_type:	one of enum devlink_sb_threshold_type
105 */
106struct nfp_shared_buf_pool_info_set {
107	struct nfp_shared_buf_pool_id id;
108	__le32 size;
109	__le32 threshold_type;
110};
111
112#endif
113