Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1 | /* |
| 2 | * AMD 10Gb Ethernet driver |
| 3 | * |
| 4 | * This file is available to you under your choice of the following two |
| 5 | * licenses: |
| 6 | * |
| 7 | * License 1: GPLv2 |
| 8 | * |
| 9 | * Copyright (c) 2014 Advanced Micro Devices, Inc. |
| 10 | * |
| 11 | * This file is free software; you may copy, redistribute and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation, either version 2 of the License, or (at |
| 14 | * your option) any later version. |
| 15 | * |
| 16 | * This file is distributed in the hope that it will be useful, but |
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | * |
| 24 | * This file incorporates work covered by the following copyright and |
| 25 | * permission notice: |
| 26 | * The Synopsys DWC ETHER XGMAC Software Driver and documentation |
| 27 | * (hereinafter "Software") is an unsupported proprietary work of Synopsys, |
| 28 | * Inc. unless otherwise expressly agreed to in writing between Synopsys |
| 29 | * and you. |
| 30 | * |
| 31 | * The Software IS NOT an item of Licensed Software or Licensed Product |
| 32 | * under any End User Software License Agreement or Agreement for Licensed |
| 33 | * Product with Synopsys or any supplement thereto. Permission is hereby |
| 34 | * granted, free of charge, to any person obtaining a copy of this software |
| 35 | * annotated with this license and the Software, to deal in the Software |
| 36 | * without restriction, including without limitation the rights to use, |
| 37 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 38 | * of the Software, and to permit persons to whom the Software is furnished |
| 39 | * to do so, subject to the following conditions: |
| 40 | * |
| 41 | * The above copyright notice and this permission notice shall be included |
| 42 | * in all copies or substantial portions of the Software. |
| 43 | * |
| 44 | * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" |
| 45 | * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 46 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 47 | * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS |
| 48 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 49 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 50 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 51 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 52 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 53 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 54 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 55 | * |
| 56 | * |
| 57 | * License 2: Modified BSD |
| 58 | * |
| 59 | * Copyright (c) 2014 Advanced Micro Devices, Inc. |
| 60 | * All rights reserved. |
| 61 | * |
| 62 | * Redistribution and use in source and binary forms, with or without |
| 63 | * modification, are permitted provided that the following conditions are met: |
| 64 | * * Redistributions of source code must retain the above copyright |
| 65 | * notice, this list of conditions and the following disclaimer. |
| 66 | * * Redistributions in binary form must reproduce the above copyright |
| 67 | * notice, this list of conditions and the following disclaimer in the |
| 68 | * documentation and/or other materials provided with the distribution. |
| 69 | * * Neither the name of Advanced Micro Devices, Inc. nor the |
| 70 | * names of its contributors may be used to endorse or promote products |
| 71 | * derived from this software without specific prior written permission. |
| 72 | * |
| 73 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 74 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 75 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 76 | * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
| 77 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 78 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 79 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 80 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 81 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 82 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 83 | * |
| 84 | * This file incorporates work covered by the following copyright and |
| 85 | * permission notice: |
| 86 | * The Synopsys DWC ETHER XGMAC Software Driver and documentation |
| 87 | * (hereinafter "Software") is an unsupported proprietary work of Synopsys, |
| 88 | * Inc. unless otherwise expressly agreed to in writing between Synopsys |
| 89 | * and you. |
| 90 | * |
| 91 | * The Software IS NOT an item of Licensed Software or Licensed Product |
| 92 | * under any End User Software License Agreement or Agreement for Licensed |
| 93 | * Product with Synopsys or any supplement thereto. Permission is hereby |
| 94 | * granted, free of charge, to any person obtaining a copy of this software |
| 95 | * annotated with this license and the Software, to deal in the Software |
| 96 | * without restriction, including without limitation the rights to use, |
| 97 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 98 | * of the Software, and to permit persons to whom the Software is furnished |
| 99 | * to do so, subject to the following conditions: |
| 100 | * |
| 101 | * The above copyright notice and this permission notice shall be included |
| 102 | * in all copies or substantial portions of the Software. |
| 103 | * |
| 104 | * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" |
| 105 | * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 106 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 107 | * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS |
| 108 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 109 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 110 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 111 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 112 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 113 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 114 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 115 | */ |
| 116 | |
| 117 | #include <linux/phy.h> |
| 118 | #include <linux/clk.h> |
Lendacky, Thomas | 801c62d | 2014-06-24 16:19:24 -0500 | [diff] [blame] | 119 | #include <linux/bitrev.h> |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 120 | #include <linux/crc32.h> |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 121 | |
| 122 | #include "xgbe.h" |
| 123 | #include "xgbe-common.h" |
| 124 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 125 | static unsigned int xgbe_usec_to_riwt(struct xgbe_prv_data *pdata, |
| 126 | unsigned int usec) |
| 127 | { |
| 128 | unsigned long rate; |
| 129 | unsigned int ret; |
| 130 | |
| 131 | DBGPR("-->xgbe_usec_to_riwt\n"); |
| 132 | |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 133 | rate = clk_get_rate(pdata->sysclk); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 134 | |
| 135 | /* |
| 136 | * Convert the input usec value to the watchdog timer value. Each |
| 137 | * watchdog timer value is equivalent to 256 clock cycles. |
| 138 | * Calculate the required value as: |
| 139 | * ( usec * ( system_clock_mhz / 10^6 ) / 256 |
| 140 | */ |
| 141 | ret = (usec * (rate / 1000000)) / 256; |
| 142 | |
| 143 | DBGPR("<--xgbe_usec_to_riwt\n"); |
| 144 | |
| 145 | return ret; |
| 146 | } |
| 147 | |
| 148 | static unsigned int xgbe_riwt_to_usec(struct xgbe_prv_data *pdata, |
| 149 | unsigned int riwt) |
| 150 | { |
| 151 | unsigned long rate; |
| 152 | unsigned int ret; |
| 153 | |
| 154 | DBGPR("-->xgbe_riwt_to_usec\n"); |
| 155 | |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 156 | rate = clk_get_rate(pdata->sysclk); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 157 | |
| 158 | /* |
| 159 | * Convert the input watchdog timer value to the usec value. Each |
| 160 | * watchdog timer value is equivalent to 256 clock cycles. |
| 161 | * Calculate the required value as: |
| 162 | * ( riwt * 256 ) / ( system_clock_mhz / 10^6 ) |
| 163 | */ |
| 164 | ret = (riwt * 256) / (rate / 1000000); |
| 165 | |
| 166 | DBGPR("<--xgbe_riwt_to_usec\n"); |
| 167 | |
| 168 | return ret; |
| 169 | } |
| 170 | |
| 171 | static int xgbe_config_pblx8(struct xgbe_prv_data *pdata) |
| 172 | { |
| 173 | struct xgbe_channel *channel; |
| 174 | unsigned int i; |
| 175 | |
| 176 | channel = pdata->channel; |
| 177 | for (i = 0; i < pdata->channel_count; i++, channel++) |
| 178 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_CR, PBLX8, |
| 179 | pdata->pblx8); |
| 180 | |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | static int xgbe_get_tx_pbl_val(struct xgbe_prv_data *pdata) |
| 185 | { |
| 186 | return XGMAC_DMA_IOREAD_BITS(pdata->channel, DMA_CH_TCR, PBL); |
| 187 | } |
| 188 | |
| 189 | static int xgbe_config_tx_pbl_val(struct xgbe_prv_data *pdata) |
| 190 | { |
| 191 | struct xgbe_channel *channel; |
| 192 | unsigned int i; |
| 193 | |
| 194 | channel = pdata->channel; |
| 195 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 196 | if (!channel->tx_ring) |
| 197 | break; |
| 198 | |
| 199 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, PBL, |
| 200 | pdata->tx_pbl); |
| 201 | } |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | static int xgbe_get_rx_pbl_val(struct xgbe_prv_data *pdata) |
| 207 | { |
| 208 | return XGMAC_DMA_IOREAD_BITS(pdata->channel, DMA_CH_RCR, PBL); |
| 209 | } |
| 210 | |
| 211 | static int xgbe_config_rx_pbl_val(struct xgbe_prv_data *pdata) |
| 212 | { |
| 213 | struct xgbe_channel *channel; |
| 214 | unsigned int i; |
| 215 | |
| 216 | channel = pdata->channel; |
| 217 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 218 | if (!channel->rx_ring) |
| 219 | break; |
| 220 | |
| 221 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RCR, PBL, |
| 222 | pdata->rx_pbl); |
| 223 | } |
| 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
| 228 | static int xgbe_config_osp_mode(struct xgbe_prv_data *pdata) |
| 229 | { |
| 230 | struct xgbe_channel *channel; |
| 231 | unsigned int i; |
| 232 | |
| 233 | channel = pdata->channel; |
| 234 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 235 | if (!channel->tx_ring) |
| 236 | break; |
| 237 | |
| 238 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, OSP, |
| 239 | pdata->tx_osp_mode); |
| 240 | } |
| 241 | |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | static int xgbe_config_rsf_mode(struct xgbe_prv_data *pdata, unsigned int val) |
| 246 | { |
| 247 | unsigned int i; |
| 248 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 249 | for (i = 0; i < pdata->rx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 250 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RSF, val); |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | static int xgbe_config_tsf_mode(struct xgbe_prv_data *pdata, unsigned int val) |
| 256 | { |
| 257 | unsigned int i; |
| 258 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 259 | for (i = 0; i < pdata->tx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 260 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TSF, val); |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | static int xgbe_config_rx_threshold(struct xgbe_prv_data *pdata, |
| 266 | unsigned int val) |
| 267 | { |
| 268 | unsigned int i; |
| 269 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 270 | for (i = 0; i < pdata->rx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 271 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RTC, val); |
| 272 | |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | static int xgbe_config_tx_threshold(struct xgbe_prv_data *pdata, |
| 277 | unsigned int val) |
| 278 | { |
| 279 | unsigned int i; |
| 280 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 281 | for (i = 0; i < pdata->tx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 282 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TTC, val); |
| 283 | |
| 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | static int xgbe_config_rx_coalesce(struct xgbe_prv_data *pdata) |
| 288 | { |
| 289 | struct xgbe_channel *channel; |
| 290 | unsigned int i; |
| 291 | |
| 292 | channel = pdata->channel; |
| 293 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 294 | if (!channel->rx_ring) |
| 295 | break; |
| 296 | |
| 297 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RIWT, RWT, |
| 298 | pdata->rx_riwt); |
| 299 | } |
| 300 | |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | static int xgbe_config_tx_coalesce(struct xgbe_prv_data *pdata) |
| 305 | { |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | static void xgbe_config_rx_buffer_size(struct xgbe_prv_data *pdata) |
| 310 | { |
| 311 | struct xgbe_channel *channel; |
| 312 | unsigned int i; |
| 313 | |
| 314 | channel = pdata->channel; |
| 315 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 316 | if (!channel->rx_ring) |
| 317 | break; |
| 318 | |
| 319 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RCR, RBSZ, |
| 320 | pdata->rx_buf_size); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | static void xgbe_config_tso_mode(struct xgbe_prv_data *pdata) |
| 325 | { |
| 326 | struct xgbe_channel *channel; |
| 327 | unsigned int i; |
| 328 | |
| 329 | channel = pdata->channel; |
| 330 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 331 | if (!channel->tx_ring) |
| 332 | break; |
| 333 | |
| 334 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, TSE, 1); |
| 335 | } |
| 336 | } |
| 337 | |
Lendacky, Thomas | 174fd25 | 2014-11-04 16:06:50 -0600 | [diff] [blame] | 338 | static void xgbe_config_sph_mode(struct xgbe_prv_data *pdata) |
| 339 | { |
| 340 | struct xgbe_channel *channel; |
| 341 | unsigned int i; |
| 342 | |
| 343 | channel = pdata->channel; |
| 344 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 345 | if (!channel->rx_ring) |
| 346 | break; |
| 347 | |
| 348 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_CR, SPH, 1); |
| 349 | } |
| 350 | |
| 351 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, HDSMS, XGBE_SPH_HDSMS_SIZE); |
| 352 | } |
| 353 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 354 | static int xgbe_disable_tx_flow_control(struct xgbe_prv_data *pdata) |
| 355 | { |
| 356 | unsigned int max_q_count, q_count; |
| 357 | unsigned int reg, reg_val; |
| 358 | unsigned int i; |
| 359 | |
| 360 | /* Clear MTL flow control */ |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 361 | for (i = 0; i < pdata->rx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 362 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, EHFC, 0); |
| 363 | |
| 364 | /* Clear MAC flow control */ |
| 365 | max_q_count = XGMAC_MAX_FLOW_CONTROL_QUEUES; |
Lendacky, Thomas | 9fc69af | 2014-08-29 13:17:08 -0500 | [diff] [blame] | 366 | q_count = min_t(unsigned int, pdata->tx_q_count, max_q_count); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 367 | reg = MAC_Q0TFCR; |
| 368 | for (i = 0; i < q_count; i++) { |
| 369 | reg_val = XGMAC_IOREAD(pdata, reg); |
| 370 | XGMAC_SET_BITS(reg_val, MAC_Q0TFCR, TFE, 0); |
| 371 | XGMAC_IOWRITE(pdata, reg, reg_val); |
| 372 | |
| 373 | reg += MAC_QTFCR_INC; |
| 374 | } |
| 375 | |
| 376 | return 0; |
| 377 | } |
| 378 | |
| 379 | static int xgbe_enable_tx_flow_control(struct xgbe_prv_data *pdata) |
| 380 | { |
| 381 | unsigned int max_q_count, q_count; |
| 382 | unsigned int reg, reg_val; |
| 383 | unsigned int i; |
| 384 | |
| 385 | /* Set MTL flow control */ |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 386 | for (i = 0; i < pdata->rx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 387 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, EHFC, 1); |
| 388 | |
| 389 | /* Set MAC flow control */ |
| 390 | max_q_count = XGMAC_MAX_FLOW_CONTROL_QUEUES; |
Lendacky, Thomas | 9fc69af | 2014-08-29 13:17:08 -0500 | [diff] [blame] | 391 | q_count = min_t(unsigned int, pdata->tx_q_count, max_q_count); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 392 | reg = MAC_Q0TFCR; |
| 393 | for (i = 0; i < q_count; i++) { |
| 394 | reg_val = XGMAC_IOREAD(pdata, reg); |
| 395 | |
| 396 | /* Enable transmit flow control */ |
| 397 | XGMAC_SET_BITS(reg_val, MAC_Q0TFCR, TFE, 1); |
| 398 | /* Set pause time */ |
| 399 | XGMAC_SET_BITS(reg_val, MAC_Q0TFCR, PT, 0xffff); |
| 400 | |
| 401 | XGMAC_IOWRITE(pdata, reg, reg_val); |
| 402 | |
| 403 | reg += MAC_QTFCR_INC; |
| 404 | } |
| 405 | |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | static int xgbe_disable_rx_flow_control(struct xgbe_prv_data *pdata) |
| 410 | { |
| 411 | XGMAC_IOWRITE_BITS(pdata, MAC_RFCR, RFE, 0); |
| 412 | |
| 413 | return 0; |
| 414 | } |
| 415 | |
| 416 | static int xgbe_enable_rx_flow_control(struct xgbe_prv_data *pdata) |
| 417 | { |
| 418 | XGMAC_IOWRITE_BITS(pdata, MAC_RFCR, RFE, 1); |
| 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | static int xgbe_config_tx_flow_control(struct xgbe_prv_data *pdata) |
| 424 | { |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 425 | struct ieee_pfc *pfc = pdata->pfc; |
| 426 | |
| 427 | if (pdata->tx_pause || (pfc && pfc->pfc_en)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 428 | xgbe_enable_tx_flow_control(pdata); |
| 429 | else |
| 430 | xgbe_disable_tx_flow_control(pdata); |
| 431 | |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | static int xgbe_config_rx_flow_control(struct xgbe_prv_data *pdata) |
| 436 | { |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 437 | struct ieee_pfc *pfc = pdata->pfc; |
| 438 | |
| 439 | if (pdata->rx_pause || (pfc && pfc->pfc_en)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 440 | xgbe_enable_rx_flow_control(pdata); |
| 441 | else |
| 442 | xgbe_disable_rx_flow_control(pdata); |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | static void xgbe_config_flow_control(struct xgbe_prv_data *pdata) |
| 448 | { |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 449 | struct ieee_pfc *pfc = pdata->pfc; |
| 450 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 451 | xgbe_config_tx_flow_control(pdata); |
| 452 | xgbe_config_rx_flow_control(pdata); |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 453 | |
| 454 | XGMAC_IOWRITE_BITS(pdata, MAC_RFCR, PFCE, |
| 455 | (pfc && pfc->pfc_en) ? 1 : 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | static void xgbe_enable_dma_interrupts(struct xgbe_prv_data *pdata) |
| 459 | { |
| 460 | struct xgbe_channel *channel; |
| 461 | unsigned int dma_ch_isr, dma_ch_ier; |
| 462 | unsigned int i; |
| 463 | |
| 464 | channel = pdata->channel; |
| 465 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 466 | /* Clear all the interrupts which are set */ |
| 467 | dma_ch_isr = XGMAC_DMA_IOREAD(channel, DMA_CH_SR); |
| 468 | XGMAC_DMA_IOWRITE(channel, DMA_CH_SR, dma_ch_isr); |
| 469 | |
| 470 | /* Clear all interrupt enable bits */ |
| 471 | dma_ch_ier = 0; |
| 472 | |
| 473 | /* Enable following interrupts |
| 474 | * NIE - Normal Interrupt Summary Enable |
| 475 | * AIE - Abnormal Interrupt Summary Enable |
| 476 | * FBEE - Fatal Bus Error Enable |
| 477 | */ |
| 478 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, NIE, 1); |
| 479 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, AIE, 1); |
| 480 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, FBEE, 1); |
| 481 | |
| 482 | if (channel->tx_ring) { |
| 483 | /* Enable the following Tx interrupts |
Lendacky, Thomas | 9227dc5 | 2014-11-04 16:06:56 -0600 | [diff] [blame^] | 484 | * TIE - Transmit Interrupt Enable (unless using |
| 485 | * per channel interrupts) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 486 | */ |
Lendacky, Thomas | 9227dc5 | 2014-11-04 16:06:56 -0600 | [diff] [blame^] | 487 | if (!pdata->per_channel_irq) |
| 488 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TIE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 489 | } |
| 490 | if (channel->rx_ring) { |
| 491 | /* Enable following Rx interrupts |
| 492 | * RBUE - Receive Buffer Unavailable Enable |
Lendacky, Thomas | 9227dc5 | 2014-11-04 16:06:56 -0600 | [diff] [blame^] | 493 | * RIE - Receive Interrupt Enable (unless using |
| 494 | * per channel interrupts) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 495 | */ |
| 496 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RBUE, 1); |
Lendacky, Thomas | 9227dc5 | 2014-11-04 16:06:56 -0600 | [diff] [blame^] | 497 | if (!pdata->per_channel_irq) |
| 498 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RIE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | XGMAC_DMA_IOWRITE(channel, DMA_CH_IER, dma_ch_ier); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | static void xgbe_enable_mtl_interrupts(struct xgbe_prv_data *pdata) |
| 506 | { |
| 507 | unsigned int mtl_q_isr; |
| 508 | unsigned int q_count, i; |
| 509 | |
| 510 | q_count = max(pdata->hw_feat.tx_q_cnt, pdata->hw_feat.rx_q_cnt); |
| 511 | for (i = 0; i < q_count; i++) { |
| 512 | /* Clear all the interrupts which are set */ |
| 513 | mtl_q_isr = XGMAC_MTL_IOREAD(pdata, i, MTL_Q_ISR); |
| 514 | XGMAC_MTL_IOWRITE(pdata, i, MTL_Q_ISR, mtl_q_isr); |
| 515 | |
| 516 | /* No MTL interrupts to be enabled */ |
Lendacky, Thomas | 91f8734 | 2014-07-02 13:04:34 -0500 | [diff] [blame] | 517 | XGMAC_MTL_IOWRITE(pdata, i, MTL_Q_IER, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | |
| 521 | static void xgbe_enable_mac_interrupts(struct xgbe_prv_data *pdata) |
| 522 | { |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 523 | unsigned int mac_ier = 0; |
| 524 | |
| 525 | /* Enable Timestamp interrupt */ |
| 526 | XGMAC_SET_BITS(mac_ier, MAC_IER, TSIE, 1); |
| 527 | |
| 528 | XGMAC_IOWRITE(pdata, MAC_IER, mac_ier); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 529 | |
| 530 | /* Enable all counter interrupts */ |
Lendacky, Thomas | a3ba7c9 | 2014-09-05 18:02:36 -0500 | [diff] [blame] | 531 | XGMAC_IOWRITE_BITS(pdata, MMC_RIER, ALL_INTERRUPTS, 0xffffffff); |
| 532 | XGMAC_IOWRITE_BITS(pdata, MMC_TIER, ALL_INTERRUPTS, 0xffffffff); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | static int xgbe_set_gmii_speed(struct xgbe_prv_data *pdata) |
| 536 | { |
| 537 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, SS, 0x3); |
| 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | static int xgbe_set_gmii_2500_speed(struct xgbe_prv_data *pdata) |
| 543 | { |
| 544 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, SS, 0x2); |
| 545 | |
| 546 | return 0; |
| 547 | } |
| 548 | |
| 549 | static int xgbe_set_xgmii_speed(struct xgbe_prv_data *pdata) |
| 550 | { |
| 551 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, SS, 0); |
| 552 | |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | static int xgbe_set_promiscuous_mode(struct xgbe_prv_data *pdata, |
| 557 | unsigned int enable) |
| 558 | { |
| 559 | unsigned int val = enable ? 1 : 0; |
| 560 | |
| 561 | if (XGMAC_IOREAD_BITS(pdata, MAC_PFR, PR) == val) |
| 562 | return 0; |
| 563 | |
| 564 | DBGPR(" %s promiscuous mode\n", enable ? "entering" : "leaving"); |
| 565 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, PR, val); |
| 566 | |
| 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | static int xgbe_set_all_multicast_mode(struct xgbe_prv_data *pdata, |
| 571 | unsigned int enable) |
| 572 | { |
| 573 | unsigned int val = enable ? 1 : 0; |
| 574 | |
| 575 | if (XGMAC_IOREAD_BITS(pdata, MAC_PFR, PM) == val) |
| 576 | return 0; |
| 577 | |
| 578 | DBGPR(" %s allmulti mode\n", enable ? "entering" : "leaving"); |
| 579 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, PM, val); |
| 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 584 | static void xgbe_set_mac_reg(struct xgbe_prv_data *pdata, |
| 585 | struct netdev_hw_addr *ha, unsigned int *mac_reg) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 586 | { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 587 | unsigned int mac_addr_hi, mac_addr_lo; |
| 588 | u8 *mac_addr; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 589 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 590 | mac_addr_lo = 0; |
| 591 | mac_addr_hi = 0; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 592 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 593 | if (ha) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 594 | mac_addr = (u8 *)&mac_addr_lo; |
| 595 | mac_addr[0] = ha->addr[0]; |
| 596 | mac_addr[1] = ha->addr[1]; |
| 597 | mac_addr[2] = ha->addr[2]; |
| 598 | mac_addr[3] = ha->addr[3]; |
| 599 | mac_addr = (u8 *)&mac_addr_hi; |
| 600 | mac_addr[0] = ha->addr[4]; |
| 601 | mac_addr[1] = ha->addr[5]; |
| 602 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 603 | DBGPR(" adding mac address %pM at 0x%04x\n", ha->addr, |
| 604 | *mac_reg); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 605 | |
| 606 | XGMAC_SET_BITS(mac_addr_hi, MAC_MACA1HR, AE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 607 | } |
| 608 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 609 | XGMAC_IOWRITE(pdata, *mac_reg, mac_addr_hi); |
| 610 | *mac_reg += MAC_MACA_INC; |
| 611 | XGMAC_IOWRITE(pdata, *mac_reg, mac_addr_lo); |
| 612 | *mac_reg += MAC_MACA_INC; |
| 613 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 614 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 615 | static void xgbe_set_mac_addn_addrs(struct xgbe_prv_data *pdata) |
| 616 | { |
| 617 | struct net_device *netdev = pdata->netdev; |
| 618 | struct netdev_hw_addr *ha; |
| 619 | unsigned int mac_reg; |
| 620 | unsigned int addn_macs; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 621 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 622 | mac_reg = MAC_MACA1HR; |
| 623 | addn_macs = pdata->hw_feat.addn_mac; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 624 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 625 | if (netdev_uc_count(netdev) > addn_macs) { |
| 626 | xgbe_set_promiscuous_mode(pdata, 1); |
| 627 | } else { |
| 628 | netdev_for_each_uc_addr(ha, netdev) { |
| 629 | xgbe_set_mac_reg(pdata, ha, &mac_reg); |
| 630 | addn_macs--; |
| 631 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 632 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 633 | if (netdev_mc_count(netdev) > addn_macs) { |
| 634 | xgbe_set_all_multicast_mode(pdata, 1); |
| 635 | } else { |
| 636 | netdev_for_each_mc_addr(ha, netdev) { |
| 637 | xgbe_set_mac_reg(pdata, ha, &mac_reg); |
| 638 | addn_macs--; |
| 639 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | |
| 643 | /* Clear remaining additional MAC address entries */ |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 644 | while (addn_macs--) |
| 645 | xgbe_set_mac_reg(pdata, NULL, &mac_reg); |
| 646 | } |
| 647 | |
| 648 | static void xgbe_set_mac_hash_table(struct xgbe_prv_data *pdata) |
| 649 | { |
| 650 | struct net_device *netdev = pdata->netdev; |
| 651 | struct netdev_hw_addr *ha; |
| 652 | unsigned int hash_reg; |
| 653 | unsigned int hash_table_shift, hash_table_count; |
| 654 | u32 hash_table[XGBE_MAC_HASH_TABLE_SIZE]; |
| 655 | u32 crc; |
| 656 | unsigned int i; |
| 657 | |
| 658 | hash_table_shift = 26 - (pdata->hw_feat.hash_table_size >> 7); |
| 659 | hash_table_count = pdata->hw_feat.hash_table_size / 32; |
| 660 | memset(hash_table, 0, sizeof(hash_table)); |
| 661 | |
| 662 | /* Build the MAC Hash Table register values */ |
| 663 | netdev_for_each_uc_addr(ha, netdev) { |
| 664 | crc = bitrev32(~crc32_le(~0, ha->addr, ETH_ALEN)); |
| 665 | crc >>= hash_table_shift; |
| 666 | hash_table[crc >> 5] |= (1 << (crc & 0x1f)); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 667 | } |
| 668 | |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 669 | netdev_for_each_mc_addr(ha, netdev) { |
| 670 | crc = bitrev32(~crc32_le(~0, ha->addr, ETH_ALEN)); |
| 671 | crc >>= hash_table_shift; |
| 672 | hash_table[crc >> 5] |= (1 << (crc & 0x1f)); |
| 673 | } |
| 674 | |
| 675 | /* Set the MAC Hash Table registers */ |
| 676 | hash_reg = MAC_HTR0; |
| 677 | for (i = 0; i < hash_table_count; i++) { |
| 678 | XGMAC_IOWRITE(pdata, hash_reg, hash_table[i]); |
| 679 | hash_reg += MAC_HTR_INC; |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | static int xgbe_add_mac_addresses(struct xgbe_prv_data *pdata) |
| 684 | { |
| 685 | if (pdata->hw_feat.hash_table_size) |
| 686 | xgbe_set_mac_hash_table(pdata); |
| 687 | else |
| 688 | xgbe_set_mac_addn_addrs(pdata); |
| 689 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | static int xgbe_set_mac_address(struct xgbe_prv_data *pdata, u8 *addr) |
| 694 | { |
| 695 | unsigned int mac_addr_hi, mac_addr_lo; |
| 696 | |
| 697 | mac_addr_hi = (addr[5] << 8) | (addr[4] << 0); |
| 698 | mac_addr_lo = (addr[3] << 24) | (addr[2] << 16) | |
| 699 | (addr[1] << 8) | (addr[0] << 0); |
| 700 | |
| 701 | XGMAC_IOWRITE(pdata, MAC_MACA0HR, mac_addr_hi); |
| 702 | XGMAC_IOWRITE(pdata, MAC_MACA0LR, mac_addr_lo); |
| 703 | |
| 704 | return 0; |
| 705 | } |
| 706 | |
| 707 | static int xgbe_read_mmd_regs(struct xgbe_prv_data *pdata, int prtad, |
| 708 | int mmd_reg) |
| 709 | { |
| 710 | unsigned int mmd_address; |
| 711 | int mmd_data; |
| 712 | |
| 713 | if (mmd_reg & MII_ADDR_C45) |
| 714 | mmd_address = mmd_reg & ~MII_ADDR_C45; |
| 715 | else |
| 716 | mmd_address = (pdata->mdio_mmd << 16) | (mmd_reg & 0xffff); |
| 717 | |
| 718 | /* The PCS registers are accessed using mmio. The underlying APB3 |
| 719 | * management interface uses indirect addressing to access the MMD |
| 720 | * register sets. This requires accessing of the PCS register in two |
| 721 | * phases, an address phase and a data phase. |
| 722 | * |
| 723 | * The mmio interface is based on 32-bit offsets and values. All |
| 724 | * register offsets must therefore be adjusted by left shifting the |
| 725 | * offset 2 bits and reading 32 bits of data. |
| 726 | */ |
| 727 | mutex_lock(&pdata->xpcs_mutex); |
| 728 | XPCS_IOWRITE(pdata, PCS_MMD_SELECT << 2, mmd_address >> 8); |
| 729 | mmd_data = XPCS_IOREAD(pdata, (mmd_address & 0xff) << 2); |
| 730 | mutex_unlock(&pdata->xpcs_mutex); |
| 731 | |
| 732 | return mmd_data; |
| 733 | } |
| 734 | |
| 735 | static void xgbe_write_mmd_regs(struct xgbe_prv_data *pdata, int prtad, |
| 736 | int mmd_reg, int mmd_data) |
| 737 | { |
| 738 | unsigned int mmd_address; |
| 739 | |
| 740 | if (mmd_reg & MII_ADDR_C45) |
| 741 | mmd_address = mmd_reg & ~MII_ADDR_C45; |
| 742 | else |
| 743 | mmd_address = (pdata->mdio_mmd << 16) | (mmd_reg & 0xffff); |
| 744 | |
| 745 | /* The PCS registers are accessed using mmio. The underlying APB3 |
| 746 | * management interface uses indirect addressing to access the MMD |
| 747 | * register sets. This requires accessing of the PCS register in two |
| 748 | * phases, an address phase and a data phase. |
| 749 | * |
| 750 | * The mmio interface is based on 32-bit offsets and values. All |
| 751 | * register offsets must therefore be adjusted by left shifting the |
| 752 | * offset 2 bits and reading 32 bits of data. |
| 753 | */ |
| 754 | mutex_lock(&pdata->xpcs_mutex); |
| 755 | XPCS_IOWRITE(pdata, PCS_MMD_SELECT << 2, mmd_address >> 8); |
| 756 | XPCS_IOWRITE(pdata, (mmd_address & 0xff) << 2, mmd_data); |
| 757 | mutex_unlock(&pdata->xpcs_mutex); |
| 758 | } |
| 759 | |
| 760 | static int xgbe_tx_complete(struct xgbe_ring_desc *rdesc) |
| 761 | { |
| 762 | return !XGMAC_GET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, OWN); |
| 763 | } |
| 764 | |
| 765 | static int xgbe_disable_rx_csum(struct xgbe_prv_data *pdata) |
| 766 | { |
| 767 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, IPC, 0); |
| 768 | |
| 769 | return 0; |
| 770 | } |
| 771 | |
| 772 | static int xgbe_enable_rx_csum(struct xgbe_prv_data *pdata) |
| 773 | { |
| 774 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, IPC, 1); |
| 775 | |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | static int xgbe_enable_rx_vlan_stripping(struct xgbe_prv_data *pdata) |
| 780 | { |
| 781 | /* Put the VLAN tag in the Rx descriptor */ |
| 782 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, EVLRXS, 1); |
| 783 | |
| 784 | /* Don't check the VLAN type */ |
| 785 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, DOVLTC, 1); |
| 786 | |
| 787 | /* Check only C-TAG (0x8100) packets */ |
| 788 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, ERSVLM, 0); |
| 789 | |
| 790 | /* Don't consider an S-TAG (0x88A8) packet as a VLAN packet */ |
| 791 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, ESVL, 0); |
| 792 | |
| 793 | /* Enable VLAN tag stripping */ |
| 794 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, EVLS, 0x3); |
| 795 | |
| 796 | return 0; |
| 797 | } |
| 798 | |
| 799 | static int xgbe_disable_rx_vlan_stripping(struct xgbe_prv_data *pdata) |
| 800 | { |
| 801 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, EVLS, 0); |
| 802 | |
| 803 | return 0; |
| 804 | } |
| 805 | |
Lendacky, Thomas | 801c62d | 2014-06-24 16:19:24 -0500 | [diff] [blame] | 806 | static int xgbe_enable_rx_vlan_filtering(struct xgbe_prv_data *pdata) |
| 807 | { |
| 808 | /* Enable VLAN filtering */ |
| 809 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, VTFE, 1); |
| 810 | |
| 811 | /* Enable VLAN Hash Table filtering */ |
| 812 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, VTHM, 1); |
| 813 | |
| 814 | /* Disable VLAN tag inverse matching */ |
| 815 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, VTIM, 0); |
| 816 | |
| 817 | /* Only filter on the lower 12-bits of the VLAN tag */ |
| 818 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, ETV, 1); |
| 819 | |
| 820 | /* In order for the VLAN Hash Table filtering to be effective, |
| 821 | * the VLAN tag identifier in the VLAN Tag Register must not |
| 822 | * be zero. Set the VLAN tag identifier to "1" to enable the |
| 823 | * VLAN Hash Table filtering. This implies that a VLAN tag of |
| 824 | * 1 will always pass filtering. |
| 825 | */ |
| 826 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANTR, VL, 1); |
| 827 | |
| 828 | return 0; |
| 829 | } |
| 830 | |
| 831 | static int xgbe_disable_rx_vlan_filtering(struct xgbe_prv_data *pdata) |
| 832 | { |
| 833 | /* Disable VLAN filtering */ |
| 834 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, VTFE, 0); |
| 835 | |
| 836 | return 0; |
| 837 | } |
| 838 | |
| 839 | #ifndef CRCPOLY_LE |
| 840 | #define CRCPOLY_LE 0xedb88320 |
| 841 | #endif |
| 842 | static u32 xgbe_vid_crc32_le(__le16 vid_le) |
| 843 | { |
| 844 | u32 poly = CRCPOLY_LE; |
| 845 | u32 crc = ~0; |
| 846 | u32 temp = 0; |
| 847 | unsigned char *data = (unsigned char *)&vid_le; |
| 848 | unsigned char data_byte = 0; |
| 849 | int i, bits; |
| 850 | |
| 851 | bits = get_bitmask_order(VLAN_VID_MASK); |
| 852 | for (i = 0; i < bits; i++) { |
| 853 | if ((i % 8) == 0) |
| 854 | data_byte = data[i / 8]; |
| 855 | |
| 856 | temp = ((crc & 1) ^ data_byte) & 1; |
| 857 | crc >>= 1; |
| 858 | data_byte >>= 1; |
| 859 | |
| 860 | if (temp) |
| 861 | crc ^= poly; |
| 862 | } |
| 863 | |
| 864 | return crc; |
| 865 | } |
| 866 | |
| 867 | static int xgbe_update_vlan_hash_table(struct xgbe_prv_data *pdata) |
| 868 | { |
| 869 | u32 crc; |
| 870 | u16 vid; |
| 871 | __le16 vid_le; |
| 872 | u16 vlan_hash_table = 0; |
| 873 | |
| 874 | /* Generate the VLAN Hash Table value */ |
| 875 | for_each_set_bit(vid, pdata->active_vlans, VLAN_N_VID) { |
| 876 | /* Get the CRC32 value of the VLAN ID */ |
| 877 | vid_le = cpu_to_le16(vid); |
| 878 | crc = bitrev32(~xgbe_vid_crc32_le(vid_le)) >> 28; |
| 879 | |
| 880 | vlan_hash_table |= (1 << crc); |
| 881 | } |
| 882 | |
| 883 | /* Set the VLAN Hash Table filtering register */ |
| 884 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANHTR, VLHT, vlan_hash_table); |
| 885 | |
| 886 | return 0; |
| 887 | } |
| 888 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 889 | static void xgbe_tx_desc_reset(struct xgbe_ring_data *rdata) |
| 890 | { |
| 891 | struct xgbe_ring_desc *rdesc = rdata->rdesc; |
| 892 | |
| 893 | /* Reset the Tx descriptor |
| 894 | * Set buffer 1 (lo) address to zero |
| 895 | * Set buffer 1 (hi) address to zero |
| 896 | * Reset all other control bits (IC, TTSE, B2L & B1L) |
| 897 | * Reset all other control bits (OWN, CTXT, FD, LD, CPC, CIC, etc) |
| 898 | */ |
| 899 | rdesc->desc0 = 0; |
| 900 | rdesc->desc1 = 0; |
| 901 | rdesc->desc2 = 0; |
| 902 | rdesc->desc3 = 0; |
Lendacky, Thomas | 08dcc47 | 2014-11-04 16:06:44 -0600 | [diff] [blame] | 903 | |
| 904 | /* Make sure ownership is written to the descriptor */ |
| 905 | wmb(); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | static void xgbe_tx_desc_init(struct xgbe_channel *channel) |
| 909 | { |
| 910 | struct xgbe_ring *ring = channel->tx_ring; |
| 911 | struct xgbe_ring_data *rdata; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 912 | int i; |
| 913 | int start_index = ring->cur; |
| 914 | |
| 915 | DBGPR("-->tx_desc_init\n"); |
| 916 | |
| 917 | /* Initialze all descriptors */ |
| 918 | for (i = 0; i < ring->rdesc_count; i++) { |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 919 | rdata = XGBE_GET_DESC_DATA(ring, i); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 920 | |
Lendacky, Thomas | 08dcc47 | 2014-11-04 16:06:44 -0600 | [diff] [blame] | 921 | /* Initialize Tx descriptor */ |
| 922 | xgbe_tx_desc_reset(rdata); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 923 | } |
| 924 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 925 | /* Update the total number of Tx descriptors */ |
| 926 | XGMAC_DMA_IOWRITE(channel, DMA_CH_TDRLR, ring->rdesc_count - 1); |
| 927 | |
| 928 | /* Update the starting address of descriptor ring */ |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 929 | rdata = XGBE_GET_DESC_DATA(ring, start_index); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 930 | XGMAC_DMA_IOWRITE(channel, DMA_CH_TDLR_HI, |
| 931 | upper_32_bits(rdata->rdesc_dma)); |
| 932 | XGMAC_DMA_IOWRITE(channel, DMA_CH_TDLR_LO, |
| 933 | lower_32_bits(rdata->rdesc_dma)); |
| 934 | |
| 935 | DBGPR("<--tx_desc_init\n"); |
| 936 | } |
| 937 | |
| 938 | static void xgbe_rx_desc_reset(struct xgbe_ring_data *rdata) |
| 939 | { |
| 940 | struct xgbe_ring_desc *rdesc = rdata->rdesc; |
| 941 | |
| 942 | /* Reset the Rx descriptor |
Lendacky, Thomas | 174fd25 | 2014-11-04 16:06:50 -0600 | [diff] [blame] | 943 | * Set buffer 1 (lo) address to header dma address (lo) |
| 944 | * Set buffer 1 (hi) address to header dma address (hi) |
| 945 | * Set buffer 2 (lo) address to buffer dma address (lo) |
| 946 | * Set buffer 2 (hi) address to buffer dma address (hi) and |
| 947 | * set control bits OWN and INTE |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 948 | */ |
Lendacky, Thomas | 174fd25 | 2014-11-04 16:06:50 -0600 | [diff] [blame] | 949 | rdesc->desc0 = cpu_to_le32(lower_32_bits(rdata->rx_hdr.dma)); |
| 950 | rdesc->desc1 = cpu_to_le32(upper_32_bits(rdata->rx_hdr.dma)); |
| 951 | rdesc->desc2 = cpu_to_le32(lower_32_bits(rdata->rx_buf.dma)); |
| 952 | rdesc->desc3 = cpu_to_le32(upper_32_bits(rdata->rx_buf.dma)); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 953 | |
Lendacky, Thomas | 174fd25 | 2014-11-04 16:06:50 -0600 | [diff] [blame] | 954 | XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, INTE, |
| 955 | rdata->interrupt ? 1 : 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 956 | |
| 957 | /* Since the Rx DMA engine is likely running, make sure everything |
| 958 | * is written to the descriptor(s) before setting the OWN bit |
| 959 | * for the descriptor |
| 960 | */ |
| 961 | wmb(); |
| 962 | |
| 963 | XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, OWN, 1); |
| 964 | |
| 965 | /* Make sure ownership is written to the descriptor */ |
| 966 | wmb(); |
| 967 | } |
| 968 | |
| 969 | static void xgbe_rx_desc_init(struct xgbe_channel *channel) |
| 970 | { |
| 971 | struct xgbe_prv_data *pdata = channel->pdata; |
| 972 | struct xgbe_ring *ring = channel->rx_ring; |
| 973 | struct xgbe_ring_data *rdata; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 974 | unsigned int start_index = ring->cur; |
| 975 | unsigned int rx_coalesce, rx_frames; |
| 976 | unsigned int i; |
| 977 | |
| 978 | DBGPR("-->rx_desc_init\n"); |
| 979 | |
| 980 | rx_coalesce = (pdata->rx_riwt || pdata->rx_frames) ? 1 : 0; |
| 981 | rx_frames = pdata->rx_frames; |
| 982 | |
| 983 | /* Initialize all descriptors */ |
| 984 | for (i = 0; i < ring->rdesc_count; i++) { |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 985 | rdata = XGBE_GET_DESC_DATA(ring, i); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 986 | |
Lendacky, Thomas | 08dcc47 | 2014-11-04 16:06:44 -0600 | [diff] [blame] | 987 | /* Set interrupt on completion bit as appropriate */ |
| 988 | if (rx_coalesce && (!rx_frames || ((i + 1) % rx_frames))) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 989 | rdata->interrupt = 0; |
Lendacky, Thomas | 08dcc47 | 2014-11-04 16:06:44 -0600 | [diff] [blame] | 990 | else |
| 991 | rdata->interrupt = 1; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 992 | |
Lendacky, Thomas | 08dcc47 | 2014-11-04 16:06:44 -0600 | [diff] [blame] | 993 | /* Initialize Rx descriptor */ |
| 994 | xgbe_rx_desc_reset(rdata); |
| 995 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 996 | |
| 997 | /* Update the total number of Rx descriptors */ |
| 998 | XGMAC_DMA_IOWRITE(channel, DMA_CH_RDRLR, ring->rdesc_count - 1); |
| 999 | |
| 1000 | /* Update the starting address of descriptor ring */ |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1001 | rdata = XGBE_GET_DESC_DATA(ring, start_index); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1002 | XGMAC_DMA_IOWRITE(channel, DMA_CH_RDLR_HI, |
| 1003 | upper_32_bits(rdata->rdesc_dma)); |
| 1004 | XGMAC_DMA_IOWRITE(channel, DMA_CH_RDLR_LO, |
| 1005 | lower_32_bits(rdata->rdesc_dma)); |
| 1006 | |
| 1007 | /* Update the Rx Descriptor Tail Pointer */ |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1008 | rdata = XGBE_GET_DESC_DATA(ring, start_index + ring->rdesc_count - 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1009 | XGMAC_DMA_IOWRITE(channel, DMA_CH_RDTR_LO, |
| 1010 | lower_32_bits(rdata->rdesc_dma)); |
| 1011 | |
| 1012 | DBGPR("<--rx_desc_init\n"); |
| 1013 | } |
| 1014 | |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 1015 | static void xgbe_update_tstamp_addend(struct xgbe_prv_data *pdata, |
| 1016 | unsigned int addend) |
| 1017 | { |
| 1018 | /* Set the addend register value and tell the device */ |
| 1019 | XGMAC_IOWRITE(pdata, MAC_TSAR, addend); |
| 1020 | XGMAC_IOWRITE_BITS(pdata, MAC_TSCR, TSADDREG, 1); |
| 1021 | |
| 1022 | /* Wait for addend update to complete */ |
| 1023 | while (XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSADDREG)) |
| 1024 | udelay(5); |
| 1025 | } |
| 1026 | |
| 1027 | static void xgbe_set_tstamp_time(struct xgbe_prv_data *pdata, unsigned int sec, |
| 1028 | unsigned int nsec) |
| 1029 | { |
| 1030 | /* Set the time values and tell the device */ |
| 1031 | XGMAC_IOWRITE(pdata, MAC_STSUR, sec); |
| 1032 | XGMAC_IOWRITE(pdata, MAC_STNUR, nsec); |
| 1033 | XGMAC_IOWRITE_BITS(pdata, MAC_TSCR, TSINIT, 1); |
| 1034 | |
| 1035 | /* Wait for time update to complete */ |
| 1036 | while (XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSINIT)) |
| 1037 | udelay(5); |
| 1038 | } |
| 1039 | |
| 1040 | static u64 xgbe_get_tstamp_time(struct xgbe_prv_data *pdata) |
| 1041 | { |
| 1042 | u64 nsec; |
| 1043 | |
| 1044 | nsec = XGMAC_IOREAD(pdata, MAC_STSR); |
| 1045 | nsec *= NSEC_PER_SEC; |
| 1046 | nsec += XGMAC_IOREAD(pdata, MAC_STNR); |
| 1047 | |
| 1048 | return nsec; |
| 1049 | } |
| 1050 | |
| 1051 | static u64 xgbe_get_tx_tstamp(struct xgbe_prv_data *pdata) |
| 1052 | { |
| 1053 | unsigned int tx_snr; |
| 1054 | u64 nsec; |
| 1055 | |
| 1056 | tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR); |
| 1057 | if (XGMAC_GET_BITS(tx_snr, MAC_TXSNR, TXTSSTSMIS)) |
| 1058 | return 0; |
| 1059 | |
| 1060 | nsec = XGMAC_IOREAD(pdata, MAC_TXSSR); |
| 1061 | nsec *= NSEC_PER_SEC; |
| 1062 | nsec += tx_snr; |
| 1063 | |
| 1064 | return nsec; |
| 1065 | } |
| 1066 | |
| 1067 | static void xgbe_get_rx_tstamp(struct xgbe_packet_data *packet, |
| 1068 | struct xgbe_ring_desc *rdesc) |
| 1069 | { |
| 1070 | u64 nsec; |
| 1071 | |
| 1072 | if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_CONTEXT_DESC3, TSA) && |
| 1073 | !XGMAC_GET_BITS_LE(rdesc->desc3, RX_CONTEXT_DESC3, TSD)) { |
| 1074 | nsec = le32_to_cpu(rdesc->desc1); |
| 1075 | nsec <<= 32; |
| 1076 | nsec |= le32_to_cpu(rdesc->desc0); |
| 1077 | if (nsec != 0xffffffffffffffffULL) { |
| 1078 | packet->rx_tstamp = nsec; |
| 1079 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1080 | RX_TSTAMP, 1); |
| 1081 | } |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | static int xgbe_config_tstamp(struct xgbe_prv_data *pdata, |
| 1086 | unsigned int mac_tscr) |
| 1087 | { |
| 1088 | /* Set one nano-second accuracy */ |
| 1089 | XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSCTRLSSR, 1); |
| 1090 | |
| 1091 | /* Set fine timestamp update */ |
| 1092 | XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSCFUPDT, 1); |
| 1093 | |
| 1094 | /* Overwrite earlier timestamps */ |
| 1095 | XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TXTSSTSM, 1); |
| 1096 | |
| 1097 | XGMAC_IOWRITE(pdata, MAC_TSCR, mac_tscr); |
| 1098 | |
| 1099 | /* Exit if timestamping is not enabled */ |
| 1100 | if (!XGMAC_GET_BITS(mac_tscr, MAC_TSCR, TSENA)) |
| 1101 | return 0; |
| 1102 | |
| 1103 | /* Initialize time registers */ |
| 1104 | XGMAC_IOWRITE_BITS(pdata, MAC_SSIR, SSINC, XGBE_TSTAMP_SSINC); |
| 1105 | XGMAC_IOWRITE_BITS(pdata, MAC_SSIR, SNSINC, XGBE_TSTAMP_SNSINC); |
| 1106 | xgbe_update_tstamp_addend(pdata, pdata->tstamp_addend); |
| 1107 | xgbe_set_tstamp_time(pdata, 0, 0); |
| 1108 | |
| 1109 | /* Initialize the timecounter */ |
| 1110 | timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc, |
| 1111 | ktime_to_ns(ktime_get_real())); |
| 1112 | |
| 1113 | return 0; |
| 1114 | } |
| 1115 | |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1116 | static void xgbe_config_dcb_tc(struct xgbe_prv_data *pdata) |
| 1117 | { |
| 1118 | struct ieee_ets *ets = pdata->ets; |
| 1119 | unsigned int total_weight, min_weight, weight; |
| 1120 | unsigned int i; |
| 1121 | |
| 1122 | if (!ets) |
| 1123 | return; |
| 1124 | |
| 1125 | /* Set Tx to deficit weighted round robin scheduling algorithm (when |
| 1126 | * traffic class is using ETS algorithm) |
| 1127 | */ |
| 1128 | XGMAC_IOWRITE_BITS(pdata, MTL_OMR, ETSALG, MTL_ETSALG_DWRR); |
| 1129 | |
| 1130 | /* Set Traffic Class algorithms */ |
| 1131 | total_weight = pdata->netdev->mtu * pdata->hw_feat.tc_cnt; |
| 1132 | min_weight = total_weight / 100; |
| 1133 | if (!min_weight) |
| 1134 | min_weight = 1; |
| 1135 | |
| 1136 | for (i = 0; i < pdata->hw_feat.tc_cnt; i++) { |
| 1137 | switch (ets->tc_tsa[i]) { |
| 1138 | case IEEE_8021QAZ_TSA_STRICT: |
| 1139 | DBGPR(" TC%u using SP\n", i); |
| 1140 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_ETSCR, TSA, |
| 1141 | MTL_TSA_SP); |
| 1142 | break; |
| 1143 | case IEEE_8021QAZ_TSA_ETS: |
| 1144 | weight = total_weight * ets->tc_tx_bw[i] / 100; |
| 1145 | weight = clamp(weight, min_weight, total_weight); |
| 1146 | |
| 1147 | DBGPR(" TC%u using DWRR (weight %u)\n", i, weight); |
| 1148 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_ETSCR, TSA, |
| 1149 | MTL_TSA_ETS); |
| 1150 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_QWR, QW, |
| 1151 | weight); |
| 1152 | break; |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | static void xgbe_config_dcb_pfc(struct xgbe_prv_data *pdata) |
| 1158 | { |
| 1159 | struct ieee_pfc *pfc = pdata->pfc; |
| 1160 | struct ieee_ets *ets = pdata->ets; |
| 1161 | unsigned int mask, reg, reg_val; |
| 1162 | unsigned int tc, prio; |
| 1163 | |
| 1164 | if (!pfc || !ets) |
| 1165 | return; |
| 1166 | |
| 1167 | for (tc = 0; tc < pdata->hw_feat.tc_cnt; tc++) { |
| 1168 | mask = 0; |
| 1169 | for (prio = 0; prio < IEEE_8021QAZ_MAX_TCS; prio++) { |
| 1170 | if ((pfc->pfc_en & (1 << prio)) && |
| 1171 | (ets->prio_tc[prio] == tc)) |
| 1172 | mask |= (1 << prio); |
| 1173 | } |
| 1174 | mask &= 0xff; |
| 1175 | |
| 1176 | DBGPR(" TC%u PFC mask=%#x\n", tc, mask); |
| 1177 | reg = MTL_TCPM0R + (MTL_TCPM_INC * (tc / MTL_TCPM_TC_PER_REG)); |
| 1178 | reg_val = XGMAC_IOREAD(pdata, reg); |
| 1179 | |
| 1180 | reg_val &= ~(0xff << ((tc % MTL_TCPM_TC_PER_REG) << 3)); |
| 1181 | reg_val |= (mask << ((tc % MTL_TCPM_TC_PER_REG) << 3)); |
| 1182 | |
| 1183 | XGMAC_IOWRITE(pdata, reg, reg_val); |
| 1184 | } |
| 1185 | |
| 1186 | xgbe_config_flow_control(pdata); |
| 1187 | } |
| 1188 | |
Lendacky, Thomas | a9d4198 | 2014-11-04 16:06:32 -0600 | [diff] [blame] | 1189 | static void xgbe_dev_xmit(struct xgbe_channel *channel) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1190 | { |
| 1191 | struct xgbe_prv_data *pdata = channel->pdata; |
| 1192 | struct xgbe_ring *ring = channel->tx_ring; |
| 1193 | struct xgbe_ring_data *rdata; |
| 1194 | struct xgbe_ring_desc *rdesc; |
| 1195 | struct xgbe_packet_data *packet = &ring->packet_data; |
| 1196 | unsigned int csum, tso, vlan; |
| 1197 | unsigned int tso_context, vlan_context; |
| 1198 | unsigned int tx_coalesce, tx_frames; |
| 1199 | int start_index = ring->cur; |
| 1200 | int i; |
| 1201 | |
Lendacky, Thomas | a9d4198 | 2014-11-04 16:06:32 -0600 | [diff] [blame] | 1202 | DBGPR("-->xgbe_dev_xmit\n"); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1203 | |
| 1204 | csum = XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, |
| 1205 | CSUM_ENABLE); |
| 1206 | tso = XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, |
| 1207 | TSO_ENABLE); |
| 1208 | vlan = XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, |
| 1209 | VLAN_CTAG); |
| 1210 | |
| 1211 | if (tso && (packet->mss != ring->tx.cur_mss)) |
| 1212 | tso_context = 1; |
| 1213 | else |
| 1214 | tso_context = 0; |
| 1215 | |
| 1216 | if (vlan && (packet->vlan_ctag != ring->tx.cur_vlan_ctag)) |
| 1217 | vlan_context = 1; |
| 1218 | else |
| 1219 | vlan_context = 0; |
| 1220 | |
| 1221 | tx_coalesce = (pdata->tx_usecs || pdata->tx_frames) ? 1 : 0; |
| 1222 | tx_frames = pdata->tx_frames; |
| 1223 | if (tx_coalesce && !channel->tx_timer_active) |
| 1224 | ring->coalesce_count = 0; |
| 1225 | |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1226 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1227 | rdesc = rdata->rdesc; |
| 1228 | |
| 1229 | /* Create a context descriptor if this is a TSO packet */ |
| 1230 | if (tso_context || vlan_context) { |
| 1231 | if (tso_context) { |
| 1232 | DBGPR(" TSO context descriptor, mss=%u\n", |
| 1233 | packet->mss); |
| 1234 | |
| 1235 | /* Set the MSS size */ |
| 1236 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_CONTEXT_DESC2, |
| 1237 | MSS, packet->mss); |
| 1238 | |
| 1239 | /* Mark it as a CONTEXT descriptor */ |
| 1240 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_CONTEXT_DESC3, |
| 1241 | CTXT, 1); |
| 1242 | |
| 1243 | /* Indicate this descriptor contains the MSS */ |
| 1244 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_CONTEXT_DESC3, |
| 1245 | TCMSSV, 1); |
| 1246 | |
| 1247 | ring->tx.cur_mss = packet->mss; |
| 1248 | } |
| 1249 | |
| 1250 | if (vlan_context) { |
| 1251 | DBGPR(" VLAN context descriptor, ctag=%u\n", |
| 1252 | packet->vlan_ctag); |
| 1253 | |
| 1254 | /* Mark it as a CONTEXT descriptor */ |
| 1255 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_CONTEXT_DESC3, |
| 1256 | CTXT, 1); |
| 1257 | |
| 1258 | /* Set the VLAN tag */ |
| 1259 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_CONTEXT_DESC3, |
| 1260 | VT, packet->vlan_ctag); |
| 1261 | |
| 1262 | /* Indicate this descriptor contains the VLAN tag */ |
| 1263 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_CONTEXT_DESC3, |
| 1264 | VLTV, 1); |
| 1265 | |
| 1266 | ring->tx.cur_vlan_ctag = packet->vlan_ctag; |
| 1267 | } |
| 1268 | |
| 1269 | ring->cur++; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1270 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1271 | rdesc = rdata->rdesc; |
| 1272 | } |
| 1273 | |
| 1274 | /* Update buffer address (for TSO this is the header) */ |
| 1275 | rdesc->desc0 = cpu_to_le32(lower_32_bits(rdata->skb_dma)); |
| 1276 | rdesc->desc1 = cpu_to_le32(upper_32_bits(rdata->skb_dma)); |
| 1277 | |
| 1278 | /* Update the buffer length */ |
| 1279 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, HL_B1L, |
| 1280 | rdata->skb_dma_len); |
| 1281 | |
| 1282 | /* VLAN tag insertion check */ |
| 1283 | if (vlan) |
| 1284 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, VTIR, |
| 1285 | TX_NORMAL_DESC2_VLAN_INSERT); |
| 1286 | |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 1287 | /* Timestamp enablement check */ |
| 1288 | if (XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES, PTP)) |
| 1289 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, TTSE, 1); |
| 1290 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1291 | /* Set IC bit based on Tx coalescing settings */ |
| 1292 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, IC, 1); |
| 1293 | if (tx_coalesce && (!tx_frames || |
| 1294 | (++ring->coalesce_count % tx_frames))) |
| 1295 | /* Clear IC bit */ |
| 1296 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, IC, 0); |
| 1297 | |
| 1298 | /* Mark it as First Descriptor */ |
| 1299 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, FD, 1); |
| 1300 | |
| 1301 | /* Mark it as a NORMAL descriptor */ |
| 1302 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, CTXT, 0); |
| 1303 | |
| 1304 | /* Set OWN bit if not the first descriptor */ |
| 1305 | if (ring->cur != start_index) |
| 1306 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, OWN, 1); |
| 1307 | |
| 1308 | if (tso) { |
| 1309 | /* Enable TSO */ |
| 1310 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, TSE, 1); |
| 1311 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, TCPPL, |
| 1312 | packet->tcp_payload_len); |
| 1313 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, TCPHDRLEN, |
| 1314 | packet->tcp_header_len / 4); |
| 1315 | } else { |
| 1316 | /* Enable CRC and Pad Insertion */ |
| 1317 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, CPC, 0); |
| 1318 | |
| 1319 | /* Enable HW CSUM */ |
| 1320 | if (csum) |
| 1321 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, |
| 1322 | CIC, 0x3); |
| 1323 | |
| 1324 | /* Set the total length to be transmitted */ |
| 1325 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, FL, |
| 1326 | packet->length); |
| 1327 | } |
| 1328 | |
| 1329 | for (i = ring->cur - start_index + 1; i < packet->rdesc_count; i++) { |
| 1330 | ring->cur++; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1331 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1332 | rdesc = rdata->rdesc; |
| 1333 | |
| 1334 | /* Update buffer address */ |
| 1335 | rdesc->desc0 = cpu_to_le32(lower_32_bits(rdata->skb_dma)); |
| 1336 | rdesc->desc1 = cpu_to_le32(upper_32_bits(rdata->skb_dma)); |
| 1337 | |
| 1338 | /* Update the buffer length */ |
| 1339 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, HL_B1L, |
| 1340 | rdata->skb_dma_len); |
| 1341 | |
| 1342 | /* Set IC bit based on Tx coalescing settings */ |
| 1343 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, IC, 1); |
| 1344 | if (tx_coalesce && (!tx_frames || |
| 1345 | (++ring->coalesce_count % tx_frames))) |
| 1346 | /* Clear IC bit */ |
| 1347 | XGMAC_SET_BITS_LE(rdesc->desc2, TX_NORMAL_DESC2, IC, 0); |
| 1348 | |
| 1349 | /* Set OWN bit */ |
| 1350 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, OWN, 1); |
| 1351 | |
| 1352 | /* Mark it as NORMAL descriptor */ |
| 1353 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, CTXT, 0); |
| 1354 | |
| 1355 | /* Enable HW CSUM */ |
| 1356 | if (csum) |
| 1357 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, |
| 1358 | CIC, 0x3); |
| 1359 | } |
| 1360 | |
| 1361 | /* Set LAST bit for the last descriptor */ |
| 1362 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, LD, 1); |
| 1363 | |
| 1364 | /* In case the Tx DMA engine is running, make sure everything |
| 1365 | * is written to the descriptor(s) before setting the OWN bit |
| 1366 | * for the first descriptor |
| 1367 | */ |
| 1368 | wmb(); |
| 1369 | |
| 1370 | /* Set OWN bit for the first descriptor */ |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1371 | rdata = XGBE_GET_DESC_DATA(ring, start_index); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1372 | rdesc = rdata->rdesc; |
| 1373 | XGMAC_SET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, OWN, 1); |
| 1374 | |
| 1375 | #ifdef XGMAC_ENABLE_TX_DESC_DUMP |
| 1376 | xgbe_dump_tx_desc(ring, start_index, packet->rdesc_count, 1); |
| 1377 | #endif |
| 1378 | |
| 1379 | /* Make sure ownership is written to the descriptor */ |
| 1380 | wmb(); |
| 1381 | |
| 1382 | /* Issue a poll command to Tx DMA by writing address |
| 1383 | * of next immediate free descriptor */ |
| 1384 | ring->cur++; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1385 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1386 | XGMAC_DMA_IOWRITE(channel, DMA_CH_TDTR_LO, |
| 1387 | lower_32_bits(rdata->rdesc_dma)); |
| 1388 | |
| 1389 | /* Start the Tx coalescing timer */ |
| 1390 | if (tx_coalesce && !channel->tx_timer_active) { |
| 1391 | channel->tx_timer_active = 1; |
| 1392 | hrtimer_start(&channel->tx_timer, |
| 1393 | ktime_set(0, pdata->tx_usecs * NSEC_PER_USEC), |
| 1394 | HRTIMER_MODE_REL); |
| 1395 | } |
| 1396 | |
| 1397 | DBGPR(" %s: descriptors %u to %u written\n", |
| 1398 | channel->name, start_index & (ring->rdesc_count - 1), |
| 1399 | (ring->cur - 1) & (ring->rdesc_count - 1)); |
| 1400 | |
Lendacky, Thomas | a9d4198 | 2014-11-04 16:06:32 -0600 | [diff] [blame] | 1401 | DBGPR("<--xgbe_dev_xmit\n"); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | static int xgbe_dev_read(struct xgbe_channel *channel) |
| 1405 | { |
| 1406 | struct xgbe_ring *ring = channel->rx_ring; |
| 1407 | struct xgbe_ring_data *rdata; |
| 1408 | struct xgbe_ring_desc *rdesc; |
| 1409 | struct xgbe_packet_data *packet = &ring->packet_data; |
Lendacky, Thomas | c52e9c6 | 2014-06-24 16:19:18 -0500 | [diff] [blame] | 1410 | struct net_device *netdev = channel->pdata->netdev; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1411 | unsigned int err, etlt; |
| 1412 | |
| 1413 | DBGPR("-->xgbe_dev_read: cur = %d\n", ring->cur); |
| 1414 | |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1415 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1416 | rdesc = rdata->rdesc; |
| 1417 | |
| 1418 | /* Check for data availability */ |
| 1419 | if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, OWN)) |
| 1420 | return 1; |
| 1421 | |
| 1422 | #ifdef XGMAC_ENABLE_RX_DESC_DUMP |
| 1423 | xgbe_dump_rx_desc(ring, rdesc, ring->cur); |
| 1424 | #endif |
| 1425 | |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 1426 | if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, CTXT)) { |
| 1427 | /* Timestamp Context Descriptor */ |
| 1428 | xgbe_get_rx_tstamp(packet, rdesc); |
| 1429 | |
| 1430 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1431 | CONTEXT, 1); |
| 1432 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1433 | CONTEXT_NEXT, 0); |
| 1434 | return 0; |
| 1435 | } |
| 1436 | |
| 1437 | /* Normal Descriptor, be sure Context Descriptor bit is off */ |
| 1438 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, CONTEXT, 0); |
| 1439 | |
| 1440 | /* Indicate if a Context Descriptor is next */ |
| 1441 | if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, CDA)) |
| 1442 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1443 | CONTEXT_NEXT, 1); |
| 1444 | |
Lendacky, Thomas | 174fd25 | 2014-11-04 16:06:50 -0600 | [diff] [blame] | 1445 | /* Get the header length */ |
| 1446 | if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, FD)) |
| 1447 | rdata->hdr_len = XGMAC_GET_BITS_LE(rdesc->desc2, |
| 1448 | RX_NORMAL_DESC2, HL); |
| 1449 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1450 | /* Get the packet length */ |
| 1451 | rdata->len = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, PL); |
| 1452 | |
| 1453 | if (!XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, LD)) { |
| 1454 | /* Not all the data has been transferred for this packet */ |
| 1455 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1456 | INCOMPLETE, 1); |
| 1457 | return 0; |
| 1458 | } |
| 1459 | |
| 1460 | /* This is the last of the data for this packet */ |
| 1461 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1462 | INCOMPLETE, 0); |
| 1463 | |
| 1464 | /* Set checksum done indicator as appropriate */ |
| 1465 | if (channel->pdata->netdev->features & NETIF_F_RXCSUM) |
| 1466 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1467 | CSUM_DONE, 1); |
| 1468 | |
| 1469 | /* Check for errors (only valid in last descriptor) */ |
| 1470 | err = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, ES); |
| 1471 | etlt = XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, ETLT); |
| 1472 | DBGPR(" err=%u, etlt=%#x\n", err, etlt); |
| 1473 | |
| 1474 | if (!err || (err && !etlt)) { |
Lendacky, Thomas | c52e9c6 | 2014-06-24 16:19:18 -0500 | [diff] [blame] | 1475 | if ((etlt == 0x09) && |
| 1476 | (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1477 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1478 | VLAN_CTAG, 1); |
| 1479 | packet->vlan_ctag = XGMAC_GET_BITS_LE(rdesc->desc0, |
| 1480 | RX_NORMAL_DESC0, |
| 1481 | OVT); |
| 1482 | DBGPR(" vlan-ctag=0x%04x\n", packet->vlan_ctag); |
| 1483 | } |
| 1484 | } else { |
| 1485 | if ((etlt == 0x05) || (etlt == 0x06)) |
| 1486 | XGMAC_SET_BITS(packet->attributes, RX_PACKET_ATTRIBUTES, |
| 1487 | CSUM_DONE, 0); |
| 1488 | else |
| 1489 | XGMAC_SET_BITS(packet->errors, RX_PACKET_ERRORS, |
| 1490 | FRAME, 1); |
| 1491 | } |
| 1492 | |
| 1493 | DBGPR("<--xgbe_dev_read: %s - descriptor=%u (cur=%d)\n", channel->name, |
| 1494 | ring->cur & (ring->rdesc_count - 1), ring->cur); |
| 1495 | |
| 1496 | return 0; |
| 1497 | } |
| 1498 | |
| 1499 | static int xgbe_is_context_desc(struct xgbe_ring_desc *rdesc) |
| 1500 | { |
| 1501 | /* Rx and Tx share CTXT bit, so check TDES3.CTXT bit */ |
| 1502 | return XGMAC_GET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, CTXT); |
| 1503 | } |
| 1504 | |
| 1505 | static int xgbe_is_last_desc(struct xgbe_ring_desc *rdesc) |
| 1506 | { |
| 1507 | /* Rx and Tx share LD bit, so check TDES3.LD bit */ |
| 1508 | return XGMAC_GET_BITS_LE(rdesc->desc3, TX_NORMAL_DESC3, LD); |
| 1509 | } |
| 1510 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1511 | static int xgbe_enable_int(struct xgbe_channel *channel, |
| 1512 | enum xgbe_int int_id) |
| 1513 | { |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1514 | unsigned int dma_ch_ier; |
| 1515 | |
| 1516 | dma_ch_ier = XGMAC_DMA_IOREAD(channel, DMA_CH_IER); |
| 1517 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1518 | switch (int_id) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1519 | case XGMAC_INT_DMA_CH_SR_TI: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1520 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TIE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1521 | break; |
| 1522 | case XGMAC_INT_DMA_CH_SR_TPS: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1523 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TXSE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1524 | break; |
| 1525 | case XGMAC_INT_DMA_CH_SR_TBU: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1526 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TBUE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1527 | break; |
| 1528 | case XGMAC_INT_DMA_CH_SR_RI: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1529 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RIE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1530 | break; |
| 1531 | case XGMAC_INT_DMA_CH_SR_RBU: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1532 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RBUE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1533 | break; |
| 1534 | case XGMAC_INT_DMA_CH_SR_RPS: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1535 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RSE, 1); |
| 1536 | break; |
| 1537 | case XGMAC_INT_DMA_CH_SR_TI_RI: |
| 1538 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TIE, 1); |
| 1539 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RIE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1540 | break; |
| 1541 | case XGMAC_INT_DMA_CH_SR_FBE: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1542 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, FBEE, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1543 | break; |
| 1544 | case XGMAC_INT_DMA_ALL: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1545 | dma_ch_ier |= channel->saved_ier; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1546 | break; |
| 1547 | default: |
| 1548 | return -1; |
| 1549 | } |
| 1550 | |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1551 | XGMAC_DMA_IOWRITE(channel, DMA_CH_IER, dma_ch_ier); |
| 1552 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1553 | return 0; |
| 1554 | } |
| 1555 | |
| 1556 | static int xgbe_disable_int(struct xgbe_channel *channel, |
| 1557 | enum xgbe_int int_id) |
| 1558 | { |
| 1559 | unsigned int dma_ch_ier; |
| 1560 | |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1561 | dma_ch_ier = XGMAC_DMA_IOREAD(channel, DMA_CH_IER); |
| 1562 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1563 | switch (int_id) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1564 | case XGMAC_INT_DMA_CH_SR_TI: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1565 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TIE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1566 | break; |
| 1567 | case XGMAC_INT_DMA_CH_SR_TPS: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1568 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TXSE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1569 | break; |
| 1570 | case XGMAC_INT_DMA_CH_SR_TBU: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1571 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TBUE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1572 | break; |
| 1573 | case XGMAC_INT_DMA_CH_SR_RI: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1574 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RIE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1575 | break; |
| 1576 | case XGMAC_INT_DMA_CH_SR_RBU: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1577 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RBUE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1578 | break; |
| 1579 | case XGMAC_INT_DMA_CH_SR_RPS: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1580 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RSE, 0); |
| 1581 | break; |
| 1582 | case XGMAC_INT_DMA_CH_SR_TI_RI: |
| 1583 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, TIE, 0); |
| 1584 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, RIE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1585 | break; |
| 1586 | case XGMAC_INT_DMA_CH_SR_FBE: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1587 | XGMAC_SET_BITS(dma_ch_ier, DMA_CH_IER, FBEE, 0); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1588 | break; |
| 1589 | case XGMAC_INT_DMA_ALL: |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1590 | channel->saved_ier = dma_ch_ier & XGBE_DMA_INTERRUPT_MASK; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1591 | dma_ch_ier &= ~XGBE_DMA_INTERRUPT_MASK; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1592 | break; |
| 1593 | default: |
| 1594 | return -1; |
| 1595 | } |
| 1596 | |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1597 | XGMAC_DMA_IOWRITE(channel, DMA_CH_IER, dma_ch_ier); |
| 1598 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1599 | return 0; |
| 1600 | } |
| 1601 | |
| 1602 | static int xgbe_exit(struct xgbe_prv_data *pdata) |
| 1603 | { |
| 1604 | unsigned int count = 2000; |
| 1605 | |
| 1606 | DBGPR("-->xgbe_exit\n"); |
| 1607 | |
| 1608 | /* Issue a software reset */ |
| 1609 | XGMAC_IOWRITE_BITS(pdata, DMA_MR, SWR, 1); |
| 1610 | usleep_range(10, 15); |
| 1611 | |
| 1612 | /* Poll Until Poll Condition */ |
| 1613 | while (count-- && XGMAC_IOREAD_BITS(pdata, DMA_MR, SWR)) |
| 1614 | usleep_range(500, 600); |
| 1615 | |
| 1616 | if (!count) |
| 1617 | return -EBUSY; |
| 1618 | |
| 1619 | DBGPR("<--xgbe_exit\n"); |
| 1620 | |
| 1621 | return 0; |
| 1622 | } |
| 1623 | |
| 1624 | static int xgbe_flush_tx_queues(struct xgbe_prv_data *pdata) |
| 1625 | { |
| 1626 | unsigned int i, count; |
| 1627 | |
Lendacky, Thomas | a9a4a2d | 2014-08-29 13:16:50 -0500 | [diff] [blame] | 1628 | if (XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER) < 0x21) |
| 1629 | return 0; |
| 1630 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1631 | for (i = 0; i < pdata->tx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1632 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, FTQ, 1); |
| 1633 | |
| 1634 | /* Poll Until Poll Condition */ |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1635 | for (i = 0; i < pdata->tx_q_count; i++) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1636 | count = 2000; |
| 1637 | while (count-- && XGMAC_MTL_IOREAD_BITS(pdata, i, |
| 1638 | MTL_Q_TQOMR, FTQ)) |
| 1639 | usleep_range(500, 600); |
| 1640 | |
| 1641 | if (!count) |
| 1642 | return -EBUSY; |
| 1643 | } |
| 1644 | |
| 1645 | return 0; |
| 1646 | } |
| 1647 | |
| 1648 | static void xgbe_config_dma_bus(struct xgbe_prv_data *pdata) |
| 1649 | { |
| 1650 | /* Set enhanced addressing mode */ |
| 1651 | XGMAC_IOWRITE_BITS(pdata, DMA_SBMR, EAME, 1); |
| 1652 | |
| 1653 | /* Set the System Bus mode */ |
| 1654 | XGMAC_IOWRITE_BITS(pdata, DMA_SBMR, UNDEF, 1); |
Lendacky, Thomas | 9867e8f | 2014-07-02 13:04:46 -0500 | [diff] [blame] | 1655 | XGMAC_IOWRITE_BITS(pdata, DMA_SBMR, BLEN_256, 1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1656 | } |
| 1657 | |
| 1658 | static void xgbe_config_dma_cache(struct xgbe_prv_data *pdata) |
| 1659 | { |
| 1660 | unsigned int arcache, awcache; |
| 1661 | |
| 1662 | arcache = 0; |
Lendacky, Thomas | cfa50c7 | 2014-07-02 13:04:57 -0500 | [diff] [blame] | 1663 | XGMAC_SET_BITS(arcache, DMA_AXIARCR, DRC, pdata->arcache); |
| 1664 | XGMAC_SET_BITS(arcache, DMA_AXIARCR, DRD, pdata->axdomain); |
| 1665 | XGMAC_SET_BITS(arcache, DMA_AXIARCR, TEC, pdata->arcache); |
| 1666 | XGMAC_SET_BITS(arcache, DMA_AXIARCR, TED, pdata->axdomain); |
| 1667 | XGMAC_SET_BITS(arcache, DMA_AXIARCR, THC, pdata->arcache); |
| 1668 | XGMAC_SET_BITS(arcache, DMA_AXIARCR, THD, pdata->axdomain); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1669 | XGMAC_IOWRITE(pdata, DMA_AXIARCR, arcache); |
| 1670 | |
| 1671 | awcache = 0; |
Lendacky, Thomas | cfa50c7 | 2014-07-02 13:04:57 -0500 | [diff] [blame] | 1672 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, DWC, pdata->awcache); |
| 1673 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, DWD, pdata->axdomain); |
| 1674 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, RPC, pdata->awcache); |
| 1675 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, RPD, pdata->axdomain); |
| 1676 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, RHC, pdata->awcache); |
| 1677 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, RHD, pdata->axdomain); |
| 1678 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, TDC, pdata->awcache); |
| 1679 | XGMAC_SET_BITS(awcache, DMA_AXIAWCR, TDD, pdata->axdomain); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1680 | XGMAC_IOWRITE(pdata, DMA_AXIAWCR, awcache); |
| 1681 | } |
| 1682 | |
| 1683 | static void xgbe_config_mtl_mode(struct xgbe_prv_data *pdata) |
| 1684 | { |
| 1685 | unsigned int i; |
| 1686 | |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1687 | /* Set Tx to weighted round robin scheduling algorithm */ |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1688 | XGMAC_IOWRITE_BITS(pdata, MTL_OMR, ETSALG, MTL_ETSALG_WRR); |
| 1689 | |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1690 | /* Set Tx traffic classes to use WRR algorithm with equal weights */ |
| 1691 | for (i = 0; i < pdata->hw_feat.tc_cnt; i++) { |
| 1692 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_ETSCR, TSA, |
| 1693 | MTL_TSA_ETS); |
| 1694 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_TC_QWR, QW, 1); |
| 1695 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1696 | |
| 1697 | /* Set Rx to strict priority algorithm */ |
| 1698 | XGMAC_IOWRITE_BITS(pdata, MTL_OMR, RAA, MTL_RAA_SP); |
| 1699 | } |
| 1700 | |
Lendacky, Thomas | f076f45 | 2014-08-29 13:16:56 -0500 | [diff] [blame] | 1701 | static unsigned int xgbe_calculate_per_queue_fifo(unsigned int fifo_size, |
| 1702 | unsigned int queue_count) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1703 | { |
| 1704 | unsigned int q_fifo_size = 0; |
| 1705 | enum xgbe_mtl_fifo_size p_fifo = XGMAC_MTL_FIFO_SIZE_256; |
| 1706 | |
| 1707 | /* Calculate Tx/Rx fifo share per queue */ |
| 1708 | switch (fifo_size) { |
| 1709 | case 0: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1710 | q_fifo_size = XGBE_FIFO_SIZE_B(128); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1711 | break; |
| 1712 | case 1: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1713 | q_fifo_size = XGBE_FIFO_SIZE_B(256); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1714 | break; |
| 1715 | case 2: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1716 | q_fifo_size = XGBE_FIFO_SIZE_B(512); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1717 | break; |
| 1718 | case 3: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1719 | q_fifo_size = XGBE_FIFO_SIZE_KB(1); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1720 | break; |
| 1721 | case 4: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1722 | q_fifo_size = XGBE_FIFO_SIZE_KB(2); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1723 | break; |
| 1724 | case 5: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1725 | q_fifo_size = XGBE_FIFO_SIZE_KB(4); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1726 | break; |
| 1727 | case 6: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1728 | q_fifo_size = XGBE_FIFO_SIZE_KB(8); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1729 | break; |
| 1730 | case 7: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1731 | q_fifo_size = XGBE_FIFO_SIZE_KB(16); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1732 | break; |
| 1733 | case 8: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1734 | q_fifo_size = XGBE_FIFO_SIZE_KB(32); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1735 | break; |
| 1736 | case 9: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1737 | q_fifo_size = XGBE_FIFO_SIZE_KB(64); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1738 | break; |
| 1739 | case 10: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1740 | q_fifo_size = XGBE_FIFO_SIZE_KB(128); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1741 | break; |
| 1742 | case 11: |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1743 | q_fifo_size = XGBE_FIFO_SIZE_KB(256); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1744 | break; |
| 1745 | } |
Lendacky, Thomas | f076f45 | 2014-08-29 13:16:56 -0500 | [diff] [blame] | 1746 | |
| 1747 | /* The configured value is not the actual amount of fifo RAM */ |
| 1748 | q_fifo_size = min_t(unsigned int, XGBE_FIFO_MAX, q_fifo_size); |
| 1749 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1750 | q_fifo_size = q_fifo_size / queue_count; |
| 1751 | |
| 1752 | /* Set the queue fifo size programmable value */ |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1753 | if (q_fifo_size >= XGBE_FIFO_SIZE_KB(256)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1754 | p_fifo = XGMAC_MTL_FIFO_SIZE_256K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1755 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(128)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1756 | p_fifo = XGMAC_MTL_FIFO_SIZE_128K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1757 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(64)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1758 | p_fifo = XGMAC_MTL_FIFO_SIZE_64K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1759 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(32)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1760 | p_fifo = XGMAC_MTL_FIFO_SIZE_32K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1761 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(16)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1762 | p_fifo = XGMAC_MTL_FIFO_SIZE_16K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1763 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(8)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1764 | p_fifo = XGMAC_MTL_FIFO_SIZE_8K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1765 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(4)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1766 | p_fifo = XGMAC_MTL_FIFO_SIZE_4K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1767 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(2)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1768 | p_fifo = XGMAC_MTL_FIFO_SIZE_2K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1769 | else if (q_fifo_size >= XGBE_FIFO_SIZE_KB(1)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1770 | p_fifo = XGMAC_MTL_FIFO_SIZE_1K; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1771 | else if (q_fifo_size >= XGBE_FIFO_SIZE_B(512)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1772 | p_fifo = XGMAC_MTL_FIFO_SIZE_512; |
Lendacky, Thomas | d0a8ba6 | 2014-06-24 16:19:06 -0500 | [diff] [blame] | 1773 | else if (q_fifo_size >= XGBE_FIFO_SIZE_B(256)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1774 | p_fifo = XGMAC_MTL_FIFO_SIZE_256; |
| 1775 | |
| 1776 | return p_fifo; |
| 1777 | } |
| 1778 | |
| 1779 | static void xgbe_config_tx_fifo_size(struct xgbe_prv_data *pdata) |
| 1780 | { |
| 1781 | enum xgbe_mtl_fifo_size fifo_size; |
| 1782 | unsigned int i; |
| 1783 | |
| 1784 | fifo_size = xgbe_calculate_per_queue_fifo(pdata->hw_feat.tx_fifo_size, |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1785 | pdata->tx_q_count); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1786 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1787 | for (i = 0; i < pdata->tx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1788 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TQS, fifo_size); |
| 1789 | |
| 1790 | netdev_notice(pdata->netdev, "%d Tx queues, %d byte fifo per queue\n", |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1791 | pdata->tx_q_count, ((fifo_size + 1) * 256)); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1792 | } |
| 1793 | |
| 1794 | static void xgbe_config_rx_fifo_size(struct xgbe_prv_data *pdata) |
| 1795 | { |
| 1796 | enum xgbe_mtl_fifo_size fifo_size; |
| 1797 | unsigned int i; |
| 1798 | |
| 1799 | fifo_size = xgbe_calculate_per_queue_fifo(pdata->hw_feat.rx_fifo_size, |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1800 | pdata->rx_q_count); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1801 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1802 | for (i = 0; i < pdata->rx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1803 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RQS, fifo_size); |
| 1804 | |
| 1805 | netdev_notice(pdata->netdev, "%d Rx queues, %d byte fifo per queue\n", |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1806 | pdata->rx_q_count, ((fifo_size + 1) * 256)); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1807 | } |
| 1808 | |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1809 | static void xgbe_config_queue_mapping(struct xgbe_prv_data *pdata) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1810 | { |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1811 | unsigned int qptc, qptc_extra, queue; |
| 1812 | unsigned int prio_queues; |
| 1813 | unsigned int ppq, ppq_extra, prio; |
| 1814 | unsigned int mask; |
| 1815 | unsigned int i, j, reg, reg_val; |
| 1816 | |
| 1817 | /* Map the MTL Tx Queues to Traffic Classes |
| 1818 | * Note: Tx Queues >= Traffic Classes |
| 1819 | */ |
| 1820 | qptc = pdata->tx_q_count / pdata->hw_feat.tc_cnt; |
| 1821 | qptc_extra = pdata->tx_q_count % pdata->hw_feat.tc_cnt; |
| 1822 | |
| 1823 | for (i = 0, queue = 0; i < pdata->hw_feat.tc_cnt; i++) { |
| 1824 | for (j = 0; j < qptc; j++) { |
| 1825 | DBGPR(" TXq%u mapped to TC%u\n", queue, i); |
| 1826 | XGMAC_MTL_IOWRITE_BITS(pdata, queue, MTL_Q_TQOMR, |
| 1827 | Q2TCMAP, i); |
| 1828 | pdata->q2tc_map[queue++] = i; |
| 1829 | } |
| 1830 | |
| 1831 | if (i < qptc_extra) { |
| 1832 | DBGPR(" TXq%u mapped to TC%u\n", queue, i); |
| 1833 | XGMAC_MTL_IOWRITE_BITS(pdata, queue, MTL_Q_TQOMR, |
| 1834 | Q2TCMAP, i); |
| 1835 | pdata->q2tc_map[queue++] = i; |
| 1836 | } |
| 1837 | } |
| 1838 | |
| 1839 | /* Map the 8 VLAN priority values to available MTL Rx queues */ |
| 1840 | prio_queues = min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, |
| 1841 | pdata->rx_q_count); |
| 1842 | ppq = IEEE_8021QAZ_MAX_TCS / prio_queues; |
| 1843 | ppq_extra = IEEE_8021QAZ_MAX_TCS % prio_queues; |
| 1844 | |
| 1845 | reg = MAC_RQC2R; |
| 1846 | reg_val = 0; |
| 1847 | for (i = 0, prio = 0; i < prio_queues;) { |
| 1848 | mask = 0; |
| 1849 | for (j = 0; j < ppq; j++) { |
| 1850 | DBGPR(" PRIO%u mapped to RXq%u\n", prio, i); |
| 1851 | mask |= (1 << prio); |
| 1852 | pdata->prio2q_map[prio++] = i; |
| 1853 | } |
| 1854 | |
| 1855 | if (i < ppq_extra) { |
| 1856 | DBGPR(" PRIO%u mapped to RXq%u\n", prio, i); |
| 1857 | mask |= (1 << prio); |
| 1858 | pdata->prio2q_map[prio++] = i; |
| 1859 | } |
| 1860 | |
| 1861 | reg_val |= (mask << ((i++ % MAC_RQC2_Q_PER_REG) << 3)); |
| 1862 | |
| 1863 | if ((i % MAC_RQC2_Q_PER_REG) && (i != prio_queues)) |
| 1864 | continue; |
| 1865 | |
| 1866 | XGMAC_IOWRITE(pdata, reg, reg_val); |
| 1867 | reg += MAC_RQC2_INC; |
| 1868 | reg_val = 0; |
| 1869 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1870 | |
| 1871 | /* Select dynamic mapping of MTL Rx queue to DMA Rx channel */ |
| 1872 | reg = MTL_RQDCM0R; |
| 1873 | reg_val = 0; |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1874 | for (i = 0; i < pdata->rx_q_count;) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1875 | reg_val |= (0x80 << ((i++ % MTL_RQDCM_Q_PER_REG) << 3)); |
| 1876 | |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 1877 | if ((i % MTL_RQDCM_Q_PER_REG) && (i != pdata->rx_q_count)) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1878 | continue; |
| 1879 | |
| 1880 | XGMAC_IOWRITE(pdata, reg, reg_val); |
| 1881 | |
| 1882 | reg += MTL_RQDCM_INC; |
| 1883 | reg_val = 0; |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | static void xgbe_config_flow_control_threshold(struct xgbe_prv_data *pdata) |
| 1888 | { |
| 1889 | unsigned int i; |
| 1890 | |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 1891 | for (i = 0; i < pdata->rx_q_count; i++) { |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1892 | /* Activate flow control when less than 4k left in fifo */ |
| 1893 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RFA, 2); |
| 1894 | |
| 1895 | /* De-activate flow control when more than 6k left in fifo */ |
| 1896 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RFD, 4); |
| 1897 | } |
| 1898 | } |
| 1899 | |
| 1900 | static void xgbe_config_mac_address(struct xgbe_prv_data *pdata) |
| 1901 | { |
| 1902 | xgbe_set_mac_address(pdata, pdata->netdev->dev_addr); |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 1903 | |
| 1904 | /* Filtering is done using perfect filtering and hash filtering */ |
| 1905 | if (pdata->hw_feat.hash_table_size) { |
| 1906 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, HPF, 1); |
| 1907 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, HUC, 1); |
| 1908 | XGMAC_IOWRITE_BITS(pdata, MAC_PFR, HMC, 1); |
| 1909 | } |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1910 | } |
| 1911 | |
| 1912 | static void xgbe_config_jumbo_enable(struct xgbe_prv_data *pdata) |
| 1913 | { |
| 1914 | unsigned int val; |
| 1915 | |
| 1916 | val = (pdata->netdev->mtu > XGMAC_STD_PACKET_MTU) ? 1 : 0; |
| 1917 | |
| 1918 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, JE, val); |
| 1919 | } |
| 1920 | |
| 1921 | static void xgbe_config_checksum_offload(struct xgbe_prv_data *pdata) |
| 1922 | { |
| 1923 | if (pdata->netdev->features & NETIF_F_RXCSUM) |
| 1924 | xgbe_enable_rx_csum(pdata); |
| 1925 | else |
| 1926 | xgbe_disable_rx_csum(pdata); |
| 1927 | } |
| 1928 | |
| 1929 | static void xgbe_config_vlan_support(struct xgbe_prv_data *pdata) |
| 1930 | { |
Lendacky, Thomas | 6e5eed0 | 2014-06-24 16:19:12 -0500 | [diff] [blame] | 1931 | /* Indicate that VLAN Tx CTAGs come from context descriptors */ |
| 1932 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANIR, CSVL, 0); |
| 1933 | XGMAC_IOWRITE_BITS(pdata, MAC_VLANIR, VLTI, 1); |
| 1934 | |
Lendacky, Thomas | 801c62d | 2014-06-24 16:19:24 -0500 | [diff] [blame] | 1935 | /* Set the current VLAN Hash Table register value */ |
| 1936 | xgbe_update_vlan_hash_table(pdata); |
| 1937 | |
| 1938 | if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER) |
| 1939 | xgbe_enable_rx_vlan_filtering(pdata); |
| 1940 | else |
| 1941 | xgbe_disable_rx_vlan_filtering(pdata); |
| 1942 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1943 | if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) |
| 1944 | xgbe_enable_rx_vlan_stripping(pdata); |
| 1945 | else |
| 1946 | xgbe_disable_rx_vlan_stripping(pdata); |
| 1947 | } |
| 1948 | |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 1949 | static u64 xgbe_mmc_read(struct xgbe_prv_data *pdata, unsigned int reg_lo) |
| 1950 | { |
| 1951 | bool read_hi; |
| 1952 | u64 val; |
| 1953 | |
| 1954 | switch (reg_lo) { |
| 1955 | /* These registers are always 64 bit */ |
| 1956 | case MMC_TXOCTETCOUNT_GB_LO: |
| 1957 | case MMC_TXOCTETCOUNT_G_LO: |
| 1958 | case MMC_RXOCTETCOUNT_GB_LO: |
| 1959 | case MMC_RXOCTETCOUNT_G_LO: |
| 1960 | read_hi = true; |
| 1961 | break; |
| 1962 | |
| 1963 | default: |
| 1964 | read_hi = false; |
| 1965 | }; |
| 1966 | |
| 1967 | val = XGMAC_IOREAD(pdata, reg_lo); |
| 1968 | |
| 1969 | if (read_hi) |
| 1970 | val |= ((u64)XGMAC_IOREAD(pdata, reg_lo + 4) << 32); |
| 1971 | |
| 1972 | return val; |
| 1973 | } |
| 1974 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1975 | static void xgbe_tx_mmc_int(struct xgbe_prv_data *pdata) |
| 1976 | { |
| 1977 | struct xgbe_mmc_stats *stats = &pdata->mmc_stats; |
| 1978 | unsigned int mmc_isr = XGMAC_IOREAD(pdata, MMC_TISR); |
| 1979 | |
| 1980 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXOCTETCOUNT_GB)) |
| 1981 | stats->txoctetcount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 1982 | xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1983 | |
| 1984 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXFRAMECOUNT_GB)) |
| 1985 | stats->txframecount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 1986 | xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1987 | |
| 1988 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXBROADCASTFRAMES_G)) |
| 1989 | stats->txbroadcastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 1990 | xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1991 | |
| 1992 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXMULTICASTFRAMES_G)) |
| 1993 | stats->txmulticastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 1994 | xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1995 | |
| 1996 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TX64OCTETS_GB)) |
| 1997 | stats->tx64octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 1998 | xgbe_mmc_read(pdata, MMC_TX64OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 1999 | |
| 2000 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TX65TO127OCTETS_GB)) |
| 2001 | stats->tx65to127octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2002 | xgbe_mmc_read(pdata, MMC_TX65TO127OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2003 | |
| 2004 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TX128TO255OCTETS_GB)) |
| 2005 | stats->tx128to255octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2006 | xgbe_mmc_read(pdata, MMC_TX128TO255OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2007 | |
| 2008 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TX256TO511OCTETS_GB)) |
| 2009 | stats->tx256to511octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2010 | xgbe_mmc_read(pdata, MMC_TX256TO511OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2011 | |
| 2012 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TX512TO1023OCTETS_GB)) |
| 2013 | stats->tx512to1023octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2014 | xgbe_mmc_read(pdata, MMC_TX512TO1023OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2015 | |
| 2016 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TX1024TOMAXOCTETS_GB)) |
| 2017 | stats->tx1024tomaxoctets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2018 | xgbe_mmc_read(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2019 | |
| 2020 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXUNICASTFRAMES_GB)) |
| 2021 | stats->txunicastframes_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2022 | xgbe_mmc_read(pdata, MMC_TXUNICASTFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2023 | |
| 2024 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXMULTICASTFRAMES_GB)) |
| 2025 | stats->txmulticastframes_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2026 | xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2027 | |
| 2028 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXBROADCASTFRAMES_GB)) |
| 2029 | stats->txbroadcastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2030 | xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2031 | |
| 2032 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXUNDERFLOWERROR)) |
| 2033 | stats->txunderflowerror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2034 | xgbe_mmc_read(pdata, MMC_TXUNDERFLOWERROR_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2035 | |
| 2036 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXOCTETCOUNT_G)) |
| 2037 | stats->txoctetcount_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2038 | xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2039 | |
| 2040 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXFRAMECOUNT_G)) |
| 2041 | stats->txframecount_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2042 | xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2043 | |
| 2044 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXPAUSEFRAMES)) |
| 2045 | stats->txpauseframes += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2046 | xgbe_mmc_read(pdata, MMC_TXPAUSEFRAMES_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2047 | |
| 2048 | if (XGMAC_GET_BITS(mmc_isr, MMC_TISR, TXVLANFRAMES_G)) |
| 2049 | stats->txvlanframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2050 | xgbe_mmc_read(pdata, MMC_TXVLANFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2051 | } |
| 2052 | |
| 2053 | static void xgbe_rx_mmc_int(struct xgbe_prv_data *pdata) |
| 2054 | { |
| 2055 | struct xgbe_mmc_stats *stats = &pdata->mmc_stats; |
| 2056 | unsigned int mmc_isr = XGMAC_IOREAD(pdata, MMC_RISR); |
| 2057 | |
| 2058 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXFRAMECOUNT_GB)) |
| 2059 | stats->rxframecount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2060 | xgbe_mmc_read(pdata, MMC_RXFRAMECOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2061 | |
| 2062 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXOCTETCOUNT_GB)) |
| 2063 | stats->rxoctetcount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2064 | xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2065 | |
| 2066 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXOCTETCOUNT_G)) |
| 2067 | stats->rxoctetcount_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2068 | xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2069 | |
| 2070 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXBROADCASTFRAMES_G)) |
| 2071 | stats->rxbroadcastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2072 | xgbe_mmc_read(pdata, MMC_RXBROADCASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2073 | |
| 2074 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXMULTICASTFRAMES_G)) |
| 2075 | stats->rxmulticastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2076 | xgbe_mmc_read(pdata, MMC_RXMULTICASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2077 | |
| 2078 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXCRCERROR)) |
| 2079 | stats->rxcrcerror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2080 | xgbe_mmc_read(pdata, MMC_RXCRCERROR_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2081 | |
| 2082 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXRUNTERROR)) |
| 2083 | stats->rxrunterror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2084 | xgbe_mmc_read(pdata, MMC_RXRUNTERROR); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2085 | |
| 2086 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXJABBERERROR)) |
| 2087 | stats->rxjabbererror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2088 | xgbe_mmc_read(pdata, MMC_RXJABBERERROR); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2089 | |
| 2090 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXUNDERSIZE_G)) |
| 2091 | stats->rxundersize_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2092 | xgbe_mmc_read(pdata, MMC_RXUNDERSIZE_G); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2093 | |
| 2094 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXOVERSIZE_G)) |
| 2095 | stats->rxoversize_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2096 | xgbe_mmc_read(pdata, MMC_RXOVERSIZE_G); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2097 | |
| 2098 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RX64OCTETS_GB)) |
| 2099 | stats->rx64octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2100 | xgbe_mmc_read(pdata, MMC_RX64OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2101 | |
| 2102 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RX65TO127OCTETS_GB)) |
| 2103 | stats->rx65to127octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2104 | xgbe_mmc_read(pdata, MMC_RX65TO127OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2105 | |
| 2106 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RX128TO255OCTETS_GB)) |
| 2107 | stats->rx128to255octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2108 | xgbe_mmc_read(pdata, MMC_RX128TO255OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2109 | |
| 2110 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RX256TO511OCTETS_GB)) |
| 2111 | stats->rx256to511octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2112 | xgbe_mmc_read(pdata, MMC_RX256TO511OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2113 | |
| 2114 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RX512TO1023OCTETS_GB)) |
| 2115 | stats->rx512to1023octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2116 | xgbe_mmc_read(pdata, MMC_RX512TO1023OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2117 | |
| 2118 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RX1024TOMAXOCTETS_GB)) |
| 2119 | stats->rx1024tomaxoctets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2120 | xgbe_mmc_read(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2121 | |
| 2122 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXUNICASTFRAMES_G)) |
| 2123 | stats->rxunicastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2124 | xgbe_mmc_read(pdata, MMC_RXUNICASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2125 | |
| 2126 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXLENGTHERROR)) |
| 2127 | stats->rxlengtherror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2128 | xgbe_mmc_read(pdata, MMC_RXLENGTHERROR_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2129 | |
| 2130 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXOUTOFRANGETYPE)) |
| 2131 | stats->rxoutofrangetype += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2132 | xgbe_mmc_read(pdata, MMC_RXOUTOFRANGETYPE_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2133 | |
| 2134 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXPAUSEFRAMES)) |
| 2135 | stats->rxpauseframes += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2136 | xgbe_mmc_read(pdata, MMC_RXPAUSEFRAMES_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2137 | |
| 2138 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXFIFOOVERFLOW)) |
| 2139 | stats->rxfifooverflow += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2140 | xgbe_mmc_read(pdata, MMC_RXFIFOOVERFLOW_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2141 | |
| 2142 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXVLANFRAMES_GB)) |
| 2143 | stats->rxvlanframes_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2144 | xgbe_mmc_read(pdata, MMC_RXVLANFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2145 | |
| 2146 | if (XGMAC_GET_BITS(mmc_isr, MMC_RISR, RXWATCHDOGERROR)) |
| 2147 | stats->rxwatchdogerror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2148 | xgbe_mmc_read(pdata, MMC_RXWATCHDOGERROR); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | static void xgbe_read_mmc_stats(struct xgbe_prv_data *pdata) |
| 2152 | { |
| 2153 | struct xgbe_mmc_stats *stats = &pdata->mmc_stats; |
| 2154 | |
| 2155 | /* Freeze counters */ |
| 2156 | XGMAC_IOWRITE_BITS(pdata, MMC_CR, MCF, 1); |
| 2157 | |
| 2158 | stats->txoctetcount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2159 | xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2160 | |
| 2161 | stats->txframecount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2162 | xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2163 | |
| 2164 | stats->txbroadcastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2165 | xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2166 | |
| 2167 | stats->txmulticastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2168 | xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2169 | |
| 2170 | stats->tx64octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2171 | xgbe_mmc_read(pdata, MMC_TX64OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2172 | |
| 2173 | stats->tx65to127octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2174 | xgbe_mmc_read(pdata, MMC_TX65TO127OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2175 | |
| 2176 | stats->tx128to255octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2177 | xgbe_mmc_read(pdata, MMC_TX128TO255OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2178 | |
| 2179 | stats->tx256to511octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2180 | xgbe_mmc_read(pdata, MMC_TX256TO511OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2181 | |
| 2182 | stats->tx512to1023octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2183 | xgbe_mmc_read(pdata, MMC_TX512TO1023OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2184 | |
| 2185 | stats->tx1024tomaxoctets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2186 | xgbe_mmc_read(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2187 | |
| 2188 | stats->txunicastframes_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2189 | xgbe_mmc_read(pdata, MMC_TXUNICASTFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2190 | |
| 2191 | stats->txmulticastframes_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2192 | xgbe_mmc_read(pdata, MMC_TXMULTICASTFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2193 | |
| 2194 | stats->txbroadcastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2195 | xgbe_mmc_read(pdata, MMC_TXBROADCASTFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2196 | |
| 2197 | stats->txunderflowerror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2198 | xgbe_mmc_read(pdata, MMC_TXUNDERFLOWERROR_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2199 | |
| 2200 | stats->txoctetcount_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2201 | xgbe_mmc_read(pdata, MMC_TXOCTETCOUNT_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2202 | |
| 2203 | stats->txframecount_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2204 | xgbe_mmc_read(pdata, MMC_TXFRAMECOUNT_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2205 | |
| 2206 | stats->txpauseframes += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2207 | xgbe_mmc_read(pdata, MMC_TXPAUSEFRAMES_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2208 | |
| 2209 | stats->txvlanframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2210 | xgbe_mmc_read(pdata, MMC_TXVLANFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2211 | |
| 2212 | stats->rxframecount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2213 | xgbe_mmc_read(pdata, MMC_RXFRAMECOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2214 | |
| 2215 | stats->rxoctetcount_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2216 | xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2217 | |
| 2218 | stats->rxoctetcount_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2219 | xgbe_mmc_read(pdata, MMC_RXOCTETCOUNT_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2220 | |
| 2221 | stats->rxbroadcastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2222 | xgbe_mmc_read(pdata, MMC_RXBROADCASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2223 | |
| 2224 | stats->rxmulticastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2225 | xgbe_mmc_read(pdata, MMC_RXMULTICASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2226 | |
| 2227 | stats->rxcrcerror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2228 | xgbe_mmc_read(pdata, MMC_RXCRCERROR_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2229 | |
| 2230 | stats->rxrunterror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2231 | xgbe_mmc_read(pdata, MMC_RXRUNTERROR); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2232 | |
| 2233 | stats->rxjabbererror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2234 | xgbe_mmc_read(pdata, MMC_RXJABBERERROR); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2235 | |
| 2236 | stats->rxundersize_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2237 | xgbe_mmc_read(pdata, MMC_RXUNDERSIZE_G); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2238 | |
| 2239 | stats->rxoversize_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2240 | xgbe_mmc_read(pdata, MMC_RXOVERSIZE_G); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2241 | |
| 2242 | stats->rx64octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2243 | xgbe_mmc_read(pdata, MMC_RX64OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2244 | |
| 2245 | stats->rx65to127octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2246 | xgbe_mmc_read(pdata, MMC_RX65TO127OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2247 | |
| 2248 | stats->rx128to255octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2249 | xgbe_mmc_read(pdata, MMC_RX128TO255OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2250 | |
| 2251 | stats->rx256to511octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2252 | xgbe_mmc_read(pdata, MMC_RX256TO511OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2253 | |
| 2254 | stats->rx512to1023octets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2255 | xgbe_mmc_read(pdata, MMC_RX512TO1023OCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2256 | |
| 2257 | stats->rx1024tomaxoctets_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2258 | xgbe_mmc_read(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2259 | |
| 2260 | stats->rxunicastframes_g += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2261 | xgbe_mmc_read(pdata, MMC_RXUNICASTFRAMES_G_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2262 | |
| 2263 | stats->rxlengtherror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2264 | xgbe_mmc_read(pdata, MMC_RXLENGTHERROR_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2265 | |
| 2266 | stats->rxoutofrangetype += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2267 | xgbe_mmc_read(pdata, MMC_RXOUTOFRANGETYPE_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2268 | |
| 2269 | stats->rxpauseframes += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2270 | xgbe_mmc_read(pdata, MMC_RXPAUSEFRAMES_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2271 | |
| 2272 | stats->rxfifooverflow += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2273 | xgbe_mmc_read(pdata, MMC_RXFIFOOVERFLOW_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2274 | |
| 2275 | stats->rxvlanframes_gb += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2276 | xgbe_mmc_read(pdata, MMC_RXVLANFRAMES_GB_LO); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2277 | |
| 2278 | stats->rxwatchdogerror += |
Lendacky, Thomas | 6026510 | 2014-09-05 18:02:30 -0500 | [diff] [blame] | 2279 | xgbe_mmc_read(pdata, MMC_RXWATCHDOGERROR); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2280 | |
| 2281 | /* Un-freeze counters */ |
| 2282 | XGMAC_IOWRITE_BITS(pdata, MMC_CR, MCF, 0); |
| 2283 | } |
| 2284 | |
| 2285 | static void xgbe_config_mmc(struct xgbe_prv_data *pdata) |
| 2286 | { |
| 2287 | /* Set counters to reset on read */ |
| 2288 | XGMAC_IOWRITE_BITS(pdata, MMC_CR, ROR, 1); |
| 2289 | |
| 2290 | /* Reset the counters */ |
| 2291 | XGMAC_IOWRITE_BITS(pdata, MMC_CR, CR, 1); |
| 2292 | } |
| 2293 | |
| 2294 | static void xgbe_enable_tx(struct xgbe_prv_data *pdata) |
| 2295 | { |
| 2296 | struct xgbe_channel *channel; |
| 2297 | unsigned int i; |
| 2298 | |
| 2299 | /* Enable each Tx DMA channel */ |
| 2300 | channel = pdata->channel; |
| 2301 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2302 | if (!channel->tx_ring) |
| 2303 | break; |
| 2304 | |
| 2305 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, ST, 1); |
| 2306 | } |
| 2307 | |
| 2308 | /* Enable each Tx queue */ |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 2309 | for (i = 0; i < pdata->tx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2310 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TXQEN, |
| 2311 | MTL_Q_ENABLED); |
| 2312 | |
| 2313 | /* Enable MAC Tx */ |
| 2314 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 1); |
| 2315 | } |
| 2316 | |
| 2317 | static void xgbe_disable_tx(struct xgbe_prv_data *pdata) |
| 2318 | { |
| 2319 | struct xgbe_channel *channel; |
| 2320 | unsigned int i; |
| 2321 | |
| 2322 | /* Disable MAC Tx */ |
| 2323 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 0); |
| 2324 | |
| 2325 | /* Disable each Tx queue */ |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 2326 | for (i = 0; i < pdata->tx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2327 | XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TXQEN, 0); |
| 2328 | |
| 2329 | /* Disable each Tx DMA channel */ |
| 2330 | channel = pdata->channel; |
| 2331 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2332 | if (!channel->tx_ring) |
| 2333 | break; |
| 2334 | |
| 2335 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, ST, 0); |
| 2336 | } |
| 2337 | } |
| 2338 | |
| 2339 | static void xgbe_enable_rx(struct xgbe_prv_data *pdata) |
| 2340 | { |
| 2341 | struct xgbe_channel *channel; |
| 2342 | unsigned int reg_val, i; |
| 2343 | |
| 2344 | /* Enable each Rx DMA channel */ |
| 2345 | channel = pdata->channel; |
| 2346 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2347 | if (!channel->rx_ring) |
| 2348 | break; |
| 2349 | |
| 2350 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RCR, SR, 1); |
| 2351 | } |
| 2352 | |
| 2353 | /* Enable each Rx queue */ |
| 2354 | reg_val = 0; |
Lendacky, Thomas | 853eb16 | 2014-07-29 08:57:31 -0500 | [diff] [blame] | 2355 | for (i = 0; i < pdata->rx_q_count; i++) |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2356 | reg_val |= (0x02 << (i << 1)); |
| 2357 | XGMAC_IOWRITE(pdata, MAC_RQC0R, reg_val); |
| 2358 | |
| 2359 | /* Enable MAC Rx */ |
| 2360 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 1); |
| 2361 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 1); |
| 2362 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 1); |
| 2363 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 1); |
| 2364 | } |
| 2365 | |
| 2366 | static void xgbe_disable_rx(struct xgbe_prv_data *pdata) |
| 2367 | { |
| 2368 | struct xgbe_channel *channel; |
| 2369 | unsigned int i; |
| 2370 | |
| 2371 | /* Disable MAC Rx */ |
| 2372 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 0); |
| 2373 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 0); |
| 2374 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 0); |
| 2375 | XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 0); |
| 2376 | |
| 2377 | /* Disable each Rx queue */ |
| 2378 | XGMAC_IOWRITE(pdata, MAC_RQC0R, 0); |
| 2379 | |
| 2380 | /* Disable each Rx DMA channel */ |
| 2381 | channel = pdata->channel; |
| 2382 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2383 | if (!channel->rx_ring) |
| 2384 | break; |
| 2385 | |
| 2386 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RCR, SR, 0); |
| 2387 | } |
| 2388 | } |
| 2389 | |
| 2390 | static void xgbe_powerup_tx(struct xgbe_prv_data *pdata) |
| 2391 | { |
| 2392 | struct xgbe_channel *channel; |
| 2393 | unsigned int i; |
| 2394 | |
| 2395 | /* Enable each Tx DMA channel */ |
| 2396 | channel = pdata->channel; |
| 2397 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2398 | if (!channel->tx_ring) |
| 2399 | break; |
| 2400 | |
| 2401 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, ST, 1); |
| 2402 | } |
| 2403 | |
| 2404 | /* Enable MAC Tx */ |
| 2405 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 1); |
| 2406 | } |
| 2407 | |
| 2408 | static void xgbe_powerdown_tx(struct xgbe_prv_data *pdata) |
| 2409 | { |
| 2410 | struct xgbe_channel *channel; |
| 2411 | unsigned int i; |
| 2412 | |
| 2413 | /* Disable MAC Tx */ |
| 2414 | XGMAC_IOWRITE_BITS(pdata, MAC_TCR, TE, 0); |
| 2415 | |
| 2416 | /* Disable each Tx DMA channel */ |
| 2417 | channel = pdata->channel; |
| 2418 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2419 | if (!channel->tx_ring) |
| 2420 | break; |
| 2421 | |
| 2422 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_TCR, ST, 0); |
| 2423 | } |
| 2424 | } |
| 2425 | |
| 2426 | static void xgbe_powerup_rx(struct xgbe_prv_data *pdata) |
| 2427 | { |
| 2428 | struct xgbe_channel *channel; |
| 2429 | unsigned int i; |
| 2430 | |
| 2431 | /* Enable each Rx DMA channel */ |
| 2432 | channel = pdata->channel; |
| 2433 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2434 | if (!channel->rx_ring) |
| 2435 | break; |
| 2436 | |
| 2437 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RCR, SR, 1); |
| 2438 | } |
| 2439 | } |
| 2440 | |
| 2441 | static void xgbe_powerdown_rx(struct xgbe_prv_data *pdata) |
| 2442 | { |
| 2443 | struct xgbe_channel *channel; |
| 2444 | unsigned int i; |
| 2445 | |
| 2446 | /* Disable each Rx DMA channel */ |
| 2447 | channel = pdata->channel; |
| 2448 | for (i = 0; i < pdata->channel_count; i++, channel++) { |
| 2449 | if (!channel->rx_ring) |
| 2450 | break; |
| 2451 | |
| 2452 | XGMAC_DMA_IOWRITE_BITS(channel, DMA_CH_RCR, SR, 0); |
| 2453 | } |
| 2454 | } |
| 2455 | |
| 2456 | static int xgbe_init(struct xgbe_prv_data *pdata) |
| 2457 | { |
| 2458 | struct xgbe_desc_if *desc_if = &pdata->desc_if; |
| 2459 | int ret; |
| 2460 | |
| 2461 | DBGPR("-->xgbe_init\n"); |
| 2462 | |
| 2463 | /* Flush Tx queues */ |
| 2464 | ret = xgbe_flush_tx_queues(pdata); |
| 2465 | if (ret) |
| 2466 | return ret; |
| 2467 | |
| 2468 | /* |
| 2469 | * Initialize DMA related features |
| 2470 | */ |
| 2471 | xgbe_config_dma_bus(pdata); |
| 2472 | xgbe_config_dma_cache(pdata); |
| 2473 | xgbe_config_osp_mode(pdata); |
| 2474 | xgbe_config_pblx8(pdata); |
| 2475 | xgbe_config_tx_pbl_val(pdata); |
| 2476 | xgbe_config_rx_pbl_val(pdata); |
| 2477 | xgbe_config_rx_coalesce(pdata); |
| 2478 | xgbe_config_tx_coalesce(pdata); |
| 2479 | xgbe_config_rx_buffer_size(pdata); |
| 2480 | xgbe_config_tso_mode(pdata); |
Lendacky, Thomas | 174fd25 | 2014-11-04 16:06:50 -0600 | [diff] [blame] | 2481 | xgbe_config_sph_mode(pdata); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2482 | desc_if->wrapper_tx_desc_init(pdata); |
| 2483 | desc_if->wrapper_rx_desc_init(pdata); |
| 2484 | xgbe_enable_dma_interrupts(pdata); |
| 2485 | |
| 2486 | /* |
| 2487 | * Initialize MTL related features |
| 2488 | */ |
| 2489 | xgbe_config_mtl_mode(pdata); |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 2490 | xgbe_config_queue_mapping(pdata); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2491 | xgbe_config_tsf_mode(pdata, pdata->tx_sf_mode); |
| 2492 | xgbe_config_rsf_mode(pdata, pdata->rx_sf_mode); |
| 2493 | xgbe_config_tx_threshold(pdata, pdata->tx_threshold); |
| 2494 | xgbe_config_rx_threshold(pdata, pdata->rx_threshold); |
| 2495 | xgbe_config_tx_fifo_size(pdata); |
| 2496 | xgbe_config_rx_fifo_size(pdata); |
| 2497 | xgbe_config_flow_control_threshold(pdata); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2498 | /*TODO: Error Packet and undersized good Packet forwarding enable |
| 2499 | (FEP and FUP) |
| 2500 | */ |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 2501 | xgbe_config_dcb_tc(pdata); |
| 2502 | xgbe_config_dcb_pfc(pdata); |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2503 | xgbe_enable_mtl_interrupts(pdata); |
| 2504 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2505 | /* |
| 2506 | * Initialize MAC related features |
| 2507 | */ |
| 2508 | xgbe_config_mac_address(pdata); |
| 2509 | xgbe_config_jumbo_enable(pdata); |
| 2510 | xgbe_config_flow_control(pdata); |
| 2511 | xgbe_config_checksum_offload(pdata); |
| 2512 | xgbe_config_vlan_support(pdata); |
| 2513 | xgbe_config_mmc(pdata); |
| 2514 | xgbe_enable_mac_interrupts(pdata); |
| 2515 | |
| 2516 | DBGPR("<--xgbe_init\n"); |
| 2517 | |
| 2518 | return 0; |
| 2519 | } |
| 2520 | |
| 2521 | void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if) |
| 2522 | { |
| 2523 | DBGPR("-->xgbe_init_function_ptrs\n"); |
| 2524 | |
| 2525 | hw_if->tx_complete = xgbe_tx_complete; |
| 2526 | |
| 2527 | hw_if->set_promiscuous_mode = xgbe_set_promiscuous_mode; |
| 2528 | hw_if->set_all_multicast_mode = xgbe_set_all_multicast_mode; |
Lendacky, Thomas | b85e4d8 | 2014-06-24 16:19:29 -0500 | [diff] [blame] | 2529 | hw_if->add_mac_addresses = xgbe_add_mac_addresses; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2530 | hw_if->set_mac_address = xgbe_set_mac_address; |
| 2531 | |
| 2532 | hw_if->enable_rx_csum = xgbe_enable_rx_csum; |
| 2533 | hw_if->disable_rx_csum = xgbe_disable_rx_csum; |
| 2534 | |
| 2535 | hw_if->enable_rx_vlan_stripping = xgbe_enable_rx_vlan_stripping; |
| 2536 | hw_if->disable_rx_vlan_stripping = xgbe_disable_rx_vlan_stripping; |
Lendacky, Thomas | 801c62d | 2014-06-24 16:19:24 -0500 | [diff] [blame] | 2537 | hw_if->enable_rx_vlan_filtering = xgbe_enable_rx_vlan_filtering; |
| 2538 | hw_if->disable_rx_vlan_filtering = xgbe_disable_rx_vlan_filtering; |
| 2539 | hw_if->update_vlan_hash_table = xgbe_update_vlan_hash_table; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2540 | |
| 2541 | hw_if->read_mmd_regs = xgbe_read_mmd_regs; |
| 2542 | hw_if->write_mmd_regs = xgbe_write_mmd_regs; |
| 2543 | |
| 2544 | hw_if->set_gmii_speed = xgbe_set_gmii_speed; |
| 2545 | hw_if->set_gmii_2500_speed = xgbe_set_gmii_2500_speed; |
| 2546 | hw_if->set_xgmii_speed = xgbe_set_xgmii_speed; |
| 2547 | |
| 2548 | hw_if->enable_tx = xgbe_enable_tx; |
| 2549 | hw_if->disable_tx = xgbe_disable_tx; |
| 2550 | hw_if->enable_rx = xgbe_enable_rx; |
| 2551 | hw_if->disable_rx = xgbe_disable_rx; |
| 2552 | |
| 2553 | hw_if->powerup_tx = xgbe_powerup_tx; |
| 2554 | hw_if->powerdown_tx = xgbe_powerdown_tx; |
| 2555 | hw_if->powerup_rx = xgbe_powerup_rx; |
| 2556 | hw_if->powerdown_rx = xgbe_powerdown_rx; |
| 2557 | |
Lendacky, Thomas | a9d4198 | 2014-11-04 16:06:32 -0600 | [diff] [blame] | 2558 | hw_if->dev_xmit = xgbe_dev_xmit; |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2559 | hw_if->dev_read = xgbe_dev_read; |
| 2560 | hw_if->enable_int = xgbe_enable_int; |
| 2561 | hw_if->disable_int = xgbe_disable_int; |
| 2562 | hw_if->init = xgbe_init; |
| 2563 | hw_if->exit = xgbe_exit; |
| 2564 | |
| 2565 | /* Descriptor related Sequences have to be initialized here */ |
| 2566 | hw_if->tx_desc_init = xgbe_tx_desc_init; |
| 2567 | hw_if->rx_desc_init = xgbe_rx_desc_init; |
| 2568 | hw_if->tx_desc_reset = xgbe_tx_desc_reset; |
| 2569 | hw_if->rx_desc_reset = xgbe_rx_desc_reset; |
| 2570 | hw_if->is_last_desc = xgbe_is_last_desc; |
| 2571 | hw_if->is_context_desc = xgbe_is_context_desc; |
| 2572 | |
| 2573 | /* For FLOW ctrl */ |
| 2574 | hw_if->config_tx_flow_control = xgbe_config_tx_flow_control; |
| 2575 | hw_if->config_rx_flow_control = xgbe_config_rx_flow_control; |
| 2576 | |
| 2577 | /* For RX coalescing */ |
| 2578 | hw_if->config_rx_coalesce = xgbe_config_rx_coalesce; |
| 2579 | hw_if->config_tx_coalesce = xgbe_config_tx_coalesce; |
| 2580 | hw_if->usec_to_riwt = xgbe_usec_to_riwt; |
| 2581 | hw_if->riwt_to_usec = xgbe_riwt_to_usec; |
| 2582 | |
| 2583 | /* For RX and TX threshold config */ |
| 2584 | hw_if->config_rx_threshold = xgbe_config_rx_threshold; |
| 2585 | hw_if->config_tx_threshold = xgbe_config_tx_threshold; |
| 2586 | |
| 2587 | /* For RX and TX Store and Forward Mode config */ |
| 2588 | hw_if->config_rsf_mode = xgbe_config_rsf_mode; |
| 2589 | hw_if->config_tsf_mode = xgbe_config_tsf_mode; |
| 2590 | |
| 2591 | /* For TX DMA Operating on Second Frame config */ |
| 2592 | hw_if->config_osp_mode = xgbe_config_osp_mode; |
| 2593 | |
| 2594 | /* For RX and TX PBL config */ |
| 2595 | hw_if->config_rx_pbl_val = xgbe_config_rx_pbl_val; |
| 2596 | hw_if->get_rx_pbl_val = xgbe_get_rx_pbl_val; |
| 2597 | hw_if->config_tx_pbl_val = xgbe_config_tx_pbl_val; |
| 2598 | hw_if->get_tx_pbl_val = xgbe_get_tx_pbl_val; |
| 2599 | hw_if->config_pblx8 = xgbe_config_pblx8; |
| 2600 | |
| 2601 | /* For MMC statistics support */ |
| 2602 | hw_if->tx_mmc_int = xgbe_tx_mmc_int; |
| 2603 | hw_if->rx_mmc_int = xgbe_rx_mmc_int; |
| 2604 | hw_if->read_mmc_stats = xgbe_read_mmc_stats; |
| 2605 | |
Lendacky, Thomas | 23e4eef | 2014-07-29 08:57:19 -0500 | [diff] [blame] | 2606 | /* For PTP config */ |
| 2607 | hw_if->config_tstamp = xgbe_config_tstamp; |
| 2608 | hw_if->update_tstamp_addend = xgbe_update_tstamp_addend; |
| 2609 | hw_if->set_tstamp_time = xgbe_set_tstamp_time; |
| 2610 | hw_if->get_tstamp_time = xgbe_get_tstamp_time; |
| 2611 | hw_if->get_tx_tstamp = xgbe_get_tx_tstamp; |
| 2612 | |
Lendacky, Thomas | fca2d99 | 2014-07-29 08:57:55 -0500 | [diff] [blame] | 2613 | /* For Data Center Bridging config */ |
| 2614 | hw_if->config_dcb_tc = xgbe_config_dcb_tc; |
| 2615 | hw_if->config_dcb_pfc = xgbe_config_dcb_pfc; |
| 2616 | |
Lendacky, Thomas | c5aa9e3 | 2014-06-05 09:15:06 -0500 | [diff] [blame] | 2617 | DBGPR("<--xgbe_init_function_ptrs\n"); |
| 2618 | } |