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++;
/** 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