1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *
9 *  1. Redistributions of source code must retain the above copyright
10 *     notice, this list of conditions and the following disclaimer.
11 *  2. Redistributions in binary form must reproduce the above copyright
12 *     notice, this list of conditions and the following disclaimer in the
13 *     documentation and/or other materials provided with the distribution.
14 *
15 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 *  POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $FreeBSD: stable/11/sys/dev/qlnx/qlnxe/ecore_sp_commands.h 337517 2018-08-09 01:17:35Z davidcs $
28 *
29 */
30
31
32#ifndef __ECORE_SP_COMMANDS_H__
33#define __ECORE_SP_COMMANDS_H__
34
35#include "ecore.h"
36#include "ecore_spq.h"
37#include "ecore_sp_api.h"
38
39#define ECORE_SP_EQ_COMPLETION  0x01
40#define ECORE_SP_CQE_COMPLETION 0x02
41
42struct ecore_sp_init_data {
43	/* The CID and FID aren't necessarily derived from hwfn,
44	 * e.g., in IOV scenarios. CID might defer between SPQ and
45	 * other elements.
46	 */
47	u32				cid;
48	u16				opaque_fid;
49
50	/* Information regarding operation upon sending & completion */
51	enum spq_mode			comp_mode;
52	struct ecore_spq_comp_cb	*p_comp_data;
53
54};
55
56/**
57 * @brief Acquire and initialize and SPQ entry for a given ramrod.
58 *
59 * @param p_hwfn
60 * @param pp_ent - will be filled with a pointer to an entry upon success
61 * @param cmd - dependent upon protocol
62 * @param protocol
63 * @param p_data - various configuration required for ramrod
64 *
65 * @return ECORE_SUCCESS upon success, otherwise failure.
66 */
67enum _ecore_status_t ecore_sp_init_request(struct ecore_hwfn *p_hwfn,
68					   struct ecore_spq_entry **pp_ent,
69					   u8 cmd,
70					   u8 protocol,
71					   struct ecore_sp_init_data *p_data);
72
73/**
74 * @brief ecore_sp_pf_start - PF Function Start Ramrod
75 *
76 * This ramrod is sent to initialize a physical function (PF). It will
77 * configure the function related parameters and write its completion to the
78 * event ring specified in the parameters.
79 *
80 * Ramrods complete on the common event ring for the PF. This ring is
81 * allocated by the driver on host memory and its parameters are written
82 * to the internal RAM of the UStorm by the Function Start Ramrod.
83 *
84 * @param p_hwfn
85 * @param p_ptt
86 * @param p_tunn - pf start tunneling configuration
87 * @param allow_npar_tx_switch - npar tx switching to be used
88 *	  for vports configured for tx-switching.
89 *
90 * @return enum _ecore_status_t
91 */
92
93enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
94				       struct ecore_ptt *p_ptt,
95				       struct ecore_tunnel_info *p_tunn,
96				       bool allow_npar_tx_switch);
97
98/**
99 * @brief ecore_sp_pf_update - PF Function Update Ramrod
100 *
101 * This ramrod updates function-related parameters. Every parameter can be
102 * updated independently, according to configuration flags.
103 *
104 * @note Final phase API.
105 *
106 * @param p_hwfn
107 *
108 * @return enum _ecore_status_t
109 */
110
111enum _ecore_status_t ecore_sp_pf_update_dcbx(struct ecore_hwfn *p_hwfn);
112
113/**
114 * @brief ecore_sp_pf_stop - PF Function Stop Ramrod
115 *
116 * This ramrod is sent to close a Physical Function (PF). It is the last ramrod
117 * sent and the last completion written to the PFs Event Ring. This ramrod also
118 * deletes the context for the Slowhwfn connection on this PF.
119 *
120 * @note Not required for first packet.
121 *
122 * @param p_hwfn
123 *
124 * @return enum _ecore_status_t
125 */
126
127enum _ecore_status_t ecore_sp_pf_stop(struct ecore_hwfn *p_hwfn);
128
129/**
130 * @brief ecore_sp_heartbeat_ramrod - Send empty Ramrod
131 *
132 * @param p_hwfn
133 *
134 * @return enum _ecore_status_t
135 */
136
137enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn);
138
139struct ecore_rl_update_params {
140	u8 qcn_update_param_flg;
141	u8 dcqcn_update_param_flg;
142	u8 rl_init_flg;
143	u8 rl_start_flg;
144	u8 rl_stop_flg;
145	u8 rl_id_first;
146	u8 rl_id_last;
147	u8 rl_dc_qcn_flg; /* If set, RL will used for DCQCN */
148	u32 rl_bc_rate; /* Byte Counter Limit */
149	u32 rl_max_rate; /* Maximum rate in Mbps resolution */
150	u32 rl_r_ai; /* Active increase rate */
151	u32 rl_r_hai; /* Hyper active increase rate */
152	u32 dcqcn_gd; /* DCQCN Alpha update gain */
153	u32 dcqcn_k_us; /* DCQCN Alpha update interval */
154	u32 dcqcn_timeuot_us;
155	u32 qcn_timeuot_us;
156};
157
158/**
159 * @brief ecore_sp_rl_update - Update rate limiters
160 *
161 * @param p_hwfn
162 * @param params
163 *
164 * @return enum _ecore_status_t
165 */
166enum _ecore_status_t ecore_sp_rl_update(struct ecore_hwfn *p_hwfn,
167					struct ecore_rl_update_params *params);
168
169/**
170 * @brief ecore_sp_pf_update_stag - PF STAG value update Ramrod
171 *
172 * @param p_hwfn
173 *
174 * @return enum _ecore_status_t
175 */
176
177enum _ecore_status_t ecore_sp_pf_update_stag(struct ecore_hwfn *p_hwfn);
178
179/**
180 * @brief ecore_sp_pf_update_ufp - PF ufp update Ramrod
181 *
182 * @param p_hwfn
183 *
184 * @return enum _ecore_status_t
185 */
186enum _ecore_status_t ecore_sp_pf_update_ufp(struct ecore_hwfn *p_hwfn);
187
188#endif /*__ECORE_SP_COMMANDS_H__*/
189