diff options
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_dcb.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_dcb.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/net/ixgbe/ixgbe_dcb.c b/drivers/net/ixgbe/ixgbe_dcb.c index 8bb9ddb6dffe..0d44c6470ca3 100644 --- a/drivers/net/ixgbe/ixgbe_dcb.c +++ b/drivers/net/ixgbe/ixgbe_dcb.c | |||
@@ -43,9 +43,12 @@ | |||
43 | * ixgbe_dcb_check_config(). | 43 | * ixgbe_dcb_check_config(). |
44 | */ | 44 | */ |
45 | s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config, | 45 | s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config, |
46 | u8 direction) | 46 | int max_frame, u8 direction) |
47 | { | 47 | { |
48 | struct tc_bw_alloc *p; | 48 | struct tc_bw_alloc *p; |
49 | int min_credit; | ||
50 | int min_multiplier; | ||
51 | int min_percent = 100; | ||
49 | s32 ret_val = 0; | 52 | s32 ret_val = 0; |
50 | /* Initialization values default for Tx settings */ | 53 | /* Initialization values default for Tx settings */ |
51 | u32 credit_refill = 0; | 54 | u32 credit_refill = 0; |
@@ -59,6 +62,31 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config, | |||
59 | goto out; | 62 | goto out; |
60 | } | 63 | } |
61 | 64 | ||
65 | min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) / | ||
66 | DCB_CREDIT_QUANTUM; | ||
67 | |||
68 | /* Find smallest link percentage */ | ||
69 | for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { | ||
70 | p = &dcb_config->tc_config[i].path[direction]; | ||
71 | bw_percent = dcb_config->bw_percentage[direction][p->bwg_id]; | ||
72 | link_percentage = p->bwg_percent; | ||
73 | |||
74 | link_percentage = (link_percentage * bw_percent) / 100; | ||
75 | |||
76 | if (link_percentage && link_percentage < min_percent) | ||
77 | min_percent = link_percentage; | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * The ratio between traffic classes will control the bandwidth | ||
82 | * percentages seen on the wire. To calculate this ratio we use | ||
83 | * a multiplier. It is required that the refill credits must be | ||
84 | * larger than the max frame size so here we find the smallest | ||
85 | * multiplier that will allow all bandwidth percentages to be | ||
86 | * greater than the max frame size. | ||
87 | */ | ||
88 | min_multiplier = (min_credit / min_percent) + 1; | ||
89 | |||
62 | /* Find out the link percentage for each TC first */ | 90 | /* Find out the link percentage for each TC first */ |
63 | for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { | 91 | for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { |
64 | p = &dcb_config->tc_config[i].path[direction]; | 92 | p = &dcb_config->tc_config[i].path[direction]; |
@@ -73,8 +101,9 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config, | |||
73 | /* Save link_percentage for reference */ | 101 | /* Save link_percentage for reference */ |
74 | p->link_percent = (u8)link_percentage; | 102 | p->link_percent = (u8)link_percentage; |
75 | 103 | ||
76 | /* Calculate credit refill and save it */ | 104 | /* Calculate credit refill ratio using multiplier */ |
77 | credit_refill = link_percentage * MINIMUM_CREDIT_REFILL; | 105 | credit_refill = min(link_percentage * min_multiplier, |
106 | MAX_CREDIT_REFILL); | ||
78 | p->data_credits_refill = (u16)credit_refill; | 107 | p->data_credits_refill = (u16)credit_refill; |
79 | 108 | ||
80 | /* Calculate maximum credit for the TC */ | 109 | /* Calculate maximum credit for the TC */ |
@@ -85,8 +114,8 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config *dcb_config, | |||
85 | * of a TC is too small, the maximum credit may not be | 114 | * of a TC is too small, the maximum credit may not be |
86 | * enough to send out a jumbo frame in data plane arbitration. | 115 | * enough to send out a jumbo frame in data plane arbitration. |
87 | */ | 116 | */ |
88 | if (credit_max && (credit_max < MINIMUM_CREDIT_FOR_JUMBO)) | 117 | if (credit_max && (credit_max < min_credit)) |
89 | credit_max = MINIMUM_CREDIT_FOR_JUMBO; | 118 | credit_max = min_credit; |
90 | 119 | ||
91 | if (direction == DCB_TX_CONFIG) { | 120 | if (direction == DCB_TX_CONFIG) { |
92 | /* | 121 | /* |