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