vxge-config.h 74 KB

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