src/dpdk/drivers/net/txgbe/base/txgbe_hw.c
void txgbe_set_pba(struct txgbe_hw *hw, int num_pb, u32 headroom,
			     int strategy)
{
	u32 pbsize = hw->mac.rx_pb_size;
	int i = 0;
	u32 rxpktsize, txpktsize, txpbthresh;

	UNREFERENCED_PARAMETER(hw);

	/* Reserve headroom */
	pbsize -= headroom;

	if (!num_pb)
		num_pb = 1;

	/* Divide remaining packet buffer space amongst the number of packet
	 * buffers requested using supplied strategy.
	 */
	switch (strategy) {
	case PBA_STRATEGY_WEIGHTED:
		/* txgbe_dcb_pba_80_48 strategy weight first half of packet
		 * buffer with 5/8 of the packet buffer space.
		 */
		rxpktsize = (pbsize * 5) / (num_pb * 4);
		pbsize -= rxpktsize * (num_pb / 2);
		rxpktsize <<= 10;
		for (; i < (num_pb / 2); i++)
			wr32(hw, TXGBE_PBRXSIZE(i), rxpktsize);
		/* fall through - configure remaining packet buffers */
	case PBA_STRATEGY_EQUAL:
		rxpktsize = (pbsize / (num_pb - i));
		rxpktsize <<= 10;
		for (; i < num_pb; i++)
			wr32(hw, TXGBE_PBRXSIZE(i), rxpktsize);
		break;
	default:
		break;
	}

	/* Only support an equally distributed Tx packet buffer strategy. */
	txpktsize = TXGBE_PBTXSIZE_MAX / num_pb;
	txpbthresh = (txpktsize / 1024) - TXGBE_TXPKT_SIZE_MAX;
	for (i = 0; i < num_pb; i++) {
		wr32(hw, TXGBE_PBTXSIZE(i), txpktsize);
		wr32(hw, TXGBE_PBTXDMATH(i), txpbthresh);
	}

	/* Clear unused TCs, if any, to zero buffer size*/
	for (; i < TXGBE_MAX_UP; i++) {
		wr32(hw, TXGBE_PBRXSIZE(i), 0);
		wr32(hw, TXGBE_PBTXSIZE(i), 0);
		wr32(hw, TXGBE_PBTXDMATH(i), 0);
	}
}
/**
 * txgbe_set_pba - Initialize Rx packet buffer
 * @hw: pointer to hardware structure
 * @num_pb: number of packet buffers to allocate
 * @headroom: reserve n KB of headroom
 * @strategy: packet buffer allocation strategy
 **/
Initialize Rx packet buffer
@hw: pointer to hardware structure
@num_pb: number of packet buffers to allocate
@headroom: reserve n KB of headroom
@strategy: packet buffer allocation strategy
Initialize Rx packet buffer @hw : pointer to hardware structure @num_pb : number of packet buffers to allocate @headroom : reserve n KB of headroom @strategy : packet buffer allocation strategy
void txgbe_set_pba(struct txgbe_hw *hw, int num_pb, u32 headroom,
			     int strategy)
{
	u32 pbsize = hw->mac.rx_pb_size;
	int i = 0;
	u32 rxpktsize, txpktsize, txpbthresh;
	UNREFERENCED_PARAMETER(hw);
	pbsize -= headroom;
	if (!num_pb)
		num_pb = 1;
	switch (strategy) {
	case PBA_STRATEGY_WEIGHTED:
		rxpktsize = (pbsize * 5) / (num_pb * 4);
		pbsize -= rxpktsize * (num_pb / 2);
		rxpktsize <<= 10;
		for (; i < (num_pb / 2); i++)
			wr32(hw, TXGBE_PBRXSIZE(i), rxpktsize);
	case PBA_STRATEGY_EQUAL:
		rxpktsize = (pbsize / (num_pb - i));
		rxpktsize <<= 10;
		for (; i < num_pb; i++)
			wr32(hw, TXGBE_PBRXSIZE(i), rxpktsize);
		break;
	default:
		break;
	}
	txpktsize = TXGBE_PBTXSIZE_MAX / num_pb;
	txpbthresh = (txpktsize / 1024) - TXGBE_TXPKT_SIZE_MAX;
	for (i = 0; i < num_pb; i++) {
		wr32(hw, TXGBE_PBTXSIZE(i), txpktsize);
		wr32(hw, TXGBE_PBTXDMATH(i), txpbthresh);
	}
	for (; i < TXGBE_MAX_UP; i++) {
		wr32(hw, TXGBE_PBRXSIZE(i), 0);
		wr32(hw, TXGBE_PBTXSIZE(i), 0);
		wr32(hw, TXGBE_PBTXDMATH(i), 0);
	}
}
void txgbe_set_pba ( struct txgbe_hw * hw , int num_pb , u32 headroom , int strategy ) { u32 pbsize = hw -> mac . rx_pb_size ; int i = 0 ; u32 rxpktsize , txpktsize , txpbthresh ; UNREFERENCED_PARAMETER ( hw ) ; pbsize -= headroom ; if ( ! num_pb ) num_pb = 1 ; switch ( strategy ) { case PBA_STRATEGY_WEIGHTED : rxpktsize = ( pbsize * 5 ) / ( num_pb * 4 ) ; pbsize -= rxpktsize * ( num_pb / 2 ) ; rxpktsize <<= 10 ; for ( ; i < ( num_pb / 2 ) ; i ++ ) wr32 ( hw , TXGBE_PBRXSIZE ( i ) , rxpktsize ) ; case PBA_STRATEGY_EQUAL : rxpktsize = ( pbsize / ( num_pb - i ) ) ; rxpktsize <<= 10 ; for ( ; i < num_pb ; i ++ ) wr32 ( hw , TXGBE_PBRXSIZE ( i ) , rxpktsize ) ; break ; default : break ; } txpktsize = TXGBE_PBTXSIZE_MAX / num_pb ; txpbthresh = ( txpktsize / 1024 ) - TXGBE_TXPKT_SIZE_MAX ; for ( i = 0 ; i < num_pb ; i ++ ) { wr32 ( hw , TXGBE_PBTXSIZE ( i ) , txpktsize ) ; wr32 ( hw , TXGBE_PBTXDMATH ( i ) , txpbthresh ) ; } for ( ; i < TXGBE_MAX_UP ; i ++ ) { wr32 ( hw , TXGBE_PBRXSIZE ( i ) , 0 ) ; wr32 ( hw , TXGBE_PBTXSIZE ( i ) , 0 ) ; wr32 ( hw , TXGBE_PBTXDMATH ( i ) , 0 ) ; } }
txgbe_set_pba - Initialize Rx packet buffer
 @hw: pointer to hardware structure
 @num_pb: number of packet buffers to allocate
 @headroom: reserve n KB of headroom
 @strategy: packet buffer allocation strategy
txgbe_set_pba - Initialize Rx packet buffer @hw : pointer to hardware structure @num_pb : number of packet buffers to allocate @headroom : reserve n KB of headroom @strategy : packet buffer allocation strategy
/* Reserve headroom */ /* Divide remaining packet buffer space amongst the number of packet
	 * buffers requested using supplied strategy.
	 */ /* txgbe_dcb_pba_80_48 strategy weight first half of packet
		 * buffer with 5/8 of the packet buffer space.
		 */ /* fall through - configure remaining packet buffers */ /* Only support an equally distributed Tx packet buffer strategy. */ /* Clear unused TCs, if any, to zero buffer size*/