#define FD_OFFSET_MASK 0x0FFF
#define FD_FORMAT_MASK 0x3
#define FD_FORMAT_SHIFT 12
+#define FD_BPID_MASK 0x3FFF
#define SG_SHORT_LEN_FLAG_MASK 0x1
#define SG_SHORT_LEN_FLAG_SHIFT 14
#define SG_SHORT_LEN_MASK 0x1FFFF
*/
static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
{
- return (dma_addr_t)fd->simple.addr;
+ return (dma_addr_t)le64_to_cpu(fd->simple.addr);
}
/**
*/
static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
{
- fd->simple.addr = addr;
+ fd->simple.addr = cpu_to_le64(addr);
}
/**
*/
static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
{
- return fd->simple.frc;
+ return le32_to_cpu(fd->simple.frc);
}
/**
*/
static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
{
- fd->simple.frc = frc;
+ fd->simple.frc = cpu_to_le32(frc);
}
/**
*/
static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
{
- return fd->simple.ctrl;
+ return le32_to_cpu(fd->simple.ctrl);
}
/**
*/
static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
{
- fd->simple.ctrl = ctrl;
+ fd->simple.ctrl = cpu_to_le32(ctrl);
}
/**
*/
static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
{
- return (dma_addr_t)fd->simple.flc;
+ return (dma_addr_t)le64_to_cpu(fd->simple.flc);
}
/**
*/
static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd, dma_addr_t flc_addr)
{
- fd->simple.flc = flc_addr;
+ fd->simple.flc = cpu_to_le64(flc_addr);
}
static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
{
- return !!((fd->simple.format_offset >> FD_SHORT_LEN_FLAG_SHIFT)
- & FD_SHORT_LEN_FLAG_MASK);
+ return !!((le16_to_cpu(fd->simple.format_offset) >>
+ FD_SHORT_LEN_FLAG_SHIFT) & FD_SHORT_LEN_FLAG_MASK);
}
/**
static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
{
if (dpaa2_fd_short_len(fd))
- return fd->simple.len & FD_SHORT_LEN_MASK;
+ return le32_to_cpu(fd->simple.len) & FD_SHORT_LEN_MASK;
- return fd->simple.len;
+ return le32_to_cpu(fd->simple.len);
}
/**
*/
static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
{
- fd->simple.len = len;
+ fd->simple.len = cpu_to_le32(len);
}
/**
*/
static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
{
- return fd->simple.format_offset & FD_OFFSET_MASK;
+ return le16_to_cpu(fd->simple.format_offset) & FD_OFFSET_MASK;
}
/**
*/
static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
{
- fd->simple.format_offset &= ~FD_OFFSET_MASK;
- fd->simple.format_offset |= offset;
+ fd->simple.format_offset &= cpu_to_le16(~FD_OFFSET_MASK);
+ fd->simple.format_offset |= cpu_to_le16(offset);
}
/**
static inline enum dpaa2_fd_format dpaa2_fd_get_format(
const struct dpaa2_fd *fd)
{
- return (enum dpaa2_fd_format)((fd->simple.format_offset
+ return (enum dpaa2_fd_format)((le16_to_cpu(fd->simple.format_offset)
>> FD_FORMAT_SHIFT) & FD_FORMAT_MASK);
}
static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
enum dpaa2_fd_format format)
{
- fd->simple.format_offset &= ~(FD_FORMAT_MASK << FD_FORMAT_SHIFT);
- fd->simple.format_offset |= format << FD_FORMAT_SHIFT;
+ fd->simple.format_offset &=
+ cpu_to_le16(~(FD_FORMAT_MASK << FD_FORMAT_SHIFT));
+ fd->simple.format_offset |= cpu_to_le16(format << FD_FORMAT_SHIFT);
}
/**
*/
static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
{
- return fd->simple.bpid;
+ return le16_to_cpu(fd->simple.bpid) & FD_BPID_MASK;
}
/**
*/
static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
{
- fd->simple.bpid = bpid;
+ fd->simple.bpid &= cpu_to_le16(~(FD_BPID_MASK));
+ fd->simple.bpid |= cpu_to_le16(bpid);
}
/**