blob: 3f385ffe420f712abbda79b14c46e2b6196d8dc8 [file] [log] [blame]
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
Catherine Sullivane8278452015-02-06 08:52:08 +00004 * Copyright(c) 2013 - 2015 Intel Corporation.
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00005 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
Greg Rosedc641b72013-12-18 13:45:51 +000015 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000017 *
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
21 * Contact Information:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 ******************************************************************************/
26
27/* ethtool support for i40e */
28
29#include "i40e.h"
30#include "i40e_diag.h"
31
32struct i40e_stats {
33 char stat_string[ETH_GSTRING_LEN];
34 int sizeof_stat;
35 int stat_offset;
36};
37
38#define I40E_STAT(_type, _name, _stat) { \
39 .stat_string = _name, \
40 .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
41 .stat_offset = offsetof(_type, _stat) \
42}
Shannon Nelsonfad177d2014-11-11 20:07:27 +000043
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000044#define I40E_NETDEV_STAT(_net_stat) \
Shannon Nelsonfad177d2014-11-11 20:07:27 +000045 I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000046#define I40E_PF_STAT(_name, _stat) \
47 I40E_STAT(struct i40e_pf, _name, _stat)
48#define I40E_VSI_STAT(_name, _stat) \
49 I40E_STAT(struct i40e_vsi, _name, _stat)
Shannon Nelson8eab9cf2014-04-23 04:49:55 +000050#define I40E_VEB_STAT(_name, _stat) \
51 I40E_STAT(struct i40e_veb, _name, _stat)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000052
53static const struct i40e_stats i40e_gstrings_net_stats[] = {
54 I40E_NETDEV_STAT(rx_packets),
55 I40E_NETDEV_STAT(tx_packets),
56 I40E_NETDEV_STAT(rx_bytes),
57 I40E_NETDEV_STAT(tx_bytes),
58 I40E_NETDEV_STAT(rx_errors),
59 I40E_NETDEV_STAT(tx_errors),
60 I40E_NETDEV_STAT(rx_dropped),
61 I40E_NETDEV_STAT(tx_dropped),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000062 I40E_NETDEV_STAT(collisions),
63 I40E_NETDEV_STAT(rx_length_errors),
64 I40E_NETDEV_STAT(rx_crc_errors),
65};
66
Shannon Nelson8eab9cf2014-04-23 04:49:55 +000067static const struct i40e_stats i40e_gstrings_veb_stats[] = {
68 I40E_VEB_STAT("rx_bytes", stats.rx_bytes),
69 I40E_VEB_STAT("tx_bytes", stats.tx_bytes),
70 I40E_VEB_STAT("rx_unicast", stats.rx_unicast),
71 I40E_VEB_STAT("tx_unicast", stats.tx_unicast),
72 I40E_VEB_STAT("rx_multicast", stats.rx_multicast),
73 I40E_VEB_STAT("tx_multicast", stats.tx_multicast),
74 I40E_VEB_STAT("rx_broadcast", stats.rx_broadcast),
75 I40E_VEB_STAT("tx_broadcast", stats.tx_broadcast),
76 I40E_VEB_STAT("rx_discards", stats.rx_discards),
77 I40E_VEB_STAT("tx_discards", stats.tx_discards),
78 I40E_VEB_STAT("tx_errors", stats.tx_errors),
79 I40E_VEB_STAT("rx_unknown_protocol", stats.rx_unknown_protocol),
80};
81
Shannon Nelson41a9e552014-04-23 04:50:20 +000082static const struct i40e_stats i40e_gstrings_misc_stats[] = {
Shannon Nelson418631d2014-04-23 04:50:07 +000083 I40E_VSI_STAT("rx_unicast", eth_stats.rx_unicast),
84 I40E_VSI_STAT("tx_unicast", eth_stats.tx_unicast),
85 I40E_VSI_STAT("rx_multicast", eth_stats.rx_multicast),
86 I40E_VSI_STAT("tx_multicast", eth_stats.tx_multicast),
Shannon Nelson41a9e552014-04-23 04:50:20 +000087 I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
88 I40E_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast),
Shannon Nelson418631d2014-04-23 04:50:07 +000089 I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
Anjali Singhai Jain2fc3d712015-08-27 11:42:29 -040090 I40E_VSI_STAT("tx_linearize", tx_linearize),
Shannon Nelson41a9e552014-04-23 04:50:20 +000091};
92
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000093/* These PF_STATs might look like duplicates of some NETDEV_STATs,
94 * but they are separate. This device supports Virtualization, and
95 * as such might have several netdevs supporting VMDq and FCoE going
96 * through a single port. The NETDEV_STATs are for individual netdevs
97 * seen at the top of the stack, and the PF_STATs are for the physical
98 * function at the bottom of the stack hosting those netdevs.
99 *
100 * The PF_STATs are appended to the netdev stats only when ethtool -S
101 * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
102 */
103static struct i40e_stats i40e_gstrings_stats[] = {
104 I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
105 I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
Shannon Nelson532d2832014-04-23 04:50:09 +0000106 I40E_PF_STAT("rx_unicast", stats.eth.rx_unicast),
107 I40E_PF_STAT("tx_unicast", stats.eth.tx_unicast),
108 I40E_PF_STAT("rx_multicast", stats.eth.rx_multicast),
109 I40E_PF_STAT("tx_multicast", stats.eth.tx_multicast),
110 I40E_PF_STAT("rx_broadcast", stats.eth.rx_broadcast),
111 I40E_PF_STAT("tx_broadcast", stats.eth.tx_broadcast),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000112 I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
113 I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000114 I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down),
Shannon Nelson9f7c9442015-07-10 19:35:57 -0400115 I40E_PF_STAT("rx_crc_errors", stats.crc_errors),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000116 I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
117 I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
118 I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
Jesse Brandeburga47a15f2014-02-06 05:51:09 +0000119 I40E_PF_STAT("tx_timeout", tx_timeout_count),
Jesse Brandeburg8a3c91c2014-05-20 08:01:43 +0000120 I40E_PF_STAT("rx_csum_bad", hw_csum_rx_error),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000121 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
122 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
123 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
124 I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
125 I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
126 I40E_PF_STAT("rx_size_64", stats.rx_size_64),
127 I40E_PF_STAT("rx_size_127", stats.rx_size_127),
128 I40E_PF_STAT("rx_size_255", stats.rx_size_255),
129 I40E_PF_STAT("rx_size_511", stats.rx_size_511),
130 I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
131 I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
132 I40E_PF_STAT("rx_size_big", stats.rx_size_big),
133 I40E_PF_STAT("tx_size_64", stats.tx_size_64),
134 I40E_PF_STAT("tx_size_127", stats.tx_size_127),
135 I40E_PF_STAT("tx_size_255", stats.tx_size_255),
136 I40E_PF_STAT("tx_size_511", stats.tx_size_511),
137 I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
138 I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
139 I40E_PF_STAT("tx_size_big", stats.tx_size_big),
140 I40E_PF_STAT("rx_undersize", stats.rx_undersize),
141 I40E_PF_STAT("rx_fragments", stats.rx_fragments),
142 I40E_PF_STAT("rx_oversize", stats.rx_oversize),
143 I40E_PF_STAT("rx_jabber", stats.rx_jabber),
144 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
Jacob Kellerbeb0dff2014-01-11 05:43:19 +0000145 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
Anjali Singhai Jain60793f4a2014-07-09 07:46:23 +0000146 I40E_PF_STAT("fdir_flush_cnt", fd_flush_cnt),
Anjali Singhai Jain433c47d2014-05-22 06:32:17 +0000147 I40E_PF_STAT("fdir_atr_match", stats.fd_atr_match),
Anjali Singhai Jain60ccd452015-04-16 20:06:01 -0400148 I40E_PF_STAT("fdir_atr_tunnel_match", stats.fd_atr_tunnel_match),
Anjali Singhai Jaind0389e52015-04-22 19:34:05 -0400149 I40E_PF_STAT("fdir_atr_status", stats.fd_atr_status),
Anjali Singhai Jain433c47d2014-05-22 06:32:17 +0000150 I40E_PF_STAT("fdir_sb_match", stats.fd_sb_match),
Anjali Singhai Jaind0389e52015-04-22 19:34:05 -0400151 I40E_PF_STAT("fdir_sb_status", stats.fd_sb_status),
Anjali Singhai Jain433c47d2014-05-22 06:32:17 +0000152
Anjali Singhai Jainbee5af72014-03-06 08:59:50 +0000153 /* LPI stats */
154 I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
155 I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
156 I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
157 I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000158};
159
Vasu Dev38e00432014-08-01 13:27:03 -0700160#ifdef I40E_FCOE
161static const struct i40e_stats i40e_gstrings_fcoe_stats[] = {
162 I40E_VSI_STAT("fcoe_bad_fccrc", fcoe_stats.fcoe_bad_fccrc),
163 I40E_VSI_STAT("rx_fcoe_dropped", fcoe_stats.rx_fcoe_dropped),
164 I40E_VSI_STAT("rx_fcoe_packets", fcoe_stats.rx_fcoe_packets),
165 I40E_VSI_STAT("rx_fcoe_dwords", fcoe_stats.rx_fcoe_dwords),
166 I40E_VSI_STAT("fcoe_ddp_count", fcoe_stats.fcoe_ddp_count),
167 I40E_VSI_STAT("fcoe_last_error", fcoe_stats.fcoe_last_error),
168 I40E_VSI_STAT("tx_fcoe_packets", fcoe_stats.tx_fcoe_packets),
169 I40E_VSI_STAT("tx_fcoe_dwords", fcoe_stats.tx_fcoe_dwords),
170};
171
172#endif /* I40E_FCOE */
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000173#define I40E_QUEUE_STATS_LEN(n) \
Shannon Nelson31cd8402014-04-04 04:43:12 +0000174 (((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs \
175 * 2 /* Tx and Rx together */ \
176 * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000177#define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
178#define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
Shannon Nelson41a9e552014-04-23 04:50:20 +0000179#define I40E_MISC_STATS_LEN ARRAY_SIZE(i40e_gstrings_misc_stats)
Vasu Dev38e00432014-08-01 13:27:03 -0700180#ifdef I40E_FCOE
181#define I40E_FCOE_STATS_LEN ARRAY_SIZE(i40e_gstrings_fcoe_stats)
182#define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
183 I40E_FCOE_STATS_LEN + \
184 I40E_MISC_STATS_LEN + \
185 I40E_QUEUE_STATS_LEN((n)))
186#else
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000187#define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
Shannon Nelson41a9e552014-04-23 04:50:20 +0000188 I40E_MISC_STATS_LEN + \
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000189 I40E_QUEUE_STATS_LEN((n)))
Vasu Dev38e00432014-08-01 13:27:03 -0700190#endif /* I40E_FCOE */
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000191#define I40E_PFC_STATS_LEN ( \
192 (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
193 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
194 FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
195 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
196 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
197 / sizeof(u64))
Neerav Parikhfe860af2015-07-10 19:36:02 -0400198#define I40E_VEB_TC_STATS_LEN ( \
199 (FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_rx_packets) + \
200 FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_rx_bytes) + \
201 FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_tx_packets) + \
202 FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_tx_bytes)) \
203 / sizeof(u64))
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000204#define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats)
Neerav Parikhfe860af2015-07-10 19:36:02 -0400205#define I40E_VEB_STATS_TOTAL (I40E_VEB_STATS_LEN + I40E_VEB_TC_STATS_LEN)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000206#define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
207 I40E_PFC_STATS_LEN + \
208 I40E_VSI_STATS_LEN((n)))
209
210enum i40e_ethtool_test_id {
211 I40E_ETH_TEST_REG = 0,
212 I40E_ETH_TEST_EEPROM,
213 I40E_ETH_TEST_INTR,
214 I40E_ETH_TEST_LOOPBACK,
215 I40E_ETH_TEST_LINK,
216};
217
218static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
219 "Register test (offline)",
220 "Eeprom test (offline)",
221 "Interrupt test (offline)",
222 "Loopback test (offline)",
223 "Link test (on/offline)"
224};
225
226#define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
227
Greg Rose7e45ab42015-02-06 08:52:19 +0000228static const char i40e_priv_flags_strings[][ETH_GSTRING_LEN] = {
229 "NPAR",
Shannon Nelson9ac77262015-08-27 11:42:40 -0400230 "LinkPolling",
Jesse Brandeburgef171782015-09-03 17:18:49 -0400231 "flow-director-atr",
Shannon Nelson1cdfd882015-09-28 14:12:34 -0400232 "veb-stats",
Greg Rose7e45ab42015-02-06 08:52:19 +0000233};
234
Shannon Nelson9ac77262015-08-27 11:42:40 -0400235#define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_priv_flags_strings)
Greg Rose7e45ab42015-02-06 08:52:19 +0000236
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000237/**
Shannon Nelsonf0d8c732014-12-11 07:06:32 +0000238 * i40e_partition_setting_complaint - generic complaint for MFP restriction
239 * @pf: the PF struct
240 **/
241static void i40e_partition_setting_complaint(struct i40e_pf *pf)
242{
243 dev_info(&pf->pdev->dev,
244 "The link settings are allowed to be changed only from the first partition of a given port. Please switch to the first partition in order to change the setting.\n");
245}
246
247/**
Catherine Sullivane8278452015-02-06 08:52:08 +0000248 * i40e_get_settings_link_up - Get the Link settings for when link is up
249 * @hw: hw structure
250 * @ecmd: ethtool command to fill in
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000251 * @netdev: network interface device structure
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000252 *
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000253 **/
Catherine Sullivane8278452015-02-06 08:52:08 +0000254static void i40e_get_settings_link_up(struct i40e_hw *hw,
255 struct ethtool_cmd *ecmd,
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400256 struct net_device *netdev,
257 struct i40e_pf *pf)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000258{
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000259 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000260 u32 link_speed = hw_link_info->link_speed;
261
Catherine Sullivane8278452015-02-06 08:52:08 +0000262 /* Initialize supported and advertised settings based on phy settings */
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000263 switch (hw_link_info->phy_type) {
264 case I40E_PHY_TYPE_40GBASE_CR4:
265 case I40E_PHY_TYPE_40GBASE_CR4_CU:
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000266 ecmd->supported = SUPPORTED_Autoneg |
267 SUPPORTED_40000baseCR4_Full;
268 ecmd->advertising = ADVERTISED_Autoneg |
269 ADVERTISED_40000baseCR4_Full;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000270 break;
Catherine Sullivane8278452015-02-06 08:52:08 +0000271 case I40E_PHY_TYPE_XLAUI:
272 case I40E_PHY_TYPE_XLPPI:
Catherine Sullivan180204c2015-02-26 16:14:58 +0000273 case I40E_PHY_TYPE_40GBASE_AOC:
Catherine Sullivane8278452015-02-06 08:52:08 +0000274 ecmd->supported = SUPPORTED_40000baseCR4_Full;
275 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000276 case I40E_PHY_TYPE_40GBASE_SR4:
277 ecmd->supported = SUPPORTED_40000baseSR4_Full;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000278 break;
279 case I40E_PHY_TYPE_40GBASE_LR4:
280 ecmd->supported = SUPPORTED_40000baseLR4_Full;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000281 break;
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000282 case I40E_PHY_TYPE_10GBASE_SR:
283 case I40E_PHY_TYPE_10GBASE_LR:
Catherine Sullivan124ed152014-07-12 07:28:12 +0000284 case I40E_PHY_TYPE_1000BASE_SX:
285 case I40E_PHY_TYPE_1000BASE_LX:
Catherine Sullivan0a862b42015-08-31 19:54:53 -0400286 ecmd->supported = SUPPORTED_10000baseT_Full;
287 if (hw_link_info->module_type[2] &
288 I40E_MODULE_TYPE_1000BASE_SX ||
289 hw_link_info->module_type[2] &
290 I40E_MODULE_TYPE_1000BASE_LX) {
291 ecmd->supported |= SUPPORTED_1000baseT_Full;
292 if (hw_link_info->requested_speeds &
293 I40E_LINK_SPEED_1GB)
294 ecmd->advertising |= ADVERTISED_1000baseT_Full;
295 }
Catherine Sullivane8278452015-02-06 08:52:08 +0000296 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
297 ecmd->advertising |= ADVERTISED_10000baseT_Full;
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000298 break;
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000299 case I40E_PHY_TYPE_10GBASE_T:
Catherine Sullivane8278452015-02-06 08:52:08 +0000300 case I40E_PHY_TYPE_1000BASE_T:
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000301 ecmd->supported = SUPPORTED_Autoneg |
Mitch Williams5960d332014-09-13 07:40:47 +0000302 SUPPORTED_10000baseT_Full |
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400303 SUPPORTED_1000baseT_Full;
Catherine Sullivane8278452015-02-06 08:52:08 +0000304 ecmd->advertising = ADVERTISED_Autoneg;
305 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
306 ecmd->advertising |= ADVERTISED_10000baseT_Full;
307 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
308 ecmd->advertising |= ADVERTISED_1000baseT_Full;
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400309 break;
Catherine Sullivan48becae2015-09-28 14:12:41 -0400310 case I40E_PHY_TYPE_1000BASE_T_OPTICAL:
311 ecmd->supported = SUPPORTED_Autoneg |
312 SUPPORTED_1000baseT_Full;
313 ecmd->advertising = ADVERTISED_Autoneg |
314 ADVERTISED_1000baseT_Full;
315 break;
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400316 case I40E_PHY_TYPE_100BASE_TX:
317 ecmd->supported = SUPPORTED_Autoneg |
318 SUPPORTED_100baseT_Full;
Catherine Sullivane8278452015-02-06 08:52:08 +0000319 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
320 ecmd->advertising |= ADVERTISED_100baseT_Full;
321 break;
322 case I40E_PHY_TYPE_10GBASE_CR1_CU:
323 case I40E_PHY_TYPE_10GBASE_CR1:
324 ecmd->supported = SUPPORTED_Autoneg |
325 SUPPORTED_10000baseT_Full;
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000326 ecmd->advertising = ADVERTISED_Autoneg |
Catherine Sullivane8278452015-02-06 08:52:08 +0000327 ADVERTISED_10000baseT_Full;
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000328 break;
329 case I40E_PHY_TYPE_XAUI:
330 case I40E_PHY_TYPE_XFI:
331 case I40E_PHY_TYPE_SFI:
332 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
Catherine Sullivan180204c2015-02-26 16:14:58 +0000333 case I40E_PHY_TYPE_10GBASE_AOC:
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000334 ecmd->supported = SUPPORTED_10000baseT_Full;
335 break;
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000336 case I40E_PHY_TYPE_SGMII:
337 ecmd->supported = SUPPORTED_Autoneg |
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400338 SUPPORTED_1000baseT_Full;
Catherine Sullivane8278452015-02-06 08:52:08 +0000339 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
340 ecmd->advertising |= ADVERTISED_1000baseT_Full;
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400341 if (pf->hw.mac.type == I40E_MAC_X722) {
342 ecmd->supported |= SUPPORTED_100baseT_Full;
343 if (hw_link_info->requested_speeds &
344 I40E_LINK_SPEED_100MB)
345 ecmd->advertising |= ADVERTISED_100baseT_Full;
346 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000347 break;
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400348 /* Backplane is set based on supported phy types in get_settings
349 * so don't set anything here but don't warn either
350 */
351 case I40E_PHY_TYPE_40GBASE_KR4:
352 case I40E_PHY_TYPE_20GBASE_KR2:
353 case I40E_PHY_TYPE_10GBASE_KR:
354 case I40E_PHY_TYPE_10GBASE_KX4:
355 case I40E_PHY_TYPE_1000BASE_KX:
356 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000357 default:
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000358 /* if we got here and link is up something bad is afoot */
Catherine Sullivan124ed152014-07-12 07:28:12 +0000359 netdev_info(netdev, "WARNING: Link is up but PHY type 0x%x is not recognized.\n",
360 hw_link_info->phy_type);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000361 }
362
Catherine Sullivane8278452015-02-06 08:52:08 +0000363 /* Set speed and duplex */
364 switch (link_speed) {
365 case I40E_LINK_SPEED_40GB:
Greg Roseedf5cff2015-04-07 19:45:41 -0400366 ethtool_cmd_speed_set(ecmd, SPEED_40000);
Catherine Sullivane8278452015-02-06 08:52:08 +0000367 break;
Jesse Brandeburgae24b402015-03-27 00:12:09 -0700368 case I40E_LINK_SPEED_20GB:
369 ethtool_cmd_speed_set(ecmd, SPEED_20000);
370 break;
Catherine Sullivane8278452015-02-06 08:52:08 +0000371 case I40E_LINK_SPEED_10GB:
372 ethtool_cmd_speed_set(ecmd, SPEED_10000);
373 break;
374 case I40E_LINK_SPEED_1GB:
375 ethtool_cmd_speed_set(ecmd, SPEED_1000);
376 break;
377 case I40E_LINK_SPEED_100MB:
378 ethtool_cmd_speed_set(ecmd, SPEED_100);
379 break;
380 default:
381 break;
382 }
383 ecmd->duplex = DUPLEX_FULL;
384}
385
386/**
387 * i40e_get_settings_link_down - Get the Link settings for when link is down
388 * @hw: hw structure
389 * @ecmd: ethtool command to fill in
390 *
391 * Reports link settings that can be determined when link is down
392 **/
393static void i40e_get_settings_link_down(struct i40e_hw *hw,
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400394 struct ethtool_cmd *ecmd,
395 struct i40e_pf *pf)
Catherine Sullivane8278452015-02-06 08:52:08 +0000396{
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400397 enum i40e_aq_capabilities_phy_type phy_types = hw->phy.phy_types;
Catherine Sullivane8278452015-02-06 08:52:08 +0000398
399 /* link is down and the driver needs to fall back on
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400400 * supported phy types to figure out what info to display
Catherine Sullivane8278452015-02-06 08:52:08 +0000401 */
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400402 ecmd->supported = 0x0;
403 ecmd->advertising = 0x0;
404 if (phy_types & I40E_CAP_PHY_TYPE_SGMII) {
405 ecmd->supported |= SUPPORTED_Autoneg |
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400406 SUPPORTED_1000baseT_Full;
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400407 ecmd->advertising |= ADVERTISED_Autoneg |
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400408 ADVERTISED_1000baseT_Full;
409 if (pf->hw.mac.type == I40E_MAC_X722) {
410 ecmd->supported |= SUPPORTED_100baseT_Full;
411 ecmd->advertising |= ADVERTISED_100baseT_Full;
412 }
Catherine Sullivane8278452015-02-06 08:52:08 +0000413 }
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400414 if (phy_types & I40E_CAP_PHY_TYPE_XAUI ||
415 phy_types & I40E_CAP_PHY_TYPE_XFI ||
416 phy_types & I40E_CAP_PHY_TYPE_SFI ||
417 phy_types & I40E_CAP_PHY_TYPE_10GBASE_SFPP_CU ||
418 phy_types & I40E_CAP_PHY_TYPE_10GBASE_AOC)
419 ecmd->supported |= SUPPORTED_10000baseT_Full;
420 if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_CR1_CU ||
421 phy_types & I40E_CAP_PHY_TYPE_10GBASE_CR1 ||
422 phy_types & I40E_CAP_PHY_TYPE_10GBASE_T ||
423 phy_types & I40E_CAP_PHY_TYPE_10GBASE_SR ||
424 phy_types & I40E_CAP_PHY_TYPE_10GBASE_LR) {
425 ecmd->supported |= SUPPORTED_Autoneg |
426 SUPPORTED_10000baseT_Full;
427 ecmd->advertising |= ADVERTISED_Autoneg |
428 ADVERTISED_10000baseT_Full;
429 }
430 if (phy_types & I40E_CAP_PHY_TYPE_XLAUI ||
431 phy_types & I40E_CAP_PHY_TYPE_XLPPI ||
432 phy_types & I40E_CAP_PHY_TYPE_40GBASE_AOC)
433 ecmd->supported |= SUPPORTED_40000baseCR4_Full;
434 if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_CR4_CU ||
435 phy_types & I40E_CAP_PHY_TYPE_40GBASE_CR4) {
436 ecmd->supported |= SUPPORTED_Autoneg |
437 SUPPORTED_40000baseCR4_Full;
438 ecmd->advertising |= ADVERTISED_Autoneg |
439 ADVERTISED_40000baseCR4_Full;
440 }
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400441 if ((phy_types & I40E_CAP_PHY_TYPE_100BASE_TX) &&
442 !(phy_types & I40E_CAP_PHY_TYPE_1000BASE_T)) {
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400443 ecmd->supported |= SUPPORTED_Autoneg |
444 SUPPORTED_100baseT_Full;
445 ecmd->advertising |= ADVERTISED_Autoneg |
446 ADVERTISED_100baseT_Full;
447 }
448 if (phy_types & I40E_CAP_PHY_TYPE_1000BASE_T ||
449 phy_types & I40E_CAP_PHY_TYPE_1000BASE_SX ||
450 phy_types & I40E_CAP_PHY_TYPE_1000BASE_LX ||
451 phy_types & I40E_CAP_PHY_TYPE_1000BASE_T_OPTICAL) {
452 ecmd->supported |= SUPPORTED_Autoneg |
453 SUPPORTED_1000baseT_Full;
454 ecmd->advertising |= ADVERTISED_Autoneg |
455 ADVERTISED_1000baseT_Full;
456 }
457 if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_SR4)
458 ecmd->supported |= SUPPORTED_40000baseSR4_Full;
459 if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_LR4)
460 ecmd->supported |= SUPPORTED_40000baseLR4_Full;
Catherine Sullivane8278452015-02-06 08:52:08 +0000461
462 /* With no link speed and duplex are unknown */
463 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
464 ecmd->duplex = DUPLEX_UNKNOWN;
465}
466
467/**
468 * i40e_get_settings - Get Link Speed and Duplex settings
469 * @netdev: network interface device structure
470 * @ecmd: ethtool command
471 *
472 * Reports speed/duplex settings based on media_type
473 **/
474static int i40e_get_settings(struct net_device *netdev,
475 struct ethtool_cmd *ecmd)
476{
477 struct i40e_netdev_priv *np = netdev_priv(netdev);
478 struct i40e_pf *pf = np->vsi->back;
479 struct i40e_hw *hw = &pf->hw;
480 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
481 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
482
483 if (link_up)
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400484 i40e_get_settings_link_up(hw, ecmd, netdev, pf);
Catherine Sullivane8278452015-02-06 08:52:08 +0000485 else
Catherine Sullivan3b6c2172015-09-03 17:18:52 -0400486 i40e_get_settings_link_down(hw, ecmd, pf);
Catherine Sullivane8278452015-02-06 08:52:08 +0000487
488 /* Now set the settings that don't rely on link being up/down */
489
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400490 /* For backplane, supported and advertised are only reliant on the
491 * phy types the NVM specifies are supported.
492 */
493 if (hw->device_id == I40E_DEV_ID_KX_B ||
494 hw->device_id == I40E_DEV_ID_KX_C ||
495 hw->device_id == I40E_DEV_ID_20G_KR2 ||
496 hw->device_id == I40E_DEV_ID_20G_KR2_A) {
497 ecmd->supported = SUPPORTED_Autoneg;
498 ecmd->advertising = ADVERTISED_Autoneg;
499 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_40GBASE_KR4) {
500 ecmd->supported |= SUPPORTED_40000baseKR4_Full;
501 ecmd->advertising |= ADVERTISED_40000baseKR4_Full;
502 }
503 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_20GBASE_KR2) {
504 ecmd->supported |= SUPPORTED_20000baseKR2_Full;
505 ecmd->advertising |= ADVERTISED_20000baseKR2_Full;
506 }
507 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_10GBASE_KR) {
508 ecmd->supported |= SUPPORTED_10000baseKR_Full;
509 ecmd->advertising |= ADVERTISED_10000baseKR_Full;
510 }
511 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_10GBASE_KX4) {
512 ecmd->supported |= SUPPORTED_10000baseKX4_Full;
513 ecmd->advertising |= ADVERTISED_10000baseKX4_Full;
514 }
515 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_1000BASE_KX) {
516 ecmd->supported |= SUPPORTED_1000baseKX_Full;
517 ecmd->advertising |= ADVERTISED_1000baseKX_Full;
518 }
519 }
520
Catherine Sullivane8278452015-02-06 08:52:08 +0000521 /* Set autoneg settings */
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000522 ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
523 AUTONEG_ENABLE : AUTONEG_DISABLE);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000524
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000525 switch (hw->phy.media_type) {
526 case I40E_MEDIA_TYPE_BACKPLANE:
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000527 ecmd->supported |= SUPPORTED_Autoneg |
528 SUPPORTED_Backplane;
529 ecmd->advertising |= ADVERTISED_Autoneg |
530 ADVERTISED_Backplane;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000531 ecmd->port = PORT_NONE;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000532 break;
533 case I40E_MEDIA_TYPE_BASET:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000534 ecmd->supported |= SUPPORTED_TP;
535 ecmd->advertising |= ADVERTISED_TP;
536 ecmd->port = PORT_TP;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000537 break;
538 case I40E_MEDIA_TYPE_DA:
539 case I40E_MEDIA_TYPE_CX4:
Jesse Brandeburgbe405eb2013-11-20 10:02:50 +0000540 ecmd->supported |= SUPPORTED_FIBRE;
541 ecmd->advertising |= ADVERTISED_FIBRE;
542 ecmd->port = PORT_DA;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000543 break;
544 case I40E_MEDIA_TYPE_FIBER:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000545 ecmd->supported |= SUPPORTED_FIBRE;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000546 ecmd->port = PORT_FIBRE;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000547 break;
548 case I40E_MEDIA_TYPE_UNKNOWN:
549 default:
550 ecmd->port = PORT_OTHER;
551 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000552 }
553
Catherine Sullivane8278452015-02-06 08:52:08 +0000554 /* Set transceiver */
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000555 ecmd->transceiver = XCVR_EXTERNAL;
556
Catherine Sullivane8278452015-02-06 08:52:08 +0000557 /* Set flow control settings */
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000558 ecmd->supported |= SUPPORTED_Pause;
559
Catherine Sullivane8278452015-02-06 08:52:08 +0000560 switch (hw->fc.requested_mode) {
Jesse Brandeburg4e91bcd2014-06-04 08:45:23 +0000561 case I40E_FC_FULL:
562 ecmd->advertising |= ADVERTISED_Pause;
563 break;
564 case I40E_FC_TX_PAUSE:
565 ecmd->advertising |= ADVERTISED_Asym_Pause;
566 break;
567 case I40E_FC_RX_PAUSE:
568 ecmd->advertising |= (ADVERTISED_Pause |
569 ADVERTISED_Asym_Pause);
570 break;
571 default:
572 ecmd->advertising &= ~(ADVERTISED_Pause |
573 ADVERTISED_Asym_Pause);
574 break;
575 }
576
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000577 return 0;
578}
579
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000580/**
581 * i40e_set_settings - Set Speed and Duplex
582 * @netdev: network interface device structure
583 * @ecmd: ethtool command
584 *
585 * Set speed/duplex per media_types advertised/forced
586 **/
587static int i40e_set_settings(struct net_device *netdev,
588 struct ethtool_cmd *ecmd)
589{
590 struct i40e_netdev_priv *np = netdev_priv(netdev);
591 struct i40e_aq_get_phy_abilities_resp abilities;
592 struct i40e_aq_set_phy_config config;
593 struct i40e_pf *pf = np->vsi->back;
594 struct i40e_vsi *vsi = np->vsi;
595 struct i40e_hw *hw = &pf->hw;
596 struct ethtool_cmd safe_ecmd;
597 i40e_status status = 0;
598 bool change = false;
599 int err = 0;
600 u8 autoneg;
601 u32 advertise;
602
Shannon Nelsonf0d8c732014-12-11 07:06:32 +0000603 /* Changing port settings is not supported if this isn't the
604 * port's controlling PF
605 */
606 if (hw->partition_id != 1) {
607 i40e_partition_setting_complaint(pf);
608 return -EOPNOTSUPP;
609 }
610
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000611 if (vsi != pf->vsi[pf->lan_vsi])
612 return -EOPNOTSUPP;
613
614 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
615 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
Catherine Sullivanc57e9f12014-07-12 07:28:13 +0000616 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE &&
617 hw->phy.link_info.link_info & I40E_AQ_LINK_UP)
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000618 return -EOPNOTSUPP;
619
Catherine Sullivanfc72dbc2015-09-01 11:36:30 -0400620 if (hw->device_id == I40E_DEV_ID_KX_B ||
621 hw->device_id == I40E_DEV_ID_KX_C ||
622 hw->device_id == I40E_DEV_ID_20G_KR2 ||
623 hw->device_id == I40E_DEV_ID_20G_KR2_A) {
624 netdev_info(netdev, "Changing settings is not supported on backplane.\n");
625 return -EOPNOTSUPP;
626 }
627
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000628 /* get our own copy of the bits to check against */
629 memset(&safe_ecmd, 0, sizeof(struct ethtool_cmd));
630 i40e_get_settings(netdev, &safe_ecmd);
631
632 /* save autoneg and speed out of ecmd */
633 autoneg = ecmd->autoneg;
634 advertise = ecmd->advertising;
635
636 /* set autoneg and speed back to what they currently are */
637 ecmd->autoneg = safe_ecmd.autoneg;
638 ecmd->advertising = safe_ecmd.advertising;
639
640 ecmd->cmd = safe_ecmd.cmd;
641 /* If ecmd and safe_ecmd are not the same now, then they are
642 * trying to set something that we do not support
643 */
644 if (memcmp(ecmd, &safe_ecmd, sizeof(struct ethtool_cmd)))
645 return -EOPNOTSUPP;
646
647 while (test_bit(__I40E_CONFIG_BUSY, &vsi->state))
648 usleep_range(1000, 2000);
649
650 /* Get the current phy config */
651 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
652 NULL);
653 if (status)
654 return -EAGAIN;
655
Catherine Sullivan124ed152014-07-12 07:28:12 +0000656 /* Copy abilities to config in case autoneg is not
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000657 * set below
658 */
659 memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000660 config.abilities = abilities.abilities;
661
662 /* Check autoneg */
663 if (autoneg == AUTONEG_ENABLE) {
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000664 /* If autoneg was not already enabled */
665 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) {
Catherine Sullivan3ce12ee2015-09-28 14:16:58 -0400666 /* If autoneg is not supported, return error */
667 if (!(safe_ecmd.supported & SUPPORTED_Autoneg)) {
668 netdev_info(netdev, "Autoneg not supported on this phy\n");
669 return -EINVAL;
670 }
671 /* Autoneg is allowed to change */
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000672 config.abilities = abilities.abilities |
673 I40E_AQ_PHY_ENABLE_AN;
674 change = true;
675 }
676 } else {
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000677 /* If autoneg is currently enabled */
678 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) {
Catherine Sullivan3ce12ee2015-09-28 14:16:58 -0400679 /* If autoneg is supported 10GBASE_T is the only PHY
680 * that can disable it, so otherwise return error
681 */
682 if (safe_ecmd.supported & SUPPORTED_Autoneg &&
683 hw->phy.link_info.phy_type !=
684 I40E_PHY_TYPE_10GBASE_T) {
685 netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
686 return -EINVAL;
687 }
688 /* Autoneg is allowed to change */
Mitch Williams5960d332014-09-13 07:40:47 +0000689 config.abilities = abilities.abilities &
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000690 ~I40E_AQ_PHY_ENABLE_AN;
691 change = true;
692 }
693 }
694
695 if (advertise & ~safe_ecmd.supported)
696 return -EINVAL;
697
698 if (advertise & ADVERTISED_100baseT_Full)
Catherine Sullivan124ed152014-07-12 07:28:12 +0000699 config.link_speed |= I40E_LINK_SPEED_100MB;
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000700 if (advertise & ADVERTISED_1000baseT_Full ||
701 advertise & ADVERTISED_1000baseKX_Full)
Catherine Sullivan124ed152014-07-12 07:28:12 +0000702 config.link_speed |= I40E_LINK_SPEED_1GB;
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000703 if (advertise & ADVERTISED_10000baseT_Full ||
704 advertise & ADVERTISED_10000baseKX4_Full ||
705 advertise & ADVERTISED_10000baseKR_Full)
Catherine Sullivan124ed152014-07-12 07:28:12 +0000706 config.link_speed |= I40E_LINK_SPEED_10GB;
Jesse Brandeburgae24b402015-03-27 00:12:09 -0700707 if (advertise & ADVERTISED_20000baseKR2_Full)
708 config.link_speed |= I40E_LINK_SPEED_20GB;
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000709 if (advertise & ADVERTISED_40000baseKR4_Full ||
710 advertise & ADVERTISED_40000baseCR4_Full ||
711 advertise & ADVERTISED_40000baseSR4_Full ||
712 advertise & ADVERTISED_40000baseLR4_Full)
Catherine Sullivan124ed152014-07-12 07:28:12 +0000713 config.link_speed |= I40E_LINK_SPEED_40GB;
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000714
Catherine Sullivan0002e112015-08-26 15:14:16 -0400715 /* If speed didn't get set, set it to what it currently is.
716 * This is needed because if advertise is 0 (as it is when autoneg
717 * is disabled) then speed won't get set.
718 */
719 if (!config.link_speed)
720 config.link_speed = abilities.link_speed;
721
Catherine Sullivan124ed152014-07-12 07:28:12 +0000722 if (change || (abilities.link_speed != config.link_speed)) {
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000723 /* copy over the rest of the abilities */
724 config.phy_type = abilities.phy_type;
725 config.eee_capability = abilities.eee_capability;
726 config.eeer = abilities.eeer_val;
727 config.low_power_ctrl = abilities.d3_lpan;
728
Catherine Sullivane8278452015-02-06 08:52:08 +0000729 /* save the requested speeds */
730 hw->phy.link_info.requested_speeds = config.link_speed;
Catherine Sullivan94128512014-07-12 07:28:16 +0000731 /* set link and auto negotiation so changes take effect */
732 config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
733 /* If link is up put link down */
734 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) {
735 /* Tell the OS link is going down, the link will go
736 * back up when fw says it is ready asynchronously
737 */
Matt Jaredc156f852015-08-27 11:42:39 -0400738 i40e_print_link_message(vsi, false);
Catherine Sullivan94128512014-07-12 07:28:16 +0000739 netif_carrier_off(netdev);
740 netif_tx_stop_all_queues(netdev);
741 }
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000742
743 /* make the aq call */
744 status = i40e_aq_set_phy_config(hw, &config, NULL);
745 if (status) {
Shannon Nelsonf1c7e722015-06-04 16:24:01 -0400746 netdev_info(netdev, "Set phy config failed, err %s aq_err %s\n",
747 i40e_stat_str(hw, status),
748 i40e_aq_str(hw, hw->aq.asq_last_status));
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000749 return -EAGAIN;
750 }
751
Catherine Sullivan0a862b42015-08-31 19:54:53 -0400752 status = i40e_update_link_info(hw);
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000753 if (status)
Catherine Sullivan52e96892015-09-28 14:16:59 -0400754 netdev_dbg(netdev, "Updating link info failed with err %s aq_err %s\n",
755 i40e_stat_str(hw, status),
756 i40e_aq_str(hw, hw->aq.asq_last_status));
Catherine Sullivanbf9c7142014-06-04 08:45:28 +0000757
758 } else {
759 netdev_info(netdev, "Nothing changed, exiting without setting anything.\n");
760 }
761
762 return err;
763}
764
Jesse Brandeburga6599722014-06-04 08:45:25 +0000765static int i40e_nway_reset(struct net_device *netdev)
766{
767 /* restart autonegotiation */
768 struct i40e_netdev_priv *np = netdev_priv(netdev);
769 struct i40e_pf *pf = np->vsi->back;
770 struct i40e_hw *hw = &pf->hw;
771 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
772 i40e_status ret = 0;
773
774 ret = i40e_aq_set_link_restart_an(hw, link_up, NULL);
775 if (ret) {
Shannon Nelsonf1c7e722015-06-04 16:24:01 -0400776 netdev_info(netdev, "link restart failed, err %s aq_err %s\n",
777 i40e_stat_str(hw, ret),
778 i40e_aq_str(hw, hw->aq.asq_last_status));
Jesse Brandeburga6599722014-06-04 08:45:25 +0000779 return -EIO;
780 }
781
782 return 0;
783}
784
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000785/**
786 * i40e_get_pauseparam - Get Flow Control status
787 * Return tx/rx-pause status
788 **/
789static void i40e_get_pauseparam(struct net_device *netdev,
790 struct ethtool_pauseparam *pause)
791{
792 struct i40e_netdev_priv *np = netdev_priv(netdev);
793 struct i40e_pf *pf = np->vsi->back;
794 struct i40e_hw *hw = &pf->hw;
795 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
Neerav Parikh4b7698c2014-11-12 00:18:57 +0000796 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000797
798 pause->autoneg =
799 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
800 AUTONEG_ENABLE : AUTONEG_DISABLE);
801
Neerav Parikh4b7698c2014-11-12 00:18:57 +0000802 /* PFC enabled so report LFC as off */
803 if (dcbx_cfg->pfc.pfcenable) {
804 pause->rx_pause = 0;
805 pause->tx_pause = 0;
806 return;
807 }
808
Jesse Brandeburgd52c20b2013-11-26 10:49:15 +0000809 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000810 pause->rx_pause = 1;
Jesse Brandeburgd52c20b2013-11-26 10:49:15 +0000811 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000812 pause->tx_pause = 1;
Jesse Brandeburgd52c20b2013-11-26 10:49:15 +0000813 } else if (hw->fc.current_mode == I40E_FC_FULL) {
814 pause->rx_pause = 1;
815 pause->tx_pause = 1;
816 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000817}
818
Catherine Sullivan2becc352014-06-04 08:45:27 +0000819/**
820 * i40e_set_pauseparam - Set Flow Control parameter
821 * @netdev: network interface device structure
822 * @pause: return tx/rx flow control status
823 **/
824static int i40e_set_pauseparam(struct net_device *netdev,
825 struct ethtool_pauseparam *pause)
826{
827 struct i40e_netdev_priv *np = netdev_priv(netdev);
828 struct i40e_pf *pf = np->vsi->back;
829 struct i40e_vsi *vsi = np->vsi;
830 struct i40e_hw *hw = &pf->hw;
831 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
Neerav Parikh4b7698c2014-11-12 00:18:57 +0000832 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
Catherine Sullivan2becc352014-06-04 08:45:27 +0000833 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
834 i40e_status status;
835 u8 aq_failures;
Catherine Sullivan7d62dac2014-07-09 07:46:18 +0000836 int err = 0;
Catherine Sullivan2becc352014-06-04 08:45:27 +0000837
Shannon Nelsonf0d8c732014-12-11 07:06:32 +0000838 /* Changing the port's flow control is not supported if this isn't the
839 * port's controlling PF
840 */
841 if (hw->partition_id != 1) {
842 i40e_partition_setting_complaint(pf);
843 return -EOPNOTSUPP;
844 }
845
Catherine Sullivan2becc352014-06-04 08:45:27 +0000846 if (vsi != pf->vsi[pf->lan_vsi])
847 return -EOPNOTSUPP;
848
849 if (pause->autoneg != ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
850 AUTONEG_ENABLE : AUTONEG_DISABLE)) {
851 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
852 return -EOPNOTSUPP;
853 }
854
855 /* If we have link and don't have autoneg */
856 if (!test_bit(__I40E_DOWN, &pf->state) &&
857 !(hw_link_info->an_info & I40E_AQ_AN_COMPLETED)) {
858 /* Send message that it might not necessarily work*/
859 netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n");
860 }
861
Neerav Parikh4b7698c2014-11-12 00:18:57 +0000862 if (dcbx_cfg->pfc.pfcenable) {
863 netdev_info(netdev,
864 "Priority flow control enabled. Cannot set link flow control.\n");
Catherine Sullivan2becc352014-06-04 08:45:27 +0000865 return -EOPNOTSUPP;
866 }
867
868 if (pause->rx_pause && pause->tx_pause)
869 hw->fc.requested_mode = I40E_FC_FULL;
870 else if (pause->rx_pause && !pause->tx_pause)
871 hw->fc.requested_mode = I40E_FC_RX_PAUSE;
872 else if (!pause->rx_pause && pause->tx_pause)
873 hw->fc.requested_mode = I40E_FC_TX_PAUSE;
874 else if (!pause->rx_pause && !pause->tx_pause)
875 hw->fc.requested_mode = I40E_FC_NONE;
876 else
877 return -EINVAL;
878
Catherine Sullivan94128512014-07-12 07:28:16 +0000879 /* Tell the OS link is going down, the link will go back up when fw
880 * says it is ready asynchronously
881 */
Matt Jaredc156f852015-08-27 11:42:39 -0400882 i40e_print_link_message(vsi, false);
Catherine Sullivan94128512014-07-12 07:28:16 +0000883 netif_carrier_off(netdev);
884 netif_tx_stop_all_queues(netdev);
885
Catherine Sullivan2becc352014-06-04 08:45:27 +0000886 /* Set the fc mode and only restart an if link is up*/
887 status = i40e_set_fc(hw, &aq_failures, link_up);
888
889 if (aq_failures & I40E_SET_FC_AQ_FAIL_GET) {
Shannon Nelsonf1c7e722015-06-04 16:24:01 -0400890 netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %s aq_err %s\n",
891 i40e_stat_str(hw, status),
892 i40e_aq_str(hw, hw->aq.asq_last_status));
Catherine Sullivan2becc352014-06-04 08:45:27 +0000893 err = -EAGAIN;
894 }
895 if (aq_failures & I40E_SET_FC_AQ_FAIL_SET) {
Shannon Nelsonf1c7e722015-06-04 16:24:01 -0400896 netdev_info(netdev, "Set fc failed on the set_phy_config call with err %s aq_err %s\n",
897 i40e_stat_str(hw, status),
898 i40e_aq_str(hw, hw->aq.asq_last_status));
Catherine Sullivan2becc352014-06-04 08:45:27 +0000899 err = -EAGAIN;
900 }
901 if (aq_failures & I40E_SET_FC_AQ_FAIL_UPDATE) {
Shannon Nelsonf1c7e722015-06-04 16:24:01 -0400902 netdev_info(netdev, "Set fc failed on the get_link_info call with err %s aq_err %s\n",
903 i40e_stat_str(hw, status),
904 i40e_aq_str(hw, hw->aq.asq_last_status));
Catherine Sullivan2becc352014-06-04 08:45:27 +0000905 err = -EAGAIN;
906 }
907
Catherine Sullivan7d62dac2014-07-09 07:46:18 +0000908 if (!test_bit(__I40E_DOWN, &pf->state)) {
909 /* Give it a little more time to try to come back */
910 msleep(75);
911 if (!test_bit(__I40E_DOWN, &pf->state))
912 return i40e_nway_reset(netdev);
913 }
Catherine Sullivan2becc352014-06-04 08:45:27 +0000914
915 return err;
916}
917
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000918static u32 i40e_get_msglevel(struct net_device *netdev)
919{
920 struct i40e_netdev_priv *np = netdev_priv(netdev);
921 struct i40e_pf *pf = np->vsi->back;
922
923 return pf->msg_enable;
924}
925
926static void i40e_set_msglevel(struct net_device *netdev, u32 data)
927{
928 struct i40e_netdev_priv *np = netdev_priv(netdev);
929 struct i40e_pf *pf = np->vsi->back;
930
931 if (I40E_DEBUG_USER & data)
932 pf->hw.debug_mask = data;
933 pf->msg_enable = data;
934}
935
936static int i40e_get_regs_len(struct net_device *netdev)
937{
938 int reg_count = 0;
939 int i;
940
941 for (i = 0; i40e_reg_list[i].offset != 0; i++)
942 reg_count += i40e_reg_list[i].elements;
943
944 return reg_count * sizeof(u32);
945}
946
947static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
948 void *p)
949{
950 struct i40e_netdev_priv *np = netdev_priv(netdev);
951 struct i40e_pf *pf = np->vsi->back;
952 struct i40e_hw *hw = &pf->hw;
953 u32 *reg_buf = p;
954 int i, j, ri;
955 u32 reg;
956
957 /* Tell ethtool which driver-version-specific regs output we have.
958 *
959 * At some point, if we have ethtool doing special formatting of
960 * this data, it will rely on this version number to know how to
961 * interpret things. Hence, this needs to be updated if/when the
962 * diags register table is changed.
963 */
964 regs->version = 1;
965
966 /* loop through the diags reg table for what to print */
967 ri = 0;
968 for (i = 0; i40e_reg_list[i].offset != 0; i++) {
969 for (j = 0; j < i40e_reg_list[i].elements; j++) {
970 reg = i40e_reg_list[i].offset
971 + (j * i40e_reg_list[i].stride);
972 reg_buf[ri++] = rd32(hw, reg);
973 }
974 }
975
976}
977
978static int i40e_get_eeprom(struct net_device *netdev,
979 struct ethtool_eeprom *eeprom, u8 *bytes)
980{
981 struct i40e_netdev_priv *np = netdev_priv(netdev);
982 struct i40e_hw *hw = &np->vsi->back->hw;
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000983 struct i40e_pf *pf = np->vsi->back;
Shannon Nelsonc150a502014-11-13 08:23:13 +0000984 int ret_val = 0, len, offset;
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000985 u8 *eeprom_buff;
986 u16 i, sectors;
987 bool last;
Shannon Nelsoncd552cb2014-07-09 07:46:09 +0000988 u32 magic;
989
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000990#define I40E_NVM_SECTOR_SIZE 4096
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000991 if (eeprom->len == 0)
992 return -EINVAL;
993
Shannon Nelsoncd552cb2014-07-09 07:46:09 +0000994 /* check for NVMUpdate access method */
995 magic = hw->vendor_id | (hw->device_id << 16);
996 if (eeprom->magic && eeprom->magic != magic) {
Shannon Nelsonc150a502014-11-13 08:23:13 +0000997 struct i40e_nvm_access *cmd;
Shannon Nelsoncd552cb2014-07-09 07:46:09 +0000998 int errno;
999
1000 /* make sure it is the right magic for NVMUpdate */
1001 if ((eeprom->magic >> 16) != hw->device_id)
1002 return -EINVAL;
1003
Shannon Nelsonc150a502014-11-13 08:23:13 +00001004 cmd = (struct i40e_nvm_access *)eeprom;
1005 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
Shannon Nelson3c5c4202015-09-28 14:12:32 -04001006 if (ret_val && (hw->debug_mask & I40E_DEBUG_NVM))
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001007 dev_info(&pf->pdev->dev,
Shannon Nelsonc150a502014-11-13 08:23:13 +00001008 "NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
1009 ret_val, hw->aq.asq_last_status, errno,
1010 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
1011 cmd->offset, cmd->data_size);
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001012
1013 return errno;
1014 }
1015
1016 /* normal ethtool get_eeprom support */
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001017 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
1018
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001019 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001020 if (!eeprom_buff)
1021 return -ENOMEM;
1022
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001023 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
1024 if (ret_val) {
1025 dev_info(&pf->pdev->dev,
1026 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1027 ret_val, hw->aq.asq_last_status);
1028 goto free_buff;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001029 }
1030
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001031 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE;
1032 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0;
1033 len = I40E_NVM_SECTOR_SIZE;
1034 last = false;
1035 for (i = 0; i < sectors; i++) {
1036 if (i == (sectors - 1)) {
1037 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
1038 last = true;
1039 }
Shannon Nelsonc150a502014-11-13 08:23:13 +00001040 offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
1041 ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len,
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001042 (u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001043 last, NULL);
Shannon Nelsonc150a502014-11-13 08:23:13 +00001044 if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001045 dev_info(&pf->pdev->dev,
Shannon Nelsonc150a502014-11-13 08:23:13 +00001046 "read NVM failed, invalid offset 0x%x\n",
1047 offset);
1048 break;
1049 } else if (ret_val &&
1050 hw->aq.asq_last_status == I40E_AQ_RC_EACCES) {
1051 dev_info(&pf->pdev->dev,
1052 "read NVM failed, access, offset 0x%x\n",
1053 offset);
1054 break;
1055 } else if (ret_val) {
1056 dev_info(&pf->pdev->dev,
1057 "read NVM failed offset %d err=%d status=0x%x\n",
1058 offset, ret_val, hw->aq.asq_last_status);
1059 break;
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001060 }
1061 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001062
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001063 i40e_release_nvm(hw);
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001064 memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001065free_buff:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001066 kfree(eeprom_buff);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001067 return ret_val;
1068}
1069
1070static int i40e_get_eeprom_len(struct net_device *netdev)
1071{
1072 struct i40e_netdev_priv *np = netdev_priv(netdev);
1073 struct i40e_hw *hw = &np->vsi->back->hw;
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001074 u32 val;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001075
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001076 val = (rd32(hw, I40E_GLPCI_LBARCTRL)
1077 & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK)
1078 >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
1079 /* register returns value in power of 2, 64Kbyte chunks. */
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001080 val = (64 * 1024) * BIT(val);
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +00001081 return val;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001082}
1083
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001084static int i40e_set_eeprom(struct net_device *netdev,
1085 struct ethtool_eeprom *eeprom, u8 *bytes)
1086{
1087 struct i40e_netdev_priv *np = netdev_priv(netdev);
1088 struct i40e_hw *hw = &np->vsi->back->hw;
1089 struct i40e_pf *pf = np->vsi->back;
Shannon Nelsonc150a502014-11-13 08:23:13 +00001090 struct i40e_nvm_access *cmd;
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001091 int ret_val = 0;
1092 int errno;
1093 u32 magic;
1094
1095 /* normal ethtool set_eeprom is not supported */
1096 magic = hw->vendor_id | (hw->device_id << 16);
1097 if (eeprom->magic == magic)
1098 return -EOPNOTSUPP;
1099
1100 /* check for NVMUpdate access method */
1101 if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id)
1102 return -EINVAL;
1103
1104 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
1105 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
1106 return -EBUSY;
1107
Shannon Nelsonc150a502014-11-13 08:23:13 +00001108 cmd = (struct i40e_nvm_access *)eeprom;
1109 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
Shannon Nelson3c5c4202015-09-28 14:12:32 -04001110 if (ret_val && (hw->debug_mask & I40E_DEBUG_NVM))
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001111 dev_info(&pf->pdev->dev,
Shannon Nelsonc150a502014-11-13 08:23:13 +00001112 "NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
1113 ret_val, hw->aq.asq_last_status, errno,
1114 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
1115 cmd->offset, cmd->data_size);
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00001116
1117 return errno;
1118}
1119
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001120static void i40e_get_drvinfo(struct net_device *netdev,
1121 struct ethtool_drvinfo *drvinfo)
1122{
1123 struct i40e_netdev_priv *np = netdev_priv(netdev);
1124 struct i40e_vsi *vsi = np->vsi;
1125 struct i40e_pf *pf = vsi->back;
1126
1127 strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
1128 strlcpy(drvinfo->version, i40e_driver_version_str,
1129 sizeof(drvinfo->version));
Shannon Nelson6dec1012015-09-28 14:12:30 -04001130 strlcpy(drvinfo->fw_version, i40e_nvm_version_str(&pf->hw),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001131 sizeof(drvinfo->fw_version));
1132 strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
1133 sizeof(drvinfo->bus_info));
1134}
1135
1136static void i40e_get_ringparam(struct net_device *netdev,
1137 struct ethtool_ringparam *ring)
1138{
1139 struct i40e_netdev_priv *np = netdev_priv(netdev);
1140 struct i40e_pf *pf = np->vsi->back;
1141 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
1142
1143 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
1144 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
1145 ring->rx_mini_max_pending = 0;
1146 ring->rx_jumbo_max_pending = 0;
Alexander Duyck9f65e152013-09-28 06:00:58 +00001147 ring->rx_pending = vsi->rx_rings[0]->count;
1148 ring->tx_pending = vsi->tx_rings[0]->count;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001149 ring->rx_mini_pending = 0;
1150 ring->rx_jumbo_pending = 0;
1151}
1152
1153static int i40e_set_ringparam(struct net_device *netdev,
1154 struct ethtool_ringparam *ring)
1155{
1156 struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
1157 struct i40e_netdev_priv *np = netdev_priv(netdev);
1158 struct i40e_vsi *vsi = np->vsi;
1159 struct i40e_pf *pf = vsi->back;
1160 u32 new_rx_count, new_tx_count;
1161 int i, err = 0;
1162
1163 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
1164 return -EINVAL;
1165
Shannon Nelson1fa18372013-11-20 10:03:08 +00001166 if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS ||
1167 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS ||
1168 ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
1169 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) {
1170 netdev_info(netdev,
1171 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
1172 ring->tx_pending, ring->rx_pending,
1173 I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS);
1174 return -EINVAL;
1175 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001176
Shannon Nelson1fa18372013-11-20 10:03:08 +00001177 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
1178 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001179
1180 /* if nothing to do return success */
Alexander Duyck9f65e152013-09-28 06:00:58 +00001181 if ((new_tx_count == vsi->tx_rings[0]->count) &&
1182 (new_rx_count == vsi->rx_rings[0]->count))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001183 return 0;
1184
1185 while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
1186 usleep_range(1000, 2000);
1187
1188 if (!netif_running(vsi->netdev)) {
1189 /* simple case - set for the next time the netdev is started */
1190 for (i = 0; i < vsi->num_queue_pairs; i++) {
Alexander Duyck9f65e152013-09-28 06:00:58 +00001191 vsi->tx_rings[i]->count = new_tx_count;
1192 vsi->rx_rings[i]->count = new_rx_count;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001193 }
1194 goto done;
1195 }
1196
1197 /* We can't just free everything and then setup again,
1198 * because the ISRs in MSI-X mode get passed pointers
1199 * to the Tx and Rx ring structs.
1200 */
1201
1202 /* alloc updated Tx resources */
Alexander Duyck9f65e152013-09-28 06:00:58 +00001203 if (new_tx_count != vsi->tx_rings[0]->count) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001204 netdev_info(netdev,
1205 "Changing Tx descriptor count from %d to %d.\n",
Alexander Duyck9f65e152013-09-28 06:00:58 +00001206 vsi->tx_rings[0]->count, new_tx_count);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001207 tx_rings = kcalloc(vsi->alloc_queue_pairs,
1208 sizeof(struct i40e_ring), GFP_KERNEL);
1209 if (!tx_rings) {
1210 err = -ENOMEM;
1211 goto done;
1212 }
1213
1214 for (i = 0; i < vsi->num_queue_pairs; i++) {
1215 /* clone ring and setup updated count */
Alexander Duyck9f65e152013-09-28 06:00:58 +00001216 tx_rings[i] = *vsi->tx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001217 tx_rings[i].count = new_tx_count;
Jesse Brandeburg1e8efb42015-08-27 11:42:33 -04001218 /* the desc and bi pointers will be reallocated in the
1219 * setup call
1220 */
1221 tx_rings[i].desc = NULL;
1222 tx_rings[i].rx_bi = NULL;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001223 err = i40e_setup_tx_descriptors(&tx_rings[i]);
1224 if (err) {
1225 while (i) {
1226 i--;
1227 i40e_free_tx_resources(&tx_rings[i]);
1228 }
1229 kfree(tx_rings);
1230 tx_rings = NULL;
1231
1232 goto done;
1233 }
1234 }
1235 }
1236
1237 /* alloc updated Rx resources */
Alexander Duyck9f65e152013-09-28 06:00:58 +00001238 if (new_rx_count != vsi->rx_rings[0]->count) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001239 netdev_info(netdev,
1240 "Changing Rx descriptor count from %d to %d\n",
Alexander Duyck9f65e152013-09-28 06:00:58 +00001241 vsi->rx_rings[0]->count, new_rx_count);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001242 rx_rings = kcalloc(vsi->alloc_queue_pairs,
1243 sizeof(struct i40e_ring), GFP_KERNEL);
1244 if (!rx_rings) {
1245 err = -ENOMEM;
1246 goto free_tx;
1247 }
1248
1249 for (i = 0; i < vsi->num_queue_pairs; i++) {
1250 /* clone ring and setup updated count */
Alexander Duyck9f65e152013-09-28 06:00:58 +00001251 rx_rings[i] = *vsi->rx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001252 rx_rings[i].count = new_rx_count;
Jesse Brandeburg1e8efb42015-08-27 11:42:33 -04001253 /* the desc and bi pointers will be reallocated in the
1254 * setup call
1255 */
1256 rx_rings[i].desc = NULL;
1257 rx_rings[i].rx_bi = NULL;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001258 err = i40e_setup_rx_descriptors(&rx_rings[i]);
1259 if (err) {
1260 while (i) {
1261 i--;
1262 i40e_free_rx_resources(&rx_rings[i]);
1263 }
1264 kfree(rx_rings);
1265 rx_rings = NULL;
1266
1267 goto free_tx;
1268 }
1269 }
1270 }
1271
1272 /* Bring interface down, copy in the new ring info,
1273 * then restore the interface
1274 */
1275 i40e_down(vsi);
1276
1277 if (tx_rings) {
1278 for (i = 0; i < vsi->num_queue_pairs; i++) {
Alexander Duyck9f65e152013-09-28 06:00:58 +00001279 i40e_free_tx_resources(vsi->tx_rings[i]);
1280 *vsi->tx_rings[i] = tx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001281 }
1282 kfree(tx_rings);
1283 tx_rings = NULL;
1284 }
1285
1286 if (rx_rings) {
1287 for (i = 0; i < vsi->num_queue_pairs; i++) {
Alexander Duyck9f65e152013-09-28 06:00:58 +00001288 i40e_free_rx_resources(vsi->rx_rings[i]);
1289 *vsi->rx_rings[i] = rx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001290 }
1291 kfree(rx_rings);
1292 rx_rings = NULL;
1293 }
1294
1295 i40e_up(vsi);
1296
1297free_tx:
1298 /* error cleanup if the Rx allocations failed after getting Tx */
1299 if (tx_rings) {
1300 for (i = 0; i < vsi->num_queue_pairs; i++)
1301 i40e_free_tx_resources(&tx_rings[i]);
1302 kfree(tx_rings);
1303 tx_rings = NULL;
1304 }
1305
1306done:
1307 clear_bit(__I40E_CONFIG_BUSY, &pf->state);
1308
1309 return err;
1310}
1311
1312static int i40e_get_sset_count(struct net_device *netdev, int sset)
1313{
1314 struct i40e_netdev_priv *np = netdev_priv(netdev);
1315 struct i40e_vsi *vsi = np->vsi;
1316 struct i40e_pf *pf = vsi->back;
1317
1318 switch (sset) {
1319 case ETH_SS_TEST:
1320 return I40E_TEST_LEN;
1321 case ETH_SS_STATS:
Shannon Nelson58ce5172015-02-27 09:15:26 +00001322 if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) {
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001323 int len = I40E_PF_STATS_LEN(netdev);
1324
Anjali Singhai Jaind1a8d272015-07-23 16:54:40 -04001325 if ((pf->lan_veb != I40E_NO_VEB) &&
1326 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED))
Neerav Parikhfe860af2015-07-10 19:36:02 -04001327 len += I40E_VEB_STATS_TOTAL;
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001328 return len;
1329 } else {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001330 return I40E_VSI_STATS_LEN(netdev);
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001331 }
Greg Rose7e45ab42015-02-06 08:52:19 +00001332 case ETH_SS_PRIV_FLAGS:
1333 return I40E_PRIV_FLAGS_STR_LEN;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001334 default:
1335 return -EOPNOTSUPP;
1336 }
1337}
1338
1339static void i40e_get_ethtool_stats(struct net_device *netdev,
1340 struct ethtool_stats *stats, u64 *data)
1341{
1342 struct i40e_netdev_priv *np = netdev_priv(netdev);
Akeem G Abodunrine7046ee2014-04-09 05:58:58 +00001343 struct i40e_ring *tx_ring, *rx_ring;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001344 struct i40e_vsi *vsi = np->vsi;
1345 struct i40e_pf *pf = vsi->back;
1346 int i = 0;
1347 char *p;
1348 int j;
1349 struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
Alexander Duyck980e9b12013-09-28 06:01:03 +00001350 unsigned int start;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001351
1352 i40e_update_stats(vsi);
1353
1354 for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
1355 p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
1356 data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
1357 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1358 }
Shannon Nelson41a9e552014-04-23 04:50:20 +00001359 for (j = 0; j < I40E_MISC_STATS_LEN; j++) {
1360 p = (char *)vsi + i40e_gstrings_misc_stats[j].stat_offset;
1361 data[i++] = (i40e_gstrings_misc_stats[j].sizeof_stat ==
1362 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1363 }
Vasu Dev38e00432014-08-01 13:27:03 -07001364#ifdef I40E_FCOE
1365 for (j = 0; j < I40E_FCOE_STATS_LEN; j++) {
1366 p = (char *)vsi + i40e_gstrings_fcoe_stats[j].stat_offset;
1367 data[i++] = (i40e_gstrings_fcoe_stats[j].sizeof_stat ==
1368 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1369 }
1370#endif
Alexander Duyck980e9b12013-09-28 06:01:03 +00001371 rcu_read_lock();
Catherine Sullivan99c472a2014-03-14 07:32:30 +00001372 for (j = 0; j < vsi->num_queue_pairs; j++) {
Akeem G Abodunrine7046ee2014-04-09 05:58:58 +00001373 tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
Alexander Duyck980e9b12013-09-28 06:01:03 +00001374
1375 if (!tx_ring)
1376 continue;
1377
1378 /* process Tx ring statistics */
1379 do {
Eric W. Biederman57a77442014-03-13 21:26:42 -07001380 start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
Alexander Duyck980e9b12013-09-28 06:01:03 +00001381 data[i] = tx_ring->stats.packets;
1382 data[i + 1] = tx_ring->stats.bytes;
Eric W. Biederman57a77442014-03-13 21:26:42 -07001383 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
Catherine Sullivan99c472a2014-03-14 07:32:30 +00001384 i += 2;
Alexander Duyck980e9b12013-09-28 06:01:03 +00001385
1386 /* Rx ring is the 2nd half of the queue pair */
1387 rx_ring = &tx_ring[1];
1388 do {
Eric W. Biederman57a77442014-03-13 21:26:42 -07001389 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
Catherine Sullivan99c472a2014-03-14 07:32:30 +00001390 data[i] = rx_ring->stats.packets;
1391 data[i + 1] = rx_ring->stats.bytes;
Eric W. Biederman57a77442014-03-13 21:26:42 -07001392 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
Catherine Sullivan99c472a2014-03-14 07:32:30 +00001393 i += 2;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001394 }
Alexander Duyck980e9b12013-09-28 06:01:03 +00001395 rcu_read_unlock();
Shannon Nelson58ce5172015-02-27 09:15:26 +00001396 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001397 return;
1398
Anjali Singhai Jaind1a8d272015-07-23 16:54:40 -04001399 if ((pf->lan_veb != I40E_NO_VEB) &&
1400 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001401 struct i40e_veb *veb = pf->veb[pf->lan_veb];
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001402
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001403 for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
1404 p = (char *)veb;
1405 p += i40e_gstrings_veb_stats[j].stat_offset;
1406 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
1407 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001408 }
Jesse Brandeburg74a6c662015-10-02 19:09:34 -07001409 for (j = 0; j < I40E_MAX_TRAFFIC_CLASS; j++) {
1410 data[i++] = veb->tc_stats.tc_tx_packets[j];
1411 data[i++] = veb->tc_stats.tc_tx_bytes[j];
1412 data[i++] = veb->tc_stats.tc_rx_packets[j];
1413 data[i++] = veb->tc_stats.tc_rx_bytes[j];
1414 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001415 }
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001416 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
1417 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
1418 data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
1419 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1420 }
1421 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
1422 data[i++] = pf->stats.priority_xon_tx[j];
1423 data[i++] = pf->stats.priority_xoff_tx[j];
1424 }
1425 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
1426 data[i++] = pf->stats.priority_xon_rx[j];
1427 data[i++] = pf->stats.priority_xoff_rx[j];
1428 }
1429 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
1430 data[i++] = pf->stats.priority_xon_2_xoff[j];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001431}
1432
1433static void i40e_get_strings(struct net_device *netdev, u32 stringset,
1434 u8 *data)
1435{
1436 struct i40e_netdev_priv *np = netdev_priv(netdev);
1437 struct i40e_vsi *vsi = np->vsi;
1438 struct i40e_pf *pf = vsi->back;
1439 char *p = (char *)data;
1440 int i;
1441
1442 switch (stringset) {
1443 case ETH_SS_TEST:
1444 for (i = 0; i < I40E_TEST_LEN; i++) {
1445 memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
1446 data += ETH_GSTRING_LEN;
1447 }
1448 break;
1449 case ETH_SS_STATS:
1450 for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
1451 snprintf(p, ETH_GSTRING_LEN, "%s",
1452 i40e_gstrings_net_stats[i].stat_string);
1453 p += ETH_GSTRING_LEN;
1454 }
Shannon Nelson41a9e552014-04-23 04:50:20 +00001455 for (i = 0; i < I40E_MISC_STATS_LEN; i++) {
1456 snprintf(p, ETH_GSTRING_LEN, "%s",
1457 i40e_gstrings_misc_stats[i].stat_string);
1458 p += ETH_GSTRING_LEN;
1459 }
Vasu Dev38e00432014-08-01 13:27:03 -07001460#ifdef I40E_FCOE
1461 for (i = 0; i < I40E_FCOE_STATS_LEN; i++) {
1462 snprintf(p, ETH_GSTRING_LEN, "%s",
1463 i40e_gstrings_fcoe_stats[i].stat_string);
1464 p += ETH_GSTRING_LEN;
1465 }
1466#endif
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001467 for (i = 0; i < vsi->num_queue_pairs; i++) {
1468 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
1469 p += ETH_GSTRING_LEN;
1470 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
1471 p += ETH_GSTRING_LEN;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001472 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
1473 p += ETH_GSTRING_LEN;
1474 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
1475 p += ETH_GSTRING_LEN;
1476 }
Shannon Nelson58ce5172015-02-27 09:15:26 +00001477 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001478 return;
1479
Anjali Singhai Jaind1a8d272015-07-23 16:54:40 -04001480 if ((pf->lan_veb != I40E_NO_VEB) &&
1481 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001482 for (i = 0; i < I40E_VEB_STATS_LEN; i++) {
1483 snprintf(p, ETH_GSTRING_LEN, "veb.%s",
1484 i40e_gstrings_veb_stats[i].stat_string);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001485 p += ETH_GSTRING_LEN;
1486 }
Neerav Parikhfe860af2015-07-10 19:36:02 -04001487 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1488 snprintf(p, ETH_GSTRING_LEN,
1489 "veb.tc_%u_tx_packets", i);
1490 p += ETH_GSTRING_LEN;
1491 snprintf(p, ETH_GSTRING_LEN,
1492 "veb.tc_%u_tx_bytes", i);
1493 p += ETH_GSTRING_LEN;
1494 snprintf(p, ETH_GSTRING_LEN,
1495 "veb.tc_%u_rx_packets", i);
1496 p += ETH_GSTRING_LEN;
1497 snprintf(p, ETH_GSTRING_LEN,
1498 "veb.tc_%u_rx_bytes", i);
1499 p += ETH_GSTRING_LEN;
1500 }
Shannon Nelson8eab9cf2014-04-23 04:49:55 +00001501 }
1502 for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
1503 snprintf(p, ETH_GSTRING_LEN, "port.%s",
1504 i40e_gstrings_stats[i].stat_string);
1505 p += ETH_GSTRING_LEN;
1506 }
1507 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1508 snprintf(p, ETH_GSTRING_LEN,
1509 "port.tx_priority_%u_xon", i);
1510 p += ETH_GSTRING_LEN;
1511 snprintf(p, ETH_GSTRING_LEN,
1512 "port.tx_priority_%u_xoff", i);
1513 p += ETH_GSTRING_LEN;
1514 }
1515 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1516 snprintf(p, ETH_GSTRING_LEN,
1517 "port.rx_priority_%u_xon", i);
1518 p += ETH_GSTRING_LEN;
1519 snprintf(p, ETH_GSTRING_LEN,
1520 "port.rx_priority_%u_xoff", i);
1521 p += ETH_GSTRING_LEN;
1522 }
1523 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1524 snprintf(p, ETH_GSTRING_LEN,
1525 "port.rx_priority_%u_xon_2_xoff", i);
1526 p += ETH_GSTRING_LEN;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001527 }
1528 /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
1529 break;
Greg Rose7e45ab42015-02-06 08:52:19 +00001530 case ETH_SS_PRIV_FLAGS:
1531 for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {
1532 memcpy(data, i40e_priv_flags_strings[i],
1533 ETH_GSTRING_LEN);
1534 data += ETH_GSTRING_LEN;
1535 }
1536 break;
Akeem G Abodunrin579b23d2015-02-24 06:58:42 +00001537 default:
1538 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001539 }
1540}
1541
1542static int i40e_get_ts_info(struct net_device *dev,
1543 struct ethtool_ts_info *info)
1544{
Jacob Kellerbeb0dff2014-01-11 05:43:19 +00001545 struct i40e_pf *pf = i40e_netdev_to_pf(dev);
1546
Jacob Kellerfe88bda2014-11-11 20:05:58 +00001547 /* only report HW timestamping if PTP is enabled */
1548 if (!(pf->flags & I40E_FLAG_PTP))
1549 return ethtool_op_get_ts_info(dev, info);
1550
Jacob Kellerbeb0dff2014-01-11 05:43:19 +00001551 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
1552 SOF_TIMESTAMPING_RX_SOFTWARE |
1553 SOF_TIMESTAMPING_SOFTWARE |
1554 SOF_TIMESTAMPING_TX_HARDWARE |
1555 SOF_TIMESTAMPING_RX_HARDWARE |
1556 SOF_TIMESTAMPING_RAW_HARDWARE;
1557
1558 if (pf->ptp_clock)
1559 info->phc_index = ptp_clock_index(pf->ptp_clock);
1560 else
1561 info->phc_index = -1;
1562
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001563 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
Jacob Kellerbeb0dff2014-01-11 05:43:19 +00001564
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001565 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
1566 BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
1567 BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
Jacob Kellerbeb0dff2014-01-11 05:43:19 +00001568
1569 return 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001570}
1571
Shannon Nelson7b086392013-11-20 10:02:59 +00001572static int i40e_link_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001573{
Shannon Nelson7b086392013-11-20 10:02:59 +00001574 struct i40e_netdev_priv *np = netdev_priv(netdev);
1575 struct i40e_pf *pf = np->vsi->back;
Jesse Brandeburga72a5abc2015-08-26 15:14:19 -04001576 i40e_status status;
1577 bool link_up = false;
Shannon Nelson7b086392013-11-20 10:02:59 +00001578
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001579 netif_info(pf, hw, netdev, "link test\n");
Jesse Brandeburga72a5abc2015-08-26 15:14:19 -04001580 status = i40e_get_link_status(&pf->hw, &link_up);
1581 if (status) {
1582 netif_err(pf, drv, netdev, "link query timed out, please retry test\n");
1583 *data = 1;
1584 return *data;
1585 }
1586
1587 if (link_up)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001588 *data = 0;
1589 else
1590 *data = 1;
1591
1592 return *data;
1593}
1594
Shannon Nelson7b086392013-11-20 10:02:59 +00001595static int i40e_reg_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001596{
Shannon Nelson7b086392013-11-20 10:02:59 +00001597 struct i40e_netdev_priv *np = netdev_priv(netdev);
1598 struct i40e_pf *pf = np->vsi->back;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001599
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001600 netif_info(pf, hw, netdev, "register test\n");
Shannon Nelson7b086392013-11-20 10:02:59 +00001601 *data = i40e_diag_reg_test(&pf->hw);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001602
Shannon Nelson7b086392013-11-20 10:02:59 +00001603 return *data;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001604}
1605
Shannon Nelson7b086392013-11-20 10:02:59 +00001606static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001607{
Shannon Nelson7b086392013-11-20 10:02:59 +00001608 struct i40e_netdev_priv *np = netdev_priv(netdev);
1609 struct i40e_pf *pf = np->vsi->back;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001610
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001611 netif_info(pf, hw, netdev, "eeprom test\n");
Shannon Nelson7b086392013-11-20 10:02:59 +00001612 *data = i40e_diag_eeprom_test(&pf->hw);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001613
Shannon Nelson4443ec92014-11-13 08:23:12 +00001614 /* forcebly clear the NVM Update state machine */
1615 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT;
1616
Shannon Nelson7b086392013-11-20 10:02:59 +00001617 return *data;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001618}
1619
Shannon Nelson7b086392013-11-20 10:02:59 +00001620static int i40e_intr_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001621{
Shannon Nelson7b086392013-11-20 10:02:59 +00001622 struct i40e_netdev_priv *np = netdev_priv(netdev);
1623 struct i40e_pf *pf = np->vsi->back;
Shannon Nelsoncd92e722013-11-16 10:00:44 +00001624 u16 swc_old = pf->sw_int_count;
1625
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001626 netif_info(pf, hw, netdev, "interrupt test\n");
Shannon Nelsoncd92e722013-11-16 10:00:44 +00001627 wr32(&pf->hw, I40E_PFINT_DYN_CTL0,
1628 (I40E_PFINT_DYN_CTL0_INTENA_MASK |
Shannon Nelson5d1ff1062014-11-11 20:04:35 +00001629 I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK |
1630 I40E_PFINT_DYN_CTL0_ITR_INDX_MASK |
1631 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_ENA_MASK |
1632 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_MASK));
Shannon Nelsoncd92e722013-11-16 10:00:44 +00001633 usleep_range(1000, 2000);
1634 *data = (swc_old == pf->sw_int_count);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001635
1636 return *data;
1637}
1638
Shannon Nelson7b086392013-11-20 10:02:59 +00001639static int i40e_loopback_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001640{
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001641 struct i40e_netdev_priv *np = netdev_priv(netdev);
1642 struct i40e_pf *pf = np->vsi->back;
1643
1644 netif_info(pf, hw, netdev, "loopback test not implemented\n");
Shannon Nelsoncd92e722013-11-16 10:00:44 +00001645 *data = 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001646
1647 return *data;
1648}
1649
Greg Rosee17bc412015-04-16 20:05:59 -04001650static inline bool i40e_active_vfs(struct i40e_pf *pf)
1651{
1652 struct i40e_vf *vfs = pf->vf;
1653 int i;
1654
1655 for (i = 0; i < pf->num_alloc_vfs; i++)
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001656 if (test_bit(I40E_VF_STAT_ACTIVE, &vfs[i].vf_states))
Greg Rosee17bc412015-04-16 20:05:59 -04001657 return true;
1658 return false;
1659}
1660
Greg Rose510efb22015-07-10 19:36:01 -04001661static inline bool i40e_active_vmdqs(struct i40e_pf *pf)
1662{
1663 struct i40e_vsi **vsi = pf->vsi;
1664 int i;
1665
1666 for (i = 0; i < pf->num_alloc_vsi; i++) {
1667 if (!vsi[i])
1668 continue;
1669 if (vsi[i]->type == I40E_VSI_VMDQ2)
1670 return true;
1671 }
1672
1673 return false;
1674}
1675
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001676static void i40e_diag_test(struct net_device *netdev,
1677 struct ethtool_test *eth_test, u64 *data)
1678{
1679 struct i40e_netdev_priv *np = netdev_priv(netdev);
Greg Rose5b86c5c2015-02-26 16:14:35 +00001680 bool if_running = netif_running(netdev);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001681 struct i40e_pf *pf = np->vsi->back;
1682
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001683 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1684 /* Offline tests */
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001685 netif_info(pf, drv, netdev, "offline testing starting\n");
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001686
Shannon Nelsonf551b432013-11-26 10:49:12 +00001687 set_bit(__I40E_TESTING, &pf->state);
Greg Rosee17bc412015-04-16 20:05:59 -04001688
Greg Rose510efb22015-07-10 19:36:01 -04001689 if (i40e_active_vfs(pf) || i40e_active_vmdqs(pf)) {
Greg Rosee17bc412015-04-16 20:05:59 -04001690 dev_warn(&pf->pdev->dev,
Greg Rose510efb22015-07-10 19:36:01 -04001691 "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n");
Greg Rosee17bc412015-04-16 20:05:59 -04001692 data[I40E_ETH_TEST_REG] = 1;
1693 data[I40E_ETH_TEST_EEPROM] = 1;
1694 data[I40E_ETH_TEST_INTR] = 1;
1695 data[I40E_ETH_TEST_LOOPBACK] = 1;
1696 data[I40E_ETH_TEST_LINK] = 1;
1697 eth_test->flags |= ETH_TEST_FL_FAILED;
1698 clear_bit(__I40E_TESTING, &pf->state);
1699 goto skip_ol_tests;
1700 }
1701
Greg Rose5b86c5c2015-02-26 16:14:35 +00001702 /* If the device is online then take it offline */
1703 if (if_running)
1704 /* indicate we're in test mode */
1705 dev_close(netdev);
1706 else
Greg Roseb4e53f02015-07-10 19:36:03 -04001707 /* This reset does not affect link - if it is
1708 * changed to a type of reset that does affect
1709 * link then the following link test would have
1710 * to be moved to before the reset
1711 */
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001712 i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));
Shannon Nelsonf551b432013-11-26 10:49:12 +00001713
Shannon Nelson7b086392013-11-20 10:02:59 +00001714 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001715 eth_test->flags |= ETH_TEST_FL_FAILED;
1716
Shannon Nelson7b086392013-11-20 10:02:59 +00001717 if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001718 eth_test->flags |= ETH_TEST_FL_FAILED;
1719
Shannon Nelson7b086392013-11-20 10:02:59 +00001720 if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001721 eth_test->flags |= ETH_TEST_FL_FAILED;
1722
Shannon Nelson7b086392013-11-20 10:02:59 +00001723 if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001724 eth_test->flags |= ETH_TEST_FL_FAILED;
1725
Shannon Nelsonf551b432013-11-26 10:49:12 +00001726 /* run reg test last, a reset is required after it */
1727 if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
1728 eth_test->flags |= ETH_TEST_FL_FAILED;
1729
1730 clear_bit(__I40E_TESTING, &pf->state);
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001731 i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));
Greg Rose5b86c5c2015-02-26 16:14:35 +00001732
1733 if (if_running)
1734 dev_open(netdev);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001735 } else {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001736 /* Online tests */
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001737 netif_info(pf, drv, netdev, "online testing starting\n");
1738
Shannon Nelson7b086392013-11-20 10:02:59 +00001739 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001740 eth_test->flags |= ETH_TEST_FL_FAILED;
1741
1742 /* Offline only tests, not run in online; pass by default */
1743 data[I40E_ETH_TEST_REG] = 0;
1744 data[I40E_ETH_TEST_EEPROM] = 0;
1745 data[I40E_ETH_TEST_INTR] = 0;
1746 data[I40E_ETH_TEST_LOOPBACK] = 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001747 }
Shannon Nelsonc140c172013-11-20 10:02:58 +00001748
Greg Rosee17bc412015-04-16 20:05:59 -04001749skip_ol_tests:
1750
Shannon Nelsonb03aaa92013-11-20 10:03:06 +00001751 netif_info(pf, drv, netdev, "testing finished\n");
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001752}
1753
1754static void i40e_get_wol(struct net_device *netdev,
1755 struct ethtool_wolinfo *wol)
1756{
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001757 struct i40e_netdev_priv *np = netdev_priv(netdev);
1758 struct i40e_pf *pf = np->vsi->back;
1759 struct i40e_hw *hw = &pf->hw;
1760 u16 wol_nvm_bits;
1761
1762 /* NVM bit on means WoL disabled for the port */
1763 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001764 if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) {
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001765 wol->supported = 0;
1766 wol->wolopts = 0;
1767 } else {
1768 wol->supported = WAKE_MAGIC;
1769 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0);
1770 }
1771}
1772
Shannon Nelsonf0d8c732014-12-11 07:06:32 +00001773/**
1774 * i40e_set_wol - set the WakeOnLAN configuration
1775 * @netdev: the netdev in question
1776 * @wol: the ethtool WoL setting data
1777 **/
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001778static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1779{
1780 struct i40e_netdev_priv *np = netdev_priv(netdev);
1781 struct i40e_pf *pf = np->vsi->back;
Shannon Nelsonf0d8c732014-12-11 07:06:32 +00001782 struct i40e_vsi *vsi = np->vsi;
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001783 struct i40e_hw *hw = &pf->hw;
1784 u16 wol_nvm_bits;
1785
Shannon Nelsonf0d8c732014-12-11 07:06:32 +00001786 /* WoL not supported if this isn't the controlling PF on the port */
1787 if (hw->partition_id != 1) {
1788 i40e_partition_setting_complaint(pf);
1789 return -EOPNOTSUPP;
1790 }
1791
1792 if (vsi != pf->vsi[pf->lan_vsi])
1793 return -EOPNOTSUPP;
1794
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001795 /* NVM bit on means WoL disabled for the port */
1796 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001797 if (BIT(hw->port) & wol_nvm_bits)
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001798 return -EOPNOTSUPP;
1799
1800 /* only magic packet is supported */
1801 if (wol->wolopts && (wol->wolopts != WAKE_MAGIC))
1802 return -EOPNOTSUPP;
1803
1804 /* is this a new value? */
1805 if (pf->wol_en != !!wol->wolopts) {
1806 pf->wol_en = !!wol->wolopts;
1807 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en);
1808 }
1809
1810 return 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001811}
1812
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001813static int i40e_set_phys_id(struct net_device *netdev,
1814 enum ethtool_phys_id_state state)
1815{
1816 struct i40e_netdev_priv *np = netdev_priv(netdev);
1817 struct i40e_pf *pf = np->vsi->back;
1818 struct i40e_hw *hw = &pf->hw;
1819 int blink_freq = 2;
1820
1821 switch (state) {
1822 case ETHTOOL_ID_ACTIVE:
1823 pf->led_status = i40e_led_get(hw);
1824 return blink_freq;
1825 case ETHTOOL_ID_ON:
Jesse Brandeburg0556a9e2013-11-28 06:39:33 +00001826 i40e_led_set(hw, 0xF, false);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001827 break;
1828 case ETHTOOL_ID_OFF:
Jesse Brandeburg0556a9e2013-11-28 06:39:33 +00001829 i40e_led_set(hw, 0x0, false);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001830 break;
1831 case ETHTOOL_ID_INACTIVE:
Jesse Brandeburg0556a9e2013-11-28 06:39:33 +00001832 i40e_led_set(hw, pf->led_status, false);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001833 break;
Akeem G Abodunrin579b23d2015-02-24 06:58:42 +00001834 default:
1835 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001836 }
1837
1838 return 0;
1839}
1840
1841/* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
1842 * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
1843 * 125us (8000 interrupts per second) == ITR(62)
1844 */
1845
1846static int i40e_get_coalesce(struct net_device *netdev,
1847 struct ethtool_coalesce *ec)
1848{
1849 struct i40e_netdev_priv *np = netdev_priv(netdev);
1850 struct i40e_vsi *vsi = np->vsi;
1851
1852 ec->tx_max_coalesced_frames_irq = vsi->work_limit;
1853 ec->rx_max_coalesced_frames_irq = vsi->work_limit;
1854
1855 if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
Mitch Williams32f5f542014-04-04 04:43:10 +00001856 ec->use_adaptive_rx_coalesce = 1;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001857
1858 if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
Mitch Williams32f5f542014-04-04 04:43:10 +00001859 ec->use_adaptive_tx_coalesce = 1;
1860
1861 ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC;
1862 ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC;
Jesse Brandeburgac26fc12015-09-28 14:12:37 -04001863 /* we use the _usecs_high to store/set the interrupt rate limit
1864 * that the hardware supports, that almost but not quite
1865 * fits the original intent of the ethtool variable,
1866 * the rx_coalesce_usecs_high limits total interrupts
1867 * per second from both tx/rx sources.
1868 */
1869 ec->rx_coalesce_usecs_high = vsi->int_rate_limit;
1870 ec->tx_coalesce_usecs_high = vsi->int_rate_limit;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001871
1872 return 0;
1873}
1874
1875static int i40e_set_coalesce(struct net_device *netdev,
1876 struct ethtool_coalesce *ec)
1877{
1878 struct i40e_netdev_priv *np = netdev_priv(netdev);
1879 struct i40e_q_vector *q_vector;
1880 struct i40e_vsi *vsi = np->vsi;
1881 struct i40e_pf *pf = vsi->back;
1882 struct i40e_hw *hw = &pf->hw;
1883 u16 vector;
1884 int i;
1885
1886 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
1887 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
1888
Jesse Brandeburgac26fc12015-09-28 14:12:37 -04001889 /* tx_coalesce_usecs_high is ignored, use rx-usecs-high instead */
1890 if (ec->tx_coalesce_usecs_high != vsi->int_rate_limit) {
1891 netif_info(pf, drv, netdev, "tx-usecs-high is not used, please program rx-usecs-high\n");
1892 return -EINVAL;
1893 }
1894
1895 if (ec->rx_coalesce_usecs_high >= INTRL_REG_TO_USEC(I40E_MAX_INTRL)) {
1896 netif_info(pf, drv, netdev, "Invalid value, rx-usecs-high range is 0-235\n");
1897 return -EINVAL;
1898 }
1899
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001900 vector = vsi->base_vector;
Mitch Williams32f5f542014-04-04 04:43:10 +00001901 if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001902 (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001903 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001904 } else if (ec->rx_coalesce_usecs == 0) {
1905 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001906 if (ec->use_adaptive_rx_coalesce)
Jesse Brandeburg79442d32014-10-25 03:24:32 +00001907 netif_info(pf, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001908 } else {
Jesse Brandeburg79442d32014-10-25 03:24:32 +00001909 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
Mitch Williams32f5f542014-04-04 04:43:10 +00001910 return -EINVAL;
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001911 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001912
Jesse Brandeburgac26fc12015-09-28 14:12:37 -04001913 vsi->int_rate_limit = ec->rx_coalesce_usecs_high;
1914
Mitch Williams32f5f542014-04-04 04:43:10 +00001915 if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001916 (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001917 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001918 } else if (ec->tx_coalesce_usecs == 0) {
1919 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001920 if (ec->use_adaptive_tx_coalesce)
Jesse Brandeburg79442d32014-10-25 03:24:32 +00001921 netif_info(pf, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001922 } else {
1923 netif_info(pf, drv, netdev,
Jesse Brandeburg79442d32014-10-25 03:24:32 +00001924 "Invalid value, tx-usecs range is 0-8160\n");
Mitch Williams32f5f542014-04-04 04:43:10 +00001925 return -EINVAL;
Carolyn Wyborny5c2cebd2014-06-04 01:23:18 +00001926 }
Mitch Williams32f5f542014-04-04 04:43:10 +00001927
1928 if (ec->use_adaptive_rx_coalesce)
1929 vsi->rx_itr_setting |= I40E_ITR_DYNAMIC;
1930 else
1931 vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
1932
1933 if (ec->use_adaptive_tx_coalesce)
1934 vsi->tx_itr_setting |= I40E_ITR_DYNAMIC;
1935 else
1936 vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001937
Alexander Duyck493fb302013-09-28 07:01:44 +00001938 for (i = 0; i < vsi->num_q_vectors; i++, vector++) {
Jesse Brandeburgac26fc12015-09-28 14:12:37 -04001939 u16 intrl = INTRL_USEC_TO_REG(vsi->int_rate_limit);
1940
Alexander Duyck493fb302013-09-28 07:01:44 +00001941 q_vector = vsi->q_vectors[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001942 q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
1943 wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
1944 q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
1945 wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
Jesse Brandeburgac26fc12015-09-28 14:12:37 -04001946 wr32(hw, I40E_PFINT_RATEN(vector - 1), intrl);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001947 i40e_flush(hw);
1948 }
1949
1950 return 0;
1951}
1952
1953/**
1954 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
1955 * @pf: pointer to the physical function struct
1956 * @cmd: ethtool rxnfc command
1957 *
1958 * Returns Success if the flow is supported, else Invalid Input.
1959 **/
1960static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
1961{
1962 cmd->data = 0;
1963
Carolyn Wyborny88eee9b2015-02-06 08:52:09 +00001964 if (pf->vsi[pf->lan_vsi]->rxnfc.data != 0) {
1965 cmd->data = pf->vsi[pf->lan_vsi]->rxnfc.data;
1966 cmd->flow_type = pf->vsi[pf->lan_vsi]->rxnfc.flow_type;
1967 return 0;
1968 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001969 /* Report default options for RSS on i40e */
1970 switch (cmd->flow_type) {
1971 case TCP_V4_FLOW:
1972 case UDP_V4_FLOW:
1973 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1974 /* fall through to add IP fields */
1975 case SCTP_V4_FLOW:
1976 case AH_ESP_V4_FLOW:
1977 case AH_V4_FLOW:
1978 case ESP_V4_FLOW:
1979 case IPV4_FLOW:
1980 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1981 break;
1982 case TCP_V6_FLOW:
1983 case UDP_V6_FLOW:
1984 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1985 /* fall through to add IP fields */
1986 case SCTP_V6_FLOW:
1987 case AH_ESP_V6_FLOW:
1988 case AH_V6_FLOW:
1989 case ESP_V6_FLOW:
1990 case IPV6_FLOW:
1991 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1992 break;
1993 default:
1994 return -EINVAL;
1995 }
1996
1997 return 0;
1998}
1999
2000/**
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002001 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
2002 * @pf: Pointer to the physical function struct
2003 * @cmd: The command to get or set Rx flow classification rules
2004 * @rule_locs: Array of used rule locations
2005 *
2006 * This function populates both the total and actual rule count of
2007 * the ethtool flow classification command
2008 *
2009 * Returns 0 on success or -EMSGSIZE if entry not found
2010 **/
2011static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf,
2012 struct ethtool_rxnfc *cmd,
2013 u32 *rule_locs)
2014{
2015 struct i40e_fdir_filter *rule;
2016 struct hlist_node *node2;
2017 int cnt = 0;
2018
2019 /* report total rule count */
Anjali Singhai Jain082def12014-04-09 05:59:00 +00002020 cmd->data = i40e_get_fd_cnt_all(pf);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002021
2022 hlist_for_each_entry_safe(rule, node2,
2023 &pf->fdir_filter_list, fdir_node) {
2024 if (cnt == cmd->rule_cnt)
2025 return -EMSGSIZE;
2026
2027 rule_locs[cnt] = rule->fd_id;
2028 cnt++;
2029 }
2030
2031 cmd->rule_cnt = cnt;
2032
2033 return 0;
2034}
2035
2036/**
2037 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
2038 * @pf: Pointer to the physical function struct
2039 * @cmd: The command to get or set Rx flow classification rules
2040 *
2041 * This function looks up a filter based on the Rx flow classification
2042 * command and fills the flow spec info for it if found
2043 *
2044 * Returns 0 on success or -EINVAL if filter not found
2045 **/
2046static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
2047 struct ethtool_rxnfc *cmd)
2048{
2049 struct ethtool_rx_flow_spec *fsp =
2050 (struct ethtool_rx_flow_spec *)&cmd->fs;
2051 struct i40e_fdir_filter *rule = NULL;
2052 struct hlist_node *node2;
2053
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002054 hlist_for_each_entry_safe(rule, node2,
2055 &pf->fdir_filter_list, fdir_node) {
2056 if (fsp->location <= rule->fd_id)
2057 break;
2058 }
2059
2060 if (!rule || fsp->location != rule->fd_id)
2061 return -EINVAL;
2062
2063 fsp->flow_type = rule->flow_type;
Anjali Singhai Jain7d54eb22014-03-14 07:32:21 +00002064 if (fsp->flow_type == IP_USER_FLOW) {
2065 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
2066 fsp->h_u.usr_ip4_spec.proto = 0;
2067 fsp->m_u.usr_ip4_spec.proto = 0;
2068 }
2069
Anjali Singhai Jain04b73bd2014-05-22 06:31:41 +00002070 /* Reverse the src and dest notion, since the HW views them from
2071 * Tx perspective where as the user expects it from Rx filter view.
2072 */
2073 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port;
2074 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port;
2075 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip[0];
2076 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip[0];
Anjali Singhai Jain387ce1a2014-05-22 06:32:23 +00002077
2078 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET)
2079 fsp->ring_cookie = RX_CLS_FLOW_DISC;
2080 else
2081 fsp->ring_cookie = rule->q_index;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002082
Anjali Singhai Jaine7c8c602015-04-07 19:45:31 -04002083 if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) {
2084 struct i40e_vsi *vsi;
2085
2086 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi);
2087 if (vsi && vsi->type == I40E_VSI_SRIOV) {
2088 fsp->h_ext.data[1] = htonl(vsi->vf_id);
2089 fsp->m_ext.data[1] = htonl(0x1);
2090 }
2091 }
2092
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002093 return 0;
2094}
2095
2096/**
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002097 * i40e_get_rxnfc - command to get RX flow classification rules
2098 * @netdev: network interface device structure
2099 * @cmd: ethtool rxnfc command
2100 *
2101 * Returns Success if the command is supported.
2102 **/
2103static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
2104 u32 *rule_locs)
2105{
2106 struct i40e_netdev_priv *np = netdev_priv(netdev);
2107 struct i40e_vsi *vsi = np->vsi;
2108 struct i40e_pf *pf = vsi->back;
2109 int ret = -EOPNOTSUPP;
2110
2111 switch (cmd->cmd) {
2112 case ETHTOOL_GRXRINGS:
2113 cmd->data = vsi->alloc_queue_pairs;
2114 ret = 0;
2115 break;
2116 case ETHTOOL_GRXFH:
2117 ret = i40e_get_rss_hash_opts(pf, cmd);
2118 break;
2119 case ETHTOOL_GRXCLSRLCNT:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002120 cmd->rule_cnt = pf->fdir_pf_active_filters;
Anjali Singhai Jain082def12014-04-09 05:59:00 +00002121 /* report total rule count */
2122 cmd->data = i40e_get_fd_cnt_all(pf);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002123 ret = 0;
2124 break;
2125 case ETHTOOL_GRXCLSRULE:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002126 ret = i40e_get_ethtool_fdir_entry(pf, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002127 break;
2128 case ETHTOOL_GRXCLSRLALL:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002129 ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs);
2130 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002131 default:
2132 break;
2133 }
2134
2135 return ret;
2136}
2137
2138/**
2139 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2140 * @pf: pointer to the physical function struct
2141 * @cmd: ethtool rxnfc command
2142 *
2143 * Returns Success if the flow input set is supported.
2144 **/
2145static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
2146{
2147 struct i40e_hw *hw = &pf->hw;
2148 u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
2149 ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
2150
2151 /* RSS does not support anything other than hashing
2152 * to queues on src and dst IPs and ports
2153 */
2154 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
2155 RXH_L4_B_0_1 | RXH_L4_B_2_3))
2156 return -EINVAL;
2157
2158 /* We need at least the IP SRC and DEST fields for hashing */
2159 if (!(nfc->data & RXH_IP_SRC) ||
2160 !(nfc->data & RXH_IP_DST))
2161 return -EINVAL;
2162
2163 switch (nfc->flow_type) {
2164 case TCP_V4_FLOW:
2165 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2166 case 0:
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002167 hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002168 break;
2169 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002170 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002171 break;
2172 default:
2173 return -EINVAL;
2174 }
2175 break;
2176 case TCP_V6_FLOW:
2177 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2178 case 0:
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002179 hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002180 break;
2181 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002182 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002183 break;
2184 default:
2185 return -EINVAL;
2186 }
2187 break;
2188 case UDP_V4_FLOW:
2189 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2190 case 0:
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002191 hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
2192 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002193 break;
2194 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002195 hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
2196 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002197 break;
2198 default:
2199 return -EINVAL;
2200 }
2201 break;
2202 case UDP_V6_FLOW:
2203 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2204 case 0:
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002205 hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
2206 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002207 break;
2208 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002209 hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
2210 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002211 break;
2212 default:
2213 return -EINVAL;
2214 }
2215 break;
2216 case AH_ESP_V4_FLOW:
2217 case AH_V4_FLOW:
2218 case ESP_V4_FLOW:
2219 case SCTP_V4_FLOW:
2220 if ((nfc->data & RXH_L4_B_0_1) ||
2221 (nfc->data & RXH_L4_B_2_3))
2222 return -EINVAL;
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002223 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002224 break;
2225 case AH_ESP_V6_FLOW:
2226 case AH_V6_FLOW:
2227 case ESP_V6_FLOW:
2228 case SCTP_V6_FLOW:
2229 if ((nfc->data & RXH_L4_B_0_1) ||
2230 (nfc->data & RXH_L4_B_2_3))
2231 return -EINVAL;
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002232 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002233 break;
2234 case IPV4_FLOW:
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002235 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
2236 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002237 break;
2238 case IPV6_FLOW:
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04002239 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
2240 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002241 break;
2242 default:
2243 return -EINVAL;
2244 }
2245
2246 wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
2247 wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
2248 i40e_flush(hw);
2249
Carolyn Wyborny88eee9b2015-02-06 08:52:09 +00002250 /* Save setting for future output/update */
2251 pf->vsi[pf->lan_vsi]->rxnfc = *nfc;
2252
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002253 return 0;
2254}
2255
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002256/**
Anjali Singhai Jain43fddb72014-02-11 08:24:09 +00002257 * i40e_match_fdir_input_set - Match a new filter against an existing one
2258 * @rule: The filter already added
2259 * @input: The new filter to comapre against
2260 *
2261 * Returns true if the two input set match
2262 **/
2263static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule,
2264 struct i40e_fdir_filter *input)
2265{
2266 if ((rule->dst_ip[0] != input->dst_ip[0]) ||
2267 (rule->src_ip[0] != input->src_ip[0]) ||
2268 (rule->dst_port != input->dst_port) ||
2269 (rule->src_port != input->src_port))
2270 return false;
2271 return true;
2272}
2273
2274/**
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002275 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
2276 * @vsi: Pointer to the targeted VSI
2277 * @input: The filter to update or NULL to indicate deletion
2278 * @sw_idx: Software index to the filter
2279 * @cmd: The command to get or set Rx flow classification rules
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002280 *
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002281 * This function updates (or deletes) a Flow Director entry from
2282 * the hlist of the corresponding PF
2283 *
2284 * Returns 0 on success
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002285 **/
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002286static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
2287 struct i40e_fdir_filter *input,
2288 u16 sw_idx,
2289 struct ethtool_rxnfc *cmd)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002290{
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002291 struct i40e_fdir_filter *rule, *parent;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002292 struct i40e_pf *pf = vsi->back;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002293 struct hlist_node *node2;
2294 int err = -EINVAL;
Jesse Brandeburgc35a1d72013-12-18 13:46:02 +00002295
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002296 parent = NULL;
2297 rule = NULL;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002298
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002299 hlist_for_each_entry_safe(rule, node2,
2300 &pf->fdir_filter_list, fdir_node) {
2301 /* hash found, or no matching entry */
2302 if (rule->fd_id >= sw_idx)
2303 break;
2304 parent = rule;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002305 }
2306
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002307 /* if there is an old rule occupying our place remove it */
2308 if (rule && (rule->fd_id == sw_idx)) {
Anjali Singhai Jain43fddb72014-02-11 08:24:09 +00002309 if (input && !i40e_match_fdir_input_set(rule, input))
2310 err = i40e_add_del_fdir(vsi, rule, false);
2311 else if (!input)
2312 err = i40e_add_del_fdir(vsi, rule, false);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002313 hlist_del(&rule->fdir_node);
2314 kfree(rule);
2315 pf->fdir_pf_active_filters--;
2316 }
2317
2318 /* If no input this was a delete, err should be 0 if a rule was
2319 * successfully found and removed from the list else -EINVAL
2320 */
2321 if (!input)
2322 return err;
2323
2324 /* initialize node and set software index */
2325 INIT_HLIST_NODE(&input->fdir_node);
2326
2327 /* add filter to the list */
2328 if (parent)
Ken Helias1d023282014-08-06 16:09:16 -07002329 hlist_add_behind(&input->fdir_node, &parent->fdir_node);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002330 else
2331 hlist_add_head(&input->fdir_node,
2332 &pf->fdir_filter_list);
2333
2334 /* update counts */
2335 pf->fdir_pf_active_filters++;
2336
2337 return 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002338}
2339
2340/**
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002341 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
2342 * @vsi: Pointer to the targeted VSI
2343 * @cmd: The command to get or set Rx flow classification rules
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002344 *
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002345 * The function removes a Flow Director filter entry from the
2346 * hlist of the corresponding PF
2347 *
2348 * Returns 0 on success
2349 */
2350static int i40e_del_fdir_entry(struct i40e_vsi *vsi,
2351 struct ethtool_rxnfc *cmd)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002352{
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002353 struct ethtool_rx_flow_spec *fsp =
2354 (struct ethtool_rx_flow_spec *)&cmd->fs;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002355 struct i40e_pf *pf = vsi->back;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002356 int ret = 0;
Jesse Brandeburgc35a1d72013-12-18 13:46:02 +00002357
Anjali Singhai Jain60793f4a2014-07-09 07:46:23 +00002358 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
2359 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
2360 return -EBUSY;
2361
Anjali Singhai Jain1e1be8f2014-07-10 08:03:26 +00002362 if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
2363 return -EBUSY;
2364
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002365 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002366
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00002367 i40e_fdir_check_and_reenable(pf);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002368 return ret;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002369}
2370
2371/**
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002372 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002373 * @vsi: pointer to the targeted VSI
2374 * @cmd: command to get or set RX flow classification rules
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002375 *
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002376 * Add Flow Director filters for a specific flow spec based on their
2377 * protocol. Returns 0 if the filters were successfully added.
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002378 **/
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002379static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
2380 struct ethtool_rxnfc *cmd)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002381{
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002382 struct ethtool_rx_flow_spec *fsp;
2383 struct i40e_fdir_filter *input;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002384 struct i40e_pf *pf;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002385 int ret = -EINVAL;
Anjali Singhai Jaine7c8c602015-04-07 19:45:31 -04002386 u16 vf_id;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002387
2388 if (!vsi)
2389 return -EINVAL;
2390
2391 pf = vsi->back;
2392
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00002393 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
2394 return -EOPNOTSUPP;
2395
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002396 if (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00002397 return -ENOSPC;
2398
Anjali Singhai Jain60793f4a2014-07-09 07:46:23 +00002399 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
2400 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
2401 return -EBUSY;
2402
Anjali Singhai Jain1e1be8f2014-07-10 08:03:26 +00002403 if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
2404 return -EBUSY;
2405
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00002406 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
2407
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002408 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort +
2409 pf->hw.func_caps.fd_filters_guaranteed)) {
2410 return -EINVAL;
2411 }
2412
Anjali Singhai Jain387ce1a2014-05-22 06:32:23 +00002413 if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) &&
2414 (fsp->ring_cookie >= vsi->num_queue_pairs))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002415 return -EINVAL;
2416
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002417 input = kzalloc(sizeof(*input), GFP_KERNEL);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002418
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002419 if (!input)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002420 return -ENOMEM;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002421
2422 input->fd_id = fsp->location;
2423
Anjali Singhai Jain35a91fd2014-03-06 09:00:00 +00002424 if (fsp->ring_cookie == RX_CLS_FLOW_DISC)
2425 input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET;
2426 else
2427 input->dest_ctl =
2428 I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
2429
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002430 input->q_index = fsp->ring_cookie;
2431 input->flex_off = 0;
2432 input->pctype = 0;
2433 input->dest_vsi = vsi->id;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002434 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
Anjali Singhai Jain0bf4b1b2015-04-16 20:06:02 -04002435 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002436 input->flow_type = fsp->flow_type;
2437 input->ip4_proto = fsp->h_u.usr_ip4_spec.proto;
Anjali Singhai Jain04b73bd2014-05-22 06:31:41 +00002438
2439 /* Reverse the src and dest notion, since the HW expects them to be from
2440 * Tx perspective where as the input from user is from Rx filter view.
2441 */
2442 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc;
2443 input->src_port = fsp->h_u.tcp_ip4_spec.pdst;
2444 input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src;
2445 input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002446
Anjali Singhai Jaine7c8c602015-04-07 19:45:31 -04002447 if (ntohl(fsp->m_ext.data[1])) {
2448 if (ntohl(fsp->h_ext.data[1]) >= pf->num_alloc_vfs) {
2449 netif_info(pf, drv, vsi->netdev, "Invalid VF id\n");
2450 goto free_input;
2451 }
2452 vf_id = ntohl(fsp->h_ext.data[1]);
2453 /* Find vsi id from vf id and override dest vsi */
2454 input->dest_vsi = pf->vf[vf_id].lan_vsi_id;
2455 if (input->q_index >= pf->vf[vf_id].num_queue_pairs) {
2456 netif_info(pf, drv, vsi->netdev, "Invalid queue id\n");
2457 goto free_input;
2458 }
2459 }
2460
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002461 ret = i40e_add_del_fdir(vsi, input, true);
Anjali Singhai Jaine7c8c602015-04-07 19:45:31 -04002462free_input:
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002463 if (ret)
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002464 kfree(input);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002465 else
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002466 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002467
2468 return ret;
2469}
Jesse Brandeburg8fb905b2014-01-17 15:36:33 -08002470
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002471/**
2472 * i40e_set_rxnfc - command to set RX flow classification rules
2473 * @netdev: network interface device structure
2474 * @cmd: ethtool rxnfc command
2475 *
2476 * Returns Success if the command is supported.
2477 **/
2478static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
2479{
2480 struct i40e_netdev_priv *np = netdev_priv(netdev);
2481 struct i40e_vsi *vsi = np->vsi;
2482 struct i40e_pf *pf = vsi->back;
2483 int ret = -EOPNOTSUPP;
2484
2485 switch (cmd->cmd) {
2486 case ETHTOOL_SRXFH:
2487 ret = i40e_set_rss_hash_opt(pf, cmd);
2488 break;
2489 case ETHTOOL_SRXCLSRLINS:
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00002490 ret = i40e_add_fdir_ethtool(vsi, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002491 break;
2492 case ETHTOOL_SRXCLSRLDEL:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00002493 ret = i40e_del_fdir_entry(vsi, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002494 break;
2495 default:
2496 break;
2497 }
2498
2499 return ret;
2500}
2501
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00002502/**
2503 * i40e_max_channels - get Max number of combined channels supported
2504 * @vsi: vsi pointer
2505 **/
2506static unsigned int i40e_max_channels(struct i40e_vsi *vsi)
2507{
2508 /* TODO: This code assumes DCB and FD is disabled for now. */
2509 return vsi->alloc_queue_pairs;
2510}
2511
2512/**
2513 * i40e_get_channels - Get the current channels enabled and max supported etc.
2514 * @netdev: network interface device structure
2515 * @ch: ethtool channels structure
2516 *
2517 * We don't support separate tx and rx queues as channels. The other count
2518 * represents how many queues are being used for control. max_combined counts
2519 * how many queue pairs we can support. They may not be mapped 1 to 1 with
2520 * q_vectors since we support a lot more queue pairs than q_vectors.
2521 **/
2522static void i40e_get_channels(struct net_device *dev,
2523 struct ethtool_channels *ch)
2524{
2525 struct i40e_netdev_priv *np = netdev_priv(dev);
2526 struct i40e_vsi *vsi = np->vsi;
2527 struct i40e_pf *pf = vsi->back;
2528
2529 /* report maximum channels */
2530 ch->max_combined = i40e_max_channels(vsi);
2531
2532 /* report info for other vector */
Jesse Brandeburg60ea5f82014-01-17 15:36:34 -08002533 ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0;
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00002534 ch->max_other = ch->other_count;
2535
2536 /* Note: This code assumes DCB is disabled for now. */
2537 ch->combined_count = vsi->num_queue_pairs;
2538}
2539
2540/**
2541 * i40e_set_channels - Set the new channels count.
2542 * @netdev: network interface device structure
2543 * @ch: ethtool channels structure
2544 *
2545 * The new channels count may not be the same as requested by the user
2546 * since it gets rounded down to a power of 2 value.
2547 **/
2548static int i40e_set_channels(struct net_device *dev,
2549 struct ethtool_channels *ch)
2550{
2551 struct i40e_netdev_priv *np = netdev_priv(dev);
2552 unsigned int count = ch->combined_count;
2553 struct i40e_vsi *vsi = np->vsi;
2554 struct i40e_pf *pf = vsi->back;
2555 int new_count;
2556
2557 /* We do not support setting channels for any other VSI at present */
2558 if (vsi->type != I40E_VSI_MAIN)
2559 return -EINVAL;
2560
2561 /* verify they are not requesting separate vectors */
2562 if (!count || ch->rx_count || ch->tx_count)
2563 return -EINVAL;
2564
2565 /* verify other_count has not changed */
Jesse Brandeburg60ea5f82014-01-17 15:36:34 -08002566 if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0))
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00002567 return -EINVAL;
2568
2569 /* verify the number of channels does not exceed hardware limits */
2570 if (count > i40e_max_channels(vsi))
2571 return -EINVAL;
2572
2573 /* update feature limits from largest to smallest supported values */
2574 /* TODO: Flow director limit, DCB etc */
2575
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00002576 /* use rss_reconfig to rebuild with new queue count and update traffic
2577 * class queue mapping
2578 */
2579 new_count = i40e_reconfig_rss_queues(pf, count);
Anjali Singhai Jain5f90f422013-12-21 05:44:43 +00002580 if (new_count > 0)
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00002581 return 0;
2582 else
2583 return -EINVAL;
2584}
2585
Mitch A Williamsb29e13b2015-03-05 04:14:40 +00002586#define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4)
2587/**
2588 * i40e_get_rxfh_key_size - get the RSS hash key size
2589 * @netdev: network interface device structure
2590 *
2591 * Returns the table size.
2592 **/
2593static u32 i40e_get_rxfh_key_size(struct net_device *netdev)
2594{
2595 return I40E_HKEY_ARRAY_SIZE;
2596}
2597
2598/**
2599 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
2600 * @netdev: network interface device structure
2601 *
2602 * Returns the table size.
2603 **/
2604static u32 i40e_get_rxfh_indir_size(struct net_device *netdev)
2605{
2606 return I40E_HLUT_ARRAY_SIZE;
2607}
2608
2609static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
2610 u8 *hfunc)
2611{
2612 struct i40e_netdev_priv *np = netdev_priv(netdev);
2613 struct i40e_vsi *vsi = np->vsi;
2614 struct i40e_pf *pf = vsi->back;
2615 struct i40e_hw *hw = &pf->hw;
2616 u32 reg_val;
2617 int i, j;
2618
2619 if (hfunc)
2620 *hfunc = ETH_RSS_HASH_TOP;
2621
2622 if (!indir)
2623 return 0;
2624
2625 for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
2626 reg_val = rd32(hw, I40E_PFQF_HLUT(i));
2627 indir[j++] = reg_val & 0xff;
2628 indir[j++] = (reg_val >> 8) & 0xff;
2629 indir[j++] = (reg_val >> 16) & 0xff;
2630 indir[j++] = (reg_val >> 24) & 0xff;
2631 }
2632
2633 if (key) {
2634 for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
2635 reg_val = rd32(hw, I40E_PFQF_HKEY(i));
2636 key[j++] = (u8)(reg_val & 0xff);
2637 key[j++] = (u8)((reg_val >> 8) & 0xff);
2638 key[j++] = (u8)((reg_val >> 16) & 0xff);
2639 key[j++] = (u8)((reg_val >> 24) & 0xff);
2640 }
2641 }
2642 return 0;
2643}
2644
2645/**
2646 * i40e_set_rxfh - set the rx flow hash indirection table
2647 * @netdev: network interface device structure
2648 * @indir: indirection table
2649 * @key: hash key
2650 *
Mitch Williamscd494fb2015-07-10 19:36:04 -04002651 * Returns -EINVAL if the table specifies an invalid queue id, otherwise
Mitch A Williamsb29e13b2015-03-05 04:14:40 +00002652 * returns 0 after programming the table.
2653 **/
2654static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
2655 const u8 *key, const u8 hfunc)
2656{
2657 struct i40e_netdev_priv *np = netdev_priv(netdev);
2658 struct i40e_vsi *vsi = np->vsi;
2659 struct i40e_pf *pf = vsi->back;
2660 struct i40e_hw *hw = &pf->hw;
2661 u32 reg_val;
2662 int i, j;
2663
2664 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
2665 return -EOPNOTSUPP;
2666
2667 if (!indir)
2668 return 0;
2669
2670 for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
2671 reg_val = indir[j++];
2672 reg_val |= indir[j++] << 8;
2673 reg_val |= indir[j++] << 16;
2674 reg_val |= indir[j++] << 24;
2675 wr32(hw, I40E_PFQF_HLUT(i), reg_val);
2676 }
2677
2678 if (key) {
2679 for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
2680 reg_val = key[j++];
2681 reg_val |= key[j++] << 8;
2682 reg_val |= key[j++] << 16;
2683 reg_val |= key[j++] << 24;
2684 wr32(hw, I40E_PFQF_HKEY(i), reg_val);
2685 }
2686 }
2687 return 0;
2688}
2689
Greg Rose7e45ab42015-02-06 08:52:19 +00002690/**
2691 * i40e_get_priv_flags - report device private flags
2692 * @dev: network interface device structure
2693 *
2694 * The get string set count and the string set should be matched for each
2695 * flag returned. Add new strings for each flag to the i40e_priv_flags_strings
2696 * array.
2697 *
2698 * Returns a u32 bitmap of flags.
2699 **/
Jesse Brandeburg5bbc3302015-02-26 16:15:20 +00002700static u32 i40e_get_priv_flags(struct net_device *dev)
Greg Rose7e45ab42015-02-06 08:52:19 +00002701{
2702 struct i40e_netdev_priv *np = netdev_priv(dev);
2703 struct i40e_vsi *vsi = np->vsi;
2704 struct i40e_pf *pf = vsi->back;
2705 u32 ret_flags = 0;
2706
2707 ret_flags |= pf->hw.func_caps.npar_enable ?
2708 I40E_PRIV_FLAGS_NPAR_FLAG : 0;
Shannon Nelson9ac77262015-08-27 11:42:40 -04002709 ret_flags |= pf->flags & I40E_FLAG_LINK_POLLING_ENABLED ?
2710 I40E_PRIV_FLAGS_LINKPOLL_FLAG : 0;
Jesse Brandeburgef171782015-09-03 17:18:49 -04002711 ret_flags |= pf->flags & I40E_FLAG_FD_ATR_ENABLED ?
2712 I40E_PRIV_FLAGS_FD_ATR : 0;
Shannon Nelson1cdfd882015-09-28 14:12:34 -04002713 ret_flags |= pf->flags & I40E_FLAG_VEB_STATS_ENABLED ?
2714 I40E_PRIV_FLAGS_VEB_STATS : 0;
Greg Rose7e45ab42015-02-06 08:52:19 +00002715
2716 return ret_flags;
2717}
2718
Shannon Nelson9ac77262015-08-27 11:42:40 -04002719/**
2720 * i40e_set_priv_flags - set private flags
2721 * @dev: network interface device structure
2722 * @flags: bit flags to be set
2723 **/
2724static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
2725{
2726 struct i40e_netdev_priv *np = netdev_priv(dev);
2727 struct i40e_vsi *vsi = np->vsi;
2728 struct i40e_pf *pf = vsi->back;
2729
2730 if (flags & I40E_PRIV_FLAGS_LINKPOLL_FLAG)
2731 pf->flags |= I40E_FLAG_LINK_POLLING_ENABLED;
2732 else
2733 pf->flags &= ~I40E_FLAG_LINK_POLLING_ENABLED;
2734
Jesse Brandeburgef171782015-09-03 17:18:49 -04002735 /* allow the user to control the state of the Flow
2736 * Director ATR (Application Targeted Routing) feature
2737 * of the driver
2738 */
2739 if (flags & I40E_PRIV_FLAGS_FD_ATR) {
2740 pf->flags |= I40E_FLAG_FD_ATR_ENABLED;
2741 } else {
2742 pf->flags &= ~I40E_FLAG_FD_ATR_ENABLED;
2743 pf->auto_disable_flags |= I40E_FLAG_FD_ATR_ENABLED;
2744 }
2745
Shannon Nelson1cdfd882015-09-28 14:12:34 -04002746 if (flags & I40E_PRIV_FLAGS_VEB_STATS)
2747 pf->flags |= I40E_FLAG_VEB_STATS_ENABLED;
2748 else
2749 pf->flags &= ~I40E_FLAG_VEB_STATS_ENABLED;
2750
Shannon Nelson9ac77262015-08-27 11:42:40 -04002751 return 0;
2752}
2753
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002754static const struct ethtool_ops i40e_ethtool_ops = {
2755 .get_settings = i40e_get_settings,
Catherine Sullivanbf9c7142014-06-04 08:45:28 +00002756 .set_settings = i40e_set_settings,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002757 .get_drvinfo = i40e_get_drvinfo,
2758 .get_regs_len = i40e_get_regs_len,
2759 .get_regs = i40e_get_regs,
2760 .nway_reset = i40e_nway_reset,
2761 .get_link = ethtool_op_get_link,
2762 .get_wol = i40e_get_wol,
Shannon Nelson8e2773a2013-11-28 06:39:22 +00002763 .set_wol = i40e_set_wol,
Shannon Nelsoncd552cb2014-07-09 07:46:09 +00002764 .set_eeprom = i40e_set_eeprom,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002765 .get_eeprom_len = i40e_get_eeprom_len,
2766 .get_eeprom = i40e_get_eeprom,
2767 .get_ringparam = i40e_get_ringparam,
2768 .set_ringparam = i40e_set_ringparam,
2769 .get_pauseparam = i40e_get_pauseparam,
Catherine Sullivan2becc352014-06-04 08:45:27 +00002770 .set_pauseparam = i40e_set_pauseparam,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002771 .get_msglevel = i40e_get_msglevel,
2772 .set_msglevel = i40e_set_msglevel,
2773 .get_rxnfc = i40e_get_rxnfc,
2774 .set_rxnfc = i40e_set_rxnfc,
2775 .self_test = i40e_diag_test,
2776 .get_strings = i40e_get_strings,
2777 .set_phys_id = i40e_set_phys_id,
2778 .get_sset_count = i40e_get_sset_count,
2779 .get_ethtool_stats = i40e_get_ethtool_stats,
2780 .get_coalesce = i40e_get_coalesce,
2781 .set_coalesce = i40e_set_coalesce,
Mitch A Williamsb29e13b2015-03-05 04:14:40 +00002782 .get_rxfh_key_size = i40e_get_rxfh_key_size,
2783 .get_rxfh_indir_size = i40e_get_rxfh_indir_size,
2784 .get_rxfh = i40e_get_rxfh,
2785 .set_rxfh = i40e_set_rxfh,
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00002786 .get_channels = i40e_get_channels,
2787 .set_channels = i40e_set_channels,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002788 .get_ts_info = i40e_get_ts_info,
Greg Rose7e45ab42015-02-06 08:52:19 +00002789 .get_priv_flags = i40e_get_priv_flags,
Shannon Nelson9ac77262015-08-27 11:42:40 -04002790 .set_priv_flags = i40e_set_priv_flags,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002791};
2792
2793void i40e_set_ethtool_ops(struct net_device *netdev)
2794{
Wilfried Klaebe7ad24ea2014-05-11 00:12:32 +00002795 netdev->ethtool_ops = &i40e_ethtool_ops;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00002796}