mirror of
https://github.com/ipxe/ipxe
synced 2026-01-30 16:40:24 +03:00
[gve] Remove separate concept of "packet descriptor"
The Linux driver occasionally uses the terminology "packet descriptor" to refer to the portion of the descriptor excluding the buffer address. This is not a helpful separation, and merely adds complexity. Simplify the code by removing this artifical separation. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -1283,19 +1283,19 @@ static int gve_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
|
|||||||
/* Populate descriptor */
|
/* Populate descriptor */
|
||||||
index = ( tx->prod++ & ( tx->count - 1 ) );
|
index = ( tx->prod++ & ( tx->count - 1 ) );
|
||||||
desc = &tx->desc.tx[index];
|
desc = &tx->desc.tx[index];
|
||||||
memset ( &desc->pkt, 0, sizeof ( desc->pkt ) );
|
|
||||||
if ( offset ) {
|
if ( offset ) {
|
||||||
desc->pkt.type = GVE_TX_TYPE_CONT;
|
desc->type = GVE_TX_TYPE_CONT;
|
||||||
|
desc->count = 0;
|
||||||
|
desc->total = 0;
|
||||||
} else {
|
} else {
|
||||||
desc->pkt.type = GVE_TX_TYPE_START;
|
desc->type = GVE_TX_TYPE_START;
|
||||||
desc->pkt.count = count;
|
desc->count = count;
|
||||||
desc->pkt.total = cpu_to_be16 ( len );
|
desc->total = cpu_to_be16 ( len );
|
||||||
}
|
}
|
||||||
desc->pkt.len = cpu_to_be16 ( frag_len );
|
desc->len = cpu_to_be16 ( frag_len );
|
||||||
DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at "
|
DBGC2 ( gve, "GVE %p TX %#04x %#02x:%#02x len %#04x/%#04x at "
|
||||||
"%#08zx\n", gve, index, desc->pkt.type,
|
"%#08zx\n", gve, index, desc->type, desc->count,
|
||||||
desc->pkt.count, be16_to_cpu ( desc->pkt.len ),
|
be16_to_cpu ( desc->len ), be16_to_cpu ( desc->total ),
|
||||||
be16_to_cpu ( desc->pkt.total ),
|
|
||||||
gve_address ( tx, index ) );
|
gve_address ( tx, index ) );
|
||||||
}
|
}
|
||||||
assert ( ( tx->prod - tx->cons ) <= tx->fill );
|
assert ( ( tx->prod - tx->cons ) <= tx->fill );
|
||||||
@@ -1363,22 +1363,22 @@ static void gve_poll_rx ( struct net_device *netdev ) {
|
|||||||
cmplt = &rx->cmplt.rx[index];
|
cmplt = &rx->cmplt.rx[index];
|
||||||
|
|
||||||
/* Check sequence number */
|
/* Check sequence number */
|
||||||
if ( ( cmplt->pkt.seq & GVE_RX_SEQ_MASK ) != seq )
|
if ( ( cmplt->seq & GVE_RX_SEQ_MASK ) != seq )
|
||||||
break;
|
break;
|
||||||
seq = gve_next ( seq );
|
seq = gve_next ( seq );
|
||||||
|
|
||||||
/* Parse completion */
|
/* Parse completion */
|
||||||
len = be16_to_cpu ( cmplt->pkt.len );
|
len = be16_to_cpu ( cmplt->len );
|
||||||
DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at "
|
DBGC2 ( gve, "GVE %p RX %#04x %#02x:%#02x len %#04zx at "
|
||||||
"%#08zx\n", gve, index, cmplt->pkt.seq,
|
"%#08zx\n", gve, index, cmplt->seq, cmplt->flags,
|
||||||
cmplt->pkt.flags, len, gve_address ( rx, index ) );
|
len, gve_address ( rx, index ) );
|
||||||
|
|
||||||
/* Accumulate a complete packet */
|
/* Accumulate a complete packet */
|
||||||
if ( cmplt->pkt.flags & GVE_RXF_ERROR ) {
|
if ( cmplt->flags & GVE_RXF_ERROR ) {
|
||||||
total = 0;
|
total = 0;
|
||||||
} else {
|
} else {
|
||||||
total += len;
|
total += len;
|
||||||
if ( cmplt->pkt.flags & GVE_RXF_MORE )
|
if ( cmplt->flags & GVE_RXF_MORE )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gve->seq = seq;
|
gve->seq = seq;
|
||||||
@@ -1393,7 +1393,7 @@ static void gve_poll_rx ( struct net_device *netdev ) {
|
|||||||
|
|
||||||
/* Copy data */
|
/* Copy data */
|
||||||
if ( iobuf ) {
|
if ( iobuf ) {
|
||||||
len = be16_to_cpu ( cmplt->pkt.len );
|
len = be16_to_cpu ( cmplt->len );
|
||||||
memcpy ( iob_put ( iobuf, len ),
|
memcpy ( iob_put ( iobuf, len ),
|
||||||
gve_buffer ( rx, rx->cons ), len );
|
gve_buffer ( rx, rx->cons ), len );
|
||||||
}
|
}
|
||||||
@@ -1406,7 +1406,7 @@ static void gve_poll_rx ( struct net_device *netdev ) {
|
|||||||
iob_pull ( iobuf, GVE_RX_PAD );
|
iob_pull ( iobuf, GVE_RX_PAD );
|
||||||
netdev_rx ( netdev, iobuf );
|
netdev_rx ( netdev, iobuf );
|
||||||
} else {
|
} else {
|
||||||
rc = ( ( cmplt->pkt.flags & GVE_RXF_ERROR ) ?
|
rc = ( ( cmplt->flags & GVE_RXF_ERROR ) ?
|
||||||
-EIO : -ENOMEM );
|
-EIO : -ENOMEM );
|
||||||
netdev_rx_err ( netdev, NULL, rc );
|
netdev_rx_err ( netdev, NULL, rc );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,8 +524,8 @@ struct gve_buffer {
|
|||||||
uint64_t addr;
|
uint64_t addr;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/** A transmit packet descriptor */
|
/** A transmit descriptor */
|
||||||
struct gve_tx_packet {
|
struct gve_tx_descriptor {
|
||||||
/** Type */
|
/** Type */
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
/** Reserved */
|
/** Reserved */
|
||||||
@@ -536,12 +536,6 @@ struct gve_tx_packet {
|
|||||||
uint16_t total;
|
uint16_t total;
|
||||||
/** Length of this descriptor */
|
/** Length of this descriptor */
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
} __attribute__ (( packed ));
|
|
||||||
|
|
||||||
/** A transmit descriptor */
|
|
||||||
struct gve_tx_descriptor {
|
|
||||||
/** Packet descriptor */
|
|
||||||
struct gve_tx_packet pkt;
|
|
||||||
/** Buffer descriptor */
|
/** Buffer descriptor */
|
||||||
struct gve_buffer buf;
|
struct gve_buffer buf;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
@@ -573,16 +567,6 @@ struct gve_rx_descriptor {
|
|||||||
struct gve_buffer buf;
|
struct gve_buffer buf;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/** A receive packet descriptor */
|
|
||||||
struct gve_rx_packet {
|
|
||||||
/** Length */
|
|
||||||
uint16_t len;
|
|
||||||
/** Flags */
|
|
||||||
uint8_t flags;
|
|
||||||
/** Sequence number */
|
|
||||||
uint8_t seq;
|
|
||||||
} __attribute__ (( packed ));
|
|
||||||
|
|
||||||
/** Receive error */
|
/** Receive error */
|
||||||
#define GVE_RXF_ERROR 0x08
|
#define GVE_RXF_ERROR 0x08
|
||||||
|
|
||||||
@@ -596,8 +580,12 @@ struct gve_rx_packet {
|
|||||||
struct gve_rx_completion {
|
struct gve_rx_completion {
|
||||||
/** Reserved */
|
/** Reserved */
|
||||||
uint8_t reserved[60];
|
uint8_t reserved[60];
|
||||||
/** Packet descriptor */
|
/** Length */
|
||||||
struct gve_rx_packet pkt;
|
uint16_t len;
|
||||||
|
/** Flags */
|
||||||
|
uint8_t flags;
|
||||||
|
/** Sequence number */
|
||||||
|
uint8_t seq;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/** Padding at the start of all received packets */
|
/** Padding at the start of all received packets */
|
||||||
|
|||||||
Reference in New Issue
Block a user