1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2 /* Copyright 2014-2016 Freescale Semiconductor Inc.
3  * Copyright 2016 NXP
4  */
5 
6 #include <linux/net_tstamp.h>
7 
8 #include "dpni.h"	/* DPNI_LINK_OPT_* */
9 #include "dpaa2-eth.h"
10 
11 /* To be kept in sync with DPNI statistics */
12 static char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
13 	"[hw] rx frames",
14 	"[hw] rx bytes",
15 	"[hw] rx mcast frames",
16 	"[hw] rx mcast bytes",
17 	"[hw] rx bcast frames",
18 	"[hw] rx bcast bytes",
19 	"[hw] tx frames",
20 	"[hw] tx bytes",
21 	"[hw] tx mcast frames",
22 	"[hw] tx mcast bytes",
23 	"[hw] tx bcast frames",
24 	"[hw] tx bcast bytes",
25 	"[hw] rx filtered frames",
26 	"[hw] rx discarded frames",
27 	"[hw] rx nobuffer discards",
28 	"[hw] tx discarded frames",
29 	"[hw] tx confirmed frames",
30 };
31 
32 #define DPAA2_ETH_NUM_STATS	ARRAY_SIZE(dpaa2_ethtool_stats)
33 
34 static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
35 	/* per-cpu stats */
36 	"[drv] tx conf frames",
37 	"[drv] tx conf bytes",
38 	"[drv] tx sg frames",
39 	"[drv] tx sg bytes",
40 	"[drv] tx realloc frames",
41 	"[drv] rx sg frames",
42 	"[drv] rx sg bytes",
43 	"[drv] enqueue portal busy",
44 	/* Channel stats */
45 	"[drv] dequeue portal busy",
46 	"[drv] channel pull errors",
47 	"[drv] cdan",
48 	"[drv] xdp drop",
49 	"[drv] xdp tx",
50 	"[drv] xdp tx errors",
51 };
52 
53 #define DPAA2_ETH_NUM_EXTRA_STATS	ARRAY_SIZE(dpaa2_ethtool_extras)
54 
55 static void dpaa2_eth_get_drvinfo(struct net_device *net_dev,
56 				  struct ethtool_drvinfo *drvinfo)
57 {
58 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
59 
60 	strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
61 
62 	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
63 		 "%u.%u", priv->dpni_ver_major, priv->dpni_ver_minor);
64 
65 	strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent),
66 		sizeof(drvinfo->bus_info));
67 }
68 
69 static int
70 dpaa2_eth_get_link_ksettings(struct net_device *net_dev,
71 			     struct ethtool_link_ksettings *link_settings)
72 {
73 	struct dpni_link_state state = {0};
74 	int err = 0;
75 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
76 
77 	err = dpni_get_link_state(priv->mc_io, 0, priv->mc_token, &state);
78 	if (err) {
79 		netdev_err(net_dev, "ERROR %d getting link state\n", err);
80 		goto out;
81 	}
82 
83 	/* At the moment, we have no way of interrogating the DPMAC
84 	 * from the DPNI side - and for that matter there may exist
85 	 * no DPMAC at all. So for now we just don't report anything
86 	 * beyond the DPNI attributes.
87 	 */
88 	if (state.options & DPNI_LINK_OPT_AUTONEG)
89 		link_settings->base.autoneg = AUTONEG_ENABLE;
90 	if (!(state.options & DPNI_LINK_OPT_HALF_DUPLEX))
91 		link_settings->base.duplex = DUPLEX_FULL;
92 	link_settings->base.speed = state.rate;
93 
94 out:
95 	return err;
96 }
97 
98 #define DPNI_DYNAMIC_LINK_SET_VER_MAJOR		7
99 #define DPNI_DYNAMIC_LINK_SET_VER_MINOR		1
100 static int
101 dpaa2_eth_set_link_ksettings(struct net_device *net_dev,
102 			     const struct ethtool_link_ksettings *link_settings)
103 {
104 	struct dpni_link_cfg cfg = {0};
105 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
106 	int err = 0;
107 
108 	/* If using an older MC version, the DPNI must be down
109 	 * in order to be able to change link settings. Taking steps to let
110 	 * the user know that.
111 	 */
112 	if (dpaa2_eth_cmp_dpni_ver(priv, DPNI_DYNAMIC_LINK_SET_VER_MAJOR,
113 				   DPNI_DYNAMIC_LINK_SET_VER_MINOR) < 0) {
114 		if (netif_running(net_dev)) {
115 			netdev_info(net_dev, "Interface must be brought down first.\n");
116 			return -EACCES;
117 		}
118 	}
119 
120 	cfg.rate = link_settings->base.speed;
121 	if (link_settings->base.autoneg == AUTONEG_ENABLE)
122 		cfg.options |= DPNI_LINK_OPT_AUTONEG;
123 	else
124 		cfg.options &= ~DPNI_LINK_OPT_AUTONEG;
125 	if (link_settings->base.duplex  == DUPLEX_HALF)
126 		cfg.options |= DPNI_LINK_OPT_HALF_DUPLEX;
127 	else
128 		cfg.options &= ~DPNI_LINK_OPT_HALF_DUPLEX;
129 
130 	err = dpni_set_link_cfg(priv->mc_io, 0, priv->mc_token, &cfg);
131 	if (err)
132 		/* ethtool will be loud enough if we return an error; no point
133 		 * in putting our own error message on the console by default
134 		 */
135 		netdev_dbg(net_dev, "ERROR %d setting link cfg\n", err);
136 
137 	return err;
138 }
139 
140 static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
141 				  u8 *data)
142 {
143 	u8 *p = data;
144 	int i;
145 
146 	switch (stringset) {
147 	case ETH_SS_STATS:
148 		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
149 			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
150 			p += ETH_GSTRING_LEN;
151 		}
152 		for (i = 0; i < DPAA2_ETH_NUM_EXTRA_STATS; i++) {
153 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
154 			p += ETH_GSTRING_LEN;
155 		}
156 		break;
157 	}
158 }
159 
160 static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset)
161 {
162 	switch (sset) {
163 	case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */
164 		return DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS;
165 	default:
166 		return -EOPNOTSUPP;
167 	}
168 }
169 
170 /** Fill in hardware counters, as returned by MC.
171  */
172 static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev,
173 					struct ethtool_stats *stats,
174 					u64 *data)
175 {
176 	int i = 0;
177 	int j, k, err;
178 	int num_cnt;
179 	union dpni_statistics dpni_stats;
180 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
181 	struct dpaa2_eth_drv_stats *extras;
182 	struct dpaa2_eth_ch_stats *ch_stats;
183 
184 	memset(data, 0,
185 	       sizeof(u64) * (DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS));
186 
187 	/* Print standard counters, from DPNI statistics */
188 	for (j = 0; j <= 2; j++) {
189 		err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token,
190 					  j, &dpni_stats);
191 		if (err != 0)
192 			netdev_warn(net_dev, "dpni_get_stats(%d) failed\n", j);
193 		switch (j) {
194 		case 0:
195 			num_cnt = sizeof(dpni_stats.page_0) / sizeof(u64);
196 			break;
197 		case 1:
198 			num_cnt = sizeof(dpni_stats.page_1) / sizeof(u64);
199 			break;
200 		case 2:
201 			num_cnt = sizeof(dpni_stats.page_2) / sizeof(u64);
202 			break;
203 		}
204 		for (k = 0; k < num_cnt; k++)
205 			*(data + i++) = dpni_stats.raw.counter[k];
206 	}
207 
208 	/* Print per-cpu extra stats */
209 	for_each_online_cpu(k) {
210 		extras = per_cpu_ptr(priv->percpu_extras, k);
211 		for (j = 0; j < sizeof(*extras) / sizeof(__u64); j++)
212 			*((__u64 *)data + i + j) += *((__u64 *)extras + j);
213 	}
214 	i += j;
215 
216 	/* Per-channel stats */
217 	for (k = 0; k < priv->num_channels; k++) {
218 		ch_stats = &priv->channel[k]->stats;
219 		for (j = 0; j < sizeof(*ch_stats) / sizeof(__u64); j++)
220 			*((__u64 *)data + i + j) += *((__u64 *)ch_stats + j);
221 	}
222 }
223 
224 static int prep_eth_rule(struct ethhdr *eth_value, struct ethhdr *eth_mask,
225 			 void *key, void *mask)
226 {
227 	int off;
228 
229 	if (eth_mask->h_proto) {
230 		off = dpaa2_eth_cls_fld_off(NET_PROT_ETH, NH_FLD_ETH_TYPE);
231 		*(__be16 *)(key + off) = eth_value->h_proto;
232 		*(__be16 *)(mask + off) = eth_mask->h_proto;
233 	}
234 
235 	if (!is_zero_ether_addr(eth_mask->h_source)) {
236 		off = dpaa2_eth_cls_fld_off(NET_PROT_ETH, NH_FLD_ETH_SA);
237 		ether_addr_copy(key + off, eth_value->h_source);
238 		ether_addr_copy(mask + off, eth_mask->h_source);
239 	}
240 
241 	if (!is_zero_ether_addr(eth_mask->h_dest)) {
242 		off = dpaa2_eth_cls_fld_off(NET_PROT_ETH, NH_FLD_ETH_DA);
243 		ether_addr_copy(key + off, eth_value->h_dest);
244 		ether_addr_copy(mask + off, eth_mask->h_dest);
245 	}
246 
247 	return 0;
248 }
249 
250 static int prep_uip_rule(struct ethtool_usrip4_spec *uip_value,
251 			 struct ethtool_usrip4_spec *uip_mask,
252 			 void *key, void *mask)
253 {
254 	int off;
255 	u32 tmp_value, tmp_mask;
256 
257 	if (uip_mask->tos || uip_mask->ip_ver)
258 		return -EOPNOTSUPP;
259 
260 	if (uip_mask->ip4src) {
261 		off = dpaa2_eth_cls_fld_off(NET_PROT_IP, NH_FLD_IP_SRC);
262 		*(__be32 *)(key + off) = uip_value->ip4src;
263 		*(__be32 *)(mask + off) = uip_mask->ip4src;
264 	}
265 
266 	if (uip_mask->ip4dst) {
267 		off = dpaa2_eth_cls_fld_off(NET_PROT_IP, NH_FLD_IP_DST);
268 		*(__be32 *)(key + off) = uip_value->ip4dst;
269 		*(__be32 *)(mask + off) = uip_mask->ip4dst;
270 	}
271 
272 	if (uip_mask->proto) {
273 		off = dpaa2_eth_cls_fld_off(NET_PROT_IP, NH_FLD_IP_PROTO);
274 		*(u8 *)(key + off) = uip_value->proto;
275 		*(u8 *)(mask + off) = uip_mask->proto;
276 	}
277 
278 	if (uip_mask->l4_4_bytes) {
279 		tmp_value = be32_to_cpu(uip_value->l4_4_bytes);
280 		tmp_mask = be32_to_cpu(uip_mask->l4_4_bytes);
281 
282 		off = dpaa2_eth_cls_fld_off(NET_PROT_UDP, NH_FLD_UDP_PORT_SRC);
283 		*(__be16 *)(key + off) = htons(tmp_value >> 16);
284 		*(__be16 *)(mask + off) = htons(tmp_mask >> 16);
285 
286 		off = dpaa2_eth_cls_fld_off(NET_PROT_UDP, NH_FLD_UDP_PORT_DST);
287 		*(__be16 *)(key + off) = htons(tmp_value & 0xFFFF);
288 		*(__be16 *)(mask + off) = htons(tmp_mask & 0xFFFF);
289 	}
290 
291 	/* Only apply the rule for IPv4 frames */
292 	off = dpaa2_eth_cls_fld_off(NET_PROT_ETH, NH_FLD_ETH_TYPE);
293 	*(__be16 *)(key + off) = htons(ETH_P_IP);
294 	*(__be16 *)(mask + off) = htons(0xFFFF);
295 
296 	return 0;
297 }
298 
299 static int prep_l4_rule(struct ethtool_tcpip4_spec *l4_value,
300 			struct ethtool_tcpip4_spec *l4_mask,
301 			void *key, void *mask, u8 l4_proto)
302 {
303 	int off;
304 
305 	if (l4_mask->tos)
306 		return -EOPNOTSUPP;
307 
308 	if (l4_mask->ip4src) {
309 		off = dpaa2_eth_cls_fld_off(NET_PROT_IP, NH_FLD_IP_SRC);
310 		*(__be32 *)(key + off) = l4_value->ip4src;
311 		*(__be32 *)(mask + off) = l4_mask->ip4src;
312 	}
313 
314 	if (l4_mask->ip4dst) {
315 		off = dpaa2_eth_cls_fld_off(NET_PROT_IP, NH_FLD_IP_DST);
316 		*(__be32 *)(key + off) = l4_value->ip4dst;
317 		*(__be32 *)(mask + off) = l4_mask->ip4dst;
318 	}
319 
320 	if (l4_mask->psrc) {
321 		off = dpaa2_eth_cls_fld_off(NET_PROT_UDP, NH_FLD_UDP_PORT_SRC);
322 		*(__be16 *)(key + off) = l4_value->psrc;
323 		*(__be16 *)(mask + off) = l4_mask->psrc;
324 	}
325 
326 	if (l4_mask->pdst) {
327 		off = dpaa2_eth_cls_fld_off(NET_PROT_UDP, NH_FLD_UDP_PORT_DST);
328 		*(__be16 *)(key + off) = l4_value->pdst;
329 		*(__be16 *)(mask + off) = l4_mask->pdst;
330 	}
331 
332 	/* Only apply the rule for IPv4 frames with the specified L4 proto */
333 	off = dpaa2_eth_cls_fld_off(NET_PROT_ETH, NH_FLD_ETH_TYPE);
334 	*(__be16 *)(key + off) = htons(ETH_P_IP);
335 	*(__be16 *)(mask + off) = htons(0xFFFF);
336 
337 	off = dpaa2_eth_cls_fld_off(NET_PROT_IP, NH_FLD_IP_PROTO);
338 	*(u8 *)(key + off) = l4_proto;
339 	*(u8 *)(mask + off) = 0xFF;
340 
341 	return 0;
342 }
343 
344 static int prep_ext_rule(struct ethtool_flow_ext *ext_value,
345 			 struct ethtool_flow_ext *ext_mask,
346 			 void *key, void *mask)
347 {
348 	int off;
349 
350 	if (ext_mask->vlan_etype)
351 		return -EOPNOTSUPP;
352 
353 	if (ext_mask->vlan_tci) {
354 		off = dpaa2_eth_cls_fld_off(NET_PROT_VLAN, NH_FLD_VLAN_TCI);
355 		*(__be16 *)(key + off) = ext_value->vlan_tci;
356 		*(__be16 *)(mask + off) = ext_mask->vlan_tci;
357 	}
358 
359 	return 0;
360 }
361 
362 static int prep_mac_ext_rule(struct ethtool_flow_ext *ext_value,
363 			     struct ethtool_flow_ext *ext_mask,
364 			     void *key, void *mask)
365 {
366 	int off;
367 
368 	if (!is_zero_ether_addr(ext_mask->h_dest)) {
369 		off = dpaa2_eth_cls_fld_off(NET_PROT_ETH, NH_FLD_ETH_DA);
370 		ether_addr_copy(key + off, ext_value->h_dest);
371 		ether_addr_copy(mask + off, ext_mask->h_dest);
372 	}
373 
374 	return 0;
375 }
376 
377 static int prep_cls_rule(struct ethtool_rx_flow_spec *fs, void *key, void *mask)
378 {
379 	int err;
380 
381 	switch (fs->flow_type & 0xFF) {
382 	case ETHER_FLOW:
383 		err = prep_eth_rule(&fs->h_u.ether_spec, &fs->m_u.ether_spec,
384 				    key, mask);
385 		break;
386 	case IP_USER_FLOW:
387 		err = prep_uip_rule(&fs->h_u.usr_ip4_spec,
388 				    &fs->m_u.usr_ip4_spec, key, mask);
389 		break;
390 	case TCP_V4_FLOW:
391 		err = prep_l4_rule(&fs->h_u.tcp_ip4_spec, &fs->m_u.tcp_ip4_spec,
392 				   key, mask, IPPROTO_TCP);
393 		break;
394 	case UDP_V4_FLOW:
395 		err = prep_l4_rule(&fs->h_u.udp_ip4_spec, &fs->m_u.udp_ip4_spec,
396 				   key, mask, IPPROTO_UDP);
397 		break;
398 	case SCTP_V4_FLOW:
399 		err = prep_l4_rule(&fs->h_u.sctp_ip4_spec,
400 				   &fs->m_u.sctp_ip4_spec, key, mask,
401 				   IPPROTO_SCTP);
402 		break;
403 	default:
404 		return -EOPNOTSUPP;
405 	}
406 
407 	if (err)
408 		return err;
409 
410 	if (fs->flow_type & FLOW_EXT) {
411 		err = prep_ext_rule(&fs->h_ext, &fs->m_ext, key, mask);
412 		if (err)
413 			return err;
414 	}
415 
416 	if (fs->flow_type & FLOW_MAC_EXT) {
417 		err = prep_mac_ext_rule(&fs->h_ext, &fs->m_ext, key, mask);
418 		if (err)
419 			return err;
420 	}
421 
422 	return 0;
423 }
424 
425 static int do_cls_rule(struct net_device *net_dev,
426 		       struct ethtool_rx_flow_spec *fs,
427 		       bool add)
428 {
429 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
430 	struct device *dev = net_dev->dev.parent;
431 	struct dpni_rule_cfg rule_cfg = { 0 };
432 	struct dpni_fs_action_cfg fs_act = { 0 };
433 	dma_addr_t key_iova;
434 	void *key_buf;
435 	int err;
436 
437 	if (fs->ring_cookie != RX_CLS_FLOW_DISC &&
438 	    fs->ring_cookie >= dpaa2_eth_queue_count(priv))
439 		return -EINVAL;
440 
441 	rule_cfg.key_size = dpaa2_eth_cls_key_size();
442 
443 	/* allocate twice the key size, for the actual key and for mask */
444 	key_buf = kzalloc(rule_cfg.key_size * 2, GFP_KERNEL);
445 	if (!key_buf)
446 		return -ENOMEM;
447 
448 	/* Fill the key and mask memory areas */
449 	err = prep_cls_rule(fs, key_buf, key_buf + rule_cfg.key_size);
450 	if (err)
451 		goto free_mem;
452 
453 	key_iova = dma_map_single(dev, key_buf, rule_cfg.key_size * 2,
454 				  DMA_TO_DEVICE);
455 	if (dma_mapping_error(dev, key_iova)) {
456 		err = -ENOMEM;
457 		goto free_mem;
458 	}
459 
460 	rule_cfg.key_iova = key_iova;
461 	rule_cfg.mask_iova = key_iova + rule_cfg.key_size;
462 
463 	if (add) {
464 		if (fs->ring_cookie == RX_CLS_FLOW_DISC)
465 			fs_act.options |= DPNI_FS_OPT_DISCARD;
466 		else
467 			fs_act.flow_id = fs->ring_cookie;
468 		err = dpni_add_fs_entry(priv->mc_io, 0, priv->mc_token, 0,
469 					fs->location, &rule_cfg, &fs_act);
470 	} else {
471 		err = dpni_remove_fs_entry(priv->mc_io, 0, priv->mc_token, 0,
472 					   &rule_cfg);
473 	}
474 
475 	dma_unmap_single(dev, key_iova, rule_cfg.key_size * 2, DMA_TO_DEVICE);
476 
477 free_mem:
478 	kfree(key_buf);
479 
480 	return err;
481 }
482 
483 static int update_cls_rule(struct net_device *net_dev,
484 			   struct ethtool_rx_flow_spec *new_fs,
485 			   int location)
486 {
487 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
488 	struct dpaa2_eth_cls_rule *rule;
489 	int err = -EINVAL;
490 
491 	if (!priv->rx_cls_enabled)
492 		return -EOPNOTSUPP;
493 
494 	if (location >= dpaa2_eth_fs_count(priv))
495 		return -EINVAL;
496 
497 	rule = &priv->cls_rules[location];
498 
499 	/* If a rule is present at the specified location, delete it. */
500 	if (rule->in_use) {
501 		err = do_cls_rule(net_dev, &rule->fs, false);
502 		if (err)
503 			return err;
504 
505 		rule->in_use = 0;
506 	}
507 
508 	/* If no new entry to add, return here */
509 	if (!new_fs)
510 		return err;
511 
512 	err = do_cls_rule(net_dev, new_fs, true);
513 	if (err)
514 		return err;
515 
516 	rule->in_use = 1;
517 	rule->fs = *new_fs;
518 
519 	return 0;
520 }
521 
522 static int dpaa2_eth_get_rxnfc(struct net_device *net_dev,
523 			       struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
524 {
525 	struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
526 	int max_rules = dpaa2_eth_fs_count(priv);
527 	int i, j = 0;
528 
529 	switch (rxnfc->cmd) {
530 	case ETHTOOL_GRXFH:
531 		/* we purposely ignore cmd->flow_type for now, because the
532 		 * classifier only supports a single set of fields for all
533 		 * protocols
534 		 */
535 		rxnfc->data = priv->rx_hash_fields;
536 		break;
537 	case ETHTOOL_GRXRINGS:
538 		rxnfc->data = dpaa2_eth_queue_count(priv);
539 		break;
540 	case ETHTOOL_GRXCLSRLCNT:
541 		rxnfc->rule_cnt = 0;
542 		for (i = 0; i < max_rules; i++)
543 			if (priv->cls_rules[i].in_use)
544 				rxnfc->rule_cnt++;
545 		rxnfc->data = max_rules;
546 		break;
547 	case ETHTOOL_GRXCLSRULE:
548 		if (rxnfc->fs.location >= max_rules)
549 			return -EINVAL;
550 		if (!priv->cls_rules[rxnfc->fs.location].in_use)
551 			return -EINVAL;
552 		rxnfc->fs = priv->cls_rules[rxnfc->fs.location].fs;
553 		break;
554 	case ETHTOOL_GRXCLSRLALL:
555 		for (i = 0; i < max_rules; i++) {
556 			if (!priv->cls_rules[i].in_use)
557 				continue;
558 			if (j == rxnfc->rule_cnt)
559 				return -EMSGSIZE;
560 			rule_locs[j++] = i;
561 		}
562 		rxnfc->rule_cnt = j;
563 		rxnfc->data = max_rules;
564 		break;
565 	default:
566 		return -EOPNOTSUPP;
567 	}
568 
569 	return 0;
570 }
571 
572 static int dpaa2_eth_set_rxnfc(struct net_device *net_dev,
573 			       struct ethtool_rxnfc *rxnfc)
574 {
575 	int err = 0;
576 
577 	switch (rxnfc->cmd) {
578 	case ETHTOOL_SRXFH:
579 		if ((rxnfc->data & DPAA2_RXH_SUPPORTED) != rxnfc->data)
580 			return -EOPNOTSUPP;
581 		err = dpaa2_eth_set_hash(net_dev, rxnfc->data);
582 		break;
583 	case ETHTOOL_SRXCLSRLINS:
584 		err = update_cls_rule(net_dev, &rxnfc->fs, rxnfc->fs.location);
585 		break;
586 	case ETHTOOL_SRXCLSRLDEL:
587 		err = update_cls_rule(net_dev, NULL, rxnfc->fs.location);
588 		break;
589 	default:
590 		err = -EOPNOTSUPP;
591 	}
592 
593 	return err;
594 }
595 
596 int dpaa2_phc_index = -1;
597 EXPORT_SYMBOL(dpaa2_phc_index);
598 
599 static int dpaa2_eth_get_ts_info(struct net_device *dev,
600 				 struct ethtool_ts_info *info)
601 {
602 	info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
603 				SOF_TIMESTAMPING_RX_HARDWARE |
604 				SOF_TIMESTAMPING_RAW_HARDWARE;
605 
606 	info->phc_index = dpaa2_phc_index;
607 
608 	info->tx_types = (1 << HWTSTAMP_TX_OFF) |
609 			 (1 << HWTSTAMP_TX_ON);
610 
611 	info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
612 			   (1 << HWTSTAMP_FILTER_ALL);
613 	return 0;
614 }
615 
616 const struct ethtool_ops dpaa2_ethtool_ops = {
617 	.get_drvinfo = dpaa2_eth_get_drvinfo,
618 	.get_link = ethtool_op_get_link,
619 	.get_link_ksettings = dpaa2_eth_get_link_ksettings,
620 	.set_link_ksettings = dpaa2_eth_set_link_ksettings,
621 	.get_sset_count = dpaa2_eth_get_sset_count,
622 	.get_ethtool_stats = dpaa2_eth_get_ethtool_stats,
623 	.get_strings = dpaa2_eth_get_strings,
624 	.get_rxnfc = dpaa2_eth_get_rxnfc,
625 	.set_rxnfc = dpaa2_eth_set_rxnfc,
626 	.get_ts_info = dpaa2_eth_get_ts_info,
627 };
628