Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe Add some files.



details:   https://anonhg.NetBSD.org/src/rev/04e3dfe0a59b
branches:  trunk
changeset: 339707:04e3dfe0a59b
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Aug 05 04:11:07 2015 +0000

description:
Add some files.

diffstat:

 sys/dev/pci/ixgbe/ixgbe_dcb.c       |  718 ++++++++++++++++++++++++++++++++++++
 sys/dev/pci/ixgbe/ixgbe_dcb.h       |  176 ++++++++
 sys/dev/pci/ixgbe/ixgbe_dcb_82598.c |  359 ++++++++++++++++++
 sys/dev/pci/ixgbe/ixgbe_dcb_82598.h |  100 +++++
 sys/dev/pci/ixgbe/ixgbe_dcb_82599.c |  586 +++++++++++++++++++++++++++++
 sys/dev/pci/ixgbe/ixgbe_dcb_82599.h |  154 +++++++
 6 files changed, 2093 insertions(+), 0 deletions(-)

diffs (truncated from 2117 to 300 lines):

diff -r a81111663ed6 -r 04e3dfe0a59b sys/dev/pci/ixgbe/ixgbe_dcb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_dcb.c     Wed Aug 05 04:11:07 2015 +0000
@@ -0,0 +1,718 @@
+/******************************************************************************
+
+  Copyright (c) 2001-2013, Intel Corporation 
+  All rights reserved.
+  
+  Redistribution and use in source and binary forms, with or without 
+  modification, are permitted provided that the following conditions are met:
+  
+   1. Redistributions of source code must retain the above copyright notice, 
+      this list of conditions and the following disclaimer.
+  
+   2. Redistributions in binary form must reproduce the above copyright 
+      notice, this list of conditions and the following disclaimer in the 
+      documentation and/or other materials provided with the distribution.
+  
+   3. Neither the name of the Intel Corporation nor the names of its 
+      contributors may be used to endorse or promote products derived from 
+      this software without specific prior written permission.
+  
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+
+******************************************************************************/
+/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_dcb.c 251964 2013-06-18 21:28:19Z jfv $*/
+
+
+#include "ixgbe_type.h"
+#include "ixgbe_dcb.h"
+#include "ixgbe_dcb_82598.h"
+#include "ixgbe_dcb_82599.h"
+
+/**
+ * ixgbe_dcb_calculate_tc_credits - This calculates the ieee traffic class
+ * credits from the configured bandwidth percentages. Credits
+ * are the smallest unit programmable into the underlying
+ * hardware. The IEEE 802.1Qaz specification do not use bandwidth
+ * groups so this is much simplified from the CEE case.
+ */
+s32 ixgbe_dcb_calculate_tc_credits(u8 *bw, u16 *refill, u16 *max,
+                                  int max_frame_size)
+{
+       int min_percent = 100;
+       int min_credit, multiplier;
+       int i;
+
+       min_credit = ((max_frame_size / 2) + IXGBE_DCB_CREDIT_QUANTUM - 1) /
+                       IXGBE_DCB_CREDIT_QUANTUM;
+
+       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+               if (bw[i] < min_percent && bw[i])
+                       min_percent = bw[i];
+       }
+
+       multiplier = (min_credit / min_percent) + 1;
+
+       /* Find out the hw credits for each TC */
+       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+               int val = min(bw[i] * multiplier, IXGBE_DCB_MAX_CREDIT_REFILL);
+
+               if (val < min_credit)
+                       val = min_credit;
+               refill[i] = (u16)val;
+
+               max[i] = bw[i] ? (bw[i]*IXGBE_DCB_MAX_CREDIT)/100 : min_credit;
+       }
+
+       return 0;
+}
+
+/**
+ * ixgbe_dcb_calculate_tc_credits_cee - Calculates traffic class credits
+ * @ixgbe_dcb_config: Struct containing DCB settings.
+ * @direction: Configuring either Tx or Rx.
+ *
+ * This function calculates the credits allocated to each traffic class.
+ * It should be called only after the rules are checked by
+ * ixgbe_dcb_check_config_cee().
+ */
+s32 ixgbe_dcb_calculate_tc_credits_cee(struct ixgbe_hw *hw,
+                                  struct ixgbe_dcb_config *dcb_config,
+                                  u32 max_frame_size, u8 direction)
+{
+       struct ixgbe_dcb_tc_path *p;
+       u32 min_multiplier      = 0;
+       u16 min_percent         = 100;
+       s32 ret_val =           IXGBE_SUCCESS;
+       /* Initialization values default for Tx settings */
+       u32 min_credit          = 0;
+       u32 credit_refill       = 0;
+       u32 credit_max          = 0;
+       u16 link_percentage     = 0;
+       u8  bw_percent          = 0;
+       u8  i;
+
+       if (dcb_config == NULL) {
+               ret_val = IXGBE_ERR_CONFIG;
+               goto out;
+       }
+
+       min_credit = ((max_frame_size / 2) + IXGBE_DCB_CREDIT_QUANTUM - 1) /
+                    IXGBE_DCB_CREDIT_QUANTUM;
+
+       /* Find smallest link percentage */
+       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+               p = &dcb_config->tc_config[i].path[direction];
+               bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
+               link_percentage = p->bwg_percent;
+
+               link_percentage = (link_percentage * bw_percent) / 100;
+
+               if (link_percentage && link_percentage < min_percent)
+                       min_percent = link_percentage;
+       }
+
+       /*
+        * The ratio between traffic classes will control the bandwidth
+        * percentages seen on the wire. To calculate this ratio we use
+        * a multiplier. It is required that the refill credits must be
+        * larger than the max frame size so here we find the smallest
+        * multiplier that will allow all bandwidth percentages to be
+        * greater than the max frame size.
+        */
+       min_multiplier = (min_credit / min_percent) + 1;
+
+       /* Find out the link percentage for each TC first */
+       for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+               p = &dcb_config->tc_config[i].path[direction];
+               bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
+
+               link_percentage = p->bwg_percent;
+               /* Must be careful of integer division for very small nums */
+               link_percentage = (link_percentage * bw_percent) / 100;
+               if (p->bwg_percent > 0 && link_percentage == 0)
+                       link_percentage = 1;
+
+               /* Save link_percentage for reference */
+               p->link_percent = (u8)link_percentage;
+
+               /* Calculate credit refill ratio using multiplier */
+               credit_refill = min(link_percentage * min_multiplier,
+                                   (u32)IXGBE_DCB_MAX_CREDIT_REFILL);
+               p->data_credits_refill = (u16)credit_refill;
+
+               /* Calculate maximum credit for the TC */
+               credit_max = (link_percentage * IXGBE_DCB_MAX_CREDIT) / 100;
+
+               /*
+                * Adjustment based on rule checking, if the percentage
+                * of a TC is too small, the maximum credit may not be
+                * enough to send out a jumbo frame in data plane arbitration.
+                */
+               if (credit_max && (credit_max < min_credit))
+                       credit_max = min_credit;
+
+               if (direction == IXGBE_DCB_TX_CONFIG) {
+                       /*
+                        * Adjustment based on rule checking, if the
+                        * percentage of a TC is too small, the maximum
+                        * credit may not be enough to send out a TSO
+                        * packet in descriptor plane arbitration.
+                        */
+                       if (credit_max && (credit_max <
+                           IXGBE_DCB_MIN_TSO_CREDIT)
+                           && (hw->mac.type == ixgbe_mac_82598EB))
+                               credit_max = IXGBE_DCB_MIN_TSO_CREDIT;
+
+                       dcb_config->tc_config[i].desc_credits_max =
+                                                               (u16)credit_max;
+               }
+
+               p->data_credits_max = (u16)credit_max;
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ * ixgbe_dcb_unpack_pfc_cee - Unpack dcb_config PFC info
+ * @cfg: dcb configuration to unpack into hardware consumable fields
+ * @map: user priority to traffic class map
+ * @pfc_up: u8 to store user priority PFC bitmask
+ *
+ * This unpacks the dcb configuration PFC info which is stored per
+ * traffic class into a 8bit user priority bitmask that can be
+ * consumed by hardware routines. The priority to tc map must be
+ * updated before calling this routine to use current up-to maps.
+ */
+void ixgbe_dcb_unpack_pfc_cee(struct ixgbe_dcb_config *cfg, u8 *map, u8 *pfc_up)
+{
+       struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
+       int up;
+
+       /*
+        * If the TC for this user priority has PFC enabled then set the
+        * matching bit in 'pfc_up' to reflect that PFC is enabled.
+        */
+       for (*pfc_up = 0, up = 0; up < IXGBE_DCB_MAX_USER_PRIORITY; up++) {
+               if (tc_config[map[up]].pfc != ixgbe_dcb_pfc_disabled)
+                       *pfc_up |= 1 << up;
+       }
+}
+
+void ixgbe_dcb_unpack_refill_cee(struct ixgbe_dcb_config *cfg, int direction,
+                            u16 *refill)
+{
+       struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
+       int tc;
+
+       for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
+               refill[tc] = tc_config[tc].path[direction].data_credits_refill;
+}
+
+void ixgbe_dcb_unpack_max_cee(struct ixgbe_dcb_config *cfg, u16 *max)
+{
+       struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
+       int tc;
+
+       for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
+               max[tc] = tc_config[tc].desc_credits_max;
+}
+
+void ixgbe_dcb_unpack_bwgid_cee(struct ixgbe_dcb_config *cfg, int direction,
+                           u8 *bwgid)
+{
+       struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
+       int tc;
+
+       for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
+               bwgid[tc] = tc_config[tc].path[direction].bwg_id;
+}
+
+void ixgbe_dcb_unpack_tsa_cee(struct ixgbe_dcb_config *cfg, int direction,
+                          u8 *tsa)
+{
+       struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
+       int tc;
+
+       for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
+               tsa[tc] = tc_config[tc].path[direction].tsa;
+}
+
+u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up)
+{
+       struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
+       u8 prio_mask = 1 << up;
+       u8 tc = cfg->num_tcs.pg_tcs;
+
+       /* If tc is 0 then DCB is likely not enabled or supported */
+       if (!tc)
+               goto out;
+
+       /*
+        * Test from maximum TC to 1 and report the first match we find.  If
+        * we find no match we can assume that the TC is 0 since the TC must
+        * be set for all user priorities
+        */
+       for (tc--; tc; tc--) {
+               if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap)
+                       break;
+       }
+out:
+       return tc;
+}
+
+void ixgbe_dcb_unpack_map_cee(struct ixgbe_dcb_config *cfg, int direction,
+                             u8 *map)
+{
+       u8 up;
+
+       for (up = 0; up < IXGBE_DCB_MAX_USER_PRIORITY; up++)
+               map[up] = ixgbe_dcb_get_tc_from_up(cfg, direction, up);
+}
+
+/**
+ * ixgbe_dcb_config - Struct containing DCB settings.
+ * @dcb_config: Pointer to DCB config structure
+ *
+ * This function checks DCB rules for DCB settings.
+ * The following rules are checked:
+ * 1. The sum of bandwidth percentages of all Bandwidth Groups must total 100%.
+ * 2. The sum of bandwidth percentages of all Traffic Classes within a Bandwidth
+ *    Group must total 100.
+ * 3. A Traffic Class should not be set to both Link Strict Priority
+ *    and Group Strict Priority.
+ * 4. Link strict Bandwidth Groups can only have link strict traffic classes
+ *    with zero bandwidth.



Home | Main Index | Thread Index | Old Index