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