1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 Intel Corporation.
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.
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
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.
19 * The full GNU General Public License is included in this distribution in
20 * the file called "COPYING".
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
26 ******************************************************************************/
28 #ifdef CONFIG_DEBUG_FS
31 #include <linux/debugfs.h>
35 static struct dentry *i40e_dbg_root;
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
42 static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
47 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
49 for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
50 if (pf->vsi[i] && (pf->vsi[i]->seid == seid))
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
61 static struct i40e_veb *i40e_dbg_find_veb(struct i40e_pf *pf, int seid)
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);
69 for (i = 0; i < I40E_MAX_VEB; i++)
70 if (pf->veb[i] && pf->veb[i]->seid == seid)
75 /**************************************************************
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 **************************************************************/
82 static char *i40e_dbg_dump_buf;
83 static ssize_t i40e_dbg_dump_data_len;
84 static ssize_t i40e_dbg_dump_buffer_len;
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
93 static ssize_t i40e_dbg_dump_read(struct file *filp, char __user *buffer,
94 size_t count, loff_t *ppos)
99 /* is *ppos bigger than the available data? */
100 if (*ppos >= i40e_dbg_dump_data_len || !i40e_dbg_dump_buf)
103 /* be sure to not read beyond the end of available data */
104 len = min_t(int, count, (i40e_dbg_dump_data_len - *ppos));
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;
115 * i40e_dbg_prep_dump_buf
116 * @pf: the pf we're working with
117 * @buflen: the desired buffer length
119 * Return positive if success, 0 if failed
121 static int i40e_dbg_prep_dump_buf(struct i40e_pf *pf, int buflen)
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;
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;
137 return i40e_dbg_dump_buffer_len;
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
147 * Any write clears the stats
149 static ssize_t i40e_dbg_dump_write(struct file *filp,
150 const char __user *buffer,
151 size_t count, loff_t *ppos)
153 struct i40e_pf *pf = filp->private_data;
154 char dump_request_buf[16];
155 bool seid_found = false;
156 int bytes_not_copied;
163 /* don't allow partial writes */
166 if (count >= sizeof(dump_request_buf))
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';
176 /* decode the SEID given to be dumped */
177 ret = kstrtol(dump_request_buf, 0, &seid);
179 dev_info(&pf->pdev->dev, "bad seid value '%s'\n",
181 } else if (seid == 0) {
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");
190 } else if (seid == pf->pf_seid || seid == 1) {
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));
197 if (i40e_dbg_prep_dump_buf(pf, buflen)) {
198 p = i40e_dbg_dump_buf;
200 len = sizeof(struct i40e_pf);
204 len = (sizeof(struct i40e_aq_desc)
205 * pf->hw.aq.num_asq_entries);
206 memcpy(p, pf->hw.aq.asq.desc, len);
209 len = (sizeof(struct i40e_aq_desc)
210 * pf->hw.aq.num_arq_entries);
211 memcpy(p, pf->hw.aq.arq.desc, len);
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);
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;
224 mutex_lock(&pf->switch_mutex);
225 vsi = i40e_dbg_find_vsi(pf, seid);
227 mutex_unlock(&pf->switch_mutex);
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)
238 buflen += sizeof(struct i40e_mac_filter) * filter_count;
240 if (i40e_dbg_prep_dump_buf(pf, buflen)) {
241 p = i40e_dbg_dump_buf;
244 len = sizeof(struct i40e_vsi);
248 len = (sizeof(struct i40e_q_vector)
249 * vsi->num_q_vectors);
250 memcpy(p, vsi->q_vectors, len);
253 len = (sizeof(struct i40e_ring) * vsi->num_queue_pairs);
254 memcpy(p, vsi->tx_rings, len);
256 memcpy(p, vsi->rx_rings, len);
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);
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);
270 /* macvlan filter list */
271 len = sizeof(struct i40e_mac_filter);
272 list_for_each_entry(f, &vsi->mac_filter_list, list) {
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);
282 mutex_unlock(&pf->switch_mutex);
283 } else if (seid >= I40E_BASE_VEB_SEID) {
284 struct i40e_veb *veb = NULL;
286 mutex_lock(&pf->switch_mutex);
287 veb = i40e_dbg_find_veb(pf, seid);
289 mutex_unlock(&pf->switch_mutex);
293 buflen = sizeof(struct i40e_veb);
294 if (i40e_dbg_prep_dump_buf(pf, buflen)) {
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);
302 mutex_unlock(&pf->switch_mutex);
307 dev_info(&pf->pdev->dev, "unknown seid %ld\n", seid);
312 static const struct file_operations i40e_dbg_dump_fops = {
313 .owner = THIS_MODULE,
315 .read = i40e_dbg_dump_read,
316 .write = i40e_dbg_dump_write,
319 /**************************************************************
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 **************************************************************/
326 static char i40e_dbg_command_buf[256] = "hello world";
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
335 static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
336 size_t count, loff_t *ppos)
338 struct i40e_pf *pf = filp->private_data;
339 int bytes_not_copied;
344 /* don't allow partial reads */
347 if (count < buf_size)
350 buf = kzalloc(buf_size, GFP_KERNEL);
354 len = snprintf(buf, buf_size, "%s: %s\n",
355 pf->vsi[pf->lan_vsi]->netdev->name,
356 i40e_dbg_command_buf);
358 bytes_not_copied = copy_to_user(buffer, buf, len);
361 if (bytes_not_copied < 0)
362 return bytes_not_copied;
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
373 static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
375 struct rtnl_link_stats64 *nstat;
376 struct i40e_mac_filter *f;
377 struct i40e_vsi *vsi;
380 vsi = i40e_dbg_find_vsi(pf, seid);
382 dev_info(&pf->pdev->dev,
383 "dump %d: seid not found\n", seid);
386 dev_info(&pf->pdev->dev, "vsi seid %d\n", seid);
388 dev_info(&pf->pdev->dev,
389 " netdev: name = %s\n",
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,
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);
488 for (i = 0; i < vsi->num_queue_pairs; i++) {
489 struct i40e_ring *rx_ring = ACCESS_ONCE(vsi->rx_rings[i]);
493 dev_info(&pf->pdev->dev,
494 " rx_rings[%i]: desc = %p\n",
496 dev_info(&pf->pdev->dev,
497 " rx_rings[%i]: dev = %p, netdev = %p, rx_bi = %p\n",
501 dev_info(&pf->pdev->dev,
502 " rx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
504 rx_ring->queue_index,
506 dev_info(&pf->pdev->dev,
507 " rx_rings[%i]: rx_hdr_len = %d, rx_buf_len = %d, dtype = %d\n",
508 i, rx_ring->rx_hdr_len,
511 dev_info(&pf->pdev->dev,
512 " rx_rings[%i]: hsplit = %d, next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
514 rx_ring->next_to_use,
515 rx_ring->next_to_clean,
516 rx_ring->ring_active);
517 dev_info(&pf->pdev->dev,
518 " rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n",
519 i, rx_ring->stats.packets,
520 rx_ring->stats.bytes,
521 rx_ring->rx_stats.non_eop_descs);
522 dev_info(&pf->pdev->dev,
523 " rx_rings[%i]: rx_stats: alloc_rx_page_failed = %lld, alloc_rx_buff_failed = %lld\n",
525 rx_ring->rx_stats.alloc_rx_page_failed,
526 rx_ring->rx_stats.alloc_rx_buff_failed);
527 dev_info(&pf->pdev->dev,
528 " rx_rings[%i]: size = %i, dma = 0x%08lx\n",
530 (long unsigned int)rx_ring->dma);
531 dev_info(&pf->pdev->dev,
532 " rx_rings[%i]: vsi = %p, q_vector = %p\n",
536 for (i = 0; i < vsi->num_queue_pairs; i++) {
537 struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[i]);
540 dev_info(&pf->pdev->dev,
541 " tx_rings[%i]: desc = %p\n",
543 dev_info(&pf->pdev->dev,
544 " tx_rings[%i]: dev = %p, netdev = %p, tx_bi = %p\n",
548 dev_info(&pf->pdev->dev,
549 " tx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
551 tx_ring->queue_index,
553 dev_info(&pf->pdev->dev,
554 " tx_rings[%i]: dtype = %d\n",
556 dev_info(&pf->pdev->dev,
557 " tx_rings[%i]: hsplit = %d, next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
559 tx_ring->next_to_use,
560 tx_ring->next_to_clean,
561 tx_ring->ring_active);
562 dev_info(&pf->pdev->dev,
563 " tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
564 i, tx_ring->stats.packets,
565 tx_ring->stats.bytes,
566 tx_ring->tx_stats.restart_queue);
567 dev_info(&pf->pdev->dev,
568 " tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",
570 tx_ring->tx_stats.tx_busy,
571 tx_ring->tx_stats.tx_done_old);
572 dev_info(&pf->pdev->dev,
573 " tx_rings[%i]: size = %i, dma = 0x%08lx\n",
575 (long unsigned int)tx_ring->dma);
576 dev_info(&pf->pdev->dev,
577 " tx_rings[%i]: vsi = %p, q_vector = %p\n",
580 dev_info(&pf->pdev->dev,
581 " tx_rings[%i]: DCB tc = %d\n",
585 dev_info(&pf->pdev->dev,
586 " work_limit = %d, rx_itr_setting = %d (%s), tx_itr_setting = %d (%s)\n",
587 vsi->work_limit, vsi->rx_itr_setting,
588 ITR_IS_DYNAMIC(vsi->rx_itr_setting) ? "dynamic" : "fixed",
590 ITR_IS_DYNAMIC(vsi->tx_itr_setting) ? "dynamic" : "fixed");
591 dev_info(&pf->pdev->dev,
592 " max_frame = %d, rx_hdr_len = %d, rx_buf_len = %d dtype = %d\n",
593 vsi->max_frame, vsi->rx_hdr_len, vsi->rx_buf_len, vsi->dtype);
594 dev_info(&pf->pdev->dev,
595 " num_q_vectors = %i, base_vector = %i\n",
596 vsi->num_q_vectors, vsi->base_vector);
597 dev_info(&pf->pdev->dev,
598 " seid = %d, id = %d, uplink_seid = %d\n",
599 vsi->seid, vsi->id, vsi->uplink_seid);
600 dev_info(&pf->pdev->dev,
601 " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
602 vsi->base_queue, vsi->num_queue_pairs, vsi->num_desc);
603 dev_info(&pf->pdev->dev, " type = %i\n", vsi->type);
604 dev_info(&pf->pdev->dev,
605 " info: valid_sections = 0x%04x, switch_id = 0x%04x\n",
606 vsi->info.valid_sections, vsi->info.switch_id);
607 dev_info(&pf->pdev->dev,
608 " info: sw_reserved[] = 0x%02x 0x%02x\n",
609 vsi->info.sw_reserved[0], vsi->info.sw_reserved[1]);
610 dev_info(&pf->pdev->dev,
611 " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n",
612 vsi->info.sec_flags, vsi->info.sec_reserved);
613 dev_info(&pf->pdev->dev,
614 " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n",
615 vsi->info.pvid, vsi->info.fcoe_pvid,
616 vsi->info.port_vlan_flags);
617 dev_info(&pf->pdev->dev,
618 " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n",
619 vsi->info.pvlan_reserved[0], vsi->info.pvlan_reserved[1],
620 vsi->info.pvlan_reserved[2]);
621 dev_info(&pf->pdev->dev,
622 " info: ingress_table = 0x%08x, egress_table = 0x%08x\n",
623 vsi->info.ingress_table, vsi->info.egress_table);
624 dev_info(&pf->pdev->dev,
625 " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n",
626 vsi->info.cas_pv_tag, vsi->info.cas_pv_flags,
627 vsi->info.cas_pv_reserved);
628 dev_info(&pf->pdev->dev,
629 " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
630 vsi->info.queue_mapping[0], vsi->info.queue_mapping[1],
631 vsi->info.queue_mapping[2], vsi->info.queue_mapping[3],
632 vsi->info.queue_mapping[4], vsi->info.queue_mapping[5],
633 vsi->info.queue_mapping[6], vsi->info.queue_mapping[7]);
634 dev_info(&pf->pdev->dev,
635 " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
636 vsi->info.queue_mapping[8], vsi->info.queue_mapping[9],
637 vsi->info.queue_mapping[10], vsi->info.queue_mapping[11],
638 vsi->info.queue_mapping[12], vsi->info.queue_mapping[13],
639 vsi->info.queue_mapping[14], vsi->info.queue_mapping[15]);
640 dev_info(&pf->pdev->dev,
641 " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
642 vsi->info.tc_mapping[0], vsi->info.tc_mapping[1],
643 vsi->info.tc_mapping[2], vsi->info.tc_mapping[3],
644 vsi->info.tc_mapping[4], vsi->info.tc_mapping[5],
645 vsi->info.tc_mapping[6], vsi->info.tc_mapping[7]);
646 dev_info(&pf->pdev->dev,
647 " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n",
648 vsi->info.queueing_opt_flags,
649 vsi->info.queueing_opt_reserved[0],
650 vsi->info.queueing_opt_reserved[1],
651 vsi->info.queueing_opt_reserved[2]);
652 dev_info(&pf->pdev->dev,
653 " info: up_enable_bits = 0x%02x\n",
654 vsi->info.up_enable_bits);
655 dev_info(&pf->pdev->dev,
656 " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n",
657 vsi->info.sched_reserved, vsi->info.outer_up_table);
658 dev_info(&pf->pdev->dev,
659 " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n",
660 vsi->info.cmd_reserved[0], vsi->info.cmd_reserved[1],
661 vsi->info.cmd_reserved[2], vsi->info.cmd_reserved[3],
662 vsi->info.cmd_reserved[4], vsi->info.cmd_reserved[5],
663 vsi->info.cmd_reserved[6], vsi->info.cmd_reserved[7]);
664 dev_info(&pf->pdev->dev,
665 " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
666 vsi->info.qs_handle[0], vsi->info.qs_handle[1],
667 vsi->info.qs_handle[2], vsi->info.qs_handle[3],
668 vsi->info.qs_handle[4], vsi->info.qs_handle[5],
669 vsi->info.qs_handle[6], vsi->info.qs_handle[7]);
670 dev_info(&pf->pdev->dev,
671 " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n",
672 vsi->info.stat_counter_idx, vsi->info.sched_id);
673 dev_info(&pf->pdev->dev,
674 " 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",
675 vsi->info.resp_reserved[0], vsi->info.resp_reserved[1],
676 vsi->info.resp_reserved[2], vsi->info.resp_reserved[3],
677 vsi->info.resp_reserved[4], vsi->info.resp_reserved[5],
678 vsi->info.resp_reserved[6], vsi->info.resp_reserved[7],
679 vsi->info.resp_reserved[8], vsi->info.resp_reserved[9],
680 vsi->info.resp_reserved[10], vsi->info.resp_reserved[11]);
682 dev_info(&pf->pdev->dev, " pf = %p\n", vsi->back);
683 dev_info(&pf->pdev->dev, " idx = %d\n", vsi->idx);
684 dev_info(&pf->pdev->dev,
685 " tc_config: numtc = %d, enabled_tc = 0x%x\n",
686 vsi->tc_config.numtc, vsi->tc_config.enabled_tc);
687 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
688 dev_info(&pf->pdev->dev,
689 " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n",
690 i, vsi->tc_config.tc_info[i].qoffset,
691 vsi->tc_config.tc_info[i].qcount,
692 vsi->tc_config.tc_info[i].netdev_tc);
694 dev_info(&pf->pdev->dev,
695 " bw: bw_limit = %d, bw_max_quanta = %d\n",
696 vsi->bw_limit, vsi->bw_max_quanta);
697 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
698 dev_info(&pf->pdev->dev,
699 " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n",
700 i, vsi->bw_ets_share_credits[i],
701 vsi->bw_ets_limit_credits[i],
702 vsi->bw_ets_max_quanta[i]);
707 * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum
708 * @pf: the i40e_pf created in command write
710 static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf)
712 struct i40e_adminq_ring *ring;
713 struct i40e_hw *hw = &pf->hw;
716 /* first the send (command) ring, then the receive (event) ring */
717 dev_info(&pf->pdev->dev, "AdminQ Tx Ring\n");
718 ring = &(hw->aq.asq);
719 for (i = 0; i < ring->count; i++) {
720 struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
721 dev_info(&pf->pdev->dev,
722 " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
723 i, d->flags, d->opcode, d->datalen, d->retval,
724 d->cookie_high, d->cookie_low);
725 dev_info(&pf->pdev->dev,
726 " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
727 d->params.raw[0], d->params.raw[1], d->params.raw[2],
728 d->params.raw[3], d->params.raw[4], d->params.raw[5],
729 d->params.raw[6], d->params.raw[7], d->params.raw[8],
730 d->params.raw[9], d->params.raw[10], d->params.raw[11],
731 d->params.raw[12], d->params.raw[13],
732 d->params.raw[14], d->params.raw[15]);
735 dev_info(&pf->pdev->dev, "AdminQ Rx Ring\n");
736 ring = &(hw->aq.arq);
737 for (i = 0; i < ring->count; i++) {
738 struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
739 dev_info(&pf->pdev->dev,
740 " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
741 i, d->flags, d->opcode, d->datalen, d->retval,
742 d->cookie_high, d->cookie_low);
743 dev_info(&pf->pdev->dev,
744 " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
745 d->params.raw[0], d->params.raw[1], d->params.raw[2],
746 d->params.raw[3], d->params.raw[4], d->params.raw[5],
747 d->params.raw[6], d->params.raw[7], d->params.raw[8],
748 d->params.raw[9], d->params.raw[10], d->params.raw[11],
749 d->params.raw[12], d->params.raw[13],
750 d->params.raw[14], d->params.raw[15]);
755 * i40e_dbg_dump_desc - handles dump desc write into command datum
756 * @cnt: number of arguments that the user supplied
757 * @vsi_seid: vsi id entered by user
758 * @ring_id: ring id entered by user
759 * @desc_n: descriptor number entered by user
760 * @pf: the i40e_pf created in command write
761 * @is_rx_ring: true if rx, false if tx
763 static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
764 struct i40e_pf *pf, bool is_rx_ring)
766 union i40e_rx_desc *ds;
767 struct i40e_ring ring;
768 struct i40e_vsi *vsi;
771 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
773 dev_info(&pf->pdev->dev,
774 "vsi %d not found\n", vsi_seid);
776 dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
778 dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
781 if (ring_id >= vsi->num_queue_pairs || ring_id < 0) {
782 dev_info(&pf->pdev->dev, "ring %d not found\n", ring_id);
784 dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
786 dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
790 ring = *vsi->rx_rings[ring_id];
792 ring = *vsi->tx_rings[ring_id];
794 dev_info(&pf->pdev->dev, "vsi = %02i %s ring = %02i\n",
795 vsi_seid, is_rx_ring ? "rx" : "tx", ring_id);
796 for (i = 0; i < ring.count; i++) {
798 ds = I40E_RX_DESC(&ring, i);
800 ds = (union i40e_rx_desc *)
801 I40E_TX_DESC(&ring, i);
802 if ((sizeof(union i40e_rx_desc) ==
803 sizeof(union i40e_16byte_rx_desc)) || (!is_rx_ring))
804 dev_info(&pf->pdev->dev,
805 " d[%03i] = 0x%016llx 0x%016llx\n", i,
806 ds->read.pkt_addr, ds->read.hdr_addr);
808 dev_info(&pf->pdev->dev,
809 " d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
810 i, ds->read.pkt_addr,
812 ds->read.rsvd1, ds->read.rsvd2);
814 } else if (cnt == 3) {
815 if (desc_n >= ring.count || desc_n < 0) {
816 dev_info(&pf->pdev->dev,
817 "descriptor %d not found\n", desc_n);
821 ds = I40E_RX_DESC(&ring, desc_n);
823 ds = (union i40e_rx_desc *)I40E_TX_DESC(&ring, desc_n);
824 if ((sizeof(union i40e_rx_desc) ==
825 sizeof(union i40e_16byte_rx_desc)) || (!is_rx_ring))
826 dev_info(&pf->pdev->dev,
827 "vsi = %02i %s ring = %02i d[%03i] = 0x%016llx 0x%016llx\n",
828 vsi_seid, is_rx_ring ? "rx" : "tx", ring_id,
829 desc_n, ds->read.pkt_addr, ds->read.hdr_addr);
831 dev_info(&pf->pdev->dev,
832 "vsi = %02i rx ring = %02i d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
834 desc_n, ds->read.pkt_addr, ds->read.hdr_addr,
835 ds->read.rsvd1, ds->read.rsvd2);
838 dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
840 dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
845 * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum
846 * @pf: the i40e_pf created in command write
848 static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf *pf)
852 for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
854 dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n",
855 i, pf->vsi[i]->seid);
859 * i40e_dbg_dump_stats - handles dump stats write into command datum
860 * @pf: the i40e_pf created in command write
861 * @estats: the eth stats structure to be dumped
863 static void i40e_dbg_dump_eth_stats(struct i40e_pf *pf,
864 struct i40e_eth_stats *estats)
866 dev_info(&pf->pdev->dev, " ethstats:\n");
867 dev_info(&pf->pdev->dev,
868 " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n",
869 estats->rx_bytes, estats->rx_unicast, estats->rx_multicast);
870 dev_info(&pf->pdev->dev,
871 " rx_broadcast = \t%lld \trx_discards = \t\t%lld \trx_errors = \t%lld\n",
872 estats->rx_broadcast, estats->rx_discards, estats->rx_errors);
873 dev_info(&pf->pdev->dev,
874 " rx_missed = \t%lld \trx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n",
875 estats->rx_missed, estats->rx_unknown_protocol,
877 dev_info(&pf->pdev->dev,
878 " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n",
879 estats->tx_unicast, estats->tx_multicast, estats->tx_broadcast);
880 dev_info(&pf->pdev->dev,
881 " tx_discards = \t%lld \ttx_errors = \t\t%lld\n",
882 estats->tx_discards, estats->tx_errors);
886 * i40e_dbg_dump_stats - handles dump stats write into command datum
887 * @pf: the i40e_pf created in command write
888 * @stats: the stats structure to be dumped
890 static void i40e_dbg_dump_stats(struct i40e_pf *pf,
891 struct i40e_hw_port_stats *stats)
895 dev_info(&pf->pdev->dev, " stats:\n");
896 dev_info(&pf->pdev->dev,
897 " crc_errors = \t\t%lld \tillegal_bytes = \t%lld \terror_bytes = \t\t%lld\n",
898 stats->crc_errors, stats->illegal_bytes, stats->error_bytes);
899 dev_info(&pf->pdev->dev,
900 " mac_local_faults = \t%lld \tmac_remote_faults = \t%lld \trx_length_errors = \t%lld\n",
901 stats->mac_local_faults, stats->mac_remote_faults,
902 stats->rx_length_errors);
903 dev_info(&pf->pdev->dev,
904 " link_xon_rx = \t\t%lld \tlink_xoff_rx = \t\t%lld \tlink_xon_tx = \t\t%lld\n",
905 stats->link_xon_rx, stats->link_xoff_rx, stats->link_xon_tx);
906 dev_info(&pf->pdev->dev,
907 " link_xoff_tx = \t\t%lld \trx_size_64 = \t\t%lld \trx_size_127 = \t\t%lld\n",
908 stats->link_xoff_tx, stats->rx_size_64, stats->rx_size_127);
909 dev_info(&pf->pdev->dev,
910 " rx_size_255 = \t\t%lld \trx_size_511 = \t\t%lld \trx_size_1023 = \t\t%lld\n",
911 stats->rx_size_255, stats->rx_size_511, stats->rx_size_1023);
912 dev_info(&pf->pdev->dev,
913 " rx_size_big = \t\t%lld \trx_undersize = \t\t%lld \trx_jabber = \t\t%lld\n",
914 stats->rx_size_big, stats->rx_undersize, stats->rx_jabber);
915 dev_info(&pf->pdev->dev,
916 " rx_fragments = \t\t%lld \trx_oversize = \t\t%lld \ttx_size_64 = \t\t%lld\n",
917 stats->rx_fragments, stats->rx_oversize, stats->tx_size_64);
918 dev_info(&pf->pdev->dev,
919 " tx_size_127 = \t\t%lld \ttx_size_255 = \t\t%lld \ttx_size_511 = \t\t%lld\n",
920 stats->tx_size_127, stats->tx_size_255, stats->tx_size_511);
921 dev_info(&pf->pdev->dev,
922 " tx_size_1023 = \t\t%lld \ttx_size_big = \t\t%lld \tmac_short_packet_dropped = \t%lld\n",
923 stats->tx_size_1023, stats->tx_size_big,
924 stats->mac_short_packet_dropped);
925 for (i = 0; i < 8; i += 4) {
926 dev_info(&pf->pdev->dev,
927 " priority_xon_rx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
928 i, stats->priority_xon_rx[i],
929 i+1, stats->priority_xon_rx[i+1],
930 i+2, stats->priority_xon_rx[i+2],
931 i+3, stats->priority_xon_rx[i+3]);
933 for (i = 0; i < 8; i += 4) {
934 dev_info(&pf->pdev->dev,
935 " priority_xoff_rx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
936 i, stats->priority_xoff_rx[i],
937 i+1, stats->priority_xoff_rx[i+1],
938 i+2, stats->priority_xoff_rx[i+2],
939 i+3, stats->priority_xoff_rx[i+3]);
941 for (i = 0; i < 8; i += 4) {
942 dev_info(&pf->pdev->dev,
943 " priority_xon_tx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
944 i, stats->priority_xon_tx[i],
945 i+1, stats->priority_xon_tx[i+1],
946 i+2, stats->priority_xon_tx[i+2],
947 i+3, stats->priority_xon_rx[i+3]);
949 for (i = 0; i < 8; i += 4) {
950 dev_info(&pf->pdev->dev,
951 " priority_xoff_tx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
952 i, stats->priority_xoff_tx[i],
953 i+1, stats->priority_xoff_tx[i+1],
954 i+2, stats->priority_xoff_tx[i+2],
955 i+3, stats->priority_xoff_tx[i+3]);
957 for (i = 0; i < 8; i += 4) {
958 dev_info(&pf->pdev->dev,
959 " priority_xon_2_xoff[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
960 i, stats->priority_xon_2_xoff[i],
961 i+1, stats->priority_xon_2_xoff[i+1],
962 i+2, stats->priority_xon_2_xoff[i+2],
963 i+3, stats->priority_xon_2_xoff[i+3]);
966 i40e_dbg_dump_eth_stats(pf, &stats->eth);
970 * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb
971 * @pf: the i40e_pf created in command write
972 * @seid: the seid the user put in
974 static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid)
976 struct i40e_veb *veb;
978 if ((seid < I40E_BASE_VEB_SEID) ||
979 (seid >= (I40E_MAX_VEB + I40E_BASE_VEB_SEID))) {
980 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
984 veb = i40e_dbg_find_veb(pf, seid);
986 dev_info(&pf->pdev->dev,
987 "%d: can't find veb\n", seid);
990 dev_info(&pf->pdev->dev,
991 "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d\n",
992 veb->idx, veb->veb_idx, veb->stats_idx, veb->seid,
994 i40e_dbg_dump_eth_stats(pf, &veb->stats);
998 * i40e_dbg_dump_veb_all - dumps all known veb's stats
999 * @pf: the i40e_pf created in command write
1001 static void i40e_dbg_dump_veb_all(struct i40e_pf *pf)
1003 struct i40e_veb *veb;
1006 for (i = 0; i < I40E_MAX_VEB; i++) {
1009 i40e_dbg_dump_veb_seid(pf, veb->seid);
1013 #define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
1015 * i40e_dbg_command_write - write into command datum
1016 * @filp: the opened file
1017 * @buffer: where to find the user's data
1018 * @count: the length of the user's data
1019 * @ppos: file position offset
1021 static ssize_t i40e_dbg_command_write(struct file *filp,
1022 const char __user *buffer,
1023 size_t count, loff_t *ppos)
1025 struct i40e_pf *pf = filp->private_data;
1026 int bytes_not_copied;
1027 struct i40e_vsi *vsi;
1028 u8 *print_buf_start;
1035 /* don't allow partial writes */
1039 cmd_buf = kzalloc(count + 1, GFP_KERNEL);
1042 bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
1043 if (bytes_not_copied < 0)
1044 return bytes_not_copied;
1045 if (bytes_not_copied > 0)
1046 count -= bytes_not_copied;
1047 cmd_buf[count] = '\0';
1049 print_buf_start = kzalloc(I40E_MAX_DEBUG_OUT_BUFFER, GFP_KERNEL);
1050 if (!print_buf_start)
1051 goto command_write_done;
1052 print_buf = print_buf_start;
1054 if (strncmp(cmd_buf, "add vsi", 7) == 0) {
1056 cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
1058 /* default to PF VSI */
1059 vsi_seid = pf->vsi[pf->lan_vsi]->seid;
1060 } else if (vsi_seid < 0) {
1061 dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n",
1063 goto command_write_done;
1066 vsi = i40e_vsi_setup(pf, I40E_VSI_VMDQ2, vsi_seid, 0);
1068 dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n",
1069 vsi->seid, vsi->uplink_seid);
1071 dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf);
1073 } else if (strncmp(cmd_buf, "del vsi", 7) == 0) {
1074 sscanf(&cmd_buf[7], "%i", &vsi_seid);
1075 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1077 dev_info(&pf->pdev->dev, "del VSI %d: seid not found\n",
1079 goto command_write_done;
1082 dev_info(&pf->pdev->dev, "deleting VSI %d\n", vsi_seid);
1083 i40e_vsi_release(vsi);
1085 } else if (strncmp(cmd_buf, "add relay", 9) == 0) {
1086 struct i40e_veb *veb;
1089 cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid);
1091 dev_info(&pf->pdev->dev,
1092 "add relay: bad command string, cnt=%d\n",
1094 goto command_write_done;
1095 } else if (uplink_seid < 0) {
1096 dev_info(&pf->pdev->dev,
1097 "add relay %d: bad uplink seid\n",
1099 goto command_write_done;
1102 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1104 dev_info(&pf->pdev->dev,
1105 "add relay: vsi VSI %d not found\n", vsi_seid);
1106 goto command_write_done;
1109 for (i = 0; i < I40E_MAX_VEB; i++)
1110 if (pf->veb[i] && pf->veb[i]->seid == uplink_seid)
1112 if (i >= I40E_MAX_VEB && uplink_seid != 0 &&
1113 uplink_seid != pf->mac_seid) {
1114 dev_info(&pf->pdev->dev,
1115 "add relay: relay uplink %d not found\n",
1117 goto command_write_done;
1120 veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid,
1121 vsi->tc_config.enabled_tc);
1123 dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid);
1125 dev_info(&pf->pdev->dev, "add relay failed\n");
1127 } else if (strncmp(cmd_buf, "del relay", 9) == 0) {
1129 cnt = sscanf(&cmd_buf[9], "%i", &veb_seid);
1131 dev_info(&pf->pdev->dev,
1132 "del relay: bad command string, cnt=%d\n",
1134 goto command_write_done;
1135 } else if (veb_seid < 0) {
1136 dev_info(&pf->pdev->dev,
1137 "del relay %d: bad relay seid\n", veb_seid);
1138 goto command_write_done;
1142 for (i = 0; i < I40E_MAX_VEB; i++)
1143 if (pf->veb[i] && pf->veb[i]->seid == veb_seid)
1145 if (i >= I40E_MAX_VEB) {
1146 dev_info(&pf->pdev->dev,
1147 "del relay: relay %d not found\n", veb_seid);
1148 goto command_write_done;
1151 dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid);
1152 i40e_veb_release(pf->veb[i]);
1154 } else if (strncmp(cmd_buf, "add macaddr", 11) == 0) {
1157 struct i40e_mac_filter *f;
1160 cnt = sscanf(&cmd_buf[11],
1161 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
1163 &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
1167 } else if (cnt != 8) {
1168 dev_info(&pf->pdev->dev,
1169 "add macaddr: bad command string, cnt=%d\n",
1171 goto command_write_done;
1174 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1176 dev_info(&pf->pdev->dev,
1177 "add macaddr: VSI %d not found\n", vsi_seid);
1178 goto command_write_done;
1181 f = i40e_add_filter(vsi, ma, vlan, false, false);
1182 ret = i40e_sync_vsi_filters(vsi);
1184 dev_info(&pf->pdev->dev,
1185 "add macaddr: %pM vlan=%d added to VSI %d\n",
1186 ma, vlan, vsi_seid);
1188 dev_info(&pf->pdev->dev,
1189 "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
1190 ma, vlan, vsi_seid, f, ret);
1192 } else if (strncmp(cmd_buf, "del macaddr", 11) == 0) {
1197 cnt = sscanf(&cmd_buf[11],
1198 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
1200 &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
1204 } else if (cnt != 8) {
1205 dev_info(&pf->pdev->dev,
1206 "del macaddr: bad command string, cnt=%d\n",
1208 goto command_write_done;
1211 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1213 dev_info(&pf->pdev->dev,
1214 "del macaddr: VSI %d not found\n", vsi_seid);
1215 goto command_write_done;
1218 i40e_del_filter(vsi, ma, vlan, false, false);
1219 ret = i40e_sync_vsi_filters(vsi);
1221 dev_info(&pf->pdev->dev,
1222 "del macaddr: %pM vlan=%d removed from VSI %d\n",
1223 ma, vlan, vsi_seid);
1225 dev_info(&pf->pdev->dev,
1226 "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
1227 ma, vlan, vsi_seid, ret);
1229 } else if (strncmp(cmd_buf, "add pvid", 8) == 0) {
1234 cnt = sscanf(&cmd_buf[8], "%i %u", &vsi_seid, &v);
1236 dev_info(&pf->pdev->dev,
1237 "add pvid: bad command string, cnt=%d\n", cnt);
1238 goto command_write_done;
1241 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1243 dev_info(&pf->pdev->dev, "add pvid: VSI %d not found\n",
1245 goto command_write_done;
1249 ret = i40e_vsi_add_pvid(vsi, vid);
1251 dev_info(&pf->pdev->dev,
1252 "add pvid: %d added to VSI %d\n",
1255 dev_info(&pf->pdev->dev,
1256 "add pvid: %d to VSI %d failed, ret=%d\n",
1257 vid, vsi_seid, ret);
1259 } else if (strncmp(cmd_buf, "del pvid", 8) == 0) {
1261 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1263 dev_info(&pf->pdev->dev,
1264 "del pvid: bad command string, cnt=%d\n",
1266 goto command_write_done;
1269 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1271 dev_info(&pf->pdev->dev,
1272 "del pvid: VSI %d not found\n", vsi_seid);
1273 goto command_write_done;
1276 i40e_vsi_remove_pvid(vsi);
1277 dev_info(&pf->pdev->dev,
1278 "del pvid: removed from VSI %d\n", vsi_seid);
1280 } else if (strncmp(cmd_buf, "dump", 4) == 0) {
1281 if (strncmp(&cmd_buf[5], "switch", 6) == 0) {
1282 i40e_fetch_switch_configuration(pf, true);
1283 } else if (strncmp(&cmd_buf[5], "vsi", 3) == 0) {
1284 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1286 i40e_dbg_dump_vsi_seid(pf, vsi_seid);
1288 i40e_dbg_dump_vsi_no_seid(pf);
1289 } else if (strncmp(&cmd_buf[5], "veb", 3) == 0) {
1290 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1292 i40e_dbg_dump_veb_seid(pf, vsi_seid);
1294 i40e_dbg_dump_veb_all(pf);
1295 } else if (strncmp(&cmd_buf[5], "desc", 4) == 0) {
1296 int ring_id, desc_n;
1297 if (strncmp(&cmd_buf[10], "rx", 2) == 0) {
1298 cnt = sscanf(&cmd_buf[12], "%i %i %i",
1299 &vsi_seid, &ring_id, &desc_n);
1300 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1302 } else if (strncmp(&cmd_buf[10], "tx", 2)
1304 cnt = sscanf(&cmd_buf[12], "%i %i %i",
1305 &vsi_seid, &ring_id, &desc_n);
1306 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1308 } else if (strncmp(&cmd_buf[10], "aq", 2) == 0) {
1309 i40e_dbg_dump_aq_desc(pf);
1311 dev_info(&pf->pdev->dev,
1312 "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1313 dev_info(&pf->pdev->dev,
1314 "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1315 dev_info(&pf->pdev->dev, "dump desc aq\n");
1317 } else if (strncmp(&cmd_buf[5], "stats", 5) == 0) {
1318 dev_info(&pf->pdev->dev, "pf stats:\n");
1319 i40e_dbg_dump_stats(pf, &pf->stats);
1320 dev_info(&pf->pdev->dev, "pf stats_offsets:\n");
1321 i40e_dbg_dump_stats(pf, &pf->stats_offsets);
1322 } else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) {
1323 dev_info(&pf->pdev->dev,
1324 "core reset count: %d\n", pf->corer_count);
1325 dev_info(&pf->pdev->dev,
1326 "global reset count: %d\n", pf->globr_count);
1327 dev_info(&pf->pdev->dev,
1328 "emp reset count: %d\n", pf->empr_count);
1329 dev_info(&pf->pdev->dev,
1330 "pf reset count: %d\n", pf->pfr_count);
1331 } else if (strncmp(&cmd_buf[5], "port", 4) == 0) {
1332 struct i40e_aqc_query_port_ets_config_resp *bw_data;
1333 struct i40e_dcbx_config *cfg =
1334 &pf->hw.local_dcbx_config;
1335 struct i40e_dcbx_config *r_cfg =
1336 &pf->hw.remote_dcbx_config;
1339 bw_data = kzalloc(sizeof(
1340 struct i40e_aqc_query_port_ets_config_resp),
1344 goto command_write_done;
1347 ret = i40e_aq_query_port_ets_config(&pf->hw,
1351 dev_info(&pf->pdev->dev,
1352 "Query Port ETS Config AQ command failed =0x%x\n",
1353 pf->hw.aq.asq_last_status);
1356 goto command_write_done;
1358 dev_info(&pf->pdev->dev,
1359 "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
1360 bw_data->tc_valid_bits,
1361 bw_data->tc_strict_priority_bits,
1362 le16_to_cpu(bw_data->tc_bw_max[0]),
1363 le16_to_cpu(bw_data->tc_bw_max[1]));
1364 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1365 dev_info(&pf->pdev->dev, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
1366 bw_data->tc_bw_share_credits[i],
1367 le16_to_cpu(bw_data->tc_bw_limits[i]));
1373 dev_info(&pf->pdev->dev,
1374 "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1375 cfg->etscfg.willing, cfg->etscfg.cbs,
1376 cfg->etscfg.maxtcs);
1377 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1378 dev_info(&pf->pdev->dev, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1379 i, cfg->etscfg.prioritytable[i],
1380 cfg->etscfg.tcbwtable[i],
1381 cfg->etscfg.tsatable[i]);
1383 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1384 dev_info(&pf->pdev->dev, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1385 i, cfg->etsrec.prioritytable[i],
1386 cfg->etsrec.tcbwtable[i],
1387 cfg->etsrec.tsatable[i]);
1389 dev_info(&pf->pdev->dev,
1390 "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1391 cfg->pfc.willing, cfg->pfc.mbc,
1392 cfg->pfc.pfccap, cfg->pfc.pfcenable);
1393 dev_info(&pf->pdev->dev,
1394 "port app_table: num_apps=%d\n", cfg->numapps);
1395 for (i = 0; i < cfg->numapps; i++) {
1396 dev_info(&pf->pdev->dev, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1397 i, cfg->app[i].priority,
1398 cfg->app[i].selector,
1399 cfg->app[i].protocolid);
1401 /* Peer TLV DCBX data */
1402 dev_info(&pf->pdev->dev,
1403 "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1404 r_cfg->etscfg.willing,
1405 r_cfg->etscfg.cbs, r_cfg->etscfg.maxtcs);
1406 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1407 dev_info(&pf->pdev->dev, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1408 i, r_cfg->etscfg.prioritytable[i],
1409 r_cfg->etscfg.tcbwtable[i],
1410 r_cfg->etscfg.tsatable[i]);
1412 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1413 dev_info(&pf->pdev->dev, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1414 i, r_cfg->etsrec.prioritytable[i],
1415 r_cfg->etsrec.tcbwtable[i],
1416 r_cfg->etsrec.tsatable[i]);
1418 dev_info(&pf->pdev->dev,
1419 "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1423 r_cfg->pfc.pfcenable);
1424 dev_info(&pf->pdev->dev,
1425 "remote port app_table: num_apps=%d\n",
1427 for (i = 0; i < r_cfg->numapps; i++) {
1428 dev_info(&pf->pdev->dev, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1429 i, r_cfg->app[i].priority,
1430 r_cfg->app[i].selector,
1431 r_cfg->app[i].protocolid);
1434 dev_info(&pf->pdev->dev,
1435 "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
1436 dev_info(&pf->pdev->dev, "dump switch, dump vsi [seid] or\n");
1437 dev_info(&pf->pdev->dev, "dump stats\n");
1438 dev_info(&pf->pdev->dev, "dump reset stats\n");
1439 dev_info(&pf->pdev->dev, "dump port\n");
1440 dev_info(&pf->pdev->dev,
1441 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1444 } else if (strncmp(cmd_buf, "msg_enable", 10) == 0) {
1446 cnt = sscanf(&cmd_buf[10], "%i", &level);
1448 if (I40E_DEBUG_USER & level) {
1449 pf->hw.debug_mask = level;
1450 dev_info(&pf->pdev->dev,
1451 "set hw.debug_mask = 0x%08x\n",
1454 pf->msg_enable = level;
1455 dev_info(&pf->pdev->dev, "set msg_enable = 0x%08x\n",
1458 dev_info(&pf->pdev->dev, "msg_enable = 0x%08x\n",
1461 } else if (strncmp(cmd_buf, "pfr", 3) == 0) {
1462 dev_info(&pf->pdev->dev, "forcing PFR\n");
1463 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
1465 } else if (strncmp(cmd_buf, "corer", 5) == 0) {
1466 dev_info(&pf->pdev->dev, "forcing CoreR\n");
1467 i40e_do_reset(pf, (1 << __I40E_CORE_RESET_REQUESTED));
1469 } else if (strncmp(cmd_buf, "globr", 5) == 0) {
1470 dev_info(&pf->pdev->dev, "forcing GlobR\n");
1471 i40e_do_reset(pf, (1 << __I40E_GLOBAL_RESET_REQUESTED));
1473 } else if (strncmp(cmd_buf, "read", 4) == 0) {
1476 cnt = sscanf(&cmd_buf[4], "%x", &address);
1478 dev_info(&pf->pdev->dev, "read <reg>\n");
1479 goto command_write_done;
1482 /* check the range on address */
1483 if (address >= I40E_MAX_REGISTER) {
1484 dev_info(&pf->pdev->dev, "read reg address 0x%08x too large\n",
1486 goto command_write_done;
1489 value = rd32(&pf->hw, address);
1490 dev_info(&pf->pdev->dev, "read: 0x%08x = 0x%08x\n",
1493 } else if (strncmp(cmd_buf, "write", 5) == 0) {
1495 cnt = sscanf(&cmd_buf[5], "%x %x", &address, &value);
1497 dev_info(&pf->pdev->dev, "write <reg> <value>\n");
1498 goto command_write_done;
1501 /* check the range on address */
1502 if (address >= I40E_MAX_REGISTER) {
1503 dev_info(&pf->pdev->dev, "write reg address 0x%08x too large\n",
1505 goto command_write_done;
1507 wr32(&pf->hw, address, value);
1508 value = rd32(&pf->hw, address);
1509 dev_info(&pf->pdev->dev, "write: 0x%08x = 0x%08x\n",
1511 } else if (strncmp(cmd_buf, "clear_stats", 11) == 0) {
1512 if (strncmp(&cmd_buf[12], "vsi", 3) == 0) {
1513 cnt = sscanf(&cmd_buf[15], "%d", &vsi_seid);
1516 for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
1517 i40e_vsi_reset_stats(pf->vsi[i]);
1518 dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n");
1519 } else if (cnt == 1) {
1520 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1522 dev_info(&pf->pdev->dev,
1523 "clear_stats vsi: bad vsi %d\n",
1525 goto command_write_done;
1527 i40e_vsi_reset_stats(vsi);
1528 dev_info(&pf->pdev->dev,
1529 "vsi clear stats called for vsi %d\n",
1532 dev_info(&pf->pdev->dev, "clear_stats vsi [seid]\n");
1534 } else if (strncmp(&cmd_buf[12], "pf", 2) == 0) {
1535 i40e_pf_reset_stats(pf);
1536 dev_info(&pf->pdev->dev, "pf clear stats called\n");
1538 dev_info(&pf->pdev->dev, "clear_stats vsi [seid] or clear_stats pf\n");
1540 } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) ||
1541 (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) {
1542 struct i40e_fdir_data fd_data;
1544 u16 packet_len, i, j = 0;
1548 asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
1551 goto command_write_done;
1553 fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
1556 if (!fd_data.raw_packet) {
1559 goto command_write_done;
1562 if (strncmp(cmd_buf, "add", 3) == 0)
1564 cnt = sscanf(&cmd_buf[13],
1565 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %512s",
1567 &fd_data.flex_off, &fd_data.pctype,
1568 &fd_data.dest_vsi, &fd_data.dest_ctl,
1569 &fd_data.fd_status, &fd_data.cnt_index,
1570 &fd_data.fd_id, &packet_len, asc_packet);
1572 dev_info(&pf->pdev->dev,
1573 "program fd_filter: bad command string, cnt=%d\n",
1577 kfree(fd_data.raw_packet);
1578 goto command_write_done;
1581 /* fix packet length if user entered 0 */
1582 if (packet_len == 0)
1583 packet_len = I40E_FDIR_MAX_RAW_PACKET_LOOKUP;
1585 /* make sure to check the max as well */
1586 packet_len = min_t(u16,
1587 packet_len, I40E_FDIR_MAX_RAW_PACKET_LOOKUP);
1589 dev_info(&pf->pdev->dev, "FD raw packet:\n");
1590 for (i = 0; i < packet_len; i++) {
1591 sscanf(&asc_packet[j], "%2hhx ",
1592 &fd_data.raw_packet[i]);
1594 snprintf(print_buf, 3, "%02x ", fd_data.raw_packet[i]);
1596 if ((i % 16) == 15) {
1597 snprintf(print_buf, 1, "\n");
1601 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1602 ret = i40e_program_fdir_filter(&fd_data, pf, add);
1604 dev_info(&pf->pdev->dev, "Filter command send Status : Success\n");
1606 dev_info(&pf->pdev->dev,
1607 "Filter command send failed %d\n", ret);
1609 kfree(fd_data.raw_packet);
1610 fd_data.raw_packet = NULL;
1613 } else if (strncmp(cmd_buf, "lldp", 4) == 0) {
1614 if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
1616 ret = i40e_aq_stop_lldp(&pf->hw, false, NULL);
1618 dev_info(&pf->pdev->dev,
1619 "Stop LLDP AQ command failed =0x%x\n",
1620 pf->hw.aq.asq_last_status);
1621 goto command_write_done;
1623 } else if (strncmp(&cmd_buf[5], "start", 5) == 0) {
1625 ret = i40e_aq_start_lldp(&pf->hw, NULL);
1627 dev_info(&pf->pdev->dev,
1628 "Start LLDP AQ command failed =0x%x\n",
1629 pf->hw.aq.asq_last_status);
1630 goto command_write_done;
1632 } else if (strncmp(&cmd_buf[5],
1633 "get local", 9) == 0) {
1637 buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
1639 goto command_write_done;
1641 ret = i40e_aq_get_lldp_mib(&pf->hw, 0,
1642 I40E_AQ_LLDP_MIB_LOCAL,
1643 buff, I40E_LLDPDU_SIZE,
1644 &llen, &rlen, NULL);
1646 dev_info(&pf->pdev->dev,
1647 "Get LLDP MIB (local) AQ command failed =0x%x\n",
1648 pf->hw.aq.asq_last_status);
1651 goto command_write_done;
1653 dev_info(&pf->pdev->dev,
1654 "Get LLDP MIB (local) AQ buffer written back:\n");
1655 for (i = 0; i < I40E_LLDPDU_SIZE; i++) {
1656 snprintf(print_buf, 3, "%02x ", buff[i]);
1658 if ((i % 16) == 15) {
1659 snprintf(print_buf, 1, "\n");
1663 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1666 } else if (strncmp(&cmd_buf[5], "get remote", 10) == 0) {
1670 buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
1672 goto command_write_done;
1674 ret = i40e_aq_get_lldp_mib(&pf->hw,
1675 I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE,
1676 I40E_AQ_LLDP_MIB_LOCAL,
1677 buff, I40E_LLDPDU_SIZE,
1678 &llen, &rlen, NULL);
1680 dev_info(&pf->pdev->dev,
1681 "Get LLDP MIB (remote) AQ command failed =0x%x\n",
1682 pf->hw.aq.asq_last_status);
1685 goto command_write_done;
1687 dev_info(&pf->pdev->dev,
1688 "Get LLDP MIB (remote) AQ buffer written back:\n");
1689 for (i = 0; i < I40E_LLDPDU_SIZE; i++) {
1690 snprintf(print_buf, 3, "%02x ", buff[i]);
1692 if ((i % 16) == 15) {
1693 snprintf(print_buf, 1, "\n");
1697 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1700 } else if (strncmp(&cmd_buf[5], "event on", 8) == 0) {
1702 ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
1705 dev_info(&pf->pdev->dev,
1706 "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
1707 pf->hw.aq.asq_last_status);
1708 goto command_write_done;
1710 } else if (strncmp(&cmd_buf[5], "event off", 9) == 0) {
1712 ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
1715 dev_info(&pf->pdev->dev,
1716 "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
1717 pf->hw.aq.asq_last_status);
1718 goto command_write_done;
1721 } else if (strncmp(cmd_buf, "nvm read", 8) == 0) {
1722 u16 buffer_len, i, bytes;
1728 cnt = sscanf(&cmd_buf[8], "%hx %x %hx",
1729 &module, &offset, &buffer_len);
1734 } else if (cnt == 1) {
1737 } else if (cnt == 2) {
1739 } else if (cnt > 3) {
1740 dev_info(&pf->pdev->dev,
1741 "nvm read: bad command string, cnt=%d\n", cnt);
1742 goto command_write_done;
1745 /* Read at least 512 words */
1746 if (buffer_len == 0)
1749 bytes = 2 * buffer_len;
1750 buff = kzalloc(bytes, GFP_KERNEL);
1752 goto command_write_done;
1754 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ);
1756 dev_info(&pf->pdev->dev,
1757 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1758 ret, pf->hw.aq.asq_last_status);
1760 goto command_write_done;
1763 ret = i40e_aq_read_nvm(&pf->hw, module, (2 * offset),
1764 bytes, (u8 *)buff, true, NULL);
1765 i40e_release_nvm(&pf->hw);
1767 dev_info(&pf->pdev->dev,
1768 "Read NVM AQ failed err=%d status=0x%x\n",
1769 ret, pf->hw.aq.asq_last_status);
1771 dev_info(&pf->pdev->dev,
1772 "Read NVM module=0x%x offset=0x%x words=%d\n",
1773 module, offset, buffer_len);
1774 for (i = 0; i < buffer_len; i++) {
1775 if ((i % 16) == 0) {
1776 snprintf(print_buf, 11, "\n0x%08x: ",
1780 snprintf(print_buf, 5, "%04x ", buff[i]);
1783 dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
1788 dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf);
1789 dev_info(&pf->pdev->dev, "available commands\n");
1790 dev_info(&pf->pdev->dev, " add vsi [relay_seid]\n");
1791 dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n");
1792 dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n");
1793 dev_info(&pf->pdev->dev, " del relay <relay_seid>\n");
1794 dev_info(&pf->pdev->dev, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1795 dev_info(&pf->pdev->dev, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1796 dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n");
1797 dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n");
1798 dev_info(&pf->pdev->dev, " dump switch\n");
1799 dev_info(&pf->pdev->dev, " dump vsi [seid]\n");
1800 dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1801 dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1802 dev_info(&pf->pdev->dev, " dump desc aq\n");
1803 dev_info(&pf->pdev->dev, " dump stats\n");
1804 dev_info(&pf->pdev->dev, " dump reset stats\n");
1805 dev_info(&pf->pdev->dev, " msg_enable [level]\n");
1806 dev_info(&pf->pdev->dev, " read <reg>\n");
1807 dev_info(&pf->pdev->dev, " write <reg> <value>\n");
1808 dev_info(&pf->pdev->dev, " clear_stats vsi [seid]\n");
1809 dev_info(&pf->pdev->dev, " clear_stats pf\n");
1810 dev_info(&pf->pdev->dev, " pfr\n");
1811 dev_info(&pf->pdev->dev, " corer\n");
1812 dev_info(&pf->pdev->dev, " globr\n");
1813 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");
1814 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");
1815 dev_info(&pf->pdev->dev, " lldp start\n");
1816 dev_info(&pf->pdev->dev, " lldp stop\n");
1817 dev_info(&pf->pdev->dev, " lldp get local\n");
1818 dev_info(&pf->pdev->dev, " lldp get remote\n");
1819 dev_info(&pf->pdev->dev, " lldp event on\n");
1820 dev_info(&pf->pdev->dev, " lldp event off\n");
1821 dev_info(&pf->pdev->dev, " nvm read [module] [word_offset] [word_count]\n");
1827 kfree(print_buf_start);
1829 print_buf_start = NULL;
1833 static const struct file_operations i40e_dbg_command_fops = {
1834 .owner = THIS_MODULE,
1835 .open = simple_open,
1836 .read = i40e_dbg_command_read,
1837 .write = i40e_dbg_command_write,
1840 /**************************************************************
1842 * The netdev_ops entry in debugfs is for giving the driver commands
1843 * to be executed from the netdev operations.
1844 **************************************************************/
1845 static char i40e_dbg_netdev_ops_buf[256] = "hello world";
1848 * i40e_dbg_netdev_ops - read for netdev_ops datum
1849 * @filp: the opened file
1850 * @buffer: where to write the data for the user to read
1851 * @count: the size of the user's buffer
1852 * @ppos: file position offset
1854 static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
1855 size_t count, loff_t *ppos)
1857 struct i40e_pf *pf = filp->private_data;
1858 int bytes_not_copied;
1863 /* don't allow partal reads */
1866 if (count < buf_size)
1869 buf = kzalloc(buf_size, GFP_KERNEL);
1873 len = snprintf(buf, buf_size, "%s: %s\n",
1874 pf->vsi[pf->lan_vsi]->netdev->name,
1875 i40e_dbg_netdev_ops_buf);
1877 bytes_not_copied = copy_to_user(buffer, buf, len);
1880 if (bytes_not_copied < 0)
1881 return bytes_not_copied;
1888 * i40e_dbg_netdev_ops_write - write into netdev_ops datum
1889 * @filp: the opened file
1890 * @buffer: where to find the user's data
1891 * @count: the length of the user's data
1892 * @ppos: file position offset
1894 static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1895 const char __user *buffer,
1896 size_t count, loff_t *ppos)
1898 struct i40e_pf *pf = filp->private_data;
1899 int bytes_not_copied;
1900 struct i40e_vsi *vsi;
1904 /* don't allow partial writes */
1907 if (count >= sizeof(i40e_dbg_netdev_ops_buf))
1910 memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf));
1911 bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf,
1913 if (bytes_not_copied < 0)
1914 return bytes_not_copied;
1915 else if (bytes_not_copied > 0)
1916 count -= bytes_not_copied;
1917 i40e_dbg_netdev_ops_buf[count] = '\0';
1919 if (strncmp(i40e_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) {
1920 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1922 dev_info(&pf->pdev->dev, "tx_timeout <vsi_seid>\n");
1923 goto netdev_ops_write_done;
1925 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1927 dev_info(&pf->pdev->dev,
1928 "tx_timeout: VSI %d not found\n", vsi_seid);
1929 goto netdev_ops_write_done;
1931 if (rtnl_trylock()) {
1932 vsi->netdev->netdev_ops->ndo_tx_timeout(vsi->netdev);
1934 dev_info(&pf->pdev->dev, "tx_timeout called\n");
1936 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1938 } else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
1940 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
1943 dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
1944 goto netdev_ops_write_done;
1946 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1948 dev_info(&pf->pdev->dev,
1949 "change_mtu: VSI %d not found\n", vsi_seid);
1950 goto netdev_ops_write_done;
1952 if (rtnl_trylock()) {
1953 vsi->netdev->netdev_ops->ndo_change_mtu(vsi->netdev,
1956 dev_info(&pf->pdev->dev, "change_mtu called\n");
1958 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1961 } else if (strncmp(i40e_dbg_netdev_ops_buf, "set_rx_mode", 11) == 0) {
1962 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1964 dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
1965 goto netdev_ops_write_done;
1967 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1969 dev_info(&pf->pdev->dev,
1970 "set_rx_mode: VSI %d not found\n", vsi_seid);
1971 goto netdev_ops_write_done;
1973 if (rtnl_trylock()) {
1974 vsi->netdev->netdev_ops->ndo_set_rx_mode(vsi->netdev);
1976 dev_info(&pf->pdev->dev, "set_rx_mode called\n");
1978 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1981 } else if (strncmp(i40e_dbg_netdev_ops_buf, "napi", 4) == 0) {
1982 cnt = sscanf(&i40e_dbg_netdev_ops_buf[4], "%i", &vsi_seid);
1984 dev_info(&pf->pdev->dev, "napi <vsi_seid>\n");
1985 goto netdev_ops_write_done;
1987 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1989 dev_info(&pf->pdev->dev, "napi: VSI %d not found\n",
1991 goto netdev_ops_write_done;
1993 for (i = 0; i < vsi->num_q_vectors; i++)
1994 napi_schedule(&vsi->q_vectors[i]->napi);
1995 dev_info(&pf->pdev->dev, "napi called\n");
1997 dev_info(&pf->pdev->dev, "unknown command '%s'\n",
1998 i40e_dbg_netdev_ops_buf);
1999 dev_info(&pf->pdev->dev, "available commands\n");
2000 dev_info(&pf->pdev->dev, " tx_timeout <vsi_seid>\n");
2001 dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n");
2002 dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n");
2003 dev_info(&pf->pdev->dev, " napi <vsi_seid>\n");
2005 netdev_ops_write_done:
2009 static const struct file_operations i40e_dbg_netdev_ops_fops = {
2010 .owner = THIS_MODULE,
2011 .open = simple_open,
2012 .read = i40e_dbg_netdev_ops_read,
2013 .write = i40e_dbg_netdev_ops_write,
2017 * i40e_dbg_pf_init - setup the debugfs directory for the pf
2018 * @pf: the pf that is starting up
2020 void i40e_dbg_pf_init(struct i40e_pf *pf)
2022 struct dentry *pfile;
2023 const char *name = pci_name(pf->pdev);
2024 const struct device *dev = &pf->pdev->dev;
2026 pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root);
2027 if (!pf->i40e_dbg_pf)
2030 pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf,
2031 &i40e_dbg_command_fops);
2035 pfile = debugfs_create_file("dump", 0600, pf->i40e_dbg_pf, pf,
2036 &i40e_dbg_dump_fops);
2040 pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf,
2041 &i40e_dbg_netdev_ops_fops);
2048 dev_info(dev, "debugfs dir/file for %s failed\n", name);
2049 debugfs_remove_recursive(pf->i40e_dbg_pf);
2054 * i40e_dbg_pf_exit - clear out the pf's debugfs entries
2055 * @pf: the pf that is stopping
2057 void i40e_dbg_pf_exit(struct i40e_pf *pf)
2059 debugfs_remove_recursive(pf->i40e_dbg_pf);
2060 pf->i40e_dbg_pf = NULL;
2062 kfree(i40e_dbg_dump_buf);
2063 i40e_dbg_dump_buf = NULL;
2067 * i40e_dbg_init - start up debugfs for the driver
2069 void i40e_dbg_init(void)
2071 i40e_dbg_root = debugfs_create_dir(i40e_driver_name, NULL);
2073 pr_info("init of debugfs failed\n");
2077 * i40e_dbg_exit - clean out the driver's debugfs entries
2079 void i40e_dbg_exit(void)
2081 debugfs_remove_recursive(i40e_dbg_root);
2082 i40e_dbg_root = NULL;
2085 #endif /* CONFIG_DEBUG_FS */