Menu

#1 rx BDs buffer initialization bug (maybe?)

open
nobody
None
5
2004-11-04
2004-11-04
doublelee
No

If only 1 channel is needed for MPC860/862 system,
UTOPIA_LOG2_MAX_CHANNELS can be set with zero
(default value is 7 for 128 channels), in case of saving
external memory.
In this case, the total numbers of BDs for VC Rx ring
could be comparitable to numbers of BDs for Raw Cell
Queue Rx ring. The current mpool round up initialization
method for rx_bd_pool maybe fail under this situation:

Example 1 (default setting, OK):
#define UTOPIA_RX_RING_SIZE 16
#define UTOPIA_RCQ_RX_RING_SIZE 8
#define UTOPIA_NUM_RX_BDS
((UTOPIA_MAX_CHANNELS * UTOPIA_RX_RING_SIZE) +
(UTOPIA_RCQ_RX_RING_SIZE))

so UTOPIA_NUM_RX_BDS means ((1 * 16) + 8 ) = 24;
In mpc860sar_init_dev_data();
num_bytes = num_rx_bds * sizeof(atm_cbd_t) = 24 * 12
= 288;
ROUNDUP_PWR2(num_bytes);
then num_bytes will eqaul to 512;
and mpool_init(&(data->rx_bd_pool), (unchar *)data-
>rbdbase, 512);
512-byte memory will be allocated both for ordinary rx
bds and raw cell queue.

And In later mpool_alloc(&(dev_data->rx_bd_pool), chan-
>rx_ring_size * sizeof(atm_cbd_t));
raw cell queue will request 8 * 12 = 96 byte memory, in
mpool_alloc(), 96 will be rounded up to 128;
ordinary rx bds will request 16 * 12 = 192 byte memory,
in mpool_alloc(), 192 will be rounded up to 256;

And 128 + 256 < 512 (bytes of mpool init)
It's OK.

Example 2 : (increase the number of BDs in per-VC Rx
ring to 32)
#define UTOPIA_RX_RING_SIZE 32
#define UTOPIA_RCQ_RX_RING_SIZE 8
#define UTOPIA_NUM_RX_BDS
((UTOPIA_MAX_CHANNELS * UTOPIA_RX_RING_SIZE) +
(UTOPIA_RCQ_RX_RING_SIZE))

so UTOPIA_NUM_RX_BDS means ((1 * 32) + 8 ) = 40;
In mpc860sar_init_dev_data();
num_bytes = num_rx_bds * sizeof(atm_cbd_t) = 40 * 12
= 480;
ROUNDUP_PWR2(num_bytes);
then num_bytes will eqaul to 512;
and mpool_init(&(data->rx_bd_pool), (unchar *)data-
>rbdbase, 512);
512-byte memory will be allocated both for ordinary rx
bds and raw cell queue.

And In later mpool_alloc(&(dev_data->rx_bd_pool), chan-
>rx_ring_size * sizeof(atm_cbd_t));
raw cell queue will request 8 * 12 = 96 byte memory, in
mpool_alloc(), 96 will be rounded up to 128;
ordinary rx bds will request 32 * 12 = 384 byte memory,
in mpool_alloc(), 384 will be rounded up to 512;

But 128 + 512 > 512 (bytes of mpool init)
ordinary rx bds cannot allocate memory from mpool.
Failed!!!

Way to resolve this bug:
current code in mpc860sar_init_dev_data(){
...
num_bytes = num_rx_bds * sizeof(atm_cbd_t);
ROUNDUP_PWR2(num_bytes);
mpool_init(&(data->rx_bd_pool), (unchar *)data-
>rbdbase, num_bytes);
...
num_bytes = num_rx_bds * sizeof(struct sk_buff *);
ROUNDUP_PWR2(num_bytes);
mpool_init(&(data->rx_skbuff_ptr_pool), (unchar *)data-
>rx_skbuff, num_bytes);
...
}

change to mpc860sar_init_dev_data(){
...
int rcq_num_bytes;
rcq_num_bytes = rcq_rx_ring_size * sizeof(atm_cbd_t);
ROUNDUP_PWR2(rcq_num_bytes);
num_bytes = (num_rx_bds - rcq_rx_ring_size) * sizeof
(atm_cbd_t);
ROUNDUP_PWR2(num_bytes);
num_bytes += rcq_num_bytes;
ROUNDUP_PWR2(num_bytes);
mpool_init(&(data->rx_bd_pool), (unchar *)data-
>rbdbase, num_bytes);
...
rcq_num_bytes = rcq_rx_ring_size * sizeof(struct
sk_buff *);
ROUNDUP_PWR2(rcq_num_bytes);
num_bytes = (num_rx_bds - rcq_rx_ring_size) * sizeof
(struct sk_buff *);
ROUNDUP_PWR2(num_bytes);
num_bytes += rcq_num_bytes;
ROUNDUP_PWR2(num_bytes);
mpool_init(&(data->rx_skbuff_ptr_pool), (unchar *)data-
>rx_skbuff, num_bytes);
...
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB