more indentation and styling done
This commit is contained in:
parent
bfa322bb19
commit
621f6fb503
|
@ -106,11 +106,13 @@ struct natsemi_nic {
|
|||
unsigned short rx_cur;
|
||||
struct natsemi_tx tx[TX_RING_SIZE];
|
||||
struct natsemi_rx rx[NUM_RX_DESC];
|
||||
|
||||
/* need to add iobuf as we cannot free iobuf->data in close without this
|
||||
* alternatively substracting sizeof(head) and sizeof(list_head) can also
|
||||
* give the same.
|
||||
*/
|
||||
struct io_buffer *iobuf[NUM_RX_DESC];
|
||||
|
||||
/* netdev_tx_complete needs pointer to the iobuf of the data so as to free
|
||||
* it from the memory.
|
||||
*/
|
||||
|
@ -154,6 +156,7 @@ enum register_offsets {
|
|||
PhyStatus = 0xC0,
|
||||
MIntrCtrl = 0xC4,
|
||||
MIntrStatus = 0xC8,
|
||||
|
||||
/* These are from the spec, around page 78... on a separate table.
|
||||
*/
|
||||
PGSEL = 0xCC,
|
||||
|
@ -302,6 +305,7 @@ static struct nvo_fragment nat_nvo_fragments[] = {
|
|||
static void nat_reset ( struct natsemi_nic *nat ) {
|
||||
|
||||
int i;
|
||||
|
||||
/* Reset chip
|
||||
*/
|
||||
outl ( ChipReset, nat->ioaddr + ChipCmd );
|
||||
|
@ -415,6 +419,7 @@ static int nat_open ( struct net_device *netdev ) {
|
|||
return 0;
|
||||
|
||||
memory_alloc_err:
|
||||
|
||||
/* this block frees the previously allocated buffers
|
||||
* if memory for all the buffers is not available
|
||||
*/
|
||||
|
@ -434,6 +439,7 @@ memory_alloc_err:
|
|||
static void nat_close ( struct net_device *netdev ) {
|
||||
struct natsemi_nic *nat = netdev->priv;
|
||||
int i;
|
||||
|
||||
/* Reset the hardware to disable everything in one go
|
||||
*/
|
||||
nat_reset ( nat );
|
||||
|
@ -478,6 +484,7 @@ static int nat_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
|
|||
|
||||
nat->tx[nat->tx_cur].bufptr = virt_to_bus ( iobuf->data );
|
||||
nat->tx[nat->tx_cur].cmdsts = iob_len ( iobuf ) | OWN;
|
||||
|
||||
/* increment the circular buffer pointer to the next buffer location
|
||||
*/
|
||||
nat->tx_cur = ( nat->tx_cur + 1 ) % TX_RING_SIZE;
|
||||
|
@ -524,6 +531,7 @@ static void nat_poll ( struct net_device *netdev) {
|
|||
*/
|
||||
if ( status & OWN )
|
||||
break;
|
||||
|
||||
/* Check if any errors in transmission
|
||||
*/
|
||||
if (! ( status & DescPktOK ) ) {
|
||||
|
@ -534,6 +542,7 @@ static void nat_poll ( struct net_device *netdev) {
|
|||
DBG ( "Success in transmitting Packet\n" );
|
||||
netdev_tx_complete ( netdev,nat->tx_iobuf[nat->tx_dirty] );
|
||||
}
|
||||
|
||||
/* setting cmdsts zero, indicating that it can be reused
|
||||
*/
|
||||
nat->tx[nat->tx_dirty].cmdsts = 0;
|
||||
|
@ -546,6 +555,7 @@ static void nat_poll ( struct net_device *netdev) {
|
|||
rx_status = (unsigned int) nat->rx[nat->rx_cur].cmdsts;
|
||||
while ( ( rx_status & OWN ) ) {
|
||||
rx_len = ( rx_status & DSIZE ) - CRC_SIZE;
|
||||
|
||||
/*check for the corrupt packet
|
||||
*/
|
||||
if ( ( rx_status & ( DescMore|DescPktOK|RxTooLong ) ) != DescPktOK) {
|
||||
|
@ -555,6 +565,7 @@ static void nat_poll ( struct net_device *netdev) {
|
|||
netdev_rx_err ( netdev,NULL,-EINVAL );
|
||||
} else {
|
||||
rx_iob = alloc_iob ( rx_len );
|
||||
|
||||
if ( !rx_iob )
|
||||
/* leave packet for next call to poll
|
||||
*/
|
||||
|
@ -562,6 +573,7 @@ static void nat_poll ( struct net_device *netdev) {
|
|||
memcpy ( iob_put ( rx_iob,rx_len ),
|
||||
nat->iobuf[nat->rx_cur]->data,rx_len );
|
||||
DBG ( "received packet\n" );
|
||||
|
||||
/* add to the receive queue.
|
||||
*/
|
||||
netdev_rx ( netdev,rx_iob );
|
||||
|
@ -571,6 +583,7 @@ static void nat_poll ( struct net_device *netdev) {
|
|||
rx_status = nat->rx[nat->rx_cur].cmdsts;
|
||||
}
|
||||
end:
|
||||
|
||||
/* re-enable the potentially idle receive state machine
|
||||
*/
|
||||
outl ( RxOn, nat->ioaddr + ChipCmd );
|
||||
|
@ -643,6 +656,7 @@ static int nat_probe ( struct pci_device *pci,
|
|||
nat_init_eeprom ( nat );
|
||||
nvs_read ( &nat->eeprom.nvs, EE_MAC-1, prev_bytes, 1 );
|
||||
nvs_read ( &nat->eeprom.nvs, EE_MAC, ll_addr_encoded, ETH_ALEN );
|
||||
|
||||
/* decoding the MAC address read from NVS
|
||||
* and save it in netdev->ll_addr
|
||||
*/
|
||||
|
@ -661,9 +675,11 @@ static int nat_probe ( struct pci_device *pci,
|
|||
return 0;
|
||||
|
||||
err_register_netdev:
|
||||
|
||||
/* Disable NIC
|
||||
*/
|
||||
nat_reset ( nat );
|
||||
|
||||
/* Free net device
|
||||
*/
|
||||
netdev_put ( netdev );
|
||||
|
|
Reference in New Issue