Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel 10 Gigabit PCI Express Linux driver |
Don Skidmore | a52055e | 2011-02-23 09:58:39 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2011 Intel Corporation. |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
| 23 | Linux NICS <linux.nics@intel.com> |
| 24 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
| 29 | #ifndef _DCB_CONFIG_H_ |
| 30 | #define _DCB_CONFIG_H_ |
| 31 | |
John Fastabend | 4c09f3a | 2011-08-04 05:47:07 +0000 | [diff] [blame^] | 32 | #include <linux/dcbnl.h> |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 33 | #include "ixgbe_type.h" |
| 34 | |
| 35 | /* DCB data structures */ |
| 36 | |
| 37 | #define IXGBE_MAX_PACKET_BUFFERS 8 |
| 38 | #define MAX_USER_PRIORITY 8 |
| 39 | #define MAX_TRAFFIC_CLASS 8 |
| 40 | #define MAX_BW_GROUP 8 |
| 41 | #define BW_PERCENT 100 |
| 42 | |
| 43 | #define DCB_TX_CONFIG 0 |
| 44 | #define DCB_RX_CONFIG 1 |
| 45 | |
| 46 | /* DCB error Codes */ |
| 47 | #define DCB_SUCCESS 0 |
| 48 | #define DCB_ERR_CONFIG -1 |
| 49 | #define DCB_ERR_PARAM -2 |
| 50 | |
| 51 | /* Transmit and receive Errors */ |
| 52 | /* Error in bandwidth group allocation */ |
| 53 | #define DCB_ERR_BW_GROUP -3 |
| 54 | /* Error in traffic class bandwidth allocation */ |
| 55 | #define DCB_ERR_TC_BW -4 |
| 56 | /* Traffic class has both link strict and group strict enabled */ |
| 57 | #define DCB_ERR_LS_GS -5 |
| 58 | /* Link strict traffic class has non zero bandwidth */ |
| 59 | #define DCB_ERR_LS_BW_NONZERO -6 |
| 60 | /* Link strict bandwidth group has non zero bandwidth */ |
| 61 | #define DCB_ERR_LS_BWG_NONZERO -7 |
| 62 | /* Traffic class has zero bandwidth */ |
| 63 | #define DCB_ERR_TC_BW_ZERO -8 |
| 64 | |
| 65 | #define DCB_NOT_IMPLEMENTED 0x7FFFFFFF |
| 66 | |
| 67 | struct dcb_pfc_tc_debug { |
| 68 | u8 tc; |
| 69 | u8 pause_status; |
| 70 | u64 pause_quanta; |
| 71 | }; |
| 72 | |
| 73 | enum strict_prio_type { |
| 74 | prio_none = 0, |
| 75 | prio_group, |
| 76 | prio_link |
| 77 | }; |
| 78 | |
PJ Waskiewicz | 235ea82 | 2009-02-27 15:44:48 +0000 | [diff] [blame] | 79 | /* DCB capability definitions */ |
| 80 | #define IXGBE_DCB_PG_SUPPORT 0x00000001 |
| 81 | #define IXGBE_DCB_PFC_SUPPORT 0x00000002 |
| 82 | #define IXGBE_DCB_BCN_SUPPORT 0x00000004 |
| 83 | #define IXGBE_DCB_UP2TC_SUPPORT 0x00000008 |
| 84 | #define IXGBE_DCB_GSP_SUPPORT 0x00000010 |
| 85 | |
| 86 | #define IXGBE_DCB_8_TC_SUPPORT 0x80 |
| 87 | |
| 88 | struct dcb_support { |
| 89 | /* DCB capabilities */ |
| 90 | u32 capabilities; |
| 91 | |
| 92 | /* Each bit represents a number of TCs configurable in the hw. |
| 93 | * If 8 traffic classes can be configured, the value is 0x80. |
| 94 | */ |
| 95 | u8 traffic_classes; |
| 96 | u8 pfc_traffic_classes; |
| 97 | }; |
| 98 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 99 | /* Traffic class bandwidth allocation per direction */ |
| 100 | struct tc_bw_alloc { |
| 101 | u8 bwg_id; /* Bandwidth Group (BWG) ID */ |
| 102 | u8 bwg_percent; /* % of BWG's bandwidth */ |
| 103 | u8 link_percent; /* % of link bandwidth */ |
| 104 | u8 up_to_tc_bitmap; /* User Priority to Traffic Class mapping */ |
| 105 | u16 data_credits_refill; /* Credit refill amount in 64B granularity */ |
| 106 | u16 data_credits_max; /* Max credits for a configured packet buffer |
| 107 | * in 64B granularity.*/ |
| 108 | enum strict_prio_type prio_type; /* Link or Group Strict Priority */ |
| 109 | }; |
| 110 | |
| 111 | enum dcb_pfc_type { |
| 112 | pfc_disabled = 0, |
| 113 | pfc_enabled_full, |
| 114 | pfc_enabled_tx, |
| 115 | pfc_enabled_rx |
| 116 | }; |
| 117 | |
| 118 | /* Traffic class configuration */ |
| 119 | struct tc_configuration { |
| 120 | struct tc_bw_alloc path[2]; /* One each for Tx/Rx */ |
| 121 | enum dcb_pfc_type dcb_pfc; /* Class based flow control setting */ |
| 122 | |
| 123 | u16 desc_credits_max; /* For Tx Descriptor arbitration */ |
| 124 | u8 tc; /* Traffic class (TC) */ |
| 125 | }; |
| 126 | |
PJ Waskiewicz | 235ea82 | 2009-02-27 15:44:48 +0000 | [diff] [blame] | 127 | struct dcb_num_tcs { |
| 128 | u8 pg_tcs; |
| 129 | u8 pfc_tcs; |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 130 | }; |
| 131 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 132 | struct ixgbe_dcb_config { |
PJ Waskiewicz | 235ea82 | 2009-02-27 15:44:48 +0000 | [diff] [blame] | 133 | struct dcb_support support; |
| 134 | struct dcb_num_tcs num_tcs; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 135 | struct tc_configuration tc_config[MAX_TRAFFIC_CLASS]; |
| 136 | u8 bw_percentage[2][MAX_BW_GROUP]; /* One each for Tx/Rx */ |
PJ Waskiewicz | 235ea82 | 2009-02-27 15:44:48 +0000 | [diff] [blame] | 137 | bool pfc_mode_enable; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 138 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 139 | u32 dcb_cfg_version; /* Not used...OS-specific? */ |
| 140 | u32 link_speed; /* For bandwidth allocation validation purpose */ |
| 141 | }; |
| 142 | |
| 143 | /* DCB driver APIs */ |
John Fastabend | 55320cb | 2011-01-05 04:47:43 +0000 | [diff] [blame] | 144 | void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en); |
John Fastabend | d43f5c2 | 2011-01-22 06:07:05 +0000 | [diff] [blame] | 145 | void ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *, int, u16 *); |
| 146 | void ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *, u16 *); |
| 147 | void ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *, int, u8 *); |
| 148 | void ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *, int, u8 *); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 149 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 150 | /* DCB credits calculation */ |
John Fastabend | 80ab193 | 2010-11-16 19:26:45 -0800 | [diff] [blame] | 151 | s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *, |
| 152 | struct ixgbe_dcb_config *, int, u8); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 153 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 154 | /* DCB hw initialization */ |
John Fastabend | 4c09f3a | 2011-08-04 05:47:07 +0000 | [diff] [blame^] | 155 | s32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max); |
John Fastabend | 17049d3 | 2011-02-23 05:58:19 +0000 | [diff] [blame] | 156 | s32 ixgbe_dcb_hw_ets_config(struct ixgbe_hw *hw, u16 *refill, u16 *max, |
| 157 | u8 *bwg_id, u8 *prio_type, u8 *tc_prio); |
John Fastabend | d033d52 | 2011-02-10 14:40:01 +0000 | [diff] [blame] | 158 | s32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 159 | s32 ixgbe_dcb_hw_config(struct ixgbe_hw *, struct ixgbe_dcb_config *); |
| 160 | |
| 161 | /* DCB definitions for credit calculation */ |
John Fastabend | 9806307 | 2010-10-28 00:59:57 +0000 | [diff] [blame] | 162 | #define DCB_CREDIT_QUANTUM 64 /* DCB Quantum */ |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 163 | #define MAX_CREDIT_REFILL 511 /* 0x1FF * 64B = 32704B */ |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 164 | #define DCB_MAX_TSO_SIZE (32*1024) /* MAX TSO packet size supported in DCB mode */ |
| 165 | #define MINIMUM_CREDIT_FOR_TSO (DCB_MAX_TSO_SIZE/64 + 1) /* 513 for 32KB TSO packet */ |
| 166 | #define MAX_CREDIT 4095 /* Maximum credit supported: 256KB * 1204 / 64B */ |
| 167 | |
| 168 | #endif /* _DCB_CONFIG_H */ |