lio_ethtool.c 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025
  1. /**********************************************************************
  2. * Author: Cavium, Inc.
  3. *
  4. * Contact: support@cavium.com
  5. * Please include "LiquidIO" in the subject.
  6. *
  7. * Copyright (c) 2003-2016 Cavium, Inc.
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more details.
  17. ***********************************************************************/
  18. #include <linux/netdevice.h>
  19. #include <linux/net_tstamp.h>
  20. #include <linux/pci.h>
  21. #include "liquidio_common.h"
  22. #include "octeon_droq.h"
  23. #include "octeon_iq.h"
  24. #include "response_manager.h"
  25. #include "octeon_device.h"
  26. #include "octeon_nic.h"
  27. #include "octeon_main.h"
  28. #include "octeon_network.h"
  29. #include "cn66xx_regs.h"
  30. #include "cn66xx_device.h"
  31. #include "cn23xx_pf_device.h"
  32. #include "cn23xx_vf_device.h"
  33. static int lio_reset_queues(struct net_device *netdev, uint32_t num_qs);
  34. struct oct_intrmod_context {
  35. int octeon_id;
  36. wait_queue_head_t wc;
  37. int cond;
  38. int status;
  39. };
  40. struct oct_intrmod_resp {
  41. u64 rh;
  42. struct oct_intrmod_cfg intrmod;
  43. u64 status;
  44. };
  45. struct oct_mdio_cmd_context {
  46. int octeon_id;
  47. wait_queue_head_t wc;
  48. int cond;
  49. };
  50. struct oct_mdio_cmd_resp {
  51. u64 rh;
  52. struct oct_mdio_cmd resp;
  53. u64 status;
  54. };
  55. #define OCT_MDIO45_RESP_SIZE (sizeof(struct oct_mdio_cmd_resp))
  56. /* Octeon's interface mode of operation */
  57. enum {
  58. INTERFACE_MODE_DISABLED,
  59. INTERFACE_MODE_RGMII,
  60. INTERFACE_MODE_GMII,
  61. INTERFACE_MODE_SPI,
  62. INTERFACE_MODE_PCIE,
  63. INTERFACE_MODE_XAUI,
  64. INTERFACE_MODE_SGMII,
  65. INTERFACE_MODE_PICMG,
  66. INTERFACE_MODE_NPI,
  67. INTERFACE_MODE_LOOP,
  68. INTERFACE_MODE_SRIO,
  69. INTERFACE_MODE_ILK,
  70. INTERFACE_MODE_RXAUI,
  71. INTERFACE_MODE_QSGMII,
  72. INTERFACE_MODE_AGL,
  73. INTERFACE_MODE_XLAUI,
  74. INTERFACE_MODE_XFI,
  75. INTERFACE_MODE_10G_KR,
  76. INTERFACE_MODE_40G_KR4,
  77. INTERFACE_MODE_MIXED,
  78. };
  79. #define OCT_ETHTOOL_REGDUMP_LEN 4096
  80. #define OCT_ETHTOOL_REGDUMP_LEN_23XX (4096 * 11)
  81. #define OCT_ETHTOOL_REGDUMP_LEN_23XX_VF (4096 * 2)
  82. #define OCT_ETHTOOL_REGSVER 1
  83. /* statistics of PF */
  84. static const char oct_stats_strings[][ETH_GSTRING_LEN] = {
  85. "rx_packets",
  86. "tx_packets",
  87. "rx_bytes",
  88. "tx_bytes",
  89. "rx_errors",
  90. "tx_errors",
  91. "rx_dropped",
  92. "tx_dropped",
  93. "tx_total_sent",
  94. "tx_total_fwd",
  95. "tx_err_pko",
  96. "tx_err_pki",
  97. "tx_err_link",
  98. "tx_err_drop",
  99. "tx_tso",
  100. "tx_tso_packets",
  101. "tx_tso_err",
  102. "tx_vxlan",
  103. "tx_mcast",
  104. "tx_bcast",
  105. "mac_tx_total_pkts",
  106. "mac_tx_total_bytes",
  107. "mac_tx_mcast_pkts",
  108. "mac_tx_bcast_pkts",
  109. "mac_tx_ctl_packets",
  110. "mac_tx_total_collisions",
  111. "mac_tx_one_collision",
  112. "mac_tx_multi_collision",
  113. "mac_tx_max_collision_fail",
  114. "mac_tx_max_deferal_fail",
  115. "mac_tx_fifo_err",
  116. "mac_tx_runts",
  117. "rx_total_rcvd",
  118. "rx_total_fwd",
  119. "rx_mcast",
  120. "rx_bcast",
  121. "rx_jabber_err",
  122. "rx_l2_err",
  123. "rx_frame_err",
  124. "rx_err_pko",
  125. "rx_err_link",
  126. "rx_err_drop",
  127. "rx_vxlan",
  128. "rx_vxlan_err",
  129. "rx_lro_pkts",
  130. "rx_lro_bytes",
  131. "rx_total_lro",
  132. "rx_lro_aborts",
  133. "rx_lro_aborts_port",
  134. "rx_lro_aborts_seq",
  135. "rx_lro_aborts_tsval",
  136. "rx_lro_aborts_timer",
  137. "rx_fwd_rate",
  138. "mac_rx_total_rcvd",
  139. "mac_rx_bytes",
  140. "mac_rx_total_bcst",
  141. "mac_rx_total_mcst",
  142. "mac_rx_runts",
  143. "mac_rx_ctl_packets",
  144. "mac_rx_fifo_err",
  145. "mac_rx_dma_drop",
  146. "mac_rx_fcs_err",
  147. "link_state_changes",
  148. };
  149. /* statistics of VF */
  150. static const char oct_vf_stats_strings[][ETH_GSTRING_LEN] = {
  151. "rx_packets",
  152. "tx_packets",
  153. "rx_bytes",
  154. "tx_bytes",
  155. "rx_errors",
  156. "tx_errors",
  157. "rx_dropped",
  158. "tx_dropped",
  159. "rx_mcast",
  160. "tx_mcast",
  161. "rx_bcast",
  162. "tx_bcast",
  163. "link_state_changes",
  164. };
  165. /* statistics of host tx queue */
  166. static const char oct_iq_stats_strings[][ETH_GSTRING_LEN] = {
  167. "packets",
  168. "bytes",
  169. "dropped",
  170. "iq_busy",
  171. "sgentry_sent",
  172. "fw_instr_posted",
  173. "fw_instr_processed",
  174. "fw_instr_dropped",
  175. "fw_bytes_sent",
  176. "tso",
  177. "vxlan",
  178. "txq_restart",
  179. };
  180. /* statistics of host rx queue */
  181. static const char oct_droq_stats_strings[][ETH_GSTRING_LEN] = {
  182. "packets",
  183. "bytes",
  184. "dropped",
  185. "dropped_nomem",
  186. "dropped_toomany",
  187. "fw_dropped",
  188. "fw_pkts_received",
  189. "fw_bytes_received",
  190. "fw_dropped_nodispatch",
  191. "vxlan",
  192. "buffer_alloc_failure",
  193. };
  194. /* LiquidIO driver private flags */
  195. static const char oct_priv_flags_strings[][ETH_GSTRING_LEN] = {
  196. };
  197. #define OCTNIC_NCMD_AUTONEG_ON 0x1
  198. #define OCTNIC_NCMD_PHY_ON 0x2
  199. static int lio_get_link_ksettings(struct net_device *netdev,
  200. struct ethtool_link_ksettings *ecmd)
  201. {
  202. struct lio *lio = GET_LIO(netdev);
  203. struct octeon_device *oct = lio->oct_dev;
  204. struct oct_link_info *linfo;
  205. u32 supported = 0, advertising = 0;
  206. linfo = &lio->linfo;
  207. switch (linfo->link.s.phy_type) {
  208. case LIO_PHY_PORT_TP:
  209. ecmd->base.port = PORT_TP;
  210. supported = (SUPPORTED_10000baseT_Full |
  211. SUPPORTED_TP | SUPPORTED_Pause);
  212. advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Pause);
  213. ecmd->base.autoneg = AUTONEG_DISABLE;
  214. break;
  215. case LIO_PHY_PORT_FIBRE:
  216. ecmd->base.port = PORT_FIBRE;
  217. if (linfo->link.s.speed == SPEED_10000) {
  218. supported = SUPPORTED_10000baseT_Full;
  219. advertising = ADVERTISED_10000baseT_Full;
  220. }
  221. supported |= SUPPORTED_FIBRE | SUPPORTED_Pause;
  222. advertising |= ADVERTISED_Pause;
  223. ecmd->base.autoneg = AUTONEG_DISABLE;
  224. break;
  225. }
  226. if (linfo->link.s.if_mode == INTERFACE_MODE_XAUI ||
  227. linfo->link.s.if_mode == INTERFACE_MODE_RXAUI ||
  228. linfo->link.s.if_mode == INTERFACE_MODE_XLAUI ||
  229. linfo->link.s.if_mode == INTERFACE_MODE_XFI) {
  230. ethtool_convert_legacy_u32_to_link_mode(
  231. ecmd->link_modes.supported, supported);
  232. ethtool_convert_legacy_u32_to_link_mode(
  233. ecmd->link_modes.advertising, advertising);
  234. } else {
  235. dev_err(&oct->pci_dev->dev, "Unknown link interface reported %d\n",
  236. linfo->link.s.if_mode);
  237. }
  238. if (linfo->link.s.link_up) {
  239. ecmd->base.speed = linfo->link.s.speed;
  240. ecmd->base.duplex = linfo->link.s.duplex;
  241. } else {
  242. ecmd->base.speed = SPEED_UNKNOWN;
  243. ecmd->base.duplex = DUPLEX_UNKNOWN;
  244. }
  245. return 0;
  246. }
  247. static void
  248. lio_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
  249. {
  250. struct lio *lio;
  251. struct octeon_device *oct;
  252. lio = GET_LIO(netdev);
  253. oct = lio->oct_dev;
  254. memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
  255. strcpy(drvinfo->driver, "liquidio");
  256. strcpy(drvinfo->version, LIQUIDIO_VERSION);
  257. strncpy(drvinfo->fw_version, oct->fw_info.liquidio_firmware_version,
  258. ETHTOOL_FWVERS_LEN);
  259. strncpy(drvinfo->bus_info, pci_name(oct->pci_dev), 32);
  260. }
  261. static void
  262. lio_get_vf_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
  263. {
  264. struct octeon_device *oct;
  265. struct lio *lio;
  266. lio = GET_LIO(netdev);
  267. oct = lio->oct_dev;
  268. memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
  269. strcpy(drvinfo->driver, "liquidio_vf");
  270. strcpy(drvinfo->version, LIQUIDIO_VERSION);
  271. strncpy(drvinfo->fw_version, oct->fw_info.liquidio_firmware_version,
  272. ETHTOOL_FWVERS_LEN);
  273. strncpy(drvinfo->bus_info, pci_name(oct->pci_dev), 32);
  274. }
  275. static int
  276. lio_send_queue_count_update(struct net_device *netdev, uint32_t num_queues)
  277. {
  278. struct lio *lio = GET_LIO(netdev);
  279. struct octeon_device *oct = lio->oct_dev;
  280. struct octnic_ctrl_pkt nctrl;
  281. int ret = 0;
  282. memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
  283. nctrl.ncmd.u64 = 0;
  284. nctrl.ncmd.s.cmd = OCTNET_CMD_QUEUE_COUNT_CTL;
  285. nctrl.ncmd.s.param1 = num_queues;
  286. nctrl.ncmd.s.param2 = num_queues;
  287. nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
  288. nctrl.wait_time = 100;
  289. nctrl.netpndev = (u64)netdev;
  290. nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
  291. ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
  292. if (ret < 0) {
  293. dev_err(&oct->pci_dev->dev, "Failed to send Queue reset command (ret: 0x%x)\n",
  294. ret);
  295. return -1;
  296. }
  297. return 0;
  298. }
  299. static void
  300. lio_ethtool_get_channels(struct net_device *dev,
  301. struct ethtool_channels *channel)
  302. {
  303. struct lio *lio = GET_LIO(dev);
  304. struct octeon_device *oct = lio->oct_dev;
  305. u32 max_rx = 0, max_tx = 0, tx_count = 0, rx_count = 0;
  306. u32 combined_count = 0, max_combined = 0;
  307. if (OCTEON_CN6XXX(oct)) {
  308. struct octeon_config *conf6x = CHIP_CONF(oct, cn6xxx);
  309. max_rx = CFG_GET_OQ_MAX_Q(conf6x);
  310. max_tx = CFG_GET_IQ_MAX_Q(conf6x);
  311. rx_count = CFG_GET_NUM_RXQS_NIC_IF(conf6x, lio->ifidx);
  312. tx_count = CFG_GET_NUM_TXQS_NIC_IF(conf6x, lio->ifidx);
  313. } else if (OCTEON_CN23XX_PF(oct)) {
  314. if (oct->sriov_info.sriov_enabled) {
  315. max_combined = lio->linfo.num_txpciq;
  316. } else {
  317. struct octeon_config *conf23_pf =
  318. CHIP_CONF(oct, cn23xx_pf);
  319. max_combined = CFG_GET_IQ_MAX_Q(conf23_pf);
  320. }
  321. combined_count = oct->num_iqs;
  322. } else if (OCTEON_CN23XX_VF(oct)) {
  323. u64 reg_val = 0ULL;
  324. u64 ctrl = CN23XX_VF_SLI_IQ_PKT_CONTROL64(0);
  325. reg_val = octeon_read_csr64(oct, ctrl);
  326. reg_val = reg_val >> CN23XX_PKT_INPUT_CTL_RPVF_POS;
  327. max_combined = reg_val & CN23XX_PKT_INPUT_CTL_RPVF_MASK;
  328. combined_count = oct->num_iqs;
  329. }
  330. channel->max_rx = max_rx;
  331. channel->max_tx = max_tx;
  332. channel->max_combined = max_combined;
  333. channel->rx_count = rx_count;
  334. channel->tx_count = tx_count;
  335. channel->combined_count = combined_count;
  336. }
  337. static int
  338. lio_irq_reallocate_irqs(struct octeon_device *oct, uint32_t num_ioqs)
  339. {
  340. struct msix_entry *msix_entries;
  341. int num_msix_irqs = 0;
  342. int i;
  343. if (!oct->msix_on)
  344. return 0;
  345. /* Disable the input and output queues now. No more packets will
  346. * arrive from Octeon.
  347. */
  348. oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR);
  349. if (oct->msix_on) {
  350. if (OCTEON_CN23XX_PF(oct))
  351. num_msix_irqs = oct->num_msix_irqs - 1;
  352. else if (OCTEON_CN23XX_VF(oct))
  353. num_msix_irqs = oct->num_msix_irqs;
  354. msix_entries = (struct msix_entry *)oct->msix_entries;
  355. for (i = 0; i < num_msix_irqs; i++) {
  356. if (oct->ioq_vector[i].vector) {
  357. /* clear the affinity_cpumask */
  358. irq_set_affinity_hint(msix_entries[i].vector,
  359. NULL);
  360. free_irq(msix_entries[i].vector,
  361. &oct->ioq_vector[i]);
  362. oct->ioq_vector[i].vector = 0;
  363. }
  364. }
  365. /* non-iov vector's argument is oct struct */
  366. if (OCTEON_CN23XX_PF(oct))
  367. free_irq(msix_entries[i].vector, oct);
  368. pci_disable_msix(oct->pci_dev);
  369. kfree(oct->msix_entries);
  370. oct->msix_entries = NULL;
  371. }
  372. kfree(oct->irq_name_storage);
  373. oct->irq_name_storage = NULL;
  374. if (octeon_allocate_ioq_vector(oct, num_ioqs)) {
  375. dev_err(&oct->pci_dev->dev, "OCTEON: ioq vector allocation failed\n");
  376. return -1;
  377. }
  378. if (octeon_setup_interrupt(oct, num_ioqs)) {
  379. dev_info(&oct->pci_dev->dev, "Setup interrupt failed\n");
  380. return -1;
  381. }
  382. /* Enable Octeon device interrupts */
  383. oct->fn_list.enable_interrupt(oct, OCTEON_ALL_INTR);
  384. return 0;
  385. }
  386. static int
  387. lio_ethtool_set_channels(struct net_device *dev,
  388. struct ethtool_channels *channel)
  389. {
  390. u32 combined_count, max_combined;
  391. struct lio *lio = GET_LIO(dev);
  392. struct octeon_device *oct = lio->oct_dev;
  393. int stopped = 0;
  394. if (strcmp(oct->fw_info.liquidio_firmware_version, "1.6.1") < 0) {
  395. dev_err(&oct->pci_dev->dev, "Minimum firmware version required is 1.6.1\n");
  396. return -EINVAL;
  397. }
  398. if (!channel->combined_count || channel->other_count ||
  399. channel->rx_count || channel->tx_count)
  400. return -EINVAL;
  401. combined_count = channel->combined_count;
  402. if (OCTEON_CN23XX_PF(oct)) {
  403. if (oct->sriov_info.sriov_enabled) {
  404. max_combined = lio->linfo.num_txpciq;
  405. } else {
  406. struct octeon_config *conf23_pf =
  407. CHIP_CONF(oct,
  408. cn23xx_pf);
  409. max_combined =
  410. CFG_GET_IQ_MAX_Q(conf23_pf);
  411. }
  412. } else if (OCTEON_CN23XX_VF(oct)) {
  413. u64 reg_val = 0ULL;
  414. u64 ctrl = CN23XX_VF_SLI_IQ_PKT_CONTROL64(0);
  415. reg_val = octeon_read_csr64(oct, ctrl);
  416. reg_val = reg_val >> CN23XX_PKT_INPUT_CTL_RPVF_POS;
  417. max_combined = reg_val & CN23XX_PKT_INPUT_CTL_RPVF_MASK;
  418. } else {
  419. return -EINVAL;
  420. }
  421. if (combined_count > max_combined || combined_count < 1)
  422. return -EINVAL;
  423. if (combined_count == oct->num_iqs)
  424. return 0;
  425. ifstate_set(lio, LIO_IFSTATE_RESETTING);
  426. if (netif_running(dev)) {
  427. dev->netdev_ops->ndo_stop(dev);
  428. stopped = 1;
  429. }
  430. if (lio_reset_queues(dev, combined_count))
  431. return -EINVAL;
  432. if (stopped)
  433. dev->netdev_ops->ndo_open(dev);
  434. ifstate_reset(lio, LIO_IFSTATE_RESETTING);
  435. return 0;
  436. }
  437. static int lio_get_eeprom_len(struct net_device *netdev)
  438. {
  439. u8 buf[192];
  440. struct lio *lio = GET_LIO(netdev);
  441. struct octeon_device *oct_dev = lio->oct_dev;
  442. struct octeon_board_info *board_info;
  443. int len;
  444. board_info = (struct octeon_board_info *)(&oct_dev->boardinfo);
  445. len = sprintf(buf, "boardname:%s serialnum:%s maj:%lld min:%lld\n",
  446. board_info->name, board_info->serial_number,
  447. board_info->major, board_info->minor);
  448. return len;
  449. }
  450. static int
  451. lio_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
  452. u8 *bytes)
  453. {
  454. struct lio *lio = GET_LIO(netdev);
  455. struct octeon_device *oct_dev = lio->oct_dev;
  456. struct octeon_board_info *board_info;
  457. if (eeprom->offset)
  458. return -EINVAL;
  459. eeprom->magic = oct_dev->pci_dev->vendor;
  460. board_info = (struct octeon_board_info *)(&oct_dev->boardinfo);
  461. sprintf((char *)bytes,
  462. "boardname:%s serialnum:%s maj:%lld min:%lld\n",
  463. board_info->name, board_info->serial_number,
  464. board_info->major, board_info->minor);
  465. return 0;
  466. }
  467. static int octnet_gpio_access(struct net_device *netdev, int addr, int val)
  468. {
  469. struct lio *lio = GET_LIO(netdev);
  470. struct octeon_device *oct = lio->oct_dev;
  471. struct octnic_ctrl_pkt nctrl;
  472. int ret = 0;
  473. memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
  474. nctrl.ncmd.u64 = 0;
  475. nctrl.ncmd.s.cmd = OCTNET_CMD_GPIO_ACCESS;
  476. nctrl.ncmd.s.param1 = addr;
  477. nctrl.ncmd.s.param2 = val;
  478. nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
  479. nctrl.wait_time = 100;
  480. nctrl.netpndev = (u64)netdev;
  481. nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
  482. ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
  483. if (ret < 0) {
  484. dev_err(&oct->pci_dev->dev, "Failed to configure gpio value\n");
  485. return -EINVAL;
  486. }
  487. return 0;
  488. }
  489. static int octnet_id_active(struct net_device *netdev, int val)
  490. {
  491. struct lio *lio = GET_LIO(netdev);
  492. struct octeon_device *oct = lio->oct_dev;
  493. struct octnic_ctrl_pkt nctrl;
  494. int ret = 0;
  495. memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
  496. nctrl.ncmd.u64 = 0;
  497. nctrl.ncmd.s.cmd = OCTNET_CMD_ID_ACTIVE;
  498. nctrl.ncmd.s.param1 = val;
  499. nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
  500. nctrl.wait_time = 100;
  501. nctrl.netpndev = (u64)netdev;
  502. nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
  503. ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
  504. if (ret < 0) {
  505. dev_err(&oct->pci_dev->dev, "Failed to configure gpio value\n");
  506. return -EINVAL;
  507. }
  508. return 0;
  509. }
  510. /* Callback for when mdio command response arrives
  511. */
  512. static void octnet_mdio_resp_callback(struct octeon_device *oct,
  513. u32 status,
  514. void *buf)
  515. {
  516. struct oct_mdio_cmd_context *mdio_cmd_ctx;
  517. struct octeon_soft_command *sc = (struct octeon_soft_command *)buf;
  518. mdio_cmd_ctx = (struct oct_mdio_cmd_context *)sc->ctxptr;
  519. oct = lio_get_device(mdio_cmd_ctx->octeon_id);
  520. if (status) {
  521. dev_err(&oct->pci_dev->dev, "MIDO instruction failed. Status: %llx\n",
  522. CVM_CAST64(status));
  523. WRITE_ONCE(mdio_cmd_ctx->cond, -1);
  524. } else {
  525. WRITE_ONCE(mdio_cmd_ctx->cond, 1);
  526. }
  527. wake_up_interruptible(&mdio_cmd_ctx->wc);
  528. }
  529. /* This routine provides PHY access routines for
  530. * mdio clause45 .
  531. */
  532. static int
  533. octnet_mdio45_access(struct lio *lio, int op, int loc, int *value)
  534. {
  535. struct octeon_device *oct_dev = lio->oct_dev;
  536. struct octeon_soft_command *sc;
  537. struct oct_mdio_cmd_resp *mdio_cmd_rsp;
  538. struct oct_mdio_cmd_context *mdio_cmd_ctx;
  539. struct oct_mdio_cmd *mdio_cmd;
  540. int retval = 0;
  541. sc = (struct octeon_soft_command *)
  542. octeon_alloc_soft_command(oct_dev,
  543. sizeof(struct oct_mdio_cmd),
  544. sizeof(struct oct_mdio_cmd_resp),
  545. sizeof(struct oct_mdio_cmd_context));
  546. if (!sc)
  547. return -ENOMEM;
  548. mdio_cmd_ctx = (struct oct_mdio_cmd_context *)sc->ctxptr;
  549. mdio_cmd_rsp = (struct oct_mdio_cmd_resp *)sc->virtrptr;
  550. mdio_cmd = (struct oct_mdio_cmd *)sc->virtdptr;
  551. WRITE_ONCE(mdio_cmd_ctx->cond, 0);
  552. mdio_cmd_ctx->octeon_id = lio_get_device_id(oct_dev);
  553. mdio_cmd->op = op;
  554. mdio_cmd->mdio_addr = loc;
  555. if (op)
  556. mdio_cmd->value1 = *value;
  557. octeon_swap_8B_data((u64 *)mdio_cmd, sizeof(struct oct_mdio_cmd) / 8);
  558. sc->iq_no = lio->linfo.txpciq[0].s.q_no;
  559. octeon_prepare_soft_command(oct_dev, sc, OPCODE_NIC, OPCODE_NIC_MDIO45,
  560. 0, 0, 0);
  561. sc->wait_time = 1000;
  562. sc->callback = octnet_mdio_resp_callback;
  563. sc->callback_arg = sc;
  564. init_waitqueue_head(&mdio_cmd_ctx->wc);
  565. retval = octeon_send_soft_command(oct_dev, sc);
  566. if (retval == IQ_SEND_FAILED) {
  567. dev_err(&oct_dev->pci_dev->dev,
  568. "octnet_mdio45_access instruction failed status: %x\n",
  569. retval);
  570. retval = -EBUSY;
  571. } else {
  572. /* Sleep on a wait queue till the cond flag indicates that the
  573. * response arrived
  574. */
  575. sleep_cond(&mdio_cmd_ctx->wc, &mdio_cmd_ctx->cond);
  576. retval = mdio_cmd_rsp->status;
  577. if (retval) {
  578. dev_err(&oct_dev->pci_dev->dev, "octnet mdio45 access failed\n");
  579. retval = -EBUSY;
  580. } else {
  581. octeon_swap_8B_data((u64 *)(&mdio_cmd_rsp->resp),
  582. sizeof(struct oct_mdio_cmd) / 8);
  583. if (READ_ONCE(mdio_cmd_ctx->cond) == 1) {
  584. if (!op)
  585. *value = mdio_cmd_rsp->resp.value1;
  586. } else {
  587. retval = -EINVAL;
  588. }
  589. }
  590. }
  591. octeon_free_soft_command(oct_dev, sc);
  592. return retval;
  593. }
  594. static int lio_set_phys_id(struct net_device *netdev,
  595. enum ethtool_phys_id_state state)
  596. {
  597. struct lio *lio = GET_LIO(netdev);
  598. struct octeon_device *oct = lio->oct_dev;
  599. int value, ret;
  600. switch (state) {
  601. case ETHTOOL_ID_ACTIVE:
  602. if (oct->chip_id == OCTEON_CN66XX) {
  603. octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
  604. VITESSE_PHY_GPIO_DRIVEON);
  605. return 2;
  606. } else if (oct->chip_id == OCTEON_CN68XX) {
  607. /* Save the current LED settings */
  608. ret = octnet_mdio45_access(lio, 0,
  609. LIO68XX_LED_BEACON_ADDR,
  610. &lio->phy_beacon_val);
  611. if (ret)
  612. return ret;
  613. ret = octnet_mdio45_access(lio, 0,
  614. LIO68XX_LED_CTRL_ADDR,
  615. &lio->led_ctrl_val);
  616. if (ret)
  617. return ret;
  618. /* Configure Beacon values */
  619. value = LIO68XX_LED_BEACON_CFGON;
  620. ret = octnet_mdio45_access(lio, 1,
  621. LIO68XX_LED_BEACON_ADDR,
  622. &value);
  623. if (ret)
  624. return ret;
  625. value = LIO68XX_LED_CTRL_CFGON;
  626. ret = octnet_mdio45_access(lio, 1,
  627. LIO68XX_LED_CTRL_ADDR,
  628. &value);
  629. if (ret)
  630. return ret;
  631. } else if (oct->chip_id == OCTEON_CN23XX_PF_VID) {
  632. octnet_id_active(netdev, LED_IDENTIFICATION_ON);
  633. /* returns 0 since updates are asynchronous */
  634. return 0;
  635. } else {
  636. return -EINVAL;
  637. }
  638. break;
  639. case ETHTOOL_ID_ON:
  640. if (oct->chip_id == OCTEON_CN66XX)
  641. octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
  642. VITESSE_PHY_GPIO_HIGH);
  643. else
  644. return -EINVAL;
  645. break;
  646. case ETHTOOL_ID_OFF:
  647. if (oct->chip_id == OCTEON_CN66XX)
  648. octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
  649. VITESSE_PHY_GPIO_LOW);
  650. else
  651. return -EINVAL;
  652. break;
  653. case ETHTOOL_ID_INACTIVE:
  654. if (oct->chip_id == OCTEON_CN66XX) {
  655. octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
  656. VITESSE_PHY_GPIO_DRIVEOFF);
  657. } else if (oct->chip_id == OCTEON_CN68XX) {
  658. /* Restore LED settings */
  659. ret = octnet_mdio45_access(lio, 1,
  660. LIO68XX_LED_CTRL_ADDR,
  661. &lio->led_ctrl_val);
  662. if (ret)
  663. return ret;
  664. ret = octnet_mdio45_access(lio, 1,
  665. LIO68XX_LED_BEACON_ADDR,
  666. &lio->phy_beacon_val);
  667. if (ret)
  668. return ret;
  669. } else if (oct->chip_id == OCTEON_CN23XX_PF_VID) {
  670. octnet_id_active(netdev, LED_IDENTIFICATION_OFF);
  671. return 0;
  672. } else {
  673. return -EINVAL;
  674. }
  675. break;
  676. default:
  677. return -EINVAL;
  678. }
  679. return 0;
  680. }
  681. static void
  682. lio_ethtool_get_ringparam(struct net_device *netdev,
  683. struct ethtool_ringparam *ering)
  684. {
  685. struct lio *lio = GET_LIO(netdev);
  686. struct octeon_device *oct = lio->oct_dev;
  687. u32 tx_max_pending = 0, rx_max_pending = 0, tx_pending = 0,
  688. rx_pending = 0;
  689. if (ifstate_check(lio, LIO_IFSTATE_RESETTING))
  690. return;
  691. if (OCTEON_CN6XXX(oct)) {
  692. struct octeon_config *conf6x = CHIP_CONF(oct, cn6xxx);
  693. tx_max_pending = CN6XXX_MAX_IQ_DESCRIPTORS;
  694. rx_max_pending = CN6XXX_MAX_OQ_DESCRIPTORS;
  695. rx_pending = CFG_GET_NUM_RX_DESCS_NIC_IF(conf6x, lio->ifidx);
  696. tx_pending = CFG_GET_NUM_TX_DESCS_NIC_IF(conf6x, lio->ifidx);
  697. } else if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct)) {
  698. tx_max_pending = CN23XX_MAX_IQ_DESCRIPTORS;
  699. rx_max_pending = CN23XX_MAX_OQ_DESCRIPTORS;
  700. rx_pending = oct->droq[0]->max_count;
  701. tx_pending = oct->instr_queue[0]->max_count;
  702. }
  703. ering->tx_pending = tx_pending;
  704. ering->tx_max_pending = tx_max_pending;
  705. ering->rx_pending = rx_pending;
  706. ering->rx_max_pending = rx_max_pending;
  707. ering->rx_mini_pending = 0;
  708. ering->rx_jumbo_pending = 0;
  709. ering->rx_mini_max_pending = 0;
  710. ering->rx_jumbo_max_pending = 0;
  711. }
  712. static int lio_23xx_reconfigure_queue_count(struct lio *lio)
  713. {
  714. struct octeon_device *oct = lio->oct_dev;
  715. struct liquidio_if_cfg_context *ctx;
  716. u32 resp_size, ctx_size, data_size;
  717. struct liquidio_if_cfg_resp *resp;
  718. struct octeon_soft_command *sc;
  719. union oct_nic_if_cfg if_cfg;
  720. struct lio_version *vdata;
  721. u32 ifidx_or_pfnum;
  722. int retval;
  723. int j;
  724. resp_size = sizeof(struct liquidio_if_cfg_resp);
  725. ctx_size = sizeof(struct liquidio_if_cfg_context);
  726. data_size = sizeof(struct lio_version);
  727. sc = (struct octeon_soft_command *)
  728. octeon_alloc_soft_command(oct, data_size,
  729. resp_size, ctx_size);
  730. if (!sc) {
  731. dev_err(&oct->pci_dev->dev, "%s: Failed to allocate soft command\n",
  732. __func__);
  733. return -1;
  734. }
  735. resp = (struct liquidio_if_cfg_resp *)sc->virtrptr;
  736. ctx = (struct liquidio_if_cfg_context *)sc->ctxptr;
  737. vdata = (struct lio_version *)sc->virtdptr;
  738. vdata->major = (__force u16)cpu_to_be16(LIQUIDIO_BASE_MAJOR_VERSION);
  739. vdata->minor = (__force u16)cpu_to_be16(LIQUIDIO_BASE_MINOR_VERSION);
  740. vdata->micro = (__force u16)cpu_to_be16(LIQUIDIO_BASE_MICRO_VERSION);
  741. ifidx_or_pfnum = oct->pf_num;
  742. WRITE_ONCE(ctx->cond, 0);
  743. ctx->octeon_id = lio_get_device_id(oct);
  744. init_waitqueue_head(&ctx->wc);
  745. if_cfg.u64 = 0;
  746. if_cfg.s.num_iqueues = oct->sriov_info.num_pf_rings;
  747. if_cfg.s.num_oqueues = oct->sriov_info.num_pf_rings;
  748. if_cfg.s.base_queue = oct->sriov_info.pf_srn;
  749. if_cfg.s.gmx_port_id = oct->pf_num;
  750. sc->iq_no = 0;
  751. octeon_prepare_soft_command(oct, sc, OPCODE_NIC,
  752. OPCODE_NIC_QCOUNT_UPDATE, 0,
  753. if_cfg.u64, 0);
  754. sc->callback = lio_if_cfg_callback;
  755. sc->callback_arg = sc;
  756. sc->wait_time = LIO_IFCFG_WAIT_TIME;
  757. retval = octeon_send_soft_command(oct, sc);
  758. if (retval == IQ_SEND_FAILED) {
  759. dev_err(&oct->pci_dev->dev,
  760. "iq/oq config failed status: %x\n",
  761. retval);
  762. goto qcount_update_fail;
  763. }
  764. if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR) {
  765. dev_err(&oct->pci_dev->dev, "Wait interrupted\n");
  766. return -1;
  767. }
  768. retval = resp->status;
  769. if (retval) {
  770. dev_err(&oct->pci_dev->dev, "iq/oq config failed\n");
  771. goto qcount_update_fail;
  772. }
  773. octeon_swap_8B_data((u64 *)(&resp->cfg_info),
  774. (sizeof(struct liquidio_if_cfg_info)) >> 3);
  775. lio->ifidx = ifidx_or_pfnum;
  776. lio->linfo.num_rxpciq = hweight64(resp->cfg_info.iqmask);
  777. lio->linfo.num_txpciq = hweight64(resp->cfg_info.iqmask);
  778. for (j = 0; j < lio->linfo.num_rxpciq; j++) {
  779. lio->linfo.rxpciq[j].u64 =
  780. resp->cfg_info.linfo.rxpciq[j].u64;
  781. }
  782. for (j = 0; j < lio->linfo.num_txpciq; j++) {
  783. lio->linfo.txpciq[j].u64 =
  784. resp->cfg_info.linfo.txpciq[j].u64;
  785. }
  786. lio->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
  787. lio->linfo.gmxport = resp->cfg_info.linfo.gmxport;
  788. lio->linfo.link.u64 = resp->cfg_info.linfo.link.u64;
  789. lio->txq = lio->linfo.txpciq[0].s.q_no;
  790. lio->rxq = lio->linfo.rxpciq[0].s.q_no;
  791. octeon_free_soft_command(oct, sc);
  792. dev_info(&oct->pci_dev->dev, "Queue count updated to %d\n",
  793. lio->linfo.num_rxpciq);
  794. return 0;
  795. qcount_update_fail:
  796. octeon_free_soft_command(oct, sc);
  797. return -1;
  798. }
  799. static int lio_reset_queues(struct net_device *netdev, uint32_t num_qs)
  800. {
  801. struct lio *lio = GET_LIO(netdev);
  802. struct octeon_device *oct = lio->oct_dev;
  803. int i, queue_count_update = 0;
  804. struct napi_struct *napi, *n;
  805. int ret;
  806. schedule_timeout_uninterruptible(msecs_to_jiffies(100));
  807. if (wait_for_pending_requests(oct))
  808. dev_err(&oct->pci_dev->dev, "There were pending requests\n");
  809. if (lio_wait_for_instr_fetch(oct))
  810. dev_err(&oct->pci_dev->dev, "IQ had pending instructions\n");
  811. if (octeon_set_io_queues_off(oct)) {
  812. dev_err(&oct->pci_dev->dev, "Setting io queues off failed\n");
  813. return -1;
  814. }
  815. /* Disable the input and output queues now. No more packets will
  816. * arrive from Octeon.
  817. */
  818. oct->fn_list.disable_io_queues(oct);
  819. /* Delete NAPI */
  820. list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list)
  821. netif_napi_del(napi);
  822. if (num_qs != oct->num_iqs) {
  823. ret = netif_set_real_num_rx_queues(netdev, num_qs);
  824. if (ret) {
  825. dev_err(&oct->pci_dev->dev,
  826. "Setting real number rx failed\n");
  827. return ret;
  828. }
  829. ret = netif_set_real_num_tx_queues(netdev, num_qs);
  830. if (ret) {
  831. dev_err(&oct->pci_dev->dev,
  832. "Setting real number tx failed\n");
  833. return ret;
  834. }
  835. /* The value of queue_count_update decides whether it is the
  836. * queue count or the descriptor count that is being
  837. * re-configured.
  838. */
  839. queue_count_update = 1;
  840. }
  841. /* Re-configuration of queues can happen in two scenarios, SRIOV enabled
  842. * and SRIOV disabled. Few things like recreating queue zero, resetting
  843. * glists and IRQs are required for both. For the latter, some more
  844. * steps like updating sriov_info for the octeon device need to be done.
  845. */
  846. if (queue_count_update) {
  847. lio_delete_glists(lio);
  848. /* Delete mbox for PF which is SRIOV disabled because sriov_info
  849. * will be now changed.
  850. */
  851. if ((OCTEON_CN23XX_PF(oct)) && !oct->sriov_info.sriov_enabled)
  852. oct->fn_list.free_mbox(oct);
  853. }
  854. for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct); i++) {
  855. if (!(oct->io_qmask.oq & BIT_ULL(i)))
  856. continue;
  857. octeon_delete_droq(oct, i);
  858. }
  859. for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
  860. if (!(oct->io_qmask.iq & BIT_ULL(i)))
  861. continue;
  862. octeon_delete_instr_queue(oct, i);
  863. }
  864. if (queue_count_update) {
  865. /* For PF re-configure sriov related information */
  866. if ((OCTEON_CN23XX_PF(oct)) &&
  867. !oct->sriov_info.sriov_enabled) {
  868. oct->sriov_info.num_pf_rings = num_qs;
  869. if (cn23xx_sriov_config(oct)) {
  870. dev_err(&oct->pci_dev->dev,
  871. "Queue reset aborted: SRIOV config failed\n");
  872. return -1;
  873. }
  874. num_qs = oct->sriov_info.num_pf_rings;
  875. }
  876. }
  877. if (oct->fn_list.setup_device_regs(oct)) {
  878. dev_err(&oct->pci_dev->dev, "Failed to configure device registers\n");
  879. return -1;
  880. }
  881. /* The following are needed in case of queue count re-configuration and
  882. * not for descriptor count re-configuration.
  883. */
  884. if (queue_count_update) {
  885. if (octeon_setup_instr_queues(oct))
  886. return -1;
  887. if (octeon_setup_output_queues(oct))
  888. return -1;
  889. /* Recreating mbox for PF that is SRIOV disabled */
  890. if (OCTEON_CN23XX_PF(oct) && !oct->sriov_info.sriov_enabled) {
  891. if (oct->fn_list.setup_mbox(oct)) {
  892. dev_err(&oct->pci_dev->dev, "Mailbox setup failed\n");
  893. return -1;
  894. }
  895. }
  896. /* Deleting and recreating IRQs whether the interface is SRIOV
  897. * enabled or disabled.
  898. */
  899. if (lio_irq_reallocate_irqs(oct, num_qs)) {
  900. dev_err(&oct->pci_dev->dev, "IRQs could not be allocated\n");
  901. return -1;
  902. }
  903. /* Enable the input and output queues for this Octeon device */
  904. if (oct->fn_list.enable_io_queues(oct)) {
  905. dev_err(&oct->pci_dev->dev, "Failed to enable input/output queues\n");
  906. return -1;
  907. }
  908. for (i = 0; i < oct->num_oqs; i++)
  909. writel(oct->droq[i]->max_count,
  910. oct->droq[i]->pkts_credit_reg);
  911. /* Informing firmware about the new queue count. It is required
  912. * for firmware to allocate more number of queues than those at
  913. * load time.
  914. */
  915. if (OCTEON_CN23XX_PF(oct) && !oct->sriov_info.sriov_enabled) {
  916. if (lio_23xx_reconfigure_queue_count(lio))
  917. return -1;
  918. }
  919. }
  920. /* Once firmware is aware of the new value, queues can be recreated */
  921. if (liquidio_setup_io_queues(oct, 0, num_qs, num_qs)) {
  922. dev_err(&oct->pci_dev->dev, "I/O queues creation failed\n");
  923. return -1;
  924. }
  925. if (queue_count_update) {
  926. if (lio_setup_glists(oct, lio, num_qs)) {
  927. dev_err(&oct->pci_dev->dev, "Gather list allocation failed\n");
  928. return -1;
  929. }
  930. /* Send firmware the information about new number of queues
  931. * if the interface is a VF or a PF that is SRIOV enabled.
  932. */
  933. if (oct->sriov_info.sriov_enabled || OCTEON_CN23XX_VF(oct))
  934. if (lio_send_queue_count_update(netdev, num_qs))
  935. return -1;
  936. }
  937. return 0;
  938. }
  939. static int lio_ethtool_set_ringparam(struct net_device *netdev,
  940. struct ethtool_ringparam *ering)
  941. {
  942. u32 rx_count, tx_count, rx_count_old, tx_count_old;
  943. struct lio *lio = GET_LIO(netdev);
  944. struct octeon_device *oct = lio->oct_dev;
  945. int stopped = 0;
  946. if (!OCTEON_CN23XX_PF(oct) && !OCTEON_CN23XX_VF(oct))
  947. return -EINVAL;
  948. if (ering->rx_mini_pending || ering->rx_jumbo_pending)
  949. return -EINVAL;
  950. rx_count = clamp_t(u32, ering->rx_pending, CN23XX_MIN_OQ_DESCRIPTORS,
  951. CN23XX_MAX_OQ_DESCRIPTORS);
  952. tx_count = clamp_t(u32, ering->tx_pending, CN23XX_MIN_IQ_DESCRIPTORS,
  953. CN23XX_MAX_IQ_DESCRIPTORS);
  954. rx_count_old = oct->droq[0]->max_count;
  955. tx_count_old = oct->instr_queue[0]->max_count;
  956. if (rx_count == rx_count_old && tx_count == tx_count_old)
  957. return 0;
  958. ifstate_set(lio, LIO_IFSTATE_RESETTING);
  959. if (netif_running(netdev)) {
  960. netdev->netdev_ops->ndo_stop(netdev);
  961. stopped = 1;
  962. }
  963. /* Change RX/TX DESCS count */
  964. if (tx_count != tx_count_old)
  965. CFG_SET_NUM_TX_DESCS_NIC_IF(octeon_get_conf(oct), lio->ifidx,
  966. tx_count);
  967. if (rx_count != rx_count_old)
  968. CFG_SET_NUM_RX_DESCS_NIC_IF(octeon_get_conf(oct), lio->ifidx,
  969. rx_count);
  970. if (lio_reset_queues(netdev, oct->num_iqs))
  971. goto err_lio_reset_queues;
  972. if (stopped)
  973. netdev->netdev_ops->ndo_open(netdev);
  974. ifstate_reset(lio, LIO_IFSTATE_RESETTING);
  975. return 0;
  976. err_lio_reset_queues:
  977. if (tx_count != tx_count_old)
  978. CFG_SET_NUM_TX_DESCS_NIC_IF(octeon_get_conf(oct), lio->ifidx,
  979. tx_count_old);
  980. if (rx_count != rx_count_old)
  981. CFG_SET_NUM_RX_DESCS_NIC_IF(octeon_get_conf(oct), lio->ifidx,
  982. rx_count_old);
  983. return -EINVAL;
  984. }
  985. static u32 lio_get_msglevel(struct net_device *netdev)
  986. {
  987. struct lio *lio = GET_LIO(netdev);
  988. return lio->msg_enable;
  989. }
  990. static void lio_set_msglevel(struct net_device *netdev, u32 msglvl)
  991. {
  992. struct lio *lio = GET_LIO(netdev);
  993. if ((msglvl ^ lio->msg_enable) & NETIF_MSG_HW) {
  994. if (msglvl & NETIF_MSG_HW)
  995. liquidio_set_feature(netdev,
  996. OCTNET_CMD_VERBOSE_ENABLE, 0);
  997. else
  998. liquidio_set_feature(netdev,
  999. OCTNET_CMD_VERBOSE_DISABLE, 0);
  1000. }
  1001. lio->msg_enable = msglvl;
  1002. }
  1003. static void lio_vf_set_msglevel(struct net_device *netdev, u32 msglvl)
  1004. {
  1005. struct lio *lio = GET_LIO(netdev);
  1006. lio->msg_enable = msglvl;
  1007. }
  1008. static void
  1009. lio_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
  1010. {
  1011. /* Notes: Not supporting any auto negotiation in these
  1012. * drivers. Just report pause frame support.
  1013. */
  1014. struct lio *lio = GET_LIO(netdev);
  1015. struct octeon_device *oct = lio->oct_dev;
  1016. pause->autoneg = 0;
  1017. pause->tx_pause = oct->tx_pause;
  1018. pause->rx_pause = oct->rx_pause;
  1019. }
  1020. static int
  1021. lio_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
  1022. {
  1023. /* Notes: Not supporting any auto negotiation in these
  1024. * drivers.
  1025. */
  1026. struct lio *lio = GET_LIO(netdev);
  1027. struct octeon_device *oct = lio->oct_dev;
  1028. struct octnic_ctrl_pkt nctrl;
  1029. struct oct_link_info *linfo = &lio->linfo;
  1030. int ret = 0;
  1031. if (oct->chip_id != OCTEON_CN23XX_PF_VID)
  1032. return -EINVAL;
  1033. if (linfo->link.s.duplex == 0) {
  1034. /*no flow control for half duplex*/
  1035. if (pause->rx_pause || pause->tx_pause)
  1036. return -EINVAL;
  1037. }
  1038. /*do not support autoneg of link flow control*/
  1039. if (pause->autoneg == AUTONEG_ENABLE)
  1040. return -EINVAL;
  1041. memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
  1042. nctrl.ncmd.u64 = 0;
  1043. nctrl.ncmd.s.cmd = OCTNET_CMD_SET_FLOW_CTL;
  1044. nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
  1045. nctrl.wait_time = 100;
  1046. nctrl.netpndev = (u64)netdev;
  1047. nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
  1048. if (pause->rx_pause) {
  1049. /*enable rx pause*/
  1050. nctrl.ncmd.s.param1 = 1;
  1051. } else {
  1052. /*disable rx pause*/
  1053. nctrl.ncmd.s.param1 = 0;
  1054. }
  1055. if (pause->tx_pause) {
  1056. /*enable tx pause*/
  1057. nctrl.ncmd.s.param2 = 1;
  1058. } else {
  1059. /*disable tx pause*/
  1060. nctrl.ncmd.s.param2 = 0;
  1061. }
  1062. ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
  1063. if (ret < 0) {
  1064. dev_err(&oct->pci_dev->dev, "Failed to set pause parameter\n");
  1065. return -EINVAL;
  1066. }
  1067. oct->rx_pause = pause->rx_pause;
  1068. oct->tx_pause = pause->tx_pause;
  1069. return 0;
  1070. }
  1071. static void
  1072. lio_get_ethtool_stats(struct net_device *netdev,
  1073. struct ethtool_stats *stats __attribute__((unused)),
  1074. u64 *data)
  1075. {
  1076. struct lio *lio = GET_LIO(netdev);
  1077. struct octeon_device *oct_dev = lio->oct_dev;
  1078. struct rtnl_link_stats64 lstats;
  1079. int i = 0, j;
  1080. if (ifstate_check(lio, LIO_IFSTATE_RESETTING))
  1081. return;
  1082. netdev->netdev_ops->ndo_get_stats64(netdev, &lstats);
  1083. /*sum of oct->droq[oq_no]->stats->rx_pkts_received */
  1084. data[i++] = lstats.rx_packets;
  1085. /*sum of oct->instr_queue[iq_no]->stats.tx_done */
  1086. data[i++] = lstats.tx_packets;
  1087. /*sum of oct->droq[oq_no]->stats->rx_bytes_received */
  1088. data[i++] = lstats.rx_bytes;
  1089. /*sum of oct->instr_queue[iq_no]->stats.tx_tot_bytes */
  1090. data[i++] = lstats.tx_bytes;
  1091. data[i++] = lstats.rx_errors +
  1092. oct_dev->link_stats.fromwire.fcs_err +
  1093. oct_dev->link_stats.fromwire.jabber_err +
  1094. oct_dev->link_stats.fromwire.l2_err +
  1095. oct_dev->link_stats.fromwire.frame_err;
  1096. data[i++] = lstats.tx_errors;
  1097. /*sum of oct->droq[oq_no]->stats->rx_dropped +
  1098. *oct->droq[oq_no]->stats->dropped_nodispatch +
  1099. *oct->droq[oq_no]->stats->dropped_toomany +
  1100. *oct->droq[oq_no]->stats->dropped_nomem
  1101. */
  1102. data[i++] = lstats.rx_dropped +
  1103. oct_dev->link_stats.fromwire.fifo_err +
  1104. oct_dev->link_stats.fromwire.dmac_drop +
  1105. oct_dev->link_stats.fromwire.red_drops +
  1106. oct_dev->link_stats.fromwire.fw_err_pko +
  1107. oct_dev->link_stats.fromwire.fw_err_link +
  1108. oct_dev->link_stats.fromwire.fw_err_drop;
  1109. /*sum of oct->instr_queue[iq_no]->stats.tx_dropped */
  1110. data[i++] = lstats.tx_dropped +
  1111. oct_dev->link_stats.fromhost.max_collision_fail +
  1112. oct_dev->link_stats.fromhost.max_deferral_fail +
  1113. oct_dev->link_stats.fromhost.total_collisions +
  1114. oct_dev->link_stats.fromhost.fw_err_pko +
  1115. oct_dev->link_stats.fromhost.fw_err_link +
  1116. oct_dev->link_stats.fromhost.fw_err_drop +
  1117. oct_dev->link_stats.fromhost.fw_err_pki;
  1118. /* firmware tx stats */
  1119. /*per_core_stats[cvmx_get_core_num()].link_stats[mdata->from_ifidx].
  1120. *fromhost.fw_total_sent
  1121. */
  1122. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_total_sent);
  1123. /*per_core_stats[i].link_stats[port].fromwire.fw_total_fwd */
  1124. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_total_fwd);
  1125. /*per_core_stats[j].link_stats[i].fromhost.fw_err_pko */
  1126. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_err_pko);
  1127. /*per_core_stats[j].link_stats[i].fromhost.fw_err_pki */
  1128. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_err_pki);
  1129. /*per_core_stats[j].link_stats[i].fromhost.fw_err_link */
  1130. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_err_link);
  1131. /*per_core_stats[cvmx_get_core_num()].link_stats[idx].fromhost.
  1132. *fw_err_drop
  1133. */
  1134. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_err_drop);
  1135. /*per_core_stats[cvmx_get_core_num()].link_stats[idx].fromhost.fw_tso */
  1136. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_tso);
  1137. /*per_core_stats[cvmx_get_core_num()].link_stats[idx].fromhost.
  1138. *fw_tso_fwd
  1139. */
  1140. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_tso_fwd);
  1141. /*per_core_stats[cvmx_get_core_num()].link_stats[idx].fromhost.
  1142. *fw_err_tso
  1143. */
  1144. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_err_tso);
  1145. /*per_core_stats[cvmx_get_core_num()].link_stats[idx].fromhost.
  1146. *fw_tx_vxlan
  1147. */
  1148. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_tx_vxlan);
  1149. /* Multicast packets sent by this port */
  1150. data[i++] = oct_dev->link_stats.fromhost.fw_total_mcast_sent;
  1151. data[i++] = oct_dev->link_stats.fromhost.fw_total_bcast_sent;
  1152. /* mac tx statistics */
  1153. /*CVMX_BGXX_CMRX_TX_STAT5 */
  1154. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.total_pkts_sent);
  1155. /*CVMX_BGXX_CMRX_TX_STAT4 */
  1156. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.total_bytes_sent);
  1157. /*CVMX_BGXX_CMRX_TX_STAT15 */
  1158. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.mcast_pkts_sent);
  1159. /*CVMX_BGXX_CMRX_TX_STAT14 */
  1160. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.bcast_pkts_sent);
  1161. /*CVMX_BGXX_CMRX_TX_STAT17 */
  1162. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.ctl_sent);
  1163. /*CVMX_BGXX_CMRX_TX_STAT0 */
  1164. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.total_collisions);
  1165. /*CVMX_BGXX_CMRX_TX_STAT3 */
  1166. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.one_collision_sent);
  1167. /*CVMX_BGXX_CMRX_TX_STAT2 */
  1168. data[i++] =
  1169. CVM_CAST64(oct_dev->link_stats.fromhost.multi_collision_sent);
  1170. /*CVMX_BGXX_CMRX_TX_STAT0 */
  1171. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.max_collision_fail);
  1172. /*CVMX_BGXX_CMRX_TX_STAT1 */
  1173. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.max_deferral_fail);
  1174. /*CVMX_BGXX_CMRX_TX_STAT16 */
  1175. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fifo_err);
  1176. /*CVMX_BGXX_CMRX_TX_STAT6 */
  1177. data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.runts);
  1178. /* RX firmware stats */
  1179. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1180. *fw_total_rcvd
  1181. */
  1182. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_total_rcvd);
  1183. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1184. *fw_total_fwd
  1185. */
  1186. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_total_fwd);
  1187. /* Multicast packets received on this port */
  1188. data[i++] = oct_dev->link_stats.fromwire.fw_total_mcast;
  1189. data[i++] = oct_dev->link_stats.fromwire.fw_total_bcast;
  1190. /*per_core_stats[core_id].link_stats[ifidx].fromwire.jabber_err */
  1191. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.jabber_err);
  1192. /*per_core_stats[core_id].link_stats[ifidx].fromwire.l2_err */
  1193. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.l2_err);
  1194. /*per_core_stats[core_id].link_stats[ifidx].fromwire.frame_err */
  1195. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.frame_err);
  1196. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1197. *fw_err_pko
  1198. */
  1199. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_err_pko);
  1200. /*per_core_stats[j].link_stats[i].fromwire.fw_err_link */
  1201. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_err_link);
  1202. /*per_core_stats[cvmx_get_core_num()].link_stats[lro_ctx->ifidx].
  1203. *fromwire.fw_err_drop
  1204. */
  1205. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_err_drop);
  1206. /*per_core_stats[cvmx_get_core_num()].link_stats[lro_ctx->ifidx].
  1207. *fromwire.fw_rx_vxlan
  1208. */
  1209. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_rx_vxlan);
  1210. /*per_core_stats[cvmx_get_core_num()].link_stats[lro_ctx->ifidx].
  1211. *fromwire.fw_rx_vxlan_err
  1212. */
  1213. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_rx_vxlan_err);
  1214. /* LRO */
  1215. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1216. *fw_lro_pkts
  1217. */
  1218. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_pkts);
  1219. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1220. *fw_lro_octs
  1221. */
  1222. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_octs);
  1223. /*per_core_stats[j].link_stats[i].fromwire.fw_total_lro */
  1224. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_total_lro);
  1225. /*per_core_stats[j].link_stats[i].fromwire.fw_lro_aborts */
  1226. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_aborts);
  1227. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1228. *fw_lro_aborts_port
  1229. */
  1230. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_aborts_port);
  1231. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1232. *fw_lro_aborts_seq
  1233. */
  1234. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_aborts_seq);
  1235. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1236. *fw_lro_aborts_tsval
  1237. */
  1238. data[i++] =
  1239. CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_aborts_tsval);
  1240. /*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
  1241. *fw_lro_aborts_timer
  1242. */
  1243. /* intrmod: packet forward rate */
  1244. data[i++] =
  1245. CVM_CAST64(oct_dev->link_stats.fromwire.fw_lro_aborts_timer);
  1246. /*per_core_stats[j].link_stats[i].fromwire.fw_lro_aborts */
  1247. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fwd_rate);
  1248. /* mac: link-level stats */
  1249. /*CVMX_BGXX_CMRX_RX_STAT0 */
  1250. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.total_rcvd);
  1251. /*CVMX_BGXX_CMRX_RX_STAT1 */
  1252. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.bytes_rcvd);
  1253. /*CVMX_PKI_STATX_STAT5 */
  1254. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.total_bcst);
  1255. /*CVMX_PKI_STATX_STAT5 */
  1256. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.total_mcst);
  1257. /*wqe->word2.err_code or wqe->word2.err_level */
  1258. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.runts);
  1259. /*CVMX_BGXX_CMRX_RX_STAT2 */
  1260. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.ctl_rcvd);
  1261. /*CVMX_BGXX_CMRX_RX_STAT6 */
  1262. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fifo_err);
  1263. /*CVMX_BGXX_CMRX_RX_STAT4 */
  1264. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.dmac_drop);
  1265. /*wqe->word2.err_code or wqe->word2.err_level */
  1266. data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fcs_err);
  1267. /*lio->link_changes*/
  1268. data[i++] = CVM_CAST64(lio->link_changes);
  1269. for (j = 0; j < MAX_OCTEON_INSTR_QUEUES(oct_dev); j++) {
  1270. if (!(oct_dev->io_qmask.iq & BIT_ULL(j)))
  1271. continue;
  1272. /*packets to network port*/
  1273. /*# of packets tx to network */
  1274. data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_done);
  1275. /*# of bytes tx to network */
  1276. data[i++] =
  1277. CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_tot_bytes);
  1278. /*# of packets dropped */
  1279. data[i++] =
  1280. CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_dropped);
  1281. /*# of tx fails due to queue full */
  1282. data[i++] =
  1283. CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_iq_busy);
  1284. /*XXX gather entries sent */
  1285. data[i++] =
  1286. CVM_CAST64(oct_dev->instr_queue[j]->stats.sgentry_sent);
  1287. /*instruction to firmware: data and control */
  1288. /*# of instructions to the queue */
  1289. data[i++] =
  1290. CVM_CAST64(oct_dev->instr_queue[j]->stats.instr_posted);
  1291. /*# of instructions processed */
  1292. data[i++] = CVM_CAST64(
  1293. oct_dev->instr_queue[j]->stats.instr_processed);
  1294. /*# of instructions could not be processed */
  1295. data[i++] = CVM_CAST64(
  1296. oct_dev->instr_queue[j]->stats.instr_dropped);
  1297. /*bytes sent through the queue */
  1298. data[i++] =
  1299. CVM_CAST64(oct_dev->instr_queue[j]->stats.bytes_sent);
  1300. /*tso request*/
  1301. data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_gso);
  1302. /*vxlan request*/
  1303. data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_vxlan);
  1304. /*txq restart*/
  1305. data[i++] =
  1306. CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_restart);
  1307. }
  1308. /* RX */
  1309. for (j = 0; j < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); j++) {
  1310. if (!(oct_dev->io_qmask.oq & BIT_ULL(j)))
  1311. continue;
  1312. /*packets send to TCP/IP network stack */
  1313. /*# of packets to network stack */
  1314. data[i++] =
  1315. CVM_CAST64(oct_dev->droq[j]->stats.rx_pkts_received);
  1316. /*# of bytes to network stack */
  1317. data[i++] =
  1318. CVM_CAST64(oct_dev->droq[j]->stats.rx_bytes_received);
  1319. /*# of packets dropped */
  1320. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.dropped_nomem +
  1321. oct_dev->droq[j]->stats.dropped_toomany +
  1322. oct_dev->droq[j]->stats.rx_dropped);
  1323. data[i++] =
  1324. CVM_CAST64(oct_dev->droq[j]->stats.dropped_nomem);
  1325. data[i++] =
  1326. CVM_CAST64(oct_dev->droq[j]->stats.dropped_toomany);
  1327. data[i++] =
  1328. CVM_CAST64(oct_dev->droq[j]->stats.rx_dropped);
  1329. /*control and data path*/
  1330. data[i++] =
  1331. CVM_CAST64(oct_dev->droq[j]->stats.pkts_received);
  1332. data[i++] =
  1333. CVM_CAST64(oct_dev->droq[j]->stats.bytes_received);
  1334. data[i++] =
  1335. CVM_CAST64(oct_dev->droq[j]->stats.dropped_nodispatch);
  1336. data[i++] =
  1337. CVM_CAST64(oct_dev->droq[j]->stats.rx_vxlan);
  1338. data[i++] =
  1339. CVM_CAST64(oct_dev->droq[j]->stats.rx_alloc_failure);
  1340. }
  1341. }
  1342. static void lio_vf_get_ethtool_stats(struct net_device *netdev,
  1343. struct ethtool_stats *stats
  1344. __attribute__((unused)),
  1345. u64 *data)
  1346. {
  1347. struct rtnl_link_stats64 lstats;
  1348. struct lio *lio = GET_LIO(netdev);
  1349. struct octeon_device *oct_dev = lio->oct_dev;
  1350. int i = 0, j, vj;
  1351. if (ifstate_check(lio, LIO_IFSTATE_RESETTING))
  1352. return;
  1353. netdev->netdev_ops->ndo_get_stats64(netdev, &lstats);
  1354. /* sum of oct->droq[oq_no]->stats->rx_pkts_received */
  1355. data[i++] = lstats.rx_packets;
  1356. /* sum of oct->instr_queue[iq_no]->stats.tx_done */
  1357. data[i++] = lstats.tx_packets;
  1358. /* sum of oct->droq[oq_no]->stats->rx_bytes_received */
  1359. data[i++] = lstats.rx_bytes;
  1360. /* sum of oct->instr_queue[iq_no]->stats.tx_tot_bytes */
  1361. data[i++] = lstats.tx_bytes;
  1362. data[i++] = lstats.rx_errors;
  1363. data[i++] = lstats.tx_errors;
  1364. /* sum of oct->droq[oq_no]->stats->rx_dropped +
  1365. * oct->droq[oq_no]->stats->dropped_nodispatch +
  1366. * oct->droq[oq_no]->stats->dropped_toomany +
  1367. * oct->droq[oq_no]->stats->dropped_nomem
  1368. */
  1369. data[i++] = lstats.rx_dropped;
  1370. /* sum of oct->instr_queue[iq_no]->stats.tx_dropped */
  1371. data[i++] = lstats.tx_dropped;
  1372. data[i++] = oct_dev->link_stats.fromwire.fw_total_mcast;
  1373. data[i++] = oct_dev->link_stats.fromhost.fw_total_mcast_sent;
  1374. data[i++] = oct_dev->link_stats.fromwire.fw_total_bcast;
  1375. data[i++] = oct_dev->link_stats.fromhost.fw_total_bcast_sent;
  1376. /* lio->link_changes */
  1377. data[i++] = CVM_CAST64(lio->link_changes);
  1378. for (vj = 0; vj < oct_dev->num_iqs; vj++) {
  1379. j = lio->linfo.txpciq[vj].s.q_no;
  1380. /* packets to network port */
  1381. /* # of packets tx to network */
  1382. data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_done);
  1383. /* # of bytes tx to network */
  1384. data[i++] = CVM_CAST64(
  1385. oct_dev->instr_queue[j]->stats.tx_tot_bytes);
  1386. /* # of packets dropped */
  1387. data[i++] = CVM_CAST64(
  1388. oct_dev->instr_queue[j]->stats.tx_dropped);
  1389. /* # of tx fails due to queue full */
  1390. data[i++] = CVM_CAST64(
  1391. oct_dev->instr_queue[j]->stats.tx_iq_busy);
  1392. /* XXX gather entries sent */
  1393. data[i++] = CVM_CAST64(
  1394. oct_dev->instr_queue[j]->stats.sgentry_sent);
  1395. /* instruction to firmware: data and control */
  1396. /* # of instructions to the queue */
  1397. data[i++] = CVM_CAST64(
  1398. oct_dev->instr_queue[j]->stats.instr_posted);
  1399. /* # of instructions processed */
  1400. data[i++] =
  1401. CVM_CAST64(oct_dev->instr_queue[j]->stats.instr_processed);
  1402. /* # of instructions could not be processed */
  1403. data[i++] =
  1404. CVM_CAST64(oct_dev->instr_queue[j]->stats.instr_dropped);
  1405. /* bytes sent through the queue */
  1406. data[i++] = CVM_CAST64(
  1407. oct_dev->instr_queue[j]->stats.bytes_sent);
  1408. /* tso request */
  1409. data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_gso);
  1410. /* vxlan request */
  1411. data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_vxlan);
  1412. /* txq restart */
  1413. data[i++] = CVM_CAST64(
  1414. oct_dev->instr_queue[j]->stats.tx_restart);
  1415. }
  1416. /* RX */
  1417. for (vj = 0; vj < oct_dev->num_oqs; vj++) {
  1418. j = lio->linfo.rxpciq[vj].s.q_no;
  1419. /* packets send to TCP/IP network stack */
  1420. /* # of packets to network stack */
  1421. data[i++] = CVM_CAST64(
  1422. oct_dev->droq[j]->stats.rx_pkts_received);
  1423. /* # of bytes to network stack */
  1424. data[i++] = CVM_CAST64(
  1425. oct_dev->droq[j]->stats.rx_bytes_received);
  1426. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.dropped_nomem +
  1427. oct_dev->droq[j]->stats.dropped_toomany +
  1428. oct_dev->droq[j]->stats.rx_dropped);
  1429. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.dropped_nomem);
  1430. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.dropped_toomany);
  1431. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.rx_dropped);
  1432. /* control and data path */
  1433. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.pkts_received);
  1434. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.bytes_received);
  1435. data[i++] =
  1436. CVM_CAST64(oct_dev->droq[j]->stats.dropped_nodispatch);
  1437. data[i++] = CVM_CAST64(oct_dev->droq[j]->stats.rx_vxlan);
  1438. data[i++] =
  1439. CVM_CAST64(oct_dev->droq[j]->stats.rx_alloc_failure);
  1440. }
  1441. }
  1442. static void lio_get_priv_flags_strings(struct lio *lio, u8 *data)
  1443. {
  1444. struct octeon_device *oct_dev = lio->oct_dev;
  1445. int i;
  1446. switch (oct_dev->chip_id) {
  1447. case OCTEON_CN23XX_PF_VID:
  1448. case OCTEON_CN23XX_VF_VID:
  1449. for (i = 0; i < ARRAY_SIZE(oct_priv_flags_strings); i++) {
  1450. sprintf(data, "%s", oct_priv_flags_strings[i]);
  1451. data += ETH_GSTRING_LEN;
  1452. }
  1453. break;
  1454. case OCTEON_CN68XX:
  1455. case OCTEON_CN66XX:
  1456. break;
  1457. default:
  1458. netif_info(lio, drv, lio->netdev, "Unknown Chip !!\n");
  1459. break;
  1460. }
  1461. }
  1462. static void lio_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
  1463. {
  1464. struct lio *lio = GET_LIO(netdev);
  1465. struct octeon_device *oct_dev = lio->oct_dev;
  1466. int num_iq_stats, num_oq_stats, i, j;
  1467. int num_stats;
  1468. switch (stringset) {
  1469. case ETH_SS_STATS:
  1470. num_stats = ARRAY_SIZE(oct_stats_strings);
  1471. for (j = 0; j < num_stats; j++) {
  1472. sprintf(data, "%s", oct_stats_strings[j]);
  1473. data += ETH_GSTRING_LEN;
  1474. }
  1475. num_iq_stats = ARRAY_SIZE(oct_iq_stats_strings);
  1476. for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct_dev); i++) {
  1477. if (!(oct_dev->io_qmask.iq & BIT_ULL(i)))
  1478. continue;
  1479. for (j = 0; j < num_iq_stats; j++) {
  1480. sprintf(data, "tx-%d-%s", i,
  1481. oct_iq_stats_strings[j]);
  1482. data += ETH_GSTRING_LEN;
  1483. }
  1484. }
  1485. num_oq_stats = ARRAY_SIZE(oct_droq_stats_strings);
  1486. for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); i++) {
  1487. if (!(oct_dev->io_qmask.oq & BIT_ULL(i)))
  1488. continue;
  1489. for (j = 0; j < num_oq_stats; j++) {
  1490. sprintf(data, "rx-%d-%s", i,
  1491. oct_droq_stats_strings[j]);
  1492. data += ETH_GSTRING_LEN;
  1493. }
  1494. }
  1495. break;
  1496. case ETH_SS_PRIV_FLAGS:
  1497. lio_get_priv_flags_strings(lio, data);
  1498. break;
  1499. default:
  1500. netif_info(lio, drv, lio->netdev, "Unknown Stringset !!\n");
  1501. break;
  1502. }
  1503. }
  1504. static void lio_vf_get_strings(struct net_device *netdev, u32 stringset,
  1505. u8 *data)
  1506. {
  1507. int num_iq_stats, num_oq_stats, i, j;
  1508. struct lio *lio = GET_LIO(netdev);
  1509. struct octeon_device *oct_dev = lio->oct_dev;
  1510. int num_stats;
  1511. switch (stringset) {
  1512. case ETH_SS_STATS:
  1513. num_stats = ARRAY_SIZE(oct_vf_stats_strings);
  1514. for (j = 0; j < num_stats; j++) {
  1515. sprintf(data, "%s", oct_vf_stats_strings[j]);
  1516. data += ETH_GSTRING_LEN;
  1517. }
  1518. num_iq_stats = ARRAY_SIZE(oct_iq_stats_strings);
  1519. for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct_dev); i++) {
  1520. if (!(oct_dev->io_qmask.iq & BIT_ULL(i)))
  1521. continue;
  1522. for (j = 0; j < num_iq_stats; j++) {
  1523. sprintf(data, "tx-%d-%s", i,
  1524. oct_iq_stats_strings[j]);
  1525. data += ETH_GSTRING_LEN;
  1526. }
  1527. }
  1528. num_oq_stats = ARRAY_SIZE(oct_droq_stats_strings);
  1529. for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); i++) {
  1530. if (!(oct_dev->io_qmask.oq & BIT_ULL(i)))
  1531. continue;
  1532. for (j = 0; j < num_oq_stats; j++) {
  1533. sprintf(data, "rx-%d-%s", i,
  1534. oct_droq_stats_strings[j]);
  1535. data += ETH_GSTRING_LEN;
  1536. }
  1537. }
  1538. break;
  1539. case ETH_SS_PRIV_FLAGS:
  1540. lio_get_priv_flags_strings(lio, data);
  1541. break;
  1542. default:
  1543. netif_info(lio, drv, lio->netdev, "Unknown Stringset !!\n");
  1544. break;
  1545. }
  1546. }
  1547. static int lio_get_priv_flags_ss_count(struct lio *lio)
  1548. {
  1549. struct octeon_device *oct_dev = lio->oct_dev;
  1550. switch (oct_dev->chip_id) {
  1551. case OCTEON_CN23XX_PF_VID:
  1552. case OCTEON_CN23XX_VF_VID:
  1553. return ARRAY_SIZE(oct_priv_flags_strings);
  1554. case OCTEON_CN68XX:
  1555. case OCTEON_CN66XX:
  1556. return -EOPNOTSUPP;
  1557. default:
  1558. netif_info(lio, drv, lio->netdev, "Unknown Chip !!\n");
  1559. return -EOPNOTSUPP;
  1560. }
  1561. }
  1562. static int lio_get_sset_count(struct net_device *netdev, int sset)
  1563. {
  1564. struct lio *lio = GET_LIO(netdev);
  1565. struct octeon_device *oct_dev = lio->oct_dev;
  1566. switch (sset) {
  1567. case ETH_SS_STATS:
  1568. return (ARRAY_SIZE(oct_stats_strings) +
  1569. ARRAY_SIZE(oct_iq_stats_strings) * oct_dev->num_iqs +
  1570. ARRAY_SIZE(oct_droq_stats_strings) * oct_dev->num_oqs);
  1571. case ETH_SS_PRIV_FLAGS:
  1572. return lio_get_priv_flags_ss_count(lio);
  1573. default:
  1574. return -EOPNOTSUPP;
  1575. }
  1576. }
  1577. static int lio_vf_get_sset_count(struct net_device *netdev, int sset)
  1578. {
  1579. struct lio *lio = GET_LIO(netdev);
  1580. struct octeon_device *oct_dev = lio->oct_dev;
  1581. switch (sset) {
  1582. case ETH_SS_STATS:
  1583. return (ARRAY_SIZE(oct_vf_stats_strings) +
  1584. ARRAY_SIZE(oct_iq_stats_strings) * oct_dev->num_iqs +
  1585. ARRAY_SIZE(oct_droq_stats_strings) * oct_dev->num_oqs);
  1586. case ETH_SS_PRIV_FLAGS:
  1587. return lio_get_priv_flags_ss_count(lio);
  1588. default:
  1589. return -EOPNOTSUPP;
  1590. }
  1591. }
  1592. /* Callback function for intrmod */
  1593. static void octnet_intrmod_callback(struct octeon_device *oct_dev,
  1594. u32 status,
  1595. void *ptr)
  1596. {
  1597. struct octeon_soft_command *sc = (struct octeon_soft_command *)ptr;
  1598. struct oct_intrmod_context *ctx;
  1599. ctx = (struct oct_intrmod_context *)sc->ctxptr;
  1600. ctx->status = status;
  1601. WRITE_ONCE(ctx->cond, 1);
  1602. /* This barrier is required to be sure that the response has been
  1603. * written fully before waking up the handler
  1604. */
  1605. wmb();
  1606. wake_up_interruptible(&ctx->wc);
  1607. }
  1608. /* get interrupt moderation parameters */
  1609. static int octnet_get_intrmod_cfg(struct lio *lio,
  1610. struct oct_intrmod_cfg *intr_cfg)
  1611. {
  1612. struct octeon_soft_command *sc;
  1613. struct oct_intrmod_context *ctx;
  1614. struct oct_intrmod_resp *resp;
  1615. int retval;
  1616. struct octeon_device *oct_dev = lio->oct_dev;
  1617. /* Alloc soft command */
  1618. sc = (struct octeon_soft_command *)
  1619. octeon_alloc_soft_command(oct_dev,
  1620. 0,
  1621. sizeof(struct oct_intrmod_resp),
  1622. sizeof(struct oct_intrmod_context));
  1623. if (!sc)
  1624. return -ENOMEM;
  1625. resp = (struct oct_intrmod_resp *)sc->virtrptr;
  1626. memset(resp, 0, sizeof(struct oct_intrmod_resp));
  1627. ctx = (struct oct_intrmod_context *)sc->ctxptr;
  1628. memset(ctx, 0, sizeof(struct oct_intrmod_context));
  1629. WRITE_ONCE(ctx->cond, 0);
  1630. ctx->octeon_id = lio_get_device_id(oct_dev);
  1631. init_waitqueue_head(&ctx->wc);
  1632. sc->iq_no = lio->linfo.txpciq[0].s.q_no;
  1633. octeon_prepare_soft_command(oct_dev, sc, OPCODE_NIC,
  1634. OPCODE_NIC_INTRMOD_PARAMS, 0, 0, 0);
  1635. sc->callback = octnet_intrmod_callback;
  1636. sc->callback_arg = sc;
  1637. sc->wait_time = 1000;
  1638. retval = octeon_send_soft_command(oct_dev, sc);
  1639. if (retval == IQ_SEND_FAILED) {
  1640. octeon_free_soft_command(oct_dev, sc);
  1641. return -EINVAL;
  1642. }
  1643. /* Sleep on a wait queue till the cond flag indicates that the
  1644. * response arrived or timed-out.
  1645. */
  1646. if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR) {
  1647. dev_err(&oct_dev->pci_dev->dev, "Wait interrupted\n");
  1648. goto intrmod_info_wait_intr;
  1649. }
  1650. retval = ctx->status || resp->status;
  1651. if (retval) {
  1652. dev_err(&oct_dev->pci_dev->dev,
  1653. "Get interrupt moderation parameters failed\n");
  1654. goto intrmod_info_wait_fail;
  1655. }
  1656. octeon_swap_8B_data((u64 *)&resp->intrmod,
  1657. (sizeof(struct oct_intrmod_cfg)) / 8);
  1658. memcpy(intr_cfg, &resp->intrmod, sizeof(struct oct_intrmod_cfg));
  1659. octeon_free_soft_command(oct_dev, sc);
  1660. return 0;
  1661. intrmod_info_wait_fail:
  1662. octeon_free_soft_command(oct_dev, sc);
  1663. intrmod_info_wait_intr:
  1664. return -ENODEV;
  1665. }
  1666. /* Configure interrupt moderation parameters */
  1667. static int octnet_set_intrmod_cfg(struct lio *lio,
  1668. struct oct_intrmod_cfg *intr_cfg)
  1669. {
  1670. struct octeon_soft_command *sc;
  1671. struct oct_intrmod_context *ctx;
  1672. struct oct_intrmod_cfg *cfg;
  1673. int retval;
  1674. struct octeon_device *oct_dev = lio->oct_dev;
  1675. /* Alloc soft command */
  1676. sc = (struct octeon_soft_command *)
  1677. octeon_alloc_soft_command(oct_dev,
  1678. sizeof(struct oct_intrmod_cfg),
  1679. 0,
  1680. sizeof(struct oct_intrmod_context));
  1681. if (!sc)
  1682. return -ENOMEM;
  1683. ctx = (struct oct_intrmod_context *)sc->ctxptr;
  1684. WRITE_ONCE(ctx->cond, 0);
  1685. ctx->octeon_id = lio_get_device_id(oct_dev);
  1686. init_waitqueue_head(&ctx->wc);
  1687. cfg = (struct oct_intrmod_cfg *)sc->virtdptr;
  1688. memcpy(cfg, intr_cfg, sizeof(struct oct_intrmod_cfg));
  1689. octeon_swap_8B_data((u64 *)cfg, (sizeof(struct oct_intrmod_cfg)) / 8);
  1690. sc->iq_no = lio->linfo.txpciq[0].s.q_no;
  1691. octeon_prepare_soft_command(oct_dev, sc, OPCODE_NIC,
  1692. OPCODE_NIC_INTRMOD_CFG, 0, 0, 0);
  1693. sc->callback = octnet_intrmod_callback;
  1694. sc->callback_arg = sc;
  1695. sc->wait_time = 1000;
  1696. retval = octeon_send_soft_command(oct_dev, sc);
  1697. if (retval == IQ_SEND_FAILED) {
  1698. octeon_free_soft_command(oct_dev, sc);
  1699. return -EINVAL;
  1700. }
  1701. /* Sleep on a wait queue till the cond flag indicates that the
  1702. * response arrived or timed-out.
  1703. */
  1704. if (sleep_cond(&ctx->wc, &ctx->cond) != -EINTR) {
  1705. retval = ctx->status;
  1706. if (retval)
  1707. dev_err(&oct_dev->pci_dev->dev,
  1708. "intrmod config failed. Status: %llx\n",
  1709. CVM_CAST64(retval));
  1710. else
  1711. dev_info(&oct_dev->pci_dev->dev,
  1712. "Rx-Adaptive Interrupt moderation %s\n",
  1713. (intr_cfg->rx_enable) ?
  1714. "enabled" : "disabled");
  1715. octeon_free_soft_command(oct_dev, sc);
  1716. return ((retval) ? -ENODEV : 0);
  1717. }
  1718. dev_err(&oct_dev->pci_dev->dev, "iq/oq config failed\n");
  1719. return -EINTR;
  1720. }
  1721. static int lio_get_intr_coalesce(struct net_device *netdev,
  1722. struct ethtool_coalesce *intr_coal)
  1723. {
  1724. struct lio *lio = GET_LIO(netdev);
  1725. struct octeon_device *oct = lio->oct_dev;
  1726. struct octeon_instr_queue *iq;
  1727. struct oct_intrmod_cfg intrmod_cfg;
  1728. if (octnet_get_intrmod_cfg(lio, &intrmod_cfg))
  1729. return -ENODEV;
  1730. switch (oct->chip_id) {
  1731. case OCTEON_CN23XX_PF_VID:
  1732. case OCTEON_CN23XX_VF_VID: {
  1733. if (!intrmod_cfg.rx_enable) {
  1734. intr_coal->rx_coalesce_usecs = oct->rx_coalesce_usecs;
  1735. intr_coal->rx_max_coalesced_frames =
  1736. oct->rx_max_coalesced_frames;
  1737. }
  1738. if (!intrmod_cfg.tx_enable)
  1739. intr_coal->tx_max_coalesced_frames =
  1740. oct->tx_max_coalesced_frames;
  1741. break;
  1742. }
  1743. case OCTEON_CN68XX:
  1744. case OCTEON_CN66XX: {
  1745. struct octeon_cn6xxx *cn6xxx =
  1746. (struct octeon_cn6xxx *)oct->chip;
  1747. if (!intrmod_cfg.rx_enable) {
  1748. intr_coal->rx_coalesce_usecs =
  1749. CFG_GET_OQ_INTR_TIME(cn6xxx->conf);
  1750. intr_coal->rx_max_coalesced_frames =
  1751. CFG_GET_OQ_INTR_PKT(cn6xxx->conf);
  1752. }
  1753. iq = oct->instr_queue[lio->linfo.txpciq[0].s.q_no];
  1754. intr_coal->tx_max_coalesced_frames = iq->fill_threshold;
  1755. break;
  1756. }
  1757. default:
  1758. netif_info(lio, drv, lio->netdev, "Unknown Chip !!\n");
  1759. return -EINVAL;
  1760. }
  1761. if (intrmod_cfg.rx_enable) {
  1762. intr_coal->use_adaptive_rx_coalesce =
  1763. intrmod_cfg.rx_enable;
  1764. intr_coal->rate_sample_interval =
  1765. intrmod_cfg.check_intrvl;
  1766. intr_coal->pkt_rate_high =
  1767. intrmod_cfg.maxpkt_ratethr;
  1768. intr_coal->pkt_rate_low =
  1769. intrmod_cfg.minpkt_ratethr;
  1770. intr_coal->rx_max_coalesced_frames_high =
  1771. intrmod_cfg.rx_maxcnt_trigger;
  1772. intr_coal->rx_coalesce_usecs_high =
  1773. intrmod_cfg.rx_maxtmr_trigger;
  1774. intr_coal->rx_coalesce_usecs_low =
  1775. intrmod_cfg.rx_mintmr_trigger;
  1776. intr_coal->rx_max_coalesced_frames_low =
  1777. intrmod_cfg.rx_mincnt_trigger;
  1778. }
  1779. if ((OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct)) &&
  1780. (intrmod_cfg.tx_enable)) {
  1781. intr_coal->use_adaptive_tx_coalesce =
  1782. intrmod_cfg.tx_enable;
  1783. intr_coal->tx_max_coalesced_frames_high =
  1784. intrmod_cfg.tx_maxcnt_trigger;
  1785. intr_coal->tx_max_coalesced_frames_low =
  1786. intrmod_cfg.tx_mincnt_trigger;
  1787. }
  1788. return 0;
  1789. }
  1790. /* Enable/Disable auto interrupt Moderation */
  1791. static int oct_cfg_adaptive_intr(struct lio *lio,
  1792. struct oct_intrmod_cfg *intrmod_cfg,
  1793. struct ethtool_coalesce *intr_coal)
  1794. {
  1795. int ret = 0;
  1796. if (intrmod_cfg->rx_enable || intrmod_cfg->tx_enable) {
  1797. intrmod_cfg->check_intrvl = intr_coal->rate_sample_interval;
  1798. intrmod_cfg->maxpkt_ratethr = intr_coal->pkt_rate_high;
  1799. intrmod_cfg->minpkt_ratethr = intr_coal->pkt_rate_low;
  1800. }
  1801. if (intrmod_cfg->rx_enable) {
  1802. intrmod_cfg->rx_maxcnt_trigger =
  1803. intr_coal->rx_max_coalesced_frames_high;
  1804. intrmod_cfg->rx_maxtmr_trigger =
  1805. intr_coal->rx_coalesce_usecs_high;
  1806. intrmod_cfg->rx_mintmr_trigger =
  1807. intr_coal->rx_coalesce_usecs_low;
  1808. intrmod_cfg->rx_mincnt_trigger =
  1809. intr_coal->rx_max_coalesced_frames_low;
  1810. }
  1811. if (intrmod_cfg->tx_enable) {
  1812. intrmod_cfg->tx_maxcnt_trigger =
  1813. intr_coal->tx_max_coalesced_frames_high;
  1814. intrmod_cfg->tx_mincnt_trigger =
  1815. intr_coal->tx_max_coalesced_frames_low;
  1816. }
  1817. ret = octnet_set_intrmod_cfg(lio, intrmod_cfg);
  1818. return ret;
  1819. }
  1820. static int
  1821. oct_cfg_rx_intrcnt(struct lio *lio,
  1822. struct oct_intrmod_cfg *intrmod,
  1823. struct ethtool_coalesce *intr_coal)
  1824. {
  1825. struct octeon_device *oct = lio->oct_dev;
  1826. u32 rx_max_coalesced_frames;
  1827. /* Config Cnt based interrupt values */
  1828. switch (oct->chip_id) {
  1829. case OCTEON_CN68XX:
  1830. case OCTEON_CN66XX: {
  1831. struct octeon_cn6xxx *cn6xxx =
  1832. (struct octeon_cn6xxx *)oct->chip;
  1833. if (!intr_coal->rx_max_coalesced_frames)
  1834. rx_max_coalesced_frames = CN6XXX_OQ_INTR_PKT;
  1835. else
  1836. rx_max_coalesced_frames =
  1837. intr_coal->rx_max_coalesced_frames;
  1838. octeon_write_csr(oct, CN6XXX_SLI_OQ_INT_LEVEL_PKTS,
  1839. rx_max_coalesced_frames);
  1840. CFG_SET_OQ_INTR_PKT(cn6xxx->conf, rx_max_coalesced_frames);
  1841. break;
  1842. }
  1843. case OCTEON_CN23XX_PF_VID: {
  1844. int q_no;
  1845. if (!intr_coal->rx_max_coalesced_frames)
  1846. rx_max_coalesced_frames = intrmod->rx_frames;
  1847. else
  1848. rx_max_coalesced_frames =
  1849. intr_coal->rx_max_coalesced_frames;
  1850. for (q_no = 0; q_no < oct->num_oqs; q_no++) {
  1851. q_no += oct->sriov_info.pf_srn;
  1852. octeon_write_csr64(
  1853. oct, CN23XX_SLI_OQ_PKT_INT_LEVELS(q_no),
  1854. (octeon_read_csr64(
  1855. oct, CN23XX_SLI_OQ_PKT_INT_LEVELS(q_no)) &
  1856. (0x3fffff00000000UL)) |
  1857. (rx_max_coalesced_frames - 1));
  1858. /*consider setting resend bit*/
  1859. }
  1860. intrmod->rx_frames = rx_max_coalesced_frames;
  1861. oct->rx_max_coalesced_frames = rx_max_coalesced_frames;
  1862. break;
  1863. }
  1864. case OCTEON_CN23XX_VF_VID: {
  1865. int q_no;
  1866. if (!intr_coal->rx_max_coalesced_frames)
  1867. rx_max_coalesced_frames = intrmod->rx_frames;
  1868. else
  1869. rx_max_coalesced_frames =
  1870. intr_coal->rx_max_coalesced_frames;
  1871. for (q_no = 0; q_no < oct->num_oqs; q_no++) {
  1872. octeon_write_csr64(
  1873. oct, CN23XX_VF_SLI_OQ_PKT_INT_LEVELS(q_no),
  1874. (octeon_read_csr64(
  1875. oct, CN23XX_VF_SLI_OQ_PKT_INT_LEVELS(q_no)) &
  1876. (0x3fffff00000000UL)) |
  1877. (rx_max_coalesced_frames - 1));
  1878. /*consider writing to resend bit here*/
  1879. }
  1880. intrmod->rx_frames = rx_max_coalesced_frames;
  1881. oct->rx_max_coalesced_frames = rx_max_coalesced_frames;
  1882. break;
  1883. }
  1884. default:
  1885. return -EINVAL;
  1886. }
  1887. return 0;
  1888. }
  1889. static int oct_cfg_rx_intrtime(struct lio *lio,
  1890. struct oct_intrmod_cfg *intrmod,
  1891. struct ethtool_coalesce *intr_coal)
  1892. {
  1893. struct octeon_device *oct = lio->oct_dev;
  1894. u32 time_threshold, rx_coalesce_usecs;
  1895. /* Config Time based interrupt values */
  1896. switch (oct->chip_id) {
  1897. case OCTEON_CN68XX:
  1898. case OCTEON_CN66XX: {
  1899. struct octeon_cn6xxx *cn6xxx =
  1900. (struct octeon_cn6xxx *)oct->chip;
  1901. if (!intr_coal->rx_coalesce_usecs)
  1902. rx_coalesce_usecs = CN6XXX_OQ_INTR_TIME;
  1903. else
  1904. rx_coalesce_usecs = intr_coal->rx_coalesce_usecs;
  1905. time_threshold = lio_cn6xxx_get_oq_ticks(oct,
  1906. rx_coalesce_usecs);
  1907. octeon_write_csr(oct,
  1908. CN6XXX_SLI_OQ_INT_LEVEL_TIME,
  1909. time_threshold);
  1910. CFG_SET_OQ_INTR_TIME(cn6xxx->conf, rx_coalesce_usecs);
  1911. break;
  1912. }
  1913. case OCTEON_CN23XX_PF_VID: {
  1914. u64 time_threshold;
  1915. int q_no;
  1916. if (!intr_coal->rx_coalesce_usecs)
  1917. rx_coalesce_usecs = intrmod->rx_usecs;
  1918. else
  1919. rx_coalesce_usecs = intr_coal->rx_coalesce_usecs;
  1920. time_threshold =
  1921. cn23xx_pf_get_oq_ticks(oct, (u32)rx_coalesce_usecs);
  1922. for (q_no = 0; q_no < oct->num_oqs; q_no++) {
  1923. q_no += oct->sriov_info.pf_srn;
  1924. octeon_write_csr64(oct,
  1925. CN23XX_SLI_OQ_PKT_INT_LEVELS(q_no),
  1926. (intrmod->rx_frames |
  1927. ((u64)time_threshold << 32)));
  1928. /*consider writing to resend bit here*/
  1929. }
  1930. intrmod->rx_usecs = rx_coalesce_usecs;
  1931. oct->rx_coalesce_usecs = rx_coalesce_usecs;
  1932. break;
  1933. }
  1934. case OCTEON_CN23XX_VF_VID: {
  1935. u64 time_threshold;
  1936. int q_no;
  1937. if (!intr_coal->rx_coalesce_usecs)
  1938. rx_coalesce_usecs = intrmod->rx_usecs;
  1939. else
  1940. rx_coalesce_usecs = intr_coal->rx_coalesce_usecs;
  1941. time_threshold =
  1942. cn23xx_vf_get_oq_ticks(oct, (u32)rx_coalesce_usecs);
  1943. for (q_no = 0; q_no < oct->num_oqs; q_no++) {
  1944. octeon_write_csr64(
  1945. oct, CN23XX_VF_SLI_OQ_PKT_INT_LEVELS(q_no),
  1946. (intrmod->rx_frames |
  1947. ((u64)time_threshold << 32)));
  1948. /*consider setting resend bit*/
  1949. }
  1950. intrmod->rx_usecs = rx_coalesce_usecs;
  1951. oct->rx_coalesce_usecs = rx_coalesce_usecs;
  1952. break;
  1953. }
  1954. default:
  1955. return -EINVAL;
  1956. }
  1957. return 0;
  1958. }
  1959. static int
  1960. oct_cfg_tx_intrcnt(struct lio *lio,
  1961. struct oct_intrmod_cfg *intrmod,
  1962. struct ethtool_coalesce *intr_coal)
  1963. {
  1964. struct octeon_device *oct = lio->oct_dev;
  1965. u32 iq_intr_pkt;
  1966. void __iomem *inst_cnt_reg;
  1967. u64 val;
  1968. /* Config Cnt based interrupt values */
  1969. switch (oct->chip_id) {
  1970. case OCTEON_CN68XX:
  1971. case OCTEON_CN66XX:
  1972. break;
  1973. case OCTEON_CN23XX_VF_VID:
  1974. case OCTEON_CN23XX_PF_VID: {
  1975. int q_no;
  1976. if (!intr_coal->tx_max_coalesced_frames)
  1977. iq_intr_pkt = CN23XX_DEF_IQ_INTR_THRESHOLD &
  1978. CN23XX_PKT_IN_DONE_WMARK_MASK;
  1979. else
  1980. iq_intr_pkt = intr_coal->tx_max_coalesced_frames &
  1981. CN23XX_PKT_IN_DONE_WMARK_MASK;
  1982. for (q_no = 0; q_no < oct->num_iqs; q_no++) {
  1983. inst_cnt_reg = (oct->instr_queue[q_no])->inst_cnt_reg;
  1984. val = readq(inst_cnt_reg);
  1985. /*clear wmark and count.dont want to write count back*/
  1986. val = (val & 0xFFFF000000000000ULL) |
  1987. ((u64)(iq_intr_pkt - 1)
  1988. << CN23XX_PKT_IN_DONE_WMARK_BIT_POS);
  1989. writeq(val, inst_cnt_reg);
  1990. /*consider setting resend bit*/
  1991. }
  1992. intrmod->tx_frames = iq_intr_pkt;
  1993. oct->tx_max_coalesced_frames = iq_intr_pkt;
  1994. break;
  1995. }
  1996. default:
  1997. return -EINVAL;
  1998. }
  1999. return 0;
  2000. }
  2001. static int lio_set_intr_coalesce(struct net_device *netdev,
  2002. struct ethtool_coalesce *intr_coal)
  2003. {
  2004. struct lio *lio = GET_LIO(netdev);
  2005. int ret;
  2006. struct octeon_device *oct = lio->oct_dev;
  2007. struct oct_intrmod_cfg intrmod = {0};
  2008. u32 j, q_no;
  2009. int db_max, db_min;
  2010. switch (oct->chip_id) {
  2011. case OCTEON_CN68XX:
  2012. case OCTEON_CN66XX:
  2013. db_min = CN6XXX_DB_MIN;
  2014. db_max = CN6XXX_DB_MAX;
  2015. if ((intr_coal->tx_max_coalesced_frames >= db_min) &&
  2016. (intr_coal->tx_max_coalesced_frames <= db_max)) {
  2017. for (j = 0; j < lio->linfo.num_txpciq; j++) {
  2018. q_no = lio->linfo.txpciq[j].s.q_no;
  2019. oct->instr_queue[q_no]->fill_threshold =
  2020. intr_coal->tx_max_coalesced_frames;
  2021. }
  2022. } else {
  2023. dev_err(&oct->pci_dev->dev,
  2024. "LIQUIDIO: Invalid tx-frames:%d. Range is min:%d max:%d\n",
  2025. intr_coal->tx_max_coalesced_frames,
  2026. db_min, db_max);
  2027. return -EINVAL;
  2028. }
  2029. break;
  2030. case OCTEON_CN23XX_PF_VID:
  2031. case OCTEON_CN23XX_VF_VID:
  2032. break;
  2033. default:
  2034. return -EINVAL;
  2035. }
  2036. intrmod.rx_enable = intr_coal->use_adaptive_rx_coalesce ? 1 : 0;
  2037. intrmod.tx_enable = intr_coal->use_adaptive_tx_coalesce ? 1 : 0;
  2038. intrmod.rx_frames = CFG_GET_OQ_INTR_PKT(octeon_get_conf(oct));
  2039. intrmod.rx_usecs = CFG_GET_OQ_INTR_TIME(octeon_get_conf(oct));
  2040. intrmod.tx_frames = CFG_GET_IQ_INTR_PKT(octeon_get_conf(oct));
  2041. ret = oct_cfg_adaptive_intr(lio, &intrmod, intr_coal);
  2042. if (!intr_coal->use_adaptive_rx_coalesce) {
  2043. ret = oct_cfg_rx_intrtime(lio, &intrmod, intr_coal);
  2044. if (ret)
  2045. goto ret_intrmod;
  2046. ret = oct_cfg_rx_intrcnt(lio, &intrmod, intr_coal);
  2047. if (ret)
  2048. goto ret_intrmod;
  2049. } else {
  2050. oct->rx_coalesce_usecs =
  2051. CFG_GET_OQ_INTR_TIME(octeon_get_conf(oct));
  2052. oct->rx_max_coalesced_frames =
  2053. CFG_GET_OQ_INTR_PKT(octeon_get_conf(oct));
  2054. }
  2055. if (!intr_coal->use_adaptive_tx_coalesce) {
  2056. ret = oct_cfg_tx_intrcnt(lio, &intrmod, intr_coal);
  2057. if (ret)
  2058. goto ret_intrmod;
  2059. } else {
  2060. oct->tx_max_coalesced_frames =
  2061. CFG_GET_IQ_INTR_PKT(octeon_get_conf(oct));
  2062. }
  2063. return 0;
  2064. ret_intrmod:
  2065. return ret;
  2066. }
  2067. static int lio_get_ts_info(struct net_device *netdev,
  2068. struct ethtool_ts_info *info)
  2069. {
  2070. struct lio *lio = GET_LIO(netdev);
  2071. info->so_timestamping =
  2072. #ifdef PTP_HARDWARE_TIMESTAMPING
  2073. SOF_TIMESTAMPING_TX_HARDWARE |
  2074. SOF_TIMESTAMPING_RX_HARDWARE |
  2075. SOF_TIMESTAMPING_RAW_HARDWARE |
  2076. SOF_TIMESTAMPING_TX_SOFTWARE |
  2077. #endif
  2078. SOF_TIMESTAMPING_RX_SOFTWARE |
  2079. SOF_TIMESTAMPING_SOFTWARE;
  2080. if (lio->ptp_clock)
  2081. info->phc_index = ptp_clock_index(lio->ptp_clock);
  2082. else
  2083. info->phc_index = -1;
  2084. #ifdef PTP_HARDWARE_TIMESTAMPING
  2085. info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
  2086. info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
  2087. (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
  2088. (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
  2089. (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT);
  2090. #endif
  2091. return 0;
  2092. }
  2093. /* Return register dump len. */
  2094. static int lio_get_regs_len(struct net_device *dev)
  2095. {
  2096. struct lio *lio = GET_LIO(dev);
  2097. struct octeon_device *oct = lio->oct_dev;
  2098. switch (oct->chip_id) {
  2099. case OCTEON_CN23XX_PF_VID:
  2100. return OCT_ETHTOOL_REGDUMP_LEN_23XX;
  2101. case OCTEON_CN23XX_VF_VID:
  2102. return OCT_ETHTOOL_REGDUMP_LEN_23XX_VF;
  2103. default:
  2104. return OCT_ETHTOOL_REGDUMP_LEN;
  2105. }
  2106. }
  2107. static int cn23xx_read_csr_reg(char *s, struct octeon_device *oct)
  2108. {
  2109. u32 reg;
  2110. u8 pf_num = oct->pf_num;
  2111. int len = 0;
  2112. int i;
  2113. /* PCI Window Registers */
  2114. len += sprintf(s + len, "\n\t Octeon CSR Registers\n\n");
  2115. /*0x29030 or 0x29040*/
  2116. reg = CN23XX_SLI_PKT_MAC_RINFO64(oct->pcie_port, oct->pf_num);
  2117. len += sprintf(s + len,
  2118. "\n[%08x] (SLI_PKT_MAC%d_PF%d_RINFO): %016llx\n",
  2119. reg, oct->pcie_port, oct->pf_num,
  2120. (u64)octeon_read_csr64(oct, reg));
  2121. /*0x27080 or 0x27090*/
  2122. reg = CN23XX_SLI_MAC_PF_INT_ENB64(oct->pcie_port, oct->pf_num);
  2123. len +=
  2124. sprintf(s + len, "\n[%08x] (SLI_MAC%d_PF%d_INT_ENB): %016llx\n",
  2125. reg, oct->pcie_port, oct->pf_num,
  2126. (u64)octeon_read_csr64(oct, reg));
  2127. /*0x27000 or 0x27010*/
  2128. reg = CN23XX_SLI_MAC_PF_INT_SUM64(oct->pcie_port, oct->pf_num);
  2129. len +=
  2130. sprintf(s + len, "\n[%08x] (SLI_MAC%d_PF%d_INT_SUM): %016llx\n",
  2131. reg, oct->pcie_port, oct->pf_num,
  2132. (u64)octeon_read_csr64(oct, reg));
  2133. /*0x29120*/
  2134. reg = 0x29120;
  2135. len += sprintf(s + len, "\n[%08x] (SLI_PKT_MEM_CTL): %016llx\n", reg,
  2136. (u64)octeon_read_csr64(oct, reg));
  2137. /*0x27300*/
  2138. reg = 0x27300 + oct->pcie_port * CN23XX_MAC_INT_OFFSET +
  2139. (oct->pf_num) * CN23XX_PF_INT_OFFSET;
  2140. len += sprintf(
  2141. s + len, "\n[%08x] (SLI_MAC%d_PF%d_PKT_VF_INT): %016llx\n", reg,
  2142. oct->pcie_port, oct->pf_num, (u64)octeon_read_csr64(oct, reg));
  2143. /*0x27200*/
  2144. reg = 0x27200 + oct->pcie_port * CN23XX_MAC_INT_OFFSET +
  2145. (oct->pf_num) * CN23XX_PF_INT_OFFSET;
  2146. len += sprintf(s + len,
  2147. "\n[%08x] (SLI_MAC%d_PF%d_PP_VF_INT): %016llx\n",
  2148. reg, oct->pcie_port, oct->pf_num,
  2149. (u64)octeon_read_csr64(oct, reg));
  2150. /*29130*/
  2151. reg = CN23XX_SLI_PKT_CNT_INT;
  2152. len += sprintf(s + len, "\n[%08x] (SLI_PKT_CNT_INT): %016llx\n", reg,
  2153. (u64)octeon_read_csr64(oct, reg));
  2154. /*0x29140*/
  2155. reg = CN23XX_SLI_PKT_TIME_INT;
  2156. len += sprintf(s + len, "\n[%08x] (SLI_PKT_TIME_INT): %016llx\n", reg,
  2157. (u64)octeon_read_csr64(oct, reg));
  2158. /*0x29160*/
  2159. reg = 0x29160;
  2160. len += sprintf(s + len, "\n[%08x] (SLI_PKT_INT): %016llx\n", reg,
  2161. (u64)octeon_read_csr64(oct, reg));
  2162. /*0x29180*/
  2163. reg = CN23XX_SLI_OQ_WMARK;
  2164. len += sprintf(s + len, "\n[%08x] (SLI_PKT_OUTPUT_WMARK): %016llx\n",
  2165. reg, (u64)octeon_read_csr64(oct, reg));
  2166. /*0x291E0*/
  2167. reg = CN23XX_SLI_PKT_IOQ_RING_RST;
  2168. len += sprintf(s + len, "\n[%08x] (SLI_PKT_RING_RST): %016llx\n", reg,
  2169. (u64)octeon_read_csr64(oct, reg));
  2170. /*0x29210*/
  2171. reg = CN23XX_SLI_GBL_CONTROL;
  2172. len += sprintf(s + len,
  2173. "\n[%08x] (SLI_PKT_GBL_CONTROL): %016llx\n", reg,
  2174. (u64)octeon_read_csr64(oct, reg));
  2175. /*0x29220*/
  2176. reg = 0x29220;
  2177. len += sprintf(s + len, "\n[%08x] (SLI_PKT_BIST_STATUS): %016llx\n",
  2178. reg, (u64)octeon_read_csr64(oct, reg));
  2179. /*PF only*/
  2180. if (pf_num == 0) {
  2181. /*0x29260*/
  2182. reg = CN23XX_SLI_OUT_BP_EN_W1S;
  2183. len += sprintf(s + len,
  2184. "\n[%08x] (SLI_PKT_OUT_BP_EN_W1S): %016llx\n",
  2185. reg, (u64)octeon_read_csr64(oct, reg));
  2186. } else if (pf_num == 1) {
  2187. /*0x29270*/
  2188. reg = CN23XX_SLI_OUT_BP_EN2_W1S;
  2189. len += sprintf(s + len,
  2190. "\n[%08x] (SLI_PKT_OUT_BP_EN2_W1S): %016llx\n",
  2191. reg, (u64)octeon_read_csr64(oct, reg));
  2192. }
  2193. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2194. reg = CN23XX_SLI_OQ_BUFF_INFO_SIZE(i);
  2195. len +=
  2196. sprintf(s + len, "\n[%08x] (SLI_PKT%d_OUT_SIZE): %016llx\n",
  2197. reg, i, (u64)octeon_read_csr64(oct, reg));
  2198. }
  2199. /*0x10040*/
  2200. for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
  2201. reg = CN23XX_SLI_IQ_INSTR_COUNT64(i);
  2202. len += sprintf(s + len,
  2203. "\n[%08x] (SLI_PKT_IN_DONE%d_CNTS): %016llx\n",
  2204. reg, i, (u64)octeon_read_csr64(oct, reg));
  2205. }
  2206. /*0x10080*/
  2207. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2208. reg = CN23XX_SLI_OQ_PKTS_CREDIT(i);
  2209. len += sprintf(s + len,
  2210. "\n[%08x] (SLI_PKT%d_SLIST_BAOFF_DBELL): %016llx\n",
  2211. reg, i, (u64)octeon_read_csr64(oct, reg));
  2212. }
  2213. /*0x10090*/
  2214. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2215. reg = CN23XX_SLI_OQ_SIZE(i);
  2216. len += sprintf(
  2217. s + len, "\n[%08x] (SLI_PKT%d_SLIST_FIFO_RSIZE): %016llx\n",
  2218. reg, i, (u64)octeon_read_csr64(oct, reg));
  2219. }
  2220. /*0x10050*/
  2221. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2222. reg = CN23XX_SLI_OQ_PKT_CONTROL(i);
  2223. len += sprintf(
  2224. s + len,
  2225. "\n[%08x] (SLI_PKT%d__OUTPUT_CONTROL): %016llx\n",
  2226. reg, i, (u64)octeon_read_csr64(oct, reg));
  2227. }
  2228. /*0x10070*/
  2229. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2230. reg = CN23XX_SLI_OQ_BASE_ADDR64(i);
  2231. len += sprintf(s + len,
  2232. "\n[%08x] (SLI_PKT%d_SLIST_BADDR): %016llx\n",
  2233. reg, i, (u64)octeon_read_csr64(oct, reg));
  2234. }
  2235. /*0x100a0*/
  2236. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2237. reg = CN23XX_SLI_OQ_PKT_INT_LEVELS(i);
  2238. len += sprintf(s + len,
  2239. "\n[%08x] (SLI_PKT%d_INT_LEVELS): %016llx\n",
  2240. reg, i, (u64)octeon_read_csr64(oct, reg));
  2241. }
  2242. /*0x100b0*/
  2243. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2244. reg = CN23XX_SLI_OQ_PKTS_SENT(i);
  2245. len += sprintf(s + len, "\n[%08x] (SLI_PKT%d_CNTS): %016llx\n",
  2246. reg, i, (u64)octeon_read_csr64(oct, reg));
  2247. }
  2248. /*0x100c0*/
  2249. for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
  2250. reg = 0x100c0 + i * CN23XX_OQ_OFFSET;
  2251. len += sprintf(s + len,
  2252. "\n[%08x] (SLI_PKT%d_ERROR_INFO): %016llx\n",
  2253. reg, i, (u64)octeon_read_csr64(oct, reg));
  2254. /*0x10000*/
  2255. for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
  2256. reg = CN23XX_SLI_IQ_PKT_CONTROL64(i);
  2257. len += sprintf(
  2258. s + len,
  2259. "\n[%08x] (SLI_PKT%d_INPUT_CONTROL): %016llx\n",
  2260. reg, i, (u64)octeon_read_csr64(oct, reg));
  2261. }
  2262. /*0x10010*/
  2263. for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
  2264. reg = CN23XX_SLI_IQ_BASE_ADDR64(i);
  2265. len += sprintf(
  2266. s + len,
  2267. "\n[%08x] (SLI_PKT%d_INSTR_BADDR): %016llx\n", reg,
  2268. i, (u64)octeon_read_csr64(oct, reg));
  2269. }
  2270. /*0x10020*/
  2271. for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
  2272. reg = CN23XX_SLI_IQ_DOORBELL(i);
  2273. len += sprintf(
  2274. s + len,
  2275. "\n[%08x] (SLI_PKT%d_INSTR_BAOFF_DBELL): %016llx\n",
  2276. reg, i, (u64)octeon_read_csr64(oct, reg));
  2277. }
  2278. /*0x10030*/
  2279. for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
  2280. reg = CN23XX_SLI_IQ_SIZE(i);
  2281. len += sprintf(
  2282. s + len,
  2283. "\n[%08x] (SLI_PKT%d_INSTR_FIFO_RSIZE): %016llx\n",
  2284. reg, i, (u64)octeon_read_csr64(oct, reg));
  2285. }
  2286. /*0x10040*/
  2287. for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++)
  2288. reg = CN23XX_SLI_IQ_INSTR_COUNT64(i);
  2289. len += sprintf(s + len,
  2290. "\n[%08x] (SLI_PKT_IN_DONE%d_CNTS): %016llx\n",
  2291. reg, i, (u64)octeon_read_csr64(oct, reg));
  2292. }
  2293. return len;
  2294. }
  2295. static int cn23xx_vf_read_csr_reg(char *s, struct octeon_device *oct)
  2296. {
  2297. int len = 0;
  2298. u32 reg;
  2299. int i;
  2300. /* PCI Window Registers */
  2301. len += sprintf(s + len, "\n\t Octeon CSR Registers\n\n");
  2302. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2303. reg = CN23XX_VF_SLI_OQ_BUFF_INFO_SIZE(i);
  2304. len += sprintf(s + len,
  2305. "\n[%08x] (SLI_PKT%d_OUT_SIZE): %016llx\n",
  2306. reg, i, (u64)octeon_read_csr64(oct, reg));
  2307. }
  2308. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2309. reg = CN23XX_VF_SLI_IQ_INSTR_COUNT64(i);
  2310. len += sprintf(s + len,
  2311. "\n[%08x] (SLI_PKT_IN_DONE%d_CNTS): %016llx\n",
  2312. reg, i, (u64)octeon_read_csr64(oct, reg));
  2313. }
  2314. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2315. reg = CN23XX_VF_SLI_OQ_PKTS_CREDIT(i);
  2316. len += sprintf(s + len,
  2317. "\n[%08x] (SLI_PKT%d_SLIST_BAOFF_DBELL): %016llx\n",
  2318. reg, i, (u64)octeon_read_csr64(oct, reg));
  2319. }
  2320. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2321. reg = CN23XX_VF_SLI_OQ_SIZE(i);
  2322. len += sprintf(s + len,
  2323. "\n[%08x] (SLI_PKT%d_SLIST_FIFO_RSIZE): %016llx\n",
  2324. reg, i, (u64)octeon_read_csr64(oct, reg));
  2325. }
  2326. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2327. reg = CN23XX_VF_SLI_OQ_PKT_CONTROL(i);
  2328. len += sprintf(s + len,
  2329. "\n[%08x] (SLI_PKT%d__OUTPUT_CONTROL): %016llx\n",
  2330. reg, i, (u64)octeon_read_csr64(oct, reg));
  2331. }
  2332. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2333. reg = CN23XX_VF_SLI_OQ_BASE_ADDR64(i);
  2334. len += sprintf(s + len,
  2335. "\n[%08x] (SLI_PKT%d_SLIST_BADDR): %016llx\n",
  2336. reg, i, (u64)octeon_read_csr64(oct, reg));
  2337. }
  2338. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2339. reg = CN23XX_VF_SLI_OQ_PKT_INT_LEVELS(i);
  2340. len += sprintf(s + len,
  2341. "\n[%08x] (SLI_PKT%d_INT_LEVELS): %016llx\n",
  2342. reg, i, (u64)octeon_read_csr64(oct, reg));
  2343. }
  2344. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2345. reg = CN23XX_VF_SLI_OQ_PKTS_SENT(i);
  2346. len += sprintf(s + len, "\n[%08x] (SLI_PKT%d_CNTS): %016llx\n",
  2347. reg, i, (u64)octeon_read_csr64(oct, reg));
  2348. }
  2349. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2350. reg = 0x100c0 + i * CN23XX_VF_OQ_OFFSET;
  2351. len += sprintf(s + len,
  2352. "\n[%08x] (SLI_PKT%d_ERROR_INFO): %016llx\n",
  2353. reg, i, (u64)octeon_read_csr64(oct, reg));
  2354. }
  2355. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2356. reg = 0x100d0 + i * CN23XX_VF_IQ_OFFSET;
  2357. len += sprintf(s + len,
  2358. "\n[%08x] (SLI_PKT%d_VF_INT_SUM): %016llx\n",
  2359. reg, i, (u64)octeon_read_csr64(oct, reg));
  2360. }
  2361. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2362. reg = CN23XX_VF_SLI_IQ_PKT_CONTROL64(i);
  2363. len += sprintf(s + len,
  2364. "\n[%08x] (SLI_PKT%d_INPUT_CONTROL): %016llx\n",
  2365. reg, i, (u64)octeon_read_csr64(oct, reg));
  2366. }
  2367. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2368. reg = CN23XX_VF_SLI_IQ_BASE_ADDR64(i);
  2369. len += sprintf(s + len,
  2370. "\n[%08x] (SLI_PKT%d_INSTR_BADDR): %016llx\n",
  2371. reg, i, (u64)octeon_read_csr64(oct, reg));
  2372. }
  2373. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2374. reg = CN23XX_VF_SLI_IQ_DOORBELL(i);
  2375. len += sprintf(s + len,
  2376. "\n[%08x] (SLI_PKT%d_INSTR_BAOFF_DBELL): %016llx\n",
  2377. reg, i, (u64)octeon_read_csr64(oct, reg));
  2378. }
  2379. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2380. reg = CN23XX_VF_SLI_IQ_SIZE(i);
  2381. len += sprintf(s + len,
  2382. "\n[%08x] (SLI_PKT%d_INSTR_FIFO_RSIZE): %016llx\n",
  2383. reg, i, (u64)octeon_read_csr64(oct, reg));
  2384. }
  2385. for (i = 0; i < (oct->sriov_info.rings_per_vf); i++) {
  2386. reg = CN23XX_VF_SLI_IQ_INSTR_COUNT64(i);
  2387. len += sprintf(s + len,
  2388. "\n[%08x] (SLI_PKT_IN_DONE%d_CNTS): %016llx\n",
  2389. reg, i, (u64)octeon_read_csr64(oct, reg));
  2390. }
  2391. return len;
  2392. }
  2393. static int cn6xxx_read_csr_reg(char *s, struct octeon_device *oct)
  2394. {
  2395. u32 reg;
  2396. int i, len = 0;
  2397. /* PCI Window Registers */
  2398. len += sprintf(s + len, "\n\t Octeon CSR Registers\n\n");
  2399. reg = CN6XXX_WIN_WR_ADDR_LO;
  2400. len += sprintf(s + len, "\n[%02x] (WIN_WR_ADDR_LO): %08x\n",
  2401. CN6XXX_WIN_WR_ADDR_LO, octeon_read_csr(oct, reg));
  2402. reg = CN6XXX_WIN_WR_ADDR_HI;
  2403. len += sprintf(s + len, "[%02x] (WIN_WR_ADDR_HI): %08x\n",
  2404. CN6XXX_WIN_WR_ADDR_HI, octeon_read_csr(oct, reg));
  2405. reg = CN6XXX_WIN_RD_ADDR_LO;
  2406. len += sprintf(s + len, "[%02x] (WIN_RD_ADDR_LO): %08x\n",
  2407. CN6XXX_WIN_RD_ADDR_LO, octeon_read_csr(oct, reg));
  2408. reg = CN6XXX_WIN_RD_ADDR_HI;
  2409. len += sprintf(s + len, "[%02x] (WIN_RD_ADDR_HI): %08x\n",
  2410. CN6XXX_WIN_RD_ADDR_HI, octeon_read_csr(oct, reg));
  2411. reg = CN6XXX_WIN_WR_DATA_LO;
  2412. len += sprintf(s + len, "[%02x] (WIN_WR_DATA_LO): %08x\n",
  2413. CN6XXX_WIN_WR_DATA_LO, octeon_read_csr(oct, reg));
  2414. reg = CN6XXX_WIN_WR_DATA_HI;
  2415. len += sprintf(s + len, "[%02x] (WIN_WR_DATA_HI): %08x\n",
  2416. CN6XXX_WIN_WR_DATA_HI, octeon_read_csr(oct, reg));
  2417. len += sprintf(s + len, "[%02x] (WIN_WR_MASK_REG): %08x\n",
  2418. CN6XXX_WIN_WR_MASK_REG,
  2419. octeon_read_csr(oct, CN6XXX_WIN_WR_MASK_REG));
  2420. /* PCI Interrupt Register */
  2421. len += sprintf(s + len, "\n[%x] (INT_ENABLE PORT 0): %08x\n",
  2422. CN6XXX_SLI_INT_ENB64_PORT0, octeon_read_csr(oct,
  2423. CN6XXX_SLI_INT_ENB64_PORT0));
  2424. len += sprintf(s + len, "\n[%x] (INT_ENABLE PORT 1): %08x\n",
  2425. CN6XXX_SLI_INT_ENB64_PORT1,
  2426. octeon_read_csr(oct, CN6XXX_SLI_INT_ENB64_PORT1));
  2427. len += sprintf(s + len, "[%x] (INT_SUM): %08x\n", CN6XXX_SLI_INT_SUM64,
  2428. octeon_read_csr(oct, CN6XXX_SLI_INT_SUM64));
  2429. /* PCI Output queue registers */
  2430. for (i = 0; i < oct->num_oqs; i++) {
  2431. reg = CN6XXX_SLI_OQ_PKTS_SENT(i);
  2432. len += sprintf(s + len, "\n[%x] (PKTS_SENT_%d): %08x\n",
  2433. reg, i, octeon_read_csr(oct, reg));
  2434. reg = CN6XXX_SLI_OQ_PKTS_CREDIT(i);
  2435. len += sprintf(s + len, "[%x] (PKT_CREDITS_%d): %08x\n",
  2436. reg, i, octeon_read_csr(oct, reg));
  2437. }
  2438. reg = CN6XXX_SLI_OQ_INT_LEVEL_PKTS;
  2439. len += sprintf(s + len, "\n[%x] (PKTS_SENT_INT_LEVEL): %08x\n",
  2440. reg, octeon_read_csr(oct, reg));
  2441. reg = CN6XXX_SLI_OQ_INT_LEVEL_TIME;
  2442. len += sprintf(s + len, "[%x] (PKTS_SENT_TIME): %08x\n",
  2443. reg, octeon_read_csr(oct, reg));
  2444. /* PCI Input queue registers */
  2445. for (i = 0; i <= 3; i++) {
  2446. u32 reg;
  2447. reg = CN6XXX_SLI_IQ_DOORBELL(i);
  2448. len += sprintf(s + len, "\n[%x] (INSTR_DOORBELL_%d): %08x\n",
  2449. reg, i, octeon_read_csr(oct, reg));
  2450. reg = CN6XXX_SLI_IQ_INSTR_COUNT(i);
  2451. len += sprintf(s + len, "[%x] (INSTR_COUNT_%d): %08x\n",
  2452. reg, i, octeon_read_csr(oct, reg));
  2453. }
  2454. /* PCI DMA registers */
  2455. len += sprintf(s + len, "\n[%x] (DMA_CNT_0): %08x\n",
  2456. CN6XXX_DMA_CNT(0),
  2457. octeon_read_csr(oct, CN6XXX_DMA_CNT(0)));
  2458. reg = CN6XXX_DMA_PKT_INT_LEVEL(0);
  2459. len += sprintf(s + len, "[%x] (DMA_INT_LEV_0): %08x\n",
  2460. CN6XXX_DMA_PKT_INT_LEVEL(0), octeon_read_csr(oct, reg));
  2461. reg = CN6XXX_DMA_TIME_INT_LEVEL(0);
  2462. len += sprintf(s + len, "[%x] (DMA_TIME_0): %08x\n",
  2463. CN6XXX_DMA_TIME_INT_LEVEL(0),
  2464. octeon_read_csr(oct, reg));
  2465. len += sprintf(s + len, "\n[%x] (DMA_CNT_1): %08x\n",
  2466. CN6XXX_DMA_CNT(1),
  2467. octeon_read_csr(oct, CN6XXX_DMA_CNT(1)));
  2468. reg = CN6XXX_DMA_PKT_INT_LEVEL(1);
  2469. len += sprintf(s + len, "[%x] (DMA_INT_LEV_1): %08x\n",
  2470. CN6XXX_DMA_PKT_INT_LEVEL(1),
  2471. octeon_read_csr(oct, reg));
  2472. reg = CN6XXX_DMA_PKT_INT_LEVEL(1);
  2473. len += sprintf(s + len, "[%x] (DMA_TIME_1): %08x\n",
  2474. CN6XXX_DMA_TIME_INT_LEVEL(1),
  2475. octeon_read_csr(oct, reg));
  2476. /* PCI Index registers */
  2477. len += sprintf(s + len, "\n");
  2478. for (i = 0; i < 16; i++) {
  2479. reg = lio_pci_readq(oct, CN6XXX_BAR1_REG(i, oct->pcie_port));
  2480. len += sprintf(s + len, "[%llx] (BAR1_INDEX_%02d): %08x\n",
  2481. CN6XXX_BAR1_REG(i, oct->pcie_port), i, reg);
  2482. }
  2483. return len;
  2484. }
  2485. static int cn6xxx_read_config_reg(char *s, struct octeon_device *oct)
  2486. {
  2487. u32 val;
  2488. int i, len = 0;
  2489. /* PCI CONFIG Registers */
  2490. len += sprintf(s + len,
  2491. "\n\t Octeon Config space Registers\n\n");
  2492. for (i = 0; i <= 13; i++) {
  2493. pci_read_config_dword(oct->pci_dev, (i * 4), &val);
  2494. len += sprintf(s + len, "[0x%x] (Config[%d]): 0x%08x\n",
  2495. (i * 4), i, val);
  2496. }
  2497. for (i = 30; i <= 34; i++) {
  2498. pci_read_config_dword(oct->pci_dev, (i * 4), &val);
  2499. len += sprintf(s + len, "[0x%x] (Config[%d]): 0x%08x\n",
  2500. (i * 4), i, val);
  2501. }
  2502. return len;
  2503. }
  2504. /* Return register dump user app. */
  2505. static void lio_get_regs(struct net_device *dev,
  2506. struct ethtool_regs *regs, void *regbuf)
  2507. {
  2508. struct lio *lio = GET_LIO(dev);
  2509. int len = 0;
  2510. struct octeon_device *oct = lio->oct_dev;
  2511. regs->version = OCT_ETHTOOL_REGSVER;
  2512. switch (oct->chip_id) {
  2513. case OCTEON_CN23XX_PF_VID:
  2514. memset(regbuf, 0, OCT_ETHTOOL_REGDUMP_LEN_23XX);
  2515. len += cn23xx_read_csr_reg(regbuf + len, oct);
  2516. break;
  2517. case OCTEON_CN23XX_VF_VID:
  2518. memset(regbuf, 0, OCT_ETHTOOL_REGDUMP_LEN_23XX_VF);
  2519. len += cn23xx_vf_read_csr_reg(regbuf + len, oct);
  2520. break;
  2521. case OCTEON_CN68XX:
  2522. case OCTEON_CN66XX:
  2523. memset(regbuf, 0, OCT_ETHTOOL_REGDUMP_LEN);
  2524. len += cn6xxx_read_csr_reg(regbuf + len, oct);
  2525. len += cn6xxx_read_config_reg(regbuf + len, oct);
  2526. break;
  2527. default:
  2528. dev_err(&oct->pci_dev->dev, "%s Unknown chipid: %d\n",
  2529. __func__, oct->chip_id);
  2530. }
  2531. }
  2532. static u32 lio_get_priv_flags(struct net_device *netdev)
  2533. {
  2534. struct lio *lio = GET_LIO(netdev);
  2535. return lio->oct_dev->priv_flags;
  2536. }
  2537. static int lio_set_priv_flags(struct net_device *netdev, u32 flags)
  2538. {
  2539. struct lio *lio = GET_LIO(netdev);
  2540. bool intr_by_tx_bytes = !!(flags & (0x1 << OCT_PRIV_FLAG_TX_BYTES));
  2541. lio_set_priv_flag(lio->oct_dev, OCT_PRIV_FLAG_TX_BYTES,
  2542. intr_by_tx_bytes);
  2543. return 0;
  2544. }
  2545. static const struct ethtool_ops lio_ethtool_ops = {
  2546. .get_link_ksettings = lio_get_link_ksettings,
  2547. .get_link = ethtool_op_get_link,
  2548. .get_drvinfo = lio_get_drvinfo,
  2549. .get_ringparam = lio_ethtool_get_ringparam,
  2550. .set_ringparam = lio_ethtool_set_ringparam,
  2551. .get_channels = lio_ethtool_get_channels,
  2552. .set_channels = lio_ethtool_set_channels,
  2553. .set_phys_id = lio_set_phys_id,
  2554. .get_eeprom_len = lio_get_eeprom_len,
  2555. .get_eeprom = lio_get_eeprom,
  2556. .get_strings = lio_get_strings,
  2557. .get_ethtool_stats = lio_get_ethtool_stats,
  2558. .get_pauseparam = lio_get_pauseparam,
  2559. .set_pauseparam = lio_set_pauseparam,
  2560. .get_regs_len = lio_get_regs_len,
  2561. .get_regs = lio_get_regs,
  2562. .get_msglevel = lio_get_msglevel,
  2563. .set_msglevel = lio_set_msglevel,
  2564. .get_sset_count = lio_get_sset_count,
  2565. .get_coalesce = lio_get_intr_coalesce,
  2566. .set_coalesce = lio_set_intr_coalesce,
  2567. .get_priv_flags = lio_get_priv_flags,
  2568. .set_priv_flags = lio_set_priv_flags,
  2569. .get_ts_info = lio_get_ts_info,
  2570. };
  2571. static const struct ethtool_ops lio_vf_ethtool_ops = {
  2572. .get_link_ksettings = lio_get_link_ksettings,
  2573. .get_link = ethtool_op_get_link,
  2574. .get_drvinfo = lio_get_vf_drvinfo,
  2575. .get_ringparam = lio_ethtool_get_ringparam,
  2576. .set_ringparam = lio_ethtool_set_ringparam,
  2577. .get_channels = lio_ethtool_get_channels,
  2578. .set_channels = lio_ethtool_set_channels,
  2579. .get_strings = lio_vf_get_strings,
  2580. .get_ethtool_stats = lio_vf_get_ethtool_stats,
  2581. .get_regs_len = lio_get_regs_len,
  2582. .get_regs = lio_get_regs,
  2583. .get_msglevel = lio_get_msglevel,
  2584. .set_msglevel = lio_vf_set_msglevel,
  2585. .get_sset_count = lio_vf_get_sset_count,
  2586. .get_coalesce = lio_get_intr_coalesce,
  2587. .set_coalesce = lio_set_intr_coalesce,
  2588. .get_priv_flags = lio_get_priv_flags,
  2589. .set_priv_flags = lio_set_priv_flags,
  2590. .get_ts_info = lio_get_ts_info,
  2591. };
  2592. void liquidio_set_ethtool_ops(struct net_device *netdev)
  2593. {
  2594. struct lio *lio = GET_LIO(netdev);
  2595. struct octeon_device *oct = lio->oct_dev;
  2596. if (OCTEON_CN23XX_VF(oct))
  2597. netdev->ethtool_ops = &lio_vf_ethtool_ops;
  2598. else
  2599. netdev->ethtool_ops = &lio_ethtool_ops;
  2600. }