Jump to main content

##

# 1.2.5.2.1 _tag_MAC_DATA_SEGMENT Structure

## C

    struct _tag_MAC_DATA_SEGMENT {
    struct _tag_MAC_DATA_SEGMENT* next;
    uint8_t* segLoad;
    uint16_t segLen;
    uint16_t segSize;
    uint16_t segFlags;
    uint16_t segLoadOffset;
    uint16_t segAllocSize;
    uint8_t segClientData[2];
    };

## Description

TCPIP MAC Data Segment.

Structure of a segment buffer transferred with the MAC. A MAC TX or RX packet can consist of multiple data segments. On TX the MAC has to be able to transmit packets that span multiple data segments. On RX of a network frame the MAC may have to use multiple segments to construct a packet. (For performance reasons, a contiguous MAC packet, with just one segment, if possible, is preferred).

## Members

Members | Description
--- | ---
next | Multi-segment support, next segment in the chain.
segLoad | Pointer to segment data payload Points to TCPIP_MAC_SEGMENT_PAYLOAD::segmentPayload. It specifies the address of the 1st payload byte. If the processor has cache, then it is always cache line size aligned. Otherwise is 32 bits aligned.
segLen | Segment payload size; TX: Number of bytes from this segment that has to be transmitted. This is the total number of bytes including the Ethernet header but not the FCS (that should be added by the driver) RX: Number of payload bytes in the segment. The MAC driver subtracts the FCS and Ethernet header length before handing over the packet to the stack. Then the segLen field is updated by each stack layer in turn.
segSize | Segment allocated total usable size. This does not include the segLoadOffset (see below).
segFlags | TCPIP_MAC_SEGMENT_FLAGS segment flags: TCPIP_MAC_SEG_FLAG_STATIC, TCPIP_MAC_SEG_FLAG_RX, TCPIP_MAC_SEG_FLAG_RX, TCPIP_MAC_SEG_FLAG_RX_STICKY.
segLoadOffset | Offset in bytes between the address pointed by segLoad and the address where the segment buffer starts/was allocated. It specifies the gap space at the beginning of the TCPIP_MAC_SEGMENT_PAYLOAD before the segmentPayload begins. segLoadOffset == sizeof(TCPIP_MAC_SEGMENT_PAYLOAD::segmentPktPtr) + sizeof(TCPIP_MAC_SEGMENT_PAYLOAD::segmentDataGap). This currently is greater or equal than 8 bytes depending on the MAC drivers that are part of the build! See TCPIP_MAC_DATA_SEGMENT. For implementations that may work outside the Harmony TCP/IP stack it is up to the MAC to check that the value of this offset is enforced.
segAllocSize | The size this segment payload allocation. Debug/trace purposes.
segClientData[2] | Additional client segment data. Ignored by the MAC driver.

## Remarks

See notes for the segLoadOffset member. On 32-bit machines, the segment payload is allocated so that it is always cache line size aligned and its size is 32-bits multiple.