Home | History | Annotate | Line # | Download | only in ixgbe
ixgbe_dcb.h revision 1.4
      1  1.1  msaitoh /******************************************************************************
      2  1.1  msaitoh 
      3  1.4  msaitoh   Copyright (c) 2001-2017, Intel Corporation
      4  1.1  msaitoh   All rights reserved.
      5  1.4  msaitoh 
      6  1.4  msaitoh   Redistribution and use in source and binary forms, with or without
      7  1.1  msaitoh   modification, are permitted provided that the following conditions are met:
      8  1.4  msaitoh 
      9  1.4  msaitoh    1. Redistributions of source code must retain the above copyright notice,
     10  1.1  msaitoh       this list of conditions and the following disclaimer.
     11  1.4  msaitoh 
     12  1.4  msaitoh    2. Redistributions in binary form must reproduce the above copyright
     13  1.4  msaitoh       notice, this list of conditions and the following disclaimer in the
     14  1.1  msaitoh       documentation and/or other materials provided with the distribution.
     15  1.4  msaitoh 
     16  1.4  msaitoh    3. Neither the name of the Intel Corporation nor the names of its
     17  1.4  msaitoh       contributors may be used to endorse or promote products derived from
     18  1.1  msaitoh       this software without specific prior written permission.
     19  1.4  msaitoh 
     20  1.1  msaitoh   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     21  1.4  msaitoh   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  1.4  msaitoh   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  1.4  msaitoh   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     24  1.4  msaitoh   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.4  msaitoh   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.4  msaitoh   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.4  msaitoh   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.4  msaitoh   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.1  msaitoh   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.1  msaitoh   POSSIBILITY OF SUCH DAMAGE.
     31  1.1  msaitoh 
     32  1.1  msaitoh ******************************************************************************/
     33  1.4  msaitoh /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_dcb.h 320688 2017-07-05 17:27:03Z erj $*/
     34  1.1  msaitoh 
     35  1.1  msaitoh #ifndef _IXGBE_DCB_H_
     36  1.1  msaitoh #define _IXGBE_DCB_H_
     37  1.1  msaitoh 
     38  1.1  msaitoh #include "ixgbe_type.h"
     39  1.1  msaitoh 
     40  1.1  msaitoh /* DCB defines */
     41  1.1  msaitoh /* DCB credit calculation defines */
     42  1.1  msaitoh #define IXGBE_DCB_CREDIT_QUANTUM	64
     43  1.1  msaitoh #define IXGBE_DCB_MAX_CREDIT_REFILL	200   /* 200 * 64B = 12800B */
     44  1.1  msaitoh #define IXGBE_DCB_MAX_TSO_SIZE		(32 * 1024) /* Max TSO pkt size in DCB*/
     45  1.1  msaitoh #define IXGBE_DCB_MAX_CREDIT		(2 * IXGBE_DCB_MAX_CREDIT_REFILL)
     46  1.1  msaitoh 
     47  1.1  msaitoh /* 513 for 32KB TSO packet */
     48  1.1  msaitoh #define IXGBE_DCB_MIN_TSO_CREDIT	\
     49  1.1  msaitoh 	((IXGBE_DCB_MAX_TSO_SIZE / IXGBE_DCB_CREDIT_QUANTUM) + 1)
     50  1.1  msaitoh 
     51  1.1  msaitoh /* DCB configuration defines */
     52  1.1  msaitoh #define IXGBE_DCB_MAX_USER_PRIORITY	8
     53  1.1  msaitoh #define IXGBE_DCB_MAX_BW_GROUP		8
     54  1.1  msaitoh #define IXGBE_DCB_BW_PERCENT		100
     55  1.1  msaitoh 
     56  1.1  msaitoh #define IXGBE_DCB_TX_CONFIG		0
     57  1.1  msaitoh #define IXGBE_DCB_RX_CONFIG		1
     58  1.1  msaitoh 
     59  1.1  msaitoh /* DCB capability defines */
     60  1.1  msaitoh #define IXGBE_DCB_PG_SUPPORT	0x00000001
     61  1.1  msaitoh #define IXGBE_DCB_PFC_SUPPORT	0x00000002
     62  1.1  msaitoh #define IXGBE_DCB_BCN_SUPPORT	0x00000004
     63  1.1  msaitoh #define IXGBE_DCB_UP2TC_SUPPORT	0x00000008
     64  1.1  msaitoh #define IXGBE_DCB_GSP_SUPPORT	0x00000010
     65  1.1  msaitoh 
     66  1.1  msaitoh struct ixgbe_dcb_support {
     67  1.1  msaitoh 	u32 capabilities; /* DCB capabilities */
     68  1.1  msaitoh 
     69  1.1  msaitoh 	/* Each bit represents a number of TCs configurable in the hw.
     70  1.1  msaitoh 	 * If 8 traffic classes can be configured, the value is 0x80. */
     71  1.1  msaitoh 	u8 traffic_classes;
     72  1.1  msaitoh 	u8 pfc_traffic_classes;
     73  1.1  msaitoh };
     74  1.1  msaitoh 
     75  1.1  msaitoh enum ixgbe_dcb_tsa {
     76  1.1  msaitoh 	ixgbe_dcb_tsa_ets = 0,
     77  1.1  msaitoh 	ixgbe_dcb_tsa_group_strict_cee,
     78  1.1  msaitoh 	ixgbe_dcb_tsa_strict
     79  1.1  msaitoh };
     80  1.1  msaitoh 
     81  1.1  msaitoh /* Traffic class bandwidth allocation per direction */
     82  1.1  msaitoh struct ixgbe_dcb_tc_path {
     83  1.1  msaitoh 	u8 bwg_id; /* Bandwidth Group (BWG) ID */
     84  1.1  msaitoh 	u8 bwg_percent; /* % of BWG's bandwidth */
     85  1.1  msaitoh 	u8 link_percent; /* % of link bandwidth */
     86  1.1  msaitoh 	u8 up_to_tc_bitmap; /* User Priority to Traffic Class mapping */
     87  1.1  msaitoh 	u16 data_credits_refill; /* Credit refill amount in 64B granularity */
     88  1.1  msaitoh 	u16 data_credits_max; /* Max credits for a configured packet buffer
     89  1.1  msaitoh 			       * in 64B granularity.*/
     90  1.1  msaitoh 	enum ixgbe_dcb_tsa tsa; /* Link or Group Strict Priority */
     91  1.1  msaitoh };
     92  1.1  msaitoh 
     93  1.1  msaitoh enum ixgbe_dcb_pfc {
     94  1.1  msaitoh 	ixgbe_dcb_pfc_disabled = 0,
     95  1.1  msaitoh 	ixgbe_dcb_pfc_enabled,
     96  1.1  msaitoh 	ixgbe_dcb_pfc_enabled_txonly,
     97  1.1  msaitoh 	ixgbe_dcb_pfc_enabled_rxonly
     98  1.1  msaitoh };
     99  1.1  msaitoh 
    100  1.1  msaitoh /* Traffic class configuration */
    101  1.1  msaitoh struct ixgbe_dcb_tc_config {
    102  1.1  msaitoh 	struct ixgbe_dcb_tc_path path[2]; /* One each for Tx/Rx */
    103  1.1  msaitoh 	enum ixgbe_dcb_pfc pfc; /* Class based flow control setting */
    104  1.1  msaitoh 
    105  1.1  msaitoh 	u16 desc_credits_max; /* For Tx Descriptor arbitration */
    106  1.1  msaitoh 	u8 tc; /* Traffic class (TC) */
    107  1.1  msaitoh };
    108  1.1  msaitoh 
    109  1.1  msaitoh enum ixgbe_dcb_pba {
    110  1.1  msaitoh 	/* PBA[0-7] each use 64KB FIFO */
    111  1.1  msaitoh 	ixgbe_dcb_pba_equal = PBA_STRATEGY_EQUAL,
    112  1.1  msaitoh 	/* PBA[0-3] each use 80KB, PBA[4-7] each use 48KB */
    113  1.1  msaitoh 	ixgbe_dcb_pba_80_48 = PBA_STRATEGY_WEIGHTED
    114  1.1  msaitoh };
    115  1.1  msaitoh 
    116  1.1  msaitoh struct ixgbe_dcb_num_tcs {
    117  1.1  msaitoh 	u8 pg_tcs;
    118  1.1  msaitoh 	u8 pfc_tcs;
    119  1.1  msaitoh };
    120  1.1  msaitoh 
    121  1.1  msaitoh struct ixgbe_dcb_config {
    122  1.1  msaitoh 	struct ixgbe_dcb_tc_config tc_config[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    123  1.1  msaitoh 	struct ixgbe_dcb_support support;
    124  1.1  msaitoh 	struct ixgbe_dcb_num_tcs num_tcs;
    125  1.1  msaitoh 	u8 bw_percentage[2][IXGBE_DCB_MAX_BW_GROUP]; /* One each for Tx/Rx */
    126  1.1  msaitoh 	bool pfc_mode_enable;
    127  1.1  msaitoh 	bool round_robin_enable;
    128  1.1  msaitoh 
    129  1.1  msaitoh 	enum ixgbe_dcb_pba rx_pba_cfg;
    130  1.1  msaitoh 
    131  1.1  msaitoh 	u32 dcb_cfg_version; /* Not used...OS-specific? */
    132  1.1  msaitoh 	u32 link_speed; /* For bandwidth allocation validation purpose */
    133  1.1  msaitoh 	bool vt_mode;
    134  1.1  msaitoh };
    135  1.1  msaitoh 
    136  1.1  msaitoh /* DCB driver APIs */
    137  1.1  msaitoh 
    138  1.1  msaitoh /* DCB rule checking */
    139  1.1  msaitoh s32 ixgbe_dcb_check_config_cee(struct ixgbe_dcb_config *);
    140  1.1  msaitoh 
    141  1.1  msaitoh /* DCB credits calculation */
    142  1.1  msaitoh s32 ixgbe_dcb_calculate_tc_credits(u8 *, u16 *, u16 *, int);
    143  1.1  msaitoh s32 ixgbe_dcb_calculate_tc_credits_cee(struct ixgbe_hw *,
    144  1.1  msaitoh 				       struct ixgbe_dcb_config *, u32, u8);
    145  1.1  msaitoh 
    146  1.1  msaitoh /* DCB PFC */
    147  1.1  msaitoh s32 ixgbe_dcb_config_pfc(struct ixgbe_hw *, u8, u8 *);
    148  1.1  msaitoh s32 ixgbe_dcb_config_pfc_cee(struct ixgbe_hw *, struct ixgbe_dcb_config *);
    149  1.1  msaitoh 
    150  1.1  msaitoh /* DCB stats */
    151  1.1  msaitoh s32 ixgbe_dcb_config_tc_stats(struct ixgbe_hw *);
    152  1.1  msaitoh s32 ixgbe_dcb_get_tc_stats(struct ixgbe_hw *, struct ixgbe_hw_stats *, u8);
    153  1.1  msaitoh s32 ixgbe_dcb_get_pfc_stats(struct ixgbe_hw *, struct ixgbe_hw_stats *, u8);
    154  1.1  msaitoh 
    155  1.1  msaitoh /* DCB config arbiters */
    156  1.1  msaitoh s32 ixgbe_dcb_config_tx_desc_arbiter_cee(struct ixgbe_hw *,
    157  1.1  msaitoh 					 struct ixgbe_dcb_config *);
    158  1.1  msaitoh s32 ixgbe_dcb_config_tx_data_arbiter_cee(struct ixgbe_hw *,
    159  1.1  msaitoh 					 struct ixgbe_dcb_config *);
    160  1.1  msaitoh s32 ixgbe_dcb_config_rx_arbiter_cee(struct ixgbe_hw *,
    161  1.1  msaitoh 				    struct ixgbe_dcb_config *);
    162  1.1  msaitoh 
    163  1.1  msaitoh /* DCB unpack routines */
    164  1.1  msaitoh void ixgbe_dcb_unpack_pfc_cee(struct ixgbe_dcb_config *, u8 *, u8 *);
    165  1.1  msaitoh void ixgbe_dcb_unpack_refill_cee(struct ixgbe_dcb_config *, int, u16 *);
    166  1.1  msaitoh void ixgbe_dcb_unpack_max_cee(struct ixgbe_dcb_config *, u16 *);
    167  1.1  msaitoh void ixgbe_dcb_unpack_bwgid_cee(struct ixgbe_dcb_config *, int, u8 *);
    168  1.1  msaitoh void ixgbe_dcb_unpack_tsa_cee(struct ixgbe_dcb_config *, int, u8 *);
    169  1.1  msaitoh void ixgbe_dcb_unpack_map_cee(struct ixgbe_dcb_config *, int, u8 *);
    170  1.1  msaitoh u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *, int, u8);
    171  1.1  msaitoh 
    172  1.1  msaitoh /* DCB initialization */
    173  1.1  msaitoh s32 ixgbe_dcb_hw_config(struct ixgbe_hw *, u16 *, u16 *, u8 *, u8 *, u8 *);
    174  1.1  msaitoh s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *, struct ixgbe_dcb_config *);
    175  1.1  msaitoh #endif /* _IXGBE_DCB_H_ */
    176