kernels/linux-2.4.0/drivers/net/wan/sdla_chdlc.c
/*============================================================================
 * Initialize Receive and Transmit Buffers.
 */
Initialize Receive and Transmit Buffers.
Initialize Receive and Transmit Buffers .
static void init_chdlc_tx_rx_buff( sdla_t* card, struct net_device *dev )
{
	CHDLC_MAILBOX_STRUCT* mb = card->mbox;
	CHDLC_TX_STATUS_EL_CFG_STRUCT *tx_config;
	CHDLC_RX_STATUS_EL_CFG_STRUCT *rx_config;
	char err;
	mb->buffer_length = 0;
	mb->command = READ_CHDLC_CONFIGURATION;
	err = sdla_exec(mb) ? mb->return_code : CMD_TIMEOUT;
	if(err != COMMAND_OK) {
		chdlc_error(card,err,mb);
		return;
	}
	if(card->hw.type == SDLA_S514) {
		tx_config = (CHDLC_TX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
                (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
                            ptr_CHDLC_Tx_stat_el_cfg_struct));
        	rx_config = (CHDLC_RX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
                (((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
                            ptr_CHDLC_Rx_stat_el_cfg_struct));
        	card->u.c.txbuf_base = (void *)(card->hw.dpmbase +
                tx_config->base_addr_Tx_status_elements);
        	card->u.c.txbuf_last = 
		(CHDLC_DATA_TX_STATUS_EL_STRUCT *)  
                card->u.c.txbuf_base +
		(tx_config->number_Tx_status_elements - 1);
        	card->u.c.rxbuf_base = (void *)(card->hw.dpmbase +
                rx_config->base_addr_Rx_status_elements);
        	card->u.c.rxbuf_last =
		(CHDLC_DATA_RX_STATUS_EL_STRUCT *)
                card->u.c.rxbuf_base +
		(rx_config->number_Rx_status_elements - 1);
        	card->u.c.txbuf = (void *)(card->hw.dpmbase +
                tx_config->next_Tx_status_element_to_use);
        	card->u.c.rxmb = (void *)(card->hw.dpmbase +
                rx_config->next_Rx_status_element_to_use);
	}
        else {
                tx_config = (CHDLC_TX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
			(((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
			ptr_CHDLC_Tx_stat_el_cfg_struct % SDLA_WINDOWSIZE));
                rx_config = (CHDLC_RX_STATUS_EL_CFG_STRUCT *)(card->hw.dpmbase +
			(((CHDLC_CONFIGURATION_STRUCT *)mb->data)->
			ptr_CHDLC_Rx_stat_el_cfg_struct % SDLA_WINDOWSIZE));
                card->u.c.txbuf_base = (void *)(card->hw.dpmbase +
		(tx_config->base_addr_Tx_status_elements % SDLA_WINDOWSIZE));
                card->u.c.txbuf_last =
		(CHDLC_DATA_TX_STATUS_EL_STRUCT *)card->u.c.txbuf_base
		+ (tx_config->number_Tx_status_elements - 1);
                card->u.c.rxbuf_base = (void *)(card->hw.dpmbase +
		(rx_config->base_addr_Rx_status_elements % SDLA_WINDOWSIZE));
                card->u.c.rxbuf_last = 
		(CHDLC_DATA_RX_STATUS_EL_STRUCT *)card->u.c.rxbuf_base
		+ (rx_config->number_Rx_status_elements - 1);
                card->u.c.txbuf = (void *)(card->hw.dpmbase +
		(tx_config->next_Tx_status_element_to_use % SDLA_WINDOWSIZE));
                card->u.c.rxmb = (void *)(card->hw.dpmbase +
		(rx_config->next_Rx_status_element_to_use % SDLA_WINDOWSIZE));
        }
        card->u.c.rx_base = rx_config->base_addr_Rx_buffer;
        card->u.c.rx_top  = rx_config->end_addr_Rx_buffer;
}
static void init_chdlc_tx_rx_buff ( sdla_t * card , struct net_device * dev ) { CHDLC_MAILBOX_STRUCT * mb = card -> mbox ; CHDLC_TX_STATUS_EL_CFG_STRUCT * tx_config ; CHDLC_RX_STATUS_EL_CFG_STRUCT * rx_config ; char err ; mb -> buffer_length = 0 ; mb -> command = READ_CHDLC_CONFIGURATION ; err = sdla_exec ( mb ) ? mb -> return_code : CMD_TIMEOUT ; if ( err != COMMAND_OK ) { chdlc_error ( card , err , mb ) ; return ; } if ( card -> hw . type == SDLA_S514 ) { tx_config = ( CHDLC_TX_STATUS_EL_CFG_STRUCT * ) ( card -> hw . dpmbase + ( ( ( CHDLC_CONFIGURATION_STRUCT * ) mb -> data ) -> ptr_CHDLC_Tx_stat_el_cfg_struct ) ) ; rx_config = ( CHDLC_RX_STATUS_EL_CFG_STRUCT * ) ( card -> hw . dpmbase + ( ( ( CHDLC_CONFIGURATION_STRUCT * ) mb -> data ) -> ptr_CHDLC_Rx_stat_el_cfg_struct ) ) ; card -> u . c . txbuf_base = ( void * ) ( card -> hw . dpmbase + tx_config -> base_addr_Tx_status_elements ) ; card -> u . c . txbuf_last = ( CHDLC_DATA_TX_STATUS_EL_STRUCT * ) card -> u . c . txbuf_base + ( tx_config -> number_Tx_status_elements - 1 ) ; card -> u . c . rxbuf_base = ( void * ) ( card -> hw . dpmbase + rx_config -> base_addr_Rx_status_elements ) ; card -> u . c . rxbuf_last = ( CHDLC_DATA_RX_STATUS_EL_STRUCT * ) card -> u . c . rxbuf_base + ( rx_config -> number_Rx_status_elements - 1 ) ; card -> u . c . txbuf = ( void * ) ( card -> hw . dpmbase + tx_config -> next_Tx_status_element_to_use ) ; card -> u . c . rxmb = ( void * ) ( card -> hw . dpmbase + rx_config -> next_Rx_status_element_to_use ) ; } else { tx_config = ( CHDLC_TX_STATUS_EL_CFG_STRUCT * ) ( card -> hw . dpmbase + ( ( ( CHDLC_CONFIGURATION_STRUCT * ) mb -> data ) -> ptr_CHDLC_Tx_stat_el_cfg_struct % SDLA_WINDOWSIZE ) ) ; rx_config = ( CHDLC_RX_STATUS_EL_CFG_STRUCT * ) ( card -> hw . dpmbase + ( ( ( CHDLC_CONFIGURATION_STRUCT * ) mb -> data ) -> ptr_CHDLC_Rx_stat_el_cfg_struct % SDLA_WINDOWSIZE ) ) ; card -> u . c . txbuf_base = ( void * ) ( card -> hw . dpmbase + ( tx_config -> base_addr_Tx_status_elements % SDLA_WINDOWSIZE ) ) ; card -> u . c . txbuf_last = ( CHDLC_DATA_TX_STATUS_EL_STRUCT * ) card -> u . c . txbuf_base + ( tx_config -> number_Tx_status_elements - 1 ) ; card -> u . c . rxbuf_base = ( void * ) ( card -> hw . dpmbase + ( rx_config -> base_addr_Rx_status_elements % SDLA_WINDOWSIZE ) ) ; card -> u . c . rxbuf_last = ( CHDLC_DATA_RX_STATUS_EL_STRUCT * ) card -> u . c . rxbuf_base + ( rx_config -> number_Rx_status_elements - 1 ) ; card -> u . c . txbuf = ( void * ) ( card -> hw . dpmbase + ( tx_config -> next_Tx_status_element_to_use % SDLA_WINDOWSIZE ) ) ; card -> u . c . rxmb = ( void * ) ( card -> hw . dpmbase + ( rx_config -> next_Rx_status_element_to_use % SDLA_WINDOWSIZE ) ) ; } card -> u . c . rx_base = rx_config -> base_addr_Rx_buffer ; card -> u . c . rx_top = rx_config -> end_addr_Rx_buffer ; }
Initialize Receive and Transmit Buffers.
Initialize Receive and Transmit Buffers .
/* Setup Head and Tails for buffers */ /* Set up next pointer to be used */ /* Setup Head and Tails for buffers */ /* Set up next pointer to be used */ /* Setup Actual Buffer Start and end addresses */