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