i40e_debugfs.c 69 KB

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