Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel 10 Gigabit PCI Express Linux driver |
| 4 | Copyright(c) 1999 - 2008 Intel Corporation. |
| 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 | #include "ixgbe.h" |
| 30 | #include <linux/dcbnl.h> |
| 31 | |
| 32 | /* Callbacks for DCB netlink in the kernel */ |
| 33 | #define BIT_DCB_MODE 0x01 |
| 34 | #define BIT_PFC 0x02 |
| 35 | #define BIT_PG_RX 0x04 |
| 36 | #define BIT_PG_TX 0x08 |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 37 | #define BIT_BCN 0x10 |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 38 | |
| 39 | int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *src_dcb_cfg, |
| 40 | struct ixgbe_dcb_config *dst_dcb_cfg, int tc_max) |
| 41 | { |
| 42 | struct tc_configuration *src_tc_cfg = NULL; |
| 43 | struct tc_configuration *dst_tc_cfg = NULL; |
| 44 | int i; |
| 45 | |
| 46 | if (!src_dcb_cfg || !dst_dcb_cfg) |
| 47 | return -EINVAL; |
| 48 | |
| 49 | for (i = DCB_PG_ATTR_TC_0; i < tc_max + DCB_PG_ATTR_TC_0; i++) { |
| 50 | src_tc_cfg = &src_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0]; |
| 51 | dst_tc_cfg = &dst_dcb_cfg->tc_config[i - DCB_PG_ATTR_TC_0]; |
| 52 | |
| 53 | dst_tc_cfg->path[DCB_TX_CONFIG].prio_type = |
| 54 | src_tc_cfg->path[DCB_TX_CONFIG].prio_type; |
| 55 | |
| 56 | dst_tc_cfg->path[DCB_TX_CONFIG].bwg_id = |
| 57 | src_tc_cfg->path[DCB_TX_CONFIG].bwg_id; |
| 58 | |
| 59 | dst_tc_cfg->path[DCB_TX_CONFIG].bwg_percent = |
| 60 | src_tc_cfg->path[DCB_TX_CONFIG].bwg_percent; |
| 61 | |
| 62 | dst_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap = |
| 63 | src_tc_cfg->path[DCB_TX_CONFIG].up_to_tc_bitmap; |
| 64 | |
| 65 | dst_tc_cfg->path[DCB_RX_CONFIG].prio_type = |
| 66 | src_tc_cfg->path[DCB_RX_CONFIG].prio_type; |
| 67 | |
| 68 | dst_tc_cfg->path[DCB_RX_CONFIG].bwg_id = |
| 69 | src_tc_cfg->path[DCB_RX_CONFIG].bwg_id; |
| 70 | |
| 71 | dst_tc_cfg->path[DCB_RX_CONFIG].bwg_percent = |
| 72 | src_tc_cfg->path[DCB_RX_CONFIG].bwg_percent; |
| 73 | |
| 74 | dst_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap = |
| 75 | src_tc_cfg->path[DCB_RX_CONFIG].up_to_tc_bitmap; |
| 76 | } |
| 77 | |
| 78 | for (i = DCB_PG_ATTR_BW_ID_0; i < DCB_PG_ATTR_BW_ID_MAX; i++) { |
| 79 | dst_dcb_cfg->bw_percentage[DCB_TX_CONFIG] |
| 80 | [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage |
| 81 | [DCB_TX_CONFIG][i-DCB_PG_ATTR_BW_ID_0]; |
| 82 | dst_dcb_cfg->bw_percentage[DCB_RX_CONFIG] |
| 83 | [i-DCB_PG_ATTR_BW_ID_0] = src_dcb_cfg->bw_percentage |
| 84 | [DCB_RX_CONFIG][i-DCB_PG_ATTR_BW_ID_0]; |
| 85 | } |
| 86 | |
| 87 | for (i = DCB_PFC_UP_ATTR_0; i < DCB_PFC_UP_ATTR_MAX; i++) { |
| 88 | dst_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc = |
| 89 | src_dcb_cfg->tc_config[i - DCB_PFC_UP_ATTR_0].dcb_pfc; |
| 90 | } |
| 91 | |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 92 | for (i = DCB_BCN_ATTR_RP_0; i < DCB_BCN_ATTR_RP_ALL; i++) { |
| 93 | dst_dcb_cfg->bcn.rp_admin_mode[i - DCB_BCN_ATTR_RP_0] = |
| 94 | src_dcb_cfg->bcn.rp_admin_mode[i - DCB_BCN_ATTR_RP_0]; |
| 95 | } |
Don Skidmore | f4314e8 | 2008-12-21 20:10:29 -0800 | [diff] [blame] | 96 | dst_dcb_cfg->bcn.bcna_option[0] = src_dcb_cfg->bcn.bcna_option[0]; |
| 97 | dst_dcb_cfg->bcn.bcna_option[1] = src_dcb_cfg->bcn.bcna_option[1]; |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 98 | dst_dcb_cfg->bcn.rp_alpha = src_dcb_cfg->bcn.rp_alpha; |
| 99 | dst_dcb_cfg->bcn.rp_beta = src_dcb_cfg->bcn.rp_beta; |
| 100 | dst_dcb_cfg->bcn.rp_gd = src_dcb_cfg->bcn.rp_gd; |
| 101 | dst_dcb_cfg->bcn.rp_gi = src_dcb_cfg->bcn.rp_gi; |
| 102 | dst_dcb_cfg->bcn.rp_tmax = src_dcb_cfg->bcn.rp_tmax; |
| 103 | dst_dcb_cfg->bcn.rp_td = src_dcb_cfg->bcn.rp_td; |
| 104 | dst_dcb_cfg->bcn.rp_rmin = src_dcb_cfg->bcn.rp_rmin; |
| 105 | dst_dcb_cfg->bcn.rp_w = src_dcb_cfg->bcn.rp_w; |
| 106 | dst_dcb_cfg->bcn.rp_rd = src_dcb_cfg->bcn.rp_rd; |
| 107 | dst_dcb_cfg->bcn.rp_ru = src_dcb_cfg->bcn.rp_ru; |
| 108 | dst_dcb_cfg->bcn.rp_wrtt = src_dcb_cfg->bcn.rp_wrtt; |
| 109 | dst_dcb_cfg->bcn.rp_ri = src_dcb_cfg->bcn.rp_ri; |
| 110 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | static u8 ixgbe_dcbnl_get_state(struct net_device *netdev) |
| 115 | { |
| 116 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 117 | |
| 118 | DPRINTK(DRV, INFO, "Get DCB Admin Mode.\n"); |
| 119 | |
| 120 | return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED); |
| 121 | } |
| 122 | |
| 123 | static u16 ixgbe_dcb_select_queue(struct net_device *dev, struct sk_buff *skb) |
| 124 | { |
| 125 | /* All traffic should default to class 0 */ |
| 126 | return 0; |
| 127 | } |
| 128 | |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 129 | static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 130 | { |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 131 | u8 err = 0; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 132 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 133 | |
| 134 | DPRINTK(DRV, INFO, "Set DCB Admin Mode.\n"); |
| 135 | |
| 136 | if (state > 0) { |
| 137 | /* Turn on DCB */ |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 138 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) |
| 139 | goto out; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 140 | |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 141 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { |
| 142 | DPRINTK(DRV, ERR, "Enable failed, needs MSI-X\n"); |
| 143 | err = 1; |
| 144 | goto out; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 145 | } |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 146 | |
| 147 | if (netif_running(netdev)) |
| 148 | netdev->netdev_ops->ndo_stop(netdev); |
| 149 | ixgbe_reset_interrupt_capability(adapter); |
| 150 | ixgbe_napi_del_all(adapter); |
Peter P Waskiewicz Jr | 7adf152 | 2008-12-26 01:36:05 -0800 | [diff] [blame] | 151 | INIT_LIST_HEAD(&netdev->napi_list); |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 152 | kfree(adapter->tx_ring); |
| 153 | kfree(adapter->rx_ring); |
| 154 | adapter->tx_ring = NULL; |
| 155 | adapter->rx_ring = NULL; |
| 156 | netdev->select_queue = &ixgbe_dcb_select_queue; |
| 157 | |
| 158 | adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED; |
| 159 | adapter->flags |= IXGBE_FLAG_DCB_ENABLED; |
| 160 | ixgbe_init_interrupt_scheme(adapter); |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 161 | if (netif_running(netdev)) |
| 162 | netdev->netdev_ops->ndo_open(netdev); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 163 | } else { |
| 164 | /* Turn off DCB */ |
| 165 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 166 | if (netif_running(netdev)) |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 167 | netdev->netdev_ops->ndo_stop(netdev); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 168 | ixgbe_reset_interrupt_capability(adapter); |
| 169 | ixgbe_napi_del_all(adapter); |
Peter P Waskiewicz Jr | 7adf152 | 2008-12-26 01:36:05 -0800 | [diff] [blame] | 170 | INIT_LIST_HEAD(&netdev->napi_list); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 171 | kfree(adapter->tx_ring); |
| 172 | kfree(adapter->rx_ring); |
| 173 | adapter->tx_ring = NULL; |
| 174 | adapter->rx_ring = NULL; |
| 175 | netdev->select_queue = NULL; |
| 176 | |
| 177 | adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; |
| 178 | adapter->flags |= IXGBE_FLAG_RSS_ENABLED; |
| 179 | ixgbe_init_interrupt_scheme(adapter); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 180 | if (netif_running(netdev)) |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 181 | netdev->netdev_ops->ndo_open(netdev); |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 182 | } |
| 183 | } |
Don Skidmore | 1486a61 | 2008-12-21 20:09:50 -0800 | [diff] [blame] | 184 | out: |
| 185 | return err; |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev, |
| 189 | u8 *perm_addr) |
| 190 | { |
| 191 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 192 | int i; |
| 193 | |
| 194 | for (i = 0; i < netdev->addr_len; i++) |
| 195 | perm_addr[i] = adapter->hw.mac.perm_addr[i]; |
| 196 | } |
| 197 | |
| 198 | static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc, |
| 199 | u8 prio, u8 bwg_id, u8 bw_pct, |
| 200 | u8 up_map) |
| 201 | { |
| 202 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 203 | |
| 204 | if (prio != DCB_ATTR_VALUE_UNDEFINED) |
| 205 | adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type = prio; |
| 206 | if (bwg_id != DCB_ATTR_VALUE_UNDEFINED) |
| 207 | adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id = bwg_id; |
| 208 | if (bw_pct != DCB_ATTR_VALUE_UNDEFINED) |
| 209 | adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent = |
| 210 | bw_pct; |
| 211 | if (up_map != DCB_ATTR_VALUE_UNDEFINED) |
| 212 | adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap = |
| 213 | up_map; |
| 214 | |
| 215 | if ((adapter->temp_dcb_cfg.tc_config[tc].path[0].prio_type != |
| 216 | adapter->dcb_cfg.tc_config[tc].path[0].prio_type) || |
| 217 | (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_id != |
| 218 | adapter->dcb_cfg.tc_config[tc].path[0].bwg_id) || |
| 219 | (adapter->temp_dcb_cfg.tc_config[tc].path[0].bwg_percent != |
| 220 | adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent) || |
| 221 | (adapter->temp_dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap != |
| 222 | adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap)) |
| 223 | adapter->dcb_set_bitmap |= BIT_PG_TX; |
| 224 | } |
| 225 | |
| 226 | static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id, |
| 227 | u8 bw_pct) |
| 228 | { |
| 229 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 230 | |
| 231 | adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] = bw_pct; |
| 232 | |
| 233 | if (adapter->temp_dcb_cfg.bw_percentage[0][bwg_id] != |
| 234 | adapter->dcb_cfg.bw_percentage[0][bwg_id]) |
| 235 | adapter->dcb_set_bitmap |= BIT_PG_RX; |
| 236 | } |
| 237 | |
| 238 | static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc, |
| 239 | u8 prio, u8 bwg_id, u8 bw_pct, |
| 240 | u8 up_map) |
| 241 | { |
| 242 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 243 | |
| 244 | if (prio != DCB_ATTR_VALUE_UNDEFINED) |
| 245 | adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type = prio; |
| 246 | if (bwg_id != DCB_ATTR_VALUE_UNDEFINED) |
| 247 | adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id = bwg_id; |
| 248 | if (bw_pct != DCB_ATTR_VALUE_UNDEFINED) |
| 249 | adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent = |
| 250 | bw_pct; |
| 251 | if (up_map != DCB_ATTR_VALUE_UNDEFINED) |
| 252 | adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap = |
| 253 | up_map; |
| 254 | |
| 255 | if ((adapter->temp_dcb_cfg.tc_config[tc].path[1].prio_type != |
| 256 | adapter->dcb_cfg.tc_config[tc].path[1].prio_type) || |
| 257 | (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_id != |
| 258 | adapter->dcb_cfg.tc_config[tc].path[1].bwg_id) || |
| 259 | (adapter->temp_dcb_cfg.tc_config[tc].path[1].bwg_percent != |
| 260 | adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent) || |
| 261 | (adapter->temp_dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap != |
| 262 | adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap)) |
| 263 | adapter->dcb_set_bitmap |= BIT_PG_RX; |
| 264 | } |
| 265 | |
| 266 | static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id, |
| 267 | u8 bw_pct) |
| 268 | { |
| 269 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 270 | |
| 271 | adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] = bw_pct; |
| 272 | |
| 273 | if (adapter->temp_dcb_cfg.bw_percentage[1][bwg_id] != |
| 274 | adapter->dcb_cfg.bw_percentage[1][bwg_id]) |
| 275 | adapter->dcb_set_bitmap |= BIT_PG_RX; |
| 276 | } |
| 277 | |
| 278 | static void ixgbe_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, |
| 279 | u8 *prio, u8 *bwg_id, u8 *bw_pct, |
| 280 | u8 *up_map) |
| 281 | { |
| 282 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 283 | |
| 284 | *prio = adapter->dcb_cfg.tc_config[tc].path[0].prio_type; |
| 285 | *bwg_id = adapter->dcb_cfg.tc_config[tc].path[0].bwg_id; |
| 286 | *bw_pct = adapter->dcb_cfg.tc_config[tc].path[0].bwg_percent; |
| 287 | *up_map = adapter->dcb_cfg.tc_config[tc].path[0].up_to_tc_bitmap; |
| 288 | } |
| 289 | |
| 290 | static void ixgbe_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id, |
| 291 | u8 *bw_pct) |
| 292 | { |
| 293 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 294 | |
| 295 | *bw_pct = adapter->dcb_cfg.bw_percentage[0][bwg_id]; |
| 296 | } |
| 297 | |
| 298 | static void ixgbe_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int tc, |
| 299 | u8 *prio, u8 *bwg_id, u8 *bw_pct, |
| 300 | u8 *up_map) |
| 301 | { |
| 302 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 303 | |
| 304 | *prio = adapter->dcb_cfg.tc_config[tc].path[1].prio_type; |
| 305 | *bwg_id = adapter->dcb_cfg.tc_config[tc].path[1].bwg_id; |
| 306 | *bw_pct = adapter->dcb_cfg.tc_config[tc].path[1].bwg_percent; |
| 307 | *up_map = adapter->dcb_cfg.tc_config[tc].path[1].up_to_tc_bitmap; |
| 308 | } |
| 309 | |
| 310 | static void ixgbe_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id, |
| 311 | u8 *bw_pct) |
| 312 | { |
| 313 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 314 | |
| 315 | *bw_pct = adapter->dcb_cfg.bw_percentage[1][bwg_id]; |
| 316 | } |
| 317 | |
| 318 | static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority, |
| 319 | u8 setting) |
| 320 | { |
| 321 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 322 | |
| 323 | adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc = setting; |
| 324 | if (adapter->temp_dcb_cfg.tc_config[priority].dcb_pfc != |
| 325 | adapter->dcb_cfg.tc_config[priority].dcb_pfc) |
| 326 | adapter->dcb_set_bitmap |= BIT_PFC; |
| 327 | } |
| 328 | |
| 329 | static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, |
| 330 | u8 *setting) |
| 331 | { |
| 332 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 333 | |
| 334 | *setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc; |
| 335 | } |
| 336 | |
| 337 | static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) |
| 338 | { |
| 339 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 340 | int ret; |
| 341 | |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 342 | adapter->dcb_set_bitmap &= ~BIT_BCN; /* no set for BCN */ |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 343 | if (!adapter->dcb_set_bitmap) |
| 344 | return 1; |
| 345 | |
| 346 | while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) |
| 347 | msleep(1); |
| 348 | |
| 349 | if (netif_running(netdev)) |
| 350 | ixgbe_down(adapter); |
| 351 | |
| 352 | ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, |
| 353 | adapter->ring_feature[RING_F_DCB].indices); |
| 354 | if (ret) { |
| 355 | clear_bit(__IXGBE_RESETTING, &adapter->state); |
| 356 | return ret; |
| 357 | } |
| 358 | |
| 359 | if (netif_running(netdev)) |
| 360 | ixgbe_up(adapter); |
| 361 | |
| 362 | adapter->dcb_set_bitmap = 0x00; |
| 363 | clear_bit(__IXGBE_RESETTING, &adapter->state); |
| 364 | return ret; |
| 365 | } |
| 366 | |
Alexander Duyck | 4613218 | 2008-11-20 21:05:08 -0800 | [diff] [blame] | 367 | static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap) |
| 368 | { |
| 369 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 370 | u8 rval = 0; |
| 371 | |
| 372 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 373 | switch (capid) { |
| 374 | case DCB_CAP_ATTR_PG: |
| 375 | *cap = true; |
| 376 | break; |
| 377 | case DCB_CAP_ATTR_PFC: |
| 378 | *cap = true; |
| 379 | break; |
| 380 | case DCB_CAP_ATTR_UP2TC: |
| 381 | *cap = false; |
| 382 | break; |
| 383 | case DCB_CAP_ATTR_PG_TCS: |
| 384 | *cap = 0x80; |
| 385 | break; |
| 386 | case DCB_CAP_ATTR_PFC_TCS: |
| 387 | *cap = 0x80; |
| 388 | break; |
| 389 | case DCB_CAP_ATTR_GSP: |
| 390 | *cap = true; |
| 391 | break; |
| 392 | case DCB_CAP_ATTR_BCN: |
| 393 | *cap = false; |
| 394 | break; |
| 395 | default: |
| 396 | rval = -EINVAL; |
| 397 | break; |
| 398 | } |
| 399 | } else { |
| 400 | rval = -EINVAL; |
| 401 | } |
| 402 | |
| 403 | return rval; |
| 404 | } |
| 405 | |
Alexander Duyck | 33dbabc | 2008-11-20 21:08:19 -0800 | [diff] [blame] | 406 | static u8 ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) |
| 407 | { |
| 408 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 409 | u8 rval = 0; |
| 410 | |
| 411 | if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { |
| 412 | switch (tcid) { |
| 413 | case DCB_NUMTCS_ATTR_PG: |
| 414 | *num = MAX_TRAFFIC_CLASS; |
| 415 | break; |
| 416 | case DCB_NUMTCS_ATTR_PFC: |
| 417 | *num = MAX_TRAFFIC_CLASS; |
| 418 | break; |
| 419 | default: |
| 420 | rval = -EINVAL; |
| 421 | break; |
| 422 | } |
| 423 | } else { |
| 424 | rval = -EINVAL; |
| 425 | } |
| 426 | |
| 427 | return rval; |
| 428 | } |
| 429 | |
| 430 | static u8 ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num) |
| 431 | { |
| 432 | return -EINVAL; |
| 433 | } |
| 434 | |
Alexander Duyck | 0eb3aa9 | 2008-11-20 21:09:23 -0800 | [diff] [blame] | 435 | static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev) |
| 436 | { |
| 437 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 438 | |
| 439 | return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED); |
| 440 | } |
| 441 | |
| 442 | static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state) |
| 443 | { |
| 444 | return; |
| 445 | } |
| 446 | |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 447 | static void ixgbe_dcbnl_getbcnrp(struct net_device *netdev, int priority, |
| 448 | u8 *setting) |
| 449 | { |
| 450 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 451 | |
| 452 | *setting = adapter->dcb_cfg.bcn.rp_admin_mode[priority]; |
| 453 | } |
| 454 | |
| 455 | |
| 456 | static void ixgbe_dcbnl_getbcncfg(struct net_device *netdev, int enum_index, |
| 457 | u32 *setting) |
| 458 | { |
| 459 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 460 | |
| 461 | switch (enum_index) { |
Don Skidmore | f4314e8 | 2008-12-21 20:10:29 -0800 | [diff] [blame] | 462 | case DCB_BCN_ATTR_BCNA_0: |
| 463 | *setting = adapter->dcb_cfg.bcn.bcna_option[0]; |
| 464 | break; |
| 465 | case DCB_BCN_ATTR_BCNA_1: |
| 466 | *setting = adapter->dcb_cfg.bcn.bcna_option[1]; |
| 467 | break; |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 468 | case DCB_BCN_ATTR_ALPHA: |
| 469 | *setting = adapter->dcb_cfg.bcn.rp_alpha; |
| 470 | break; |
| 471 | case DCB_BCN_ATTR_BETA: |
| 472 | *setting = adapter->dcb_cfg.bcn.rp_beta; |
| 473 | break; |
| 474 | case DCB_BCN_ATTR_GD: |
| 475 | *setting = adapter->dcb_cfg.bcn.rp_gd; |
| 476 | break; |
| 477 | case DCB_BCN_ATTR_GI: |
| 478 | *setting = adapter->dcb_cfg.bcn.rp_gi; |
| 479 | break; |
| 480 | case DCB_BCN_ATTR_TMAX: |
| 481 | *setting = adapter->dcb_cfg.bcn.rp_tmax; |
| 482 | break; |
| 483 | case DCB_BCN_ATTR_TD: |
| 484 | *setting = adapter->dcb_cfg.bcn.rp_td; |
| 485 | break; |
| 486 | case DCB_BCN_ATTR_RMIN: |
| 487 | *setting = adapter->dcb_cfg.bcn.rp_rmin; |
| 488 | break; |
| 489 | case DCB_BCN_ATTR_W: |
| 490 | *setting = adapter->dcb_cfg.bcn.rp_w; |
| 491 | break; |
| 492 | case DCB_BCN_ATTR_RD: |
| 493 | *setting = adapter->dcb_cfg.bcn.rp_rd; |
| 494 | break; |
| 495 | case DCB_BCN_ATTR_RU: |
| 496 | *setting = adapter->dcb_cfg.bcn.rp_ru; |
| 497 | break; |
| 498 | case DCB_BCN_ATTR_WRTT: |
| 499 | *setting = adapter->dcb_cfg.bcn.rp_wrtt; |
| 500 | break; |
| 501 | case DCB_BCN_ATTR_RI: |
| 502 | *setting = adapter->dcb_cfg.bcn.rp_ri; |
| 503 | break; |
| 504 | default: |
| 505 | *setting = -1; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | static void ixgbe_dcbnl_setbcnrp(struct net_device *netdev, int priority, |
| 510 | u8 setting) |
| 511 | { |
| 512 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 513 | |
| 514 | adapter->temp_dcb_cfg.bcn.rp_admin_mode[priority] = setting; |
| 515 | |
| 516 | if (adapter->temp_dcb_cfg.bcn.rp_admin_mode[priority] != |
| 517 | adapter->dcb_cfg.bcn.rp_admin_mode[priority]) |
| 518 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 519 | } |
| 520 | |
| 521 | static void ixgbe_dcbnl_setbcncfg(struct net_device *netdev, int enum_index, |
| 522 | u32 setting) |
| 523 | { |
| 524 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
| 525 | |
| 526 | switch (enum_index) { |
Don Skidmore | f4314e8 | 2008-12-21 20:10:29 -0800 | [diff] [blame] | 527 | case DCB_BCN_ATTR_BCNA_0: |
| 528 | adapter->temp_dcb_cfg.bcn.bcna_option[0] = setting; |
| 529 | if (adapter->temp_dcb_cfg.bcn.bcna_option[0] != |
| 530 | adapter->dcb_cfg.bcn.bcna_option[0]) |
| 531 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 532 | break; |
| 533 | case DCB_BCN_ATTR_BCNA_1: |
| 534 | adapter->temp_dcb_cfg.bcn.bcna_option[1] = setting; |
| 535 | if (adapter->temp_dcb_cfg.bcn.bcna_option[1] != |
| 536 | adapter->dcb_cfg.bcn.bcna_option[1]) |
| 537 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 538 | break; |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 539 | case DCB_BCN_ATTR_ALPHA: |
| 540 | adapter->temp_dcb_cfg.bcn.rp_alpha = setting; |
| 541 | if (adapter->temp_dcb_cfg.bcn.rp_alpha != |
| 542 | adapter->dcb_cfg.bcn.rp_alpha) |
| 543 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 544 | break; |
| 545 | case DCB_BCN_ATTR_BETA: |
| 546 | adapter->temp_dcb_cfg.bcn.rp_beta = setting; |
| 547 | if (adapter->temp_dcb_cfg.bcn.rp_beta != |
| 548 | adapter->dcb_cfg.bcn.rp_beta) |
| 549 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 550 | break; |
| 551 | case DCB_BCN_ATTR_GD: |
| 552 | adapter->temp_dcb_cfg.bcn.rp_gd = setting; |
| 553 | if (adapter->temp_dcb_cfg.bcn.rp_gd != |
| 554 | adapter->dcb_cfg.bcn.rp_gd) |
| 555 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 556 | break; |
| 557 | case DCB_BCN_ATTR_GI: |
| 558 | adapter->temp_dcb_cfg.bcn.rp_gi = setting; |
| 559 | if (adapter->temp_dcb_cfg.bcn.rp_gi != |
| 560 | adapter->dcb_cfg.bcn.rp_gi) |
| 561 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 562 | break; |
| 563 | case DCB_BCN_ATTR_TMAX: |
| 564 | adapter->temp_dcb_cfg.bcn.rp_tmax = setting; |
| 565 | if (adapter->temp_dcb_cfg.bcn.rp_tmax != |
| 566 | adapter->dcb_cfg.bcn.rp_tmax) |
| 567 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 568 | break; |
| 569 | case DCB_BCN_ATTR_TD: |
| 570 | adapter->temp_dcb_cfg.bcn.rp_td = setting; |
| 571 | if (adapter->temp_dcb_cfg.bcn.rp_td != |
| 572 | adapter->dcb_cfg.bcn.rp_td) |
| 573 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 574 | break; |
| 575 | case DCB_BCN_ATTR_RMIN: |
| 576 | adapter->temp_dcb_cfg.bcn.rp_rmin = setting; |
| 577 | if (adapter->temp_dcb_cfg.bcn.rp_rmin != |
| 578 | adapter->dcb_cfg.bcn.rp_rmin) |
| 579 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 580 | break; |
| 581 | case DCB_BCN_ATTR_W: |
| 582 | adapter->temp_dcb_cfg.bcn.rp_w = setting; |
| 583 | if (adapter->temp_dcb_cfg.bcn.rp_w != |
| 584 | adapter->dcb_cfg.bcn.rp_w) |
| 585 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 586 | break; |
| 587 | case DCB_BCN_ATTR_RD: |
| 588 | adapter->temp_dcb_cfg.bcn.rp_rd = setting; |
| 589 | if (adapter->temp_dcb_cfg.bcn.rp_rd != |
| 590 | adapter->dcb_cfg.bcn.rp_rd) |
| 591 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 592 | break; |
| 593 | case DCB_BCN_ATTR_RU: |
| 594 | adapter->temp_dcb_cfg.bcn.rp_ru = setting; |
| 595 | if (adapter->temp_dcb_cfg.bcn.rp_ru != |
| 596 | adapter->dcb_cfg.bcn.rp_ru) |
| 597 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 598 | break; |
| 599 | case DCB_BCN_ATTR_WRTT: |
| 600 | adapter->temp_dcb_cfg.bcn.rp_wrtt = setting; |
| 601 | if (adapter->temp_dcb_cfg.bcn.rp_wrtt != |
| 602 | adapter->dcb_cfg.bcn.rp_wrtt) |
| 603 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 604 | break; |
| 605 | case DCB_BCN_ATTR_RI: |
| 606 | adapter->temp_dcb_cfg.bcn.rp_ri = setting; |
| 607 | if (adapter->temp_dcb_cfg.bcn.rp_ri != |
| 608 | adapter->dcb_cfg.bcn.rp_ri) |
| 609 | adapter->dcb_set_bitmap |= BIT_BCN; |
| 610 | break; |
| 611 | default: |
| 612 | break; |
| 613 | } |
| 614 | } |
| 615 | |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 616 | struct dcbnl_rtnl_ops dcbnl_ops = { |
| 617 | .getstate = ixgbe_dcbnl_get_state, |
| 618 | .setstate = ixgbe_dcbnl_set_state, |
| 619 | .getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr, |
| 620 | .setpgtccfgtx = ixgbe_dcbnl_set_pg_tc_cfg_tx, |
| 621 | .setpgbwgcfgtx = ixgbe_dcbnl_set_pg_bwg_cfg_tx, |
| 622 | .setpgtccfgrx = ixgbe_dcbnl_set_pg_tc_cfg_rx, |
| 623 | .setpgbwgcfgrx = ixgbe_dcbnl_set_pg_bwg_cfg_rx, |
| 624 | .getpgtccfgtx = ixgbe_dcbnl_get_pg_tc_cfg_tx, |
| 625 | .getpgbwgcfgtx = ixgbe_dcbnl_get_pg_bwg_cfg_tx, |
| 626 | .getpgtccfgrx = ixgbe_dcbnl_get_pg_tc_cfg_rx, |
| 627 | .getpgbwgcfgrx = ixgbe_dcbnl_get_pg_bwg_cfg_rx, |
| 628 | .setpfccfg = ixgbe_dcbnl_set_pfc_cfg, |
| 629 | .getpfccfg = ixgbe_dcbnl_get_pfc_cfg, |
Alexander Duyck | 4613218 | 2008-11-20 21:05:08 -0800 | [diff] [blame] | 630 | .setall = ixgbe_dcbnl_set_all, |
Alexander Duyck | 33dbabc | 2008-11-20 21:08:19 -0800 | [diff] [blame] | 631 | .getcap = ixgbe_dcbnl_getcap, |
| 632 | .getnumtcs = ixgbe_dcbnl_getnumtcs, |
Alexander Duyck | 0eb3aa9 | 2008-11-20 21:09:23 -0800 | [diff] [blame] | 633 | .setnumtcs = ixgbe_dcbnl_setnumtcs, |
| 634 | .getpfcstate = ixgbe_dcbnl_getpfcstate, |
Alexander Duyck | 859ee3c | 2008-11-20 21:10:23 -0800 | [diff] [blame] | 635 | .setpfcstate = ixgbe_dcbnl_setpfcstate, |
| 636 | .getbcncfg = ixgbe_dcbnl_getbcncfg, |
| 637 | .getbcnrp = ixgbe_dcbnl_getbcnrp, |
| 638 | .setbcncfg = ixgbe_dcbnl_setbcncfg, |
| 639 | .setbcnrp = ixgbe_dcbnl_setbcnrp |
Alexander Duyck | 2f90b86 | 2008-11-20 20:52:10 -0800 | [diff] [blame] | 640 | }; |
| 641 | |