Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation
3 : : */
4 : :
5 : : #include <rte_string_fns.h>
6 : : #include <rte_alarm.h>
7 : : #include <ethdev_pci.h>
8 : :
9 : : #include <ctype.h>
10 : : #include <fcntl.h>
11 : : #include <stdio.h>
12 : : #include <sys/types.h>
13 : : #include <sys/stat.h>
14 : : #include <unistd.h>
15 : : #include <math.h>
16 : :
17 : : #include <rte_tailq.h>
18 : : #include <rte_os_shim.h>
19 : :
20 : : #include "eal_firmware.h"
21 : :
22 : : #include "base/ice_sched.h"
23 : : #include "base/ice_flow.h"
24 : : #include "base/ice_dcb.h"
25 : : #include "base/ice_common.h"
26 : : #include "base/ice_ptp_hw.h"
27 : :
28 : : #include "ice_ethdev.h"
29 : : #include "ice_rxtx.h"
30 : : #include "ice_generic_flow.h"
31 : :
32 : : /* devargs */
33 : : #define ICE_SAFE_MODE_SUPPORT_ARG "safe-mode-support"
34 : : #define ICE_DEFAULT_MAC_DISABLE "default-mac-disable"
35 : : #define ICE_PROTO_XTR_ARG "proto_xtr"
36 : : #define ICE_FIELD_OFFS_ARG "field_offs"
37 : : #define ICE_FIELD_NAME_ARG "field_name"
38 : : #define ICE_HW_DEBUG_MASK_ARG "hw_debug_mask"
39 : : #define ICE_ONE_PPS_OUT_ARG "pps_out"
40 : : #define ICE_RX_LOW_LATENCY_ARG "rx_low_latency"
41 : : #define ICE_MBUF_CHECK_ARG "mbuf_check"
42 : : #define ICE_DDP_FILENAME_ARG "ddp_pkg_file"
43 : : #define ICE_DDP_LOAD_SCHED_ARG "ddp_load_sched_topo"
44 : : #define ICE_TM_LEVELS_ARG "tm_sched_levels"
45 : : #define ICE_RL_BURST_SIZE_ARG "rl_burst_size"
46 : : #define ICE_SOURCE_PRUNE_ARG "source-prune"
47 : : #define ICE_LINK_STATE_ON_CLOSE "link_state_on_close"
48 : :
49 : : #define ICE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
50 : :
51 : : static const char * const ice_valid_args[] = {
52 : : ICE_SAFE_MODE_SUPPORT_ARG,
53 : : ICE_PROTO_XTR_ARG,
54 : : ICE_FIELD_OFFS_ARG,
55 : : ICE_FIELD_NAME_ARG,
56 : : ICE_HW_DEBUG_MASK_ARG,
57 : : ICE_ONE_PPS_OUT_ARG,
58 : : ICE_RX_LOW_LATENCY_ARG,
59 : : ICE_DEFAULT_MAC_DISABLE,
60 : : ICE_MBUF_CHECK_ARG,
61 : : ICE_DDP_FILENAME_ARG,
62 : : ICE_DDP_LOAD_SCHED_ARG,
63 : : ICE_TM_LEVELS_ARG,
64 : : ICE_RL_BURST_SIZE_ARG,
65 : : ICE_SOURCE_PRUNE_ARG,
66 : : ICE_LINK_STATE_ON_CLOSE,
67 : : NULL
68 : : };
69 : :
70 : : #define PPS_OUT_DELAY_NS 1
71 : :
72 : : /* Maximum number of VSI */
73 : : #define ICE_MAX_NUM_VSIS (768UL)
74 : :
75 : : struct proto_xtr_ol_flag {
76 : : const struct rte_mbuf_dynflag param;
77 : : bool required;
78 : : };
79 : :
80 : : static bool ice_proto_xtr_hw_support[PROTO_XTR_MAX];
81 : :
82 : : static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
83 : : [PROTO_XTR_VLAN] = {
84 : : .param = { .name = "intel_pmd_dynflag_proto_xtr_vlan" }},
85 : : [PROTO_XTR_IPV4] = {
86 : : .param = { .name = "intel_pmd_dynflag_proto_xtr_ipv4" }},
87 : : [PROTO_XTR_IPV6] = {
88 : : .param = { .name = "intel_pmd_dynflag_proto_xtr_ipv6" }},
89 : : [PROTO_XTR_IPV6_FLOW] = {
90 : : .param = { .name = "intel_pmd_dynflag_proto_xtr_ipv6_flow" }},
91 : : [PROTO_XTR_TCP] = {
92 : : .param = { .name = "intel_pmd_dynflag_proto_xtr_tcp" }},
93 : : [PROTO_XTR_IP_OFFSET] = {
94 : : .param = { .name = "intel_pmd_dynflag_proto_xtr_ip_offset" }}
95 : : };
96 : :
97 : : enum ice_link_state_on_close {
98 : : ICE_LINK_DOWN,
99 : : ICE_LINK_UP,
100 : : ICE_LINK_INITIAL,
101 : : };
102 : :
103 : : #define ICE_OS_DEFAULT_PKG_NAME "ICE OS Default Package"
104 : : #define ICE_COMMS_PKG_NAME "ICE COMMS Package"
105 : : #define ICE_MAX_RES_DESC_NUM 1024
106 : :
107 : : #define ICE_MAC_E810_MAX_WATERMARK 143744U
108 : : #define ICE_MAC_E830_MAX_WATERMARK 259103U
109 : : #define ICE_MAC_TC_MAX_WATERMARK (((hw)->mac_type == ICE_MAC_E830) ? \
110 : : ICE_MAC_E830_MAX_WATERMARK : ICE_MAC_E810_MAX_WATERMARK)
111 : :
112 : : #define ICE_RSS_LUT_GLOBAL_QUEUE_NB 64
113 : :
114 : : /* Polling interval used when the interrupt path is unavailable */
115 : : #define ICE_AQ_ALARM_INTERVAL 50000 /* us */
116 : :
117 : : static int ice_dev_configure(struct rte_eth_dev *dev);
118 : : static void ice_aq_alarm_handler(void *param);
119 : : static int ice_dev_start(struct rte_eth_dev *dev);
120 : : static int ice_dev_stop(struct rte_eth_dev *dev);
121 : : static int ice_dev_close(struct rte_eth_dev *dev);
122 : : static int ice_dev_reset(struct rte_eth_dev *dev);
123 : : static int ice_dev_info_get(struct rte_eth_dev *dev,
124 : : struct rte_eth_dev_info *dev_info);
125 : : static int ice_phy_conf_link(struct ice_hw *hw,
126 : : u16 force_speed,
127 : : bool link_up,
128 : : bool link_autoneg);
129 : : static int ice_link_update(struct rte_eth_dev *dev,
130 : : int wait_to_complete);
131 : : static int ice_dev_set_link_up(struct rte_eth_dev *dev);
132 : : static int ice_dev_set_link_down(struct rte_eth_dev *dev);
133 : : static int ice_dev_led_on(struct rte_eth_dev *dev);
134 : : static int ice_dev_led_off(struct rte_eth_dev *dev);
135 : :
136 : : static int ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
137 : : static int ice_vlan_offload_set(struct rte_eth_dev *dev, int mask);
138 : : static int ice_rss_reta_update(struct rte_eth_dev *dev,
139 : : struct rte_eth_rss_reta_entry64 *reta_conf,
140 : : uint16_t reta_size);
141 : : static int ice_rss_reta_query(struct rte_eth_dev *dev,
142 : : struct rte_eth_rss_reta_entry64 *reta_conf,
143 : : uint16_t reta_size);
144 : : static int ice_rss_hash_update(struct rte_eth_dev *dev,
145 : : struct rte_eth_rss_conf *rss_conf);
146 : : static int ice_rss_hash_conf_get(struct rte_eth_dev *dev,
147 : : struct rte_eth_rss_conf *rss_conf);
148 : : static int ice_promisc_enable(struct rte_eth_dev *dev);
149 : : static int ice_promisc_disable(struct rte_eth_dev *dev);
150 : : static int ice_allmulti_enable(struct rte_eth_dev *dev);
151 : : static int ice_allmulti_disable(struct rte_eth_dev *dev);
152 : : static int ice_vlan_filter_set(struct rte_eth_dev *dev,
153 : : uint16_t vlan_id,
154 : : int on);
155 : : static int ice_macaddr_set(struct rte_eth_dev *dev,
156 : : struct rte_ether_addr *mac_addr);
157 : : static int ice_macaddr_add(struct rte_eth_dev *dev,
158 : : struct rte_ether_addr *mac_addr,
159 : : __rte_unused uint32_t index,
160 : : uint32_t pool);
161 : : static void ice_macaddr_remove(struct rte_eth_dev *dev, uint32_t index);
162 : : static int ice_rx_queue_intr_enable(struct rte_eth_dev *dev,
163 : : uint16_t queue_id);
164 : : static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
165 : : uint16_t queue_id);
166 : : static int ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
167 : : size_t fw_size);
168 : : static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
169 : : uint16_t pvid, int on);
170 : : static int ice_vlan_tpid_set(struct rte_eth_dev *dev,
171 : : enum rte_vlan_type vlan_type,
172 : : uint16_t tpid);
173 : : static int ice_get_eeprom_length(struct rte_eth_dev *dev);
174 : : static int ice_get_eeprom(struct rte_eth_dev *dev,
175 : : struct rte_dev_eeprom_info *eeprom);
176 : : static int ice_get_module_info(struct rte_eth_dev *dev,
177 : : struct rte_eth_dev_module_info *modinfo);
178 : : static int ice_get_module_eeprom(struct rte_eth_dev *dev,
179 : : struct rte_dev_eeprom_info *info);
180 : : static int ice_stats_get(struct rte_eth_dev *dev,
181 : : struct rte_eth_stats *stats, struct eth_queue_stats *qstats);
182 : : static int ice_stats_reset(struct rte_eth_dev *dev);
183 : : static int ice_xstats_get(struct rte_eth_dev *dev,
184 : : struct rte_eth_xstat *xstats, unsigned int n);
185 : : static int ice_xstats_get_names(struct rte_eth_dev *dev,
186 : : struct rte_eth_xstat_name *xstats_names,
187 : : unsigned int limit);
188 : : static int ice_dev_flow_ops_get(struct rte_eth_dev *dev,
189 : : const struct rte_flow_ops **ops);
190 : : static int ice_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
191 : : struct rte_eth_udp_tunnel *udp_tunnel);
192 : : static int ice_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
193 : : struct rte_eth_udp_tunnel *udp_tunnel);
194 : : static int ice_timesync_enable(struct rte_eth_dev *dev);
195 : : static int ice_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
196 : : struct timespec *timestamp,
197 : : uint32_t flags);
198 : : static int ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
199 : : struct timespec *timestamp);
200 : : static int ice_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
201 : : static int ice_timesync_adjust_freq(struct rte_eth_dev *dev, int64_t ppm);
202 : : static int ice_timesync_read_time(struct rte_eth_dev *dev,
203 : : struct timespec *timestamp);
204 : : static int ice_timesync_write_time(struct rte_eth_dev *dev,
205 : : const struct timespec *timestamp);
206 : : static int ice_timesync_disable(struct rte_eth_dev *dev);
207 : : static int ice_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
208 : : static int ice_fec_get_capability(struct rte_eth_dev *dev, struct rte_eth_fec_capa *speed_fec_capa,
209 : : unsigned int num);
210 : : static int ice_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa);
211 : : static int ice_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa);
212 : : static const uint32_t *ice_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev,
213 : : size_t *no_of_elements);
214 : : static int ice_get_dcb_info(struct rte_eth_dev *dev, struct rte_eth_dcb_info *dcb_info);
215 : : static void ice_set_dflt_mib(struct rte_eth_dev *dev);
216 : : static int ice_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
217 : : static int ice_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
218 : : static int ice_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf);
219 : : static int ice_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
220 : : uint32_t tx_rate);
221 : : static int ice_get_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
222 : : uint32_t *tx_rate);
223 : : static int ice_get_link_info_safe(struct ice_pf *pf, bool ena_lse,
224 : : struct ice_link_status *link);
225 : :
226 : : static const struct rte_pci_id pci_id_ice_map[] = {
227 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823L_BACKPLANE) },
228 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823L_SFP) },
229 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823L_10G_BASE_T) },
230 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823L_1GBE) },
231 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823L_QSFP) },
232 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_BACKPLANE) },
233 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_QSFP) },
234 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_SFP) },
235 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810_XXV_BACKPLANE) },
236 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810_XXV_QSFP) },
237 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810_XXV_SFP) },
238 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823C_BACKPLANE) },
239 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823C_QSFP) },
240 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823C_SFP) },
241 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823C_10G_BASE_T) },
242 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823C_SGMII) },
243 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822_SI_DFLT) },
244 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822C_BACKPLANE) },
245 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822C_QSFP) },
246 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822C_SFP) },
247 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822C_10G_BASE_T) },
248 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822C_SGMII) },
249 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822L_BACKPLANE) },
250 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822L_SFP) },
251 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822L_10G_BASE_T) },
252 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E822L_SGMII) },
253 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E824S) },
254 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_BACKPLANE) },
255 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_QSFP) },
256 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_SFP) },
257 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_C825X) },
258 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_SGMII) },
259 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_BACKPLANE) },
260 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_QSFP56) },
261 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_SFP) },
262 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830C_BACKPLANE) },
263 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_L_BACKPLANE) },
264 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830C_QSFP) },
265 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_L_QSFP) },
266 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830C_SFP) },
267 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_L_SFP) },
268 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_10G_BASE_T) },
269 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_BACKPLANE), },
270 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56), },
271 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP), },
272 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_BACKPLANE), },
273 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_QSFP), },
274 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_SFP), },
275 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_BACKPLANE), },
276 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_QSFP), },
277 : : { RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_SFP), },
278 : : { .vendor_id = 0, /* sentinel */ },
279 : : };
280 : :
281 : : static int
282 : 0 : ice_tm_ops_get(struct rte_eth_dev *dev __rte_unused,
283 : : void *arg)
284 : : {
285 [ # # ]: 0 : if (!arg)
286 : : return -EINVAL;
287 : :
288 : 0 : *(const void **)arg = &ice_tm_ops;
289 : :
290 : 0 : return 0;
291 : : }
292 : :
293 : : static const struct eth_dev_ops ice_eth_dev_ops = {
294 : : .dev_configure = ice_dev_configure,
295 : : .dev_start = ice_dev_start,
296 : : .dev_stop = ice_dev_stop,
297 : : .dev_close = ice_dev_close,
298 : : .dev_reset = ice_dev_reset,
299 : : .dev_set_link_up = ice_dev_set_link_up,
300 : : .dev_set_link_down = ice_dev_set_link_down,
301 : : .dev_led_on = ice_dev_led_on,
302 : : .dev_led_off = ice_dev_led_off,
303 : : .rx_queue_start = ice_rx_queue_start,
304 : : .rx_queue_stop = ice_rx_queue_stop,
305 : : .tx_queue_start = ice_tx_queue_start,
306 : : .tx_queue_stop = ice_tx_queue_stop,
307 : : .rx_queue_setup = ice_rx_queue_setup,
308 : : .rx_queue_release = ice_dev_rx_queue_release,
309 : : .tx_queue_setup = ice_tx_queue_setup,
310 : : .tx_queue_release = ice_dev_tx_queue_release,
311 : : .dev_infos_get = ice_dev_info_get,
312 : : .dev_supported_ptypes_get = ice_dev_supported_ptypes_get,
313 : : .link_update = ice_link_update,
314 : : .mtu_set = ice_mtu_set,
315 : : .mac_addr_set = ice_macaddr_set,
316 : : .mac_addr_add = ice_macaddr_add,
317 : : .mac_addr_remove = ice_macaddr_remove,
318 : : .vlan_filter_set = ice_vlan_filter_set,
319 : : .vlan_offload_set = ice_vlan_offload_set,
320 : : .reta_update = ice_rss_reta_update,
321 : : .reta_query = ice_rss_reta_query,
322 : : .rss_hash_update = ice_rss_hash_update,
323 : : .rss_hash_conf_get = ice_rss_hash_conf_get,
324 : : .promiscuous_enable = ice_promisc_enable,
325 : : .promiscuous_disable = ice_promisc_disable,
326 : : .allmulticast_enable = ice_allmulti_enable,
327 : : .allmulticast_disable = ice_allmulti_disable,
328 : : .rx_queue_intr_enable = ice_rx_queue_intr_enable,
329 : : .rx_queue_intr_disable = ice_rx_queue_intr_disable,
330 : : .fw_version_get = ice_fw_version_get,
331 : : .vlan_pvid_set = ice_vlan_pvid_set,
332 : : .vlan_tpid_set = ice_vlan_tpid_set,
333 : : .rxq_info_get = ice_rxq_info_get,
334 : : .txq_info_get = ice_txq_info_get,
335 : : .rx_burst_mode_get = ice_rx_burst_mode_get,
336 : : .tx_burst_mode_get = ice_tx_burst_mode_get,
337 : : .get_eeprom_length = ice_get_eeprom_length,
338 : : .get_eeprom = ice_get_eeprom,
339 : : .get_module_info = ice_get_module_info,
340 : : .get_module_eeprom = ice_get_module_eeprom,
341 : : .stats_get = ice_stats_get,
342 : : .stats_reset = ice_stats_reset,
343 : : .xstats_get = ice_xstats_get,
344 : : .xstats_get_names = ice_xstats_get_names,
345 : : .xstats_reset = ice_stats_reset,
346 : : .flow_ops_get = ice_dev_flow_ops_get,
347 : : .udp_tunnel_port_add = ice_dev_udp_tunnel_port_add,
348 : : .udp_tunnel_port_del = ice_dev_udp_tunnel_port_del,
349 : : .tx_done_cleanup = ice_tx_done_cleanup,
350 : : .get_monitor_addr = ice_get_monitor_addr,
351 : : .timesync_enable = ice_timesync_enable,
352 : : .timesync_read_rx_timestamp = ice_timesync_read_rx_timestamp,
353 : : .timesync_read_tx_timestamp = ice_timesync_read_tx_timestamp,
354 : : .timesync_adjust_time = ice_timesync_adjust_time,
355 : : .timesync_adjust_freq = ice_timesync_adjust_freq,
356 : : .timesync_read_time = ice_timesync_read_time,
357 : : .timesync_write_time = ice_timesync_write_time,
358 : : .timesync_disable = ice_timesync_disable,
359 : : .read_clock = ice_read_clock,
360 : : .tm_ops_get = ice_tm_ops_get,
361 : : .fec_get_capability = ice_fec_get_capability,
362 : : .fec_get = ice_fec_get,
363 : : .fec_set = ice_fec_set,
364 : : .buffer_split_supported_hdr_ptypes_get = ice_buffer_split_supported_hdr_ptypes_get,
365 : : .get_dcb_info = ice_get_dcb_info,
366 : : .flow_ctrl_get = ice_flow_ctrl_get,
367 : : .flow_ctrl_set = ice_flow_ctrl_set,
368 : : .priority_flow_ctrl_set = ice_priority_flow_ctrl_set,
369 : : .set_queue_rate_limit = ice_set_queue_rate_limit,
370 : : .get_queue_rate_limit = ice_get_queue_rate_limit,
371 : : };
372 : :
373 : : /* store statistics names and its offset in stats structure */
374 : : struct ice_xstats_name_off {
375 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
376 : : unsigned int offset;
377 : : };
378 : :
379 : : static const struct ice_xstats_name_off ice_stats_strings[] = {
380 : : {"rx_unicast_packets", offsetof(struct ice_eth_stats, rx_unicast)},
381 : : {"rx_multicast_packets", offsetof(struct ice_eth_stats, rx_multicast)},
382 : : {"rx_broadcast_packets", offsetof(struct ice_eth_stats, rx_broadcast)},
383 : : {"rx_dropped_packets", offsetof(struct ice_eth_stats, rx_discards)},
384 : : {"rx_unknown_protocol_packets", offsetof(struct ice_eth_stats,
385 : : rx_unknown_protocol)},
386 : : {"tx_unicast_packets", offsetof(struct ice_eth_stats, tx_unicast)},
387 : : {"tx_multicast_packets", offsetof(struct ice_eth_stats, tx_multicast)},
388 : : {"tx_broadcast_packets", offsetof(struct ice_eth_stats, tx_broadcast)},
389 : : {"tx_dropped_packets", offsetof(struct ice_eth_stats, tx_discards)},
390 : : };
391 : :
392 : : #define ICE_NB_ETH_XSTATS (sizeof(ice_stats_strings) / \
393 : : sizeof(ice_stats_strings[0]))
394 : :
395 : : static const struct ice_xstats_name_off ice_mbuf_strings[] = {
396 : : {"tx_mbuf_error_packets", offsetof(struct ice_mbuf_stats, tx_pkt_errors)},
397 : : };
398 : :
399 : : #define ICE_NB_MBUF_XSTATS (sizeof(ice_mbuf_strings) / sizeof(ice_mbuf_strings[0]))
400 : :
401 : : static const struct ice_xstats_name_off ice_temp_strings[] = {
402 : : {"chip_temperature_celsius", offsetof(struct ice_temp_stats, temp)},
403 : : {"chip_temperature_warning_celsius",
404 : : offsetof(struct ice_temp_stats, warning)},
405 : : {"chip_temperature_critical_celsius",
406 : : offsetof(struct ice_temp_stats, critical)},
407 : : {"chip_temperature_fatal_celsius",
408 : : offsetof(struct ice_temp_stats, fatal)},
409 : : };
410 : :
411 : : #define ICE_NB_TEMP_XSTATS RTE_DIM(ice_temp_strings)
412 : :
413 : : static const struct ice_xstats_name_off ice_hw_port_strings[] = {
414 : : {"tx_link_down_dropped", offsetof(struct ice_hw_port_stats,
415 : : tx_dropped_link_down)},
416 : : {"rx_crc_errors", offsetof(struct ice_hw_port_stats, crc_errors)},
417 : : {"rx_illegal_byte_errors", offsetof(struct ice_hw_port_stats,
418 : : illegal_bytes)},
419 : : {"rx_error_bytes", offsetof(struct ice_hw_port_stats, error_bytes)},
420 : : {"mac_local_errors", offsetof(struct ice_hw_port_stats,
421 : : mac_local_faults)},
422 : : {"mac_remote_errors", offsetof(struct ice_hw_port_stats,
423 : : mac_remote_faults)},
424 : : {"rx_len_errors", offsetof(struct ice_hw_port_stats,
425 : : rx_len_errors)},
426 : : {"tx_xon_packets", offsetof(struct ice_hw_port_stats, link_xon_tx)},
427 : : {"rx_xon_packets", offsetof(struct ice_hw_port_stats, link_xon_rx)},
428 : : {"tx_xoff_packets", offsetof(struct ice_hw_port_stats, link_xoff_tx)},
429 : : {"rx_xoff_packets", offsetof(struct ice_hw_port_stats, link_xoff_rx)},
430 : : {"priority_xon_rx_tc0", offsetof(struct ice_hw_port_stats, priority_xon_rx[0])},
431 : : {"priority_xon_rx_tc1", offsetof(struct ice_hw_port_stats, priority_xon_rx[1])},
432 : : {"priority_xon_rx_tc2", offsetof(struct ice_hw_port_stats, priority_xon_rx[2])},
433 : : {"priority_xon_rx_tc3", offsetof(struct ice_hw_port_stats, priority_xon_rx[3])},
434 : : {"priority_xon_rx_tc4", offsetof(struct ice_hw_port_stats, priority_xon_rx[4])},
435 : : {"priority_xon_rx_tc5", offsetof(struct ice_hw_port_stats, priority_xon_rx[5])},
436 : : {"priority_xon_rx_tc6", offsetof(struct ice_hw_port_stats, priority_xon_rx[6])},
437 : : {"priority_xon_rx_tc7", offsetof(struct ice_hw_port_stats, priority_xon_rx[7])},
438 : : {"priority_xoff_rx_tc0", offsetof(struct ice_hw_port_stats, priority_xoff_rx[0])},
439 : : {"priority_xoff_rx_tc1", offsetof(struct ice_hw_port_stats, priority_xoff_rx[1])},
440 : : {"priority_xoff_rx_tc2", offsetof(struct ice_hw_port_stats, priority_xoff_rx[2])},
441 : : {"priority_xoff_rx_tc3", offsetof(struct ice_hw_port_stats, priority_xoff_rx[3])},
442 : : {"priority_xoff_rx_tc4", offsetof(struct ice_hw_port_stats, priority_xoff_rx[4])},
443 : : {"priority_xoff_rx_tc5", offsetof(struct ice_hw_port_stats, priority_xoff_rx[5])},
444 : : {"priority_xoff_rx_tc6", offsetof(struct ice_hw_port_stats, priority_xoff_rx[6])},
445 : : {"priority_xoff_rx_tc7", offsetof(struct ice_hw_port_stats, priority_xoff_rx[7])},
446 : : {"priority_xon_tx_tc0", offsetof(struct ice_hw_port_stats, priority_xon_tx[0])},
447 : : {"priority_xon_tx_tc1", offsetof(struct ice_hw_port_stats, priority_xon_tx[1])},
448 : : {"priority_xon_tx_tc2", offsetof(struct ice_hw_port_stats, priority_xon_tx[2])},
449 : : {"priority_xon_tx_tc3", offsetof(struct ice_hw_port_stats, priority_xon_tx[3])},
450 : : {"priority_xon_tx_tc4", offsetof(struct ice_hw_port_stats, priority_xon_tx[4])},
451 : : {"priority_xon_tx_tc5", offsetof(struct ice_hw_port_stats, priority_xon_tx[5])},
452 : : {"priority_xon_tx_tc6", offsetof(struct ice_hw_port_stats, priority_xon_tx[6])},
453 : : {"priority_xon_tx_tc7", offsetof(struct ice_hw_port_stats, priority_xon_tx[7])},
454 : : {"priority_xoff_tx_tc0", offsetof(struct ice_hw_port_stats, priority_xoff_tx[0])},
455 : : {"priority_xoff_tx_tc1", offsetof(struct ice_hw_port_stats, priority_xoff_tx[1])},
456 : : {"priority_xoff_tx_tc2", offsetof(struct ice_hw_port_stats, priority_xoff_tx[2])},
457 : : {"priority_xoff_tx_tc3", offsetof(struct ice_hw_port_stats, priority_xoff_tx[3])},
458 : : {"priority_xoff_tx_tc4", offsetof(struct ice_hw_port_stats, priority_xoff_tx[4])},
459 : : {"priority_xoff_tx_tc5", offsetof(struct ice_hw_port_stats, priority_xoff_tx[5])},
460 : : {"priority_xoff_tx_tc6", offsetof(struct ice_hw_port_stats, priority_xoff_tx[6])},
461 : : {"priority_xoff_tx_tc7", offsetof(struct ice_hw_port_stats, priority_xoff_tx[7])},
462 : : {"priority_xon_2_xoff_tc0", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[0])},
463 : : {"priority_xon_2_xoff_tc1", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[1])},
464 : : {"priority_xon_2_xoff_tc2", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[2])},
465 : : {"priority_xon_2_xoff_tc3", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[3])},
466 : : {"priority_xon_2_xoff_tc4", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[4])},
467 : : {"priority_xon_2_xoff_tc5", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[5])},
468 : : {"priority_xon_2_xoff_tc6", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[6])},
469 : : {"priority_xon_2_xoff_tc7", offsetof(struct ice_hw_port_stats, priority_xon_2_xoff[7])},
470 : : {"rx_size_64_packets", offsetof(struct ice_hw_port_stats, rx_size_64)},
471 : : {"rx_size_65_to_127_packets", offsetof(struct ice_hw_port_stats,
472 : : rx_size_127)},
473 : : {"rx_size_128_to_255_packets", offsetof(struct ice_hw_port_stats,
474 : : rx_size_255)},
475 : : {"rx_size_256_to_511_packets", offsetof(struct ice_hw_port_stats,
476 : : rx_size_511)},
477 : : {"rx_size_512_to_1023_packets", offsetof(struct ice_hw_port_stats,
478 : : rx_size_1023)},
479 : : {"rx_size_1024_to_1522_packets", offsetof(struct ice_hw_port_stats,
480 : : rx_size_1522)},
481 : : {"rx_size_1523_to_max_packets", offsetof(struct ice_hw_port_stats,
482 : : rx_size_big)},
483 : : {"rx_undersized_errors", offsetof(struct ice_hw_port_stats,
484 : : rx_undersize)},
485 : : {"rx_oversize_errors", offsetof(struct ice_hw_port_stats,
486 : : rx_oversize)},
487 : : {"rx_mac_short_pkt_dropped", offsetof(struct ice_hw_port_stats,
488 : : mac_short_pkt_dropped)},
489 : : {"rx_fragmented_errors", offsetof(struct ice_hw_port_stats,
490 : : rx_fragments)},
491 : : {"rx_jabber_errors", offsetof(struct ice_hw_port_stats, rx_jabber)},
492 : : {"tx_size_64_packets", offsetof(struct ice_hw_port_stats, tx_size_64)},
493 : : {"tx_size_65_to_127_packets", offsetof(struct ice_hw_port_stats,
494 : : tx_size_127)},
495 : : {"tx_size_128_to_255_packets", offsetof(struct ice_hw_port_stats,
496 : : tx_size_255)},
497 : : {"tx_size_256_to_511_packets", offsetof(struct ice_hw_port_stats,
498 : : tx_size_511)},
499 : : {"tx_size_512_to_1023_packets", offsetof(struct ice_hw_port_stats,
500 : : tx_size_1023)},
501 : : {"tx_size_1024_to_1522_packets", offsetof(struct ice_hw_port_stats,
502 : : tx_size_1522)},
503 : : {"tx_size_1523_to_max_packets", offsetof(struct ice_hw_port_stats,
504 : : tx_size_big)},
505 : : };
506 : :
507 : : #define ICE_NB_HW_PORT_XSTATS (sizeof(ice_hw_port_strings) / \
508 : : sizeof(ice_hw_port_strings[0]))
509 : :
510 : : static void
511 : : ice_init_controlq_parameter(struct ice_hw *hw)
512 : : {
513 : : /* fields for adminq */
514 : 0 : hw->adminq.num_rq_entries = ICE_ADMINQ_LEN;
515 : 0 : hw->adminq.num_sq_entries = ICE_ADMINQ_LEN;
516 : 0 : hw->adminq.rq_buf_size = ICE_ADMINQ_BUF_SZ;
517 : 0 : hw->adminq.sq_buf_size = ICE_ADMINQ_BUF_SZ;
518 : :
519 : : /* fields for mailboxq, DPDK used as PF host */
520 : 0 : hw->mailboxq.num_rq_entries = ICE_MAILBOXQ_LEN;
521 : 0 : hw->mailboxq.num_sq_entries = ICE_MAILBOXQ_LEN;
522 : 0 : hw->mailboxq.rq_buf_size = ICE_MAILBOXQ_BUF_SZ;
523 : 0 : hw->mailboxq.sq_buf_size = ICE_MAILBOXQ_BUF_SZ;
524 : :
525 : : /* fields for sideband queue */
526 : 0 : hw->sbq.num_rq_entries = ICE_SBQ_LEN;
527 : 0 : hw->sbq.num_sq_entries = ICE_SBQ_LEN;
528 : 0 : hw->sbq.rq_buf_size = ICE_SBQ_MAX_BUF_LEN;
529 : 0 : hw->sbq.sq_buf_size = ICE_SBQ_MAX_BUF_LEN;
530 : :
531 : : }
532 : :
533 : : static int
534 : 0 : lookup_proto_xtr_type(const char *xtr_name)
535 : : {
536 : : static struct {
537 : : const char *name;
538 : : enum proto_xtr_type type;
539 : : } xtr_type_map[] = {
540 : : { "vlan", PROTO_XTR_VLAN },
541 : : { "ipv4", PROTO_XTR_IPV4 },
542 : : { "ipv6", PROTO_XTR_IPV6 },
543 : : { "ipv6_flow", PROTO_XTR_IPV6_FLOW },
544 : : { "tcp", PROTO_XTR_TCP },
545 : : { "ip_offset", PROTO_XTR_IP_OFFSET },
546 : : };
547 : : uint32_t i;
548 : :
549 [ # # ]: 0 : for (i = 0; i < RTE_DIM(xtr_type_map); i++) {
550 [ # # ]: 0 : if (strcmp(xtr_name, xtr_type_map[i].name) == 0)
551 : 0 : return xtr_type_map[i].type;
552 : : }
553 : :
554 : : return -1;
555 : : }
556 : :
557 : : /*
558 : : * Parse elem, the elem could be single number/range or '(' ')' group
559 : : * 1) A single number elem, it's just a simple digit. e.g. 9
560 : : * 2) A single range elem, two digits with a '-' between. e.g. 2-6
561 : : * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
562 : : * Within group elem, '-' used for a range separator;
563 : : * ',' used for a single number.
564 : : */
565 : : static int
566 : 0 : parse_queue_set(const char *input, int xtr_type, struct ice_devargs *devargs)
567 : : {
568 : : const char *str = input;
569 : 0 : char *end = NULL;
570 : : uint32_t min, max;
571 : : uint32_t idx;
572 : :
573 [ # # ]: 0 : while (isblank(*str))
574 : 0 : str++;
575 : :
576 [ # # # # ]: 0 : if (!isdigit(*str) && *str != '(')
577 : : return -1;
578 : :
579 : : /* process single number or single range of number */
580 [ # # ]: 0 : if (*str != '(') {
581 : 0 : errno = 0;
582 : 0 : idx = strtoul(str, &end, 10);
583 [ # # # # : 0 : if (errno || end == NULL || idx >= ICE_MAX_QUEUE_NUM)
# # ]
584 : : return -1;
585 : :
586 [ # # ]: 0 : while (isblank(*end))
587 : 0 : end++;
588 : :
589 : : min = idx;
590 : : max = idx;
591 : :
592 : : /* process single <number>-<number> */
593 [ # # ]: 0 : if (*end == '-') {
594 : 0 : end++;
595 [ # # ]: 0 : while (isblank(*end))
596 : 0 : end++;
597 [ # # ]: 0 : if (!isdigit(*end))
598 : : return -1;
599 : :
600 : 0 : errno = 0;
601 : 0 : idx = strtoul(end, &end, 10);
602 [ # # # # : 0 : if (errno || end == NULL || idx >= ICE_MAX_QUEUE_NUM)
# # ]
603 : : return -1;
604 : :
605 : : max = idx;
606 [ # # ]: 0 : while (isblank(*end))
607 : 0 : end++;
608 : : }
609 : :
610 [ # # ]: 0 : if (*end != ':')
611 : : return -1;
612 : :
613 : 0 : for (idx = RTE_MIN(min, max);
614 [ # # ]: 0 : idx <= RTE_MAX(min, max); idx++)
615 : 0 : devargs->proto_xtr[idx] = xtr_type;
616 : :
617 : : return 0;
618 : : }
619 : :
620 : : /* process set within bracket */
621 : 0 : str++;
622 [ # # ]: 0 : while (isblank(*str))
623 : 0 : str++;
624 [ # # ]: 0 : if (*str == '\0')
625 : : return -1;
626 : :
627 : : min = ICE_MAX_QUEUE_NUM;
628 : : do {
629 : : /* go ahead to the first digit */
630 [ # # ]: 0 : while (isblank(*str))
631 : 0 : str++;
632 [ # # ]: 0 : if (!isdigit(*str))
633 : : return -1;
634 : :
635 : : /* get the digit value */
636 : 0 : errno = 0;
637 : 0 : idx = strtoul(str, &end, 10);
638 [ # # # # : 0 : if (errno || end == NULL || idx >= ICE_MAX_QUEUE_NUM)
# # ]
639 : : return -1;
640 : :
641 : : /* go ahead to separator '-',',' and ')' */
642 [ # # ]: 0 : while (isblank(*end))
643 : 0 : end++;
644 [ # # ]: 0 : if (*end == '-') {
645 [ # # ]: 0 : if (min == ICE_MAX_QUEUE_NUM)
646 : : min = idx;
647 : : else /* avoid continuous '-' */
648 : : return -1;
649 [ # # ]: 0 : } else if (*end == ',' || *end == ')') {
650 : : max = idx;
651 [ # # ]: 0 : if (min == ICE_MAX_QUEUE_NUM)
652 : : min = idx;
653 : :
654 : 0 : for (idx = RTE_MIN(min, max);
655 [ # # ]: 0 : idx <= RTE_MAX(min, max); idx++)
656 : 0 : devargs->proto_xtr[idx] = xtr_type;
657 : :
658 : : min = ICE_MAX_QUEUE_NUM;
659 : : } else {
660 : : return -1;
661 : : }
662 : :
663 : 0 : str = end + 1;
664 [ # # ]: 0 : } while (*end != ')' && *end != '\0');
665 : :
666 : : return 0;
667 : : }
668 : :
669 : : static int
670 : 0 : parse_queue_proto_xtr(const char *queues, struct ice_devargs *devargs)
671 : : {
672 : : const char *queue_start;
673 : : uint32_t idx;
674 : : int xtr_type;
675 : : char xtr_name[32];
676 : :
677 [ # # ]: 0 : while (isblank(*queues))
678 : 0 : queues++;
679 : :
680 [ # # ]: 0 : if (*queues != '[') {
681 : 0 : xtr_type = lookup_proto_xtr_type(queues);
682 [ # # ]: 0 : if (xtr_type < 0)
683 : : return -1;
684 : :
685 : 0 : devargs->proto_xtr_dflt = xtr_type;
686 : :
687 : 0 : return 0;
688 : : }
689 : :
690 : 0 : queues++;
691 : : do {
692 [ # # ]: 0 : while (isblank(*queues))
693 : 0 : queues++;
694 [ # # ]: 0 : if (*queues == '\0')
695 : : return -1;
696 : :
697 : : queue_start = queues;
698 : :
699 : : /* go across a complete bracket */
700 [ # # ]: 0 : if (*queue_start == '(') {
701 : 0 : queues += strcspn(queues, ")");
702 [ # # ]: 0 : if (*queues != ')')
703 : : return -1;
704 : : }
705 : :
706 : : /* scan the separator ':' */
707 : 0 : queues += strcspn(queues, ":");
708 [ # # ]: 0 : if (*queues++ != ':')
709 : : return -1;
710 [ # # ]: 0 : while (isblank(*queues))
711 : 0 : queues++;
712 : :
713 : 0 : for (idx = 0; ; idx++) {
714 [ # # # # ]: 0 : if (isblank(queues[idx]) ||
715 [ # # ]: 0 : queues[idx] == ',' ||
716 [ # # ]: 0 : queues[idx] == ']' ||
717 : : queues[idx] == '\0')
718 : : break;
719 : :
720 [ # # ]: 0 : if (idx > sizeof(xtr_name) - 2)
721 : : return -1;
722 : :
723 : 0 : xtr_name[idx] = queues[idx];
724 : : }
725 : 0 : xtr_name[idx] = '\0';
726 : 0 : xtr_type = lookup_proto_xtr_type(xtr_name);
727 [ # # ]: 0 : if (xtr_type < 0)
728 : : return -1;
729 : :
730 : : queues += idx;
731 : :
732 [ # # # # : 0 : while (isblank(*queues) || *queues == ',' || *queues == ']')
# # ]
733 : 0 : queues++;
734 : :
735 [ # # ]: 0 : if (parse_queue_set(queue_start, xtr_type, devargs) < 0)
736 : : return -1;
737 [ # # ]: 0 : } while (*queues != '\0');
738 : :
739 : : return 0;
740 : : }
741 : :
742 : : static int
743 : 0 : handle_proto_xtr_arg(__rte_unused const char *key, const char *value,
744 : : void *extra_args)
745 : : {
746 : : struct ice_devargs *devargs = extra_args;
747 : :
748 [ # # ]: 0 : if (value == NULL || extra_args == NULL)
749 : : return -EINVAL;
750 : :
751 [ # # ]: 0 : if (parse_queue_proto_xtr(value, devargs) < 0) {
752 : 0 : PMD_DRV_LOG(ERR,
753 : : "The protocol extraction parameter is wrong : '%s'",
754 : : value);
755 : 0 : return -1;
756 : : }
757 : :
758 : : return 0;
759 : : }
760 : :
761 : : static int
762 : 0 : handle_field_offs_arg(__rte_unused const char *key, const char *value,
763 : : void *offs_args)
764 : : {
765 : : int *offset = offs_args;
766 : :
767 [ # # ]: 0 : if (value == NULL || offs_args == NULL)
768 : : return -EINVAL;
769 : :
770 [ # # ]: 0 : if (!isdigit(*value))
771 : : return -1;
772 : :
773 : 0 : *offset = atoi(value);
774 : :
775 : 0 : return 0;
776 : : }
777 : :
778 : : static int
779 : 0 : handle_field_name_arg(__rte_unused const char *key, const char *value,
780 : : void *name_args)
781 : : {
782 : : char *name = name_args;
783 : : int ret;
784 : :
785 [ # # ]: 0 : if (name == NULL || name_args == NULL)
786 : : return -EINVAL;
787 [ # # ]: 0 : if (isdigit(*value))
788 : : return -1;
789 : :
790 : : ret = strlcpy(name, value, RTE_MBUF_DYN_NAMESIZE);
791 [ # # ]: 0 : if (ret < 0 || ret >= RTE_MBUF_DYN_NAMESIZE) {
792 : 0 : PMD_DRV_LOG(ERR,
793 : : "The protocol extraction field name too long : '%s'",
794 : : name);
795 : 0 : return -1;
796 : : }
797 : : return 0;
798 : : }
799 : :
800 : : static int
801 : 0 : handle_ddp_filename_arg(__rte_unused const char *key, const char *value, void *name_args)
802 : : {
803 : : char **filename = name_args;
804 [ # # ]: 0 : if (strlen(value) >= ICE_MAX_PKG_FILENAME_SIZE) {
805 : 0 : PMD_DRV_LOG(ERR, "The DDP package filename is too long : '%s'", value);
806 : 0 : return -1;
807 : : }
808 : 0 : free(*filename);
809 : 0 : *filename = strdup(value);
810 : 0 : return 0;
811 : : }
812 : :
813 : : static void
814 : 0 : ice_check_proto_xtr_support(struct ice_hw *hw)
815 : : {
816 : : #define FLX_REG(val, fld, idx) \
817 : : (((val) & GLFLXP_RXDID_FLX_WRD_##idx##_##fld##_M) >> \
818 : : GLFLXP_RXDID_FLX_WRD_##idx##_##fld##_S)
819 : : static struct {
820 : : uint32_t rxdid;
821 : : uint8_t opcode;
822 : : uint8_t protid_0;
823 : : uint8_t protid_1;
824 : : } xtr_sets[] = {
825 : : [PROTO_XTR_VLAN] = { ICE_RXDID_COMMS_AUX_VLAN,
826 : : ICE_RX_OPC_EXTRACT,
827 : : ICE_PROT_EVLAN_O, ICE_PROT_VLAN_O},
828 : : [PROTO_XTR_IPV4] = { ICE_RXDID_COMMS_AUX_IPV4,
829 : : ICE_RX_OPC_EXTRACT,
830 : : ICE_PROT_IPV4_OF_OR_S,
831 : : ICE_PROT_IPV4_OF_OR_S },
832 : : [PROTO_XTR_IPV6] = { ICE_RXDID_COMMS_AUX_IPV6,
833 : : ICE_RX_OPC_EXTRACT,
834 : : ICE_PROT_IPV6_OF_OR_S,
835 : : ICE_PROT_IPV6_OF_OR_S },
836 : : [PROTO_XTR_IPV6_FLOW] = { ICE_RXDID_COMMS_AUX_IPV6_FLOW,
837 : : ICE_RX_OPC_EXTRACT,
838 : : ICE_PROT_IPV6_OF_OR_S,
839 : : ICE_PROT_IPV6_OF_OR_S },
840 : : [PROTO_XTR_TCP] = { ICE_RXDID_COMMS_AUX_TCP,
841 : : ICE_RX_OPC_EXTRACT,
842 : : ICE_PROT_TCP_IL, ICE_PROT_ID_INVAL },
843 : : [PROTO_XTR_IP_OFFSET] = { ICE_RXDID_COMMS_AUX_IP_OFFSET,
844 : : ICE_RX_OPC_PROTID,
845 : : ICE_PROT_IPV4_OF_OR_S,
846 : : ICE_PROT_IPV6_OF_OR_S },
847 : : };
848 : : uint32_t i;
849 : :
850 [ # # ]: 0 : for (i = 0; i < RTE_DIM(xtr_sets); i++) {
851 : 0 : uint32_t rxdid = xtr_sets[i].rxdid;
852 : : uint32_t v;
853 : :
854 [ # # ]: 0 : if (xtr_sets[i].protid_0 != ICE_PROT_ID_INVAL) {
855 : 0 : v = ICE_READ_REG(hw, GLFLXP_RXDID_FLX_WRD_4(rxdid));
856 : :
857 [ # # ]: 0 : if (FLX_REG(v, PROT_MDID, 4) == xtr_sets[i].protid_0 &&
858 [ # # ]: 0 : FLX_REG(v, RXDID_OPCODE, 4) == xtr_sets[i].opcode)
859 : 0 : ice_proto_xtr_hw_support[i] = true;
860 : : }
861 : :
862 [ # # ]: 0 : if (xtr_sets[i].protid_1 != ICE_PROT_ID_INVAL) {
863 : 0 : v = ICE_READ_REG(hw, GLFLXP_RXDID_FLX_WRD_5(rxdid));
864 : :
865 [ # # ]: 0 : if (FLX_REG(v, PROT_MDID, 5) == xtr_sets[i].protid_1 &&
866 [ # # ]: 0 : FLX_REG(v, RXDID_OPCODE, 5) == xtr_sets[i].opcode)
867 : 0 : ice_proto_xtr_hw_support[i] = true;
868 : : }
869 : : }
870 : 0 : }
871 : :
872 : : static int
873 : 0 : ice_res_pool_init(struct ice_res_pool_info *pool, uint32_t base,
874 : : uint32_t num)
875 : : {
876 : : struct pool_entry *entry;
877 : :
878 [ # # ]: 0 : if (!pool || !num)
879 : : return -EINVAL;
880 : :
881 : 0 : entry = rte_zmalloc(NULL, sizeof(*entry), 0);
882 [ # # ]: 0 : if (!entry) {
883 : 0 : PMD_INIT_LOG(ERR,
884 : : "Failed to allocate memory for resource pool");
885 : 0 : return -ENOMEM;
886 : : }
887 : :
888 : : /* queue heap initialize */
889 : 0 : pool->num_free = num;
890 : 0 : pool->num_alloc = 0;
891 : 0 : pool->base = base;
892 : 0 : LIST_INIT(&pool->alloc_list);
893 : : LIST_INIT(&pool->free_list);
894 : :
895 : : /* Initialize element */
896 : 0 : entry->base = 0;
897 : 0 : entry->len = num;
898 : :
899 : 0 : LIST_INSERT_HEAD(&pool->free_list, entry, next);
900 : 0 : return 0;
901 : : }
902 : :
903 : : static int
904 : 0 : ice_res_pool_alloc(struct ice_res_pool_info *pool,
905 : : uint16_t num)
906 : : {
907 : : struct pool_entry *entry, *valid_entry;
908 : :
909 [ # # ]: 0 : if (!pool || !num) {
910 : 0 : PMD_INIT_LOG(ERR, "Invalid parameter");
911 : 0 : return -EINVAL;
912 : : }
913 : :
914 [ # # ]: 0 : if (pool->num_free < num) {
915 : 0 : PMD_INIT_LOG(ERR, "No resource. ask:%u, available:%u",
916 : : num, pool->num_free);
917 : 0 : return -ENOMEM;
918 : : }
919 : :
920 : : valid_entry = NULL;
921 : : /* Lookup in free list and find most fit one */
922 [ # # ]: 0 : LIST_FOREACH(entry, &pool->free_list, next) {
923 [ # # ]: 0 : if (entry->len >= num) {
924 : : /* Find best one */
925 [ # # ]: 0 : if (entry->len == num) {
926 : : valid_entry = entry;
927 : : break;
928 : : }
929 [ # # ]: 0 : if (!valid_entry ||
930 [ # # ]: 0 : valid_entry->len > entry->len)
931 : : valid_entry = entry;
932 : : }
933 : : }
934 : :
935 : : /* Not find one to satisfy the request, return */
936 [ # # ]: 0 : if (!valid_entry) {
937 : 0 : PMD_INIT_LOG(ERR, "No valid entry found");
938 : 0 : return -ENOMEM;
939 : : }
940 : : /**
941 : : * The entry have equal queue number as requested,
942 : : * remove it from alloc_list.
943 : : */
944 [ # # ]: 0 : if (valid_entry->len == num) {
945 [ # # ]: 0 : LIST_REMOVE(valid_entry, next);
946 : : } else {
947 : : /**
948 : : * The entry have more numbers than requested,
949 : : * create a new entry for alloc_list and minus its
950 : : * queue base and number in free_list.
951 : : */
952 : 0 : entry = rte_zmalloc(NULL, sizeof(*entry), 0);
953 [ # # ]: 0 : if (!entry) {
954 : 0 : PMD_INIT_LOG(ERR,
955 : : "Failed to allocate memory for "
956 : : "resource pool");
957 : 0 : return -ENOMEM;
958 : : }
959 : 0 : entry->base = valid_entry->base;
960 : 0 : entry->len = num;
961 : 0 : valid_entry->base += num;
962 : 0 : valid_entry->len -= num;
963 : : valid_entry = entry;
964 : : }
965 : :
966 : : /* Insert it into alloc list, not sorted */
967 [ # # ]: 0 : LIST_INSERT_HEAD(&pool->alloc_list, valid_entry, next);
968 : :
969 : 0 : pool->num_free -= valid_entry->len;
970 : 0 : pool->num_alloc += valid_entry->len;
971 : :
972 : 0 : return valid_entry->base + pool->base;
973 : : }
974 : :
975 : : static void
976 : 0 : ice_res_pool_destroy(struct ice_res_pool_info *pool)
977 : : {
978 : : struct pool_entry *entry, *next_entry;
979 : :
980 [ # # ]: 0 : if (!pool)
981 : : return;
982 : :
983 [ # # ]: 0 : for (entry = LIST_FIRST(&pool->alloc_list); entry; entry = next_entry) {
984 : 0 : next_entry = LIST_NEXT(entry, next);
985 [ # # ]: 0 : LIST_REMOVE(entry, next);
986 : 0 : rte_free(entry);
987 : : }
988 : :
989 [ # # ]: 0 : for (entry = LIST_FIRST(&pool->free_list); entry; entry = next_entry) {
990 : 0 : next_entry = LIST_NEXT(entry, next);
991 [ # # ]: 0 : LIST_REMOVE(entry, next);
992 : 0 : rte_free(entry);
993 : : }
994 : :
995 : 0 : pool->num_free = 0;
996 : 0 : pool->num_alloc = 0;
997 : 0 : pool->base = 0;
998 : 0 : LIST_INIT(&pool->alloc_list);
999 : 0 : LIST_INIT(&pool->free_list);
1000 : : }
1001 : :
1002 : : static void
1003 : : ice_vsi_config_default_rss(struct ice_aqc_vsi_props *info)
1004 : : {
1005 : : /* Set VSI LUT selection */
1006 : : info->q_opt_rss = ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI &
1007 : : ICE_AQ_VSI_Q_OPT_RSS_LUT_M;
1008 : : /* Set Hash scheme */
1009 : : info->q_opt_rss |= ICE_AQ_VSI_Q_OPT_RSS_TPLZ &
1010 : : ICE_AQ_VSI_Q_OPT_RSS_HASH_M;
1011 : : /* enable TC */
1012 : 0 : info->q_opt_tc = ICE_AQ_VSI_Q_OPT_TC_OVR_M;
1013 : : }
1014 : :
1015 : : static int
1016 : 0 : ice_vsi_config_tc_queue_mapping(struct ice_hw *hw, struct ice_vsi *vsi,
1017 : : struct ice_aqc_vsi_props *info,
1018 : : uint8_t enabled_tcmap)
1019 : : {
1020 : : uint16_t fls, qp_idx;
1021 : :
1022 : : /* default tc 0 now. Multi-TC supporting need to be done later.
1023 : : * Configure TC and queue mapping parameters, for enabled TC,
1024 : : * allocate qpnum_per_tc queues to this traffic.
1025 : : */
1026 [ # # ]: 0 : if (enabled_tcmap != 0x01) {
1027 : 0 : PMD_INIT_LOG(ERR, "only TC0 is supported");
1028 : 0 : return -ENOTSUP;
1029 : : }
1030 : :
1031 : : /* vector 0 is reserved and 1 vector for ctrl vsi */
1032 [ # # ]: 0 : if (vsi->adapter->hw.func_caps.common_cap.num_msix_vectors < 2) {
1033 : 0 : vsi->nb_rxqs = 0;
1034 : : } else {
1035 : 0 : vsi->nb_rxqs = RTE_MIN(vsi->nb_rxqs, ICE_MAX_Q_PER_TC);
1036 : 0 : vsi->nb_rxqs = RTE_MIN(vsi->nb_rxqs,
1037 : : (uint16_t)vsi->adapter->hw.func_caps.common_cap.num_msix_vectors - 2);
1038 : :
1039 : : /* cap max QPs to what the HW reports as num-children for each layer.
1040 : : * Multiply num_children for each layer from the entry_point layer to
1041 : : * the qgroup, or second-last layer.
1042 : : * Avoid any potential overflow by using uint32_t type and breaking loop
1043 : : * once we have a number greater than the already configured max.
1044 : : */
1045 : : uint32_t max_sched_vsi_nodes = 1;
1046 [ # # ]: 0 : for (uint8_t i = hw->sw_entry_point_layer; i < hw->num_tx_sched_layers - 1; i++) {
1047 : 0 : max_sched_vsi_nodes *= hw->max_children[i];
1048 [ # # ]: 0 : if (max_sched_vsi_nodes >= vsi->nb_rxqs)
1049 : : break;
1050 : : }
1051 : 0 : vsi->nb_rxqs = RTE_MIN(vsi->nb_rxqs, max_sched_vsi_nodes);
1052 : : }
1053 : :
1054 : : /* nb_rxqs(hex) -> fls */
1055 : : /* 0000 -> 0 */
1056 : : /* 0001 -> 0 */
1057 : : /* 0002 -> 1 */
1058 : : /* 0003 ~ 0004 -> 2 */
1059 : : /* 0005 ~ 0008 -> 3 */
1060 : : /* 0009 ~ 0010 -> 4 */
1061 : : /* 0011 ~ 0020 -> 5 */
1062 : : /* 0021 ~ 0040 -> 6 */
1063 : : /* 0041 ~ 0080 -> 7 */
1064 : : /* 0081 ~ 0100 -> 8 */
1065 [ # # # # ]: 0 : fls = (vsi->nb_rxqs == 0) ? 0 : rte_fls_u32(vsi->nb_rxqs - 1);
1066 : :
1067 : : qp_idx = 0;
1068 : : /* Set tc and queue mapping with VSI */
1069 : 0 : info->tc_mapping[0] = rte_cpu_to_le_16((qp_idx <<
1070 : : ICE_AQ_VSI_TC_Q_OFFSET_S) |
1071 : : (fls << ICE_AQ_VSI_TC_Q_NUM_S));
1072 : :
1073 : : /* Associate queue number with VSI */
1074 : 0 : info->mapping_flags |= rte_cpu_to_le_16(ICE_AQ_VSI_Q_MAP_CONTIG);
1075 : 0 : info->q_mapping[0] = rte_cpu_to_le_16(vsi->base_queue);
1076 : 0 : info->q_mapping[1] = rte_cpu_to_le_16(vsi->nb_rxqs);
1077 : 0 : info->valid_sections |=
1078 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_RXQ_MAP_VALID);
1079 : : /* Set the info.ingress_table and info.egress_table
1080 : : * for UP translate table. Now just set it to 1:1 map by default
1081 : : * -- 0b 111 110 101 100 011 010 001 000 == 0xFAC688
1082 : : */
1083 : : #define ICE_TC_QUEUE_TABLE_DFLT 0x00FAC688
1084 : 0 : info->ingress_table = rte_cpu_to_le_32(ICE_TC_QUEUE_TABLE_DFLT);
1085 : 0 : info->egress_table = rte_cpu_to_le_32(ICE_TC_QUEUE_TABLE_DFLT);
1086 : 0 : info->outer_up_table = rte_cpu_to_le_32(ICE_TC_QUEUE_TABLE_DFLT);
1087 : 0 : return 0;
1088 : : }
1089 : :
1090 : : static int
1091 : 0 : ice_init_mac_address(struct rte_eth_dev *dev)
1092 : : {
1093 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1094 : 0 : struct ice_adapter *ad = (struct ice_adapter *)hw->back;
1095 : :
1096 [ # # ]: 0 : if (!rte_is_unicast_ether_addr
1097 [ # # ]: 0 : ((struct rte_ether_addr *)hw->port_info[0].mac.lan_addr)) {
1098 : 0 : PMD_INIT_LOG(ERR, "Invalid MAC address");
1099 : 0 : return -EINVAL;
1100 : : }
1101 : :
1102 : : rte_ether_addr_copy(
1103 : : (struct rte_ether_addr *)hw->port_info[0].mac.lan_addr,
1104 : : (struct rte_ether_addr *)hw->port_info[0].mac.perm_addr);
1105 : :
1106 : 0 : dev->data->mac_addrs =
1107 : 0 : rte_zmalloc(NULL, sizeof(struct rte_ether_addr) * ICE_NUM_MACADDR_MAX, 0);
1108 [ # # ]: 0 : if (!dev->data->mac_addrs) {
1109 : 0 : PMD_INIT_LOG(ERR,
1110 : : "Failed to allocate memory to store mac address");
1111 : 0 : return -ENOMEM;
1112 : : }
1113 : : /* store it to dev data */
1114 [ # # ]: 0 : if (!ad->devargs.default_mac_disable)
1115 : 0 : rte_ether_addr_copy((struct rte_ether_addr *)hw->port_info[0].mac.perm_addr,
1116 : : &dev->data->mac_addrs[0]);
1117 : : return 0;
1118 : : }
1119 : :
1120 : : /* Find out specific MAC filter */
1121 : : static struct ice_mac_filter *
1122 : : ice_find_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *macaddr)
1123 : : {
1124 : : struct ice_mac_filter *f;
1125 : :
1126 [ # # # # ]: 0 : TAILQ_FOREACH(f, &vsi->mac_list, next) {
1127 [ # # # # ]: 0 : if (rte_is_same_ether_addr(macaddr, &f->mac_info.mac_addr))
1128 : : return f;
1129 : : }
1130 : :
1131 : : return NULL;
1132 : : }
1133 : :
1134 : : static int
1135 : 0 : ice_add_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *mac_addr)
1136 : : {
1137 : : struct ice_fltr_list_entry *m_list_itr = NULL;
1138 : : struct ice_mac_filter *f;
1139 : : struct LIST_HEAD_TYPE list_head;
1140 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
1141 : 0 : struct ice_adapter *ad = (struct ice_adapter *)hw->back;
1142 : : int ret = 0;
1143 : :
1144 [ # # # # ]: 0 : if (ad->devargs.default_mac_disable && rte_is_same_ether_addr(mac_addr,
1145 [ # # ]: 0 : (struct rte_ether_addr *)hw->port_info[0].mac.perm_addr)) {
1146 : 0 : PMD_DRV_LOG(ERR, "This Default MAC filter is disabled.");
1147 : 0 : return 0;
1148 : : }
1149 : : /* If it's added and configured, return */
1150 : : f = ice_find_mac_filter(vsi, mac_addr);
1151 [ # # ]: 0 : if (f) {
1152 : 0 : PMD_DRV_LOG(INFO, "This MAC filter already exists.");
1153 : 0 : return 0;
1154 : : }
1155 : :
1156 : 0 : INIT_LIST_HEAD(&list_head);
1157 : :
1158 : : m_list_itr = (struct ice_fltr_list_entry *)
1159 : 0 : ice_malloc(hw, sizeof(*m_list_itr));
1160 [ # # ]: 0 : if (!m_list_itr) {
1161 : : ret = -ENOMEM;
1162 : 0 : goto DONE;
1163 : : }
1164 [ # # ]: 0 : ice_memcpy(m_list_itr->fltr_info.l_data.mac.mac_addr,
1165 : : mac_addr, ETH_ALEN, ICE_NONDMA_TO_NONDMA);
1166 : 0 : m_list_itr->fltr_info.src_id = ICE_SRC_ID_VSI;
1167 : 0 : m_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1168 : 0 : m_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_MAC;
1169 : 0 : m_list_itr->fltr_info.flag = ICE_FLTR_TX;
1170 : 0 : m_list_itr->fltr_info.vsi_handle = vsi->idx;
1171 : :
1172 [ # # ]: 0 : LIST_ADD(&m_list_itr->list_entry, &list_head);
1173 : :
1174 : : /* Add the mac */
1175 : 0 : ret = ice_add_mac(hw, &list_head);
1176 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1177 : 0 : PMD_DRV_LOG(ERR, "Failed to add MAC filter");
1178 : : ret = -EINVAL;
1179 : 0 : goto DONE;
1180 : : }
1181 : : /* Add the mac addr into mac list */
1182 : 0 : f = rte_zmalloc(NULL, sizeof(*f), 0);
1183 [ # # ]: 0 : if (!f) {
1184 : 0 : PMD_DRV_LOG(ERR, "failed to allocate memory");
1185 : : ret = -ENOMEM;
1186 : 0 : goto DONE;
1187 : : }
1188 : : rte_ether_addr_copy(mac_addr, &f->mac_info.mac_addr);
1189 : 0 : TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
1190 : 0 : vsi->mac_num++;
1191 : :
1192 : : ret = 0;
1193 : :
1194 : 0 : DONE:
1195 : 0 : ice_free(hw, m_list_itr);
1196 : 0 : return ret;
1197 : : }
1198 : :
1199 : : static int
1200 : 0 : ice_remove_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *mac_addr)
1201 : : {
1202 : : struct ice_fltr_list_entry *m_list_itr = NULL;
1203 : : struct ice_mac_filter *f;
1204 : : struct LIST_HEAD_TYPE list_head;
1205 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
1206 : : int ret = 0;
1207 : :
1208 : : /* Can't find it, return an error */
1209 : : f = ice_find_mac_filter(vsi, mac_addr);
1210 [ # # ]: 0 : if (!f)
1211 : : return -EINVAL;
1212 : :
1213 : 0 : INIT_LIST_HEAD(&list_head);
1214 : :
1215 : : m_list_itr = (struct ice_fltr_list_entry *)
1216 : 0 : ice_malloc(hw, sizeof(*m_list_itr));
1217 [ # # ]: 0 : if (!m_list_itr) {
1218 : : ret = -ENOMEM;
1219 : 0 : goto DONE;
1220 : : }
1221 [ # # ]: 0 : ice_memcpy(m_list_itr->fltr_info.l_data.mac.mac_addr,
1222 : : mac_addr, ETH_ALEN, ICE_NONDMA_TO_NONDMA);
1223 : 0 : m_list_itr->fltr_info.src_id = ICE_SRC_ID_VSI;
1224 : 0 : m_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1225 : 0 : m_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_MAC;
1226 : 0 : m_list_itr->fltr_info.flag = ICE_FLTR_TX;
1227 : 0 : m_list_itr->fltr_info.vsi_handle = vsi->idx;
1228 : :
1229 [ # # ]: 0 : LIST_ADD(&m_list_itr->list_entry, &list_head);
1230 : :
1231 : : /* remove the mac filter */
1232 : 0 : ret = ice_remove_mac(hw, &list_head);
1233 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1234 : 0 : PMD_DRV_LOG(ERR, "Failed to remove MAC filter");
1235 : : ret = -EINVAL;
1236 : 0 : goto DONE;
1237 : : }
1238 : :
1239 : : /* Remove the mac addr from mac list */
1240 [ # # ]: 0 : TAILQ_REMOVE(&vsi->mac_list, f, next);
1241 : 0 : rte_free(f);
1242 : 0 : vsi->mac_num--;
1243 : :
1244 : : ret = 0;
1245 : 0 : DONE:
1246 : 0 : ice_free(hw, m_list_itr);
1247 : 0 : return ret;
1248 : : }
1249 : :
1250 : : /* Find out specific VLAN filter */
1251 : : static struct ice_vlan_filter *
1252 : : ice_find_vlan_filter(struct ice_vsi *vsi, struct ice_vlan *vlan)
1253 : : {
1254 : : struct ice_vlan_filter *f;
1255 : :
1256 [ # # # # ]: 0 : TAILQ_FOREACH(f, &vsi->vlan_list, next) {
1257 [ # # # # ]: 0 : if (vlan->tpid == f->vlan_info.vlan.tpid &&
1258 [ # # # # ]: 0 : vlan->vid == f->vlan_info.vlan.vid)
1259 : : return f;
1260 : : }
1261 : :
1262 : : return NULL;
1263 : : }
1264 : :
1265 : : static int
1266 : 0 : ice_add_vlan_filter(struct ice_vsi *vsi, struct ice_vlan *vlan)
1267 : : {
1268 : : struct ice_fltr_list_entry *v_list_itr = NULL;
1269 : : struct ice_vlan_filter *f;
1270 : : struct LIST_HEAD_TYPE list_head;
1271 : : struct ice_hw *hw;
1272 : : int ret = 0;
1273 : :
1274 [ # # # # ]: 0 : if (!vsi || vlan->vid > RTE_ETHER_MAX_VLAN_ID)
1275 : : return -EINVAL;
1276 : :
1277 : 0 : hw = ICE_VSI_TO_HW(vsi);
1278 : :
1279 : : /* If it's added and configured, return. */
1280 : : f = ice_find_vlan_filter(vsi, vlan);
1281 [ # # ]: 0 : if (f) {
1282 : 0 : PMD_DRV_LOG(INFO, "This VLAN filter already exists.");
1283 : 0 : return 0;
1284 : : }
1285 : :
1286 [ # # ]: 0 : if (!vsi->vlan_anti_spoof_on && !vsi->vlan_filter_on)
1287 : : return 0;
1288 : :
1289 : 0 : INIT_LIST_HEAD(&list_head);
1290 : :
1291 : : v_list_itr = (struct ice_fltr_list_entry *)
1292 : 0 : ice_malloc(hw, sizeof(*v_list_itr));
1293 [ # # ]: 0 : if (!v_list_itr) {
1294 : : ret = -ENOMEM;
1295 : 0 : goto DONE;
1296 : : }
1297 : 0 : v_list_itr->fltr_info.l_data.vlan.vlan_id = vlan->vid;
1298 : 0 : v_list_itr->fltr_info.l_data.vlan.tpid = vlan->tpid;
1299 : 0 : v_list_itr->fltr_info.l_data.vlan.tpid_valid = true;
1300 : 0 : v_list_itr->fltr_info.src_id = ICE_SRC_ID_VSI;
1301 : 0 : v_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1302 : 0 : v_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_VLAN;
1303 : 0 : v_list_itr->fltr_info.flag = ICE_FLTR_TX;
1304 : 0 : v_list_itr->fltr_info.vsi_handle = vsi->idx;
1305 : :
1306 [ # # ]: 0 : LIST_ADD(&v_list_itr->list_entry, &list_head);
1307 : :
1308 : : /* Add the vlan */
1309 : 0 : ret = ice_add_vlan(hw, &list_head);
1310 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1311 : 0 : PMD_DRV_LOG(ERR, "Failed to add VLAN filter");
1312 : : ret = -EINVAL;
1313 : 0 : goto DONE;
1314 : : }
1315 : :
1316 : : /* Add vlan into vlan list */
1317 : 0 : f = rte_zmalloc(NULL, sizeof(*f), 0);
1318 [ # # ]: 0 : if (!f) {
1319 : 0 : PMD_DRV_LOG(ERR, "failed to allocate memory");
1320 : : ret = -ENOMEM;
1321 : 0 : goto DONE;
1322 : : }
1323 : 0 : f->vlan_info.vlan.tpid = vlan->tpid;
1324 : 0 : f->vlan_info.vlan.vid = vlan->vid;
1325 : 0 : TAILQ_INSERT_TAIL(&vsi->vlan_list, f, next);
1326 : 0 : vsi->vlan_num++;
1327 : :
1328 : : ret = 0;
1329 : :
1330 : 0 : DONE:
1331 : 0 : ice_free(hw, v_list_itr);
1332 : 0 : return ret;
1333 : : }
1334 : :
1335 : : static int
1336 : 0 : ice_remove_vlan_filter(struct ice_vsi *vsi, struct ice_vlan *vlan)
1337 : : {
1338 : : struct ice_fltr_list_entry *v_list_itr = NULL;
1339 : : struct ice_vlan_filter *f;
1340 : : struct LIST_HEAD_TYPE list_head;
1341 : : struct ice_hw *hw;
1342 : : int ret = 0;
1343 : :
1344 [ # # # # ]: 0 : if (!vsi || vlan->vid > RTE_ETHER_MAX_VLAN_ID)
1345 : : return -EINVAL;
1346 : :
1347 : 0 : hw = ICE_VSI_TO_HW(vsi);
1348 : :
1349 : : /* Can't find it, return an error */
1350 : : f = ice_find_vlan_filter(vsi, vlan);
1351 [ # # ]: 0 : if (!f)
1352 : : return -EINVAL;
1353 : :
1354 : 0 : INIT_LIST_HEAD(&list_head);
1355 : :
1356 : : v_list_itr = (struct ice_fltr_list_entry *)
1357 : 0 : ice_malloc(hw, sizeof(*v_list_itr));
1358 [ # # ]: 0 : if (!v_list_itr) {
1359 : : ret = -ENOMEM;
1360 : 0 : goto DONE;
1361 : : }
1362 : :
1363 : 0 : v_list_itr->fltr_info.l_data.vlan.vlan_id = vlan->vid;
1364 : 0 : v_list_itr->fltr_info.l_data.vlan.tpid = vlan->tpid;
1365 : 0 : v_list_itr->fltr_info.l_data.vlan.tpid_valid = true;
1366 : 0 : v_list_itr->fltr_info.src_id = ICE_SRC_ID_VSI;
1367 : 0 : v_list_itr->fltr_info.fltr_act = ICE_FWD_TO_VSI;
1368 : 0 : v_list_itr->fltr_info.lkup_type = ICE_SW_LKUP_VLAN;
1369 : 0 : v_list_itr->fltr_info.flag = ICE_FLTR_TX;
1370 : 0 : v_list_itr->fltr_info.vsi_handle = vsi->idx;
1371 : :
1372 [ # # ]: 0 : LIST_ADD(&v_list_itr->list_entry, &list_head);
1373 : :
1374 : : /* remove the vlan filter */
1375 : 0 : ret = ice_remove_vlan(hw, &list_head);
1376 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1377 : 0 : PMD_DRV_LOG(ERR, "Failed to remove VLAN filter");
1378 : : ret = -EINVAL;
1379 : 0 : goto DONE;
1380 : : }
1381 : :
1382 : : /* Remove the vlan id from vlan list */
1383 [ # # ]: 0 : TAILQ_REMOVE(&vsi->vlan_list, f, next);
1384 : 0 : rte_free(f);
1385 : 0 : vsi->vlan_num--;
1386 : :
1387 : : ret = 0;
1388 : 0 : DONE:
1389 : 0 : ice_free(hw, v_list_itr);
1390 : 0 : return ret;
1391 : : }
1392 : :
1393 : : static int
1394 : 0 : ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi)
1395 : : {
1396 : : struct ice_mac_filter *m_f;
1397 : : struct ice_vlan_filter *v_f;
1398 : : void *temp;
1399 : : int ret = 0;
1400 : :
1401 [ # # # # ]: 0 : if (!vsi || !vsi->mac_num)
1402 : : return -EINVAL;
1403 : :
1404 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(m_f, &vsi->mac_list, next, temp) {
1405 : 0 : ret = ice_remove_mac_filter(vsi, &m_f->mac_info.mac_addr);
1406 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1407 : : ret = -EINVAL;
1408 : 0 : goto DONE;
1409 : : }
1410 : : }
1411 : :
1412 [ # # ]: 0 : if (vsi->vlan_num == 0)
1413 : : return 0;
1414 : :
1415 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(v_f, &vsi->vlan_list, next, temp) {
1416 : 0 : ret = ice_remove_vlan_filter(vsi, &v_f->vlan_info.vlan);
1417 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1418 : : ret = -EINVAL;
1419 : 0 : goto DONE;
1420 : : }
1421 : : }
1422 : :
1423 : 0 : DONE:
1424 : : return ret;
1425 : : }
1426 : :
1427 : : /* Enable IRQ0 */
1428 : : static void
1429 : 0 : ice_pf_enable_irq0(struct ice_hw *hw)
1430 : : {
1431 : : /* reset the registers */
1432 : 0 : ICE_WRITE_REG(hw, PFINT_OICR_ENA, 0);
1433 : 0 : ICE_READ_REG(hw, PFINT_OICR);
1434 : :
1435 : : /* Enable all OICR causes except link-state-change: LSC is delivered
1436 : : * as an unsolicited AdminQ get-link-status notification.
1437 : : */
1438 : 0 : ICE_WRITE_REG(hw, PFINT_OICR_ENA,
1439 : : (uint32_t)(PFINT_OICR_ENA_INT_ENA_M &
1440 : : (~PFINT_OICR_LINK_STAT_CHANGE_M)));
1441 : :
1442 : 0 : ICE_WRITE_REG(hw, PFINT_OICR_CTL,
1443 : : (0 & PFINT_OICR_CTL_MSIX_INDX_M) |
1444 : : ((0 << PFINT_OICR_CTL_ITR_INDX_S) &
1445 : : PFINT_OICR_CTL_ITR_INDX_M) |
1446 : : PFINT_OICR_CTL_CAUSE_ENA_M);
1447 : :
1448 : 0 : ICE_WRITE_REG(hw, PFINT_FW_CTL,
1449 : : (0 & PFINT_FW_CTL_MSIX_INDX_M) |
1450 : : ((0 << PFINT_FW_CTL_ITR_INDX_S) &
1451 : : PFINT_FW_CTL_ITR_INDX_M) |
1452 : : PFINT_FW_CTL_CAUSE_ENA_M);
1453 : :
1454 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(0),
1455 : : GLINT_DYN_CTL_INTENA_M |
1456 : : GLINT_DYN_CTL_CLEARPBA_M |
1457 : : GLINT_DYN_CTL_ITR_INDX_M);
1458 : :
1459 : 0 : ice_flush(hw);
1460 : 0 : }
1461 : :
1462 : : /* Disable IRQ0 */
1463 : : static void
1464 : : ice_pf_disable_irq0(struct ice_hw *hw)
1465 : : {
1466 : : /* Disable all interrupt types */
1467 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(0), GLINT_DYN_CTL_WB_ON_ITR_M);
1468 : 0 : ice_flush(hw);
1469 : : }
1470 : :
1471 : : static void
1472 : 0 : ice_handle_aq_msg(struct rte_eth_dev *dev)
1473 : : {
1474 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1475 : 0 : struct ice_ctl_q_info *cq = &hw->adminq;
1476 : 0 : unsigned char buf[ICE_AQ_MAX_BUF_LEN] = {0};
1477 : 0 : struct ice_rq_event_info event = {
1478 : : .msg_buf = buf,
1479 : : .buf_len = sizeof(buf),
1480 : : };
1481 : : uint16_t pending, opcode;
1482 : : int ret;
1483 : :
1484 : 0 : pending = 1;
1485 [ # # ]: 0 : while (pending) {
1486 : 0 : ret = ice_clean_rq_elem(hw, cq, &event, &pending);
1487 : :
1488 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1489 [ # # ]: 0 : if (hw->adminq.sq_last_status != 0)
1490 : 0 : PMD_DRV_LOG(INFO, "Failed to read msg from AdminQ, adminq_err: %u",
1491 : : hw->adminq.sq_last_status);
1492 : : break;
1493 : : }
1494 : 0 : opcode = rte_le_to_cpu_16(event.desc.opcode);
1495 : :
1496 [ # # ]: 0 : switch (opcode) {
1497 : 0 : case ice_aqc_opc_get_link_status:
1498 : 0 : ret = ice_link_update(dev, 0);
1499 [ # # ]: 0 : if (!ret) {
1500 : : /* On link-up, reapply the default single-TC configuration. */
1501 [ # # ]: 0 : if ((hw->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP) &&
1502 [ # # ]: 0 : !(dev->data->dev_conf.rxmode.mq_mode &
1503 : : RTE_ETH_MQ_RX_DCB_FLAG))
1504 : 0 : ice_set_dflt_mib(dev);
1505 : :
1506 : 0 : rte_eth_dev_callback_process
1507 : : (dev, RTE_ETH_EVENT_INTR_LSC, NULL);
1508 : : }
1509 : : break;
1510 : 0 : default:
1511 : 0 : PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
1512 : : opcode);
1513 : 0 : break;
1514 : : }
1515 : : }
1516 : 0 : }
1517 : :
1518 : : /*
1519 : : * Alarm-based AdminQ polling handler that drains the AdminQ to process
1520 : : * async events, then re-arms itself.
1521 : : *
1522 : : * @param param
1523 : : * The address of parameter (struct rte_eth_dev *) registered before.
1524 : : *
1525 : : * @return
1526 : : * void
1527 : : */
1528 : : static void
1529 : 0 : ice_aq_alarm_handler(void *param)
1530 : : {
1531 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
1532 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1533 : :
1534 [ # # ]: 0 : if (!pf->adapter_stopped) {
1535 : 0 : ice_handle_aq_msg(dev);
1536 : 0 : rte_eal_alarm_set(ICE_AQ_ALARM_INTERVAL, ice_aq_alarm_handler, dev);
1537 : : }
1538 : 0 : }
1539 : :
1540 : : /**
1541 : : * Interrupt handler triggered by NIC for handling
1542 : : * specific interrupt.
1543 : : *
1544 : : * @param handle
1545 : : * Pointer to interrupt handle.
1546 : : * @param param
1547 : : * The address of parameter (struct rte_eth_dev *) registered before.
1548 : : *
1549 : : * @return
1550 : : * void
1551 : : */
1552 : : static void
1553 : 0 : ice_interrupt_handler(void *param)
1554 : : {
1555 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
1556 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1557 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
1558 : : uint32_t oicr;
1559 : : uint32_t reg;
1560 : : uint8_t pf_num;
1561 : : uint8_t event;
1562 : : uint16_t queue;
1563 : :
1564 : : /* Disable interrupt */
1565 : : ice_pf_disable_irq0(hw);
1566 : :
1567 : : /* read out interrupt causes */
1568 : 0 : oicr = ICE_READ_REG(hw, PFINT_OICR);
1569 : :
1570 : : /* No interrupt event indicated */
1571 [ # # ]: 0 : if (!(oicr & PFINT_OICR_INTEVENT_M)) {
1572 : 0 : PMD_DRV_LOG(INFO, "No interrupt event");
1573 : 0 : goto done;
1574 : : }
1575 : :
1576 : : /* Always drain the AdminQ on any misc interrupt. */
1577 : 0 : ice_handle_aq_msg(dev);
1578 : :
1579 [ # # ]: 0 : if (oicr & PFINT_OICR_MAL_DETECT_M) {
1580 : 0 : PMD_DRV_LOG(WARNING, "OICR: MDD event");
1581 : 0 : reg = ICE_READ_REG(hw, GL_MDET_TX_PQM);
1582 [ # # ]: 0 : if (reg & GL_MDET_TX_PQM_VALID_M) {
1583 : 0 : pf_num = (reg & GL_MDET_TX_PQM_PF_NUM_M) >>
1584 : : GL_MDET_TX_PQM_PF_NUM_S;
1585 : 0 : event = (reg & GL_MDET_TX_PQM_MAL_TYPE_M) >>
1586 : : GL_MDET_TX_PQM_MAL_TYPE_S;
1587 : 0 : queue = (reg & GL_MDET_TX_PQM_QNUM_M) >>
1588 : : GL_MDET_TX_PQM_QNUM_S;
1589 : :
1590 : 0 : PMD_DRV_LOG(WARNING, "Malicious Driver Detection event "
1591 : : "%d by PQM on TX queue %d PF# %d",
1592 : : event, queue, pf_num);
1593 : : }
1594 : :
1595 : 0 : reg = ICE_READ_REG(hw, GL_MDET_TX_TCLAN);
1596 [ # # ]: 0 : if (reg & GL_MDET_TX_TCLAN_VALID_M) {
1597 : 0 : pf_num = (reg & GL_MDET_TX_TCLAN_PF_NUM_M) >>
1598 : : GL_MDET_TX_TCLAN_PF_NUM_S;
1599 : 0 : event = (reg & GL_MDET_TX_TCLAN_MAL_TYPE_M) >>
1600 : : GL_MDET_TX_TCLAN_MAL_TYPE_S;
1601 : 0 : queue = (reg & GL_MDET_TX_TCLAN_QNUM_M) >>
1602 : : GL_MDET_TX_TCLAN_QNUM_S;
1603 : :
1604 : 0 : PMD_DRV_LOG(WARNING, "Malicious Driver Detection event "
1605 : : "%d by TCLAN on TX queue %d PF# %d",
1606 : : event, queue, pf_num);
1607 : : }
1608 : :
1609 : 0 : reg = ICE_READ_REG(hw, GL_MDET_TX_TDPU);
1610 [ # # ]: 0 : if (reg & GL_MDET_TX_TDPU_VALID_M) {
1611 : 0 : pf_num = (reg & GL_MDET_TX_TDPU_PF_NUM_M) >>
1612 : : GL_MDET_TX_TDPU_PF_NUM_S;
1613 : 0 : event = (reg & GL_MDET_TX_TDPU_MAL_TYPE_M) >>
1614 : : GL_MDET_TX_TDPU_MAL_TYPE_S;
1615 : 0 : queue = (reg & GL_MDET_TX_TDPU_QNUM_M) >>
1616 : : GL_MDET_TX_TDPU_QNUM_S;
1617 : :
1618 : 0 : PMD_DRV_LOG(WARNING, "Malicious Driver Detection event "
1619 : : "%d by TDPU on TX queue %d PF# %d",
1620 : : event, queue, pf_num);
1621 : : }
1622 : : }
1623 : 0 : done:
1624 : : /* Enable interrupt */
1625 : 0 : ice_pf_enable_irq0(hw);
1626 : 0 : rte_intr_ack(pci_dev->intr_handle);
1627 : :
1628 : : /* Re-drain AdminQ to catch events that arrived during the CLEARPBA window */
1629 : 0 : ice_handle_aq_msg(dev);
1630 : 0 : }
1631 : :
1632 : : static void
1633 : 0 : ice_init_proto_xtr(struct rte_eth_dev *dev)
1634 : : {
1635 : 0 : struct ice_adapter *ad =
1636 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1637 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1638 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
1639 : : const struct proto_xtr_ol_flag *ol_flag;
1640 : : bool proto_xtr_enable = false;
1641 : : int offset, field_offs;
1642 : : uint16_t i;
1643 : :
1644 : 0 : pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0);
1645 [ # # ]: 0 : if (unlikely(pf->proto_xtr == NULL)) {
1646 : 0 : PMD_DRV_LOG(ERR, "No memory for setting up protocol extraction table");
1647 : 0 : return;
1648 : : }
1649 : :
1650 [ # # ]: 0 : for (i = 0; i < pf->lan_nb_qps; i++) {
1651 [ # # ]: 0 : pf->proto_xtr[i] = ad->devargs.proto_xtr[i] != PROTO_XTR_NONE ?
1652 : : ad->devargs.proto_xtr[i] :
1653 : : ad->devargs.proto_xtr_dflt;
1654 : :
1655 [ # # ]: 0 : if (pf->proto_xtr[i] != PROTO_XTR_NONE) {
1656 : : uint8_t type = pf->proto_xtr[i];
1657 : :
1658 : 0 : ice_proto_xtr_ol_flag_params[type].required = true;
1659 : : proto_xtr_enable = true;
1660 : : }
1661 : : }
1662 : :
1663 [ # # ]: 0 : if (likely(!proto_xtr_enable)) {
1664 : 0 : ad->devargs.xtr_field_offs = -1;
1665 : 0 : return;
1666 : : }
1667 : :
1668 : 0 : ice_check_proto_xtr_support(hw);
1669 : :
1670 : : /*check mbuf dynfield*/
1671 : 0 : field_offs = rte_mbuf_dynfield_lookup(ad->devargs.xtr_field_name, NULL);
1672 [ # # ]: 0 : if (ad->devargs.xtr_field_offs == field_offs) {
1673 : 0 : PMD_DRV_LOG(DEBUG,
1674 : : "Protocol extraction metadata offset in mbuf is : %d",
1675 : : ad->devargs.xtr_field_offs);
1676 : : } else {
1677 : 0 : PMD_DRV_LOG(ERR, "Invalid field offset or name, no match dynfield, [%d],[%s]",
1678 : : ad->devargs.xtr_field_offs, ad->devargs.xtr_field_name);
1679 : 0 : ad->devargs.xtr_field_offs = -1;
1680 : 0 : return;
1681 : : }
1682 : :
1683 : 0 : PMD_DRV_LOG(DEBUG,
1684 : : "Protocol extraction metadata offset in mbuf is : %d",
1685 : : ad->devargs.xtr_field_offs);
1686 : :
1687 [ # # ]: 0 : for (i = 0; i < RTE_DIM(ice_proto_xtr_ol_flag_params); i++) {
1688 : 0 : ol_flag = &ice_proto_xtr_ol_flag_params[i];
1689 : :
1690 : 0 : ad->devargs.xtr_flag_offs[i] = 0xff;
1691 : :
1692 [ # # ]: 0 : if (!ol_flag->required)
1693 : 0 : continue;
1694 : :
1695 [ # # ]: 0 : if (!ice_proto_xtr_hw_support[i]) {
1696 : 0 : PMD_DRV_LOG(ERR,
1697 : : "Protocol extraction type %u is not supported in hardware",
1698 : : i);
1699 : 0 : ad->devargs.xtr_field_offs = -1;
1700 : 0 : break;
1701 : : }
1702 : :
1703 : 0 : offset = rte_mbuf_dynflag_register(&ol_flag->param);
1704 [ # # ]: 0 : if (unlikely(offset == -1)) {
1705 : 0 : PMD_DRV_LOG(ERR,
1706 : : "Protocol extraction offload '%s' failed to register with error %d",
1707 : : ol_flag->param.name, -rte_errno);
1708 : :
1709 : 0 : ad->devargs.xtr_field_offs = -1;
1710 : 0 : break;
1711 : : }
1712 : :
1713 : 0 : PMD_DRV_LOG(DEBUG,
1714 : : "Protocol extraction offload '%s' offset in mbuf is : %d",
1715 : : ol_flag->param.name, offset);
1716 : :
1717 : 0 : ad->devargs.xtr_flag_offs[i] = offset;
1718 : : }
1719 : : }
1720 : :
1721 : : /* Initialize SW parameters of PF */
1722 : : static int
1723 : 0 : ice_pf_sw_init(struct rte_eth_dev *dev)
1724 : : {
1725 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1726 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
1727 : :
1728 : 0 : pf->lan_nb_qp_max =
1729 : 0 : (uint16_t)RTE_MIN(hw->func_caps.common_cap.num_txq,
1730 : : hw->func_caps.common_cap.num_rxq);
1731 : :
1732 : 0 : pf->lan_nb_qps = pf->lan_nb_qp_max;
1733 : :
1734 : 0 : ice_init_proto_xtr(dev);
1735 : :
1736 [ # # ]: 0 : if (hw->func_caps.fd_fltr_guar > 0 ||
1737 [ # # ]: 0 : hw->func_caps.fd_fltr_best_effort > 0) {
1738 : 0 : pf->flags |= ICE_FLAG_FDIR;
1739 : 0 : pf->fdir_nb_qps = ICE_DEFAULT_QP_NUM_FDIR;
1740 : 0 : pf->lan_nb_qps = pf->lan_nb_qp_max - pf->fdir_nb_qps;
1741 : : } else {
1742 : 0 : pf->fdir_nb_qps = 0;
1743 : : }
1744 : 0 : pf->fdir_qp_offset = 0;
1745 : :
1746 : 0 : return 0;
1747 : : }
1748 : :
1749 : : struct ice_vsi *
1750 : 0 : ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
1751 : : {
1752 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
1753 : : struct ice_vsi *vsi = NULL;
1754 : : struct ice_vsi_ctx vsi_ctx;
1755 : : int ret;
1756 : 0 : struct rte_ether_addr broadcast = {
1757 : : .addr_bytes = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} };
1758 : : struct rte_ether_addr mac_addr;
1759 : 0 : uint16_t max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };
1760 : : uint8_t tc_bitmap = 0x1;
1761 : : uint16_t cfg;
1762 : 0 : struct ice_adapter *ad = (struct ice_adapter *)hw->back;
1763 : :
1764 : : /* hw->num_lports = 1 in NIC mode */
1765 : 0 : vsi = rte_zmalloc(NULL, sizeof(struct ice_vsi), 0);
1766 [ # # ]: 0 : if (!vsi)
1767 : : return NULL;
1768 : :
1769 : 0 : vsi->idx = pf->next_vsi_idx;
1770 : 0 : pf->next_vsi_idx++;
1771 : 0 : vsi->type = type;
1772 : 0 : vsi->adapter = ICE_PF_TO_ADAPTER(pf);
1773 : 0 : vsi->max_macaddrs = ICE_NUM_MACADDR_MAX;
1774 : 0 : vsi->vlan_anti_spoof_on = 0;
1775 : 0 : vsi->vlan_filter_on = 1;
1776 : 0 : TAILQ_INIT(&vsi->mac_list);
1777 : 0 : TAILQ_INIT(&vsi->vlan_list);
1778 : :
1779 : : /* Be sync with RTE_ETH_RSS_RETA_SIZE_x maximum value definition */
1780 : 0 : pf->hash_lut_size = hw->func_caps.common_cap.rss_table_size >
1781 : 0 : RTE_ETH_RSS_RETA_SIZE_512 ? RTE_ETH_RSS_RETA_SIZE_512 :
1782 : : hw->func_caps.common_cap.rss_table_size;
1783 : 0 : pf->flags |= ICE_FLAG_RSS_AQ_CAPABLE;
1784 : :
1785 : : /* Defines the type of outer tag expected */
1786 [ # # # ]: 0 : pf->outer_ethertype = RTE_ETHER_TYPE_VLAN;
1787 : :
1788 : : memset(&vsi_ctx, 0, sizeof(vsi_ctx));
1789 [ # # # ]: 0 : switch (type) {
1790 : 0 : case ICE_VSI_PF:
1791 : 0 : vsi->nb_rxqs = pf->lan_nb_qps;
1792 : 0 : vsi->base_queue = 1;
1793 : : ice_vsi_config_default_rss(&vsi_ctx.info);
1794 : 0 : vsi_ctx.alloc_from_pool = true;
1795 : 0 : vsi_ctx.flags = ICE_AQ_VSI_TYPE_PF;
1796 : : /* switch_id is queried by get_switch_config aq, which is done
1797 : : * by ice_init_hw
1798 : : */
1799 : 0 : vsi_ctx.info.sw_id = hw->port_info->sw_id;
1800 : : /* Source Prune */
1801 [ # # ]: 0 : if (!ad->devargs.source_prune) {
1802 : : /* Disable source prune to support VRRP
1803 : : * when source-prune devarg is not set
1804 : : */
1805 : : vsi_ctx.info.sw_flags =
1806 : : ICE_AQ_VSI_SW_FLAG_LOCAL_LB;
1807 : 0 : vsi_ctx.info.sw_flags |=
1808 : : ICE_AQ_VSI_SW_FLAG_SRC_PRUNE;
1809 : : }
1810 : : cfg = ICE_AQ_VSI_PROP_SW_VALID;
1811 : 0 : vsi_ctx.info.valid_sections |= rte_cpu_to_le_16(cfg);
1812 : 0 : vsi_ctx.info.sw_flags2 = ICE_AQ_VSI_SW_FLAG_LAN_ENA;
1813 : : /* Allow all untagged or tagged packets */
1814 : : vsi_ctx.info.inner_vlan_flags = ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL;
1815 : 0 : vsi_ctx.info.inner_vlan_flags |= ICE_AQ_VSI_INNER_VLAN_EMODE_NOTHING;
1816 : 0 : vsi_ctx.info.q_opt_rss = ICE_AQ_VSI_Q_OPT_RSS_LUT_PF |
1817 : : ICE_AQ_VSI_Q_OPT_RSS_TPLZ;
1818 [ # # ]: 0 : if (ice_is_dvm_ena(hw)) {
1819 : : vsi_ctx.info.outer_vlan_flags =
1820 : : (ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ALL <<
1821 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) &
1822 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M;
1823 : : vsi_ctx.info.outer_vlan_flags |=
1824 : : (ICE_AQ_VSI_OUTER_TAG_VLAN_8100 <<
1825 : : ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
1826 : : ICE_AQ_VSI_OUTER_TAG_TYPE_M;
1827 : 0 : vsi_ctx.info.outer_vlan_flags |=
1828 : : (ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING <<
1829 : : ICE_AQ_VSI_OUTER_VLAN_EMODE_S);
1830 : : }
1831 : :
1832 : : /* FDIR */
1833 : : cfg = ICE_AQ_VSI_PROP_SECURITY_VALID |
1834 : : ICE_AQ_VSI_PROP_FLOW_DIR_VALID;
1835 : 0 : vsi_ctx.info.valid_sections |= rte_cpu_to_le_16(cfg);
1836 : : cfg = ICE_AQ_VSI_FD_ENABLE;
1837 : 0 : vsi_ctx.info.fd_options = rte_cpu_to_le_16(cfg);
1838 : 0 : vsi_ctx.info.max_fd_fltr_dedicated =
1839 : 0 : rte_cpu_to_le_16(hw->func_caps.fd_fltr_guar);
1840 : 0 : vsi_ctx.info.max_fd_fltr_shared =
1841 : 0 : rte_cpu_to_le_16(hw->func_caps.fd_fltr_best_effort);
1842 : :
1843 : : /* Enable VLAN/UP trip */
1844 : 0 : ret = ice_vsi_config_tc_queue_mapping(hw, vsi,
1845 : : &vsi_ctx.info,
1846 : : ICE_DEFAULT_TCMAP);
1847 [ # # ]: 0 : if (ret) {
1848 : 0 : PMD_INIT_LOG(ERR,
1849 : : "tc queue mapping with vsi failed, "
1850 : : "err = %d",
1851 : : ret);
1852 : 0 : goto fail_mem;
1853 : : }
1854 : 0 : vsi->nb_txqs = vsi->nb_rxqs;
1855 : :
1856 : 0 : break;
1857 : 0 : case ICE_VSI_CTRL:
1858 : 0 : vsi->nb_rxqs = pf->fdir_nb_qps;
1859 : 0 : vsi->base_queue = ICE_FDIR_QUEUE_ID;
1860 : 0 : vsi_ctx.alloc_from_pool = true;
1861 : 0 : vsi_ctx.flags = ICE_AQ_VSI_TYPE_PF;
1862 : :
1863 : : cfg = ICE_AQ_VSI_PROP_FLOW_DIR_VALID;
1864 : 0 : vsi_ctx.info.valid_sections |= rte_cpu_to_le_16(cfg);
1865 : : cfg = ICE_AQ_VSI_FD_PROG_ENABLE;
1866 : 0 : vsi_ctx.info.fd_options = rte_cpu_to_le_16(cfg);
1867 : 0 : vsi_ctx.info.sw_id = hw->port_info->sw_id;
1868 : 0 : vsi_ctx.info.sw_flags2 = ICE_AQ_VSI_SW_FLAG_LAN_ENA;
1869 : 0 : ret = ice_vsi_config_tc_queue_mapping(hw, vsi,
1870 : : &vsi_ctx.info,
1871 : : ICE_DEFAULT_TCMAP);
1872 [ # # ]: 0 : if (ret) {
1873 : 0 : PMD_INIT_LOG(ERR,
1874 : : "tc queue mapping with vsi failed, "
1875 : : "err = %d",
1876 : : ret);
1877 : 0 : goto fail_mem;
1878 : : }
1879 : 0 : vsi->nb_txqs = vsi->nb_rxqs;
1880 : 0 : break;
1881 : 0 : default:
1882 : : /* for other types of VSI */
1883 : 0 : PMD_INIT_LOG(ERR, "other types of VSI not supported");
1884 : 0 : goto fail_mem;
1885 : : }
1886 : :
1887 : : /* VF has MSIX interrupt in VF range, don't allocate here */
1888 [ # # ]: 0 : if (type == ICE_VSI_PF) {
1889 : 0 : ret = ice_res_pool_alloc(&pf->msix_pool,
1890 : 0 : RTE_MIN(vsi->nb_rxqs,
1891 : : RTE_MAX_RXTX_INTR_VEC_ID));
1892 [ # # ]: 0 : if (ret < 0) {
1893 : 0 : PMD_INIT_LOG(ERR, "VSI MAIN %d get heap failed %d",
1894 : : vsi->vsi_id, ret);
1895 : : }
1896 : 0 : vsi->msix_intr = ret;
1897 : 0 : vsi->nb_msix = RTE_MIN(vsi->nb_rxqs, RTE_MAX_RXTX_INTR_VEC_ID);
1898 : : } else if (type == ICE_VSI_CTRL) {
1899 : 0 : ret = ice_res_pool_alloc(&pf->msix_pool, 1);
1900 [ # # ]: 0 : if (ret < 0) {
1901 : 0 : PMD_DRV_LOG(ERR, "VSI %d get heap failed %d",
1902 : : vsi->vsi_id, ret);
1903 : : }
1904 : 0 : vsi->msix_intr = ret;
1905 : 0 : vsi->nb_msix = 1;
1906 : : } else {
1907 : : vsi->msix_intr = 0;
1908 : : vsi->nb_msix = 0;
1909 : : }
1910 : 0 : ret = ice_add_vsi(hw, vsi->idx, &vsi_ctx, NULL);
1911 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
1912 : 0 : PMD_INIT_LOG(ERR, "add vsi failed, err = %d", ret);
1913 : 0 : goto fail_mem;
1914 : : }
1915 : : /* store vsi information is SW structure */
1916 : 0 : vsi->vsi_id = vsi_ctx.vsi_num;
1917 : 0 : vsi->info = vsi_ctx.info;
1918 : 0 : pf->vsis_allocated = vsi_ctx.vsis_allocd;
1919 : 0 : pf->vsis_unallocated = vsi_ctx.vsis_unallocated;
1920 : :
1921 [ # # ]: 0 : if (type == ICE_VSI_PF) {
1922 : : /* MAC configuration */
1923 : : rte_ether_addr_copy((struct rte_ether_addr *)
1924 : 0 : hw->port_info->mac.perm_addr,
1925 : : &pf->dev_addr);
1926 : :
1927 : : rte_ether_addr_copy(&pf->dev_addr, &mac_addr);
1928 : 0 : ret = ice_add_mac_filter(vsi, &mac_addr);
1929 [ # # ]: 0 : if (ret != ICE_SUCCESS)
1930 : 0 : PMD_INIT_LOG(ERR, "Failed to add dflt MAC filter");
1931 : :
1932 : : rte_ether_addr_copy(&broadcast, &mac_addr);
1933 : 0 : ret = ice_add_mac_filter(vsi, &mac_addr);
1934 [ # # ]: 0 : if (ret != ICE_SUCCESS)
1935 : 0 : PMD_INIT_LOG(ERR, "Failed to add MAC filter");
1936 : : }
1937 : :
1938 : : /* At the beginning, only TC0. */
1939 : 0 : max_txqs[0] = vsi->nb_txqs;
1940 : 0 : ret = ice_cfg_vsi_lan(hw->port_info, vsi->idx,
1941 : : tc_bitmap, max_txqs);
1942 [ # # ]: 0 : if (ret != ICE_SUCCESS)
1943 : 0 : PMD_INIT_LOG(ERR, "Failed to config vsi sched");
1944 : :
1945 : : return vsi;
1946 : 0 : fail_mem:
1947 : 0 : rte_free(vsi);
1948 : 0 : pf->next_vsi_idx--;
1949 : 0 : return NULL;
1950 : : }
1951 : :
1952 : : static int
1953 : 0 : ice_send_driver_ver(struct ice_hw *hw)
1954 : : {
1955 : : struct ice_driver_ver dv;
1956 : :
1957 : : /* we don't have driver version use 0 for dummy */
1958 : 0 : dv.major_ver = 0;
1959 : 0 : dv.minor_ver = 0;
1960 : 0 : dv.build_ver = 0;
1961 : 0 : dv.subbuild_ver = 0;
1962 : : strlcpy((char *)dv.driver_string, "dpdk", sizeof(dv.driver_string));
1963 : :
1964 : 0 : return ice_aq_send_driver_ver(hw, &dv, NULL);
1965 : : }
1966 : :
1967 : : static int
1968 : 0 : ice_pf_setup(struct ice_pf *pf)
1969 : : {
1970 : 0 : struct ice_adapter *ad = ICE_PF_TO_ADAPTER(pf);
1971 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
1972 : : struct ice_vsi *vsi;
1973 : : uint16_t unused;
1974 : :
1975 : : /* Clear all stats counters */
1976 : 0 : pf->offset_loaded = false;
1977 : 0 : memset(&pf->stats, 0, sizeof(struct ice_hw_port_stats));
1978 : 0 : memset(&pf->stats_offset, 0, sizeof(struct ice_hw_port_stats));
1979 : 0 : memset(&pf->internal_stats, 0, sizeof(struct ice_eth_stats));
1980 : 0 : memset(&pf->internal_stats_offset, 0, sizeof(struct ice_eth_stats));
1981 : :
1982 : : /* force guaranteed filter pool for PF */
1983 : 0 : ice_alloc_fd_guar_item(hw, &unused,
1984 : 0 : hw->func_caps.fd_fltr_guar);
1985 : : /* force shared filter pool for PF */
1986 : 0 : ice_alloc_fd_shrd_item(hw, &unused,
1987 : 0 : hw->func_caps.fd_fltr_best_effort);
1988 : :
1989 : 0 : vsi = ice_setup_vsi(pf, ICE_VSI_PF);
1990 [ # # ]: 0 : if (!vsi) {
1991 : 0 : PMD_INIT_LOG(ERR, "Failed to add vsi for PF");
1992 : 0 : return -EINVAL;
1993 : : }
1994 : :
1995 : : /* set the number of hidden Tx scheduler layers. If no devargs parameter to
1996 : : * set the number of exposed levels, the default is to expose all levels,
1997 : : * except the TC layer.
1998 : : *
1999 : : * If the number of exposed levels is set, we check that it's not greater
2000 : : * than the HW can provide (in which case we do nothing except log a warning),
2001 : : * and then set the hidden layers to be the total number of levels minus the
2002 : : * requested visible number.
2003 : : */
2004 : 0 : pf->tm_conf.hidden_layers = hw->port_info->has_tc;
2005 [ # # ]: 0 : if (ad->devargs.tm_exposed_levels != 0) {
2006 : 0 : const uint8_t avail_layers = hw->num_tx_sched_layers - hw->port_info->has_tc;
2007 : : const uint8_t req_layers = ad->devargs.tm_exposed_levels;
2008 [ # # ]: 0 : if (req_layers > avail_layers) {
2009 : 0 : PMD_INIT_LOG(WARNING, "The number of TM scheduler exposed levels exceeds the number of supported levels (%u)",
2010 : : avail_layers);
2011 : 0 : PMD_INIT_LOG(WARNING, "Setting scheduler layers to %u", avail_layers);
2012 : : } else {
2013 : 0 : pf->tm_conf.hidden_layers = hw->num_tx_sched_layers - req_layers;
2014 : : }
2015 : : }
2016 : :
2017 : 0 : pf->main_vsi = vsi;
2018 : : rte_spinlock_init(&pf->link_lock);
2019 : :
2020 : 0 : return 0;
2021 : : }
2022 : :
2023 : : static enum ice_pkg_type
2024 : 0 : ice_load_pkg_type(struct ice_hw *hw)
2025 : : {
2026 : : enum ice_pkg_type package_type;
2027 : :
2028 : : /* store the activated package type (OS default or Comms) */
2029 [ # # ]: 0 : if (!strncmp((char *)hw->active_pkg_name, ICE_OS_DEFAULT_PKG_NAME,
2030 : : ICE_PKG_NAME_SIZE))
2031 : : package_type = ICE_PKG_TYPE_OS_DEFAULT;
2032 [ # # ]: 0 : else if (!strncmp((char *)hw->active_pkg_name, ICE_COMMS_PKG_NAME,
2033 : : ICE_PKG_NAME_SIZE))
2034 : : package_type = ICE_PKG_TYPE_COMMS;
2035 : : else
2036 : : package_type = ICE_PKG_TYPE_UNKNOWN;
2037 : :
2038 [ # # ]: 0 : PMD_INIT_LOG(NOTICE, "Active package is: %d.%d.%d.%d, %s (%s VLAN mode)",
2039 : : hw->active_pkg_ver.major, hw->active_pkg_ver.minor,
2040 : : hw->active_pkg_ver.update, hw->active_pkg_ver.draft,
2041 : : hw->active_pkg_name,
2042 : : ice_is_dvm_ena(hw) ? "double" : "single");
2043 : :
2044 : 0 : return package_type;
2045 : : }
2046 : :
2047 : 0 : static int ice_read_customized_path(char *pkg_file, uint16_t buff_len)
2048 : : {
2049 : : int fp, n;
2050 : :
2051 : : fp = open(ICE_PKG_FILE_CUSTOMIZED_PATH, O_RDONLY);
2052 [ # # ]: 0 : if (fp < 0) {
2053 : 0 : PMD_INIT_LOG(INFO, "Failed to read CUSTOMIZED_PATH");
2054 : 0 : return -EIO;
2055 : : }
2056 : :
2057 [ # # ]: 0 : n = read(fp, pkg_file, buff_len - 1);
2058 [ # # ]: 0 : if (n > 0) {
2059 [ # # ]: 0 : if (pkg_file[n - 1] == '\n')
2060 : 0 : n--;
2061 : 0 : pkg_file[n] = '\0';
2062 : : }
2063 : :
2064 : 0 : close(fp);
2065 : 0 : return n;
2066 : : }
2067 : :
2068 : : static int
2069 : 0 : ice_firmware_read(const char *file, void *buf, size_t *bufsz)
2070 : : {
2071 : 0 : int ret = rte_firmware_read(file, buf, bufsz);
2072 : :
2073 [ # # ]: 0 : if (ret < 0)
2074 : 0 : PMD_INIT_LOG(DEBUG, "Cannot read DDP file %s", file);
2075 : :
2076 : 0 : return ret;
2077 : : }
2078 : :
2079 : 0 : int ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t dsn)
2080 : : {
2081 : 0 : struct ice_hw *hw = &adapter->hw;
2082 : : char pkg_file[ICE_MAX_PKG_FILENAME_SIZE];
2083 : : char customized_path[ICE_MAX_PKG_FILENAME_SIZE];
2084 : : char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE];
2085 : : void *buf;
2086 : : size_t bufsz;
2087 : : int err;
2088 : :
2089 : : /* first read any explicitly referenced DDP file*/
2090 [ # # ]: 0 : if (adapter->devargs.ddp_filename != NULL) {
2091 : : strlcpy(pkg_file, adapter->devargs.ddp_filename, sizeof(pkg_file));
2092 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) == 0) {
2093 : 0 : goto load_fw;
2094 : : } else {
2095 : 0 : PMD_INIT_LOG(ERR, "Cannot load DDP file: %s", pkg_file);
2096 : 0 : return -1;
2097 : : }
2098 : : }
2099 : :
2100 : : memset(opt_ddp_filename, 0, ICE_MAX_PKG_FILENAME_SIZE);
2101 : : snprintf(opt_ddp_filename, ICE_MAX_PKG_FILENAME_SIZE,
2102 : : "ice-%016" PRIx64 ".pkg", dsn);
2103 : :
2104 [ # # ]: 0 : if (ice_read_customized_path(customized_path, ICE_MAX_PKG_FILENAME_SIZE) > 0) {
2105 [ # # ]: 0 : if (use_dsn) {
2106 : : snprintf(pkg_file, RTE_DIM(pkg_file), "%s/%s",
2107 : : customized_path, opt_ddp_filename);
2108 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) == 0)
2109 : 0 : goto load_fw;
2110 : : }
2111 : : snprintf(pkg_file, RTE_DIM(pkg_file), "%s/%s", customized_path, "ice.pkg");
2112 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) == 0)
2113 : 0 : goto load_fw;
2114 : : }
2115 : :
2116 [ # # ]: 0 : if (!use_dsn)
2117 : 0 : goto no_dsn;
2118 : :
2119 : : strlcpy(pkg_file, ICE_PKG_FILE_SEARCH_PATH_UPDATES, ICE_MAX_PKG_FILENAME_SIZE);
2120 : 0 : strlcat(pkg_file, opt_ddp_filename, ICE_MAX_PKG_FILENAME_SIZE);
2121 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) == 0)
2122 : 0 : goto load_fw;
2123 : :
2124 : : strlcpy(pkg_file, ICE_PKG_FILE_SEARCH_PATH_DEFAULT, ICE_MAX_PKG_FILENAME_SIZE);
2125 : 0 : strlcat(pkg_file, opt_ddp_filename, ICE_MAX_PKG_FILENAME_SIZE);
2126 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) == 0)
2127 : 0 : goto load_fw;
2128 : :
2129 : 0 : no_dsn:
2130 : : strlcpy(pkg_file, ICE_PKG_FILE_UPDATES, ICE_MAX_PKG_FILENAME_SIZE);
2131 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) == 0)
2132 : 0 : goto load_fw;
2133 : :
2134 : : strlcpy(pkg_file, ICE_PKG_FILE_DEFAULT, ICE_MAX_PKG_FILENAME_SIZE);
2135 [ # # ]: 0 : if (ice_firmware_read(pkg_file, &buf, &bufsz) < 0) {
2136 : 0 : PMD_INIT_LOG(ERR, "Failed to load default DDP package " ICE_PKG_FILE_DEFAULT);
2137 : 0 : return -1;
2138 : : }
2139 : :
2140 : 0 : load_fw:
2141 : 0 : PMD_INIT_LOG(DEBUG, "DDP package name: %s", pkg_file);
2142 : :
2143 : 0 : err = ice_copy_and_init_pkg(hw, buf, bufsz, adapter->devargs.ddp_load_sched);
2144 [ # # ]: 0 : if (!ice_is_init_pkg_successful(err)) {
2145 : 0 : PMD_INIT_LOG(ERR, "Failed to load DDP package: %d", err);
2146 : 0 : free(buf);
2147 : 0 : return -1;
2148 : : }
2149 : :
2150 : : /* store the loaded pkg type info */
2151 : 0 : adapter->active_pkg_type = ice_load_pkg_type(hw);
2152 : :
2153 : 0 : free(buf);
2154 : 0 : return 0;
2155 : : }
2156 : :
2157 : : static void
2158 : 0 : ice_base_queue_get(struct ice_pf *pf)
2159 : : {
2160 : : uint32_t reg;
2161 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
2162 : :
2163 : 0 : reg = ICE_READ_REG(hw, PFLAN_RX_QALLOC);
2164 [ # # ]: 0 : if (reg & PFLAN_RX_QALLOC_VALID_M) {
2165 : 0 : pf->base_queue = reg & PFLAN_RX_QALLOC_FIRSTQ_M;
2166 : : } else {
2167 : 0 : PMD_INIT_LOG(WARNING, "Failed to get Rx base queue"
2168 : : " index");
2169 : : }
2170 : 0 : }
2171 : :
2172 : : static int
2173 : 0 : parse_bool(const char *key, const char *value, void *args)
2174 : : {
2175 : : bool *i = args;
2176 : :
2177 [ # # # # ]: 0 : if (value == NULL || value[0] == '\0') {
2178 : 0 : PMD_DRV_LOG(WARNING, "key:\"%s\", requires a value, which must be 0 or 1", key);
2179 : 0 : return -1;
2180 : : }
2181 [ # # # # ]: 0 : if (value[1] != '\0' || (value[0] != '0' && value[0] != '1')) {
2182 : 0 : PMD_DRV_LOG(WARNING, "invalid value:\"%s\" for key:\"%s\", value must be 0 or 1",
2183 : : value, key);
2184 : 0 : return -1;
2185 : : }
2186 : :
2187 : 0 : *i = (value[0] == '1');
2188 : 0 : return 0;
2189 : : }
2190 : :
2191 : : static int
2192 : 0 : parse_u64(const char *key, const char *value, void *args)
2193 : : {
2194 : : u64 *num = (u64 *)args;
2195 : : u64 tmp;
2196 : :
2197 : 0 : errno = 0;
2198 : 0 : tmp = strtoull(value, NULL, 16);
2199 [ # # ]: 0 : if (errno) {
2200 : 0 : PMD_DRV_LOG(WARNING, "%s: \"%s\" is not a valid u64",
2201 : : key, value);
2202 : 0 : return -1;
2203 : : }
2204 : :
2205 : 0 : *num = tmp;
2206 : :
2207 : 0 : return 0;
2208 : : }
2209 : :
2210 : : static int
2211 : 0 : parse_u32(const char *key, const char *value, void *args)
2212 : : {
2213 : : uint32_t *num = args;
2214 : : unsigned long tmp;
2215 : : char *endptr;
2216 : :
2217 : 0 : errno = 0;
2218 : 0 : tmp = strtoul(value, &endptr, 0);
2219 [ # # # # : 0 : if (errno != 0 || endptr == value || *endptr != '\0') {
# # ]
2220 : 0 : PMD_DRV_LOG(WARNING, "%s: \"%s\" is not a valid u32", key, value);
2221 : 0 : return -1;
2222 : : }
2223 [ # # ]: 0 : if (tmp > UINT32_MAX) {
2224 : 0 : PMD_DRV_LOG(WARNING, "%s: value \"%s\" is out of range", key, value);
2225 : 0 : return -1;
2226 : : }
2227 : :
2228 : 0 : *num = (uint32_t)tmp;
2229 : :
2230 : 0 : return 0;
2231 : : }
2232 : :
2233 : : static int
2234 : 0 : parse_tx_sched_levels(const char *key, const char *value, void *args)
2235 : : {
2236 : : uint8_t *num = args;
2237 : : long tmp;
2238 : : char *endptr;
2239 : :
2240 : 0 : errno = 0;
2241 : 0 : tmp = strtol(value, &endptr, 0);
2242 : : /* the value needs two stage validation, since the actual number of available
2243 : : * levels is not known at this point. Initially just validate that it is in
2244 : : * the correct range, between 3 and 8. Later validation will check that the
2245 : : * available layers on a particular port is higher than the value specified here.
2246 : : */
2247 [ # # # # ]: 0 : if (errno || *endptr != '\0' ||
2248 [ # # ]: 0 : tmp < (ICE_VSI_LAYER_OFFSET - 1) || tmp >= ICE_TM_MAX_LAYERS) {
2249 : 0 : PMD_DRV_LOG(WARNING, "%s: Invalid value \"%s\", should be in range [%d, %d]",
2250 : : key, value, ICE_VSI_LAYER_OFFSET - 1, ICE_TM_MAX_LAYERS - 1);
2251 : 0 : return -1;
2252 : : }
2253 : :
2254 : 0 : *num = tmp;
2255 : :
2256 : 0 : return 0;
2257 : : }
2258 : :
2259 : : static int
2260 : 0 : parse_link_state_on_close(const char *key, const char *value, void *args)
2261 : : {
2262 : : int *state = args, ret = 0;
2263 : :
2264 [ # # ]: 0 : if (value == NULL || state == NULL)
2265 : : return -EINVAL;
2266 : :
2267 [ # # ]: 0 : if (strcmp(value, "down") == 0) {
2268 : 0 : *state = ICE_LINK_DOWN;
2269 [ # # ]: 0 : } else if (strcmp(value, "up") == 0) {
2270 : 0 : *state = ICE_LINK_UP;
2271 [ # # ]: 0 : } else if (strcmp(value, "initial") == 0) {
2272 : 0 : *state = ICE_LINK_INITIAL;
2273 : : } else {
2274 : : ret = -EINVAL;
2275 : 0 : PMD_DRV_LOG(WARNING, "%s: Invalid value \"%s\", "
2276 : : "should be \"down\" \"up\" or \"initial\"", key, value);
2277 : : }
2278 : :
2279 : : return ret;
2280 : : }
2281 : :
2282 : : static int
2283 : : lookup_pps_type(const char *pps_name)
2284 : : {
2285 : : static struct {
2286 : : const char *name;
2287 : : enum pps_type type;
2288 : : } pps_type_map[] = {
2289 : : { "pin", PPS_PIN },
2290 : : };
2291 : :
2292 : : uint32_t i;
2293 : :
2294 : : for (i = 0; i < RTE_DIM(pps_type_map); i++) {
2295 : 0 : if (strcmp(pps_name, pps_type_map[i].name) == 0)
2296 : 0 : return pps_type_map[i].type;
2297 : : }
2298 : :
2299 : : return -1;
2300 : : }
2301 : :
2302 : : static int
2303 : 0 : parse_pin_set(const char *input, int pps_type, struct ice_devargs *devargs)
2304 : : {
2305 : : const char *str = input;
2306 : 0 : char *end = NULL;
2307 : : uint32_t idx;
2308 : :
2309 [ # # ]: 0 : while (isblank(*str))
2310 : 0 : str++;
2311 : :
2312 [ # # ]: 0 : if (!isdigit(*str))
2313 : : return -1;
2314 : :
2315 [ # # ]: 0 : if (pps_type == PPS_PIN) {
2316 : 0 : idx = strtoul(str, &end, 10);
2317 [ # # # # ]: 0 : if (end == NULL || idx >= ICE_MAX_PIN_NUM)
2318 : : return -1;
2319 [ # # ]: 0 : while (isblank(*end))
2320 : 0 : end++;
2321 [ # # ]: 0 : if (*end != ']')
2322 : : return -1;
2323 : :
2324 : 0 : devargs->pin_idx = idx;
2325 : 0 : devargs->pps_out_ena = 1;
2326 : :
2327 : 0 : return 0;
2328 : : }
2329 : :
2330 : : return -1;
2331 : : }
2332 : :
2333 : : static int
2334 : 0 : parse_pps_out_parameter(const char *pins, struct ice_devargs *devargs)
2335 : : {
2336 : : const char *pin_start;
2337 : : uint32_t idx;
2338 : : int pps_type;
2339 : : char pps_name[32];
2340 : :
2341 [ # # ]: 0 : while (isblank(*pins))
2342 : 0 : pins++;
2343 : :
2344 : 0 : pins++;
2345 [ # # ]: 0 : while (isblank(*pins))
2346 : 0 : pins++;
2347 [ # # ]: 0 : if (*pins == '\0')
2348 : : return -1;
2349 : :
2350 : 0 : for (idx = 0; ; idx++) {
2351 [ # # # # ]: 0 : if (isblank(pins[idx]) ||
2352 [ # # ]: 0 : pins[idx] == ':' ||
2353 : : pins[idx] == '\0')
2354 : : break;
2355 : :
2356 : 0 : pps_name[idx] = pins[idx];
2357 : : }
2358 [ # # ]: 0 : pps_name[idx] = '\0';
2359 : : pps_type = lookup_pps_type(pps_name);
2360 [ # # ]: 0 : if (pps_type < 0)
2361 : : return -1;
2362 : :
2363 : : pins += idx;
2364 : :
2365 : 0 : pins += strcspn(pins, ":");
2366 [ # # ]: 0 : if (*pins++ != ':')
2367 : : return -1;
2368 [ # # ]: 0 : while (isblank(*pins))
2369 : 0 : pins++;
2370 : :
2371 : : pin_start = pins;
2372 : :
2373 : : while (isblank(*pins))
2374 : : pins++;
2375 : :
2376 [ # # ]: 0 : if (parse_pin_set(pin_start, pps_type, devargs) < 0)
2377 : 0 : return -1;
2378 : :
2379 : : return 0;
2380 : : }
2381 : :
2382 : : static int
2383 : 0 : handle_pps_out_arg(__rte_unused const char *key, const char *value,
2384 : : void *extra_args)
2385 : : {
2386 : : struct ice_devargs *devargs = extra_args;
2387 : :
2388 [ # # ]: 0 : if (value == NULL || extra_args == NULL)
2389 : : return -EINVAL;
2390 : :
2391 [ # # ]: 0 : if (parse_pps_out_parameter(value, devargs) < 0) {
2392 : 0 : PMD_DRV_LOG(ERR,
2393 : : "The GPIO pin parameter is wrong : '%s'",
2394 : : value);
2395 : 0 : return -1;
2396 : : }
2397 : :
2398 : : return 0;
2399 : : }
2400 : :
2401 : : static int
2402 : 0 : ice_parse_mbuf_check(__rte_unused const char *key, const char *value, void *args)
2403 : : {
2404 : : char *cur;
2405 : : char *tmp;
2406 : : int str_len;
2407 : : int valid_len;
2408 : :
2409 : : int ret = 0;
2410 : : uint64_t *mc_flags = args;
2411 : 0 : char *str2 = strdup(value);
2412 [ # # ]: 0 : if (str2 == NULL)
2413 : : return -1;
2414 : :
2415 : 0 : str_len = strlen(str2);
2416 [ # # ]: 0 : if (str_len == 0) {
2417 : : ret = -1;
2418 : 0 : goto err_end;
2419 : : }
2420 : :
2421 : : /* Try stripping the outer square brackets of the parameter string. */
2422 : : str_len = strlen(str2);
2423 [ # # # # ]: 0 : if (str2[0] == '[' && str2[str_len - 1] == ']') {
2424 [ # # ]: 0 : if (str_len < 3) {
2425 : : ret = -1;
2426 : 0 : goto err_end;
2427 : : }
2428 : 0 : valid_len = str_len - 2;
2429 : 0 : memmove(str2, str2 + 1, valid_len);
2430 : 0 : memset(str2 + valid_len, '\0', 2);
2431 : : }
2432 : :
2433 : 0 : cur = strtok_r(str2, ",", &tmp);
2434 [ # # ]: 0 : while (cur != NULL) {
2435 [ # # ]: 0 : if (!strcmp(cur, "mbuf"))
2436 : 0 : *mc_flags |= ICE_MBUF_CHECK_F_TX_MBUF;
2437 [ # # ]: 0 : else if (!strcmp(cur, "size"))
2438 : 0 : *mc_flags |= ICE_MBUF_CHECK_F_TX_SIZE;
2439 [ # # ]: 0 : else if (!strcmp(cur, "segment"))
2440 : 0 : *mc_flags |= ICE_MBUF_CHECK_F_TX_SEGMENT;
2441 [ # # ]: 0 : else if (!strcmp(cur, "offload"))
2442 : 0 : *mc_flags |= ICE_MBUF_CHECK_F_TX_OFFLOAD;
2443 : : else
2444 : 0 : PMD_DRV_LOG(ERR, "Unsupported diagnostic type: %s", cur);
2445 : 0 : cur = strtok_r(NULL, ",", &tmp);
2446 : : }
2447 : :
2448 : 0 : err_end:
2449 : 0 : free(str2);
2450 : 0 : return ret;
2451 : : }
2452 : :
2453 : 0 : static int ice_parse_devargs(struct rte_eth_dev *dev)
2454 : : {
2455 : 0 : struct ice_adapter *ad =
2456 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2457 : 0 : struct rte_devargs *devargs = dev->device->devargs;
2458 : : struct rte_kvargs *kvlist;
2459 : : int ret;
2460 : :
2461 [ # # ]: 0 : if (devargs == NULL)
2462 : : return 0;
2463 : :
2464 : 0 : kvlist = rte_kvargs_parse(devargs->args, ice_valid_args);
2465 [ # # ]: 0 : if (kvlist == NULL) {
2466 : 0 : PMD_INIT_LOG(ERR, "Invalid kvargs key");
2467 : 0 : return -EINVAL;
2468 : : }
2469 : :
2470 : 0 : ad->devargs.proto_xtr_dflt = PROTO_XTR_NONE;
2471 : 0 : memset(ad->devargs.proto_xtr, PROTO_XTR_NONE,
2472 : : sizeof(ad->devargs.proto_xtr));
2473 : :
2474 : 0 : ret = rte_kvargs_process(kvlist, ICE_PROTO_XTR_ARG,
2475 : 0 : &handle_proto_xtr_arg, &ad->devargs);
2476 [ # # ]: 0 : if (ret)
2477 : 0 : goto bail;
2478 : :
2479 : 0 : ret = rte_kvargs_process(kvlist, ICE_FIELD_OFFS_ARG,
2480 : 0 : &handle_field_offs_arg, &ad->devargs.xtr_field_offs);
2481 [ # # ]: 0 : if (ret)
2482 : 0 : goto bail;
2483 : :
2484 : 0 : ret = rte_kvargs_process(kvlist, ICE_FIELD_NAME_ARG,
2485 : 0 : &handle_field_name_arg, &ad->devargs.xtr_field_name);
2486 [ # # ]: 0 : if (ret)
2487 : 0 : goto bail;
2488 : :
2489 : 0 : ret = rte_kvargs_process(kvlist, ICE_SAFE_MODE_SUPPORT_ARG,
2490 : 0 : &parse_bool, &ad->devargs.safe_mode_support);
2491 [ # # ]: 0 : if (ret)
2492 : 0 : goto bail;
2493 : :
2494 : 0 : ret = rte_kvargs_process(kvlist, ICE_DEFAULT_MAC_DISABLE,
2495 : 0 : &parse_bool, &ad->devargs.default_mac_disable);
2496 [ # # ]: 0 : if (ret)
2497 : 0 : goto bail;
2498 : :
2499 : 0 : ret = rte_kvargs_process(kvlist, ICE_HW_DEBUG_MASK_ARG,
2500 : 0 : &parse_u64, &ad->hw.debug_mask);
2501 [ # # ]: 0 : if (ret)
2502 : 0 : goto bail;
2503 : :
2504 : 0 : ret = rte_kvargs_process(kvlist, ICE_ONE_PPS_OUT_ARG,
2505 : : &handle_pps_out_arg, &ad->devargs);
2506 [ # # ]: 0 : if (ret)
2507 : 0 : goto bail;
2508 : :
2509 : 0 : ret = rte_kvargs_process(kvlist, ICE_MBUF_CHECK_ARG,
2510 : 0 : &ice_parse_mbuf_check, &ad->devargs.mbuf_check);
2511 [ # # ]: 0 : if (ret)
2512 : 0 : goto bail;
2513 : :
2514 : 0 : ret = rte_kvargs_process(kvlist, ICE_RX_LOW_LATENCY_ARG,
2515 : 0 : &parse_bool, &ad->devargs.rx_low_latency);
2516 [ # # ]: 0 : if (ret)
2517 : 0 : goto bail;
2518 : :
2519 : 0 : ret = rte_kvargs_process(kvlist, ICE_DDP_FILENAME_ARG,
2520 : 0 : &handle_ddp_filename_arg, &ad->devargs.ddp_filename);
2521 [ # # ]: 0 : if (ret)
2522 : 0 : goto bail;
2523 : :
2524 : 0 : ret = rte_kvargs_process(kvlist, ICE_DDP_LOAD_SCHED_ARG,
2525 : 0 : &parse_bool, &ad->devargs.ddp_load_sched);
2526 [ # # ]: 0 : if (ret)
2527 : 0 : goto bail;
2528 : :
2529 : 0 : ret = rte_kvargs_process(kvlist, ICE_TM_LEVELS_ARG,
2530 : 0 : &parse_tx_sched_levels, &ad->devargs.tm_exposed_levels);
2531 [ # # ]: 0 : if (ret)
2532 : 0 : goto bail;
2533 : :
2534 : 0 : ret = rte_kvargs_process(kvlist, ICE_RL_BURST_SIZE_ARG,
2535 : 0 : &parse_u32, &ad->devargs.rl_burst_size);
2536 [ # # ]: 0 : if (ret)
2537 : 0 : goto bail;
2538 : :
2539 : 0 : ret = rte_kvargs_process(kvlist, ICE_SOURCE_PRUNE_ARG,
2540 : 0 : &parse_bool, &ad->devargs.source_prune);
2541 [ # # ]: 0 : if (ret)
2542 : 0 : goto bail;
2543 : :
2544 : 0 : ret = rte_kvargs_process(kvlist, ICE_LINK_STATE_ON_CLOSE,
2545 : 0 : &parse_link_state_on_close, &ad->devargs.link_state_on_close);
2546 : :
2547 : 0 : bail:
2548 : 0 : rte_kvargs_free(kvlist);
2549 : 0 : return ret;
2550 : : }
2551 : :
2552 : : static int
2553 : 0 : ice_get_hw_res(struct ice_hw *hw, uint16_t res_type,
2554 : : uint16_t num, uint16_t desc_id,
2555 : : uint16_t *prof_buf, uint16_t *num_prof)
2556 : : {
2557 : : struct ice_aqc_res_elem *resp_buf;
2558 : : int ret;
2559 : : uint16_t buf_len;
2560 : : bool res_shared = 1;
2561 : : struct ice_aq_desc aq_desc;
2562 : : struct ice_sq_cd *cd = NULL;
2563 : : struct ice_aqc_get_allocd_res_desc *cmd =
2564 : : &aq_desc.params.get_res_desc;
2565 : :
2566 : 0 : buf_len = sizeof(*resp_buf) * num;
2567 : 0 : resp_buf = ice_malloc(hw, buf_len);
2568 [ # # ]: 0 : if (!resp_buf)
2569 : : return -ENOMEM;
2570 : :
2571 : 0 : ice_fill_dflt_direct_cmd_desc(&aq_desc,
2572 : : ice_aqc_opc_get_allocd_res_desc);
2573 : :
2574 : 0 : cmd->ops.cmd.res = CPU_TO_LE16(((res_type << ICE_AQC_RES_TYPE_S) &
2575 : : ICE_AQC_RES_TYPE_M) | (res_shared ?
2576 : : ICE_AQC_RES_TYPE_FLAG_SHARED : 0));
2577 : 0 : cmd->ops.cmd.first_desc = CPU_TO_LE16(desc_id);
2578 : :
2579 : 0 : ret = ice_aq_send_cmd(hw, &aq_desc, resp_buf, buf_len, cd);
2580 [ # # ]: 0 : if (!ret)
2581 : 0 : *num_prof = LE16_TO_CPU(cmd->ops.resp.num_desc);
2582 : : else
2583 : 0 : goto exit;
2584 : :
2585 : 0 : ice_memcpy(prof_buf, resp_buf, sizeof(*resp_buf) *
2586 : : (*num_prof), ICE_NONDMA_TO_NONDMA);
2587 : :
2588 : 0 : exit:
2589 : 0 : ice_free(hw, resp_buf);
2590 : 0 : return ret;
2591 : : }
2592 : : static int
2593 : 0 : ice_cleanup_resource(struct ice_hw *hw, uint16_t res_type)
2594 : : {
2595 : : int ret;
2596 : : uint16_t prof_id;
2597 : : uint16_t prof_buf[ICE_MAX_RES_DESC_NUM];
2598 : : uint16_t first_desc = 1;
2599 : 0 : uint16_t num_prof = 0;
2600 : :
2601 : 0 : ret = ice_get_hw_res(hw, res_type, ICE_MAX_RES_DESC_NUM,
2602 : : first_desc, prof_buf, &num_prof);
2603 [ # # ]: 0 : if (ret) {
2604 : 0 : PMD_INIT_LOG(ERR, "Failed to get fxp resource");
2605 : 0 : return ret;
2606 : : }
2607 : :
2608 [ # # ]: 0 : for (prof_id = 0; prof_id < num_prof; prof_id++) {
2609 : 0 : ret = ice_free_hw_res(hw, res_type, 1, &prof_buf[prof_id]);
2610 [ # # ]: 0 : if (ret) {
2611 : 0 : PMD_INIT_LOG(ERR, "Failed to free fxp resource");
2612 : 0 : return ret;
2613 : : }
2614 : : }
2615 : : return 0;
2616 : : }
2617 : :
2618 : : static int
2619 : 0 : ice_reset_fxp_resource(struct ice_hw *hw)
2620 : : {
2621 : : int ret;
2622 : :
2623 : 0 : ret = ice_cleanup_resource(hw, ICE_AQC_RES_TYPE_FD_PROF_BLDR_PROFID);
2624 [ # # ]: 0 : if (ret) {
2625 : 0 : PMD_INIT_LOG(ERR, "Failed to clearup fdir resource");
2626 : 0 : return ret;
2627 : : }
2628 : :
2629 : 0 : ret = ice_cleanup_resource(hw, ICE_AQC_RES_TYPE_HASH_PROF_BLDR_PROFID);
2630 [ # # ]: 0 : if (ret) {
2631 : 0 : PMD_INIT_LOG(ERR, "Failed to clearup rss resource");
2632 : 0 : return ret;
2633 : : }
2634 : :
2635 : : return 0;
2636 : : }
2637 : :
2638 : : static void
2639 : : ice_rss_ctx_init(struct ice_pf *pf)
2640 : : {
2641 : 0 : memset(&pf->hash_ctx, 0, sizeof(pf->hash_ctx));
2642 : : }
2643 : :
2644 : : static uint64_t
2645 : : ice_get_supported_rxdid(struct ice_hw *hw)
2646 : : {
2647 : : uint64_t supported_rxdid = 0; /* bitmap for supported RXDID */
2648 : : uint32_t regval;
2649 : : int i;
2650 : :
2651 : : supported_rxdid |= RTE_BIT64(ICE_RXDID_LEGACY_1);
2652 : :
2653 [ # # ]: 0 : for (i = ICE_RXDID_FLEX_NIC; i < ICE_FLEX_DESC_RXDID_MAX_NUM; i++) {
2654 : 0 : regval = ICE_READ_REG(hw, GLFLXP_RXDID_FLAGS(i, 0));
2655 : 0 : if ((regval >> GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S)
2656 [ # # ]: 0 : & GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M)
2657 : 0 : supported_rxdid |= RTE_BIT64(i);
2658 : : }
2659 : : return supported_rxdid;
2660 : : }
2661 : :
2662 : 0 : static void ice_ptp_init_info(struct rte_eth_dev *dev)
2663 : : {
2664 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2665 : : struct ice_adapter *ad =
2666 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2667 : :
2668 [ # # # # ]: 0 : switch (hw->phy_model) {
2669 : 0 : case ICE_PHY_ETH56G:
2670 : 0 : ad->ptp_tx_block = hw->pf_id;
2671 : 0 : ad->ptp_tx_index = 0;
2672 : 0 : break;
2673 : 0 : case ICE_PHY_E810:
2674 : : case ICE_PHY_E830:
2675 : 0 : ad->ptp_tx_block = hw->port_info->lport;
2676 : 0 : ad->ptp_tx_index = 0;
2677 : 0 : break;
2678 : 0 : case ICE_PHY_E822:
2679 : 0 : ad->ptp_tx_block = hw->pf_id / ICE_PORTS_PER_QUAD;
2680 : 0 : ad->ptp_tx_index = (hw->pf_id % ICE_PORTS_PER_QUAD) *
2681 : : ICE_PORTS_PER_PHY_E822 * ICE_QUADS_PER_PHY_E822;
2682 : 0 : break;
2683 : 0 : default:
2684 : 0 : PMD_DRV_LOG(WARNING, "Unsupported PHY model");
2685 : 0 : break;
2686 : : }
2687 : 0 : }
2688 : :
2689 : : static int
2690 : 0 : ice_dev_init(struct rte_eth_dev *dev)
2691 : : {
2692 : : struct rte_pci_device *pci_dev;
2693 : : struct rte_intr_handle *intr_handle;
2694 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2695 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2696 : : struct ice_adapter *ad =
2697 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2698 : : struct ice_vsi *vsi;
2699 : : int ret;
2700 : : #ifndef RTE_EXEC_ENV_WINDOWS
2701 : : off_t pos;
2702 : : uint32_t dsn_low, dsn_high;
2703 : : uint64_t dsn;
2704 : : bool use_dsn;
2705 : : #endif
2706 : :
2707 : 0 : dev->dev_ops = &ice_eth_dev_ops;
2708 : 0 : dev->rx_queue_count = ice_rx_queue_count;
2709 : 0 : dev->rx_descriptor_status = ice_rx_descriptor_status;
2710 : 0 : dev->tx_descriptor_status = ice_tx_descriptor_status;
2711 : 0 : dev->rx_pkt_burst = ice_recv_pkts;
2712 : 0 : dev->tx_pkt_burst = ice_xmit_pkts;
2713 : 0 : dev->tx_pkt_prepare = ice_prep_pkts;
2714 : :
2715 : : /* for secondary processes, we don't initialise any further as primary
2716 : : * has already done this work.
2717 : : */
2718 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
2719 : 0 : ice_set_rx_function(dev);
2720 : 0 : ice_set_tx_function(dev);
2721 : 0 : return 0;
2722 : : }
2723 : :
2724 : 0 : ice_set_default_ptype_table(dev);
2725 : 0 : pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2726 : 0 : intr_handle = pci_dev->intr_handle;
2727 : :
2728 : 0 : pf->adapter = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2729 : 0 : pf->dev_data = dev->data;
2730 : 0 : hw->back = pf->adapter;
2731 : 0 : hw->hw_addr = (uint8_t *)pci_dev->mem_resource[0].addr;
2732 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
2733 : 0 : hw->device_id = pci_dev->id.device_id;
2734 : 0 : hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
2735 : 0 : hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
2736 : 0 : hw->bus.device = pci_dev->addr.devid;
2737 : 0 : hw->bus.func = pci_dev->addr.function;
2738 : :
2739 : 0 : ret = ice_parse_devargs(dev);
2740 [ # # ]: 0 : if (ret) {
2741 : 0 : PMD_INIT_LOG(ERR, "Failed to parse devargs");
2742 : : ret = -EINVAL;
2743 : 0 : goto err_free_devargs;
2744 : : }
2745 : :
2746 : : ice_init_controlq_parameter(hw);
2747 : :
2748 : 0 : ret = ice_init_hw(hw);
2749 [ # # ]: 0 : if (ret) {
2750 : 0 : PMD_INIT_LOG(ERR, "Failed to initialize HW");
2751 : : ret = -EINVAL;
2752 : 0 : goto err_free_devargs;
2753 : : }
2754 : :
2755 : : /*
2756 : : * Override the hardware default scheduler rate-limiter burst size only
2757 : : * when the user explicitly requests it. A smaller burst reduces Tx
2758 : : * latency jitter for time-sensitive traffic at the cost of throughput,
2759 : : * so it must not change for every port. ice_cfg_rl_burst_size()
2760 : : * validates the value against the hardware-allowed range.
2761 : : */
2762 [ # # # # ]: 0 : if (ad->devargs.rl_burst_size != 0 &&
2763 : 0 : ice_cfg_rl_burst_size(hw, ad->devargs.rl_burst_size) != 0) {
2764 : 0 : PMD_INIT_LOG(ERR, "Invalid rl_burst_size %u bytes",
2765 : : ad->devargs.rl_burst_size);
2766 : 0 : ice_deinit_hw(hw);
2767 : : ret = -EINVAL;
2768 : 0 : goto err_free_devargs;
2769 : : }
2770 : :
2771 : : #ifndef RTE_EXEC_ENV_WINDOWS
2772 : : use_dsn = false;
2773 : : dsn = 0;
2774 : 0 : pos = rte_pci_find_ext_capability(pci_dev, RTE_PCI_EXT_CAP_ID_DSN);
2775 [ # # ]: 0 : if (pos) {
2776 [ # # # # ]: 0 : if (rte_pci_read_config(pci_dev, &dsn_low, 4, pos + 4) < 0 ||
2777 : 0 : rte_pci_read_config(pci_dev, &dsn_high, 4, pos + 8) < 0) {
2778 : 0 : PMD_INIT_LOG(WARNING, "Failed to read pci config space");
2779 : : } else {
2780 : : use_dsn = true;
2781 : 0 : dsn = (uint64_t)dsn_high << 32 | dsn_low;
2782 : : }
2783 : : } else {
2784 : 0 : PMD_INIT_LOG(INFO, "Failed to read device serial number");
2785 : : }
2786 : :
2787 : 0 : ret = ice_load_pkg(pf->adapter, use_dsn, dsn);
2788 [ # # ]: 0 : if (ret == 0) {
2789 : 0 : ret = ice_init_hw_tbls(hw);
2790 [ # # ]: 0 : if (ret) {
2791 : 0 : PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d", ret);
2792 : 0 : ice_free_seg(hw);
2793 : : }
2794 : : }
2795 : :
2796 [ # # ]: 0 : if (ret) {
2797 [ # # ]: 0 : if (!ad->devargs.safe_mode_support) {
2798 : 0 : PMD_INIT_LOG(ERR, "Failed to load the DDP package,"
2799 : : "Use safe-mode-support=1 to enter Safe Mode");
2800 : 0 : goto err_init_fw;
2801 : : }
2802 : :
2803 : 0 : PMD_INIT_LOG(WARNING, "Failed to load the DDP package,"
2804 : : "Entering Safe Mode");
2805 : 0 : ad->is_safe_mode = 1;
2806 : : }
2807 : : #endif
2808 : :
2809 : 0 : PMD_INIT_LOG(INFO, "FW %d.%d.%05d API %d.%d",
2810 : : hw->fw_maj_ver, hw->fw_min_ver, hw->fw_build,
2811 : : hw->api_maj_ver, hw->api_min_ver);
2812 : :
2813 : 0 : ice_pf_sw_init(dev);
2814 : 0 : ret = ice_init_mac_address(dev);
2815 [ # # ]: 0 : if (ret) {
2816 : 0 : PMD_INIT_LOG(ERR, "Failed to initialize mac address");
2817 : 0 : goto err_init_mac;
2818 : : }
2819 : :
2820 : 0 : ret = ice_res_pool_init(&pf->msix_pool, 1,
2821 : 0 : hw->func_caps.common_cap.num_msix_vectors - 1);
2822 [ # # ]: 0 : if (ret) {
2823 : 0 : PMD_INIT_LOG(ERR, "Failed to init MSIX pool");
2824 : 0 : goto err_msix_pool_init;
2825 : : }
2826 : :
2827 : 0 : ret = ice_pf_setup(pf);
2828 [ # # ]: 0 : if (ret) {
2829 : 0 : PMD_INIT_LOG(ERR, "Failed to setup PF");
2830 : 0 : goto err_pf_setup;
2831 : : }
2832 : :
2833 : 0 : ret = ice_send_driver_ver(hw);
2834 [ # # ]: 0 : if (ret) {
2835 : 0 : PMD_INIT_LOG(ERR, "Failed to send driver version");
2836 : 0 : goto err_release_vsi;
2837 : : }
2838 : :
2839 : 0 : vsi = pf->main_vsi;
2840 : :
2841 : 0 : ret = ice_aq_stop_lldp(hw, true, false, NULL);
2842 [ # # ]: 0 : if (ret != ICE_SUCCESS)
2843 : 0 : PMD_INIT_LOG(DEBUG, "lldp has already stopped");
2844 : 0 : ret = ice_init_dcb(hw, true);
2845 [ # # ]: 0 : if (ret != ICE_SUCCESS)
2846 : 0 : PMD_INIT_LOG(DEBUG, "Failed to init DCB");
2847 : : /* Forward LLDP packets to default VSI */
2848 : 0 : ret = ice_lldp_fltr_add_remove(hw, vsi->vsi_id, true);
2849 [ # # ]: 0 : if (ret != ICE_SUCCESS)
2850 : 0 : PMD_INIT_LOG(DEBUG, "Failed to cfg lldp");
2851 : : /* register callback func to eal lib */
2852 : 0 : rte_intr_callback_register(intr_handle,
2853 : : ice_interrupt_handler, dev);
2854 : :
2855 : 0 : ice_pf_enable_irq0(hw);
2856 : :
2857 : : /* enable uio intr after callback register */
2858 : 0 : rte_intr_enable(intr_handle);
2859 : :
2860 : : /* get base queue pairs index in the device */
2861 : 0 : ice_base_queue_get(pf);
2862 : :
2863 : : /* Initialize RSS context for gtpu_eh */
2864 : : ice_rss_ctx_init(pf);
2865 : :
2866 : : /* Initialize TM configuration */
2867 : 0 : ice_tm_conf_init(dev);
2868 : :
2869 : : /* Initialize PHY model */
2870 : 0 : ice_ptp_init_phy_model(hw);
2871 : :
2872 : : /* Initialize PTP info */
2873 : 0 : ice_ptp_init_info(dev);
2874 : :
2875 [ # # ]: 0 : if (hw->phy_model == ICE_PHY_E822) {
2876 : 0 : ret = ice_start_phy_timer_e822(hw, hw->pf_id, true);
2877 [ # # ]: 0 : if (ret)
2878 : 0 : PMD_INIT_LOG(ERR, "Failed to start phy timer");
2879 : : }
2880 : :
2881 [ # # ]: 0 : if (!ad->is_safe_mode) {
2882 : 0 : ret = ice_flow_init(ad);
2883 [ # # ]: 0 : if (ret) {
2884 : 0 : PMD_INIT_LOG(ERR, "Failed to initialize flow");
2885 : 0 : goto err_flow_init;
2886 : : }
2887 : : }
2888 : :
2889 : 0 : ret = ice_reset_fxp_resource(hw);
2890 [ # # ]: 0 : if (ret) {
2891 : 0 : PMD_INIT_LOG(ERR, "Failed to reset fxp resource");
2892 : 0 : goto err_flow_init;
2893 : : }
2894 : :
2895 : 0 : pf->supported_rxdid = ice_get_supported_rxdid(hw);
2896 : :
2897 : : /* reset all stats of the device, including pf and main vsi */
2898 : 0 : ice_stats_reset(dev);
2899 : :
2900 : 0 : return 0;
2901 : :
2902 : 0 : err_flow_init:
2903 : 0 : ice_flow_uninit(ad);
2904 : 0 : rte_intr_disable(intr_handle);
2905 : : ice_pf_disable_irq0(hw);
2906 : 0 : rte_intr_callback_unregister(intr_handle,
2907 : : ice_interrupt_handler, dev);
2908 : 0 : err_release_vsi:
2909 : 0 : ice_release_vsi(pf->main_vsi);
2910 : 0 : pf->main_vsi = NULL;
2911 : 0 : err_pf_setup:
2912 : 0 : ice_res_pool_destroy(&pf->msix_pool);
2913 : 0 : err_msix_pool_init:
2914 : 0 : rte_free(dev->data->mac_addrs);
2915 : 0 : dev->data->mac_addrs = NULL;
2916 : 0 : err_init_mac:
2917 : 0 : rte_free(pf->proto_xtr);
2918 : : #ifndef RTE_EXEC_ENV_WINDOWS
2919 : 0 : err_init_fw:
2920 : : #endif
2921 : 0 : ice_deinit_hw(hw);
2922 : 0 : err_free_devargs:
2923 : 0 : free(RTE_CAST_PTR(void *, ad->devargs.ddp_filename));
2924 : 0 : ad->devargs.ddp_filename = NULL;
2925 : :
2926 : 0 : return ret;
2927 : : }
2928 : :
2929 : : int
2930 : 0 : ice_release_vsi(struct ice_vsi *vsi)
2931 : : {
2932 : : struct ice_hw *hw;
2933 : : struct ice_vsi_ctx vsi_ctx;
2934 : : struct ice_mac_filter *m_f;
2935 : : struct ice_vlan_filter *v_f;
2936 : : void *temp;
2937 : : int ret, error = 0;
2938 : :
2939 [ # # ]: 0 : if (!vsi)
2940 : : return error;
2941 : :
2942 : 0 : hw = ICE_VSI_TO_HW(vsi);
2943 : :
2944 : 0 : ice_remove_all_mac_vlan_filters(vsi);
2945 : :
2946 : : /* filters whose HW removal failed or was skipped are still listed */
2947 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(m_f, &vsi->mac_list, next, temp)
2948 : 0 : rte_free(m_f);
2949 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(v_f, &vsi->vlan_list, next, temp)
2950 : 0 : rte_free(v_f);
2951 : :
2952 : : memset(&vsi_ctx, 0, sizeof(vsi_ctx));
2953 : :
2954 : 0 : vsi_ctx.vsi_num = vsi->vsi_id;
2955 : 0 : vsi_ctx.info = vsi->info;
2956 : 0 : ret = ice_free_vsi(hw, vsi->idx, &vsi_ctx, false, NULL);
2957 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
2958 : 0 : PMD_INIT_LOG(ERR, "Failed to free vsi by aq, %u", vsi->vsi_id);
2959 : : error = -1;
2960 : : }
2961 : :
2962 : 0 : rte_free(vsi->rss_lut);
2963 : 0 : rte_free(vsi->rss_key);
2964 : 0 : rte_free(vsi);
2965 : 0 : return error;
2966 : : }
2967 : :
2968 : : void
2969 : 0 : ice_vsi_disable_queues_intr(struct ice_vsi *vsi)
2970 : : {
2971 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[vsi->adapter->pf.dev_data->port_id];
2972 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
2973 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2974 : : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2975 : : uint16_t msix_intr, i;
2976 : :
2977 : : /* disable interrupt and also clear all the exist config */
2978 [ # # ]: 0 : for (i = 0; i < vsi->nb_used_qps; i++) {
2979 : 0 : ICE_WRITE_REG(hw, QINT_TQCTL(vsi->base_queue + i), 0);
2980 : 0 : ICE_WRITE_REG(hw, QINT_RQCTL(vsi->base_queue + i), 0);
2981 : : rte_wmb();
2982 : : }
2983 : :
2984 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
2985 : : /* vfio-pci */
2986 [ # # ]: 0 : for (i = 0; i < vsi->nb_msix; i++) {
2987 : 0 : msix_intr = vsi->msix_intr + i;
2988 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(msix_intr),
2989 : : GLINT_DYN_CTL_WB_ON_ITR_M);
2990 : : }
2991 : : else
2992 : : /* igb_uio */
2993 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(0), GLINT_DYN_CTL_WB_ON_ITR_M);
2994 : 0 : }
2995 : :
2996 : : static int
2997 : 0 : ice_dev_stop(struct rte_eth_dev *dev)
2998 : : {
2999 : 0 : struct rte_eth_dev_data *data = dev->data;
3000 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3001 : : struct ice_adapter *ad =
3002 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3003 : 0 : struct ice_vsi *main_vsi = pf->main_vsi;
3004 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
3005 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
3006 : : uint16_t i;
3007 : :
3008 : : /* avoid stopping again */
3009 [ # # ]: 0 : if (pf->adapter_stopped)
3010 : : return 0;
3011 : :
3012 : : /* stop and clear all Rx queues */
3013 [ # # ]: 0 : for (i = 0; i < data->nb_rx_queues; i++)
3014 : 0 : ice_rx_queue_stop(dev, i);
3015 : :
3016 : : /* stop and clear all Tx queues */
3017 [ # # ]: 0 : for (i = 0; i < data->nb_tx_queues; i++)
3018 : 0 : ice_tx_queue_stop(dev, i);
3019 : :
3020 : : /* disable all queue interrupts */
3021 : 0 : ice_vsi_disable_queues_intr(main_vsi);
3022 : :
3023 [ # # ]: 0 : if (dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
3024 : 0 : ad->txpp_ena = 0;
3025 : 0 : ice_timesync_disable(dev);
3026 : : }
3027 : :
3028 [ # # # # ]: 0 : if (pf->adapter->devargs.link_state_on_close == ICE_LINK_UP ||
3029 : 0 : (pf->adapter->devargs.link_state_on_close == ICE_LINK_INITIAL &&
3030 [ # # ]: 0 : pf->init_link_up))
3031 : : ice_dev_set_link_up(dev);
3032 : : else
3033 : : ice_dev_set_link_down(dev);
3034 : :
3035 : : /* Clean datapath event and queue/vec mapping */
3036 : 0 : rte_intr_efd_disable(intr_handle);
3037 : 0 : rte_intr_vec_list_free(intr_handle);
3038 : :
3039 : 0 : pf->adapter_stopped = true;
3040 : 0 : dev->data->dev_started = 0;
3041 : :
3042 [ # # ]: 0 : if (pf->use_aq_polling) {
3043 : 0 : rte_eal_alarm_cancel(ice_aq_alarm_handler, dev);
3044 : 0 : pf->use_aq_polling = false;
3045 : : }
3046 : :
3047 : : return 0;
3048 : : }
3049 : :
3050 : : static void
3051 : 0 : ice_deinit_dcb(struct rte_eth_dev *dev)
3052 : : {
3053 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3054 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3055 : 0 : struct ice_port_info *port_info = hw->port_info;
3056 : : struct ice_qos_cfg *qos_cfg = &port_info->qos_cfg;
3057 : 0 : struct ice_dcbx_cfg *local_dcb_conf = &qos_cfg->local_dcbx_cfg;
3058 : : int i, ret, cgd_idx;
3059 : : uint16_t max_frame_size;
3060 : 0 : u8 max_tcs = local_dcb_conf->etscfg.maxtcs;
3061 : : u8 tc;
3062 : :
3063 [ # # ]: 0 : if (!(dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_DCB_FLAG ||
3064 [ # # ]: 0 : dev->data->dev_conf.txmode.mq_mode == RTE_ETH_MQ_TX_DCB))
3065 : : return;
3066 : :
3067 [ # # ]: 0 : for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
3068 : 0 : tc = ice_get_tc_by_priority(hw, i);
3069 : 0 : cgd_idx = ice_get_cgd_idx(hw, tc);
3070 [ # # ]: 0 : wr32(hw, GLRPB_TCHW(cgd_idx), CPU_TO_LE32(ICE_MAC_TC_MAX_WATERMARK));
3071 [ # # ]: 0 : wr32(hw, GLRPB_TCLW(cgd_idx), CPU_TO_LE32(ICE_MAC_TC_MAX_WATERMARK));
3072 : : }
3073 : :
3074 [ # # ]: 0 : max_frame_size = pf->dev_data->mtu ?
3075 : : pf->dev_data->mtu + ICE_ETH_OVERHEAD : ICE_FRAME_SIZE_MAX;
3076 : : /* for each TC resets corresponding PFC quanta/threshold to its default values */
3077 : 0 : ret = ice_aq_set_mac_pfc_cfg(hw, max_frame_size, (1 << max_tcs) - 1,
3078 : : UINT16_MAX, INT16_MAX + 1, false, NULL);
3079 [ # # ]: 0 : if (ret)
3080 : 0 : PMD_DRV_LOG(ERR, "Failed to set mac config on DCB deinit");
3081 : :
3082 : : memset(local_dcb_conf, 0, sizeof(*local_dcb_conf));
3083 : 0 : local_dcb_conf->etscfg.maxtcs = max_tcs;
3084 : 0 : local_dcb_conf->etscfg.tcbwtable[0] = 100;
3085 : 0 : local_dcb_conf->etsrec.tcbwtable[0] = 100;
3086 : 0 : ret = ice_set_dcb_cfg(port_info);
3087 [ # # ]: 0 : if (ret)
3088 : 0 : PMD_DRV_LOG(ERR, "Failed to disable DCB");
3089 : : }
3090 : :
3091 : : static int
3092 : 0 : ice_dev_close(struct rte_eth_dev *dev)
3093 : : {
3094 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3095 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3096 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
3097 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
3098 : : struct ice_adapter *ad =
3099 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3100 : : int ret;
3101 : : uint32_t val;
3102 : 0 : uint8_t timer = hw->func_caps.ts_func_info.tmr_index_owned;
3103 : 0 : uint32_t pin_idx = ad->devargs.pin_idx;
3104 : :
3105 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
3106 : : return 0;
3107 : :
3108 : : /* Since stop will make link down, then the link event will be
3109 : : * triggered, disable the irq firstly.
3110 : : */
3111 : : ice_pf_disable_irq0(hw);
3112 : :
3113 : : /* Unregister callback func from eal lib, use sync version to
3114 : : * make sure all active interrupt callbacks is done, then it's
3115 : : * safe to free all resources.
3116 : : */
3117 : 0 : rte_intr_callback_unregister_sync(intr_handle,
3118 : : ice_interrupt_handler, dev);
3119 : :
3120 : 0 : ret = ice_dev_stop(dev);
3121 : :
3122 [ # # ]: 0 : if (!ad->is_safe_mode)
3123 : 0 : ice_flow_uninit(ad);
3124 : :
3125 : 0 : ice_deinit_dcb(dev);
3126 : : /* release all queue resource */
3127 : 0 : ice_free_queues(dev);
3128 : :
3129 : 0 : ice_res_pool_destroy(&pf->msix_pool);
3130 : 0 : ice_release_vsi(pf->main_vsi);
3131 : 0 : ice_deinit_hw(hw);
3132 : 0 : free((void *)(uintptr_t)ad->devargs.ddp_filename);
3133 : 0 : ad->devargs.ddp_filename = NULL;
3134 : 0 : rte_free(pf->proto_xtr);
3135 : 0 : pf->proto_xtr = NULL;
3136 : :
3137 : : /* Uninit TM configuration */
3138 : 0 : ice_tm_conf_uninit(dev);
3139 : :
3140 [ # # ]: 0 : if (ad->devargs.pps_out_ena) {
3141 : 0 : ICE_WRITE_REG(hw, GLTSYN_AUX_OUT(pin_idx, timer), 0);
3142 : 0 : ICE_WRITE_REG(hw, GLTSYN_CLKO(pin_idx, timer), 0);
3143 : 0 : ICE_WRITE_REG(hw, GLTSYN_TGT_L(pin_idx, timer), 0);
3144 : 0 : ICE_WRITE_REG(hw, GLTSYN_TGT_H(pin_idx, timer), 0);
3145 : :
3146 : : val = GLGEN_GPIO_CTL_PIN_DIR_M;
3147 : 0 : ICE_WRITE_REG(hw, GLGEN_GPIO_CTL(pin_idx), val);
3148 : : }
3149 : :
3150 : : /* disable uio intr before callback unregister */
3151 : 0 : rte_intr_disable(intr_handle);
3152 : :
3153 : 0 : return ret;
3154 : : }
3155 : :
3156 : : static int
3157 : 0 : ice_dev_uninit(struct rte_eth_dev *dev)
3158 : : {
3159 : 0 : ice_dev_close(dev);
3160 : :
3161 : 0 : return 0;
3162 : : }
3163 : :
3164 : : static bool
3165 : : is_hash_cfg_valid(struct ice_rss_hash_cfg *cfg)
3166 : : {
3167 [ # # # # ]: 0 : return (cfg->hash_flds != 0 && cfg->addl_hdrs != 0) ? true : false;
3168 : : }
3169 : :
3170 : : static void
3171 : : hash_cfg_reset(struct ice_rss_hash_cfg *cfg)
3172 : : {
3173 : 0 : cfg->hash_flds = 0;
3174 : 0 : cfg->addl_hdrs = 0;
3175 : 0 : cfg->symm = 0;
3176 : 0 : cfg->hdr_type = ICE_RSS_OUTER_HEADERS;
3177 : 0 : }
3178 : :
3179 : : static int
3180 : 0 : ice_hash_moveout(struct ice_pf *pf, struct ice_rss_hash_cfg *cfg)
3181 : : {
3182 : : int status;
3183 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
3184 [ # # ]: 0 : struct ice_vsi *vsi = pf->main_vsi;
3185 : :
3186 [ # # ]: 0 : if (!is_hash_cfg_valid(cfg))
3187 : : return -ENOENT;
3188 : :
3189 : 0 : status = ice_rem_rss_cfg(hw, vsi->idx, cfg);
3190 [ # # ]: 0 : if (status && status != ICE_ERR_DOES_NOT_EXIST) {
3191 : 0 : PMD_DRV_LOG(ERR,
3192 : : "ice_rem_rss_cfg failed for VSI:%d, error:%d",
3193 : : vsi->idx, status);
3194 : 0 : return -EBUSY;
3195 : : }
3196 : :
3197 : : return 0;
3198 : : }
3199 : :
3200 : : static int
3201 : 0 : ice_hash_moveback(struct ice_pf *pf, struct ice_rss_hash_cfg *cfg)
3202 : : {
3203 : : int status;
3204 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
3205 [ # # ]: 0 : struct ice_vsi *vsi = pf->main_vsi;
3206 : :
3207 [ # # ]: 0 : if (!is_hash_cfg_valid(cfg))
3208 : : return -ENOENT;
3209 : :
3210 : 0 : status = ice_add_rss_cfg(hw, vsi->idx, cfg);
3211 [ # # ]: 0 : if (status) {
3212 : 0 : PMD_DRV_LOG(ERR,
3213 : : "ice_add_rss_cfg failed for VSI:%d, error:%d",
3214 : : vsi->idx, status);
3215 : 0 : return -EBUSY;
3216 : : }
3217 : :
3218 : : return 0;
3219 : : }
3220 : :
3221 : : static int
3222 : : ice_hash_remove(struct ice_pf *pf, struct ice_rss_hash_cfg *cfg)
3223 : : {
3224 : : int ret;
3225 : :
3226 : 0 : ret = ice_hash_moveout(pf, cfg);
3227 [ # # # # : 0 : if (ret && (ret != -ENOENT))
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
3228 : : return ret;
3229 : :
3230 : : hash_cfg_reset(cfg);
3231 : :
3232 : 0 : return 0;
3233 : : }
3234 : :
3235 : : static int
3236 : 0 : ice_add_rss_cfg_pre_gtpu(struct ice_pf *pf, struct ice_hash_gtpu_ctx *ctx,
3237 : : u8 ctx_idx)
3238 : : {
3239 : : int ret;
3240 : :
3241 [ # # # # : 0 : switch (ctx_idx) {
# # # # ]
3242 : 0 : case ICE_HASH_GTPU_CTX_EH_IP:
3243 : 0 : ret = ice_hash_remove(pf,
3244 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_UDP]);
3245 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3246 : : return ret;
3247 : :
3248 : 0 : ret = ice_hash_remove(pf,
3249 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_TCP]);
3250 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3251 : : return ret;
3252 : :
3253 : 0 : ret = ice_hash_remove(pf,
3254 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP]);
3255 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3256 : : return ret;
3257 : :
3258 : 0 : ret = ice_hash_remove(pf,
3259 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_UDP]);
3260 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3261 : : return ret;
3262 : :
3263 : 0 : ret = ice_hash_remove(pf,
3264 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_TCP]);
3265 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3266 : : return ret;
3267 : :
3268 : 0 : ret = ice_hash_remove(pf,
3269 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP]);
3270 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3271 : : return ret;
3272 : :
3273 : 0 : ret = ice_hash_remove(pf,
3274 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_UDP]);
3275 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3276 : : return ret;
3277 : :
3278 : 0 : ret = ice_hash_remove(pf,
3279 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_TCP]);
3280 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3281 : 0 : return ret;
3282 : :
3283 : : break;
3284 : 0 : case ICE_HASH_GTPU_CTX_EH_IP_UDP:
3285 : 0 : ret = ice_hash_remove(pf,
3286 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_UDP]);
3287 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3288 : : return ret;
3289 : :
3290 : 0 : ret = ice_hash_remove(pf,
3291 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_UDP]);
3292 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3293 : : return ret;
3294 : :
3295 : 0 : ret = ice_hash_moveout(pf,
3296 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP]);
3297 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3298 : : return ret;
3299 : :
3300 : 0 : ret = ice_hash_moveout(pf,
3301 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_TCP]);
3302 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3303 : : return ret;
3304 : :
3305 : 0 : ret = ice_hash_moveout(pf,
3306 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP]);
3307 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3308 : : return ret;
3309 : :
3310 : 0 : ret = ice_hash_moveout(pf,
3311 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_TCP]);
3312 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3313 : 0 : return ret;
3314 : :
3315 : : break;
3316 : 0 : case ICE_HASH_GTPU_CTX_EH_IP_TCP:
3317 : 0 : ret = ice_hash_remove(pf,
3318 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_TCP]);
3319 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3320 : : return ret;
3321 : :
3322 : 0 : ret = ice_hash_remove(pf,
3323 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_TCP]);
3324 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3325 : : return ret;
3326 : :
3327 : 0 : ret = ice_hash_moveout(pf,
3328 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP]);
3329 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3330 : : return ret;
3331 : :
3332 : 0 : ret = ice_hash_moveout(pf,
3333 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_UDP]);
3334 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3335 : : return ret;
3336 : :
3337 : 0 : ret = ice_hash_moveout(pf,
3338 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP]);
3339 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3340 : : return ret;
3341 : :
3342 : 0 : ret = ice_hash_moveout(pf,
3343 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_UDP]);
3344 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3345 : 0 : return ret;
3346 : :
3347 : : break;
3348 : 0 : case ICE_HASH_GTPU_CTX_UP_IP:
3349 : 0 : ret = ice_hash_remove(pf,
3350 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_UDP]);
3351 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3352 : : return ret;
3353 : :
3354 : 0 : ret = ice_hash_remove(pf,
3355 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_TCP]);
3356 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3357 : : return ret;
3358 : :
3359 : 0 : ret = ice_hash_moveout(pf,
3360 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP]);
3361 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3362 : : return ret;
3363 : :
3364 : 0 : ret = ice_hash_moveout(pf,
3365 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_UDP]);
3366 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3367 : : return ret;
3368 : :
3369 : 0 : ret = ice_hash_moveout(pf,
3370 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_TCP]);
3371 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3372 : 0 : return ret;
3373 : :
3374 : : break;
3375 : 0 : case ICE_HASH_GTPU_CTX_UP_IP_UDP:
3376 : : case ICE_HASH_GTPU_CTX_UP_IP_TCP:
3377 : 0 : ret = ice_hash_moveout(pf,
3378 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP]);
3379 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3380 : : return ret;
3381 : :
3382 : 0 : ret = ice_hash_moveout(pf,
3383 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_UDP]);
3384 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3385 : : return ret;
3386 : :
3387 : 0 : ret = ice_hash_moveout(pf,
3388 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_TCP]);
3389 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3390 : 0 : return ret;
3391 : :
3392 : : break;
3393 : 0 : case ICE_HASH_GTPU_CTX_DW_IP:
3394 : 0 : ret = ice_hash_remove(pf,
3395 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_UDP]);
3396 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3397 : : return ret;
3398 : :
3399 : 0 : ret = ice_hash_remove(pf,
3400 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_TCP]);
3401 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3402 : : return ret;
3403 : :
3404 : 0 : ret = ice_hash_moveout(pf,
3405 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP]);
3406 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3407 : : return ret;
3408 : :
3409 : 0 : ret = ice_hash_moveout(pf,
3410 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_UDP]);
3411 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3412 : : return ret;
3413 : :
3414 : 0 : ret = ice_hash_moveout(pf,
3415 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_TCP]);
3416 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3417 : 0 : return ret;
3418 : :
3419 : : break;
3420 : 0 : case ICE_HASH_GTPU_CTX_DW_IP_UDP:
3421 : : case ICE_HASH_GTPU_CTX_DW_IP_TCP:
3422 : 0 : ret = ice_hash_moveout(pf,
3423 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP]);
3424 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3425 : : return ret;
3426 : :
3427 : 0 : ret = ice_hash_moveout(pf,
3428 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_UDP]);
3429 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3430 : : return ret;
3431 : :
3432 : 0 : ret = ice_hash_moveout(pf,
3433 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_TCP]);
3434 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3435 : 0 : return ret;
3436 : :
3437 : : break;
3438 : : default:
3439 : : break;
3440 : : }
3441 : :
3442 : : return 0;
3443 : : }
3444 : :
3445 : 0 : static u8 calc_gtpu_ctx_idx(uint32_t hdr)
3446 : : {
3447 : : u8 eh_idx, ip_idx;
3448 : :
3449 [ # # ]: 0 : if (hdr & ICE_FLOW_SEG_HDR_GTPU_EH)
3450 : : eh_idx = 0;
3451 [ # # ]: 0 : else if (hdr & ICE_FLOW_SEG_HDR_GTPU_UP)
3452 : : eh_idx = 1;
3453 [ # # ]: 0 : else if (hdr & ICE_FLOW_SEG_HDR_GTPU_DWN)
3454 : : eh_idx = 2;
3455 : : else
3456 : : return ICE_HASH_GTPU_CTX_MAX;
3457 : :
3458 : : ip_idx = 0;
3459 [ # # ]: 0 : if (hdr & ICE_FLOW_SEG_HDR_UDP)
3460 : : ip_idx = 1;
3461 [ # # ]: 0 : else if (hdr & ICE_FLOW_SEG_HDR_TCP)
3462 : : ip_idx = 2;
3463 : :
3464 [ # # ]: 0 : if (hdr & (ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV6))
3465 : 0 : return eh_idx * 3 + ip_idx;
3466 : : else
3467 : : return ICE_HASH_GTPU_CTX_MAX;
3468 : : }
3469 : :
3470 : : static int
3471 : 0 : ice_add_rss_cfg_pre(struct ice_pf *pf, uint32_t hdr)
3472 : : {
3473 : 0 : u8 gtpu_ctx_idx = calc_gtpu_ctx_idx(hdr);
3474 : :
3475 [ # # ]: 0 : if (hdr & ICE_FLOW_SEG_HDR_IPV4)
3476 : 0 : return ice_add_rss_cfg_pre_gtpu(pf, &pf->hash_ctx.gtpu4,
3477 : : gtpu_ctx_idx);
3478 [ # # ]: 0 : else if (hdr & ICE_FLOW_SEG_HDR_IPV6)
3479 : 0 : return ice_add_rss_cfg_pre_gtpu(pf, &pf->hash_ctx.gtpu6,
3480 : : gtpu_ctx_idx);
3481 : :
3482 : : return 0;
3483 : : }
3484 : :
3485 : : static int
3486 : 0 : ice_add_rss_cfg_post_gtpu(struct ice_pf *pf, struct ice_hash_gtpu_ctx *ctx,
3487 : : u8 ctx_idx, struct ice_rss_hash_cfg *cfg)
3488 : : {
3489 : : int ret;
3490 : :
3491 [ # # ]: 0 : if (ctx_idx < ICE_HASH_GTPU_CTX_MAX)
3492 : 0 : ctx->ctx[ctx_idx] = *cfg;
3493 : :
3494 [ # # # # ]: 0 : switch (ctx_idx) {
3495 : : case ICE_HASH_GTPU_CTX_EH_IP:
3496 : : break;
3497 : 0 : case ICE_HASH_GTPU_CTX_EH_IP_UDP:
3498 : 0 : ret = ice_hash_moveback(pf,
3499 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP]);
3500 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3501 : : return ret;
3502 : :
3503 : 0 : ret = ice_hash_moveback(pf,
3504 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_TCP]);
3505 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3506 : : return ret;
3507 : :
3508 : 0 : ret = ice_hash_moveback(pf,
3509 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP]);
3510 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3511 : : return ret;
3512 : :
3513 : 0 : ret = ice_hash_moveback(pf,
3514 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_TCP]);
3515 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3516 : 0 : return ret;
3517 : :
3518 : : break;
3519 : 0 : case ICE_HASH_GTPU_CTX_EH_IP_TCP:
3520 : 0 : ret = ice_hash_moveback(pf,
3521 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP]);
3522 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3523 : : return ret;
3524 : :
3525 : 0 : ret = ice_hash_moveback(pf,
3526 : : &ctx->ctx[ICE_HASH_GTPU_CTX_UP_IP_UDP]);
3527 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3528 : : return ret;
3529 : :
3530 : 0 : ret = ice_hash_moveback(pf,
3531 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP]);
3532 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3533 : : return ret;
3534 : :
3535 : 0 : ret = ice_hash_moveback(pf,
3536 : : &ctx->ctx[ICE_HASH_GTPU_CTX_DW_IP_UDP]);
3537 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3538 : 0 : return ret;
3539 : :
3540 : : break;
3541 : 0 : case ICE_HASH_GTPU_CTX_UP_IP:
3542 : : case ICE_HASH_GTPU_CTX_UP_IP_UDP:
3543 : : case ICE_HASH_GTPU_CTX_UP_IP_TCP:
3544 : : case ICE_HASH_GTPU_CTX_DW_IP:
3545 : : case ICE_HASH_GTPU_CTX_DW_IP_UDP:
3546 : : case ICE_HASH_GTPU_CTX_DW_IP_TCP:
3547 : 0 : ret = ice_hash_moveback(pf,
3548 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP]);
3549 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3550 : : return ret;
3551 : :
3552 : 0 : ret = ice_hash_moveback(pf,
3553 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_UDP]);
3554 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3555 : : return ret;
3556 : :
3557 : 0 : ret = ice_hash_moveback(pf,
3558 : : &ctx->ctx[ICE_HASH_GTPU_CTX_EH_IP_TCP]);
3559 [ # # ]: 0 : if (ret && (ret != -ENOENT))
3560 : 0 : return ret;
3561 : :
3562 : : break;
3563 : : default:
3564 : : break;
3565 : : }
3566 : :
3567 : : return 0;
3568 : : }
3569 : :
3570 : : static int
3571 : 0 : ice_add_rss_cfg_post(struct ice_pf *pf, struct ice_rss_hash_cfg *cfg)
3572 : : {
3573 : 0 : u8 gtpu_ctx_idx = calc_gtpu_ctx_idx(cfg->addl_hdrs);
3574 : :
3575 [ # # ]: 0 : if (cfg->addl_hdrs & ICE_FLOW_SEG_HDR_IPV4)
3576 : 0 : return ice_add_rss_cfg_post_gtpu(pf, &pf->hash_ctx.gtpu4,
3577 : : gtpu_ctx_idx, cfg);
3578 [ # # ]: 0 : else if (cfg->addl_hdrs & ICE_FLOW_SEG_HDR_IPV6)
3579 : 0 : return ice_add_rss_cfg_post_gtpu(pf, &pf->hash_ctx.gtpu6,
3580 : : gtpu_ctx_idx, cfg);
3581 : :
3582 : : return 0;
3583 : : }
3584 : :
3585 : : static void
3586 : 0 : ice_rem_rss_cfg_post(struct ice_pf *pf, uint32_t hdr)
3587 : : {
3588 : 0 : u8 gtpu_ctx_idx = calc_gtpu_ctx_idx(hdr);
3589 : :
3590 [ # # ]: 0 : if (gtpu_ctx_idx >= ICE_HASH_GTPU_CTX_MAX)
3591 : : return;
3592 : :
3593 [ # # ]: 0 : if (hdr & ICE_FLOW_SEG_HDR_IPV4)
3594 : 0 : hash_cfg_reset(&pf->hash_ctx.gtpu4.ctx[gtpu_ctx_idx]);
3595 [ # # ]: 0 : else if (hdr & ICE_FLOW_SEG_HDR_IPV6)
3596 : 0 : hash_cfg_reset(&pf->hash_ctx.gtpu6.ctx[gtpu_ctx_idx]);
3597 : : }
3598 : :
3599 : : int
3600 : 0 : ice_rem_rss_cfg_wrap(struct ice_pf *pf, uint16_t vsi_id,
3601 : : struct ice_rss_hash_cfg *cfg)
3602 : : {
3603 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
3604 : : int ret;
3605 : :
3606 : 0 : ret = ice_rem_rss_cfg(hw, vsi_id, cfg);
3607 [ # # ]: 0 : if (ret && ret != ICE_ERR_DOES_NOT_EXIST)
3608 : 0 : PMD_DRV_LOG(ERR, "remove rss cfg failed");
3609 : :
3610 : 0 : ice_rem_rss_cfg_post(pf, cfg->addl_hdrs);
3611 : :
3612 : 0 : return 0;
3613 : : }
3614 : :
3615 : : int
3616 : 0 : ice_add_rss_cfg_wrap(struct ice_pf *pf, uint16_t vsi_id,
3617 : : struct ice_rss_hash_cfg *cfg)
3618 : : {
3619 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
3620 : : int ret;
3621 : :
3622 : 0 : ret = ice_add_rss_cfg_pre(pf, cfg->addl_hdrs);
3623 [ # # ]: 0 : if (ret)
3624 : 0 : PMD_DRV_LOG(ERR, "add rss cfg pre failed");
3625 : :
3626 : 0 : ret = ice_add_rss_cfg(hw, vsi_id, cfg);
3627 [ # # ]: 0 : if (ret)
3628 : 0 : PMD_DRV_LOG(ERR, "add rss cfg failed");
3629 : :
3630 : 0 : ret = ice_add_rss_cfg_post(pf, cfg);
3631 [ # # ]: 0 : if (ret)
3632 : 0 : PMD_DRV_LOG(ERR, "add rss cfg post failed");
3633 : :
3634 : 0 : return 0;
3635 : : }
3636 : :
3637 : : static void
3638 : 0 : ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf)
3639 : : {
3640 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
3641 : 0 : struct ice_vsi *vsi = pf->main_vsi;
3642 : : struct ice_rss_hash_cfg cfg;
3643 : : int ret;
3644 : :
3645 : : #define ICE_RSS_HF_ALL ( \
3646 : : RTE_ETH_RSS_IPV4 | \
3647 : : RTE_ETH_RSS_IPV6 | \
3648 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
3649 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
3650 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
3651 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
3652 : : RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
3653 : : RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
3654 : :
3655 : 0 : ret = ice_rem_vsi_rss_cfg(hw, vsi->idx);
3656 [ # # ]: 0 : if (ret)
3657 : 0 : PMD_DRV_LOG(ERR, "%s Remove rss vsi fail %d",
3658 : : __func__, ret);
3659 : :
3660 : 0 : cfg.symm = 0;
3661 : 0 : cfg.hdr_type = ICE_RSS_OUTER_HEADERS;
3662 : : /* Configure RSS for IPv4 with src/dst addr as input set */
3663 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV4) {
3664 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER;
3665 : 0 : cfg.hash_flds = ICE_FLOW_HASH_IPV4;
3666 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3667 [ # # ]: 0 : if (ret)
3668 : 0 : PMD_DRV_LOG(ERR, "%s IPV4 rss flow fail %d",
3669 : : __func__, ret);
3670 : : }
3671 : :
3672 : : /* Configure RSS for IPv6 with src/dst addr as input set */
3673 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6) {
3674 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER;
3675 : 0 : cfg.hash_flds = ICE_FLOW_HASH_IPV6;
3676 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3677 [ # # ]: 0 : if (ret)
3678 : 0 : PMD_DRV_LOG(ERR, "%s IPV6 rss flow fail %d",
3679 : : __func__, ret);
3680 : : }
3681 : :
3682 : : /* Configure RSS for udp4 with src/dst addr and port as input set */
3683 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP) {
3684 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4 |
3685 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3686 : 0 : cfg.hash_flds = ICE_HASH_UDP_IPV4;
3687 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3688 [ # # ]: 0 : if (ret)
3689 : 0 : PMD_DRV_LOG(ERR, "%s UDP_IPV4 rss flow fail %d",
3690 : : __func__, ret);
3691 : : }
3692 : :
3693 : : /* Configure RSS for udp6 with src/dst addr and port as input set */
3694 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP) {
3695 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV6 |
3696 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3697 : 0 : cfg.hash_flds = ICE_HASH_UDP_IPV6;
3698 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3699 [ # # ]: 0 : if (ret)
3700 : 0 : PMD_DRV_LOG(ERR, "%s UDP_IPV6 rss flow fail %d",
3701 : : __func__, ret);
3702 : : }
3703 : :
3704 : : /* Configure RSS for tcp4 with src/dst addr and port as input set */
3705 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_TCP) {
3706 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV4 |
3707 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3708 : 0 : cfg.hash_flds = ICE_HASH_TCP_IPV4;
3709 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3710 [ # # ]: 0 : if (ret)
3711 : 0 : PMD_DRV_LOG(ERR, "%s TCP_IPV4 rss flow fail %d",
3712 : : __func__, ret);
3713 : : }
3714 : :
3715 : : /* Configure RSS for tcp6 with src/dst addr and port as input set */
3716 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP) {
3717 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV6 |
3718 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3719 : 0 : cfg.hash_flds = ICE_HASH_TCP_IPV6;
3720 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3721 [ # # ]: 0 : if (ret)
3722 : 0 : PMD_DRV_LOG(ERR, "%s TCP_IPV6 rss flow fail %d",
3723 : : __func__, ret);
3724 : : }
3725 : :
3726 : : /* Configure RSS for sctp4 with src/dst addr and port as input set */
3727 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_SCTP) {
3728 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV4 |
3729 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3730 : 0 : cfg.hash_flds = ICE_HASH_SCTP_IPV4;
3731 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3732 [ # # ]: 0 : if (ret)
3733 : 0 : PMD_DRV_LOG(ERR, "%s SCTP_IPV4 rss flow fail %d",
3734 : : __func__, ret);
3735 : : }
3736 : :
3737 : : /* Configure RSS for sctp6 with src/dst addr and port as input set */
3738 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_SCTP) {
3739 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV6 |
3740 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3741 : 0 : cfg.hash_flds = ICE_HASH_SCTP_IPV6;
3742 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3743 [ # # ]: 0 : if (ret)
3744 : 0 : PMD_DRV_LOG(ERR, "%s SCTP_IPV6 rss flow fail %d",
3745 : : __func__, ret);
3746 : : }
3747 : :
3748 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV4) {
3749 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_PPPOE | ICE_FLOW_SEG_HDR_IPV4 |
3750 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3751 : 0 : cfg.hash_flds = ICE_FLOW_HASH_IPV4;
3752 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3753 [ # # ]: 0 : if (ret)
3754 : 0 : PMD_DRV_LOG(ERR, "%s PPPoE_IPV4 rss flow fail %d",
3755 : : __func__, ret);
3756 : : }
3757 : :
3758 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6) {
3759 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_PPPOE | ICE_FLOW_SEG_HDR_IPV6 |
3760 : : ICE_FLOW_SEG_HDR_IPV_OTHER;
3761 : 0 : cfg.hash_flds = ICE_FLOW_HASH_IPV6;
3762 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3763 [ # # ]: 0 : if (ret)
3764 : 0 : PMD_DRV_LOG(ERR, "%s PPPoE_IPV6 rss flow fail %d",
3765 : : __func__, ret);
3766 : : }
3767 : :
3768 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP) {
3769 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_PPPOE | ICE_FLOW_SEG_HDR_UDP |
3770 : : ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER;
3771 : 0 : cfg.hash_flds = ICE_HASH_UDP_IPV4;
3772 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3773 [ # # ]: 0 : if (ret)
3774 : 0 : PMD_DRV_LOG(ERR, "%s PPPoE_IPV4_UDP rss flow fail %d",
3775 : : __func__, ret);
3776 : : }
3777 : :
3778 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP) {
3779 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_PPPOE | ICE_FLOW_SEG_HDR_UDP |
3780 : : ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER;
3781 : 0 : cfg.hash_flds = ICE_HASH_UDP_IPV6;
3782 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3783 [ # # ]: 0 : if (ret)
3784 : 0 : PMD_DRV_LOG(ERR, "%s PPPoE_IPV6_UDP rss flow fail %d",
3785 : : __func__, ret);
3786 : : }
3787 : :
3788 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_TCP) {
3789 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_PPPOE | ICE_FLOW_SEG_HDR_TCP |
3790 : : ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER;
3791 : 0 : cfg.hash_flds = ICE_HASH_TCP_IPV4;
3792 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3793 [ # # ]: 0 : if (ret)
3794 : 0 : PMD_DRV_LOG(ERR, "%s PPPoE_IPV4_TCP rss flow fail %d",
3795 : : __func__, ret);
3796 : : }
3797 : :
3798 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP) {
3799 : 0 : cfg.addl_hdrs = ICE_FLOW_SEG_HDR_PPPOE | ICE_FLOW_SEG_HDR_TCP |
3800 : : ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER;
3801 : 0 : cfg.hash_flds = ICE_HASH_TCP_IPV6;
3802 : 0 : ret = ice_add_rss_cfg_wrap(pf, vsi->idx, &cfg);
3803 [ # # ]: 0 : if (ret)
3804 : 0 : PMD_DRV_LOG(ERR, "%s PPPoE_IPV6_TCP rss flow fail %d",
3805 : : __func__, ret);
3806 : : }
3807 : :
3808 : 0 : pf->rss_hf = rss_hf & ICE_RSS_HF_ALL;
3809 : 0 : }
3810 : :
3811 : : static void
3812 : 0 : ice_get_default_rss_key(uint8_t *rss_key, uint32_t rss_key_size)
3813 : : {
3814 : : static struct ice_aqc_get_set_rss_keys default_key;
3815 : : static bool default_key_done;
3816 : : uint8_t *key = (uint8_t *)&default_key;
3817 : : size_t i;
3818 : :
3819 [ # # ]: 0 : if (rss_key_size > sizeof(default_key)) {
3820 : 0 : PMD_DRV_LOG(WARNING,
3821 : : "requested size %u is larger than default %zu, "
3822 : : "only %zu bytes are gotten for key",
3823 : : rss_key_size, sizeof(default_key),
3824 : : sizeof(default_key));
3825 : : }
3826 : :
3827 [ # # ]: 0 : if (!default_key_done) {
3828 : : /* Calculate the default hash key */
3829 [ # # ]: 0 : for (i = 0; i < sizeof(default_key); i++)
3830 : 0 : key[i] = (uint8_t)rte_rand();
3831 : 0 : default_key_done = true;
3832 : : }
3833 : 0 : memcpy(rss_key, key, RTE_MIN(rss_key_size, sizeof(default_key)));
3834 : 0 : }
3835 : :
3836 : 0 : static int ice_init_rss(struct ice_pf *pf)
3837 : : {
3838 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
3839 : 0 : struct ice_vsi *vsi = pf->main_vsi;
3840 : 0 : struct rte_eth_dev_data *dev_data = pf->dev_data;
3841 : : struct ice_aq_get_set_rss_lut_params lut_params;
3842 : : struct rte_eth_rss_conf *rss_conf;
3843 : : struct ice_aqc_get_set_rss_keys key;
3844 : : uint16_t i, nb_q;
3845 : : int ret = 0;
3846 : 0 : bool is_safe_mode = pf->adapter->is_safe_mode;
3847 : : uint32_t reg;
3848 : :
3849 : : rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf;
3850 : 0 : nb_q = dev_data->nb_rx_queues;
3851 : 0 : vsi->rss_key_size = ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE +
3852 : : ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE;
3853 : 0 : vsi->rss_lut_size = pf->hash_lut_size;
3854 : :
3855 [ # # ]: 0 : if (nb_q == 0) {
3856 : 0 : PMD_DRV_LOG(WARNING,
3857 : : "RSS is not supported as rx queues number is zero");
3858 : 0 : return 0;
3859 : : }
3860 : :
3861 [ # # ]: 0 : if (is_safe_mode) {
3862 : 0 : PMD_DRV_LOG(WARNING, "RSS is not supported in safe mode");
3863 : 0 : return 0;
3864 : : }
3865 : :
3866 [ # # ]: 0 : if (!vsi->rss_key) {
3867 : 0 : vsi->rss_key = rte_zmalloc(NULL,
3868 : : vsi->rss_key_size, 0);
3869 [ # # ]: 0 : if (vsi->rss_key == NULL) {
3870 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for rss_key");
3871 : 0 : return -ENOMEM;
3872 : : }
3873 : : }
3874 [ # # ]: 0 : if (!vsi->rss_lut) {
3875 : 0 : vsi->rss_lut = rte_zmalloc(NULL,
3876 : 0 : vsi->rss_lut_size, 0);
3877 [ # # ]: 0 : if (vsi->rss_lut == NULL) {
3878 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for rss_key");
3879 : 0 : rte_free(vsi->rss_key);
3880 : 0 : vsi->rss_key = NULL;
3881 : 0 : return -ENOMEM;
3882 : : }
3883 : : }
3884 : : /* configure RSS key */
3885 [ # # ]: 0 : if (!rss_conf->rss_key)
3886 : 0 : ice_get_default_rss_key(vsi->rss_key, vsi->rss_key_size);
3887 : : else
3888 : 0 : memcpy(vsi->rss_key, rss_conf->rss_key,
3889 : 0 : RTE_MIN(rss_conf->rss_key_len,
3890 : : vsi->rss_key_size));
3891 : :
3892 : 0 : memcpy(key.standard_rss_key, vsi->rss_key,
3893 : : ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);
3894 : : memcpy(key.extended_hash_key,
3895 : : &vsi->rss_key[ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE],
3896 : : ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE);
3897 : 0 : ret = ice_aq_set_rss_key(hw, vsi->idx, &key);
3898 [ # # ]: 0 : if (ret)
3899 : 0 : goto out;
3900 : :
3901 : : /* init RSS LUT table */
3902 [ # # ]: 0 : for (i = 0; i < vsi->rss_lut_size; i++)
3903 : 0 : vsi->rss_lut[i] = i % nb_q;
3904 : :
3905 [ # # # # ]: 0 : if (nb_q <= ICE_RSS_LUT_GLOBAL_QUEUE_NB && (hw)->mac_type == ICE_MAC_E830) {
3906 : : struct ice_vsi_ctx vsi_ctx;
3907 : : uint16_t global_lut;
3908 : :
3909 [ # # ]: 0 : if (!vsi->global_lut_allocated) {
3910 : 0 : ret = ice_alloc_rss_global_lut(hw, false, &global_lut);
3911 [ # # ]: 0 : if (ret)
3912 : 0 : goto out;
3913 : 0 : vsi->global_lut_allocated = true;
3914 : 0 : vsi->global_lut_id = global_lut;
3915 : : }
3916 : 0 : global_lut = vsi->global_lut_id;
3917 : :
3918 : 0 : vsi_ctx.flags = ICE_AQ_VSI_TYPE_PF;
3919 : 0 : vsi_ctx.info = vsi->info;
3920 : 0 : vsi_ctx.info.q_opt_rss &= ICE_AQ_VSI_Q_OPT_RSS_LUT_M |
3921 : : ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M;
3922 : 0 : vsi_ctx.info.q_opt_rss |= ICE_AQ_VSI_Q_OPT_RSS_LUT_GBL |
3923 : 0 : ((global_lut << ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_S) &
3924 : : ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M);
3925 : :
3926 : 0 : vsi_ctx.info.valid_sections =
3927 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_Q_OPT_VALID);
3928 : :
3929 : 0 : ret = ice_update_vsi(hw, vsi->idx, &vsi_ctx, NULL);
3930 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
3931 : 0 : PMD_INIT_LOG(ERR, "update vsi failed, err = %d", ret);
3932 : 0 : goto out;
3933 : : }
3934 : :
3935 : 0 : vsi->info = vsi_ctx.info;
3936 : 0 : lut_params.lut_type = ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_GLOBAL;
3937 : 0 : lut_params.global_lut_id = global_lut;
3938 : : } else {
3939 : 0 : lut_params.lut_type = ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF;
3940 : 0 : lut_params.global_lut_id = 0;
3941 : : }
3942 : :
3943 : 0 : lut_params.vsi_handle = vsi->idx;
3944 : 0 : lut_params.lut_size = vsi->rss_lut_size;
3945 : 0 : lut_params.lut = vsi->rss_lut;
3946 : 0 : ret = ice_aq_set_rss_lut(hw, &lut_params);
3947 [ # # ]: 0 : if (ret)
3948 : 0 : goto out;
3949 : :
3950 : : /* Enable registers for symmetric_toeplitz function. */
3951 : 0 : reg = ICE_READ_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id));
3952 : 0 : reg = (reg & (~VSIQF_HASH_CTL_HASH_SCHEME_M)) |
3953 : : (1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
3954 : 0 : ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
3955 : :
3956 : : /* RSS hash configuration */
3957 : 0 : ice_rss_hash_set(pf, rss_conf->rss_hf);
3958 : :
3959 : 0 : return 0;
3960 : 0 : out:
3961 : 0 : rte_free(vsi->rss_key);
3962 : 0 : vsi->rss_key = NULL;
3963 : 0 : rte_free(vsi->rss_lut);
3964 : 0 : vsi->rss_lut = NULL;
3965 : 0 : return -EINVAL;
3966 : : }
3967 : :
3968 : : static int
3969 : 0 : check_dcb_conf(int is_8_ports, struct rte_eth_dcb_rx_conf *dcb_conf)
3970 : : {
3971 : : uint32_t tc_map = 0;
3972 : : int i;
3973 : :
3974 : 0 : enum rte_eth_nb_tcs nb_tcs = dcb_conf->nb_tcs;
3975 [ # # ]: 0 : if (nb_tcs != RTE_ETH_4_TCS && is_8_ports) {
3976 : 0 : PMD_DRV_LOG(ERR, "Invalid num TCs setting - only 4 TCs are supported");
3977 : 0 : return -1;
3978 [ # # ]: 0 : } else if (nb_tcs != RTE_ETH_4_TCS && nb_tcs != RTE_ETH_8_TCS) {
3979 : 0 : PMD_DRV_LOG(ERR, "Invalid num TCs setting - only 8 TCs or 4 TCs are supported");
3980 : 0 : return -1;
3981 : : }
3982 : :
3983 : : /* Check if associated TC are in continuous range */
3984 [ # # ]: 0 : for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++)
3985 : 0 : tc_map |= 1 << (dcb_conf->dcb_tc[i] & 0x7);
3986 : :
3987 [ # # ]: 0 : if (!rte_is_power_of_2(tc_map + 1)) {
3988 : 0 : PMD_DRV_LOG(ERR,
3989 : : "Bad VLAN User Priority to Traffic Class association in DCB config");
3990 : 0 : return -1;
3991 : : }
3992 : :
3993 : 0 : return rte_popcount32(tc_map);
3994 : : }
3995 : :
3996 : : static int
3997 : 0 : ice_dev_configure(struct rte_eth_dev *dev)
3998 : : {
3999 : 0 : struct ice_adapter *ad =
4000 : 0 : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4001 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4002 : : int ret;
4003 : :
4004 : : /* Initialize to TRUE. If any of Rx queues doesn't meet the
4005 : : * bulk allocation or vector Rx preconditions we will reset it.
4006 : : */
4007 : 0 : ad->rx_bulk_alloc_allowed = true;
4008 : 0 : ad->tx_simple_allowed = true;
4009 : :
4010 : 0 : ad->rx_func_type = ICE_RX_DEFAULT;
4011 : 0 : ad->tx_func_type = ICE_TX_DEFAULT;
4012 : :
4013 : 0 : pf->dcb_num_tcs = 1;
4014 : :
4015 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
4016 : 0 : dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
4017 : :
4018 [ # # ]: 0 : if (dev->data->nb_rx_queues) {
4019 : 0 : ret = ice_init_rss(pf);
4020 [ # # ]: 0 : if (ret) {
4021 : 0 : PMD_DRV_LOG(ERR, "Failed to enable rss for PF");
4022 : 0 : return ret;
4023 : : }
4024 : : }
4025 : :
4026 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_DCB_FLAG) {
4027 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4028 : 0 : struct ice_vsi *vsi = pf->main_vsi;
4029 : 0 : struct ice_port_info *port_info = hw->port_info;
4030 : : struct ice_qos_cfg *qos_cfg = &port_info->qos_cfg;
4031 : 0 : struct ice_dcbx_cfg *local_dcb_conf = &qos_cfg->local_dcbx_cfg;
4032 : : struct ice_vsi_ctx ctxt;
4033 : 0 : struct rte_eth_dcb_rx_conf *dcb_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
4034 : : int i;
4035 : 0 : enum rte_eth_nb_tcs nb_tcs = dcb_conf->nb_tcs;
4036 : : int nb_tc_used, queues_per_tc;
4037 : : uint16_t total_q_nb;
4038 : :
4039 : 0 : nb_tc_used = check_dcb_conf(ice_get_port_max_cgd(hw) == ICE_4_CGD_PER_PORT,
4040 : : dcb_conf);
4041 [ # # ]: 0 : if (nb_tc_used < 0)
4042 : 0 : return -EINVAL;
4043 : :
4044 : 0 : pf->dcb_num_tcs = nb_tc_used;
4045 : :
4046 : 0 : ctxt.info = vsi->info;
4047 [ # # ]: 0 : if (rte_le_to_cpu_16(ctxt.info.mapping_flags) == ICE_AQ_VSI_Q_MAP_NONCONTIG) {
4048 : 0 : PMD_DRV_LOG(ERR, "VSI configured with non contiguous queues, DCB is not supported");
4049 : 0 : return -EINVAL;
4050 : : }
4051 : :
4052 : 0 : total_q_nb = dev->data->nb_rx_queues;
4053 : 0 : queues_per_tc = total_q_nb / nb_tc_used;
4054 [ # # ]: 0 : if (total_q_nb % nb_tc_used != 0) {
4055 : 0 : PMD_DRV_LOG(ERR, "For DCB, number of queues must be evenly divisible by number of used TCs");
4056 : 0 : return -EINVAL;
4057 [ # # ]: 0 : } else if (!rte_is_power_of_2(queues_per_tc)) {
4058 : 0 : PMD_DRV_LOG(ERR, "For DCB, number of queues per TC must be a power of 2");
4059 : 0 : return -EINVAL;
4060 : : }
4061 : :
4062 [ # # ]: 0 : for (i = 0; i < nb_tc_used; i++) {
4063 : 0 : ctxt.info.tc_mapping[i] =
4064 : 0 : rte_cpu_to_le_16(((i * queues_per_tc) << ICE_AQ_VSI_TC_Q_OFFSET_S) |
4065 : : (rte_log2_u32(queues_per_tc) << ICE_AQ_VSI_TC_Q_NUM_S));
4066 : : }
4067 : :
4068 : : memset(local_dcb_conf, 0, sizeof(*local_dcb_conf));
4069 : :
4070 : 0 : local_dcb_conf->etscfg.maxtcs = nb_tcs;
4071 : :
4072 : : /* Associate each VLAN UP with particular TC */
4073 [ # # ]: 0 : for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
4074 : 0 : local_dcb_conf->etscfg.prio_table[i] = dcb_conf->dcb_tc[i];
4075 : 0 : local_dcb_conf->etsrec.prio_table[i] = dcb_conf->dcb_tc[i];
4076 : : }
4077 : :
4078 : : /*
4079 : : * Since current API does not support setting ETS BW Share and Scheduler
4080 : : * configure all TC as ETS and evenly share load across all existing TC
4081 : : **/
4082 : 0 : const int bw_share_percent = 100 / nb_tc_used;
4083 : : const int bw_share_left = 100 - bw_share_percent * nb_tc_used;
4084 [ # # ]: 0 : for (i = 0; i < nb_tc_used; i++) {
4085 : : /* Per TC bandwidth table (all valued must add up to 100%), valid on ETS */
4086 : 0 : local_dcb_conf->etscfg.tcbwtable[i] = bw_share_percent;
4087 : 0 : local_dcb_conf->etsrec.tcbwtable[i] = bw_share_percent;
4088 : :
4089 : : /**< Transmission Selection Algorithm. 0 - Strict prio, 2 - ETS */
4090 : 0 : local_dcb_conf->etscfg.tsatable[i] = 2;
4091 : 0 : local_dcb_conf->etsrec.tsatable[i] = 2;
4092 : : }
4093 : :
4094 [ # # ]: 0 : for (i = 0; i < bw_share_left; i++) {
4095 : 0 : local_dcb_conf->etscfg.tcbwtable[i]++;
4096 : 0 : local_dcb_conf->etsrec.tcbwtable[i]++;
4097 : : }
4098 : :
4099 : 0 : local_dcb_conf->pfc.pfccap = nb_tcs;
4100 : : local_dcb_conf->pfc.pfcena = 0;
4101 : :
4102 : 0 : ret = ice_set_dcb_cfg(port_info);
4103 [ # # ]: 0 : if (ret) {
4104 : 0 : PMD_DRV_LOG(ERR, "Failed to configure DCB for PF");
4105 : 0 : return ret;
4106 : : }
4107 : :
4108 : : /* Update VSI queue allocatios per TC */
4109 : 0 : ctxt.info.valid_sections = rte_cpu_to_le_16(ICE_AQ_VSI_PROP_RXQ_MAP_VALID);
4110 : 0 : ctxt.info.mapping_flags = rte_cpu_to_le_16(ICE_AQ_VSI_Q_MAP_CONTIG);
4111 : :
4112 : 0 : ret = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
4113 [ # # ]: 0 : if (ret) {
4114 : 0 : PMD_DRV_LOG(ERR, "Failed to configure queue mapping");
4115 : 0 : return ret;
4116 : : }
4117 : :
4118 : 0 : ctxt.info.valid_sections = 0;
4119 : 0 : vsi->info = ctxt.info;
4120 : :
4121 : 0 : hw->port_info->fc.current_mode = ICE_FC_PFC;
4122 : : }
4123 : :
4124 : : return 0;
4125 : : }
4126 : :
4127 : : static int
4128 : 0 : ice_get_dcb_info(struct rte_eth_dev *dev, struct rte_eth_dcb_info *dcb_info)
4129 : : {
4130 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4131 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4132 : 0 : struct ice_port_info *port_info = hw->port_info;
4133 : : struct ice_qos_cfg *qos_cfg = &port_info->qos_cfg;
4134 : : struct ice_dcbx_cfg *dcb_conf = &qos_cfg->local_dcbx_cfg;
4135 : 0 : struct ice_vsi *vsi = pf->main_vsi;
4136 : :
4137 [ # # ]: 0 : if (rte_le_to_cpu_16(vsi->info.mapping_flags) == ICE_AQ_VSI_Q_MAP_NONCONTIG) {
4138 : 0 : PMD_DRV_LOG(ERR, "VSI configured with non contiguous queues, DCB is not supported");
4139 : 0 : return -ENOTSUP;
4140 : : }
4141 : :
4142 : 0 : dcb_info->nb_tcs = dcb_conf->etscfg.maxtcs;
4143 [ # # ]: 0 : for (int i = 0; i < dcb_info->nb_tcs; i++) {
4144 : 0 : dcb_info->prio_tc[i] = dcb_conf->etscfg.prio_table[i];
4145 : 0 : dcb_info->tc_bws[i] = dcb_conf->etscfg.tcbwtable[i];
4146 : : /* Using VMDQ pool zero since DCB+VMDQ is not supported */
4147 : 0 : uint16_t tc_rx_q_map = rte_le_to_cpu_16(vsi->info.tc_mapping[i]);
4148 : 0 : dcb_info->tc_queue.tc_rxq[0][i].base = tc_rx_q_map & ICE_AQ_VSI_TC_Q_OFFSET_M;
4149 : 0 : dcb_info->tc_queue.tc_rxq[0][i].nb_queue =
4150 : 0 : 1 << ((tc_rx_q_map & ICE_AQ_VSI_TC_Q_NUM_M) >> ICE_AQ_VSI_TC_Q_NUM_S);
4151 : :
4152 : 0 : dcb_info->tc_queue.tc_txq[0][i].base = dcb_info->tc_queue.tc_rxq[0][i].base;
4153 : 0 : dcb_info->tc_queue.tc_txq[0][i].nb_queue = dcb_info->tc_queue.tc_rxq[0][i].nb_queue;
4154 : : }
4155 : :
4156 : : return 0;
4157 : : }
4158 : :
4159 : : /*
4160 : : * Program a default single-TC local LLDP MIB configuration. All user priorities
4161 : : * map to TC0 at 100% bandwidth.
4162 : : */
4163 : : static void
4164 : 0 : ice_set_dflt_mib(struct rte_eth_dev *dev)
4165 : : {
4166 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4167 : 0 : struct ice_dcbx_cfg dcbcfg = { 0 };
4168 : 0 : uint8_t lldpmib[ICE_LLDPDU_SIZE] = { 0 };
4169 : : uint16_t miblen;
4170 : :
4171 : 0 : dcbcfg.etscfg.willing = 1;
4172 : 0 : dcbcfg.etscfg.maxtcs = hw->func_caps.common_cap.maxtc;
4173 : 0 : dcbcfg.etscfg.tcbwtable[0] = 100;
4174 : 0 : dcbcfg.etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
4175 : 0 : dcbcfg.etsrec = dcbcfg.etscfg;
4176 : 0 : dcbcfg.etsrec.willing = 0;
4177 : 0 : dcbcfg.pfc.willing = 1;
4178 : 0 : dcbcfg.pfc.pfccap = hw->func_caps.common_cap.maxtc;
4179 : :
4180 : 0 : ice_dcb_cfg_to_lldp(lldpmib, &miblen, &dcbcfg, ICE_SET_PFC_SYM);
4181 : :
4182 [ # # ]: 0 : if (ice_aq_set_lldp_mib(hw, SET_LOCAL_MIB_TYPE_LOCAL_MIB, lldpmib, miblen, NULL))
4183 : 0 : PMD_DRV_LOG(ERR, "Failed to set default LLDP MIB");
4184 : 0 : }
4185 : :
4186 : : /* PHY pause advertisement bits for a link flow control mode */
4187 : : static uint8_t
4188 : : ice_fc_mode_to_pause_caps(enum rte_eth_fc_mode mode)
4189 : : {
4190 : : switch (mode) {
4191 : : case RTE_ETH_FC_FULL:
4192 : : return ICE_AQC_PHY_EN_TX_LINK_PAUSE | ICE_AQC_PHY_EN_RX_LINK_PAUSE;
4193 : : case RTE_ETH_FC_TX_PAUSE:
4194 : : return ICE_AQC_PHY_EN_TX_LINK_PAUSE;
4195 : : case RTE_ETH_FC_RX_PAUSE:
4196 : : return ICE_AQC_PHY_EN_RX_LINK_PAUSE;
4197 : : default:
4198 : : return 0;
4199 : : }
4200 : : }
4201 : :
4202 : : static int
4203 : 0 : ice_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4204 : : {
4205 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4206 : 0 : bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
4207 : : struct ice_link_status link_status;
4208 : : bool tx_pause, rx_pause;
4209 : : int ret;
4210 : :
4211 : 0 : ret = ice_get_link_info_safe(pf, enable_lse, &link_status);
4212 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
4213 : 0 : PMD_DRV_LOG(ERR, "Failed to get link info");
4214 : 0 : return -EIO;
4215 : : }
4216 : :
4217 : : /* Last applied request; autoneg and send_xon are never set as they are
4218 : : * not programmed. The mode is the one negotiated with the link partner,
4219 : : * taken from the snapshot rather than the shared port state which the
4220 : : * link event handler updates concurrently.
4221 : : */
4222 : 0 : *fc_conf = pf->fc_conf;
4223 : :
4224 : 0 : tx_pause = (link_status.an_info & ICE_AQ_LINK_PAUSE_TX) != 0;
4225 : 0 : rx_pause = (link_status.an_info & ICE_AQ_LINK_PAUSE_RX) != 0;
4226 [ # # ]: 0 : if (tx_pause && rx_pause)
4227 : 0 : fc_conf->mode = RTE_ETH_FC_FULL;
4228 [ # # ]: 0 : else if (tx_pause)
4229 : 0 : fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
4230 [ # # ]: 0 : else if (rx_pause)
4231 : 0 : fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
4232 : : else
4233 : 0 : fc_conf->mode = RTE_ETH_FC_NONE;
4234 : :
4235 : : return 0;
4236 : : }
4237 : :
4238 : : /*
4239 : : * Program the Rx buffer watermarks, pause quanta and MAC control frame
4240 : : * forwarding shared by link flow control and priority flow control.
4241 : : * A tc_bitmap of 0 selects link flow control; a single bit selects a PFC
4242 : : * traffic class. Watermark or quanta values of 0 leave the current setting.
4243 : : * The only step that can fail is issued first so that on error nothing
4244 : : * has been changed.
4245 : : */
4246 : : static int
4247 : 0 : ice_cfg_fc_params(struct rte_eth_dev *dev, uint8_t tc_bitmap,
4248 : : struct rte_eth_fc_conf *fc_conf)
4249 : : {
4250 : : #define E830_MAC_COMMAND_CONFIG(pi) (((pi)->phy.link_info.link_speed == ICE_AQ_LINK_SPEED_200GB) ? \
4251 : : E830_PRTMAC_200G_COMMAND_CONFIG : E830_PRTMAC_COMMAND_CONFIG)
4252 : :
4253 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4254 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4255 : 0 : struct ice_port_info *port_info = hw->port_info;
4256 [ # # ]: 0 : uint8_t tc = tc_bitmap == 0 ? 0 : rte_ctz32(tc_bitmap);
4257 : 0 : uint32_t high_water = fc_conf->high_water;
4258 : 0 : uint32_t low_water = fc_conf->low_water;
4259 : : uint16_t max_frame_size;
4260 : : int cgd_idx;
4261 : : int ret;
4262 : :
4263 [ # # ]: 0 : if (high_water > ICE_MAC_TC_MAX_WATERMARK)
4264 : : high_water = ICE_MAC_TC_MAX_WATERMARK;
4265 : : if (low_water > ICE_MAC_TC_MAX_WATERMARK)
4266 : : low_water = ICE_MAC_TC_MAX_WATERMARK;
4267 : :
4268 : 0 : fc_conf->high_water = high_water;
4269 : 0 : fc_conf->low_water = low_water;
4270 : :
4271 : 0 : cgd_idx = ice_get_cgd_idx(hw, tc);
4272 [ # # ]: 0 : if (high_water)
4273 : 0 : wr32(hw, GLRPB_TCHW(cgd_idx), high_water);
4274 [ # # ]: 0 : if (low_water)
4275 : 0 : wr32(hw, GLRPB_TCLW(cgd_idx), low_water);
4276 : :
4277 : : /* Update forwarding of the non FC MAC control frames settings */
4278 [ # # ]: 0 : if (hw->mac_type == ICE_MAC_E830) {
4279 [ # # ]: 0 : u32 mac_config = rd32(hw, E830_MAC_COMMAND_CONFIG(port_info));
4280 : :
4281 [ # # ]: 0 : if (fc_conf->mac_ctrl_frame_fwd)
4282 : 0 : mac_config |= E830_PRTMAC_COMMAND_CONFIG_CNTL_FRM_ENA_M;
4283 : : else
4284 : 0 : mac_config &= ~E830_PRTMAC_COMMAND_CONFIG_CNTL_FRM_ENA_M;
4285 : :
4286 [ # # ]: 0 : wr32(hw, E830_MAC_COMMAND_CONFIG(port_info), mac_config);
4287 : : } else {
4288 : 0 : fc_conf->mac_ctrl_frame_fwd = false;
4289 : : }
4290 : :
4291 : : /* Update pause quanta and refresh threshold */
4292 [ # # ]: 0 : max_frame_size = pf->dev_data->mtu ?
4293 : : pf->dev_data->mtu + ICE_ETH_OVERHEAD :
4294 : : ICE_FRAME_SIZE_MAX;
4295 : 0 : ret = ice_aq_set_mac_pfc_cfg(hw, max_frame_size, tc_bitmap,
4296 : 0 : fc_conf->pause_time, ((u32)fc_conf->pause_time + 1) / 2,
4297 : : false, NULL);
4298 [ # # ]: 0 : if (ret)
4299 : 0 : PMD_DRV_LOG(ERR, "Can not update MAC configuration");
4300 : :
4301 : 0 : return ret;
4302 : : }
4303 : :
4304 : : static int
4305 : 0 : ice_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4306 : : {
4307 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4308 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4309 : 0 : struct ice_port_info *pi = hw->port_info;
4310 : 0 : bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
4311 : : struct ice_link_status link_status;
4312 : : enum ice_fc_mode req_mode;
4313 : 0 : struct rte_eth_fc_conf tmp_fc_conf = { 0 };
4314 : : bool link_up;
4315 : : u8 aq_failures;
4316 : : int ret;
4317 : :
4318 : : /* Link flow control and priority flow control are mutually exclusive */
4319 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_DCB_FLAG) {
4320 : 0 : PMD_DRV_LOG(ERR, "Priority flow control is enabled, cannot set link flow control");
4321 : 0 : return -ENOTSUP;
4322 : : }
4323 : :
4324 : 0 : ret = ice_get_link_info_safe(pf, enable_lse, &link_status);
4325 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
4326 : 0 : PMD_DRV_LOG(ERR, "Failed to get link info");
4327 : 0 : return -EIO;
4328 : : }
4329 : 0 : link_up = link_status.link_info & ICE_AQ_LINK_UP;
4330 : :
4331 [ # # ]: 0 : switch (fc_conf->mode) {
4332 : : case RTE_ETH_FC_NONE:
4333 : : req_mode = ICE_FC_NONE;
4334 : : break;
4335 : : case RTE_ETH_FC_RX_PAUSE:
4336 : : req_mode = ICE_FC_RX_PAUSE;
4337 : : break;
4338 : : case RTE_ETH_FC_TX_PAUSE:
4339 : : req_mode = ICE_FC_TX_PAUSE;
4340 : : break;
4341 : : case RTE_ETH_FC_FULL:
4342 : : req_mode = ICE_FC_FULL;
4343 : : break;
4344 : 0 : default:
4345 : 0 : PMD_DRV_LOG(ERR, "Invalid flow control mode %d", fc_conf->mode);
4346 : 0 : return -EINVAL;
4347 : : }
4348 : :
4349 : : /* ice_set_fc() reprograms pause config and, if auto link update is
4350 : : * enabled, restarts the link so the new mode is renegotiated. The
4351 : : * default MIB that configures the pipeline for LFC is reapplied from
4352 : : * the link-up event handler.
4353 : : */
4354 : 0 : pi->fc.req_mode = req_mode;
4355 : 0 : ret = ice_set_fc(pi, &aq_failures, link_up);
4356 [ # # # # ]: 0 : if (ret != 0 && aq_failures != ICE_SET_FC_AQ_FAIL_UPDATE) {
4357 : 0 : PMD_DRV_LOG(ERR, "Failed to set flow control mode, ret %d aq_failures 0x%x",
4358 : : ret, aq_failures);
4359 : 0 : return -EIO;
4360 : : }
4361 : :
4362 : 0 : pf->fc_conf.mode = fc_conf->mode;
4363 : :
4364 : : /* Apply the Rx buffer watermarks and pause quanta. If ice_cfg_fc_params
4365 : : * fails, leaves pause quanta at 0 (keep the current value), since this
4366 : : * is the only place where it may fail. Update watermarks
4367 : : * unconditionally.
4368 : : */
4369 : 0 : tmp_fc_conf = *fc_conf;
4370 : 0 : ret = ice_cfg_fc_params(dev, 0, &tmp_fc_conf);
4371 [ # # ]: 0 : if (ret != 0) {
4372 : 0 : PMD_DRV_LOG(WARNING, "Flow control mode applied, pause parameters left unchanged");
4373 : : } else {
4374 [ # # ]: 0 : if (tmp_fc_conf.pause_time)
4375 : 0 : pf->fc_conf.pause_time = tmp_fc_conf.pause_time;
4376 : : }
4377 [ # # ]: 0 : if (tmp_fc_conf.high_water)
4378 : 0 : pf->fc_conf.high_water = tmp_fc_conf.high_water;
4379 [ # # ]: 0 : if (tmp_fc_conf.low_water)
4380 : 0 : pf->fc_conf.low_water = tmp_fc_conf.low_water;
4381 : 0 : pf->fc_conf.mac_ctrl_frame_fwd = tmp_fc_conf.mac_ctrl_frame_fwd;
4382 : :
4383 : 0 : return 0;
4384 : : }
4385 : :
4386 : : static int
4387 : 0 : ice_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4388 : : {
4389 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4390 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4391 : 0 : struct ice_port_info *port_info = hw->port_info;
4392 : : struct ice_qos_cfg *qos_cfg = &port_info->qos_cfg;
4393 : : struct ice_dcbx_cfg *dcb_conf = &qos_cfg->local_dcbx_cfg;
4394 : 0 : struct rte_eth_fc_conf tmp_fc_conf = { 0 };
4395 : : int ret;
4396 : :
4397 : 0 : dcb_conf->pfc_mode = ICE_QOS_MODE_VLAN;
4398 : 0 : dcb_conf->pfc.willing = 0;
4399 : : /** pfccap should already be set by DCB config, check if zero */
4400 [ # # ]: 0 : if (dcb_conf->pfc.pfccap == 0) {
4401 : 0 : PMD_DRV_LOG(ERR, "DCB is not configured on the port, can not set PFC");
4402 : 0 : return -EINVAL;
4403 : : }
4404 : :
4405 : 0 : ret = ice_aq_set_pfc_mode(hw, ICE_AQC_PFC_VLAN_BASED_PFC, NULL);
4406 [ # # ]: 0 : if (ret) {
4407 : 0 : PMD_DRV_LOG(ERR, "Failed to enable PFC in VLAN mode");
4408 : 0 : return ret;
4409 : : }
4410 : :
4411 : 0 : u8 tc = ice_get_tc_by_priority(hw, pfc_conf->priority);
4412 : :
4413 [ # # # # : 0 : switch (pfc_conf->fc.mode) {
# ]
4414 : 0 : case (RTE_ETH_FC_NONE):
4415 : 0 : dcb_conf->pfc.pfcena &= ~(1 << tc);
4416 : 0 : dcb_conf->pfc.pfcena_asym_rx &= ~(1 << tc);
4417 : 0 : dcb_conf->pfc.pfcena_asym_tx &= ~(1 << tc);
4418 : 0 : break;
4419 : 0 : case (RTE_ETH_FC_RX_PAUSE):
4420 : 0 : dcb_conf->pfc.pfcena &= ~(1 << tc);
4421 : 0 : dcb_conf->pfc.pfcena_asym_rx |= (1 << tc);
4422 : 0 : dcb_conf->pfc.pfcena_asym_tx &= ~(1 << tc);
4423 : 0 : break;
4424 : 0 : case (RTE_ETH_FC_TX_PAUSE):
4425 : 0 : dcb_conf->pfc.pfcena &= ~(1 << tc);
4426 : 0 : dcb_conf->pfc.pfcena_asym_rx &= ~(1 << tc);
4427 : 0 : dcb_conf->pfc.pfcena_asym_tx |= (1 << tc);
4428 : 0 : break;
4429 : 0 : case (RTE_ETH_FC_FULL):
4430 : 0 : dcb_conf->pfc.pfcena |= (1 << tc);
4431 : 0 : dcb_conf->pfc.pfcena_asym_rx &= ~(1 << tc);
4432 : 0 : dcb_conf->pfc.pfcena_asym_tx &= ~(1 << tc);
4433 : 0 : break;
4434 : : }
4435 : :
4436 : 0 : ret = ice_set_dcb_cfg(port_info);
4437 [ # # ]: 0 : if (ret) {
4438 : 0 : PMD_DRV_LOG(ERR, "Failed to configure DCB for PF");
4439 : 0 : return ret;
4440 : : }
4441 : :
4442 : : /* Apply the Rx buffer watermarks and pause quanta for the PFC
4443 : : * traffic class selected by the user priority.
4444 : : */
4445 : 0 : tmp_fc_conf = pfc_conf->fc;
4446 : 0 : ret = ice_cfg_fc_params(dev, 1 << tc, &tmp_fc_conf);
4447 [ # # ]: 0 : if (ret)
4448 : 0 : PMD_DRV_LOG(WARNING, "Flow control mode applied, pause parameters left unchanged");
4449 : :
4450 : : return 0;
4451 : : }
4452 : :
4453 : : static int
4454 : 0 : ice_set_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
4455 : : uint32_t tx_rate)
4456 : : {
4457 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4458 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4459 : 0 : struct ice_vsi *vsi = pf->main_vsi;
4460 : : int ret;
4461 : :
4462 [ # # ]: 0 : if (queue_idx >= dev->data->nb_tx_queues) {
4463 : 0 : PMD_DRV_LOG(ERR, "Tx queue %u is out of range (%u configured)",
4464 : : queue_idx, dev->data->nb_tx_queues);
4465 : 0 : return -EINVAL;
4466 : : }
4467 : :
4468 : : /*
4469 : : * A committed TM hierarchy owns the bandwidth of every scheduler node
4470 : : * and reapplies it on each commit, so the two interfaces are exclusive.
4471 : : */
4472 [ # # ]: 0 : if (pf->tm_conf.committed) {
4473 : 0 : PMD_DRV_LOG(ERR, "Tx rate limit cannot be set while a traffic manager hierarchy is committed");
4474 : 0 : return -EBUSY;
4475 : : }
4476 : :
4477 : : /*
4478 : : * The scheduler node of a Tx queue only exists once the queue has been
4479 : : * added to the Tx scheduler tree, which happens on queue start.
4480 : : */
4481 [ # # ]: 0 : if (dev->data->tx_queue_state[queue_idx] != RTE_ETH_QUEUE_STATE_STARTED) {
4482 : 0 : PMD_DRV_LOG(ERR, "Tx queue %u must be started before setting its rate limit",
4483 : : queue_idx);
4484 : 0 : return -EINVAL;
4485 : : }
4486 : :
4487 : : /* Rate is expressed in Mbps by the API, the scheduler uses Kbps. */
4488 [ # # ]: 0 : if (tx_rate > ICE_SCHED_MAX_BW / 1000) {
4489 : 0 : PMD_DRV_LOG(ERR, "Invalid Tx rate %u Mbps for queue %u, maximum is %u Mbps",
4490 : : tx_rate, queue_idx, (uint32_t)(ICE_SCHED_MAX_BW / 1000));
4491 : 0 : return -EINVAL;
4492 : : }
4493 : :
4494 : : /* A rate of 0 removes the limit and restores the default bandwidth. */
4495 [ # # ]: 0 : if (tx_rate == 0)
4496 : 0 : ret = ice_cfg_q_bw_dflt_lmt(hw->port_info, vsi->idx, 0,
4497 : : queue_idx, ICE_MAX_BW);
4498 : : else
4499 : 0 : ret = ice_cfg_q_bw_lmt(hw->port_info, vsi->idx, 0, queue_idx,
4500 : : ICE_MAX_BW, tx_rate * 1000);
4501 [ # # ]: 0 : if (ret) {
4502 : 0 : PMD_DRV_LOG(ERR, "Failed to set Tx rate limit on queue %u, error %d",
4503 : : queue_idx, ret);
4504 : 0 : return -EIO;
4505 : : }
4506 : :
4507 : : return 0;
4508 : : }
4509 : :
4510 : : /*
4511 : : * Returns the rate limit currently programmed on a Tx queue, 0 if unlimited.
4512 : : * The scheduler caches the requested rate, but that cache outlives the queue
4513 : : * node, which is destroyed on queue stop and recreated with the default
4514 : : * profile, so only trust it while the node still carries a rate limit.
4515 : : */
4516 : : uint32_t
4517 : 0 : ice_txq_rate_limit_kbps(struct ice_pf *pf, uint16_t queue_idx)
4518 : : {
4519 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4520 : : struct ice_sched_node *node;
4521 : : struct ice_q_ctx *q_ctx;
4522 : :
4523 : 0 : q_ctx = ice_get_lan_q_ctx(hw, pf->main_vsi->idx, 0, queue_idx);
4524 [ # # ]: 0 : if (q_ctx == NULL)
4525 : : return 0;
4526 : :
4527 : 0 : node = ice_sched_find_node_by_teid(hw->port_info->root, q_ctx->q_teid);
4528 [ # # ]: 0 : if (node == NULL ||
4529 [ # # ]: 0 : rte_le_to_cpu_16(node->info.data.eir_bw.bw_profile_idx) ==
4530 : : ICE_SCHED_DFLT_RL_PROF_ID)
4531 : : return 0;
4532 : :
4533 : 0 : return q_ctx->bw_t_info.eir_bw.bw;
4534 : : }
4535 : :
4536 : : static int
4537 : 0 : ice_get_queue_rate_limit(struct rte_eth_dev *dev, uint16_t queue_idx,
4538 : : uint32_t *tx_rate)
4539 : : {
4540 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4541 : :
4542 : 0 : *tx_rate = ice_txq_rate_limit_kbps(pf, queue_idx) / 1000;
4543 : :
4544 : 0 : return 0;
4545 : : }
4546 : :
4547 : : static void
4548 : 0 : __vsi_queues_bind_intr(struct ice_vsi *vsi, uint16_t msix_vect,
4549 : : int base_queue, int nb_queue)
4550 : : {
4551 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
4552 : : uint32_t val, val_tx;
4553 : : bool rx_low_latency;
4554 : : int i;
4555 : :
4556 : 0 : rx_low_latency = vsi->adapter->devargs.rx_low_latency;
4557 [ # # ]: 0 : for (i = 0; i < nb_queue; i++) {
4558 : : /*do actual bind*/
4559 : 0 : val = (msix_vect & QINT_RQCTL_MSIX_INDX_M) |
4560 : : (0 << QINT_RQCTL_ITR_INDX_S) | QINT_RQCTL_CAUSE_ENA_M;
4561 : : val_tx = (msix_vect & QINT_TQCTL_MSIX_INDX_M) |
4562 : : (0 << QINT_TQCTL_ITR_INDX_S) | QINT_TQCTL_CAUSE_ENA_M;
4563 : :
4564 : 0 : PMD_DRV_LOG(INFO, "queue %d is binding to vect %d",
4565 : : base_queue + i, msix_vect);
4566 : :
4567 : : /* set ITR0 value */
4568 [ # # ]: 0 : if (rx_low_latency) {
4569 : : /**
4570 : : * Empirical configuration for optimal real time
4571 : : * latency reduced interrupt throttling to 2us
4572 : : */
4573 : 0 : ICE_WRITE_REG(hw, GLINT_ITR(0, msix_vect), 0x1);
4574 : 0 : ICE_WRITE_REG(hw, QRX_ITR(base_queue + i),
4575 : : QRX_ITR_NO_EXPR_M);
4576 : : } else {
4577 : 0 : ICE_WRITE_REG(hw, GLINT_ITR(0, msix_vect), 0x2);
4578 : 0 : ICE_WRITE_REG(hw, QRX_ITR(base_queue + i), 0);
4579 : : }
4580 : :
4581 : 0 : ICE_WRITE_REG(hw, QINT_RQCTL(base_queue + i), val);
4582 : 0 : ICE_WRITE_REG(hw, QINT_TQCTL(base_queue + i), val_tx);
4583 : : }
4584 : 0 : }
4585 : :
4586 : : void
4587 : 0 : ice_vsi_queues_bind_intr(struct ice_vsi *vsi)
4588 : : {
4589 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[vsi->adapter->pf.dev_data->port_id];
4590 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
4591 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
4592 : : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
4593 : 0 : uint16_t msix_vect = vsi->msix_intr;
4594 : 0 : uint16_t nb_msix = RTE_MIN(vsi->nb_msix,
4595 : : rte_intr_nb_efd_get(intr_handle));
4596 : : uint16_t queue_idx = 0;
4597 : : int record = 0;
4598 : : int i;
4599 : :
4600 : : /* clear Rx/Tx queue interrupt */
4601 [ # # ]: 0 : for (i = 0; i < vsi->nb_used_qps; i++) {
4602 : 0 : ICE_WRITE_REG(hw, QINT_TQCTL(vsi->base_queue + i), 0);
4603 : 0 : ICE_WRITE_REG(hw, QINT_RQCTL(vsi->base_queue + i), 0);
4604 : : }
4605 : :
4606 : : /* PF bind interrupt */
4607 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
4608 : : queue_idx = 0;
4609 : : record = 1;
4610 : : }
4611 : :
4612 [ # # ]: 0 : for (i = 0; i < vsi->nb_used_qps; i++) {
4613 [ # # ]: 0 : if (nb_msix <= 1) {
4614 [ # # ]: 0 : if (!rte_intr_allow_others(intr_handle))
4615 : : msix_vect = ICE_MISC_VEC_ID;
4616 : :
4617 : : /* uio mapping all queue to one msix_vect */
4618 : 0 : __vsi_queues_bind_intr(vsi, msix_vect,
4619 : 0 : vsi->base_queue + i,
4620 : 0 : vsi->nb_used_qps - i);
4621 : :
4622 [ # # # # ]: 0 : for (; !!record && i < vsi->nb_used_qps; i++)
4623 : 0 : rte_intr_vec_list_index_set(intr_handle,
4624 : : queue_idx + i, msix_vect);
4625 : :
4626 : : break;
4627 : : }
4628 : :
4629 : : /* vfio 1:1 queue/msix_vect mapping */
4630 : 0 : __vsi_queues_bind_intr(vsi, msix_vect,
4631 : 0 : vsi->base_queue + i, 1);
4632 : :
4633 [ # # ]: 0 : if (!!record)
4634 : 0 : rte_intr_vec_list_index_set(intr_handle,
4635 : : queue_idx + i,
4636 : : msix_vect);
4637 : :
4638 : 0 : msix_vect++;
4639 : 0 : nb_msix--;
4640 : : }
4641 : 0 : }
4642 : :
4643 : : void
4644 : 0 : ice_vsi_enable_queues_intr(struct ice_vsi *vsi)
4645 : : {
4646 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[vsi->adapter->pf.dev_data->port_id];
4647 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
4648 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
4649 : : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
4650 : : uint16_t msix_intr, i;
4651 : :
4652 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
4653 [ # # ]: 0 : for (i = 0; i < vsi->nb_used_qps; i++) {
4654 : 0 : msix_intr = vsi->msix_intr + i;
4655 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(msix_intr),
4656 : : GLINT_DYN_CTL_INTENA_M |
4657 : : GLINT_DYN_CTL_CLEARPBA_M |
4658 : : GLINT_DYN_CTL_ITR_INDX_M |
4659 : : GLINT_DYN_CTL_WB_ON_ITR_M);
4660 : : }
4661 : : else
4662 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(0),
4663 : : GLINT_DYN_CTL_INTENA_M |
4664 : : GLINT_DYN_CTL_CLEARPBA_M |
4665 : : GLINT_DYN_CTL_ITR_INDX_M |
4666 : : GLINT_DYN_CTL_WB_ON_ITR_M);
4667 : 0 : }
4668 : :
4669 : : static int
4670 : 0 : ice_rxq_intr_setup(struct rte_eth_dev *dev)
4671 : : {
4672 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4673 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
4674 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
4675 : 0 : struct ice_vsi *vsi = pf->main_vsi;
4676 : : uint32_t intr_vector = 0;
4677 : :
4678 : 0 : rte_intr_disable(intr_handle);
4679 : :
4680 : : /* check and configure queue intr-vector mapping */
4681 [ # # ]: 0 : if ((rte_intr_cap_multiple(intr_handle) ||
4682 [ # # ]: 0 : !RTE_ETH_DEV_SRIOV(dev).active) &&
4683 [ # # ]: 0 : dev->data->dev_conf.intr_conf.rxq != 0) {
4684 : 0 : intr_vector = dev->data->nb_rx_queues;
4685 [ # # ]: 0 : if (intr_vector > ICE_MAX_INTR_QUEUE_NUM) {
4686 : 0 : PMD_DRV_LOG(ERR, "At most %d intr queues supported",
4687 : : ICE_MAX_INTR_QUEUE_NUM);
4688 : 0 : return -ENOTSUP;
4689 : : }
4690 [ # # ]: 0 : if (rte_intr_efd_enable(intr_handle, intr_vector))
4691 : : return -1;
4692 : : }
4693 : :
4694 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
4695 [ # # ]: 0 : if (rte_intr_vec_list_alloc(intr_handle, NULL,
4696 : 0 : dev->data->nb_rx_queues)) {
4697 : 0 : PMD_DRV_LOG(ERR,
4698 : : "Failed to allocate %d rx_queues intr_vec",
4699 : : dev->data->nb_rx_queues);
4700 : 0 : return -ENOMEM;
4701 : : }
4702 : : }
4703 : :
4704 : : /* Map queues with MSIX interrupt */
4705 : 0 : vsi->nb_used_qps = dev->data->nb_rx_queues;
4706 : 0 : ice_vsi_queues_bind_intr(vsi);
4707 : :
4708 : : /* Enable interrupts for all the queues */
4709 : 0 : ice_vsi_enable_queues_intr(vsi);
4710 : :
4711 : 0 : rte_intr_enable(intr_handle);
4712 : :
4713 : 0 : return 0;
4714 : : }
4715 : :
4716 : : static int
4717 : 0 : ice_get_link_info_safe(struct ice_pf *pf, bool ena_lse,
4718 : : struct ice_link_status *link)
4719 : : {
4720 : 0 : struct ice_hw *hw = ICE_PF_TO_HW(pf);
4721 : : int ret;
4722 : :
4723 : 0 : rte_spinlock_lock(&pf->link_lock);
4724 : :
4725 : 0 : ret = ice_aq_get_link_info(hw->port_info, ena_lse, link, NULL);
4726 : :
4727 : : rte_spinlock_unlock(&pf->link_lock);
4728 : :
4729 : 0 : return ret;
4730 : : }
4731 : :
4732 : : static void
4733 : 0 : ice_get_init_link_status(struct rte_eth_dev *dev)
4734 : : {
4735 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4736 : 0 : bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
4737 : : struct ice_link_status link_status;
4738 : : int ret;
4739 : :
4740 : 0 : ret = ice_get_link_info_safe(pf, enable_lse, &link_status);
4741 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
4742 : 0 : PMD_DRV_LOG(ERR, "Failed to get link info");
4743 : 0 : pf->init_link_up = false;
4744 : 0 : return;
4745 : : }
4746 : :
4747 [ # # ]: 0 : if (link_status.link_info & ICE_AQ_LINK_UP)
4748 : 0 : pf->init_link_up = true;
4749 : : else
4750 : 0 : pf->init_link_up = false;
4751 : : }
4752 : :
4753 : : static int
4754 : 0 : ice_pps_out_cfg(struct ice_hw *hw, int idx, int timer)
4755 : : {
4756 : : uint64_t current_time, start_time;
4757 : : uint32_t hi, lo, lo2, func, val;
4758 : :
4759 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(timer));
4760 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(timer));
4761 : 0 : lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(timer));
4762 : :
4763 [ # # ]: 0 : if (lo2 < lo) {
4764 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(timer));
4765 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(timer));
4766 : : }
4767 : :
4768 : 0 : current_time = ((uint64_t)hi << 32) | lo;
4769 : :
4770 : 0 : start_time = (current_time + NSEC_PER_SEC) /
4771 : : NSEC_PER_SEC * NSEC_PER_SEC;
4772 : 0 : start_time = start_time - PPS_OUT_DELAY_NS;
4773 : :
4774 : 0 : func = 8 + idx + timer * 4;
4775 : 0 : val = GLGEN_GPIO_CTL_PIN_DIR_M |
4776 : 0 : ((func << GLGEN_GPIO_CTL_PIN_FUNC_S) &
4777 : : GLGEN_GPIO_CTL_PIN_FUNC_M);
4778 : :
4779 : : /* Write clkout with half of period value */
4780 : 0 : ICE_WRITE_REG(hw, GLTSYN_CLKO(idx, timer), NSEC_PER_SEC / 2);
4781 : :
4782 : : /* Write TARGET time register */
4783 : 0 : ICE_WRITE_REG(hw, GLTSYN_TGT_L(idx, timer), start_time & 0xffffffff);
4784 : 0 : ICE_WRITE_REG(hw, GLTSYN_TGT_H(idx, timer), start_time >> 32);
4785 : :
4786 : : /* Write AUX_OUT register */
4787 : 0 : ICE_WRITE_REG(hw, GLTSYN_AUX_OUT(idx, timer),
4788 : : GLTSYN_AUX_OUT_0_OUT_ENA_M | GLTSYN_AUX_OUT_0_OUTMOD_M);
4789 : :
4790 : : /* Write GPIO CTL register */
4791 : 0 : ICE_WRITE_REG(hw, GLGEN_GPIO_CTL(idx), val);
4792 : :
4793 : 0 : return 0;
4794 : : }
4795 : :
4796 : : static int
4797 : 0 : ice_dev_start(struct rte_eth_dev *dev)
4798 : : {
4799 : 0 : struct rte_eth_dev_data *data = dev->data;
4800 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4801 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4802 : 0 : struct ice_vsi *vsi = pf->main_vsi;
4803 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
4804 : : struct ice_adapter *ad =
4805 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4806 : : uint16_t nb_rxq = 0;
4807 : : uint16_t nb_txq, i;
4808 : : uint16_t max_frame_size;
4809 : : int mask, ret;
4810 : 0 : uint8_t timer = hw->func_caps.ts_func_info.tmr_index_owned;
4811 : 0 : uint32_t pin_idx = ad->devargs.pin_idx;
4812 : : ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
4813 : : ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
4814 : :
4815 : : /* choose vector Tx function before starting queues */
4816 : 0 : ice_set_tx_function(dev);
4817 : :
4818 : : /* program Tx queues' context in hardware */
4819 [ # # ]: 0 : for (nb_txq = 0; nb_txq < data->nb_tx_queues; nb_txq++) {
4820 : 0 : ret = ice_tx_queue_start(dev, nb_txq);
4821 [ # # ]: 0 : if (ret) {
4822 : 0 : PMD_DRV_LOG(ERR, "fail to start Tx queue %u", nb_txq);
4823 : 0 : goto tx_err;
4824 : : }
4825 : : }
4826 : :
4827 : : /* program Rx queues' context in hardware*/
4828 [ # # ]: 0 : for (nb_rxq = 0; nb_rxq < data->nb_rx_queues; nb_rxq++) {
4829 : 0 : ret = ice_rx_queue_start(dev, nb_rxq);
4830 [ # # ]: 0 : if (ret) {
4831 : 0 : PMD_DRV_LOG(ERR, "fail to start Rx queue %u", nb_rxq);
4832 : 0 : goto rx_err;
4833 : : }
4834 : : }
4835 : :
4836 : : /* we need to choose Rx fn after queue start, when we know if we need scattered Rx */
4837 : 0 : ice_set_rx_function(dev);
4838 : :
4839 : : mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
4840 : : RTE_ETH_VLAN_EXTEND_MASK;
4841 [ # # ]: 0 : if (ice_is_dvm_ena(hw))
4842 : : mask |= RTE_ETH_QINQ_STRIP_MASK;
4843 : :
4844 : 0 : ret = ice_vlan_offload_set(dev, mask);
4845 [ # # ]: 0 : if (ret) {
4846 : 0 : PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
4847 : 0 : goto rx_err;
4848 : : }
4849 : :
4850 : : /* enable Rx interrupt and mapping Rx queue to interrupt vector */
4851 [ # # ]: 0 : if (ice_rxq_intr_setup(dev))
4852 : : return -EIO;
4853 : :
4854 : : /* Fall back to polling the AdminQ via an alarm on platforms where
4855 : : * interrupt delivery is unavailable.
4856 : : */
4857 [ # # ]: 0 : if (rte_intr_enable(pci_dev->intr_handle) != 0) {
4858 [ # # ]: 0 : if (rte_eal_alarm_set(ICE_AQ_ALARM_INTERVAL, ice_aq_alarm_handler, dev) != 0)
4859 : 0 : PMD_DRV_LOG(WARNING, "Failed to set alarm for AdminQ polling");
4860 : : else
4861 : 0 : pf->use_aq_polling = true;
4862 : : }
4863 : :
4864 : : /* Enable receiving broadcast packets and transmitting packets */
4865 : : ice_set_bit(ICE_PROMISC_BCAST_RX, pmask);
4866 : : ice_set_bit(ICE_PROMISC_BCAST_TX, pmask);
4867 : : ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
4868 : : ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
4869 : :
4870 : 0 : ret = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
4871 [ # # ]: 0 : if (ret != ICE_SUCCESS)
4872 : 0 : PMD_DRV_LOG(INFO, "fail to set vsi broadcast");
4873 : :
4874 : 0 : ret = ice_aq_set_event_mask(hw, hw->port_info->lport,
4875 : : ((u16)(ICE_AQ_LINK_EVENT_LINK_FAULT |
4876 : : ICE_AQ_LINK_EVENT_PHY_TEMP_ALARM |
4877 : : ICE_AQ_LINK_EVENT_EXCESSIVE_ERRORS |
4878 : : ICE_AQ_LINK_EVENT_SIGNAL_DETECT |
4879 : : ICE_AQ_LINK_EVENT_AN_COMPLETED |
4880 : : ICE_AQ_LINK_EVENT_PORT_TX_SUSPENDED)),
4881 : : NULL);
4882 [ # # ]: 0 : if (ret != ICE_SUCCESS)
4883 : 0 : PMD_DRV_LOG(WARNING, "Fail to set phy mask");
4884 : :
4885 : 0 : ice_get_init_link_status(dev);
4886 : :
4887 : : ice_dev_set_link_up(dev);
4888 : :
4889 : : /* Call get_link_info aq command to enable/disable LSE */
4890 : 0 : ice_link_update(dev, 0);
4891 : :
4892 : 0 : pf->adapter_stopped = false;
4893 : :
4894 : : /* Set the max frame size to default value*/
4895 [ # # ]: 0 : max_frame_size = pf->dev_data->mtu ?
4896 : : pf->dev_data->mtu + ICE_ETH_OVERHEAD :
4897 : : ICE_FRAME_SIZE_MAX;
4898 : :
4899 : : /* Set the max frame size to HW*/
4900 : 0 : ice_aq_set_mac_cfg(hw, max_frame_size, false, NULL);
4901 : :
4902 [ # # ]: 0 : if (ad->devargs.pps_out_ena) {
4903 : 0 : ret = ice_pps_out_cfg(hw, pin_idx, timer);
4904 [ # # ]: 0 : if (ret) {
4905 : 0 : PMD_DRV_LOG(ERR, "Fail to configure 1pps out");
4906 : 0 : goto rx_err;
4907 : : }
4908 : : }
4909 : :
4910 [ # # ]: 0 : if (dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
4911 : 0 : ice_timesync_enable(dev);
4912 : 0 : ad->txpp_ena = 1;
4913 : : }
4914 : :
4915 : : return 0;
4916 : :
4917 : : /* stop the started queues if failed to start all queues */
4918 : 0 : rx_err:
4919 [ # # ]: 0 : for (i = 0; i < nb_rxq; i++)
4920 : 0 : ice_rx_queue_stop(dev, i);
4921 : 0 : tx_err:
4922 [ # # ]: 0 : for (i = 0; i < nb_txq; i++)
4923 : 0 : ice_tx_queue_stop(dev, i);
4924 : :
4925 : 0 : pf->adapter_stopped = true;
4926 : :
4927 : 0 : return -EIO;
4928 : : }
4929 : :
4930 : : static int
4931 : 0 : ice_dev_reset(struct rte_eth_dev *dev)
4932 : : {
4933 : : int ret;
4934 : :
4935 [ # # ]: 0 : if (dev->data->sriov.active)
4936 : : return -ENOTSUP;
4937 : :
4938 : : ret = ice_dev_uninit(dev);
4939 : : if (ret) {
4940 : : PMD_INIT_LOG(ERR, "failed to uninit device, status = %d", ret);
4941 : : return -ENXIO;
4942 : : }
4943 : :
4944 : 0 : ret = ice_dev_init(dev);
4945 [ # # ]: 0 : if (ret) {
4946 : 0 : PMD_INIT_LOG(ERR, "failed to init device, status = %d", ret);
4947 : 0 : return -ENXIO;
4948 : : }
4949 : :
4950 : : return 0;
4951 : : }
4952 : :
4953 : : static int
4954 : 0 : ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
4955 : : {
4956 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4957 : : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4958 : 0 : struct ice_vsi *vsi = pf->main_vsi;
4959 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
4960 : 0 : bool is_safe_mode = pf->adapter->is_safe_mode;
4961 : : u64 phy_type_low;
4962 : : u64 phy_type_high;
4963 : :
4964 : 0 : dev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN;
4965 : 0 : dev_info->max_rx_pktlen = ICE_FRAME_SIZE_MAX;
4966 : 0 : dev_info->max_rx_queues = vsi->nb_rxqs;
4967 : 0 : dev_info->max_tx_queues = vsi->nb_txqs;
4968 : 0 : dev_info->max_mac_addrs = vsi->max_macaddrs;
4969 : 0 : dev_info->max_vfs = pci_dev->max_vfs;
4970 : 0 : dev_info->max_mtu = dev_info->max_rx_pktlen - ICE_ETH_OVERHEAD;
4971 : 0 : dev_info->min_mtu = RTE_ETHER_MIN_MTU;
4972 : :
4973 : 0 : dev_info->rx_offload_capa =
4974 : : RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
4975 : : RTE_ETH_RX_OFFLOAD_KEEP_CRC |
4976 : : RTE_ETH_RX_OFFLOAD_SCATTER |
4977 : : RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
4978 : 0 : dev_info->tx_offload_capa =
4979 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
4980 : : RTE_ETH_TX_OFFLOAD_TCP_TSO |
4981 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
4982 : : RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
4983 : 0 : dev_info->flow_type_rss_offloads = 0;
4984 : :
4985 [ # # ]: 0 : if (!is_safe_mode) {
4986 : 0 : dev_info->rx_offload_capa = ICE_RX_SCALAR_OFFLOADS |
4987 : : ICE_RX_VECTOR_OFFLOADS | ICE_RX_VECTOR_OFFLOAD_OFFLOADS;
4988 : 0 : dev_info->tx_offload_capa = ICE_TX_SCALAR_OFFLOADS |
4989 : : CI_TX_VECTOR_OFFLOADS | CI_TX_VEC_OFFLOAD_PATH_OFFLOADS |
4990 : : CI_TX_VEC_CTX_OFFLOAD_PATH_OFFLOADS;
4991 [ # # ]: 0 : if (hw->phy_model != ICE_PHY_E830)
4992 : 0 : dev_info->tx_offload_capa &= ~RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP;
4993 : 0 : dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
4994 : : }
4995 : :
4996 : 0 : dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
4997 : 0 : dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
4998 : :
4999 : 0 : dev_info->reta_size = pf->hash_lut_size;
5000 : 0 : dev_info->hash_key_size = (VSIQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t);
5001 : :
5002 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
5003 : : .rx_thresh = {
5004 : : .pthresh = ICE_DEFAULT_RX_PTHRESH,
5005 : : .hthresh = ICE_DEFAULT_RX_HTHRESH,
5006 : : .wthresh = ICE_DEFAULT_RX_WTHRESH,
5007 : : },
5008 : : .rx_free_thresh = ICE_DEFAULT_RX_FREE_THRESH,
5009 : : .rx_drop_en = 0,
5010 : : .offloads = 0,
5011 : : };
5012 : :
5013 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
5014 : : .tx_thresh = {
5015 : : .pthresh = ICE_DEFAULT_TX_PTHRESH,
5016 : : .hthresh = ICE_DEFAULT_TX_HTHRESH,
5017 : : .wthresh = ICE_DEFAULT_TX_WTHRESH,
5018 : : },
5019 : : .tx_free_thresh = ICE_DEFAULT_TX_FREE_THRESH,
5020 : : .tx_rs_thresh = ICE_DEFAULT_TX_RSBIT_THRESH,
5021 : : .offloads = 0,
5022 : : };
5023 : :
5024 : 0 : dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
5025 [ # # ]: 0 : .nb_max = ICE_MAX_NUM_DESC_BY_MAC(hw),
5026 : : .nb_min = ICE_MIN_RING_DESC,
5027 : : .nb_align = ICE_ALIGN_RING_DESC,
5028 : : };
5029 : :
5030 : 0 : dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
5031 : : .nb_max = ICE_MAX_NUM_DESC_BY_MAC(hw),
5032 : : .nb_min = ICE_MIN_RING_DESC,
5033 : : .nb_align = ICE_ALIGN_RING_DESC,
5034 : : .nb_mtu_seg_max = ICE_TX_MTU_SEG_MAX,
5035 : : .nb_seg_max = ICE_MAX_NUM_DESC_BY_MAC(hw),
5036 : : };
5037 : :
5038 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M |
5039 : : RTE_ETH_LINK_SPEED_100M |
5040 : : RTE_ETH_LINK_SPEED_1G |
5041 : : RTE_ETH_LINK_SPEED_2_5G |
5042 : : RTE_ETH_LINK_SPEED_5G |
5043 : : RTE_ETH_LINK_SPEED_10G |
5044 : : RTE_ETH_LINK_SPEED_20G |
5045 : : RTE_ETH_LINK_SPEED_25G;
5046 : :
5047 : 0 : phy_type_low = hw->port_info->phy.phy_type_low;
5048 : 0 : phy_type_high = hw->port_info->phy.phy_type_high;
5049 : :
5050 [ # # ]: 0 : if (ICE_PHY_TYPE_SUPPORT_50G(phy_type_low))
5051 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_50G;
5052 : :
5053 [ # # # # ]: 0 : if (ICE_PHY_TYPE_SUPPORT_100G_LOW(phy_type_low) ||
5054 [ # # ]: 0 : ICE_PHY_TYPE_SUPPORT_100G_HIGH(phy_type_high))
5055 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_100G;
5056 : :
5057 [ # # ]: 0 : if (ICE_PHY_TYPE_SUPPORT_200G_HIGH(phy_type_high))
5058 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_200G;
5059 : :
5060 : 0 : dev_info->nb_rx_queues = dev->data->nb_rx_queues;
5061 : 0 : dev_info->nb_tx_queues = dev->data->nb_tx_queues;
5062 : :
5063 : 0 : dev_info->default_rxportconf.burst_size = ICE_RX_MAX_BURST;
5064 : 0 : dev_info->default_txportconf.burst_size = ICE_TX_MAX_BURST;
5065 : 0 : dev_info->default_rxportconf.nb_queues = 1;
5066 : 0 : dev_info->default_txportconf.nb_queues = 1;
5067 : 0 : dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
5068 : 0 : dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
5069 : :
5070 : 0 : dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
5071 : 0 : dev_info->rx_seg_capa.multi_pools = 1;
5072 : 0 : dev_info->rx_seg_capa.offset_allowed = 0;
5073 : 0 : dev_info->rx_seg_capa.offset_align_log2 = 0;
5074 : :
5075 : 0 : return 0;
5076 : : }
5077 : :
5078 : : static inline int
5079 : 0 : ice_atomic_read_link_status(struct rte_eth_dev *dev,
5080 : : struct rte_eth_link *link)
5081 : : {
5082 : : struct rte_eth_link *dst = link;
5083 : 0 : struct rte_eth_link *src = &dev->data->dev_link;
5084 : :
5085 : : /* NOTE: review for potential ordering optimization */
5086 [ # # ]: 0 : if (!rte_atomic_compare_exchange_strong_explicit((uint64_t __rte_atomic *)dst,
5087 : : (uint64_t *)dst, *(uint64_t *)src,
5088 : : rte_memory_order_seq_cst, rte_memory_order_seq_cst))
5089 : 0 : return -1;
5090 : :
5091 : : return 0;
5092 : : }
5093 : :
5094 : : static inline int
5095 : 0 : ice_atomic_write_link_status(struct rte_eth_dev *dev,
5096 : : struct rte_eth_link *link)
5097 : : {
5098 : 0 : struct rte_eth_link *dst = &dev->data->dev_link;
5099 : : struct rte_eth_link *src = link;
5100 : :
5101 : : /* NOTE: review for potential ordering optimization */
5102 [ # # ]: 0 : if (!rte_atomic_compare_exchange_strong_explicit((uint64_t __rte_atomic *)dst,
5103 : : (uint64_t *)dst, *(uint64_t *)src,
5104 : : rte_memory_order_seq_cst, rte_memory_order_seq_cst))
5105 : 0 : return -1;
5106 : :
5107 : : return 0;
5108 : : }
5109 : :
5110 : : static int
5111 : 0 : ice_link_update(struct rte_eth_dev *dev, int wait_to_complete)
5112 : : {
5113 : : #define CHECK_INTERVAL 50 /* 50ms */
5114 : : #define MAX_REPEAT_TIME 40 /* 2s (40 * 50ms) in total */
5115 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5116 : : struct ice_link_status link_status;
5117 : : struct rte_eth_link link, old;
5118 : : int status;
5119 : : unsigned int rep_cnt = MAX_REPEAT_TIME;
5120 : 0 : bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
5121 : :
5122 : : memset(&link, 0, sizeof(link));
5123 : : memset(&old, 0, sizeof(old));
5124 : : memset(&link_status, 0, sizeof(link_status));
5125 : 0 : ice_atomic_read_link_status(dev, &old);
5126 : :
5127 : : do {
5128 : : /* Get link status information from hardware */
5129 : 0 : status = ice_get_link_info_safe(pf, enable_lse, &link_status);
5130 [ # # ]: 0 : if (status != ICE_SUCCESS) {
5131 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
5132 : 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
5133 : 0 : PMD_DRV_LOG(ERR, "Failed to get link info");
5134 : 0 : goto out;
5135 : : }
5136 : :
5137 : 0 : link.link_status = link_status.link_info & ICE_AQ_LINK_UP;
5138 [ # # # # ]: 0 : if (!wait_to_complete || link.link_status)
5139 : : break;
5140 : :
5141 : : rte_delay_ms(CHECK_INTERVAL);
5142 [ # # ]: 0 : } while (--rep_cnt);
5143 : :
5144 [ # # ]: 0 : if (!link.link_status)
5145 : 0 : goto out;
5146 : :
5147 : : /* Full-duplex operation at all supported speeds */
5148 : 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
5149 : :
5150 : : /* Parse the link status */
5151 [ # # # # : 0 : switch (link_status.link_speed) {
# # # # #
# # # #
# ]
5152 : 0 : case ICE_AQ_LINK_SPEED_10MB:
5153 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_10M;
5154 : 0 : break;
5155 : 0 : case ICE_AQ_LINK_SPEED_100MB:
5156 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
5157 : 0 : break;
5158 : 0 : case ICE_AQ_LINK_SPEED_1000MB:
5159 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_1G;
5160 : 0 : break;
5161 : 0 : case ICE_AQ_LINK_SPEED_2500MB:
5162 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_2_5G;
5163 : 0 : break;
5164 : 0 : case ICE_AQ_LINK_SPEED_5GB:
5165 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_5G;
5166 : 0 : break;
5167 : 0 : case ICE_AQ_LINK_SPEED_10GB:
5168 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_10G;
5169 : 0 : break;
5170 : 0 : case ICE_AQ_LINK_SPEED_20GB:
5171 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_20G;
5172 : 0 : break;
5173 : 0 : case ICE_AQ_LINK_SPEED_25GB:
5174 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_25G;
5175 : 0 : break;
5176 : 0 : case ICE_AQ_LINK_SPEED_40GB:
5177 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_40G;
5178 : 0 : break;
5179 : 0 : case ICE_AQ_LINK_SPEED_50GB:
5180 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_50G;
5181 : 0 : break;
5182 : 0 : case ICE_AQ_LINK_SPEED_100GB:
5183 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100G;
5184 : 0 : break;
5185 : 0 : case ICE_AQ_LINK_SPEED_200GB:
5186 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_200G;
5187 : 0 : break;
5188 : 0 : case ICE_AQ_LINK_SPEED_UNKNOWN:
5189 : 0 : PMD_DRV_LOG(ERR, "Unknown link speed");
5190 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_UNKNOWN;
5191 : 0 : break;
5192 : 0 : default:
5193 : 0 : PMD_DRV_LOG(ERR, "None link speed");
5194 : : link.link_speed = RTE_ETH_SPEED_NUM_NONE;
5195 : 0 : break;
5196 : : }
5197 : :
5198 : 0 : link.link_autoneg = !(dev->data->dev_conf.link_speeds &
5199 : : RTE_ETH_LINK_SPEED_FIXED);
5200 : :
5201 : 0 : out:
5202 : 0 : ice_atomic_write_link_status(dev, &link);
5203 [ # # ]: 0 : if (link.link_status == old.link_status)
5204 : 0 : return -1;
5205 : :
5206 : : return 0;
5207 : : }
5208 : :
5209 : : static inline uint16_t
5210 : 0 : ice_parse_link_speeds(uint16_t link_speeds)
5211 : : {
5212 : : uint16_t link_speed = ICE_AQ_LINK_SPEED_UNKNOWN;
5213 : :
5214 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_200G)
5215 : : link_speed |= ICE_AQ_LINK_SPEED_200GB;
5216 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_100G)
5217 : 0 : link_speed |= ICE_AQ_LINK_SPEED_100GB;
5218 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_50G)
5219 : 0 : link_speed |= ICE_AQ_LINK_SPEED_50GB;
5220 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_40G)
5221 : 0 : link_speed |= ICE_AQ_LINK_SPEED_40GB;
5222 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_25G)
5223 : 0 : link_speed |= ICE_AQ_LINK_SPEED_25GB;
5224 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_20G)
5225 : 0 : link_speed |= ICE_AQ_LINK_SPEED_20GB;
5226 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_10G)
5227 : 0 : link_speed |= ICE_AQ_LINK_SPEED_10GB;
5228 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_5G)
5229 : 0 : link_speed |= ICE_AQ_LINK_SPEED_5GB;
5230 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_2_5G)
5231 : 0 : link_speed |= ICE_AQ_LINK_SPEED_2500MB;
5232 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_1G)
5233 : 0 : link_speed |= ICE_AQ_LINK_SPEED_1000MB;
5234 [ # # ]: 0 : if (link_speeds & RTE_ETH_LINK_SPEED_100M)
5235 : 0 : link_speed |= ICE_AQ_LINK_SPEED_100MB;
5236 : :
5237 : 0 : return link_speed;
5238 : : }
5239 : :
5240 : : static int
5241 : 0 : ice_apply_link_speed(struct rte_eth_dev *dev)
5242 : : {
5243 : : uint16_t speed;
5244 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5245 : : struct rte_eth_conf *conf = &dev->data->dev_conf;
5246 : :
5247 [ # # ]: 0 : if (conf->link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
5248 : 0 : conf->link_speeds = RTE_ETH_LINK_SPEED_200G |
5249 : : RTE_ETH_LINK_SPEED_100G |
5250 : : RTE_ETH_LINK_SPEED_50G |
5251 : : RTE_ETH_LINK_SPEED_40G |
5252 : : RTE_ETH_LINK_SPEED_25G |
5253 : : RTE_ETH_LINK_SPEED_20G |
5254 : : RTE_ETH_LINK_SPEED_10G |
5255 : : RTE_ETH_LINK_SPEED_5G |
5256 : : RTE_ETH_LINK_SPEED_2_5G |
5257 : : RTE_ETH_LINK_SPEED_1G |
5258 : : RTE_ETH_LINK_SPEED_100M;
5259 : : }
5260 : 0 : speed = ice_parse_link_speeds(conf->link_speeds);
5261 [ # # ]: 0 : if (speed == ICE_AQ_LINK_SPEED_UNKNOWN) {
5262 : 0 : PMD_DRV_LOG(ERR, "No valid link speed setting specified");
5263 : 0 : return -EINVAL;
5264 : : }
5265 : :
5266 : 0 : bool link_autoneg = (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) == 0;
5267 : 0 : return ice_phy_conf_link(hw, speed, true, link_autoneg);
5268 : : }
5269 : :
5270 : : static int
5271 : 0 : ice_phy_conf_link(struct ice_hw *hw,
5272 : : u16 link_speeds_bitmap,
5273 : : bool link_up,
5274 : : bool link_autoneg)
5275 : : {
5276 : 0 : struct ice_aqc_set_phy_cfg_data cfg = { 0 };
5277 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(hw->back);
5278 : 0 : struct ice_port_info *pi = hw->port_info;
5279 : : struct ice_aqc_get_phy_caps_data *phy_caps;
5280 : : int err;
5281 : 0 : u64 phy_type_low = 0;
5282 : 0 : u64 phy_type_high = 0;
5283 : :
5284 [ # # ]: 0 : if (!pi)
5285 : : return -EIO;
5286 : :
5287 : : phy_caps = (struct ice_aqc_get_phy_caps_data *)
5288 : 0 : ice_malloc(hw, sizeof(*phy_caps));
5289 [ # # ]: 0 : if (!phy_caps)
5290 : : return ICE_ERR_NO_MEMORY;
5291 : :
5292 : :
5293 [ # # ]: 0 : if (ice_fw_supports_report_dflt_cfg(pi->hw))
5294 : 0 : err = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_DFLT_CFG,
5295 : : phy_caps, NULL);
5296 : : else
5297 : 0 : err = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
5298 : : phy_caps, NULL);
5299 [ # # ]: 0 : if (err)
5300 : 0 : goto done;
5301 : :
5302 : 0 : ice_update_phy_type(&phy_type_low, &phy_type_high, link_speeds_bitmap);
5303 : :
5304 [ # # ]: 0 : if (link_speeds_bitmap == ICE_LINK_SPEED_UNKNOWN) {
5305 : 0 : cfg.phy_type_low = phy_caps->phy_type_low;
5306 : 0 : cfg.phy_type_high = phy_caps->phy_type_high;
5307 [ # # ]: 0 : } else if (phy_type_low & phy_caps->phy_type_low ||
5308 [ # # ]: 0 : phy_type_high & phy_caps->phy_type_high) {
5309 : 0 : cfg.phy_type_low = phy_type_low & phy_caps->phy_type_low;
5310 : 0 : cfg.phy_type_high = phy_type_high & phy_caps->phy_type_high;
5311 : : } else {
5312 : 0 : PMD_DRV_LOG(WARNING, "Invalid speed setting, set to default!");
5313 : 0 : cfg.phy_type_low = phy_caps->phy_type_low;
5314 : 0 : cfg.phy_type_high = phy_caps->phy_type_high;
5315 : : }
5316 : :
5317 : 0 : cfg.caps = phy_caps->caps | ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
5318 : :
5319 : 0 : cfg.caps &= ~(ICE_AQC_PHY_EN_TX_LINK_PAUSE | ICE_AQC_PHY_EN_RX_LINK_PAUSE);
5320 [ # # ]: 0 : cfg.caps |= ice_fc_mode_to_pause_caps(pf->fc_conf.mode);
5321 : 0 : cfg.low_power_ctrl_an = phy_caps->low_power_ctrl_an;
5322 [ # # ]: 0 : if (!link_autoneg)
5323 : 0 : cfg.low_power_ctrl_an &= ~(ICE_AQC_PHY_AN_EN_CLAUSE28 |
5324 : : ICE_AQC_PHY_AN_EN_CLAUSE73 |
5325 : : ICE_AQC_PHY_AN_EN_CLAUSE37);
5326 : 0 : cfg.eee_cap = phy_caps->eee_cap;
5327 : 0 : cfg.eeer_value = phy_caps->eeer_value;
5328 : 0 : cfg.link_fec_opt = phy_caps->link_fec_options;
5329 [ # # ]: 0 : if (link_up)
5330 : 0 : cfg.caps |= ICE_AQ_PHY_ENA_LINK;
5331 : : else
5332 : 0 : cfg.caps &= ~ICE_AQ_PHY_ENA_LINK;
5333 : :
5334 : 0 : err = ice_aq_set_phy_cfg(hw, pi, &cfg, NULL);
5335 : :
5336 : 0 : done:
5337 : 0 : ice_free(hw, phy_caps);
5338 : 0 : return err;
5339 : : }
5340 : :
5341 : : static int
5342 : 0 : ice_dev_set_link_up(struct rte_eth_dev *dev)
5343 : : {
5344 : 0 : return ice_apply_link_speed(dev);
5345 : : }
5346 : :
5347 : : static int
5348 : 0 : ice_dev_set_link_down(struct rte_eth_dev *dev)
5349 : : {
5350 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5351 : : uint8_t speed = ICE_LINK_SPEED_UNKNOWN;
5352 : :
5353 : 0 : return ice_phy_conf_link(hw, speed, false, true);
5354 : : }
5355 : :
5356 : : static int
5357 : 0 : ice_dev_led_on(struct rte_eth_dev *dev)
5358 : : {
5359 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5360 : 0 : int status = ice_aq_set_port_id_led(hw->port_info, false, NULL);
5361 : :
5362 [ # # ]: 0 : return status == ICE_SUCCESS ? 0 : -ENOTSUP;
5363 : : }
5364 : :
5365 : : static int
5366 : 0 : ice_dev_led_off(struct rte_eth_dev *dev)
5367 : : {
5368 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5369 : 0 : int status = ice_aq_set_port_id_led(hw->port_info, true, NULL);
5370 : :
5371 [ # # ]: 0 : return status == ICE_SUCCESS ? 0 : -ENOTSUP;
5372 : : }
5373 : :
5374 : : static int
5375 : 0 : ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
5376 : : {
5377 : : /* mtu setting is forbidden if port is start */
5378 [ # # ]: 0 : if (dev->data->dev_started != 0) {
5379 : 0 : PMD_DRV_LOG(ERR,
5380 : : "port %d must be stopped before configuration",
5381 : : dev->data->port_id);
5382 : 0 : return -EBUSY;
5383 : : }
5384 : :
5385 : : return 0;
5386 : : }
5387 : :
5388 : 0 : static int ice_macaddr_set(struct rte_eth_dev *dev,
5389 : : struct rte_ether_addr *mac_addr)
5390 : : {
5391 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5392 : : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5393 [ # # ]: 0 : struct ice_vsi *vsi = pf->main_vsi;
5394 : : struct ice_mac_filter *f;
5395 : : uint8_t flags = 0;
5396 : : int ret;
5397 : :
5398 : : if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
5399 : 0 : PMD_DRV_LOG(ERR, "Tried to set invalid MAC address.");
5400 : 0 : return -EINVAL;
5401 : : }
5402 : :
5403 [ # # ]: 0 : TAILQ_FOREACH(f, &vsi->mac_list, next) {
5404 [ # # ]: 0 : if (rte_is_same_ether_addr(&pf->dev_addr, &f->mac_info.mac_addr))
5405 : : break;
5406 : : }
5407 : :
5408 [ # # ]: 0 : if (!f) {
5409 : 0 : PMD_DRV_LOG(ERR, "Failed to find filter for default mac");
5410 : 0 : return -EIO;
5411 : : }
5412 : :
5413 : 0 : ret = ice_remove_mac_filter(vsi, &f->mac_info.mac_addr);
5414 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
5415 : 0 : PMD_DRV_LOG(ERR, "Failed to delete mac filter");
5416 : 0 : return -EIO;
5417 : : }
5418 : 0 : ret = ice_add_mac_filter(vsi, mac_addr);
5419 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
5420 : 0 : PMD_DRV_LOG(ERR, "Failed to add mac filter");
5421 : 0 : return -EIO;
5422 : : }
5423 : : rte_ether_addr_copy(mac_addr, &pf->dev_addr);
5424 : :
5425 : : flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
5426 : 0 : ret = ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags, NULL);
5427 [ # # ]: 0 : if (ret != ICE_SUCCESS)
5428 : 0 : PMD_DRV_LOG(ERR, "Failed to set manage mac");
5429 : :
5430 : : return 0;
5431 : : }
5432 : :
5433 : : /* Add a MAC address, and update filters */
5434 : : static int
5435 : 0 : ice_macaddr_add(struct rte_eth_dev *dev,
5436 : : struct rte_ether_addr *mac_addr,
5437 : : __rte_unused uint32_t index,
5438 : : __rte_unused uint32_t pool)
5439 : : {
5440 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5441 : 0 : struct ice_vsi *vsi = pf->main_vsi;
5442 : : int ret;
5443 : :
5444 : 0 : ret = ice_add_mac_filter(vsi, mac_addr);
5445 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
5446 : 0 : PMD_DRV_LOG(ERR, "Failed to add MAC filter");
5447 : 0 : return -EINVAL;
5448 : : }
5449 : :
5450 : : return ICE_SUCCESS;
5451 : : }
5452 : :
5453 : : /* Remove a MAC address, and update filters */
5454 : : static void
5455 : 0 : ice_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)
5456 : : {
5457 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5458 : 0 : struct ice_vsi *vsi = pf->main_vsi;
5459 : : struct rte_eth_dev_data *data = dev->data;
5460 : : struct rte_ether_addr *macaddr;
5461 : : int ret;
5462 : :
5463 : 0 : macaddr = &data->mac_addrs[index];
5464 : 0 : ret = ice_remove_mac_filter(vsi, macaddr);
5465 [ # # ]: 0 : if (ret) {
5466 : 0 : PMD_DRV_LOG(ERR, "Failed to remove MAC filter");
5467 : 0 : return;
5468 : : }
5469 : : }
5470 : :
5471 : : static int
5472 : 0 : ice_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
5473 : : {
5474 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5475 : : /* Use the configured outer_ethertype instead of hardcoded 0x8100 */
5476 : 0 : struct ice_vlan vlan = ICE_VLAN(pf->outer_ethertype, vlan_id);
5477 : 0 : struct ice_vsi *vsi = pf->main_vsi;
5478 : : int ret;
5479 : :
5480 : 0 : PMD_INIT_FUNC_TRACE();
5481 : :
5482 : : /**
5483 : : * Vlan 0 is the generic filter for untagged packets
5484 : : * and can't be removed or added by user.
5485 : : */
5486 [ # # ]: 0 : if (vlan_id == 0)
5487 : : return 0;
5488 : :
5489 [ # # ]: 0 : if (on) {
5490 : 0 : ret = ice_add_vlan_filter(vsi, &vlan);
5491 [ # # ]: 0 : if (ret < 0) {
5492 : 0 : PMD_DRV_LOG(ERR, "Failed to add vlan filter");
5493 : 0 : return -EINVAL;
5494 : : }
5495 : : } else {
5496 : 0 : ret = ice_remove_vlan_filter(vsi, &vlan);
5497 [ # # ]: 0 : if (ret < 0) {
5498 : 0 : PMD_DRV_LOG(ERR, "Failed to remove vlan filter");
5499 : 0 : return -EINVAL;
5500 : : }
5501 : : }
5502 : :
5503 : : return 0;
5504 : : }
5505 : :
5506 : : /* In Single VLAN Mode (SVM), single VLAN filters via ICE_SW_LKUP_VLAN are
5507 : : * based on the inner VLAN ID, so the VLAN TPID (i.e. 0x8100 or 0x888a8)
5508 : : * doesn't matter. In Double VLAN Mode (DVM), outer/single VLAN filters via
5509 : : * ICE_SW_LKUP_VLAN are based on the outer/single VLAN ID + VLAN TPID.
5510 : : *
5511 : : * For both modes add a VLAN 0 + no VLAN TPID filter to handle untagged traffic
5512 : : * when VLAN pruning is enabled. Also, this handles VLAN 0 priority tagged
5513 : : * traffic in SVM, since the VLAN TPID isn't part of filtering.
5514 : : *
5515 : : * If DVM is enabled then an explicit VLAN 0 + VLAN TPID filter needs to be
5516 : : * added to allow VLAN 0 priority tagged traffic in DVM, since the VLAN TPID is
5517 : : * part of filtering.
5518 : : */
5519 : : static int
5520 : 0 : ice_vsi_add_vlan_zero(struct ice_vsi *vsi)
5521 : : {
5522 : : struct ice_vlan vlan;
5523 : : int err;
5524 : :
5525 : 0 : vlan = ICE_VLAN(0, 0);
5526 : 0 : err = ice_add_vlan_filter(vsi, &vlan);
5527 [ # # ]: 0 : if (err) {
5528 : 0 : PMD_DRV_LOG(DEBUG, "Failed to add VLAN ID 0");
5529 : 0 : return err;
5530 : : }
5531 : :
5532 : : /* in SVM both VLAN 0 filters are identical */
5533 [ # # ]: 0 : if (!ice_is_dvm_ena(&vsi->adapter->hw))
5534 : : return 0;
5535 : :
5536 : 0 : vlan = ICE_VLAN(RTE_ETHER_TYPE_VLAN, 0);
5537 : 0 : err = ice_add_vlan_filter(vsi, &vlan);
5538 [ # # ]: 0 : if (err) {
5539 : 0 : PMD_DRV_LOG(DEBUG, "Failed to add VLAN ID 0 in double VLAN mode");
5540 : 0 : return err;
5541 : : }
5542 : :
5543 : : return 0;
5544 : : }
5545 : :
5546 : : /*
5547 : : * Delete the VLAN 0 filters in the same manner that they were added in
5548 : : * ice_vsi_add_vlan_zero.
5549 : : */
5550 : : static int
5551 : 0 : ice_vsi_del_vlan_zero(struct ice_vsi *vsi)
5552 : : {
5553 : : struct ice_vlan vlan;
5554 : : int err;
5555 : :
5556 : 0 : vlan = ICE_VLAN(0, 0);
5557 : 0 : err = ice_remove_vlan_filter(vsi, &vlan);
5558 [ # # ]: 0 : if (err) {
5559 : 0 : PMD_DRV_LOG(DEBUG, "Failed to remove VLAN ID 0");
5560 : 0 : return err;
5561 : : }
5562 : :
5563 : : /* in SVM both VLAN 0 filters are identical */
5564 [ # # ]: 0 : if (!ice_is_dvm_ena(&vsi->adapter->hw))
5565 : : return 0;
5566 : :
5567 : 0 : vlan = ICE_VLAN(RTE_ETHER_TYPE_VLAN, 0);
5568 : 0 : err = ice_remove_vlan_filter(vsi, &vlan);
5569 [ # # ]: 0 : if (err) {
5570 : 0 : PMD_DRV_LOG(DEBUG, "Failed to remove VLAN ID 0 in double VLAN mode");
5571 : 0 : return err;
5572 : : }
5573 : :
5574 : : return 0;
5575 : : }
5576 : :
5577 : : /* Configure vlan filter on or off */
5578 : : static int
5579 : 0 : ice_vsi_config_vlan_filter(struct ice_vsi *vsi, bool on)
5580 : : {
5581 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5582 : : struct ice_vsi_ctx ctxt;
5583 : : uint8_t sw_flags2;
5584 : : int ret = 0;
5585 : :
5586 : : sw_flags2 = ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA;
5587 : :
5588 [ # # ]: 0 : if (on)
5589 : 0 : vsi->info.sw_flags2 |= sw_flags2;
5590 : : else
5591 : 0 : vsi->info.sw_flags2 &= ~sw_flags2;
5592 : :
5593 : 0 : vsi->info.sw_id = hw->port_info->sw_id;
5594 : 0 : (void)memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info));
5595 : 0 : ctxt.info.valid_sections =
5596 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_SW_VALID |
5597 : : ICE_AQ_VSI_PROP_SECURITY_VALID);
5598 : 0 : ctxt.vsi_num = vsi->vsi_id;
5599 : :
5600 : 0 : ret = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
5601 [ # # ]: 0 : if (ret) {
5602 [ # # ]: 0 : PMD_DRV_LOG(INFO, "Update VSI failed to %s vlan rx pruning",
5603 : : on ? "enable" : "disable");
5604 : 0 : return -EINVAL;
5605 : : } else {
5606 : 0 : vsi->info.valid_sections |=
5607 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_SW_VALID |
5608 : : ICE_AQ_VSI_PROP_SECURITY_VALID);
5609 : : }
5610 : :
5611 : : /* consist with other drivers, allow untagged packet when vlan filter on */
5612 [ # # ]: 0 : if (on)
5613 : 0 : ret = ice_vsi_add_vlan_zero(vsi);
5614 : : else
5615 : 0 : ret = ice_vsi_del_vlan_zero(vsi);
5616 : :
5617 : : return 0;
5618 : : }
5619 : :
5620 : : /* Manage VLAN stripping for the VSI for Rx */
5621 : : static int
5622 : 0 : ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena)
5623 : : {
5624 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5625 : : struct ice_vsi_ctx ctxt;
5626 : : int status, err = 0;
5627 : :
5628 : : /* do not allow modifying VLAN stripping when a port VLAN is configured
5629 : : * on this VSI
5630 : : */
5631 [ # # ]: 0 : if (vsi->info.port_based_inner_vlan)
5632 : : return 0;
5633 : :
5634 : : memset(&ctxt, 0, sizeof(ctxt));
5635 : :
5636 [ # # ]: 0 : if (ena)
5637 : : /* Strip VLAN tag from Rx packet and put it in the desc */
5638 : : ctxt.info.inner_vlan_flags =
5639 : : ICE_AQ_VSI_INNER_VLAN_EMODE_STR_BOTH;
5640 : : else
5641 : : /* Disable stripping. Leave tag in packet */
5642 : 0 : ctxt.info.inner_vlan_flags =
5643 : : ICE_AQ_VSI_INNER_VLAN_EMODE_NOTHING;
5644 : :
5645 : : /* Allow all packets untagged/tagged */
5646 : 0 : ctxt.info.inner_vlan_flags |= ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL;
5647 : :
5648 : 0 : ctxt.info.valid_sections = rte_cpu_to_le_16(ICE_AQ_VSI_PROP_VLAN_VALID);
5649 : :
5650 : 0 : status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
5651 [ # # ]: 0 : if (status) {
5652 [ # # ]: 0 : PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan stripping",
5653 : : ena ? "enable" : "disable");
5654 : : err = -EIO;
5655 : : } else {
5656 : 0 : vsi->info.inner_vlan_flags = ctxt.info.inner_vlan_flags;
5657 : : }
5658 : :
5659 : : return err;
5660 : : }
5661 : :
5662 : : static int
5663 : : ice_vsi_ena_inner_stripping(struct ice_vsi *vsi)
5664 : : {
5665 : 0 : return ice_vsi_manage_vlan_stripping(vsi, true);
5666 : : }
5667 : :
5668 : : static int
5669 : : ice_vsi_dis_inner_stripping(struct ice_vsi *vsi)
5670 : : {
5671 : 0 : return ice_vsi_manage_vlan_stripping(vsi, false);
5672 : : }
5673 : :
5674 : : /**
5675 : : * tpid_to_vsi_outer_vlan_type - convert from TPID to VSI context based tag_type
5676 : : * @tpid: tpid used to translate into VSI context based tag_type
5677 : : * @tag_type: output variable to hold the VSI context based tag type
5678 : : */
5679 : : static int tpid_to_vsi_outer_vlan_type(u16 tpid, u8 *tag_type)
5680 : : {
5681 [ # # # # : 0 : switch (tpid) {
# # # # ]
5682 : : case RTE_ETHER_TYPE_VLAN:
5683 : : *tag_type = ICE_AQ_VSI_OUTER_TAG_VLAN_8100;
5684 : : break;
5685 : : case RTE_ETHER_TYPE_QINQ:
5686 : : *tag_type = ICE_AQ_VSI_OUTER_TAG_STAG;
5687 : : break;
5688 : : case RTE_ETHER_TYPE_QINQ1:
5689 : : *tag_type = ICE_AQ_VSI_OUTER_TAG_VLAN_9100;
5690 : : break;
5691 : : default:
5692 : : *tag_type = 0;
5693 : : return -EINVAL;
5694 : : }
5695 : :
5696 : : return 0;
5697 : : }
5698 : :
5699 : : /**
5700 : : * ice_is_supported_port_vlan_proto - make sure the vlan_proto is supported
5701 : : * @hw: hardware structure used to check the VLAN mode
5702 : : * @vlan_proto: VLAN TPID being checked
5703 : : *
5704 : : * If the device is configured in Double VLAN Mode (DVM), it supports three
5705 : : * types: RTE_ETHER_TYPE_VLAN, RTE_ETHER_TYPE_QINQ1 and RTE_ETHER_TYPE_QINQ. If the device is
5706 : : * configured in Single VLAN Mode (SVM), then only RTE_ETHER_TYPE_VLAN is supported.
5707 : : */
5708 : : static bool
5709 : 0 : ice_is_supported_port_vlan_proto(struct ice_hw *hw, u16 vlan_proto)
5710 : : {
5711 : : bool is_supported = false;
5712 : :
5713 [ # # # # ]: 0 : switch (vlan_proto) {
5714 : 0 : case RTE_ETHER_TYPE_VLAN:
5715 : : is_supported = true;
5716 : 0 : break;
5717 : 0 : case RTE_ETHER_TYPE_QINQ:
5718 [ # # ]: 0 : if (ice_is_dvm_ena(hw))
5719 : : is_supported = true;
5720 : : break;
5721 : 0 : case RTE_ETHER_TYPE_QINQ1:
5722 [ # # ]: 0 : if (ice_is_dvm_ena(hw))
5723 : : is_supported = true;
5724 : : break;
5725 : : }
5726 : :
5727 : 0 : return is_supported;
5728 : : }
5729 : :
5730 : : /**
5731 : : * ice_vsi_ena_outer_stripping - enable outer VLAN stripping
5732 : : * @vsi: VSI to configure
5733 : : * @tpid: TPID to enable outer VLAN stripping for
5734 : : *
5735 : : * Enable outer VLAN stripping via VSI context. This function should only be
5736 : : * used if DVM is supported.
5737 : : *
5738 : : * Since the VSI context only supports a single TPID for insertion and
5739 : : * stripping, setting the TPID for stripping will affect the TPID for insertion.
5740 : : * Callers need to be aware of this limitation.
5741 : : *
5742 : : * Only modify outer VLAN stripping settings and the VLAN TPID. Outer VLAN
5743 : : * insertion settings are unmodified.
5744 : : *
5745 : : * This enables hardware to strip a VLAN tag with the specified TPID to be
5746 : : * stripped from the packet and placed in the receive descriptor.
5747 : : */
5748 : 0 : static int ice_vsi_ena_outer_stripping(struct ice_vsi *vsi, u16 tpid)
5749 : : {
5750 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5751 : : struct ice_vsi_ctx ctxt;
5752 : : int status, err = 0;
5753 : : u8 tag_type;
5754 : :
5755 : : /* do not allow modifying VLAN stripping when a port VLAN is configured
5756 : : * on this VSI
5757 : : */
5758 [ # # ]: 0 : if (vsi->info.port_based_outer_vlan)
5759 : : return 0;
5760 : :
5761 : : if (tpid_to_vsi_outer_vlan_type(tpid, &tag_type))
5762 : : return -EINVAL;
5763 : :
5764 : : memset(&ctxt, 0, sizeof(ctxt));
5765 : :
5766 : 0 : ctxt.info.valid_sections =
5767 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_OUTER_TAG_VALID);
5768 : : /* clear current outer VLAN strip settings */
5769 : 0 : ctxt.info.outer_vlan_flags = vsi->info.outer_vlan_flags &
5770 : : ~(ICE_AQ_VSI_OUTER_VLAN_EMODE_M | ICE_AQ_VSI_OUTER_TAG_TYPE_M);
5771 : 0 : ctxt.info.outer_vlan_flags |=
5772 : : (ICE_AQ_VSI_OUTER_VLAN_EMODE_SHOW_BOTH <<
5773 : : ICE_AQ_VSI_OUTER_VLAN_EMODE_S) |
5774 : 0 : ((tag_type << ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
5775 : : ICE_AQ_VSI_OUTER_TAG_TYPE_M);
5776 : :
5777 : 0 : status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
5778 [ # # ]: 0 : if (status) {
5779 : 0 : PMD_DRV_LOG(ERR, "Update VSI failed to enable outer VLAN stripping");
5780 : : err = -EIO;
5781 : : } else {
5782 : 0 : vsi->info.outer_vlan_flags = ctxt.info.outer_vlan_flags;
5783 : : }
5784 : :
5785 : : return err;
5786 : : }
5787 : :
5788 : : static int
5789 : 0 : ice_vsi_dis_outer_stripping(struct ice_vsi *vsi)
5790 : : {
5791 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5792 : : struct ice_vsi_ctx ctxt;
5793 : : int status, err = 0;
5794 : :
5795 [ # # ]: 0 : if (vsi->info.port_based_outer_vlan)
5796 : : return 0;
5797 : :
5798 : : memset(&ctxt, 0, sizeof(ctxt));
5799 : :
5800 : 0 : ctxt.info.valid_sections =
5801 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_OUTER_TAG_VALID);
5802 : : /* clear current outer VLAN strip settings */
5803 : 0 : ctxt.info.outer_vlan_flags = vsi->info.outer_vlan_flags &
5804 : : ~ICE_AQ_VSI_OUTER_VLAN_EMODE_M;
5805 : 0 : ctxt.info.outer_vlan_flags |= ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING <<
5806 : : ICE_AQ_VSI_OUTER_VLAN_EMODE_S;
5807 : :
5808 : 0 : status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
5809 [ # # ]: 0 : if (status) {
5810 : 0 : PMD_DRV_LOG(ERR, "Update VSI failed to disable outer VLAN stripping");
5811 : : err = -EIO;
5812 : : } else {
5813 : 0 : vsi->info.outer_vlan_flags = ctxt.info.outer_vlan_flags;
5814 : : }
5815 : :
5816 : : return err;
5817 : : }
5818 : :
5819 : : static int
5820 : 0 : ice_vsi_config_vlan_stripping(struct ice_vsi *vsi, bool ena)
5821 : : {
5822 : : int ret;
5823 : :
5824 [ # # ]: 0 : if (ena)
5825 : : ret = ice_vsi_ena_inner_stripping(vsi);
5826 : : else
5827 : : ret = ice_vsi_dis_inner_stripping(vsi);
5828 : :
5829 : 0 : return ret;
5830 : : }
5831 : :
5832 : : /* Configure outer vlan stripping on or off in QinQ mode */
5833 : : static int
5834 : 0 : ice_vsi_config_outer_vlan_stripping(struct ice_vsi *vsi, bool on)
5835 : : {
5836 : 0 : uint16_t outer_ethertype = vsi->adapter->pf.outer_ethertype;
5837 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5838 : :
5839 [ # # ]: 0 : if (vsi->vsi_id >= ICE_MAX_NUM_VSIS) {
5840 : 0 : PMD_DRV_LOG(ERR, "VSI ID exceeds the maximum");
5841 : 0 : return -EINVAL;
5842 : : }
5843 : :
5844 [ # # ]: 0 : if (!ice_is_dvm_ena(hw)) {
5845 : 0 : PMD_DRV_LOG(ERR, "Single VLAN mode (SVM) does not support qinq");
5846 : 0 : return -EOPNOTSUPP;
5847 : : }
5848 : :
5849 : : return on ?
5850 [ # # ]: 0 : ice_vsi_ena_outer_stripping(vsi, outer_ethertype) :
5851 : 0 : ice_vsi_dis_outer_stripping(vsi);
5852 : : }
5853 : :
5854 : : static int
5855 : 0 : ice_vlan_offload_set(struct rte_eth_dev *dev, int mask)
5856 : : {
5857 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5858 : 0 : struct ice_vsi *vsi = pf->main_vsi;
5859 : : struct rte_eth_rxmode *rxmode;
5860 : :
5861 : : rxmode = &dev->data->dev_conf.rxmode;
5862 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_FILTER_MASK) {
5863 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
5864 : 0 : ice_vsi_config_vlan_filter(vsi, true);
5865 : : else
5866 : 0 : ice_vsi_config_vlan_filter(vsi, false);
5867 : : }
5868 : :
5869 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5870 [ # # ]: 0 : if (!ice_is_dvm_ena(hw)) {
5871 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
5872 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
5873 : 0 : ice_vsi_config_vlan_stripping(vsi, true);
5874 : : else
5875 : 0 : ice_vsi_config_vlan_stripping(vsi, false);
5876 : : }
5877 : :
5878 [ # # ]: 0 : if (mask & RTE_ETH_QINQ_STRIP_MASK) {
5879 : 0 : PMD_DRV_LOG(ERR, "Single VLAN mode (SVM) does not support qinq");
5880 : 0 : return -ENOTSUP;
5881 : : }
5882 : : } else {
5883 [ # # ]: 0 : if ((mask & RTE_ETH_VLAN_STRIP_MASK) |
5884 : : (mask & RTE_ETH_QINQ_STRIP_MASK)) {
5885 [ # # ]: 0 : if (rxmode->offloads & (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
5886 : : RTE_ETH_RX_OFFLOAD_QINQ_STRIP))
5887 : 0 : ice_vsi_config_outer_vlan_stripping(vsi, true);
5888 : : else
5889 : 0 : ice_vsi_config_outer_vlan_stripping(vsi, false);
5890 : : }
5891 : :
5892 [ # # ]: 0 : if (mask & RTE_ETH_QINQ_STRIP_MASK) {
5893 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
5894 : 0 : ice_vsi_config_vlan_stripping(vsi, true);
5895 : : else
5896 : 0 : ice_vsi_config_vlan_stripping(vsi, false);
5897 : : }
5898 : : }
5899 : :
5900 : : return 0;
5901 : : }
5902 : :
5903 : : static int
5904 : 0 : ice_get_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size)
5905 : : {
5906 : : struct ice_aq_get_set_rss_lut_params lut_params;
5907 : 0 : struct ice_pf *pf = ICE_VSI_TO_PF(vsi);
5908 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
5909 : : int ret;
5910 : :
5911 [ # # ]: 0 : if (!lut)
5912 : : return -EINVAL;
5913 : :
5914 [ # # ]: 0 : if (pf->flags & ICE_FLAG_RSS_AQ_CAPABLE) {
5915 : 0 : lut_params.vsi_handle = vsi->idx;
5916 : 0 : lut_params.lut_size = lut_size;
5917 [ # # ]: 0 : lut_params.lut_type = (vsi->global_lut_allocated) ?
5918 : : ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_GLOBAL : ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF;
5919 : 0 : lut_params.lut = lut;
5920 [ # # ]: 0 : lut_params.global_lut_id = (vsi->global_lut_allocated) ? vsi->global_lut_id : 0;
5921 : 0 : ret = ice_aq_get_rss_lut(hw, &lut_params);
5922 [ # # ]: 0 : if (ret) {
5923 : 0 : PMD_DRV_LOG(ERR, "Failed to get RSS lookup table");
5924 : 0 : return -EINVAL;
5925 : : }
5926 : : } else {
5927 : : uint64_t *lut_dw = (uint64_t *)lut;
5928 : 0 : uint16_t i, lut_size_dw = lut_size / 4;
5929 : :
5930 [ # # ]: 0 : for (i = 0; i < lut_size_dw; i++)
5931 : 0 : lut_dw[i] = ICE_READ_REG(hw, PFQF_HLUT(i));
5932 : : }
5933 : :
5934 : : return 0;
5935 : : }
5936 : :
5937 : : static int
5938 : 0 : ice_set_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size)
5939 : : {
5940 : : struct ice_aq_get_set_rss_lut_params lut_params;
5941 : : struct ice_pf *pf;
5942 : : struct ice_hw *hw;
5943 : : int ret;
5944 : :
5945 [ # # ]: 0 : if (!vsi || !lut)
5946 : : return -EINVAL;
5947 : :
5948 : 0 : pf = ICE_VSI_TO_PF(vsi);
5949 : 0 : hw = ICE_VSI_TO_HW(vsi);
5950 : :
5951 [ # # ]: 0 : if (pf->flags & ICE_FLAG_RSS_AQ_CAPABLE) {
5952 : 0 : lut_params.vsi_handle = vsi->idx;
5953 : 0 : lut_params.lut_size = lut_size;
5954 [ # # ]: 0 : lut_params.lut_type = (vsi->global_lut_allocated) ?
5955 : : ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_GLOBAL : ICE_AQC_GSET_RSS_LUT_TABLE_TYPE_PF;
5956 : 0 : lut_params.lut = lut;
5957 [ # # ]: 0 : lut_params.global_lut_id = (vsi->global_lut_allocated) ? vsi->global_lut_id : 0;
5958 : 0 : ret = ice_aq_set_rss_lut(hw, &lut_params);
5959 [ # # ]: 0 : if (ret) {
5960 : 0 : PMD_DRV_LOG(ERR, "Failed to set RSS lookup table");
5961 : 0 : return -EINVAL;
5962 : : }
5963 : : } else {
5964 : : uint64_t *lut_dw = (uint64_t *)lut;
5965 : 0 : uint16_t i, lut_size_dw = lut_size / 4;
5966 : :
5967 [ # # ]: 0 : for (i = 0; i < lut_size_dw; i++)
5968 : 0 : ICE_WRITE_REG(hw, PFQF_HLUT(i), lut_dw[i]);
5969 : :
5970 : 0 : ice_flush(hw);
5971 : : }
5972 : :
5973 : : return 0;
5974 : : }
5975 : :
5976 : : static int
5977 : 0 : ice_rss_reta_update(struct rte_eth_dev *dev,
5978 : : struct rte_eth_rss_reta_entry64 *reta_conf,
5979 : : uint16_t reta_size)
5980 : : {
5981 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
5982 : 0 : uint16_t i, lut_size = pf->hash_lut_size;
5983 : : uint16_t idx, shift;
5984 : 0 : uint8_t lut[ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K] = {0};
5985 : : int ret;
5986 : :
5987 : 0 : if (reta_size != ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128 &&
5988 [ # # # # ]: 0 : reta_size != ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_512 &&
5989 : : reta_size != ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K) {
5990 : 0 : PMD_DRV_LOG(ERR,
5991 : : "The size of hash lookup table configured (%d)"
5992 : : "doesn't match the number hardware can "
5993 : : "supported (128, 512, 2048)",
5994 : : reta_size);
5995 : 0 : return -EINVAL;
5996 : : }
5997 : :
5998 : : /* It MUST use the current LUT size to get the RSS lookup table,
5999 : : * otherwise if will fail with -100 error code.
6000 : : */
6001 : 0 : ret = ice_get_rss_lut(pf->main_vsi, lut, lut_size);
6002 [ # # ]: 0 : if (ret)
6003 : : return ret;
6004 : :
6005 [ # # ]: 0 : for (i = 0; i < reta_size; i++) {
6006 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
6007 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
6008 [ # # ]: 0 : if (reta_conf[idx].mask & (1ULL << shift))
6009 : 0 : lut[i] = reta_conf[idx].reta[shift];
6010 : : }
6011 : 0 : ret = ice_set_rss_lut(pf->main_vsi, lut, reta_size);
6012 [ # # ]: 0 : if (ret == 0 && lut_size != reta_size) {
6013 : 0 : PMD_DRV_LOG(INFO,
6014 : : "The size of hash lookup table is changed from (%d) to (%d)",
6015 : : lut_size, reta_size);
6016 : 0 : pf->hash_lut_size = reta_size;
6017 : : }
6018 : :
6019 : : return 0;
6020 : : }
6021 : :
6022 : : static int
6023 : 0 : ice_rss_reta_query(struct rte_eth_dev *dev,
6024 : : struct rte_eth_rss_reta_entry64 *reta_conf,
6025 : : uint16_t reta_size)
6026 : : {
6027 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6028 : 0 : uint16_t i, lut_size = pf->hash_lut_size;
6029 : : uint16_t idx, shift;
6030 : 0 : uint8_t lut[ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K] = {0};
6031 : : int ret;
6032 : :
6033 [ # # ]: 0 : if (reta_size != lut_size) {
6034 : 0 : PMD_DRV_LOG(ERR,
6035 : : "The size of hash lookup table configured (%d)"
6036 : : "doesn't match the number hardware can "
6037 : : "supported (%d)",
6038 : : reta_size, lut_size);
6039 : 0 : return -EINVAL;
6040 : : }
6041 : :
6042 : 0 : ret = ice_get_rss_lut(pf->main_vsi, lut, reta_size);
6043 [ # # ]: 0 : if (ret)
6044 : : return ret;
6045 : :
6046 [ # # ]: 0 : for (i = 0; i < reta_size; i++) {
6047 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
6048 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
6049 [ # # ]: 0 : if (reta_conf[idx].mask & (1ULL << shift))
6050 : 0 : reta_conf[idx].reta[shift] = lut[i];
6051 : : }
6052 : :
6053 : : return 0;
6054 : : }
6055 : :
6056 : : static int
6057 : 0 : ice_set_rss_key(struct ice_vsi *vsi, uint8_t *key, uint8_t key_len)
6058 : : {
6059 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
6060 : : int ret = 0;
6061 : :
6062 [ # # ]: 0 : if (!key || key_len == 0) {
6063 : 0 : PMD_DRV_LOG(DEBUG, "No key to be configured");
6064 : 0 : return 0;
6065 [ # # ]: 0 : } else if (key_len != (VSIQF_HKEY_MAX_INDEX + 1) *
6066 : : sizeof(uint32_t)) {
6067 : 0 : PMD_DRV_LOG(ERR, "Invalid key length %u", key_len);
6068 : 0 : return -EINVAL;
6069 : : }
6070 : :
6071 : : struct ice_aqc_get_set_rss_keys *key_dw =
6072 : : (struct ice_aqc_get_set_rss_keys *)key;
6073 : :
6074 : 0 : ret = ice_aq_set_rss_key(hw, vsi->idx, key_dw);
6075 [ # # ]: 0 : if (ret) {
6076 : 0 : PMD_DRV_LOG(ERR, "Failed to configure RSS key via AQ");
6077 : : ret = -EINVAL;
6078 : : }
6079 : :
6080 : : return ret;
6081 : : }
6082 : :
6083 : : static int
6084 : 0 : ice_get_rss_key(struct ice_vsi *vsi, uint8_t *key, uint8_t *key_len)
6085 : : {
6086 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
6087 : : int ret;
6088 : :
6089 [ # # ]: 0 : if (!key || !key_len)
6090 : : return -EINVAL;
6091 : :
6092 : 0 : ret = ice_aq_get_rss_key
6093 : 0 : (hw, vsi->idx,
6094 : : (struct ice_aqc_get_set_rss_keys *)key);
6095 [ # # ]: 0 : if (ret) {
6096 : 0 : PMD_DRV_LOG(ERR, "Failed to get RSS key via AQ");
6097 : 0 : return -EINVAL;
6098 : : }
6099 : 0 : *key_len = (VSIQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t);
6100 : :
6101 : 0 : return 0;
6102 : : }
6103 : :
6104 : : static int
6105 : 0 : ice_rss_hash_update(struct rte_eth_dev *dev,
6106 : : struct rte_eth_rss_conf *rss_conf)
6107 : : {
6108 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6109 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6110 : : int status;
6111 : :
6112 : : /* set hash key */
6113 : 0 : status = ice_set_rss_key(vsi, rss_conf->rss_key, rss_conf->rss_key_len);
6114 [ # # ]: 0 : if (status)
6115 : : return status;
6116 : :
6117 [ # # ]: 0 : if (rss_conf->rss_hf == 0)
6118 : 0 : pf->rss_hf = 0;
6119 : :
6120 : : /* RSS hash configuration */
6121 : 0 : ice_rss_hash_set(pf, rss_conf->rss_hf);
6122 : :
6123 : 0 : return 0;
6124 : : }
6125 : :
6126 : : static int
6127 : 0 : ice_rss_hash_conf_get(struct rte_eth_dev *dev,
6128 : : struct rte_eth_rss_conf *rss_conf)
6129 : : {
6130 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6131 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6132 : :
6133 : 0 : ice_get_rss_key(vsi, rss_conf->rss_key,
6134 : : &rss_conf->rss_key_len);
6135 : :
6136 : 0 : rss_conf->rss_hf = pf->rss_hf;
6137 : 0 : return 0;
6138 : : }
6139 : :
6140 : : static int
6141 : 0 : ice_promisc_enable(struct rte_eth_dev *dev)
6142 : : {
6143 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6144 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6145 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6146 : : int status, ret = 0;
6147 : : ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
6148 : : ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
6149 : :
6150 : : ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
6151 : : ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
6152 : : ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
6153 : : ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
6154 : :
6155 : 0 : status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
6156 [ # # # ]: 0 : switch (status) {
6157 : 0 : case ICE_ERR_ALREADY_EXISTS:
6158 : 0 : PMD_DRV_LOG(DEBUG, "Promisc mode has already been enabled");
6159 : : case ICE_SUCCESS:
6160 : : break;
6161 : 0 : default:
6162 : 0 : PMD_DRV_LOG(ERR, "Failed to enable promisc, err=%d", status);
6163 : : ret = -EAGAIN;
6164 : : }
6165 : :
6166 : 0 : return ret;
6167 : : }
6168 : :
6169 : : static int
6170 : 0 : ice_promisc_disable(struct rte_eth_dev *dev)
6171 : : {
6172 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6173 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6174 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6175 : : int status, ret = 0;
6176 : : ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
6177 : : ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
6178 : :
6179 [ # # ]: 0 : if (dev->data->all_multicast == 1) {
6180 : : ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
6181 : : ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
6182 : : } else {
6183 : : ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
6184 : : ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
6185 : : ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
6186 : : ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
6187 : : }
6188 : :
6189 : 0 : status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0);
6190 [ # # ]: 0 : if (status != ICE_SUCCESS) {
6191 : 0 : PMD_DRV_LOG(ERR, "Failed to clear promisc, err=%d", status);
6192 : : ret = -EAGAIN;
6193 : : }
6194 : :
6195 : 0 : return ret;
6196 : : }
6197 : :
6198 : : static int
6199 : 0 : ice_allmulti_enable(struct rte_eth_dev *dev)
6200 : : {
6201 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6202 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6203 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6204 : : int status, ret = 0;
6205 : : ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
6206 : : ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
6207 : :
6208 : : ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
6209 : : ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
6210 : :
6211 : 0 : status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
6212 : :
6213 [ # # # ]: 0 : switch (status) {
6214 : 0 : case ICE_ERR_ALREADY_EXISTS:
6215 : 0 : PMD_DRV_LOG(DEBUG, "Allmulti has already been enabled");
6216 : : case ICE_SUCCESS:
6217 : : break;
6218 : 0 : default:
6219 : 0 : PMD_DRV_LOG(ERR, "Failed to enable allmulti, err=%d", status);
6220 : : ret = -EAGAIN;
6221 : : }
6222 : :
6223 : 0 : return ret;
6224 : : }
6225 : :
6226 : : static int
6227 : 0 : ice_allmulti_disable(struct rte_eth_dev *dev)
6228 : : {
6229 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6230 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6231 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6232 : : int status, ret = 0;
6233 : : ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
6234 : : ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
6235 : :
6236 [ # # ]: 0 : if (dev->data->promiscuous == 1)
6237 : : return 0; /* must remain in all_multicast mode */
6238 : :
6239 : : ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
6240 : : ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
6241 : :
6242 : 0 : status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0);
6243 [ # # ]: 0 : if (status != ICE_SUCCESS) {
6244 : 0 : PMD_DRV_LOG(ERR, "Failed to clear allmulti, err=%d", status);
6245 : : ret = -EAGAIN;
6246 : : }
6247 : :
6248 : : return ret;
6249 : : }
6250 : :
6251 : 0 : static int ice_rx_queue_intr_enable(struct rte_eth_dev *dev,
6252 : : uint16_t queue_id)
6253 : : {
6254 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
6255 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
6256 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6257 : : uint32_t val;
6258 : : uint16_t msix_intr;
6259 : :
6260 : 0 : msix_intr = rte_intr_vec_list_index_get(intr_handle, queue_id);
6261 : :
6262 : : val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |
6263 : : GLINT_DYN_CTL_ITR_INDX_M;
6264 : : val &= ~GLINT_DYN_CTL_WB_ON_ITR_M;
6265 : :
6266 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(msix_intr), val);
6267 : 0 : rte_intr_ack(pci_dev->intr_handle);
6268 : :
6269 : 0 : return 0;
6270 : : }
6271 : :
6272 : 0 : static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
6273 : : uint16_t queue_id)
6274 : : {
6275 : 0 : struct rte_pci_device *pci_dev = ICE_DEV_TO_PCI(dev);
6276 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
6277 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6278 : : uint16_t msix_intr;
6279 : :
6280 : 0 : msix_intr = rte_intr_vec_list_index_get(intr_handle, queue_id);
6281 : :
6282 : 0 : ICE_WRITE_REG(hw, GLINT_DYN_CTL(msix_intr), GLINT_DYN_CTL_WB_ON_ITR_M);
6283 : :
6284 : 0 : return 0;
6285 : : }
6286 : :
6287 : : static int
6288 : 0 : ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
6289 : : {
6290 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6291 : : u8 ver, patch;
6292 : : u16 build;
6293 : : int ret;
6294 : :
6295 : 0 : ver = hw->flash.orom.major;
6296 : 0 : patch = hw->flash.orom.patch;
6297 : 0 : build = hw->flash.orom.build;
6298 : :
6299 : 0 : ret = snprintf(fw_version, fw_size,
6300 : : "%x.%02x 0x%08x %d.%d.%d",
6301 : 0 : hw->flash.nvm.major,
6302 [ # # ]: 0 : hw->flash.nvm.minor,
6303 : : hw->flash.nvm.eetrack,
6304 : : ver, build, patch);
6305 [ # # ]: 0 : if (ret < 0)
6306 : : return -EINVAL;
6307 : :
6308 : : /* add the size of '\0' */
6309 : 0 : ret += 1;
6310 [ # # ]: 0 : if (fw_size < (size_t)ret)
6311 : : return ret;
6312 : : else
6313 : 0 : return 0;
6314 : : }
6315 : :
6316 : : static int
6317 : 0 : ice_vsi_vlan_pvid_set(struct ice_vsi *vsi, struct ice_vsi_vlan_pvid_info *info)
6318 : : {
6319 : : struct ice_hw *hw;
6320 : : struct ice_vsi_ctx ctxt;
6321 : : uint8_t vlan_flags = 0;
6322 : : int ret;
6323 : :
6324 [ # # ]: 0 : if (!vsi || !info) {
6325 : 0 : PMD_DRV_LOG(ERR, "invalid parameters");
6326 : 0 : return -EINVAL;
6327 : : }
6328 : :
6329 [ # # ]: 0 : if (info->on) {
6330 : 0 : vsi->info.port_based_inner_vlan = info->config.pvid;
6331 : : /**
6332 : : * If insert pvid is enabled, only tagged pkts are
6333 : : * allowed to be sent out.
6334 : : */
6335 : : vlan_flags = ICE_AQ_VSI_INNER_VLAN_INSERT_PVID |
6336 : : ICE_AQ_VSI_INNER_VLAN_TX_MODE_ACCEPTUNTAGGED;
6337 : : } else {
6338 : 0 : vsi->info.port_based_inner_vlan = 0;
6339 [ # # ]: 0 : if (info->config.reject.tagged == 0)
6340 : : vlan_flags |= ICE_AQ_VSI_INNER_VLAN_TX_MODE_ACCEPTTAGGED;
6341 : :
6342 [ # # ]: 0 : if (info->config.reject.untagged == 0)
6343 : 0 : vlan_flags |= ICE_AQ_VSI_INNER_VLAN_TX_MODE_ACCEPTUNTAGGED;
6344 : : }
6345 : 0 : vsi->info.inner_vlan_flags &= ~(ICE_AQ_VSI_INNER_VLAN_INSERT_PVID |
6346 : : ICE_AQ_VSI_INNER_VLAN_EMODE_M);
6347 : 0 : vsi->info.inner_vlan_flags |= vlan_flags;
6348 : : memset(&ctxt, 0, sizeof(ctxt));
6349 : 0 : memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info));
6350 : 0 : ctxt.info.valid_sections =
6351 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_VLAN_VALID);
6352 : 0 : ctxt.vsi_num = vsi->vsi_id;
6353 : :
6354 : 0 : hw = ICE_VSI_TO_HW(vsi);
6355 : 0 : ret = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
6356 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
6357 : 0 : PMD_DRV_LOG(ERR,
6358 : : "update VSI for VLAN insert failed, err %d",
6359 : : ret);
6360 : 0 : return -EINVAL;
6361 : : }
6362 : :
6363 : 0 : vsi->info.valid_sections |=
6364 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_VLAN_VALID);
6365 : :
6366 : 0 : return ret;
6367 : : }
6368 : :
6369 : : /**
6370 : : * ice_vsi_set_outer_port_vlan - set the outer port VLAN and related settings
6371 : : * @vsi: VSI to configure
6372 : : * @vlan_info: packed u16 that contains the VLAN prio and ID
6373 : : * @tpid: TPID of the port VLAN
6374 : : *
6375 : : * Set the port VLAN prio, ID, and TPID.
6376 : : *
6377 : : * Enable VLAN pruning so the VSI doesn't receive any traffic that doesn't match
6378 : : * a VLAN prune rule. The caller should take care to add a VLAN prune rule that
6379 : : * matches the port VLAN ID and TPID.
6380 : : *
6381 : : * Tell hardware to strip outer VLAN tagged packets on receive and don't put
6382 : : * them in the receive descriptor. VSI(s) in port VLANs should not be aware of
6383 : : * the port VLAN ID or TPID they are assigned to.
6384 : : *
6385 : : * Tell hardware to prevent outer VLAN tag insertion on transmit and only allow
6386 : : * untagged outer packets from the transmit descriptor.
6387 : : *
6388 : : * Also, tell the hardware to insert the port VLAN on transmit.
6389 : : */
6390 : : static int
6391 : 0 : ice_vsi_set_outer_port_vlan(struct ice_vsi *vsi, u16 vlan_info, u16 tpid)
6392 : : {
6393 [ # # # # ]: 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
6394 : : struct ice_vsi_ctx ctxt;
6395 : : int status, err = 0;
6396 : : u8 tag_type;
6397 : :
6398 : : if (tpid_to_vsi_outer_vlan_type(tpid, &tag_type))
6399 : : return -EINVAL;
6400 : :
6401 : : memset(&ctxt, 0, sizeof(ctxt));
6402 : :
6403 : 0 : ctxt.info = vsi->info;
6404 : :
6405 : 0 : ctxt.info.sw_flags2 |= ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA;
6406 : :
6407 : 0 : ctxt.info.port_based_outer_vlan = rte_cpu_to_le_16(vlan_info);
6408 : 0 : ctxt.info.outer_vlan_flags =
6409 : : (ICE_AQ_VSI_OUTER_VLAN_EMODE_SHOW <<
6410 : : ICE_AQ_VSI_OUTER_VLAN_EMODE_S) |
6411 : 0 : ((tag_type << ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
6412 : : ICE_AQ_VSI_OUTER_TAG_TYPE_M) |
6413 : : ICE_AQ_VSI_OUTER_VLAN_BLOCK_TX_DESC |
6414 : : (ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ACCEPTUNTAGGED <<
6415 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) |
6416 : : ICE_AQ_VSI_OUTER_VLAN_PORT_BASED_INSERT;
6417 : 0 : ctxt.info.valid_sections =
6418 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_OUTER_TAG_VALID |
6419 : : ICE_AQ_VSI_PROP_SW_VALID);
6420 : :
6421 : 0 : status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
6422 [ # # ]: 0 : if (status != ICE_SUCCESS) {
6423 : 0 : PMD_DRV_LOG(ERR,
6424 : : "update VSI for setting outer port based VLAN failed, err %d",
6425 : : status);
6426 : : err = -EINVAL;
6427 : : } else {
6428 : 0 : vsi->info.port_based_outer_vlan = ctxt.info.port_based_outer_vlan;
6429 : 0 : vsi->info.outer_vlan_flags = ctxt.info.outer_vlan_flags;
6430 : 0 : vsi->info.sw_flags2 = ctxt.info.sw_flags2;
6431 : : }
6432 : :
6433 : : return err;
6434 : : }
6435 : :
6436 : : /**
6437 : : * ice_vsi_dis_outer_insertion - disable outer VLAN insertion
6438 : : * @vsi: VSI to configure
6439 : : * @info: vlan pvid info
6440 : : *
6441 : : * Disable outer VLAN insertion via VSI context. This function should only be
6442 : : * used if DVM is supported.
6443 : : *
6444 : : * Only modify the outer VLAN insertion settings. The VLAN TPID and outer VLAN
6445 : : * settings are unmodified.
6446 : : *
6447 : : * This tells the hardware to not allow VLAN tagged packets in the transmit
6448 : : * descriptor. This enables software offloaded VLAN insertion and disables
6449 : : * hardware offloaded VLAN insertion.
6450 : : */
6451 : 0 : static int ice_vsi_dis_outer_insertion(struct ice_vsi *vsi, struct ice_vsi_vlan_pvid_info *info)
6452 : : {
6453 [ # # ]: 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
6454 : : struct ice_vsi_ctx ctxt;
6455 : : uint8_t vlan_flags = 0;
6456 : : int status, err = 0;
6457 : :
6458 : : memset(&ctxt, 0, sizeof(ctxt));
6459 : :
6460 : 0 : ctxt.info.valid_sections =
6461 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_OUTER_TAG_VALID);
6462 : : ctxt.info.port_based_inner_vlan = 0;
6463 : : /* clear current outer VLAN insertion settings */
6464 : 0 : ctxt.info.outer_vlan_flags = vsi->info.outer_vlan_flags &
6465 : : ~(ICE_AQ_VSI_OUTER_VLAN_PORT_BASED_INSERT |
6466 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M);
6467 [ # # ]: 0 : if (info->config.reject.tagged == 0)
6468 : : vlan_flags |= ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ACCEPTTAGGED;
6469 [ # # ]: 0 : if (info->config.reject.untagged == 0)
6470 : 0 : vlan_flags |= ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ACCEPTUNTAGGED;
6471 : 0 : ctxt.info.outer_vlan_flags |=
6472 : : ICE_AQ_VSI_OUTER_VLAN_BLOCK_TX_DESC |
6473 : 0 : ((vlan_flags <<
6474 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) &
6475 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M);
6476 : :
6477 : 0 : status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
6478 [ # # ]: 0 : if (status != ICE_SUCCESS) {
6479 : 0 : PMD_DRV_LOG(ERR,
6480 : : "update VSI for disabling outer VLAN insertion failed, err %d",
6481 : : status);
6482 : : err = -EINVAL;
6483 : : } else {
6484 : 0 : vsi->info.outer_vlan_flags = ctxt.info.outer_vlan_flags;
6485 : 0 : vsi->info.port_based_inner_vlan = ctxt.info.port_based_inner_vlan;
6486 : : }
6487 : :
6488 : 0 : return err;
6489 : : }
6490 : :
6491 : : static int
6492 : 0 : ice_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on)
6493 : : {
6494 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6495 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6496 [ # # ]: 0 : struct rte_eth_dev_data *data = pf->dev_data;
6497 : : struct ice_vsi_vlan_pvid_info info;
6498 : : int ret;
6499 : :
6500 : : memset(&info, 0, sizeof(info));
6501 : 0 : info.on = on;
6502 [ # # ]: 0 : if (info.on) {
6503 : 0 : info.config.pvid = pvid;
6504 : : } else {
6505 : 0 : info.config.reject.tagged =
6506 : 0 : data->dev_conf.txmode.hw_vlan_reject_tagged;
6507 : 0 : info.config.reject.untagged =
6508 : 0 : data->dev_conf.txmode.hw_vlan_reject_untagged;
6509 : : }
6510 : :
6511 [ # # ]: 0 : if (ice_is_dvm_ena(&vsi->adapter->hw)) {
6512 [ # # ]: 0 : if (on)
6513 : 0 : return ice_vsi_set_outer_port_vlan(vsi, pvid, pf->outer_ethertype);
6514 : : else
6515 : 0 : return ice_vsi_dis_outer_insertion(vsi, &info);
6516 : : }
6517 : :
6518 : 0 : ret = ice_vsi_vlan_pvid_set(vsi, &info);
6519 [ # # ]: 0 : if (ret < 0) {
6520 : 0 : PMD_DRV_LOG(ERR, "Failed to set pvid.");
6521 : 0 : return -EINVAL;
6522 : : }
6523 : :
6524 : : return 0;
6525 : : }
6526 : :
6527 : 0 : static int ice_vsi_ena_outer_insertion(struct ice_vsi *vsi, uint16_t tpid)
6528 : : {
6529 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
6530 : : struct ice_vsi_ctx ctxt;
6531 : : int status, err = 0;
6532 : : u8 tag_type;
6533 : : /* do not allow modifying VLAN stripping when a port VLAN is configured
6534 : : * on this VSI
6535 : : */
6536 [ # # ]: 0 : if (vsi->info.port_based_outer_vlan)
6537 : : return 0;
6538 : :
6539 : : if (tpid_to_vsi_outer_vlan_type(tpid, &tag_type))
6540 : : return -EINVAL;
6541 : :
6542 : : memset(&ctxt, 0, sizeof(ctxt));
6543 : 0 : ctxt.info.valid_sections =
6544 : : rte_cpu_to_le_16(ICE_AQ_VSI_PROP_OUTER_TAG_VALID);
6545 : : /* clear current outer VLAN insertion settings */
6546 : 0 : ctxt.info.outer_vlan_flags = vsi->info.outer_vlan_flags &
6547 : : ~(ICE_AQ_VSI_OUTER_VLAN_PORT_BASED_INSERT |
6548 : : ICE_AQ_VSI_OUTER_VLAN_BLOCK_TX_DESC |
6549 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M |
6550 : : ICE_AQ_VSI_OUTER_TAG_TYPE_M);
6551 : 0 : ctxt.info.outer_vlan_flags |=
6552 : : ((ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ALL <<
6553 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_S) &
6554 : : ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M) |
6555 : 0 : ((tag_type << ICE_AQ_VSI_OUTER_TAG_TYPE_S) &
6556 : : ICE_AQ_VSI_OUTER_TAG_TYPE_M);
6557 : :
6558 : 0 : status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL);
6559 [ # # ]: 0 : if (status) {
6560 : 0 : PMD_DRV_LOG(ERR, "Update VSI failed to enable outer VLAN stripping");
6561 : : err = -EIO;
6562 : : } else {
6563 : 0 : vsi->info.outer_vlan_flags = ctxt.info.outer_vlan_flags;
6564 : : }
6565 : :
6566 : : return err;
6567 : : }
6568 : :
6569 : : static int
6570 : 0 : ice_vlan_tpid_set(struct rte_eth_dev *dev,
6571 : : enum rte_vlan_type vlan_type,
6572 : : uint16_t tpid)
6573 : : {
6574 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
6575 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6576 : 0 : struct ice_vsi *vsi = pf->main_vsi;
6577 : 0 : uint64_t qinq = dev->data->dev_conf.rxmode.offloads &
6578 : : RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
6579 : : int err = 0;
6580 : :
6581 [ # # ]: 0 : if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
6582 : 0 : vlan_type != RTE_ETH_VLAN_TYPE_OUTER) ||
6583 [ # # # # ]: 0 : (!qinq && vlan_type == RTE_ETH_VLAN_TYPE_INNER) ||
6584 : 0 : !ice_is_supported_port_vlan_proto(hw, tpid)) {
6585 : 0 : PMD_DRV_LOG(ERR,
6586 : : "Unsupported vlan type.");
6587 : 0 : return -EINVAL;
6588 : : }
6589 : :
6590 : 0 : err = ice_vsi_ena_outer_insertion(vsi, tpid);
6591 [ # # ]: 0 : if (!err)
6592 : 0 : pf->outer_ethertype = tpid;
6593 : :
6594 : : return err;
6595 : : }
6596 : :
6597 : : static int
6598 : 0 : ice_get_eeprom_length(struct rte_eth_dev *dev)
6599 : : {
6600 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6601 : :
6602 : 0 : return hw->flash.flash_size;
6603 : : }
6604 : :
6605 : : static int
6606 : 0 : ice_get_eeprom(struct rte_eth_dev *dev,
6607 : : struct rte_dev_eeprom_info *eeprom)
6608 : : {
6609 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6610 : 0 : uint8_t *data = eeprom->data;
6611 : : int status;
6612 : :
6613 : 0 : eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6614 : :
6615 : 0 : status = ice_acquire_nvm(hw, ICE_RES_READ);
6616 [ # # ]: 0 : if (status) {
6617 : 0 : PMD_DRV_LOG(ERR, "acquire nvm failed.");
6618 : 0 : return -EIO;
6619 : : }
6620 : :
6621 : 0 : status = ice_read_flat_nvm(hw, eeprom->offset, &eeprom->length,
6622 : : data, false);
6623 : :
6624 : 0 : ice_release_nvm(hw);
6625 : :
6626 [ # # ]: 0 : if (status) {
6627 : 0 : PMD_DRV_LOG(ERR, "EEPROM read failed.");
6628 : 0 : return -EIO;
6629 : : }
6630 : :
6631 : : return 0;
6632 : : }
6633 : :
6634 : : static int
6635 : 0 : ice_get_module_info(struct rte_eth_dev *dev,
6636 : : struct rte_eth_dev_module_info *modinfo)
6637 : : {
6638 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6639 : 0 : u8 sff8472_comp = 0;
6640 : 0 : u8 sff8472_swap = 0;
6641 : 0 : u8 sff8636_rev = 0;
6642 : 0 : u8 value = 0;
6643 : : int status;
6644 : :
6645 : 0 : status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR, 0x00, 0x00,
6646 : : 0, &value, 1, 0, NULL);
6647 [ # # ]: 0 : if (status)
6648 : : return -EIO;
6649 : :
6650 [ # # # ]: 0 : switch (value) {
6651 : 0 : case ICE_MODULE_TYPE_SFP:
6652 : 0 : status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
6653 : : ICE_MODULE_SFF_8472_COMP, 0x00, 0,
6654 : : &sff8472_comp, 1, 0, NULL);
6655 [ # # ]: 0 : if (status)
6656 : : return -EIO;
6657 : 0 : status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
6658 : : ICE_MODULE_SFF_8472_SWAP, 0x00, 0,
6659 : : &sff8472_swap, 1, 0, NULL);
6660 [ # # ]: 0 : if (status)
6661 : : return -EIO;
6662 : :
6663 [ # # ]: 0 : if (sff8472_swap & ICE_MODULE_SFF_ADDR_MODE) {
6664 : 0 : modinfo->type = ICE_MODULE_SFF_8079;
6665 : 0 : modinfo->eeprom_len = ICE_MODULE_SFF_8079_LEN;
6666 [ # # # # ]: 0 : } else if (sff8472_comp &&
6667 : : (sff8472_swap & ICE_MODULE_SFF_DIAG_CAPAB)) {
6668 : 0 : modinfo->type = ICE_MODULE_SFF_8472;
6669 : 0 : modinfo->eeprom_len = ICE_MODULE_SFF_8472_LEN;
6670 : : } else {
6671 : 0 : modinfo->type = ICE_MODULE_SFF_8079;
6672 : 0 : modinfo->eeprom_len = ICE_MODULE_SFF_8079_LEN;
6673 : : }
6674 : : break;
6675 : 0 : case ICE_MODULE_TYPE_QSFP_PLUS:
6676 : : case ICE_MODULE_TYPE_QSFP28:
6677 : 0 : status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
6678 : : ICE_MODULE_REVISION_ADDR, 0x00, 0,
6679 : : &sff8636_rev, 1, 0, NULL);
6680 [ # # ]: 0 : if (status)
6681 : : return -EIO;
6682 : : /* Check revision compliance */
6683 [ # # ]: 0 : if (sff8636_rev > 0x02) {
6684 : : /* Module is SFF-8636 compliant */
6685 : 0 : modinfo->type = ICE_MODULE_SFF_8636;
6686 : 0 : modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN;
6687 : : } else {
6688 : 0 : modinfo->type = ICE_MODULE_SFF_8436;
6689 : 0 : modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN;
6690 : : }
6691 : : break;
6692 : 0 : default:
6693 : 0 : PMD_DRV_LOG(WARNING, "SFF Module Type not recognized.");
6694 : 0 : return -EINVAL;
6695 : : }
6696 : : return 0;
6697 : : }
6698 : :
6699 : : static int
6700 : 0 : ice_get_module_eeprom(struct rte_eth_dev *dev,
6701 : : struct rte_dev_eeprom_info *info)
6702 : : {
6703 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6704 : : #define SFF_READ_BLOCK_SIZE 8
6705 : : #define I2C_BUSY_TRY_TIMES 4
6706 : : #define I2C_USLEEP_MIN_TIME 1500
6707 : : #define I2C_USLEEP_MAX_TIME 2500
6708 : 0 : uint8_t value[SFF_READ_BLOCK_SIZE] = {0};
6709 : : uint8_t addr = ICE_I2C_EEPROM_DEV_ADDR;
6710 : : uint8_t *data = NULL;
6711 : : bool is_sfp = false;
6712 : : uint32_t i, j;
6713 : : uint32_t offset = 0;
6714 : : uint8_t page = 0;
6715 : : int status;
6716 : :
6717 [ # # # # : 0 : if (!info || !info->length || !info->data)
# # ]
6718 : : return -EINVAL;
6719 : :
6720 : 0 : status = ice_aq_sff_eeprom(hw, 0, addr, offset, page, 0, value, 1, 0,
6721 : : NULL);
6722 [ # # ]: 0 : if (status)
6723 : : return -EIO;
6724 : :
6725 [ # # ]: 0 : if (value[0] == ICE_MODULE_TYPE_SFP)
6726 : : is_sfp = true;
6727 : :
6728 : 0 : data = info->data;
6729 : 0 : memset(data, 0, info->length);
6730 [ # # ]: 0 : for (i = 0; i < info->length; i += SFF_READ_BLOCK_SIZE) {
6731 : 0 : offset = i + info->offset;
6732 : : page = 0;
6733 : :
6734 : : /* Check if we need to access the other memory page */
6735 [ # # ]: 0 : if (is_sfp) {
6736 [ # # ]: 0 : if (offset >= ICE_MODULE_SFF_8079_LEN) {
6737 : 0 : offset -= ICE_MODULE_SFF_8079_LEN;
6738 : : addr = ICE_I2C_EEPROM_DEV_ADDR2;
6739 : : }
6740 : : } else {
6741 [ # # ]: 0 : while (offset >= ICE_MODULE_SFF_8436_LEN) {
6742 : : /* Compute memory page number and offset. */
6743 : 0 : offset -= ICE_MODULE_SFF_8436_LEN / 2;
6744 : 0 : page++;
6745 : : }
6746 : : }
6747 : :
6748 : : /* Bit 2 of eeprom address 0x02 declares upper
6749 : : * pages are disabled on QSFP modules.
6750 : : * SFP modules only ever use page 0.
6751 : : */
6752 [ # # # # ]: 0 : if (page == 0 || !(data[0x2] & 0x4)) {
6753 : : uint32_t copy_len;
6754 : :
6755 : : /* If i2c bus is busy due to slow page change or
6756 : : * link management access, call can fail.
6757 : : * This is normal. So we retry this a few times.
6758 : : */
6759 [ # # ]: 0 : for (j = 0; j < I2C_BUSY_TRY_TIMES; j++) {
6760 : 0 : status = ice_aq_sff_eeprom(hw, 0, addr, offset,
6761 : 0 : page, !is_sfp, value,
6762 : : SFF_READ_BLOCK_SIZE,
6763 : : 0, NULL);
6764 : 0 : PMD_DRV_LOG(DEBUG, "SFF %02X %02X %02X %X = "
6765 : : "%02X%02X%02X%02X."
6766 : : "%02X%02X%02X%02X (%X)",
6767 : : addr, offset, page, is_sfp,
6768 : : value[0], value[1],
6769 : : value[2], value[3],
6770 : : value[4], value[5],
6771 : : value[6], value[7],
6772 : : status);
6773 [ # # ]: 0 : if (status) {
6774 : 0 : usleep_range(I2C_USLEEP_MIN_TIME,
6775 : : I2C_USLEEP_MAX_TIME);
6776 : : memset(value, 0, SFF_READ_BLOCK_SIZE);
6777 : : continue;
6778 : : }
6779 : : break;
6780 : : }
6781 : :
6782 : : /* Clamp the copy to the bytes actually requested: the final
6783 : : * block is shorter than SFF_READ_BLOCK_SIZE whenever
6784 : : * info->length is not a multiple of it.
6785 : : */
6786 : 0 : copy_len = RTE_MIN((uint32_t)SFF_READ_BLOCK_SIZE, info->length - i);
6787 : 0 : memcpy(data + i, value, copy_len);
6788 : : }
6789 : : }
6790 : :
6791 : : return 0;
6792 : : }
6793 : :
6794 : : static void
6795 : : ice_stat_update_32(struct ice_hw *hw,
6796 : : uint32_t reg,
6797 : : bool offset_loaded,
6798 : : uint64_t *offset,
6799 : : uint64_t *stat)
6800 : : {
6801 : : uint64_t new_data;
6802 : :
6803 : 0 : new_data = (uint64_t)ICE_READ_REG(hw, reg);
6804 [ # # # # : 0 : if (!offset_loaded)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # ]
6805 : 0 : *offset = new_data;
6806 : :
6807 [ # # # # : 0 : if (new_data >= *offset)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # ]
6808 : 0 : *stat = (uint64_t)(new_data - *offset);
6809 : : else
6810 : 0 : *stat = (uint64_t)((new_data +
6811 : : ((uint64_t)1 << ICE_32_BIT_WIDTH))
6812 : : - *offset);
6813 : : }
6814 : :
6815 : : static void
6816 : 0 : ice_stat_update_40(struct ice_hw *hw,
6817 : : uint32_t hireg,
6818 : : uint32_t loreg,
6819 : : bool offset_loaded,
6820 : : uint64_t *offset,
6821 : : uint64_t *stat)
6822 : : {
6823 : : uint64_t new_data;
6824 : : uint32_t lo_old, hi, lo;
6825 : :
6826 : : do {
6827 : 0 : lo_old = ICE_READ_REG(hw, loreg);
6828 : 0 : hi = ICE_READ_REG(hw, hireg);
6829 : 0 : lo = ICE_READ_REG(hw, loreg);
6830 [ # # ]: 0 : } while (lo_old > lo);
6831 : :
6832 : 0 : new_data = (uint64_t)lo;
6833 : 0 : new_data |= (uint64_t)(hi & ICE_8_BIT_MASK) << ICE_32_BIT_WIDTH;
6834 : :
6835 [ # # ]: 0 : if (!offset_loaded)
6836 : 0 : *offset = new_data;
6837 : :
6838 [ # # ]: 0 : if (new_data >= *offset)
6839 : 0 : *stat = new_data - *offset;
6840 : : else
6841 : 0 : *stat = (uint64_t)((new_data +
6842 : : ((uint64_t)1 << ICE_40_BIT_WIDTH)) -
6843 : : *offset);
6844 : :
6845 : 0 : *stat &= ICE_40_BIT_MASK;
6846 : 0 : }
6847 : :
6848 : : /**
6849 : : * There are various counters that are bubbled up in uint64 values but do not make use of all
6850 : : * 64 bits, most commonly using only 32 or 40 bits. This function handles the "overflow" when
6851 : : * these counters hit their 32 or 40 bit limit to enlarge that limitation to 64 bits.
6852 : :
6853 : : * @offset_loaded: refers to whether this function has been called before and old_value is known to
6854 : : * have a value, i.e. its possible that value has overflowed past its original limitation
6855 : : * @value_bit_limitation: refers to the number of bits the given value uses before overflowing
6856 : : * @value: is the current value with its original limitation (i.e. 32 or 40 bits)
6857 : : * @old_value: is expected to be the previous value of the given value with the overflow accounted
6858 : : * for (i.e. the full 64 bit previous value)
6859 : : *
6860 : : * This function will appropriately update both value and old_value, accounting for overflow
6861 : : */
6862 : : static void
6863 : : ice_handle_overflow(bool offset_loaded,
6864 : : uint8_t value_bit_limitation,
6865 : : uint64_t *value,
6866 : : uint64_t *old_value)
6867 : : {
6868 : : uint64_t low_bit_mask = RTE_LEN2MASK(value_bit_limitation, uint64_t);
6869 : : uint64_t high_bit_mask = ~low_bit_mask;
6870 : :
6871 : 0 : if (offset_loaded) {
6872 [ # # # # : 0 : if ((*old_value & low_bit_mask) > *value)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
6873 : 0 : *value += (uint64_t)1 << value_bit_limitation;
6874 : 0 : *value += *old_value & high_bit_mask;
6875 : : }
6876 [ # # # # : 0 : *old_value = *value;
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
6877 : : }
6878 : :
6879 : : /* Get all the statistics of a VSI */
6880 : : static void
6881 : 0 : ice_update_vsi_stats(struct ice_vsi *vsi)
6882 : : {
6883 : : struct ice_eth_stats *oes = &vsi->eth_stats_offset;
6884 : : struct ice_eth_stats *nes = &vsi->eth_stats;
6885 : 0 : struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
6886 : 0 : int idx = rte_le_to_cpu_16(vsi->vsi_id);
6887 : :
6888 : : /*
6889 : : * Unicast/multicast/broadcast counters include discarded packets. Received packets is
6890 : : * calculated by deducting discards from unicast/multicast/broadcast. To prevent a
6891 : : * potential underflow, read discards first to guarantee it is smaller than
6892 : : * unicast/multicast/broadcast.
6893 : : */
6894 : 0 : ice_stat_update_32(hw, GLV_RDPC(idx), vsi->offset_loaded,
6895 : : &oes->rx_discards, &nes->rx_discards);
6896 : :
6897 : 0 : ice_stat_update_40(hw, GLV_GORCH(idx), GLV_GORCL(idx),
6898 : 0 : vsi->offset_loaded, &oes->rx_bytes,
6899 : 0 : &nes->rx_bytes);
6900 : 0 : ice_stat_update_40(hw, GLV_UPRCH(idx), GLV_UPRCL(idx),
6901 : 0 : vsi->offset_loaded, &oes->rx_unicast,
6902 : 0 : &nes->rx_unicast);
6903 : 0 : ice_stat_update_40(hw, GLV_MPRCH(idx), GLV_MPRCL(idx),
6904 : 0 : vsi->offset_loaded, &oes->rx_multicast,
6905 : 0 : &nes->rx_multicast);
6906 : 0 : ice_stat_update_40(hw, GLV_BPRCH(idx), GLV_BPRCL(idx),
6907 : 0 : vsi->offset_loaded, &oes->rx_broadcast,
6908 : 0 : &nes->rx_broadcast);
6909 : :
6910 [ # # ]: 0 : ice_handle_overflow(vsi->offset_loaded, ICE_40_BIT_WIDTH,
6911 : : &nes->rx_unicast, &vsi->old_get_stats_fields.rx_unicast);
6912 : : ice_handle_overflow(vsi->offset_loaded, ICE_40_BIT_WIDTH,
6913 : : &nes->rx_multicast, &vsi->old_get_stats_fields.rx_multicast);
6914 : : ice_handle_overflow(vsi->offset_loaded, ICE_40_BIT_WIDTH,
6915 : : &nes->rx_broadcast, &vsi->old_get_stats_fields.rx_broadcast);
6916 : : ice_handle_overflow(vsi->offset_loaded, ICE_40_BIT_WIDTH,
6917 : : &nes->rx_bytes, &vsi->old_get_stats_fields.rx_bytes);
6918 : :
6919 : : /* exclude CRC bytes */
6920 : 0 : nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast +
6921 : 0 : nes->rx_broadcast) * RTE_ETHER_CRC_LEN;
6922 : :
6923 : : /* GLV_REPC not supported */
6924 : : /* GLV_RMPC not supported */
6925 : 0 : ice_stat_update_32(hw, GLSWID_RUPP(idx), vsi->offset_loaded,
6926 : : &oes->rx_unknown_protocol,
6927 : : &nes->rx_unknown_protocol);
6928 : 0 : ice_stat_update_40(hw, GLV_GOTCH(idx), GLV_GOTCL(idx),
6929 : 0 : vsi->offset_loaded, &oes->tx_bytes,
6930 : 0 : &nes->tx_bytes);
6931 : 0 : ice_stat_update_40(hw, GLV_UPTCH(idx), GLV_UPTCL(idx),
6932 : 0 : vsi->offset_loaded, &oes->tx_unicast,
6933 : 0 : &nes->tx_unicast);
6934 : 0 : ice_stat_update_40(hw, GLV_MPTCH(idx), GLV_MPTCL(idx),
6935 : 0 : vsi->offset_loaded, &oes->tx_multicast,
6936 : 0 : &nes->tx_multicast);
6937 : 0 : ice_stat_update_40(hw, GLV_BPTCH(idx), GLV_BPTCL(idx),
6938 : 0 : vsi->offset_loaded, &oes->tx_broadcast,
6939 : 0 : &nes->tx_broadcast);
6940 : : /* GLV_TDPC not supported */
6941 : 0 : ice_stat_update_32(hw, GLV_TEPC(idx), vsi->offset_loaded,
6942 : : &oes->tx_errors, &nes->tx_errors);
6943 : :
6944 [ # # ]: 0 : ice_handle_overflow(vsi->offset_loaded, ICE_32_BIT_WIDTH,
6945 : : &nes->rx_discards, &vsi->old_get_stats_fields.rx_discards);
6946 : : ice_handle_overflow(vsi->offset_loaded, ICE_32_BIT_WIDTH,
6947 : : &nes->tx_errors, &vsi->old_get_stats_fields.tx_errors);
6948 : : ice_handle_overflow(vsi->offset_loaded, ICE_40_BIT_WIDTH,
6949 : : &nes->tx_bytes, &vsi->old_get_stats_fields.tx_bytes);
6950 : :
6951 : 0 : vsi->offset_loaded = true;
6952 : :
6953 : 0 : PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats start **************",
6954 : : vsi->vsi_id);
6955 : 0 : PMD_DRV_LOG(DEBUG, "rx_bytes: %"PRIu64"", nes->rx_bytes);
6956 : 0 : PMD_DRV_LOG(DEBUG, "rx_unicast: %"PRIu64"", nes->rx_unicast);
6957 : 0 : PMD_DRV_LOG(DEBUG, "rx_multicast: %"PRIu64"", nes->rx_multicast);
6958 : 0 : PMD_DRV_LOG(DEBUG, "rx_broadcast: %"PRIu64"", nes->rx_broadcast);
6959 : 0 : PMD_DRV_LOG(DEBUG, "rx_discards: %"PRIu64"", nes->rx_discards);
6960 : 0 : PMD_DRV_LOG(DEBUG, "rx_unknown_protocol: %"PRIu64"",
6961 : : nes->rx_unknown_protocol);
6962 : 0 : PMD_DRV_LOG(DEBUG, "tx_bytes: %"PRIu64"", nes->tx_bytes);
6963 : 0 : PMD_DRV_LOG(DEBUG, "tx_unicast: %"PRIu64"", nes->tx_unicast);
6964 : 0 : PMD_DRV_LOG(DEBUG, "tx_multicast: %"PRIu64"", nes->tx_multicast);
6965 : 0 : PMD_DRV_LOG(DEBUG, "tx_broadcast: %"PRIu64"", nes->tx_broadcast);
6966 : 0 : PMD_DRV_LOG(DEBUG, "tx_discards: %"PRIu64"", nes->tx_discards);
6967 : 0 : PMD_DRV_LOG(DEBUG, "tx_errors: %"PRIu64"", nes->tx_errors);
6968 : 0 : PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats end ****************",
6969 : : vsi->vsi_id);
6970 : 0 : }
6971 : :
6972 : : static void
6973 : 0 : ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw)
6974 : : {
6975 : : struct ice_hw_port_stats *ns = &pf->stats; /* new stats */
6976 : : struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */
6977 : :
6978 : : /* Get statistics of struct ice_eth_stats */
6979 : 0 : ice_stat_update_40(hw, GLPRT_GORCH(hw->port_info->lport),
6980 : 0 : GLPRT_GORCL(hw->port_info->lport),
6981 : 0 : pf->offset_loaded, &os->eth.rx_bytes,
6982 : 0 : &ns->eth.rx_bytes);
6983 : 0 : ice_stat_update_40(hw, GLPRT_UPRCH(hw->port_info->lport),
6984 : 0 : GLPRT_UPRCL(hw->port_info->lport),
6985 : 0 : pf->offset_loaded, &os->eth.rx_unicast,
6986 : 0 : &ns->eth.rx_unicast);
6987 : 0 : ice_stat_update_40(hw, GLPRT_MPRCH(hw->port_info->lport),
6988 : 0 : GLPRT_MPRCL(hw->port_info->lport),
6989 : 0 : pf->offset_loaded, &os->eth.rx_multicast,
6990 : 0 : &ns->eth.rx_multicast);
6991 : 0 : ice_stat_update_40(hw, GLPRT_BPRCH(hw->port_info->lport),
6992 : 0 : GLPRT_BPRCL(hw->port_info->lport),
6993 : 0 : pf->offset_loaded, &os->eth.rx_broadcast,
6994 : 0 : &ns->eth.rx_broadcast);
6995 : : ice_stat_update_32(hw, PRTRPB_RDPC,
6996 : 0 : pf->offset_loaded, &os->eth.rx_discards,
6997 : : &ns->eth.rx_discards);
6998 : :
6999 [ # # ]: 0 : ice_handle_overflow(pf->offset_loaded, ICE_40_BIT_WIDTH,
7000 : : &ns->eth.rx_bytes, &pf->old_get_stats_fields.rx_bytes);
7001 : : ice_handle_overflow(pf->offset_loaded, ICE_32_BIT_WIDTH,
7002 : : &ns->eth.rx_discards, &pf->old_get_stats_fields.rx_discards);
7003 : :
7004 : : /* Workaround: CRC size should not be included in byte statistics,
7005 : : * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx
7006 : : * packet.
7007 : : */
7008 : 0 : ns->eth.rx_bytes -= (ns->eth.rx_unicast + ns->eth.rx_multicast +
7009 : 0 : ns->eth.rx_broadcast) * RTE_ETHER_CRC_LEN;
7010 : :
7011 : : /* GLPRT_REPC not supported */
7012 : : /* GLPRT_RMPC not supported */
7013 : 0 : ice_stat_update_32(hw, GLSWID_RUPP(hw->port_info->lport),
7014 : : pf->offset_loaded,
7015 : : &os->eth.rx_unknown_protocol,
7016 : : &ns->eth.rx_unknown_protocol);
7017 : 0 : ice_stat_update_40(hw, GLPRT_GOTCH(hw->port_info->lport),
7018 : 0 : GLPRT_GOTCL(hw->port_info->lport),
7019 : 0 : pf->offset_loaded, &os->eth.tx_bytes,
7020 : 0 : &ns->eth.tx_bytes);
7021 : 0 : ice_stat_update_40(hw, GLPRT_UPTCH(hw->port_info->lport),
7022 : 0 : GLPRT_UPTCL(hw->port_info->lport),
7023 : 0 : pf->offset_loaded, &os->eth.tx_unicast,
7024 : 0 : &ns->eth.tx_unicast);
7025 : 0 : ice_stat_update_40(hw, GLPRT_MPTCH(hw->port_info->lport),
7026 : 0 : GLPRT_MPTCL(hw->port_info->lport),
7027 : 0 : pf->offset_loaded, &os->eth.tx_multicast,
7028 : 0 : &ns->eth.tx_multicast);
7029 : 0 : ice_stat_update_40(hw, GLPRT_BPTCH(hw->port_info->lport),
7030 : 0 : GLPRT_BPTCL(hw->port_info->lport),
7031 : 0 : pf->offset_loaded, &os->eth.tx_broadcast,
7032 : 0 : &ns->eth.tx_broadcast);
7033 : :
7034 [ # # ]: 0 : ice_handle_overflow(pf->offset_loaded, ICE_40_BIT_WIDTH,
7035 : : &ns->eth.tx_bytes, &pf->old_get_stats_fields.tx_bytes);
7036 : : ice_handle_overflow(pf->offset_loaded, ICE_40_BIT_WIDTH,
7037 : : &ns->eth.tx_unicast, &pf->old_get_stats_fields.tx_unicast);
7038 : : ice_handle_overflow(pf->offset_loaded, ICE_40_BIT_WIDTH,
7039 : : &ns->eth.tx_multicast, &pf->old_get_stats_fields.tx_multicast);
7040 : : ice_handle_overflow(pf->offset_loaded, ICE_40_BIT_WIDTH,
7041 : : &ns->eth.tx_broadcast, &pf->old_get_stats_fields.tx_broadcast);
7042 : :
7043 : 0 : ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast +
7044 : 0 : ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN;
7045 : :
7046 : : /* GLPRT_TEPC not supported */
7047 : :
7048 : : /* additional port specific stats */
7049 : 0 : ice_stat_update_32(hw, GLPRT_TDOLD(hw->port_info->lport),
7050 : : pf->offset_loaded, &os->tx_dropped_link_down,
7051 : : &ns->tx_dropped_link_down);
7052 : 0 : ice_stat_update_32(hw, GLPRT_CRCERRS(hw->port_info->lport),
7053 : 0 : pf->offset_loaded, &os->crc_errors,
7054 : : &ns->crc_errors);
7055 : 0 : ice_stat_update_32(hw, GLPRT_ILLERRC(hw->port_info->lport),
7056 : 0 : pf->offset_loaded, &os->illegal_bytes,
7057 : : &ns->illegal_bytes);
7058 : : /* GLPRT_ERRBC not supported */
7059 : 0 : ice_stat_update_32(hw, GLPRT_MLFC(hw->port_info->lport),
7060 : 0 : pf->offset_loaded, &os->mac_local_faults,
7061 : : &ns->mac_local_faults);
7062 : 0 : ice_stat_update_32(hw, GLPRT_MRFC(hw->port_info->lport),
7063 : 0 : pf->offset_loaded, &os->mac_remote_faults,
7064 : : &ns->mac_remote_faults);
7065 : :
7066 : 0 : ice_stat_update_32(hw, GLPRT_RLEC(hw->port_info->lport),
7067 : 0 : pf->offset_loaded, &os->rx_len_errors,
7068 : : &ns->rx_len_errors);
7069 : :
7070 : 0 : ice_stat_update_32(hw, GLPRT_LXONRXC(hw->port_info->lport),
7071 : 0 : pf->offset_loaded, &os->link_xon_rx,
7072 : : &ns->link_xon_rx);
7073 : 0 : ice_stat_update_32(hw, GLPRT_LXOFFRXC(hw->port_info->lport),
7074 : 0 : pf->offset_loaded, &os->link_xoff_rx,
7075 : : &ns->link_xoff_rx);
7076 : 0 : ice_stat_update_32(hw, GLPRT_LXONTXC(hw->port_info->lport),
7077 : 0 : pf->offset_loaded, &os->link_xon_tx,
7078 : : &ns->link_xon_tx);
7079 : 0 : ice_stat_update_32(hw, GLPRT_LXOFFTXC(hw->port_info->lport),
7080 : 0 : pf->offset_loaded, &os->link_xoff_tx,
7081 : : &ns->link_xoff_tx);
7082 : 0 : ice_stat_update_40(hw, GLPRT_PRC64H(hw->port_info->lport),
7083 : 0 : GLPRT_PRC64L(hw->port_info->lport),
7084 : 0 : pf->offset_loaded, &os->rx_size_64,
7085 : 0 : &ns->rx_size_64);
7086 : 0 : ice_stat_update_40(hw, GLPRT_PRC127H(hw->port_info->lport),
7087 : 0 : GLPRT_PRC127L(hw->port_info->lport),
7088 : 0 : pf->offset_loaded, &os->rx_size_127,
7089 : 0 : &ns->rx_size_127);
7090 : 0 : ice_stat_update_40(hw, GLPRT_PRC255H(hw->port_info->lport),
7091 : 0 : GLPRT_PRC255L(hw->port_info->lport),
7092 : 0 : pf->offset_loaded, &os->rx_size_255,
7093 : 0 : &ns->rx_size_255);
7094 : 0 : ice_stat_update_40(hw, GLPRT_PRC511H(hw->port_info->lport),
7095 : 0 : GLPRT_PRC511L(hw->port_info->lport),
7096 : 0 : pf->offset_loaded, &os->rx_size_511,
7097 : 0 : &ns->rx_size_511);
7098 : 0 : ice_stat_update_40(hw, GLPRT_PRC1023H(hw->port_info->lport),
7099 : 0 : GLPRT_PRC1023L(hw->port_info->lport),
7100 : 0 : pf->offset_loaded, &os->rx_size_1023,
7101 : 0 : &ns->rx_size_1023);
7102 : 0 : ice_stat_update_40(hw, GLPRT_PRC1522H(hw->port_info->lport),
7103 : 0 : GLPRT_PRC1522L(hw->port_info->lport),
7104 : 0 : pf->offset_loaded, &os->rx_size_1522,
7105 : 0 : &ns->rx_size_1522);
7106 : 0 : ice_stat_update_40(hw, GLPRT_PRC9522H(hw->port_info->lport),
7107 : 0 : GLPRT_PRC9522L(hw->port_info->lport),
7108 : 0 : pf->offset_loaded, &os->rx_size_big,
7109 : 0 : &ns->rx_size_big);
7110 : 0 : ice_stat_update_32(hw, GLPRT_RUC(hw->port_info->lport),
7111 : 0 : pf->offset_loaded, &os->rx_undersize,
7112 : : &ns->rx_undersize);
7113 : 0 : ice_stat_update_32(hw, GLPRT_RFC(hw->port_info->lport),
7114 : 0 : pf->offset_loaded, &os->rx_fragments,
7115 : : &ns->rx_fragments);
7116 : 0 : ice_stat_update_32(hw, GLPRT_ROC(hw->port_info->lport),
7117 : 0 : pf->offset_loaded, &os->rx_oversize,
7118 : : &ns->rx_oversize);
7119 : 0 : ice_stat_update_32(hw, GLPRT_RJC(hw->port_info->lport),
7120 : 0 : pf->offset_loaded, &os->rx_jabber,
7121 : : &ns->rx_jabber);
7122 : 0 : ice_stat_update_40(hw, GLPRT_PTC64H(hw->port_info->lport),
7123 : 0 : GLPRT_PTC64L(hw->port_info->lport),
7124 : 0 : pf->offset_loaded, &os->tx_size_64,
7125 : 0 : &ns->tx_size_64);
7126 : 0 : ice_stat_update_40(hw, GLPRT_PTC127H(hw->port_info->lport),
7127 : 0 : GLPRT_PTC127L(hw->port_info->lport),
7128 : 0 : pf->offset_loaded, &os->tx_size_127,
7129 : 0 : &ns->tx_size_127);
7130 : 0 : ice_stat_update_40(hw, GLPRT_PTC255H(hw->port_info->lport),
7131 : 0 : GLPRT_PTC255L(hw->port_info->lport),
7132 : 0 : pf->offset_loaded, &os->tx_size_255,
7133 : 0 : &ns->tx_size_255);
7134 : 0 : ice_stat_update_40(hw, GLPRT_PTC511H(hw->port_info->lport),
7135 : 0 : GLPRT_PTC511L(hw->port_info->lport),
7136 : 0 : pf->offset_loaded, &os->tx_size_511,
7137 : 0 : &ns->tx_size_511);
7138 : 0 : ice_stat_update_40(hw, GLPRT_PTC1023H(hw->port_info->lport),
7139 : 0 : GLPRT_PTC1023L(hw->port_info->lport),
7140 : 0 : pf->offset_loaded, &os->tx_size_1023,
7141 : 0 : &ns->tx_size_1023);
7142 : 0 : ice_stat_update_40(hw, GLPRT_PTC1522H(hw->port_info->lport),
7143 : 0 : GLPRT_PTC1522L(hw->port_info->lport),
7144 : 0 : pf->offset_loaded, &os->tx_size_1522,
7145 : 0 : &ns->tx_size_1522);
7146 : 0 : ice_stat_update_40(hw, GLPRT_PTC9522H(hw->port_info->lport),
7147 : 0 : GLPRT_PTC9522L(hw->port_info->lport),
7148 : 0 : pf->offset_loaded, &os->tx_size_big,
7149 : 0 : &ns->tx_size_big);
7150 : :
7151 [ # # ]: 0 : ice_handle_overflow(pf->offset_loaded, ICE_32_BIT_WIDTH,
7152 : : &ns->crc_errors, &pf->old_get_stats_fields.crc_errors);
7153 : : ice_handle_overflow(pf->offset_loaded, ICE_32_BIT_WIDTH,
7154 : : &ns->rx_undersize, &pf->old_get_stats_fields.rx_undersize);
7155 : : ice_handle_overflow(pf->offset_loaded, ICE_32_BIT_WIDTH,
7156 : : &ns->rx_fragments, &pf->old_get_stats_fields.rx_fragments);
7157 : : ice_handle_overflow(pf->offset_loaded, ICE_32_BIT_WIDTH,
7158 : : &ns->rx_oversize, &pf->old_get_stats_fields.rx_oversize);
7159 : : ice_handle_overflow(pf->offset_loaded, ICE_32_BIT_WIDTH,
7160 : : &ns->rx_jabber, &pf->old_get_stats_fields.rx_jabber);
7161 : :
7162 : : /* GLPRT_MSPDC not supported */
7163 : : /* GLPRT_XEC not supported */
7164 : :
7165 [ # # ]: 0 : for (int i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
7166 : 0 : ice_stat_update_40(hw, GLPRT_PXONRXC_H(hw->port_info->lport, i),
7167 : 0 : GLPRT_PXONRXC(hw->port_info->lport, i),
7168 : 0 : pf->offset_loaded, &os->priority_xon_rx[i],
7169 : 0 : &ns->priority_xon_rx[i]);
7170 : 0 : ice_stat_update_40(hw, GLPRT_PXONTXC_H(hw->port_info->lport, i),
7171 : 0 : GLPRT_PXONTXC(hw->port_info->lport, i),
7172 : 0 : pf->offset_loaded, &os->priority_xon_tx[i],
7173 : 0 : &ns->priority_xon_tx[i]);
7174 : 0 : ice_stat_update_40(hw, GLPRT_PXOFFRXC_H(hw->port_info->lport, i),
7175 : 0 : GLPRT_PXOFFRXC(hw->port_info->lport, i),
7176 : 0 : pf->offset_loaded, &os->priority_xoff_rx[i],
7177 : 0 : &ns->priority_xoff_rx[i]);
7178 : 0 : ice_stat_update_40(hw, GLPRT_PXOFFTXC_H(hw->port_info->lport, i),
7179 : 0 : GLPRT_PXOFFTXC(hw->port_info->lport, i),
7180 : 0 : pf->offset_loaded, &os->priority_xoff_tx[i],
7181 : 0 : &ns->priority_xoff_tx[i]);
7182 : 0 : ice_stat_update_40(hw, GLPRT_RXON2OFFCNT_H(hw->port_info->lport, i),
7183 : 0 : GLPRT_RXON2OFFCNT(hw->port_info->lport, i),
7184 : 0 : pf->offset_loaded, &os->priority_xon_2_xoff[i],
7185 : 0 : &ns->priority_xon_2_xoff[i]);
7186 : : }
7187 : :
7188 : 0 : pf->offset_loaded = true;
7189 : :
7190 [ # # ]: 0 : if (pf->main_vsi)
7191 : 0 : ice_update_vsi_stats(pf->main_vsi);
7192 : 0 : }
7193 : :
7194 : : /* Get all statistics of a port */
7195 : : static int
7196 : 0 : ice_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
7197 : : struct eth_queue_stats *qstats __rte_unused)
7198 : : {
7199 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
7200 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7201 : : struct ice_hw_port_stats *ns = &pf->stats; /* new stats */
7202 : :
7203 : : /* call read registers - updates values, now write them to struct */
7204 : 0 : ice_read_stats_registers(pf, hw);
7205 : :
7206 : 0 : stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
7207 : 0 : pf->main_vsi->eth_stats.rx_multicast +
7208 : 0 : pf->main_vsi->eth_stats.rx_broadcast -
7209 : 0 : pf->main_vsi->eth_stats.rx_discards;
7210 : 0 : stats->opackets = ns->eth.tx_unicast +
7211 : 0 : ns->eth.tx_multicast +
7212 : 0 : ns->eth.tx_broadcast;
7213 : 0 : stats->ibytes = pf->main_vsi->eth_stats.rx_bytes;
7214 : 0 : stats->obytes = ns->eth.tx_bytes;
7215 : 0 : stats->oerrors = ns->eth.tx_errors +
7216 : 0 : pf->main_vsi->eth_stats.tx_errors;
7217 : :
7218 : : /* Rx Errors */
7219 : 0 : stats->imissed = ns->eth.rx_discards +
7220 : : pf->main_vsi->eth_stats.rx_discards;
7221 : 0 : stats->ierrors = ns->crc_errors +
7222 : 0 : ns->rx_undersize +
7223 : 0 : ns->rx_oversize + ns->rx_fragments + ns->rx_jabber;
7224 : :
7225 : 0 : PMD_DRV_LOG(DEBUG, "*************** PF stats start *****************");
7226 : 0 : PMD_DRV_LOG(DEBUG, "rx_bytes: %"PRIu64"", ns->eth.rx_bytes);
7227 : 0 : PMD_DRV_LOG(DEBUG, "rx_unicast: %"PRIu64"", ns->eth.rx_unicast);
7228 : 0 : PMD_DRV_LOG(DEBUG, "rx_multicast:%"PRIu64"", ns->eth.rx_multicast);
7229 : 0 : PMD_DRV_LOG(DEBUG, "rx_broadcast:%"PRIu64"", ns->eth.rx_broadcast);
7230 : 0 : PMD_DRV_LOG(DEBUG, "rx_discards:%"PRIu64"", ns->eth.rx_discards);
7231 : 0 : PMD_DRV_LOG(DEBUG, "vsi rx_discards:%"PRIu64"",
7232 : : pf->main_vsi->eth_stats.rx_discards);
7233 : 0 : PMD_DRV_LOG(DEBUG, "rx_unknown_protocol: %"PRIu64"",
7234 : : ns->eth.rx_unknown_protocol);
7235 : 0 : PMD_DRV_LOG(DEBUG, "tx_bytes: %"PRIu64"", ns->eth.tx_bytes);
7236 : 0 : PMD_DRV_LOG(DEBUG, "tx_unicast: %"PRIu64"", ns->eth.tx_unicast);
7237 : 0 : PMD_DRV_LOG(DEBUG, "tx_multicast:%"PRIu64"", ns->eth.tx_multicast);
7238 : 0 : PMD_DRV_LOG(DEBUG, "tx_broadcast:%"PRIu64"", ns->eth.tx_broadcast);
7239 : 0 : PMD_DRV_LOG(DEBUG, "tx_discards:%"PRIu64"", ns->eth.tx_discards);
7240 : 0 : PMD_DRV_LOG(DEBUG, "vsi tx_discards:%"PRIu64"",
7241 : : pf->main_vsi->eth_stats.tx_discards);
7242 : 0 : PMD_DRV_LOG(DEBUG, "tx_errors: %"PRIu64"", ns->eth.tx_errors);
7243 : :
7244 : 0 : PMD_DRV_LOG(DEBUG, "tx_dropped_link_down: %"PRIu64"",
7245 : : ns->tx_dropped_link_down);
7246 : 0 : PMD_DRV_LOG(DEBUG, "crc_errors: %"PRIu64"", ns->crc_errors);
7247 : 0 : PMD_DRV_LOG(DEBUG, "illegal_bytes: %"PRIu64"",
7248 : : ns->illegal_bytes);
7249 : 0 : PMD_DRV_LOG(DEBUG, "error_bytes: %"PRIu64"", ns->error_bytes);
7250 : 0 : PMD_DRV_LOG(DEBUG, "mac_local_faults: %"PRIu64"",
7251 : : ns->mac_local_faults);
7252 : 0 : PMD_DRV_LOG(DEBUG, "mac_remote_faults: %"PRIu64"",
7253 : : ns->mac_remote_faults);
7254 : 0 : PMD_DRV_LOG(DEBUG, "link_xon_rx: %"PRIu64"", ns->link_xon_rx);
7255 : 0 : PMD_DRV_LOG(DEBUG, "link_xoff_rx: %"PRIu64"", ns->link_xoff_rx);
7256 : 0 : PMD_DRV_LOG(DEBUG, "link_xon_tx: %"PRIu64"", ns->link_xon_tx);
7257 : 0 : PMD_DRV_LOG(DEBUG, "link_xoff_tx: %"PRIu64"", ns->link_xoff_tx);
7258 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_64: %"PRIu64"", ns->rx_size_64);
7259 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_127: %"PRIu64"", ns->rx_size_127);
7260 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_255: %"PRIu64"", ns->rx_size_255);
7261 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_511: %"PRIu64"", ns->rx_size_511);
7262 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_1023: %"PRIu64"", ns->rx_size_1023);
7263 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_1522: %"PRIu64"", ns->rx_size_1522);
7264 : 0 : PMD_DRV_LOG(DEBUG, "rx_size_big: %"PRIu64"", ns->rx_size_big);
7265 : 0 : PMD_DRV_LOG(DEBUG, "rx_undersize: %"PRIu64"", ns->rx_undersize);
7266 : 0 : PMD_DRV_LOG(DEBUG, "rx_fragments: %"PRIu64"", ns->rx_fragments);
7267 : 0 : PMD_DRV_LOG(DEBUG, "rx_oversize: %"PRIu64"", ns->rx_oversize);
7268 : 0 : PMD_DRV_LOG(DEBUG, "rx_jabber: %"PRIu64"", ns->rx_jabber);
7269 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_64: %"PRIu64"", ns->tx_size_64);
7270 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_127: %"PRIu64"", ns->tx_size_127);
7271 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_255: %"PRIu64"", ns->tx_size_255);
7272 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_511: %"PRIu64"", ns->tx_size_511);
7273 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_1023: %"PRIu64"", ns->tx_size_1023);
7274 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_1522: %"PRIu64"", ns->tx_size_1522);
7275 : 0 : PMD_DRV_LOG(DEBUG, "tx_size_big: %"PRIu64"", ns->tx_size_big);
7276 : 0 : PMD_DRV_LOG(DEBUG, "rx_len_errors: %"PRIu64"", ns->rx_len_errors);
7277 : 0 : PMD_DRV_LOG(DEBUG, "************* PF stats end ****************");
7278 : 0 : return 0;
7279 : : }
7280 : :
7281 : : /* Reset the statistics */
7282 : : static int
7283 : 0 : ice_stats_reset(struct rte_eth_dev *dev)
7284 : : {
7285 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
7286 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7287 : :
7288 : : /* Mark PF and VSI stats to update the offset, aka "reset" */
7289 : 0 : pf->offset_loaded = false;
7290 [ # # ]: 0 : if (pf->main_vsi)
7291 : 0 : pf->main_vsi->offset_loaded = false;
7292 : :
7293 : : /* read the stats, reading current register values into offset */
7294 : 0 : ice_read_stats_registers(pf, hw);
7295 : :
7296 : 0 : memset(&pf->mbuf_stats, 0, sizeof(struct ice_mbuf_stats));
7297 : :
7298 : 0 : return 0;
7299 : : }
7300 : :
7301 : : static bool
7302 : : ice_temp_sensor_supported(struct ice_hw *hw)
7303 : : {
7304 : 0 : return (hw->dev_caps.supported_sensors &
7305 : 0 : ICE_SENSOR_SUPPORT_E810_INT_TEMP) != 0;
7306 : : }
7307 : :
7308 : : /*
7309 : : * Read the internal temperature sensor with the admin queue command
7310 : : * "Get Sensor Reading". The result is kept for one second so that frequent
7311 : : * xstats polling does not load the firmware. On failure all values are 0.
7312 : : */
7313 : : static void
7314 : 0 : ice_update_temp_stats(struct ice_pf *pf, struct ice_hw *hw)
7315 : : {
7316 : : struct ice_aqc_get_sensor_reading_resp resp;
7317 : 0 : struct ice_temp_stats *ts = &pf->temp_stats;
7318 : : uint64_t now = rte_get_timer_cycles();
7319 : : int ret;
7320 : :
7321 [ # # # # ]: 0 : if (pf->temp_read_tsc != 0 &&
7322 : 0 : now - pf->temp_read_tsc < rte_get_timer_hz())
7323 : 0 : return;
7324 : 0 : pf->temp_read_tsc = now;
7325 : :
7326 : : memset(&resp, 0, sizeof(resp));
7327 : 0 : ret = ice_aq_get_sensor_reading(hw, ICE_AQC_INT_TEMP_SENSOR,
7328 : : ICE_AQC_INT_TEMP_FORMAT, &resp, NULL);
7329 [ # # ]: 0 : if (ret != 0) {
7330 : 0 : PMD_DRV_LOG(DEBUG, "Failed to read chip temperature: %d", ret);
7331 : : memset(ts, 0, sizeof(*ts));
7332 : 0 : return;
7333 : : }
7334 : :
7335 : : /* the reading is signed, report below zero as 0 */
7336 : 0 : ts->temp = resp.data.s0f0.temp > 0 ? (uint64_t)resp.data.s0f0.temp : 0;
7337 : 0 : ts->warning = resp.data.s0f0.temp_warning_threshold;
7338 : 0 : ts->critical = resp.data.s0f0.temp_critical_threshold;
7339 : 0 : ts->fatal = resp.data.s0f0.temp_fatal_threshold;
7340 : : }
7341 : :
7342 : : static uint32_t
7343 : : ice_xstats_calc_num(struct rte_eth_dev *dev)
7344 : : {
7345 : : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7346 : : uint32_t num;
7347 : :
7348 : : num = ICE_NB_ETH_XSTATS + ICE_NB_MBUF_XSTATS + ICE_NB_HW_PORT_XSTATS;
7349 [ # # ]: 0 : if (ice_temp_sensor_supported(hw))
7350 : : num += ICE_NB_TEMP_XSTATS;
7351 : :
7352 : : return num;
7353 : : }
7354 : :
7355 : : static void
7356 : : ice_update_mbuf_stats(struct rte_eth_dev *ethdev,
7357 : : struct ice_mbuf_stats *mbuf_stats)
7358 : : {
7359 : : uint16_t idx;
7360 : : struct ci_tx_queue *txq;
7361 : :
7362 [ # # ]: 0 : for (idx = 0; idx < ethdev->data->nb_tx_queues; idx++) {
7363 : 0 : txq = ethdev->data->tx_queues[idx];
7364 : 0 : mbuf_stats->tx_pkt_errors += txq->mbuf_errors;
7365 : : }
7366 : : }
7367 : :
7368 : : static int
7369 : 0 : ice_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
7370 : : unsigned int n)
7371 : : {
7372 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
7373 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7374 : : struct ice_adapter *adapter =
7375 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7376 : : struct ice_mbuf_stats mbuf_stats = {0};
7377 : : unsigned int i;
7378 : : unsigned int count;
7379 [ # # ]: 0 : struct ice_hw_port_stats *hw_stats = &pf->stats;
7380 : :
7381 : : count = ice_xstats_calc_num(dev);
7382 [ # # ]: 0 : if (n < count)
7383 : 0 : return count;
7384 : :
7385 : 0 : ice_read_stats_registers(pf, hw);
7386 : :
7387 [ # # ]: 0 : if (!xstats)
7388 : : return 0;
7389 : :
7390 : : count = 0;
7391 : :
7392 [ # # ]: 0 : if (adapter->devargs.mbuf_check)
7393 : : ice_update_mbuf_stats(dev, &mbuf_stats);
7394 : :
7395 : : /* Get stats from ice_eth_stats struct */
7396 [ # # ]: 0 : for (i = 0; i < ICE_NB_ETH_XSTATS; i++) {
7397 : 0 : xstats[count].value =
7398 : 0 : *(uint64_t *)((char *)&hw_stats->eth +
7399 : 0 : ice_stats_strings[i].offset);
7400 : 0 : xstats[count].id = count;
7401 : 0 : count++;
7402 : : }
7403 : :
7404 : : /* Get stats from ice_mbuf_stats struct */
7405 [ # # ]: 0 : for (i = 0; i < ICE_NB_MBUF_XSTATS; i++) {
7406 : 0 : xstats[count].value =
7407 : : *(uint64_t *)((char *)&mbuf_stats + ice_mbuf_strings[i].offset);
7408 : 0 : xstats[count].id = count;
7409 : 0 : count++;
7410 : : }
7411 : :
7412 : : /* Get individual stats from ice_hw_port struct */
7413 [ # # ]: 0 : for (i = 0; i < ICE_NB_HW_PORT_XSTATS; i++) {
7414 : 0 : xstats[count].value =
7415 : 0 : *(uint64_t *)((char *)hw_stats +
7416 : 0 : ice_hw_port_strings[i].offset);
7417 : 0 : xstats[count].id = count;
7418 : 0 : count++;
7419 : : }
7420 : :
7421 : : /* Get chip temperature from ice_temp_stats struct */
7422 [ # # ]: 0 : if (ice_temp_sensor_supported(hw)) {
7423 : 0 : ice_update_temp_stats(pf, hw);
7424 [ # # ]: 0 : for (i = 0; i < ICE_NB_TEMP_XSTATS; i++) {
7425 : 0 : xstats[count].value =
7426 : 0 : *(uint64_t *)((char *)&pf->temp_stats +
7427 : 0 : ice_temp_strings[i].offset);
7428 : 0 : xstats[count].id = count;
7429 : 0 : count++;
7430 : : }
7431 : : }
7432 : :
7433 : 0 : return count;
7434 : : }
7435 : :
7436 : 0 : static int ice_xstats_get_names(struct rte_eth_dev *dev,
7437 : : struct rte_eth_xstat_name *xstats_names,
7438 : : __rte_unused unsigned int limit)
7439 : : {
7440 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7441 : : unsigned int count = 0;
7442 : : unsigned int i;
7443 : :
7444 [ # # ]: 0 : if (!xstats_names)
7445 : 0 : return ice_xstats_calc_num(dev);
7446 : :
7447 : : /* Note: limit checked in rte_eth_xstats_names() */
7448 : :
7449 : : /* Get stats from ice_eth_stats struct */
7450 [ # # ]: 0 : for (i = 0; i < ICE_NB_ETH_XSTATS; i++) {
7451 : 0 : strlcpy(xstats_names[count].name, ice_stats_strings[i].name,
7452 : : sizeof(xstats_names[count].name));
7453 : 0 : count++;
7454 : : }
7455 : :
7456 : : /* Get stats from ice_mbuf_stats struct */
7457 [ # # ]: 0 : for (i = 0; i < ICE_NB_MBUF_XSTATS; i++) {
7458 : 0 : strlcpy(xstats_names[count].name, ice_mbuf_strings[i].name,
7459 : : sizeof(xstats_names[count].name));
7460 : 0 : count++;
7461 : : }
7462 : :
7463 : : /* Get individual stats from ice_hw_port struct */
7464 [ # # ]: 0 : for (i = 0; i < ICE_NB_HW_PORT_XSTATS; i++) {
7465 : 0 : strlcpy(xstats_names[count].name, ice_hw_port_strings[i].name,
7466 : : sizeof(xstats_names[count].name));
7467 : 0 : count++;
7468 : : }
7469 : :
7470 : : /* Get chip temperature from ice_temp_stats struct */
7471 [ # # ]: 0 : if (ice_temp_sensor_supported(hw)) {
7472 [ # # ]: 0 : for (i = 0; i < ICE_NB_TEMP_XSTATS; i++) {
7473 : 0 : strlcpy(xstats_names[count].name,
7474 : : ice_temp_strings[i].name,
7475 : : sizeof(xstats_names[count].name));
7476 : 0 : count++;
7477 : : }
7478 : : }
7479 : :
7480 : 0 : return count;
7481 : : }
7482 : :
7483 : : static int
7484 : 0 : ice_dev_flow_ops_get(struct rte_eth_dev *dev,
7485 : : const struct rte_flow_ops **ops)
7486 : : {
7487 [ # # ]: 0 : if (!dev)
7488 : : return -EINVAL;
7489 : :
7490 : 0 : *ops = &ice_flow_ops;
7491 : 0 : return 0;
7492 : : }
7493 : :
7494 : : /* Add UDP tunneling port */
7495 : : static int
7496 : 0 : ice_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7497 : : struct rte_eth_udp_tunnel *udp_tunnel)
7498 : : {
7499 : : int ret = 0;
7500 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7501 : : struct ice_adapter *ad =
7502 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7503 : :
7504 [ # # ]: 0 : if (udp_tunnel == NULL)
7505 : : return -EINVAL;
7506 : :
7507 [ # # ]: 0 : switch (udp_tunnel->prot_type) {
7508 : 0 : case RTE_ETH_TUNNEL_TYPE_VXLAN:
7509 : 0 : ret = ice_create_tunnel(hw, TNL_VXLAN, udp_tunnel->udp_port);
7510 [ # # # # ]: 0 : if (!ret && ad->psr != NULL)
7511 : 0 : ice_parser_vxlan_tunnel_set(ad->psr,
7512 : 0 : udp_tunnel->udp_port, true);
7513 : : break;
7514 : 0 : default:
7515 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
7516 : : ret = -EINVAL;
7517 : 0 : break;
7518 : : }
7519 : :
7520 : : return ret;
7521 : : }
7522 : :
7523 : : /* Delete UDP tunneling port */
7524 : : static int
7525 : 0 : ice_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7526 : : struct rte_eth_udp_tunnel *udp_tunnel)
7527 : : {
7528 : : int ret = 0;
7529 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7530 : : struct ice_adapter *ad =
7531 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7532 : :
7533 [ # # ]: 0 : if (udp_tunnel == NULL)
7534 : : return -EINVAL;
7535 : :
7536 [ # # ]: 0 : switch (udp_tunnel->prot_type) {
7537 : 0 : case RTE_ETH_TUNNEL_TYPE_VXLAN:
7538 : 0 : ret = ice_destroy_tunnel(hw, udp_tunnel->udp_port, 0);
7539 [ # # # # ]: 0 : if (!ret && ad->psr != NULL)
7540 : 0 : ice_parser_vxlan_tunnel_set(ad->psr,
7541 : 0 : udp_tunnel->udp_port, false);
7542 : : break;
7543 : 0 : default:
7544 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
7545 : : ret = -EINVAL;
7546 : 0 : break;
7547 : : }
7548 : :
7549 : : return ret;
7550 : : }
7551 : :
7552 : : /**
7553 : : * ice_ptp_write_init - Set PHC time to provided value
7554 : : * @hw: Hardware private structure
7555 : : *
7556 : : * Set the PHC time to CLOCK_REALTIME
7557 : : */
7558 : 0 : static int ice_ptp_write_init(struct ice_hw *hw)
7559 : : {
7560 : : uint64_t ns;
7561 : : struct timespec sys_time;
7562 : 0 : clock_gettime(CLOCK_REALTIME, &sys_time);
7563 : : ns = rte_timespec_to_ns(&sys_time);
7564 : :
7565 : 0 : return ice_ptp_init_time(hw, ns, true);
7566 : : }
7567 : :
7568 : : static int
7569 : 0 : ice_timesync_enable(struct rte_eth_dev *dev)
7570 : : {
7571 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7572 : : struct ice_adapter *ad =
7573 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7574 : : int ret;
7575 : :
7576 [ # # ]: 0 : if (ad->txpp_ena)
7577 : : return 0;
7578 : :
7579 [ # # # # ]: 0 : if (dev->data->dev_started && !(dev->data->dev_conf.rxmode.offloads &
7580 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
7581 : 0 : PMD_DRV_LOG(ERR, "Rx timestamp offload not configured");
7582 : 0 : return -1;
7583 : : }
7584 : :
7585 [ # # ]: 0 : if (hw->func_caps.ts_func_info.src_tmr_owned) {
7586 : 0 : ret = ice_ptp_init_phc(hw);
7587 [ # # ]: 0 : if (ret) {
7588 : 0 : PMD_DRV_LOG(ERR, "Failed to initialize PHC");
7589 : 0 : return -1;
7590 : : }
7591 : :
7592 : 0 : ret = ice_ptp_write_incval(hw, ICE_PTP_NOMINAL_INCVAL_E810, true);
7593 [ # # ]: 0 : if (ret) {
7594 : 0 : PMD_DRV_LOG(ERR,
7595 : : "Failed to write PHC increment time value");
7596 : 0 : return -1;
7597 : : }
7598 : : }
7599 : :
7600 [ # # ]: 0 : if (!ice_ptp_lock(hw)) {
7601 [ # # ]: 0 : ice_debug(hw, ICE_DBG_PTP, "Failed to acquire PTP semaphore");
7602 : 0 : return ICE_ERR_NOT_READY;
7603 : : }
7604 : :
7605 : 0 : ret = ice_ptp_write_init(hw);
7606 : 0 : ice_ptp_unlock(hw);
7607 [ # # ]: 0 : if (ret)
7608 : 0 : PMD_INIT_LOG(ERR, "Failed to set current system time to PHC timer");
7609 : :
7610 : 0 : ad->ptp_ena = 1;
7611 : :
7612 : 0 : return 0;
7613 : : }
7614 : :
7615 : : static int
7616 : 0 : ice_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
7617 : : struct timespec *timestamp, uint32_t flags)
7618 : : {
7619 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7620 : : struct ice_adapter *ad =
7621 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7622 : : struct ci_rx_queue *rxq;
7623 : : uint32_t ts_high;
7624 : : uint64_t ts_ns;
7625 : :
7626 : 0 : rxq = dev->data->rx_queues[flags];
7627 : :
7628 : 0 : ts_high = rxq->time_high;
7629 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, ts_high);
7630 : 0 : *timestamp = rte_ns_to_timespec(ts_ns);
7631 : :
7632 : 0 : return 0;
7633 : : }
7634 : :
7635 : : static int
7636 : 0 : ice_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
7637 : : struct timespec *timestamp)
7638 : : {
7639 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7640 : : struct ice_adapter *ad =
7641 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7642 : 0 : uint64_t ts_ns, tstamp, tstamp_ready = 0;
7643 : : uint64_t end_time;
7644 : : const uint64_t mask = 0xFFFFFFFF;
7645 : : int ret;
7646 : :
7647 : : /* Set the end time with a delay of 10 microseconds */
7648 : 0 : end_time = rte_get_timer_cycles() + (rte_get_timer_hz() / 100000);
7649 : :
7650 : : do {
7651 : 0 : ret = ice_get_phy_tx_tstamp_ready(hw, ad->ptp_tx_block, &tstamp_ready);
7652 [ # # ]: 0 : if (ret) {
7653 : 0 : PMD_DRV_LOG(ERR, "Failed to get phy ready for timestamp");
7654 : 0 : return -1;
7655 : : }
7656 : :
7657 [ # # # # ]: 0 : if ((tstamp_ready & BIT_ULL(0)) == 0 && rte_get_timer_cycles() > end_time) {
7658 : 0 : PMD_DRV_LOG(ERR, "Timeout to get phy ready for timestamp");
7659 : 0 : return -1;
7660 : : }
7661 [ # # ]: 0 : } while ((tstamp_ready & BIT_ULL(0)) == 0);
7662 : :
7663 : 0 : ret = ice_read_phy_tstamp(hw, ad->ptp_tx_block, ad->ptp_tx_index, &tstamp);
7664 [ # # # # ]: 0 : if (ret || tstamp == 0) {
7665 : 0 : PMD_DRV_LOG(ERR, "Failed to read phy timestamp");
7666 : 0 : return -1;
7667 : : }
7668 : :
7669 : 0 : ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, (tstamp >> 8) & mask);
7670 : 0 : *timestamp = rte_ns_to_timespec(ts_ns);
7671 : :
7672 : 0 : return 0;
7673 : : }
7674 : :
7675 : : static int
7676 : 0 : ice_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
7677 : : {
7678 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7679 : 0 : uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
7680 : : uint32_t lo, lo2, hi;
7681 : : uint64_t time, ns;
7682 : : int ret;
7683 : :
7684 [ # # ]: 0 : if (delta > INT32_MAX || delta < INT32_MIN) {
7685 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
7686 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
7687 : 0 : lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
7688 : :
7689 [ # # ]: 0 : if (lo2 < lo) {
7690 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
7691 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
7692 : : }
7693 : :
7694 : 0 : time = ((uint64_t)hi << 32) | lo;
7695 : 0 : ns = time + delta;
7696 : :
7697 : 0 : wr32(hw, GLTSYN_SHTIME_L(tmr_idx), ICE_LO_DWORD(ns));
7698 : 0 : wr32(hw, GLTSYN_SHTIME_H(tmr_idx), ICE_HI_DWORD(ns));
7699 : 0 : wr32(hw, GLTSYN_SHTIME_0(tmr_idx), 0);
7700 : :
7701 : 0 : ret = ice_ptp_init_time(hw, ns, true);
7702 [ # # ]: 0 : if (ret) {
7703 : 0 : PMD_DRV_LOG(ERR, "PTP init time failed, err %d", ret);
7704 : 0 : return -1;
7705 : : }
7706 : : return 0;
7707 : : }
7708 : :
7709 : 0 : ret = ice_ptp_adj_clock(hw, delta, true);
7710 [ # # ]: 0 : if (ret) {
7711 : 0 : PMD_DRV_LOG(ERR, "PTP adj clock failed, err %d", ret);
7712 : 0 : return -1;
7713 : : }
7714 : :
7715 : : return 0;
7716 : : }
7717 : :
7718 : : static int
7719 : 0 : ice_timesync_adjust_freq(struct rte_eth_dev *dev, int64_t ppm)
7720 : : {
7721 [ # # # # ]: 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7722 : : int64_t incval, diff = 0;
7723 : : bool negative = false;
7724 : : uint64_t div, rem;
7725 : : uint64_t divisor = 1000000ULL << 16;
7726 : : int shift;
7727 : : int ret;
7728 : :
7729 : 0 : incval = ice_get_base_incval(hw, ICE_SRC_TMR_MODE_NANOSECONDS);
7730 : :
7731 [ # # ]: 0 : if (ppm < 0) {
7732 : : negative = true;
7733 : 0 : ppm = -ppm;
7734 : : }
7735 : :
7736 : : /* can incval * ppm overflow ? */
7737 [ # # ]: 0 : if (log2(incval) + log2(ppm) > 62) {
7738 : 0 : rem = ppm % divisor;
7739 : 0 : div = ppm / divisor;
7740 : 0 : diff = div * incval;
7741 : 0 : ppm = rem;
7742 : :
7743 : 0 : shift = log2(incval) + log2(ppm) - 62;
7744 [ # # ]: 0 : if (shift > 0) {
7745 : : /* drop precision */
7746 : 0 : ppm >>= shift;
7747 : 0 : divisor >>= shift;
7748 : : }
7749 : : }
7750 : :
7751 [ # # ]: 0 : if (divisor)
7752 : 0 : diff = diff + incval * ppm / divisor;
7753 : :
7754 [ # # ]: 0 : if (negative)
7755 : 0 : incval -= diff;
7756 : : else
7757 : 0 : incval += diff;
7758 : :
7759 : 0 : ret = ice_ptp_write_incval_locked(hw, incval, true);
7760 [ # # ]: 0 : if (ret) {
7761 : 0 : PMD_DRV_LOG(ERR, "PTP failed to set incval, err %d", ret);
7762 : 0 : return -1;
7763 : : }
7764 : : return 0;
7765 : : }
7766 : :
7767 : : static int
7768 : 0 : ice_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
7769 : : {
7770 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7771 : : uint64_t ns;
7772 : : int ret;
7773 : :
7774 : : ns = rte_timespec_to_ns(ts);
7775 : 0 : ret = ice_ptp_init_time(hw, ns, true);
7776 [ # # ]: 0 : if (ret) {
7777 : 0 : PMD_DRV_LOG(ERR, "PTP init time failed, err %d", ret);
7778 : 0 : return -1;
7779 : : }
7780 : :
7781 : : return 0;
7782 : : }
7783 : :
7784 : : static int
7785 : 0 : ice_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
7786 : : {
7787 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7788 : 0 : uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
7789 : : uint32_t hi, lo, lo2;
7790 : : uint64_t time;
7791 : :
7792 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
7793 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
7794 : 0 : lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
7795 : :
7796 [ # # ]: 0 : if (lo2 < lo) {
7797 : 0 : lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
7798 : 0 : hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
7799 : : }
7800 : :
7801 [ # # ]: 0 : time = ((uint64_t)hi << 32) | lo;
7802 : 0 : *ts = rte_ns_to_timespec(time);
7803 : :
7804 : 0 : return 0;
7805 : : }
7806 : :
7807 : : static int
7808 : 0 : ice_timesync_disable(struct rte_eth_dev *dev)
7809 : : {
7810 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7811 : : struct ice_adapter *ad =
7812 : : ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
7813 : 0 : uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
7814 : : uint64_t val;
7815 : : uint8_t lport;
7816 : :
7817 [ # # ]: 0 : if (ad->txpp_ena)
7818 : : return 0;
7819 : :
7820 : 0 : lport = hw->port_info->lport;
7821 : :
7822 : 0 : ice_clear_phy_tstamp(hw, lport, 0);
7823 : :
7824 : 0 : val = ICE_READ_REG(hw, GLTSYN_ENA(tmr_idx));
7825 : 0 : val &= ~GLTSYN_ENA_TSYN_ENA_M;
7826 : 0 : ICE_WRITE_REG(hw, GLTSYN_ENA(tmr_idx), val);
7827 : :
7828 : 0 : ICE_WRITE_REG(hw, GLTSYN_INCVAL_L(tmr_idx), 0);
7829 : 0 : ICE_WRITE_REG(hw, GLTSYN_INCVAL_H(tmr_idx), 0);
7830 : :
7831 : 0 : ad->ptp_ena = 0;
7832 : :
7833 : 0 : return 0;
7834 : : }
7835 : :
7836 : : static int
7837 : 0 : ice_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
7838 : : {
7839 : : struct timespec ts;
7840 : : int ret;
7841 : :
7842 : 0 : ret = ice_timesync_read_time(dev, &ts);
7843 [ # # ]: 0 : if (ret)
7844 : : return ret;
7845 : :
7846 : 0 : *clock = (uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
7847 : :
7848 : 0 : return 0;
7849 : : }
7850 : :
7851 : : static const uint32_t *
7852 : 0 : ice_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
7853 : : size_t *no_of_elements)
7854 : : {
7855 : : /* Buffer split protocol header capability. */
7856 : : static const uint32_t ptypes[] = {
7857 : : /* Non tunneled */
7858 : : RTE_PTYPE_L2_ETHER,
7859 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
7860 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP,
7861 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP,
7862 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP,
7863 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
7864 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP,
7865 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP,
7866 : : RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP,
7867 : :
7868 : : /* Tunneled */
7869 : : RTE_PTYPE_TUNNEL_GRENAT,
7870 : :
7871 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
7872 : :
7873 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7874 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
7875 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7876 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
7877 : :
7878 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7879 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP,
7880 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7881 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP,
7882 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7883 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP,
7884 : :
7885 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7886 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP,
7887 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7888 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP,
7889 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
7890 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP,
7891 : :
7892 : : };
7893 : :
7894 : 0 : *no_of_elements = RTE_DIM(ptypes);
7895 : 0 : return ptypes;
7896 : : }
7897 : :
7898 : : static unsigned int
7899 : 0 : ice_fec_get_capa_num(struct ice_aqc_get_phy_caps_data *pcaps,
7900 : : struct rte_eth_fec_capa *speed_fec_capa)
7901 : : {
7902 : : unsigned int num = 0;
7903 : 0 : int auto_fec = (pcaps->caps & ICE_AQC_PHY_EN_AUTO_FEC) ?
7904 : 0 : RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) : 0;
7905 : 0 : int link_nofec = (pcaps->link_fec_options & ICE_AQC_PHY_FEC_DIS) ?
7906 : 0 : RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC) : 0;
7907 : :
7908 [ # # ]: 0 : if (pcaps->eee_cap & ICE_AQC_PHY_EEE_EN_100BASE_TX) {
7909 [ # # ]: 0 : if (speed_fec_capa) {
7910 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_100M;
7911 : 0 : speed_fec_capa[num].capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
7912 : : }
7913 : : num++;
7914 : : }
7915 : :
7916 [ # # ]: 0 : if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_1000BASE_T |
7917 : : ICE_AQC_PHY_EEE_EN_1000BASE_KX)) {
7918 [ # # ]: 0 : if (speed_fec_capa) {
7919 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_1G;
7920 : 0 : speed_fec_capa[num].capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
7921 : : }
7922 : 0 : num++;
7923 : : }
7924 : :
7925 [ # # ]: 0 : if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_10GBASE_T |
7926 : : ICE_AQC_PHY_EEE_EN_10GBASE_KR)) {
7927 [ # # ]: 0 : if (speed_fec_capa) {
7928 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_10G;
7929 : 0 : speed_fec_capa[num].capa = auto_fec | link_nofec;
7930 : :
7931 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN)
7932 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
7933 : : }
7934 : 0 : num++;
7935 : : }
7936 : :
7937 [ # # ]: 0 : if (pcaps->eee_cap & ICE_AQC_PHY_EEE_EN_25GBASE_KR) {
7938 [ # # ]: 0 : if (speed_fec_capa) {
7939 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_25G;
7940 : 0 : speed_fec_capa[num].capa = auto_fec | link_nofec;
7941 : :
7942 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN)
7943 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
7944 : :
7945 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
7946 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(RS);
7947 : : }
7948 : 0 : num++;
7949 : : }
7950 : :
7951 [ # # ]: 0 : if (pcaps->eee_cap & ICE_AQC_PHY_EEE_EN_40GBASE_KR4) {
7952 [ # # ]: 0 : if (speed_fec_capa) {
7953 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_40G;
7954 : 0 : speed_fec_capa[num].capa = auto_fec | link_nofec;
7955 : :
7956 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN)
7957 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
7958 : : }
7959 : 0 : num++;
7960 : : }
7961 : :
7962 [ # # ]: 0 : if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_50GBASE_KR2 |
7963 : : ICE_AQC_PHY_EEE_EN_50GBASE_KR_PAM4)) {
7964 [ # # ]: 0 : if (speed_fec_capa) {
7965 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_50G;
7966 : 0 : speed_fec_capa[num].capa = auto_fec | link_nofec;
7967 : :
7968 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN)
7969 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
7970 : :
7971 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
7972 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(RS);
7973 : : }
7974 : 0 : num++;
7975 : : }
7976 : :
7977 [ # # ]: 0 : if (pcaps->eee_cap & (ICE_AQC_PHY_EEE_EN_100GBASE_KR4 |
7978 : : ICE_AQC_PHY_EEE_EN_100GBASE_KR2_PAM4)) {
7979 [ # # ]: 0 : if (speed_fec_capa) {
7980 : 0 : speed_fec_capa[num].speed = RTE_ETH_SPEED_NUM_100G;
7981 : 0 : speed_fec_capa[num].capa = auto_fec | link_nofec;
7982 : :
7983 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN)
7984 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
7985 : :
7986 [ # # ]: 0 : if (pcaps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
7987 : 0 : speed_fec_capa[num].capa |= RTE_ETH_FEC_MODE_CAPA_MASK(RS);
7988 : : }
7989 : 0 : num++;
7990 : : }
7991 : :
7992 : 0 : return num;
7993 : : }
7994 : :
7995 : : static int
7996 : 0 : ice_fec_get_capability(struct rte_eth_dev *dev, struct rte_eth_fec_capa *speed_fec_capa,
7997 : : unsigned int num)
7998 : : {
7999 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8000 : 0 : struct ice_aqc_get_phy_caps_data pcaps = {0};
8001 : : unsigned int capa_num;
8002 : : int ret;
8003 : :
8004 : 0 : ret = ice_aq_get_phy_caps(hw->port_info, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
8005 : : &pcaps, NULL);
8006 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
8007 : 0 : PMD_DRV_LOG(ERR, "Failed to get capability information: %d",
8008 : : ret);
8009 : 0 : return -ENOTSUP;
8010 : : }
8011 : :
8012 : : /* first time to get capa_num */
8013 : 0 : capa_num = ice_fec_get_capa_num(&pcaps, NULL);
8014 [ # # ]: 0 : if (!speed_fec_capa || num < capa_num)
8015 : 0 : return capa_num;
8016 : :
8017 : 0 : return ice_fec_get_capa_num(&pcaps, speed_fec_capa);
8018 : : }
8019 : :
8020 : : static int
8021 : 0 : ice_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa)
8022 : : {
8023 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8024 : 0 : struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
8025 : 0 : bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
8026 : : bool link_up;
8027 : : u32 temp_fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
8028 : 0 : struct ice_link_status link_status = {0};
8029 : 0 : struct ice_aqc_get_phy_caps_data pcaps = {0};
8030 : 0 : struct ice_port_info *pi = hw->port_info;
8031 : : u8 fec_config;
8032 : : int ret;
8033 : :
8034 [ # # ]: 0 : if (!pi)
8035 : : return -ENOTSUP;
8036 : :
8037 : 0 : ret = ice_get_link_info_safe(pf, enable_lse, &link_status);
8038 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
8039 : 0 : PMD_DRV_LOG(ERR, "Failed to get link information: %d",
8040 : : ret);
8041 : 0 : return -ENOTSUP;
8042 : : }
8043 : :
8044 : 0 : link_up = link_status.link_info & ICE_AQ_LINK_UP;
8045 : :
8046 : 0 : ret = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
8047 : : &pcaps, NULL);
8048 [ # # ]: 0 : if (ret != ICE_SUCCESS) {
8049 : 0 : PMD_DRV_LOG(ERR, "Failed to get capability information: %d",
8050 : : ret);
8051 : 0 : return -ENOTSUP;
8052 : : }
8053 : :
8054 : : /* Get current FEC mode from port info */
8055 [ # # ]: 0 : if (link_up) {
8056 [ # # # ]: 0 : switch (link_status.fec_info) {
8057 : 0 : case ICE_AQ_LINK_25G_KR_FEC_EN:
8058 : 0 : *fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
8059 : 0 : break;
8060 : 0 : case ICE_AQ_LINK_25G_RS_528_FEC_EN:
8061 : : /* fall-through */
8062 : : case ICE_AQ_LINK_25G_RS_544_FEC_EN:
8063 : 0 : *fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(RS);
8064 : 0 : break;
8065 : 0 : default:
8066 : 0 : *fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
8067 : 0 : break;
8068 : : }
8069 : 0 : return 0;
8070 : : }
8071 : :
8072 [ # # ]: 0 : if (pcaps.caps & ICE_AQC_PHY_EN_AUTO_FEC) {
8073 : 0 : *fec_capa = RTE_ETH_FEC_MODE_CAPA_MASK(AUTO);
8074 : 0 : return 0;
8075 : : }
8076 : :
8077 : 0 : fec_config = pcaps.link_fec_options & ICE_AQC_PHY_FEC_MASK;
8078 : :
8079 [ # # ]: 0 : if (fec_config & (ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN |
8080 : : ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN |
8081 : : ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ |
8082 : : ICE_AQC_PHY_FEC_25G_KR_REQ))
8083 : : temp_fec_capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
8084 : :
8085 [ # # ]: 0 : if (fec_config & (ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN |
8086 : : ICE_AQC_PHY_FEC_25G_RS_528_REQ |
8087 : : ICE_AQC_PHY_FEC_25G_RS_544_REQ))
8088 : 0 : temp_fec_capa |= RTE_ETH_FEC_MODE_CAPA_MASK(RS);
8089 : :
8090 : 0 : *fec_capa = temp_fec_capa;
8091 : 0 : return 0;
8092 : : }
8093 : :
8094 : : static int
8095 : 0 : ice_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa)
8096 : : {
8097 : 0 : struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8098 : 0 : struct ice_port_info *pi = hw->port_info;
8099 : : struct ice_aqc_set_phy_cfg_data cfg = { 0 };
8100 : : bool fec_auto = false, fec_kr = false, fec_rs = false;
8101 : :
8102 [ # # ]: 0 : if (!pi)
8103 : : return -ENOTSUP;
8104 : :
8105 [ # # ]: 0 : if (fec_capa & ~(RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) |
8106 : : RTE_ETH_FEC_MODE_CAPA_MASK(BASER) |
8107 : : RTE_ETH_FEC_MODE_CAPA_MASK(RS)))
8108 : : return -EINVAL;
8109 : : /* Copy the current user PHY configuration. The current user PHY
8110 : : * configuration is initialized during probe from PHY capabilities
8111 : : * software mode, and updated on set PHY configuration.
8112 : : */
8113 [ # # ]: 0 : memcpy(&cfg, &pi->phy.curr_user_phy_cfg, sizeof(cfg));
8114 : :
8115 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(AUTO))
8116 : : fec_auto = true;
8117 : :
8118 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(BASER))
8119 : : fec_kr = true;
8120 : :
8121 [ # # ]: 0 : if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(RS))
8122 : : fec_rs = true;
8123 : :
8124 [ # # ]: 0 : if (fec_auto) {
8125 [ # # ]: 0 : if (fec_kr || fec_rs) {
8126 [ # # ]: 0 : if (fec_rs) {
8127 : 0 : cfg.link_fec_opt = ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN |
8128 : : ICE_AQC_PHY_FEC_25G_RS_528_REQ |
8129 : : ICE_AQC_PHY_FEC_25G_RS_544_REQ;
8130 : : }
8131 [ # # ]: 0 : if (fec_kr) {
8132 : 0 : cfg.link_fec_opt |= ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN |
8133 : : ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN |
8134 : : ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ |
8135 : : ICE_AQC_PHY_FEC_25G_KR_REQ;
8136 : : }
8137 : : } else {
8138 : 0 : cfg.link_fec_opt = ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN |
8139 : : ICE_AQC_PHY_FEC_25G_RS_528_REQ |
8140 : : ICE_AQC_PHY_FEC_25G_RS_544_REQ |
8141 : : ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN |
8142 : : ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN |
8143 : : ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ |
8144 : : ICE_AQC_PHY_FEC_25G_KR_REQ;
8145 : : }
8146 : : } else {
8147 [ # # ]: 0 : if (fec_kr ^ fec_rs) {
8148 [ # # ]: 0 : if (fec_rs) {
8149 : 0 : cfg.link_fec_opt = ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN |
8150 : : ICE_AQC_PHY_FEC_25G_RS_528_REQ |
8151 : : ICE_AQC_PHY_FEC_25G_RS_544_REQ;
8152 : : } else {
8153 : 0 : cfg.link_fec_opt = ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN |
8154 : : ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN |
8155 : : ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ |
8156 : : ICE_AQC_PHY_FEC_25G_KR_REQ;
8157 : : }
8158 : : } else {
8159 : : return -EINVAL;
8160 : : }
8161 : : }
8162 : :
8163 : : /* Recovery of accidentally rewritten bit */
8164 [ # # ]: 0 : if (pi->phy.curr_user_phy_cfg.link_fec_opt &
8165 : : ICE_AQC_PHY_FEC_DIS)
8166 : 0 : cfg.link_fec_opt |= ICE_AQC_PHY_FEC_DIS;
8167 : :
8168 : : /* Proceed only if requesting different FEC mode */
8169 [ # # ]: 0 : if (pi->phy.curr_user_phy_cfg.link_fec_opt == cfg.link_fec_opt)
8170 : : return 0;
8171 : :
8172 : 0 : cfg.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
8173 : :
8174 [ # # ]: 0 : if (ice_aq_set_phy_cfg(pi->hw, pi, &cfg, NULL))
8175 : 0 : return -EAGAIN;
8176 : :
8177 : : return 0;
8178 : : }
8179 : :
8180 : : static int
8181 : 0 : ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
8182 : : struct rte_pci_device *pci_dev)
8183 : : {
8184 : 0 : return rte_eth_dev_pci_generic_probe(pci_dev,
8185 : : sizeof(struct ice_adapter),
8186 : : ice_dev_init);
8187 : : }
8188 : :
8189 : : static int
8190 : 0 : ice_pci_remove(struct rte_pci_device *pci_dev)
8191 : : {
8192 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev, ice_dev_uninit);
8193 : : }
8194 : :
8195 : : static struct rte_pci_driver rte_ice_pmd = {
8196 : : .id_table = pci_id_ice_map,
8197 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
8198 : : .probe = ice_pci_probe,
8199 : : .remove = ice_pci_remove,
8200 : : };
8201 : :
8202 : : /**
8203 : : * Driver initialization routine.
8204 : : * Invoked once at EAL init time.
8205 : : * Register itself as the [Poll Mode] Driver of PCI devices.
8206 : : */
8207 : 306 : RTE_PMD_REGISTER_PCI(net_ice, rte_ice_pmd);
8208 : : RTE_PMD_REGISTER_PCI_TABLE(net_ice, pci_id_ice_map);
8209 : : RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_generic | vfio-pci");
8210 : : RTE_PMD_REGISTER_PARAM_STRING(net_ice,
8211 : : ICE_HW_DEBUG_MASK_ARG "=0xXXX"
8212 : : ICE_PROTO_XTR_ARG "=[queue:]<vlan|ipv4|ipv6|ipv6_flow|tcp|ip_offset>"
8213 : : ICE_SAFE_MODE_SUPPORT_ARG "=<0|1>"
8214 : : ICE_DEFAULT_MAC_DISABLE "=<0|1>"
8215 : : ICE_DDP_FILENAME_ARG "=</path/to/file>"
8216 : : ICE_DDP_LOAD_SCHED_ARG "=<0|1>"
8217 : : ICE_TM_LEVELS_ARG "=<N>"
8218 : : ICE_RL_BURST_SIZE_ARG "=<N>"
8219 : : ICE_SOURCE_PRUNE_ARG "=<0|1>"
8220 : : ICE_RX_LOW_LATENCY_ARG "=<0|1>"
8221 : : ICE_LINK_STATE_ON_CLOSE "=<down|up|initial>");
8222 : :
8223 [ - + ]: 306 : RTE_LOG_REGISTER_SUFFIX(ice_logtype_init, init, NOTICE);
8224 [ - + ]: 306 : RTE_LOG_REGISTER_SUFFIX(ice_logtype_driver, driver, NOTICE);
8225 : : #ifdef RTE_ETHDEV_DEBUG_RX
8226 : : RTE_LOG_REGISTER_SUFFIX(ice_logtype_rx, rx, DEBUG);
8227 : : #endif
8228 : : #ifdef RTE_ETHDEV_DEBUG_TX
8229 : : RTE_LOG_REGISTER_SUFFIX(ice_logtype_tx, tx, DEBUG);
8230 : : #endif
8231 : :
8232 : 0 : bool is_ice_supported(struct rte_eth_dev *dev)
8233 : : {
8234 : 0 : return !strcmp(dev->device->driver->name, rte_ice_pmd.driver.name);
8235 : : }
|