blob: 2a44f2e25a26e9d4077136d8a5479f817d4e36e6 [file] [log] [blame]
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -08004 * Copyright(c) 2013 - 2016 Intel Corporation.
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00005 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
Greg Rosedc641b72013-12-18 13:45:51 +000015 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000017 *
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
21 * Contact Information:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 ******************************************************************************/
26
27#ifdef CONFIG_DEBUG_FS
28
29#include <linux/fs.h>
30#include <linux/debugfs.h>
31
32#include "i40e.h"
33
34static struct dentry *i40e_dbg_root;
35
36/**
37 * i40e_dbg_find_vsi - searches for the vsi with the given seid
Jeff Kirsherb40c82e62015-02-27 09:18:34 +000038 * @pf - the PF structure to search for the vsi
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000039 * @seid - seid of the vsi it is searching for
40 **/
41static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
42{
43 int i;
44
45 if (seid < 0)
46 dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
47 else
Mitch Williams505682c2014-05-20 08:01:37 +000048 for (i = 0; i < pf->num_alloc_vsi; i++)
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000049 if (pf->vsi[i] && (pf->vsi[i]->seid == seid))
50 return pf->vsi[i];
51
52 return NULL;
53}
54
55/**
56 * i40e_dbg_find_veb - searches for the veb with the given seid
Jeff Kirsherb40c82e62015-02-27 09:18:34 +000057 * @pf - the PF structure to search for the veb
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000058 * @seid - seid of the veb it is searching for
59 **/
60static struct i40e_veb *i40e_dbg_find_veb(struct i40e_pf *pf, int seid)
61{
62 int i;
63
Kiran Patil4147e2c2016-01-15 14:33:14 -080064 for (i = 0; i < I40E_MAX_VEB; i++)
65 if (pf->veb[i] && pf->veb[i]->seid == seid)
66 return pf->veb[i];
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000067 return NULL;
68}
69
70/**************************************************************
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000071 * command
72 * The command entry in debugfs is for giving the driver commands
73 * to be executed - these may be for changing the internal switch
74 * setup, adding or removing filters, or other things. Many of
75 * these will be useful for some forms of unit testing.
76 **************************************************************/
Greg Rosed1da3ac2015-02-27 09:18:29 +000077static char i40e_dbg_command_buf[256] = "";
Jesse Brandeburg02e9c292013-09-11 08:40:17 +000078
79/**
80 * i40e_dbg_command_read - read for command datum
81 * @filp: the opened file
82 * @buffer: where to write the data for the user to read
83 * @count: the size of the user's buffer
84 * @ppos: file position offset
85 **/
86static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
87 size_t count, loff_t *ppos)
88{
89 struct i40e_pf *pf = filp->private_data;
90 int bytes_not_copied;
91 int buf_size = 256;
92 char *buf;
93 int len;
94
95 /* don't allow partial reads */
96 if (*ppos != 0)
97 return 0;
98 if (count < buf_size)
99 return -ENOSPC;
100
101 buf = kzalloc(buf_size, GFP_KERNEL);
102 if (!buf)
103 return -ENOSPC;
104
105 len = snprintf(buf, buf_size, "%s: %s\n",
106 pf->vsi[pf->lan_vsi]->netdev->name,
107 i40e_dbg_command_buf);
108
109 bytes_not_copied = copy_to_user(buffer, buf, len);
110 kfree(buf);
111
Rasmus Villemoes0286c672015-10-17 22:58:19 +0200112 if (bytes_not_copied)
113 return -EFAULT;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000114
115 *ppos = len;
116 return len;
117}
118
119/**
Shannon Nelsone625f712013-11-26 10:49:31 +0000120 * i40e_dbg_dump_vsi_seid - handles dump vsi seid write into command datum
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000121 * @pf: the i40e_pf created in command write
122 * @seid: the seid the user put in
123 **/
124static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
125{
126 struct rtnl_link_stats64 *nstat;
127 struct i40e_mac_filter *f;
128 struct i40e_vsi *vsi;
129 int i;
130
131 vsi = i40e_dbg_find_vsi(pf, seid);
132 if (!vsi) {
133 dev_info(&pf->pdev->dev,
134 "dump %d: seid not found\n", seid);
135 return;
136 }
137 dev_info(&pf->pdev->dev, "vsi seid %d\n", seid);
Shannon Nelsonde1017f2015-12-23 12:05:53 -0800138 if (vsi->netdev) {
139 struct net_device *nd = vsi->netdev;
140
141 dev_info(&pf->pdev->dev, " netdev: name = %s, state = %lu, flags = 0x%08x\n",
142 nd->name, nd->state, nd->flags);
143 dev_info(&pf->pdev->dev, " features = 0x%08lx\n",
144 (unsigned long int)nd->features);
145 dev_info(&pf->pdev->dev, " hw_features = 0x%08lx\n",
146 (unsigned long int)nd->hw_features);
147 dev_info(&pf->pdev->dev, " vlan_features = 0x%08lx\n",
148 (unsigned long int)nd->vlan_features);
149 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000150 if (vsi->active_vlans)
151 dev_info(&pf->pdev->dev,
152 " vlgrp: & = %p\n", vsi->active_vlans);
153 dev_info(&pf->pdev->dev,
Shannon Nelsonde1017f2015-12-23 12:05:53 -0800154 " state = %li flags = 0x%08lx, netdev_registered = %i, current_netdev_flags = 0x%04x\n",
155 vsi->state, vsi->flags,
156 vsi->netdev_registered, vsi->current_netdev_flags);
Shannon Nelson2ddb80c2015-02-27 09:18:36 +0000157 if (vsi == pf->vsi[pf->lan_vsi])
Shannon Nelsonde1017f2015-12-23 12:05:53 -0800158 dev_info(&pf->pdev->dev, " MAC address: %pM SAN MAC: %pM Port MAC: %pM\n",
Shannon Nelson2ddb80c2015-02-27 09:18:36 +0000159 pf->hw.mac.addr,
160 pf->hw.mac.san_addr,
161 pf->hw.mac.port_addr);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000162 list_for_each_entry(f, &vsi->mac_filter_list, list) {
163 dev_info(&pf->pdev->dev,
164 " mac_filter_list: %pM vid=%d, is_netdev=%d is_vf=%d counter=%d\n",
165 f->macaddr, f->vlan, f->is_netdev, f->is_vf,
166 f->counter);
167 }
168 nstat = i40e_get_vsi_stats_struct(vsi);
169 dev_info(&pf->pdev->dev,
170 " net_stats: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400171 (unsigned long int)nstat->rx_packets,
172 (unsigned long int)nstat->rx_bytes,
173 (unsigned long int)nstat->rx_errors,
174 (unsigned long int)nstat->rx_dropped);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000175 dev_info(&pf->pdev->dev,
176 " net_stats: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400177 (unsigned long int)nstat->tx_packets,
178 (unsigned long int)nstat->tx_bytes,
179 (unsigned long int)nstat->tx_errors,
180 (unsigned long int)nstat->tx_dropped);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000181 dev_info(&pf->pdev->dev,
182 " net_stats: multicast = %lu, collisions = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400183 (unsigned long int)nstat->multicast,
184 (unsigned long int)nstat->collisions);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000185 dev_info(&pf->pdev->dev,
186 " net_stats: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400187 (unsigned long int)nstat->rx_length_errors,
188 (unsigned long int)nstat->rx_over_errors,
189 (unsigned long int)nstat->rx_crc_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000190 dev_info(&pf->pdev->dev,
191 " net_stats: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400192 (unsigned long int)nstat->rx_frame_errors,
193 (unsigned long int)nstat->rx_fifo_errors,
194 (unsigned long int)nstat->rx_missed_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000195 dev_info(&pf->pdev->dev,
196 " net_stats: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400197 (unsigned long int)nstat->tx_aborted_errors,
198 (unsigned long int)nstat->tx_carrier_errors,
199 (unsigned long int)nstat->tx_fifo_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000200 dev_info(&pf->pdev->dev,
201 " net_stats: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400202 (unsigned long int)nstat->tx_heartbeat_errors,
203 (unsigned long int)nstat->tx_window_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000204 dev_info(&pf->pdev->dev,
205 " net_stats: rx_compressed = %lu, tx_compressed = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400206 (unsigned long int)nstat->rx_compressed,
207 (unsigned long int)nstat->tx_compressed);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000208 dev_info(&pf->pdev->dev,
209 " net_stats_offsets: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400210 (unsigned long int)vsi->net_stats_offsets.rx_packets,
211 (unsigned long int)vsi->net_stats_offsets.rx_bytes,
212 (unsigned long int)vsi->net_stats_offsets.rx_errors,
213 (unsigned long int)vsi->net_stats_offsets.rx_dropped);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000214 dev_info(&pf->pdev->dev,
215 " net_stats_offsets: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400216 (unsigned long int)vsi->net_stats_offsets.tx_packets,
217 (unsigned long int)vsi->net_stats_offsets.tx_bytes,
218 (unsigned long int)vsi->net_stats_offsets.tx_errors,
219 (unsigned long int)vsi->net_stats_offsets.tx_dropped);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000220 dev_info(&pf->pdev->dev,
221 " net_stats_offsets: multicast = %lu, collisions = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400222 (unsigned long int)vsi->net_stats_offsets.multicast,
223 (unsigned long int)vsi->net_stats_offsets.collisions);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000224 dev_info(&pf->pdev->dev,
225 " net_stats_offsets: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400226 (unsigned long int)vsi->net_stats_offsets.rx_length_errors,
227 (unsigned long int)vsi->net_stats_offsets.rx_over_errors,
228 (unsigned long int)vsi->net_stats_offsets.rx_crc_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000229 dev_info(&pf->pdev->dev,
230 " net_stats_offsets: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400231 (unsigned long int)vsi->net_stats_offsets.rx_frame_errors,
232 (unsigned long int)vsi->net_stats_offsets.rx_fifo_errors,
233 (unsigned long int)vsi->net_stats_offsets.rx_missed_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000234 dev_info(&pf->pdev->dev,
235 " net_stats_offsets: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400236 (unsigned long int)vsi->net_stats_offsets.tx_aborted_errors,
237 (unsigned long int)vsi->net_stats_offsets.tx_carrier_errors,
238 (unsigned long int)vsi->net_stats_offsets.tx_fifo_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000239 dev_info(&pf->pdev->dev,
240 " net_stats_offsets: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400241 (unsigned long int)vsi->net_stats_offsets.tx_heartbeat_errors,
242 (unsigned long int)vsi->net_stats_offsets.tx_window_errors);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000243 dev_info(&pf->pdev->dev,
244 " net_stats_offsets: rx_compressed = %lu, tx_compressed = %lu\n",
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400245 (unsigned long int)vsi->net_stats_offsets.rx_compressed,
246 (unsigned long int)vsi->net_stats_offsets.tx_compressed);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000247 dev_info(&pf->pdev->dev,
248 " tx_restart = %d, tx_busy = %d, rx_buf_failed = %d, rx_page_failed = %d\n",
249 vsi->tx_restart, vsi->tx_busy,
250 vsi->rx_buf_failed, vsi->rx_page_failed);
Alexander Duyck9f65e152013-09-28 06:00:58 +0000251 rcu_read_lock();
252 for (i = 0; i < vsi->num_queue_pairs; i++) {
253 struct i40e_ring *rx_ring = ACCESS_ONCE(vsi->rx_rings[i]);
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400254
Alexander Duyck9f65e152013-09-28 06:00:58 +0000255 if (!rx_ring)
256 continue;
257
258 dev_info(&pf->pdev->dev,
259 " rx_rings[%i]: desc = %p\n",
260 i, rx_ring->desc);
261 dev_info(&pf->pdev->dev,
262 " rx_rings[%i]: dev = %p, netdev = %p, rx_bi = %p\n",
263 i, rx_ring->dev,
264 rx_ring->netdev,
265 rx_ring->rx_bi);
266 dev_info(&pf->pdev->dev,
267 " rx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
268 i, rx_ring->state,
269 rx_ring->queue_index,
270 rx_ring->reg_idx);
271 dev_info(&pf->pdev->dev,
272 " rx_rings[%i]: rx_hdr_len = %d, rx_buf_len = %d, dtype = %d\n",
273 i, rx_ring->rx_hdr_len,
274 rx_ring->rx_buf_len,
275 rx_ring->dtype);
276 dev_info(&pf->pdev->dev,
277 " rx_rings[%i]: hsplit = %d, next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
Mitch Williams46686072016-01-13 16:51:51 -0800278 i, ring_is_ps_enabled(rx_ring),
Alexander Duyck9f65e152013-09-28 06:00:58 +0000279 rx_ring->next_to_use,
280 rx_ring->next_to_clean,
281 rx_ring->ring_active);
282 dev_info(&pf->pdev->dev,
283 " rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n",
284 i, rx_ring->stats.packets,
285 rx_ring->stats.bytes,
286 rx_ring->rx_stats.non_eop_descs);
287 dev_info(&pf->pdev->dev,
Mitch Williams420136c2013-12-18 13:45:59 +0000288 " rx_rings[%i]: rx_stats: alloc_page_failed = %lld, alloc_buff_failed = %lld\n",
Alexander Duyck9f65e152013-09-28 06:00:58 +0000289 i,
Mitch Williams420136c2013-12-18 13:45:59 +0000290 rx_ring->rx_stats.alloc_page_failed,
291 rx_ring->rx_stats.alloc_buff_failed);
Alexander Duyck9f65e152013-09-28 06:00:58 +0000292 dev_info(&pf->pdev->dev,
Mitch Williamsf16704e2016-01-13 16:51:49 -0800293 " rx_rings[%i]: rx_stats: realloc_count = %lld, page_reuse_count = %lld\n",
294 i,
295 rx_ring->rx_stats.realloc_count,
296 rx_ring->rx_stats.page_reuse_count);
297 dev_info(&pf->pdev->dev,
Alexander Duyck9f65e152013-09-28 06:00:58 +0000298 " rx_rings[%i]: size = %i, dma = 0x%08lx\n",
299 i, rx_ring->size,
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400300 (unsigned long int)rx_ring->dma);
Alexander Duyck9f65e152013-09-28 06:00:58 +0000301 dev_info(&pf->pdev->dev,
302 " rx_rings[%i]: vsi = %p, q_vector = %p\n",
303 i, rx_ring->vsi,
304 rx_ring->q_vector);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000305 }
Alexander Duyck9f65e152013-09-28 06:00:58 +0000306 for (i = 0; i < vsi->num_queue_pairs; i++) {
307 struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[i]);
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400308
Alexander Duyck9f65e152013-09-28 06:00:58 +0000309 if (!tx_ring)
310 continue;
Jesse Brandeburg1b60f3c2013-11-28 06:39:35 +0000311
Alexander Duyck9f65e152013-09-28 06:00:58 +0000312 dev_info(&pf->pdev->dev,
313 " tx_rings[%i]: desc = %p\n",
314 i, tx_ring->desc);
315 dev_info(&pf->pdev->dev,
316 " tx_rings[%i]: dev = %p, netdev = %p, tx_bi = %p\n",
317 i, tx_ring->dev,
318 tx_ring->netdev,
319 tx_ring->tx_bi);
320 dev_info(&pf->pdev->dev,
321 " tx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
322 i, tx_ring->state,
323 tx_ring->queue_index,
324 tx_ring->reg_idx);
325 dev_info(&pf->pdev->dev,
326 " tx_rings[%i]: dtype = %d\n",
327 i, tx_ring->dtype);
328 dev_info(&pf->pdev->dev,
Mitch Williams46686072016-01-13 16:51:51 -0800329 " tx_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
330 i,
Alexander Duyck9f65e152013-09-28 06:00:58 +0000331 tx_ring->next_to_use,
332 tx_ring->next_to_clean,
333 tx_ring->ring_active);
334 dev_info(&pf->pdev->dev,
335 " tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
336 i, tx_ring->stats.packets,
337 tx_ring->stats.bytes,
338 tx_ring->tx_stats.restart_queue);
339 dev_info(&pf->pdev->dev,
340 " tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",
341 i,
342 tx_ring->tx_stats.tx_busy,
343 tx_ring->tx_stats.tx_done_old);
344 dev_info(&pf->pdev->dev,
345 " tx_rings[%i]: size = %i, dma = 0x%08lx\n",
346 i, tx_ring->size,
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400347 (unsigned long int)tx_ring->dma);
Alexander Duyck9f65e152013-09-28 06:00:58 +0000348 dev_info(&pf->pdev->dev,
349 " tx_rings[%i]: vsi = %p, q_vector = %p\n",
350 i, tx_ring->vsi,
351 tx_ring->q_vector);
352 dev_info(&pf->pdev->dev,
353 " tx_rings[%i]: DCB tc = %d\n",
354 i, tx_ring->dcb_tc);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000355 }
Alexander Duyck9f65e152013-09-28 06:00:58 +0000356 rcu_read_unlock();
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000357 dev_info(&pf->pdev->dev,
358 " work_limit = %d, rx_itr_setting = %d (%s), tx_itr_setting = %d (%s)\n",
359 vsi->work_limit, vsi->rx_itr_setting,
360 ITR_IS_DYNAMIC(vsi->rx_itr_setting) ? "dynamic" : "fixed",
361 vsi->tx_itr_setting,
362 ITR_IS_DYNAMIC(vsi->tx_itr_setting) ? "dynamic" : "fixed");
363 dev_info(&pf->pdev->dev,
364 " max_frame = %d, rx_hdr_len = %d, rx_buf_len = %d dtype = %d\n",
365 vsi->max_frame, vsi->rx_hdr_len, vsi->rx_buf_len, vsi->dtype);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000366 dev_info(&pf->pdev->dev,
367 " num_q_vectors = %i, base_vector = %i\n",
368 vsi->num_q_vectors, vsi->base_vector);
369 dev_info(&pf->pdev->dev,
370 " seid = %d, id = %d, uplink_seid = %d\n",
371 vsi->seid, vsi->id, vsi->uplink_seid);
372 dev_info(&pf->pdev->dev,
373 " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
374 vsi->base_queue, vsi->num_queue_pairs, vsi->num_desc);
375 dev_info(&pf->pdev->dev, " type = %i\n", vsi->type);
376 dev_info(&pf->pdev->dev,
377 " info: valid_sections = 0x%04x, switch_id = 0x%04x\n",
378 vsi->info.valid_sections, vsi->info.switch_id);
379 dev_info(&pf->pdev->dev,
380 " info: sw_reserved[] = 0x%02x 0x%02x\n",
381 vsi->info.sw_reserved[0], vsi->info.sw_reserved[1]);
382 dev_info(&pf->pdev->dev,
383 " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n",
384 vsi->info.sec_flags, vsi->info.sec_reserved);
385 dev_info(&pf->pdev->dev,
386 " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n",
387 vsi->info.pvid, vsi->info.fcoe_pvid,
388 vsi->info.port_vlan_flags);
389 dev_info(&pf->pdev->dev,
390 " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n",
391 vsi->info.pvlan_reserved[0], vsi->info.pvlan_reserved[1],
392 vsi->info.pvlan_reserved[2]);
393 dev_info(&pf->pdev->dev,
394 " info: ingress_table = 0x%08x, egress_table = 0x%08x\n",
395 vsi->info.ingress_table, vsi->info.egress_table);
396 dev_info(&pf->pdev->dev,
397 " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n",
398 vsi->info.cas_pv_tag, vsi->info.cas_pv_flags,
399 vsi->info.cas_pv_reserved);
400 dev_info(&pf->pdev->dev,
401 " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
402 vsi->info.queue_mapping[0], vsi->info.queue_mapping[1],
403 vsi->info.queue_mapping[2], vsi->info.queue_mapping[3],
404 vsi->info.queue_mapping[4], vsi->info.queue_mapping[5],
405 vsi->info.queue_mapping[6], vsi->info.queue_mapping[7]);
406 dev_info(&pf->pdev->dev,
407 " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
408 vsi->info.queue_mapping[8], vsi->info.queue_mapping[9],
409 vsi->info.queue_mapping[10], vsi->info.queue_mapping[11],
410 vsi->info.queue_mapping[12], vsi->info.queue_mapping[13],
411 vsi->info.queue_mapping[14], vsi->info.queue_mapping[15]);
412 dev_info(&pf->pdev->dev,
413 " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
414 vsi->info.tc_mapping[0], vsi->info.tc_mapping[1],
415 vsi->info.tc_mapping[2], vsi->info.tc_mapping[3],
416 vsi->info.tc_mapping[4], vsi->info.tc_mapping[5],
417 vsi->info.tc_mapping[6], vsi->info.tc_mapping[7]);
418 dev_info(&pf->pdev->dev,
419 " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n",
420 vsi->info.queueing_opt_flags,
421 vsi->info.queueing_opt_reserved[0],
422 vsi->info.queueing_opt_reserved[1],
423 vsi->info.queueing_opt_reserved[2]);
424 dev_info(&pf->pdev->dev,
425 " info: up_enable_bits = 0x%02x\n",
426 vsi->info.up_enable_bits);
427 dev_info(&pf->pdev->dev,
428 " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n",
429 vsi->info.sched_reserved, vsi->info.outer_up_table);
430 dev_info(&pf->pdev->dev,
431 " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n",
432 vsi->info.cmd_reserved[0], vsi->info.cmd_reserved[1],
433 vsi->info.cmd_reserved[2], vsi->info.cmd_reserved[3],
434 vsi->info.cmd_reserved[4], vsi->info.cmd_reserved[5],
435 vsi->info.cmd_reserved[6], vsi->info.cmd_reserved[7]);
436 dev_info(&pf->pdev->dev,
437 " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
438 vsi->info.qs_handle[0], vsi->info.qs_handle[1],
439 vsi->info.qs_handle[2], vsi->info.qs_handle[3],
440 vsi->info.qs_handle[4], vsi->info.qs_handle[5],
441 vsi->info.qs_handle[6], vsi->info.qs_handle[7]);
442 dev_info(&pf->pdev->dev,
443 " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n",
444 vsi->info.stat_counter_idx, vsi->info.sched_id);
445 dev_info(&pf->pdev->dev,
446 " 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",
447 vsi->info.resp_reserved[0], vsi->info.resp_reserved[1],
448 vsi->info.resp_reserved[2], vsi->info.resp_reserved[3],
449 vsi->info.resp_reserved[4], vsi->info.resp_reserved[5],
450 vsi->info.resp_reserved[6], vsi->info.resp_reserved[7],
451 vsi->info.resp_reserved[8], vsi->info.resp_reserved[9],
452 vsi->info.resp_reserved[10], vsi->info.resp_reserved[11]);
453 if (vsi->back)
Jeff Kirsherb40c82e62015-02-27 09:18:34 +0000454 dev_info(&pf->pdev->dev, " PF = %p\n", vsi->back);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000455 dev_info(&pf->pdev->dev, " idx = %d\n", vsi->idx);
456 dev_info(&pf->pdev->dev,
457 " tc_config: numtc = %d, enabled_tc = 0x%x\n",
458 vsi->tc_config.numtc, vsi->tc_config.enabled_tc);
459 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
460 dev_info(&pf->pdev->dev,
461 " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n",
462 i, vsi->tc_config.tc_info[i].qoffset,
463 vsi->tc_config.tc_info[i].qcount,
464 vsi->tc_config.tc_info[i].netdev_tc);
465 }
466 dev_info(&pf->pdev->dev,
467 " bw: bw_limit = %d, bw_max_quanta = %d\n",
468 vsi->bw_limit, vsi->bw_max_quanta);
469 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
470 dev_info(&pf->pdev->dev,
471 " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n",
472 i, vsi->bw_ets_share_credits[i],
473 vsi->bw_ets_limit_credits[i],
474 vsi->bw_ets_max_quanta[i]);
475 }
Vasu Dev38e00432014-08-01 13:27:03 -0700476#ifdef I40E_FCOE
477 if (vsi->type == I40E_VSI_FCOE) {
478 dev_info(&pf->pdev->dev,
479 " fcoe_stats: rx_packets = %llu, rx_dwords = %llu, rx_dropped = %llu\n",
480 vsi->fcoe_stats.rx_fcoe_packets,
481 vsi->fcoe_stats.rx_fcoe_dwords,
482 vsi->fcoe_stats.rx_fcoe_dropped);
483 dev_info(&pf->pdev->dev,
484 " fcoe_stats: tx_packets = %llu, tx_dwords = %llu\n",
485 vsi->fcoe_stats.tx_fcoe_packets,
486 vsi->fcoe_stats.tx_fcoe_dwords);
487 dev_info(&pf->pdev->dev,
488 " fcoe_stats: bad_crc = %llu, last_error = %llu\n",
489 vsi->fcoe_stats.fcoe_bad_fccrc,
490 vsi->fcoe_stats.fcoe_last_error);
491 dev_info(&pf->pdev->dev, " fcoe_stats: ddp_count = %llu\n",
492 vsi->fcoe_stats.fcoe_ddp_count);
493 }
494#endif
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000495}
496
497/**
498 * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum
499 * @pf: the i40e_pf created in command write
500 **/
501static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf)
502{
503 struct i40e_adminq_ring *ring;
504 struct i40e_hw *hw = &pf->hw;
Shannon Nelsone625f712013-11-26 10:49:31 +0000505 char hdr[32];
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000506 int i;
507
Shannon Nelsone625f712013-11-26 10:49:31 +0000508 snprintf(hdr, sizeof(hdr), "%s %s: ",
509 dev_driver_string(&pf->pdev->dev),
510 dev_name(&pf->pdev->dev));
511
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000512 /* first the send (command) ring, then the receive (event) ring */
513 dev_info(&pf->pdev->dev, "AdminQ Tx Ring\n");
514 ring = &(hw->aq.asq);
515 for (i = 0; i < ring->count; i++) {
516 struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400517
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000518 dev_info(&pf->pdev->dev,
519 " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
520 i, d->flags, d->opcode, d->datalen, d->retval,
521 d->cookie_high, d->cookie_low);
Shannon Nelsone625f712013-11-26 10:49:31 +0000522 print_hex_dump(KERN_INFO, hdr, DUMP_PREFIX_NONE,
523 16, 1, d->params.raw, 16, 0);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000524 }
525
526 dev_info(&pf->pdev->dev, "AdminQ Rx Ring\n");
527 ring = &(hw->aq.arq);
528 for (i = 0; i < ring->count; i++) {
529 struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400530
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000531 dev_info(&pf->pdev->dev,
532 " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
533 i, d->flags, d->opcode, d->datalen, d->retval,
534 d->cookie_high, d->cookie_low);
Shannon Nelsone625f712013-11-26 10:49:31 +0000535 print_hex_dump(KERN_INFO, hdr, DUMP_PREFIX_NONE,
536 16, 1, d->params.raw, 16, 0);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000537 }
538}
539
540/**
541 * i40e_dbg_dump_desc - handles dump desc write into command datum
542 * @cnt: number of arguments that the user supplied
543 * @vsi_seid: vsi id entered by user
544 * @ring_id: ring id entered by user
545 * @desc_n: descriptor number entered by user
546 * @pf: the i40e_pf created in command write
547 * @is_rx_ring: true if rx, false if tx
548 **/
549static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
550 struct i40e_pf *pf, bool is_rx_ring)
551{
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800552 struct i40e_tx_desc *txd;
553 union i40e_rx_desc *rxd;
Joe Perchese6c97232014-11-18 05:53:00 +0000554 struct i40e_ring *ring;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000555 struct i40e_vsi *vsi;
556 int i;
557
558 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
559 if (!vsi) {
Shannon Nelson7792fe42013-11-26 10:49:29 +0000560 dev_info(&pf->pdev->dev, "vsi %d not found\n", vsi_seid);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000561 return;
562 }
563 if (ring_id >= vsi->num_queue_pairs || ring_id < 0) {
564 dev_info(&pf->pdev->dev, "ring %d not found\n", ring_id);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000565 return;
566 }
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800567 if (!vsi->tx_rings || !vsi->tx_rings[0]->desc) {
Shannon Nelson29d07902013-11-26 10:49:26 +0000568 dev_info(&pf->pdev->dev,
569 "descriptor rings have not been allocated for vsi %d\n",
570 vsi_seid);
571 return;
572 }
Joe Perchese6c97232014-11-18 05:53:00 +0000573
574 ring = kmemdup(is_rx_ring
575 ? vsi->rx_rings[ring_id] : vsi->tx_rings[ring_id],
576 sizeof(*ring), GFP_KERNEL);
577 if (!ring)
578 return;
579
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000580 if (cnt == 2) {
581 dev_info(&pf->pdev->dev, "vsi = %02i %s ring = %02i\n",
582 vsi_seid, is_rx_ring ? "rx" : "tx", ring_id);
Joe Perchese6c97232014-11-18 05:53:00 +0000583 for (i = 0; i < ring->count; i++) {
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800584 if (!is_rx_ring) {
Joe Perchese6c97232014-11-18 05:53:00 +0000585 txd = I40E_TX_DESC(ring, i);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000586 dev_info(&pf->pdev->dev,
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -0800587 " d[%03x] = 0x%016llx 0x%016llx\n",
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800588 i, txd->buffer_addr,
589 txd->cmd_type_offset_bsz);
590 } else if (sizeof(union i40e_rx_desc) ==
591 sizeof(union i40e_16byte_rx_desc)) {
Joe Perchese6c97232014-11-18 05:53:00 +0000592 rxd = I40E_RX_DESC(ring, i);
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800593 dev_info(&pf->pdev->dev,
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -0800594 " d[%03x] = 0x%016llx 0x%016llx\n",
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800595 i, rxd->read.pkt_addr,
596 rxd->read.hdr_addr);
597 } else {
Joe Perchese6c97232014-11-18 05:53:00 +0000598 rxd = I40E_RX_DESC(ring, i);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000599 dev_info(&pf->pdev->dev,
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -0800600 " d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800601 i, rxd->read.pkt_addr,
602 rxd->read.hdr_addr,
603 rxd->read.rsvd1, rxd->read.rsvd2);
604 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000605 }
606 } else if (cnt == 3) {
Joe Perchese6c97232014-11-18 05:53:00 +0000607 if (desc_n >= ring->count || desc_n < 0) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000608 dev_info(&pf->pdev->dev,
609 "descriptor %d not found\n", desc_n);
Joe Perchese3fe44c2014-12-08 04:28:39 +0000610 goto out;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000611 }
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800612 if (!is_rx_ring) {
Joe Perchese6c97232014-11-18 05:53:00 +0000613 txd = I40E_TX_DESC(ring, desc_n);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000614 dev_info(&pf->pdev->dev,
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -0800615 "vsi = %02i tx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n",
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800616 vsi_seid, ring_id, desc_n,
617 txd->buffer_addr, txd->cmd_type_offset_bsz);
618 } else if (sizeof(union i40e_rx_desc) ==
619 sizeof(union i40e_16byte_rx_desc)) {
Joe Perchese6c97232014-11-18 05:53:00 +0000620 rxd = I40E_RX_DESC(ring, desc_n);
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800621 dev_info(&pf->pdev->dev,
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -0800622 "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n",
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800623 vsi_seid, ring_id, desc_n,
624 rxd->read.pkt_addr, rxd->read.hdr_addr);
625 } else {
Joe Perchese6c97232014-11-18 05:53:00 +0000626 rxd = I40E_RX_DESC(ring, desc_n);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000627 dev_info(&pf->pdev->dev,
Jesse Brandeburg13cb3e92016-01-13 16:51:47 -0800628 "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
Shannon Nelson68bf94a2014-01-15 15:18:23 -0800629 vsi_seid, ring_id, desc_n,
630 rxd->read.pkt_addr, rxd->read.hdr_addr,
631 rxd->read.rsvd1, rxd->read.rsvd2);
632 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000633 } else {
Shannon Nelson7792fe42013-11-26 10:49:29 +0000634 dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000635 }
Joe Perchese3fe44c2014-12-08 04:28:39 +0000636
637out:
Joe Perchese6c97232014-11-18 05:53:00 +0000638 kfree(ring);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000639}
640
641/**
642 * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum
643 * @pf: the i40e_pf created in command write
644 **/
645static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf *pf)
646{
647 int i;
648
Mitch Williams505682c2014-05-20 08:01:37 +0000649 for (i = 0; i < pf->num_alloc_vsi; i++)
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000650 if (pf->vsi[i])
651 dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n",
652 i, pf->vsi[i]->seid);
653}
654
655/**
656 * i40e_dbg_dump_stats - handles dump stats write into command datum
657 * @pf: the i40e_pf created in command write
658 * @estats: the eth stats structure to be dumped
659 **/
660static void i40e_dbg_dump_eth_stats(struct i40e_pf *pf,
661 struct i40e_eth_stats *estats)
662{
663 dev_info(&pf->pdev->dev, " ethstats:\n");
664 dev_info(&pf->pdev->dev,
665 " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n",
666 estats->rx_bytes, estats->rx_unicast, estats->rx_multicast);
667 dev_info(&pf->pdev->dev,
Shannon Nelson03da6f62014-04-23 04:50:19 +0000668 " rx_broadcast = \t%lld \trx_discards = \t\t%lld\n",
669 estats->rx_broadcast, estats->rx_discards);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000670 dev_info(&pf->pdev->dev,
Shannon Nelson03da6f62014-04-23 04:50:19 +0000671 " rx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n",
672 estats->rx_unknown_protocol, estats->tx_bytes);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000673 dev_info(&pf->pdev->dev,
674 " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n",
675 estats->tx_unicast, estats->tx_multicast, estats->tx_broadcast);
676 dev_info(&pf->pdev->dev,
677 " tx_discards = \t%lld \ttx_errors = \t\t%lld\n",
678 estats->tx_discards, estats->tx_errors);
679}
680
681/**
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000682 * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb
683 * @pf: the i40e_pf created in command write
684 * @seid: the seid the user put in
685 **/
686static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid)
687{
688 struct i40e_veb *veb;
689
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000690 veb = i40e_dbg_find_veb(pf, seid);
691 if (!veb) {
Shannon Nelsone625f712013-11-26 10:49:31 +0000692 dev_info(&pf->pdev->dev, "can't find veb %d\n", seid);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000693 return;
694 }
695 dev_info(&pf->pdev->dev,
Neerav Parikh51616012015-02-06 08:52:14 +0000696 "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d mode=%s\n",
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000697 veb->idx, veb->veb_idx, veb->stats_idx, veb->seid,
Neerav Parikh51616012015-02-06 08:52:14 +0000698 veb->uplink_seid,
699 veb->bridge_mode == BRIDGE_MODE_VEPA ? "VEPA" : "VEB");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000700 i40e_dbg_dump_eth_stats(pf, &veb->stats);
701}
702
703/**
704 * i40e_dbg_dump_veb_all - dumps all known veb's stats
705 * @pf: the i40e_pf created in command write
706 **/
707static void i40e_dbg_dump_veb_all(struct i40e_pf *pf)
708{
709 struct i40e_veb *veb;
710 int i;
711
712 for (i = 0; i < I40E_MAX_VEB; i++) {
713 veb = pf->veb[i];
714 if (veb)
715 i40e_dbg_dump_veb_seid(pf, veb->seid);
716 }
717}
718
719#define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
720/**
721 * i40e_dbg_command_write - write into command datum
722 * @filp: the opened file
723 * @buffer: where to find the user's data
724 * @count: the length of the user's data
725 * @ppos: file position offset
726 **/
727static ssize_t i40e_dbg_command_write(struct file *filp,
728 const char __user *buffer,
729 size_t count, loff_t *ppos)
730{
731 struct i40e_pf *pf = filp->private_data;
Jesse Brandeburg004173c2013-09-28 07:13:44 +0000732 char *cmd_buf, *cmd_buf_tmp;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000733 int bytes_not_copied;
734 struct i40e_vsi *vsi;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000735 int vsi_seid;
736 int veb_seid;
737 int cnt;
738
739 /* don't allow partial writes */
740 if (*ppos != 0)
741 return 0;
742
743 cmd_buf = kzalloc(count + 1, GFP_KERNEL);
744 if (!cmd_buf)
745 return count;
746 bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
Rasmus Villemoes0286c672015-10-17 22:58:19 +0200747 if (bytes_not_copied) {
Alexey Khoroshilovdda094a2015-02-21 07:32:47 +0000748 kfree(cmd_buf);
Rasmus Villemoes0286c672015-10-17 22:58:19 +0200749 return -EFAULT;
Alexey Khoroshilovdda094a2015-02-21 07:32:47 +0000750 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000751 cmd_buf[count] = '\0';
752
Jesse Brandeburg004173c2013-09-28 07:13:44 +0000753 cmd_buf_tmp = strchr(cmd_buf, '\n');
754 if (cmd_buf_tmp) {
755 *cmd_buf_tmp = '\0';
756 count = cmd_buf_tmp - cmd_buf + 1;
757 }
758
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000759 if (strncmp(cmd_buf, "add vsi", 7) == 0) {
760 vsi_seid = -1;
761 cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
762 if (cnt == 0) {
763 /* default to PF VSI */
764 vsi_seid = pf->vsi[pf->lan_vsi]->seid;
765 } else if (vsi_seid < 0) {
766 dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n",
767 vsi_seid);
768 goto command_write_done;
769 }
770
Anjali Singhai Jainfc608612015-05-08 15:35:57 -0700771 /* By default we are in VEPA mode, if this is the first VF/VMDq
772 * VSI to be added switch to VEB mode.
773 */
774 if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) {
775 pf->flags |= I40E_FLAG_VEB_MODE_ENABLED;
776 i40e_do_reset_safe(pf,
777 BIT_ULL(__I40E_PF_RESET_REQUESTED));
778 }
779
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000780 vsi = i40e_vsi_setup(pf, I40E_VSI_VMDQ2, vsi_seid, 0);
781 if (vsi)
782 dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n",
783 vsi->seid, vsi->uplink_seid);
784 else
785 dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf);
786
787 } else if (strncmp(cmd_buf, "del vsi", 7) == 0) {
Jesse Brandeburg6995b362015-08-28 17:55:54 -0400788 cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
789 if (cnt != 1) {
790 dev_info(&pf->pdev->dev,
791 "del vsi: bad command string, cnt=%d\n",
792 cnt);
793 goto command_write_done;
794 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000795 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
796 if (!vsi) {
797 dev_info(&pf->pdev->dev, "del VSI %d: seid not found\n",
798 vsi_seid);
799 goto command_write_done;
800 }
801
802 dev_info(&pf->pdev->dev, "deleting VSI %d\n", vsi_seid);
803 i40e_vsi_release(vsi);
804
805 } else if (strncmp(cmd_buf, "add relay", 9) == 0) {
806 struct i40e_veb *veb;
807 int uplink_seid, i;
808
809 cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid);
810 if (cnt != 2) {
811 dev_info(&pf->pdev->dev,
812 "add relay: bad command string, cnt=%d\n",
813 cnt);
814 goto command_write_done;
815 } else if (uplink_seid < 0) {
816 dev_info(&pf->pdev->dev,
817 "add relay %d: bad uplink seid\n",
818 uplink_seid);
819 goto command_write_done;
820 }
821
822 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
823 if (!vsi) {
824 dev_info(&pf->pdev->dev,
Shannon Nelsonc07019e2013-12-21 05:44:51 +0000825 "add relay: VSI %d not found\n", vsi_seid);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000826 goto command_write_done;
827 }
828
829 for (i = 0; i < I40E_MAX_VEB; i++)
830 if (pf->veb[i] && pf->veb[i]->seid == uplink_seid)
831 break;
832 if (i >= I40E_MAX_VEB && uplink_seid != 0 &&
833 uplink_seid != pf->mac_seid) {
834 dev_info(&pf->pdev->dev,
835 "add relay: relay uplink %d not found\n",
836 uplink_seid);
837 goto command_write_done;
838 }
839
840 veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid,
841 vsi->tc_config.enabled_tc);
842 if (veb)
843 dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid);
844 else
845 dev_info(&pf->pdev->dev, "add relay failed\n");
846
847 } else if (strncmp(cmd_buf, "del relay", 9) == 0) {
848 int i;
849 cnt = sscanf(&cmd_buf[9], "%i", &veb_seid);
850 if (cnt != 1) {
851 dev_info(&pf->pdev->dev,
852 "del relay: bad command string, cnt=%d\n",
853 cnt);
854 goto command_write_done;
855 } else if (veb_seid < 0) {
856 dev_info(&pf->pdev->dev,
857 "del relay %d: bad relay seid\n", veb_seid);
858 goto command_write_done;
859 }
860
861 /* find the veb */
862 for (i = 0; i < I40E_MAX_VEB; i++)
863 if (pf->veb[i] && pf->veb[i]->seid == veb_seid)
864 break;
865 if (i >= I40E_MAX_VEB) {
866 dev_info(&pf->pdev->dev,
867 "del relay: relay %d not found\n", veb_seid);
868 goto command_write_done;
869 }
870
871 dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid);
872 i40e_veb_release(pf->veb[i]);
873
874 } else if (strncmp(cmd_buf, "add macaddr", 11) == 0) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000875 struct i40e_mac_filter *f;
Shannon Nelson738a9e92013-09-28 07:14:04 +0000876 int vlan = 0;
877 u8 ma[6];
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000878 int ret;
879
880 cnt = sscanf(&cmd_buf[11],
881 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
882 &vsi_seid,
883 &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
884 &vlan);
885 if (cnt == 7) {
886 vlan = 0;
887 } else if (cnt != 8) {
888 dev_info(&pf->pdev->dev,
889 "add macaddr: bad command string, cnt=%d\n",
890 cnt);
891 goto command_write_done;
892 }
893
894 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
895 if (!vsi) {
896 dev_info(&pf->pdev->dev,
897 "add macaddr: VSI %d not found\n", vsi_seid);
898 goto command_write_done;
899 }
900
Anjali Singhai Jain10dc0352015-10-01 14:37:35 -0400901 spin_lock_bh(&vsi->mac_filter_list_lock);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000902 f = i40e_add_filter(vsi, ma, vlan, false, false);
Anjali Singhai Jain10dc0352015-10-01 14:37:35 -0400903 spin_unlock_bh(&vsi->mac_filter_list_lock);
Jesse Brandeburg17652c62015-11-05 17:01:02 -0800904 ret = i40e_sync_vsi_filters(vsi);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000905 if (f && !ret)
906 dev_info(&pf->pdev->dev,
907 "add macaddr: %pM vlan=%d added to VSI %d\n",
908 ma, vlan, vsi_seid);
909 else
910 dev_info(&pf->pdev->dev,
911 "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
912 ma, vlan, vsi_seid, f, ret);
913
914 } else if (strncmp(cmd_buf, "del macaddr", 11) == 0) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000915 int vlan = 0;
Shannon Nelson738a9e92013-09-28 07:14:04 +0000916 u8 ma[6];
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000917 int ret;
918
919 cnt = sscanf(&cmd_buf[11],
920 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
921 &vsi_seid,
922 &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
923 &vlan);
924 if (cnt == 7) {
925 vlan = 0;
926 } else if (cnt != 8) {
927 dev_info(&pf->pdev->dev,
928 "del macaddr: bad command string, cnt=%d\n",
929 cnt);
930 goto command_write_done;
931 }
932
933 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
934 if (!vsi) {
935 dev_info(&pf->pdev->dev,
936 "del macaddr: VSI %d not found\n", vsi_seid);
937 goto command_write_done;
938 }
939
Anjali Singhai Jain10dc0352015-10-01 14:37:35 -0400940 spin_lock_bh(&vsi->mac_filter_list_lock);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000941 i40e_del_filter(vsi, ma, vlan, false, false);
Anjali Singhai Jain10dc0352015-10-01 14:37:35 -0400942 spin_unlock_bh(&vsi->mac_filter_list_lock);
Jesse Brandeburg17652c62015-11-05 17:01:02 -0800943 ret = i40e_sync_vsi_filters(vsi);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000944 if (!ret)
945 dev_info(&pf->pdev->dev,
946 "del macaddr: %pM vlan=%d removed from VSI %d\n",
947 ma, vlan, vsi_seid);
948 else
949 dev_info(&pf->pdev->dev,
950 "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
951 ma, vlan, vsi_seid, ret);
952
953 } else if (strncmp(cmd_buf, "add pvid", 8) == 0) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000954 i40e_status ret;
Shannon Nelson738a9e92013-09-28 07:14:04 +0000955 u16 vid;
Toralf Försterefe1ac22014-05-20 08:23:00 +0000956 unsigned int v;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000957
958 cnt = sscanf(&cmd_buf[8], "%i %u", &vsi_seid, &v);
959 if (cnt != 2) {
960 dev_info(&pf->pdev->dev,
961 "add pvid: bad command string, cnt=%d\n", cnt);
962 goto command_write_done;
963 }
964
965 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
966 if (!vsi) {
967 dev_info(&pf->pdev->dev, "add pvid: VSI %d not found\n",
968 vsi_seid);
969 goto command_write_done;
970 }
971
Toralf Försterefe1ac22014-05-20 08:23:00 +0000972 vid = v;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +0000973 ret = i40e_vsi_add_pvid(vsi, vid);
974 if (!ret)
975 dev_info(&pf->pdev->dev,
976 "add pvid: %d added to VSI %d\n",
977 vid, vsi_seid);
978 else
979 dev_info(&pf->pdev->dev,
980 "add pvid: %d to VSI %d failed, ret=%d\n",
981 vid, vsi_seid, ret);
982
983 } else if (strncmp(cmd_buf, "del pvid", 8) == 0) {
984
985 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
986 if (cnt != 1) {
987 dev_info(&pf->pdev->dev,
988 "del pvid: bad command string, cnt=%d\n",
989 cnt);
990 goto command_write_done;
991 }
992
993 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
994 if (!vsi) {
995 dev_info(&pf->pdev->dev,
996 "del pvid: VSI %d not found\n", vsi_seid);
997 goto command_write_done;
998 }
999
1000 i40e_vsi_remove_pvid(vsi);
1001 dev_info(&pf->pdev->dev,
1002 "del pvid: removed from VSI %d\n", vsi_seid);
1003
1004 } else if (strncmp(cmd_buf, "dump", 4) == 0) {
1005 if (strncmp(&cmd_buf[5], "switch", 6) == 0) {
1006 i40e_fetch_switch_configuration(pf, true);
1007 } else if (strncmp(&cmd_buf[5], "vsi", 3) == 0) {
1008 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1009 if (cnt > 0)
1010 i40e_dbg_dump_vsi_seid(pf, vsi_seid);
1011 else
1012 i40e_dbg_dump_vsi_no_seid(pf);
1013 } else if (strncmp(&cmd_buf[5], "veb", 3) == 0) {
1014 cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
1015 if (cnt > 0)
1016 i40e_dbg_dump_veb_seid(pf, vsi_seid);
1017 else
1018 i40e_dbg_dump_veb_all(pf);
1019 } else if (strncmp(&cmd_buf[5], "desc", 4) == 0) {
1020 int ring_id, desc_n;
1021 if (strncmp(&cmd_buf[10], "rx", 2) == 0) {
1022 cnt = sscanf(&cmd_buf[12], "%i %i %i",
1023 &vsi_seid, &ring_id, &desc_n);
1024 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1025 desc_n, pf, true);
1026 } else if (strncmp(&cmd_buf[10], "tx", 2)
1027 == 0) {
1028 cnt = sscanf(&cmd_buf[12], "%i %i %i",
1029 &vsi_seid, &ring_id, &desc_n);
1030 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1031 desc_n, pf, false);
1032 } else if (strncmp(&cmd_buf[10], "aq", 2) == 0) {
1033 i40e_dbg_dump_aq_desc(pf);
1034 } else {
1035 dev_info(&pf->pdev->dev,
1036 "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1037 dev_info(&pf->pdev->dev,
1038 "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1039 dev_info(&pf->pdev->dev, "dump desc aq\n");
1040 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001041 } else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) {
1042 dev_info(&pf->pdev->dev,
1043 "core reset count: %d\n", pf->corer_count);
1044 dev_info(&pf->pdev->dev,
1045 "global reset count: %d\n", pf->globr_count);
1046 dev_info(&pf->pdev->dev,
1047 "emp reset count: %d\n", pf->empr_count);
1048 dev_info(&pf->pdev->dev,
1049 "pf reset count: %d\n", pf->pfr_count);
Anjali Singhai Jain810b3ae2014-07-10 07:58:25 +00001050 dev_info(&pf->pdev->dev,
1051 "pf tx sluggish count: %d\n",
1052 pf->tx_sluggish_count);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001053 } else if (strncmp(&cmd_buf[5], "port", 4) == 0) {
1054 struct i40e_aqc_query_port_ets_config_resp *bw_data;
1055 struct i40e_dcbx_config *cfg =
1056 &pf->hw.local_dcbx_config;
1057 struct i40e_dcbx_config *r_cfg =
1058 &pf->hw.remote_dcbx_config;
1059 int i, ret;
1060
1061 bw_data = kzalloc(sizeof(
1062 struct i40e_aqc_query_port_ets_config_resp),
1063 GFP_KERNEL);
1064 if (!bw_data) {
1065 ret = -ENOMEM;
1066 goto command_write_done;
1067 }
1068
1069 ret = i40e_aq_query_port_ets_config(&pf->hw,
1070 pf->mac_seid,
1071 bw_data, NULL);
1072 if (ret) {
1073 dev_info(&pf->pdev->dev,
1074 "Query Port ETS Config AQ command failed =0x%x\n",
1075 pf->hw.aq.asq_last_status);
1076 kfree(bw_data);
1077 bw_data = NULL;
1078 goto command_write_done;
1079 }
1080 dev_info(&pf->pdev->dev,
1081 "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
1082 bw_data->tc_valid_bits,
1083 bw_data->tc_strict_priority_bits,
1084 le16_to_cpu(bw_data->tc_bw_max[0]),
1085 le16_to_cpu(bw_data->tc_bw_max[1]));
1086 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1087 dev_info(&pf->pdev->dev, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
1088 bw_data->tc_bw_share_credits[i],
1089 le16_to_cpu(bw_data->tc_bw_limits[i]));
1090 }
1091
1092 kfree(bw_data);
1093 bw_data = NULL;
1094
1095 dev_info(&pf->pdev->dev,
Neerav Parikh9fa61dd2014-11-12 00:18:25 +00001096 "port dcbx_mode=%d\n", cfg->dcbx_mode);
1097 dev_info(&pf->pdev->dev,
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001098 "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1099 cfg->etscfg.willing, cfg->etscfg.cbs,
1100 cfg->etscfg.maxtcs);
1101 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1102 dev_info(&pf->pdev->dev, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1103 i, cfg->etscfg.prioritytable[i],
1104 cfg->etscfg.tcbwtable[i],
1105 cfg->etscfg.tsatable[i]);
1106 }
1107 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1108 dev_info(&pf->pdev->dev, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1109 i, cfg->etsrec.prioritytable[i],
1110 cfg->etsrec.tcbwtable[i],
1111 cfg->etsrec.tsatable[i]);
1112 }
1113 dev_info(&pf->pdev->dev,
1114 "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1115 cfg->pfc.willing, cfg->pfc.mbc,
1116 cfg->pfc.pfccap, cfg->pfc.pfcenable);
1117 dev_info(&pf->pdev->dev,
1118 "port app_table: num_apps=%d\n", cfg->numapps);
1119 for (i = 0; i < cfg->numapps; i++) {
1120 dev_info(&pf->pdev->dev, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1121 i, cfg->app[i].priority,
1122 cfg->app[i].selector,
1123 cfg->app[i].protocolid);
1124 }
1125 /* Peer TLV DCBX data */
1126 dev_info(&pf->pdev->dev,
1127 "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1128 r_cfg->etscfg.willing,
1129 r_cfg->etscfg.cbs, r_cfg->etscfg.maxtcs);
1130 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1131 dev_info(&pf->pdev->dev, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1132 i, r_cfg->etscfg.prioritytable[i],
1133 r_cfg->etscfg.tcbwtable[i],
1134 r_cfg->etscfg.tsatable[i]);
1135 }
1136 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1137 dev_info(&pf->pdev->dev, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1138 i, r_cfg->etsrec.prioritytable[i],
1139 r_cfg->etsrec.tcbwtable[i],
1140 r_cfg->etsrec.tsatable[i]);
1141 }
1142 dev_info(&pf->pdev->dev,
1143 "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1144 r_cfg->pfc.willing,
1145 r_cfg->pfc.mbc,
1146 r_cfg->pfc.pfccap,
1147 r_cfg->pfc.pfcenable);
1148 dev_info(&pf->pdev->dev,
1149 "remote port app_table: num_apps=%d\n",
1150 r_cfg->numapps);
1151 for (i = 0; i < r_cfg->numapps; i++) {
1152 dev_info(&pf->pdev->dev, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1153 i, r_cfg->app[i].priority,
1154 r_cfg->app[i].selector,
1155 r_cfg->app[i].protocolid);
1156 }
Jesse Brandeburg3169c322015-04-07 19:45:37 -04001157 } else if (strncmp(&cmd_buf[5], "debug fwdata", 12) == 0) {
1158 int cluster_id, table_id;
1159 int index, ret;
1160 u16 buff_len = 4096;
1161 u32 next_index;
1162 u8 next_table;
1163 u8 *buff;
1164 u16 rlen;
1165
1166 cnt = sscanf(&cmd_buf[18], "%i %i %i",
1167 &cluster_id, &table_id, &index);
1168 if (cnt != 3) {
1169 dev_info(&pf->pdev->dev,
1170 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1171 goto command_write_done;
1172 }
1173
1174 dev_info(&pf->pdev->dev,
1175 "AQ debug dump fwdata params %x %x %x %x\n",
1176 cluster_id, table_id, index, buff_len);
1177 buff = kzalloc(buff_len, GFP_KERNEL);
1178 if (!buff)
1179 goto command_write_done;
1180
1181 ret = i40e_aq_debug_dump(&pf->hw, cluster_id, table_id,
1182 index, buff_len, buff, &rlen,
1183 &next_table, &next_index,
1184 NULL);
1185 if (ret) {
1186 dev_info(&pf->pdev->dev,
1187 "debug dump fwdata AQ Failed %d 0x%x\n",
1188 ret, pf->hw.aq.asq_last_status);
1189 kfree(buff);
1190 buff = NULL;
1191 goto command_write_done;
1192 }
1193 dev_info(&pf->pdev->dev,
1194 "AQ debug dump fwdata rlen=0x%x next_table=0x%x next_index=0x%x\n",
1195 rlen, next_table, next_index);
1196 print_hex_dump(KERN_INFO, "AQ buffer WB: ",
1197 DUMP_PREFIX_OFFSET, 16, 1,
1198 buff, rlen, true);
1199 kfree(buff);
1200 buff = NULL;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001201 } else {
1202 dev_info(&pf->pdev->dev,
1203 "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
Shannon Nelson7204a782014-10-17 03:14:47 +00001204 dev_info(&pf->pdev->dev, "dump switch\n");
1205 dev_info(&pf->pdev->dev, "dump vsi [seid]\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001206 dev_info(&pf->pdev->dev, "dump reset stats\n");
1207 dev_info(&pf->pdev->dev, "dump port\n");
1208 dev_info(&pf->pdev->dev,
1209 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1210 }
1211
1212 } else if (strncmp(cmd_buf, "msg_enable", 10) == 0) {
1213 u32 level;
1214 cnt = sscanf(&cmd_buf[10], "%i", &level);
1215 if (cnt) {
1216 if (I40E_DEBUG_USER & level) {
1217 pf->hw.debug_mask = level;
1218 dev_info(&pf->pdev->dev,
1219 "set hw.debug_mask = 0x%08x\n",
1220 pf->hw.debug_mask);
1221 }
1222 pf->msg_enable = level;
1223 dev_info(&pf->pdev->dev, "set msg_enable = 0x%08x\n",
1224 pf->msg_enable);
1225 } else {
1226 dev_info(&pf->pdev->dev, "msg_enable = 0x%08x\n",
1227 pf->msg_enable);
1228 }
1229 } else if (strncmp(cmd_buf, "pfr", 3) == 0) {
Jesse Brandeburg69bfb112014-02-11 08:24:13 +00001230 dev_info(&pf->pdev->dev, "debugfs: forcing PFR\n");
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001231 i40e_do_reset_safe(pf, BIT(__I40E_PF_RESET_REQUESTED));
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001232
1233 } else if (strncmp(cmd_buf, "corer", 5) == 0) {
Jesse Brandeburg69bfb112014-02-11 08:24:13 +00001234 dev_info(&pf->pdev->dev, "debugfs: forcing CoreR\n");
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001235 i40e_do_reset_safe(pf, BIT(__I40E_CORE_RESET_REQUESTED));
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001236
1237 } else if (strncmp(cmd_buf, "globr", 5) == 0) {
Jesse Brandeburg69bfb112014-02-11 08:24:13 +00001238 dev_info(&pf->pdev->dev, "debugfs: forcing GlobR\n");
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001239 i40e_do_reset_safe(pf, BIT(__I40E_GLOBAL_RESET_REQUESTED));
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001240
Shannon Nelson7823fe32013-11-16 10:00:45 +00001241 } else if (strncmp(cmd_buf, "empr", 4) == 0) {
Jesse Brandeburg69bfb112014-02-11 08:24:13 +00001242 dev_info(&pf->pdev->dev, "debugfs: forcing EMPR\n");
Jesse Brandeburg41a1d042015-06-04 16:24:02 -04001243 i40e_do_reset_safe(pf, BIT(__I40E_EMP_RESET_REQUESTED));
Shannon Nelson7823fe32013-11-16 10:00:45 +00001244
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001245 } else if (strncmp(cmd_buf, "read", 4) == 0) {
1246 u32 address;
1247 u32 value;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001248
Shannon Nelson2706a202013-11-26 10:49:30 +00001249 cnt = sscanf(&cmd_buf[4], "%i", &address);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001250 if (cnt != 1) {
1251 dev_info(&pf->pdev->dev, "read <reg>\n");
1252 goto command_write_done;
1253 }
1254
1255 /* check the range on address */
Shannon Nelson2ac8b672015-07-23 16:54:37 -04001256 if (address > (pf->ioremap_len - sizeof(u32))) {
1257 dev_info(&pf->pdev->dev, "read reg address 0x%08x too large, max=0x%08lx\n",
Jesse Brandeburge88ae662015-08-13 18:54:26 -07001258 address, (unsigned long int)(pf->ioremap_len - sizeof(u32)));
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001259 goto command_write_done;
1260 }
1261
1262 value = rd32(&pf->hw, address);
1263 dev_info(&pf->pdev->dev, "read: 0x%08x = 0x%08x\n",
1264 address, value);
1265
1266 } else if (strncmp(cmd_buf, "write", 5) == 0) {
1267 u32 address, value;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001268
Shannon Nelson2706a202013-11-26 10:49:30 +00001269 cnt = sscanf(&cmd_buf[5], "%i %i", &address, &value);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001270 if (cnt != 2) {
1271 dev_info(&pf->pdev->dev, "write <reg> <value>\n");
1272 goto command_write_done;
1273 }
1274
1275 /* check the range on address */
Shannon Nelson2ac8b672015-07-23 16:54:37 -04001276 if (address > (pf->ioremap_len - sizeof(u32))) {
1277 dev_info(&pf->pdev->dev, "write reg address 0x%08x too large, max=0x%08lx\n",
Jesse Brandeburge88ae662015-08-13 18:54:26 -07001278 address, (unsigned long int)(pf->ioremap_len - sizeof(u32)));
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001279 goto command_write_done;
1280 }
1281 wr32(&pf->hw, address, value);
1282 value = rd32(&pf->hw, address);
1283 dev_info(&pf->pdev->dev, "write: 0x%08x = 0x%08x\n",
1284 address, value);
1285 } else if (strncmp(cmd_buf, "clear_stats", 11) == 0) {
1286 if (strncmp(&cmd_buf[12], "vsi", 3) == 0) {
Shannon Nelson2706a202013-11-26 10:49:30 +00001287 cnt = sscanf(&cmd_buf[15], "%i", &vsi_seid);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001288 if (cnt == 0) {
1289 int i;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001290
Mitch Williams505682c2014-05-20 08:01:37 +00001291 for (i = 0; i < pf->num_alloc_vsi; i++)
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001292 i40e_vsi_reset_stats(pf->vsi[i]);
1293 dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n");
1294 } else if (cnt == 1) {
1295 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1296 if (!vsi) {
1297 dev_info(&pf->pdev->dev,
1298 "clear_stats vsi: bad vsi %d\n",
1299 vsi_seid);
1300 goto command_write_done;
1301 }
1302 i40e_vsi_reset_stats(vsi);
1303 dev_info(&pf->pdev->dev,
1304 "vsi clear stats called for vsi %d\n",
1305 vsi_seid);
1306 } else {
1307 dev_info(&pf->pdev->dev, "clear_stats vsi [seid]\n");
1308 }
Shannon Nelson694dc1c2015-01-24 09:58:34 +00001309 } else if (strncmp(&cmd_buf[12], "port", 4) == 0) {
1310 if (pf->hw.partition_id == 1) {
1311 i40e_pf_reset_stats(pf);
1312 dev_info(&pf->pdev->dev, "port stats cleared\n");
1313 } else {
1314 dev_info(&pf->pdev->dev, "clear port stats not allowed on this port partition\n");
1315 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001316 } else {
Shannon Nelson694dc1c2015-01-24 09:58:34 +00001317 dev_info(&pf->pdev->dev, "clear_stats vsi [seid] or clear_stats port\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001318 }
Anjali Singhai Jainf1143c42013-11-28 06:42:38 +00001319 } else if (strncmp(cmd_buf, "send aq_cmd", 11) == 0) {
1320 struct i40e_aq_desc *desc;
1321 i40e_status ret;
1322
1323 desc = kzalloc(sizeof(struct i40e_aq_desc), GFP_KERNEL);
1324 if (!desc)
1325 goto command_write_done;
1326 cnt = sscanf(&cmd_buf[11],
Shannon Nelsonfbe82102014-11-11 20:05:13 +00001327 "%hi %hi %hi %hi %i %i %i %i %i %i",
Anjali Singhai Jainf1143c42013-11-28 06:42:38 +00001328 &desc->flags,
1329 &desc->opcode, &desc->datalen, &desc->retval,
1330 &desc->cookie_high, &desc->cookie_low,
1331 &desc->params.internal.param0,
1332 &desc->params.internal.param1,
1333 &desc->params.internal.param2,
1334 &desc->params.internal.param3);
1335 if (cnt != 10) {
1336 dev_info(&pf->pdev->dev,
1337 "send aq_cmd: bad command string, cnt=%d\n",
1338 cnt);
1339 kfree(desc);
1340 desc = NULL;
1341 goto command_write_done;
1342 }
1343 ret = i40e_asq_send_command(&pf->hw, desc, NULL, 0, NULL);
1344 if (!ret) {
1345 dev_info(&pf->pdev->dev, "AQ command sent Status : Success\n");
1346 } else if (ret == I40E_ERR_ADMIN_QUEUE_ERROR) {
1347 dev_info(&pf->pdev->dev,
1348 "AQ command send failed Opcode %x AQ Error: %d\n",
1349 desc->opcode, pf->hw.aq.asq_last_status);
1350 } else {
1351 dev_info(&pf->pdev->dev,
1352 "AQ command send failed Opcode %x Status: %d\n",
1353 desc->opcode, ret);
1354 }
1355 dev_info(&pf->pdev->dev,
1356 "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
1357 desc->flags, desc->opcode, desc->datalen, desc->retval,
1358 desc->cookie_high, desc->cookie_low,
1359 desc->params.internal.param0,
1360 desc->params.internal.param1,
1361 desc->params.internal.param2,
1362 desc->params.internal.param3);
1363 kfree(desc);
1364 desc = NULL;
1365 } else if (strncmp(cmd_buf, "send indirect aq_cmd", 20) == 0) {
1366 struct i40e_aq_desc *desc;
1367 i40e_status ret;
1368 u16 buffer_len;
1369 u8 *buff;
1370
1371 desc = kzalloc(sizeof(struct i40e_aq_desc), GFP_KERNEL);
1372 if (!desc)
1373 goto command_write_done;
1374 cnt = sscanf(&cmd_buf[20],
Shannon Nelsonfbe82102014-11-11 20:05:13 +00001375 "%hi %hi %hi %hi %i %i %i %i %i %i %hi",
Anjali Singhai Jainf1143c42013-11-28 06:42:38 +00001376 &desc->flags,
1377 &desc->opcode, &desc->datalen, &desc->retval,
1378 &desc->cookie_high, &desc->cookie_low,
1379 &desc->params.internal.param0,
1380 &desc->params.internal.param1,
1381 &desc->params.internal.param2,
1382 &desc->params.internal.param3,
1383 &buffer_len);
1384 if (cnt != 11) {
1385 dev_info(&pf->pdev->dev,
1386 "send indirect aq_cmd: bad command string, cnt=%d\n",
1387 cnt);
1388 kfree(desc);
1389 desc = NULL;
1390 goto command_write_done;
1391 }
1392 /* Just stub a buffer big enough in case user messed up */
1393 if (buffer_len == 0)
1394 buffer_len = 1280;
1395
1396 buff = kzalloc(buffer_len, GFP_KERNEL);
1397 if (!buff) {
1398 kfree(desc);
1399 desc = NULL;
1400 goto command_write_done;
1401 }
1402 desc->flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
1403 ret = i40e_asq_send_command(&pf->hw, desc, buff,
1404 buffer_len, NULL);
1405 if (!ret) {
1406 dev_info(&pf->pdev->dev, "AQ command sent Status : Success\n");
1407 } else if (ret == I40E_ERR_ADMIN_QUEUE_ERROR) {
1408 dev_info(&pf->pdev->dev,
1409 "AQ command send failed Opcode %x AQ Error: %d\n",
1410 desc->opcode, pf->hw.aq.asq_last_status);
1411 } else {
1412 dev_info(&pf->pdev->dev,
1413 "AQ command send failed Opcode %x Status: %d\n",
1414 desc->opcode, ret);
1415 }
1416 dev_info(&pf->pdev->dev,
1417 "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
1418 desc->flags, desc->opcode, desc->datalen, desc->retval,
1419 desc->cookie_high, desc->cookie_low,
1420 desc->params.internal.param0,
1421 desc->params.internal.param1,
1422 desc->params.internal.param2,
1423 desc->params.internal.param3);
1424 print_hex_dump(KERN_INFO, "AQ buffer WB: ",
1425 DUMP_PREFIX_OFFSET, 16, 1,
1426 buff, buffer_len, true);
1427 kfree(buff);
1428 buff = NULL;
1429 kfree(desc);
1430 desc = NULL;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001431 } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) ||
1432 (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) {
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001433 struct i40e_fdir_filter fd_data;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001434 u16 packet_len, i, j = 0;
1435 char *asc_packet;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001436 u8 *raw_packet;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001437 bool add = false;
Shannon Nelson738a9e92013-09-28 07:14:04 +00001438 int ret;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001439
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00001440 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
1441 goto command_write_done;
1442
1443 if (strncmp(cmd_buf, "add", 3) == 0)
1444 add = true;
1445
1446 if (add && (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED))
1447 goto command_write_done;
1448
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001449 asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE,
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001450 GFP_KERNEL);
1451 if (!asc_packet)
1452 goto command_write_done;
1453
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001454 raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE,
1455 GFP_KERNEL);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001456
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001457 if (!raw_packet) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001458 kfree(asc_packet);
1459 asc_packet = NULL;
1460 goto command_write_done;
1461 }
1462
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001463 cnt = sscanf(&cmd_buf[13],
Alan Cox5561b6a2013-12-12 02:44:24 +00001464 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %511s",
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001465 &fd_data.q_index,
1466 &fd_data.flex_off, &fd_data.pctype,
1467 &fd_data.dest_vsi, &fd_data.dest_ctl,
1468 &fd_data.fd_status, &fd_data.cnt_index,
1469 &fd_data.fd_id, &packet_len, asc_packet);
1470 if (cnt != 10) {
1471 dev_info(&pf->pdev->dev,
1472 "program fd_filter: bad command string, cnt=%d\n",
1473 cnt);
1474 kfree(asc_packet);
1475 asc_packet = NULL;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001476 kfree(raw_packet);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001477 goto command_write_done;
1478 }
1479
1480 /* fix packet length if user entered 0 */
1481 if (packet_len == 0)
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001482 packet_len = I40E_FDIR_MAX_RAW_PACKET_SIZE;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001483
1484 /* make sure to check the max as well */
1485 packet_len = min_t(u16,
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001486 packet_len, I40E_FDIR_MAX_RAW_PACKET_SIZE);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001487
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001488 for (i = 0; i < packet_len; i++) {
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001489 cnt = sscanf(&asc_packet[j], "%2hhx ", &raw_packet[i]);
1490 if (!cnt)
1491 break;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001492 j += 3;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001493 }
Neerav Parikh3753cb22013-11-26 10:49:25 +00001494 dev_info(&pf->pdev->dev, "FD raw packet dump\n");
1495 print_hex_dump(KERN_INFO, "FD raw packet: ",
1496 DUMP_PREFIX_OFFSET, 16, 1,
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001497 raw_packet, packet_len, true);
1498 ret = i40e_program_fdir_filter(&fd_data, raw_packet, pf, add);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001499 if (!ret) {
1500 dev_info(&pf->pdev->dev, "Filter command send Status : Success\n");
1501 } else {
1502 dev_info(&pf->pdev->dev,
1503 "Filter command send failed %d\n", ret);
1504 }
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001505 kfree(raw_packet);
1506 raw_packet = NULL;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001507 kfree(asc_packet);
1508 asc_packet = NULL;
Anjali Singhai Jaine17ff052014-06-04 04:22:48 +00001509 } else if (strncmp(cmd_buf, "fd current cnt", 14) == 0) {
1510 dev_info(&pf->pdev->dev, "FD current total filter count for this interface: %d\n",
1511 i40e_get_current_fd_count(pf));
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001512 } else if (strncmp(cmd_buf, "lldp", 4) == 0) {
1513 if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
1514 int ret;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001515
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001516 ret = i40e_aq_stop_lldp(&pf->hw, false, NULL);
1517 if (ret) {
1518 dev_info(&pf->pdev->dev,
1519 "Stop LLDP AQ command failed =0x%x\n",
1520 pf->hw.aq.asq_last_status);
1521 goto command_write_done;
1522 }
Neerav Parikh4e3b35b2014-01-17 15:36:37 -08001523 ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
1524 pf->hw.mac.addr,
1525 I40E_ETH_P_LLDP, 0,
1526 pf->vsi[pf->lan_vsi]->seid,
1527 0, true, NULL, NULL);
1528 if (ret) {
1529 dev_info(&pf->pdev->dev,
1530 "%s: Add Control Packet Filter AQ command failed =0x%x\n",
1531 __func__, pf->hw.aq.asq_last_status);
1532 goto command_write_done;
1533 }
1534#ifdef CONFIG_I40E_DCB
1535 pf->dcbx_cap = DCB_CAP_DCBX_HOST |
1536 DCB_CAP_DCBX_VER_IEEE;
1537#endif /* CONFIG_I40E_DCB */
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001538 } else if (strncmp(&cmd_buf[5], "start", 5) == 0) {
1539 int ret;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001540
Neerav Parikh4e3b35b2014-01-17 15:36:37 -08001541 ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
1542 pf->hw.mac.addr,
1543 I40E_ETH_P_LLDP, 0,
1544 pf->vsi[pf->lan_vsi]->seid,
1545 0, false, NULL, NULL);
1546 if (ret) {
1547 dev_info(&pf->pdev->dev,
1548 "%s: Remove Control Packet Filter AQ command failed =0x%x\n",
1549 __func__, pf->hw.aq.asq_last_status);
1550 /* Continue and start FW LLDP anyways */
1551 }
1552
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001553 ret = i40e_aq_start_lldp(&pf->hw, NULL);
1554 if (ret) {
1555 dev_info(&pf->pdev->dev,
1556 "Start LLDP AQ command failed =0x%x\n",
1557 pf->hw.aq.asq_last_status);
1558 goto command_write_done;
1559 }
Neerav Parikh4e3b35b2014-01-17 15:36:37 -08001560#ifdef CONFIG_I40E_DCB
1561 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED |
1562 DCB_CAP_DCBX_VER_IEEE;
1563#endif /* CONFIG_I40E_DCB */
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001564 } else if (strncmp(&cmd_buf[5],
1565 "get local", 9) == 0) {
Shannon Nelson738a9e92013-09-28 07:14:04 +00001566 u16 llen, rlen;
Neerav Parikh3753cb22013-11-26 10:49:25 +00001567 int ret;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001568 u8 *buff;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001569
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001570 buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
1571 if (!buff)
1572 goto command_write_done;
1573
1574 ret = i40e_aq_get_lldp_mib(&pf->hw, 0,
1575 I40E_AQ_LLDP_MIB_LOCAL,
1576 buff, I40E_LLDPDU_SIZE,
1577 &llen, &rlen, NULL);
1578 if (ret) {
1579 dev_info(&pf->pdev->dev,
1580 "Get LLDP MIB (local) AQ command failed =0x%x\n",
1581 pf->hw.aq.asq_last_status);
1582 kfree(buff);
1583 buff = NULL;
1584 goto command_write_done;
1585 }
Neerav Parikh3753cb22013-11-26 10:49:25 +00001586 dev_info(&pf->pdev->dev, "LLDP MIB (local)\n");
1587 print_hex_dump(KERN_INFO, "LLDP MIB (local): ",
1588 DUMP_PREFIX_OFFSET, 16, 1,
1589 buff, I40E_LLDPDU_SIZE, true);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001590 kfree(buff);
1591 buff = NULL;
1592 } else if (strncmp(&cmd_buf[5], "get remote", 10) == 0) {
Shannon Nelson738a9e92013-09-28 07:14:04 +00001593 u16 llen, rlen;
Neerav Parikh3753cb22013-11-26 10:49:25 +00001594 int ret;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001595 u8 *buff;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001596
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001597 buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
1598 if (!buff)
1599 goto command_write_done;
1600
1601 ret = i40e_aq_get_lldp_mib(&pf->hw,
1602 I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE,
Neerav Parikhc27936e2014-06-03 23:50:16 +00001603 I40E_AQ_LLDP_MIB_REMOTE,
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001604 buff, I40E_LLDPDU_SIZE,
1605 &llen, &rlen, NULL);
1606 if (ret) {
1607 dev_info(&pf->pdev->dev,
1608 "Get LLDP MIB (remote) AQ command failed =0x%x\n",
1609 pf->hw.aq.asq_last_status);
1610 kfree(buff);
1611 buff = NULL;
1612 goto command_write_done;
1613 }
Neerav Parikh3753cb22013-11-26 10:49:25 +00001614 dev_info(&pf->pdev->dev, "LLDP MIB (remote)\n");
1615 print_hex_dump(KERN_INFO, "LLDP MIB (remote): ",
1616 DUMP_PREFIX_OFFSET, 16, 1,
1617 buff, I40E_LLDPDU_SIZE, true);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001618 kfree(buff);
1619 buff = NULL;
1620 } else if (strncmp(&cmd_buf[5], "event on", 8) == 0) {
1621 int ret;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001622
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001623 ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
1624 true, NULL);
1625 if (ret) {
1626 dev_info(&pf->pdev->dev,
1627 "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
1628 pf->hw.aq.asq_last_status);
1629 goto command_write_done;
1630 }
1631 } else if (strncmp(&cmd_buf[5], "event off", 9) == 0) {
1632 int ret;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001633
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001634 ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
1635 false, NULL);
1636 if (ret) {
1637 dev_info(&pf->pdev->dev,
1638 "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
1639 pf->hw.aq.asq_last_status);
1640 goto command_write_done;
1641 }
1642 }
1643 } else if (strncmp(cmd_buf, "nvm read", 8) == 0) {
Neerav Parikh3753cb22013-11-26 10:49:25 +00001644 u16 buffer_len, bytes;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001645 u16 module;
1646 u32 offset;
1647 u16 *buff;
1648 int ret;
1649
1650 cnt = sscanf(&cmd_buf[8], "%hx %x %hx",
1651 &module, &offset, &buffer_len);
1652 if (cnt == 0) {
1653 module = 0;
1654 offset = 0;
1655 buffer_len = 0;
1656 } else if (cnt == 1) {
1657 offset = 0;
1658 buffer_len = 0;
1659 } else if (cnt == 2) {
1660 buffer_len = 0;
1661 } else if (cnt > 3) {
1662 dev_info(&pf->pdev->dev,
1663 "nvm read: bad command string, cnt=%d\n", cnt);
1664 goto command_write_done;
1665 }
1666
Jesse Brandeburg520dfd82013-09-28 07:13:39 +00001667 /* set the max length */
1668 buffer_len = min_t(u16, buffer_len, I40E_MAX_AQ_BUF_SIZE/2);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001669
1670 bytes = 2 * buffer_len;
Jesse Brandeburg520dfd82013-09-28 07:13:39 +00001671
1672 /* read at least 1k bytes, no more than 4kB */
1673 bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001674 buff = kzalloc(bytes, GFP_KERNEL);
1675 if (!buff)
1676 goto command_write_done;
1677
1678 ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ);
1679 if (ret) {
1680 dev_info(&pf->pdev->dev,
1681 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1682 ret, pf->hw.aq.asq_last_status);
1683 kfree(buff);
1684 goto command_write_done;
1685 }
1686
1687 ret = i40e_aq_read_nvm(&pf->hw, module, (2 * offset),
1688 bytes, (u8 *)buff, true, NULL);
1689 i40e_release_nvm(&pf->hw);
1690 if (ret) {
1691 dev_info(&pf->pdev->dev,
1692 "Read NVM AQ failed err=%d status=0x%x\n",
1693 ret, pf->hw.aq.asq_last_status);
1694 } else {
1695 dev_info(&pf->pdev->dev,
1696 "Read NVM module=0x%x offset=0x%x words=%d\n",
1697 module, offset, buffer_len);
Anjali Singhai Jaina45e88c2013-11-28 06:39:26 +00001698 if (bytes)
Neerav Parikh3753cb22013-11-26 10:49:25 +00001699 print_hex_dump(KERN_INFO, "NVM Dump: ",
1700 DUMP_PREFIX_OFFSET, 16, 2,
Anjali Singhai Jaina45e88c2013-11-28 06:39:26 +00001701 buff, bytes, true);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001702 }
1703 kfree(buff);
1704 buff = NULL;
1705 } else {
1706 dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf);
1707 dev_info(&pf->pdev->dev, "available commands\n");
1708 dev_info(&pf->pdev->dev, " add vsi [relay_seid]\n");
1709 dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n");
1710 dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n");
1711 dev_info(&pf->pdev->dev, " del relay <relay_seid>\n");
1712 dev_info(&pf->pdev->dev, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1713 dev_info(&pf->pdev->dev, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1714 dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n");
1715 dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n");
1716 dev_info(&pf->pdev->dev, " dump switch\n");
1717 dev_info(&pf->pdev->dev, " dump vsi [seid]\n");
1718 dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1719 dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1720 dev_info(&pf->pdev->dev, " dump desc aq\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001721 dev_info(&pf->pdev->dev, " dump reset stats\n");
Jesse Brandeburg3169c322015-04-07 19:45:37 -04001722 dev_info(&pf->pdev->dev, " dump debug fwdata <cluster_id> <table_id> <index>\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001723 dev_info(&pf->pdev->dev, " msg_enable [level]\n");
1724 dev_info(&pf->pdev->dev, " read <reg>\n");
1725 dev_info(&pf->pdev->dev, " write <reg> <value>\n");
1726 dev_info(&pf->pdev->dev, " clear_stats vsi [seid]\n");
Shannon Nelson694dc1c2015-01-24 09:58:34 +00001727 dev_info(&pf->pdev->dev, " clear_stats port\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001728 dev_info(&pf->pdev->dev, " pfr\n");
1729 dev_info(&pf->pdev->dev, " corer\n");
1730 dev_info(&pf->pdev->dev, " globr\n");
Anjali Singhai Jainf1143c42013-11-28 06:42:38 +00001731 dev_info(&pf->pdev->dev, " send aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3>\n");
1732 dev_info(&pf->pdev->dev, " send indirect aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3> <buffer_len>\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001733 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");
1734 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");
Anjali Singhai Jaine17ff052014-06-04 04:22:48 +00001735 dev_info(&pf->pdev->dev, " fd current cnt");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001736 dev_info(&pf->pdev->dev, " lldp start\n");
1737 dev_info(&pf->pdev->dev, " lldp stop\n");
1738 dev_info(&pf->pdev->dev, " lldp get local\n");
1739 dev_info(&pf->pdev->dev, " lldp get remote\n");
1740 dev_info(&pf->pdev->dev, " lldp event on\n");
1741 dev_info(&pf->pdev->dev, " lldp event off\n");
1742 dev_info(&pf->pdev->dev, " nvm read [module] [word_offset] [word_count]\n");
1743 }
1744
1745command_write_done:
1746 kfree(cmd_buf);
1747 cmd_buf = NULL;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001748 return count;
1749}
1750
1751static const struct file_operations i40e_dbg_command_fops = {
1752 .owner = THIS_MODULE,
1753 .open = simple_open,
1754 .read = i40e_dbg_command_read,
1755 .write = i40e_dbg_command_write,
1756};
1757
1758/**************************************************************
1759 * netdev_ops
1760 * The netdev_ops entry in debugfs is for giving the driver commands
1761 * to be executed from the netdev operations.
1762 **************************************************************/
Greg Rosed1da3ac2015-02-27 09:18:29 +00001763static char i40e_dbg_netdev_ops_buf[256] = "";
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001764
1765/**
1766 * i40e_dbg_netdev_ops - read for netdev_ops datum
1767 * @filp: the opened file
1768 * @buffer: where to write the data for the user to read
1769 * @count: the size of the user's buffer
1770 * @ppos: file position offset
1771 **/
1772static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
1773 size_t count, loff_t *ppos)
1774{
1775 struct i40e_pf *pf = filp->private_data;
1776 int bytes_not_copied;
1777 int buf_size = 256;
1778 char *buf;
1779 int len;
1780
1781 /* don't allow partal reads */
1782 if (*ppos != 0)
1783 return 0;
1784 if (count < buf_size)
1785 return -ENOSPC;
1786
1787 buf = kzalloc(buf_size, GFP_KERNEL);
1788 if (!buf)
1789 return -ENOSPC;
1790
1791 len = snprintf(buf, buf_size, "%s: %s\n",
1792 pf->vsi[pf->lan_vsi]->netdev->name,
1793 i40e_dbg_netdev_ops_buf);
1794
1795 bytes_not_copied = copy_to_user(buffer, buf, len);
1796 kfree(buf);
1797
Rasmus Villemoes0286c672015-10-17 22:58:19 +02001798 if (bytes_not_copied)
1799 return -EFAULT;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001800
1801 *ppos = len;
1802 return len;
1803}
1804
1805/**
1806 * i40e_dbg_netdev_ops_write - write into netdev_ops datum
1807 * @filp: the opened file
1808 * @buffer: where to find the user's data
1809 * @count: the length of the user's data
1810 * @ppos: file position offset
1811 **/
1812static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1813 const char __user *buffer,
1814 size_t count, loff_t *ppos)
1815{
1816 struct i40e_pf *pf = filp->private_data;
1817 int bytes_not_copied;
1818 struct i40e_vsi *vsi;
Jesse Brandeburg004173c2013-09-28 07:13:44 +00001819 char *buf_tmp;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001820 int vsi_seid;
1821 int i, cnt;
1822
1823 /* don't allow partial writes */
1824 if (*ppos != 0)
1825 return 0;
1826 if (count >= sizeof(i40e_dbg_netdev_ops_buf))
1827 return -ENOSPC;
1828
1829 memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf));
1830 bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf,
1831 buffer, count);
Rasmus Villemoes0286c672015-10-17 22:58:19 +02001832 if (bytes_not_copied)
1833 return -EFAULT;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001834 i40e_dbg_netdev_ops_buf[count] = '\0';
1835
Jesse Brandeburg004173c2013-09-28 07:13:44 +00001836 buf_tmp = strchr(i40e_dbg_netdev_ops_buf, '\n');
1837 if (buf_tmp) {
1838 *buf_tmp = '\0';
1839 count = buf_tmp - i40e_dbg_netdev_ops_buf + 1;
1840 }
1841
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001842 if (strncmp(i40e_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) {
1843 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1844 if (cnt != 1) {
1845 dev_info(&pf->pdev->dev, "tx_timeout <vsi_seid>\n");
1846 goto netdev_ops_write_done;
1847 }
1848 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1849 if (!vsi) {
1850 dev_info(&pf->pdev->dev,
1851 "tx_timeout: VSI %d not found\n", vsi_seid);
Shannon Nelsonca046572014-03-06 09:00:02 +00001852 } else if (!vsi->netdev) {
1853 dev_info(&pf->pdev->dev, "tx_timeout: no netdev for VSI %d\n",
1854 vsi_seid);
1855 } else if (test_bit(__I40E_DOWN, &vsi->state)) {
1856 dev_info(&pf->pdev->dev, "tx_timeout: VSI %d not UP\n",
1857 vsi_seid);
1858 } else if (rtnl_trylock()) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001859 vsi->netdev->netdev_ops->ndo_tx_timeout(vsi->netdev);
1860 rtnl_unlock();
1861 dev_info(&pf->pdev->dev, "tx_timeout called\n");
1862 } else {
1863 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1864 }
1865 } else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
1866 int mtu;
Jesse Brandeburg6995b362015-08-28 17:55:54 -04001867
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001868 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
1869 &vsi_seid, &mtu);
1870 if (cnt != 2) {
1871 dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
1872 goto netdev_ops_write_done;
1873 }
1874 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1875 if (!vsi) {
1876 dev_info(&pf->pdev->dev,
1877 "change_mtu: VSI %d not found\n", vsi_seid);
Shannon Nelsonca046572014-03-06 09:00:02 +00001878 } else if (!vsi->netdev) {
1879 dev_info(&pf->pdev->dev, "change_mtu: no netdev for VSI %d\n",
1880 vsi_seid);
1881 } else if (rtnl_trylock()) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001882 vsi->netdev->netdev_ops->ndo_change_mtu(vsi->netdev,
1883 mtu);
1884 rtnl_unlock();
1885 dev_info(&pf->pdev->dev, "change_mtu called\n");
1886 } else {
1887 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1888 }
1889
1890 } else if (strncmp(i40e_dbg_netdev_ops_buf, "set_rx_mode", 11) == 0) {
1891 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1892 if (cnt != 1) {
1893 dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
1894 goto netdev_ops_write_done;
1895 }
1896 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1897 if (!vsi) {
1898 dev_info(&pf->pdev->dev,
1899 "set_rx_mode: VSI %d not found\n", vsi_seid);
Shannon Nelsonca046572014-03-06 09:00:02 +00001900 } else if (!vsi->netdev) {
1901 dev_info(&pf->pdev->dev, "set_rx_mode: no netdev for VSI %d\n",
1902 vsi_seid);
1903 } else if (rtnl_trylock()) {
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001904 vsi->netdev->netdev_ops->ndo_set_rx_mode(vsi->netdev);
1905 rtnl_unlock();
1906 dev_info(&pf->pdev->dev, "set_rx_mode called\n");
1907 } else {
1908 dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1909 }
1910
1911 } else if (strncmp(i40e_dbg_netdev_ops_buf, "napi", 4) == 0) {
1912 cnt = sscanf(&i40e_dbg_netdev_ops_buf[4], "%i", &vsi_seid);
1913 if (cnt != 1) {
1914 dev_info(&pf->pdev->dev, "napi <vsi_seid>\n");
1915 goto netdev_ops_write_done;
1916 }
1917 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1918 if (!vsi) {
1919 dev_info(&pf->pdev->dev, "napi: VSI %d not found\n",
1920 vsi_seid);
Shannon Nelsonca046572014-03-06 09:00:02 +00001921 } else if (!vsi->netdev) {
1922 dev_info(&pf->pdev->dev, "napi: no netdev for VSI %d\n",
1923 vsi_seid);
1924 } else {
1925 for (i = 0; i < vsi->num_q_vectors; i++)
1926 napi_schedule(&vsi->q_vectors[i]->napi);
1927 dev_info(&pf->pdev->dev, "napi called\n");
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001928 }
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001929 } else {
1930 dev_info(&pf->pdev->dev, "unknown command '%s'\n",
1931 i40e_dbg_netdev_ops_buf);
1932 dev_info(&pf->pdev->dev, "available commands\n");
1933 dev_info(&pf->pdev->dev, " tx_timeout <vsi_seid>\n");
1934 dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n");
1935 dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n");
1936 dev_info(&pf->pdev->dev, " napi <vsi_seid>\n");
1937 }
1938netdev_ops_write_done:
1939 return count;
1940}
1941
1942static const struct file_operations i40e_dbg_netdev_ops_fops = {
1943 .owner = THIS_MODULE,
1944 .open = simple_open,
1945 .read = i40e_dbg_netdev_ops_read,
1946 .write = i40e_dbg_netdev_ops_write,
1947};
1948
1949/**
Jeff Kirsherb40c82e62015-02-27 09:18:34 +00001950 * i40e_dbg_pf_init - setup the debugfs directory for the PF
1951 * @pf: the PF that is starting up
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001952 **/
1953void i40e_dbg_pf_init(struct i40e_pf *pf)
1954{
Jesse Brandeburg63010022013-09-28 07:13:33 +00001955 struct dentry *pfile;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001956 const char *name = pci_name(pf->pdev);
Jesse Brandeburg63010022013-09-28 07:13:33 +00001957 const struct device *dev = &pf->pdev->dev;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001958
1959 pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root);
Jesse Brandeburg63010022013-09-28 07:13:33 +00001960 if (!pf->i40e_dbg_pf)
1961 return;
1962
1963 pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf,
1964 &i40e_dbg_command_fops);
1965 if (!pfile)
1966 goto create_failed;
1967
Jesse Brandeburg63010022013-09-28 07:13:33 +00001968 pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf,
1969 &i40e_dbg_netdev_ops_fops);
1970 if (!pfile)
1971 goto create_failed;
1972
1973 return;
1974
1975create_failed:
1976 dev_info(dev, "debugfs dir/file for %s failed\n", name);
1977 debugfs_remove_recursive(pf->i40e_dbg_pf);
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001978}
1979
1980/**
Jeff Kirsherb40c82e62015-02-27 09:18:34 +00001981 * i40e_dbg_pf_exit - clear out the PF's debugfs entries
1982 * @pf: the PF that is stopping
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001983 **/
1984void i40e_dbg_pf_exit(struct i40e_pf *pf)
1985{
1986 debugfs_remove_recursive(pf->i40e_dbg_pf);
1987 pf->i40e_dbg_pf = NULL;
Jesse Brandeburg02e9c292013-09-11 08:40:17 +00001988}
1989
1990/**
1991 * i40e_dbg_init - start up debugfs for the driver
1992 **/
1993void i40e_dbg_init(void)
1994{
1995 i40e_dbg_root = debugfs_create_dir(i40e_driver_name, NULL);
1996 if (!i40e_dbg_root)
1997 pr_info("init of debugfs failed\n");
1998}
1999
2000/**
2001 * i40e_dbg_exit - clean out the driver's debugfs entries
2002 **/
2003void i40e_dbg_exit(void)
2004{
2005 debugfs_remove_recursive(i40e_dbg_root);
2006 i40e_dbg_root = NULL;
2007}
2008
2009#endif /* CONFIG_DEBUG_FS */