descs_com.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*******************************************************************************
  2. Header File to describe Normal/enhanced descriptor functions used for RING
  3. and CHAINED modes.
  4. Copyright(C) 2011 STMicroelectronics Ltd
  5. It defines all the functions used to handle the normal/enhanced
  6. descriptors in case of the DMA is configured to work in chained or
  7. in ring mode.
  8. This program is free software; you can redistribute it and/or modify it
  9. under the terms and conditions of the GNU General Public License,
  10. version 2, as published by the Free Software Foundation.
  11. This program is distributed in the hope it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. more details.
  15. You should have received a copy of the GNU General Public License along with
  16. this program; if not, write to the Free Software Foundation, Inc.,
  17. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  18. The full GNU General Public License is included in this distribution in
  19. the file called "COPYING".
  20. Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
  21. *******************************************************************************/
  22. #if defined(CONFIG_STMMAC_RING)
  23. static inline void ehn_desc_rx_set_on_ring_chain(struct dma_desc *p, int end)
  24. {
  25. p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1;
  26. if (end)
  27. p->des01.erx.end_ring = 1;
  28. }
  29. static inline void ehn_desc_tx_set_on_ring_chain(struct dma_desc *p, int end)
  30. {
  31. if (end)
  32. p->des01.etx.end_ring = 1;
  33. }
  34. static inline void enh_desc_end_tx_desc(struct dma_desc *p, int ter)
  35. {
  36. p->des01.etx.end_ring = ter;
  37. }
  38. static inline void enh_set_tx_desc_len(struct dma_desc *p, int len)
  39. {
  40. if (unlikely(len > BUF_SIZE_4KiB)) {
  41. p->des01.etx.buffer1_size = BUF_SIZE_4KiB;
  42. p->des01.etx.buffer2_size = len - BUF_SIZE_4KiB;
  43. } else
  44. p->des01.etx.buffer1_size = len;
  45. }
  46. static inline void ndesc_rx_set_on_ring_chain(struct dma_desc *p, int end)
  47. {
  48. p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
  49. if (end)
  50. p->des01.rx.end_ring = 1;
  51. }
  52. static inline void ndesc_tx_set_on_ring_chain(struct dma_desc *p, int end)
  53. {
  54. if (end)
  55. p->des01.tx.end_ring = 1;
  56. }
  57. static inline void ndesc_end_tx_desc(struct dma_desc *p, int ter)
  58. {
  59. p->des01.tx.end_ring = ter;
  60. }
  61. static inline void norm_set_tx_desc_len(struct dma_desc *p, int len)
  62. {
  63. if (unlikely(len > BUF_SIZE_2KiB)) {
  64. p->des01.etx.buffer1_size = BUF_SIZE_2KiB - 1;
  65. p->des01.etx.buffer2_size = len - p->des01.etx.buffer1_size;
  66. } else
  67. p->des01.tx.buffer1_size = len;
  68. }
  69. #else
  70. static inline void ehn_desc_rx_set_on_ring_chain(struct dma_desc *p, int end)
  71. {
  72. p->des01.erx.second_address_chained = 1;
  73. }
  74. static inline void ehn_desc_tx_set_on_ring_chain(struct dma_desc *p, int end)
  75. {
  76. p->des01.etx.second_address_chained = 1;
  77. }
  78. static inline void enh_desc_end_tx_desc(struct dma_desc *p, int ter)
  79. {
  80. p->des01.etx.second_address_chained = 1;
  81. }
  82. static inline void enh_set_tx_desc_len(struct dma_desc *p, int len)
  83. {
  84. p->des01.etx.buffer1_size = len;
  85. }
  86. static inline void ndesc_rx_set_on_ring_chain(struct dma_desc *p, int end)
  87. {
  88. p->des01.rx.second_address_chained = 1;
  89. }
  90. static inline void ndesc_tx_set_on_ring_chain(struct dma_desc *p, int ring_size)
  91. {
  92. p->des01.tx.second_address_chained = 1;
  93. }
  94. static inline void ndesc_end_tx_desc(struct dma_desc *p, int ter)
  95. {
  96. p->des01.tx.second_address_chained = 1;
  97. }
  98. static inline void norm_set_tx_desc_len(struct dma_desc *p, int len)
  99. {
  100. p->des01.tx.buffer1_size = len;
  101. }
  102. #endif