diff options
Diffstat (limited to 'src/drivers/net/exanic.c')
| -rw-r--r-- | src/drivers/net/exanic.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index aaa6a28a1..a36f7a774 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -395,7 +395,7 @@ static int exanic_open ( struct net_device *netdev ) { } /* Reset receive region contents */ - memset_user ( port->rx, 0, 0xff, EXANIC_RX_LEN ); + memset ( port->rx, 0xff, EXANIC_RX_LEN ); /* Reset transmit feedback region */ *(port->txf) = 0; @@ -406,7 +406,7 @@ static int exanic_open ( struct net_device *netdev ) { port->rx_cons = 0; /* Map receive region */ - exanic_write_base ( phys_to_bus ( user_to_phys ( port->rx, 0 ) ), + exanic_write_base ( phys_to_bus ( virt_to_phys ( port->rx ) ), ( port->regs + EXANIC_PORT_RX_BASE ) ); /* Enable promiscuous mode */ @@ -540,26 +540,23 @@ static void exanic_poll_tx ( struct net_device *netdev ) { static void exanic_poll_rx ( struct net_device *netdev ) { struct exanic_port *port = netdev->priv; struct exanic_rx_chunk *rx; - struct exanic_rx_descriptor desc; + unsigned int index; uint8_t current; uint8_t previous; - size_t offset; size_t len; for ( ; ; port->rx_cons++ ) { /* Fetch descriptor */ - offset = ( ( port->rx_cons * sizeof ( *rx ) ) % EXANIC_RX_LEN ); - copy_from_user ( &desc, port->rx, - ( offset + offsetof ( typeof ( *rx ), desc ) ), - sizeof ( desc ) ); + index = ( port->rx_cons % EXANIC_RX_COUNT ); + rx = &port->rx[index]; /* Calculate generation */ - current = ( port->rx_cons / ( EXANIC_RX_LEN / sizeof ( *rx ) )); + current = ( port->rx_cons / EXANIC_RX_COUNT ); previous = ( current - 1 ); /* Do nothing if no chunk is ready */ - if ( desc.generation == previous ) + if ( rx->desc.generation == previous ) break; /* Allocate I/O buffer if needed */ @@ -573,14 +570,12 @@ static void exanic_poll_rx ( struct net_device *netdev ) { } /* Calculate chunk length */ - len = ( desc.len ? desc.len : sizeof ( rx->data ) ); + len = ( rx->desc.len ? rx->desc.len : sizeof ( rx->data ) ); /* Append data to I/O buffer */ if ( len <= iob_tailroom ( port->rx_iobuf ) ) { - copy_from_user ( iob_put ( port->rx_iobuf, len ), - port->rx, - ( offset + offsetof ( typeof ( *rx ), - data ) ), len ); + memcpy ( iob_put ( port->rx_iobuf, len ), + rx->data, len ); } else { DBGC ( port, "EXANIC %s RX too large\n", netdev->name ); @@ -589,23 +584,19 @@ static void exanic_poll_rx ( struct net_device *netdev ) { /* Check for overrun */ rmb(); - copy_from_user ( &desc.generation, port->rx, - ( offset + offsetof ( typeof ( *rx ), - desc.generation ) ), - sizeof ( desc.generation ) ); - if ( desc.generation != current ) { + if ( rx->desc.generation != current ) { DBGC ( port, "EXANIC %s RX overrun\n", netdev->name ); port->rx_rc = -ENOBUFS; continue; } /* Wait for end of packet */ - if ( ! desc.len ) + if ( ! rx->desc.len ) continue; /* Check for receive errors */ - if ( desc.status & EXANIC_STATUS_ERROR_MASK ) { - port->rx_rc = -EIO_STATUS ( desc.status ); + if ( rx->desc.status & EXANIC_STATUS_ERROR_MASK ) { + port->rx_rc = -EIO_STATUS ( rx->desc.status ); DBGC ( port, "EXANIC %s RX %04x error: %s\n", netdev->name, port->rx_cons, strerror ( port->rx_rc ) ); @@ -729,8 +720,8 @@ static int exanic_probe_port ( struct exanic *exanic, struct device *dev, DBGC ( port, "EXANIC %s port %d TX [%#05zx,%#05zx) TXF %#02x RX " "[%#lx,%#lx)\n", netdev->name, index, port->tx_offset, ( port->tx_offset + tx_len ), port->txf_slot, - user_to_phys ( port->rx, 0 ), - user_to_phys ( port->rx, EXANIC_RX_LEN ) ); + virt_to_phys ( port->rx ), + ( virt_to_phys ( port->rx ) + EXANIC_RX_LEN ) ); /* Set initial link state */ exanic_check_link ( netdev ); |
