# _EMAC_Pkt Struct Reference
[EMAC Data Structures]

EMACObjects EMAC Objects. More...

`#include <csl_emac.h>`

## Data Fields

Uint32 | AppPrivate
struct _EMAC_Pkt * | pPrev
struct _EMAC_Pkt * | pNext
Uint8 * | pDataBuffer
Uint32 | BufferLen
Uint32 | Flags
Uint32 | ValidLen
Uint32 | DataOffset
Uint32 | PktChannel
Uint32 | PktLength
Uint32 | PktFrags

## Detailed Description

EMACObjects EMAC Objects.

EMAC_Pkt The packet structure defines the basic unit of memory used to hold data packets for the EMAC device.

A packet is comprised of one or more packet buffers. Each packet buffer contains a packet buffer header, and a pointer to the buffer data. The EMAC_Pkt structure defines the packet buffer header.

The pDataBuffer field points to the packet data. This is set when the buffer is allocated, and is not altered.

BufferLen holds the the total length of the data buffer that is used to store the packet (or packet fragment). This size is set by the entity that originally allocates the buffer, and is not altered.

The Flags field contains additional information about the packet

ValidLen holds the length of the valid data currently contained in the data buffer.

DataOffset is the byte offset from the start of the data buffer to the first byte of valid data. Thus (ValidLen+DataOffet)<=BufferLen.

Note that for receive buffer packets, the DataOffset field may be assigned before there is any valid data in the packet buffer. This allows the application to reserve space at the top of data buffer for private use. In all instances, the DataOffset field must be valid for all packets handled by EMAC.

The data portion of the packet buffer represents a packet or a fragment of a larger packet. This is determined by the Flags parameter. At the start of every packet, the SOP bit is set in Flags. If the EOP bit is also set, then the packet is not fragmented. Otherwise; the next packet structure pointed to by the pNext field will contain the next fragment in the packet. On either type of buffer, when the SOP bit is set in Flags, then the PktChannel, PktLength, and PktFrags fields must also be valid. These fields contain additional information about the packet.

The PktChannel field detetmines what channel the packet has arrived on, or what channel it should be transmitted on. The EMAC library supports only a single receive channel, but allows for up to eight transmit channels. Transmit channels can be treated as round-robin or priority queues.

The PktLength field holds the size of the entire packet. On single frag packets (both SOP and EOP set in BufFlags), PktLength and ValidLen will be equal.

The PktFrags field holds the number of fragments (EMAC_Pkt records) used to describe the packet. If more than 1 frag is present, the first record must have EMAC_PKT_FLAGS_SOP flag set, with corresponding fields validated. Each frag/record must be linked list using the pNext field, and the final frag/record must have EMAC_PKT_FLAGS_EOP flag set and pNext=0.

In systems where the packet resides in cacheable memory, the data buffer must start on a cache line boundary and be an even multiple of cache lines in size. The EMAC_Pkt header must not appear in the same cache line as the data portion of the packet. On multi-fragment packets, some packet fragments may reside in cacheable memory where others do not.

        <b> NOTE: It is up to the caller to assure that all packet buffers
        residing in cacheable memory are not currently stored in L1 or L2
        cache when passed to any EMAC function. </b>

Some of the packet Flags can only be set if the device is in the proper configuration to receive the corresponding frames. In order to enable these flags, the following modes must be set: RxCrc Flag : RXCRC Mode in EMAC_Config RxErr Flags : PASSERROR Mode in EMAC_Config RxCtl Flags : PASSCONTROL Mode in EMAC_Config RxPrm Flag : EMAC_RXFILTER_ALL in EMAC_setReceiveFilter()

## Field Documentation

Uint32 _EMAC_Pkt::AppPrivate

For use by the application

Uint32 _EMAC_Pkt::BufferLen

Physical Length of buffer (read only)

Uint32 _EMAC_Pkt::DataOffset

Byte offset to valid data

Uint32 _EMAC_Pkt::Flags

Packet Flags

Uint8* _EMAC_Pkt::pDataBuffer

Pointer to Data Buffer (read only)

Uint32 _EMAC_Pkt::PktChannel

Tx/Rx Channel/Priority 0-7 (SOP only)

Uint32 _EMAC_Pkt::PktFrags

No of frags in packet (SOP only) frag is EMAC_Pkt record-normally 1

Uint32 _EMAC_Pkt::PktLength

Length of Packet (SOP only) (same as ValidLen on single frag Pkt)

struct _EMAC_Pkt* _EMAC_Pkt::pNext

Next record

struct _EMAC_Pkt* _EMAC_Pkt::pPrev

Previous record

Uint32 _EMAC_Pkt::ValidLen

Length of valid data in buffer

The documentation for this struct was generated from the following file:

- csl_emac.h

Copyright 2012, Texas Instruments Incorporated