diff options
author | John Fastabend <john.r.fastabend@intel.com> | 2011-02-10 09:40:01 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-02-11 11:47:15 -0500 |
commit | d033d526a465c4bb8a499a0b5df65b3e7cf4da6f (patch) | |
tree | 570fba34e3fe39dd158dbf38296ca486298b2548 /drivers/net/ixgbe/ixgbe_dcb.c | |
parent | 55320cb58baebd1795ec92f4550a1e8b38bf9ddf (diff) |
ixgbe: DCB, implement 802.1Qaz routines
Implements 802.1Qaz support for ixgbe driver. Additionally,
this adds IEEE_8021QAZ_TSA_{} defines to dcbnl.h this is to
avoid having to use cryptic numeric codes for the TSA type.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_dcb.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_dcb.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/drivers/net/ixgbe/ixgbe_dcb.c b/drivers/net/ixgbe/ixgbe_dcb.c index d9bb670ae258..13c962efbfc9 100644 --- a/drivers/net/ixgbe/ixgbe_dcb.c +++ b/drivers/net/ixgbe/ixgbe_dcb.c | |||
@@ -34,6 +34,42 @@ | |||
34 | #include "ixgbe_dcb_82599.h" | 34 | #include "ixgbe_dcb_82599.h" |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * ixgbe_ieee_credits - This calculates the ieee traffic class | ||
38 | * credits from the configured bandwidth percentages. Credits | ||
39 | * are the smallest unit programable into the underlying | ||
40 | * hardware. The IEEE 802.1Qaz specification do not use bandwidth | ||
41 | * groups so this is much simplified from the CEE case. | ||
42 | */ | ||
43 | s32 ixgbe_ieee_credits(__u8 *bw, __u16 *refill, __u16 *max, int max_frame) | ||
44 | { | ||
45 | int min_percent = 100; | ||
46 | int min_credit, multiplier; | ||
47 | int i; | ||
48 | |||
49 | min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) / | ||
50 | DCB_CREDIT_QUANTUM; | ||
51 | |||
52 | for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { | ||
53 | if (bw[i] < min_percent && bw[i]) | ||
54 | min_percent = bw[i]; | ||
55 | } | ||
56 | |||
57 | multiplier = (min_credit / min_percent) + 1; | ||
58 | |||
59 | /* Find out the hw credits for each TC */ | ||
60 | for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { | ||
61 | int val = min(bw[i] * multiplier, MAX_CREDIT_REFILL); | ||
62 | |||
63 | if (val < min_credit) | ||
64 | val = min_credit; | ||
65 | refill[i] = val; | ||
66 | |||
67 | max[i] = (bw[i] * MAX_CREDIT)/100; | ||
68 | } | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | /** | ||
37 | * ixgbe_dcb_calculate_tc_credits - Calculates traffic class credits | 73 | * ixgbe_dcb_calculate_tc_credits - Calculates traffic class credits |
38 | * @ixgbe_dcb_config: Struct containing DCB settings. | 74 | * @ixgbe_dcb_config: Struct containing DCB settings. |
39 | * @direction: Configuring either Tx or Rx. | 75 | * @direction: Configuring either Tx or Rx. |
@@ -236,3 +272,70 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, | |||
236 | return ret; | 272 | return ret; |
237 | } | 273 | } |
238 | 274 | ||
275 | /* Helper routines to abstract HW specifics from DCB netlink ops */ | ||
276 | s32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en) | ||
277 | { | ||
278 | int ret = -EINVAL; | ||
279 | |||
280 | switch (hw->mac.type) { | ||
281 | case ixgbe_mac_82598EB: | ||
282 | ret = ixgbe_dcb_config_pfc_82598(hw, pfc_en); | ||
283 | break; | ||
284 | case ixgbe_mac_82599EB: | ||
285 | case ixgbe_mac_X540: | ||
286 | ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en); | ||
287 | break; | ||
288 | default: | ||
289 | break; | ||
290 | } | ||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | s32 ixgbe_dcb_hw_ets_config(struct ixgbe_hw *hw, | ||
295 | u16 *refill, u16 *max, u8 *bwg_id, u8 *tsa) | ||
296 | { | ||
297 | int i; | ||
298 | u8 prio_type[IEEE_8021QAZ_MAX_TCS]; | ||
299 | |||
300 | /* Map TSA onto CEE prio type */ | ||
301 | for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { | ||
302 | switch (tsa[i]) { | ||
303 | case IEEE_8021QAZ_TSA_STRICT: | ||
304 | prio_type[i] = 2; | ||
305 | break; | ||
306 | case IEEE_8021QAZ_TSA_ETS: | ||
307 | prio_type[i] = 0; | ||
308 | break; | ||
309 | default: | ||
310 | /* Hardware only supports priority strict or | ||
311 | * ETS transmission selection algorithms if | ||
312 | * we receive some other value from dcbnl | ||
313 | * throw an error | ||
314 | */ | ||
315 | return -EINVAL; | ||
316 | } | ||
317 | } | ||
318 | |||
319 | switch (hw->mac.type) { | ||
320 | case ixgbe_mac_82598EB: | ||
321 | ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, | ||
322 | prio_type); | ||
323 | ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max, | ||
324 | bwg_id, prio_type); | ||
325 | ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max, | ||
326 | bwg_id, prio_type); | ||
327 | break; | ||
328 | case ixgbe_mac_82599EB: | ||
329 | case ixgbe_mac_X540: | ||
330 | ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, | ||
331 | bwg_id, prio_type); | ||
332 | ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, | ||
333 | bwg_id, prio_type); | ||
334 | ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, | ||
335 | bwg_id, prio_type); | ||
336 | break; | ||
337 | default: | ||
338 | break; | ||
339 | } | ||
340 | return 0; | ||
341 | } | ||