[vmxnet3] Avoid completely filling the TX descriptor ring
Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
1852803e46
commit
3f8da985aa
|
@ -92,19 +92,24 @@ static int vmxnet3_transmit ( struct net_device *netdev,
|
|||
struct io_buffer *iobuf ) {
|
||||
struct vmxnet3_nic *vmxnet = netdev_priv ( netdev );
|
||||
struct vmxnet3_tx_desc *tx_desc;
|
||||
unsigned int fill;
|
||||
unsigned int desc_idx;
|
||||
unsigned int generation;
|
||||
|
||||
/* Check that we have a free transmit descriptor */
|
||||
desc_idx = ( vmxnet->count.tx_prod % VMXNET3_NUM_TX_DESC );
|
||||
generation = ( ( vmxnet->count.tx_prod & VMXNET3_NUM_TX_DESC ) ?
|
||||
0 : cpu_to_le32 ( VMXNET3_TXF_GEN ) );
|
||||
if ( vmxnet->tx_iobuf[desc_idx] ) {
|
||||
fill = ( vmxnet->count.tx_prod - vmxnet->count.tx_cons );
|
||||
if ( fill >= VMXNET3_TX_FILL ) {
|
||||
DBGC ( vmxnet, "VMXNET3 %p out of transmit descriptors\n",
|
||||
vmxnet );
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
/* Locate transmit descriptor */
|
||||
desc_idx = ( vmxnet->count.tx_prod % VMXNET3_NUM_TX_DESC );
|
||||
generation = ( ( vmxnet->count.tx_prod & VMXNET3_NUM_TX_DESC ) ?
|
||||
0 : cpu_to_le32 ( VMXNET3_TXF_GEN ) );
|
||||
assert ( vmxnet->tx_iobuf[desc_idx] == NULL );
|
||||
|
||||
/* Increment producer counter */
|
||||
vmxnet->count.tx_prod++;
|
||||
|
||||
|
|
|
@ -493,6 +493,9 @@ struct vmxnet3_nic {
|
|||
/** MTU size */
|
||||
#define VMXNET3_MTU ( ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* FCS */ )
|
||||
|
||||
/** Transmit ring maximum fill level */
|
||||
#define VMXNET3_TX_FILL ( VMXNET3_NUM_TX_DESC - 1 )
|
||||
|
||||
/** Receive ring maximum fill level */
|
||||
#define VMXNET3_RX_FILL 8
|
||||
|
||||
|
|
Reference in New Issue