xref: /openbmc/linux/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c (revision b97d6790d03b763eca08847a9a5869a4291b9f9a)
1c5aa9e3bSLendacky, Thomas /*
2c5aa9e3bSLendacky, Thomas  * AMD 10Gb Ethernet driver
3c5aa9e3bSLendacky, Thomas  *
4c5aa9e3bSLendacky, Thomas  * This file is available to you under your choice of the following two
5c5aa9e3bSLendacky, Thomas  * licenses:
6c5aa9e3bSLendacky, Thomas  *
7c5aa9e3bSLendacky, Thomas  * License 1: GPLv2
8c5aa9e3bSLendacky, Thomas  *
9757e6aa3SLendacky, Thomas  * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
10c5aa9e3bSLendacky, Thomas  *
11c5aa9e3bSLendacky, Thomas  * This file is free software; you may copy, redistribute and/or modify
12c5aa9e3bSLendacky, Thomas  * it under the terms of the GNU General Public License as published by
13c5aa9e3bSLendacky, Thomas  * the Free Software Foundation, either version 2 of the License, or (at
14c5aa9e3bSLendacky, Thomas  * your option) any later version.
15c5aa9e3bSLendacky, Thomas  *
16c5aa9e3bSLendacky, Thomas  * This file is distributed in the hope that it will be useful, but
17c5aa9e3bSLendacky, Thomas  * WITHOUT ANY WARRANTY; without even the implied warranty of
18c5aa9e3bSLendacky, Thomas  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19c5aa9e3bSLendacky, Thomas  * General Public License for more details.
20c5aa9e3bSLendacky, Thomas  *
21c5aa9e3bSLendacky, Thomas  * You should have received a copy of the GNU General Public License
22c5aa9e3bSLendacky, Thomas  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23c5aa9e3bSLendacky, Thomas  *
24c5aa9e3bSLendacky, Thomas  * This file incorporates work covered by the following copyright and
25c5aa9e3bSLendacky, Thomas  * permission notice:
26c5aa9e3bSLendacky, Thomas  *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
27c5aa9e3bSLendacky, Thomas  *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
28c5aa9e3bSLendacky, Thomas  *     Inc. unless otherwise expressly agreed to in writing between Synopsys
29c5aa9e3bSLendacky, Thomas  *     and you.
30c5aa9e3bSLendacky, Thomas  *
31c5aa9e3bSLendacky, Thomas  *     The Software IS NOT an item of Licensed Software or Licensed Product
32c5aa9e3bSLendacky, Thomas  *     under any End User Software License Agreement or Agreement for Licensed
33c5aa9e3bSLendacky, Thomas  *     Product with Synopsys or any supplement thereto.  Permission is hereby
34c5aa9e3bSLendacky, Thomas  *     granted, free of charge, to any person obtaining a copy of this software
35c5aa9e3bSLendacky, Thomas  *     annotated with this license and the Software, to deal in the Software
36c5aa9e3bSLendacky, Thomas  *     without restriction, including without limitation the rights to use,
37c5aa9e3bSLendacky, Thomas  *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
38c5aa9e3bSLendacky, Thomas  *     of the Software, and to permit persons to whom the Software is furnished
39c5aa9e3bSLendacky, Thomas  *     to do so, subject to the following conditions:
40c5aa9e3bSLendacky, Thomas  *
41c5aa9e3bSLendacky, Thomas  *     The above copyright notice and this permission notice shall be included
42c5aa9e3bSLendacky, Thomas  *     in all copies or substantial portions of the Software.
43c5aa9e3bSLendacky, Thomas  *
44c5aa9e3bSLendacky, Thomas  *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
45c5aa9e3bSLendacky, Thomas  *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
46c5aa9e3bSLendacky, Thomas  *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47c5aa9e3bSLendacky, Thomas  *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
48c5aa9e3bSLendacky, Thomas  *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49c5aa9e3bSLendacky, Thomas  *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50c5aa9e3bSLendacky, Thomas  *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51c5aa9e3bSLendacky, Thomas  *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52c5aa9e3bSLendacky, Thomas  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53c5aa9e3bSLendacky, Thomas  *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
54c5aa9e3bSLendacky, Thomas  *     THE POSSIBILITY OF SUCH DAMAGE.
55c5aa9e3bSLendacky, Thomas  *
56c5aa9e3bSLendacky, Thomas  *
57c5aa9e3bSLendacky, Thomas  * License 2: Modified BSD
58c5aa9e3bSLendacky, Thomas  *
59757e6aa3SLendacky, Thomas  * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
60c5aa9e3bSLendacky, Thomas  * All rights reserved.
61c5aa9e3bSLendacky, Thomas  *
62c5aa9e3bSLendacky, Thomas  * Redistribution and use in source and binary forms, with or without
63c5aa9e3bSLendacky, Thomas  * modification, are permitted provided that the following conditions are met:
64c5aa9e3bSLendacky, Thomas  *     * Redistributions of source code must retain the above copyright
65c5aa9e3bSLendacky, Thomas  *       notice, this list of conditions and the following disclaimer.
66c5aa9e3bSLendacky, Thomas  *     * Redistributions in binary form must reproduce the above copyright
67c5aa9e3bSLendacky, Thomas  *       notice, this list of conditions and the following disclaimer in the
68c5aa9e3bSLendacky, Thomas  *       documentation and/or other materials provided with the distribution.
69c5aa9e3bSLendacky, Thomas  *     * Neither the name of Advanced Micro Devices, Inc. nor the
70c5aa9e3bSLendacky, Thomas  *       names of its contributors may be used to endorse or promote products
71c5aa9e3bSLendacky, Thomas  *       derived from this software without specific prior written permission.
72c5aa9e3bSLendacky, Thomas  *
73c5aa9e3bSLendacky, Thomas  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
74c5aa9e3bSLendacky, Thomas  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75c5aa9e3bSLendacky, Thomas  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76c5aa9e3bSLendacky, Thomas  * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
77c5aa9e3bSLendacky, Thomas  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78c5aa9e3bSLendacky, Thomas  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
79c5aa9e3bSLendacky, Thomas  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80c5aa9e3bSLendacky, Thomas  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81c5aa9e3bSLendacky, Thomas  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
82c5aa9e3bSLendacky, Thomas  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83c5aa9e3bSLendacky, Thomas  *
84c5aa9e3bSLendacky, Thomas  * This file incorporates work covered by the following copyright and
85c5aa9e3bSLendacky, Thomas  * permission notice:
86c5aa9e3bSLendacky, Thomas  *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
87c5aa9e3bSLendacky, Thomas  *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
88c5aa9e3bSLendacky, Thomas  *     Inc. unless otherwise expressly agreed to in writing between Synopsys
89c5aa9e3bSLendacky, Thomas  *     and you.
90c5aa9e3bSLendacky, Thomas  *
91c5aa9e3bSLendacky, Thomas  *     The Software IS NOT an item of Licensed Software or Licensed Product
92c5aa9e3bSLendacky, Thomas  *     under any End User Software License Agreement or Agreement for Licensed
93c5aa9e3bSLendacky, Thomas  *     Product with Synopsys or any supplement thereto.  Permission is hereby
94c5aa9e3bSLendacky, Thomas  *     granted, free of charge, to any person obtaining a copy of this software
95c5aa9e3bSLendacky, Thomas  *     annotated with this license and the Software, to deal in the Software
96c5aa9e3bSLendacky, Thomas  *     without restriction, including without limitation the rights to use,
97c5aa9e3bSLendacky, Thomas  *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98c5aa9e3bSLendacky, Thomas  *     of the Software, and to permit persons to whom the Software is furnished
99c5aa9e3bSLendacky, Thomas  *     to do so, subject to the following conditions:
100c5aa9e3bSLendacky, Thomas  *
101c5aa9e3bSLendacky, Thomas  *     The above copyright notice and this permission notice shall be included
102c5aa9e3bSLendacky, Thomas  *     in all copies or substantial portions of the Software.
103c5aa9e3bSLendacky, Thomas  *
104c5aa9e3bSLendacky, Thomas  *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
105c5aa9e3bSLendacky, Thomas  *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
106c5aa9e3bSLendacky, Thomas  *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
107c5aa9e3bSLendacky, Thomas  *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
108c5aa9e3bSLendacky, Thomas  *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
109c5aa9e3bSLendacky, Thomas  *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
110c5aa9e3bSLendacky, Thomas  *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
111c5aa9e3bSLendacky, Thomas  *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
112c5aa9e3bSLendacky, Thomas  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
113c5aa9e3bSLendacky, Thomas  *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
114c5aa9e3bSLendacky, Thomas  *     THE POSSIBILITY OF SUCH DAMAGE.
115c5aa9e3bSLendacky, Thomas  */
116c5aa9e3bSLendacky, Thomas 
117c5aa9e3bSLendacky, Thomas #include <linux/spinlock.h>
118c5aa9e3bSLendacky, Thomas #include <linux/phy.h>
11923e4eef7SLendacky, Thomas #include <linux/net_tstamp.h>
120c5aa9e3bSLendacky, Thomas 
121c5aa9e3bSLendacky, Thomas #include "xgbe.h"
122c5aa9e3bSLendacky, Thomas #include "xgbe-common.h"
123c5aa9e3bSLendacky, Thomas 
124c5aa9e3bSLendacky, Thomas struct xgbe_stats {
125c5aa9e3bSLendacky, Thomas 	char stat_string[ETH_GSTRING_LEN];
126c5aa9e3bSLendacky, Thomas 	int stat_size;
127c5aa9e3bSLendacky, Thomas 	int stat_offset;
128c5aa9e3bSLendacky, Thomas };
129c5aa9e3bSLendacky, Thomas 
130c5aa9e3bSLendacky, Thomas #define XGMAC_MMC_STAT(_string, _var)				\
131c5aa9e3bSLendacky, Thomas 	{ _string,						\
132c593642cSPankaj Bharadiya 	  sizeof_field(struct xgbe_mmc_stats, _var),		\
133c5aa9e3bSLendacky, Thomas 	  offsetof(struct xgbe_prv_data, mmc_stats._var),	\
134c5aa9e3bSLendacky, Thomas 	}
135c5aa9e3bSLendacky, Thomas 
1365452b2dfSLendacky, Thomas #define XGMAC_EXT_STAT(_string, _var)				\
1375452b2dfSLendacky, Thomas 	{ _string,						\
138c593642cSPankaj Bharadiya 	  sizeof_field(struct xgbe_ext_stats, _var),		\
1395452b2dfSLendacky, Thomas 	  offsetof(struct xgbe_prv_data, ext_stats._var),	\
1405452b2dfSLendacky, Thomas 	}
1415452b2dfSLendacky, Thomas 
142c5aa9e3bSLendacky, Thomas static const struct xgbe_stats xgbe_gstring_stats[] = {
143c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_bytes", txoctetcount_gb),
144c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_packets", txframecount_gb),
145c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_unicast_packets", txunicastframes_gb),
146c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_broadcast_packets", txbroadcastframes_gb),
147c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_multicast_packets", txmulticastframes_gb),
148c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_vlan_packets", txvlanframes_g),
1493010608dSLendacky, Thomas 	XGMAC_EXT_STAT("tx_vxlan_packets", tx_vxlan_packets),
1505452b2dfSLendacky, Thomas 	XGMAC_EXT_STAT("tx_tso_packets", tx_tso_packets),
151c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_64_byte_packets", tx64octets_gb),
152c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_65_to_127_byte_packets", tx65to127octets_gb),
153c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_128_to_255_byte_packets", tx128to255octets_gb),
154c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_256_to_511_byte_packets", tx256to511octets_gb),
155c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_512_to_1023_byte_packets", tx512to1023octets_gb),
156c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_1024_to_max_byte_packets", tx1024tomaxoctets_gb),
157c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_underflow_errors", txunderflowerror),
158c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("tx_pause_frames", txpauseframes),
159c5aa9e3bSLendacky, Thomas 
160c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_bytes", rxoctetcount_gb),
161c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_packets", rxframecount_gb),
162c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_unicast_packets", rxunicastframes_g),
163c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_broadcast_packets", rxbroadcastframes_g),
164c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_multicast_packets", rxmulticastframes_g),
165c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_vlan_packets", rxvlanframes_gb),
1663010608dSLendacky, Thomas 	XGMAC_EXT_STAT("rx_vxlan_packets", rx_vxlan_packets),
167c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_64_byte_packets", rx64octets_gb),
168c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_65_to_127_byte_packets", rx65to127octets_gb),
169c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_128_to_255_byte_packets", rx128to255octets_gb),
170c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_256_to_511_byte_packets", rx256to511octets_gb),
171c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_512_to_1023_byte_packets", rx512to1023octets_gb),
172c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_1024_to_max_byte_packets", rx1024tomaxoctets_gb),
173c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_undersize_packets", rxundersize_g),
174c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_oversize_packets", rxoversize_g),
175c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_crc_errors", rxcrcerror),
176c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_crc_errors_small_packets", rxrunterror),
177c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_crc_errors_giant_packets", rxjabbererror),
178c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_length_errors", rxlengtherror),
179c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_out_of_range_errors", rxoutofrangetype),
180c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_fifo_overflow_errors", rxfifooverflow),
181c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_watchdog_errors", rxwatchdogerror),
1823010608dSLendacky, Thomas 	XGMAC_EXT_STAT("rx_csum_errors", rx_csum_errors),
1833010608dSLendacky, Thomas 	XGMAC_EXT_STAT("rx_vxlan_csum_errors", rx_vxlan_csum_errors),
184c5aa9e3bSLendacky, Thomas 	XGMAC_MMC_STAT("rx_pause_frames", rxpauseframes),
1855452b2dfSLendacky, Thomas 	XGMAC_EXT_STAT("rx_split_header_packets", rx_split_header_packets),
18672c9ac4eSLendacky, Thomas 	XGMAC_EXT_STAT("rx_buffer_unavailable", rx_buffer_unavailable),
187c5aa9e3bSLendacky, Thomas };
188a2ea14d7SLendacky, Thomas 
189c5aa9e3bSLendacky, Thomas #define XGBE_STATS_COUNT	ARRAY_SIZE(xgbe_gstring_stats)
190c5aa9e3bSLendacky, Thomas 
xgbe_get_strings(struct net_device * netdev,u32 stringset,u8 * data)191c5aa9e3bSLendacky, Thomas static void xgbe_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
192c5aa9e3bSLendacky, Thomas {
19380a788c9SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
194c5aa9e3bSLendacky, Thomas 	int i;
195c5aa9e3bSLendacky, Thomas 
196c5aa9e3bSLendacky, Thomas 	switch (stringset) {
197c5aa9e3bSLendacky, Thomas 	case ETH_SS_STATS:
198c5aa9e3bSLendacky, Thomas 		for (i = 0; i < XGBE_STATS_COUNT; i++) {
199c5aa9e3bSLendacky, Thomas 			memcpy(data, xgbe_gstring_stats[i].stat_string,
200c5aa9e3bSLendacky, Thomas 			       ETH_GSTRING_LEN);
201c5aa9e3bSLendacky, Thomas 			data += ETH_GSTRING_LEN;
202c5aa9e3bSLendacky, Thomas 		}
20380a788c9SLendacky, Thomas 		for (i = 0; i < pdata->tx_ring_count; i++) {
20480a788c9SLendacky, Thomas 			sprintf(data, "txq_%u_packets", i);
20580a788c9SLendacky, Thomas 			data += ETH_GSTRING_LEN;
20680a788c9SLendacky, Thomas 			sprintf(data, "txq_%u_bytes", i);
20780a788c9SLendacky, Thomas 			data += ETH_GSTRING_LEN;
20880a788c9SLendacky, Thomas 		}
20980a788c9SLendacky, Thomas 		for (i = 0; i < pdata->rx_ring_count; i++) {
21080a788c9SLendacky, Thomas 			sprintf(data, "rxq_%u_packets", i);
21180a788c9SLendacky, Thomas 			data += ETH_GSTRING_LEN;
21280a788c9SLendacky, Thomas 			sprintf(data, "rxq_%u_bytes", i);
21380a788c9SLendacky, Thomas 			data += ETH_GSTRING_LEN;
21480a788c9SLendacky, Thomas 		}
215c5aa9e3bSLendacky, Thomas 		break;
216c5aa9e3bSLendacky, Thomas 	}
217c5aa9e3bSLendacky, Thomas }
218c5aa9e3bSLendacky, Thomas 
xgbe_get_ethtool_stats(struct net_device * netdev,struct ethtool_stats * stats,u64 * data)219c5aa9e3bSLendacky, Thomas static void xgbe_get_ethtool_stats(struct net_device *netdev,
220c5aa9e3bSLendacky, Thomas 				   struct ethtool_stats *stats, u64 *data)
221c5aa9e3bSLendacky, Thomas {
222c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
223c5aa9e3bSLendacky, Thomas 	u8 *stat;
224c5aa9e3bSLendacky, Thomas 	int i;
225c5aa9e3bSLendacky, Thomas 
226c5aa9e3bSLendacky, Thomas 	pdata->hw_if.read_mmc_stats(pdata);
227c5aa9e3bSLendacky, Thomas 	for (i = 0; i < XGBE_STATS_COUNT; i++) {
228c5aa9e3bSLendacky, Thomas 		stat = (u8 *)pdata + xgbe_gstring_stats[i].stat_offset;
229c5aa9e3bSLendacky, Thomas 		*data++ = *(u64 *)stat;
230c5aa9e3bSLendacky, Thomas 	}
23180a788c9SLendacky, Thomas 	for (i = 0; i < pdata->tx_ring_count; i++) {
23280a788c9SLendacky, Thomas 		*data++ = pdata->ext_stats.txq_packets[i];
23380a788c9SLendacky, Thomas 		*data++ = pdata->ext_stats.txq_bytes[i];
23480a788c9SLendacky, Thomas 	}
23580a788c9SLendacky, Thomas 	for (i = 0; i < pdata->rx_ring_count; i++) {
23680a788c9SLendacky, Thomas 		*data++ = pdata->ext_stats.rxq_packets[i];
23780a788c9SLendacky, Thomas 		*data++ = pdata->ext_stats.rxq_bytes[i];
23880a788c9SLendacky, Thomas 	}
239c5aa9e3bSLendacky, Thomas }
240c5aa9e3bSLendacky, Thomas 
xgbe_get_sset_count(struct net_device * netdev,int stringset)241c5aa9e3bSLendacky, Thomas static int xgbe_get_sset_count(struct net_device *netdev, int stringset)
242c5aa9e3bSLendacky, Thomas {
24380a788c9SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
244c5aa9e3bSLendacky, Thomas 	int ret;
245c5aa9e3bSLendacky, Thomas 
246c5aa9e3bSLendacky, Thomas 	switch (stringset) {
247c5aa9e3bSLendacky, Thomas 	case ETH_SS_STATS:
24880a788c9SLendacky, Thomas 		ret = XGBE_STATS_COUNT +
24980a788c9SLendacky, Thomas 		      (pdata->tx_ring_count * 2) +
25080a788c9SLendacky, Thomas 		      (pdata->rx_ring_count * 2);
251c5aa9e3bSLendacky, Thomas 		break;
252c5aa9e3bSLendacky, Thomas 
253c5aa9e3bSLendacky, Thomas 	default:
254c5aa9e3bSLendacky, Thomas 		ret = -EOPNOTSUPP;
255c5aa9e3bSLendacky, Thomas 	}
256c5aa9e3bSLendacky, Thomas 
257c5aa9e3bSLendacky, Thomas 	return ret;
258c5aa9e3bSLendacky, Thomas }
259c5aa9e3bSLendacky, Thomas 
xgbe_get_pauseparam(struct net_device * netdev,struct ethtool_pauseparam * pause)260c5aa9e3bSLendacky, Thomas static void xgbe_get_pauseparam(struct net_device *netdev,
261c5aa9e3bSLendacky, Thomas 				struct ethtool_pauseparam *pause)
262c5aa9e3bSLendacky, Thomas {
263c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
264c5aa9e3bSLendacky, Thomas 
265c1ce2f77SLendacky, Thomas 	pause->autoneg = pdata->phy.pause_autoneg;
266c1ce2f77SLendacky, Thomas 	pause->tx_pause = pdata->phy.tx_pause;
267c1ce2f77SLendacky, Thomas 	pause->rx_pause = pdata->phy.rx_pause;
268c5aa9e3bSLendacky, Thomas }
269c5aa9e3bSLendacky, Thomas 
xgbe_set_pauseparam(struct net_device * netdev,struct ethtool_pauseparam * pause)270c5aa9e3bSLendacky, Thomas static int xgbe_set_pauseparam(struct net_device *netdev,
271c5aa9e3bSLendacky, Thomas 			       struct ethtool_pauseparam *pause)
272c5aa9e3bSLendacky, Thomas {
273c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
27485f9feb6SLendacky, Thomas 	struct ethtool_link_ksettings *lks = &pdata->phy.lks;
275c5aa9e3bSLendacky, Thomas 	int ret = 0;
276c5aa9e3bSLendacky, Thomas 
277e5dd8b81SLendacky, Thomas 	if (pause->autoneg && (pdata->phy.autoneg != AUTONEG_ENABLE)) {
278e5dd8b81SLendacky, Thomas 		netdev_err(netdev,
279beef8516SColin Ian King 			   "autoneg disabled, pause autoneg not available\n");
280c1ce2f77SLendacky, Thomas 		return -EINVAL;
281e5dd8b81SLendacky, Thomas 	}
282c5aa9e3bSLendacky, Thomas 
283c1ce2f77SLendacky, Thomas 	pdata->phy.pause_autoneg = pause->autoneg;
284c1ce2f77SLendacky, Thomas 	pdata->phy.tx_pause = pause->tx_pause;
285c1ce2f77SLendacky, Thomas 	pdata->phy.rx_pause = pause->rx_pause;
286c1ce2f77SLendacky, Thomas 
28785f9feb6SLendacky, Thomas 	XGBE_CLR_ADV(lks, Pause);
28885f9feb6SLendacky, Thomas 	XGBE_CLR_ADV(lks, Asym_Pause);
289c5aa9e3bSLendacky, Thomas 
290c1ce2f77SLendacky, Thomas 	if (pause->rx_pause) {
29185f9feb6SLendacky, Thomas 		XGBE_SET_ADV(lks, Pause);
29285f9feb6SLendacky, Thomas 		XGBE_SET_ADV(lks, Asym_Pause);
293c5aa9e3bSLendacky, Thomas 	}
294c5aa9e3bSLendacky, Thomas 
29585f9feb6SLendacky, Thomas 	if (pause->tx_pause) {
29685f9feb6SLendacky, Thomas 		/* Equivalent to XOR of Asym_Pause */
29785f9feb6SLendacky, Thomas 		if (XGBE_ADV(lks, Asym_Pause))
29885f9feb6SLendacky, Thomas 			XGBE_CLR_ADV(lks, Asym_Pause);
29985f9feb6SLendacky, Thomas 		else
30085f9feb6SLendacky, Thomas 			XGBE_SET_ADV(lks, Asym_Pause);
30185f9feb6SLendacky, Thomas 	}
302c1ce2f77SLendacky, Thomas 
303c5aa9e3bSLendacky, Thomas 	if (netif_running(netdev))
3047c12aa08SLendacky, Thomas 		ret = pdata->phy_if.phy_config_aneg(pdata);
305c5aa9e3bSLendacky, Thomas 
306c5aa9e3bSLendacky, Thomas 	return ret;
307c5aa9e3bSLendacky, Thomas }
308c5aa9e3bSLendacky, Thomas 
xgbe_get_link_ksettings(struct net_device * netdev,struct ethtool_link_ksettings * cmd)30990fdd04eSPhilippe Reynes static int xgbe_get_link_ksettings(struct net_device *netdev,
31090fdd04eSPhilippe Reynes 				   struct ethtool_link_ksettings *cmd)
311c5aa9e3bSLendacky, Thomas {
312c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
31385f9feb6SLendacky, Thomas 	struct ethtool_link_ksettings *lks = &pdata->phy.lks;
314c5aa9e3bSLendacky, Thomas 
31590fdd04eSPhilippe Reynes 	cmd->base.phy_address = pdata->phy.address;
316c5aa9e3bSLendacky, Thomas 
317*54f06863SRaju Rangoju 	if (netif_carrier_ok(netdev)) {
31890fdd04eSPhilippe Reynes 		cmd->base.speed = pdata->phy.speed;
31990fdd04eSPhilippe Reynes 		cmd->base.duplex = pdata->phy.duplex;
320*54f06863SRaju Rangoju 	} else {
321*54f06863SRaju Rangoju 		cmd->base.speed = SPEED_UNKNOWN;
322*54f06863SRaju Rangoju 		cmd->base.duplex = DUPLEX_UNKNOWN;
323*54f06863SRaju Rangoju 	}
3247c12aa08SLendacky, Thomas 
325*54f06863SRaju Rangoju 	cmd->base.autoneg = pdata->phy.autoneg;
32690fdd04eSPhilippe Reynes 	cmd->base.port = PORT_NONE;
327c5aa9e3bSLendacky, Thomas 
32885f9feb6SLendacky, Thomas 	XGBE_LM_COPY(cmd, supported, lks, supported);
32985f9feb6SLendacky, Thomas 	XGBE_LM_COPY(cmd, advertising, lks, advertising);
33085f9feb6SLendacky, Thomas 	XGBE_LM_COPY(cmd, lp_advertising, lks, lp_advertising);
33185f9feb6SLendacky, Thomas 
3327c12aa08SLendacky, Thomas 	return 0;
333c5aa9e3bSLendacky, Thomas }
334c5aa9e3bSLendacky, Thomas 
xgbe_set_link_ksettings(struct net_device * netdev,const struct ethtool_link_ksettings * cmd)33590fdd04eSPhilippe Reynes static int xgbe_set_link_ksettings(struct net_device *netdev,
33690fdd04eSPhilippe Reynes 				   const struct ethtool_link_ksettings *cmd)
337c5aa9e3bSLendacky, Thomas {
338c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
33985f9feb6SLendacky, Thomas 	struct ethtool_link_ksettings *lks = &pdata->phy.lks;
34085f9feb6SLendacky, Thomas 	__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
341c5aa9e3bSLendacky, Thomas 	u32 speed;
342c5aa9e3bSLendacky, Thomas 	int ret;
343c5aa9e3bSLendacky, Thomas 
34490fdd04eSPhilippe Reynes 	speed = cmd->base.speed;
345c5aa9e3bSLendacky, Thomas 
34690fdd04eSPhilippe Reynes 	if (cmd->base.phy_address != pdata->phy.address) {
347e5dd8b81SLendacky, Thomas 		netdev_err(netdev, "invalid phy address %hhu\n",
34890fdd04eSPhilippe Reynes 			   cmd->base.phy_address);
3498c43a2ccSLendacky, Thomas 		return -EINVAL;
350e5dd8b81SLendacky, Thomas 	}
351c5aa9e3bSLendacky, Thomas 
35290fdd04eSPhilippe Reynes 	if ((cmd->base.autoneg != AUTONEG_ENABLE) &&
35390fdd04eSPhilippe Reynes 	    (cmd->base.autoneg != AUTONEG_DISABLE)) {
354e5dd8b81SLendacky, Thomas 		netdev_err(netdev, "unsupported autoneg %hhu\n",
35590fdd04eSPhilippe Reynes 			   cmd->base.autoneg);
3568c43a2ccSLendacky, Thomas 		return -EINVAL;
357e5dd8b81SLendacky, Thomas 	}
358c5aa9e3bSLendacky, Thomas 
35990fdd04eSPhilippe Reynes 	if (cmd->base.autoneg == AUTONEG_DISABLE) {
360e57f7a3fSLendacky, Thomas 		if (!pdata->phy_if.phy_valid_speed(pdata, speed)) {
361e5dd8b81SLendacky, Thomas 			netdev_err(netdev, "unsupported speed %u\n", speed);
3628c43a2ccSLendacky, Thomas 			return -EINVAL;
363f047604aSLendacky, Thomas 		}
364f047604aSLendacky, Thomas 
36590fdd04eSPhilippe Reynes 		if (cmd->base.duplex != DUPLEX_FULL) {
366e5dd8b81SLendacky, Thomas 			netdev_err(netdev, "unsupported duplex %hhu\n",
36790fdd04eSPhilippe Reynes 				   cmd->base.duplex);
3688c43a2ccSLendacky, Thomas 			return -EINVAL;
369f047604aSLendacky, Thomas 		}
370e5dd8b81SLendacky, Thomas 	}
371e5dd8b81SLendacky, Thomas 
372e5dd8b81SLendacky, Thomas 	netif_dbg(pdata, link, netdev,
37385f9feb6SLendacky, Thomas 		  "requested advertisement 0x%*pb, phy supported 0x%*pb\n",
37485f9feb6SLendacky, Thomas 		  __ETHTOOL_LINK_MODE_MASK_NBITS, cmd->link_modes.advertising,
37585f9feb6SLendacky, Thomas 		  __ETHTOOL_LINK_MODE_MASK_NBITS, lks->link_modes.supported);
376c5aa9e3bSLendacky, Thomas 
3774973056cSSean Anderson 	linkmode_and(advertising, cmd->link_modes.advertising,
3784973056cSSean Anderson 		     lks->link_modes.supported);
37985f9feb6SLendacky, Thomas 
38085f9feb6SLendacky, Thomas 	if ((cmd->base.autoneg == AUTONEG_ENABLE) &&
38185f9feb6SLendacky, Thomas 	    bitmap_empty(advertising, __ETHTOOL_LINK_MODE_MASK_NBITS)) {
382e5dd8b81SLendacky, Thomas 		netdev_err(netdev,
383e5dd8b81SLendacky, Thomas 			   "unsupported requested advertisement\n");
3848c43a2ccSLendacky, Thomas 		return -EINVAL;
385e5dd8b81SLendacky, Thomas 	}
386c5aa9e3bSLendacky, Thomas 
387c5aa9e3bSLendacky, Thomas 	ret = 0;
38890fdd04eSPhilippe Reynes 	pdata->phy.autoneg = cmd->base.autoneg;
3897c12aa08SLendacky, Thomas 	pdata->phy.speed = speed;
39090fdd04eSPhilippe Reynes 	pdata->phy.duplex = cmd->base.duplex;
3914973056cSSean Anderson 	linkmode_copy(lks->link_modes.advertising, advertising);
392c5aa9e3bSLendacky, Thomas 
39390fdd04eSPhilippe Reynes 	if (cmd->base.autoneg == AUTONEG_ENABLE)
39485f9feb6SLendacky, Thomas 		XGBE_SET_ADV(lks, Autoneg);
395c5aa9e3bSLendacky, Thomas 	else
39685f9feb6SLendacky, Thomas 		XGBE_CLR_ADV(lks, Autoneg);
397c5aa9e3bSLendacky, Thomas 
398c5aa9e3bSLendacky, Thomas 	if (netif_running(netdev))
3997c12aa08SLendacky, Thomas 		ret = pdata->phy_if.phy_config_aneg(pdata);
400c5aa9e3bSLendacky, Thomas 
401c5aa9e3bSLendacky, Thomas 	return ret;
402c5aa9e3bSLendacky, Thomas }
403c5aa9e3bSLendacky, Thomas 
xgbe_get_drvinfo(struct net_device * netdev,struct ethtool_drvinfo * drvinfo)404c5aa9e3bSLendacky, Thomas static void xgbe_get_drvinfo(struct net_device *netdev,
405c5aa9e3bSLendacky, Thomas 			     struct ethtool_drvinfo *drvinfo)
406c5aa9e3bSLendacky, Thomas {
407c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
408a9a4a2d9SLendacky, Thomas 	struct xgbe_hw_features *hw_feat = &pdata->hw_feat;
409c5aa9e3bSLendacky, Thomas 
410f029c781SWolfram Sang 	strscpy(drvinfo->driver, XGBE_DRV_NAME, sizeof(drvinfo->driver));
411f029c781SWolfram Sang 	strscpy(drvinfo->bus_info, dev_name(pdata->dev),
412c5aa9e3bSLendacky, Thomas 		sizeof(drvinfo->bus_info));
413c5aa9e3bSLendacky, Thomas 	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%d",
414a9a4a2d9SLendacky, Thomas 		 XGMAC_GET_BITS(hw_feat->version, MAC_VR, USERVER),
415a9a4a2d9SLendacky, Thomas 		 XGMAC_GET_BITS(hw_feat->version, MAC_VR, DEVID),
416a9a4a2d9SLendacky, Thomas 		 XGMAC_GET_BITS(hw_feat->version, MAC_VR, SNPSVER));
417c5aa9e3bSLendacky, Thomas }
418c5aa9e3bSLendacky, Thomas 
xgbe_get_msglevel(struct net_device * netdev)419349fb2d7SLendacky, Thomas static u32 xgbe_get_msglevel(struct net_device *netdev)
420349fb2d7SLendacky, Thomas {
421349fb2d7SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
422349fb2d7SLendacky, Thomas 
423349fb2d7SLendacky, Thomas 	return pdata->msg_enable;
424349fb2d7SLendacky, Thomas }
425349fb2d7SLendacky, Thomas 
xgbe_set_msglevel(struct net_device * netdev,u32 msglevel)426349fb2d7SLendacky, Thomas static void xgbe_set_msglevel(struct net_device *netdev, u32 msglevel)
427349fb2d7SLendacky, Thomas {
428349fb2d7SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
429349fb2d7SLendacky, Thomas 
430349fb2d7SLendacky, Thomas 	pdata->msg_enable = msglevel;
431349fb2d7SLendacky, Thomas }
432349fb2d7SLendacky, Thomas 
xgbe_get_coalesce(struct net_device * netdev,struct ethtool_coalesce * ec,struct kernel_ethtool_coalesce * kernel_coal,struct netlink_ext_ack * extack)433c5aa9e3bSLendacky, Thomas static int xgbe_get_coalesce(struct net_device *netdev,
434f3ccfda1SYufeng Mo 			     struct ethtool_coalesce *ec,
435f3ccfda1SYufeng Mo 			     struct kernel_ethtool_coalesce *kernel_coal,
436f3ccfda1SYufeng Mo 			     struct netlink_ext_ack *extack)
437c5aa9e3bSLendacky, Thomas {
438c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
439c5aa9e3bSLendacky, Thomas 
440c5aa9e3bSLendacky, Thomas 	memset(ec, 0, sizeof(struct ethtool_coalesce));
441c5aa9e3bSLendacky, Thomas 
4424a57ebccSLendacky, Thomas 	ec->rx_coalesce_usecs = pdata->rx_usecs;
443c5aa9e3bSLendacky, Thomas 	ec->rx_max_coalesced_frames = pdata->rx_frames;
444c5aa9e3bSLendacky, Thomas 
445c5aa9e3bSLendacky, Thomas 	ec->tx_max_coalesced_frames = pdata->tx_frames;
446c5aa9e3bSLendacky, Thomas 
447c5aa9e3bSLendacky, Thomas 	return 0;
448c5aa9e3bSLendacky, Thomas }
449c5aa9e3bSLendacky, Thomas 
xgbe_set_coalesce(struct net_device * netdev,struct ethtool_coalesce * ec,struct kernel_ethtool_coalesce * kernel_coal,struct netlink_ext_ack * extack)450c5aa9e3bSLendacky, Thomas static int xgbe_set_coalesce(struct net_device *netdev,
451f3ccfda1SYufeng Mo 			     struct ethtool_coalesce *ec,
452f3ccfda1SYufeng Mo 			     struct kernel_ethtool_coalesce *kernel_coal,
453f3ccfda1SYufeng Mo 			     struct netlink_ext_ack *extack)
454c5aa9e3bSLendacky, Thomas {
455c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
456c5aa9e3bSLendacky, Thomas 	struct xgbe_hw_if *hw_if = &pdata->hw_if;
457c5aa9e3bSLendacky, Thomas 	unsigned int rx_frames, rx_riwt, rx_usecs;
458c635eaacSLendacky, Thomas 	unsigned int tx_frames;
459c5aa9e3bSLendacky, Thomas 
460c5aa9e3bSLendacky, Thomas 	rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs);
4614a57ebccSLendacky, Thomas 	rx_usecs = ec->rx_coalesce_usecs;
462c5aa9e3bSLendacky, Thomas 	rx_frames = ec->rx_max_coalesced_frames;
463c5aa9e3bSLendacky, Thomas 
464c5aa9e3bSLendacky, Thomas 	/* Use smallest possible value if conversion resulted in zero */
4654a57ebccSLendacky, Thomas 	if (rx_usecs && !rx_riwt)
466c5aa9e3bSLendacky, Thomas 		rx_riwt = 1;
467c5aa9e3bSLendacky, Thomas 
468c5aa9e3bSLendacky, Thomas 	/* Check the bounds of values for Rx */
469c5aa9e3bSLendacky, Thomas 	if (rx_riwt > XGMAC_MAX_DMA_RIWT) {
470e5dd8b81SLendacky, Thomas 		netdev_err(netdev, "rx-usec is limited to %d usecs\n",
4714a57ebccSLendacky, Thomas 			   hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT));
472c5aa9e3bSLendacky, Thomas 		return -EINVAL;
473c5aa9e3bSLendacky, Thomas 	}
4744780b7caSLendacky, Thomas 	if (rx_frames > pdata->rx_desc_count) {
475e5dd8b81SLendacky, Thomas 		netdev_err(netdev, "rx-frames is limited to %d frames\n",
4764780b7caSLendacky, Thomas 			   pdata->rx_desc_count);
477c5aa9e3bSLendacky, Thomas 		return -EINVAL;
478c5aa9e3bSLendacky, Thomas 	}
479c5aa9e3bSLendacky, Thomas 
480c5aa9e3bSLendacky, Thomas 	tx_frames = ec->tx_max_coalesced_frames;
481c5aa9e3bSLendacky, Thomas 
482c5aa9e3bSLendacky, Thomas 	/* Check the bounds of values for Tx */
4834780b7caSLendacky, Thomas 	if (tx_frames > pdata->tx_desc_count) {
484e5dd8b81SLendacky, Thomas 		netdev_err(netdev, "tx-frames is limited to %d frames\n",
4854780b7caSLendacky, Thomas 			   pdata->tx_desc_count);
486c5aa9e3bSLendacky, Thomas 		return -EINVAL;
487c5aa9e3bSLendacky, Thomas 	}
488c5aa9e3bSLendacky, Thomas 
489c5aa9e3bSLendacky, Thomas 	pdata->rx_riwt = rx_riwt;
4904a57ebccSLendacky, Thomas 	pdata->rx_usecs = rx_usecs;
491c5aa9e3bSLendacky, Thomas 	pdata->rx_frames = rx_frames;
492c5aa9e3bSLendacky, Thomas 	hw_if->config_rx_coalesce(pdata);
493c5aa9e3bSLendacky, Thomas 
494c5aa9e3bSLendacky, Thomas 	pdata->tx_frames = tx_frames;
495c5aa9e3bSLendacky, Thomas 	hw_if->config_tx_coalesce(pdata);
496c5aa9e3bSLendacky, Thomas 
497c5aa9e3bSLendacky, Thomas 	return 0;
498c5aa9e3bSLendacky, Thomas }
499c5aa9e3bSLendacky, Thomas 
xgbe_get_rxnfc(struct net_device * netdev,struct ethtool_rxnfc * rxnfc,u32 * rule_locs)500f6ac8628SLendacky, Thomas static int xgbe_get_rxnfc(struct net_device *netdev,
501f6ac8628SLendacky, Thomas 			  struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
502f6ac8628SLendacky, Thomas {
503f6ac8628SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
504f6ac8628SLendacky, Thomas 
505f6ac8628SLendacky, Thomas 	switch (rxnfc->cmd) {
506f6ac8628SLendacky, Thomas 	case ETHTOOL_GRXRINGS:
507f6ac8628SLendacky, Thomas 		rxnfc->data = pdata->rx_ring_count;
508f6ac8628SLendacky, Thomas 		break;
509f6ac8628SLendacky, Thomas 	default:
510f6ac8628SLendacky, Thomas 		return -EOPNOTSUPP;
511f6ac8628SLendacky, Thomas 	}
512f6ac8628SLendacky, Thomas 
513f6ac8628SLendacky, Thomas 	return 0;
514f6ac8628SLendacky, Thomas }
515f6ac8628SLendacky, Thomas 
xgbe_get_rxfh_key_size(struct net_device * netdev)516f6ac8628SLendacky, Thomas static u32 xgbe_get_rxfh_key_size(struct net_device *netdev)
517f6ac8628SLendacky, Thomas {
518f6ac8628SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
519f6ac8628SLendacky, Thomas 
520f6ac8628SLendacky, Thomas 	return sizeof(pdata->rss_key);
521f6ac8628SLendacky, Thomas }
522f6ac8628SLendacky, Thomas 
xgbe_get_rxfh_indir_size(struct net_device * netdev)523f6ac8628SLendacky, Thomas static u32 xgbe_get_rxfh_indir_size(struct net_device *netdev)
524f6ac8628SLendacky, Thomas {
525f6ac8628SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
526f6ac8628SLendacky, Thomas 
527f6ac8628SLendacky, Thomas 	return ARRAY_SIZE(pdata->rss_table);
528f6ac8628SLendacky, Thomas }
529f6ac8628SLendacky, Thomas 
xgbe_get_rxfh(struct net_device * netdev,u32 * indir,u8 * key,u8 * hfunc)530892311f6SEyal Perry static int xgbe_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
531892311f6SEyal Perry 			 u8 *hfunc)
532f6ac8628SLendacky, Thomas {
533f6ac8628SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
534f6ac8628SLendacky, Thomas 	unsigned int i;
535f6ac8628SLendacky, Thomas 
536f6ac8628SLendacky, Thomas 	if (indir) {
537f6ac8628SLendacky, Thomas 		for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++)
538f6ac8628SLendacky, Thomas 			indir[i] = XGMAC_GET_BITS(pdata->rss_table[i],
539f6ac8628SLendacky, Thomas 						  MAC_RSSDR, DMCH);
540f6ac8628SLendacky, Thomas 	}
541f6ac8628SLendacky, Thomas 
542f6ac8628SLendacky, Thomas 	if (key)
543f6ac8628SLendacky, Thomas 		memcpy(key, pdata->rss_key, sizeof(pdata->rss_key));
544f6ac8628SLendacky, Thomas 
545892311f6SEyal Perry 	if (hfunc)
546892311f6SEyal Perry 		*hfunc = ETH_RSS_HASH_TOP;
547892311f6SEyal Perry 
548f6ac8628SLendacky, Thomas 	return 0;
549f6ac8628SLendacky, Thomas }
550f6ac8628SLendacky, Thomas 
xgbe_set_rxfh(struct net_device * netdev,const u32 * indir,const u8 * key,const u8 hfunc)551f6ac8628SLendacky, Thomas static int xgbe_set_rxfh(struct net_device *netdev, const u32 *indir,
552892311f6SEyal Perry 			 const u8 *key, const u8 hfunc)
553f6ac8628SLendacky, Thomas {
554f6ac8628SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
555f6ac8628SLendacky, Thomas 	struct xgbe_hw_if *hw_if = &pdata->hw_if;
556f6ac8628SLendacky, Thomas 	unsigned int ret;
557f6ac8628SLendacky, Thomas 
558e5dd8b81SLendacky, Thomas 	if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) {
559e5dd8b81SLendacky, Thomas 		netdev_err(netdev, "unsupported hash function\n");
560892311f6SEyal Perry 		return -EOPNOTSUPP;
561e5dd8b81SLendacky, Thomas 	}
562892311f6SEyal Perry 
563f6ac8628SLendacky, Thomas 	if (indir) {
564f6ac8628SLendacky, Thomas 		ret = hw_if->set_rss_lookup_table(pdata, indir);
565f6ac8628SLendacky, Thomas 		if (ret)
566f6ac8628SLendacky, Thomas 			return ret;
567f6ac8628SLendacky, Thomas 	}
568f6ac8628SLendacky, Thomas 
569f6ac8628SLendacky, Thomas 	if (key) {
570f6ac8628SLendacky, Thomas 		ret = hw_if->set_rss_hash_key(pdata, key);
571f6ac8628SLendacky, Thomas 		if (ret)
572f6ac8628SLendacky, Thomas 			return ret;
573f6ac8628SLendacky, Thomas 	}
574f6ac8628SLendacky, Thomas 
575f6ac8628SLendacky, Thomas 	return 0;
576f6ac8628SLendacky, Thomas }
577f6ac8628SLendacky, Thomas 
xgbe_get_ts_info(struct net_device * netdev,struct ethtool_ts_info * ts_info)57823e4eef7SLendacky, Thomas static int xgbe_get_ts_info(struct net_device *netdev,
57923e4eef7SLendacky, Thomas 			    struct ethtool_ts_info *ts_info)
58023e4eef7SLendacky, Thomas {
58123e4eef7SLendacky, Thomas 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
58223e4eef7SLendacky, Thomas 
58323e4eef7SLendacky, Thomas 	ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
58423e4eef7SLendacky, Thomas 				   SOF_TIMESTAMPING_RX_SOFTWARE |
58523e4eef7SLendacky, Thomas 				   SOF_TIMESTAMPING_SOFTWARE |
58623e4eef7SLendacky, Thomas 				   SOF_TIMESTAMPING_TX_HARDWARE |
58723e4eef7SLendacky, Thomas 				   SOF_TIMESTAMPING_RX_HARDWARE |
58823e4eef7SLendacky, Thomas 				   SOF_TIMESTAMPING_RAW_HARDWARE;
58923e4eef7SLendacky, Thomas 
59023e4eef7SLendacky, Thomas 	if (pdata->ptp_clock)
59123e4eef7SLendacky, Thomas 		ts_info->phc_index = ptp_clock_index(pdata->ptp_clock);
59223e4eef7SLendacky, Thomas 	else
59323e4eef7SLendacky, Thomas 		ts_info->phc_index = -1;
59423e4eef7SLendacky, Thomas 
59523e4eef7SLendacky, Thomas 	ts_info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
59623e4eef7SLendacky, Thomas 	ts_info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
59723e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
59823e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
59923e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
60023e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
60123e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
60223e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
60323e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
60423e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
60523e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
60623e4eef7SLendacky, Thomas 			      (1 << HWTSTAMP_FILTER_ALL);
60723e4eef7SLendacky, Thomas 
60823e4eef7SLendacky, Thomas 	return 0;
60923e4eef7SLendacky, Thomas }
61023e4eef7SLendacky, Thomas 
xgbe_get_module_info(struct net_device * netdev,struct ethtool_modinfo * modinfo)61153a1024aSTom Lendacky static int xgbe_get_module_info(struct net_device *netdev,
61253a1024aSTom Lendacky 				struct ethtool_modinfo *modinfo)
61353a1024aSTom Lendacky {
61453a1024aSTom Lendacky 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
61553a1024aSTom Lendacky 
61653a1024aSTom Lendacky 	return pdata->phy_if.module_info(pdata, modinfo);
61753a1024aSTom Lendacky }
61853a1024aSTom Lendacky 
xgbe_get_module_eeprom(struct net_device * netdev,struct ethtool_eeprom * eeprom,u8 * data)61953a1024aSTom Lendacky static int xgbe_get_module_eeprom(struct net_device *netdev,
62053a1024aSTom Lendacky 				  struct ethtool_eeprom *eeprom, u8 *data)
62153a1024aSTom Lendacky {
62253a1024aSTom Lendacky 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
62353a1024aSTom Lendacky 
62453a1024aSTom Lendacky 	return pdata->phy_if.module_eeprom(pdata, eeprom, data);
62553a1024aSTom Lendacky }
62653a1024aSTom Lendacky 
62774624944SHao Chen static void
xgbe_get_ringparam(struct net_device * netdev,struct ethtool_ringparam * ringparam,struct kernel_ethtool_ringparam * kernel_ringparam,struct netlink_ext_ack * extack)62874624944SHao Chen xgbe_get_ringparam(struct net_device *netdev,
62974624944SHao Chen 		   struct ethtool_ringparam *ringparam,
63074624944SHao Chen 		   struct kernel_ethtool_ringparam *kernel_ringparam,
63174624944SHao Chen 		   struct netlink_ext_ack *extack)
632bab748deSTom Lendacky {
633bab748deSTom Lendacky 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
634bab748deSTom Lendacky 
635bab748deSTom Lendacky 	ringparam->rx_max_pending = XGBE_RX_DESC_CNT_MAX;
636bab748deSTom Lendacky 	ringparam->tx_max_pending = XGBE_TX_DESC_CNT_MAX;
637bab748deSTom Lendacky 	ringparam->rx_pending = pdata->rx_desc_count;
638bab748deSTom Lendacky 	ringparam->tx_pending = pdata->tx_desc_count;
639bab748deSTom Lendacky }
640bab748deSTom Lendacky 
xgbe_set_ringparam(struct net_device * netdev,struct ethtool_ringparam * ringparam,struct kernel_ethtool_ringparam * kernel_ringparam,struct netlink_ext_ack * extack)641bab748deSTom Lendacky static int xgbe_set_ringparam(struct net_device *netdev,
64274624944SHao Chen 			      struct ethtool_ringparam *ringparam,
64374624944SHao Chen 			      struct kernel_ethtool_ringparam *kernel_ringparam,
64474624944SHao Chen 			      struct netlink_ext_ack *extack)
645bab748deSTom Lendacky {
646bab748deSTom Lendacky 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
647bab748deSTom Lendacky 	unsigned int rx, tx;
648bab748deSTom Lendacky 
649bab748deSTom Lendacky 	if (ringparam->rx_mini_pending || ringparam->rx_jumbo_pending) {
650bab748deSTom Lendacky 		netdev_err(netdev, "unsupported ring parameter\n");
651bab748deSTom Lendacky 		return -EINVAL;
652bab748deSTom Lendacky 	}
653bab748deSTom Lendacky 
654bab748deSTom Lendacky 	if ((ringparam->rx_pending < XGBE_RX_DESC_CNT_MIN) ||
655bab748deSTom Lendacky 	    (ringparam->rx_pending > XGBE_RX_DESC_CNT_MAX)) {
656bab748deSTom Lendacky 		netdev_err(netdev,
657bab748deSTom Lendacky 			   "rx ring parameter must be between %u and %u\n",
658bab748deSTom Lendacky 			   XGBE_RX_DESC_CNT_MIN, XGBE_RX_DESC_CNT_MAX);
659bab748deSTom Lendacky 		return -EINVAL;
660bab748deSTom Lendacky 	}
661bab748deSTom Lendacky 
662bab748deSTom Lendacky 	if ((ringparam->tx_pending < XGBE_TX_DESC_CNT_MIN) ||
663bab748deSTom Lendacky 	    (ringparam->tx_pending > XGBE_TX_DESC_CNT_MAX)) {
664bab748deSTom Lendacky 		netdev_err(netdev,
665bab748deSTom Lendacky 			   "tx ring parameter must be between %u and %u\n",
666bab748deSTom Lendacky 			   XGBE_TX_DESC_CNT_MIN, XGBE_TX_DESC_CNT_MAX);
667bab748deSTom Lendacky 		return -EINVAL;
668bab748deSTom Lendacky 	}
669bab748deSTom Lendacky 
670bab748deSTom Lendacky 	rx = __rounddown_pow_of_two(ringparam->rx_pending);
671bab748deSTom Lendacky 	if (rx != ringparam->rx_pending)
672bab748deSTom Lendacky 		netdev_notice(netdev,
673bab748deSTom Lendacky 			      "rx ring parameter rounded to power of two: %u\n",
674bab748deSTom Lendacky 			      rx);
675bab748deSTom Lendacky 
676bab748deSTom Lendacky 	tx = __rounddown_pow_of_two(ringparam->tx_pending);
677bab748deSTom Lendacky 	if (tx != ringparam->tx_pending)
678bab748deSTom Lendacky 		netdev_notice(netdev,
679bab748deSTom Lendacky 			      "tx ring parameter rounded to power of two: %u\n",
680bab748deSTom Lendacky 			      tx);
681bab748deSTom Lendacky 
682bab748deSTom Lendacky 	if ((rx == pdata->rx_desc_count) &&
683bab748deSTom Lendacky 	    (tx == pdata->tx_desc_count))
684bab748deSTom Lendacky 		goto out;
685bab748deSTom Lendacky 
686bab748deSTom Lendacky 	pdata->rx_desc_count = rx;
687bab748deSTom Lendacky 	pdata->tx_desc_count = tx;
688bab748deSTom Lendacky 
689bab748deSTom Lendacky 	xgbe_restart_dev(pdata);
690bab748deSTom Lendacky 
691bab748deSTom Lendacky out:
692bab748deSTom Lendacky 	return 0;
693bab748deSTom Lendacky }
694bab748deSTom Lendacky 
xgbe_get_channels(struct net_device * netdev,struct ethtool_channels * channels)69501b5277fSTom Lendacky static void xgbe_get_channels(struct net_device *netdev,
69601b5277fSTom Lendacky 			      struct ethtool_channels *channels)
69701b5277fSTom Lendacky {
69801b5277fSTom Lendacky 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
69901b5277fSTom Lendacky 	unsigned int rx, tx, combined;
70001b5277fSTom Lendacky 
70101b5277fSTom Lendacky 	/* Calculate maximums allowed:
70201b5277fSTom Lendacky 	 *   - Take into account the number of available IRQs
70301b5277fSTom Lendacky 	 *   - Do not take into account the number of online CPUs so that
70401b5277fSTom Lendacky 	 *     the user can over-subscribe if desired
70501b5277fSTom Lendacky 	 *   - Tx is additionally limited by the number of hardware queues
70601b5277fSTom Lendacky 	 */
70701b5277fSTom Lendacky 	rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count);
70801b5277fSTom Lendacky 	rx = min(rx, pdata->channel_irq_count);
70901b5277fSTom Lendacky 	tx = min(pdata->hw_feat.tx_ch_cnt, pdata->tx_max_channel_count);
71001b5277fSTom Lendacky 	tx = min(tx, pdata->channel_irq_count);
71101b5277fSTom Lendacky 	tx = min(tx, pdata->tx_max_q_count);
71201b5277fSTom Lendacky 
71301b5277fSTom Lendacky 	combined = min(rx, tx);
71401b5277fSTom Lendacky 
71501b5277fSTom Lendacky 	channels->max_combined = combined;
71601b5277fSTom Lendacky 	channels->max_rx = rx ? rx - 1 : 0;
71701b5277fSTom Lendacky 	channels->max_tx = tx ? tx - 1 : 0;
71801b5277fSTom Lendacky 
71901b5277fSTom Lendacky 	/* Get current settings based on device state */
72001b5277fSTom Lendacky 	rx = pdata->new_rx_ring_count ? : pdata->rx_ring_count;
72101b5277fSTom Lendacky 	tx = pdata->new_tx_ring_count ? : pdata->tx_ring_count;
72201b5277fSTom Lendacky 
72301b5277fSTom Lendacky 	combined = min(rx, tx);
72401b5277fSTom Lendacky 	rx -= combined;
72501b5277fSTom Lendacky 	tx -= combined;
72601b5277fSTom Lendacky 
72701b5277fSTom Lendacky 	channels->combined_count = combined;
72801b5277fSTom Lendacky 	channels->rx_count = rx;
72901b5277fSTom Lendacky 	channels->tx_count = tx;
73001b5277fSTom Lendacky }
73101b5277fSTom Lendacky 
xgbe_print_set_channels_input(struct net_device * netdev,struct ethtool_channels * channels)73201b5277fSTom Lendacky static void xgbe_print_set_channels_input(struct net_device *netdev,
73301b5277fSTom Lendacky 					  struct ethtool_channels *channels)
73401b5277fSTom Lendacky {
73501b5277fSTom Lendacky 	netdev_err(netdev, "channel inputs: combined=%u, rx-only=%u, tx-only=%u\n",
73601b5277fSTom Lendacky 		   channels->combined_count, channels->rx_count,
73701b5277fSTom Lendacky 		   channels->tx_count);
73801b5277fSTom Lendacky }
73901b5277fSTom Lendacky 
xgbe_set_channels(struct net_device * netdev,struct ethtool_channels * channels)74001b5277fSTom Lendacky static int xgbe_set_channels(struct net_device *netdev,
74101b5277fSTom Lendacky 			     struct ethtool_channels *channels)
74201b5277fSTom Lendacky {
74301b5277fSTom Lendacky 	struct xgbe_prv_data *pdata = netdev_priv(netdev);
74401b5277fSTom Lendacky 	unsigned int rx, rx_curr, tx, tx_curr, combined;
74501b5277fSTom Lendacky 
74601b5277fSTom Lendacky 	/* Calculate maximums allowed:
74701b5277fSTom Lendacky 	 *   - Take into account the number of available IRQs
74801b5277fSTom Lendacky 	 *   - Do not take into account the number of online CPUs so that
74901b5277fSTom Lendacky 	 *     the user can over-subscribe if desired
75001b5277fSTom Lendacky 	 *   - Tx is additionally limited by the number of hardware queues
75101b5277fSTom Lendacky 	 */
75201b5277fSTom Lendacky 	rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count);
75301b5277fSTom Lendacky 	rx = min(rx, pdata->channel_irq_count);
75401b5277fSTom Lendacky 	tx = min(pdata->hw_feat.tx_ch_cnt, pdata->tx_max_channel_count);
75501b5277fSTom Lendacky 	tx = min(tx, pdata->tx_max_q_count);
75601b5277fSTom Lendacky 	tx = min(tx, pdata->channel_irq_count);
75701b5277fSTom Lendacky 
75801b5277fSTom Lendacky 	combined = min(rx, tx);
75901b5277fSTom Lendacky 
76001b5277fSTom Lendacky 	/* Should not be setting other count */
76101b5277fSTom Lendacky 	if (channels->other_count) {
76201b5277fSTom Lendacky 		netdev_err(netdev,
76301b5277fSTom Lendacky 			   "other channel count must be zero\n");
76401b5277fSTom Lendacky 		return -EINVAL;
76501b5277fSTom Lendacky 	}
76601b5277fSTom Lendacky 
76701b5277fSTom Lendacky 	/* Require at least one Combined (Rx and Tx) channel */
76801b5277fSTom Lendacky 	if (!channels->combined_count) {
76901b5277fSTom Lendacky 		netdev_err(netdev,
77001b5277fSTom Lendacky 			   "at least one combined Rx/Tx channel is required\n");
77101b5277fSTom Lendacky 		xgbe_print_set_channels_input(netdev, channels);
77201b5277fSTom Lendacky 		return -EINVAL;
77301b5277fSTom Lendacky 	}
77401b5277fSTom Lendacky 
77501b5277fSTom Lendacky 	/* Check combined channels */
77601b5277fSTom Lendacky 	if (channels->combined_count > combined) {
77701b5277fSTom Lendacky 		netdev_err(netdev,
77801b5277fSTom Lendacky 			   "combined channel count cannot exceed %u\n",
77901b5277fSTom Lendacky 			   combined);
78001b5277fSTom Lendacky 		xgbe_print_set_channels_input(netdev, channels);
78101b5277fSTom Lendacky 		return -EINVAL;
78201b5277fSTom Lendacky 	}
78301b5277fSTom Lendacky 
78401b5277fSTom Lendacky 	/* Can have some Rx-only or Tx-only channels, but not both */
78501b5277fSTom Lendacky 	if (channels->rx_count && channels->tx_count) {
78601b5277fSTom Lendacky 		netdev_err(netdev,
78701b5277fSTom Lendacky 			   "cannot specify both Rx-only and Tx-only channels\n");
78801b5277fSTom Lendacky 		xgbe_print_set_channels_input(netdev, channels);
78901b5277fSTom Lendacky 		return -EINVAL;
79001b5277fSTom Lendacky 	}
79101b5277fSTom Lendacky 
79201b5277fSTom Lendacky 	/* Check that we don't exceed the maximum number of channels */
79301b5277fSTom Lendacky 	if ((channels->combined_count + channels->rx_count) > rx) {
79401b5277fSTom Lendacky 		netdev_err(netdev,
79501b5277fSTom Lendacky 			   "total Rx channels (%u) requested exceeds maximum available (%u)\n",
79601b5277fSTom Lendacky 			   channels->combined_count + channels->rx_count, rx);
79701b5277fSTom Lendacky 		xgbe_print_set_channels_input(netdev, channels);
79801b5277fSTom Lendacky 		return -EINVAL;
79901b5277fSTom Lendacky 	}
80001b5277fSTom Lendacky 
80101b5277fSTom Lendacky 	if ((channels->combined_count + channels->tx_count) > tx) {
80201b5277fSTom Lendacky 		netdev_err(netdev,
80301b5277fSTom Lendacky 			   "total Tx channels (%u) requested exceeds maximum available (%u)\n",
80401b5277fSTom Lendacky 			   channels->combined_count + channels->tx_count, tx);
80501b5277fSTom Lendacky 		xgbe_print_set_channels_input(netdev, channels);
80601b5277fSTom Lendacky 		return -EINVAL;
80701b5277fSTom Lendacky 	}
80801b5277fSTom Lendacky 
80901b5277fSTom Lendacky 	rx = channels->combined_count + channels->rx_count;
81001b5277fSTom Lendacky 	tx = channels->combined_count + channels->tx_count;
81101b5277fSTom Lendacky 
81201b5277fSTom Lendacky 	rx_curr = pdata->new_rx_ring_count ? : pdata->rx_ring_count;
81301b5277fSTom Lendacky 	tx_curr = pdata->new_tx_ring_count ? : pdata->tx_ring_count;
81401b5277fSTom Lendacky 
81501b5277fSTom Lendacky 	if ((rx == rx_curr) && (tx == tx_curr))
81601b5277fSTom Lendacky 		goto out;
81701b5277fSTom Lendacky 
81801b5277fSTom Lendacky 	pdata->new_rx_ring_count = rx;
81901b5277fSTom Lendacky 	pdata->new_tx_ring_count = tx;
82001b5277fSTom Lendacky 
82101b5277fSTom Lendacky 	xgbe_full_restart_dev(pdata);
82201b5277fSTom Lendacky 
82301b5277fSTom Lendacky out:
82401b5277fSTom Lendacky 	return 0;
82501b5277fSTom Lendacky }
82601b5277fSTom Lendacky 
827c5aa9e3bSLendacky, Thomas static const struct ethtool_ops xgbe_ethtool_ops = {
8284a1ce010SJakub Kicinski 	.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS |
8294a1ce010SJakub Kicinski 				     ETHTOOL_COALESCE_MAX_FRAMES,
830c5aa9e3bSLendacky, Thomas 	.get_drvinfo = xgbe_get_drvinfo,
831349fb2d7SLendacky, Thomas 	.get_msglevel = xgbe_get_msglevel,
832349fb2d7SLendacky, Thomas 	.set_msglevel = xgbe_set_msglevel,
833c5aa9e3bSLendacky, Thomas 	.get_link = ethtool_op_get_link,
834c5aa9e3bSLendacky, Thomas 	.get_coalesce = xgbe_get_coalesce,
835c5aa9e3bSLendacky, Thomas 	.set_coalesce = xgbe_set_coalesce,
836c5aa9e3bSLendacky, Thomas 	.get_pauseparam = xgbe_get_pauseparam,
837c5aa9e3bSLendacky, Thomas 	.set_pauseparam = xgbe_set_pauseparam,
838c5aa9e3bSLendacky, Thomas 	.get_strings = xgbe_get_strings,
839c5aa9e3bSLendacky, Thomas 	.get_ethtool_stats = xgbe_get_ethtool_stats,
840c5aa9e3bSLendacky, Thomas 	.get_sset_count = xgbe_get_sset_count,
841f6ac8628SLendacky, Thomas 	.get_rxnfc = xgbe_get_rxnfc,
842f6ac8628SLendacky, Thomas 	.get_rxfh_key_size = xgbe_get_rxfh_key_size,
843f6ac8628SLendacky, Thomas 	.get_rxfh_indir_size = xgbe_get_rxfh_indir_size,
844f6ac8628SLendacky, Thomas 	.get_rxfh = xgbe_get_rxfh,
845f6ac8628SLendacky, Thomas 	.set_rxfh = xgbe_set_rxfh,
84623e4eef7SLendacky, Thomas 	.get_ts_info = xgbe_get_ts_info,
84790fdd04eSPhilippe Reynes 	.get_link_ksettings = xgbe_get_link_ksettings,
84890fdd04eSPhilippe Reynes 	.set_link_ksettings = xgbe_set_link_ksettings,
84953a1024aSTom Lendacky 	.get_module_info = xgbe_get_module_info,
85053a1024aSTom Lendacky 	.get_module_eeprom = xgbe_get_module_eeprom,
851bab748deSTom Lendacky 	.get_ringparam = xgbe_get_ringparam,
852bab748deSTom Lendacky 	.set_ringparam = xgbe_set_ringparam,
85301b5277fSTom Lendacky 	.get_channels = xgbe_get_channels,
85401b5277fSTom Lendacky 	.set_channels = xgbe_set_channels,
855c5aa9e3bSLendacky, Thomas };
856c5aa9e3bSLendacky, Thomas 
xgbe_get_ethtool_ops(void)857ce0b15d1Sstephen hemminger const struct ethtool_ops *xgbe_get_ethtool_ops(void)
858c5aa9e3bSLendacky, Thomas {
859ce0b15d1Sstephen hemminger 	return &xgbe_ethtool_ops;
860c5aa9e3bSLendacky, Thomas }
861