PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/staging/octeon/cvmx-wqe.h

https://github.com/Dabary/linux_gt-i9000
C Header | 397 lines | 75 code | 26 blank | 296 comment | 3 complexity | 7a2be3743f5fe3eafec7362213f42028 MD5 | raw file
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: support@caviumnetworks.com
  5. * This file is part of the OCTEON SDK
  6. *
  7. * Copyright (c) 2003-2008 Cavium Networks
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this file; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. * or visit http://www.gnu.org/licenses/.
  23. *
  24. * This file may also be available under a different license from Cavium.
  25. * Contact Cavium Networks for more information
  26. ***********************license end**************************************/
  27. /**
  28. *
  29. * This header file defines the work queue entry (wqe) data structure.
  30. * Since this is a commonly used structure that depends on structures
  31. * from several hardware blocks, those definitions have been placed
  32. * in this file to create a single point of definition of the wqe
  33. * format.
  34. * Data structures are still named according to the block that they
  35. * relate to.
  36. *
  37. */
  38. #ifndef __CVMX_WQE_H__
  39. #define __CVMX_WQE_H__
  40. #include "cvmx-packet.h"
  41. #define OCT_TAG_TYPE_STRING(x) \
  42. (((x) == CVMX_POW_TAG_TYPE_ORDERED) ? "ORDERED" : \
  43. (((x) == CVMX_POW_TAG_TYPE_ATOMIC) ? "ATOMIC" : \
  44. (((x) == CVMX_POW_TAG_TYPE_NULL) ? "NULL" : \
  45. "NULL_NULL")))
  46. /**
  47. * HW decode / err_code in work queue entry
  48. */
  49. typedef union {
  50. uint64_t u64;
  51. /* Use this struct if the hardware determines that the packet is IP */
  52. struct {
  53. /* HW sets this to the number of buffers used by this packet */
  54. uint64_t bufs:8;
  55. /* HW sets to the number of L2 bytes prior to the IP */
  56. uint64_t ip_offset:8;
  57. /* set to 1 if we found DSA/VLAN in the L2 */
  58. uint64_t vlan_valid:1;
  59. /* Set to 1 if the DSA/VLAN tag is stacked */
  60. uint64_t vlan_stacked:1;
  61. uint64_t unassigned:1;
  62. /* HW sets to the DSA/VLAN CFI flag (valid when vlan_valid) */
  63. uint64_t vlan_cfi:1;
  64. /* HW sets to the DSA/VLAN_ID field (valid when vlan_valid) */
  65. uint64_t vlan_id:12;
  66. /* Ring Identifier (if PCIe). Requires PIP_GBL_CTL[RING_EN]=1 */
  67. uint64_t pr:4;
  68. uint64_t unassigned2:8;
  69. /* the packet needs to be decompressed */
  70. uint64_t dec_ipcomp:1;
  71. /* the packet is either TCP or UDP */
  72. uint64_t tcp_or_udp:1;
  73. /* the packet needs to be decrypted (ESP or AH) */
  74. uint64_t dec_ipsec:1;
  75. /* the packet is IPv6 */
  76. uint64_t is_v6:1;
  77. /*
  78. * (rcv_error, not_IP, IP_exc, is_frag, L4_error,
  79. * software, etc.).
  80. */
  81. /*
  82. * reserved for software use, hardware will clear on
  83. * packet creation.
  84. */
  85. uint64_t software:1;
  86. /* exceptional conditions below */
  87. /* the receive interface hardware detected an L4 error
  88. * (only applies if !is_frag) (only applies if
  89. * !rcv_error && !not_IP && !IP_exc && !is_frag)
  90. * failure indicated in err_code below, decode:
  91. *
  92. * - 1 = Malformed L4
  93. * - 2 = L4 Checksum Error: the L4 checksum value is
  94. * - 3 = UDP Length Error: The UDP length field would
  95. * make the UDP data longer than what remains in
  96. * the IP packet (as defined by the IP header
  97. * length field).
  98. * - 4 = Bad L4 Port: either the source or destination
  99. * TCP/UDP port is 0.
  100. * - 8 = TCP FIN Only: the packet is TCP and only the
  101. * FIN flag set.
  102. * - 9 = TCP No Flags: the packet is TCP and no flags
  103. * are set.
  104. * - 10 = TCP FIN RST: the packet is TCP and both FIN
  105. * and RST are set.
  106. * - 11 = TCP SYN URG: the packet is TCP and both SYN
  107. * and URG are set.
  108. * - 12 = TCP SYN RST: the packet is TCP and both SYN
  109. * and RST are set.
  110. * - 13 = TCP SYN FIN: the packet is TCP and both SYN
  111. * and FIN are set.
  112. */
  113. uint64_t L4_error:1;
  114. /* set if the packet is a fragment */
  115. uint64_t is_frag:1;
  116. /* the receive interface hardware detected an IP error
  117. * / exception (only applies if !rcv_error && !not_IP)
  118. * failure indicated in err_code below, decode:
  119. *
  120. * - 1 = Not IP: the IP version field is neither 4 nor
  121. * 6.
  122. * - 2 = IPv4 Header Checksum Error: the IPv4 header
  123. * has a checksum violation.
  124. * - 3 = IP Malformed Header: the packet is not long
  125. * enough to contain the IP header.
  126. * - 4 = IP Malformed: the packet is not long enough
  127. * to contain the bytes indicated by the IP
  128. * header. Pad is allowed.
  129. * - 5 = IP TTL Hop: the IPv4 TTL field or the IPv6
  130. * Hop Count field are zero.
  131. * - 6 = IP Options
  132. */
  133. uint64_t IP_exc:1;
  134. /*
  135. * Set if the hardware determined that the packet is a
  136. * broadcast.
  137. */
  138. uint64_t is_bcast:1;
  139. /*
  140. * St if the hardware determined that the packet is a
  141. * multi-cast.
  142. */
  143. uint64_t is_mcast:1;
  144. /*
  145. * Set if the packet may not be IP (must be zero in
  146. * this case).
  147. */
  148. uint64_t not_IP:1;
  149. /*
  150. * The receive interface hardware detected a receive
  151. * error (must be zero in this case).
  152. */
  153. uint64_t rcv_error:1;
  154. /* lower err_code = first-level descriptor of the
  155. * work */
  156. /* zero for packet submitted by hardware that isn't on
  157. * the slow path */
  158. /* type is cvmx_pip_err_t */
  159. uint64_t err_code:8;
  160. } s;
  161. /* use this to get at the 16 vlan bits */
  162. struct {
  163. uint64_t unused1:16;
  164. uint64_t vlan:16;
  165. uint64_t unused2:32;
  166. } svlan;
  167. /*
  168. * use this struct if the hardware could not determine that
  169. * the packet is ip.
  170. */
  171. struct {
  172. /*
  173. * HW sets this to the number of buffers used by this
  174. * packet.
  175. */
  176. uint64_t bufs:8;
  177. uint64_t unused:8;
  178. /* set to 1 if we found DSA/VLAN in the L2 */
  179. uint64_t vlan_valid:1;
  180. /* Set to 1 if the DSA/VLAN tag is stacked */
  181. uint64_t vlan_stacked:1;
  182. uint64_t unassigned:1;
  183. /*
  184. * HW sets to the DSA/VLAN CFI flag (valid when
  185. * vlan_valid)
  186. */
  187. uint64_t vlan_cfi:1;
  188. /*
  189. * HW sets to the DSA/VLAN_ID field (valid when
  190. * vlan_valid).
  191. */
  192. uint64_t vlan_id:12;
  193. /*
  194. * Ring Identifier (if PCIe). Requires
  195. * PIP_GBL_CTL[RING_EN]=1
  196. */
  197. uint64_t pr:4;
  198. uint64_t unassigned2:12;
  199. /*
  200. * reserved for software use, hardware will clear on
  201. * packet creation.
  202. */
  203. uint64_t software:1;
  204. uint64_t unassigned3:1;
  205. /*
  206. * set if the hardware determined that the packet is
  207. * rarp.
  208. */
  209. uint64_t is_rarp:1;
  210. /*
  211. * set if the hardware determined that the packet is
  212. * arp
  213. */
  214. uint64_t is_arp:1;
  215. /*
  216. * set if the hardware determined that the packet is a
  217. * broadcast.
  218. */
  219. uint64_t is_bcast:1;
  220. /*
  221. * set if the hardware determined that the packet is a
  222. * multi-cast
  223. */
  224. uint64_t is_mcast:1;
  225. /*
  226. * set if the packet may not be IP (must be one in
  227. * this case)
  228. */
  229. uint64_t not_IP:1;
  230. /* The receive interface hardware detected a receive
  231. * error. Failure indicated in err_code below,
  232. * decode:
  233. *
  234. * - 1 = partial error: a packet was partially
  235. * received, but internal buffering / bandwidth
  236. * was not adequate to receive the entire
  237. * packet.
  238. * - 2 = jabber error: the RGMII packet was too large
  239. * and is truncated.
  240. * - 3 = overrun error: the RGMII packet is longer
  241. * than allowed and had an FCS error.
  242. * - 4 = oversize error: the RGMII packet is longer
  243. * than allowed.
  244. * - 5 = alignment error: the RGMII packet is not an
  245. * integer number of bytes
  246. * and had an FCS error (100M and 10M only).
  247. * - 6 = fragment error: the RGMII packet is shorter
  248. * than allowed and had an FCS error.
  249. * - 7 = GMX FCS error: the RGMII packet had an FCS
  250. * error.
  251. * - 8 = undersize error: the RGMII packet is shorter
  252. * than allowed.
  253. * - 9 = extend error: the RGMII packet had an extend
  254. * error.
  255. * - 10 = length mismatch error: the RGMII packet had
  256. * a length that did not match the length field
  257. * in the L2 HDR.
  258. * - 11 = RGMII RX error/SPI4 DIP4 Error: the RGMII
  259. * packet had one or more data reception errors
  260. * (RXERR) or the SPI4 packet had one or more
  261. * DIP4 errors.
  262. * - 12 = RGMII skip error/SPI4 Abort Error: the RGMII
  263. * packet was not large enough to cover the
  264. * skipped bytes or the SPI4 packet was
  265. * terminated with an About EOPS.
  266. * - 13 = RGMII nibble error/SPI4 Port NXA Error: the
  267. * RGMII packet had a studder error (data not
  268. * repeated - 10/100M only) or the SPI4 packet
  269. * was sent to an NXA.
  270. * - 16 = FCS error: a SPI4.2 packet had an FCS error.
  271. * - 17 = Skip error: a packet was not large enough to
  272. * cover the skipped bytes.
  273. * - 18 = L2 header malformed: the packet is not long
  274. * enough to contain the L2.
  275. */
  276. uint64_t rcv_error:1;
  277. /*
  278. * lower err_code = first-level descriptor of the
  279. * work
  280. */
  281. /*
  282. * zero for packet submitted by hardware that isn't on
  283. * the slow path
  284. */
  285. /* type is cvmx_pip_err_t (union, so can't use directly */
  286. uint64_t err_code:8;
  287. } snoip;
  288. } cvmx_pip_wqe_word2;
  289. /**
  290. * Work queue entry format
  291. *
  292. * must be 8-byte aligned
  293. */
  294. typedef struct {
  295. /*****************************************************************
  296. * WORD 0
  297. * HW WRITE: the following 64 bits are filled by HW when a packet arrives
  298. */
  299. /**
  300. * raw chksum result generated by the HW
  301. */
  302. uint16_t hw_chksum;
  303. /**
  304. * Field unused by hardware - available for software
  305. */
  306. uint8_t unused;
  307. /**
  308. * Next pointer used by hardware for list maintenance.
  309. * May be written/read by HW before the work queue
  310. * entry is scheduled to a PP
  311. * (Only 36 bits used in Octeon 1)
  312. */
  313. uint64_t next_ptr:40;
  314. /*****************************************************************
  315. * WORD 1
  316. * HW WRITE: the following 64 bits are filled by HW when a packet arrives
  317. */
  318. /**
  319. * HW sets to the total number of bytes in the packet
  320. */
  321. uint64_t len:16;
  322. /**
  323. * HW sets this to input physical port
  324. */
  325. uint64_t ipprt:6;
  326. /**
  327. * HW sets this to what it thought the priority of the input packet was
  328. */
  329. uint64_t qos:3;
  330. /**
  331. * the group that the work queue entry will be scheduled to
  332. */
  333. uint64_t grp:4;
  334. /**
  335. * the type of the tag (ORDERED, ATOMIC, NULL)
  336. */
  337. uint64_t tag_type:3;
  338. /**
  339. * the synchronization/ordering tag
  340. */
  341. uint64_t tag:32;
  342. /**
  343. * WORD 2 HW WRITE: the following 64-bits are filled in by
  344. * hardware when a packet arrives This indicates a variety of
  345. * status and error conditions.
  346. */
  347. cvmx_pip_wqe_word2 word2;
  348. /**
  349. * Pointer to the first segment of the packet.
  350. */
  351. union cvmx_buf_ptr packet_ptr;
  352. /**
  353. * HW WRITE: octeon will fill in a programmable amount from the
  354. * packet, up to (at most, but perhaps less) the amount
  355. * needed to fill the work queue entry to 128 bytes
  356. *
  357. * If the packet is recognized to be IP, the hardware starts
  358. * (except that the IPv4 header is padded for appropriate
  359. * alignment) writing here where the IP header starts. If the
  360. * packet is not recognized to be IP, the hardware starts
  361. * writing the beginning of the packet here.
  362. */
  363. uint8_t packet_data[96];
  364. /**
  365. * If desired, SW can make the work Q entry any length. For the
  366. * purposes of discussion here, Assume 128B always, as this is all that
  367. * the hardware deals with.
  368. *
  369. */
  370. } CVMX_CACHE_LINE_ALIGNED cvmx_wqe_t;
  371. #endif /* __CVMX_WQE_H__ */