vxge-config.h 78 KB

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