i40e_debugfs.c 67 KB

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