xref: /freebsd-src/sys/dev/mlx5/mlx5_en/port_buffer.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1c28ef249SHans Petter Selasky /*-
289c0b4faSHans Petter Selasky  * Copyright (c) 2018-2019 Mellanox Technologies. All rights reserved.
3c28ef249SHans Petter Selasky  *
4c28ef249SHans Petter Selasky  * Redistribution and use in source and binary forms, with or without
5c28ef249SHans Petter Selasky  * modification, are permitted provided that the following conditions
6c28ef249SHans Petter Selasky  * are met:
7c28ef249SHans Petter Selasky  * 1. Redistributions of source code must retain the above copyright
8c28ef249SHans Petter Selasky  *    notice, this list of conditions and the following disclaimer.
9c28ef249SHans Petter Selasky  * 2. Redistributions in binary form must reproduce the above copyright
10c28ef249SHans Petter Selasky  *    notice, this list of conditions and the following disclaimer in the
11c28ef249SHans Petter Selasky  *    documentation and/or other materials provided with the distribution.
12c28ef249SHans Petter Selasky  *
13c28ef249SHans Petter Selasky  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14c28ef249SHans Petter Selasky  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15c28ef249SHans Petter Selasky  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16c28ef249SHans Petter Selasky  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17c28ef249SHans Petter Selasky  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18c28ef249SHans Petter Selasky  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19c28ef249SHans Petter Selasky  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20c28ef249SHans Petter Selasky  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21c28ef249SHans Petter Selasky  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22c28ef249SHans Petter Selasky  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23c28ef249SHans Petter Selasky  * SUCH DAMAGE.
24c28ef249SHans Petter Selasky  */
25c28ef249SHans Petter Selasky 
26c28ef249SHans Petter Selasky #ifndef __MLX5_EN_PORT_BUFFER_H__
27c28ef249SHans Petter Selasky #define __MLX5_EN_PORT_BUFFER_H__
28c28ef249SHans Petter Selasky 
29*89918a23SKonstantin Belousov #include <dev/mlx5/mlx5_en/en.h>
30c28ef249SHans Petter Selasky #include <dev/mlx5/port.h>
31c28ef249SHans Petter Selasky 
32c28ef249SHans Petter Selasky #define MLX5E_MAX_BUFFER 8
33c28ef249SHans Petter Selasky #define MLX5E_BUFFER_CELL_SHIFT 7
34c28ef249SHans Petter Selasky #define MLX5E_DEFAULT_CABLE_LEN 7 /* 7 meters */
35c28ef249SHans Petter Selasky 
36c28ef249SHans Petter Selasky #define MLX5_BUFFER_SUPPORTED(mdev) (MLX5_CAP_GEN(mdev, pcam_reg) && \
37c28ef249SHans Petter Selasky 				     MLX5_CAP_PCAM_REG(mdev, pbmc) && \
38c28ef249SHans Petter Selasky 				     MLX5_CAP_PCAM_REG(mdev, pptb))
39c28ef249SHans Petter Selasky 
40c28ef249SHans Petter Selasky enum {
41c28ef249SHans Petter Selasky 	MLX5E_PORT_BUFFER_CABLE_LEN   = BIT(0),
42c28ef249SHans Petter Selasky 	MLX5E_PORT_BUFFER_PFC         = BIT(1),
43c28ef249SHans Petter Selasky 	MLX5E_PORT_BUFFER_PRIO2BUFFER = BIT(2),
44c28ef249SHans Petter Selasky 	MLX5E_PORT_BUFFER_SIZE        = BIT(3),
45c28ef249SHans Petter Selasky };
46c28ef249SHans Petter Selasky 
47c28ef249SHans Petter Selasky struct mlx5e_bufferx_reg {
48c28ef249SHans Petter Selasky 	u8   lossy;
49c28ef249SHans Petter Selasky 	u8   epsb;
50c28ef249SHans Petter Selasky 	u32  size;
51c28ef249SHans Petter Selasky 	u32  xoff;
52c28ef249SHans Petter Selasky 	u32  xon;
53c28ef249SHans Petter Selasky };
54c28ef249SHans Petter Selasky 
55c28ef249SHans Petter Selasky struct mlx5e_port_buffer {
56c28ef249SHans Petter Selasky 	u32                       port_buffer_size;
57c28ef249SHans Petter Selasky 	u32                       spare_buffer_size;
58c28ef249SHans Petter Selasky 	struct mlx5e_bufferx_reg  buffer[MLX5E_MAX_BUFFER];
59c28ef249SHans Petter Selasky };
60c28ef249SHans Petter Selasky 
61c28ef249SHans Petter Selasky #define	IEEE_8021QAZ_MAX_TCS	8
62c28ef249SHans Petter Selasky 
63c28ef249SHans Petter Selasky struct ieee_pfc {
64c28ef249SHans Petter Selasky 	__u8	pfc_cap;
65c28ef249SHans Petter Selasky 	__u8	pfc_en;
66c28ef249SHans Petter Selasky 	__u8	mbc;
67c28ef249SHans Petter Selasky 	__u16	delay;
68c28ef249SHans Petter Selasky 	__u64	requests[IEEE_8021QAZ_MAX_TCS];
69c28ef249SHans Petter Selasky 	__u64	indications[IEEE_8021QAZ_MAX_TCS];
70c28ef249SHans Petter Selasky };
71c28ef249SHans Petter Selasky 
72c28ef249SHans Petter Selasky int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
73c28ef249SHans Petter Selasky 				    u32 change, unsigned int mtu,
74c28ef249SHans Petter Selasky 				    struct ieee_pfc *pfc,
75c28ef249SHans Petter Selasky 				    u32 *buffer_size,
76c28ef249SHans Petter Selasky 				    u8 *prio2buffer);
77c28ef249SHans Petter Selasky 
78c28ef249SHans Petter Selasky int mlx5e_port_query_buffer(struct mlx5e_priv *priv,
79c28ef249SHans Petter Selasky 			    struct mlx5e_port_buffer *port_buffer);
80c28ef249SHans Petter Selasky #endif
81