aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_common.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index de65643b79a4..cc2a4a1528e2 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -3267,3 +3267,69 @@ s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps)
3267 3267
3268 return 0; 3268 return 0;
3269} 3269}
3270
3271/**
3272 * ixgbe_set_rxpba_generic - Initialize RX packet buffer
3273 * @hw: pointer to hardware structure
3274 * @num_pb: number of packet buffers to allocate
3275 * @headroom: reserve n KB of headroom
3276 * @strategy: packet buffer allocation strategy
3277 **/
3278void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw,
3279 int num_pb,
3280 u32 headroom,
3281 int strategy)
3282{
3283 u32 pbsize = hw->mac.rx_pb_size;
3284 int i = 0;
3285 u32 rxpktsize, txpktsize, txpbthresh;
3286
3287 /* Reserve headroom */
3288 pbsize -= headroom;
3289
3290 if (!num_pb)
3291 num_pb = 1;
3292
3293 /* Divide remaining packet buffer space amongst the number
3294 * of packet buffers requested using supplied strategy.
3295 */
3296 switch (strategy) {
3297 case (PBA_STRATEGY_WEIGHTED):
3298 /* pba_80_48 strategy weight first half of packet buffer with
3299 * 5/8 of the packet buffer space.
3300 */
3301 rxpktsize = ((pbsize * 5 * 2) / (num_pb * 8));
3302 pbsize -= rxpktsize * (num_pb / 2);
3303 rxpktsize <<= IXGBE_RXPBSIZE_SHIFT;
3304 for (; i < (num_pb / 2); i++)
3305 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
3306 /* Fall through to configure remaining packet buffers */
3307 case (PBA_STRATEGY_EQUAL):
3308 /* Divide the remaining Rx packet buffer evenly among the TCs */
3309 rxpktsize = (pbsize / (num_pb - i)) << IXGBE_RXPBSIZE_SHIFT;
3310 for (; i < num_pb; i++)
3311 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpktsize);
3312 break;
3313 default:
3314 break;
3315 }
3316
3317 /*
3318 * Setup Tx packet buffer and threshold equally for all TCs
3319 * TXPBTHRESH register is set in K so divide by 1024 and subtract
3320 * 10 since the largest packet we support is just over 9K.
3321 */
3322 txpktsize = IXGBE_TXPBSIZE_MAX / num_pb;
3323 txpbthresh = (txpktsize / 1024) - IXGBE_TXPKT_SIZE_MAX;
3324 for (i = 0; i < num_pb; i++) {
3325 IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), txpktsize);
3326 IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), txpbthresh);
3327 }
3328
3329 /* Clear unused TCs, if any, to zero buffer size*/
3330 for (; i < IXGBE_MAX_PB; i++) {
3331 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
3332 IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), 0);
3333 IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), 0);
3334 }
3335}