/*1* AMD 10Gb Ethernet driver2*3* Copyright (c) 2014-2016,2020 Advanced Micro Devices, Inc.4*5* This file is available to you under your choice of the following two6* licenses:7*8* License 1: GPLv29*10* This file is free software; you may copy, redistribute and/or modify11* it under the terms of the GNU General Public License as published by12* the Free Software Foundation, either version 2 of the License, or (at13* your option) any later version.14*15* This file is distributed in the hope that it will be useful, but16* WITHOUT ANY WARRANTY; without even the implied warranty of17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU18* General Public License for more details.19*20* You should have received a copy of the GNU General Public License21* along with this program. If not, see <http://www.gnu.org/licenses/>.22*23* This file incorporates work covered by the following copyright and24* permission notice:25* The Synopsys DWC ETHER XGMAC Software Driver and documentation26* (hereinafter "Software") is an unsupported proprietary work of Synopsys,27* Inc. unless otherwise expressly agreed to in writing between Synopsys28* and you.29*30* The Software IS NOT an item of Licensed Software or Licensed Product31* under any End User Software License Agreement or Agreement for Licensed32* Product with Synopsys or any supplement thereto. Permission is hereby33* granted, free of charge, to any person obtaining a copy of this software34* annotated with this license and the Software, to deal in the Software35* without restriction, including without limitation the rights to use,36* copy, modify, merge, publish, distribute, sublicense, and/or sell copies37* of the Software, and to permit persons to whom the Software is furnished38* to do so, subject to the following conditions:39*40* The above copyright notice and this permission notice shall be included41* in all copies or substantial portions of the Software.42*43* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"44* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED45* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A46* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS47* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR48* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF49* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS50* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN51* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)52* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF53* THE POSSIBILITY OF SUCH DAMAGE.54*55*56* License 2: Modified BSD57*58* Redistribution and use in source and binary forms, with or without59* modification, are permitted provided that the following conditions are met:60* * Redistributions of source code must retain the above copyright61* notice, this list of conditions and the following disclaimer.62* * Redistributions in binary form must reproduce the above copyright63* notice, this list of conditions and the following disclaimer in the64* documentation and/or other materials provided with the distribution.65* * Neither the name of Advanced Micro Devices, Inc. nor the66* names of its contributors may be used to endorse or promote products67* derived from this software without specific prior written permission.68*69* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"70* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE71* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE72* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY73* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES74* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;75* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND76* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT77* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF78* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.79*80* This file incorporates work covered by the following copyright and81* permission notice:82* The Synopsys DWC ETHER XGMAC Software Driver and documentation83* (hereinafter "Software") is an unsupported proprietary work of Synopsys,84* Inc. unless otherwise expressly agreed to in writing between Synopsys85* and you.86*87* The Software IS NOT an item of Licensed Software or Licensed Product88* under any End User Software License Agreement or Agreement for Licensed89* Product with Synopsys or any supplement thereto. Permission is hereby90* granted, free of charge, to any person obtaining a copy of this software91* annotated with this license and the Software, to deal in the Software92* without restriction, including without limitation the rights to use,93* copy, modify, merge, publish, distribute, sublicense, and/or sell copies94* of the Software, and to permit persons to whom the Software is furnished95* to do so, subject to the following conditions:96*97* The above copyright notice and this permission notice shall be included98* in all copies or substantial portions of the Software.99*100* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"101* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED102* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A103* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS104* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR105* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF106* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS107* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN108* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)109* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF110* THE POSSIBILITY OF SUCH DAMAGE.111*/112113#include <sys/cdefs.h>114#include "xgbe.h"115#include "xgbe-common.h"116117static void118xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)119{120struct xgbe_hw_if *hw_if = &pdata->hw_if;121struct xgbe_channel *channel;122struct xgbe_ring *ring;123struct xgbe_ring_data *rdata;124struct xgbe_ring_desc *rdesc;125bus_addr_t rdesc_paddr;126unsigned int i, j;127128DBGPR("-->xgbe_wrapper_tx_descriptor_init\n");129130for (i = 0; i < pdata->channel_count; i++) {131132channel = pdata->channel[i];133134ring = channel->tx_ring;135if (!ring)136break;137138rdesc = ring->rdesc;139rdesc_paddr = ring->rdesc_paddr;140141for (j = 0; j < ring->rdesc_count; j++) {142rdata = XGBE_GET_DESC_DATA(ring, j);143144rdata->rdesc = rdesc;145rdata->rdata_paddr = rdesc_paddr;146147rdesc++;148rdesc_paddr += sizeof(struct xgbe_ring_desc);149}150151ring->cur = 0;152ring->dirty = 0;153memset(&ring->tx, 0, sizeof(ring->tx));154155hw_if->tx_desc_init(channel);156}157158DBGPR("<--xgbe_wrapper_tx_descriptor_init\n");159}160161static void162xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)163{164struct xgbe_hw_if *hw_if = &pdata->hw_if;165struct xgbe_channel *channel;166struct xgbe_ring *ring;167struct xgbe_ring_desc *rdesc;168struct xgbe_ring_data *rdata;169bus_addr_t rdesc_paddr;170unsigned int i, j;171172DBGPR("-->xgbe_wrapper_rx_descriptor_init\n");173174for (i = 0; i < pdata->channel_count; i++) {175176channel = pdata->channel[i];177178ring = channel->rx_ring;179if (!ring)180break;181182rdesc = ring->rdesc;183rdesc_paddr = ring->rdesc_paddr;184185for (j = 0; j < ring->rdesc_count; j++) {186rdata = XGBE_GET_DESC_DATA(ring, j);187188rdata->rdesc = rdesc;189rdata->rdata_paddr = rdesc_paddr;190191rdesc++;192rdesc_paddr += sizeof(struct xgbe_ring_desc);193}194195ring->cur = 0;196ring->dirty = 0;197198hw_if->rx_desc_init(channel);199}200}201202void203xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if)204{205206desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init;207desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init;208}209210211