blob: 14d5328e6ac9196486739bbf4554c3dd7b191b7b [file] [log] [blame]
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001/* QLogic qede NIC Driver
2* Copyright (c) 2015 QLogic Corporation
3*
4* This software is available under the terms of the GNU General Public License
5* (GPL) Version 2, available from the file COPYING in the main directory of
6* this source tree.
7*/
8
9#include <linux/version.h>
10#include <linux/types.h>
11#include <linux/netdevice.h>
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -040012#include <linux/etherdevice.h>
Sudarsana Kalluru133fac02015-10-26 11:02:34 +020013#include <linux/ethtool.h>
14#include <linux/string.h>
15#include <linux/pci.h>
16#include <linux/capability.h>
17#include "qede.h"
18
19#define QEDE_STAT_OFFSET(stat_name) (offsetof(struct qede_stats, stat_name))
20#define QEDE_STAT_STRING(stat_name) (#stat_name)
21#define _QEDE_STAT(stat_name, pf_only) \
22 {QEDE_STAT_OFFSET(stat_name), QEDE_STAT_STRING(stat_name), pf_only}
23#define QEDE_PF_STAT(stat_name) _QEDE_STAT(stat_name, true)
24#define QEDE_STAT(stat_name) _QEDE_STAT(stat_name, false)
25
26#define QEDE_RQSTAT_OFFSET(stat_name) \
27 (offsetof(struct qede_rx_queue, stat_name))
28#define QEDE_RQSTAT_STRING(stat_name) (#stat_name)
29#define QEDE_RQSTAT(stat_name) \
30 {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -040031
32#define QEDE_SELFTEST_POLL_COUNT 100
33
Sudarsana Kalluru133fac02015-10-26 11:02:34 +020034static const struct {
35 u64 offset;
36 char string[ETH_GSTRING_LEN];
37} qede_rqstats_arr[] = {
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -040038 QEDE_RQSTAT(rcv_pkts),
Sudarsana Kalluru133fac02015-10-26 11:02:34 +020039 QEDE_RQSTAT(rx_hw_errors),
40 QEDE_RQSTAT(rx_alloc_errors),
Manish Choprac72a6122016-06-30 02:35:18 -040041 QEDE_RQSTAT(rx_ip_frags),
Sudarsana Kalluru133fac02015-10-26 11:02:34 +020042};
43
44#define QEDE_NUM_RQSTATS ARRAY_SIZE(qede_rqstats_arr)
45#define QEDE_RQSTATS_DATA(dev, sindex, rqindex) \
46 (*((u64 *)(((char *)(dev->fp_array[(rqindex)].rxq)) +\
47 qede_rqstats_arr[(sindex)].offset)))
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -040048#define QEDE_TQSTAT_OFFSET(stat_name) \
49 (offsetof(struct qede_tx_queue, stat_name))
50#define QEDE_TQSTAT_STRING(stat_name) (#stat_name)
51#define QEDE_TQSTAT(stat_name) \
52 {QEDE_TQSTAT_OFFSET(stat_name), QEDE_TQSTAT_STRING(stat_name)}
53#define QEDE_NUM_TQSTATS ARRAY_SIZE(qede_tqstats_arr)
54static const struct {
55 u64 offset;
56 char string[ETH_GSTRING_LEN];
57} qede_tqstats_arr[] = {
58 QEDE_TQSTAT(xmit_pkts),
59 QEDE_TQSTAT(stopped_cnt),
60};
61
62#define QEDE_TQSTATS_DATA(dev, sindex, tssid, tcid) \
Arnd Bergmann84fd1b12016-08-26 17:37:53 +020063 (*((u64 *)(((void *)(&dev->fp_array[tssid].txqs[tcid])) +\
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -040064 qede_tqstats_arr[(sindex)].offset)))
65
Sudarsana Kalluru133fac02015-10-26 11:02:34 +020066static const struct {
67 u64 offset;
68 char string[ETH_GSTRING_LEN];
69 bool pf_only;
70} qede_stats_arr[] = {
71 QEDE_STAT(rx_ucast_bytes),
72 QEDE_STAT(rx_mcast_bytes),
73 QEDE_STAT(rx_bcast_bytes),
74 QEDE_STAT(rx_ucast_pkts),
75 QEDE_STAT(rx_mcast_pkts),
76 QEDE_STAT(rx_bcast_pkts),
77
78 QEDE_STAT(tx_ucast_bytes),
79 QEDE_STAT(tx_mcast_bytes),
80 QEDE_STAT(tx_bcast_bytes),
81 QEDE_STAT(tx_ucast_pkts),
82 QEDE_STAT(tx_mcast_pkts),
83 QEDE_STAT(tx_bcast_pkts),
84
85 QEDE_PF_STAT(rx_64_byte_packets),
Yuval Mintzd4967cf2016-04-22 08:41:01 +030086 QEDE_PF_STAT(rx_65_to_127_byte_packets),
87 QEDE_PF_STAT(rx_128_to_255_byte_packets),
88 QEDE_PF_STAT(rx_256_to_511_byte_packets),
89 QEDE_PF_STAT(rx_512_to_1023_byte_packets),
90 QEDE_PF_STAT(rx_1024_to_1518_byte_packets),
91 QEDE_PF_STAT(rx_1519_to_1522_byte_packets),
92 QEDE_PF_STAT(rx_1519_to_2047_byte_packets),
93 QEDE_PF_STAT(rx_2048_to_4095_byte_packets),
94 QEDE_PF_STAT(rx_4096_to_9216_byte_packets),
95 QEDE_PF_STAT(rx_9217_to_16383_byte_packets),
Sudarsana Kalluru133fac02015-10-26 11:02:34 +020096 QEDE_PF_STAT(tx_64_byte_packets),
97 QEDE_PF_STAT(tx_65_to_127_byte_packets),
98 QEDE_PF_STAT(tx_128_to_255_byte_packets),
99 QEDE_PF_STAT(tx_256_to_511_byte_packets),
100 QEDE_PF_STAT(tx_512_to_1023_byte_packets),
101 QEDE_PF_STAT(tx_1024_to_1518_byte_packets),
102 QEDE_PF_STAT(tx_1519_to_2047_byte_packets),
103 QEDE_PF_STAT(tx_2048_to_4095_byte_packets),
104 QEDE_PF_STAT(tx_4096_to_9216_byte_packets),
105 QEDE_PF_STAT(tx_9217_to_16383_byte_packets),
106
107 QEDE_PF_STAT(rx_mac_crtl_frames),
108 QEDE_PF_STAT(tx_mac_ctrl_frames),
109 QEDE_PF_STAT(rx_pause_frames),
110 QEDE_PF_STAT(tx_pause_frames),
111 QEDE_PF_STAT(rx_pfc_frames),
112 QEDE_PF_STAT(tx_pfc_frames),
113
114 QEDE_PF_STAT(rx_crc_errors),
115 QEDE_PF_STAT(rx_align_errors),
116 QEDE_PF_STAT(rx_carrier_errors),
117 QEDE_PF_STAT(rx_oversize_packets),
118 QEDE_PF_STAT(rx_jabbers),
119 QEDE_PF_STAT(rx_undersize_packets),
120 QEDE_PF_STAT(rx_fragments),
121 QEDE_PF_STAT(tx_lpi_entry_count),
122 QEDE_PF_STAT(tx_total_collisions),
123 QEDE_PF_STAT(brb_truncates),
124 QEDE_PF_STAT(brb_discards),
125 QEDE_STAT(no_buff_discards),
126 QEDE_PF_STAT(mftag_filter_discards),
127 QEDE_PF_STAT(mac_filter_discards),
128 QEDE_STAT(tx_err_drop_pkts),
Sudarsana Reddy Kalluru1a5a3662016-08-16 10:51:01 -0400129 QEDE_STAT(ttl0_discard),
130 QEDE_STAT(packet_too_big_discard),
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200131
132 QEDE_STAT(coalesced_pkts),
133 QEDE_STAT(coalesced_events),
134 QEDE_STAT(coalesced_aborts_num),
135 QEDE_STAT(non_coalesced_pkts),
136 QEDE_STAT(coalesced_bytes),
137};
138
139#define QEDE_STATS_DATA(dev, index) \
140 (*((u64 *)(((char *)(dev)) + offsetof(struct qede_dev, stats) \
141 + qede_stats_arr[(index)].offset)))
142
143#define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
144
Yuval Mintzf3e72102016-04-22 08:41:02 +0300145enum {
146 QEDE_PRI_FLAG_CMT,
147 QEDE_PRI_FLAG_LEN,
148};
149
150static const char qede_private_arr[QEDE_PRI_FLAG_LEN][ETH_GSTRING_LEN] = {
151 "Coupled-Function",
152};
153
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -0400154enum qede_ethtool_tests {
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -0400155 QEDE_ETHTOOL_INT_LOOPBACK,
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -0400156 QEDE_ETHTOOL_INTERRUPT_TEST,
157 QEDE_ETHTOOL_MEMORY_TEST,
158 QEDE_ETHTOOL_REGISTER_TEST,
159 QEDE_ETHTOOL_CLOCK_TEST,
160 QEDE_ETHTOOL_TEST_MAX
161};
162
163static const char qede_tests_str_arr[QEDE_ETHTOOL_TEST_MAX][ETH_GSTRING_LEN] = {
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -0400164 "Internal loopback (offline)",
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -0400165 "Interrupt (online)\t",
166 "Memory (online)\t\t",
167 "Register (online)\t",
168 "Clock (online)\t\t",
169};
170
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200171static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
172{
173 int i, j, k;
174
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400175 for (i = 0, k = 0; i < QEDE_QUEUE_CNT(edev); i++) {
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -0400176 int tc;
177
178 for (j = 0; j < QEDE_NUM_RQSTATS; j++)
179 sprintf(buf + (k + j) * ETH_GSTRING_LEN,
180 "%d: %s", i, qede_rqstats_arr[j].string);
181 k += QEDE_NUM_RQSTATS;
182 for (tc = 0; tc < edev->num_tc; tc++) {
183 for (j = 0; j < QEDE_NUM_TQSTATS; j++)
184 sprintf(buf + (k + j) * ETH_GSTRING_LEN,
185 "%d.%d: %s", i, tc,
186 qede_tqstats_arr[j].string);
187 k += QEDE_NUM_TQSTATS;
188 }
189 }
190
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200191 for (i = 0, j = 0; i < QEDE_NUM_STATS; i++) {
Yuval Mintzfefb0202016-05-11 16:36:19 +0300192 if (IS_VF(edev) && qede_stats_arr[i].pf_only)
193 continue;
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -0400194 strcpy(buf + (k + j) * ETH_GSTRING_LEN,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200195 qede_stats_arr[i].string);
196 j++;
197 }
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200198}
199
200static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
201{
202 struct qede_dev *edev = netdev_priv(dev);
203
204 switch (stringset) {
205 case ETH_SS_STATS:
206 qede_get_strings_stats(edev, buf);
207 break;
Yuval Mintzf3e72102016-04-22 08:41:02 +0300208 case ETH_SS_PRIV_FLAGS:
209 memcpy(buf, qede_private_arr,
210 ETH_GSTRING_LEN * QEDE_PRI_FLAG_LEN);
211 break;
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -0400212 case ETH_SS_TEST:
213 memcpy(buf, qede_tests_str_arr,
214 ETH_GSTRING_LEN * QEDE_ETHTOOL_TEST_MAX);
215 break;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200216 default:
217 DP_VERBOSE(edev, QED_MSG_DEBUG,
218 "Unsupported stringset 0x%08x\n", stringset);
219 }
220}
221
222static void qede_get_ethtool_stats(struct net_device *dev,
223 struct ethtool_stats *stats, u64 *buf)
224{
225 struct qede_dev *edev = netdev_priv(dev);
226 int sidx, cnt = 0;
227 int qid;
228
229 qede_fill_by_demand_stats(edev);
230
231 mutex_lock(&edev->qede_lock);
232
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400233 for (qid = 0; qid < QEDE_QUEUE_CNT(edev); qid++) {
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -0400234 int tc;
235
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400236 if (edev->fp_array[qid].type & QEDE_FASTPATH_RX) {
237 for (sidx = 0; sidx < QEDE_NUM_RQSTATS; sidx++)
238 buf[cnt++] = QEDE_RQSTATS_DATA(edev, sidx, qid);
239 }
240
241 if (edev->fp_array[qid].type & QEDE_FASTPATH_TX) {
242 for (tc = 0; tc < edev->num_tc; tc++) {
243 for (sidx = 0; sidx < QEDE_NUM_TQSTATS; sidx++)
244 buf[cnt++] = QEDE_TQSTATS_DATA(edev,
245 sidx,
246 qid, tc);
247 }
Sudarsana Reddy Kalluru68db9ec2016-08-16 10:51:02 -0400248 }
249 }
250
Yuval Mintzfefb0202016-05-11 16:36:19 +0300251 for (sidx = 0; sidx < QEDE_NUM_STATS; sidx++) {
252 if (IS_VF(edev) && qede_stats_arr[sidx].pf_only)
253 continue;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200254 buf[cnt++] = QEDE_STATS_DATA(edev, sidx);
Yuval Mintzfefb0202016-05-11 16:36:19 +0300255 }
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200256
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200257 mutex_unlock(&edev->qede_lock);
258}
259
260static int qede_get_sset_count(struct net_device *dev, int stringset)
261{
262 struct qede_dev *edev = netdev_priv(dev);
263 int num_stats = QEDE_NUM_STATS;
264
265 switch (stringset) {
266 case ETH_SS_STATS:
Yuval Mintzfefb0202016-05-11 16:36:19 +0300267 if (IS_VF(edev)) {
268 int i;
269
270 for (i = 0; i < QEDE_NUM_STATS; i++)
271 if (qede_stats_arr[i].pf_only)
272 num_stats--;
273 }
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400274 return num_stats + QEDE_RSS_COUNT(edev) * QEDE_NUM_RQSTATS +
275 QEDE_TSS_COUNT(edev) * QEDE_NUM_TQSTATS * edev->num_tc;
Yuval Mintzf3e72102016-04-22 08:41:02 +0300276 case ETH_SS_PRIV_FLAGS:
277 return QEDE_PRI_FLAG_LEN;
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -0400278 case ETH_SS_TEST:
Yuval Mintz6ecb0a02016-05-26 11:01:19 +0300279 if (!IS_VF(edev))
280 return QEDE_ETHTOOL_TEST_MAX;
281 else
282 return 0;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200283 default:
284 DP_VERBOSE(edev, QED_MSG_DEBUG,
285 "Unsupported stringset 0x%08x\n", stringset);
286 return -EINVAL;
287 }
288}
289
Yuval Mintzf3e72102016-04-22 08:41:02 +0300290static u32 qede_get_priv_flags(struct net_device *dev)
291{
292 struct qede_dev *edev = netdev_priv(dev);
293
294 return (!!(edev->dev_info.common.num_hwfns > 1)) << QEDE_PRI_FLAG_CMT;
295}
296
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400297struct qede_link_mode_mapping {
298 u32 qed_link_mode;
299 u32 ethtool_link_mode;
300};
301
302static const struct qede_link_mode_mapping qed_lm_map[] = {
303 {QED_LM_FIBRE_BIT, ETHTOOL_LINK_MODE_FIBRE_BIT},
304 {QED_LM_Autoneg_BIT, ETHTOOL_LINK_MODE_Autoneg_BIT},
305 {QED_LM_Asym_Pause_BIT, ETHTOOL_LINK_MODE_Asym_Pause_BIT},
306 {QED_LM_Pause_BIT, ETHTOOL_LINK_MODE_Pause_BIT},
307 {QED_LM_1000baseT_Half_BIT, ETHTOOL_LINK_MODE_1000baseT_Half_BIT},
308 {QED_LM_1000baseT_Full_BIT, ETHTOOL_LINK_MODE_1000baseT_Full_BIT},
309 {QED_LM_10000baseKR_Full_BIT, ETHTOOL_LINK_MODE_10000baseKR_Full_BIT},
310 {QED_LM_25000baseKR_Full_BIT, ETHTOOL_LINK_MODE_25000baseKR_Full_BIT},
311 {QED_LM_40000baseLR4_Full_BIT, ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT},
312 {QED_LM_50000baseKR2_Full_BIT, ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT},
313 {QED_LM_100000baseKR4_Full_BIT,
314 ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT},
315};
316
317#define QEDE_DRV_TO_ETHTOOL_CAPS(caps, lk_ksettings, name) \
318{ \
319 int i; \
320 \
321 for (i = 0; i < QED_LM_COUNT; i++) { \
322 if ((caps) & (qed_lm_map[i].qed_link_mode)) \
323 __set_bit(qed_lm_map[i].ethtool_link_mode,\
324 lk_ksettings->link_modes.name); \
325 } \
326}
327
328#define QEDE_ETHTOOL_TO_DRV_CAPS(caps, lk_ksettings, name) \
329{ \
330 int i; \
331 \
332 for (i = 0; i < QED_LM_COUNT; i++) { \
333 if (test_bit(qed_lm_map[i].ethtool_link_mode, \
334 lk_ksettings->link_modes.name)) \
335 caps |= qed_lm_map[i].qed_link_mode; \
336 } \
337}
338
339static int qede_get_link_ksettings(struct net_device *dev,
340 struct ethtool_link_ksettings *cmd)
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200341{
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400342 struct ethtool_link_settings *base = &cmd->base;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200343 struct qede_dev *edev = netdev_priv(dev);
344 struct qed_link_output current_link;
345
346 memset(&current_link, 0, sizeof(current_link));
347 edev->ops->common->get_link(edev->cdev, &current_link);
348
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400349 ethtool_link_ksettings_zero_link_mode(cmd, supported);
350 QEDE_DRV_TO_ETHTOOL_CAPS(current_link.supported_caps, cmd, supported)
351
352 ethtool_link_ksettings_zero_link_mode(cmd, advertising);
353 QEDE_DRV_TO_ETHTOOL_CAPS(current_link.advertised_caps, cmd, advertising)
354
355 ethtool_link_ksettings_zero_link_mode(cmd, lp_advertising);
356 QEDE_DRV_TO_ETHTOOL_CAPS(current_link.lp_caps, cmd, lp_advertising)
357
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200358 if ((edev->state == QEDE_STATE_OPEN) && (current_link.link_up)) {
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400359 base->speed = current_link.speed;
360 base->duplex = current_link.duplex;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200361 } else {
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400362 base->speed = SPEED_UNKNOWN;
363 base->duplex = DUPLEX_UNKNOWN;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200364 }
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400365 base->port = current_link.port;
366 base->autoneg = (current_link.autoneg) ? AUTONEG_ENABLE :
367 AUTONEG_DISABLE;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200368
369 return 0;
370}
371
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400372static int qede_set_link_ksettings(struct net_device *dev,
373 const struct ethtool_link_ksettings *cmd)
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200374{
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400375 const struct ethtool_link_settings *base = &cmd->base;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200376 struct qede_dev *edev = netdev_priv(dev);
377 struct qed_link_output current_link;
378 struct qed_link_params params;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200379
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300380 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400381 DP_INFO(edev, "Link settings are not allowed to be changed\n");
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200382 return -EOPNOTSUPP;
383 }
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200384 memset(&current_link, 0, sizeof(current_link));
385 memset(&params, 0, sizeof(params));
386 edev->ops->common->get_link(edev->cdev, &current_link);
387
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200388 params.override_flags |= QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS;
389 params.override_flags |= QED_LINK_OVERRIDE_SPEED_AUTONEG;
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400390 if (base->autoneg == AUTONEG_ENABLE) {
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200391 params.autoneg = true;
392 params.forced_speed = 0;
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400393 QEDE_ETHTOOL_TO_DRV_CAPS(params.adv_speeds, cmd, advertising)
394 } else { /* forced speed */
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200395 params.override_flags |= QED_LINK_OVERRIDE_SPEED_FORCED_SPEED;
396 params.autoneg = false;
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400397 params.forced_speed = base->speed;
398 switch (base->speed) {
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200399 case SPEED_10000:
400 if (!(current_link.supported_caps &
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400401 QED_LM_10000baseKR_Full_BIT)) {
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200402 DP_INFO(edev, "10G speed not supported\n");
403 return -EINVAL;
404 }
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400405 params.adv_speeds = QED_LM_10000baseKR_Full_BIT;
406 break;
407 case SPEED_25000:
408 if (!(current_link.supported_caps &
409 QED_LM_25000baseKR_Full_BIT)) {
410 DP_INFO(edev, "25G speed not supported\n");
411 return -EINVAL;
412 }
413 params.adv_speeds = QED_LM_25000baseKR_Full_BIT;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200414 break;
415 case SPEED_40000:
416 if (!(current_link.supported_caps &
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400417 QED_LM_40000baseLR4_Full_BIT)) {
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200418 DP_INFO(edev, "40G speed not supported\n");
419 return -EINVAL;
420 }
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400421 params.adv_speeds = QED_LM_40000baseLR4_Full_BIT;
422 break;
Yuval Mintz16d59462016-08-19 08:34:58 +0300423 case SPEED_50000:
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400424 if (!(current_link.supported_caps &
425 QED_LM_50000baseKR2_Full_BIT)) {
426 DP_INFO(edev, "50G speed not supported\n");
427 return -EINVAL;
428 }
429 params.adv_speeds = QED_LM_50000baseKR2_Full_BIT;
430 break;
Yuval Mintz16d59462016-08-19 08:34:58 +0300431 case SPEED_100000:
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400432 if (!(current_link.supported_caps &
433 QED_LM_100000baseKR4_Full_BIT)) {
434 DP_INFO(edev, "100G speed not supported\n");
435 return -EINVAL;
436 }
437 params.adv_speeds = QED_LM_100000baseKR4_Full_BIT;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200438 break;
439 default:
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -0400440 DP_INFO(edev, "Unsupported speed %u\n", base->speed);
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200441 return -EINVAL;
442 }
443 }
444
445 params.link_up = true;
446 edev->ops->common->set_link(edev->cdev, &params);
447
448 return 0;
449}
450
451static void qede_get_drvinfo(struct net_device *ndev,
452 struct ethtool_drvinfo *info)
453{
454 char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
455 struct qede_dev *edev = netdev_priv(ndev);
456
457 strlcpy(info->driver, "qede", sizeof(info->driver));
458 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
459
460 snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
461 edev->dev_info.common.fw_major,
462 edev->dev_info.common.fw_minor,
463 edev->dev_info.common.fw_rev,
464 edev->dev_info.common.fw_eng);
465
466 snprintf(mfw, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
467 (edev->dev_info.common.mfw_rev >> 24) & 0xFF,
468 (edev->dev_info.common.mfw_rev >> 16) & 0xFF,
469 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
470 edev->dev_info.common.mfw_rev & 0xFF);
471
472 if ((strlen(storm) + strlen(mfw) + strlen("mfw storm ")) <
473 sizeof(info->fw_version)) {
474 snprintf(info->fw_version, sizeof(info->fw_version),
475 "mfw %s storm %s", mfw, storm);
476 } else {
477 snprintf(info->fw_version, sizeof(info->fw_version),
478 "%s %s", mfw, storm);
479 }
480
481 strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
482}
483
484static u32 qede_get_msglevel(struct net_device *ndev)
485{
486 struct qede_dev *edev = netdev_priv(ndev);
487
Yuval Mintz1a635e42016-08-15 10:42:43 +0300488 return ((u32)edev->dp_level << QED_LOG_LEVEL_SHIFT) | edev->dp_module;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200489}
490
491static void qede_set_msglevel(struct net_device *ndev, u32 level)
492{
493 struct qede_dev *edev = netdev_priv(ndev);
494 u32 dp_module = 0;
495 u8 dp_level = 0;
496
497 qede_config_debug(level, &dp_module, &dp_level);
498
499 edev->dp_level = dp_level;
500 edev->dp_module = dp_module;
501 edev->ops->common->update_msglvl(edev->cdev,
502 dp_module, dp_level);
503}
504
Sudarsana Kalluru32a7a572015-11-30 12:25:05 +0200505static int qede_nway_reset(struct net_device *dev)
506{
507 struct qede_dev *edev = netdev_priv(dev);
508 struct qed_link_output current_link;
509 struct qed_link_params link_params;
510
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300511 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
Yuval Mintz1a635e42016-08-15 10:42:43 +0300512 DP_INFO(edev, "Link settings are not allowed to be changed\n");
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300513 return -EOPNOTSUPP;
514 }
515
Sudarsana Kalluru32a7a572015-11-30 12:25:05 +0200516 if (!netif_running(dev))
517 return 0;
518
519 memset(&current_link, 0, sizeof(current_link));
520 edev->ops->common->get_link(edev->cdev, &current_link);
521 if (!current_link.link_up)
522 return 0;
523
524 /* Toggle the link */
525 memset(&link_params, 0, sizeof(link_params));
526 link_params.link_up = false;
527 edev->ops->common->set_link(edev->cdev, &link_params);
528 link_params.link_up = true;
529 edev->ops->common->set_link(edev->cdev, &link_params);
530
531 return 0;
532}
533
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200534static u32 qede_get_link(struct net_device *dev)
535{
536 struct qede_dev *edev = netdev_priv(dev);
537 struct qed_link_output current_link;
538
539 memset(&current_link, 0, sizeof(current_link));
540 edev->ops->common->get_link(edev->cdev, &current_link);
541
542 return current_link.link_up;
543}
544
Sudarsana Reddy Kallurud552fa82016-06-21 09:36:22 -0400545static int qede_get_coalesce(struct net_device *dev,
546 struct ethtool_coalesce *coal)
547{
548 struct qede_dev *edev = netdev_priv(dev);
Sudarsana Reddy Kallurud2890de2016-06-28 02:10:59 -0400549 u16 rxc, txc;
Sudarsana Reddy Kallurud552fa82016-06-21 09:36:22 -0400550
551 memset(coal, 0, sizeof(struct ethtool_coalesce));
Sudarsana Reddy Kallurud2890de2016-06-28 02:10:59 -0400552 edev->ops->common->get_coalesce(edev->cdev, &rxc, &txc);
553
554 coal->rx_coalesce_usecs = rxc;
555 coal->tx_coalesce_usecs = txc;
Sudarsana Reddy Kallurud552fa82016-06-21 09:36:22 -0400556
557 return 0;
558}
559
560static int qede_set_coalesce(struct net_device *dev,
561 struct ethtool_coalesce *coal)
562{
563 struct qede_dev *edev = netdev_priv(dev);
564 int i, rc = 0;
565 u16 rxc, txc;
566 u8 sb_id;
567
568 if (!netif_running(dev)) {
569 DP_INFO(edev, "Interface is down\n");
570 return -EINVAL;
571 }
572
573 if (coal->rx_coalesce_usecs > QED_COALESCE_MAX ||
574 coal->tx_coalesce_usecs > QED_COALESCE_MAX) {
575 DP_INFO(edev,
576 "Can't support requested %s coalesce value [max supported value %d]\n",
577 coal->rx_coalesce_usecs > QED_COALESCE_MAX ? "rx"
578 : "tx",
579 QED_COALESCE_MAX);
580 return -EINVAL;
581 }
582
583 rxc = (u16)coal->rx_coalesce_usecs;
584 txc = (u16)coal->tx_coalesce_usecs;
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400585 for_each_queue(i) {
Sudarsana Reddy Kallurud552fa82016-06-21 09:36:22 -0400586 sb_id = edev->fp_array[i].sb_info->igu_sb_id;
587 rc = edev->ops->common->set_coalesce(edev->cdev, rxc, txc,
588 (u8)i, sb_id);
589 if (rc) {
590 DP_INFO(edev, "Set coalesce error, rc = %d\n", rc);
591 return rc;
592 }
593 }
594
595 return rc;
596}
597
Sudarsana Kalluru01ef7e02015-11-30 12:25:02 +0200598static void qede_get_ringparam(struct net_device *dev,
599 struct ethtool_ringparam *ering)
600{
601 struct qede_dev *edev = netdev_priv(dev);
602
603 ering->rx_max_pending = NUM_RX_BDS_MAX;
604 ering->rx_pending = edev->q_num_rx_buffers;
605 ering->tx_max_pending = NUM_TX_BDS_MAX;
606 ering->tx_pending = edev->q_num_tx_buffers;
607}
608
609static int qede_set_ringparam(struct net_device *dev,
610 struct ethtool_ringparam *ering)
611{
612 struct qede_dev *edev = netdev_priv(dev);
613
614 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
615 "Set ring params command parameters: rx_pending = %d, tx_pending = %d\n",
616 ering->rx_pending, ering->tx_pending);
617
618 /* Validate legality of configuration */
619 if (ering->rx_pending > NUM_RX_BDS_MAX ||
620 ering->rx_pending < NUM_RX_BDS_MIN ||
621 ering->tx_pending > NUM_TX_BDS_MAX ||
622 ering->tx_pending < NUM_TX_BDS_MIN) {
623 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
624 "Can only support Rx Buffer size [0%08x,...,0x%08x] and Tx Buffer size [0x%08x,...,0x%08x]\n",
625 NUM_RX_BDS_MIN, NUM_RX_BDS_MAX,
626 NUM_TX_BDS_MIN, NUM_TX_BDS_MAX);
627 return -EINVAL;
628 }
629
630 /* Change ring size and re-load */
631 edev->q_num_rx_buffers = ering->rx_pending;
632 edev->q_num_tx_buffers = ering->tx_pending;
633
634 if (netif_running(edev->ndev))
635 qede_reload(edev, NULL, NULL);
636
637 return 0;
638}
639
Sudarsana Kalluru0f7db142015-11-30 12:25:06 +0200640static void qede_get_pauseparam(struct net_device *dev,
641 struct ethtool_pauseparam *epause)
642{
643 struct qede_dev *edev = netdev_priv(dev);
644 struct qed_link_output current_link;
645
646 memset(&current_link, 0, sizeof(current_link));
647 edev->ops->common->get_link(edev->cdev, &current_link);
648
649 if (current_link.pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
650 epause->autoneg = true;
651 if (current_link.pause_config & QED_LINK_PAUSE_RX_ENABLE)
652 epause->rx_pause = true;
653 if (current_link.pause_config & QED_LINK_PAUSE_TX_ENABLE)
654 epause->tx_pause = true;
655
656 DP_VERBOSE(edev, QED_MSG_DEBUG,
657 "ethtool_pauseparam: cmd %d autoneg %d rx_pause %d tx_pause %d\n",
658 epause->cmd, epause->autoneg, epause->rx_pause,
659 epause->tx_pause);
660}
661
662static int qede_set_pauseparam(struct net_device *dev,
663 struct ethtool_pauseparam *epause)
664{
665 struct qede_dev *edev = netdev_priv(dev);
666 struct qed_link_params params;
667 struct qed_link_output current_link;
668
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300669 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
Sudarsana Kalluru0f7db142015-11-30 12:25:06 +0200670 DP_INFO(edev,
Yuval Mintzfe7cd2b2016-04-22 08:41:03 +0300671 "Pause settings are not allowed to be changed\n");
Sudarsana Kalluru0f7db142015-11-30 12:25:06 +0200672 return -EOPNOTSUPP;
673 }
674
675 memset(&current_link, 0, sizeof(current_link));
676 edev->ops->common->get_link(edev->cdev, &current_link);
677
678 memset(&params, 0, sizeof(params));
679 params.override_flags |= QED_LINK_OVERRIDE_PAUSE_CONFIG;
680 if (epause->autoneg) {
Yuval Mintzd194fd22016-08-19 08:34:57 +0300681 if (!(current_link.supported_caps & QED_LM_Autoneg_BIT)) {
Sudarsana Kalluru0f7db142015-11-30 12:25:06 +0200682 DP_INFO(edev, "autoneg not supported\n");
683 return -EINVAL;
684 }
685 params.pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
686 }
687 if (epause->rx_pause)
688 params.pause_config |= QED_LINK_PAUSE_RX_ENABLE;
689 if (epause->tx_pause)
690 params.pause_config |= QED_LINK_PAUSE_TX_ENABLE;
691
692 params.link_up = true;
693 edev->ops->common->set_link(edev->cdev, &params);
694
695 return 0;
696}
697
Sudarsana Kalluru133fac02015-10-26 11:02:34 +0200698static void qede_update_mtu(struct qede_dev *edev, union qede_reload_args *args)
699{
700 edev->ndev->mtu = args->mtu;
701}
702
703/* Netdevice NDOs */
704#define ETH_MAX_JUMBO_PACKET_SIZE 9600
705#define ETH_MIN_PACKET_SIZE 60
706int qede_change_mtu(struct net_device *ndev, int new_mtu)
707{
708 struct qede_dev *edev = netdev_priv(ndev);
709 union qede_reload_args args;
710
711 if ((new_mtu > ETH_MAX_JUMBO_PACKET_SIZE) ||
712 ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) {
713 DP_ERR(edev, "Can't support requested MTU size\n");
714 return -EINVAL;
715 }
716
717 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
718 "Configuring MTU size of %d\n", new_mtu);
719
720 /* Set the mtu field and re-start the interface if needed*/
721 args.mtu = new_mtu;
722
723 if (netif_running(edev->ndev))
724 qede_reload(edev, &qede_update_mtu, &args);
725
726 qede_update_mtu(edev, &args);
727
728 return 0;
729}
730
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200731static void qede_get_channels(struct net_device *dev,
732 struct ethtool_channels *channels)
733{
734 struct qede_dev *edev = netdev_priv(dev);
735
736 channels->max_combined = QEDE_MAX_RSS_CNT(edev);
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400737 channels->combined_count = QEDE_QUEUE_CNT(edev) - edev->fp_num_tx -
738 edev->fp_num_rx;
739 channels->tx_count = edev->fp_num_tx;
740 channels->rx_count = edev->fp_num_rx;
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200741}
742
743static int qede_set_channels(struct net_device *dev,
744 struct ethtool_channels *channels)
745{
746 struct qede_dev *edev = netdev_priv(dev);
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400747 u32 count;
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200748
749 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
750 "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
751 channels->rx_count, channels->tx_count,
752 channels->other_count, channels->combined_count);
753
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400754 count = channels->rx_count + channels->tx_count +
755 channels->combined_count;
756
757 /* We don't support `other' channels */
758 if (channels->other_count) {
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200759 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
760 "command parameters not supported\n");
761 return -EINVAL;
762 }
763
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400764 if (!(channels->combined_count || (channels->rx_count &&
765 channels->tx_count))) {
766 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
767 "need to request at least one transmit and one receive channel\n");
768 return -EINVAL;
769 }
770
771 if (count > QEDE_MAX_RSS_CNT(edev)) {
772 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
773 "requested channels = %d max supported channels = %d\n",
774 count, QEDE_MAX_RSS_CNT(edev));
775 return -EINVAL;
776 }
777
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200778 /* Check if there was a change in the active parameters */
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400779 if ((count == QEDE_QUEUE_CNT(edev)) &&
780 (channels->tx_count == edev->fp_num_tx) &&
781 (channels->rx_count == edev->fp_num_rx)) {
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200782 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
783 "No change in active parameters\n");
784 return 0;
785 }
786
787 /* We need the number of queues to be divisible between the hwfns */
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400788 if ((count % edev->dev_info.common.num_hwfns) ||
789 (channels->tx_count % edev->dev_info.common.num_hwfns) ||
790 (channels->rx_count % edev->dev_info.common.num_hwfns)) {
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200791 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400792 "Number of channels must be divisible by %04x\n",
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200793 edev->dev_info.common.num_hwfns);
794 return -EINVAL;
795 }
796
797 /* Set number of queues and reload if necessary */
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400798 edev->req_queues = count;
799 edev->req_num_tx = channels->tx_count;
800 edev->req_num_rx = channels->rx_count;
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +0200801 if (netif_running(dev))
802 qede_reload(edev, NULL, NULL);
803
804 return 0;
805}
806
Sudarsana Kalluru3d971cb2015-11-30 12:25:04 +0200807static int qede_set_phys_id(struct net_device *dev,
808 enum ethtool_phys_id_state state)
809{
810 struct qede_dev *edev = netdev_priv(dev);
811 u8 led_state = 0;
812
813 switch (state) {
814 case ETHTOOL_ID_ACTIVE:
815 return 1; /* cycle on/off once per second */
816
817 case ETHTOOL_ID_ON:
818 led_state = QED_LED_MODE_ON;
819 break;
820
821 case ETHTOOL_ID_OFF:
822 led_state = QED_LED_MODE_OFF;
823 break;
824
825 case ETHTOOL_ID_INACTIVE:
826 led_state = QED_LED_MODE_RESTORE;
827 break;
828 }
829
830 edev->ops->common->set_led(edev->cdev, led_state);
831
832 return 0;
833}
834
Sudarsana Reddy Kalluru961acde2016-04-10 12:43:01 +0300835static int qede_get_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
836{
837 info->data = RXH_IP_SRC | RXH_IP_DST;
838
839 switch (info->flow_type) {
840 case TCP_V4_FLOW:
841 case TCP_V6_FLOW:
842 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
843 break;
844 case UDP_V4_FLOW:
845 if (edev->rss_params.rss_caps & QED_RSS_IPV4_UDP)
846 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
847 break;
848 case UDP_V6_FLOW:
849 if (edev->rss_params.rss_caps & QED_RSS_IPV6_UDP)
850 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
851 break;
852 case IPV4_FLOW:
853 case IPV6_FLOW:
854 break;
855 default:
856 info->data = 0;
857 break;
858 }
859
860 return 0;
861}
862
863static int qede_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
864 u32 *rules __always_unused)
865{
866 struct qede_dev *edev = netdev_priv(dev);
867
868 switch (info->cmd) {
869 case ETHTOOL_GRXRINGS:
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -0400870 info->data = QEDE_RSS_COUNT(edev);
Sudarsana Reddy Kalluru961acde2016-04-10 12:43:01 +0300871 return 0;
872 case ETHTOOL_GRXFH:
873 return qede_get_rss_flags(edev, info);
874 default:
875 DP_ERR(edev, "Command parameters not supported\n");
876 return -EOPNOTSUPP;
877 }
878}
879
880static int qede_set_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
881{
882 struct qed_update_vport_params vport_update_params;
883 u8 set_caps = 0, clr_caps = 0;
884
885 DP_VERBOSE(edev, QED_MSG_DEBUG,
886 "Set rss flags command parameters: flow type = %d, data = %llu\n",
887 info->flow_type, info->data);
888
889 switch (info->flow_type) {
890 case TCP_V4_FLOW:
891 case TCP_V6_FLOW:
892 /* For TCP only 4-tuple hash is supported */
893 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST |
894 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
895 DP_INFO(edev, "Command parameters not supported\n");
896 return -EINVAL;
897 }
898 return 0;
899 case UDP_V4_FLOW:
900 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
901 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
902 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
903 set_caps = QED_RSS_IPV4_UDP;
904 DP_VERBOSE(edev, QED_MSG_DEBUG,
905 "UDP 4-tuple enabled\n");
906 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
907 clr_caps = QED_RSS_IPV4_UDP;
908 DP_VERBOSE(edev, QED_MSG_DEBUG,
909 "UDP 4-tuple disabled\n");
910 } else {
911 return -EINVAL;
912 }
913 break;
914 case UDP_V6_FLOW:
915 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
916 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
917 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
918 set_caps = QED_RSS_IPV6_UDP;
919 DP_VERBOSE(edev, QED_MSG_DEBUG,
920 "UDP 4-tuple enabled\n");
921 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
922 clr_caps = QED_RSS_IPV6_UDP;
923 DP_VERBOSE(edev, QED_MSG_DEBUG,
924 "UDP 4-tuple disabled\n");
925 } else {
926 return -EINVAL;
927 }
928 break;
929 case IPV4_FLOW:
930 case IPV6_FLOW:
931 /* For IP only 2-tuple hash is supported */
932 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST)) {
933 DP_INFO(edev, "Command parameters not supported\n");
934 return -EINVAL;
935 }
936 return 0;
937 case SCTP_V4_FLOW:
938 case AH_ESP_V4_FLOW:
939 case AH_V4_FLOW:
940 case ESP_V4_FLOW:
941 case SCTP_V6_FLOW:
942 case AH_ESP_V6_FLOW:
943 case AH_V6_FLOW:
944 case ESP_V6_FLOW:
945 case IP_USER_FLOW:
946 case ETHER_FLOW:
947 /* RSS is not supported for these protocols */
948 if (info->data) {
949 DP_INFO(edev, "Command parameters not supported\n");
950 return -EINVAL;
951 }
952 return 0;
953 default:
954 return -EINVAL;
955 }
956
957 /* No action is needed if there is no change in the rss capability */
958 if (edev->rss_params.rss_caps == ((edev->rss_params.rss_caps &
959 ~clr_caps) | set_caps))
960 return 0;
961
962 /* Update internal configuration */
963 edev->rss_params.rss_caps = (edev->rss_params.rss_caps & ~clr_caps) |
964 set_caps;
965 edev->rss_params_inited |= QEDE_RSS_CAPS_INITED;
966
967 /* Re-configure if possible */
968 if (netif_running(edev->ndev)) {
969 memset(&vport_update_params, 0, sizeof(vport_update_params));
970 vport_update_params.update_rss_flg = 1;
971 vport_update_params.vport_id = 0;
972 memcpy(&vport_update_params.rss_params, &edev->rss_params,
973 sizeof(vport_update_params.rss_params));
974 return edev->ops->vport_update(edev->cdev,
975 &vport_update_params);
976 }
977
978 return 0;
979}
980
981static int qede_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
982{
983 struct qede_dev *edev = netdev_priv(dev);
984
985 switch (info->cmd) {
986 case ETHTOOL_SRXFH:
987 return qede_set_rss_flags(edev, info);
988 default:
989 DP_INFO(edev, "Command parameters not supported\n");
990 return -EOPNOTSUPP;
991 }
992}
993
994static u32 qede_get_rxfh_indir_size(struct net_device *dev)
995{
996 return QED_RSS_IND_TABLE_SIZE;
997}
998
999static u32 qede_get_rxfh_key_size(struct net_device *dev)
1000{
1001 struct qede_dev *edev = netdev_priv(dev);
1002
1003 return sizeof(edev->rss_params.rss_key);
1004}
1005
1006static int qede_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, u8 *hfunc)
1007{
1008 struct qede_dev *edev = netdev_priv(dev);
1009 int i;
1010
1011 if (hfunc)
1012 *hfunc = ETH_RSS_HASH_TOP;
1013
1014 if (!indir)
1015 return 0;
1016
1017 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
1018 indir[i] = edev->rss_params.rss_ind_table[i];
1019
1020 if (key)
1021 memcpy(key, edev->rss_params.rss_key,
1022 qede_get_rxfh_key_size(dev));
1023
1024 return 0;
1025}
1026
1027static int qede_set_rxfh(struct net_device *dev, const u32 *indir,
1028 const u8 *key, const u8 hfunc)
1029{
1030 struct qed_update_vport_params vport_update_params;
1031 struct qede_dev *edev = netdev_priv(dev);
1032 int i;
1033
1034 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1035 return -EOPNOTSUPP;
1036
1037 if (!indir && !key)
1038 return 0;
1039
1040 if (indir) {
1041 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
1042 edev->rss_params.rss_ind_table[i] = indir[i];
1043 edev->rss_params_inited |= QEDE_RSS_INDIR_INITED;
1044 }
1045
1046 if (key) {
1047 memcpy(&edev->rss_params.rss_key, key,
1048 qede_get_rxfh_key_size(dev));
1049 edev->rss_params_inited |= QEDE_RSS_KEY_INITED;
1050 }
1051
1052 if (netif_running(edev->ndev)) {
1053 memset(&vport_update_params, 0, sizeof(vport_update_params));
1054 vport_update_params.update_rss_flg = 1;
1055 vport_update_params.vport_id = 0;
1056 memcpy(&vport_update_params.rss_params, &edev->rss_params,
1057 sizeof(vport_update_params.rss_params));
1058 return edev->ops->vport_update(edev->cdev,
1059 &vport_update_params);
1060 }
1061
1062 return 0;
1063}
1064
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001065/* This function enables the interrupt generation and the NAPI on the device */
1066static void qede_netif_start(struct qede_dev *edev)
1067{
1068 int i;
1069
1070 if (!netif_running(edev->ndev))
1071 return;
1072
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -04001073 for_each_queue(i) {
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001074 /* Update and reenable interrupts */
1075 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_ENABLE, 1);
1076 napi_enable(&edev->fp_array[i].napi);
1077 }
1078}
1079
1080/* This function disables the NAPI and the interrupt generation on the device */
1081static void qede_netif_stop(struct qede_dev *edev)
1082{
1083 int i;
1084
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -04001085 for_each_queue(i) {
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001086 napi_disable(&edev->fp_array[i].napi);
1087 /* Disable interrupts */
1088 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_DISABLE, 0);
1089 }
1090}
1091
1092static int qede_selftest_transmit_traffic(struct qede_dev *edev,
1093 struct sk_buff *skb)
1094{
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -04001095 struct qede_tx_queue *txq = NULL;
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001096 struct eth_tx_1st_bd *first_bd;
1097 dma_addr_t mapping;
1098 int i, idx, val;
1099
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -04001100 for_each_queue(i) {
1101 if (edev->fp_array[i].type & QEDE_FASTPATH_TX) {
1102 txq = edev->fp_array[i].txqs;
1103 break;
1104 }
1105 }
1106
1107 if (!txq) {
1108 DP_NOTICE(edev, "Tx path is not available\n");
1109 return -1;
1110 }
1111
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001112 /* Fill the entry in the SW ring and the BDs in the FW ring */
1113 idx = txq->sw_tx_prod & NUM_TX_BDS_MAX;
1114 txq->sw_tx_ring[idx].skb = skb;
1115 first_bd = qed_chain_produce(&txq->tx_pbl);
1116 memset(first_bd, 0, sizeof(*first_bd));
1117 val = 1 << ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT;
1118 first_bd->data.bd_flags.bitfields = val;
Yuval Mintz351a4ded2016-06-02 10:23:29 +03001119 val = skb->len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK;
1120 first_bd->data.bitfields |= (val << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT);
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001121
1122 /* Map skb linear data for DMA and set in the first BD */
1123 mapping = dma_map_single(&edev->pdev->dev, skb->data,
1124 skb_headlen(skb), DMA_TO_DEVICE);
1125 if (unlikely(dma_mapping_error(&edev->pdev->dev, mapping))) {
1126 DP_NOTICE(edev, "SKB mapping failed\n");
1127 return -ENOMEM;
1128 }
1129 BD_SET_UNMAP_ADDR_LEN(first_bd, mapping, skb_headlen(skb));
1130
1131 /* update the first BD with the actual num BDs */
1132 first_bd->data.nbds = 1;
1133 txq->sw_tx_prod++;
1134 /* 'next page' entries are counted in the producer value */
1135 val = cpu_to_le16(qed_chain_get_prod_idx(&txq->tx_pbl));
1136 txq->tx_db.data.bd_prod = val;
1137
1138 /* wmb makes sure that the BDs data is updated before updating the
1139 * producer, otherwise FW may read old data from the BDs.
1140 */
1141 wmb();
1142 barrier();
1143 writel(txq->tx_db.raw, txq->doorbell_addr);
1144
1145 /* mmiowb is needed to synchronize doorbell writes from more than one
1146 * processor. It guarantees that the write arrives to the device before
1147 * the queue lock is released and another start_xmit is called (possibly
1148 * on another CPU). Without this barrier, the next doorbell can bypass
1149 * this doorbell. This is applicable to IA64/Altix systems.
1150 */
1151 mmiowb();
1152
1153 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1154 if (qede_txq_has_work(txq))
1155 break;
1156 usleep_range(100, 200);
1157 }
1158
1159 if (!qede_txq_has_work(txq)) {
1160 DP_NOTICE(edev, "Tx completion didn't happen\n");
1161 return -1;
1162 }
1163
1164 first_bd = (struct eth_tx_1st_bd *)qed_chain_consume(&txq->tx_pbl);
1165 dma_unmap_page(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
1166 BD_UNMAP_LEN(first_bd), DMA_TO_DEVICE);
1167 txq->sw_tx_cons++;
1168 txq->sw_tx_ring[idx].skb = NULL;
1169
1170 return 0;
1171}
1172
1173static int qede_selftest_receive_traffic(struct qede_dev *edev)
1174{
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001175 u16 hw_comp_cons, sw_comp_cons, sw_rx_index, len;
1176 struct eth_fast_path_rx_reg_cqe *fp_cqe;
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -04001177 struct qede_rx_queue *rxq = NULL;
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001178 struct sw_rx_data *sw_rx_data;
1179 union eth_rx_cqe *cqe;
1180 u8 *data_ptr;
1181 int i;
1182
Sudarsana Reddy Kalluru9a4d7e82016-08-23 10:56:55 -04001183 for_each_queue(i) {
1184 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
1185 rxq = edev->fp_array[i].rxq;
1186 break;
1187 }
1188 }
1189
1190 if (!rxq) {
1191 DP_NOTICE(edev, "Rx path is not available\n");
1192 return -1;
1193 }
1194
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001195 /* The packet is expected to receive on rx-queue 0 even though RSS is
1196 * enabled. This is because the queue 0 is configured as the default
1197 * queue and that the loopback traffic is not IP.
1198 */
1199 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1200 if (qede_has_rx_work(rxq))
1201 break;
1202 usleep_range(100, 200);
1203 }
1204
1205 if (!qede_has_rx_work(rxq)) {
1206 DP_NOTICE(edev, "Failed to receive the traffic\n");
1207 return -1;
1208 }
1209
1210 hw_comp_cons = le16_to_cpu(*rxq->hw_cons_ptr);
1211 sw_comp_cons = qed_chain_get_cons_idx(&rxq->rx_comp_ring);
1212
1213 /* Memory barrier to prevent the CPU from doing speculative reads of CQE
1214 * / BD before reading hw_comp_cons. If the CQE is read before it is
1215 * written by FW, then FW writes CQE and SB, and then the CPU reads the
1216 * hw_comp_cons, it will use an old CQE.
1217 */
1218 rmb();
1219
1220 /* Get the CQE from the completion ring */
1221 cqe = (union eth_rx_cqe *)qed_chain_consume(&rxq->rx_comp_ring);
1222
1223 /* Get the data from the SW ring */
1224 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX;
1225 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index];
1226 fp_cqe = &cqe->fast_path_regular;
1227 len = le16_to_cpu(fp_cqe->len_on_first_bd);
1228 data_ptr = (u8 *)(page_address(sw_rx_data->data) +
1229 fp_cqe->placement_offset + sw_rx_data->page_offset);
1230 for (i = ETH_HLEN; i < len; i++)
1231 if (data_ptr[i] != (unsigned char)(i & 0xff)) {
1232 DP_NOTICE(edev, "Loopback test failed\n");
1233 qede_recycle_rx_bd_ring(rxq, edev, 1);
1234 return -1;
1235 }
1236
1237 qede_recycle_rx_bd_ring(rxq, edev, 1);
1238
1239 return 0;
1240}
1241
1242static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
1243{
1244 struct qed_link_params link_params;
1245 struct sk_buff *skb = NULL;
1246 int rc = 0, i;
1247 u32 pkt_size;
1248 u8 *packet;
1249
1250 if (!netif_running(edev->ndev)) {
1251 DP_NOTICE(edev, "Interface is down\n");
1252 return -EINVAL;
1253 }
1254
1255 qede_netif_stop(edev);
1256
1257 /* Bring up the link in Loopback mode */
1258 memset(&link_params, 0, sizeof(link_params));
1259 link_params.link_up = true;
1260 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1261 link_params.loopback_mode = loopback_mode;
1262 edev->ops->common->set_link(edev->cdev, &link_params);
1263
1264 /* Wait for loopback configuration to apply */
1265 msleep_interruptible(500);
1266
1267 /* prepare the loopback packet */
1268 pkt_size = edev->ndev->mtu + ETH_HLEN;
1269
1270 skb = netdev_alloc_skb(edev->ndev, pkt_size);
1271 if (!skb) {
1272 DP_INFO(edev, "Can't allocate skb\n");
1273 rc = -ENOMEM;
1274 goto test_loopback_exit;
1275 }
1276 packet = skb_put(skb, pkt_size);
1277 ether_addr_copy(packet, edev->ndev->dev_addr);
1278 ether_addr_copy(packet + ETH_ALEN, edev->ndev->dev_addr);
1279 memset(packet + (2 * ETH_ALEN), 0x77, (ETH_HLEN - (2 * ETH_ALEN)));
1280 for (i = ETH_HLEN; i < pkt_size; i++)
1281 packet[i] = (unsigned char)(i & 0xff);
1282
1283 rc = qede_selftest_transmit_traffic(edev, skb);
1284 if (rc)
1285 goto test_loopback_exit;
1286
1287 rc = qede_selftest_receive_traffic(edev);
1288 if (rc)
1289 goto test_loopback_exit;
1290
1291 DP_VERBOSE(edev, NETIF_MSG_RX_STATUS, "Loopback test successful\n");
1292
1293test_loopback_exit:
1294 dev_kfree_skb(skb);
1295
1296 /* Bring up the link in Normal mode */
1297 memset(&link_params, 0, sizeof(link_params));
1298 link_params.link_up = true;
1299 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1300 link_params.loopback_mode = QED_LINK_LOOPBACK_NONE;
1301 edev->ops->common->set_link(edev->cdev, &link_params);
1302
1303 /* Wait for loopback configuration to apply */
1304 msleep_interruptible(500);
1305
1306 qede_netif_start(edev);
1307
1308 return rc;
1309}
1310
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -04001311static void qede_self_test(struct net_device *dev,
1312 struct ethtool_test *etest, u64 *buf)
1313{
1314 struct qede_dev *edev = netdev_priv(dev);
1315
1316 DP_VERBOSE(edev, QED_MSG_DEBUG,
1317 "Self-test command parameters: offline = %d, external_lb = %d\n",
1318 (etest->flags & ETH_TEST_FL_OFFLINE),
1319 (etest->flags & ETH_TEST_FL_EXTERNAL_LB) >> 2);
1320
1321 memset(buf, 0, sizeof(u64) * QEDE_ETHTOOL_TEST_MAX);
1322
Sudarsana Reddy Kalluru16f46bf2016-04-28 20:20:54 -04001323 if (etest->flags & ETH_TEST_FL_OFFLINE) {
1324 if (qede_selftest_run_loopback(edev,
1325 QED_LINK_LOOPBACK_INT_PHY)) {
1326 buf[QEDE_ETHTOOL_INT_LOOPBACK] = 1;
1327 etest->flags |= ETH_TEST_FL_FAILED;
1328 }
1329 }
1330
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -04001331 if (edev->ops->common->selftest->selftest_interrupt(edev->cdev)) {
1332 buf[QEDE_ETHTOOL_INTERRUPT_TEST] = 1;
1333 etest->flags |= ETH_TEST_FL_FAILED;
1334 }
1335
1336 if (edev->ops->common->selftest->selftest_memory(edev->cdev)) {
1337 buf[QEDE_ETHTOOL_MEMORY_TEST] = 1;
1338 etest->flags |= ETH_TEST_FL_FAILED;
1339 }
1340
1341 if (edev->ops->common->selftest->selftest_register(edev->cdev)) {
1342 buf[QEDE_ETHTOOL_REGISTER_TEST] = 1;
1343 etest->flags |= ETH_TEST_FL_FAILED;
1344 }
1345
1346 if (edev->ops->common->selftest->selftest_clock(edev->cdev)) {
1347 buf[QEDE_ETHTOOL_CLOCK_TEST] = 1;
1348 etest->flags |= ETH_TEST_FL_FAILED;
1349 }
1350}
1351
Manish Chopra3d789992016-06-30 02:35:21 -04001352static int qede_set_tunable(struct net_device *dev,
1353 const struct ethtool_tunable *tuna,
1354 const void *data)
1355{
1356 struct qede_dev *edev = netdev_priv(dev);
1357 u32 val;
1358
1359 switch (tuna->id) {
1360 case ETHTOOL_RX_COPYBREAK:
1361 val = *(u32 *)data;
1362 if (val < QEDE_MIN_PKT_LEN || val > QEDE_RX_HDR_SIZE) {
1363 DP_VERBOSE(edev, QED_MSG_DEBUG,
1364 "Invalid rx copy break value, range is [%u, %u]",
1365 QEDE_MIN_PKT_LEN, QEDE_RX_HDR_SIZE);
1366 return -EINVAL;
1367 }
1368
1369 edev->rx_copybreak = *(u32 *)data;
1370 break;
1371 default:
1372 return -EOPNOTSUPP;
1373 }
1374
1375 return 0;
1376}
1377
1378static int qede_get_tunable(struct net_device *dev,
1379 const struct ethtool_tunable *tuna, void *data)
1380{
1381 struct qede_dev *edev = netdev_priv(dev);
1382
1383 switch (tuna->id) {
1384 case ETHTOOL_RX_COPYBREAK:
1385 *(u32 *)data = edev->rx_copybreak;
1386 break;
1387 default:
1388 return -EOPNOTSUPP;
1389 }
1390
1391 return 0;
1392}
1393
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001394static const struct ethtool_ops qede_ethtool_ops = {
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -04001395 .get_link_ksettings = qede_get_link_ksettings,
1396 .set_link_ksettings = qede_set_link_ksettings,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001397 .get_drvinfo = qede_get_drvinfo,
1398 .get_msglevel = qede_get_msglevel,
1399 .set_msglevel = qede_set_msglevel,
Sudarsana Kalluru32a7a572015-11-30 12:25:05 +02001400 .nway_reset = qede_nway_reset,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001401 .get_link = qede_get_link,
Sudarsana Reddy Kallurud552fa82016-06-21 09:36:22 -04001402 .get_coalesce = qede_get_coalesce,
1403 .set_coalesce = qede_set_coalesce,
Sudarsana Kalluru01ef7e02015-11-30 12:25:02 +02001404 .get_ringparam = qede_get_ringparam,
1405 .set_ringparam = qede_set_ringparam,
Sudarsana Kalluru0f7db142015-11-30 12:25:06 +02001406 .get_pauseparam = qede_get_pauseparam,
1407 .set_pauseparam = qede_set_pauseparam,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001408 .get_strings = qede_get_strings,
Sudarsana Kalluru3d971cb2015-11-30 12:25:04 +02001409 .set_phys_id = qede_set_phys_id,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001410 .get_ethtool_stats = qede_get_ethtool_stats,
Yuval Mintzf3e72102016-04-22 08:41:02 +03001411 .get_priv_flags = qede_get_priv_flags,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001412 .get_sset_count = qede_get_sset_count,
Sudarsana Reddy Kalluru961acde2016-04-10 12:43:01 +03001413 .get_rxnfc = qede_get_rxnfc,
1414 .set_rxnfc = qede_set_rxnfc,
1415 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
1416 .get_rxfh_key_size = qede_get_rxfh_key_size,
1417 .get_rxfh = qede_get_rxfh,
1418 .set_rxfh = qede_set_rxfh,
Sudarsana Kalluru8edf0492015-11-30 12:25:01 +02001419 .get_channels = qede_get_channels,
1420 .set_channels = qede_set_channels,
Sudarsana Reddy Kalluru3044a022016-04-28 20:20:53 -04001421 .self_test = qede_self_test,
Manish Chopra3d789992016-06-30 02:35:21 -04001422 .get_tunable = qede_get_tunable,
1423 .set_tunable = qede_set_tunable,
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001424};
1425
Yuval Mintzfefb0202016-05-11 16:36:19 +03001426static const struct ethtool_ops qede_vf_ethtool_ops = {
Sudarsana Reddy Kalluru054c67d2016-08-09 03:51:23 -04001427 .get_link_ksettings = qede_get_link_ksettings,
Yuval Mintzfefb0202016-05-11 16:36:19 +03001428 .get_drvinfo = qede_get_drvinfo,
1429 .get_msglevel = qede_get_msglevel,
1430 .set_msglevel = qede_set_msglevel,
1431 .get_link = qede_get_link,
1432 .get_ringparam = qede_get_ringparam,
1433 .set_ringparam = qede_set_ringparam,
1434 .get_strings = qede_get_strings,
1435 .get_ethtool_stats = qede_get_ethtool_stats,
1436 .get_priv_flags = qede_get_priv_flags,
1437 .get_sset_count = qede_get_sset_count,
1438 .get_rxnfc = qede_get_rxnfc,
1439 .set_rxnfc = qede_set_rxnfc,
1440 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
1441 .get_rxfh_key_size = qede_get_rxfh_key_size,
1442 .get_rxfh = qede_get_rxfh,
1443 .set_rxfh = qede_set_rxfh,
1444 .get_channels = qede_get_channels,
1445 .set_channels = qede_set_channels,
Manish Chopra3d789992016-06-30 02:35:21 -04001446 .get_tunable = qede_get_tunable,
1447 .set_tunable = qede_set_tunable,
Yuval Mintzfefb0202016-05-11 16:36:19 +03001448};
1449
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001450void qede_set_ethtool_ops(struct net_device *dev)
1451{
Yuval Mintzfefb0202016-05-11 16:36:19 +03001452 struct qede_dev *edev = netdev_priv(dev);
1453
1454 if (IS_VF(edev))
1455 dev->ethtool_ops = &qede_vf_ethtool_ops;
1456 else
1457 dev->ethtool_ops = &qede_ethtool_ops;
Sudarsana Kalluru133fac02015-10-26 11:02:34 +02001458}