@@ -81,6 +81,7 @@ struct dpaa2_fd {
8181#define FD_OFFSET_MASK 0x0FFF
8282#define FD_FORMAT_MASK 0x3
8383#define FD_FORMAT_SHIFT 12
84+ #define FD_BPID_MASK 0x3FFF
8485#define SG_SHORT_LEN_FLAG_MASK 0x1
8586#define SG_SHORT_LEN_FLAG_SHIFT 14
8687#define SG_SHORT_LEN_MASK 0x1FFFF
@@ -105,7 +106,7 @@ enum dpaa2_fd_format {
105106 */
106107static inline dma_addr_t dpaa2_fd_get_addr (const struct dpaa2_fd * fd )
107108{
108- return (dma_addr_t )fd -> simple .addr ;
109+ return (dma_addr_t )le64_to_cpu ( fd -> simple .addr ) ;
109110}
110111
111112/**
@@ -115,7 +116,7 @@ static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
115116 */
116117static inline void dpaa2_fd_set_addr (struct dpaa2_fd * fd , dma_addr_t addr )
117118{
118- fd -> simple .addr = addr ;
119+ fd -> simple .addr = cpu_to_le64 ( addr ) ;
119120}
120121
121122/**
@@ -126,7 +127,7 @@ static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
126127 */
127128static inline u32 dpaa2_fd_get_frc (const struct dpaa2_fd * fd )
128129{
129- return fd -> simple .frc ;
130+ return le32_to_cpu ( fd -> simple .frc ) ;
130131}
131132
132133/**
@@ -136,7 +137,7 @@ static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
136137 */
137138static inline void dpaa2_fd_set_frc (struct dpaa2_fd * fd , u32 frc )
138139{
139- fd -> simple .frc = frc ;
140+ fd -> simple .frc = cpu_to_le32 ( frc ) ;
140141}
141142
142143/**
@@ -147,7 +148,7 @@ static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
147148 */
148149static inline u32 dpaa2_fd_get_ctrl (const struct dpaa2_fd * fd )
149150{
150- return fd -> simple .ctrl ;
151+ return le32_to_cpu ( fd -> simple .ctrl ) ;
151152}
152153
153154/**
@@ -157,7 +158,7 @@ static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
157158 */
158159static inline void dpaa2_fd_set_ctrl (struct dpaa2_fd * fd , u32 ctrl )
159160{
160- fd -> simple .ctrl = ctrl ;
161+ fd -> simple .ctrl = cpu_to_le32 ( ctrl ) ;
161162}
162163
163164/**
@@ -168,7 +169,7 @@ static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
168169 */
169170static inline dma_addr_t dpaa2_fd_get_flc (const struct dpaa2_fd * fd )
170171{
171- return (dma_addr_t )fd -> simple .flc ;
172+ return (dma_addr_t )le64_to_cpu ( fd -> simple .flc ) ;
172173}
173174
174175/**
@@ -178,13 +179,13 @@ static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
178179 */
179180static inline void dpaa2_fd_set_flc (struct dpaa2_fd * fd , dma_addr_t flc_addr )
180181{
181- fd -> simple .flc = flc_addr ;
182+ fd -> simple .flc = cpu_to_le64 ( flc_addr ) ;
182183}
183184
184185static inline bool dpaa2_fd_short_len (const struct dpaa2_fd * fd )
185186{
186- return !!((fd -> simple .format_offset >> FD_SHORT_LEN_FLAG_SHIFT )
187- & FD_SHORT_LEN_FLAG_MASK );
187+ return !!((le16_to_cpu ( fd -> simple .format_offset ) >>
188+ FD_SHORT_LEN_FLAG_SHIFT ) & FD_SHORT_LEN_FLAG_MASK );
188189}
189190
190191/**
@@ -196,9 +197,9 @@ static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
196197static inline u32 dpaa2_fd_get_len (const struct dpaa2_fd * fd )
197198{
198199 if (dpaa2_fd_short_len (fd ))
199- return fd -> simple .len & FD_SHORT_LEN_MASK ;
200+ return le32_to_cpu ( fd -> simple .len ) & FD_SHORT_LEN_MASK ;
200201
201- return fd -> simple .len ;
202+ return le32_to_cpu ( fd -> simple .len ) ;
202203}
203204
204205/**
@@ -208,7 +209,7 @@ static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
208209 */
209210static inline void dpaa2_fd_set_len (struct dpaa2_fd * fd , u32 len )
210211{
211- fd -> simple .len = len ;
212+ fd -> simple .len = cpu_to_le32 ( len ) ;
212213}
213214
214215/**
@@ -219,7 +220,7 @@ static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
219220 */
220221static inline uint16_t dpaa2_fd_get_offset (const struct dpaa2_fd * fd )
221222{
222- return fd -> simple .format_offset & FD_OFFSET_MASK ;
223+ return le16_to_cpu ( fd -> simple .format_offset ) & FD_OFFSET_MASK ;
223224}
224225
225226/**
@@ -229,8 +230,8 @@ static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
229230 */
230231static inline void dpaa2_fd_set_offset (struct dpaa2_fd * fd , uint16_t offset )
231232{
232- fd -> simple .format_offset &= ~FD_OFFSET_MASK ;
233- fd -> simple .format_offset |= offset ;
233+ fd -> simple .format_offset &= cpu_to_le16 ( ~FD_OFFSET_MASK ) ;
234+ fd -> simple .format_offset |= cpu_to_le16 ( offset ) ;
234235}
235236
236237/**
@@ -242,7 +243,7 @@ static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
242243static inline enum dpaa2_fd_format dpaa2_fd_get_format (
243244 const struct dpaa2_fd * fd )
244245{
245- return (enum dpaa2_fd_format )((fd -> simple .format_offset
246+ return (enum dpaa2_fd_format )((le16_to_cpu ( fd -> simple .format_offset )
246247 >> FD_FORMAT_SHIFT ) & FD_FORMAT_MASK );
247248}
248249
@@ -254,8 +255,9 @@ static inline enum dpaa2_fd_format dpaa2_fd_get_format(
254255static inline void dpaa2_fd_set_format (struct dpaa2_fd * fd ,
255256 enum dpaa2_fd_format format )
256257{
257- fd -> simple .format_offset &= ~(FD_FORMAT_MASK << FD_FORMAT_SHIFT );
258- fd -> simple .format_offset |= format << FD_FORMAT_SHIFT ;
258+ fd -> simple .format_offset &=
259+ cpu_to_le16 (~(FD_FORMAT_MASK << FD_FORMAT_SHIFT ));
260+ fd -> simple .format_offset |= cpu_to_le16 (format << FD_FORMAT_SHIFT );
259261}
260262
261263/**
@@ -266,7 +268,7 @@ static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
266268 */
267269static inline uint16_t dpaa2_fd_get_bpid (const struct dpaa2_fd * fd )
268270{
269- return fd -> simple .bpid ;
271+ return le16_to_cpu ( fd -> simple .bpid ) & FD_BPID_MASK ;
270272}
271273
272274/**
@@ -276,7 +278,8 @@ static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
276278 */
277279static inline void dpaa2_fd_set_bpid (struct dpaa2_fd * fd , uint16_t bpid )
278280{
279- fd -> simple .bpid = bpid ;
281+ fd -> simple .bpid &= cpu_to_le16 (~(FD_BPID_MASK ));
282+ fd -> simple .bpid |= cpu_to_le16 (bpid );
280283}
281284
282285/**
0 commit comments