aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/stmicro/stmmac/descs_com.h
blob: dd8d6e19dff6b2c1182dfb0f31ca8c4696c84931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*******************************************************************************
  Header File to describe Normal/enhanced descriptor functions used for RING
  and CHAINED modes.

  Copyright(C) 2011  STMicroelectronics Ltd

  It defines all the functions used to handle the normal/enhanced
  descriptors in case of the DMA is configured to work in chained or
  in ring mode.

  This program is free software; you can redistribute it and/or modify it
  under the terms and conditions of the GNU General Public License,
  version 2, as published by the Free Software Foundation.

  This program is distributed in the hope it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  more details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

  The full GNU General Public License is included in this distribution in
  the file called "COPYING".

  Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/

#if defined(CONFIG_STMMAC_RING)
static inline void ehn_desc_rx_set_on_ring_chain(struct dma_desc *p, int end)
{
	p->des01.erx.buffer2_size = BUF_SIZE_8KiB - 1;
	if (end)
		p->des01.erx.end_ring = 1;
}

static inline void ehn_desc_tx_set_on_ring_chain(struct dma_desc *p, int end)
{
	if (end)
		p->des01.etx.end_ring = 1;
}

static inline void enh_desc_end_tx_desc(struct dma_desc *p, int ter)
{
	p->des01.etx.end_ring = ter;
}

static inline void enh_set_tx_desc_len(struct dma_desc *p, int len)
{
	if (unlikely(len > BUF_SIZE_4KiB)) {
		p->des01.etx.buffer1_size = BUF_SIZE_4KiB;
		p->des01.etx.buffer2_size = len - BUF_SIZE_4KiB;
	} else
		p->des01.etx.buffer1_size = len;
}

static inline void ndesc_rx_set_on_ring_chain(struct dma_desc *p, int end)
{
	p->des01.rx.buffer2_size = BUF_SIZE_2KiB - 1;
	if (end)
		p->des01.rx.end_ring = 1;
}

static inline void ndesc_tx_set_on_ring_chain(struct dma_desc *p, int end)
{
	if (end)
		p->des01.tx.end_ring = 1;
}

static inline void ndesc_end_tx_desc(struct dma_desc *p, int ter)
{
	p->des01.tx.end_ring = ter;
}

static inline void norm_set_tx_desc_len(struct dma_desc *p, int len)
{
	if (unlikely(len > BUF_SIZE_2KiB)) {
		p->des01.etx.buffer1_size = BUF_SIZE_2KiB - 1;
		p->des01.etx.buffer2_size = len - p->des01.etx.buffer1_size;
	} else
		p->des01.tx.buffer1_size = len;
}

#else

static inline void ehn_desc_rx_set_on_ring_chain(struct dma_desc *p, int end)
{
	p->des01.erx.second_address_chained = 1;
}

static inline void ehn_desc_tx_set_on_ring_chain(struct dma_desc *p, int end)
{
	p->des01.etx.second_address_chained = 1;
}

static inline void enh_desc_end_tx_desc(struct dma_desc *p, int ter)
{
	p->des01.etx.second_address_chained = 1;
}

static inline void enh_set_tx_desc_len(struct dma_desc *p, int len)
{
	p->des01.etx.buffer1_size = len;
}

static inline void ndesc_rx_set_on_ring_chain(struct dma_desc *p, int end)
{
	p->des01.rx.second_address_chained = 1;
}

static inline void ndesc_tx_set_on_ring_chain(struct dma_desc *p, int ring_size)
{
	p->des01.tx.second_address_chained = 1;
}

static inline void ndesc_end_tx_desc(struct dma_desc *p, int ter)
{
	p->des01.tx.second_address_chained = 1;
}

static inline void norm_set_tx_desc_len(struct dma_desc *p, int len)
{
	p->des01.tx.buffer1_size = len;
}
#endif