diff options
author | 2010-10-18 16:18:48 +0000 | |
---|---|---|
committer | 2010-10-18 16:18:48 +0000 | |
commit | 6c737afc7574107d351d5344e1372e3116fc48eb (patch) | |
tree | 9b9514fb1ac6bc9d4e588be6c6d5a0c33531c14f | |
parent | remove v2.0 initialization values for the Osprey. (diff) | |
download | wireguard-openbsd-6c737afc7574107d351d5344e1372e3116fc48eb.tar.xz wireguard-openbsd-6c737afc7574107d351d5344e1372e3116fc48eb.zip |
Add __attribute__((aligned(4))) to __packed Tx/Rx descriptors.
This makes gcc generate much more efficient code on architectures
with strong alignment constraints (like sparc64).
We use __packed to tell the compiler to not insert padding between
fields but the start of the descriptors is always 32-bit aligned.
When __packed is used, gcc assumes worst case scenario and generates
complicated code to prevent unaligned accesses.
Inspired by a similar change to ath9k.
Tested on sparc64.
For the record, example to set a field to 1 on a sparc64:
without __attribute__((aligned(4))):
ldub [%g2], %g1
and %g1, 0, %g1
stb %g1, [%g2]
ldub [%g2+1], %g1
and %g1, 0, %g1
stb %g1, [%g2+1]
ldub [%g2+2], %g1
and %g1, 0, %g1
stb %g1, [%g2+2]
ldub [%g2+3], %g1
and %g1, 0, %g1
or %g1, 1, %g1
stb %g1, [%g2+3]
with __attribute__((aligned(4))):
mov 1, %g1
st %g1, [%g2]
-rw-r--r-- | sys/dev/ic/ar5008reg.h | 6 | ||||
-rw-r--r-- | sys/dev/ic/ar9003reg.h | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/sys/dev/ic/ar5008reg.h b/sys/dev/ic/ar5008reg.h index 9c9caf27c94..62d7c1b53ca 100644 --- a/sys/dev/ic/ar5008reg.h +++ b/sys/dev/ic/ar5008reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5008reg.h,v 1.1 2010/05/10 17:44:21 damien Exp $ */ +/* $OpenBSD: ar5008reg.h,v 1.2 2010/10/18 16:18:48 damien Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -685,7 +685,7 @@ struct ar_tx_desc { * not cross a 4KB boundary. */ uint32_t pad[8]; -} __packed; +} __packed __attribute__((aligned(4))); /* Bits for ds_ctl0. */ #define AR_TXC0_FRAME_LEN_M 0x00000fff @@ -858,7 +858,7 @@ struct ar_rx_desc { * not cross a 4KB boundary. */ uint32_t pad[3]; -} __packed; +} __packed __attribute__((aligned(4))); /* Bits for ds_ctl1. */ #define AR_RXC1_BUF_LEN_M 0x00000fff diff --git a/sys/dev/ic/ar9003reg.h b/sys/dev/ic/ar9003reg.h index 4f2d0bab88e..03be390db74 100644 --- a/sys/dev/ic/ar9003reg.h +++ b/sys/dev/ic/ar9003reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ar9003reg.h,v 1.3 2010/06/21 19:54:28 damien Exp $ */ +/* $OpenBSD: ar9003reg.h,v 1.4 2010/10/18 16:18:48 damien Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -880,7 +880,7 @@ struct ar_tx_desc { * not cross a 4KB boundary. */ uint32_t pad[9]; -} __packed; +} __packed __attribute__((aligned(4))); /* Bits for ds_info. */ #define AR_TXI_DESC_NDWORDS_M 0x000000ff @@ -1020,7 +1020,7 @@ struct ar_tx_status { uint32_t ds_status6; uint32_t ds_status7; uint32_t ds_status8; -} __packed; +} __packed __attribute__((aligned(4))); /* Bits for ds_status3. */ #define AR_TXS3_EXCESSIVE_RETRIES 0x00000002 @@ -1058,7 +1058,7 @@ struct ar_rx_status { uint32_t ds_status9; uint32_t ds_status10; uint32_t ds_status11; -} __packed; +} __packed __attribute__((aligned(4))); /* Bits for ds_info. */ #define AR_RXI_CTRL_STAT 0x00004000 |