Commit 11db04c8 authored by Paul Martin's avatar Paul Martin Committed by Ralf Baechle

MIPS: Octeon: Turn hardware bitfields and structures inside out.

Although the proper way to do this for bitfields would be to use
the macro that Ralf has provided, this is a little easier to
understand as a diff.
Signed-off-by: default avatarPaul Martin <paul.martin@codethink.co.uk>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9628/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 0a1cd2c5
...@@ -519,44 +519,89 @@ int cvmx_l2c_unlock_mem_region(uint64_t start, uint64_t len) ...@@ -519,44 +519,89 @@ int cvmx_l2c_unlock_mem_region(uint64_t start, uint64_t len)
union __cvmx_l2c_tag { union __cvmx_l2c_tag {
uint64_t u64; uint64_t u64;
struct cvmx_l2c_tag_cn50xx { struct cvmx_l2c_tag_cn50xx {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t reserved:40; uint64_t reserved:40;
uint64_t V:1; /* Line valid */ uint64_t V:1; /* Line valid */
uint64_t D:1; /* Line dirty */ uint64_t D:1; /* Line dirty */
uint64_t L:1; /* Line locked */ uint64_t L:1; /* Line locked */
uint64_t U:1; /* Use, LRU eviction */ uint64_t U:1; /* Use, LRU eviction */
uint64_t addr:20; /* Phys mem addr (33..14) */ uint64_t addr:20; /* Phys mem addr (33..14) */
#else
uint64_t addr:20; /* Phys mem addr (33..14) */
uint64_t U:1; /* Use, LRU eviction */
uint64_t L:1; /* Line locked */
uint64_t D:1; /* Line dirty */
uint64_t V:1; /* Line valid */
uint64_t reserved:40;
#endif
} cn50xx; } cn50xx;
struct cvmx_l2c_tag_cn30xx { struct cvmx_l2c_tag_cn30xx {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t reserved:41; uint64_t reserved:41;
uint64_t V:1; /* Line valid */ uint64_t V:1; /* Line valid */
uint64_t D:1; /* Line dirty */ uint64_t D:1; /* Line dirty */
uint64_t L:1; /* Line locked */ uint64_t L:1; /* Line locked */
uint64_t U:1; /* Use, LRU eviction */ uint64_t U:1; /* Use, LRU eviction */
uint64_t addr:19; /* Phys mem addr (33..15) */ uint64_t addr:19; /* Phys mem addr (33..15) */
#else
uint64_t addr:19; /* Phys mem addr (33..15) */
uint64_t U:1; /* Use, LRU eviction */
uint64_t L:1; /* Line locked */
uint64_t D:1; /* Line dirty */
uint64_t V:1; /* Line valid */
uint64_t reserved:41;
#endif
} cn30xx; } cn30xx;
struct cvmx_l2c_tag_cn31xx { struct cvmx_l2c_tag_cn31xx {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t reserved:42; uint64_t reserved:42;
uint64_t V:1; /* Line valid */ uint64_t V:1; /* Line valid */
uint64_t D:1; /* Line dirty */ uint64_t D:1; /* Line dirty */
uint64_t L:1; /* Line locked */ uint64_t L:1; /* Line locked */
uint64_t U:1; /* Use, LRU eviction */ uint64_t U:1; /* Use, LRU eviction */
uint64_t addr:18; /* Phys mem addr (33..16) */ uint64_t addr:18; /* Phys mem addr (33..16) */
#else
uint64_t addr:18; /* Phys mem addr (33..16) */
uint64_t U:1; /* Use, LRU eviction */
uint64_t L:1; /* Line locked */
uint64_t D:1; /* Line dirty */
uint64_t V:1; /* Line valid */
uint64_t reserved:42;
#endif
} cn31xx; } cn31xx;
struct cvmx_l2c_tag_cn38xx { struct cvmx_l2c_tag_cn38xx {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t reserved:43; uint64_t reserved:43;
uint64_t V:1; /* Line valid */ uint64_t V:1; /* Line valid */
uint64_t D:1; /* Line dirty */ uint64_t D:1; /* Line dirty */
uint64_t L:1; /* Line locked */ uint64_t L:1; /* Line locked */
uint64_t U:1; /* Use, LRU eviction */ uint64_t U:1; /* Use, LRU eviction */
uint64_t addr:17; /* Phys mem addr (33..17) */ uint64_t addr:17; /* Phys mem addr (33..17) */
#else
uint64_t addr:17; /* Phys mem addr (33..17) */
uint64_t U:1; /* Use, LRU eviction */
uint64_t L:1; /* Line locked */
uint64_t D:1; /* Line dirty */
uint64_t V:1; /* Line valid */
uint64_t reserved:43;
#endif
} cn38xx; } cn38xx;
struct cvmx_l2c_tag_cn58xx { struct cvmx_l2c_tag_cn58xx {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t reserved:44; uint64_t reserved:44;
uint64_t V:1; /* Line valid */ uint64_t V:1; /* Line valid */
uint64_t D:1; /* Line dirty */ uint64_t D:1; /* Line dirty */
uint64_t L:1; /* Line locked */ uint64_t L:1; /* Line locked */
uint64_t U:1; /* Use, LRU eviction */ uint64_t U:1; /* Use, LRU eviction */
uint64_t addr:16; /* Phys mem addr (33..18) */ uint64_t addr:16; /* Phys mem addr (33..18) */
#else
uint64_t addr:16; /* Phys mem addr (33..18) */
uint64_t U:1; /* Use, LRU eviction */
uint64_t L:1; /* Line locked */
uint64_t D:1; /* Line dirty */
uint64_t V:1; /* Line valid */
uint64_t reserved:44;
#endif
} cn58xx; } cn58xx;
struct cvmx_l2c_tag_cn58xx cn56xx; /* 2048 sets */ struct cvmx_l2c_tag_cn58xx cn56xx; /* 2048 sets */
struct cvmx_l2c_tag_cn31xx cn52xx; /* 512 sets */ struct cvmx_l2c_tag_cn31xx cn52xx; /* 512 sets */
......
...@@ -104,6 +104,7 @@ typedef enum { ...@@ -104,6 +104,7 @@ typedef enum {
typedef union { typedef union {
uint64_t u64; uint64_t u64;
#ifdef __BIG_ENDIAN_BITFIELD
/* mapped or unmapped virtual address */ /* mapped or unmapped virtual address */
struct { struct {
uint64_t R:2; uint64_t R:2;
...@@ -202,6 +203,72 @@ typedef union { ...@@ -202,6 +203,72 @@ typedef union {
uint64_t didspace:24; uint64_t didspace:24;
uint64_t unused:40; uint64_t unused:40;
} sfilldidspace; } sfilldidspace;
#else
struct {
uint64_t offset:62;
uint64_t R:2;
} sva;
struct {
uint64_t offset:31;
uint64_t zeroes:33;
} suseg;
struct {
uint64_t offset:29;
uint64_t sp:2;
uint64_t ones:33;
} sxkseg;
struct {
uint64_t pa:49;
uint64_t mbz:10;
uint64_t cca:3;
uint64_t R:2;
} sxkphys;
struct {
uint64_t offset:36;
uint64_t unaddr:4;
uint64_t did:8;
uint64_t is_io:1;
uint64_t mbz:15;
} sphys;
struct {
uint64_t offset:36;
uint64_t unaddr:4;
uint64_t zeroes:24;
} smem;
struct {
uint64_t offset:36;
uint64_t unaddr:4;
uint64_t did:8;
uint64_t is_io:1;
uint64_t mbz:13;
uint64_t mem_region:2;
} sio;
struct {
uint64_t addr:13;
cvmx_add_win_dec_t csrdec:2;
uint64_t ones:49;
} sscr;
struct {
uint64_t addr:7;
uint64_t type:3;
uint64_t unused2:3;
uint64_t csrdec:2;
uint64_t ones:49;
} sdma;
struct {
uint64_t unused:40;
uint64_t didspace:24;
} sfilldidspace;
#endif
} cvmx_addr_t; } cvmx_addr_t;
......
...@@ -95,6 +95,7 @@ struct cvmx_bootmem_named_block_desc { ...@@ -95,6 +95,7 @@ struct cvmx_bootmem_named_block_desc {
* positions for backwards compatibility. * positions for backwards compatibility.
*/ */
struct cvmx_bootmem_desc { struct cvmx_bootmem_desc {
#if defined(__BIG_ENDIAN_BITFIELD) || defined(CVMX_BUILD_FOR_LINUX_HOST)
/* spinlock to control access to list */ /* spinlock to control access to list */
uint32_t lock; uint32_t lock;
/* flags for indicating various conditions */ /* flags for indicating various conditions */
...@@ -120,7 +121,20 @@ struct cvmx_bootmem_desc { ...@@ -120,7 +121,20 @@ struct cvmx_bootmem_desc {
uint32_t named_block_name_len; uint32_t named_block_name_len;
/* address of named memory block descriptors */ /* address of named memory block descriptors */
uint64_t named_block_array_addr; uint64_t named_block_array_addr;
#else /* __LITTLE_ENDIAN */
uint32_t flags;
uint32_t lock;
uint64_t head_addr;
uint32_t minor_version;
uint32_t major_version;
uint64_t app_data_addr;
uint64_t app_data_size;
uint32_t named_block_name_len;
uint32_t named_block_num_blocks;
uint64_t named_block_array_addr;
#endif
}; };
/** /**
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
typedef union { typedef union {
uint64_t u64; uint64_t u64;
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
/* /*
* the (64-bit word) location in scratchpad to write * the (64-bit word) location in scratchpad to write
* to (if len != 0) * to (if len != 0)
...@@ -63,6 +64,12 @@ typedef union { ...@@ -63,6 +64,12 @@ typedef union {
* the NCB bus. * the NCB bus.
*/ */
uint64_t addr:40; uint64_t addr:40;
#else
uint64_t addr:40;
uint64_t did:8;
uint64_t len:8;
uint64_t scraddr:8;
#endif
} s; } s;
} cvmx_fpa_iobdma_data_t; } cvmx_fpa_iobdma_data_t;
......
...@@ -53,12 +53,21 @@ ...@@ -53,12 +53,21 @@
union cvmx_l2c_tag { union cvmx_l2c_tag {
uint64_t u64; uint64_t u64;
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t reserved:28; uint64_t reserved:28;
uint64_t V:1; /* Line valid */ uint64_t V:1; /* Line valid */
uint64_t D:1; /* Line dirty */ uint64_t D:1; /* Line dirty */
uint64_t L:1; /* Line locked */ uint64_t L:1; /* Line locked */
uint64_t U:1; /* Use, LRU eviction */ uint64_t U:1; /* Use, LRU eviction */
uint64_t addr:32; /* Phys mem (not all bits valid) */ uint64_t addr:32; /* Phys mem (not all bits valid) */
#else
uint64_t addr:32; /* Phys mem (not all bits valid) */
uint64_t U:1; /* Use, LRU eviction */
uint64_t L:1; /* Line locked */
uint64_t D:1; /* Line dirty */
uint64_t V:1; /* Line valid */
uint64_t reserved:28;
#endif
} s; } s;
}; };
......
...@@ -39,6 +39,7 @@ union cvmx_buf_ptr { ...@@ -39,6 +39,7 @@ union cvmx_buf_ptr {
void *ptr; void *ptr;
uint64_t u64; uint64_t u64;
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
/* if set, invert the "free" pick of the overall /* if set, invert the "free" pick of the overall
* packet. HW always sets this bit to 0 on inbound * packet. HW always sets this bit to 0 on inbound
* packet */ * packet */
...@@ -55,6 +56,13 @@ union cvmx_buf_ptr { ...@@ -55,6 +56,13 @@ union cvmx_buf_ptr {
uint64_t size:16; uint64_t size:16;
/* Pointer to the first byte of the data, NOT buffer */ /* Pointer to the first byte of the data, NOT buffer */
uint64_t addr:40; uint64_t addr:40;
#else
uint64_t addr:40;
uint64_t size:16;
uint64_t pool:3;
uint64_t back:4;
uint64_t i:1;
#endif
} s; } s;
}; };
......
...@@ -127,6 +127,7 @@ typedef struct { ...@@ -127,6 +127,7 @@ typedef struct {
typedef union { typedef union {
uint64_t u64; uint64_t u64;
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
/* Must CVMX_IO_SEG */ /* Must CVMX_IO_SEG */
uint64_t mem_space:2; uint64_t mem_space:2;
/* Must be zero */ /* Must be zero */
...@@ -151,6 +152,17 @@ typedef union { ...@@ -151,6 +152,17 @@ typedef union {
uint64_t queue:9; uint64_t queue:9;
/* Must be zero */ /* Must be zero */
uint64_t reserved4:3; uint64_t reserved4:3;
#else
uint64_t reserved4:3;
uint64_t queue:9;
uint64_t port:9;
uint64_t reserved3:15;
uint64_t reserved2:4;
uint64_t did:8;
uint64_t is_io:1;
uint64_t reserved:13;
uint64_t mem_space:2;
#endif
} s; } s;
} cvmx_pko_doorbell_address_t; } cvmx_pko_doorbell_address_t;
...@@ -160,6 +172,7 @@ typedef union { ...@@ -160,6 +172,7 @@ typedef union {
typedef union { typedef union {
uint64_t u64; uint64_t u64;
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
/* /*
* The size of the reg1 operation - could be 8, 16, * The size of the reg1 operation - could be 8, 16,
* 32, or 64 bits. * 32, or 64 bits.
...@@ -229,6 +242,24 @@ typedef union { ...@@ -229,6 +242,24 @@ typedef union {
uint64_t segs:6; uint64_t segs:6;
/* Including L2, but no trailing CRC */ /* Including L2, but no trailing CRC */
uint64_t total_bytes:16; uint64_t total_bytes:16;
#else
uint64_t total_bytes:16;
uint64_t segs:6;
uint64_t dontfree:1;
uint64_t ignore_i:1;
uint64_t ipoffp1:7;
uint64_t gather:1;
uint64_t rsp:1;
uint64_t wqp:1;
uint64_t n2:1;
uint64_t le:1;
uint64_t reg0:11;
uint64_t subone0:1;
uint64_t reg1:11;
uint64_t subone1:1;
uint64_t size0:2;
uint64_t size1:2;
#endif
} s; } s;
} cvmx_pko_command_word0_t; } cvmx_pko_command_word0_t;
......
This diff is collapsed.
...@@ -57,6 +57,7 @@ typedef union { ...@@ -57,6 +57,7 @@ typedef union {
/* Use this struct if the hardware determines that the packet is IP */ /* Use this struct if the hardware determines that the packet is IP */
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
/* HW sets this to the number of buffers used by this packet */ /* HW sets this to the number of buffers used by this packet */
uint64_t bufs:8; uint64_t bufs:8;
/* HW sets to the number of L2 bytes prior to the IP */ /* HW sets to the number of L2 bytes prior to the IP */
...@@ -166,13 +167,45 @@ typedef union { ...@@ -166,13 +167,45 @@ typedef union {
* the slow path */ * the slow path */
/* type is cvmx_pip_err_t */ /* type is cvmx_pip_err_t */
uint64_t err_code:8; uint64_t err_code:8;
#else
uint64_t err_code:8;
uint64_t rcv_error:1;
uint64_t not_IP:1;
uint64_t is_mcast:1;
uint64_t is_bcast:1;
uint64_t IP_exc:1;
uint64_t is_frag:1;
uint64_t L4_error:1;
uint64_t software:1;
uint64_t is_v6:1;
uint64_t dec_ipsec:1;
uint64_t tcp_or_udp:1;
uint64_t dec_ipcomp:1;
uint64_t unassigned2:4;
uint64_t unassigned2a:4;
uint64_t pr:4;
uint64_t vlan_id:12;
uint64_t vlan_cfi:1;
uint64_t unassigned:1;
uint64_t vlan_stacked:1;
uint64_t vlan_valid:1;
uint64_t ip_offset:8;
uint64_t bufs:8;
#endif
} s; } s;
/* use this to get at the 16 vlan bits */ /* use this to get at the 16 vlan bits */
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
uint64_t unused1:16; uint64_t unused1:16;
uint64_t vlan:16; uint64_t vlan:16;
uint64_t unused2:32; uint64_t unused2:32;
#else
uint64_t unused2:32;
uint64_t vlan:16;
uint64_t unused1:16;
#endif
} svlan; } svlan;
/* /*
...@@ -180,6 +213,7 @@ typedef union { ...@@ -180,6 +213,7 @@ typedef union {
* the packet is ip. * the packet is ip.
*/ */
struct { struct {
#ifdef __BIG_ENDIAN_BITFIELD
/* /*
* HW sets this to the number of buffers used by this * HW sets this to the number of buffers used by this
* packet. * packet.
...@@ -296,6 +330,27 @@ typedef union { ...@@ -296,6 +330,27 @@ typedef union {
*/ */
/* type is cvmx_pip_err_t (union, so can't use directly */ /* type is cvmx_pip_err_t (union, so can't use directly */
uint64_t err_code:8; uint64_t err_code:8;
#else
uint64_t err_code:8;
uint64_t rcv_error:1;
uint64_t not_IP:1;
uint64_t is_mcast:1;
uint64_t is_bcast:1;
uint64_t is_arp:1;
uint64_t is_rarp:1;
uint64_t unassigned3:1;
uint64_t software:1;
uint64_t unassigned2:4;
uint64_t unassigned2a:8;
uint64_t pr:4;
uint64_t vlan_id:12;
uint64_t vlan_cfi:1;
uint64_t unassigned:1;
uint64_t vlan_stacked:1;
uint64_t vlan_valid:1;
uint64_t unused:8;
uint64_t bufs:8;
#endif
} snoip; } snoip;
} cvmx_pip_wqe_word2; } cvmx_pip_wqe_word2;
...@@ -312,6 +367,7 @@ typedef struct { ...@@ -312,6 +367,7 @@ typedef struct {
* HW WRITE: the following 64 bits are filled by HW when a packet arrives * HW WRITE: the following 64 bits are filled by HW when a packet arrives
*/ */
#ifdef __BIG_ENDIAN_BITFIELD
/** /**
* raw chksum result generated by the HW * raw chksum result generated by the HW
*/ */
...@@ -327,12 +383,18 @@ typedef struct { ...@@ -327,12 +383,18 @@ typedef struct {
* (Only 36 bits used in Octeon 1) * (Only 36 bits used in Octeon 1)
*/ */
uint64_t next_ptr:40; uint64_t next_ptr:40;
#else
uint64_t next_ptr:40;
uint8_t unused;
uint16_t hw_chksum;
#endif
/***************************************************************** /*****************************************************************
* WORD 1 * WORD 1
* HW WRITE: the following 64 bits are filled by HW when a packet arrives * HW WRITE: the following 64 bits are filled by HW when a packet arrives
*/ */
#ifdef __BIG_ENDIAN_BITFIELD
/** /**
* HW sets to the total number of bytes in the packet * HW sets to the total number of bytes in the packet
*/ */
...@@ -359,6 +421,15 @@ typedef struct { ...@@ -359,6 +421,15 @@ typedef struct {
* the synchronization/ordering tag * the synchronization/ordering tag
*/ */
uint64_t tag:32; uint64_t tag:32;
#else
uint64_t tag:32;
uint64_t tag_type:2;
uint64_t zero_2:1;
uint64_t grp:4;
uint64_t qos:3;
uint64_t ipprt:6;
uint64_t len:16;
#endif
/** /**
* WORD 2 HW WRITE: the following 64-bits are filled in by * WORD 2 HW WRITE: the following 64-bits are filled in by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment