1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2016 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
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
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
25 ******************************************************************************/
27 #ifdef CONFIG_DEBUG_FS
30 #include <linux/debugfs.h>
34 static struct dentry
*i40e_dbg_root
;
37 * i40e_dbg_find_vsi - searches for the vsi with the given seid
38 * @pf - the PF structure to search for the vsi
39 * @seid - seid of the vsi it is searching for
41 static struct i40e_vsi
*i40e_dbg_find_vsi(struct i40e_pf
*pf
, int seid
)
46 dev_info(&pf
->pdev
->dev
, "%d: bad seid\n", seid
);
48 for (i
= 0; i
< pf
->num_alloc_vsi
; i
++)
49 if (pf
->vsi
[i
] && (pf
->vsi
[i
]->seid
== seid
))
56 * i40e_dbg_find_veb - searches for the veb with the given seid
57 * @pf - the PF structure to search for the veb
58 * @seid - seid of the veb it is searching for
60 static struct i40e_veb
*i40e_dbg_find_veb(struct i40e_pf
*pf
, int seid
)
64 for (i
= 0; i
< I40E_MAX_VEB
; i
++)
65 if (pf
->veb
[i
] && pf
->veb
[i
]->seid
== seid
)
70 /**************************************************************
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 **************************************************************/
77 static char i40e_dbg_command_buf
[256] = "";
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
86 static ssize_t
i40e_dbg_command_read(struct file
*filp
, char __user
*buffer
,
87 size_t count
, loff_t
*ppos
)
89 struct i40e_pf
*pf
= filp
->private_data
;
95 /* don't allow partial reads */
101 buf
= kzalloc(buf_size
, GFP_KERNEL
);
105 len
= snprintf(buf
, buf_size
, "%s: %s\n",
106 pf
->vsi
[pf
->lan_vsi
]->netdev
->name
,
107 i40e_dbg_command_buf
);
109 bytes_not_copied
= copy_to_user(buffer
, buf
, len
);
112 if (bytes_not_copied
)
120 * i40e_dbg_dump_vsi_seid - handles dump vsi seid write into command datum
121 * @pf: the i40e_pf created in command write
122 * @seid: the seid the user put in
124 static void i40e_dbg_dump_vsi_seid(struct i40e_pf
*pf
, int seid
)
126 struct rtnl_link_stats64
*nstat
;
127 struct i40e_mac_filter
*f
;
128 struct i40e_vsi
*vsi
;
131 vsi
= i40e_dbg_find_vsi(pf
, seid
);
133 dev_info(&pf
->pdev
->dev
,
134 "dump %d: seid not found\n", seid
);
137 dev_info(&pf
->pdev
->dev
, "vsi seid %d\n", seid
);
139 struct net_device
*nd
= vsi
->netdev
;
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
);
150 dev_info(&pf
->pdev
->dev
,
151 " vlgrp: & = %p\n", vsi
->active_vlans
);
152 dev_info(&pf
->pdev
->dev
,
153 " state = %li flags = 0x%08lx, netdev_registered = %i, current_netdev_flags = 0x%04x\n",
154 vsi
->state
, vsi
->flags
,
155 vsi
->netdev_registered
, vsi
->current_netdev_flags
);
156 if (vsi
== pf
->vsi
[pf
->lan_vsi
])
157 dev_info(&pf
->pdev
->dev
, " MAC address: %pM SAN MAC: %pM Port MAC: %pM\n",
160 pf
->hw
.mac
.port_addr
);
161 list_for_each_entry(f
, &vsi
->mac_filter_list
, list
) {
162 dev_info(&pf
->pdev
->dev
,
163 " mac_filter_list: %pM vid=%d, is_netdev=%d is_vf=%d counter=%d\n",
164 f
->macaddr
, f
->vlan
, f
->is_netdev
, f
->is_vf
,
167 nstat
= i40e_get_vsi_stats_struct(vsi
);
168 dev_info(&pf
->pdev
->dev
,
169 " net_stats: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
170 (unsigned long int)nstat
->rx_packets
,
171 (unsigned long int)nstat
->rx_bytes
,
172 (unsigned long int)nstat
->rx_errors
,
173 (unsigned long int)nstat
->rx_dropped
);
174 dev_info(&pf
->pdev
->dev
,
175 " net_stats: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
176 (unsigned long int)nstat
->tx_packets
,
177 (unsigned long int)nstat
->tx_bytes
,
178 (unsigned long int)nstat
->tx_errors
,
179 (unsigned long int)nstat
->tx_dropped
);
180 dev_info(&pf
->pdev
->dev
,
181 " net_stats: multicast = %lu, collisions = %lu\n",
182 (unsigned long int)nstat
->multicast
,
183 (unsigned long int)nstat
->collisions
);
184 dev_info(&pf
->pdev
->dev
,
185 " net_stats: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
186 (unsigned long int)nstat
->rx_length_errors
,
187 (unsigned long int)nstat
->rx_over_errors
,
188 (unsigned long int)nstat
->rx_crc_errors
);
189 dev_info(&pf
->pdev
->dev
,
190 " net_stats: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
191 (unsigned long int)nstat
->rx_frame_errors
,
192 (unsigned long int)nstat
->rx_fifo_errors
,
193 (unsigned long int)nstat
->rx_missed_errors
);
194 dev_info(&pf
->pdev
->dev
,
195 " net_stats: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
196 (unsigned long int)nstat
->tx_aborted_errors
,
197 (unsigned long int)nstat
->tx_carrier_errors
,
198 (unsigned long int)nstat
->tx_fifo_errors
);
199 dev_info(&pf
->pdev
->dev
,
200 " net_stats: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
201 (unsigned long int)nstat
->tx_heartbeat_errors
,
202 (unsigned long int)nstat
->tx_window_errors
);
203 dev_info(&pf
->pdev
->dev
,
204 " net_stats: rx_compressed = %lu, tx_compressed = %lu\n",
205 (unsigned long int)nstat
->rx_compressed
,
206 (unsigned long int)nstat
->tx_compressed
);
207 dev_info(&pf
->pdev
->dev
,
208 " net_stats_offsets: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
209 (unsigned long int)vsi
->net_stats_offsets
.rx_packets
,
210 (unsigned long int)vsi
->net_stats_offsets
.rx_bytes
,
211 (unsigned long int)vsi
->net_stats_offsets
.rx_errors
,
212 (unsigned long int)vsi
->net_stats_offsets
.rx_dropped
);
213 dev_info(&pf
->pdev
->dev
,
214 " net_stats_offsets: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
215 (unsigned long int)vsi
->net_stats_offsets
.tx_packets
,
216 (unsigned long int)vsi
->net_stats_offsets
.tx_bytes
,
217 (unsigned long int)vsi
->net_stats_offsets
.tx_errors
,
218 (unsigned long int)vsi
->net_stats_offsets
.tx_dropped
);
219 dev_info(&pf
->pdev
->dev
,
220 " net_stats_offsets: multicast = %lu, collisions = %lu\n",
221 (unsigned long int)vsi
->net_stats_offsets
.multicast
,
222 (unsigned long int)vsi
->net_stats_offsets
.collisions
);
223 dev_info(&pf
->pdev
->dev
,
224 " net_stats_offsets: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
225 (unsigned long int)vsi
->net_stats_offsets
.rx_length_errors
,
226 (unsigned long int)vsi
->net_stats_offsets
.rx_over_errors
,
227 (unsigned long int)vsi
->net_stats_offsets
.rx_crc_errors
);
228 dev_info(&pf
->pdev
->dev
,
229 " net_stats_offsets: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
230 (unsigned long int)vsi
->net_stats_offsets
.rx_frame_errors
,
231 (unsigned long int)vsi
->net_stats_offsets
.rx_fifo_errors
,
232 (unsigned long int)vsi
->net_stats_offsets
.rx_missed_errors
);
233 dev_info(&pf
->pdev
->dev
,
234 " net_stats_offsets: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
235 (unsigned long int)vsi
->net_stats_offsets
.tx_aborted_errors
,
236 (unsigned long int)vsi
->net_stats_offsets
.tx_carrier_errors
,
237 (unsigned long int)vsi
->net_stats_offsets
.tx_fifo_errors
);
238 dev_info(&pf
->pdev
->dev
,
239 " net_stats_offsets: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
240 (unsigned long int)vsi
->net_stats_offsets
.tx_heartbeat_errors
,
241 (unsigned long int)vsi
->net_stats_offsets
.tx_window_errors
);
242 dev_info(&pf
->pdev
->dev
,
243 " net_stats_offsets: rx_compressed = %lu, tx_compressed = %lu\n",
244 (unsigned long int)vsi
->net_stats_offsets
.rx_compressed
,
245 (unsigned long int)vsi
->net_stats_offsets
.tx_compressed
);
246 dev_info(&pf
->pdev
->dev
,
247 " tx_restart = %d, tx_busy = %d, rx_buf_failed = %d, rx_page_failed = %d\n",
248 vsi
->tx_restart
, vsi
->tx_busy
,
249 vsi
->rx_buf_failed
, vsi
->rx_page_failed
);
251 for (i
= 0; i
< vsi
->num_queue_pairs
; i
++) {
252 struct i40e_ring
*rx_ring
= ACCESS_ONCE(vsi
->rx_rings
[i
]);
257 dev_info(&pf
->pdev
->dev
,
258 " rx_rings[%i]: desc = %p\n",
260 dev_info(&pf
->pdev
->dev
,
261 " rx_rings[%i]: dev = %p, netdev = %p, rx_bi = %p\n",
265 dev_info(&pf
->pdev
->dev
,
266 " rx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
268 rx_ring
->queue_index
,
270 dev_info(&pf
->pdev
->dev
,
271 " rx_rings[%i]: rx_buf_len = %d\n",
272 i
, rx_ring
->rx_buf_len
);
273 dev_info(&pf
->pdev
->dev
,
274 " rx_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
276 rx_ring
->next_to_use
,
277 rx_ring
->next_to_clean
,
278 rx_ring
->ring_active
);
279 dev_info(&pf
->pdev
->dev
,
280 " rx_rings[%i]: rx_stats: packets = %lld, bytes = %lld, non_eop_descs = %lld\n",
281 i
, rx_ring
->stats
.packets
,
282 rx_ring
->stats
.bytes
,
283 rx_ring
->rx_stats
.non_eop_descs
);
284 dev_info(&pf
->pdev
->dev
,
285 " rx_rings[%i]: rx_stats: alloc_page_failed = %lld, alloc_buff_failed = %lld\n",
287 rx_ring
->rx_stats
.alloc_page_failed
,
288 rx_ring
->rx_stats
.alloc_buff_failed
);
289 dev_info(&pf
->pdev
->dev
,
290 " rx_rings[%i]: rx_stats: realloc_count = %lld, page_reuse_count = %lld\n",
292 rx_ring
->rx_stats
.realloc_count
,
293 rx_ring
->rx_stats
.page_reuse_count
);
294 dev_info(&pf
->pdev
->dev
,
295 " rx_rings[%i]: size = %i, dma = 0x%08lx\n",
297 (unsigned long int)rx_ring
->dma
);
298 dev_info(&pf
->pdev
->dev
,
299 " rx_rings[%i]: vsi = %p, q_vector = %p\n",
302 dev_info(&pf
->pdev
->dev
,
303 " rx_rings[%i]: rx_itr_setting = %d (%s)\n",
304 i
, rx_ring
->rx_itr_setting
,
305 ITR_IS_DYNAMIC(rx_ring
->rx_itr_setting
) ? "dynamic" : "fixed");
307 for (i
= 0; i
< vsi
->num_queue_pairs
; i
++) {
308 struct i40e_ring
*tx_ring
= ACCESS_ONCE(vsi
->tx_rings
[i
]);
313 dev_info(&pf
->pdev
->dev
,
314 " tx_rings[%i]: desc = %p\n",
316 dev_info(&pf
->pdev
->dev
,
317 " tx_rings[%i]: dev = %p, netdev = %p, tx_bi = %p\n",
321 dev_info(&pf
->pdev
->dev
,
322 " tx_rings[%i]: state = %li, queue_index = %d, reg_idx = %d\n",
324 tx_ring
->queue_index
,
326 dev_info(&pf
->pdev
->dev
,
327 " tx_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
329 tx_ring
->next_to_use
,
330 tx_ring
->next_to_clean
,
331 tx_ring
->ring_active
);
332 dev_info(&pf
->pdev
->dev
,
333 " tx_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
334 i
, tx_ring
->stats
.packets
,
335 tx_ring
->stats
.bytes
,
336 tx_ring
->tx_stats
.restart_queue
);
337 dev_info(&pf
->pdev
->dev
,
338 " tx_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",
340 tx_ring
->tx_stats
.tx_busy
,
341 tx_ring
->tx_stats
.tx_done_old
);
342 dev_info(&pf
->pdev
->dev
,
343 " tx_rings[%i]: size = %i, dma = 0x%08lx\n",
345 (unsigned long int)tx_ring
->dma
);
346 dev_info(&pf
->pdev
->dev
,
347 " tx_rings[%i]: vsi = %p, q_vector = %p\n",
350 dev_info(&pf
->pdev
->dev
,
351 " tx_rings[%i]: DCB tc = %d\n",
353 dev_info(&pf
->pdev
->dev
,
354 " tx_rings[%i]: tx_itr_setting = %d (%s)\n",
355 i
, tx_ring
->tx_itr_setting
,
356 ITR_IS_DYNAMIC(tx_ring
->tx_itr_setting
) ? "dynamic" : "fixed");
359 dev_info(&pf
->pdev
->dev
,
360 " work_limit = %d\n",
362 dev_info(&pf
->pdev
->dev
,
363 " max_frame = %d, rx_buf_len = %d dtype = %d\n",
364 vsi
->max_frame
, vsi
->rx_buf_len
, 0);
365 dev_info(&pf
->pdev
->dev
,
366 " num_q_vectors = %i, base_vector = %i\n",
367 vsi
->num_q_vectors
, vsi
->base_vector
);
368 dev_info(&pf
->pdev
->dev
,
369 " seid = %d, id = %d, uplink_seid = %d\n",
370 vsi
->seid
, vsi
->id
, vsi
->uplink_seid
);
371 dev_info(&pf
->pdev
->dev
,
372 " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
373 vsi
->base_queue
, vsi
->num_queue_pairs
, vsi
->num_desc
);
374 dev_info(&pf
->pdev
->dev
, " type = %i\n", vsi
->type
);
375 dev_info(&pf
->pdev
->dev
,
376 " info: valid_sections = 0x%04x, switch_id = 0x%04x\n",
377 vsi
->info
.valid_sections
, vsi
->info
.switch_id
);
378 dev_info(&pf
->pdev
->dev
,
379 " info: sw_reserved[] = 0x%02x 0x%02x\n",
380 vsi
->info
.sw_reserved
[0], vsi
->info
.sw_reserved
[1]);
381 dev_info(&pf
->pdev
->dev
,
382 " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n",
383 vsi
->info
.sec_flags
, vsi
->info
.sec_reserved
);
384 dev_info(&pf
->pdev
->dev
,
385 " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n",
386 vsi
->info
.pvid
, vsi
->info
.fcoe_pvid
,
387 vsi
->info
.port_vlan_flags
);
388 dev_info(&pf
->pdev
->dev
,
389 " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n",
390 vsi
->info
.pvlan_reserved
[0], vsi
->info
.pvlan_reserved
[1],
391 vsi
->info
.pvlan_reserved
[2]);
392 dev_info(&pf
->pdev
->dev
,
393 " info: ingress_table = 0x%08x, egress_table = 0x%08x\n",
394 vsi
->info
.ingress_table
, vsi
->info
.egress_table
);
395 dev_info(&pf
->pdev
->dev
,
396 " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n",
397 vsi
->info
.cas_pv_tag
, vsi
->info
.cas_pv_flags
,
398 vsi
->info
.cas_pv_reserved
);
399 dev_info(&pf
->pdev
->dev
,
400 " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
401 vsi
->info
.queue_mapping
[0], vsi
->info
.queue_mapping
[1],
402 vsi
->info
.queue_mapping
[2], vsi
->info
.queue_mapping
[3],
403 vsi
->info
.queue_mapping
[4], vsi
->info
.queue_mapping
[5],
404 vsi
->info
.queue_mapping
[6], vsi
->info
.queue_mapping
[7]);
405 dev_info(&pf
->pdev
->dev
,
406 " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
407 vsi
->info
.queue_mapping
[8], vsi
->info
.queue_mapping
[9],
408 vsi
->info
.queue_mapping
[10], vsi
->info
.queue_mapping
[11],
409 vsi
->info
.queue_mapping
[12], vsi
->info
.queue_mapping
[13],
410 vsi
->info
.queue_mapping
[14], vsi
->info
.queue_mapping
[15]);
411 dev_info(&pf
->pdev
->dev
,
412 " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
413 vsi
->info
.tc_mapping
[0], vsi
->info
.tc_mapping
[1],
414 vsi
->info
.tc_mapping
[2], vsi
->info
.tc_mapping
[3],
415 vsi
->info
.tc_mapping
[4], vsi
->info
.tc_mapping
[5],
416 vsi
->info
.tc_mapping
[6], vsi
->info
.tc_mapping
[7]);
417 dev_info(&pf
->pdev
->dev
,
418 " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n",
419 vsi
->info
.queueing_opt_flags
,
420 vsi
->info
.queueing_opt_reserved
[0],
421 vsi
->info
.queueing_opt_reserved
[1],
422 vsi
->info
.queueing_opt_reserved
[2]);
423 dev_info(&pf
->pdev
->dev
,
424 " info: up_enable_bits = 0x%02x\n",
425 vsi
->info
.up_enable_bits
);
426 dev_info(&pf
->pdev
->dev
,
427 " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n",
428 vsi
->info
.sched_reserved
, vsi
->info
.outer_up_table
);
429 dev_info(&pf
->pdev
->dev
,
430 " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n",
431 vsi
->info
.cmd_reserved
[0], vsi
->info
.cmd_reserved
[1],
432 vsi
->info
.cmd_reserved
[2], vsi
->info
.cmd_reserved
[3],
433 vsi
->info
.cmd_reserved
[4], vsi
->info
.cmd_reserved
[5],
434 vsi
->info
.cmd_reserved
[6], vsi
->info
.cmd_reserved
[7]);
435 dev_info(&pf
->pdev
->dev
,
436 " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
437 vsi
->info
.qs_handle
[0], vsi
->info
.qs_handle
[1],
438 vsi
->info
.qs_handle
[2], vsi
->info
.qs_handle
[3],
439 vsi
->info
.qs_handle
[4], vsi
->info
.qs_handle
[5],
440 vsi
->info
.qs_handle
[6], vsi
->info
.qs_handle
[7]);
441 dev_info(&pf
->pdev
->dev
,
442 " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n",
443 vsi
->info
.stat_counter_idx
, vsi
->info
.sched_id
);
444 dev_info(&pf
->pdev
->dev
,
445 " 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",
446 vsi
->info
.resp_reserved
[0], vsi
->info
.resp_reserved
[1],
447 vsi
->info
.resp_reserved
[2], vsi
->info
.resp_reserved
[3],
448 vsi
->info
.resp_reserved
[4], vsi
->info
.resp_reserved
[5],
449 vsi
->info
.resp_reserved
[6], vsi
->info
.resp_reserved
[7],
450 vsi
->info
.resp_reserved
[8], vsi
->info
.resp_reserved
[9],
451 vsi
->info
.resp_reserved
[10], vsi
->info
.resp_reserved
[11]);
453 dev_info(&pf
->pdev
->dev
, " PF = %p\n", vsi
->back
);
454 dev_info(&pf
->pdev
->dev
, " idx = %d\n", vsi
->idx
);
455 dev_info(&pf
->pdev
->dev
,
456 " tc_config: numtc = %d, enabled_tc = 0x%x\n",
457 vsi
->tc_config
.numtc
, vsi
->tc_config
.enabled_tc
);
458 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
459 dev_info(&pf
->pdev
->dev
,
460 " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n",
461 i
, vsi
->tc_config
.tc_info
[i
].qoffset
,
462 vsi
->tc_config
.tc_info
[i
].qcount
,
463 vsi
->tc_config
.tc_info
[i
].netdev_tc
);
465 dev_info(&pf
->pdev
->dev
,
466 " bw: bw_limit = %d, bw_max_quanta = %d\n",
467 vsi
->bw_limit
, vsi
->bw_max_quanta
);
468 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
469 dev_info(&pf
->pdev
->dev
,
470 " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n",
471 i
, vsi
->bw_ets_share_credits
[i
],
472 vsi
->bw_ets_limit_credits
[i
],
473 vsi
->bw_ets_max_quanta
[i
]);
476 if (vsi
->type
== I40E_VSI_FCOE
) {
477 dev_info(&pf
->pdev
->dev
,
478 " fcoe_stats: rx_packets = %llu, rx_dwords = %llu, rx_dropped = %llu\n",
479 vsi
->fcoe_stats
.rx_fcoe_packets
,
480 vsi
->fcoe_stats
.rx_fcoe_dwords
,
481 vsi
->fcoe_stats
.rx_fcoe_dropped
);
482 dev_info(&pf
->pdev
->dev
,
483 " fcoe_stats: tx_packets = %llu, tx_dwords = %llu\n",
484 vsi
->fcoe_stats
.tx_fcoe_packets
,
485 vsi
->fcoe_stats
.tx_fcoe_dwords
);
486 dev_info(&pf
->pdev
->dev
,
487 " fcoe_stats: bad_crc = %llu, last_error = %llu\n",
488 vsi
->fcoe_stats
.fcoe_bad_fccrc
,
489 vsi
->fcoe_stats
.fcoe_last_error
);
490 dev_info(&pf
->pdev
->dev
, " fcoe_stats: ddp_count = %llu\n",
491 vsi
->fcoe_stats
.fcoe_ddp_count
);
497 * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum
498 * @pf: the i40e_pf created in command write
500 static void i40e_dbg_dump_aq_desc(struct i40e_pf
*pf
)
502 struct i40e_adminq_ring
*ring
;
503 struct i40e_hw
*hw
= &pf
->hw
;
507 snprintf(hdr
, sizeof(hdr
), "%s %s: ",
508 dev_driver_string(&pf
->pdev
->dev
),
509 dev_name(&pf
->pdev
->dev
));
511 /* first the send (command) ring, then the receive (event) ring */
512 dev_info(&pf
->pdev
->dev
, "AdminQ Tx Ring\n");
513 ring
= &(hw
->aq
.asq
);
514 for (i
= 0; i
< ring
->count
; i
++) {
515 struct i40e_aq_desc
*d
= I40E_ADMINQ_DESC(*ring
, i
);
517 dev_info(&pf
->pdev
->dev
,
518 " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
519 i
, d
->flags
, d
->opcode
, d
->datalen
, d
->retval
,
520 d
->cookie_high
, d
->cookie_low
);
521 print_hex_dump(KERN_INFO
, hdr
, DUMP_PREFIX_NONE
,
522 16, 1, d
->params
.raw
, 16, 0);
525 dev_info(&pf
->pdev
->dev
, "AdminQ Rx Ring\n");
526 ring
= &(hw
->aq
.arq
);
527 for (i
= 0; i
< ring
->count
; i
++) {
528 struct i40e_aq_desc
*d
= I40E_ADMINQ_DESC(*ring
, i
);
530 dev_info(&pf
->pdev
->dev
,
531 " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
532 i
, d
->flags
, d
->opcode
, d
->datalen
, d
->retval
,
533 d
->cookie_high
, d
->cookie_low
);
534 print_hex_dump(KERN_INFO
, hdr
, DUMP_PREFIX_NONE
,
535 16, 1, d
->params
.raw
, 16, 0);
540 * i40e_dbg_dump_desc - handles dump desc write into command datum
541 * @cnt: number of arguments that the user supplied
542 * @vsi_seid: vsi id entered by user
543 * @ring_id: ring id entered by user
544 * @desc_n: descriptor number entered by user
545 * @pf: the i40e_pf created in command write
546 * @is_rx_ring: true if rx, false if tx
548 static void i40e_dbg_dump_desc(int cnt
, int vsi_seid
, int ring_id
, int desc_n
,
549 struct i40e_pf
*pf
, bool is_rx_ring
)
551 struct i40e_tx_desc
*txd
;
552 union i40e_rx_desc
*rxd
;
553 struct i40e_ring
*ring
;
554 struct i40e_vsi
*vsi
;
557 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
559 dev_info(&pf
->pdev
->dev
, "vsi %d not found\n", vsi_seid
);
562 if (ring_id
>= vsi
->num_queue_pairs
|| ring_id
< 0) {
563 dev_info(&pf
->pdev
->dev
, "ring %d not found\n", ring_id
);
566 if (!vsi
->tx_rings
|| !vsi
->tx_rings
[0]->desc
) {
567 dev_info(&pf
->pdev
->dev
,
568 "descriptor rings have not been allocated for vsi %d\n",
573 ring
= kmemdup(is_rx_ring
574 ? vsi
->rx_rings
[ring_id
] : vsi
->tx_rings
[ring_id
],
575 sizeof(*ring
), GFP_KERNEL
);
580 dev_info(&pf
->pdev
->dev
, "vsi = %02i %s ring = %02i\n",
581 vsi_seid
, is_rx_ring
? "rx" : "tx", ring_id
);
582 for (i
= 0; i
< ring
->count
; i
++) {
584 txd
= I40E_TX_DESC(ring
, i
);
585 dev_info(&pf
->pdev
->dev
,
586 " d[%03x] = 0x%016llx 0x%016llx\n",
588 txd
->cmd_type_offset_bsz
);
590 rxd
= I40E_RX_DESC(ring
, i
);
591 dev_info(&pf
->pdev
->dev
,
592 " d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
593 i
, rxd
->read
.pkt_addr
,
595 rxd
->read
.rsvd1
, rxd
->read
.rsvd2
);
598 } else if (cnt
== 3) {
599 if (desc_n
>= ring
->count
|| desc_n
< 0) {
600 dev_info(&pf
->pdev
->dev
,
601 "descriptor %d not found\n", desc_n
);
605 txd
= I40E_TX_DESC(ring
, desc_n
);
606 dev_info(&pf
->pdev
->dev
,
607 "vsi = %02i tx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n",
608 vsi_seid
, ring_id
, desc_n
,
609 txd
->buffer_addr
, txd
->cmd_type_offset_bsz
);
611 rxd
= I40E_RX_DESC(ring
, desc_n
);
612 dev_info(&pf
->pdev
->dev
,
613 "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
614 vsi_seid
, ring_id
, desc_n
,
615 rxd
->read
.pkt_addr
, rxd
->read
.hdr_addr
,
616 rxd
->read
.rsvd1
, rxd
->read
.rsvd2
);
619 dev_info(&pf
->pdev
->dev
, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
627 * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum
628 * @pf: the i40e_pf created in command write
630 static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf
*pf
)
634 for (i
= 0; i
< pf
->num_alloc_vsi
; i
++)
636 dev_info(&pf
->pdev
->dev
, "dump vsi[%d]: %d\n",
637 i
, pf
->vsi
[i
]->seid
);
641 * i40e_dbg_dump_stats - handles dump stats write into command datum
642 * @pf: the i40e_pf created in command write
643 * @estats: the eth stats structure to be dumped
645 static void i40e_dbg_dump_eth_stats(struct i40e_pf
*pf
,
646 struct i40e_eth_stats
*estats
)
648 dev_info(&pf
->pdev
->dev
, " ethstats:\n");
649 dev_info(&pf
->pdev
->dev
,
650 " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n",
651 estats
->rx_bytes
, estats
->rx_unicast
, estats
->rx_multicast
);
652 dev_info(&pf
->pdev
->dev
,
653 " rx_broadcast = \t%lld \trx_discards = \t\t%lld\n",
654 estats
->rx_broadcast
, estats
->rx_discards
);
655 dev_info(&pf
->pdev
->dev
,
656 " rx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n",
657 estats
->rx_unknown_protocol
, estats
->tx_bytes
);
658 dev_info(&pf
->pdev
->dev
,
659 " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n",
660 estats
->tx_unicast
, estats
->tx_multicast
, estats
->tx_broadcast
);
661 dev_info(&pf
->pdev
->dev
,
662 " tx_discards = \t%lld \ttx_errors = \t\t%lld\n",
663 estats
->tx_discards
, estats
->tx_errors
);
667 * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb
668 * @pf: the i40e_pf created in command write
669 * @seid: the seid the user put in
671 static void i40e_dbg_dump_veb_seid(struct i40e_pf
*pf
, int seid
)
673 struct i40e_veb
*veb
;
675 veb
= i40e_dbg_find_veb(pf
, seid
);
677 dev_info(&pf
->pdev
->dev
, "can't find veb %d\n", seid
);
680 dev_info(&pf
->pdev
->dev
,
681 "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d mode=%s\n",
682 veb
->idx
, veb
->veb_idx
, veb
->stats_idx
, veb
->seid
,
684 veb
->bridge_mode
== BRIDGE_MODE_VEPA
? "VEPA" : "VEB");
685 i40e_dbg_dump_eth_stats(pf
, &veb
->stats
);
689 * i40e_dbg_dump_veb_all - dumps all known veb's stats
690 * @pf: the i40e_pf created in command write
692 static void i40e_dbg_dump_veb_all(struct i40e_pf
*pf
)
694 struct i40e_veb
*veb
;
697 for (i
= 0; i
< I40E_MAX_VEB
; i
++) {
700 i40e_dbg_dump_veb_seid(pf
, veb
->seid
);
704 #define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
706 * i40e_dbg_command_write - write into command datum
707 * @filp: the opened file
708 * @buffer: where to find the user's data
709 * @count: the length of the user's data
710 * @ppos: file position offset
712 static ssize_t
i40e_dbg_command_write(struct file
*filp
,
713 const char __user
*buffer
,
714 size_t count
, loff_t
*ppos
)
716 struct i40e_pf
*pf
= filp
->private_data
;
717 char *cmd_buf
, *cmd_buf_tmp
;
718 int bytes_not_copied
;
719 struct i40e_vsi
*vsi
;
724 /* don't allow partial writes */
728 cmd_buf
= kzalloc(count
+ 1, GFP_KERNEL
);
731 bytes_not_copied
= copy_from_user(cmd_buf
, buffer
, count
);
732 if (bytes_not_copied
) {
736 cmd_buf
[count
] = '\0';
738 cmd_buf_tmp
= strchr(cmd_buf
, '\n');
741 count
= cmd_buf_tmp
- cmd_buf
+ 1;
744 if (strncmp(cmd_buf
, "add vsi", 7) == 0) {
746 cnt
= sscanf(&cmd_buf
[7], "%i", &vsi_seid
);
748 /* default to PF VSI */
749 vsi_seid
= pf
->vsi
[pf
->lan_vsi
]->seid
;
750 } else if (vsi_seid
< 0) {
751 dev_info(&pf
->pdev
->dev
, "add VSI %d: bad vsi seid\n",
753 goto command_write_done
;
756 /* By default we are in VEPA mode, if this is the first VF/VMDq
757 * VSI to be added switch to VEB mode.
759 if (!(pf
->flags
& I40E_FLAG_VEB_MODE_ENABLED
)) {
760 pf
->flags
|= I40E_FLAG_VEB_MODE_ENABLED
;
761 i40e_do_reset_safe(pf
,
762 BIT_ULL(__I40E_PF_RESET_REQUESTED
));
765 vsi
= i40e_vsi_setup(pf
, I40E_VSI_VMDQ2
, vsi_seid
, 0);
767 dev_info(&pf
->pdev
->dev
, "added VSI %d to relay %d\n",
768 vsi
->seid
, vsi
->uplink_seid
);
770 dev_info(&pf
->pdev
->dev
, "'%s' failed\n", cmd_buf
);
772 } else if (strncmp(cmd_buf
, "del vsi", 7) == 0) {
773 cnt
= sscanf(&cmd_buf
[7], "%i", &vsi_seid
);
775 dev_info(&pf
->pdev
->dev
,
776 "del vsi: bad command string, cnt=%d\n",
778 goto command_write_done
;
780 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
782 dev_info(&pf
->pdev
->dev
, "del VSI %d: seid not found\n",
784 goto command_write_done
;
787 dev_info(&pf
->pdev
->dev
, "deleting VSI %d\n", vsi_seid
);
788 i40e_vsi_release(vsi
);
790 } else if (strncmp(cmd_buf
, "add relay", 9) == 0) {
791 struct i40e_veb
*veb
;
794 cnt
= sscanf(&cmd_buf
[9], "%i %i", &uplink_seid
, &vsi_seid
);
796 dev_info(&pf
->pdev
->dev
,
797 "add relay: bad command string, cnt=%d\n",
799 goto command_write_done
;
800 } else if (uplink_seid
< 0) {
801 dev_info(&pf
->pdev
->dev
,
802 "add relay %d: bad uplink seid\n",
804 goto command_write_done
;
807 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
809 dev_info(&pf
->pdev
->dev
,
810 "add relay: VSI %d not found\n", vsi_seid
);
811 goto command_write_done
;
814 for (i
= 0; i
< I40E_MAX_VEB
; i
++)
815 if (pf
->veb
[i
] && pf
->veb
[i
]->seid
== uplink_seid
)
817 if (i
>= I40E_MAX_VEB
&& uplink_seid
!= 0 &&
818 uplink_seid
!= pf
->mac_seid
) {
819 dev_info(&pf
->pdev
->dev
,
820 "add relay: relay uplink %d not found\n",
822 goto command_write_done
;
825 veb
= i40e_veb_setup(pf
, 0, uplink_seid
, vsi_seid
,
826 vsi
->tc_config
.enabled_tc
);
828 dev_info(&pf
->pdev
->dev
, "added relay %d\n", veb
->seid
);
830 dev_info(&pf
->pdev
->dev
, "add relay failed\n");
832 } else if (strncmp(cmd_buf
, "del relay", 9) == 0) {
834 cnt
= sscanf(&cmd_buf
[9], "%i", &veb_seid
);
836 dev_info(&pf
->pdev
->dev
,
837 "del relay: bad command string, cnt=%d\n",
839 goto command_write_done
;
840 } else if (veb_seid
< 0) {
841 dev_info(&pf
->pdev
->dev
,
842 "del relay %d: bad relay seid\n", veb_seid
);
843 goto command_write_done
;
847 for (i
= 0; i
< I40E_MAX_VEB
; i
++)
848 if (pf
->veb
[i
] && pf
->veb
[i
]->seid
== veb_seid
)
850 if (i
>= I40E_MAX_VEB
) {
851 dev_info(&pf
->pdev
->dev
,
852 "del relay: relay %d not found\n", veb_seid
);
853 goto command_write_done
;
856 dev_info(&pf
->pdev
->dev
, "deleting relay %d\n", veb_seid
);
857 i40e_veb_release(pf
->veb
[i
]);
859 } else if (strncmp(cmd_buf
, "add macaddr", 11) == 0) {
860 struct i40e_mac_filter
*f
;
865 cnt
= sscanf(&cmd_buf
[11],
866 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
868 &ma
[0], &ma
[1], &ma
[2], &ma
[3], &ma
[4], &ma
[5],
872 } else if (cnt
!= 8) {
873 dev_info(&pf
->pdev
->dev
,
874 "add macaddr: bad command string, cnt=%d\n",
876 goto command_write_done
;
879 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
881 dev_info(&pf
->pdev
->dev
,
882 "add macaddr: VSI %d not found\n", vsi_seid
);
883 goto command_write_done
;
886 spin_lock_bh(&vsi
->mac_filter_list_lock
);
887 f
= i40e_add_filter(vsi
, ma
, vlan
, false, false);
888 spin_unlock_bh(&vsi
->mac_filter_list_lock
);
889 ret
= i40e_sync_vsi_filters(vsi
);
891 dev_info(&pf
->pdev
->dev
,
892 "add macaddr: %pM vlan=%d added to VSI %d\n",
895 dev_info(&pf
->pdev
->dev
,
896 "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
897 ma
, vlan
, vsi_seid
, f
, ret
);
899 } else if (strncmp(cmd_buf
, "del macaddr", 11) == 0) {
904 cnt
= sscanf(&cmd_buf
[11],
905 "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
907 &ma
[0], &ma
[1], &ma
[2], &ma
[3], &ma
[4], &ma
[5],
911 } else if (cnt
!= 8) {
912 dev_info(&pf
->pdev
->dev
,
913 "del macaddr: bad command string, cnt=%d\n",
915 goto command_write_done
;
918 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
920 dev_info(&pf
->pdev
->dev
,
921 "del macaddr: VSI %d not found\n", vsi_seid
);
922 goto command_write_done
;
925 spin_lock_bh(&vsi
->mac_filter_list_lock
);
926 i40e_del_filter(vsi
, ma
, vlan
, false, false);
927 spin_unlock_bh(&vsi
->mac_filter_list_lock
);
928 ret
= i40e_sync_vsi_filters(vsi
);
930 dev_info(&pf
->pdev
->dev
,
931 "del macaddr: %pM vlan=%d removed from VSI %d\n",
934 dev_info(&pf
->pdev
->dev
,
935 "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
936 ma
, vlan
, vsi_seid
, ret
);
938 } else if (strncmp(cmd_buf
, "add pvid", 8) == 0) {
943 cnt
= sscanf(&cmd_buf
[8], "%i %u", &vsi_seid
, &v
);
945 dev_info(&pf
->pdev
->dev
,
946 "add pvid: bad command string, cnt=%d\n", cnt
);
947 goto command_write_done
;
950 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
952 dev_info(&pf
->pdev
->dev
, "add pvid: VSI %d not found\n",
954 goto command_write_done
;
958 ret
= i40e_vsi_add_pvid(vsi
, vid
);
960 dev_info(&pf
->pdev
->dev
,
961 "add pvid: %d added to VSI %d\n",
964 dev_info(&pf
->pdev
->dev
,
965 "add pvid: %d to VSI %d failed, ret=%d\n",
968 } else if (strncmp(cmd_buf
, "del pvid", 8) == 0) {
970 cnt
= sscanf(&cmd_buf
[8], "%i", &vsi_seid
);
972 dev_info(&pf
->pdev
->dev
,
973 "del pvid: bad command string, cnt=%d\n",
975 goto command_write_done
;
978 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
980 dev_info(&pf
->pdev
->dev
,
981 "del pvid: VSI %d not found\n", vsi_seid
);
982 goto command_write_done
;
985 i40e_vsi_remove_pvid(vsi
);
986 dev_info(&pf
->pdev
->dev
,
987 "del pvid: removed from VSI %d\n", vsi_seid
);
989 } else if (strncmp(cmd_buf
, "dump", 4) == 0) {
990 if (strncmp(&cmd_buf
[5], "switch", 6) == 0) {
991 i40e_fetch_switch_configuration(pf
, true);
992 } else if (strncmp(&cmd_buf
[5], "vsi", 3) == 0) {
993 cnt
= sscanf(&cmd_buf
[8], "%i", &vsi_seid
);
995 i40e_dbg_dump_vsi_seid(pf
, vsi_seid
);
997 i40e_dbg_dump_vsi_no_seid(pf
);
998 } else if (strncmp(&cmd_buf
[5], "veb", 3) == 0) {
999 cnt
= sscanf(&cmd_buf
[8], "%i", &vsi_seid
);
1001 i40e_dbg_dump_veb_seid(pf
, vsi_seid
);
1003 i40e_dbg_dump_veb_all(pf
);
1004 } else if (strncmp(&cmd_buf
[5], "desc", 4) == 0) {
1005 int ring_id
, desc_n
;
1006 if (strncmp(&cmd_buf
[10], "rx", 2) == 0) {
1007 cnt
= sscanf(&cmd_buf
[12], "%i %i %i",
1008 &vsi_seid
, &ring_id
, &desc_n
);
1009 i40e_dbg_dump_desc(cnt
, vsi_seid
, ring_id
,
1011 } else if (strncmp(&cmd_buf
[10], "tx", 2)
1013 cnt
= sscanf(&cmd_buf
[12], "%i %i %i",
1014 &vsi_seid
, &ring_id
, &desc_n
);
1015 i40e_dbg_dump_desc(cnt
, vsi_seid
, ring_id
,
1017 } else if (strncmp(&cmd_buf
[10], "aq", 2) == 0) {
1018 i40e_dbg_dump_aq_desc(pf
);
1020 dev_info(&pf
->pdev
->dev
,
1021 "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1022 dev_info(&pf
->pdev
->dev
,
1023 "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1024 dev_info(&pf
->pdev
->dev
, "dump desc aq\n");
1026 } else if (strncmp(&cmd_buf
[5], "reset stats", 11) == 0) {
1027 dev_info(&pf
->pdev
->dev
,
1028 "core reset count: %d\n", pf
->corer_count
);
1029 dev_info(&pf
->pdev
->dev
,
1030 "global reset count: %d\n", pf
->globr_count
);
1031 dev_info(&pf
->pdev
->dev
,
1032 "emp reset count: %d\n", pf
->empr_count
);
1033 dev_info(&pf
->pdev
->dev
,
1034 "pf reset count: %d\n", pf
->pfr_count
);
1035 dev_info(&pf
->pdev
->dev
,
1036 "pf tx sluggish count: %d\n",
1037 pf
->tx_sluggish_count
);
1038 } else if (strncmp(&cmd_buf
[5], "port", 4) == 0) {
1039 struct i40e_aqc_query_port_ets_config_resp
*bw_data
;
1040 struct i40e_dcbx_config
*cfg
=
1041 &pf
->hw
.local_dcbx_config
;
1042 struct i40e_dcbx_config
*r_cfg
=
1043 &pf
->hw
.remote_dcbx_config
;
1046 bw_data
= kzalloc(sizeof(
1047 struct i40e_aqc_query_port_ets_config_resp
),
1051 goto command_write_done
;
1054 ret
= i40e_aq_query_port_ets_config(&pf
->hw
,
1058 dev_info(&pf
->pdev
->dev
,
1059 "Query Port ETS Config AQ command failed =0x%x\n",
1060 pf
->hw
.aq
.asq_last_status
);
1063 goto command_write_done
;
1065 dev_info(&pf
->pdev
->dev
,
1066 "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
1067 bw_data
->tc_valid_bits
,
1068 bw_data
->tc_strict_priority_bits
,
1069 le16_to_cpu(bw_data
->tc_bw_max
[0]),
1070 le16_to_cpu(bw_data
->tc_bw_max
[1]));
1071 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1072 dev_info(&pf
->pdev
->dev
, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
1073 bw_data
->tc_bw_share_credits
[i
],
1074 le16_to_cpu(bw_data
->tc_bw_limits
[i
]));
1080 dev_info(&pf
->pdev
->dev
,
1081 "port dcbx_mode=%d\n", cfg
->dcbx_mode
);
1082 dev_info(&pf
->pdev
->dev
,
1083 "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1084 cfg
->etscfg
.willing
, cfg
->etscfg
.cbs
,
1085 cfg
->etscfg
.maxtcs
);
1086 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1087 dev_info(&pf
->pdev
->dev
, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1088 i
, cfg
->etscfg
.prioritytable
[i
],
1089 cfg
->etscfg
.tcbwtable
[i
],
1090 cfg
->etscfg
.tsatable
[i
]);
1092 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1093 dev_info(&pf
->pdev
->dev
, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1094 i
, cfg
->etsrec
.prioritytable
[i
],
1095 cfg
->etsrec
.tcbwtable
[i
],
1096 cfg
->etsrec
.tsatable
[i
]);
1098 dev_info(&pf
->pdev
->dev
,
1099 "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1100 cfg
->pfc
.willing
, cfg
->pfc
.mbc
,
1101 cfg
->pfc
.pfccap
, cfg
->pfc
.pfcenable
);
1102 dev_info(&pf
->pdev
->dev
,
1103 "port app_table: num_apps=%d\n", cfg
->numapps
);
1104 for (i
= 0; i
< cfg
->numapps
; i
++) {
1105 dev_info(&pf
->pdev
->dev
, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1106 i
, cfg
->app
[i
].priority
,
1107 cfg
->app
[i
].selector
,
1108 cfg
->app
[i
].protocolid
);
1110 /* Peer TLV DCBX data */
1111 dev_info(&pf
->pdev
->dev
,
1112 "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
1113 r_cfg
->etscfg
.willing
,
1114 r_cfg
->etscfg
.cbs
, r_cfg
->etscfg
.maxtcs
);
1115 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1116 dev_info(&pf
->pdev
->dev
, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1117 i
, r_cfg
->etscfg
.prioritytable
[i
],
1118 r_cfg
->etscfg
.tcbwtable
[i
],
1119 r_cfg
->etscfg
.tsatable
[i
]);
1121 for (i
= 0; i
< I40E_MAX_TRAFFIC_CLASS
; i
++) {
1122 dev_info(&pf
->pdev
->dev
, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
1123 i
, r_cfg
->etsrec
.prioritytable
[i
],
1124 r_cfg
->etsrec
.tcbwtable
[i
],
1125 r_cfg
->etsrec
.tsatable
[i
]);
1127 dev_info(&pf
->pdev
->dev
,
1128 "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
1132 r_cfg
->pfc
.pfcenable
);
1133 dev_info(&pf
->pdev
->dev
,
1134 "remote port app_table: num_apps=%d\n",
1136 for (i
= 0; i
< r_cfg
->numapps
; i
++) {
1137 dev_info(&pf
->pdev
->dev
, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
1138 i
, r_cfg
->app
[i
].priority
,
1139 r_cfg
->app
[i
].selector
,
1140 r_cfg
->app
[i
].protocolid
);
1142 } else if (strncmp(&cmd_buf
[5], "debug fwdata", 12) == 0) {
1143 int cluster_id
, table_id
;
1145 u16 buff_len
= 4096;
1151 cnt
= sscanf(&cmd_buf
[18], "%i %i %i",
1152 &cluster_id
, &table_id
, &index
);
1154 dev_info(&pf
->pdev
->dev
,
1155 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1156 goto command_write_done
;
1159 dev_info(&pf
->pdev
->dev
,
1160 "AQ debug dump fwdata params %x %x %x %x\n",
1161 cluster_id
, table_id
, index
, buff_len
);
1162 buff
= kzalloc(buff_len
, GFP_KERNEL
);
1164 goto command_write_done
;
1166 ret
= i40e_aq_debug_dump(&pf
->hw
, cluster_id
, table_id
,
1167 index
, buff_len
, buff
, &rlen
,
1168 &next_table
, &next_index
,
1171 dev_info(&pf
->pdev
->dev
,
1172 "debug dump fwdata AQ Failed %d 0x%x\n",
1173 ret
, pf
->hw
.aq
.asq_last_status
);
1176 goto command_write_done
;
1178 dev_info(&pf
->pdev
->dev
,
1179 "AQ debug dump fwdata rlen=0x%x next_table=0x%x next_index=0x%x\n",
1180 rlen
, next_table
, next_index
);
1181 print_hex_dump(KERN_INFO
, "AQ buffer WB: ",
1182 DUMP_PREFIX_OFFSET
, 16, 1,
1187 dev_info(&pf
->pdev
->dev
,
1188 "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
1189 dev_info(&pf
->pdev
->dev
, "dump switch\n");
1190 dev_info(&pf
->pdev
->dev
, "dump vsi [seid]\n");
1191 dev_info(&pf
->pdev
->dev
, "dump reset stats\n");
1192 dev_info(&pf
->pdev
->dev
, "dump port\n");
1193 dev_info(&pf
->pdev
->dev
,
1194 "dump debug fwdata <cluster_id> <table_id> <index>\n");
1197 } else if (strncmp(cmd_buf
, "msg_enable", 10) == 0) {
1199 cnt
= sscanf(&cmd_buf
[10], "%i", &level
);
1201 if (I40E_DEBUG_USER
& level
) {
1202 pf
->hw
.debug_mask
= level
;
1203 dev_info(&pf
->pdev
->dev
,
1204 "set hw.debug_mask = 0x%08x\n",
1207 pf
->msg_enable
= level
;
1208 dev_info(&pf
->pdev
->dev
, "set msg_enable = 0x%08x\n",
1211 dev_info(&pf
->pdev
->dev
, "msg_enable = 0x%08x\n",
1214 } else if (strncmp(cmd_buf
, "pfr", 3) == 0) {
1215 dev_info(&pf
->pdev
->dev
, "debugfs: forcing PFR\n");
1216 i40e_do_reset_safe(pf
, BIT(__I40E_PF_RESET_REQUESTED
));
1218 } else if (strncmp(cmd_buf
, "corer", 5) == 0) {
1219 dev_info(&pf
->pdev
->dev
, "debugfs: forcing CoreR\n");
1220 i40e_do_reset_safe(pf
, BIT(__I40E_CORE_RESET_REQUESTED
));
1222 } else if (strncmp(cmd_buf
, "globr", 5) == 0) {
1223 dev_info(&pf
->pdev
->dev
, "debugfs: forcing GlobR\n");
1224 i40e_do_reset_safe(pf
, BIT(__I40E_GLOBAL_RESET_REQUESTED
));
1226 } else if (strncmp(cmd_buf
, "empr", 4) == 0) {
1227 dev_info(&pf
->pdev
->dev
, "debugfs: forcing EMPR\n");
1228 i40e_do_reset_safe(pf
, BIT(__I40E_EMP_RESET_REQUESTED
));
1230 } else if (strncmp(cmd_buf
, "read", 4) == 0) {
1234 cnt
= sscanf(&cmd_buf
[4], "%i", &address
);
1236 dev_info(&pf
->pdev
->dev
, "read <reg>\n");
1237 goto command_write_done
;
1240 /* check the range on address */
1241 if (address
> (pf
->ioremap_len
- sizeof(u32
))) {
1242 dev_info(&pf
->pdev
->dev
, "read reg address 0x%08x too large, max=0x%08lx\n",
1243 address
, (unsigned long int)(pf
->ioremap_len
- sizeof(u32
)));
1244 goto command_write_done
;
1247 value
= rd32(&pf
->hw
, address
);
1248 dev_info(&pf
->pdev
->dev
, "read: 0x%08x = 0x%08x\n",
1251 } else if (strncmp(cmd_buf
, "write", 5) == 0) {
1254 cnt
= sscanf(&cmd_buf
[5], "%i %i", &address
, &value
);
1256 dev_info(&pf
->pdev
->dev
, "write <reg> <value>\n");
1257 goto command_write_done
;
1260 /* check the range on address */
1261 if (address
> (pf
->ioremap_len
- sizeof(u32
))) {
1262 dev_info(&pf
->pdev
->dev
, "write reg address 0x%08x too large, max=0x%08lx\n",
1263 address
, (unsigned long int)(pf
->ioremap_len
- sizeof(u32
)));
1264 goto command_write_done
;
1266 wr32(&pf
->hw
, address
, value
);
1267 value
= rd32(&pf
->hw
, address
);
1268 dev_info(&pf
->pdev
->dev
, "write: 0x%08x = 0x%08x\n",
1270 } else if (strncmp(cmd_buf
, "clear_stats", 11) == 0) {
1271 if (strncmp(&cmd_buf
[12], "vsi", 3) == 0) {
1272 cnt
= sscanf(&cmd_buf
[15], "%i", &vsi_seid
);
1276 for (i
= 0; i
< pf
->num_alloc_vsi
; i
++)
1277 i40e_vsi_reset_stats(pf
->vsi
[i
]);
1278 dev_info(&pf
->pdev
->dev
, "vsi clear stats called for all vsi's\n");
1279 } else if (cnt
== 1) {
1280 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1282 dev_info(&pf
->pdev
->dev
,
1283 "clear_stats vsi: bad vsi %d\n",
1285 goto command_write_done
;
1287 i40e_vsi_reset_stats(vsi
);
1288 dev_info(&pf
->pdev
->dev
,
1289 "vsi clear stats called for vsi %d\n",
1292 dev_info(&pf
->pdev
->dev
, "clear_stats vsi [seid]\n");
1294 } else if (strncmp(&cmd_buf
[12], "port", 4) == 0) {
1295 if (pf
->hw
.partition_id
== 1) {
1296 i40e_pf_reset_stats(pf
);
1297 dev_info(&pf
->pdev
->dev
, "port stats cleared\n");
1299 dev_info(&pf
->pdev
->dev
, "clear port stats not allowed on this port partition\n");
1302 dev_info(&pf
->pdev
->dev
, "clear_stats vsi [seid] or clear_stats port\n");
1304 } else if (strncmp(cmd_buf
, "send aq_cmd", 11) == 0) {
1305 struct i40e_aq_desc
*desc
;
1308 desc
= kzalloc(sizeof(struct i40e_aq_desc
), GFP_KERNEL
);
1310 goto command_write_done
;
1311 cnt
= sscanf(&cmd_buf
[11],
1312 "%hi %hi %hi %hi %i %i %i %i %i %i",
1314 &desc
->opcode
, &desc
->datalen
, &desc
->retval
,
1315 &desc
->cookie_high
, &desc
->cookie_low
,
1316 &desc
->params
.internal
.param0
,
1317 &desc
->params
.internal
.param1
,
1318 &desc
->params
.internal
.param2
,
1319 &desc
->params
.internal
.param3
);
1321 dev_info(&pf
->pdev
->dev
,
1322 "send aq_cmd: bad command string, cnt=%d\n",
1326 goto command_write_done
;
1328 ret
= i40e_asq_send_command(&pf
->hw
, desc
, NULL
, 0, NULL
);
1330 dev_info(&pf
->pdev
->dev
, "AQ command sent Status : Success\n");
1331 } else if (ret
== I40E_ERR_ADMIN_QUEUE_ERROR
) {
1332 dev_info(&pf
->pdev
->dev
,
1333 "AQ command send failed Opcode %x AQ Error: %d\n",
1334 desc
->opcode
, pf
->hw
.aq
.asq_last_status
);
1336 dev_info(&pf
->pdev
->dev
,
1337 "AQ command send failed Opcode %x Status: %d\n",
1340 dev_info(&pf
->pdev
->dev
,
1341 "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
1342 desc
->flags
, desc
->opcode
, desc
->datalen
, desc
->retval
,
1343 desc
->cookie_high
, desc
->cookie_low
,
1344 desc
->params
.internal
.param0
,
1345 desc
->params
.internal
.param1
,
1346 desc
->params
.internal
.param2
,
1347 desc
->params
.internal
.param3
);
1350 } else if (strncmp(cmd_buf
, "send indirect aq_cmd", 20) == 0) {
1351 struct i40e_aq_desc
*desc
;
1356 desc
= kzalloc(sizeof(struct i40e_aq_desc
), GFP_KERNEL
);
1358 goto command_write_done
;
1359 cnt
= sscanf(&cmd_buf
[20],
1360 "%hi %hi %hi %hi %i %i %i %i %i %i %hi",
1362 &desc
->opcode
, &desc
->datalen
, &desc
->retval
,
1363 &desc
->cookie_high
, &desc
->cookie_low
,
1364 &desc
->params
.internal
.param0
,
1365 &desc
->params
.internal
.param1
,
1366 &desc
->params
.internal
.param2
,
1367 &desc
->params
.internal
.param3
,
1370 dev_info(&pf
->pdev
->dev
,
1371 "send indirect aq_cmd: bad command string, cnt=%d\n",
1375 goto command_write_done
;
1377 /* Just stub a buffer big enough in case user messed up */
1378 if (buffer_len
== 0)
1381 buff
= kzalloc(buffer_len
, GFP_KERNEL
);
1385 goto command_write_done
;
1387 desc
->flags
|= cpu_to_le16((u16
)I40E_AQ_FLAG_BUF
);
1388 ret
= i40e_asq_send_command(&pf
->hw
, desc
, buff
,
1391 dev_info(&pf
->pdev
->dev
, "AQ command sent Status : Success\n");
1392 } else if (ret
== I40E_ERR_ADMIN_QUEUE_ERROR
) {
1393 dev_info(&pf
->pdev
->dev
,
1394 "AQ command send failed Opcode %x AQ Error: %d\n",
1395 desc
->opcode
, pf
->hw
.aq
.asq_last_status
);
1397 dev_info(&pf
->pdev
->dev
,
1398 "AQ command send failed Opcode %x Status: %d\n",
1401 dev_info(&pf
->pdev
->dev
,
1402 "AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
1403 desc
->flags
, desc
->opcode
, desc
->datalen
, desc
->retval
,
1404 desc
->cookie_high
, desc
->cookie_low
,
1405 desc
->params
.internal
.param0
,
1406 desc
->params
.internal
.param1
,
1407 desc
->params
.internal
.param2
,
1408 desc
->params
.internal
.param3
);
1409 print_hex_dump(KERN_INFO
, "AQ buffer WB: ",
1410 DUMP_PREFIX_OFFSET
, 16, 1,
1411 buff
, buffer_len
, true);
1416 } else if ((strncmp(cmd_buf
, "add fd_filter", 13) == 0) ||
1417 (strncmp(cmd_buf
, "rem fd_filter", 13) == 0)) {
1418 struct i40e_fdir_filter fd_data
;
1419 u16 packet_len
, i
, j
= 0;
1425 if (!(pf
->flags
& I40E_FLAG_FD_SB_ENABLED
))
1426 goto command_write_done
;
1428 if (strncmp(cmd_buf
, "add", 3) == 0)
1431 if (add
&& (pf
->auto_disable_flags
& I40E_FLAG_FD_SB_ENABLED
))
1432 goto command_write_done
;
1434 asc_packet
= kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE
,
1437 goto command_write_done
;
1439 raw_packet
= kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE
,
1445 goto command_write_done
;
1448 cnt
= sscanf(&cmd_buf
[13],
1449 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %511s",
1451 &fd_data
.flex_off
, &fd_data
.pctype
,
1452 &fd_data
.dest_vsi
, &fd_data
.dest_ctl
,
1453 &fd_data
.fd_status
, &fd_data
.cnt_index
,
1454 &fd_data
.fd_id
, &packet_len
, asc_packet
);
1456 dev_info(&pf
->pdev
->dev
,
1457 "program fd_filter: bad command string, cnt=%d\n",
1462 goto command_write_done
;
1465 /* fix packet length if user entered 0 */
1466 if (packet_len
== 0)
1467 packet_len
= I40E_FDIR_MAX_RAW_PACKET_SIZE
;
1469 /* make sure to check the max as well */
1470 packet_len
= min_t(u16
,
1471 packet_len
, I40E_FDIR_MAX_RAW_PACKET_SIZE
);
1473 for (i
= 0; i
< packet_len
; i
++) {
1474 cnt
= sscanf(&asc_packet
[j
], "%2hhx ", &raw_packet
[i
]);
1479 dev_info(&pf
->pdev
->dev
, "FD raw packet dump\n");
1480 print_hex_dump(KERN_INFO
, "FD raw packet: ",
1481 DUMP_PREFIX_OFFSET
, 16, 1,
1482 raw_packet
, packet_len
, true);
1483 ret
= i40e_program_fdir_filter(&fd_data
, raw_packet
, pf
, add
);
1485 dev_info(&pf
->pdev
->dev
, "Filter command send Status : Success\n");
1487 dev_info(&pf
->pdev
->dev
,
1488 "Filter command send failed %d\n", ret
);
1494 } else if (strncmp(cmd_buf
, "fd current cnt", 14) == 0) {
1495 dev_info(&pf
->pdev
->dev
, "FD current total filter count for this interface: %d\n",
1496 i40e_get_current_fd_count(pf
));
1497 } else if (strncmp(cmd_buf
, "lldp", 4) == 0) {
1498 if (strncmp(&cmd_buf
[5], "stop", 4) == 0) {
1501 ret
= i40e_aq_stop_lldp(&pf
->hw
, false, NULL
);
1503 dev_info(&pf
->pdev
->dev
,
1504 "Stop LLDP AQ command failed =0x%x\n",
1505 pf
->hw
.aq
.asq_last_status
);
1506 goto command_write_done
;
1508 ret
= i40e_aq_add_rem_control_packet_filter(&pf
->hw
,
1511 pf
->vsi
[pf
->lan_vsi
]->seid
,
1512 0, true, NULL
, NULL
);
1514 dev_info(&pf
->pdev
->dev
,
1515 "%s: Add Control Packet Filter AQ command failed =0x%x\n",
1516 __func__
, pf
->hw
.aq
.asq_last_status
);
1517 goto command_write_done
;
1519 #ifdef CONFIG_I40E_DCB
1520 pf
->dcbx_cap
= DCB_CAP_DCBX_HOST
|
1521 DCB_CAP_DCBX_VER_IEEE
;
1522 #endif /* CONFIG_I40E_DCB */
1523 } else if (strncmp(&cmd_buf
[5], "start", 5) == 0) {
1526 ret
= i40e_aq_add_rem_control_packet_filter(&pf
->hw
,
1529 pf
->vsi
[pf
->lan_vsi
]->seid
,
1530 0, false, NULL
, NULL
);
1532 dev_info(&pf
->pdev
->dev
,
1533 "%s: Remove Control Packet Filter AQ command failed =0x%x\n",
1534 __func__
, pf
->hw
.aq
.asq_last_status
);
1535 /* Continue and start FW LLDP anyways */
1538 ret
= i40e_aq_start_lldp(&pf
->hw
, NULL
);
1540 dev_info(&pf
->pdev
->dev
,
1541 "Start LLDP AQ command failed =0x%x\n",
1542 pf
->hw
.aq
.asq_last_status
);
1543 goto command_write_done
;
1545 #ifdef CONFIG_I40E_DCB
1546 pf
->dcbx_cap
= DCB_CAP_DCBX_LLD_MANAGED
|
1547 DCB_CAP_DCBX_VER_IEEE
;
1548 #endif /* CONFIG_I40E_DCB */
1549 } else if (strncmp(&cmd_buf
[5],
1550 "get local", 9) == 0) {
1555 buff
= kzalloc(I40E_LLDPDU_SIZE
, GFP_KERNEL
);
1557 goto command_write_done
;
1559 ret
= i40e_aq_get_lldp_mib(&pf
->hw
, 0,
1560 I40E_AQ_LLDP_MIB_LOCAL
,
1561 buff
, I40E_LLDPDU_SIZE
,
1562 &llen
, &rlen
, NULL
);
1564 dev_info(&pf
->pdev
->dev
,
1565 "Get LLDP MIB (local) AQ command failed =0x%x\n",
1566 pf
->hw
.aq
.asq_last_status
);
1569 goto command_write_done
;
1571 dev_info(&pf
->pdev
->dev
, "LLDP MIB (local)\n");
1572 print_hex_dump(KERN_INFO
, "LLDP MIB (local): ",
1573 DUMP_PREFIX_OFFSET
, 16, 1,
1574 buff
, I40E_LLDPDU_SIZE
, true);
1577 } else if (strncmp(&cmd_buf
[5], "get remote", 10) == 0) {
1582 buff
= kzalloc(I40E_LLDPDU_SIZE
, GFP_KERNEL
);
1584 goto command_write_done
;
1586 ret
= i40e_aq_get_lldp_mib(&pf
->hw
,
1587 I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE
,
1588 I40E_AQ_LLDP_MIB_REMOTE
,
1589 buff
, I40E_LLDPDU_SIZE
,
1590 &llen
, &rlen
, NULL
);
1592 dev_info(&pf
->pdev
->dev
,
1593 "Get LLDP MIB (remote) AQ command failed =0x%x\n",
1594 pf
->hw
.aq
.asq_last_status
);
1597 goto command_write_done
;
1599 dev_info(&pf
->pdev
->dev
, "LLDP MIB (remote)\n");
1600 print_hex_dump(KERN_INFO
, "LLDP MIB (remote): ",
1601 DUMP_PREFIX_OFFSET
, 16, 1,
1602 buff
, I40E_LLDPDU_SIZE
, true);
1605 } else if (strncmp(&cmd_buf
[5], "event on", 8) == 0) {
1608 ret
= i40e_aq_cfg_lldp_mib_change_event(&pf
->hw
,
1611 dev_info(&pf
->pdev
->dev
,
1612 "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
1613 pf
->hw
.aq
.asq_last_status
);
1614 goto command_write_done
;
1616 } else if (strncmp(&cmd_buf
[5], "event off", 9) == 0) {
1619 ret
= i40e_aq_cfg_lldp_mib_change_event(&pf
->hw
,
1622 dev_info(&pf
->pdev
->dev
,
1623 "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
1624 pf
->hw
.aq
.asq_last_status
);
1625 goto command_write_done
;
1628 } else if (strncmp(cmd_buf
, "nvm read", 8) == 0) {
1629 u16 buffer_len
, bytes
;
1635 cnt
= sscanf(&cmd_buf
[8], "%hx %x %hx",
1636 &module
, &offset
, &buffer_len
);
1641 } else if (cnt
== 1) {
1644 } else if (cnt
== 2) {
1646 } else if (cnt
> 3) {
1647 dev_info(&pf
->pdev
->dev
,
1648 "nvm read: bad command string, cnt=%d\n", cnt
);
1649 goto command_write_done
;
1652 /* set the max length */
1653 buffer_len
= min_t(u16
, buffer_len
, I40E_MAX_AQ_BUF_SIZE
/2);
1655 bytes
= 2 * buffer_len
;
1657 /* read at least 1k bytes, no more than 4kB */
1658 bytes
= clamp(bytes
, (u16
)1024, (u16
)I40E_MAX_AQ_BUF_SIZE
);
1659 buff
= kzalloc(bytes
, GFP_KERNEL
);
1661 goto command_write_done
;
1663 ret
= i40e_acquire_nvm(&pf
->hw
, I40E_RESOURCE_READ
);
1665 dev_info(&pf
->pdev
->dev
,
1666 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1667 ret
, pf
->hw
.aq
.asq_last_status
);
1669 goto command_write_done
;
1672 ret
= i40e_aq_read_nvm(&pf
->hw
, module
, (2 * offset
),
1673 bytes
, (u8
*)buff
, true, NULL
);
1674 i40e_release_nvm(&pf
->hw
);
1676 dev_info(&pf
->pdev
->dev
,
1677 "Read NVM AQ failed err=%d status=0x%x\n",
1678 ret
, pf
->hw
.aq
.asq_last_status
);
1680 dev_info(&pf
->pdev
->dev
,
1681 "Read NVM module=0x%x offset=0x%x words=%d\n",
1682 module
, offset
, buffer_len
);
1684 print_hex_dump(KERN_INFO
, "NVM Dump: ",
1685 DUMP_PREFIX_OFFSET
, 16, 2,
1691 dev_info(&pf
->pdev
->dev
, "unknown command '%s'\n", cmd_buf
);
1692 dev_info(&pf
->pdev
->dev
, "available commands\n");
1693 dev_info(&pf
->pdev
->dev
, " add vsi [relay_seid]\n");
1694 dev_info(&pf
->pdev
->dev
, " del vsi [vsi_seid]\n");
1695 dev_info(&pf
->pdev
->dev
, " add relay <uplink_seid> <vsi_seid>\n");
1696 dev_info(&pf
->pdev
->dev
, " del relay <relay_seid>\n");
1697 dev_info(&pf
->pdev
->dev
, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1698 dev_info(&pf
->pdev
->dev
, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1699 dev_info(&pf
->pdev
->dev
, " add pvid <vsi_seid> <vid>\n");
1700 dev_info(&pf
->pdev
->dev
, " del pvid <vsi_seid>\n");
1701 dev_info(&pf
->pdev
->dev
, " dump switch\n");
1702 dev_info(&pf
->pdev
->dev
, " dump vsi [seid]\n");
1703 dev_info(&pf
->pdev
->dev
, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
1704 dev_info(&pf
->pdev
->dev
, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1705 dev_info(&pf
->pdev
->dev
, " dump desc aq\n");
1706 dev_info(&pf
->pdev
->dev
, " dump reset stats\n");
1707 dev_info(&pf
->pdev
->dev
, " dump debug fwdata <cluster_id> <table_id> <index>\n");
1708 dev_info(&pf
->pdev
->dev
, " msg_enable [level]\n");
1709 dev_info(&pf
->pdev
->dev
, " read <reg>\n");
1710 dev_info(&pf
->pdev
->dev
, " write <reg> <value>\n");
1711 dev_info(&pf
->pdev
->dev
, " clear_stats vsi [seid]\n");
1712 dev_info(&pf
->pdev
->dev
, " clear_stats port\n");
1713 dev_info(&pf
->pdev
->dev
, " pfr\n");
1714 dev_info(&pf
->pdev
->dev
, " corer\n");
1715 dev_info(&pf
->pdev
->dev
, " globr\n");
1716 dev_info(&pf
->pdev
->dev
, " send aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3>\n");
1717 dev_info(&pf
->pdev
->dev
, " send indirect aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3> <buffer_len>\n");
1718 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");
1719 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");
1720 dev_info(&pf
->pdev
->dev
, " fd current cnt");
1721 dev_info(&pf
->pdev
->dev
, " lldp start\n");
1722 dev_info(&pf
->pdev
->dev
, " lldp stop\n");
1723 dev_info(&pf
->pdev
->dev
, " lldp get local\n");
1724 dev_info(&pf
->pdev
->dev
, " lldp get remote\n");
1725 dev_info(&pf
->pdev
->dev
, " lldp event on\n");
1726 dev_info(&pf
->pdev
->dev
, " lldp event off\n");
1727 dev_info(&pf
->pdev
->dev
, " nvm read [module] [word_offset] [word_count]\n");
1736 static const struct file_operations i40e_dbg_command_fops
= {
1737 .owner
= THIS_MODULE
,
1738 .open
= simple_open
,
1739 .read
= i40e_dbg_command_read
,
1740 .write
= i40e_dbg_command_write
,
1743 /**************************************************************
1745 * The netdev_ops entry in debugfs is for giving the driver commands
1746 * to be executed from the netdev operations.
1747 **************************************************************/
1748 static char i40e_dbg_netdev_ops_buf
[256] = "";
1751 * i40e_dbg_netdev_ops - read for netdev_ops datum
1752 * @filp: the opened file
1753 * @buffer: where to write the data for the user to read
1754 * @count: the size of the user's buffer
1755 * @ppos: file position offset
1757 static ssize_t
i40e_dbg_netdev_ops_read(struct file
*filp
, char __user
*buffer
,
1758 size_t count
, loff_t
*ppos
)
1760 struct i40e_pf
*pf
= filp
->private_data
;
1761 int bytes_not_copied
;
1766 /* don't allow partal reads */
1769 if (count
< buf_size
)
1772 buf
= kzalloc(buf_size
, GFP_KERNEL
);
1776 len
= snprintf(buf
, buf_size
, "%s: %s\n",
1777 pf
->vsi
[pf
->lan_vsi
]->netdev
->name
,
1778 i40e_dbg_netdev_ops_buf
);
1780 bytes_not_copied
= copy_to_user(buffer
, buf
, len
);
1783 if (bytes_not_copied
)
1791 * i40e_dbg_netdev_ops_write - write into netdev_ops datum
1792 * @filp: the opened file
1793 * @buffer: where to find the user's data
1794 * @count: the length of the user's data
1795 * @ppos: file position offset
1797 static ssize_t
i40e_dbg_netdev_ops_write(struct file
*filp
,
1798 const char __user
*buffer
,
1799 size_t count
, loff_t
*ppos
)
1801 struct i40e_pf
*pf
= filp
->private_data
;
1802 int bytes_not_copied
;
1803 struct i40e_vsi
*vsi
;
1808 /* don't allow partial writes */
1811 if (count
>= sizeof(i40e_dbg_netdev_ops_buf
))
1814 memset(i40e_dbg_netdev_ops_buf
, 0, sizeof(i40e_dbg_netdev_ops_buf
));
1815 bytes_not_copied
= copy_from_user(i40e_dbg_netdev_ops_buf
,
1817 if (bytes_not_copied
)
1819 i40e_dbg_netdev_ops_buf
[count
] = '\0';
1821 buf_tmp
= strchr(i40e_dbg_netdev_ops_buf
, '\n');
1824 count
= buf_tmp
- i40e_dbg_netdev_ops_buf
+ 1;
1827 if (strncmp(i40e_dbg_netdev_ops_buf
, "tx_timeout", 10) == 0) {
1828 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[11], "%i", &vsi_seid
);
1830 dev_info(&pf
->pdev
->dev
, "tx_timeout <vsi_seid>\n");
1831 goto netdev_ops_write_done
;
1833 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1835 dev_info(&pf
->pdev
->dev
,
1836 "tx_timeout: VSI %d not found\n", vsi_seid
);
1837 } else if (!vsi
->netdev
) {
1838 dev_info(&pf
->pdev
->dev
, "tx_timeout: no netdev for VSI %d\n",
1840 } else if (test_bit(__I40E_DOWN
, &vsi
->state
)) {
1841 dev_info(&pf
->pdev
->dev
, "tx_timeout: VSI %d not UP\n",
1843 } else if (rtnl_trylock()) {
1844 vsi
->netdev
->netdev_ops
->ndo_tx_timeout(vsi
->netdev
);
1846 dev_info(&pf
->pdev
->dev
, "tx_timeout called\n");
1848 dev_info(&pf
->pdev
->dev
, "Could not acquire RTNL - please try again\n");
1850 } else if (strncmp(i40e_dbg_netdev_ops_buf
, "change_mtu", 10) == 0) {
1853 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[11], "%i %i",
1856 dev_info(&pf
->pdev
->dev
, "change_mtu <vsi_seid> <mtu>\n");
1857 goto netdev_ops_write_done
;
1859 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1861 dev_info(&pf
->pdev
->dev
,
1862 "change_mtu: VSI %d not found\n", vsi_seid
);
1863 } else if (!vsi
->netdev
) {
1864 dev_info(&pf
->pdev
->dev
, "change_mtu: no netdev for VSI %d\n",
1866 } else if (rtnl_trylock()) {
1867 vsi
->netdev
->netdev_ops
->ndo_change_mtu(vsi
->netdev
,
1870 dev_info(&pf
->pdev
->dev
, "change_mtu called\n");
1872 dev_info(&pf
->pdev
->dev
, "Could not acquire RTNL - please try again\n");
1875 } else if (strncmp(i40e_dbg_netdev_ops_buf
, "set_rx_mode", 11) == 0) {
1876 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[11], "%i", &vsi_seid
);
1878 dev_info(&pf
->pdev
->dev
, "set_rx_mode <vsi_seid>\n");
1879 goto netdev_ops_write_done
;
1881 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1883 dev_info(&pf
->pdev
->dev
,
1884 "set_rx_mode: VSI %d not found\n", vsi_seid
);
1885 } else if (!vsi
->netdev
) {
1886 dev_info(&pf
->pdev
->dev
, "set_rx_mode: no netdev for VSI %d\n",
1888 } else if (rtnl_trylock()) {
1889 vsi
->netdev
->netdev_ops
->ndo_set_rx_mode(vsi
->netdev
);
1891 dev_info(&pf
->pdev
->dev
, "set_rx_mode called\n");
1893 dev_info(&pf
->pdev
->dev
, "Could not acquire RTNL - please try again\n");
1896 } else if (strncmp(i40e_dbg_netdev_ops_buf
, "napi", 4) == 0) {
1897 cnt
= sscanf(&i40e_dbg_netdev_ops_buf
[4], "%i", &vsi_seid
);
1899 dev_info(&pf
->pdev
->dev
, "napi <vsi_seid>\n");
1900 goto netdev_ops_write_done
;
1902 vsi
= i40e_dbg_find_vsi(pf
, vsi_seid
);
1904 dev_info(&pf
->pdev
->dev
, "napi: VSI %d not found\n",
1906 } else if (!vsi
->netdev
) {
1907 dev_info(&pf
->pdev
->dev
, "napi: no netdev for VSI %d\n",
1910 for (i
= 0; i
< vsi
->num_q_vectors
; i
++)
1911 napi_schedule(&vsi
->q_vectors
[i
]->napi
);
1912 dev_info(&pf
->pdev
->dev
, "napi called\n");
1915 dev_info(&pf
->pdev
->dev
, "unknown command '%s'\n",
1916 i40e_dbg_netdev_ops_buf
);
1917 dev_info(&pf
->pdev
->dev
, "available commands\n");
1918 dev_info(&pf
->pdev
->dev
, " tx_timeout <vsi_seid>\n");
1919 dev_info(&pf
->pdev
->dev
, " change_mtu <vsi_seid> <mtu>\n");
1920 dev_info(&pf
->pdev
->dev
, " set_rx_mode <vsi_seid>\n");
1921 dev_info(&pf
->pdev
->dev
, " napi <vsi_seid>\n");
1923 netdev_ops_write_done
:
1927 static const struct file_operations i40e_dbg_netdev_ops_fops
= {
1928 .owner
= THIS_MODULE
,
1929 .open
= simple_open
,
1930 .read
= i40e_dbg_netdev_ops_read
,
1931 .write
= i40e_dbg_netdev_ops_write
,
1935 * i40e_dbg_pf_init - setup the debugfs directory for the PF
1936 * @pf: the PF that is starting up
1938 void i40e_dbg_pf_init(struct i40e_pf
*pf
)
1940 struct dentry
*pfile
;
1941 const char *name
= pci_name(pf
->pdev
);
1942 const struct device
*dev
= &pf
->pdev
->dev
;
1944 pf
->i40e_dbg_pf
= debugfs_create_dir(name
, i40e_dbg_root
);
1945 if (!pf
->i40e_dbg_pf
)
1948 pfile
= debugfs_create_file("command", 0600, pf
->i40e_dbg_pf
, pf
,
1949 &i40e_dbg_command_fops
);
1953 pfile
= debugfs_create_file("netdev_ops", 0600, pf
->i40e_dbg_pf
, pf
,
1954 &i40e_dbg_netdev_ops_fops
);
1961 dev_info(dev
, "debugfs dir/file for %s failed\n", name
);
1962 debugfs_remove_recursive(pf
->i40e_dbg_pf
);
1966 * i40e_dbg_pf_exit - clear out the PF's debugfs entries
1967 * @pf: the PF that is stopping
1969 void i40e_dbg_pf_exit(struct i40e_pf
*pf
)
1971 debugfs_remove_recursive(pf
->i40e_dbg_pf
);
1972 pf
->i40e_dbg_pf
= NULL
;
1976 * i40e_dbg_init - start up debugfs for the driver
1978 void i40e_dbg_init(void)
1980 i40e_dbg_root
= debugfs_create_dir(i40e_driver_name
, NULL
);
1982 pr_info("init of debugfs failed\n");
1986 * i40e_dbg_exit - clean out the driver's debugfs entries
1988 void i40e_dbg_exit(void)
1990 debugfs_remove_recursive(i40e_dbg_root
);
1991 i40e_dbg_root
= NULL
;
1994 #endif /* CONFIG_DEBUG_FS */