i40e_debugfs.c 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075
  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].stats.packets,
  462. vsi->rx_rings[i].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].stats.packets,
  506. vsi->tx_rings[i].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, tx_done_old = %lld\n",
  510. i,
  511. vsi->tx_rings[i].tx_stats.tx_busy,
  512. vsi->tx_rings[i].tx_stats.tx_done_old);
  513. dev_info(&pf->pdev->dev,
  514. " tx_rings[%i]: size = %i, dma = 0x%08lx\n",
  515. i, vsi->tx_rings[i].size,
  516. (long unsigned int)vsi->tx_rings[i].dma);
  517. dev_info(&pf->pdev->dev,
  518. " tx_rings[%i]: vsi = %p, q_vector = %p\n",
  519. i, vsi->tx_rings[i].vsi,
  520. vsi->tx_rings[i].q_vector);
  521. dev_info(&pf->pdev->dev,
  522. " tx_rings[%i]: DCB tc = %d\n",
  523. i, vsi->tx_rings[i].dcb_tc);
  524. }
  525. }
  526. dev_info(&pf->pdev->dev,
  527. " work_limit = %d, rx_itr_setting = %d (%s), tx_itr_setting = %d (%s)\n",
  528. vsi->work_limit, vsi->rx_itr_setting,
  529. ITR_IS_DYNAMIC(vsi->rx_itr_setting) ? "dynamic" : "fixed",
  530. vsi->tx_itr_setting,
  531. ITR_IS_DYNAMIC(vsi->tx_itr_setting) ? "dynamic" : "fixed");
  532. dev_info(&pf->pdev->dev,
  533. " max_frame = %d, rx_hdr_len = %d, rx_buf_len = %d dtype = %d\n",
  534. vsi->max_frame, vsi->rx_hdr_len, vsi->rx_buf_len, vsi->dtype);
  535. if (vsi->q_vectors) {
  536. for (i = 0; i < vsi->num_q_vectors; i++) {
  537. dev_info(&pf->pdev->dev,
  538. " q_vectors[%i]: base index = %ld\n",
  539. i, ((long int)*vsi->q_vectors[i].rx.ring-
  540. (long int)*vsi->q_vectors[0].rx.ring)/
  541. sizeof(struct i40e_ring));
  542. }
  543. }
  544. dev_info(&pf->pdev->dev,
  545. " num_q_vectors = %i, base_vector = %i\n",
  546. vsi->num_q_vectors, vsi->base_vector);
  547. dev_info(&pf->pdev->dev,
  548. " seid = %d, id = %d, uplink_seid = %d\n",
  549. vsi->seid, vsi->id, vsi->uplink_seid);
  550. dev_info(&pf->pdev->dev,
  551. " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
  552. vsi->base_queue, vsi->num_queue_pairs, vsi->num_desc);
  553. dev_info(&pf->pdev->dev, " type = %i\n", vsi->type);
  554. dev_info(&pf->pdev->dev,
  555. " info: valid_sections = 0x%04x, switch_id = 0x%04x\n",
  556. vsi->info.valid_sections, vsi->info.switch_id);
  557. dev_info(&pf->pdev->dev,
  558. " info: sw_reserved[] = 0x%02x 0x%02x\n",
  559. vsi->info.sw_reserved[0], vsi->info.sw_reserved[1]);
  560. dev_info(&pf->pdev->dev,
  561. " info: sec_flags = 0x%02x, sec_reserved = 0x%02x\n",
  562. vsi->info.sec_flags, vsi->info.sec_reserved);
  563. dev_info(&pf->pdev->dev,
  564. " info: pvid = 0x%04x, fcoe_pvid = 0x%04x, port_vlan_flags = 0x%02x\n",
  565. vsi->info.pvid, vsi->info.fcoe_pvid,
  566. vsi->info.port_vlan_flags);
  567. dev_info(&pf->pdev->dev,
  568. " info: pvlan_reserved[] = 0x%02x 0x%02x 0x%02x\n",
  569. vsi->info.pvlan_reserved[0], vsi->info.pvlan_reserved[1],
  570. vsi->info.pvlan_reserved[2]);
  571. dev_info(&pf->pdev->dev,
  572. " info: ingress_table = 0x%08x, egress_table = 0x%08x\n",
  573. vsi->info.ingress_table, vsi->info.egress_table);
  574. dev_info(&pf->pdev->dev,
  575. " info: cas_pv_stag = 0x%04x, cas_pv_flags= 0x%02x, cas_pv_reserved = 0x%02x\n",
  576. vsi->info.cas_pv_tag, vsi->info.cas_pv_flags,
  577. vsi->info.cas_pv_reserved);
  578. dev_info(&pf->pdev->dev,
  579. " info: queue_mapping[0..7 ] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
  580. vsi->info.queue_mapping[0], vsi->info.queue_mapping[1],
  581. vsi->info.queue_mapping[2], vsi->info.queue_mapping[3],
  582. vsi->info.queue_mapping[4], vsi->info.queue_mapping[5],
  583. vsi->info.queue_mapping[6], vsi->info.queue_mapping[7]);
  584. dev_info(&pf->pdev->dev,
  585. " info: queue_mapping[8..15] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
  586. vsi->info.queue_mapping[8], vsi->info.queue_mapping[9],
  587. vsi->info.queue_mapping[10], vsi->info.queue_mapping[11],
  588. vsi->info.queue_mapping[12], vsi->info.queue_mapping[13],
  589. vsi->info.queue_mapping[14], vsi->info.queue_mapping[15]);
  590. dev_info(&pf->pdev->dev,
  591. " info: tc_mapping[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
  592. vsi->info.tc_mapping[0], vsi->info.tc_mapping[1],
  593. vsi->info.tc_mapping[2], vsi->info.tc_mapping[3],
  594. vsi->info.tc_mapping[4], vsi->info.tc_mapping[5],
  595. vsi->info.tc_mapping[6], vsi->info.tc_mapping[7]);
  596. dev_info(&pf->pdev->dev,
  597. " info: queueing_opt_flags = 0x%02x queueing_opt_reserved[0..2] = 0x%02x 0x%02x 0x%02x\n",
  598. vsi->info.queueing_opt_flags,
  599. vsi->info.queueing_opt_reserved[0],
  600. vsi->info.queueing_opt_reserved[1],
  601. vsi->info.queueing_opt_reserved[2]);
  602. dev_info(&pf->pdev->dev,
  603. " info: up_enable_bits = 0x%02x\n",
  604. vsi->info.up_enable_bits);
  605. dev_info(&pf->pdev->dev,
  606. " info: sched_reserved = 0x%02x, outer_up_table = 0x%04x\n",
  607. vsi->info.sched_reserved, vsi->info.outer_up_table);
  608. dev_info(&pf->pdev->dev,
  609. " info: cmd_reserved[] = 0x%02x 0x%02x 0x%02x 0x0%02x 0x%02x 0x%02x 0x%02x 0x0%02x\n",
  610. vsi->info.cmd_reserved[0], vsi->info.cmd_reserved[1],
  611. vsi->info.cmd_reserved[2], vsi->info.cmd_reserved[3],
  612. vsi->info.cmd_reserved[4], vsi->info.cmd_reserved[5],
  613. vsi->info.cmd_reserved[6], vsi->info.cmd_reserved[7]);
  614. dev_info(&pf->pdev->dev,
  615. " info: qs_handle[] = 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
  616. vsi->info.qs_handle[0], vsi->info.qs_handle[1],
  617. vsi->info.qs_handle[2], vsi->info.qs_handle[3],
  618. vsi->info.qs_handle[4], vsi->info.qs_handle[5],
  619. vsi->info.qs_handle[6], vsi->info.qs_handle[7]);
  620. dev_info(&pf->pdev->dev,
  621. " info: stat_counter_idx = 0x%04x, sched_id = 0x%04x\n",
  622. vsi->info.stat_counter_idx, vsi->info.sched_id);
  623. dev_info(&pf->pdev->dev,
  624. " 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",
  625. vsi->info.resp_reserved[0], vsi->info.resp_reserved[1],
  626. vsi->info.resp_reserved[2], vsi->info.resp_reserved[3],
  627. vsi->info.resp_reserved[4], vsi->info.resp_reserved[5],
  628. vsi->info.resp_reserved[6], vsi->info.resp_reserved[7],
  629. vsi->info.resp_reserved[8], vsi->info.resp_reserved[9],
  630. vsi->info.resp_reserved[10], vsi->info.resp_reserved[11]);
  631. if (vsi->back)
  632. dev_info(&pf->pdev->dev, " pf = %p\n", vsi->back);
  633. dev_info(&pf->pdev->dev, " idx = %d\n", vsi->idx);
  634. dev_info(&pf->pdev->dev,
  635. " tc_config: numtc = %d, enabled_tc = 0x%x\n",
  636. vsi->tc_config.numtc, vsi->tc_config.enabled_tc);
  637. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  638. dev_info(&pf->pdev->dev,
  639. " tc_config: tc = %d, qoffset = %d, qcount = %d, netdev_tc = %d\n",
  640. i, vsi->tc_config.tc_info[i].qoffset,
  641. vsi->tc_config.tc_info[i].qcount,
  642. vsi->tc_config.tc_info[i].netdev_tc);
  643. }
  644. dev_info(&pf->pdev->dev,
  645. " bw: bw_limit = %d, bw_max_quanta = %d\n",
  646. vsi->bw_limit, vsi->bw_max_quanta);
  647. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  648. dev_info(&pf->pdev->dev,
  649. " bw[%d]: ets_share_credits = %d, ets_limit_credits = %d, max_quanta = %d\n",
  650. i, vsi->bw_ets_share_credits[i],
  651. vsi->bw_ets_limit_credits[i],
  652. vsi->bw_ets_max_quanta[i]);
  653. }
  654. }
  655. /**
  656. * i40e_dbg_dump_aq_desc - handles dump aq_desc write into command datum
  657. * @pf: the i40e_pf created in command write
  658. **/
  659. static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf)
  660. {
  661. struct i40e_adminq_ring *ring;
  662. struct i40e_hw *hw = &pf->hw;
  663. int i;
  664. /* first the send (command) ring, then the receive (event) ring */
  665. dev_info(&pf->pdev->dev, "AdminQ Tx Ring\n");
  666. ring = &(hw->aq.asq);
  667. for (i = 0; i < ring->count; i++) {
  668. struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
  669. dev_info(&pf->pdev->dev,
  670. " at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
  671. i, d->flags, d->opcode, d->datalen, d->retval,
  672. d->cookie_high, d->cookie_low);
  673. dev_info(&pf->pdev->dev,
  674. " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
  675. d->params.raw[0], d->params.raw[1], d->params.raw[2],
  676. d->params.raw[3], d->params.raw[4], d->params.raw[5],
  677. d->params.raw[6], d->params.raw[7], d->params.raw[8],
  678. d->params.raw[9], d->params.raw[10], d->params.raw[11],
  679. d->params.raw[12], d->params.raw[13],
  680. d->params.raw[14], d->params.raw[15]);
  681. }
  682. dev_info(&pf->pdev->dev, "AdminQ Rx Ring\n");
  683. ring = &(hw->aq.arq);
  684. for (i = 0; i < ring->count; i++) {
  685. struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);
  686. dev_info(&pf->pdev->dev,
  687. " ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
  688. i, d->flags, d->opcode, d->datalen, d->retval,
  689. d->cookie_high, d->cookie_low);
  690. dev_info(&pf->pdev->dev,
  691. " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
  692. d->params.raw[0], d->params.raw[1], d->params.raw[2],
  693. d->params.raw[3], d->params.raw[4], d->params.raw[5],
  694. d->params.raw[6], d->params.raw[7], d->params.raw[8],
  695. d->params.raw[9], d->params.raw[10], d->params.raw[11],
  696. d->params.raw[12], d->params.raw[13],
  697. d->params.raw[14], d->params.raw[15]);
  698. }
  699. }
  700. /**
  701. * i40e_dbg_dump_desc - handles dump desc write into command datum
  702. * @cnt: number of arguments that the user supplied
  703. * @vsi_seid: vsi id entered by user
  704. * @ring_id: ring id entered by user
  705. * @desc_n: descriptor number entered by user
  706. * @pf: the i40e_pf created in command write
  707. * @is_rx_ring: true if rx, false if tx
  708. **/
  709. static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
  710. struct i40e_pf *pf, bool is_rx_ring)
  711. {
  712. union i40e_rx_desc *ds;
  713. struct i40e_ring ring;
  714. struct i40e_vsi *vsi;
  715. int i;
  716. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  717. if (!vsi) {
  718. dev_info(&pf->pdev->dev,
  719. "vsi %d not found\n", vsi_seid);
  720. if (is_rx_ring)
  721. dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
  722. else
  723. dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
  724. return;
  725. }
  726. if (ring_id >= vsi->num_queue_pairs || ring_id < 0) {
  727. dev_info(&pf->pdev->dev, "ring %d not found\n", ring_id);
  728. if (is_rx_ring)
  729. dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
  730. else
  731. dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
  732. return;
  733. }
  734. if (is_rx_ring)
  735. ring = vsi->rx_rings[ring_id];
  736. else
  737. ring = vsi->tx_rings[ring_id];
  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. ds = I40E_RX_DESC(&ring, i);
  744. else
  745. ds = (union i40e_rx_desc *)
  746. I40E_TX_DESC(&ring, i);
  747. if ((sizeof(union i40e_rx_desc) ==
  748. sizeof(union i40e_16byte_rx_desc)) || (!is_rx_ring))
  749. dev_info(&pf->pdev->dev,
  750. " d[%03i] = 0x%016llx 0x%016llx\n", i,
  751. ds->read.pkt_addr, ds->read.hdr_addr);
  752. else
  753. dev_info(&pf->pdev->dev,
  754. " d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
  755. i, ds->read.pkt_addr,
  756. ds->read.hdr_addr,
  757. ds->read.rsvd1, ds->read.rsvd2);
  758. }
  759. } else if (cnt == 3) {
  760. if (desc_n >= ring.count || desc_n < 0) {
  761. dev_info(&pf->pdev->dev,
  762. "descriptor %d not found\n", desc_n);
  763. return;
  764. }
  765. if (is_rx_ring)
  766. ds = I40E_RX_DESC(&ring, desc_n);
  767. else
  768. ds = (union i40e_rx_desc *)I40E_TX_DESC(&ring, desc_n);
  769. if ((sizeof(union i40e_rx_desc) ==
  770. sizeof(union i40e_16byte_rx_desc)) || (!is_rx_ring))
  771. dev_info(&pf->pdev->dev,
  772. "vsi = %02i %s ring = %02i d[%03i] = 0x%016llx 0x%016llx\n",
  773. vsi_seid, is_rx_ring ? "rx" : "tx", ring_id,
  774. desc_n, ds->read.pkt_addr, ds->read.hdr_addr);
  775. else
  776. dev_info(&pf->pdev->dev,
  777. "vsi = %02i rx ring = %02i d[%03i] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
  778. vsi_seid, ring_id,
  779. desc_n, ds->read.pkt_addr, ds->read.hdr_addr,
  780. ds->read.rsvd1, ds->read.rsvd2);
  781. } else {
  782. if (is_rx_ring)
  783. dev_info(&pf->pdev->dev, "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
  784. else
  785. dev_info(&pf->pdev->dev, "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
  786. }
  787. }
  788. /**
  789. * i40e_dbg_dump_vsi_no_seid - handles dump vsi write into command datum
  790. * @pf: the i40e_pf created in command write
  791. **/
  792. static void i40e_dbg_dump_vsi_no_seid(struct i40e_pf *pf)
  793. {
  794. int i;
  795. for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
  796. if (pf->vsi[i])
  797. dev_info(&pf->pdev->dev, "dump vsi[%d]: %d\n",
  798. i, pf->vsi[i]->seid);
  799. }
  800. /**
  801. * i40e_dbg_dump_stats - handles dump stats write into command datum
  802. * @pf: the i40e_pf created in command write
  803. * @estats: the eth stats structure to be dumped
  804. **/
  805. static void i40e_dbg_dump_eth_stats(struct i40e_pf *pf,
  806. struct i40e_eth_stats *estats)
  807. {
  808. dev_info(&pf->pdev->dev, " ethstats:\n");
  809. dev_info(&pf->pdev->dev,
  810. " rx_bytes = \t%lld \trx_unicast = \t\t%lld \trx_multicast = \t%lld\n",
  811. estats->rx_bytes, estats->rx_unicast, estats->rx_multicast);
  812. dev_info(&pf->pdev->dev,
  813. " rx_broadcast = \t%lld \trx_discards = \t\t%lld \trx_errors = \t%lld\n",
  814. estats->rx_broadcast, estats->rx_discards, estats->rx_errors);
  815. dev_info(&pf->pdev->dev,
  816. " rx_missed = \t%lld \trx_unknown_protocol = \t%lld \ttx_bytes = \t%lld\n",
  817. estats->rx_missed, estats->rx_unknown_protocol,
  818. estats->tx_bytes);
  819. dev_info(&pf->pdev->dev,
  820. " tx_unicast = \t%lld \ttx_multicast = \t\t%lld \ttx_broadcast = \t%lld\n",
  821. estats->tx_unicast, estats->tx_multicast, estats->tx_broadcast);
  822. dev_info(&pf->pdev->dev,
  823. " tx_discards = \t%lld \ttx_errors = \t\t%lld\n",
  824. estats->tx_discards, estats->tx_errors);
  825. }
  826. /**
  827. * i40e_dbg_dump_stats - handles dump stats write into command datum
  828. * @pf: the i40e_pf created in command write
  829. * @stats: the stats structure to be dumped
  830. **/
  831. static void i40e_dbg_dump_stats(struct i40e_pf *pf,
  832. struct i40e_hw_port_stats *stats)
  833. {
  834. int i;
  835. dev_info(&pf->pdev->dev, " stats:\n");
  836. dev_info(&pf->pdev->dev,
  837. " crc_errors = \t\t%lld \tillegal_bytes = \t%lld \terror_bytes = \t\t%lld\n",
  838. stats->crc_errors, stats->illegal_bytes, stats->error_bytes);
  839. dev_info(&pf->pdev->dev,
  840. " mac_local_faults = \t%lld \tmac_remote_faults = \t%lld \trx_length_errors = \t%lld\n",
  841. stats->mac_local_faults, stats->mac_remote_faults,
  842. stats->rx_length_errors);
  843. dev_info(&pf->pdev->dev,
  844. " link_xon_rx = \t\t%lld \tlink_xoff_rx = \t\t%lld \tlink_xon_tx = \t\t%lld\n",
  845. stats->link_xon_rx, stats->link_xoff_rx, stats->link_xon_tx);
  846. dev_info(&pf->pdev->dev,
  847. " link_xoff_tx = \t\t%lld \trx_size_64 = \t\t%lld \trx_size_127 = \t\t%lld\n",
  848. stats->link_xoff_tx, stats->rx_size_64, stats->rx_size_127);
  849. dev_info(&pf->pdev->dev,
  850. " rx_size_255 = \t\t%lld \trx_size_511 = \t\t%lld \trx_size_1023 = \t\t%lld\n",
  851. stats->rx_size_255, stats->rx_size_511, stats->rx_size_1023);
  852. dev_info(&pf->pdev->dev,
  853. " rx_size_big = \t\t%lld \trx_undersize = \t\t%lld \trx_jabber = \t\t%lld\n",
  854. stats->rx_size_big, stats->rx_undersize, stats->rx_jabber);
  855. dev_info(&pf->pdev->dev,
  856. " rx_fragments = \t\t%lld \trx_oversize = \t\t%lld \ttx_size_64 = \t\t%lld\n",
  857. stats->rx_fragments, stats->rx_oversize, stats->tx_size_64);
  858. dev_info(&pf->pdev->dev,
  859. " tx_size_127 = \t\t%lld \ttx_size_255 = \t\t%lld \ttx_size_511 = \t\t%lld\n",
  860. stats->tx_size_127, stats->tx_size_255, stats->tx_size_511);
  861. dev_info(&pf->pdev->dev,
  862. " tx_size_1023 = \t\t%lld \ttx_size_big = \t\t%lld \tmac_short_packet_dropped = \t%lld\n",
  863. stats->tx_size_1023, stats->tx_size_big,
  864. stats->mac_short_packet_dropped);
  865. for (i = 0; i < 8; i += 4) {
  866. dev_info(&pf->pdev->dev,
  867. " priority_xon_rx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
  868. i, stats->priority_xon_rx[i],
  869. i+1, stats->priority_xon_rx[i+1],
  870. i+2, stats->priority_xon_rx[i+2],
  871. i+3, stats->priority_xon_rx[i+3]);
  872. }
  873. for (i = 0; i < 8; i += 4) {
  874. dev_info(&pf->pdev->dev,
  875. " priority_xoff_rx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
  876. i, stats->priority_xoff_rx[i],
  877. i+1, stats->priority_xoff_rx[i+1],
  878. i+2, stats->priority_xoff_rx[i+2],
  879. i+3, stats->priority_xoff_rx[i+3]);
  880. }
  881. for (i = 0; i < 8; i += 4) {
  882. dev_info(&pf->pdev->dev,
  883. " priority_xon_tx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
  884. i, stats->priority_xon_tx[i],
  885. i+1, stats->priority_xon_tx[i+1],
  886. i+2, stats->priority_xon_tx[i+2],
  887. i+3, stats->priority_xon_rx[i+3]);
  888. }
  889. for (i = 0; i < 8; i += 4) {
  890. dev_info(&pf->pdev->dev,
  891. " priority_xoff_tx[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
  892. i, stats->priority_xoff_tx[i],
  893. i+1, stats->priority_xoff_tx[i+1],
  894. i+2, stats->priority_xoff_tx[i+2],
  895. i+3, stats->priority_xoff_tx[i+3]);
  896. }
  897. for (i = 0; i < 8; i += 4) {
  898. dev_info(&pf->pdev->dev,
  899. " priority_xon_2_xoff[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld \t[%d] = \t%lld\n",
  900. i, stats->priority_xon_2_xoff[i],
  901. i+1, stats->priority_xon_2_xoff[i+1],
  902. i+2, stats->priority_xon_2_xoff[i+2],
  903. i+3, stats->priority_xon_2_xoff[i+3]);
  904. }
  905. i40e_dbg_dump_eth_stats(pf, &stats->eth);
  906. }
  907. /**
  908. * i40e_dbg_dump_veb_seid - handles dump stats of a single given veb
  909. * @pf: the i40e_pf created in command write
  910. * @seid: the seid the user put in
  911. **/
  912. static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid)
  913. {
  914. struct i40e_veb *veb;
  915. if ((seid < I40E_BASE_VEB_SEID) ||
  916. (seid >= (I40E_MAX_VEB + I40E_BASE_VEB_SEID))) {
  917. dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
  918. return;
  919. }
  920. veb = i40e_dbg_find_veb(pf, seid);
  921. if (!veb) {
  922. dev_info(&pf->pdev->dev,
  923. "%d: can't find veb\n", seid);
  924. return;
  925. }
  926. dev_info(&pf->pdev->dev,
  927. "veb idx=%d,%d stats_ic=%d seid=%d uplink=%d\n",
  928. veb->idx, veb->veb_idx, veb->stats_idx, veb->seid,
  929. veb->uplink_seid);
  930. i40e_dbg_dump_eth_stats(pf, &veb->stats);
  931. }
  932. /**
  933. * i40e_dbg_dump_veb_all - dumps all known veb's stats
  934. * @pf: the i40e_pf created in command write
  935. **/
  936. static void i40e_dbg_dump_veb_all(struct i40e_pf *pf)
  937. {
  938. struct i40e_veb *veb;
  939. int i;
  940. for (i = 0; i < I40E_MAX_VEB; i++) {
  941. veb = pf->veb[i];
  942. if (veb)
  943. i40e_dbg_dump_veb_seid(pf, veb->seid);
  944. }
  945. }
  946. #define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
  947. /**
  948. * i40e_dbg_command_write - write into command datum
  949. * @filp: the opened file
  950. * @buffer: where to find the user's data
  951. * @count: the length of the user's data
  952. * @ppos: file position offset
  953. **/
  954. static ssize_t i40e_dbg_command_write(struct file *filp,
  955. const char __user *buffer,
  956. size_t count, loff_t *ppos)
  957. {
  958. struct i40e_pf *pf = filp->private_data;
  959. int bytes_not_copied;
  960. struct i40e_vsi *vsi;
  961. u8 *print_buf_start;
  962. u8 *print_buf;
  963. char *cmd_buf;
  964. int vsi_seid;
  965. int veb_seid;
  966. int cnt;
  967. /* don't allow partial writes */
  968. if (*ppos != 0)
  969. return 0;
  970. cmd_buf = kzalloc(count + 1, GFP_KERNEL);
  971. if (!cmd_buf)
  972. return count;
  973. bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
  974. if (bytes_not_copied < 0)
  975. return bytes_not_copied;
  976. if (bytes_not_copied > 0)
  977. count -= bytes_not_copied;
  978. cmd_buf[count] = '\0';
  979. print_buf_start = kzalloc(I40E_MAX_DEBUG_OUT_BUFFER, GFP_KERNEL);
  980. if (!print_buf_start)
  981. goto command_write_done;
  982. print_buf = print_buf_start;
  983. if (strncmp(cmd_buf, "add vsi", 7) == 0) {
  984. vsi_seid = -1;
  985. cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
  986. if (cnt == 0) {
  987. /* default to PF VSI */
  988. vsi_seid = pf->vsi[pf->lan_vsi]->seid;
  989. } else if (vsi_seid < 0) {
  990. dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n",
  991. vsi_seid);
  992. goto command_write_done;
  993. }
  994. vsi = i40e_vsi_setup(pf, I40E_VSI_VMDQ2, vsi_seid, 0);
  995. if (vsi)
  996. dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n",
  997. vsi->seid, vsi->uplink_seid);
  998. else
  999. dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf);
  1000. } else if (strncmp(cmd_buf, "del vsi", 7) == 0) {
  1001. sscanf(&cmd_buf[7], "%i", &vsi_seid);
  1002. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1003. if (!vsi) {
  1004. dev_info(&pf->pdev->dev, "del VSI %d: seid not found\n",
  1005. vsi_seid);
  1006. goto command_write_done;
  1007. }
  1008. dev_info(&pf->pdev->dev, "deleting VSI %d\n", vsi_seid);
  1009. i40e_vsi_release(vsi);
  1010. } else if (strncmp(cmd_buf, "add relay", 9) == 0) {
  1011. struct i40e_veb *veb;
  1012. int uplink_seid, i;
  1013. cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid);
  1014. if (cnt != 2) {
  1015. dev_info(&pf->pdev->dev,
  1016. "add relay: bad command string, cnt=%d\n",
  1017. cnt);
  1018. goto command_write_done;
  1019. } else if (uplink_seid < 0) {
  1020. dev_info(&pf->pdev->dev,
  1021. "add relay %d: bad uplink seid\n",
  1022. uplink_seid);
  1023. goto command_write_done;
  1024. }
  1025. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1026. if (!vsi) {
  1027. dev_info(&pf->pdev->dev,
  1028. "add relay: vsi VSI %d not found\n", vsi_seid);
  1029. goto command_write_done;
  1030. }
  1031. for (i = 0; i < I40E_MAX_VEB; i++)
  1032. if (pf->veb[i] && pf->veb[i]->seid == uplink_seid)
  1033. break;
  1034. if (i >= I40E_MAX_VEB && uplink_seid != 0 &&
  1035. uplink_seid != pf->mac_seid) {
  1036. dev_info(&pf->pdev->dev,
  1037. "add relay: relay uplink %d not found\n",
  1038. uplink_seid);
  1039. goto command_write_done;
  1040. }
  1041. veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid,
  1042. vsi->tc_config.enabled_tc);
  1043. if (veb)
  1044. dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid);
  1045. else
  1046. dev_info(&pf->pdev->dev, "add relay failed\n");
  1047. } else if (strncmp(cmd_buf, "del relay", 9) == 0) {
  1048. int i;
  1049. cnt = sscanf(&cmd_buf[9], "%i", &veb_seid);
  1050. if (cnt != 1) {
  1051. dev_info(&pf->pdev->dev,
  1052. "del relay: bad command string, cnt=%d\n",
  1053. cnt);
  1054. goto command_write_done;
  1055. } else if (veb_seid < 0) {
  1056. dev_info(&pf->pdev->dev,
  1057. "del relay %d: bad relay seid\n", veb_seid);
  1058. goto command_write_done;
  1059. }
  1060. /* find the veb */
  1061. for (i = 0; i < I40E_MAX_VEB; i++)
  1062. if (pf->veb[i] && pf->veb[i]->seid == veb_seid)
  1063. break;
  1064. if (i >= I40E_MAX_VEB) {
  1065. dev_info(&pf->pdev->dev,
  1066. "del relay: relay %d not found\n", veb_seid);
  1067. goto command_write_done;
  1068. }
  1069. dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid);
  1070. i40e_veb_release(pf->veb[i]);
  1071. } else if (strncmp(cmd_buf, "add macaddr", 11) == 0) {
  1072. u8 ma[6];
  1073. int vlan = 0;
  1074. struct i40e_mac_filter *f;
  1075. int ret;
  1076. cnt = sscanf(&cmd_buf[11],
  1077. "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
  1078. &vsi_seid,
  1079. &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
  1080. &vlan);
  1081. if (cnt == 7) {
  1082. vlan = 0;
  1083. } else if (cnt != 8) {
  1084. dev_info(&pf->pdev->dev,
  1085. "add macaddr: bad command string, cnt=%d\n",
  1086. cnt);
  1087. goto command_write_done;
  1088. }
  1089. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1090. if (!vsi) {
  1091. dev_info(&pf->pdev->dev,
  1092. "add macaddr: VSI %d not found\n", vsi_seid);
  1093. goto command_write_done;
  1094. }
  1095. f = i40e_add_filter(vsi, ma, vlan, false, false);
  1096. ret = i40e_sync_vsi_filters(vsi);
  1097. if (f && !ret)
  1098. dev_info(&pf->pdev->dev,
  1099. "add macaddr: %pM vlan=%d added to VSI %d\n",
  1100. ma, vlan, vsi_seid);
  1101. else
  1102. dev_info(&pf->pdev->dev,
  1103. "add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
  1104. ma, vlan, vsi_seid, f, ret);
  1105. } else if (strncmp(cmd_buf, "del macaddr", 11) == 0) {
  1106. u8 ma[6];
  1107. int vlan = 0;
  1108. int ret;
  1109. cnt = sscanf(&cmd_buf[11],
  1110. "%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
  1111. &vsi_seid,
  1112. &ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
  1113. &vlan);
  1114. if (cnt == 7) {
  1115. vlan = 0;
  1116. } else if (cnt != 8) {
  1117. dev_info(&pf->pdev->dev,
  1118. "del macaddr: bad command string, cnt=%d\n",
  1119. cnt);
  1120. goto command_write_done;
  1121. }
  1122. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1123. if (!vsi) {
  1124. dev_info(&pf->pdev->dev,
  1125. "del macaddr: VSI %d not found\n", vsi_seid);
  1126. goto command_write_done;
  1127. }
  1128. i40e_del_filter(vsi, ma, vlan, false, false);
  1129. ret = i40e_sync_vsi_filters(vsi);
  1130. if (!ret)
  1131. dev_info(&pf->pdev->dev,
  1132. "del macaddr: %pM vlan=%d removed from VSI %d\n",
  1133. ma, vlan, vsi_seid);
  1134. else
  1135. dev_info(&pf->pdev->dev,
  1136. "del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
  1137. ma, vlan, vsi_seid, ret);
  1138. } else if (strncmp(cmd_buf, "add pvid", 8) == 0) {
  1139. int v;
  1140. u16 vid;
  1141. i40e_status ret;
  1142. cnt = sscanf(&cmd_buf[8], "%i %u", &vsi_seid, &v);
  1143. if (cnt != 2) {
  1144. dev_info(&pf->pdev->dev,
  1145. "add pvid: bad command string, cnt=%d\n", cnt);
  1146. goto command_write_done;
  1147. }
  1148. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1149. if (!vsi) {
  1150. dev_info(&pf->pdev->dev, "add pvid: VSI %d not found\n",
  1151. vsi_seid);
  1152. goto command_write_done;
  1153. }
  1154. vid = (unsigned)v;
  1155. ret = i40e_vsi_add_pvid(vsi, vid);
  1156. if (!ret)
  1157. dev_info(&pf->pdev->dev,
  1158. "add pvid: %d added to VSI %d\n",
  1159. vid, vsi_seid);
  1160. else
  1161. dev_info(&pf->pdev->dev,
  1162. "add pvid: %d to VSI %d failed, ret=%d\n",
  1163. vid, vsi_seid, ret);
  1164. } else if (strncmp(cmd_buf, "del pvid", 8) == 0) {
  1165. cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
  1166. if (cnt != 1) {
  1167. dev_info(&pf->pdev->dev,
  1168. "del pvid: bad command string, cnt=%d\n",
  1169. cnt);
  1170. goto command_write_done;
  1171. }
  1172. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1173. if (!vsi) {
  1174. dev_info(&pf->pdev->dev,
  1175. "del pvid: VSI %d not found\n", vsi_seid);
  1176. goto command_write_done;
  1177. }
  1178. i40e_vsi_remove_pvid(vsi);
  1179. dev_info(&pf->pdev->dev,
  1180. "del pvid: removed from VSI %d\n", vsi_seid);
  1181. } else if (strncmp(cmd_buf, "dump", 4) == 0) {
  1182. if (strncmp(&cmd_buf[5], "switch", 6) == 0) {
  1183. i40e_fetch_switch_configuration(pf, true);
  1184. } else if (strncmp(&cmd_buf[5], "vsi", 3) == 0) {
  1185. cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
  1186. if (cnt > 0)
  1187. i40e_dbg_dump_vsi_seid(pf, vsi_seid);
  1188. else
  1189. i40e_dbg_dump_vsi_no_seid(pf);
  1190. } else if (strncmp(&cmd_buf[5], "veb", 3) == 0) {
  1191. cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
  1192. if (cnt > 0)
  1193. i40e_dbg_dump_veb_seid(pf, vsi_seid);
  1194. else
  1195. i40e_dbg_dump_veb_all(pf);
  1196. } else if (strncmp(&cmd_buf[5], "desc", 4) == 0) {
  1197. int ring_id, desc_n;
  1198. if (strncmp(&cmd_buf[10], "rx", 2) == 0) {
  1199. cnt = sscanf(&cmd_buf[12], "%i %i %i",
  1200. &vsi_seid, &ring_id, &desc_n);
  1201. i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
  1202. desc_n, pf, true);
  1203. } else if (strncmp(&cmd_buf[10], "tx", 2)
  1204. == 0) {
  1205. cnt = sscanf(&cmd_buf[12], "%i %i %i",
  1206. &vsi_seid, &ring_id, &desc_n);
  1207. i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
  1208. desc_n, pf, false);
  1209. } else if (strncmp(&cmd_buf[10], "aq", 2) == 0) {
  1210. i40e_dbg_dump_aq_desc(pf);
  1211. } else {
  1212. dev_info(&pf->pdev->dev,
  1213. "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
  1214. dev_info(&pf->pdev->dev,
  1215. "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
  1216. dev_info(&pf->pdev->dev, "dump desc aq\n");
  1217. }
  1218. } else if (strncmp(&cmd_buf[5], "stats", 5) == 0) {
  1219. dev_info(&pf->pdev->dev, "pf stats:\n");
  1220. i40e_dbg_dump_stats(pf, &pf->stats);
  1221. dev_info(&pf->pdev->dev, "pf stats_offsets:\n");
  1222. i40e_dbg_dump_stats(pf, &pf->stats_offsets);
  1223. } else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) {
  1224. dev_info(&pf->pdev->dev,
  1225. "core reset count: %d\n", pf->corer_count);
  1226. dev_info(&pf->pdev->dev,
  1227. "global reset count: %d\n", pf->globr_count);
  1228. dev_info(&pf->pdev->dev,
  1229. "emp reset count: %d\n", pf->empr_count);
  1230. dev_info(&pf->pdev->dev,
  1231. "pf reset count: %d\n", pf->pfr_count);
  1232. } else if (strncmp(&cmd_buf[5], "port", 4) == 0) {
  1233. struct i40e_aqc_query_port_ets_config_resp *bw_data;
  1234. struct i40e_dcbx_config *cfg =
  1235. &pf->hw.local_dcbx_config;
  1236. struct i40e_dcbx_config *r_cfg =
  1237. &pf->hw.remote_dcbx_config;
  1238. int i, ret;
  1239. bw_data = kzalloc(sizeof(
  1240. struct i40e_aqc_query_port_ets_config_resp),
  1241. GFP_KERNEL);
  1242. if (!bw_data) {
  1243. ret = -ENOMEM;
  1244. goto command_write_done;
  1245. }
  1246. ret = i40e_aq_query_port_ets_config(&pf->hw,
  1247. pf->mac_seid,
  1248. bw_data, NULL);
  1249. if (ret) {
  1250. dev_info(&pf->pdev->dev,
  1251. "Query Port ETS Config AQ command failed =0x%x\n",
  1252. pf->hw.aq.asq_last_status);
  1253. kfree(bw_data);
  1254. bw_data = NULL;
  1255. goto command_write_done;
  1256. }
  1257. dev_info(&pf->pdev->dev,
  1258. "port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
  1259. bw_data->tc_valid_bits,
  1260. bw_data->tc_strict_priority_bits,
  1261. le16_to_cpu(bw_data->tc_bw_max[0]),
  1262. le16_to_cpu(bw_data->tc_bw_max[1]));
  1263. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  1264. dev_info(&pf->pdev->dev, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
  1265. bw_data->tc_bw_share_credits[i],
  1266. le16_to_cpu(bw_data->tc_bw_limits[i]));
  1267. }
  1268. kfree(bw_data);
  1269. bw_data = NULL;
  1270. dev_info(&pf->pdev->dev,
  1271. "port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
  1272. cfg->etscfg.willing, cfg->etscfg.cbs,
  1273. cfg->etscfg.maxtcs);
  1274. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  1275. dev_info(&pf->pdev->dev, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
  1276. i, cfg->etscfg.prioritytable[i],
  1277. cfg->etscfg.tcbwtable[i],
  1278. cfg->etscfg.tsatable[i]);
  1279. }
  1280. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  1281. dev_info(&pf->pdev->dev, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
  1282. i, cfg->etsrec.prioritytable[i],
  1283. cfg->etsrec.tcbwtable[i],
  1284. cfg->etsrec.tsatable[i]);
  1285. }
  1286. dev_info(&pf->pdev->dev,
  1287. "port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
  1288. cfg->pfc.willing, cfg->pfc.mbc,
  1289. cfg->pfc.pfccap, cfg->pfc.pfcenable);
  1290. dev_info(&pf->pdev->dev,
  1291. "port app_table: num_apps=%d\n", cfg->numapps);
  1292. for (i = 0; i < cfg->numapps; i++) {
  1293. dev_info(&pf->pdev->dev, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
  1294. i, cfg->app[i].priority,
  1295. cfg->app[i].selector,
  1296. cfg->app[i].protocolid);
  1297. }
  1298. /* Peer TLV DCBX data */
  1299. dev_info(&pf->pdev->dev,
  1300. "remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
  1301. r_cfg->etscfg.willing,
  1302. r_cfg->etscfg.cbs, r_cfg->etscfg.maxtcs);
  1303. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  1304. dev_info(&pf->pdev->dev, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
  1305. i, r_cfg->etscfg.prioritytable[i],
  1306. r_cfg->etscfg.tcbwtable[i],
  1307. r_cfg->etscfg.tsatable[i]);
  1308. }
  1309. for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
  1310. dev_info(&pf->pdev->dev, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
  1311. i, r_cfg->etsrec.prioritytable[i],
  1312. r_cfg->etsrec.tcbwtable[i],
  1313. r_cfg->etsrec.tsatable[i]);
  1314. }
  1315. dev_info(&pf->pdev->dev,
  1316. "remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
  1317. r_cfg->pfc.willing,
  1318. r_cfg->pfc.mbc,
  1319. r_cfg->pfc.pfccap,
  1320. r_cfg->pfc.pfcenable);
  1321. dev_info(&pf->pdev->dev,
  1322. "remote port app_table: num_apps=%d\n",
  1323. r_cfg->numapps);
  1324. for (i = 0; i < r_cfg->numapps; i++) {
  1325. dev_info(&pf->pdev->dev, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
  1326. i, r_cfg->app[i].priority,
  1327. r_cfg->app[i].selector,
  1328. r_cfg->app[i].protocolid);
  1329. }
  1330. } else {
  1331. dev_info(&pf->pdev->dev,
  1332. "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
  1333. dev_info(&pf->pdev->dev, "dump switch, dump vsi [seid] or\n");
  1334. dev_info(&pf->pdev->dev, "dump stats\n");
  1335. dev_info(&pf->pdev->dev, "dump reset stats\n");
  1336. dev_info(&pf->pdev->dev, "dump port\n");
  1337. dev_info(&pf->pdev->dev,
  1338. "dump debug fwdata <cluster_id> <table_id> <index>\n");
  1339. }
  1340. } else if (strncmp(cmd_buf, "msg_enable", 10) == 0) {
  1341. u32 level;
  1342. cnt = sscanf(&cmd_buf[10], "%i", &level);
  1343. if (cnt) {
  1344. if (I40E_DEBUG_USER & level) {
  1345. pf->hw.debug_mask = level;
  1346. dev_info(&pf->pdev->dev,
  1347. "set hw.debug_mask = 0x%08x\n",
  1348. pf->hw.debug_mask);
  1349. }
  1350. pf->msg_enable = level;
  1351. dev_info(&pf->pdev->dev, "set msg_enable = 0x%08x\n",
  1352. pf->msg_enable);
  1353. } else {
  1354. dev_info(&pf->pdev->dev, "msg_enable = 0x%08x\n",
  1355. pf->msg_enable);
  1356. }
  1357. } else if (strncmp(cmd_buf, "pfr", 3) == 0) {
  1358. dev_info(&pf->pdev->dev, "forcing PFR\n");
  1359. i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
  1360. } else if (strncmp(cmd_buf, "corer", 5) == 0) {
  1361. dev_info(&pf->pdev->dev, "forcing CoreR\n");
  1362. i40e_do_reset(pf, (1 << __I40E_CORE_RESET_REQUESTED));
  1363. } else if (strncmp(cmd_buf, "globr", 5) == 0) {
  1364. dev_info(&pf->pdev->dev, "forcing GlobR\n");
  1365. i40e_do_reset(pf, (1 << __I40E_GLOBAL_RESET_REQUESTED));
  1366. } else if (strncmp(cmd_buf, "read", 4) == 0) {
  1367. u32 address;
  1368. u32 value;
  1369. cnt = sscanf(&cmd_buf[4], "%x", &address);
  1370. if (cnt != 1) {
  1371. dev_info(&pf->pdev->dev, "read <reg>\n");
  1372. goto command_write_done;
  1373. }
  1374. /* check the range on address */
  1375. if (address >= I40E_MAX_REGISTER) {
  1376. dev_info(&pf->pdev->dev, "read reg address 0x%08x too large\n",
  1377. address);
  1378. goto command_write_done;
  1379. }
  1380. value = rd32(&pf->hw, address);
  1381. dev_info(&pf->pdev->dev, "read: 0x%08x = 0x%08x\n",
  1382. address, value);
  1383. } else if (strncmp(cmd_buf, "write", 5) == 0) {
  1384. u32 address, value;
  1385. cnt = sscanf(&cmd_buf[5], "%x %x", &address, &value);
  1386. if (cnt != 2) {
  1387. dev_info(&pf->pdev->dev, "write <reg> <value>\n");
  1388. goto command_write_done;
  1389. }
  1390. /* check the range on address */
  1391. if (address >= I40E_MAX_REGISTER) {
  1392. dev_info(&pf->pdev->dev, "write reg address 0x%08x too large\n",
  1393. address);
  1394. goto command_write_done;
  1395. }
  1396. wr32(&pf->hw, address, value);
  1397. value = rd32(&pf->hw, address);
  1398. dev_info(&pf->pdev->dev, "write: 0x%08x = 0x%08x\n",
  1399. address, value);
  1400. } else if (strncmp(cmd_buf, "clear_stats", 11) == 0) {
  1401. if (strncmp(&cmd_buf[12], "vsi", 3) == 0) {
  1402. cnt = sscanf(&cmd_buf[15], "%d", &vsi_seid);
  1403. if (cnt == 0) {
  1404. int i;
  1405. for (i = 0; i < pf->hw.func_caps.num_vsis; i++)
  1406. i40e_vsi_reset_stats(pf->vsi[i]);
  1407. dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n");
  1408. } else if (cnt == 1) {
  1409. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1410. if (!vsi) {
  1411. dev_info(&pf->pdev->dev,
  1412. "clear_stats vsi: bad vsi %d\n",
  1413. vsi_seid);
  1414. goto command_write_done;
  1415. }
  1416. i40e_vsi_reset_stats(vsi);
  1417. dev_info(&pf->pdev->dev,
  1418. "vsi clear stats called for vsi %d\n",
  1419. vsi_seid);
  1420. } else {
  1421. dev_info(&pf->pdev->dev, "clear_stats vsi [seid]\n");
  1422. }
  1423. } else if (strncmp(&cmd_buf[12], "pf", 2) == 0) {
  1424. i40e_pf_reset_stats(pf);
  1425. dev_info(&pf->pdev->dev, "pf clear stats called\n");
  1426. } else {
  1427. dev_info(&pf->pdev->dev, "clear_stats vsi [seid] or clear_stats pf\n");
  1428. }
  1429. } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) ||
  1430. (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) {
  1431. struct i40e_fdir_data fd_data;
  1432. int ret;
  1433. u16 packet_len, i, j = 0;
  1434. char *asc_packet;
  1435. bool add = false;
  1436. asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
  1437. GFP_KERNEL);
  1438. if (!asc_packet)
  1439. goto command_write_done;
  1440. fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
  1441. GFP_KERNEL);
  1442. if (!fd_data.raw_packet) {
  1443. kfree(asc_packet);
  1444. asc_packet = NULL;
  1445. goto command_write_done;
  1446. }
  1447. if (strncmp(cmd_buf, "add", 3) == 0)
  1448. add = true;
  1449. cnt = sscanf(&cmd_buf[13],
  1450. "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %512s",
  1451. &fd_data.q_index,
  1452. &fd_data.flex_off, &fd_data.pctype,
  1453. &fd_data.dest_vsi, &fd_data.dest_ctl,
  1454. &fd_data.fd_status, &fd_data.cnt_index,
  1455. &fd_data.fd_id, &packet_len, asc_packet);
  1456. if (cnt != 10) {
  1457. dev_info(&pf->pdev->dev,
  1458. "program fd_filter: bad command string, cnt=%d\n",
  1459. cnt);
  1460. kfree(asc_packet);
  1461. asc_packet = NULL;
  1462. kfree(fd_data.raw_packet);
  1463. goto command_write_done;
  1464. }
  1465. /* fix packet length if user entered 0 */
  1466. if (packet_len == 0)
  1467. packet_len = I40E_FDIR_MAX_RAW_PACKET_LOOKUP;
  1468. /* make sure to check the max as well */
  1469. packet_len = min_t(u16,
  1470. packet_len, I40E_FDIR_MAX_RAW_PACKET_LOOKUP);
  1471. dev_info(&pf->pdev->dev, "FD raw packet:\n");
  1472. for (i = 0; i < packet_len; i++) {
  1473. sscanf(&asc_packet[j], "%2hhx ",
  1474. &fd_data.raw_packet[i]);
  1475. j += 3;
  1476. snprintf(print_buf, 3, "%02x ", fd_data.raw_packet[i]);
  1477. print_buf += 3;
  1478. if ((i % 16) == 15) {
  1479. snprintf(print_buf, 1, "\n");
  1480. print_buf++;
  1481. }
  1482. }
  1483. dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
  1484. ret = i40e_program_fdir_filter(&fd_data, pf, add);
  1485. if (!ret) {
  1486. dev_info(&pf->pdev->dev, "Filter command send Status : Success\n");
  1487. } else {
  1488. dev_info(&pf->pdev->dev,
  1489. "Filter command send failed %d\n", ret);
  1490. }
  1491. kfree(fd_data.raw_packet);
  1492. fd_data.raw_packet = NULL;
  1493. kfree(asc_packet);
  1494. asc_packet = NULL;
  1495. } else if (strncmp(cmd_buf, "lldp", 4) == 0) {
  1496. if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
  1497. int ret;
  1498. ret = i40e_aq_stop_lldp(&pf->hw, false, NULL);
  1499. if (ret) {
  1500. dev_info(&pf->pdev->dev,
  1501. "Stop LLDP AQ command failed =0x%x\n",
  1502. pf->hw.aq.asq_last_status);
  1503. goto command_write_done;
  1504. }
  1505. } else if (strncmp(&cmd_buf[5], "start", 5) == 0) {
  1506. int ret;
  1507. ret = i40e_aq_start_lldp(&pf->hw, NULL);
  1508. if (ret) {
  1509. dev_info(&pf->pdev->dev,
  1510. "Start LLDP AQ command failed =0x%x\n",
  1511. pf->hw.aq.asq_last_status);
  1512. goto command_write_done;
  1513. }
  1514. } else if (strncmp(&cmd_buf[5],
  1515. "get local", 9) == 0) {
  1516. int ret, i;
  1517. u8 *buff;
  1518. u16 llen, rlen;
  1519. buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
  1520. if (!buff)
  1521. goto command_write_done;
  1522. ret = i40e_aq_get_lldp_mib(&pf->hw, 0,
  1523. I40E_AQ_LLDP_MIB_LOCAL,
  1524. buff, I40E_LLDPDU_SIZE,
  1525. &llen, &rlen, NULL);
  1526. if (ret) {
  1527. dev_info(&pf->pdev->dev,
  1528. "Get LLDP MIB (local) AQ command failed =0x%x\n",
  1529. pf->hw.aq.asq_last_status);
  1530. kfree(buff);
  1531. buff = NULL;
  1532. goto command_write_done;
  1533. }
  1534. dev_info(&pf->pdev->dev,
  1535. "Get LLDP MIB (local) AQ buffer written back:\n");
  1536. for (i = 0; i < I40E_LLDPDU_SIZE; i++) {
  1537. snprintf(print_buf, 3, "%02x ", buff[i]);
  1538. print_buf += 3;
  1539. if ((i % 16) == 15) {
  1540. snprintf(print_buf, 1, "\n");
  1541. print_buf++;
  1542. }
  1543. }
  1544. dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
  1545. kfree(buff);
  1546. buff = NULL;
  1547. } else if (strncmp(&cmd_buf[5], "get remote", 10) == 0) {
  1548. int ret, i;
  1549. u8 *buff;
  1550. u16 llen, rlen;
  1551. buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
  1552. if (!buff)
  1553. goto command_write_done;
  1554. ret = i40e_aq_get_lldp_mib(&pf->hw,
  1555. I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE,
  1556. I40E_AQ_LLDP_MIB_LOCAL,
  1557. buff, I40E_LLDPDU_SIZE,
  1558. &llen, &rlen, NULL);
  1559. if (ret) {
  1560. dev_info(&pf->pdev->dev,
  1561. "Get LLDP MIB (remote) AQ command failed =0x%x\n",
  1562. pf->hw.aq.asq_last_status);
  1563. kfree(buff);
  1564. buff = NULL;
  1565. goto command_write_done;
  1566. }
  1567. dev_info(&pf->pdev->dev,
  1568. "Get LLDP MIB (remote) AQ buffer written back:\n");
  1569. for (i = 0; i < I40E_LLDPDU_SIZE; i++) {
  1570. snprintf(print_buf, 3, "%02x ", buff[i]);
  1571. print_buf += 3;
  1572. if ((i % 16) == 15) {
  1573. snprintf(print_buf, 1, "\n");
  1574. print_buf++;
  1575. }
  1576. }
  1577. dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
  1578. kfree(buff);
  1579. buff = NULL;
  1580. } else if (strncmp(&cmd_buf[5], "event on", 8) == 0) {
  1581. int ret;
  1582. ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
  1583. true, NULL);
  1584. if (ret) {
  1585. dev_info(&pf->pdev->dev,
  1586. "Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
  1587. pf->hw.aq.asq_last_status);
  1588. goto command_write_done;
  1589. }
  1590. } else if (strncmp(&cmd_buf[5], "event off", 9) == 0) {
  1591. int ret;
  1592. ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
  1593. false, NULL);
  1594. if (ret) {
  1595. dev_info(&pf->pdev->dev,
  1596. "Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
  1597. pf->hw.aq.asq_last_status);
  1598. goto command_write_done;
  1599. }
  1600. }
  1601. } else if (strncmp(cmd_buf, "nvm read", 8) == 0) {
  1602. u16 buffer_len, i, bytes;
  1603. u16 module;
  1604. u32 offset;
  1605. u16 *buff;
  1606. int ret;
  1607. cnt = sscanf(&cmd_buf[8], "%hx %x %hx",
  1608. &module, &offset, &buffer_len);
  1609. if (cnt == 0) {
  1610. module = 0;
  1611. offset = 0;
  1612. buffer_len = 0;
  1613. } else if (cnt == 1) {
  1614. offset = 0;
  1615. buffer_len = 0;
  1616. } else if (cnt == 2) {
  1617. buffer_len = 0;
  1618. } else if (cnt > 3) {
  1619. dev_info(&pf->pdev->dev,
  1620. "nvm read: bad command string, cnt=%d\n", cnt);
  1621. goto command_write_done;
  1622. }
  1623. /* Read at least 512 words */
  1624. if (buffer_len == 0)
  1625. buffer_len = 512;
  1626. bytes = 2 * buffer_len;
  1627. buff = kzalloc(bytes, GFP_KERNEL);
  1628. if (!buff)
  1629. goto command_write_done;
  1630. ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ);
  1631. if (ret) {
  1632. dev_info(&pf->pdev->dev,
  1633. "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
  1634. ret, pf->hw.aq.asq_last_status);
  1635. kfree(buff);
  1636. goto command_write_done;
  1637. }
  1638. ret = i40e_aq_read_nvm(&pf->hw, module, (2 * offset),
  1639. bytes, (u8 *)buff, true, NULL);
  1640. i40e_release_nvm(&pf->hw);
  1641. if (ret) {
  1642. dev_info(&pf->pdev->dev,
  1643. "Read NVM AQ failed err=%d status=0x%x\n",
  1644. ret, pf->hw.aq.asq_last_status);
  1645. } else {
  1646. dev_info(&pf->pdev->dev,
  1647. "Read NVM module=0x%x offset=0x%x words=%d\n",
  1648. module, offset, buffer_len);
  1649. for (i = 0; i < buffer_len; i++) {
  1650. if ((i % 16) == 0) {
  1651. snprintf(print_buf, 11, "\n0x%08x: ",
  1652. offset + i);
  1653. print_buf += 11;
  1654. }
  1655. snprintf(print_buf, 5, "%04x ", buff[i]);
  1656. print_buf += 5;
  1657. }
  1658. dev_info(&pf->pdev->dev, "%s\n", print_buf_start);
  1659. }
  1660. kfree(buff);
  1661. buff = NULL;
  1662. } else {
  1663. dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf);
  1664. dev_info(&pf->pdev->dev, "available commands\n");
  1665. dev_info(&pf->pdev->dev, " add vsi [relay_seid]\n");
  1666. dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n");
  1667. dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n");
  1668. dev_info(&pf->pdev->dev, " del relay <relay_seid>\n");
  1669. dev_info(&pf->pdev->dev, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
  1670. dev_info(&pf->pdev->dev, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
  1671. dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n");
  1672. dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n");
  1673. dev_info(&pf->pdev->dev, " dump switch\n");
  1674. dev_info(&pf->pdev->dev, " dump vsi [seid]\n");
  1675. dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
  1676. dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
  1677. dev_info(&pf->pdev->dev, " dump desc aq\n");
  1678. dev_info(&pf->pdev->dev, " dump stats\n");
  1679. dev_info(&pf->pdev->dev, " dump reset stats\n");
  1680. dev_info(&pf->pdev->dev, " msg_enable [level]\n");
  1681. dev_info(&pf->pdev->dev, " read <reg>\n");
  1682. dev_info(&pf->pdev->dev, " write <reg> <value>\n");
  1683. dev_info(&pf->pdev->dev, " clear_stats vsi [seid]\n");
  1684. dev_info(&pf->pdev->dev, " clear_stats pf\n");
  1685. dev_info(&pf->pdev->dev, " pfr\n");
  1686. dev_info(&pf->pdev->dev, " corer\n");
  1687. dev_info(&pf->pdev->dev, " globr\n");
  1688. 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");
  1689. 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");
  1690. dev_info(&pf->pdev->dev, " lldp start\n");
  1691. dev_info(&pf->pdev->dev, " lldp stop\n");
  1692. dev_info(&pf->pdev->dev, " lldp get local\n");
  1693. dev_info(&pf->pdev->dev, " lldp get remote\n");
  1694. dev_info(&pf->pdev->dev, " lldp event on\n");
  1695. dev_info(&pf->pdev->dev, " lldp event off\n");
  1696. dev_info(&pf->pdev->dev, " nvm read [module] [word_offset] [word_count]\n");
  1697. }
  1698. command_write_done:
  1699. kfree(cmd_buf);
  1700. cmd_buf = NULL;
  1701. kfree(print_buf_start);
  1702. print_buf = NULL;
  1703. print_buf_start = NULL;
  1704. return count;
  1705. }
  1706. static const struct file_operations i40e_dbg_command_fops = {
  1707. .owner = THIS_MODULE,
  1708. .open = simple_open,
  1709. .read = i40e_dbg_command_read,
  1710. .write = i40e_dbg_command_write,
  1711. };
  1712. /**************************************************************
  1713. * netdev_ops
  1714. * The netdev_ops entry in debugfs is for giving the driver commands
  1715. * to be executed from the netdev operations.
  1716. **************************************************************/
  1717. static char i40e_dbg_netdev_ops_buf[256] = "hello world";
  1718. /**
  1719. * i40e_dbg_netdev_ops - read for netdev_ops datum
  1720. * @filp: the opened file
  1721. * @buffer: where to write the data for the user to read
  1722. * @count: the size of the user's buffer
  1723. * @ppos: file position offset
  1724. **/
  1725. static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
  1726. size_t count, loff_t *ppos)
  1727. {
  1728. struct i40e_pf *pf = filp->private_data;
  1729. int bytes_not_copied;
  1730. int buf_size = 256;
  1731. char *buf;
  1732. int len;
  1733. /* don't allow partal reads */
  1734. if (*ppos != 0)
  1735. return 0;
  1736. if (count < buf_size)
  1737. return -ENOSPC;
  1738. buf = kzalloc(buf_size, GFP_KERNEL);
  1739. if (!buf)
  1740. return -ENOSPC;
  1741. len = snprintf(buf, buf_size, "%s: %s\n",
  1742. pf->vsi[pf->lan_vsi]->netdev->name,
  1743. i40e_dbg_netdev_ops_buf);
  1744. bytes_not_copied = copy_to_user(buffer, buf, len);
  1745. kfree(buf);
  1746. if (bytes_not_copied < 0)
  1747. return bytes_not_copied;
  1748. *ppos = len;
  1749. return len;
  1750. }
  1751. /**
  1752. * i40e_dbg_netdev_ops_write - write into netdev_ops datum
  1753. * @filp: the opened file
  1754. * @buffer: where to find the user's data
  1755. * @count: the length of the user's data
  1756. * @ppos: file position offset
  1757. **/
  1758. static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
  1759. const char __user *buffer,
  1760. size_t count, loff_t *ppos)
  1761. {
  1762. struct i40e_pf *pf = filp->private_data;
  1763. int bytes_not_copied;
  1764. struct i40e_vsi *vsi;
  1765. int vsi_seid;
  1766. int i, cnt;
  1767. /* don't allow partial writes */
  1768. if (*ppos != 0)
  1769. return 0;
  1770. if (count >= sizeof(i40e_dbg_netdev_ops_buf))
  1771. return -ENOSPC;
  1772. memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf));
  1773. bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf,
  1774. buffer, count);
  1775. if (bytes_not_copied < 0)
  1776. return bytes_not_copied;
  1777. else if (bytes_not_copied > 0)
  1778. count -= bytes_not_copied;
  1779. i40e_dbg_netdev_ops_buf[count] = '\0';
  1780. if (strncmp(i40e_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) {
  1781. cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
  1782. if (cnt != 1) {
  1783. dev_info(&pf->pdev->dev, "tx_timeout <vsi_seid>\n");
  1784. goto netdev_ops_write_done;
  1785. }
  1786. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1787. if (!vsi) {
  1788. dev_info(&pf->pdev->dev,
  1789. "tx_timeout: VSI %d not found\n", vsi_seid);
  1790. goto netdev_ops_write_done;
  1791. }
  1792. if (rtnl_trylock()) {
  1793. vsi->netdev->netdev_ops->ndo_tx_timeout(vsi->netdev);
  1794. rtnl_unlock();
  1795. dev_info(&pf->pdev->dev, "tx_timeout called\n");
  1796. } else {
  1797. dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
  1798. }
  1799. } else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
  1800. int mtu;
  1801. cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
  1802. &vsi_seid, &mtu);
  1803. if (cnt != 2) {
  1804. dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
  1805. goto netdev_ops_write_done;
  1806. }
  1807. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1808. if (!vsi) {
  1809. dev_info(&pf->pdev->dev,
  1810. "change_mtu: VSI %d not found\n", vsi_seid);
  1811. goto netdev_ops_write_done;
  1812. }
  1813. if (rtnl_trylock()) {
  1814. vsi->netdev->netdev_ops->ndo_change_mtu(vsi->netdev,
  1815. mtu);
  1816. rtnl_unlock();
  1817. dev_info(&pf->pdev->dev, "change_mtu called\n");
  1818. } else {
  1819. dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
  1820. }
  1821. } else if (strncmp(i40e_dbg_netdev_ops_buf, "set_rx_mode", 11) == 0) {
  1822. cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
  1823. if (cnt != 1) {
  1824. dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
  1825. goto netdev_ops_write_done;
  1826. }
  1827. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1828. if (!vsi) {
  1829. dev_info(&pf->pdev->dev,
  1830. "set_rx_mode: VSI %d not found\n", vsi_seid);
  1831. goto netdev_ops_write_done;
  1832. }
  1833. if (rtnl_trylock()) {
  1834. vsi->netdev->netdev_ops->ndo_set_rx_mode(vsi->netdev);
  1835. rtnl_unlock();
  1836. dev_info(&pf->pdev->dev, "set_rx_mode called\n");
  1837. } else {
  1838. dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
  1839. }
  1840. } else if (strncmp(i40e_dbg_netdev_ops_buf, "napi", 4) == 0) {
  1841. cnt = sscanf(&i40e_dbg_netdev_ops_buf[4], "%i", &vsi_seid);
  1842. if (cnt != 1) {
  1843. dev_info(&pf->pdev->dev, "napi <vsi_seid>\n");
  1844. goto netdev_ops_write_done;
  1845. }
  1846. vsi = i40e_dbg_find_vsi(pf, vsi_seid);
  1847. if (!vsi) {
  1848. dev_info(&pf->pdev->dev, "napi: VSI %d not found\n",
  1849. vsi_seid);
  1850. goto netdev_ops_write_done;
  1851. }
  1852. for (i = 0; i < vsi->num_q_vectors; i++)
  1853. napi_schedule(&vsi->q_vectors[i].napi);
  1854. dev_info(&pf->pdev->dev, "napi called\n");
  1855. } else {
  1856. dev_info(&pf->pdev->dev, "unknown command '%s'\n",
  1857. i40e_dbg_netdev_ops_buf);
  1858. dev_info(&pf->pdev->dev, "available commands\n");
  1859. dev_info(&pf->pdev->dev, " tx_timeout <vsi_seid>\n");
  1860. dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n");
  1861. dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n");
  1862. dev_info(&pf->pdev->dev, " napi <vsi_seid>\n");
  1863. }
  1864. netdev_ops_write_done:
  1865. return count;
  1866. }
  1867. static const struct file_operations i40e_dbg_netdev_ops_fops = {
  1868. .owner = THIS_MODULE,
  1869. .open = simple_open,
  1870. .read = i40e_dbg_netdev_ops_read,
  1871. .write = i40e_dbg_netdev_ops_write,
  1872. };
  1873. /**
  1874. * i40e_dbg_pf_init - setup the debugfs directory for the pf
  1875. * @pf: the pf that is starting up
  1876. **/
  1877. void i40e_dbg_pf_init(struct i40e_pf *pf)
  1878. {
  1879. struct dentry *pfile __attribute__((unused));
  1880. const char *name = pci_name(pf->pdev);
  1881. pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root);
  1882. if (pf->i40e_dbg_pf) {
  1883. pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf,
  1884. pf, &i40e_dbg_command_fops);
  1885. pfile = debugfs_create_file("dump", 0600, pf->i40e_dbg_pf, pf,
  1886. &i40e_dbg_dump_fops);
  1887. pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf,
  1888. pf, &i40e_dbg_netdev_ops_fops);
  1889. } else {
  1890. dev_info(&pf->pdev->dev,
  1891. "debugfs entry for %s failed\n", name);
  1892. }
  1893. }
  1894. /**
  1895. * i40e_dbg_pf_exit - clear out the pf's debugfs entries
  1896. * @pf: the pf that is stopping
  1897. **/
  1898. void i40e_dbg_pf_exit(struct i40e_pf *pf)
  1899. {
  1900. debugfs_remove_recursive(pf->i40e_dbg_pf);
  1901. pf->i40e_dbg_pf = NULL;
  1902. kfree(i40e_dbg_dump_buf);
  1903. i40e_dbg_dump_buf = NULL;
  1904. }
  1905. /**
  1906. * i40e_dbg_init - start up debugfs for the driver
  1907. **/
  1908. void i40e_dbg_init(void)
  1909. {
  1910. i40e_dbg_root = debugfs_create_dir(i40e_driver_name, NULL);
  1911. if (!i40e_dbg_root)
  1912. pr_info("init of debugfs failed\n");
  1913. }
  1914. /**
  1915. * i40e_dbg_exit - clean out the driver's debugfs entries
  1916. **/
  1917. void i40e_dbg_exit(void)
  1918. {
  1919. debugfs_remove_recursive(i40e_dbg_root);
  1920. i40e_dbg_root = NULL;
  1921. }
  1922. #endif /* CONFIG_DEBUG_FS */