Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ibmveth: Fix little endian issues

The hypervisor is big endian, so little endian kernel builds need
to byteswap.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Anton Blanchard and committed by
David S. Miller
0b536be7 c67c71b4

+18 -5
+2 -2
drivers/net/ethernet/ibm/ibmveth.c
··· 106 106 /* simple methods of getting data from the current rxq entry */ 107 107 static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter) 108 108 { 109 - return adapter->rx_queue.queue_addr[adapter->rx_queue.index].flags_off; 109 + return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].flags_off); 110 110 } 111 111 112 112 static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter) ··· 132 132 133 133 static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) 134 134 { 135 - return adapter->rx_queue.queue_addr[adapter->rx_queue.index].length; 135 + return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length); 136 136 } 137 137 138 138 static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter)
+16 -3
drivers/net/ethernet/ibm/ibmveth.h
··· 164 164 u64 tx_send_failed; 165 165 }; 166 166 167 + /* 168 + * We pass struct ibmveth_buf_desc_fields to the hypervisor in registers, 169 + * so we don't need to byteswap the two elements. However since we use 170 + * a union (ibmveth_buf_desc) to convert from the struct to a u64 we 171 + * do end up with endian specific ordering of the elements and that 172 + * needs correcting. 173 + */ 167 174 struct ibmveth_buf_desc_fields { 175 + #ifdef __BIG_ENDIAN 168 176 u32 flags_len; 177 + u32 address; 178 + #else 179 + u32 address; 180 + u32 flags_len; 181 + #endif 169 182 #define IBMVETH_BUF_VALID 0x80000000 170 183 #define IBMVETH_BUF_TOGGLE 0x40000000 171 184 #define IBMVETH_BUF_NO_CSUM 0x02000000 172 185 #define IBMVETH_BUF_CSUM_GOOD 0x01000000 173 186 #define IBMVETH_BUF_LEN_MASK 0x00FFFFFF 174 - u32 address; 175 187 }; 176 188 177 189 union ibmveth_buf_desc { ··· 192 180 }; 193 181 194 182 struct ibmveth_rx_q_entry { 195 - u32 flags_off; 183 + __be32 flags_off; 196 184 #define IBMVETH_RXQ_TOGGLE 0x80000000 197 185 #define IBMVETH_RXQ_TOGGLE_SHIFT 31 198 186 #define IBMVETH_RXQ_VALID 0x40000000 ··· 200 188 #define IBMVETH_RXQ_CSUM_GOOD 0x01000000 201 189 #define IBMVETH_RXQ_OFF_MASK 0x0000FFFF 202 190 203 - u32 length; 191 + __be32 length; 192 + /* correlator is only used by the OS, no need to byte swap */ 204 193 u64 correlator; 205 194 }; 206 195