vxge-config.h 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279
  1. /******************************************************************************
  2. * This software may be used and distributed according to the terms of
  3. * the GNU General Public License (GPL), incorporated herein by reference.
  4. * Drivers based on or derived from this code fall under the GPL and must
  5. * retain the authorship, copyright and license notice. This file is not
  6. * a complete program and may only be used when the entire operating
  7. * system is licensed under the GPL.
  8. * See the file COPYING in this distribution for more information.
  9. *
  10. * vxge-config.h: Driver for Exar Corp's X3100 Series 10GbE PCIe I/O
  11. * Virtualized Server Adapter.
  12. * Copyright(c) 2002-2010 Exar Corp.
  13. ******************************************************************************/
  14. #ifndef VXGE_CONFIG_H
  15. #define VXGE_CONFIG_H
  16. #include <linux/list.h>
  17. #include <linux/slab.h>
  18. #ifndef VXGE_CACHE_LINE_SIZE
  19. #define VXGE_CACHE_LINE_SIZE 128
  20. #endif
  21. #define vxge_os_vaprintf(level, mask, fmt, ...) { \
  22. char buff[255]; \
  23. snprintf(buff, 255, fmt, __VA_ARGS__); \
  24. printk(buff); \
  25. printk("\n"); \
  26. }
  27. #ifndef VXGE_ALIGN
  28. #define VXGE_ALIGN(adrs, size) \
  29. (((size) - (((u64)adrs) & ((size)-1))) & ((size)-1))
  30. #endif
  31. #define VXGE_HW_MIN_MTU 68
  32. #define VXGE_HW_MAX_MTU 9600
  33. #define VXGE_HW_DEFAULT_MTU 1500
  34. #ifdef VXGE_DEBUG_ASSERT
  35. /**
  36. * vxge_assert
  37. * @test: C-condition to check
  38. * @fmt: printf like format string
  39. *
  40. * This function implements traditional assert. By default assertions
  41. * are enabled. It can be disabled by undefining VXGE_DEBUG_ASSERT macro in
  42. * compilation
  43. * time.
  44. */
  45. #define vxge_assert(test) { \
  46. if (!(test)) \
  47. vxge_os_bug("bad cond: "#test" at %s:%d\n", \
  48. __FILE__, __LINE__); }
  49. #else
  50. #define vxge_assert(test)
  51. #endif /* end of VXGE_DEBUG_ASSERT */
  52. /**
  53. * enum enum vxge_debug_level
  54. * @VXGE_NONE: debug disabled
  55. * @VXGE_ERR: all errors going to be logged out
  56. * @VXGE_TRACE: all errors plus all kind of verbose tracing print outs
  57. * going to be logged out. Very noisy.
  58. *
  59. * This enumeration going to be used to switch between different
  60. * debug levels during runtime if DEBUG macro defined during
  61. * compilation. If DEBUG macro not defined than code will be
  62. * compiled out.
  63. */
  64. enum vxge_debug_level {
  65. VXGE_NONE = 0,
  66. VXGE_TRACE = 1,
  67. VXGE_ERR = 2
  68. };
  69. #define NULL_VPID 0xFFFFFFFF
  70. #ifdef CONFIG_VXGE_DEBUG_TRACE_ALL
  71. #define VXGE_DEBUG_MODULE_MASK 0xffffffff
  72. #define VXGE_DEBUG_TRACE_MASK 0xffffffff
  73. #define VXGE_DEBUG_ERR_MASK 0xffffffff
  74. #define VXGE_DEBUG_MASK 0x000001ff
  75. #else
  76. #define VXGE_DEBUG_MODULE_MASK 0x20000000
  77. #define VXGE_DEBUG_TRACE_MASK 0x20000000
  78. #define VXGE_DEBUG_ERR_MASK 0x20000000
  79. #define VXGE_DEBUG_MASK 0x00000001
  80. #endif
  81. /*
  82. * @VXGE_COMPONENT_LL: do debug for vxge link layer module
  83. * @VXGE_COMPONENT_ALL: activate debug for all modules with no exceptions
  84. *
  85. * This enumeration going to be used to distinguish modules
  86. * or libraries during compilation and runtime. Makefile must declare
  87. * VXGE_DEBUG_MODULE_MASK macro and set it to proper value.
  88. */
  89. #define VXGE_COMPONENT_LL 0x20000000
  90. #define VXGE_COMPONENT_ALL 0xffffffff
  91. #define VXGE_HW_BASE_INF 100
  92. #define VXGE_HW_BASE_ERR 200
  93. #define VXGE_HW_BASE_BADCFG 300
  94. enum vxge_hw_status {
  95. VXGE_HW_OK = 0,
  96. VXGE_HW_FAIL = 1,
  97. VXGE_HW_PENDING = 2,
  98. VXGE_HW_COMPLETIONS_REMAIN = 3,
  99. VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS = VXGE_HW_BASE_INF + 1,
  100. VXGE_HW_INF_OUT_OF_DESCRIPTORS = VXGE_HW_BASE_INF + 2,
  101. VXGE_HW_ERR_INVALID_HANDLE = VXGE_HW_BASE_ERR + 1,
  102. VXGE_HW_ERR_OUT_OF_MEMORY = VXGE_HW_BASE_ERR + 2,
  103. VXGE_HW_ERR_VPATH_NOT_AVAILABLE = VXGE_HW_BASE_ERR + 3,
  104. VXGE_HW_ERR_VPATH_NOT_OPEN = VXGE_HW_BASE_ERR + 4,
  105. VXGE_HW_ERR_WRONG_IRQ = VXGE_HW_BASE_ERR + 5,
  106. VXGE_HW_ERR_SWAPPER_CTRL = VXGE_HW_BASE_ERR + 6,
  107. VXGE_HW_ERR_INVALID_MTU_SIZE = VXGE_HW_BASE_ERR + 7,
  108. VXGE_HW_ERR_INVALID_INDEX = VXGE_HW_BASE_ERR + 8,
  109. VXGE_HW_ERR_INVALID_TYPE = VXGE_HW_BASE_ERR + 9,
  110. VXGE_HW_ERR_INVALID_OFFSET = VXGE_HW_BASE_ERR + 10,
  111. VXGE_HW_ERR_INVALID_DEVICE = VXGE_HW_BASE_ERR + 11,
  112. VXGE_HW_ERR_VERSION_CONFLICT = VXGE_HW_BASE_ERR + 12,
  113. VXGE_HW_ERR_INVALID_PCI_INFO = VXGE_HW_BASE_ERR + 13,
  114. VXGE_HW_ERR_INVALID_TCODE = VXGE_HW_BASE_ERR + 14,
  115. VXGE_HW_ERR_INVALID_BLOCK_SIZE = VXGE_HW_BASE_ERR + 15,
  116. VXGE_HW_ERR_INVALID_STATE = VXGE_HW_BASE_ERR + 16,
  117. VXGE_HW_ERR_PRIVILAGED_OPEARATION = VXGE_HW_BASE_ERR + 17,
  118. VXGE_HW_ERR_INVALID_PORT = VXGE_HW_BASE_ERR + 18,
  119. VXGE_HW_ERR_FIFO = VXGE_HW_BASE_ERR + 19,
  120. VXGE_HW_ERR_VPATH = VXGE_HW_BASE_ERR + 20,
  121. VXGE_HW_ERR_CRITICAL = VXGE_HW_BASE_ERR + 21,
  122. VXGE_HW_ERR_SLOT_FREEZE = VXGE_HW_BASE_ERR + 22,
  123. VXGE_HW_BADCFG_RING_INDICATE_MAX_PKTS = VXGE_HW_BASE_BADCFG + 1,
  124. VXGE_HW_BADCFG_FIFO_BLOCKS = VXGE_HW_BASE_BADCFG + 2,
  125. VXGE_HW_BADCFG_VPATH_MTU = VXGE_HW_BASE_BADCFG + 3,
  126. VXGE_HW_BADCFG_VPATH_RPA_STRIP_VLAN_TAG = VXGE_HW_BASE_BADCFG + 4,
  127. VXGE_HW_BADCFG_VPATH_MIN_BANDWIDTH = VXGE_HW_BASE_BADCFG + 5,
  128. VXGE_HW_BADCFG_INTR_MODE = VXGE_HW_BASE_BADCFG + 6,
  129. VXGE_HW_BADCFG_RTS_MAC_EN = VXGE_HW_BASE_BADCFG + 7,
  130. VXGE_HW_EOF_TRACE_BUF = -1
  131. };
  132. /**
  133. * enum enum vxge_hw_device_link_state - Link state enumeration.
  134. * @VXGE_HW_LINK_NONE: Invalid link state.
  135. * @VXGE_HW_LINK_DOWN: Link is down.
  136. * @VXGE_HW_LINK_UP: Link is up.
  137. *
  138. */
  139. enum vxge_hw_device_link_state {
  140. VXGE_HW_LINK_NONE,
  141. VXGE_HW_LINK_DOWN,
  142. VXGE_HW_LINK_UP
  143. };
  144. /**
  145. * struct vxge_hw_device_date - Date Format
  146. * @day: Day
  147. * @month: Month
  148. * @year: Year
  149. * @date: Date in string format
  150. *
  151. * Structure for returning date
  152. */
  153. #define VXGE_HW_FW_STRLEN 32
  154. struct vxge_hw_device_date {
  155. u32 day;
  156. u32 month;
  157. u32 year;
  158. char date[VXGE_HW_FW_STRLEN];
  159. };
  160. struct vxge_hw_device_version {
  161. u32 major;
  162. u32 minor;
  163. u32 build;
  164. char version[VXGE_HW_FW_STRLEN];
  165. };
  166. u64
  167. __vxge_hw_vpath_pci_func_mode_get(
  168. u32 vp_id,
  169. struct vxge_hw_vpath_reg __iomem *vpath_reg);
  170. /**
  171. * struct vxge_hw_fifo_config - Configuration of fifo.
  172. * @enable: Is this fifo to be commissioned
  173. * @fifo_blocks: Numbers of TxDL (that is, lists of Tx descriptors)
  174. * blocks per queue.
  175. * @max_frags: Max number of Tx buffers per TxDL (that is, per single
  176. * transmit operation).
  177. * No more than 256 transmit buffers can be specified.
  178. * @memblock_size: Fifo descriptors are allocated in blocks of @mem_block_size
  179. * bytes. Setting @memblock_size to page size ensures
  180. * by-page allocation of descriptors. 128K bytes is the
  181. * maximum supported block size.
  182. * @alignment_size: per Tx fragment DMA-able memory used to align transmit data
  183. * (e.g., to align on a cache line).
  184. * @intr: Boolean. Use 1 to generate interrupt for each completed TxDL.
  185. * Use 0 otherwise.
  186. * @no_snoop_bits: If non-zero, specifies no-snoop PCI operation,
  187. * which generally improves latency of the host bridge operation
  188. * (see PCI specification). For valid values please refer
  189. * to struct vxge_hw_fifo_config{} in the driver sources.
  190. * Configuration of all Titan fifos.
  191. * Note: Valid (min, max) range for each attribute is specified in the body of
  192. * the struct vxge_hw_fifo_config{} structure.
  193. */
  194. struct vxge_hw_fifo_config {
  195. u32 enable;
  196. #define VXGE_HW_FIFO_ENABLE 1
  197. #define VXGE_HW_FIFO_DISABLE 0
  198. u32 fifo_blocks;
  199. #define VXGE_HW_MIN_FIFO_BLOCKS 2
  200. #define VXGE_HW_MAX_FIFO_BLOCKS 128
  201. u32 max_frags;
  202. #define VXGE_HW_MIN_FIFO_FRAGS 1
  203. #define VXGE_HW_MAX_FIFO_FRAGS 256
  204. u32 memblock_size;
  205. #define VXGE_HW_MIN_FIFO_MEMBLOCK_SIZE VXGE_HW_BLOCK_SIZE
  206. #define VXGE_HW_MAX_FIFO_MEMBLOCK_SIZE 131072
  207. #define VXGE_HW_DEF_FIFO_MEMBLOCK_SIZE 8096
  208. u32 alignment_size;
  209. #define VXGE_HW_MIN_FIFO_ALIGNMENT_SIZE 0
  210. #define VXGE_HW_MAX_FIFO_ALIGNMENT_SIZE 65536
  211. #define VXGE_HW_DEF_FIFO_ALIGNMENT_SIZE VXGE_CACHE_LINE_SIZE
  212. u32 intr;
  213. #define VXGE_HW_FIFO_QUEUE_INTR_ENABLE 1
  214. #define VXGE_HW_FIFO_QUEUE_INTR_DISABLE 0
  215. #define VXGE_HW_FIFO_QUEUE_INTR_DEFAULT 0
  216. u32 no_snoop_bits;
  217. #define VXGE_HW_FIFO_NO_SNOOP_DISABLED 0
  218. #define VXGE_HW_FIFO_NO_SNOOP_TXD 1
  219. #define VXGE_HW_FIFO_NO_SNOOP_FRM 2
  220. #define VXGE_HW_FIFO_NO_SNOOP_ALL 3
  221. #define VXGE_HW_FIFO_NO_SNOOP_DEFAULT 0
  222. };
  223. /**
  224. * struct vxge_hw_ring_config - Ring configurations.
  225. * @enable: Is this ring to be commissioned
  226. * @ring_blocks: Numbers of RxD blocks in the ring
  227. * @buffer_mode: Receive buffer mode (1, 2, 3, or 5); for details please refer
  228. * to Titan User Guide.
  229. * @scatter_mode: Titan supports two receive scatter modes: A and B.
  230. * For details please refer to Titan User Guide.
  231. * @rx_timer_val: The number of 32ns periods that would be counted between two
  232. * timer interrupts.
  233. * @greedy_return: If Set it forces the device to return absolutely all RxD
  234. * that are consumed and still on board when a timer interrupt
  235. * triggers. If Clear, then if the device has already returned
  236. * RxD before current timer interrupt trigerred and after the
  237. * previous timer interrupt triggered, then the device is not
  238. * forced to returned the rest of the consumed RxD that it has
  239. * on board which account for a byte count less than the one
  240. * programmed into PRC_CFG6.RXD_CRXDT field
  241. * @rx_timer_ci: TBD
  242. * @backoff_interval_us: Time (in microseconds), after which Titan
  243. * tries to download RxDs posted by the host.
  244. * Note that the "backoff" does not happen if host posts receive
  245. * descriptors in the timely fashion.
  246. * Ring configuration.
  247. */
  248. struct vxge_hw_ring_config {
  249. u32 enable;
  250. #define VXGE_HW_RING_ENABLE 1
  251. #define VXGE_HW_RING_DISABLE 0
  252. #define VXGE_HW_RING_DEFAULT 1
  253. u32 ring_blocks;
  254. #define VXGE_HW_MIN_RING_BLOCKS 1
  255. #define VXGE_HW_MAX_RING_BLOCKS 128
  256. #define VXGE_HW_DEF_RING_BLOCKS 2
  257. u32 buffer_mode;
  258. #define VXGE_HW_RING_RXD_BUFFER_MODE_1 1
  259. #define VXGE_HW_RING_RXD_BUFFER_MODE_3 3
  260. #define VXGE_HW_RING_RXD_BUFFER_MODE_5 5
  261. #define VXGE_HW_RING_RXD_BUFFER_MODE_DEFAULT 1
  262. u32 scatter_mode;
  263. #define VXGE_HW_RING_SCATTER_MODE_A 0
  264. #define VXGE_HW_RING_SCATTER_MODE_B 1
  265. #define VXGE_HW_RING_SCATTER_MODE_C 2
  266. #define VXGE_HW_RING_SCATTER_MODE_USE_FLASH_DEFAULT 0xffffffff
  267. u64 rxds_limit;
  268. #define VXGE_HW_DEF_RING_RXDS_LIMIT 44
  269. };
  270. /**
  271. * struct vxge_hw_vp_config - Configuration of virtual path
  272. * @vp_id: Virtual Path Id
  273. * @min_bandwidth: Minimum Guaranteed bandwidth
  274. * @ring: See struct vxge_hw_ring_config{}.
  275. * @fifo: See struct vxge_hw_fifo_config{}.
  276. * @tti: Configuration of interrupt associated with Transmit.
  277. * see struct vxge_hw_tim_intr_config();
  278. * @rti: Configuration of interrupt associated with Receive.
  279. * see struct vxge_hw_tim_intr_config();
  280. * @mtu: mtu size used on this port.
  281. * @rpa_strip_vlan_tag: Strip VLAN Tag enable/disable. Instructs the device to
  282. * remove the VLAN tag from all received tagged frames that are not
  283. * replicated at the internal L2 switch.
  284. * 0 - Do not strip the VLAN tag.
  285. * 1 - Strip the VLAN tag. Regardless of this setting, VLAN tags are
  286. * always placed into the RxDMA descriptor.
  287. *
  288. * This structure is used by the driver to pass the configuration parameters to
  289. * configure Virtual Path.
  290. */
  291. struct vxge_hw_vp_config {
  292. u32 vp_id;
  293. #define VXGE_HW_VPATH_PRIORITY_MIN 0
  294. #define VXGE_HW_VPATH_PRIORITY_MAX 16
  295. #define VXGE_HW_VPATH_PRIORITY_DEFAULT 0
  296. u32 min_bandwidth;
  297. #define VXGE_HW_VPATH_BANDWIDTH_MIN 0
  298. #define VXGE_HW_VPATH_BANDWIDTH_MAX 100
  299. #define VXGE_HW_VPATH_BANDWIDTH_DEFAULT 0
  300. struct vxge_hw_ring_config ring;
  301. struct vxge_hw_fifo_config fifo;
  302. struct vxge_hw_tim_intr_config tti;
  303. struct vxge_hw_tim_intr_config rti;
  304. u32 mtu;
  305. #define VXGE_HW_VPATH_MIN_INITIAL_MTU VXGE_HW_MIN_MTU
  306. #define VXGE_HW_VPATH_MAX_INITIAL_MTU VXGE_HW_MAX_MTU
  307. #define VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU 0xffffffff
  308. u32 rpa_strip_vlan_tag;
  309. #define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE 1
  310. #define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_DISABLE 0
  311. #define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT 0xffffffff
  312. };
  313. /**
  314. * struct vxge_hw_device_config - Device configuration.
  315. * @dma_blockpool_initial: Initial size of DMA Pool
  316. * @dma_blockpool_max: Maximum blocks in DMA pool
  317. * @intr_mode: Line, or MSI-X interrupt.
  318. *
  319. * @rth_en: Enable Receive Traffic Hashing(RTH) using IT(Indirection Table).
  320. * @rth_it_type: RTH IT table programming type
  321. * @rts_mac_en: Enable Receive Traffic Steering using MAC destination address
  322. * @vp_config: Configuration for virtual paths
  323. * @device_poll_millis: Specify the interval (in mulliseconds)
  324. * to wait for register reads
  325. *
  326. * Titan configuration.
  327. * Contains per-device configuration parameters, including:
  328. * - stats sampling interval, etc.
  329. *
  330. * In addition, struct vxge_hw_device_config{} includes "subordinate"
  331. * configurations, including:
  332. * - fifos and rings;
  333. * - MAC (done at firmware level).
  334. *
  335. * See Titan User Guide for more details.
  336. * Note: Valid (min, max) range for each attribute is specified in the body of
  337. * the struct vxge_hw_device_config{} structure. Please refer to the
  338. * corresponding include file.
  339. * See also: struct vxge_hw_tim_intr_config{}.
  340. */
  341. struct vxge_hw_device_config {
  342. u32 dma_blockpool_initial;
  343. u32 dma_blockpool_max;
  344. #define VXGE_HW_MIN_DMA_BLOCK_POOL_SIZE 0
  345. #define VXGE_HW_INITIAL_DMA_BLOCK_POOL_SIZE 0
  346. #define VXGE_HW_INCR_DMA_BLOCK_POOL_SIZE 4
  347. #define VXGE_HW_MAX_DMA_BLOCK_POOL_SIZE 4096
  348. #define VXGE_HW_MAX_PAYLOAD_SIZE_512 2
  349. u32 intr_mode;
  350. #define VXGE_HW_INTR_MODE_IRQLINE 0
  351. #define VXGE_HW_INTR_MODE_MSIX 1
  352. #define VXGE_HW_INTR_MODE_MSIX_ONE_SHOT 2
  353. #define VXGE_HW_INTR_MODE_DEF 0
  354. u32 rth_en;
  355. #define VXGE_HW_RTH_DISABLE 0
  356. #define VXGE_HW_RTH_ENABLE 1
  357. #define VXGE_HW_RTH_DEFAULT 0
  358. u32 rth_it_type;
  359. #define VXGE_HW_RTH_IT_TYPE_SOLO_IT 0
  360. #define VXGE_HW_RTH_IT_TYPE_MULTI_IT 1
  361. #define VXGE_HW_RTH_IT_TYPE_DEFAULT 0
  362. u32 rts_mac_en;
  363. #define VXGE_HW_RTS_MAC_DISABLE 0
  364. #define VXGE_HW_RTS_MAC_ENABLE 1
  365. #define VXGE_HW_RTS_MAC_DEFAULT 0
  366. struct vxge_hw_vp_config vp_config[VXGE_HW_MAX_VIRTUAL_PATHS];
  367. u32 device_poll_millis;
  368. #define VXGE_HW_MIN_DEVICE_POLL_MILLIS 1
  369. #define VXGE_HW_MAX_DEVICE_POLL_MILLIS 100000
  370. #define VXGE_HW_DEF_DEVICE_POLL_MILLIS 1000
  371. };
  372. /**
  373. * function vxge_uld_link_up_f - Link-Up callback provided by driver.
  374. * @devh: HW device handle.
  375. * Link-up notification callback provided by the driver.
  376. * This is one of the per-driver callbacks, see struct vxge_hw_uld_cbs{}.
  377. *
  378. * See also: struct vxge_hw_uld_cbs{}, vxge_uld_link_down_f{},
  379. * vxge_hw_driver_initialize().
  380. */
  381. /**
  382. * function vxge_uld_link_down_f - Link-Down callback provided by
  383. * driver.
  384. * @devh: HW device handle.
  385. *
  386. * Link-Down notification callback provided by the driver.
  387. * This is one of the per-driver callbacks, see struct vxge_hw_uld_cbs{}.
  388. *
  389. * See also: struct vxge_hw_uld_cbs{}, vxge_uld_link_up_f{},
  390. * vxge_hw_driver_initialize().
  391. */
  392. /**
  393. * function vxge_uld_crit_err_f - Critical Error notification callback.
  394. * @devh: HW device handle.
  395. * (typically - at HW device iinitialization time).
  396. * @type: Enumerated hw error, e.g.: double ECC.
  397. * @serr_data: Titan status.
  398. * @ext_data: Extended data. The contents depends on the @type.
  399. *
  400. * Link-Down notification callback provided by the driver.
  401. * This is one of the per-driver callbacks, see struct vxge_hw_uld_cbs{}.
  402. *
  403. * See also: struct vxge_hw_uld_cbs{}, enum vxge_hw_event{},
  404. * vxge_hw_driver_initialize().
  405. */
  406. /**
  407. * struct vxge_hw_uld_cbs - driver "slow-path" callbacks.
  408. * @link_up: See vxge_uld_link_up_f{}.
  409. * @link_down: See vxge_uld_link_down_f{}.
  410. * @crit_err: See vxge_uld_crit_err_f{}.
  411. *
  412. * Driver slow-path (per-driver) callbacks.
  413. * Implemented by driver and provided to HW via
  414. * vxge_hw_driver_initialize().
  415. * Note that these callbacks are not mandatory: HW will not invoke
  416. * a callback if NULL is specified.
  417. *
  418. * See also: vxge_hw_driver_initialize().
  419. */
  420. struct vxge_hw_uld_cbs {
  421. void (*link_up)(struct __vxge_hw_device *devh);
  422. void (*link_down)(struct __vxge_hw_device *devh);
  423. void (*crit_err)(struct __vxge_hw_device *devh,
  424. enum vxge_hw_event type, u64 ext_data);
  425. };
  426. /*
  427. * struct __vxge_hw_blockpool_entry - Block private data structure
  428. * @item: List header used to link.
  429. * @length: Length of the block
  430. * @memblock: Virtual address block
  431. * @dma_addr: DMA Address of the block.
  432. * @dma_handle: DMA handle of the block.
  433. * @acc_handle: DMA acc handle
  434. *
  435. * Block is allocated with a header to put the blocks into list.
  436. *
  437. */
  438. struct __vxge_hw_blockpool_entry {
  439. struct list_head item;
  440. u32 length;
  441. void *memblock;
  442. dma_addr_t dma_addr;
  443. struct pci_dev *dma_handle;
  444. struct pci_dev *acc_handle;
  445. };
  446. /*
  447. * struct __vxge_hw_blockpool - Block Pool
  448. * @hldev: HW device
  449. * @block_size: size of each block.
  450. * @Pool_size: Number of blocks in the pool
  451. * @pool_max: Maximum number of blocks above which to free additional blocks
  452. * @req_out: Number of block requests with OS out standing
  453. * @free_block_list: List of free blocks
  454. *
  455. * Block pool contains the DMA blocks preallocated.
  456. *
  457. */
  458. struct __vxge_hw_blockpool {
  459. struct __vxge_hw_device *hldev;
  460. u32 block_size;
  461. u32 pool_size;
  462. u32 pool_max;
  463. u32 req_out;
  464. struct list_head free_block_list;
  465. struct list_head free_entry_list;
  466. };
  467. /*
  468. * enum enum __vxge_hw_channel_type - Enumerated channel types.
  469. * @VXGE_HW_CHANNEL_TYPE_UNKNOWN: Unknown channel.
  470. * @VXGE_HW_CHANNEL_TYPE_FIFO: fifo.
  471. * @VXGE_HW_CHANNEL_TYPE_RING: ring.
  472. * @VXGE_HW_CHANNEL_TYPE_MAX: Maximum number of HW-supported
  473. * (and recognized) channel types. Currently: 2.
  474. *
  475. * Enumerated channel types. Currently there are only two link-layer
  476. * channels - Titan fifo and Titan ring. In the future the list will grow.
  477. */
  478. enum __vxge_hw_channel_type {
  479. VXGE_HW_CHANNEL_TYPE_UNKNOWN = 0,
  480. VXGE_HW_CHANNEL_TYPE_FIFO = 1,
  481. VXGE_HW_CHANNEL_TYPE_RING = 2,
  482. VXGE_HW_CHANNEL_TYPE_MAX = 3
  483. };
  484. /*
  485. * struct __vxge_hw_channel
  486. * @item: List item; used to maintain a list of open channels.
  487. * @type: Channel type. See enum vxge_hw_channel_type{}.
  488. * @devh: Device handle. HW device object that contains _this_ channel.
  489. * @vph: Virtual path handle. Virtual Path Object that contains _this_ channel.
  490. * @length: Channel length. Currently allocated number of descriptors.
  491. * The channel length "grows" when more descriptors get allocated.
  492. * See _hw_mempool_grow.
  493. * @reserve_arr: Reserve array. Contains descriptors that can be reserved
  494. * by driver for the subsequent send or receive operation.
  495. * See vxge_hw_fifo_txdl_reserve(),
  496. * vxge_hw_ring_rxd_reserve().
  497. * @reserve_ptr: Current pointer in the resrve array
  498. * @reserve_top: Reserve top gives the maximum number of dtrs available in
  499. * reserve array.
  500. * @work_arr: Work array. Contains descriptors posted to the channel.
  501. * Note that at any point in time @work_arr contains 3 types of
  502. * descriptors:
  503. * 1) posted but not yet consumed by Titan device;
  504. * 2) consumed but not yet completed;
  505. * 3) completed but not yet freed
  506. * (via vxge_hw_fifo_txdl_free() or vxge_hw_ring_rxd_free())
  507. * @post_index: Post index. At any point in time points on the
  508. * position in the channel, which'll contain next to-be-posted
  509. * descriptor.
  510. * @compl_index: Completion index. At any point in time points on the
  511. * position in the channel, which will contain next
  512. * to-be-completed descriptor.
  513. * @free_arr: Free array. Contains completed descriptors that were freed
  514. * (i.e., handed over back to HW) by driver.
  515. * See vxge_hw_fifo_txdl_free(), vxge_hw_ring_rxd_free().
  516. * @free_ptr: current pointer in free array
  517. * @per_dtr_space: Per-descriptor space (in bytes) that channel user can utilize
  518. * to store per-operation control information.
  519. * @stats: Pointer to common statistics
  520. * @userdata: Per-channel opaque (void*) user-defined context, which may be
  521. * driver object, ULP connection, etc.
  522. * Once channel is open, @userdata is passed back to user via
  523. * vxge_hw_channel_callback_f.
  524. *
  525. * HW channel object.
  526. *
  527. * See also: enum vxge_hw_channel_type{}, enum vxge_hw_channel_flag
  528. */
  529. struct __vxge_hw_channel {
  530. struct list_head item;
  531. enum __vxge_hw_channel_type type;
  532. struct __vxge_hw_device *devh;
  533. struct __vxge_hw_vpath_handle *vph;
  534. u32 length;
  535. u32 vp_id;
  536. void **reserve_arr;
  537. u32 reserve_ptr;
  538. u32 reserve_top;
  539. void **work_arr;
  540. u32 post_index ____cacheline_aligned;
  541. u32 compl_index ____cacheline_aligned;
  542. void **free_arr;
  543. u32 free_ptr;
  544. void **orig_arr;
  545. u32 per_dtr_space;
  546. void *userdata;
  547. struct vxge_hw_common_reg __iomem *common_reg;
  548. u32 first_vp_id;
  549. struct vxge_hw_vpath_stats_sw_common_info *stats;
  550. } ____cacheline_aligned;
  551. /*
  552. * struct __vxge_hw_virtualpath - Virtual Path
  553. *
  554. * @vp_id: Virtual path id
  555. * @vp_open: This flag specifies if vxge_hw_vp_open is called from LL Driver
  556. * @hldev: Hal device
  557. * @vp_config: Virtual Path Config
  558. * @vp_reg: VPATH Register map address in BAR0
  559. * @vpmgmt_reg: VPATH_MGMT register map address
  560. * @max_mtu: Max mtu that can be supported
  561. * @vsport_number: vsport attached to this vpath
  562. * @max_kdfc_db: Maximum kernel mode doorbells
  563. * @max_nofl_db: Maximum non offload doorbells
  564. * @tx_intr_num: Interrupt Number associated with the TX
  565. * @ringh: Ring Queue
  566. * @fifoh: FIFO Queue
  567. * @vpath_handles: Virtual Path handles list
  568. * @stats_block: Memory for DMAing stats
  569. * @stats: Vpath statistics
  570. *
  571. * Virtual path structure to encapsulate the data related to a virtual path.
  572. * Virtual paths are allocated by the HW upon getting configuration from the
  573. * driver and inserted into the list of virtual paths.
  574. */
  575. struct __vxge_hw_virtualpath {
  576. u32 vp_id;
  577. u32 vp_open;
  578. #define VXGE_HW_VP_NOT_OPEN 0
  579. #define VXGE_HW_VP_OPEN 1
  580. struct __vxge_hw_device *hldev;
  581. struct vxge_hw_vp_config *vp_config;
  582. struct vxge_hw_vpath_reg __iomem *vp_reg;
  583. struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg;
  584. struct __vxge_hw_non_offload_db_wrapper __iomem *nofl_db;
  585. u32 max_mtu;
  586. u32 vsport_number;
  587. u32 max_kdfc_db;
  588. u32 max_nofl_db;
  589. struct __vxge_hw_ring *____cacheline_aligned ringh;
  590. struct __vxge_hw_fifo *____cacheline_aligned fifoh;
  591. struct list_head vpath_handles;
  592. struct __vxge_hw_blockpool_entry *stats_block;
  593. struct vxge_hw_vpath_stats_hw_info *hw_stats;
  594. struct vxge_hw_vpath_stats_hw_info *hw_stats_sav;
  595. struct vxge_hw_vpath_stats_sw_info *sw_stats;
  596. };
  597. /*
  598. * struct __vxge_hw_vpath_handle - List item to store callback information
  599. * @item: List head to keep the item in linked list
  600. * @vpath: Virtual path to which this item belongs
  601. *
  602. * This structure is used to store the callback information.
  603. */
  604. struct __vxge_hw_vpath_handle{
  605. struct list_head item;
  606. struct __vxge_hw_virtualpath *vpath;
  607. };
  608. /*
  609. * struct __vxge_hw_device
  610. *
  611. * HW device object.
  612. */
  613. /**
  614. * struct __vxge_hw_device - Hal device object
  615. * @magic: Magic Number
  616. * @device_id: PCI Device Id of the adapter
  617. * @major_revision: PCI Device major revision
  618. * @minor_revision: PCI Device minor revision
  619. * @bar0: BAR0 virtual address.
  620. * @pdev: Physical device handle
  621. * @config: Confguration passed by the LL driver at initialization
  622. * @link_state: Link state
  623. *
  624. * HW device object. Represents Titan adapter
  625. */
  626. struct __vxge_hw_device {
  627. u32 magic;
  628. #define VXGE_HW_DEVICE_MAGIC 0x12345678
  629. #define VXGE_HW_DEVICE_DEAD 0xDEADDEAD
  630. u16 device_id;
  631. u8 major_revision;
  632. u8 minor_revision;
  633. void __iomem *bar0;
  634. struct pci_dev *pdev;
  635. struct net_device *ndev;
  636. struct vxge_hw_device_config config;
  637. enum vxge_hw_device_link_state link_state;
  638. struct vxge_hw_uld_cbs uld_callbacks;
  639. u32 host_type;
  640. u32 func_id;
  641. u32 access_rights;
  642. #define VXGE_HW_DEVICE_ACCESS_RIGHT_VPATH 0x1
  643. #define VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM 0x2
  644. #define VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM 0x4
  645. struct vxge_hw_legacy_reg __iomem *legacy_reg;
  646. struct vxge_hw_toc_reg __iomem *toc_reg;
  647. struct vxge_hw_common_reg __iomem *common_reg;
  648. struct vxge_hw_mrpcim_reg __iomem *mrpcim_reg;
  649. struct vxge_hw_srpcim_reg __iomem *srpcim_reg \
  650. [VXGE_HW_TITAN_SRPCIM_REG_SPACES];
  651. struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg \
  652. [VXGE_HW_TITAN_VPMGMT_REG_SPACES];
  653. struct vxge_hw_vpath_reg __iomem *vpath_reg \
  654. [VXGE_HW_TITAN_VPATH_REG_SPACES];
  655. u8 __iomem *kdfc;
  656. u8 __iomem *usdc;
  657. struct __vxge_hw_virtualpath virtual_paths \
  658. [VXGE_HW_MAX_VIRTUAL_PATHS];
  659. u64 vpath_assignments;
  660. u64 vpaths_deployed;
  661. u32 first_vp_id;
  662. u64 tim_int_mask0[4];
  663. u32 tim_int_mask1[4];
  664. struct __vxge_hw_blockpool block_pool;
  665. struct vxge_hw_device_stats stats;
  666. u32 debug_module_mask;
  667. u32 debug_level;
  668. u32 level_err;
  669. u32 level_trace;
  670. };
  671. #define VXGE_HW_INFO_LEN 64
  672. /**
  673. * struct vxge_hw_device_hw_info - Device information
  674. * @host_type: Host Type
  675. * @func_id: Function Id
  676. * @vpath_mask: vpath bit mask
  677. * @fw_version: Firmware version
  678. * @fw_date: Firmware Date
  679. * @flash_version: Firmware version
  680. * @flash_date: Firmware Date
  681. * @mac_addrs: Mac addresses for each vpath
  682. * @mac_addr_masks: Mac address masks for each vpath
  683. *
  684. * Returns the vpath mask that has the bits set for each vpath allocated
  685. * for the driver and the first mac address for each vpath
  686. */
  687. struct vxge_hw_device_hw_info {
  688. u32 host_type;
  689. #define VXGE_HW_NO_MR_NO_SR_NORMAL_FUNCTION 0
  690. #define VXGE_HW_MR_NO_SR_VH0_BASE_FUNCTION 1
  691. #define VXGE_HW_NO_MR_SR_VH0_FUNCTION0 2
  692. #define VXGE_HW_NO_MR_SR_VH0_VIRTUAL_FUNCTION 3
  693. #define VXGE_HW_MR_SR_VH0_INVALID_CONFIG 4
  694. #define VXGE_HW_SR_VH_FUNCTION0 5
  695. #define VXGE_HW_SR_VH_VIRTUAL_FUNCTION 6
  696. #define VXGE_HW_VH_NORMAL_FUNCTION 7
  697. u64 function_mode;
  698. #define VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION 0
  699. #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION 1
  700. #define VXGE_HW_FUNCTION_MODE_SRIOV 2
  701. #define VXGE_HW_FUNCTION_MODE_MRIOV 3
  702. #define VXGE_HW_FUNCTION_MODE_MRIOV_8 4
  703. #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_17 5
  704. #define VXGE_HW_FUNCTION_MODE_SRIOV_8 6
  705. #define VXGE_HW_FUNCTION_MODE_SRIOV_4 7
  706. #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_2 8
  707. #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_4 9
  708. #define VXGE_HW_FUNCTION_MODE_MRIOV_4 10
  709. u32 func_id;
  710. u64 vpath_mask;
  711. struct vxge_hw_device_version fw_version;
  712. struct vxge_hw_device_date fw_date;
  713. struct vxge_hw_device_version flash_version;
  714. struct vxge_hw_device_date flash_date;
  715. u8 serial_number[VXGE_HW_INFO_LEN];
  716. u8 part_number[VXGE_HW_INFO_LEN];
  717. u8 product_desc[VXGE_HW_INFO_LEN];
  718. u8 (mac_addrs)[VXGE_HW_MAX_VIRTUAL_PATHS][ETH_ALEN];
  719. u8 (mac_addr_masks)[VXGE_HW_MAX_VIRTUAL_PATHS][ETH_ALEN];
  720. };
  721. /**
  722. * struct vxge_hw_device_attr - Device memory spaces.
  723. * @bar0: BAR0 virtual address.
  724. * @pdev: PCI device object.
  725. *
  726. * Device memory spaces. Includes configuration, BAR0 etc. per device
  727. * mapped memories. Also, includes a pointer to OS-specific PCI device object.
  728. */
  729. struct vxge_hw_device_attr {
  730. void __iomem *bar0;
  731. struct pci_dev *pdev;
  732. struct vxge_hw_uld_cbs uld_callbacks;
  733. };
  734. #define VXGE_HW_DEVICE_LINK_STATE_SET(hldev, ls) (hldev->link_state = ls)
  735. #define VXGE_HW_DEVICE_TIM_INT_MASK_SET(m0, m1, i) { \
  736. if (i < 16) { \
  737. m0[0] |= vxge_vBIT(0x8, (i*4), 4); \
  738. m0[1] |= vxge_vBIT(0x4, (i*4), 4); \
  739. } \
  740. else { \
  741. m1[0] = 0x80000000; \
  742. m1[1] = 0x40000000; \
  743. } \
  744. }
  745. #define VXGE_HW_DEVICE_TIM_INT_MASK_RESET(m0, m1, i) { \
  746. if (i < 16) { \
  747. m0[0] &= ~vxge_vBIT(0x8, (i*4), 4); \
  748. m0[1] &= ~vxge_vBIT(0x4, (i*4), 4); \
  749. } \
  750. else { \
  751. m1[0] = 0; \
  752. m1[1] = 0; \
  753. } \
  754. }
  755. #define VXGE_HW_DEVICE_STATS_PIO_READ(loc, offset) { \
  756. status = vxge_hw_mrpcim_stats_access(hldev, \
  757. VXGE_HW_STATS_OP_READ, \
  758. loc, \
  759. offset, \
  760. &val64); \
  761. \
  762. if (status != VXGE_HW_OK) \
  763. return status; \
  764. }
  765. #define VXGE_HW_VPATH_STATS_PIO_READ(offset) { \
  766. status = __vxge_hw_vpath_stats_access(vpath, \
  767. VXGE_HW_STATS_OP_READ, \
  768. offset, \
  769. &val64); \
  770. if (status != VXGE_HW_OK) \
  771. return status; \
  772. }
  773. /*
  774. * struct __vxge_hw_ring - Ring channel.
  775. * @channel: Channel "base" of this ring, the common part of all HW
  776. * channels.
  777. * @mempool: Memory pool, the pool from which descriptors get allocated.
  778. * (See vxge_hw_mm.h).
  779. * @config: Ring configuration, part of device configuration
  780. * (see struct vxge_hw_device_config{}).
  781. * @ring_length: Length of the ring
  782. * @buffer_mode: 1, 3, or 5. The value specifies a receive buffer mode,
  783. * as per Titan User Guide.
  784. * @rxd_size: RxD sizes for 1-, 3- or 5- buffer modes. As per Titan spec,
  785. * 1-buffer mode descriptor is 32 byte long, etc.
  786. * @rxd_priv_size: Per RxD size reserved (by HW) for driver to keep
  787. * per-descriptor data (e.g., DMA handle for Solaris)
  788. * @per_rxd_space: Per rxd space requested by driver
  789. * @rxds_per_block: Number of descriptors per hardware-defined RxD
  790. * block. Depends on the (1-, 3-, 5-) buffer mode.
  791. * @rxdblock_priv_size: Reserved at the end of each RxD block. HW internal
  792. * usage. Not to confuse with @rxd_priv_size.
  793. * @cmpl_cnt: Completion counter. Is reset to zero upon entering the ISR.
  794. * @callback: Channel completion callback. HW invokes the callback when there
  795. * are new completions on that channel. In many implementations
  796. * the @callback executes in the hw interrupt context.
  797. * @rxd_init: Channel's descriptor-initialize callback.
  798. * See vxge_hw_ring_rxd_init_f{}.
  799. * If not NULL, HW invokes the callback when opening
  800. * the ring.
  801. * @rxd_term: Channel's descriptor-terminate callback. If not NULL,
  802. * HW invokes the callback when closing the corresponding channel.
  803. * See also vxge_hw_channel_rxd_term_f{}.
  804. * @stats: Statistics for ring
  805. * Ring channel.
  806. *
  807. * Note: The structure is cache line aligned to better utilize
  808. * CPU cache performance.
  809. */
  810. struct __vxge_hw_ring {
  811. struct __vxge_hw_channel channel;
  812. struct vxge_hw_mempool *mempool;
  813. struct vxge_hw_vpath_reg __iomem *vp_reg;
  814. struct vxge_hw_common_reg __iomem *common_reg;
  815. u32 ring_length;
  816. u32 buffer_mode;
  817. u32 rxd_size;
  818. u32 rxd_priv_size;
  819. u32 per_rxd_space;
  820. u32 rxds_per_block;
  821. u32 rxdblock_priv_size;
  822. u32 cmpl_cnt;
  823. u32 vp_id;
  824. u32 doorbell_cnt;
  825. u32 total_db_cnt;
  826. u64 rxds_limit;
  827. enum vxge_hw_status (*callback)(
  828. struct __vxge_hw_ring *ringh,
  829. void *rxdh,
  830. u8 t_code,
  831. void *userdata);
  832. enum vxge_hw_status (*rxd_init)(
  833. void *rxdh,
  834. void *userdata);
  835. void (*rxd_term)(
  836. void *rxdh,
  837. enum vxge_hw_rxd_state state,
  838. void *userdata);
  839. struct vxge_hw_vpath_stats_sw_ring_info *stats ____cacheline_aligned;
  840. struct vxge_hw_ring_config *config;
  841. } ____cacheline_aligned;
  842. /**
  843. * enum enum vxge_hw_txdl_state - Descriptor (TXDL) state.
  844. * @VXGE_HW_TXDL_STATE_NONE: Invalid state.
  845. * @VXGE_HW_TXDL_STATE_AVAIL: Descriptor is available for reservation.
  846. * @VXGE_HW_TXDL_STATE_POSTED: Descriptor is posted for processing by the
  847. * device.
  848. * @VXGE_HW_TXDL_STATE_FREED: Descriptor is free and can be reused for
  849. * filling-in and posting later.
  850. *
  851. * Titan/HW descriptor states.
  852. *
  853. */
  854. enum vxge_hw_txdl_state {
  855. VXGE_HW_TXDL_STATE_NONE = 0,
  856. VXGE_HW_TXDL_STATE_AVAIL = 1,
  857. VXGE_HW_TXDL_STATE_POSTED = 2,
  858. VXGE_HW_TXDL_STATE_FREED = 3
  859. };
  860. /*
  861. * struct __vxge_hw_fifo - Fifo.
  862. * @channel: Channel "base" of this fifo, the common part of all HW
  863. * channels.
  864. * @mempool: Memory pool, from which descriptors get allocated.
  865. * @config: Fifo configuration, part of device configuration
  866. * (see struct vxge_hw_device_config{}).
  867. * @interrupt_type: Interrupt type to be used
  868. * @no_snoop_bits: See struct vxge_hw_fifo_config{}.
  869. * @txdl_per_memblock: Number of TxDLs (TxD lists) per memblock.
  870. * on TxDL please refer to Titan UG.
  871. * @txdl_size: Configured TxDL size (i.e., number of TxDs in a list), plus
  872. * per-TxDL HW private space (struct __vxge_hw_fifo_txdl_priv).
  873. * @priv_size: Per-Tx descriptor space reserved for driver
  874. * usage.
  875. * @per_txdl_space: Per txdl private space for the driver
  876. * @callback: Fifo completion callback. HW invokes the callback when there
  877. * are new completions on that fifo. In many implementations
  878. * the @callback executes in the hw interrupt context.
  879. * @txdl_term: Fifo's descriptor-terminate callback. If not NULL,
  880. * HW invokes the callback when closing the corresponding fifo.
  881. * See also vxge_hw_fifo_txdl_term_f{}.
  882. * @stats: Statistics of this fifo
  883. *
  884. * Fifo channel.
  885. * Note: The structure is cache line aligned.
  886. */
  887. struct __vxge_hw_fifo {
  888. struct __vxge_hw_channel channel;
  889. struct vxge_hw_mempool *mempool;
  890. struct vxge_hw_fifo_config *config;
  891. struct vxge_hw_vpath_reg __iomem *vp_reg;
  892. struct __vxge_hw_non_offload_db_wrapper __iomem *nofl_db;
  893. u64 interrupt_type;
  894. u32 no_snoop_bits;
  895. u32 txdl_per_memblock;
  896. u32 txdl_size;
  897. u32 priv_size;
  898. u32 per_txdl_space;
  899. u32 vp_id;
  900. u32 tx_intr_num;
  901. enum vxge_hw_status (*callback)(
  902. struct __vxge_hw_fifo *fifo_handle,
  903. void *txdlh,
  904. enum vxge_hw_fifo_tcode t_code,
  905. void *userdata,
  906. struct sk_buff ***skb_ptr,
  907. int nr_skb,
  908. int *more);
  909. void (*txdl_term)(
  910. void *txdlh,
  911. enum vxge_hw_txdl_state state,
  912. void *userdata);
  913. struct vxge_hw_vpath_stats_sw_fifo_info *stats ____cacheline_aligned;
  914. } ____cacheline_aligned;
  915. /*
  916. * struct __vxge_hw_fifo_txdl_priv - Transmit descriptor HW-private data.
  917. * @dma_addr: DMA (mapped) address of _this_ descriptor.
  918. * @dma_handle: DMA handle used to map the descriptor onto device.
  919. * @dma_offset: Descriptor's offset in the memory block. HW allocates
  920. * descriptors in memory blocks (see struct vxge_hw_fifo_config{})
  921. * Each memblock is a contiguous block of DMA-able memory.
  922. * @frags: Total number of fragments (that is, contiguous data buffers)
  923. * carried by this TxDL.
  924. * @align_vaddr_start: Aligned virtual address start
  925. * @align_vaddr: Virtual address of the per-TxDL area in memory used for
  926. * alignement. Used to place one or more mis-aligned fragments
  927. * @align_dma_addr: DMA address translated from the @align_vaddr.
  928. * @align_dma_handle: DMA handle that corresponds to @align_dma_addr.
  929. * @align_dma_acch: DMA access handle corresponds to @align_dma_addr.
  930. * @align_dma_offset: The current offset into the @align_vaddr area.
  931. * Grows while filling the descriptor, gets reset.
  932. * @align_used_frags: Number of fragments used.
  933. * @alloc_frags: Total number of fragments allocated.
  934. * @unused: TODO
  935. * @next_txdl_priv: (TODO).
  936. * @first_txdp: (TODO).
  937. * @linked_txdl_priv: Pointer to any linked TxDL for creating contiguous
  938. * TxDL list.
  939. * @txdlh: Corresponding txdlh to this TxDL.
  940. * @memblock: Pointer to the TxDL memory block or memory page.
  941. * on the next send operation.
  942. * @dma_object: DMA address and handle of the memory block that contains
  943. * the descriptor. This member is used only in the "checked"
  944. * version of the HW (to enforce certain assertions);
  945. * otherwise it gets compiled out.
  946. * @allocated: True if the descriptor is reserved, 0 otherwise. Internal usage.
  947. *
  948. * Per-transmit decsriptor HW-private data. HW uses the space to keep DMA
  949. * information associated with the descriptor. Note that driver can ask HW
  950. * to allocate additional per-descriptor space for its own (driver-specific)
  951. * purposes.
  952. *
  953. * See also: struct vxge_hw_ring_rxd_priv{}.
  954. */
  955. struct __vxge_hw_fifo_txdl_priv {
  956. dma_addr_t dma_addr;
  957. struct pci_dev *dma_handle;
  958. ptrdiff_t dma_offset;
  959. u32 frags;
  960. u8 *align_vaddr_start;
  961. u8 *align_vaddr;
  962. dma_addr_t align_dma_addr;
  963. struct pci_dev *align_dma_handle;
  964. struct pci_dev *align_dma_acch;
  965. ptrdiff_t align_dma_offset;
  966. u32 align_used_frags;
  967. u32 alloc_frags;
  968. u32 unused;
  969. struct __vxge_hw_fifo_txdl_priv *next_txdl_priv;
  970. struct vxge_hw_fifo_txd *first_txdp;
  971. void *memblock;
  972. };
  973. /*
  974. * struct __vxge_hw_non_offload_db_wrapper - Non-offload Doorbell Wrapper
  975. * @control_0: Bits 0 to 7 - Doorbell type.
  976. * Bits 8 to 31 - Reserved.
  977. * Bits 32 to 39 - The highest TxD in this TxDL.
  978. * Bits 40 to 47 - Reserved.
  979. * Bits 48 to 55 - Reserved.
  980. * Bits 56 to 63 - No snoop flags.
  981. * @txdl_ptr: The starting location of the TxDL in host memory.
  982. *
  983. * Created by the host and written to the adapter via PIO to a Kernel Doorbell
  984. * FIFO. All non-offload doorbell wrapper fields must be written by the host as
  985. * part of a doorbell write. Consumed by the adapter but is not written by the
  986. * adapter.
  987. */
  988. struct __vxge_hw_non_offload_db_wrapper {
  989. u64 control_0;
  990. #define VXGE_HW_NODBW_GET_TYPE(ctrl0) vxge_bVALn(ctrl0, 0, 8)
  991. #define VXGE_HW_NODBW_TYPE(val) vxge_vBIT(val, 0, 8)
  992. #define VXGE_HW_NODBW_TYPE_NODBW 0
  993. #define VXGE_HW_NODBW_GET_LAST_TXD_NUMBER(ctrl0) vxge_bVALn(ctrl0, 32, 8)
  994. #define VXGE_HW_NODBW_LAST_TXD_NUMBER(val) vxge_vBIT(val, 32, 8)
  995. #define VXGE_HW_NODBW_GET_NO_SNOOP(ctrl0) vxge_bVALn(ctrl0, 56, 8)
  996. #define VXGE_HW_NODBW_LIST_NO_SNOOP(val) vxge_vBIT(val, 56, 8)
  997. #define VXGE_HW_NODBW_LIST_NO_SNOOP_TXD_READ_TXD0_WRITE 0x2
  998. #define VXGE_HW_NODBW_LIST_NO_SNOOP_TX_FRAME_DATA_READ 0x1
  999. u64 txdl_ptr;
  1000. };
  1001. /*
  1002. * TX Descriptor
  1003. */
  1004. /**
  1005. * struct vxge_hw_fifo_txd - Transmit Descriptor
  1006. * @control_0: Bits 0 to 6 - Reserved.
  1007. * Bit 7 - List Ownership. This field should be initialized
  1008. * to '1' by the driver before the transmit list pointer is
  1009. * written to the adapter. This field will be set to '0' by the
  1010. * adapter once it has completed transmitting the frame or frames in
  1011. * the list. Note - This field is only valid in TxD0. Additionally,
  1012. * for multi-list sequences, the driver should not release any
  1013. * buffers until the ownership of the last list in the multi-list
  1014. * sequence has been returned to the host.
  1015. * Bits 8 to 11 - Reserved
  1016. * Bits 12 to 15 - Transfer_Code. This field is only valid in
  1017. * TxD0. It is used to describe the status of the transmit data
  1018. * buffer transfer. This field is always overwritten by the
  1019. * adapter, so this field may be initialized to any value.
  1020. * Bits 16 to 17 - Host steering. This field allows the host to
  1021. * override the selection of the physical transmit port.
  1022. * Attention:
  1023. * Normal sounds as if learned from the switch rather than from
  1024. * the aggregation algorythms.
  1025. * 00: Normal. Use Destination/MAC Address
  1026. * lookup to determine the transmit port.
  1027. * 01: Send on physical Port1.
  1028. * 10: Send on physical Port0.
  1029. * 11: Send on both ports.
  1030. * Bits 18 to 21 - Reserved
  1031. * Bits 22 to 23 - Gather_Code. This field is set by the host and
  1032. * is used to describe how individual buffers comprise a frame.
  1033. * 10: First descriptor of a frame.
  1034. * 00: Middle of a multi-descriptor frame.
  1035. * 01: Last descriptor of a frame.
  1036. * 11: First and last descriptor of a frame (the entire frame
  1037. * resides in a single buffer).
  1038. * For multi-descriptor frames, the only valid gather code sequence
  1039. * is {10, [00], 01}. In other words, the descriptors must be placed
  1040. * in the list in the correct order.
  1041. * Bits 24 to 27 - Reserved
  1042. * Bits 28 to 29 - LSO_Frm_Encap. LSO Frame Encapsulation
  1043. * definition. Only valid in TxD0. This field allows the host to
  1044. * indicate the Ethernet encapsulation of an outbound LSO packet.
  1045. * 00 - classic mode (best guess)
  1046. * 01 - LLC
  1047. * 10 - SNAP
  1048. * 11 - DIX
  1049. * If "classic mode" is selected, the adapter will attempt to
  1050. * decode the frame's Ethernet encapsulation by examining the L/T
  1051. * field as follows:
  1052. * <= 0x05DC LLC/SNAP encoding; must examine DSAP/SSAP to determine
  1053. * if packet is IPv4 or IPv6.
  1054. * 0x8870 Jumbo-SNAP encoding.
  1055. * 0x0800 IPv4 DIX encoding
  1056. * 0x86DD IPv6 DIX encoding
  1057. * others illegal encapsulation
  1058. * Bits 30 - LSO_ Flag. Large Send Offload (LSO) flag.
  1059. * Set to 1 to perform segmentation offload for TCP/UDP.
  1060. * This field is valid only in TxD0.
  1061. * Bits 31 to 33 - Reserved.
  1062. * Bits 34 to 47 - LSO_MSS. TCP/UDP LSO Maximum Segment Size
  1063. * This field is meaningful only when LSO_Control is non-zero.
  1064. * When LSO_Control is set to TCP_LSO, the single (possibly large)
  1065. * TCP segment described by this TxDL will be sent as a series of
  1066. * TCP segments each of which contains no more than LSO_MSS
  1067. * payload bytes.
  1068. * When LSO_Control is set to UDP_LSO, the single (possibly large)
  1069. * UDP datagram described by this TxDL will be sent as a series of
  1070. * UDP datagrams each of which contains no more than LSO_MSS
  1071. * payload bytes.
  1072. * All outgoing frames from this TxDL will have LSO_MSS bytes of UDP
  1073. * or TCP payload, with the exception of the last, which will have
  1074. * <= LSO_MSS bytes of payload.
  1075. * Bits 48 to 63 - Buffer_Size. Number of valid bytes in the
  1076. * buffer to be read by the adapter. This field is written by the
  1077. * host. A value of 0 is illegal.
  1078. * Bits 32 to 63 - This value is written by the adapter upon
  1079. * completion of a UDP or TCP LSO operation and indicates the number
  1080. * of UDP or TCP payload bytes that were transmitted. 0x0000 will be
  1081. * returned for any non-LSO operation.
  1082. * @control_1: Bits 0 to 4 - Reserved.
  1083. * Bit 5 - Tx_CKO_IPv4 Set to a '1' to enable IPv4 header checksum
  1084. * offload. This field is only valid in the first TxD of a frame.
  1085. * Bit 6 - Tx_CKO_TCP Set to a '1' to enable TCP checksum offload.
  1086. * This field is only valid in the first TxD of a frame (the TxD's
  1087. * gather code must be 10 or 11). The driver should only set this
  1088. * bit if it can guarantee that TCP is present.
  1089. * Bit 7 - Tx_CKO_UDP Set to a '1' to enable UDP checksum offload.
  1090. * This field is only valid in the first TxD of a frame (the TxD's
  1091. * gather code must be 10 or 11). The driver should only set this
  1092. * bit if it can guarantee that UDP is present.
  1093. * Bits 8 to 14 - Reserved.
  1094. * Bit 15 - Tx_VLAN_Enable VLAN tag insertion flag. Set to a '1' to
  1095. * instruct the adapter to insert the VLAN tag specified by the
  1096. * Tx_VLAN_Tag field. This field is only valid in the first TxD of
  1097. * a frame.
  1098. * Bits 16 to 31 - Tx_VLAN_Tag. Variable portion of the VLAN tag
  1099. * to be inserted into the frame by the adapter (the first two bytes
  1100. * of a VLAN tag are always 0x8100). This field is only valid if the
  1101. * Tx_VLAN_Enable field is set to '1'.
  1102. * Bits 32 to 33 - Reserved.
  1103. * Bits 34 to 39 - Tx_Int_Number. Indicates which Tx interrupt
  1104. * number the frame associated with. This field is written by the
  1105. * host. It is only valid in the first TxD of a frame.
  1106. * Bits 40 to 42 - Reserved.
  1107. * Bit 43 - Set to 1 to exclude the frame from bandwidth metering
  1108. * functions. This field is valid only in the first TxD
  1109. * of a frame.
  1110. * Bits 44 to 45 - Reserved.
  1111. * Bit 46 - Tx_Int_Per_List Set to a '1' to instruct the adapter to
  1112. * generate an interrupt as soon as all of the frames in the list
  1113. * have been transmitted. In order to have per-frame interrupts,
  1114. * the driver should place a maximum of one frame per list. This
  1115. * field is only valid in the first TxD of a frame.
  1116. * Bit 47 - Tx_Int_Utilization Set to a '1' to instruct the adapter
  1117. * to count the frame toward the utilization interrupt specified in
  1118. * the Tx_Int_Number field. This field is only valid in the first
  1119. * TxD of a frame.
  1120. * Bits 48 to 63 - Reserved.
  1121. * @buffer_pointer: Buffer start address.
  1122. * @host_control: Host_Control.Opaque 64bit data stored by driver inside the
  1123. * Titan descriptor prior to posting the latter on the fifo
  1124. * via vxge_hw_fifo_txdl_post().The %host_control is returned as is
  1125. * to the driver with each completed descriptor.
  1126. *
  1127. * Transmit descriptor (TxD).Fifo descriptor contains configured number
  1128. * (list) of TxDs. * For more details please refer to Titan User Guide,
  1129. * Section 5.4.2 "Transmit Descriptor (TxD) Format".
  1130. */
  1131. struct vxge_hw_fifo_txd {
  1132. u64 control_0;
  1133. #define VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER vxge_mBIT(7)
  1134. #define VXGE_HW_FIFO_TXD_T_CODE_GET(ctrl0) vxge_bVALn(ctrl0, 12, 4)
  1135. #define VXGE_HW_FIFO_TXD_T_CODE(val) vxge_vBIT(val, 12, 4)
  1136. #define VXGE_HW_FIFO_TXD_T_CODE_UNUSED VXGE_HW_FIFO_T_CODE_UNUSED
  1137. #define VXGE_HW_FIFO_TXD_GATHER_CODE(val) vxge_vBIT(val, 22, 2)
  1138. #define VXGE_HW_FIFO_TXD_GATHER_CODE_FIRST VXGE_HW_FIFO_GATHER_CODE_FIRST
  1139. #define VXGE_HW_FIFO_TXD_GATHER_CODE_LAST VXGE_HW_FIFO_GATHER_CODE_LAST
  1140. #define VXGE_HW_FIFO_TXD_LSO_EN vxge_mBIT(30)
  1141. #define VXGE_HW_FIFO_TXD_LSO_MSS(val) vxge_vBIT(val, 34, 14)
  1142. #define VXGE_HW_FIFO_TXD_BUFFER_SIZE(val) vxge_vBIT(val, 48, 16)
  1143. u64 control_1;
  1144. #define VXGE_HW_FIFO_TXD_TX_CKO_IPV4_EN vxge_mBIT(5)
  1145. #define VXGE_HW_FIFO_TXD_TX_CKO_TCP_EN vxge_mBIT(6)
  1146. #define VXGE_HW_FIFO_TXD_TX_CKO_UDP_EN vxge_mBIT(7)
  1147. #define VXGE_HW_FIFO_TXD_VLAN_ENABLE vxge_mBIT(15)
  1148. #define VXGE_HW_FIFO_TXD_VLAN_TAG(val) vxge_vBIT(val, 16, 16)
  1149. #define VXGE_HW_FIFO_TXD_INT_NUMBER(val) vxge_vBIT(val, 34, 6)
  1150. #define VXGE_HW_FIFO_TXD_INT_TYPE_PER_LIST vxge_mBIT(46)
  1151. #define VXGE_HW_FIFO_TXD_INT_TYPE_UTILZ vxge_mBIT(47)
  1152. u64 buffer_pointer;
  1153. u64 host_control;
  1154. };
  1155. /**
  1156. * struct vxge_hw_ring_rxd_1 - One buffer mode RxD for ring
  1157. * @host_control: This field is exclusively for host use and is "readonly"
  1158. * from the adapter's perspective.
  1159. * @control_0:Bits 0 to 6 - RTH_Bucket get
  1160. * Bit 7 - Own Descriptor ownership bit. This bit is set to 1
  1161. * by the host, and is set to 0 by the adapter.
  1162. * 0 - Host owns RxD and buffer.
  1163. * 1 - The adapter owns RxD and buffer.
  1164. * Bit 8 - Fast_Path_Eligible When set, indicates that the
  1165. * received frame meets all of the criteria for fast path processing.
  1166. * The required criteria are as follows:
  1167. * !SYN &
  1168. * (Transfer_Code == "Transfer OK") &
  1169. * (!Is_IP_Fragment) &
  1170. * ((Is_IPv4 & computed_L3_checksum == 0xFFFF) |
  1171. * (Is_IPv6)) &
  1172. * ((Is_TCP & computed_L4_checksum == 0xFFFF) |
  1173. * (Is_UDP & (computed_L4_checksum == 0xFFFF |
  1174. * computed _L4_checksum == 0x0000)))
  1175. * (same meaning for all RxD buffer modes)
  1176. * Bit 9 - L3 Checksum Correct
  1177. * Bit 10 - L4 Checksum Correct
  1178. * Bit 11 - Reserved
  1179. * Bit 12 to 15 - This field is written by the adapter. It is
  1180. * used to report the status of the frame transfer to the host.
  1181. * 0x0 - Transfer OK
  1182. * 0x4 - RDA Failure During Transfer
  1183. * 0x5 - Unparseable Packet, such as unknown IPv6 header.
  1184. * 0x6 - Frame integrity error (FCS or ECC).
  1185. * 0x7 - Buffer Size Error. The provided buffer(s) were not
  1186. * appropriately sized and data loss occurred.
  1187. * 0x8 - Internal ECC Error. RxD corrupted.
  1188. * 0x9 - IPv4 Checksum error
  1189. * 0xA - TCP/UDP Checksum error
  1190. * 0xF - Unknown Error or Multiple Error. Indicates an
  1191. * unknown problem or that more than one of transfer codes is set.
  1192. * Bit 16 - SYN The adapter sets this field to indicate that
  1193. * the incoming frame contained a TCP segment with its SYN bit
  1194. * set and its ACK bit NOT set. (same meaning for all RxD buffer
  1195. * modes)
  1196. * Bit 17 - Is ICMP
  1197. * Bit 18 - RTH_SPDM_HIT Set to 1 if there was a match in the
  1198. * Socket Pair Direct Match Table and the frame was steered based
  1199. * on SPDM.
  1200. * Bit 19 - RTH_IT_HIT Set to 1 if there was a match in the
  1201. * Indirection Table and the frame was steered based on hash
  1202. * indirection.
  1203. * Bit 20 to 23 - RTH_HASH_TYPE Indicates the function (hash
  1204. * type) that was used to calculate the hash.
  1205. * Bit 19 - IS_VLAN Set to '1' if the frame was/is VLAN
  1206. * tagged.
  1207. * Bit 25 to 26 - ETHER_ENCAP Reflects the Ethernet encapsulation
  1208. * of the received frame.
  1209. * 0x0 - Ethernet DIX
  1210. * 0x1 - LLC
  1211. * 0x2 - SNAP (includes Jumbo-SNAP)
  1212. * 0x3 - IPX
  1213. * Bit 27 - IS_IPV4 Set to '1' if the frame contains an IPv4 packet.
  1214. * Bit 28 - IS_IPV6 Set to '1' if the frame contains an IPv6 packet.
  1215. * Bit 29 - IS_IP_FRAG Set to '1' if the frame contains a fragmented
  1216. * IP packet.
  1217. * Bit 30 - IS_TCP Set to '1' if the frame contains a TCP segment.
  1218. * Bit 31 - IS_UDP Set to '1' if the frame contains a UDP message.
  1219. * Bit 32 to 47 - L3_Checksum[0:15] The IPv4 checksum value that
  1220. * arrived with the frame. If the resulting computed IPv4 header
  1221. * checksum for the frame did not produce the expected 0xFFFF value,
  1222. * then the transfer code would be set to 0x9.
  1223. * Bit 48 to 63 - L4_Checksum[0:15] The TCP/UDP checksum value that
  1224. * arrived with the frame. If the resulting computed TCP/UDP checksum
  1225. * for the frame did not produce the expected 0xFFFF value, then the
  1226. * transfer code would be set to 0xA.
  1227. * @control_1:Bits 0 to 1 - Reserved
  1228. * Bits 2 to 15 - Buffer0_Size.This field is set by the host and
  1229. * eventually overwritten by the adapter. The host writes the
  1230. * available buffer size in bytes when it passes the descriptor to
  1231. * the adapter. When a frame is delivered the host, the adapter
  1232. * populates this field with the number of bytes written into the
  1233. * buffer. The largest supported buffer is 16, 383 bytes.
  1234. * Bit 16 to 47 - RTH Hash Value 32-bit RTH hash value. Only valid if
  1235. * RTH_HASH_TYPE (Control_0, bits 20:23) is nonzero.
  1236. * Bit 48 to 63 - VLAN_Tag[0:15] The contents of the variable portion
  1237. * of the VLAN tag, if one was detected by the adapter. This field is
  1238. * populated even if VLAN-tag stripping is enabled.
  1239. * @buffer0_ptr: Pointer to buffer. This field is populated by the driver.
  1240. *
  1241. * One buffer mode RxD for ring structure
  1242. */
  1243. struct vxge_hw_ring_rxd_1 {
  1244. u64 host_control;
  1245. u64 control_0;
  1246. #define VXGE_HW_RING_RXD_RTH_BUCKET_GET(ctrl0) vxge_bVALn(ctrl0, 0, 7)
  1247. #define VXGE_HW_RING_RXD_LIST_OWN_ADAPTER vxge_mBIT(7)
  1248. #define VXGE_HW_RING_RXD_FAST_PATH_ELIGIBLE_GET(ctrl0) vxge_bVALn(ctrl0, 8, 1)
  1249. #define VXGE_HW_RING_RXD_L3_CKSUM_CORRECT_GET(ctrl0) vxge_bVALn(ctrl0, 9, 1)
  1250. #define VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(ctrl0) vxge_bVALn(ctrl0, 10, 1)
  1251. #define VXGE_HW_RING_RXD_T_CODE_GET(ctrl0) vxge_bVALn(ctrl0, 12, 4)
  1252. #define VXGE_HW_RING_RXD_T_CODE(val) vxge_vBIT(val, 12, 4)
  1253. #define VXGE_HW_RING_RXD_T_CODE_UNUSED VXGE_HW_RING_T_CODE_UNUSED
  1254. #define VXGE_HW_RING_RXD_SYN_GET(ctrl0) vxge_bVALn(ctrl0, 16, 1)
  1255. #define VXGE_HW_RING_RXD_IS_ICMP_GET(ctrl0) vxge_bVALn(ctrl0, 17, 1)
  1256. #define VXGE_HW_RING_RXD_RTH_SPDM_HIT_GET(ctrl0) vxge_bVALn(ctrl0, 18, 1)
  1257. #define VXGE_HW_RING_RXD_RTH_IT_HIT_GET(ctrl0) vxge_bVALn(ctrl0, 19, 1)
  1258. #define VXGE_HW_RING_RXD_RTH_HASH_TYPE_GET(ctrl0) vxge_bVALn(ctrl0, 20, 4)
  1259. #define VXGE_HW_RING_RXD_IS_VLAN_GET(ctrl0) vxge_bVALn(ctrl0, 24, 1)
  1260. #define VXGE_HW_RING_RXD_ETHER_ENCAP_GET(ctrl0) vxge_bVALn(ctrl0, 25, 2)
  1261. #define VXGE_HW_RING_RXD_FRAME_PROTO_GET(ctrl0) vxge_bVALn(ctrl0, 27, 5)
  1262. #define VXGE_HW_RING_RXD_L3_CKSUM_GET(ctrl0) vxge_bVALn(ctrl0, 32, 16)
  1263. #define VXGE_HW_RING_RXD_L4_CKSUM_GET(ctrl0) vxge_bVALn(ctrl0, 48, 16)
  1264. u64 control_1;
  1265. #define VXGE_HW_RING_RXD_1_BUFFER0_SIZE_GET(ctrl1) vxge_bVALn(ctrl1, 2, 14)
  1266. #define VXGE_HW_RING_RXD_1_BUFFER0_SIZE(val) vxge_vBIT(val, 2, 14)
  1267. #define VXGE_HW_RING_RXD_1_BUFFER0_SIZE_MASK vxge_vBIT(0x3FFF, 2, 14)
  1268. #define VXGE_HW_RING_RXD_1_RTH_HASH_VAL_GET(ctrl1) vxge_bVALn(ctrl1, 16, 32)
  1269. #define VXGE_HW_RING_RXD_VLAN_TAG_GET(ctrl1) vxge_bVALn(ctrl1, 48, 16)
  1270. u64 buffer0_ptr;
  1271. };
  1272. enum vxge_hw_rth_algoritms {
  1273. RTH_ALG_JENKINS = 0,
  1274. RTH_ALG_MS_RSS = 1,
  1275. RTH_ALG_CRC32C = 2
  1276. };
  1277. /**
  1278. * struct vxge_hw_rth_hash_types - RTH hash types.
  1279. * @hash_type_tcpipv4_en: Enables RTH field type HashTypeTcpIPv4
  1280. * @hash_type_ipv4_en: Enables RTH field type HashTypeIPv4
  1281. * @hash_type_tcpipv6_en: Enables RTH field type HashTypeTcpIPv6
  1282. * @hash_type_ipv6_en: Enables RTH field type HashTypeIPv6
  1283. * @hash_type_tcpipv6ex_en: Enables RTH field type HashTypeTcpIPv6Ex
  1284. * @hash_type_ipv6ex_en: Enables RTH field type HashTypeIPv6Ex
  1285. *
  1286. * Used to pass RTH hash types to rts_rts_set.
  1287. *
  1288. * See also: vxge_hw_vpath_rts_rth_set(), vxge_hw_vpath_rts_rth_get().
  1289. */
  1290. struct vxge_hw_rth_hash_types {
  1291. u8 hash_type_tcpipv4_en;
  1292. u8 hash_type_ipv4_en;
  1293. u8 hash_type_tcpipv6_en;
  1294. u8 hash_type_ipv6_en;
  1295. u8 hash_type_tcpipv6ex_en;
  1296. u8 hash_type_ipv6ex_en;
  1297. };
  1298. u32
  1299. vxge_hw_device_debug_mask_get(struct __vxge_hw_device *devh);
  1300. void vxge_hw_device_debug_set(
  1301. struct __vxge_hw_device *devh,
  1302. enum vxge_debug_level level,
  1303. u32 mask);
  1304. u32
  1305. vxge_hw_device_error_level_get(struct __vxge_hw_device *devh);
  1306. u32
  1307. vxge_hw_device_trace_level_get(struct __vxge_hw_device *devh);
  1308. u32
  1309. vxge_hw_device_debug_mask_get(struct __vxge_hw_device *devh);
  1310. /**
  1311. * vxge_hw_ring_rxd_size_get - Get the size of ring descriptor.
  1312. * @buf_mode: Buffer mode (1, 3 or 5)
  1313. *
  1314. * This function returns the size of RxD for given buffer mode
  1315. */
  1316. static inline u32 vxge_hw_ring_rxd_size_get(u32 buf_mode)
  1317. {
  1318. return sizeof(struct vxge_hw_ring_rxd_1);
  1319. }
  1320. /**
  1321. * vxge_hw_ring_rxds_per_block_get - Get the number of rxds per block.
  1322. * @buf_mode: Buffer mode (1 buffer mode only)
  1323. *
  1324. * This function returns the number of RxD for RxD block for given buffer mode
  1325. */
  1326. static inline u32 vxge_hw_ring_rxds_per_block_get(u32 buf_mode)
  1327. {
  1328. return (u32)((VXGE_HW_BLOCK_SIZE-16) /
  1329. sizeof(struct vxge_hw_ring_rxd_1));
  1330. }
  1331. /**
  1332. * vxge_hw_ring_rxd_1b_set - Prepare 1-buffer-mode descriptor.
  1333. * @rxdh: Descriptor handle.
  1334. * @dma_pointer: DMA address of a single receive buffer this descriptor
  1335. * should carry. Note that by the time vxge_hw_ring_rxd_1b_set is called,
  1336. * the receive buffer should be already mapped to the device
  1337. * @size: Size of the receive @dma_pointer buffer.
  1338. *
  1339. * Prepare 1-buffer-mode Rx descriptor for posting
  1340. * (via vxge_hw_ring_rxd_post()).
  1341. *
  1342. * This inline helper-function does not return any parameters and always
  1343. * succeeds.
  1344. *
  1345. */
  1346. static inline
  1347. void vxge_hw_ring_rxd_1b_set(
  1348. void *rxdh,
  1349. dma_addr_t dma_pointer,
  1350. u32 size)
  1351. {
  1352. struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
  1353. rxdp->buffer0_ptr = dma_pointer;
  1354. rxdp->control_1 &= ~VXGE_HW_RING_RXD_1_BUFFER0_SIZE_MASK;
  1355. rxdp->control_1 |= VXGE_HW_RING_RXD_1_BUFFER0_SIZE(size);
  1356. }
  1357. /**
  1358. * vxge_hw_ring_rxd_1b_get - Get data from the completed 1-buf
  1359. * descriptor.
  1360. * @vpath_handle: Virtual Path handle.
  1361. * @rxdh: Descriptor handle.
  1362. * @dma_pointer: DMA address of a single receive buffer this descriptor
  1363. * carries. Returned by HW.
  1364. * @pkt_length: Length (in bytes) of the data in the buffer pointed by
  1365. *
  1366. * Retrieve protocol data from the completed 1-buffer-mode Rx descriptor.
  1367. * This inline helper-function uses completed descriptor to populate receive
  1368. * buffer pointer and other "out" parameters. The function always succeeds.
  1369. *
  1370. */
  1371. static inline
  1372. void vxge_hw_ring_rxd_1b_get(
  1373. struct __vxge_hw_ring *ring_handle,
  1374. void *rxdh,
  1375. u32 *pkt_length)
  1376. {
  1377. struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
  1378. *pkt_length =
  1379. (u32)VXGE_HW_RING_RXD_1_BUFFER0_SIZE_GET(rxdp->control_1);
  1380. }
  1381. /**
  1382. * vxge_hw_ring_rxd_1b_info_get - Get extended information associated with
  1383. * a completed receive descriptor for 1b mode.
  1384. * @vpath_handle: Virtual Path handle.
  1385. * @rxdh: Descriptor handle.
  1386. * @rxd_info: Descriptor information
  1387. *
  1388. * Retrieve extended information associated with a completed receive descriptor.
  1389. *
  1390. */
  1391. static inline
  1392. void vxge_hw_ring_rxd_1b_info_get(
  1393. struct __vxge_hw_ring *ring_handle,
  1394. void *rxdh,
  1395. struct vxge_hw_ring_rxd_info *rxd_info)
  1396. {
  1397. struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
  1398. rxd_info->syn_flag =
  1399. (u32)VXGE_HW_RING_RXD_SYN_GET(rxdp->control_0);
  1400. rxd_info->is_icmp =
  1401. (u32)VXGE_HW_RING_RXD_IS_ICMP_GET(rxdp->control_0);
  1402. rxd_info->fast_path_eligible =
  1403. (u32)VXGE_HW_RING_RXD_FAST_PATH_ELIGIBLE_GET(rxdp->control_0);
  1404. rxd_info->l3_cksum_valid =
  1405. (u32)VXGE_HW_RING_RXD_L3_CKSUM_CORRECT_GET(rxdp->control_0);
  1406. rxd_info->l3_cksum =
  1407. (u32)VXGE_HW_RING_RXD_L3_CKSUM_GET(rxdp->control_0);
  1408. rxd_info->l4_cksum_valid =
  1409. (u32)VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(rxdp->control_0);
  1410. rxd_info->l4_cksum =
  1411. (u32)VXGE_HW_RING_RXD_L4_CKSUM_GET(rxdp->control_0);
  1412. rxd_info->frame =
  1413. (u32)VXGE_HW_RING_RXD_ETHER_ENCAP_GET(rxdp->control_0);
  1414. rxd_info->proto =
  1415. (u32)VXGE_HW_RING_RXD_FRAME_PROTO_GET(rxdp->control_0);
  1416. rxd_info->is_vlan =
  1417. (u32)VXGE_HW_RING_RXD_IS_VLAN_GET(rxdp->control_0);
  1418. rxd_info->vlan =
  1419. (u32)VXGE_HW_RING_RXD_VLAN_TAG_GET(rxdp->control_1);
  1420. rxd_info->rth_bucket =
  1421. (u32)VXGE_HW_RING_RXD_RTH_BUCKET_GET(rxdp->control_0);
  1422. rxd_info->rth_it_hit =
  1423. (u32)VXGE_HW_RING_RXD_RTH_IT_HIT_GET(rxdp->control_0);
  1424. rxd_info->rth_spdm_hit =
  1425. (u32)VXGE_HW_RING_RXD_RTH_SPDM_HIT_GET(rxdp->control_0);
  1426. rxd_info->rth_hash_type =
  1427. (u32)VXGE_HW_RING_RXD_RTH_HASH_TYPE_GET(rxdp->control_0);
  1428. rxd_info->rth_value =
  1429. (u32)VXGE_HW_RING_RXD_1_RTH_HASH_VAL_GET(rxdp->control_1);
  1430. }
  1431. /**
  1432. * vxge_hw_ring_rxd_private_get - Get driver private per-descriptor data
  1433. * of 1b mode 3b mode ring.
  1434. * @rxdh: Descriptor handle.
  1435. *
  1436. * Returns: private driver info associated with the descriptor.
  1437. * driver requests per-descriptor space via vxge_hw_ring_attr.
  1438. *
  1439. */
  1440. static inline void *vxge_hw_ring_rxd_private_get(void *rxdh)
  1441. {
  1442. struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
  1443. return (void *)(size_t)rxdp->host_control;
  1444. }
  1445. /**
  1446. * vxge_hw_fifo_txdl_cksum_set_bits - Offload checksum.
  1447. * @txdlh: Descriptor handle.
  1448. * @cksum_bits: Specifies which checksums are to be offloaded: IPv4,
  1449. * and/or TCP and/or UDP.
  1450. *
  1451. * Ask Titan to calculate IPv4 & transport checksums for _this_ transmit
  1452. * descriptor.
  1453. * This API is part of the preparation of the transmit descriptor for posting
  1454. * (via vxge_hw_fifo_txdl_post()). The related "preparation" APIs include
  1455. * vxge_hw_fifo_txdl_mss_set(), vxge_hw_fifo_txdl_buffer_set_aligned(),
  1456. * and vxge_hw_fifo_txdl_buffer_set().
  1457. * All these APIs fill in the fields of the fifo descriptor,
  1458. * in accordance with the Titan specification.
  1459. *
  1460. */
  1461. static inline void vxge_hw_fifo_txdl_cksum_set_bits(void *txdlh, u64 cksum_bits)
  1462. {
  1463. struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
  1464. txdp->control_1 |= cksum_bits;
  1465. }
  1466. /**
  1467. * vxge_hw_fifo_txdl_mss_set - Set MSS.
  1468. * @txdlh: Descriptor handle.
  1469. * @mss: MSS size for _this_ TCP connection. Passed by TCP stack down to the
  1470. * driver, which in turn inserts the MSS into the @txdlh.
  1471. *
  1472. * This API is part of the preparation of the transmit descriptor for posting
  1473. * (via vxge_hw_fifo_txdl_post()). The related "preparation" APIs include
  1474. * vxge_hw_fifo_txdl_buffer_set(), vxge_hw_fifo_txdl_buffer_set_aligned(),
  1475. * and vxge_hw_fifo_txdl_cksum_set_bits().
  1476. * All these APIs fill in the fields of the fifo descriptor,
  1477. * in accordance with the Titan specification.
  1478. *
  1479. */
  1480. static inline void vxge_hw_fifo_txdl_mss_set(void *txdlh, int mss)
  1481. {
  1482. struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
  1483. txdp->control_0 |= VXGE_HW_FIFO_TXD_LSO_EN;
  1484. txdp->control_0 |= VXGE_HW_FIFO_TXD_LSO_MSS(mss);
  1485. }
  1486. /**
  1487. * vxge_hw_fifo_txdl_vlan_set - Set VLAN tag.
  1488. * @txdlh: Descriptor handle.
  1489. * @vlan_tag: 16bit VLAN tag.
  1490. *
  1491. * Insert VLAN tag into specified transmit descriptor.
  1492. * The actual insertion of the tag into outgoing frame is done by the hardware.
  1493. */
  1494. static inline void vxge_hw_fifo_txdl_vlan_set(void *txdlh, u16 vlan_tag)
  1495. {
  1496. struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
  1497. txdp->control_1 |= VXGE_HW_FIFO_TXD_VLAN_ENABLE;
  1498. txdp->control_1 |= VXGE_HW_FIFO_TXD_VLAN_TAG(vlan_tag);
  1499. }
  1500. /**
  1501. * vxge_hw_fifo_txdl_private_get - Retrieve per-descriptor private data.
  1502. * @txdlh: Descriptor handle.
  1503. *
  1504. * Retrieve per-descriptor private data.
  1505. * Note that driver requests per-descriptor space via
  1506. * struct vxge_hw_fifo_attr passed to
  1507. * vxge_hw_vpath_open().
  1508. *
  1509. * Returns: private driver data associated with the descriptor.
  1510. */
  1511. static inline void *vxge_hw_fifo_txdl_private_get(void *txdlh)
  1512. {
  1513. struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
  1514. return (void *)(size_t)txdp->host_control;
  1515. }
  1516. /**
  1517. * struct vxge_hw_ring_attr - Ring open "template".
  1518. * @callback: Ring completion callback. HW invokes the callback when there
  1519. * are new completions on that ring. In many implementations
  1520. * the @callback executes in the hw interrupt context.
  1521. * @rxd_init: Ring's descriptor-initialize callback.
  1522. * See vxge_hw_ring_rxd_init_f{}.
  1523. * If not NULL, HW invokes the callback when opening
  1524. * the ring.
  1525. * @rxd_term: Ring's descriptor-terminate callback. If not NULL,
  1526. * HW invokes the callback when closing the corresponding ring.
  1527. * See also vxge_hw_ring_rxd_term_f{}.
  1528. * @userdata: User-defined "context" of _that_ ring. Passed back to the
  1529. * user as one of the @callback, @rxd_init, and @rxd_term arguments.
  1530. * @per_rxd_space: If specified (i.e., greater than zero): extra space
  1531. * reserved by HW per each receive descriptor.
  1532. * Can be used to store
  1533. * and retrieve on completion, information specific
  1534. * to the driver.
  1535. *
  1536. * Ring open "template". User fills the structure with ring
  1537. * attributes and passes it to vxge_hw_vpath_open().
  1538. */
  1539. struct vxge_hw_ring_attr {
  1540. enum vxge_hw_status (*callback)(
  1541. struct __vxge_hw_ring *ringh,
  1542. void *rxdh,
  1543. u8 t_code,
  1544. void *userdata);
  1545. enum vxge_hw_status (*rxd_init)(
  1546. void *rxdh,
  1547. void *userdata);
  1548. void (*rxd_term)(
  1549. void *rxdh,
  1550. enum vxge_hw_rxd_state state,
  1551. void *userdata);
  1552. void *userdata;
  1553. u32 per_rxd_space;
  1554. };
  1555. /**
  1556. * function vxge_hw_fifo_callback_f - FIFO callback.
  1557. * @vpath_handle: Virtual path whose Fifo "containing" 1 or more completed
  1558. * descriptors.
  1559. * @txdlh: First completed descriptor.
  1560. * @txdl_priv: Pointer to per txdl space allocated
  1561. * @t_code: Transfer code, as per Titan User Guide.
  1562. * Returned by HW.
  1563. * @host_control: Opaque 64bit data stored by driver inside the Titan
  1564. * descriptor prior to posting the latter on the fifo
  1565. * via vxge_hw_fifo_txdl_post(). The @host_control is returned
  1566. * as is to the driver with each completed descriptor.
  1567. * @userdata: Opaque per-fifo data specified at fifo open
  1568. * time, via vxge_hw_vpath_open().
  1569. *
  1570. * Fifo completion callback (type declaration). A single per-fifo
  1571. * callback is specified at fifo open time, via
  1572. * vxge_hw_vpath_open(). Typically gets called as part of the processing
  1573. * of the Interrupt Service Routine.
  1574. *
  1575. * Fifo callback gets called by HW if, and only if, there is at least
  1576. * one new completion on a given fifo. Upon processing the first @txdlh driver
  1577. * is _supposed_ to continue consuming completions using:
  1578. * - vxge_hw_fifo_txdl_next_completed()
  1579. *
  1580. * Note that failure to process new completions in a timely fashion
  1581. * leads to VXGE_HW_INF_OUT_OF_DESCRIPTORS condition.
  1582. *
  1583. * Non-zero @t_code means failure to process transmit descriptor.
  1584. *
  1585. * In the "transmit" case the failure could happen, for instance, when the
  1586. * link is down, in which case Titan completes the descriptor because it
  1587. * is not able to send the data out.
  1588. *
  1589. * For details please refer to Titan User Guide.
  1590. *
  1591. * See also: vxge_hw_fifo_txdl_next_completed(), vxge_hw_fifo_txdl_term_f{}.
  1592. */
  1593. /**
  1594. * function vxge_hw_fifo_txdl_term_f - Terminate descriptor callback.
  1595. * @txdlh: First completed descriptor.
  1596. * @txdl_priv: Pointer to per txdl space allocated
  1597. * @state: One of the enum vxge_hw_txdl_state{} enumerated states.
  1598. * @userdata: Per-fifo user data (a.k.a. context) specified at
  1599. * fifo open time, via vxge_hw_vpath_open().
  1600. *
  1601. * Terminate descriptor callback. Unless NULL is specified in the
  1602. * struct vxge_hw_fifo_attr{} structure passed to vxge_hw_vpath_open()),
  1603. * HW invokes the callback as part of closing fifo, prior to
  1604. * de-allocating the ring and associated data structures
  1605. * (including descriptors).
  1606. * driver should utilize the callback to (for instance) unmap
  1607. * and free DMA data buffers associated with the posted (state =
  1608. * VXGE_HW_TXDL_STATE_POSTED) descriptors,
  1609. * as well as other relevant cleanup functions.
  1610. *
  1611. * See also: struct vxge_hw_fifo_attr{}
  1612. */
  1613. /**
  1614. * struct vxge_hw_fifo_attr - Fifo open "template".
  1615. * @callback: Fifo completion callback. HW invokes the callback when there
  1616. * are new completions on that fifo. In many implementations
  1617. * the @callback executes in the hw interrupt context.
  1618. * @txdl_term: Fifo's descriptor-terminate callback. If not NULL,
  1619. * HW invokes the callback when closing the corresponding fifo.
  1620. * See also vxge_hw_fifo_txdl_term_f{}.
  1621. * @userdata: User-defined "context" of _that_ fifo. Passed back to the
  1622. * user as one of the @callback, and @txdl_term arguments.
  1623. * @per_txdl_space: If specified (i.e., greater than zero): extra space
  1624. * reserved by HW per each transmit descriptor. Can be used to
  1625. * store, and retrieve on completion, information specific
  1626. * to the driver.
  1627. *
  1628. * Fifo open "template". User fills the structure with fifo
  1629. * attributes and passes it to vxge_hw_vpath_open().
  1630. */
  1631. struct vxge_hw_fifo_attr {
  1632. enum vxge_hw_status (*callback)(
  1633. struct __vxge_hw_fifo *fifo_handle,
  1634. void *txdlh,
  1635. enum vxge_hw_fifo_tcode t_code,
  1636. void *userdata,
  1637. struct sk_buff ***skb_ptr,
  1638. int nr_skb, int *more);
  1639. void (*txdl_term)(
  1640. void *txdlh,
  1641. enum vxge_hw_txdl_state state,
  1642. void *userdata);
  1643. void *userdata;
  1644. u32 per_txdl_space;
  1645. };
  1646. /**
  1647. * struct vxge_hw_vpath_attr - Attributes of virtual path
  1648. * @vp_id: Identifier of Virtual Path
  1649. * @ring_attr: Attributes of ring for non-offload receive
  1650. * @fifo_attr: Attributes of fifo for non-offload transmit
  1651. *
  1652. * Attributes of virtual path. This structure is passed as parameter
  1653. * to the vxge_hw_vpath_open() routine to set the attributes of ring and fifo.
  1654. */
  1655. struct vxge_hw_vpath_attr {
  1656. u32 vp_id;
  1657. struct vxge_hw_ring_attr ring_attr;
  1658. struct vxge_hw_fifo_attr fifo_attr;
  1659. };
  1660. enum vxge_hw_status
  1661. __vxge_hw_blockpool_create(struct __vxge_hw_device *hldev,
  1662. struct __vxge_hw_blockpool *blockpool,
  1663. u32 pool_size,
  1664. u32 pool_max);
  1665. void
  1666. __vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool *blockpool);
  1667. struct __vxge_hw_blockpool_entry *
  1668. __vxge_hw_blockpool_block_allocate(struct __vxge_hw_device *hldev,
  1669. u32 size);
  1670. void
  1671. __vxge_hw_blockpool_block_free(struct __vxge_hw_device *hldev,
  1672. struct __vxge_hw_blockpool_entry *entry);
  1673. void *
  1674. __vxge_hw_blockpool_malloc(struct __vxge_hw_device *hldev,
  1675. u32 size,
  1676. struct vxge_hw_mempool_dma *dma_object);
  1677. void
  1678. __vxge_hw_blockpool_free(struct __vxge_hw_device *hldev,
  1679. void *memblock,
  1680. u32 size,
  1681. struct vxge_hw_mempool_dma *dma_object);
  1682. enum vxge_hw_status
  1683. __vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config);
  1684. enum vxge_hw_status
  1685. __vxge_hw_device_config_check(struct vxge_hw_device_config *new_config);
  1686. enum vxge_hw_status
  1687. vxge_hw_mgmt_device_config(struct __vxge_hw_device *devh,
  1688. struct vxge_hw_device_config *dev_config, int size);
  1689. enum vxge_hw_status __devinit vxge_hw_device_hw_info_get(
  1690. void __iomem *bar0,
  1691. struct vxge_hw_device_hw_info *hw_info);
  1692. enum vxge_hw_status
  1693. __vxge_hw_vpath_fw_ver_get(
  1694. u32 vp_id,
  1695. struct vxge_hw_vpath_reg __iomem *vpath_reg,
  1696. struct vxge_hw_device_hw_info *hw_info);
  1697. enum vxge_hw_status
  1698. __vxge_hw_vpath_card_info_get(
  1699. u32 vp_id,
  1700. struct vxge_hw_vpath_reg __iomem *vpath_reg,
  1701. struct vxge_hw_device_hw_info *hw_info);
  1702. enum vxge_hw_status __devinit vxge_hw_device_config_default_get(
  1703. struct vxge_hw_device_config *device_config);
  1704. /**
  1705. * vxge_hw_device_link_state_get - Get link state.
  1706. * @devh: HW device handle.
  1707. *
  1708. * Get link state.
  1709. * Returns: link state.
  1710. */
  1711. static inline
  1712. enum vxge_hw_device_link_state vxge_hw_device_link_state_get(
  1713. struct __vxge_hw_device *devh)
  1714. {
  1715. return devh->link_state;
  1716. }
  1717. void vxge_hw_device_terminate(struct __vxge_hw_device *devh);
  1718. const u8 *
  1719. vxge_hw_device_serial_number_get(struct __vxge_hw_device *devh);
  1720. u16 vxge_hw_device_link_width_get(struct __vxge_hw_device *devh);
  1721. const u8 *
  1722. vxge_hw_device_product_name_get(struct __vxge_hw_device *devh);
  1723. enum vxge_hw_status __devinit vxge_hw_device_initialize(
  1724. struct __vxge_hw_device **devh,
  1725. struct vxge_hw_device_attr *attr,
  1726. struct vxge_hw_device_config *device_config);
  1727. enum vxge_hw_status vxge_hw_device_getpause_data(
  1728. struct __vxge_hw_device *devh,
  1729. u32 port,
  1730. u32 *tx,
  1731. u32 *rx);
  1732. enum vxge_hw_status vxge_hw_device_setpause_data(
  1733. struct __vxge_hw_device *devh,
  1734. u32 port,
  1735. u32 tx,
  1736. u32 rx);
  1737. static inline void *vxge_os_dma_malloc(struct pci_dev *pdev,
  1738. unsigned long size,
  1739. struct pci_dev **p_dmah,
  1740. struct pci_dev **p_dma_acch)
  1741. {
  1742. gfp_t flags;
  1743. void *vaddr;
  1744. unsigned long misaligned = 0;
  1745. int realloc_flag = 0;
  1746. *p_dma_acch = *p_dmah = NULL;
  1747. if (in_interrupt())
  1748. flags = GFP_ATOMIC | GFP_DMA;
  1749. else
  1750. flags = GFP_KERNEL | GFP_DMA;
  1751. realloc:
  1752. vaddr = kmalloc((size), flags);
  1753. if (vaddr == NULL)
  1754. return vaddr;
  1755. misaligned = (unsigned long)VXGE_ALIGN((unsigned long)vaddr,
  1756. VXGE_CACHE_LINE_SIZE);
  1757. if (realloc_flag)
  1758. goto out;
  1759. if (misaligned) {
  1760. /* misaligned, free current one and try allocating
  1761. * size + VXGE_CACHE_LINE_SIZE memory
  1762. */
  1763. kfree((void *) vaddr);
  1764. size += VXGE_CACHE_LINE_SIZE;
  1765. realloc_flag = 1;
  1766. goto realloc;
  1767. }
  1768. out:
  1769. *(unsigned long *)p_dma_acch = misaligned;
  1770. vaddr = (void *)((u8 *)vaddr + misaligned);
  1771. return vaddr;
  1772. }
  1773. extern void vxge_hw_blockpool_block_add(
  1774. struct __vxge_hw_device *devh,
  1775. void *block_addr,
  1776. u32 length,
  1777. struct pci_dev *dma_h,
  1778. struct pci_dev *acc_handle);
  1779. static inline void vxge_os_dma_malloc_async(struct pci_dev *pdev, void *devh,
  1780. unsigned long size)
  1781. {
  1782. gfp_t flags;
  1783. void *vaddr;
  1784. if (in_interrupt())
  1785. flags = GFP_ATOMIC | GFP_DMA;
  1786. else
  1787. flags = GFP_KERNEL | GFP_DMA;
  1788. vaddr = kmalloc((size), flags);
  1789. vxge_hw_blockpool_block_add(devh, vaddr, size, pdev, pdev);
  1790. }
  1791. static inline void vxge_os_dma_free(struct pci_dev *pdev, const void *vaddr,
  1792. struct pci_dev **p_dma_acch)
  1793. {
  1794. unsigned long misaligned = *(unsigned long *)p_dma_acch;
  1795. u8 *tmp = (u8 *)vaddr;
  1796. tmp -= misaligned;
  1797. kfree((void *)tmp);
  1798. }
  1799. /*
  1800. * __vxge_hw_mempool_item_priv - will return pointer on per item private space
  1801. */
  1802. static inline void*
  1803. __vxge_hw_mempool_item_priv(
  1804. struct vxge_hw_mempool *mempool,
  1805. u32 memblock_idx,
  1806. void *item,
  1807. u32 *memblock_item_idx)
  1808. {
  1809. ptrdiff_t offset;
  1810. void *memblock = mempool->memblocks_arr[memblock_idx];
  1811. offset = (u32)((u8 *)item - (u8 *)memblock);
  1812. vxge_assert(offset >= 0 && (u32)offset < mempool->memblock_size);
  1813. (*memblock_item_idx) = (u32) offset / mempool->item_size;
  1814. vxge_assert((*memblock_item_idx) < mempool->items_per_memblock);
  1815. return (u8 *)mempool->memblocks_priv_arr[memblock_idx] +
  1816. (*memblock_item_idx) * mempool->items_priv_size;
  1817. }
  1818. enum vxge_hw_status
  1819. __vxge_hw_mempool_grow(
  1820. struct vxge_hw_mempool *mempool,
  1821. u32 num_allocate,
  1822. u32 *num_allocated);
  1823. struct vxge_hw_mempool*
  1824. __vxge_hw_mempool_create(
  1825. struct __vxge_hw_device *devh,
  1826. u32 memblock_size,
  1827. u32 item_size,
  1828. u32 private_size,
  1829. u32 items_initial,
  1830. u32 items_max,
  1831. struct vxge_hw_mempool_cbs *mp_callback,
  1832. void *userdata);
  1833. struct __vxge_hw_channel*
  1834. __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
  1835. enum __vxge_hw_channel_type type, u32 length,
  1836. u32 per_dtr_space, void *userdata);
  1837. void
  1838. __vxge_hw_channel_free(
  1839. struct __vxge_hw_channel *channel);
  1840. enum vxge_hw_status
  1841. __vxge_hw_channel_initialize(
  1842. struct __vxge_hw_channel *channel);
  1843. enum vxge_hw_status
  1844. __vxge_hw_channel_reset(
  1845. struct __vxge_hw_channel *channel);
  1846. /*
  1847. * __vxge_hw_fifo_txdl_priv - Return the max fragments allocated
  1848. * for the fifo.
  1849. * @fifo: Fifo
  1850. * @txdp: Poniter to a TxD
  1851. */
  1852. static inline struct __vxge_hw_fifo_txdl_priv *
  1853. __vxge_hw_fifo_txdl_priv(
  1854. struct __vxge_hw_fifo *fifo,
  1855. struct vxge_hw_fifo_txd *txdp)
  1856. {
  1857. return (struct __vxge_hw_fifo_txdl_priv *)
  1858. (((char *)((ulong)txdp->host_control)) +
  1859. fifo->per_txdl_space);
  1860. }
  1861. enum vxge_hw_status vxge_hw_vpath_open(
  1862. struct __vxge_hw_device *devh,
  1863. struct vxge_hw_vpath_attr *attr,
  1864. struct __vxge_hw_vpath_handle **vpath_handle);
  1865. enum vxge_hw_status
  1866. __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog);
  1867. enum vxge_hw_status vxge_hw_vpath_close(
  1868. struct __vxge_hw_vpath_handle *vpath_handle);
  1869. enum vxge_hw_status
  1870. vxge_hw_vpath_reset(
  1871. struct __vxge_hw_vpath_handle *vpath_handle);
  1872. enum vxge_hw_status
  1873. vxge_hw_vpath_recover_from_reset(
  1874. struct __vxge_hw_vpath_handle *vpath_handle);
  1875. void
  1876. vxge_hw_vpath_enable(struct __vxge_hw_vpath_handle *vp);
  1877. enum vxge_hw_status
  1878. vxge_hw_vpath_check_leak(struct __vxge_hw_ring *ringh);
  1879. enum vxge_hw_status vxge_hw_vpath_mtu_set(
  1880. struct __vxge_hw_vpath_handle *vpath_handle,
  1881. u32 new_mtu);
  1882. enum vxge_hw_status vxge_hw_vpath_stats_enable(
  1883. struct __vxge_hw_vpath_handle *vpath_handle);
  1884. enum vxge_hw_status
  1885. __vxge_hw_vpath_stats_access(
  1886. struct __vxge_hw_virtualpath *vpath,
  1887. u32 operation,
  1888. u32 offset,
  1889. u64 *stat);
  1890. enum vxge_hw_status
  1891. __vxge_hw_vpath_xmac_tx_stats_get(
  1892. struct __vxge_hw_virtualpath *vpath,
  1893. struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats);
  1894. enum vxge_hw_status
  1895. __vxge_hw_vpath_xmac_rx_stats_get(
  1896. struct __vxge_hw_virtualpath *vpath,
  1897. struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats);
  1898. enum vxge_hw_status
  1899. __vxge_hw_vpath_stats_get(
  1900. struct __vxge_hw_virtualpath *vpath,
  1901. struct vxge_hw_vpath_stats_hw_info *hw_stats);
  1902. void
  1903. vxge_hw_vpath_rx_doorbell_init(struct __vxge_hw_vpath_handle *vp);
  1904. enum vxge_hw_status
  1905. __vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config *vp_config);
  1906. void
  1907. __vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev);
  1908. enum vxge_hw_status
  1909. __vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg);
  1910. enum vxge_hw_status
  1911. __vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg);
  1912. enum vxge_hw_status
  1913. __vxge_hw_kdfc_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg,
  1914. struct vxge_hw_vpath_reg __iomem *vpath_reg);
  1915. enum vxge_hw_status
  1916. __vxge_hw_device_register_poll(
  1917. void __iomem *reg,
  1918. u64 mask, u32 max_millis);
  1919. #ifndef readq
  1920. static inline u64 readq(void __iomem *addr)
  1921. {
  1922. u64 ret = 0;
  1923. ret = readl(addr + 4);
  1924. ret <<= 32;
  1925. ret |= readl(addr);
  1926. return ret;
  1927. }
  1928. #endif
  1929. #ifndef writeq
  1930. static inline void writeq(u64 val, void __iomem *addr)
  1931. {
  1932. writel((u32) (val), addr);
  1933. writel((u32) (val >> 32), (addr + 4));
  1934. }
  1935. #endif
  1936. static inline void __vxge_hw_pio_mem_write32_upper(u32 val, void __iomem *addr)
  1937. {
  1938. writel(val, addr + 4);
  1939. }
  1940. static inline void __vxge_hw_pio_mem_write32_lower(u32 val, void __iomem *addr)
  1941. {
  1942. writel(val, addr);
  1943. }
  1944. static inline enum vxge_hw_status
  1945. __vxge_hw_pio_mem_write64(u64 val64, void __iomem *addr,
  1946. u64 mask, u32 max_millis)
  1947. {
  1948. enum vxge_hw_status status = VXGE_HW_OK;
  1949. __vxge_hw_pio_mem_write32_lower((u32)vxge_bVALn(val64, 32, 32), addr);
  1950. wmb();
  1951. __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32), addr);
  1952. wmb();
  1953. status = __vxge_hw_device_register_poll(addr, mask, max_millis);
  1954. return status;
  1955. }
  1956. struct vxge_hw_toc_reg __iomem *
  1957. __vxge_hw_device_toc_get(void __iomem *bar0);
  1958. enum vxge_hw_status
  1959. __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev);
  1960. void
  1961. __vxge_hw_device_id_get(struct __vxge_hw_device *hldev);
  1962. void
  1963. __vxge_hw_device_host_info_get(struct __vxge_hw_device *hldev);
  1964. enum vxge_hw_status
  1965. vxge_hw_device_flick_link_led(struct __vxge_hw_device *devh, u64 on_off);
  1966. enum vxge_hw_status
  1967. __vxge_hw_device_initialize(struct __vxge_hw_device *hldev);
  1968. enum vxge_hw_status
  1969. __vxge_hw_vpath_pci_read(
  1970. struct __vxge_hw_virtualpath *vpath,
  1971. u32 phy_func_0,
  1972. u32 offset,
  1973. u32 *val);
  1974. enum vxge_hw_status
  1975. __vxge_hw_vpath_addr_get(
  1976. u32 vp_id,
  1977. struct vxge_hw_vpath_reg __iomem *vpath_reg,
  1978. u8 (macaddr)[ETH_ALEN],
  1979. u8 (macaddr_mask)[ETH_ALEN]);
  1980. u32
  1981. __vxge_hw_vpath_func_id_get(
  1982. u32 vp_id, struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg);
  1983. enum vxge_hw_status
  1984. __vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath);
  1985. enum vxge_hw_status
  1986. vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device *hldev, u64 vpath_mask);
  1987. /**
  1988. * vxge_debug
  1989. * @level: level of debug verbosity.
  1990. * @mask: mask for the debug
  1991. * @buf: Circular buffer for tracing
  1992. * @fmt: printf like format string
  1993. *
  1994. * Provides logging facilities. Can be customized on per-module
  1995. * basis or/and with debug levels. Input parameters, except
  1996. * module and level, are the same as posix printf. This function
  1997. * may be compiled out if DEBUG macro was never defined.
  1998. * See also: enum vxge_debug_level{}.
  1999. */
  2000. #define vxge_trace_aux(level, mask, fmt, ...) \
  2001. {\
  2002. vxge_os_vaprintf(level, mask, fmt, __VA_ARGS__);\
  2003. }
  2004. #define vxge_debug(module, level, mask, fmt, ...) { \
  2005. if ((level >= VXGE_TRACE && ((module & VXGE_DEBUG_TRACE_MASK) == module)) || \
  2006. (level >= VXGE_ERR && ((module & VXGE_DEBUG_ERR_MASK) == module))) {\
  2007. if ((mask & VXGE_DEBUG_MASK) == mask)\
  2008. vxge_trace_aux(level, mask, fmt, __VA_ARGS__); \
  2009. } \
  2010. }
  2011. #if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK)
  2012. #define vxge_debug_ll(level, mask, fmt, ...) \
  2013. {\
  2014. vxge_debug(VXGE_COMPONENT_LL, level, mask, fmt, __VA_ARGS__);\
  2015. }
  2016. #else
  2017. #define vxge_debug_ll(level, mask, fmt, ...)
  2018. #endif
  2019. enum vxge_hw_status vxge_hw_vpath_rts_rth_itable_set(
  2020. struct __vxge_hw_vpath_handle **vpath_handles,
  2021. u32 vpath_count,
  2022. u8 *mtable,
  2023. u8 *itable,
  2024. u32 itable_size);
  2025. enum vxge_hw_status vxge_hw_vpath_rts_rth_set(
  2026. struct __vxge_hw_vpath_handle *vpath_handle,
  2027. enum vxge_hw_rth_algoritms algorithm,
  2028. struct vxge_hw_rth_hash_types *hash_type,
  2029. u16 bucket_size);
  2030. enum vxge_hw_status
  2031. __vxge_hw_device_is_privilaged(u32 host_type, u32 func_id);
  2032. #endif