blob: 44e3fa43af619334fbbea42b02008bd0f30ad06a [file] [log] [blame]
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 Intel Corporation.
5 *
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 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * The full GNU General Public License is included in this distribution in
20 * the file called "COPYING".
21 *
22 * Contact Information:
23 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *
26 ******************************************************************************/
27
28#ifdef CONFIG_DEBUG_FS
29
30#include <linux/fs.h>
31#include <linux/debugfs.h>
32
33#include "i40e.h"
34
35static struct dentry *i40e_dbg_root;
36
37/**
38 * i40e_dbg_find_vsi - searches for the vsi with the given seid
39 * @pf - the pf structure to search for the vsi
40 * @seid - seid of the vsi it is searching for
41 **/
42static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
43{
44 int i;
45
46 if (seid < 0)
47 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
48 else
49 for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
50 if (pf->vsi[i] && (pf->vsi[i]->seid == seid))
51 return pf->vsi[i];
52
53 return NULL;
54}
55
56/**
57 * i40e_dbg_find_veb - searches for the veb with the given seid
58 * @pf - the pf structure to search for the veb
59 * @seid - seid of the veb it is searching for
60 **/
61static struct i40e_veb *i40e_dbg_find_veb(struct i40e_pf *pf, int seid)
62{
63 int i;
64
65 if ((seid < I40E_BASE_VEB_SEID) ||
66 (seid > (I40E_BASE_VEB_SEID + I40E_MAX_VEB)))
67 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
68 else
69 for (i = 0; i < I40E_MAX_VEB; i++)
70 if (pf->veb[i] && pf->veb[i]->seid == seid)
71 return pf->veb[i];
72 return NULL;
73}
74
75/**************************************************************
76 * dump
77 * The dump entry in debugfs is for getting a data snapshow of
78 * the driver's current configuration and runtime details.
79 * When the filesystem entry is written, a snapshot is taken.
80 * When the entry is read, the most recent snapshot data is dumped.
81 **************************************************************/
82static char *i40e_dbg_dump_buf;
83static ssize_t i40e_dbg_dump_data_len;
84static ssize_t i40e_dbg_dump_buffer_len;
85
86/**
87 * i40e_dbg_dump_read - read the dump data
88 * @filp: the opened file
89 * @buffer: where to write the data for the user to read
90 * @count: the size of the user's buffer
91 * @ppos: file position offset
92 **/
93static ssize_t i40e_dbg_dump_read(struct file *filp, char __user *buffer,
94 size_t count, loff_t *ppos)
95{
96 int bytes_not_copied;
97 int len;
98
99 /* is *ppos bigger than the available data? */
100 if (*ppos >= i40e_dbg_dump_data_len || !i40e_dbg_dump_buf)
101 return 0;
102
103 /* be sure to not read beyond the end of available data */
104 len = min_t(int, count, (i40e_dbg_dump_data_len - *ppos));
105
106 bytes_not_copied = copy_to_user(buffer, &i40e_dbg_dump_buf[*ppos], len);
107 if (bytes_not_copied < 0)
108 return bytes_not_copied;
109
110 *ppos += len;
111 return len;
112}
113
114/**
115 * i40e_dbg_prep_dump_buf
116 * @pf: the pf we're working with
117 * @buflen: the desired buffer length
118 *
119 * Return positive if success, 0 if failed
120 **/
121static int i40e_dbg_prep_dump_buf(struct i40e_pf *pf, int buflen)
122{
123 /* if not already big enough, prep for re alloc */
124 if (i40e_dbg_dump_buffer_len && i40e_dbg_dump_buffer_len < buflen) {
125 kfree(i40e_dbg_dump_buf);
126 i40e_dbg_dump_buffer_len = 0;
127 i40e_dbg_dump_buf = NULL;
128 }
129
130 /* get a new buffer if needed */
131 if (!i40e_dbg_dump_buf) {
132 i40e_dbg_dump_buf = kzalloc(buflen, GFP_KERNEL);
133 if (i40e_dbg_dump_buf != NULL)
134 i40e_dbg_dump_buffer_len = buflen;
135 }
136
137 return i40e_dbg_dump_buffer_len;
138}
139
140/**
141 * i40e_dbg_dump_write - trigger a datadump snapshot
142 * @filp: the opened file
143 * @buffer: where to find the user's data
144 * @count: the length of the user's data
145 * @ppos: file position offset
146 *
147 * Any write clears the stats
148 **/
149static ssize_t i40e_dbg_dump_write(struct file *filp,
150 const char __user *buffer,
151 size_t count, loff_t *ppos)
152{
153 struct i40e_pf *pf = filp->private_data;
154 char dump_request_buf[16];
155 bool seid_found = false;
156 int bytes_not_copied;
157 long seid = -1;
158 int buflen = 0;
159 int i, ret;
160 int len;
161 u8 *p;
162
163 /* don't allow partial writes */
164 if (*ppos != 0)
165 return 0;
166 if (count >= sizeof(dump_request_buf))
167 return -ENOSPC;
168
169 bytes_not_copied = copy_from_user(dump_request_buf, buffer, count);
170 if (bytes_not_copied < 0)
171 return bytes_not_copied;
172 if (bytes_not_copied > 0)
173 count -= bytes_not_copied;
174 dump_request_buf[count] = '\0';
175
176 /* decode the SEID given to be dumped */
177 ret = kstrtol(dump_request_buf, 0, &seid);
178 if (ret < 0) {
179 dev_info(&pf->pdev->dev, "bad seid value '%s'\n",
180 dump_request_buf);
181 } else if (seid == 0) {
182 seid_found = true;
183
184 kfree(i40e_dbg_dump_buf);
185 i40e_dbg_dump_buffer_len = 0;
186 i40e_dbg_dump_data_len = 0;
187 i40e_dbg_dump_buf = NULL;
188 dev_info(&pf->pdev->dev, "debug buffer freed\n");
189
190 } else if (seid == pf->pf_seid || seid == 1) {
191 seid_found = true;
192
193 buflen = sizeof(struct i40e_pf);
194 buflen += (sizeof(struct i40e_aq_desc)
195 * (pf->hw.aq.num_arq_entries + pf->hw.aq.num_asq_entries));
196
197 if (i40e_dbg_prep_dump_buf(pf, buflen)) {
198 p = i40e_dbg_dump_buf;
199
200 len = sizeof(struct i40e_pf);
201 memcpy(p, pf, len);
202 p += len;
203
204 len = (sizeof(struct i40e_aq_desc)
205 * pf->hw.aq.num_asq_entries);
206 memcpy(p, pf->hw.aq.asq.desc, len);
207 p += len;
208
209 len = (sizeof(struct i40e_aq_desc)
210 * pf->hw.aq.num_arq_entries);
211 memcpy(p, pf->hw.aq.arq.desc, len);
212 p += len;
213
214 i40e_dbg_dump_data_len = buflen;
215 dev_info(&pf->pdev->dev,
216 "PF seid %ld dumped %d bytes\n",
217 seid, (int)i40e_dbg_dump_data_len);
218 }
219 } else if (seid >= I40E_BASE_VSI_SEID) {
220 struct i40e_vsi *vsi = NULL;
221 struct i40e_mac_filter *f;
222 int filter_count = 0;
223
224 mutex_lock(&pf->switch_mutex);
225 vsi = i40e_dbg_find_vsi(pf, seid);
226 if (!vsi) {
227 mutex_unlock(&pf->switch_mutex);
228 goto write_exit;
229 }
230
231 buflen = sizeof(struct i40e_vsi);
232 buflen += sizeof(struct i40e_q_vector) * vsi->num_q_vectors;
233 buflen += sizeof(struct i40e_ring) * 2 * vsi->num_queue_pairs;
234 buflen += sizeof(struct i40e_tx_buffer) * vsi->num_queue_pairs;
235 buflen += sizeof(struct i40e_rx_buffer) * vsi->num_queue_pairs;
236 list_for_each_entry(f, &vsi->mac_filter_list, list)
237 filter_count++;
238 buflen += sizeof(struct i40e_mac_filter) * filter_count;
239
240 if (i40e_dbg_prep_dump_buf(pf, buflen)) {
241 p = i40e_dbg_dump_buf;
242 seid_found = true;
243
244 len = sizeof(struct i40e_vsi);
245 memcpy(p, vsi, len);
246 p += len;
247
248 len = (sizeof(struct i40e_q_vector)
249 * vsi->num_q_vectors);
250 memcpy(p, vsi->q_vectors, len);
251 p += len;
252
253 len = (sizeof(struct i40e_ring) * vsi->num_queue_pairs);
254 memcpy(p, vsi->tx_rings, len);
255 p += len;
256 memcpy(p, vsi->rx_rings, len);
257 p += len;
258
259 for (i = 0; i < vsi->num_queue_pairs; i++) {
260 len = sizeof(struct i40e_tx_buffer);
261 memcpy(p, vsi->tx_rings[i].tx_bi, len);
262 p += len;
263 }
264 for (i = 0; i < vsi->num_queue_pairs; i++) {
265 len = sizeof(struct i40e_rx_buffer);
266 memcpy(p, vsi->rx_rings[i].rx_bi, len);
267 p += len;
268 }
269
270 /* macvlan filter list */
271 len = sizeof(struct i40e_mac_filter);
272 list_for_each_entry(f, &vsi->mac_filter_list, list) {
273 memcpy(p, f, len);
274 p += len;
275 }
276
277 i40e_dbg_dump_data_len = buflen;
278 dev_info(&pf->pdev->dev,
279 "VSI seid %ld dumped %d bytes\n",
280 seid, (int)i40e_dbg_dump_data_len);
281 }
282 mutex_unlock(&pf->switch_mutex);
283 } else if (seid >= I40E_BASE_VEB_SEID) {
284 struct i40e_veb *veb = NULL;
285
286 mutex_lock(&pf->switch_mutex);
287 veb = i40e_dbg_find_veb(pf, seid);
288 if (!veb) {
289 mutex_unlock(&pf->switch_mutex);
290 goto write_exit;
291 }
292
293 buflen = sizeof(struct i40e_veb);
294 if (i40e_dbg_prep_dump_buf(pf, buflen)) {
295 seid_found = true;
296 memcpy(i40e_dbg_dump_buf, veb, buflen);
297 i40e_dbg_dump_data_len = buflen;
298 dev_info(&pf->pdev->dev,
299 "VEB seid %ld dumped %d bytes\n",
300 seid, (int)i40e_dbg_dump_data_len);
301 }
302 mutex_unlock(&pf->switch_mutex);
303 }
304
305write_exit:
306 if (!seid_found)
307 dev_info(&pf->pdev->dev, "unknown seid %ld\n", seid);
308
309 return count;
310}
311
312static const struct file_operations i40e_dbg_dump_fops = {
313 .owner = THIS_MODULE,
314 .open = simple_open,
315 .read = i40e_dbg_dump_read,
316 .write = i40e_dbg_dump_write,
317};
318
319/**************************************************************
320 * command
321 * The command entry in debugfs is for giving the driver commands
322 * to be executed - these may be for changing the internal switch
323 * setup, adding or removing filters, or other things. Many of
324 * these will be useful for some forms of unit testing.
325 **************************************************************/
326static char i40e_dbg_command_buf[256] = "hello world";
327
328/**
329 * i40e_dbg_command_read - read for command datum
330 * @filp: the opened file
331 * @buffer: where to write the data for the user to read
332 * @count: the size of the user's buffer
333 * @ppos: file position offset
334 **/
335static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
336 size_t count, loff_t *ppos)
337{
338 struct i40e_pf *pf = filp->private_data;
339 int bytes_not_copied;
340 int buf_size = 256;
341 char *buf;
342 int len;
343
344 /* don't allow partial reads */
345 if (*ppos != 0)
346 return 0;
347 if (count < buf_size)
348 return -ENOSPC;
349
350 buf = kzalloc(buf_size, GFP_KERNEL);
351 if (!buf)
352 return -ENOSPC;
353
354 len = snprintf(buf, buf_size, "%s: %s\n",
355 pf->vsi[pf->lan_vsi]->netdev->name,
356 i40e_dbg_command_buf);
357
358 bytes_not_copied = copy_to_user(buffer, buf, len);
359 kfree(buf);
360
361 if (bytes_not_copied < 0)
362 return bytes_not_copied;
363
364 *ppos = len;
365 return len;
366}
367
368/**
369 * i40e_dbg_dump_vsi_seid - handles dump vsi seid write into pokem datum
370 * @pf: the i40e_pf created in command write
371 * @seid: the seid the user put in
372 **/
373static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
374{
375 struct rtnl_link_stats64 *nstat;
376 struct i40e_mac_filter *f;
377 struct i40e_vsi *vsi;
378 int i;
379
380 vsi = i40e_dbg_find_vsi(pf, seid);
381 if (!vsi) {
382 dev_info(&pf->pdev->dev,
383 "dump %d: seid not found\n", seid);
384 return;
385 }
386 dev_info(&pf->pdev->dev, "vsi seid %d\n", seid);
387 if (vsi->netdev)
388 dev_info(&pf->pdev->dev,
389 " netdev: name = %s\n",
390 vsi->netdev->name);
391 if (vsi->active_vlans)
392 dev_info(&pf->pdev->dev,
393 " vlgrp: & = %p\n", vsi->active_vlans);
394 dev_info(&pf->pdev->dev,
395 " netdev_registered = %i, current_netdev_flags = 0x%04x, state = %li flags = 0x%08lx\n",
396 vsi->netdev_registered,
397 vsi->current_netdev_flags, vsi->state, vsi->flags);
398 list_for_each_entry(f, &vsi->mac_filter_list, list) {
399 dev_info(&pf->pdev->dev,
400 " mac_filter_list: %pM vid=%d, is_netdev=%d is_vf=%d counter=%d\n",
401 f->macaddr, f->vlan, f->is_netdev, f->is_vf,
402 f->counter);
403 }
404 nstat = i40e_get_vsi_stats_struct(vsi);
405 dev_info(&pf->pdev->dev,
406 " net_stats: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
407 (long unsigned int)nstat->rx_packets,
408 (long unsigned int)nstat->rx_bytes,
409 (long unsigned int)nstat->rx_errors,
410 (long unsigned int)nstat->rx_dropped);
411 dev_info(&pf->pdev->dev,
412 " net_stats: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
413 (long unsigned int)nstat->tx_packets,
414 (long unsigned int)nstat->tx_bytes,
415 (long unsigned int)nstat->tx_errors,
416 (long unsigned int)nstat->tx_dropped);
417 dev_info(&pf->pdev->dev,
418 " net_stats: multicast = %lu, collisions = %lu\n",
419 (long unsigned int)nstat->multicast,
420 (long unsigned int)nstat->collisions);
421 dev_info(&pf->pdev->dev,
422 " net_stats: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
423 (long unsigned int)nstat->rx_length_errors,
424 (long unsigned int)nstat->rx_over_errors,
425 (long unsigned int)nstat->rx_crc_errors);
426 dev_info(&pf->pdev->dev,
427 " net_stats: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
428 (long unsigned int)nstat->rx_frame_errors,
429 (long unsigned int)nstat->rx_fifo_errors,
430 (long unsigned int)nstat->rx_missed_errors);
431 dev_info(&pf->pdev->dev,
432 " net_stats: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
433 (long unsigned int)nstat->tx_aborted_errors,
434 (long unsigned int)nstat->tx_carrier_errors,
435 (long unsigned int)nstat->tx_fifo_errors);
436 dev_info(&pf->pdev->dev,
437 " net_stats: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
438 (long unsigned int)nstat->tx_heartbeat_errors,
439 (long unsigned int)nstat->tx_window_errors);
440 dev_info(&pf->pdev->dev,
441 " net_stats: rx_compressed = %lu, tx_compressed = %lu\n",
442 (long unsigned int)nstat->rx_compressed,
443 (long unsigned int)nstat->tx_compressed);
444 dev_info(&pf->pdev->dev,
445 " net_stats_offsets: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
446 (long unsigned int)vsi->net_stats_offsets.rx_packets,
447 (long unsigned int)vsi->net_stats_offsets.rx_bytes,
448 (long unsigned int)vsi->net_stats_offsets.rx_errors,
449 (long unsigned int)vsi->net_stats_offsets.rx_dropped);
450 dev_info(&pf->pdev->dev,
451 " net_stats_offsets: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
452 (long unsigned int)vsi->net_stats_offsets.tx_packets,
453 (long unsigned int)vsi->net_stats_offsets.tx_bytes,
454 (long unsigned int)vsi->net_stats_offsets.tx_errors,
455 (long unsigned int)vsi->net_stats_offsets.tx_dropped);
456 dev_info(&pf->pdev->dev,
457 " net_stats_offsets: multicast = %lu, collisions = %lu\n",
458 (long unsigned int)vsi->net_stats_offsets.multicast,
459 (long unsigned int)vsi->net_stats_offsets.collisions);
460 dev_info(&pf->pdev->dev,
461 " net_stats_offsets: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
462 (long unsigned int)vsi->net_stats_offsets.rx_length_errors,
463 (long unsigned int)vsi->net_stats_offsets.rx_over_errors,
464 (long unsigned int)vsi->net_stats_offsets.rx_crc_errors);
465 dev_info(&pf->pdev->dev,
466 " net_stats_offsets: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
467 (long unsigned int)vsi->net_stats_offsets.rx_frame_errors,
468 (long unsigned int)vsi->net_stats_offsets.rx_fifo_errors,
469 (long unsigned int)vsi->net_stats_offsets.rx_missed_errors);
470 dev_info(&pf->pdev->dev,
471 " net_stats_offsets: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
472 (long unsigned int)vsi->net_stats_offsets.tx_aborted_errors,
473 (long unsigned int)vsi->net_stats_offsets.tx_carrier_errors,
474 (long unsigned int)vsi->net_stats_offsets.tx_fifo_errors);
475 dev_info(&pf->pdev->dev,
476 " net_stats_offsets: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
477 (long unsigned int)vsi->net_stats_offsets.tx_heartbeat_errors,
478 (long unsigned int)vsi->net_stats_offsets.tx_window_errors);
479 dev_info(&pf->pdev->dev,
480 " net_stats_offsets: rx_compressed = %lu, tx_compressed = %lu\n",
481 (long unsigned int)vsi->net_stats_offsets.rx_compressed,
482 (long unsigned int)vsi->net_stats_offsets.tx_compressed);
483 dev_info(&pf->pdev->dev,
484 " tx_restart = %d, tx_busy = %d, rx_buf_failed = %d, rx_page_failed = %d\n",
485 vsi->tx_restart, vsi->tx_busy,
486 vsi->rx_buf_failed, vsi->rx_page_failed);
487 if (vsi->rx_rings) {
488 for (i = 0; i < vsi->num_queue_pairs; i++) {
489 dev_info(&pf->pdev->dev,
490 " rx_rings[%i]: desc = %p\n",
491 i, vsi->rx_rings[i].desc);
492 dev_info(&pf->pdev->dev,
493 " rx_rings[%i]: dev = %p, netdev = %p, rx_bi = %p\n",
494 i, vsi->rx_rings[i].dev,
495 vsi->rx_rings[i].netdev,
496 vsi->rx_rings[i].rx_bi);
497 dev_info(&pf->pdev->dev,
498 " rx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
499 i, vsi->rx_rings[i].state,
500 vsi->rx_rings[i].queue_index,
501 vsi->rx_rings[i].reg_idx);
502 dev_info(&pf->pdev->dev,
503 " rx_rings[%i]: rx_hdr_len = %d, rx_buf_len = %d, dtype = %d\n",
504 i, vsi->rx_rings[i].rx_hdr_len,
505 vsi->rx_rings[i].rx_buf_len,
506 vsi->rx_rings[i].dtype);
507 dev_info(&pf->pdev->dev,
508 " rx_rings[%i]: hsplit = %d, next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
509 i, vsi->rx_rings[i].hsplit,
510 vsi->rx_rings[i].next_to_use,
511 vsi->rx_rings[i].next_to_clean,
512 vsi->rx_rings[i].ring_active);
513 dev_info(&pf->pdev->dev,
514 " rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n",
Alexander Duycka114d0a2013-09-28 06:00:43 +0000515 i, vsi->rx_rings[i].stats.packets,
516 vsi->rx_rings[i].stats.bytes,
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000517 vsi->rx_rings[i].rx_stats.non_eop_descs);
518 dev_info(&pf->pdev->dev,
519 " rx_rings[%i]: rx_stats: alloc_rx_page_failed = %lld, alloc_rx_buff_failed = %lld\n",
520 i,
521 vsi->rx_rings[i].rx_stats.alloc_rx_page_failed,
522 vsi->rx_rings[i].rx_stats.alloc_rx_buff_failed);
523 dev_info(&pf->pdev->dev,
524 " rx_rings[%i]: size = %i, dma = 0x%08lx\n",
525 i, vsi->rx_rings[i].size,
526 (long unsigned int)vsi->rx_rings[i].dma);
527 dev_info(&pf->pdev->dev,
528 " rx_rings[%i]: vsi = %p, q_vector = %p\n",
529 i, vsi->rx_rings[i].vsi,
530 vsi->rx_rings[i].q_vector);
531 }
532 }
533 if (vsi->tx_rings) {
534 for (i = 0; i < vsi->num_queue_pairs; i++) {
535 dev_info(&pf->pdev->dev,
536 " tx_rings[%i]: desc = %p\n",
537 i, vsi->tx_rings[i].desc);
538 dev_info(&pf->pdev->dev,
539 " tx_rings[%i]: dev = %p, netdev = %p, tx_bi = %p\n",
540 i, vsi->tx_rings[i].dev,
541 vsi->tx_rings[i].netdev,
542 vsi->tx_rings[i].tx_bi);
543 dev_info(&pf->pdev->dev,
544 " tx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
545 i, vsi->tx_rings[i].state,
546 vsi->tx_rings[i].queue_index,
547 vsi->tx_rings[i].reg_idx);
548 dev_info(&pf->pdev->dev,
549 " tx_rings[%i]: dtype = %d\n",
550 i, vsi->tx_rings[i].dtype);
551 dev_info(&pf->pdev->dev,
552 " tx_rings[%i]: hsplit = %d, next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
553 i, vsi->tx_rings[i].hsplit,
554 vsi->tx_rings[i].next_to_use,
555 vsi->tx_rings[i].next_to_clean,
556 vsi->tx_rings[i].ring_active);
557 dev_info(&pf->pdev->dev,
558 " tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
Alexander Duycka114d0a2013-09-28 06:00:43 +0000559 i, vsi->tx_rings[i].stats.packets,
560 vsi->tx_rings[i].stats.bytes,
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000561 vsi->tx_rings[i].tx_stats.restart_queue);
562 dev_info(&pf->pdev->dev,
Alexander Duyckc304fda2013-09-28 06:00:12 +0000563 " tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000564 i,
565 vsi->tx_rings[i].tx_stats.tx_busy,
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000566 vsi->tx_rings[i].tx_stats.tx_done_old);
567 dev_info(&pf->pdev->dev,
568 " tx_rings[%i]: size = %i, dma = 0x%08lx\n",
569 i, vsi->tx_rings[i].size,
570 (long unsigned int)vsi->tx_rings[i].dma);
571 dev_info(&pf->pdev->dev,
572 " tx_rings[%i]: vsi = %p, q_vector = %p\n",
573 i, vsi->tx_rings[i].vsi,
574 vsi->tx_rings[i].q_vector);
575 dev_info(&pf->pdev->dev,
576 " tx_rings[%i]: DCB tc = %d\n",
577 i, vsi->tx_rings[i].dcb_tc);
578 }
579 }
580 dev_info(&pf->pdev->dev,
581 " work_limit = %d, rx_itr_setting = %d (%s), tx_itr_setting = %d (%s)\n",
582 vsi->work_limit, vsi->rx_itr_setting,
583 ITR_IS_DYNAMIC(vsi->rx_itr_setting) ? "dynamic" : "fixed",
584 vsi->tx_itr_setting,
585 ITR_IS_DYNAMIC(vsi->tx_itr_setting) ? "dynamic" : "fixed");
586 dev_info(&pf->pdev->dev,
587 " max_frame = %d, rx_hdr_len = %d, rx_buf_len = %d dtype = %d\n",
588 vsi->max_frame, vsi->rx_hdr_len, vsi->rx_buf_len, vsi->dtype);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000589 dev_info(&pf->pdev->dev,
590 " num_q_vectors = %i, base_vector = %i\n",
591 vsi->num_q_vectors, vsi->base_vector);
592 dev_info(&pf->pdev->dev,
593 " seid = %d, id = %d, uplink_seid = %d\n",
594 vsi->seid, vsi->id, vsi->uplink_seid);
595 dev_info(&pf->pdev->dev,
596 " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
597 vsi->base_queue, vsi->num_queue_pairs, vsi->num_desc);
598 dev_info(&pf->pdev->dev, " type = %i\n", vsi->type);
599 dev_info(&pf->pdev->dev,
600 " info: valid_sections = 0x%04x, switch_id = 0x%04x\n",
601 vsi->info.valid_sections, vsi->info.switch_id);
602 dev_info(&pf->pdev->dev,
603 " info: sw_reserved[] = 0x%02x 0x%02x\n",
604 vsi->info.sw_reserved[0], vsi->info.sw_reserved[1]);
605 dev_info(&pf->pdev->dev,
606 " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n",
607 vsi->info.sec_flags, vsi->info.sec_reserved);
608 dev_info(&pf->pdev->dev,
609 " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n",
610 vsi->info.pvid, vsi->info.fcoe_pvid,
611 vsi->info.port_vlan_flags);
612 dev_info(&pf->pdev->dev,
613 " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n",
614 vsi->info.pvlan_reserved[0], vsi->info.pvlan_reserved[1],
615 vsi->info.pvlan_reserved[2]);
616 dev_info(&pf->pdev->dev,
617 " info: ingress_table = 0x%08x, egress_table = 0x%08x\n",
618 vsi->info.ingress_table, vsi->info.egress_table);
619 dev_info(&pf->pdev->dev,
620 " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n",
621 vsi->info.cas_pv_tag, vsi->info.cas_pv_flags,
622 vsi->info.cas_pv_reserved);
623 dev_info(&pf->pdev->dev,
624 " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
625 vsi->info.queue_mapping[0], vsi->info.queue_mapping[1],
626 vsi->info.queue_mapping[2], vsi->info.queue_mapping[3],
627 vsi->info.queue_mapping[4], vsi->info.queue_mapping[5],
628 vsi->info.queue_mapping[6], vsi->info.queue_mapping[7]);
629 dev_info(&pf->pdev->dev,
630 " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
631 vsi->info.queue_mapping[8], vsi->info.queue_mapping[9],
632 vsi->info.queue_mapping[10], vsi->info.queue_mapping[11],
633 vsi->info.queue_mapping[12], vsi->info.queue_mapping[13],
634 vsi->info.queue_mapping[14], vsi->info.queue_mapping[15]);
635 dev_info(&pf->pdev->dev,
636 " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
637 vsi->info.tc_mapping[0], vsi->info.tc_mapping[1],
638 vsi->info.tc_mapping[2], vsi->info.tc_mapping[3],
639 vsi->info.tc_mapping[4], vsi->info.tc_mapping[5],
640 vsi->info.tc_mapping[6], vsi->info.tc_mapping[7]);
641 dev_info(&pf->pdev->dev,
642 " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n",
643 vsi->info.queueing_opt_flags,
644 vsi->info.queueing_opt_reserved[0],
645 vsi->info.queueing_opt_reserved[1],
646 vsi->info.queueing_opt_reserved[2]);
647 dev_info(&pf->pdev->dev,
648 " info: up_enable_bits = 0x%02x\n",
649 vsi->info.up_enable_bits);
650 dev_info(&pf->pdev->dev,
651 " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n",
652 vsi->info.sched_reserved, vsi->info.outer_up_table);
653 dev_info(&pf->pdev->dev,
654 " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n",
655 vsi->info.cmd_reserved[0], vsi->info.cmd_reserved[1],
656 vsi->info.cmd_reserved[2], vsi->info.cmd_reserved[3],
657 vsi->info.cmd_reserved[4], vsi->info.cmd_reserved[5],
658 vsi->info.cmd_reserved[6], vsi->info.cmd_reserved[7]);
659 dev_info(&pf->pdev->dev,
660 " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
661 vsi->info.qs_handle[0], vsi->info.qs_handle[1],
662 vsi->info.qs_handle[2], vsi->info.qs_handle[3],
663 vsi->info.qs_handle[4], vsi->info.qs_handle[5],
664 vsi->info.qs_handle[6], vsi->info.qs_handle[7]);
665 dev_info(&pf->pdev->dev,
666 " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n",
667 vsi->info.stat_counter_idx, vsi->info.sched_id);
668 dev_info(&pf->pdev->dev,
669 " info: resp_reserved[] = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
670 vsi->info.resp_reserved[0], vsi->info.resp_reserved[1],
671 vsi->info.resp_reserved[2], vsi->info.resp_reserved[3],
672 vsi->info.resp_reserved[4], vsi->info.resp_reserved[5],
673 vsi->info.resp_reserved[6], vsi->info.resp_reserved[7],
674 vsi->info.resp_reserved[8], vsi->info.resp_reserved[9],
675 vsi->info.resp_reserved[10], vsi->info.resp_reserved[11]);
676 if (vsi->back)
677 dev_info(&pf->pdev->dev, " pf = %p\n", vsi->back);
678 dev_info(&pf->pdev->dev, " idx = %d\n", vsi->idx);
679 dev_info(&pf->pdev->dev,
680 " tc_config: numtc = %d, enabled_tc = 0x%x\n",
681 vsi->tc_config.numtc, vsi->tc_config.enabled_tc);
682 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
683 dev_info(&pf->pdev->dev,
684 " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n",
685 i, vsi->tc_config.tc_info[i].qoffset,
686 vsi->tc_config.tc_info[i].qcount,
687 vsi->tc_config.tc_info[i].netdev_tc);
688 }
689 dev_info(&pf->pdev->dev,
690 " bw: bw_limit = %d, bw_max_quanta = %d\n",
691 vsi->bw_limit, vsi->bw_max_quanta);
692 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
693 dev_info(&pf->pdev->dev,
694 " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n",
695 i, vsi->bw_ets_share_credits[i],
696 vsi->bw_ets_limit_credits[i],
697 vsi->bw_ets_max_quanta[i]);
698 }
699}
700
701/**
702 * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum
703 * @pf: the i40e_pf created in command write
704 **/
705static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf)
706{
707 struct i40e_adminq_ring *ring;
708 struct i40e_hw *hw = &pf->hw;
709 int i;
710
711 /* first the send (command) ring, then the receive (event) ring */
712 dev_info(&pf->pdev->dev, "AdminQ Tx Ring\n");
713 ring = &(hw->aq.asq);
714 for (i = 0; i < ring->count; i++) {
715 struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
716 dev_info(&pf->pdev->dev,
717 " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
718 i, d->flags, d->opcode, d->datalen, d->retval,
719 d->cookie_high, d->cookie_low);
720 dev_info(&pf->pdev->dev,
721 " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
722 d->params.raw[0], d->params.raw[1], d->params.raw[2],
723 d->params.raw[3], d->params.raw[4], d->params.raw[5],
724 d->params.raw[6], d->params.raw[7], d->params.raw[8],
725 d->params.raw[9], d->params.raw[10], d->params.raw[11],
726 d->params.raw[12], d->params.raw[13],
727 d->params.raw[14], d->params.raw[15]);
728 }
729
730 dev_info(&pf->pdev->dev, "AdminQ Rx Ring\n");
731 ring = &(hw->aq.arq);
732 for (i = 0; i < ring->count; i++) {
733 struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
734 dev_info(&pf->pdev->dev,
735 " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
736 i, d->flags, d->opcode, d->datalen, d->retval,
737 d->cookie_high, d->cookie_low);
738 dev_info(&pf->pdev->dev,
739 " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
740 d->params.raw[0], d->params.raw[1], d->params.raw[2],
741 d->params.raw[3], d->params.raw[4], d->params.raw[5],
742 d->params.raw[6], d->params.raw[7], d->params.raw[8],
743 d->params.raw[9], d->params.raw[10], d->params.raw[11],
744 d->params.raw[12], d->params.raw[13],
745 d->params.raw[14], d->params.raw[15]);
746 }
747}
748
749/**
750 * i40e_dbg_dump_desc - handles dump desc write into command datum
751 * @cnt: number of arguments that the user supplied
752 * @vsi_seid: vsi id entered by user
753 * @ring_id: ring id entered by user
754 * @desc_n: descriptor number entered by user
755 * @pf: the i40e_pf created in command write
756 * @is_rx_ring: true if rx, false if tx
757 **/
758static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
759 struct i40e_pf *pf, bool is_rx_ring)
760{
761 union i40e_rx_desc *ds;
762 struct i40e_ring ring;
763 struct i40e_vsi *vsi;
764 int i;
765
766 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
767 if (!vsi) {
768 dev_info(&pf->pdev->dev,
769 "vsi %d not found\n", vsi_seid);
770 if (is_rx_ring)
771 dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
772 else
773 dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
774 return;
775 }
776 if (ring_id >= vsi->num_queue_pairs || ring_id < 0) {
777 dev_info(&pf->pdev->dev, "ring %d not found\n", ring_id);
778 if (is_rx_ring)
779 dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
780 else
781 dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
782 return;
783 }
784 if (is_rx_ring)
785 ring = vsi->rx_rings[ring_id];
786 else
787 ring = vsi->tx_rings[ring_id];
788 if (cnt == 2) {
789 dev_info(&pf->pdev->dev, "vsi = %02i %s ring = %02i\n",
790 vsi_seid, is_rx_ring ? "rx" : "tx", ring_id);
791 for (i = 0; i < ring.count; i++) {
792 if (is_rx_ring)
793 ds = I40E_RX_DESC(&ring, i);
794 else
795 ds = (union i40e_rx_desc *)
796 I40E_TX_DESC(&ring, i);
797 if ((sizeof(union i40e_rx_desc) ==
798 sizeof(union i40e_16byte_rx_desc)) || (!is_rx_ring))
799 dev_info(&pf->pdev->dev,
800 " d[%03i] = 0x%016llx 0x%016llx\n", i,
801 ds->read.pkt_addr, ds->read.hdr_addr);
802 else
803 dev_info(&pf->pdev->dev,
804 " d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
805 i, ds->read.pkt_addr,
806 ds->read.hdr_addr,
807 ds->read.rsvd1, ds->read.rsvd2);
808 }
809 } else if (cnt == 3) {
810 if (desc_n >= ring.count || desc_n < 0) {
811 dev_info(&pf->pdev->dev,
812 "descriptor %d not found\n", desc_n);
813 return;
814 }
815 if (is_rx_ring)
816 ds = I40E_RX_DESC(&ring, desc_n);
817 else
818 ds = (union i40e_rx_desc *)I40E_TX_DESC(&ring, desc_n);
819 if ((sizeof(union i40e_rx_desc) ==
820 sizeof(union i40e_16byte_rx_desc)) || (!is_rx_ring))
821 dev_info(&pf->pdev->dev,
822 "vsi = %02i %s ring = %02i d[%03i] = 0x%016llx 0x%016llx\n",
823 vsi_seid, is_rx_ring ? "rx" : "tx", ring_id,
824 desc_n, ds->read.pkt_addr, ds->read.hdr_addr);
825 else
826 dev_info(&pf->pdev->dev,
827 "vsi = %02i rx ring = %02i d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
828 vsi_seid, ring_id,
829 desc_n, ds->read.pkt_addr, ds->read.hdr_addr,
830 ds->read.rsvd1, ds->read.rsvd2);
831 } else {
832 if (is_rx_ring)
833 dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
834 else
835 dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
836 }
837}
838
839/**
840 * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum
841 * @pf: the i40e_pf created in command write
842 **/
843static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf *pf)
844{
845 int i;
846
847 for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
848 if (pf->vsi[i])
849 dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n",
850 i, pf->vsi[i]->seid);
851}
852
853/**
854 * i40e_dbg_dump_stats - handles dump stats write into command datum
855 * @pf: the i40e_pf created in command write
856 * @estats: the eth stats structure to be dumped
857 **/
858static void i40e_dbg_dump_eth_stats(struct i40e_pf *pf,
859 struct i40e_eth_stats *estats)
860{
861 dev_info(&pf->pdev->dev, " ethstats:\n");
862 dev_info(&pf->pdev->dev,
863 " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n",
864 estats->rx_bytes, estats->rx_unicast, estats->rx_multicast);
865 dev_info(&pf->pdev->dev,
866 " rx_broadcast = \t%lld \trx_discards = \t\t%lld \trx_errors = \t%lld\n",
867 estats->rx_broadcast, estats->rx_discards, estats->rx_errors);
868 dev_info(&pf->pdev->dev,
869 " rx_missed = \t%lld \trx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n",
870 estats->rx_missed, estats->rx_unknown_protocol,
871 estats->tx_bytes);
872 dev_info(&pf->pdev->dev,
873 " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n",
874 estats->tx_unicast, estats->tx_multicast, estats->tx_broadcast);
875 dev_info(&pf->pdev->dev,
876 " tx_discards = \t%lld \ttx_errors = \t\t%lld\n",
877 estats->tx_discards, estats->tx_errors);
878}
879
880/**
881 * i40e_dbg_dump_stats - handles dump stats write into command datum
882 * @pf: the i40e_pf created in command write
883 * @stats: the stats structure to be dumped
884 **/
885static void i40e_dbg_dump_stats(struct i40e_pf *pf,
886 struct i40e_hw_port_stats *stats)
887{
888 int i;
889
890 dev_info(&pf->pdev->dev, " stats:\n");
891 dev_info(&pf->pdev->dev,
892 " crc_errors = \t\t%lld \tillegal_bytes = \t%lld \terror_bytes = \t\t%lld\n",
893 stats->crc_errors, stats->illegal_bytes, stats->error_bytes);
894 dev_info(&pf->pdev->dev,
895 " mac_local_faults = \t%lld \tmac_remote_faults = \t%lld \trx_length_errors = \t%lld\n",
896 stats->mac_local_faults, stats->mac_remote_faults,
897 stats->rx_length_errors);
898 dev_info(&pf->pdev->dev,
899 " link_xon_rx = \t\t%lld \tlink_xoff_rx = \t\t%lld \tlink_xon_tx = \t\t%lld\n",
900 stats->link_xon_rx, stats->link_xoff_rx, stats->link_xon_tx);
901 dev_info(&pf->pdev->dev,
902 " link_xoff_tx = \t\t%lld \trx_size_64 = \t\t%lld \trx_size_127 = \t\t%lld\n",
903 stats->link_xoff_tx, stats->rx_size_64, stats->rx_size_127);
904 dev_info(&pf->pdev->dev,
905 " rx_size_255 = \t\t%lld \trx_size_511 = \t\t%lld \trx_size_1023 = \t\t%lld\n",
906 stats->rx_size_255, stats->rx_size_511, stats->rx_size_1023);
907 dev_info(&pf->pdev->dev,
908 " rx_size_big = \t\t%lld \trx_undersize = \t\t%lld \trx_jabber = \t\t%lld\n",
909 stats->rx_size_big, stats->rx_undersize, stats->rx_jabber);
910 dev_info(&pf->pdev->dev,
911 " rx_fragments = \t\t%lld \trx_oversize = \t\t%lld \ttx_size_64 = \t\t%lld\n",
912 stats->rx_fragments, stats->rx_oversize, stats->tx_size_64);
913 dev_info(&pf->pdev->dev,
914 " tx_size_127 = \t\t%lld \ttx_size_255 = \t\t%lld \ttx_size_511 = \t\t%lld\n",
915 stats->tx_size_127, stats->tx_size_255, stats->tx_size_511);
916 dev_info(&pf->pdev->dev,
917 " tx_size_1023 = \t\t%lld \ttx_size_big = \t\t%lld \tmac_short_packet_dropped = \t%lld\n",
918 stats->tx_size_1023, stats->tx_size_big,
919 stats->mac_short_packet_dropped);
920 for (i = 0; i < 8; i += 4) {
921 dev_info(&pf->pdev->dev,
922 " priority_xon_rx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
923 i, stats->priority_xon_rx[i],
924 i+1, stats->priority_xon_rx[i+1],
925 i+2, stats->priority_xon_rx[i+2],
926 i+3, stats->priority_xon_rx[i+3]);
927 }
928 for (i = 0; i < 8; i += 4) {
929 dev_info(&pf->pdev->dev,
930 " priority_xoff_rx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
931 i, stats->priority_xoff_rx[i],
932 i+1, stats->priority_xoff_rx[i+1],
933 i+2, stats->priority_xoff_rx[i+2],
934 i+3, stats->priority_xoff_rx[i+3]);
935 }
936 for (i = 0; i < 8; i += 4) {
937 dev_info(&pf->pdev->dev,
938 " priority_xon_tx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
939 i, stats->priority_xon_tx[i],
940 i+1, stats->priority_xon_tx[i+1],
941 i+2, stats->priority_xon_tx[i+2],
942 i+3, stats->priority_xon_rx[i+3]);
943 }
944 for (i = 0; i < 8; i += 4) {
945 dev_info(&pf->pdev->dev,
946 " priority_xoff_tx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
947 i, stats->priority_xoff_tx[i],
948 i+1, stats->priority_xoff_tx[i+1],
949 i+2, stats->priority_xoff_tx[i+2],
950 i+3, stats->priority_xoff_tx[i+3]);
951 }
952 for (i = 0; i < 8; i += 4) {
953 dev_info(&pf->pdev->dev,
954 " priority_xon_2_xoff[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
955 i, stats->priority_xon_2_xoff[i],
956 i+1, stats->priority_xon_2_xoff[i+1],
957 i+2, stats->priority_xon_2_xoff[i+2],
958 i+3, stats->priority_xon_2_xoff[i+3]);
959 }
960
961 i40e_dbg_dump_eth_stats(pf, &stats->eth);
962}
963
964/**
965 * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb
966 * @pf: the i40e_pf created in command write
967 * @seid: the seid the user put in
968 **/
969static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid)
970{
971 struct i40e_veb *veb;
972
973 if ((seid < I40E_BASE_VEB_SEID) ||
974 (seid >= (I40E_MAX_VEB + I40E_BASE_VEB_SEID))) {
975 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
976 return;
977 }
978
979 veb = i40e_dbg_find_veb(pf, seid);
980 if (!veb) {
981 dev_info(&pf->pdev->dev,
982 "%d: can't find veb\n", seid);
983 return;
984 }
985 dev_info(&pf->pdev->dev,
986 "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d\n",
987 veb->idx, veb->veb_idx, veb->stats_idx, veb->seid,
988 veb->uplink_seid);
989 i40e_dbg_dump_eth_stats(pf, &veb->stats);
990}
991
992/**
993 * i40e_dbg_dump_veb_all - dumps all known veb's stats
994 * @pf: the i40e_pf created in command write
995 **/
996static void i40e_dbg_dump_veb_all(struct i40e_pf *pf)
997{
998 struct i40e_veb *veb;
999 int i;
1000
1001 for (i = 0; i < I40E_MAX_VEB; i++) {
1002 veb = pf->veb[i];
1003 if (veb)
1004 i40e_dbg_dump_veb_seid(pf, veb->seid);
1005 }
1006}
1007
1008#define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
1009/**
1010 * i40e_dbg_command_write - write into command datum
1011 * @filp: the opened file
1012 * @buffer: where to find the user's data
1013 * @count: the length of the user's data
1014 * @ppos: file position offset
1015 **/
1016static ssize_t i40e_dbg_command_write(struct file *filp,
1017 const char __user *buffer,
1018 size_t count, loff_t *ppos)
1019{
1020 struct i40e_pf *pf = filp->private_data;
1021 int bytes_not_copied;
1022 struct i40e_vsi *vsi;
1023 u8 *print_buf_start;
1024 u8 *print_buf;
1025 char *cmd_buf;
1026 int vsi_seid;
1027 int veb_seid;
1028 int cnt;
1029
1030 /* don't allow partial writes */
1031 if (*ppos != 0)
1032 return 0;
1033
1034 cmd_buf = kzalloc(count + 1, GFP_KERNEL);
1035 if (!cmd_buf)
1036 return count;
1037 bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
1038 if (bytes_not_copied < 0)
1039 return bytes_not_copied;
1040 if (bytes_not_copied > 0)
1041 count -= bytes_not_copied;
1042 cmd_buf[count] = '\0';
1043
1044 print_buf_start = kzalloc(I40E_MAX_DEBUG_OUT_BUFFER, GFP_KERNEL);
1045 if (!print_buf_start)
1046 goto command_write_done;
1047 print_buf = print_buf_start;
1048
1049 if (strncmp(cmd_buf, "add vsi", 7) == 0) {
1050 vsi_seid = -1;
1051 cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
1052 if (cnt == 0) {
1053 /* default to PF VSI */
1054 vsi_seid = pf->vsi[pf->lan_vsi]->seid;
1055 } else if (vsi_seid < 0) {
1056 dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n",
1057 vsi_seid);
1058 goto command_write_done;
1059 }
1060
1061 vsi = i40e_vsi_setup(pf, I40E_VSI_VMDQ2, vsi_seid, 0);
1062 if (vsi)
1063 dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n",
1064 vsi->seid, vsi->uplink_seid);
1065 else
1066 dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf);
1067
1068 } else if (strncmp(cmd_buf, "del vsi", 7) == 0) {
1069 sscanf(&cmd_buf[7], "%i", &vsi_seid);
1070 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1071 if (!vsi) {
1072 dev_info(&pf->pdev->dev, "del VSI %d: seid not found\n",
1073 vsi_seid);
1074 goto command_write_done;
1075 }
1076
1077 dev_info(&pf->pdev->dev, "deleting VSI %d\n", vsi_seid);
1078 i40e_vsi_release(vsi);
1079
1080 } else if (strncmp(cmd_buf, "add relay", 9) == 0) {
1081 struct i40e_veb *veb;
1082 int uplink_seid, i;
1083
1084 cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid);
1085 if (cnt != 2) {
1086 dev_info(&pf->pdev->dev,
1087 "add relay: bad command string, cnt=%d\n",
1088 cnt);
1089 goto command_write_done;
1090 } else if (uplink_seid < 0) {
1091 dev_info(&pf->pdev->dev,
1092 "add relay %d: bad uplink seid\n",
1093 uplink_seid);
1094 goto command_write_done;
1095 }
1096
1097 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1098 if (!vsi) {
1099 dev_info(&pf->pdev->dev,
1100 "add relay: vsi VSI %d not found\n", vsi_seid);
1101 goto command_write_done;
1102 }
1103
1104 for (i = 0; i < I40E_MAX_VEB; i++)
1105 if (pf->veb[i] && pf->veb[i]->seid == uplink_seid)
1106 break;
1107 if (i >= I40E_MAX_VEB && uplink_seid != 0 &&
1108 uplink_seid != pf->mac_seid) {
1109 dev_info(&pf->pdev->dev,
1110 "add relay: relay uplink %d not found\n",
1111 uplink_seid);
1112 goto command_write_done;
1113 }
1114
1115 veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid,
1116 vsi->tc_config.enabled_tc);
1117 if (veb)
1118 dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid);
1119 else
1120 dev_info(&pf->pdev->dev, "add relay failed\n");
1121
1122 } else if (strncmp(cmd_buf, "del relay", 9) == 0) {
1123 int i;
1124 cnt = sscanf(&cmd_buf[9], "%i", &veb_seid);
1125 if (cnt != 1) {
1126 dev_info(&pf->pdev->dev,
1127 "del relay: bad command string, cnt=%d\n",
1128 cnt);
1129 goto command_write_done;
1130 } else if (veb_seid < 0) {
1131 dev_info(&pf->pdev->dev,
1132 "del relay %d: bad relay seid\n", veb_seid);
1133 goto command_write_done;
1134 }
1135
1136 /* find the veb */
1137 for (i = 0; i < I40E_MAX_VEB; i++)
1138 if (pf->veb[i] && pf->veb[i]->seid == veb_seid)
1139 break;
1140 if (i >= I40E_MAX_VEB) {
1141 dev_info(&pf->pdev->dev,
1142 "del relay: relay %d not found\n", veb_seid);
1143 goto command_write_done;
1144 }
1145
1146 dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid);
1147 i40e_veb_release(pf->veb[i]);
1148
1149 } else if (strncmp(cmd_buf, "add macaddr", 11) == 0) {
1150 u8 ma[6];
1151 int vlan = 0;
1152 struct i40e_mac_filter *f;
1153 int ret;
1154
1155 cnt = sscanf(&cmd_buf[11],
1156 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
1157 &vsi_seid,
1158 &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
1159 &vlan);
1160 if (cnt == 7) {
1161 vlan = 0;
1162 } else if (cnt != 8) {
1163 dev_info(&pf->pdev->dev,
1164 "add macaddr: bad command string, cnt=%d\n",
1165 cnt);
1166 goto command_write_done;
1167 }
1168
1169 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1170 if (!vsi) {
1171 dev_info(&pf->pdev->dev,
1172 "add macaddr: VSI %d not found\n", vsi_seid);
1173 goto command_write_done;
1174 }
1175
1176 f = i40e_add_filter(vsi, ma, vlan, false, false);
1177 ret = i40e_sync_vsi_filters(vsi);
1178 if (f && !ret)
1179 dev_info(&pf->pdev->dev,
1180 "add macaddr: %pM vlan=%d added to VSI %d\n",
1181 ma, vlan, vsi_seid);
1182 else
1183 dev_info(&pf->pdev->dev,
1184 "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
1185 ma, vlan, vsi_seid, f, ret);
1186
1187 } else if (strncmp(cmd_buf, "del macaddr", 11) == 0) {
1188 u8 ma[6];
1189 int vlan = 0;
1190 int ret;
1191
1192 cnt = sscanf(&cmd_buf[11],
1193 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
1194 &vsi_seid,
1195 &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
1196 &vlan);
1197 if (cnt == 7) {
1198 vlan = 0;
1199 } else if (cnt != 8) {
1200 dev_info(&pf->pdev->dev,
1201 "del macaddr: bad command string, cnt=%d\n",
1202 cnt);
1203 goto command_write_done;
1204 }
1205
1206 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1207 if (!vsi) {
1208 dev_info(&pf->pdev->dev,
1209 "del macaddr: VSI %d not found\n", vsi_seid);
1210 goto command_write_done;
1211 }
1212
1213 i40e_del_filter(vsi, ma, vlan, false, false);
1214 ret = i40e_sync_vsi_filters(vsi);
1215 if (!ret)
1216 dev_info(&pf->pdev->dev,
1217 "del macaddr: %pM vlan=%d removed from VSI %d\n",
1218 ma, vlan, vsi_seid);
1219 else
1220 dev_info(&pf->pdev->dev,
1221 "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
1222 ma, vlan, vsi_seid, ret);
1223
1224 } else if (strncmp(cmd_buf, "add pvid", 8) == 0) {
1225 int v;
1226 u16 vid;
1227 i40e_status ret;
1228
1229 cnt = sscanf(&cmd_buf[8], "%i %u", &vsi_seid, &v);
1230 if (cnt != 2) {
1231 dev_info(&pf->pdev->dev,
1232 "add pvid: bad command string, cnt=%d\n", cnt);
1233 goto command_write_done;
1234 }
1235
1236 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1237 if (!vsi) {
1238 dev_info(&pf->pdev->dev, "add pvid: VSI %d not found\n",
1239 vsi_seid);
1240 goto command_write_done;
1241 }
1242
1243 vid = (unsigned)v;
1244 ret = i40e_vsi_add_pvid(vsi, vid);
1245 if (!ret)
1246 dev_info(&pf->pdev->dev,
1247 "add pvid: %d added to VSI %d\n",
1248 vid, vsi_seid);
1249 else
1250 dev_info(&pf->pdev->dev,
1251 "add pvid: %d to VSI %d failed, ret=%d\n",
1252 vid, vsi_seid, ret);
1253
1254 } else if (strncmp(cmd_buf, "del pvid", 8) == 0) {
1255
1256 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1257 if (cnt != 1) {
1258 dev_info(&pf->pdev->dev,
1259 "del pvid: bad command string, cnt=%d\n",
1260 cnt);
1261 goto command_write_done;
1262 }
1263
1264 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1265 if (!vsi) {
1266 dev_info(&pf->pdev->dev,
1267 "del pvid: VSI %d not found\n", vsi_seid);
1268 goto command_write_done;
1269 }
1270
1271 i40e_vsi_remove_pvid(vsi);
1272 dev_info(&pf->pdev->dev,
1273 "del pvid: removed from VSI %d\n", vsi_seid);
1274
1275 } else if (strncmp(cmd_buf, "dump", 4) == 0) {
1276 if (strncmp(&cmd_buf[5], "switch", 6) == 0) {
1277 i40e_fetch_switch_configuration(pf, true);
1278 } else if (strncmp(&cmd_buf[5], "vsi", 3) == 0) {
1279 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1280 if (cnt > 0)
1281 i40e_dbg_dump_vsi_seid(pf, vsi_seid);
1282 else
1283 i40e_dbg_dump_vsi_no_seid(pf);
1284 } else if (strncmp(&cmd_buf[5], "veb", 3) == 0) {
1285 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1286 if (cnt > 0)
1287 i40e_dbg_dump_veb_seid(pf, vsi_seid);
1288 else
1289 i40e_dbg_dump_veb_all(pf);
1290 } else if (strncmp(&cmd_buf[5], "desc", 4) == 0) {
1291 int ring_id, desc_n;
1292 if (strncmp(&cmd_buf[10], "rx", 2) == 0) {
1293 cnt = sscanf(&cmd_buf[12], "%i %i %i",
1294 &vsi_seid, &ring_id, &desc_n);
1295 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1296 desc_n, pf, true);
1297 } else if (strncmp(&cmd_buf[10], "tx", 2)
1298 == 0) {
1299 cnt = sscanf(&cmd_buf[12], "%i %i %i",
1300 &vsi_seid, &ring_id, &desc_n);
1301 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1302 desc_n, pf, false);
1303 } else if (strncmp(&cmd_buf[10], "aq", 2) == 0) {
1304 i40e_dbg_dump_aq_desc(pf);
1305 } else {
1306 dev_info(&pf->pdev->dev,
1307 "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1308 dev_info(&pf->pdev->dev,
1309 "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1310 dev_info(&pf->pdev->dev, "dump desc aq\n");
1311 }
1312 } else if (strncmp(&cmd_buf[5], "stats", 5) == 0) {
1313 dev_info(&pf->pdev->dev, "pf stats:\n");
1314 i40e_dbg_dump_stats(pf, &pf->stats);
1315 dev_info(&pf->pdev->dev, "pf stats_offsets:\n");
1316 i40e_dbg_dump_stats(pf, &pf->stats_offsets);
1317 } else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) {
1318 dev_info(&pf->pdev->dev,
1319 "core reset count: %d\n", pf->corer_count);
1320 dev_info(&pf->pdev->dev,
1321 "global reset count: %d\n", pf->globr_count);
1322 dev_info(&pf->pdev->dev,
1323 "emp reset count: %d\n", pf->empr_count);
1324 dev_info(&pf->pdev->dev,
1325 "pf reset count: %d\n", pf->pfr_count);
1326 } else if (strncmp(&cmd_buf[5], "port", 4) == 0) {
1327 struct i40e_aqc_query_port_ets_config_resp *bw_data;
1328 struct i40e_dcbx_config *cfg =
1329 &pf->hw.local_dcbx_config;
1330 struct i40e_dcbx_config *r_cfg =
1331 &pf->hw.remote_dcbx_config;
1332 int i, ret;
1333
1334 bw_data = kzalloc(sizeof(
1335 struct i40e_aqc_query_port_ets_config_resp),
1336 GFP_KERNEL);
1337 if (!bw_data) {
1338 ret = -ENOMEM;
1339 goto command_write_done;
1340 }
1341
1342 ret = i40e_aq_query_port_ets_config(&pf->hw,
1343 pf->mac_seid,
1344 bw_data, NULL);
1345 if (ret) {
1346 dev_info(&pf->pdev->dev,
1347 "Query Port ETS Config AQ command failed =0x%x\n",
1348 pf->hw.aq.asq_last_status);
1349 kfree(bw_data);
1350 bw_data = NULL;
1351 goto command_write_done;
1352 }
1353 dev_info(&pf->pdev->dev,
1354 "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
1355 bw_data->tc_valid_bits,
1356 bw_data->tc_strict_priority_bits,
1357 le16_to_cpu(bw_data->tc_bw_max[0]),
1358 le16_to_cpu(bw_data->tc_bw_max[1]));
1359 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1360 dev_info(&pf->pdev->dev, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
1361 bw_data->tc_bw_share_credits[i],
1362 le16_to_cpu(bw_data->tc_bw_limits[i]));
1363 }
1364
1365 kfree(bw_data);
1366 bw_data = NULL;
1367
1368 dev_info(&pf->pdev->dev,
1369 "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1370 cfg->etscfg.willing, cfg->etscfg.cbs,
1371 cfg->etscfg.maxtcs);
1372 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1373 dev_info(&pf->pdev->dev, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1374 i, cfg->etscfg.prioritytable[i],
1375 cfg->etscfg.tcbwtable[i],
1376 cfg->etscfg.tsatable[i]);
1377 }
1378 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1379 dev_info(&pf->pdev->dev, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1380 i, cfg->etsrec.prioritytable[i],
1381 cfg->etsrec.tcbwtable[i],
1382 cfg->etsrec.tsatable[i]);
1383 }
1384 dev_info(&pf->pdev->dev,
1385 "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1386 cfg->pfc.willing, cfg->pfc.mbc,
1387 cfg->pfc.pfccap, cfg->pfc.pfcenable);
1388 dev_info(&pf->pdev->dev,
1389 "port app_table: num_apps=%d\n", cfg->numapps);
1390 for (i = 0; i < cfg->numapps; i++) {
1391 dev_info(&pf->pdev->dev, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1392 i, cfg->app[i].priority,
1393 cfg->app[i].selector,
1394 cfg->app[i].protocolid);
1395 }
1396 /* Peer TLV DCBX data */
1397 dev_info(&pf->pdev->dev,
1398 "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1399 r_cfg->etscfg.willing,
1400 r_cfg->etscfg.cbs, r_cfg->etscfg.maxtcs);
1401 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1402 dev_info(&pf->pdev->dev, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1403 i, r_cfg->etscfg.prioritytable[i],
1404 r_cfg->etscfg.tcbwtable[i],
1405 r_cfg->etscfg.tsatable[i]);
1406 }
1407 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1408 dev_info(&pf->pdev->dev, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1409 i, r_cfg->etsrec.prioritytable[i],
1410 r_cfg->etsrec.tcbwtable[i],
1411 r_cfg->etsrec.tsatable[i]);
1412 }
1413 dev_info(&pf->pdev->dev,
1414 "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1415 r_cfg->pfc.willing,
1416 r_cfg->pfc.mbc,
1417 r_cfg->pfc.pfccap,
1418 r_cfg->pfc.pfcenable);
1419 dev_info(&pf->pdev->dev,
1420 "remote port app_table: num_apps=%d\n",
1421 r_cfg->numapps);
1422 for (i = 0; i < r_cfg->numapps; i++) {
1423 dev_info(&pf->pdev->dev, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1424 i, r_cfg->app[i].priority,
1425 r_cfg->app[i].selector,
1426 r_cfg->app[i].protocolid);
1427 }
1428 } else {
1429 dev_info(&pf->pdev->dev,
1430 "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
1431 dev_info(&pf->pdev->dev, "dump switch, dump vsi [seid] or\n");
1432 dev_info(&pf->pdev->dev, "dump stats\n");
1433 dev_info(&pf->pdev->dev, "dump reset stats\n");
1434 dev_info(&pf->pdev->dev, "dump port\n");
1435 dev_info(&pf->pdev->dev,
1436 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1437 }
1438
1439 } else if (strncmp(cmd_buf, "msg_enable", 10) == 0) {
1440 u32 level;
1441 cnt = sscanf(&cmd_buf[10], "%i", &level);
1442 if (cnt) {
1443 if (I40E_DEBUG_USER & level) {
1444 pf->hw.debug_mask = level;
1445 dev_info(&pf->pdev->dev,
1446 "set hw.debug_mask = 0x%08x\n",
1447 pf->hw.debug_mask);
1448 }
1449 pf->msg_enable = level;
1450 dev_info(&pf->pdev->dev, "set msg_enable = 0x%08x\n",
1451 pf->msg_enable);
1452 } else {
1453 dev_info(&pf->pdev->dev, "msg_enable = 0x%08x\n",
1454 pf->msg_enable);
1455 }
1456 } else if (strncmp(cmd_buf, "pfr", 3) == 0) {
1457 dev_info(&pf->pdev->dev, "forcing PFR\n");
1458 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
1459
1460 } else if (strncmp(cmd_buf, "corer", 5) == 0) {
1461 dev_info(&pf->pdev->dev, "forcing CoreR\n");
1462 i40e_do_reset(pf, (1 << __I40E_CORE_RESET_REQUESTED));
1463
1464 } else if (strncmp(cmd_buf, "globr", 5) == 0) {
1465 dev_info(&pf->pdev->dev, "forcing GlobR\n");
1466 i40e_do_reset(pf, (1 << __I40E_GLOBAL_RESET_REQUESTED));
1467
1468 } else if (strncmp(cmd_buf, "read", 4) == 0) {
1469 u32 address;
1470 u32 value;
1471 cnt = sscanf(&cmd_buf[4], "%x", &address);
1472 if (cnt != 1) {
1473 dev_info(&pf->pdev->dev, "read <reg>\n");
1474 goto command_write_done;
1475 }
1476
1477 /* check the range on address */
1478 if (address >= I40E_MAX_REGISTER) {
1479 dev_info(&pf->pdev->dev, "read reg address 0x%08x too large\n",
1480 address);
1481 goto command_write_done;
1482 }
1483
1484 value = rd32(&pf->hw, address);
1485 dev_info(&pf->pdev->dev, "read: 0x%08x = 0x%08x\n",
1486 address, value);
1487
1488 } else if (strncmp(cmd_buf, "write", 5) == 0) {
1489 u32 address, value;
1490 cnt = sscanf(&cmd_buf[5], "%x %x", &address, &value);
1491 if (cnt != 2) {
1492 dev_info(&pf->pdev->dev, "write <reg> <value>\n");
1493 goto command_write_done;
1494 }
1495
1496 /* check the range on address */
1497 if (address >= I40E_MAX_REGISTER) {
1498 dev_info(&pf->pdev->dev, "write reg address 0x%08x too large\n",
1499 address);
1500 goto command_write_done;
1501 }
1502 wr32(&pf->hw, address, value);
1503 value = rd32(&pf->hw, address);
1504 dev_info(&pf->pdev->dev, "write: 0x%08x = 0x%08x\n",
1505 address, value);
1506 } else if (strncmp(cmd_buf, "clear_stats", 11) == 0) {
1507 if (strncmp(&cmd_buf[12], "vsi", 3) == 0) {
1508 cnt = sscanf(&cmd_buf[15], "%d", &vsi_seid);
1509 if (cnt == 0) {
1510 int i;
1511 for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
1512 i40e_vsi_reset_stats(pf->vsi[i]);
1513 dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n");
1514 } else if (cnt == 1) {
1515 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1516 if (!vsi) {
1517 dev_info(&pf->pdev->dev,
1518 "clear_stats vsi: bad vsi %d\n",
1519 vsi_seid);
1520 goto command_write_done;
1521 }
1522 i40e_vsi_reset_stats(vsi);
1523 dev_info(&pf->pdev->dev,
1524 "vsi clear stats called for vsi %d\n",
1525 vsi_seid);
1526 } else {
1527 dev_info(&pf->pdev->dev, "clear_stats vsi [seid]\n");
1528 }
1529 } else if (strncmp(&cmd_buf[12], "pf", 2) == 0) {
1530 i40e_pf_reset_stats(pf);
1531 dev_info(&pf->pdev->dev, "pf clear stats called\n");
1532 } else {
1533 dev_info(&pf->pdev->dev, "clear_stats vsi [seid] or clear_stats pf\n");
1534 }
1535 } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) ||
1536 (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) {
1537 struct i40e_fdir_data fd_data;
1538 int ret;
1539 u16 packet_len, i, j = 0;
1540 char *asc_packet;
1541 bool add = false;
1542
1543 asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
1544 GFP_KERNEL);
1545 if (!asc_packet)
1546 goto command_write_done;
1547
1548 fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
1549 GFP_KERNEL);
1550
1551 if (!fd_data.raw_packet) {
1552 kfree(asc_packet);
1553 asc_packet = NULL;
1554 goto command_write_done;
1555 }
1556
1557 if (strncmp(cmd_buf, "add", 3) == 0)
1558 add = true;
1559 cnt = sscanf(&cmd_buf[13],
1560 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %512s",
1561 &fd_data.q_index,
1562 &fd_data.flex_off, &fd_data.pctype,
1563 &fd_data.dest_vsi, &fd_data.dest_ctl,
1564 &fd_data.fd_status, &fd_data.cnt_index,
1565 &fd_data.fd_id, &packet_len, asc_packet);
1566 if (cnt != 10) {
1567 dev_info(&pf->pdev->dev,
1568 "program fd_filter: bad command string, cnt=%d\n",
1569 cnt);
1570 kfree(asc_packet);
1571 asc_packet = NULL;
1572 kfree(fd_data.raw_packet);
1573 goto command_write_done;
1574 }
1575
1576 /* fix packet length if user entered 0 */
1577 if (packet_len == 0)
1578 packet_len = I40E_FDIR_MAX_RAW_PACKET_LOOKUP;
1579
1580 /* make sure to check the max as well */
1581 packet_len = min_t(u16,
1582 packet_len, I40E_FDIR_MAX_RAW_PACKET_LOOKUP);
1583
1584 dev_info(&pf->pdev->dev, "FD raw packet:\n");
1585 for (i = 0; i < packet_len; i++) {
1586 sscanf(&asc_packet[j], "%2hhx ",
1587 &fd_data.raw_packet[i]);
1588 j += 3;
1589 snprintf(print_buf, 3, "%02x ", fd_data.raw_packet[i]);
1590 print_buf += 3;
1591 if ((i % 16) == 15) {
1592 snprintf(print_buf, 1, "\n");
1593 print_buf++;
1594 }
1595 }
1596 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1597 ret = i40e_program_fdir_filter(&fd_data, pf, add);
1598 if (!ret) {
1599 dev_info(&pf->pdev->dev, "Filter command send Status : Success\n");
1600 } else {
1601 dev_info(&pf->pdev->dev,
1602 "Filter command send failed %d\n", ret);
1603 }
1604 kfree(fd_data.raw_packet);
1605 fd_data.raw_packet = NULL;
1606 kfree(asc_packet);
1607 asc_packet = NULL;
1608 } else if (strncmp(cmd_buf, "lldp", 4) == 0) {
1609 if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
1610 int ret;
1611 ret = i40e_aq_stop_lldp(&pf->hw, false, NULL);
1612 if (ret) {
1613 dev_info(&pf->pdev->dev,
1614 "Stop LLDP AQ command failed =0x%x\n",
1615 pf->hw.aq.asq_last_status);
1616 goto command_write_done;
1617 }
1618 } else if (strncmp(&cmd_buf[5], "start", 5) == 0) {
1619 int ret;
1620 ret = i40e_aq_start_lldp(&pf->hw, NULL);
1621 if (ret) {
1622 dev_info(&pf->pdev->dev,
1623 "Start LLDP AQ command failed =0x%x\n",
1624 pf->hw.aq.asq_last_status);
1625 goto command_write_done;
1626 }
1627 } else if (strncmp(&cmd_buf[5],
1628 "get local", 9) == 0) {
1629 int ret, i;
1630 u8 *buff;
1631 u16 llen, rlen;
1632 buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
1633 if (!buff)
1634 goto command_write_done;
1635
1636 ret = i40e_aq_get_lldp_mib(&pf->hw, 0,
1637 I40E_AQ_LLDP_MIB_LOCAL,
1638 buff, I40E_LLDPDU_SIZE,
1639 &llen, &rlen, NULL);
1640 if (ret) {
1641 dev_info(&pf->pdev->dev,
1642 "Get LLDP MIB (local) AQ command failed =0x%x\n",
1643 pf->hw.aq.asq_last_status);
1644 kfree(buff);
1645 buff = NULL;
1646 goto command_write_done;
1647 }
1648 dev_info(&pf->pdev->dev,
1649 "Get LLDP MIB (local) AQ buffer written back:\n");
1650 for (i = 0; i < I40E_LLDPDU_SIZE; i++) {
1651 snprintf(print_buf, 3, "%02x ", buff[i]);
1652 print_buf += 3;
1653 if ((i % 16) == 15) {
1654 snprintf(print_buf, 1, "\n");
1655 print_buf++;
1656 }
1657 }
1658 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1659 kfree(buff);
1660 buff = NULL;
1661 } else if (strncmp(&cmd_buf[5], "get remote", 10) == 0) {
1662 int ret, i;
1663 u8 *buff;
1664 u16 llen, rlen;
1665 buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
1666 if (!buff)
1667 goto command_write_done;
1668
1669 ret = i40e_aq_get_lldp_mib(&pf->hw,
1670 I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE,
1671 I40E_AQ_LLDP_MIB_LOCAL,
1672 buff, I40E_LLDPDU_SIZE,
1673 &llen, &rlen, NULL);
1674 if (ret) {
1675 dev_info(&pf->pdev->dev,
1676 "Get LLDP MIB (remote) AQ command failed =0x%x\n",
1677 pf->hw.aq.asq_last_status);
1678 kfree(buff);
1679 buff = NULL;
1680 goto command_write_done;
1681 }
1682 dev_info(&pf->pdev->dev,
1683 "Get LLDP MIB (remote) AQ buffer written back:\n");
1684 for (i = 0; i < I40E_LLDPDU_SIZE; i++) {
1685 snprintf(print_buf, 3, "%02x ", buff[i]);
1686 print_buf += 3;
1687 if ((i % 16) == 15) {
1688 snprintf(print_buf, 1, "\n");
1689 print_buf++;
1690 }
1691 }
1692 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1693 kfree(buff);
1694 buff = NULL;
1695 } else if (strncmp(&cmd_buf[5], "event on", 8) == 0) {
1696 int ret;
1697 ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
1698 true, NULL);
1699 if (ret) {
1700 dev_info(&pf->pdev->dev,
1701 "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
1702 pf->hw.aq.asq_last_status);
1703 goto command_write_done;
1704 }
1705 } else if (strncmp(&cmd_buf[5], "event off", 9) == 0) {
1706 int ret;
1707 ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
1708 false, NULL);
1709 if (ret) {
1710 dev_info(&pf->pdev->dev,
1711 "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
1712 pf->hw.aq.asq_last_status);
1713 goto command_write_done;
1714 }
1715 }
1716 } else if (strncmp(cmd_buf, "nvm read", 8) == 0) {
1717 u16 buffer_len, i, bytes;
1718 u16 module;
1719 u32 offset;
1720 u16 *buff;
1721 int ret;
1722
1723 cnt = sscanf(&cmd_buf[8], "%hx %x %hx",
1724 &module, &offset, &buffer_len);
1725 if (cnt == 0) {
1726 module = 0;
1727 offset = 0;
1728 buffer_len = 0;
1729 } else if (cnt == 1) {
1730 offset = 0;
1731 buffer_len = 0;
1732 } else if (cnt == 2) {
1733 buffer_len = 0;
1734 } else if (cnt > 3) {
1735 dev_info(&pf->pdev->dev,
1736 "nvm read: bad command string, cnt=%d\n", cnt);
1737 goto command_write_done;
1738 }
1739
1740 /* Read at least 512 words */
1741 if (buffer_len == 0)
1742 buffer_len = 512;
1743
1744 bytes = 2 * buffer_len;
1745 buff = kzalloc(bytes, GFP_KERNEL);
1746 if (!buff)
1747 goto command_write_done;
1748
1749 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ);
1750 if (ret) {
1751 dev_info(&pf->pdev->dev,
1752 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1753 ret, pf->hw.aq.asq_last_status);
1754 kfree(buff);
1755 goto command_write_done;
1756 }
1757
1758 ret = i40e_aq_read_nvm(&pf->hw, module, (2 * offset),
1759 bytes, (u8 *)buff, true, NULL);
1760 i40e_release_nvm(&pf->hw);
1761 if (ret) {
1762 dev_info(&pf->pdev->dev,
1763 "Read NVM AQ failed err=%d status=0x%x\n",
1764 ret, pf->hw.aq.asq_last_status);
1765 } else {
1766 dev_info(&pf->pdev->dev,
1767 "Read NVM module=0x%x offset=0x%x words=%d\n",
1768 module, offset, buffer_len);
1769 for (i = 0; i < buffer_len; i++) {
1770 if ((i % 16) == 0) {
1771 snprintf(print_buf, 11, "\n0x%08x: ",
1772 offset + i);
1773 print_buf += 11;
1774 }
1775 snprintf(print_buf, 5, "%04x ", buff[i]);
1776 print_buf += 5;
1777 }
1778 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1779 }
1780 kfree(buff);
1781 buff = NULL;
1782 } else {
1783 dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf);
1784 dev_info(&pf->pdev->dev, "available commands\n");
1785 dev_info(&pf->pdev->dev, " add vsi [relay_seid]\n");
1786 dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n");
1787 dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n");
1788 dev_info(&pf->pdev->dev, " del relay <relay_seid>\n");
1789 dev_info(&pf->pdev->dev, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1790 dev_info(&pf->pdev->dev, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1791 dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n");
1792 dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n");
1793 dev_info(&pf->pdev->dev, " dump switch\n");
1794 dev_info(&pf->pdev->dev, " dump vsi [seid]\n");
1795 dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1796 dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1797 dev_info(&pf->pdev->dev, " dump desc aq\n");
1798 dev_info(&pf->pdev->dev, " dump stats\n");
1799 dev_info(&pf->pdev->dev, " dump reset stats\n");
1800 dev_info(&pf->pdev->dev, " msg_enable [level]\n");
1801 dev_info(&pf->pdev->dev, " read <reg>\n");
1802 dev_info(&pf->pdev->dev, " write <reg> <value>\n");
1803 dev_info(&pf->pdev->dev, " clear_stats vsi [seid]\n");
1804 dev_info(&pf->pdev->dev, " clear_stats pf\n");
1805 dev_info(&pf->pdev->dev, " pfr\n");
1806 dev_info(&pf->pdev->dev, " corer\n");
1807 dev_info(&pf->pdev->dev, " globr\n");
1808 dev_info(&pf->pdev->dev, " add fd_filter <dest q_index> <flex_off> <pctype> <dest_vsi> <dest_ctl> <fd_status> <cnt_index> <fd_id> <packet_len> <packet>\n");
1809 dev_info(&pf->pdev->dev, " rem fd_filter <dest q_index> <flex_off> <pctype> <dest_vsi> <dest_ctl> <fd_status> <cnt_index> <fd_id> <packet_len> <packet>\n");
1810 dev_info(&pf->pdev->dev, " lldp start\n");
1811 dev_info(&pf->pdev->dev, " lldp stop\n");
1812 dev_info(&pf->pdev->dev, " lldp get local\n");
1813 dev_info(&pf->pdev->dev, " lldp get remote\n");
1814 dev_info(&pf->pdev->dev, " lldp event on\n");
1815 dev_info(&pf->pdev->dev, " lldp event off\n");
1816 dev_info(&pf->pdev->dev, " nvm read [module] [word_offset] [word_count]\n");
1817 }
1818
1819command_write_done:
1820 kfree(cmd_buf);
1821 cmd_buf = NULL;
1822 kfree(print_buf_start);
1823 print_buf = NULL;
1824 print_buf_start = NULL;
1825 return count;
1826}
1827
1828static const struct file_operations i40e_dbg_command_fops = {
1829 .owner = THIS_MODULE,
1830 .open = simple_open,
1831 .read = i40e_dbg_command_read,
1832 .write = i40e_dbg_command_write,
1833};
1834
1835/**************************************************************
1836 * netdev_ops
1837 * The netdev_ops entry in debugfs is for giving the driver commands
1838 * to be executed from the netdev operations.
1839 **************************************************************/
1840static char i40e_dbg_netdev_ops_buf[256] = "hello world";
1841
1842/**
1843 * i40e_dbg_netdev_ops - read for netdev_ops datum
1844 * @filp: the opened file
1845 * @buffer: where to write the data for the user to read
1846 * @count: the size of the user's buffer
1847 * @ppos: file position offset
1848 **/
1849static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
1850 size_t count, loff_t *ppos)
1851{
1852 struct i40e_pf *pf = filp->private_data;
1853 int bytes_not_copied;
1854 int buf_size = 256;
1855 char *buf;
1856 int len;
1857
1858 /* don't allow partal reads */
1859 if (*ppos != 0)
1860 return 0;
1861 if (count < buf_size)
1862 return -ENOSPC;
1863
1864 buf = kzalloc(buf_size, GFP_KERNEL);
1865 if (!buf)
1866 return -ENOSPC;
1867
1868 len = snprintf(buf, buf_size, "%s: %s\n",
1869 pf->vsi[pf->lan_vsi]->netdev->name,
1870 i40e_dbg_netdev_ops_buf);
1871
1872 bytes_not_copied = copy_to_user(buffer, buf, len);
1873 kfree(buf);
1874
1875 if (bytes_not_copied < 0)
1876 return bytes_not_copied;
1877
1878 *ppos = len;
1879 return len;
1880}
1881
1882/**
1883 * i40e_dbg_netdev_ops_write - write into netdev_ops datum
1884 * @filp: the opened file
1885 * @buffer: where to find the user's data
1886 * @count: the length of the user's data
1887 * @ppos: file position offset
1888 **/
1889static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1890 const char __user *buffer,
1891 size_t count, loff_t *ppos)
1892{
1893 struct i40e_pf *pf = filp->private_data;
1894 int bytes_not_copied;
1895 struct i40e_vsi *vsi;
1896 int vsi_seid;
1897 int i, cnt;
1898
1899 /* don't allow partial writes */
1900 if (*ppos != 0)
1901 return 0;
1902 if (count >= sizeof(i40e_dbg_netdev_ops_buf))
1903 return -ENOSPC;
1904
1905 memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf));
1906 bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf,
1907 buffer, count);
1908 if (bytes_not_copied < 0)
1909 return bytes_not_copied;
1910 else if (bytes_not_copied > 0)
1911 count -= bytes_not_copied;
1912 i40e_dbg_netdev_ops_buf[count] = '\0';
1913
1914 if (strncmp(i40e_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) {
1915 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1916 if (cnt != 1) {
1917 dev_info(&pf->pdev->dev, "tx_timeout <vsi_seid>\n");
1918 goto netdev_ops_write_done;
1919 }
1920 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1921 if (!vsi) {
1922 dev_info(&pf->pdev->dev,
1923 "tx_timeout: VSI %d not found\n", vsi_seid);
1924 goto netdev_ops_write_done;
1925 }
1926 if (rtnl_trylock()) {
1927 vsi->netdev->netdev_ops->ndo_tx_timeout(vsi->netdev);
1928 rtnl_unlock();
1929 dev_info(&pf->pdev->dev, "tx_timeout called\n");
1930 } else {
1931 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1932 }
1933 } else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
1934 int mtu;
1935 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
1936 &vsi_seid, &mtu);
1937 if (cnt != 2) {
1938 dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
1939 goto netdev_ops_write_done;
1940 }
1941 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1942 if (!vsi) {
1943 dev_info(&pf->pdev->dev,
1944 "change_mtu: VSI %d not found\n", vsi_seid);
1945 goto netdev_ops_write_done;
1946 }
1947 if (rtnl_trylock()) {
1948 vsi->netdev->netdev_ops->ndo_change_mtu(vsi->netdev,
1949 mtu);
1950 rtnl_unlock();
1951 dev_info(&pf->pdev->dev, "change_mtu called\n");
1952 } else {
1953 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1954 }
1955
1956 } else if (strncmp(i40e_dbg_netdev_ops_buf, "set_rx_mode", 11) == 0) {
1957 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1958 if (cnt != 1) {
1959 dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
1960 goto netdev_ops_write_done;
1961 }
1962 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1963 if (!vsi) {
1964 dev_info(&pf->pdev->dev,
1965 "set_rx_mode: VSI %d not found\n", vsi_seid);
1966 goto netdev_ops_write_done;
1967 }
1968 if (rtnl_trylock()) {
1969 vsi->netdev->netdev_ops->ndo_set_rx_mode(vsi->netdev);
1970 rtnl_unlock();
1971 dev_info(&pf->pdev->dev, "set_rx_mode called\n");
1972 } else {
1973 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1974 }
1975
1976 } else if (strncmp(i40e_dbg_netdev_ops_buf, "napi", 4) == 0) {
1977 cnt = sscanf(&i40e_dbg_netdev_ops_buf[4], "%i", &vsi_seid);
1978 if (cnt != 1) {
1979 dev_info(&pf->pdev->dev, "napi <vsi_seid>\n");
1980 goto netdev_ops_write_done;
1981 }
1982 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1983 if (!vsi) {
1984 dev_info(&pf->pdev->dev, "napi: VSI %d not found\n",
1985 vsi_seid);
1986 goto netdev_ops_write_done;
1987 }
1988 for (i = 0; i < vsi->num_q_vectors; i++)
Alexander Duyck493fb302013-09-28 07:01:44 +00001989 napi_schedule(&vsi->q_vectors[i]->napi);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001990 dev_info(&pf->pdev->dev, "napi called\n");
1991 } else {
1992 dev_info(&pf->pdev->dev, "unknown command '%s'\n",
1993 i40e_dbg_netdev_ops_buf);
1994 dev_info(&pf->pdev->dev, "available commands\n");
1995 dev_info(&pf->pdev->dev, " tx_timeout <vsi_seid>\n");
1996 dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n");
1997 dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n");
1998 dev_info(&pf->pdev->dev, " napi <vsi_seid>\n");
1999 }
2000netdev_ops_write_done:
2001 return count;
2002}
2003
2004static const struct file_operations i40e_dbg_netdev_ops_fops = {
2005 .owner = THIS_MODULE,
2006 .open = simple_open,
2007 .read = i40e_dbg_netdev_ops_read,
2008 .write = i40e_dbg_netdev_ops_write,
2009};
2010
2011/**
2012 * i40e_dbg_pf_init - setup the debugfs directory for the pf
2013 * @pf: the pf that is starting up
2014 **/
2015void i40e_dbg_pf_init(struct i40e_pf *pf)
2016{
2017 struct dentry *pfile __attribute__((unused));
2018 const char *name = pci_name(pf->pdev);
2019
2020 pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root);
2021 if (pf->i40e_dbg_pf) {
2022 pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf,
2023 pf, &i40e_dbg_command_fops);
2024 pfile = debugfs_create_file("dump", 0600, pf->i40e_dbg_pf, pf,
2025 &i40e_dbg_dump_fops);
2026 pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf,
2027 pf, &i40e_dbg_netdev_ops_fops);
2028 } else {
2029 dev_info(&pf->pdev->dev,
2030 "debugfs entry for %s failed\n", name);
2031 }
2032}
2033
2034/**
2035 * i40e_dbg_pf_exit - clear out the pf's debugfs entries
2036 * @pf: the pf that is stopping
2037 **/
2038void i40e_dbg_pf_exit(struct i40e_pf *pf)
2039{
2040 debugfs_remove_recursive(pf->i40e_dbg_pf);
2041 pf->i40e_dbg_pf = NULL;
2042
2043 kfree(i40e_dbg_dump_buf);
2044 i40e_dbg_dump_buf = NULL;
2045}
2046
2047/**
2048 * i40e_dbg_init - start up debugfs for the driver
2049 **/
2050void i40e_dbg_init(void)
2051{
2052 i40e_dbg_root = debugfs_create_dir(i40e_driver_name, NULL);
2053 if (!i40e_dbg_root)
2054 pr_info("init of debugfs failed\n");
2055}
2056
2057/**
2058 * i40e_dbg_exit - clean out the driver's debugfs entries
2059 **/
2060void i40e_dbg_exit(void)
2061{
2062 debugfs_remove_recursive(i40e_dbg_root);
2063 i40e_dbg_root = NULL;
2064}
2065
2066#endif /* CONFIG_DEBUG_FS */