New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / net / fm10k / base / fm10k_pf.h
1 /*******************************************************************************
2
3 Copyright (c) 2013 - 2015, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9  1. Redistributions of source code must retain the above copyright notice,
10     this list of conditions and the following disclaimer.
11
12  2. Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in the
14     documentation and/or other materials provided with the distribution.
15
16  3. Neither the name of the Intel Corporation nor the names of its
17     contributors may be used to endorse or promote products derived from
18     this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32 ***************************************************************************/
33
34 #ifndef _FM10K_PF_H_
35 #define _FM10K_PF_H_
36
37 #include "fm10k_type.h"
38 #include "fm10k_common.h"
39
40 bool fm10k_glort_valid_pf(struct fm10k_hw *hw, u16 glort);
41 u16 fm10k_queues_per_pool(struct fm10k_hw *hw);
42 u16 fm10k_vf_queue_index(struct fm10k_hw *hw, u16 vf_idx);
43
44 enum fm10k_pf_tlv_msg_id_v1 {
45         FM10K_PF_MSG_ID_TEST                    = 0x000, /* msg ID reserved */
46         FM10K_PF_MSG_ID_XCAST_MODES             = 0x001,
47         FM10K_PF_MSG_ID_UPDATE_MAC_FWD_RULE     = 0x002,
48         FM10K_PF_MSG_ID_LPORT_MAP               = 0x100,
49         FM10K_PF_MSG_ID_LPORT_CREATE            = 0x200,
50         FM10K_PF_MSG_ID_LPORT_DELETE            = 0x201,
51         FM10K_PF_MSG_ID_CONFIG                  = 0x300,
52         FM10K_PF_MSG_ID_UPDATE_PVID             = 0x400,
53         FM10K_PF_MSG_ID_CREATE_FLOW_TABLE       = 0x501,
54         FM10K_PF_MSG_ID_DELETE_FLOW_TABLE       = 0x502,
55         FM10K_PF_MSG_ID_UPDATE_FLOW             = 0x503,
56         FM10K_PF_MSG_ID_DELETE_FLOW             = 0x504,
57         FM10K_PF_MSG_ID_SET_FLOW_STATE          = 0x505,
58         FM10K_PF_MSG_ID_GET_1588_INFO           = 0x506,
59         FM10K_PF_MSG_ID_1588_TIMESTAMP          = 0x701,
60         FM10K_PF_MSG_ID_1588_CLOCK_OWNER        = 0x702,
61         FM10K_PF_MSG_ID_MASTER_CLK_OFFSET       = 0x703,
62 };
63
64 enum fm10k_pf_tlv_attr_id_v1 {
65         FM10K_PF_ATTR_ID_ERR                    = 0x00,
66         FM10K_PF_ATTR_ID_LPORT_MAP              = 0x01,
67         FM10K_PF_ATTR_ID_XCAST_MODE             = 0x02,
68         FM10K_PF_ATTR_ID_MAC_UPDATE             = 0x03,
69         FM10K_PF_ATTR_ID_VLAN_UPDATE            = 0x04,
70         FM10K_PF_ATTR_ID_CONFIG                 = 0x05,
71         FM10K_PF_ATTR_ID_CREATE_FLOW_TABLE      = 0x06,
72         FM10K_PF_ATTR_ID_DELETE_FLOW_TABLE      = 0x07,
73         FM10K_PF_ATTR_ID_UPDATE_FLOW            = 0x08,
74         FM10K_PF_ATTR_ID_FLOW_STATE             = 0x09,
75         FM10K_PF_ATTR_ID_FLOW_HANDLE            = 0x0A,
76         FM10K_PF_ATTR_ID_DELETE_FLOW            = 0x0B,
77         FM10K_PF_ATTR_ID_PORT                   = 0x0C,
78         FM10K_PF_ATTR_ID_UPDATE_PVID            = 0x0D,
79         FM10K_PF_ATTR_ID_1588_TIMESTAMP         = 0x10,
80         FM10K_PF_ATTR_ID_1588_CLOCK_OWNER       = 0x12,
81         FM10K_PF_ATTR_ID_MASTER_CLK_OFFSET      = 0x14,
82 };
83
84 #define FM10K_MSG_LPORT_MAP_GLORT_SHIFT 0
85 #define FM10K_MSG_LPORT_MAP_GLORT_SIZE  16
86 #define FM10K_MSG_LPORT_MAP_MASK_SHIFT  16
87 #define FM10K_MSG_LPORT_MAP_MASK_SIZE   16
88
89 #define FM10K_MSG_UPDATE_PVID_GLORT_SHIFT       0
90 #define FM10K_MSG_UPDATE_PVID_GLORT_SIZE        16
91 #define FM10K_MSG_UPDATE_PVID_PVID_SHIFT        16
92 #define FM10K_MSG_UPDATE_PVID_PVID_SIZE         16
93
94 #define FM10K_MSG_ERR_PEP_NOT_SCHEDULED 280
95
96 /* The following data structures are overlayed directly onto TLV mailbox
97  * messages, and must not break 4 byte alignment. Ensure the structures line
98  * up correctly as per their TLV definition.
99  */
100 #ifdef C99
101 #pragma pack(push, 4)
102 #else
103 #pragma pack(4)
104 #endif /* C99 */
105
106 struct fm10k_mac_update {
107         __le32  mac_lower;
108         __le16  mac_upper;
109         __le16  vlan;
110         __le16  glort;
111         u8      flags;
112         u8      action;
113 };
114
115 struct fm10k_global_table_data {
116         __le32  used;
117         __le32  avail;
118 };
119
120 struct fm10k_swapi_error {
121         __le32                          status;
122         struct fm10k_global_table_data  mac;
123         struct fm10k_global_table_data  nexthop;
124         struct fm10k_global_table_data  ffu;
125 };
126
127 struct fm10k_swapi_1588_timestamp {
128         __le64 egress;
129         __le64 ingress;
130         __le16 dglort;
131         __le16 sglort;
132 };
133
134 struct fm10k_swapi_1588_clock_owner {
135         __le16 glort;
136         __le16 enabled;
137 };
138
139 #ifdef C99
140 #pragma pack(pop)
141 #else
142 #pragma pack()
143 #endif /* C99 */
144
145 s32 fm10k_msg_lport_map_pf(struct fm10k_hw *, u32 **, struct fm10k_mbx_info *);
146 extern const struct fm10k_tlv_attr fm10k_lport_map_msg_attr[];
147 #define FM10K_PF_MSG_LPORT_MAP_HANDLER(func) \
148         FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_LPORT_MAP, \
149                           fm10k_lport_map_msg_attr, func)
150 extern const struct fm10k_tlv_attr fm10k_update_pvid_msg_attr[];
151 #define FM10K_PF_MSG_UPDATE_PVID_HANDLER(func) \
152         FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_UPDATE_PVID, \
153                           fm10k_update_pvid_msg_attr, func)
154
155 s32 fm10k_msg_err_pf(struct fm10k_hw *, u32 **, struct fm10k_mbx_info *);
156 extern const struct fm10k_tlv_attr fm10k_err_msg_attr[];
157 #define FM10K_PF_MSG_ERR_HANDLER(msg, func) \
158         FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_##msg, fm10k_err_msg_attr, func)
159
160 extern const struct fm10k_tlv_attr fm10k_1588_timestamp_msg_attr[];
161 #define FM10K_PF_MSG_1588_TIMESTAMP_HANDLER(func) \
162         FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_1588_TIMESTAMP, \
163                           fm10k_1588_timestamp_msg_attr, func)
164
165 s32 fm10k_msg_1588_clock_owner_pf(struct fm10k_hw *, u32 **,
166                                   struct fm10k_mbx_info *);
167 extern const struct fm10k_tlv_attr fm10k_1588_clock_owner_attr[];
168 #define FM10K_PF_MSG_1588_CLOCK_OWNER_HANDLER(func) \
169         FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_1588_CLOCK_OWNER, \
170                           fm10k_1588_clock_owner_attr, func)
171
172 extern const struct fm10k_tlv_attr fm10k_master_clk_offset_attr[];
173 #define FM10K_PF_MSG_MASTER_CLK_OFFSET_HANDLER(func) \
174         FM10K_MSG_HANDLER(FM10K_PF_MSG_ID_MASTER_CLK_OFFSET, \
175                           fm10k_master_clk_offset_attr, func)
176
177 s32 fm10k_iov_msg_msix_pf(struct fm10k_hw *, u32 **, struct fm10k_mbx_info *);
178 s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *, u32 **,
179                               struct fm10k_mbx_info *);
180 s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *, u32 **,
181                                  struct fm10k_mbx_info *);
182 #ifndef NO_DEFAULT_SRIOV_MSG_HANDLERS
183 extern const struct fm10k_msg_data fm10k_iov_msg_data_pf[];
184 #endif
185
186 s32 fm10k_init_ops_pf(struct fm10k_hw *hw);
187 #endif /* _FM10K_PF_H */