i40e_debugfs.c 64 KB

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