1fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas/* 2fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * AMD 10Gb Ethernet driver 3fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 4fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * This file is available to you under your choice of the following two 5fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * licenses: 6fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 7fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * License 1: GPLv2 8fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 9fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Copyright (c) 2014 Advanced Micro Devices, Inc. 10fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 11fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * This file is free software; you may copy, redistribute and/or modify 12fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * it under the terms of the GNU General Public License as published by 13fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * the Free Software Foundation, either version 2 of the License, or (at 14fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * your option) any later version. 15fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 16fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * This file is distributed in the hope that it will be useful, but 17fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * WITHOUT ANY WARRANTY; without even the implied warranty of 18fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * General Public License for more details. 20fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 21fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * You should have received a copy of the GNU General Public License 22fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * along with this program. If not, see <http://www.gnu.org/licenses/>. 23fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 24fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * This file incorporates work covered by the following copyright and 25fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * permission notice: 26fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * The Synopsys DWC ETHER XGMAC Software Driver and documentation 27fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 28fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Inc. unless otherwise expressly agreed to in writing between Synopsys 29fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * and you. 30fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 31fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * The Software IS NOT an item of Licensed Software or Licensed Product 32fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * under any End User Software License Agreement or Agreement for Licensed 33fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Product with Synopsys or any supplement thereto. Permission is hereby 34fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * granted, free of charge, to any person obtaining a copy of this software 35fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * annotated with this license and the Software, to deal in the Software 36fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * without restriction, including without limitation the rights to use, 37fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 38fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * of the Software, and to permit persons to whom the Software is furnished 39fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * to do so, subject to the following conditions: 40fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 41fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * The above copyright notice and this permission notice shall be included 42fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * in all copies or substantial portions of the Software. 43fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 44fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 45fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 46fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 48fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 49fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 50fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 51fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 52fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 53fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 54fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * THE POSSIBILITY OF SUCH DAMAGE. 55fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 56fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 57fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * License 2: Modified BSD 58fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 59fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Copyright (c) 2014 Advanced Micro Devices, Inc. 60fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * All rights reserved. 61fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 62fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Redistribution and use in source and binary forms, with or without 63fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * modification, are permitted provided that the following conditions are met: 64fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * * Redistributions of source code must retain the above copyright 65fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * notice, this list of conditions and the following disclaimer. 66fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * * Redistributions in binary form must reproduce the above copyright 67fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * notice, this list of conditions and the following disclaimer in the 68fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * documentation and/or other materials provided with the distribution. 69fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * * Neither the name of Advanced Micro Devices, Inc. nor the 70fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * names of its contributors may be used to endorse or promote products 71fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * derived from this software without specific prior written permission. 72fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 73fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 74fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 75fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 76fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 77fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 78fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 79fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 80fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 81fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 82fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 83fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 84fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * This file incorporates work covered by the following copyright and 85fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * permission notice: 86fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * The Synopsys DWC ETHER XGMAC Software Driver and documentation 87fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 88fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Inc. unless otherwise expressly agreed to in writing between Synopsys 89fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * and you. 90fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 91fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * The Software IS NOT an item of Licensed Software or Licensed Product 92fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * under any End User Software License Agreement or Agreement for Licensed 93fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * Product with Synopsys or any supplement thereto. Permission is hereby 94fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * granted, free of charge, to any person obtaining a copy of this software 95fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * annotated with this license and the Software, to deal in the Software 96fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * without restriction, including without limitation the rights to use, 97fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 98fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * of the Software, and to permit persons to whom the Software is furnished 99fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * to do so, subject to the following conditions: 100fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 101fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * The above copyright notice and this permission notice shall be included 102fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * in all copies or substantial portions of the Software. 103fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * 104fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 105fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 106fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 107fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 108fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 109fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 110fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 111fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 112fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 113fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 114fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas * THE POSSIBILITY OF SUCH DAMAGE. 115fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas */ 116fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 117fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas#include <linux/netdevice.h> 118fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas#include <net/dcbnl.h> 119fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 120fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas#include "xgbe.h" 121fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas#include "xgbe-common.h" 122fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 123fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic int xgbe_dcb_ieee_getets(struct net_device *netdev, 124fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct ieee_ets *ets) 125fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 126fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct xgbe_prv_data *pdata = netdev_priv(netdev); 127fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 128fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas /* Set number of supported traffic classes */ 129fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas ets->ets_cap = pdata->hw_feat.tc_cnt; 130fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 131fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (pdata->ets) { 132fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas ets->cbs = pdata->ets->cbs; 133fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas memcpy(ets->tc_tx_bw, pdata->ets->tc_tx_bw, 134fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas sizeof(ets->tc_tx_bw)); 135fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas memcpy(ets->tc_tsa, pdata->ets->tc_tsa, 136fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas sizeof(ets->tc_tsa)); 137fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas memcpy(ets->prio_tc, pdata->ets->prio_tc, 138fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas sizeof(ets->prio_tc)); 139fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas } 140fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 141fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 0; 142fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 143fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 144fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic int xgbe_dcb_ieee_setets(struct net_device *netdev, 145fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct ieee_ets *ets) 146fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 147fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct xgbe_prv_data *pdata = netdev_priv(netdev); 148fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas unsigned int i, tc_ets, tc_ets_weight; 149fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 150fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas tc_ets = 0; 151fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas tc_ets_weight = 0; 152fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 153fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas DBGPR(" TC%u: tx_bw=%hhu, rx_bw=%hhu, tsa=%hhu\n", i, 154fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas ets->tc_tx_bw[i], ets->tc_rx_bw[i], ets->tc_tsa[i]); 155fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas DBGPR(" PRIO%u: TC=%hhu\n", i, ets->prio_tc[i]); 156fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 157fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) && 158fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas (i >= pdata->hw_feat.tc_cnt)) 159fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return -EINVAL; 160fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 161fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (ets->prio_tc[i] >= pdata->hw_feat.tc_cnt) 162fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return -EINVAL; 163fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 164fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas switch (ets->tc_tsa[i]) { 165fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas case IEEE_8021QAZ_TSA_STRICT: 166fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas break; 167fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas case IEEE_8021QAZ_TSA_ETS: 168fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas tc_ets = 1; 169fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas tc_ets_weight += ets->tc_tx_bw[i]; 170fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas break; 171fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 172fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas default: 173fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return -EINVAL; 174fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas } 175fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas } 176fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 177fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas /* Weights must add up to 100% */ 178fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (tc_ets && (tc_ets_weight != 100)) 179fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return -EINVAL; 180fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 181fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (!pdata->ets) { 182fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pdata->ets = devm_kzalloc(pdata->dev, sizeof(*pdata->ets), 183fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas GFP_KERNEL); 184fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (!pdata->ets) 185fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return -ENOMEM; 186fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas } 187fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 188fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas memcpy(pdata->ets, ets, sizeof(*pdata->ets)); 189fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 190fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pdata->hw_if.config_dcb_tc(pdata); 191fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 192fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 0; 193fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 194fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 195fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic int xgbe_dcb_ieee_getpfc(struct net_device *netdev, 196fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct ieee_pfc *pfc) 197fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 198fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct xgbe_prv_data *pdata = netdev_priv(netdev); 199fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 200fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas /* Set number of supported PFC traffic classes */ 201fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pfc->pfc_cap = pdata->hw_feat.tc_cnt; 202fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 203fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (pdata->pfc) { 204fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pfc->pfc_en = pdata->pfc->pfc_en; 205fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pfc->mbc = pdata->pfc->mbc; 206fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pfc->delay = pdata->pfc->delay; 207fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas } 208fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 209fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 0; 210fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 211fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 212fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic int xgbe_dcb_ieee_setpfc(struct net_device *netdev, 213fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct ieee_pfc *pfc) 214fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 215fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas struct xgbe_prv_data *pdata = netdev_priv(netdev); 216fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 217fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas DBGPR(" cap=%hhu, en=%hhx, mbc=%hhu, delay=%hhu\n", 218fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pfc->pfc_cap, pfc->pfc_en, pfc->mbc, pfc->delay); 219fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 220fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (!pdata->pfc) { 221fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pdata->pfc = devm_kzalloc(pdata->dev, sizeof(*pdata->pfc), 222fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas GFP_KERNEL); 223fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (!pdata->pfc) 224fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return -ENOMEM; 225fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas } 226fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 227fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas memcpy(pdata->pfc, pfc, sizeof(*pdata->pfc)); 228fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 229fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas pdata->hw_if.config_dcb_pfc(pdata); 230fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 231fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 0; 232fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 233fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 234fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic u8 xgbe_dcb_getdcbx(struct net_device *netdev) 235fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 236fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE; 237fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 238fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 239fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic u8 xgbe_dcb_setdcbx(struct net_device *netdev, u8 dcbx) 240fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 241fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas u8 support = xgbe_dcb_getdcbx(netdev); 242fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 243fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas DBGPR(" DCBX=%#hhx\n", dcbx); 244fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 245fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if (dcbx & ~support) 246fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 1; 247fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 248fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas if ((dcbx & support) != support) 249fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 1; 250fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 251fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return 0; 252fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 253fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 254fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasstatic const struct dcbnl_rtnl_ops xgbe_dcbnl_ops = { 255fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas /* IEEE 802.1Qaz std */ 256fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas .ieee_getets = xgbe_dcb_ieee_getets, 257fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas .ieee_setets = xgbe_dcb_ieee_setets, 258fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas .ieee_getpfc = xgbe_dcb_ieee_getpfc, 259fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas .ieee_setpfc = xgbe_dcb_ieee_setpfc, 260fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 261fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas /* DCBX configuration */ 262fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas .getdcbx = xgbe_dcb_getdcbx, 263fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas .setdcbx = xgbe_dcb_setdcbx, 264fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas}; 265fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas 266fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomasconst struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void) 267fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas{ 268fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas return &xgbe_dcbnl_ops; 269fca2d99428473884e67ef8ea1586e58151ed6ac3Lendacky, Thomas} 270