1
1

btl/usnic: pack a wire data struct

Might as well save a few bytes when sending this struct across the
network via the __opal_attribute_packed__ attribute.

That being said, also re-order the elements in this struct so that
there's no holes to begin with.  Do this so that the compiler/runtime
won't effect (slow) unaligned reads/writes because of the
__opal_attribute_packed__ attribute.

The "packed" attribute is really more about defensive programming
(e.g., if we make a mistake and have a hole, "packed" will remove it
for us).

*** Do not bring this commit back to existing/already-released release
branches: it will cause incompatibility, since it effectively changes
the usNIC BTL wire protocol.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Этот коммит содержится в:
Jeff Squyres 2019-10-04 12:09:13 -07:00
родитель b774b47428
Коммит f3429d7a44

Просмотреть файл

@ -138,18 +138,24 @@ typedef struct {
the length of the packet to meet a minimum size */
uint16_t payload_len;
/* If this is an emulated PUT, store at this address on receiver */
char *put_addr;
/* Type of BTL header (see enum, above) */
uint8_t payload_type;
/* true if there is piggy-backed ACK */
uint8_t ack_present;
/* This field is ordered here so that we have no holes in the
struct. Technically this doesn't matter, because we're using
the __packed__ attribute (so there will be no holes anyway),
but ordering things nicely in the struct prevents the need for
unaligned reads/writes when using _packed__. */
/* If this is an emulated PUT, store at this address on
receiver */
char *put_addr;
/* tag for upper layer */
mca_btl_base_tag_t tag;
} opal_btl_usnic_btl_header_t;
} __opal_attribute_packed__ opal_btl_usnic_btl_header_t;
/**
* BTL header for a chunk of a fragment