i40e_debugfs.c 64 KB

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