sxgbe_desc.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /* 10G controller driver for Samsung SoCs
  2. *
  3. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Author: Siva Reddy Kallam <siva.kallam@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __SXGBE_DESC_H__
  13. #define __SXGBE_DESC_H__
  14. #define SXGBE_DESC_SIZE_BYTES 16
  15. /* forward declaration */
  16. struct sxgbe_extra_stats;
  17. /* Transmit checksum insertion control */
  18. enum tdes_csum_insertion {
  19. cic_disabled = 0, /* Checksum Insertion Control */
  20. cic_only_ip = 1, /* Only IP header */
  21. /* IP header but pseudoheader is not calculated */
  22. cic_no_pseudoheader = 2,
  23. cic_full = 3, /* IP header and pseudoheader */
  24. };
  25. struct sxgbe_tx_norm_desc {
  26. u64 tdes01; /* buf1 address */
  27. union {
  28. /* TX Read-Format Desc 2,3 */
  29. struct {
  30. /* TDES2 */
  31. u32 buf1_size:14;
  32. u32 vlan_tag_ctl:2;
  33. u32 buf2_size:14;
  34. u32 timestmp_enable:1;
  35. u32 int_on_com:1;
  36. /* TDES3 */
  37. union {
  38. u16 tcp_payload_len;
  39. struct {
  40. u32 total_pkt_len:15;
  41. u32 reserved1:1;
  42. } pkt_len;
  43. } tx_pkt_len;
  44. u16 cksum_ctl:2;
  45. u16 tse_bit:1;
  46. u16 tcp_hdr_len:4;
  47. u16 sa_insert_ctl:3;
  48. u16 crc_pad_ctl:2;
  49. u16 last_desc:1;
  50. u16 first_desc:1;
  51. u16 ctxt_bit:1;
  52. u16 own_bit:1;
  53. } tx_rd_des23;
  54. /* tx write back Desc 2,3 */
  55. struct {
  56. /* WB TES2 */
  57. u32 reserved1;
  58. /* WB TES3 */
  59. u32 reserved2:31;
  60. u32 own_bit:1;
  61. } tx_wb_des23;
  62. } tdes23;
  63. };
  64. struct sxgbe_rx_norm_desc {
  65. union {
  66. u64 rdes01; /* buf1 address */
  67. union {
  68. u32 out_vlan_tag:16;
  69. u32 in_vlan_tag:16;
  70. u32 rss_hash;
  71. } rx_wb_des01;
  72. } rdes01;
  73. union {
  74. /* RX Read format Desc 2,3 */
  75. struct{
  76. /* RDES2 */
  77. u64 buf2_addr:62;
  78. /* RDES3 */
  79. u32 int_on_com:1;
  80. u32 own_bit:1;
  81. } rx_rd_des23;
  82. /* RX write back */
  83. struct{
  84. /* WB RDES2 */
  85. u32 hdr_len:10;
  86. u32 rdes2_reserved:2;
  87. u32 elrd_val:1;
  88. u32 iovt_sel:1;
  89. u32 res_pkt:1;
  90. u32 vlan_filter_match:1;
  91. u32 sa_filter_fail:1;
  92. u32 da_filter_fail:1;
  93. u32 hash_filter_pass:1;
  94. u32 macaddr_filter_match:8;
  95. u32 l3_filter_match:1;
  96. u32 l4_filter_match:1;
  97. u32 l34_filter_num:3;
  98. /* WB RDES3 */
  99. u32 pkt_len:14;
  100. u32 rdes3_reserved:1;
  101. u32 err_summary:1;
  102. u32 err_l2_type:4;
  103. u32 layer34_pkt_type:4;
  104. u32 no_coagulation_pkt:1;
  105. u32 in_seq_pkt:1;
  106. u32 rss_valid:1;
  107. u32 context_des_avail:1;
  108. u32 last_desc:1;
  109. u32 first_desc:1;
  110. u32 recv_context_desc:1;
  111. u32 own_bit:1;
  112. } rx_wb_des23;
  113. } rdes23;
  114. };
  115. /* Context descriptor structure */
  116. struct sxgbe_tx_ctxt_desc {
  117. u32 tstamp_lo;
  118. u32 tstamp_hi;
  119. u32 maxseg_size:15;
  120. u32 reserved1:1;
  121. u32 ivlan_tag:16;
  122. u32 vlan_tag:16;
  123. u32 vltag_valid:1;
  124. u32 ivlan_tag_valid:1;
  125. u32 ivlan_tag_ctl:2;
  126. u32 reserved2:3;
  127. u32 ctxt_desc_err:1;
  128. u32 reserved3:2;
  129. u32 ostc:1;
  130. u32 tcmssv:1;
  131. u32 reserved4:2;
  132. u32 ctxt_bit:1;
  133. u32 own_bit:1;
  134. };
  135. struct sxgbe_rx_ctxt_desc {
  136. u32 tstamp_lo;
  137. u32 tstamp_hi;
  138. u32 reserved1;
  139. u32 ptp_msgtype:4;
  140. u32 tstamp_available:1;
  141. u32 ptp_rsp_err:1;
  142. u32 tstamp_dropped:1;
  143. u32 reserved2:23;
  144. u32 rx_ctxt_desc:1;
  145. u32 own_bit:1;
  146. };
  147. struct sxgbe_desc_ops {
  148. /* DMA TX descriptor ring initialization */
  149. void (*init_tx_desc)(struct sxgbe_tx_norm_desc *p);
  150. /* Invoked by the xmit function to prepare the tx descriptor */
  151. void (*tx_desc_enable_tse)(struct sxgbe_tx_norm_desc *p, u8 is_tse,
  152. u32 total_hdr_len, u32 tcp_hdr_len,
  153. u32 tcp_payload_len);
  154. /* Assign buffer lengths for descriptor */
  155. void (*prepare_tx_desc)(struct sxgbe_tx_norm_desc *p, u8 is_fd,
  156. int buf1_len, int pkt_len, int cksum);
  157. /* Set VLAN control information */
  158. void (*tx_vlanctl_desc)(struct sxgbe_tx_norm_desc *p, int vlan_ctl);
  159. /* Set the owner of the descriptor */
  160. void (*set_tx_owner)(struct sxgbe_tx_norm_desc *p);
  161. /* Get the owner of the descriptor */
  162. int (*get_tx_owner)(struct sxgbe_tx_norm_desc *p);
  163. /* Invoked by the xmit function to close the tx descriptor */
  164. void (*close_tx_desc)(struct sxgbe_tx_norm_desc *p);
  165. /* Clean the tx descriptor as soon as the tx irq is received */
  166. void (*release_tx_desc)(struct sxgbe_tx_norm_desc *p);
  167. /* Clear interrupt on tx frame completion. When this bit is
  168. * set an interrupt happens as soon as the frame is transmitted
  169. */
  170. void (*clear_tx_ic)(struct sxgbe_tx_norm_desc *p);
  171. /* Last tx segment reports the transmit status */
  172. int (*get_tx_ls)(struct sxgbe_tx_norm_desc *p);
  173. /* Get the buffer size from the descriptor */
  174. int (*get_tx_len)(struct sxgbe_tx_norm_desc *p);
  175. /* Set tx timestamp enable bit */
  176. void (*tx_enable_tstamp)(struct sxgbe_tx_norm_desc *p);
  177. /* get tx timestamp status */
  178. int (*get_tx_timestamp_status)(struct sxgbe_tx_norm_desc *p);
  179. /* TX Context Descripto Specific */
  180. void (*tx_ctxt_desc_set_ctxt)(struct sxgbe_tx_ctxt_desc *p);
  181. /* Set the owner of the TX context descriptor */
  182. void (*tx_ctxt_desc_set_owner)(struct sxgbe_tx_ctxt_desc *p);
  183. /* Get the owner of the TX context descriptor */
  184. int (*get_tx_ctxt_owner)(struct sxgbe_tx_ctxt_desc *p);
  185. /* Set TX mss */
  186. void (*tx_ctxt_desc_set_mss)(struct sxgbe_tx_ctxt_desc *p, u16 mss);
  187. /* Set TX mss */
  188. int (*tx_ctxt_desc_get_mss)(struct sxgbe_tx_ctxt_desc *p);
  189. /* Set TX tcmssv */
  190. void (*tx_ctxt_desc_set_tcmssv)(struct sxgbe_tx_ctxt_desc *p);
  191. /* Reset TX ostc */
  192. void (*tx_ctxt_desc_reset_ostc)(struct sxgbe_tx_ctxt_desc *p);
  193. /* Set IVLAN information */
  194. void (*tx_ctxt_desc_set_ivlantag)(struct sxgbe_tx_ctxt_desc *p,
  195. int is_ivlanvalid, int ivlan_tag,
  196. int ivlan_ctl);
  197. /* Return IVLAN Tag */
  198. int (*tx_ctxt_desc_get_ivlantag)(struct sxgbe_tx_ctxt_desc *p);
  199. /* Set VLAN Tag */
  200. void (*tx_ctxt_desc_set_vlantag)(struct sxgbe_tx_ctxt_desc *p,
  201. int is_vlanvalid, int vlan_tag);
  202. /* Return VLAN Tag */
  203. int (*tx_ctxt_desc_get_vlantag)(struct sxgbe_tx_ctxt_desc *p);
  204. /* Set Time stamp */
  205. void (*tx_ctxt_set_tstamp)(struct sxgbe_tx_ctxt_desc *p,
  206. u8 ostc_enable, u64 tstamp);
  207. /* Close TX context descriptor */
  208. void (*close_tx_ctxt_desc)(struct sxgbe_tx_ctxt_desc *p);
  209. /* WB status of context descriptor */
  210. int (*get_tx_ctxt_cde)(struct sxgbe_tx_ctxt_desc *p);
  211. /* DMA RX descriptor ring initialization */
  212. void (*init_rx_desc)(struct sxgbe_rx_norm_desc *p, int disable_rx_ic,
  213. int mode, int end);
  214. /* Get own bit */
  215. int (*get_rx_owner)(struct sxgbe_rx_norm_desc *p);
  216. /* Set own bit */
  217. void (*set_rx_owner)(struct sxgbe_rx_norm_desc *p);
  218. /* Set Interrupt on completion bit */
  219. void (*set_rx_int_on_com)(struct sxgbe_rx_norm_desc *p);
  220. /* Get the receive frame size */
  221. int (*get_rx_frame_len)(struct sxgbe_rx_norm_desc *p);
  222. /* Return first Descriptor status */
  223. int (*get_rx_fd_status)(struct sxgbe_rx_norm_desc *p);
  224. /* Return first Descriptor status */
  225. int (*get_rx_ld_status)(struct sxgbe_rx_norm_desc *p);
  226. /* Return the reception status looking at the RDES1 */
  227. int (*rx_wbstatus)(struct sxgbe_rx_norm_desc *p,
  228. struct sxgbe_extra_stats *x, int *checksum);
  229. /* Get own bit */
  230. int (*get_rx_ctxt_owner)(struct sxgbe_rx_ctxt_desc *p);
  231. /* Set own bit */
  232. void (*set_rx_ctxt_owner)(struct sxgbe_rx_ctxt_desc *p);
  233. /* Return the reception status looking at Context control information */
  234. void (*rx_ctxt_wbstatus)(struct sxgbe_rx_ctxt_desc *p,
  235. struct sxgbe_extra_stats *x);
  236. /* Get rx timestamp status */
  237. int (*get_rx_ctxt_tstamp_status)(struct sxgbe_rx_ctxt_desc *p);
  238. /* Get timestamp value for rx, need to check this */
  239. u64 (*get_timestamp)(struct sxgbe_rx_ctxt_desc *p);
  240. };
  241. const struct sxgbe_desc_ops *sxgbe_get_desc_ops(void);
  242. #endif /* __SXGBE_DESC_H__ */